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); } + + - - \ No newline at end of file From 3eebaf3fb1c1affc1c9abf7687b1d1ee826eb175 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 18 Apr 2014 14:27:34 +0800 Subject: [PATCH 0027/1564] Remove modify the sample --- template/index.html | 47 +-------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/template/index.html b/template/index.html index 9b98730a5f..a5e02d13d4 100644 --- a/template/index.html +++ b/template/index.html @@ -20,52 +20,7 @@ } - + From f2b30a6e1499593f27f8a449b6488e4e18d13d1a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 21 Apr 2014 11:25:26 +0800 Subject: [PATCH 0028/1564] Fixed: correct the mistake of CCBoot.js that renderMode default value is wrong. --- CCBoot.js | 8 +++++--- cocos2d/core/labelttf/CCLabelTTF.js | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index a8b9937c72..e17dd35e02 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -553,7 +553,7 @@ cc.loader = { cb = option; var img = new Image(); - if (opt.isCrossOrigin) + if (opt.isCrossOrigin && location.origin != "file://") img.crossOrigin = "Anonymous"; cc._addEventListener(img, "load", function () { @@ -1502,9 +1502,11 @@ cc.game = { var self = this, CONFIG_KEY = self.CONFIG_KEY; var _init = function (cfg) { cfg[CONFIG_KEY.engineDir] = cfg[CONFIG_KEY.engineDir] || "frameworks/cocos2d-html5"; - cfg[CONFIG_KEY.debugMode] = cfg[CONFIG_KEY.debugMode] || 0; + if(cfg[CONFIG_KEY.debugMode] == null) + cfg[CONFIG_KEY.debugMode] = 0; cfg[CONFIG_KEY.frameRate] = cfg[CONFIG_KEY.frameRate] || 60; - cfg[CONFIG_KEY.renderMode] = cfg[CONFIG_KEY.renderMode] || 1; + if(cfg[CONFIG_KEY.renderMode] == null) + cfg[CONFIG_KEY.renderMode] = 1; return cfg; }; if (document["ccConfig"]) { diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 79106064a6..e09b5d3898 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1181,7 +1181,6 @@ document.body ? cc._addEventListener(window, 'load', function () { this.removeEventListener('load', arguments.callee, false); document.body.appendChild(cc.LabelTTF.__labelHeightDiv); - console.log(1); }, false); From 5cdff4335dcbcf5cde9df7f40816fa71deccb582 Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 21 Apr 2014 14:52:24 +0800 Subject: [PATCH 0029/1564] fixed #4914:add cc.AnimationFrame.create and refactor ctor --- cocos2d/core/sprites/CCAnimation.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index 41ac829eb9..967523f82f 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -40,8 +40,19 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ _delayPerUnit:0, _userInfo:null, - ctor:function () { + /** + * @constructor + * @param spriteFrame + * @param delayUnits + * @param userInfo + * @returns {AnimationFrame} + */ + ctor:function (spriteFrame, delayUnits, userInfo) { this._delayPerUnit = 0; + if(userInfo !== undefined) + { + this.initWithSpriteFrame(spriteFrame,delayUnits,userInfo); + } }, clone: function(){ @@ -123,6 +134,18 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ } }); +/** + * Creates an animation frame. + * @param {cc.SpriteFrame} spriteFrame + * @param {Number} delayUnits + * @param {object} userInfo + * @example + * + */ +cc.AnimationFrame.create = function(spriteFrame,delayUnits,userInfo){ + return new cc.AnimationFrame(spriteFrame,delayUnits,userInfo); +}; + /** *

* A cc.Animation object is used to perform animations on the cc.Sprite objects.
From d4150c2e37736c4b37afe61038966b029a8a4f02 Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 21 Apr 2014 15:03:04 +0800 Subject: [PATCH 0030/1564] fix ctor --- cocos2d/core/sprites/CCAnimation.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index 967523f82f..e330a24a19 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -49,10 +49,9 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ */ ctor:function (spriteFrame, delayUnits, userInfo) { this._delayPerUnit = 0; - if(userInfo !== undefined) - { - this.initWithSpriteFrame(spriteFrame,delayUnits,userInfo); - } + this._spriteFrame = spriteFrame || null; + this._delayPerUnit = delayUnits || null; + this._userInfo = userInfo || null; }, clone: function(){ From 10390b8e135d72012111e09fb49dbc9e26055f85 Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 21 Apr 2014 15:05:20 +0800 Subject: [PATCH 0031/1564] fix bug --- cocos2d/core/sprites/CCAnimation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index e330a24a19..1694557852 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -50,7 +50,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ ctor:function (spriteFrame, delayUnits, userInfo) { this._delayPerUnit = 0; this._spriteFrame = spriteFrame || null; - this._delayPerUnit = delayUnits || null; + this._delayPerUnit = delayUnits || 0; this._userInfo = userInfo || null; }, From 6b9a2eb293ae64fabf801981190b9e0a2ec933ea Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 21 Apr 2014 15:06:26 +0800 Subject: [PATCH 0032/1564] fix bug --- cocos2d/core/sprites/CCAnimation.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index 1694557852..ea72c13e01 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -48,7 +48,6 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ * @returns {AnimationFrame} */ ctor:function (spriteFrame, delayUnits, userInfo) { - this._delayPerUnit = 0; this._spriteFrame = spriteFrame || null; this._delayPerUnit = delayUnits || 0; this._userInfo = userInfo || null; From 8f507301c99974c54d935e51e42270e7f1bd810b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 21 Apr 2014 15:49:52 +0800 Subject: [PATCH 0033/1564] Fix a bug that cc.path.dirname --- CCBoot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index a8b9937c72..78ab6f0070 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -276,11 +276,12 @@ cc.path = { * @example cc.path.driname("a/b/c.png");//-->"a/b" cc.path.driname("a/b/c.png?a=1&b=2");//-->"a/b" + cc.path.dirname("c.png");//-->"" * @param {string} pathStr * @returns {*} */ dirname: function (pathStr) { - return pathStr.replace(/(\/|\\\\)$/, "").replace(/(\/|\\\\)[^(\/|\\\\)]+$/, ""); + return pathStr.replace(/((.*)\/)?(.*?\..*$)/, '$2'); }, /** From d5cb733152ba053eb9903f6a1a5bc1addc7bede4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 21 Apr 2014 16:06:56 +0800 Subject: [PATCH 0034/1564] Fix a bug that cc.path.dirname --- CCBoot.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 78ab6f0070..01979851b4 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -274,14 +274,18 @@ cc.path = { /** * Get ext name of a file path. * @example + * unix cc.path.driname("a/b/c.png");//-->"a/b" cc.path.driname("a/b/c.png?a=1&b=2");//-->"a/b" cc.path.dirname("c.png");//-->"" + * windows + cc.path.driname("a\\b\\c.png");//-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2");//-->"a\b" * @param {string} pathStr * @returns {*} */ dirname: function (pathStr) { - return pathStr.replace(/((.*)\/)?(.*?\..*$)/, '$2'); + return pathStr.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)/, '$2'); }, /** From 8dffa86d6ade6827f60fd792595e9da879e010e8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 21 Apr 2014 16:49:58 +0800 Subject: [PATCH 0035/1564] Fix a bug that cc.path.dirname --- CCBoot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 01979851b4..054d31f7c2 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -277,6 +277,7 @@ cc.path = { * unix cc.path.driname("a/b/c.png");//-->"a/b" cc.path.driname("a/b/c.png?a=1&b=2");//-->"a/b" + cc.path.dirname("a/b/");//-->"a/b" cc.path.dirname("c.png");//-->"" * windows cc.path.driname("a\\b\\c.png");//-->"a\b" @@ -285,7 +286,7 @@ cc.path = { * @returns {*} */ dirname: function (pathStr) { - return pathStr.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)/, '$2'); + return pathStr.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, '$2'); }, /** From 67f05439d94de02b9cc22509fdb84c579f49bd94 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 21 Apr 2014 17:30:39 +0800 Subject: [PATCH 0036/1564] Modify the annotation --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 054d31f7c2..6d8fc81335 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -272,7 +272,7 @@ cc.path = { }, /** - * Get ext name of a file path. + * Get dirname of a file path. * @example * unix cc.path.driname("a/b/c.png");//-->"a/b" From fa5835570ed2eaad36932e16fac45fe914a06384 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 21 Apr 2014 18:13:46 +0800 Subject: [PATCH 0037/1564] Fix a bug that after the compression error --- cocos2d/text-input/CCIMEDispatcher.js | 7 ++++++- tools/build.xml | 27 +++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index 07727f5e36..fa970e8b7a 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -515,4 +515,9 @@ cc.IMEDispatcher.Impl = cc.Class.extend(/** @lends cc.IMEDispatcher.Impl# */{ // Initialize imeDispatcher singleton cc.imeDispatcher = new cc.IMEDispatcher(); -cc.imeDispatcher.init(); \ No newline at end of file + +document.body ? + cc.imeDispatcher.init() : + cc._addEventListener(window, 'load', function () { + cc.imeDispatcher.init(); + }, false); \ No newline at end of file diff --git a/tools/build.xml b/tools/build.xml index 7069c5466c..d7ceeec1b0 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -15,13 +15,13 @@ + - @@ -34,28 +34,28 @@ - - + + + + - - - + + + - - @@ -63,6 +63,7 @@ + @@ -271,6 +272,16 @@ + From 96944aa704da23dc1921389e0927781abb06caf9 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 22 Apr 2014 16:28:07 +0800 Subject: [PATCH 0038/1564] Fixed: add inputExtension to build.xml --- tools/build.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/build.xml b/tools/build.xml index 7069c5466c..57ae79f9b5 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -26,6 +26,7 @@ + @@ -230,7 +231,7 @@ - @@ -271,6 +272,19 @@ + + From c6b65012c850f15e8e592bebcf227321da7e0050 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 22 Apr 2014 16:45:36 +0800 Subject: [PATCH 0039/1564] Fixed : modify compilationLevel from "whitespace" to "simple" --- tools/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build.xml b/tools/build.xml index 4b123a9b6f..4b90ba6875 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -232,7 +232,7 @@ - From afd371e5d48bf4c811f786abacd1244550baf39e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 22 Apr 2014 18:37:31 +0800 Subject: [PATCH 0040/1564] Closed #4919: fixed a bug of ccui.Layout that its scaleX, scaleY value is wrong in draw function --- extensions/ccui/layouts/UILayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 356f39e9af..8518cef628 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -115,10 +115,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _initStencilForCanvas: function () { this._clippingStencil = cc.DrawNode.create(); - var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); var locContext = cc._renderContext; var stencil = this._clippingStencil; stencil.draw = function () { + var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); for (var i = 0; i < stencil._buffer.length; i++) { var element = stencil._buffer[i]; var vertices = element.verts; From d7a6ce149caf4ff9a675ca58ca46aa7d2b3efb14 Mon Sep 17 00:00:00 2001 From: NatWeiss Date: Wed, 23 Apr 2014 09:20:01 -0700 Subject: [PATCH 0041/1564] Fixes bug in stopMusic() In Chrome, it can take a few seconds for the `ended` property of music to become `false`. Therefore if one plays music, then immediately stops the music, `_stopAudio` can silently fail and then `stopMusic` mistakenly sets `_currMusic` to `null`, which leaves the music playing and no way to stop it. The problem is compounded if this situation is repeated. There can be many music tracks playing and it slows down the browser tremendously. This pull request fixes the bug by verifying that `_stopAudio` worked. --- cocos2d/audio/CCAudio.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 2c11b66c59..ffd13484aa 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -342,7 +342,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (this._musicPlayState > 0) { var audio = this._currMusic; if (!audio) return; - this._stopAudio(audio); + if (!this._stopAudio(audio)) return; if (releaseData) cc.loader.release(this._currMusicPath); this._currMusic = null; this._currMusicPath = null; @@ -358,7 +358,9 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ audio.pause(); audio.duration && (audio.currentTime = audio.duration); } + return true; } + return false; }, /** From e0e12aefef28ad4adf397f05f6fd716eb0900bd2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 24 Apr 2014 10:08:08 +0800 Subject: [PATCH 0042/1564] Compatible with builder --- cocos2d/core/platform/CCCommon.js | 2 ++ cocos2d/core/platform/CCTypesWebGL.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index 6f6dc3bd95..77f0f5cd83 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -24,6 +24,8 @@ THE SOFTWARE. ****************************************************************************/ +var _tmp = _tmp || {}; + /** * Function added for JS bindings compatibility. Not needed in cocos2d-html5. * @function diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index b89758ce5e..17bcde7044 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -22,6 +22,8 @@ THE SOFTWARE. ****************************************************************************/ +var _tmp = _tmp || {}; + _tmp.WebGLColor = function () { //redefine some types with ArrayBuffer for WebGL cc.color = function (r, g, b, a, arrayBuffer, offset) { From a7e4b71e2171ed752ed0ff1244de65fb0df032c2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 24 Apr 2014 14:57:23 +0800 Subject: [PATCH 0043/1564] Closed #4926: add a condition to check plist file in SpriteFrameCache.addSpriteFrames --- .gitignore | 3 ++- cocos2d/audio/CCAudio.js | 5 +++-- cocos2d/core/sprites/CCSpriteFrameCache.js | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index af2dade7dc..c99130832c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ lib build aspnet_client node_modules -/tools/jsdoc_toolkit-2.4.0 \ No newline at end of file +/tools/jsdoc_toolkit-2.4.0 +/package diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 2c11b66c59..88a49f8269 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -957,7 +957,8 @@ cc._audioLoader = { } else { return cb("can not found the resource of audio! Last match url is : " + realUrl); } - if (tryArr.indexOf(extname) >= 0) return self._load(realUrl, url, res, count + 1, tryArr, audio, cb); + if (tryArr.indexOf(extname) >= 0) + return self._load(realUrl, url, res, count + 1, tryArr, audio, cb); realUrl = path.changeExtname(realUrl, extname); tryArr.push(extname); audio = self._loadAudio(realUrl, audio, function (err) { @@ -972,6 +973,7 @@ cc._audioLoader = { return this._supportedAudioTypes.indexOf(type.toLowerCase()) >= 0; }, _loadAudio: function (url, audio, cb) { + var _Audio = cc.WebAudio || Audio; if (arguments.length == 2) { cb = audio, audio = new _Audio(); @@ -1008,7 +1010,6 @@ cc._audioLoader = { }; cc._audioLoader._supportedAudioTypes = function () { var au = cc.newElement('audio'), arr = []; - ; if (au.canPlayType) { //

* @return {Number} */ - getContentScaleFactor:function () { + getContentScaleFactor: function () { return this._contentScaleFactor; }, @@ -270,7 +270,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ *

* @return {cc.Node} */ - getNotificationNode:function () { + getNotificationNode: function () { return this._notificationNode; }, @@ -281,7 +281,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ *

* @return {cc.Size} */ - getWinSize:function () { + getWinSize: function () { return this._winSizeInPoints; }, @@ -293,7 +293,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ *

* @return {cc.Size} */ - getWinSizeInPixels:function () { + getWinSizeInPixels: function () { return cc.size(this._winSizeInPoints.width * this._contentScaleFactor, this._winSizeInPoints.height * this._contentScaleFactor); }, @@ -305,7 +305,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ /** * pause director */ - pause:function () { + pause: function () { if (this._paused) return; @@ -323,7 +323,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * ONLY call it if there is a running scene. *

*/ - popScene:function () { + popScene: function () { cc.assert(this._runningScene, cc._LogInfos.Director_popScene); @@ -341,21 +341,21 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ /** * Removes cached all cocos2d cached data. It will purge the cc.textureCache, cc.spriteFrameCache, cc.animationCache */ - purgeCachedData:function () { - cc.animationCache._clear(); - cc.spriteFrameCache._clear(); - cc.textureCache._clear(); + purgeCachedData: function () { + cc.animationCache._clear(); + cc.spriteFrameCache._clear(); + cc.textureCache._clear(); }, /** * purge Director */ - purgeDirector:function () { + purgeDirector: function () { //cleanup scheduler this.getScheduler().unscheduleAllCallbacks(); // Disable event dispatching - if(cc.eventManager) + if (cc.eventManager) cc.eventManager.setEnabled(false); // don't release the event handlers @@ -391,7 +391,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ *

* @param {cc.Scene} scene */ - pushScene:function (scene) { + pushScene: function (scene) { cc.assert(scene, cc._LogInfos.Director_pushScene); @@ -405,18 +405,18 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * Run a scene. Replaces the running scene with a new one when the scene is running. * @param {cc.Scene} scene */ - runScene:function(scene){ + runScene: function (scene) { cc.assert(scene, cc._LogInfos.Director_pushScene); - if(!this._runningScene){ + if (!this._runningScene) { //start scene this.pushScene(scene); this.startAnimation(); - }else{ + } else { //replace scene var i = this._scenesStack.length; - if(i === 0){ + if (i === 0) { this._sendCleanupToScene = true; this._scenesStack[i] = scene; this._nextScene = scene; @@ -431,7 +431,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ /** * resume director */ - resume:function () { + resume: function () { if (!this._paused) { return; } @@ -454,7 +454,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ *

* @param {Number} scaleFactor */ - setContentScaleFactor:function (scaleFactor) { + setContentScaleFactor: function (scaleFactor) { if (scaleFactor != this._contentScaleFactor) { this._contentScaleFactor = scaleFactor; this._createStatsLabel(); @@ -471,7 +471,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ /** * sets the default values based on the CCConfiguration info */ - setDefaultValues:function(){ + setDefaultValues: function () { }, @@ -479,16 +479,16 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * set next delta time is zero * @param {Boolean} nextDeltaTimeZero */ - setNextDeltaTimeZero:function (nextDeltaTimeZero) { + setNextDeltaTimeZero: function (nextDeltaTimeZero) { this._nextDeltaTimeZero = nextDeltaTimeZero; }, /** * set next scene */ - setNextScene:function () { + setNextScene: function () { var runningIsTransition = false, newIsTransition = false; - if(cc.TransitionScene){ + if (cc.TransitionScene) { runningIsTransition = this._runningScene ? this._runningScene instanceof cc.TransitionScene : false; newIsTransition = this._nextScene ? this._nextScene instanceof cc.TransitionScene : false; } @@ -520,7 +520,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * set Notification Node * @param {cc.Node} node */ - setNotificationNode:function (node) { + setNotificationNode: function (node) { this._notificationNode = node; }, @@ -528,11 +528,11 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * CCDirector delegate. It shall implemente the CCDirectorDelegate protocol * @return {cc.DirectorDelegate} */ - getDelegate:function () { + getDelegate: function () { return this._projectionDelegate; }, - setDelegate:function (delegate) { + setDelegate: function (delegate) { this._projectionDelegate = delegate; }, @@ -584,7 +584,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ *

* @return {Boolean} */ - isSendCleanupToScene:function () { + isSendCleanupToScene: function () { return this._sendCleanupToScene; }, @@ -592,7 +592,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * Get current running Scene. Director can only run one Scene at the time * @return {cc.Scene} */ - getRunningScene:function () { + getRunningScene: function () { return this._runningScene; }, @@ -600,7 +600,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * Get the FPS value * @return {Number} */ - getAnimationInterval:function () { + getAnimationInterval: function () { return this._animationInterval; }, @@ -608,7 +608,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * Whether or not to display the FPS on the bottom-left corner * @return {Boolean} */ - isDisplayStats:function () { + isDisplayStats: function () { return this._displayStats; }, @@ -616,7 +616,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * Display the FPS on the bottom-left corner * @param {Boolean} displayStats */ - setDisplayStats:function (displayStats) { + setDisplayStats: function (displayStats) { this._displayStats = displayStats; }, @@ -624,7 +624,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * seconds per frame * @return {Number} */ - getSecondsPerFrame:function () { + getSecondsPerFrame: function () { return this._secondsPerFrame; }, @@ -632,7 +632,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * is next delta time zero * @return {Boolean} */ - isNextDeltaTimeZero:function () { + isNextDeltaTimeZero: function () { return this._nextDeltaTimeZero; }, @@ -640,7 +640,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * Whether or not the Director is paused * @return {Boolean} */ - isPaused:function () { + isPaused: function () { return this._paused; }, @@ -648,7 +648,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * How many frames were called since the director started * @return {Number} */ - getTotalFrames:function () { + getTotalFrames: function () { return this._totalFrames; }, @@ -659,7 +659,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * Internally it will call `popToSceneStackLevel(1)` *

*/ - popToRootScene:function () { + popToRootScene: function () { this.popToSceneStackLevel(1); }, @@ -704,26 +704,26 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ /** * (cc.Scheduler associated with this director) */ - getScheduler:function () { + getScheduler: function () { return this._scheduler; }, - setScheduler:function (scheduler) { + setScheduler: function (scheduler) { if (this._scheduler != scheduler) { this._scheduler = scheduler; } }, - getActionManager:function () { + getActionManager: function () { return this._actionManager; }, - setActionManager:function (actionManager) { + setActionManager: function (actionManager) { if (this._actionManager != actionManager) { this._actionManager = actionManager; } }, - getDeltaTime:function(){ + getDeltaTime: function () { return this._deltaTime; }, @@ -744,12 +744,12 @@ cc.Director.EVENT_AFTER_UPDATE = "director_after_update"; * implementation of DisplayLinkDirector **************************************************/ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ - invalid:false, + invalid: false, /** * start Animation */ - startAnimation:function () { + startAnimation: function () { this._nextDeltaTimeZero = true; this.invalid = false; }, @@ -757,7 +757,7 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ /** * main loop of director */ - mainLoop:function () { + mainLoop: function () { if (this._purgeDirectorInNextLoop) { this._purgeDirectorInNextLoop = false; this.purgeDirector(); @@ -770,7 +770,7 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ /** * stop animation */ - stopAnimation:function () { + stopAnimation: function () { this.invalid = true; }, @@ -778,7 +778,7 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ * set Animation Interval * @param {Number} value */ - setAnimationInterval:function (value) { + setAnimationInterval: function (value) { this._animationInterval = value; if (!this.invalid) { this.stopAnimation(); @@ -851,17 +851,17 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._winSizeInPoints.width = cc._canvas.width; //this._openGLView.getDesignResolutionSize(); this._winSizeInPoints.height = cc._canvas.height; this._openGLView = openGLView || cc.view; - if(cc.eventManager) + if (cc.eventManager) cc.eventManager.setEnabled(true); }; - _p._clear = function() { + _p._clear = function () { var viewport = this._openGLView.getViewPortRect(); cc._renderContext.clearRect(-viewport.x, viewport.y, viewport.width, -viewport.height); }; - _p._createStatsLabel = function(){ + _p._createStatsLabel = function () { var _t = this; var fontSize = 0; if (_t._winSizeInPoints.width > _t._winSizeInPoints.height) @@ -891,15 +891,17 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //if (this._openGLView) { //return this._openGLView.getVisibleOrigin(); //} else { - return cc.p(0,0); + return cc.p(0, 0); //} }; -}else { +} else { cc.Director._fpsImage = new Image(); cc._addEventListener(cc.Director._fpsImage, "load", function () { cc.Director._fpsImageLoaded = true; }); - if(cc._fpsImage){ + if (cc._fpsImage) { cc.Director._fpsImage.src = cc._fpsImage; } + _tmp.DirectorWebGL && _tmp.DirectorWebGL(); + delete _tmp.DirectorWebGL; } \ No newline at end of file diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 5351a14ae5..c437aa4ce4 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -24,8 +24,8 @@ THE SOFTWARE. ****************************************************************************/ -if (cc._renderType === cc._RENDER_TYPE_WEBGL) { +_tmp.DirectorWebGL = function () { /** * OpenGL projection protocol @@ -36,7 +36,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { /** * Called by CCDirector when the projection is updated, and "custom" projection is used */ - updateProjection:function () { + updateProjection: function () { } }); @@ -92,7 +92,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { _p.setDepthTest = function (on) { - var loc_gl= cc._renderContext; + var loc_gl = cc._renderContext; if (on) { loc_gl.clearDepth(1.0); loc_gl.enable(loc_gl.DEPTH_TEST); @@ -133,29 +133,29 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { }*/ //} - if(cc.eventManager) + if (cc.eventManager) cc.eventManager.setEnabled(true); }; - _p._clear = function() { + _p._clear = function () { var gl = cc._renderContext; gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); }; - _p._beforeVisitScene = function() { + _p._beforeVisitScene = function () { cc.kmGLPushMatrix(); }; - _p._afterVisitScene = function() { + _p._afterVisitScene = function () { cc.kmGLPopMatrix(); }; - _p._createStatsLabel = function(){ + _p._createStatsLabel = function () { var _t = this; - if(!cc.LabelAtlas) + if (!cc.LabelAtlas) return _t._createStatsLabelForCanvas(); - if((cc.Director._fpsImageLoaded == null) || (cc.Director._fpsImageLoaded == false)) + if ((cc.Director._fpsImageLoaded == null) || (cc.Director._fpsImageLoaded == false)) return; var texture = new cc.Texture2D(); @@ -176,12 +176,12 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { a factor of design resolution ratio of 480x320 is also needed. */ var factor = cc.view.getDesignResolutionSize().height / 320.0; - if(factor === 0) + if (factor === 0) factor = _t._winSizeInPoints.height / 320.0; var tmpLabel = new cc.LabelAtlas(); tmpLabel._setIgnoreContentScaleFactor(true); - tmpLabel.initWithString("00.0", texture, 12, 32 , '.'); + tmpLabel.initWithString("00.0", texture, 12, 32, '.'); tmpLabel.scale = factor; _t._FPSLabel = tmpLabel; @@ -203,7 +203,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { _t._FPSLabel.setPosition(locStatsPosition); }; - _p._createStatsLabelForCanvas = function(){ + _p._createStatsLabelForCanvas = function () { var _t = this; //The original _createStatsLabelForCanvas method //Because the referenced by a cc.Director.prototype._createStatsLabel @@ -273,8 +273,6 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { }; - - _p.getVisibleSize = function () { //if (this._openGLView) { return this._openGLView.getVisibleSize(); @@ -298,10 +296,10 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { /** * Sets the glViewport */ - _p.setViewport = function(){ - if(this._openGLView) { + _p.setViewport = function () { + if (this._openGLView) { var locWinSizeInPoints = this._winSizeInPoints; - this._openGLView.setViewPortInPoints(0,0, locWinSizeInPoints.width, locWinSizeInPoints.height); + this._openGLView.setViewPortInPoints(0, 0, locWinSizeInPoints.width, locWinSizeInPoints.height); } }; diff --git a/moduleConfig.json b/moduleConfig.json index 20cdaaefdb..54327651af 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -98,8 +98,8 @@ "cocos2d/core/sprites/CCSpriteFrameCache.js", "cocos2d/core/CCConfiguration.js", - "cocos2d/core/CCDirector.js", "cocos2d/core/CCDirectorWebGL.js", + "cocos2d/core/CCDirector.js", "cocos2d/core/CCCamera.js", "cocos2d/core/CCScheduler.js", diff --git a/tools/build.xml b/tools/build.xml index 4b90ba6875..4b76a9fec7 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -58,8 +58,8 @@ - + @@ -234,7 +234,7 @@ - + From 3fc50c6d2c5664725701a4ad73a4fe08c90c279b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 25 Apr 2014 18:43:50 +0800 Subject: [PATCH 0046/1564] Closed #4856: fixed a bug of cc.TMXXMLParser and cc.TMXLayer getTileAt etc functions support a point or x,y as their parameters. --- Base64Images.js | 5 +- CCBoot.js | 5 +- CCDebugger.js | 28 ++++++-- cocos2d/actions/CCAction.js | 4 +- cocos2d/actions/CCActionCamera.js | 4 +- cocos2d/actions/CCActionCatmullRom.js | 4 +- cocos2d/actions/CCActionEase.js | 4 +- cocos2d/actions/CCActionInstant.js | 4 +- cocos2d/actions/CCActionInterval.js | 4 +- cocos2d/actions/CCActionTween.js | 4 +- cocos2d/actions3d/CCActionGrid.js | 4 +- cocos2d/actions3d/CCActionGrid3D.js | 4 +- cocos2d/actions3d/CCActionPageTurn3D.js | 4 +- cocos2d/actions3d/CCActionTiledGrid.js | 4 +- cocos2d/audio/CCAudio.js | 4 +- cocos2d/clipping-nodes/CCClippingNode.js | 4 +- cocos2d/core/CCActionManager.js | 4 +- cocos2d/core/CCCamera.js | 4 +- cocos2d/core/CCConfiguration.js | 4 +- cocos2d/core/CCDirector.js | 4 +- cocos2d/core/CCDirectorWebGL.js | 4 +- cocos2d/core/CCDrawingPrimitivesCanvas.js | 4 +- cocos2d/core/CCDrawingPrimitivesWebGL.js | 4 +- cocos2d/core/CCScheduler.js | 4 +- .../base-nodes/BaseNodesPropertyDefine.js | 4 +- cocos2d/core/base-nodes/BaseNodesWebGL.js | 4 +- cocos2d/core/base-nodes/CCAtlasNode.js | 4 +- cocos2d/core/base-nodes/CCNode.js | 4 +- cocos2d/core/cocoa/CCAffineTransform.js | 4 +- cocos2d/core/cocoa/CCGeometry.js | 4 +- cocos2d/core/event-manager/CCEvent.js | 3 +- .../core/event-manager/CCEventExtension.js | 3 +- cocos2d/core/event-manager/CCEventListener.js | 3 +- cocos2d/core/event-manager/CCEventManager.js | 3 +- cocos2d/core/event-manager/CCTouch.js | 2 +- cocos2d/core/labelttf/CCLabelTTF.js | 4 +- .../core/labelttf/LabelTTFPropertyDefine.js | 4 +- cocos2d/core/labelttf/LabelTTFWebGL.js | 4 +- cocos2d/core/layers/CCLayer.js | 4 +- cocos2d/core/layers/CCLayerPropertyDefine.js | 4 +- cocos2d/core/layers/CCLayerWebGL.js | 4 +- cocos2d/core/platform/CCClass.js | 4 +- cocos2d/core/platform/CCCommon.js | 4 +- cocos2d/core/platform/CCConfig.js | 4 +- cocos2d/core/platform/CCEGLView.js | 4 +- cocos2d/core/platform/CCInputExtension.js | 2 +- cocos2d/core/platform/CCInputManager.js | 2 +- cocos2d/core/platform/CCLoaders.js | 5 +- cocos2d/core/platform/CCMacro.js | 4 +- cocos2d/core/platform/CCSAXParser.js | 4 +- cocos2d/core/platform/CCScreen.js | 4 +- cocos2d/core/platform/CCTypes.js | 4 +- .../core/platform/CCTypesPropertyDefine.js | 4 +- cocos2d/core/platform/CCTypesWebGL.js | 4 +- cocos2d/core/platform/CCVisibleRect.js | 5 +- cocos2d/core/platform/miniFramework.js | 4 +- cocos2d/core/scenes/CCLoaderScene.js | 5 +- cocos2d/core/scenes/CCScene.js | 4 +- cocos2d/core/scenes/CCSceneFile.js | 5 +- cocos2d/core/sprites/CCAnimation.js | 4 +- cocos2d/core/sprites/CCAnimationCache.js | 4 +- cocos2d/core/sprites/CCSprite.js | 4 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 4 +- cocos2d/core/sprites/CCSpriteFrame.js | 4 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 4 +- cocos2d/core/sprites/SpritesPropertyDefine.js | 4 +- cocos2d/core/sprites/SpritesWebGL.js | 4 +- cocos2d/core/support/CCPointExtension.js | 4 +- cocos2d/core/support/CCVertex.js | 4 +- cocos2d/core/support/TransformUtils.js | 4 +- cocos2d/core/textures/CCTexture2D.js | 4 +- cocos2d/core/textures/CCTextureAtlas.js | 4 +- cocos2d/core/textures/CCTextureCache.js | 4 +- .../core/textures/TexturesPropertyDefine.js | 4 +- cocos2d/core/textures/TexturesWebGL.js | 4 +- cocos2d/core/utils/BinaryLoader.js | 4 +- cocos2d/effects/CCGrabber.js | 4 +- cocos2d/effects/CCGrid.js | 6 +- cocos2d/kazmath/aabb.js | 4 +- cocos2d/kazmath/gl/mat4stack.js | 4 +- cocos2d/kazmath/gl/matrix.js | 4 +- cocos2d/kazmath/mat3.js | 4 +- cocos2d/kazmath/mat4.js | 4 +- cocos2d/kazmath/plane.js | 4 +- cocos2d/kazmath/quaternion.js | 4 +- cocos2d/kazmath/ray2.js | 4 +- cocos2d/kazmath/utility.js | 4 +- cocos2d/kazmath/vec2.js | 4 +- cocos2d/kazmath/vec3.js | 4 +- cocos2d/kazmath/vec4.js | 4 +- cocos2d/labels/CCLabelAtlas.js | 4 +- cocos2d/labels/CCLabelBMFont.js | 4 +- cocos2d/menus/CCMenu.js | 4 +- cocos2d/menus/CCMenuItem.js | 4 +- cocos2d/motion-streak/CCMotionStreak.js | 4 +- cocos2d/node-grid/CCNodeGrid.js | 4 +- cocos2d/parallax/CCParallaxNode.js | 4 +- cocos2d/particle/CCPNGReader.js | 5 +- cocos2d/particle/CCParticleBatchNode.js | 6 +- cocos2d/particle/CCParticleExamples.js | 4 +- cocos2d/particle/CCParticleSystem.js | 4 +- cocos2d/particle/CCTIFFReader.js | 6 +- cocos2d/physics/CCPhysicsDebugNode.js | 4 +- cocos2d/physics/CCPhysicsSprite.js | 6 +- .../progress-timer/CCActionProgressTimer.js | 4 +- cocos2d/progress-timer/CCProgressTimer.js | 4 +- cocos2d/render-texture/CCRenderTexture.js | 6 +- cocos2d/shaders/CCGLProgram.js | 4 +- cocos2d/shaders/CCGLStateCache.js | 4 +- cocos2d/shaders/CCShaderCache.js | 4 +- cocos2d/shaders/CCShaders.js | 4 +- cocos2d/shape-nodes/CCDrawNode.js | 4 +- cocos2d/text-input/CCIMEDispatcher.js | 4 +- cocos2d/text-input/CCTextFieldTTF.js | 4 +- cocos2d/tilemap/CCTGAlib.js | 4 +- cocos2d/tilemap/CCTMXLayer.js | 69 ++++++++++++------- cocos2d/tilemap/CCTMXObjectGroup.js | 4 +- cocos2d/tilemap/CCTMXTiledMap.js | 4 +- cocos2d/tilemap/CCTMXXMLParser.js | 8 +-- cocos2d/tilemap/CCTileMapAtlas.js | 4 +- cocos2d/transitions/CCTransition.js | 4 +- cocos2d/transitions/CCTransitionPageTurn.js | 4 +- cocos2d/transitions/CCTransitionProgress.js | 4 +- extensions/ccb-reader/CCBAnimationManager.js | 4 +- extensions/ccb-reader/CCBKeyframe.js | 4 +- extensions/ccb-reader/CCBReader.js | 4 +- extensions/ccb-reader/CCBReaderUtil.js | 4 +- .../ccb-reader/CCBRelativePositioning.js | 4 +- extensions/ccb-reader/CCBSequence.js | 4 +- extensions/ccb-reader/CCBValue.js | 4 +- extensions/ccb-reader/CCControlLoader.js | 4 +- extensions/ccb-reader/CCNodeLoader.js | 4 +- extensions/ccb-reader/CCNodeLoaderLibrary.js | 4 +- extensions/ccb-reader/CCSpriteLoader.js | 4 +- extensions/ccui/base-classes/UIWidget.js | 3 +- extensions/ccui/layouts/UILayout.js | 3 +- extensions/ccui/layouts/UILayoutDefine.js | 3 +- extensions/ccui/layouts/UILayoutParameter.js | 3 +- extensions/ccui/system/CocosGUI.js | 3 +- extensions/ccui/system/UIHelper.js | 3 +- extensions/ccui/uiwidgets/UIButton.js | 3 +- extensions/ccui/uiwidgets/UICheckBox.js | 3 +- extensions/ccui/uiwidgets/UIImageView.js | 3 +- extensions/ccui/uiwidgets/UILoadingBar.js | 9 +-- extensions/ccui/uiwidgets/UIRichText.js | 3 +- extensions/ccui/uiwidgets/UISlider.js | 9 +-- extensions/ccui/uiwidgets/UIText.js | 3 +- extensions/ccui/uiwidgets/UITextAtlas.js | 3 +- extensions/ccui/uiwidgets/UITextBMFont.js | 3 +- extensions/ccui/uiwidgets/UITextField.js | 3 +- .../uiwidgets/scroll-widget/UIListView.js | 3 +- .../uiwidgets/scroll-widget/UIPageView.js | 3 +- .../uiwidgets/scroll-widget/UIScrollView.js | 3 +- extensions/cocostudio/CocoStudio.js | 3 +- extensions/cocostudio/action/CCActionFrame.js | 3 +- .../cocostudio/action/CCActionManager.js | 3 +- extensions/cocostudio/action/CCActionNode.js | 3 +- .../cocostudio/action/CCActionObject.js | 3 +- extensions/cocostudio/armature/CCArmature.js | 3 +- extensions/cocostudio/armature/CCBone.js | 3 +- .../armature/animation/CCArmatureAnimation.js | 3 +- .../armature/animation/CCProcessBase.js | 3 +- .../cocostudio/armature/animation/CCTween.js | 3 +- .../cocostudio/armature/datas/CCDatas.js | 3 +- .../armature/display/CCBatchNode.js | 3 +- .../armature/display/CCDecorativeDisplay.js | 3 +- .../armature/display/CCDisplayFactory.js | 3 +- .../armature/display/CCDisplayManager.js | 3 +- .../cocostudio/armature/display/CCSkin.js | 3 +- .../armature/physics/CCColliderDetector.js | 3 +- .../armature/utils/CCArmatureDataManager.js | 3 +- .../armature/utils/CCArmatureDefine.js | 3 +- .../armature/utils/CCDataReaderHelper.js | 3 +- .../utils/CCSpriteFrameCacheHelper.js | 3 +- .../armature/utils/CCTransformHelp.js | 3 +- .../armature/utils/CCTweenFunction.js | 3 +- .../cocostudio/armature/utils/CCUtilMath.js | 3 +- .../cocostudio/components/CCComAttribute.js | 3 +- .../cocostudio/components/CCComAudio.js | 3 +- .../cocostudio/components/CCComController.js | 3 +- .../cocostudio/components/CCComRender.js | 3 +- .../cocostudio/components/CCComponent.js | 3 +- .../components/CCComponentContainer.js | 3 +- extensions/cocostudio/reader/GUIReader.js | 3 +- extensions/cocostudio/reader/SceneReader.js | 3 +- .../cocostudio/trigger/ObjectFactory.js | 3 +- extensions/cocostudio/trigger/TriggerBase.js | 3 +- extensions/cocostudio/trigger/TriggerMng.js | 3 +- extensions/cocostudio/trigger/TriggerObj.js | 3 +- extensions/editbox/CCEditBox.js | 3 +- extensions/editbox/CCdomNode.js | 5 +- extensions/gui/control-extension/CCControl.js | 7 +- .../gui/control-extension/CCControlButton.js | 4 +- .../CCControlColourPicker.js | 8 +-- .../control-extension/CCControlHuePicker.js | 4 +- .../CCControlPotentiometer.js | 5 +- .../CCControlSaturationBrightnessPicker.js | 4 +- .../gui/control-extension/CCControlSlider.js | 4 +- .../gui/control-extension/CCControlStepper.js | 5 +- .../gui/control-extension/CCControlSwitch.js | 4 +- .../gui/control-extension/CCControlUtils.js | 4 +- .../gui/control-extension/CCInvocation.js | 4 +- .../gui/control-extension/CCMenuPassive.js | 4 +- .../gui/control-extension/CCScale9Sprite.js | 4 +- extensions/gui/scrollview/CCScrollView.js | 4 +- extensions/gui/scrollview/CCSorting.js | 4 +- extensions/gui/scrollview/CCTableView.js | 4 +- extensions/pluginx/plugins/AnalyticsFlurry.js | 44 ++++++------ extensions/pluginx/plugins/SocialFacebook.js | 25 +++++++ extensions/pluginx/plugins/SocialQQWeibo.js | 25 +++++++ extensions/pluginx/plugins/SocialQzone.js | 25 +++++++ extensions/pluginx/plugins/SocialTwitter.js | 25 +++++++ extensions/pluginx/plugins/SocialWeibo.js | 25 +++++++ extensions/pluginx/protocols/Config.js | 4 +- extensions/pluginx/protocols/PluginFactory.js | 4 +- extensions/pluginx/protocols/PluginManager.js | 4 +- .../pluginx/protocols/PluginProtocol.js | 4 +- extensions/pluginx/protocols/PluginUtils.js | 3 +- extensions/pluginx/protocols/ProtocolAds.js | 3 +- .../pluginx/protocols/ProtocolAnalytics.js | 3 +- .../pluginx/protocols/ProtocolSocial.js | 3 +- .../pluginx/samples/HelloSocial/src/myApp.js | 26 ------- template/src/myApp.js | 26 ------- 223 files changed, 695 insertions(+), 448 deletions(-) diff --git a/Base64Images.js b/Base64Images.js index 8f7cce4362..0d983506be 100644 --- a/Base64Images.js +++ b/Base64Images.js @@ -1,7 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/CCBoot.js b/CCBoot.js index 16e5ef94e3..fd0cbb399a 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1,7 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/CCDebugger.js b/CCDebugger.js index d8b633c160..54bbe9a595 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -1,7 +1,27 @@ -/** - * Created by small on 14-4-3. - */ - +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ cc._LogInfos = { ActionManager_addAction: "cc.ActionManager.addAction(): action must be non-null", diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index ade6d8d428..b9d15dc1fa 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index f055f6ca8e..8766e2095f 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index b1fd07e501..45c6bade43 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008 Radu Gruian Copyright (c) 2011 Vit Valentin diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 295136f94f..ad61c2efa7 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index b2313e64a6..4c53cf4442 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 9eece2b601..3d0b7d6b4c 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index 5877e8c93b..a4c04730f4 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index 8f7feea8f7..00e9c0309d 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index f1387f1d9c..8123111759 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions3d/CCActionPageTurn3D.js b/cocos2d/actions3d/CCActionPageTurn3D.js index dae59a11ee..1658230f96 100644 --- a/cocos2d/actions3d/CCActionPageTurn3D.js +++ b/cocos2d/actions3d/CCActionPageTurn3D.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index b146e8a355..821eb9e6f6 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index d72d32a525..8a373d726a 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 397ce18470..97a9df2ef5 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2012 Pierre-David Bélanger http://www.cocos2d-x.org diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index d2351263a7..1b4eaf5fb7 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js index ac01fd8e6f..1f22cc11d6 100644 --- a/cocos2d/core/CCCamera.js +++ b/cocos2d/core/CCCamera.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/CCConfiguration.js b/cocos2d/core/CCConfiguration.js index 7efd9fac60..54ef6f2de6 100644 --- a/cocos2d/core/CCConfiguration.js +++ b/cocos2d/core/CCConfiguration.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 4581a54a5b..3e3f27297b 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 5351a14ae5..1b4941f954 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/CCDrawingPrimitivesCanvas.js b/cocos2d/core/CCDrawingPrimitivesCanvas.js index 66a9b540cc..f88489e2b0 100644 --- a/cocos2d/core/CCDrawingPrimitivesCanvas.js +++ b/cocos2d/core/CCDrawingPrimitivesCanvas.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/CCDrawingPrimitivesWebGL.js b/cocos2d/core/CCDrawingPrimitivesWebGL.js index d156c83fc1..54001668eb 100644 --- a/cocos2d/core/CCDrawingPrimitivesWebGL.js +++ b/cocos2d/core/CCDrawingPrimitivesWebGL.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 10428ac16a..456ff248f4 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js index 2af9fe5d9a..4d2cea6056 100644 --- a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +++ b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index 6216f5cbbf..b342200a3c 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index ec305cd204..fa703106ba 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b42094b4fe..d50e6586d2 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/cocoa/CCAffineTransform.js b/cocos2d/core/cocoa/CCAffineTransform.js index 150875a0fb..d539fa0e3a 100644 --- a/cocos2d/core/cocoa/CCAffineTransform.js +++ b/cocos2d/core/cocoa/CCAffineTransform.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/cocoa/CCGeometry.js b/cocos2d/core/cocoa/CCGeometry.js index 11ace91ee1..57b1521c77 100644 --- a/cocos2d/core/cocoa/CCGeometry.js +++ b/cocos2d/core/cocoa/CCGeometry.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/event-manager/CCEvent.js b/cocos2d/core/event-manager/CCEvent.js index 09535c7500..402a410c86 100644 --- a/cocos2d/core/event-manager/CCEvent.js +++ b/cocos2d/core/event-manager/CCEvent.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/event-manager/CCEventExtension.js b/cocos2d/core/event-manager/CCEventExtension.js index 7c3f41f473..f6e27f370a 100644 --- a/cocos2d/core/event-manager/CCEventExtension.js +++ b/cocos2d/core/event-manager/CCEventExtension.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 8d5baaf3ac..8de5e58269 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2014 Chukong Technologies Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 9fa5c881b9..af4d5c8e65 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/event-manager/CCTouch.js b/cocos2d/core/event-manager/CCTouch.js index 2e3849bb7e..e6e6c3a1ee 100644 --- a/cocos2d/core/event-manager/CCTouch.js +++ b/cocos2d/core/event-manager/CCTouch.js @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index e09b5d3898..a32f2513db 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/labelttf/LabelTTFPropertyDefine.js b/cocos2d/core/labelttf/LabelTTFPropertyDefine.js index f12b819296..79667a2633 100644 --- a/cocos2d/core/labelttf/LabelTTFPropertyDefine.js +++ b/cocos2d/core/labelttf/LabelTTFPropertyDefine.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/labelttf/LabelTTFWebGL.js b/cocos2d/core/labelttf/LabelTTFWebGL.js index 99d05070ed..f6d1a0a9cc 100644 --- a/cocos2d/core/labelttf/LabelTTFWebGL.js +++ b/cocos2d/core/labelttf/LabelTTFWebGL.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index efb491604c..940e76f551 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/layers/CCLayerPropertyDefine.js b/cocos2d/core/layers/CCLayerPropertyDefine.js index 1eac9fd438..8dcf53a234 100644 --- a/cocos2d/core/layers/CCLayerPropertyDefine.js +++ b/cocos2d/core/layers/CCLayerPropertyDefine.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/layers/CCLayerWebGL.js b/cocos2d/core/layers/CCLayerWebGL.js index a7b58fda77..c33e8864f4 100644 --- a/cocos2d/core/layers/CCLayerWebGL.js +++ b/cocos2d/core/layers/CCLayerWebGL.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 95228e2e5d..b55ff2dacd 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index 77f0f5cd83..9b5de58478 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 2b52726809..eb472fc828 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 9fff32b23a..6f3b0e3be9 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCInputExtension.js b/cocos2d/core/platform/CCInputExtension.js index 5846094d12..36013d457c 100644 --- a/cocos2d/core/platform/CCInputExtension.js +++ b/cocos2d/core/platform/CCInputExtension.js @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 932cc6937d..962dfe3675 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index c7f5608c99..be29833ee7 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -1,7 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 16a82fc979..5496215d93 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCSAXParser.js b/cocos2d/core/platform/CCSAXParser.js index df436b38fd..d4cbeedc49 100644 --- a/cocos2d/core/platform/CCSAXParser.js +++ b/cocos2d/core/platform/CCSAXParser.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index 874c4b035e..3355f33dae 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 3e0acbb699..cfa43f5b50 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCTypesPropertyDefine.js b/cocos2d/core/platform/CCTypesPropertyDefine.js index a80e1d3809..8c94fe9a65 100644 --- a/cocos2d/core/platform/CCTypesPropertyDefine.js +++ b/cocos2d/core/platform/CCTypesPropertyDefine.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index 17bcde7044..c68d115ee8 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/CCVisibleRect.js b/cocos2d/core/platform/CCVisibleRect.js index 98b818f2a2..a0dc4502b2 100644 --- a/cocos2d/core/platform/CCVisibleRect.js +++ b/cocos2d/core/platform/CCVisibleRect.js @@ -1,7 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/platform/miniFramework.js b/cocos2d/core/platform/miniFramework.js index 10e9397378..daea2d3638 100644 --- a/cocos2d/core/platform/miniFramework.js +++ b/cocos2d/core/platform/miniFramework.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index cdd596a123..1c51c50df2 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -1,7 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/scenes/CCScene.js b/cocos2d/core/scenes/CCScene.js index af8bd9f754..bdee48559f 100644 --- a/cocos2d/core/scenes/CCScene.js +++ b/cocos2d/core/scenes/CCScene.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/scenes/CCSceneFile.js b/cocos2d/core/scenes/CCSceneFile.js index f0a881e45e..de4b748d0c 100644 --- a/cocos2d/core/scenes/CCSceneFile.js +++ b/cocos2d/core/scenes/CCSceneFile.js @@ -1,7 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index ea72c13e01..ff0ecc329c 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index e76e5e9875..1980a7aa8f 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index bacfd2c6a0..eddde0ebd7 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 33a1c656a8..7145762d9f 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index cfe6eeec10..38cc93687b 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 994a6b5045..699bcebdcf 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/SpritesPropertyDefine.js b/cocos2d/core/sprites/SpritesPropertyDefine.js index 44f00ba839..a62373caee 100644 --- a/cocos2d/core/sprites/SpritesPropertyDefine.js +++ b/cocos2d/core/sprites/SpritesPropertyDefine.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 57b12e09ef..1a949732fc 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/support/CCPointExtension.js index 7a8fef6a4c..618b65c0ff 100644 --- a/cocos2d/core/support/CCPointExtension.js +++ b/cocos2d/core/support/CCPointExtension.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/support/CCVertex.js b/cocos2d/core/support/CCVertex.js index a5b3f06026..acae86ac2e 100644 --- a/cocos2d/core/support/CCVertex.js +++ b/cocos2d/core/support/CCVertex.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2d/core/support/TransformUtils.js b/cocos2d/core/support/TransformUtils.js index 80cd797290..bb57c6f8c4 100644 --- a/cocos2d/core/support/TransformUtils.js +++ b/cocos2d/core/support/TransformUtils.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2009 Valentin Milea http://www.cocos2d-x.org diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index cd1401d309..db42e2bf49 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index 1c22cf49dd..d34875c185 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index c0494c1026..1d2e0efc05 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/textures/TexturesPropertyDefine.js b/cocos2d/core/textures/TexturesPropertyDefine.js index f6936370d1..ae093b0bcb 100644 --- a/cocos2d/core/textures/TexturesPropertyDefine.js +++ b/cocos2d/core/textures/TexturesPropertyDefine.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index b1666db64b..ba66b9e66d 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/core/utils/BinaryLoader.js b/cocos2d/core/utils/BinaryLoader.js index 8bb4959213..6260636efa 100644 --- a/cocos2d/core/utils/BinaryLoader.js +++ b/cocos2d/core/utils/BinaryLoader.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/effects/CCGrabber.js b/cocos2d/effects/CCGrabber.js index 64831a9d6f..a4dc754ff2 100644 --- a/cocos2d/effects/CCGrabber.js +++ b/cocos2d/effects/CCGrabber.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index 963b048f7c..2389e82801 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -1,8 +1,8 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org - Copyright (c) 2009 On-Core Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2009 On-Core http://www.cocos2d-x.org diff --git a/cocos2d/kazmath/aabb.js b/cocos2d/kazmath/aabb.js index a5c8a116d2..8fafef6f67 100644 --- a/cocos2d/kazmath/aabb.js +++ b/cocos2d/kazmath/aabb.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/gl/mat4stack.js b/cocos2d/kazmath/gl/mat4stack.js index 0532d759dc..b87450e9c7 100644 --- a/cocos2d/kazmath/gl/mat4stack.js +++ b/cocos2d/kazmath/gl/mat4stack.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/gl/matrix.js b/cocos2d/kazmath/gl/matrix.js index 6459b51bda..ed579f8c0f 100644 --- a/cocos2d/kazmath/gl/matrix.js +++ b/cocos2d/kazmath/gl/matrix.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/mat3.js b/cocos2d/kazmath/mat3.js index 7bcc8a1c77..fea8559630 100644 --- a/cocos2d/kazmath/mat3.js +++ b/cocos2d/kazmath/mat3.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/mat4.js b/cocos2d/kazmath/mat4.js index 8fa12a41de..9c62be7284 100644 --- a/cocos2d/kazmath/mat4.js +++ b/cocos2d/kazmath/mat4.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/plane.js b/cocos2d/kazmath/plane.js index 5470415f1a..02acd8399b 100644 --- a/cocos2d/kazmath/plane.js +++ b/cocos2d/kazmath/plane.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/quaternion.js b/cocos2d/kazmath/quaternion.js index 54e1de8e17..1a863f372b 100644 --- a/cocos2d/kazmath/quaternion.js +++ b/cocos2d/kazmath/quaternion.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/ray2.js b/cocos2d/kazmath/ray2.js index d87f9c342e..e9edbcd13d 100644 --- a/cocos2d/kazmath/ray2.js +++ b/cocos2d/kazmath/ray2.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/utility.js b/cocos2d/kazmath/utility.js index 173ae61f33..4f1d8153c7 100644 --- a/cocos2d/kazmath/utility.js +++ b/cocos2d/kazmath/utility.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/vec2.js b/cocos2d/kazmath/vec2.js index 613ad45559..888b234bf1 100644 --- a/cocos2d/kazmath/vec2.js +++ b/cocos2d/kazmath/vec2.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/vec3.js b/cocos2d/kazmath/vec3.js index c31de7c191..07dc0fb4ea 100644 --- a/cocos2d/kazmath/vec3.js +++ b/cocos2d/kazmath/vec3.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/kazmath/vec4.js b/cocos2d/kazmath/vec4.js index 870e480632..9712743fff 100644 --- a/cocos2d/kazmath/vec4.js +++ b/cocos2d/kazmath/vec4.js @@ -1,5 +1,7 @@ /** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008, Luke Benstead. All rights reserved. diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index f008aa480d..d423e953e2 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 76f52cf287..307c88a60c 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 90ad1289ef..6b8ec265f6 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index e366f25418..889e3741ca 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 13254d9a79..a3894e2a4f 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2008-2009 Jason Booth http://www.cocos2d-x.org diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index b5cc41e2a5..ace59b19ea 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2014 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index e2b33b860b..afb25a7b72 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/particle/CCPNGReader.js b/cocos2d/particle/CCPNGReader.js index 99fb63c2cb..ee860be525 100644 --- a/cocos2d/particle/CCPNGReader.js +++ b/cocos2d/particle/CCPNGReader.js @@ -1,7 +1,8 @@ /**************************************************************************** Copyright (c) 2011 Devon Govett - Copyright (c) 2010-2012 cocos2d-x.org - + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 5f44b8f557..503e5a469e 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -1,8 +1,8 @@ /** - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * Copyright (C) 2009 Matt Oswald - * Copyright (c) 2009-2010 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. * Copyright (c) 2011 Marco Tillemans * * http://www.cocos2d-x.org diff --git a/cocos2d/particle/CCParticleExamples.js b/cocos2d/particle/CCParticleExamples.js index 962d4b7fc4..c8618c1833 100644 --- a/cocos2d/particle/CCParticleExamples.js +++ b/cocos2d/particle/CCParticleExamples.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 7db66ef7c8..871af2f38b 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/particle/CCTIFFReader.js b/cocos2d/particle/CCTIFFReader.js index 8eb693f8d6..4e24945021 100644 --- a/cocos2d/particle/CCTIFFReader.js +++ b/cocos2d/particle/CCTIFFReader.js @@ -2,7 +2,10 @@ Copyright (c) 2011 Gordon P. Hemsley http://gphemsley.org/ - Copyright (c) 2010-2013 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +27,6 @@ THE SOFTWARE. ****************************************************************************/ - /** * @namespace A tiff file reader, it can parse byte array to draw into a canvas */ diff --git a/cocos2d/physics/CCPhysicsDebugNode.js b/cocos2d/physics/CCPhysicsDebugNode.js index 93c8c9d203..44e6e70ede 100644 --- a/cocos2d/physics/CCPhysicsDebugNode.js +++ b/cocos2d/physics/CCPhysicsDebugNode.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2012 Scott Lembcke and Howling Moon Software http://www.cocos2d-x.org diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 455ac7c322..733690a633 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -1,4 +1,8 @@ -/** Copyright (c) 2012 Scott Lembcke and Howling Moon Software +/** + * Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index 6245b0024a..454ca66e48 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (C) 2010 Lam Pham http://www.cocos2d-x.org diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 832031c6e2..9b0e76503b 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2010 Lam Pham http://www.cocos2d-x.org diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index e41a78ee9b..f7c206d216 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -1,8 +1,8 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2009 Jason Booth Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2009 Jason Booth http://www.cocos2d-x.org diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 991efd0722..e8adba7d9f 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -1,9 +1,9 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright 2011 Jeff Lamarche Copyright 2012 Goffredo Marocchi - Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js index c8d890ae32..b61645d64b 100644 --- a/cocos2d/shaders/CCGLStateCache.js +++ b/cocos2d/shaders/CCGLStateCache.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/shaders/CCShaderCache.js b/cocos2d/shaders/CCShaderCache.js index 8b56228447..894122046e 100644 --- a/cocos2d/shaders/CCShaderCache.js +++ b/cocos2d/shaders/CCShaderCache.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/shaders/CCShaders.js b/cocos2d/shaders/CCShaders.js index 1304248d1a..097d0167a0 100644 --- a/cocos2d/shaders/CCShaders.js +++ b/cocos2d/shaders/CCShaders.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 57abf6a9ea..f59f4a27f1 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2012 Scott Lembcke and Howling Moon Software http://www.cocos2d-x.org diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index fa970e8b7a..df35dee6cf 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index 04fd28cb02..8bdff08f5f 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/tilemap/CCTGAlib.js b/cocos2d/tilemap/CCTGAlib.js index 1f729e20df..e0114586b9 100644 --- a/cocos2d/tilemap/CCTGAlib.js +++ b/cocos2d/tilemap/CCTGAlib.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 9463cf4009..29a81f9c1b 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -174,7 +174,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ } }, - /** * Return texture of cc.SpriteBatchNode * @return {cc.Texture2D} @@ -452,12 +451,15 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * You can remove either by calling:
* - layer.removeChild(sprite, cleanup);
* - or layer.removeTileAt(ccp(x,y));

- * @param {cc.Point} pos + * @param {cc.Point|Number} pos or x + * @param {Number} [y] * @return {cc.Sprite} */ - getTileAt: function (pos) { + getTileAt: function (pos, y) { if(!pos) throw "cc.TMXLayer.getTileAt(): pos should be non-null"; + if(y !== undefined) + pos = cc.p(pos, y); if(pos.x >= this._layerSize.width || pos.y >= this._layerSize.height || pos.x < 0 || pos.y < 0) throw "cc.TMXLayer.getTileAt(): invalid position"; if(!this.tiles || !this._atlasIndexArray){ @@ -465,8 +467,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ return null; } - var tile = null; - var gid = this.getTileGIDAt(pos); + var tile = null, gid = this.getTileGIDAt(pos); // if GID == 0, then no tile is present if (gid === 0) @@ -498,12 +499,15 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * Returns the tile gid at a given tile coordinate.
* if it returns 0, it means that the tile is empty.
* This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())
- * @param {cc.Point} pos + * @param {cc.Point|Number} pos or x + * @param {Number} [y] * @return {Number} */ - getTileGIDAt:function (pos) { + getTileGIDAt:function (pos, y) { if(!pos) throw "cc.TMXLayer.getTileGIDAt(): pos should be non-null"; + if(y !== undefined) + pos = cc.p(pos, y); if(pos.x >= this._layerSize.width || pos.y >= this._layerSize.height || pos.x < 0 || pos.y < 0) throw "cc.TMXLayer.getTileGIDAt(): invalid position"; if(!this.tiles || !this._atlasIndexArray){ @@ -522,12 +526,15 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ /** * lipped tiles can be changed dynamically - * @param {cc.Point} pos + * @param {cc.Point|Number} pos or x + * @param {Number} [y] * @return {Number} */ - getTileFlagsAt:function (pos) { + getTileFlagsAt:function (pos, y) { if(!pos) throw "cc.TMXLayer.getTileFlagsAt(): pos should be non-null"; + if(y !== undefined) + pos = cc.p(pos, y); if(pos.x >= this._layerSize.width || pos.y >= this._layerSize.height || pos.x < 0 || pos.y < 0) throw "cc.TMXLayer.getTileFlagsAt(): invalid position"; if(!this.tiles || !this._atlasIndexArray){ @@ -549,26 +556,33 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
* If a tile is already placed at that position, then it will be removed.

* @param {Number} gid - * @param {cc.Point} pos - * @param {Number} flags + * @param {cc.Point|Number} posOrX position or x + * @param {Number} flagsOrY flags or y + * @param {Number} [flags] */ - setTileGID:function (gid, pos, flags) { - if(!pos) + setTileGID: function(gid, posOrX, flagsOrY, flags) { + if(!posOrX) throw "cc.TMXLayer.setTileGID(): pos should be non-null"; + var pos; + if (flags !== undefined) { + pos = cc.p(posOrX, flagsOrY); + } else { + pos = posOrX; + flags = flagsOrY; + } if(pos.x >= this._layerSize.width || pos.y >= this._layerSize.height || pos.x < 0 || pos.y < 0) throw "cc.TMXLayer.setTileGID(): invalid position"; if(!this.tiles || !this._atlasIndexArray){ cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released"); - return null; + return; } if(gid !== 0 && gid < this.tileset.firstGid){ cc.log( "cc.TMXLayer.setTileGID(): invalid gid:" + gid); - return null; + return; } flags = flags || 0; this._setNodeDirtyForCache(); - var currentFlags = this.getTileFlagsAt(pos); var currentGID = this.getTileGIDAt(pos); @@ -599,16 +613,19 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ /** * Removes a tile at given tile coordinate - * @param {cc.Point} pos + * @param {cc.Point|Number} pos position or x + * @param {Number} [y] */ - removeTileAt:function (pos) { + removeTileAt:function (pos, y) { if(!pos) throw "cc.TMXLayer.removeTileAt(): pos should be non-null"; + if(y !== undefined) + pos = cc.p(pos, y); if(pos.x >= this._layerSize.width || pos.y >= this._layerSize.height || pos.x < 0 || pos.y < 0) throw "cc.TMXLayer.removeTileAt(): invalid position"; if(!this.tiles || !this._atlasIndexArray){ cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released"); - return null; + return; } var gid = this.getTileGIDAt(pos); @@ -650,10 +667,13 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ /** * Returns the position in pixels of a given tile coordinate - * @param {cc.Point} pos + * @param {cc.Point|Number} pos position or x + * @param {Number} [y] * @return {cc.Point} */ - getPositionAt:function (pos) { + getPositionAt:function (pos, y) { + if (y !== undefined) + pos = cc.p(pos, y); var ret = cc.p(0,0); switch (this.layerOrientation) { case cc.TMX_ORIENTATION_ORTHO: @@ -871,8 +891,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this._setupTileSprite(tile, pos, gid); // get atlas index - var indexForZ = this._atlasIndexForExistantZ(z); - tile.atlasIndex = indexForZ; + tile.atlasIndex = this._atlasIndexForExistantZ(z); tile.dirty = true; tile.updateTransform(); this.tiles[z] = gid; diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js index 47233e51e1..89e00cb9b2 100644 --- a/cocos2d/tilemap/CCTMXObjectGroup.js +++ b/cocos2d/tilemap/CCTMXObjectGroup.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index b76ce052c9..80fec01956 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index 235db4772d..2fa881431f 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -613,8 +613,8 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ // PARSE var tiles = selTileset.getElementsByTagName('tile'); if (tiles) { - for (i = 0; i < tiles.length; i++) { - var t = tiles[i]; + for (var tIdx = 0; tIdx < tiles.length; tIdx++) { + var t = tiles[tIdx]; this.parentGID = parseInt(tileset.firstGid) + parseInt(t.getAttribute('id') || 0); var tp = t.querySelectorAll("properties > property"); if (tp) { diff --git a/cocos2d/tilemap/CCTileMapAtlas.js b/cocos2d/tilemap/CCTileMapAtlas.js index 62b4689de2..9fe38f92cc 100644 --- a/cocos2d/tilemap/CCTileMapAtlas.js +++ b/cocos2d/tilemap/CCTileMapAtlas.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 09bdec9035..3afae82447 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/transitions/CCTransitionPageTurn.js b/cocos2d/transitions/CCTransitionPageTurn.js index 49baf685fb..739db6f3ca 100644 --- a/cocos2d/transitions/CCTransitionPageTurn.js +++ b/cocos2d/transitions/CCTransitionPageTurn.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index 988365fdf0..17130f0830 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBAnimationManager.js b/extensions/ccb-reader/CCBAnimationManager.js index 17c4b4317a..fd330b01cb 100644 --- a/extensions/ccb-reader/CCBAnimationManager.js +++ b/extensions/ccb-reader/CCBAnimationManager.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBKeyframe.js b/extensions/ccb-reader/CCBKeyframe.js index 57da466e85..c3eb7afaeb 100644 --- a/extensions/ccb-reader/CCBKeyframe.js +++ b/extensions/ccb-reader/CCBKeyframe.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index 98636f9c47..7da5f1bb1a 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBReaderUtil.js b/extensions/ccb-reader/CCBReaderUtil.js index ec327c8533..d3ebcfa821 100644 --- a/extensions/ccb-reader/CCBReaderUtil.js +++ b/extensions/ccb-reader/CCBReaderUtil.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBRelativePositioning.js b/extensions/ccb-reader/CCBRelativePositioning.js index b314bab304..53c7e901a9 100644 --- a/extensions/ccb-reader/CCBRelativePositioning.js +++ b/extensions/ccb-reader/CCBRelativePositioning.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBSequence.js b/extensions/ccb-reader/CCBSequence.js index b991c48e4b..a1bc0e2734 100644 --- a/extensions/ccb-reader/CCBSequence.js +++ b/extensions/ccb-reader/CCBSequence.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBValue.js b/extensions/ccb-reader/CCBValue.js index c8f028f0c7..9f5924cae1 100644 --- a/extensions/ccb-reader/CCBValue.js +++ b/extensions/ccb-reader/CCBValue.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCControlLoader.js b/extensions/ccb-reader/CCControlLoader.js index 859f9eceed..c739e2cc14 100644 --- a/extensions/ccb-reader/CCControlLoader.js +++ b/extensions/ccb-reader/CCControlLoader.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCNodeLoader.js b/extensions/ccb-reader/CCNodeLoader.js index 4a2da84488..99ffa33290 100644 --- a/extensions/ccb-reader/CCNodeLoader.js +++ b/extensions/ccb-reader/CCNodeLoader.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCNodeLoaderLibrary.js b/extensions/ccb-reader/CCNodeLoaderLibrary.js index 85a6b4cbfb..487dc7b2fe 100644 --- a/extensions/ccb-reader/CCNodeLoaderLibrary.js +++ b/extensions/ccb-reader/CCNodeLoaderLibrary.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCSpriteLoader.js b/extensions/ccb-reader/CCSpriteLoader.js index 13c0ceaee6..604a6324ed 100644 --- a/extensions/ccb-reader/CCSpriteLoader.js +++ b/extensions/ccb-reader/CCSpriteLoader.js @@ -1,7 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 7ff359a4de..32adf58d16 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 8518cef628..ad41615785 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/layouts/UILayoutDefine.js b/extensions/ccui/layouts/UILayoutDefine.js index ab8ba0afb1..baac1615e2 100644 --- a/extensions/ccui/layouts/UILayoutDefine.js +++ b/extensions/ccui/layouts/UILayoutDefine.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index ab0d88d7a8..9a09a27127 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/system/CocosGUI.js b/extensions/ccui/system/CocosGUI.js index 5d8966092b..bcd9f7c123 100644 --- a/extensions/ccui/system/CocosGUI.js +++ b/extensions/ccui/system/CocosGUI.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 9497372000..fff3af6778 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 1e878ca816..37b11ed1cf 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index ab0eb005e6..72462d988d 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 839c273d18..7ad416beca 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 73358bab9a..e78b6e7581 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -251,9 +252,9 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ if (this._renderBarTexType == ccui.Widget.PLIST_TEXTURE) { var barNode = this._barRenderer; if (barNode) { - var to = barNode.getTextureRect()._origin; - x = to.x; - y = to.y; + var rect = barNode.getTextureRect(); + x = rect.x; + y = rect.y; } } if (this._scale9Enabled) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index a3b15e9df5..06427a79cd 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 3563f26d47..e3693bdfb7 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -408,9 +409,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ if (this._progressBarTexType == ccui.Widget.PLIST_TEXTURE) { var barNode = this._progressBarRenderer; if (barNode) { - var to = barNode.getTextureRect()._origin; - x = to.x; - y = to.y; + var rect = barNode.getTextureRect(); + x = rect.x; + y = rect.y; } } this._progressBarRenderer.setTextureRect(cc.rect(x, y, this._progressBarTextureSize.width * (percent / 100.0), this._progressBarTextureSize.height)); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 24b98b50ec..6c33d49a02 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 34ac176eeb..887c6084f9 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 1f6fd49291..ef8d365a81 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 0b7e74d3a5..4576fc4ef2 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 0c5be09bd6..19082c880d 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index ff0b8e2543..d60f9c4ea9 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 0c0ef0d978..33c6a3077c 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/CocoStudio.js b/extensions/cocostudio/CocoStudio.js index 74ba3c0751..f0febd3726 100644 --- a/extensions/cocostudio/CocoStudio.js +++ b/extensions/cocostudio/CocoStudio.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index e26f347538..4fed31dbb8 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index 8c8b3ea7e6..a4a9becbbf 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index ccac6385fb..0d206bf1ab 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js index 8430b73635..289f509709 100644 --- a/extensions/cocostudio/action/CCActionObject.js +++ b/extensions/cocostudio/action/CCActionObject.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index fa4d89f893..8ca2af9361 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index b150c2aa11..ad03c0c9f4 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 60385d8da1..5c72afac4b 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index 5166acc62f..251fa52059 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index c42c2e71a3..71a47e9508 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index a4680f4b24..3df3fe9b50 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index ad8307b5f7..8eeef78217 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js index 2a537eccda..314c67f7bd 100644 --- a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +++ b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index a898315dc8..3286b8f640 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index e49855c9e5..e6940b5192 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index d77bb8ee1e..58667c605f 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index 25dd2b3404..b907aba4a8 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 25be4680d6..573f6d4a41 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/utils/CCArmatureDefine.js b/extensions/cocostudio/armature/utils/CCArmatureDefine.js index de82c45931..7ed4fd10ad 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDefine.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDefine.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index e072c1cc2d..d3307cf1de 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index c79a854a80..93efbc3d68 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index d2430c2b10..4dea62f99a 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/utils/CCTweenFunction.js b/extensions/cocostudio/armature/utils/CCTweenFunction.js index 15a71cc16f..259b005065 100644 --- a/extensions/cocostudio/armature/utils/CCTweenFunction.js +++ b/extensions/cocostudio/armature/utils/CCTweenFunction.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/armature/utils/CCUtilMath.js b/extensions/cocostudio/armature/utils/CCUtilMath.js index b960b05754..d03e7334d1 100644 --- a/extensions/cocostudio/armature/utils/CCUtilMath.js +++ b/extensions/cocostudio/armature/utils/CCUtilMath.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/components/CCComAttribute.js b/extensions/cocostudio/components/CCComAttribute.js index 0b91d17cbe..b1940b107f 100644 --- a/extensions/cocostudio/components/CCComAttribute.js +++ b/extensions/cocostudio/components/CCComAttribute.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/components/CCComAudio.js b/extensions/cocostudio/components/CCComAudio.js index a3868a7c78..6654457225 100644 --- a/extensions/cocostudio/components/CCComAudio.js +++ b/extensions/cocostudio/components/CCComAudio.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/components/CCComController.js b/extensions/cocostudio/components/CCComController.js index 1f2c7ead72..209340e228 100644 --- a/extensions/cocostudio/components/CCComController.js +++ b/extensions/cocostudio/components/CCComController.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/components/CCComRender.js b/extensions/cocostudio/components/CCComRender.js index 5626d03ba8..738aca4fef 100644 --- a/extensions/cocostudio/components/CCComRender.js +++ b/extensions/cocostudio/components/CCComRender.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/components/CCComponent.js b/extensions/cocostudio/components/CCComponent.js index e444b2da0e..a32daa9411 100644 --- a/extensions/cocostudio/components/CCComponent.js +++ b/extensions/cocostudio/components/CCComponent.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/components/CCComponentContainer.js b/extensions/cocostudio/components/CCComponentContainer.js index 470561f3ed..06bf70e458 100644 --- a/extensions/cocostudio/components/CCComponentContainer.js +++ b/extensions/cocostudio/components/CCComponentContainer.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 37e4847d48..feec1364a6 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 2d73b83801..9f6f44dd0c 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/trigger/ObjectFactory.js b/extensions/cocostudio/trigger/ObjectFactory.js index be74b1a0f6..fdc0f36669 100644 --- a/extensions/cocostudio/trigger/ObjectFactory.js +++ b/extensions/cocostudio/trigger/ObjectFactory.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/trigger/TriggerBase.js b/extensions/cocostudio/trigger/TriggerBase.js index b8f4f68482..36bf20b460 100644 --- a/extensions/cocostudio/trigger/TriggerBase.js +++ b/extensions/cocostudio/trigger/TriggerBase.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/trigger/TriggerMng.js b/extensions/cocostudio/trigger/TriggerMng.js index 988e27893d..3b2dd9c298 100644 --- a/extensions/cocostudio/trigger/TriggerMng.js +++ b/extensions/cocostudio/trigger/TriggerMng.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/cocostudio/trigger/TriggerObj.js b/extensions/cocostudio/trigger/TriggerObj.js index e0b19d2634..ca31188aa7 100644 --- a/extensions/cocostudio/trigger/TriggerObj.js +++ b/extensions/cocostudio/trigger/TriggerObj.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index f536db4488..9feb9b9c42 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2012 James Chen http://www.cocos2d-x.org diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index 641c1ecd95..35e22693a4 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -1,7 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/gui/control-extension/CCControl.js b/extensions/gui/control-extension/CCControl.js index d2b83b053d..dd519f76ee 100644 --- a/extensions/gui/control-extension/CCControl.js +++ b/extensions/gui/control-extension/CCControl.js @@ -1,6 +1,7 @@ /** - * - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * Copyright 2011 Yannick Loriot. * http://yannickloriot.com * @@ -22,8 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * - * converted to Javascript / cocos2d-x by Angus C */ /** Number of kinds of control event. */ diff --git a/extensions/gui/control-extension/CCControlButton.js b/extensions/gui/control-extension/CCControlButton.js index 132966f4b9..fe89f4e54c 100644 --- a/extensions/gui/control-extension/CCControlButton.js +++ b/extensions/gui/control-extension/CCControlButton.js @@ -1,7 +1,9 @@ /** * CCControlButton.m * - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * Copyright 2011 Yannick Loriot. * http://yannickloriot.com * diff --git a/extensions/gui/control-extension/CCControlColourPicker.js b/extensions/gui/control-extension/CCControlColourPicker.js index cde810b43a..03814ed519 100644 --- a/extensions/gui/control-extension/CCControlColourPicker.js +++ b/extensions/gui/control-extension/CCControlColourPicker.js @@ -1,6 +1,8 @@ /** * - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk @@ -24,10 +26,8 @@ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + * THE SOFTWARE. * * - * - * converted to Javascript / cocos2d-x by Angus C */ /** diff --git a/extensions/gui/control-extension/CCControlHuePicker.js b/extensions/gui/control-extension/CCControlHuePicker.js index e4543d1ff6..485a84c239 100644 --- a/extensions/gui/control-extension/CCControlHuePicker.js +++ b/extensions/gui/control-extension/CCControlHuePicker.js @@ -1,6 +1,8 @@ /** * - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk diff --git a/extensions/gui/control-extension/CCControlPotentiometer.js b/extensions/gui/control-extension/CCControlPotentiometer.js index c4cf3f9325..0f29baf387 100644 --- a/extensions/gui/control-extension/CCControlPotentiometer.js +++ b/extensions/gui/control-extension/CCControlPotentiometer.js @@ -1,5 +1,8 @@ /** - * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * * http://www.cocos2d-x.org * * Copyright 2012 Yannick Loriot. All rights reserved. diff --git a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js index 5117ac0508..00eff64a72 100644 --- a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js +++ b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js @@ -1,6 +1,8 @@ /** * - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Copyright 2012 Stewart Hamilton-Arrandale. * http://creativewax.co.uk diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index ed1016fee5..c762409c2b 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -1,6 +1,8 @@ /** * - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Copyright 2011 Yannick Loriot. All rights reserved. * http://yannickloriot.com diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js index 926e7855ff..4dabaae3b1 100644 --- a/extensions/gui/control-extension/CCControlStepper.js +++ b/extensions/gui/control-extension/CCControlStepper.js @@ -1,5 +1,8 @@ /** - * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * * http://www.cocos2d-x.org * * Copyright 2012 Yannick Loriot. All rights reserved. diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js index 45f82dbef2..88b969e646 100644 --- a/extensions/gui/control-extension/CCControlSwitch.js +++ b/extensions/gui/control-extension/CCControlSwitch.js @@ -1,6 +1,8 @@ /** * - * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2008-2010 Ricardo Quesada + * Copyright (c) 2011-2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Copyright 2011 Yannick Loriot. All rights reserved. * http://yannickloriot.com diff --git a/extensions/gui/control-extension/CCControlUtils.js b/extensions/gui/control-extension/CCControlUtils.js index 327e09790e..f2701c261a 100644 --- a/extensions/gui/control-extension/CCControlUtils.js +++ b/extensions/gui/control-extension/CCControlUtils.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright 2012 Stewart Hamilton-Arrandale. http://creativewax.co.uk diff --git a/extensions/gui/control-extension/CCInvocation.js b/extensions/gui/control-extension/CCInvocation.js index b3fff1f9a9..881fec6865 100644 --- a/extensions/gui/control-extension/CCInvocation.js +++ b/extensions/gui/control-extension/CCInvocation.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/gui/control-extension/CCMenuPassive.js b/extensions/gui/control-extension/CCMenuPassive.js index ba0a3e831d..4a0da21985 100644 --- a/extensions/gui/control-extension/CCMenuPassive.js +++ b/extensions/gui/control-extension/CCMenuPassive.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index e38b779ed0..ab82a877da 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2012 Neofect. All rights reserved. http://www.cocos2d-x.org diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index e7cf71cf58..fd6bb644a3 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2010 Sangwoo Im http://www.cocos2d-x.org diff --git a/extensions/gui/scrollview/CCSorting.js b/extensions/gui/scrollview/CCSorting.js index 96fe4b1493..0d9faa5c90 100644 --- a/extensions/gui/scrollview/CCSorting.js +++ b/extensions/gui/scrollview/CCSorting.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2010 Sangwoo Im http://www.cocos2d-x.org diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js index 5fb7d9b1ed..5fd24f0160 100644 --- a/extensions/gui/scrollview/CCTableView.js +++ b/extensions/gui/scrollview/CCTableView.js @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2010 Sangwoo Im http://www.cocos2d-x.org diff --git a/extensions/pluginx/plugins/AnalyticsFlurry.js b/extensions/pluginx/plugins/AnalyticsFlurry.js index 6cf264ce52..cc4481e1d7 100755 --- a/extensions/pluginx/plugins/AnalyticsFlurry.js +++ b/extensions/pluginx/plugins/AnalyticsFlurry.js @@ -1,29 +1,27 @@ -/* +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. -Functions available from FlurryAgent v1.0.0: + http://www.cocos2d-x.org -setAppVersion: function, -getFlurryAgentVersion: function, -setShowErrorInLogEnabled: function, -setDebugLogEnabled: function, -setSessionContinueSeconds: function, -setRequestInterval: function, -startSession: function, -endSession: function, -pauseSession: function, -logEvent: function, -endTimedEvent: function, -timedEvents: function, -logError: function, -logPurchase: function, -setUserId: function, -setAge: function, -setGender: function, -setLocation: function, -setEventLogging: function, -requestCallback: function + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: -*/ + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ plugin.AnalyticsFlurry = cc.Class.extend({ debug: false, diff --git a/extensions/pluginx/plugins/SocialFacebook.js b/extensions/pluginx/plugins/SocialFacebook.js index a1e0aa22c1..9f258df8fb 100644 --- a/extensions/pluginx/plugins/SocialFacebook.js +++ b/extensions/pluginx/plugins/SocialFacebook.js @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + plugin.SocialFacebook = cc.Class.extend({ /** diff --git a/extensions/pluginx/plugins/SocialQQWeibo.js b/extensions/pluginx/plugins/SocialQQWeibo.js index b7405ddea6..40ec8ec507 100644 --- a/extensions/pluginx/plugins/SocialQQWeibo.js +++ b/extensions/pluginx/plugins/SocialQQWeibo.js @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + plugin.SocialQQWeibo = cc.Class.extend({ _shareInfo: null, diff --git a/extensions/pluginx/plugins/SocialQzone.js b/extensions/pluginx/plugins/SocialQzone.js index 160c4e3c97..7063a52bfb 100644 --- a/extensions/pluginx/plugins/SocialQzone.js +++ b/extensions/pluginx/plugins/SocialQzone.js @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + plugin.SocialQzone = cc.Class.extend({ _shareInfo: null, diff --git a/extensions/pluginx/plugins/SocialTwitter.js b/extensions/pluginx/plugins/SocialTwitter.js index 34c2a5af0d..bbcaf68932 100644 --- a/extensions/pluginx/plugins/SocialTwitter.js +++ b/extensions/pluginx/plugins/SocialTwitter.js @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + plugin.SocialTwitter = cc.Class.extend({ _shareInfo: null, diff --git a/extensions/pluginx/plugins/SocialWeibo.js b/extensions/pluginx/plugins/SocialWeibo.js index cfe01a2aea..bda2c64a75 100644 --- a/extensions/pluginx/plugins/SocialWeibo.js +++ b/extensions/pluginx/plugins/SocialWeibo.js @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + plugin.SocialWeibo = cc.Class.extend({ _shareInfo: null, diff --git a/extensions/pluginx/protocols/Config.js b/extensions/pluginx/protocols/Config.js index 94f63fc279..bcf2d393e6 100644 --- a/extensions/pluginx/protocols/Config.js +++ b/extensions/pluginx/protocols/Config.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -22,7 +23,6 @@ THE SOFTWARE. ****************************************************************************/ - /** * @namespace */ diff --git a/extensions/pluginx/protocols/PluginFactory.js b/extensions/pluginx/protocols/PluginFactory.js index e56a4431f5..3c17e5b2d3 100644 --- a/extensions/pluginx/protocols/PluginFactory.js +++ b/extensions/pluginx/protocols/PluginFactory.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -22,7 +23,6 @@ THE SOFTWARE. ****************************************************************************/ - plugin.PluginType = { ADS:["AdSense"], ANALYTICS:["AdsGoogle","AnalyticsFlurry"], diff --git a/extensions/pluginx/protocols/PluginManager.js b/extensions/pluginx/protocols/PluginManager.js index 5588384d9a..d3a79bdfe3 100644 --- a/extensions/pluginx/protocols/PluginManager.js +++ b/extensions/pluginx/protocols/PluginManager.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -22,7 +23,6 @@ THE SOFTWARE. ****************************************************************************/ - var plugin = plugin || {}; /** diff --git a/extensions/pluginx/protocols/PluginProtocol.js b/extensions/pluginx/protocols/PluginProtocol.js index 5d3354dafd..8513b69a98 100644 --- a/extensions/pluginx/protocols/PluginProtocol.js +++ b/extensions/pluginx/protocols/PluginProtocol.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -22,7 +23,6 @@ THE SOFTWARE. ****************************************************************************/ - /** * @class PluginProtocol */ diff --git a/extensions/pluginx/protocols/PluginUtils.js b/extensions/pluginx/protocols/PluginUtils.js index 5603d59a4a..8435040b27 100644 --- a/extensions/pluginx/protocols/PluginUtils.js +++ b/extensions/pluginx/protocols/PluginUtils.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/pluginx/protocols/ProtocolAds.js b/extensions/pluginx/protocols/ProtocolAds.js index 66784d00c9..86f927be58 100755 --- a/extensions/pluginx/protocols/ProtocolAds.js +++ b/extensions/pluginx/protocols/ProtocolAds.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/pluginx/protocols/ProtocolAnalytics.js b/extensions/pluginx/protocols/ProtocolAnalytics.js index 1499dc1e66..5f4dd9d5dc 100755 --- a/extensions/pluginx/protocols/ProtocolAnalytics.js +++ b/extensions/pluginx/protocols/ProtocolAnalytics.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/pluginx/protocols/ProtocolSocial.js b/extensions/pluginx/protocols/ProtocolSocial.js index 1de0d75bea..287223be11 100644 --- a/extensions/pluginx/protocols/ProtocolSocial.js +++ b/extensions/pluginx/protocols/ProtocolSocial.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2012+2013 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/pluginx/samples/HelloSocial/src/myApp.js b/extensions/pluginx/samples/HelloSocial/src/myApp.js index 80ce026207..fb1fb1a355 100644 --- a/extensions/pluginx/samples/HelloSocial/src/myApp.js +++ b/extensions/pluginx/samples/HelloSocial/src/myApp.js @@ -1,29 +1,3 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - var TAG_SHARE_BY_SNWEIBO = 100; var TAG_SHARE_BY_QQWEIBO = 101; var TAG_SHARE_BY_QZONE = 102; diff --git a/template/src/myApp.js b/template/src/myApp.js index 55c767b6f0..ec63dece90 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -1,29 +1,3 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - var MyLayer = cc.Layer.extend({ helloLabel:null, sprite:null, From 4b6ca4e611f5a59d66ef29c87dc154302879e48f Mon Sep 17 00:00:00 2001 From: NatWeiss Date: Fri, 25 Apr 2014 13:52:45 -0700 Subject: [PATCH 0047/1564] Fixes WebGL Warning if Invalid Texture With WebGL, it's possible to get lots of warnings (and slow down the browser) if a texture is loaded that has no width or height. The following warnings will be generated: WebGL: INVALID_VALUE: texImage2D: no canvas CCTexture2D.js [.WebGLRenderingContext]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete' (index):1 WebGL: too many errors, no more errors will be reported to the console for this context. This pull request fixes the bug by checking the HTML element's width and height before trying to turn it into a texture. --- cocos2d/core/textures/TexturesWebGL.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index ba66b9e66d..61b94006da 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -409,6 +409,9 @@ _tmp.WebGLTexture2D = function () { if (!img) return; self.initWithElement(img); } + if (!self._htmlElementObj.width || !self._htmlElementObj.height) { + return; + } self._isLoaded = true; //upload image to buffer var gl = cc._renderContext; @@ -883,4 +886,4 @@ _tmp.WebGLTextureCache = function () { }; delete _p; -} \ No newline at end of file +} From b33676e07a8f9306172ce57c72688bd087bd289d Mon Sep 17 00:00:00 2001 From: NatWeiss Date: Fri, 25 Apr 2014 15:56:49 -0700 Subject: [PATCH 0048/1564] Fix Firefox audio bug In the `_play` method, the `offset` parameter can sometimes be `undefined`. This causes the following error in Firefox which effectively disables all audio: `TypeError: Argument 2 of AudioBufferSourceNode.start is not a finite floating-point value. sourceNode.start(0, offset);` This pull request fixes the bug by ensuring the offset is 0 if undefined. --- cocos2d/audio/CCAudio.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 8a373d726a..1ea81f65f5 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -75,6 +75,7 @@ if (cc.sys._supportWebAudio) { var self = this; var sourceNode = self._sourceNode = _ctx["createBufferSource"](); var volumeNode = self._volumeNode; + offset = offset || 0; sourceNode.buffer = self._buffer; volumeNode["gain"].value = self._volume; From ddbddcd42886deed88a4f296bf3b85fbea1595fd Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 28 Apr 2014 14:53:17 +0800 Subject: [PATCH 0049/1564] Fix chipmunk typo issue --- external/chipmunk/chipmunk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/chipmunk/chipmunk.js b/external/chipmunk/chipmunk.js index 38d0d8c191..92299ff62b 100755 --- a/external/chipmunk/chipmunk.js +++ b/external/chipmunk/chipmunk.js @@ -1544,7 +1544,7 @@ //this.vx = v.x; this.vy = v.y; var v_limit = this.v_limit; var lensq = vx * vx + vy * vy; - var scale = (lensq > v_limit*v_limit) ? v_limit / Math.sqrt(len) : 1; + var scale = (lensq > v_limit*v_limit) ? v_limit / Math.sqrt(lensq) : 1; this.vx = vx * scale; this.vy = vy * scale; From 8f94c971cd2f3dce66af2fb4feba739ae7044bfd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Apr 2014 16:07:57 +0800 Subject: [PATCH 0050/1564] Issue #4979: Add a script path to CCBoot.js --- CCBoot.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index fd0cbb399a..0813abd325 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1517,14 +1517,29 @@ cc.game = { if (document["ccConfig"]) { self.config = _init(document["ccConfig"]); } else { + try { - var txt = cc.loader._loadTxtSync("project.json"); + + var cocos_script = document.getElementsByTagName('script'); + for(var i=0;i Date: Tue, 29 Apr 2014 16:47:10 +0800 Subject: [PATCH 0051/1564] Closed #4980: Fixed a bug of ccui.LoadingBar that its barRendererScaleChangedWithSize is incorrect. --- cocos2d/core/platform/CCInputExtension.js | 8 ++++++-- extensions/ccui/uiwidgets/UILoadingBar.js | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/platform/CCInputExtension.js b/cocos2d/core/platform/CCInputExtension.js index 36013d457c..74cf905775 100644 --- a/cocos2d/core/platform/CCInputExtension.js +++ b/cocos2d/core/platform/CCInputExtension.js @@ -56,11 +56,15 @@ _p.setAccelerometerInterval = function(interval){ }; _p._registerKeyboardEvent = function(){ - cc._addEventListener(document, "keydown", function (e) { + cc._addEventListener(cc._canvas, "keydown", function (e) { cc.eventManager.dispatchEvent(new cc.EventKeyboard(e.keyCode, true)); + e.stopPropagation(); + e.preventDefault(); }); - cc._addEventListener(document, "keyup", function (e) { + cc._addEventListener(cc._canvas, "keyup", function (e) { cc.eventManager.dispatchEvent(new cc.EventKeyboard(e.keyCode, false)); + e.stopPropagation(); + e.preventDefault(); }); }; diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index e78b6e7581..d85be7669b 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -315,6 +315,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._totalLength = this._barRendererTextureSize.width; this._barRenderer.setScale(1.0); this._size.width = this._barRendererTextureSize.width; + this._size.height = this._barRendererTextureSize.height; } } else { From b6da3663df6b3b03fb945855609141cf653f3647 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Apr 2014 17:11:05 +0800 Subject: [PATCH 0052/1564] Closed #4979: Add a script to CCBoot.js --- CCBoot.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 0813abd325..719189e1e4 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1525,14 +1525,19 @@ cc.game = { var _t = cocos_script[i].getAttribute('cocos'); if(_t == '' || _t){break;} } - var _src, txt; + var _src, txt, _resPath; if(i < cocos_script.length){ _src = cocos_script[i].src; - _src && (_src = _src.replace(/(.*?)\/[^\/]*$/, '$1/project.json')); + if(_src){ + _resPath = /(.*)\//.exec(_src)[0]; + cc.loader.resPath = _resPath; + _src = cc.path.join(_resPath, 'project.json'); + } txt = cc.loader._loadTxtSync(_src); } - if(!txt) + if(!txt){ txt = cc.loader._loadTxtSync("project.json"); + } var data = JSON.parse(txt); self.config = _init(data || {}); } catch (e) { From a42ed2709ef2147bb19ea0f9f4374db305334f55 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Tue, 29 Apr 2014 14:40:07 +0300 Subject: [PATCH 0053/1564] fixed ClippingNode's DrawNode stencil bug on Canvas --- cocos2d/clipping-nodes/CCClippingNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 97a9df2ef5..a0a9bae0a9 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -395,7 +395,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ _setStencilForCanvas: function (stencil) { this._stencil = stencil; - var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); var locContext = cc._renderContext; // For texture stencil, use the sprite itself if (stencil instanceof cc.Sprite) { @@ -404,6 +403,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // For shape stencil, rewrite the draw of stencil ,only init the clip path and draw nothing. else if (stencil instanceof cc.DrawNode) { stencil.draw = function () { + var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); for (var i = 0; i < stencil._buffer.length; i++) { var element = stencil._buffer[i]; var vertices = element.verts; From 81b8eb107986fb4617b4fec9ba685184f9937a7c Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 30 Apr 2014 10:15:23 +0800 Subject: [PATCH 0054/1564] Remove a useless variable in CCClass --- cocos2d/core/platform/CCClass.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index b55ff2dacd..81225ab019 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -82,7 +82,7 @@ var ClassManager = { ClassManager.compileSuper.ClassManager = ClassManager; (function () { - var initializing = false, fnTest = /\b_super\b/; + var fnTest = /\b_super\b/; var config = cc.game.config; var releaseMode = config[cc.game.CONFIG_KEY.classReleaseMode]; if(releaseMode) { From e0ec5a3c0168b54352548f658c00cd416866de2d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 30 Apr 2014 10:48:59 +0800 Subject: [PATCH 0055/1564] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSprite.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index eddde0ebd7..ba59f09984 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1287,6 +1287,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (!rect) { rect = cc.rect(0, 0, texture.width, texture.height); } + + if(rect.x + rect.width > texture.width){ + rect.width = texture.width - rect.x; + } + if(rect.y + rect.height > texture.height){ + rect.height = texture.height - rect.y; + } + _t._originalTexture = texture; _t.texture = texture; From 386709598373980e33070790aab1a6a95c82b780 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 30 Apr 2014 10:51:54 +0800 Subject: [PATCH 0056/1564] Closed #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSpriteFrame.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 38cc93687b..d97a8055bc 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -353,6 +353,13 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this.setTexture(texture); } + if(rect.x + rect.width > texture.width){ + rect.width = texture.width - rect.x; + } + if(rect.y + rect.height > texture.height){ + rect.height = texture.height - rect.y; + } + this._rectInPixels = rect; this._rect = cc.rectPixelsToPoints(rect); this._offsetInPixels.x = offset.x; From 91b95f08129f00f51998c75b15a11912a809709b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 30 Apr 2014 11:01:12 +0800 Subject: [PATCH 0057/1564] Closed #4988: AddSpriteFrames is error after cc.loeader.release. --- cocos2d/core/sprites/CCSpriteFrameCache.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 699bcebdcf..6614ddf5a8 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -194,8 +194,8 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ cc.assert(url, cc._LogInfos.spriteFrameCache_addSpriteFrames_2); //Is it a SpriteFrame plist? - var dict = cc.loader.getRes(url); - if(!dict["frames"]) + var dict = this._frameConfigCache[url] || cc.loader.getRes(url); + if(!dict || !dict["frames"]) return; var self = this; From b715b3ce3437f7018ee6614eb4c6f16d252c94a5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 30 Apr 2014 11:28:58 +0800 Subject: [PATCH 0058/1564] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSprite.js | 8 ++------ cocos2d/core/sprites/CCSpriteFrame.js | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index ba59f09984..4d949cad30 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1288,12 +1288,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { rect = cc.rect(0, 0, texture.width, texture.height); } - if(rect.x + rect.width > texture.width){ - rect.width = texture.width - rect.x; - } - if(rect.y + rect.height > texture.height){ - rect.height = texture.height - rect.y; - } + cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); _t._originalTexture = texture; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index d97a8055bc..8e5fd44060 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -353,12 +353,8 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this.setTexture(texture); } - if(rect.x + rect.width > texture.width){ - rect.width = texture.width - rect.x; - } - if(rect.y + rect.height > texture.height){ - rect.height = texture.height - rect.y; - } + cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); this._rectInPixels = rect; this._rect = cc.rectPixelsToPoints(rect); From 27b2160ce71986dfd3a9a20c170f599b68fc2258 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 30 Apr 2014 18:28:32 +0800 Subject: [PATCH 0059/1564] Closed #4993: CCDrawNode drawSegment a bug --- cocos2d/shape-nodes/CCDrawNode.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index f59f4a27f1..5ce0da3741 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -868,6 +868,9 @@ cc.DrawNodeWebGL = cc.Node.extend({ var b = {vertices: {x: pos.x - radius, y: pos.y + radius}, colors: c4bColor, texCoords: {u: -1.0, v: 1.0}}; var c = {vertices: {x: pos.x + radius, y: pos.y + radius}, colors: c4bColor, texCoords: {u: 1.0, v: 1.0}}; var d = {vertices: {x: pos.x + radius, y: pos.y - radius}, colors: c4bColor, texCoords: {u: 1.0, v: -1.0}}; + + this._ensureCapacity(2*3); + this._buffer.push(new cc.V2F_C4B_T2F_Triangle(a, b, c, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT)); this._buffer.push(new cc.V2F_C4B_T2F_Triangle(a, c, d, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT)); this._dirty = true; From 1a992026888307da650ef972c2ba3d491539c528 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 4 May 2014 14:26:24 +0800 Subject: [PATCH 0060/1564] Closed #4998: Typo in method name: cc.radiansToDegress --- cocos2d/actions/CCActionCamera.js | 4 ++-- cocos2d/core/platform/CCMacro.js | 4 ++++ cocos2d/particle/CCParticleSystem.js | 2 +- cocos2d/physics/CCPhysicsSprite.js | 6 +++--- extensions/cocostudio/armature/display/CCSkin.js | 4 ++-- extensions/gui/control-extension/CCControlHuePicker.js | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 8766e2095f..6610acba3b 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -188,10 +188,10 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ _t._radius = retValue.newRadius; if (isNaN(_t._angleZ)) - _t._angleZ = cc.radiansToDegress(retValue.zenith); + _t._angleZ = cc.radiansToDegrees(retValue.zenith); if (isNaN(_t._angleX)) - _t._angleX = cc.radiansToDegress(retValue.azimuth); + _t._angleX = cc.radiansToDegrees(retValue.azimuth); _t._radZ = cc.degreesToRadians(_t._angleZ); _t._radX = cc.degreesToRadians(_t._angleX); diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 5496215d93..b7ca167e22 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -140,7 +140,11 @@ cc.degreesToRadians = function (angle) { * @return {Number} * @function */ +cc.radiansToDegrees = function (angle) { + return angle * cc.DEG; +}; cc.radiansToDegress = function (angle) { + cc.log('cc.radiansToDegress() should be called cc.radiansToDegrees()'); return angle * cc.DEG; }; diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 871af2f38b..87827f8f36 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1844,7 +1844,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // rotation is dir if(locModeA.rotationIsDir) - particle.rotation = -cc.radiansToDegress(cc.pToAngle(locParticleModeA.dir)); + particle.rotation = -cc.radiansToDegrees(cc.pToAngle(locParticleModeA.dir)); } else { // Mode Radius: B var locModeB = this.modeB, locParitlceModeB = particle.modeB; diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 733690a633..36d84e9040 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -115,7 +115,7 @@ this.setNodeDirty(); }, getRotation:function () { - return (this._ignoreBodyRotation ? cc.radiansToDegress(this._rotationRadians) : cc.radiansToDegress(this._body.GetAngle())); + return (this._ignoreBodyRotation ? cc.radiansToDegrees(this._rotationRadians) : cc.radiansToDegrees(this._body.GetAngle())); }, setRotation:function (r) { if (this._ignoreBodyRotation) { @@ -251,7 +251,7 @@ } }, getRotation:function () { - return this._ignoreBodyRotation ? cc.radiansToDegress(this._rotationRadiansX) : -cc.radiansToDegress(this._body.a); + return this._ignoreBodyRotation ? cc.radiansToDegrees(this._rotationRadiansX) : -cc.radiansToDegrees(this._body.a); }, setRotation:function (r) { if (this._ignoreBodyRotation) { @@ -263,7 +263,7 @@ }, _syncRotation:function () { if (this._rotationRadiansX != -this._body.a) { - cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegress(this._body.a)); + cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegrees(this._body.a)); } }, nodeToParentTransform:function () { diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 58667c605f..8eee27d06e 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -63,8 +63,8 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this.setScaleX(skinData.scaleX); this.setScaleY(skinData.scaleY); - this.setRotationX(cc.radiansToDegress(skinData.skewX)); - this.setRotationY(cc.radiansToDegress(-skinData.skewY)); + this.setRotationX(cc.radiansToDegrees(skinData.skewX)); + this.setRotationY(cc.radiansToDegrees(-skinData.skewY)); this.setPosition(skinData.x, skinData.y); var localTransform = this.nodeToParentTransform(); diff --git a/extensions/gui/control-extension/CCControlHuePicker.js b/extensions/gui/control-extension/CCControlHuePicker.js index 485a84c239..92d5097bf2 100644 --- a/extensions/gui/control-extension/CCControlHuePicker.js +++ b/extensions/gui/control-extension/CCControlHuePicker.js @@ -135,7 +135,7 @@ cc.ControlHuePicker = cc.Control.extend(/** @lends cc.ControlHuePicker# */{ // Update angle by using the direction of the location var angle = Math.atan2(dy, dx); - var angleDeg = cc.radiansToDegress(angle) + 180.0; + var angleDeg = cc.radiansToDegrees(angle) + 180.0; // use the position / slider width to determin the percentage the dragger is at this.setHue(angleDeg); From 30dd7fcdbd595608109a69acf69b41d0e9eb10c4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 May 2014 14:54:28 +0800 Subject: [PATCH 0061/1564] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSprite.js | 4 ++-- cocos2d/core/sprites/CCSpriteFrame.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4d949cad30..4b40ca6757 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1288,8 +1288,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { rect = cc.rect(0, 0, texture.width, texture.height); } - cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + cc.assert(rect.x + rect.width <= texture.width || texture == "", 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(rect.y + rect.height <= texture.height || texture == "", 'Rect height exceeds the maximum margin: %s', texture.url); _t._originalTexture = texture; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 8e5fd44060..5a581f2888 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -353,8 +353,8 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this.setTexture(texture); } - cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + cc.assert(rect.x + rect.width <= texture.width || texture == "", 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(rect.y + rect.height <= texture.height || texture == "", 'Rect height exceeds the maximum margin: %s', texture.url); this._rectInPixels = rect; this._rect = cc.rectPixelsToPoints(rect); From fc2aba49ce34835066ac11feff1983cb6c6f7c30 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 May 2014 15:00:44 +0800 Subject: [PATCH 0062/1564] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSprite.js | 6 ++++-- cocos2d/core/sprites/CCSpriteFrame.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4b40ca6757..635aeb5120 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1288,8 +1288,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { rect = cc.rect(0, 0, texture.width, texture.height); } - cc.assert(rect.x + rect.width <= texture.width || texture == "", 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(rect.y + rect.height <= texture.height || texture == "", 'Rect height exceeds the maximum margin: %s', texture.url); + if(!texture) { + cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + } _t._originalTexture = texture; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 5a581f2888..9eb4344e60 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -353,8 +353,10 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this.setTexture(texture); } - cc.assert(rect.x + rect.width <= texture.width || texture == "", 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(rect.y + rect.height <= texture.height || texture == "", 'Rect height exceeds the maximum margin: %s', texture.url); + if(!texture){ + cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + } this._rectInPixels = rect; this._rect = cc.rectPixelsToPoints(rect); From bc931df80e58766c55e4aa1b65c26f043e206f99 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 May 2014 15:52:22 +0800 Subject: [PATCH 0063/1564] Issue #5019: ccui.ImageView The picture is not pre loaded setSize invalid --- extensions/ccui/uiwidgets/UIImageView.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 7ad416beca..9d348e05c8 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -79,13 +79,13 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ var locRendererSize = imageRenderer.getContentSize(); if(imageRenderer.textureLoaded()){ - this._imageTextureSize.width = locRendererSize.width; - this._imageTextureSize.height = locRendererSize.height; + this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locRendererSize.width; + this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locRendererSize.height; }else{ imageRenderer.addLoadedEventListener(function(){ var locSize = imageRenderer.getContentSize(); - this._imageTextureSize.width = locSize.width; - this._imageTextureSize.height = locSize.height; + this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locSize.width; + this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locSize.height; if (imageRenderer.setCapInsets) { imageRenderer.setCapInsets(this._capInsets); } From 5776a24ec01340ffc60117b10728750158b5da90 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 May 2014 11:13:34 +0800 Subject: [PATCH 0064/1564] Issue #5019: ccui.ImageView The picture is not pre loaded setSize invalid --- cocos2d/core/sprites/CCSprite.js | 2 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 635aeb5120..017228d189 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -820,7 +820,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ var texture = cc.textureCache.textureForKey(filename); if (!texture) { texture = cc.textureCache.addImage(filename); - return this.initWithTexture(texture, rect); + return this.initWithTexture(texture, rect || cc.rect(0, 0, 0, 0)); } else { if (!rect) { var size = texture.getContentSize(); diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 9d348e05c8..d079ee4516 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -65,7 +65,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._textureFile = fileName; this._imageTexType = texType; - var imageRenderer = this._imageRenderer + var imageRenderer = this._imageRenderer; switch (this._imageTexType) { case ccui.Widget.LOCAL_TEXTURE: imageRenderer.initWithFile(fileName); From e1f5ca48b6fc0d2ff0ab5649f7f4307c91e0aaef Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 May 2014 18:01:46 +0800 Subject: [PATCH 0065/1564] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSprite.js | 29 +++++++++++++++++----- cocos2d/core/sprites/CCSpriteFrame.js | 15 ++++++++--- cocos2d/core/sprites/CCSpriteFrameCache.js | 15 ----------- cocos2d/core/sprites/SpritesWebGL.js | 14 +++++++++++ 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 017228d189..cfa0384cfb 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -209,7 +209,6 @@ cc.cutRotateImageToCanvas = function (texture, rect) { var nCanvas = cc.newElement("canvas"); nCanvas.width = rect.width; nCanvas.height = rect.height; - var ctx = nCanvas.getContext("2d"); ctx.translate(nCanvas.width / 2, nCanvas.height / 2); ctx.rotate(-1.5707963267948966); @@ -425,8 +424,9 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ this._textureLoaded = false; spriteFrame.addLoadedEventListener(this._spriteFrameLoadedCallback, this); } - var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect()); + this.setSpriteFrame(spriteFrame); + var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect(), spriteFrame._rotated); return ret; }, @@ -1246,6 +1246,18 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { rotated = rotated || false; + + if (rotated && texture.isLoaded()) { + var tempElement = texture.getHtmlElementObj(); + tempElement = cc.cutRotateImageToCanvas(tempElement, rect); + var tempTexture = new cc.Texture2D(); + tempTexture.initWithElement(tempElement); + tempTexture.handleLoadedTexture(); + texture = tempTexture; + + _t._rect = cc.rect(0, 0, rect.width, rect.height); + } + if (!cc.NodeRGBA.prototype.init.call(_t)) return false; @@ -1273,7 +1285,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._textureLoaded = locTextureLoaded; if (!locTextureLoaded) { - _t._rectRotated = rotated || false; + _t._rectRotated = rotated; if (rect) { _t._rect.x = rect.x; _t._rect.y = rect.y; @@ -1288,9 +1300,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { rect = cc.rect(0, 0, texture.width, texture.height); } - if(!texture) { - cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + if(texture) { + var _x, _y; + + _x = rect.x + rect.width; + _y = rect.y + rect.height; + + cc.assert(_x <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(_y <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); } _t._originalTexture = texture; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 9eb4344e60..9844805354 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -353,9 +353,18 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this.setTexture(texture); } - if(!texture){ - cc.assert(rect.x + rect.width <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(rect.y + rect.height <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + + if(texture) { + var _x, _y; + if(rotated){ + _x = rect.y + rect.height; + _y = rect.x + rect.width; + }else{ + _x = rect.x + rect.width; + _y = rect.y + rect.height; + } + cc.assert(_x <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(_y <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); } this._rectInPixels = rect; diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 6614ddf5a8..50e7266d70 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -230,21 +230,6 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ spAliases[alias] = key; } } - if (cc._renderType === cc._RENDER_TYPE_CANVAS && spriteFrame.isRotated()) { - //clip to canvas - var locTexture = spriteFrame.getTexture(); - if (locTexture.isLoaded()) { - var tempElement = spriteFrame.getTexture().getHtmlElementObj(); - tempElement = cc.cutRotateImageToCanvas(tempElement, spriteFrame.getRectInPixels()); - var tempTexture = new cc.Texture2D(); - tempTexture.initWithElement(tempElement); - tempTexture.handleLoadedTexture(); - spriteFrame.setTexture(tempTexture); - - var rect = spriteFrame._rect; - spriteFrame.setRect(cc.rect(0, 0, rect.width, rect.height)); - } - } spriteFrames[key] = spriteFrame; } } diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 1a949732fc..164153c546 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -174,6 +174,20 @@ _tmp.WebGLSprite = function () { if (!rect) { rect = cc.rect(0, 0, texture.width, texture.height); } + + if(texture) { + var _x, _y; + if(rotated){ + _x = rect.y + rect.height; + _y = rect.x + rect.width; + }else{ + _x = rect.x + rect.width; + _y = rect.y + rect.height; + } + cc.assert(_x <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); + cc.assert(_y <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + } + _t.texture = texture; _t.setTextureRect(rect, rotated); From 35a1e37d00d0b1df0099b15c34dde6f68d142b8f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 May 2014 09:58:39 +0800 Subject: [PATCH 0066/1564] Issue #4986: Reduction of CCSpriteFrameCache rotation method --- cocos2d/core/sprites/CCSpriteFrameCache.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 50e7266d70..f525202f49 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -230,6 +230,26 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ spAliases[alias] = key; } } + + if (cc._renderType === cc._RENDER_TYPE_CANVAS && spriteFrame.isRotated()) { + //clip to canvas + var locTexture = spriteFrame.getTexture(); + if (locTexture.isLoaded()) { + + spriteFrame.setRotated(false); + + var tempElement = spriteFrame.getTexture().getHtmlElementObj(); + tempElement = cc.cutRotateImageToCanvas(tempElement, spriteFrame.getRectInPixels()); + var tempTexture = new cc.Texture2D(); + tempTexture.initWithElement(tempElement); + tempTexture.handleLoadedTexture(); + spriteFrame.setTexture(tempTexture); + + var rect = spriteFrame._rect; + spriteFrame.setRect(cc.rect(0, 0, rect.width, rect.height)); + } + } + spriteFrames[key] = spriteFrame; } } From 4d437931e7f6784bc1772701e090525c8269f852 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 May 2014 10:20:37 +0800 Subject: [PATCH 0067/1564] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSpriteFrame.js | 4 ++-- cocos2d/core/sprites/SpritesWebGL.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 9844805354..0cd67b1d46 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -357,8 +357,8 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ if(texture) { var _x, _y; if(rotated){ - _x = rect.y + rect.height; - _y = rect.x + rect.width; + _x = rect.x + rect.height; + _y = rect.y + rect.width; }else{ _x = rect.x + rect.width; _y = rect.y + rect.height; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 164153c546..5c435096de 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -178,8 +178,8 @@ _tmp.WebGLSprite = function () { if(texture) { var _x, _y; if(rotated){ - _x = rect.y + rect.height; - _y = rect.x + rect.width; + _x = rect.x + rect.height; + _y = rect.y + rect.width; }else{ _x = rect.x + rect.width; _y = rect.y + rect.height; From 92f25c24786d7d3d1f83ac7ff348bb6240051cbc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 7 May 2014 14:03:21 +0800 Subject: [PATCH 0068/1564] Issue #5040: Improve ParticleSystem default initialization, no init function call if no parameter given --- 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 87827f8f36..69201b3023 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -364,11 +364,11 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ this._quadsArrayBuffer = null; } - if (!plistFile || typeof(plistFile) === "number") { - var ton = plistFile || 100; + if (typeof(plistFile) === "number") { + var ton = plistFile; this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); this.initWithTotalParticles(ton); - }else{ + } else if (plistFile) { this.initWithFile(plistFile); } }, From fb592b4c780c897c63b01321924b55cf1dcad04a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 7 May 2014 16:53:44 +0800 Subject: [PATCH 0069/1564] Closed #4975: integrate spine into -html5 v3.0 beta --- CCBoot.js | 3 - cocos2d/core/platform/CCLoaders.js | 2 +- cocos2d/core/platform/CCMacro.js | 6 + cocos2d/core/sprites/CCSprite.js | 33 +- cocos2d/core/sprites/SpritesWebGL.js | 4 +- cocos2d/particle/CCParticleSystem.js | 4 +- extensions/spine/CCSkeleton.js | 402 +++++ extensions/spine/CCSkeletonAnimation.js | 223 +++ extensions/spine/Spine.js | 1816 +++++++++++++++++++++++ moduleConfig.json | 9 +- 10 files changed, 2471 insertions(+), 31 deletions(-) create mode 100644 extensions/spine/CCSkeleton.js create mode 100644 extensions/spine/CCSkeletonAnimation.js create mode 100644 extensions/spine/Spine.js diff --git a/CCBoot.js b/CCBoot.js index 719189e1e4..7a48e18d6e 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -542,9 +542,6 @@ cc.loader = { * @param {!string} url * @param {object} [option] * @param {function} cb - * @param {string} url - * @param {object} [option] - * @param {function} [cb] * @returns {Image} */ loadImg: function (url, option, cb) { diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index be29833ee7..362b8074c4 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -28,7 +28,7 @@ cc._txtLoader = { cc.loader.loadTxt(realUrl, cb); } }; -cc.loader.register(["txt", "xml", "vsh", "fsh"], cc._txtLoader); +cc.loader.register(["txt", "xml", "vsh", "fsh", "atlas"], cc._txtLoader); cc._jsonLoader = { load : function(realUrl, url, res, cb){ diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index b7ca167e22..0720042476 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -43,6 +43,12 @@ cc.PI = Math.PI; */ cc.FLT_MAX = parseFloat('3.402823466e+38F'); +/** + * @constant + * @type Number + */ +cc.FLT_MIN = parseFloat("1.175494351e-38F"); + /** * @constant * @type Number diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index cfa0384cfb..8d6e8c422c 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -637,7 +637,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ * Also, flipping the texture doesn't alter the anchorPoint.
* If you want to flip the anchorPoint too, and/or to flip the children too use:
* sprite->setScaleX(sprite->getScaleX() * -1);

- * @return {Boolean} true if the sprite is flipped horizaontally, false otherwise. + * @return {Boolean} true if the sprite is flipped horizontally, false otherwise. */ isFlippedX:function () { return this._flippedX; @@ -651,7 +651,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ * Also, flipping the texture doesn't alter the anchorPoint.
* If you want to flip the anchorPoint too, and/or to flip the children too use:
* sprite->setScaleY(sprite->getScaleY() * -1);

- * @return {Boolean} true if the sprite is flipped vertically, flase otherwise. + * @return {Boolean} true if the sprite is flipped vertically, false otherwise. */ isFlippedY:function () { return this._flippedY; @@ -741,10 +741,11 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ * @function * @param {String|cc.SpriteFrame|cc.SpriteBatchNode|HTMLImageElement|cc.Texture2D} fileName sprite construct parameter * @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite. + * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. */ ctor: null, - _softInit: function (fileName, rect) { + _softInit: function (fileName, rect, rotated) { if (fileName === undefined) cc.Sprite.prototype.init.call(this); else if (typeof(fileName) === "string") { @@ -761,7 +762,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ else if (typeof(fileName) === "object") { if (fileName instanceof cc.Texture2D) { // Init with texture and rect - this.initWithTexture(fileName, rect); + this.initWithTexture(fileName, rect, rotated); } else if (fileName instanceof cc.SpriteFrame) { // Init with a sprite frame this.initWithSpriteFrame(fileName); @@ -1115,6 +1116,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ * @constructs * @param {String|cc.SpriteFrame|HTMLImageElement|cc.Texture2D} fileName The string which indicates a path to image file, e.g., "scene1/monster.png". * @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite. + * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. * @return {cc.Sprite} A valid sprite object * @example * @@ -1136,8 +1138,8 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ * var sprite2 = cc.Sprite.create(texture, cc.rect(0,0,480,320)); * */ -cc.Sprite.create = function (fileName, rect) { - return new cc.Sprite(fileName, rect); +cc.Sprite.create = function (fileName, rect, rotated) { + return new cc.Sprite(fileName, rect, rotated); }; @@ -1150,7 +1152,6 @@ cc.Sprite.INDEX_NOT_INITIALIZED = -1; if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - var _p = cc.Sprite.prototype; _p._spriteFrameLoadedCallback = function(spriteFrame){ @@ -1176,7 +1177,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._setNodeDirtyForCache(); }; - _p.ctor = function (fileName, rect) { + _p.ctor = function (fileName, rect, rotated) { var self = this; cc.NodeRGBA.prototype.ctor.call(self); self._shouldBeHidden = false; @@ -1190,7 +1191,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { self._textureRect_Canvas = {x: 0, y: 0, width: 0, height:0, validRect: false}; self._drawSize_Canvas = cc.size(0, 0); - self._softInit(fileName, rect); + self._softInit(fileName, rect, rotated); }; _p.setBlendFunc = function (src, dst) { @@ -1240,13 +1241,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.initWithTexture = function (texture, rect, rotated) { var _t = this; - var argnum = arguments.length; - - cc.assert(argnum != 0, cc._LogInfos.CCSpriteBatchNode_initWithTexture); + cc.assert(arguments.length != 0, cc._LogInfos.CCSpriteBatchNode_initWithTexture); rotated = rotated || false; - if (rotated && texture.isLoaded()) { var tempElement = texture.getHtmlElementObj(); tempElement = cc.cutRotateImageToCanvas(tempElement, rect); @@ -1262,7 +1260,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return false; _t._batchNode = null; - _t._recursiveDirty = false; _t.dirty = false; _t._opacityModifyRGB = true; @@ -1301,17 +1298,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } if(texture) { - var _x, _y; - - _x = rect.x + rect.width; - _y = rect.y + rect.height; - + var _x = rect.x + rect.width, _y = rect.y + rect.height; cc.assert(_x <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); cc.assert(_y <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); } - _t._originalTexture = texture; - _t.texture = texture; _t.setTextureRect(rect, rotated); diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 5c435096de..b77b03bd74 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -47,7 +47,7 @@ _tmp.WebGLSprite = function () { this.updateColor(); }; - _p.ctor = function (fileName, rect) { + _p.ctor = function (fileName, rect, rotated) { var self = this; cc.NodeRGBA.prototype.ctor.call(self); self._shouldBeHidden = false; @@ -62,7 +62,7 @@ _tmp.WebGLSprite = function () { self._textureLoaded = true; - self._softInit(fileName, rect); + self._softInit(fileName, rect, rotated); }; _p.setBlendFunc = function (src, dst) { diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 87827f8f36..44dc0fa36b 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2117,7 +2117,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } // color - if (!this._dontTint) { + if (!this._dontTint || cc._renderType === cc._RENDER_TYPE_CANVAS) { selParticle.color.r += (selParticle.deltaColor.r * dt); selParticle.color.g += (selParticle.deltaColor.g * dt); selParticle.color.b += (selParticle.deltaColor.b * dt); @@ -2344,7 +2344,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ retParticle._opacityModifyRGB = this._opacityModifyRGB; // texture - retParticle._texture = this._texture; + this.setTextureWithRect(this._texture,this._pointRect); } } return retParticle; diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js new file mode 100644 index 0000000000..62da6fc521 --- /dev/null +++ b/extensions/spine/CCSkeleton.js @@ -0,0 +1,402 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2014 Shengxiang Chen (Nero Chan) + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +var sp = sp || {}; + +sp.VERTEX_INDEX = { + X1: 0, + Y1: 1, + X2: 2, + Y2: 3, + X3: 4, + Y3: 5, + X4: 6, + Y4: 7 +}; + +sp.ATTACHMENT_TYPE = { + REGION: 0, + REGION_SEQUENCE: 1, + BOUNDING_BOX: 2 +}; + +sp.Skeleton = cc.NodeRGBA.extend({ + _skeleton: null, + _rootBone: null, + _timeScale: 1, + _debugSlots: false, + _debugBones: false, + _premultipliedAlpha: false, + _ownsSkeletonData: null, + _atlas: null, + _blendFunc: null, + ctor:function(){ + cc.NodeRGBA.prototype.ctor.call(this); + this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; + }, + init: function () { + cc.Node.prototype.init.call(this); + this.setOpacityModifyRGB(true); + this._blendFunc.src = cc.ONE; + this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + if (cc._renderType === cc._RENDER_TYPE_WEBGL) + this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + this.scheduleUpdate(); + }, + setDebugSolots:function(v){ + this._debugSlots = v; + }, + + setDebugBones:function(v){ + this._debugBones = v; + }, + + setTimeScale:function(v){ + this._timeScale = v; + }, + + initWithArgs: function (/*multi arguments*/) { + var argSkeletonFile = arguments[0], argAtlasFile = arguments[1], + skeletonData, atlas, scale, ownsSkeletonData; + + if (typeof argSkeletonFile == 'string') { + if (typeof argAtlasFile == 'string') { + var data = cc.loader.getRes(argAtlasFile); + sp._atlasLoader.setAtlasFile(argAtlasFile); + atlas = new spine.Atlas(data, sp._atlasLoader); + } else { + atlas = arguments[1]; + } + scale = arguments[2] || 1 / cc.director.getContentScaleFactor(); + + var attachmentLoader = new spine.AtlasAttachmentLoader(atlas); + var skeletonJsonReader = new spine.SkeletonJson(attachmentLoader); + skeletonJsonReader.scale = scale; + + var skeletonJson = cc.loader.getRes(argSkeletonFile); + skeletonData = skeletonJsonReader.readSkeletonData(skeletonJson); + atlas.dispose(skeletonJsonReader); + ownsSkeletonData = true; + } else { + skeletonData = arguments[0]; + ownsSkeletonData = arguments[1]; + } + this.setSkeletonData(skeletonData, ownsSkeletonData); + this.init(); + }, + + boundingBox: function () { + var minX = cc.FLT_MAX, minY = cc.FLT_MAX, maxX = cc.FLT_MIN, maxY = cc.FLT_MIN; + var scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices = [], + slots = this._skeleton.slots, VERTEX = sp.VERTEX_INDEX; + + for (var i = 0, slotCount = slots.length; i < slotCount; ++i) { + var slot = slots[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + var attachment = slot.attachment; + sp.regionAttachment_computeWorldVertices(attachment, slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); + minX = Math.min(minX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); + minY = Math.min(minY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY); + maxX = Math.max(maxX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); + maxY = Math.max(maxY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY); + } + var position = this.getPosition(); + return cc.rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY); + }, + updateWorldTransform: function () { + this._skeleton.updateWorldTransform(); + }, + setToSetupPose: function () { + this._skeleton.setToSetupPose(); + }, + setBonesToSetupPose: function () { + this._skeleton.setBonesToSetupPose(); + }, + setSlotsToSetupPose: function () { + this._skeleton.setSlotsToSetupPose(); + }, + findBone: function (boneName) { + return this._skeleton.findBone(boneName); + }, + findSlot: function (slotName) { + return this._skeleton.findSlot(slotName); + }, + setSkin: function (skinName) { + return this._skeleton.setSkinByName(skinName); + }, + getAttachment: function (slotName, attachmentName) { + return this._skeleton.getAttachmentBySlotName(slotName, attachmentName); + }, + setAttachment: function (slotName, attachmentName) { + return this._skeleton.setAttachment(slotName, attachmentName); + }, + setOpacityModifyRGB: function (v) { + this._premultipliedAlpha = v; + }, + isOpacityModifyRGB: function () { + return this._premultipliedAlpha; + }, + setSkeletonData: function (skeletonData, ownsSkeletonData) { + this._skeleton = new spine.Skeleton(skeletonData); + this._rootBone = this._skeleton.getRootBone(); + this._ownsSkeletonData = ownsSkeletonData; + + if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + var locSkeleton = this._skeleton, rendererObject, rect; + for (var i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { + var slot = locSkeleton.drawOrder[i]; + var attachment = slot.attachment; + if (!(attachment instanceof spine.RegionAttachment)) { + continue; + } + rendererObject = attachment.rendererObject; + rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); + var sprite = cc.Sprite.create(rendererObject.page._texture, rect, rendererObject.rotate); + this.addChild(sprite,-1); + slot.currentSprite = sprite; + } + } + }, + + getTextureAtlas: function (regionAttachment) { + return regionAttachment.rendererObject.page.rendererObject; + }, + getBlendFunc: function () { + return this._blendFunc; + }, + setBlendFunc: function (_blendFunc) { + this._blendFunc = _blendFunc; + }, + + update: function (dt) { + this._skeleton.update(dt); + + if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + var color = this.getColor(), locSkeleton = this._skeleton; + locSkeleton.updateWorldTransform(); + var drawOrder = this._skeleton.drawOrder; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var attachment = slot.attachment, selSprite = slot.currentSprite; + if (!(attachment instanceof spine.RegionAttachment)) { + if(selSprite) + selSprite.setVisible(false); + continue; + } + if(!selSprite){ + var rendererObject = attachment.rendererObject; + var rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); + var sprite = cc.Sprite.create(rendererObject.page._texture, rect, rendererObject.rotate); + this.addChild(sprite,-1); + slot.currentSprite = sprite; + } + selSprite.setVisible(true); + //update color and blendFunc + selSprite.setBlendFunc(cc.BLEND_SRC, slot.data.additiveBlending ? cc.ONE : cc.BLEND_DST); + + var bone = slot.bone; + selSprite.setPosition(bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01, + bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); + selSprite.setScale(bone.worldScaleX, bone.worldScaleY); + selSprite.setRotation(- (slot.bone.worldRotation + attachment.rotation)); + } + } + }, + + draw: null, + + _drawForWebGL: function () { + cc.nodeDrawSetup(this); +// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); + var color = this.getColor(), locSkeleton = this._skeleton; + locSkeleton.r = color.r / 255; + locSkeleton.g = color.g / 255; + locSkeleton.b = color.b / 255; + locSkeleton.a = this.getOpacity() / 255; + if (this._premultipliedAlpha) { + locSkeleton.r *= locSkeleton.a; + locSkeleton.g *= locSkeleton.a; + locSkeleton.b *= locSkeleton.a; + } + + var additive,textureAtlas,attachment,slot, i, n, + quad = new cc.V3F_C4B_T2F_Quad(); + var locBlendFunc = this._blendFunc; + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + var regionTextureAtlas = this.getTextureAtlas(attachment); + + if (slot.data.additiveBlending != additive) { + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + additive = !additive; + cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); + } else if (regionTextureAtlas != textureAtlas && textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + textureAtlas = regionTextureAtlas; + + var quadCount = textureAtlas.getTotalQuads(); + if (textureAtlas.getCapacity() == quadCount) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) + return; + } + + sp._regionAttachment_updateQuad(attachment, slot, quad, this._premultipliedAlpha); + textureAtlas.updateQuad(quad, quadCount); + } + + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + + var drawingUtil = cc._drawingUtil; + if (this._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + quad = new cc.V3F_C4B_T2F_Quad(); + sp._regionAttachment_updateQuad(attachment, slot, quad); + + var points = []; + points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); + points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); + points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); + points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); + drawingUtil.drawPoly(points, 4, true); + } + } + + if (this._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + if (i == 0) { + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + } + }, + + _drawForCanvas: function () { + if(!this._debugSlots && !this._debugBones){ + return; + } + var locSkeleton = this._skeleton; + var attachment,slot, i, n, drawingUtil = cc._drawingUtil; + if (this._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + var points = []; + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); + drawingUtil.drawPoly(points, 4, true); + } + } + + if (this._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + if (i === 0) + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + } +}); + +if (cc._renderType === cc._RENDER_TYPE_WEBGL) { + sp.Skeleton.prototype.draw = sp.Skeleton.prototype._drawForWebGL; +}else{ + sp.Skeleton.prototype.draw = sp.Skeleton.prototype._drawForCanvas; +} + +sp.Skeleton.createWithData = function (skeletonData, ownsSkeletonData) { + var c = new sp.Skeleton(); + c.initWithArgs.apply(c, arguments); + return c; +}; + +sp.Skeleton.createWithFile = function (skeletonDataFile, atlasFile/* or atlas*/, scale) { + var c = new sp.Skeleton(); + c.initWithArgs.apply(c, arguments); + return c; +}; \ No newline at end of file diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js new file mode 100644 index 0000000000..6347587daf --- /dev/null +++ b/extensions/spine/CCSkeletonAnimation.js @@ -0,0 +1,223 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2014 Shengxiang Chen (Nero Chan) + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +sp._atlasPage_createTexture_webGL = function (self, path) { + var texture = cc.textureCache.addImage(path); + self.rendererObject = cc.TextureAtlas.create(texture, 128); + self.width = texture.getPixelsWide(); + self.height = texture.getPixelsHigh(); +}; + +sp._atlasPage_createTexture_canvas = function(self, path) { + self._texture = cc.textureCache.addImage(path); +}; + +sp._atlasPage_disposeTexture = function (self) { + self.rendererObject.release(); +}; + +sp._atlasLoader = { + spAtlasFile:null, + setAtlasFile:function(spAtlasFile){ + this.spAtlasFile = spAtlasFile; + }, + load:function(page, line, spAtlas){ + var texturePath = cc.path.join(cc.path.dirname(this.spAtlasFile), line); + if (cc._renderType === cc._RENDER_TYPE_WEBGL) + sp._atlasPage_createTexture_webGL(page,texturePath); + else + sp._atlasPage_createTexture_canvas(page,texturePath); + }, + unload:function(obj){ + + } +}; + +sp.regionAttachment_computeWorldVertices = function(self, x, y, bone, vertices){ + var offset = self.offset; + x += bone.worldX; + y += bone.worldY; + var vertexIndex = sp.VERTEX_INDEX; + vertices[vertexIndex.X1] = offset[vertexIndex.X1] * bone.m00 + offset[vertexIndex.Y1] * bone.m01 + x; + vertices[vertexIndex.Y1] = offset[vertexIndex.X1] * bone.m10 + offset[vertexIndex.Y1] * bone.m11 + y; + vertices[vertexIndex.X2] = offset[vertexIndex.X2] * bone.m00 + offset[vertexIndex.Y2] * bone.m01 + x; + vertices[vertexIndex.Y2] = offset[vertexIndex.X2] * bone.m10 + offset[vertexIndex.Y2] * bone.m11 + y; + vertices[vertexIndex.X3] = offset[vertexIndex.X3] * bone.m00 + offset[vertexIndex.Y3] * bone.m01 + x; + vertices[vertexIndex.Y3] = offset[vertexIndex.X3] * bone.m10 + offset[vertexIndex.Y3] * bone.m11 + y; + vertices[vertexIndex.X4] = offset[vertexIndex.X4] * bone.m00 + offset[vertexIndex.Y4] * bone.m01 + x; + vertices[vertexIndex.Y4] = offset[vertexIndex.X4] * bone.m10 + offset[vertexIndex.Y4] * bone.m11 + y; +}; + +/*cc._spCallback = function(state, trackIndex, type,event, loopCount){ + state.context.onAnimationStateEvent(trackIndex, type, event, loopCount); + };*/ + +sp._regionAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { + var vertices = {}; + self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); + var r = slot.skeleton.r * slot.r * 255; + var g = slot.skeleton.g * slot.g * 255; + var b = slot.skeleton.b * slot.b * 255; + var normalizedAlpha = slot.skeleton.a * slot.a; + if (premultipliedAlpha) { + r *= normalizedAlpha; + g *= normalizedAlpha; + b *= normalizedAlpha; + } + var a = normalizedAlpha * 255; + + quad.bl.colors.r = quad.tl.colors.r = quad.tr.colors.r = quad.br.colors.r = r; + quad.bl.colors.g = quad.tl.colors.g = quad.tr.colors.g = quad.br.colors.g = g; + quad.bl.colors.b = quad.tl.colors.b = quad.tr.colors.b = quad.br.colors.b = b; + quad.bl.colors.a = quad.tl.colors.a = quad.tr.colors.a = quad.br.colors.a = a; + + var VERTEX = sp.VERTEX_INDEX; + quad.bl.vertices.x = vertices[VERTEX.X1]; + quad.bl.vertices.y = vertices[VERTEX.Y1]; + quad.tl.vertices.x = vertices[VERTEX.X2]; + quad.tl.vertices.y = vertices[VERTEX.Y2]; + quad.tr.vertices.x = vertices[VERTEX.X3]; + quad.tr.vertices.y = vertices[VERTEX.Y3]; + quad.br.vertices.x = vertices[VERTEX.X4]; + quad.br.vertices.y = vertices[VERTEX.Y4]; + + quad.bl.texCoords.u = self.uvs[VERTEX.X1]; + quad.bl.texCoords.v = self.uvs[VERTEX.Y1]; + quad.tl.texCoords.u = self.uvs[VERTEX.X2]; + quad.tl.texCoords.v = self.uvs[VERTEX.Y2]; + quad.tr.texCoords.u = self.uvs[VERTEX.X3]; + quad.tr.texCoords.v = self.uvs[VERTEX.Y3]; + quad.br.texCoords.u = self.uvs[VERTEX.X4]; + quad.br.texCoords.v = self.uvs[VERTEX.Y4]; +}; + +sp._regionAttachment_updateSlotForCanvas = function(self, slot, points) { + if(!points) + return; + + var vertices = {}; + self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); + var VERTEX = sp.VERTEX_INDEX; + points.length = 0; + points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1])); + points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4])); + points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3])); + points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2])); +}; + +sp.ANIMATION_EVENT_TYPE = { + START: 0, + END: 1, + COMPLETE: 2, + EVENT: 3 +}; + +sp.SkeletonAnimation = sp.Skeleton.extend({ + _state: null, + _target: null, + _callback: null, + init: function () { + this._super(); + this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data)); + }, + setAnimationStateData: function (stateData) { + var state = new spine.AnimationState(stateData); + state.onStart = this._onAnimationStateStart.bind(this); + state.onComplete = this._onAnimationStateComplete.bind(this); + state.onEnd = this._onAnimationStateEnd.bind(this); + state.onEvent = this._onAnimationStateEvent.bind(this); + this._state = state; + }, + setMix: function (fromAnimation, toAnimation, duration) { + this._state.data.setMixByName(fromAnimation, toAnimation, duration); + }, + setAnimationListener: function (target, callback) { + this._target = target; + this._callback = callback; + }, + setAnimation: function (trackIndex, name, loop) { + var animation = this._skeleton.data.findAnimation(name); + if (!animation) { + cc.log("Spine: Animation not found: " + name); + return 0; + } + return this._state.setAnimation(trackIndex, animation, loop); + }, + addAnimation: function (trackIndex, name, loop, delay) { + var animation = this._skeleton.data.findAnimation(name); + if (!animation) { + cc.log("Spine: Animation not found:" + name); + return 0; + } + return this._state.addAnimation(trackIndex, animation, loop, delay); + }, + getCurrent: function (trackIndex) { + return this._state.getCurrent(trackIndex); + }, + clearTracks: function () { + this._state.clearTracks(); + }, + clearTrack: function (trackIndex) { + this._state.clearTrack(trackIndex); + }, + update: function (dt) { + this._super(dt); + + dt *= this._timeScale; + this._state.update(dt); + this._state.apply(this._skeleton); + this._skeleton.updateWorldTransform(); + }, + _onAnimationStateStart: function (trackIndex) { + this._animationStateCallback(trackIndex, sp.ANIMATION_EVENT_TYPE.START, null, 0); + }, + _onAnimationStateEnd: function (trackIndex) { + this._animationStateCallback(trackIndex, sp.ANIMATION_EVENT_TYPE.END, null, 0); + }, + _onAnimationStateComplete: function (trackIndex, count) { + this._animationStateCallback(trackIndex, sp.ANIMATION_EVENT_TYPE.COMPLETE, null, count); + }, + _onAnimationStateEvent: function (trackIndex, event) { + this._animationStateCallback(trackIndex, sp.ANIMATION_EVENT_TYPE.EVENT, event, 0); + }, + _animationStateCallback: function (trackIndex, type, event, loopCount) { + if (this._target && this._callback) { + this._callback.call(this._target, this, trackIndex, type, event, loopCount) + } + } +}); + +sp.SkeletonAnimation.createWithData = function (skeletonData) { + var c = new sp.SkeletonAnimation(); + c.initWithArgs.apply(c, arguments); + return c; +}; + +sp.SkeletonAnimation.create = function (skeletonDataFile, atlasFile/* or atlas*/, scale) { + var c = new sp.SkeletonAnimation(); + c.initWithArgs.apply(c, arguments); + return c; +}; \ No newline at end of file diff --git a/extensions/spine/Spine.js b/extensions/spine/Spine.js new file mode 100644 index 0000000000..f6b6f699d2 --- /dev/null +++ b/extensions/spine/Spine.js @@ -0,0 +1,1816 @@ +/****************************************************************************** + * Spine Runtimes Software License + * Version 2 + * + * Copyright (c) 2013, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable and + * non-transferable license to install, execute and perform the Spine Runtimes + * Software (the "Software") solely for internal use. Without the written + * permission of Esoteric Software, you may not (a) modify, translate, adapt or + * otherwise create derivative works, improvements of the Software or develop + * new applications using the Software or (b) remove, delete, alter or obscure + * any trademarks or any copyright, trademark, patent or other intellectual + * property or proprietary rights notices on or in the Software, including + * any copy thereof. Redistributions in binary or source form must include + * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +var spine = spine || {}; + +spine.BoneData = function (name, parent) { + this.name = name; + this.parent = parent; +}; +spine.BoneData.prototype = { + length: 0, + x: 0, y: 0, + rotation: 0, + scaleX: 1, scaleY: 1, + inheritScale: true, + inheritRotation: true +}; + +spine.SlotData = function (name, boneData) { + this.name = name; + this.boneData = boneData; +}; +spine.SlotData.prototype = { + r: 1, g: 1, b: 1, a: 1, + attachmentName: null, + additiveBlending: false +}; + +spine.Bone = function (boneData, parent) { + this.data = boneData; + this.parent = parent; + this.setToSetupPose(); +}; +spine.Bone.yDown = false; +spine.Bone.prototype = { + x: 0, y: 0, + rotation: 0, + scaleX: 1, scaleY: 1, + m00: 0, m01: 0, worldX: 0, // a b x + m10: 0, m11: 0, worldY: 0, // c d y + worldRotation: 0, + worldScaleX: 1, worldScaleY: 1, + updateWorldTransform: function (flipX, flipY) { + var parent = this.parent; + if (parent != null) { + this.worldX = this.x * parent.m00 + this.y * parent.m01 + parent.worldX; + this.worldY = this.x * parent.m10 + this.y * parent.m11 + parent.worldY; + if (this.data.inheritScale) { + this.worldScaleX = parent.worldScaleX * this.scaleX; + this.worldScaleY = parent.worldScaleY * this.scaleY; + } else { + this.worldScaleX = this.scaleX; + this.worldScaleY = this.scaleY; + } + this.worldRotation = this.data.inheritRotation ? parent.worldRotation + this.rotation : this.rotation; + } else { + this.worldX = flipX ? -this.x : this.x; + this.worldY = flipY != spine.Bone.yDown ? -this.y : this.y; + this.worldScaleX = this.scaleX; + this.worldScaleY = this.scaleY; + this.worldRotation = this.rotation; + } + var radians = this.worldRotation * Math.PI / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + this.m00 = cos * this.worldScaleX; + this.m10 = sin * this.worldScaleX; + this.m01 = -sin * this.worldScaleY; + this.m11 = cos * this.worldScaleY; + if (flipX) { + this.m00 = -this.m00; + this.m01 = -this.m01; + } + if (flipY != spine.Bone.yDown) { + this.m10 = -this.m10; + this.m11 = -this.m11; + } + }, + setToSetupPose: function () { + var data = this.data; + this.x = data.x; + this.y = data.y; + this.rotation = data.rotation; + this.scaleX = data.scaleX; + this.scaleY = data.scaleY; + } +}; + +spine.Slot = function (slotData, skeleton, bone) { + this.data = slotData; + this.skeleton = skeleton; + this.bone = bone; + this.setToSetupPose(); +}; +spine.Slot.prototype = { + r: 1, g: 1, b: 1, a: 1, + _attachmentTime: 0, + attachment: null, + setAttachment: function (attachment) { + this.attachment = attachment; + this._attachmentTime = this.skeleton.time; + }, + setAttachmentTime: function (time) { + this._attachmentTime = this.skeleton.time - time; + }, + getAttachmentTime: function () { + return this.skeleton.time - this._attachmentTime; + }, + setToSetupPose: function () { + var data = this.data; + this.r = data.r; + this.g = data.g; + this.b = data.b; + this.a = data.a; + + var slotDatas = this.skeleton.data.slots; + for (var i = 0, n = slotDatas.length; i < n; i++) { + if (slotDatas[i] == data) { + this.setAttachment(!data.attachmentName ? null : this.skeleton.getAttachmentBySlotIndex(i, data.attachmentName)); + break; + } + } + } +}; + +spine.Skin = function (name) { + this.name = name; + this.attachments = {}; +}; +spine.Skin.prototype = { + addAttachment: function (slotIndex, name, attachment) { + this.attachments[slotIndex + ":" + name] = attachment; + }, + getAttachment: function (slotIndex, name) { + return this.attachments[slotIndex + ":" + name]; + }, + _attachAll: function (skeleton, oldSkin) { + console.log(oldSkin.attachments); + for (var key in oldSkin.attachments) { + var colon = key.indexOf(":"); + var slotIndex = parseInt(key.substring(0, colon)); + var name = key.substring(colon + 1); + var slot = skeleton.slots[slotIndex]; + if (slot.attachment && slot.attachment.name == name) { + var attachment = this.getAttachment(slotIndex, name); + if (attachment) slot.setAttachment(attachment); + } + } + } +}; + +spine.Animation = function (name, timelines, duration) { + this.name = name; + this.timelines = timelines; + this.duration = duration; +}; +spine.Animation.prototype = { + apply: function (skeleton, lastTime, time, loop, events) { + if (loop && this.duration != 0) { + time %= this.duration; + lastTime %= this.duration; + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + timelines[i].apply(skeleton, lastTime, time, events, 1); + }, + mix: function (skeleton, lastTime, time, loop, events, alpha) { + if (loop && this.duration != 0) { + time %= this.duration; + lastTime %= this.duration; + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + timelines[i].apply(skeleton, lastTime, time, events, alpha); + } +}; + +spine.binarySearch = function (values, target, step) { + var low = 0; + var high = Math.floor(values.length / step) - 2; + if (high == 0) return step; + var current = high >>> 1; + while (true) { + if (values[(current + 1) * step] <= target) + low = current + 1; + else + high = current; + if (low == high) return (low + 1) * step; + current = (low + high) >>> 1; + } +}; +spine.linearSearch = function (values, target, step) { + for (var i = 0, last = values.length - step; i <= last; i += step) + if (values[i] > target) return i; + return -1; +}; + +spine.Curves = function (frameCount) { + this.curves = []; // dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... + this.curves.length = (frameCount - 1) * 6; +}; +spine.Curves.prototype = { + setLinear: function (frameIndex) { + this.curves[frameIndex * 6] = 0/*LINEAR*/; + }, + setStepped: function (frameIndex) { + this.curves[frameIndex * 6] = -1/*STEPPED*/; + }, + /** Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next. + * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of + * the difference between the keyframe's values. */ + setCurve: function (frameIndex, cx1, cy1, cx2, cy2) { + var subdiv_step = 1 / 10/*BEZIER_SEGMENTS*/; + var subdiv_step2 = subdiv_step * subdiv_step; + var subdiv_step3 = subdiv_step2 * subdiv_step; + var pre1 = 3 * subdiv_step; + var pre2 = 3 * subdiv_step2; + var pre4 = 6 * subdiv_step2; + var pre5 = 6 * subdiv_step3; + var tmp1x = -cx1 * 2 + cx2; + var tmp1y = -cy1 * 2 + cy2; + var tmp2x = (cx1 - cx2) * 3 + 1; + var tmp2y = (cy1 - cy2) * 3 + 1; + var i = frameIndex * 6; + var curves = this.curves; + curves[i] = cx1 * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3; + curves[i + 1] = cy1 * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3; + curves[i + 2] = tmp1x * pre4 + tmp2x * pre5; + curves[i + 3] = tmp1y * pre4 + tmp2y * pre5; + curves[i + 4] = tmp2x * pre5; + curves[i + 5] = tmp2y * pre5; + }, + getCurvePercent: function (frameIndex, percent) { + percent = percent < 0 ? 0 : (percent > 1 ? 1 : percent); + var curveIndex = frameIndex * 6; + var curves = this.curves; + var dfx = curves[curveIndex]; + if (!dfx/*LINEAR*/) return percent; + if (dfx == -1/*STEPPED*/) return 0; + var dfy = curves[curveIndex + 1]; + var ddfx = curves[curveIndex + 2]; + var ddfy = curves[curveIndex + 3]; + var dddfx = curves[curveIndex + 4]; + var dddfy = curves[curveIndex + 5]; + var x = dfx, y = dfy; + var i = 10/*BEZIER_SEGMENTS*/ - 2; + while (true) { + if (x >= percent) { + var lastX = x - dfx; + var lastY = y - dfy; + return lastY + (y - lastY) * (percent - lastX) / (x - lastX); + } + if (i == 0) break; + i--; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + x += dfx; + y += dfy; + } + return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1. + } +}; + +spine.RotateTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, angle, ... + this.frames.length = frameCount * 2; +}; +spine.RotateTimeline.prototype = { + boneIndex: 0, + getFrameCount: function () { + return this.frames.length / 2; + }, + setFrame: function (frameIndex, time, angle) { + frameIndex *= 2; + this.frames[frameIndex] = time; + this.frames[frameIndex + 1] = angle; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) return; // Time is before first frame. + + var bone = skeleton.bones[this.boneIndex]; + + if (time >= frames[frames.length - 2]) { // Time is after last frame. + var amount = bone.data.rotation + frames[frames.length - 1] - bone.rotation; + while (amount > 180) + amount -= 360; + while (amount < -180) + amount += 360; + bone.rotation += amount * alpha; + return; + } + + // Interpolate between the last frame and the current frame. + var frameIndex = spine.binarySearch(frames, time, 2); + var lastFrameValue = frames[frameIndex - 1]; + var frameTime = frames[frameIndex]; + var percent = 1 - (time - frameTime) / (frames[frameIndex - 2/*LAST_FRAME_TIME*/] - frameTime); + percent = this.curves.getCurvePercent(frameIndex / 2 - 1, percent); + + var amount = frames[frameIndex + 1/*FRAME_VALUE*/] - lastFrameValue; + while (amount > 180) + amount -= 360; + while (amount < -180) + amount += 360; + amount = bone.data.rotation + (lastFrameValue + amount * percent) - bone.rotation; + while (amount > 180) + amount -= 360; + while (amount < -180) + amount += 360; + bone.rotation += amount * alpha; + } +}; + +spine.TranslateTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, x, y, ... + this.frames.length = frameCount * 3; +}; +spine.TranslateTimeline.prototype = { + boneIndex: 0, + getFrameCount: function () { + return this.frames.length / 3; + }, + setFrame: function (frameIndex, time, x, y) { + frameIndex *= 3; + this.frames[frameIndex] = time; + this.frames[frameIndex + 1] = x; + this.frames[frameIndex + 2] = y; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) return; // Time is before first frame. + + var bone = skeleton.bones[this.boneIndex]; + + if (time >= frames[frames.length - 3]) { // Time is after last frame. + bone.x += (bone.data.x + frames[frames.length - 2] - bone.x) * alpha; + bone.y += (bone.data.y + frames[frames.length - 1] - bone.y) * alpha; + return; + } + + // Interpolate between the last frame and the current frame. + var frameIndex = spine.binarySearch(frames, time, 3); + var lastFrameX = frames[frameIndex - 2]; + var lastFrameY = frames[frameIndex - 1]; + var frameTime = frames[frameIndex]; + var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime); + percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent); + + bone.x += (bone.data.x + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.x) * alpha; + bone.y += (bone.data.y + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.y) * alpha; + } +}; + +spine.ScaleTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, x, y, ... + this.frames.length = frameCount * 3; +}; +spine.ScaleTimeline.prototype = { + boneIndex: 0, + getFrameCount: function () { + return this.frames.length / 3; + }, + setFrame: function (frameIndex, time, x, y) { + frameIndex *= 3; + this.frames[frameIndex] = time; + this.frames[frameIndex + 1] = x; + this.frames[frameIndex + 2] = y; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) return; // Time is before first frame. + + var bone = skeleton.bones[this.boneIndex]; + + if (time >= frames[frames.length - 3]) { // Time is after last frame. + bone.scaleX += (bone.data.scaleX - 1 + frames[frames.length - 2] - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - 1 + frames[frames.length - 1] - bone.scaleY) * alpha; + return; + } + + // Interpolate between the last frame and the current frame. + var frameIndex = spine.binarySearch(frames, time, 3); + var lastFrameX = frames[frameIndex - 2]; + var lastFrameY = frames[frameIndex - 1]; + var frameTime = frames[frameIndex]; + var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime); + percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent); + + bone.scaleX += (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.scaleY) * alpha; + } +}; + +spine.ColorTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, r, g, b, a, ... + this.frames.length = frameCount * 5; +}; +spine.ColorTimeline.prototype = { + slotIndex: 0, + getFrameCount: function () { + return this.frames.length / 5; + }, + setFrame: function (frameIndex, time, r, g, b, a) { + frameIndex *= 5; + this.frames[frameIndex] = time; + this.frames[frameIndex + 1] = r; + this.frames[frameIndex + 2] = g; + this.frames[frameIndex + 3] = b; + this.frames[frameIndex + 4] = a; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) return; // Time is before first frame. + + var slot = skeleton.slots[this.slotIndex]; + + if (time >= frames[frames.length - 5]) { // Time is after last frame. + var i = frames.length - 1; + slot.r = frames[i - 3]; + slot.g = frames[i - 2]; + slot.b = frames[i - 1]; + slot.a = frames[i]; + return; + } + + // Interpolate between the last frame and the current frame. + var frameIndex = spine.binarySearch(frames, time, 5); + var lastFrameR = frames[frameIndex - 4]; + var lastFrameG = frames[frameIndex - 3]; + var lastFrameB = frames[frameIndex - 2]; + var lastFrameA = frames[frameIndex - 1]; + var frameTime = frames[frameIndex]; + var percent = 1 - (time - frameTime) / (frames[frameIndex - 5/*LAST_FRAME_TIME*/] - frameTime); + percent = this.curves.getCurvePercent(frameIndex / 5 - 1, percent); + + var r = lastFrameR + (frames[frameIndex + 1/*FRAME_R*/] - lastFrameR) * percent; + var g = lastFrameG + (frames[frameIndex + 2/*FRAME_G*/] - lastFrameG) * percent; + var b = lastFrameB + (frames[frameIndex + 3/*FRAME_B*/] - lastFrameB) * percent; + var a = lastFrameA + (frames[frameIndex + 4/*FRAME_A*/] - lastFrameA) * percent; + if (alpha < 1) { + slot.r += (r - slot.r) * alpha; + slot.g += (g - slot.g) * alpha; + slot.b += (b - slot.b) * alpha; + slot.a += (a - slot.a) * alpha; + } else { + slot.r = r; + slot.g = g; + slot.b = b; + slot.a = a; + } + } +}; + +spine.AttachmentTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, ... + this.frames.length = frameCount; + this.attachmentNames = []; + this.attachmentNames.length = frameCount; +}; +spine.AttachmentTimeline.prototype = { + slotIndex: 0, + getFrameCount: function () { + return this.frames.length; + }, + setFrame: function (frameIndex, time, attachmentName) { + this.frames[frameIndex] = time; + this.attachmentNames[frameIndex] = attachmentName; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) return; // Time is before first frame. + + var frameIndex; + if (time >= frames[frames.length - 1]) // Time is after last frame. + frameIndex = frames.length - 1; + else + frameIndex = spine.binarySearch(frames, time, 1) - 1; + + var attachmentName = this.attachmentNames[frameIndex]; + skeleton.slots[this.slotIndex].setAttachment(!attachmentName ? null : skeleton.getAttachmentBySlotIndex(this.slotIndex, attachmentName)); + } +}; + +spine.EventTimeline = function (frameCount) { + this.frames = []; // time, ... + this.frames.length = frameCount; + this.events = []; + this.events.length = frameCount; +}; +spine.EventTimeline.prototype = { + getFrameCount: function () { + return this.frames.length; + }, + setFrame: function (frameIndex, time, event) { + this.frames[frameIndex] = time; + this.events[frameIndex] = event; + }, + /** Fires events for frames > lastTime and <= time. */ + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + if (!firedEvents) return; + + var frames = this.frames; + var frameCount = frames.length; + + if (lastTime > time) { // Fire events after last time for looped animations. + this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha); + lastTime = -1; + } else if (lastTime >= frames[frameCount - 1]) // Last time is after last frame. + return; + if (time < frames[0]) return; // Time is before first frame. + + var frameIndex; + if (lastTime < frames[0]) + frameIndex = 0; + else { + frameIndex = spine.binarySearch(frames, lastTime, 1); + var frame = frames[frameIndex]; + while (frameIndex > 0) { // Fire multiple events with the same frame. + if (frames[frameIndex - 1] != frame) break; + frameIndex--; + } + } + var events = this.events; + for (; frameIndex < frameCount && time >= frames[frameIndex]; frameIndex++) + firedEvents.push(events[frameIndex]); + } +}; + +spine.DrawOrderTimeline = function (frameCount) { + this.frames = []; // time, ... + this.frames.length = frameCount; + this.drawOrders = []; + this.drawOrders.length = frameCount; +}; +spine.DrawOrderTimeline.prototype = { + getFrameCount: function () { + return this.frames.length; + }, + setFrame: function (frameIndex, time, drawOrder) { + this.frames[frameIndex] = time; + this.drawOrders[frameIndex] = drawOrder; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) return; // Time is before first frame. + + var frameIndex; + if (time >= frames[frames.length - 1]) // Time is after last frame. + frameIndex = frames.length - 1; + else + frameIndex = spine.binarySearch(frames, time, 1) - 1; + + var drawOrder = skeleton.drawOrder; + var slots = skeleton.slots; + var drawOrderToSetupIndex = this.drawOrders[frameIndex]; + if (!drawOrderToSetupIndex) { + for (var i = 0, n = slots.length; i < n; i++) + drawOrder[i] = slots[i]; + } else { + for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) + drawOrder[i] = skeleton.slots[drawOrderToSetupIndex[i]]; + } + + } +}; + +spine.SkeletonData = function () { + this.bones = []; + this.slots = []; + this.skins = []; + this.events = []; + this.animations = []; +}; +spine.SkeletonData.prototype = { + defaultSkin: null, + /** @return May be null. */ + findBone: function (boneName) { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].name == boneName) return bones[i]; + return null; + }, + /** @return -1 if the bone was not found. */ + findBoneIndex: function (boneName) { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].name == boneName) return i; + return -1; + }, + /** @return May be null. */ + findSlot: function (slotName) { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + if (slots[i].name == slotName) return slots[i]; + } + return null; + }, + /** @return -1 if the bone was not found. */ + findSlotIndex: function (slotName) { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].name == slotName) return i; + return -1; + }, + /** @return May be null. */ + findSkin: function (skinName) { + var skins = this.skins; + for (var i = 0, n = skins.length; i < n; i++) + if (skins[i].name == skinName) return skins[i]; + return null; + }, + /** @return May be null. */ + findEvent: function (eventName) { + var events = this.events; + for (var i = 0, n = events.length; i < n; i++) + if (events[i].name == eventName) return events[i]; + return null; + }, + /** @return May be null. */ + findAnimation: function (animationName) { + var animations = this.animations; + for (var i = 0, n = animations.length; i < n; i++) + if (animations[i].name == animationName) return animations[i]; + return null; + } +}; + +spine.Skeleton = function (skeletonData) { + this.data = skeletonData; + + this.bones = []; + for (var i = 0, n = skeletonData.bones.length; i < n; i++) { + var boneData = skeletonData.bones[i]; + var parent = !boneData.parent ? null : this.bones[skeletonData.bones.indexOf(boneData.parent)]; + this.bones.push(new spine.Bone(boneData, parent)); + } + + this.slots = []; + this.drawOrder = []; + for (var i = 0, n = skeletonData.slots.length; i < n; i++) { + var slotData = skeletonData.slots[i]; + var bone = this.bones[skeletonData.bones.indexOf(slotData.boneData)]; + var slot = new spine.Slot(slotData, this, bone); + this.slots.push(slot); + this.drawOrder.push(slot); + } +}; +spine.Skeleton.prototype = { + x: 0, y: 0, + skin: null, + r: 1, g: 1, b: 1, a: 1, + time: 0, + flipX: false, flipY: false, + /** Updates the world transform for each bone. */ + updateWorldTransform: function () { + var flipX = this.flipX; + var flipY = this.flipY; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].updateWorldTransform(flipX, flipY); + }, + /** Sets the bones and slots to their setup pose values. */ + setToSetupPose: function () { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }, + setBonesToSetupPose: function () { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].setToSetupPose(); + }, + setSlotsToSetupPose: function () { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + slots[i].setToSetupPose(i); + }, + /** @return May return null. */ + getRootBone: function () { + return this.bones.length == 0 ? null : this.bones[0]; + }, + /** @return May be null. */ + findBone: function (boneName) { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].data.name == boneName) return bones[i]; + return null; + }, + /** @return -1 if the bone was not found. */ + findBoneIndex: function (boneName) { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].data.name == boneName) return i; + return -1; + }, + /** @return May be null. */ + findSlot: function (slotName) { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].data.name == slotName) return slots[i]; + return null; + }, + /** @return -1 if the bone was not found. */ + findSlotIndex: function (slotName) { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].data.name == slotName) return i; + return -1; + }, + setSkinByName: function (skinName) { + var skin = this.data.findSkin(skinName); + if (!skin) throw "Skin not found: " + skinName; + this.setSkin(skin); + }, + /** Sets the skin used to look up attachments not found in the {@link SkeletonData#getDefaultSkin() default skin}. Attachments + * from the new skin are attached if the corresponding attachment from the old skin was attached. + * @param newSkin May be null. */ + setSkin: function (newSkin) { + if (this.skin && newSkin) { + newSkin._attachAll(this, this.skin); + } + this.skin = newSkin; + }, + /** @return May be null. */ + getAttachmentBySlotName: function (slotName, attachmentName) { + return this.getAttachmentBySlotIndex(this.data.findSlotIndex(slotName), attachmentName); + }, + /** @return May be null. */ + getAttachmentBySlotIndex: function (slotIndex, attachmentName) { + if (this.skin) { + var attachment = this.skin.getAttachment(slotIndex, attachmentName); + if (attachment) return attachment; + } + if (this.data.defaultSkin) return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); + return null; + }, + /** @param attachmentName May be null. */ + setAttachment: function (slotName, attachmentName) { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) { + var attachment = null; + if (attachmentName) { + attachment = this.getAttachment(i, attachmentName); + if (!attachment) throw "Attachment not found: " + attachmentName + ", for slot: " + slotName; + } + slot.setAttachment(attachment); + return; + } + } + throw "Slot not found: " + slotName; + }, + update: function (delta) { + this.time += delta; + } +}; + +spine.EventData = function (name) { + this.name = name; +}; + +spine.EventData.prototype = { + intValue: 0, + floatValue: 0, + stringValue: null +}; + +spine.Event = function (data) { + this.data = data; +}; + +spine.Event.prototype = { + intValue: 0, + floatValue: 0, + stringValue: null +}; + +spine.AttachmentType = { + region: 0, + boundingbox: 1 +}; + +spine.RegionAttachment = function (name) { + this.name = name; + this.offset = []; + this.offset.length = 8; + this.uvs = []; + this.uvs.length = 8; +}; + +spine.RegionAttachment.prototype = { + type: spine.AttachmentType.region, + x: 0, y: 0, + rotation: 0, + scaleX: 1, scaleY: 1, + width: 0, height: 0, + rendererObject: null, + regionOffsetX: 0, regionOffsetY: 0, + regionWidth: 0, regionHeight: 0, + regionOriginalWidth: 0, regionOriginalHeight: 0, + setUVs: function (u, v, u2, v2, rotate) { + var uvs = this.uvs; + if (rotate) { + uvs[2/*X2*/] = u; + uvs[3/*Y2*/] = v2; + uvs[4/*X3*/] = u; + uvs[5/*Y3*/] = v; + uvs[6/*X4*/] = u2; + uvs[7/*Y4*/] = v; + uvs[0/*X1*/] = u2; + uvs[1/*Y1*/] = v2; + } else { + uvs[0/*X1*/] = u; + uvs[1/*Y1*/] = v2; + uvs[2/*X2*/] = u; + uvs[3/*Y2*/] = v; + uvs[4/*X3*/] = u2; + uvs[5/*Y3*/] = v; + uvs[6/*X4*/] = u2; + uvs[7/*Y4*/] = v2; + } + }, + updateOffset: function () { + var regionScaleX = this.width / this.regionOriginalWidth * this.scaleX; + var regionScaleY = this.height / this.regionOriginalHeight * this.scaleY; + var localX = -this.width / 2 * this.scaleX + this.regionOffsetX * regionScaleX; + var localY = -this.height / 2 * this.scaleY + this.regionOffsetY * regionScaleY; + var localX2 = localX + this.regionWidth * regionScaleX; + var localY2 = localY + this.regionHeight * regionScaleY; + var radians = this.rotation * Math.PI / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + var localXCos = localX * cos + this.x; + var localXSin = localX * sin; + var localYCos = localY * cos + this.y; + var localYSin = localY * sin; + var localX2Cos = localX2 * cos + this.x; + var localX2Sin = localX2 * sin; + var localY2Cos = localY2 * cos + this.y; + var localY2Sin = localY2 * sin; + var offset = this.offset; + offset[0/*X1*/] = localXCos - localYSin; + offset[1/*Y1*/] = localYCos + localXSin; + offset[2/*X2*/] = localXCos - localY2Sin; + offset[3/*Y2*/] = localY2Cos + localXSin; + offset[4/*X3*/] = localX2Cos - localY2Sin; + offset[5/*Y3*/] = localY2Cos + localX2Sin; + offset[6/*X4*/] = localX2Cos - localYSin; + offset[7/*Y4*/] = localYCos + localX2Sin; + }, + computeVertices: function (x, y, bone, vertices) { + x += bone.worldX; + y += bone.worldY; + var m00 = bone.m00; + var m01 = bone.m01; + var m10 = bone.m10; + var m11 = bone.m11; + var offset = this.offset; + vertices[0/*X1*/] = offset[0/*X1*/] * m00 + offset[1/*Y1*/] * m01 + x; + vertices[1/*Y1*/] = offset[0/*X1*/] * m10 + offset[1/*Y1*/] * m11 + y; + vertices[2/*X2*/] = offset[2/*X2*/] * m00 + offset[3/*Y2*/] * m01 + x; + vertices[3/*Y2*/] = offset[2/*X2*/] * m10 + offset[3/*Y2*/] * m11 + y; + vertices[4/*X3*/] = offset[4/*X3*/] * m00 + offset[5/*X3*/] * m01 + x; + vertices[5/*X3*/] = offset[4/*X3*/] * m10 + offset[5/*X3*/] * m11 + y; + vertices[6/*X4*/] = offset[6/*X4*/] * m00 + offset[7/*Y4*/] * m01 + x; + vertices[7/*Y4*/] = offset[6/*X4*/] * m10 + offset[7/*Y4*/] * m11 + y; + } +}; + +spine.BoundingBoxAttachment = function (name) { + this.name = name; + this.vertices = []; +}; + +spine.BoundingBoxAttachment.prototype = { + type: spine.AttachmentType.boundingBox, + computeWorldVertices: function (x, y, bone, worldVertices) { + x += bone.worldX; + y += bone.worldY; + var m00 = bone.m00; + var m01 = bone.m01; + var m10 = bone.m10; + var m11 = bone.m11; + var vertices = this.vertices; + for (var i = 0, n = vertices.length; i < n; i += 2) { + var px = vertices[i]; + var py = vertices[i + 1]; + worldVertices[i] = px * m00 + py * m01 + x; + worldVertices[i + 1] = px * m10 + py * m11 + y; + } + } +}; + +spine.AnimationStateData = function (skeletonData) { + this.skeletonData = skeletonData; + this.animationToMixTime = {}; +}; +spine.AnimationStateData.prototype = { + defaultMix: 0, + setMixByName: function (fromName, toName, duration) { + var from = this.skeletonData.findAnimation(fromName); + if (!from) throw "Animation not found: " + fromName; + var to = this.skeletonData.findAnimation(toName); + if (!to) throw "Animation not found: " + toName; + this.setMix(from, to, duration); + }, + setMix: function (from, to, duration) { + this.animationToMixTime[from.name + ":" + to.name] = duration; + }, + getMix: function (from, to) { + var time = this.animationToMixTime[from.name + ":" + to.name]; + return time ? time : this.defaultMix; + } +}; + +spine.TrackEntry = function () { +}; +spine.TrackEntry.prototype = { + next: null, previous: null, + animation: null, + loop: false, + delay: 0, time: 0, lastTime: -1, endTime: 0, + timeScale: 1, + mixTime: 0, mixDuration: 0, + onStart: null, onEnd: null, onComplete: null, onEvent: null +}; + +spine.AnimationState = function (stateData) { + this.data = stateData; + this.tracks = []; + this.events = []; +}; + +spine.AnimationState.prototype = { + onStart: null, + onEnd: null, + onComplete: null, + onEvent: null, + timeScale: 1, + update: function (delta) { + delta *= this.timeScale; + for (var i = 0; i < this.tracks.length; i++) { + var current = this.tracks[i]; + if (!current) continue; + + var trackDelta = delta * current.timeScale; + current.time += trackDelta; + if (current.previous) { + current.previous.time += trackDelta; + current.mixTime += trackDelta; + } + + var next = current.next; + if (next) { + if (current.lastTime >= next.delay) this.setCurrent(i, next); + } else { + // End non-looping animation when it reaches its end time and there is no next entry. + if (!current.loop && current.lastTime >= current.endTime) this.clearTrack(i); + } + } + }, + apply: function (skeleton) { + for (var i = 0; i < this.tracks.length; i++) { + var current = this.tracks[i]; + if (!current) continue; + + this.events.length = 0; + + var time = current.time; + var lastTime = current.lastTime; + var endTime = current.endTime; + var loop = current.loop; + if (!loop && time > endTime) time = endTime; + + var previous = current.previous; + if (!previous) + current.animation.apply(skeleton, current.lastTime, time, loop, this.events); + else { + var previousTime = previous.time; + if (!previous.loop && previousTime > previous.endTime) previousTime = previous.endTime; + previous.animation.apply(skeleton, previousTime, previousTime, previous.loop, null); + + var alpha = current.mixTime / current.mixDuration; + if (alpha >= 1) { + alpha = 1; + current.previous = null; + } + current.animation.mix(skeleton, current.lastTime, time, loop, this.events, alpha); + } + + for (var ii = 0, nn = this.events.length; ii < nn; ii++) { + var event = this.events[ii]; + if (current.onEvent != null) current.onEvent(i, event); + if (this.onEvent != null) this.onEvent(i, event); + } + + // Check if completed the animation or a loop iteration. + if (loop ? (lastTime % endTime > time % endTime) : (lastTime < endTime && time >= endTime)) { + var count = Math.floor(time / endTime); + if (current.onComplete) current.onComplete(i, count); + if (this.onComplete) this.onComplete(i, count); + } + + current.lastTime = current.time; + } + }, + clearTracks: function () { + for (var i = 0, n = this.tracks.length; i < n; i++) + this.clearTrack(i); + this.tracks.length = 0; + }, + clearTrack: function (trackIndex) { + if (trackIndex >= this.tracks.length) return; + var current = this.tracks[trackIndex]; + if (!current) return; + + if (current.onEnd != null) current.onEnd(trackIndex); + if (this.onEnd != null) this.onEnd(trackIndex); + + this.tracks[trackIndex] = null; + }, + _expandToIndex: function (index) { + if (index < this.tracks.length) return this.tracks[index]; + while (index >= this.tracks.length) + this.tracks.push(null); + return null; + }, + setCurrent: function (index, entry) { + var current = this._expandToIndex(index); + if (current) { + var previous = current.previous; + current.previous = null; + + if (current.onEnd != null) current.onEnd(index); + if (this.onEnd != null) this.onEnd(index); + + entry.mixDuration = this.data.getMix(current.animation, entry.animation); + if (entry.mixDuration > 0) { + entry.mixTime = 0; + // If a mix is in progress, mix from the closest animation. + if (previous && current.mixTime / current.mixDuration < 0.5) + entry.previous = previous; + else + entry.previous = current; + } + } + + this.tracks[index] = entry; + + if (entry.onStart != null) entry.onStart(index); + if (this.onStart != null) this.onStart(index); + }, + setAnimationByName: function (trackIndex, animationName, loop) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (!animation) throw "Animation not found: " + animationName; + return this.setAnimation(trackIndex, animation, loop); + }, + /** Set the current animation. Any queued animations are cleared. */ + setAnimation: function (trackIndex, animation, loop) { + var entry = new spine.TrackEntry(); + entry.animation = animation; + entry.loop = loop; + entry.endTime = animation.duration; + this.setCurrent(trackIndex, entry); + return entry; + }, + addAnimationByName: function (trackIndex, animationName, loop, delay) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (!animation) throw "Animation not found: " + animationName; + return this.addAnimation(trackIndex, animation, loop, delay); + }, + /** Adds an animation to be played delay seconds after the current or last queued animation. + * @param delay May be <= 0 to use duration of previous animation minus any mix duration plus the negative delay. */ + addAnimation: function (trackIndex, animation, loop, delay) { + var entry = new spine.TrackEntry(); + entry.animation = animation; + entry.loop = loop; + entry.endTime = animation.duration; + + var last = this._expandToIndex(trackIndex); + if (last) { + while (last.next) + last = last.next; + last.next = entry; + } else + this.tracks[trackIndex] = entry; + + if (delay <= 0) { + if (last) + delay += last.endTime - this.data.getMix(last.animation, animation); + else + delay = 0; + } + entry.delay = delay; + + return entry; + }, + /** May be null. */ + getCurrent: function (trackIndex) { + if (trackIndex >= this.tracks.length) return null; + return this.tracks[trackIndex]; + } +}; + +spine.SkeletonJson = function (attachmentLoader) { + this.attachmentLoader = attachmentLoader; +}; +spine.SkeletonJson.prototype = { + scale: 1, + readSkeletonData: function (root) { + var skeletonData = new spine.SkeletonData(); + + // Bones. + var bones = root["bones"]; + for (var i = 0, n = bones.length; i < n; i++) { + var boneMap = bones[i]; + var parent = null; + if (boneMap["parent"]) { + parent = skeletonData.findBone(boneMap["parent"]); + if (!parent) throw "Parent bone not found: " + boneMap["parent"]; + } + var boneData = new spine.BoneData(boneMap["name"], parent); + boneData.length = (boneMap["length"] || 0) * this.scale; + boneData.x = (boneMap["x"] || 0) * this.scale; + boneData.y = (boneMap["y"] || 0) * this.scale; + boneData.rotation = (boneMap["rotation"] || 0); + boneData.scaleX = boneMap["scaleX"] || 1; + boneData.scaleY = boneMap["scaleY"] || 1; + boneData.inheritScale = !boneMap["inheritScale"] || boneMap["inheritScale"] == "true"; + boneData.inheritRotation = !boneMap["inheritRotation"] || boneMap["inheritRotation"] == "true"; + skeletonData.bones.push(boneData); + } + + // Slots. + var slots = root["slots"]; + for (var i = 0, n = slots.length; i < n; i++) { + var slotMap = slots[i]; + var boneData = skeletonData.findBone(slotMap["bone"]); + if (!boneData) throw "Slot bone not found: " + slotMap["bone"]; + var slotData = new spine.SlotData(slotMap["name"], boneData); + + var color = slotMap["color"]; + if (color) { + slotData.r = spine.SkeletonJson.toColor(color, 0); + slotData.g = spine.SkeletonJson.toColor(color, 1); + slotData.b = spine.SkeletonJson.toColor(color, 2); + slotData.a = spine.SkeletonJson.toColor(color, 3); + } + + slotData.attachmentName = slotMap["attachment"]; + slotData.additiveBlending = slotMap["additive"] && slotMap["additive"] == "true"; + + skeletonData.slots.push(slotData); + } + + // Skins. + var skins = root["skins"]; + for (var skinName in skins) { + if (!skins.hasOwnProperty(skinName)) continue; + var skinMap = skins[skinName]; + var skin = new spine.Skin(skinName); + for (var slotName in skinMap) { + if (!skinMap.hasOwnProperty(slotName)) continue; + var slotIndex = skeletonData.findSlotIndex(slotName); + var slotEntry = skinMap[slotName]; + for (var attachmentName in slotEntry) { + if (!slotEntry.hasOwnProperty(attachmentName)) continue; + var attachment = this.readAttachment(skin, attachmentName, slotEntry[attachmentName]); + if (attachment != null) skin.addAttachment(slotIndex, attachmentName, attachment); + } + } + skeletonData.skins.push(skin); + if (skin.name == "default") skeletonData.defaultSkin = skin; + } + + // Events. + var events = root["events"]; + for (var eventName in events) { + if (!events.hasOwnProperty(eventName)) continue; + var eventMap = events[eventName]; + var eventData = new spine.EventData(eventName); + eventData.intValue = eventMap["int"] || 0; + eventData.floatValue = eventMap["float"] || 0; + eventData.stringValue = eventMap["string"] || null; + skeletonData.events.push(eventData); + } + + // Animations. + var animations = root["animations"]; + for (var animationName in animations) { + if (!animations.hasOwnProperty(animationName)) continue; + this.readAnimation(animationName, animations[animationName], skeletonData); + } + + return skeletonData; + }, + readAttachment: function (skin, name, map) { + name = map["name"] || name; + + var type = spine.AttachmentType[map["type"] || "region"]; + var attachment = this.attachmentLoader.newAttachment(skin, type, name); + + if (type == spine.AttachmentType.region) { + attachment.x = (map["x"] || 0) * this.scale; + attachment.y = (map["y"] || 0) * this.scale; + attachment.scaleX = map["scaleX"] || 1; + attachment.scaleY = map["scaleY"] || 1; + attachment.rotation = map["rotation"] || 0; + attachment.width = (map["width"] || 32) * this.scale; + attachment.height = (map["height"] || 32) * this.scale; + attachment.updateOffset(); + } else if (type == spine.AttachmentType.boundingBox) { + var vertices = map["vertices"]; + for (var i = 0, n = vertices.length; i < n; i++) + attachment.vertices.push(vertices[i] * this.scale); + } + + return attachment; + }, + readAnimation: function (name, map, skeletonData) { + var timelines = []; + var duration = 0; + + var bones = map["bones"]; + for (var boneName in bones) { + if (!bones.hasOwnProperty(boneName)) continue; + var boneIndex = skeletonData.findBoneIndex(boneName); + if (boneIndex == -1) throw "Bone not found: " + boneName; + var boneMap = bones[boneName]; + + for (var timelineName in boneMap) { + if (!boneMap.hasOwnProperty(timelineName)) continue; + var values = boneMap[timelineName]; + if (timelineName == "rotate") { + var timeline = new spine.RotateTimeline(values.length); + timeline.boneIndex = boneIndex; + + var frameIndex = 0; + for (var i = 0, n = values.length; i < n; i++) { + var valueMap = values[i]; + timeline.setFrame(frameIndex, valueMap["time"], valueMap["angle"]); + spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 2 - 2]); + + } else if (timelineName == "translate" || timelineName == "scale") { + var timeline; + var timelineScale = 1; + if (timelineName == "scale") + timeline = new spine.ScaleTimeline(values.length); + else { + timeline = new spine.TranslateTimeline(values.length); + timelineScale = this.scale; + } + timeline.boneIndex = boneIndex; + + var frameIndex = 0; + for (var i = 0, n = values.length; i < n; i++) { + var valueMap = values[i]; + var x = (valueMap["x"] || 0) * timelineScale; + var y = (valueMap["y"] || 0) * timelineScale; + timeline.setFrame(frameIndex, valueMap["time"], x, y); + spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 3 - 3]); + + } else + throw "Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"; + } + } + + var slots = map["slots"]; + for (var slotName in slots) { + if (!slots.hasOwnProperty(slotName)) continue; + var slotMap = slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + + for (var timelineName in slotMap) { + if (!slotMap.hasOwnProperty(timelineName)) continue; + var values = slotMap[timelineName]; + if (timelineName == "color") { + var timeline = new spine.ColorTimeline(values.length); + timeline.slotIndex = slotIndex; + + var frameIndex = 0; + for (var i = 0, n = values.length; i < n; i++) { + var valueMap = values[i]; + var color = valueMap["color"]; + var r = spine.SkeletonJson.toColor(color, 0); + var g = spine.SkeletonJson.toColor(color, 1); + var b = spine.SkeletonJson.toColor(color, 2); + var a = spine.SkeletonJson.toColor(color, 3); + timeline.setFrame(frameIndex, valueMap["time"], r, g, b, a); + spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 5 - 5]); + + } else if (timelineName == "attachment") { + var timeline = new spine.AttachmentTimeline(values.length); + timeline.slotIndex = slotIndex; + + var frameIndex = 0; + for (var i = 0, n = values.length; i < n; i++) { + var valueMap = values[i]; + timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + + } else + throw "Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"; + } + } + + var events = map["events"]; + if (events) { + var timeline = new spine.EventTimeline(events.length); + var frameIndex = 0; + for (var i = 0, n = events.length; i < n; i++) { + var eventMap = events[i]; + var eventData = skeletonData.findEvent(eventMap["name"]); + if (!eventData) throw "Event not found: " + eventMap["name"]; + var event = new spine.Event(eventData); + event.intValue = eventMap.hasOwnProperty("int") ? eventMap["int"] : eventData.intValue; + event.floatValue = eventMap.hasOwnProperty("float") ? eventMap["float"] : eventData.floatValue; + event.stringValue = eventMap.hasOwnProperty("string") ? eventMap["string"] : eventData.stringValue; + timeline.setFrame(frameIndex++, eventMap["time"], event); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + + var drawOrderValues = map["draworder"]; + if (drawOrderValues) { + var timeline = new spine.DrawOrderTimeline(drawOrderValues.length); + var slotCount = skeletonData.slots.length; + var frameIndex = 0; + for (var i = 0, n = drawOrderValues.length; i < n; i++) { + var drawOrderMap = drawOrderValues[i]; + var drawOrder = null; + if (drawOrderMap["offsets"]) { + drawOrder = []; + drawOrder.length = slotCount; + for (var ii = slotCount - 1; ii >= 0; ii--) + drawOrder[ii] = -1; + var offsets = drawOrderMap["offsets"]; + var unchanged = []; + unchanged.length = slotCount - offsets.length; + var originalIndex = 0, unchangedIndex = 0; + for (var ii = 0, nn = offsets.length; ii < nn; ii++) { + var offsetMap = offsets[ii]; + var slotIndex = skeletonData.findSlotIndex(offsetMap["slot"]); + if (slotIndex == -1) throw "Slot not found: " + offsetMap["slot"]; + // Collect unchanged items. + while (originalIndex != slotIndex) + unchanged[unchangedIndex++] = originalIndex++; + // Set changed items. + drawOrder[originalIndex + offsetMap["offset"]] = originalIndex++; + } + // Collect remaining unchanged items. + while (originalIndex < slotCount) + unchanged[unchangedIndex++] = originalIndex++; + // Fill in unchanged items. + for (var ii = slotCount - 1; ii >= 0; ii--) + if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex]; + } + timeline.setFrame(frameIndex++, drawOrderMap["time"], drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + + skeletonData.animations.push(new spine.Animation(name, timelines, duration)); + } +}; + +spine.SkeletonJson.readCurve = function (timeline, frameIndex, valueMap) { + var curve = valueMap["curve"]; + if (!curve) return; + if (curve == "stepped") + timeline.curves.setStepped(frameIndex); + else if (curve instanceof Array) + timeline.curves.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); +}; + +spine.SkeletonJson.toColor = function (hexString, colorIndex) { + if (hexString.length != 8) throw "Color hexidecimal length must be 8, recieved: " + hexString; + return parseInt(hexString.substring(colorIndex * 2, (colorIndex * 2) + 2), 16) / 255; +}; + +spine.Atlas = function (atlasText, textureLoader) { + this.textureLoader = textureLoader; + this.pages = []; + this.regions = []; + + var reader = new spine.AtlasReader(atlasText); + var tuple = []; + tuple.length = 4; + var page = null; + while (true) { + var line = reader.readLine(); + if (line == null) break; + line = reader.trim(line); + if (line.length == 0) + page = null; + else if (!page) { + page = new spine.AtlasPage(); + page.name = line; + + page.format = spine.Atlas.Format[reader.readValue()]; + + reader.readTuple(tuple); + page.minFilter = spine.Atlas.TextureFilter[tuple[0]]; + page.magFilter = spine.Atlas.TextureFilter[tuple[1]]; + + var direction = reader.readValue(); + page.uWrap = spine.Atlas.TextureWrap.clampToEdge; + page.vWrap = spine.Atlas.TextureWrap.clampToEdge; + if (direction == "x") + page.uWrap = spine.Atlas.TextureWrap.repeat; + else if (direction == "y") + page.vWrap = spine.Atlas.TextureWrap.repeat; + else if (direction == "xy") + page.uWrap = page.vWrap = spine.Atlas.TextureWrap.repeat; + + textureLoader.load(page, line, this); + + this.pages.push(page); + } else { + var region = new spine.AtlasRegion(); + region.name = line; + region.page = page; + + region.rotate = reader.readValue() == "true"; + + reader.readTuple(tuple); + var x = parseInt(tuple[0]); + var y = parseInt(tuple[1]); + + reader.readTuple(tuple); + var width = parseInt(tuple[0]); + var height = parseInt(tuple[1]); + + region.u = x / page.width; + region.v = y / page.height; + if (region.rotate) { + region.u2 = (x + height) / page.width; + region.v2 = (y + width) / page.height; + } else { + region.u2 = (x + width) / page.width; + region.v2 = (y + height) / page.height; + } + region.x = x; + region.y = y; + region.width = Math.abs(width); + region.height = Math.abs(height); + + if (reader.readTuple(tuple) == 4) { // split is optional + region.splits = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])]; + + if (reader.readTuple(tuple) == 4) { // pad is optional, but only present with splits + region.pads = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])]; + + reader.readTuple(tuple); + } + } + + region.originalWidth = parseInt(tuple[0]); + region.originalHeight = parseInt(tuple[1]); + + reader.readTuple(tuple); + region.offsetX = parseInt(tuple[0]); + region.offsetY = parseInt(tuple[1]); + + region.index = parseInt(reader.readValue()); + + this.regions.push(region); + } + } +}; +spine.Atlas.prototype = { + findRegion: function (name) { + var regions = this.regions; + for (var i = 0, n = regions.length; i < n; i++) + if (regions[i].name == name) return regions[i]; + return null; + }, + dispose: function () { + var pages = this.pages; + for (var i = 0, n = pages.length; i < n; i++) + this.textureLoader.unload(pages[i].rendererObject); + }, + updateUVs: function (page) { + var regions = this.regions; + for (var i = 0, n = regions.length; i < n; i++) { + var region = regions[i]; + if (region.page != page) continue; + region.u = region.x / page.width; + region.v = region.y / page.height; + if (region.rotate) { + region.u2 = (region.x + region.height) / page.width; + region.v2 = (region.y + region.width) / page.height; + } else { + region.u2 = (region.x + region.width) / page.width; + region.v2 = (region.y + region.height) / page.height; + } + } + } +}; + +spine.Atlas.Format = { + Alpha: 0, + Intensity: 1, + LuminanceAlpha: 2, + RGB565: 3, + RGBA4444: 4, + RGB888: 5, + RGBA8888: 6 +}; + +spine.Atlas.TextureFilter = { + Nearest: 0, + Linear: 1, + MipMap: 2, + MipMapNearestNearest: 3, + MipMapLinearNearest: 4, + MipMapNearestLinear: 5, + MipMapLinearLinear: 6 +}; + +spine.Atlas.TextureWrap = { + mirroredRepeat: 0, + clampToEdge: 1, + repeat: 2 +}; + +spine.AtlasPage = function () { +}; +spine.AtlasPage.prototype = { + name: null, + format: null, + minFilter: null, + magFilter: null, + uWrap: null, + vWrap: null, + rendererObject: null, + width: 0, + height: 0 +}; + +spine.AtlasRegion = function () { +}; +spine.AtlasRegion.prototype = { + page: null, + name: null, + x: 0, y: 0, + width: 0, height: 0, + u: 0, v: 0, u2: 0, v2: 0, + offsetX: 0, offsetY: 0, + originalWidth: 0, originalHeight: 0, + index: 0, + rotate: false, + splits: null, + pads: null +}; + +spine.AtlasReader = function (text) { + this.lines = text.split(/\r\n|\r|\n/); +}; +spine.AtlasReader.prototype = { + index: 0, + trim: function (value) { + return value.replace(/^\s+|\s+$/g, ""); + }, + readLine: function () { + if (this.index >= this.lines.length) return null; + return this.lines[this.index++]; + }, + readValue: function () { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) throw "Invalid line: " + line; + return this.trim(line.substring(colon + 1)); + }, + /** Returns the number of tuple values read (2 or 4). */ + readTuple: function (tuple) { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) throw "Invalid line: " + line; + var i = 0, lastMatch = colon + 1; + for (; i < 3; i++) { + var comma = line.indexOf(",", lastMatch); + if (comma == -1) { + if (i == 0) throw "Invalid line: " + line; + break; + } + tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch)); + lastMatch = comma + 1; + } + tuple[i] = this.trim(line.substring(lastMatch)); + return i + 1; + } +}; + +spine.AtlasAttachmentLoader = function (atlas) { + this.atlas = atlas; +}; +spine.AtlasAttachmentLoader.prototype = { + newAttachment: function (skin, type, name) { + switch (type) { + case spine.AttachmentType.boundingbox: + return new spine.BoundingBoxAttachment(name); + case spine.AttachmentType.region: + var region = this.atlas.findRegion(name); + if (!region) throw "Region not found in atlas: " + name + " (" + type + ")"; + var attachment = new spine.RegionAttachment(name); + attachment.rendererObject = region; + attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate); + attachment.regionOffsetX = region.offsetX; + attachment.regionOffsetY = region.offsetY; + attachment.regionWidth = region.width; + attachment.regionHeight = region.height; + attachment.regionOriginalWidth = region.originalWidth; + attachment.regionOriginalHeight = region.originalHeight; + return attachment; + } + throw "Unknown attachment type: " + type; + } +}; + +spine.SkeletonBounds = function () { + this.polygonPool = []; + this.polygons = []; + this.boundingBoxes = []; +}; +spine.SkeletonBounds.prototype = { + minX: 0, minY: 0, maxX: 0, maxY: 0, + update: function (skeleton, updateAabb) { + var slots = skeleton.slots; + var slotCount = slots.length; + var x = skeleton.x, y = skeleton.y; + var boundingBoxes = this.boundingBoxes; + var polygonPool = this.polygonPool; + var polygons = this.polygons; + + boundingBoxes.length = 0; + for (var i = 0, n = polygons.length; i < n; i++) + polygonPool.push(polygons[i]); + polygons.length = 0; + + for (var i = 0; i < slotCount; i++) { + var slot = slots[i]; + var boundingBox = slot.attachment; + if (boundingBox.type != spine.AttachmentType.boundingBox) continue; + boundingBoxes.push(boundingBox); + + var poolCount = polygonPool.length, polygon; + if (poolCount > 0) { + polygon = polygonPool[poolCount - 1]; + polygonPool.splice(poolCount - 1, 1); + } else + polygon = []; + polygons.push(polygon); + + polygon.length = boundingBox.vertices.length; + boundingBox.computeWorldVertices(x, y, slot.bone, polygon); + } + + if (updateAabb) this.aabbCompute(); + }, + aabbCompute: function () { + var polygons = this.polygons; + var minX = Number.MAX_VALUE, minY = Number.MAX_VALUE, maxX = Number.MIN_VALUE, maxY = Number.MIN_VALUE; + for (var i = 0, n = polygons.length; i < n; i++) { + var vertices = polygons[i]; + for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { + var x = vertices[ii]; + var y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }, + /** Returns true if the axis aligned bounding box contains the point. */ + aabbContainsPoint: function (x, y) { + return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; + }, + /** Returns true if the axis aligned bounding box intersects the line segment. */ + aabbIntersectsSegment: function (x1, y1, x2, y2) { + var minX = this.minX, minY = this.minY, maxX = this.maxX, maxY = this.maxY; + if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY)) + return false; + var m = (y2 - y1) / (x2 - x1); + var y = m * (minX - x1) + y1; + if (y > minY && y < maxY) return true; + y = m * (maxX - x1) + y1; + if (y > minY && y < maxY) return true; + var x = (minY - y1) / m + x1; + if (x > minX && x < maxX) return true; + x = (maxY - y1) / m + x1; + if (x > minX && x < maxX) return true; + return false; + }, + /** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */ + aabbIntersectsSkeleton: function (bounds) { + return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; + }, + /** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more + * efficient to only call this method if {@link #aabbContainsPoint(float, float)} returns true. */ + containsPoint: function (x, y) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.polygonContainsPoint(polygons[i], x, y)) return this.boundingBoxes[i]; + return null; + }, + /** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually + * more efficient to only call this method if {@link #aabbIntersectsSegment(float, float, float, float)} returns true. */ + intersectsSegment: function (x1, y1, x2, y2) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (polygons[i].intersectsSegment(x1, y1, x2, y2)) return this.boundingBoxes[i]; + return null; + }, + /** Returns true if the polygon contains the point. */ + polygonContainsPoint: function (polygon, x, y) { + var nn = polygon.length; + var prevIndex = nn - 2; + var inside = false; + for (var ii = 0; ii < nn; ii += 2) { + var vertexY = polygon[ii + 1]; + var prevY = polygon[prevIndex + 1]; + if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { + var vertexX = polygon[ii]; + if (vertexX + (y - vertexY) / (prevY - vertexY) * (polygon[prevIndex] - vertexX) < x) inside = !inside; + } + prevIndex = ii; + } + return inside; + }, + /** Returns true if the polygon contains the line segment. */ + intersectsSegment: function (polygon, x1, y1, x2, y2) { + var nn = polygon.length; + var width12 = x1 - x2, height12 = y1 - y2; + var det1 = x1 * y2 - y1 * x2; + var x3 = polygon[nn - 2], y3 = polygon[nn - 1]; + for (var ii = 0; ii < nn; ii += 2) { + var x4 = polygon[ii], y4 = polygon[ii + 1]; + var det2 = x3 * y4 - y3 * x4; + var width34 = x3 - x4, height34 = y3 - y4; + var det3 = width12 * height34 - height12 * width34; + var x = (det1 * width34 - width12 * det2) / det3; + if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { + var y = (det1 * height34 - height12 * det2) / det3; + if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return true; + } + x3 = x4; + y3 = y4; + } + return false; + }, + getPolygon: function (attachment) { + var index = this.boundingBoxes.indexOf(attachment); + return index == -1 ? null : this.polygons[index]; + }, + getWidth: function () { + return this.maxX - this.minX; + }, + getHeight: function () { + return this.maxY - this.minY; + } +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 54327651af..2eb2054eb5 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -363,8 +363,14 @@ "extensions/pluginx/plugins/AnalyticsFlurry.js" ], - "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "pluginx"], + "spine":[ + "core", + "extensions/spine/Spine.js", + "extensions/spine/CCSkeleton.js", + "extensions/spine/CCSkeletonAnimation.js" + ], + "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "pluginx", "spine"], "box2d" : [ "core", "physics", @@ -377,7 +383,6 @@ "external/chipmunk/chipmunk.js" ], "socketio" : [ - "external/socketio/socket.io.min.js" ], "external" : ["box2d", "chipmunk", "socketio"] From f195b38fd1631c788920a04a880b6a9289b11aaf Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 7 May 2014 17:13:01 +0800 Subject: [PATCH 0070/1564] Fixed #4975: rename sp.Skeleton.createWithFile to sp.Skeleton.create --- extensions/spine/CCSkeleton.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 62da6fc521..a4c8dd0d6f 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -395,7 +395,7 @@ sp.Skeleton.createWithData = function (skeletonData, ownsSkeletonData) { return c; }; -sp.Skeleton.createWithFile = function (skeletonDataFile, atlasFile/* or atlas*/, scale) { +sp.Skeleton.create = function (skeletonDataFile, atlasFile/* or atlas*/, scale) { var c = new sp.Skeleton(); c.initWithArgs.apply(c, arguments); return c; From 0ea38ac8dc43faab0bd0d09afd8eb0d2b266349d Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 8 May 2014 13:59:00 +0800 Subject: [PATCH 0071/1564] fix the fileutils search path bug --- cocos2d/particle/CCParticleSystem.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index fa84c91d2c..f2d07aff69 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1072,7 +1072,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getStartColor:function () { - return this._startColor; + var color = cc.c4f(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a); + return color; }, /** @@ -1088,7 +1089,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getStartColorVar:function () { - return this._startColorVar; + var color = cc.c4f(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a); + return color; }, /** @@ -1104,7 +1106,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getEndColor:function () { - return this._endColor; + var color = cc.c4f(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a); + return color; }, /** @@ -1120,7 +1123,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getEndColorVar:function () { - return this._endColorVar; + var color = cc.c4f(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a); + return color; }, /** From 71f8cc45b9c7abb7d6bbaceffc8b9ebd60c02abb Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 8 May 2014 14:42:15 +0800 Subject: [PATCH 0072/1564] change CCParticleSystem clone function --- cocos2d/particle/CCParticleSystem.js | 132 ++++++++++++--------------- 1 file changed, 57 insertions(+), 75 deletions(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index f2d07aff69..29fb876a82 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1072,7 +1072,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getStartColor:function () { - var color = cc.c4f(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a); + var color = cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a); return color; }, @@ -1089,7 +1089,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getStartColorVar:function () { - var color = cc.c4f(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a); + var color = cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a); return color; }, @@ -1106,7 +1106,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getEndColor:function () { - var color = cc.c4f(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a); + var color = cc.color(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a); return color; }, @@ -1123,7 +1123,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getEndColorVar:function () { - var color = cc.c4f(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a); + var color = cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a); return color; }, @@ -2242,113 +2242,95 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } } }, - - clone:function () { + clone:function(){ var retParticle = new cc.ParticleSystem(); // self, not super - if (retParticle.initWithTotalParticles(this._totalParticles)) { + if (retParticle.initWithTotalParticles(this.getTotalParticles())) { // angle - retParticle.angle = this.angle; - retParticle.angleVar = this.angleVar; + retParticle.setAngle(this.getAngle()); + retParticle.setAngleVar(this.getAngleVar()); // duration - retParticle.duration = this.duration; + retParticle.setDuration(this.getDuration()); // blend function - retParticle._blendFunc.src = this._blendFunc.src; - retParticle._blendFunc.dst = this._blendFunc.dst; + var blend = this.getBlendFunc(); + retParticle.setBlendFunc(blend.src,blend.dst); // color - var particleStartColor = retParticle._startColor, locStartColor = this._startColor; - particleStartColor.r = locStartColor.r; - particleStartColor.g = locStartColor.g; - particleStartColor.b = locStartColor.b; - particleStartColor.a = locStartColor.a; - - var particleStartColorVar = retParticle._startColorVar, locStartColorVar = this._startColorVar; - particleStartColorVar.r = locStartColorVar.r; - particleStartColorVar.g = locStartColorVar.g; - particleStartColorVar.b = locStartColorVar.b; - particleStartColorVar.a = locStartColorVar.a; - - var particleEndColor = retParticle._endColor, locEndColor = this._endColor; - particleEndColor.r = locEndColor.r; - particleEndColor.g = locEndColor.g; - particleEndColor.b = locEndColor.b; - particleEndColor.a = locEndColor.a; - - var particleEndColorVar = retParticle._endColorVar, locEndColorVar = this._endColorVar; - particleEndColorVar.r = locEndColorVar.r; - particleEndColorVar.g = locEndColorVar.g; - particleEndColorVar.b = locEndColorVar.b; - particleEndColorVar.a = locEndColorVar.a; + retParticle.setStartColor(this.getStartColor()); - // particle size - retParticle.startSize = this.startSize; - retParticle.startSizeVar = this.startSizeVar; - retParticle.endSize = this.endSize; - retParticle.endSizeVar = this.endSizeVar; + retParticle.setStartColorVar(this.getStartColorVar()); + + retParticle.setEndColor(this.getEndColor()); + + retParticle.setEndColorVar(this.getEndColorVar()); + + // this size + retParticle.setStartSize(this.getStartSize()); + retParticle.setStartSizeVar(this.getStartSizeVar()); + retParticle.setEndSize(this.getEndSize()); + retParticle.setEndSizeVar(this.getEndSizeVar()); // position - retParticle.x = this._position.x; - retParticle.y = this._position.y; - retParticle._posVar.x = this._posVar.x; - retParticle._posVar.y = this._posVar.y; + retParticle.setPosition(cc.p(this.x, this.y)); + retParticle.setPosVar(cc.p(this.getPosVar().x,this.getPosVar().y)); // Spinning - retParticle.startSpin = this.startSpin; - retParticle.startSpinVar = this.startSpinVar; - retParticle.endSpin = this.endSpin; - retParticle.endSpinVar = this.endSpinVar; + retParticle.setStartSpin(this.getStartSpin()||0); + retParticle.setStartSpinVar(this.getStartSpinVar()||0); + retParticle.setEndSpin(this.getEndSpin()||0); + retParticle.setEndSpinVar(this.getEndSpinVar()||0); - retParticle.emitterMode = this.emitterMode; + retParticle.setEmitterMode(this.getEmitterMode()); // Mode A: Gravity + tangential accel + radial accel - if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) { - var particleModeA = retParticle.modeA, locModeA = this.modeA; + if (this.getEmitterMode() == cc.ParticleSystem.MODE_GRAVITY) { // gravity - particleModeA.gravity.x = locModeA.gravity.x; - particleModeA.gravity.y = locModeA.gravity.y; + var gra = this.getGravity(); + retParticle.setGravity(cc.p(gra.x,gra.y)); // speed - particleModeA.speed = locModeA.speed; - particleModeA.speedVar = locModeA.speedVar; + retParticle.setSpeed(this.getSpeed()); + retParticle.setSpeedVar(this.getSpeedVar()); // radial acceleration - particleModeA.radialAccel = locModeA.radialAccel; - - particleModeA.radialAccelVar = locModeA.radialAccelVar; + retParticle.setRadialAccel(this.getRadialAccel()); + retParticle.setRadialAccelVar(this.getRadialAccelVar()); // tangential acceleration - particleModeA.tangentialAccel = locModeA.tangentialAccel; + retParticle.setTangentialAccel(this.getTangentialAccel()); + retParticle.setTangentialAccelVar(this.getTangentialAccelVar()); - particleModeA.tangentialAccelVar = locModeA.tangentialAccelVar; - } else if (this.emitterMode == cc.ParticleSystem.MODE_RADIUS) { - var particleModeB = retParticle.modeB, locModeB = this.modeB; + } else if (this.getEmitterMode() == cc.ParticleSystem.MODE_RADIUS) { // or Mode B: radius movement - particleModeB.startRadius = locModeB.startRadius; - particleModeB.startRadiusVar = locModeB.startRadiusVar; - particleModeB.endRadius = locModeB.endRadius; - particleModeB.endRadiusVar = locModeB.endRadiusVar; - particleModeB.rotatePerSecond = locModeB.rotatePerSecond; - particleModeB.rotatePerSecondVar = locModeB.rotatePerSecondVar; + retParticle.setStartRadius(this.getStartRadius()); + retParticle.setStartRadiusVar(this.getStartRadiusVar()); + retParticle.setEndRadius(this.getEndRadius()); + retParticle.setEndRadiusVar(this.getEndRadiusVar()); + + retParticle.setRotatePerSecond(this.getRotatePerSecond()); + retParticle.setRotatePerSecondVar(this.getRotatePerSecondVar()); } // life span - retParticle.life = this.life; - retParticle.lifeVar = this.lifeVar; + retParticle.setLife(this.getLife()); + retParticle.setLifeVar(this.getLifeVar()); // emission Rate - retParticle.emissionRate = this.emissionRate; + retParticle.setEmissionRate(this.getEmissionRate()); //don't get the internal texture if a batchNode is used - if (!this._batchNode) { + if (!this.getBatchNode()) { // Set a compatible default for the alpha transfer - retParticle._opacityModifyRGB = this._opacityModifyRGB; - + retParticle.setOpacityModifyRGB(this.isOpacityModifyRGB()); // texture - this.setTextureWithRect(this._texture,this._pointRect); + var texture = this.getTexture(); + if(texture){ + var size = texture.getContentSize(); + retParticle.setTextureWithRect(texture, cc.rect(0, 0, size.width, size.height)); + } } } return retParticle; From e5e6dfe413b03104befab3878467096aa0418c0a Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 8 May 2014 14:47:31 +0800 Subject: [PATCH 0073/1564] change CCParticleSystem clone function --- cocos2d/particle/CCParticleSystem.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 29fb876a82..8309aa9b7d 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2242,7 +2242,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } } }, - clone:function(){ + + clone:function () { var retParticle = new cc.ParticleSystem(); // self, not super From fc0b1e606c6e6747176e487eae1949399e6650bc Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 8 May 2014 14:55:40 +0800 Subject: [PATCH 0074/1564] change CCParticleSystem clone function --- cocos2d/particle/CCParticleSystem.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 8309aa9b7d..23607fd0d9 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1072,8 +1072,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getStartColor:function () { - var color = cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a); - return color; + return cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a); }, /** @@ -1089,8 +1088,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getStartColorVar:function () { - var color = cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a); - return color; + return cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a); }, /** @@ -1106,8 +1104,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getEndColor:function () { - var color = cc.color(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a); - return color; + return cc.color(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a); }, /** @@ -1123,8 +1120,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Color} */ getEndColorVar:function () { - var color = cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a); - return color; + return cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a); }, /** From bec8d481d549d7100a48d05c1cb55de32b7cd9aa Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 8 May 2014 16:01:59 +0800 Subject: [PATCH 0075/1564] Issue #3943: update cc.RepeatForEver's jsDoc --- cocos2d/actions/CCActionInterval.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 1aea35d174..0abd9944bd 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -137,9 +137,10 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ /** * @return {Number} */ - getAmplitudeRate:function () { + getAmplitudeRate: function () { // Abstract class needs implementation cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass."); + return 0; } }); @@ -536,10 +537,10 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.RepeatForever} */ reverse:function () { - return (cc.RepeatForever.create(this._innerAction.reverse())); + return cc.RepeatForever.create(this._innerAction.reverse()); }, /** From 90d66fe98ed3070c9fd5495cf9568848212db45e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 8 May 2014 16:40:07 +0800 Subject: [PATCH 0076/1564] Issue 3943: To create the mirror method --- CCBoot.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 7a48e18d6e..c1c235b0f7 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1468,6 +1468,7 @@ cc.game = { self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW); self._eventShow.setUserData(self); self.onStart(); + self._mirrorMthod(); } }); } else { @@ -1481,6 +1482,7 @@ cc.game = { self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW); self._eventShow.setUserData(self); self.onStart(); + self._mirrorMthod(); clearInterval(self._checkPrepare); } }, 10); @@ -1494,6 +1496,80 @@ cc.game = { _run(); }, false); }, + + /** + * To create the mirror method + * @private + */ + _mirrorMthod: function(){ + cc.action = cc.Action.create; + cc.speed = cc.Speed.create; + cc.follow = cc.Follow.create; + cc.orbitCamera = cc.OrbitCamera.create; + cc.cardinalSplineTo = cc.CardinalSplineTo.create; + cc.cardinalSplineBy = cc.CardinalSplineBy.create; + cc.catmullRomTo = cc.CatmullRomTo.create; + cc.catmullRomBy = cc.CatmullRomBy.create; +// cc.actionEase = cc.ActionEase.create; +// cc.easeRateAction = cc.EaseRateAction.create; +// cc.easeIn = cc.EaseIn.create; +// cc.easeOut = cc.EaseOut.create; +// cc.easeInOut = cc.EaseInOut.create; +// cc.easeExponentialIn = cc.EaseExponentialIn.create; +// cc.easeExponentialOut = cc.EaseExponentialOut.create; +// cc.easeExponentialInOut = cc.EaseExponentialInOut.create; +// cc.easeSineIn = cc.EaseSineIn.create; +// cc.easeSineOut = cc.EaseSineOut.create; +// cc.easeSineInOut = cc.EaseSineInOut.create; +// cc.easeElastic = cc.EaseElastic.create; +// cc.easeElasticIn = cc.EaseElasticIn.create; +// cc.easeElasticOut = cc.EaseElasticOut.create; +// cc.easeElasticInOut = cc.EaseElasticInOut.create; +// cc.easeBounce = cc.EaseBounce.create; +// cc.easeBounceIn = cc.EaseBounceIn.create; +// cc.easeBounceOut = cc.EaseBounceOut.create; +// cc.easeBounceInOut = cc.EaseBounceInOut.create; +// cc.easeBackIn = cc.EaseBackIn.create; +// cc.easeBackOut = cc.EaseBackOut.create; +// cc.easeBackInOut = cc.EaseBackInOut.create; + cc.show = cc.Show.create; + cc.hide = cc.Hide.create; + cc.toggleVisibility = cc.ToggleVisibility.create; + cc.removeSelf = cc.RemoveSelf.create; + cc.flipX = cc.FlipX.create; + cc.flipY = cc.FlipY.create; + cc.place = cc.Place.create; + cc.callFunc = cc.CallFunc.create; + cc.actionInterval = cc.ActionInterval.create; + cc.sequence = cc.Sequence.create; + cc.repeat = cc.Repeat.create; + cc.repeatForever = cc.RepeatForever.create; + cc.spawn = cc.Spawn.create; + cc.rotateTo = cc.RotateTo.create; + cc.rotateBy = cc.RotateBy.create; + cc.moveBy = cc.MoveBy.create; + cc.moveTo = cc.MoveTo.create; + cc.skewTo = cc.SkewTo.create; + cc.skewBy = cc.SkewBy.create; + cc.jumpBy = cc.JumpBy.create; + cc.jumpTo = cc.JumpTo.create; + cc.bezierBy = cc.BezierBy.create; + cc.bezierTo = cc.BezierTo.create; + cc.scaleTo = cc.ScaleTo.create; + cc.scaleBy = cc.ScaleBy.create; + cc.blink = cc.Blink.create; + cc.fadeTo = cc.FadeTo.create; + cc.fadeIn = cc.FadeIn.create; + cc.fadeOut = cc.FadeOut.create; + cc.tintTo = cc.TintTo.create; + cc.tintBy = cc.TintBy.create; + cc.delayTime = cc.DelayTime.create; + cc.reverseTime = cc.ReverseTime.create; + cc.animate = cc.Animate.create; + cc.targetedAction = cc.TargetedAction.create; + cc.actionTween = cc.ActionTween.create; + }, + /** * Init config. * @param cb From 0a338e005f4a3707a29ffcba9916abb43bd63c7a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 May 2014 09:30:56 +0800 Subject: [PATCH 0077/1564] Issue 3943: Change the method name --- CCBoot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index c1c235b0f7..de2d47eb8d 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1468,7 +1468,7 @@ cc.game = { self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW); self._eventShow.setUserData(self); self.onStart(); - self._mirrorMthod(); + self._mirrorMethod(); } }); } else { @@ -1482,7 +1482,7 @@ cc.game = { self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW); self._eventShow.setUserData(self); self.onStart(); - self._mirrorMthod(); + self._mirrorMethod(); clearInterval(self._checkPrepare); } }, 10); @@ -1501,7 +1501,7 @@ cc.game = { * To create the mirror method * @private */ - _mirrorMthod: function(){ + _mirrorMethod: function(){ cc.action = cc.Action.create; cc.speed = cc.Speed.create; cc.follow = cc.Follow.create; From ce1eab2db0bef1870107e20c750869dd5a894a44 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 9 May 2014 15:12:00 +0800 Subject: [PATCH 0078/1564] Issue #3943: refactoring cc.EaseAction for use friendly --- cocos2d/actions/CCActionEase.js | 306 +++++++++++++++++++++++++--- cocos2d/actions/CCActionInstant.js | 10 - cocos2d/actions/CCActionInterval.js | 44 ++-- 3 files changed, 302 insertions(+), 58 deletions(-) diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 32ffa31942..7557bc1d06 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -174,7 +174,7 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseRateAction} */ reverse:function () { return cc.EaseRateAction.create(this._inner.reverse(), 1 / this._rate); @@ -207,7 +207,7 @@ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseIn} */ reverse:function () { return cc.EaseIn.create(this._inner.reverse(), 1 / this._rate); @@ -231,6 +231,15 @@ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ cc.EaseIn.create = function (action, rate) { return new cc.EaseIn(action, rate); }; + +cc.easeIn = function (rate) { + return { + _rate: rate, + easing: function (dt) { + return Math.pow(dt, this._rate); + }}; +}; + /** * cc.EaseOut action with a rate * @class @@ -245,7 +254,7 @@ cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseOut} */ reverse:function () { return cc.EaseOut.create(this._inner.reverse(), 1 / this._rate); @@ -270,6 +279,14 @@ cc.EaseOut.create = function (action, rate) { return new cc.EaseOut(action, rate); }; +cc.easeOut = function (rate) { + return { + _rate: rate, + easing: function (dt) { + return Math.pow(dt, 1 / this._rate); + }}; +}; + /** * cc.EaseInOut action with a rate * @class @@ -294,7 +311,7 @@ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseInOut} */ reverse:function () { return cc.EaseInOut.create(this._inner.reverse(), this._rate); @@ -312,6 +329,19 @@ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ cc.EaseInOut.create = function (action, rate) { return new cc.EaseInOut(action, rate); }; + +cc.easeInOut = function (rate) { + return { + _rate: rate, + easing: function (dt) { + dt *= 2; + if (dt < 1) + return 0.5 * Math.pow(dt, this._rate); + else + return 1.0 - 0.5 * Math.pow(2 - dt, this._rate); + }}; +}; + /** * cc.Ease Exponential In * @class @@ -326,7 +356,7 @@ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseExponentialOut} */ reverse:function () { return cc.EaseExponentialOut.create(this._inner.reverse()); @@ -349,13 +379,22 @@ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ cc.EaseExponentialIn.create = function (action) { return new cc.EaseExponentialIn(action); }; + +cc._easeExponentialInObj = { + easing: function(dt){ + return dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1)); + } +}; +cc.easeExponentialIn = function(){ + return cc._easeExponentialInObj; +}; + /** * Ease Exponential Out * @class * @extends cc.ActionEase */ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# */{ - /** * @param {Number} time1 */ @@ -364,7 +403,7 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# * }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseExponentialIn} */ reverse:function () { return cc.EaseExponentialIn.create(this._inner.reverse()); @@ -388,6 +427,15 @@ cc.EaseExponentialOut.create = function (action) { return new cc.EaseExponentialOut(action); }; +cc._easeExponentialOutObj = { + easing: function(dt){ + return dt == 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1); + } +}; +cc.easeExponentialOut = function(){ + return cc._easeExponentialOutObj; +}; + /** * Ease Exponential InOut * @class @@ -422,7 +470,7 @@ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOu } }); -/** creates the action +/** creates an EaseExponentialInOut action * @param {cc.ActionInterval} action * @return {cc.EaseExponentialInOut} * @example @@ -433,6 +481,21 @@ cc.EaseExponentialInOut.create = function (action) { return new cc.EaseExponentialInOut(action); }; +cc._easeExponentialInOutObj = { + easing: function(dt){ + if( dt !== 1 && dt !== 0) { + dt *= 2; + if (dt < 1) + return 0.5 * Math.pow(2, 10 * (dt - 1)); + else + return 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2); + } + return dt; + } +}; +cc.easeExponentialInOut = function(){ + return cc._easeExponentialInOutObj; +}; /** * Ease Sine In @@ -444,12 +507,12 @@ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ * @param {Number} time1 */ update:function (time1) { - time1 = time1===0 || time1==1 ? time1 : -1 * Math.cos(time1 * Math.PI / 2) + 1; + time1 = time1===0 || time1===1 ? time1 : -1 * Math.cos(time1 * Math.PI / 2) + 1; this._inner.update(time1); }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseSineOut} */ reverse:function () { return cc.EaseSineOut.create(this._inner.reverse()); @@ -462,7 +525,7 @@ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ } }); -/** creates the action +/** creates an EaseSineIn action * @param {cc.ActionInterval} action * @return {cc.EaseSineIn} * @example @@ -472,6 +535,16 @@ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ cc.EaseSineIn.create = function (action) { return new cc.EaseSineIn(action); }; + +cc._easeSineInObj = { + easing: function(dt){ + return (dt===0 || dt===1) ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1; + } +}; +cc.easeSineIn = function(){ + return cc._easeSineInObj; +}; + /** * Ease Sine Out * @class @@ -482,12 +555,12 @@ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ * @param {Number} time1 */ update:function (time1) { - time1 = time1===0 || time1==1 ? time1 : Math.sin(time1 * Math.PI / 2); + time1 = time1===0 || time1===1 ? time1 : Math.sin(time1 * Math.PI / 2); this._inner.update(time1); }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseSineIn} */ reverse:function () { return cc.EaseSineIn.create(this._inner.reverse()); @@ -500,8 +573,7 @@ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ } }); - -/** creates the action +/** creates an EaseSineOut action * @param {cc.ActionInterval} action * @return {cc.EaseSineOut} * @example @@ -512,6 +584,14 @@ cc.EaseSineOut.create = function (action) { return new cc.EaseSineOut(action); }; +cc._easeSineOutObj = { + easing: function(dt){ + return (dt===0 || dt==1) ? dt : Math.sin(dt * Math.PI / 2); + } +}; +cc.easeSineOut = function(){ + return cc._easeSineOutObj; +}; /** * Ease Sine InOut @@ -523,7 +603,7 @@ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ * @param {Number} time1 */ update:function (time1) { - time1 = time1===0 || time1==1 ? time1 : -0.5 * (Math.cos(Math.PI * time1) - 1); + time1 = time1===0 || time1===1 ? time1 : -0.5 * (Math.cos(Math.PI * time1) - 1); this._inner.update(time1); }, @@ -534,7 +614,7 @@ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseSineInOut} */ reverse:function () { return cc.EaseSineInOut.create(this._inner.reverse()); @@ -552,6 +632,15 @@ cc.EaseSineInOut.create = function (action) { return new cc.EaseSineInOut(action); }; +cc._easeSineInOutObj = { + easing: function(dt){ + return (dt === 0 || dt === 1) ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1); + } +}; +cc.easeSineInOut = function(){ + return cc._easeSineInOutObj; +}; + /** * Ease Elastic abstract class * @class @@ -606,6 +695,7 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ */ reverse:function () { cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass."); + return null; }, clone:function(){ @@ -650,7 +740,7 @@ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseElasticOut} */ reverse:function () { return cc.EaseElasticOut.create(this._inner.reverse(), this._period); @@ -663,10 +753,9 @@ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ } }); - /** Creates the action with the inner action and the period in radians (default is 0.3) * @param {cc.ActionInterval} action - * @param {Number} [period=] + * @param {Number} [period=0.3] * @return {cc.EaseElasticIn} * @example * // example @@ -676,6 +765,30 @@ cc.EaseElasticIn.create = function (action, period) { return new cc.EaseElasticIn(action, period); }; +//default ease elastic in object (period = 0.3) +cc._easeElasticInObj = { + easing:function(dt){ + if (dt === 0 || dt === 1) + return dt; + dt = dt - 1; + return -Math.pow(2, 10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3); + } +}; + +cc.easeElasticIn = function (period) { + if(period && period !== 0.3){ + return { + _period: period, + easing: function (dt) { + if (dt === 0 || dt === 1) + return dt; + dt = dt - 1; + return -Math.pow(2, 10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period); + }}; + } + return cc._easeElasticInObj; +}; + /** * Ease Elastic Out action. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @@ -699,7 +812,7 @@ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseElasticIn} */ reverse:function () { return cc.EaseElasticIn.create(this._inner.reverse(), this._period); @@ -712,7 +825,6 @@ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ } }); - /** Creates the action with the inner action and the period in radians (default is 0.3) * @param {cc.ActionInterval} action * @param {Number} [period=0.3] @@ -725,6 +837,24 @@ cc.EaseElasticOut.create = function (action, period) { return new cc.EaseElasticOut(action, period); }; +//default ease elastic out object (period = 0.3) +cc._easeElasticOutObj = { + easing: function (dt) { + return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3) + 1; + } +}; + +cc.easeElasticOut = function (period) { + if(period && period !== 0.3){ + return { + _period: period, + easing: function (dt) { + return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period) + 1; + }}; + } + return cc._easeElasticOutObj; +}; + /** * Ease Elastic InOut action. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @@ -756,7 +886,7 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseElasticInOut} */ reverse:function () { return cc.EaseElasticInOut.create(this._inner.reverse(), this._period); @@ -781,6 +911,30 @@ cc.EaseElasticInOut.create = function (action, period) { return new cc.EaseElasticInOut(action, period); }; +cc.easeElasticInOut = function (period) { + period = period || 0.3; + return { + _period: period, + easing: function (dt) { + var newT = 0; + var locPeriod = this._period; + if (dt === 0 || dt === 1) { + newT = dt; + } else { + dt = dt * 2; + if (!locPeriod) + locPeriod = this._period = 0.3 * 1.5; + var s = locPeriod / 4; + dt = dt - 1; + if (dt < 0) + newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod); + else + newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1; + } + return newT; + }}; +}; + /** * cc.EaseBounce abstract class. * @class @@ -813,14 +967,14 @@ cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseBounce} */ reverse:function () { return cc.EaseBounce.create(this._inner.reverse()); } }); -/** creates the action +/** creates an ease bounce action * @param {cc.ActionInterval} action * @return {cc.EaseBounce} * @example @@ -847,7 +1001,7 @@ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseBounceOut} */ reverse:function () { return cc.EaseBounceOut.create(this._inner.reverse()); @@ -870,6 +1024,31 @@ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ cc.EaseBounceIn.create = function (action) { return new cc.EaseBounceIn(action); }; + +cc._bounceTime = function (time1) { + if (time1 < 1 / 2.75) { + return 7.5625 * time1 * time1; + } else if (time1 < 2 / 2.75) { + time1 -= 1.5 / 2.75; + return 7.5625 * time1 * time1 + 0.75; + } else if (time1 < 2.5 / 2.75) { + time1 -= 2.25 / 2.75; + return 7.5625 * time1 * time1 + 0.9375; + } + + time1 -= 2.625 / 2.75; + return 7.5625 * time1 * time1 + 0.984375; +}; + +cc._easeBounceInObj = { + easing: function(dt){ + return 1 - cc._bounceTime(1 - dt); + } +}; +cc.easeBounceIn = function(){ + return cc._easeBounceInObj; +}; + /** * cc.EaseBounceOut action. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @@ -910,6 +1089,15 @@ cc.EaseBounceOut.create = function (action) { return new cc.EaseBounceOut(action); }; +cc._easeBounceOutObj = { + easing: function(dt){ + return cc._bounceTime(dt); + } +}; +cc.easeBounceOut = function(){ + return cc._easeBounceOutObj; +}; + /** * cc.EaseBounceInOut action. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @@ -938,7 +1126,7 @@ cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseBounceInOut} */ reverse:function () { return cc.EaseBounceInOut.create(this._inner.reverse()); @@ -956,9 +1144,25 @@ cc.EaseBounceInOut.create = function (action) { return new cc.EaseBounceInOut(action); }; +cc._easeBounceInOutObj = { + easing: function (time1) { + var newT; + if (time1 < 0.5) { + time1 = time1 * 2; + newT = (1 - cc._bounceTime(1 - time1)) * 0.5; + } else { + newT = cc._bounceTime(time1 * 2 - 1) * 0.5 + 0.5; + } + return newT; + }}; + +cc.easeBounceInOut = function(){ + return cc._easeBounceInOutObj; +}; + /** * cc.EaseBackIn 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 */ @@ -973,7 +1177,7 @@ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseBackOut} */ reverse:function () { return cc.EaseBackOut.create(this._inner.reverse()); @@ -998,9 +1202,19 @@ cc.EaseBackIn.create = function (action) { return new cc.EaseBackIn(action); }; +cc._easeBackInObj = { + easing: function (time1) { + var overshoot = 1.70158; + return (time1===0 || time1===1) ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot); + }}; + +cc.easeBackIn = function(){ + return cc._easeBackInObj; +}; + /** * cc.EaseBackOut 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 */ @@ -1010,13 +1224,12 @@ cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ */ update:function (time1) { var overshoot = 1.70158; - time1 = time1 - 1; this._inner.update(time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1); }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseBackIn} */ reverse:function () { return cc.EaseBackIn.create(this._inner.reverse()); @@ -1040,6 +1253,17 @@ cc.EaseBackOut.create = function (action) { return new cc.EaseBackOut(action); }; +cc._easeBackOutObj = { + easing: function (time1) { + var overshoot = 1.70158; + time1 = time1 - 1; + return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1; + }}; + +cc.easeBackOut = function(){ + return cc._easeBackOutObj; +}; + /** * cc.EaseBackInOut action. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @@ -1068,7 +1292,7 @@ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.EaseBackInOut} */ reverse:function () { return cc.EaseBackInOut.create(this._inner.reverse()); @@ -1087,3 +1311,19 @@ cc.EaseBackInOut.create = function (action) { return new cc.EaseBackInOut(action); }; +cc._easeBackInOutObj = { + easing: function (time1) { + var overshoot = 1.70158 * 1.525; + time1 = time1 * 2; + if (time1 < 1) { + return (time1 * time1 * ((overshoot + 1) * time1 - overshoot)) / 2; + } else { + time1 = time1 - 2; + return (time1 * time1 * ((overshoot + 1) * time1 + overshoot)) / 2 + 1; + } + }}; + +cc.easeBackInOut = function(){ + return cc._easeBackInOutObj; +}; + diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index 4c53cf4442..1959e2a149 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -503,16 +503,6 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ } }, - copy:function() { - var n = new cc.CallFunc(); - if(this._selectorTarget){ - n.initWithFunction(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 3d0b7d6b4c..ae5d1e03fc 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -46,6 +46,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _elapsed:0, _firstTick:false, + _easeList: null, /** * @constructor @@ -55,7 +56,6 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ ctor:function (d) { cc.FiniteTimeAction.prototype.ctor.call(this); - d !== undefined && this.initWithDuration(d); }, @@ -95,10 +95,31 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ return new cc.ActionInterval(this._duration); }, + easing: function (easeObj) { + var locEaseList = this._easeList; + if (locEaseList) + locEaseList.length = 0; + else + locEaseList = []; + for (var i = 0; i < arguments.length; i++) + locEaseList.push(arguments[i]); + return this; + }, + + _computeEaseTime: function (dt) { + var locList = this._easeList; + if ((!locList) || (locList.length === 0)) + return dt; + for (var i = 0, n = locList.length; i < n; i++) + dt = locList.easing(dt); + return dt; + }, + /** * @param {Number} dt delta time in seconds */ step:function (dt) { + dt = this._computeEaseTime(dt); if (this._firstTick) { this._firstTick = false; this._elapsed = 0; @@ -143,6 +164,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ getAmplitudeRate:function () { // Abstract class needs implementation cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass."); + return 0; } }); @@ -170,7 +192,6 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ /** Create an array of sequenceable actions * @constructor * @param {Array|cc.FiniteTimeAction} tempArray - * @return {cc.Sequence} * @example * // create sequence with actions * var seq = new cc.Sequence(act1, act2); @@ -299,14 +320,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 @@ -504,7 +517,7 @@ cc.Repeat.create = function (action, times) { /** Repeats an action for ever.
* To repeat the an action for a limited number of times use the Repeat action.
- * @warning This action can't be Sequencable because it is not an IntervalAction + * @warning This action can't be Sequenceable because it is not an IntervalAction * @class * @extends cc.ActionInterval */ @@ -2366,11 +2379,12 @@ cc.DelayTime.create = function (d) { }; /** - * Executes an action in reverse order, from time=duration to time=0 - * @warning Use this action carefully. This action is not - * sequenceable. Use it as the default "reversed" method - * of your own actions, but using it outside the "reversed" + *

+ * Executes an action in reverse order, from time=duration to time=0
+ * @warning Use this action carefully. This action is not sequenceable.
+ * Use it as the default "reversed" method of your own actions, but using it outside the "reversed"
* scope is not recommended. + *

* @class * @extends cc.ActionInterval */ From a4924d0cc88746e90ca15598191e1bf2be1e4d03 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 May 2014 16:20:38 +0800 Subject: [PATCH 0079/1564] Issue #3943: Add the cc.action.speed method --- cocos2d/actions/CCAction.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index b9d15dc1fa..5539c0b8f7 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -176,6 +176,35 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ retain:function () { }, release:function () { + }, + + _speed:0.0, + + /** + * Changes the speed of an action, making it take longer (speed>1) + * or less (speed<1) time.
+ * Useful to simulate 'slow motion' or 'fast forward' effect. + * + * @param speed + * @returns {cc.Action} + */ + speed: function(speed){ + + var self = this; + self._speed = speed; + var _step = self.step; + self.step = function(dt){ + _step.call(self, dt * speed); + }; + + return this; + }, + + /** + * @return {Number} + */ + getSpeed: function(speed){ + return this._speed; } }); /** Allocates and initializes the action From 52dc551c23d1c1997984ea80a6f61c391716095d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 May 2014 16:27:58 +0800 Subject: [PATCH 0080/1564] Issue #3943: Moving the cc.action.speed method --- cocos2d/actions/CCAction.js | 29 ----------------------------- cocos2d/actions/CCActionInterval.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 2863e31fc7..2b9e088711 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -177,35 +177,6 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ retain:function () { }, release:function () { - }, - - _speed:0.0, - - /** - * Changes the speed of an action, making it take longer (speed>1) - * or less (speed<1) time.
- * Useful to simulate 'slow motion' or 'fast forward' effect. - * - * @param speed - * @returns {cc.Action} - */ - speed: function(speed){ - - var self = this; - self._speed = speed; - var _step = self.step; - self.step = function(dt){ - _step.call(self, dt * speed); - }; - - return this; - }, - - /** - * @return {Number} - */ - getSpeed: function(speed){ - return this._speed; } }); /** Allocates and initializes the action diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index ae5d1e03fc..7b8f4257da 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -165,6 +165,35 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ // Abstract class needs implementation cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass."); return 0; + }, + + _speed:0.0, + + /** + * Changes the speed of an action, making it take longer (speed>1) + * or less (speed<1) time.
+ * Useful to simulate 'slow motion' or 'fast forward' effect. + * + * @param speed + * @returns {cc.Action} + */ + speed: function(speed){ + + var self = this; + self._speed = speed; + var _step = self.step; + self.step = function(dt){ + _step.call(self, dt * speed); + }; + + return this; + }, + + /** + * @return {Number} + */ + getSpeed: function(speed){ + return this._speed; } }); From 28d6d50bf07e2218b8293bbe71ecc88d43e557c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=AF=E6=9D=B0?= Date: Sat, 10 May 2014 11:33:38 +0800 Subject: [PATCH 0081/1564] Issue #3943: Add the cc.action.repeat() and cc.action.repeatForever() --- cocos2d/actions/CCActionInterval.js | 46 +++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 7b8f4257da..75e1e6b962 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -47,6 +47,8 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _elapsed:0, _firstTick:false, _easeList: null, + _times:0, + _speed:0.0, /** * @constructor @@ -55,6 +57,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ * var actionInterval = new cc.ActionInterval(3); */ ctor:function (d) { + this._times = 0; cc.FiniteTimeAction.prototype.ctor.call(this); d !== undefined && this.initWithDuration(d); }, @@ -131,6 +134,19 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ var t = this._elapsed / (this._duration > 0.0000001192092896 ? this._duration : 0.0000001192092896); t = (1 > t ? t : 1); this.update(t > 0 ? t : 0); + + if(this._times > 1 && this.isDone()){ + if(!this._repeatForever){ + this._times--; + } + //var diff = locInnerAction.getElapsed() - locInnerAction.getDuration(); + this.startWithTarget(this.target); + // to prevent jerk. issue #390 ,1247 + //this._innerAction.step(0); + //this._innerAction.step(diff); + this.step(this.getElapsed() - this.getDuration()); + + } }, /** @@ -167,8 +183,6 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ return 0; }, - _speed:0.0, - /** * Changes the speed of an action, making it take longer (speed>1) * or less (speed<1) time.
@@ -194,6 +208,34 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ getSpeed: function(speed){ return this._speed; + }, + + /** + * Repeats an action a number of times. + * To repeat an action forever use the CCRepeatForever action. + * @param times + * @returns {cc.ActionInterval} + */ + repeat: function(times){ + + times = parseInt(times); + if(isNaN(parseInt(times))){ + this._times = 0; + }else{ + this._times = times; + } + return this; + }, + + /** + * Repeats an action for ever.
+ * To repeat the an action for a limited number of times use the Repeat action.
+ * @returns {cc.ActionInterval} + */ + repeatForever: function(){ + this._times = 2; + this._repeatForever = 1; + return this; } }); From 7d2797292e0344a8d764c2a5eebd7403b0b9c6ae Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 11 May 2014 09:46:21 +0800 Subject: [PATCH 0082/1564] Issue #3943: Change the value of times --- cocos2d/actions/CCActionInterval.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 75e1e6b962..291e0280ab 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -57,7 +57,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ * var actionInterval = new cc.ActionInterval(3); */ ctor:function (d) { - this._times = 0; + this._times = 1; cc.FiniteTimeAction.prototype.ctor.call(this); d !== undefined && this.initWithDuration(d); }, From 2bfcedef86b6adcfe63439cfca67ca82546ff740 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sun, 11 May 2014 10:17:30 +0800 Subject: [PATCH 0083/1564] Issue #3943: add a reverse sample function to cc.easeElasticOut --- cocos2d/actions/CCActionEase.js | 6 +++++- cocos2d/actions/CCActionInterval.js | 18 ++++++++++-------- cocos2d/core/CCDirectorWebGL.js | 6 ++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 7557bc1d06..994179425d 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -850,7 +850,11 @@ cc.easeElasticOut = function (period) { _period: period, easing: function (dt) { return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period) + 1; - }}; + }, + reverse:function(){ + return cc.easeElasticIn(this._period); + } + }; } return cc._easeElasticOutObj; }; diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index ae5d1e03fc..6bdb4c7184 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -397,8 +397,10 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ if (this.initWithDuration(duration)) { this._times = times; this._innerAction = action; - if (action instanceof cc.ActionInstant) + if (action instanceof cc.ActionInstant){ + this._actionInstant = true; this._times -= 1; + } this._total = 0; return true; } @@ -456,9 +458,9 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ 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) { + // don't set a instant action back or update it, it has no use because it has no duration + if (!this._actionInstant) { + if (this._total === locTimes) { locInnerAction.update(1); locInnerAction.stop(); } else { @@ -899,7 +901,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ /** * @constructor - * @param {Number} duration druation in seconds + * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY] deltaAngleY in degrees * @example @@ -956,7 +958,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }, /** - * @return {cc.ActionInterval} + * @return {cc.RotateBy} */ reverse:function () { return cc.RotateBy.create(this._duration, -this._angleX, -this._angleY); @@ -964,7 +966,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }); /** - * @param {Number} duration druation in seconds + * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY] deltaAngleY in degrees * @return {cc.RotateBy} @@ -1091,7 +1093,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ /** * @param {Number} duration duration in seconds - * @param {cc.Point|Number} deltaPosition + * @param {cc.Point|Number} deltaPos * @param {Number} deltaY * @return {cc.MoveBy} * @example diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index f090e187c4..02aa073164 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -152,8 +152,10 @@ _tmp.DirectorWebGL = function () { _p._createStatsLabel = function () { var _t = this; - if (!cc.LabelAtlas) - return _t._createStatsLabelForCanvas(); + if (!cc.LabelAtlas){ + _t._createStatsLabelForCanvas(); + return + } if ((cc.Director._fpsImageLoaded == null) || (cc.Director._fpsImageLoaded == false)) return; From 5de1c6c41ea55e1f6f3d371f8f53e442803a3eec Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 11 May 2014 13:52:01 +0800 Subject: [PATCH 0084/1564] Issue #3943: Modification of clone, reverse and getDuration --- cocos2d/actions/CCAction.js | 2 +- cocos2d/actions/CCActionInterval.js | 158 ++++++++++++++++++++-------- cocos2d/core/CCActionManager.js | 2 +- 3 files changed, 118 insertions(+), 44 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 2b9e088711..7cf1bed256 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -214,7 +214,7 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ * @return {Number} */ getDuration:function () { - return this._duration; + return this._duration * (this._times || 1); }, /** set duration in seconds of the action diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 291e0280ab..87babc982a 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -47,8 +47,10 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _elapsed:0, _firstTick:false, _easeList: null, - _times:0, - _speed:0.0, + _times:1, + _repeatForever: false, + _repeatMethod: false,//Compatible with repeat class, Discard after can be deleted + _speed: 1, /** * @constructor @@ -57,7 +59,11 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ * var actionInterval = new cc.ActionInterval(3); */ ctor:function (d) { + this._speed = 1; this._times = 1; + this._repeatForever = false; + this.MAX_VALUE = 2; + this._repeatMethod =false;//Compatible with repeat class, Discard after can be deleted cc.FiniteTimeAction.prototype.ctor.call(this); d !== undefined && this.initWithDuration(d); }, @@ -90,12 +96,26 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ return (this._elapsed >= this._duration); }, + /** + * Some additional parameters of cloning + * @param {cc.Action} action + * @private + */ + _cloneDecoration: function(action){ + action._repeatForever = this._repeatForever; + action._speed = this._speed; + action._times = this._times; + action._easeList = this._easeList;; + }, + /** * returns a new clone of the action * @returns {cc.ActionInterval} */ clone:function () { - return new cc.ActionInterval(this._duration); + var action = new cc.ActionInterval(this._duration); + this._cloneDecoration(action); + return action; }, easing: function (easeObj) { @@ -135,16 +155,17 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ t = (1 > t ? t : 1); this.update(t > 0 ? t : 0); - if(this._times > 1 && this.isDone()){ + //Compatible with repeat class, Discard after can be deleted (this._repeatMethod) + if(this._repeatMethod && this._times > 1 && this.isDone()){ if(!this._repeatForever){ this._times--; } - //var diff = locInnerAction.getElapsed() - locInnerAction.getDuration(); + //var diff = locInnerAction.getElapsed() - locInnerAction._duration; this.startWithTarget(this.target); // to prevent jerk. issue #390 ,1247 //this._innerAction.step(0); //this._innerAction.step(diff); - this.step(this.getElapsed() - this.getDuration()); + this.step(this._elapsed - this._duration); } }, @@ -193,12 +214,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ speed: function(speed){ - var self = this; - self._speed = speed; - var _step = self.step; - self.step = function(dt){ - _step.call(self, dt * speed); - }; + this._speed = speed; return this; }, @@ -218,9 +234,10 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ repeat: function(times){ + this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted times = parseInt(times); if(isNaN(parseInt(times))){ - this._times = 0; + this._times = 1; }else{ this._times = times; } @@ -233,8 +250,9 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ * @returns {cc.ActionInterval} */ repeatForever: function(){ - this._times = 2; - this._repeatForever = 1; + this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted + this._times = this.MAX_VALUE; + this._repeatForever = true; return this; } }); @@ -301,7 +319,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ if(!actionOne || !actionTwo) throw "cc.Sequence.initWithTwoActions(): arguments must all be non nil"; - var d = actionOne.getDuration() + actionTwo.getDuration(); + var d = actionOne._duration + actionTwo._duration; this.initWithDuration(d); this._actions[0] = actionOne; @@ -315,6 +333,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ */ clone:function () { var action = new cc.Sequence(); + this._cloneDecoration(action); action.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone()); return action; }, @@ -324,7 +343,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); - this._split = this._actions[0].getDuration() / this._duration; + this._split = this._actions[0]._duration / this._duration; this._last = -1; }, @@ -390,7 +409,9 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse()); + var action = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse()); + this._cloneDecoration(action); + return action; } }); /** helper constructor to create an array of sequenceable actions @@ -463,7 +484,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ * @return {Boolean} */ initWithAction:function (action, times) { - var duration = action.getDuration() * times; + var duration = action._duration * times; if (this.initWithDuration(duration)) { this._times = times; @@ -482,6 +503,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ */ clone:function () { var action = new cc.Repeat(); + this._cloneDecoration(action); action.initWithAction(this._innerAction.clone(), this._times); return action; }, @@ -491,7 +513,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ */ startWithTarget:function (target) { this._total = 0; - this._nextDt = this._innerAction.getDuration() / this._duration; + this._nextDt = this._innerAction._duration / this._duration; cc.ActionInterval.prototype.startWithTarget.call(this, target); this._innerAction.startWithTarget(target); }, @@ -519,7 +541,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ this._total++; locInnerAction.stop(); locInnerAction.startWithTarget(this.target); - locNextDt += locInnerAction.getDuration() / locDuration; + locNextDt += locInnerAction._duration / locDuration; this._nextDt = locNextDt; } @@ -534,7 +556,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ locInnerAction.stop(); } else { // issue #390 prevent jerk, use right update - locInnerAction.update(time - (locNextDt - locInnerAction.getDuration() / locDuration)); + locInnerAction.update(time - (locNextDt - locInnerAction._duration / locDuration)); } } } else { @@ -553,7 +575,9 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.Repeat.create(this._innerAction.reverse(), this._times); + var action = cc.Repeat.create(this._innerAction.reverse(), this._times); + this._cloneDecoration(action); + return action; }, /** @@ -627,6 +651,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ */ clone:function () { var action = new cc.RepeatForever(); + this._cloneDecoration(action); action.initWithAction(this._innerAction.clone()); return action; }, @@ -646,12 +671,12 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ var locInnerAction = this._innerAction; locInnerAction.step(dt); if (locInnerAction.isDone()) { - //var diff = locInnerAction.getElapsed() - locInnerAction.getDuration(); + //var diff = locInnerAction.getElapsed() - locInnerAction._duration; locInnerAction.startWithTarget(this.target); // to prevent jerk. issue #390 ,1247 //this._innerAction.step(0); //this._innerAction.step(diff); - locInnerAction.step(locInnerAction.getElapsed() - locInnerAction.getDuration()); + locInnerAction.step(locInnerAction.getElapsed() - locInnerAction._duration); } }, @@ -666,7 +691,9 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ * @return {cc.ActionInterval} */ reverse:function () { - return (cc.RepeatForever.create(this._innerAction.reverse())); + var action = cc.RepeatForever.create(this._innerAction.reverse()); + this._cloneDecoration(action); + return action; }, /** @@ -747,8 +774,8 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ var ret = false; - var d1 = action1.getDuration(); - var d2 = action2.getDuration(); + var d1 = action1._duration; + var d2 = action2._duration; if (this.initWithDuration(Math.max(d1, d2))) { this._one = action1; @@ -771,6 +798,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ */ clone:function () { var action = new cc.Spawn(); + this._cloneDecoration(action); action.initWithTwoActions(this._one.clone(), this._two.clone()); return action; }, @@ -807,7 +835,9 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ * @return {cc.FiniteTimeAction} */ reverse:function () { - return cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse()); + var action = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse()); + this._cloneDecoration(action); + return action; } }); @@ -895,6 +925,7 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ */ clone:function () { var action = new cc.RotateTo(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY); return action; }, @@ -1003,6 +1034,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ */ clone:function () { var action = new cc.RotateBy(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._angleX, this._angleY); return action; }, @@ -1030,7 +1062,9 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.RotateBy.create(this._duration, -this._angleX, -this._angleY); + var action = cc.RotateBy.create(this._duration, -this._angleX, -this._angleY); + this._cloneDecoration(action); + return action; } }); @@ -1109,6 +1143,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ */ clone:function () { var action = new cc.MoveBy(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._positionDelta) return action; }, @@ -1156,7 +1191,9 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ * MoveTo reverse is not implemented */ reverse:function () { - return cc.MoveBy.create(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); + var action = cc.MoveBy.create(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); + this._cloneDecoration(action); + return action; } }); @@ -1225,6 +1262,7 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ */ clone:function () { var action = new cc.MoveTo(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._endPosition); return action; }, @@ -1302,6 +1340,7 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ */ clone:function () { var action = new cc.SkewTo(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._endSkewX, this._endSkewY); return action; }, @@ -1387,6 +1426,7 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ */ clone:function () { var action = new cc.SkewBy(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._skewX, this._skewY); return action; }, @@ -1406,7 +1446,9 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.SkewBy.create(this._duration, -this._skewX, -this._skewY); + var action = cc.SkewBy.create(this._duration, -this._skewX, -this._skewY); + this._cloneDecoration(action); + return action; } }); /** @@ -1490,6 +1532,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ */ clone:function () { var action = new cc.JumpBy(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._delta, this._height, this._jumps); return action; }, @@ -1540,7 +1583,9 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.JumpBy.create(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); + var action = cc.JumpBy.create(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); + this._cloneDecoration(action); + return action; } }); @@ -1581,6 +1626,7 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ */ clone:function () { var action = new cc.JumpTo(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._delta, this._height, this._jumps); return action; } @@ -1662,6 +1708,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ */ clone:function () { var action = new cc.BezierBy(); + this._cloneDecoration(action); var newConfigs = []; for (var i = 0; i < this._config.length; i++) { var selConf = this._config[i]; @@ -1731,7 +1778,9 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ cc.pAdd(locConfig[1], cc.pNeg(locConfig[2])), cc.pAdd(locConfig[0], cc.pNeg(locConfig[2])), cc.pNeg(locConfig[2]) ]; - return cc.BezierBy.create(this._duration, r); + var action = cc.BezierBy.create(this._duration, r); + this._cloneDecoration(action); + return action; } }); @@ -1789,6 +1838,7 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ */ clone:function () { var action = new cc.BezierTo(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._toConfig); return action; }, @@ -1874,6 +1924,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ */ clone:function () { var action = new cc.ScaleTo(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._endScaleX, this._endScaleY); return action; }, @@ -1937,7 +1988,9 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.ScaleBy.create(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); + var action = cc.ScaleBy.create(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); + this._cloneDecoration(action); + return action; }, /** @@ -1946,6 +1999,7 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ */ clone:function () { var action = new cc.ScaleBy(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._endScaleX, this._endScaleY); return action; } @@ -2005,6 +2059,7 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ */ clone:function () { var action = new cc.Blink(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._times); return action; }, @@ -2034,7 +2089,9 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.Blink.create(this._duration, this._times); + var action = cc.Blink.create(this._duration, this._times); + this._cloneDecoration(action); + return action; } }); /** @@ -2091,6 +2148,7 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ */ clone:function () { var action = new cc.FadeTo(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._toOpacity); return action; }, @@ -2141,6 +2199,7 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ reverse:function () { var action = new cc.FadeOut(); action.initWithDuration(this._duration, 0); + this._cloneDecoration(action); return action; }, @@ -2150,6 +2209,7 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ */ clone:function () { var action = new cc.FadeIn(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._toOpacity); return action; }, @@ -2192,6 +2252,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ var action = new cc.FadeIn(); action._reverseAction = this; action.initWithDuration(this._duration, 255); + this._cloneDecoration(action); return action; }, @@ -2201,6 +2262,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ */ clone:function () { var action = new cc.FadeOut(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._toOpacity); return action; } @@ -2266,6 +2328,7 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ */ clone:function () { var action = new cc.TintTo(); + this._cloneDecoration(action); var locTo = this._to; action.initWithDuration(this._duration, locTo.r, locTo.g, locTo.b); return action; @@ -2359,6 +2422,7 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ */ clone:function () { var action = new cc.TintBy(); + this._cloneDecoration(action); action.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB); return action; }, @@ -2391,7 +2455,9 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.TintBy.create(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); + var action = cc.TintBy.create(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); + this._cloneDecoration(action); + return action; } }); @@ -2424,7 +2490,9 @@ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.DelayTime.create(this._duration); + var action = cc.DelayTime.create(this._duration); + this._cloneDecoration(action); + return action; }, /** @@ -2433,6 +2501,7 @@ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ */ clone:function () { var action = new cc.DelayTime(); + this._cloneDecoration(action); action.initWithDuration(this._duration); return action; } @@ -2485,7 +2554,7 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ if(action == this._other) throw "cc.ReverseTime.initWithAction(): the action was already passed in."; - if (cc.ActionInterval.prototype.initWithDuration.call(this, action.getDuration())) { + if (cc.ActionInterval.prototype.initWithDuration.call(this, action._duration)) { // Don't leak if action is reused this._other = action; return true; @@ -2499,6 +2568,7 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ */ clone:function () { var action = new cc.ReverseTime(); + this._cloneDecoration(action); action.initWithAction(this._other.clone()); return action; }, @@ -2594,7 +2664,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ initWithAnimation:function (animation) { if(!animation) throw "cc.Animate.initWithAnimation(): animation must be non-NULL"; - var singleDuration = animation.getDuration(); + var singleDuration = animation._duration; if (this.initWithDuration(singleDuration * animation.getLoops())) { this._nextFrame = 0; this.setAnimation(animation); @@ -2627,6 +2697,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ */ clone:function () { var action = new cc.Animate(); + this._cloneDecoration(action); action.initWithAnimation(this._animation.clone()); return action; }, @@ -2692,7 +2763,9 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ } var newAnim = cc.Animation.create(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops()); newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame()); - return cc.Animate.create(newAnim); + var action = cc.Animate.create(newAnim); + this._cloneDecoration(action); + return action; }, /** @@ -2748,7 +2821,7 @@ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{ * @return {Boolean} */ initWithTarget:function (target, action) { - if (this.initWithDuration(action.getDuration())) { + if (this.initWithDuration(action._duration)) { this._forcedTarget = target; this._action = action; return true; @@ -2762,6 +2835,7 @@ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{ */ clone:function () { var action = new cc.TargetedAction(); + this._cloneDecoration(action); action.initWithTarget(this._forcedTarget, this._action.clone()); return action; }, diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index 1b4eaf5fb7..b4353b91b9 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -345,7 +345,7 @@ cc.ActionManager = cc.Class.extend({ continue; locCurrTarget.currentActionSalvaged = false; - locCurrTarget.currentAction.step(dt); + locCurrTarget.currentAction.step(dt * (locCurrTarget.currentAction._speed || 1)); if (locCurrTarget.currentActionSalvaged) { // The currentAction told the node to remove it. To prevent the action from // accidentally deallocating itself before finishing its step, we retained From 11dbe46a1ea9e75026edbdd995f1bda9dd535800 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 11 May 2014 14:52:40 +0800 Subject: [PATCH 0085/1564] Issue #3943: Compatible with old class --- cocos2d/actions/CCActionInterval.js | 6 ++++-- cocos2d/core/CCActionManager.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 87babc982a..e34072974d 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -51,6 +51,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _repeatForever: false, _repeatMethod: false,//Compatible with repeat class, Discard after can be deleted _speed: 1, + _speedMethod: false,//Compatible with speed class, Discard after can be deleted /** * @constructor @@ -63,7 +64,8 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ this._times = 1; this._repeatForever = false; this.MAX_VALUE = 2; - this._repeatMethod =false;//Compatible with repeat class, Discard after can be deleted + this._repeatMethod = false;//Compatible with repeat class, Discard after can be deleted + this._speedMethod = false;//Compatible with repeat class, Discard after can be deleted cc.FiniteTimeAction.prototype.ctor.call(this); d !== undefined && this.initWithDuration(d); }, @@ -2664,7 +2666,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ initWithAnimation:function (animation) { if(!animation) throw "cc.Animate.initWithAnimation(): animation must be non-NULL"; - var singleDuration = animation._duration; + var singleDuration = animation.getDuration(); if (this.initWithDuration(singleDuration * animation.getLoops())) { this._nextFrame = 0; this.setAnimation(animation); diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index b4353b91b9..37369ac7d9 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -345,7 +345,7 @@ cc.ActionManager = cc.Class.extend({ continue; locCurrTarget.currentActionSalvaged = false; - locCurrTarget.currentAction.step(dt * (locCurrTarget.currentAction._speed || 1)); + locCurrTarget.currentAction.step(dt * ( locCurrTarget.currentAction._speedMethod ? locCurrTarget.currentAction._speed : 1 ) ); if (locCurrTarget.currentActionSalvaged) { // The currentAction told the node to remove it. To prevent the action from // accidentally deallocating itself before finishing its step, we retained From badc471dd90a9e9ca72a8fbc3f2eec9888f0cefd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 11 May 2014 16:36:14 +0800 Subject: [PATCH 0086/1564] Issue #3943: Ease reverse --- cocos2d/actions/CCActionEase.js | 89 +++++++++++++++++++++++++---- cocos2d/actions/CCActionInterval.js | 43 ++++++++++++-- 2 files changed, 116 insertions(+), 16 deletions(-) diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 994179425d..b1bcf7cee2 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -237,7 +237,11 @@ cc.easeIn = function (rate) { _rate: rate, easing: function (dt) { return Math.pow(dt, this._rate); - }}; + }, + reverse: function(){ + return cc.easeOut(this._rate); + } + }; }; /** @@ -284,7 +288,11 @@ cc.easeOut = function (rate) { _rate: rate, easing: function (dt) { return Math.pow(dt, 1 / this._rate); - }}; + }, + reverse: function(){ + return cc.easeIn(this._rate) + } + }; }; /** @@ -339,7 +347,11 @@ cc.easeInOut = function (rate) { return 0.5 * Math.pow(dt, this._rate); else return 1.0 - 0.5 * Math.pow(2 - dt, this._rate); - }}; + }, + reverse: function(){ + return cc.easeInOut(this._rate); + } + }; }; /** @@ -383,6 +395,9 @@ cc.EaseExponentialIn.create = function (action) { cc._easeExponentialInObj = { easing: function(dt){ return dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1)); + }, + reverse: function(){ + return cc._easeExponentialOutObj; } }; cc.easeExponentialIn = function(){ @@ -430,6 +445,9 @@ cc.EaseExponentialOut.create = function (action) { cc._easeExponentialOutObj = { easing: function(dt){ return dt == 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1); + }, + reverse: function(){ + return cc._easeExponentialInObj; } }; cc.easeExponentialOut = function(){ @@ -491,6 +509,9 @@ cc._easeExponentialInOutObj = { return 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2); } return dt; + }, + reverse: function(){ + return cc._easeExponentialInOutObj; } }; cc.easeExponentialInOut = function(){ @@ -539,6 +560,9 @@ cc.EaseSineIn.create = function (action) { cc._easeSineInObj = { easing: function(dt){ return (dt===0 || dt===1) ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1; + }, + reverse: function(){ + return cc._easeSineOutObj; } }; cc.easeSineIn = function(){ @@ -587,6 +611,9 @@ cc.EaseSineOut.create = function (action) { cc._easeSineOutObj = { easing: function(dt){ return (dt===0 || dt==1) ? dt : Math.sin(dt * Math.PI / 2); + }, + reverse: function(){ + return cc._easeSineInObj; } }; cc.easeSineOut = function(){ @@ -635,6 +662,9 @@ cc.EaseSineInOut.create = function (action) { cc._easeSineInOutObj = { easing: function(dt){ return (dt === 0 || dt === 1) ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1); + }, + reverse: function(){ + return cc._easeSineInOutObj; } }; cc.easeSineInOut = function(){ @@ -772,7 +802,10 @@ cc._easeElasticInObj = { return dt; dt = dt - 1; return -Math.pow(2, 10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3); - } + }, + reverse:function(){ + return cc._easeElasticOutObj; + } }; cc.easeElasticIn = function (period) { @@ -784,7 +817,14 @@ cc.easeElasticIn = function (period) { return dt; dt = dt - 1; return -Math.pow(2, 10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period); - }}; + }, + /** + * @return {cc.EaseElasticIn} + */ + reverse:function () { + return cc.easeElasticOut(this._period); + } + }; } return cc._easeElasticInObj; }; @@ -841,6 +881,9 @@ cc.EaseElasticOut.create = function (action, period) { cc._easeElasticOutObj = { easing: function (dt) { return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3) + 1; + }, + reverse:function(){ + return cc._easeElasticInObj; } }; @@ -936,7 +979,11 @@ cc.easeElasticInOut = function (period) { newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1; } return newT; - }}; + }, + reverse: function(){ + return cc.EaseElasticInOut(this._period); + } + }; }; /** @@ -1047,6 +1094,9 @@ cc._bounceTime = function (time1) { cc._easeBounceInObj = { easing: function(dt){ return 1 - cc._bounceTime(1 - dt); + }, + reverse: function(){ + return cc._easeBounceOutObj; } }; cc.easeBounceIn = function(){ @@ -1096,6 +1146,9 @@ cc.EaseBounceOut.create = function (action) { cc._easeBounceOutObj = { easing: function(dt){ return cc._bounceTime(dt); + }, + reverse:function () { + return cc._easeBounceInObj; } }; cc.easeBounceOut = function(){ @@ -1158,7 +1211,11 @@ cc._easeBounceInOutObj = { newT = cc._bounceTime(time1 * 2 - 1) * 0.5 + 0.5; } return newT; - }}; + }, + reverse: function(){ + return cc._easeBounceInOutObj; + } +}; cc.easeBounceInOut = function(){ return cc._easeBounceInOutObj; @@ -1210,7 +1267,11 @@ cc._easeBackInObj = { easing: function (time1) { var overshoot = 1.70158; return (time1===0 || time1===1) ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot); - }}; + }, + reverse: function(){ + return cc._easeBackOutObj; + } +}; cc.easeBackIn = function(){ return cc._easeBackInObj; @@ -1262,7 +1323,11 @@ cc._easeBackOutObj = { var overshoot = 1.70158; time1 = time1 - 1; return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1; - }}; + }, + reverse: function(){ + return cc._easeBackInObj; + } +}; cc.easeBackOut = function(){ return cc._easeBackOutObj; @@ -1325,7 +1390,11 @@ cc._easeBackInOutObj = { time1 = time1 - 2; return (time1 * time1 * ((overshoot + 1) * time1 + overshoot)) / 2 + 1; } - }}; + }, + reverse: function(){ + return cc._easeBackInOutObj; + } +}; cc.easeBackInOut = function(){ return cc._easeBackInOutObj; diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index b96e69ae6a..2357b53e4f 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -107,7 +107,22 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ action._repeatForever = this._repeatForever; action._speed = this._speed; action._times = this._times; - action._easeList = this._easeList;; + action._easeList = this._easeList; + }, + + /** + * + * @param action + * @private + */ + _reverseEaseList: function(action){ + + if(this._easeList){ + + action._easeList = this._easeList.map(function(_ease){ + return _ease.reverse(); + }); + } }, /** @@ -121,13 +136,12 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, easing: function (easeObj) { - var locEaseList = this._easeList; - if (locEaseList) - locEaseList.length = 0; + if (this._easeList) + this._easeList.length = 0; else - locEaseList = []; + this._easeList = []; for (var i = 0; i < arguments.length; i++) - locEaseList.push(arguments[i]); + this._easeList.push(arguments[i]); return this; }, @@ -413,6 +427,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ reverse:function () { var action = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse()); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -581,6 +596,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ reverse:function () { var action = cc.Repeat.create(this._innerAction.reverse(), this._times); this._cloneDecoration(action); + this._reverseEaseList(action); return action; }, @@ -697,6 +713,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ reverse:function () { var action = cc.RepeatForever.create(this._innerAction.reverse()); this._cloneDecoration(action); + this._reverseEaseList(action); return action; }, @@ -841,6 +858,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ reverse:function () { var action = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse()); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -1068,6 +1086,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ reverse:function () { var action = cc.RotateBy.create(this._duration, -this._angleX, -this._angleY); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -1197,6 +1216,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ reverse:function () { var action = cc.MoveBy.create(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -1452,6 +1472,7 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ reverse:function () { var action = cc.SkewBy.create(this._duration, -this._skewX, -this._skewY); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -1589,6 +1610,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ reverse:function () { var action = cc.JumpBy.create(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -1784,6 +1806,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ cc.pNeg(locConfig[2]) ]; var action = cc.BezierBy.create(this._duration, r); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -1994,6 +2017,7 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ reverse:function () { var action = cc.ScaleBy.create(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); this._cloneDecoration(action); + this._reverseEaseList(action); return action; }, @@ -2095,6 +2119,7 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ reverse:function () { var action = cc.Blink.create(this._duration, this._times); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -2204,6 +2229,7 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ var action = new cc.FadeOut(); action.initWithDuration(this._duration, 0); this._cloneDecoration(action); + this._reverseEaseList(action); return action; }, @@ -2257,6 +2283,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ action._reverseAction = this; action.initWithDuration(this._duration, 255); this._cloneDecoration(action); + this._reverseEaseList(action); return action; }, @@ -2461,6 +2488,7 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ reverse:function () { var action = cc.TintBy.create(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); this._cloneDecoration(action); + this._reverseEaseList(action); return action; } }); @@ -2496,6 +2524,7 @@ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ reverse:function () { var action = cc.DelayTime.create(this._duration); this._cloneDecoration(action); + this._reverseEaseList(action); return action; }, @@ -2769,6 +2798,8 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame()); var action = cc.Animate.create(newAnim); this._cloneDecoration(action); + this._reverseEaseList(action); + return action; }, From 600047b3746865fdbdb9188330c530881f1eadb5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 11 May 2014 16:54:51 +0800 Subject: [PATCH 0087/1564] Issue #3943: Removal map method --- cocos2d/actions/CCActionInterval.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 2357b53e4f..67d2627ae1 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -116,12 +116,11 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ * @private */ _reverseEaseList: function(action){ - if(this._easeList){ - - action._easeList = this._easeList.map(function(_ease){ - return _ease.reverse(); - }); + action._easeList = []; + for(var i=0; i Date: Sun, 11 May 2014 17:59:24 +0800 Subject: [PATCH 0088/1564] Fixed #5097: Make CCTouch return copies of point --- cocos2d/core/event-manager/CCTouch.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/event-manager/CCTouch.js b/cocos2d/core/event-manager/CCTouch.js index e6e6c3a1ee..8e1550462c 100644 --- a/cocos2d/core/event-manager/CCTouch.js +++ b/cocos2d/core/event-manager/CCTouch.js @@ -50,7 +50,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ getLocation:function () { //TODO //return cc.director.convertToGL(this._point); - return this._point; + return {x: this._point.x, y: this._point.y}; }, /** @@ -76,7 +76,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ getPreviousLocation:function () { //TODO //return cc.director.convertToGL(this._prevPoint); - return this._prevPoint; + return {x: this._prevPoint.x, y: this._prevPoint.y}; }, /** @@ -86,7 +86,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ getStartLocation: function() { //TODO //return cc.director.convertToGL(this._startPoint); - return this._startPoint; + return {x: this._startPoint.x, y: this._startPoint.y}; }, /** @@ -102,7 +102,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ * @return {cc.Point} */ getLocationInView: function() { - return this._point; + return {x: this._point.x, y: this._point.y}; }, /** @@ -110,7 +110,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ * @return {cc.Point} */ getPreviousLocationInView: function(){ - return this._prevPoint; + return {x: this._prevPoint.x, y: this._prevPoint.y}; }, /** @@ -118,7 +118,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ * @return {cc.Point} */ getStartLocationInView: function(){ - return this._startPoint; + return {x: this._startPoint.x, y: this._startPoint.y}; }, /** From cbbc3eb4bece260c68b14e647d2fdf32851b48f0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 11 May 2014 18:07:37 +0800 Subject: [PATCH 0089/1564] Issue #3943: Modify update methods, and ease --- cocos2d/actions/CCActionCamera.js | 1 + cocos2d/actions/CCActionCatmullRom.js | 1 + cocos2d/actions/CCActionEase.js | 4 ++-- cocos2d/actions/CCActionInterval.js | 23 ++++++++++++++++++++--- cocos2d/core/CCActionManager.js | 1 + 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 6610acba3b..a7a2132694 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -204,6 +204,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ }, update:function (dt) { + dt = this._computeEaseTime(dt); var r = (this._radius + this._deltaRadius * dt) * cc.Camera.getZEye(); var za = this._radZ + this._radDeltaZ * dt; var xa = this._radX + this._radDeltaX * dt; diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index 45c6bade43..c9cb334ca9 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -189,6 +189,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * * @param {Number} time */ update:function (time) { + time = this._computeEaseTime(time); var p, lt; var ps = this._points; // eg. diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index b1bcf7cee2..68f67d3fac 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -239,7 +239,7 @@ cc.easeIn = function (rate) { return Math.pow(dt, this._rate); }, reverse: function(){ - return cc.easeOut(this._rate); + return cc.easeIn(1 / this._rate); } }; }; @@ -290,7 +290,7 @@ cc.easeOut = function (rate) { return Math.pow(dt, 1 / this._rate); }, reverse: function(){ - return cc.easeIn(this._rate) + return cc.easeOut(1 / this._rate) } }; }; diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 67d2627ae1..31a8869d6a 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -119,7 +119,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ if(this._easeList){ action._easeList = []; for(var i=0; i Date: Mon, 12 May 2014 17:38:04 +0800 Subject: [PATCH 0090/1564] Issue #3943: Fix a bug that no copy of the object properties --- cocos2d/actions/CCActionInterval.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 31a8869d6a..aab0cecf9c 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -108,6 +108,8 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ action._speed = this._speed; action._times = this._times; action._easeList = this._easeList; + action._speedMethod = this._speedMethod; + action._repeatMethod = this._repeatMethod; }, /** From 759e4c69f15118158926e82ec7fbe12909d7ec1f Mon Sep 17 00:00:00 2001 From: XiaoLongHan Date: Tue, 13 May 2014 10:34:02 +0800 Subject: [PATCH 0091/1564] fix cocosbuilder create particle error --- 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 23607fd0d9..835e41ac95 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -364,8 +364,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ this._quadsArrayBuffer = null; } - if (typeof(plistFile) === "number") { - var ton = plistFile; + if (!plistFile || typeof(plistFile) === "number") { + var ton = plistFile || 100; this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); this.initWithTotalParticles(ton); } else if (plistFile) { @@ -2824,4 +2824,4 @@ cc.ParticleSystem.TYPE_RELATIVE = 1; * @constant * @type Number */ -cc.ParticleSystem.TYPE_GROUPED = 2; \ No newline at end of file +cc.ParticleSystem.TYPE_GROUPED = 2; From 453b1d0f36749f0c4ece9349bc08f54737c3f0c6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 May 2014 11:59:33 +0800 Subject: [PATCH 0092/1564] Closed #5157: Fix - LabelAtlas use setString will clear everything in canvas mode --- cocos2d/labels/CCLabelAtlas.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index d423e953e2..37147d8f18 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -182,6 +182,11 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ } }, + _addChildForCanvas: function(child, zOrder, tag){ + child._lateChild = true; + cc.NodeRGBA.prototype.addChild.call(this, child, zOrder, tag); + }, + /** * @function * Atlas generation @@ -210,7 +215,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ } else fontChar.initWithTexture(texture, rect); - this.addChild(fontChar, 0, i); + cc.NodeRGBA.prototype.addChild.call(this, fontChar, 0, i); } else { if (c == 32) { fontChar.init(); @@ -319,7 +324,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ len = locChildren.length; for (var i = 0; i < len; i++) { var node = locChildren[i]; - if (node) + if (node && !node._lateChild) node.visible = false; } } @@ -370,6 +375,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { _p.updateAtlasValues = _p._updateAtlasValuesForCanvas; _p.setString = _p._setStringForCanvas; _p.setOpacity = _p._setOpacityForCanvas; + _p.addChild = _p._addChildForCanvas; } // Override properties From ca4d44d53c59991875673a7398a4b15ad26c84f6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 May 2014 14:30:49 +0800 Subject: [PATCH 0093/1564] Closed #1843: setColor of cc.LabelTTF doesn't work --- cocos2d/core/platform/CCTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index cfa43f5b50..64fb2bbf7e 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -36,7 +36,7 @@ cc.Color = function (r, g, b, a) { this.r = r || 0; this.g = g || 0; this.b = b || 0; - this.a = a || 0; + this.a = a; }; /** From 63c6c100213857c6fdba19a437f119d8473378a3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 May 2014 15:10:10 +0800 Subject: [PATCH 0094/1564] Closed #1843: cc.color default value problems --- cocos2d/core/platform/CCTypesWebGL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index c68d115ee8..f76adc33ec 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -53,7 +53,7 @@ _tmp.WebGLColor = function () { this._rU8[0] = r || 0; this._gU8[0] = g || 0; this._bU8[0] = b || 0; - this._aU8[0] = a || 0; + this._aU8[0] = a || 255; if (a === undefined) { this.a_undefined = true; From 958c5f6f7820b1d798930587a9ff0b69013cf215 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 May 2014 15:27:44 +0800 Subject: [PATCH 0095/1564] Issue #3943: Repeat to accumulate --- cocos2d/actions/CCActionInterval.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index aab0cecf9c..795ca886f5 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -230,7 +230,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ speed: function(speed){ - this._speed = speed; + this._speed *= speed; this._speedMethod = true; return this; @@ -256,7 +256,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ if(isNaN(parseInt(times))){ this._times = 1; }else{ - this._times = times; + this._times *= times; } return this; }, From a4d1af719f690e7fae84712b7e649d81df522267 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 May 2014 15:58:22 +0800 Subject: [PATCH 0096/1564] Issue #3943: Add ActionInterval.setSpeed --- cocos2d/actions/CCActionInterval.js | 32 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 795ca886f5..08568784e5 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -229,20 +229,33 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ * @returns {cc.Action} */ speed: function(speed){ + if(speed <= 0){ + cc.log("The speed parameter error"); + return this; + } + this._speedMethod = true;//Compatible with repeat class, Discard after can be deleted this._speed *= speed; - this._speedMethod = true; - return this; }, /** * @return {Number} */ - getSpeed: function(speed){ + getSpeed: function(){ return this._speed; }, + /** + * + * @param {Number} speed + * @returns {cc.ActionInterval} + */ + setSpeed: function(speed){ + this._speed = speed; + return this; + }, + /** * Repeats an action a number of times. * To repeat an action forever use the CCRepeatForever action. @@ -250,14 +263,13 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ * @returns {cc.ActionInterval} */ repeat: function(times){ - - this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted - times = parseInt(times); - if(isNaN(parseInt(times))){ - this._times = 1; - }else{ - this._times *= times; + times = Math.round(times); + if(times < 1){ + cc.log("The repeat parameter error"); + return this; } + this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted + this._times *= times; return this; }, From d3a6c420752c527809700478a843cc68f60dbf2b Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 13 May 2014 16:49:33 +0800 Subject: [PATCH 0097/1564] Feature #5033: refactor Widget,Layout,Button,Checkbox --- extensions/ccui/base-classes/UIWidget.js | 17 ++++++++++++----- extensions/ccui/layouts/UILayout.js | 16 +++++++++++----- extensions/ccui/uiwidgets/UIButton.js | 16 +++++++++++----- extensions/ccui/uiwidgets/UICheckBox.js | 16 +++++++++++----- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 32adf58d16..c773f7fbb7 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -83,6 +83,15 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _className: "Widget", _flippedX: false, _flippedY: false, + + + /** + * allocates and initializes a UIWidget. + * @constructor + * @example + * // example + * var uiWidget = new ccui.Widget(); + */ ctor: function () { cc.Node.prototype.ctor.call(this); this._enabled = true; @@ -117,6 +126,8 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ this._touchListener = null; this._flippedX = false; this._flippedY = false; + + this.init(); }, /** @@ -1491,11 +1502,7 @@ _p = null; * var uiWidget = ccui.Widget.create(); */ ccui.Widget.create = function () { - var widget = new ccui.Widget(); - if (widget && widget.init()) { - return widget; - } - return null; + return new ccui.Widget(); }; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index ad41615785..4cb9e644ce 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -60,6 +60,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _clippingParent: null, _className: "Layout", _backGroundImageColor: null, + + /** + * allocates and initializes a UILayout. + * @constructor + * @example + * // example + * var uiLayout = new ccui.Layout(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._clippingEnabled = false; @@ -88,6 +96,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingRect = cc.rect(0, 0, 0, 0); this._clippingParent = null; this._backGroundImageColor = cc.color(255, 255, 255, 255); + + this.init(); }, init: function () { if (cc.Node.prototype.init.call(this)) { @@ -1532,11 +1542,7 @@ _p = null; * var uiLayout = ccui.Layout.create(); */ ccui.Layout.create = function () { - var layout = new ccui.Layout(); - if (layout && layout.init()) { - return layout; - } - return null; + return new ccui.Layout(); }; // Constants diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 37b11ed1cf..f189c70026 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -65,6 +65,14 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _pressedTextureLoaded: false, _disabledTextureLoaded: false, _className: "Button", + + /** + * allocates and initializes a UIButton. + * @constructor + * @example + * // example + * var uiButton = new ccui.Button(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._buttonNormalRenderer = null; @@ -95,6 +103,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._normalTextureLoaded = false; this._pressedTextureLoaded = false; this._disabledTextureLoaded = false; + + this.init(); }, init: function () { @@ -821,11 +831,7 @@ _p = null; * var uiButton = ccui.Button.create(); */ ccui.Button.create = function () { - var uiButton = new ccui.Button(); - if (uiButton && uiButton.init()) { - return uiButton; - } - return null; + return new ccui.Button; }; // Constants diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 72462d988d..52fc760c1e 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -50,6 +50,14 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _backGroundDisabledFileName: "", _frontCrossDisabledFileName: "", _className: "CheckBox", + + /** + * allocates and initializes a UICheckBox. + * @constructor + * @example + * // example + * var uiCheckBox = new ccui.CheckBox(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._backGroundBoxRenderer = null; @@ -70,6 +78,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossFileName = ""; this._backGroundDisabledFileName = ""; this._frontCrossDisabledFileName = ""; + + this.init(); }, init: function () { if (ccui.Widget.prototype.init.call(this)) { @@ -572,11 +582,7 @@ _p = null; * var uiCheckBox = ccui.CheckBox.create(); */ ccui.CheckBox.create = function () { - var uiCheckBox = new ccui.CheckBox(); - if (uiCheckBox && uiCheckBox.init()) { - return uiCheckBox; - } - return null; + return new ccui.Checkbox(); }; // Constants From fddc58f1228c3689d08b81d8def2b8775c456918 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 May 2014 17:06:20 +0800 Subject: [PATCH 0098/1564] Issue 3943: To create the mirror method --- CCBoot.js | 75 -------------------------------- cocos2d/actions/CCActionTween.js | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 75 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index de2d47eb8d..17b8076c21 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1468,7 +1468,6 @@ cc.game = { self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW); self._eventShow.setUserData(self); self.onStart(); - self._mirrorMethod(); } }); } else { @@ -1482,7 +1481,6 @@ cc.game = { self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW); self._eventShow.setUserData(self); self.onStart(); - self._mirrorMethod(); clearInterval(self._checkPrepare); } }, 10); @@ -1497,79 +1495,6 @@ cc.game = { }, false); }, - /** - * To create the mirror method - * @private - */ - _mirrorMethod: function(){ - cc.action = cc.Action.create; - cc.speed = cc.Speed.create; - cc.follow = cc.Follow.create; - cc.orbitCamera = cc.OrbitCamera.create; - cc.cardinalSplineTo = cc.CardinalSplineTo.create; - cc.cardinalSplineBy = cc.CardinalSplineBy.create; - cc.catmullRomTo = cc.CatmullRomTo.create; - cc.catmullRomBy = cc.CatmullRomBy.create; -// cc.actionEase = cc.ActionEase.create; -// cc.easeRateAction = cc.EaseRateAction.create; -// cc.easeIn = cc.EaseIn.create; -// cc.easeOut = cc.EaseOut.create; -// cc.easeInOut = cc.EaseInOut.create; -// cc.easeExponentialIn = cc.EaseExponentialIn.create; -// cc.easeExponentialOut = cc.EaseExponentialOut.create; -// cc.easeExponentialInOut = cc.EaseExponentialInOut.create; -// cc.easeSineIn = cc.EaseSineIn.create; -// cc.easeSineOut = cc.EaseSineOut.create; -// cc.easeSineInOut = cc.EaseSineInOut.create; -// cc.easeElastic = cc.EaseElastic.create; -// cc.easeElasticIn = cc.EaseElasticIn.create; -// cc.easeElasticOut = cc.EaseElasticOut.create; -// cc.easeElasticInOut = cc.EaseElasticInOut.create; -// cc.easeBounce = cc.EaseBounce.create; -// cc.easeBounceIn = cc.EaseBounceIn.create; -// cc.easeBounceOut = cc.EaseBounceOut.create; -// cc.easeBounceInOut = cc.EaseBounceInOut.create; -// cc.easeBackIn = cc.EaseBackIn.create; -// cc.easeBackOut = cc.EaseBackOut.create; -// cc.easeBackInOut = cc.EaseBackInOut.create; - cc.show = cc.Show.create; - cc.hide = cc.Hide.create; - cc.toggleVisibility = cc.ToggleVisibility.create; - cc.removeSelf = cc.RemoveSelf.create; - cc.flipX = cc.FlipX.create; - cc.flipY = cc.FlipY.create; - cc.place = cc.Place.create; - cc.callFunc = cc.CallFunc.create; - cc.actionInterval = cc.ActionInterval.create; - cc.sequence = cc.Sequence.create; - cc.repeat = cc.Repeat.create; - cc.repeatForever = cc.RepeatForever.create; - cc.spawn = cc.Spawn.create; - cc.rotateTo = cc.RotateTo.create; - cc.rotateBy = cc.RotateBy.create; - cc.moveBy = cc.MoveBy.create; - cc.moveTo = cc.MoveTo.create; - cc.skewTo = cc.SkewTo.create; - cc.skewBy = cc.SkewBy.create; - cc.jumpBy = cc.JumpBy.create; - cc.jumpTo = cc.JumpTo.create; - cc.bezierBy = cc.BezierBy.create; - cc.bezierTo = cc.BezierTo.create; - cc.scaleTo = cc.ScaleTo.create; - cc.scaleBy = cc.ScaleBy.create; - cc.blink = cc.Blink.create; - cc.fadeTo = cc.FadeTo.create; - cc.fadeIn = cc.FadeIn.create; - cc.fadeOut = cc.FadeOut.create; - cc.tintTo = cc.TintTo.create; - cc.tintBy = cc.TintBy.create; - cc.delayTime = cc.DelayTime.create; - cc.reverseTime = cc.ReverseTime.create; - cc.animate = cc.Animate.create; - cc.targetedAction = cc.TargetedAction.create; - cc.actionTween = cc.ActionTween.create; - }, - /** * Init config. * @param cb diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index a4c04730f4..90283f9bb4 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -131,3 +131,48 @@ cc.ActionTween.create = function (duration, key, from, to) { return ret; return null; }; + +cc.action = cc.Action.create; +cc.speed = cc.Speed.create; +cc.follow = cc.Follow.create; +cc.orbitCamera = cc.OrbitCamera.create; +cc.cardinalSplineTo = cc.CardinalSplineTo.create; +cc.cardinalSplineBy = cc.CardinalSplineBy.create; +cc.catmullRomTo = cc.CatmullRomTo.create; +cc.catmullRomBy = cc.CatmullRomBy.create; +cc.show = cc.Show.create; +cc.hide = cc.Hide.create; +cc.toggleVisibility = cc.ToggleVisibility.create; +cc.removeSelf = cc.RemoveSelf.create; +cc.flipX = cc.FlipX.create; +cc.flipY = cc.FlipY.create; +cc.place = cc.Place.create; +cc.callFunc = cc.CallFunc.create; +cc.actionInterval = cc.ActionInterval.create; +cc.sequence = cc.Sequence.create; +cc.repeat = cc.Repeat.create; +cc.repeatForever = cc.RepeatForever.create; +cc.spawn = cc.Spawn.create; +cc.rotateTo = cc.RotateTo.create; +cc.rotateBy = cc.RotateBy.create; +cc.moveBy = cc.MoveBy.create; +cc.moveTo = cc.MoveTo.create; +cc.skewTo = cc.SkewTo.create; +cc.skewBy = cc.SkewBy.create; +cc.jumpBy = cc.JumpBy.create; +cc.jumpTo = cc.JumpTo.create; +cc.bezierBy = cc.BezierBy.create; +cc.bezierTo = cc.BezierTo.create; +cc.scaleTo = cc.ScaleTo.create; +cc.scaleBy = cc.ScaleBy.create; +cc.blink = cc.Blink.create; +cc.fadeTo = cc.FadeTo.create; +cc.fadeIn = cc.FadeIn.create; +cc.fadeOut = cc.FadeOut.create; +cc.tintTo = cc.TintTo.create; +cc.tintBy = cc.TintBy.create; +cc.delayTime = cc.DelayTime.create; +cc.reverseTime = cc.ReverseTime.create; +cc.animate = cc.Animate.create; +cc.targetedAction = cc.TargetedAction.create; +cc.actionTween = cc.ActionTween.create; \ No newline at end of file From a22b84dfa2a0073a49a931afbbbc6f3a3b9faff4 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 14 May 2014 13:49:47 +0800 Subject: [PATCH 0099/1564] Feature #5033: refactor ImageView,LoadingBar,RichText,Slider,Text,TextAtlas,TextBMFont,TextField --- extensions/ccui/uiwidgets/UIImageView.js | 16 +++++++++++----- extensions/ccui/uiwidgets/UILoadingBar.js | 16 +++++++++++----- extensions/ccui/uiwidgets/UIRichText.js | 14 +++++++++++--- extensions/ccui/uiwidgets/UISlider.js | 15 ++++++++++----- extensions/ccui/uiwidgets/UIText.js | 16 +++++++++++----- extensions/ccui/uiwidgets/UITextAtlas.js | 16 +++++++++++----- extensions/ccui/uiwidgets/UITextBMFont.js | 16 +++++++++++----- extensions/ccui/uiwidgets/UITextField.js | 16 +++++++++++----- 8 files changed, 87 insertions(+), 38 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index d079ee4516..d253c98a9a 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -37,6 +37,14 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ _imageTexType: null, _imageTextureSize: null, _className:"ImageView", + + /** + * allocates and initializes a UIImageView. + * @constructor + * @example + * // example + * var uiImageView = new ccui.ImageView; + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._scale9Enabled = false; @@ -46,6 +54,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._textureFile = ""; this._imageTexType = ccui.Widget.LOCAL_TEXTURE; this._imageTextureSize = cc.size(this._size.width, this._size.height); + + this.init(); }, initRenderer: function () { @@ -320,11 +330,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * var uiImageView = ccui.ImageView.create(); */ ccui.ImageView.create = function () { - var uiImageView = new ccui.ImageView(); - if (uiImageView && uiImageView.init()) { - return uiImageView; - } - return null; + return new ccui.ImageView(); }; // Constants diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index d85be7669b..cace9e9439 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -44,6 +44,14 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _textureFile: "", _isTextureLoaded: false, _className: "LoadingBar", + + /** + * allocates and initializes a UILoadingBar. + * @constructor + * @example + * // example + * var uiLoadingBar = new ccui.LoadingBar; + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._barType = ccui.LoadingBar.TYPE_LEFT; @@ -56,6 +64,8 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._prevIgnoreSize = true; this._capInsets = cc.rect(0, 0, 0, 0); this._textureFile = ""; + + this.init(); }, initRenderer: function () { @@ -404,11 +414,7 @@ _p = null; * var uiLoadingBar = ccui.LoadingBar.create(); */ ccui.LoadingBar.create = function () { - var uiLoadingBar = new ccui.LoadingBar(); - if (uiLoadingBar && uiLoadingBar.init()) { - return uiLoadingBar; - } - return null; + return new ccui.LoadingBar(); }; // Constants diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 06427a79cd..161a8ef15f 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -166,6 +166,12 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ _verticalSpace: 0, _elementRenderersContainer: null, + /** + * create a rich text + * @constructor + * @example + * var uiRichText = new ccui.RichTex(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._formatTextDirty = false; @@ -174,6 +180,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._leftSpaceWidth = 0; this._verticalSpace = 0; this._elementRenderersContainer = null; + + this.init(); }, initRenderer: function () { @@ -451,11 +459,11 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ /** * create a rich text * @returns {RichText} + * @example + * var uiRichText = ccui.RichTex.create(); */ ccui.RichText.create = function(){ - var richText = new ccui.RichText(); - richText.init(); - return richText; + return new ccui.RichText(); }; // Constants diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index e3693bdfb7..65ce7f6789 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -58,6 +58,13 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _ballDTexType: null, _isTextureLoaded: false, _className: "Slider", + /** + * allocates and initializes a UISlider. + * @constructor + * @example + * // example + * var uiSlider = new ccui.Slider(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._barRenderer = null; @@ -86,6 +93,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballPTexType = ccui.Widget.LOCAL_TEXTURE; this._ballDTexType = ccui.Widget.LOCAL_TEXTURE; this._isTextureLoaded = false; + + this.init(); }, init: function () { @@ -642,11 +651,7 @@ _p = null; * var uiSlider = ccui.Slider.create(); */ ccui.Slider.create = function () { - var uiSlider = new ccui.Slider(); - if (uiSlider && uiSlider.init()) { - return uiSlider; - } - return null; + return new ccui.Slider(); }; // Constant diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 6c33d49a02..a7f1f35a70 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -51,6 +51,14 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ _textVerticalAlignment: 0, _textHorizontalAlignment: 0, _className: "Text", + + /** + * allocates and initializes a UILabel. + * @constructor + * @example + * // example + * var uiLabel = new ccui.Text(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this.touchScaleEnabled = false; @@ -63,6 +71,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._textAreaSize = cc.size(0, 0); this._textVerticalAlignment = 0; this._textHorizontalAlignment = 0; + + this.init(); }, init: function () { @@ -414,11 +424,7 @@ _p = null; * var uiLabel = ccui.Text.create(); */ ccui.Text.create = function () { - var uiLabel = new ccui.Text(); - if (uiLabel && uiLabel.init()) { - return uiLabel; - } - return null; + return new ccui.Text(); }; ccui.Text.RENDERER_ZORDER = -1; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 887c6084f9..dd578c78c5 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -38,9 +38,19 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ _itemHeight: 0, _startCharMap: "", _className: "TextAtlas", + + /** + * allocates and initializes a UILabelAtlas. + * @constructor + * @example + * // example + * var uiLabelAtlas = new ccui.TextAtlas(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._labelAtlasRenderer = null; + + this.init(); }, initRenderer: function () { @@ -205,11 +215,7 @@ _p = null; * var uiLabelAtlas = ccui.TextAtlas.create(); */ ccui.TextAtlas.create = function () { - var uiLabelAtlas = new ccui.TextAtlas(); - if (uiLabelAtlas && uiLabelAtlas.init()) { - return uiLabelAtlas; - } - return null; + return new ccui.TextAtlas(); }; // Constants diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index ef8d365a81..dcdd35512b 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -36,10 +36,20 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ _fntFileName: "", _stringValue: "", _className: "TextBMFont", + + /** + * allocates and initializes a UILabelBMFont. + * @constructor + * @example + * // example + * var uiLabelBMFont = new ccui.TextBMFont(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._labelBMFontRenderer = null; this._fileHasInit = false; + + this.init() }, initRenderer: function () { this._labelBMFontRenderer = cc.LabelBMFont.create(); @@ -203,11 +213,7 @@ _p = null; * var uiLabelBMFont = ccui.TextBMFont.create(); */ ccui.TextBMFont.create = function () { - var uiLabelBMFont = new ccui.TextBMFont(); - if (uiLabelBMFont && uiLabelBMFont.init()) { - return uiLabelBMFont; - } - return null; + return new ccui.TextBMFont(); }; // Constants diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 4576fc4ef2..63fcf2ad64 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -267,6 +267,14 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _insertTextSelector: null, _deleteBackwardSelector: null, _passwordStyleText: "", + + /** + * allocates and initializes a UITextField. + * @constructor + * @example + * // example + * var uiTextField = new ccui.TextField(); + */ ctor: function () { ccui.Widget.prototype.ctor.call(this); this._textFieldRender = null; @@ -284,6 +292,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._detachWithIMESelector = null; this._insertTextSelector = null; this._deleteBackwardSelector = null; + + this.init(); }, onEnter: function () { @@ -767,11 +777,7 @@ _p = null; * var uiTextField = ccui.TextField.create(); */ ccui.TextField.create = function () { - var uiTextField = new ccui.TextField(); - if (uiTextField && uiTextField.init()) { - return uiTextField; - } - return null; + return new ccui.TextField(); }; // Constants From ecdffd9bfa33e3cb5f2e7deac0bed0bf3f213eff Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 14 May 2014 14:08:35 +0800 Subject: [PATCH 0100/1564] Feature #5033: refactor ListView,ScrollView,PageView --- .../uiwidgets/scroll-widget/UIListView.js | 22 ++++++++++++++----- .../uiwidgets/scroll-widget/UIPageView.js | 15 ++++++++----- .../uiwidgets/scroll-widget/UIScrollView.js | 14 +++++++----- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 19082c880d..72ba5d74d3 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -38,6 +38,13 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ _curSelectedIndex: 0, _refreshViewDirty: true, _className:"ListView", + /** + * allocates and initializes a UIListView. + * @constructor + * @example + * // example + * var uiPageView = new ccui.ListView(); + */ ctor: function () { ccui.ScrollView.prototype.ctor.call(this); this._model = null; @@ -48,6 +55,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._listViewEventSelector = null; this._curSelectedIndex = 0; this._refreshViewDirty = true; + + this.init(); }, init: function () { @@ -455,12 +464,15 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } }); +/** + * allocates and initializes a UIListView. + * @constructs + * @example + * // example + * var uiPageView = ccui.ListView.create(); + */ ccui.ListView.create = function () { - var uiListView = new ccui.ListView(); - if (uiListView && uiListView.init()) { - return uiListView; - } - return null; + return new ccui.ListView(); }; // Constants diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index d60f9c4ea9..9b7434f6c8 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -47,6 +47,13 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _pageViewEventListener: null, _pageViewEventSelector: null, _className:"PageView", + /** + * allocates and initializes a UIPageView. + * @constructor + * @example + * // example + * var uiPageView = new ccui.PageView(); + */ ctor: function () { ccui.Layout.prototype.ctor.call(this); this._curPageIdx = 0; @@ -66,6 +73,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._childFocusCancelOffset = 5; this._pageViewEventListener = null; this._pageViewEventSelector = null; + + this.init(); }, init: function () { @@ -592,11 +601,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * var uiPageView = ccui.PageView.create(); */ ccui.PageView.create = function () { - var uiPageView = new ccui.PageView(); - if (uiPageView && uiPageView.init()) { - return uiPageView; - } - return null; + return new ccui.PageView(); }; // Constants diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 33c6a3077c..61c074ce3a 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -73,6 +73,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _scrollViewEventListener: null, _scrollViewEventSelector: null, _className: "ScrollView", + /** + * allocates and initializes a UIScrollView. + * @constructor + * @example + * // example + * var uiScrollView = new ccui.ScrollView(); + */ ctor: function () { ccui.Layout.prototype.ctor.call(this); this._innerContainer = null; @@ -112,6 +119,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.inertiaScrollEnabled = true; this._scrollViewEventListener = null; this._scrollViewEventSelector = null; + this.init(); }, init: function () { @@ -1635,11 +1643,7 @@ _p = null; * var uiScrollView = ccui.ScrollView.create(); */ ccui.ScrollView.create = function () { - var uiScrollView = new ccui.ScrollView(); - if (uiScrollView && uiScrollView.init()) { - return uiScrollView; - } - return null; + return new ccui.ScrollView(); }; // Constants From 7b0f906292b9013a6fd12563c268dcd4ee148df9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 14 May 2014 16:48:32 +0800 Subject: [PATCH 0101/1564] Fixed #5177: use `tag` to setup tag value in ccui.Widget.getChildByTag --- extensions/ccui/base-classes/UIWidget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 32adf58d16..e15ac909fa 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -203,7 +203,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ if (__children != null) { for (var i = 0; i < __children.length; i++) { var node = __children[i]; - if (node && node._tag == tag) + if (node && node.tag == tag) return node; } } From 17d6468d13e689e9981b3345adaab2513cb1949c Mon Sep 17 00:00:00 2001 From: NatWeiss Date: Wed, 14 May 2014 11:58:19 -0700 Subject: [PATCH 0102/1564] Fixes two WebGL errors when minified Two WebGL-specific files were missing which cause undefined function errors when trying to access `_tmp.WebGLColor` and `_tmp.WebGLLabelTTF` when minified. --- tools/build.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/build.xml b/tools/build.xml index 4b76a9fec7..ec1450e26e 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -21,6 +21,7 @@ + @@ -65,6 +66,7 @@ + @@ -289,4 +291,4 @@
- \ No newline at end of file + From cff9d75915190da7400d51a612074cc58787d11f Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 15 May 2014 14:15:21 +0800 Subject: [PATCH 0103/1564] Feature #5033: Make ccui classes extendable in H5 and JSB --- extensions/ccui/base-classes/UIWidget.js | 29 +-------------- extensions/ccui/layouts/UILayout.js | 24 ++---------- extensions/ccui/uiwidgets/UIButton.js | 34 +++-------------- extensions/ccui/uiwidgets/UICheckBox.js | 32 +++------------- extensions/ccui/uiwidgets/UIImageView.js | 11 +----- extensions/ccui/uiwidgets/UILoadingBar.js | 13 +------ extensions/ccui/uiwidgets/UISlider.js | 37 +++---------------- extensions/ccui/uiwidgets/UIText.js | 19 ++-------- extensions/ccui/uiwidgets/UITextAtlas.js | 3 -- extensions/ccui/uiwidgets/UITextBMFont.js | 4 -- extensions/ccui/uiwidgets/UITextField.js | 17 --------- .../uiwidgets/scroll-widget/UIPageView.js | 17 +++++---- 12 files changed, 40 insertions(+), 200 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index c773f7fbb7..62dced8776 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -64,7 +64,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _name: "default", _widgetType: null, _actionTag: 0, - _size: null, + _size: cc.size(0, 0), _customSize: null, _layoutParameterDictionary: null, _ignoreSize: false, @@ -83,50 +83,23 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _className: "Widget", _flippedX: false, _flippedY: false, - - - /** - * allocates and initializes a UIWidget. - * @constructor - * @example - * // example - * var uiWidget = new ccui.Widget(); - */ ctor: function () { cc.Node.prototype.ctor.call(this); - this._enabled = true; - this._bright = true; - this._touchEnabled = false; - this._touchPassedEnabled = false; - 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._touchEventListener = null; - this._touchEventSelector = null; - this._name = "default"; this._widgetType = ccui.Widget.TYPE_WIDGET; - this._actionTag = 0; this._size = cc.size(0, 0); this._customSize = cc.size(0, 0); this._layoutParameterDictionary = {}; - this._ignoreSize = false; this._widgetChildren = []; - this._affectByClipping = false; this._sizeType = ccui.Widget.SIZE_ABSOLUTE; this._sizePercent = cc.p(0, 0); this.positionType = ccui.Widget.POSITION_ABSOLUTE; this._positionPercent = cc.p(0, 0); - this._reorderWidgetChildDirty = false; - this._hitted = false; this._nodes = []; this._color = cc.color(255, 255, 255, 255); - this._touchListener = null; - this._flippedX = false; - this._flippedY = false; - this.init(); }, diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 4cb9e644ce..a51709054c 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -40,18 +40,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _backGroundImageFileName: null, _backGroundImageCapInsets: null, _colorType: null, - _bgImageTexType: null, + _bgImageTexType: ccui.Widget.LOCAL_TEXTURE, _colorRender: null, _gradientRender: null, _color: null, _startColor: null, _endColor: null, _alongVector: null, - _opacity: null, + _opacity: 255, _backGroundImageTextureSize: null, _layoutType: null, - _doLayoutDirty: false, - _clippingRectDirty: false, + _doLayoutDirty: true, + _clippingRectDirty: true, _clippingType: null, _clippingStencil: null, _handleScissor: false, @@ -70,34 +70,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ ctor: function () { ccui.Widget.prototype.ctor.call(this); - this._clippingEnabled = false; - this._backGroundScale9Enabled = false; - this._backGroundImage = null; - this._backGroundImageFileName = ""; this._backGroundImageCapInsets = cc.rect(0, 0, 0, 0); this._colorType = ccui.Layout.BG_COLOR_NONE; - this._bgImageTexType = ccui.Widget.LOCAL_TEXTURE; - this._colorRender = null; - this._gradientRender = null; this._color = cc.color(255, 255, 255, 255); this._startColor = cc.color(255, 255, 255, 255); this._endColor = cc.color(255, 255, 255, 255); this._alongVector = cc.p(0, -1); - this._opacity = 255; this._backGroundImageTextureSize = cc.size(0, 0); this._layoutType = ccui.Layout.ABSOLUTE; this._widgetType = ccui.Widget.TYPE_CONTAINER; - this._doLayoutDirty = true; - this._clippingRectDirty = true; this._clippingType = ccui.Layout.CLIPPING_STENCIL; - this._clippingStencil = null; - this._handleScissor = false; - this._scissorRectDirty = false; this._clippingRect = cc.rect(0, 0, 0, 0); - this._clippingParent = null; this._backGroundImageColor = cc.color(255, 255, 255, 255); - - this.init(); }, init: function () { if (cc.Node.prototype.init.call(this)) { diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index f189c70026..858c167347 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -49,14 +49,14 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _capInsetsNormal: null, _capInsetsPressed: null, _capInsetsDisabled: null, - _normalTexType: null, - _pressedTexType: null, - _disabledTexType: null, + _normalTexType: ccui.Widget.LOCAL_TEXTURE, + _pressedTexType: ccui.Widget.LOCAL_TEXTURE, + _disabledTexType: ccui.Widget.LOCAL_TEXTURE, _normalTextureSize: null, _pressedTextureSize: null, _disabledTextureSize: null, pressedActionEnabled: false, - _titleColor: null, + _titleColor: cc.color.WHITE, _normalTextureScaleXInSize: 1, _normalTextureScaleYInSize: 1, _pressedTextureScaleXInSize: 1, @@ -74,37 +74,15 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * var uiButton = new ccui.Button(); */ ctor: function () { - ccui.Widget.prototype.ctor.call(this); - this._buttonNormalRenderer = null; - this._buttonClickedRenderer = null; - this._buttonDisableRenderer = null; - this._titleRenderer = null; - this._normalFileName = ""; - this._clickedFileName = ""; - this._disabledFileName = ""; - this._prevIgnoreSize = true; - this._scale9Enabled = false; this._capInsetsNormal = cc.rect(0, 0, 0, 0); this._capInsetsPressed = cc.rect(0, 0, 0, 0); this._capInsetsDisabled = cc.rect(0, 0, 0, 0); - this._normalTexType = ccui.Widget.LOCAL_TEXTURE; - this._pressedTexType = ccui.Widget.LOCAL_TEXTURE; - this._disabledTexType = ccui.Widget.LOCAL_TEXTURE; var locSize = this._size; this._normalTextureSize = cc.size(locSize.width, locSize.height); this._pressedTextureSize = cc.size(locSize.width, locSize.height); this._disabledTextureSize = cc.size(locSize.width, locSize.height); - this.pressedActionEnabled = false; - this._titleColor = cc.color.WHITE; - this._normalTextureScaleXInSize = 1; - this._normalTextureScaleYInSize = 1; - this._pressedTextureScaleXInSize = 1; - this._pressedTextureScaleYInSize = 1; - this._normalTextureLoaded = false; - this._pressedTextureLoaded = false; - this._disabledTextureLoaded = false; - - this.init(); + + ccui.Widget.prototype.ctor.call(this); }, init: function () { diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 52fc760c1e..410b8c5946 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -39,11 +39,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _isSelected: true, _checkBoxEventListener: null, _checkBoxEventSelector: null, - _backGroundTexType: null, - _backGroundSelectedTexType: null, - _frontCrossTexType: null, - _backGroundDisabledTexType: null, - _frontCrossDisabledTexType: null, + _backGroundTexType: ccui.Widget.LOCAL_TEXTURE, + _backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE, + _frontCrossTexType: ccui.Widget.LOCAL_TEXTURE, + _backGroundDisabledTexType: ccui.Widget.LOCAL_TEXTURE, + _frontCrossDisabledTexType: ccui.Widget.LOCAL_TEXTURE, _backGroundFileName: "", _backGroundSelectedFileName: "", _frontCrossFileName: "", @@ -60,26 +60,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ */ ctor: function () { ccui.Widget.prototype.ctor.call(this); - this._backGroundBoxRenderer = null; - this._backGroundSelectedBoxRenderer = null; - this._frontCrossRenderer = null; - this._backGroundBoxDisabledRenderer = null; - this._frontCrossDisabledRenderer = null; - this._isSelected = true; - this._checkBoxEventListener = null; - this._checkBoxEventSelector = null; - this._backGroundTexType = ccui.Widget.LOCAL_TEXTURE; - this._backGroundSelectedTexType = ccui.Widget.LOCAL_TEXTURE; - this._frontCrossTexType = ccui.Widget.LOCAL_TEXTURE; - this._backGroundDisabledTexType = ccui.Widget.LOCAL_TEXTURE; - this._frontCrossDisabledTexType = ccui.Widget.LOCAL_TEXTURE; - this._backGroundFileName = ""; - this._backGroundSelectedFileName = ""; - this._frontCrossFileName = ""; - this._backGroundDisabledFileName = ""; - this._frontCrossDisabledFileName = ""; - - this.init(); }, init: function () { if (ccui.Widget.prototype.init.call(this)) { @@ -582,7 +562,7 @@ _p = null; * var uiCheckBox = ccui.CheckBox.create(); */ ccui.CheckBox.create = function () { - return new ccui.Checkbox(); + return new ccui.CheckBox(); }; // Constants diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index d253c98a9a..3610e8682e 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -34,7 +34,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ _capInsets: null, _imageRenderer: null, _textureFile: "", - _imageTexType: null, + _imageTexType: ccui.Widget.LOCAL_TEXTURE, _imageTextureSize: null, _className:"ImageView", @@ -46,16 +46,9 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * var uiImageView = new ccui.ImageView; */ ctor: function () { - ccui.Widget.prototype.ctor.call(this); - this._scale9Enabled = false; - this._prevIgnoreSize = true; this._capInsets = cc.rect(0,0,0,0); - this._imageRenderer = null; - this._textureFile = ""; - this._imageTexType = ccui.Widget.LOCAL_TEXTURE; this._imageTextureSize = cc.size(this._size.width, this._size.height); - - this.init(); + ccui.Widget.prototype.ctor.call(this); }, initRenderer: function () { diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index cace9e9439..3d5af75ecf 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -36,7 +36,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _percent: 100, _totalLength: 0, _barRenderer: null, - _renderBarTexType: null, + _renderBarTexType: ccui.Widget.LOCAL_TEXTURE, _barRendererTextureSize: null, _scale9Enabled: false, _prevIgnoreSize: true, @@ -53,19 +53,10 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ * var uiLoadingBar = new ccui.LoadingBar; */ ctor: function () { - ccui.Widget.prototype.ctor.call(this); this._barType = ccui.LoadingBar.TYPE_LEFT; - this._percent = 100; - this._totalLength = 0; - this._barRenderer = null; - this._renderBarTexType = ccui.Widget.LOCAL_TEXTURE; this._barRendererTextureSize = cc.size(0, 0); - this._scale9Enabled = false; - this._prevIgnoreSize = true; this._capInsets = cc.rect(0, 0, 0, 0); - this._textureFile = ""; - - this.init(); + ccui.Widget.prototype.ctor.call(this); }, initRenderer: function () { diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 65ce7f6789..9b78ca4cdd 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -51,11 +51,11 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _capInsetsProgressBarRenderer: null, _sliderEventListener: null, _sliderEventSelector: null, - _barTexType: null, - _progressBarTexType: null, - _ballNTexType: null, - _ballPTexType: null, - _ballDTexType: null, + _barTexType: ccui.Widget.LOCAL_TEXTURE, + _progressBarTexType: ccui.Widget.LOCAL_TEXTURE, + _ballNTexType: ccui.Widget.LOCAL_TEXTURE, + _ballPTexType: ccui.Widget.LOCAL_TEXTURE, + _ballDTexType: ccui.Widget.LOCAL_TEXTURE, _isTextureLoaded: false, _className: "Slider", /** @@ -66,35 +66,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * var uiSlider = new ccui.Slider(); */ ctor: function () { - ccui.Widget.prototype.ctor.call(this); - this._barRenderer = null; - this._progressBarRenderer = null; this._progressBarTextureSize = cc.size(0, 0); - this._slidBallNormalRenderer = null; - this._slidBallPressedRenderer = null; - this._slidBallDisabledRenderer = null; - this._slidBallRenderer = null; - this._barLength = 0; - this._percent = 0; - this._scale9Enabled = false; - this._prevIgnoreSize = true; - this._textureFile = ""; - this._progressBarTextureFile = ""; - this._slidBallNormalTextureFile = ""; - this._slidBallPressedTextureFile = ""; - this._slidBallDisabledTextureFile = ""; this._capInsetsBarRenderer = cc.rect(0, 0, 0, 0); this._capInsetsProgressBarRenderer = cc.rect(0, 0, 0, 0); - this._sliderEventListener = null; - this._sliderEventSelector = null; - this._barTexType = ccui.Widget.LOCAL_TEXTURE; - this._progressBarTexType = ccui.Widget.LOCAL_TEXTURE; - this._ballNTexType = ccui.Widget.LOCAL_TEXTURE; - this._ballPTexType = ccui.Widget.LOCAL_TEXTURE; - this._ballDTexType = ccui.Widget.LOCAL_TEXTURE; - this._isTextureLoaded = false; - - this.init(); + ccui.Widget.prototype.ctor.call(this); }, init: function () { diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index a7f1f35a70..ee3532ccb1 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -43,9 +43,9 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ touchScaleEnabled: false, _normalScaleValueX: 0, _normalScaleValueY: 0, - _fontName: "", - _fontSize: 0, - _onSelectedScaleOffset: 0, + _fontName: "Thonburi", + _fontSize: 10, + _onSelectedScaleOffset:0.5, _labelRenderer: "", _textAreaSize: null, _textVerticalAlignment: 0, @@ -60,19 +60,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * var uiLabel = new ccui.Text(); */ ctor: function () { - ccui.Widget.prototype.ctor.call(this); - this.touchScaleEnabled = false; - this._normalScaleValueX = 0; - this._normalScaleValueY = 0; - this._fontName = "Thonburi"; - this._fontSize = 10; - this._onSelectedScaleOffset = 0.5; - this._labelRenderer = ""; this._textAreaSize = cc.size(0, 0); - this._textVerticalAlignment = 0; - this._textHorizontalAlignment = 0; - - this.init(); + ccui.Widget.prototype.ctor.call(this); }, init: function () { diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index dd578c78c5..3e31b4e7c7 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -48,9 +48,6 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ */ ctor: function () { ccui.Widget.prototype.ctor.call(this); - this._labelAtlasRenderer = null; - - this.init(); }, initRenderer: function () { diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index dcdd35512b..3b22677e88 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -46,10 +46,6 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ */ ctor: function () { ccui.Widget.prototype.ctor.call(this); - this._labelBMFontRenderer = null; - this._fileHasInit = false; - - this.init() }, initRenderer: function () { this._labelBMFontRenderer = cc.LabelBMFont.create(); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 63fcf2ad64..ff8d27cc39 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -277,23 +277,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ */ ctor: function () { ccui.Widget.prototype.ctor.call(this); - this._textFieldRender = null; - this._touchWidth = 0; - this._touchHeight = 0; - this._useTouchArea = false; - - this._textFieldEventListener = null; - this._textFieldEventSelector = null; - this._attachWithIMEListener = null; - this._detachWithIMEListener = null; - this._insertTextListener = null; - this._deleteBackwardListener = null; - this._attachWithIMESelector = null; - this._detachWithIMESelector = null; - this._insertTextSelector = null; - this._deleteBackwardSelector = null; - - this.init(); }, onEnter: function () { diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 9b7434f6c8..d3a5ea775e 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -79,7 +79,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ init: function () { if (ccui.Layout.prototype.init.call(this)) { - this._pages = []; this.setClippingEnabled(true); this.setTouchEnabled(true); return true; @@ -280,14 +279,16 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, updateChildrenSize: function () { - if (!this._pages.length <= 0) { - return; - } + if(this._pages){ + if (!this._pages.length <= 0) { + return; + } - var selfSize = this.getSize(); - for (var i = 0; i < this._pages.length; i++) { - var page = this._pages[i]; - page.setSize(selfSize); + var selfSize = this.getSize(); + for (var i = 0; i < this._pages.length; i++) { + var page = this._pages[i]; + page.setSize(selfSize); + } } }, From 3c25ec6f0f4a898a22d784ee67fb56b9b949f4a1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 15 May 2014 18:09:31 +0800 Subject: [PATCH 0104/1564] Issue #5096: Performance Optimization of cc.Node.sortAllChildren --- cocos2d/core/base-nodes/CCNode.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index d50e6586d2..d77cce0b1c 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1318,22 +1318,25 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ sortAllChildren: function () { if (this._reorderChildDirty) { var _children = this._children; - var i, j, length = _children.length, tempChild; // insertion sort - for (i = 0; i < length; i++) { - var tempItem = _children[i]; + var len = _children.length, i, j, tmp; + for(i=1; i= 0 && ( tempItem._localZOrder < tempChild._localZOrder || - ( tempItem._localZOrder == tempChild._localZOrder && tempItem.arrivalOrder < tempChild.arrivalOrder ))) { - _children[j + 1] = tempChild; - j = j - 1; - tempChild = _children[j]; + while(j >= 0){ + if(tmp._localZOrder < _children[j]._localZOrder){ + _children[j+1] = _children[j]; + }else if(tmp._localZOrder === _children[j]._localZOrder && tmp.arrivalOrder < _children[j].arrivalOrder){ + _children[j+1] = _children[j]; + }else{ + break; + } + j--; } - _children[j + 1] = tempItem; + _children[j+1] = tmp; } //don't need to check children recursively, that's done in visit of each child From 62869b39dcc75c31fbdc8865da4b29a5b567e3e4 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Thu, 15 May 2014 15:53:49 +0300 Subject: [PATCH 0105/1564] fixed fontloader's types --- cocos2d/core/platform/CCLoaders.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index 362b8074c4..c64a6ee3dd 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -73,10 +73,10 @@ cc.loader.register(["plist"], cc._plistLoader); cc._fontLoader = { TYPE : { - "eot" : "embedded-opentype", - "ttf" : "truetype", - "woff" : "woff", - "svg" : "svg" + ".eot" : "embedded-opentype", + ".ttf" : "truetype", + ".woff" : "woff", + ".svg" : "svg" }, _loadFont : function(name, srcs, type){ var doc = document, path = cc.path, TYPE = this.TYPE, fontStyle = cc.newElement("style"); From fbab2abb169949428db77021bae221b77c5084c7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 16 May 2014 10:56:45 +0800 Subject: [PATCH 0106/1564] Issue #5214: Add checking the file and moving log text --- CCBoot.js | 2 +- CCDebugger.js | 12 +++++++-- cocos2d/core/CCDirector.js | 5 ++-- cocos2d/core/CCDirectorWebGL.js | 2 +- .../base-nodes/BaseNodesPropertyDefine.js | 4 +-- cocos2d/core/base-nodes/BaseNodesWebGL.js | 2 +- cocos2d/core/base-nodes/CCAtlasNode.js | 6 ++--- cocos2d/core/base-nodes/CCNode.js | 15 ++++++----- cocos2d/core/event-manager/CCEventManager.js | 4 +-- cocos2d/core/labelttf/CCLabelTTF.js | 11 ++++---- .../core/labelttf/LabelTTFPropertyDefine.js | 2 +- cocos2d/core/labelttf/LabelTTFWebGL.js | 2 +- cocos2d/core/layers/CCLayer.js | 26 ++++++++++++------- cocos2d/core/layers/CCLayerPropertyDefine.js | 6 ++--- cocos2d/core/layers/CCLayerWebGL.js | 4 +-- cocos2d/core/platform/CCCommon.js | 2 +- cocos2d/core/platform/CCMacro.js | 2 +- cocos2d/core/platform/CCTypes.js | 10 ++++--- .../core/platform/CCTypesPropertyDefine.js | 2 +- cocos2d/core/platform/CCTypesWebGL.js | 4 +-- cocos2d/core/sprites/CCSprite.js | 15 ++++++----- cocos2d/core/sprites/CCSpriteFrame.js | 4 +-- cocos2d/core/sprites/SpritesPropertyDefine.js | 2 +- cocos2d/core/sprites/SpritesWebGL.js | 6 ++--- cocos2d/core/textures/CCTexture2D.js | 10 ++++--- cocos2d/core/textures/CCTextureAtlas.js | 10 ++++--- cocos2d/core/textures/CCTextureCache.js | 7 ++--- .../core/textures/TexturesPropertyDefine.js | 4 +-- cocos2d/core/textures/TexturesWebGL.js | 8 +++--- 29 files changed, 109 insertions(+), 80 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 17b8076c21..e85ef5d2b7 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -24,7 +24,7 @@ ****************************************************************************/ var cc = cc || {}; -var _tmp = _tmp || {}; +cc._tmp = cc._tmp || {}; cc._LogInfos = {}; /** @expose */ diff --git a/CCDebugger.js b/CCDebugger.js index 54bbe9a595..632fbe4601 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -73,8 +73,9 @@ cc._LogInfos = { Node_schedule_2: "interval must be positive", Node_initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.", - AtlasNode_updateAtlasValues: "Shall be overridden in subclasses", + AtlasNode_updateAtlasValues: "cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses", AtlasNode_initWithTileFile: "", + AtlasNode__initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.", _EventListenerKeyboard_checkAvailable: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!", _EventListenerTouchOneByOne_checkAvailable: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!", @@ -208,8 +209,15 @@ cc._LogInfos = { Texture2D_bitsPerPixelForFormat: "bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format", Texture2D__initPremultipliedATextureWithImage: "cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha", Texture2D_addImage_2: "cc.Texture.addImage(): path should be non-null", - Texture2D_initWithData: "NSInternalInconsistencyException" + Texture2D_initWithData: "NSInternalInconsistencyException", + MissingFile: "Missing file: %s", + radiansToDegress: "cc.radiansToDegress() should be called cc.radiansToDegrees()", + RectWidth: "Rect width exceeds maximum margin: %s", + RectHeight: "Rect height exceeds maximum margin: %s", + + EventManager__updateListeners: "If program goes here, there should be event in dispatch.", + EventManager__updateListeners_2: "_inDispatch should be 1 here." }; //+++++++++++++++++++++++++something about log start++++++++++++++++++++++++++++ diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 859a14a916..ab859e9b0d 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -902,6 +902,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (cc._fpsImage) { cc.Director._fpsImage.src = cc._fpsImage; } - _tmp.DirectorWebGL && _tmp.DirectorWebGL(); - delete _tmp.DirectorWebGL; + cc.assert(typeof cc._tmp.DirectorWebGL === "function", cc._LogInfos.MissingFile, "CCDirectorWebGL.js"); + cc._tmp.DirectorWebGL(); + delete cc._tmp.DirectorWebGL; } \ No newline at end of file diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 02aa073164..f2be8bd5b2 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -25,7 +25,7 @@ ****************************************************************************/ -_tmp.DirectorWebGL = function () { +cc._tmp.DirectorWebGL = function () { /** * OpenGL projection protocol diff --git a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js index 4d2cea6056..82669c6f9e 100644 --- a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +++ b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.PrototypeCCNode = function () { +cc._tmp.PrototypeCCNode = function () { var _p = cc.Node.prototype; @@ -122,7 +122,7 @@ _tmp.PrototypeCCNode = function () { cc.defineGetterSetter(_p, "glServerState", _p.getGLServerState, _p.setGLServerState); }; -_tmp.PrototypeCCNodeRGBA = function () { +cc._tmp.PrototypeCCNodeRGBA = function () { var _p = cc.NodeRGBA.prototype; /** @expose */ diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index b342200a3c..6aabe33b06 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.WebGLCCNode = function () { +cc._tmp.WebGLCCNode = function () { /** * CCNode diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index fa703106ba..fa3206ffc9 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -86,7 +86,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ * Shall be overridden in subclasses */ updateAtlasValues: function () { - cc.log("cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses"); + cc.log(cc._LogInfos.AtlasNode_updateAtlasValues); }, /** cc.AtlasNode - RGBA protocol @@ -198,7 +198,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ this._opacityModifyRGB = true; this._originalTexture = texture; if (!this._originalTexture) { - cc.log("cocos2d: Could not initialize cc.AtlasNode. Invalid Texture."); + cc.log(cc._LogInfos.AtlasNode__initWithTexture); return false; } this._textureForCanvas = this._originalTexture; @@ -223,7 +223,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ this.textureAtlas.initWithTexture(texture, itemsToRender); if (!this.textureAtlas) { - cc.log("cocos2d: Could not initialize cc.AtlasNode. Invalid Texture."); + cc.log(cc._LogInfos.AtlasNode__initWithTexture); return false; } diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index d77cce0b1c..b775bb5831 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2203,11 +2203,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p = null; } else { - _tmp.WebGLCCNode(); - delete _tmp.WebGLCCNode; + cc.assert(typeof cc._tmp.WebGLCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesWebGL.js"); + cc._tmp.WebGLCCNode(); + delete cc._tmp.WebGLCCNode; } -_tmp.PrototypeCCNode(); -delete _tmp.PrototypeCCNode; +cc.assert(typeof cc._tmp.PrototypeCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); +cc._tmp.PrototypeCCNode(); +delete cc._tmp.PrototypeCCNode; /** @@ -2470,8 +2472,9 @@ cc.NodeRGBA.create = function () { return res; }; -_tmp.PrototypeCCNodeRGBA(); -delete _tmp.PrototypeCCNodeRGBA; +cc.assert(typeof cc._tmp.PrototypeCCNodeRGBA === "function", cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); +cc._tmp.PrototypeCCNodeRGBA(); +delete cc._tmp.PrototypeCCNodeRGBA; /** * Node on enter diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index af4d5c8e65..9aa49360ef 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -383,7 +383,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ _updateListeners: function (event) { var locInDispatch = this._inDispatch; - cc.assert(locInDispatch > 0, "If program goes here, there should be event in dispatch."); + cc.assert(locInDispatch > 0, cc._LogInfos.EventManager__updateListeners); if (event.getType() == cc.Event.TOUCH) { this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID); this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID); @@ -393,7 +393,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ if(locInDispatch > 1) return; - cc.assert(locInDispatch == 1, "_inDispatch should be 1 here."); + cc.assert(locInDispatch == 1, cc._LogInfos.EventManager__updateListeners_2); var locListenersMap = this._listenersMap, locPriorityDirtyFlagMap = this._priorityDirtyFlagMap; for (var selKey in locListenersMap) { if (locListenersMap[selKey].empty()) { diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index a32f2513db..19ee1bb5f7 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1120,13 +1120,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p = null; } else { - _tmp.WebGLLabelTTF(); - delete _tmp.WebGLLabelTTF; + cc.assert(typeof cc._tmp.WebGLLabelTTF === "function", cc._LogInfos.MissingFile, "LabelTTFWebGL.js"); + cc._tmp.WebGLLabelTTF(); + delete cc._tmp.WebGLLabelTTF; } - -_tmp.PrototypeLabelTTF(); -delete _tmp.PrototypeLabelTTF; +cc.assert(typeof cc._tmp.PrototypeLabelTTF === "function", cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js"); +cc._tmp.PrototypeLabelTTF(); +delete cc._tmp.PrototypeLabelTTF; cc.LabelTTF._textAlign = ["left", "center", "right"]; diff --git a/cocos2d/core/labelttf/LabelTTFPropertyDefine.js b/cocos2d/core/labelttf/LabelTTFPropertyDefine.js index 79667a2633..71ff3a964a 100644 --- a/cocos2d/core/labelttf/LabelTTFPropertyDefine.js +++ b/cocos2d/core/labelttf/LabelTTFPropertyDefine.js @@ -25,7 +25,7 @@ ****************************************************************************/ -_tmp.PrototypeLabelTTF = function () { +cc._tmp.PrototypeLabelTTF = function () { var _p = cc.LabelTTF.prototype; // Override properties diff --git a/cocos2d/core/labelttf/LabelTTFWebGL.js b/cocos2d/core/labelttf/LabelTTFWebGL.js index f6d1a0a9cc..afc167655d 100644 --- a/cocos2d/core/labelttf/LabelTTFWebGL.js +++ b/cocos2d/core/labelttf/LabelTTFWebGL.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.WebGLLabelTTF = function () { +cc._tmp.WebGLLabelTTF = function () { var _p = cc.LabelTTF.prototype; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 940e76f551..d4453f67ed 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -328,8 +328,9 @@ cc.LayerRGBA = cc.Layer.extend(/** @lends cc.LayerRGBA# */{ } }); -_tmp.PrototypeLayerRGBA(); -delete _tmp.PrototypeLayerRGBA; +cc.assert(typeof cc._tmp.PrototypeLayerRGBA === "function", cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); +cc._tmp.PrototypeLayerRGBA(); +delete cc._tmp.PrototypeLayerRGBA; /** *

@@ -534,12 +535,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerGradient define end _p = null; } else { - _tmp.WebGLLayerColor(); - delete _tmp.WebGLLayerColor; + cc.assert(typeof cc._tmp.WebGLLayerColor === "function", cc._LogInfos.MissingFile, "CCLayerWebGL.js"); + cc._tmp.WebGLLayerColor(); + delete cc._tmp.WebGLLayerColor; } -_tmp.PrototypeLayerColor(); -delete _tmp.PrototypeLayerColor; +cc.assert(typeof cc._tmp.PrototypeLayerColor === "function", cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); +cc._tmp.PrototypeLayerColor(); +delete cc._tmp.PrototypeLayerColor; /** *

@@ -816,11 +819,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerGradient define end _p = null; } else { - _tmp.WebGLLayerGradient(); - delete _tmp.WebGLLayerGradient; + cc.assert(typeof cc._tmp.WebGLLayerGradient === "function", cc._LogInfos.MissingFile, "CCLayerWebGL.js"); + cc._tmp.WebGLLayerGradient(); + delete cc._tmp.WebGLLayerGradient; } -_tmp.PrototypeLayerGradient(); -delete _tmp.PrototypeLayerGradient; + +cc.assert(typeof cc._tmp.PrototypeLayerGradient === "function", cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); +cc._tmp.PrototypeLayerGradient(); +delete cc._tmp.PrototypeLayerGradient; /** * CCMultipleLayer is a CCLayer with the ability to multiplex it's children.
diff --git a/cocos2d/core/layers/CCLayerPropertyDefine.js b/cocos2d/core/layers/CCLayerPropertyDefine.js index 8dcf53a234..f88eedf13d 100644 --- a/cocos2d/core/layers/CCLayerPropertyDefine.js +++ b/cocos2d/core/layers/CCLayerPropertyDefine.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.PrototypeLayerRGBA = function () { +cc._tmp.PrototypeLayerRGBA = function () { var _p = cc.LayerRGBA.prototype; // Extended properties /** @expose */ @@ -44,14 +44,14 @@ _tmp.PrototypeLayerRGBA = function () { cc.defineGetterSetter(_p, "cascadeColor", _p.isCascadeColorEnabled, _p.setCascadeColorEnabled); }; -_tmp.PrototypeLayerColor = function () { +cc._tmp.PrototypeLayerColor = function () { var _p = cc.LayerColor.prototype; // Override properties cc.defineGetterSetter(_p, "width", _p._getWidth, _p._setWidth); cc.defineGetterSetter(_p, "height", _p._getHeight, _p._setHeight); }; -_tmp.PrototypeLayerGradient = function () { +cc._tmp.PrototypeLayerGradient = function () { var _p = cc.LayerGradient.prototype; // Extended properties /** @expose */ diff --git a/cocos2d/core/layers/CCLayerWebGL.js b/cocos2d/core/layers/CCLayerWebGL.js index c33e8864f4..8d03f273f4 100644 --- a/cocos2d/core/layers/CCLayerWebGL.js +++ b/cocos2d/core/layers/CCLayerWebGL.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.WebGLLayerColor = function () { +cc._tmp.WebGLLayerColor = function () { //cc.LayerColor define start var _p = cc.LayerColor.prototype; _p._squareVertices = null; @@ -129,7 +129,7 @@ _tmp.WebGLLayerColor = function () { //cc.LayerColor define end } -_tmp.WebGLLayerGradient = function () { +cc._tmp.WebGLLayerGradient = function () { //cc.LayerGradient define start var _p = cc.LayerGradient.prototype; _p.draw = cc.LayerColor.prototype.draw; diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index 9b5de58478..9506423418 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -var _tmp = _tmp || {}; +cc._tmp = cc._tmp || {}; /** * Function added for JS bindings compatibility. Not needed in cocos2d-html5. diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 0720042476..92ff5fa8f9 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -150,7 +150,7 @@ cc.radiansToDegrees = function (angle) { return angle * cc.DEG; }; cc.radiansToDegress = function (angle) { - cc.log('cc.radiansToDegress() should be called cc.radiansToDegrees()'); + cc.log(cc._LogInfos.radiansToDegress); return angle * cc.DEG; }; diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 64fb2bbf7e..946e1b7422 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -335,10 +335,12 @@ cc.FontDefinition = function () { }; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - _tmp.WebGLColor(); - delete _tmp.WebGLColor; + cc.assert(typeof cc._tmp.WebGLColor === "function", cc._LogInfos.MissingFile, "CCTypesWebGL.js"); + cc._tmp.WebGLColor(); + delete cc._tmp.WebGLColor; } -_tmp.PrototypeColor(); -delete _tmp.PrototypeColor; +cc.assert(typeof cc._tmp.PrototypeColor === "function", cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js"); +cc._tmp.PrototypeColor(); +delete cc._tmp.PrototypeColor; diff --git a/cocos2d/core/platform/CCTypesPropertyDefine.js b/cocos2d/core/platform/CCTypesPropertyDefine.js index 8c94fe9a65..0fc7d68bc2 100644 --- a/cocos2d/core/platform/CCTypesPropertyDefine.js +++ b/cocos2d/core/platform/CCTypesPropertyDefine.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.PrototypeColor = function () { +cc._tmp.PrototypeColor = function () { var _p = cc.color; /** * White color (255, 255, 255, 255) diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index f76adc33ec..2e7de169ea 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -24,9 +24,9 @@ THE SOFTWARE. ****************************************************************************/ -var _tmp = _tmp || {}; +cc._tmp = cc._tmp || {}; -_tmp.WebGLColor = function () { +cc._tmp.WebGLColor = function () { //redefine some types with ArrayBuffer for WebGL cc.color = function (r, g, b, a, arrayBuffer, offset) { if (r === undefined) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 8d6e8c422c..4cbf50dd4b 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1299,8 +1299,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(texture) { var _x = rect.x + rect.width, _y = rect.y + rect.height; - cc.assert(_x <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(_y <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); + cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); } _t._originalTexture = texture; _t.texture = texture; @@ -1606,9 +1606,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { delete _p; } else { - _tmp.WebGLSprite(); - delete _tmp.WebGLSprite; + cc.assert(typeof cc._tmp.WebGLSprite === "function", cc._LogInfos.MissingFile, "SpritesWebGL.js"); + cc._tmp.WebGLSprite(); + delete cc._tmp.WebGLSprite; } -_tmp.PrototypeSprite(); -delete _tmp.PrototypeSprite; + +cc.assert(typeof cc._tmp.PrototypeSprite === "function", cc._LogInfos.MissingFile, "SpritesPropertyDefine.js"); +cc._tmp.PrototypeSprite(); +delete cc._tmp.PrototypeSprite; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 0cd67b1d46..f0b716f94e 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -363,8 +363,8 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ _x = rect.x + rect.width; _y = rect.y + rect.height; } - cc.assert(_x <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(_y <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); + cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); } this._rectInPixels = rect; diff --git a/cocos2d/core/sprites/SpritesPropertyDefine.js b/cocos2d/core/sprites/SpritesPropertyDefine.js index a62373caee..20e8cc938a 100644 --- a/cocos2d/core/sprites/SpritesPropertyDefine.js +++ b/cocos2d/core/sprites/SpritesPropertyDefine.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.PrototypeSprite = function () { +cc._tmp.PrototypeSprite = function () { var _p = cc.Sprite.prototype; // Override properties diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index b77b03bd74..be3706a4ba 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.WebGLSprite = function () { +cc._tmp.WebGLSprite = function () { var _p = cc.Sprite.prototype; @@ -184,8 +184,8 @@ _tmp.WebGLSprite = function () { _x = rect.x + rect.width; _y = rect.y + rect.height; } - cc.assert(_x <= texture.width, 'Rect width exceeds maximum margin: %s', texture.url); - cc.assert(_y <= texture.height, 'Rect height exceeds the maximum margin: %s', texture.url); + cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); + cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); } _t.texture = texture; diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index db42e2bf49..25e5f11e1e 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -352,9 +352,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }); } else { - _tmp.WebGLTexture2D(); - delete _tmp.WebGLTexture2D; + cc.assert(typeof cc._tmp.WebGLTexture2D === "function", cc._LogInfos.MissingFile, "TexturesWebGL.js"); + cc._tmp.WebGLTexture2D(); + delete cc._tmp.WebGLTexture2D; } -_tmp.PrototypeTexture2D(); -delete _tmp.PrototypeTexture2D; \ No newline at end of file +cc.assert(typeof cc._tmp.PrototypeTexture2D === "function", cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); +cc._tmp.PrototypeTexture2D(); +delete cc._tmp.PrototypeTexture2D; \ No newline at end of file diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index d34875c185..b91300a82b 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -648,9 +648,11 @@ cc.TextureAtlas.create = function (fileName, capacity) { }; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - _tmp.WebGLTextureAtlas(); - delete _tmp.WebGLTextureAtlas; + cc.assert(typeof cc._tmp.WebGLTextureAtlas === "function", cc._LogInfos.MissingFile, "TexturesWebGL.js"); + cc._tmp.WebGLTextureAtlas(); + delete cc._tmp.WebGLTextureAtlas; } -_tmp.PrototypeTextureAtlas(); -delete _tmp.PrototypeTextureAtlas; \ No newline at end of file +cc.assert(typeof cc._tmp.PrototypeTextureAtlas === "function", cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); +cc._tmp.PrototypeTextureAtlas(); +delete cc._tmp.PrototypeTextureAtlas; \ No newline at end of file diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 1d2e0efc05..13868d951e 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -274,7 +274,7 @@ cc.textureCache = /** @lends cc.textureCache# */{ for (var selCanvasKey in selCanvasColorsArr) { var selCanvas = selCanvasColorsArr[selCanvasKey]; count++; - cc.log("cocos2d: '%s' id= HTMLCanvasElement %s x %s", key, selCanvas.width, selCanvas.height); + cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, key, selCanvas.width, selCanvas.height); totalBytes += selCanvas.width * selCanvas.height * 4; } @@ -354,6 +354,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p = null; } else { - _tmp.WebGLTextureCache(); - delete _tmp.WebGLTextureCache; + cc.assert(typeof cc._tmp.WebGLTextureCache === "function", cc._LogInfos.MissingFile, "TexturesWebGL.js"); + cc._tmp.WebGLTextureCache(); + delete cc._tmp.WebGLTextureCache; } \ No newline at end of file diff --git a/cocos2d/core/textures/TexturesPropertyDefine.js b/cocos2d/core/textures/TexturesPropertyDefine.js index ae093b0bcb..1aadfb013a 100644 --- a/cocos2d/core/textures/TexturesPropertyDefine.js +++ b/cocos2d/core/textures/TexturesPropertyDefine.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.PrototypeTexture2D = function () { +cc._tmp.PrototypeTexture2D = function () { var _c = cc.Texture2D; @@ -203,7 +203,7 @@ _tmp.PrototypeTexture2D = function () { _c.defaultPixelFormat = _c.PIXEL_FORMAT_DEFAULT; }; -_tmp.PrototypeTextureAtlas = function () { +cc._tmp.PrototypeTextureAtlas = function () { var _p = cc.TextureAtlas.prototype; diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 61b94006da..ba17755895 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ -_tmp.WebGLTexture2D = function () { +cc._tmp.WebGLTexture2D = function () { /** *

@@ -742,7 +742,7 @@ _tmp.WebGLTexture2D = function () { }; -_tmp.WebGLTextureAtlas = function () { +cc._tmp.WebGLTextureAtlas = function () { var _p = cc.TextureAtlas.prototype; @@ -816,8 +816,8 @@ _tmp.WebGLTextureAtlas = function () { //cc.checkGLErrorDebug(); }; -} -_tmp.WebGLTextureCache = function () { +}; +cc._tmp.WebGLTextureCache = function () { var _p = cc.textureCache; From 31baadc5d739d83913f95a4a99d66affe80e5c51 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 16 May 2014 15:41:31 +0800 Subject: [PATCH 0107/1564] Issue #5216: CCEventExtension is missing of build.xml --- tools/build.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build.xml b/tools/build.xml index ec1450e26e..36f27c7193 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -36,6 +36,7 @@ + From 708b5bcb1c81350aa78689932f221c76104038ce Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 19 May 2014 16:22:16 +0800 Subject: [PATCH 0108/1564] Delete .gitmodules file --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 43af3292c4..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "samples"] - path = samples - url = https://github.com/cocos2d/cocos2d-js-tests.git From 81f3021de4059a73b2cbaba0de9aa5b73b4f6ecb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 19 May 2014 17:20:20 +0800 Subject: [PATCH 0109/1564] Issue #5096: Performance Optimization of cc.Sprite.sortAllChildren --- cocos2d/core/sprites/CCSprite.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4cbf50dd4b..4d1fc9ba01 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -478,27 +478,36 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ sortAllChildren:function () { if (this._reorderChildDirty) { - var j, tempItem, locChildren = this._children, tempChild; - for (var i = 1; i < locChildren.length; i++) { - tempItem = locChildren[i]; + var _children = this._children; + + // insertion sort + var len = _children.length, i, j, tmp; + for(i=1; i= 0 && ( tempItem._localZOrder < tempChild._localZOrder || - ( tempItem._localZOrder == tempChild._localZOrder && tempItem.arrivalOrder < tempChild.arrivalOrder ))) { - locChildren[j + 1] = tempChild; - j = j - 1; - tempChild = locChildren[j]; + while(j >= 0){ + if(tmp._localZOrder < _children[j]._localZOrder){ + _children[j+1] = _children[j]; + }else if(tmp._localZOrder === _children[j]._localZOrder && tmp.arrivalOrder < _children[j].arrivalOrder){ + _children[j+1] = _children[j]; + }else{ + break; + } + j--; } - locChildren[j + 1] = tempItem; + _children[j+1] = tmp; } if (this._batchNode) { - this._arrayMakeObjectsPerformSelector(locChildren, cc.Node.StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(_children, cc.Node.StateCallbackType.sortAllChildren); } + + //don't need to check children recursively, that's done in visit of each child this._reorderChildDirty = false; } + }, /** From 1cabbb25094b6c3bae27c212b2c6ad166fbc53ee Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 20 May 2014 13:22:15 +0800 Subject: [PATCH 0110/1564] Issue #4986: Fix a bug that repeat rotation error --- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4d1fc9ba01..4953afb051 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -425,8 +425,8 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ spriteFrame.addLoadedEventListener(this._spriteFrameLoadedCallback, this); } + var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect()); this.setSpriteFrame(spriteFrame); - var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect(), spriteFrame._rotated); return ret; }, diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index f525202f49..4d89fe1947 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -235,9 +235,6 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ //clip to canvas var locTexture = spriteFrame.getTexture(); if (locTexture.isLoaded()) { - - spriteFrame.setRotated(false); - var tempElement = spriteFrame.getTexture().getHtmlElementObj(); tempElement = cc.cutRotateImageToCanvas(tempElement, spriteFrame.getRectInPixels()); var tempTexture = new cc.Texture2D(); From bdc2a4dbf171c37f97c53d5e13d50f53c2bb09ca Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 20 May 2014 13:55:24 +0800 Subject: [PATCH 0111/1564] Closed #5249: Debugger module is not properly replace the %s --- CCDebugger.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/CCDebugger.js b/CCDebugger.js index 632fbe4601..c63571e274 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -44,7 +44,7 @@ cc._LogInfos = { arrayVerifyType: "element type is wrong!", - Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%d to %d", + Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s", Scheduler_scheduleCallbackForTarget_2: "cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.", Scheduler_scheduleCallbackForTarget_3: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.", Scheduler_pauseTarget: "cc.Scheduler.pauseTarget():target should be non-null", @@ -266,12 +266,27 @@ cc._logToWebPage = function (msg) { //to make sure the cc.log, cc.warn, cc.error and cc.assert would not throw error before init by debugger mode. if (console.log) { - cc.log = Function.prototype.bind.call(console.log, console); + cc.log = function(msg){ + for (var i = 1; i < arguments.length; i++) { + msg = msg.replace("%s", arguments[i]); + } + console.log(msg); + }; cc.warn = console.warn ? - Function.prototype.bind.call(console.warn, console) : + function(msg){ + for (var i = 1; i < arguments.length; i++) { + msg = msg.replace("%s", arguments[i]); + } + console.warn(msg); + } : cc.log; cc.error = console.error ? - Function.prototype.bind.call(console.error, console) : + function(msg){ + for (var i = 1; i < arguments.length; i++) { + msg = msg.replace("%s", arguments[i]); + } + console.error(msg); + } : cc.log; cc.assert = function (cond, msg) { if (!cond && msg) { From bff054fed49606764664442355c310df1992481e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 20 May 2014 17:50:26 +0800 Subject: [PATCH 0112/1564] Issue #5254: uiReader not set the opacity --- cocos2d/actions/CCActionInterval.js | 4 ++-- extensions/ccui/base-classes/UIWidget.js | 15 +++++++++++++-- extensions/ccui/uiwidgets/UIButton.js | 7 +------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 08568784e5..3e5e717c79 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2212,7 +2212,7 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ update:function (time) { time = this._computeEaseTime(time); if (this.target.RGBAProtocol) { - var fromOpacity = this._fromOpacity; + var fromOpacity = this._fromOpacity || 255; this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time; } }, @@ -2406,7 +2406,7 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ update:function (time) { time = this._computeEaseTime(time); var locFrom = this._from, locTo = this._to; - if (this.target.RGBAProtocol) { + if (locFrom && this.target.RGBAProtocol) { this.target.color = cc.color(locFrom.r + (locTo.r - locFrom.r) * time, locFrom.g + (locTo.g - locFrom.g) * time, locFrom.b + (locTo.b - locFrom.b) * time); diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index d02da7d30e..81e2a1612c 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -47,6 +47,8 @@ * @property {Number} actionTag - The action tag of the widget */ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ + + RGBAProtocol: true, _enabled: true, ///< Highest control of widget _bright: true, ///< is this widget bright _touchEnabled: false, ///< is this widget touch endabled @@ -1385,7 +1387,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ */ setOpacity: function (opacity) { this._color.a = opacity; - this.updateTextureOpacity(); + this.updateTextureOpacity(opacity); }, /** @@ -1400,8 +1402,14 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, - updateTextureOpacity: function () { + updateTextureOpacity: function (opacity) { + for(var p in this._children){ + var item = this._children[p]; + if(item && item.RGBAProtocol){ + item.setOpacity(opacity); + } + } }, @@ -1463,6 +1471,9 @@ cc.defineGetterSetter(_p, "name", _p.getName, _p.setName); /** @expose */ _p.actionTag; cc.defineGetterSetter(_p, "actionTag", _p.getActionTag, _p.setActionTag); +/** @expose */ +_p.opacity; +cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); _p = null; diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 858c167347..5525afd3d8 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -64,6 +64,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _normalTextureLoaded: false, _pressedTextureLoaded: false, _disabledTextureLoaded: false, + _cascadeOpacityEnabled: true, _className: "Button", /** @@ -743,12 +744,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.updateColorToRenderer(this._buttonDisableRenderer); }, - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._buttonNormalRenderer); - this.updateOpacityToRenderer(this._buttonClickedRenderer); - this.updateOpacityToRenderer(this._buttonDisableRenderer); - }, - /** * Returns the "class name" of widget. * @returns {string} From 41cdc8caf9ea43b880501e4190f9503c2c0a899b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 May 2014 10:59:59 +0800 Subject: [PATCH 0113/1564] Issue #4986: Fix a bug that the rotation parameters error --- cocos2d/core/sprites/CCSprite.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4953afb051..8db3657abd 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -425,7 +425,8 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ spriteFrame.addLoadedEventListener(this._spriteFrameLoadedCallback, this); } - var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect()); + var rotated = cc._renderType === cc._RENDER_TYPE_CANVAS ? false : spriteFrame._rotated; + var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect(), rotated); this.setSpriteFrame(spriteFrame); return ret; From bd5c5343c507d3851b0d926fc8975ff24ef041c9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 May 2014 11:02:16 +0800 Subject: [PATCH 0114/1564] Issue #5254: Fix a bug that the _formOpacity parameters error --- cocos2d/actions/CCActionInterval.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 3e5e717c79..8fc3bda266 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2212,7 +2212,7 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ update:function (time) { time = this._computeEaseTime(time); if (this.target.RGBAProtocol) { - var fromOpacity = this._fromOpacity || 255; + var fromOpacity = this._fromOpacity !== undefined ? this._fromOpacity : 255; this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time; } }, From 6064ab52582d449e44c7bf1ed86a408e9a612a7b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 May 2014 11:28:43 +0800 Subject: [PATCH 0115/1564] Issue #3943: Fix a bug that EaseElasticInOut.reverse error --- cocos2d/actions/CCActionEase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 68f67d3fac..7bde1cd070 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -981,7 +981,7 @@ cc.easeElasticInOut = function (period) { return newT; }, reverse: function(){ - return cc.EaseElasticInOut(this._period); + return cc.easeElasticInOut(this._period); } }; }; From 32054eb689ede6b658c4c5fc08b4aa6c1ba67b8b Mon Sep 17 00:00:00 2001 From: Yifeng Wu Date: Wed, 21 May 2014 12:46:38 +0800 Subject: [PATCH 0116/1564] Added some tween support for CocoStudio UI. Note that, Custom, Quad, Cubic, Quart, Quint, and Circ ease type is not supported yet. --- extensions/cocostudio/action/CCActionFrame.js | 177 +++++++++++++++++- extensions/cocostudio/action/CCActionNode.js | 7 + 2 files changed, 174 insertions(+), 10 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 4fed31dbb8..705b2489f8 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -34,6 +34,51 @@ ccs.FRAME_TYPE_TINT = 3; ccs.FRAME_TYPE_FADE = 4; ccs.FRAME_TYPE_MAX = 5; +ccs.FrameEaseType = { + Linear : 0, + + Sine_EaseIn : 1, + Sine_EaseOut : 2, + Sine_EaseInOut : 3, + + Quad_EaseIn : 4, + Quad_EaseOut : 5, + Quad_EaseInOut : 6, + + Cubic_EaseIn : 7, + Cubic_EaseOut : 8, + Cubic_EaseInOut : 9, + + Quart_EaseIn : 10, + Quart_EaseOut : 11, + Quart_EaseInOut : 12, + + Quint_EaseIn : 13, + Quint_EaseOut : 14, + Quint_EaseInOut : 15, + + Expo_EaseIn : 16, + Expo_EaseOut : 17, + Expo_EaseInOut : 18, + + Circ_EaseIn : 19, + Circ_EaseOut : 20, + Circ_EaseInOut : 21, + + Elastic_EaesIn : 22, + Elastic_EaesOut : 23, + Elastic_EaesInOut : 24, + + Back_EaseIn : 25, + Back_EaseOut : 26, + Back_EaseInOut : 27, + + Bounce_EaseIn : 28, + Bounce_EaseOut : 29, + Bounce_EaseInOut : 30 +}; + + /** * Base class for ccs.ActionFrame * @class @@ -58,6 +103,113 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ */ getAction: function (duration) { return null; + }, + + _getEasingAction : function (action) { + if (action == null) { + console.error("Action cannot be null!"); + return null; + } + + var resultAction; + switch (this.easingType) { + case ccs.FrameEaseType.Linear: + resultAction = action; + break; + case ccs.FrameEaseType.Sine_EaseIn: + resultAction = cc.EaseSineIn.create(action); + break; + case ccs.FrameEaseType.Sine_EaseOut: + resultAction = cc.EaseSineOut.create(action); + break; + case ccs.FrameEaseType.Sine_EaseInOut: + resultAction = cc.EaseSineInOut.create(action); + break; +// case ccs.FrameEaseType.Quad_EaseIn: +// resultAction = cc.Quad_EaseIn.create(action); +// break; +// case ccs.FrameEaseType.Quad_EaseOut: +// resultAction = cc.Quad_EaseOut.create(action); +// break; +// case ccs.FrameEaseType.Quad_EaseInOut: +// resultAction = cc.Quad_EaseInOut.create(action); +// break; +// case ccs.FrameEaseType.Cubic_EaseIn: +// resultAction = cc.Cubic_EaseIn.create(action); +// break; +// case ccs.FrameEaseType.Cubic_EaseOut: +// resultAction = cc.Cubic_EaseOut.create(action); +// break; +// case ccs.FrameEaseType.Cubic_EaseInOut: +// resultAction = cc.Cubic_EaseInOut.create(action); +// break; +// case ccs.FrameEaseType.Quart_EaseIn: +// resultAction = cc.Quart_EaseIn.create(action); +// break; +// case ccs.FrameEaseType.Quart_EaseOut: +// resultAction = cc.Quart_EaseOut.create(action); +// break; +// case ccs.FrameEaseType.Quart_EaseInOut: +// resultAction = cc.Quart_EaseInOut.create(action); +// break; +// case ccs.FrameEaseType.Quint_EaseIn: +// resultAction = cc.Quint_EaseIn.create(action); +// break; +// case ccs.FrameEaseType.Quint_EaseOut: +// resultAction = cc.Quint_EaseOut.create(action); +// break; +// case ccs.FrameEaseType.Quint_EaseInOut: +// resultAction = cc.Quint_EaseInOut.create(action); +// break; + case ccs.FrameEaseType.Expo_EaseIn: + resultAction = cc.EaseExponentialIn.create(action); + break; + case ccs.FrameEaseType.Expo_EaseOut: + resultAction = cc.EaseExponentialOut.create(action); + break; + case ccs.FrameEaseType.Expo_EaseInOut: + resultAction = cc.EaseExponentialInOut.create(action); + break; +// case ccs.FrameEaseType.Circ_EaseIn: +// resultAction = cc.Circ_EaseIn.create(action); +// break; +// case ccs.FrameEaseType.Circ_EaseOut: +// resultAction = cc.Circ_EaseOut.create(action); +// break; +// case ccs.FrameEaseType.Circ_EaseInOut: +// resultAction = cc.Circ_EaseInOut.create(action); +// break; + case ccs.FrameEaseType.Elastic_EaesIn: + resultAction = cc.Elastic_EaesIn.create(action); + break; + case ccs.FrameEaseType.Elastic_EaesOut: + resultAction = cc.Elastic_EaesOut.create(action); + break; + case ccs.FrameEaseType.Elastic_EaesInOut: + resultAction = cc.Elastic_EaesInOut.create(action); + break; + case ccs.FrameEaseType.Back_EaseIn: + resultAction = cc.EaseBackIn.create(action); + break; + case ccs.FrameEaseType.Back_EaseOut: + resultAction = cc.EaseBackOut.create(action); + break; + case ccs.FrameEaseType.Back_EaseInOut: + resultAction = cc.EaseBackInOut.create(action); + break; + case ccs.FrameEaseType.Bounce_EaseIn: + resultAction = cc.Bounce_EaseIn.create(action); + break; + case ccs.FrameEaseType.Bounce_EaseOut: + resultAction = cc.Bounce_EaseOut.create(action); + break; + case ccs.FrameEaseType.Bounce_EaseInOut: + resultAction = cc.Bounce_EaseInOut.create(action); + default: + console.error("Frame ease type: " + this.easingType + " is currently not supported."); + } + + return resultAction; } }); @@ -100,10 +252,11 @@ ccs.ActionMoveFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionMoveFrame# */{ /** * Gets the CCAction of ActionFrame. * @param {number} duration - * @returns {cc.MoveTo} + * @returns {cc.Action} */ getAction: function (duration) { - return cc.MoveTo.create(duration, this._position); + var action = cc.MoveTo.create(duration, this._position); + return this._getEasingAction(action); } }); @@ -157,10 +310,11 @@ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# * /** * Gets the action of ActionFrame. * @param duration - * @returns {cc.ScaleTo} + * @returns {cc.Action} */ getAction: function (duration) { - return cc.ScaleTo.create(duration, this._scaleX, this._scaleY); + var action = cc.ScaleTo.create(duration, this._scaleX, this._scaleY); + return this._getEasingAction(action); } }); @@ -196,10 +350,11 @@ ccs.ActionRotationFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionRotationFr /** * Gets the CCAction of ActionFrame. * @param {number} duration - * @returns {cc.RotateTo} + * @returns {cc.Action} */ getAction: function (duration) { - return cc.RotateTo.create(duration, this._rotation); + var action = cc.RotateTo.create(duration, this._rotation); + return this._getEasingAction(action); } }); @@ -235,10 +390,11 @@ ccs.ActionFadeFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionFadeFrame# */{ /** * Gets the CCAction of ActionFrame. * @param duration - * @returns {cc.FadeTo} + * @returns {cc.Action} */ getAction: function (duration) { - return cc.FadeTo.create(duration, this._opacity); + var action = cc.FadeTo.create(duration, this._opacity); + return this._getEasingAction(action); } }); @@ -278,9 +434,10 @@ ccs.ActionTintFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionTintFrame# */{ /** * Gets the action of ActionFrame. * @param duration - * @returns {cc.TintTo} + * @returns {cc.Action} */ getAction: function (duration) { - return cc.TintTo.create(duration, this._color.r, this._color.g, this._color.b); + var action = cc.TintTo.create(duration, this._color.r, this._color.g, this._color.b); + return this._getEasingAction(action); } }); \ No newline at end of file diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index 0d206bf1ab..784cfe3b88 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -64,10 +64,13 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ for (var i = 0; i < actionframelist.length; i++) { var actionFrameDic = actionframelist[i]; var frameInex = actionFrameDic["frameid"]; + var frameTweenType = actionFrameDic["tweenType"]; + if (actionFrameDic["positionx"] !== undefined) { var positionX = actionFrameDic["positionx"]; var positionY = actionFrameDic["positiony"]; var actionFrame = new ccs.ActionMoveFrame(); + actionFrame.easingType = frameTweenType; actionFrame.frameIndex = frameInex; actionFrame.setPosition(positionX, positionY); var actionArray = this._frameArray[ccs.FRAME_TYPE_MOVE]; @@ -78,6 +81,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var scaleX = actionFrameDic["scalex"]; var scaleY = actionFrameDic["scaley"]; var actionFrame = new ccs.ActionScaleFrame(); + actionFrame.easingType = frameTweenType; actionFrame.frameIndex = frameInex; actionFrame.setScaleX(scaleX); actionFrame.setScaleY(scaleY); @@ -88,6 +92,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ if (actionFrameDic["rotation"] !== undefined) { var rotation = actionFrameDic["rotation"]; var actionFrame = new ccs.ActionRotationFrame(); + actionFrame.easingType = frameTweenType; actionFrame.frameIndex = frameInex; actionFrame.setRotation(rotation); var actionArray = this._frameArray[ccs.FRAME_TYPE_ROTATE]; @@ -97,6 +102,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ if (actionFrameDic["opacity"] !== undefined) { var opacity = actionFrameDic["opacity"]; var actionFrame = new ccs.ActionFadeFrame(); + actionFrame.easingType = frameTweenType; actionFrame.frameIndex = frameInex; actionFrame.setOpacity(opacity); var actionArray = this._frameArray[ccs.FRAME_TYPE_FADE]; @@ -108,6 +114,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var colorG = actionFrameDic["colorg"]; var colorB = actionFrameDic["colorb"]; var actionFrame = new ccs.ActionTintFrame(); + actionFrame.easingType = frameTweenType; actionFrame.frameIndex = frameInex; actionFrame.setColor(cc.color(colorR, colorG, colorB)); var actionArray = this._frameArray[ccs.FRAME_TYPE_TINT]; From 6e8c999fca3e9026ca0c7951edbf7fc6edb733b5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 May 2014 15:17:15 +0800 Subject: [PATCH 0117/1564] Issue #5109: Action.repeat parameter limits --- cocos2d/actions/CCActionInterval.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 8fc3bda266..3cbd0ffc48 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -264,7 +264,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ repeat: function(times){ times = Math.round(times); - if(times < 1){ + if(isNaN(times) || times < 1){ cc.log("The repeat parameter error"); return this; } From 7508aedfcd68396ce854396768d7fa1aef9e861f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 May 2014 15:19:19 +0800 Subject: [PATCH 0118/1564] Issue #5278: ccs.Bone visit invalid --- extensions/cocostudio/armature/CCBone.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index ad03c0c9f4..dc421c6e19 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -166,6 +166,11 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ * @param dt */ update: function (dt) { + + // quick return if not visible + if (!this._visible) + return; + var locParentBone = this.parentBone; var locArmature = this._armature; var locTweenData = this._tweenData; @@ -243,6 +248,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ */ visit: function (ctx) { var node = this.getDisplayManager().getDisplayRenderNode(); + if (node) { node.visit(ctx); } From 3e2f3688d7e0d56cf44759c9ce643015d225d4ad Mon Sep 17 00:00:00 2001 From: Yifeng Wu Date: Wed, 21 May 2014 15:18:52 +0800 Subject: [PATCH 0119/1564] Added place holders for Custom type --- extensions/cocostudio/action/CCActionFrame.js | 6 ++++++ extensions/cocostudio/action/CCActionNode.js | 1 + 2 files changed, 7 insertions(+) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 705b2489f8..e92c5bde15 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -35,6 +35,8 @@ ccs.FRAME_TYPE_FADE = 4; ccs.FRAME_TYPE_MAX = 5; ccs.FrameEaseType = { + Custom : -1, + Linear : 0, Sine_EaseIn : 1, @@ -88,6 +90,7 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ frameType: 0, easingType: 0, frameIndex: 0, + frameTweenParameter: null, time: 0, ctor: function () { this.frameType = 0; @@ -113,6 +116,9 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ var resultAction; switch (this.easingType) { +// case ccs.FrameEaseType.Custom: +// +// break; case ccs.FrameEaseType.Linear: resultAction = action; break; diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index 784cfe3b88..3399fa1fe9 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -65,6 +65,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var actionFrameDic = actionframelist[i]; var frameInex = actionFrameDic["frameid"]; var frameTweenType = actionFrameDic["tweenType"]; + var frameTweenParameter = actionFrameDic["tweenParameter"]; if (actionFrameDic["positionx"] !== undefined) { var positionX = actionFrameDic["positionx"]; From 076b9b9121e2e4f8000028582e09654af0f7933d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 May 2014 15:29:45 +0800 Subject: [PATCH 0120/1564] Issue #5278: ccs.Bone visit invalid --- extensions/cocostudio/armature/CCBone.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index dc421c6e19..c6c02b90df 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -166,11 +166,6 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ * @param dt */ update: function (dt) { - - // quick return if not visible - if (!this._visible) - return; - var locParentBone = this.parentBone; var locArmature = this._armature; var locTweenData = this._tweenData; @@ -247,8 +242,11 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ * Rewrite visit ,when node draw, g_NumberOfDraws is changeless */ visit: function (ctx) { - var node = this.getDisplayManager().getDisplayRenderNode(); + // quick return if not visible + if (!this._visible) + return; + var node = this.getDisplayManager().getDisplayRenderNode(); if (node) { node.visit(ctx); } From ee1c6dd96101e29d9daec6e37aa13e7bb0d2aeb3 Mon Sep 17 00:00:00 2001 From: Yifeng Wu Date: Wed, 21 May 2014 15:36:11 +0800 Subject: [PATCH 0121/1564] fixed a bug which bounce frame ease type called a wrong api --- extensions/cocostudio/action/CCActionFrame.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index e92c5bde15..b6feb544a6 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -1,6 +1,5 @@ /**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2010-2012 cocos2d-x.org http://www.cocos2d-x.org @@ -204,13 +203,13 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ resultAction = cc.EaseBackInOut.create(action); break; case ccs.FrameEaseType.Bounce_EaseIn: - resultAction = cc.Bounce_EaseIn.create(action); + resultAction = cc.EaseBounceIn.create(action); break; case ccs.FrameEaseType.Bounce_EaseOut: - resultAction = cc.Bounce_EaseOut.create(action); + resultAction = cc.EaseBounceOut.create(action); break; case ccs.FrameEaseType.Bounce_EaseInOut: - resultAction = cc.Bounce_EaseInOut.create(action); + resultAction = cc.EaseBounceInOut.create(action); default: console.error("Frame ease type: " + this.easingType + " is currently not supported."); } From 716863d6afbf1a0c2fba317abc77b52427fe6b6c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 May 2014 17:58:35 +0800 Subject: [PATCH 0122/1564] Issue#5283: cc.SkewTo implementation of the results of special value when the problem --- cocos2d/core/base-nodes/CCNode.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b775bb5831..41aa4610e2 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2162,6 +2162,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { // offset the anchorpoint var skx = Math.tan(-_t._skewX * Math.PI / 180); var sky = Math.tan(-_t._skewY * Math.PI / 180); + if(skx === Infinity){ + skx = 99999999; + } + if(sky === Infinity){ + sky = 99999999; + } var xx = appY * skx * sx; var yy = appX * sky * sy; t.a = Cos + -Sin * sky; From 8563a01b8942f722349e5fff4f93d3c5a69ecf39 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 May 2014 10:52:39 +0800 Subject: [PATCH 0123/1564] Removed setColor judgment transparency --- cocos2d/core/sprites/CCSprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 8db3657abd..0ae9475857 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1426,7 +1426,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.setColor = function (color3) { var _t = this; var curColor = _t.color; - if ((curColor.r === color3.r) && (curColor.g === color3.g) && (curColor.b === color3.b) && (curColor.a === color3.a)) + if ((curColor.r === color3.r) && (curColor.g === color3.g) && (curColor.b === color3.b)) return; cc.NodeRGBA.prototype.setColor.call(_t, color3); From 9f26f626c194131ee33533b5fb0b2543234dfcab Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 May 2014 11:02:38 +0800 Subject: [PATCH 0124/1564] Issue #5245: Fix a bug that abnormal opacity --- extensions/ccui/base-classes/UIWidget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 81e2a1612c..0c7718a2df 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1386,6 +1386,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ * @param {Number} opacity */ setOpacity: function (opacity) { + if(opacity === this._color.a) return; this._color.a = opacity; this.updateTextureOpacity(opacity); }, From 939f2e15245ef25ccc10baa9547db01c046b87de Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 22 May 2014 15:25:25 +0800 Subject: [PATCH 0125/1564] Fixed #5325: the getXXXColor of cc.NodeRGBA and UILayout shall return a new color object. --- cocos2d/core/base-nodes/CCNode.js | 3 ++- extensions/ccui/layouts/UILayout.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 41aa4610e2..a375c9a819 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2359,7 +2359,8 @@ cc.NodeRGBA = cc.Node.extend(/** @lends cc.NodeRGBA# */{ * @returns {cc.Color} */ getDisplayedColor: function () { - return this._displayedColor; + var tmpColor = this._displayedColor; + return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); }, /** diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index a51709054c..029a82fddf 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -836,7 +836,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @returns {cc.Color} */ getBackGroundColor: function () { - return this._color; + var tmpColor = this._color; + return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); }, /** @@ -844,7 +845,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @returns {cc.Color} */ getBackGroundStartColor: function () { - return this._startColor; + var tmpColor = this._startColor; + return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); }, /** @@ -852,7 +854,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @returns {cc.Color} */ getBackGroundEndColor: function () { - return this._endColor; + var tmpColor = this._endColor; + return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); }, /** From 5ce08a0fcab7f50be986496fae1088a35a57e8f9 Mon Sep 17 00:00:00 2001 From: Yifeng Wu Date: Thu, 22 May 2014 17:14:19 +0800 Subject: [PATCH 0126/1564] fixed the elastic api call --- extensions/cocostudio/action/CCActionFrame.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index b6feb544a6..2f4d83c2d8 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -185,13 +185,13 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ // resultAction = cc.Circ_EaseInOut.create(action); // break; case ccs.FrameEaseType.Elastic_EaesIn: - resultAction = cc.Elastic_EaesIn.create(action); + resultAction = cc.EaseElasticIn.create(action); break; case ccs.FrameEaseType.Elastic_EaesOut: - resultAction = cc.Elastic_EaesOut.create(action); + resultAction = cc.EaseElasticOut.create(action); break; case ccs.FrameEaseType.Elastic_EaesInOut: - resultAction = cc.Elastic_EaesInOut.create(action); + resultAction = cc.EaseElasticInOut.create(action); break; case ccs.FrameEaseType.Back_EaseIn: resultAction = cc.EaseBackIn.create(action); From 00ed7d33cca97b33c489d406c57c3d225abbbddc Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 May 2014 20:12:51 +0800 Subject: [PATCH 0127/1564] Issue #5214: Fix cc._tmp cc is not define --- cocos2d/core/platform/CCCommon.js | 1 + cocos2d/core/platform/CCTypesWebGL.js | 1 + 2 files changed, 2 insertions(+) diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index 9506423418..bfeb0cc47a 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -24,6 +24,7 @@ THE SOFTWARE. ****************************************************************************/ +var cc = cc || {}; cc._tmp = cc._tmp || {}; /** diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index 2e7de169ea..e2bdf6b35b 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -24,6 +24,7 @@ THE SOFTWARE. ****************************************************************************/ +var cc = cc || {}; cc._tmp = cc._tmp || {}; cc._tmp.WebGLColor = function () { From bf1317947d41f1666f8b042a8abe5f56bd019724 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 May 2014 20:27:34 +0800 Subject: [PATCH 0128/1564] Closed #5333: CCBoot create new canvas no assignment method --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index e85ef5d2b7..c64962bb8d 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1271,7 +1271,7 @@ cc._setup = function (el, width, height) { width = width || element.clientWidth; height = height || element.clientHeight; localContainer = cc.container = element; - localCanvas = cc._canvas = cc.newElement("CANVAS"); + localCanvas = cc._canvas = cc.$(cc.newElement("CANVAS")); element.appendChild(localCanvas); } From af503b8ba983eb8fc585a3c79a5e5c24546737c1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 May 2014 20:34:18 +0800 Subject: [PATCH 0129/1564] Change the version number --- cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index eb472fc828..712fa11d75 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -33,7 +33,7 @@ * @constant * @type String */ -cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 alpha 2"; +cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 beta"; /** *

diff --git a/tools/build.xml b/tools/build.xml index 36f27c7193..8afae20eab 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-beta-min.js"> @@ -236,7 +236,7 @@ + debug="false" output="./../lib/cocos2d-html5-v3.0-beta-core-min.js"> From 03cd9f13e89b1e580effd897bffd05125608d4bc Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 23 May 2014 11:59:31 +0800 Subject: [PATCH 0130/1564] Issue #5335: update AUTHORS.txt for v3.0 beta --- AUTHORS.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 87d25c8517..b375805426 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -153,6 +153,8 @@ samael @samael65535 CCPhysicsSprite bug fix NatWeiss @NatWeiss Add analytics plugin protocol ,Flurry plugin and ProtocolAds.js plugin protocol cc.FileUtils refactoring + cc.Audio bugs fix + cc.Texture2D bug fix Andor Salga @asalga typo fix @@ -165,6 +167,7 @@ Asano @LaercioAsano cc.Node bug fix Bruno Assarisse @bassarisse cc.LabelBMFont bug fix +musikov @musikov cc.ClippingNode bug fix Retired Core Developers: Shengxiang Chen (Nero Chan) From 585e1cf4aa835aee8b8609551804445369fc02b6 Mon Sep 17 00:00:00 2001 From: linshun Date: Fri, 23 May 2014 16:38:44 +0800 Subject: [PATCH 0131/1564] issue #5335: Updated changed log of cocos2d-html5 v3.0 beta. --- CHANGELOG.txt | 99 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b4b4164a5e..a5968b9245 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,41 +1,80 @@ ChangeLog: + +Cocos2d-html5-v3.0 beta @ May.23, 2014 + +* Refactored actions to make it more friendly and easy-to-use. +* Integrated Spine skeleton animation feature. +* Renamed constants of ProgressTimer, Scale9Sprite, TMXLayerInfo, Node, ParticleSystem for maintainability. +* Modified mouseMove event behavior of cc.inputManager to compatible with Cocos2d-x +* Modified cc.game.run to receive a canvas id as parameter. +* Added local audio file playing from 'file://' origin. +* Added local images file displaying from 'file://' origin. +* Refactored cc.TMXLayer's setTileAt etc functions to support point or x,y as their parameters. +* Added a check to cc.Sprite and cc.SpriteFrame to avoid its texture rect out of bounds. +* Added a check to cc.SpriteFrame to avoid cc.loader release invalid sprite frame file. +* Made cc.Touch return copies of point. +* Made the default of cc.Color alpha value is 255 to avoid cc.Sprite's setColor is invalid. +* Optimized cc.Node.sortAllChildren for better performance. +* Added warning of cc.Texture2D if it has an invalid texture. + +* Bugs fix: + 1. Fixed a bug of cc.winSize that it returns incorrect value when using setDesignResolution. + 2. Added a check to cc._setup to avoid double invocation. + 3. Fixed a bug of cc.TMXMapInfo that its tile's property id is incorrect. + 4. Fixed a bug of cc.Scale9Sprite that its CascadeColor and CascadeOpacity are invalid. + 5. Fixed a bug of ccs.UILoadingBar which its barRendererScaleChangedWithSize is incorrect. + 6. Added some forgotten files to build.xml for minimize core. + 7. Corrected a mistake of renderMode default value in CCBoot.js. + 8. Fixed a bug of ccui.Layout's draw function that its scaleX, scaleY value is incorrect. + 9. Fixed a bug of cc.Audio's stopMusic function. + 10. Fixed a bug of TextureCache that it can't remove image's event handler. + 11. Fixed ClippingNode's DrawNode stencil bug on Canvas. + 12. Fixed a typo 'cc.radiansToDegress' function to 'cc.radiansToDegrees'. + 13. Fixed a bug of ccui.ImageView that its setSize is invalid when the picture without pre-load. + 14. Fixed a bug of cc.ParticleSystem that it throws a error when create from CocosBuilder. + 15. Fixed a bug of cc.LabelAtlas that it can't display its children. + 16. Fixed a bug of cc.fontLoader that it can't load custom font. + 17. Fixed a bug of ccui.Widget that its setOpacity is invalid. + 18. Fixed a bug of cc.Node that it transform value is incorrect when a node skew to a special value. + 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. +* Minimized the size of core from 254k to 113k after google closure advanced compiling +* Made cc.DrawNode support some DrawingPrimitive's drawing function on WebGL mode +* Added undefined checking in cc.loader for better performance. * 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. +* Added the warning information to notice developers that their project.json cannot be loaded or parsed. +* Added 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 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. -* Rename ccs.comAttribute's `getCString` function to `getString`. +* Added render mode checking to 3D action classes. +* Added SocketIO +* 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" +* Made actions extendable directly via ctor +* Added null callback check in cc.textureCache.addImage +* Fixed the API inconsistence of ccs.ArmatureAnimation.play +* Fixed compatibility and performance for ctor +* Renamed all Uppercase functions to lowercase in CCMacro +* Added necessary GL constants in H5 +* Fixed CONSTANTS inconsistence between h5 and JSB * 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. + 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 doesn't 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 some comment errors of framework. + 6. Fixed a bug of cc.LabelBMFont that it's multiline works incorrectly. + 7. Fixed a bug that Touches event doesn't work in release mode on IE browser. + 8. Fixed a bug that cc.winSize has not been reset after cc.view.setDesignResolutionSize. + 9. Fixed typo in ccui.Widget.TOUCH_BEGAN + 10. Fixed a bug of cc.MenuItemSprite.create that + 11. Fixed a bug of cc.loader that it need to set value before call the callback. + 12. Fixed a bug of cc.log that it doesn't work in IE9 + 13. Fixed IE incompatible issue with __lookupGetter__ + 14. Fixed a mistake of cc.Node that it return a reference of _position in getPosition + 15. Fixed a bug of cc.ClippingNode that its _super is undefined + 16. Fixed a bug of inputManager's touch event in IE browser * Known Issues: 1. EventListener is not extendable. From 13e57193327c97b322a384bff703f26f70da0bad Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 23 May 2014 17:01:23 +0800 Subject: [PATCH 0132/1564] Issue #5335: modify jsDoc tag @constructor --- AUTHORS.txt | 3 ++ cocos2d/actions/CCAction.js | 4 +- cocos2d/actions/CCActionCamera.js | 2 +- cocos2d/actions/CCActionCatmullRom.js | 8 ++-- cocos2d/actions/CCActionEase.js | 6 +-- cocos2d/actions/CCActionInstant.js | 10 ++-- cocos2d/actions/CCActionInterval.js | 46 +++++++++---------- cocos2d/actions/CCActionTween.js | 2 +- cocos2d/actions3d/CCActionGrid.js | 4 +- cocos2d/actions3d/CCActionGrid3D.js | 19 ++++---- cocos2d/actions3d/CCActionTiledGrid.js | 14 +++--- cocos2d/clipping-nodes/CCClippingNode.js | 2 +- cocos2d/core/CCScheduler.js | 2 +- cocos2d/core/base-nodes/CCAtlasNode.js | 2 +- cocos2d/core/labelttf/CCLabelTTF.js | 2 +- cocos2d/core/layers/CCLayer.js | 10 ++-- cocos2d/core/platform/CCCommon.js | 1 - cocos2d/core/sprites/CCAnimation.js | 4 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 3 +- cocos2d/core/sprites/CCSpriteFrame.js | 5 +- cocos2d/core/textures/CCTextureAtlas.js | 2 +- .../core/textures/TexturesPropertyDefine.js | 1 - cocos2d/effects/CCGrid.js | 6 +-- cocos2d/labels/CCLabelBMFont.js | 2 +- cocos2d/menus/CCMenu.js | 1 - cocos2d/menus/CCMenuItem.js | 13 +++--- cocos2d/motion-streak/CCMotionStreak.js | 4 +- cocos2d/particle/CCParticleBatchNode.js | 2 +- cocos2d/particle/CCParticleSystem.js | 2 +- cocos2d/physics/CCPhysicsSprite.js | 5 +- .../progress-timer/CCActionProgressTimer.js | 4 +- cocos2d/render-texture/CCRenderTexture.js | 4 +- cocos2d/shape-nodes/CCDrawNode.js | 4 +- cocos2d/text-input/CCTextFieldTTF.js | 4 +- cocos2d/tilemap/CCTMXLayer.js | 4 +- cocos2d/tilemap/CCTMXTiledMap.js | 5 +- cocos2d/tilemap/CCTMXXMLParser.js | 4 +- cocos2d/tilemap/CCTileMapAtlas.js | 6 ++- cocos2d/transitions/CCTransition.js | 2 +- extensions/ccui/layouts/UILayout.js | 2 +- extensions/ccui/uiwidgets/UIButton.js | 2 +- extensions/ccui/uiwidgets/UICheckBox.js | 2 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- extensions/ccui/uiwidgets/UIRichText.js | 2 +- extensions/ccui/uiwidgets/UISlider.js | 2 +- extensions/ccui/uiwidgets/UIText.js | 2 +- extensions/ccui/uiwidgets/UITextAtlas.js | 2 +- extensions/ccui/uiwidgets/UITextBMFont.js | 2 +- extensions/ccui/uiwidgets/UITextField.js | 2 +- .../uiwidgets/scroll-widget/UIListView.js | 2 +- .../uiwidgets/scroll-widget/UIPageView.js | 2 +- .../uiwidgets/scroll-widget/UIScrollView.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 2 +- 54 files changed, 126 insertions(+), 128 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index b375805426..3e7b86b2bb 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -168,6 +168,9 @@ Asano @LaercioAsano cc.Node bug fix Bruno Assarisse @bassarisse cc.LabelBMFont bug fix musikov @musikov cc.ClippingNode bug fix + cc.fontLoader bug fix + +Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix Retired Core Developers: Shengxiang Chen (Nero Chan) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 7cf1bed256..95350328da 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -255,7 +255,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ _innerAction:null, /** - * @constructor + * Constructor of cc.Speed * @param {cc.ActionInterval} action * @param {Number} speed */ @@ -414,7 +414,7 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ * creates the action with a set boundary
* creates the action with no boundary set * - * @constructor + * Constructor of cc.Follow * @param {cc.Node} followedNode * @param {cc.Rect} rect * @example diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index a7a2132694..267baef4a3 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -109,7 +109,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ /** * creates a cc.OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX - * @constructor + * Constructor of cc.OrbitCamera * @param {Number} t time * @param {Number} radius * @param {Number} deltaRadius diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index c9cb334ca9..c432e4d0da 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -129,7 +129,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * /** * Creates an action with a Cardinal Spline array of points and tension * - * @constructor + * Constructor of cc.CardinalSplineTo * @param {Number} duration * @param {Array} points array of control points * @param {Number} tension @@ -295,7 +295,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# /** * creates an action with a Cardinal Spline array of points and tension * - * @constructor + * Constructor of cc.CardinalSplineBy * @param {Number} duration * @param {Array} points * @param {Number} tension @@ -409,7 +409,7 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{ /** * creates an action with a Cardinal Spline array of points and tension * - * @constructor + * Constructor of cc.CatmullRomTo * @param {Number} dt * @param {Array} points * @@ -472,7 +472,7 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({ /** * Creates an action with a Cardinal Spline array of points and tension * - * @constructor + * Constructor of cc.CatmullRomBy * @param {Number} dt * @param {Array} points * diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 7bde1cd070..abbd959d6c 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -36,7 +36,7 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ /** * creates the action of ActionEase * - * @constructor + * Constructor of cc.ActionEase * @param {cc.ActionInterval} action * * @example @@ -125,7 +125,7 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ /** * Creates the action with the inner action and the rate parameter * - * @constructor + * Constructor of cc.EaseRateAction * @param {cc.ActionInterval} action * @param {Number} rate * @@ -681,7 +681,7 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ /** Creates the action with the inner action and the period in radians (default is 0.3) * - * @constructor + * Constructor of cc.EaseElastic * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index 1959e2a149..c5bbb0d5c5 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -169,7 +169,7 @@ cc.RemoveSelf = cc.ActionInstant.extend({ /** * Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. * - * @constructor + * Constructor of cc.RemoveSelf * @param {Boolean} [isNeedCleanUp=true] * * @example @@ -225,7 +225,7 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ /** * Create a FlipX action to flip or unflip the target * - * @constructor + * Constructor of cc.FlipX * @param {Boolean} flip Indicate whether the target should be flipped or not * * @example @@ -290,7 +290,7 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{ /** * Create a FlipY action to flip or unflip the target * - * @constructor + * Constructor of cc.FlipY * @param {Boolean} flip * @example * var flipYAction = new cc.FlipY(true); @@ -355,7 +355,7 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ /** * Creates a Place action with a position * - * @constructor + * Constructor of cc.Place * @param {cc.Point|Number} pos * @param {Number} [y] * @example @@ -427,7 +427,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ /** * Creates a CallFunc action with the callback * - * @constructor + * Constructor of cc.CallFunc * @param {function} selector * @param {object|null} [selectorTarget] * @param {*|null} [data] data for function, it accepts all data types. diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 3cbd0ffc48..a2d75049d5 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -54,7 +54,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _speedMethod: false,//Compatible with speed class, Discard after can be deleted /** - * @constructor + * constructor of cc.ActionInterval * @param {Number} d duration in seconds * @example * var actionInterval = new cc.ActionInterval(3); @@ -308,7 +308,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ _last:0, /** Create an array of sequenceable actions - * @constructor + * Constructor of cc.Sequence * @param {Array|cc.FiniteTimeAction} tempArray * @example * // create sequence with actions @@ -497,7 +497,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ /** * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) - * @constructor + * Constructor of cc.Repeat * @param {cc.FiniteTimeAction} action * @param {Number} times * @example @@ -771,7 +771,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ _two:null, /** - * @constructor + * Constructor of cc.Spawn * @param {Array|cc.FiniteTimeAction} tempArray * @example * var action = new cc.Spawn(cc.JumpBy.create(2, cc.p(300, 0), 50, 4), cc.RotateBy.create(2, 720)); @@ -929,7 +929,7 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ /** * Creates a RotateTo action with x and y rotation angles - * @constructor + * Constructor of cc.RotateTo * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees. * @param {Number} [deltaAngleY] deltaAngleY in degrees. @@ -1039,7 +1039,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ _startAngleY:0, /** - * @constructor + * Constructor of cc.RotateBy * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY] deltaAngleY in degrees @@ -1141,7 +1141,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ _previousPosition:null, /** - * @constructor + * Constructor of cc.MoveBy * @param {Number} duration duration in seconds * @param {cc.Point|Number} deltaPos * @param {Number} [deltaY] @@ -1265,7 +1265,7 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ _endPosition:null, /** - * @constructor + * Constructor of cc.MoveTo * @param {Number} duration duration in seconds * @param {cc.Point|Number} position * @param {Number} y @@ -1348,7 +1348,7 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ _deltaY:0, /** - * @constructor + * Constructor of cc.SkewTo * @param {Number} t time in seconds * @param {Number} sx * @param {Number} sy @@ -1438,7 +1438,7 @@ cc.SkewTo.create = function (t, sx, sy) { cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ /** - * @constructor + * Constructor of cc.SkewBy * @param {Number} t time in seconds * @param {Number} sx skew in degrees for X axis * @param {Number} sy skew in degrees for Y axis @@ -1525,7 +1525,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ _previousPosition:null, /** - * @constructor + * Constructor of JumpBy * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -1721,7 +1721,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ _previousPosition:null, /** - * @constructor + * Constructor of BezierBy * @param {Number} t time in seconds * @param {Array} c Array of points * @example @@ -1855,7 +1855,7 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ _toConfig:null, /** - * @constructor + * Constructor of cc.BezierTo * @param {Number} t * @param {Array} c array of points * @example @@ -1936,7 +1936,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ _deltaY:0, /** - * @constructor + * Constructor of cc.ScaleTo * @param {Number} duration * @param {Number} sx scale parameter in X * @param {Number} [sy] scale parameter in Y, if Null equal to sx @@ -2080,9 +2080,9 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ _originalState:false, /** - * @constructor - * @param {Number} duration duration in seconds - * @param (Number) blinks blinks in times + * Constructor of cc.Blink + * @param {Number} duration duration in seconds + * @param {Number} blinks blinks in times * @example * var action = new cc.Blink(2, 10); */ @@ -2171,7 +2171,7 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ _fromOpacity:0, /** - * @constructor + * Constructor of cc.FadeTo * @param {Number} duration * @param {Number} opacity 0-255, 0 is transparent * @example @@ -2347,7 +2347,7 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ _from:null, /** - * @constructor + * Constructor of cc.TintTo * @param {Number} duration * @param {Number} red 0-255 * @param {Number} green 0-255 @@ -2443,7 +2443,7 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ _fromB:0, /** - * @constructor + * Constructor of cc.TintBy * @param {Number} duration duration in seconds * @param {Number} deltaRed * @param {Number} deltaGreen @@ -2592,7 +2592,7 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ _other:null, /** - * @constructor + * Constructor of cc.ReverseTime * @param {cc.FiniteTimeAction} action * @example * var reverse = new cc.ReverseTime(this); @@ -2690,7 +2690,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ _splitTimes:null, /** - * @constructor + * Constructor of cc.Animate * create the animate with animation * @param {cc.Animation} animation * @example @@ -2869,7 +2869,7 @@ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{ /** * Create an action with the specified action and forced target - * @constructor + * Constructor of cc.TargetedAction * @param {cc.Node} target * @param {cc.FiniteTimeAction} action */ diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index 90283f9bb4..ae3b52a406 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -58,7 +58,7 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ /** * Creates an initializes the action with the property name (key), and the from and to parameters. - * @constructor + * Constructor of cc.ActionTween * @param {Number} duration * @param {String} key * @param {Number} from diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index 00e9c0309d..36e03617b7 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -34,7 +34,7 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ /** * Creates a grid action with duration and grid size - * @constructor + * Constructor of cc.GridAction * @param {Number} duration * @param {cc.Size} gridSize */ @@ -253,7 +253,7 @@ cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{ /** * creates an action with the number of times that the current grid will be reused - * @constructor + * Constructor of cc.ReuseGrid * @param {Number} times */ ctor: function(times) { diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index 8123111759..2945f6a411 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -133,7 +133,7 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ /** * Create a Flip X 3D action with duration - * @constructor + * Constructor of cc.FlipX3D * @param {Number} duration */ ctor: function(duration) { @@ -247,7 +247,7 @@ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ /** * Create a flip Y 3d action with duration - * @constructor + * Constructor of cc.FlipY3D * @param {Number} duration */ ctor: function(duration) { @@ -346,7 +346,7 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ /** * creates a lens 3d action with center position, radius - * @constructor + * Constructor of cc.Lens3D * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -492,7 +492,7 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ /** * creates a ripple 3d action with radius, number of waves, amplitude - * @constructor + * Constructor of cc.Ripple3D * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -629,7 +629,7 @@ cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{ /** * Create a shaky3d action with a range, shake Z vertices - * @constructor + * Constructor of cc.Shaky3D * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -700,8 +700,7 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ /** * Create a liquid action with amplitude, a grid and duration - * - * @constructor + * Constructor of cc.Liquid * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -805,8 +804,7 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ /** * Create a wave action with amplitude, horizontal sin, vertical sin, a grid and duration - * - * @constructor + * Constructor of cc.Waves * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -922,8 +920,7 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ /** * Create a grid 3d action with center position, number of twirls, amplitude, a grid size and duration - * - * @constructor + * Constructor of cc.Twirl * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index 821eb9e6f6..a4981dded6 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -35,7 +35,7 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ /** * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration - * @constructor + * Constructor of cc.ShakyTiles3D * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -121,7 +121,7 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D /** * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration - * @constructor + * Constructor of cc.ShatteredTiles3D * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -225,7 +225,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ /** * creates the action with a random seed, the grid size and the duration - * @constructor + * Constructor of cc.ShuffleTiles * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} seed @@ -683,7 +683,7 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ /** * creates the action with a number of waves, the waves amplitude, the grid size and the duration - * @constructor + * Constructor of cc.WavesTiles3D * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -787,7 +787,7 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ /** * creates the action with the number of jumps, the sin amplitude, the grid size and the duration - * @constructor + * Constructor of cc.JumpTiles3D * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} numberOfJumps @@ -904,7 +904,7 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ /** * creates the action with the number of rows to split and the duration - * @constructor + * Constructor of cc.SplitRows * @param {Number} duration * @param {Number} rows */ @@ -971,7 +971,7 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ /** * Creates the action with the number of columns to split and the duration - * @constructor + * Constructor of cc.SplitCols * @param {Number} duration * @param {Number} cols */ diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index a0a9bae0a9..fa22c26054 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -66,7 +66,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ /** * Creates and initializes a clipping node with an other node as its stencil. * The stencil node will be retained. - * @constructor + * Constructor of cc.ClippingNode * @param {cc.Node} [stencil=null] */ ctor: function (stencil) { diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 456ff248f4..d68ecbc2e6 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -187,7 +187,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ /** * cc.Timer's Constructor - * @constructor + * Constructor of cc.Timer * @param {cc.Class} target target * @param {String|function} callback Selector * @param {Number} [interval=0] second diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index fa3206ffc9..a3e5cd2b86 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -65,7 +65,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ /** * Creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render - * @constructor + * Constructor of cc.AtlasNode * @param {String} tile * @param {Number} tileWidth * @param {Number} tileHeight diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 19ee1bb5f7..a1e5e8b237 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -89,7 +89,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ /** * creates a cc.LabelTTF from a font name, alignment, dimension and font size - * @constructor + * Constructor of cc.LabelTTF * @param {String} text * @param {String|cc.FontDefinition} [fontName="Arial"] * @param {Number} [fontSize=16] diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index d4453f67ed..1d1d4e109b 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -39,7 +39,7 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ _className: "Layer", /** - * @constructor + * Constructor of cc.Layer */ ctor: function () { var nodep = cc.Node.prototype; @@ -91,7 +91,7 @@ cc.LayerRGBA = cc.Layer.extend(/** @lends cc.LayerRGBA# */{ _className: "LayerRGBA", /** - * @constructor + * Constructor of cc.LayerRGBA */ ctor: function () { cc.Layer.prototype.ctor.call(this); @@ -410,7 +410,7 @@ cc.LayerColor = cc.LayerRGBA.extend(/** @lends cc.LayerColor# */{ _isLighterMode: false, /** - * @constructor + * Constructor of cc.LayerColor * @function * @param {cc.Color} [color=] * @param {Number} [width=] @@ -585,7 +585,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ _className: "LayerGradient", /** - * @constructor + * Constructor of cc.LayerGradient * @param {cc.Color} start starting color * @param {cc.Color} end * @param {cc.Point|Null} v @@ -842,7 +842,7 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ _className: "LayerMultiplex", /** - * @constructor + * Constructor of cc.LayerMultiplex * @param {Array} layers an array of cc.Layer */ ctor: function (layers) { diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index bfeb0cc47a..a9c3a7d7dc 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -230,7 +230,6 @@ cc.getImageFormatByData = function (imgData) { // The following code was copied + pasted from goog.base / goog.inherits // cc.inherits = function (childCtor, parentCtor) { - /** @constructor */ function tempCtor() {} tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index ff0ecc329c..178cd63266 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -41,7 +41,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ _userInfo:null, /** - * @constructor + * Constructor of cc.AnimationFrame * @param spriteFrame * @param delayUnits * @param userInfo @@ -177,7 +177,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ /** * Creates an animation. - * @constructor + * Constructor of cc.Animation * @param {Array} frames * @param {Number} delay * @param {Number} [loops=1] diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 7145762d9f..e9aff59993 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -382,9 +382,10 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * creates a cc.SpriteBatchNodeCanvas with a file image (.png, .jpg etc) with a default capacity of 29 children.
* The capacity will be increased in 33% in runtime if it run out of space.
* The file will be loaded using the TextureMgr.
+ * Constructor of cc.SpriteBatchNode *

* @function - * @constructor + * * @param {String} fileImage * @param {Number} capacity * @example diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index f0b716f94e..6653a712a4 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -55,9 +55,10 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ /** *

* Create a cc.SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
- * The originalSize is the size in pixels of the frame before being trimmed. + * The originalSize is the size in pixels of the frame before being trimmed.
+ * Constructor of cc.SpriteFrame *

- * @constructor + * * @param {String|cc.Texture2D} filename * @param {cc.Rect} rect if parameters' length equal 2, rect in points, else rect in pixels * @param {Boolean} rotated diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index b91300a82b..5dac079e9f 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -59,7 +59,7 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ /** *

Creates a TextureAtlas with an filename and with an initial capacity for Quads.
* The TextureAtlas capacity can be increased in runtime.

- * @constructor + * Constructor of cc.TextureAtlas * @param {String|cc.Texture2D} fileName * @param {Number} capacity * @example diff --git a/cocos2d/core/textures/TexturesPropertyDefine.js b/cocos2d/core/textures/TexturesPropertyDefine.js index 1aadfb013a..fe1eef3801 100644 --- a/cocos2d/core/textures/TexturesPropertyDefine.js +++ b/cocos2d/core/textures/TexturesPropertyDefine.js @@ -37,7 +37,6 @@ cc._tmp.PrototypeTexture2D = function () { * By default it is disabled.
*

* @param haveAlphaPremultiplied - * @constructor */ _c.PVRImagesHavePremultipliedAlpha = function (haveAlphaPremultiplied) { cc.PVRHaveAlphaPremultiplied_ = haveAlphaPremultiplied; diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index 2389e82801..a07ba5ef69 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -45,7 +45,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ /** * create one cc.GridBase Object - * @constructor + * Constructor of cc.GridBase * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] @@ -299,7 +299,7 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ /** * create one Grid3D object - * @constructor + * Constructor of cc.Grid3D * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] @@ -508,7 +508,7 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ /** * create one TiledGrid3D object - * @constructor + * Constructor of cc.TiledGrid3D * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 307c88a60c..9b308760d3 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -129,7 +129,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ /** * creates a bitmap font atlas with an initial string and the FNT file - * @constructor + * Constructor of cc.LabelBMFont * @param {String} str * @param {String} fntFile * @param {Number} [width=-1] diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 6b8ec265f6..37fddb1581 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -66,7 +66,6 @@ cc.Menu = cc.LayerRGBA.extend(/** @lends cc.Menu# */{ /** * Constructor of cc.Menu - * @constructor * @function * @param {...cc.MenuItem|null} menuItems * diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 889e3741ca..d9d998cfc6 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -43,8 +43,7 @@ cc.MenuItem = cc.NodeRGBA.extend(/** @lends cc.MenuItem# */{ _className: "MenuItem", /** - * Constructor - * @constructor + * Constructor of cc.MenuItem * @param {function|String} callback * @param {cc.Node} target */ @@ -212,7 +211,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ _colorBackup: null, /** - * @constructor + * Constructor of cc.MenuItemLabel * @param {cc.Node} label * @param {function|String} selector * @param {cc.Node} target @@ -502,7 +501,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ _fontName: null, /** - * @constructor + * Constructor of cc.MenuItemFont * @param {String} value text for the menu item * @param {function|String} callback * @param {cc.Node} target @@ -669,7 +668,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ _disabledImage: null, /** - * @constructor + * Constructor of cc.MenuItemSprite * @param {Image|Null} normalSprite normal state image * @param {Image|Null} selectedSprite selected state image * @param {Image|cc.Node|Null} three disabled state image OR target node @@ -999,7 +998,7 @@ cc.MenuItemSprite.create = function (normalSprite, selectedSprite, three, four, cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ /** - * @constructor + * Constructor of cc.MenuItemImage * @param {string|null} normalImage * @param {string|null} selectedImage * @param {string|null} disabledImage @@ -1124,7 +1123,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ _color: null, /** - * @constructor + * Constructor of cc.MenuItemToggle * @example * // Example * //create a toggle item with 2 menu items (which you can then toggle between them later) diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index a3894e2a4f..cd575a6093 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -70,8 +70,8 @@ cc.MotionStreak = cc.NodeRGBA.extend(/** @lends cc.MotionStreak# */{ _className:"MotionStreak", /** - * creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename or texture - * @constructor + * creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename or texture
+ * Constructor of cc.MotionStreak * @param {Number} fade time to fade * @param {Number} minSeg minimum segment size * @param {Number} stroke stroke's width diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 503e5a469e..adbdc63f5f 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -68,7 +68,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ /** * initializes the particle system with the name of a file on disk (for a list of supported formats look at the cc.Texture2D class), a capacity of particles - * @constructor + * Constructor of cc.ParticleBatchNode * @param {String|cc.Texture2D} fileImage * @param {Number} capacity * @example diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 835e41ac95..197b883a36 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -299,7 +299,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * This plist files can be create manually or with Particle Designer:
* http://particledesigner.71squared.com/
*

- * @constructor + * Constructor of cc.ParticleSystem * @param {String|Number} plistFile */ ctor:function (plistFile) { diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 36d84e9040..1afaa0498c 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -43,7 +43,7 @@ _rotation:1, /** * Create a PhysicsSprite with filename and rect - * @constructor + * Constructor of cc.PhysicsSprite for Box2d * @param {String|cc.Texture2D|cc.SpriteFrame} fileName * @param {cc.Rect} rect * @example @@ -158,7 +158,7 @@ /** * Create a PhysicsSprite with filename and rect - * @constructor + * Constructor of cc.PhysicsSprite for chipmunk * @param {String|cc.Texture2D|cc.SpriteFrame} fileName * @param {cc.Rect} rect * @example @@ -366,7 +366,6 @@ /** * Create a PhysicsSprite with filename and rect - * @constructor * @param {String|cc.Texture2D|cc.SpriteFrame} fileName * @param {cc.Rect} rect * @return {cc.PhysicsSprite} diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index 454ca66e48..7354ca41ad 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -36,7 +36,7 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ /** * Creates a ProgressTo action with a duration and a percent - * @constructor + * Constructor of cc.ProgressTo * @param {Number} duration duration in seconds * @param {Number} percent * @example @@ -119,7 +119,7 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ /** * Creates and initializes the action with a duration, a "from" percentage and a "to" percentage - * @constructor + * Constructor of cc.ProgressFromTo * @param {Number} duration duration in seconds * @param {Number} fromPercentage * @param {Number} toPercentage diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index f7c206d216..565e81eb94 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -119,7 +119,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid - * @constructor + * Constructor of cc.RenderTexture for Canvas * @param {Number} width * @param {Number} height * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format @@ -147,7 +147,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid - * @constructor + * Constructor of * @param {Number} width * @param {Number} height * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 5ce0da3741..073b874f5d 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -95,8 +95,8 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ _drawColor: null, _className:"DrawNodeCanvas", - /* - * @constructor + /** + * Constructor of cc.DrawNode for Canvas */ ctor: function () { cc.Node.prototype.ctor.call(this); diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index 8bdff08f5f..8a993671c3 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -101,8 +101,8 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ _className:"TextFieldTTF", /** - * creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size - * @constructor + * creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size
+ * Constructor of cc.TextFieldTTF * @param {String} placeholder * @param {cc.Size} dimensions * @param {Number} alignment diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 29a81f9c1b..008910b239 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -92,8 +92,8 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ _className:"TMXLayer", /** - * Creates a cc.TMXLayer with an tile set info, a layer info and a map info - * @constructor + * Creates a cc.TMXLayer with an tile set info, a layer info and a map info
+ * Constructor of cc.TMXLayer * @param {cc.TMXTilesetInfo} tilesetInfo * @param {cc.TMXLayerInfo} layerInfo * @param {cc.TMXMapInfo} mapInfo diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index 80fec01956..ddfd9ff82a 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -119,9 +119,8 @@ cc.TMXTiledMap = cc.NodeRGBA.extend(/** @lends cc.TMXTiledMap# */{ _className: "TMXTiledMap", /** - * Creates a TMX Tiled Map with a TMX file or content string. - * Implementation cc.TMXTiledMap - * @constructor + * Creates a TMX Tiled Map with a TMX file or content string.
+ * Constructor of cc.TMXTiledMap * @param {String} tmxFile tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @example diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index 2fa881431f..909aadb93e 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -264,8 +264,8 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ _currentFirstGID:0, /** - * Creates a TMX Format with a tmx file or content string - * @constructor + * Creates a TMX Format with a tmx file or content string
+ * Constructor of cc.TMXMapInfo * @param {String} tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @example diff --git a/cocos2d/tilemap/CCTileMapAtlas.js b/cocos2d/tilemap/CCTileMapAtlas.js index 9fe38f92cc..ecfb854d56 100644 --- a/cocos2d/tilemap/CCTileMapAtlas.js +++ b/cocos2d/tilemap/CCTileMapAtlas.js @@ -56,8 +56,10 @@ cc.TileMapAtlas = cc.AtlasNode.extend(/** @lends cc.TileMapAtlas# */{ /** *

Creates a cc.TileMap with a tile file (atlas) with a map file and the width and height of each tile in points.
- * The tile file will be loaded using the TextureMgr.

- * @constructor + * The tile file will be loaded using the TextureMgr.
+ * Constructor of cc.TileMapAtlas + *

+ * * @param {String} tile * @param {String} mapFile * @param {Number} tileWidth diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 3afae82447..09e0da33b5 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -82,7 +82,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ /** * creates a base transition with duration and incoming scene - * @constructor + * Constructor of cc.TransitionScene * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to transit with */ diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 029a82fddf..c5021ce803 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -63,7 +63,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * allocates and initializes a UILayout. - * @constructor + * Constructor of ccui.Layout * @example * // example * var uiLayout = new ccui.Layout(); diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 5525afd3d8..02ea4673e8 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -69,7 +69,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * allocates and initializes a UIButton. - * @constructor + * Constructor of ccui.Button * @example * // example * var uiButton = new ccui.Button(); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 410b8c5946..67c44ceb67 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -53,7 +53,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ /** * allocates and initializes a UICheckBox. - * @constructor + * Constructor of ccui.CheckBox * @example * // example * var uiCheckBox = new ccui.CheckBox(); diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 3610e8682e..8c8d0e403e 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -40,7 +40,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ /** * allocates and initializes a UIImageView. - * @constructor + * Constructor of ccui.ImageView * @example * // example * var uiImageView = new ccui.ImageView; diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 3d5af75ecf..a190a58800 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -47,7 +47,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ /** * allocates and initializes a UILoadingBar. - * @constructor + * Constructor of ccui.LoadingBar * @example * // example * var uiLoadingBar = new ccui.LoadingBar; diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 161a8ef15f..8892664e12 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -168,7 +168,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ /** * create a rich text - * @constructor + * Constructor of ccui.RichText * @example * var uiRichText = new ccui.RichTex(); */ diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 9b78ca4cdd..54fadedac5 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -60,7 +60,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _className: "Slider", /** * allocates and initializes a UISlider. - * @constructor + * Constructor of ccui.Slider * @example * // example * var uiSlider = new ccui.Slider(); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index ee3532ccb1..104fdd35fb 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -54,7 +54,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ /** * allocates and initializes a UILabel. - * @constructor + * Constructor of ccui.Text * @example * // example * var uiLabel = new ccui.Text(); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 3e31b4e7c7..31045c0a5f 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -41,7 +41,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ /** * allocates and initializes a UILabelAtlas. - * @constructor + * Constructor of ccui.TextAtlas * @example * // example * var uiLabelAtlas = new ccui.TextAtlas(); diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 3b22677e88..27de310636 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -39,7 +39,7 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ /** * allocates and initializes a UILabelBMFont. - * @constructor + * Constructor of ccui.TextBMFont * @example * // example * var uiLabelBMFont = new ccui.TextBMFont(); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index ff8d27cc39..9ad9385080 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -270,7 +270,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * allocates and initializes a UITextField. - * @constructor + * Constructor of ccui.TextField * @example * // example * var uiTextField = new ccui.TextField(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 72ba5d74d3..7b738bc86e 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -40,7 +40,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ _className:"ListView", /** * allocates and initializes a UIListView. - * @constructor + * Constructor of ccui.ListView * @example * // example * var uiPageView = new ccui.ListView(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index d3a5ea775e..aa62595010 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -49,7 +49,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _className:"PageView", /** * allocates and initializes a UIPageView. - * @constructor + * Constructor of ccui.PageView * @example * // example * var uiPageView = new ccui.PageView(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 61c074ce3a..9ef2e5ea4f 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -75,7 +75,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _className: "ScrollView", /** * allocates and initializes a UIScrollView. - * @constructor + * Constructor of ccui.ScrollView * @example * // example * var uiScrollView = new ccui.ScrollView(); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 8ca2af9361..080c24cc56 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -57,7 +57,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ /** * Create a armature node. - * @constructor + * Constructor of ccs.Armature * @param {String} name * @param {ccs.Bone} parentBone * @example From 9a783164456f978ffd9c41e852b0e65e3b9ebc96 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 May 2014 21:52:40 +0800 Subject: [PATCH 0133/1564] Issue #5364: Change setText to setString --- extensions/ccui/uiwidgets/UIText.js | 27 +++++++++++++-- extensions/ccui/uiwidgets/UITextAtlas.js | 12 ++++++- extensions/ccui/uiwidgets/UITextBMFont.js | 21 ++++++++++-- extensions/ccui/uiwidgets/UITextField.js | 41 +++++++++++++++++++++-- extensions/cocostudio/reader/GUIReader.js | 16 ++++----- extensions/editbox/CCEditBox.js | 30 ++++++++++++++++- 6 files changed, 128 insertions(+), 19 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 104fdd35fb..55d19c2d9a 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -77,19 +77,40 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Changes the value of label. + * Changes the value of label. + * @deprecated * @param {String} text */ setText: function (text) { + cc.log("Please use the setString"); + this._labelRenderer.setString(text); + this.labelScaleChangedWithSize(); + }, + + /** + * Changes the value of label. + * @param {String} text + */ + setString: function (text) { this._labelRenderer.setString(text); this.labelScaleChangedWithSize(); }, /** * Gets the string value of label. + * @deprecated * @returns {String} */ getStringValue: function () { + cc.log("Please use the getString"); + return this._labelRenderer.getString(); + }, + + /** + * Gets the string value of label. + * @returns {String} + */ + getString: function () { return this._labelRenderer.getString(); }, @@ -363,7 +384,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ copySpecialProperties: function (uiLabel) { this.setFontName(uiLabel._fontName); this.setFontSize(uiLabel._labelRenderer.getFontSize()); - this.setText(uiLabel.getStringValue()); + this.setString(uiLabel.getString()); this.setTouchScaleChangeEnabled(uiLabel.touchScaleEnabled); this.setTextAreaSize(uiLabel._size); this.setTextHorizontalAlignment(uiLabel._textHorizontalAlignment); @@ -382,7 +403,7 @@ _p.boundingHeight; cc.defineGetterSetter(_p, "boundingHeight", _p._getBoundingHeight, _p._setBoundingHeight); /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getStringValue, _p.setText); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); /** @expose */ _p.stringLength; cc.defineGetterSetter(_p, "stringLength", _p.getStringLength); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 31045c0a5f..3313d989e7 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -93,9 +93,19 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ /** * get string value for labelatlas. + * @deprecated * @returns {String} */ getStringValue: function () { + cc.log("Please use the getString"); + return this._labelAtlasRenderer.getString(); + }, + + /** + * get string value for labelatlas. + * @returns {String} + */ + getString: function () { return this._labelAtlasRenderer.getString(); }, @@ -199,7 +209,7 @@ var _p = ccui.TextAtlas.prototype; // Extended properties /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getStringValue, _p.setStringValue); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setStringValue); _p = null; diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 27de310636..c5518e71d2 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -65,7 +65,7 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ this.updateAnchorPoint(); this.labelBMFontScaleChangedWithSize(); this._fileHasInit = true; - this.setText(this._stringValue); + this.setString(this._stringValue); if (!this._labelBMFontRenderer.textureLoaded()) { this._labelBMFontRenderer.addLoadedEventListener(function () { @@ -76,9 +76,24 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ /** * set string value for labelbmfont + * @deprecated * @param {String} value */ setText: function (value) { + cc.log("Please use the setString"); + if (!value) { + return; + } + this._stringValue = value; + this._labelBMFontRenderer.setString(value); + this.labelBMFontScaleChangedWithSize(); + }, + + /** + * set string value for labelbmfont + * @param {String} value + */ + setString: function (value) { if (!value) { return; } @@ -91,7 +106,7 @@ ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ * get string value for labelbmfont. * @returns {String} */ - getStringValue: function () { + getString: function () { return this._stringValue; }, @@ -196,7 +211,7 @@ var _p = ccui.TextBMFont.prototype; // Extended properties /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getStringValue, _p.setStringValue); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setStringValue); _p = null; diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 9ad9385080..dc31027aa5 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -310,9 +310,34 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * Changes the string value of textField. + * @deprecated * @param {String} text */ setText: function (text) { + cc.log("Please use the setString"); + if (!text) { + return; + } + text = String(text); + if (this.isMaxLengthEnabled()) { + text = text.substr(0, this.getMaxLength()); + } + if (this.isPasswordEnabled()) { + this._textFieldRender.setPasswordText(text); + this._textFieldRender.insertText(text, text.length); + } + else { + this._textFieldRender.setString(text); + } + this._textFieldRender.setString(text); + this.textfieldRendererScaleChangedWithSize(); + }, + + /** + * Changes the string value of textField. + * @param {String} text + */ + setString: function (text) { if (!text) { return; } @@ -398,9 +423,19 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * get textField string value + * @deprecated * @returns {String} */ getStringValue: function () { + cc.log("Please use the getString"); + return this._textFieldRender.getString(); + }, + + /** + * get textField string value + * @returns {String} + */ + getString: function () { return this._textFieldRender.getString(); }, @@ -706,8 +741,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, copySpecialProperties: function (textField) { - this.setText(textField._textFieldRender.getString()); - this.setPlaceHolder(textField.getStringValue()); + this.setString(textField._textFieldRender.getString()); + this.setPlaceHolder(textField.getString()); this.setFontSize(textField._textFieldRender.getFontSize()); this.setFontName(textField._textFieldRender.getFontName()); this.setMaxLengthEnabled(textField.isMaxLengthEnabled()); @@ -726,7 +761,7 @@ var _p = ccui.TextField.prototype; // Extended properties /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getStringValue, _p.setText); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setText); /** @expose */ _p.placeHolder; cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder); diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index feec1364a6..da642efd68 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -447,7 +447,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var touchScaleChangeAble = options["touchScaleEnable"]; label.setTouchScaleChangeEnabled(touchScaleChangeAble); var text = options["text"]; - label.setText(text); + label.setString(text); if (options["fontSize"] !== undefined) { label.setFontSize(options["fontSize"]); } @@ -622,7 +622,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ setPropsForTextAreaFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var textArea = widget; - textArea.setText(options["text"]); + textArea.setString(options["text"]); if (options["fontSize"] !== undefined) { textArea.setFontSize(options["fontSize"]); } @@ -668,7 +668,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ if (options["placeHolder"] !== undefined) { textField.setPlaceHolder(options["placeHolder"]); } - textField.setText(options["text"]); + textField.setString(options["text"]); if (options["fontSize"] !== undefined) { textField.setFontSize(options["fontSize"]); } @@ -732,7 +732,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var cmf_tp = this._filePath + cmft; labelBMFont.setFntFile(cmf_tp); var text = options["text"]; - labelBMFont.setText(text); + labelBMFont.setString(text); this.setColorPropsForWidgetFromJsonDictionary(widget, options); } }); @@ -1182,7 +1182,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var touchScaleChangeAble = options["touchScaleEnable"]; label.setTouchScaleChangeEnabled(touchScaleChangeAble); var text = options["text"]; - label.setText(text); + label.setString(text); if (options["fontSize"] !== undefined) { label.setFontSize(options["fontSize"]); } @@ -1428,7 +1428,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ setPropsForTextAreaFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var textArea = widget; - textArea.setText(options["text"]); + textArea.setString(options["text"]); if (options["fontSize"] !== undefined) { textArea.setFontSize(options["fontSize"]); } @@ -1474,7 +1474,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ if (options["placeHolder"] !== undefined) { textField.setPlaceHolder(options["placeHolder"]); } - textField.setText(options["text"]); + textField.setString(options["text"]); if (options["fontSize"] !== undefined) { textField.setFontSize(options["fontSize"]); } @@ -1588,7 +1588,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ cmftDic = null; var text = options["text"]; - labelBMFont.setText(text); + labelBMFont.setString(text); this.setColorPropsForWidgetFromJsonDictionary(widget, options); } diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 9feb9b9c42..51a3051f98 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -343,9 +343,27 @@ cc.EditBox = cc.ControlButton.extend({ /** * Set the text entered in the edit box. + * @deprecated * @param {string} text The given text. */ setText: function (text) { + cc.log("Please use the setString"); + if (text != null) { + if (text == "") { + this._edTxt.value = this._placeholderText; + this._edTxt.style.color = cc.colorToHex(this._placeholderColor); + } else { + this._edTxt.value = text; + this._edTxt.style.color = cc.colorToHex(this._textColor); + } + } + }, + + /** + * Set the text entered in the edit box. + * @param {string} text The given text. + */ + setString: function (text) { if (text != null) { if (text == "") { this._edTxt.value = this._placeholderText; @@ -476,9 +494,19 @@ cc.EditBox = cc.ControlButton.extend({ /** * Gets the input string of the edit box. + * @deprecated * @return {string} */ getText: function () { + cc.log("Please use the getString"); + return this._edTxt.value; + }, + + /** + * Gets the input string of the edit box. + * @return {string} + */ + getString: function () { return this._edTxt.value; }, @@ -592,7 +620,7 @@ _p.fontColor; cc.defineGetterSetter(_p, "fontColor", null, _p.setFontColor); /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getText, _p.setText); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); /** @expose */ _p.maxLength; cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength); From 45be31918e651c4e29a5f06171dd0daead692adb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 27 May 2014 15:05:54 +0800 Subject: [PATCH 0134/1564] Add engine version --- cocos2d/core/platform/CCConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 712fa11d75..21627f37d4 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -33,7 +33,7 @@ * @constant * @type String */ -cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 beta"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 beta"; /** *

From b1a978ea2d7a4467bad0135057084a435850c04e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 29 May 2014 14:36:03 +0800 Subject: [PATCH 0135/1564] Issue #5410: Creating new actions --- cocos2d/actions/CCActionEase.js | 714 ++++++++++++++++++++++++++++++++ 1 file changed, 714 insertions(+) diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index abbd959d6c..80ce8f69f5 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -1400,3 +1400,717 @@ cc.easeBackInOut = function(){ return cc._easeBackInOutObj; }; +/** + * cc.EaseBezierAction action. + * @type {Function|*} + */ +cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ + + _p0: null, + _p1: null, + _p2: null, + _p3: null, + + ctor: function(action){ + cc.ActionEase.prototype.ctor.call(this, action); + }, + + _updateTime: function(a, b, c, d, t){ + return (Math.pow(1-t,3) * a + 3*t*(Math.pow(1-t,2))*b + 3*Math.pow(t,2)*(1-t)*c + Math.pow(t,3)*d ); + }, + + update: function(time){ + var t = this._updateTime(this._p0, this._p1, this._p2, this._p3, time); + this._inner.update(t); + }, + clone: function(){ + var action = new cc.EaseBezierAction(); + action.initWithAction(this._inner.clone()); + action.setBezierParamer(this._p0, this._p1, this._p2, this._p3); + return action; + }, + reverse: function(){ + var action = cc.EaseBezierAction.create(this._inner.reverse()); + action.setBezierParamer(this._p3, this._p2, this._p1, this._p0); + return action; + }, + setBezierParamer: function(p0, p1, p2, p3){ + this._p0 = p0 || 0; + this._p1 = p1 || 0; + this._p2 = p2 || 0; + this._p3 = p3 || 0; + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionIn} + */ +cc.EaseBezierAction.create = function(action){ + return new cc.EaseBezierAction(action); +}; + +cc.easeBezierAction = function(p0, p1, p2, p3){ + return { + easing: function(time){ + return cc.EaseBezierAction.prototype._updateTime(p0, p1, p2, p3, time); + }, + reverse: function(){ + return cc.easeBezierAction(p3, p2, p1, p0); + } + }; +}; + + +/** + * cc.EaseQuadraticActionIn action. + * @type {Function|*} + */ +cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionIn# */{ + + _updateTime: function(time){ + return Math.pow(time, 2); + }, + + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + + clone: function(){ + var action = new cc.EaseQuadraticActionIn(); + action.initWithAction(this._inner.clone()); + return action; + }, + + reverse: function(){ + return cc.EaseQuadraticActionIn.create(this._inner.reverse()); + } + +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionIn} + */ +cc.EaseQuadraticActionIn.create = function(action){ + return new cc.EaseQuadraticActionIn(action); +}; + +cc._easeQuadraticActionIn = { + easing: cc.EaseQuadraticActionIn.prototype._updateTime, + reverse: function(){ + return cc._easeQuadraticActionIn; + } +}; + +cc.easeQuadraticActionIn = function(){ + return cc._easeQuadraticActionIn; +}; + +/** + * cc.EaseQuadraticActionIn action. + * @type {Function|*} + */ +cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionOut# */{ + + _updateTime: function(time){ + return -time*(time-2); + }, + + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuadraticActionOut(); + action.initWithAction(); + return action; + }, + reverse: function(){ + return cc.EaseQuadraticActionOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuadraticActionOut.create = function(action){ + return new cc.EaseQuadraticActionOut(action); +}; + +cc._easeQuadraticActionOut = { + easing: cc.EaseQuadraticActionOut.prototype._updateTime, + reverse: function(){ + return cc._easeQuadraticActionOut; + } +}; + +cc.easeQuadraticActionOut = function(){ + return cc._easeQuadraticActionOut; +}; + +/** + * cc.EaseQuadraticActionInOut action. + * @type {Function|*} + */ +cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionInOut# */{ + _updateTime: function(time){ + var resultTime = time; + time *= 2; + if(time < 1){ + resultTime = time * time * 0.5; + }else{ + --time; + resultTime = -0.5 * ( time * ( time - 2 ) - 1) + } + return resultTime; + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuadraticActionInOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseQuadraticActionInOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuadraticActionInOut.create = function(action){ + return new cc.EaseQuadraticActionInOut(action); +}; + +cc._easeQuadraticActionInOut = { + easing: cc.EaseQuadraticActionInOut.prototype._updateTime, + reverse: function(){ + return cc._easeQuadraticActionInOut; + } +}; + +cc.easeQuadraticActionInOut = function(){ + return cc._easeQuadraticActionInOut; +}; + +/** + * cc.EaseQuarticActionIn action. + * @type {Function|*} + */ +cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# */{ + _updateTime: function(time){ + return time * time * time * time; + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuarticActionIn(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseQuarticActionIn.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuarticActionIn.create = function(action){ + return new cc.EaseQuarticActionIn(action); +}; + +cc._easeQuarticActionIn = { + easing: cc.EaseQuarticActionIn.prototype._updateTime, + reverse: function(){ + return cc._easeQuarticActionIn; + } +}; + +cc.easeQuarticActionIn = function(){ + return cc._easeQuarticActionIn; +}; + +/** + * cc.EaseQuarticActionOut action. + * @type {Function|*} + */ +cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOut# */{ + _updateTime: function(time){ + time -= 1; + return -(time * time * time * time - 1); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuarticActionOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseQuarticActionOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuarticActionOut.create = function(action){ + return new cc.EaseQuarticActionOut(action); +}; + +cc._easeQuarticActionOut = { + easing: cc.EaseQuarticActionOut.prototype._updateTime, + reverse: function(){ + return cc._easeQuarticActionOut; + } +}; + +cc.easeQuarticActionOut = function(){ + return cc._easeQuarticActionOut; +}; + +/** + * cc.EaseQuarticActionInOut action. + * @type {Function|*} + */ +cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionInOut# */{ + _updateTime: function(time){ + time = time*2; + if (time < 1) + return 0.5 * time * time * time * time; + time -= 2; + return -0.5 * (time * time * time * time - 2); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuarticActionInOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseQuarticActionInOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuarticActionInOut.create = function(action){ + return new cc.EaseQuarticActionInOut(action); +}; + +cc._easeQuarticActionInOut = { + easing: cc.EaseQuarticActionInOut.prototype._updateTime, + reverse: function(){ + return cc._easeQuarticActionInOut; + } +}; + +cc.easeQuarticActionInOut = function(){ + return cc._easeQuarticActionInOut; +}; + +/** + * cc.EaseQuinticActionIn action. + * @type {Function|*} + */ +cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# */{ + _updateTime: function(time){ + return time * time * time * time * time; + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuinticActionIn(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseQuinticActionIn.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuinticActionIn.create = function(action){ + return new cc.EaseQuinticActionIn(action); +}; + +cc._easeQuinticActionIn = { + easing: cc.EaseQuinticActionIn.prototype._updateTime, + reverse: function(){ + return cc._easeQuinticActionIn; + } +}; + +cc.easeQuinticActionIn = function(){ + return cc._easeQuinticActionIn; +}; + +/** + * cc.EaseQuinticActionOut action. + * @type {Function|*} + */ +cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOut# */{ + _updateTime: function(time){ + time -=1; + return (time * time * time * time * time + 1); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuinticActionOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseQuinticActionOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuinticActionOut.create = function(action){ + return new cc.EaseQuinticActionOut(action); +}; + +cc._easeQuinticActionOut = { + easing: cc.EaseQuinticActionOut.prototype._updateTime, + reverse: function(){ + return cc._easeQuinticActionOut; + } +}; + +cc.easeQuinticActionOut = function(){ + return cc._easeQuinticActionOut; +}; + +/** + * cc.EaseQuinticActionInOut action. + * @type {Function|*} + */ +cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionInOut# */{ + _updateTime: function(time){ + time = time*2; + if (time < 1) + return 0.5 * time * time * time * time * time; + time -= 2; + return 0.5 * (time * time * time * time * time + 2); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseQuinticActionInOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseQuinticActionInOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseQuinticActionInOut.create = function(action){ + return new cc.EaseQuinticActionInOut(action); +}; + +cc._easeQuinticActionInOut = { + easing: cc.EaseQuinticActionInOut.prototype._updateTime, + reverse: function(){ + return cc._easeQuinticActionInOut; + } +}; + +cc.easeQuinticActionInOut = function(){ + return cc._easeQuinticActionInOut; +}; + +/** + * cc.EaseCircleActionIn action. + * @type {Function|*} + */ +cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# */{ + _updateTime: function(time){ + return -1 * (Math.sqrt(1 - time * time) - 1); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseCircleActionIn(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseCircleActionIn.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseCircleActionIn.create = function(action){ + return new cc.EaseCircleActionIn(action); +}; + +cc._easeCircleActionIn = { + easing: cc.EaseCircleActionIn.prototype._updateTime, + reverse: function(){ + return cc._easeCircleActionIn; + } +}; + +cc.easeCircleActionIn = function(){ + return cc._easeCircleActionIn; +}; + +/** + * cc.EaseCircleActionOut action. + * @type {Function|*} + */ +cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# */{ + _updateTime: function(time){ + time = time - 1; + return Math.sqrt(1 - time * time); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseCircleActionOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseCircleActionOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseCircleActionOut.create = function(action){ + return new cc.EaseCircleActionOut(action); +}; + +cc._easeCircleActionOut = { + easing: cc.EaseCircleActionOut.prototype._updateTime, + reverse: function(){ + return cc._easeCircleActionOut; + } +}; + +cc.easeCircleActionOut = function(){ + return cc._easeCircleActionOut; +}; + +/** + * cc.EaseCircleActionInOut action. + * @type {Function|*} + */ +cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionInOut# */{ + _updateTime: function(time){ + time = time * 2; + if (time < 1) + return -0.5 * (Math.sqrt(1 - time * time) - 1); + time -= 2; + return 0.5 * (Math.sqrt(1 - time * time) + 1); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseCircleActionInOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseCircleActionInOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseCircleActionInOut.create = function(action){ + return new cc.EaseCircleActionInOut(action); +}; + +cc._easeCircleActionInOut = { + easing: cc.EaseCircleActionInOut.prototype._updateTime, + reverse: function(){ + return cc._easeCircleActionInOut; + } +}; + +cc.easeCircleActionInOut = function(){ + return cc._easeCircleActionInOut; +}; + +/** + * cc.EaseCubicActionIn action. + * @type {Function|*} + */ +cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{ + _updateTime: function(time){ + return time * time * time; + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseCubicActionIn(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseCubicActionIn.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseCubicActionIn.create = function(action){ + return new cc.EaseCubicActionIn(action); +}; + +cc._easeCubicActionIn = { + easing: cc.EaseCubicActionIn.prototype._updateTime, + reverse: function(){ + return cc._easeCubicActionIn; + } +}; + +cc.easeCubicActionIn = function(){ + return cc._easeCubicActionIn; +}; + +/** + * cc.EaseCubicActionOut action. + * @type {Function|*} + */ +cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# */{ + _updateTime: function(time){ + time -= 1; + return (time * time * time + 1); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseCubicActionOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseCubicActionOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseCubicActionOut.create = function(action){ + return new cc.EaseCubicActionOut(action); +}; + +cc._easeCubicActionOut = { + easing: cc.EaseCubicActionOut.prototype._updateTime, + reverse: function(){ + return cc._easeCubicActionOut; + } +}; + +cc.easeCubicActionOut = function(){ + return cc._easeCubicActionOut; +}; + + +/** + * cc.EaseCubicActionInOut action. + * @type {Function|*} + */ +cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOut# */{ + _updateTime: function(time){ + time = time*2; + if (time < 1) + return 0.5 * time * time * time; + time -= 2; + return 0.5 * (time * time * time + 2); + }, + update: function(time){ + this._inner.update(this._updateTime(time)); + }, + clone: function(){ + var action = new cc.EaseCubicActionInOut(); + action.initWithAction(this._inner.clone()); + return action; + }, + reverse: function(){ + return cc.EaseCubicActionInOut.create(this._inner.reverse()); + } +}); + +/** + * creates the action + * @param action + * @returns {cc.EaseQuadraticActionOut} + */ +cc.EaseCubicActionInOut.create = function(action){ + return new cc.EaseCubicActionInOut(action); +}; + +cc._easeCubicActionInOut = { + easing: cc.EaseCubicActionInOut.prototype._updateTime, + reverse: function(){ + return cc._easeCubicActionInOut; + } +}; + +cc.easeCubicActionInOut = function(){ + return cc._easeCubicActionInOut; +}; + From 0cf4712cbf1c20928e721d0bfe9d0d4d3bd8517c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 29 May 2014 15:32:24 +0800 Subject: [PATCH 0136/1564] Closed #5375: fixed a bug of cc._audioLoader that it doesn't work when a audio file loads fail. --- CCBoot.js | 95 ++++++++------ cocos2d/audio/CCAudio.js | 133 ++++++++++++-------- cocos2d/core/layers/CCLayer.js | 4 +- cocos2d/core/platform/CCLoaders.js | 2 +- cocos2d/core/scenes/CCLoaderScene.js | 4 +- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/transitions/CCTransitionProgress.js | 2 +- 7 files changed, 146 insertions(+), 96 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index c64962bb8d..0a179a16d4 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -67,17 +67,19 @@ cc._isNodeJs = typeof require !== 'undefined' && require("fs"); * @param {object|array} obj * @param {function} iterator * @param {object} context - * @param {object} [context] */ cc.each = function (obj, iterator, context) { - if (!obj) return; + if (!obj) + return; if (obj instanceof Array) { for (var i = 0, li = obj.length; i < li; i++) { - if (iterator.call(context, obj[i], i) === false) return; + if (iterator.call(context, obj[i], i) === false) + return; } } else { for (var key in obj) { - if (iterator.call(context, obj[key], key) === false) return; + if (iterator.call(context, obj[key], key) === false) + return; } } }; @@ -106,25 +108,30 @@ cc.async = { // Counter for cc.async _counterFunc: function (err) { var counter = this.counter; - if (counter.err) return; + if (counter.err) + return; var length = counter.length; var results = counter.results; var option = counter.option; var cb = option.cb, cbTarget = option.cbTarget, trigger = option.trigger, triggerTarget = option.triggerTarget; if (err) { counter.err = err; - if (cb) return cb.call(cbTarget, err); + if (cb) + return cb.call(cbTarget, err); return; } var result = Array.apply(null, arguments).slice(1); var l = result.length; - if (l == 0) result = null; - else if (l == 1) result = result[0]; - else result = result; + if (l == 0) + result = null; + else if (l == 1) + result = result[0]; results[this.index] = result; counter.count--; - if (trigger) trigger.call(triggerTarget, result, length - counter.count, length); - if (counter.count == 0 && cb) cb.apply(cbTarget, [null, results]); + if (trigger) + trigger.call(triggerTarget, result, length - counter.count, length); + if (counter.count == 0 && cb) + cb.apply(cbTarget, [null, results]); }, // Empty function for async. @@ -140,24 +147,29 @@ cc.async = { parallel: function (tasks, option, cb) { var async = cc.async; if (cb !== undefined) { - if (typeof option == "function") option = {trigger: option}; + if (typeof option == "function") + option = {trigger: option}; option.cb = cb || option.cb; - } - else if (option !== undefined) { - if (typeof option == "function") option = {cb: option}; - } else if (tasks !== undefined) option = {}; - else throw "arguments error!"; + } else if (option !== undefined) { + if (typeof option == "function") + option = {cb: option}; + } else if (tasks !== undefined) + option = {}; + else + throw "arguments error!"; var isArr = tasks instanceof Array; var li = isArr ? tasks.length : Object.keys(tasks).length; if (li == 0) { - if (option.cb) option.cb.call(option.cbTarget, null); + if (option.cb) + option.cb.call(option.cbTarget, null); return; } var results = isArr ? [] : {}; var counter = { length: li, count: li, option: option, results: results}; cc.each(tasks, function (task, index) { - if (counter.err) return false; + if (counter.err) + return false; var counterFunc = !option.cb && !option.trigger ? async._emptyFunc : async._counterFunc.bind({counter: counter, index: index});//bind counter and index task(counterFunc, index); }); @@ -183,25 +195,26 @@ cc.async = { option = {iterator: option}; if (len === 3) option.cb = cb || option.cb; - else if (len == 2); - else + else if(len < 2) throw "arguments error!"; - if (typeof option == "function") option = {iterator: option}; + if (typeof option == "function") + option = {iterator: option}; if (cb !== undefined) option.cb = cb || option.cb; - else if (option !== undefined) - ; - else throw "arguments error!"; + else if (tasks === undefined ) + throw "arguments error!"; var isArr = tasks instanceof Array; var li = isArr ? tasks.length : Object.keys(tasks).length; - if (li == 0) { - if (option.cb) option.cb.call(option.cbTarget, null); + if (li === 0) { + if (option.cb) + option.cb.call(option.cbTarget, null); return; } var results = isArr ? [] : {}; var counter = { length: li, count: li, option: option, results: results}; cc.each(tasks, function (task, index) { - if (counter.err) return false; + if (counter.err) + return false; var counterFunc = !option.cb ? self._emptyFunc : self._counterFunc.bind({counter: counter, index: index});//bind counter and index option.iterator.call(option.iteratorTarget, task, index, counterFunc); }); @@ -211,7 +224,6 @@ cc.async = { //+++++++++++++++++++++++++something about path begin++++++++++++++++++++++++++++++++ cc.path = { - /** * Join strings to be a path. * @example @@ -246,6 +258,20 @@ cc.path = { return temp ? temp[1] : null; }, + /** + * Get the main name of a file name + * @param {string} fileName + * @returns {string} + */ + mainFileName: function(fileName){ + if(fileName){ + var idx = fileName.lastIndexOf("."); + if(idx !== -1) + return fileName.substring(0,idx); + } + return fileName + }, + /** * Get the file name of a file path. * @example @@ -604,6 +630,7 @@ cc.loader = { if (err) { cc.log(err); self.cache[url] = null; + delete self.cache[url]; cb(); } else { self.cache[url] = data; @@ -647,14 +674,12 @@ cc.loader = { if (cb !== undefined) { if (typeof option == "function") option = {trigger: option}; - } - else if (option !== undefined) { + } else if (option !== undefined) { if (typeof option == "function") { cb = option; option = {}; } - } - else if (res !== undefined) + } else if (res !== undefined) option = {}; else throw "arguments error!"; @@ -708,7 +733,7 @@ cc.loader = { *
*
*

- * @param {String} filename The plist file name. + * @param {String} url The plist file name. * @param {Function} [cb] callback */ loadAliases: function (url, cb) { @@ -722,7 +747,7 @@ cc.loader = { /** * Register a resource loader into loader. - * @param {string} extname + * @param {string} extNames * @param {function} loader */ register: function (extNames, loader) { diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 1ea81f65f5..afeb7c9cee 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -119,8 +119,10 @@ if (cc.sys._supportWebAudio) { _stop: function () { var self = this, sourceNode = self._sourceNode; if (self._stopped) return; - if (sourceNode.stop) sourceNode.stop(0); - else sourceNode.noteOff(0); + if (sourceNode.stop) + sourceNode.stop(0); + else + sourceNode.noteOff(0); self._stopped = true; }, play: function () { @@ -154,7 +156,8 @@ if (cc.sys._supportWebAudio) { }, load: function () { var self = this; - if (self._loadState == 1) return; + if (self._loadState == 1) + return; self._loadState = -1;//not loaded self.played = false; @@ -185,14 +188,18 @@ if (cc.sys._supportWebAudio) { self._buffer = buffer; var success = self._events["success"], canplaythrough = self._events["canplaythrough"]; - if (success) success(); - if (canplaythrough) canplaythrough(); - if (self._loadState == 0 || self.autoplay == "autoplay" || self.autoplay == true) self._play(); + if (success) + success(); + if (canplaythrough) + canplaythrough(); + if (self._loadState == 0 || self.autoplay == "autoplay" || self.autoplay == true) + self._play(); self._loadState = 1;//loaded }, _onError: function () { - var error = this._events["error"] - if (error) error(); + var error = this._events["error"]; + if (error) + error(); this._loadState = -2;//load failed }, cloneNode: function () { @@ -200,7 +207,8 @@ if (cc.sys._supportWebAudio) { obj.volume = self.volume; obj._loadState = self._loadState; obj._buffer = self._buffer; - if (obj._loadState == 0 || obj._loadState == -1) obj.load(); + if (obj._loadState == 0 || obj._loadState == -1) + obj.load(); return obj; } @@ -212,7 +220,8 @@ if (cc.sys._supportWebAudio) { return this._loop; }, function (loop) { this._loop = loop; - if (this._sourceNode) this._sourceNode.loop = loop; + if (this._sourceNode) + this._sourceNode.loop = loop; }); /** @expose */ _p.volume; @@ -239,7 +248,6 @@ if (cc.sys._supportWebAudio) { var sourceNode = this._sourceNode; return sourceNode && sourceNode["playbackState"] == 2; }); - } /** @@ -266,7 +274,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ ctor: function () { var self = this; self._soundSupported = cc._audioLoader._supportedAudioTypes.length > 0; - if (self._effectPauseCb) self._effectPauseCb = self._effectPauseCb.bind(self); + if (self._effectPauseCb) + self._effectPauseCb = self._effectPauseCb.bind(self); }, /** @@ -302,7 +311,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (!self._soundSupported) return; var audio = self._currMusic; - if (audio) this._stopAudio(audio); + if (audio) + this._stopAudio(audio); if (url != self._currMusicPath) { audio = self._getAudioByUrl(url); self._currMusic = audio; @@ -343,8 +353,10 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (this._musicPlayState > 0) { var audio = this._currMusic; if (!audio) return; - if (!this._stopAudio(audio)) return; - if (releaseData) cc.loader.release(this._currMusicPath); + if (!this._stopAudio(audio)) + return; + if (releaseData) + cc.loader.release(this._currMusicPath); this._currMusic = null; this._currMusicPath = null; this._musicPlayState = 0; @@ -404,7 +416,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ * cc.audioEngine.rewindMusic(); */ rewindMusic: function () { - if (this._currMusic) this._playMusic(this._currMusic); + if (this._currMusic) + this._playMusic(this._currMusic); }, /** @@ -450,7 +463,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ //effect begin _getEffectList: function (url) { var list = this._audioPool[url]; - if (!list) list = this._audioPool[url] = []; + if (!list) + list = this._audioPool[url] = []; return list; }, _getEffect: function (url) { @@ -463,7 +477,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (eff.ended) { audio = eff; audio.currentTime = 0; - if (window.chrome) audio.load(); + if (window.chrome) + audio.load(); break; } } @@ -473,9 +488,11 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ return null; } audio = self._getAudioByUrl(url); - if (!audio) return null; + if (!audio) + return null; audio = audio.cloneNode(true); - if (self._effectPauseCb) cc._addEventListener(audio, "pause", self._effectPauseCb); + if (self._effectPauseCb) + cc._addEventListener(audio, "pause", self._effectPauseCb); audio.volume = this._effectsVolume; effList.push(audio); } @@ -711,11 +728,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { return audioId; }, pauseEffect: function (effectId) { - cc.log("pauseEffect not supported in single audio mode!") -// var currEffect = this._currEffect; -// if(this._currEffectId != effectId || !currEffect || currEffect.ended) return; -// this._pausedEffIds.push(this._currEffectId); -// currEffect.pause(); + cc.log("pauseEffect not supported in single audio mode!"); }, pauseAllEffects: function () { var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds, currEffect = self._currEffect; @@ -728,20 +741,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { currEffect.pause(); }, resumeEffect: function (effectId) { - cc.log("resumeEffect not supported in single audio mode!") -// var self = this, currEffect = self._currEffect, pauseds = self._pausedEffIds; -// if(self._currEffectId == effectId) return;//the effect is playing -// var index = pauseds.indexOf(effectId); -// if(index >= 0){ -// pauseds.splice(index, 1);//delete item -// var eff = self._effects[effectId]; -// var expendTime = currEffect ? currEffect.currentTime - (currEffect.startTime || 0) : 0; -// if(eff && eff.currentTime + expendTime < eff.duration) { -// self._waitingEffIds.push(self._currEffectId); -// self._waitingEffIds.push(effectId); -// self._currEffect.pause(); -// } -// } + cc.log("resumeEffect not supported in single audio mode!"); }, resumeAllEffects: function () { var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; @@ -829,12 +829,14 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { for (var i = 0, li = waitings.length; i < li;) {//reset waitings if (effects[waitings[i]] == audio) { waitings.splice(i, 1); - } else i++; + } else + i++; } for (var i = 0, li = pauseds.length; i < li;) {//reset pauseds if (effects[pauseds[i]] == audio) { pauseds.splice(i, 1); - } else i++; + } else + i++; } audio._isToPlay = true;//custom flag return audio; @@ -842,7 +844,8 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { _stopAllEffects: function () { var self = this, currEffect = self._currEffect, audioPool = self._audioPool, sglCache = self._effectCache4Single, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; - if (!currEffect && waitings.length == 0 && pauseds.length == 0) return; + if (!currEffect && waitings.length == 0 && pauseds.length == 0) + return; for (var key in sglCache) { var eff = sglCache[key]; eff.duration && (eff.currentTime = eff.duration); @@ -881,7 +884,6 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { self._musicPlayState = 2; self._needToResumeMusic = false; } - ; }, _getWaitingEffToPlay: function () { var self = this, waitings = self._waitingEffIds, effects = self._effects, @@ -891,10 +893,12 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { self._expendTime4Music += expendTime; while (true) {//get a audio to play - if (waitings.length == 0) break; + if (waitings.length == 0) + break; var effId = waitings.pop(); var eff = effects[effId]; - if (!eff) continue; + if (!eff) + continue; if (eff._isToPlay || eff.loop || (eff.duration && eff.currentTime + expendTime < eff.duration)) { self._currEffectId = effId; self._currEffect = eff; @@ -944,11 +948,27 @@ cc._audioLoader = { getBasePath: function () { return cc.loader.audioPath; }, + /** + *

+ * pre-load the audio.
+ * note: If the preload audio type doesn't be supported on current platform, loader will use other audio format to try, but its key is still the origin audio format.
+ * for example: a.mp3 doesn't be supported on some browser, loader will load a.ogg, if a.ogg loads success, user still uses a.mp3 to play audio. + *

+ * @param {String} realUrl + * @param {String} url the key of the audio in the cc.loader.cache + * @param {Array|Null} res + * @param {Number} count + * @param {Array} tryArr the audio types were tried + * @param {cc.Audio} audio + * @param {function} cb callback + * @private + */ _load: function (realUrl, url, res, count, tryArr, audio, cb) { var self = this, locLoader = cc.loader, path = cc.path; var types = this._supportedAudioTypes; var extname = ""; - if (types.length == 0) return cb("can not support audio!"); + if (types.length == 0) + return cb("can not support audio!"); if (count == -1) { extname = (path.extname(realUrl) || "").toLowerCase(); if (!self.audioTypeSupported(extname)) { @@ -964,10 +984,12 @@ cc._audioLoader = { return self._load(realUrl, url, res, count + 1, tryArr, audio, cb); realUrl = path.changeExtname(realUrl, extname); tryArr.push(extname); + var delFlag = (count == types.length -1); audio = self._loadAudio(realUrl, audio, function (err) { - if (err) return self._load(realUrl, url, res, count + 1, tryArr, audio, cb);//can not found + if (err) + return self._load(realUrl, url, res, count + 1, tryArr, audio, cb);//can not found cb(null, audio); - }); + }, delFlag); locLoader.cache[url] = audio; }, @@ -975,11 +997,12 @@ cc._audioLoader = { if (!type) return false; return this._supportedAudioTypes.indexOf(type.toLowerCase()) >= 0; }, - _loadAudio: function (url, audio, cb) { + _loadAudio: function (url, audio, cb, delFlag) { var _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); if (arguments.length == 2) { - cb = audio, audio = new _Audio(); - } else if (arguments.length == 3 && !audio) { + cb = audio; + audio = new _Audio(); + } else if ((arguments.length > 3 ) && !audio) { audio = new _Audio(); } audio.src = url; @@ -997,9 +1020,11 @@ cc._audioLoader = { this.removeEventListener(error, arguments.callee, false); }, false); cc._addEventListener(audio, error, function () { - cb("load " + url + " failed") - this.removeEventListener(canplaythrough, arguments.callee, false); - this.removeEventListener(error, arguments.callee, false); + cb("load " + url + " failed"); + if(delFlag){ + this.removeEventListener(canplaythrough, arguments.callee, false); + this.removeEventListener(error, arguments.callee, false); + } }, false); audio.load(); } diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 1d1d4e109b..766c9f5f30 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -59,9 +59,7 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ * @return {cc.Layer|Null} */ cc.Layer.create = function () { - var ret = new cc.Layer(); - return ret; - + return new cc.Layer(); }; /** diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index c64a6ee3dd..f9e56a93d5 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -87,7 +87,7 @@ cc._fontLoader = { if(srcs instanceof Array){ for(var i = 0, li = srcs.length; i < li; i++){ var src = srcs[i]; - type = path.extname(src); + type = path.extname(src).toLowerCase(); fontStr += "url('" + srcs[i] + "') format('" + TYPE[type] + "')"; fontStr += (i == li - 1) ? ";" : ","; } diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index 1c51c50df2..84b10086c9 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -104,8 +104,10 @@ cc.LoaderScene = cc.Scene.extend({ self.unschedule(self._startLoading); var res = self.resources; self._length = res.length; + self._count = 0; cc.loader.load(res, function(result, count){ self._count = count; }, function(){ - self.cb(); + if(self.cb) + self.cb(); }); self.schedule(self._updatePercent); }, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 0ae9475857..ecf577bbc3 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1583,7 +1583,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextureCoord.x, locTextureCoord.y, locTextureCoord.width, locTextureCoord.height, flipXOffset, flipYOffset, locDrawSizeCanvas.width , locDrawSizeCanvas.height); } - } else if (locContentSize.width !== 0) { + } else if (!_t._texture && locTextureCoord.validRect) { var curColor = _t.color; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; context.fillRect(flipXOffset, flipYOffset, locContentSize.width * locEGL_ScaleX, locContentSize.height * locEGL_ScaleY); diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index 17130f0830..acabedd4bc 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -364,7 +364,7 @@ cc.TransitionProgressOutIn = cc.TransitionProgress.extend(/** @lends cc.Transiti pNode.barChangeRate = cc.p(1, 1); pNode.percentage = 100; - this._setAttrs(pNode, winSize.width / 2, winSize.height / 2); + this._setAttrs(pNode, size.width / 2, size.height / 2); return pNode; } From 39a85b791ae4e2c1f870f12d47d087094629e1b3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 May 2014 10:22:42 +0800 Subject: [PATCH 0137/1564] Closed #5412: Fixed keyboard events loss --- CCBoot.js | 1 + cocos2d/core/platform/CCInputExtension.js | 4 ++-- cocos2d/core/platform/CCInputManager.js | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 0a179a16d4..ab55f0f0fc 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1303,6 +1303,7 @@ cc._setup = function (el, width, height) { localCanvas.addClass("gameCanvas"); localCanvas.setAttribute("width", width || 480); localCanvas.setAttribute("height", height || 320); + localCanvas.setAttribute("tabindex", 99); localConStyle = localContainer.style; localConStyle.width = (width || 480) + "px"; localConStyle.height = (height || 320) + "px"; diff --git a/cocos2d/core/platform/CCInputExtension.js b/cocos2d/core/platform/CCInputExtension.js index 74cf905775..17e7d4f44a 100644 --- a/cocos2d/core/platform/CCInputExtension.js +++ b/cocos2d/core/platform/CCInputExtension.js @@ -60,12 +60,12 @@ _p._registerKeyboardEvent = function(){ cc.eventManager.dispatchEvent(new cc.EventKeyboard(e.keyCode, true)); e.stopPropagation(); e.preventDefault(); - }); + }, false); cc._addEventListener(cc._canvas, "keyup", function (e) { cc.eventManager.dispatchEvent(new cc.EventKeyboard(e.keyCode, false)); e.stopPropagation(); e.preventDefault(); - }); + }, false); }; _p._registerAccelerometerEvent = function(){ diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 962dfe3675..002bd0e41b 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -349,6 +349,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); + if(!supportTouches) selfPointer.handleTouchesBegin([selfPointer.getTouchByXY(location.x, location.y, pos)]); @@ -358,6 +359,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ event.stopPropagation(); event.preventDefault(); + element.focus(); }, false); cc._addEventListener(element, "mouseup", function (event) { @@ -460,6 +462,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ selfPointer.handleTouchesBegin(selfPointer.getTouchesByEvent(event, pos)); event.stopPropagation(); event.preventDefault(); + element.focus(); }, false); cc._addEventListener(element, "touchmove", function (event) { From 994af6ec073d82557e911192e86d7a0554ff2eac Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 May 2014 10:43:40 +0800 Subject: [PATCH 0138/1564] Closed #5413: Enhanced cc.log function --- CCDebugger.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CCDebugger.js b/CCDebugger.js index c63571e274..8126cb8907 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -265,17 +265,24 @@ cc._logToWebPage = function (msg) { }; //to make sure the cc.log, cc.warn, cc.error and cc.assert would not throw error before init by debugger mode. +cc._formatString = function(arg){ + if(typeof arg === 'object'){ + return JSON.stringify(arg); + }else{ + return arg; + } +}; if (console.log) { cc.log = function(msg){ for (var i = 1; i < arguments.length; i++) { - msg = msg.replace("%s", arguments[i]); + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); } console.log(msg); }; cc.warn = console.warn ? function(msg){ for (var i = 1; i < arguments.length; i++) { - msg = msg.replace("%s", arguments[i]); + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); } console.warn(msg); } : @@ -283,7 +290,7 @@ if (console.log) { cc.error = console.error ? function(msg){ for (var i = 1; i < arguments.length; i++) { - msg = msg.replace("%s", arguments[i]); + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); } console.error(msg); } : @@ -291,7 +298,7 @@ if (console.log) { cc.assert = function (cond, msg) { if (!cond && msg) { for (var i = 2; i < arguments.length; i++) { - msg = msg.replace("%s", arguments[i]); + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); } throw msg; } From e0b550760d142c764e0529f6abbb81730d0ddd33 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 30 May 2014 11:11:02 +0800 Subject: [PATCH 0139/1564] Closed #5414: multiple property object supports in extend function --- AUTHORS.txt | 1 + cocos2d/core/platform/CCClass.js | 119 ++++++++++++----------- cocos2d/core/support/CCPointExtension.js | 2 +- 3 files changed, 63 insertions(+), 59 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 3e7b86b2bb..71af13094b 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -114,6 +114,7 @@ XiaoJun Zheng @SmallAiTT _getResType error fix add node.js scripts for publishing game refactor cc.CCBReader cc.view bug fix + multiple property object supports in extend function Guozhu Cheng @bengol cc.SimpleAudioEngine bug fix diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 81225ab019..a224bcc924 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -98,10 +98,10 @@ ClassManager.compileSuper.ClassManager = ClassManager; /** * Create a new Class that inherits from this Class - * @param {object} prop + * @param {object} props * @return {function} */ - cc.Class.extend = function (prop) { + cc.Class.extend = function (props) { var _super = this.prototype; // Instantiate a base Class (but only create the instance, @@ -144,63 +144,66 @@ ClassManager.compileSuper.ClassManager = ClassManager; this.__getters__ && (Class.__getters__ = cc.clone(this.__getters__)); this.__setters__ && (Class.__setters__ = cc.clone(this.__setters__)); - for (var name in prop) { - var isFunc = (typeof prop[name] === "function"); - var override = (typeof _super[name] === "function"); - var hasSuperCall = fnTest.test(prop[name]); - - if(releaseMode && isFunc && override && hasSuperCall) { - desc.value = ClassManager.compileSuper(prop[name], name, classId); - Object.defineProperty(prototype, name, desc); - } else if(isFunc && override && hasSuperCall){ - desc.value = (function (name, fn) { - return function () { - var tmp = this._super; - - // Add a new ._super() method that is the same method - // but on the super-Class - this._super = _super[name]; - - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; - - return ret; - }; - })(name, prop[name]); - Object.defineProperty(prototype, name, desc); - } else if(isFunc) { - desc.value = prop[name]; - Object.defineProperty(prototype, name, desc); - } else{ - prototype[name] = prop[name]; + for(var idx = 0, li = arguments.length; idx < li; ++idx) { + var prop = arguments[idx]; + for (var name in prop) { + var isFunc = (typeof prop[name] === "function"); + var override = (typeof _super[name] === "function"); + var hasSuperCall = fnTest.test(prop[name]); + + if (releaseMode && isFunc && override && hasSuperCall) { + desc.value = ClassManager.compileSuper(prop[name], name, classId); + Object.defineProperty(prototype, name, desc); + } else if (isFunc && override && hasSuperCall) { + desc.value = (function (name, fn) { + return function () { + var tmp = this._super; + + // Add a new ._super() method that is the same method + // but on the super-Class + this._super = _super[name]; + + // The method only need to be bound temporarily, so we + // remove it when we're done executing + var ret = fn.apply(this, arguments); + this._super = tmp; + + return ret; + }; + })(name, prop[name]); + Object.defineProperty(prototype, name, desc); + } else if (isFunc) { + desc.value = prop[name]; + Object.defineProperty(prototype, name, desc); + } else { + prototype[name] = prop[name]; + } + + if (isFunc) { + // Override registered getter/setter + var getter, setter, propertyName; + if (this.__getters__ && this.__getters__[name]) { + propertyName = this.__getters__[name]; + for (var i in this.__setters__) { + if (this.__setters__[i] == propertyName) { + setter = i; + break; + } + } + cc.defineGetterSetter(prototype, propertyName, prop[name], prop[setter] ? prop[setter] : prototype[setter], name, setter); + } + if (this.__setters__ && this.__setters__[name]) { + propertyName = this.__setters__[name]; + for (var i in this.__getters__) { + if (this.__getters__[i] == propertyName) { + getter = i; + break; + } + } + cc.defineGetterSetter(prototype, propertyName, prop[getter] ? prop[getter] : prototype[getter], prop[name], getter, name); + } + } } - - if (isFunc) { - // Override registered getter/setter - var getter, setter, propertyName; - if( this.__getters__ && this.__getters__[name] ) { - propertyName = this.__getters__[name]; - for (var i in this.__setters__) { - if (this.__setters__[i] == propertyName) { - setter = i; - break; - } - } - cc.defineGetterSetter(prototype, propertyName, prop[name], prop[setter] ? prop[setter] : prototype[setter], name, setter); - } - if( this.__setters__ && this.__setters__[name] ) { - propertyName = this.__setters__[name]; - for (var i in this.__getters__) { - if (this.__getters__[i] == propertyName) { - getter = i; - break; - } - } - cc.defineGetterSetter(prototype, propertyName, prop[getter] ? prop[getter] : prototype[getter], prop[name], getter, name); - } - } } // And make this Class extendable diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/support/CCPointExtension.js index 618b65c0ff..b7fc3096f2 100644 --- a/cocos2d/core/support/CCPointExtension.js +++ b/cocos2d/core/support/CCPointExtension.js @@ -192,7 +192,7 @@ cc.pLength = function (v) { * Calculates the distance between two points * @param {cc.Point} v1 * @param {cc.Point} v2 - * @return {cc.pLength} + * @return {Number} */ cc.pDistance = function (v1, v2) { return cc.pLength(cc.pSub(v1, v2)); From 4f995d0c4466e9158873a7b7a0c36af24167e4e9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 May 2014 11:14:57 +0800 Subject: [PATCH 0140/1564] Merge and Modification from @f15gdsy --- extensions/cocostudio/action/CCActionFrame.js | 133 +++++++++--------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 2f4d83c2d8..59fc14b3a3 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -115,101 +116,101 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ var resultAction; switch (this.easingType) { -// case ccs.FrameEaseType.Custom: -// -// break; + case ccs.FrameEaseType.Custom: + break; case ccs.FrameEaseType.Linear: resultAction = action; break; case ccs.FrameEaseType.Sine_EaseIn: - resultAction = cc.EaseSineIn.create(action); + resultAction = action.easing(cc.easeSineIn()); break; case ccs.FrameEaseType.Sine_EaseOut: - resultAction = cc.EaseSineOut.create(action); + resultAction = action.easing(cc.easeSineOut()); break; case ccs.FrameEaseType.Sine_EaseInOut: - resultAction = cc.EaseSineInOut.create(action); - break; -// case ccs.FrameEaseType.Quad_EaseIn: -// resultAction = cc.Quad_EaseIn.create(action); -// break; -// case ccs.FrameEaseType.Quad_EaseOut: -// resultAction = cc.Quad_EaseOut.create(action); -// break; -// case ccs.FrameEaseType.Quad_EaseInOut: -// resultAction = cc.Quad_EaseInOut.create(action); -// break; -// case ccs.FrameEaseType.Cubic_EaseIn: -// resultAction = cc.Cubic_EaseIn.create(action); -// break; -// case ccs.FrameEaseType.Cubic_EaseOut: -// resultAction = cc.Cubic_EaseOut.create(action); -// break; -// case ccs.FrameEaseType.Cubic_EaseInOut: -// resultAction = cc.Cubic_EaseInOut.create(action); -// break; -// case ccs.FrameEaseType.Quart_EaseIn: -// resultAction = cc.Quart_EaseIn.create(action); -// break; -// case ccs.FrameEaseType.Quart_EaseOut: -// resultAction = cc.Quart_EaseOut.create(action); -// break; -// case ccs.FrameEaseType.Quart_EaseInOut: -// resultAction = cc.Quart_EaseInOut.create(action); -// break; -// case ccs.FrameEaseType.Quint_EaseIn: -// resultAction = cc.Quint_EaseIn.create(action); -// break; -// case ccs.FrameEaseType.Quint_EaseOut: -// resultAction = cc.Quint_EaseOut.create(action); -// break; -// case ccs.FrameEaseType.Quint_EaseInOut: -// resultAction = cc.Quint_EaseInOut.create(action); -// break; + resultAction = action.easing(cc.easeSineInOut()); + break; + case ccs.FrameEaseType.Quad_EaseIn: + resultAction = action.easing(cc.easeQuadraticActionIn()); + break; + case ccs.FrameEaseType.Quad_EaseOut: + resultAction = action.easing(cc.easeQuadraticActionOut()); + break; + case ccs.FrameEaseType.Quad_EaseInOut: + resultAction = action.easing(cc.easeQuadraticActionInOut()); + break; + case ccs.FrameEaseType.Cubic_EaseIn: + resultAction = action.easing(cc.easeCubicActionIn()); + break; + case ccs.FrameEaseType.Cubic_EaseOut: + resultAction = action.easing(cc.easeCubicActionOut()); + break; + case ccs.FrameEaseType.Cubic_EaseInOut: + resultAction = action.easing(cc.easeCubicActionInOut()); + break; + case ccs.FrameEaseType.Quart_EaseIn: + resultAction = action.easing(cc.easeQuarticActionIn()); + break; + case ccs.FrameEaseType.Quart_EaseOut: + resultAction = action.easing(cc.easeQuarticActionOut()); + break; + case ccs.FrameEaseType.Quart_EaseInOut: + resultAction = action.easing(cc.easeQuarticActionInOut()); + break; + case ccs.FrameEaseType.Quint_EaseIn: + resultAction = action.easing(cc.easeQuinticActionIn()); + break; + case ccs.FrameEaseType.Quint_EaseOut: + resultAction = action.easing(cc.easeQuinticActionOut()); + break; + case ccs.FrameEaseType.Quint_EaseInOut: + resultAction = action.easing(cc.easeQuinticActionInOut()); + break; case ccs.FrameEaseType.Expo_EaseIn: - resultAction = cc.EaseExponentialIn.create(action); + resultAction = action.easing(cc.easeExponentialIn()); break; case ccs.FrameEaseType.Expo_EaseOut: - resultAction = cc.EaseExponentialOut.create(action); + resultAction = action.easing(cc.easeExponentialOut()); break; case ccs.FrameEaseType.Expo_EaseInOut: - resultAction = cc.EaseExponentialInOut.create(action); - break; -// case ccs.FrameEaseType.Circ_EaseIn: -// resultAction = cc.Circ_EaseIn.create(action); -// break; -// case ccs.FrameEaseType.Circ_EaseOut: -// resultAction = cc.Circ_EaseOut.create(action); -// break; -// case ccs.FrameEaseType.Circ_EaseInOut: -// resultAction = cc.Circ_EaseInOut.create(action); -// break; + resultAction = action.easing(cc.easeExponentialInOut()); + break; + case ccs.FrameEaseType.Circ_EaseIn: + resultAction = action.easing(cc.easeCircleActionIn()); + break; + case ccs.FrameEaseType.Circ_EaseOut: + resultAction = action.easing(cc.easeCircleActionOut()); + break; + case ccs.FrameEaseType.Circ_EaseInOut: + resultAction = action.easing(cc.easeCircleActionInOut()); + break; case ccs.FrameEaseType.Elastic_EaesIn: - resultAction = cc.EaseElasticIn.create(action); + resultAction = action.easing(cc.easeElasticIn()); break; case ccs.FrameEaseType.Elastic_EaesOut: - resultAction = cc.EaseElasticOut.create(action); + resultAction = action.easing(cc.easeElasticOut()); break; case ccs.FrameEaseType.Elastic_EaesInOut: - resultAction = cc.EaseElasticInOut.create(action); + resultAction = action.easing(cc.easeElasticInOut()); break; case ccs.FrameEaseType.Back_EaseIn: - resultAction = cc.EaseBackIn.create(action); + resultAction = action.easing(cc.easeBackIn()); break; case ccs.FrameEaseType.Back_EaseOut: - resultAction = cc.EaseBackOut.create(action); + resultAction = action.easing(cc.easeBackOut()); break; case ccs.FrameEaseType.Back_EaseInOut: - resultAction = cc.EaseBackInOut.create(action); + resultAction = action.easing(cc.easeBackInOut()); break; case ccs.FrameEaseType.Bounce_EaseIn: - resultAction = cc.EaseBounceIn.create(action); + resultAction = action.easing(cc.easeBounceIn()); break; case ccs.FrameEaseType.Bounce_EaseOut: - resultAction = cc.EaseBounceOut.create(action); + resultAction = action.easing(cc.easeBounceOut()); break; case ccs.FrameEaseType.Bounce_EaseInOut: - resultAction = cc.EaseBounceInOut.create(action); + resultAction = action.easing(cc.easeBounceInOut()); + break; default: console.error("Frame ease type: " + this.easingType + " is currently not supported."); } From 5a3cc8bfe8343924ffafffaa0d681b2c6176d7a1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 May 2014 11:27:02 +0800 Subject: [PATCH 0141/1564] Add getAction default data --- extensions/cocostudio/action/CCActionFrame.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 59fc14b3a3..5b2ce2eeb8 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -109,7 +109,7 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ }, _getEasingAction : function (action) { - if (action == null) { + if (action === null) { console.error("Action cannot be null!"); return null; } @@ -258,10 +258,11 @@ ccs.ActionMoveFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionMoveFrame# */{ /** * Gets the CCAction of ActionFrame. * @param {number} duration - * @returns {cc.Action} + * @returns {cc.MoveTo} */ getAction: function (duration) { var action = cc.MoveTo.create(duration, this._position); + action.easingType = this.easingType || ccs.FrameEaseType.Linear; return this._getEasingAction(action); } }); @@ -316,10 +317,11 @@ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# * /** * Gets the action of ActionFrame. * @param duration - * @returns {cc.Action} + * @returns {cc.ScaleTo} */ getAction: function (duration) { var action = cc.ScaleTo.create(duration, this._scaleX, this._scaleY); + action.easingType = this.easingType || ccs.FrameEaseType.Linear; return this._getEasingAction(action); } }); @@ -356,10 +358,11 @@ ccs.ActionRotationFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionRotationFr /** * Gets the CCAction of ActionFrame. * @param {number} duration - * @returns {cc.Action} + * @returns {cc.RotateTo} */ getAction: function (duration) { var action = cc.RotateTo.create(duration, this._rotation); + action.easingType = this.easingType || ccs.FrameEaseType.Linear; return this._getEasingAction(action); } }); @@ -396,10 +399,11 @@ ccs.ActionFadeFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionFadeFrame# */{ /** * Gets the CCAction of ActionFrame. * @param duration - * @returns {cc.Action} + * @returns {cc.FadeTo} */ getAction: function (duration) { var action = cc.FadeTo.create(duration, this._opacity); + action.easingType = this.easingType || ccs.FrameEaseType.Linear; return this._getEasingAction(action); } }); @@ -440,10 +444,11 @@ ccs.ActionTintFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionTintFrame# */{ /** * Gets the action of ActionFrame. * @param duration - * @returns {cc.Action} + * @returns {cc.TintTo} */ getAction: function (duration) { var action = cc.TintTo.create(duration, this._color.r, this._color.g, this._color.b); + action.easingType = this.easingType || ccs.FrameEaseType.Linear; return this._getEasingAction(action); } }); \ No newline at end of file From 0aa776128f11fa2e41761633de26b0f742903ff4 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 30 May 2014 14:02:13 +0800 Subject: [PATCH 0142/1564] Closed #5416: Modify addListener of cc.eventManager for user friendly --- CCDebugger.js | 2 +- cocos2d/core/event-manager/CCEventManager.js | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CCDebugger.js b/CCDebugger.js index 8126cb8907..46bf66c6cc 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -92,7 +92,7 @@ cc._LogInfos = { eventManager_setPriority: "Can't set fixed priority with scene graph based listener.", eventManager_addListener_2: "Invalid parameters.", eventManager_addListener_3: "listener must be a cc.EventListener object when adding a fixed priority listener", - eventManager_addListener_4: "The listener has been registered.", + eventManager_addListener_4: "The listener has been registered, please don't register it again.", LayerMultiplex_initWithLayers: "parameters should not be ending with null in Javascript", LayerMultiplex_switchTo: "Invalid index in MultiplexLayer switchTo message", diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 9aa49360ef..e235a8202d 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -653,18 +653,15 @@ cc.eventManager = /** @lends cc.eventManager# */{ * except calls removeAllListeners(). */ addListener: function (listener, nodeOrPriority) { - cc.assert(listener && nodeOrPriority, cc._LogInfos.eventManager_addListener_2); - if(!(listener instanceof cc.EventListener)){ - cc.assert(typeof nodeOrPriority !== "number", cc._LogInfos.eventManager_addListener_3); - listener = cc.EventListener.create(listener); - } else{ - - cc.assert(!listener._isRegistered(), cc._LogInfos.eventManager_addListener_4); - + } else { + if(listener._isRegistered()){ + cc.log(cc._LogInfos.eventManager_addListener_4); + return; + } } if (!listener.checkAvailable()) From 8396daf06c5016656d362e24245363cee0b84737 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 May 2014 15:24:15 +0800 Subject: [PATCH 0143/1564] Issue #5412: Fixed a bug the redundant border in chrome --- CCBoot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/CCBoot.js b/CCBoot.js index ab55f0f0fc..8813c8aa1c 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1304,6 +1304,7 @@ cc._setup = function (el, width, height) { localCanvas.setAttribute("width", width || 480); localCanvas.setAttribute("height", height || 320); localCanvas.setAttribute("tabindex", 99); + localCanvas.style.outline = "none"; localConStyle = localContainer.style; localConStyle.width = (width || 480) + "px"; localConStyle.height = (height || 320) + "px"; From 17fa44ffb3d08e599ab96bb25f1b134559419c06 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Fri, 30 May 2014 17:51:56 +0300 Subject: [PATCH 0144/1564] fixed JumpTo bug with wrong _delta position --- cocos2d/actions/CCActionInterval.js | 49 ++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index a2d75049d5..461e9a2481 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -1657,14 +1657,55 @@ cc.JumpBy.create = function (duration, position, y, height, jumps) { * @extends cc.JumpBy */ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ + _endPosition:null, - /** + /** + * Constructor of JumpTo + * @param {Number} duration + * @param {cc.Point|Number} position + * @param {Number} [y] + * @param {Number} height + * @param {Number} jumps + * @example + * var actionTo = new cc.JumpTo(2, cc.p(300, 0), 50, 4); + * var actionTo = new cc.JumpTo(2, 300, 0, 50, 4); + */ + ctor:function (duration, position, y, height, jumps) { + cc.JumpBy.prototype.ctor.call(this); + this._endPosition = cc.p(0, 0); + + height !== undefined && this.initWithDuration(duration, position, y, height, jumps); + }, + /** + * @param {Number} duration + * @param {cc.Point|Number} position + * @param {Number} [y] + * @param {Number} height + * @param {Number} jumps + * @return {Boolean} + * @example + * actionTo.initWithDuration(2, cc.p(300, 0), 50, 4); + * actionTo.initWithDuration(2, 300, 0, 50, 4); + */ + initWithDuration:function (duration, position, y, height, jumps) { + if (cc.JumpBy.prototype.initWithDuration.call(this, duration, position, y, height, jumps)) { + if (jumps === undefined) { + y = position.y; + position = position.x; + } + this._endPosition.x = position; + this._endPosition.y = y; + return true; + } + return false; + }, + /** * @param {cc.Node} target */ startWithTarget:function (target) { cc.JumpBy.prototype.startWithTarget.call(this, target); - this._delta.x = this._delta.x - this._startPosition.x; - this._delta.y = this._delta.y - this._startPosition.y; + this._delta.x = this._endPosition.x - this._startPosition.x; + this._delta.y = this._endPosition.y - this._startPosition.y; }, /** @@ -1674,7 +1715,7 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ clone:function () { var action = new cc.JumpTo(); this._cloneDecoration(action); - action.initWithDuration(this._duration, this._delta, this._height, this._jumps); + action.initWithDuration(this._duration, this._endPosition, this._height, this._jumps); return action; } }); From c6cce79a94e04e585127e97ce48d0cdab81ea222 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 3 Jun 2014 10:25:38 +0800 Subject: [PATCH 0145/1564] Fixed #1891: readme.mdown includes dead link --- README.mdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mdown b/README.mdown index 64bd5efde7..5e3bc6adcd 100644 --- a/README.mdown +++ b/README.mdown @@ -37,7 +37,7 @@ Contact us [1]: http://www.cocos2d-x.org "Cocos2d-html5" [2]: http://www.cocos2d-x.org "Cocos2d-X" [3]: http://www.cocos2d-x.org "www.cocos2d-x.org" -[4]: http://www.cocos2d-x.org/embedded/cocos2d-x/classes.html "API References" +[4]: http://www.cocos2d-x.org/wiki/Reference "API References" [5]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org" [6]: http://www.twitter.com/cocos2dhtml5 "http://www.twitter.com/cocos2dhtml5" [7]: http://t.sina.com.cn/cocos2dhtml5 "http://t.sina.com.cn/cocos2dhtml5" From f7455d420e4be4eaef7edc0f8615ba3a8b82fad9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 4 Jun 2014 15:00:10 +0800 Subject: [PATCH 0146/1564] Issue #5486: Automatically changes the size of the element failure - cocostudio --- extensions/ccui/uiwidgets/UIText.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 55d19c2d9a..3e20f73101 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -386,7 +386,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this.setFontSize(uiLabel._labelRenderer.getFontSize()); this.setString(uiLabel.getString()); this.setTouchScaleChangeEnabled(uiLabel.touchScaleEnabled); - this.setTextAreaSize(uiLabel._size); + this.setTextAreaSize(uiLabel._textAreaSize); this.setTextHorizontalAlignment(uiLabel._textHorizontalAlignment); this.setTextVerticalAlignment(uiLabel._textVerticalAlignment); } From d56a694f186c541e1b880a635b29a2433c08a831 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 4 Jun 2014 15:40:42 +0800 Subject: [PATCH 0147/1564] Fixed #5489: Make SpriteFrame's initWithTexture function support string parameter as texture --- cocos2d/core/sprites/CCSpriteFrame.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 6653a712a4..3a60efe757 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -354,7 +354,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this.setTexture(texture); } - + texture = this.getTexture(); if(texture) { var _x, _y; if(rotated){ From a170832d79e0d7dd227683c8e28f60116e64c9cc Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Wed, 4 Jun 2014 13:50:27 +0300 Subject: [PATCH 0148/1564] fixed bug with inverted ClippingNode with DrawNode as stencil on Canvas; --- cocos2d/clipping-nodes/CCClippingNode.js | 21 +++++++++++++++++++-- cocos2d/core/support/CCVertex.js | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index fa22c26054..f5bef35eb9 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -311,10 +311,10 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ } var context = ctx || cc._renderContext; + var canvas = context.canvas; // Composition mode, costy but support texture stencil if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) { // Cache the current canvas, for later use (This is a little bit heavy, replace this solution with other walkthrough) - var canvas = context.canvas; var locCache = cc.ClippingNode._getSharedCache(); locCache.width = canvas.width; locCache.height = canvas.height; @@ -346,6 +346,19 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ context.save(); this.transform(context); this._stencil.visit(context); + if (this.inverted) { + context.save(); + + context.setTransform(1, 0, 0, 1, 0, 0); + + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); + + context.restore(); + } context.clip(); // Clip mode doesn't support recusive stencil, so once we used a clip stencil, @@ -404,11 +417,15 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ else if (stencil instanceof cc.DrawNode) { stencil.draw = function () { var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); + locContext.beginPath(); for (var i = 0; i < stencil._buffer.length; i++) { var element = stencil._buffer[i]; var vertices = element.verts; + + cc.assert(cc.vertexListIsClockwise(vertices), + "Only clockwise polygons should be used as stencil"); + var firstPoint = vertices[0]; - locContext.beginPath(); locContext.moveTo(firstPoint.x * locEGL_ScaleX, -firstPoint.y * locEGL_ScaleY); for (var j = 1, len = vertices.length; j < len; j++) locContext.lineTo(vertices[j].x * locEGL_ScaleX, -vertices[j].y * locEGL_ScaleY); diff --git a/cocos2d/core/support/CCVertex.js b/cocos2d/core/support/CCVertex.js index acae86ac2e..c300506f7a 100644 --- a/cocos2d/core/support/CCVertex.js +++ b/cocos2d/core/support/CCVertex.js @@ -149,4 +149,22 @@ cc.vertexLineIntersect = function (Ax, Ay, Bx, By, Cx, Cy, Dx, Dy) { // Success. return {isSuccess:true, value:t}; +}; + +/** + * returns wheter or not polygon defined by vertex list is clockwise + * @param {Array} verts + * @return {Boolean} + */ +cc.vertexListIsClockwise = function(verts) { + for (var i = 0, len = verts.length; i < len; i++) { + var a = verts[i]; + var b = verts[(i + 1) % len]; + var c = verts[(i + 2) % len]; + + if (cc.pCross(cc.pSub(b, a), cc.pSub(c, b)) > 0) + return false; + } + + return true; }; \ No newline at end of file From 3a5de728e1fc22b61a8c4d3fa447247e7e206310 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 11:55:20 +0800 Subject: [PATCH 0149/1564] Issue #1851: Fixed a bug about Armature loop --- extensions/cocostudio/armature/animation/CCArmatureAnimation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 5c72afac4b..9f224fb5ee 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -389,7 +389,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, loop, 0); }, /** From bf06b4e949d3c526570855fddbdd19e3d2f1527f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 16:29:19 +0800 Subject: [PATCH 0150/1564] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSprite.js | 8 ++++++-- cocos2d/core/sprites/CCSpriteFrame.js | 8 ++++++-- cocos2d/core/sprites/SpritesWebGL.js | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index ecf577bbc3..4ff76a7a3e 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1309,8 +1309,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(texture) { var _x = rect.x + rect.width, _y = rect.y + rect.height; - cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); - cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); + if(_x > texture.width){ + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if(_y > texture.height){ + cc.error(cc._LogInfos.RectHeight, texture.url); + } } _t._originalTexture = texture; _t.texture = texture; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 6653a712a4..d305631d92 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -364,8 +364,12 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ _x = rect.x + rect.width; _y = rect.y + rect.height; } - cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); - cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); + if(_x > texture.width){ + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if(_y > texture.height){ + cc.error(cc._LogInfos.RectHeight, texture.url); + } } this._rectInPixels = rect; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index be3706a4ba..3f333fb003 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -184,8 +184,12 @@ cc._tmp.WebGLSprite = function () { _x = rect.x + rect.width; _y = rect.y + rect.height; } - cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); - cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); + if(_x > texture.width){ + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if(_y > texture.height){ + cc.error(cc._LogInfos.RectHeight, texture.url); + } } _t.texture = texture; From 5092ada0700fe40fc9b4668bf7069a37024f7e56 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 18:09:07 +0800 Subject: [PATCH 0151/1564] Issue #5504: To change the color default value --- cocos2d/core/platform/CCTypes.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 946e1b7422..0d894d2cbf 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -36,10 +36,23 @@ cc.Color = function (r, g, b, a) { this.r = r || 0; this.g = g || 0; this.b = b || 0; - this.a = a; + this.a = a || 255; }; /** + * Introduction of the corresponding data, generate a color object + * You can choose the incoming parameters: + * + * 1. cc.color(255, 255, 255, 255); + * 4 parameters into the corresponding R, G, B, A + * + * 2. cc.color("#000000"); + * Function to convert a string to the corresponding value + * + * 3. cc.color({r: 255, g: 255, b: 255, a: 255}); + * Also can pass an object, including all data + * + * ‘a’ are optional. The default is 255 * * @param {Number|String|cc.Color} r * @param {Number} g @@ -53,8 +66,8 @@ cc.color = function (r, g, b, a) { if (typeof r === "string") return cc.hexToColor(r); if (typeof r === "object") - return {r: r.r, g: r.g, b: r.b, a: r.a}; - return {r: r, g: g, b: b, a: a }; + return {r: r.r, g: r.g, b: r.b, a: r.a || 255}; + return {r: r, g: g, b: b, a: a || 255 }; }; /** From f6a3a6ff25a0cc479bc27ea9985f1573b11cfc95 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 18:24:57 +0800 Subject: [PATCH 0152/1564] Issue #5504: To change the color default value --- cocos2d/core/platform/CCTypes.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 0d894d2cbf..c36a9b9827 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -40,24 +40,24 @@ cc.Color = function (r, g, b, a) { }; /** - * Introduction of the corresponding data, generate a color object - * You can choose the incoming parameters: + * Generate a color object based on multiple forms of parameters + * @example * - * 1. cc.color(255, 255, 255, 255); - * 4 parameters into the corresponding R, G, B, A + * // 1. All channals seperately as parameters + * var color1 = cc.color(255, 255, 255, 255); * - * 2. cc.color("#000000"); - * Function to convert a string to the corresponding value + * // 2. Convert a hex string to a color + * var color2 = cc.color("#000000"); * - * 3. cc.color({r: 255, g: 255, b: 255, a: 255}); - * Also can pass an object, including all data + * // 3. An color object as parameter + * var color3 = cc.color({r: 255, g: 255, b: 255, a: 255}); * - * ‘a’ are optional. The default is 255 + * Alpha chanal is optional. Default value is 255 * * @param {Number|String|cc.Color} r * @param {Number} g * @param {Number} b - * @param {Number} a + * @param {Number} [a=255] * @returns {cc.Color} */ cc.color = function (r, g, b, a) { From dfc28968974ae21faaf14828d4cb645d7f7792e2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 18:31:04 +0800 Subject: [PATCH 0153/1564] Issue #5504: To change the color default value --- cocos2d/core/platform/CCTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index c36a9b9827..cd94385a9a 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -43,7 +43,7 @@ cc.Color = function (r, g, b, a) { * Generate a color object based on multiple forms of parameters * @example * - * // 1. All channals seperately as parameters + * // 1. All channels seperately as parameters * var color1 = cc.color(255, 255, 255, 255); * * // 2. Convert a hex string to a color From 28e42a7958f035be37e8665f7b48dd8a0a862a82 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 18:35:03 +0800 Subject: [PATCH 0154/1564] Issue #5504: To change the color default value --- cocos2d/core/platform/CCTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index cd94385a9a..165b9f340f 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -52,7 +52,7 @@ cc.Color = function (r, g, b, a) { * // 3. An color object as parameter * var color3 = cc.color({r: 255, g: 255, b: 255, a: 255}); * - * Alpha chanal is optional. Default value is 255 + * Alpha channel is optional. Default value is 255 * * @param {Number|String|cc.Color} r * @param {Number} g From 01b9350af87e0b94526ba29075bb46b09c97db72 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 21:05:17 +0800 Subject: [PATCH 0155/1564] Issue #5507: auto full screen bug --- cocos2d/core/platform/CCEGLView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 6f3b0e3be9..3854153eeb 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -644,7 +644,7 @@ cc.ContainerStrategy = cc.Class.extend(/** @lends cc.ContainerStrategy# */{ _setupContainer: function (view, w, h) { var frame = view._frame; - if (this._autoFullScreen && cc.sys.isMobile && frame == document.documentElement) { + if (cc.view._autoFullScreen && cc.sys.isMobile && frame == document.documentElement) { // Automatically full screen when user touches on mobile version cc.screen.autoFullScreen(frame); } From f42a6f432e1959b4a8ae34b489ce771825ea1de4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 8 Jun 2014 16:37:07 +0800 Subject: [PATCH 0156/1564] Fixed #5520: Automatically handle loaded texture --- cocos2d/core/textures/CCTextureCache.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 13868d951e..13da9eed16 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -331,6 +331,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return tex; } + tex = locTexs[url] = new cc.Texture2D(); + tex.url = url; if (!cc.loader.getRes(url)) { if (cc.loader._checkIsImageURL(url)) { cc.loader.load(url, function (err) { @@ -345,9 +347,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }); } } + else { + tex.handleLoadedTexture(); + } - tex = locTexs[url] = new cc.Texture2D(); - tex.url = url; return tex; }; From 138e2267c1ff8832fcc2ba531d37a1b838dd542e Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 8 Jun 2014 17:06:50 +0800 Subject: [PATCH 0157/1564] Fixed #5521: Correct the rect information for initWithTexture in cc.Sprite.initWithFile function --- cocos2d/core/sprites/CCSprite.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4ff76a7a3e..582b616703 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -828,16 +828,16 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ cc.assert(filename, cc._LogInfos.Sprite_initWithFile); - var texture = cc.textureCache.textureForKey(filename); - if (!texture) { - texture = cc.textureCache.addImage(filename); - return this.initWithTexture(texture, rect || cc.rect(0, 0, 0, 0)); + var tex = cc.textureCache.textureForKey(filename); + if (!tex) { + tex = cc.textureCache.addImage(filename); + return this.initWithTexture(tex, rect || cc.rect(0, 0, tex._contentSize.width, tex._contentSize.height)); } else { if (!rect) { - var size = texture.getContentSize(); + var size = tex.getContentSize(); rect = cc.rect(0, 0, size.width, size.height); } - return this.initWithTexture(texture, rect); + return this.initWithTexture(tex, rect); } }, From a579e1b650e54b7c92d7324c1ab48a82e5617a41 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 9 Jun 2014 11:22:28 +0800 Subject: [PATCH 0158/1564] Refactor #5096: Improve performance of cc.rectIntersectsRect --- cocos2d/core/cocoa/CCGeometry.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/cocoa/CCGeometry.js b/cocos2d/core/cocoa/CCGeometry.js index 57b1521c77..ec2ad150de 100644 --- a/cocos2d/core/cocoa/CCGeometry.js +++ b/cocos2d/core/cocoa/CCGeometry.js @@ -274,11 +274,12 @@ cc.rectContainsPoint = function (rect, point) { * @param {cc.Rect} rectB * @return {Boolean} */ -cc.rectIntersectsRect = function (rectA, rectB) { - return !(cc.rectGetMaxX(rectA) < cc.rectGetMinX(rectB) || - cc.rectGetMaxX(rectB) < cc.rectGetMinX(rectA) || - cc.rectGetMaxY(rectA) < cc.rectGetMinY(rectB) || - cc.rectGetMaxY(rectB) < cc.rectGetMinY(rectA)); +cc.rectIntersectsRect = function (ra, rb) { + var maxax = ra.x + ra.width, + maxay = ra.y + ra.height, + maxbx = rb.x + rb.width, + maxby = rb.y + rb.height; + return !(maxax < rb.x || maxbx < ra.x || maxay < rb.y || maxby < ra.y); }; /** From c3c1fa7f0f1b77804ba32abbedac64ea077f4d63 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 11 Jun 2014 11:15:03 +0800 Subject: [PATCH 0159/1564] Fixed #5540: Refactor ccui.TextAtlas setStringValue to setString --- extensions/ccui/uiwidgets/UITextAtlas.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 3313d989e7..4124f1ba63 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -83,12 +83,12 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ /** * set string value for labelatlas. + * @deprecated * @param {String} value */ setStringValue: function (value) { - this._stringValue = value; - this._labelAtlasRenderer.setString(value); - this.labelAtlasScaleChangedWithSize(); + cc.log("Please use the setString"); + this.setString(value); }, /** @@ -98,17 +98,27 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ */ getStringValue: function () { cc.log("Please use the getString"); - return this._labelAtlasRenderer.getString(); + return this.getString(); }, /** - * get string value for labelatlas. + * get string value for ui text atlas. * @returns {String} */ getString: function () { return this._labelAtlasRenderer.getString(); }, + /** + * set string value for ui text atlas. + * @param {String} value + */ + setString: function (value) { + this._stringValue = value; + this._labelAtlasRenderer.setString(value); + this.labelAtlasScaleChangedWithSize(); + }, + /** * override "setAnchorPoint" of widget. * @param {cc.Point|Number} point The anchor point of UILabelAtlas or The anchor point.x of UILabelAtlas. @@ -209,7 +219,7 @@ var _p = ccui.TextAtlas.prototype; // Extended properties /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getString, _p.setStringValue); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); _p = null; From 72a72a74473db20cea497e2e3f5847d126697fd6 Mon Sep 17 00:00:00 2001 From: tovchenko Date: Wed, 11 Jun 2014 11:38:31 +0300 Subject: [PATCH 0160/1564] fixed cc.Skin bounding box calculation for canvas rendering --- extensions/cocostudio/armature/display/CCSkin.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 8eee27d06e..7701ac2902 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -98,12 +98,10 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this._transform = cc.AffineTransformConcat(locTransform, locArmature.nodeToParentTransform()); } if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - locTransform = this._transform + locTransform = this._transform; locTransform.b *= -1; locTransform.c *= -1; - var tempB = locTransform.b; - locTransform.b = locTransform.c; - locTransform.c = tempB; + locTransform.b = [locTransform.c, locTransform.c = locTransform.b][0]; } }, /** returns a "local" axis aligned bounding box of the node.
@@ -113,6 +111,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ getBoundingBox: function () { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); var transForm = this.nodeToParentTransform(); + if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + transForm.b *= -1; + transForm.c *= -1; + transForm.b = [transForm.c, transForm.c = transForm.b][0]; + } return cc.RectApplyAffineTransform(rect, transForm); }, From 0f4b2f83e4134da7cc476718d797d88e7e2f9ba3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 12 Jun 2014 12:07:11 +0800 Subject: [PATCH 0161/1564] Issue ##5548: May create an empty action --- extensions/cocostudio/action/CCActionFrame.js | 2 -- extensions/cocostudio/action/CCActionNode.js | 12 ++++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 5b2ce2eeb8..ce5b84eede 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -211,8 +211,6 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ case ccs.FrameEaseType.Bounce_EaseInOut: resultAction = action.easing(cc.easeBounceInOut()); break; - default: - console.error("Frame ease type: " + this.easingType + " is currently not supported."); } return resultAction; diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index 3399fa1fe9..58071c7050 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -268,12 +268,16 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var locSrcFrame = locArray[j - 1]; var locDuration = (locFrame.frameIndex - locSrcFrame.frameIndex) * this.getUnitTime(); var locAction = locFrame.getAction(locDuration); - locSequenceArray.push(locAction); + if(locAction){ + locSequenceArray.push(locAction); + } } } - var locSequence = cc.Sequence.create(locSequenceArray); - if (locSequence != null) { - locSpawnArray.push(locSequence); + if(locSequenceArray){ + var locSequence = cc.Sequence.create(locSequenceArray); + if (locSequence != null) { + locSpawnArray.push(locSequence); + } } } From b117966d8db27acab3af5f9c74d665df485f4876 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 13 Jun 2014 14:10:26 +0800 Subject: [PATCH 0162/1564] Fixed #5556: Make FadeIn support only duration as parameter This action should always animate node's opacity to 255 --- cocos2d/actions/CCActionInterval.js | 7 ++----- extensions/ccui/uiwidgets/UITextField.js | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 461e9a2481..97c2d23e67 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2322,16 +2322,13 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ /** * @param {Number} duration duration in seconds - * @param {Number} [toOpacity] to opacity * @return {cc.FadeIn} * @example * //example * var action = cc.FadeIn.create(1.0); */ -cc.FadeIn.create = function (duration, toOpacity) { - if(toOpacity == null) - toOpacity = 255; - return new cc.FadeIn(duration, toOpacity); +cc.FadeIn.create = function (duration) { + return new cc.FadeIn(duration, 255); }; diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index dc31027aa5..9e67344ae0 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -761,7 +761,7 @@ var _p = ccui.TextField.prototype; // Extended properties /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getString, _p.setText); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); /** @expose */ _p.placeHolder; cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder); From 0fcb8c30e163c190a748fb812280f941a67b91e5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 13 Jun 2014 18:08:18 +0800 Subject: [PATCH 0163/1564] Temporary removal of assert --- cocos2d/clipping-nodes/CCClippingNode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index f5bef35eb9..11735b7cca 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -422,8 +422,8 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ var element = stencil._buffer[i]; var vertices = element.verts; - cc.assert(cc.vertexListIsClockwise(vertices), - "Only clockwise polygons should be used as stencil"); + //cc.assert(cc.vertexListIsClockwise(vertices), + // "Only clockwise polygons should be used as stencil"); var firstPoint = vertices[0]; locContext.moveTo(firstPoint.x * locEGL_ScaleX, -firstPoint.y * locEGL_ScaleY); From a4686fd293786eb23201a2b06351bd238a5c1bce Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 17 Jun 2014 16:44:11 +0800 Subject: [PATCH 0164/1564] Follow up the code - #5501 --- extensions/ccui/layouts/UILayout.js | 74 ++------------------ extensions/ccui/layouts/UILayoutParameter.js | 7 +- extensions/ccui/uiwidgets/UIButton.js | 6 +- extensions/ccui/uiwidgets/UISlider.js | 4 +- extensions/ccui/uiwidgets/UIText.js | 3 + extensions/cocostudio/reader/GUIReader.js | 1 + 6 files changed, 16 insertions(+), 79 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index c5021ce803..cb5154cf2e 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -157,6 +157,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ removeAllChildren: function (cleanup) { ccui.Widget.prototype.removeAllChildren.call(this, cleanup); + }, + + removeAllChildrenWithCleanup: function(cleanup){ + ccui.Widget.prototype.removeAllChildrenWithCleanup(cleanup); this._doLayoutDirty = true; }, @@ -507,7 +511,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ getClippingRect: function () { if (this._clippingRectDirty) { - this._handleScissor = true; var worldPos = this.convertToWorldSpace(cc.p(0, 0)); var t = this.nodeToWorldTransform(); var scissorWidth = this._size.width * t.a; @@ -1314,114 +1317,47 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT: locFinalPosY += locMargin.bottom; - 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) { - locFinalPosY += locRelativeWidgetMargin.top; - } - locFinalPosY += locMargin.left; + locFinalPosX += locMargin.left; break; case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER: locFinalPosY += locMargin.bottom; - 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) { - locFinalPosY += locRelativeWidgetMargin.top; - } break; case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT: locFinalPosY += locMargin.bottom; - 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) { - locFinalPosY += locRelativeWidgetMargin.top; - } locFinalPosX -= locMargin.right; break; case ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP: locFinalPosX -= locMargin.right; - 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) { - locFinalPosX -= locRelativeWidgetMargin.left; - } locFinalPosY -= locMargin.top; break; case ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER: locFinalPosX -= locMargin.right; - 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) { - locFinalPosX -= locRelativeWidgetMargin.left; - } break; case ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM: locFinalPosX -= locMargin.right; - 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) { - locFinalPosX -= locRelativeWidgetMargin.left; - } locFinalPosY += locMargin.bottom; break; break; case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP: 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) { - locFinalPosX += locRelativeWidgetMargin.right; - } locFinalPosY -= locMargin.top; break; case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER: 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) { - locFinalPosX += locRelativeWidgetMargin.right; - } break; case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM: 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) { - locFinalPosX += locRelativeWidgetMargin.right; - } locFinalPosY += locMargin.bottom; break; - break; case ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP: 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) { - locFinalPosY -= locRelativeWidgetMargin.bottom; - } locFinalPosX += locMargin.left; break; case ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER: 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) { - locFinalPosY -= locRelativeWidgetMargin.bottom; - } break; case ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM: 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) { - locFinalPosY -= locRelativeWidgetMargin.bottom; - } locFinalPosX -= locMargin.right; break; default: diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 9a09a27127..bb2b1d4a4d 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -82,10 +82,7 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * @param {ccui.LayoutParameter} model */ copyProperties:function(model){ - this._margin.left = model._margin.left; - this._margin.top = model._margin.top; - this._margin.right = model._margin.right; - this._margin.bottom = model._margin.bottom; + this._margin = model._margin; } }); @@ -234,7 +231,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat * @returns {ccui.RelativeLayoutParameter} */ createCloneInstance:function(){ - return ccui.LinearLayoutParameter.create(); + return ccui.RelativeLayoutParameter.create(); }, /** diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 02ea4673e8..2c3a93cc0f 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -358,7 +358,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * Get normal renderer cap insets . * @returns {cc.Rect} */ - getCapInsetNormalRenderer: function () { + getCapInsetsNormalRenderer:function(){ return this._capInsetsNormal; }, @@ -378,7 +378,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * Get pressed renderer cap insets . * @returns {cc.Rect} */ - getCapInsetPressedRenderer: function () { + getCapInsetsPressedRenderer: function () { return this._capInsetsPressed; }, @@ -398,7 +398,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * Get disable renderer cap insets . * @returns {cc.Rect} */ - getCapInsetDisabledRenderer: function () { + getCapInsetsDisabledRenderer: function () { return this._capInsetsDisabled; }, diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 54fadedac5..02e514ff68 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -256,7 +256,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * Get cap insets for slider. * @returns {cc.Rect} */ - getCapInsetBarRenderer: function () { + getCapInsetsBarRenderer: function () { return this._capInsetsBarRenderer; }, @@ -276,7 +276,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * Get cap insets for slider. * @returns {cc.Rect} */ - getCapInsetProgressBarRenderer: function () { + getCapInsetsProgressBarRenderer: function () { return this._capInsetsProgressBarRenderer; }, diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 3e20f73101..a00d0adab2 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -182,6 +182,9 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRenderer.setDimensions(size); this.labelScaleChangedWithSize(); }, + getTextAreaSize: function(){ + return this._labelRenderer.getDimensions(); + }, _setBoundingWidth: function (value) { this._textAreaSize.width = value; this._labelRenderer._setBoundingWidth(value); diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index da642efd68..b230afa907 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -1126,6 +1126,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var selectedState = options["selectedState"] || false; widget.setSelectedState(selectedState); + checkBox.setSelectedState(options, "selectedState"); this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, From e2af5b5c56e83ac46b130c14b52b1fc953b0d2d3 Mon Sep 17 00:00:00 2001 From: mutoo Date: Tue, 17 Jun 2014 19:00:50 +0800 Subject: [PATCH 0165/1564] fixed: one-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0; --- .../cocostudio/armature/animation/CCProcessBase.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index 251fa52059..4ccbdcadce 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -85,7 +85,7 @@ 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, + _processScale: 1, _isComplete: true, _isPause: true, _isPlaying: false, @@ -100,7 +100,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ _curFrameIndex: null, _isLoopBack: false, ctor: function () { - this.processScale = 1; + this._processScale = 1; this._isComplete = true; this._isPause = true; this._isPlaying = false; @@ -172,7 +172,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ * dt/this.animationInternal determine it is not a frame animation. If frame speed changed, it will not make our * animation speed slower or quicker. */ - locCurrentFrame += this.processScale * (dt / this.animationInternal); + locCurrentFrame += this._processScale * (dt / this.animationInternal); this._currentPercent = locCurrentFrame / locNextFrameIndex; @@ -289,7 +289,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ * @returns {number} */ getProcessScale: function () { - return this.processScale; + return this._processScale; }, /** @@ -297,7 +297,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ * @param processScale */ setProcessScale: function (processScale) { - this.processScale = processScale; + this._processScale = processScale; }, /** From 69311556ec88e032acf56253392cc333d3bc26c9 Mon Sep 17 00:00:00 2001 From: mutoo Date: Tue, 17 Jun 2014 19:03:08 +0800 Subject: [PATCH 0166/1564] fixed: an obvious layout bug; --- extensions/ccui/layouts/UILayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index c5021ce803..1fba4c16c6 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1320,7 +1320,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ && locRelativeWidgetLPAlign != ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT) { locFinalPosY += locRelativeWidgetMargin.top; } - locFinalPosY += locMargin.left; + locFinalPosX += locMargin.left; break; case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER: locFinalPosY += locMargin.bottom; From 4ad6c6cf24c174cc053f1ceeae28eba6ecbe7f64 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 18 Jun 2014 18:18:12 +0800 Subject: [PATCH 0167/1564] add render --- extensions/ccui/uiwidgets/UIButton.js | 6 +- extensions/ccui/uiwidgets/UICheckBox.js | 16 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UIText.js | 4 +- extensions/ccui/uiwidgets/UITextAtlas.js | 4 +- extensions/ccui/uiwidgets/UITextBMFont.js | 4 +- extensions/ccui/uiwidgets/UITextField.js | 8 +- extensions/cocostudio/action/CCActionNode.js | 37 ++-- extensions/cocostudio/reader/GUIReader.js | 17 ++ .../widgetreader/ButtonReader/ButtonReader.js | 170 +++++++++++++++++ .../CheckBoxReader/CheckBoxReader.js | 173 ++++++++++++++++++ .../ImageViewReader/ImageViewReader.js | 108 +++++++++++ .../LabelAtlasReader/LabelAtlasReader.js | 82 +++++++++ .../LabelBMFontReader/LabelBMFontReader.js | 76 ++++++++ .../widgetreader/LabelReader/LabelReader.js | 84 +++++++++ .../widgetreader/LayoutReader/LayoutReader.js | 128 +++++++++++++ .../ListViewReader/ListViewReader.js | 56 ++++++ .../LoadingBarReader/LoadingBarReader.js | 91 +++++++++ .../PageViewReader/PageViewReader.js | 45 +++++ .../ScrollViewReader/ScrollViewReader.js | 60 ++++++ .../widgetreader/SliderReader/SliderReader.js | 167 +++++++++++++++++ .../TextFieldReader/TextFieldReader.js | 99 ++++++++++ .../reader/widgetreader/WidgetReader.js | 139 ++++++++++++++ .../widgetreader/WidgetReaderProtocol.js | 31 ++++ .../cocostudio/trigger/ObjectFactory.js | 36 ++++ 25 files changed, 1610 insertions(+), 33 deletions(-) create mode 100644 extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/WidgetReader.js create mode 100644 extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 2c3a93cc0f..5d670cc444 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -226,11 +226,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ buttonNormalRenderer.setCapInsets(this._capInsetsNormal); } + this.normalTextureScaleChangedWithSize(); this.updateColorToRenderer(buttonNormalRenderer); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.normalTextureScaleChangedWithSize(); this._normalTextureLoaded = true; }, @@ -276,10 +276,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ clickedRenderer.setCapInsets(this._capInsetsNormal); } this.updateColorToRenderer(clickedRenderer); + this.pressedTextureScaleChangedWithSize(); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.pressedTextureScaleChangedWithSize(); this._pressedTextureLoaded = true; }, @@ -325,10 +325,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ disableRenderer.setCapInsets(this._capInsetsNormal); } this.updateColorToRenderer(disableRenderer); + this.disabledTextureScaleChangedWithSize(); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.disabledTextureScaleChangedWithSize(); this._disabledTextureLoaded = true; }, diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 67c44ceb67..a5887788d8 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -124,17 +124,17 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } - this.updateColorToRenderer(bgBoxRenderer); - this.updateAnchorPoint(); - this.updateFlippedX(); - this.updateFlippedY(); + this.backGroundTextureScaleChangedWithSize(); if (!bgBoxRenderer.textureLoaded()) { this._backGroundBoxRenderer.setContentSize(this._customSize); bgBoxRenderer.addLoadedEventListener(function () { this.backGroundTextureScaleChangedWithSize(); }, this); } - this.backGroundTextureScaleChangedWithSize(); + this.updateColorToRenderer(bgBoxRenderer); + this.updateAnchorPoint(); + this.updateFlippedX(); + this.updateFlippedY(); }, /** * Load backGroundSelected texture for checkbox. @@ -187,11 +187,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } + this.frontCrossTextureScaleChangedWithSize(); this.updateColorToRenderer(this._frontCrossRenderer); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.frontCrossTextureScaleChangedWithSize(); }, /** @@ -216,11 +216,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } + this.backGroundDisabledTextureScaleChangedWithSize(); this.updateColorToRenderer(this._backGroundBoxDisabledRenderer); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.backGroundDisabledTextureScaleChangedWithSize(); }, /** @@ -245,11 +245,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } + this.frontCrossDisabledTextureScaleChangedWithSize(); this.updateColorToRenderer(this._frontCrossDisabledRenderer); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.frontCrossDisabledTextureScaleChangedWithSize(); }, onTouchEnded: function (touch, event) { diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 8c8d0e403e..0143d37d02 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -117,9 +117,9 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if (!this._scale9Enabled){ this._imageRenderer.setTextureRect(rect); var locRendererSize = this._imageRenderer.getContentSize(); + this.imageTextureScaleChangedWithSize(); this._imageTextureSize.width = locRendererSize.width; this._imageTextureSize.height = locRendererSize.height; - this.imageTextureScaleChangedWithSize(); } }, diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index a00d0adab2..3041075c5b 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -39,7 +39,7 @@ * @property {Number} verticalAlign - Vertical Alignment of label: cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM * @property {Boolean} touchScaleEnabled - Indicate whether the label will scale when touching */ -ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ +ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ touchScaleEnabled: false, _normalScaleValueX: 0, _normalScaleValueY: 0, @@ -436,7 +436,7 @@ _p = null; * // example * var uiLabel = ccui.Text.create(); */ -ccui.Text.create = function () { +ccui.Label = ccui.Text.create = function () { return new ccui.Text(); }; diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 4124f1ba63..5c44b711a7 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -30,7 +30,7 @@ * * @property {String} string - Content string of the label */ -ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ +ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ _labelAtlasRenderer: null, _stringValue: "", _charMapFileName: "", @@ -231,7 +231,7 @@ _p = null; * // example * var uiLabelAtlas = ccui.TextAtlas.create(); */ -ccui.TextAtlas.create = function () { +ccui.LabelAtlas.create = ccui.TextAtlas.create = function () { return new ccui.TextAtlas(); }; diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index c5518e71d2..7fd76a22c7 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -30,7 +30,7 @@ * * @property {String} string - Content string of the label */ -ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ +ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ _labelBMFontRenderer: null, _fileHasInit: false, _fntFileName: "", @@ -223,7 +223,7 @@ _p = null; * // example * var uiLabelBMFont = ccui.TextBMFont.create(); */ -ccui.TextBMFont.create = function () { +ccui.LabelBMFont.create = ccui.TextBMFont.create = function () { return new ccui.TextBMFont(); }; diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 9e67344ae0..5a48d5fff1 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -32,7 +32,7 @@ * @property {Number} maxLength - The max length of the text field * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password */ -ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ +ccui.UILabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ maxLengthEnabled: false, maxLength: 0, passwordEnabled: false, @@ -226,7 +226,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ } }); -ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { +ccui.UILabelField.create = ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { var ret = new ccui.UICCTextField(); if (ret && ret.initWithString("", fontName, fontSize)) { if (placeholder) { @@ -251,7 +251,7 @@ ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { * @property {Number} maxLength - The max length of the text field * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password */ -ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ +ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _textFieldRender: null, _touchWidth: 0, _touchHeight: 0, @@ -794,7 +794,7 @@ _p = null; * // example * var uiTextField = ccui.TextField.create(); */ -ccui.TextField.create = function () { +ccui.LabelField.create = ccui.TextField.create = function () { return new ccui.TextField(); }; diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index 58071c7050..3e428a4e84 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -65,14 +65,21 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var actionFrameDic = actionframelist[i]; var frameInex = actionFrameDic["frameid"]; var frameTweenType = actionFrameDic["tweenType"]; - var frameTweenParameter = actionFrameDic["tweenParameter"]; + var frameTweenParameterNum = actionFrameDic["tweenParameter"]; + + for (var j = 0; j < frameTweenParameterNum; j++){ + var value = actionFrameDic["tweenParameter"][j]; + frameTweenParameter.push(value); + } if (actionFrameDic["positionx"] !== undefined) { var positionX = actionFrameDic["positionx"]; var positionY = actionFrameDic["positiony"]; var actionFrame = new ccs.ActionMoveFrame(); - actionFrame.easingType = frameTweenType; - actionFrame.frameIndex = frameInex; +// actionFrame.easingType = frameTweenType; +// actionFrame.frameIndex = frameInex; + actionFrame.setEasingType(frameTweenType); + actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setPosition(positionX, positionY); var actionArray = this._frameArray[ccs.FRAME_TYPE_MOVE]; actionArray.push(actionFrame); @@ -82,8 +89,10 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var scaleX = actionFrameDic["scalex"]; var scaleY = actionFrameDic["scaley"]; var actionFrame = new ccs.ActionScaleFrame(); - actionFrame.easingType = frameTweenType; - actionFrame.frameIndex = frameInex; +// actionFrame.easingType = frameTweenType; +// actionFrame.frameIndex = frameInex; + actionFrame.setEasingType(frameTweenType); + actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setScaleX(scaleX); actionFrame.setScaleY(scaleY); var actionArray = this._frameArray[ccs.FRAME_TYPE_SCALE]; @@ -93,8 +102,10 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ if (actionFrameDic["rotation"] !== undefined) { var rotation = actionFrameDic["rotation"]; var actionFrame = new ccs.ActionRotationFrame(); - actionFrame.easingType = frameTweenType; - actionFrame.frameIndex = frameInex; +// actionFrame.easingType = frameTweenType; +// actionFrame.frameIndex = frameInex; + actionFrame.setEasingType(frameTweenType); + actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setRotation(rotation); var actionArray = this._frameArray[ccs.FRAME_TYPE_ROTATE]; actionArray.push(actionFrame); @@ -103,8 +114,10 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ if (actionFrameDic["opacity"] !== undefined) { var opacity = actionFrameDic["opacity"]; var actionFrame = new ccs.ActionFadeFrame(); - actionFrame.easingType = frameTweenType; - actionFrame.frameIndex = frameInex; +// actionFrame.easingType = frameTweenType; +// actionFrame.frameIndex = frameInex; + actionFrame.setEasingType(frameTweenType); + actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setOpacity(opacity); var actionArray = this._frameArray[ccs.FRAME_TYPE_FADE]; actionArray.push(actionFrame); @@ -115,8 +128,10 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var colorG = actionFrameDic["colorg"]; var colorB = actionFrameDic["colorb"]; var actionFrame = new ccs.ActionTintFrame(); - actionFrame.easingType = frameTweenType; - actionFrame.frameIndex = frameInex; +// actionFrame.easingType = frameTweenType; +// actionFrame.frameIndex = frameInex; + actionFrame.setEasingType(frameTweenType); + actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setColor(cc.color(colorR, colorG, colorB)); var actionArray = this._frameArray[ccs.FRAME_TYPE_TINT]; actionArray.push(actionFrame); diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index b230afa907..dd5e562eba 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -29,6 +29,8 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ _filePath: "", _olderVersion: false, _fileDesignSizes: {}, + _mapObject: {}, + _mapParseSelector: {}, /** * get version @@ -132,6 +134,21 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ this._filePath = ""; this._olderVersion = false; this._fileDesignSizes = {}; + }, + registerTypeAndCallBack: function(classType, ins, object, callback){ + var factoryCreate = ccs.objectFactory.getInstance(); + var t = new ccs.TInfo(classType, object); + factoryCreate.registerType(t); + + if(object){ + this._mapObject[classType] = object; + } + if(callback){ + this._mapParseSelector[classType] = callback; + } + }, + getFilePath: function(){ + return this._filePath; } }; diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js new file mode 100644 index 0000000000..a868632ee5 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -0,0 +1,170 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.ButtonReader = ccs.WidgetReader.extend({ + + instanceButtonReader: null, + + getInstance: function(){ + if(!this.instanceButtonReader){ + this.instanceButtonReader = new ccs.ButtonReader(); + } + return this.instanceButtonReader; + }, + + purge: function(){ + this.instanceButtonReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var button = widget; + var scale9Enable = options["scale9Enable"]; + button.setScale9Enabled(scale9Enable); + + var normalDic = options["normalData"]; + var normalType = normalDic["resourceType"]; + switch (normalType) + { + case 0: + { + var tp_n = jsonPath; + var normalFileName = normalDic["path"]; + var normalFileName_tp = (normalFileName && normalFileName !== "") ? + tp_n + normalFileName : + null; + button.loadTextureNormal(normalFileName_tp); + break; + } + case 1: + { + var normalFileName = normalDic["path"]; + button.loadTextureNormal(normalFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + var pressedDic = options["pressedData"]; + var pressedType = pressedDic["resourceType"]; + switch (pressedType) + { + case 0: + { + var tp_p = jsonPath; + var pressedFileName = pressedDic["path"]; + var pressedFileName_tp = (pressedFileName && pressedFileName !== "") ? + tp_p + pressedFileName : + null;; + button.loadTexturePressed(pressedFileName_tp); + break; + } + case 1: + { + var pressedFileName = pressedDic["path"]; + button.loadTexturePressed(pressedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + var disabledDic = options["disabledData"]; + var disabledType = disabledDic["resourceType"]; + switch (disabledType) + { + case 0: + { + var tp_d = jsonPath; + var disabledFileName = disabledDic["path"]; + var disabledFileName_tp = (disabledFileName && disabledFileName !== "") ? + tp_d + disabledFileName : + null; + button.loadTextureDisabled(disabledFileName_tp); + break; + } + case 1: + { + var disabledFileName = disabledDic["path"]; + button.loadTextureDisabled(disabledFileName,ui::UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + if (scale9Enable) + { + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + + button.setCapInsets(cc.rect(cx, cy, cw, ch)); + var sw = options["scale9Width"]; + var sh = options["scale9Height"]; + if (sw && sh) + { + var swf = options["scale9Width"]; + var shf = options["scale9Height"]; + button.setSize(cc.size(swf, shf)); + } + } + var tt = options["text"]; + if (tt) + { + var text = options["text"]; + if (text) + { + button.setTitleText(text); + } + } + + var cr = options["textColorR"]; + var cg = options["textColorG"]; + var cb = options["textColorB"]; + var cri = cr?options["textColorR"]:255; + var cgi = cg?options["textColorG"]:255; + var cbi = cb?options["textColorB"]:255; + + button.setTitleColor(cc.color(cri,cgi,cbi)); + var fs = options["fontSize"]; + if (fs) + { + button.setTitleFontSize(options["fontSize"]); + } + var fn = options["fontName"]; + if (fn) + { + button.setTitleFontName(options["fontName"]); + } + + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js new file mode 100644 index 0000000000..d7dc2cf017 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -0,0 +1,173 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.CheckBoxReader = ccs.WidgetReader.extend({ + + instanceCheckBoxReader: null, + + getInstance: function(){ + if(!this.instanceCheckBoxReader){ + this.instanceCheckBoxReader = new ccs.CheckBoxReader(); + } + return this.instanceCheckBoxReader; + }, + + purge: function(){ + this.instanceCheckBoxReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var checkBox = widget; + + var backGroundDic = options["backGroundBoxData"]; + var backGroundType = backGroundDic["resourceType"]; + switch (backGroundType) + { + case 0: + { + var tp_b = jsonPath; + var backGroundFileName = backGroundDic["path"]; + var backGroundFileName_tp = (backGroundFileName && backGroundFileName !== "") ? + tp_b + backGroundFileName : + null; + checkBox.loadTextureBackGround(backGroundFileName_tp); + break; + } + case 1: + { + var backGroundFileName = backGroundDic["path"]; + checkBox.loadTextureBackGround(backGroundFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + + var backGroundSelectedDic = options["backGroundBoxSelectedData"]; + var backGroundSelectedType = backGroundSelectedDic["resourceType"]; + switch (backGroundSelectedType) + { + case 0: + { + var tp_bs = jsonPath; + var backGroundSelectedFileName = backGroundSelectedDic["path"]; + var backGroundSelectedFileName_tp = (backGroundSelectedFileName && backGroundSelectedFileName !== "") ? + tp_bs + backGroundSelectedFileName : + null; + checkBox.loadTextureBackGroundSelected(backGroundSelectedFileName_tp); + break; + } + case 1: + { + var backGroundSelectedFileName = backGroundSelectedDic["path"]; + checkBox.loadTextureBackGroundSelected(backGroundSelectedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + + var frontCrossDic = options["frontCrossData"]; + var frontCrossType = frontCrossDic["resourceType"]; + switch (frontCrossType) + { + case 0: + { + var tp_c = jsonPath; + var frontCrossFileName = frontCrossDic["path"]; + var frontCrossFileName_tp = (frontCrossFileName && frontCrossFileName !== "") ? + tp_c + frontCrossFileName : + null; + checkBox.loadTextureFrontCross(frontCrossFileName_tp); + break; + } + case 1: + { + var frontCrossFileName = frontCrossDic["path"]; + checkBox.loadTextureFrontCross(frontCrossFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + + var backGroundDisabledDic = options["backGroundBoxDisabledData"]; + var backGroundDisabledType = backGroundDisabledDic["resourceType"]; + switch (backGroundDisabledType) + { + case 0: + { + var tp_bd = jsonPath; + var backGroundDisabledFileName = backGroundDisabledDic["path"]; + var backGroundDisabledFileName_tp = (backGroundDisabledFileName && backGroundDisabledFileName !== "") ? + tp_bd + backGroundDisabledFileName : + null; + checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); + break; + } + case 1: + { + var backGroundDisabledFileName = backGroundDisabledDic["path"]; + checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + + var frontCrossDisabledDic = options["frontCrossDisabledData"]; + var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; + switch (frontCrossDisabledType) + { + case 0: + { + var tp_cd = jsonPath; + var frontCrossDisabledFileName = options["path"]; + var frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && frontCrossDisabledFileName !== "") ? + tp_cd + frontCrossDisabledFileName : + null; + checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); + break; + } + case 1: + { + var frontCrossDisabledFileName = options["path"]; + checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js new file mode 100644 index 0000000000..f1d16b6b47 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -0,0 +1,108 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.ImageViewReader = ccs.WidgetReader.extend({ + + instanceImageViewReader: null, + + getInstance: function(){ + if(!this.instanceImageViewReader){ + this.instanceImageViewReader = new ccs.ImageViewReader(); + } + return this.instanceImageViewReader; + }, + + purge: function(){ + this.instanceImageViewReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var imageView = widget; + + var imageFileNameDic = options["fileNameData"]; + var imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType) + { + case 0: + { + var tp_i = jsonPath; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = NULL; + if (imageFileName && imageFileName !== "") + { + imageFileName_tp = tp_i + imageFileName; + imageView.loadTexture(imageFileName_tp); + } + break; + } + case 1: + { + var imageFileName = imageFileNameDic["path"]; + imageView.loadTexture(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + + var scale9EnableExist = options["scale9Enable"]; + var scale9Enable = false; + if (scale9EnableExist) + { + scale9Enable = options["scale9Enable"]; + } + imageView.setScale9Enabled(scale9Enable); + + + if (scale9Enable) + { + var sw = options["scale9Width"]; + var sh = options["scale9Height"]; + if (sw && sh) + { + var swf = options["scale9Width"]; + var shf = options["scale9Height"]; + imageView.setSize(cc.size(swf, shf)); + } + + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + + imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); + + } + + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js new file mode 100644 index 0000000000..76d7ee29c2 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -0,0 +1,82 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.LabelAtlasReader = ccs.WidgetReader.extend({ + + instanceLabelAtalsReader: null, + + getInstance: function(){ + if(!this.instanceLabelAtalsReader){ + this.instanceLabelAtalsReader = new ccs.LabelAtlasReader(); + } + return this.instanceLabelAtalsReader; + }, + + purge: function(){ + this.instanceLabelAtalsReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var labelAtlas = widget; + var sv = options["stringValue"]; + var cmf = options["charMapFile"]; + var iw = options["itemWidth"]; + var ih = options["itemHeight"]; + var scm = options["startCharMap"]; + if (sv && cmf && iw && ih && scm){ + var cmftDic = options["charMapFileData"]; + var cmfType = cmftDic["resourceType"]; + switch (cmfType){ + case 0: + var tp_c = jsonPath; + var cmfPath = cmftDic["path"]; + var cmf_tp = tp_c + cmfPath; + labelAtlas.setProperty( + options["stringValue"], + cmf_tp, + options["itemWidth"], + options["itemHeight"], + options["startCharMap"] + ); + break; + case 1: + cc.log("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + } + + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js new file mode 100644 index 0000000000..e257028539 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -0,0 +1,76 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.LabelBMFontReader = ccs.WidgetReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.LabelBMFontReader(); + } + return this.instanceTextFieldReader; + }, + + purge: function(){ + this.instanceTextFieldReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var labelBMFont = widget; + + var cmftDic = options["fileNameData"]; + var cmfType = cmftDic["resourceType"]; + switch (cmfType) + { + case 0: + { + var tp_c = jsonPath; + var cmfPath = cmftDic["path"]; + var cmf_tp = tp_c + cmfPath; + labelBMFont.setFntFile(cmf_tp); + break; + } + case 1: + cc.log("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + + var text = options["text"]; + labelBMFont.setText(text); + + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js new file mode 100644 index 0000000000..9776ed2fe7 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -0,0 +1,84 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.LabelReader = ccs.WidgetReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.LabelReader(); + } + return this.instanceTextFieldReader; + }, + + purge: function(){ + this.instanceTextFieldReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var label = widget; + var touchScaleChangeAble = options["touchScaleEnable"]; + label.setTouchScaleChangeEnabled(touchScaleChangeAble); + var text = options["text"]; + label.setText(text); + var fs = options["fontSize"]; + if (fs) + { + label.setFontSize(options["fontSize"]); + } + var fn = options["fontName"]; + if (fn) + { + label.setFontName(options["fontName"]); + } + var aw = options["areaWidth"]; + var ah = options["areaHeight"]; + if (aw && ah) + { + var size = cc.size(options["areaWidth"], options["areaHeight"]); + label.setTextAreaSize(size); + } + var ha = options["hAlignment"]; + if (ha) + { + label.setTextHorizontalAlignment(options["hAlignment"]); + } + var va = options["vAlignment"]; + if (va) + { + label.setTextVerticalAlignment(options["vAlignment"]); + } + + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js new file mode 100644 index 0000000000..fac7a947f3 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -0,0 +1,128 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.LayoutReader = ccs.WidgetReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.LayoutReader(); + } + return this.instanceTextFieldReader; + }, + + purge: function(){ + this.instanceTextFieldReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var panel = widget; + + var w = 0, h = 0; + var adaptScrenn = options["adaptScreen"]; + if (adaptScrenn){ + var screenSize = cc.director.getWinSize(); + w = screenSize.width; + h = screenSize.height; + }else{ + w = options["width"]; + h = options["height"]; + } + panel.setSize(cc.size(w, h)); + + panel.setClippingEnabled(options["clipAble"]); + + var backGroundScale9Enable = options["backGroundScale9Enable"]; + panel.setBackGroundImageScale9Enabled(backGroundScale9Enable); + var cr = options["bgColorR"]; + var cg = options["bgColorG"]; + var cb = options["bgColorB"]; + + var scr = options["bgStartColorR"]; + var scg = options["bgStartColorG"]; + var scb = options["bgStartColorB"]; + + var ecr = options["bgEndColorR"]; + var ecg = options["bgEndColorG"]; + var ecb = options["bgEndColorB"]; + + var bgcv1 = options["vectorX"]; + var bgcv2 = [options, "vectorY"]; + panel.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); + + var co = options["bgColorOpacity"]; + + var colorType = options["colorType"]; + panel.setBackGroundColorType(colorType/*ui::LayoutBackGroundColorType(colorType)*/); + panel.setBackGroundColor(cc.color(scr, scg, scb), cc.color(ecr, ecg, ecb)); + panel.setBackGroundColor(cc.color(cr, cg, cb)); + panel.setBackGroundColorOpacity(co); + + + var imageFileNameDic = options["backGroundImageData"]; + var imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType) + { + case 0: + { + var tp_b = jsonPath; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = (imageFileName && (imageFileName !== "")) ? + tp_b + imageFileName : + null; + panel.setBackGroundImage(imageFileName_tp); + break; + } + case 1: + { + var imageFileName = imageFileNameDic["path"]; + panel.setBackGroundImage(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + + if (backGroundScale9Enable) + { + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + } + panel.setLayoutType(options["layoutType"]); + + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js new file mode 100644 index 0000000000..a0930bc9e4 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -0,0 +1,56 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.ListViewReader = ccs.ScrollViewReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.ListViewReader(); + } + return this.instanceTextFieldReader; + }, + + purge: function(){ + this.instanceTextFieldReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.ScrollViewReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + var listView = widget; + + var direction = options["direction"]; + listView.setDirection(direction); + + var gravity = options["gravity"]; + listView.setGravity(gravity); + + var itemMargin = options["itemMargin"]; + listView.setItemsMargin(itemMargin); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js new file mode 100644 index 0000000000..b3debe0d44 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -0,0 +1,91 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.LoadingBarReader = ccs.WidgetReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.LoadingBarReader(); + } + return this.instanceTextFieldReader; + }, + + purge: function(){ + this.instanceTextFieldReader = null; + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var jsonPath = ccs.uiReader.getFilePath(); + + var loadingBar = widget; + + var imageFileNameDic = options["textureData"]; + var imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType){ + case 0: + var tp_i = jsonPath; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = null; + if (imageFileName && (imageFileName !== "")){ + imageFileName_tp = tp_i + imageFileName; + loadingBar.loadTexture(imageFileName_tp); + } + break; + case 1: + var imageFileName = imageFileNameDic["path"]; + loadingBar.loadTexture(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + + var scale9Enable = options["scale9Enable"]; + loadingBar.setScale9Enabled(scale9Enable); + + if (scale9Enable){ + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + + loadingBar.setCapInsets(cc.rect(cx, cy, cw, ch)); + + var width = options["width"]; + var height = options["height"]; + loadingBar.setSize(cc.size(width, height)); + } + + loadingBar.setDirection(options["direction"]/*ui::LoadingBarType(options["direction"])*/); + loadingBar.setPercent(options["percent"]); + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js new file mode 100644 index 0000000000..7a986d10f6 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -0,0 +1,45 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.PageViewReader = ccs.LayoutReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.PageViewReader(); + } + return this.instanceTextFieldReader; + }, + + purge: function(){ + + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.LayoutReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js new file mode 100644 index 0000000000..b6f683d04d --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -0,0 +1,60 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.ScrollViewReader = ccs.LayoutReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.ScrollViewReader(); + } + return this.instanceTextFieldReader; + }, + + purge: function(){ + + }, + + setPropsFromJsonDictionary: function(widget, options){ + + ccs.LayoutReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + + var scrollView = widget; + + var innerWidth = options["innerWidth"]; + var innerHeight = options["innerHeight"]; + scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + + var direction = options["direction"]; + scrollView.setDirection(direction); + + scrollView.setBounceEnabled(options["bounceEnable"]); + + + ccs.LayoutReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js new file mode 100644 index 0000000000..4bb1690568 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -0,0 +1,167 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.SliderReader = ccs.WidgetReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.SliderReader(); + } + return this.instanceTextFieldReader; + }, + purge: function(){ + this.instanceTextFieldReader = null; + }, + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + var jsonPath = ccs.uiReader.getFilePath(); + + var slider = widget; + + var barTextureScale9Enable = options["barTextureScale9Enable"]; + slider.setScale9Enabled(barTextureScale9Enable); + var bt = options["barFileName"]; + var barLength = options["length"]; + if(bt){ + if(barTextureScale9Enable){ + var imageFileNameDic = options["barFileNameData"]; + var imageFileType = options["resourceType"]; + switch(imageFileType){ + case 0: + var tp_b = jsonPath; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = (imageFileName && imageFileName !== "" ) ? + ( tp_b + imageFileName ) : + null; + slider.loadBarTexture(imageFileName_tp); + break; + case 1: + var imageFileName = imageFileNameDic["path"]; + slider.loadBarTexture(imageFileName, 1 /*ui::UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + slider.setSize(cc.size(barLength, slider.getContentSize().height)); + } + }else{ + var imageFileNameDic = options["barFileNameDic"]; + var imageFileType = imageFileNameDic["resourceType"]; + switch(imageFileType){ + case 0: + var tp_b = jsonPath; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = ( imageFileName && imageFileName !== "" ) ? + tp_b + imageFileName : + slider.loadBarTexture(imageFileName_tp); + break; + case 1: + var imageFileName = imageFileNameDic["path"]; + slider.loadBarTexture(imageFileName, 1 /*ui::UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + } + var normalDic = options["ballNormalData"]; + switch(normalDic){ + case 0: + var tp_n = jsonPath; + var normalFileName = normalDic["path"]; + var normalFileName_tp = ( normalFileName && (normalFileName !== "") ) ? + tp_n + normalFileName : + null; + slider.loadSlidBallTextureNormal(normalFileName_tp); + break; + case 1: + var normalFileName = normalDic["path"]; + slider.loadSlidBallTextureNormal(normalFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + + var pressedDic = options["ballPressedData"]; + var pressedTyep = pressedDic["resourceType"]; + switch(pressedTyep){ + case 0: + var tp_p = jsonPath; + var pressedFileName = pressedDic["path"]; + var pressedFileName_tp = ( pressedFileName && pressedFileName !== "" ) ? + tp_p + pressedFileName : + null; + slider.loadSlidBallTexturePressed(pressedFileName_tp); + break; + case 1: + var pressedFileName = pressedDic["path"]; + slider.loadSlidBallTexturePressed(pressedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + var disabledDic = options["ballDisabledData"]; + var disabledType = disabledDic["resourceType"]; + switch(disabledType){ + case 0: + var tp_d = jsonPath; + var disabledFileName = disabledDic["path"]; + var disabledFileName_tp = ( disabledFileName && disabledFileName !== "" ) ? + tp_d + disabledFileName : + null; + slider.loadSlidBallTextureDisabled(disabledFileName_tp); + break; + case 1: + var disabledFileName = disabledDic["path"]; + slider.loadSlidBallTextureDisabled(disabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + var progressBarDic = options["progressBarData"]; + var progressBarType = progressBarDic["resourceType"]; + switch (progressBarType){ + case 0: + var tp_b = jsonPath; + var imageFileName = progressBarDic["path"]; + var imageFileName_tp = ( imageFileName && imageFileName !== "" ) ? + (tp_b + imageFileName) : + null; + slider.loadProgressBarTexture(imageFileName_tp); + break; + case 1: + var imageFileName = progressBarDic["path"]; + slider.loadProgressBarTexture(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js new file mode 100644 index 0000000000..ee7828dba8 --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -0,0 +1,99 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.TextFieldReader = ccs.WidgetReader.extend({ + + instanceTextFieldReader: null, + + getInstance: function(){ + if(!this.instanceTextFieldReader){ + this.instanceTextFieldReader = new ccs.TextFieldReader(); + } + return this.instanceTextFieldReader; + }, + purge: function(){ + this.instanceTextFieldReader = null; + }, + setPropsFromJsonDictionary: function(widget, options){ + + ccs.WidgetReader.prototype.setPropsFromJsonDictionary.call(this, widget, options); + + var textField = widget; + var ph = options["placeHolder"]; + if(ph){ + textField.setPlaceHolder(ph); + } + textField.setText(options["text"]); + var fs = options["fontSize1"]; + if(fs){ + textField.setFontSize(fs); + } + var fn = options["fontName"]; + if(fn){ + textField.setFontName(fn); + } + var tsw = options["touchSizeWidth"]; + var tsh = options["touchSizeHeight"]; + if(tsw && tsh){ + textField.setTouchSize(tsw, tsh); + } + + var dw = options["width"]; + var dh = options["height"]; + if(dw > 0 || dh > 0){ + //textField.setSize(cc.size(dw, dh)); + } + var maxLengthEnable = options["maxLengthEnable"]; + textField.setMaxLengthEnabled(maxLengthEnable); + + if(maxLengthEnable){ + var maxLength = options["maxLength"]; + textField.setMaxLength(maxLength); + } + var passwordEnable = options["passwordEnable"]; + textField.setPasswordEnabled(passwordEnable); + if(passwordEnable){ + textField.setPasswordStyleText(options["passwordStyleText"]); + } + + var aw = options["areaWidth"]; + var ah = options["areaHeight"]; + if(aw && ah){ + var size = cc.size(aw, ah); + textField.setTextAreaSize(size); + } + var ha = options["hAlignment"]; + if(ha){ + textField.setTextHorizontalAlignment(ha); + } + var va = options["vAlignment"]; + if(va){ + textField.setTextVerticalAlignment(va); + } + + ccs.WidgetReader.prototype.setColorPropsFromJsonDictionary.call(this, widget, options); + + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js new file mode 100644 index 0000000000..45696e65cf --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -0,0 +1,139 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.WidgetReader = ccs.WidgetReaderProtocol.extend({ + + instanceWidgetReader: null, + + getInstance: function(){ + if(!this.instanceWidgetReader){ + this.instanceWidgetReader = new ccs.WidgetReader(); + } + return this.instanceWidgetReader; + }, + purge: function(){ + this.instanceWidgetReader = null; + }, + setPropsFromJsonDictionary: function(widget, options){ + + var ignoreSizeExsit = options["ignoreSize"]; + if(ignoreSizeExsit){ + widget.ignoreContentAdaptWithSize(ignoreSizeExsit); + } + + widget.setSizeType(options["sizeType"]); + widget.setPositionType(options["positionType"]); + + widget.setSizePercent(cc.p(options["sizePercentX"], options["sizePercentY"])); + widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"])); + + var w = options["width"]; + var h = options["height"]; + widget.setSize(cc.size(w, h)); + + widget.setTag(options["tag"]); + widget.setActionTag(options["actiontag"]); + widget.setTouchEnabled(options["touchAble"]); + var name = options["name"]; + var widgetName = name ? name : "default"; + widget.setName(widgetName); + + var x = options["x"]; + var y = options["y"]; + widget.setPosition(cc.p(x, y)); + + var sx = options["scalex"]; + if(sx){ + widget.setScaleX(sx); + } + var sy = options["scaleY"]; + if(sy){ + widget.setScaleY(sy); + } + var rt = options["rotation"]; + if(rt){ + widget.setRotation(rt); + } + var vb = options["visible"]; + if(vb){ + widget.setVisible(vb); + } + widget.setZOrder(options["ZOrder"]); + + var layout = options["layoutParameter"]; + if(layout){ + var layoutParameterDic = options["layoutParameter"]; + var paramType = options["type"]; + var parameter = null; + + switch(paramType){ + case 0: + break; + case 1: + parameter = ccs.LinearLayoutParameter.create(); + var gravity = layoutParameterDic["gravity"]; + parameter.setGravity(gravity); + break; + case 2: + parameter = ccs.RelativeLayoutParameter.create(); + var rParameter = parameter; + var relativeName = options["relativeName"]; + rParameter.setRelativeName(relativeName); + var align = layoutParameterDic["align"]; + rParameter.setAlign(align); + break; + default: + break; + } + if(parameter){ + var mgl = layoutParameterDic["marginLeft"]; + var mgt = layoutParameterDic["marginTop"]; + var mgr = layoutParameterDic["marginRight"]; + var mgb = layoutParameterDic["marginDown"]; + parameter.setMargin(mgl, mgt, mgr, mgb); + widget.setLayoutParameter(parameter); + } + } + + + }, + setColorPropsFromJsonDictionary: function(widget, options){ + var op = options["opacity"]; + if(op){ + widget.setOpacity(op); + } + var colorR = options["colorR"] || 255; + var colorG = options["colorG"] || 255; + var colorB = options["colorB"] || 255; + widget.setColor(cc.color(colorR, colorG, colorB)); + var apx = options["anchorPointX"]; + var apxf = apx || (widget.getWidgetType() === ccs.WidgetType ? 0.5 : 0); + var apy = options["anchorPointY"]; + var apyf = apy || (widget.getWidgetType() === ccs.WidgetType ? 0.5 : 0); + widget.setAnchorPoint(cc.p(apxf, apyf)); + widget.setFlipX(options["flipX"]); + widget.setFlipX(options["flipY"]); + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js new file mode 100644 index 0000000000..e2d581db9f --- /dev/null +++ b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js @@ -0,0 +1,31 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.WidgetReaderProtocol = cc.Class.extend({ + + setPropsFromJsonDictionary: function(widget, options){ + + } +}); \ No newline at end of file diff --git a/extensions/cocostudio/trigger/ObjectFactory.js b/extensions/cocostudio/trigger/ObjectFactory.js index fdc0f36669..8b1e26398a 100644 --- a/extensions/cocostudio/trigger/ObjectFactory.js +++ b/extensions/cocostudio/trigger/ObjectFactory.js @@ -41,7 +41,43 @@ ccs.objectFactory = { registerType: function (t) { this._typeMap[t._className] = t; + }, + + createGUI: function(name){ + var object = null; + if(name === "Panel"){ + name = "Layout"; + }else if(name === "TextArea"){ + name = "Label"; + }else if(name === "TextButton"){ + name = "Button"; + } + + do{ + + var t = this._typeMap[name]; + if(t._fun === null){ + break; + } + object = t._fun; + }while(0); + + return object; + }, + + createWidgetReaderProtocol: function(name){ + var object = null; + do{ + var t = this._typeMap[name]; + if(t._fun === null){ + break; + } + object = t._fun; + }while(0); + return object; } + + }; ccs.TInfo = ccs.Class.extend({ From 036bf96318b68d5d721f77317a7220ad44c2852f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 19 Jun 2014 09:47:35 +0800 Subject: [PATCH 0168/1564] Follow up the code - #5614 --- extensions/cocostudio/action/CCActionFrame.js | 6 ++++++ extensions/cocostudio/action/CCActionNode.js | 1 + .../reader/widgetreader/SliderReader/SliderReader.js | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index ce5b84eede..8dd454c052 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -214,6 +214,12 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ } return resultAction; + }, + setEasingParameter: function(parameter){ + this._Parameter = []; + for(var i=0;i Date: Thu, 19 Jun 2014 10:18:11 +0800 Subject: [PATCH 0169/1564] Follow up the code - #5614 --- extensions/ccui/uiwidgets/UITextField.js | 10 ++- extensions/cocostudio/ActionManagerEx.js | 77 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 extensions/cocostudio/ActionManagerEx.js diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 5a48d5fff1..3e2ec5168b 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -32,7 +32,7 @@ * @property {Number} maxLength - The max length of the text field * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password */ -ccui.UILabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ +ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ maxLengthEnabled: false, maxLength: 0, passwordEnabled: false, @@ -279,6 +279,14 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# ccui.Widget.prototype.ctor.call(this); }, + init: function(){ + if(ccui.Widget.prototype.init.call(this)){ + this.setTouchEnabled(true); + return true; + } + return false; + }, + onEnter: function () { ccui.Widget.prototype.onEnter.call(this); this.setUpdateEnabled(true); diff --git a/extensions/cocostudio/ActionManagerEx.js b/extensions/cocostudio/ActionManagerEx.js new file mode 100644 index 0000000000..e8b91d681e --- /dev/null +++ b/extensions/cocostudio/ActionManagerEx.js @@ -0,0 +1,77 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.ActionManagerEx = ccs.Class.extend({ + + initWithDictionary: function(jsonName, dic, root){ + var path = jsonName; + var pos = path.lastIndexOf("/"); + var fileName = path.substr(pos+1,path.length()); + cc.log("filename == %s",fileName.toString()); + var actionList = []; + var actionCount = dic["actionlist"]; + for (var i=0; i Date: Thu, 19 Jun 2014 11:15:44 +0800 Subject: [PATCH 0170/1564] Follow up the code - #5668 --- .../uiwidgets/scroll-widget/UIListView.js | 17 +- extensions/cocostudio/reader/GUIReader.js | 209 +++++++++++------- 2 files changed, 148 insertions(+), 78 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 7b738bc86e..61b13b2f35 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -378,9 +378,17 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._listViewEventSelector = selector; }, - selectedItemEvent: function () { + selectedItemEvent: function (state) { if(this._listViewEventSelector&&this._listViewEventListener){ - this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.EVENT_SELECTED_ITEM); + + switch(state){ + case 0: + this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_START); + break; + default: + this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_END); + break; + } } }, @@ -395,7 +403,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } parent = parent.getParent(); } - this.selectedItemEvent(); + this.selectedItemEvent(handleState); } }, @@ -479,6 +487,9 @@ ccui.ListView.create = function () { //listView event type ccui.ListView.EVENT_SELECTED_ITEM = 0; +ccui.LISTVIEW_ONSELECTEDITEM_START = 0; +ccui.LISTVIEW_ONSELECTEDITEM_END = 1; + //listView gravity ccui.ListView.GRAVITY_LEFT = 0; ccui.ListView.GRAVITY_RIGHT = 1; diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index dd5e562eba..2e9b60f198 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -149,6 +149,12 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ }, getFilePath: function(){ return this._filePath; + }, + getParseObjectMap: function(){ + return this._mapObject; + }, + getParseCallBackMap: function(){ + return this._mapParseSelector; } }; @@ -304,6 +310,8 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var z = options["ZOrder"]; widget.setLocalZOrder(z); }, + setPropsForAllWidgetFromJsonDictionary: function(){}, + setPropsForAllCustomWidgetFromJsonDictionary: function(){}, setColorPropsForWidgetFromJsonDictionary: function (widget, options) { if (options["opacity"] !== undefined) { @@ -790,90 +798,141 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ actions = null; return widget; }, + setPropsForAllWidgetFromJsonDictionary: function(reader, widget, options){ + reader.setPropsFromJsonDictionary(widget, options); + }, + setPropsForAllCustomWidgetFromJsonDictionary: function(classType, widget, customOptions){ + var guiReader = ccs.uiReader; + + var object_map = guiReader.getParseObjectMap(); + var object = object_map[classType]; + + var selector_map = guiReader.getParseCallBackMap(); + var selector = selector_map[classType]; + + if (object && selector) + { + object.selector.call(this, classType, widget, customOptions); + } + + }, widgetFromJsonDictionary: function (data) { - var widget = null; + var classname = data["classname"]; var uiOptions = data["options"]; - if (classname == "Button") { - widget = ccui.Button.create(); - this.setPropsForButtonFromJsonDictionary(widget, uiOptions); - } - else if (classname == "CheckBox") { - widget = ccui.CheckBox.create(); - this.setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); - } - else if (classname == "Label") { - widget = ccui.Text.create(); - this.setPropsForLabelFromJsonDictionary(widget, uiOptions); - } - else if (classname == "LabelAtlas") { - widget = ccui.TextAtlas.create(); - this.setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); - } - else if (classname == "LoadingBar") { - widget = ccui.LoadingBar.create(); - this.setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); - } else if (classname == "ScrollView") { - widget = ccui.ScrollView.create(); - this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); - } - else if (classname == "TextArea") { - widget = ccui.Text.create(); - this.setPropsForLabelFromJsonDictionary(widget, uiOptions); - } - else if (classname == "TextButton") { - widget = ccui.Button.create(); - this.setPropsForButtonFromJsonDictionary(widget, uiOptions); - } - else if (classname == "TextField") { - widget = ccui.TextField.create(); - this.setPropsForTextFieldFromJsonDictionary(widget, uiOptions); - } - else if (classname == "ImageView") { - widget = ccui.ImageView.create(); - this.setPropsForImageViewFromJsonDictionary(widget, uiOptions); - } - else if (classname == "Panel") { - widget = ccui.Layout.create(); - this.setPropsForLayoutFromJsonDictionary(widget, uiOptions); - } - else if (classname == "Slider") { - widget = ccui.Slider.create(); - this.setPropsForSliderFromJsonDictionary(widget, uiOptions); - } - else if (classname == "LabelBMFont") { - widget = ccui.TextBMFont.create(); - this.setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); - } - else if (classname == "DragPanel") { - widget = ccui.ScrollView.create(); - this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); - } - else if (classname == "ListView") { - widget = ccui.ListView.create(); - this.setPropsForListViewFromJsonDictionary(widget, uiOptions); + var widget = ccs.objectFactory.getInstance().createGUI(classname); + + // create widget reader to parse properties of widget + var readerName = classname; + switch(readerName){ + case "Panel": + readerName = "Layout"; + break; + case "TextArea": + readerName = "Label"; + break; + case "TextButton": + readerName = "Button"; + break; } - else if (classname == "PageView") { - widget = ccui.PageView.create(); - this.setPropsForPageViewFromJsonDictionary(widget, uiOptions); + readerName += "Reader"; + var reader = ccs.objectFactory.getInstance().createWidgetReaderProtocol(readerName); + if(reader){ + // widget parse with widget reader + this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); + }else{ + // 1st., custom widget parse properties of parent widget with parent widget reader + if(widget instanceof ccs.Button){ + readerName = "ButtonReader"; + }else if(widget instanceof ccs.CheckBox){ + readerName = "CheckBoxReader"; + }else if (widget instanceof ccs.ImageView) + { + readerName = "ImageViewReader"; + } + else if (widget instanceof ccs.LabelAtlas) + { + readerName = "LabelAtlasReader"; + } + else if (widget instanceof ccs.LabelBMFont) + { + readerName = "LabelBMFontReader"; + } + else if (widget instanceof ccs.Label) + { + readerName = "LabelReader"; + } + else if (widget instanceof ccs.LoadingBar) + { + readerName = "LoadingBarReader"; + } + else if (widget instanceof ccs.Slider) + { + readerName = "SliderReader"; + } + else if (widget instanceof ccs.TextField) + { + readerName = "TextFieldReader"; + } + else if (widget instanceof ccs.Layout) + { + readerName = "LayoutReader"; + } + else if (widget instanceof ccs.ScrollView) + { + readerName = "ScrollViewReader"; + } + else if (widget instanceof ccs.ListView) + { + readerName = "ListViewReader"; + } + else if (widget instanceof ccs.PageView) + { + readerName = "PageViewReader"; + } + else if (widget instanceof ccs.Widget) + { + readerName = "WidgetReader"; + } + + var render = ccs.objectFactory.getInstance().createWidgetReaderProtocol(readerName); + this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); + + // 2nd., custom widget parse with custom reader + var customProperty = uiOptions["customProperty"]; + var customJsonDict = uiOptions; + if (!uiOptions) + { + cc.log("GetParseError"); + } + this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); } - var children = data["children"]; - for (var i = 0; i < children.length; i++) { - var subData = children[i]; + var childrenCount = data["children"]; + for (var i = 0; i < childrenCount; i++) + { + var subData = data["children"][i]; var child = this.widgetFromJsonDictionary(subData); - if (child) { - if (widget instanceof ccui.PageView && child instanceof ccui.Layout) { - widget.addPage(child); - } else if (widget instanceof ccui.ListView) { - widget.pushBackCustomItem(child); - } else { - widget.addChild(child); + if (child) + { + var pageView = widget; + if (pageView) + { + pageView.addPage(child); + } + else + { + var listView = widget; + if (listView) + { + listView.pushBackCustomItem(child); + } + else + { + widget.addChild(child); + } } } - subData = null; } - - uiOptions = null; return widget; }, From 4890fdaf012d376840ff89bcfd88b5db6cfdc277 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 19 Jun 2014 16:44:49 +0800 Subject: [PATCH 0171/1564] Closed #3546: Added bake function to cc.Layer --- cocos2d/core/base-nodes/CCNode.js | 14 +- cocos2d/core/layers/CCLayer.js | 228 +++++++++++++++++++++- cocos2d/core/layers/CCLayerWebGL.js | 8 + cocos2d/core/sprites/CCBakeSprite.js | 68 +++++++ cocos2d/render-texture/CCRenderTexture.js | 2 +- moduleConfig.json | 1 + 6 files changed, 311 insertions(+), 10 deletions(-) create mode 100644 cocos2d/core/sprites/CCBakeSprite.js diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index a375c9a819..8962188412 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1868,10 +1868,21 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ this._cacheDirty = true; var cachedP = this._cachedParent; + //var cachedP = this._parent; cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); } }, + _setCachedParent: function(cachedParent){ + if(this._cachedParent == cachedParent) + return; + + this._cachedParent = cachedParent; + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._setCachedParent(cachedParent); + }, + /** * Returns a camera object that lets you move the node using a gluLookAt * @return {cc.Camera} A CCCamera object that lets you move the node using a gluLookAt @@ -1949,7 +1960,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); var trans = this.nodeToWorldTransform(); rect = cc.RectApplyAffineTransform(rect, this.nodeToWorldTransform()); - //rect = cc.rect(0 | rect.x - 4, 0 | rect.y - 4, 0 | rect.width + 8, 0 | rect.height + 8); //query child's BoundingBox if (!this._children) @@ -1987,6 +1997,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } return rect; }, + _nodeToParentTransformForWebGL: function () { var _t = this; if (_t._transformDirty) { @@ -2116,6 +2127,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } else _t.draw(context); + this._cacheDirty = false; _t.arrivalOrder = 0; context.restore(); }; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 766c9f5f30..97fbc08fd1 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -32,10 +32,8 @@ * @extends cc.Node */ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ - /** - * init layer - * @return {Boolean} - */ + _isBaked: false, + _bakeSprite: null, _className: "Layer", /** @@ -47,7 +45,28 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ this._ignoreAnchorPointForPosition = true; nodep.setAnchorPoint.call(this, 0.5, 0.5); nodep.setContentSize.call(this, cc.winSize); - } + this._cachedParent = this; + }, + + /** + * set the layer to cache all of children to a bake sprite, and draw itself by bake sprite. recommend using it in UI. + */ + bake: null, + + /** + * cancel the layer to cache all of children to a bake sprite. + */ + unbake: null, + + /** + * Determines if the layer is baked. + * @returns {boolean} + */ + isBaked: function(){ + return this._isBaked; + }, + + visit: null }); /** @@ -62,6 +81,111 @@ cc.Layer.create = function () { return new cc.Layer(); }; +if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + var p = cc.Layer.prototype; + p.bake = function(){ + if (!this._isBaked) { + //limit: 1. its children's blendfunc are invalid. + this._isBaked = this._cacheDirty = true; + + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._setCachedParent(this); + + if (!this._bakeSprite) + this._bakeSprite = new cc.BakeSprite(); + } + }; + + p.unbake = function(){ + if (this._isBaked) { + this._isBaked = false; + this._cacheDirty = true; + + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._setCachedParent(null); + } + }; + + p.visit = function(ctx){ + if(!this._isBaked){ + cc.Node.prototype.visit.call(this, ctx); + return; + } + + var context = ctx || cc._renderContext, i; + var _t = this; + var children = _t._children; + var len = children.length; + // quick return if not visible + if (!_t._visible || len === 0) + return; + + var locBakeSprite = this._bakeSprite; + + context.save(); + _t.transform(context); + + if(this._cacheDirty){ + //compute the bounding box of the bake layer. + var boundingBox = this._getBoundingBoxForBake(); + boundingBox.width = 0 | boundingBox.width; + boundingBox.height = 0 | boundingBox.height; + var bakeContext = locBakeSprite.getCacheContext(); + locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); + bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); + + //reset the bake sprite's position + var anchor = locBakeSprite.getAnchorPointInPoints(); + locBakeSprite.setPosition(anchor.x + boundingBox.x, anchor.y + boundingBox.y); + + //visit for canvas + _t.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + children[i].visit(bakeContext); + } + + this._cacheDirty = false; + } + + //the bakeSprite is drawing + locBakeSprite.visit(context); + + _t.arrivalOrder = 0; + context.restore(); + }; + + p._getBoundingBoxForBake = function () { + var rect = null; + + //query child's BoundingBox + if (!this._children || this._children.length === 0) + return cc.rect(0, 0, 10, 10); + + var locChildren = this._children; + for (var i = 0; i < locChildren.length; i++) { + var child = locChildren[i]; + if (child && child._visible) { + if(rect){ + var childRect = child._getBoundingBoxToCurrentNode(); + if (childRect) + rect = cc.rectUnion(rect, childRect); + }else{ + rect = child._getBoundingBoxToCurrentNode(); + } + } + } + return rect; + }; + p = null; +}else{ + cc.assert(typeof cc._tmp.LayerDefineForWebGL === "function", cc._LogInfos.MissingFile, "CCLayerWebGL.js"); + cc._tmp.LayerDefineForWebGL(); + delete cc._tmp.LayerDefineForWebGL; +} + /** *

* CCLayerRGBA is a subclass of CCLayer that implements the CCRGBAProtocol protocol using a solid color as the background.
@@ -508,7 +632,6 @@ cc.LayerColor.create = function (color, width, height) { return new cc.LayerColor(color, width, height); }; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerColor define start var _p = cc.LayerColor.prototype; @@ -516,7 +639,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.LayerRGBA.prototype.ctor.call(this); this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); cc.LayerColor.prototype.init.call(this, color, width, height); - } + }; _p._setWidth = cc.LayerRGBA.prototype._setWidth; _p._setHeight = cc.LayerRGBA.prototype._setHeight; _p._updateColor = function () { @@ -530,7 +653,96 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.fillRect(0, 0, _t.width * locEGLViewer.getScaleX(), -_t.height * locEGLViewer.getScaleY()); cc.g_NumberOfDraws++; }; - //cc.LayerGradient define end + + //for bake + _p.visit = function(ctx){ + if(!this._isBaked){ + cc.Node.prototype.visit.call(this, ctx); + return; + } + + var context = ctx || cc._renderContext, i; + var _t = this; + var children = _t._children; + var len = children.length; + // quick return if not visible + if (!_t._visible) + return; + + var locBakeSprite = this._bakeSprite; + + context.save(); + _t.transform(context); + + if(this._cacheDirty){ + //compute the bounding box of the bake layer. + var boundingBox = this._getBoundingBoxForBake(); + boundingBox.width = 0 | boundingBox.width; + boundingBox.height = 0 | boundingBox.height; + var bakeContext = locBakeSprite.getCacheContext(); + locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); + var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = this._position; + if(this._ignoreAnchorPointForPosition){ + bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); + //reset the bake sprite's position + locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); + } else { + var selfAnchor = this.getAnchorPointInPoints(); + var selfPos = {x: locPos.x - selfAnchor.x, y: locPos.y - selfAnchor.y}; + bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); + locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); + } + + var child; + //visit for canvas + if (len > 0) { + _t.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + child = children[i]; + if (child._localZOrder < 0) + child.visit(bakeContext); + else + break; + } + _t.draw(bakeContext); + for (; i < len; i++) { + children[i].visit(bakeContext); + } + } else + _t.draw(bakeContext); + this._cacheDirty = false; + } + + //the bakeSprite is drawing + locBakeSprite.visit(context); + + _t.arrivalOrder = 0; + context.restore(); + }; + + _p._getBoundingBoxForBake = function () { + //default size + var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); + var trans = this.nodeToWorldTransform(); + rect = cc.RectApplyAffineTransform(rect, this.nodeToWorldTransform()); + + //query child's BoundingBox + if (!this._children || this._children.length === 0) + return rect; + + var locChildren = this._children; + for (var i = 0; i < locChildren.length; i++) { + var child = locChildren[i]; + if (child && child._visible) { + var childRect = child._getBoundingBoxToCurrentNode(trans); + rect = cc.rectUnion(rect, childRect); + } + } + return rect; + }; + + //cc.LayerColor define end _p = null; } else { cc.assert(typeof cc._tmp.WebGLLayerColor === "function", cc._LogInfos.MissingFile, "CCLayerWebGL.js"); diff --git a/cocos2d/core/layers/CCLayerWebGL.js b/cocos2d/core/layers/CCLayerWebGL.js index 8d03f273f4..7b4d26ee45 100644 --- a/cocos2d/core/layers/CCLayerWebGL.js +++ b/cocos2d/core/layers/CCLayerWebGL.js @@ -24,6 +24,14 @@ THE SOFTWARE. ****************************************************************************/ +cc._tmp.LayerDefineForWebGL = function(){ + var _p = cc.Layer.prototype; + //Layer doesn't support bake function in WebGL + _p.bake = function(){}; + _p.unbake = function(){}; + _p.visit = cc.Node.prototype.visit; +}; + cc._tmp.WebGLLayerColor = function () { //cc.LayerColor define start var _p = cc.LayerColor.prototype; diff --git a/cocos2d/core/sprites/CCBakeSprite.js b/cocos2d/core/sprites/CCBakeSprite.js new file mode 100644 index 0000000000..3e0d515721 --- /dev/null +++ b/cocos2d/core/sprites/CCBakeSprite.js @@ -0,0 +1,68 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of _t software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.BakeSprite = cc.Sprite.extend({ + _cacheCanvas: null, + _cacheContext: null, + + ctor: function(){ + cc.Sprite.prototype.ctor.call(this); + var canvasElement = document.createElement("canvas"); + canvasElement.width = canvasElement.height = 10; + this._cacheCanvas = canvasElement; + this._cacheContext = canvasElement.getContext("2d"); + + var texture = new cc.Texture2D(); + texture.initWithElement(canvasElement); + texture.handleLoadedTexture(); + this.setTexture(texture); + }, + + getCacheContext: function(){ + return this._cacheContext; + }, + + getCacheCanvas: function(){ + return this._cacheCanvas; + }, + + /** + * reset the cache canvas size + * @param {cc.Size|Number} sizeOrWidth size or width + * @param {Number} [height] + */ + resetCanvasSize: function(sizeOrWidth, height){ + if(height === undefined){ + height = sizeOrWidth.height; + sizeOrWidth = sizeOrWidth.width; + } + var locCanvas = this._cacheCanvas; + locCanvas.width = sizeOrWidth; + locCanvas.height = height; //TODO note baidu browser reset the context after set width or height + this.getTexture().handleLoadedTexture(); + this.setTextureRect(cc.rect(0,0, sizeOrWidth, height), false); + } +}); diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 565e81eb94..723bbb24fb 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -147,7 +147,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid - * Constructor of + * Constructor of cc.RenderTexture for WebGL * @param {Number} width * @param {Number} height * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format diff --git a/moduleConfig.json b/moduleConfig.json index 2eb2054eb5..fc2272c02b 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -92,6 +92,7 @@ "cocos2d/core/sprites/SpritesPropertyDefine.js", "cocos2d/core/sprites/CCSprite.js", "cocos2d/core/sprites/CCSpriteBatchNode.js", + "cocos2d/core/sprites/CCBakeSprite.js", "cocos2d/core/sprites/CCAnimation.js", "cocos2d/core/sprites/CCAnimationCache.js", "cocos2d/core/sprites/CCSpriteFrame.js", From 3ac99a3f2821338c5b1b174fc1e109c29023dd6b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 19 Jun 2014 17:05:54 +0800 Subject: [PATCH 0172/1564] Closed #3646: modify cc.Layer to avoid the normal layer when it doesn't use bake function. --- cocos2d/core/layers/CCLayer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 97fbc08fd1..022da080ce 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -45,7 +45,6 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ this._ignoreAnchorPointForPosition = true; nodep.setAnchorPoint.call(this, 0.5, 0.5); nodep.setContentSize.call(this, cc.winSize); - this._cachedParent = this; }, /** @@ -88,6 +87,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //limit: 1. its children's blendfunc are invalid. this._isBaked = this._cacheDirty = true; + this._cachedParent = this; var children = this._children; for(var i = 0, len = children.length; i < len; i++) children[i]._setCachedParent(this); @@ -102,6 +102,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._isBaked = false; this._cacheDirty = true; + this._cachedParent = null; var children = this._children; for(var i = 0, len = children.length; i < len; i++) children[i]._setCachedParent(null); From 7d1dbb7f818a56529c2684cb549c2ea53a69c510 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 19 Jun 2014 17:12:45 +0800 Subject: [PATCH 0173/1564] Fixed #5576: Calcul cc.visibleRect with visible rect of cc.view --- cocos2d/core/platform/CCEGLView.js | 4 +- cocos2d/core/platform/CCVisibleRect.js | 136 ++++++++++--------------- 2 files changed, 53 insertions(+), 87 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 3854153eeb..4439c38483 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -96,7 +96,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ var sys = cc.sys; _t.enableRetina(sys.os == sys.OS_IOS || sys.os == sys.OS_OSX); - cc.visibleRect && cc.visibleRect.init(_t._designResolutionSize); + cc.visibleRect && cc.visibleRect.init(_t._visibleRect); // Setup system default resolution policies _t._rpExactFit = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.EXACT_FIT); @@ -470,7 +470,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ // For editbox if (cc.DOM) cc.DOM._resetEGLViewDiv(); - cc.visibleRect && cc.visibleRect.init(_t.getVisibleSize()); + cc.visibleRect && cc.visibleRect.init(_t._visibleRect); }, /** diff --git a/cocos2d/core/platform/CCVisibleRect.js b/cocos2d/core/platform/CCVisibleRect.js index a0dc4502b2..e33672a4a1 100644 --- a/cocos2d/core/platform/CCVisibleRect.js +++ b/cocos2d/core/platform/CCVisibleRect.js @@ -25,104 +25,70 @@ ****************************************************************************/ /** + * cc.visibleRect define the actual visible rect of the current view, + * it should represent the same rect as cc.view.getViewportRect() + * + * @property {cc.Point} topLeft - Top left coordinate of the screen related to the game scene + * @property {cc.Point} topRight - Top right coordinate of the screen related to the game scene + * @property {cc.Point} top - Top center coordinate of the screen related to the game scene + * @property {cc.Point} bottomLeft - Bottom left coordinate of the screen related to the game scene + * @property {cc.Point} bottomRight - Bottom right coordinate of the screen related to the game scene + * @property {cc.Point} bottom - Bottom center coordinate of the screen related to the game scene + * @property {cc.Point} center - Center coordinate of the screen related to the game scene + * @property {cc.Point} left - Left center coordinate of the screen related to the game scene + * @property {cc.Point} right - Right center coordinate of the screen related to the game scene + * @property {Number} width - Width of the screen + * @property {Number} height - Height of the screen * * @type Object */ cc.visibleRect = { - _topLeft:cc.p(0,0), - _topRight:cc.p(0,0), - _top:cc.p(0,0), - _bottomLeft:cc.p(0,0), - _bottomRight:cc.p(0,0), - _bottom:cc.p(0,0), - _center:cc.p(0,0), - _left:cc.p(0,0), - _right:cc.p(0,0), - _width:0, - _height:0, - init:function(size){ - this._width = size.width; - this._height = size.height; + topLeft:cc.p(0,0), + topRight:cc.p(0,0), + top:cc.p(0,0), + bottomLeft:cc.p(0,0), + bottomRight:cc.p(0,0), + bottom:cc.p(0,0), + center:cc.p(0,0), + left:cc.p(0,0), + right:cc.p(0,0), + width:0, + height:0, - var w = this._width; - var h = this._height; + init:function(visibleRect){ + var w = this.width = visibleRect.width; + var h = this.height = visibleRect.height; + var l = visibleRect.x, + b = visibleRect.y, + t = b + h, + r = l + w; //top - this._topLeft.y = h; - this._topRight.x = w; - this._topRight.y = h; - this._top.x = w/2; - this._top.y = h; + this.topLeft.x = l; + this.topLeft.y = t; + this.topRight.x = r; + this.topRight.y = t; + this.top.x = l + w/2; + this.top.y = t; //bottom - this._bottomRight.x = w; - this._bottom.x = w/2; + this.bottomLeft.x = l; + this.bottomLeft.y = b; + this.bottomRight.x = r; + this.bottomRight.y = b; + this.bottom.x = l + w/2; + this.bottom.y = b; //center - this._center.x = w/2; - this._center.y = h/2; + this.center.x = l + w/2; + this.center.y = b + h/2; //left - this._left.y = h/2; + this.left.x = l; + this.left.y = b + h/2; //right - this._right.x = w; - this._right.y = h/2; + this.right.x = r; + this.right.y = b + h/2; } -}; - -/** @expose */ -cc.visibleRect.width; -cc.defineGetterSetter(cc.visibleRect, "width", function(){ - return this._width; -}); -/** @expose */ -cc.visibleRect.height; -cc.defineGetterSetter(cc.visibleRect, "height", function(){ - return this._height; -}); -/** @expose */ -cc.visibleRect.topLeft; -cc.defineGetterSetter(cc.visibleRect, "topLeft", function(){ - return this._topLeft; -}); -/** @expose */ -cc.visibleRect.topRight; -cc.defineGetterSetter(cc.visibleRect, "topRight", function(){ - return this._topRight; -}); -/** @expose */ -cc.visibleRect.top; -cc.defineGetterSetter(cc.visibleRect, "top", function(){ - return this._top; -}); -/** @expose */ -cc.visibleRect.bottomLeft; -cc.defineGetterSetter(cc.visibleRect, "bottomLeft", function(){ - return this._bottomLeft; -}); -/** @expose */ -cc.visibleRect.bottomRight; -cc.defineGetterSetter(cc.visibleRect, "bottomRight", function(){ - return this._bottomRight; -}); -/** @expose */ -cc.visibleRect.bottom; -cc.defineGetterSetter(cc.visibleRect, "bottom", function(){ - return this._bottom; -}); -/** @expose */ -cc.visibleRect.center; -cc.defineGetterSetter(cc.visibleRect, "center", function(){ - return this._center; -}); -/** @expose */ -cc.visibleRect.left; -cc.defineGetterSetter(cc.visibleRect, "left", function(){ - return this._left; -}); -/** @expose */ -cc.visibleRect.right; -cc.defineGetterSetter(cc.visibleRect, "right", function(){ - return this._right; -}); \ No newline at end of file +}; \ No newline at end of file From 0e9669b05f12e32ac66cf82bac7ca66d30d2dc07 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 19 Jun 2014 17:15:33 +0800 Subject: [PATCH 0174/1564] Fixed #5577: Position children with cc.visibleRect --- cocos2d/core/scenes/CCLoaderScene.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index 84b10086c9..f269bbb686 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -31,17 +31,14 @@ cc.LoaderScene = cc.Scene.extend({ _className:"LoaderScene", init : function(){ var self = this; - var winSize = cc.director.getWinSize(); - //logo var logoWidth = 160; var logoHeight = 200; - var centerPos = cc.p(winSize.width / 2, winSize.height / 2); // bg var bgLayer = self._bgLayer = cc.LayerColor.create(cc.color(32, 32, 32, 255)); - bgLayer.setPosition(0, 0); + bgLayer.setPosition(cc.visibleRect.bottomLeft); self.addChild(bgLayer, 0); //image move to CCSceneFile.js @@ -51,14 +48,14 @@ cc.LoaderScene = cc.Scene.extend({ cc.loader.loadImg(cc._loaderImage, {isCrossOrigin : false }, function(err, img){ logoWidth = img.width; logoHeight = img.height; - self._initStage(img, centerPos); + self._initStage(img, cc.visibleRect.center); }); fontSize = 14; lblHeight = -logoHeight / 2 - 10; } //loading percent var label = self._label = cc.LabelTTF.create("Loading... 0%", "Arial", fontSize); - label.setPosition(cc.pAdd(centerPos, cc.p(0, lblHeight))); + label.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, lblHeight))); label.setColor(cc.color(180, 180, 180)); bgLayer.addChild(this._label, 10); return true; From a5ee3354c21b878c04d00d32f629bbe55407162e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 20 Jun 2014 14:27:36 +0800 Subject: [PATCH 0175/1564] Follow up the code - #8b9d572 --- extensions/ccui/base-classes/UIWidget.js | 6 + extensions/ccui/layouts/UILayout.js | 15 +- extensions/ccui/layouts/UILayoutParameter.js | 8 +- extensions/ccui/uiwidgets/UIButton.js | 1 + extensions/ccui/uiwidgets/UISlider.js | 5 +- extensions/ccui/uiwidgets/UITextField.js | 144 ++++++++++++++++- .../armature/display/CCDisplayFactory.js | 5 + .../armature/display/CCDisplayManager.js | 102 +++++++++++- extensions/cocostudio/reader/GUIReader.js | 146 ++++++++++++------ .../widgetreader/ButtonReader/ButtonReader.js | 4 +- .../ImageViewReader/ImageViewReader.js | 2 +- .../widgetreader/LayoutReader/LayoutReader.js | 41 ++--- .../reader/widgetreader/WidgetReader.js | 30 +++- .../widgetreader/WidgetReaderProtocol.js | 2 +- .../cocostudio/trigger/ObjectFactory.js | 21 +-- moduleConfig.json | 19 ++- 16 files changed, 446 insertions(+), 105 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 0c7718a2df..38fb118a6a 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -85,6 +85,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _className: "Widget", _flippedX: false, _flippedY: false, + _opacity: 255, ctor: function () { cc.Node.prototype.ctor.call(this); this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; @@ -1424,6 +1425,11 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ if (renderer.RGBAProtocol) { renderer.setOpacity(this._color.a); } + }, + + updateRGBAToRenderer: function(renderer){ + renderer.setColor(this._color); + renderer.setOpacity(this._opacity); } }); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index cb5154cf2e..0fa6936d6c 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -83,16 +83,25 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingRect = cc.rect(0, 0, 0, 0); this._backGroundImageColor = cc.color(255, 255, 255, 255); }, + onEnter: function(){ + ccui.Widget.prototype.onEnter.call(this); + if (this._clippingStencil) + { + this._clippingStencil.onEnter(); + } + this._doLayoutDirty = true; + this._clippingRectDirty = true; + }, init: function () { if (cc.Node.prototype.init.call(this)) { this._layoutParameterDictionary = {}; this._widgetChildren = []; this.initRenderer(); + this.setBright(true); this.ignoreContentAdaptWithSize(false); this.setSize(cc.size(0, 0)); - this.setBright(true); this.setAnchorPoint(0, 0); - this.initStencil(); +// this.initStencil(); return true; } return false; @@ -1363,7 +1372,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ default: break; } - locChild.setPosition(locFinalPosX, locFinalPosY); + locChild.setPosition(cc.p(locFinalPosX, locFinalPosY)); locLayoutParameter._put = true; unlayoutChildCount--; } diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index bb2b1d4a4d..95fbae96e3 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -142,7 +142,13 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL */ copyProperties: function (model) { ccui.LayoutParameter.prototype.copyProperties.call(this, model); - this.setGravity(model._linearGravity); + var parameter = model; + if(parameter){ + this.setAlign(parameter._relativeAlign); + this.setRelativeName(parameter._relativeLayoutName); + this.setRelativeToWidgetName(parameter._relativeWidgetName); + //this.setGravity(model._linearGravity); + } } }); diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 5d670cc444..3c758410e4 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -231,6 +231,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); + this.updateRGBAToRenderer(buttonNormalRenderer); this._normalTextureLoaded = true; }, diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 02e514ff68..e08119e1c9 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -129,6 +129,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this.barRendererScaleChangedWithSize(); }, this); } + + this.progressBarRendererScaleChangedWithSize(); }, /** @@ -276,7 +278,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * Get cap insets for slider. * @returns {cc.Rect} */ - getCapInsetsProgressBarRenderer: function () { + getCapInsetsProgressBarRebderer: function () { return this._capInsetsProgressBarRenderer; }, @@ -533,6 +535,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._progressBarTextureSize = this._progressBarRenderer.getContentSize(); } else { var ptextureSize = this._progressBarTextureSize; diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 3e2ec5168b..d4b70a21c7 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -125,6 +125,120 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu } }, + _calcCharCount: function(pszText){ + var n = 0; + var ch = pszText; + if(!ch) { + if (0x80 != (0xC0 & ch)) + { + ++n; + } + ++pszText; + } + return n; + }, + + insertText: function(text, len){ + var input_text = text; + + if (text !== "\n") + { + if (this._maxLengthEnabled) + { + var text_count = this._calcCharCount(this.getString()); + if (text_count >= this._maxLength) + { + // password + if (this._passwordEnabled) + { + this.setPasswordText(this.getString()); + } + return; + } + + if ( + (cc.sys.os == cc.sys.OS_IOS) || + (cc.sys.os == cc.sys.OS_OSX) || + (cc.sys.os == cc.sys.OS_WINDOWS) + ) + var input_count = _calcCharCount(text); + var total = text_count + input_count; + + if (total > this._maxLength) + { + var end = 0; + var length = this._maxLength - text_count; + + for (var i = 0; i < length; ++i) + { + var value = text[i]; + + if (value >= 0 && value <= 127) // ascii + { + end++; + } + else + { + end += 3; + } + } + input_text = input_text.substr(0, end); + len = end; + } + else if (cc.sys.os == cc.sys.OS_ANDROID) + { + var input_count = this._calcCharCount(text); + if (input_count > this._maxLength) + { + var ascii = 0; + var unicode = 0; + var end = 0; + var count = 0; + + for (var i = 0; i < input_count * 3; ++i) + { + var value = text[i]; + + if (value >= 0 && value <= 127) // ascii + { + ascii++; + count++; + } + else + { + unicode++; + if (unicode % 3 == 0) + { + count++; + } + } + + if (count == this._maxLength) + { + break; + } + } + end = ascii + unicode; + input_text = input_text.substr(0, end); + len = end; + } + } + + } + } + ccui.TextFieldTTF.insertText(input_text, len); + + // password + if (this._passwordEnabled) + { + if (ccui.TextFieldTTF.prototype.getCharCount.call(this) > 0) + { + this.setPasswordText(this.getString()); + } + } + + }, + deleteBackward: function () { cc.TextFieldTTF.prototype.deleteBackward.call(this); @@ -226,7 +340,7 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu } }); -ccui.UILabelField.create = ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { +ccui.UICCLabelField.create = ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { var ret = new ccui.UICCTextField(); if (ret && ret.initWithString("", fontName, fontSize)) { if (placeholder) { @@ -308,6 +422,28 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# this._touchHeight = size.height; }, + setTouchAreaEnabled: function(enable){ + this._useTouchArea = enable; + }, + + hitTest: function(pt){ + if (this._useTouchArea) + { + var nsp = this.convertToNodeSpace(pt); + var bb = cc.rect(-this._touchWidth * this._anchorPoint.x, -this._touchHeight * this._anchorPoint.y, this._touchWidth, this._touchHeight); + if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) + { + return true; + } + } + else + { + return ccui.Widget.hitTest(pt); + } + + return false; + }, + /** * Get touch size. * @returns {cc.Size} @@ -484,6 +620,8 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */ setMaxLength: function (length) { this._textFieldRender.setMaxLength(length); + + this.setString(this.getString()); }, /** @@ -513,6 +651,8 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# setPasswordStyleText: function (styleText) { this._textFieldRender.setPasswordStyleText(styleText); this._passwordStyleText = styleText; + + this.setString(this.getString()); }, /** @@ -540,6 +680,8 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# if (this.getDeleteBackward()) { this.deleteBackwardEvent(); this.setDeleteBackward(false); + + this.textfieldRendererScaleChangedWithSize(); } }, diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index 3286b8f640..bbfd3d1710 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -190,10 +190,15 @@ ccs.DisplayFactory.addParticleDisplay = function (bone, decoDisplay, displayData ccs.DisplayFactory.createParticleDisplay = function (bone, decoDisplay) { var displayData = decoDisplay.getDisplayData(); var system = cc.ParticleSystem.create(displayData.displayName); + + system.removeFromParent(); + system.cleanup(); + var armature = bone.getArmature(); if (armature) { system.setParent(bone.getArmature()); } + decoDisplay.setDisplay(system); }; ccs.DisplayFactory.updateParticleDisplay = function (bone, particleSystem, dt) { diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index e6940b5192..057ca1dcfb 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -54,27 +54,113 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends cc.DisplayManager */{ return true; }, - addDisplay: function (displayData, index) { + addDisplay: function (display, index) { + var decoDisplay = null; - if (index >= 0 && index < this._decoDisplayList.length) { + + if( (index >= 0) && (index < this._decoDisplayList.length) ) + { decoDisplay = this._decoDisplayList[index]; } - else { + else + { decoDisplay = ccs.DecorativeDisplay.create(); this._decoDisplayList.push(decoDisplay); } - if(displayData instanceof ccs.DisplayData){ - ccs.DisplayFactory.addDisplay(this._bone, decoDisplay, displayData); - }else{ - this._addDisplayOther(decoDisplay,displayData); + var displayData = null; + if (display instanceof ccs.Skin) + { + var skin = display; + skin.setBone(this._bone); + displayData = this.SpriteDisplayData.create(); + + ccs.DisplayFactory.initSpriteDisplay(this._bone, decoDisplay, skin.getDisplayName(), skin); + + var spriteDisplayData = decoDisplay.getDisplayData(); + if (spriteDisplayData instanceof ccs.SpriteDisplayData) + { + skin.setSkinData(spriteDisplayData.skinData); + displayData.skinData = spriteDisplayData.skinData; + } + else + { + var find = false; + + for (var i = this._decoDisplayList.length - 2; i>=0; i--) + { + var dd = this._decoDisplayList[i]; + var sdd = dd.getDisplayData(); + if (sdd instanceof ccs.SpriteDisplayData) + { + find = true; + skin.setSkinData(sdd.skinData); + displayData.skinData = sdd.skinData; + break; + } + } +// +// if (!find) +// { +// BaseData baseData; +// skin.setSkinData(baseData); +// } + } } + else if (display instanceof ccs.ParticleSystemQuad) + { + displayData = ccs.ParticleDisplayData.create(); + + display.removeFromParent(); + display.cleanup(); + + var armature = this._bone.getArmature(); + if (armature) + { + display.setParent(armature); + } + } + else if(display instanceof ccs.Armature) + { + var armature = display; + displayData = ccs.ArmatureDisplayData.create(); + displayData.displayName = armature.getName(); + armature.setParentBone(this._bone); + } + else + { + displayData = ccs.DisplayData.create(); + } + + decoDisplay.setDisplay(display); + decoDisplay.setDisplayData(displayData); //! if changed display index is current display index, then change current display to the new display - if (index == this._displayIndex) { + if(index == this._displayIndex) + { this._displayIndex = -1; this.changeDisplayWithIndex(index, false); } +// var decoDisplay = null; +// if (index >= 0 && index < this._decoDisplayList.length) { +// decoDisplay = this._decoDisplayList[index]; +// } +// else { +// decoDisplay = ccs.DecorativeDisplay.create(); +// this._decoDisplayList.push(decoDisplay); +// } +// +// if(displayData instanceof ccs.DisplayData){ +// ccs.DisplayFactory.addDisplay(this._bone, decoDisplay, displayData); +// }else{ +// this._addDisplayOther(decoDisplay,displayData); +// } +// +// //! if changed display index is current display index, then change current display to the new display +// if (index == this._displayIndex) { +// this._displayIndex = -1; +// this.changeDisplayWithIndex(index, false); +// } }, _addDisplayOther:function(decoDisplay,display){ diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 2e9b60f198..f0c57e7d53 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -136,7 +136,7 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ this._fileDesignSizes = {}; }, registerTypeAndCallBack: function(classType, ins, object, callback){ - var factoryCreate = ccs.objectFactory.getInstance(); + var factoryCreate = ccs.objectFactory; var t = new ccs.TInfo(classType, object); factoryCreate.registerType(t); @@ -818,9 +818,59 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ }, widgetFromJsonDictionary: function (data) { + var widget = null; var classname = data["classname"]; var uiOptions = data["options"]; - var widget = ccs.objectFactory.getInstance().createGUI(classname); + if (classname == "Button") { + widget = ccui.Button.create(); + } + else if (classname == "CheckBox") { + widget = ccui.CheckBox.create(); + } + else if (classname == "Label") { + widget = ccui.Text.create(); + } + else if (classname == "LabelAtlas") { + widget = ccui.TextAtlas.create(); + } + else if (classname == "LoadingBar") { + widget = ccui.LoadingBar.create(); + } else if (classname == "ScrollView") { + widget = ccui.ScrollView.create(); + } + else if (classname == "TextArea") { + widget = ccui.Text.create(); + } + else if (classname == "TextButton") { + widget = ccui.Button.create(); + } + else if (classname == "TextField") { + widget = ccui.TextField.create(); + } + else if (classname == "ImageView") { + widget = ccui.ImageView.create(); + } + else if (classname == "Panel") { + widget = ccui.Layout.create(); + } + else if (classname == "Slider") { + widget = ccui.Slider.create(); + } + else if (classname == "LabelBMFont") { + widget = ccui.TextBMFont.create(); + } + else if (classname == "DragPanel") { + widget = ccui.ScrollView.create(); + } + else if (classname == "ListView") { + widget = ccui.ListView.create(); + } + else if (classname == "PageView") { + widget = ccui.PageView.create(); + } + else if (classname == "Widget"){ + widget = ccui.Widget.create(); + } // create widget reader to parse properties of widget var readerName = classname; @@ -836,67 +886,68 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ break; } readerName += "Reader"; - var reader = ccs.objectFactory.getInstance().createWidgetReaderProtocol(readerName); + var reader = ccs.objectFactory.createWidgetReaderProtocol(readerName); if(reader){ // widget parse with widget reader this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); }else{ // 1st., custom widget parse properties of parent widget with parent widget reader - if(widget instanceof ccs.Button){ - readerName = "ButtonReader"; - }else if(widget instanceof ccs.CheckBox){ - readerName = "CheckBoxReader"; - }else if (widget instanceof ccs.ImageView) + + var render; + if(widget instanceof ccui.Button){ + render = new ccs.ButtonReader(); + }else if(widget instanceof ccui.CheckBox){ + render = new ccs.CheckBoxReader(); + }else if (widget instanceof ccui.ImageView) { - readerName = "ImageViewReader"; + render = new ccs.ImageViewReader(); } - else if (widget instanceof ccs.LabelAtlas) + else if (widget instanceof ccui.LabelAtlas) { - readerName = "LabelAtlasReader"; + render = new ccs.LabelAtlasReader(); } - else if (widget instanceof ccs.LabelBMFont) + else if (widget instanceof ccui.LabelBMFont) { - readerName = "LabelBMFontReader"; + render = new ccs.LabelBMFontReader(); } - else if (widget instanceof ccs.Label) + else if (widget instanceof ccui.Label) { - readerName = "LabelReader"; + render = new ccs.LabelReader(); } - else if (widget instanceof ccs.LoadingBar) + else if (widget instanceof ccui.LoadingBar) { - readerName = "LoadingBarReader"; + render = new ccs.LoadingBarReader(); } - else if (widget instanceof ccs.Slider) + else if (widget instanceof ccui.Slider) { - readerName = "SliderReader"; + render = new ccs.SliderReader(); } - else if (widget instanceof ccs.TextField) + else if (widget instanceof ccui.TextField) { - readerName = "TextFieldReader"; + render = new ccs.TextFieldReader(); } - else if (widget instanceof ccs.Layout) + else if (widget instanceof ccui.Layout) { - readerName = "LayoutReader"; + render = new ccs.LayoutReader(); } - else if (widget instanceof ccs.ScrollView) + else if (widget instanceof ccui.ScrollView) { - readerName = "ScrollViewReader"; + render = new ccs.ScrollViewReader(); } - else if (widget instanceof ccs.ListView) + else if (widget instanceof ccui.ListView) { - readerName = "ListViewReader"; + render = new ccs.ListViewReader(); } - else if (widget instanceof ccs.PageView) + else if (widget instanceof ccui.PageView) { - readerName = "PageViewReader"; + render = new ccs.PageViewReader(); } - else if (widget instanceof ccs.Widget) + else if (widget instanceof ccui.Widget) { - readerName = "WidgetReader"; + render = new ccs.WidgetReader(); } - var render = ccs.objectFactory.getInstance().createWidgetReaderProtocol(readerName); - this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); + this.setPropsForAllWidgetFromJsonDictionary(render, widget, uiOptions); // 2nd., custom widget parse with custom reader var customProperty = uiOptions["customProperty"]; @@ -908,29 +959,13 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); } var childrenCount = data["children"]; - for (var i = 0; i < childrenCount; i++) + for (var i = 0; i < childrenCount.length; i++) { var subData = data["children"][i]; var child = this.widgetFromJsonDictionary(subData); if (child) { - var pageView = widget; - if (pageView) - { - pageView.addPage(child); - } - else - { - var listView = widget; - if (listView) - { - listView.pushBackCustomItem(child); - } - else - { - widget.addChild(child); - } - } + widget.addChild(child); } } return widget; @@ -942,6 +977,10 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var widgetName = name ? name : "default"; widget.setName(widgetName); + if(name == "background_Panel"){ + void(0); + } + if (options["ignoreSize"] !== undefined) { widget.ignoreContentAdaptWithSize(options["ignoreSize"]); } @@ -962,6 +1001,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var x = options["x"]; var y = options["y"]; widget.setPosition(x, y); + widget.x = x; + widget.y = y; + widget._transformDirty = true; + + if (options["scaleX"] !== undefined) { widget.setScaleX(options["scaleX"]); } diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index a868632ee5..a21938f124 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -44,7 +44,7 @@ ccs.ButtonReader = ccs.WidgetReader.extend({ var jsonPath = ccs.uiReader.getFilePath(); - + var button = widget; var scale9Enable = options["scale9Enable"]; button.setScale9Enabled(scale9Enable); @@ -112,7 +112,7 @@ ccs.ButtonReader = ccs.WidgetReader.extend({ case 1: { var disabledFileName = disabledDic["path"]; - button.loadTextureDisabled(disabledFileName,ui::UI_TEX_TYPE_PLIST); + button.loadTextureDisabled(disabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } default: diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index f1d16b6b47..c6cc9d9cbf 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -55,7 +55,7 @@ ccs.ImageViewReader = ccs.WidgetReader.extend({ { var tp_i = jsonPath; var imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = NULL; + var imageFileName_tp = null; if (imageFileName && imageFileName !== "") { imageFileName_tp = tp_i + imageFileName; diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index fac7a947f3..a7ef59b8d3 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -89,29 +89,32 @@ ccs.LayoutReader = ccs.WidgetReader.extend({ var imageFileNameDic = options["backGroundImageData"]; - var imageFileNameType = imageFileNameDic["resourceType"]; - switch (imageFileNameType) - { - case 0: - { - var tp_b = jsonPath; - var imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = (imageFileName && (imageFileName !== "")) ? - tp_b + imageFileName : - null; - panel.setBackGroundImage(imageFileName_tp); - break; - } - case 1: + if(imageFileNameDic){ + var imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType) { - var imageFileName = imageFileNameDic["path"]; - panel.setBackGroundImage(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); - break; + case 0: + { + var tp_b = jsonPath; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = (imageFileName && (imageFileName !== "")) ? + tp_b + imageFileName : + null; + panel.setBackGroundImage(imageFileName_tp); + break; + } + case 1: + { + var imageFileName = imageFileNameDic["path"]; + panel.setBackGroundImage(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; } - default: - break; } + if (backGroundScale9Enable) { var cx = options["capInsetsX"]; diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 45696e65cf..b65573e67d 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -63,6 +63,13 @@ ccs.WidgetReader = ccs.WidgetReaderProtocol.extend({ var x = options["x"]; var y = options["y"]; widget.setPosition(cc.p(x, y)); + widget.x = x; + widget.y = y; + + + if(options["name"] == "background_Panel"){ + void 0; + } var sx = options["scalex"]; if(sx){ @@ -80,7 +87,7 @@ ccs.WidgetReader = ccs.WidgetReaderProtocol.extend({ if(vb){ widget.setVisible(vb); } - widget.setZOrder(options["ZOrder"]); + widget.setLocalZOrder(options["ZOrder"]); var layout = options["layoutParameter"]; if(layout){ @@ -117,6 +124,23 @@ ccs.WidgetReader = ccs.WidgetReaderProtocol.extend({ } } + if(options["name"] == "background_Panel"){ + var tmp = {x: widget.x}; + widget.__defineGetter__('x', function(){ + return tmp.x + }); + widget.__defineSetter__('x', function(x){ + tmp.x = x; + }); + var tmp2 = {x: widget._position.x}; + widget._position.__defineGetter__('x', function(){ + return tmp2.x + }); + widget._position.__defineSetter__('x', function(x){ + tmp2.x = x; + }); + void 0; + } }, setColorPropsFromJsonDictionary: function(widget, options){ @@ -133,7 +157,7 @@ ccs.WidgetReader = ccs.WidgetReaderProtocol.extend({ var apy = options["anchorPointY"]; var apyf = apy || (widget.getWidgetType() === ccs.WidgetType ? 0.5 : 0); widget.setAnchorPoint(cc.p(apxf, apyf)); - widget.setFlipX(options["flipX"]); - widget.setFlipX(options["flipY"]); +// widget.setFlipX(options["flipX"]); +// widget.setFlipX(options["flipY"]); } }); \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js index e2d581db9f..833ef41ecb 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ -ccs.WidgetReaderProtocol = cc.Class.extend({ +ccs.WidgetReaderProtocol = ccs.Class.extend({ setPropsFromJsonDictionary: function(widget, options){ diff --git a/extensions/cocostudio/trigger/ObjectFactory.js b/extensions/cocostudio/trigger/ObjectFactory.js index 8b1e26398a..3c85b19658 100644 --- a/extensions/cocostudio/trigger/ObjectFactory.js +++ b/extensions/cocostudio/trigger/ObjectFactory.js @@ -53,27 +53,22 @@ ccs.objectFactory = { name = "Button"; } - do{ - - var t = this._typeMap[name]; - if(t._fun === null){ - break; - } + var t = this._typeMap[name]; + if(t && t._fun){ object = t._fun; - }while(0); + } return object; }, createWidgetReaderProtocol: function(name){ var object = null; - do{ - var t = this._typeMap[name]; - if(t._fun === null){ - break; - } + + var t = this._typeMap[name]; + if(t && t._fun){ object = t._fun; - }while(0); + } + return object; } diff --git a/moduleConfig.json b/moduleConfig.json index 2eb2054eb5..25e7191e94 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -282,6 +282,7 @@ "extensions/cocostudio/components/CCComponent.js", "extensions/cocostudio/components/CCComponentContainer.js", "extensions/cocostudio/CocoStudio.js", + "extensions/cocostudio/ActionManagerEx.js", "extensions/cocostudio/armature/utils/CCArmatureDefine.js", "extensions/cocostudio/armature/utils/CCDataReaderHelper.js", @@ -318,7 +319,23 @@ "extensions/cocostudio/trigger/TriggerObj.js", "extensions/cocostudio/reader/GUIReader.js", - "extensions/cocostudio/reader/SceneReader.js" + "extensions/cocostudio/reader/SceneReader.js", + "extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js", + "extensions/cocostudio/reader/widgetreader/WidgetReader.js", + + "extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js", + "extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js", + "extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js", + "extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js", + "extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js", + "extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js", + "extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js", + "extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js", + "extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js", + "extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js", + "extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js", + "extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js", + "extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js" ], "gui" : [ "core", "clipping-nodes", "render-texture", "actions", "progress-timer", From e48b93837d90f46d77f0efeb0dd437d5ca655095 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 20 Jun 2014 16:48:35 +0800 Subject: [PATCH 0176/1564] Fixed #5581: Make cc.loader continue the counter process even if a resource failed --- CCBoot.js | 6 ++++-- cocos2d/core/platform/CCLoaders.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 8813c8aa1c..1dfa85ced7 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -622,8 +622,10 @@ cc.loader = { if (obj) return cb(null, obj); var loader = self._register[type.toLowerCase()]; - if (!loader) - return cb("loader for [" + type + "] not exists!"); + if (!loader) { + cc.error("loader for [" + type + "] not exists!"); + return cb(); + } var basePath = loader.getBasePath ? loader.getBasePath() : self.resPath; var realUrl = self.getUrl(basePath, url); loader.load(realUrl, url, item, function (err, data) { diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index f9e56a93d5..dc23290abd 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -47,7 +47,7 @@ cc._imgLoader = { }); } }; -cc.loader.register(["png", "jpg", "bmp","jpeg","gif"], cc._imgLoader); +cc.loader.register(["png", "jpg", "bmp","jpeg","gif", "ico"], cc._imgLoader); cc._serverImgLoader = { load : function(realUrl, url, res, cb){ cc.loader.cache[url] = cc.loader.loadImg(res.src, function(err, img){ From d91c2bf889f95a098d7062700d4b6af13a397d49 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 20 Jun 2014 18:00:09 +0800 Subject: [PATCH 0177/1564] Follow up the code - #c0b67e6d1b --- extensions/ccb-reader/CCBAnimationManager.js | 8 +++- extensions/ccui/layouts/UILayout.js | 1 + extensions/ccui/uiwidgets/UIButton.js | 40 +++++++++++++++++++ extensions/ccui/uiwidgets/UICheckBox.js | 29 +++++++++----- extensions/ccui/uiwidgets/UIImageView.js | 4 +- .../armature/display/CCBatchNode.js | 19 ++++++--- .../armature/display/CCDisplayFactory.js | 3 +- .../gui/control-extension/CCControlSwitch.js | 22 +++++----- 8 files changed, 97 insertions(+), 29 deletions(-) diff --git a/extensions/ccb-reader/CCBAnimationManager.js b/extensions/ccb-reader/CCBAnimationManager.js index fd330b01cb..d08e9b54a7 100644 --- a/extensions/ccb-reader/CCBAnimationManager.js +++ b/extensions/ccb-reader/CCBAnimationManager.js @@ -539,7 +539,13 @@ cc.BuilderAnimationManager = cc.Class.extend({ // TODO only handle rotation, opacity, displayFrame, color if(propName === "rotation"){ node.setRotation(value); - } else if(propName === "opacity"){ + } else if(propName == "rotationX") + { + node.setRotationSkewX(value); + }else if(propName == "rotationY") + { + node.setRotationSkewY(value); + }else if(propName === "opacity"){ node.setOpacity(value); } else if(propName === "displayFrame"){ node.setSpriteFrame(value); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 0fa6936d6c..9eddd4836d 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -58,6 +58,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _scissorRectDirty: false, _clippingRect: null, _clippingParent: null, + _clippingRectDirty: true, _className: "Layout", _backGroundImageColor: null, diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 3c758410e4..3107a10787 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -281,6 +281,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); + this.updateRGBAToRenderer(this._buttonDisableRenderer); this._pressedTextureLoaded = true; }, @@ -330,6 +331,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); + this.updateRGBAToRenderer(this._buttonDisableRenderer); this._disabledTextureLoaded = true; }, @@ -458,6 +460,44 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); }, + setFlippedX: function(flippedX){ + this._titleRenderer.setFlippedX(flippedX); + if (this._scale9Enabled) + { + return; + } + this._buttonNormalRenderer.setFlippedX(flippedX); + this._buttonClickedRenderer.setFlippedX(flippedX); + this._buttonDisableRenderer.setFlippedX(flippedX); + }, + + setFlipY: function(flippedY){ + this._titleRenderer.setFlippedY(flippedY); + if (this._scale9Enabled) + { + return; + } + this._buttonNormalRenderer.setFlippedY(flippedY); + this._buttonClickedRenderer.setFlippedY(flippedY); + this._buttonDisableRenderer.setFlippedY(flippedY); + }, + + isFlippedX: function(){ + if (this._scale9Enabled) + { + return false; + } + return this._buttonNormalRenderer.isFlippedX(); + }, + + isFlippedY: function(){ + if (this._scale9Enabled) + { + return false; + } + return this._buttonNormalRenderer.isFlippedY(); + }, + updateFlippedX: function () { this._titleRenderer.setFlippedX(this._flippedX); if (this._scale9Enabled) { diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index a5887788d8..2b91436a72 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -61,7 +61,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ ctor: function () { ccui.Widget.prototype.ctor.call(this); }, - init: function () { + init: function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { if (ccui.Widget.prototype.init.call(this)) { this.setTouchEnabled(true); this.setSelectedState(false); @@ -131,10 +131,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this.backGroundTextureScaleChangedWithSize(); }, this); } - this.updateColorToRenderer(bgBoxRenderer); + this.backGroundTextureScaleChangedWithSize(); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); + this.updateColorToRenderer(bgBoxRenderer); }, /** * Load backGroundSelected texture for checkbox. @@ -158,11 +159,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } - this.updateColorToRenderer(this._backGroundSelectedBoxRenderer); + this.backGroundSelectedTextureScaleChangedWithSize(); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.backGroundSelectedTextureScaleChangedWithSize(); + this.updateRGBAToRenderer(this._backGroundSelectedBoxRenderer); }, /** @@ -188,10 +189,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } this.frontCrossTextureScaleChangedWithSize(); - this.updateColorToRenderer(this._frontCrossRenderer); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); + this.updateRGBAToRenderer(this._frontCrossRenderer); }, /** @@ -217,10 +218,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } this.backGroundDisabledTextureScaleChangedWithSize(); - this.updateColorToRenderer(this._backGroundBoxDisabledRenderer); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); + this.updateRGBAToRenderer(this._backGroundBoxDisabledRenderer); }, /** @@ -246,10 +247,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } this.frontCrossDisabledTextureScaleChangedWithSize(); - this.updateColorToRenderer(this._frontCrossDisabledRenderer); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); + this.updateRGBAToRenderer(this._frontCrossDisabledRenderer); }, onTouchEnded: function (touch, event) { @@ -561,8 +562,18 @@ _p = null; * // example * var uiCheckBox = ccui.CheckBox.create(); */ -ccui.CheckBox.create = function () { - return new ccui.CheckBox(); +ccui.CheckBox.create = function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { + var widget = new ccui.CheckBox(); + if (widget && widget.init(backGround, + backGroundSeleted, + cross, + backGroundDisabled, + frontCrossDisabled, + texType)) + { + return widget; + } + return null; }; // Constants diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 0143d37d02..d47250d9ac 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -102,11 +102,11 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ imageRenderer.setCapInsets(this._capInsets); } - this.updateColorToRenderer(imageRenderer); + this.imageTextureScaleChangedWithSize(); this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.imageTextureScaleChangedWithSize(); + this.updateRGBAToRenderer(imageRenderer); }, /** diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index 8eeef78217..c5f51c9ea2 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -42,18 +42,27 @@ cc.BatchNode = cc.Node.extend({ } }, - visit:function () { + visit:function (renderer, parentTransform, parentTransformUpdated) { // quick return if not visible. children won't be drawn. if (!this._visible) { return; } + var dirty = parentTransformUpdated || this._transformUpdated; + if(dirty) + this._modelViewTransform = this.transform(parentTransform); + this._transformUpdated = false; + + // IMPORTANT: + // To ease the migration to v3.0, we still support the kmGL stack, + // but it is deprecated and your code should not rely on it this.kmGLPushMatrix(); if (this.grid && this.grid.isActive()) { this.grid.beforeDraw(); } - this.transform(); + this.sortAllChildren(); - this.draw(); + this.draw(renderer, this._modelViewTransform, dirty); + // reset for next frame this.arrivalOrder = 0; if (this.grid && this.grid.isActive()) { @@ -62,8 +71,8 @@ cc.BatchNode = cc.Node.extend({ this.kmGLPopMatrix(); }, - draw:function (ctx) { - cc.nodeDrawSetup(this); + draw:function (renderer, transform, transformUpdated) { + var child = null; for (var i = 0; i < this._children.length; i++) { child = this._children[i]; diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index bbfd3d1710..897b45c81d 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -76,7 +76,8 @@ ccs.DisplayFactory.updateDisplay = function (bone,dt, dirty) { this.updateArmatureDisplay(bone, display, dt); break; default: - display.setAdditionalTransform(bone.nodeToArmatureTransform()); + var transform = bone.getNodeToArmatureTransform(); + display.setAdditionalTransform(transform); break; } diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js index 88b969e646..45981e936a 100644 --- a/extensions/gui/control-extension/CCControlSwitch.js +++ b/extensions/gui/control-extension/CCControlSwitch.js @@ -266,17 +266,17 @@ cc.ControlSwitchSprite = cc.Sprite.extend({ this._thumbSprite.setPosition(this._onSprite.getContentSize().width + this._sliderXPosition, this._maskSize.height / 2); - this._backRT.begin(); - - this._onSprite.visit(); - this._offSprite.visit(); - - if (this._onLabel) - this._onLabel.visit(); - if (this._offLabel) - this._offLabel.visit(); - - this._backRT.end(); +// this._backRT.begin(); +// +// this._onSprite.visit(); +// this._offSprite.visit(); +// +// if (this._onLabel) +// this._onLabel.visit(); +// if (this._offLabel) +// this._offLabel.visit(); +// +// this._backRT.end(); //this.setFlippedY(true); }, From 2b6cf5efa63c7eb3ad5eaad9bf3993ccb1caa579 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 24 Jun 2014 18:23:26 +0800 Subject: [PATCH 0178/1564] Update - ccs.Armature/ccs.ActionObject/ccs.armatureDataManager/ccs.dataReaderHelper --- .../cocostudio/action/CCActionObject.js | 24 +- extensions/cocostudio/armature/CCArmature.js | 2 +- .../armature/utils/CCArmatureDataManager.js | 29 +- .../armature/utils/CCDataReaderHelper.js | 389 +++++++++++------- .../cocostudio/components/CCComController.js | 4 + .../cocostudio/components/CCComRender.js | 1 + 6 files changed, 272 insertions(+), 177 deletions(-) diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js index 289f509709..c47864194f 100644 --- a/extensions/cocostudio/action/CCActionObject.js +++ b/extensions/cocostudio/action/CCActionObject.js @@ -37,6 +37,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ _unitTime: 0, _currentTime: 0, _scheduler:null, + _fTotalTime: 0, ctor: function () { this._actionNodeList = []; this._name = ""; @@ -45,6 +46,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ this._playing = false; this._unitTime = 0.1; this._currentTime = 0; + this._fTotalTime = 0; this._scheduler = new cc.Scheduler(); cc.director.getScheduler().scheduleUpdateForTarget(this._scheduler, 0, false); }, @@ -118,6 +120,10 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ this._currentTime = time; }, + getTotalTime: function(){ + return this._fTotalTime; + }, + /** * Return if the action is playing. * @returns {boolean} @@ -136,14 +142,20 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ this.setLoop(dic["loop"]); this.setUnitTime(dic["unittime"]); var actionNodeList = dic["actionnodelist"]; + var maxLength = 0; for (var i = 0; i < actionNodeList.length; i++) { - var locActionNode = new ccs.ActionNode(); - var locActionNodeDic = actionNodeList[i]; - locActionNode.initWithDictionary(locActionNodeDic, root); - locActionNode.setUnitTime(this.getUnitTime()); - this._actionNodeList.push(locActionNode); - locActionNodeDic = null; + var actionNode = new ccs.ActionNode(); + + var actionNodeDic = actionNodeList[i]; + actionNode.initWithDictionary(actionNodeDic, root); + actionNode.setUnitTime(this.getUnitTime()); + this._actionNodeList.push(actionNode); + var length = actionNode.getLastFrameIndex() - actionNode.getFirstFrameIndex(); + if(length > maxLength){ + maxLength = length; + } } + this._fTotalTime = maxLength * this._unitTime; }, /** diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 080c24cc56..27f95bd412 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -386,7 +386,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ _nodeToParentTransformForCanvas: function () { if (!this._transform) this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - if (this._transformDirty) { + if (this._transformDirty || true) { this._armatureTransformDirty = true; var t = this._transform;// quick reference // base position diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 573f6d4a41..b12d85b42c 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -76,11 +76,14 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * @param {ccs.ArmatureData} armatureData */ addArmatureData:function (id, armatureData, configFilePath) { - if (this._armarureDatas) { - var data = this.getRelativeData(configFilePath); + var data = this.getRelativeData(configFilePath); + if (data) + { data.armatures.push(id); - this._armarureDatas[id] = armatureData; } + + this._armarureDatas[id] = armatureData; + }, /** @@ -210,21 +213,11 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * //example2 * ccs.armatureDataManager.addArmatureFileInfo("res/test.png","res/test.plist","res/test.json"); */ - addArmatureFileInfo:function (/*imagePath, plistPath, configFilePath*/) { - var imagePath, plistPath, configFilePath; - var isLoadSpriteFrame = false; - if (arguments.length == 1) { - configFilePath = arguments[0]; - isLoadSpriteFrame = true; - this.addRelativeData(configFilePath); - } else if (arguments.length == 3){ - imagePath = arguments[0]; - plistPath = arguments[1]; - configFilePath = arguments[2]; - this.addRelativeData(configFilePath); - this.addSpriteFrameFromFile(plistPath, imagePath, configFilePath); - } - ccs.dataReaderHelper.addDataFromFile(configFilePath,isLoadSpriteFrame); + addArmatureFileInfo:function (configFilePath/*imagePath, plistPath, configFilePath*/) { + this.addRelativeData(configFilePath); + + this._autoLoadSpriteFile = true; + ccs.dataReaderHelper.addDataFromFile(configFilePath); }, /** diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index d3307cf1de..af9049bfc9 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -168,25 +168,54 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ this._asyncRefTotalCount = 0; }, - addDataFromFile: function (filePath, isLoadSpriteFrame) { - if (this._configFileList.indexOf(filePath) != -1) { - return; + addDataFromFile: function (filePath/*, isLoadSpriteFrame*/) { + /* + * Check if file is already added to ArmatureDataManager, if then return. + */ + for(var i = 0; i < this._configFileList.length; i++) + { + if (this._configFileList[i] == filePath) + { + return; + } } this._configFileList.push(filePath); - this._initBaseFilePath(filePath); + //! find the base file path + var basefilePath = filePath; + var pos = basefilePath.lastIndexOf("/"); + + if (pos != -1) + { + basefilePath = basefilePath.substr(0, pos + 1); + } + else + { + basefilePath = ""; + } + + + var filePathStr = filePath; + var str = cc.path.extname(filePathStr); - var str = cc.path.extname(filePath).toLowerCase(); + // Read content from file + var fullPath = cc.path.join(filePath); var dataInfo = new ccs.DataInfo(); - dataInfo.filename = filePath; - dataInfo.basefilePath = this._initBaseFilePath(filePath); - if (str == ".xml") { - this.addDataFromXML(filePath, dataInfo); + dataInfo.filename = filePathStr; + dataInfo.asyncStruct = null; + dataInfo.baseFilePath = basefilePath; + if (str == ".xml") + { + //addDataFromCache... + this.addDataFromXML(fullPath, dataInfo); } - else if (str == ".json" || str == ".exportjson") { - this.addDataFromJson(filePath, dataInfo, isLoadSpriteFrame); + else if(str == ".json" || str == ".ExportJson") + { + //addDataFromJsonCache... + this.addDataFromJson(fullPath, dataInfo); } + }, addDataFromFileAsync: function (filePath, target, selector, isLoadSpriteFrame) { @@ -273,45 +302,45 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ skeleton = null; }, - decodeArmature: function (armatureXML, dataInfo) { - var name = armatureXML.getAttribute(ccs.CONST_A_NAME); + decodeArmature: function (json, dataInfo) { var armatureData = new ccs.ArmatureData(); - armatureData.name = name; - - var bonesXML = armatureXML.querySelectorAll(ccs.CONST_ARMATURE + " > " + ccs.CONST_BONE); - - for (var i = 0; i < bonesXML.length; i++) { - var boneXML = bonesXML[i]; - var parentName = boneXML.getAttribute(ccs.CONST_A_PARENT); - var parentXML = null; - if (parentName) { - //parentXML = armatureXML.querySelectorAll(ccs.CONST_ARMATURE+" > "+ccs.CONST_BONE); - for (var j = 0; j < bonesXML.length; j++) { - parentXML = bonesXML[j]; - if (parentName == bonesXML[j].getAttribute(ccs.CONST_A_NAME)) { - //todo - break; - } - } - } - var boneData = this.decodeBone(boneXML, parentXML, dataInfo); + armatureData.init(); + + var name = json[ccs.CONST_A_NAME]; + if(name != null) + { + armatureData.name = name; + } + + dataInfo.cocoStudioVersion = armatureData.dataVersion = json[ccs.CONST_VERSION] ? + json[ccs.CONST_VERSION][1] : ''; + + var length = json[ccs.CONST_BONE_DATA] ? + json[ccs.CONST_BONE_DATA].length : + 0; + for (var i = 0; i < length; i++) + { + var dic = json[ccs.CONST_BONE_DATA][i]; //json[BONE_DATA][i]; + var boneData = this.decodeBone(dic, dataInfo); armatureData.addBoneData(boneData); + } + return armatureData; }, decodeBone: function (boneXML, parentXML, dataInfo) { - var name = boneXML.getAttribute(ccs.CONST_A_NAME); + var name = boneXML[ccs.CONST_A_NAME]; if (name == "") { return; } var boneData = new ccs.BoneData(); boneData.name = name; - boneData.parentName = boneXML.getAttribute(ccs.CONST_A_PARENT) || ""; - boneData.zOrder = parseInt(boneXML.getAttribute(ccs.CONST_A_Z)) || 0; + boneData.parentName = boneXML[ccs.CONST_A_PARENT] || ""; + boneData.zOrder = parseInt(boneXML[ccs.CONST_A_Z]) || 0; - var displaysXML = boneXML.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_DISPLAY); + var displaysXML = boneXML[ccs.CONST_DISPLAY_DATA] || []; var displayXML; for (var i = 0; i < displaysXML.length; i++) { @@ -322,7 +351,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return boneData; }, decodeBoneDisplay: function (displayXML, dataInfo) { - var isArmature = parseFloat(displayXML.getAttribute(ccs.CONST_A_IS_ARMATURE)) || 0; + var isArmature = parseFloat(displayXML[ccs.CONST_A_IS_ARMATURE]) || 0; var displayData = null; if (isArmature == 1) { @@ -333,7 +362,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ displayData = new ccs.SpriteDisplayData(); displayData.displayType = ccs.DISPLAY_TYPE_SPRITE; } - var displayName = displayXML.getAttribute(ccs.CONST_A_NAME) || ""; + var displayName = displayXML[ccs.CONST_A_NAME] || ""; if (displayName) { displayData.displayName = displayName; } @@ -341,87 +370,105 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, - decodeAnimation: function (animationXML, dataInfo) { - var name = animationXML.getAttribute(ccs.CONST_A_NAME); - var aniData = new ccs.AnimationData(); + decodeAnimation: function (json, dataInfo) { + + var aniData = new ccs.AnimationData(); + + var name = json[ccs.CONST_A_NAME]; + var armatureData = ccs.armatureDataManager.getArmatureData(name); + aniData.name = name; - var movementsXML = animationXML.querySelectorAll(ccs.CONST_ANIMATION + " > " + ccs.CONST_MOVEMENT); - var movementXML = null; - for (var i = 0; i < movementsXML.length; i++) { - movementXML = movementsXML[i]; - var movementData = this.decodeMovement(movementXML, armatureData, dataInfo); - aniData.addMovement(movementData); + var movementXML = json[ccs.CONST_MOVEMENT_DATA]; + + if(movementXML){ + for (var i = 0; i < movementXML.length; i++) + { + var movementData = this.decodeMovement(movementXML[i], armatureData, dataInfo); + aniData.addMovement(movementData); + + } } + return aniData; + }, decodeMovement: function (movementXML, armatureData, dataInfo) { - var movName = movementXML.getAttribute(ccs.CONST_A_NAME); - var movementData = new ccs.MovementData(); - movementData.name = movName; - var duration, durationTo, durationTween, loop = 0, tweenEasing = 0; - duration = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION)) || 0; - movementData.duration = duration; + var movementData = new ccs.MovementData(); - durationTo = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION_TO)) || 0; - movementData.durationTo = durationTo; + var movName = movementXML[ccs.CONST_A_NAME]; + movementData.name = movName; - durationTween = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION_TWEEN)) || 0; - movementData.durationTween = durationTween; - loop = movementXML.getAttribute(ccs.CONST_A_LOOP); - movementData.loop = loop ? Boolean(parseFloat(loop)) : true; + var tweenEasing = 0; - var easing = movementXML.getAttribute(ccs.CONST_A_TWEEN_EASING); - if (easing) { - if (easing != ccs.CONST_FL_NAN) { - tweenEasing = parseFloat(easing) || 0; - movementData.tweenEasing = tweenEasing == 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; - } else { - movementData.tweenEasing = ccs.TweenType.linear; - } + if( movementXML[ccs.CONST_A_DURATION]) + { + movementData.duration = movementXML[ccs.CONST_A_DURATION]; + } + if( movementXML[ccs.CONST_A_DURATION_TO]) + { + movementData.durationTo = movementXML[ccs.CONST_A_DURATION_TO]; + } + if( movementXML[ccs.CONST_A_DURATION_TWEEN]) + { + movementData.durationTween = movementXML[ccs.CONST_A_DURATION_TWEEN]; + } + if( movementXML[ccs.CONST_A_LOOP]) + { + movementData.loop = movementXML[ccs.CONST_A_LOOP] != 0; } - var movBonesXml = movementXML.querySelectorAll(ccs.CONST_MOVEMENT + " > " + ccs.CONST_BONE); - var movBoneXml = null; - for (var i = 0; i < movBonesXml.length; i++) { - movBoneXml = movBonesXml[i]; - var boneName = movBoneXml.getAttribute(ccs.CONST_A_NAME); - - if (movementData.getMovementBoneData(boneName)) { - continue; + var _easing = movementXML[ccs.CONST_A_TWEEN_EASING]; + if(_easing != null) + { + var str = _easing; + if(str != ccs.CONST_FL_NAN) + { + if( movementXML[ccs.CONST_A_TWEEN_EASING]) + { + movementData.tweenEasing = tweenEasing == 2 ? + //cocos2d.tweenfunc.Sine_EaseInOut : + 3 : + movementXML[ccs.CONST_A_TWEEN_EASING]; + } + } + else + { + movementData.tweenEasing = 0//cocos2d.tweenfunc.Linear; } + } - var boneData = armatureData.getBoneData(boneName); - var parentName = boneData.parentName; + //var movBoneXml = movementXML[ccs.CONST_BONE]; - var parentXML = null; - if (parentName != "") { - for (var j = 0; j < movBonesXml.length; j++) { - parentXML = movBonesXml[j]; - if (parentName == parentXML.getAttribute(ccs.CONST_A_NAME)) { - break; - } - } - } - var moveBoneData = this.decodeMovementBone(movBoneXml, parentXML, boneData, dataInfo); - movementData.addMovementBoneData(moveBoneData); + var movBoneXml = movementXML[ccs.CONST_MOVEMENT_BONE_DATA]; + for (var i = 0; i < movBoneXml.length; i++) + { + var parentXml = null; + var dic = movBoneXml[i]; + var movementBoneData = this.decodeMovementBone(movementXML, parentXml, dic, dataInfo); + movementData.addMovementBoneData(movementBoneData); } + return movementData; + + }, decodeMovementBone: function (movBoneXml, parentXml, boneData, dataInfo) { var movBoneData = new ccs.MovementBoneData(); + movBoneData.init(); + var scale, delay; if (movBoneXml) { - scale = parseFloat(movBoneXml.getAttribute(ccs.CONST_A_MOVEMENT_SCALE)) || 0; + scale = parseFloat(movBoneXml[ccs.CONST_A_MOVEMENT_SCALE]) || 0; movBoneData.scale = scale; - delay = parseFloat(movBoneXml.getAttribute(ccs.CONST_A_MOVEMENT_DELAY)) || 0; + delay = parseFloat(movBoneXml[ccs.CONST_A_MOVEMENT_DELAY]) || 0; if (delay > 0) { delay -= 1; } @@ -446,7 +493,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var totalDuration = 0; - var name = movBoneXml.getAttribute(ccs.CONST_A_NAME); + var name = movBoneXml[ccs.CONST_A_NAME]; movBoneData.name = name; var framesXML = movBoneXml.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_FRAME); var j = 0; @@ -457,7 +504,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ while (j < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) { parentFrameXML = parentXMLList[j]; parentTotalDuration += currentDuration; - currentDuration = parseFloat(parentFrameXML.getAttribute(ccs.CONST_A_DURATION)); + currentDuration = parseFloat(parentFrameXML[ccs.CONST_A_DURATION]); j++; } } @@ -619,45 +666,61 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return frameData; }, - decodeTexture: function (textureXML, dataInfo) { + decodeTexture: function (json, dataInfo) { + if(!dataInfo){ + debugger; + } + var textureData = new ccs.TextureData(); - if (textureXML.getAttribute(ccs.CONST_A_NAME)) { - textureData.name = textureXML.getAttribute(ccs.CONST_A_NAME); + textureData.init(); + + if( json[ccs.CONST_A_NAME] != null) + { + textureData.name = json[ccs.CONST_A_NAME]; } - var px, py, width, height = 0; - if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { - px = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_X)) || 0; - py = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_Y)) || 0; + + if(dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) + { + textureData.pivotX = json[ccs.CONST_A_COCOS2D_PIVOT_X]; + textureData.pivotY = json[ccs.CONST_A_COCOS2D_PIVOT_Y]; } - else { - px = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_X)) || 0; - py = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_Y)) || 0; + else + { + textureData.pivotX = json[ccs.CONST_A_PIVOT_X]; + textureData.pivotY = json[ccs.CONST_A_PIVOT_Y]; } - width = parseFloat(textureXML.getAttribute(ccs.CONST_A_WIDTH)) || 0; - height = parseFloat(textureXML.getAttribute(ccs.CONST_A_HEIGHT)) || 0; - var anchorPointX = px / width; - var anchorPointY = (height - py) / height; + textureData.width = json[ccs.CONST_A_WIDTH]; + textureData.height = json[ccs.CONST_A_HEIGHT]; + + var anchorPointX = textureData.pivotX / textureData.width; + var anchorPointY = (textureData.height - textureData.pivotY) / textureData.height; textureData.pivotX = anchorPointX; textureData.pivotY = anchorPointY; - var contoursXML = textureXML.querySelectorAll(ccs.CONST_SUB_TEXTURE + " > " + ccs.CONST_CONTOUR); - for (var i = 0; i < contoursXML.length; i++) { - this.decodeContour(contoursXML[i], dataInfo); + var contour = json[ccs.CONST_CONTOUR_DATA]; + if(contour){ + for (var i=0; i < contour.length; i++) + { + var dic = contour[i]; + var contourData = this.decodeContour(dic); + textureData.contourDataList.push(contourData); + } } + return textureData; }, decodeContour: function (contourXML, dataInfo) { var contourData = new ccs.ContourData(); - var vertexDatasXML = contourXML.querySelectorAll(ccs.CONST_CONTOUR + " > " + ccs.CONST_CONTOUR_VERTEX); + var vertexDatasXML = contourXML['vertex']; var vertexDataXML; for (var i = 0; i < vertexDatasXML.length; i++) { vertexDataXML = vertexDatasXML[i]; var vertex = cc.p(0, 0); - vertex.x = parseFloat(vertexDataXML.getAttribute(ccs.CONST_A_X)) || 0; - vertex.y = parseFloat(vertexDataXML.getAttribute(ccs.CONST_A_Y)) || 0; + vertex.x = parseFloat(vertexDataXML[ccs.CONST_A_X]) || 0; + vertex.y = parseFloat(vertexDataXML[ccs.CONST_A_Y]) || 0; //vertex.y = - vertex.y;//todo contourData.vertexList.push(vertex); } @@ -665,50 +728,72 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, - addDataFromJson: function (filePath, dataInfo, isLoadSpriteFrame) { + addDataFromJson: function (filePath, dataInfo) { var fileContent = cc.loader.getRes(filePath); - this.addDataFromJsonCache(fileContent, dataInfo, isLoadSpriteFrame); + this.addDataFromJsonCache(fileContent, dataInfo, filePath); }, - addDataFromJsonCache: function (dic, dataInfo, isLoadSpriteFrame) { - dataInfo.contentScale = dic[ccs.CONST_CONTENT_SCALE] || 1; - var armatureDataArr = dic[ccs.CONST_ARMATURE_DATA] || []; - var armatureData; - for (var i = 0; i < armatureDataArr.length; i++) { - armatureData = this.decodeArmatureFromJSON(armatureDataArr[i], dataInfo); - ccs.armatureDataManager.addArmatureData(armatureData.name, armatureData, dataInfo.filename); - } - - var animationDataArr = dic[ccs.CONST_ANIMATION_DATA] || []; - var animationData; - for (var i = 0; i < animationDataArr.length; i++) { - animationData = this.decodeAnimationFromJson(animationDataArr[i], dataInfo); - ccs.armatureDataManager.addAnimationData(animationData.name, animationData, dataInfo.filename); - } - - var textureDataArr = dic[ccs.CONST_TEXTURE_DATA] || []; - var textureData; - for (var i = 0; i < textureDataArr.length; i++) { - textureData = this.decodeTextureFromJson(textureDataArr[i], dataInfo); - ccs.armatureDataManager.addTextureData(textureData.name, textureData, dataInfo.filename); - } - - if (isLoadSpriteFrame) { - var configFiles = dic[ccs.CONST_CONFIG_FILE_PATH] || []; - var locFilePath, locPos, locPlistPath, locImagePath; - for (var i = 0; i < configFiles.length; i++) { - locFilePath = configFiles[i]; - locPos = locFilePath.lastIndexOf("."); - locFilePath = locFilePath.substring(0, locPos); - locPlistPath = dataInfo.basefilePath + locFilePath + ".plist"; - locImagePath = dataInfo.basefilePath + locFilePath + ".png"; - ccs.armatureDataManager.addSpriteFrameFromFile(locPlistPath, locImagePath, dataInfo.filename); - } + addDataFromJsonCache: function (json, dataInfo, filePath) { + // Decode armatures + var length = json[ccs.CONST_ARMATURE_DATA].length; + for(var i=0; i Date: Wed, 25 Jun 2014 14:11:37 +0800 Subject: [PATCH 0179/1564] Issue #5602: fix ScrollView addChild bug --- extensions/gui/scrollview/CCScrollView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index fd6bb644a3..dce7bfce37 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -648,8 +648,8 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ zOrder = zOrder || child.getLocalZOrder(); tag = tag || child.getTag(); - child.ignoreAnchorPointForPosition(false); - child.setAnchorPoint(0, 0); + //child.ignoreAnchorPointForPosition(false); + //child.setAnchorPoint(0, 0); if (this._container != child) { this._container.addChild(child, zOrder, tag); } else { From 0851205c63d8e9f10fe71e9b6f3baf636d4d7472 Mon Sep 17 00:00:00 2001 From: sincntx Date: Wed, 25 Jun 2014 17:13:41 +0900 Subject: [PATCH 0180/1564] Touch anywhere of screen to finish input when using cc.EditBox --- extensions/editbox/CCEditBox.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 51a3051f98..3150ece3cf 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -250,7 +250,10 @@ cc.EditBox = cc.ControlButton.extend({ tmpEdTxt.style.height = "100%"; tmpEdTxt.style.active = 0; tmpEdTxt.style.outline = "medium"; - + var onCanvasClick = function() { + tmpEdTxt.blur(); + }; + // TODO the event listener will be remove when EditBox removes from parent. cc._addEventListener(tmpEdTxt, "input", function () { if (selfPointer._delegate && selfPointer._delegate.editBoxTextChanged) @@ -271,6 +274,7 @@ cc.EditBox = cc.ControlButton.extend({ } if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidBegin) selfPointer._delegate.editBoxEditingDidBegin(selfPointer); + cc._addEventListener(cc._canvas, "click", onCanvasClick); }); cc._addEventListener(tmpEdTxt, "blur", function () { if (this.value == "") { @@ -282,6 +286,7 @@ cc.EditBox = cc.ControlButton.extend({ selfPointer._delegate.editBoxEditingDidEnd(selfPointer); if (selfPointer._delegate && selfPointer._delegate.editBoxReturn) selfPointer._delegate.editBoxReturn(selfPointer); + cc._canvas.removeEventListener('click', onCanvasClick); }); cc.DOM.convert(tmpDOMSprite); From 03fc756d9632f09b6e8d454f5874c71b9514e6fa Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 25 Jun 2014 16:23:26 +0800 Subject: [PATCH 0181/1564] issue #5604: update ccui.Widget function names --- extensions/ccui/base-classes/UIWidget.js | 12 +- extensions/ccui/layouts/UILayout.js | 52 +++--- .../uiwidgets/scroll-widget/UIPageView.js | 8 +- .../uiwidgets/scroll-widget/UIScrollView.js | 164 +++++++++--------- 4 files changed, 118 insertions(+), 118 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 0c7718a2df..63e82fdc78 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1187,7 +1187,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ * Gets the left boundary position of this widget. * @returns {number} */ - getLeftInParent: function () { + getLeftBoundary: function () { return this.getPositionX() - this._getAnchorX() * this._size.width; }, @@ -1195,7 +1195,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ * Gets the bottom boundary position of this widget. * @returns {number} */ - getBottomInParent: function () { + getBottomBoundary: function () { return this.getPositionY() - this._getAnchorY() * this._size.height; }, @@ -1203,16 +1203,16 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ * Gets the right boundary position of this widget. * @returns {number} */ - getRightInParent: function () { - return this.getLeftInParent() + this._size.width; + getRightBoundary: function () { + return this.getLeftBoundary() + this._size.width; }, /** * Gets the top boundary position of this widget. * @returns {number} */ - getTopInParent: function () { - return this.getBottomInParent() + this._size.height; + getTopBoundary: function () { + return this.getBottomBoundary() + this._size.height; }, /** diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 1fba4c16c6..7cc8d7e7fa 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1020,7 +1020,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX += locMargin.left; locFinalPosY -= locMargin.top; locChild.setPosition(locFinalPosX, locFinalPosY); - topBoundary = locChild.getBottomInParent() - locMargin.bottom; + topBoundary = locChild.getBottomBoundary() - locMargin.bottom; } } }, @@ -1055,7 +1055,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX += locMargin.left; locFinalPosY -= locMargin.top; locChild.setPosition(locFinalPosX, locFinalPosY); - leftBoundary = locChild.getRightInParent() + locMargin.right; + leftBoundary = locChild.getRightBoundary() + locMargin.right; } } }, @@ -1138,8 +1138,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationBottom = locRelativeWidget.getTopInParent(); - var locationLeft = locRelativeWidget.getLeftInParent(); + var locationBottom = locRelativeWidget.getTopBoundary(); + var locationLeft = locRelativeWidget.getLeftBoundary(); locFinalPosY = locationBottom + locAP.y * locSize.height; locFinalPosX = locationLeft + locAP.x * locSize.width; } @@ -1150,10 +1150,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ continue; } var rbs = locRelativeWidget.getSize(); - var locationBottom = locRelativeWidget.getTopInParent(); + var locationBottom = locRelativeWidget.getTopBoundary(); locFinalPosY = locationBottom + locAP.y * locSize.height; - locFinalPosX = locRelativeWidget.getLeftInParent() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; + locFinalPosX = locRelativeWidget.getLeftBoundary() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; } break; case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT: @@ -1161,8 +1161,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationBottom = locRelativeWidget.getTopInParent(); - var locationRight = locRelativeWidget.getRightInParent(); + var locationBottom = locRelativeWidget.getTopBoundary(); + var locationRight = locRelativeWidget.getRightBoundary(); locFinalPosY = locationBottom + locAP.y * locSize.height; locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; } @@ -1172,8 +1172,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationTop = locRelativeWidget.getTopInParent(); - var locationRight = locRelativeWidget.getLeftInParent(); + var locationTop = locRelativeWidget.getTopBoundary(); + var locationRight = locRelativeWidget.getLeftBoundary(); locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; } @@ -1184,10 +1184,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ continue; } var rbs = locRelativeWidget.getSize(); - var locationRight = locRelativeWidget.getLeftInParent(); + var locationRight = locRelativeWidget.getLeftBoundary(); locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; - locFinalPosY = locRelativeWidget.getBottomInParent() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; + locFinalPosY = locRelativeWidget.getBottomBoundary() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; } break; case ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM: @@ -1195,8 +1195,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationBottom = locRelativeWidget.getBottomInParent(); - var locationRight = locRelativeWidget.getLeftInParent(); + var locationBottom = locRelativeWidget.getBottomBoundary(); + var locationRight = locRelativeWidget.getLeftBoundary(); locFinalPosY = locationBottom + locAP.y * locSize.height; locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; } @@ -1206,8 +1206,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationTop = locRelativeWidget.getTopInParent(); - var locationLeft = locRelativeWidget.getRightInParent(); + var locationTop = locRelativeWidget.getTopBoundary(); + var locationLeft = locRelativeWidget.getRightBoundary(); locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; locFinalPosX = locationLeft + locAP.x * locSize.width; } @@ -1218,10 +1218,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ continue; } var rbs = locRelativeWidget.getSize(); - var locationLeft = locRelativeWidget.getRightInParent(); + var locationLeft = locRelativeWidget.getRightBoundary(); locFinalPosX = locationLeft + locAP.x * locSize.width; - locFinalPosY = locRelativeWidget.getBottomInParent() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; + locFinalPosY = locRelativeWidget.getBottomBoundary() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; } break; case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM: @@ -1229,8 +1229,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationBottom = locRelativeWidget.getBottomInParent(); - var locationLeft = locRelativeWidget.getRightInParent(); + var locationBottom = locRelativeWidget.getBottomBoundary(); + var locationLeft = locRelativeWidget.getRightBoundary(); locFinalPosY = locationBottom + locAP.y * locSize.height; locFinalPosX = locationLeft + locAP.x * locSize.width; } @@ -1240,8 +1240,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationTop = locRelativeWidget.getBottomInParent(); - var locationLeft = locRelativeWidget.getLeftInParent(); + var locationTop = locRelativeWidget.getBottomBoundary(); + var locationLeft = locRelativeWidget.getLeftBoundary(); locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; locFinalPosX = locationLeft + locAP.x * locSize.width; } @@ -1252,10 +1252,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ continue; } var rbs = locRelativeWidget.getSize(); - var locationTop = locRelativeWidget.getBottomInParent(); + var locationTop = locRelativeWidget.getBottomBoundary(); locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; - locFinalPosX = locRelativeWidget.getLeftInParent() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; + locFinalPosX = locRelativeWidget.getLeftBoundary() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; } break; case ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM: @@ -1263,8 +1263,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; } - var locationTop = locRelativeWidget.getBottomInParent(); - var locationRight = locRelativeWidget.getRightInParent(); + var locationTop = locRelativeWidget.getBottomBoundary(); + var locationRight = locRelativeWidget.getRightBoundary(); locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index aa62595010..3b01e8f9e4 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -433,16 +433,16 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ switch (this._touchMoveDir) { case ccui.PageView.TOUCH_DIR_LEFT: // left - if (this._rightChild.getRightInParent() + touchOffset <= this._rightBoundary) { - realOffset = this._rightBoundary - this._rightChild.getRightInParent(); + if (this._rightChild.getRightBoundary() + touchOffset <= this._rightBoundary) { + realOffset = this._rightBoundary - this._rightChild.getRightBoundary(); this.movePages(realOffset); return false; } break; case ccui.PageView.TOUCH_DIR_RIGHT: // right - if (this._leftChild.getLeftInParent() + touchOffset >= this._leftBoundary) { - realOffset = this._leftBoundary - this._leftChild.getLeftInParent(); + if (this._leftChild.getLeftBoundary() + touchOffset >= this._leftBoundary) { + realOffset = this._leftBoundary - this._leftChild.getLeftBoundary(); this.movePages(realOffset); return false; } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 9ef2e5ea4f..3ff57c850c 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -188,7 +188,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.scrollChildren(0, offset); break; case ccui.ScrollView.DIR_HORIZONTAL: - if (this._innerContainer.getRightInParent() <= locSize.width) { + if (this._innerContainer.getRightBoundary() <= locSize.width) { var newInnerSize = this._innerContainer.getSize(); var offset = originalInnerSize.width - newInnerSize.width; this.scrollChildren(offset, 0); @@ -198,7 +198,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var newInnerSize = this._innerContainer.getSize(); var offsetY = originalInnerSize.height - newInnerSize.height; var offsetX = 0; - if (this._innerContainer.getRightInParent() <= locSize.width) { + if (this._innerContainer.getRightBoundary() <= locSize.width) { offsetX = originalInnerSize.width - newInnerSize.width; } this.scrollChildren(offsetX, offsetY); @@ -210,16 +210,16 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var innerSize = innerContainer.getSize(); var innerPos = innerContainer.getPosition(); var innerAP = innerContainer.getAnchorPoint(); - if (innerContainer.getLeftInParent() > 0.0) { + if (innerContainer.getLeftBoundary() > 0.0) { innerContainer.setPosition(innerAP.x * innerSize.width, innerPos.y); } - if (innerContainer.getRightInParent() < locSize.width) { + if (innerContainer.getRightBoundary() < locSize.width) { innerContainer.setPosition(locSize.width - ((1.0 - innerAP.x) * innerSize.width), innerPos.y); } if (innerPos.y > 0.0) { innerContainer.setPosition(innerPos.x, innerAP.y * innerSize.height); } - if (innerContainer.getTopInParent() < locSize.height) { + if (innerContainer.getTopBoundary() < locSize.height) { innerContainer.setPosition(innerPos.x, locSize.height - (1.0 - innerAP.y) * innerSize.height); } }, @@ -237,7 +237,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ switch (this.direction) { case ccui.ScrollView.DIR_HORIZONTAL: case ccui.ScrollView.DIR_BOTH: - if (container.getRightInParent() <= locW) { + if (container.getRightBoundary() <= locW) { var newInnerWidth = container.width; var offset = oldInnerWidth - newInnerWidth; this.scrollChildren(offset, 0); @@ -245,10 +245,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; } var innerAX = container.anchorX; - if (container.getLeftInParent() > 0.0) { + if (container.getLeftBoundary() > 0.0) { container.x = innerAX * innerWidth; } - if (container.getRightInParent() < locW) { + if (container.getRightBoundary() < locW) { container.x = locW - ((1.0 - innerAX) * innerWidth); } }, @@ -272,10 +272,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; } var innerAY = container.anchorY; - if (container.getLeftInParent() > 0.0) { + if (container.getLeftBoundary() > 0.0) { container.y = innerAY * innerHeight; } - if (container.getRightInParent() < locH) { + if (container.getRightBoundary() < locH) { container.y = locH - ((1.0 - innerAY) * innerHeight); } }, @@ -463,49 +463,49 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.checkBounceBoundary(); if (this._topBounceNeeded || this._bottomBounceNeeded || this._leftBounceNeeded || this._rightBounceNeeded) { if (this._topBounceNeeded && this._leftBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0.0, this._size.height), cc.p(this._innerContainer.getLeftInParent(), this._innerContainer.getTopInParent())); + var scrollVector = cc.pSub(cc.p(0.0, this._size.height), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getTopBoundary())); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._topBounceNeeded && this._rightBounceNeeded) { - var scrollVector = cc.pSub(cc.p(this._size.width, this._size.height), cc.p(this._innerContainer.getRightInParent(), this._innerContainer.getTopInParent())); + var scrollVector = cc.pSub(cc.p(this._size.width, this._size.height), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getTopBoundary())); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._bottomBounceNeeded && this._leftBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftInParent(), this._innerContainer.getBottomInParent())); + var scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getBottomBoundary())); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._bottomBounceNeeded && this._rightBounceNeeded) { - var scrollVector = cc.pSub(cc.p(this._size.width, 0.0), cc.p(this._innerContainer.getRightInParent(), this._innerContainer.getBottomInParent())); + var scrollVector = cc.pSub(cc.p(this._size.width, 0.0), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getBottomBoundary())); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._topBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, this._size.height), cc.p(0.0, this._innerContainer.getTopInParent())); + var scrollVector = cc.pSub(cc.p(0, this._size.height), cc.p(0.0, this._innerContainer.getTopBoundary())); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._bottomBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, 0), cc.p(0.0, this._innerContainer.getBottomInParent())); + var scrollVector = cc.pSub(cc.p(0, 0), cc.p(0.0, this._innerContainer.getBottomBoundary())); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._leftBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftInParent(), 0.0)); + var scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), 0.0)); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._rightBounceNeeded) { - var scrollVector = cc.pSub(cc.p(this._size.width, 0), cc.p(this._innerContainer.getRightInParent(), 0.0)); + var scrollVector = cc.pSub(cc.p(this._size.width, 0), cc.p(this._innerContainer.getRightBoundary(), 0.0)); var orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); @@ -516,7 +516,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, checkBounceBoundary: function () { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos > this._bottomBoundary) { this.scrollToBottomEvent(); this._bottomBounceNeeded = true; @@ -524,7 +524,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else { this._bottomBounceNeeded = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos < this._topBoundary) { this.scrollToTopEvent(); this._topBounceNeeded = true; @@ -532,7 +532,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else { this._topBounceNeeded = false; } - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos < this._rightBoundary) { this.scrollToRightEvent(); this._rightBounceNeeded = true; @@ -540,7 +540,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else { this._rightBounceNeeded = false; } - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos > this._leftBoundary) { this.scrollToLeftEvent(); this._leftBounceNeeded = true; @@ -637,13 +637,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ { var realOffsetX = touchOffsetX; var realOffsetY = touchOffsetY; - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.bounceRightEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.bounceTopEvent(); @@ -655,13 +655,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ { var realOffsetX = touchOffsetX; var realOffsetY = touchOffsetY; - var icLefrPos = this._innerContainer.getLeftInParent(); + var icLefrPos = this._innerContainer.getLeftBoundary(); if (icLefrPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLefrPos; this.bounceLeftEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.bounceTopEvent(); @@ -673,13 +673,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ { var realOffsetX = touchOffsetX; var realOffsetY = touchOffsetY; - var icLefrPos = this._innerContainer.getLeftInParent(); + var icLefrPos = this._innerContainer.getLeftBoundary(); if (icLefrPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLefrPos; this.bounceLeftEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.bounceBottomEvent(); @@ -691,13 +691,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ { var realOffsetX = touchOffsetX; var realOffsetY = touchOffsetY; - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.bounceRightEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.bounceBottomEvent(); @@ -708,7 +708,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // bounce to top { var realOffsetY = touchOffsetY; - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.bounceTopEvent(); @@ -719,7 +719,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) //bounce to bottom { var realOffsetY = touchOffsetY; - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.bounceBottomEvent(); @@ -730,7 +730,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else if (touchOffsetX > 0.0 && touchOffsetY == 0.0) //bounce to right { var realOffsetX = touchOffsetX; - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.bounceRightEvent(); @@ -741,7 +741,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) //bounce to left { var realOffsetX = touchOffsetX; - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; this.bounceLeftEvent(); @@ -757,14 +757,14 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical if (this._autoScrollDir.y > 0) { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; } } else { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; @@ -773,14 +773,14 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; case ccui.ScrollView.DIR_HORIZONTAL: // horizontal if (this._autoScrollDir.x > 0) { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; } } else { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; @@ -790,12 +790,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ case ccui.ScrollView.DIR_BOTH: if (touchOffsetX > 0.0 && touchOffsetY > 0.0) // up right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; @@ -803,12 +803,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) // up left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icRightPos; scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; @@ -816,12 +816,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) // down left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icRightPos; scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icTopPos; scrollEnabled = false; @@ -829,12 +829,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0) // down right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icTopPos; scrollEnabled = false; @@ -842,7 +842,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // up { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; @@ -850,7 +850,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) // left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icRightPos; scrollEnabled = false; @@ -858,7 +858,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) // down { - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icTopPos; scrollEnabled = false; @@ -866,7 +866,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0) // right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; @@ -892,13 +892,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ case ccui.ScrollView.DIR_VERTICAL: // vertical var realOffset = touchOffsetY; if (this.bounceEnabled) { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffset = this._bounceBottomBoundary - icBottomPos; this.scrollToBottomEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffset = this._bounceTopBoundary - icTopPos; this.scrollToTopEvent(); @@ -906,13 +906,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } } else { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffset = this._bottomBoundary - icBottomPos; this.scrollToBottomEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffset = this._topBoundary - icTopPos; this.scrollToTopEvent(); @@ -924,13 +924,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ case ccui.ScrollView.DIR_HORIZONTAL: // horizontal var realOffset = touchOffsetX; if (this.bounceEnabled) { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffset = this._bounceRightBoundary - icRightPos; this.scrollToRightEvent(); scrollEnabled = false; } - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffset = this._bounceLeftBoundary - icLeftPos; this.scrollToLeftEvent(); @@ -938,13 +938,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } } else { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffset = this._rightBoundary - icRightPos; this.scrollToRightEvent(); scrollEnabled = false; } - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffset = this._leftBoundary - icLeftPos; this.scrollToLeftEvent(); @@ -959,13 +959,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (this.bounceEnabled) { if (touchOffsetX > 0.0 && touchOffsetY > 0.0) // up right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffsetX = this._bounceLeftBoundary - icLeftPos; this.scrollToLeftEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffsetY = this._bounceBottomBoundary - icBottomPos; this.scrollToBottomEvent(); @@ -974,13 +974,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) // up left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffsetX = this._bounceRightBoundary - icRightPos; this.scrollToRightEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffsetY = this._bounceBottomBoundary - icBottomPos; this.scrollToBottomEvent(); @@ -989,13 +989,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) // down left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffsetX = this._bounceRightBoundary - icRightPos; this.scrollToRightEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffsetY = this._bounceTopBoundary - icTopPos; this.scrollToTopEvent(); @@ -1004,13 +1004,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0) // down right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffsetX = this._bounceLeftBoundary - icLeftPos; this.scrollToLeftEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffsetY = this._bounceTopBoundary - icTopPos; this.scrollToTopEvent(); @@ -1019,7 +1019,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // up { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffsetY = this._bounceBottomBoundary - icBottomPos; this.scrollToBottomEvent(); @@ -1028,7 +1028,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) // left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffsetX = this._bounceRightBoundary - icRightPos; this.scrollToRightEvent(); @@ -1037,7 +1037,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) // down { - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffsetY = this._bounceTopBoundary - icTopPos; this.scrollToTopEvent(); @@ -1046,7 +1046,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0) // right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffsetX = this._bounceLeftBoundary - icLeftPos; this.scrollToLeftEvent(); @@ -1057,13 +1057,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else { if (touchOffsetX > 0.0 && touchOffsetY > 0.0) // up right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; this.scrollToLeftEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.scrollToBottomEvent(); @@ -1072,13 +1072,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) // up left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.scrollToRightEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.scrollToBottomEvent(); @@ -1087,13 +1087,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0 && touchOffsetY < 0) // down left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.scrollToRightEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.scrollToTopEvent(); @@ -1102,13 +1102,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX > 0 && touchOffsetY < 0) // down right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; this.scrollToLeftEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.scrollToTopEvent(); @@ -1117,7 +1117,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // up { - var icBottomPos = this._innerContainer.getBottomInParent(); + var icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.scrollToBottomEvent(); @@ -1126,7 +1126,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) // left { - var icRightPos = this._innerContainer.getRightInParent(); + var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.scrollToRightEvent(); @@ -1135,7 +1135,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX == 0.0 && touchOffsetY < 0) // down { - var icTopPos = this._innerContainer.getTopInParent(); + var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.scrollToTopEvent(); @@ -1144,7 +1144,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX > 0 && touchOffsetY == 0) // right { - var icLeftPos = this._innerContainer.getLeftInParent(); + var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; this.scrollToLeftEvent(); From ccf27c62ac7ce24c6eb35a9fb5c74faaf33c7416 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 26 Jun 2014 15:17:13 +0800 Subject: [PATCH 0182/1564] Issue #5600: update cocostudio 1. ui 2. render --- extensions/ccui/layouts/UILayout.js | 13 +- extensions/ccui/layouts/UILayoutParameter.js | 17 +- extensions/cocostudio/action/CCActionFrame.js | 3 + extensions/cocostudio/armature/CCArmature.js | 2 +- .../armature/display/CCDisplayManager.js | 10 +- .../armature/utils/CCArmatureDataManager.js | 41 +- .../armature/utils/CCDataReaderHelper.js | 389 +++++++----------- extensions/cocostudio/reader/GUIReader.js | 42 +- extensions/cocostudio/reader/SceneReader.js | 14 +- .../widgetreader/ButtonReader/ButtonReader.js | 23 +- .../CheckBoxReader/CheckBoxReader.js | 19 +- .../ImageViewReader/ImageViewReader.js | 19 +- .../LabelAtlasReader/LabelAtlasReader.js | 19 +- .../LabelBMFontReader/LabelBMFontReader.js | 20 +- .../widgetreader/LabelReader/LabelReader.js | 21 +- .../widgetreader/LayoutReader/LayoutReader.js | 20 +- .../ListViewReader/ListViewReader.js | 17 +- .../LoadingBarReader/LoadingBarReader.js | 19 +- .../PageViewReader/PageViewReader.js | 17 +- .../ScrollViewReader/ScrollViewReader.js | 19 +- .../widgetreader/SliderReader/SliderReader.js | 19 +- .../TextFieldReader/TextFieldReader.js | 19 +- .../reader/widgetreader/WidgetReader.js | 45 +- 23 files changed, 306 insertions(+), 521 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 9eddd4836d..077b10eb72 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -58,10 +58,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _scissorRectDirty: false, _clippingRect: null, _clippingParent: null, - _clippingRectDirty: true, _className: "Layout", _backGroundImageColor: null, - + _finalPositionX: 0, + _finalPositionY: 0, /** * allocates and initializes a UILayout. * Constructor of ccui.Layout @@ -1008,6 +1008,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var topBoundary = layoutSize.height; for (var i = 0; i < layoutChildrenArray.length; ++i) { var locChild = layoutChildrenArray[i]; + if(locChild.name === "UItest"){ + void 0; + } var locLayoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.LINEAR); if (locLayoutParameter) { @@ -1030,8 +1033,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ break; } var locMargin = locLayoutParameter.getMargin(); - locFinalPosX += locMargin.left; - locFinalPosY -= locMargin.top; + locFinalPosX += locMargin.left || 0; + locFinalPosY -= locMargin.top || 0; locChild.setPosition(locFinalPosX, locFinalPosY); topBoundary = locChild.getBottomInParent() - locMargin.bottom; } @@ -1380,13 +1383,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } } }, + _doLayout: function () { if (!this._doLayoutDirty) { return; } switch (this._layoutType) { case ccui.Layout.ABSOLUTE: - break; case ccui.Layout.LINEAR_VERTICAL: this.doLayout_LINEAR_VERTICAL(); break; diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 95fbae96e3..7a496ae5b9 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -41,10 +41,17 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * @param {ccui.Margin} margin */ setMargin: function (margin) { - this._margin.left = margin.left; - this._margin.top = margin.top; - this._margin.right = margin.right; - this._margin.bottom = margin.bottom; + if(typeof margin === 'object'){ + this._margin.left = margin.left; + this._margin.top = margin.top; + this._margin.right = margin.right; + this._margin.bottom = margin.bottom; + }else{ + this._margin.left = arguments[0]; + this._margin.top = arguments[1]; + this._margin.right = arguments[2]; + this._margin.bottom = arguments[3]; + } }, /** @@ -147,7 +154,7 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL this.setAlign(parameter._relativeAlign); this.setRelativeName(parameter._relativeLayoutName); this.setRelativeToWidgetName(parameter._relativeWidgetName); - //this.setGravity(model._linearGravity); + this.setGravity(model._linearGravity); } } }); diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 8dd454c052..b1c8a1cb54 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -220,6 +220,9 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ for(var i=0;i " + ccs.CONST_BONE); + + for (var i = 0; i < bonesXML.length; i++) { + var boneXML = bonesXML[i]; + var parentName = boneXML.getAttribute(ccs.CONST_A_PARENT); + var parentXML = null; + if (parentName) { + //parentXML = armatureXML.querySelectorAll(ccs.CONST_ARMATURE+" > "+ccs.CONST_BONE); + for (var j = 0; j < bonesXML.length; j++) { + parentXML = bonesXML[j]; + if (parentName == bonesXML[j].getAttribute(ccs.CONST_A_NAME)) { + //todo + break; + } + } + } + var boneData = this.decodeBone(boneXML, parentXML, dataInfo); armatureData.addBoneData(boneData); - } - return armatureData; }, decodeBone: function (boneXML, parentXML, dataInfo) { - var name = boneXML[ccs.CONST_A_NAME]; + var name = boneXML.getAttribute(ccs.CONST_A_NAME); if (name == "") { return; } var boneData = new ccs.BoneData(); boneData.name = name; - boneData.parentName = boneXML[ccs.CONST_A_PARENT] || ""; - boneData.zOrder = parseInt(boneXML[ccs.CONST_A_Z]) || 0; + boneData.parentName = boneXML.getAttribute(ccs.CONST_A_PARENT) || ""; + boneData.zOrder = parseInt(boneXML.getAttribute(ccs.CONST_A_Z)) || 0; - var displaysXML = boneXML[ccs.CONST_DISPLAY_DATA] || []; + var displaysXML = boneXML.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_DISPLAY); var displayXML; for (var i = 0; i < displaysXML.length; i++) { @@ -351,7 +322,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return boneData; }, decodeBoneDisplay: function (displayXML, dataInfo) { - var isArmature = parseFloat(displayXML[ccs.CONST_A_IS_ARMATURE]) || 0; + var isArmature = parseFloat(displayXML.getAttribute(ccs.CONST_A_IS_ARMATURE)) || 0; var displayData = null; if (isArmature == 1) { @@ -362,7 +333,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ displayData = new ccs.SpriteDisplayData(); displayData.displayType = ccs.DISPLAY_TYPE_SPRITE; } - var displayName = displayXML[ccs.CONST_A_NAME] || ""; + var displayName = displayXML.getAttribute(ccs.CONST_A_NAME) || ""; if (displayName) { displayData.displayName = displayName; } @@ -370,105 +341,87 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, - decodeAnimation: function (json, dataInfo) { - - var aniData = new ccs.AnimationData(); - - var name = json[ccs.CONST_A_NAME]; - + decodeAnimation: function (animationXML, dataInfo) { + var name = animationXML.getAttribute(ccs.CONST_A_NAME); + var aniData = new ccs.AnimationData(); var armatureData = ccs.armatureDataManager.getArmatureData(name); - aniData.name = name; - var movementXML = json[ccs.CONST_MOVEMENT_DATA]; - - if(movementXML){ - for (var i = 0; i < movementXML.length; i++) - { - var movementData = this.decodeMovement(movementXML[i], armatureData, dataInfo); - aniData.addMovement(movementData); - - } + var movementsXML = animationXML.querySelectorAll(ccs.CONST_ANIMATION + " > " + ccs.CONST_MOVEMENT); + var movementXML = null; + for (var i = 0; i < movementsXML.length; i++) { + movementXML = movementsXML[i]; + var movementData = this.decodeMovement(movementXML, armatureData, dataInfo); + aniData.addMovement(movementData); } - return aniData; - }, decodeMovement: function (movementXML, armatureData, dataInfo) { - + var movName = movementXML.getAttribute(ccs.CONST_A_NAME); var movementData = new ccs.MovementData(); - - var movName = movementXML[ccs.CONST_A_NAME]; movementData.name = movName; + var duration, durationTo, durationTween, loop = 0, tweenEasing = 0; + duration = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION)) || 0; + movementData.duration = duration; - var tweenEasing = 0; + durationTo = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION_TO)) || 0; + movementData.durationTo = durationTo; - if( movementXML[ccs.CONST_A_DURATION]) - { - movementData.duration = movementXML[ccs.CONST_A_DURATION]; - } - if( movementXML[ccs.CONST_A_DURATION_TO]) - { - movementData.durationTo = movementXML[ccs.CONST_A_DURATION_TO]; - } - if( movementXML[ccs.CONST_A_DURATION_TWEEN]) - { - movementData.durationTween = movementXML[ccs.CONST_A_DURATION_TWEEN]; - } - if( movementXML[ccs.CONST_A_LOOP]) - { - movementData.loop = movementXML[ccs.CONST_A_LOOP] != 0; - } + durationTween = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION_TWEEN)) || 0; + movementData.durationTween = durationTween; - var _easing = movementXML[ccs.CONST_A_TWEEN_EASING]; - if(_easing != null) - { - var str = _easing; - if(str != ccs.CONST_FL_NAN) - { - if( movementXML[ccs.CONST_A_TWEEN_EASING]) - { - movementData.tweenEasing = tweenEasing == 2 ? - //cocos2d.tweenfunc.Sine_EaseInOut : - 3 : - movementXML[ccs.CONST_A_TWEEN_EASING]; - } - } - else - { - movementData.tweenEasing = 0//cocos2d.tweenfunc.Linear; + loop = movementXML.getAttribute(ccs.CONST_A_LOOP); + movementData.loop = loop ? Boolean(parseFloat(loop)) : true; + + var easing = movementXML.getAttribute(ccs.CONST_A_TWEEN_EASING); + if (easing) { + if (easing != ccs.CONST_FL_NAN) { + tweenEasing = parseFloat(easing) || 0; + movementData.tweenEasing = tweenEasing == 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; + } else { + movementData.tweenEasing = ccs.TweenType.linear; } } - //var movBoneXml = movementXML[ccs.CONST_BONE]; - - var movBoneXml = movementXML[ccs.CONST_MOVEMENT_BONE_DATA]; - for (var i = 0; i < movBoneXml.length; i++) - { - var parentXml = null; - var dic = movBoneXml[i]; - var movementBoneData = this.decodeMovementBone(movementXML, parentXml, dic, dataInfo); - movementData.addMovementBoneData(movementBoneData); - } + var movBonesXml = movementXML.querySelectorAll(ccs.CONST_MOVEMENT + " > " + ccs.CONST_BONE); + var movBoneXml = null; + for (var i = 0; i < movBonesXml.length; i++) { + movBoneXml = movBonesXml[i]; + var boneName = movBoneXml.getAttribute(ccs.CONST_A_NAME); - return movementData; + if (movementData.getMovementBoneData(boneName)) { + continue; + } + var boneData = armatureData.getBoneData(boneName); + var parentName = boneData.parentName; + var parentXML = null; + if (parentName != "") { + for (var j = 0; j < movBonesXml.length; j++) { + parentXML = movBonesXml[j]; + if (parentName == parentXML.getAttribute(ccs.CONST_A_NAME)) { + break; + } + } + } + var moveBoneData = this.decodeMovementBone(movBoneXml, parentXML, boneData, dataInfo); + movementData.addMovementBoneData(moveBoneData); + } + return movementData; }, decodeMovementBone: function (movBoneXml, parentXml, boneData, dataInfo) { var movBoneData = new ccs.MovementBoneData(); - movBoneData.init(); - var scale, delay; if (movBoneXml) { - scale = parseFloat(movBoneXml[ccs.CONST_A_MOVEMENT_SCALE]) || 0; + scale = parseFloat(movBoneXml.getAttribute(ccs.CONST_A_MOVEMENT_SCALE)) || 0; movBoneData.scale = scale; - delay = parseFloat(movBoneXml[ccs.CONST_A_MOVEMENT_DELAY]) || 0; + delay = parseFloat(movBoneXml.getAttribute(ccs.CONST_A_MOVEMENT_DELAY)) || 0; if (delay > 0) { delay -= 1; } @@ -493,7 +446,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var totalDuration = 0; - var name = movBoneXml[ccs.CONST_A_NAME]; + var name = movBoneXml.getAttribute(ccs.CONST_A_NAME); movBoneData.name = name; var framesXML = movBoneXml.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_FRAME); var j = 0; @@ -504,7 +457,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ while (j < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) { parentFrameXML = parentXMLList[j]; parentTotalDuration += currentDuration; - currentDuration = parseFloat(parentFrameXML[ccs.CONST_A_DURATION]); + currentDuration = parseFloat(parentFrameXML.getAttribute(ccs.CONST_A_DURATION)); j++; } } @@ -666,61 +619,45 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return frameData; }, - decodeTexture: function (json, dataInfo) { - if(!dataInfo){ - debugger; - } - + decodeTexture: function (textureXML, dataInfo) { var textureData = new ccs.TextureData(); - textureData.init(); - - if( json[ccs.CONST_A_NAME] != null) - { - textureData.name = json[ccs.CONST_A_NAME]; + if (textureXML.getAttribute(ccs.CONST_A_NAME)) { + textureData.name = textureXML.getAttribute(ccs.CONST_A_NAME); } - - if(dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) - { - textureData.pivotX = json[ccs.CONST_A_COCOS2D_PIVOT_X]; - textureData.pivotY = json[ccs.CONST_A_COCOS2D_PIVOT_Y]; + var px, py, width, height = 0; + if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { + px = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_X)) || 0; + py = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_Y)) || 0; } - else - { - textureData.pivotX = json[ccs.CONST_A_PIVOT_X]; - textureData.pivotY = json[ccs.CONST_A_PIVOT_Y]; + else { + px = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_X)) || 0; + py = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_Y)) || 0; } + width = parseFloat(textureXML.getAttribute(ccs.CONST_A_WIDTH)) || 0; + height = parseFloat(textureXML.getAttribute(ccs.CONST_A_HEIGHT)) || 0; - textureData.width = json[ccs.CONST_A_WIDTH]; - textureData.height = json[ccs.CONST_A_HEIGHT]; - - var anchorPointX = textureData.pivotX / textureData.width; - var anchorPointY = (textureData.height - textureData.pivotY) / textureData.height; + var anchorPointX = px / width; + var anchorPointY = (height - py) / height; textureData.pivotX = anchorPointX; textureData.pivotY = anchorPointY; - var contour = json[ccs.CONST_CONTOUR_DATA]; - if(contour){ - for (var i=0; i < contour.length; i++) - { - var dic = contour[i]; - var contourData = this.decodeContour(dic); - textureData.contourDataList.push(contourData); - } + var contoursXML = textureXML.querySelectorAll(ccs.CONST_SUB_TEXTURE + " > " + ccs.CONST_CONTOUR); + for (var i = 0; i < contoursXML.length; i++) { + this.decodeContour(contoursXML[i], dataInfo); } - return textureData; }, decodeContour: function (contourXML, dataInfo) { var contourData = new ccs.ContourData(); - var vertexDatasXML = contourXML['vertex']; + var vertexDatasXML = contourXML.querySelectorAll(ccs.CONST_CONTOUR + " > " + ccs.CONST_CONTOUR_VERTEX); var vertexDataXML; for (var i = 0; i < vertexDatasXML.length; i++) { vertexDataXML = vertexDatasXML[i]; var vertex = cc.p(0, 0); - vertex.x = parseFloat(vertexDataXML[ccs.CONST_A_X]) || 0; - vertex.y = parseFloat(vertexDataXML[ccs.CONST_A_Y]) || 0; + vertex.x = parseFloat(vertexDataXML.getAttribute(ccs.CONST_A_X)) || 0; + vertex.y = parseFloat(vertexDataXML.getAttribute(ccs.CONST_A_Y)) || 0; //vertex.y = - vertex.y;//todo contourData.vertexList.push(vertex); } @@ -728,72 +665,50 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, - addDataFromJson: function (filePath, dataInfo) { + addDataFromJson: function (filePath, dataInfo, isLoadSpriteFrame) { var fileContent = cc.loader.getRes(filePath); - this.addDataFromJsonCache(fileContent, dataInfo, filePath); + this.addDataFromJsonCache(fileContent, dataInfo, isLoadSpriteFrame); }, - addDataFromJsonCache: function (json, dataInfo, filePath) { - // Decode armatures - var length = json[ccs.CONST_ARMATURE_DATA].length; - for(var i=0; i Date: Thu, 26 Jun 2014 18:21:54 +0800 Subject: [PATCH 0183/1564] Closed #5613: fixed a bug of cc.Audio that it throws an error when audio's duration is infinity --- cocos2d/audio/CCAudio.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index afeb7c9cee..da13a78a46 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -336,7 +336,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ audio.stop(); } else { audio.pause(); - audio.duration && (audio.currentTime = audio.duration); + audio.currentTime = 0; } } this._musicPlayState = 2; @@ -368,8 +368,10 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (audio.stop) {//cc.WebAudio audio.stop(); } else { - audio.pause(); - audio.duration && (audio.currentTime = audio.duration); + if(audio.duration && audio.duration != Infinity) + audio.currentTime = audio.duration; + else + audio.pause(); } return true; } @@ -816,7 +818,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { var self = this, audio = self._effectCache4Single[url], locLoader = cc.loader, waitings = self._waitingEffIds, pauseds = self._pausedEffIds, effects = self._effects; if (audio) { - audio.duration && (audio.currentTime = 0);//reset current time + audio.currentTime = 0; //reset current time } else { audio = self._getAudioByUrl(url); if (!audio) return null; @@ -848,7 +850,8 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { return; for (var key in sglCache) { var eff = sglCache[key]; - eff.duration && (eff.currentTime = eff.duration); + if(eff.duration && eff.duration != Infinity) + eff.currentTime = eff.duration; } waitings.length = 0; pauseds.length = 0; @@ -857,7 +860,8 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { for (var i = 0, li = list.length; i < li; i++) { var eff = list[i]; eff.loop = false; - eff.duration && (eff.currentTime = eff.duration); + if(eff.duration && eff.duration != Infinity) + eff.currentTime = eff.duration; } } if (currEffect) self._stopAudio(currEffect); @@ -874,7 +878,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { else self._resumeAudio(currEffect); } else if (self._needToResumeMusic) { var currMusic = self._currMusic; - if (currMusic.duration) {//calculate current time + if (currMusic.duration && currMusic.duration != Infinity) {//calculate current time var temp = currMusic.currentTime + self._expendTime4Music; temp = temp - currMusic.duration * ((temp / currMusic.duration) | 0); currMusic.currentTime = temp; @@ -902,7 +906,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { if (eff._isToPlay || eff.loop || (eff.duration && eff.currentTime + expendTime < eff.duration)) { self._currEffectId = effId; self._currEffect = eff; - if (!eff._isToPlay && eff.duration) { + if (!eff._isToPlay && eff.duration && eff.duration != Infinity) { var temp = eff.currentTime + expendTime; temp = temp - eff.duration * ((temp / eff.duration) | 0); eff.currentTime = temp; @@ -910,7 +914,8 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { eff._isToPlay = false; return eff; } else { - eff.duration && (eff.currentTime = eff.duration); + if(eff.duration && eff.duration != Infinity) + eff.currentTime = eff.duration; } } self._currEffectId = null; @@ -1054,7 +1059,7 @@ cc._audioLoader._supportedAudioTypes = function () { cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader); // Initialize Audio engine singleton -cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngineForSingle() : new cc.AudioEngine(); +cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngine() : new cc.AudioEngine(); cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function () { cc.audioEngine._pausePlaying(); }); From e48056b6018ece781e06055c692900ab05a50217 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 26 Jun 2014 18:24:16 +0800 Subject: [PATCH 0184/1564] Fixed a bug of cc.Audio that it throws an error when audio's duration is infinity --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index da13a78a46..e7cf1d91ae 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -1059,7 +1059,7 @@ cc._audioLoader._supportedAudioTypes = function () { cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader); // Initialize Audio engine singleton -cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngine() : new cc.AudioEngine(); +cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngineForSingle() : new cc.AudioEngine(); cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function () { cc.audioEngine._pausePlaying(); }); From dabc6eb712d420bfa466c03547a421eb9c794bdb Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 27 Jun 2014 09:36:34 +0800 Subject: [PATCH 0185/1564] Issue #5600: Fixed two bugs in Cocostudio GUI: UIChekBox, UITextField --- cocos2d/core/base-nodes/CCNode.js | 2 ++ extensions/ccui/layouts/UILayout.js | 2 +- extensions/ccui/uiwidgets/UICheckBox.js | 4 +++- extensions/ccui/uiwidgets/UITextField.js | 19 ++++++------------- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 8962188412..ccbfe2bd68 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1720,6 +1720,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} */ convertToWorldSpace: function (nodePoint) { + nodePoint = nodePoint || cc.p(0,0); return cc.PointApplyAffineTransform(nodePoint, this.nodeToWorldTransform()); }, @@ -1740,6 +1741,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} */ convertToWorldSpaceAR: function (nodePoint) { + nodePoint = nodePoint || cc.p(0,0); var pt = cc.pAdd(nodePoint, this._anchorPointInPoints); return this.convertToWorldSpace(pt); }, diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 54a64885dd..aa01142169 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -102,7 +102,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.ignoreContentAdaptWithSize(false); this.setSize(cc.size(0, 0)); this.setAnchorPoint(0, 0); -// this.initStencil(); + this.initStencil(); return true; } return false; diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 2b91436a72..07ee1078b7 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -63,8 +63,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, init: function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { if (ccui.Widget.prototype.init.call(this)) { + this._isSelected = true; this.setTouchEnabled(true); this.setSelectedState(false); + this.loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType); return true; } return false; @@ -532,7 +534,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, createCloneInstance: function () { - return ccui.CheckBox.create(); + return ccui.CheckBox.create(); //TODO should it do anything? }, copySpecialProperties: function (uiCheckBox) { diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index d4b70a21c7..14b40377b4 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -96,7 +96,7 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu return false; }, - insertText: function (text, len) { + insertText: function (text, len) { //todo need to delete var str_text = text; var locString = cc.TextFieldTTF.prototype.getString.call(this); var str_len = locString.length; @@ -143,13 +143,13 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu if (text !== "\n") { - if (this._maxLengthEnabled) + if (this.maxLengthEnabled) { var text_count = this._calcCharCount(this.getString()); if (text_count >= this._maxLength) { // password - if (this._passwordEnabled) + if (this.passwordEnabled) { this.setPasswordText(this.getString()); } @@ -161,7 +161,7 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu (cc.sys.os == cc.sys.OS_OSX) || (cc.sys.os == cc.sys.OS_WINDOWS) ) - var input_count = _calcCharCount(text); + var input_count = this._calcCharCount(text); var total = text_count + input_count; if (total > this._maxLength) @@ -223,20 +223,13 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu len = end; } } - } } - ccui.TextFieldTTF.insertText(input_text, len); + cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); // password - if (this._passwordEnabled) - { - if (ccui.TextFieldTTF.prototype.getCharCount.call(this) > 0) - { + if (this.passwordEnabled && (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0)) this.setPasswordText(this.getString()); - } - } - }, deleteBackward: function () { From 96222b222b1fb0aaed9085da4666898c9f258f82 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 27 Jun 2014 11:12:56 +0800 Subject: [PATCH 0186/1564] Issue #5600: fix a bug that Slider --- cocos2d/labels/CCLabelAtlas.js | 2 +- .../reader/widgetreader/SliderReader/SliderReader.js | 10 ++++++---- .../widgetreader/TextFieldReader/TextFieldReader.js | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 37147d8f18..0a9899b37e 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -194,7 +194,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ updateAtlasValues: null, _updateAtlasValuesForCanvas: function () { - var locString = this._string; + var locString = this._string || ""; var n = locString.length; var texture = this.texture; var locItemWidth = this._itemWidth , locItemHeight = this._itemHeight; //needn't multiply cc.contentScaleFactor(), because sprite's draw will do this diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index edf9967ad8..1f00049967 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -64,7 +64,7 @@ ccs.SliderReader = { slider.setSize(cc.size(barLength, slider.getContentSize().height)); } }else{ - var imageFileNameDic = options["barFileNameDic"]; + var imageFileNameDic = options["barFileNameData"]; var imageFileType = imageFileNameDic["resourceType"]; switch(imageFileType){ case 0: @@ -72,6 +72,7 @@ ccs.SliderReader = { var imageFileName = imageFileNameDic["path"]; var imageFileName_tp = ( imageFileName && imageFileName !== "" ) ? tp_b + imageFileName : + null; slider.loadBarTexture(imageFileName_tp); break; case 1: @@ -83,7 +84,8 @@ ccs.SliderReader = { } } var normalDic = options["ballNormalData"]; - switch(normalDic){ + var normalType = normalDic["resourceType"]; + switch(normalType){ case 0: var tp_n = jsonPath; var normalFileName = normalDic["path"]; @@ -101,8 +103,8 @@ ccs.SliderReader = { } var pressedDic = options["ballPressedData"]; - var pressedTyep = pressedDic["resourceType"]; - switch(pressedTyep){ + var pressedType = pressedDic["resourceType"]; + switch(pressedType){ case 0: var tp_p = jsonPath; var pressedFileName = pressedDic["path"]; diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index 612b5cfd51..c794f1f892 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -38,7 +38,7 @@ ccs.TextFieldReader = { if(ph){ textField.setPlaceHolder(ph); } - textField.setText(options["text"]); + textField.setString(options["text"]); var fs = options["fontSize1"]; if(fs){ textField.setFontSize(fs); From 1cbc45c026dbc0e429d963fb67df54174eb4d93a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 27 Jun 2014 13:35:53 +0800 Subject: [PATCH 0187/1564] Issue #5600: ScrollView --- extensions/cocostudio/reader/GUIReader.js | 12 ++++++------ .../ScrollViewReader/ScrollViewReader.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 660e35281c..8186c84d2c 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -926,22 +926,22 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ { render = ccs.TextFieldReader; } - else if (widget instanceof ccui.Layout) + else if (widget instanceof ccui.ListView) { - render = ccs.LayoutReader; + render = ccs.ListViewReader; } else if (widget instanceof ccui.ScrollView) { render = ccs.ScrollViewReader; } - else if (widget instanceof ccui.ListView) - { - render = ccs.ListViewReader; - } else if (widget instanceof ccui.PageView) { render = ccs.PageViewReader; } + else if (widget instanceof ccui.Layout) + { + render = ccs.LayoutReader; + } else if (widget instanceof ccui.Widget) { render = ccs.WidgetReader; diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index 766ff70f25..2bd4c02c16 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -46,6 +46,6 @@ ccs.ScrollViewReader = { scrollView.setBounceEnabled(options["bounceEnable"]); - ccs.LayoutReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file From c25fe9563536a86e95a268a54fb587d78784b9fb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 27 Jun 2014 17:11:36 +0800 Subject: [PATCH 0188/1564] Issue #5600: update cocostudio 1. UIHBox 2. UIRelativeBox 3. UIVBox --- extensions/ccui/base-classes/UIWidget.js | 9 ++++ extensions/ccui/layouts/UIHBox.js | 59 ++++++++++++++++++++++++ extensions/ccui/layouts/UIRelativeBox.js | 59 ++++++++++++++++++++++++ extensions/ccui/layouts/UIVBox.js | 59 ++++++++++++++++++++++++ moduleConfig.json | 3 ++ 5 files changed, 189 insertions(+) create mode 100644 extensions/ccui/layouts/UIHBox.js create mode 100644 extensions/ccui/layouts/UIRelativeBox.js create mode 100644 extensions/ccui/layouts/UIVBox.js diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 17fd5e39ea..79f7f5adc3 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -86,6 +86,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _flippedX: false, _flippedY: false, _opacity: 255, + _focusEnabled: false, ctor: function () { cc.Node.prototype.ctor.call(this); this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; @@ -221,6 +222,14 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ return null; }, + setFocusEnabled: function(enable){ + this._focusEnabled = enable; + }, + + isFocusEnabled: function(){ + return this._focusEnabled; + }, + /** * remove child * @param {ccui.Widget} widget diff --git a/extensions/ccui/layouts/UIHBox.js b/extensions/ccui/layouts/UIHBox.js new file mode 100644 index 0000000000..394e9a8e97 --- /dev/null +++ b/extensions/ccui/layouts/UIHBox.js @@ -0,0 +1,59 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * Base class for ccui.HBox + * @class + * @extends ccui.Layout + */ +ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ + + init: function(){ + if(ccui.Layout.prototype.init.call(this)){ + this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL); + return true; + } + return false; + }, + + initWithSize: function(size){ + if(this.init()){ + this.setSize(size); + return true; + } + return false; + } +}); + +ccui.HBox.create = function(size){ + var widget = new ccui.HBox(); + if(size){ + if(widget.initWithSize()){ + return widget; + } + return null; + } + return widget; +}; \ No newline at end of file diff --git a/extensions/ccui/layouts/UIRelativeBox.js b/extensions/ccui/layouts/UIRelativeBox.js new file mode 100644 index 0000000000..b662ccacc2 --- /dev/null +++ b/extensions/ccui/layouts/UIRelativeBox.js @@ -0,0 +1,59 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * Base class for ccui.RelativeBox + * @class + * @extends ccui.Layout + */ +ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ + + init: function(){ + if(ccui.Layout.prototype.init.call(this)){ + this.setLayoutType(ccui.Layout.RELATIVE); + return true; + } + return false; + }, + + initWithSize: function(size){ + if(this.init()){ + this.setSize(size); + return true; + } + return false; + } +}); + +ccui.RelativeBox.create = function(size){ + var widget = new ccui.RelativeBox(); + if(size){ + if(widget.initWithSize()){ + return widget; + } + return null; + } + return widget; +}; \ No newline at end of file diff --git a/extensions/ccui/layouts/UIVBox.js b/extensions/ccui/layouts/UIVBox.js new file mode 100644 index 0000000000..01f34af4e2 --- /dev/null +++ b/extensions/ccui/layouts/UIVBox.js @@ -0,0 +1,59 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * Base class for ccui.RelativeBox + * @class + * @extends ccui.Layout + */ +ccui.VBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ + + init: function(){ + if(ccui.Layout.prototype.init.call(this)){ + this.setLayoutType(ccui.Layout.VERTICAL); + return true; + } + return false; + }, + + initWithSize: function(size){ + if(this.init()){ + this.setSize(size); + return true; + } + return false; + } +}); + +ccui.VBox.create = function(size){ + var widget = new ccui.VBox(); + if(size){ + if(widget.initWithSize()){ + return widget; + } + return null; + } + return widget; +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index cefbd4c75c..9b05e274dd 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -262,6 +262,9 @@ "extensions/ccui/layouts/UILayout.js", "extensions/ccui/layouts/UILayoutParameter.js", "extensions/ccui/layouts/UILayoutDefine.js", + "extensions/ccui/layouts/UIHBox.js", + "extensions/ccui/layouts/UIRelativeBox.js", + "extensions/ccui/layouts/UIVBox.js", "extensions/ccui/system/UIHelper.js", "extensions/ccui/uiwidgets/UIButton.js", "extensions/ccui/uiwidgets/UICheckBox.js", From 79e464824a544bb76bc3cb87936a58f6563e0a06 Mon Sep 17 00:00:00 2001 From: aslan Date: Fri, 27 Jun 2014 21:51:54 +0800 Subject: [PATCH 0189/1564] fix cc.Spawn.create error --- cocos2d/actions/CCActionInterval.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 97c2d23e67..e27ca195c4 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -894,7 +894,7 @@ cc.Spawn.create = function (/*Multiple Arguments*/tempArray) { var prev = paramArray[0]; for (var i = 1; i < paramArray.length; i++) { if (paramArray[i] != null) - prev = this._actionOneTwo(prev, paramArray[i]); + prev = cc.Spawn._actionOneTwo(prev, paramArray[i]); } return prev; }; From 74f64f32a93920510cd07c54560a3da26c27ce33 Mon Sep 17 00:00:00 2001 From: aslan Date: Fri, 27 Jun 2014 22:05:20 +0800 Subject: [PATCH 0190/1564] fix the bug: ccui.LoadingBar.setPercent will crash, when it's render texture is in plist and scale9Enabled is true --- extensions/ccui/uiwidgets/UILoadingBar.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index a190a58800..44565cb3ea 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -249,19 +249,20 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } var res = this._percent / 100.0; - var x = 0, y = 0; - if (this._renderBarTexType == ccui.Widget.PLIST_TEXTURE) { - var barNode = this._barRenderer; - if (barNode) { - var rect = barNode.getTextureRect(); - x = rect.x; - y = rect.y; - } - } if (this._scale9Enabled) this.setScale9Scale(); - else + else { + var x = 0, y = 0; + if (this._renderBarTexType == ccui.Widget.PLIST_TEXTURE) { + var barNode = this._barRenderer; + if (barNode) { + var rect = barNode.getTextureRect(); + x = rect.x; + y = rect.y; + } + } this._barRenderer.setTextureRect(cc.rect(x, y, this._barRendererTextureSize.width * res, this._barRendererTextureSize.height)); + } }, /** From 1db6bbf3460d74f89d9c9df9a84b2d21b99ee232 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Jun 2014 10:24:19 +0800 Subject: [PATCH 0191/1564] Issue #5600: ListView and PageView --- extensions/cocostudio/reader/GUIReader.js | 38 +++++++++++++++---- .../widgetreader/LayoutReader/LayoutReader.js | 4 +- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 8186c84d2c..fcff8bee03 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -958,14 +958,36 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ } this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); } - var childrenCount = data["children"]; - for (var i = 0; i < childrenCount.length; i++) - { - var subData = data["children"][i]; - var child = this.widgetFromJsonDictionary(subData); - if (child) - { - widget.addChild(child); + var childrenItem = data["children"]; + for(var i=0; i Date: Sat, 28 Jun 2014 10:44:13 +0800 Subject: [PATCH 0192/1564] Issue #5600: LayoutRender bug --- .../cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 77136dec14..eb2426ab39 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -66,7 +66,7 @@ ccs.LayoutReader = { var ecb = options["bgEndColorB"]; var bgcv1 = options["vectorX"]; - var bgcv2 = [options, "vectorY"]; + var bgcv2 = options["vectorY"]; panel.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); var co = options["bgColorOpacity"]; From ccaeb0b2adfb1e8aabf8ec30dba12eb82a1a6e34 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Jun 2014 10:49:17 +0800 Subject: [PATCH 0193/1564] Issue #5600: TextAtlas --- .../reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index cbbaa925a4..55056d22f1 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -38,7 +38,7 @@ ccs.LabelAtlasReader = { var labelAtlas = widget; var sv = options["stringValue"]; - var cmf = options["charMapFile"]; + var cmf = options["charMapFileData"] || options["charMapFile"]; var iw = options["itemWidth"]; var ih = options["itemHeight"]; var scm = options["startCharMap"]; From 936b4228c6da59e2a3a760d72c9e8b6a0aafa3a2 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Sat, 28 Jun 2014 11:36:34 +0800 Subject: [PATCH 0194/1564] add CCPool into extensions --- extensions/ccpool/CCPool.js | 124 ++++++++++++++++++++++++++++++++++++ moduleConfig.json | 7 +- 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 extensions/ccpool/CCPool.js diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js new file mode 100644 index 0000000000..68252e931f --- /dev/null +++ b/extensions/ccpool/CCPool.js @@ -0,0 +1,124 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +var CCPool = cc.Class.extend({ + _pool: null, + ctor: function () { + this._pool = {}; + }, + + /** + * Put the obj in pool + * @param obj + */ + putInPool: function (obj) { + if (obj instanceof cc.Node) { + var pid = obj.constructor.prototype.__pid; + if (!pid) { + var desc = { writable: true, enumerable: false, configurable: true }; + desc.value = ClassManager.getNewID(); + Object.defineProperty(obj.constructor.prototype, '__pid', desc); + } + if (!this._pool[pid]) { + this._pool[pid] = []; + } + obj.unuse(); + obj.retain();//use for jsb + this._pool[pid].push(obj); + } + }, + + /** + * Check if this kind of obj has already in pool + * @param objClass + * @returns {boolean} if this kind of obj is already in pool return true,else return false; + */ + hasObj: function (objClass) { + var pid = objClass.prototype.__pid; + var list = this._pool[pid]; + if (!list || list.length == 0) { + return false; + } + return true; + }, + + /** + * Remove the obj if you want to delete it; + * @param obj + */ + removeObj: function (obj) { + var pid = obj.constructor.prototype.__pid; + if (pid) { + var list = this._pool[pid]; + if (list) { + for (var i = 0; i < list.length; i++) { + if (obj === list[i]) { + obj.release()//use for jsb + list.splice(i, 1); + } + } + } + } + }, + + /** + * Get the obj from pool + * @param args + * @returns {*} call the reuse function an return the obj + */ + getFromPool: function (objClass/*,args*/) { + if (this.hasObj(objClass)) { + var pid = objClass.prototype.__pid; + var list = this._pool[pid]; + var args = Array.prototype.slice.call(arguments); + args.shift(); + var obj = list.pop(); + obj.reuse.apply(obj, args); + return obj; + } + }, + + /** + * remove all objs in pool and reset the pool + */ + drainAllPools: function () { + for (var i in this._pool) { + for (var j = 0; j < this._pool[i].length; j++) { + var obj = this._pool[i][j]; + obj.release() + } + } + this._pool = {}; + } +}); +CCPool._instance = null; +CCPool._getInstance = function () { + if (!CCPool._instance) { + CCPool._instance = new CCPool(); + } + return CCPool._instance; +} +cc.pool = CCPool._getInstance(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index fc2272c02b..9cafa49a72 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -255,6 +255,11 @@ "extensions/editbox/CCdomNode.js", "extensions/editbox/CCEditBox.js" ], + "ccpool" : [ + "core", "gui", + + "extensions/ccpool/CCPool.js" + ], "ccui" : [ "core", "gui", "actions", "labels", "text-input","clipping-nodes", "extensions/ccui/system/CocosGUI.js", @@ -371,7 +376,7 @@ "extensions/spine/CCSkeleton.js", "extensions/spine/CCSkeletonAnimation.js" ], - "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "pluginx", "spine"], + "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "pluginx", "spine","ccpool"], "box2d" : [ "core", "physics", From 1291ea5cf1f6a7827c89a8ec919c094d4e707b00 Mon Sep 17 00:00:00 2001 From: AaronRZH <287628769@qq.com> Date: Sat, 28 Jun 2014 11:48:47 +0800 Subject: [PATCH 0195/1564] fix bug on create a sequence objcet or a spawn object using new method --- cocos2d/actions/CCActionInterval.js | 42 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 97c2d23e67..60aec63aaa 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -326,17 +326,16 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ if ((last >= 0) && (paramArray[last] == null)) cc.log("parameters should not be ending with null in Javascript"); - if (last >= 0) { - var prev = paramArray[0], action1; - for (var i = 1; i < last; i++) { - if (paramArray[i]) { - action1 = prev; - prev = cc.Sequence.create(); - prev.initWithTwoActions(action1, paramArray[i]); - } - } - this.initWithTwoActions(prev, paramArray[last]); - } + if (last >= 0) { + var prev = paramArray[0], action1; + for (var i = 1; i < last; i++) { + if (paramArray[i]) { + action1 = prev; + prev = cc.Sequence._actionOneTwo(action1, paramArray[i]); + } + } + this.initWithTwoActions(prev, paramArray[last]); + } }, /** initializes the action
@@ -786,17 +785,16 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ if ((last >= 0) && (paramArray[last] == null)) cc.log("parameters should not be ending with null in Javascript"); - if (last >= 0) { - var prev = paramArray[0], action1; - for (var i = 1; i < last; i++) { - if (paramArray[i]) { - action1 = prev; - prev = cc.Spwan.create(); - prev.initWithTwoActions(action1, paramArray[i]); - } - } - this.initWithTwoActions(prev, paramArray[last]); - } + if (last >= 0) { + var prev = paramArray[0], action1; + for (var i = 1; i < last; i++) { + if (paramArray[i]) { + action1 = prev; + prev = cc.Spawn._actionOneTwo(action1, paramArray[i]); + } + } + this.initWithTwoActions(prev, paramArray[last]); + } }, /** initializes the Spawn action with the 2 actions to spawn From 211b086a7e4cb78972f0b831324daf55f632ce54 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 28 Jun 2014 14:19:24 +0800 Subject: [PATCH 0196/1564] Issue #5600: Add cc.ProtectedNode to ccui and sync ccui.UIWidget --- cocos2d/core/sprites/CCBakeSprite.js | 2 - extensions/ccb-reader/CCBReader.js | 2 + .../ccui/base-classes/CCProtectedNode.js | 429 ++++++++++++++++++ extensions/ccui/base-classes/UIWidget.js | 377 +++++++++++---- extensions/ccui/layouts/UILayout.js | 7 +- extensions/ccui/uiwidgets/UICheckBox.js | 4 +- extensions/ccui/uiwidgets/UISlider.js | 6 +- .../uiwidgets/scroll-widget/UIPageView.js | 6 +- .../uiwidgets/scroll-widget/UIScrollView.js | 6 +- 9 files changed, 733 insertions(+), 106 deletions(-) create mode 100644 extensions/ccui/base-classes/CCProtectedNode.js diff --git a/cocos2d/core/sprites/CCBakeSprite.js b/cocos2d/core/sprites/CCBakeSprite.js index 3e0d515721..f3a87e0fe7 100644 --- a/cocos2d/core/sprites/CCBakeSprite.js +++ b/cocos2d/core/sprites/CCBakeSprite.js @@ -1,6 +1,4 @@ /**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index 7da5f1bb1a..8cc51607fa 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -935,6 +935,8 @@ cc.BuilderReader = cc.Class.extend({ if (this._currentBit >= 8) { this._currentBit = 0; this._currentByte++; + if(this._currentByte > this._data.length) + throw "out of the data bound"; } return bit; diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js new file mode 100644 index 0000000000..a2b5afda8a --- /dev/null +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -0,0 +1,429 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Node + _protectedChildren: null, + _reorderProtectedChildDirty: false, + + _insertProtectedChild: function(child, z){ + this._reorderProtectedChildDirty = true; + this._protectedChildren.push(child); + child._setLocalZOrder(z); + }, + + ctor: function(){ + this._protectedChildren = []; + }, + + /** + * Adds a child to the container with z order and tag + * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. + * @param {cc.Node} child A child node + * @param {Number} [localZOrder] Z order for drawing priority. Please refer to `setLocalZOrder(int)` + * @param {Number} [tag] An integer to identify the node easily. Please refer to `setTag(int)` + */ + addProtectedChild: function(child, localZOrder, tag){ + cc.assert(child != null, "child must be non-nil"); + cc.assert(child.parent, "child already added. It can't be added again"); + + localZOrder = localZOrder || child.getLocalZOrder(); + if(tag) + child.setTag(tag); + + this._insertProtectedChild(child, localZOrder); + child.setParent(this); + child.setOrderOfArrival(cc.s_globalOrderOfArrival); + + //TODO USE PHYSICS + + if(this._running){ + child.onEnter(); + // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter + if(this._isTransitionFinished) + child.onEnterTransitionDidFinish(); + } + if(this._cascadeColorEnabled) + this.updateDisplayedColor(); + if (this._cascadeOpacityEnabled) + this.updateDisplayedOpacity(); + }, + + /** + * Gets a child from the container with its tag + * @param {Number} tag An identifier to find the child node. + * @return {cc.Node} a Node object whose tag equals to the input parameter + */ + getProtectedChildByTag: function(tag){ + cc.assert(tag != cc.NODE_TAG_INVALID, "Invalid tag"); + var locChildren = this._protectedChildren; + for(var i = 0, len = locChildren.length; i < len; i++) + if(locChildren.getTag() == tag) + return locChildren[i]; + return null; + }, + + /** + * Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. + * @param {cc.Node} child The child node which will be removed. + * @param {Boolean} [cleanup=true] true if all running actions and callbacks on the child node will be cleanup, false otherwise. + */ + removeProtectedChild: function(child, cleanup){ + if(cleanup == null) + cleanup = true; + var locChildren = this._protectedChildren; + if(locChildren.length === 0) + return; + var idx = locChildren.indexOf(child); + if(idx > -1){ + if(this._running){ + child.onExitTransitionDidStart(); + child.onExit(); + } + //TODO USE PHYSICS + + // If you don't do cleanup, the child's actions will not get removed and the + // its scheduledSelectors_ dict will not get released! + if (cleanup) + child.cleanup(); + + // set parent nil at the end + child.setParent(null); + locChildren.splice(idx, 1); + } + }, + + /** + * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter + * @param {Number} tag + * @param {Boolean} [cleanup=true] + */ + removeProtectedChildByTag: function(tag, cleanup){ + cc.assert( tag != cc.NODE_TAG_INVALID, "Invalid tag"); + + if(cleanup == null) + cleanup = true; + + var child = this.getProtectedChildByTag(tag); + + if (child == null) + cc.log("cocos2d: removeChildByTag(tag = %d): child not found!", tag); + else + this.removeProtectedChild(child, cleanup); + }, + + /** + * Removes all children from the container with a cleanup. + * @see `removeAllChildrenWithCleanup(bool)` + */ + removeAllProtectedChildren: function(){ + this.removeAllProtectedChildrenWithCleanup(true); + }, + + /** + * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. + * @param {Boolean} [cleanup=true] true if all running actions on all children nodes should be cleanup, false otherwise. + */ + removeAllProtectedChildrenWithCleanup: function(cleanup){ + if(cleanup == null) + cleanup = true; + var locChildren = this._protectedChildren; + // not using detachChild improves speed here + for (var i = 0, len = locChildren.length; i< len; i++) { + var child = locChildren[i]; + // IMPORTANT: + // -1st do onExit + // -2nd cleanup + if(this._running){ + child.onExitTransitionDidStart(); + child.onExit(); + } + + //TODO USE PHYSICS + + if (cleanup) + child.cleanup(); + // set parent nil at the end + child.setParent(null); + } + locChildren.length = 0; + }, + + /** + * Reorders a child according to a new z value. + * @param {cc.Node} child An already added child node. It MUST be already added. + * @param {Number} localZOrder Z order for drawing priority. Please refer to setLocalZOrder(int) + */ + reorderProtectedChild: function(child, localZOrder){ + cc.assert( child != null, "Child must be non-nil"); + this._reorderProtectedChildDirty = true; + child.setOrderOfArrival(cc.s_globalOrderOfArrival++); + child._setLocalZOrder(localZOrder); + }, + + /** + *

+ * Sorts the children array once before drawing, instead of every time when a child is added or reordered.
+ * This approach can improves the performance massively.
+ * @note Don't call this manually unless a child added needs to be removed in the same frame + *

+ */ + sortAllProtectedChildren: function(){ + if (this._reorderProtectedChildDirty) { + var _children = this._children; + + // insertion sort + var len = _children.length, i, j, tmp; + for(i=1; i= 0){ + if(tmp._localZOrder < _children[j]._localZOrder){ + _children[j+1] = _children[j]; + }else if(tmp._localZOrder === _children[j]._localZOrder && tmp.arrivalOrder < _children[j].arrivalOrder){ + _children[j+1] = _children[j]; + }else{ + break; + } + j--; + } + _children[j+1] = tmp; + } + + //don't need to check children recursively, that's done in visit of each child + this._reorderProtectedChildDirty = false; + } + }, + + visit: null, + + _visitForCanvas: function(ctx){ + var _t = this; + // quick return if not visible + if (!_t._visible) + return; + + //visit for canvas + var context = ctx || cc._renderContext, i, j; + var children = _t._children, child; + var locChildren = _t._children, locProtectedChildren = this._protectedChildren; + var childLen = locChildren.length, pLen = locProtectedChildren.length; + context.save(); + _t.transform(context); + + _t.sortAllChildren(); + _t.sortAllProtectedChildren(); + + // draw children zOrder < 0 + for (i = 0; i < childLen; i++) { + child = children[i]; + if (child._localZOrder < 0) + child.visit(context); + else + break; + } + for (j = 0; j < pLen; j++) { + child = locProtectedChildren[j]; + if (child._localZOrder < 0) + child.visit(context); + else + break; + } + + _t.draw(context); + + for (; i < childLen; i++) { + children[i] && children[i].visit(context); + } + for (; j < pLen; j++) { + locProtectedChildren[i] && locProtectedChildren[i].visit(context); + } + + this._cacheDirty = false; + _t.arrivalOrder = 0; + context.restore(); + }, + + _visitForWebGL: function(){ + var _t = this; + // quick return if not visible + if (!_t._visible) + return; + var context = cc._renderContext, i, currentStack = cc.current_stack, j; + + //optimize performance for javascript + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(_t._stackMatrix, currentStack.top); + currentStack.top = _t._stackMatrix; + + var locGrid = _t.grid; + if (locGrid && locGrid._active) + locGrid.beforeDraw(); + + _t.transform(); + + var locChildren = _t._children, locProtectedChildren = this._protectedChildren; + var childLen = locChildren.length, pLen = locProtectedChildren.length; + _t.sortAllChildren(); + _t.sortAllProtectedChildren(); + + // draw children zOrder < 0 + for (i = 0; i < childLen; i++) { + if (locChildren[i] && locChildren[i]._localZOrder < 0) + locChildren[i].visit(); + else + break; + } + for(j = 0; j < pLen; j++){ + if (locProtectedChildren[j] && locProtectedChildren[j]._localZOrder < 0) + locProtectedChildren[j].visit(); + else + break; + } + _t.draw(context); + // draw children zOrder >= 0 + for (; i < childLen; i++) { + if (locChildren[i]) { + locChildren[i].visit(); + } + } + for (; j < pLen; j++) { + if (locProtectedChildren[j]) { + locProtectedChildren[j].visit(); + } + } + + _t.arrivalOrder = 0; + if (locGrid && locGrid._active) + locGrid.afterDraw(_t); + + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); + }, + + cleanup: function(){ + cc.Node.prototype.cleanup.call(this); + var locChildren = this._protectedChildren; + for(var i = 0 , len = locChildren.length; i < len; i++) + locChildren[i].cleanup(); + }, + + onEnter: function(){ + cc.Node.prototype.onEnter.call(this); + var locChildren = this._protectedChildren; + for(var i = 0, len = locChildren.length;i< len;i++) + locChildren.onEnter(); + }, + + /** + *

+ * Event callback that is invoked when the Node enters in the 'stage'.
+ * If the Node enters the 'stage' with a transition, this event is called when the transition finishes.
+ * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish() + *

+ */ + onEnterTransitionDidFinish: function(){ + cc.Node.prototype.onEnterTransitionDidFinish.call(this); + var locChildren = this._protectedChildren; + for(var i = 0, len = locChildren.length;i< len;i++) + locChildren.onEnterTransitionDidFinish(); + }, + + onExit:function(){ + cc.Node.prototype.onExit.call(this); + var locChildren = this._protectedChildren; + for(var i = 0, len = locChildren.length;i< len;i++) + locChildren.onExit(); + }, + + /** + *

+ * Event callback that is called every time the Node leaves the 'stage'.
+ * If the Node leaves the 'stage' with a transition, this callback is called when the transition starts. + *

+ */ + onExitTransitionDidStart: function(){ + cc.Node.prototype.onExitTransitionDidStart.call(this); + var locChildren = this._protectedChildren; + for(var i = 0, len = locChildren.length;i< len;i++) + locChildren.onExitTransitionDidStart(); + }, + + updateDisplayedOpacity: function(parentOpacity){ + this._displayedOpacity = this._realOpacity * parentOpacity/255.0; + this.updateColor(); + + if (this._cascadeOpacityEnabled){ + var i,len, locChildren = this._children, _opacity = this._displayedOpacity; + for(i = 0, len = locChildren.length;i < len; i++) + locChildren[i].updateDisplayedOpacity(_opacity); + locChildren = this._protectedChildren; + for(i = 0, len = locChildren.length;i < len; i++) + locChildren[i].updateDisplayedOpacity(_opacity); + } + }, + + updateDisplayedColor: function(parentColor){ + var displayedColor = this._displayedColor, realColor = this._realColor; + displayedColor.r = realColor.r * parentColor.r/255.0; + displayedColor.g = realColor.g * parentColor.g/255.0; + displayedColor.b = realColor.b * parentColor.b/255.0; + this.updateColor(); + + if (this._cascadeColorEnabled){ + var i, len, locChildren = this._children; + for(i = 0, len = locChildren.length; i < len; i++) + locChildren[i].updateDisplayedColor(displayedColor); + + locChildren = this._protectedChildren; + for(i =0, len = locChildren.length; i < len; i++) + locChildren[i].updateDisplayedColor(displayedColor); + } + }, + + disableCascadeColor: function(){ + var white = cc.color.WHITE; + var i, len, locChildren = this._children; + for(i = 0, len = locChildren.length; i < len; i++) + locChildren[i].updateDisplayedColor(white); + + locChildren = this._protectedChildren; + for(i =0, len = locChildren.length; i < len; i++) + locChildren[i].updateDisplayedColor(white); + } +}); + +if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForCanvas; +}else{ + cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForWebGL; +} + +/** + * create a cc.ProtectedNode object; + */ +cc.ProtectedNode.create = function(){ + return new cc.ProtectedNode(); +}; \ No newline at end of file diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 17fd5e39ea..9df6c8b47b 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -46,9 +46,7 @@ * @property {String} name - The name of the widget * @property {Number} actionTag - The action tag of the widget */ -ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ - - RGBAProtocol: true, +ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ _enabled: true, ///< Highest control of widget _bright: true, ///< is this widget bright _touchEnabled: false, ///< is this widget touch endabled @@ -56,9 +54,10 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _focus: false, ///< is the widget on focus _brightStyle: null, ///< bright style _updateEnabled: false, ///< is "update" method scheduled - _touchStartPos: null, ///< touch began point - _touchMovePos: null, ///< touch moved point - _touchEndPos: null, ///< touch ended point + + _touchBeganPosition: null, ///< touch began point + _touchMovePosition: null, ///< touch moved point + _touchEndPosition: null, ///< touch ended point _touchEventListener: null, _touchEventSelector: null, @@ -69,6 +68,11 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _size: cc.size(0, 0), _customSize: null, _layoutParameterDictionary: null, + _layoutParameterType:0, + + _focused: false, + _focusEnabled: true, + _ignoreSize: false, _widgetChildren: null, _affectByClipping: false, @@ -78,7 +82,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ positionType: null, _positionPercent: null, _reorderWidgetChildDirty: false, - _hitted: false, + _hitted: false, //TODO typo _nodes: null, _touchListener: null, _color: null, @@ -86,12 +90,16 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ _flippedX: false, _flippedY: false, _opacity: 255, + _highlight: false, + + _touchEventCallback: null, + ctor: function () { - cc.Node.prototype.ctor.call(this); + cc.ProtectedNode.prototype.ctor.call(this); this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; - this._touchStartPos = cc.p(0, 0); - this._touchMovePos = cc.p(0, 0); - this._touchEndPos = cc.p(0, 0); + this._touchBeganPosition = cc.p(0, 0); + this._touchMovePosition = cc.p(0, 0); + this._touchEndPosition = cc.p(0, 0); this._widgetType = ccui.Widget.TYPE_WIDGET; this._size = cc.size(0, 0); this._customSize = cc.size(0, 0); @@ -103,7 +111,8 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ this._positionPercent = cc.p(0, 0); this._nodes = []; this._color = cc.color(255, 255, 255, 255); - this.init(); + this._layoutParameterType = ccui.LayoutParameter.NONE; + this.init(); //TODO }, /** @@ -127,6 +136,10 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ cc.Node.prototype.onEnter.call(this); }, + onExit: function(){ + + }, + visit: function (ctx) { if (this._enabled) { cc.Node.prototype.visit.call(this, ctx); @@ -221,6 +234,26 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ return null; }, + _updateContentSizeWithTextureSize: function(size){ + + }, + + _isAncestorsEnabled: function(){ + + }, + + _getAncensterWidget: function(node){ + + }, + + _isAncestorsVisible: function(node){ + + }, + + _cleanupWidget: function(){ + + }, + /** * remove child * @param {ccui.Widget} widget @@ -258,7 +291,11 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, /** - * Set enabled renderer + *

+ * Sets whether the widget is enabled
+ * true if the widget is enabled, widget may be touched , false if the widget is disabled, widget cannot be touched.
+ * The default value is true, a widget is default to enabled + *

* @param {Boolean} enabled */ setEnabled: function (enabled) { @@ -370,7 +407,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Changes the size that is widget's size - * @param {cc.Size} size + * @param {cc.Size} size that is widget's size */ setSize: function (size) { var locW = this._customSize.width = size.width; @@ -423,7 +460,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Changes the percent that is widget's percent size - * @param {cc.Point} percent + * @param {cc.Point} percent that is widget's percent size */ setSizePercent: function (percent) { this._sizePercent.x = percent.x; @@ -448,6 +485,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ this._customSize.height = height; this.onSizeChanged(); }, + _setWidthPercent: function (percent) { this._sizePercent.x = percent; var width = this._customSize.width; @@ -473,8 +511,9 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * update size and position + * @param {cc.Size} [parentSize] parent size */ - updateSizeAndPosition: function () { + updateSizeAndPosition: function (parentSize) { switch (this._sizeType) { case ccui.Widget.SIZE_ABSOLUTE: var locSize; @@ -565,7 +604,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /**TEXTURE_RES_TYPE * Changes the size type of widget. - * @param {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} type + * @param {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} type that is widget's size type */ setSizeType: function (type) { this._sizeType = type; @@ -573,7 +612,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Gets the size type of widget. - * @returns {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} + * @returns {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} that is widget's size type */ getSizeType: function () { return this._sizeType; @@ -581,7 +620,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Ignore the widget size - * @param {Boolean} ignore + * @param {Boolean} ignore true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ ignoreContentAdaptWithSize: function (ignore) { this._ignoreSize = ignore; @@ -599,7 +638,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Gets the widget if is ignore it's size. - * @returns {boolean} + * @returns {boolean} true that widget will ignore it's size, use texture size, false otherwise. */ isIgnoreContentAdaptWithSize: function () { return this._ignoreSize; @@ -610,15 +649,19 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ * @returns {cc.Size} */ getSize: function () { - return this._size; + return cc.size(this._size); }, /** - * Get custom size + * Get custom size of widget * @returns {cc.Size} */ getCustomSize: function () { - return this._customSize + return cc.size(this._customSize); + }, + + getLayoutSize: function(){ + return cc.size(this._size); }, /** @@ -637,7 +680,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Gets world position of widget. - * @returns {cc.Point} + * @returns {cc.Point} world position of widget. */ getWorldPosition: function () { return this.convertToWorldSpace(cc.p(0, 0)); @@ -651,6 +694,13 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ return this; }, + /** + * Gets the content size of widget. Content size is widget's texture size. + */ + getVirtualRendererSize:function(){ + + }, + /** * call back function called when size changed. */ @@ -676,13 +726,13 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, /** - * Sets whether the widget is touch enabled - * @param enable + * Sets whether the widget is touch enabled. The default value is false, a widget is default to touch disabled + * @param {Boolean} enable true if the widget is touch enabled, false if the widget is touch disabled. */ setTouchEnabled: function (enable) { - if (this._touchEnabled === enable) { + if (this._touchEnabled === enable) return; - } + this._touchEnabled = enable; if (this._touchEnabled) { this._touchListener = cc.EventListener.create({ @@ -700,12 +750,28 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * To set the bright style of widget. - * @returns {boolean} + * @returns {boolean} true if the widget is touch enabled, false if the widget is touch disabled. */ isTouchEnabled: function () { return this._touchEnabled; }, + /** + * Determines if the widget is highlighted + * @returns {boolean} true if the widget is highlighted, false if the widget is not highlighted . + */ + isHighlighted: function(){ + return true; + }, + + /** + * Sets whether the widget is highlighted. The default value is false, a widget is default to not highlighted + * @param highlight true if the widget is highlighted, false if the widget is not highlighted. + */ + setHighlighted:function(highlight){ + + }, + /** * Schedules the "update" method. * @param enable @@ -733,7 +799,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Determines if the widget is on focused - * @returns {boolean} + * @returns {boolean} whether the widget is focused or not */ isFocused: function () { return this._focus; @@ -742,13 +808,13 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Sets whether the widget is on focused * The default value is false, a widget is default to not on focused - * @param {boolean} fucos + * @param {boolean} focus pass true to let the widget get focus or pass false to let the widget lose focus */ - setFocused: function (fucos) { - if (fucos == this._focus) { + setFocused: function (focus) { + if (focus == this._focus) { return; } - this._focus = fucos; + this._focus = focus; if (this._bright) { if (this._focus) { this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT); @@ -762,20 +828,115 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ } }, - setBright: function (bright, containChild) { + /** + * returns whether the widget could accept focus. + * @returns {boolean} true represent the widget could accept focus, false represent the widget couldn't accept focus + */ + isFocusEnabled: function(){ + return true; + }, + + /** + * sets whether the widget could accept focus. + * @param {Boolean} enable true represent the widget could accept focus, false represent the widget couldn't accept focus + */ + setFocusEnabled: function(enable){ + + }, + + /** + *

+ * When a widget is in a layout, you could call this method to get the next focused widget within a specified direction.
+ * If the widget is not in a layout, it will return itself + *

+ * @param direction the direction to look for the next focused widget in a layout + * @param current the current focused widget + * @return the next focused widget in a layout + */ + findNextFocusedWidget: function( direction, current){ + + }, + + /** + * when a widget calls this method, it will get focus immediately. + */ + requestFocus: function(){ + + }, + + /** + * no matter what widget object you call this method on , it will return you the exact one focused widget + */ + getCurrentFocusedWidget: function(){ + + }, + + /** + * call this method with parameter true to enable the Android Dpad focus navigation feature + * @param {Boolean} enable set true to enable dpad focus navigation, otherwise disable dpad focus navigation + */ + enableDpadNavigation: function(enable){ + + }, + + /** + *

+ * When a widget lose/get focus, this method will be called. Be Caution when you provide your own version,
+ * you must call widget->setFocused(true/false) to change the focus state of the current focused widget; + *

+ */ + onFocusChanged: null, + + /** + * use this function to manually specify the next focused widget regards to each direction + */ + onNextFocusedWidget: null, + + /** + * Sends the touch event to widget's parent + * @param {Number} eventType + * @param {ccui.Widget} sender + * @param {cc.Touch} touch + */ + interceptTouchEvent: function(eventType, sender, touch){ + + }, + + /** + * This method is called when a focus change event happens + * @param {ccui.Widget} widgetLostFocus + * @param {ccui.Widget} widgetGetFocus + */ + onFocusChange: function(widgetLostFocus, widgetGetFocus){ + + }, + + /** + * Dispatch a EventFocus through a EventDispatcher + * @param {ccui.Widget} widgetLostFocus + * @param {ccui.Widget} widgetGetFocus + */ + dispatchFocusEvent: function(widgetLostFocus, widgetGetFocus){ + + }, + + /** + * Sets whether the widget is bright. The default value is true, a widget is default to bright + * @param {Boolean} bright true if the widget is bright, false if the widget is dark. + */ + setBright: function (bright) { this._bright = bright; if (this._bright) { this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL); - } - else { + } else { this.onPressStateChangedToDisabled(); } }, /** * To set the bright style of widget. - * @param {ccui.Widget.BRIGHT_STYLE_NONE|ccui.Widget.BRIGHT_STYLE_NORMAL|ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT} style + * @param {ccui.Widget.BRIGHT_STYLE_NONE|ccui.Widget.BRIGHT_STYLE_NORMAL|ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT} style BRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state. */ setBrightStyle: function (style) { if (this._brightStyle == style) { @@ -799,35 +960,31 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ * call back function called widget's state changed to normal. */ onPressStateChangedToNormal: function () { - }, /** * call back function called widget's state changed to selected. */ onPressStateChangedToPressed: function () { - }, /** * call back function called widget's state changed to dark. */ onPressStateChangedToDisabled: function () { - }, /** * A call back function when widget lost of focus. */ didNotSelectSelf: function () { - }, 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); + this._touchBeganPosition.x = touchPoint.x; + this._touchBeganPosition.y = touchPoint.y; + this._hitted = this.isEnabled() && this.isTouchEnabled() && this.hitTest(touchPoint) && this.isClippingParentContainsPoint(touchPoint); if (!this._hitted) { return false; } @@ -842,8 +999,8 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ onTouchMoved: function (touch, event) { var touchPoint = touch.getLocation(); - this._touchMovePos.x = touchPoint.x; - this._touchMovePos.y = touchPoint.y; + this._touchMovePosition.x = touchPoint.x; + this._touchMovePosition.y = touchPoint.y; this.setFocused(this.hitTest(touchPoint)); var widgetParent = this.getWidgetParent(); if (widgetParent) { @@ -855,8 +1012,8 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ onTouchEnded: function (touch, event) { var touchPoint = touch.getLocation(); - this._touchEndPos.x = touchPoint.x; - this._touchEndPos.y = touchPoint.y; + this._touchEndPosition.x = touchPoint.x; + this._touchEndPosition.y = touchPoint.y; var focus = this._focus; this.setFocused(false); var widgetParent = this.getWidgetParent(); @@ -892,25 +1049,22 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ pushDownEvent: function () { if (this._touchEventListener && this._touchEventSelector) { - if (this._touchEventSelector) { + if (this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN); - } } }, moveEvent: function () { if (this._touchEventListener && this._touchEventSelector) { - if (this._touchEventSelector) { + if (this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_MOVED); - } } }, releaseUpEvent: function () { if (this._touchEventListener && this._touchEventSelector) { - if (this._touchEventSelector) { + if (this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED); - } } }, @@ -937,23 +1091,15 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Checks a point if is in widget's space * @param {cc.Point} pt - * @returns {boolean} + * @returns {boolean} true if the point is in widget's space, flase otherwise. */ hitTest: function (pt) { var nsp = this.convertToNodeSpace(pt); var bb = cc.rect(-this._size.width * this._anchorPoint.x, -this._size.height * this._anchorPoint.y, this._size.width, this._size.height); - if (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height) { - return true; - } - return false; + return (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height); }, - /** - * Checks a point if in parent's area. - * @param {cc.Point} pt - * @returns {Boolean} - */ - clippingParentAreaContainPoint: function (pt) { + isClippingParentContainsPoint: function(pt){ this._affectByClipping = false; var parent = this.getParent(); var clippingParent = null; @@ -986,6 +1132,17 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ return true; }, + /** + * Checks a point if in parent's area. + * @deprecated + * @param {cc.Point} pt + * @returns {Boolean} + */ + clippingParentAreaContainPoint: function (pt) { + cc.log("clippingParentAreaContainPoint is deprecated. Please use isClippingParentContainsPoint instead."); + this.isClippingParentContainsPoint(pt); + }, + /** * Sends the touch event to widget's parent * @param {number} handleState @@ -1001,6 +1158,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Changes the position (x,y) of the widget . + * The original point (0,0) is at the left-bottom corner of screen. * @param {cc.Point||Number} pos * @param {Number} posY */ @@ -1012,8 +1170,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ if (pSize.width <= 0 || pSize.height <= 0) { this._positionPercent.x = 0; this._positionPercent.y = 0; - } - else { + } else { if (posY) { this._positionPercent.x = pos / pSize.width; this._positionPercent.y = posY / pSize.height; @@ -1098,11 +1255,12 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Gets the percent (x,y) of the widget - * @returns {cc.Point} + * @returns {cc.Point} The percent (x,y) of the widget in OpenGL coordinates */ getPositionPercent: function () { return this._positionPercent; }, + _getXPercent: function () { return this._positionPercent.x; }, @@ -1112,7 +1270,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Changes the position type of the widget - * @param {ccui.Widget.POSITION_ABSOLUTE|ccui.Widget.POSITION_PERCENT} type + * @param {ccui.Widget.POSITION_ABSOLUTE|ccui.Widget.POSITION_PERCENT} type the position type of widget */ setPositionType: function (type) { this.positionType = type; @@ -1120,15 +1278,15 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ /** * Gets the position type of the widget - * @returns {cc.pPositionType} + * @returns {ccui.Widget.POSITION_ABSOLUTE|ccui.Widget.POSITION_PERCENT} the position type of widget */ getPositionType: function () { return this.positionType; }, /** - * Set flipped x - * @param {Boolean} flipX + * Sets whether the widget should be flipped horizontally or not. + * @param {Boolean} flipX true if the widget should be flipped horizaontally, false otherwise. */ setFlippedX: function (flipX) { this._flippedX = flipX; @@ -1136,16 +1294,22 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, /** - * Get flipped x - * @returns {Boolean} + *

+ * Returns the flag which indicates whether the widget is flipped horizontally or not.
+ * It only flips the texture of the widget, and not the texture of the widget's children.
+ * Also, flipping the texture doesn't alter the anchorPoint.
+ * If you want to flip the anchorPoint too, and/or to flip the children too use:
+ * widget->setScaleX(sprite->getScaleX() * -1); + *

+ * @returns {Boolean} true if the widget is flipped horizontally, false otherwise. */ isFlippedX: function () { return this._flippedX; }, /** - * Set flipped y - * @param {Boolean} flipY + * Sets whether the widget should be flipped vertically or not. + * @param {Boolean} flipY true if the widget should be flipped vertically, false otherwise. */ setFlippedY: function (flipY) { this._flippedY = flipY; @@ -1153,8 +1317,14 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, /** - * Get flipped y - * @returns {Boolean} + *

+ * Return the flag which indicates whether the widget is flipped vertically or not.
+ * It only flips the texture of the widget, and not the texture of the widget's children.
+ * Also, flipping the texture doesn't alter the anchorPoint.
+ * If you want to flip the anchorPoint too, and/or to flip the children too use:
+ * widget->setScaleY(widget->getScaleY() * -1); + *

+ * @returns {Boolean} true if the widget is flipped vertically, false otherwise. */ isFlippedY: function () { return this._flippedY; @@ -1168,9 +1338,13 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, + adaptRenderers: function(){ + + }, + /** * Determines if the widget is bright - * @returns {boolean} + * @returns {boolean} true if the widget is bright, false if the widget is dark. */ isBright: function () { return this._bright; @@ -1217,27 +1391,42 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, /** - * Gets touch start position - * @returns {cc.Point} + * Gets the touch began point of widget when widget is selected. + * @returns {cc.Point} the touch began point. */ getTouchStartPos: function () { - return this._touchStartPos; + cc.log("getTouchStartPos is deprecated. Please use getTouchBeganPosition instead."); + return this.getTouchBeganPosition(); + }, + + getTouchBeganPosition: function(){ + return cc.p(this._touchBeganPosition); }, /** - * Gets touch move position - * @returns {cc.Point} + *Gets the touch move point of widget when widget is selected. + * @returns {cc.Point} the touch move point. */ getTouchMovePos: function () { - return this._touchMovePos; + cc.log("getTouchMovePos is deprecated. Please use getTouchMovePosition instead."); + return this.getTouchMovePosition(); + }, + + getTouchMovePosition: function(){ + return cc.p(this._touchMovePosition); }, /** - * Gets touch end position - * @returns {cc.Point} + * Gets the touch end point of widget when widget is selected. + * @returns {cc.Point} the touch end point. */ getTouchEndPos: function () { - return this._touchEndPos; + cc.log("getTouchEndPos is deprecated. Please use getTouchEndPosition instead."); + return this.getTouchEndPosition(); + }, + + getTouchEndPosition:function(){ + return cc.p(this._touchEndPosition); }, /** @@ -1265,7 +1454,7 @@ ccui.Widget = ccui.Node.extend(/** @lends ccui.Widget# */{ }, /** - * Sets layout parameter + * Gets LayoutParameter of widget. * @param {ccui.LayoutParameter} parameter */ setLayoutParameter: function (parameter) { @@ -1507,11 +1696,17 @@ ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT = 1; ccui.Widget.TYPE_WIDGET = 0; ccui.Widget.TYPE_CONTAINER = 1; +//Focus Direction +ccui.Widget.LEFT = 0; +ccui.Widget.RIGHT = 1; +ccui.Widget.UP = 0; +ccui.Widget.DOWN = 1; + //texture resource type ccui.Widget.LOCAL_TEXTURE = 0; ccui.Widget.PLIST_TEXTURE = 1; -//touch event type +//touch event type //TODO why don't use a common define ? ccui.Widget.TOUCH_BEGAN = 0; ccui.Widget.TOUCH_MOVED = 1; ccui.Widget.TOUCH_ENDED = 2; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index aa01142169..140b732fac 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -87,12 +87,15 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ onEnter: function(){ ccui.Widget.prototype.onEnter.call(this); if (this._clippingStencil) - { this._clippingStencil.onEnter(); - } this._doLayoutDirty = true; this._clippingRectDirty = true; }, + onExit: function(){ + ccui.Widget.prototype.onExit.call(this); + if (this._clippingStencil) + this._clippingStencil.onExit(); + }, init: function () { if (cc.Node.prototype.init.call(this)) { this._layoutParameterDictionary = {}; diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 07ee1078b7..bbe2a81cc1 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -257,8 +257,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ onTouchEnded: function (touch, event) { var touchPoint = touch.getLocation(); - this._touchEndPos.x = touchPoint.x; - this._touchEndPos.y = touchPoint.y; + this._touchEndPosition.x = touchPoint.x; + this._touchEndPosition.y = touchPoint.y; if (this._focus) { this.releaseUpEvent(); if (this._isSelected) { diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index e08119e1c9..e2f126165d 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -407,7 +407,7 @@ 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) { - var nsp = this.convertToNodeSpace(this._touchStartPos); + var nsp = this.convertToNodeSpace(this._touchBeganPosition); this.setPercent(this.getPercentWithBallPos(nsp.x)); this.percentChangedEvent(); } @@ -416,8 +416,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ onTouchMoved: function (touch, event) { var touchPoint = touch.getLocation(); - this._touchMovePos.x = touchPoint.x; - this._touchMovePos.y = touchPoint.y; + this._touchMovePosition.x = touchPoint.x; + this._touchMovePosition.y = touchPoint.y; var nsp = this.convertToNodeSpace(touchPoint); this._slidBallRenderer.setPosition(nsp.x, 0); this.setPercent(this.getPercentWithBallPos(nsp.x)); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 3b01e8f9e4..54b6a6ef12 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -385,8 +385,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ onTouchMoved: function (touch,event) { var touchPoint = touch.getLocation(); - this._touchMovePos.x = touchPoint.x; - this._touchMovePos.y = touchPoint.y; + this._touchMovePosition.x = touchPoint.x; + this._touchMovePosition.y = touchPoint.y; this.handleMoveLogic(touchPoint); var widgetParent = this.getWidgetParent(); if (widgetParent) { @@ -401,7 +401,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this.handleReleaseLogic(this._touchEndPos); + this.handleReleaseLogic(this._touchEndPosition); }, onTouchCancelled: function (touch, event) { diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 3ff57c850c..9c11b2c8b0 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1383,19 +1383,19 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ onTouchBegan: function (touch, event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); if (this._hitted) { - this.handlePressLogic(this._touchStartPos); + this.handlePressLogic(this._touchBeganPosition); } return pass; }, onTouchMoved: function (touch, event) { ccui.Layout.prototype.onTouchMoved.call(this, touch, event); - this.handleMoveLogic(this._touchMovePos); + this.handleMoveLogic(this._touchMovePosition); }, onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this.handleReleaseLogic(this._touchEndPos); + this.handleReleaseLogic(this._touchEndPosition); }, onTouchCancelled: function (touch, event) { From dd65167f426eba8b64129f129f58565544d82d5a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Jun 2014 10:50:48 +0800 Subject: [PATCH 0197/1564] Issue #5624: pluginx - facebook --- extensions/pluginx/Plugin.js | 205 ++++++++++++++++ extensions/pluginx/platform/facebook.js | 220 ++++++++++++++++++ extensions/pluginx/platform/facebook_sdk.js | 147 ++++++++++++ extensions/pluginx/plugins/AnalyticsFlurry.js | 96 -------- extensions/pluginx/plugins/SocialFacebook.js | 56 ----- extensions/pluginx/plugins/SocialQQWeibo.js | 67 ------ extensions/pluginx/plugins/SocialQzone.js | 70 ------ extensions/pluginx/plugins/SocialTwitter.js | 59 ----- extensions/pluginx/plugins/SocialWeibo.js | 66 ------ extensions/pluginx/protocols/Config.js | 91 -------- extensions/pluginx/protocols/PluginFactory.js | 97 -------- extensions/pluginx/protocols/PluginManager.js | 88 ------- .../pluginx/protocols/PluginProtocol.js | 102 -------- extensions/pluginx/protocols/PluginUtils.js | 173 -------------- extensions/pluginx/protocols/ProtocolAds.js | 151 ------------ .../pluginx/protocols/ProtocolAnalytics.js | 133 ----------- .../pluginx/protocols/ProtocolSocial.js | 106 --------- .../pluginx/samples/HelloSocial/cocos2d.js | 85 ------- .../pluginx/samples/HelloSocial/index.html | 34 --- .../pluginx/samples/HelloSocial/main.js | 59 ----- .../samples/HelloSocial/res/CloseNormal.png | Bin 6835 -> 0 bytes .../samples/HelloSocial/res/CloseSelected.png | Bin 5711 -> 0 bytes .../samples/HelloSocial/res/background.png | Bin 481198 -> 0 bytes .../samples/HelloSocial/res/facebook.gif | Bin 2513 -> 0 bytes .../samples/HelloSocial/res/qqweibo.gif | Bin 2700 -> 0 bytes .../pluginx/samples/HelloSocial/res/qzone.gif | Bin 1750 -> 0 bytes .../samples/HelloSocial/res/snweibo.gif | Bin 2716 -> 0 bytes .../samples/HelloSocial/res/twitter.gif | Bin 2193 -> 0 bytes .../HelloSocial/src/MySocialManager.js | 120 ---------- .../pluginx/samples/HelloSocial/src/myApp.js | 105 --------- .../samples/HelloSocial/src/resource.js | 19 -- moduleConfig.json | 21 +- 32 files changed, 575 insertions(+), 1795 deletions(-) create mode 100644 extensions/pluginx/Plugin.js create mode 100644 extensions/pluginx/platform/facebook.js create mode 100644 extensions/pluginx/platform/facebook_sdk.js delete mode 100755 extensions/pluginx/plugins/AnalyticsFlurry.js delete mode 100644 extensions/pluginx/plugins/SocialFacebook.js delete mode 100644 extensions/pluginx/plugins/SocialQQWeibo.js delete mode 100644 extensions/pluginx/plugins/SocialQzone.js delete mode 100644 extensions/pluginx/plugins/SocialTwitter.js delete mode 100644 extensions/pluginx/plugins/SocialWeibo.js delete mode 100644 extensions/pluginx/protocols/Config.js delete mode 100644 extensions/pluginx/protocols/PluginFactory.js delete mode 100644 extensions/pluginx/protocols/PluginManager.js delete mode 100644 extensions/pluginx/protocols/PluginProtocol.js delete mode 100644 extensions/pluginx/protocols/PluginUtils.js delete mode 100755 extensions/pluginx/protocols/ProtocolAds.js delete mode 100755 extensions/pluginx/protocols/ProtocolAnalytics.js delete mode 100644 extensions/pluginx/protocols/ProtocolSocial.js delete mode 100644 extensions/pluginx/samples/HelloSocial/cocos2d.js delete mode 100644 extensions/pluginx/samples/HelloSocial/index.html delete mode 100644 extensions/pluginx/samples/HelloSocial/main.js delete mode 100755 extensions/pluginx/samples/HelloSocial/res/CloseNormal.png delete mode 100755 extensions/pluginx/samples/HelloSocial/res/CloseSelected.png delete mode 100755 extensions/pluginx/samples/HelloSocial/res/background.png delete mode 100644 extensions/pluginx/samples/HelloSocial/res/facebook.gif delete mode 100644 extensions/pluginx/samples/HelloSocial/res/qqweibo.gif delete mode 100644 extensions/pluginx/samples/HelloSocial/res/qzone.gif delete mode 100644 extensions/pluginx/samples/HelloSocial/res/snweibo.gif delete mode 100644 extensions/pluginx/samples/HelloSocial/res/twitter.gif delete mode 100644 extensions/pluginx/samples/HelloSocial/src/MySocialManager.js delete mode 100644 extensions/pluginx/samples/HelloSocial/src/myApp.js delete mode 100644 extensions/pluginx/samples/HelloSocial/src/resource.js diff --git a/extensions/pluginx/Plugin.js b/extensions/pluginx/Plugin.js new file mode 100644 index 0000000000..7b8117712f --- /dev/null +++ b/extensions/pluginx/Plugin.js @@ -0,0 +1,205 @@ +(function(w){ + + if(cc === undefined){ + return; + } + + var config = cc.game.config.plugin || {}; + var SDK = { + user: null, + share: null, + social: null + }; + + var Plugin = { + getSDK: function(){ + return SDK; + }, + isSupportFunction: function(name){ + if(typeof this[name] === 'function'){ + return true; + }else{ + return false; + } + }, + getUserPlugin: function(){ + return { + callStringFuncWithParam: function(){ + return this.callFuncWithParam.apply(this, arguments); + }, + callFuncWithParam: function(name, opt){ + if(config['common'] && config['common']['user'] && pluginList[config['common']['user']]){ + var _plugin = pluginList[config['common']['user']]; + if(typeof _plugin.user[name] == 'function'){ + return _plugin.user[name](opt); + }else if(typeof _plugin[name] == 'function'){ + return _plugin[name](opt); + } + } + } + }; + }, + getSharePlugin: function(){ + return { + callStringFuncWithParam: function(){ + return this.callFuncWithParam.apply(this, arguments); + }, + callFuncWithParam: function(name, opt){ + if(config['common'] && config['common']['share'] && pluginList[config['common']['share']]){ + var _plugin = pluginList[config['common']['share']]; + if(typeof _plugin.share[name] == 'function'){ + return _plugin.share[name](opt); + }else if(typeof _plugin[name] == 'function'){ + return _plugin[name](opt); + } + } + } + }; + } + }; + + var pluginList = {}; + + Plugin.extend = function(name, method){ + var use = false; + for(var p in config['common']){ + if(config['common'][p] == name){ + for(var o in method[p]){ + Plugin[o] = method[p][o]; + } + use = true; + SDK[p] = name; + } + } + if(use){ + method.init(config[name]); + } + pluginList[name] = method; + }; + + var pluginManager = { + loadPlugin: function(pluginName){ + if(!pluginName){ + cc.log("PliginManager - PluginName error"); + return null; + } + var info = pluginName.match(/[A-Z][a-z]+/g); + + if(info.length !== 2){ + cc.log("PliginManager - PluginName error"); + return null; + } + + var pluginObj = { + setDebugMode: function(){}, + startSession: function(){}, + setCaptureUncaughtException: function(){}, + callFuncWithParam: function(funName){ + if(!pluginList[pluginN]){ + return; + } + var _fun = pluginList[pluginN]['common'][funName]; + if(_fun){ + var _arg = Array.prototype.slice.call(arguments, 1); + return _fun.apply(_fun, _arg); + } + return; + }, + getPluginName: function(){ + return pluginN; + }, + getPluginVersion: function(){ + return "1.0"; + }, + callStringFuncWithParam: function(){ + return pluginObj.callFuncWithParam.apply(pluginObj, arguments); + } + }; + var moduleN = info[0].toLowerCase(); + var pluginN = info[1].toLowerCase(); + if(!pluginList[pluginN]){ + cc.log("Plugin does not exist"); + return pluginObj; + } + pluginList[pluginN].init(); + for(var p in pluginList[pluginN][moduleN]){ + pluginObj[p] = pluginList[pluginN][moduleN][p]; + } + return pluginObj; + + } + }; + + w['plugin'] = { + extend: Plugin.extend, + agentManager: Plugin, + AgentManager: { + getInstance: function(){ + return plugin.agentManager; + } + }, + PluginManager: { + getInstance: function(){ + return pluginManager; + } + } + }; + + + plugin.PluginParam = function(type, value){ + var paramType = plugin.PluginParam.ParamType,tmpValue; + switch(type){ + case paramType.TypeInt: + tmpValue = parseInt(value); + break; + case paramType.TypeFloat: + tmpValue = parseFloat(value); + break; + case paramType.TypeBool: + tmpValue = Boolean(value); + break; + case paramType.TypeString: + tmpValue = String(value); + break; + case paramType.TypeStringMap: + tmpValue = value//JSON.stringify(value); + break; + default: + tmpValue = value; + } + return tmpValue + }; + + plugin.PluginParam.ParamType = { + TypeInt:1, + TypeFloat:2, + TypeBool:3, + TypeString:4, + TypeStringMap:5 + }; + + plugin.PluginParam.AdsResultCode = { + AdsReceived:0, + FullScreenViewShown:1, + FullScreenViewDismissed:2, + PointsSpendSucceed:3, + PointsSpendFailed:4, + NetworkError:5, + UnknownError:6 + }; + + plugin.PluginParam.PayResultCode = { + PaySuccess:0, + PayFail:1, + PayCancel:2, + PayTimeOut:3 + }; + + plugin.PluginParam.ShareResultCode = { + ShareSuccess:0, + ShareFail:1, + ShareCancel:2, + ShareTimeOut:3 + }; + +})(window); \ No newline at end of file diff --git a/extensions/pluginx/platform/facebook.js b/extensions/pluginx/platform/facebook.js new file mode 100644 index 0000000000..e2b5ae1bca --- /dev/null +++ b/extensions/pluginx/platform/facebook.js @@ -0,0 +1,220 @@ +(function(P){ + + + var name = "facebook"; + + var userInfo = { + //accessToken: "", + //expriesIn: "", + //signedRequest: "", + //userID: "" + }; + + var errMsg = { + '0': 'success', + '1': 'Unknown error', + '2': 'Network error', + '3': 'Without permission', + '4': 'Interrupt operation' + }; + + var configCache = {}; + var isInit = false; + + P.extend(name, { + init: function(config){ + if (!FB || isInit) { + return; + } + var self = this; + self._isLogined = false; + configCache = config; + FB.init({ + appId : config['appId'], + xfbml : config['xfbml'], + version : config['version'] + }); + FB.getLoginStatus(function(response) { + if (response && response.status === 'connected') { + //login + self._isLogined = true; + //save user info + userInfo = response.authResponse; + }else{ + self._isLogined = false; + } + }); + isInit = true; + }, + + /* + User Class + */ + user: { + + login: function(callback){ + var self = this; + FB.login(function(response) { + if (response.authResponse) { + self._isLogined = true; + //save user info + userInfo = response.authResponse; + typeof callback === 'function' && callback(0, errMsg[0]); + } else { + typeof callback === 'function' && callback(1, errMsg[1]); + } + }, { scope: '' }); + }, + + logout: function(callback){ + FB.logout(function(response) { + if(response.authResponse){ + // user is now logged out + self._isLogined = false; + userInfo = {}; + typeof callback === 'function' && callback(0, errMsg[0]); + }else{ + typeof callback === 'function' && callback(1, errMsg[1]); + } + }); + }, + + isLogined: function(callback){ + var self = this; + + FB.getLoginStatus(function(response) { + if (response && response.status === 'connected') { + self._isLogined = true; + //login - save user info + userInfo = response.authResponse; + typeof callback === 'function' && callback(0); + }else{ + self._isLogined = false; + typeof callback === 'function' && callback(1, errMsg[1]); + } + }); + return this._isLogined; + }, + + getUserId: function(){ + return userInfo['userID']; + }, + + getToken: function(){ + return userInfo['accessToken']; + } + }, + + /* + Share Class + */ + share:{ + /* + + info: { + site: + title: + caption: + link: + text: + imagePath: + imageUrl: + location: + + dialogMode: + + notifyText: + notifyIcon: + + comment: + } + + */ + share: function(info, callback){ + + FB.ui({ + method: 'share', + name: info['title'], + caption: info['caption'], + description: info['text'], + href: info['link'], + picture: info['imageUrl'] + }, + function(response) { + if (response) { + if(response.post_id) + typeof callback === 'function' && callback(0, errMsg[0]); + else + typeof callback === 'function' && callback(3, errMsg[3]); + } else { + typeof callback === 'function' && callback(4, errMsg[4]); + } + }); + } + }, + + /* + Social Class + */ + social: { + submitScore: function(callback){ + if(userInfo.userID){ + FB.api("/"+userInfo.userID+"/scores", 'post', {score: 100}, function(response){ + console.log(response); + if(response){ + typeof callback === 'function' && callback(0, errMsg[0]); + }else{ + typeof callback === 'function' && callback(1, errMsg[1]); + } + }); + }else{ + callback(3, errMsg[3]); + } + }, + showLeaderboard: function(callback){ + if(configCache['appId']){ + FB.api("/"+configCache['appId']+"/scores", function(response){ + if(response['error']){ + typeof callback === 'function' && callback(1, response['message']); + }else if(response['data']){ + typeof callback === 'function' && callback(0, response['data']); + } + }); + } + }, + unlockAchievement: function(){ + + }, + showAchievements: function(){ + + } + }, + + dialog: function(options, callback){ + + FB.ui({ + method: 'share', + name: options['title'], + caption: options['caption'], + description: options['text'], + href: options['link'], + picture: options['imageUrl'] + }, + function(response) { + if (response) { + if(response.post_id) + typeof callback === 'function' && callback(0, errMsg[0]); + else + typeof callback === 'function' && callback(3, errMsg[3]); + } else { + typeof callback === 'function' && callback(4, errMsg[4]); + } + }); + }, + + ui: FB.ui, + api: FB.api + }); + + +})(plugin); \ No newline at end of file diff --git a/extensions/pluginx/platform/facebook_sdk.js b/extensions/pluginx/platform/facebook_sdk.js new file mode 100644 index 0000000000..5a5d0596af --- /dev/null +++ b/extensions/pluginx/platform/facebook_sdk.js @@ -0,0 +1,147 @@ +/*1401783924,168639065,JIT Construction: v1272844,zh_CN*/ + +/** + * Copyright Facebook Inc. + * + * Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + */ +try {window.FB || (function(window) { + var self = window, document = window.document; + var setTimeout = window.setTimeout, setInterval = window.setInterval,clearTimeout = window.clearTimeout,clearInterval = window.clearInterval;var __DEV__ = 0; + function emptyFunction() {}; + var __w, __t; + __t=function(a){return a[0];};__w=function(a){return a;}; + var require,__d;(function(a){var b={},c={},d=['global','require','requireDynamic','requireLazy','module','exports'];require=function(e,f){if(c.hasOwnProperty(e))return c[e];if(!b.hasOwnProperty(e)){if(f)return null;throw new Error('Module '+e+' has not been defined');}var g=b[e],h=g.deps,i=h.length,j,k=[];for(var l=0;l1?Number(arguments[1]):0;if(isNaN(j))j=0;var k=Math.min(Math.max(j,0),i.length);return i.indexOf(String(h),j)==k;};g.endsWith=function(h){var i=String(this);if(this==null)throw new TypeError('String.prototype.endsWith called on null or undefined');var j=i.length,k=String(h),l=arguments.length>1?Number(arguments[1]):j;if(isNaN(l))l=0;var m=Math.min(Math.max(l,0),j),n=m-k.length;if(n<0)return false;return i.lastIndexOf(k,n)==n;};g.contains=function(h){if(this==null)throw new TypeError('String.prototype.contains called on null or undefined');var i=String(this),j=arguments.length>1?Number(arguments[1]):0;if(isNaN(j))j=0;return i.indexOf(String(h),j)!=-1;};g.repeat=function(h){if(this==null)throw new TypeError('String.prototype.repeat called on null or undefined');var i=String(this),j=h?Number(h):0;if(isNaN(j))j=0;if(j<0||j===Infinity)throw RangeError();if(j===1)return i;if(j===0)return '';var k='';while(j){if(j&1)k+=i;if((j>>=1))i+=i;}return k;};e.exports=g;},null); + __d("ES5Array",[],function(a,b,c,d,e,f){var g={};g.isArray=function(h){return Object.prototype.toString.call(h)=='[object Array]';};e.exports=g;},null); + __d("ES5Object",[],function(a,b,c,d,e,f){var g={};g.create=function(h){var i=typeof h;if(i!='object'&&i!='function')throw new TypeError('Object prototype may only be a Object or null');var j=new Function();j.prototype=h;return new j();};g.keys=function(h){var i=typeof h;if(i!='object'&&i!='function'||h===null)throw new TypeError('Object.keys called on non-object');var j=[];for(var k in h)if(Object.prototype.hasOwnProperty.call(h,k))j.push(k);var l=!({toString:true}).propertyIsEnumerable('toString'),m=['toString','toLocaleString','valueOf','hasOwnProperty','isPrototypeOf','prototypeIsEnumerable','constructor'];if(l)for(var n=0;n1)))/4)-ca((ga-1901+ha)/100)+ca((ga-1601+ha)/400);};}if(typeof JSON=="object"&&JSON){k.stringify=JSON.stringify;k.parse=JSON.parse;}if((m=typeof k.stringify=="function"&&!ea)){(ba=function(){return 1;}).toJSON=ba;try{m=k.stringify(0)==="0"&&k.stringify(new Number())==="0"&&k.stringify(new String())=='""'&&k.stringify(g)===j&&k.stringify(j)===j&&k.stringify()===j&&k.stringify(ba)==="1"&&k.stringify([ba])=="[1]"&&k.stringify([j])=="[null]"&&k.stringify(null)=="null"&&k.stringify([j,g,null])=="[null,null,null]"&&k.stringify({result:[ba,true,false,null,"\0\b\n\f\r\t"]})==l&&k.stringify(null,ba)==="1"&&k.stringify([1,2],null,1)=="[\n 1,\n 2\n]"&&k.stringify(new Date(-8.64e+15))=='"-271821-04-20T00:00:00.000Z"'&&k.stringify(new Date(8.64e+15))=='"+275760-09-13T00:00:00.000Z"'&&k.stringify(new Date(-62198755200000))=='"-000001-01-01T00:00:00.000Z"'&&k.stringify(new Date(-1))=='"1969-12-31T23:59:59.999Z"';}catch(fa){m=false;}}if(typeof k.parse=="function")try{if(k.parse("0")===0&&!k.parse(false)){ba=k.parse(l);if((r=ba.A.length==5&&ba.A[0]==1)){try{r=!k.parse('"\t"');}catch(fa){}if(r)try{r=k.parse("01")!=1;}catch(fa){}}}}catch(fa){r=false;}ba=l=null;if(!m||!r){if(!(h={}.hasOwnProperty))h=function(ga){var ha={},ia;if((ha.__proto__=null,ha.__proto__={toString:1},ha).toString!=g){h=function(ja){var ka=this.__proto__,la=ja in (this.__proto__=null,this);this.__proto__=ka;return la;};}else{ia=ha.constructor;h=function(ja){var ka=(this.constructor||ia).prototype;return ja in this&&!(ja in ka&&this[ja]===ka[ja]);};}ha=null;return h.call(this,ga);};i=function(ga,ha){var ia=0,ja,ka,la,ma;(ja=function(){this.valueOf=0;}).prototype.valueOf=0;ka=new ja();for(la in ka)if(h.call(ka,la))ia++;ja=ka=null;if(!ia){ka=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];ma=function(na,oa){var pa=g.call(na)=="[object Function]",qa,ra;for(qa in na)if(!(pa&&qa=="prototype")&&h.call(na,qa))oa(qa);for(ra=ka.length;qa=ka[--ra];h.call(na,qa)&&oa(qa));};}else if(ia==2){ma=function(na,oa){var pa={},qa=g.call(na)=="[object Function]",ra;for(ra in na)if(!(qa&&ra=="prototype")&&!h.call(pa,ra)&&(pa[ra]=1)&&h.call(na,ra))oa(ra);};}else ma=function(na,oa){var pa=g.call(na)=="[object Function]",qa,ra;for(qa in na)if(!(pa&&qa=="prototype")&&h.call(na,qa)&&!(ra=qa==="constructor"))oa(qa);if(ra||h.call(na,(qa="constructor")))oa(qa);};return ma(ga,ha);};if(!m){n={"\\":"\\\\",'"':'\\"',"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};o=function(ga,ha){return ("000000"+(ha||0)).slice(-ga);};p=function(ga){var ha='"',ia=0,ja;for(;ja=ga.charAt(ia);ia++)ha+='\\"\b\f\n\r\t'.indexOf(ja)>-1?n[ja]:ja<" "?"\\u00"+o(2,ja.charCodeAt(0).toString(16)):ja;return ha+'"';};q=function(ga,ha,ia,ja,ka,la,ma){var na=ha[ga],oa,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za,ab,bb,cb;if(typeof na=="object"&&na){oa=g.call(na);if(oa=="[object Date]"&&!h.call(na,"toJSON")){if(na>-1/0&&na<1/0){if(ea){ra=ca(na/86400000);for(pa=ca(ra/365.2425)+1970-1;ea(pa+1,0)<=ra;pa++);for(qa=ca((ra-ea(pa,0))/30.42);ea(pa,qa+1)<=ra;qa++);ra=1+ra-ea(pa,qa);sa=(na%86400000+86400000)%86400000;ta=ca(sa/3600000)%24;ua=ca(sa/60000)%60;va=ca(sa/1000)%60;wa=sa%1000;}else{pa=na.getUTCFullYear();qa=na.getUTCMonth();ra=na.getUTCDate();ta=na.getUTCHours();ua=na.getUTCMinutes();va=na.getUTCSeconds();wa=na.getUTCMilliseconds();}na=(pa<=0||pa>=10000?(pa<0?"-":"+")+o(6,pa<0?-pa:pa):o(4,pa))+"-"+o(2,qa+1)+"-"+o(2,ra)+"T"+o(2,ta)+":"+o(2,ua)+":"+o(2,va)+"."+o(3,wa)+"Z";}else na=null;}else if(typeof na.toJSON=="function"&&((oa!="[object Number]"&&oa!="[object String]"&&oa!="[object Array]")||h.call(na,"toJSON")))na=na.toJSON(ga);}if(ia)na=ia.call(ha,ga,na);if(na===null)return "null";oa=g.call(na);if(oa=="[object Boolean]"){return ""+na;}else if(oa=="[object Number]"){return na>-1/0&&na<1/0?""+na:"null";}else if(oa=="[object String]")return p(na);if(typeof na=="object"){for(ab=ma.length;ab--;)if(ma[ab]===na)throw TypeError();ma.push(na);xa=[];bb=la;la+=ka;if(oa=="[object Array]"){for(za=0,ab=na.length;za0)for(ja="",ia>10&&(ia=10);ja.length-1){z++;}else if("{}[]:,".indexOf(ia)>-1){z++;return ia;}else if(ia=='"'){for(ja="@",z++;z-1){ja+=t[ia];z++;}else if(ia=="u"){ka=++z;for(la=z+4;z="0"&&ia<="9"||ia>="a"&&ia<="f"||ia>="A"&&ia<="F"))u();}ja+=s("0x"+ga.slice(ka,z));}else u();}else{if(ia=='"')break;ja+=ia;z++;}}if(ga.charAt(z)=='"'){z++;return ja;}u();}else{ka=z;if(ia=="-"){ma=true;ia=ga.charAt(++z);}if(ia>="0"&&ia<="9"){if(ia=="0"&&(ia=ga.charAt(z+1),ia>="0"&&ia<="9"))u();ma=false;for(;z="0"&&ia<="9");z++);if(ga.charAt(z)=="."){la=++z;for(;la="0"&&ia<="9");la++);if(la==z)u();z=la;}ia=ga.charAt(z);if(ia=="e"||ia=="E"){ia=ga.charAt(++z);if(ia=="+"||ia=="-")z++;for(la=z;la="0"&&ia<="9");la++);if(la==z)u();z=la;}return +ga.slice(ka,z);}if(ma)u();if(ga.slice(z,z+4)=="true"){z+=4;return true;}else if(ga.slice(z,z+5)=="false"){z+=5;return false;}else if(ga.slice(z,z+4)=="null"){z+=4;return null;}u();}}return "$";};w=function(ga){var ha,ia,ja;if(ga=="$")u();if(typeof ga=="string"){if(ga.charAt(0)=="@")return ga.slice(1);if(ga=="["){ha=[];for(;;ia||(ia=true)){ga=v();if(ga=="]")break;if(ia)if(ga==","){ga=v();if(ga=="]")u();}else u();if(ga==",")u();ha.push(w(ga));}return ha;}else if(ga=="{"){ha={};for(;;ia||(ia=true)){ga=v();if(ga=="}")break;if(ia)if(ga==","){ga=v();if(ga=="}")u();}else u();if(ga==","||typeof ga!="string"||ga.charAt(0)!="@"||v()!=":")u();ha[ga.slice(1)]=w(v());}return ha;}u();}return ga;};y=function(ga,ha,ia){var ja=x(ga,ha,ia);if(ja===j){delete ga[ha];}else ga[ha]=ja;};x=function(ga,ha,ia){var ja=ga[ha],ka;if(typeof ja=="object"&&ja)if(g.call(ja)=="[object Array]"){for(ka=ja.length;ka--;)y(ja,ka,ia);}else i(ja,function(la){y(ja,la,ia);});return ia.call(ga,ha,ja);};k.parse=function(ga,ha){z=0;aa=ga;var ia=w(v());if(v()!="$")u();z=aa=null;return ha&&g.call(ha)=="[object Function]"?x((ba={},ba[""]=ia,ba),"",ha):ia;};}}}).call(this);},null); + __d("ES5",["ES5ArrayPrototype","ES5FunctionPrototype","ES5StringPrototype","ES5Array","ES5Object","ES5Date","JSON3"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=Array.prototype.slice,o=Object.prototype.toString,p={'JSON.stringify':m.stringify,'JSON.parse':m.parse},q={array:g,'function':h,string:i,Object:k,Array:j,Date:l};for(var r in q){if(!q.hasOwnProperty(r))continue;var s=q[r],t=r===r.toLowerCase()?window[r.replace(/^\w/,function(x){return x.toUpperCase();})].prototype:window[r];for(var u in s){if(!s.hasOwnProperty(u))continue;var v=t[u];p[r+'.'+u]=v&&/\{\s+\[native code\]\s\}/.test(v)?v:s[u];}}function w(x,y,z){var aa=n.call(arguments,3),ba=z?/\s(.*)\]/.exec(o.call(x).toLowerCase())[1]:x,ca=p[ba+'.'+y]||x[y];if(typeof ca==='function')return ca.apply(x,aa);}e.exports=w;},null); + var ES5 = require('ES5'); + __d("JSSDKRuntimeConfig",[],{"locale":"zh_CN","rtl":false,"revision":"1272844"});__d("JSSDKConfig",[],{"bustCache":true,"tagCountLogRate":0.01,"errorHandling":{"rate":4},"usePluginPipe":true,"features":{"kill_fragment":true,"xfbml_profile_pic_server":true,"error_handling":{"rate":4},"e2e_ping_tracking":{"rate":1.0e-6},"xd_timeout":{"rate":4,"value":30000},"use_bundle":true},"api":{"mode":"warn","whitelist":["Canvas","Canvas.Prefetcher","Canvas.Prefetcher.addStaticResource","Canvas.Prefetcher.setCollectionMode","Canvas.getPageInfo","Canvas.hideFlashElement","Canvas.scrollTo","Canvas.setAutoGrow","Canvas.setDoneLoading","Canvas.setSize","Canvas.setUrlHandler","Canvas.showFlashElement","Canvas.startTimer","Canvas.stopTimer","Data","Data.process","Data.query","Data.query:wait","Data.waitOn","Data.waitOn:wait","Event","Event.subscribe","Event.unsubscribe","Music.flashCallback","Music.init","Music.send","Payment","Payment.cancelFlow","Payment.continueFlow","Payment.init","Payment.lockForProcessing","Payment.unlockForProcessing","Payment.parse","Payment.setSize","ThirdPartyProvider","ThirdPartyProvider.init","ThirdPartyProvider.sendData","UA","UA.nativeApp","XFBML","XFBML.RecommendationsBar","XFBML.RecommendationsBar.markRead","XFBML.parse","addFriend","api","getAccessToken","getAuthResponse","getLoginStatus","getUserID","init","login","logout","publish","share","ui","ui:subscribe"]},"initSitevars":{"enableMobileComments":1,"iframePermissions":{"read_stream":false,"manage_mailbox":false,"manage_friendlists":false,"read_mailbox":false,"publish_checkins":true,"status_update":true,"photo_upload":true,"video_upload":true,"sms":false,"create_event":true,"rsvp_event":true,"offline_access":true,"email":true,"xmpp_login":false,"create_note":true,"share_item":true,"export_stream":false,"publish_stream":true,"publish_likes":true,"ads_management":false,"contact_email":true,"access_private_data":false,"read_insights":false,"read_requests":false,"read_friendlists":true,"manage_pages":false,"physical_login":false,"manage_groups":false,"read_deals":false}}});__d("UrlMapConfig",[],{"www":"www.facebook.com","m":"m.facebook.com","connect":"connect.facebook.net","business":"business.facebook.com","api_https":"api.facebook.com","api_read_https":"api-read.facebook.com","graph_https":"graph.facebook.com","fbcdn_http":"static.ak.fbcdn.net","fbcdn_https":"fbstatic-a.akamaihd.net","cdn_http":"static.ak.facebook.com","cdn_https":"s-static.ak.facebook.com"});__d("JSSDKXDConfig",[],{"XdUrl":"\/connect\/xd_arbiter.php?version=41","XdBundleUrl":"\/connect\/xd_arbiter\/V80PAcvrynR.js?version=41","Flash":{"path":"https:\/\/connect.facebook.net\/rsrc.php\/v1\/yR\/r\/ks_9ZXiQ0GL.swf"},"useCdn":true});__d("JSSDKCssConfig",[],{"rules":".fb_hidden{position:absolute;top:-10000px;z-index:10001}.fb_invisible{display:none}.fb_reset{background:none;border:0;border-spacing:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}.fb_reset>div{overflow:hidden}.fb_link img{border:none}\n.fb_dialog{background:rgba(82, 82, 82, .7);position:absolute;top:-10000px;z-index:10001}.fb_reset .fb_dialog_legacy{overflow:visible}.fb_dialog_advanced{padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.fb_dialog_content{background:#fff;color:#333}.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px}.fb_dialog_mobile .fb_dialog_close_icon{top:5px;left:5px;right:auto}.fb_dialog_padding{background-color:transparent;position:absolute;width:1px;z-index:-1}.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif)}.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif)}.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:25px;padding:20px}.fb_dialog_top_left,.fb_dialog_top_right,.fb_dialog_bottom_left,.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}.fb_dialog_vert_left,.fb_dialog_vert_right,.fb_dialog_horiz_top,.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}.fb_dialog_vert_left,.fb_dialog_vert_right{width:10px;height:100\u0025}.fb_dialog_vert_left{margin-left:-10px}.fb_dialog_vert_right{right:0;margin-right:-10px}.fb_dialog_horiz_top,.fb_dialog_horiz_bottom{width:100\u0025;height:10px}.fb_dialog_horiz_top{margin-top:-10px}.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}.fb_dialog_iframe{line-height:0}.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:15px;font-weight:bold;margin:0}.fb_dialog_content .dialog_title>span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}body.fb_hidden{-webkit-transform:none;height:100\u0025;margin:0;overflow:visible;position:absolute;top:-10000px;left:0;width:100\u0025}.fb_dialog.fb_dialog_mobile.loading{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ya\/r\/3rhSv5V8j3o.gif) white no-repeat 50\u0025 50\u0025;min-height:100\u0025;min-width:100\u0025;overflow:hidden;position:absolute;top:0;z-index:10001}.fb_dialog.fb_dialog_mobile.loading.centered{max-height:590px;min-height:590px;max-width:500px;min-width:500px}#fb-root #fb_dialog_ipad_overlay{background:rgba(0, 0, 0, .45);position:absolute;left:0;top:0;width:100\u0025;min-height:100\u0025;z-index:10000}#fb-root #fb_dialog_ipad_overlay.hidden{display:none}.fb_dialog.fb_dialog_mobile.loading iframe{visibility:hidden}.fb_dialog_content .dialog_header{-webkit-box-shadow:white 0 1px 1px -1px inset;background:-webkit-gradient(linear, 0\u0025 0\u0025, 0\u0025 100\u0025, from(#738ABA), to(#2C4987));border-bottom:1px solid;border-color:#1d4088;color:#fff;font:14px Helvetica, sans-serif;font-weight:bold;text-overflow:ellipsis;text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0;vertical-align:middle;white-space:nowrap}.fb_dialog_content .dialog_header table{-webkit-font-smoothing:subpixel-antialiased;height:43px;width:100\u0025}.fb_dialog_content .dialog_header td.header_left{font-size:13px;padding-left:5px;vertical-align:middle;width:60px}.fb_dialog_content .dialog_header td.header_right{font-size:13px;padding-right:5px;vertical-align:middle;width:60px}.fb_dialog_content .touchable_button{background:-webkit-gradient(linear, 0\u0025 0\u0025, 0\u0025 100\u0025, from(#4966A6), color-stop(.5, #355492), to(#2A4887));border:1px solid #29447e;-webkit-background-clip:padding-box;-webkit-border-radius:3px;-webkit-box-shadow:rgba(0, 0, 0, .117188) 0 1px 1px inset, rgba(255, 255, 255, .167969) 0 1px 0;display:inline-block;margin-top:3px;max-width:85px;line-height:18px;padding:4px 12px;position:relative}.fb_dialog_content .dialog_header .touchable_button input{border:none;background:none;color:#fff;font:12px Helvetica, sans-serif;font-weight:bold;margin:2px -12px;padding:2px 6px 3px 6px;text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0}.fb_dialog_content .dialog_header .header_center{color:#fff;font-size:17px;font-weight:bold;line-height:18px;text-align:center;vertical-align:middle}.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/y9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}#fb_dialog_loader_close{float:left}.fb_dialog.fb_dialog_mobile .fb_dialog_close_button{text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0}.fb_dialog.fb_dialog_mobile .fb_dialog_close_icon{visibility:hidden}\n.fb_iframe_widget{display:inline-block;position:relative}.fb_iframe_widget span{display:inline-block;position:relative;text-align:justify}.fb_iframe_widget iframe{position:absolute}.fb_iframe_widget_lift{z-index:1}.fb_hide_iframes iframe{position:relative;left:-10000px}.fb_iframe_widget_loader{position:relative;display:inline-block}.fb_iframe_widget_fluid{display:inline}.fb_iframe_widget_fluid span{width:100\u0025}.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/y9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_connect_bar_container div,.fb_connect_bar_container span,.fb_connect_bar_container a,.fb_connect_bar_container img,.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:14px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}.fb_connect_bar a:hover{color:#fff}.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}.fb_connect_bar div a,.fb_connect_bar span,.fb_connect_bar span a{color:#bac6da;font-size:12px;text-decoration:none}.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fbpluginrecommendationsbarleft,.fbpluginrecommendationsbarright{position:fixed !important;bottom:0;z-index:999}.fbpluginrecommendationsbarleft{left:10px}.fbpluginrecommendationsbarright{right:10px}","components":["css:fb.css.base","css:fb.css.dialog","css:fb.css.iframewidget","css:fb.css.connectbarwidget","css:fb.css.plugin.recommendationsbar"]});__d("ApiClientConfig",[],{"FlashRequest":{"swfUrl":"https:\/\/connect.facebook.net\/rsrc.php\/v1\/yW\/r\/PvklbuW2Ycn.swf"}});__d("JSSDKCanvasPrefetcherConfig",[],{"blacklist":[144959615576466],"sampleRate":500});__d("JSSDKPluginPipeConfig",[],{"threshold":0,"enabledApps":{"209753825810663":1,"187288694643718":1}});__d("JSSDKConnectBarConfig",[],{"imgs":{"buttonUrl":"rsrc.php\/v2\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/v2\/yo\/r\/UlIqmHJn-SK.gif"}}); + __d("QueryString",[],function(a,b,c,d,e,f){function g(k){var l=[];ES5(ES5('Object','keys',false,k).sort(),'forEach',true,function(m){var n=k[m];if(typeof n==='undefined')return;if(n===null){l.push(m);return;}l.push(encodeURIComponent(m)+'='+encodeURIComponent(n));});return l.join('&');}function h(k,l){var m={};if(k==='')return m;var n=k.split('&');for(var o=0;oh);},ie64:function(){return x.ie()&&r;},firefox:function(){return w()||i;},opera:function(){return w()||j;},webkit:function(){return w()||k;},safari:function(){return x.webkit();},chrome:function(){return w()||l;},windows:function(){return w()||o;},osx:function(){return w()||n;},linux:function(){return w()||p;},iphone:function(){return w()||s;},mobile:function(){return w()||(s||t||q||v);},nativeApp:function(){return w()||u;},android:function(){return w()||q;},ipad:function(){return w()||t;}};e.exports=x;},null); + __d("hasNamePropertyBug",["guid","UserAgent"],function(a,b,c,d,e,f,g,h){var i=h.ie()?undefined:false;function j(){var l=document.createElement("form"),m=l.appendChild(document.createElement("input"));m.name=g();i=m!==l.elements[m.name];l=m=null;return i;}function k(){return typeof i==='undefined'?j():i;}e.exports=k;},null); + __d("wrapFunction",[],function(a,b,c,d,e,f){var g={};function h(i,j,k){j=j||'default';return function(){var l=j in g?g[j](i,k):i;return l.apply(this,arguments);};}h.setWrapper=function(i,j){j=j||'default';g[j]=i;};e.exports=h;},null); + __d("DOMEventListener",["wrapFunction"],function(a,b,c,d,e,f,g){var h,i;if(window.addEventListener){h=function(k,l,m){m.wrapper=g(m,'entry','DOMEventListener.add '+l);k.addEventListener(l,m.wrapper,false);};i=function(k,l,m){k.removeEventListener(l,m.wrapper,false);};}else if(window.attachEvent){h=function(k,l,m){m.wrapper=g(m,'entry','DOMEventListener.add '+l);k.attachEvent('on'+l,m.wrapper);};i=function(k,l,m){k.detachEvent('on'+l,m.wrapper);};}else i=h=function(){};var j={add:function(k,l,m){h(k,l,m);return {remove:function(){i(k,l,m);k=null;}};},remove:i};e.exports=j;},null); + __d("sdk.createIframe",["copyProperties","guid","hasNamePropertyBug","DOMEventListener"],function(a,b,c,d,e,f,g,h,i,j){function k(l){l=g({},l);var m,n=l.name||h(),o=l.root,p=l.style||{border:'none'},q=l.url,r=l.onload;if(i()){m=document.createElement('');j.root.innerHTML=('');k=true;setTimeout(function(){j.root.innerHTML=o;j.root.firstChild.src=j.url;j.onInsert&&j.onInsert(j.root.firstChild);},0);}else{var p=document.createElement('iframe');p.id=j.id;p.name=j.name;p.onload=m;p.scrolling='no';p.style.border='none';p.style.overflow='hidden';if(j.title)p.title=j.title;if(j.className)p.className=j.className;if(j.height!==undefined)p.style.height=j.height+'px';if(j.width!==undefined)if(j.width=='100%'){p.style.width=j.width;}else p.style.width=j.width+'px';j.root.appendChild(p);k=true;p.src=j.url;j.onInsert&&j.onInsert(p);}}e.exports=i;},null); + __d("sdk.Native",["copyProperties","Log","UserAgent"],function(a,b,c,d,e,f,g,h,i){var j='fbNativeReady',k={onready:function(l){if(!i.nativeApp()){h.error('FB.Native.onready only works when the page is rendered '+'in a WebView of the native Facebook app. Test if this is the '+'case calling FB.UA.nativeApp()');return;}if(window.__fbNative&&!this.nativeReady)g(this,window.__fbNative);if(this.nativeReady){l();}else{var m=function(n){window.removeEventListener(j,m);this.onready(l);};window.addEventListener(j,m,false);}}};e.exports=k;},null); + __d("resolveURI",[],function(a,b,c,d,e,f){function g(h){if(!h)return window.location.href;h=h.replace(/&/g,'&').replace(/"/g,'"');var i=document.createElement('div');i.innerHTML='';return i.firstChild.href;}e.exports=g;},null); + __d("sdk.UIServer",["sdk.Auth","sdk.Content","createObjectFrom","copyProperties","sdk.Dialog","sdk.DOM","sdk.Event","flattenObject","sdk.Frictionless","sdk.getContextType","guid","insertIframe","Log","sdk.Native","QueryString","resolveURI","sdk.RPC","sdk.Runtime","JSSDKConfig","UrlMap","UserAgent","sdk.XD"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ba){var ca={transform:function(fa){if(fa.params.display==='touch'&&fa.params.access_token&&window.postMessage){fa.params.channel=ea._xdChannelHandler(fa.id,'parent');if(!aa.nativeApp())fa.params.in_iframe=1;return fa;}else return ea.genericTransform(fa);},getXdRelation:function(fa){var ga=fa.display;if(ga==='touch'&&window.postMessage&&fa.in_iframe)return 'parent';return ea.getXdRelation(fa);}},da={'stream.share':{size:{width:670,height:340},url:'sharer.php',transform:function(fa){if(!fa.params.u)fa.params.u=window.location.toString();fa.params.display='popup';return fa;}},apprequests:{transform:function(fa){fa=ca.transform(fa);fa.params.frictionless=o&&o._useFrictionless;if(fa.params.frictionless){if(o.isAllowed(fa.params.to)){fa.params.display='iframe';fa.params.in_iframe=true;fa.hideLoader=true;}fa.cb=o._processRequestResponse(fa.cb,fa.hideLoader);}fa.closeIcon=false;return fa;},getXdRelation:ca.getXdRelation},feed:ca,'permissions.oauth':{url:'dialog/oauth',size:{width:(aa.mobile()?null:475),height:(aa.mobile()?null:183)},transform:function(fa){if(!x.getClientID()){s.error('FB.login() called before FB.init().');return;}if(g.getAuthResponse()&&!fa.params.scope&&!fa.params.auth_type){s.error('FB.login() called when user is already connected.');fa.cb&&fa.cb({status:x.getLoginStatus(),authResponse:g.getAuthResponse()});return;}var ga=fa.cb,ha=fa.id;delete fa.cb;var ia=ES5('Object','keys',false,j(fa.params.response_type?i(fa.params.response_type.split(',')):{},{token:true,signed_request:true})).join(',');if(fa.params.display==='async'){j(fa.params,{client_id:x.getClientID(),origin:p(),response_type:ia,domain:location.hostname});fa.cb=g.xdResponseWrapper(ga,g.getAuthResponse(),'permissions.oauth');}else j(fa.params,{client_id:x.getClientID(),redirect_uri:v(ea.xdHandler(ga,ha,'opener',g.getAuthResponse(),'permissions.oauth')),origin:p(),response_type:ia,domain:location.hostname});return fa;}},'auth.logout':{url:'logout.php',transform:function(fa){if(!x.getClientID()){s.error('FB.logout() called before calling FB.init().');}else if(!g.getAuthResponse()){s.error('FB.logout() called without an access token.');}else{fa.params.next=ea.xdHandler(fa.cb,fa.id,'parent',g.getAuthResponse(),'logout');return fa;}}},'login.status':{url:'dialog/oauth',transform:function(fa){var ga=fa.cb,ha=fa.id;delete fa.cb;j(fa.params,{client_id:x.getClientID(),redirect_uri:ea.xdHandler(ga,ha,'parent',g.getAuthResponse(),'login_status'),origin:p(),response_type:'token,signed_request,code',domain:location.hostname});return fa;}}},ea={Methods:da,_loadedNodes:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(fa){if(fa.params.display=='dialog'||fa.params.display=='iframe')j(fa.params,{display:'iframe',channel:ea._xdChannelHandler(fa.id,'parent.parent')},true);return fa;},checkOauthDisplay:function(fa){var ga=fa.scope||fa.perms||x.getScope();if(!ga)return fa.display;var ha=ga.split(/\s|,/g);for(var ia=0;ia2000;},getDisplayMode:function(fa,ga){if(ga.display==='hidden'||ga.display==='none')return ga.display;var ha=x.isEnvironment(x.ENVIRONMENTS.CANVAS)||x.isEnvironment(x.ENVIRONMENTS.PAGETAB);if(ha&&!ga.display)return 'async';if(aa.mobile()||ga.display==='touch')return 'touch';if(!x.getAccessToken()&&(ga.display=='iframe'||ga.display=='dialog')&&!fa.loggedOutIframe){s.error('"dialog" mode can only be used when the user is connected.');return 'popup';}if(fa.connectDisplay&&!ha)return fa.connectDisplay;return ga.display||(x.getAccessToken()?'dialog':'popup');},getXdRelation:function(fa){var ga=fa.display;if(ga==='popup'||ga==='touch')return 'opener';if(ga==='dialog'||ga==='iframe'||ga==='hidden'||ga==='none')return 'parent';if(ga==='async')return 'parent.frames['+window.name+']';},popup:function(fa){var ga=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,ha=typeof window.screenY!='undefined'?window.screenY:window.screenTop,ia=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,ja=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),ka=aa.mobile()?null:fa.size.width,la=aa.mobile()?null:fa.size.height,ma=(ga<0)?window.screen.width+ga:ga,na=parseInt(ma+((ia-ka)/2),10),oa=parseInt(ha+((ja-la)/2.5),10),pa=[];if(ka!==null)pa.push('width='+ka);if(la!==null)pa.push('height='+la);pa.push('left='+na);pa.push('top='+oa);pa.push('scrollbars=1');if(fa.name=='permissions.request'||fa.name=='permissions.oauth')pa.push('location=1,toolbar=0');pa=pa.join(',');var qa;if(fa.post){qa=window.open('about:blank',fa.id,pa);if(qa){ea.setLoadedNode(fa,qa,'popup');h.submitToTarget({url:fa.url,target:fa.id,params:fa.params});}}else{qa=window.open(fa.url,fa.id,pa);if(qa)ea.setLoadedNode(fa,qa,'popup');}if(!qa)return;if(fa.id in ea._defaultCb)ea._popupMonitor();},setLoadedNode:function(fa,ga,ha){if(fa.params&&fa.params.display!='popup')ga.fbCallID=fa.id;ga={node:ga,type:ha,fbCallID:fa.id};ea._loadedNodes[fa.id]=ga;},getLoadedNode:function(fa){var ga=typeof fa=='object'?fa.id:fa,ha=ea._loadedNodes[ga];return ha?ha.node:null;},hidden:function(fa){fa.className='FB_UI_Hidden';fa.root=h.appendHidden('');ea._insertIframe(fa);},iframe:function(fa){fa.className='FB_UI_Dialog';var ga=function(){ea._triggerDefault(fa.id);};fa.root=k.create({onClose:ga,closeIcon:fa.closeIcon===undefined?true:fa.closeIcon,classes:(aa.ipad()?'centered':'')});if(!fa.hideLoader)k.showLoader(ga,fa.size.width);l.addCss(fa.root,'fb_dialog_iframe');ea._insertIframe(fa);},touch:function(fa){if(fa.params&&fa.params.in_iframe){if(fa.ui_created){k.showLoader(function(){ea._triggerDefault(fa.id);},0);}else ea.iframe(fa);}else if(aa.nativeApp()&&!fa.ui_created){fa.frame=fa.id;t.onready(function(){ea.setLoadedNode(fa,t.open(fa.url+'#cb='+fa.frameName),'native');});ea._popupMonitor();}else if(!fa.ui_created)ea.popup(fa);},async:function(fa){fa.params.redirect_uri=location.protocol+'//'+location.host+location.pathname;delete fa.params.access_token;w.remote.showDialog(fa.params,function(ga){var ha=ga.result;if(ha&&ha.e2e){var ia=k.get(fa.id);ia.trackEvents(ha.e2e);ia.trackEvent('close');delete ha.e2e;}fa.cb(ha);});},getDefaultSize:function(){return k.getDefaultSize();},_insertIframe:function(fa){ea._loadedNodes[fa.id]=false;var ga=function(ha){if(fa.id in ea._loadedNodes)ea.setLoadedNode(fa,ha,'iframe');};if(fa.post){r({url:'about:blank',root:fa.root,className:fa.className,width:fa.size.width,height:fa.size.height,id:fa.id,onInsert:ga,onload:function(ha){h.submitToTarget({url:fa.url,target:ha.name,params:fa.params});}});}else r({url:fa.url,root:fa.root,className:fa.className,width:fa.size.width,height:fa.size.height,id:fa.id,name:fa.frameName,onInsert:ga});},_handleResizeMessage:function(fa,ga){var ha=ea.getLoadedNode(fa);if(!ha)return;if(ga.height)ha.style.height=ga.height+'px';if(ga.width)ha.style.width=ga.width+'px';ba.inform('resize.ack',ga||{},'parent.frames['+ha.name+']');if(!k.isActive(ha))k.show(ha);},_triggerDefault:function(fa){ea._xdRecv({frame:fa},ea._defaultCb[fa]||function(){});},_popupMonitor:function(){var fa;for(var ga in ea._loadedNodes)if(ea._loadedNodes.hasOwnProperty(ga)&&ga in ea._defaultCb){var ha=ea._loadedNodes[ga];if(ha.type!='popup'&&ha.type!='native')continue;var ia=ha.node;try{if(ia.closed){ea._triggerDefault(ga);}else fa=true;}catch(ja){}}if(fa&&!ea._popupInterval){ea._popupInterval=setInterval(ea._popupMonitor,100);}else if(!fa&&ea._popupInterval){clearInterval(ea._popupInterval);ea._popupInterval=null;}},_xdChannelHandler:function(fa,ga){return ba.handler(function(ha){var ia=ea.getLoadedNode(fa);if(!ia)return;if(ha.type=='resize'){ea._handleResizeMessage(fa,ha);}else if(ha.type=='hide'){k.hide(ia);}else if(ha.type=='rendered'){var ja=k._findRoot(ia);k.show(ja);}else if(ha.type=='fireevent')m.fire(ha.event);},ga,true,null);},_xdNextHandler:function(fa,ga,ha,ia){if(ia)ea._defaultCb[ga]=fa;return ba.handler(function(ja){ea._xdRecv(ja,fa);},ha)+'&frame='+ga;},_xdRecv:function(fa,ga){var ha=ea.getLoadedNode(fa.frame);if(ha)if(ha.close){try{ha.close();if(/iPhone.*Version\/(5|6)/.test(navigator.userAgent)&&RegExp.$1!=='5')window.focus();ea._popupCount--;}catch(ia){}}else if(l.containsCss(ha,'FB_UI_Hidden')){setTimeout(function(){ha.parentNode.parentNode.removeChild(ha.parentNode);},3000);}else if(l.containsCss(ha,'FB_UI_Dialog'))k.remove(ha);delete ea._loadedNodes[fa.frame];delete ea._defaultCb[fa.frame];if(fa.e2e){var ja=k.get(fa.frame);ja.trackEvents(fa.e2e);ja.trackEvent('close');delete fa.e2e;}ga(fa);},_xdResult:function(fa,ga,ha,ia){return (ea._xdNextHandler(function(ja){fa&&fa(ja.result&&ja.result!=ea._resultToken&&ES5('JSON','parse',false,ja.result));},ga,ha,ia)+'&result='+encodeURIComponent(ea._resultToken));},xdHandler:function(fa,ga,ha,ia,ja){return ea._xdNextHandler(g.xdResponseWrapper(fa,ia,ja),ga,ha,true);}};w.stub('showDialog');e.exports=ea;},null); + __d("sdk.ui",["Assert","sdk.Impressions","Log","sdk.PlatformVersioning","sdk.Runtime","sdk.UIServer","copyProperties","sdk.feature"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){function o(p,q){g.isObject(p);g.maybeFunction(q);if(k.getIsVersioned()){j.assertVersionIsSet();if(p.version){j.assertValidVersion(p.version);}else p.version=k.getVersion();}p=m({},p);if(!p.method){i.error('"method" is a required parameter for FB.ui().');return null;}var r=p.method;if(p.redirect_uri){i.warn('When using FB.ui, you should not specify a redirect_uri.');delete p.redirect_uri;}if((r=='permissions.request'||r=='permissions.oauth')&&(p.display=='iframe'||p.display=='dialog'))p.display=l.checkOauthDisplay(p);var s=n('e2e_tracking',true);if(s)p.e2e={};var t=l.prepareCall(p,q||function(){});if(!t)return null;var u=t.params.display;if(u==='dialog'){u='iframe';}else if(u==='none')u='hidden';var v=l[u];if(!v){i.error('"display" must be one of "popup", '+'"dialog", "iframe", "touch", "async", "hidden", or "none"');return null;}if(s)t.dialog.subscribe('e2e:end',function(w){w.method=r;w.display=u;i.debug('e2e: %s',ES5('JSON','stringify',false,w));h.log(114,{payload:w});});v(t);return t.dialog;}e.exports=o;},null); + __d("legacy:fb.auth",["sdk.Auth","sdk.Cookie","copyProperties","sdk.Event","FB","Log","sdk.Runtime","sdk.SignedRequest","sdk.ui"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){k.provide('',{getLoginStatus:function(){return g.getLoginStatus.apply(g,arguments);},getAuthResponse:function(){return g.getAuthResponse();},getAccessToken:function(){return m.getAccessToken()||null;},getUserID:function(){return m.getUserID()||m.getCookieUserID();},login:function(p,q){if(q&&q.perms&&!q.scope){q.scope=q.perms;delete q.perms;l.warn('OAuth2 specification states that \'perms\' '+'should now be called \'scope\'. Please update.');}var r=m.isEnvironment(m.ENVIRONMENTS.CANVAS)||m.isEnvironment(m.ENVIRONMENTS.PAGETAB);o(i({method:'permissions.oauth',display:r?'async':'popup',domain:location.hostname},q||{}),p);},logout:function(p){o({method:'auth.logout',display:'hidden'},p);}});g.subscribe('logout',ES5(j.fire,'bind',true,j,'auth.logout'));g.subscribe('login',ES5(j.fire,'bind',true,j,'auth.login'));g.subscribe('authresponse.change',ES5(j.fire,'bind',true,j,'auth.authResponseChange'));g.subscribe('status.change',ES5(j.fire,'bind',true,j,'auth.statusChange'));j.subscribe('init:post',function(p){if(p.status)g.getLoginStatus();if(m.getClientID())if(p.authResponse){g.setAuthResponse(p.authResponse,'connected');}else if(m.getUseCookie()){var q=h.loadSignedRequest(),r;if(q){try{r=n.parse(q);}catch(s){h.clearSignedRequestCookie();}if(r&&r.user_id)m.setCookieUserID(r.user_id);}h.loadMeta();}});},3); + __d("sdk.Canvas.Plugin",["sdk.api","sdk.RPC","Log","UserAgent","sdk.Runtime","createArrayFrom"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m='CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000',n='CLSID:444785F1-DE89-4295-863A-D46C3A781394',o=null,p=!(j.osx()>=10.9&&(j.chrome()>=31||j.webkit()>=537.71||j.firefox()>=25));function q(aa){aa._hideunity_savedstyle={};aa._hideunity_savedstyle.left=aa.style.left;aa._hideunity_savedstyle.position=aa.style.position;aa._hideunity_savedstyle.width=aa.style.width;aa._hideunity_savedstyle.height=aa.style.height;aa.style.left='-10000px';aa.style.position='absolute';aa.style.width='1px';aa.style.height='1px';}function r(aa){if(aa._hideunity_savedstyle){aa.style.left=aa._hideunity_savedstyle.left;aa.style.position=aa._hideunity_savedstyle.position;aa.style.width=aa._hideunity_savedstyle.width;aa.style.height=aa._hideunity_savedstyle.height;}}function s(aa){aa._old_visibility=aa.style.visibility;aa.style.visibility='hidden';}function t(aa){aa.style.visibility=aa._old_visibility||'';delete aa._old_visibility;}function u(aa){var ba=aa.type?aa.type.toLowerCase():null,ca=ba==='application/x-shockwave-flash'||(aa.classid&&aa.classid.toUpperCase()==m);if(!ca)return false;var da=/opaque|transparent/i;if(da.test(aa.getAttribute('wmode')))return false;for(var ea=0;ea=-p)return false;}j=o;h.remote.setSize(o);return true;}function m(o,p){if(p===undefined&&typeof o==='number'){p=o;o=true;}if(o||o===undefined){if(i===null)i=setInterval(function(){l();},p||100);l();}else if(i!==null){clearInterval(i);i=null;}}h.stub('setSize');var n={setSize:l,setAutoGrow:m};e.exports=n;},null); + __d("sdk.Canvas.Navigation",["sdk.RPC"],function(a,b,c,d,e,f,g){function h(j){g.local.navigate=function(k){j({path:k});};g.remote.setNavigationEnabled(true);}g.stub('setNavigationEnabled');var i={setUrlHandler:h};e.exports=i;},null); + __d("sdk.Canvas.Tti",["sdk.RPC","sdk.Runtime"],function(a,b,c,d,e,f,g,h){function i(n,o){var p={appId:h.getClientID(),time:ES5('Date','now',false),name:o},q=[p];if(n)q.push(function(r){n(r.result);});g.remote.logTtiMessage.apply(null,q);}function j(){i(null,'StartIframeAppTtiTimer');}function k(n){i(n,'StopIframeAppTtiTimer');}function l(n){i(n,'RecordIframeAppTti');}g.stub('logTtiMessage');var m={setDoneLoading:l,startTimer:j,stopTimer:k};e.exports=m;},null); + __d("legacy:fb.canvas",["Assert","sdk.Canvas.Environment","sdk.Event","FB","sdk.Canvas.Plugin","sdk.Canvas.IframeHandling","Log","sdk.Canvas.Navigation","sdk.Runtime","sdk.Canvas.Tti"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){j.provide('Canvas',{setSize:function(q){g.maybeObject(q,'Invalid argument');return l.setSize.apply(null,arguments);},setAutoGrow:function(){return l.setAutoGrow.apply(null,arguments);},getPageInfo:function(q){g.isFunction(q,'Invalid argument');return h.getPageInfo.apply(null,arguments);},scrollTo:function(q,r){g.maybeNumber(q,'Invalid argument');g.maybeNumber(r,'Invalid argument');return h.scrollTo.apply(null,arguments);},setDoneLoading:function(q){g.maybeFunction(q,'Invalid argument');return p.setDoneLoading.apply(null,arguments);},startTimer:function(){return p.startTimer.apply(null,arguments);},stopTimer:function(q){g.maybeFunction(q,'Invalid argument');return p.stopTimer.apply(null,arguments);},getHash:function(q){g.isFunction(q,'Invalid argument');return n.getHash.apply(null,arguments);},setHash:function(q){g.isString(q,'Invalid argument');return n.setHash.apply(null,arguments);},setUrlHandler:function(q){g.isFunction(q,'Invalid argument');return n.setUrlHandler.apply(null,arguments);}});i.subscribe('init:post',function(q){if(o.isEnvironment(o.ENVIRONMENTS.CANVAS)){g.isTrue(!q.hideFlashCallback||!q.hidePluginCallback,'cannot specify deprecated hideFlashCallback and new hidePluginCallback');k._setHidePluginCallback(q.hidePluginCallback||q.hideFlashCallback);}});},3); + __d("sdk.Canvas.Prefetcher",["sdk.api","createArrayFrom","JSSDKCanvasPrefetcherConfig","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j){var k={AUTOMATIC:0,MANUAL:1},l=i.sampleRate,m=i.blacklist,n=k.AUTOMATIC,o=[];function p(){var u={object:'data',link:'href',script:'src'};if(n==k.AUTOMATIC)ES5(ES5('Object','keys',false,u),'forEach',true,function(v){var w=u[v];ES5(h(document.getElementsByTagName(v)),'forEach',true,function(x){if(x[w])o.push(x[w]);});});if(o.length===0)return;g(j.getClientID()+'/staticresources','post',{urls:ES5('JSON','stringify',false,o),is_https:location.protocol==='https:'});o=[];}function q(){if(!j.isEnvironment(j.ENVIRONMENTS.CANVAS)||!j.getClientID()||!l)return;if(Math.random()>1/l||m=='*'||~ES5(m,'indexOf',true,j.getClientID()))return;setTimeout(p,30000);}function r(u){n=u;}function s(u){o.push(u);}var t={COLLECT_AUTOMATIC:k.AUTOMATIC,COLLECT_MANUAL:k.MANUAL,addStaticResource:s,setCollectionMode:r,_maybeSample:q};e.exports=t;},null); + __d("legacy:fb.canvas.prefetcher",["FB","sdk.Canvas.Prefetcher","sdk.Event","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j){g.provide('Canvas.Prefetcher',h);i.subscribe('init:post',function(k){if(j.isEnvironment(j.ENVIRONMENTS.CANVAS))h._maybeSample();});},3); + __d("legacy:fb.event",["FB","sdk.Event"],function(a,b,c,d,e,f,g,h){g.provide('Event',{subscribe:ES5(h.subscribe,'bind',true,h),unsubscribe:ES5(h.unsubscribe,'bind',true,h)});},3); + __d("legacy:fb.frictionless",["FB","sdk.Frictionless"],function(a,b,c,d,e,f,g,h){g.provide('Frictionless',h);},3); + __d("sdk.init",["sdk.Cookie","sdk.ErrorHandling","sdk.Event","Log","ManagedError","sdk.PlatformVersioning","QueryString","sdk.Runtime","sdk.URI","copyProperties","createArrayFrom"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){function r(t){var u=(typeof t=='number'&&t>0)||(typeof t=='string'&&/^[0-9a-f]{21,}$|^[0-9]{1,21}$/.test(t));if(u)return t.toString();j.warn('Invalid App Id: Must be a number or numeric string representing '+'the application id.');return null;}function s(t){if(n.getInitialized())j.warn('FB.init has already been called - this could indicate a problem');if(n.getIsVersioned()){if(Object.prototype.toString.call(t)!=='[object Object]')throw new k('Invalid argument');if(t.authResponse)throw new k('Setting authResponse is not supported');if(!t.version)t.version=o(location.href).getQueryData().sdk_version;l.assertValidVersion(t.version);n.setVersion(t.version);}else{if(/number|string/.test(typeof t)){j.warn('FB.init called with invalid parameters');t={apiKey:t};}t=p({status:true},t||{});}var u=r(t.appId||t.apiKey);if(u!==null)n.setClientID(u);if('scope' in t)n.setScope(t.scope);if(t.cookie){n.setUseCookie(true);if(typeof t.cookie==='string')g.setDomain(t.cookie);}if(t.kidDirectedSite)n.setKidDirectedSite(true);n.setInitialized(true);i.fire('init:post',t);}setTimeout(function(){var t=/(connect\.facebook\.net|\.facebook\.com\/assets.php).*?#(.*)/;ES5(q(document.getElementsByTagName('script')),'forEach',true,function(u){if(u.src){var v=t.exec(u.src);if(v){var w=m.decode(v[2]);for(var x in w)if(w.hasOwnProperty(x)){var y=w[x];if(y=='0')w[x]=0;}s(w);}}});if(window.fbAsyncInit&&!window.fbAsyncInit.hasRun){window.fbAsyncInit.hasRun=true;h.unguard(window.fbAsyncInit)();}},0);e.exports=s;},null); + __d("legacy:fb.init",["FB","sdk.init"],function(a,b,c,d,e,f,g,h){g.provide('',{init:h});},3); + __d("legacy:fb.pay",["copyProperties","sdk.Runtime","sdk.UIServer","sdk.XD","FB"],function(a,b,c,d,e,f,g,h,i,j){b('FB');var k={error_code:1383001,error_message:'An unknown error caused the dialog to be closed'},l=function(m){return function(n){m(n&&n.response?ES5('JSON','parse',false,n.response):k);};};g(i.Methods,{'pay.prompt':{transform:function(m){var n=j.handler(l(m.cb),'parent.frames['+(window.name||'iframe_canvas')+']');m.params.channel=n;j.inform('Pay.Prompt',m.params);}},pay:{size:{width:555,height:120},connectDisplay:'popup',transform:function(m){m.cb=l(m.cb);if(!h.isEnvironment(h.ENVIRONMENTS.CANVAS)){m.params.order_info=ES5('JSON','stringify',false,m.params.order_info);return m;}var n=j.handler(m.cb,'parent.frames['+(window.name||'iframe_canvas')+']');m.params.channel=n;m.params.uiserver=true;j.inform('Pay.Prompt',m.params);}}});},3); + __d("legacy:fb.ui",["FB","sdk.ui"],function(a,b,c,d,e,f,g,h){g.provide('',{ui:h});},3); + __d("Miny",[],function(a,b,c,d,e,f){var g='Miny1',h={encode:[],decode:{}},i='wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'.split('');function j(n){for(var o=h.encode.length;o=0,'onrender() has been called too many times');};ES5(i(ca.getElementsByTagName('*')),'forEach',true,function(ka){if(!ea&&ka.getAttribute('fb-xfbml-state'))return;if(ka.nodeType!==1)return;var la=w(ka)||x(ka);if(!la)return;if(p.ie()<9&&ka.scopeName)ka=z(ka,la.xmlns,la.localName);ga++;ha++;var ma=new la.ctor(ka,la.xmlns,la.localName,y(ka));ma.subscribe('render',o(function(){ka.setAttribute('fb-xfbml-state','rendered');ia();}));var na=function(){if(ka.getAttribute('fb-xfbml-state')=='parsed'){t.subscribe('render.queue',na);}else{ka.setAttribute('fb-xfbml-state','parsed');ma.process();}};na();});t.inform('parse',fa,ha);var ja=30000;setTimeout(function(){if(ga>0)m.warn('%s tags failed to render in %s ms',ga,ja);},ja);ia();}t.subscribe('render',function(){var ca=t.getSubscribers('render.queue');t.clearSubscribers('render.queue');ES5(ca,'forEach',true,function(da){da();});});h(t,{registerTag:function(ca){var da=ca.xmlns+':'+ca.localName;g.isUndefined(q[da],da+' already registered');q[da]=ca;r[ca.xmlns+'-'+ca.localName]=ca;},parse:function(ca,da){aa(ca||document.body,da||function(){},true);},parseNew:function(){aa(document.body,function(){},false);}});if(k('log_tag_count')){var ba=function(ca,da){t.unsubscribe('parse',ba);setTimeout(ES5(l.log,'bind',true,null,102,{tag_count:da}),5000);};t.subscribe('parse',ba);}e.exports=t;},null); + __d("PluginPipe",["sdk.Content","copyProperties","sdk.feature","guid","insertIframe","Miny","ObservableMixin","JSSDKPluginPipeConfig","sdk.Runtime","UrlMap","UserAgent","XFBML"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){var s=new m(),t=n.threshold,u=[];function v(){return !!(i('plugin_pipe')&&o.getSecure()!==undefined&&(q.chrome()||q.firefox())&&n.enabledApps[o.getClientID()]);}function w(){var y=u;u=[];if(y.length<=t){ES5(y,'forEach',true,function(ba){k(ba.config);});return;}var z=y.length+1;function aa(){z--;if(z===0)x(y);}ES5(y,'forEach',true,function(ba){var ca={};for(var da in ba.config)ca[da]=ba.config[da];ca.url=p.resolve('www',o.getSecure())+'/plugins/plugin_pipe_shell.php';ca.onload=aa;k(ca);});aa();}r.subscribe('parse',w);function x(y){var z=document.createElement('span');g.appendHidden(z);var aa={};ES5(y,'forEach',true,function(fa){aa[fa.config.name]={plugin:fa.tag,params:fa.params};});var ba=ES5('JSON','stringify',false,aa),ca=l.encode(ba);ES5(y,'forEach',true,function(fa){var ga=document.getElementsByName(fa.config.name)[0];ga.onload=fa.config.onload;});var da=p.resolve('www',o.getSecure())+'/plugins/pipe.php',ea=j();k({url:'about:blank',root:z,name:ea,className:'fb_hidden fb_invisible',onload:function(){g.submitToTarget({url:da,target:ea,params:{plugins:ca.length-1)?n:l;});},isValid:function(){for(var k=this.dom;k;k=k.parentNode)if(k==document.body)return true;},clear:function(){g.html(this.dom,'');}},i);e.exports=j;},null); + __d("sdk.XFBML.IframeWidget",["sdk.Arbiter","sdk.Auth","sdk.Content","copyProperties","sdk.DOM","sdk.Event","sdk.XFBML.Element","guid","insertIframe","QueryString","sdk.Runtime","sdk.ui","UrlMap","sdk.XD"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u=m.extend({_iframeName:null,_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',_widgetPipeEnabled:false,_borderReset:false,_repositioned:false,getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){return this._iframeName;},getIframeTitle:function(){return 'Facebook Social Plugin';},getChannelUrl:function(){if(!this._channelUrl){var y=this;this._channelUrl=t.handler(function(z){y.fire('xd.'+z.type,z);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},arbiterInform:function(event,y,z){t.sendToFacebook(this.getIframeName(),{method:event,params:ES5('JSON','stringify',false,y||{}),behavior:z||g.BEHAVIOR_PERSISTENT});},_arbiterInform:function(event,y,z){var aa='parent.frames["'+this.getIframeNode().name+'"]';t.inform(event,y,aa,z);},getDefaultWebDomain:function(){return s.resolve('www');},process:function(y){if(this._done){if(!this._allowReProcess&&!y)return;this.clear();}else this._oneTimeSetup();this._done=true;this._iframeName=this.getIframeName()||this._iframeName||n();if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();k.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){k.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',ES5(this.fire,'bind',true,this,'render'));var z=this.getSize()||{},aa=this.getFullyQualifiedURL();if(z.width=='100%')k.addCss(this.dom,'fb_iframe_widget_fluid');this.clear();o({url:aa,root:this.dom.appendChild(document.createElement('span')),name:this._iframeName,title:this.getIframeTitle(),className:q.getRtl()?'fb_rtl':'fb_ltr',height:z.height,width:z.width,onload:ES5(this.fire,'bind',true,this,'iframe.onload')});this._resizeFlow(z);this.loaded=false;this.subscribe('iframe.onload',ES5(function(){this.loaded=true;},'bind',true,this));},generateWidgetPipeIframeName:function(){v++;return 'fb_iframe_'+v;},getFullyQualifiedURL:function(){var y=this._getURL();y+='?'+p.encode(this._getQS());if(y.length>2000){y='about:blank';var z=ES5(function(){this._postRequest();this.unsubscribe('iframe.onload',z);},'bind',true,this);this.subscribe('iframe.onload',z);}return y;},_getWidgetPipeShell:function(){return s.resolve('www')+'/common/widget_pipe_shell.php';},_oneTimeSetup:function(){this.subscribe('xd.resize',ES5(this._handleResizeMsg,'bind',true,this));this.subscribe('xd.resize',ES5(this._bubbleResizeEvent,'bind',true,this));this.subscribe('xd.resize.iframe',ES5(this._resizeIframe,'bind',true,this));this.subscribe('xd.resize.flow',ES5(this._resizeFlow,'bind',true,this));this.subscribe('xd.resize.flow',ES5(this._bubbleResizeEvent,'bind',true,this));this.subscribe('xd.refreshLoginStatus',function(){h.getLoginStatus(function(){},true);});this.subscribe('xd.logout',function(){r({method:'auth.logout',display:'hidden'},function(){});});if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',ES5(this._makeVisible,'bind',true,this));this.subscribe('xd.verify',ES5(function(y){this.arbiterInform('xd/verify',y.token);},'bind',true,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();k.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){h.getLoginStatus(ES5(function(y){var z=y.status;l.subscribe('auth.statusChange',ES5(function(aa){if(!this.isValid())return;if(z=='unknown'||aa.status=='unknown')this.process(true);z=aa.status;},'bind',true,this));},'bind',true,this));},_handleResizeMsg:function(y){if(!this.isValid())return;this._resizeIframe(y);this._resizeFlow(y);if(!this._borderReset){this.getIframeNode().style.border='none';this._borderReset=true;}this._makeVisible();},_bubbleResizeEvent:function(y){var z={height:y.height,width:y.width,pluginID:this.getAttribute('plugin-id')};l.fire('xfbml.resize',z);},_resizeIframe:function(y){var z=this.getIframeNode();if(y.reposition==="true")this._repositionIframe(y);y.height&&(z.style.height=y.height+'px');y.width&&(z.style.width=y.width+'px');this._updateIframeZIndex();},_resizeFlow:function(y){var z=this.dom.getElementsByTagName('span')[0];y.height&&(z.style.height=y.height+'px');y.width&&(z.style.width=y.width+'px');this._updateIframeZIndex();},_updateIframeZIndex:function(){var y=this.dom.getElementsByTagName('span')[0],z=this.getIframeNode(),aa=z.style.height===y.style.height&&z.style.width===y.style.width,ba=aa?'removeCss':'addCss';k[ba](z,'fb_iframe_widget_lift');},_repositionIframe:function(y){var z=this.getIframeNode(),aa=parseInt(k.getStyle(z,'width'),10),ba=k.getPosition(z).x,ca=k.getViewportInfo().width,da=parseInt(y.width,10);if(ba+da>ca&&ba>da){z.style.left=aa-da+'px';this.arbiterInform('xd/reposition',{type:'horizontal'});this._repositioned=true;}else if(this._repositioned){z.style.left='0px';this.arbiterInform('xd/reposition',{type:'restore'});this._repositioned=false;}},_addLoader:function(){if(!this._loaderDiv){k.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){k.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return j({api_key:q.getClientID(),locale:q.getLocale(),sdk:'joey',kid_directed_site:q.getKidDirectedSite(),ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var y=this.getDefaultWebDomain(),z='';return y+'/plugins/'+z+this.getUrlBits().name+'.php';},_postRequest:function(){i.submitToTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}),v=0,w={};function x(){var y={};for(var z in w){var aa=w[z];y[z]={widget:aa.getUrlBits().name,params:aa._getQS()};}return y;}e.exports=u;},null); + __d("sdk.XFBML.Comments",["sdk.Event","sdk.XFBML.IframeWidget","QueryString","sdk.Runtime","JSSDKConfig","UrlMap","UserAgent"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=h.extend({_visibleAfter:'immediate',_refreshOnAuthChange:true,setupAndValidate:function(){var o={channel_url:this.getChannelUrl(),colorscheme:this.getAttribute('colorscheme'),skin:this.getAttribute('skin'),numposts:this.getAttribute('num-posts',10),width:this._getLengthAttribute('width'),href:this.getAttribute('href'),permalink:this.getAttribute('permalink'),publish_feed:this.getAttribute('publish_feed'),order_by:this.getAttribute('order_by'),mobile:this._getBoolAttribute('mobile')};if(!o.width&&!o.permalink)o.width=550;if(k.initSitevars.enableMobileComments&&m.mobile()&&o.mobile!==false){o.mobile=true;delete o.width;}if(!o.skin)o.skin=o.colorscheme;if(!o.href){o.migrated=this.getAttribute('migrated');o.xid=this.getAttribute('xid');o.title=this.getAttribute('title',document.title);o.url=this.getAttribute('url',document.URL);o.quiet=this.getAttribute('quiet');o.reverse=this.getAttribute('reverse');o.simple=this.getAttribute('simple');o.css=this.getAttribute('css');o.notify=this.getAttribute('notify');if(!o.xid){var p=ES5(document.URL,'indexOf',true,'#');if(p>0){o.xid=encodeURIComponent(document.URL.substring(0,p));}else o.xid=encodeURIComponent(document.URL);}if(o.migrated)o.href=l.resolve('www')+'/plugins/comments_v1.php?'+'app_id='+j.getClientID()+'&xid='+encodeURIComponent(o.xid)+'&url='+encodeURIComponent(o.url);}else{var q=this.getAttribute('fb_comment_id');if(!q){q=i.decode(document.URL.substring(ES5(document.URL,'indexOf',true,'?')+1)).fb_comment_id;if(q&&ES5(q,'indexOf',true,'#')>0)q=q.substring(0,ES5(q,'indexOf',true,'#'));}if(q){o.fb_comment_id=q;this.subscribe('render',ES5(function(){if(!window.location.hash)window.location.hash=this.getIframeNode().id;},'bind',true,this));}}this._attr=o;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',ES5(this._handleCommentMsg,'bind',true,this));this.subscribe('xd.commentCreated',ES5(this._handleCommentCreatedMsg,'bind',true,this));this.subscribe('xd.commentRemoved',ES5(this._handleCommentRemovedMsg,'bind',true,this));},getSize:function(){if(!this._attr.permalink)return {width:this._attr.mobile?'100%':this._attr.width,height:160};},getUrlBits:function(){return {name:'comments',params:this._attr};},getDefaultWebDomain:function(){return l.resolve(this._attr.mobile?'m':'www',true);},_handleCommentMsg:function(o){if(!this.isValid())return;g.fire('comments.add',{post:o.post,user:o.user,widget:this});},_handleCommentCreatedMsg:function(o){if(!this.isValid())return;var p={href:o.href,commentID:o.commentID,parentCommentID:o.parentCommentID};g.fire('comment.create',p);},_handleCommentRemovedMsg:function(o){if(!this.isValid())return;var p={href:o.href,commentID:o.commentID};g.fire('comment.remove',p);}});e.exports=n;},null); + __d("mergeArrays",[],function(a,b,c,d,e,f){function g(h,i){for(var j=0;j%s',n));if(n>0)h.removeCss(this.dom,'fb_comments_count_zero');this.fire('render');},'bind',true,this));}});e.exports=k;},null); + __d("sdk.Anim",["sdk.DOM"],function(a,b,c,d,e,f,g){var h={ate:function(i,j,k,l){k=!isNaN(parseFloat(k))&&k>=0?k:750;var m=40,n={},o={},p=null,q=setInterval(ES5(function(){if(!p)p=ES5('Date','now',false);var r=1;if(k!=0)r=Math.min((ES5('Date','now',false)-p)/k,1);for(var s in j)if(j.hasOwnProperty(s)){var t=j[s];if(!n[s]){var u=g.getStyle(i,s);if(u===false)return;n[s]=this._parseCSS(u+'');}if(!o[s])o[s]=this._parseCSS(t.toString());var v='';ES5(n[s],'forEach',true,function(w,x){if(isNaN(o[s][x].numPart)&&o[s][x].textPart=='?'){v=w.numPart+w.textPart;}else if(isNaN(w.numPart)){v=w.textPart;}else v+=(w.numPart+Math.ceil((o[s][x].numPart-w.numPart)*Math.sin(Math.PI/2*r)))+o[s][x].textPart+' ';});g.setStyle(i,s,v);}if(r==1){clearInterval(q);if(l)l(i);}},'bind',true,this),m);},_parseCSS:function(i){var j=[];ES5(i.split(' '),'forEach',true,function(k){var l=parseInt(k,10);j.push({numPart:l,textPart:k.replace(l,'')});});return j;}};e.exports=h;},null); + __d("escapeHTML",[],function(a,b,c,d,e,f){var g=/[&<>"'\/]/g,h={'&':'&','<':'<','>':'>','"':'"',"'":''','/':'/'};function i(j){return j.replace(g,function(k){return h[k];});}e.exports=i;},null); + __d("sdk.Helper",["sdk.ErrorHandling","sdk.Event","UrlMap","safeEval","sprintf"],function(a,b,c,d,e,f,g,h,i,j,k){var l={isUser:function(m){return m<2.2e+09||(m>=1e+14&&m<=100099999989999)||(m>=8.9e+13&&m<=89999999999999);},upperCaseFirstChar:function(m){if(m.length>0){return m.substr(0,1).toUpperCase()+m.substr(1);}else return m;},getProfileLink:function(m,n,o){if(!o&&m)o=k('%s/profile.php?id=%s',i.resolve('www'),m.uid||m.id);if(o)n=k('%s',o,n);return n;},invokeHandler:function(m,n,o){if(m)if(typeof m==='string'){g.unguard(j)(m,o);}else if(m.apply)g.unguard(m).apply(n,o||[]);},fireEvent:function(m,n){var o=n._attr.href;n.fire(m,o);h.fire(m,o,n);},executeFunctionByName:function(m){var n=Array.prototype.slice.call(arguments,1),o=m.split("."),p=o.pop(),q=window;for(var r=0;r'+''+'{2}'+''+''+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',t.tx._("\u4e0d\uff0c\u8c22\u8c22"),v.resolve('fbcdn')+'/'+k.imgs.buttonUrl,t.tx._("\u5173\u95ed"),y[this._picFieldName]||v.resolve('fbcdn')+'/'+k.imgs.missingProfileUrl,o(y.first_name),t.tx._("\u4f60\u597d\uff0c{firstName}\u3002\u003Cstrong>{siteName}\u003C\/strong>\u6b63\u5728\u4f7f\u7528 Facebook \u4e2a\u6027\u5316\u4f60\u7684\u4f53\u9a8c\u3002",{firstName:o(y.first_name),siteName:o(y.site_name)}),t.tx._("\u4e86\u89e3\u66f4\u591a"),y.profile_url,v.resolve('www')+'/sitetour/connect.php'));ES5(j(z.getElementsByTagName('a')),'forEach',true,function(da){da.onclick=ES5(this._clickHandler,'bind',true,this);},this);this._page=document.body;var ba=0;if(this._page.parentNode){ba=Math.round((parseFloat(m.getStyle(this._page.parentNode,'height'))-parseFloat(m.getStyle(this._page,'height')))/2);}else ba=parseInt(m.getStyle(this._page,'marginTop'),10);ba=isNaN(ba)?0:ba;this._initTopMargin=ba;if(!window.XMLHttpRequest){aa.className+=" fb_connect_bar_container_ie6";}else{aa.style.top=(-1*this._initialHeight)+'px';g.ate(aa,{top:'0px'},this._animationSpeed);}var ca={marginTop:this._initTopMargin+this._initialHeight+'px'};if(w.ie()){ca.backgroundPositionY=this._initialHeight+'px';}else ca.backgroundPosition='? '+this._initialHeight+'px';g.ate(this._page,ca,this._animationSpeed);},_clickHandler:function(y){y=y||window.event;var z=y.target||y.srcElement;while(z.nodeName!='A')z=z.parentNode;switch(z.className){case 'fb_bar_close':h({method:'Connect.connectBarMarkAcknowledged'});s.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(z.href);break;case 'fb_no_thanks':this._closeConnectBar();h({method:'Connect.connectBarMarkAcknowledged'});s.impression({lid:104,name:'widget_user_no_thanks'});h({method:'auth.revokeAuthorization',block:true},ES5(function(){this.fire('connectbar.ondeauth');p.fire('connectbar.ondeauth',this);r.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();},'bind',true,this));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var y={marginTop:this._initTopMargin+'px'};if(w.ie()){y.backgroundPositionY='0px';}else y.backgroundPosition='? 0px';var z=(this._animationSpeed==0)?0:300;g.ate(this._page,y,z);g.ate(this._container,{top:(-1*this._initialHeight)+'px'},z,function(aa){aa.parentNode.removeChild(aa);});this.fire('connectbar.onclose');p.fire('connectbar.onclose',this);r.invokeHandler(this.getAttribute('on-close'),this);}});e.exports=x;},null); + __d("sdk.XFBML.LoginButton",["sdk.Helper","IframePlugin"],function(a,b,c,d,e,f,g,h){var i=h.extend({constructor:function(j,k,l,m){this.parent(j,k,l,m);var n=h.getVal(m,'on_login');if(n)this.subscribe('login.status',function(o){g.invokeHandler(n,null,[o]);});},getParams:function(){return {scope:'string',perms:'string',size:'string',login_text:'text',show_faces:'bool',max_rows:'string',show_login_face:'bool',registration_url:'url_maybe',auto_logout_link:'bool',one_click:'bool',show_banner:'bool',auth_type:'string'};}});e.exports=i;},null); + __d("sdk.XFBML.Name",["copyProperties","sdk.Data","escapeHTML","sdk.Event","sdk.XFBML.Element","sdk.Helper","Log","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=k.extend({process:function(){g(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){m.error('"uid" is a required attribute for ');this.fire('render');return;}var p=[];if(this._firstnameonly){p.push('first_name');}else if(this._lastnameonly){p.push('last_name');}else p.push('name');if(this._subjectId){p.push('sex');if(this._subjectId==n.getUserID())this._reflexive=true;}var q;j.monitor('auth.statusChange',ES5(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=n.getUserID();if(!this._uid)return;if(l.isUser(this._uid)){q=h._selectByIndex(p,'user','uid',this._uid);}else q=h._selectByIndex(['name','id'],'profile','id',this._uid);q.wait(ES5(function(r){if(this._subjectId==this._uid){this._renderPronoun(r[0]);}else this._renderOther(r[0]);this.fire('render');},'bind',true,this));},'bind',true,this));},_renderPronoun:function(p){var q='',r=this._objective;if(this._subjectId){r=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==n.getUserID()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){q='your own';}else q='your';}else if(this._reflexive){q='yourself';}else q='you';}else switch(p.sex){case 'male':if(this._possessive){q=this._reflexive?'his own':'his';}else if(this._reflexive){q='himself';}else if(r){q='him';}else q='he';break;case 'female':if(this._possessive){q=this._reflexive?'her own':'her';}else if(this._reflexive){q='herself';}else if(r){q='her';}else q='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){q='their own';}else q='their';}else if(this._reflexive){q='themselves';}else if(r){q='them';}else q='they';}else if(this._possessive){if(this._reflexive){q='his/her own';}else q='his/her';}else if(this._reflexive){q='himself/herself';}else if(r){q='him/her';}else q='he/she';break;}if(this._getBoolAttribute('capitalize',false))q=l.upperCaseFirstChar(q);this.dom.innerHTML=q;},_renderOther:function(p){var q='',r='';if(this._uid==n.getUserID()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){q='your own';}else q='yourself';}else if(this._possessive){q='your';}else q='you';}else if(p){if(null===p.first_name)p.first_name='';if(null===p.last_name)p.last_name='';if(this._firstnameonly&&p.first_name!==undefined){q=i(p.first_name);}else if(this._lastnameonly&&p.last_name!==undefined)q=i(p.last_name);if(!q)q=i(p.name);if(q!==''&&this._possessive)q+='\'s';}if(!q)q=i(this.getAttribute('if-cant-see','Facebook User'));if(q){if(this._getBoolAttribute('capitalize',false))q=l.upperCaseFirstChar(q);if(p&&this._linked){r=l.getProfileLink(p,q,this.getAttribute('href',null));}else r=q;}this.dom.innerHTML=r;}});e.exports=o;},null); + __d("sdk.XFBML.RecommendationsBar",["sdk.Arbiter","DOMEventListener","sdk.Event","sdk.XFBML.IframeWidget","resolveURI","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=j.extend({getUrlBits:function(){return {name:'recommendations_bar',params:this._attr};},setupAndValidate:function(){function n(w,x){var y=0,z=null;function aa(){x();z=null;y=ES5('Date','now',false);}return function(){if(!z){var ba=ES5('Date','now',false);if(ba-y=this._attr.trigger;}}});e.exports=m;},null); + __d("sdk.XFBML.Registration",["sdk.Auth","sdk.Helper","sdk.XFBML.IframeWidget","sdk.Runtime","UrlMap"],function(a,b,c,d,e,f,g,h,i,j,k){var l=i.extend({_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={action:this.getAttribute('action'),border_color:this.getAttribute('border-color'),channel_url:this.getChannelUrl(),client_id:j.getClientID(),fb_only:this._getBoolAttribute('fb-only',false),fb_register:this._getBoolAttribute('fb-register',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),no_footer:this._getBoolAttribute('no-footer'),no_header:this._getBoolAttribute('no-header'),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600),target:this.getAttribute('target')};if(this._attr.onvalidate)this.subscribe('xd.validate',ES5(function(m){var n=ES5('JSON','parse',false,m.value),o=ES5(function(q){this.arbiterInform('Registration.Validation',{errors:q,id:m.id});},'bind',true,this),p=h.executeFunctionByName(this._attr.onvalidate,n,o);if(p)o(p);},'bind',true,this));this.subscribe('xd.authLogin',ES5(this._onAuthLogin,'bind',true,this));this.subscribe('xd.authLogout',ES5(this._onAuthLogout,'bind',true,this));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var m;if(!this._attr.fields){m=['name'];}else try{m=ES5('JSON','parse',false,this._attr.fields);}catch(n){m=this._attr.fields.split(/,/);}if(this._attr.widthGoogle Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier.Click the logo to download.

' + - ''; - var p = d.getElementById(c.tag).parentNode; - p.style.background = 'none'; - p.style.border = 'none'; - p.insertBefore(s); - - d.body.style.background = '#ffffff'; - return; - } - - var fn; - window.addEventListener('DOMContentLoaded', fn = function() { - this.removeEventListener('DOMContentLoaded', fn, false); - //first load engine file if specified - var s = d.createElement('script'); - /*********Delete this section if you have packed all files into one*******/ - if (c.SingleEngineFile && !c.engineDir) { - s.src = c.SingleEngineFile; - } - else if (c.engineDir && !c.SingleEngineFile) { - s.src = c.engineDir + 'jsloader.js'; - } - else { - alert('You must specify either the single engine file OR the engine directory in "cocos2d.js"'); - } - /*********Delete this section if you have packed all files into one*******/ - - //s.src = 'myTemplate.js'; //IMPORTANT: Un-comment this line if you have packed all files into one - - d.body.appendChild(s); - document.ccConfig = c; - s.id = 'cocos2d-html5'; - //else if single file specified, load singlefile - }); -})(); diff --git a/extensions/pluginx/samples/HelloSocial/index.html b/extensions/pluginx/samples/HelloSocial/index.html deleted file mode 100644 index 6b4cece82c..0000000000 --- a/extensions/pluginx/samples/HelloSocial/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Cocos2d-html5 Hello World test - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/pluginx/samples/HelloSocial/main.js b/extensions/pluginx/samples/HelloSocial/main.js deleted file mode 100644 index 183e53c1c5..0000000000 --- a/extensions/pluginx/samples/HelloSocial/main.js +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. - - http://www.cocos2d-x.org - - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ -var cocos2dApp = cc.Application.extend({ - config:document['ccConfig'], - ctor:function (scene) { - this._super(); - this.startScene = scene; - cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; - cc.initDebugSetting(); - cc.setup(this.config['tag']); - cc.AppController.shareAppController().didFinishLaunchingWithOptions(); - }, - applicationDidFinishLaunching:function () { - // initialize director - var director = cc.director; - var designSize = cc.size(800, 450); - - cc.view.setDesignResolutionSize(designSize.width, designSize.height, cc.ResolutionPolicy.SHOW_ALL); - - // turn on display FPS - director.setDisplayStats(this.config['showFPS']); - - // set FPS. the default value is 1.0/60 if you don't call this - director.setAnimationInterval(1.0 / this.config['frameRate']); - - //load resources - cc.LoaderScene.preload(g_ressources, function () { - director.runScene(new this.startScene()); - }, this); - - return true; - } -}); - -var myApp = new cocos2dApp(MyScene); \ No newline at end of file diff --git a/extensions/pluginx/samples/HelloSocial/res/CloseNormal.png b/extensions/pluginx/samples/HelloSocial/res/CloseNormal.png deleted file mode 100755 index 8ff9369dc96a072c4348179b28a7aa6bcabe3952..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6835 zcmV;k8cgMhP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000l(NklY|>Ct#(&Tb?>N&`y!h<7E+3croNA-0~^0bdPDcyg>!sp0Tf$Cb5;kJ z&MVBnWL{yxyqwnL&SDz&$Id7~ zh^By3lNt3+5YCB$a4eKjq&~f*Y0(uOg=G;-_E>C9=;zw9TJI~HICTO=6QHJm^xiJ-91FE(w7&h+=C1Q* z=9U#x_C}2}p%aO$AYxb}Fp&dStst}vt35%GK|%^8!&J4*BH++T5;}$xQ0j!Lmcn4Tgz_}CnEVez-lCZ7R6MIi<8sh(&%Nmd~SC>ll^tCk%N_#bt=%2V;5R> z9x0le*ZyG^L^UR5GFjgAJ|}<%OI8-(tBM@z6W8j8N$ zS4{`CRz4A=Vp(z?FhB442dXyJ1U24jylHu-TC!SS*;%&;kjAo+v}y&R5fies{3=Xu zdDci5X4hj*&NnN4y|LcN)8)wRj|9znP8}cs5vbf>@#8eTe{R9w*fBfzq5WC!lB0(G zSBcgvZp*Z~?$S*IrF2kh@-#sPW9H_1rCT$~A5M4zq&KB{8FIe@@A;4IR74 zGN%y#={&7_*7v&57GQ-^eXC0D2j!x9dDJjM%kTm%YJL{b3c6wt_CiJsV<3!n>7n@5 zj*hxbxsw}ieZ!-UeT1{SX88YXpC7n!B(jN8q==yVW5+H(o3J>? z!T~7&9s;Grig4_N6NY0Efu{T$hpYSiEhAr=4ONan7+qL@{fxQ!CC-W+FVthPllH6{ z*L_kGZH9mqEtzJ4c##tuS#gOIyQMj}@TjMAIql)}f#k8uK(ajo{FKF}4mM%2i4)^Q zoF*a~6Yhk?CM=dk1b`3#@>Ra4yYy01&*=IBfFYu$?2^VS0!<}RhtK3ZqaP6mhE6Hg2ai9YYdsxiHTW^WpNXdL|}%v>B0{{v`7BPaMJG` zi#GWHLajRdS^4GSYGEdTipHU4cw`(Pq|T!tqoJ!#Z0y9w0QVKVt_VN@Kw&uET6N5c z6Bo0%)WIcAT*Bf~7MBXFjGI(~sG39JNn-+}VbL-e{W%LD1rYh_9R!S5E?Eb-8le-0 zl{7(HhSUHshb%PUtJw@73xr9<^oLF)25iE@sS`H_mP0FcGJ|7}oa|1fI(8xz4#bB& zAWDFoB{b4lV zX9RANcbgtsnr!2VK#}3t2dV&aGIbJgQd>(9O|tv~NGi3EnHrN|saYNes91o+iA?|< zv2a`i$VR}a6DI&UMZs8%GoUFTF;!wA02J2>{w;?lz$1c)youb2aO%V)EH}GZR4#Rn76HV)CaYKxwo;+&mgPrxeljA{m3nxjL`j0(Am_ zM3M>QQUe$0T1%K<&@x=alBP}&Ig!|KoF7g0P`zFg0)cG_I+G*eD-qSKQtZGi!UTX6 z(P-k5eVh8e(2)09dx~kVRg|GOecjachKS`ExswwoJ^@fx`p0rr1du=h1&;s`@c;-2 z5<0e3!)eMwDGREWS@p-S)CXQ#0tH3iTWtuBg_do~5EkL7c|}wVZ8%c3Wu?d`ddnhc zoFNG^nyk_1nw}JSL97PT9iqvn8hB~VY8BK7tN|n<48+d#MJ^$NSG6ov5ppH7yLDf< zyJWDUaIjKx`8LE@s%+!4+dyY8)Q@S*H6iO1lr`rBu2u>nmaqpWwxW z|N9UDIbV~K;ek)Z`}XC${d>VfgFiEZ2mn~Xd0(L=qt&6RwMxBd3E4dPov(bbarp4nTB~pjq?`aGonV~}5V7`j6dc`ub@=-B3uON; z1Vg=lN|pDN2z&q{B5rYm?^i5yXxP#?gJWTq*GeWHP1&Z*u4354mZi_? z(+mKsTCeDvU{nL~RnZmbNo1ilw5;l$UJdY)&pE>)Rmw4qQudUAHl zroSSbnaZtb|?j(Ll(eV6YI-f;AdY)5Gzx2L_M^4YnIqn%+mCr(mN1h}I-gr!;yTzC1p zzc;6?es1GWzj5ZOXCC^FPO2TI(ER+ZPwlvVS1GL?Dw|k)YGMmyA_q5bxTmpj?7+7b zJ2_Y}>Du2vRao}NpWk=r)N^jlt=~P*X7dLR-~Qn*-ul6{-#h7tFP=3#bHPBtCU~vT zh#f}!2dn9v{wQww^o*|Dc|q%pmxe|_h*{=ww(W0mzjKH?@jw(#%-M^J^f>q9^SEV zS>NxLEZ^Uc#wQQ&c}Z!#Hl}*#V9)*7 zKWrafbo#%LvyBY{hnG6#Rh;rFR_RJgDtY*~k1QZ|Ez3Ur%_qPjUL09xB_Ut8x&*8E~tKQI^(;K=A`&V9YPMpb( zJovf)SbWw09P7OCrNOR!7k%u;edk`buKm%TIR}@YcWn{`(zD|I*WuxPvtB=I&0oIV zvxhsD+!W{XTh)f{g5J=b>+d?_>?8<|?>P6P?RrDEr#EzKy`fv_4c)ahNq+rqm0!PG z38{@7@Ye#*@U_bz?p z+YdZ{)5(o2IZVJ~fdq%Xk zv2g$Pe*=KwTQ58#d%W+*B;3hfW>ejL+b(_Ohqo{6-2VJ6+Qg@;G+H6rJMfdWU-`hA zCm;AbF9{b+_{&WGz^r?Id9QI|A#l;UGoLW|#%G(qx#=4Kxc8qvwxa3at_>vIDWo-h`;w|U@9RSGCD^cieHOT+~002ovPDHLkV1nLwB5MEu diff --git a/extensions/pluginx/samples/HelloSocial/res/CloseSelected.png b/extensions/pluginx/samples/HelloSocial/res/CloseSelected.png deleted file mode 100755 index f75c4179a57cf4803549c6739ad2ea0e6186e307..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5711 zcmV-V7O?4wP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000YmNklf@Ue5WQPk(>QIo($nWBC8PsXw#73)BG(fCrR-G9ZB%DBAPr{~AyN z&A}oH;ikxoh(l2>aBM&UjFK{yJUSJR$u;w*xOg0Jfjur;xB%#G zFYAWY`+MfE*wgh7C2br>h%iG|J38vbZ|SJd!Up&v^UgW|&g zn}L>8c_^1P?yY-E|Ni``cq*>TrNc8vHe6Q!kM~c_Et%G!-bgZ0xk}(Fq;iag*q6i? zHaI)Kb5ZT0hc2xB+}K9%0G`YKK+b)uXdZI}&H%1f9|kzmUQYlEj~t1<_`^0c6VKza z;r@YVre_zM70M?@%tgi}J?ro``SX z*b%egbWC2KQPHHissU?l)lV|ExUXO)+gZPIWW&<0{epIIpc+j|Wa0~G_~GlCg)f{EF_QR^Mr4~MLOy3H(U*POeu z&0JcJ+0w0HX^Tj^xgTJSb#Ia!`qdt$#xW=fpK0V}+p!;5dg@BnzJfkAigDlZZ+ZbDOB z2cQJeRfE)5t{$Y8dJe~Y0kMQSPx3}*z^b>q&lET%1YO#EJSs&>0xt5H8yQSRq~Ro1 z(_{-QVB$V=alQPt6P8Olifdju&Nb1*y6-9>(uvV8K4Qq{l*pH2Fak2JWY@_qo;_A% zR->Y#W0VwN3_m?yxKg zkF;O&+@bDi30xtJINn|4Xjh&v(nui?LSO*jl{nIHqP?3XYhOgQw=ttu@V6~lt{s*k zYbsNZcJzFfa)E56{7Q?8e?L@cMrGt#xse7;W{@)p(BL_}^G0N!q?jkp=WFlY+PZvi zM-hOn@0?=sv%lu6YhPvK-XlEn(jJPXGHA{Iqo?`TAH2ejgC_vN3%d^T=r49Lr==cg zV(x$K(A}n3sFkH6*(iKs@5xRYOvK2Xo47aeB-Ke$w(=$~GS1CYhOc{W@3DouPxj1w zvsn1MhhOuzUo*D(ArosHDG*B1SqfSG@*YMHdWV+AT26HrIrLsHpE|DvM+y)EDFx+7 z^Zfp{+vD#1jVMX2uQquVxxN@_7R(%l)3?O%?AYNztC_^bNlg^Pb6)YPQ4M!GVJT0c zz+=C8>%MQixbK!Qig9IMC3d8s)>mk)iJ}NcLXE3PKC1}3Sor$ScHR8#m-aqDP{Jt{ zyGHwBX@iLLwWI2}YTTgolp7=oSPf|GO_81@zIo-OZQs1&yxS?{V|w%I&10t@dFbVR zD}AMgDMy~E{ldm!G8+i1oU5E+Zyf7bx#rb<-ytkZr(BF`O>_&f*oQLq>ge4dqf7tyY44fPkuT4Cx2N=_LQolvj&U4W%GLObj4|tiIOet)=P)?yB|?fr^j z;CboubAWrjAov2HLfY5GA1*QYf0CR6!{qvr$JofN&)Bb1Etj&|>a@_@= z1Y>yg$R4_t&$1EcB|b+OLtQS@`n!#f>LI=F9+&0PY&*s>V2&3Ab1MrL%r@)Suc2JN z(hGvt_XAu8%t-+I%B9oF@ZtZ)@#E|4^=E*czzTqF*vI zv2e;KPfH=Sr4c0(W^q@FGwX`u>B!PA>>n4D?<+ z-7fdHq#&EndYqUv>9=lcYsR{Jr)}HUxs;y=?6_jvb2Ba%;un(_KX6F{proWO<3`&a z{CaHLUwW2pI7hBnam>C49j&%q4Y&-r$^NFlW??pO4uRMUf?U|#EGZP4Qf)eIza7Gu zar+*+ifv;I>HWjL53aB-d@mJmt-!sZ?@tHjgucH3xY)+e7+|$|;e|1w?|(U^ zWHOC@pzZ1sGf*9zW2Ij47x+hEK-*prd|;>l9RQn=T9@*T^j-h}002ovPDHLkV1n`^ B=o

_AOJ~3 zK~#9!#Jx+8BsrQbb|OhLI(tN)aUv^9@BnT>ssg4L2?+vv1ZXn?q(7j=UEJTQ67ZP~-r+?PZU3a~NkMeW| zm$-C54;%pCECE1wfCLY3&|NP;CqMi%o&j9=(-{ZozQc3Re?038pf5mo`S||;*O*o4 zlq3f<0Q9K54(0dpdZ5?Em+$@#|Nd8qqYzI3fEyGbj_C>k08jv+Zh*?Z5%GHnh$GZ< zadG&cf)E1YsMNE70FNd|Da7@*b-cP^DlgeMmd0`)fAQ11+WZzlreVOG?dlG3EzGv9~vJ08HBek}g zoCN^W-kUy?YizAz!Lmo#)rMfREZMEv-dS6g)$(AN^i#L0(z*;dVayW7%dJ?;%lzhj!*okeSH zYPyZiM~L`O;Ac1o0Q?|Nf5g>w&mX~G0>I@b33=v%H(a=@!=nQi{CnO|!RZScj>|lMubCy8D|a7e&$IN-MqJ-WUJG)_<4iS92S`QxeK z9G~DghkI!n-JH0)z5tE-^h*YZ8_)(3fw|$I0v0>Kr8fZ3!Ew;0K+oYu@&XF{yRop0 z9ihyKp4AQZ0W3APH2{M+!hTi=Q=(OXg=Ops)&MGe!^Tl^W9$fPSiBJojKMMp3o8H? zFSZtdx-oXNuoegtpo$~ST380ApqN##DqUcewNN+99)>i-M*+bEW9(?H$~rv@Zx~oM z#!U9ptOrsK78Lv0609!%N;bK#oB*5CQ?16;E%-v&&0zToT;eG7V<;UvF10Eo? z@9Ewwkl|5u;fbrMwQZIH@)QU_K(}(z4*9pR9-a`AYGwmfrDxGp4|EwlBdaB!J(pyO zOtMO5tx5JaY2DVgG`{hZ$_0GvQ-1u-g93(v#sm!jZ^{~;Hd8E+U(OlbwHP3*EGvQc zpcL@%6vR^io`QOK0`EQXBz&A!@__37D`$+5Ur*Nn2tmt0z(`98C;|0^;=#kh=M@?f zqGTL5DTk@wTfj4rVoD_oBW%)+EF~IxFHN_2@4Y9KE@BctcKz55rX!D5Duq%|fQC07 zG_7D-5CTF#LSLZNhgOT-oPd(n69P{NypPr3Nyuyq3Pu1{^kL&E^)T>brFl}R5e85& zTCpNDl!4aF-nyBIkMl9Fi`IiI!5EX8+K+Y?K7V?8s85}HNI2AM8dRjTw{~yurL*Gf zfBCIn>GVpQ^5~;X;u_w34+nv(f)Gx30Eg4vZ&!^j(9B%*+CjT#Gyu3f9RT3BE3T?TryIpN z1($FgKXRu52XGF_IepQ+La#Zc+9^(jbKD`&%Dmwm6z;0QA75nSTnF7p1{y8`=-x%3 zOfwkm2FiK(o&$)hg#$o&e2)QYa{%_`-x$7&_(9zuj$i`nGZ+H|*aNJA{R{{eFN#Q% zSpz7gZq|N=g|)_71IEBugumiD0AL1I1;(0%HxYtI_JzSRfFVL_Tda9)Ads1OViqc0 zY1sn+t8Uh+@IR94L*f9ZqmJuZbL`IE%HgzOz z+js2nfQMIEl4ND`8PQKH+@>j=4{^U6Mz_E?<<^W9TU`;8(mMIs+_sYccEBhD%p!3< zr(38hPuXWh_Dd)%n+4k))0Cf;B`nrxIRj5H1j}aX$wcivyf^T4I;q3>Nk&2{ESuW{ zoydS%3z-Z7?p%72we`ugH~9&M_TGB}8bNbd^>_>))6=a9?>3n?wzznUz1T07s14Si zp-stz3i2KR_1;fVE+y4jHQYx5*i?iz)dE>1o+smjkoYmHL+>e}3xE!=Ho={0J<-`f zZUKTe0c8&g(AYuA6dMr&@=(BNPeCXNP3ApX3{x-x1trs`dHC=MP(R`}KWn{M4J-oY zvEBoZO6%ZwW%0R-uN_Pu0V>eX=XFjq=$;pW=Fgv4Gn6X=vS49$P|@^v09jc_%GPtH zScccZ;u4MGtM+BG*e}0n0b=hdTbnvB0UNBEKf>|ux4-a!b{(_>oYqQdrL@x;8ocZEFE8%O`3aED0UF@o z-@|F3;ha+4H@g2MA<;XCQLf;0*EHNIjfTq~e&CIKc>ryw(;RRSM!OsY1C)cNFDcNc z0qsiG+2x-*K!YCf^((%9WqTht_oBiMUb1#x6HGQ>9ABEEw) zz)=XsQg;#%U@R&hA{Wd8RjsnAMF;`*9oP|!Df^j$F~O|00)l}tFbKxjcfd_qg@CgK z7-QC2SOaksfrMsEfT;+;Z83*2R-24(@&9bb6o?!R=ik~L2HPYIJs|G^LtC)Fdxt-a z>;J7q_Qo)o5;;qwE>AgMHSedQ+bQ8q0+66JQg(K4n0sxWuZ*x6NnWy0Ed!fl$3;Us zFwhLBFat5`-qX23k)VLU(?i*zjYKEbPO=Zt|xO1z~R zDh)=AfdZaZ*5K>=v6R|;?*LiJvst^2XVaxAmKLv z^pu3YTVgRIm}mP$!JrV5?-vqJJbrho*Jt}NMPZjVddDkT#QmT73)!3a=l3!lJCO9a zkyM&jYZIxp-T8<({})^}u00wDD$pz41T{0~-~+=806lf00o7F2%$WEN)>tSTR2k72 z-vAa7b_MAs!Z;_aSrt7GGvZ1oI~GchQNl5>*Z9gnAkc;hW`JMq0;FEzC@{)l{W@1L z06|jnuX940t^!0drxW(=m}NpW!T_2$>@s%+y;1u)X5SAhbc_u2!p`G3)0*9c5Ul}6 zJ6nw`Ve0@NX_^R44Ly%sWCTR9N$nJ?`SOnr?57_oU<&WU=DjyF^ysTA2RkWI9j#~J z&Q=+Xc-QooHX}q6%}a;}rI8^fVcyH(UZw3S-1Z)DVPpDJ7|lR@8`#YZ_F0=M$%BGW zN+>1pqypo7jZq%ECs~9Mh0dYPwm z0PO*qZFczS?tzaYtIF!rEcNH=RuJ7GA9xGUJnc9Z@MfpbY#AZ1t2pLD4!gT#QDHQh zf~xr2hpkATjV5pZ1^{}*(DV8wOY7()A|iKGJt6SkzC~^`=DAq&+p%GGOz1@52Q&(g zC&)+Mz^NDg=~G~!BbIG~O7(yfc*9))vIjH`8V=W8&^w&Z{CnOUxpM&J;DRfs8x4Iy zL*?lw&du2tc=oRP-oW^fG)C)gLaOhtz zaE^1%d#$0-2-?7D6)9z!_~wyjb|n~SfTo6_IR-JV184*EFJCpjeEGWv{_ubxJ`NK; z1A{fNM%mBtdke7lU=P-SF=PMLG8hDqZ4JYb1;MmcL7<$Z%vKESu3)g1vG?&9qO}YF zgoR}Rc}EZ*6ck2THOQG2ti>%b)7Cyjq|OYK$<7EGf%go|;vublZ&Oingt-jLVAN$V z3os%apIlSrsZ3?pR)~b39^UyDElom*VGh_cPD&o`J}W^MASS7i(7xR0t+A5ZOZ_%( zZ;?Fn6W-eI&E{ZFLV7JJ)5Nke`z|{}7f-oOYa{41{EUS5@C#rk2~}yn)9C?fxAQv` z)Mq3Y1&c7;Pe6#7BKxERs34Ig^48B*4oghn0H;#7@hl-^3Qs`%3`4JO)st7Wqb=?% z3glbDhEgLRB#l@zOpn%lv@*1rs;n>}UJ*bDLq+A19fW%#U z?~_8s7Sz-L0DYWfi(Zf+LlT-32C1hLP)cW70AE&WcHZ6@UB?HJAmuv$l;)$;r`ME^bEjt zaH@mTxLzRz`WLMg@FIWsfZr&3;3OeA7mvK>FYZ@3#rerO?uO%hT?bAfDesS+{#iR{ zr*yBh*8EYphP$oeR6L0My=!bv`;8?0gM2$7^6_5#Z+vsPJ#aNH1pQTB6Wmw_b1I5Mjs zo?t(R^M`L~lFU0s)W|)SMskUSCOh!Tx^#J>4W-L;1>L>>8OVuAp8X7f&;{COQ}a!;#e-c% zOJRbEfn1U!e$o2W%fcOsTIi3_0?_mQd&jc0`78@wTShzqb z`&lHXArY?w%Bn%R5qyBy5k1e{%rUTlp-uLy$)ND9FofX8e$!qvx8DTq2>#UOs!=Xlv1CL)=d+OrHLVaCxf^T41(2zQ~N$r{5JA zT}9-mDK{`pf{dc+5tE%!ACG>~spE{`w19f*sV}r0tg?sdVV9`C zycOsUQ@&!MY2q`3yl?@ENqEwWDW#$2RqHCL^l%-Y2z7kj?nzJ%%+H zLh7vi6e9bGo)hs}+%|M2>tmBgOLOeu{DRIuNZh;78h5fY%ae=5t^Ostgr53nVR5tO-DalxcUjU9$9o^rkpLA zdH^w7E`R=pFH)R!^o1yIQxrsM8ZMGyXg@hfS@WXevFn7|KPMF#;0A;jN#RI;55}cz0(18P-^4>Z6(&#`WYxE8$3a4?sXn+e2P;iQd z10BE{jz+tNQths|{(5}+fD@Vq%?Ym2&~S=}V}ttkmc- zWO%9E+Z|RhbRenTMG`u4Gro3iWe1F=JIB(Z{hDEDpZTx2YlpB+Iuu{CY$Ty8T4G!} zBSAB-P>UdzZBlTX{MGVhb9mj(b~=5HZ!T+NipVGU$Y&7IV~{ssX5=Z!pjM@@ltwPx zr&i8tHckHCmpPnh+$XNl1yn^Z7GKBeHK#q7a$8H zv`@2Fj&tVNdk)$vI|G?OpCKHIoAuVP4kT@I^k>`IF$6z{Ru-O2snu_!n<#tG}^$q{&-W)LAT^#i#8$xyLkdDO0W8*xlM{L z0Er1LKOUmdfY*wNL+ep{^0+Wi|z z-&nmd=M`a$9X&zL9&F>mYQK+)9xBG)wGLRj(3oZCkCoRuphuSu(E$KDeE|nQpTQ5{ zhxBz1^yoTtqgohT0%u&HFCDHOu7C!veRsKZ9N=Ad{W-ALkn#T^+zS6u%JT>Cv+lYP z?>-MO9=LS+IpnG9b%!gGJGvC`MFYAUqPGAi;DkdaWj^o&&N;t)NJ*q`!u9FrK16!q z>FMuhcDuVu6Us zietPl(aq^T1tC&6l$3%Hc?gy4`%wq2@SHz0T{$EmN(_xMkH^WqS#5~%y;AXw7`~a@ zb({N&{`&Q65q=_o@mJ56xs$yu+IGhe>`rQ~w$!eEKMiuR;tDVosh#IC|Y|C-SRw`_J0-EL4E`Q!`wdtT~%fH{Zp6!$@OJisfy2@r>zG{fK zE!y_mOLTwFB$WOUaFAjBA|;+UKj8=NG@vw25}c#gfWzs4-y~EAr6DE0=g@%apnEt6 zN6`Qcg{B-0Z?p!7zG}`n9^rVyj}3QC&{F_SBN{3oWpe;1^e+H3xJ1*zX>bW>r?iHn z>Jx8%0C(;vpo80v9&p|D6P(7Q#8pv#r2LUe=^Bcc9`x}53806g;E)aY_uxnHBh`+g zac~r%kdB7T2c7g|@Fe2E5uHkN3P~Tidr=i~+5#*nB?kA&$LKX9ikg#eyNEIE;C5qp z&qR#9Vp-s+!_PzaJI3H(5D4L20vcruN~L%xA?@glgT*@q1XD_}>;=9ys&rvKiUH7vD{Ukz30 zGfpK$mGM)jDS;jJ6ch|?Dh8o>m>3FpN;CDQFT8O18UL5svJ&%xRCX8^Tr`b^&An2L zidZ^qQ22?z;(~`>;ZavPD_eSQscwl*di2I|(`=)_2j^~)tR1$g2?bds!+nY`NRT23 zElRX#wmC7Dhm3pY+5Yg3^`T$ul{8>aT4}`~t{?on=OQfF%pn5uw^JUlXxeh1%>@Ib z1xOoCBKrjqPIY^YVcDsCh7J5wC04JUK`6~K`L16$Ly=rWNB6^-Yj8ieG=Fp4Y!}97 z?(B)=r%d*Hf%j|Rd^~D7oq%X5$s0u!WK>povb4dGT;KR5%ttp_;fcRSyW@=KGS>7v zo)}e&LGD~^ajj^P2*%hfccIy!ioV7-%-`z*aNBPM$`k;C0Q4Qo7{0B4wjX?8)Mu0a|yB?0hQ7PR^5852$nd&BJI0k1P4p#?7 zHK+2?z4TMrbYK^vXO1K`RySB@Ts*5H;WM3kija2&lXIim@FY^FtZkAm_s{)<{Mya3}SLiuJMwXjhUIydB#1D z?-&N6+|JhJY^l$NyF@&*h?d}M+Vpt<2=GwKT*-Y}j*2CpPZ{HJUNS)-g^&ZY-D|QB zLy`sec5Puv{6zn{4?|b>`dLkNM`!cqg1e7JW6Ur|3VQ+c1V+=$iGi=zXFi|#c7)Ns z>MnyaigCqNWNE|{h>KjaBZW4Mu0b+ELIfeZ0JIA!cIK}j8I;)y*Ov(1)F0_1*WD(NVdjVYp>%Ib@3wJfar!*@IL$Hi7+;O7m`duW^@1ggm;Y>P zYig6Q^-$!n=RW-Tc5)v44pZ@VFS4@0oJwZ)0q6~>^dJJtj*CvKxRm6P`C5HC=go>z z({Jn>(V3%YJDdY~<)#kZ6?4pIKA6@|@r*0}cEy+c(z+!N3`9WgJX|;wfi6e;TIyrs z@t=7klazs@p%EW*036p2?h_gTrMv4dS}E-uKM8P-O9$6$JOi9J9H8iR@DdFH^e=$p zC;6gO?>;&A$+=%&oNHdrPH|i{B+y7W4#yjZ6rTkl{2%~+5~bZDeJJ?UP{^N(Bz-8(o1=O`Yb6TXvYdH%qq;6iXJbbmwxG%sixsvY2<9hH)D zfet-1l~0h5X#N20D4YXF-#gdS7eS?PFV`9mZN@)lU=bbIsheeN;GV-@h}3PZ5scXw zIM6Wm9s_NR7#k%73S{hP?ZdF=8iEWe+^mWLv|0Qb;nW}#3^sVRdq~8$&8Bq0V1vLq zi@$xF`hLdXe}hfs&LetOqvH-SkvXUlIE(dl9~*pe04xFM(0w09j`npnI85+yzG2Hl zcp7ZQPL}L@F!aVC^8>Y1`f4rR&5!tG)h1c9;KzgQuoLUpx*7$BEpIs5ni<@b=hD(2 zz!C%9MosPb9jU3q1F=gcyk)T-po6!&U?B6jktHYeW^+6%nZ*oG$LP#45@5xWdop#7 zK<)<)BzM)k5W3c{=_b=OUO$pZ{BjD}WN7nY%i0#BTY)K`zvTUc#K6BLdssuLm2nw_ zx~rnpIJeUw#BXhxmILT;8j_I7ij|hTCUvk**SJhFR&0{TR+nleG+@*49CZwB*SvhJ ztuv~j2kA6O;k4#SB%})r{Wk~Dc3}XKsbu{gFR1CrGc5oBAOJ~3K~%e}1eqM-nYvcW zf!f5&zb_8WkcxR+2GD*thV~Qg{k0gHzD-M!DL>QR)5!Dn4MCuycfx2>9+ZiDmb=bV zz3cS9fCKy-<;A)OI%p)#au1->mrh^e9lFEy5{}_@NjlvDT@VppflCJfCkYK)lZrZA zcsk<>Ts!_j^0NdwJau@&m~yVgj)Lj#0DvDP&N2$1Q_vHjyLR$?=28NXCkZ}?o`di@ zD6M7WwgGtpP7?SD{0u3R`)7#`fId9^lRSUOGjITKI05MU3xI<>uQ0K>@E8C@h>U$x zxG6xXn^L!cCxdJn>L$dK5TX1^g@4se#bm{(oK7hQnXQFwJS3uK+UWdO9J9oaH8NYJ?oUf)u-S(T*D(y6M{ikO z39k=PQ+{vn8Ru>E13gN$?DA904x_=A`Qv+cu+}TFU9PTnwd(fN_8=UbsYE6%$ZCaV zMF9%oa8>OZpVDR$d-iR{f3q8u5%>&)xs&&)KVkW~)nAsx&}K2mg`{v#XAd`I!mXf+ z1#5HkylWs9$<76vtGThW{>v7sXiTOQohJ&qo%idu4H9{q4~{m52iO>dxo6o*1KGVY z?};>y?KoG^Zl}vOZNtQ^|4OZf|Fy^@eZTk1Y+9(j2I=kB&`UqF%|^q$9I?5_s=P_9 zn>!}1wOY4$3u(43TfS}Ewr!VF9Ku?#g+>~b1xo-Lke&V);3Ig4^C4nT-a~h|c0iXO zFD!1=({DN;p2gE0e*$7*b(12Q0Z zc{bEMxm*NN!z-~Auh zsO;>Z7*MHzfOrar8Wo_1&?jm*2RTcw0K~@%bk0u==HOgKJU>I{Gaz1|>Tu)j3%*tc zPdm4VcbO$k3IVq;~)O^)bJ}z9^0O>Salj| ztMySi2DY{+U}ou9;oT6~zU{2O%6>bnnj)+WOB=C$>sOdC&XQJ%zIALBckcGp3wb~@b6%;I*RDJpf#L=#S7B=nj`2x(B4>1Me#VNPfoo42=$#33!$`;1qpb=q}N~CwT}s z^(1i(AX_4&jq~W`gUifGh77(qy6Z>qK5)_UEO9=AOK^!N;4CG6lBZns0U)}pP8_s^ zghtn0KH?hOe*`Zbhe&28Vj53p0NwMyl+ZaIB?PXB?7Ex)#yT0TZqXx$fDpk=#|^lN zk!&BXd>-gph^OQTBf!&V1pv>$rSy*>RGkGEB?KP+cT7KoRE{O0O};hM4dOVG(*t>| zZmFPZ0lb&Xh5CYGz5tkDcLCrlzJA5m+IVB%iX>QdnyU&$_@78c(Ho!JD`t}Y483@hZx)KC4J?M$qa(AyPYcNy-gAs&2ERA@?T z%+4@a?Y=&_mFrpWutgn}Gn>T*49_c-WxEIYXfrzsz+SaCP_&x47ry3|QtT43*+bY+ z!KP5jg`4*v*rj#Zz3A8MNOYG;sZ}}KVTp~&yU?P!*`~PfF0h5Ms}$nCF2mkv-7#N> z?cj6rFWRc@S!SZEyAW^3`L}y4A=@)-*|%DFuL;-2^I&S z97HA=Vpg}v4XcEz7pUejJyC+`!HwP2b=}HqEX|h)pzj@lyT{*NHOIP^!+a~QdOb71 z_RSXNwO_LPr;43z(XO>=n1gG`xzO_Da5+#q3$g$cK=~3bXKYr9Z0b32EL?kMv$8E< z*6yk_bAPw0`>e{}+eMVMw&0rZ(Cr=N9$_>~2dQT~Z(DxM{nDuqpPV2H~!EaJEvv!^+yU#n}H^VrK zt--Wrh41JU_O(KsZv@d%eE541DtBPpJKC&WE6P?`GpXg|mP+MPa4An`;Ltt)SI9)o zM)cT0O3tPJrN`-jv+REP80cQfrG)Id3*-Ulpk>fYK!PKwFVF#f7bMX-5!GCd{yj3F zi)%Qx*mvlFkI?9G0dU4o9UxB!$Q-yz9014;7YX2eh$`pjkk%nOx0Zc(xjf0U{P9mf z4|(8_8i4K+vhE8IUwLKZb`V34JhYhMzd_+ppiL!442{hHbE!jC!9R3(FUmBPdKTgd zs)9t5Bm)9ZB7BVAqoaOWh;y!&5ThIFV4%-R>UvZ!QdK_n_L>q-tjik9MVb+l>s`tUa|QsY#Gk+= zez_#{obk99;L_<2lIyd+UicH2m-EQf@^hqbBcSY|1DV@FOI!hciHMi~Bmro2=%70Z ziED=w!m~7h%LS*X-;ih7{qnI7f@2As4)WRuDp<=7T}+8X0-Zd`?s}2@%mdwgy+ndJ zX0n6+sGotSGarz;?z-y*x=SGY02$@cC_(xNormCt99v9kiJ?V~APe4Dl+0`T`55u* zD8vv5N@yq{gv!vZ%He5zrihF(j(|#njU&`^mMI~kibI8K)Cx|n6j4-4tu_HSGN*XQ zDJ>m!-T?3wUsKqHHug}P^Tz*?F8DL3YcmXO>eg#}wObycv$IFpG_BSHAe4sFRs*bT z&Q%jMz_L>ncfqU4m2GLP+8s07j)~h8Fq)O{(yWz=)pzsFGQO~{=Q-9ESCe0MD5#C8 z1F*#$**O?#hb3uBr!}z5w(EJY(|2~U#cM}NZIGd`LS!@MV+jYdttx426v*kqD!n3j= zXEwqdwRfNG1!mE(?y?6vCWtC7w5?rbzuE3yv8_zBqui{0OA!5b=()YOyRSaBty=%A z_-TlkB%Kb3b5fo}R-YBSPi}T+v-V z1|~Xk+xlbQ>4S_R$2)w)wUZ|a0M`iOBYJ*1$kT`J@?X()kY_xdp%3W#3`X;QAfaUn zNw|TbhquQCge@vWb@5S5SlblNPzZ5M7+Q!->7fE376K~2G0@L91(l*8LJa{7)ew4c zNnfF+ITV|PF2WwpRME!*h}Q^p0rY4d@KVgLyUwD#c5t&nJg^4PZJoO_%OJJgviPOl zZ_Ny*wA&EVW(U4(7K!h^xviZ|UF$ZuUGVbI?nt~^&vpYou&kvLNomY*RFGwfwx|Vo zWT+u+#+aFljoApAUfHME-fP-P?X5j>+9X@6o3cBOP|=L_V-pQ-3spwDfSHT)i0PAA z^NzBb*#QEy^A0}g%Nqv3RvuGl67yPTV~wmRwkln7L!Zvfyv6E=W~bZY_CA9AwMMV~ zJq{Ue2~^BoRJ6H2AycE5*)&;G&!?T(hjv+;wvYcca~qV~*SiIYGfJY3XEfV|PQH)r zXwlk~(iSgb>mc9S`?}umKsoPU?JNw#MN?uIF!VU#P@IaCyX2Na>LhGP0@^6MkTS*3 z)*UY3K^UFR{{;vePVC`~bE%Ht5|^kp?sSrNaLAMFt{)};fCC5g`TPW+`zZ0$b?79{ z-Sr{?JjrkfP+okUY$QvB&bwJl?Srjs${?kwV$0v!t>;47Z1y53* zf9g1ZpP~ElKw*Ey0pRBlFL4V$A5j6G5jO`HbplTiNh~qoZ1p@5K_CdHqbH4{f(q(q zHF}-PxL=jC!$&9;Q_daP2_cjkV~mS*MsNc<=fv|d^Lclx1X~fa4=VSImt`-9)Iq)? zZotzQ@>k+tM~$p-Q=5j{EMU7fKLcpD;ohcoWLvXByG?O!P)93yXqPSIUGwU_vfw>a zpxw}8#(mvj#T!{)SdUKM6?auo4Y;&|;$$YJv(%_|DX7Rxkm92;Piy_5A{*3K+I z14K3&GgmJyyN`@);{n-r-d)*{+++%}n;p^=pw(6fz(nNGE>&_yLWej_i!zLS2^~L= z+r8H8)kCE`m^mlPa!%2%uwd<7HqX3voZ1Zvw=jZ>tO8rWzI(E2UR$1Zg2R-J%Z4tM z)q;Vkh>Nld@+GHP)eE(lpB~+;HZw5-<~}lE)~2sBQ5I<9e;d|(MY<6v@^%JBZ5E-s z7_9C7S?zZK&2^jE)}ZtBcDrnEDF7W@#XWaO3TTPsg5oT>gnsUD0uI0hS`TiRJ9*9U zH30M-@8k&)*Pi7dbq*e#qf+^D0Qw|`22SX%KL(e2;2c(Q{JqET|0++sfPFc~xeRTXicdwD$LU)&+B|7jko<89DBc4BYT7sW5<+Bcj zImiz{-*=adCM)C{Vx*!~!Mi4*MMTfyDAesa-G0nLY)nKPOKEbrCisC?N+GE-M25hl z(`c1DlU8a*IjarmjH+y7#wgc+z0Dx?%3TUdD52i@hjN&*GBVh`G|N5@sAfB<`8I!| z0`j57%8_aoNa$4$pt~##8|V0qyVfT;yD&xFweQ&O&F~$DuPriS%rv(dmy?L;T3L(< ze(P#SqXKnpDx^~jSXSM?zZ*l>O}L3Ly<(VWlXh9mJ=3jOfJdypi}8wCZE?qrIj(0!mU!ofj zE+KiBAZrI5&KCwmEamyY&k{XkcZR-nm!F|8;D>|cBLfZHch|$yp8#2Lve5;F#|82N zeug}w3m%{o1P3B|K7RnvKYvV8=q393ShCIoGQ6d8b;rcN7Tj};of0FeKtMnZZk)3; z#S@|)delgZnzABY5mg>ZyrBey8X@u#>ZaC@3|64?E#scC>Rw}x_;1<2$1Y*?+rfCk7Ky^-O^g6Q4n&Ya06!b(pxKH35j|a#{h!=2*UVw7+8u$e9 z*qi_d{d{STFAbMYYk)&(!113RkB^V)x99%TC(6GEI{ElV_ep~TjRfF0IOoj^)xE-r zL;VUgXkGxw^N;*2b>BH?e&Wp^9vg72E^riFICV`$ydIwZB+nnTQgCXHo=19IT_FV; z1r4A98o*J2N=f+-K-YJ_tf`+v>~26nFtFhM*TOPbz$#c9Ktyooq;3#TU=Il{mqtw8 z7(2o;8+ecC^XUe0WMF_`Hte2;xZDp+ydT1SGxjiaI)V3K7FJn+iTAJ}Kg_~Hg?&k* z@Lcws!TnE&0nUbi+zSTLjKG_1TFm`5?r zZ(&&!?n!jz^~r*!wD(NVq?WR+RDv%<*T(4JCPiePTuHMy%Gs|Bpp+V42DLS?n-P0S z*)Pf31Q`QA(=5jxl#IC_<7|^kgmbo|&X7ee&i^Je-IzR?<(#DM>peW(XxUU@gv2t1 zlpj1i^(mFu9F!8oc)296eNu+tw!Vg2+Oe&%96C5JZ(e*d9XHeJF&@6`&LP;br=Ehu zGA4tN8wR`F`w2@uD|~FhKxi7E@sEM}NhI$25S%q^?aDjt;}A31kHctja84``TmETk z;b*xni?i6538q2P%PO!0-Y!IG_V6SN=)Bs4$;5~Z>E~knjhUn#KHU^onpzTB-C1vI z-IyThi9bQnMsfhoy)-;vVh#zkpujAe$q_?^(z3*{}Jf<_m2U?L&IsH;aYtH zmr%cgb7+c2%76Sp_Z^;lDCc_BoVe?`zCHsz8tR%J+5y+Y(+BzC|LA`CCDG3Z@JIRh z1AqKa`hlZy(BVl9prLw5*{jaMQ8bVZcmtsCI;VfDqh|rI z;wX;H#x16sRi@ygtYPd325YT=u&@vi?7hWjs}y4lEMjODAT$J&Wv~{EF#*P4EdwAJ z6adD=djQJ*tB91HO*@;)DihGZV9c^yDUo^kwQPI-4%f074Q>IZpwfbZt&17Lv%dZv zzI!3|-Pec0I=umaz6XW}49ys*pG;XKaSp?HBG$wEXims5OzGSh)@C6;oze;myEIK@ z;Cm53&kZ-7VU5i-2F)gk;jSgQ39BRi1g2K`7+Oo5Z1XyKHLn14Mu%ckM4#wZYj71lx#&l)K`LNFN z0QIrO$vCNd?>#~jm`aZ`X+oZ?eDWm(#cN;zS-{!DUu|gy4|v~#j=eI00Pm+2P#NBY zrd1ng3xKq#&C|13mKzppr8-1NTvlxD75P^iMe2(MH>;+V4{N##uSe)y88LQ8MtwwP zzG~%S3R`R2is7)8rXpE;+q87_`NLj2%g`d9bfJ@tJg{FL)*E@L*gcOp+J0Xg?Z>ss zY{AOH5|NIy)EzL|+J#p0#j?jQ4c&r1_SN16tR<4V>(ZQ(eMbq1!#_w!@B^MCo;&bE zJXv^6E-0=5x-mkE9+k(P?x556*NZ%#5xmsl3|#cb9_KTc5=csoOH^p+OHhYE;*7KG z!YM!;(s9J3v<}g{hm(%s2w{*?M4^b(rLto1Iw#M6!t-T7&yxRyb8?n%6niHh!_ z4?5g??Ni9a2;}<`G)K>Ix6HY+$lN$*(q}+aw98P>&ncbb7{O$S!+m_h?Us9)R#2JK zWicXhh$D_SlKWmdO5_a9XM_MN-8 ztnr#-<~@0^WeU6MjxEK1*sGjxR~Hi1s#>o9iddt4%cf|*sh_d+b;Ka`556;uiQ->t z%14`xmJe66iGKB)cW>MK_H46DOgNs}7M@$`<*;*~?<@#G+Nn;*zG{vrW)B{{of)<(=$2g`Z>wT;R-S~OUu71e zg}>d)rX$e1=2P?P&Y2J7_1Imu-iTw(T3gYUPwj+Vc8OkoM<4L_5=Za@P7+;*Yfxwa zx(7!>oH7B{4o?yvGk_aGW*3~{K_9>+u076YTza6xrPCJ~qXwc6UNs^v=LjC~&~;Lu zgGY{pRwGi!^#TrD(F4%kfuDh1KVSHdXB~tkQUV3qY#+~w;18?7OxQij!}plTrvaE-<+6$ z&VZ%=Jm6yiC>6XlAB7M~Jqsa57j}z?Rzw~2QQU6N32=+i@pHWQnEc|+k1C2RoM09< zMXey_ygINH)Vp>}@isqM=<((2yRXEWsO5Nr+0?#?<)0pYw$Vnn6?nz4rC>w$j*3xwPx%bEzH7zBb7(W0R8vcO8$} zxh%Jf0hI2+(Cyr%<6SMb=$kur#Rcyh<%-MfX^3|T!2s88^zp1O9q)nz=I(OoE+28d z;3Q+{>>P1sL@l@k4-TOZ0B}0sbWY&A2m0u`?gXI2Q)GZSz@<#wb|#ewrw;YcV|EnTC0aSqh zPCy*vUyXnjcq&ogaYWB!Ozh;~Ip9@s7Qu0{LUC_6bSMh8HXvz;V+g8}zE-!K;Z`yA zz>pusF~&>5z*&nD;pWcijv~YZ7c*ix2i+or)~dwVVi7ZM(ACB3;gABXfBEv&;mg-C zxVPOJME13FPP=##q6}zkw;ms_YTuTx-D7mtk@{U|hOHECt2kz#l`}hTY~PsbE^W7o z$i++xxc?m8D>F8LcDDCH40$N*#T%>B$nL=5v*B>h`9+(}*0x-g*n2v71f6ZYGZv+1 z%U;hHvS*hE$4cbo!EyHBQh;ssZJ9))4?Ui%sY@D>B4-AIP5w;jtG=#@`c zH0bsY;JtNuyCXlZ52@acLuc^2a+mib6U>rXGvnsfM~O}5MbEruWz?2`OP$s%XMpV- ztGgS)mV?I*2UX2lW^ApagfG|8vzgim@?QL}0N`$L3QYq}an+ssRW?t!x=wwHXx3>i z9ONT@y8@Iur!yKEkdmMH`H@RF1#pdqhhu;c0`#T3e$q|@7y0-DK*7N|ce(?l({LJG z!YPic!i$1?fz!D5-Src=#);$li|aH1#}#e{dk-jPjS=ZIBUqF{!!X7KjpjdR4-xPzTTC z(fjdwE=HtfT}_(6*UodyPuk@&OS@1rbL}c-O*|=33wY3=Utc)fL@8+AroIkZCMwHz z?T|^$+UJ!poKGV0I9kj!0WI5NiGD6OVHrSMPy*_Mc-7Zxh>V9)mrmWh>Q$3f+EJHC zQlTI6PRBrKc_=pP&wiG9pLO~CVWd176>p^L2iX>T5EhlXWjSM4Aij{{w!W^!B`Ke@ zZATE@QV^Q5T6>r;WSdckOET4{e?{?L^&(l1CL8A)#{uZ4=VNO&giTBO_AkF|K!!_f z(7?9Ig8G$uXfr!cYDQ=>V~}Yg)Ds^7Ye1C0jMCg9c{`&@O<}33J=J_$_0YSRm&^c? zjkDrYVL6>Y&un#7yJW>S9!w@}X{OcOBDnDY03ZNKL_t(mSYlcjY+D|*@yoSrOjX8B zBlY>^0sd>yK4iU<|iVR4M^kOL`vRJe^11d)gBRv9rZgi;qEJV7Kq zhKg+Tn7|ms922U2jtc6wEAIFdHZxv%6!@0+GB0b!qCpwK7l2S<#2! zhcL|UhXd`G5jnsdl}c+TC`mjm{Etby;2sRsWvGe4~u!?vDL!J;6>D zUDf`vzxS`@!tUw*=ANu?*VwX)8g=_Kj%U2Xi@!l<0SHlGP03}{L!Tsg$8pxb9AuO@ z93tEa=ouHtGcO;*pUx8KE+0E|k|%lepv?d@B%;2e1NwxI(d!NadVYAo!$07i>TiFB zItpVX z%|^AfQc8#sRtlA3od}TyFT4Qf2$~C2svvL_xDDqHLx94l5(%>Abk1>*d8h&LXF}=` zljm^(^9Y3^1I-I~dWxhooL$#!9P97j{XPEQul;|oV~onQ)N=S*V(7ajgeux@@0g9o z1BGTDD%eg!jOC^}geh((bIH01Haic)?Vu3M%)(8~C);gxe%J6(7EAt4@79WxEwQG$ zGh35KGX3@&=b0>cM4LBmyDyP?XP5<7F}t$%&0(A;9mrG{R2FDqOgpH~Em+%5Dt@-d zYL}t&n7k%k89U3^qrO2ZVFH~5~K-*DS|H^uDgDer$0$8J6wX4S@NHN15Ofveva|C zH3xo_&>b#4&;uQ=GQ#dtbfofGnzSAQy z9nSN;dxwVyJUrmx2q+-@tETKJ5qKx@<-g&}mw0cIS);q){F6L?=q?{K5<1s72h1%e z%LWiKAl!(R2WD5@0*21W*JH%U@epCgG7kXrro{0ajuWZ@Lx&r3ZdweXxrcXRLgL<{ z7mo~wj)4r1fXW`NrfUEZsdV5b;w@vm@d+P2OGB(-=y>rgyvr0xPYw=d{!2u*MUmpO z*D&-t9LQbV-|Ok!F3+`-5CXyaT3gFYfD&yHTVft&1^c7Gz6wv9eRkCDc<7#Z3)L3M z=QgttFa32S^wO-bQ2cuj%-DM`Z8xs5?aV#Pqz+gOK-JFD+bq0CwcE7cSfcwU;=GcZ!8xuSK3$E8Jf?s4IF0fP-sjG=T1O zuQ(UH7w8>&3d-St-#&Hv|L!{tT%r5;7a%Ml5kOB5gNW&=ng@k<@9^%g_}Ze^R36cs z(R>1jR*Lfz=R!LdgT){yN}|(g3V=WM-KXRV^;_ab)a0 z!;#_0@L-u4i!;0v0+!V=Q*it|xQJ%!quEBs)p0m;4*>1}PWi#PhoFc40=&!B=)g># zmdmxsYt77p_=+YiU#V%cqfgvwxDQW)V^W)fGK^y4A-+cb3=|PPrm{7^n|{tSohiLW zFPOCS=kJ$|Zky%JEYww-xr<(@Sd_stmW+2bKna=M3xI-Q!C&em79GnxYx~rKS!f4R z&4s_G&nzk3{n+ATIE`Ee9W=y~7!`D^^|qzN=W=XMaxb$qd*jz;MDk{GSziz3;fv1Y zJwQAK9hA+3r`_BG^a_j`ViH+@-w2+Z0q`5+V-!@eL6Q8%~UTOC$TbE1%$Bb1q5svy0@Mm1~WR}VAFgq(FyJo&8Aj#id_ICS`n|*rp zVooY~-B1H(@n0Anj$2RypN`MOenSRDxY-lq>uq>y`Wp1yPW;l3PTA9)l)#kcosxRx z`r7g$%#IU>02%zs1;$r*z$FX8 zeFcDr2M~e>1%;aLi<}^x5u#te;@=bw{P5ww;PP`6fk+wMbOaK*>odMtLp}lMyJr9g z$sh1Qm4XH%sKlg;fm0Vkq+AH4E=oN|<~wRpZUcK980)b(1!t|M zEi(A^n@TtqnsOx9zvfz+10?vV*Ba;%14T|SG$wJ0e;>MHM!uPe```_6Uz__T9iwgE z#g4wt@sQb1M=W2~)@pmb(&jW}`^^-)T_kzt7noVxWH$N96f9Jo#e21wu3fCgmc?ZW zW7C?c^$1qPiqG~bSNzAe=H4oN15&ywf==GtB3(7###r&r@-2=T_lt1MYBkxR3{%>+ zWGxv6M`5`tfbEVaX;KZ^on6lsfo7H?WETQ5JF3u99P^FJSRAhAF0+%gG;Ly_S~ls< z)q%LUuW!HEXzWa|-Qk_Y%q+}U2d3OLvg5*jbYo}MYX42p^9q60Zq!849BiG0x7)i5 zmEEh^#ktOfmGisVF+&%7LwPrw@9&w#uDh?!2@_8+3`{Tv{?KS`;X3Ucmz0Yi^=}>Y z1<>GUoF73$7($H`ARggdcm2dUMZ>w&=%jPN_0s82oO7JcxatlU4Xt~{m4l#Y9yzDl zDXpL3I=El@Pro{Sb=oE9+ylTn4a)KG03=#h-C*-$H-UauwK^1duwV@T{#Obm&;Oft z8d^bXs847d;Lv@_P7P|vC-6i6>DLiGqk%QBD)7q8rrnmK03HB{%5!M8ROpOBy=F5 zyk8CoM@SYyiO^YY_XLi5MKm^32F0Z%$F-A|p|iM6q~s!eZCyVn-bls-tT1eLxgD2i zEt0!Uhy|ZMfsWasgByh`wsZ(RJ$0b5p9S-%_sMc^p(S+&I{ZrLNcwo6IOsfDe8!58 z{sHLpz1^ZSOyQho;C8Ggs8D&m*<(gu*W z5+F09<=W``nYJxRK~csSgnO0(lm`1T+K>$rn#_t|SHcL=Y^!4^;(F-!4gQvHlF&4Z zZx}i~pRLJ%1&7E~9$3l`iGW%Lz^SWZ{B#*(25t)}K}zsBF%0z9Q54-EW4l zr-QGo5%0(7kduI)%dUBLuUH5Z|07`WUf5@4)XSF!XgE#>-aNUB>hvd#j`Js+9^pD% zuif>Nc1kP7ox|zO9YufPKTtsG4&C*l_0It3Kl})X?)pmz2M!0_Xsr~d4*ZcTs+|iU z$!V2A=M%s|{s58ylDb9EJPIU+)|zNJW)eBZoK`RN1y*p*cjItLEEb?PLD1AHo3<6A3^j7lu+gPsE?szz$SIO3G4WL8E z$fk6yq7|YlzD3_KeA0l=rbb$M8vYIdTE~rQz+*vEsdPgY*~Gr+!o1;z_{L1)d&5)w zX18po`8Yxckp!vyWL*c429(Ne>+V3$aoIyzX!z<*)AqtME(_I-z+?d{kW5a91;X|B z4ms76q1+2Bxz|niPqGKiYbeeEvck$!6p-~bRb%h(Tik9O&F?S9R2`Y>T{0rV>uHiu zG1cD3#ewn*?3~OW;ol_V*@VjR@9mxz#nZ|eQpZqw=;^ko70vMz)|fNFU9}AK+1L5G zO$g$5LAuhj`fDB`{h>XRd-#4uFaLAIUF;gj_mho2&ErRW{SvI|y3-S`?)Ca*$e`yi z4xQ0>dV2lx<br`+?1G<-|KmRiRmoLMZX%_;FcAvWI2_Jsx+&JJB7{_kJ zFh=6J>7W}tgirNw$yPas&Jj}gX<%B3Bqq!a;NfBX*MAv%r@JRS{TU~X?i2y^6VN^3 z=>tw9hQI39PCuQ1Ck1(+UtrH*2MM_V1WU0D#`U1a*pI@$0wR}Bf+lg{ftDs=C%8ZW zVL=0cI2bTHaZHpzFNOU*BAR5)6!-CnAVNeS3n7pIhNOX^v{qn>XC?$2+?{Cx&=W)K zdJdY26pzJ3kN{*QF~&pyOrW9zxKFOkI2&V$NZ_1&iUJj>%?K`&aF{K#=Si)eTdgs` zkS4iJ3qW}MmH}u)m+rAaXU0))^UyheDZ84~yScS;r`0bAqREUh{;2$NDDZ$%VX{Dr zlHgPaXgA)**4rM*H};Oh_*!#(T{0m%OAEcCq*OM$>JyqX5^h=Fh6HuRg-F?Osb;JD`FJZ*JhJkP=3|M6FjYS}nh2xz_Qk^NBr+D(Ct8 zm2L%_?FCJxG90|PnGrfmTw2z|=z8m!XaPm@v$oy&D7dX{bYy9d0qQ4heH zr$0Wue*OG}j{shSqZ}Szhei5evdQ>*MTe*E3Bz@G4Ia&}0h$i8pm}K@_d2{jg{Z>U zD_$PwwCtvV{@3)bNmV@k)y{Ntq%%=>ga`(1CcUSz(Eob<@BeFu|M3U@4gg+0PUJK2 zdj0eX`1<(t0zjdEfP#IQ_}7Te`xL=vZ1jAdzS{LbAJx*~x7MIXegp?+LRz75QBZ6@ zqW|2(Sqt>A#`bQKM8m@LaJ_RjL<0sz@uWGn#`JJ84Lp8Ba+6M89wxQg)DBoIG|cQI zJsW^TWwl9)WS1o1rJYC(JsY!F$dugk&R@${lcL3ECp!Sc6?g<5yARjlI{9*(&@>fW z-)edPz1rxF;4<29?ko)RGWsjiPqsi|EsT8Ya{W~A0N;17+OA60?v-WpE(e&qV)M_P z=b{mlRmEhUddM%B54Q@vp9L!|eNve!zAR<)XClC5^*PsXVBW~QTEX&BBk!N0lvZES zE?P1Emglsl>0jEVaCoVur&TlYDnjy2x2(L?OV7$y4mTH}o$e3a>Vu^SSdN`1w*BIH zU%J%2^H4;kpXR!`7ydI`ADa&i=ZCz~-rli~4mHc`=jaTbol-7Dj&&Jt z9(L%y8ISI|@OCn1-D$~nyRYt;l;e5jboXy^OLyAVRrK9lE??iq81!yJ&w%-F|NXzs z;CM#M3lN+z^oPd|81NY1JY*30^W%i4E3YB{rzhYO@Bt5f0?G+4$8x>g^33Egx$eAH zeLXx3?*GE~KjMe&@P{AxkPN3EA75TDbO02Z2mA?e2E8)?J|aNj;PhuxDW6GD)qZp^ zz^90-CxqFD;ymk?7(aP1yAZlXsOKz+)FM^kb+r z_4uLhOAWp`;2s!Z>5zR^I}e7{kszNZjt6B^y*lR|F8m0jKG-g8`I~kdxgNRj4No$v zt!)m%{`EQJ7D)3n|NAUjCg@nHd~NF;q<#%8?O|xlHCt=6^>6AQCIDDMipI);YF#6C z96jd|jmrpbdOL=mOtn@WPwMcXxGO@_V~@4|v<91Lw)vAcJ#f6rJdek(Vdz^A`cL)s zqh@3q2G@1R&kX~#8!DZ<(DSrLYFBR&6ji(%jei?Sb1@>yHrJ34wcOor>np#_hn@~H zDa+EpEQ=;@aU=AZf?pce?JX@KDsA3sL-jKC8= zJ+43b)P3w;0K}}40C--9@Tu3=VdqOieG_e&7|u6Fz=?c=*G^gKB~zpbv!ci$ibBi^He*rM)xOxagFTJ5X2{ zxIVsT4HsRG_#Lbi{U(|P@naCr~(ur^CkDH_VU$YIBY zKx&PC2Hh^j!Pu0(;)3_IN%qVxGWyjEbKB^74W0X~)~R)q;0Rv!q@hFi^|AYK9ROUv zV+j7x2Qc43)vYJ)@Fj zDF=wBH>7zMpK51U^c#^M?bKt4swHPp-c~3NFg!5Ei zeZ+ra++|w92k6P=^IYY^`Odb^yQM6s==AG$H>~k!ziik3-OC58J#ri>uAPspc<0NE zA)K_eiUs*d9vUIcR*+R+qoEPAvzZ`TiZe(T5KYzLW>2zRQyF0e}m! zAiV=j)BG`V$sZm=kV?eR;ZK6fPu<6m*FAj75YC5>5g12@xB!u_K=#?!^q+{!uUCAH zj&&8D(`G;C8iSm5b_XcWJT^e1iqrxX5%6Pl+#{Ym|uZkm6cjN%ZK7H}@$*T5*- z7Z{r%z$x}4M4_1QJ+5~^Zz6{rGfUt;Ip?hXM{7O;*1}FH;1&ij{e&-#wG;cERsv=T zIs525XfZ+P@a@(tF5AvLbv(g79e=)vl!w?O<&c|?2Igf3>&6za+?D9rm;kqT+q|!! z=lnM&Umko|r@W_~iva_GuaCi05%>;__;DB~{q($=)awb8(18(T@q^3-u(x-ixHdcS z_PJpLc2_^k*`J%E>JjP#wS%K9`8|H6i{tN%zkFag-aqH|AUfM^sOirEh$6>&>Gtj- z-?%AMsv0<}ZAdpnjy*2z?iFu!#JoM)12C>_r$>sye_EPFI;G?P_APyfje^}Q+0?ds7HWce=$_QOd3oCM_ALmmjxw|we%|yL2_PkVd1G{fFux*siye7N|-TpP(aH%F^!0Oh`r@XB4zo)_GDST;Ey*?rR{!I5@mg1^|_ z{o8fF+d2VBk4XKN%UzAt;y^b&dPwa8W->2;LI1e{9{%0aD_(;Px_muG^qkPm@ESJK zudl-^hElEZdR-BU*ZDZFS3Ch7uEQq)2|cf1@ho6)8?bCqLAaK4OcI9pg8?#V=zu8k zjp(@#-phe@&6FE($W*~F&RF9DC*6N8Pbj1lI`qb&2YLf*%!_kk1m#p&r6nN`|xYfu(E^ucq!SA54cR`Ral_02CiFe>q_bCVliv2^)760FEL zz_h#xleGt$gpao^qqIZ4(I&Lo1i&Fj*&P!65RbVq#a%bw_Vd-Q(ZHRZl;44SZf~-( z%Pc*b@N-P1XfyPD`(y$a$#>IhvPb;O!T$bE7@D_MrgwT6ONrFlgSYC&m@ON{7+LP1 zYz(=CjbzZ9W5b@2Fw0~Gy_P6Qb`$vqIZAtsz@7J24z}j1dP1t-DEFL$?Dgn7WY+g! z=v5MGrJWCLSu69GeOIo?rgnx^^w+n4U?rMqIt^{G!9z!P53J>ml}0{*3fCw9a=$Q;j16)1{J8>7lfCR1=G=K=ZVEQ4!M}tKm2GKW8 z*qMa*i3kijTXJE4(y%mf>K71M5{jlDLi5td1-f(c=?gn^!c4&nnym!q4%jn+0qzOl zXqG{sX*kV{nu!1*B5BwFASb`h1B4;CX$9?w42*@axXbLn;nLzQdge*+vCa%S_#W6{ zGbykDgug?SJ`W>003*HvKM*~}ID&&_g`Dmx@<{ie=5du-!T2AEIyIQQ1Gnj;)8j$G{{%4!?CN?>CMa?uBeOfC7>& zT`+R?{&4O3!pcGcKAP0dT}Z#T<=bS59GtwGWQL^xz1oPIKQa0EX1`W|r^RJ#dQ@c< z=F{Y}&XL6KZCB+->X)WHypNH5nGvq4cw7`m4u*X?-5PbPk1xNRtIyzZ=)BcnvalPN zTYyqFTdNhIsZGXp$BkPGud*^z)r0(wkF`4XMN8A$J!9oqi?*iyF@YJEhN#hE91;#7z`Wj>z z0XpLf1Ppyzs#nud@D$PW_4P9zI;h7|i@7xco6Md~N<5uBn1fkFM9e)1Ae(2e7+8>* zk8IE8{49;d*`i6oV7&tgdJz^PIAMJHKjsWVY5)UDSt<;~0PSF_XG{R%WB?*winiFb zWG%P{8X`l~#CQ~8m|$Z)*Ui(` z8&h0nRd(YTdiVE!`_IBC@MaD}d#fe=Hjek(1k98r>q{eN|E6g}Dl_665t-~Zy`GJ< zl?EsYpeF#mngnzf6r+khSN528H?&$8Gl#E2ZMqG4)T%G6Ff_oyGi?bF)dYn~{GL`0 zUeD<Mz%E!9T(LrU_GA$6`2u7 zAFMc1am_mZ(1YSsDDuYu03ZNKL_t)GjQJRLp#ZhQxV5ggakk!L8N}h$%A?t5_pEB( z>=&c&>cU%9c_^#C!_#?%UOYScm3)CO2Ym>|7$nwCAat$wd`kiBK@k{F|bFaZr_sCNOH#-5wMeR(vGo%x4|p`XIxhYrAa!uSPnufb8d>u~BY4(Nc>FBpe} zrwzIjx(;23p~F*$?gO4Q#_{^)e;dDk!KsBFCllq3mzkkiGJOePgr z&rvT#0Hb#o4mpE#CTb#s8~2QYX>?DBp3!h2Z6wc&F`V8W0rWZK916I1U;@M1Y*2JA z?o>^yB`3J_?gBV6B%yq2u1c~I(7WErB@Pyg;F_xLjj}ZkWxwCT%^`+xQoV)02G)5| zh&n7WGy;b1wCVmH*KZ@PKL9{KRD(?3{yKuBmjK#BTKHu7s}#JKoewLu3@N;M+O&(4 z{3cB}QzLY1p7gbdmg=mvvr6&VytHUW&Wxy=?R~(am4s{XJ-90ZKfe;W_cMsRQT(SuRyHBh`DCc@F!< z$_@J-#M@(azQaQsnRHcO{$gV+eK!}a%a9mmnlkUauAU=rnYZWThp)u)t@?1ADKK(-S&PS)|Ng;#SRX4p1r*ZTphO~l+nUT9g z6C@gz5|S2XN7fLC$*}_k0y_i(7Gy0+ZsbH0>uU=40S4KInb8pX9?Z@H><9#&*AH$M zau5KAPrbXa2#gCFmRXA&TQ3M;E)JI&2oo1H^ZMns%h-xRomUYmS)jK7)Bz`Sc8&t*`FXnbXtD)eV?2w0i5ad61S?73yQ=KUA7_=Lt*gO)Y*#5NZ+KcQ1LI z4GmTBrVbwA-fzSzHEP0w?Z%j?%dP00d$ zF92vNC-@@q5}7o>&$l(kcjxGHWK(R>qh&~Ly)t9t-++6>ShzJ*tlU?UrBT0nt( zZ9$aQ+}pe_Z{rR5iTiC9`+*l5%lI5gqp|V)C+#CgY zLCE@f56o8x`{HAM7wD^ufvy8!N^=VZ&9b87eZNg0H;1_@t*U$i$3=Uq;!a3vXpe%l zUfv;J3u4DAO41+Ra=mw3b2lX@8w^zuDSwx0PtnUigAxf%1a2r1u8qj`|NWQW^ziiI z&)xVmobYt&Z~{gQczyc#(skYN^%GvN$*xxe!1(&~%g4?<4S)TD;S1asob+}4GJgKw zNB0%uh{p~9t^*z)(*V5#p!?cC)x4i6Ng$T*H)LLbnCAy1LkbAslAR31PO5kone1kW z3_C8!Apzh!C~KK^YQGaxr(U zgUV+mGT9LCZ3)6mDY{$85;)2$opa$sCi>yI-Z6}T07p(_2I(Px+x3u3dQK?a1qN)y z(B@87bY`9NFv9T5D19mE>X1ZuLI(_EAq7%-Mq$u$jJS>`V>q4)a6I=~DW;{ydxF{y7(J1fK0wO*rF89>vHo?-P=sn|A9ex0~Sm}%xBZ+oWf<>r0%Yk2unn=E>% zgkJO5cTw63TB&U+eG72i(YI>=8Z~)=y0P_AXTH7P+q;^ZXZeF(UxvQ>W8LgVhf!ewxi3Ur zo&UpsmdmdZR`%f`>)~A3zHb`aJY0Ws|1zAuJ$>lVeZ=+jI(|ZjuKS3u<1l`X9tlGb zNdv$zj@{Eg4A%kOh+#l?(&)x-UnB7x(DNS+nkK0-ws(`=I>(!VW`(C^et!}DZ43fD zO*MjHoj{bzUjJ4AYW}82S+buKYNvoiIg;Z<#4I2oOL1)w z&J2J_9}^CxiV|Yhga9%@Z#_fj@>{1&DhuKY@hnxH2B)8k&4ALsG?fn)+Y2E)mxXOmBpg)j6zCS6d zjRUGE;Xs2#W2QNNS*t|eYn>Hqsf+|E3jl8cq^*^JudmaJzQZ$&tE(6DcT;>a@}=Zr z3rB0Mz4jGAq9@V!aUR-dauG#yXV{^tIKd$wYf#m4A=HY`R5I}?)pJ|6A;^0M&@}Zb zbth0QTcXW21k_5aF$3uQO7kv1LFN@L`;I}TxrDkhFl~i_w`EqjXY7YF=L54^@e_W7 zXkUNpah@cOku=Ah@10&1KxZS5PB(zJb~TrvRCy?P-=g*8Tiq(HR0PdxleB6}Ds|oH z)A*t$xST3BMY1~I8i3wfsrhXTUD*w2cZ1l~#-4&&@e}Hv5qTR!>lKE^TvK=eMl0CA zIKGezlG#trF^S7-&l=bUfA}$e>C7*{pI^WJ75Iu#cjlMZuU{f0izZ{~K^eR5>6h-R zhw&A|DZrs|_y%+_oTVi^JVen&ft*%+GtvA@7eF9om4aE5hF>D8og;cSsff@46bWEM z&k{m(kx~YU=$XhdW_^Ygf%J|VM01RAC`qW4K>@x7+zhzjSwSE=JN{KJ7osz)K`*I5 zQe3Wy$|#~FE-JhYtv z^f>(lU>wIzcU|{E>+X7W0Yf*?O=WlK2mrc?q^0sG1}4c*=)tcB0^cSQYh!Y~iJ^D= zE_VLOZ!76=cs@b7TgSH!)oyS&`OG1;`G#usAi7crzn+`D--WY!cdOeUA(0OBA63Jq zi|&*FwAZm3%&SB~*Q@6|wAPutJsom`BHlkqUNYQu(eqll zL`>JNs!UOqbEqnSy0u=ZRuJysEyld_vvvSf*oANX28Ryl9!K~80A0k;N}+KHc;!%-wkK~u`uNUV;v6~Y z6w5Wa)P?s6WiF@$Ys~pMnk;fMUSJEy|7(|YL6-Ll+ zP^|L!aQmmMA(s~=$a9j?6N6r#J&mBGMI%qXf~*40ti-w z8DK#pQGF4bC`pYYl@0>2BM8Vik)oP2$+tPlN@z2uHGVGhvm<0qc2o>JvRVchQ&{H< zjr1)c;{mU3_JJvQXC#(7D)Fz^QJbzi%^3PS(7-p#{ffJ$h8+%dW4ulqvNcY6s-N-- z*kGeG3|)BJsqG!aDqp)#qrQQD&iCWEP6^jW^Mc|nnpD<|SuFy_mkWS(DdF@+zQqSu ziz64bkKSN#{5{oHTVPF zBbcE2%EZHKt^KB!hv5n2wVx%xG?fyj@ABIueiipDx%SC^WOZ|WWo2Ez%|&g34jbvw z{#jGR5!L5#yPi|cg-gM=#Al?#RIR2JSb>zvG+;gw-{C;sXNYY2^z`o1b7KovyfZn? zb>Y?ao=xmdN)=V6^B}oHYs3qc&Ao;;DHqCVtJM_M`PGM&utd+2gguD%8naW%(!$5z zvqyE25Qiyrioqih6~r(F0`g3}XO+{RlEK-ipY{d?;f;_L;1OuoEUC5hi2Z zr%%*?jCImSdyT+G7oDD9KrTS$V0&kP5a>-{f;BJ*HF~fg0fIQt*}k0FMMF7jO>x$6 z!Yl+LPLw&Jw6376pl^~&5DP3ZJBLdUa{vrn3OkIs67e#jYNlvfA|`BMi$kB@8ucY+ z7IKv4_-?A?EQ1Y!J(s%WFQ#uWSw!lHSHvR1{1w&q-Bd)Fc<2-0FkaDhIDLTb#)zTS z!`m_RR%(*Z*5qohU`v;vpd9kIjdA@;TOHlX8Bu_740g3r&&ecvJyDB`dV*etL5eRX8~Dj}i|J51rWvOtyVf$5y-DnGf4`=R*11e}#|TQk?*F z5N}X+Dn2UMy+jMP8;_$8VHr9S(Fzbs8XOPNNmHT|6|M7HWbeIK3Ap%@DAhRuuGrsp z1oIPpUrKQDpZ(jq|NbgF_P#B<<7|*zZg;E+jRojdXcHz}^`4e8eL1!@O*uf54ZxO- zi@w;asrE&ALuuq5yI5H&_-v`ww#X53$=~~mx^- z3`wpUUXOVC<*EAs3>b!2d;tawBc3#d&w9`!Iy4=07i;E1f1;^OjWSFenCaAOLL^~{ zkLwo{326XC<^}cze963@V?v7b6Y91AU=5s;-bn-WpT#i%VIlh>@>zN@WTKeDSkM{N zK%DD;rN*Q%DMv8LBTm3c9O5L_4l=AYYze`IqXDx3hRy~eeeWn@WdckvloRG;uqh$x1;Mg75i+I`0VTLen~_4C z)6@vN7ADJosidjzzfvLNY%$VB<;IMa)9VU!({IKcLyzMKtxu=sbOOewaSU1xrIzN< zcMJuqv2SDS+%=LVoe`MyV=;zA2#LCyCQFWcpeE$ z0MV;&%r1ThKvTIAs7_6p?R2n%`zbpPU)~N~+j!K;%r0RSP3g|-Dp459>NJoXJT^-k zbzKe9`(8UJr zx>9rO%XE%wCT$x)`-r>)_)1O+adi|00j&yXJhNR^+D}g2zPut`Sx8JDpaZp~K9#5G z#Pv~9^Q2psY2o2-PEdYpYpm!{9=k)auZ@k_ z1S5&pRx9H9(6zS^pEW}*lV5G&I9ndJn59hicr1X=37|HJTK|L>9#3^4i;Pft&H!Z>35@(KsM z#>nn*yuQ9_KtH`uhi@W)7(){6Py%SOnbY$W;++K0lM{19&vwaAPry3bKeI7s*q4}@ z$pnTWONL0u1^os~5NychA|XhSgXP>AEXEpPAxrdZC0S9xSU5l~0lSKG!cJJop22W% z(f;}TjK-mt$k0+$!Z5>ldH1u^Gb$1%alRlxDG4#XT7`oks&ikA7RpykTsl;TN zh+`$^2>W6xtj$%PDzZW49g0Mty9SsQ8rH{{I(>}Wegh=kUI0v+ZUs!>+6KJeCGUOZ zm~UKtsg($Ht%UYzpFt(wwTXoEcI)a2pj?al{IT1rH<}uEBJJVvT`w%GrcCBwt7&a_r1rryW?i#X4w<9e0+U-JIdw)I6!n;e{hm=8G19n@y7lM0k`w0%~^>O=Bb zsm%%s6ufFZR0{>Ar0O|80q9x9(e6sn{oeeV-|}itxVtmx1AhM%09|QDMds|>CHOr! z2O^I3b^t)meG&mt6UyMkG5un%9p^#e0eBM2G{O!go%k2_c8LBbM;0kXF5nV4fPOCY}cPYxHb^!Rm3 zJ+aZ6E>u=NGclxb^LIEA7m&1wt0vk=h3}uJ=Hwo|G~%!u=#6R!ti;g2{f6N&s^y2Y zM(a*MDkbcI-!kMpmlBS^X~d|T>!{6$vC}6s-8f!YzOJZIAROobzWVSsj zde4^woA~cu61RR)ch%2T(R>v#^I=AOYeiD+VmgJYtS81T;J(20>$s4g;i31VxE5X< zI+H=`I$EIA1nrHkSd*btYcaQ7M{X~3c(-3I>ZrW;+UsOU;P336JIlr@7}5zeZ!4v& zmFL0V90wRvJL&Z^<<}_M?=H3c&ohyeZg)}XEq?i?0G%hgJgx1#-(K3Umpox-MNiuF zI&m9$?shIJNEUT10%nCkwMnb&3*vbpiAY8s*o@R#F7(wB1N%w(QL`RZ6Y|{w(3rH< zH*d%ObFVU$d2KLNZ;=@71L$?QX(iuVk$Dl3;P*ge;n)EbVQ5c6$;z#VV^AZ`HRey> z)pLoVhqTo`0^{sE)@cl%$6*A%c1<^oV-V+(u?UrHM9%dIf2{-V9Ow*KW2_4@gu=?L zd>LctSz?VE5h7*<$h^Er6O1)j`U~jUfP{cvgka9k)C5!Jfa%Mj*af(pxNza9j1TvTq4x*sdwCG9 zjT5qb{wor@2}A1|>^ojqemvtIIBe@3MElxzb7vCHdo1Rsm!Wjn^CH%DTMzyJ}E?lNmfk@;sLCVGZFgUN}*qzrZpW1U=xEN~75Z~z+l-272~ z{P6=$CkzEo7?1jtejLZ^YbZ19Ms3kZL~3#glxL6-MDycl9>*Cc9m!J()^#(Bx#%1Q zAdn>(dJdvs3wusZe9^wy35+3WfS!dIy@NFd7Gxk7*I#JPl7_De8sM zbJ%v`WQ0cyqHy^ky(MIO$Ew7za%mHvf2jUA6`tbwb zzXKgkz;KF1gt0hv1WxEqcpcFJZCbBkayLkshfH9%e;CtC-Rk4c%Nw35jy#V0R25 zu}&^QvFjiNG$I)LANUPjm;C{{S9C)rjDFSKI9~BbZKY`L~>y;q~TBm=p2kWi~9^BbAG1a>n!5>3xYuh zU?vPbA?cuhh(OWeoEcGH9EEo_b3kF#hs0z@2Qn0)stC!<=7eBCFuj#nYH0h*h25_VCL8>)@59h;57~sRiQFH0 z?Y~hqgwEfbOs2n|@Z$%5bcs&RDhP*AJ2<9gT8GmKr!n(`E`=PY1{g>8^`uWH^AT-UVICKrD;fZ_CN!M4nTSfUc5Q?``*jhg2;aROLttW>2SXE7TWXM`fQ)^ z8%fF+OZT#YS5j5etZMujt@eTflv`A4fV%_`e6x~4tI8Ekx&gI`Zg%Tma^W)H=rDdC zL*Kj349;wNej`YegE_AXan^Ll32LaS>2_g39^jjf&$?eR z*846oe!arH#nWwL=tBTnuXZ&Gj@s993o-Acl#iMme6XrZsksVIL8YZi{O>A#R;nGN zV3)&6kNI#oj7;_qwjkE`mg@yzREAE?Pt@% zHGs}8F(XQoB-1#rzWsiBEW*dU^o|63DIU*hy^Jb zSQ0h>03ZNKL_t(9C0R!Yn%I(KfK2Y*7p|;B;PFzgAv2L&lVlK=vrx56kmkLDIk&*ZUm6Q(0K)h00Py{ahZIKm zbeh8m3)7e6zj0as=)_2mqduK5Vr;&ix~G%2xDF$l@A&bs3|RSHU;ftg9On(cw-r4R zjwTCZc!_d1MT#pc}c^wf^;btKW%iex>wTdxj1d7Iss zvvG~@xs(Nf4%g9Ei-5QHhIB;(oKQs`>!ZC|Lqvw`u3#!VSrhz-d+?c{H^b01lMU@R ztlJk2oNqQP-?7@w2zYWbkSl8J_ILUh0u_%%1I^AxK8}-qS`y##2|#!;@OKzL4PVEAXmt1YLD6v?#*xQS z{3Cr6NiqrvY6B)AsU;#A^Ng2&1f3!5`d@`Fl%lr5l5k}ZHW&g4#1sNy1116ma4h1C zv4D}riI4~cy-;JwigVJ0XzfOt_~jus#E_N#LVtN7B5EuVLTWc+{59C7YQKo!6FGo76K@UO0 z#2|qKTbzx(I0huuWyK4k)qNqavgG4vcysByvxBfi=0&(MFswI9&{-yVLdGVD(J`9{E(0yc`7S1t!? zn$0Ey|BCPOJ_gO9^Ia@8-+I5^m`MEw?54w%=FgD9J{yTky94B!yLapiJ6>OU0|QR7 z4Fx0;+N(rYE-}K?aytO}K%B}Bt6U~D>-*!(Z@_3hF97_?V9+1Et2Y3^=4w&jt$tns zXb+_(0G$f{)P~X97BMG_p1pJ=_ObF(5sXX>mfp(m=ntTd}=d;)w97+Pok zCextUreZfG z{|B630Ki?)e-2*{YeG_;W0@dw!eK;#h7C&Jpgds*OClg?B%(;6=d-v=U~7#fSR=y5 zyo7ThBDq}5`I#Ck%n{H!2Voe3go;WFF#44F5-@#8fhiLWLC@$fp}sFgs2GMLfEXNT z^l)wV89eD9R`qr<$gc+)Km->-lY;&PAUYEW>|#q=8&n-ckPs;87{WbK0~VQd#{{r6 z4HFTwkci;2--X-^pd$mlQBYV*DBL3~^QTG>8irOsfuZG~=eR$j zex4yW<@Vd*gbM&YolCwDZg;k|IU|enhqA4iRQTL1O$RYj>sNTPW{pvE(pHEj=S6AP zPF2;~Bh$a_=9i;b`bM7@AozVySFtOK>NfbdqUUmL%YOTrh=YMnOM=x(Bv*0xtlrM6 zE%}O8A&EVuflpnhWIF%N>F1nac+XkVXUA6MkTy>$ez}5}9jM>oT>K%@Cd3=vn!Xj8 zzl7ZCR5RCCYuD!fGf5_d1x~VZMFZ=S-5LO6UP47604J+4%pk~=>G@37M%_Z-bVHKg zB+s}A*rj}EaWQHfut~MSE`GcZ+;FgLBQoRwasWugg~QVG8NCx>qQ<$42os&jl5;(o zfXD$Nclj4#Cyprv{UsumASq%72_@4rK=IOpbsZ$4Y9J+ZhZ4cbT`t1tOck-f(EY3o z4nMdH1X1w;VoL;2L(FWg1<-Re){tnyAyFYhfhH#g!wICnxM-pm_7iU66jz?1?7cUK z(YEwd$#)ARbdd=7r`PxIz!hVc4L6w#`l*Zl&|L>uz~OH|djd{4Wm=Bemt!2!>C*`4 z5vT6d;na=eNsq%f;NJv8>t)8lHi#+43cn8Q(Stb&O)CJM^&5&oYqadZ z>!2-POgp~Pq_kPSl|9!#ML*Yik_n=Z^sDe_;Xy8|rH!uq@x{82beqQ` zs-Uv*+J|@>?+ebXy+wgZwK3JsmWT&@46g{u-kU-pSzryGxlvVn03%M?j7quxF}Shl z^f{C6r^oTea4dB+y?tsMfQt)zy(I=tZt|7ztBOFyXF4=pkkCsE?K56lW>X!Xi`r9w z;_nNZWtVD^)ok*v06KYlv^82fzjd>2$iK_Tvl@bSI_R2G@%3)4$ebfE%7UY3_R;l} zrDr?W3$ZvBVPhad**?9KKqM0-+)T-1n2n)XvMdY(WB(EK5`k$<_HZ#WaMEG-ZbHno z?!%l&-^l(3*lhxQ6_5xZy?})pLlmSM1nb-dJ*0`28e|*5kTjr);U;Q8WQ1e>pJSI` zaDcrRG>DvclQ8btqCsp!n<5DTjuH-ppHpxjLX{y+nA0K}Wl*2W7F=d9Cm@rI>RdrOyG4pyc+}r{FUqj8h*#c4 z)w6J+-mmyv0B8?SQ34qNwAWc#O^CD%M#`XBzp;m*{pJ)nx3-^&uboi(o3vc89`LtT zG`hghUPoUrU-5_LgI&rWv32uHaxHHIU0ep*SV9yH6Iu0h_$ByK&>MCLU4E`{0e^(= z%>eZ6Cs{3&S34&f-lkR@W|^&oB?xC9i~YE20l)TpF2WQGOGCY0<4v;cDZOx#_=T{@ zgUFd~t~2&$0d)*L<0qsOo7ADG(;psh6wf}1x?UQ?*p@GGK-9f{!XVsFl0q~10q92B(A6UIs;BFm-uFaAvj^81_ZbsXy61QFa#oM zIM{B8bI}004>ofIvJp=PZ#x2nVFHGBK~5c!boijL!9$t|L=uYsn1czlo6%%{2_DvH zV9rFA#3e%CT4E9yV{NQdq{s>PeIHwlOcclvxn9C05lM932&IG|GAy&Vb4BsIdYQ@n zMBdnI!{$KkUz~#of+Nazpqm_^PZ2$bB*J0DSBG!o>|_U^4K5r*LdzByFyt5-BcM+W z#xCkRPU8uuu^IJv73c=4xjjs@+YE;~?tnGB(qS_VOcf^heg{L(RJ2#Atnem=rj2=O z#~sh#6ZrN944o+|Wl?ptqYOC$ptrJGs_pLM&i1~=!BGIsdk@omkMfyJ$M>rSAZS7x z^X}&3_>gcNLb3Ck>}waOlcj}J>-cJS?HGWr1B*5lPpOS1B9|tHS+b_r$SlLwI7i>w zo7m@ii_K48Yp3`$>*9vcEdMT4tjQx`7T>PoRN5ItD-F?Tbxs&(+aY!Ly2;qC+8ft8 zEL}AUDArCv#w6@X;Z>~zL)2zCU%oa_YEclz ztMX*MVx{Zd*!%g;~68EVm7s5d}$e;y|m}ZKW7{Z`4s6oR(2>R|Lunm#o z)-pI?^kNad2}jqv+o)J3KK#yCZrnkJ;*vrNR8CO?{hjaw=z)I3x1@o7 z>VOko2V4i>iV<)F^eLG`2atRMCJa4Jc|OUSW7K089XoV41g(eeaP3C8?`RSa?QbpF zeQg(B?wdOpk%SI6!|#?BhS6r5XDO)Y+dMSYN08f)^sdBYe-Gv<6_sjjU#pKH^&Q!< zzC{(UW)8nh<2_7HuXVNh)*Q3C(%@&ODLL7x;(F)g4xhV`Znppc#Za}pIf`sssA2Lu zSE}pvVGC&EC9&eQ)ZJx|TCOqjNaQUi;6<;x4XJ&J7R4_(^Z8FM&(Odh5F_6jANP%B zv^_s|N=?l}VMu6wxvo)4Co4m*D)3$T5&^2R1q7Lq_Ac?b*mx)u&l$^_R0M5X7S+YnsOL>2-(6Ii5SA^_I) zmyj<=pyYH+@eyR$e{Y#3~@pZ&F;IW(496CAHO@JxApF#sdFPG2$N`aK4$s5@1#2lQdQB}35QgQzrcEUVdUIWnu27}{?_w7u{- z-T*N7${YOlsDn)$FN+hW-Ob;d?6|&T7+ucciJ5Gx`-{~*(`wd&-kyzWOM+I#r*8?M zfdtYfttKM^16{|^Ir}Or+^FZxknk^Bd%bm~`aoH!2LeSY8`h0^1wgJl-rgd=)vNqb z0A21gc-p)hL7tI|P}ks$XLmQBoY`Z#VkWSkreW`W#BbHR6jiV#h$~eUZLBl9^#JOH zhn=tB7!PRGrrV_yw(WnG$`h~3YR`9(!fylUihbjbHo^N_Ur_+(o01=*ECk47)$bNd zYmZtarQTmMSLc@a8Ld;?N@XOj55`hwSC;tr$e_Km+E+kT{NoP{unB`tX)Wsz``_`! z^$R=#pmj}G7z~Ocg6jjJn}BSNn)>K6Vepbg%Q?V=znUJ2PVUjC-=>c{z=YrRK(wWB zrg!n1tO-8G#aB;M?)nu>_KZz{&c*+CCjCE*vChGm^ldL@BGALRxd7`e3@i+s>j7(Q zACKQVxO5eLZ>9_C5k8f^y$8@wr)g~OK4Cs<3){z5g|Ws?Z?+LM8^FaY?X%3j*c8@G zc7lCeg+#`EzU=9ih2LACcT>ZnhjZaedN^YMSh!E=t3RO+5$OiKbFk*cxITR!D(xQ@ zIquC^+RaCC*`3V3zyLq+EAV6cARjxt0#6A4!|N;1X*`Yil+g5m0nwwQTYvtF>wrh# z3Sht^@Zst4E3WuD;!)%JaQiaaRG=fP(5CA0p+r<_O48Q;T-&w~k#>vn7D$Vh z%kNm6A>XmFb>F|z_B(k)#=x5mj4kxMbz*dYUq8axq?_B~*xrI1Xsh+*FN$Z{S(HjAme+8t0u~bmxpwj_yj#i-dPC@~l^wNjOYce6OoD50h`ku%}OqX|qGr>}1XPF&BDIr0E7}~*I z&;Z6-`@-%5f;~S+X@((=HHAWrg&}GBt8#qVF8dB2a!IU4#NS@WI(QW zGP^1F$ra@pfa@;;n2v~?>j_P`zrpA_#h6o^C?w~h4Ge`u zbxIE0*j(b|0*yYoh&TjZoq|leR=W5%zysfbN6h9MPk=#GbOa^z01N|$A^AghKQLmP zLcJ3?y-;z4cyJ(++1ldjI^B&K5B-22&26uVd=)O+TU{zQjl#m9j*}hIVvBkHx$4uQ ze5Q_G@dK(R9rkb8%aeOQv|nPTR~&%9L36}UagAf%GMl|gDXd4qHD}Y7XOm~6ZBZ<1 zrS*=!yj{&$r5kjsQk+T?yT>epo~o0wWOxk^@zu!XWmb7n-jw~Bd~bC|F6IiB?N;}9 z(pa~*1?G{S4t$S3*f-}#O5Z*&wf5GQ=~m~_py59%NTGurN8S^77I>?zjVWHFsH`99 z{1@7LU+M2F<~ToIy_MpLc^{Lb6W}K}bEut`tVZ1T7dju<^jHiL%LhBz=ov(a^@4Co zSdGg>y%?fK8V>pjB69sFY6!-VZ33u{$S@rF#YB_oKtC`GgqYAUdd|Gv2n{iuO)2Os zjGpP=pXtT2V@uBg>4GSzrTgAdV*#F50wMI9lbdx9;R~2&4?BX1b%CLU`iQ(EB)8~$ zflT3l>?9cY1>e1(<4(#CaRfuDa+HbUS_lF$)(DHSXNmCIA}P8-h4Lm1YM~nl$oiG4bKqE#HUK2RhBf8U%v1e8$cC4TT|?Um$-GTc6gGh1|4HJ`hrk4#XtPD%P`= z5O1zJ=%`7^PdCuvj?^@%Rc{E8Z`sC2#fvU)q_3=q_Y>lLtuOerSZGy!ybOUHB?i*8 z8C_nxG+vEMwblFN4~<$sQ6(!O5hzd1uRU000u4PEC2X33ESATct)@!T`zl9r#9>KQ z#@zyX`h!vouU6$Q{&!Mw@Et|)x~BN@HyTNi`AdW|lheiAVNB$hS-=u%>If#}|D`Yy zQ|`&H%rO@0i$33RHM23=tX+09{~c-s1Gese1xu6{ujBJ528SRyflx~PaMF_y$iM;@ zArP4}H4RL#fn$(`6QDSlk+`!O2VQ9Z%mk-jm{=imZ&6YMx5lDW*a+%TupfM+qqcD_-suSuQU_(iQm3Y)fnilJp{eGmdF6K zpGpHMMyo^&O=aNOgf-$~OnX4J8^&fTMkm)AhcmKpa>7WWPrnRqEVfyy5iMo05xq$~ zua|ok`~2YAFNSZbsdFGoI|r_;N2vVCw<>pIpT)3=nrwHU50zX#DvR+{r0DapW>MXz z_jqW1+zN1$Ebv)mV0FJuZxoMY-r^pmPob^@Xw0@lZPgt_ZNvG=&|&@iMaw7Tr~Q84 z?ruz~V==C%xqz>g%}1U#wXx}V z)HK>l%}oWFdCa>Z=`{u8@4?V35_;|46kIqG(Tf!9Cm@5~ITk@5#2g7U8=~~)ek%Ku zjjX!x=~AFb8Mf{xdU)cP)8u5$47Pd!1ok5k1R#>x=Y@AU^g*{lL<~m|IJpp=lmD~e zOyGd08@w2>Afx0^bD7_~%%b6h2ZKH<^t{6mQ=vn$+xB&!~qY{TR zi9}+pQ(!w0&F0bo42(boLZK*=;TUiivX;z?xCD|bR+ZhD}J{#sjaZ|;uLam1PDx4F*$34*d z=;wC?(E65>M)d^rDpXu=B1`3qv3o%h`<=^CtBM}lK8+cU?6Ny4Hbv>Q;G7}}o9r9I zeeC8WDLjY z-TXm|8rzMONgitm0T^Ru)cVOe^ycLSeesTX4zW7W!lcvgVJ&)CeENjB;4xJGP1S|5 z^bjVs7A%bEowFvLwgX<$`3K#&>-*kWYhbK_ai3g2mF~?Km(K7d)!)r;!pqAG99%3; zjCT#z^t~%9^m^ykO=aQw_|+SAfyPdih1tvXQ%h~X%;Gb1L(O+0VQUBc=rI~R0iU}R z#0@+KpgiC;l>G&5G-d$(n#ndE@fd#i@B!#>9q`x%JU)CKuJ{~2 zqtQHUt`Oc_^&orCICeK&dF$^olc=&f&lbByY)8(sy&pioJ?r^EL%i+HeB;DK(uF2b zo*cX!*=}ChZo}-Z&2OM|*TSw$3lLyH;WyKJ${M098*~o)Sf6t(1c~cia4~D&Y~FVF zEdsPF+y3|N0vn&^`PAC^lJmv@mc5Mjns@6$qI^sH!q8yY@74EmD#Hw9V%h~UyAiYpjGZ~`axnP5N?(qEb=H8E#2 z4f^0wm%Qyr;#V-3nVZHM^r2P{fb=uOlO94a=l`F&x9O4`N0J1E0g&pfZlEW9&9Y|7 z`@P=I%hsIwwEO>m#$NWA_1;!lM9dPENmF&eeGdwd;Fpm%l6zs-kOz001BW zNklrXhWuQ8RmII=4WNrM@R7XcdK`<~A0P+A2EOa7j zvR~f3cnYs)gurkBSV91iN}qEDAq%Xhw!#WJ=abJQw`Z?KL}m3$TCP+orx(1v;cdkK zxUOZFeT%=uyy45bXT`TI`W`(pA&s1WT)Enz#C-$p)LB@v3H6`N^s;TVXc4D|Lgk^4 zwH)bN>F0EdExkd2rQ6g-Mcu5rI*i$CaZ3;Q89j)$?IV@2WwA3=oP+tu%icKJ+h%!3 ziER}*ZHgk*q)j)Iy~+J=k}%eP>JF$NvngfN47AOCf~0Ukb6#xE}$(l)@oc<(R_ zA^Z#v?o#VL4TNy^acRlyCH;OeKm(2`ng;!CF~2+>^J1`rmWx{;Hz`t zmQSfF75R+0z1N&BJOJSRy$sW@Go!2=^Haq!>(9^XV%N_+^Yb(Q=^4r+ukGue3->(# zUg>O%#nlcYuF89l_~H2}zfB+U{(guc{}FA&A0`sy#&PoR!$j}hO?iE4)( zJ7UU)boJ3H_l!Vr@TZ0GnF^q(;3ZnBmNT_1`CW&}k%KUN1`~*~*PH$`Gu#2J(&Vr> zlKgrO2pY5p0OUvmx3wSfB9H-~0G0v5Obx*iJW)gQjpc!XL6r3vm#O1T_0SF^`1yi{ za&RDDDsr80K7$zKH71aV$mzkHGsPY*`N1+k8aP5j!*C%w!x0(=frywT!*f-V2tefg zNs0g(AfX0<86fZBPLQClyQH5H0y}teg@=|R#a5cxyBx8uW_2%)hy)Fw(rTAOaI`J~ z#wCE5M9&CqZUw6U=^PQf$fc@NOkX}%s2%nFQ~Z06_bc$jAqDx|qyHoNHUsN1WK#}A zj3fH~2|nwf+ZHh*#>vqRnw&CAI9i3#Hb(S4Y>zlHs_IjGVq>ntC&y;Z5mX>=(+ zm%*ueokW@>Y%Nt)5t{|8wn}QVYo_-0XIe+JbU5x7d#vDbWP`J!KR^1i-NU7p&8wSo zr_Gjj_K}Q`zNxz4Imyu)N<|Rsf z4FBTEpNNR1nTTO#=D-=CXFERCSu+ij-SR+LwKBkYHHT(RZS)QfAP->(i>|3s2ooVN zGe8R2&kX_(i?BaEQUW2MZec9(jbPzM&xc$tBI?*d&XaHh0G_}X=+78(HjYSu2&A~E zgyqCN8%T?&3WTcP(~=t#Tq*tvB;dWrQ;}8J4SJq&Ffhjan=#@#BDQ!%?13>LMzkI+ zDhwUVb1{W|TeMjca=oIru)sCK`iK!0w&`sQ5qL)g%pQimA%u7&PgNem(2ur^$ZEY= zA6Yg`HJgT=8!P*x9vlZKHXSeoXVYN zW@it(qwT@kQ!MQUBC}fc$O0d)-qIS_RO}-ZGMXInZSU)GCigd6IY#rXnJgV@!SaW` zVRV$hNZ;0Qs_F5MKDW4fKaMxkz1;;S`-H7v8k+(3eZDu5l>THD(?cK?IOXVL8{ib;aaavsnQ65_MhZ=KzqVy$CfNh6|v$ zFr!mAmsQK8zQzLv{QzpQ0W?kaoS<{*?~q09M+5@z97_WtQl~r)L?BNbX0*x#q6RED zoxuWOavlxAogkNC$YC{bgrI6^kOLYThCmI?z*iXOS|H9jLwyL`FomqeX5D6R*xA&x02=WZ zyqB16+h+qiyF$-BzJ%F`;|jc%ACzad5$|IbnP-_p&-<;mJ3eiW%Dp=H5N%|zU;?E8agAXVlX z-Azvh+^%7CONF|*1+AB(!LCY4UCRD_o%-Hn61wovc5$0kH@c)XayA>FRuAL^z@*NU z#oO3@-t{KHVwwM#7NYqq@iw+gHhU?idT+HnLx%vGx$v~BN<~@&Z0tpZ>eqg)H zH?Qc#Pt$KYKg+>T<^bx*8f&xL_hg|%r=N0I_YeY$1IRn@Z0#H{2tvkcnP%QBQhvJy zsVqCD*o~~sI0F}Om|00xYY3OlvjD6h7cJ4bTP%wTwFglWnuI~80__M)poSVR%)+Ig zQMDEvAi$Y$xr8AQ2;LKUB2obc8p1H35y&OyCn^SI#_0qR3mJP%9_L5AEV879MNf=vF>ocVPH$K*9TP`#OlsWmcl&pD8VS(wFp#{dt1VFqjR zqFPyV5lV2z&Vma9oO>bi`Ko9V;iTgD>EEew!k>X0*W%9qE(BaI`LhR=;;FPx)ZdVt zb`_GgWmeobZCV&zem_M_Yq?9t(&t6pU}qz zhK@j=QF{MWe$xUGQ4b)(dX$F3cf4l|&AWB;RDtQ$^82BEeA?J+4N!EUuCA7L_Cf5fAYvQ^*67I~)Q zOS$sk`i99{m)2D5pA~~OrMa-Www87#`?<=v-AkCsm~7cXmhu&`uv-C08I>tbYgf0! zisdwjwDA2^u}CuO4$?Kn`cV>kj_IRZ1pi1eXU2o(K0??)YP)uRFD~q55||}Zn)a8I zZ>phvfI-trd}UX=6W_#plk1MYfHQ8 z$~10iet(c8wYW9Y!g4NIbhaXl1&oxpu{S0l^;EX7wgi*dy}nu8<}PdTfW5zqzgy?n z%pz2u;l;+77paopS;Fx@fwN8z3m9+m&_@^2?rqM#X=^}$rOsMdYpgW~m)lVHqNH+Q zLHJn+#7!~fxM+HcE4~{GlZ^pD2oOS*L736)q<(fF!XSY^lY(-80=W1(yJE^Dv({<& z3?jG}5Es%KwXes4V2VKcrb6zVoh&YrBgZcS=cs9fF9LFN^B*bH#U*6xi_@t@1~wTb zhmhN8R2Z%Mh0}?{l=CM-t{HY{G{zOH1 zEiB|;KqL)2I*BKQK>j3#N$U&=3^pV2>~kN6r3Aa3&$KLMWrjEHR(Z;T42$4U)7c|vC;G-8BvupTx- z;|!mAT-)Bp*n3SV1mZhvbB#^Y%qBT@d(U+r@vpdB5vwLjyN-IzYfGn;nKdaBs6 zWcCx;Ct3C50^8KpC#k9pcl#^zRx_Dj;lqLTG`TU;&0q_Wl#)qi)+?oCt*v)$0wAro zl7Wpk1Br?;4nIZa#KqUEqR0QAZYdREm_#o(pIg|LK8 zKFIPeHMxDmF5V=~26id&BHLtl^yI2Zx7;+|Fg`jowB{Xh_=6)yWiUxVK&nb0w7M3x z4>YIaP}+2-V)DNzguWAr^Q~O5#Xh|M;6Yw{3JdH6WhwJ83{1q?URr37fs~I|B%QhW3O(y@oF`&xh*`iO z?-g(}10e4m4?#Z^3y7F=_zTFtfDneyq}w6yL0)w$5C{(x=v*Qo$r}lobR%_F$lDv<3HXY51sp796KGX#Xq#Z)qxTqr=Qi`iUxG%U z0I|UC5gb92W8FBbGTJFpr8ek@G5gt#xJLB0{H}#yKnktxlj|yK4Id&_)4>}f^xovU( zFnPo7EMa6FIs13y#%s*W5R5CB%rI! zyzUBP6RfG6kSnJ#DpK9Y2bG=MC`r4@j9GJGWEEs zbRgSZXac}hY>L$}S-e^Z&{s;p0Q9|Os3I82w@Q7%0${_Dpzk!zffp6 z=S9P=GxJT=tNOxHSK5FC&H;zY$U4BkfVDNSL?;dyn27*K zB&-+}VSqM7ss!SEQvGys*VePabUITr2T79m+<+W72w42-OvJ;_0Yv`%Qk2<5x%*Qj zT&Q9Ha^?#Qe^$gy4Z`r58YhJ8{Ox^KZ=<{ssWw9@=fSB&;B#aFpc&=_CaNu@2v7yv z6W)5HJ_{%6uPJwMj2Hoo7$d%p2xE@&er>B8s)cDQ+l`rNUM3Mv-x^VbF2rJWgtYsAQpz4)&5U@9^{DCkQ^wC!UU zIz2#1q#cyDhJL*KXsd~B*I1h7PkuN-^BpX^&MWx+Rw-JO^e7~>DxtHeW9Kk+#_?9Z5epmUm57BW%LfdXpl3AS8^w^ediu=C5SO5JcqN+~uVfXKc9>2EZFn2!_ zZ+H`XPuu=mX!5Gr0k;7(ULe^>1C(iDfE-Q)$q_1Cj2%2p4i5p-pJWEv!)77Kr;Bo? zH$+)$6w{Ba)-8-B0Jw7|Ujfk{vOr+@x|JQKbDoGq02U&E8U(?aG7biSpuk%6!%5~$ zg^3yk<->yB9snM|tfm@E9(kcv3Q$0k19=e7Pw1I|&yCk!;67n#pn=rbIAR zL=?Z1ff)dE$eIl>&L@Nh7)rmOho>1p0|>()%mAHFK$B(C-hqXMS>R8^K{y2RXKn%p zQSTAX8f&O{Ls*0b)Tv@z+XsnAn1scVlPMwx0^xu_+D({qR-~l2XGad_^!EV}=guHa zVDTAr6AQtS7Xrp7;45CQc)tRD?%{h@zIjwU3jkLj2DO=+XRy9S-(wu1=_}9A7)Qi$ z7C?_NJ8i@k?F69ptA9ct5uec80;Uo5!7((5iSHmSqU7Dw*DE06iIUC4&U9IQVq?sBxAA?ZOE=mF2S}IzdXz zdyW|?W^1@zaV}!(gerFa#$vo072W(gX_keg?aQ#>ZqzlI^}cl5!B#7tCwvB)TSHSd zBy3^TQnmR|YmStXHD-yBl7R(*DzQCp$TZnBMe$xT5^aKDD!YbMj^EZ>`x*-$?Be<1 zO>jOkPN~!gcJR2Foi|K5w&h-kAE@78PHvfeGi=IZB^@K+o&INgXNFk3 zf0=%EZ3DBViFtG`*eKT5Tch7=7jKR3)Du1wpVK{P>@0G?$)p>^b5)LebV$;-nR0aX z;5c|60TOHVlwRNnbk?J>!j0-c2$gxgl9f56P>L0u z%dbH7!DRVzHfJDJTyQn1(7j7SA{nX@2y}vE3ywkzX8PpX?{)mnRmi}u(J7p9+H0Kr9avTGrs`NH5pLXd&8ZiRbfLI{4RZlwQn|nOB=zTWU7>i}ch%D!53RZ3> zvRT6j`+~?v0Jd*qj1kcyUZ-rr%vkrWZAZiwt-e5vKoN4hTl*<(5(-zQsgD!Gckkju zL1+3H_q;zz7kfLYd@uxadEMCW0icgU2hBk@pV@29uQ-bN_0oYj1e<2S)tueU1>+96 zLCI8oM%{8BbPGLGey*{!|CR#FZ*zU!G+si zPr<2*sIImrxl(U$2WNh0J7M-N>yjr*Qb=7X8;Hl^873+i$9<}%%FeU%|1CuecF`Cp zM`fFoRM0WqRSDK)eRP`Cy(=J}u+E0qHUgvtF}g?qOtK(O&8$5ylyv~mOjD-G zMzaFYG(pR>@iVzG!4xW57P$G5HjPc&h2Au@nm+F;HE=8+JH{irWw>FweM36LRiQ0y zFU*c3(eDGG^R~y>4+H2&A8GE}Al6JX?afb*%(V8~PE=YNqO3_T=9Fw_*`y>$#{Kkv zQD#slOste?Q{0tFQBEuko$ zCt#gXnseuMD)o9>O5}Wj&J$m*N9DZ(vmh|}vjB8Dd4Fc++{Gv*6@21`nc;orw>@zX z0@3-*B;*O?$$OSS*&`bs7={anKt-%TF56dA(+oT(0{Ws_A#E-s!ih>VpD$+#2q0q2 zVc-PNFfcU?I+1TU1R?-_0Ow#Jl|Ez2T`w6ZbOr?spFu9Cf`^NCCT3IYK|nrSF2bLQ zPQsEsxu*-n0yt1J!{~)hJsTh*N6xrx9HO3maIstWYKYLdzS^& zZHp1DYh!HH)eeY_Z9b)qUA#5lX`<~?bO4Gg`)>t*&e4{kitp;*u?%@}U@cc&W_L%Xa${+3m3O93xqz15B*b3+R^=(MO$ ztjz4}Vnw!(jmE?()m8VpHDEB?D86JTQ;3gwFdq%jZbq(aee=qdAXV)L>EZgaxxM%< zS_W63X_tX!tPRfh%kw7hTWu-pXL>a)1BRyiU{gb&Wxc>2N-&D$!OC56Q)f4a4nRAE zY&QW!2COxJnu901umH*#os%U@+FF=($dwF92Pxc=9)rDmsHyT;Tp2K?2d8H`P;l5g z`inbTPq(CE5L%&U$!5ggqY>|55;AEXLcj4XcJA?%9@)gy8=oC-`kMxX zbbz+$fgzw|*rF0EC}HtHM+t!FR7qv5SWLogImiHTUA@=chE zTl3aBW96zrfI8V>7JG2WCd5;J8l2Fr6jKGdK_g&LEIu-}Q?W8}6L8_&{&+s~Fdzg7 z{L2e_m0)-!j3EL#saXVza8M^@!inhR1tH*P#>vd9PJ3S+Ey6H*7Y&=1w+4@S!CC(ybrz= zK-b-eW{0V@+pf8ElOC?-tZGHvXM}l(H z{OFfC!1IDT9{v-JmiT)tUsZ*^n~q8CI4JXJ$u81o?9_}_c)-Irm0gRCJ%&Vm9x)#LC-5uY##0L3x zOU(i`+SN8tH?dnL5(iuw;5*{ge3T3)KoVtx|aya&+3F-T1^3sVHr zsWAaaRup_JEgsFWBS5Ys@a+KGjJl%90Oh&0SOosvr6UhJbfMb zX-Jh(LIOJB z^_waF6e4CwlONqQL^Om8!7&L54G`5kWDPVkb3;u~AH7Mrq26|sy(x%@GM=8cDFefM zNcK(Rz~o6c0@Ubb;YriXfOno7u&^i3S$`7pGaEm<;yI|H001BWNkl&N|GSA6dfVOKvlzfDl5~Y-DP`m~WH@Q#gQ})4dl$_OPBW_8Z>b@L#T9z93!k zb_Fb+CfGazJ)Wjql@`xEzQi3;S)uTApFKLz0&N3)0`>uPcHn4>9Y;2b0DeG$zkWh* z0gLvEXk&xcqP0Mbwg>unjjgse#@O0E7H4SS^;5E?eW{*mA8GzI$F3Ad4TV(`#Rtk* zi#bcGY0ErPG&kRn7Lc~OhsOYPcZ|`y9c*pP!yP2u$JV#)N15yejxMfR{U-kIi&)XA zPb73x%HpY%SPg15oBXrn*ecVbWn61j9OPG zqy_q%6yKHpwgBkbG1{t6M~3{fzX)LGS1ZMtEQ@BI1=tlvmkBE;Gi#kwTHD_3GmKpo zrnA=_T&XxdRtkI&K%2*^e7i574oCgsN?O3$w5SE7WexCm_)3!)<$Jx{IyW?*fjb@- zcD*m$@k+Yw{=Rz5$3n|fl{i$NcmqgjyfEZ`%3#Z@sTo1J)~sA^vaETcq6f_88w0Au zJ1oi)c{-t~9dJ4J6%G5!>{*s9HK~JMv3h`ZE$$B(VWpoD5M&UL0zxo=DpI6!ZdM4J zV?eymKMVP@hXaV10TJ&UozK~&j^LfkbSm?32}Crg(D`y<=wCfxV)cY(1~<$q-T;v!(z8KO3{64|!oYNz+62#8 zcfkP-Je^oVLDd2lgus);{KXSNf;jJlLkYAQvU^<-k%w?8fh?=4g6ew&fOF?L^(71? z`+bhZNpQfIIQ|VX0xh0;T#*IJPi>ZJycYDVe|c`vw=)%e9TB6_*7cT72X|}>zufm| z+rl-^`VAmH<)Fg0B6Nx^bn7(CrAOb|cD#ldV{2QWjSXykjfn4P8yg#}dUuFcAr&7W zp^tBDzH6>@yIaE4iER^mdq4|TFe2G+Y7{)0q`I5u!5kksHf7`w2?e$sQFq{yz3Et6 z05*G*z54Dvke#7w=9|^e&cIHgDoS})X15F8#%$t4(oF_>vC~M)MSjCU*Bz*9XuZ5X ztVnIULA!I+?6Qe#KI;bxgT)Z;9_ZywoBHyC)VH9lYq$2+WtyCN6%6u+Zk0)hZ7RCI zmhPu}#qj%sC?n=F3oQ1bY3{3?fOSfhjopMn&Afl)RQ(}0l$Km!WNuKzcVKtx{z8!d_p#{{6q2s~wzj_JO9LT`&&8i+C4*!F$f_whPL z+qQk%BF1ZP@fs1|U_T)?3+@?PQ>$C3j?=w4x_bbS+lS|rd|YN7TEd&|o1%i4)SBC) z`q)=@6WxB)SUMdb13 zD%_LWwKwf7Ir)0Zh89{bToyLXW?VG|otLuAjvJ^((@wd=6@fRUR(#+(XU>@HqOEEV zGnj*D;I4Wj0xZa`eZ>}^I#n@oik(4(EH zW{U6euw6CY)dg?; zJZYF4VUR~TS@c_T2k#6uzOi93^zvubF;jMJP?IrjzYE1_Zjvzsz~y4*L_y9zcVTw5 zo20xx$5dnXyqn|!lEXDh4vT{mNO64@37^?Xjb%m9kX2>)V*#5N{`@m z%qia*s-nt@al{yN);9n=eL_s}3owD^g@EqMzCHP<|&E6xV)AV{111*@UtjX*~e5b9J z(jvG1F5J~t+vObV}qe3RhAv83P(@H zl6e6)O(pSOV(6~IDIx+kNJvT26y{Qt*NT2~7H6G)Dur}THn%*=ys0t@qNmN6s#5A^ z$a>qbdlq<`vc8;3PY!fkU>!AP2Q{P)^!84RdzyAa|mF`LFcJ(l3GDfPZP|m-tKk`+wc6JLLt1<~b632)R3Ov4vF&4uCQFF8lMDr>c7fh+&#( zScDkEg*h;3eqd0=O31UaLryjKlwtk9pAa+v#nahS#`*+^_V=-VU4#URg@<9Frhz{z zzNe&=j#MsV(Xpq1XNRw7H$Gah~q%?`L;{a5f!Iuj+(~0nKSx)1B`UwII z0ZlnSB*OXB34hKAUMXfz3#;!iAjfc1$=u2Q8{$X_bmu0c7VW%bB7^|&fb{FKGTs8f zQ^_v*@wvD=kCpDZokOkvlOZ^Rg5MBBG$(b_g%VR3y0J{4W+t$UBRWhem>Y=^YSggbzn#cTJW zTmFXEkEz`!Qnu~QsaQpLI4{#?UfI)9&XNAH=ouSo{D{Uj$NKX6rOdsLkTyG+w6prn z4jwie;iYs;vOLJeY%XGF3RW%vI+@~UXJ_bTcVe?QeUWQ)yf!~xAv4uqCJUP3aLz^C zHkelZJb64l1fbJiU)en9QlWZvW2i*91yX%GWJ&MpMAF7ZAyrLvTjtR00BG!XrSeRx z@-Z}&2euHVxz*F>$tuObx5)^5C<2|T$XK%X4VNLPK#arWV5Zm zw>GV{xG5!B+@90ht?w|ogNx`Uyro@pj8qwMrhU}I3ox1&ZhFTs4(^@1rGz6OwvpFUSpfj79(bzJ3!0E{}?7xN34Sn0=hd%-6`@X-vj%|F8zrG>qH}Kw|X+l%99*UzAd zwH6sR6X*UyfrwX#R|Vy<z=aXA2{gd)1PA=(0st>( z030s$d1nqKXoZTPJRk_1gGW|BtD-~oFq1X4h(hGNGGs1(P^k#c4lIL!WgsDP#6-F3 zJ74m$Ye19#Ishka!4%4o>?E`8NvSG$mzC~eD1$?FCz8V*vlu%^DDIiA5D^*b;~4Vj zeFI?e8@z{pmPCItXADT@q!261j^}c#!_B;JD%P^Z@>Kg?Jd2%rMIzs_anfcxQA+|8xS?#pIH;O_1GM^Auwl0 zx$~JrzyNN@pFL&Vtj&T%M0EC$0inUbEC2!#;pGL5lo&!l0vzRk24t39LGX)5qr&KX z!Myj(oCCeju1LcL1Ql=NQW6T!PXFm%UIZ8}7cTD0Sxqwx%nSw-Q`Vhp>{>(}eHF_6jJ^k+&^H)I zSml^C#JgWQc=Tv{v?JOcZHsY?t)_YB+(E!%%)ZpIxwf{CIpVv8zMhSUEgag|#`tOw z-?BP&zKz#LR<(hKeK_fF{|0`1+S)CCZMy99jFy%#F;!INBLDZEor2x)0p=Lj-iEUU zJV4ob;sCtEBBDQ)r-H)ip}@Z+xzphU^$U_b~o;iEqLlpt1|n(r%R=_Q997 zhv2t+>=nB8G-Pj)p6Tv};UCUDe;@Q*kL8End1-~WMA*ElogM2KzxC|#&TibmodiuL z5q*_=LUjs^n>{yF@4!LA08&!=l)2IY+2kRY&nUZ_IY8hL=%0I-r*>@7+xCYa+dsHy zpV6Xy?pxKgjuC(Rf*&l}=Zus3SM(PBGy1;2j-#qn@der_hKT1jbCEsX@k4{5!K)h1 zNq|2S51NwAL<9j3L(K+zB5nkOA!y?u&gU$r zZW?&TpH2`$(+occ3P51EGc}TPY9_ahj8I*6*%KhhaJkGrcOduT<&yblY8on_IrlGW zejyQqSU`{=3=HxPLjdJINa36zICvsDpR%J!@g|%B2LO2Cpj5OB0U+m{@MnY}w-V0U zb@k~$CG03a3xl{c4lagXgt>khfh%5t_a09p5OIyL6U1$Sn7yBsZ`QBpXN)Kh)2_dE z{;NK#?}30X5$_RJ^9aW(KV^d2?GyTlHYcdGtpC|xVDO(U8+ITU4;6f3F`pG z%H9V_w8U2xODR=fS1xxyc!cKQ)NPZ-alon9xH>&NMbmvQE=~P{Q`ex)b@%yC6>wfi zILeVzu@bknPr{tRT{Gtv>k2i)W*?1?Djuh+%ghT))=WS1L7BBCgLV^qdPll-bEncTsE_$ICnA&w=TmN`4nR%^M zyKFw)vjP96DDTHc)eNBjI{@chQ51+WhJl0nQRD$I2s|cInOF)b?cg08zDQq4o}Z*>)Jkl@(iHE7xd5g;|~}k+8*sQ+Gn&Q zA~J@Kf5n$^CKUVUlClBxBk*57VQNea5bw{#91w&()W`zLo{K<)&O{&%!axKG zmGi*ar&;3}X&6H0*)Nh+3;OR9AqX5fA`w7@CXvfe+IUw$rhbPoTm}ve@w`!?BH&he zH2wRFG@KhBfdND1R1E^TKfefrFBi>-q4S9#Lnx0S40@1oEKLU4ED+9$c9n5w35N#; z^?@cLjUgpiaxgD+}UTgJ5_O8o1X4?WIt`Q;NwSZ}(oN%0U8gr{65D}lyNBwckd#~6=3m~?+ zgRr%THn$aK4m-9_K8v9dTcGbfB4Wflu5FfSYGW2zPAT0qouqq{?423>wj`R5(Q|eE z_8Ic+gt3uC&(+~?^SOHv2u!nTT7Ujst+;FobLnv_>mvZ&J+>Tdu26csgulAxn*;9Z zY?4U^J*hafzi?R(PMcUvTdz@eEsRd!@=My|Zf*Wmx!kloGd3-Tx|El^3r|)6dSO(T z9<`57X3y0kW#@&29YL-oEUBuMraDp0zb`8}d{D^#Xj*U;nPNU}M)Q#>6fcxeHQQIx zlgvUBZKpu=q|cSPAT?!w{cKtfW5xu$s|1n#Y^lE|Y*J-_`;f!2 z!ldAsPM`+D`Y|X&=PV3Ij_j5q;h4V@==$Xgu7AOM3tWL7_n#vlZ5+(NI%2fwGc@ltQ3d@| z+r~DIvF&@HZzCdNt1X4DM`$BPAib%+A`ueTVc3Ta_;!6m^IrW)Ex7g&*%5~3hb906 zlU8Dm-Fa&(iLL>S{dnQ|8z$YATU?ndcha`EPq!ag6}J6ick{`&CB}46l9Xe)$jyvk zQ`gi}F|$*da)ZufR85Oz!I~pXvl=0(DiUjPdeeKig$Prq1`F)QB4&EYbaT)Hl?}*> zhb|2CWPE1K&Fip>p^q1PyA7wSZ(7izO|ROMrsHAo=yJTmU%%t6Gs$Sy<2CJ(`qTb6 z3#JPrEtAQTsS}wFy*lZrypwkJ__jU>v!hEt@_{t63m|!UtL$JUzNeYEi-M0@Ja%t! zsbua;5zrPLrhUIeKA3jCJ9_RuY+L=U$51=qED8!{e{;Gn6PlwyF}t(-*ja<^H=e-l zmdm6Z<9~S^kH2KP55f$j*fDi}*q}M^(c5I)YTmRhpA6sk3 zIL5#ICBA-XH9~npPh*StC8}o_zC?@|N5r4;b;R{6iXOUe-55*lef~e#bm};*e2M~Fj9GWJ>S^{2PAVL8=2$92!X9;|fqJ(b1MeO_YfS*nv z!DYzSCBvYnN}2|jA>&{@yBDFC988!GhbMm$83xeFfhcp&4gfiSZnEQ^13+iO$x9fZ ziQLj)7+69>XB0O-mP?s4H1v^|f{m$JhJ}lOX9$5mi@Is+6<7U+W<6#+4G@taAdo_5 z=PSo(U(_6~)B)rT*I&O}@ctEP^2F%ZBR;lMfH%@sC1NGU*s9<;jBW2>+csiE zY$MvfkG751@g3aZ-CA46Pta{?m&K|UMYAMuYwWZOmd&xd?GYMHtAC|6C3%RU%}ROP zP28USJyAfHUH4X}vfC^-={O_M+yk-eN@3a|h;E(ajrD6fr1SS)@aAHkCT}piSQW?s zwkV|MIF-3-U^W{ByT?GM1<_?Q{XAL1?QN@S6W_y8xf+>tz(DI;r5v4`52c{>iD*pb zASYfnNn~t`$ zUE}NVU^m|na+W(Ph_rK+5AW7}nMYc-v+g9p+utstJ1$(A{f>;C4~2a-!}8>F$}&4y z+Ozylp!q|}knXpz;AZnfdSJb}bq=S&w<_ppep6?&ZGZlr{**p^>9?^_)cqNZ$w(pl zy7?Ru4Nt`Sdnv7fGfg@xU}yAwQkZ_!5CHh+`i|v|q+?L>#l7v zR{&}l(r7LUvFd|8h5=2JRTjgbtSv5=;lgzGxk1o-kbsH2$5{hbd^T_6kRPKw{h1t* z1oibRyZ^J#P8}0k)sxl;&S$8ynTUu69*D@D&jL_GIKz<_Oc{Qle?LjX*+Vc0{MixY zq6W{N0B!UnTiznc@NB;~&^hy>Nm%3{J zBA(g|c|*uW3DrZ7MWpfEgCYaW%Uq7K~@MbNnwKiEx7PdC5UDOv~E!dK^l`hrVMQL-LK5CD&g!V)E z-e$`~Z*b5)hE5AqmMY8BQY$y#eR8iABh}~XHcOe{mS^l@p5|j(y4#$A?x3M9?Jt1S zU(K$i-O-9__vzlcx;aa_%gUb`SXG4EI!NiWOQ*PsuUA}n2ZA)o+`CE50-P0TxLDsb6Hbbi0IR+gANA-uaLq)ECF7Ii# z1hD-clhcE2s)$Q$7wwV9MmS*RbKRB)N z-Vh}B63U5~GwO1upv<9nv?=XnJv7aRcUkh9B^>VMC;#vNJ@tRYk3SZCQx9<0x*y}U zMf?)Oml%D9Ll_aqShJJxsWQqQDqB;+&kzU81N^M1Am^KH)NQ@2t@;O0B~lV zr!7Io(36mdG(rWC`1Km!fp{&WyqGt`Wwfe*I4he+yaK(l)V@R#Dtf*G7C-(GuOs5$ zD+sO)g)!scae~g{X1GVhF}Bg7SHHTrplH@P6#xJr07*naRH!xFaB_?uXC7Kb9k7V8 zZE87n+qO;HyD`Lfgiq70Tss(~w9w=c2-cQHrHLllv_GV+OYiH)X zow3<`W5aB&)`Z&_dh5o}9i{;8(h~_eucX^sE^o|+-KwGPsQu??>Xm~v@CZGZzwWdW z9*JGkzAnX7$a1k~s12bT7y!*gLfbieVf8*{_IgMYt(!2rt(IL}9rN~W09xH`HxwbE zvliBxluYrKu1?_upm~Lmx`hINruSsMs@dvFtr%$8A*s`G7zG{bMRqNp&0}Y2+c3&& zxy=l%iYrB>wYnn=SugVz%UB!i1L`Bbcylv$T9Ys-ZO~0O%azM~(rxmOYJ<15Awicd zb+s9v*_&Bb9mYq@shI^qHdXP2$LN{5YV_{4EK;|yc%W%8-q>QBor#UMRuS`5EX7z- z)ij)JsR2F;pqFRl`{%8EPZ74+NTAKC1;*^Dqs<1!8|>ap2Mo8J)821?7GBAKW-mNL z?muLCONmB_u(&$Gd-@ut*=6e0Lw15D4^n!P9K^r;l+4rndxNikMf{5R`hy*>=z%X8 zEnU&}uQ5b?{fh8cgulWLg;u;yUS*hqF52wwn=$lELQht{Duy24->uPYtK`HFHC|?b z0%ucdDGa)5R+x#v09?rQC0)EbR z(b6dVWq1$IAdn+rR#Arvk0J9eMVLY493&{u&0v;>-RY$P_!6@0!=J&q36Z6NHaij# zId~5chk$|6uy-dWf?VKU&~O+oL^&mrh;r}Ylp?7DXcc=*G&9OSr))yW$&C4t;xo2Z zcNUg6&|Ci+e~oy(Ry=SIJmIN@?aLI>;>RAZ8N*_X=vA3B;;K@MHWSqfj$?`Gerlnc zE$e|E&n@~EW5DZJ1kZC!3T914#?Uc0rvh!S!QNR0-9Kdmj@DwtB-HMEHy=rCb*I<1 zJ#2ivzJG!=D@v?P*ql4G$XW~L1ySt$Q%@lK1IZr46m8HW;^@0=1xH(Rj!*kxsq=Y#_ zC?yz$$dzI=pGbk}b~YU~!rSSM8r>GcH zFq5oPjgF)#RVm9J#6aiYcc8kd)ojiLR!N`bD#{*retVMGMqVx2pv~+RIQ0~07UZKO z^y;9$Ek@vggjt-~?+K%Kfc4ZtdQ|>6o{#TGswcZw^}WrIFMOX2z5H2S7bXF8fyqp0 zmTtbfEQX@-RS#%n@h+)J2MMtg0Mhc;x6cE<{@)0HMfig7*X!56;u;Ww!sT)NYa9dG z=j{Cq;2QIHui$6}eMZI55zmNYMM6(JVqfg-UYn+C)DKQcXb3UTG%P~rb9U=1YHbD3 z0Ej%!1R^+xQ7evQT2F6%nt>Q3S$Hi+sr(}wy>F*ZV}u52gD}EUq0azV7I8k=Ipovc`ZG#%$tY_2zdxu}G9gj1|C^NAdzBeUH#yM(G_CC`l>85RijAofH2um(lxYv_0A$ z;}^tnj9=s56iEkI3-sCV`D!!U*BA6WJyE|ibn0W|r&^`0 z7+SjtJ#w#GX_mx*EctzLvxkO$l1AVOCx;-oTrza#Iw*uyasj}docw%oL~s;77m+j( z9GpNf5J(25hBSGQPEN8dwE6&&T#DVYBH_yg=kqN85E|Vs z?1b32Xj^3UPrJw_R4m@YqP;?4w2z1uZB`CtMRe@@A7Z>B#u%?LzP3%wHXt!X+qZ2W zaeckoPk3$cwr4?rDmlqMD8HLyF1VV-626H}u*Wq{lgz5RdBcc)f^obj=Scapo4YKT zsR+*9ypj(J><(2NX(M`GolSE*b*DRawznX7TFkcEzar_*1)ury-2a zp!eau#iI2}wfFh@7B0CqhcGv`5FKodU(>$MMOFhSp@cwiW zB((Wm4fXD5n3p~+TfxRoNg&N7ux07$aRz!ZG>o_x6d!0|aR9*yJkU6mLFZ^aQtRQh z9q`;cSXfjC|L6by_J@Cc?>j``k1zP~PjLVC!@vD_wHDWiI7V3Xwy@3t*H>JDEAWGg zn=P)_*xQm{@r>vGhrU-EXpPl~%2r-`U@QRo%QN~Bz&N7s@dc)D)&rV601iULS=BAT zP!J&jB3X2Cx#WOurKlme0DW~R;mANw{OL1oFjOs`VJ`R#O=1JY5{vJe?<#QgcZ~x!$>#u@W;O$zt=c#?L z#}j}a*SPHSixVL{|H}f_<42Fz7V#B8R%@uMox<|*3$AUBFzj1=3E62QMzj&Fe?lA4 zqE%;c6eL~P=@u5gsGn5^J)(7JZ4qIkZTr^s@p>%`HZq2eBO=*} zcCUMnHpWu5QldLR&j$yAu z2{f^~$LM*(SRTT&scR-j`f$=3Zo=MvW70!+AAoxmZDAIPq^Ukr$Hv}#qlouE$CNrP zCt!2Dv@D$R5^q-9d&YK$f3d{}x=034!71{NxP;9SX4wWwWnD*8GodC%6F_u+vrp=_ z@q=}}+BJ{3Vnhh|<4fzGV|<3S=pC-J6?8TTzFqTgaHVb8O^_V_oCWp z^`4^vfiD*hfwJ0IhVnNCJV+JS3;~FPc;{FyV70;y>gOH!l6yllKRt^?00gdA=#X8U zLm|Q^GdnPZ7Ks(EirUE^pkU!&uTARTVhe<#Xm?W_AT09ssc4WZBpnf3{P+w9yvFPd zt;(D@SwxR`0?^_*;yBKaK#p-PxLg|oq^nEfE@;Ax@^E@V1T*uyntVz z-`l>di@IpT=!;BGpU#S`5~~hHrkFVw{1Hh}5z4(!xo0M@t4?J6DD*>8i;L@9D|Uee z8sI%Npmhk}S#(&T=#y5y$FhK9?D^uY?s{Zt-Xj(U%vfgLpMz1f7jG;}R&*Hi2${s9 z7W943d+-mf-?7BdVRt-5rP+tGk+&RvSxd}F2UA#@WfNhUJ}+D98g=!ii6C9mCAz+& z(oLeF8morwa&mk#x6#AYBn+lH>cvJv;6W6U`p z#N}+;3wdCb-0R3=XcTc4%7uL>eCtTvzaoY%79DQ_=;B51WLKyb!@Xd@CzBOmIy?N9 z43tq`tq}~Nr3fi1GE0@4l1$cSrW_QwQVVM#ETmQM{l|O9d<9^t?|TI>zk+k%8}PR1 zC1#^!ZV3;->kI%7W6v-6Ha@VQ=H-nu@C(QJyj=Cn7=E4s^ow3zuh4Ul%5rvI7LDlV zzJa&Xse>Kl0kxv z5)L2=HsYV+;t6v23dl@RzF_(I<;~g!_?P(I5u*fKutb7+m1p>}JRWKa{Rj9N;Ls|7 z;AL5DS^QU$QAR2FIf8d4P1f&v+8jI=l!zGcsspg#n5b1qjZagXhYyOhR$Q#=y(PfE5kdQ z;HhyZzA3xjRu;P2IRSUgvxx?-yw^8FT1v zg1M|AtyY9I3jiGJLE23p;#?tw8+3I|?@nO&OenTg2N2Ca~TCOrTX2R>H zvJ>m}z8{x)LZXcyP2I`0;;17V-*BM@e@p>(Gi36_-`Vsux_xwTpgfr)FJ)rxm2Kq(o zc?R^)T0bqX9yu=>S3qMC9E_va*N{)wc`-w&F(KoLc1dJlC}6@<^yw2q0G3XPLXH{_ zf;H1*iEI>55R&Vhcg~j58YLvrBiU25u6voFOsFh;e1x*r=cEY0TJ-{Ygz_bfQVKv# zlQl+2X+6CyKqpH?UWk4I=O=Y;vh_u4IHvRaDp*@U#wBq zSOE&k4ewirh=XlBG%xRlgzy1`<**w?~QdkNWth}=v14kW&96k-j zli)pPYeKkxO)t=FNiq+{eE@icp--GMzARW+-}fAxLw&q|{H2IZW|{PY-GyJfu$O_= zw03|a9ZU!6b~zU8i%D?v9=j?q?-niA*&P_Fbg?|rt*Oqqt*fS;wn@# zT<uWUF|opjR_CK#%DL<^`0HhCrljGSTj6^n_ilF`#+i+s`rRhoMVj9FE8k*CZ?R~u zM$g$=Lg!p}pnkSZLZ>kFvU>$z{2N)H)%D$)e{cO*ypGIlj~VEOVg>15?0S@=H5RQ_ zxR!zV$Sg;0B+m3Q7j_qSuY&_?B5=ED2k}7m0JL-H*m3v$sutO1d8-vwal=?+*k20i zc8=se0{t~r99?^@@W$!sIylG5vewq_)>Ez`l{88?Qs}bJ51c$9trV<)P+kKOc*@Pm z@@d`#D9@+j-F)%*_+eSl|BU75*Pj)xPw2T19bEJReXZ$d0P~Cm_=(|FFAU4SVf;<` zO2i(}TzgwH=zdwQm;s#8zv;z0HYkoBfYt!6r+NPJg|C|4Fh&Rq;B=y|((5sx43t?b z0<8`1%hm>_*4GyjpbQZ~d<}{RGEe|XNW#lx&50!0)5#`hWD6qLlXrCn6zq$#%7Bbj zC;Q)D?2CVH@M6SQ84)}AtP%mTS^!?vR`!0S#zeRj}Gn3U9z!f^%>$;qYQ;jyI0Q*YL#z zZzl26IToyX=&OTYMy9)FUI`s)1AFv6bVAq*TNg_Ls0Jb}4WMVf4sq!hEF7)<&x-FpcDq@ zDiq9Z620tA47wGzU@gwG2UjzjOiB0GALVmSI@c1g9r~6sR%j@K(+i5ai_^1aBq3#F zplcr^t3F^qGoeGnagVwvLEgw~U9~hHT9#{1`37R^_6r3_VT&-3uY~MU`(ia{W6{Sj z{i7h5E}OdD?FbG94c{?XU&Ws^O_dF7++R~}#8He7H!u#2MbS80&$BB_UTX+X$EwTb+PI7=W;R?j*64Fxbj@tEg`xpQzX-Pzj=fiVY|Gy5 zTwO;t4Cp%6b-+|FXdG5N>J+R{Yhq!0m%^1LH1*F67!sYPS)^+4Y(aq-3?dQ*0)V?tGR=Hs7 z4~r1xU2JxO1zDql`ay~{SI$^S0b^r|hyXo?_Xx1~N)mtn8%KWwd4@c5tvxQ90rVW_ zZ@?MQm44%@XTJQ5MPbq49Q-G64e(y}d|AL2fO$8wR}XFU(l1yz&z$T8pg8o^6OdYW zU3WUYtpe_>n|SwS3YrAti}SLcWC4P;FuXg4h}G#iD!*(aXNamevCf?NW?)uUvNpCr@*{22?!n}*hSU1DlVA6!;g zze4b3!B1xZF{SbZ-WLpXpuCr5K@xI|!G5~;TIMkUYd(5AI~FPsbz-Lbo&$>y`RT>E z=UC>sU$F3gnZ3Sa>3NTST$FzQFa-%+Vd$y=+vMx%heBpqRw~7+;`rpZz`A=&kGU4a z?m=t!34G}aD!NVp*~8F3Hpq6z2iqG)&Y#+cidt;v2i|95DpQUD=xCpW%o|M#^u`*h z(j_-&D!-Z>DY}*_I=>>HzkL-;)wCuFdH7~+AaujgbyY?JE6b$fs()9*uLy@I)IfR; z--XuR6&BVtJ6dN=4?|Z4i`e@UOdC6ybL+In+?-w3DWo1Ko6-jW)hI9kU}mG?*+dJ@rpR2?ponN6%l8=%kU6bW2KWmr8uwaks?RG1YU8#7eLJFPT zm+%e+pWStET@sgM8J)v^c(}uE21~KJWx8C&5k_}oouA?O5?o5&&((E`^Fv#&Ak@k( zm#FAlAy(aifzqynq1)38H79Ug=9OKY@!U#p`0FX8eZH1Ai+8sCwXT>-ub|q(`Z39x zykhof^^lhaq~$ky{7>1vQ(&?xnlOmOE_;MDAq0BElBZ`MAA{tVARx&a`pqNg@%BH4UFOZ6ST%W zV_9a;3F@B%GW zY>2-X3b4w@4HAg(m8_Rm_&G;#uM6@H5+M0V@?@2<#t1`}j38;P0Z53DC{9FV$Ra8? zi~)?0L_R{rJHkPE9-2<{c=>8WJfR^XW38Xy7<&Rqk`hE-!a+nvS&$@>z=X+DCBlEk z8fDG1HO3kRs7N^zgox%U1jM%BAL=C~Zo1YfUMbO6(kA%w-x(>M=p7#vu}o-au`-A7uv=VRR1 z9P_@%kl^iA9VhQR9dln+5_;*;k9;`+%d*U>Kk>g;UGR;@&=YE+h9SaE~2sCcIE_K3%eNULy$|W1AEe*GL1&V{QD6 z{nqrYmEJt8I*OD*5nH#*fN4Yx`E5QLCgjD1D@KUTC;!J*kW`30Y5;xbe%Lve1w>nW zzm1?}l90Iy9tInEDD|Fkusue?bht`RTGtidB9C*+Tg#*g@>+pH!#X}F9PJOq| ziMlNNW@t?XY_e%_pH5PUb7_~~C^|cQwLwU0iJ*+~VS@q!@)4^kv4v3zuz0b`gmk}? z2wbfHlMG${BY<~ziu9xZFX!NM%4+5;Fwn2B&{qu&ENA?$S7-oy(dhf1{=6!zG<_vRf77KR1OsXy_4>;r~g&~uIv9R0HN&>K+qWezXP$Xt_+n0w09Pe?u3ZZTJBL)OSBOgz~Z-!oU@h0ly^U66CQL=-h` z?C1c!-0h^m?AZDHoswx1C>x(+N;anu0XG<0{BBqVo(-n$S(mO^hGT5m$^hqZii{jP(retxCEtw?T+f`T=Tm-Dc7Nf>;7)L0!l#7O|ll<8+^7g>C4mI6|hyHbR9d5_OZ_P8cjjQV1XKrVC%1Zj8D>m>2nBqSu zpXUtel^ZK94TZ@wp%VZhq*#M9CaRnB{J2YQ`Szn)_{}Hdx(AO&f@H4-} z=w^VQ`NN3wSzk54`5F9-*BQ`&FF4d!U6dYPui*`(S5IlT!x4zguUbSm39%YVs1=oB z0+bR$K>Fv9{*zBw#U862g$!p*O23gLx{jwoc?pLXQ?K6zAfYg+X;M>sOF>N&)PxCY znt(}7Q{2b!lhf1Fq{5%-XE<*EqZWhKNFZWphw~u z1O^%ksX%gsr1&qrPUWqaJ~f({-4S7E17NcQeQjP$nirBDN6+brS-%_Ll-d0J!Hp05 zKlI&?;Q+y6)=$~;1H)ZrX2_ll`#+ao`k~Pnifd+WHGzm(srXnEJ)8X&FzlWjn+Zwt z$V8&-BpDb}U!CIDY__4DpIAR)^Dtu=yL%e#Cue!}?wR_WrG2)08@Ko7mgZ*jh%Ljm znuMv%QH))G(|oc|wwwG=2^$aW{*f7P8D3WGuGwsK*ze6mMRntlHO%e5vS<2#Wh=G! z+dh>&&tLap*tED|Wyh?|>hNr%r_>jFoyJh!)rU>fvIkCk)&T8y4~++#5$%7=>@~IO zn&p>#xcQm=6L)O*zHt(U_VKLOVb~tEG4+YgMzap$KUPDwkfJmuvuaWVB1sk}fh;xS z@e(X1tY>yXC;R@(^ud;Sd5iuV0Ps3rvAp8?v%WszUtWU;@S?eoVD87O{uz2X^Bz54 zW+r%#w>QouIP?|sKm7}O4RGj1FBR*k+l{CTpnRgkOUG!5D`JC)!5Ce8iEqqv&aJ0+G!G!AfTQmB7)ar zcoI68OqUtmFl5M6(US#PUkDgv6*f@am=pjj1+5++Vd`VyBMC_w0M?qsA5SLZ*C%T% zlm#W6|1HyC`0zz9efFV)z9&!0^X1}kttMP&BY4OBe*Lrk#ww*+vC?$JE{)4{ca`ME+5=pdn9r^d^Oe!(2f@6uxdpqFJ? zda%eyFL8>sgv@TmybO9d0buAE76#3HHX-1d=bm%0zMp5D_`-V38dx~^;?3?B@5IL$ z;NCybow|;74l$@?6D7-1rYM1&cd7kO^t>ghjH^nNvSr1zs_b$pXK7CMS*oDUfr{nP zEE=D=PtwLWiu~MnA&3q~56#pAamV)eaIXZsJA7Lk%Cm7db%7Ou;h~fez{$Cev8cH1 zny1T4h)oP-uNcTktrfg#*S>2JB?8fgmYCiCjbGFD0V~ci$I{}yTijiT7QU(! zaN7*Ep^nA46(X8d87BQqt<-QE%rq1YtyWL7eZ>f?LUhXfn@U(+Z-EVdO@uku3|`6U z({1Tm9eduj10N^~w6?))$g}#EHIX~;y zD=_0>1ik_D*)x!yeunlR!w7ypYfmv=HE>P-&XHc60f3Ld2o31#HByEr;LGkAR`GD8 z6e2LnBJ4S)NGvO;r%7Bc5P*~lz>|VhfKbXa%23lvGUI8=dD+A$t0%zo*9t;PH9n$ew`{@Da;NYw}xT=6uZ9=@A^j3=OSkejW9>Vy#h8 z*?#x<7|UZd!1WlLXE z$En?l(X_zeBY0r5Th9OF$M89R#%A2dYWeVK9^}|w*^>P=pS!pD>9N;{*|47`T;Oc0 zduWpO&k}9Uh>f6uHt(%XFrG4FS~uc#*N|ucd$-Bkk}}=w@NkqNT~Dt)!pNDM9Gk7E zs&(41q4kG+S>s4cq>L`5TMd&xoXXATUp zVY)ZK)b#(a@-UxW5dF1Q1&1TU_3bJKd+(lOZQcBAV=yqSWiFrEr9AjcqKqKe@Q4{w zd0mId6%ih0O#q(5a~WTh^5bv*E&`J=;FEdA`3#%`e$rRqTSP$P8Mx}_2#F98(g<)| zpAeH(fUADK;=#W?Uhxb7`r8>ZGVun0FJ8e>VZn8ha4FRe6O{DzlIzSN`;z+ollUf- zS6HZsScN|unT|yUv?-th1`a<5rGTeNT%@>!Eei<KK8s%e#% zC?Ul~DuwCkNeVG#M;_KD)JoG%TS1SlSVzM_huE3e&nHNYj&795&&iW_k2yJ<4G&A5sdjO1_ z&)8sSzT)y>8M1 zxYt4qI}PAF?~Z08I@;XOvIb5C<}MHg*&_`$i&iUM?ILX;vHfGY|(=v!*`@&Fc z`euhP*(BMt-~rW5iN0r_c00}91|v$X&EDw%^lM3$a!taD1}Pz38mRd40Km}3X`a$? zcx;*fM6NWljk7@|sc>(U@|$ZO?68?p-?|cZ^U*ah!rYzWkel<+iO2toWD4_+0BLRFmW(COY|$f(D%yY~kardq@U{|< zkMHBZ1rrY}TX|=KGchxPg#&s~i}%~WtT}MiGp+$r@iTz_y70aSV|aajo`3!)ED~o9 zg=N-weZ}$yKrae70}F@eo&%0K0Uczeq)VC;0TC>ktu@LTr3{G3(__FiMF|(d8cQdu zEGAfMy)Yxp)+f-(k`N@VRS*}@iR=VxCMaV;A}_T2CJ00!b3{N{FZv)U=uy(&OZ%+6 z*Yc#4gzzzhf+$*Tgs5;!glRICjP+t=>#x}an3or$yhEJ@e5q&tm@pY-3@HO5H9Y}; z$OK$*zY4nqAr*r*M)N#0)ZTv|+Ht#!5AwO{U6%?NCcoVUZY*uK$MWzzf^54(o@ zb$1UQvhrN9EJA>R`Jm~pNK{F`?l!(0DEIx&-llyFmvMme%h4U+TvWPO(H$-hAVpOi zE2G!<@6*iR)&@|D>~3a6=a(qNszfuBxYJ!14AfZeC3l$SX9UK&P$$PgJ}`yAT!+qu zQsIsLGs5!y&?o>cGiXvTsL(UJR~6|Rl7OT-VAW!D+0WQ!b-S>RHt}rdrBu`^L{3f2 z)p1HJ_fGU>h?FVKGI7Yp^Oy~8&C{$aq@8n&xz$P`%Tx+qh-1{j+$2{@v6`b}x8Ggr z(W6cob(udgb7)ulCF44mAFw+*yan51strOr;8@_w|BD~Dd_3GeaYyA$=p1(RP1(i2 zg`RCbba!+KKG14HNF1aHrzX4l0UMuJCqk+Sp{Rcn@tOR$?`*`TRtugQ3_4VWfAJz_ zTmdXULkBdYIXHR^u3pu$T>C}i)$3Y$kUlS0^x~>Lp7Vu==M2Y;9mW$*g)v{8_Y3(o zP0pkcCYC!8$%r09o+3_|l%cTNIKdEQ^eFI~ zuad~97g#_D^`z{}1R^1UN0I~sSf#|}(VkA^bGEIw$n!RKBqUi7$l%4m!gx;DOR>}0 zCo+Ck(0ZuJc(Xj1Xubgej~R3(Ah%mVu)z)|Ph^c)WXoFi9pnIuYbYG_oH1K`)D18P zr?~a{kDF)aXrydkj9J0*m7@|0o&tn~Ra(Xy|p%DYP zUAO9?Z(wNiSs#)gcC|;y z=Q;<+SeVEinZQy8$_oG$uQ)^Jx{!VCP(_6%Xu4_JXkTJ>2ctFn6)U4gQsINUISp(g zZ4ZF+!f0Giru$8CBEE77XS5M#i>tV5n5xHSNAQGjY1^V$69-DaAMmLHux z3^MJFe2%UeuIOB&ljo^7!HY6XMH7Jj%t#*lWtV#h{{I9+yF0{>yEDLdB?Hj8J=3c4 z2W|E#gVH!AZjFZDDx<7PWu;^dtoegAmQr1vw{tr1j$&y z`C1>tCrIRX}xLFY-S@LWnV z#;i1XIsT^w9b;^AB&^9FD(ftjNBr4xlUHI3i$C}P!Vd_CKfFPItmqk`C=dx&GK?Zt z@-1-)_cNadoFAI9s zgZID!2b?~VTbzT7x7wT3vhjHex1hCa&&$mZj8HY}(QRU;P}JunDyd=tZWO?E4z6=7 z20?dd5TOQlxt@5AKL6HjA{ocjk>LGYuudYx|R)^%L37{aer|wI^4k_SNqKG->jQI=IiX9DJB0~7 zI@bzM$QN#{*-UsFmxHN71)B?V6YCFP3aV%?VMb6t`~QCm-=7qufVf-$rJjPRoPTk>cB^kktjwJWiXcYC?~mGd1%$Uqgs) z8&{3<8Rv77_uzVsG;{o|q^0(sIrCVG3i`s0mt<(nyewAayrEidNttI<1%<_AFh12u zg`(HJ*YP79?>bu%v3Ii=M&S$QFjX)$(tKfA5O zOWNfsrsg|N7$w_C&?*x*Cg?)a#?1PMsTyTo@+`d(5lkgtU3dEO zr3X&$aPN5kh#tS!dVfM4;hCrBxa#YJ5KyP+Y#~EMod{qTfV{|Tx2M|7I9fqVDS;_q z-%G%!GL%{(dNYUT0umDO6%|gxvr+*8OOY(6g_r(YjFIy zMji9{d_t@p^t|=DM|^DdgIE&is|5X@W7v-dhSuKmnMVXY`$U!S&G_YLcWu4^@5oB} zk0Ald5TrSbcj?D4^aeKB-SOU!^24niqdh!jF~DLNBGg-}c#h!ULv`(+yX_nrdxrye zmg;Jmo8N7MR(s&L_JFe8;>Y5O+&$2|O$~R?nZ1LLQ6tsepBy$0t$}zBXxBD=gZ3}a zu$g~Rxh7{!fD+cDYdiRr#vAReoTUuS#y()M)ma(t1Lu}qNr@I49cjN4tOG}7{A}wD zRxrIfQ-*NktefUVzfmi=c#MV~9>KqAjDFt6 zM{saY3MZe$l&Hc-zU7v+|Nk+u=M~)d5h~syFMT}B9ylL?k?UC(8~!-q1NrKRt@ShJ z-mqN{xpbdva0{PpI%c>6@jtfwg!y#eqMXamt`_ZlyJ!JJ zf#b1Bc3St%+{0K0V04|_bBARvcQaV3P;0RA+_l+|5!gQmcRK9=STZYy#!V}obfm*T zu-L8ugeeVGRQyiZhdDTW$BRw23>jZHX^-&GyY~*WKem1r5Bq_~{OCyEx(4>vlz(sZ zYIO5^r@4dpO=}7S@_8APg|93$HcViRf>Bv(4BFY?3SmzD+aCa+=QyAF_$`2s;KHGC zotNi-yz1vvI0$fdmM2J%U87D2C!D^(o}hvGR67PQz@mG`zgTn(UmkGsMQB|}gz%D-Twq_sbLQ8Za|qO^STHC%k}4L7MN2#!^# z6to7`z?*s4;N3w`mIxLEB5Ni(ovfM2LR_RZfHfou)~X3au+t=n=#fHQ9}&R_DJ=jq ziAQ=-#^+QSWdJM1qgP2Ar7&4#rc@XRW0c7k4*n2OdlAYVuD-X*#$-Htwon!jQdnah zJ}iLeE5-$939T?|us+VkdMpb@AG^H-aLHKEF)u10X$H(1OAqEt4K>sPvEaI3jsYkO zz!qrlR<~dV-g=xlG@=Vf)NGt31jieI9_NP>Ke0stSfCl_A(1-@ofq`1&s{Z^4Cwc) z*UPeCS(arP`<}s9E~@ZhK60Q3>oxOY>Av@w-Xnko%d+U6A!wk(G5BLVnJ>R2pLf>~ z^BrF@il+TR+3D7+=k{u=4sPGJOX#}Brd$>>(0bf0#f!Q;=l{pbpci+q>gBUg*ud^3 zp`;zoPr~*jSxQCM z(0q~!*NWwb&>@?_bS%1B#O;TRun~K=&IT)X+||Qat6T3R!PGHDaSZ5KGB#r97`nRj zIW>STud6LLHxTO>bD3Vg8h3qQk3;L2n{hD3AQ4ozMej|@Zsyip`to42;#+q2-;ka= zbk4ZWm2&iSnTO&k$5Zc$))c&RoMUC>uDfw(!Y5VRzOR&33g7+cQh8uLz-)i9PHm}d zb1e4DdAg0(zB}RDKg9eLrHTZOL`!bCXSsPZ`;zz@%K=>e{X;;{;qeM!zUtro?y8?N z0W0s$?2Au6DHv^${T-gX1MeZPV?6&aU+|^F=@j{85mW|Zv->ei#A_dGGVwaQs_G z6cluTaQoE7wKtW>bdT8^;$(OL2*Usnp;UJaJNrg^Eg=^jRx*mF;DJ7K=#lnC%4f;w zx8ZOjZErYhPlQH5h%t>-m6dTdjo&rLT7k92g)%p%e&(*4-{cn2pI$>5HY(k6CBZ}r zl=c)c!_IPuZDfU*=A}Pg$naU#wd6@{D^11Trz<^xt|-XOF(eJV`GoLe{W+foV4D|s z6XBVia@$@RtPf;p^py?I?-eqYxMygb)4azR^CPQ*_t)Bpj&+4kjHC9@I8j~YCL?X` z3_zW@{5FL-lQ&Q!O4m8q)5+X8SU`9>)XN&E%3`O#xc+>`!@sML(G2K+`Y+elX8^b^ z9`}6V=MHZL1Sf$qC_V&AlRbgH;M76>o$Tt1WOR!h$60g`QT|OOkCM9FUqVu ztnvR(WG1tzgc1ZI&#D_`49J+t7(+zf;(`RcnFbL+Qb=tIn0aN*K>%O8|J8@KxFg)64Yu8?q;u7nA%wKr~GghzQbH_=xXG z8Cd0&(Ed`AF*ay0yqAhM?)IE=(2bO7-u~!=5wwMkD;i3f$-VyZV`5>xIRndrMPux- z=rx+#le?bn@mv4^AOJ~3K~zifwTQ0BBgfJQcZ&ko{uuy98AxlN)XjMGW{GPKe*5s$ zHSngP7n~({4~$E&njV4q%b!%&ar8awu`C+e?`NQ!Sua;3yg))@)=PNwK;K6Sd|~Jp zPbvFp0AHY&zGoQuGS67hpJt2?ShOdgsB; zV26ks*W4L*0yOnikiDJ)>#kh9EjZ`!kE37Mub6|@_ zl4>y^aho~ynJ*31w{UjAKAd?vkZsSXYdtSE;4el-sy#@ROvCtZFU2(6WcUXgnrx~;(_91L?T zWYV+T9+@_Q@3->f3C{8yE{t10OhT_)yzfP7$|iUSJvUZXSxq3Xl&r6i6YDE7 zXD(MBHSxTG;rzJb{0+b>t`EKd>kM3>pMQ6K_UJjVh9{gl{JF?CRLJz!YC}s$ycaAc zkc7_DlrgLq5gjw8z@lPW{Up*+R%LZHd#!+!Rqow6WY}1KE+!-~vYLQNDyf73G zav1U(rswqx3kfO2lb9woNg*Q-o!DtetZHdr<0u7$5Gvn^p!m*Dn!qJyuKQTTv{@;| zG-cOMMz%SaY=~gB5w;dSDJ0bN@$rFQmiKo6y3PokUn9pHndw=tnS66eDzDsgdh)PR z%Oh4L^i|h0Fu(mV=H{I9_f}@vb=pCXI+g}T_Sr{n=YJIYr8R(2b8yV@JG0-;8Y=G9 z)-wm^eAIf@8XT`$d-*fKM?OZ)_v(0v)iA%x1?J`2 zqsg1qkgbC>_H($i#;{sZSo{6s{@U~nm3g9J1;kW+ymfNYhoeOHRzZ$gb5lRL!=H6N z*;`yXvOLnF{@Ds0rwST-s22gO6pc+~=oy%l-_Yp+qlY#tzM5_xi`A7+*@ykB;xZ|PfN&>F(no>E4Ixx3UZnJy-yYIOBaZ3GTii{PQc{R% zb;nZ@A?{mElaTrBV1fiDf2zN&6Q^MGcZpYA2$?JkCn$V;z?cQ^03KEV>e1mm17k$M zSxw=XL)WPE81u?P@5u3hZ#;-G=7_(qQLu47uihH|tur6-06feEFh|7c^9dt$n4v?6 zw?-D%t>f>WGv!A3#0bpLb7o05a%>bPb9i$MCLB5_K2j3+tdo8tVROGV;>MX+WOTQq zf6o|iZrmD(c9vI_>Vwvq!uHGUxj^v6_h5Q01v`x2k59@dPgF6V z>PqF698B#{xAx&Ox_JXBgZD-Il$tvrhVE6q9;)Qc_R!w!RVCCrkTu`x=)(XTvlTXe zXI?%)u|R2W)xMsZ5kA#5XlTp|Z|t}A6K&d_mz2Z3$3~cZB4}G(%2wal``qrC&gxu; zbP?k<9dX)9F;mZoQMSD7CoA-mUQMq>{<rV_npa!&(G81^pP)=GW1 zd6wd_#5?Y~A9hdD_>ZX4ttfgSk7J(xL8Yj3p{& zX?D{-hJ5H7d}iAEa~Ag(VTNI|jB{hcF+>ba&5>fLAhT^_=%aU@>^#x2b*svv-5gzz z*&9u5w#*V{3U>~pY0vukn{Y?NZ@fkpL;}JV_Rby;`)ImMUo2X;0Fr6uu}o8c{>hh9 zy=v(H_Fwet&mK&i`C0d4w+vs%u9q!lAO-<6(dI%3NQm@WqE*QnL&kf9AnWGJ!lvz8 zSgQaSvc_2RLIxmG{=lYex+Da?l9XSKua6-}DT#zq%34cgEdi%MN!U2E6c<5Kf=DT4 zC(sE*ux7GEBnU*-TJb1IdIt{!GDKtz?8^j_!kc@j6JW%JND7d(HVi5+FClT3U&k-M!D7tdUVP-W`#w8$smSa6j;B~&y3?N@wTk`=EWn=1*``oIA_4Z5wg2E zmaD?60+S=>3ts}GtQY77yl=o~u=hXBZ(WT0PVwFT?HGx;K>0N9c~M>;y)4TDu)YT* z(6gSizK;QeC*F_Ca)J*9@3Hu>!sX9er`W|FnW`GgvYg&x7~%R3`+)mm;LyR9Ia?K_ zaYNc$z1Wg+?z~$+*v1C{$m+?vws5%{!skqNXNou98U z%Fj*LY#yHsgs&!Jxd_r_t+XqX4f8JzUZ|XDF%6uvVBSH41z~g(^17;1G+I$^b-;i+ zi_F@Xp_m)WxTdKDV~jcHI^cx$Th*yzn~obD5VAgPV)}G;{@aPrUqH7+Tu+w6^TGe0R^;p~xrfjMSe8pyj` zE{`~xxzKplNZNS$T|SKFqeFI1ySR|ZlFLophrj@*4(QL5v(3AJb8xInRS+RhG&Ne< zHbu&w4 zQYk1gWzy%8bIq`9`cO~<|7mi3e#ZFi70}PmLHdldrxCl3{jD5SvT9yc&SGy*MaB6h zF+`Sum=aRF_*h7kb|GG*4K)GLQyEf_l;~&SO`1LZ46l2>{8m6=3TIS80bb!8CD8sePrp}EB8 z$QZ&BEJU8-<;tbcNhqU=nbM?6HeRU-0v~U{`*ZG7!Pk_KKn6cVA~xovq#Qov4$Uz# zFnF+NjEFgbXP=+qeU-=aWlrSow{y#>LkC*Ae9Qp*Ta22+OE_{WIXwcNzmB|4NSU=B zxkfN~=HZC6)Ht;yQBA3Jmp3b2iUgpO6`K$(DIJTC0oF_J){KdQkeV?Z zNeveESZBT4$8CE7eO)v--eY#!*f89pqZ7W)Y*xx|d~!v7D6h0#2Z8(@Dp!Yw%_Z1c z(GQuAbu%kvUB)v6V4!2`dh2MJ9cke^l0_lz$0C}oPTp*cw==H2GJhEEj1EJ7-ttRB zpIk1CraX2-W2a7ZI|0bFhT5$>iS}J+?)2I10DiLx7Drk3?Yg6xontXS;zG?l4$BPe zL_~op3cF;2qmf(o+#}W~(gjYZFZ$^p`M>*y`Fef+T|m#@#_KCOZNA9AsN5LP~J~o_E0hPeF^+j3KJEp^S_~ReomgfWxTbwVl$~s@(H)~+V_z+VGHNe*rz<^cr zq`~ue<}+e)3iJ#QS%Zor0qZPjMaKZ}un%M8#z#ENtMpnIJI-tCyfK>uqz?u6Ib37v z3Xi#n=@+%uoO53|xI+C5LkD#Yn8_zK2ZR~7<2iOCWSRr6W!2mMHzV0I=1ecW9T{;UEIPu!?v*@Yl?ZU zM$4Sb?*nVfvR!um9D))9Wuakgie38xb*x)=Bed9Za11@BYM+i#=XcrFEg|h|VH5V5 zbqdB@a7tsRj-hkj?auAt0k<#Xv9K)z#I%^6z04Zwj(BxUD|)EzLtWS1Y~4ev>#RM_ ztEY;NJlt?w?8xW4P&Br44seC3Sbmgi{~_iBMLM`lUgBjWUPIs|A8D}ZqM(AhXj;Yq zXI$(_!w+yKV~rlq z%7H2w?RCD5Rv%?u)iWxgRMCo9)izliuk)*4eBA60OPkm7=DL^2LxnS|D{e|%(U^mP z!*nfYy0WR7N(1&;TB_)BOaN+n21H(0Rs=i;kwL~r7mgeyVXOd5LP$KEpPqjQ4e;|B zBOcC7DR~nNjnwaQbFwC$=axBNsb%>P^suJZdOWfqk(DFfA7t)!ZQahyyiIp{@{ z@*H#J^|4+7f$-h%`JhVyE|5=Zs*-5Z3PL!n+#68j>^{_=fOlLM;Qg9QHO44_;47DW zy=Hb6R}W4{oB=&2Gdu6LvF4}n(Q6>Qgd>pF-gX1H@|Dh=btpXb6?@lf@YI;2hsO0f zuT-=T@YcYL7@<;g%$coR0?paG{ATCTdX4Djp?(rrb5~~Y@vQkX06lW(8S`3N2ypNb z&>z!qYDan77O`g!Gt+SjcF>RBe1^Af&}6ot!uFYz7Efl5Q3280F5P)ZbHxY*3oBnY1vy1Vb3R3K4vvb82}jai6m_wiJM9ud%OP*?fG4iHbHmq`$H1( zwDQeuZiq7M@35^uKa@u|H1|6b19;`jU=6lqhr5D2{+)~jS8ZTz9d7{kF6Og!w;)~wPB0VHl3@wC|F{H4> z)ByswlMB_VPs!vE3BM-Q2BrxY*~s_{-iG>RBgerPucm;~|wtHzCQ-)&!$grIV zn!TJkN=<|aFnzr`>({)mGosd6Y%U(w?Mh5f>BR|uTCjWo=2=GziHI5#-uxDg=T`h# z#tjD4h|PD)Xh3ZJI+9w0}U``>x6%2Z%oI} z(2;?zfpxMO2{I4PfpNr~A@K1*&l)2*xPE;FANj*2lY%?|vwnX1g11#ixw>T9_5l5< z+q`LKE8&I#tT_yzaW~`3l+f88NA5Qdd#JRP#q#sPb=sr!^Ua0z)?xecKizB0MioN^ z5MFW620_!_^*@vaw#E>maIG6CWE1AA>j^H~(v^0|&Ks4x*<7Nfv_M;_o3|-wwl;nq z>h0!nY3*iecAF?|P+a{kRWLi#dVH$Cnb^(^VC`olJISKK9-HZ9YVgWAY{#ww8wLGv zRLOB0+-JX0f4<=qNmQIF*!E@1I`MjyZM)#2NICVIf_zS4%aNzqZChQgI*)}6!tBo} zvXg9fV;W5k>delW-*FSN<(OM*W9o}cL*6;;+C=YM)ZzX>c-LHGXpaqr%jHJJLCta6 z?D~3}y%|V-&)K`}G+mLtJD@kC(giLGDq|~?*K!274F_md{&$P56@cy{VMYaU7KmvICzn?N6I36HuM8G4? z2-0LvGmkqVDH+Bsss_ssj~u{w=JQqKe8v^HVmxC;LeE(xVDifgUUEFg>l&}neD%|V z4)8Yu;&FxVyaxIjJl}7Q3^yk%&Ha{wR9erRk9_2Meuaki^9}EKow(<9i!%Vu&$Im> zgDb;5%;y8DH_#cC+0(E1xKm}fHE+6QWRG12b5B}ZNusF%5)Rx7euQbbOXctJv88)z z`OZ!D@^e#cQp2)dG1Z| zd&5R1p0$Tzn+w01FgMOjT!acgG1#)8@5Y`E#YVi)xw-yDJKrR0*YyiiExK)5nZ@VA z=ZAf4YP_O5qoTKFi>+A}g_MC|Ri|6r2rs|C^M?n^TRLf~aWLT?Q`9unv$tq!_TAerKB{@20*TKsyy4^HpY^j#^m9PQ8F@Tn1fS=UpANYySl^9|@_4@BdJV5MIpLLl#uy|SdQK54 zIZJ)cd@X{f2OrN5*@m)>>T3kbC4ub=`!?7b0Qe;sMB|#_=<|xGy~Bo{H8cm;(42G6 zLu(zw4>^K7B~?Vb13(xy40KA} zu{QGvHXCZr6!$uFnD4h)g<|_^3>68N@zF!;;O)VM2J^XD;DEw(dADb^uYdFft*#E; zTtHXw2$Y> zX-&KJW;V@hG;An#oAn$m1>2>B*cFsO(uM1!kQ7Tn)8svm`@?$@FL^>ds#>%q0^QWaFIxHDiJ6nIhm-E z`wuec?9UQ6*SZxcRwRxO0RN1ud)8|tO0LrwBUGJr?JgH!F(1zy*PxvUX!*?N=j$rr zNQit)355}PpD*+EI-U`X;$l4Ec)obT+l!}1jKDm{On77{zC`6Z1IH~9h!=8by}rxO zoO9^lw3is@tvXuk?FKc+IXc;ak7G%4^Z1J+UY}?E^Bdkao!OQNP38uj)ffoO4FKK5 zzr(>{Vt-UI2M4fwW7bjDeMl081|?$;0O(=o-hE)9^VX~)$FQxt!#+N%)E>94apTrx z$``jPjs&19plAvi^md=AdHcDYw7rQ!+(pmXMusMUZa^Gw%aNeLa1&mB>Or|1gxSIf zd#iP19k$sKihT$96{3nenc7=O9i3ASV3q;* zNL&DRSa!LAdKNmA#(LqKzN1>Zp#Zi-fXN*iHP1 zzUnz-Qf5Vgxx?MagKQ%f5w3rZd_124JwIR9=T{y1=@Gz;8CN}?xyQ{3SeJ-duMl<% zdAVnoE5&nip1#%qx+282=c)to>^bS=TgM+BptYXC$JPH1{On2S`A^Sp@4xKahc}&^ zZUfDO0QxXSJupB4z+hULwD#ANk0kn&${WxghRz3L+P@LoPtG5X0BG7_XUe-#xvF5c zBYTSrHEr^j8ux~<7Zrd;E`wfK?qOs2WKFGsu79Ee&^J~|Onq+Y<|!SvciVy--@EM% zx637QY_>SmAmVe)IrZH=03CKS@7>010rchylWFx$3fFYFIV3b@lT>x^VHZ8`PL(M^ zI8!6=T^UB&Y;mcq*@N0`Jys|PGSP6IwzHkQ!Po|XHup-hz`g(g zAOJ~3K~#~JxwSCX68u-lG63;vT07Jib1Rat#(2-K#vz+VkmHZfLXYF^PigKqLyJA) zySgSFq!`fdqi?Ko`cByTd73?epIjg+ZkZ@L2mZr%`~Yb{mcQ-$U*)PF5s$l2z_^5h zxqzNM_bV_6K;m86`ahs;@8&bhLNdLV2;H`WbA?{yGI|LIFpdjg^1b1lqYVj7g&+&? zD#R$!VtFwXdW?~yKSGGN^sh<`z+153kfQ_EG3_jg5WBVHxeNEU?^t2=t(D6HDIo^2 zj1D)OU=|4>AjHR`W%#P|`xMFPZL#+o^3ptj~zU0=-K{Q zw__erF%CjA>*LFyvg*eQg;on&v{s+miC>u23{w}`q$%h^ftlrLwR@j>S7%Kx8>q#~ zDUM7Z4+*MDHIsj_%3?x=&CWxuNj0B}=3CriYaO$VEDGnz_h{eIoR~e7j*7(?TDy0t zvfKlDkePvaK`ua;oqL z1J?j&99pTk)y+Mw`3Z*q#G2DiU*(?~hL7$77K)McnSiQJl|TPnJb0YFbbtQ8EatN1 zgY%yBxeP_!A1-8%*gFvK2eWn0J(Is}9bw-&nTO?+=Rly&5o3JsJz;A^(*3>5;tD-b zPQUH_H@bT_Pr&9h2H`C3|N~$z#cui*C@os z&q}QI2M|%?(P!oe7Ejq8)0#{3`M(3^zy9@2Tl6f__&$rMA4F0t+$XK*83U}QVv%TV z0E*2Q97m#}771xhV6JS3VZhCx<;6;z38apW#5I}pxJQxE!i=nOP zc?@tmL*9aJO?Uup3J0YmTeiv#A>`u$3GsS^v<>3))*~=L2s}n9|6#@VXr)+{;4t4A zjnrorxIRB>?32?G{jHCH>{)L){{$!#L`4RLouEW^Mn-n}xe==(6i_Ql%RybHf#w`J znT!g*s)|M(DiLxNNa*PBSTRdQ#gw_KJRmu_3Umowl^>XdF*~tvuS>#fW~T?fWJ#6g zbgK3k&zcY=x;^>O!7PINZqKQq&T;osG4H9N4iE^@3oy6Lz@MWI`C*q1a8@0{b#_od zrgTQZN2+8MG1I&_74b(!i(-praNLzl+G!Y%*-J(2G7@!%)>UuBgc8=Z9G~59ah9z` zuu3nATUtT6WEkyxKw*l*IGh=fj;Y${2-TDG+~X$UKR?y#`Gd-yBeam7GE|=?p-X#q zeW|GfVx;2T06zH5TOvv^;8+bYyRkVY2eP?P4gH5qT&oOj$A9MWa z3;;QLo-twSyFM|W2ua;Wwef%Zzn$r_7fa7@QQU^`?!EV2to-hcW84&pH(=bWfyuDT z5$d&KX6m!ys{Ramrj)t;>I`(29>3oU(vWE)6BVajnUV+^>z|jGhd%JX)_?l??b{q5FMn*Ym^k}T+ z3Ec4{4B=S|46BN)+z!qzZ>y6}22P(Qe2*v2zp5e>%sHaivf={f-sTFR8s%8;D8HKJ zO_71q9Lq+Qc|;eg)f0_}c*1oYU9SVPrz+mYr<|%(dG7I<2dv6*kg7OO=ci3+K!cU| zu8*Pnud&u(RD`2-JWXM{D@SY}F{by&KJex-OP$X2yY2^D8%^FvWFDyzcZwPKfx3s`s-ZeLfev z)Fi%POAbFj6(zHC&o)**Qa^&R(h9`+VX3J4azmWvM#ABfJZ!!Pd<9@%_oT3p)N7qx z?Vy9Xp^nhPUb}L#r=+H#@mbzRxfN^-)5Il0;00W;l9a9 z36f}2rPt4Ro2G=ib=7=tnTVKp)lG<4<_N;~0Qz~FFil;k>U*x?Xgc9#e`gh-V{e;QtO6D2p(N9^Gr$6#=tpALU4Ike^J=@~=T@jSf!EHkn z3iXVRcn}z+HHjOg@n8n9Sba0RdtKX##h_<6@NH93?A8{$S&31!LxkN8ydJ2Xhr}QR zAVx@XjR6(UyvS00MF;-YrBxZKdHY$MP*f z4?Z52^Yc$`vN)I|@3IpVY_jfEOzo|GOYb7-+Lu&fK+58+>4TG2u*sdq+U*AXVXh_1SZFS6J7m!Gc(wogo+bF6-YDM(Sc9$~pnRn`Y zm@keg7R9Ig+d7k^b7n9!ITdz*p^?{#s-l?Z^rGGI4?FR0ZXu|BH;bCoW9aivcDjC_ zPuseCE(}Q8i#Je5c)=iI2Djr zcWYk<8+QUM?>33he#Cy(R2-TY#4rpau)Mz+Jlzh%fOZVK7R&f%P__9?YZ6sxEg-~z z)|Bmy7OS>{7yvoR$C?6Gc;U0BjhzldN+X6A5V+faLWo5A>_6-Ok#N#t0AxrhybS`a zd^{{1zqJqpcrBTU9+-lzAm978bTC)($BN-^f>aM zw9$+v) z9wRbdO~HFbk(1WQ1~Y6`*sYQ623HzwICaKy`Zl>PJgYO{d7)aa4B-ULYbr@_eZWXI zf|JHxfwn#d&^(?i9pAk9jH|RH=#@OY0`rQ8u1N1s+&63IQnCH}(VI~J;5}Rb@g+rv zE>(1><6{ct^5ru%0J`h?j>w=LR12?E0CcJcC;>_*tfuhNQNRKYH+gt3X=7UoR ztoLqr5l-)|T7x=5lXok|)*Vq}OqOu&1799UUgt4K!K+UPEJ5eAdT*YlGYC$`FPfEbO~!xPUg6>!Y3?_y0hu#D2kti$KU4N{I+ z2H~XG62If|3ynpwhbzc-W%`PIOL%7^WsWH0><=krk`&_sx_}V3n{@oN5CXSX$kEw^ z2p7RJ08&2Q7s$r=*+pdLIcM9Hz2Fs3R-OU3C&3bm1wfx8clQDGPEec59x;&&moVS# zG!9FK?N0`>@c2KcTOv$xVgPVP0#dtf3DRQ8AKZ9Cr!?v3Ftn$9GQnjPt?>*us%K{o zp8?QM^wVAV%+4L3Mw;fX)e(9=JXWO&ixSnwu~x_=8n8mZdHS;GT*!kzasbd;qY%m$ z9jZDBc}j2T94)e)dz!P%;f1HTQE9b<0Db*xj9Q78vpUn2>OF_&2lo^}RMi2>+t=)c zm-;H%jMp#sutN;Ze;WDlNdV1unmjARNve#_h@o|T<`5l4<3Y18?Q>QR1ZyUs87{iR zgWCD6pcZgS1xI)iEyV2ccjtKMjz|l-;0)KJ>+X^5nh%}s{r~m}T($yg1E{?!qc>%V z=3^E;8yk=r=mWl-X6OIb_ZC(g=v>0hxymK|M3+Nno1fjAV!>&es7>?KbtXrp?=a0F z;AVC-c?ZmIv$KnyFjZCn(l=r%dfOnj|1IIrGoq-!MFP?RVi91mNk~~_+lmEP7Q?f) zG|k#%1TN#70nJ9R;ZV7JA4kJO$B5bC+ffdK7y*nD!{GHB?LgUJjKCnJt4tIINxu-4 ziF228l(n_UkeSNaCkiHnvmvJ8spg25wq&y~a%$m-XaK?pITj(>Ht0V5_FIr(LR*OW z0r`QC7ra#1OcjlHRbrY~a4z3}2A6U8{^m~^B$N_vbw$^q&%m6NfiC4}QOyR!;p3uy z9L1cJV(Wx>l2aig*)v@Iw1t3-#xgDh+Vv=1oSYqP<;=rR)d3Q(gZxshp=O_Fq4pI^ zXG>P~!RuD>a)cuoZ5X3YTX7ub0yKL&~SaGn@Dnmw$sa-T5alUyeYq75!*Gr+_Ez_tGf*Ta*(mtr%ja~k?O>_5%rda1ZHD^o(hqt^KoairEADz67Wz0N6JCzWr}3+xr{fiv zelszA##p0m0RpmzVHh#O)cP6v*}`TyI!J1Kn9Yj|5DB_AuiYRPyKNGeVp3Qn+E%o!gd^vH@Q0=3r7J*O zz5^G0E7_IBWg99_R8hOZsOr>^m&5O4Sf%%%z&;R-#vi^bZLBkwP&(3e>f)cDBQh%w z1XXDdp00fJ(|hNoOIGEYdF>(1DVtqTDr)yB9gg|9CHMi1{=BeURky;lD=%gLO7%&n zPT)XGqCL<*C>7)(XMdaP1%1&yM$iOw*my#p#E^+O~?2Y+DH3@7FLw|zD*2nwPDFk+xrWkmY-$zVm z)2DReXl?8gAn1w+>v1a6Op4*iTRtAe6cN&z#M;j^7x~k!yZ86|G^aLkjsm~C{Awb; z=;EzT0h)(=Z zAYNYwOBh3%ub7Ph7=}9_$8n7Fw;c^Uh=7mHyZ)1|nh?Pg+J+9gf43tRQ%dM*>?{FUAf~$EQYrV#P(aX1U&k;V7zA)#>ZQ z>j*BkC@x!Tkw;=gR536PbmR%5BEIG<oj(`VbC1D@<$W%pfgSHhfBp{1vtU?V z!cp9sPDnyk!QA@CZd@K6V%RdT@bZ+7)3hCO;QAD`cn}d!!UdfHe9^@% zoFeB@b*hd}M(;;TRu59`IUXL!qZ!9fv3t`Q@MZL@&kQTh?wTwhR5}&OV0Re$nU-Vu zF!l4M!WwnvnAe3+`rLh_>AWF~jT(hyC;*H#Mf^u2RN^=lFR|!4QX@ycoyi8~sZL|h z6*kwZu8F33f^q41^Ag~wGypk{*J!vy5T1959T7 z+t)Z+oIQxqan%Ea6K_Or7nhWE4rPA=$dEK>VWLDK@jE07Cf^W{Qkn=A(cW-_e3*|* z?`&reuWiF#7K91O@<1!?-x4jb*6l1$P-4#yLIL41oEm-4QI7hlbnyJiS@<%0Ze(RA znd9e&ZB}7;RJ0(d$Y`#-k1{{Q6MgEsCg@p}h-scN^oKeQTJu+oUegEOh^%-<>SvMI zr>@aYrOneP^*Q>hiVoH8jd`l8oK$-d|H48_kN40h)pDj#E4{gtn@6grrYOm7>ZeSy zM_g&3DlP~(IH^?RBSL2aNo~cU*Gp9WNW4XPX%OSV&w>Ix_VdUOmPmkDOwJ#5MNX#t zOu6~5F8NQh7)fjO?16q}@P3YOKIQ8g^ZN9L+&MnyB?-EAWK4=mO`$DkXXxZ^mqR5m zahh@OoRZ6f$+g7%e$ejhr zVPjcjJHohdSXz3Nlx2xVph=&;=dggs9y{oKXee^(>3FFdisVsta=J{ZK|IeFe5Io4Jh zf=8~CpT+XIh>M(_2EaA*iv|81mBWO*T=-gr!Ub)X(pguC5=3;yMC#{fwft0iGmCsb zip3hN=;^GE_hVDldGUj$5nUo?q_xWoJ^80r6cS?i2-3}aLp3`g4yLOvwis8Cq zZLAE#Azfe)%exU^7|6E(ZQBYgcsDv}7&Iu`7A<^~H=MWKFboE1OQ(l!+tv9#aDE;3$Eh_2V3gw^1_3zww@CqSOfg&Z>@l-Qz%<3# z&e(1!1*}*|4qAD*c+I%9(ThIAWg&;M&@K5mae-DqE+1q9aP-h(tqn#J8P))GTɟr7GXgg07q?KO~`R z%~r;Ue%~b%*>n@SfPj$;KVz%tTCXew^qi zd4DFHE+Ou-X*4fipY%Rr1*`4TCtn!6c;TIzm`NMY4$Tw?lxE4W%#*nhZBka49-mo( zVY{cr$&$#At`r`P%yi@voqJ5;im&JdZvH)e@-r3 zeZt4`muX#t&^bDfG355Oz+!^3jWF7PJXrPffMIlUX8>(`b7mdm_->>fVVedGkB}Hd zJ4z?y7>2<{pJ0?jAb2g>229~0(Mi9(FOb&0L%d>mj4s=60RAOHpN4z3fYvFSYm~D0 zes&dwQb-{wDecWPgxiqgn0+K6<+4dFCXtWB*g_jc$3v2OO#AH(AI%Zh$kP|eC{=%w z+oZl7w_T+Rk-+MykxM=CnD#QE}tqZan)za3VHRbC6{JZ@YRiA^z$^^{uSZ` zRP()6&OABs4CMRC7gz5;iP;mg!-!d84nun*s*DHa&-gYzkBzI{2K&;EGfO@D3(zr) z)^XE#buz1&$GJr8PeGY1L!G5}@u}skr|=T1FG(B(NU=S;%+sC0ZmAycS9GRV&!1@V zC`yA4%Q^3a!dB1*!*fF@wXHhUPlDdnvMpW$wB? zGT6N`Va99-*4YHCkhgGm*t+W?cN*O7J;*lbwu{65`p&b`gcl|-+7Qo3o2@fq z8M0w|@{U%9x80~N1k88`rtR^ut_Zet3yci6Z4DZ>HE*^M5MoI~`#fPRW9_kMTVRpz z?_=8vEG+zD>_~ zXVCtd-q?q-ub7C70t6z4rJkPRQJp?%p7nEp)N_x~6IApLF4YDxs9jQr<>l2pCrgmm zsMmQar4BjF=YQ1BQ^K#ut8&?5%Ev1xuK2Qw-tFbjY zy$-_47*$sYz(emB&@f?Z+Q5=W@X3B&gU)$oh_7s<6H0RE@uBj_t%W^1ljA#!E>-x& z97+6XXjDuNVdu$DcnQPjKs}v=FpHu0JM+H#ea-UbFrJC!-(&fdijHGo%977K6G6Ei zs}{DS8+HD!#KWqjBYmDzG84138T{(Vkxvi z<_0~-LJoLZ+IVrim?N|xR|fPeDUnQ(u_42EZ}vk=)}N9D>L*=8iAQQ- zQIl7mTkOPOpC5Hb`YKg&;dnZp{V7=Tu;_akm1Ln6u+VG@$$pxUg<)P3y{LXmbbPPTn=*iX99ZlDu<=iW%r|zXwF_0rzZ-pu-l3 z=-DDtTOEhQPHy(RFuHrH!}jPIp-}H6YPKwS?;V(f)|u8|MknW$%>m2%vz)0%N6gE2 zli%VTP;`_8K26agL5DCIh*l0}blo4;?j0@g)fC~moRokZT`iuKHG2cQw#BjtSes|O zzKU@ij9p!8_~RCiJT|afc(dan1PzW@VC2*eNlJ_Y1FaVv$MMa5ON_? zT?|NX3O{Gm^qBCI{FP1&u8J{e&8QcP|7j4^%_$r!aLEa_F8J0J(Q{rn=o~+KXLLNx zlw$3=KDN)p^!65k%|bCEvD~oXDSe=6X9p+|>iGcleFVQ}^sn8NY<&*6 znyQ(d48#)46D7nQbKLtTL6CC$*cAIke=G^_Oxx}85BU1e?I;&Wqj_){-5&J<5bdiN zAm86*!u7sFjH5K_j&Tg{E{hE4dGyI3UW_4p?#eih_Rkg}7<>qd3!{M^NyXpb@=_q$ z;XW9$R@`m?hJ{3^001tTNu5KtQU)1^%rqiG0M?7HgtG(xY|WvC#2fjX6vo5OFzQlT zc3DVBDHkEyY;V?%1CYkXj?7#z0FRHK!t8z$4Xb|-D!TU2KQlZY0zRY(g*vTEt3MgE zf3k3ESx}m`a2z{e?eP7_>&MSYYM#FQ2auQ@dvF(RyU%#PvZ9B^^U#^?btZOjUOrW! zgyQM^Nu9Zzm9}M0b*$5?%J$a7z4usrq7~msn}4C`$93#M#!uY)I;Vztfv!F5Jlf>N zCzPnpS$q|$P_dil#CMlMcBTuN8p{<5lvDw%@_mo*5Eq&ikTgHIiO;P@#Uc!T*rlHy z$-@X6W%raN8_uSW(8i%*lFt3aoy!VKL@cx?FA>i1nEAx`Sf7@k4E{6CRho_;)!JG)EdAj$3>zQ4oMqcIYjl1BbH?xEVd5n=fUeN5P}9pD*!=j?nnUP zV*dUQDeFu^TLN3`0k)tlwSX%bbmfNLX2Y2@yU4&B@DLt|oA1bF5v}v`SRh&mlkY7h zsUUPH`F6wO0VypwU%aBj$VXZ!KZ=ioU^jJaAMk@v?8gH~K8v0~t?nvkT1K3#N*_j# zDa*eSK8rYTu!bU(;+`~p7?66DGR(H%bm^~oIF_#3L4 z-;RWx-Jzy)!-btg(1!(NCFG;C59kvYft|W6OzmE(VuvU82S;Y@+=usYx}?HXilNKL ztTd7KhmKILB;;(@t9rLhsAt-z$-|D7=@_d0zhc~wb+HOC%bSW7Buu66 zpVM(y*U!ookBlQO97q*1rag46QL_=3d7afMF*!f*2#LZ2O$kG4^ONo5Iak0WnCBV7 zrq&(}GW7vLY;OkKQJL^O%^mgA@EAIQ&H=K{W!sJ3y1LC4@1F!w`$kACa(ERkV+HLZF}{r!oezW`7Q--(?*=-L0ayVb?i#sEMU<-W%wJQ+<5JHM?m|`lAZ^F4W&N)4Y3v*Ej+(T4!|%B(z8qBkEs}X94gx&2`Zgye0 z@Mp%qgSDC1TQFMsFReR7-PFqEvmnl7?vg2B_!Be*GSNiPoH1|>#leEmmwU&|sx5RC z?Uy8OXCz2Y3&wJ@${)0HVV`nA(&c|d8t8c{#@hA2P1)G44;*u6YVzT1M(MGmin-K-I2xU9j~5#u69^J42n!lQ{H zH2EiDum*Ikl#39MQp83aq`*#^1ec&p_G0K}k}o}E&@}tAm6>yMgq|&E6^oSKk2y!+ zQeq5X+msa&XAePIQ(%!2QjP)xT4%7Aq|&qx$3`!(PT7kU)yUDzF23WRFVD=Vi}ycA zgpaZZ4gdFHn$It;1*)oaih7?@^xR=yV57Jba&VT_S_cc@oVC++j_C+ol_xps6YL3U zvw@?|P)FsO)V9&gL|zsyd$_8PpD;Dz$Nf?C8e+$p@c zm9gU{EbBWM&CBHFPKQ*xLyn1;GHF;jjpb+DpnGdPhhFAxfK%3rJl-|00#%jgAtinr zEWgUf)Wg#)!t@D?l-gc@ZhGkt|1@(R5ZF^GG8H+;4sO8;+I!Unp0=A3MRn@aW~$`o zZo=D~#_?I=*)YJf#i%CnWuB}IqAzSU7HLcrFT$4w%uQBb+}$%zcU7Pxtj@dY>TH@porP z=hev4fjtWfM@LA*3JL^(!OD>>935W8_)e?n77P5m0AmotC`OZq;^PBtoua@Z$I)Wh z$Yo&5>!7$UJg(^*1cjX3yn-#np)53Ntjf#sgsYF zpxw0D2I1P9*DL%`h)?x0F5zZ_tD&)tv zjS36(ETOLX{$0qA=Zrj_-;gyAw$G7Tj}orS>-(y@xI=G+lAw!4OImt=X@^WBvRf>s z19b8so*j=f_-DI3Kz1G3x5VQo-pph`l?4Yh4>O_D+!T;62G$ z=EBia!GaYeJLufOTXW=C(8IVs1Pyi$W_HPktyJS~z^jejBU%n)B<uw_1 z;4@4t3})B%PMFbIM>`wSJ;zgmKAPvCOKI)P-!;E~`}*~F|AIxvOC%(w))8rZ_aKH5 z<04^e1jX=bptfv*7PkctSfjcT1n~bj z*|f<_fqa7#O~mop65?ibCvt=wq!=MN@C*Hr4?>BP2!$ZRiGZHnq~Z}p3KoI1fV0{V z7LQ8^NGXH>Amtb;70nDlB0jDdx&u;50pNB69#K>w+7=&cJZ|y2%~Jx5=+h%JG1jL5 zVtMQAXH5TdMpMNA$BmJ}A~r^Zn*Ycc9uL+I2v!1J%dNzpLNEJ*na{F07Dzw?70?u_5b7;5DpX*_)Ty0R8;G{v-ob9l-CgmrSg%gW2wb#|v5r(eb zRtf8=3&R}uSU!)cIy>$hU2P*v&}?rmsRNAGma^x2H-RRDC=vlnay(k)zKi4xdC;c^ z{f4UDOsdR%>47Guy69OweU?Nl5@^gQLu1mS2t{#nW|QhLND z7oQ`z$R&VgVRgx)93hR$`So=G1}j`%Fto;9PQoQ@V;sjt4y_m$Pib3Hc}&>lfW-$J zDF|b`5hb%&>KOu~bZTiqwi;9%LbTSb+7Qc+2TV?3_!tdI89n@#5`(zoMjL&+ zQ3Ow)5N4c&Vm18DcOC>4{7yZgJp-7N&~fEXc_E+G-2)4(Q*lM%DSb?VjH+sW^2c5T zAG`%HKPuKz#4I9$j3ukKc!wq6k^4YvzB7$DbwlcSrmONP>lu5L{F-pKqju%#?Z%6q zcg0>2^=Tl-gBDKrBO58X2{i38GReUV_lu@?ao+|&y$4} zL}o!eAJ!5QnDL}vs4z$?Xegya){iQUBE`azVnBVIHpnVc`Tb~4GAI{RWa{}rwsOMa=9t^laDiCJkkNIn)fLXY<_{J-f|x zxObjU>bgGxn3dKB^J%Qxh=Fl3Qxm=w!(sJj`wbs+rao+#Yp=SUZvj(OKN`+oK&#?`T>e1VY{Pb5S z{la!hSBaKa-QVxK}QXKTz_qZFfkd zC*0)!+|Y0|JUET!5|e8T0PNzqygK zE46lZaGUEh?td@tyBoF(E*sGJPsFEi0Wd!$Lta{79-c-@)UXo zaB1xCwviKS&O9}n%SLzDY}l~z6IKW2db|7U61C}NtF-~M9|&Ky-?@-mZF47;Y$V=E zQ`x@%65F8NCB6Wcrnzj5IWh)wxh~cAPIr9qNcF;!y)pML2QS=i%?0i=TLaQf@?H_X z#Cg^ynyr4fZ)gBq&;ZRP+XVx^lwQx!lD(N+&$+N_b8G;%rZH#KWEbON?rq-i>^!&R z2GIaE9bI03RW1q_Gd{cD%LcsoE=2Ai?fU$sao3}v9c9~mCv{(rZ~n`+VcT$N`~kW@ zlsUX@+d{uKr_LKRO**o&a01PSropyl*KOOHt?^&kaJgK{H~dy^dc+O6Vxt z>OvonJ41lh+Xj5KgTKAJ7vQA{%<2ShuQ5BIoR~4AC$#f~f=I(DH^^Jw>#cKN@2N@y zL?dEDspIIuIjfnANN5CdyzBe^-nrsJbBK;Y?=Yk9V@)^EcdrEEcRpmWqeAD|n{T*k zKaf{|#4LpPZgieNpF?AG-8|2RUA9d_^G}R0njWJQSof|#af;sl{bP}nRIb zqEz|m<@n=vDpqzKZgxlhq4w(;RdtbBM_aZPNxZy0n(3{dr~WK$6lpwv^yg3-xyv>Y z;&)eh!U3guRYSmQ=|90vAiY_6w*6R=&CV`KBvd6U7#sWgOQjEey><58lmcaxWINJ> zxj>NAak;cWmdC|2T??^EI%FszObpHv%`n?vA~-?HKRGN`Qcf%WHL5WBSUdXXnN?mJ z;NtGMkG+CiVDn5k}(;C-BIC1S4d--%xlCqgZg4Pt+Ti1m|!AN z$S1uXI-C*Nz7wiUu<3{WG`-=M4`2b-MPEOx5?4B0x-1I`+y+rDcrn9hP<0E)(E-XK z2sWh6IvEXI7D)26;XEoZ+>8l@fz-}(Lk^?BAO|7D;9|9{3tZbm+-{G@!$=#9YWQ}$ z0k>s&*n@2a+*SizEyG>!0c~BMW&EC~-4jb1MwkF+K_Rr19tQ^*G_5ZLX=*ns@Xj9s zLdwyGg)hKOz*k1L zvoo_fq9G^)?h?x4$5)PF-!+e3w1Cu2w&oAXWYb%b)Qr_{va@qoRxzz-wU}&;6PyOm z6lj@)q}Af6vfL>YJutJh9%(<6iWq*zc)97Ogg+2hRC1zZm>?h}K+DCO`b+*b`SZ;kMGSq#z_o~s3b zhY&XcCuQ=#Hk|}p(7iQIO9SAiK-__eHIPzXPz`CVegrN zkL5gAg@;a`^gblOM0fDB$6R{u=X{{b^Xk;|F@(DySRakx`iJssvoF)B7Uw%pJND@v zRz!;$U|R11G*uOL>rb^nD!A5>3vLd_e&Cj<>OuWAu#TUF1A~v_Va$m9;jiK(XbZ z9{Y1ZDbA^mnE5pvcDgluOP0*q`KgU4t@*B1H|J2wBv(_9L={-qxRJ>19nA3JQw=*; z;9Qm6OODbTe+G;2Loi#D8;?E-IG~!&2`EUQ_ndLWmWPhn+CbPMc+SlP_F5{tLx;Y@ z{ccHRPtSHeX74gbl^R`&k10|Q__(v&ZP)ep;0fLL6S{k-cT8}(HIEC2F;h}~w)WEA zeq(+o2)6HMf@a}}=kDJ3T{oEqw0yCZXH@0|X?39Yf{xC022#NW@Pg}C`SQz$M*CfU zH8pb&>sTk2$iG6OMQc1UOlY=&eTFBteseA+aCCTdlt#Y+SUcz;KuMTFLkvQQyBtRA z{cN-iQW$*Pwk;O%7^DaoS=cykA*7TKIr<8`wr$(CeLNnI35 z6DPayhfO?*F!Vxfo>ALY3gs!Zrd5f;kkSi3sWie->;v=`<9A%qZ+aun@g z@%6Hxl@KkYPuArXSJoq^_I=ZWnnKa-xf={(lk&f7wtfQV;`;rFxB_gQFlqQE~VT6uZ4 zP)JJA2bAXiZk4Y4KAKER1(Kd` z83KI-v18oBKk-z^4S*>oP!)rMTpOzD4~z3CGkROu0CFEg$l||sG+`)T;in#8pL^QX zrW46EiYAZzAOZ5sp|T&CgQgL4ti0#}vP_~5z$8!RZ@vm%ad5?zx5nmWh^wH$8MC&1 zMT;I4wPR*0!}prf09;Nwd29@=h#58G?ySA0L(!W&y3bSKnwa0Pys=p2@XBzMr;>z1 z`NXNUoH|j!Gz-fw#^gp3fA-+_7dyhKvSx%u4V(bET$ElGhAU0zWv-5&EhLdE$rf^( z_ov8zqKCf9SKvNNDtrb#7l;whmeYBUYJB-x=M9agNF(9EY}-UmhT?F0N2A4qnB4BtG0~>7(x{)O379<6@9C@r9p<@5 z_x-z+AOAA{z5!Co(ZDzZ$4oqmQ*pHBpF=A~NbBhQDy;RJHK%jD@+bkD8aP4>tzoGH zyGo#>DHD`p5Ynj{#QkoOyOADKczL@Co0WoApvACAxkysmCuJ+dA|cyFpj{*uftwhN zhIv_>M{?V`bQRArXUwrRVD{*F$hc$as|+1|ZI4%oJMiX@%cExj0SJjv1avMWWKC3E ztSb~Y0~~UZB063{4qOTe+*-6ZEDxaN+ke#fr+ruVPk@rl=GG0m>Sqi?hobGUj;v0c zNRo1+izBM7Z(2P!81lnFJmaMR03ZNKL_t)Ea*6!WrALMS+4M7= zrg5h7frHaBb;iRO$gK}_qG>LhE+eu-@Y@Ig@O9*JEUPOQD{lD7Y~%D$-Xrs&RLnJx7oxS8WK84 znS0N7d$=5J7mlJvrk4J|%lGZe@4s7n=RiDz2nlS^o?NWWvrPoF$_?lGoba-MH+v>O ziyYxdXzPz51nv-!(j=$cZ?{)0kB1y@Vh~1XAxc5qQcA*zFVfgbi&hB3L*K;R2Yx%W z3?Xh(0(dM-5=&U37P7qX@Rj7*-1mxCuOroI}L>iuUW8!%CQ)>vK3| znUUWD!s|v{Dxoh!9Q;+Yx{lkcW2Y4{|vv$GfJB=&bhUjR0^74=#yL8&2(VJr?oypQ9NSY!)o(BJUyQPdq9N0&1{>W zc(W#+&@q7K8JVX`hj0L(b$RlVJY1F9ZEJ;4(O0xI=2_xIxn7I!JjT`O$?AcGBiY0e z)K;Y%HMd}9S)7k9oLM>gNU7c9)gDb*0L_Cu-qd?}c`I#w&fU@qM{ZKA;+X`uSBYt* zRp2gF?p2ZX0&;Csu7hR?P0JZqIvj-FMd!Qq!u9NW7WV{(LMdU~<`v+lk+2xrx1A3VF|RVEjc5ueWpXr?4zH-vag`rEp^PvG&}oIAicjX`y;~kC zD|IhEsg%W+Au{gviWWN(Ha0CK0g(j7dOMDJO5HVzKj|A*dF;#fNE!=ey1jflHpnRK zsCV&%4&AyG#lDASmq9HtCMVaJ=D-4*mpThZUJ&i z=>r5IEIBP7%Ob;G7763><~VQ(IkdOiVm`LCz=9UH+pTToGvdKLd8h!DG$E;b?vawT%JC^)^zW)1GC$kBv;|2j zNw2G^oXJH}DIt2|_T!~_O#J|3ew0;uqNW>8aw_d70ygKRDYq5!a-~#Q3E~D0J8T!l zgK!VWUHf_X%U$dfgED1zv3j=vyBP5jbU}u?n!w{|Zg8bl(yiDt9aHIwo|u*AQ9Pdt z5j4n3`fcqB9(jRSU@V$^AOs#IGXqwe&4%Jet=E<|iKsT0iq>P~}%xHU{wcVp_dT8k@;8$J7SXOhgnZ$86EFkD2bf%=WJQ({)6< zaPKj{VRE_OUZya0#(g%&Wexi zbio{-<(|#P=Gcqc%r{6ggm?Q$a$;Y9O9|#F5YM!#aCXQ12jKfWOTxCAxIP($LN6Fv z7xM=Pn;`&J82CP;L!+1ie-hEYpf7$@OG(k4U?F#j_^LgL*5VgZkyEenjG zIu;O8NI-~o46s#N7a5w;}3K2=TD5Cy1D2{>A9I3Y~=q!9+7{O+%!BAn4h{ z^Wcz2>^}rG=`fQRkwl0SC@&zwRWl0&LdcK=?n*G>82DuYZtcf^`i9?&V=6Kw@3C() zFG9T(j{PWxrsH)9Lvw!q$yJU}JYwNf$WZ$L1HgN3A3F@38|Nzn?AalP2Cc_ILGD~^ zpCaPYXP)h(Hf+z!L4Cs^_zy45z=ZyAr8vG|<=ux!sHz^VHq{j3lze1N5nLxg&AhN~F`6D*(N-#BkqXnjOnz5_!m_c&VBDHpU=Sm5&q#S_c=!G5tf10>e!Rw5=d6a-mAk8`K%$2NnS0)(VM-d{{8r2A;YV!U;Tv zWx?$x03jdmXst@P1dW4ag6>x0Ogf6k)D$%PlEI+9aGug*P*kkEH0`Bqm-i%gP=xwmV|B%EN7DKkF0*E;gfjNv@ct5qU^?5nB*dFVqL9#j^UtEnjcN` z>_Jo!nMQOO16`^s7+NVt7WwlTa-nrKQKmQre)(?YoRvFXbVW5Qs-z1xCJsjXbrP+8 zdQSC@2}OiDz<8}REx+WsAr7(%OHGbKv*+%8|36gWa!>%O>s*GZ&~;VR9Q)Q%ME{}T z5)Hc)WhS`Qvc(42c5?+)+QPx^9?-LmHJS2o6;dxqUhd`?Psj8#LC;sOcC zpmA=6sTF)}?==4-2DJ-B>r}|2kk)`g+*-)R1|o{V6!oEP7by&wZZSZ@n0H9|5LECS z#R`_GW>JbXDM4mRVF%eXd0C|TX49f_jK3e9wPA8`D6%JDSs z;1)$=n4ic~JI1U|m^~Q@bBxM%Y9JY&!*aort0Fe98tRq&7k2G7>@%J}3q^UJrE(h0 zvtvTGgd%vB@o>OHpG43~?^1HbeX^&d0+oA-ToJZ=_AIS4D+7+`C_{N7qly%dj+ibj zgJk27X~UucMHp%l%ZzN+81;X~_{o(CwL1coZACOi+cEyu=lB6muvB{2==$BKV)1Ng zaY*UnVbJ`DDX-KrV7{HoFh}vwurF)L#>Qs@kUnK2cYX;okrq~@U^9n);Cfh zp5ZF;(k$*A=^HfMn`rU`K&OPci9VVASrM1IuJ>Vtn5M#HAv>Lk^3C?VyiK-=AG8R% zxBuRN--D;bC_My|au^0Nj&G6Td65gEe8C|xbq=M0gT;E|n=^iPyBHuaNE@s@NJxyM zaGy7ED-T0L54hp(kYo!|R_I*YFbu;et>3ehqcdx3UF5Z~o)A(#AX-vexOi2=67aDE z#O-#ooU^MwB(`@62KJP&fcp#yJWMqe&R#>hY!m>aj5i$0{#r*a8>Pyv#j?QYE^Ons z65%XFdz044*;jT-Y3#0V0~Sd6=8s%>{7w#42tiJ*1q7Cd`gqgo2SuiQ7euiXCmrE0 z^N3Zdicfbrwm3e})qU@P%5ywhe$>S*TgE7dZS|X+nff_S_&7D|`LC*&=T&Xs1iB^l zKKe=0vv?vq#LBbj>$Nj+g?+3l&OFt5K6@gO~egUAui$D#ZJ|Jq|kuf8q7y*>jBgpr|sV z5v)}9XK(2gr>O$xDKbOu(9IS)6UjtuQqjQ$c6;)7a#*wP3Y2qz&bw8Ep49cbE5c~{ zZjDP%3G-mRVZ5rN-~g{hPB~}HvWy90S!ADG5Q{_3aqfx~5;p5(KnrVrXB(>x|HT3< z0_5y`4CI1X79!M)j#Ki3%o)% z={jG2GB9PQzMK>J3Qxl{^s_V!eHy9Q%^7KdU%Yp>d|Lxv(8E?BXbGA z2^Jt@UIIwFqys)mIm5mB*>Z3dbIkc*c#bD!WmP|~^e*)bWlFlV^44i~8s!ikOR|6z zE6-Gv1K&~kx$8Qt!VV|}UIO+iMc;b^%szB}`sbuAsZM(#%i??4{$o*>6Czo0Rm<+= z1%Li;6wS_c-ERzWr-bzFx;y$V<7gejJk2Dquz;W`s!iYQJDWAqcX)e?w%=Jsx3@Od z*1*nE#>A-u9#i)nNsF06(VvfT={tv{=gG6z6KEWFD$*cWItdQ!J>6`6zJJG;?-1XG z2_~^#bfX+cK*-FN&hfqm(|L9o-K?JNh8lUFBcXoGeD}r6zA|Egj-{#A= z8vwaH1X?K$Ns z)LvoSLM#^ATXcTIumFI(-3AHZfd@u>k@!0x6>uXq(;yQDf~RR>i3sWC@{B-QK;UK- z;vtLMr=l2PcngV^B-gaWR!|mwIbhSyg%LoTHnZHb9AoLo4XwcAfBXx^Ule{onOt1c z=LLpfA53IwPUVRSR|2H=s6R5bKUGV(9|)&2b*DbLDdOS8t*DTZ1#rU4X+0~YazCZL zM@5CQuhM$yG(bInWmWu?*;jt66We3~h3C*Yk5O0Y`Yo%Svd&cj9#ADdb{Y|T7R@D8 z;QY_g`C6T-Usb2(VzsXIBOsy7K*!|@Jo-1o55>9ziQL7nb1_#W7(wWCK|W1~VbRvq zPV`TS(pJTN(F0R4Jml0jt++H1PgDKEyQ&RIrZ*ii(C6nSh3lEjEcDJ^C^DFiz~ zXv07Un>Ae|%Nb{8fya*ctUS`_6LUv$1vFA!w?a)8|Af=yZtE(BBkrWKY2~I!n(9uT zxifQ99D4243ts=5gP)dlCiJeilORZxqGy7kt$4$H(nyf|$U37$FsH<`i|~ud>Aph* z#^YTZZo9X~H+jFjiLlW0NJt={KQ?o)21`4~>dqQ^^c{fd%{XTC;aCz2XoP0zQ}TNP z@bS@a+uuGuK4gH&64GF3DS>5K0JLWL-r>cewJ2`%LTBsT>>z4lBJkdRWkl0Jia&g9*wC z*B@N|39L#ZIzL97el$Lps9a!&&OGe6bFbwNJF^&KsRTpo8X0>G%#xxU6@kOD#$)%n zz$yT`2>SHN=~1$UT*#rLC4zWkEHPdv$Zpl{0Wn@^Ak>B7Rriw$dM;tWp8%lQPvM-4 z2gV4VH7%6ST-XoX^E~N7UJ=2LIy5hcvMIRtxBfnD$Qdt${CLC}g3U8eV9wk-)C^jw znm-|3yH^M8qz~{|>dMZG2H(8its>Z}j{r14$3m*#Fy7gR0NM;|W^BusbBY$rg#esZY>rtEK?W-nKm5@WeJrHq}Y zodMIG#kdZ48;wIBQ_)t!vBzn9;|l`4gDFSAt6lH$F$L&BjnQ}3;Mw5fu0o&tn!esy z*3IECd(6F!6@Q}}_B6RYP`@prZ_a-DZTtBC{jZ*H#wcM!Jwgz73$fq~8Hnd`^l>R-xVPd4NVym_g~{;{vc)3D)|L&nMu#9JgjfJE2qAC& zLE!C8ikpy9%5fCd)lEo~tRm$o7a!{_@epvegExOx0(giPq8;p+8fJE&YTzLT)CQ=( z)jEny9GT0zJ4(CYXD2?xYWI)cLR6bVc`i&&B!gs|~{ogemelavbQco=sTIAiGG zOgT_n!u`YwBztmo@{oT1F`DP>5i3Lmg{ssV^cp7xReOni#S(qZt46=%$yo2?Wv|yy zPcwJF%s#V*P=WO-Sx$Ju{*h<%jNJ*AqT(OUP93XGgWG89serV2M4T&)ye6waU^2$F zPUQvk(gf=ox17N=G^cu=Q+Gkh6+1O4-o391==r%aU{}$X%;oQoI6qFna z;5tcAVamr!Ml?MykmfpE!h_Bc_RR7b%oFWG`K+d%REmS%Hm>eVQQz9hKc#GhcaR2&=b1e_CM{E8(j}QVVb?0DllWx;Lc?$ zpyy(H=y{%KL5hR>8a+4q4bD0K^he;u2sRYw;5LT0=bUqHR$wg1)g&-L``;Owm&bZ; zB9%1IDXyU>rA?I46fFm6_Zw_rCrrwFi5Wc2VOD+>pgum9ZTtP}*RSik0DqBEuCrW$ zbzN~?g%qN>%2fha04tUi>o)+n0#~_0uB*+~9t7kSxMH|MteDqvm7#Z}@8tOkf)0b!caw5|QNecQht_Cv_FWa^O*e?0uY)!q2#C?`E(0<Mqj-+h!VzH|9BdiGMegyV-`_D@(;2{NlH~ZO`6s z(f<-;v;mjxf(Ag-T=Lytq7Kpkjls_i(110#G}sz6ThpM~-23i|E7yS>L-<-sMZo!;Z5X z&UL^GE?d+aeMdF_h6w^*`WTsGj+z#Q4u!1gBBd+i}zm>;SyFpn31lzhV$ z@Y=Q=54RpYbFhYNiQa6xTVa>%F3a!Jc(B}Tn`EE!j}n%*Fu4-87in_Y6*RDI^w<7e z^oAGmhPrh3KhHqN!8zyrkDPOJ132^yfMZtB%GEIT;J`dVtFG(O|1oGbfLYDlq>fEG zsEX~}Wd`^R6Nuv+UBCg%(6OvW@s3*tns=SqquCngj(wN`-qRWs&iUS4-Q~ql&^&pd zYYwslW@Wi-mCl%_8Jq(>u>@1mc1+#TG%KYQ=j!7_&9m13`0d+_aW)!Zx&G6N#H&qDO*gqT+}R{&S>BC!Ip6R+K`_hxOnZotd8 zFY_0y^KWAK?bm+A_1C}u^?H37|1$sf>+5js<@yjptSja(|Fo{_udo04^*{gpGCyWH z|9bxo!2AFFAM2OJ!ntMX#Q-VC@qdYH*Nfjo-%B}5`2~OweSa16I%5TdSXT)wtHHX> zbzS8;&&xWu5G%}FVO`f125Vy#>lH%G29)D^MZczYb=R0P9w4sm70oq_^WxgQT>oIE zB|#W1gt%VU2$NqkL=K9fuLdte06nl;FnnFtc?D+k%6b)|ZLdvpUDqpG3!T>$7Fo}0 z75-nZ*B)14PXD?>uB$uQ^?L2m_#;}^_1m@S*9OfZH>k}R9c~JTgV2*yEP)DUfOB{w z45W21(O3*k-rtlP*Q?0t7? z3!smgyy+VE9NU1GbblOBTR?q3pcOi?yZacZ492iAo?{3zS+=#H$1vKO|vur8Vf~ra)Vt+ zceymUc=SxKUIz2*6;ePz^;@k2Ui?e|7djf`@$?rnFWk)0+k3!$*!=f$@%_vU9-=(+9_W#oMc0H2gSeD?i5-IBDw6rj7mIvVW5QXss zCLeOq)4=F-I!;m?Xhk*?%$ouISR zfYUApgWH9Dt9DCCjkfK87EsCPMCIdKmyW3%fDWpJx)wU8u=HLwr6^H|P&kn=6s*1i zR$r|gsPam_H(4U2JaLt%I{_7M}M%MA#?ay!{z{9{`?Frs{#%K(C?~Ol*$g^m` z0=)nUV($ffW@beANhFX0&ym}~UE&&$#AilNMDGCa2L_|>dJsu4sFRR%`0U{&(ed4r z^j^qA+qU0$l8|RUQ`>gbODVgy2gLKc{*%$?^M`k`7acx*9NELe5QK#B0-hNX`jdJ7 z?)3iUc{FfDqzvkly=5kdUAl*Jq!8l_Xo~535+S-(!Ku`5zHM zdM`m8dOP0{`fkvslCE{E!U0(YSiO*AK-EE8;Bqw^||OvrJ&#J3X^S3d~y*)rqh!;W6 zumjjsvE{I9_%9wB={H{0js6gKz7RRcd-0koM}IMa=`v{|6e2uX?U8nNG&ds9bzMT| z8mfY*R1H+Bjsee*v1V0;6q(JCF!xn+001BWNkl;uJLkOZ0Ax5%yvq;PJCcwoRRqxN4YW=V1h_dBjLP#mI z5%Rgp`Ceg(Y2#4e-o0XFRLcP+!W0F+8HYw*0SdgXZp1v00d$-&)s!Kt77XIJRj3LO zIBh<#TG9&`ALhN2h{(AD4yeTKD0EzLtGure#r|3V8KLgnnd1FwP1~s+S?ekwhzjMt zM=i2BHaIb*F6O%$<_}HVJ7!EMpUZNYZp`@r~&Haa~7nXOP?Fx^1x0<4rMAXQE@sLCa(gQmQxXe4Ty#vuD~Q^R}$&b;s2&7dCCBMQ|aR|oPem6sH_)3}IU z=SKja!PM+9N71$!&#M_mW^%s|9D$-BNn`%EsDV zTHKvb_T<(Qh2E?~tW;kWAQlurn`%^QD5zNxU~$GjM1uL=GvdD2cX9exBuU((e8jna zX3vXf^{b6$$@81_%9?Jrj=MR2BaznL<5{}d_tE}A1N>{gQ5XNO9>}1qImznbolnUH z&5YvpA=N@8x~S@#mD=m*3ApUHrRQNemrG21+r0f@NnaP~?RKvKD-)fI>E`Cbt`!R$ zz@DI|tM65-Er(&Mz}r`5TdpUQ>LONZeACiVdkECx^rM~@Fhe&`{MeqIseWNTn6QEV6@a;(*0Og=sr84!mOV1_;r{Fa5fz=eC zZYMu7t$*2|XP{GU`)7222JDPwEzq^NI^de7zrI3QYY)&@Wd4TAFDPZ>jMVwO9dLDs z7N0i%09^IeDy8BCj-ln%t?JYSn{ECfvZk$4u{jF%`o&nS;r_=k{0fYe!pO!Oz)SWX zjTAm6=|wNP8L=4;?+0+-ND`7g^$jS6*oa8_A>w6{@SZgQ^b+h_>Lii$Ubg*To}MI# zy_QlE=y;-o^vu$O!Jc}Fj)p;ZMAA!7p5cY}ZFgiC!%QG4@cwjy_v1$m`57MFyLa@i z^PjbZ?7OFdFXTl-^x?mM@P^?f8cA&<$?Nf>KX?)(rGWqB;R!8!!)AbC4++Dcyav!v zM@>gWUh7Y0(9kUi)Em|ep99X6!@n_BOa<{m3Mr8k_!*7i0@qI^t*B5Yh7pd=53kn#!PP6i`vSS10~E|DWF?ncNV z*NLDZmiKTG@Xn)U8B&e0KY_$SReR)*fFMG($83Eh{2Z2SncG*t|Ae30U)Kel{ViyG zJ%{cvJ5x_qRe?LjOoyF2FTW`gVLB9%zXjiTnZOB~FuST^r12qcSg5O+bEFWaB>ys~ z=@R!mR8yu0ap@xTydQ^NEfN)$yy}3}TAIiwV!;|JV!LWF zNUIxxRIwnI&u4Rs1W?MTRG|vhP8?cPQ|!CSC#@piFt`+ae_&))+nM01t2za=`7@ar ztQ4$+MXv8tIv!A$gs&FR8csoJ=;c{Dr4V_~PAT_`R{9qxn;F;^(9jkx8<#5!J=Y6b zl+)>*4Ml{wE>Z4*c3 zAF$fm{|Pr@h`Mx45DWt&;KfYI@P4+V^T3k?NwA0T5Fj7XAd&ZY>cN2Vcm_7XyN!UNJvK@*;CV{G5E2m3h|onpG2&}}T`^MGt3QCUDz zGxIOvW+md{mZX#u4MR%ry#%BXbT}Nm2NLakBALiN3{A)5QM4_*_b`au zEGi2K2}Xwn@w5s{#6DLN=Bo(H4EQS%!wLebRsv!w!mGrx#;jzKh7hW%q_+pS5b?19 zAY%A3LGZb3E%UsKBEuP{hZS34d7ld2at$aUP{$66MC%GR>|wgO<5G7`Ygkpx;KCX( zva3Ut@g;=20}L0ThVW2`v#e;?@QvpFUPM(C%92rR0vF4)P6(nZVRQ!5<;@HLgiUnj zfOR=xx<^%A#73MzWg|U3q*eW~$yse^Koj@ErC(AQpxS;mQ8WM`*ieM%3)ZrjaP!oy z)?ua+t*J8iA|q;A1#X%Prg!q6+U~hvbd>B4z0#Fi7^2LgbnV3G&^WJ|Aq!RLsWI1W zGa_+h9R!Seayeq%P46X&NMQ;X=^jgS#90S#A;32uCH+_$n_m-^1mO$5WbHY^z){An znaCJ(mVYuA1TZl5;66jf0fnA1qX#aWRqB8N)Du7r9jPH6FA?QMJ3#7_)nNP|0R1x! zml43RY3Q%V=jYRh;cvt|GS1_8dg+hH<7K!^b|{Q7Q5G0YPp2PFJPzj%m*E^u#D{^$ zEOE?4ePmz^QLgR?YWmqlq#*!24gj)|^*~w1nt9-?@!Wvu*pK6x7ZS)5dfuZ}5K+?r z20ZziWN|uPI{8fu5So}R>GQ|qGxa?)n9t*7+>$Yl$DSw}o})oy%0HUOK8bdW8|y<# zE{7b6JBzDe=5uljZ=!k1IdW{Wxb@_J9=R~45S;FX()P2voke?V`su3(9Xq+R{8UwU z)2GXfoxP=~Wp8Bd|9}hKKajOn!MfQscp{**$ZD%j)%EMB0`4nGDPK$eaM&SlV3~%- zeLI!cJS5#7kwcZjsBU`(x46Nt-yypu1-N^u?p3EPzNy@fT>AFv_U_Yz>?pSqw^n!C z_ZGv4<;`(-UBcrhRK4^56i2IXTvEO7%zj@^aV9j}`B<%Lw`)37PYs*cQk%B9@^%+i zlpB7OTeB*#KML~)lHmKyg?Za6DZec>rdK-kujn7{jDknaW!*z7DpD}9TtC%qro`Gm z-MUP&*$7Z>mXvucxYuVjvdo;lKjK#nO9NzS67Ciqt>&R#FGwxZqQ1K<)f>|o>$Zl9 z_Q6RpZ*X-&mD!494NUbFQ7gJ@_4NX@ZP(6n(AOpC%*q=Je48Cmbi&ow;t%Z#w8kIX zg>OqXOwp4$O1I``pEbI+J9XD9x=c`>F>%{<=&tjnU8Bk1jwuXqSFgHkcD_X43<*7r zL`P;AGd7?JI`>V|a?a`y+!vN51X}ZHo2=&C5C*26fFAwO(2+oN?0do)M;JbxdVr#f zVM7?th5T`(Ix`!f2N@pN7!VETbALQGMC0Yc%)^ZxIU~{a*Es*(7;}7n`RiZ*8wi*4aQ*-s%{XFd#X`klm-od0Ffj20w6qy7 z@pPhrZ?A;G;4?9SdZJVG{f-zKN&A^WJ(}ooXr?p&sebbHC+q$Jg?h#c>W?!iR1baj z^_At$Q=q>#n*z7%=lCU7h>4uGPI3*E{V}ccJ;VZ(ONgIQ~-A16>KYt6=>Z^wS1?r$wn{e)R zI!!yNGUqv#Z?;-i&Ll2Dy7i=8O~mN7$7|h<2kdeC#B>Ox`eS?mGp1QU> zwp}l}Zw^xWDR9}7gl|AC9c4rC?4czjyq9fv?4P{WT5BTm@R|pBNH4wg`tKh_hxgyV z0G}@(e!l)Zo?e~+ap>gt-@j;WJ`QJ+QjbO){ORRcg1S?C`SI^YQs2@~|NR2U)6)^; zjb=!C?%#R-tZ{(%5{Is%K^u7PT8cbn58nYK8~Ck2a%9UQsC zkV(8b(K05Ia)zZ*D%%SQAJr^8yqMS>9+G6zwV0Fv6FtLwFG&J0#(ei*{_Fei-veNy zjUSnD5MCbQ$x?F;2MK(RZyA^dUZC-2!SwLnWU&-K<9_dfM7c?YlyhT>@4`zT3Eoiv zx`zb3W_XI)A^wn$DFHeND9~?z`r;5dTcHxDgxF9I-F>dWeqvcg(SXfIwwNV{Z*nl7+VW0}PAhLL+aW1UHJ`qBwgb)HY*kDrzFSy_W zVCT%`I@c%=<+N_S)*oIa_U|MM!(&g<+gIws>jU8C8FO+sR8dj3N`!(*&aVmxbykoK zp}0`79tS&@lX<-YYXYjB)Aj`gIWaxL?)Xc=rBpg1vV31%A+k1C&DbNVzS`M!2&gLT zT;zH*s7mb09zJqo18P(SIY@*G0#&V0L7|>B*p?b3ZheqR(lB!wN*+L66;rYjRbENf z!h1C;lrnb~E>e$0%;ZmbaFru}}Cs{}ZMLkKQ}s#_tOx>#+r3C7%30PH=BA_Unm?a%-SnD@e z6>dnrS*!>b3$2g(;USqAC`IeVK5pJf_k@xlKdq4=ORg^&(sr8}Nn>k65EGMjr9-u= zRT*AG&vvFLXOXx)?TgIx7rO~X%w!~IOWOQ$rM=y@Y0j!@bC%^wTPswtd_!-dumuC6 z?Ve-(UE8(jP6+^C&oS7nV*vZwwS`&Wg1<2J`6o`gHDDHz;grT&qk+1(r} zZd2GhN0_hKcKdWfB6Uo{8#!X$M){2^CKZj{7Ix)X_4PV^;!FI`FfcFzAVk~0DPmZ} zAD^j@^bRu_1%g1wm!9azoXzo~FCUKd{Cs{sj+YA$OhALaKORAmGXNOF;J)uusJSQN z9vs=%Bb)K%<%N#N55v$$F2|`KFXMO~`s0xZeg6!C8HS!t&(Fuf7&8nnKm7H>kAEA^ zBl;fT^N5BLHw0_|0uLX~mlVxyz`%Kk2G@NVXC20Yj(vN?XMpI~00bU)xEn=0IQ1I?;HHU=<_u%vT_a-fXc8+Ua!Z(b zXmZp%$DPZj88pqL8M1rQ$$I^Nfh%xTZUl;8^vu|q$sQA%gEB2-jN?kupIbPM^OR7n zmD{*xf3>;Y?VzgN{`^Or<@LzPUVPlzuMPb^dhz)T+2XjyPC>{Y)&cghet%=9P3^zQ zBe?a4T^GtMkUF84qEF_C;(pNlhG|-T?;5r$2HCmFtxNu=sALRZ+mv%(hg}t%Rjcgs zUA2V$hkgA(l<*;r$lY_ru>W+R!l-XW4pEPU``p6zWgZkN-!toM5;3qVx6OJx4Qso) zNRZ%a z;`~W}V#O-h(m}GVW4-Ev9eRLTP<7m`HO0MUwYIksCH38rSf=7`Sby$XNbXsXxvgScS8fB^uIq5U>gmm{#WfS1BVsPi z#jhoo<62mW16_vi*TjVWg5f&MhTCICMiJ%kiU2Se?kA_}1`(lR;N$bl>C^)l&gUc* zXFv@-e|PGSbR7E&`ZIn^2+(9`)d1$0p%okErYH2^A)-=710s6)>vy9WaRv{GnLwxh zav5KKcm{C(Z~^f0!!teixSTHoE|)WpQZm)@Sn3=(p zI;dcfPlsX#450y~e(ck(07PWU(>9>UTLuGc44NkGdJ0_69H}D4;HG7Fc@^}(6?po8 z0)GMoa44L^36Ued_!@X}Bj>Dt2l_&)eRkGb{Bn0ea&OB9zA3q_Zo-d;vW%sm)hjDy zy>N}5&X|s=>NR6}OCES2AMbX1(e9CQ-R;b%1yEb%)a@K){c5Y!+i$}Iz3+DU1(W1e z>;n7113D*k=R2qXyTA$iY1SpX6>A{!V18Ges8rJ^OfTT?1l zcY7XsgMiwA0o4>RbVhTePbCHY#su3kR*BTq;SNfVe`NH9gwh z9?aq!UE8*QPAmy$Rnp5-J8P3I7I9SwhO}L>`^MG&V&Q%PRAg~nt;-kKSqJN`dG>YI zl`i5Mb~bIvCN8)_!)l-(3jpjtkq5kl01-*(r~Y)J z9$tfR?D}sYIzb(^^sXmKm&@PHFg%_5k&QPTy-MWa053>Dwh~e@Yvy5K{S5<!qGxeyQ_ z^YP5ydzfJyyhndLcCwW)?7@bK4xYXDUJB{G*Pn*0G2#J2n+#Z}p^h34&!3pRChDam z?^ytl^{9*~jMOwk4<@g62_MC6AYJPS#5BnkPhf8X`bQXZJudxrOr4Q5e{{B8D8 zi&{dkkEV&u`}gnt0nA=Ad(E1)^q=9qHvpthw(4GbFAfBOnb{H1GXN=>`Njq@wVLK% z3GlH}vw>8Q68=}<07RBXVKq)NaZci0D1FEUAfoh{X|3+89#1lFU>!5evk0>%`O_w-`A#xxj}2fe=LEQn+|j8#cqYTIAX%r()dl8=PlO zweYSf?qRh{QrR6_>C|GG7rrH3wj|DEdAibxu&PAz8xh$E!@Asv`qr_R+{>-*U_KV6`}eg3eK8{!l0dTM7Y` z!V{?~Z7%OW2*TY7BQ|P?D;G%TvIWen@e>vwU7%;T2JGV17To@~>VB~V&?=+nS=+4? z+;Bkj|3k#nQ_X>ca`qn%E*T8!#8#ep&(k*7?S?}DbZwi^GtfDARnEdG4Xd0@4ReM1 z+!Sms-*ms|t5cD5tu>s5)3`dQwmWs!LMde@N^~MNuS(H%fynb7%fc$Bpb|0MD&UKh zjrSh>Q?~FB-n2!CGJ)nEg5i4zYKR0uOt#wuFttzJyB>Z3bITeDzIkTz@#BTrkUaEH z{isK1$Ya+<8gU~!qGZ%3fn5f?>(r4XRQa##>+@eCNDg^LHt#Mjc2319v~rGf`kNl&(uio zCBP68CR#8`lBCCv%$fkmNJQ}f;G?mNAqc>GMD)xIiOF~{8VDw>H-GSKwD0@l`|n?3 zMPLHZ(&wJ{gifOOQEC|`vY5U1aTau4+xH~lHS;I-FrPfL_we3C=$?(gy@xm69}d(+ zDMF8E4G0kX;kEP%6$*DAD_9RSz$YL8zkxqPh6I!4BBbpBN%Qn>WF}!Z2Zcl6kX3!w z7F|2&8GAZqxQX7x-UE4FN$R)3R8f#_?Y{h60eiyo_&bE%T5K4%U(KDU9+dlY`^>o| zC)Vv+l-IX_?~V*@jXIn8-hbezyEr{R*LIkgA|u4|A^K_;L{+;a3mrri6?!8L6-#`! z*q8}1V^HddRBZggf|SbJ6|jZqSS&cIhp98r{(o45&}XF_pw(+p|% z5dpNC(2Ecvh@?@RFtE$w;nlpdh*T|zMCY}zAskX8lR%`yp5S9Vc@<(o!D{K5T|lQo z3lyGv%dxmXaW)C31)#E}vSbKB9I6mPs0v}@1@aCP5}jsv6%eX$I2>m2y@at{W)9m$ z@L`TD6hhofc)tUq#lp9BUgvh$@~-gED|DhmxVf6|0_fFZu(cGJF?4b(Tnl$bd~0uP z^aXzJE4y+p=1Nr{{%IFgmA-;ukvv>{JKRReUoG>hur7mGk{`0jMvlnNIvYuaBXKUS z6W4i?+_*w_nRHRebLi_UP3qc7rA|*L(AWHqZgrurr?2U}T2F3>MKjvW2GNOkp|4kc z?bY_w-6{qS&Lyfr_8%S)YG^C&5FDcjRwu^k%weU#{e*z z<~taoW=I6+iK7wu5TJ&LdNjikpd*;6L8MZE5*wNeeThgXh~IsFIr3nJ4R50fU9H^8Jmm>vGi#8qYtg`9K) zHfZvZ2@DLEk(v>7Y#3u^8G|^<#!)Ffm&ni!8WT%F0pPrC8WGS?YDJ`VFD`*+Vn%*N z3QzzA@Mq9Bt3PMWk=zvq#!zzv_%~)rEmWIQC~6W~sK0(iSp2u%g?_&es;U(i;6@Yb zJ1}vb(0rUN{B^I#Z2Oj3al7J%ZpbC-e%^566T7c$?yA+9vg-B{$8SAH;Yi4Ede)p?i+auR^W`nywF5E3?!}->~@!_$zE{g?pPLbdUQ!k4T zW-a6vGbElqpMY-LmA2po6rEI@mww>s1E(4M=4!qC!T2jQ(CTYEh%PX_zAojcuRy0` zE#XqnI(|^!tYa(-9lHpfQ#-$W`4U3-^5r)~{5qVY%V1I%HW)BA83pzwAnYkgLxZWO zD1UtHVG_uDX-WW`fLKObG|3DbFtahK!ma_Bhgi_oH1QM3sT$y6Afn*|%rG2JC&FYM zo#5vPTrLB601-3JKYmCcd;o}sVT?tQoN#)>CbnaY062+Pk3+6;OYI-VfkuF+PX&4? zg^e@7YRb{?4x za}!0DV@)R!@r>zLjU31Gil4jybU=&0K+a9_FK-B-C|o!iL`lFU_~+bA!$}zsi~SV} zNxa=%1e=kXBZG-i)Bmn&Yu!IG6?MC!sIOl={~50>Sx?5O5Rr86pFfs3sSkBd#L66IKJLl?>7Rwzw6PO)p^yMiYQmGYM*$X&Y;$&)4LFE z-KQ%H@waX}UinL1;F$W6$)(;pNZs;^)!xQx+JmUQ5(M{_du-SHjS@>(XE#N&b=eH7 zZ0UcTKxV|y*6xmAyD0aXueDZ5vD&Eu<*R$wvc%haX>B);2D`~#qu3|r&(cSmd6)XTC@8Jp@Wp@D>&?qoy+gt-2Xp%Gg9K>1JFP_#cz!Ox zW(iE&DLNdbHUM2jsdd8EyPC=cg574lTXbk!bSL1dC)hoOwc`QXu5CN5ueowD0o(}R zb*Hh6fv=mOuSnQ=M*nLZ-^~&0)$7Zb-@N}6floxw14dx-Ntptwa|CpL4O5XBHOXlt zyN7@b^YKVbMHIC_Xwe^K!d%oe0Qv?*biP~|+&@1PXyB1e)DWhmG{F&|1H%At1e(lD zjQ;tE%Xk?EqW;*^I56|@^70+iX&i+_*2^$+C%Gwuf0Gd^no7~F;;&C9LKYhnIGhbqv zV1n&*jB#V;5$CAR5i1{Ku_J*eAfLp$iTV^;j;dCC*XWs7Bx;Fe!{vO^9b?% zB;nCa&M)%@gNoqvkhf8J$5WUxCYzO{waxUU|CfJx#wTZ;hElNBy%IUK4=*}@Sj71z z;8U-jR6X3F$@-)StEGA}b))irdltKMrushS+W~UL&)+s6tsUkMTKhg)y< zrhNtVmc8T@;9QN`s$6tm?|m;9$XlCZjQd&~wg?0PfUOgQZq)?$V6VIlMAzz#lVjaE z>hAD&v%!#k+kxG3KVWyu_E3@-Z*0`;PRZ`nwz(>=DALQWLT-1!#>By_Enb!k)^%;| zog{+Yu4t6Jrdr**2{g+KY;)@2O)b?7?v;KGl|O?oZ6m`s($z80D5Y41$^h0e#G zd`zr5D>X_AiEw*kF1p)0)CW*x7SMnFYrFdIu~HEAP6Qk`qXb_$b?mOf(%vPx2j;W0 z%Z9FPyjF$9?!g7NzPTwDXeaTw0y@WVFVJ@F%%nhD=+m`R1UbFg0(vQnk#K4Z1)mF` zTUZZvi-5G&*U6z|VuwWV-JVX+S9Cf->x7__l-@+)Mj=V3p(E(uW31}+24HGcW^R1> z^2Pg48Qz$TZ=%CRlMMwY&}`OG(+O<#l+oK@z)jL!7@nU`Y$$7$C6Yh{P1Hm=h|K6% z#wCdXHZeR+O*28QA>%Fr4Z{U|B!Iz}AAdZaPQ-);&!-cBaTu6Kphyt-fFE<+RzN$|aacFFE zz02^S&5=f{@VYq3V_~v-5{+2NL~M=!>;pZvmwLE~cejB!_1gaC)-2rIb@$qoC`>sQ zaKKut6gF0UD|L$kmdrzQ8sPK&v2zG|FXUgs=)&t_+9EmUq7vQGtZoa6=FLuB&R|tL zd(%)Px`8H&%HF7saM|sOLax;0+%n9qR-+|?C5J*A?e?s9xUp$n2FGWc(qv1smoTvF zRKnMVr*8?3);lRmd*ipb6>^(6hWpB`J$7OG`VTk!j@->D_!@?Ott0CiF~^|3I*wGK z{m*~`w6nTc1fwoS3)MR7G5~cmaJ5cZ1q+=X+1QIfmyfsd2ri0aD6~)t_yurn4rnL< zZRgxCxH{N>IBk_u3fbAj0d1!uc};b2RztU0L`N+JouiMIgLAn&(&?*n)+wa`4d?VP zh2xN$_MLH23L%z!HGuJc7>3Jej7SA#g1jWiXr9rdAqa}${OIhFBKwkhYS07hy(dV3 zh&o6Bho{pC@Gt;LFQs63??DZ`e>(O06Gr`W224qu!NapTK$7=hNl_}LgHqVYVOfBwMZ0P&6CQR@)^d-zYRz1AN`)&m<2@BIO+*~1Hh zVeR?g*?abagoKpTu^GTxQtyR__OqNs+c7i7fsOvl`_upZ*B?lJhBj>vBB{0c`^S%$ z4xBcNDy=U)zxyAd-_s>uL(*f|GwG@&LFsy;*=bwMpgZB88 z0I-Ml%zotJ0R9ua@m@em;~7#)F9H9_!+SIg&;DocKQkMnHQ;4Y^f!TKFC|IYw(mqs zBpWG3?CGSvLJ~4oKpFr7Qjl!rv2c%(UP4F_r8T7N0SHNiPErT2V>u`UBuRPbyqAd5 zBHkzWn2i++;Jp_@^|flg1P;L=h*&)mb{!FRR=ZSyQ~{N$DuECjLa0Mk2~-v#%sv*= z|5imo%;cc4lo}{riyE!n^12<#{h}sPgnRNDds-o4Q^qIko)|^BaPR#!xLlnQ9(a&h zAcRVU>2d^$QkCLg2xSF#tkd6lf9|^}E|#Q8s^u-%wmak!n|Xy_+_AF!>i(te=v1Wl zgQ%)1N@Ao_)L4|kVHUhdS0`4ty^7KtYJ1W=W@?}ksYEtv8B7KuwWy0RoE%f;%MI9d zt8uAwCKHxvaOGMfwI~|fc~Cu^LcDaQA2X`*%((;s{DE^N33>LT9Q;m2&tqp zl!M*IH#3?Gxj0Njca}<|IzlnuF%getUG%ibrGe` zS1y&tkXR4!_@$jCL!cIzI!(;qpB+fVb~(agnka;TS`~k;Zx?5;>-Q{FD60_Tt=rhN z+@4aqOWY$Jy_tLL32c+SwRo2?ipS_Ga7k(Iqi!o@>^Z>&H(KN1L>^1}u z5tTv2M?FdE8gu{~uz-|AQp)~#j3BN3rtP0(jM_$R4FMqlFGb&XY@jtqxeOV_Hl!g4 zpJBF)^`D=-hbM`Fjg%rv!GQ?)41mx*olexX2aTrhg~zAiBfqH6tuZN5&z2^hK4W#HBimr=ZM-M@7G!7HslW53$4-+>8^1uDR|Mns=jz4!& zg8fgdFT?QhCp{Sb4bXJY?_d7R_v>rUqh?l*WKHCo(hW7^2GrVD=z47|7&MoS?Zw12AAm)|%X90U+VEa`XmaPthEQ+>Xu zV3EOhRfV+GuV!5)RW0k6t8GL=?5*emH*gppSgXYCHB)Usu()}UaI5Cp-d%-j)YTpE z?Pg>epO)FTFWJb2j1*S(dxZ)|*nNNJ5_Ws)u2I?i@XWBgnz3_uB>XIH8y1Qx0*a(M zl3nepN=*<**d0&91*DIX7~$5*6A}wE97Ya5SEv#%WzjGBxxL>nlfz+%c9Scdmb-c9 zseNZ~F2?xIgTI;~ZF(xfD(U7Xj6*q+!ES zH*sDI#4Ot}x!DN>8!8d*t`W7WQCBK~so;Q6gr7smd()_@;@k>QR@G8=Gi<`dlQc*O z@lJ-grCCs1LdMMt(^piR#e6G5f}jvk2N6^#*TZ6bR11Y0yB6K6CUKiW)eo=f(}{WM zns@cpYcnW4MyBLN@w*TTOWV*p;evfg8_Hl$n10@k)~pcsI=F+!R)MZ<(cya5GuvSS zdE4$e`lo0BIBRqTA0tvMmR=`wQC_<}+JZiT=ZU;guqkvRNTbz}zI@dsX(XOOCwc~O zovc^3NWFybZM;~Z%?I34J0?oWFz4lm(HJ~8M*xGF-8u%KZwMyym#3<+hNzEKe{3*d zK+`8uGaV-uY@!m-WRsD-2JAV{4ZWRfddby~yyT$+5cL%)R!)tP-yUE!of4hvaY=r_^n&)OsM?W)M6yp6x?4kp~m;(+r&G zDeL~5X~^}?;B_~Qf2MA+_Z^Mqv1i@d+R^U)CwLUC|7uXCCA#Xxlvz3 zPJF|61hUtlUO?M~M~h;?0*q#cG|)op0@Y$cq1Xqt8-RN)K92y|{g*FadS(D;47gt)W7{dj?kxr+V zBl_d;VT|H#<1ijiFAZRZ^FZjIkIl%;jF)4N=JKJ*B5BN7{EpBh+A#Ih(6K+7s1wJt zNClAmsps!9aO`Q!7#cuBS!E(&U;_{xF^(l)ndkqFWsWe+Jd9=-xPa29Q*#6^mywB% zlnB*55raScjfv>kKhs2aHc3Im6lY1-iR_@5dYX}CLFPUOOtkWjmj-H%{d5?b(R1{k zY>>+#(`E6@|IXEcJpD@4=i)^o5MyLq@@U~$lnQDZ92H(L?<;h(=^Dz>JUL9oKuc^%F zwRfJ**4Ap>-g1U7GWqR|W2yF*G8K zc6PgUj3ZOsiV(QsgzF87`vaDl9pCNS{(1Euw5-*)!2jNH)NP5N2hQ?X>9s97eO+(; zPgVHXP64-`i;v2e#xIG8CTA(-u5EKQVT+8O7iw`)0{U8L!s#sxO&-|$3eauao>Gwd zx{4MTa&psQJG5xChFxhouG=giU3|Gq`+zF|y;JizU&X4;xw3CPWpvox>iBha z@8W*!Xscxr!@3j~*!fIxRkZ_Zw*bO!(w(rsKYJ9vT52ONrLgNsC&w1>v|gxW?A#W+ z8BoPsTNlNty|jW|gu|EJ@7@YdzaqeCSN;9^7~I}(Rn&Y=Z@pqLUf&du{K^Yi+{;@9C1kh(aYgC`6zv?1bzLKn4zH}Kj z|4-q|Z@)z_Heldn%>jz&xt~GUgiuWpdnSs0Dt*ew&+$$}5knK2j6NGg35y7=8j#6i zbP1m;m4j=(THL@XBpCp{mB%Q&9T4AWB+PkK7`1DKA-^M^|WiRba$Q*Zj? zc^nX--|@s|NHN!jV8Dh4gZ>ypqCHWJwi+^#uE9ifI-Zz0$ww2SwaPHYs58x>c>v(c z<^1y9sc8}{rb4d-z{m{4X?6V`Qd*sE^Qj{(O@zuxZGcA!Bed7>q&F^pjEv4+CP?&41@79D_*Z((YIz$s{iukS5*H40e0WM z;Z})v{pP^#4GdjEllpqV3#u{Hv}Kun_HN z&05yygqWkM9oon|)@=)Y-Xk}cfnGg>=@~tr(x19A`diSEyB28MM9XM10XoKq+uX$b ze%Ip%X(6QXAz=WudjZuA8lE09bBM6Wwgj!ri@gHHf(O2TAp z3T-wNusg*-8SCJ4@=oaqAj2uNeR?JaUj`WPu_xde3=D=Nc>y@~r*SwZQbjfziSIN- z^h_^J4<65#a||{Qh9U$^l!jwZNH#8gxeJKGYz_VOhi4cbxM8MoI5TsMuf7}!&nLsp zna46PKMY|0j`|~wyov)ypnv(>hx5q8@F8R8r31?_a7Nsj>Vh8h^73+y(R4GzU$f_S z0tOOCd%~Lo4*)Ux6QzLm02pJ2sP1gWq0l2_08MiuY8WQj)1>>886wE?%}CUDriS`H z2iiw)ba-ji*KS528 zgEA22-m*(ehhbSbENhk zyDm%M)*FDf_k>pE!PM8_`}(zTSG|ykbnZTwn}3`mX?wxINPE}-S9=!;FIr+>QCFNv zWP2a0r&NT!JE2q-RWGr2t#+sE-cI9Azb?edRpI?&?W1$Pu8UocRksT*R%4-lcq?x2 zTCv*wg=z;z|8xAY{wSN;U4xRlNr=}10AHu>J`0yV7RXNDiZXUr;M*KEae#xqLa7$5 zQ-|~e9Q4(x1N7B74L8ZsmH$@nY>Nw9r4-OYwac5TVPoN-0@@Y;tcJ$b!Rl$zb`~lN zXE^H|;FK#C0tdL%R9L7k3U3sm(`wlZZTV~0wN<4)f95E>fx)NEg^3~$K5H*DQBe+} zrC!Qb`p*Ca_0&)=fEH4MBuD~)1bKJ~DW!;F4D(A$82!0#JG2tBe1s=R2g9&0V7WWx|1=)Qa3KY_I|{nPVje~@79 z!Jqi4r*}Q|UF+fX$AP_;o+05iOQQEr{rFjX4e7m(${rrxcoH-k^YPcv1=hD zfOnmIIkjdOk}4g0;~9Wwe*fJ&@7oXOpS@>99lr)JFkS<*5C;KK`9yAI;0|C&uSd-z zYwbU2HagvKW~`*+B#D+JTAA>x00`8v|5?I-T6oX?lV<}d01wZQ2Z<=w0tu3mB;a8@ zOw>k{knkS#PD;r<$T%Q;lHG{6g3x>anZ5V$H0kRxlE_^t%F#6N1~A@#mQ61K@4o=Q z0)NUHLnZRes%Jq_&U5+jQx8S+Bc$Sw|k0L71`8AtYdF^y(gHk`9l?U#HC_S zmWmv>)pIJfr&_h3?6*)aw3X_z(tV}hP=#v#_MYxYwJP7QikqJ#F($bSvDY;swkJTv zOLS2%FKT!RAy!&ns89tFwZOzw?7mjD3k%7B#YjxuH|ga~!V*y~BT8wklv?akLtwsV zg(k$Vu3|t1QLU8|t3pdqC6PoCJ1X}}*ot#acd%Mq$aYA@KC!d@22fX+Bw3R7Mbh@W zEkz(uM`@Bp-&b*jrm>S-qfnJ{7=VKfHmu}3k_3xdNdZR9y5$%a+i@*K4HTkuSw=+w z5OuZei{NmNNf7VJ+^AZtWfN>1BGW($DZR0tuygpi66O34S^Y7DNi-#F7Myvu*Ql$y z0-%%%~@rZK3~}7v~!?K^x_jc?d+&!5b11o7Gw*vBdI3H?)gvz9l;g z!1`L2=iH9ZYIg9$vDPkPU&*XV6U4!XG502ZN3jCFeZg4ZKLmOhzfQ1E?iPAL$|FH!f{>WzZX)7Y7WPqfE2m2u_ zH~T0D2cSDWJ@=%4{@DYbnWO3(^RYkm$CsZz{xoRLI~)%$0XBY!cK{MHUfYeAXgff9 z!`^7`**6kG8m+z8u?_P#2~E?HlnmpUz4uZc0I(mySz?Y2qBx!O`PMexfAVwVVyBV> z#S4vK8BziyWe3m9gMb#n*nS8=+f8E%;jpSIp5|er zXRT(OTHjhQlbmmi*zrj^|ur2G^g&B-j>p$P>&N`hyRInkT zx=AKDARsCMqeAg0t5Agy1Z-Fwdb1-F6Y3AU7<#F9C-RXY#4H!?V1wPZ-sK~SR{-?h zWC-)qI>X5swJ1Pj;1*Unl_#Dpn!L1Hj?a%q71YTve=MdK0;7KSh_3Ua; zS5xe{5;M-u-B2i1*APJn5kgqWcE=q|WNj#=#5ba@>QGIJ$?Kt)=h|vUO%uM<0K9Pv zg4p&)v4IY_1)vMi6J~Msu)3bbB0o#jyVu7;RYWdap=OS|0J>T)q8Y=-6N{pacHYCx z>Z!$@RGWb=u=#wri%@TYeRumZRx;5c0*Pmxgg9D#ZHt;ZpgkuVbEa_QKV6rEja#qG zqlom67QhKzyHU8CxYT+!W9iyi&n}-;U-gnJ(w5}xwp8uNRPMIzb}Jk=?f(ttRe&@@C~9tZAYGJn!> zXoyUdTBb<@gGZ)k>id2ehRgYkGmd@VKlj5pd^iusQ%{6(h=l0o<%Pf(J`cy(c7_=k zKtsoY2g6DBfiVzIZqm#^Uli0eXbc-lR|^8cFgLiI$MbU^TbcMFiGvbF;28b*($jg2 zgy06i%c&oS59a|yN5jJ~CZFp*M!9KXnxt-w4LUY7Sp$~Z8mIm^m|++u<^n~^G0a3g zN49>92OgHZ2X4?$f_;fFV%W?gAqy|bXg!$N*M^ZyA`PN|2|cGW#^_WYDd1ovl6w3< znrR;K7f!B`%tQLXOn?WNq6a&G21i3940Dt#G!4gdtu*>(Du-bhG)(B}_{<{#gMzcF zDx~eU8h7rG$jR;3Ha)Ple&fmOZN%zco%sXV($ydBt9ydi%?ay5D$MRFlhm*E$-aEb z!nL{HwBPL#iT4TdSPDI5m9y8F1#ZFRKt1U*%oTo%{Bla@V_Dm$UOT~p3$q{`ziqgb z>RosBVO%0>-)h;+_1;jvAIlKm4nEn3kEH5)VjQd}5gV#Xp@p~QvG2Q4-l+jl3u%hN z0dd6{wiZe~WH()xMB!KTW|qaDb}_g%VmNmFon7L`>SMKqQdrt3uJj}(^gOel-GYvC zV+z-9(~--{R<)qs7q|CbDR8aetWvKMY93AG*~cdomdnPia%!jUteAE^`0XogxTlJ< z+la@D5SN^gb*Jx+$()!_^}i|$1*I*3e8Byc}J*1iyR(b6JSaEZx~PJ#jU=z-{!5h)gghNz`?AP@2hCqbT`fcdM=BhnF0y2IMO#_gWvXev|9i)W!-b+9pi8}J1*?ZPtpR3;_ptb*bIBWjo zS?f=Rh~9noid=&!6K4O8bUVx02tac3DRCeQg?i(^(Z}LMBLtc894~P_2~NJcpcf8 zxNrSG{`$iceKsGpmj|Geg4y_JQ*!J(*&Q`&HnSg!7g7S>y?;9BpS_RaXZ8$ce(p~o z`sqCCPXoNCrhnH;DVaZg1XxN)Nm9O(Imj=i_nsoJVj^S+lHRAFb#z2A-Y?KIQ6r_0 zooM^$7D=u2*h**R!$U(Z$$4MQpoQ1oS&X15(eMb&c7!^dRKe@a4YS{-02vuyw2WiEuK<@TA%-!;}T2#5S zdql?+^s*|8C$vu3d=~0yJ2Xf_HcjN4`lIyo;+Ny}HM zV3&E@)QqMY>D4>YJ6#Hjx#GP5O8rNZxm;{!#NVHEX=DI*7dwXvl zc}&1w*rA&U(3YNlpI5H)1}8~%HZ0#vG+08kY1G7BL~E-ARDHSZ*l z#4~_ub%;}BV=;ZwF6vnYB8Iq=!cVv?3~ZX~v*3|8bAIY3oJ2})wd-m=8%dFTj*iLp zvTmG9uiKF7a&VDN_6M7d^P%J+FGVS2o~w-)$*{ON%m+|xA_?QpE*dyjH^9KK`yd;K zY%X%F6S6!Bt&-cZ!u?y)QjD|2vg-ZU7mEwNK(3M_8`m3~GNiD)`3&g~Zm-_?@s}F+ z0&2%yf!_GuCO4W8-#0Mrs*9v}hC3-m0FaH<|2hW4DHGJs9`%L@Kd+58i3DPrqh@(F z6M@7yMChE_Fpb3s6o;^~`r#4t?qaB@ioX;n#$td^@*al*#aL7`+75da5(ejwHbW3| z6!nr4nqm&kIGSQCk|q!lVRXEV;&_EpvksO(1kJu2FCbl^25GHHi)hrK`h2XKbJbsZ zdlRbF@%&(Jx0lE2TTaBxcn_<`&fUVDp=2zynuC%U= zF(RUgYE8x%25S&et+lR+lvY;kqzmBJ&RAy4Y&zBg0Vxue>ez~~;gAEUH9#EjhEi-8^e)gO97l~-p=Px8;0T?5~B4Dj?emH*b zUXAHQKu!C%UmBMF`f~AEoI{2JL1%NzW_wpD&A9qyIfQZ$KDk6J0Kt|y04u<}a^(u;_GPV-QdST+Q zK)Y^KO)@XA+UbBxUG~oXc+hJz{8B5u?%Qa%lfUGYN@-Al2wa&TF!o_ zNVvq%YT9`fWS5zbHk(S%!=Cosi;Y7F8t%uPN z@ewblYsBP4IjCYekJi&I0D1?PPfCwm6>w@y0JV$H_XuVNp9+}y{Itw%fc{=Ze|>H2 z(2r`7u$X8j?#G@d^?kPxsi-36x6kvSP*7^CB^XxMn^K|iu26;Z8l#Xq=oSl-ImI)Z zaWj(Dja%s+hQ1DF8()KeR$efB|ArGLFT1?DK@nFNHTCQQKj2JOZ+e93{ z+Aa4!T+Gz0rSM2D+gl&HIJwma0)@?-$mVEH|M~)j%NKi9q|*F!m6ogJ4QIJnT0!Ck zq)l&d4j<7O_n`lDJ-S(kwD?RHG4;5(73Pt!aP!n~iwA?-=z{VOb}mEpYs8}?Fb3*( zt$HXT={qLY&g0$Ez+xj|Q&sgBgbu=KC(YhQD!`1xFb*cB2#x+5gHH}GmOONkG!goU z?!lvHV}6YB&8c9c3V7ZJehwlcSwsdU!>kmLRZA&CzFbf3C3;}66{YqNn`g~ylplYI1 zqYsrf*3@MUu`k!FkAJ4JtqFjICP1{-r1h(LJ)N6h|NA5Q8{ZfrFJ4RCd3z24bK6!L z)Egrrq_tOY(cCp)-A?rvn^ST3g7uKHk_G z^9BM$j;9l~T8xE8&4z<+SwxHoAM5%J+OR=T`a%SCMaBr5&a<$u!pu0>&hlnkrO6wrhCM{uw zAfb5_lUQ5e^S0+`ZXNXPS|U44fFNwdKp0}ggtIOXE#en25HMaPM76UZplX@+T||dR zmkuPf)`3KaL^gVx^$mrZ)bVhD2wS|B>Q8PrbKA|e+4ON(6vZynmfi{nWJSoOb$d-a zt4~ttntxA`>|*+RmaEgmr{pMhYJeA4?EI?O8NGUavHahrugB+=A5 z+&e<1EOZ~H-E|&lD)l~MxVvOrjk8LSfXY(bFfB>KV_P{jkJqq@tDhETp~-35hRPH& z-G~CRp)47e23g_Eg;~ zMtUjpn;ql*a(<1W0pzhg#C>wnnn!${Mhqh4lvMQ;)g6Ty-j;3~g1wv9y@Jm*=1@bE z2%WdlfZHtbDn^5E?e>;mNp6e5TBuz`biVkk?hW3eIi;UVOxk8|OGo6h=LiVFb!-9d z*z13Zz-$@kQ%hhfTY$T3$FL=V*Xu5VcJU zX0{#L^9kVo!nR`ub4(4SvLqjK!a;n@XsCR8YQa5s9rx%<>(Mi!did#l2I$gt@b+*F zo}Z5!nNzW{sP9+-<}A}T?cR*WXBc&mt{-TamP4g zrj~=jGxH>V4#e{$o1We9$d4G8-XeM;sJ-&oGD;2;0@3l$YmWiTTsGuQzZsU%(;Ur? zWDF;VaGu6A1VKg(N!VuqM9e<4CkevzlKM%pK7}5JaSaE>)}ri6v}Jh)0KNi40X6K# zEGPedKPYZWEg1G3V$*Feb!!FQM|@cNsZCnImGABNFK95%N!z7yfFWtq>JIcbzNqQVNqQ@wdF75~gNBD5NqKF~Wskv*AudY;^!+SDb-R~)#(QbJ_TqiMXD&}RJ?X_4Qqa9XrD0crJ&y6lvYu7mj(8js=j3sW%Hf5_ z;pUjf;k|pr(zE=YLHZwP@mN{wy>Ilnb>bU8nuFu#CTFqJkTDL$A9VT5qXc_g-MDvr zD??XB5yZ>+W-RgrQ@OwYNgDU+Y8XCuA?Ek*iNp8@ZtUac$d*H!80F=EQRKjqDc`642!O{0$UbQU#M-N%&or(L%0T2^zbHHV8FO>Z;jD_1RFW%5>0&+bMtl> z7Qzfo?Hly1yNKcT^zilZh}RdxEI`N1uSRPnRaKML@D&9ey(t*bti8KP5JgPrnVMGY zgx}dKjXlvUB4XJS#VUHRSYahvlV*s91(dhVQ^BB*uu|J4GnA6n8ivk|;%YKcfhSd69zFF+B2$mC$BU4sxJyyq;e#OaG&Y zSTP5MvU)fuh-E-2{O%MAw>01?ieN^zU_PC4NsF`^LWOl03g?tlg90`J50^+bV==sN zdu-=Dz9HenUE!RY_rZN!j^C2Z`yZx0p}SkF8y8hhmwm)od!xEoj^9c=?=l=}msMK$ zLZ}SRz2ltmF#}zwJAAzI;*o4}#qdyg%-}NQi91@#iAOrk!3Axy3$7Bmr;DR`mr@(< zY~tt_C&hQdskJl4#9uiT#?$k2V-PW@Noe{h#ZqM3RC-)$-Pgaa1f&(e--HT)qJ5Ents?Oc{+3o=e^7_2E5uS9GI7h!e`Qg1zCub1=e(6HM&-Z)L<6CjFKFyj(@#bI*JITfYhlk_<#xxAJjL+~P;R!Z}nS$1w_smf#x0TV&d z;@qq0{Erykxqamey9l>XyDf2fF^THJ8(o&EEL>Id=jWR{jl+Gzj#QH7-rdo~`&8u2 z)t+AEljwQf^^p5o%R=N2H)M$%&MihNc~WKXRC@sRB?JD9q5%Fpi!=f=QEWudbyQGH z>WgYEkKRGgXW-A_xP}P&Ys`2W5jPjpw;zNm`K+b(zUM3b9KOhd&4lNhhxPv>J(JwD%VuPll288lE)r7O*b+sd21y#>L8 zR)Ryx?ZTd^sy^@xus?JAhE7kX=s*mDfDcSdKqVHihZ8j!;_5LBtq{R$9ySOYd992+4({ zgZ9UYFpCwX$o~$|sL2Ch9dNMKVN|uImPLe(*N=FALG3?X*U%y?N(b}oXk#Y;Ls+cH zA#4dE(4O^Hq+-V*AYu4_VmSZ=h6Q>PqWKANb!9b9UhL!eO4{4l(Ri^v1J>jQ%fO-TRz-& zG4w8gPM(Sp>Wmvd>J8@3?n`OZ{RKv_ipypn;Yob$c8s~kSS`-tQTgq=ETV~QfuY@I zw^iD9lcgAcJJ>ySA$3m)A2#(Wzs$1FiugW|<$&(?Khr<~ddIk49c=Mq>I z6s!SYsUn_^EL%2ysss?tjhU%}Vk`Pd?Z{k2tx3b7Dlm1aWlnja_~-%C2snqlNc9>M z{f{vSB7&aA%Q8|~?+(r>7Pb4hKiey%h(>au+0orO1N%3EQDI$xU#mE#5m`-&Y+mmV z3&iQCe!d2B%DKVKDvX7i%K=%?uqO!9?b{%`py$XIGi69b9=pwUPC12pLh5`Y3z;YN zh}C9`X>7Bt3`k{hp*s&jf;sm-KF^a5&twJg3Gh2YWeUqCm$Xgg-ZqLnxoiiFn|YH( zQC7N;EEJpy|D7b^YXGg@1<*N^%JAp^bD5?z5wsCN8!XGYsc^aYs7U6MQ}$|8!-!(U z4_^!{@WTWT=*bp(q39@pBGAmmYHL3*-qTVSf#ycBu3Emm;r9$<0-IPz04*A*NYjzf z8z7pIDL_+OA3<;OLj+>Y;rwuH+g9G*Afau|n!dAWk90hqsy5_fOmYQ<14wKyS_GO& zhxR+F>ht-C3h2f5omg1r+sozFy*@lWX^Y+%?fcBUeYBu$S`YW0o}QYsmacp4Uk!r= zY{1MGte_vyr>1%M`#+vvjq&egX6*x4URiMP0$?2k&<1i4EgI_U!y~oT&D?^^vj=Ee z2dOjwX3O?(|MdxCjghuF%K`nZuM|D}^_SaA|NVA*I{#{a+yrubIJ4#}SCjY=zl5py6-+OL%6*g}Q?*5?aq5Y;Uk17kF_hGt<6O?52*8>3mk#y1s;u!w|d zAj#|%4l-?!c#pe4 za2GAEoDDwT>sYLkIo@ZN-KSvn>Q8q(RMWfZ%JOyd)XNS)mRL!oZBpuv)LU(SmBqJ> zYu}7J{LBJC7fTGHik&cp8Ahu#WMx?uSbo~{szuXh9%D`-qq@M*4$6z6-TZ-Wa($T3 zU7qiEOm1Mbis>qm>s+CrJ1}}2CS(;cv~$2#P7!G_wX)8RJD}8^I!Lx*Q@yr!SR_{X zY>xy$C-yUH4>V>-xaT!fy=%dc&-0*IP`shOGYOM3B=!T-M-OwutizbO49Y1ee|B9& ze8Vto4dmZlqAniRGJaKNEG?%DF?Y7J2(o2dyXU8; zr>E1`?zy{OuKwk=>;K;Mr?xpgoloDMxa<3C2QW1)2>mmAaVvqml9i~11%p~@x$S}0 zGP7kczJ7aZi2m*Q8BvQsU<&&J1oTYya^XHCWqZxC1sb&HbHl*%-=BlYF#{m(IVf#Q zbbSZ%SUliJB7o3$J$3fm>8btp?ce_X_vlI-HXoI@%nXKY34KY;xhWaUeQ(kK+vRfU zn3+m6?HS!As3r(RLA^^2l|bKj9nL0KGkn%bVZ>-+X}dODrZU)gJ_ zy9j?vptk_prXgxC90kEN#gTi>cLz*%(Oc-88b%W>Ut>84!2{+l=Rcr~?+of{F43YS zLR)(AcbHb8h0)t@Q`?4OfiHUyF@Q;=jwl$1=e7ypk`l;2rNz^HcEW$kD9VmU8x-HR z2T)QA!2ZA2pFh22bD&-H#czza2iY zzs2UmhUKe@9dFuM$UEV)sHq)`y-^%CJ3R}JH>%DgzxnQfEcb4}9~NMT%d!ea=EX|dx>O2$98bJ68y6!q+*N1dopQwxN|gJkWJ;FaQ`ByWoe$-k%U=$w z)0{XY=lQmIz$3OiWOAnm5kkmzozk~+Ym&JZ=|JUEMA@*5b;2nhqQ*ZIsfUk-_dj!? ze>_zS*w3>N6(t&U3y1{r~m*U07*na zR4Lvbw)ejA-i&`2Mpx&Adp2w2X?`SIG)sQ^?kGg^`7b~P9QN*IX7-_5B!Q>s+3ZDy zCx_}Cpw|ex^16+ps8JM={|>YFPsslS_d5>|;CBr*J5Eqr2ci+7?)`8i{ia!fl4>HN z5?aIvz*+|#a48UB0=4J5)m6{Ew?im_zO&ccO@rEVQ&nH2m!{RP3{CoYZY|5{SXV8X zo|~q&0JW-aAN*&NhEjC=KYl$QkI(<}_R{rU@G5}TR7T?Q>3ljp)-TT&bL)+Pm&pe7 zOmu!YG4%80#UnqqY{alJ41q{z*;p3H!||a6Dym4+`Jp`#ebKh6wRGHD^LRSfb#=Sm zf>>K12T!-^U}SMnU%x%6zBiq*5E8}Q->%nJuofI^(p2?q+M3uHft-(L5oq> zea~(C&>oN1+tsjW5DtonSd14cFx$GSi0bRhZzAg3uTR?c%&avuLyTAm3&cuYRc(9L zb$c;4?t{A$eesdynfbyy1N~~qDFIH$()=I%z zqbgDqDQZF#Y)lq=tf|&Di4kEVfUavX0!?*Y1K^usxoK!kb&!cbz*fZjKzmA>d>$c{ zrHBClT|+OeR0O(ew2hJUVhyp+~voFNGBXBBK0AoO$ziL%N&n3Pb zca;ijJ6;#q-0j^w)kOrsW42a(Ozu=JWqtRAExRVcZlCOS>+(Y|uvIP#3YK|1Gw&a; zO(I@1&_m{2l7YM@RY(=glW#=Y<{#{H-R?}t+|p`X?TU<2H|i{IdR=L8YL9^)_J(U5 zhLuOH%4XyqtS6Ea={zr}+=vA^oo9Q1X-sV$6*A<=vnhC5IhR9xd!fB z%ahv1|D0#VTtpd{Cf<_N<=JE_#mS@wM2t>5MQrw=NCB&P$`Re_!aG4eB?8&7x zERPGFL_CDdn+&GSEn}3u58?Uc+$4Tlh<`T1kPOxTzI-hC5bQBP+;J6NRPC)G_qpmK z_&|?I4ok7b&GDA4w8V+EZ996(cKDT>%BEqAKb=(TM+z`~?5xHvkaEPf6?b zItmlK!c;*Rx^1aeq(xYSx%ZZHIwn0gRBEkAV2lw#ebUGF{B}^_HzGx(NL1Iq^jEH0 zT^)~fBx5ZE?deFGpb2b^;r84rt+gf%1Ar=`LscKE)7SI!Kc27G8`yeCq=`y`heA*1 z)9I=0pD(vdF9Bh(02VkAJ+>#q{Cs=y4s&d8-Zc*a_C`PkU8}m%U@^Zuw8s*!re|S@ zK9atf?q=+_r!$M(dJ}-87Oga___!I%ho|$gu65US@@jxrG2DqLXr+bpm(%0<`?V)c z%p%~bJvM@ldn;ZMjkYFpGvB)lk=DBQN)dVWy9ce+v3lsmbbbGH`n9bUIwLg*5CbCt zPu5jk)ej>2@^WFr-bv2GObMpSvYMX~ptIW3Z|E3bGyP+Fn@s;unyeV5w5n<)!R1>i zf)xc#RC$+dqEgdQ%Nw&5G4X{Eh_FC>ij5aoGd&Ol+;z+^5D^Vsx0>*1;mg=+3mwvDRk5?i&rxK#j|D*n zm1W97VH|cclRt59bekt-{IS?RO5F#*TYXj%;vX>LZ-$$s)yM(FOd(#sgSwZlrB{~&*#XcisC#pE4WWk z#p4)1Yfcgh_)#t1yD~b?R%)HaJ;Ti%y<5MGKgO@l*`lbCIXfBCBbkf}-k98JZuaS6`1;^_?O&1jr!J;St?+Nh-#x8Eo-&!K`3w22-= zep3bj#vk5Oc?qDW?_$YG?-0;qF%&o~8x5n_x?Xy248@GX$06e3*!kz@YZc8p#ucP4 zfFj`MJJ;vo0EK`4ZUt`)2!8hlx-o081z0rc5;RA70I!x6YO0}06KOA;(9vzTq*4>0 z$va~}ge?>4$H(KBN=q*SAq|LPdA(ivAo~2&5-D@-jj=?BzBBzxM`+t~1qd|3!t@N$ zhPiDYj4}WCpEqMVXpcvAMR;X^`Si>2@u|K(|8~2)GJ==0KwHRDOLcuR%$KfLKvkC( z2kAwV_I?o%$gE7zVoh7s4{deSa=pD6V+;!c=elZZ{g2B9BHw=fW{fq)1nq}MfFkfQ zhpIh49r+-Z4V&0q=OY^#?bo9*riK!>7TkV0wx@?fZ&-|XOE%oyjA1KJ?Jq_|>l!d( zg_>FeRaMt*ed{`+wylY~8`oNENC%Go&<&jxQO|t4-XN?&63AoEGOMW1uxkF%FGExb zs0Fyzk>H=WXMOJy_V8651mxQj8Gs0@vWCd3wIWhg8gwKgVIyL!g(B^dz19@0LVVjQ z_gc4FYwkKmPr4DY5Yd`gSc#?jsG%$@1Yv*)z717kj-%+{Z=L3u~8pf`k#qJIvm29hU zP+8Qx7k9ck->2^*{hh5OkjYSG33~HDEnw)x#5eU^R&EK@hXvHeI5%bO2gsribQtC- zgec!)vF*!MjvNKloXC@mu3JK0uOc7D6=o}tuc{Go?v2x6e}WACm(cS(lto&y{}4fE z4k4v+St(n-F9)(5&--d{P}OjxEb`WGJ#MW(K)CXm^YzByQMQ z9>zqM=v=(G1-Y~ZB4LHIX(f=&+6%WOoQppUU6cFGxX>-HQjlqHsXbexmzw|rb3@v%-nH#x$g8JM$bm%S?nD5w@?qDi?ve1 z09BE=TWozcrr%7N*wa6%$s9J4!7JK0WOOGR8B^jKMF9*j1I8hm(^X5xIdaSaXAgcK z#}VT=6vaXtcQ_n=>fe8Nj5kD61&!b1zwrtNTGBD?xdc_H1*||gz!;G?4WO#asy?2N z$M$?~t4fO&W_V`|0(nJ&K(SO0P2092+OUD9x+Xw(U1$5l`RR;<*sJM#4|?SI)Yeti z^|tmJYk4)sYOU(y!*Aa&rtiTlEIwPBS%kT1>DSZwdVPMr+z@<#HG=_pY@4Qeyxnd$ z^BMuN062&beI|j=MA7jZ0vID-ACDHVx6Z^U6RD2J_OZS7{qy(k@pS(Bc)psRE$f-Z z7E)RRy|JhE_(1dqG1h>62(|WfXnQ;w%f46gO{A{r@qc@K>y4PhTMSP(ul#iSTDPa( zT)nopqFO>Awl>UK*GFCVa2 zeeenhDWR|wJ|k!&b z5|OoUz(0ZC?{l^B4pJZ+kS*HYvISlm!~K53*K-o?2Y2mv?&<;RZ35Hayp?U14OzBA ztDmd_u0f*0Y#9=OT^9SsvirXMt4(Dy)4b+09B_z`TP;cGgooZiA}b9;;KjxOW8P8e zrJKr=klh8|yBlF}*ZXg3UyP^O<$#NpU~bWa6EO7rY>ye{F0R3{C8?a27BUBy?Puy{ z_Zf7bwH(@pM!#|yrbexC5oV^A({FGw=Q-^?a>2oENL;~+EKw4v#jY$uEn^IuC*IsJ zPG)%%{hVz}9ogpO6d6+NwB}sL^=~tkA%mLv)j%*iw?oDT?Z`Hua8hGss>qbelv?(= zeO6E~N4LKxtr`-&LH@j!WzT1_mslH^jVprJ`*AZzptpLd_- zh?MuZ!N#lARLId8w)c{_4pdpf5oAknmn~838d$p>dGR_*_QMmnm`?tFldRL;>%8`H zn!aY@)+Z&VCoY%#MP8)&_A@Jd-wMMycgWmy&BkKDUV&^_-(XkPg2Cj*?UW}__@Y8K zUF>R_R)K-W!X4QF_>tswV$s_)axRJiFaZkBxb{D0a9k7{ZH8BI zq@?wV_D*&reBvaA9)Y3=@@T*P5fC^Il%j_Y0yIRVg#l}!1Psj@A@riwL?SXZ>WLWc zxi`lAFugHv@>UvmMx2Dgpg}#snSY6|3BZ&%>YtsRTHtiz6zdxIkruE{r>&?rStZ~I=DLE zd~Qg$zumqYuN?5}1BM7tg*xE~svx}y)(y-oTB|oD#+o-4E02%IW7QgC zEI^(QS32M}2&6tATVZPr3q*_dE^MTAb!-o+7Rwq|n5eFfPhV@TtuTu~NB|=G`uOc; zzV{t#ji>f#*qXl66@j^XH6CCl!UuVU0BG8CFX*}p+X#1KCb#x59s&qa^XsqQTKZzZ z^2#WosfJZZ97Y03oiNrP18DzAM9PcLwN|Bu)mA!H)=H7G0u?-=LnEOQ$U%E(>rJUy zsIKd_MICK3IH+qhJ&;lW=%E$yKGPyVsc`T=hOZDqNM)&&$U#Rf61+lMlxQdq>UDU^ z2Yy`vM5Gj1E8%XXeqY`i7v0*K+Lp7DXO&Byf7y($vsfa(gFuTt##!ArzDu!g9+AkX zb~xA^pK>z0_ej5!!+VE^c01s2gQ4eVq6<{a4u)PC_onjb0xQknM_<|YC$&QdruMqU z8vDJAsa@3LdTM4q)ho{2Ii(ib-U!Nk<9?*>UGfp?T`dQaTspPd=`jqBa`>m4gv1Mh zX@bHPwz11AC&D@3dxaF{b2XV9JLMdp1{V^&U0VJhhH>6?ZyuslK0m`306KIO_`fK> z0?M#u)*aklfghR5miBQI(B4xrWO z+GT1@LJy1FzihF?YCm^+QXOo8)0k4nF�|19_kzqfw%pN+|)8Cn^%PG+)7r$R1W> zFs?MdSexsoT8?Zl(ZnShj`fm4;Y0cJ0>xt`gi6-AzGlt-D23y*=llRN*}Ch*v>j& zP^tZJn(BCDvDO%GjjY3%p`w;rGQB`6(txgyk4IAKjSq5o6FETeczzT`*Xy$gKh~|T ztC!nvM)>Lcr1TeSIySE?>>D|)PZZJA&_i#yGdH$N!SC#KEgI^VZ@>Qa+h4VqYxkS! z1po}gvTn3jJ|q&36?plL?v)g0@aYx+SdXAqK8&E zOgFHvXRwGsOzDk4y2 za&#hKi1z7{)(Y@XK!;e~;4n5lx$>;Y!b0EWLF$ZM45sef$!9jp&75?xAgDiycz0@x z8Jyc|kqLh-f}-O6t?vn!u_6WUeY>@mV;4ia)ROid4~-p}Z}zTUd3oc{6Dn~Hpo_cG z=gF#YF%}>4(phB3mUV<;vr5WW8iy3+#AkChS9Vh*olO$pC5+Bf1x0*QYO}Bi3(od4 zcd~>#o)oIRFK-qk>*~j*1mZ>{&4YOWlo{X`7FmJ-Qu%spOY=iB!nwT$Qa8`e z<*Fr9*+xPD3>a4qV?nzKtsH>LN$M~JJ*oNxy~M=UtEP$%`AWGx&q^ep%d6DNaT{1rZd zJtl9AtF*sy!Rd|xgpFP&bSITMpYEe-mL9Js_Jjqt>1Qr^Nt z*dDAFVIp0(M<@~N4VX2c*_gVjsnWOp<$7bW%wmMah#{>tJ+SHOhht6DU9Lttnbrc# zrLNEC#&oaWFITJa-~RgT@oRm(e($>8zyhK)iT951?PD_2t`z>G6%Oaev$2K^KtdXZ z`D$(qA!rRcSWCxNE2_2n!PbNDlC*aMWDza8t!iUfI8Ihl(5ixNA5Kag#Awl)N@~w% zEf8z1fxv+E>G5n|xxf9ULC5nGcQ1wwL@YE!4%R>`VGE^5YheLVN$m@FrZ-TYY2Nv2 zj}K4({jcY$;_LVBcI$id(EL)9Hey(;w$MZ(8l;tI1+NhIiwi2@e=~oj68REPL^0`4 zLB&;iYRE(rA7s45Xody%`9?*2-UTSZ!1&)33tq|&`OH|3z(T- zh#F0`Wh2HfRJ8Uw5zjG&)lRy z*wGIpKYkdTm>lYoZQjGsb5}|vP?f?ifw%*pcOOx+iFO`rH^R4@U5oQ2{d^aTZ+#OA z1$R#jy{;R$`{+3-Wo+%jXV5w=MU-1(=y*ig27{{$op>0b~#|^am7bwMKa&= zJaE0kgf+(m#3b`#OwtrLCwEgXiby)1pb*b8ES((gD7NM!P|8I=aToD!x?FavCV)6T zN~zd785<_k$+7W!7~Q?n)at^^7K=YMo1f3SB~$0;?dJ zY$aMrS0G7iN0w!YXvaHMF9c%_`{6wKbQ5_r9tfcjx$aV@%vc z6}Du4VD^hP_qVxqq29jOBs*H0bT>@$`ae}rH~jM_%Aejx7?hBPG}${-NkmPX{IR5_ z@%$ijKZO%Ag2A%)>Ycur`PyBt9Zqf2Hf_^Tv|EnOyWA5sq0-+lK-@8&lG=MS?^oCJ z^}+y}Q`<22=!mK7`nILh=?tL1J~J4g(r=!*Bs#ZEcd=K#5a@sWU*FEa-~ayHbsTrz zdkzyLnk&x+!T~}P;mZ8{d}*j*TrXX>Bw2mrA^K}~dOCyY>-luK^gJB`0l=lZHci`< zE%Rl1pO-}t(6$YC3`-?IVK>UMB;pceEi-e+7N^q*;EuT@lth+0O9X#{N`{3cl+=Q# z?>cW{O_p||P#QX&pU$V2yUXR;6SDT3x3*-VoERAA?K|(n!wonwSKd(P*>--#jf$w+oGma1nx z?znZX9_~%}&+qhlUJcv9e6P=NI%I5a4deKqy&ENJ=Db*no7el5f948bAMCgsz~Pg3 z#vOG>{?3(~{$sd*gBtGN>c*8Qdzd=f?g>rq-{Qh$v2k23cFyx~_pZCKdmr}(Cf|w_ zg6nmjudcfx*~BOA-Lv>U-ernma(nd*^f+VC@kcb-$1)dSdPNar%{%D1o`~V1`b#km z-W9JXFpg%#IHIUfth|=0py3$DnR6cZ5q4E9jqd%ni!e0{U@S%yZ-=+vm3#a7Q>#Q( z;bjb>Nt1^5HXKcJt}6=M9UFdSz_1APL5tN?5~+q-tyE3AuIjq-b#SerwXfV;Xb7}^ zW83w;H9zd3u8st%v^r=JO$4pbS?>AOG6M(E$H$}AV8a0Eio7Emk?xE!Fa7E9_{-yC zTPZ*rD}*;Td^|q9yxiDWiFwTmQt7&;`n$PZ`%7Kb|KtDu+nI3r$Mf~p)$Oru6`NiI zEoovcfPFO*eAp5K+9z}?^u`iZbz8w`_PnGf02&l%PPRk}HNoIZU9qv^MG`?SAqP#z zV{NT>>CnEll1i%EN;fU{23DXz$Fo3;>4n8wqiZDsb9)uY`TWTI!fXij0};TM1zMNX z9#}-Aq6Z@V(p@@hpoySSl2%%aNC^n2q=(0cZ{NPv6}so|=4xWY9Ye#g5$i21f~mHi zWZ{X7L!bq$WU}L+4G&Gp?*-oeBI+iT)&eb-p)?6Nvi?xoS{4!DAY!#vG4jybP#&vp@rliT9F26Wwi>2td%N>l-3Gb6pM(W zmK3a&pZGn4T2OVvXXFFw4?MDB0XbW65qY*KN4ve|ssueR3CCEXOF7P28>_Ny6HcP~ zorIt6z8L!6L95UPKCW4{<-fDtZl4%?JJG1~kf^<<>TH0w{fOwYvGmysq)fIkiMWe$ zu!^`-v4zup)akh<>WjQknHSg=Uz94G!u_VlNfr`)#6!Ej!iv`q7G=vZnKeWTE|E+w z#WPu*=Txdi)J(XER8cv%s1Tq^-B>O2#cjiYq|*rL5h#}`*DXAUQxmoU|@cr@^JY_ ziklOpiv)o)2De3n~=Dk0}48k_75y zeLkN~p4O!he3%l5OrLf?1bo+iQ*XsHF2&zEZlZkzLe``fp+q3-z-a4}n+ za{a=G042e43Y}L3=JVxxYMayf)S~ISzGJ4yRr@Tw>-Bm%JyAo{GtSNBl8i05yIfDF zwrN`QG4QVp94IveD#7d-)Nmlyzq9pR?bG=L?zm$DwXG*{Tc*x3U;BS2;MAN!c)nhk zdumREHpXK!O0)nqZS!<$&xA{Nxn8HSv>@=r#UfD8Ga0*}a_vkx?|j9-hX0mC@s;G0 z1Iwh?5z+ulN{Q>~vzTp|V<4c1o%}%9`!#by7c=*uSm1YnxIzE`AOJ~3K~!K{qO_hX zPg50rjO5IkV|{=Ga077I73+EVHtaUD?YpLF0rWk@C(my=jbb7Niht2pG{+99kneNT z<6YKc1o90Xl`r34toe*Q_HvE$i;IP7@qPO21Kz^(+T&-2W!~S|H!}0ktKry25)L0R z$QzhYX8H`~=QSS~{5tcedQRI0(d!H6lE8Vbvnvf&M{andiet8I-Q!!Ie z`G66_2b5v4$&oAaoudl;crix)F26f~<6dzB)!E;rDxAQRzNABJUW73kx@=ml46M;g6E$U99gIL&ly5hL4xL^i!fcJ0Ufzrm`^KWR zZHc_Hxuy14Q&m@WeQfKNG-)WUwdsr%Y3YDYUS2y5U6xcGTdK5r!^=wtP2LqlQ_Fn^ zKvxgOvgxg1g9F!X3zplpH@)!|3xYRq&Zb4TZ6#VgU!DQ|bbfqnzg9Cg3WHffW}&vi!iEJ}Yo)Yj zm+h+nHW1;S73U8Abcq&8NJ&p6%PX`ZU5UJkM5ns4)N%+lg|gA4}*eO3KIN#*)=^MH8E!P`@Y>(QB z?S`4lyf!pir^P;=MONUNc-~`?-MIKv=iuDnrUs?$0q=6oZs(|Gj&_wtIBfXhXmGmV zp|d2&BTM#hG5~Pvaa;3fo|)eCx)s2t+&aPFj|H=ZyEeirm9(v!DBR2p0D@UclA>rI*(_bfA%GdMK?oFk2lbcrcb*rg)4c_Yt? zU=0VrWf`2y6r5Wd&@Fs*R6Ij*|FS#2Nh+jo#x4r~Kj*K-Y}G30HYYfnN&wz@BXwhq z{u|Cs^tJj>?;QE*)yuZ@b5%u#8r9i&-E&G*SM{d#(A=S%e{5LoNh9t5x8CQUKYu!> z%JRQVY+N8eC+;-TiUcnGFM1B5*sfnQu@i;p3Cl?|&1{J+6EjCbx(t6L_N;b8p3U>p zSH9W~jONr*>#6M11<$y8VJlHdAaqv%{Pct~otgXo+C4va{iSEi=sNafGnhEA$IZFv zyZ*Vml+=DbKLKEVE}!Eehfn4X+)@MPj+tidb~+RQh{}Yhv;g7KcbC39pW1Kdr_JB(;b1$< zj0-G?8j7nIOuM%8#Zkf>NaS)ZKSWh?_%W0%EC8>E_P=4a2%2;PmErtY8(Cm$QI>!g zDwnP8nb{X5$j03&%QBuizZouJJs(ci?^NW$L9iB)o)7!RUS{1z#<~IeiAyJIJ$>$X z4FEMQz&-bW!r`#P)eRdXycaq$v;EL47-fwFulb;it|sZ z{O%k>pt(H>J??yNzL68=$qz%6X0HgA1zr6y9UkbnU9sVga&Xv_QdJRNt5v^=Ub^Z6{KEb8+0 z#e%oY-yN-SOo_)7Jtx0Nhi&u~mwec#*CuK+oVB?gF^qvzzPmGn=hcg(_%p1;_ES}1 zz^ASOPXXsBrg^)Vl0zt`48xMupQ+chl7)TE?o^b?i)4(FfVbg;3eUKI7gaN4DW7SFzcL0;_Ymy)llfqCl~s#8*eW7MgE` z)zgY5or+;s<`$2r$h(g`uFSemHW;&-HKt} zbI+Gc*8^x;LIXx=VHrfAj=SeeS9<)-=($6=Y=v8_6d0B{c0dBST(4cv-%d}b_C#&x z^#*alz}@rp{B-IreFNh5#N2r+GzJG`i-07j@uVPiVD2%sTKWMl>1@L(DT%x~0RWoQ z6I$2~&)3WI<+-!IpAiIC=jvWE__fw9jFEOJyFv(=gxPA zCTpc+c&NleQ!yP#^2_A_`oB&Zjk#BoIoXO0N}&{@hrvZTFZ-B@XhP5FC-fY^ZUZp- z-mehD-?^U<{&FGccg|92Qzc5A)*hWFeW66uoGsfS6>_9-c>~Xe4Zs=poeCJT|Pq#BAD~2&ogdAI4O9FFt`iO>I0nE5wyySOE z(&H|MELo1}OM;zCBHymM zhJ`9&9ENu=bdhQfX7SUq%08^2-a8A?bTM6Q_qOyV99Y<8bG0kmDZW z+b+XDmO7*pBhQPqtZGcwGy8iqZeZ;0(s}nas#jf zJ}@qth-aK!gxh9b;H5OPbN@PoZr5YFGeo}a$5cbQ-d=Kkub*%H8WcLnI%`H4W+?zsy}XYx{M zlqgX)CE?t(+%pGIbmb0qq4W*NJ!r)lAZ9NUp2n+W?*Hxi?|;MBr}hL~dD=kP0@Pi4 zYKc2Ofvz|+IzPNU_p}^5FwlEE$P8v?CW|PNCL;E>5&;}Xoc`1R)IUF8y6d&;BF049 zoKNSc_C$UmWG@}tF05)APwp~$PL;rRLa~gtBx=qe>X`Z3ZOP_z#+1>N!!8gr?a!@r z8ZLCzG?}wZOO)hH#FD{c{Q{ulV4y;n*938fhL5ljpi_eG?eYWSYG4M|aVj(om|<-k zC7xd7S3ynF^gRUjut85nfni9jBla9S_W9_%SaL7RyIp!4dly5e7!aR*7{13q?Q^e- zN96n5`uK_M-=)p5qGM(;^zvEz0euog*m-&$hAm+|zWdz$q|R{~iF_AZdze@hMII1z z03i8LRQZSjL-5K-A@oq}d~!b1%;Wv>UufXR8NUCKquI>hjfi*2uP4wc(bw*v=VI-r z60m%+prXf5EHV8kj++Z-50l+Fvjc`W>_yZMr!a5U@bB(Z@!pSN7ySQ*8BFbSqNy#twR30_WQEuwJ> zRsgOBq5!`^^{|Kj^PavQ)}(<-1AXBT>{Br5cXZmDR8g58@I$0NBH~mh^486h8KIy^ zN?LpEwbu?G(@KEADisd`AnKx9TmX_CfR3c>0KDG^6**$r$(FjSyn5~)%tkS%n#e8| zSTe&f*mxXk7@1^+AVY3KDaE>|rz~0LMYGXH;v9t}Vgs6Y{>h6WUCC0TENjgy@rY5l z{cF|*zXgPK=YAncT6KZOW@ds)FlUVMse}gc^tDAg}Ol#pjOi3k+ zG6#EbOK!@-qUl)Xk#1tsHVeM3*Acsfbn~LW(vMP4jo5o=9x~&bVZ5MZnXo3ISJBB1 z@qENGuKwEKG5Gi1eje`ROzGbGzbC71Z&qdaiV!}IY!pG^yIQB z1TBvyn&)9)BOYEt6Ks>g94{EzsT0gvXY5d<#r5B8y(S-DT+J5dir14>;*})QqnpBX z%p`>6*s1Q#gWK1g4Q+Ax3j0*svUjG(UX!AMozO%b$*$a`(7K47I3z?>QO;whAGp>w z?C*|GU~zI{=ONSVZK^{`Lx}VrYwf{ytM(A=IUv+=gNpaR#*JUcIYY<=P|jYud)WBm z^LgjMxWwOm0-uQ984Ki%>>qM4kyz;@&FBK`AlbGa0&|YR3yQG?uGc;?hz3E|t2IHJ zu4^U9j${VHO7@k2YfDiN%ivaCJK0}B0JRvh*QtQ-jWX)}&i4TZ3~mVo8km9hc9j5Y zH7G8?pClsLwJk9)40l#WF$X!p;^nZoU&pD6EcE`DA#^voGP43-K`lYvdR9DW9-wZw z8=+IIrR|6|QcA@<+?Dd$=__4v>-#QvAS-QD zI5(dcU~fHPR6Hx=XWK9XMfQhCZC$ zHRftiN>A-$x9e$VzHJ1x_GQ^mY4ehQjD3cfc0OThnr7NDI=7EDvq#TO69n7VOF*YB z8+r7xlUL6aS)G-Jbo!y|DdXZNyR%Cto7?kROu{x0G31#RwD`h>h5d`iE@Gc&Fziq) z)Reh|?Omcd&R&%o>!#d^Hg~HLd2EptG}%(OX(m0(DmBE7aFceNCk#w(xkhNBz681+aQX_ zrPoYEl3Hd+x>1zcnwDDGN##WyzDkeC0Q`Q>?B2*9t8WPg8j6)>Ug&Wmbg~0TgLw#) ztUqnTX(AGPxeTAYWTK5w(LgO6bU6FIm!2K=!_W)~l2kSO(lI5GG6P*p znY75e{xQ(DFb1ZjE|StF5zp+qwHUC$l9vgHnJC2vY_gN}+utv`*V24ZS#o(NC(+`axB=}DT4 z?RM(Z9`p{`%hKmFC`!LI`y__2e@FE2gg$CQ%GIv1mygN{3~gU?>l4x4Pdreim#owh zm`#~#c@JWVW9*SyL@Z*3Wt%<;jl`k~-wElON0(KTYOgXm=piNwMSR#)xlL%A=@<_F zV7^A+>00F_1t~K>Eo~;Aq9CykCzG>Z&;_N-t-!O>S|7dsO(b2PdL$l&&zh%(*^70ygJ9_c>97CTA zdOE|a{(hQD8Lt9?Te6DXl!px<)=;%GQHz z_MH?tXuTD)?5^I(qPzC|KE!q4jysaXDtC5Hr6{KVy&9&cQJ+ zLy6ooEk%~WJjS4HVOo%pe#Il)^|mEMAm)1*j)8%0scjhu4JzRU&pS;AlbuZJ6v?3v zVTg1XfC5QRV>4K>mek?j|Ih#S?f?GA$-R05h(KX_=?=J{p~u|M-@Y~W3PPl zb8fUCFzi&g8gDW5A^x;`m6=Degxyo@mMo;*AY1W>tNamj@1-K{32U|+U1fH`)?329 zz(9(O0Sf$HbC@4^2xzw=naCH4CC$7S!AzU|)I3SA=UnaKi!=FfvwM_S)wF}$kmbbF zv=+MN4C5UX7A&Qoj}dg{Q6id6?&V=zmBgz}U}#^skqFTolk#E%WIc_WW4vY+z)u@q zf434b%0-&vxtjLi^<V1;%cT;u6`2l|}bH-5RH8D^s&}Dh^>E z$M1znO^|0jx+q?R$Ulaj*Xz80qg(b>cB_6NHW2xZN>qE;cNg=1%MkX8Fy6lX@^`1> zyo;~T_|%|J{C_~epP929N6h2@X`=bV9@=4p&z2Pi{GmXyms0i~IT+@aNRnLeO(zky@^{aVbn%>X16Pvl|u)_*?IuxZQNGv%su+Q5-DcI$^+Wpt~YT1t~4`)+Rn?V zNp`oJ1Qb{gYEgkGqo8CjS+itD-)p5gy43kNBxp8*)Rx*%73Z}s5^WH%OAvL$286f> zK0sNFGD1&mW;RKtQG8vgg)&Ot2WF)VZzC+EekVILF|D{*vlI~mkI*ykqUfl|=0yd5 zWS5AbIfe;wmB-L%!;Wgx=lk~Zl87l({{;Z-y=B7TjM-Rm(E1#rEZ%>H0SJ&FWi&%6 zB1uacrIoU0!*2fXiwO0}Z6*f`&Gdp<(_WisyT=Qze))7HPqoYGSlitH58c^!&mfl> zOgk^jAJr>MJOAfJL7O8Var7uF``W5S`?UDi?y)m(>8PC z$7`(+7AZ@=FG-q;VkfZ;v{o9aFrU-P4#e&kcmifyJ`i+pZb366bCd|(a*c%N>N?|OtIWS?5eI;bv8mQ3pX8%GrmS-4NWG$ zl6k1t9A+I#26{~H%^TqSEpos)ExpSwfBQiy`pEiY#CXn#X8`!bH-%6Cvs}Mk5_yd- zaz>hfL#*-{z=Z)1!(9z3vVcUb*3gMCB%qb;wWr)uft6AB-}`IVQX4Ye3xT-@kRo>G z5{8i1N(t6{Z(QNNr z8Twh;JlRJH(iIuHr?L=xH7rMWxW}?%u}5Yt44W-erjOwAt59=#csHK*EbZ)qp%-rn zdq{KcV#c+xbhCpA*AxCff}Rt26OUl*6u4s%X51UTE(}ld=x9VXXd4OZjFYyxRH3kk z%Y{VE9?}$LXR+1R#txXVO@V_^lH<)jFSZZpo0X119FfThwe5K{+i9=QB-Uw*9U^X8 zp(JF^Vo$dBrbFFP{-DVNlhAV0`+jU`*d*^wX@y_{T-XNNa7 zSFAYXC%LHQ_Aotyn45uZ!1wfbBik~<5yM6d)rq&;rK$I@)s|61zU87 zEe_T!PLKY%BK!!2Shwul3ch#3o^5Nsb9m({mJ~L`@1n8Ov`pJn>PfPDbCr|KYxKPD zgz*ZyoN)7H1(_dK5N3ahfB*RSnCIEM2S~X~{&|RI_EAg*iZXMF73?8uiI(cWwv|D4 zA*Cd*{w7V_FLz<13? zh4L@q`lR)%TlWsi=Cy6dlCrCIr| z;^?Ad@uC*i45RLMrM1owDrv0^8(e9rtMt~_fdQw0_PVGY*CtW6yy16QX_HIZTL4f7 z%t|ZGOD=+_P4$IDM6GPW&`NX50I_B~h0)B}z6nBy#9x~XA|sXWEw+ZfIbcw^v;-4N zTNixHq1dzqMOSEQTM%`tYQmh)_FI9$U=8*!_NkIK77iLD$2!kWFZ*pB1(0uPzMQNM z+b6Yk0qEL+!AdhAspEgA@a@~%>9i$?n&QsYJSKT|^6_^6es_#gAJj_i@iWs8kT#hE zL4yhVPF_tpz!$`#yK=~5Y<+;Ccb}~X?i`Dv!$!fZXr2M!SNnT6FR3=OTB0UCt5=Hm z&>Gn`Q^L?2$-GVY3K0Hv#ZaT$R9;E8$buev|86X?cKoJSb29A%g~`4aSo}cRdZ%^8 z4$jFVA)9UCBb2lG)lSC^`z&S(CMvIW9%^zVngP}+2i9AY4ZFo}_VBK9co8mbUiQ1H zcrB0E+?-Z1)S{qStEhK8FD5%3%!_z*Gb?_wxxB+Zz^}PiP4Ooi`aWk|`HuCWZ6;U< zG}B(EmHn>dnIoMjudo#1r55G(=*;atP3+y`g~$R-`|t)I2^{ef?JgE>ds@b~u1%dn zs8`IuRxUDCdz$32Xc;&H=aqir+ks2;6Ks9Pk9{TdOteCx8<0$GZjQEr&gIWCT5)tK zQJufdU=gM&w9+$)>4Uo4l?Xg|2Rcu@#xei^AOJ~3K~xHw>CU^_5v|6UDj0+ABKWLD z54EgGVwU(AB>*A5 zI^<#A{FWn7&g}RKj}Ej%hPlmpU&h5~y}NZAItIcR4lueUV|c;SW~p;6>OP|cJXTR6 z>Aacp5W|2d6c@5-vu#}d&{FFQ4I?^l0Rxl92j$Nqod+u&EjbLyPLjMEew#lsb|q5) zOuN}nQHTVBhwb9~5N=!|6`AdmIbx^j30^j%vO#jY<1w~JoIEm*+H-o^kVL!H^w~XK ztb>W^2$4=ZA2v0QUR63DY%u(^)okod$RiltJVl7hvn+SkYjSuIiT-KXC5=VE(9hLD zjhHgkiU$x)-c4_9oAD@-eGrVjRPmqfnIebq8ZWqCMz=AW+io|zj^?JLejTgiLsJxm z9ejj+uqz6jvd^%J$3faAqMeTX4`Z{#DS5A~cIT=o<*L73a}bD><663Q=7gpY+idTWYo;f9qJ{3?d*!-Ta-(~i05nx(hA%*B+5ND8%9>+-{*`y%KJSP( z&Wo8x{KW_GfzMCnWdKLKas(Vvb4+-Eo-=|M=)3?rygyff5P=PoA+#W70Fyv$zfHtl zD?x)V6zp0efCpu~pB;f@*Y!6kB}Js0k%z%Y&AS$RVKSIg2^VDs3FNV|X2m*?sjX+h zJ647b55Cj2Aq{T5KA@G!fPoSK^x9SfHbh=r>vQ;qA!XOnpc%{^N!fSIdWhrk3S){4 zyZ;><=7G5-x^_gq{|jMIN+C!Qs8!H|2_y{K(?PzYu70f-nR z!Rb`wvdR6d`AKA7?FYu4SrdpLfdRg-utkg3Bjf@}Cu0$lop~FZh7+}%n%DaejRF$x zI_eZF^Kbw5R#hvFL-7pEA9m4A->$)H6yDj8pr4KzGx3zd*}K`U9|nzG3a}oa=R}G& z8WiFv8%9?htposCs z9_5tmxVJ>plsX5BII+Pk?~x7G^h17aM^j=~;H;T4j3f?VxP6hY-5bTu>hBm!h~1Qd zND)nAr>S|#W}^|Sz^^GslKr$0$~%1EL+X9X2xPzb(=>&;(qQc1CW9@xx!4eq&q5 z21|Y8(#n|!W-vM_2~fkJm0D(uT6i(bni&Th=68VAQOda*t-Y9+7cXW)FHl0rx06Gb?Qqxm1(q=HV#3iL$s7(w<$wV88;fSiE zdZ(&zN-#(0Jp)=&UZ;M5i6H^ePj~v zHoIKNzkv$5iQn&%t|b4^jQOv(=7dSCDalPw{F!X9DkB$Gt8oY@Y;p4g?OY;ol?LEO7Q8Lie zljQZL>sK+F^qkD|<_*Nu0FxEvEZeP%OB7g7e-}ezzlm_OEtzT_2@Y`J3ez0)Wl3t3 zT!dryWuVOtdpL>Q!P-Vk+k6{BY^lLan$>Js#Skn`o69G9S&mphSet{@ zX0=E~saR^r2!So++_hjxJGc=UUu##`X$xBID&Wh~V%tz6<4MatgvoR-#4*0|wV5(W zPPCBs@nguzVH-9Il&S`c++9>Wh`Ju#J;jkx=F!b}3TxXmc9Ao0-d{peYkgBmOh@|7w+B-+4)BiyYcVa|`lZZF)&+)t%J4UH@yV@&+CNbvL@A z@0bm%cmJCN_oFYh2_6!(xaBQWxW~?2g8dv@WB}Z9bUb5blDYN5=%LkA+}(A^pmMrk$N z{aE^IFI!@*n1=z(P_Y+w5xtZ@kiHM0uZ-q3@XZl$S_962HGx{0x#&gVvx#ROiaW_; z=&W^3n|NOn95xnx3$tD#6hrN@XG6?^BroEkeI!E>OOl?YHULOo!6+MQri6;#&)fLp znshqevpd8*faWY2;feQ-sFfYDVhzA!=!kjtZr@^;Jy`*fMahT8idXpCzgNB&a{Wsg zW3w+zC;{k0ynfKlTRd=PjeJ+}v=u*qq4(?M5Bpy%`RRfRntt35@F~{ZZR=ignGG;C z%j3&VTTJN%H_a;ZE1JD+kaJ>-t|JC8(~-sNbC&lZcD7lk^`!rdP9W*ULi_+a7whEz zDx5r;S8>FGitQO%Z|!kdqLwb=rt$Rey0Bs8sy*cn4eK#ZLD(D-cEE_r3OnWZ6?#a^HKzHr&MNXZR_*1GD+X09Oi z=wc}%ig2=7PShUOUfR4Rrp>cpc3VnnSAAAR#&i3 zb)CL0GVu54Wk=w%F#K<5FKc))|XZj8Q z`t+Vv5Bb(xZ7_`I-_lRJAC zOk9kOHq)*_)gH1w;N2IzABM8yK{%~3ek6+@XIwUhInDFvExGu`(+rA-N50HEkk{_y zvqYx5U$+!o0PxhHSrr~mwye?cJ-7>>`{`L=6KP(%JEd5)N6D@^v6^ICQsO>*Or~rr z8;U)T>q9{NFxPf)lWBf1(hhcnVsDptY@LNy&v_Ej_@&71kUQ$~{etU~dwwyaX|t4t ztq#fou`z!B_99%4FAgHqSzv1KGCBcT?G_N=yoKa-9>FFFN3%P_)!2o0@ zJK3=^OJ@lpDf=$CGQ%*lR=$1rLJx<(Xb_0HHZQ#cv)4w;E|}NRVjPhw!z3-u|2#~R zeb#Wp)7YHpbeS2gy!Q9^cMPDuyUA`C26Z3Sj4OChJPdcVbd$1|{k4-YtTE`j?yl6z zt7fHqNgcyLdmJaZBSQdnZ9vo%bj-}Y1vaAVHBm>h>%a#3{T+jrx4!G7hopMYMiq*I z{?^Igdi73TN|7jPj|A_-y`}crU+=86R*E&yf_ZrVok&vGby8AK28?%);cwIut9Qd3 z!8O`gFIX_%Y5Oo!Cy7WwF>8X{6bokiB>TY>gtp=Yud~MQEx|D7uF}Rkf&<3DfZLY5 z;YGr?zUQN#?FhBo5T3F29vI9j#cHV;3nP>c5(p#%-^{^Yu?PUdFk^F;TnODJ^qgH{ zZJwWLeOaLa+U&fT4SUHGbjfTx5aQignhd=VIlb(Cp-*muG+8 zy7svsH8i_xa!|d+HnwoT7SrJ)$Q};*p=e;o+3X=-Y_Ttz&dQROLeS<3GrIGvTz3|9RV*QvYm&Hrf^@751p0Fps}%-eqvpPz)^aEuI=FnXtD=VAUfxk`rCEGz$8U6*CidZ4yZ23Gw zoSNnZkSe?xg(n!A97AtSA(r&irs+(X<9ZUOPfzk2cK=>bzOb>ogfVtP_`OR{V46hp zI z**iRa{O6~b=jP)h7YhTZfC_M^ff_X`)OB6VM7^FGH$GykQ|q+aQG72E=t7qY9bLF~ zh8d_^Kwi6_`(M7u`n%)t&#y-R>Ga6#+{n&3hO6OR91js{v~67jHJq!d2Dwp<7#*BL zUDc=wHOTSk09-C-Nkr$GdKN)o16}vC9+-&N&C?lpBYy!#}lh&VkO7DmW0)pX%%T*FTMO{&j$JaL(0# z!8rF9^QcE2M`QjnR98-YAHIJz>gzaa$HqD1oN+vkj;X#}Z@v6qe_;?i$O~0;uBz${ zZvhe3)%kM1UavoY=|MFSSQ}I|5gbrc>&zRze%0eJd>w}2zYW7b$I*Ouxc>Z0cmCqu z4D-mN)?Ww1?u$ITzns=z$8oIQDmX)R?ZDcN&JoF;Y64M3=d(QHawd{>{YJPrjLtZ& z9BOig>zYv2Fzm{ndIqSKe8G^c&)^(Bqw>QjzN+FQ=9B;E z892>x1^qXwgC#muz>G@ZBt%t(<(cOh=^Jw)cus@OCUK4|?TiZ9C{ImX%ai|`odMCH z3JZKXVV?a6t8k|CvN`~&6RJ~~g4Kzq-%iUqoKA5;!sN#{&Se-RDpXazfZ}w#i3MQo z6sBX36+IQpQ31_QKb@POe){QDRi~;tRX@Gqt$Gsx=J^fP9Iv1%9b%5V)qln*okTvW zd7djw^E}VR#XHaQJp1*Y<~1CdtzXT(O*>J{NcbhqbLZw0@%#h`I zp2Lm}lWAvEr)r*O%qKqvf1qgsnlNq6a_gDH|19PzUUw&){M9;#vzpW1Um}eYPC}sa zXFg{W9qu04-7U=asj8~e>MHj8-p<>*)N0|$~OJfoVeox|>#rz#c>UJ5SR`_}FB)86HqFBrc8-}a=^1#dk9XIwr%KR-S` zK0XxCL1qGr%qa}}S$X<_h-7U~x6p)IGeB16w9Ndk@4u6}cO(hWe+;}7$x%iEMR(ERY+F!4?!1i7{ugDGU&8e3ZTVrS2xL zo^tIV;WgY~_5KI+wd>{0+}`iQpx!gHWCGD}e@_~R)Z`FoyQ^%`>HDCxVx!Q4NU~O2 z0(w<{n#+L9Bgs%Mu{cnYuv!+C7sKtitx}SsC%gKb1`m^$`>xQ%kiqQ(oBaqFjd{Wm*3&Xup#?aivKyI;O$0z`u(2o{grM?`kgwj>}$Vi0Yn6Pi{-e)i~H z9A1g|F(OK9{n{qo@fx=F5I_&E% zb~+EHowOPA()B&u4Z|5u_PJ$B>Ja;|U6nY#J?49(*%Q_**}r3Bq(^m%yZ4O5^shQ( ziO|aA*ilqOv7XJFUF|$Gnj-Jmh!r_5Andm5_&S+7t@-U~0&s%(4|_H57Pvsztj_U) z`Np?!V;8G=DJSw1_{22Ze|(%iKR-9`fZ^&yJJ&lBjun?k6nMVPVe9cYuGsd|~HC^{13)5CINVjmndYH7W=57sDhH z-Lbh`&KG%BT07^)ko|@^vjd!Su6EAVwQ~-2 zCa!j5ZpiYeRSUeSEK6aLg)JOekgu6lC@ z0ID;{hoo+d{C4;(2M5#+sF@w=_*pf>Mst!evHTejN4g0)FUAd|z zg7oY*`Am>c;5cINn$*6QdEJn&sp$-HTC~0R`9fNh6@Y3p~1ts<_D_8>2wkm zDpaS_ih-UI?K&Tvu&98lYAQczJ0QK8ioaBttA!%NDRRu7A)7sKJI`~L8mS^1jXX7w zxW8q^H?!;~K&0ss`FW&FOJet@?B_WBa|tx(gKP^4jH0(j#(-oT=~w4JpL4k<#L;0 zo=>N@c|N_((~OuknA5$+mNQySX@EBEV{fu|%CmnlBNs0tTkeVtM9=enF^}cR=^bX< zmW+S)>uQc{bjr>kr7NmaRh?2|!3GLGCAIv^8?oGnecsP+pHo$d1~^5=I%Xci30C2u zvI6>kRg3JI1!fPRH-LEDc6GITl*YF`%g>UW{%rmyi0Y$0%~kbTSEzx`H_V_toC}}^ zc?epA>Kb(b8N2keTLARo@d$9VAs3ygd1Q7xj{H@ti@coA6_4M)j?THiYUgUyH92;! zu0b_{TGZznHOQd`U|O7I_j7%z)t^C{>IYrdgrCpXFS0(@Y8>64V}1Q{IseRm-pBv; zPaX}NLyZfazupJbxcu@<^ysKjUr^UA!2!-Vc*#Iy2^}huKjSYmj$>Wd?7oj`bdJAV zE_F@pjQKtW!Acfaco5{G9>KwR$P8E4wX3Td71-bn>>R4P?th{`^*E~Ues-y@OwFSn z;pp-O#yN)?M6$imFJFKJ?YzVT^_xRg^PfCw4XSIZ;0%wBH4{f3iR{Y{q=^opo{>VbAEGF6)O7q%eDUn_4$pia0K_}Dj#eGP|A*- zVWk!8adaaa9yL2NE@4=v@Cg!*x~`lvK}S>jGi|A^T)@pPU||2|df9}a;6_*1u5D|oyRfAb&gSo^tANuT*X#hQgPx?WgS?}5aK@Pm zRb5MfzkeT>7=RgX9L8AJN%~y7x<*~M09sf3KcmJ46feG->bk9+fpcFj=L=O|zm4wW zzr%i1^V?tZ$LIXv=8t;*!2E%a3U9#M8;bk0^-q%cbG1#y#T0$Id(RQJoaT8h(Mf?7 zE1<$@E-0#bVHoEr7ccln<0+(Bn+&`*rDkM{W!LFy0TfTl5^wr^_3|7K&sm=)T&Xzl z8ivk=9CMZooqbyP0L07*xdoWKppQHWykO|9ldwlEB`;NpU7)uiv?}2A_Ergj>NHyb zC-4M22W5(VaMmJ=e?*+bI8jkga+8BIk=DD)D>r3SoNb}pNI$@qL`|7}SbpQ5wo})-&cUzv4rsjm^ zl(ZNH5}cPQ2!L$4n7lS2S8dxu;5N@yRh2ifynD0QX) zF4LV5xr_x>LeGnaBOiAZIl#_##ytC7RH3qYh?PZU5C~jJvnP|v2XCiBUuN@LT@l0u z2f6HscCw{XDLpkrSfzPYBY488s;U#<;|Cjpt0MVP0{vzi70+3iy^DI!IA}Ncq6G)= zdB*1_eYnrhPX`3PIr`H!<^{xi3 z?;TwMg1Rrh5JbSWl^uM45kELzTB)^?BxTQ-(ll$l|=P z{bG~bKQKUsIW_C^HpoO>f4dU3p@X8g_`7yQ#NJjSEk$HBy+j~*q-iiSk$1RmC8UCi z2E*i=Q5$U-AlVUjp$3rAQVSD|kC%Sn!R~|=6oKTeSGQgdgSvyEeBZ#;)TG`oF_YaK z2tQW&$VNQsA^tqcnqIQh?=MAlHd7Nkb?Qsi{K;=&D!mid226QAdSBfko}`DHm5Sk@ zTj6xvrp0$im=*_;SBgbrDOI!<7LzUd^2B9q)>UMw%CvBnn6fOiwL5Z-R4I0BMVPze zS$i;__8@UyKCO>BJ#VTU#Y#W0d2f!MAB!svGwjX&KCmkY(j+slCe2sMoi~rwJQJQ9 zrSB@Ed`p)`G$O&KDU=0=xhh(ih(9}Ci%6YiS z?ipewsaW>z(LG}^flIH5SaIE9esigY7J7N{<@B<$NUSDny~Eb?WecjcXxqIOdgbmF zd(xoHUQX<}**8gHGG){8V5{%=qo5dr-?r1S3T@v|{BgD=>7mnqUk1(o^&cPj_`s+0 zs*Q+Rbm&z=?H-Wbn9~)e3S}d2LMf6y5=^fS8rw1lrw?w+KPjzl=n0yrK;>P3<>8)V zCIa1h$)Mkd`~9vBxCLp=QcA?8hC#3FUDRX`4RzNr9G%Gsz%bka(-C<1UA^D2_kQKLb0bE(E zp+h%B5cPd8Z&v`s(aJiZNW;ubB&h?a^(H42`opx|T20CudgyYe^T5EGc0&AiG5dD3?QRww#Y3 zn99H{^p44Fr2)ujR){V&h|lH7ZMs5Cro5-z$0Y~lJ3F5MZUM<&Ozr(RS_+!|3=;>r zI-xDxN-I#0EU=)6e?=ImA0fvz2Dmz@Tugu*DQT_pL~6@I+j%CII2d z7Je<>R<;4A#>4CdB`=j>LD`v1j-!%u3NpwIW)^E$U9=#}8b8}D)H^^cJ_;;fxpEb0 zB8r`Mww|4QKa_`&RnoQNA?;TVbrOr`1M&ubTSrLYdEn$49R_N5e2uquc}QL?yIz;e zfv3XDw+XHzEAzf7?<1G=!lLXOzc&XHgooVumEPD=2|cZEQLFH|Nn&7YV1jZ-0ck#>IgjiaA`=e7G1o5K+y{btkW1 zzI-`Ls@bt~Kuw?vy8agsjasF%>00?Ozx?ubH2?L#{?~sh?d?J;f=`4xB#sRJd9LzY5JfgmIbh+O8pTArg7)P)JYPcv>=RaAE z>hk4h`laO{=ypy!CP#FRaLs`oJI4k!0gfCPRAY3tByzQSA=`2*ioMl&BEOe&;e#43@nb z{z!mB-qYLv#x1IkwynJw%sI3b0Jy3SvJ?M;?p)OsoFnSIrG{6?gxRef;JmDY-3Yj< zc0g6vH5gH=?=O&_0WgoF(?L?797F1KP8^2kmC$}X&Q-Mm&VG%&j46h)-roa1)z$yf zN#~%)u|CtK2D6iAiHh8tlRd$4FaPD2{y%B;mCd+lWj+B2{G-NOg^y3nfcwP!iTSgd zKda`m`g9I8K7r3Se7?QC0dG+#k*ORSh!f_;(IU$kS6=M#fGY@I9P9LUgC*%6G_mt( zqv%L#zG`0Qn#Hm7BKzeOUQ?Ps#1omTQgVA_%`q2Z=ozIRI_WSoIYlPEJ>_ZH^mBD8 zAA8lFCM8%01kJ3MJIqO`(!?{#=dBTyKildgPE}RSNh6A+Cfq&KSj|+OfJ)$0oxC`; zIsxMH3C*iq&f#a^beb1AjTif#l2gZNNkT{M{R!gKR6El$ z?=ATQfoNf60nE|0p%FM$r_=0f3A|qWggGcUgMKv5k=NhM7IPIABNIJ`P2LoKFhZcJ z_6A#QfH~ypv$cr!7x@JvsuNC?pYbRQ@QcY|r=1G(k{#VRP8CF%`VZo+(@!TML^Vf| z3TC9X+BMIGWFF1wCx|BBP%~zK;8cK6rTv>+eP)mB=6ODOnZ(HkNpp5PnRc(2 zjmBV3o+L|ELv$1=wLUX2SJfM41nZPI4VY)l)>^+BQz=&Vmt!vTi1(W6G_UVUHdB(k z@U-$=>Qp9biqDr^1c}m0BPFIy}+BpN_NfBoAXG*n)j9;LcS89#< z6Q6oRByYJf-*iG|`D!|1jJMVZRQ@F>FPJh0k8%dEg+wsm<<(eP#56cV_SfI89Wkrn zUCNeLjlI2H0viJQ?smQQzu$-7-``iXA(#{x)OS)dE6GNQpy(sw^mh5*P8KF!a} z9TD|VN)1{mrNcm|mzgg#CuSLj4Fer@1g(@JDXHyzYih5zpcdr28{QRzp^R@`s1o-~ zL?8~P#dOr6$D|Dfez@%u@ywf)$TIXG&oF$T_W*pG6Td|nru8jOIO=J-py0@qA;{YK z5c?k9-lZfq>q%SIi(LrJFh-X{%vDd`>xP%ZM){3lw3IxrgRBYOb(>^5ZQm!6h`>Zf z`6NQ5*RR+9>YbyP3)5TOXyC7p2YRc(o*R6A;&Xoc$LSMqMdortU^c4`Y0p{Lr8jqA zP#XJ6!+>dzI6vYVa`HIirIt?;&9U7n%HNxXIDTx{AwNB@uJ zDWCj=X9Av(ZgDm}(;oc?9>{{4rH`b|TY`wR1)AdUPa1fx&4s5|uAxW{uN%)y5p?I9 zAT$v#nw72us^0g)Mwo!;p&Kk>0*PRI)KlzzMOJmoD96?c#v?@~& zTv<%Qk9A|zU@aD(iq!19aQ|5}1XJFC+5)L*<3@&n>4*pwkK{uK*`OUhxUtp>vE2dI z9`&Uv3^ME{Sz+x<*ML39+hm=$C!bKWq7fV88h@Vz=gXIh@M2tOLBJ(}9;Rbj?q zpfKY@0bPp@(B?o*ks$$zXJU&8F^GaN*A$34hta7Ax5vZrdEK@YJ=8#GSrbSth#@4V znHjQ|w`&L1cg2PXY$UaiK@Qvw?*@PZ2z`Ge+5PYDzYq6;Gw9!@XFqi<0L8{I_3|n^ z#RDt$Qf3oTR@Y0`QU6QCd{>Hz=yv-}4R-+7UvI1i9#}&$`qbUfWUaA{Qmpyc+YPwA zzrTYEAg7@C&P1}8xBj>5Fx=mj2AEn}l)7H_O4Me`T8!lmiNf=h|cUBqzUAyaVzY&pA3K|4;ABI5<0WKSc(eE0v@4a%Dl_DvbVOVgHmXcW>4~z~Rnn@ybPB&4CqCuUcPIAa0&?49%wD(OcoTj;f)?k8)FD<6g!~{c6B}m;3)lIqQ$2!^-nkKH)w>&zP}9f zJ&PLE`Z8-})_cX<1qB_}0N%uR04KXq9Xu~XCd+A5U z#5|Ps3@Iw5aS0tTv>nQiTP~akf5i9hz=!)`& zl0u+q0?ciu#Xxf^*H$!9LeNZ@P&nF6(-e*PrVKo%Q?N}YL|AQwVk2c;`5N0yFNI&? zSf#&`T1+W`v9My>$|~F{rih_Mj*0hdKlhXyEA(8nlb;T><@SZ`SCpXGxK;M<2R;N6 zm|i1O9!fNx+~6~V*6Qzn(B~(dTOi#L>s$f|up(bJcjW5aCOk(=lWUmBAGSG=Hm%7Y z#%)Kj5jG)nyQL0b$xw!=kUkS6z)EXY0ClmQG*Rn&HG5$vN!+?C1ONK3|3x!ztoK6K zWa@}84Eo-6S4jyyqd?EH1E5&}ZICYyUA}oLbGi6Y4dYSd1@dRQYYc@ zsz#AI0vk45tw=Yof&QF%9pkib4z4G zqwcW%%mVW0;RdI?4`K{SibA~5-meXT3>Ir=A27DQ7x;oJ(-BA#rOuSR@Z90bO9L}R z9f6pYF=iQ6G@DLkyP=NYA>q!3+cu8SUr4Nc0PN}O&wrc@KH6v)EhQ1iKm*(wwB40x zV9mGw1_G41U2pIA`yKDdvKj%E_XJ`nCc6IT+i&mse*fKjd*kEd?H{Mlm2vUk>HB66 z@L)2B7I{;|m%jE$z5Uk9vBYYtg55QT-X2;!6GLyGQO%F4`+odOy!whHH_iQTMMk-9 zeQrhb;Df}31XCUntm~66sp$3br%euFwXDyJ3)dr=>|x$u$r{)lVtCrdhW4Oq`l3Pi zb#@^loNQ{|y`kd|D8fUAd>cKkyMRtdrqAJjyN%CnhTv>d)~MMvJ8pMTTZ!w0@6>J& z8TC!T*~DCpJ&I6cJH{-FVy)e{UFQ_+L;s_Q4=6*7n&ycH7?G(54q|@OCeE@jq}oFS+=vTY&f>26~rx z{@7%PpJ0pDKbE1qL+v5`oQyF-4!R9IT@Yr(H?Ypo4cgWtWhy^702EN`v)=I&qw@g4 zgcLUG(5+b#fd?J3+5~Flpw;_bbM6)rj2Xhfu3gt+7=}BMyk2{TX2q<1U++}(X0E^e z_WrJYxg0o%4SWsbJAMxcN#8>U5jGybvVrj|G&ASo0Hs;|m)p%_XfUhL{vwi;26$%$ zb?@a>$~MX?0P4D4dWA+bb)Z;i$WXo*lCd>epoG3Cp=Tnn23l5HsrNwx)KN<R7-_@YBlD)j$euZY)O9Irp(qKR;1G%)(NmY}qz><3Eq-F&+`u?t|?c~+3T?=^c z4Gv|9srfabMF>JVT6u0@<;byMXtb1G6ZiHuXj)q9tmPTY7B0YU_7P?)PD-{JoOeWF zPNXukT5vftQ;;rEQPD`9uN~Azhi%W98Y%B?UU0uCDimAd$kiJI_@+W8MYhY8B~EV> z$AKgC`e^|J(#(D5B|K6R4a0Ejf9pWZdYyObNJ=ok17v&q&%gb4hrZv3<*xC$#z1*r z?V{DQeep)PPmsL^ou`-i3j2)2cp<%CG_)4a8YtVHX0zLz{=>mq@gp__*|D2v&q3e9 z*}{rY5a=o3sO|_DIy+j?%EPXS)!2Zy*?CF_f_Xi+MH64UDtXL0!;5%k4X~-6I-vGf z8XEgx4>bEZZjqh$nn7INY3;%K_!_(5Q;{?Q_8~UJGuH{R@UJPpm{vi=v}xYFq6Wn| ztaz-Uvo>cxrwmE^K+p;=>sc(`rr67^S!3(N>qcau%aqa2<$g^m@TK&cILH>*o&HhH4>8c6pPmtl&>2AY8hS<{7Y1|Sp|=_12ycz@ z3HiVuBX<8=A@Tx=tRL{nNsGgO+9)=qJe$e`8c-;<+w8q` z?PW)L(03y0Z#_dRbvN4MVUy5HFMEI#zk5u@fL7=`38k6&erE!tB;OWp2woIg$}Zqq zFqfkTNU_5E@BQ`G%N}{}srAW1E03;?y%25SWv zw5{(-hy{?YmXaw18=ms!;XWwl{?=b_S1`~s2F1fL48yJOnfYDcHM3-5t)P^;o53)% z0vjf1W|CJPhOY0i_)IV>-1(hIw(@G!9c)+)VAEZ1APFAg471-RK?x(F=Uf?{+*6jVm(cUdR}mR=9Hhws%4dO3#)Wf+Z#i)8i-?A(JibpYWI`Oy zK9dNN0j&p4g6zV9B$C-Jt%jRAY^LxuD$+T{sBIPy_>1K%#Q!<{KmHwE(2ekwx;r$$ zT7!U&dS>q0zVGQ@hd-1q!U<|gN-zT&*Y5V)Z?`)SzyJQ8&lSCSWF^)`{HwdAeKp5f z-W4-O%AyfRci`z6Mz+sBFjqn&A(2EvPmhrHNAZ$V_l%`257jM*z_1 z!qZd|z($#8(0Qxl@EH0Yi|n#LnKm$91&y~lR8U&Lqdi1I@1TS+rwU6SH;U3rkoWx} zkZe1mK`RD2A}M=--jxbcSkCE7k1FWbo9rdjyCP73yAg0#%4lXb1@Xs_H~D@anA4xA zB}m!zx_!R~Nvp?r9P|RD2X*bce8`e|is6J->JC<{_|8)H{k7-2ibrR(L=;uCfY!|I z-Iz!;lVX+xmazh^D6;d(`=tPkwmqv!5_NzEv$xOoMPp0=4~iLd^LF1M3Bb&(m|4FM z=C0M1NU1?{)bcX!tf0^l&~^ZMLfv;i*UA`ZP}j+;R(CKdeP=LH4|Lu{jSVEVt(0J; zyhLL^gj-|ixEFZQH&gju;#`Qq1#({M?BF5-mv>AsD80;Wktl7`>Xj>+F@-eM^ud*{NYF$_Zt zK%!-4kRd7Q&e6p>jQ_V^<-55LO6Qx1x`3XE>2|wOPrvK;`|t00U`qg6A@Es>@is+P zV&j|pqZ)*jgf`DGA9J>1jiFy!O`}k*vgx)-6n&)G)e=Gg@ zXo3^19sK&NubgUZa6xM_?yeELq}P6oAhMa6Y_!z2nYnhRBPg0JHw&A(cyec{*$fG))i?xvC_f^u^N5 z+V$y+5+>SlEyoDZGFDTRE_h9>_q0XmH|=x3;a0E~Z!9rY^T2~WpOh)vcuje&ELW2d zA|xo9EwbOuDI}@bjz~W%XtW!x&93EqQ#7x(YhlQqcH(c`ne1UYY`s;)L&$tomKkj9 zzU`0f<0D8lB6My+m86PlQ0)`T&gnheT(A4R5!%qEE#aEFuGztPr!Jt5-Hz8^&bhjx zwob>Y0S>*=LN7O$A(imCZZR8k5scT4{&IMOH+OT69jKx&*E6}d+PV5t*L5|T5$bzQ zZGHJNGKTT%(qyhahlX?jYIG$3<1d$9g750Pq!FQ}9nzH2Yda9}9kypD0XwnY8# zK8)-PoNqY~>_*4(@(Y|Bzbl6~0@Xj&b$fQBzSIDC9E}4QY8T(R$G^T_a0VQM*|-t<&AqW>=bStfgSiH32|hdb|FiZsJ+36#mEega>1H>Dm(y+< zl+aELS^#q~i?>uRdw%$AXDKau@fIVXxX=J}VAN_ebw`b^nH5=Y7WQp!PV%KXkf@3m z!65y^-2L2h&ppT7@1s^p2DqnFgl>81FmSrZ`0lg>7>sBt7uNZm`5ux5!&i1tWM4cLyeNkWN->m!7pUv@plE5!Y{WJdS9jD9XKixkV`X0Rb`14PH zOJB?{_{ZD-^Z6&v;g9r%6oEfMr}^@?|NH%P|1a17qW|%qa6iRZ``qdI=>WKBpw#Ke zy0EijaffrS!@AR3gap1eeCiP0iu}{ocZvUfbm75`i&*`x%_qbyIONQ`%_axOyhryZ zXy3ff_r^01H5?8H1aGQCsKWz~!|~$? z91a382L5q496t^?;*fI#55Pe*?|E$Uu&YN}h$lQ8ACF`4tb06qL%BzD1`bCY9*2(* zh{N0!{g!o9|R-F#V zgE$`WcytM&`KDL7F4i}>u}9=#b5ljTRht{q_63h44qYm#+kc;9{@CM~a_)5+kg8_# zB1hCpMfVBl9Mn)q&MZ~kXRBpl?bw>4!K`1&Y08kg&BG@40t_genRK#O2vKd8G|e=F zpcxd{TaqAUv}U%ct6jIkEr40kWl@A+6ldgoAwcUj89vz7I**t6VpgNs*s5Poz-q3y z8!MvdKgP61&jgmimd-$_nO9!H%Q6GRW(^S{@eEMdVq9<6%Xv|BHhhCky>grE#3U?W zSp%e?G_i#S6kwpaHX)O(;+NvtigF0e3^2{4*IQtegIr_=&9l;c(;;*a1{x-)o0G){ zNt)FHy~cnI4%TSuqJF*V8;oY7ty-c0g9y+!wv{IaYrYX!QDSN>->@oD3maf_2ODI^%uvX!v$GKnrRx?~1% zn3c4dM3!+86EjR$5_L(yHD^wcmaFbd=oMtm26xBEG9_b`;BsSulnDur2`VH6ewn`f zbae83ha@GA^d z5D_9n8GSCqQ}X-YIZEiNK*(3(kzEal1K{0McppEtl5Z#WK6ffUgl!Kv>Ylw2fQ!e> z4cg-klkaOzxuN-EQejHniJWysNQn*k=g@6=7G}7bOe}(-fjGtO%%(aB5yZr45_RgF zENVfHYtM6M3$nwodDjP@RQn=?-_8k6Z6e1umNHYXB`Gkm>3i*#tm27$vGZx4MVYW` z)wcpjauXMw=8~7(G__aW1OXAHTCS2eH)d@EGe^<6(fJ|~8cZrySGp*>--X-Ylu5k6=#!!cK)bB&$~(7t)7`A z*jh*nNHA~2&eW=OsTX@xNQR)8fNGfOri~_qAa0YwtAUk^F`PlsU^9UEJYN2d6oogm;tst2f25gkRy-{%8Mj>DA>C9ZxFn!IU^yqv9CB4kD5P@Y`*Sw1!=7HRZ_RIBAOIH?i2lW0v7U@_Z{0?F0A4_$zxOoJ z;h&*Fwf}Jh+m8OkB>3sqt_dDd%>Fvv@^xroN+twIj>P zPRjjx+pMd8f14Bk%IJC8)OhW9pmW%U2lm>H(I{&cCHwm75-+a6!9_5YfOD6y?}RD* zCi-YQfypJH=%QPTZzUb&*!o@)meFC1ORr+HD?`a?C~Od~D(7bkt>A-Qq33FCO;eRo z-d-)wPGwh(Ppzp&JNzfg1(vN8o!D%r6Ro?Wd;bR3UKWjW%vP8;yi4t0_c?*}so7s= zmOr>Fw-)}>(9^WPa*rG6+~Htdrp|OCmKBEVDKllM*;s0BUA{mYFOh z!vb<90>d&xNt5y?_{K1(fuRfozWU}$>_wFM}e zrsVY#f$9vi>Nou7xLG?Gug$zPxT@H=_|^@tjf7>1xXP^wlK-4kFN+O^Of<2renMaq z?CuaVx>3cI*V`)-9B#?wVBk%F;iAw^$h@pQo6&moH$?EWi*7AYG|Rku4#Wh4*1V9K zQzknBHY`;F02K}`)S^H<-`Hq|QZq^DIP*Y*+sxww#RNLv3#So0bN%xp-wXu?Ghol| z(f)@X3ZipG6(wTDx#3M;3^Nhl;#EWsURuOfW9R`Kp2qtudbVr~rKdei`~$R21v!eH zL@?zQU7=7v{>5OUC*dkwln=Uqb4lsx2g7_~N&(QDJ?lJAqLg~LBBs!!C@{M6@JKxF zW~Q*iUONHweUysG;Bykr`AH<0utD#g8h@&Y)Xe+){XWPL+WW3t?I+;|EfY5=%ZA?7 zn?P@Y9rbMHMx#BQ_jPevWt?QA57e}Bl+~6!DKnO-G7yzJHQE;?YBpD1o$JdqIGa-m zf8W2SY?ZzqV(O2=)CIoRZI|JkYF&!>LitbLxe3CFO^}TkD5?DpK!24eUb{r@VBfHp zn+}tEbz2s%igW+!4kVshjMS~6QBm37E8>ff$<7(TJi^US!12?s-Q2hAdNo4Na*Ly> zm_cvfYM)OmQG>y?fNB$8B2ZHhL>mU$V%f~M2T(Cb^qkmNMs!7B9k|aK5|ruAh;U{o zW3(->YX*2;6zkije=fr~8gT(<->&QBvMjS&`4*HOoIDZ~%?xO5Y_2#g$Ip^+<1I%; zNdT8KozLeB^NI>DlA>i+q@oYtjdd+Su>fnH6{(qESl`w(j2JODg1_}@7`S}Bs9A+T z6AE*Kz#M1nC_6jUU)oxdk|-iM%`12bOeX^rDh<6VqD7sdZ5&%P8ndGL%;pyT`@+dC zqn^9yo0pXa&)KR9{+=YZZo=?fkKRB#?wKhQPmn$wNK)&NXEhnq{94Qz8)qBAwGkZ zxrV(2db`@RS&_+yP0?kh)!@c#H54tE%UPRSZxJ}R73<>zKYbTJJ#F8K*O*thH>|vp z<;8nhRnx%LX!n7zjSLW*p8gY=$L2;Z%CpW@{K*JIV~6c~6YajDn5Va?^`2gyoO2=s zQHaD26{;8zPSmx~W_!eD-cXchcxj~zFLoS{z1tk}7?zQ&UfwWO$$&(Nlzr3sjYY^J zMu*lli`b3Mm4i!5EoK1vFn(F)E=4`jTIqQ*hIS1Jx*^*Ai{`lRqzd(FbX`#1ROvMa z9BBJ#Rpw+Z%xFagQzLcoJ?AZaO}$rSd0dT&5ckmpCUc8E4_u0Zu$&u+A6gpt`v^@(B z>X7(r_ao=MnBHcvW7^GxF6Ai^#@7xLZn?>bKf<*o~bl!u}(O(&CU#l=` z?MD4ZWArRhc>`ExY#>+flhE>s70(wV)VjE84q{Bmjk`w^I#EL_Vo0@I7D8ZOQz~{e zL}1Nqi55r@g8j2iyd*)A);jXxw9G0fp5?j~7ElA&ECFDx8CYjY^P&)Y@n8gx3uvv= zkxXKTAfhk{4-)2Nge-~9lmbf-gwOM`s1Pt7_a<=06rCCZik%fH02#ke5QHEOm@9(K=D?=pWcQkxgjQ|HiU{4=}C6Wu9pyHUlCAK z>-7qw$m=K7kF+3}ptj9E)z*ToX(bu-^a8bQka#89?%Ev|jo>&OmOfpk;@-gkX|^hK zGQ`JUyDuTEkXR=7XbzRnT>0q`un-xeZ#QFs<-9D5x|-Ydwz7@45SjsyQZqoe+ggM! z7QnyZr#H}y+eLye@960v_=EiO6DskQ3gSoa)-4a@TlD+{LqEsn0||H1XT0W^V~c!x z^_rT%>}~hLGqJ+Z1uCS_8PULsodcEH`6wwO@$F;i_x6ZSoiASXv$wprD?lg`*cCsr z20F+icDvZl)kuAmS(0OhHgDtlxNE;@H~juDKX5dkhAQW%+!k(fRjYlf{Xy|_Crp5!q8m)E zp4w>c7IYT$jN$d#;^wXYWOwMd?J2)?aPzg>dfNP*RM%&js%}UwLv(>cyXF-xn~L}y zpYlmm&Ar^<*~7@$-rHBAeDR71_@7`nbj0`XPyo~`xV-IpD@g$<$~Q=A+K4w=S7i*) zGa{GEd%x~Bh^qj%mZ#>9W~9XRR>DhL0fhjIIJvOJ4?GhQvoXveMJ4*q(E?^0@>o{Z zu!MP8q|{*Cpp}}9<)Drx!lD+E1ZfCJ>3B6_2@Gns9fpMkv(~H&d!P1F&TQ6nRBWY! zt^Y;A@o!dV1B-&SL)G>-7Wb4<53hBe{W z^NjVTwJ}C(MCI)anlWn=LRvH>WRw#{tk$?JL^B%>WVzAW&hwd+fz@n?jRIy009K}b zQzT<@B+X}LU6|fR01U%7Nkp@v<;;d{6s2tEO*bo+vmQ=t3M+7;Dc(`Bx^a?!#7S$%x;1Zx36KArWqDBW`sZi+Ws?5pq6*ih6-QjFkkA`XS^!}kh3IKM+5`rgR7 zBYk~m>?;PF|053+@dn_p5xN&uEJqP?q(@@~*+r3Z)E^>{BDOaNd`d_l1I>IWCf|a& z3LQ^wBcY#K8?YAuGNHpM(%pHC&^_bo2Ayx`rU4#(uV+xV;iqEZ*R(hM57cS#&!^Tt zyZftt>UG+ODuMiU10lP2KIm^da9q&y)@U+c?IPFBDV3zW#_t=M)ih!qP$%8=#KcJjPYoL{3q<)ig;}7y>hO+%-H(OV3OucA+AQsx1 z={blusRZ}b>|BT>Y;UO%KWYR{<$lqLu%_0u&iUP|>4yiaT>{Wx@GR*E)EYH-2!Ygg zgFob`olUQqYFYhB&|es`JJOE28_%16)fw0zgdpUC7*t0NQq0P>>2oVCvH)^kjn>*y zY-|U_Wnge5A}jkZ)}u?GhgX3K1oIWhp;v{{r5V~h#O18fY-P9DJk zvsEEgku^zX+dyI)iC(sRlQYq*XgV3oF;M@@hWZ;A6%7*>IfMY3Jxat2o&K!elCw{Z?J#D3c5dXs72skz1^oNx*= zpg^nu9lJk4OwNQ^Dk8<}H?Zb2sYR(PZfjZ~Y6j7a6d<#li6qw5l;fGV<1hIB{o~{C zz3&A#kMK0z6`|oK+~ft&^&!t~GeJ1LfuV;_;w}cId9L;k#!0*!UBpIMy?0+19UC}S zSyVW?vB%g0;Ju3a*?aFjH0yadA90#+u8z$RA_e=2K@4=|!@PAhm>}{Dl@nr`9E8LF z2+U^GKJUAQ`>g>=rG(z_&IyxDHJj=IAzbh)c9A_6;*E!~h~P`SXr?@a<1vO%AnAp7 zW@np~Q7OIq^2$w5tz&ZjO$|rI=CW~H!BVUD80aQ4dY+<)+l?%vTQKLl>)RJeLM+3k zJy7kU(q^0;Jz<+0Gy%Rw&vgJ~*tV%QA$eL=R|mMY?G`)tALkk;?;QE(YVk%}9)@$Y zQBI^CPm21+8ODva*FC%CJYTs_x-az)ClvHtaq4cg-rMT&2~2muPWaRB@g%A}G(liv z0ZHneKW&Ysf{K7;j87}cd$zWr8=?{7J(!Y*135H-<#X{yt@*5mxu{?jMxL{K!l=i= zJYua0S!GNG7}+?4$2N4Ql_E)t*6ZzN&Swg{q$r2TMQ@2fPb!it1F$;y4-l=Z=GxsX zXg&x;(hLB+wRs{lIA(BE({f4hu<;;7inT})h(g@qN<>o4k$E@yXr*znI`P`(BLH)| zX=4~tkwTR1#NW;|=fO?_ZtKU`eXxLJ*wr$Wf;NB-z8|aBvkIc; zTM(FY3JPQZG>44{M_aQYnnON1$q3!;=7d|r*4*Yr$ytFlzX;LX|0=VDJc8Wq#ZXQr zSHGuHrQ`(f(juV^Uawbu2+VFVG_@`teWZPoLxk(ja(e~Eu0W_pC=D_OXm7)CCZ~%s zU7+8;0}zBXx*P8Z5^O^~N;A<6UKtt+w5TZJ5Bd%@(@e8ro^wI$gv5r2o;on#@S+vy23>K7QNpx;2E+aMq0&A? z`--6DP`4y>H{Il)7&f&~$qmOVf3*9#F$8g4`dT&)3FMofLi)tyoDfmmo+8kuDd!~* zPmPG^d9z)=c>E9He4PIhQ{{9J51<k%1b6dmrL3|NPw!^EVp!!jvSfgh#Iky#q^?&6W>V6X2#aDCNeRd@pNsgNu zV?{S~!wmAS+-EC8t1hLz)U~bil}*PUtKDs@7~|o0mi*?z5>=&I>91e+geoo2>(`6- z(DSohI%bF33PbY~9*%q6M0i%8nE>3tT|jXnt7yxW?T~!ga=13|8WC;XfM3EjI{8UN zwF5^W$BdE5LIZfB-c<#&+m!tlbi@R#niqw$3IG`MJd;u;IzL}Pn%KllKW5f93#*h& z;DaQrWmtU$%>;rr7Tk*tYIQ(+4rB$aOt7%iA^V$jejkPoS`zT!h!cV4B7AM7E^Ha0 zg`coz$}rS7Hb(1NE#Xiube@UUBIk%|S2nj*Ya%t%Y_*YUCbl}@R3ca#j6qbYMvC79 zz_;6cK8Hhv=rF+&WVDt<3eaq89C}t~%^JEDWYZD`Itj#*^$&q0i*iVW0D{n@VNw-BUnlT%FzJtJ$$e0WO+Hb>|H2J-T$}I!agczi<%3H6dX;(EsVPN8l-v zsGxiJEDsS9+#+}D;X|gK5K(U`GSQYN_v)G_7~}bDE)9Hv_zYcs-{~`|I>-G;X&|Z| zah)kWP0=Dk=XYl89pdwnjUu4<7*dzG2wT0U~0dCsGf8h=>$ek=JC7RSt^?`LymPS(tSMEdQ z_TlPXdmE#C;zr=6v_dD|uB}%QN3GP$T<)tJ~ z_n+_g&kbC-10j|yyl)7!t3KtP&GaM@oj}aG4mi96C&(O5cBEte@jYb11rTrtLxV%i z-{&1B3+xO{gY_9;}^#1mp>@nVR47Oo6kGrNb-CDUjk!D$8`Lu90A<%k{Q0x`1MYn1kNfeC`{_=1^~?EF|Fhvg;U1l0KGQn5Gpk?z=JSsG-KO;mW`mQY z)9HTa6HfQz{rHiC`51JPU(^?+j>o&TpT{r1eB3#`am~e^(ubU?XiN%gEaqyWO3Q05 zlNxQGN*X3k$!$Hq=RN&bt;Bm;r1h)fpNDmRN_DR-Z=BaLLJT3{bP5fD6G?gc5;o>| z`a-9p#U1xg+~WemtmsJh`@O=<_pspa_tWVZE=viVQtapHbON0S_tRe<_rHcXf6S-T z@e`lFsMEAh8D?ZQ|fDgs`Q^zHJ(z7y$3b z;c@I=`2da&;BZWzdN@9S$K!E09v?X1a1=*z#34Mp9>)nWH&8fyq(gZ);vs;a!@nO7 zf57AMIO6emeBgkO4?OU3csxSDn#1wvbKF?76dvgv;;B96gt&Cl;!=nyeoYMA!Q(JZ zk4Mg_#4(1e#fUYGa}29+yJL7VKX9DFPeii>^3hK#QA|_%#SxE(^9~`TFlcjVltM>praF`|>4mdm><1o>%rbNn= zEKBn7csvgN@%T8lI+e%I2YehJ@KtQZpBw=G`%K*^pRFU zxoL>Q@pw2s{KLaP;NTvQ$MF$@{NV6-JdVf1;cz_uJWb(;-aX(w1CJDC=a2EGl0pQ% z57!nj9RY|h`1ydt&oO!P(PjG$ZcvW`6PuX6_TqKrjMq1}!+t{RmkIgoh7{3RO^^FDX2D|37;Rj>)9DGr*E5+Qc7_ChI?twV@JKEK5VHMwJCKL$_gTurPp;4ZAH9XPtR*u56pB-auk7YzW~?!GY2; zYgR;Ogo!T;;1XWT49v@X`O18=+8~IBNm^~$mY|E&n$}EMporvEUuTdawd$K@tw>b? z+OnpfK@7HmnzVt%O;!gsaJF{Dm5vT~{kt5B6A4?A6ek|@2wQx~OzNy8QP>X-$7^M1 zW0i~?_acS0ty`uO(bR2U|~S=$iijspjE?!jV0pnOI6CD`g++Kg^a~X)ry^~jFXxY z-r=(wA(oU-(PA$yU01Rbxusc1;j|l!CX%6#C$? z*3d?NH=5*`X2Z3n!eOsl)_=%oZb_%dQ|f`m|QO2;m*X zW(hw*1_qNtaZ1O!yh_@(V?=Zo+cxNdqes`!lu1l9F z|EJ@LqXQ^fI(yh_+W9)dZbZgxG89Ruv)5P97-`6y)G_LeQ#FW0@!KdEu$^2q=q?jx z=1LS9EU#pTp^+l8TXezIzer{fLsa$PceNyK?>!{3DMSxu0?FinMj2viv(8G9`jv=T zYk)I)=6cTp9t)j+ZNN~3i<%j1m~+&)jIJ96-zFD`7;|BnEtj5rd=XJK@6~kaleGwS zu!};q6mV?otQTywlYl#c?;EdR2CG>CxUGg$V4voY^bAGHvRQSof+GYQW`fn6>@zIG z&gX?d(AQfGnvu0n^i5yS>Ox8N-D_@`wYEe{Qu|oQY&Q{nixY;H1SnV?0%edjKDGnI z&n3}ZghH>sWD|AYyup+5hCpGZN_5tX*79qY8?LWq8AUt6{x27SWNBubJhO91VXBy; zlEiY*dyou!VrBkSat8VSMR+k8Vr{e}HO~qfAjmldy3;1TWAk^t3f1N-#4l7eMvrK{C=t z)_J)27cQgW4Ty`Cwg;x^OAzZMwB3cXPos+Rscrf|_B(AZFVRkPxRG)LgR1O#F3D(J zG*&j#(}gtfHmqMIo}T}r%5&2g(sp+s=Qb`b6W+Q`yH|{fyh9Fce9O5APL3NHdU4kh`GBiV!0{_GtJBf zF@QZRNJw}maAOP5S`cP?DwEjt5VISg^Nm^BND*76TJsP6$X;Q04b`mxF-6gGS*E^lic>pK zy1_|P%&6=<*?ionN+Mgl+@qtRNR+SZ=LORr`pp4O7h~c-orCv&|Jrm-W1xU_-yKP} z3mL`ccH+n7P?KOfK|tj3hcE{_%%pri6Y@G-D$x%m)G!rt)00$9w{ygvG^i@Bx=vHt zhR^yTe8f3RRB|Io>t|aT5_i5!l>T z0x2S$$me3=VwssqDa72woSauqowls#f?!{lc-WZsM+D|PsaeH>lOzJmF1shp?Gc!v z1{j(E(7c2a2IkgoOq1inW9oWvDfBChq>NLPjR|Ak%21KPvS!(|S&e7jz6*K0i5 z_wT4i$69MUu^se_ZdTs8CxGWIJW^gBz|l66YXF487P&20nMT0DZ(inp*Mo4MUYy>9 z%dg;b3Q`vsVra1e3mKy%4E>ItBtyC6_u#rtwI~tAxp(ezo`gqh{pG8elrYyRUifqU zSbAft&6q~udnzN2&-UI0wD0{}C&WM5z^OvgZRJ+)y&qi;e&^tb?O5v6CARb~-hFxC zry6fJ)u{+6d6TGS@`|1D1`&zg1;mZ7nu;Ml-MutVvN&ugi z^Z87C)7r$n2#(Zp#;UDl9f)2AE|&|jk=L*g!okzwAOsi-R&(gxmvaHFbn(wCG&HAk zr7t*BS0L4|0kJl8UZ6E6V`;E8Y-Y@$MG}Fv&6sqCBn6gs3kVCo24iCq$4oQM|A!>l zn}%et4uuNsv&$RqnYKd$HRCIjPQNY$2N9u?0;g_T^js^eWbT@z`j>O;qNJI#+}U!w zVB)0}jxUk4V7V=R0WpbB=ZUZ^1g#e(X;HxoZ;@D;SIZzeV<8ZJBdjo*)tMGW>s2$e zB095T@Hf7NZp&5clpG(*Mfz2JozvRUiI4e#+2UJiphqdW2n-+w^`6 z;pT-saWRM(*?arF$D4Sq=X;H#Mbnk8osm? z(^T=|X~(81Cw&J!aw$7R-I0HOExS!Dh-g=X8v($yLSJWAy8gHZQA=Uv-77TbqPV8H zX;n=W(I>3zIyAdiMPN(}^xF`gee_&kKYn`%Mg+1ieE~7ODpcP88YPW8_w-h`|GAUc zGq^tP+iZMVjo#moH_bFtqJ!YF9&uzvyRqgVevX-!Wr5fD><{WzK z!Et$yMJIIVn4@A_Qp;u9jz?z(5d*B_QBs&gGK#HWDFKp*VSt4&N5~h_zY})Og4E(g z9bQqi3Z?Bw^-Evr?)9i+MGn7A(hBfkJ(5GZa-sGqed7+C(H{2FiGK zZ@#CeJhYTS@}3BI9zy5*HIp*d3|c_8{hK0Nsgb*aG;z|vCfD+)hhh#aw`^90gtRGZ zkrHN^AiiHd@BzKT!eUv;$}j`_ZPg(9x}13he+8KNidhj|z*h#-aweXXZ^7>u~pZ{nsMZ)7oovM=LKy2sVD!(i{d&-UkaTuX{7b2&q${<~>cfB=Yu z`J;KC0Gx=tpJ;2OLWV~vhjSTKr4%~XVa+K`xebFhvdh=+DrTNUkwA!A!0S;AbJAJ>8Fi@M&0QblQ%{K+~@FqJKCCxS$y^U~klmmN}t00bBw%K_-ROeL_OZD0jAC z*`Zw;xfu}JfyWJjUhP2Ok}I=|`lUSRzT1?_LOM80+x&-|k(VZ5R%d{i*lKOH=9(Uk zZy^Ci1fn_et~N(7SHOyD;|C^4X5MDjf#gilX@L|esDL`bV7}R`* zg33{Tl^b)Pnqw_9^D-;VCbkA-v1cZl0cioSLHItLnapGd0Rv{sAsn&xa*-qXL%?rD zVbTtbCo(C?HceR)M-hl^OSW#A*T=W^iYBVlE72N$+q`j9@!Q)ARLXdj#UnQ(b{MLf z$ksJ#9PlN;LPlaakj-qHvez<6k~G_BZ9aqQHwFVg!wWCI|J9xUjjwDB`0rMw2n>8P zmI+@kGz0XNHJJZ_2*9HGN?W74{97yWSmmWh8X`(&NqZpFc)yo^F59fpsp_1^T5iIrq$H$Xct575Poca%LJ9R3= z2KVlqxW?D^2dOf@(K0lLdn)HT{%@8oR4Pn2U^P2s^sA)G=Oy9}OF4`sUn=8_`oi!XN{iwv4@^GWGP_Pk;kpW=Q?P8#!Zb}`kkNbR@<3%b^j2LUA&@37 zpJ#KWO|dF+^ojFtR_r-dd^;7}UpiS*@0^RVF!^+D?Ycz*xOGb8gd!I4{h}4GS>*B_ z9eSRsRh-isMNKZaq+uKMDyE)s*wfg#@bLXltD;qBM(>M z)x@PnMMXudCp2g^pqOk>Bp1O4IHpk0609}CuWSIRT34t;2GfgbI*_wgAk)t|;#hQ{X}ILGoB?*L}PsYGS8QV*sS_`V-3rkLtlc1 z<+|Q9+dyEd^X0NAzFxJ?O@{_Pa!`6uDhil650Yl4oM#HQeAxhwg4Kq;EWav}HwFcp zwpdKC)=Y77lE9o8Xmk+S?k;H>uB|kg$7tfdNnI!?M@Xg_JeI>=N=r-ghKJrHbjk|5 zmRC~m1k>q3NHNwt7g^Vpaj9|AGN-l#Q7m0$$kZem=N&C|yTZ+7U(5_C*W31IC!PP7 z?^kQS@$Ev&YTU?P^|~_uc2NsRhlOxekPOmT0Zo85%mkdjE}EHjDQjk0{!X1C@y*<> zw>A4erV9-pKYb5LDuW*L+i_JJm!?*Zp&@x}8V2gG^?<+y>VZKW=;@uZ%a` zGx$HCtTsL6DplIQB_^E4boqc>by@NHjD+qV+P)G)2X4B+>22(xgBNb{Dd&3RF;(@r}iyx3PTdXLE)Jm=jG zc<*<5FY)DK zD(iGA4tePc&K`m(%dx~FxmS52h25-_?qYAOPPB$@q3=;@y>u`{e{b@xA!40(O`oD7 zr(JarqJG?0q_(J}FRl_cxZWZoy-%YH*@jIv;C_4e5cL}IZod;#wt2IP`zgexKoU=4 zR@@KHhYW@ycWmvdgY?YIAC0F&mH!t#4w70!$}+pQRbd1Y*~SNcFoGE55*Fx@)z8KA zV{5gCm>^8dfHbdza3=L)j;u2(?jlMehN!x7?k_v{UV6njw?Uw1i*DeEH#n;-fp3mp6%d+Yf>kVursq?%ry zwRn_a(;QxKfnWoggR&qyd=p@dSq;ymZoGyThemegsA~^vM`$>>9@=7rCtp;HH5VOl zCncs96wY`sdXsFKW^6tdQsy!y*}>GQ@Wbj(mYzUs)3~>7pk`6ExrvnKNVy01%vF7A zswI{qzC-aqurM&meJ93x%iuEz5XgPE0@LSzbN{dZSBAB~AB_fMwS1Ye5JAHR-|4W} zR|=S)H4{N9WppW3FSIO5k(@QmKdiT#USZ?BWL=JY{M6s{d=FRp=eigQD8{xH^$5?9 zaS%_MdewtR`~W@q%z1R984VcEZ+YcGZ}hE)#gBct&Z41vq`nFs++~3>s&(*UYB6*r z^Ker#-xUS36lsVHzZAZYi0p`GKY~6POiUZgF}LM$cTc6*K7+gOrXqaU)Ee2-FU8@x zm_qG+*KZFL{8TvI1{tCb(CpVjp@V-!_n$HqT`gmOHNO~#3|(Rm!}bQHjN7Qux2wVr zoQ6FxiDEzJpJLppD_?fT>_h>bfn3jdf?MqLN)gu4md-WTbh6LLhK!;pI9j=atKeft zx4Vs4`n6Cv_G!Eydp2(ht+4hy{4{N~)uVow-z(f2$nKq(gdZ=xX?p`Kh`$+6cESnl zyNYk_#xJ?&=?%tZbncJO_~xBKJXs#%vPUDGbsXpL5L?_GwqN@RD?^&F-Yz1t2&TfX zK#^^~k5qIDxZv6kn40{Mj85c6Bb@l@7%~BpAi^B8Py#D&XAJ|W40l?Kz2KlxyWu4) z%VFM2Szsph+t=UJEJ-P%`DRvTXluxV=DDDz#4qz|0Y%VYFxlGKBlzvHB9f9JQ*{!x z2thosD1y7$p&UFqf>I^= z`XyDBjpv0^woS2LkM$9K7vCN5FV1VrL~@pNCNS{pndXIH041fiRszsi0R~j*OPCuo zSjFa)nu!eX&3wD+wVcehqmacLySKhL&QnPmL`SCjF<2ETtQ*r5VxZsAd^DKqNe1kQ z78ILqynAwMcMX<|2?IlUhe&35PoPnSOZNTb#IQB*`iJH;5Ony_G-3buoyDEUj+Vm# zBIZ@VL%_QUDWbd!WG)<)8%a3*{vNf;=)(OEspx(_@=fp=-nkP#)V3(wxNae0kAIr7 zn7AlzMd#Ph$vP6{*aGW-1E;P8b+0PJESM5*1LRTpYu7tfPD#;#^rnk-sUxbTj!JQ~ z?RX49Th$Ngu1)X6B(`8KF8(a)C_-tsu~inLI4+M}>70n`NbD7~5ju;JwT^36zTa_z zn_htR=2yNg|NJQGI}`=Z?Nu>TEelEI*i@7l?rG1%)nc7;HX2L5?ObxZ7ZbWSnR4tp zMl;W1RP}8N*jK>;J8i+un;)McO?qWt9m-oPf$k6}Dp!_JWe z1+Qv;i&#W?Ey<`3PAp+T5Tv48F)>5IG9;A)Qh2-E&JI*75zUGSk`fvxSSFHDHq9aK zQELsQ5^}5z);jbY@Xt*6?LYsfXwkefvs9$8FpQ3A7>3z`<_w;rtby5rqQ<2?@|v~M zuxcv-CP2~*0$ug086;JJWdy~flUE2CUEXeyinaN6HB4BRuhweZuFOoN&NSZ;Ckv6i z^x|owRJ{;0Tg${cAK@q#NU(ifZ-|O#V%CsRoWWu0jyawn?3G$PvhjFXv*n5b!IwhL z&{-61@^&T!J zsf}V;a|(TgrRIvJdMyTz!zhu8i7GS$_{(3u<0p8y-!5kbK$9da7vK!A)T^?Zp)8o` znp|ZxaxF&`Ie7^(;6Jhsdg}!X2nI$|OdFyw_4(1$&rbo%mK*cC9F2H`Xx?qjztbap z{u=-M^;3;4`gUgrqeV3x^?O<77hINmN9Oz1Z~76gdL*mSav)9+Wo@}Yk_J@vA3mXu z$xTJ+nJOl+?~>r0+dCry8w_3HUY7?wr73t|X6bzlDK5lG`IJK>S6=kn z;77jKjV0xfhIVkyK|l=RL({P9R6Gs+MvXs3WlH+lmY|&y75bb9&+h219kp=qd-t`h zvv+MN<-2mOG0$lZ^^?`$eG$uuErRvC9V|CmD(yiFqrGBtwd7K*d$&ovcR6l`0mP`O z_(H<*5|G+16?zm85uTjc^KNV46%YeQ%V3fno{QUInRB{u>$j^dn>=_m-onlzmti}} zbXJ^(A9GMuQ%p;vDwUBcK9+myT`-_1M0nS8aTH@gGWW_hBo%HP{}Osme@bK-zkU6> z{JK~jv>7>XdnRjQ?w@5qk~+^smI=_@j6+J)7@EPbH>`Bai7kP=PAvtt4AzDXbP^k5 zIWN$3!!44&MLaMA{B6}5II9Jg`4&?Pwbm*~mIlH>bphzjT1k2z^ zcTz8*2C%Mro>dI=iMTl&Q)Y0Ja5E^)hAwmTyyL-K2m28qZCe9MVhaf-$e>rx+6T(b z7N&rY3r9^2#-&tfaxm%6S2p)%65%dvd;hi5 z82-BvjDG$wdzUwLn<=4v_&?RM-ZwtLHL?sb4GG5XeS9<2pJluv3t?T&a8*oW>#Q+t z1e<%k>H4rw0=}8!^M&m6)1bw^T_YP0k4C^Tp7?*WhN~5-LTpCfHWn^#*wZ!N39%ue ze`L*W%Bb3jxk(f8HO}@O`s(+^`~7vbB}YTg;M13t)J)MuwpRF9kGN-LP`u~+!s{XDn5`#>>ckj&oo5q#oi)3-APq_ z{(_;i;=%HYY*}H6Di@I)^Q8h}`Vb-VQ3ZkAMOCw-O zeM<>ig~35vjW5d0X66Dz64WxI%;j;%QD)p8aSp83sIm`vzdp)B;<$;52$l_Cg7=<| z0qL{Ca#0$L8xc{G4#-T$2L*+`tyDW6QBf6?}Lv#y$Q>k*vTiA!+8RM(He5GCBYYA_ix}4Ok+Y)g>7v+G^G_4zJFn zia`gW5r}O31sPzYb=sS{iVM(`WK+NfrrG2m%=)rsFbosbK7Te6_O`fnvkVP`_M<=_ z-|5r+_uIezx67}KmEe_0&kXww->k(f)!Bj>8YNHDBG{?KT+D^k1qy&+zCl|U2IxF5 z^I2KYMg9Ht8yk&di=L;aOm3Y#5g*4>N~QL$L(k8imF`vW>>kW{f@1xT-_#ph+Y$Z| zZ9v2GL9)<)^;7Nq@cSP%)ASxlA41Hwx0*P@2+6l8;*~YF=zGM&k897hconF=HCYph zkSs9BbByD8n$#z{m^yx-M z)P5s8NbK)4lp59a^E+L#C%p~V)JQ^Xe(u|wqbP-gulLlo=XiQ<+4yRKO>H;OjhiU@ zQn6;O`rk=w3~uuRJN-uY6hM#l8#IC;L+{%LN+pwoQ5<0g;F8!>$q`|4iC54}8;`K0 zjpQO%maVeGw!j8Sr_n@+NbJTTCJ(cWk&;ITshL0;#C)qfmm|KQ6U>0?M6zH zAqmDpmI&s0v(ad5)>@|#Pey=d6f1(PWey;a(~;rZ%EY81tq)tK-`Fyst;IYmhV9!F z-N_l-xlyO0=Vo zEM@6BgicGQgSlFZTwW57__nx}GiA+pm>Q)Jtyp=N+qi@6lw#1yR|~NXuAz3IFk77v zGeiFL@gL91GV_fIB+r&LlK}zBGJ}}7Ds5shK&dJ)$=!v)mLO@qEQ&zi)*Hu$1EWZv zeI2*qMnPBp8AkQ}qst9|+$7%hj^2Ney<||_i}w9fsG7#mL~m^N(!Q^cYTh?=e)lO@ zWzjVe-d^myPb(lEKmT&h%Pybongvn8SyZitYB|Kgxvf&+-6lgmzOAQ6`K=Hgt0+7= z^@MkB8aROMZi$$hIP+>C(7&o;d}T`P#ET@$?eX|`V~>7wTq{_wG!kNmtlZW!ZnsG5 zD#lWIO`SW9AJ%bQJmA*6%(cS@8LjWQ`Q*QK?;Xl*{ND8BbE_rQ001BWNklNFXtdo{ofeEFtxt%=(7qn8e(ULh~UXlvXtQc#0xA+k=fo2IS4I8d&1{u7Mk!(7G z?3Ib@x}X9zbOr$E%dfvBm26X+#2X9vAYQB}pLAU%vm}|KIJev{g{yn31BHXR?5_ zrUc$oP{Ny7Wa*HI&de$FJ#;EqUp0}sEaw~R_1l#V`?}K-@<0%Q&WZ?SVS?qa)uXw^2i!r;i#XD0AocE~b>G_X_Jamn< zp8;N%e0)WX4JtuSmN7>bc`xDOr5%M2c`O_794XJ()9%@F(M7~Klr5Mf8=O44)NPtFk$W822W}R?iXW{$y=#^~h(c)@9a>JPS7iUR)Ny$Mz z;C27>YTs&NYG50@G(5S4AL{dvte@gRYVux+9DW=CDZ~#~Z{kM}%dqllU75tQTCIBo9P7xk7pR4{ zyd?uG&C5P|4nNntuEhjx%YH`swrYe^?Z8C^F35~qXdeK{INV6l7cLJoHoHojt>^|K z8Qg<2%dA-wDVcs*f;2#oG!xB4Vfx9G12M;sU?dd)oi+b4r|R+cSTk$r<$PB2j4j3v z@{kgP$Ch!u-cqoJ*)0ufh?q0)BKRi?8wx;@1uQKRvw_J8;=tDHFPz{2UO=J0P**6T zicW>;l*~b7Luvst$VQ%y)^#lcI2QRPmenA2_YR8mNa&DEf7 zx+y8OJ4UG#7wD#5?(As2yZ!MR3k2Uka>w$&JvwAW6Ft2RZ{EEqSa+Rw-S5H2 zT}xhUwnDtZ(A|gn7h9Lyv7XbfuEEfL#DR(7L9PSCdLaD%13t$sw9wM+q2B(~Ixku< zSN=J{Re?FpL22;XMlIu`vf33AuQJ$8dtDh+H1$A%R*jRbukllsY)`&9HooVYeFYE0 zSeEk+lW5k;6mgm_kFSo}_t&@ANFRTl{x47Fl{*7!z5V8Lp88j2KbigxvvXOCU;cf4fyy~V zh}N*hL-f_-9zOQi5W}LIlyQ;Q$*=1p{ZbMFVYH}N*?e)`H|W!}sU z1-pZuWqGKh1Vzg^a7Zlr#PJ*n5GEGaBg;HU1QF zN>8PdCH73DBFeNsH{v8oy~v+=#f@dme2E$sB6a@tBIh%&I=+{!RW`x0Fc>j2kBWwt z{gz~HeIAQlb&)TT48nMhtEC)1YhzxwExndxRGp*5({i-1Wa3*lR(TYN_67gpUk$ET z{`!@8C37Pv&6I7;nX~6O(F`IYDG3(qO>3lST!N&qMYw+Zd(Bz1&G_j9KYhGztBE=x zZHjpe)eYb6Wu){^3$cr##lNS!Jw3ZOi_PS|cy19re9BEvgPjY%GQ|g~AN4gm486x1 zi}A1g(DJVTAm0Rek6~AO^7?7o9=$QO@4FgH)JCuZ-nn3g(Ay)6&UiZnsriT+JiPN! z*AsObFI=!NaLAo%e}%sEIPxtd=y;EKo>eQ=?#2a4^1OlRydKPCZ|FYZ)x+U<>bcKcU=q%SD>eR z8@h>LH#im3ldUpA4B7uZbe_n5KdwS|Pk`vNzB}E~#skH9h^kcV&SHI&68W;7;w{1L zXSjAt@%N$U*Tr3R6}YyPYK3`zLL22xC5Da1taFQ=6IBWh9vNU6ZMoum++Ygk8)4`c z@i6)U#10TiL_IXM93)jj0Rot1ve2mL)dq_+6L0`XGFayBGs1@tZjyO%oa#I zB)216vtqV3sVXXNJ5snYjY2I}uSoHU+_{7>0Fw;tlq4A4s+y}041_Z?2&4lM+?GH@ zw4tv%Dw~v2QqH8v+=7>y3TAi)8YcK$RD9?L(v6ThOOjw~Atl=l!K*W_MAi@xz%lWJ zLaDK^sUq3JZAzsW9aO}q0pEsmZGff7&Vdfws6M9K9ZO?6*+;l zrmj>DmrfYdlq%tAiWxVCXqJ>sb?P%gM8NrH`4@&+C2MnA*Rx8mWdgzKGz|a-vIX($d$Q)~DaPquBX+rytuKgs zzdPxCz4@t;I+&JnU0+@#Q?TEWG|)JOp@<({oq$q-$^Nh;wz~QGSOwyHF>yoCPUD)x zZ5y^*>*N6#shuJ+dPY5C=Eu+BX{&mO&R=E!i(b5@OMR`bebth0>Edc`l> z;BGSsImJx+c67}RS|UG&o?pUnF^aEyxeNoTxy`n8Ej2ogRa{fGo@yZ6<$Dj-iLdIw zPPDbT&P1z?b{zy4RiyUbJA~8rB@HUNf$*Wx@9eBczjrD3lXio7>SBCdJN$HS-6vO7 z*xFbB3zxX9yurngwQ@2@4T1O4yA|HLPp`Vybi2 zMo#z6jRsvTV5*l%kfo}yW@efRSQ(euUX%)UEHu}R8-QtMngIha zbZ%kjT$Xh;lI%`8;d_G)@q|d;$)?(|D%}O#rNP-LH=N(Yd14SdJ9-Fg(eqS2ZoS_S z9%7WY?6(LhLb1xZb=u(ZNj%5UVxOR?EQoiw)+~Okp3NfWpzKl61@`zBL%Uv3>%HIe z9`u{Hn_6fo+D`nyBeu!8LxY~a6M7i)b6srLI(~E6X!n+m|1##3#9%;tdca_EjHl6r|E!GV#nfxV8)vJJ8=1MRkfu ztd8bX*!Y}o=ysG*Zl}T&?Jn&6xv0rq=SEkV5R+&p>UKIy(?$XB-R6Y)lBPZ~v}=*2 ztM+GVN^4)$fIaxm>q(%pA`FCdMg8xbmuYizc{8Nw=>WmL21D!*hYb6Ce(ww%TZXsl zh7SWw0ze_^!t{E_4qHhuTH6Hv|7m-BUP*E+S z{qb+aeqxGsl?5V%S%3~~&f<`4kIEJJO(#A4X7(hit1It~@K3taXvdBjO4qw~3*0(q zP?3L}L?b0$pgJrgAV~&HFh|SH|1fbQk>A>uz?mP=GjDY)F@&wKx=RFhJQ_9oU6%(O zH7*``1s{+_KfE7BxJ*88uYnQ_5We0&t{-2&Ty8Mh^Nc2{cy*__EJ!3$V4gS401*FO zu921`%3x-tU;XP#6)+L^LaPy#o3kWhsT$*gLT?1DKVZ zNu|N4yzpHig{0`k@FO?o!FaXChapJ16mE#p?_gF6B-3q1Tcp@7LAw?=!5uHJN>Dgy zK*DP&qOOSnniaron94*InI3C4DXoQ}^>S4+2n*x!!E^%@5fhm4@FO*B$IIw7^Md6< z7p1Oz|3^43d0=R{U23I(aBeew7kRGJ7~@V2z0l*iT~j8mnW$IEf5LW?zB*KvwY?f~ zgP!}rhtpsUktVrm1a%xRS@D^4y)Ig+4Dy^UdiXnY*+~46bjD(bq3_LzwnI+2DwlC6 zav_p9n!=t!?lh|TQf!4X8;`OZ9;n%AExoG+z24-S;R9oAG7y8wJ zm|XVPuCK0mJpfu%-Q4icdY%Bo_EAyRQv!P4WH#57YS2Gy7ku%WPHk>q^Hf%s^ktW@ zKd#|}Xsack+q~9_u1ah3;?3=3pp-G1qCDm5noYJ&VX?i(tDu=DQN7`&O2E8*1y{B+ zVQFTI6}_0o@AX4vu!A&n`CbtRQF(C}${Xjlx3vM#1sH8oJZe^mVl!3cJ-0>A-m5KX zbEBy(cUUx80wW6U!?9&BV^N7@euV_0`=E|Z)=Zf4=((ihuw~XudYkufVT64-FFBER zdeM@v*V!i^7Xp%4`ez@3@d&hJ5IUC{+|my^oc=%l@pb+?Fso>fLd-hU;-lS2##3o| zLNs44S5gvl4qD^_xoM@Pw^d%ixZkzc=?3HNhmP%E3^tXVhB#aL^)C^}8>RrCOtfHiN!T@Exd_Y}(XWW?lYQn^zNq?M-**m}( z2H!!7X1b69pcEv3m|Crq80dgWgZ7oFvE;28alfd|H?(SyMOnj8dcIf?!GQ6E`W2>|z%&g%S*g4w;MIx|(obcqXWu z(jUBh)c|JY!`!hjnApQ|05i=@{NO(-i^(ksoqqBLynnCXjIIlwobCMB?$buDc^Oar zT)+Z7*9^sUSPSX~5Hhx_XWVZ0k9AiAy))gsmT!yCPFA+Xiq&oEV6oIv7ek?|1n&-+ zWC!pq#&3%k-J#j!qFG=KuV8WYYhRZa&L|yvRy0L|&Wc0Sm29!aRibf4Lt9oacWTS6 z?}X8dZH!M4Mo+Gcy%cQ*TZ4y7ovvD7d;D9%VaTFC{O#*+f(ngHFe%6ljzkVP)XZcvU#iDaLr5Vw2@47fN3GN zUa~Zi$e0MF z7X&Fqv0k2yuxCjOHjC1%v3wBSNX-nxK3Fax0h%RY(GLcbQU#Xhf*VBD1I7#@&CA#O z4(8F#U}sw&5l?cAAWAuGgqA-kgkshQ=ZEwigYoKyce9KlM-8%|o?$CAj9L;#_xqU2Nl&f{{IL zFm=yTfs=ve7u~-n%qvZ;JT8PAvYss?XwB{z@p!0*7-Z29m<<6E5xmbH*MAHkNfN1m ziV1`{YLPt|3TE;K7eqvK0U&26x>87n(f(t`NCIhQ{`gAEWtPMyoI>inG_0AK6pJd1hXg==0nJjs!ZF2*BlXyUmvvddPtHLkMob$y$wwwASAC zj)<7OPSwDxU)qk+E`sAN_gtS8(e?L$+{5jWgb*we5j3gG%!%UVk}2&HSF0#uPHHs z{pvwcNDG%NNiTZ&59T|dzy!s_nl48GhJqq4=kEF)+7q_OyAow zw1b_du3p*g*W*TT5!g5aixz13H+Htc0zQFfySud5$C7q?PTfMb7?4BLYc6_>@dk%A zy*TFAwDs%nOxT;zUt)=YFvGb$*JEd2L}!<774fpU-2)Qc$$c7}TLc}`)UfR7leII; zv@J^)NYWMKpc0eZc>-iV~# z-TLTEUU`!e+6(#BWYK0V^-^<-AeBYT6*%1kV_cesQ)&&$$Ag|EGG`Dbdefgzb|DDF#8m z{=?fS6-c71=bZz>@pfHhEH^PhrEatNq7>0QO9Jr>V$H|T{R9#?00oP`S z9q0J?0f@B0=t48mtSRQY zr|hJZT3st>YZ=3ir`xnUqo=vE0VLLqD##-60G;hR)qp)HLNLz|m#x@$q%y!>Bmy#`yVj z(T*{MCUzzc#%mbv6V_VbD zhZmV?TWhh}5tY!nnnq$pG&FVsuJbE^I z2|@SdH5b7oanVaM_^SdMH(5m9R+<2K;Sd)n-dk%>YWxeU!(?9FUlIcyg z)zEkwgO3PO5o-{u8}V1>f9MZI>Y`?1fSI6v=PPi90<*p|FT4OyAj~(;Y&7sB{9^GI zJ&-cRwog#>@-gg&Jls_2-CiW&=>0hf0b4W%3T$VCmbB? z!cIa|`oU})rJ)9!Ij1NwQ|!c8~6x>MKe!X3OH(XP>Eit${v2W1ybb<4ek|1b49~{$1%8rbe(OR1$wKkPIboN zWw*rO>TR?ZV#{T09qL4nASjy)whe!ET8$X+-xKQU%Vs5!bDWk)e7nK&}Hi?7s6nn{8Y$Yz2pp$ZWhv&qZo3Kk+cc)x!D zG+$=J${knLx<^1YEJMzUefqUaCfMr!C9(8sSdG>dL~8MK>!P-dL)5 z-OI=Vr3@`hA`C-pO1B#Wl8CCI@B>J0+d?-)f4nC$dU1qXVB%o%neE;{CfNSnW?Hm< z@clwpP5i-pXRYsA5nbp)fMi<0T5ATbxDx$-r~8Ngz(PvSU({^@-}M7V^k%+QHD9%506H#c(k(eU^uQO-Xl`IaBMc{E3}Tg(LOUHn>i;^K)D>RNCq( z52og8u0F6*94g>!-EB6NUHh9p)mHv6aEvaK&K2A{ER8{%+E_A z!*&33l=xPGf?<9iLT=x*hZ3o%7qQH}Uz&hwh=*nc?Lik-y_C!bh=G}c7_@>DTztv% zXiR{dWf8Md^gfy($B^@^lnTDLwThqu;?)X)8pSbhJ+GN1&oVgsvd@){u72!K0uk2~ z#9=&*60Gr7A0dN%F$&8+e|1<=!qCch*OdZvzt_3O)sm`goI32!|DRI%nuJ_$%D@@Q zu&z!ARfArNpyZm@e!YZJbiLg4L*e5O)(dbA;g7UP4)z_=6RT7xi?1^-#Q%7($u<#* zAUB#D_4a(7L29`NHAP%t%#0=04Vp)!c4Lg4hoG5Au}%gXgpen$k}Dp0_dgR2XZ&(0 zTe3)+ZD15zty)SpxzyJI1f18#1`o}-mFyU?dX0r}$`avZ@ zwcS}YLzpR-Y`dL>_83Bp#BD!v3**UH^gzJNce&j(0#@-K)ix(PAfcyvauOj9x-7T5 z5k5cCWzcQ0vyADTvDo39_j1I7NUry~rf#_z)Q6HlhYKF!l$jf%!2#}-TUriy5fKGQ#&rWpV~`?`V#o)(60$F!l2$VEJNk+mRPTU^dr)(q@Ug1f8xb zu+Xf75M{m*io|QmTr%g)c5V(QnXA8d-V|-C%Vtla&YBiViO#uIk{X6OgJ;i72YQ$T zrOjK;)%fh_IA(G#NfRi@zU41LSne#Yc7~HrnU+$43~L?l4S`rvVdlcYR)UFe58Csz z^#GSOYX3(9K8vJ*-pauq#Lx{#BsQwxEV5`#RexmGalRo~YwgSLH~<*~-uZAY#s zeD}nN-Nd2hS=(^N)iXck!q;XMFkJmqE1;H79a06hYCxEpUXIa;*j?m3x|^f_7QNxq zdl!lQ5|^ud2vIaO*x_XGuZ74*80dsj%2*PQsg$3k!w+S~UDRiV>&UyHc{SY+HIQbT z-VzYtKD9^$l5|Iasx4AC5x2E0q+#ae!F0*sC*n3rt&Le*paG*b2ojfTUNtPx0Bda) z_6E;s4;-V53m-F2+A$jwD8mXp^TyPoJj;u^D5+)u3h7kIc*+r>mvUJij4zcYI2c9; zuon~Xxb)0MZW2pqcdI3i@LogHQltJ(muayUDX?R);Y9y$SmMDCGsN>tmL>XcnC;h1 zXA{2n6ztUu;pTD>I3&9gCMc4m!KSkJ@DU);h5D`SKA*B{C7Q=DMU&4s&9#-FA+OJ87i3miB`JwL*Ut0P8{rellHU5q}|q4yQvennz0f?le^s+ z{urk2{kStKEGFS#CpUS-TO=w@gUG{TNZ1`TQ3}m%y6%&!^2J}F#ID<;cv-p`u1oEU z#Y@xDYF#Az>l@wobetRxR!TbAd_5Z+u?qzI&qUTZ=Mih|6oB^Fuvs*(u&P8ey{?!Y zWMS=*A$y29K3Fpn+rG%2R?DH*#`)&hMy;{?raV-%>OI<@8pRcW?o!E8GRNMpfSx6% zZuwvxP)(#&NZL@=%YFF0rJZ?9MN{6lRK&X1?G+AMWB?|$hqWJ9vE;I@jWGGNLgC{={Wc&QEyd)pltu#8Edrn@ll?$B|?#d0C?@)Rh7##g>yp}x@VD?W;a zSy-+FI$QcDGNfWAt#$F<*tLlhdsBlIz0Zq^w#aXEG41jeqBGCf!!t*oc|WC57K53= zX8R6NgIC*R!oAFp>wZE^Q{v`7J7wDL?TNk|HN$7ogwYhP%e!IDTRmvcvcMj>&Q z9Rv00B}Y2izUaZ8z5v`4qM7?|^NmFTrYFD^nJ9Gv#AdrLOPA8)QK_6KOjQQ@_7as* zd9NUv=;qv^FBfhHU-+F(haTgecUxn3FoENNM|IaVQN;Soj?;{I_1+XkPR+qTrK|U}w_uw_i=hdPKF76d+9FcjRb;cPmQ$Z8 z9l2M>y!&Dn{abXx2tfz>O(iR~2r-QE*=^c8d2KQD4je|s2WRy&&~^@1fUILf9WzQ~ z1{_&GJHu2m#l0jjumG?w89Y*i?JeZGyW&og-52VR-+5u9BmaP6*RoZV&`Vc0L^(>^i0=+yp{#GO5nw?7fF~# zm!32jh9L=%vcT5i|7SIO9S^As2&|VlUS;gXEW{o(!1^JYF}nd4!=6z%L(5!_khSh5 z2X~^#9Wp`8uKi_;=(vpSq$1CV$|&!;6cE?bq=?~lNlM`ZTHhZ;kZLx1`QYV3moMt} zp*^o$JftJT962mTlyjOxl2p`FvK`lzQ`l85rF;2CO1pA7tGnVXlSE_^!Q`Os9Jf2K za<}Dui&;dx>iiP}m=@37iULNLqKv89<|}Kv@*++#Nw`)ZzV!2Y?V{yc42_=tb&7NJ zF-dfv$F%m*8K)*Jj;{M8VO!)-KqUh$$b1$iKGE9$l3+iRq}< zlT!n28k)N((M)#t`iq=n-i8Mql8A`Wm30Ts&`q0&Bm@GDyfJ-kSxKW&XBM!U*hWVeV}e0`Vegu?P0T})e5+U1_wc}Ks&oG~;f zT`9lV%7!mT3?vyi;I&>8>E9d}Zw9WUsGx6CR&|wilDiSf2bFLoPpJ$!W+GJ}t$?Li zYeN@G^5j6_<=7X$3C+vnv0UcaCxY-2G`h?jqNR(p#kll{8d=#H1l)SW@g`$(=zhYj zi?S(bSHqe?T9R6p1p~unP^k^4;;OOHi+m-MPf~{vx9)$aA5v05t(#(B1OjWm+(0CG zF-4j<8TM>1129Z@EY(pG!LTP^3xP^nGte;pe6!>uDqC_1VL4>#qY z`BJ%v^}E(+0wzsy_T`sKc%K72%cn8)8qcIMtIP|Syl%-qol?=F`K$i8(e3ZoFJJFp z^`5CnQ89Ue$*gz7b*?kRr#E$(qtLQjX@ayqhHlG>Z5-)DkCGJ8xgcaNG_UOB1L8K( z&GBHYd+~-om>QhGjo9Wr+sfh2^?A9XKpl@&2n#XUZ|)%Le+<64jgFx^;aQtd#~~j5 zvsVoxzYeiW9c~X*OrI!O>^MdHg+-z{D~a<|FQi1y>b9^B);edM5BzcM(ouBIU}W!> zIt?e+d1^$W{koW`ZRyQ>7qyN?h<3r4AHHGRYw?k(V%r<|J;l4~ww&}pEMKNq7v>Q* z8KUeDKhYKl+6GQhK3l@)ULNLr#qb@tbz0wlK&C=5KefC-haVTCM@qbcti|0G8|Ky( z)+I^9=JgqeK=UUT8pDrGua_GKZqR9WHfMqYBpZ`c0 z>Vh&sJpXdJ>yLT9Dn&ZSV#`WC=#-RE76o#bBd~3z9Qe>tVpUB+ zS5kX=6&KGX2-jx0YCv(QM=%dO@^UI-PPp+Few@1KcmTjrtV8l48I!y}Og~SNvT0pX zX9U_ioTXRYMOBhfJFZ@;_^*`73yH_2Pp*$#v)`9+^>=3^)J%mn<~y@*irv%h^oVAug|;{mR) zLqNat(zke(v0^)iR9X8KGsE2)n)z|O}s5mB@ciqXQ#!a4_Q9lqI&P23JoYlpo5RF4*0 z$JOUtxv8q;*xKY`8s#oW61PzndHso~p>`V|GF4oDC=ey{lc`$xCU4+gf_62`rUt9! z)JYL{CtAyRw-28Wz`9XJjd(ST2Ty%=2H${Vw?kd;yno#8Qh5uVU;4y1MZ&_#+c^)` zU01sQN+183Khvk*0pjSZX6i%SB5k|(d)YCdJ>a{+y{VpA zS6G?khBNlPUZ%u6!Ktg=uk?-58vxutE>r(@&@MJH?|1IKQBky%(37 zh*Y$&^DHeMr$v=&%2N z`P=1s`M7_i6Z++sUjTeJ-@oH~g`wZ@_V%^`&`FJ8;Y97}T!4yw@D$Y_&c3EI3+A?H z7i=JmXpdol$RmvIBj#NbH-SNV89LTn*8K=Wygew9RwT=uPB^u^ibjpf)ckwWXHgoBF~| zy`A<%?RgE8o`DGPUueEJn`$*#bP9Y)wt5?FZ|&ibOmd5&wTxe&OnXx4dKck-!xS9PIB(fERP)`0??9E8jwx1$RUs3u`Pv;~~A1Z@v#) z>xv~sDLO~AROneYA$281OLCh;Sgf4(&@-Y2hZ*{@(42Ba%8i(|+8=HF%5Jn+6wpN1 zJ_^m7F!>7Izan7n#)+DtF<*%Y`ffZ*_Kt7N(QQ1Z^f433;424K(Mg3Lq!jZuo}DTJ zzcsTP0BJ=L&T>%#F(}fC>S0;L^~9&Ca9d%RSdD2ziP8;_#i4FKRD4ttMO8g{>BePN z2DA5XWY!NrDN?NN`i~D>Fca>Xe*Oi4X%1NVm-zO3-x36M^F8BN;g8LE}Q<2 z3dFX9X@YQKvb{jH=C59G;hb%UaEvMJvCU#PDzI!R^oilcrl+ER&Q1d_@PdSPhYJGX zve=_#gOvBOxBW8jd<3?-rXr=~^A7;r`bfkMyDU1J7z$XXVuaL%xZOK>2zs^y-fm>v z`w{iArdNX3>aFNpZADkL4BA7-co+}6PxHWNr$@+sC1a%|e z&Px#UvIabQmXy9i>Hk|7&Xrg5KrqN4$=uIPSPH4 z#7JA?JOUKt14U3_UMtD8kTRe+fQ<&n=Kx7APu}e$J{~kH0<&gwAzY-=ctl0MW{@IM zSG7R%!z3d8?d`2c7Y*K(ZZs*Rn1TaEw>U9OB5~28=k)wCJJ24h~nrcH5$AkPLzAZ#2mceYt`= z2rk%vskPtwDeA zNwRP%k!APsafR-@_bA(L&Bd>;EcTo#(IzTRyJZLmOwRg;NLX=D2ISnU>+A*(Tmt2; z-x23_LEm)j;(y}L;LSGeV_R1P;zriI)ii%nm@ysyg!=@B7QL0(C(-wbl$WDc3}ee2 z!Z4sN(&()VEOq}vC_2ozP2vlvOQye2pX9`bR4Z(%7uMdMxx&e8VxfGlQH!aMQc}Rp ziWJ4bVt=v=F);8vF{Y-Iv1q)R!XG>%vBFw2)P8@w53?PH4Ldc3+ z%J}R`@Urm2dI{lwU?}Co>U=w+_ULd)(rd0Qwf$-VBz^m(iOp%IZ|qT->rt%_Adm_48KMazaAsgm} zvI01)Qs$ddv(^uTpxp52nK3I;7uFPUIYC`#bp?MI%~E-A9}a@`LTc$KM3A)|R1`P* zYfNwRj3|a-Y;0-L4Qc5ALLaipizmoLy$4dA0_NuAX<|5=y%V!xD!m}R#T{#o`v_7f z@B*!HRqFD`{Uhu`vnB@7T|dgv1BWmwNfp;^8c*o%(e+F*9DnLyp^{Mv!h_VcZN zTiu51RhGqp0_EnyRG4Y&SUt)N98gKtO_-7Zw8i`rtP`+}E;tsrKQ~FY7`mAQ3u7-g zTv6?_RlT5Ncj(5s60-@<%J&9X>n&lc;p<-6lTD!*A;yR4Ff|b&9qz6qU0vU9!R^AM z*WM{M^OF0nXQI=n`Wno*W?vD;bY&A$k3~K<{tm72L>`h>Y%5;}9(g;c1l5CoDsS=l zIHyl6@;a}GX*gheuLs)~J?|fbZI==goU0TXyG(Nj?!Gb%+PkmQ5Ao0q3%wKcDK-o= zeL&720;`ZM*J3DUKoKO&vTPf*xQvU7lRSqeE50-LZFv(rNdO~Z!TmoG1~LE*9>jOE z2?FCl+42@T103r-~FHp^~3;G#L)xF$R#l1o452RJ)1t5=t5F8yH-w2Gaji zXdNBL+;IQzmB4;B973%ZeV0lR&4Fg$He4o-S1N$mX!!L(E9Qul_)K)YfSGBD)+cpF zdRDX;O8JruD7yX~yf8l^R`oF@vjSbTrr^FpU}$Ipsrhn~bT@kO_eDm@1oH>zR+8kX z?QX`$X6Y=OBCKmxe_CrqY7p@_VvYTcjV#xL?usfItzQcTUHWl{Et4PMi3 zgzLup5wDJJ5}%riT&(05KMO&KHeoee-?%jWh?k3s=B_)G0$&e{y3V_so3@Q;9tW>< zF8GF5E?Ikfu+VH9PP(Tj$*~v?V#-M`9*=g#Ag+SI(`FQG(z2)OYh4z8$dkI=CCNb; zT{MsOoPT%HLpJpt*BdbI)r+IM;u__Z+d;%=j^dx71f>38Qg4}?79I)UF5xi z^Cp2L>ad{I}0V3CVpqd?wVAvweG9x8003ZdJ-=Kn?|dL}eyo@jE`+Q)O$X>{m1 zk{E!LBo(x`RLLip04{)|4|kKlK@-+}l_c-qwQMjO;^dqm8NpvzR5e65p|o0OVq2C(3fS7k(Urnp)#?L9%|cv4F> zDusUFunWqclPz98SY|dwYbm7=`W!*;#a6Pgjh4vxnhB&O6k~ZXU5FIT_p-J3Us!5P z)~!?75NKb4b9+!rw=2dJpP4o5ezcC*ZgfCplJ+*AdDs24;!3AOtAov)E2gP{JEB?% z1nULsMZB&vh5bM)kZX^&&YylcFGg8*RIrGB$X?H)^^fhVHqThdBQ8@*ko zj63}0b=ZL(8wgs5Cr>E#uVQ1);u>z!;gwpc=4A^Q9S5}CcnRB2Jki$m@Sq(6?CIsw z*Y(T^$EBo6^d2c&uV6Q+ANYB52s_wF7vD9q7W)Y*`skb2z2Xr{T$>KQO#8I`c0gy# zsHy`O&>cJA{m)N_UdcxZ6fp{i0&rqh0MnhJh-rZ*gRcap>>5UkVeej?*g)@ru#}x- z%sO|E5x_%?8vunYd(aG3-Bh)NGuUK#F=!V(m&qfUhmJp#1y%q6sZ`PsQ|o@~YvwX! zZ*V`E!xYgVDXSt1SGIUjdGySNAtTn!c5hLA(xA-xmgEFBvLQ6S+|MNajwA zV>JxO05FC_K%f`Ja5=PO_kx3ou23`U$HGfO&%t`ecgPXdN}5m)(fIHf`fk{OLcR(! zm>)#Msa>!xq=YS8XL-5$PZMVUIELu(h2@2?9ANmX2P=Wvgr3vs>v(HTG2Gj%`}(oq zT=fVe80;^ziA4)ahS6HGy7Pms7cW-oX8ruY`+e)@96cWnRG?pQZzD`BcJob2s`c}K zgdIc3XoBF5%`RJQb3fru?5z|^9($_hpwhQ_3X%h7g_x{$KkErSI6FJFQ?cFL`Qo@; zx}>&cgL_za45~aN6w{BRq>`_<6DlD`Lv>qN5n!qRmivS#`aYCYDonPZL(YqRh`{H_eldc;y=*D*~7kz%H=;SK8dcuG6pY3>c2h1*C^LM=kz>3`SzGzox0d{fH`=BatrZ^Z~-*1Kx^Of&sYdc<&cqx zz*quKVqmagm>|^T81YT=1z+3mo9YF5XFD&Co;3i@{#$4W<`Tfw7`j3(M01Ioi2`Gr zKoJ>Y)FtnT6`OoP11S^Hn*rjGK9R!fj9wV`V%ZbiFAOvI zVF(hlkCY|=N&%2W2F$!*x#I<%^d$Sz%7Qby%EZ0A7Q%c38?AK|g9l@7uiW5pC+jGX z6i$f`HD9h0caxSko}s2Y==X%+TS2l?@)EijO#^}n43^i; zZXW8~TQ_uws~Y$0-U->AB#777(e7M3+dqr0>sM({5H~G)u=Geydb4i&uB!Ado%& zfJ|F`&+f=6SJd_EaqF|;Y-cA?O66QrG_ZLo)o&tr)j;BY22AgmU2kex?N$GAtGv#B z98SQ4SpsvIaCK5MlnHRyU=gnR1#>KLg58Gpthu@%C^UH0{%C3H*9Ca@gqSIW1%_C@ z&~=p79+E0zu69H#0EQ%rNp|>X@c;lI07*naRN5$s=gJbngae|Oc*miE%VRF-^V&c< zqZc+P5>1jA#&DrdKxAM`n%DH*ED~r+v|knRC@a$1$2YQ1%JHPJmnEw;JaNk! z09{o$93Kg-f(8S;)Zvb%%`+)h3IRQ{j_{sZ2&|dGq!i7x7~=~CfHb_Abm#ez^QA{v zk0mtY%KecWQD9y!fxwt=MDv{&V;1DpLN&8@`^dr-52AY*`l0A@mF8}Y@#)|U0vjUD zq?(15|KEJM5UHRQHrtgFN{1Fy>i}8y5JYI6qlKs(&vDt~Q|F`Qh>R5sQv+`q7Q+;u zH<@}bm*U{_QW}!0SUemAo|N5}r<~hsu#ERm_Dx10gvPi9Shriu`Qx^ixowXtUKnURhlNDK-TqJW( zM{z;i*^VCFjR(jNwb<8$w1tZjgmlNJLp0Qjnn#NZIygbpH`s0sPxd$N1~9B7uqRBe zF3V4_o}0Gaku?at-#?rTxvZTatSHO$(>{idguQj>JD=NL$*5kgxoNWu*j>x@qT64c z@P_LzdFW4}!08ZST8~s)myXiU zE1#`JbpD(YpB9?j5K$hf7)rqf?5LESjrbw4VuULQjC&@x>ZELrz_TC?OSJ6E!;8lt z9aHB3;bomKXnL?xc7Ei0#z?jdTc_X41dQcf3qqbU*GCnuknw4MG3MA~Q_pz^yIjhO z(HirajF%Z2AUQ)4jM>Bj^2SaiCOIcAy=O{jx{SB?qa!6l30`NZE;EA-Ye_`vO7qN1 zwoveP7@6tMH&rq^mTe}M44ChQ6Nt*@an;?|8Kc&>PZCMY#{2Q*a6#@d(Yz4`m%}$y z8S<|c(UsXO%iW{rm{hNo<^nx)ckL1=dS=FhaJj^-2+%Z0A0T)%Ot z;iga*2so8_<0>tS_Fb;44aKd>Yea&NhapOVEI14pG!pME9WwKs0zt%7HTPzZXAu$yTLD+ut6A)$AHbDL5?-3;I=aMvcZmklQ5u{tw={s7Z-4*$7Xs;pAG}0$g9)o6P(a>Xc^p#0=#p43 zWt&^1*|Fzot5_*npj;T729#ME=|Sf z3+STthqr7F=$Tn@2R(O65CxR>jxtvm4YP#(Xn-_Gh028gy1LBQYY<0qp`xf;0GS!; z5~=;%ty@=5N~KfXT!zo*CUqr6 zmpil}27iD5<@|;}0sIqg>UEC0_9ea1PGktst+_^iu6mQYt$*OdM;O?|85 z1gpd+ChQnsJ-uSFhO^L5%aUt5gnVY-iXXbR?@Rn^r$qb0*RTKksp3>OAZV99cAq4h z%TI=*u_AZd4cJDpf7`paG8!Vd9ZubCPh^`9(tiZpc)8eJ(Ucc|s(IOzgk!CM*b#LE z%RQUuTr03~;Y(Q4nk6V3 ze&-CV>^~Z7@Mr(iZ{JqnysivjJp-#**Hbvv)t{NfjPv=-;J0;M-+&YTx#E20_1kIy z{pv12yI{*6Hzx|(o|3Cin+i%}i{O9s*#dsvUP^KWMTwto9& zRvpgp{M-3VkTU>MgcU0rKLl`I*K}jBVub-#F!+p>dHn`}=-2`k}j zfHTsSNS}v-`iuJOxAoiOzy5Em8sHT~%zp`8gY?@LJ+E~MAlz#Z(HSe&Z&-;|VD&X%`=khXL>BaA0n&AP&z*VQj_&&V$X zFt6)+KA%^dPrs?(aOTyR^_#y!zr6Xd!S^RlIc*S62Ru8^`!l~4pZ@jye1?DCF#+%X ztDDc~SM3w9c;bov4$7Y%m<*q#AmSPSd4E3f{sf-R{~z$~FPZ-fPDS3UZBDB#hH~$nGo~P%jy!XX5vUoqG zpPxFneM-+k{^!}8#&*iLPY8q&j^;74Pk({8!>OSEpXKO( zhWqY+^nBuZf`1&I&*uq#pq!p3yrVslci8t6p82-Kuk{|!=M(wpifj0M!apeQ;Syj1 z-lrNN`ICQ!&p+Se!JJ-!<7dwf(ckFzJk+0qC#(FYx|+||=vfrw98=tBxwHD|jn82{ zfS))$Vg0|GU%B`yg$u7#f4=eknzn4?hugRD=$U=CXEcp2MHeDB=e5P%&sSeBp33q~ z(th#On+s0EH-GcpsoF|lv#9La3(+CWIug%;nN#TTwVfbg-;8*@@f}Fy8*jA)a^qZ4 z5T>D@N>)u)4Ub5H!lMd01Eg{~T*dKXB*f(IUwsRsXSxfzGdp^X!(;%~T9cf~`<8eq za?w{+?};mpFvXxCkmS*dPI^bT%3J{q1vbQ57tA>jOsz}Sl>l6CUx>U(a`*t}_B9g^ zWR_3{_i)@qGDvr3_O2|FpbWhA99QRLko5zxvN4FfCmt?r`K_X-(3^`xda=xd=#rUt=E7im^C0AM2Ez~}K(e}c zwGB;d*rj-~-kwB5U6s1{O9+#?{9dE1y?bN7m~SLN9;2VZonV(YLOjoYg+{u zFFBrm-%3q8y2>tW<25VxQ(XR40Mw1^`308~B_4HLT-(Z(sKt)B!TBC63o8N;{3-6v zi(;pNRc$!1BK}!4H{YT#IkBT%iWk?}{+OI01Z#`t$gP9GUUbfMFd=bcFCs<*(^j{8 za(NG;F{#ToZJSEaCgP@JOXEVLLF)@Hl1$d-JRH#)VI)gR2m#woP2cJZii4V}708HR zobal@@IdJ)=t;&*=hS7sf0VRt?reWRPGkF#LX%~IPOy-j+>x_)pQM8ewZx$WK{sfQ z>|R;-$xHXC%Ps~ywB2FEPsx3md@hLz0tYVau!{0Jfg?>_s^*xt; zt15pqm1R>i$59rMf*z=J)hN+*iDprJUXhxMEwTx7J_k9$EL$YMLC_g$7VoZ>bqyPX4Q_4UyfYn4?M5dl#Pw0Ku*i!I2FbYPvcrsIX|PQIFkd!~ z3su~OUq6|6UZ#MK#0xVP9}*tF85UPEn%tH4b9v#^aklHEdxT9Ikk-tct`-gTFQdEQ zr58GBfb%NCUkP=?ta#DI^qg+PZhD6OrO_}kR)R&jo` zC#tjd>e=5}+cDj>ZKC$(9K+V5zG8!tYK2TI9}u2bs!T8Bu_!xYHIxH%Xl0 z6&4nIaLu_w$Wflj#`v&|eVn4XV_Jx$?fh%COX5@OP4{~JT)&u{Lsv4_+sQ6;{-M+8 zZK%68aqOH^qKuwp+GX;H z;{vqj?aI7#Np2mNf~Th$SlC3bLN3re=bAu?Y`vKvH)>$Rtid$TGcLcAm-jAgz-4CS z0R)^jw?M)e_Ry^eGk0YI6#%xL z?QG?v@p`VB22j-%@BZo71UOB_$|PN=?>w zXq4rldd<^hO^PzC(G9CXo|6`Un{3UF0uavHNrWfEO;&URAVvM65NRD+ESyAr7i}@H zyWq_3fz)aDk=a}1e!hYs4pu^rF1D(n=?3XMFUaOs@3`sn!2Zx7cenluL+54TXC3>4MJY93*ksc-VrFknqWkb-Kv_jq*n)c+K-mh&7Aw=-aPjJ^x>>|Ofkk{r1Gpp8P4 zC5F2*FjFdaG^vuEsO;>J%?Ub6`ttW1Gw@+dN_>}qoN1mDBwao}h!kBUGnse+DT$nd zU}N?%K0YzM7{2BDj`A}ZT29k*oBu*|0YA!PCtk7@Hk+cCvwn0__NU>P_3r=ZVn}WV zZ$kgxERYusxM39Jv4uT4nTbrLTUb$8WHs}>n2vF^8wN|n<9vO9JAPqq1XtR7Y*R0352M)fzLz`e zgd*mo!hsQo-32mJnU7P~chYDLx7^v@2piZ!+6|Li5qtwL#mdcZ%BgkvOvE6Ydg@eh zgcu&c0l@nS^gQ({R8`^SP@3gW5YPJ{)MnG4ez2u$ALl*vy#La1KY^It=ih4sKrg1l zC8nKx*}4$nP$}C6gW+9W{;w6^fGhpazs{G%{MQHnCxZy<$_uBat93n}!DobSBgo%~ zW?p?)-|2k*?fh>Sl5{?;=S?>t0V{u7*DlsMBYk0&I1}MFC`G@`=kxiD^BP*6=zKn( zSFGpM%ZS)hX#BrJuai>r>tBelp8a>uXF8wBx6z%~b%|%RuD=q|3|@J~8rt0$p>=Q# zy;b3#b;XG!LH!nbC;^z&Hv*bMdA=sxaV{Gs@#}AY!K^^P!kmCN;0*aIRs!D6=ks}u z7c5`AGf-W`jGoT`!j-@&^l<_!z|8*G&G~#<@rHFxzGy3OT0;k#0e=1U*Xv)e!1>$C zysir~%!>1QKh>e|9|U>)A{@xefxj^ z2^0ELi?cZc|AjN~ZCwpce^KYR6)VHESF=p*_l`BS3elzR&+q&ZW_wVng3D4Bz(l$=T zmYL@hr{~kRb3H?sQf?u7J-dX?n9YyNmw4zg^W8J=rwqOGzMc+G;5p&sTU=afbxCjX zcf?+w@L%t_VagRPKBv0N@9FS_Elw&lpiR%?{dl26YqTghom%uP>fWQcLhzlCp%o16 zLw!2o`Fsc7@$Ub5;w|)_VRNkU*2S(e-$XZp2+y|TFWl?5JP^__X^-n2{%%;{sE%`OIC9<#-R*{P}#oKc9F$ z-7^gQ)RX#*x2U)dgZ9^F9&c`Qor|M<$Mb#DC>c8VEO0u#H~oCw%@#zQ?OkcVU;j*> z-r|2d-+LST*!-}60`Us?t%M8v>~)pB`=R}88pKY%lQW%`tq*>?NZIsy9(dk5ATT{R z@8w25V+{BNPN&Ti(QTP~zQCj|4X3(m(-tqY_DuKD^K<;G_wjN5WJ~dTAN`(y(>tDZ z=VosI6YXoH1C*PGwrDo3+7i+ar@D8u9r#R8biK&=!z>TJ10bK;O;SaoPFHNJp-6Jc zOiHopXI}eH9u4&MHfM9i7zc^O%nZVvgM_1yVAh0_L3ErgciCjxZNq?45K%})m_xn^T~yMz_)roo%tdCn={9vSgA`PSs9Bve{nED4}Iv?Z-2H(B5#&# z7L8GeOsBS?=G%qTHD15a5sQ@TXJ&-Ja|SciTr|!iw=?p#Hc*EN*0<^7fBylRiHOO_ zWIk8ee0yNeyx`+QDpeFh(q`xRc4Yu}ovCH!N`{_Yo);-;d?P4#1XGgqn37)(PV0z~ zf{8kol;YT_*ah?Al|+E@8jWP;?YB+RL>aUO6M+mCt&LJMDP=SR%XfVL^ZTE_OyYnD z+J5rq2>{zY`a$@1FV`M`>qHfHYj=h1Y@LYPNp)*Et0MVfBOb7Ur%dXOPYNuXmPt{^ zT8NsQb8f>TO*_n#s9mw_l%1_R$6GbI@qp=gUQnF|f7jvoC5DRXc+yufN?X4)lZ^Tl00%-_)LVSd1;_UOu~a z*v3{J%ScvXUzpkrN#B?3@uzz*hc%m@E34%zBkCrCLqUV$73VJowT``no)ZJ=N>YAZ z9!rd;$iUY-E6}WnIklh_xz&sq55iiLlITRMqxilzjtko3@5e_cdd zGtV&~Bx5+lw!I>l+5lJ{8XSELh&BS~e2B7%V&)>0aHCQ!V`EyvUe|xm%T2mH7oKmjqo*QT^8`Yn8qheN~M4~ zC8WQ^!BWkLG0uZq%`b+52bzGKRV6KG;5b#EPfM`*63}zLp|pF<+FNIAls2tvM<)cl zN=MO){&=X{CCOgc^iPl^BmQXrsftqahR@Q!CdJ0&$=^gKZy zJrB1Z6_o8{lNkY=8t3y{Az+O zPOtS-wqk?`MCbfIxpZ`KTlR?K`P7vwiB@zg!bd+q$Kxe?jDKE)qL z&!V5Ie&8t=$A@iip|yvhPox;~k7Y5?9_o6o)bo#5rDoO(^S#zP7EM(pIi(+=$0%iS zv#Grux`3(dAlw9@6b=(0={c>48qGF}1FU(`MAx#{%9F+tWRfg7dI#|0aZHRTG>s56 zFn?^AbV@2@HfD$>Yuh~XPGkT8rRXvT-q^qpdkHH81YZ4?UjUkxM@QgMcaWxXkA%>ZG zCUv1ZGc*W)nt#4e@0+fs!$R3$jGw1Z*PrU9!*oms+0|hbb^uu2#(Y3*dFSFUBW`Sv z;%#k2=He5RaW!@1gpZ1wcU{iNb=r5Pim7%jE7oO!>P|UP6daCDw03t2>=|;1hJH?m z*V7*A{qV=55dW!yX;?V{mrFeAFkA z?w%EQtLzbXPya-;@S|Y5NHPPYNCnGS@08!P=+XYbkUmnJHib4ZEW=O7-8VrU9oiky<`q+uqcM7VBhBS4T$ z1{%J~KF^rFiylf-IsYH`k3ZDy_jK243%i^hX@GgYkWyZ4V(^-Rjy{Op5ArdbidaLC zX3<~|BYDqFET zWf%1LUD>7j^Hq>~q3b*=#hL;BQ~vpG-|JV?z)z|(H`{3c@N%vg6mZ>$X#VV^Fd%=1 zW?Nm9KPvk+fp0qqX4;+3d+et>&H!x_$ZCe~#oDKKRA>lw_hOl|Q*JndFJmty%2uPQ z2TGubEAO=>wtjs_4yLIwO#L%?-R5M6z_h|xm2aIDt>51Z*fUKoJrU98WSq+R^7P%f zSb=0<<8njflb&>WC;7K0zH8h?wl z@Ltgf8$@#AtCkF0j*0*PAOJ~3K~y@6{`d;N%;3s2gdvkv35amLdTRd_a?Wla%uK{X zuerdkcXh^v)tXgY1P{2E*Qo!=-IW%s+^lcvEB~nFjpUT z4@SfO1R=foNLwnfMb3LL>fT^6>s~oTyJme*owCj}eqSAtKL5A=`BA?5z-wUhe*ENcZAymTo2VC}b<(V& ziLxR^89KL0T*-mI^6-J97Z{b(@{3Y?iy8XRDR}Fegth`G;TDB)hr!Li*L=UTcajcC zFC=><=cK5XMYU%E#kfETF*k<%h9uQshZIRDkZw~IYhf+5U@hz! zfcCJs4O}TZ_WX$`1%Q{Ogm$#i4zur{TekQwU26si_d65u0s|9oFc07rrTmu?`El0m zQgQeL@ov15Sx}N&=(vNS;|0FlZnrO&#k1)|VbMe#M8^gdmrS$2V&(;SE;T!h(!M#Y z24^p)*w#c;OT|l(s*UHz)M9h3Gk$ z_9g*C^Bmg@6V1*(`rFH({eHti%3vMIrd~u=5L}kMlBgm|HJ}zYGl*z5tQpIn-{0Qf znhd;d#cVSn2~i`0z4!jcBku)aIrWLt&me_qpZ`8SSBdegun(U{F<>vC^R&Y!4?`oT z9MW)z0CH`*#=&BM3(b{NKP^nS!g#wq)$k2laGwcM+u@ZK7*Xtfg07sbZ3Epm!!pTh zgsq|+EFgr9Q8sypJppwQ#`qepROvV(1_62;E-+bFV`w{g7(ZJUK;=1Y0ZdcdYwJ4y zWqZT9Z8mUtb(BBAXAVxyzIb-017O$foaATL*7kFfw*iv=yz%qD@{jx3@7h!}IwC!? zKP2jKk&teNTllXN(Z$0%s5#o-)}&g+GR-+y4F*t%t{0wNBM|qgN_s^+XG#qktjgdx zFAPc19$b^y#C1@0y*;m7_HoT}#F)mvhACgpM8E$|1tl1vl84kYNoKQ{qF*pH3&u#c z0(Vo4Vqs>PIB}&l1(1UspGLD!QGgGCn0i>jLX7AJ0^p0kMxX6kNI-Fez_Tj z)?6>+N)1NBtg$E6yO__4=9!lf`OKp+TkyOT&8j(|*O~H>n+Q`2(A?ixvZr3|gsUVn zWp+0&nrM_GM(vJs!+!q4DsXRLLoQNFA*s^ zvYWJuE~*8Tqg7%xg&9Oa$nhQK&+q47-hRo>6i3O2G|j)5M(psf_SHON$J32CI#s!b zHcLg-ss71}e)Xx#`iar(D1MAQng-U&Zs&?kJ2UdMrva_cC=K zg?rlqYyJPky-SbeNV+9s*LmpA4VhX*s=4SlR@Vl zSf{JO=m=aUbX{>#voCh*B9xqecJl2m*2GP@h`TG(Nn-YO2@2MHCfXE6cU5fdaX6KP$ z&nMXq$sQVxOeRQ>W@v&JK|5j^+WBfk$V)Lsn);qKyt!LEL>?H#wG{?V&LZe26acM9 zxx}Cw%MuLO>=i7($BQoG;V%(M2@ToP$4}3aXgmi$wNyB4LHQ8cH(Ro>9wY8z7D@)x z1PN)+_L_Rn1OtFNI%H{Ys5F^G*YS6rF4licGJrmG7PhV@5hhyTk431>l;sHT|O6FWVp6$D8NBD1&dQOBMz;`|pq{|>*) z?CaqXX613_`Q3TSIqPmSvdi&o(+wtdIVd>9ltmA2Gp2L8{Y5-Rr95TdNK?_wc6-os zEz)@vt;}BAkl>~DpoF%*PTh5w_V_@Q9Mbyd=K5ECa>Z014ik=kp0c*NZ&Y71zgk4G z+$NG zuN{BY(PL=j1^&gV?t&5xo)tl$k>y2a-1uVXUqNXq_+V%o-tA#@#L(KVyvHg#MV8DR z9b}{wr91kVh`^WNrN;~#SguoDtR;aNOpF2O$!;}>H;5Afhf`pX(!-Fn7y&YIsdh~v zsi4($+S1O$PQu#H#hHSZYt6-41HB~Q8X5P=%uFZM(@|sO!Q$ycTAR*<1~>WHSZm-a zde(LHy!^h^MQf*9kmMxn$)rdZm8zOJQ%>8Aaq2ZQE|x*9K-%b&93Zp3oMrE`=(+a} zBwWt*ZuD2q9cQ91ck&4)EUGiPSb&ko=Vx`I;S6^A9Io;H;nWrj8bq#J+LU+pv79nP z_#Q3G&@2Rkn?zddZOdMjC!|x;N5%l6UV~X)ew}`Oz{7%($)9EGabWZ66SDO|dAX3Y zj495E!PbM8woCO46}MY!S=Hv6%wp(kzh(65-a#Uv0>5rp>m{q>?YuVJwL5W%b$Y!FCJCRs9A#eCto*2{1==+a+4=)b@DaWh|#8u|_koyW3m` z=n4vZA6n>u37wrhSzg=TIzb;YCD(Jl33O_dVC)DBT}0HSN87v`N&*Kuiz0?Ly8&xyGevK&_# zXuk?PrpXI{_1mD#6U~q9#4;}Et^{}I7`ng=ynxgINIjqAsn>(|$7LXMj}D_f<&Jk7 z#=Hy)u`D`ZX#2Z_^uOB73re9zPhggiu!3e@fH|v`rk-ut8IL0Ymg;kjsCq>wiuGQ^ zJdBK9^}S1J)(l`IPdkskbT4qp6cw}yX=-&LWQ`-jOZmZR=ir^7exJ8Zkwi>%<#r*y z2SH)98Wb)I+=f9O`~LLOAK5u|ybc;;DJF^8IW|kAzAO-;ra?%!=hStD%bpSuHv@zL ztVVz&(|8_8DW}mVI~hPi6X&y!h@J@mUj~-613h!LP2#xv;R*(bWR|s_cTJtmz;ty- zGOtjL3K9SB#J!FxVwnC}(Mh@Ps`af5qg>jP+OTlBWRv{D&XSyx?DH_cR6PKkFG=k$ zMdCg&CIrxvV&-e78(cSCOAAVJvK1Zk&GB(+H&wq~jqEFN-aOx05NuI{be`P;U(bRTrETF($D0W&Z(j1I@swp${Odp!?EWjo=#-wk;jj6 zlD3*&k|=6sKY59P+Vj2}WV+RpSFX&QPo3wy0=KgBwNhlezBTQ?pDT@ci?VI+oqqlX zO!mFyp7Y%gqVIJ(S2^_ZUGKu-DZpd0*vdXlK@#=g(fR(yw<(N{YjS2Hf>J!3S4Zxg zkfxLBKRu6^S7(IhqzeidvfR9|Tpl%}gc{CDbgoFzXNG8WhW*20^}xe39j&pl3ptU@ zBQ4@TtaY4Arm#hOz96$d9Z!HnbXo?H8ZHbC*-NrCzSiDUS%aZ@;52g%RGFZ-QblEh zFgDm-4PYFjGP^WowrLp-LrV}O`RKj@BfE9@%vGAl*Utdd$Bzy)N*hbb03;E5%dqo^ z5n$Pq9t*OQ%QJC(MJ9N8#VwALO;Oe(H1qlM>*)nVDp;tvr2tO+H#i6?!u-VVORqW9 z=@f+*c(jOJq2m!m7={J(^l5~{2nwkrg$YSQKgaw?O7eT0%9%r+BIjn3E`CVa587Hv z&7A2*3cy|W&fyeQv)3b$4Zqa7G+yTcq$t)P_Q@=R2?L-q9hWO=a3Zjt)X3+*;4i=H zewPnn9!a$Uk92cdaNgEP--?^T!W(a%)>jv2%IJ7Z5tm&F9BfnHc2e{f!?Hsf4(p_a7n{`T?x6VCrAK5uTXL!>xr**_v*Gb$@ zKPORwQx55tM>Qpi?`cl1@H#%|+8lCCxM_0R#TijMXT}^sL%sA_Y3CL7EvEX6w4LuO zbKCHNi1%PuuLka-N~5kd?&bxrJ>P&u%L2Y{aeLc?RkvJx>_Ww6wLsU_y6f_A=k=hI zzZ!bJ7oW~MKJ#6Ex^Ftp^~JCzg8`{?Z6JBA$?OnWHs?0L4D@T&f(&Z}z?&I_k@D(~ zJ@dc=lgla_F^r%il)?})rnO6~pj=zYC3Z|;JQeh93Y28_9>?FAFT>cAR3r!1nm|m{ zv(`9#?5T&CMQ~^u;}27>l`f|$mzkt=TYln2=#>v{Ycui zxYi%oBY4TFWwcDE$i(@L%*-^5acXV%OlLysW|OQhFeFh=r;*PB*N5q0E{&X~V!#W2 z4{e)MnAPH+Zdq?Lp++oc)Y8oddY13JD7p%Hd-Ha%LVNou-=(mutI;xTw$t~MMD6WQ z-?HbPkT8JR#HOoR0=6qbamDoG-RhNF8PIsA!`15OT-FX&qP;Wz`Nn>0C^q@Zly&e$ zNKBhefffauZ4AV0i;MNWLO8lRAW$20Fw;AL)Scx{G^3kK@stoc-!^Pc3{cdB@PPgthlhw zL+AM(C+LBRgWbagIFce}0$a5(Q;4l7n6o9f?J~NTxH*;&$|M{`0`zQ|_{*2iKM`;` zy&R9n3y*N2iUV_joG4Y>k|e19bbJmXZ3)&CA*fr>9{6m-X)I7>1`iBQoVGb5Xvr52 zI!ZO6_;mDlOR`-kvV%~I`9i=!&Pc>3V5l_e99k0Ds;|;%kB2j)>`%&3&(EjR^D_W; zqIm{EqStyXCmV_=t!s475mNSup?kVcs4oy+u1SaHQDcmilwM+#B=Yr$Fk1WE5V%}x zXMB>obrk5C04U|`ob6WPC6hdkr4t^P1h!|C$9$QDgV_v$5sXAQTz@c>x8kOha)yV| zvFF&^bQs|1XRqES1XpY-${^DPoK$R2Off~gaIJAmCk%~ILrSkP@%5%w)vW>T{NlSu8#DsvSnbxY{HV`!bL>|hun7jfiZ>W@ueV}1ZR|D`#&p}!<2x|){QZXesTygv2bSLiO;gbgGVS%0gVheZ zUB*%y!^vr*(;Up|dhnTx2u`kvB|#;qG@r3YOruxPNc)#Lp-qA4CD$&&uiwc(0N1gHQL(&N= zMZGPo!zz91#(q6$^@-T>fGS1|gI^g(_@#LY7_l1R;(pX(`zeFg2iJ}CkfrQDeo{<4 zyk2-1G-DjcaU9V9dkJ|NFFag$T1z-vQ0lni<|E8xJ1zSeOUwzf z))kcGJ5uW35^csUhRITW)x z8JNY;IAzV4;C;MGSaSHj^XnTJlri(oo_u)=e6hRW;|d1t2*D^RKnbLPc%^7WQ9V8;pM6W6=j;+%OM zVfue(7`p4a$%e|8Dvk`FcQx2i1s~~))AxY5?fPx`Jz-*-PO!VJ$u)|TUz5LQYZu?e zLT=~G;lDb1-Z+d(`_-Q~-McC07OB5dVfH*%F?9LUaFst^cvo$}>mm{&^ARS>WtXYs zLi^YSg0k@CXvcGF0v2~ZTyO%B;y^kwr~a}ITO@QghYZE6PSNf)m~Ti(ZR@O#&qwv5 zcsLKQuRM&JgKyq=emxUmc)e)nECHX4M<9}k@PjogI!fwo36>s`x-fDn$_`H6@HU?<4K7D|zc?*^?p=@p;I4xa;>w`k3B2d~Ywq3o4yBmLa%4tjMPpRcJ(dACfnV(QtOWREglXD5uy5d^ zyLy{#@tKpS+Dn7yDT(#jaaGdSWzhht6}$b61Na-VE4t$s}Fd zg?Y|Y9=cCL@ff-a&e%;I zzQU1@*U`jSbA{*R#QLB_&+uwv9>9ZzZK2XqYe+~Q2D`@$k|W_w6V} z9)ID!sK93%i%8Zkz2K)8>p4Wd?R<>FwNSe#O7EMIR8;zj2Q$tf$X=Zy&CQ&juQg$g zu$QuFn6)NMD_M1%>LPWskv4hJ;p`xWadYWl@-l{Q5SBVzIDK;2gBY6V#5e=SHTyJg z5zWQtIMCqZ*-))Q-^&D2%^@)XZ3BPOSqA#>{|@x`6@OvEgkKhND_>82}I)Dt%ji=pTBb%6FB zHniJHrc4D)yHHKlrKQWJxT)}It$rY@HcmxU(-v;4ooJimP(Klg|$yEo+{nS-W;0VqVJe+FhNeUF$`aw9*Vf zv#vwj8bYBZ;Hgv8(a2dZ3>I_*D8TS}I6f14h0%F;$W-S%yh1&b4YekU248*e;`hMP z*QiO5w!y+$S7D9TBY^(-`0{dMI$yrL@_4~uHOavUgmCI{KIg|QEBW1ltPA3Ca+pD9 znhg|bHB$Cv#&VRLvXi2u>;6(kFVTp;gi%m%nJC$VTw!x%S zuV@^WfH3&ev5ff5YJ4xrR_(>qk_UpSKw!?zzSA;9I%2Wl5q63++dNL+`Zzz#y!@)Y zn-Vh$e`c}--FY8IES>yBzpv+`hc0btLjB27PN}x}z)@T~ZGM^BMRH z@H_j&-$6c<+%w98xBZ#J8FQRbY%}g*L6*Y4DtvDju*c@x*%6}_o9HlK=S-V-MS$-+ z{b?VAGtD)=xqtyxD~f2=kznXGoSg#X0y-pkv;=VNmVTok-aD)+l{d>I@1A>fdl<5* zSiPvF{mdn{4zIUu0gDn0-7bJgr6=D`tqO& zS4HAn2iES*9rclIZ8A7_n^TJJ&W=WzIYj=~@TW&Xbr|24NBx~34a?C&D)z7leIvG-W)fdM?f9FNax#Fz7zSB&EVJu{q9#z+yb zFE_)fv9GK5^77J=Q=0=F^b_v8lIWx|Ae$BHaes8oBA3`C$}&e${s&Kz=Tl+5*f~+yq1R+PUOYxr z>Xhr24DHafnfiJ56yR> z=l3tAI)cx}L~kXOcdH0GEi2oZWIJX1?>2-JUeYq%M&e7PkYnf+tW5d48Q<8}j@BPx z)&}$5A+kbzzGIfP%7kz3ciKa|ZZzo}fpC|Qr6t@8P&?x1F5SR1r&zQSk1|)-&Gu$` z4Qent;bEs`x3IW&#gu*aM0hI5-bT+=f0v>e+Ya~MrE{+6F8gMRyo*hihr0@$UBLOg zkGWsrs(1JP-}tAy`yp9r@oo>OUCgZ7xUjN+ZEdmrwlY^LH`o9-Wv3jh&72m~u35)5 z^y&uensdf85v>SBJUksd-zB1*u_Uv=uKQkva zmOXv^^a2d8ub-LE){@WL$pwy>NF9gs1!XWs0>M1=unX(GJW?--D(-8{+7WVzof#>p zW6z`Z%4Q4Myd+CM&nyFV(DSfW_ny087-s~f7>JWEtdGBhvi6euzG}M6g0HF$b9_2XT z*VmCqDph{aDMO-k+jjGq{aJ&~;j4a{)w4?(^l#g!!rWLTEIb7C9FkUun0a7rg&ZpF zdCoM309L>-;{h=X3^B7<*^p|MrH*V|Izwry|pS zuvIfwZ&!p^^HkFEx0TJIA-a3K_G)+SUVzxTnaaG07+0|W_x{;qcF}HP_-}R#Y4=`m zVk`gvAOJ~3K~x{)a+Z2W#L}()*5$vZpnGnYs=Hic-`v`hConZ*uwi@bpjV_Yom#;U zxg40foCA|Lr6J?xGG5f_bo_GRP)6ts+_W9Ena5Y^pM6mq>G2}_9z>D@d&Yk3j`dSv zjP85&^6y{9;XI75%!5PE18bdAdMCxhfRU-EO~B-I*s>>5r(P)w7>CqvgEgFcG{gJg zK^Khy)AB+Zb-q^uq$5qwY)77YOO ze3VLQSHq@#;9zZf6!h9jIVl6AS+nzJG*LwlWpP7=T~!YlDZ41mj%V7zwr|dzKDSZT?K0iYIlubbHPA+b(RRZz1k^ zjiuWjFK=0RWD3he5-ct;yRVbjO_utEnBj# zhfW==yLFnf8iliyFupZn+et^))xh~wAIqcKb%}=CBow6_{-@IFd2_l@kg`*nbz^5# zsh(vn7D(z>XI@^NlsU<3IuQ8&5KVpF8TJ1^TzJFYCcwatF`&$r_wS_ z#xXCUb9iUCL_V35)mQsh3{CUc#?f8Ta3f>1kwg~k+9?f369t{gXKCR? zLKIPsXITLi%}kbofK=MCsiP`_4GVd92n2LzMx0EB-1d6=icLM_q9^K-GPk^U-@Ao^ z0M$|qU0>pmHeE&fTD*8>mJiJ^begmm6L5GOtg0tdkC4ue(21u<2Al`EomHGKKE#@~ zCN`QuedOt}2+&dF=3|Viw_qUr!S*QFv%ik~wo4keihvx~ySfCW0hzjG7dMp*aG5F- zp=affQS zm_K(fo0ZV70iJFc`_)=yzHyEBAIV~;73;ZaorQIZofRlB-G>RnnHK7e6eY(sh$%n1 zd21GQTP3}A{U@I%+HGFz6NCl=Uyu$@^)-z zS1us!0sLzlY*Bp{>^PF{ofm7BJn!y1_AT$7wmiqVdZsCWX3o>da#qU?XBXz7C|3f4 z{BiK66bs5QAfe#BKx;fVc@lcOjHj2E<4-(bM1(rZC+;c2FoGcEM;)zvZRtNrX$$R` zd7zl22mr_D>}@M#-UEC`|N2QpNH31DgY%GrVfE-v+*5_*VoUQpCyrY zVo~jq3kT-xESVII!>G@kc!LG+k|JWU)?@_q63jekL_=W0Fj(b`)?==&NS4s0vs2*Y zs_`&Dsb2MV^3y9~CTnEE3v4Q7Qjy2LTx`i}7k{PIjW%?~c07w;Daq=i#3dqW2T3Xk zrzU2u(ek9z4Ya?i4I?8J$I@0k329M_?mr-Y%r4n@q%Wzq_J$1PD0HC$wqd{0kC1pzp z(uPu&N~kceW+oIfa`Num#7rO!eZ@mDf=o;3j4kwWA53aj)>HGXO$+dR&q%y9yjv|V z>vlxewL1pgjnkc1QCp^ESa@9}a=}~hs>{gC8MPIIO)OPC>$KT#R94>CD8B6%M%~jU z1Kq7c&|5nynrhm-SX~tZOq~l?sqSLJ?EYK3*zJnMV3&_$O^FmJ?clbz^HR*yE|k2s z*_+OE_c`qCiQ9OeTVJr$zA5lXv0ZKrAGzz~QLyty*!t8Sig#^sVCjL^-Py7$$CbE< z6zYn3QE}d`ikr51_vEl|;r?a;&v-!wjTVgNvAt0_Q1KH0ZmKoH7#kvpE#9ys^z%`j zKC1JV0i%vMj3Nf$VT3x%{-nntfP3;389OHl?b1A;o?ni~o?c&n0uSm49vymS&G9Q1 z)tsJr9C#c^D);r&iH>9rr8QWGm1rJt=2sA@UV)?wFLW>+fYzRiCq@0K=kusFFZe^1 z;yB-$4C{H9Sfwy$)`LXgVW`Su1DNcOM}YL;v1jV7F$@=*b)v|d;6dl=WY;fLuOnlh z!sj)SyZuY1tteFwCe2PS!XSUK>=AjpG)bV|)?;dWc8R#YHfQ5<*VaCH7<8iMj~~q^ zFaAgg)(o8b+;Ap{F~*e>?Y+SVujrYbg*hn&**h_bX7W;^ycq*q&q|%p6Gq;;o2*nq z9sB2JfHaS}M%)DeiT4KO@;2YLj1|>QEaB>QWxMdOA~S{+tI})((4)m_H`@%v;^3 zdk1z7@OC2rGQAdaiXMudvSx?i%JDJ<^akBLt#Z$62iC6hplu5IHfD(^Ma;!QQCqvS z+CU^1**z7ZR;{ORT&&&Mkl(a^F-IW1eGl$Y0LM+;d}Q6c`?vk(>QA}0&I)fnj=B~; z4QQpDuieJ&ZPpj&m4d%{byIcpj8(7r5df`~LLt|B&e=u-50cv>tOj4D{?7%dkbcusgb87POAv}OFDhvZNYj36J2w{6Rub2Mi zS-mK}3_Oegv}OWH8{3gw4(F1qts?{h#OKj6tEo;Pp19UnTA*3m-s3YJ6-I#0fOM`U z>B_R&!muh{wv`T(EgE+-~dN}*ST!H3*z zz~=mp4x%OrXwBujl0ZI8+%}yi*;7w8sFH}5lRAngKKdC8dkjqph6WyxF8XI4YF%kW z&}HI;`e+@H?;OF=w2mmdnsB%pu)W8^X(4wGcF{{oKxO#r)@#h~#n5eeep!}5aVpcw zcswV^nI7>RJptE-@Gi09dJh*E9RRbHgR&*3RpijF1=Y;E@o>9npOP@UMdwYoBW60( z(DT9;w+((Yf&RrjO`H9BuF=qo!qa=_W0e*EseX61+xwWd`gXe_fLVI}6$$fgm*pIN z6PNrB^bDYF+j&mmbe)o2l+(?#zx4Ls)uO;<*v+zimg`r09v$7v!P!UBJZ~DjSH75m z)%(I{_FcQ3lap@WEF%6K9zT2n8VCV44j~xNwhccU{0smv$)E6J|EZG~O$HbYU|@{* zdk|HsssSJ%APj^65kW8jK_8x=p#=<#7Dfmd0{}++0vJ3PBOrLVJp4`bD1XofFxu_Z z9ScK<eFo5yB$(w!|-+dYRp?WCIJ`-f-n$<2Q%u19_hmm`0yy6 zh#raXD4w2(gb{!-5P*O%!We_50UGo6)fhk+dg|5j4@w=4c`y*LF?Dz|5Jqc&h1)Ab z5DD?vKM{SPAAX?6-WY9+G0ZT=g!VE51`q(VetR?e!QhPz8yI1)oP?yFloI#>_}Li2 z zG$bA&NVtBWlODE)p6yAI1dM*;hX!E78pgmFFaB@r27GI|l1Br8`X`~Dz=n$=IT-Mp zw|NeI{Ym`r0kAibfiT7-lSA9g#x{%rAc#yu_7Xq{01yV61l|n4adH;wK^*OW?G{9Kbi+ZEdf0BD=|yW4CRA3_E9ak#cP9Ng)x?YG%68Xm$EF8gKq z&ul2X=6?{|JN`DigSpzvv3BBDTwCCZ&hIh)X>d*deT`pPp6?a7UU9vmxdIKYz~SoJ zrYTy+zME|209>2JW)Hr1_y%sS0E9UEzU9`LtU+s-#-*qO1R{)s(Wt+B-&^FbV!f;Tf4GAWIM}vmla}LwR?=-r$GyNQ-A?vv`s< z_|1Mgv`NF?F>_d4_2$Eih~T(^u~_7d-+l(({NSjK9n9ijYDc)QD~xjdRgedd>kk+K z<4~y(!hO~VBB{)SFwDO|8^8!a2xAP4Mk8SH0T1KD-{A4_hX+9pTno^Xd{n2?%isR+ zd&U3s$Dd#SFZE=e2t448*`j9#U|`q*8!-C6`ya+X4sZW-5sy!T7OUAVNIBpr<8hY( zAcRtX`|;_+4``nFZ5YpNzG{Ew!lS2Tk|D_O@b>csZ(0bz2(W~V%o{^^VEsS{DAfIC3@rS%kWm}g5K=Y-f&A=DSiERl zYmqSq#;`wM7zlcRcytZ_bun8j&@&OlBLqP-kYq8v(Mc-;)cC8?_>0JJ^CB?yPf{sk z4EW7mVVQi=Jir|wyX#9&!mb7g0Rfl?;V?93hZ!$Efgb%GA{-btfO#_v0TWI}fItFZ zyaC2yar;*~S+tOo1U(s}l~VNK5k%0x7=CaKX$-(%W6|;(vk<>PJ_!NyrVZY}eoEX( zfIv?W24CH^^Lpk-B4upDnXdpeqcILnHwJhx$$jCdWbNk`E9PX;EM2s|QE4}Tu~#X6K2x@?A~f_V;D02eH# zCkHgwq)d~L4R>FOX-F&zxe(EwKmps$m? zFMR0X;k4tuW2>SwN%1Dcc9 z@I3)^Tb}VDwq%=56|a7td5ct?i|J+SPPIMMrmlwtw!Yp4UHx6!)*lXC>!t+u2Dg8% z2Xu$Zob&raLus6-GmP)+Qhz{5D6wdTG*X1a4)kwpN2RLA4# zNQ2j}k_`3|l-f}^#RSRB=(kV!e_0hm*neqe?vF~3{%AC`9z&En0qW(%srp7IJ|Q(i7t1#6}G;1zQ^=L%KL|Nq1TcWRX*{eaAv#1T9fQ4B#I}tIj%mE z^9*+)u)7&0AnBx;_}8;lLw0jJb#p=-L1_@OOg z@$w^|F?nJ1hPZV3R=S$MD%Wnm&-lLDsyE_bDn+B28~B8|n}Z@^m*_kx?40rf*+LSq zyaHLNZM)d0vs`JBxxAFU>pNMZyqib7p*2YDpIdyFE^*sMdcO72o+`oi)+gI{_UGIL zq+L0)l~T>$F4x5>cIIhc;!pL(`wp(5n2HQ9-%MkQbA$ouD*t%Ex}ydmHzixe(7IN( zcPx>_Ta-;J|zYoOmymxr`Ml8 zTV#`*yVpIFqNPb&JQ@O#zFf2T6>2$ zKM%?dvsZnf^sE~jU-IThUK;8`Ppsm2&?6=0&zz$Bany=&{CFG(Cnqmpole^a+VbE_ z39KyoSyGn9@gqK`Q0}WubvUfIe#5mH0_O=WI!vTM6pfG5)R(l{j{4A?S=&TF&kmHP z&6ej(f{#)u9n|h)>QNo1UKF>>mB5!Est!Q)q`*9UVfB$n5k`BbB7>?<`>%QU!bFwQ zPfonsrJX#1NRjG!7(=EvbP`}BWdfFoB`_u!n&J$+G@?!`P-%G`-Iv{?M;*b${C{Km zv-jx?No9*sY3kNf@iOSWg)p)>iSIaA@5$GgcZ`kc#yoPG_mAvT5}cCO|Fo4hDLzvi z=RDN`LNE`odehYdvzC0*!dY<6K2ixR>>^Uk$|w_IbP$YI>(G9)u!?W$7t@ViQ-W51 zj(I5gzA%yR^s{au;r+_jkX)MWw*idmH(oWPuH6q-Z{yso4ib5ZB8nu;ievJABpqTQ z(*%#WmA1U>H!P?3N0!_JP|Gd0D?q<}@8j{_GTcR~PVqQu@7nBr1td*ItP+7`sMF$T z=DP&G84pGaifrlav1FO;|0%|u#m`6!iH{2C0j8cY>HsxiOqPmc{H5Tgo(qLRMLGpoC`;6Rz=Sqv-bV564FQ+ z_(r6jFc`p~}MR>#gEj^XMj^ZY+9oh>-4{-osp642+*Ur6;w zMVB+GesYEL9a#-bUND-%Xg`NbTOw?>2T~hiDsg1mthRAvUn6T59heuc9h$Yf1vn-3 z%k`M#Ew(*RQ#p%_ymM*Bjqx%P*(D2%_M*Ct`t=`*9?9!&%^3^cAN$iu1LI|cW=PV| zL=;wC9Q(`Xn66T+rMNo>ktc>%^T)zTNp8ZquOMyj0ynj%fuSx8IRINlK{F(2_PAg?Byb=SuZh zJ|MSkIRv+RNbzYg`ggaW*L?3FT(@Fq+YSyxw-x`5N|eh2L%VM*F?8MNpxrx`Z{*cY z-y48$y7;ZFVYF+PXWl-6si2&bS;|&7obSETY2R62Mca6C=8CgvzY*$=r+V$!F^lkmJ-GO`CcReTH^aUHOqn5alkJ#@67U<4#T1J=TJXo`_C_F>y?A%#|nWBD@H;#;IFb!DzbN z5@&lbvU+*Z?9whgkWHdAEP7u0TI7uel5oBq4x-8ms7$u(@e~o+FRq!M<#<#(Log~o z#Up?-a|9%GBGnUm8b%PGnOXBFsRxm+U`i^c7{SR7^+}Y}T7UWJGd_KC&fH77-Er_5 z0F>9jI739LK=zD$O<(U9+;g!=Qc$xDCiL(|(d#P!CKbun?6~`sq^TZEoIR0DAmb^!fV1fjNpq6b#Vd<)(qys zqGyQ=og=X`jDiqi0tS%s!RFTfCD`xe9b7Y~3kp<0_)I=@iF`-kkW&~w74lg)u>dCx z)&m3Fqi6c>|Ac?MPJec2XEB7?^6I)sx420glZ@yH=G06)1Ouw`+G&q3yP<`Lx14cemK%Z(yLK z3Zh-RHuLR!bKi~B&Ua4660g2_|I_C;K+ij=+v$5hR5v{M{wiiFO$FhpBb^I_GF{;2 zY>7Uh8`qOR_M&VTpzJrV2zvBU&~YW4ND*jYy|O!IJY%(o6(f{2JD1#4Yh(y(08Z%iQceNUud7uqTLAlQjB%AGS0!!SOp9;6c! z=Ail*7|{K5e>$F^dH^TFZ~@a9<2Y(2?xUnz=SkfhsAvgN5IY*eOpn`ARC+RnpL(ksDkiAccwbi@0Ut#kU`z+Ht zU4!u1FT_Nu2WcK$Q2;X%?wQM}uf5hu>UnbYWingxnUui*o@(bsnM1j~3nUQ~>%mUG zdJqx}y&S}*Z+Qam6wTgEFU4V_EA5CY$9#_?_0+liz!_+}ga&I{r*!#-@nqV5HF1D$ zSK6_3xLe0J?HY=xYH2d8w;t&{I}8o4CJ50h6*QEZ3U_-i#2rGAZr6v4(1*e^F$MYS zSst0AU@f%}lSR){JvOM&na>+cblo(!oEqN1w1q|AbZai#?YqCfc`+cr``elw+kD3( zVEVR$ZCAdtNY8%fPj?4W{SJ?jb?dQ$$$xhxOd^nr!kW&78d^ zGx9t6oCIS4j>HU-=zBR1plFv{GN&sjI{%msZ#ekazr2hW=F5d-PWvT%7;nLUieVkS zl^KjVaLU_}IpyPE(QGb7;4C3Myl#V77{EAQKL77OonBrfkyAZ8w`~tIPrW*xpuCvZ zmciN5I?X&@NGtR~;n0J0%wtcf@ty*GsTmdUDlraBpGWoF6GvNUr!Uvqi${8|1{q2& zKW}iIdq$IHNRsNL!89;)f~$2>N=k?a?}DIY@kx*;Jw_(aANZV(Ej2 z3nhv4oA6hAOqmt%637XZc`+3%5o`7@0@=83Z3RQ@Lgb;7NEcVz;Fdf%tM&8(iL?_E z6M9Ef+p9>(3nXfjNShLb+&x;RQ)7#wL*gJ)1j{k_G>J8hU$q3cbn7Rh!_bF+y#BMr zk8Q;qx+H$eQJ^i0+PiHkv9JwZu-8F?yjq91$#PGbb!#;_BCV4vOpZem$DHy!v)|sl zNh5VP_|6+VY`ZnOrmU(hk(}mD{;q51n(%zh58GkrZ2&Sy$&78eXC09xx^I?~>$0)0Gqy4}{KpzY)cs&9yfg$IB}-tJ6p7B|z|uJu}ot zrH%?D5yj7%HQT~TJ3C??tV)=qJ<`N`A!@s2$`D(NjF>&AZGjnqF!0&Cwj@X|pl7E= zcGoB~ouKS1mG+V(Pl`z9B5U%MYnG6ffb?~yoXl$SOmE(3QN%I&*58C(G0X*2eh4wqi9pExNyk;-rnYU znx+}^G*2Pwss+%^>s4G`9YQRk4c)5ov_1?M`p0PmVr!MLvHO|3)0K4clk`_Uc``hRF{Uh(TC<#cv>EMSFp}$ zaL2T;-S`%kz1zoGE?M#J*4Dc3xgtMr9O6RNT!Y%}E*#$7-))krg*|k1+a@aqOFZB1 zqkDHj#@o$5eLD!Bb|1uV!9907?$!!`My}DMouHXEwWT+U2vhV-Dt%3+>;BTRqZTd) z=w^fK2y{}G)#U1`cR4k1Ff#ntACKe6!+2Kx2`XX1lEdLZiBYlXl#Y~O=8#|)N(Xh$ z76t)m@>Q)l*7kYAxIj6&O5C#^&R=Mt6y~ZEJwGc@&-NGwJvb1;DPL+CN|Jry{gDcw zWly%nWa6*q`CdP{Adot#WAEJQh#5UI^Qbw&RCYU*hL1!WJC@ZzK!7z!f_i&`deQil zw@VL=4KPFdSXA>JDi=jE0B=Fk3!T`~UsAnD*af22@ z4^S%em5Z=G;8o6VQw!OdIV6pTtLenZF)@^)+g*N~I`3%S`Gkp-bnrWhr2VNx0fvLj zHiOWU%8B)$)*K}8Wnn6L%G?$GF05K8ylc-?Ce9=TP7+nk5}94tM`m-W#H`!ZVQTtX^Dv11&#vH!Dg(x&$spD-U?Qmw}$dA-^KBJ#OHyJ(K05^}C?WnXDmck4=a8%V?($fZ6imgAqY$pw(j5T~6m zZoPNS^V}8-Jtb&6Bwj$ zBn;~|{Knq9E5(Q)#g|tPQ6f03od?&Z3`Br@K7zpm!wXt9`%$$lB&5K= zrPz%xBlR+0xA%yTg5_R9%l1b~xLY1vLy)4Eqax}ZXdXPNJ?1`h9@MfP6K`)$s^1vQ zdhDenXx3KF5P9c#HtKXbJ|7jq*OU=4XrKWDaMBFcBWxbHj0OuDndyfvC3V2!(Ruu<2r*ebz7ZE*M;?`cH!lRFM){U&(X-NADd+~LuAYmd!>S&h` zkP+1R9EPe0oT`f~L`26UK#mBnoiN!&9#^P1l#3y7cF!`s@7%pK@Yzn2l$Y02VqMK) zmKkqetrh!)0V< zhyxy4%=0p0e0>dfbxfRY4|~&wCZRw_E9CLo*wL*phTT2mmi5}3sxYB21`hUt?Y^PZ z@~?BkNpI*n3OUE-^drs_d{lV0T+ppziqf+$^;*n9M5P3CuHdV#+}k2DyTdds=2>a^ z=p3PQMzUthA5&%nlS|Lrx*7Bh;I-Aj9o~Z+*Whov175#x%il_@&NuIltpD#O(eIm6 zynmw71|3*ei(S80t@dB#I=u5}x{cRrMTELwr*f}eUeanMX0Bj>CH+i&vIvb-q#TqJ zqFBb{6Ulxt9vb30Wj2N^-&)Vx- zG6-#XbBU0Fg48%q!I_b1KtgM+A*J)~&>%a@Ii60>FGsrqpd$ab?v!CU7j6@2|JnCSrxFF@LMlnP^Nstvq)P7{COD}{CJyC3Al*D*-ZKYCKC$ni1 zyiLn?c_61HkeqK|S@s7~$Nu=taGK8KVm#7?RZDrseFL=eT=zf`} z6{@T2fM0*r|NM*W(Em%N2+Gev&!d}Vmm(LfeSeWmf%tZsA1^QG5g<^n=((5w_V{w) z;iuQ}avAt9Xa(@FtXE44+1jkkzk*)pIUmSY7^37+-`Y~bQbn)^v8P3OU*2@njuq){ z--wj~(4r>O54yhWab66eiAB~_aX-i~G_n%I5<}ah6$@Uo%EB2^SWp*{;~z z)n^3L4Zv3~(hCO5iS~b5H)E~~Tc&A24Q8*@uY>!?Jl{rhIfh>AN$qY-j`x~(x9jlp zz8blG`<~v3+sbU3dGDcS3Xu2JPu3f@^|xJH?U1X}=?aFP?@(vA@4Y_1i-;DVmI?4sM+F|h+$+t4)l#MqhFvP+i5P@|F@ne! zM)kysFc2<7v^`F#GEl}i$MSzqZ?P_hega8p&7R2{=1L5jc_3v`1z9)d5Z98Kq{)PP z)}iFhy3;L~_a*3)MCzCh@4SFh=W~ca3}s}wY$e^GB9D4Va}Q?p0FH6>pQHq7hQ-kS zYpj7@spHGhx|&dV;KU)ZP=Yiuv_}{+OvgAqVU0>^4>J#gBxOY|$^1!I$lA1WlL$)X zop;fnIVFZE>wrCxQW?~XHH$h0eR;x40gh$*3da?T)Tx6!_no?PFqL;rB7KP;wzm$^ z^9cluLFi2B<@3kjox`oh+UCnJmo6yD%8X}QnTY6ka$Ik(Tz}#bQNTgKkRGD#sRXix zpA`MHiwPVYe6`*nixn91Omv*X^5FcW-JFm$k+c{Z0QE<_jQGO%|GHmF8nEj+0QxU1 z|6>02f2Tg$rLSQ)$BA#2Ta(R)G?fA`@-~{*`I7*~z&xD!Lewk$vG4!>lX|`MKbS-5)+qS@b(|v7DCWqYy%+B|+(R1bn=Gzai=3B478>#J= z9IS_ZE+-@r7H^sWeV^Er`40NG3nkC(4MIJ~;xlHTR*A7OEo!$XC->0WJFPiUQ(7&4 znuJw!jHPA!XqzZYxLDp}1|2`&hoOJ@whZuDk90g96%FSzXh=vhMqUg?+Pn5LXiUdo z!r&d{c!~ZcyA4vwhY?^SQ8;51dr5S9re48U{kgSVK#!vyM*#BJ_v*;Znk87f6J6o* zlX(D@F1(AMzCY6G;n4KLQcF1iDB}vEa$+o7smyMp&+`sh^wf zCAk#ICq0b3Hia2yJK0M(eCgq73E+dw#rtRYdr?VZ?J6ntn5rG1dSXZJ7TB5D8Ei8R z7PWfGx3;|tN%VMjQ!q0IngAGTg$Mzayv7ow&KKmOAA)1etN2Av7}1SZjn(^5xuN9A*8~C zl!~sQgjiV^F?2H3>GA-OspQ+b-4|_jDBfej&@MgfRwzpw(b>-F8x`I5YR39Ko)GhQ zO>&%f^StS${O&oD??%%1etx>$2$?vgT>;tc_C4|qKWz+P>`-T>x1Jo^_d_8;$_okR z9XaIh;EeD7Zmm6&E`NAD{!b8qF)#*iZ+LqPgN6VM3;?+Q0|M~{A?^DD!nilYh6M*f z3Ou?hoG{iT0^|lj;~*wIKAwL3!!LZ+U;p_0fiM4H%vbXW8!T>PF z4rqp<8E?igj4^EYoQ!x~Q_o|C^Cjj?|L24Dyf1ke~`%$sSRgnnbN zhG?u&wgE&VV9eX7AJEv7b33I*f}T#N$0s5Du`*y7u4n2j;1983rZet>}yYz(_jYIhA`?^D3Q z2pD68A&?McL<92`wwF>vAY+WMSDcNz?l49?iO@3ksElcdjA0=RKtgC+A{O%VV z8Z-yYS6r|E>c9P0KmMVAH0Cl4!}tbcpF6gTuAt}QabsMAz!=~GMjHVb!3^8!1q|H( zd1NzcV+{V???0S~{+~a;y=n9CyNAOS*K!Bf{7>UwTnqvSU_Ri045&7T_}R{Xy#;3b zdlNR*0tWzXgTrD_YSLW;(}d=V>5A(W*DGLuX>bLu6RwqW02+T#SK!e2edj~y0nHTv zng&g}k%Qm+HQV4dY^GVXSUDOW{GTg;=8$i{Ntz;l%C-j@f8y6G4p&?cNlW+^I5gR{ z3XgMiStDm>kp5$17;ljEiP;@h`I8=YoBW>kp98MI^>B3uIb&KjRcwdp>f8Lf2TdGM z`P>x;TyK5-dOaKt;ZU3VVcd0bBx#!*c3`L`x#HKX-z1H<=wpY)6><050o^t0RNFh< z{c}iKvu)R}gFTDZ9b_AJS6t}pw*kp3(6%^ici!4rZy|Ww+Yae&zj|C2w%XGcS|_m1zbCc9}?$BqG&ErV(}j zWJ+So88{Mp?VDslZ2HNOy&(29C8Y;XvbZulj;R+mQ6I#-NR#bCbT0kqsg_e@`6az`8qUvAtqk7jNM@G44Qiht#ivgE`lv9 z^F;FN3CCyKD9)!l_E~}tS-$A;*u{Dhx>#A%6)ysXq%RO!V5?4*=>MoD@vR$ zi#WZ9yJ6C9$~X@s`;hXT{S2D(CJo9C_C>4|eLte;!`U^)gG=;C;i|c)^AVgpKoT!J zujsG_J1i-qxxV1I!`DU75#tu5yntlGe>s_|}4S3+qJ#5pGYo}j3&ALuxLoGec z=-Nv0=$feD{s8Sgg_*cn6!E>9{e4XD4dS`IvBI!{_^a(XZI}A(y765hb*)x=O+eD( z@c7{c<}Krnh2@lmWd{X>u@sf?{4ZJLt(g(%Ia4f#JG&=IFaiJ`{o4X0!mkdm1vF0b zhd(?%zbL~$|I;7;Bh0{q7GE9aaJ%QQ@#K&t@Ms{6CBTjY^#|{1^#&Rb&BNpI zWFBD5S0Nr9Y0KIZq6WgiG>;#SfA?>G6cS{>#uzpbje!va@n8&K%rDT|z{viINEu@( zM3bTC&_-Zrld;dGXD}dycodK7g9S-KJdqLxjjf*YET940HL}c}VHk)XPme!qqld3= z42FSzGX}))6)Tq<%Er|`- z*$v+KjoAeEUxop5BcK^*ARk3T)R1V%vf+RM8v$rMKB7@*$h{huJ&ZpyOE4RM(J8j6 zYgLo=Iw1^^TW_!%30>Euh?{+PCpIje1Ra$ilH!TfqtV*D8N+V?@D;$;)aaD z+nW#%Km()A8{0)82n{wc20}ncd;g}L#k{>WFmZA&8sABCRg5u4u+R_Yp@AutF#PuB z&Rqy2Kte!JY!t%=S{PWm-oO~c!uBFSxCIO$K!7p)2J_WT>Rm6;LfCZ_yQm}F`h#0A zGk_6x)xxlSu`$L7wu>4h`bVLFKe5sMBYi{<9)~wJFla>VJZ=rdEZFAF9}`v)44{QE zFxoHW342QRLK66m%|$;vKR$l?y?UGZAODNSFF3T@yxq0NT?G=i- zz?!%>TTAVDYPmzs_|E>{mS8^A_qq3{Ntm99*%QL2tJA;@&@@R~91=F#fA|0#x`foW zl&E6_B_t{XJh*bWWW8T2X% zJuf;y%79jx>1!O*-E~fA=>iNit!FMhFYNzUYoBE+);{B@@aqjAc1Vu>UIzM5yS9gI z-gE^yUF%eO#$va%g^oy2Uqc5-8a?mZUG2^dZ{2Qa9IpNbKWw4rHf_})4FBSkubUiueg$vT15`=$>n;+yS?L3lf2;UF8*bQZY|`=~OlgN{80=V_ zg2YP;W~>^~$rEkBiC$4^6r`T!B5u%?;01=$TUC)%C+d$%DZZRvhu1Th37R5fw@eRC zUBdErb;e>!KwC%YlwIn_?IVO(&ZVcU8DpNLpP5e7vV*i%lFg=LUjQq3iK zrRzJ%T2hjvJ~^)ee9GC`EYUDn0iIvapFj2lx?r^2JTn$GMAoNGa2U9Sd;Dog1)$U=p6P6@SCpsx2X3KQ? zl^nRLv!ySKB09nr?`C~@+p@!RxD3XH&lhqmv~L&AiVc$lb*i6;*E?GmXHE^R83Uim z?vN-*`JGR8elfBG3_U(EP2sd)lu+Zwt*f5hhAk6bu3ruL+5w`5n#o#@yX7IAh!m0Q zr18vSudvQ|_y2_U)nMu7zytzmW*O@y-NhLG!-)S8{r~#%3|#(?KmOx9@8|8hEly~P z(%6M%ZI=;tQ_8x`E4*FG-7b~NcW_0MC#6$!HBTQcEi$@$n6P=3P~6zUnsvubs?V~~ zNf3Bmwl<~i+4K8YxxLKvzMo14c0GQw!!(7!?rvHXL>Bc{PFY=95NO-&C6%PX-mOS& zt1A(;zHyhs!@NO6SI?oADL=L7=G#h%?v8$2*z&lgg*nL`+#poHUH!a8L4T7!^L?uo z?|=The}h?Hn3j*mq>FV2_543W5yT?|ksu=of}G^k(q_U6551N&(X0|+0_#^LX{_E7 z4Il#joG$-2lIVl{;q-X?@dxz*U*CTI`H!z}mw~{-XfO*66gq4xT$J?qd!iqo@Hb?b z*)!oLp&c!~Xdqxr12iy=KqK&AAgB?55kkL>jlg67L-RlyZ|;~WeBH9r&4=gTA3u=( z1;$c}Bp&QL24)ICil;|K zjSvqo1_aZ%P8di>1JDzmgrjZ+k^CSYNr22lV};A+;Su7|orL)c%a98|3qU)Se`Hu) zpEZCGg#Q00?tOkFN75{@7v(h4zM78Mq0Jz3mkyz3)@z}G6av&zm!MgwM}Q8yC*Ako z+@o|^VD?x#33*Th6&iF&?$T6O8(Z+~{)|lXN*(MsX>|9B@}opp!A$lVS7NDka z9gWtWo$fzqpbgM~nw;+!;xYS}iBD#zQ&{$c=Zg`xu>zs1fJg}O1hxRPutErtt`5Ge z!A&NpzYdwRsz^>n2O+r#!fs!rg0)r%>t)>E8Z*%2S6{x-KQ!O{VVo~$+uQolj3;S5 z;kO|3I^cq~xg@U6iqa+`2NzC64&F-Fo1mb%af3A~)ZX_K^-{5k& zTy~8o(1PZBcC7z(D)z?tU20d5ldtWygKkL9J@K6OT8p>1G&@`_LDTJp=^YyP_sE>) z0^%KZjv{Sy3Gyy{U26AXmzc-q^_VM8>{y-Ht%>1nX1Xc=zGkv_RU*0^`3roFW>>wF zaduw{tk!Hl(HoD_3|!{yncbBYsqzut?e42weF_78xmbJG!~S+ zr1-V;^ZE`no4?)U!*VHJJ}q9*WEZym9A650V)yvP-+~_V3b6nz8sBRL5cQU=wZF@& zyK%|5otfeQG>O2-SZjq4==+}b>h0eswI}h$+Or-{r}KCc_AKmsz>;Na*)~@A5;^3c znn!9r0M_DBh~bI;O7aJ5&#=rMAxSNCYJ9|B!qm$-_|rVH+Xf z_J9x&q7k+s7>2Q~_z%}jDFmz)UZUjo9+sX2=m|~Zl_f%0cI|K0`eA#Y=WT34Ul2)Vg&>&jN1i@2vI8l8p*CsJOWPu z`Q}$Pux_&@1iXmDT5G-B%3Y;l=%O>&E4WCh!HNcK)&LqXL<;l<34I2d+s!{?Qp>8f zXu|Ir-ylq+h?KQL_wBoWY z5?I0LX$m_K2k7DZ3mu@``ESe@>>BKFnf+$P*XZ3wWS4{cYP(WV7tWXM);EXwj!Sr`p&e)=3zP2E)!7dI+_xVw0?VYS)BB4yF$Oj(7{0B699BuLu)Z1GeT0U#6H zXhSY_Jf#p7eq`2zI?$kq596p=kI^9u%*S`{zE*NmHiGj203ZNKL_t*FD^B7J@`21= zGhj#&_2AK^4M&44gR(nn6=_H@2_+jTCX*h<=r~ll;~1*q0oT6i#R&eY zdF#b4WL#Eb;j`p+f5L_f|GR7+dLfZg-g(U!0Mz>o!X!>GT*RLPOF>blrvL-JYjo2* z8ZKovNfUxR_K+6WOTLBhx_*PQ=Scy`@&%>47k=($PJH2@oNHh5Yar*o2TnHLe(byk zgI2zN>E;+yn?j*rly^Pm9fxU7m1g1w=%sUsj=ig^`0-LQ<}$#E+?1F3qr}Xlh~0oN z^9e+s^TVI;C(42qX{nAXF0kxG=JFgkc-rMxokb*(%u*Zm*C!B$fA_2B>EYqsZ%?l) zYx=5g*LEr9qm5qD(e|yY`mIOqf+CsspT5(v!$193q2HL0m2R^oLjs1$$8H&B z!_fD>0hKlh*$?_b(Y~j_uRxklzWdCZESP}9I3#>|eWC+b`ozjvD{F6ZftOrgO-@e@ z!v(@Q>G)Twp)Ll?5S?<;?}(M`hkj6fug3An$I-p?boz$>J--|VB2v9_mIXZOh+j$d zA<=MA^IhSIssTrCC_zNwx=8h$*&}n+bi$!$lSkSRAbEjlG@ziAqMm%Jj5mFp%!+&_5obw_QmQgtyPR_Iz7oLR zK-we}8)Nz0)=2hg1f=BP=j#k7cw}Hin2801;x%&jc-R0KjaeYY#cy(muT zf3cf8RO|(0HbNw047g$a_b2>Y(Et2j{L4T7asJKe`?kG~0+!9--h6c`zSm+#7hsh~ zDOE??6^w4N8RcD=J$DIGFL7@;M0-7CZmwLK$AaBP9&_9%v|Z<5^a6NhD(dzsUYQHf zT05t9g@WeFu({+yv=PzIZAw=u2VhzrWi$CZvuAGag9~j}!O#_0cpF~;ctD50cFP;p zR(_s_Il|~GfPBk>?H>7W`^sOrM*}@=5B)37Er?^=ji5+eec$^od`pbot|JET^xx=~ z`|mDGbN{gbHKYYC&n-_8x~C6d^TBupmi`gpDzBK5ZE?q&@QE*Tx+pH31hAu@??lhQ zqDhHJ_J=R&(1%R5(Xo0IGWfDr2P3pBPmK-Jcyz0kW=-p5H{vBlM8sOh>^;`&jEr1O z;5*IS0_R~g>yfn?9gN=h!+ty+`8a|w;>EmZmWoM3W&Lf;45(ob0*`tVOvq~~gR#xb z(dOvM^-mG9u*N)4Fhji#J#)^k_I*k_M<7R$cs7g~nd(}q3K&f?^lvfqwYzONq5@5^Uc-pdK-QVpzG#oiSnoG?AE*iZo2g^&r1$*d)b~! zygean&+O15o@P6}W)<&HZVb8=4y*m>TIbvAxXHVKo`>vhEOFG|ZrVD`B6y~~FH-yd zez@z@^>hb9yxD=*t~mecJ`gv(?ws4}1*ji^dEMmf+IdmZ>0aM?*mjla*Dh}K^hvie ze<<8vrp+_#?!5Z$Q%MGCzpi`2ZIoNv;z_qh^Q1UPU zFxn{?7Qtz5SD_dc&+dSNB_so!q6HU3YOt!1eee12c!3dUjowXzSOY4+XAY&OHS`Y0CFJCEQ}& zlVXnyIo~`*l)d0k!|gWL$~miQMI>me5*$-(%TynZWU{j=O~HL|H!5B!~gr&fBhfMznL&y zB@zpO(S~K9#hUwU+wRlW28RyYB-7YfZaTD~Seq-Kw_#01?K!QM+bbtG$G7O_7|lIT z-TfvZH?b5-?)g@NTHz`kFi3-nnlY+%$Dwo>G<<|08+M>k^c541cr=qQ$m|XyIR;{Cnp5R=mA`Yq%cR z?sfNPx_bw7FTFi&*K?|5^X5!$fCZG|!gK00Zl?{eXqg-usD5~Urf0V#kMPv23An{2 z8$05OeVsgKofuU%hyX?rhs@!(7>pNA#r6_O0FLdJAvwga*91U%G(ceHEJq}=(ZkRm zp8I}0onDwn$DIe+xJrzjQ=d?6sBYL~B{W05l8T(mTVU(5lKtN8XgEuYLCz)1Lr=ZJ z$c7j!m-vGNelEE~<2t~?alC_Gm3xkcXtF1z94eM+)|5cd%YbzR;z5w?l^=|;Ct84X zvxF^tWAm}pZxq<8R|-901o+6#H7{a6BCObbza=3ZbRB&Oqa+a1UpVZ$IO!71DdEpT ziz1WbUY*ou+y|lk?N(}IG)(#nN!std$R-~aS_rvQ+d+7VF2HfLYA2+ptvE4By~+i| zL0i1stGM|WClSF3sg*|KT6X#k9K*BTUim;?-Ys z7Mz>E;}i(zDBviV-#Hd&yH8lu=bQ)IxVWy0R;SVhtnDzP>wswkMYokyOT7tj8B^PA~m%I6VJ~^>{kHAm*saM6a>aXV<&m zc(ol^;Us1dN$<1ES$C5^S&|@9=m`UO)NcD>3f(1$_C%6LUcz>Y`G_MGu`LX*U=9!j zAVug^ka+~&Uj~ZWolD-}=%nNf<7($74!ki;GM)-YzS`ZJaf$p)hNY>Frrl}s1~==i zr3=cEKs}qWtYL&9pt6?X-v6W>WlRHs2wHQo9m|s+0~_jryTi~Us0XRA)#D)RmZ4iP z6Scn_ec$1-@=`_6?!nMRim1=(HT6f7K9}Nj>h~zw-t^2YID2Z!nId6L)RJ8n@no?jsg4>?V$pTk#*N)!-q>1;6`Z@}uHcnZX7~8T-{Sn8wGY4piAE%IXJ-97 z*t76HZ5s!$nHMwwKmh$=|Mr(}zJ2#Q7;Oz(!}dF4HQUj?H?WqSW0+-FE36e3!a`UU zmV_0;5;a7IsUb2xMNkM>8i+)&oyt668Gy@e6R^zA2`n>KmR2;urDw-^9Be)pX*zoY$|$2a@t!=truZnoAMAsQ>3Bd!Iz2)l=1N}C&J zCkI)|F2bjx3DF-0qDOmvZ>^Prh#mz!I)^j>PwMTjpTBtf_=wM&hvvaPKH=d5&{&6S zdw__Z9xWc&oGqWd5nH@1!a|U+)_iEd))~_p3u{e`Hgs1CqNm3vOTrq9;77cOBz$Nd zDY$>LzX8si+H!bP;Rhi4k_Ge(1LqYeV8+oh=<#y^e1`Yd4l#2nQZikKeP|vVSU?!g zhBhShrDRMCSkRj%Jdr&cdp=tm(hc1iI?H4d;UM8a!oWVz8zqOKd3f-qY<`3z>pK z__Gz_3E~M-db2GzkR%W%Isi6|XdMl2>FBcbY?uWhHxt6S+WEk}%(a>UJiR>tuxEoX zQsLxH{+x;@CDa~5q)tj3e!~xGva`++uOLNFPXgo|Cxa_BTj4;n5W)hF;)#S1LI`HI z=kwW~t-poF{fWMA0#8Iw)&gKbPoUm%$XsOS3EsE|NZ7^-65f*0IvYD!V{Icuai;+h z4BMlkBN_Jzi^e}V96lh}S{8z$U9_->mhT^%j~9GqAAk>*-MEK0qd30oXSZ0)NxOc& zQT*FwhBnTYzH#RA5CRa!T4C*f{-6Ex??3+HyMO%s1((dq%vsMi(ZBg}nSf@u%LD2z zAqeh*rorTb=yt2Xv!=d0?$&%ti!NE%U4X7`1aivhEJ|y319s#{4<*#*5|1UTSZ*`sogk$~EX@CToO>u4_^rY+q!5D19;Ns+@)RGht6escv!(LJp z!T2**P#OfIjaSC7CJwb_Q(*zd=?zl@Dl`0)xY}T^$TlJJkjuO@E*|4(LAoK(6 z_lf^z%{q9lxr=p0foQ~5Onj4@Mo{sTkZ*hE0@pCp06R3gOLUoKWUfewqF#~MG@rHbubWnu&Aov7J`4x!yJ*3u zkffqEQGyAq09~k+SGtP0T#P4;7xI|NBsWy7Q+XvMkr^{gt2veFK_Jx=Fc1;=<%O9s zxJ6xKq4P-4!xZQlM2aLS7m&>+v?Y()b9aOthLc&Z1{89&S)!92n+}?#yjt>WHb~dAyQ_B$Ekdt zt}70+8ON8A4u@6VI#y7Gs^#(shziIz6_mt3z%bC;%rF@w{7@$VDaCoJhCv#AY#1o4t=<#UQ)_-BoA0ocJr@QeThVfNIgaIsFi}1$|__(q?$7^sjZ>l;{%d^k- zCJ-CY%XoS|41Y8H_3ytw0hn5}*NmnT!1PUo?RD>hg@yArjOf znm69Q0zKn)g*ZpF5xIJ~WEXxu)iE@HDXT{>@k|l9^b_K*=W_DBs-tcyfodGC zt>b)B_gr^-jOO*c-5SL9lSh5J?-u-oUo}I_p9ej=@?6BWdyrea7rcuBfv9H?=>Vg# z;pY@F^w;0`J||WQnitqKNTWxG*EEk~#U;Q66dcv?eAxf`*ZlJCcpCQuzy!l{Vf7rJME7Sc7F z0VDJn0FAR@P_iG?VXvqMnAre|6%%V{7-P(fp#ud`X)zR|9x;TzsE9MYg#t*qMoohZ z@)H=c?-jw@SA)lx8=*Y9(V8{jMBqWpY8>2GJ$k2yB`{0Ph9w9RvCk{_9!{PZzDbix zJ*sm@F=h*Pux6-o=n0PW*#vHd9cB{6_lBY z)bRWaBJ;w4Hl!qnd(;y~G}>l=ptL$4FfQ7^qiJy(Dt>-aH;d(`z(3WPN-| z`HsAD2Fy?Jcq9eL0if0SQ|XX?#b<|BosS&%gOtSM0P_1Q>tjpAtV!$iaD}(<)t~qf zIU^VYKjBEF>t%qJ@lR=LPz+)k^XrgA<(4m0b6kRqw=2{v0rXU2=xhs%s=wf(5=QHB zG~mF5$L+7%8634f4C8n_TW{)LJz8 zDCy@67k1t4#kEAR>$59Y@|sM!XeA7T)aB+yEbQ|r+NE)7PzWZ z;!bVFM9+V3&XDxH2~5@^)ixs#uK|R)j#BDM+O4+4SG6m)_kpM>O_h4t;7&;TBel*y z6<7Lctg4qKZ;aIaTZk*}hyFoL{?f%FyfWjWfT0 z_w|Yn*Pshgdve|j!AfmmvdRvXCIyw4S;A+gCdu(=R?{?fINBZ+-Vi@k;m}_#15_uAOdRG z)4t~;YZ@tnZ(l4({v{?ht4RP-Djy3cNfFV=oOwHJaLnTvJmZp6h8KY>?w%QezJh*( z5npg-bC`W)?8}SBJX!ueAf-cJeve=>^qqO|QL4Oi6Hf}3L zGWd4;Q;pUk#+6&BaLIE`jAQoXDgr|?WY43Fn{HlpfYP=zbmcYag8}TEU?@mSm<`cM z>%*7(;V<^T|NaDYQ_bjWqZS^`=N44f^%Rw@o~Px4Glf*bZsABB4LUqxpG)wQalG@g zcpMMVX6G_5mhd^p2l+5eE2G)PvR4U(>Co2tk>=ue+s>cUoO7yE3(QL@dJEjdUtR`F zxO9<~ilf7XYX*0*#=a=6R|F*Y!Gx{`J@2*F#-}9z)wL26x-M8>cX$8V7WY11wSWFJ zfcq)GcqK9D7U}+~%b!a0+-;%Ew%pRyS{Ur=WX!u9KvTtljWb9=NxKT7o(bTWf^J-_9i*tBV?v4oQEJ$O95ykOsd_5A$u_1C>J286Lx0%Yy(kQffn?KoJQ-1eV}2ItWOq)M1}xCuZ=;DMXp2l*|l1 zF3qvn^VRu%3Gw6^dI_Lh4SPkh-z)F9mc<~G3|Kp_=bIiFb605@Ze73c$vOSWOg11X zrHVM$>JSj_R1Yo0kXA0U$_4#-($l zaFW$QoQOj9iOG$V-2oka%-le@WFAvtVmzJtfoSN#Fk=vxQ)v^EQva9~hz7tV9fr3Y z_Wf{(Tz=RpQ3w;{OnyS72-;bCm*A~{&OY>ynTbN)VcO9xwe21-YbGVrr-3hYWDq(& zuB5_dn>GmWEK3}`mcGEnnkh zcwTB==V}-sx>(K6v>HJ_*ri3-f!`@wV}zqka}9gUfpP6zc0*e%?QM*ZZWCL!&_E+Y zrR_FTwMH-H;@oAaA)EeHT_NyDw%FCx_lgu@zDAc$YqO5Uo$gAQG*^x@t)TW6e#?fz zr?FAY0mH}{4hMf;&weRSJO;eQScs{r_n;iCaD<#HDS8$OO&NtLhNLm0Pp+;${%HmlYIXk>_!lEBM6vPsJrwTEwk!!HrAmr}^YxW}S;M0|#0M)?MB z9uWLd_k$ue00eU~!IKbXOd=dFc_1fY;**<8BS4T6L~ZsZ%s zHL?RRwNqDzGyyiviyu$Zvb-C>(v%}s$3y!Tw+J5FqJq3w*`}*7G$-2EK&QP1qo?Y3 zQSUYMhv`~OAtt@L`c}_jzQuA?RnggT(!Xwb5Bt%cZzigA*~FT<5pEIL_*i3if<5*7)9L7R6Ot%P z4n)Ww1WWYTJH%o<*QTMhW}{y~N)jnZl4?(iNHLgMYoKT2BpH$og<5eQ=;$P@ZY4HE zQbN%%?1y1bpPK<;pTJ&gARY#K7q|s=ZS{8)U6p**N)~j3mS^P-UPg zgtI_`%o>zR5PGQnmn5Y&2CTiQFEbmhdIh5tX=YPUjyEXifV=_Df3_eO+%kh zu>p)Zz5AwDN04$V7~>oNVq-4nGoNGlwmUn+q`nNhOJCEk`-T_$St8{yUfjD90HyXw zIXKSB+xcjWWnPMpY7D)M5O5SWsk(1-H&*N?do~UKyW(kMeg6jeWy>nm1ICF zLjgT7vpz8-oiNg#hG!_qJxgcZ!OUjuNs=nuL@-70SCGa6K9d< zZ0N|FkNCVY$)tw34`F7_`UM#F{TQ;xJy#mEx}Hd5W7zPJ&|yg-N+QGKlDH(Lo}UL7 z!>6_9tBvNDcc=ZY)gW;q@+^O`jf(auBa}BWG)})t1h50{seLeNh$$dOlL2a(hj_Rh z!RSw!q#GbGm59193d!by0ek+^>-+Phl^l5GEr|)O@`~1F^uzGHr~Sap&?B4_c^omC zaU6jYWFHIxImxa4_K~u?kO5>rAidv7u)&x^WiJ1c|Fb7}656Yyl%m5k2+%j&1U#vJ;^oWH^n=ZD@~zP zcTauLgXu5#_~(D7ep6_JtI)aKU|+Uc#->10P8F-Q1-8y4wo_yl+i6OWxC@-oe8YPy zV!T{qkoCpQiHgoa+FU`s-IcYuTQZ|wqTSXc2bB@ML4M`jYdrR1J)Y(jT54-h|CK7) z@XBfX=h?YTH5MXpud${@{ zto#k9g+&{qcVHCrGnfhKTG9mmM%F%?1dh{w! z_06J)!BV;-_50z=!+sc~C+dk3x90-bV(K<2fC(BbS$#RE;Q)pn4ZuVStdA${ku%5t zB$GLr=zQn@vDlEH=t?Zy)36_UHQ;!PH$xF=5XNuxyZ$sB9Fz}nb5SUqO(2=LU=s`V zHL)rcb{aDJ8>S!iehb9x9LSW6=FEvAEl{Re%^u_EVaHep7c)-b@9TM;Lpz!4|0RHa z==WcJ#gu|I17hq0+GY>;7mbEKv{2{t@!I-=VO%qt$;&csnylL>!&LIVHtvAKL8{*8 z)%1)J$p|H4&0Kn(J-G}3y_Y%^oV(|$ohyhW04mJ8F@KU{pQFR_sqK%XOCjadK^SOu zz3tMLk$Lo}VSN0Z|Y3 zZG~>K=o;}{qoT`;Tk+3n0!aM%(?4sIT43IW4(_jWrAKg?FPQy(s;zK2YU$SN(&QJ| zcAC(22}gHXZeLreW=|Wd-;4?!mVP*IaK^VohgaPEqQ5YMZnbx=A(v^5;i547Dst?$ zj74hDbI!H`6$DygW-EK1c4`sS9^KWQfWLw%+tqAg*U5KQZlUAVwas?|r7Ku#g?2lH zcEe9E-ml)aUEQeej^AHy=H{y;Xp5quc8Uf#W9)=CY&m_BAehhem5 zvyJvZRkeE(%B zH40GEWak&QOPn=p0z~~l9z7e+x%R-wVS6V7RUFkL&_SM2zY5$(O+IeU6yU<(^ibSU>R;S?q0w2X## zn?2%uOB6OwJTmqEez7C0omii|^=5|Ux4x=^HRKhr#c+Ebqs#J_yG_1jE)5^@HE?ck zEh-B>X1cY0Pf<3o>egvr36`e0LXA$COY}TlIY?VM+l5;|i=|D+Ja5*Fqb9OK{7)Go zuMl|2ECg+7sj)}~p0+_ui%R>}d=2kZ24{9Ry-3qp;JqSvy3M(IY{$&3ep*E?b0tXo zRTcKBhQM<1bSh|k5<15#>i~6;#l2zLElQn$V}ZMPpJo)E-Q9h5b;X$YAp2=!V}Mmp z>fM8K_b*N>D8JqbOt-d7Q>~kD_5SV6lg1qi=4vl>wWe{)t}#5aO~#8bm~M_T!3Xax zp);+!mq0E<&@W%5f-uM%Y2^UL(m8xZPvcC*8kj*+eb1U-OimW2J|5{nUP|)FvM1PU zzKI|m9%3+?9l|M^6Ot6&@1QV#>|?1;2<+6&8uf=nf5*PAX0S}k-jwq2`Sl(!*KXFUkw1gJ3-S3B16n$ z(uy$kF(hSeHGGAJT($p<{7ypvc0Nmecs+s^NljT0`R{A0QA}`(|X`fuH zfEgk8fL!?N5#Yo$<@v4coIz?JQeb1U?-4s`lOvIhqkco(!(mJ(RX5Br{)X#iC*)NQ z4(g%YLLj(t%)J8Bdd)mEgYt&zxf%?w-6;@s$V-F=WhF2+gn?#HsA0zjFA{V zWDks65Sp2zf!!v0&X!99NRu+_h%-he(@$q4qa-rMcnlrN-=02=ef?USaaK${)8h|!ftYC#Q)7$XA`{qS69}a_3#0-a?*#(RjD<`|YBl7GX zQ^-+?Bva0v6`-zHL~>Ac7zpfAI1-9uNx6#F*+mDpIPy6)P8?0ltdFODKd5vfTfp6+ z+&=t`koHm~xqEi+ZSp0{AN}e1>rp$9Y=7qBN5Q%iYqF~Tn7xQG{madJ!ZTXf8 z81Izg!@M1aPM>0hclZd;Lo2ZMI{?=*%t7lVgF?Ihe5GS4DxIt|3@tO!_zyq)@Ui`f z`N10zzXB4sS3%c&4Lx_&g>7Cjms5wWQg~ZOo)JS&rQzDVv2xZ4zg*3k@kH%(g`m!X zJg~A0B36N_|Jp$OKFdUqn}uJGPYqaMu$tApKk9zM@gY8|aZ z*oD)`m5{>jKA`j(9=R)l@><%_-QqH@>^Qp(482JZPt|_GHZKe0lX1GoXSg~_Q*|?0 zSI^v~XUOhXyMT=CYk2GGId|otZIIC2#?$N@O~y*(9TFo$4FXn?weImTAAelh1#@~PRFtI!1BbAfl`v0n9ZWa5X?|TmEYB6 zC19LyE)i5uvv{UTH89 zo`PsU^inBL+%ccD?_vurVi_uM8xQB`r$-Z#vdIwGC9OqG!5U6bEHK2}bjK`?Y2e19 zt4}u`zX1#(T!DQfwa!`uPNLvsTx_FCu8@jiZE31z*Y%)63qeXPwD5 zErchWanZyK;?t-OiuVe90;D?>^A@L>v92EGaU4wMRaneImlVSMf;C5;!M@r0P#j@( z9Y}4gSrS}BUcB_K60dL$otXy%b3ZOdG$)SXod)wIqsqoON&kA-uFp~5(* zV6KV%&d>Xv1S**bK;J_FC$qHZU|f@TWJdV;sk@rd2*Cc)wnEIAJy=d@O;rXOS2_z( z3WDbf{Jj(8%#j<-SStr>76uE2W?{oSEzcx$2b{VqFt%+=VA;M7nI){(E_(CUKq!bd zA|c*Z50riLsbd7%5A)pkPaG|*()_t(#_Pyy-eLHqwS`7`h>E71yrLZ zin&grzd~_P(=KmiZdORXQ5l(F#%9h_-MV<9*P-agEW*_B&Y>wN5DQqFvg6d8|fwaLL2lO8#-SDA)( z!*+mD_6wWi%hAVMQ}6 zTM9u$ij-qAiI{!oql5p)_<;;^iz! zCjc7fp%_HrYbuo24PHplE}vhr@KAP0kAtkn)J}#{3P+8c1LLJm^tT^+qs*!R@t^f66SUUuZgu=r?5>|Uh$e5K#r*I#n96|K;ZQdA|^CX zDI~|=tg8%Q+f7Tdbb5s2*XA671ttzRi0%>UFQQ#fre5lPKv)Qe_zHY_Q<$)Xq0 zr|dz(F|P$UVt`qX*{_&7w#h({t6Lk8?;C?LJW3)c(BMy3Wy!|m47)PK!DHd3qpk zUd)9dg74pgQi>#jB@q-!ePWO|N%37;NZy4$@1kZRP9W*=fq}cmEcv1Q?MlW~ybJ^)R`y44w zE(V83?vF10MTVqn8NL3z@rlc5ak3GF5YMFj<)W!AA96~Yp71RdLRiSF*9~9EjHz(n zMA@<3j1N@q;g#xXX_& z>zsjcWPCO^pEaL-_Sqb;*%H*ubIlF9n<{ngwKOy2csmku%h;{WT!)Kwan3y|HlV%Z zXQ#46+vdyET%Ma#W@cVoU9EPEZC~Tc8b23Xh;>eQ1uouWZ}$^Xc1tbCN`}y4!>xIn zif#kf-Yt4BtL<;ojon!`HM(UGUS)p0GW6}oj^CY|l-I$z>5BZIEbvcP^!iKmoI7UJ zby^E;&mwE^I$XSi(qHb$tMcRpdfuFjol!okg;FN3WjtL`m-;Icm~3kGUQO-7FgX6iFl%18!coAGdE`o*zTsF@5*jiWS9)aQB)~2!MTS35>N`Kr&@fj|q4oUUB@=~E3gV$zVQ3rEzrzXbScy+fy zRU7YR*(qPq??T;We8j`&f5sp4h(x+N?J1lB#mfQEOJYFtF=r!sMN0J=^rFYpNgKnW z5f2aTia2Szwz_Plu!`wkv@maY%y!*!?W!icbhRaK-dr?e`tZE|euozAJl#RgP1kXg zUzF!9n9|m({M&7H8#VND!F>e@y)lf5SD%6?rg|%Hxk@`R%G@n&SJDn>LfcJs0M`|u zV(!ub@7z_icb(}^!n|Ld1^2O`U96(u7BozX@b=n~=eYZsOZGEqFG~12m!2C-8A1Dr z*MIl^qq`P`^D3$y+qQ~ZHHvn+dSdG{?XEH9>xmadXjiVNZLbp!8GsJ?Y5_y@M)~m; za?X~Tj5&%RiVg81U^lO|)1nQLO~ERM1NxY0>6g3JX}XnOx-~JGF_<8Jpx#^FI^Yo3 z`vgr=`~zeNVF3y&3zPnr}!(7wpo-h)U*);a5m4F6@#`o#2H@MT^LA~WDeN)1xEHbqTAH7-F4#4uwr zFG~RJ_BJbGdBf1mN^3-kv?LlC#JPMZw+`W8Fi~mN3U@uEYZ4gDMli-(Q-}nCJn$V}n*>L%3w|Fp1JG8zBm|T>N$D(1L z_(oKOu0fOBDb@sYxrtse(}kjeiH9%2;PF`a*lji;NTN*N zTscSM>I3BqWF5P@hRRHwVKN&zv<1LUZFZ_0r*c%Fv_IcpBYdI0#N`CPfy=8^S@496348^FUrUp+sc4tRGuzI%DG*0v84 z?KGp!Y$niMU2K+^HUXh_TG3#2lsd1y93uRRN6ePe30KT0+LCZu(ackEB5iq6a}B(< zo9EuvR>*mg-CccoHv{NW#`$!Wp#AwmoAbQB?siFG3z5$GHli(dKy!^eUdskbXYG=N z{;8PxpSwLNqTi^z&VuDfeab!dnVjF;GZ#>^mB1NcAe6 ziRZj2?QRsY)>JD}VvWY?E4y_Z9S|36C z%uO$o)a1@~L9EMK6H#4J;NfhdBN-q*jpM!#A`_op&6#a=a{EY@E?F5TkeZ&l4&%j( zR7F>k$;vW@!<-3ZHx;|Csz}`UF1Uyyox=&`MWFa>J1-6Dk8*!-VWM%gc=Hi8!v6|6!0Ctam^FIl0tQ`UCKgum2Y%u7sfPiqnBeJE= zmZY@xuSED)_*DxF{to;eFxIkVAz)!Gtc9?EZ6MIV0`A*F#Nz~3%UT=Wt^sUgpVXVT z3cuCAWn*z>Ypu07vw*drCqa+a3L&1{q9g=_aOjx;YXxA1fPjD+6g?_>d;$?Z7eX|G zNDx^7wgH6`5e=-h5I{JQCJumAN-6cmT7G|an1|U~Sj*WM!CE1#wScfhkK$2~5bQ6@ z^4VBxt+gzmlzQ`q-dixk!m@uuYtgu2aQ~Oa!~$$BjP^qHn0yCRt#?*|EecJ5CA_|Yhi_e1)H^!^ZOei zgrG-3pIbBn5B7Y9wbmLpEi5c7p#hr4KPR@a!oSr6J%OI=nPEqNM%F#=Hh&ku2JCAI zQsB`)ibTK@NB|Z>(9@HEu<5g*0RR$kGv5DcfQG0Mwh7apdl)sZ@xXfjNksB@ou1j5KkZhL5BI;@4h>pPruv`|N8lt zm+lw8|NnkJ&wtthyB#hU-~s^Ht%2PoOp;i3oG!RDXn<*QKfM5#9k4^=4z$~`+Pl=w(>0ST20B!cNT`_LgaojFD#`Sq#-1_@RI3JMi>My#< z5Z-%t!LE75t-K38yGJ8D2wj_<+XVoci@!KOSKHMs$cK05-#3kSM(gjY&&wrUY_~ZK zVRdu=a&D{~1Pmmx_Do%}iDlQ6qjY%$#?sr)^(p0APy^DTF^h?m%o}?$`j0ZN4znb; zQ8KBnS{~_XU-*|Yct)ahF9>Y|7ZqbEg*ln(Eb zn?o3F-o1O-_i9kk$Xe}ER`}}1#Ktg6EpZYucfw2YCRnC`5Rul$cSlkrb3)JQINb3a zh1R>OgrSoPPQo!Ldh{8H$+c`L-R4xmhSz?3Ry1g+wLb0p1Ch*P_t-beQE#FXT4ws- zd0GkTJ^Q*p9BA(wVZE!GgcJK>5u8WK0mH|S$UHC}fd%Av?|Fn&OnvU+9Nejk85HI} z>spOu(R0Yjb%mLs@$xnI1F5}><5{>m@Pc>t2N^*_e;8Cx`osWaPcS7DY*2Vh7Ge#< zd|HT(xGX;TUOP(povbyvxOHSga3(LXNkb&lh_mLGuSpGQx^Gl!}3|+7inEz^M7(fBheSb$I@_|K(Tve=+=r|MDQmK=A^ zjHcIgR9opttR(d1{MeNA(6_m_=_aJx4nE#aeM^;tY1M@lh0&4WtNwIL7SpX}LYK|5 ztHSYrVjlWGjdW!GaaTQipXPa+)Bh>Ye?xrSZdZJKxZ4< z=Ebber~AY<)7|42e+z=Ju-0biIWsZ{WXkf&wP(x5ia^)|jtjy7 z2Gl%0s`Ylz+Q55R05FylM<|2^tmQ^MJs;@X??!73pBcu!55GdBtRPq@MGykQwH=B` zoLdCKOW^782|_x;)rK;+0DwS$zvr4osWh=!7D+*tS)vE=sNkqV*20r&f$R%MvamoS z1VsM?AR>&i3N%94_wR!iLOcKvB)p9v|s}NIr>%#QuxJ^FdLA4;J>!XJ&Y=9Kyf~PIpCE9><5XO?Mm&D{S@^sLG5F zwIDnQ0i2l`5NPmZMWD6ajj#rm!3<#`nE7n2fDq22&Dvb@%&-=4b2Bj0Y%Q}LEyj~I zXP6H#0>+)A_4IJgnfe`@6{30k;!FDci8Tja-1>RQ3@gyMIVM&QvS2pM*0Q#iU5&^J zEH=$gZ{Iu(Uy4U%A;SE(_Jf76F#d_PRzO%-c#_;bX+p#aC>+s#{!Z8jSciRWCN_5i zVFe7(0EQriL(c>}Jw?L)k%SGLwe=qvu6{rQmaQ*Ik)v<{K?EBf0uji2V?jbd`m&b) zBx(Ry``%jXixIZ*)f-`pii$O^VgXkHa~_1$We&{Z1(%&CZg!EsN=)n}F;17xvrw0&NeokXLF2esPrI}z zIN&yL-n(X-d)s+B#}k2#FHJP*&u+aErmFyUjw?^(4|dHa`*ocMT>h(igq=Uov^*#6-oS0yX7S`m+U*2@?@J5SA)UN$9 zWjtIY`@@@F8eEXr==7fPNB5wKg2Kz#=-TU+W7T4J!9OiG{Ug505oxn)xu7ELXcu?& zvU#XARJ~l#?rss!anNgXJt=v@LwC7Uv^|N0z7!MnChU&1Z`)yaSuyfmHdk+sYc>a( zU47;><{;&oeDg;rpPDXvdg9a9G_L{B0svWz!Xt(JmqqxWZ2)a8NPyX^ z2z){O3@ZY0Vq6q*xF2{DQILPYXIe=z>&{($kyb=8V9P}0<0#y+S zD_@7FC$jt=RtS205=7Rx<_U`HV|LDd9(udJ}9lx&1}u;Of>E#7Np zW@cm0>=1baG|dA9L=Y!1yE`r1Slft^Y#cXXnAx8FAV~-!0Cu$2dJbB^3PBMgSqlj? zghrqd!dlTk(bE@i8}%fteR}iumxnh@Zmz+=B1&Wg95`-lyti(f!`2#WO@!5c=h#Rz zHe#6krW;txXT!D;fOrBuHBPPL{_nj3EbJMUAuO{y@&{OvZWC;P&L$`vtQ)vYqQY(y z=e8C8HH}!D3}79{EJy(7^LOVDXCodTg$P?LYuUY*jeFDVt0zD>^@XtcrjKDkLWn@^ zK7H{wZ@&5^Jt||2^(W6@iw9o;aFbG?5#qt^1_gu_96mD~XWj_^7z>Bg0n0dhITss$ zFRTrp5mGqlECdk=w-W#pJvD+XET35jA%uw2KK#{ovUSJ`w`U4}tUs}0qi<~^1cZ28N{ql3^r4YW^TWf(%cW_iT{mC4<^c~6pEdYs z8)_^G;jCiB6MD<%qyDWukENEyiiZc7AfyYjHwYT_cpSg|@=5)7|IL5@y?yw{|LYrE z9(HYeDG*pF&0prQmK1f!DHd^4NpuD-({#b*(lt9@>yK-yJH}-~+hErfh^=c2z|^&2 zHF9fS8r`-Hi)`EOc9-2Hes_n<9O~WKRqT+RL#ArjT?)k3Ivk&AHFl+nBR{Hpx65u> z{B3ucBR}A?UwfxYgGElUspsFtCzJqtmnq^S9ZmwZx%hOs9Ca2VH>e^<39}2Lo@|#)l@!=+00)G zAtIOCy!u9V)g8lJ8Kp~{nsa%d+wuf1%TZcG`napVd2UVoNIh`#;ti@* zr+HQAOvQE(QoIIdkr(x7j9A;Rg@iLs>wJn>R1Mk;UnWJ0kX~yqvVSa2!{lyy%P4G< z2|Ebj|DU$^`;jF{vxH7ohP&HWvzgOojBc^+XnLf$hjJs$Hq9;;HYM1p$cxD|^Q+!#RB!MR9 zH0|{UIz+-Fq_EeL9}YyniGPCtDH$@NbHiN9Z<5F*25#bL22ScY0qQtO8C5hfOoM~F zitxq{vBE+m*>X9bMRH}Z^+fSni_}^s1eL?-yjQ&L!p7VXA~0(r1tMt8h4r`-pya|7 zsuJ?H^RXohalK||n6uGGQc6fsd8F5>52;c>VYsJ%<~*^>=;q`{8EyZ(@Q5=rZb5{y^Hzm(pnU%389+$_mArG@Q>8-yx^-qe*3WgD zjhh#*2%=K1QBAj|+@^HrASR+TwM%`Q^V_*&%-u5I4a0(g@b%l5LHO|+l_Y`ZXJd_N zyn5p^olQnT0KsVe7vKKVzyIkU{kK2=F97`F7ynZa^nJf9+aQ2;kNL(6xQMf!=Vhp* z0ZXn3n6tX;5Tpt*Fgmmd`ml!Cix`?IF8$szIkyVLOVI<=^uAqo7Tl_Zu*{;qA!a%G zU(8K`NXtyOujAFP_Ovys*rjpv-=NZ9Nlk>IFDi5D$p0zy7v9(@*KbPWx1|2~JG*Rt zg5oCq=uX5dI*Ps#Xq|?t-$ZP@Yb-LiHE*NVU(gc4sj@O{R(bcYI@4_$1n0T7bKZ(@ zT=VEM)Zs46khzfOT^4goJ2bTPLw)%KE~T#Nq9m)nYug7QmuK~t^ew}DN&IrP%XH&2 zc|e&!y?udK2&e`YHOAfe8_-_Nvav*>LhNqYGO%cd7^g*4dttFD^@3jG8LZ5_u9pOr z+GdWi-|lGKNRSXEQr_g3)Z-M~!Z<^X4q+&Q^7bEqD@_LrkdTyENHPgveExj0jN>G8 zs89LU#F&#vT>c>iNr0_4Yl~{vdP`J#d>0!Z3s?;hAD`q=Qc8Z|V(O&0 z$9g&kD-2RDZY3pBR%%!G$2n&Q+iZs^!vu21bK!1ATVxm47ybB(JQ(CEY!Cch9*@`f zN)$1MAtR=+Q5V54B24k;XP7e!=`)F(ikeCYP6V}==@>GBm`RP}&p(k;tT`P=5jh); z%=DXK+?4{vxe;=5@5llIV??FfRJcr^2vJ?cptnSH<}$?Y*>OSIe#3?Y#0k;|(L=a& zoATMTo6WO(DTpfFBy77~s3Q`%j}s^0?LtiN_lh7v2}4&incfJm!0#C7X5bEYg66kB zq(Ast{bZ7)%`=-*?zKYoJJsfU9Csdqz|4Q~?LYbSiU0A>|G_-Z|NNi-&wbx-F!Y`m zR_T{97wcB?kc*~wvtRRuEvT*SZRhP*^+OBV_VL$4Uw`zic0ZY4fw{{6dH)jaUzcBzB@$kf>bX2*)<|7;Ux3EH7;+=PuY{uV2dcb&O=Q+Q5_=J z>c&0m99{;4FTpTh~OBq5zkKK_Pe$~*#vU-VM-9k z_06yO%xpj5y!OWUKOeQ*h3y&g2pts%qq!L3@ z^n~^a>hkz;I!ErG_qe+BniUo@-FGvt9 zUzomx-vPg45Z>my8DEBf?_MzT^XX*R?l2W$pA}kNy?Zo!%SL8={`Q}K`h@@H&;P-) zEdTOfe%tpCC2y6Ht9_rXrVD_1@vGasY*zH8`jw$v`Iln7-D@NYKzW(#CY`>5;3$2g zV@yoSs+beJnUM&#rFOo$fop6dziYo#VCWs{s^6T`Py+j5zge(EN?C&B4npZKLeFLY zO81=#HxZKwM*9ZPp;gtGZ^0Y41w1y1TVxx6W#=N?JY25R?YkI!@sRg@#&pXr?Cx)w zeyw`Og#+aQJKM~co7mG~Lq9j8lZG9ry&s=+<*S#?2dh56{!&#cJ)A@PGX+AP^O&2O zCLcD;_~qw+_r45=D=hPMD%!1fr`$21fwWsdoHdiuwmdjz^c@5V%eMKe8l+tM|CkYNhK#D$8r0QaIjNm4-E`Xj)#^h zr-t$~kKio1KL~&gX=r4o6M;{sr*X7^_W2b7-V;Fqnp_YHz(gaB%IB#-xTrs7&0uw$ z)Fk!EP|dVwImg-nP~$Wz$$%0mU)#8fxQ~XkFvN*4w#9)WUXL|;3h>BfeGmX)*-~Sc zaBBm#EqnMJYMp6Bl9P)?1lKk&(%wtk8P7;!W{7H=QcVa-lBC2)5(xo8>{2$#f4~K^ zXT^7!=?ff8<#qyM#P?(}>||lZrAIVo8U{b`l!ET>ZcG3r|3nmY=?2z1&y7*~m_7+)!bByY+iEeySV1G;(7zvbogU;jUYoqu`0ylqTgBd~yQ z!7qv6*Nkt!{b!#((SQA){pbJvJpa|d`ajV>Y#6o~7&h=?cF?&7GfSTQ?4W@&>&T(d z?Tk$T+ojxM!Hjw6D{Bys>*qeLc`2&A@CeEAy!*ETW(>3EbX#C$*-2eVUeU`tFv+lG zrTdzeo^NALa~j-d-62c180L(uz6L$7km9>HD=#|?J21Mx%2t3;j*groXT~D>Q#XVteGz- zvn6qBS^KoCEnu>M!a&F=N&@5!ZeZZ~`FvC(NHLw+5}=@bY=n?>8MxO{hI;K*o@a40I=3L5>Q|ywYd`;<&LcYBvl3XFiMSRbDRv0VM5t_(xn8+LYQ7)V>uRI z#z;YWH4mNHzzGn>xKAS{5OGF@I_Zm#|47t2#~nk!?_tx$NI5o~AX^ql)C%#ec03vJ z9kwe}moTPDj1n%2uf6GYnbo3jHEdYUA)lp0lG$)jB$IMXwsnx6KoHWQXM)Tr{hhsa zW`vifc=Ae2dFF8Co)eK0%GInm)x?rQ+hcAY+nsDJLw`Z)SO_~k)_#KXwll9@Zl0AGKN-*LWUq~^;iIaXSTAnkWbY}TJY|Fcg|KmRZP-aq{B zUS59l+rJ8>^LZa7U08XCji7KIyo#eQi=G#KtlCx7;)hE?-p(6xb6#>ZyY%R*E zi7l=P=?#nq5|XZk(eqACKSx-D*8?mUAmCnN^Lzs<*wRezeY|gB-YpuBuJ(MaL z_F>H-VVpwqXS$2I2Eb`i@*5=xmW7l`sjNa?f0a|c?)B^yWPcF4)RB=4ux2|JDk9En z4%Or=!3}wZfhR)A!m-h|wdHaXOh8UYg5t<@695e+u+!x;phH)k0!1}5Ijwj?;#?+M zMy|dPy6ikM83Erc{1Eeo*ml%uY)ftLo(s%Yk0I4GEs|^^sKCj4k=xK{pxpV|u={k+ zc6c0h^HC|1P?=qtsZ+R6AlVZY&3uNI&3zif5*J%25v#chy4{T!BnClNyT_*5jM{Ra;biZyWQ7$h+-)X+_388Tw@*+1)t~?D z&;N)2(X8t(QXu z4TfPKL+_=j-w54G7@ZT+b6-raeoqY0Lee#iz5$NT!#hK{`=T52ee7(DMqPdsdLFLs zaNbkwxV-6IX538HUp(gvW75~m{5v!co37s>dzB3NV=`k?n`&>giuYUVQu|wYgT21h zasqCC?NEwAHze`)2b{Blr+}WX{o$JRr6!oWtVZ=dO-3Iw1^feI8f z5?)$SV z9bM%*NHd&3ft_BI0EV&-wh>1oh>+nt9w(>oR)O#*z*5M;=2#Gqy9&2QK-N`CLhRBl)pgtd=sNl85 zwx`f)WFXuX33Tyv5kW`^g4G7BcUxrBmJZN-K}S=4W%S~q=wuQrSmarAuN>j5%eIb| zNs;X!m1Yi<*U}V{belnLTf zzhDL`N29cvDR%fw*``n^w+(gaM95OnX-m&jj-mYpYW;lr?l1n+kAMIF{ty0>|MeID zBbK?Zvj^(NxVdd`2G{qOk=V;z*GS8iZ!1Xb(G*D3KVRBw+0tkHR6+j?6;>Vk^5}sG z_C5j$G*^w1>F@o}FAWHcQe&`OgoI0jNS!N~IxiQi(F!+h|jAqx~TsTbz|IRB;9Z3#5l4w)zS4>|e6tZU z=}ark47Sl?!7;yTRL+7U|864T8p#av7`m?%h%IZtWEEag@+e1lYztu?=-z2pmESp?9WHMYSauv_us+83Q7i$otytaG5tva3~2`o&aa* zhJ^Mgxk2zU`%Qke2o0BBJyOu$9M$t-uSU}($0xWxS1@3}R7PEH>R0{=u$gtC%{OV= z4MO%{7L>7NfZRhVDL>5&Jcl2O5-3yXX3lazi8ih>b*+razX8dS^ghXw+b`%8y6DvQ z-jL*c{;a0)AAbDze|!GRe|7#V=bEv!SKU|`o{?m=OF~+y?=NZ~7W5I>%^O`|Yqdqm zs`fiL=F1!2aQ8dh5x#VHxXa7$f${5Oowd(eg#Zkm7VksVzTXhOGj^n!QK~XjF@?SN z!~ifaJ4#F4*&ol07*naRM_mbh8>7j?y5HDIlP~M-}Eo`w;O+K&nmM~n{OETVIS8n zTXuP)oVlJ^ID4;~IJQmbJZv|Rm&*(D=0Epm+T5zblvX(P_0HGsQrnXxZlvdWPR>nZ zpxgc|C4eq{plzA{OnEIG(9CDtL_Y5j+{KSXqGuSs^)8AMcaG&e9oV|Y8pz}HaTHR4 zIao+Ln$?jWHDm9PA*CnDGTuGdrhR^P4kqLS!U3aAVA&X)a=A6*Y@HFA$GF7cCtuvyL;tyR&iB zzZP4R;D{F{(dX0olNg;hgT7_=mcWz-Db6Yrm#43srb$U=W)e+`oUF1GIvA~`Ks%QQ zr_|+GB&|o?lyUyWJMMltcN?N-BUzp-)d_ zTiQGxJVeNc$BHSPK;~>6(K9l;^xSihMEseWKFZ_Ih={dG>ikGilT*uRu;p?~;?BV6 zbME;k+9W#(N`)@NCJ3~0J45$=k-irh92=4Yj*f=Z?1qY&Q?p{mWOHG0UJ?gfG4LQ# z5Co$$5yuV%k@m7gfM$Mv{>9VNKl+cK{=@UHf4%(hL$H!vT5H!3mpEtqyaSx(qFt}= zTc4`BujW7*4@)#|i&k*~5%$2BH>@G!{0;Q>2Dp%k{;gcihn#ILPA-(K=VciBciK@E z%7@&HtPBCJTb!1g=+zBqZgis+W7$W~w*nns6FCh1yrIbF9q4kq7$27Lj)*; zN11b3BS?y!VgFl(U8vWjtG8W@OUX%J%8HN5@?7A)7l&S%0RG;8uI#Xe-BIbcm5RO1 z*t{bpM}vEAgXS5<+u^opvotC^H$5Q5hBQ+{m(%K^2j7O1pD#W-bBl(5XMy5Sw5;V8 zwvD%S3XLdgqkHhUaex+2?J#WN8SGY9-6V1SdL>9I1(GtFMF7AAok;>>7g(sI5=F8JD$|cZk%_3VG#c(4I6~~W6cT`GoQ~1+ zOOUV?Uq{+#ZCFW?N_yD|jJG0=b!yAZbhdnAw%TSV#sE&wCw9ZbmJ8aoVADyskxkcZ z13!0R?_`5BAzR-6z#v6VB62#P2sloocH(j`U9e3p zI>qs1ZJr^IM7u)bd}=evaXKD_0yK!ZjQ+4*0TY;3%9IE#^NK)BMlCND&z)Bs?0Dpb zLGffKGZO{$4CL;6)c~-5#%B*__5MUD>nmKv8nE)j)edVZ`B4)l& z1o*Mqk2!{S+;D^j&>yaM{9fPx3?=_Qw}x@QVl$V*hP}yH3NV%}pk4MKu$B{cwI9qF z>A9F+OVfaF*=4NjLF!vYl?zVN#RVVGTGoA|Q_=_K|LmLhc?VzLLO*AWk*9WY*yLz8 zLCR7n)#vqmLBeTs$#t#~P12px>HM7rDXBmt2!hBm5i|<~Yg!A4tmI39j$|j9c9|+% z3`PinF7G%VOb1BHqIA?76`KZkR0Kt@R zs`IE!;aPhXZ9?4s)5R{uCI|#QzipUS>~uBTpg1q>Z-C;ZAd=H%ny8eQ4ayCI4mTtE zVOB=-IahD3qafLW-JV};QdKtc5rFx8epYIHI(~fq;McgNuCYek?<5NqH{IY~ z2X~Ztmm75BHU28jm(9zVeaPw zJ2pfm+jN*)FyM_~x-Y=qQo`ImKij_2ZzI+vmOX2{{6B{)1K!^R`>!+L1xY=WgE3zP z&gC)Ziy-Zq#08gSFc*RT(7c=fcK_Tf*SWcEsS+wujlrESBJx|dBui^p%C3lI4j8#E zMYJ}<&9YfuxEcBkB+oZK2#46>UWeT!{>_%S=>31F38E<$Mz`?G{f|S{!aDkh0TQBK zo#UGA{~`gxIDrBas2PGmr1crh*3plVGjS1B4rsT z$HeD$)j{EzG@VIn%cMrXHgk<2-3R3)o~Ch>!AgspkbnUuK_uyP)}K$`h8#G*=(^i< z)@Mb^aopPQrc6(ww0*0%XDgUs*)YJ*U47Qp-vpJETn(>!Whm#0YKgtHtjKgxnae@J< zs|bR1KpqX~z#8G0_OL(E%I3j->jqKG##-Ih$k<)(wy zJW9_uC$AS_{fH;~o9w-kxnVYdu1Cq_f-n(1bLyeZ!X(4?EB!+SowE%{i1rL|_a+e8 z&L`W%%3fCK+wL*4ieU16As43u3$Sx^Ndb=}L{Z5OPc4`IfQJ$* z^o4>nb_EXc0K+nrz;g}+{g9Eby9MipIab_=RI7gGT{rA)ZwiS*-o806L!cGs8h_0D z82a~-AoMpu?g2&c4$zQ!G=6btq2c)oV66${7EHS}Wal!-9 z?D^)owYykabGA_R7lEd?^6yta7poTi#R*g0*5TQ$xgh_%0F*EsV zY#5sPL`7#xAc%<1`Wfe+9mhbLdS_!zKK>+Dra59;f;9#@7tgz(<Y#XF|65YJnG%HHAbH;WiJ62 z79=w9^d^0U1S!j*ltH#xOJMJDA;PZAR<)6sWQ01Fg|Rtrs_(}}fyC@y7}X4EZKdi% zW>o|t5JV_fap7(kY^Oy&%g*MkCUyL~<6r)pfAg{|O|YE7sXUdW-?XgVRzx0lYqNa| z=!hWPmVP(PdC;Rb5`F#M-QE4&`a^yA-cxcL2kQBn&GXP&9W$n}G`8NsTAAcvm~+Ri zox1qO8DT5CED+`nR2ue(*g2!v%bvVK%rGbHa*6+2-h%|+gQI7?EJ%OM*8~?g;`OG1#?p)oyf)m0B4)0yd?|lk*zhdNEj#TCzIfXZ z`1UISjR}mam4_d@UAeyLy8TeajXbb9lR(kyQ!QnA{oJo(!dcsL*{{XdF?2kz$Ysxk z%~j4sP->JB9uLW)V~7x~113p7JB|RIjp3kAFo}x`Zo?#}aS|%VM7V%uV#Zms4lE>d z(og#jv5Ds#G%U`J)J@?#zUOW%wRSTXGM+M}zf=Px7dy z|Lu?d=;eIQ;O4d)ufGlcyibeSUtG5a;02I`X_Bl{Qw=$~g23dN^?Bv{N@^I}q~@W& z>J8TfO+yeBEL&c14%PBudo6u(E*{FQNP^KV@kGDRJ|@numEO`M;P#~kUh18){?KPM z=`w8Kchf}d7K(cKF$83#f2gi#*;tA7J4dapfAhcet@$@!x{3ydu38>9O7UDOGqk++ zF5_dg{QH{EOuyA4?P2IVWPaWZPF6Xo*ySx;UT%1tmdnq5zq7*`E^Y|l^(v{o-|MUB zZ$td;FYj->-~$N)(al`4^(L)TMg6!EVpgm8^1Vu_p zqDc|}AxRpxuGq`DCz*w2JBq3s%7+LVZ)OpJod?k5&EH~NNwN%K%d9~}P?+Q-Cux~I z8f)0erMo9aQY1rW0|-z=MxW0#jvy;sGGnbU@yxhm_-yE@A|+__>DCbsWX>dE>j6Rx zdu#=8^B)OM+gn_MVFege@_3|CdB|lIlqT)nyX&}WW_01%vm>z*;@9Z!6JPZ*O1SH4f#9-;%_~X>>72amtRaRW&-g5VU<; z-^zt8^OIhdOODEo?nwVnLu*YOF0bW%69_p$^D?Afu^=Iz=W=}>c0kXjz`pDfa6=m$ zG_TR?JBLEMQA4GgdapkEPOZZ``QW*^NgEQfUoOM9{sww+xp*_@Rzv4)7u64WYg>JT z`zBJK-vbaYu(SI=DRc;PMLcKJ^KEc>{!uJ%zx{>b#}LLnc4+(_&6^gZdHT&%*@fUY zk^;-#yguxq=c|8iHL$BVtsrJ)-v4G%!>7=l*=?*(n{)AW1=+OAzdnud{r+sFCHc?i=Wux*(!&ex)?PViV6Va!~#$P+NP1@f_vu7VA_dm40DFN z_Pjpgbe7Zj^yJOS-M|V0E30%c!^()jz!W3qx1rr+3YsQsU*J0;s`Ym`JN@L@p zSvA;)^!w6_{`&Uf;?K9fgjEj6yv(=+m;WY%W%_on-eu6d$IUnXyYJhI=nOjdx9|EQ zr!Y4(H+e$%yt|`0{3ygM@`kfIx1mj4bD*6?xg6}n_lmiuD#NQ@UruK*pHm(hqCk?@7dwj&{j5RIbRwZBN=P$-G1%7KU4ozhFh){N0b<}4@NOHxx(1eF zFQ-F=dosGRKoSRUU7T49IgwDIQ&49x#-yf}VwAiiwX2FmD;gMq2~xtc_bqo5)ly5(K)z-~fIb;!8{$QU z-_?*hPUH9lkTGX{(yp1nvTLbKsF@oc+VN&-=Ks#`ce8OGdC9qI$wlbY z^@V_&1q$ou*wkQKNtu-+$3{&Zrmqf>Lr!Djri(<@pAxp;%sl>t9{PtDFD%`H4oW8) zcV}D{slI%{4>2AvtR8mhbdVcFj(Z+jT7~Kx=6xEmFR;bm%Abo_aP2Q1JXyF@ z6ypvao3r1#GPbj)oVQ=ST(n-UG4y-KYu+E0nqc<#ql(+S-T3<*3WsV)`|Bl$VMhtx z$K34Y@(J`;PpN-TwPe=eGxOGP)vFw*O$W7{mziD9`dL zQM#A&TFoXb2gwaNe$&&($@jAt5Ra>-p8RW-ltc=WoZ6d75L>vQHHv31Q1~+B!DwPq zVibN&j&@ryLC;p2TY_eOK0hl(Qj!U=4c3c=IZ}X5bWNl#1Xc$@f}`QJe*R2q%vBH$ zYPrI)0MR6soI+2JD}#G5#WthGoF-K=9QDpA#Mv==G51c66FCX8zk5Uzv1V;Gfk>*% zA#GzHEVkAYA-Ccvo%Eu>ITaV^v4(U59Z2U=0TM+eB+=;X;(D?RFf%{1(dINAm6TOn zIHU04MoJfHKS@>4A|0Q`PfzTkBO5{HnPar5;uR@aqd5P&lspfG5aphYVI5H`n;MD%;6jibMlsgX>M{`J{ni{(Y5d68Fze}p(PQgv z8pF=>JaIAv0Y6ab!&Vc0{5xMC-hR8>g;nMicm)8A&ZaOQaJTspkRXs^W@B`qr)>ro zdVICuOXtcUQn;(qaqvJi5;5p(^sD{r!&iS$E=e=`2LVz7CZJ4*uV%wK@56oY+kl2VHG0XUj+>Fk04$L>`06EB(qrhd53<^zi(Iy zQOZ_kP^8w)Nlf774Z{xUyFt}U^E5(E&fhk4ZjC@I&v6cR&YO=k$mWg0y8gkuF>Gn3 z*6(E0H^AAR^kNTKwhvaT=Wa0&13{&5XoCPxn&-E&D_g;g~}(igv`a-hymi?j0Z*02H0tjOsla+U5h z%F(-GWjSNpb2dq=s-zsJ$#u7BR))Z=89Kt~uzreiE0Lv`L3-MhL4X9k?8VgVryI{^IFcAHv9U4&}NF}{S8w|sa z@)Jq5jB-E279>VB8f^hhQn~{?_wqzL+KEx=6U815XAA`$(*1=J*bQet-3cTsHk zBS%T33Y);|o zX3x3yz*hvU9z6$V6%yWq$EnValO$4q`O9-_SzSm#hSpR8tE?v}*qn^E+BL|^(OU4E ziB;8Q5AD^6A(IymGnQd#;Ma^iTv|wWN6xV{OVIO;EBHJY72)9q6glIHSYgf*UB-=(Z+l&gLk43TP<45qAY$1}$%{9kkIM4-J#yf=eQSzT zk&P9}vO^=6;^v5?vlIJ0h~;4)koMPv5Y5BZC_GkHuI^5Ul6&4Mt@IbBX*NxUixYYn zcCK@~N$9tRDhFKVj4vQu=Kardy#O#>WT!c|2Dn0pa|R<5sq5vavCt`mB zS|+t)Tw^m@<*I8Nwj351hjd7KUETdGHb%o+<1y1H<#7a6`>rB4TM(53@MYvL+MlOop9x+sK2GQfONG>vjP^Qk(A9{Azz?k7UH-Uk9yECwh=n%QWp zXjGCJzxmCthan-~0mB>KjAg6*n?nI3ECFY>CuV?@qEU`C(etw=0AJnBU*;AP%8r`j zsv1krRSA907~COuC0XX^!BOX9FI#*!^tI5U-{s+!d7iKFe{&PdwY(sPYtR`NNaZ;K z$RA4|R|xz^7eR9UVZ;{sI_Z$_q(RPCJU|;j*8-H)<^QNd3ji zPhanu`wQENboqw{PPk%0C$>_DTD8Zy_iRNF+Q5+dHH>HVsnthlVwreAhzri zKq4F#8|x0|`fjO9l``$$U5EJ`^#^KEly%F#95cuK)lb z07*naRP?56u}D(470(x}ZCyWQ;DgK6-6%yAyHb5bsX5D zLvb2E{`_e)1`LeO&qVt`7UuySED#_dJlA-FhM|#2LpvJ>QedOQp24;a3@QxAavF&g z8=X<4+=kj^5Oa}eR|?#PqR^8jc0|g}NI!Q-;kqmd*2zUA5lBIJ_#DnfWaiU;_HFJS z0WfDRl`JU5*p8Xf?Fw(=)Ps<@I}ni?mD{1<#MTs9p5Am(j&l0wl;0L0=lf=9KQBr8 ztQOvhW-tD36T9!>sK)bW;3=71*bR+MfFdx66{neJaPn-ur2My0&+{CIMtx6~&_N)n zRGDN{?PBBIwFr`BBqwSVf}ZeL1si(WNYr>IfR$6-qj*nJ%sJhec-wL3Xxr}kUY+w_ zyd=v)laK5~=rMG9<6_H?Vq2QV=G@#TtNhJWw`t+>9c2dv`teAg5 zl~;WW?YZ~wiJvOaGl1E%>}_N?Y!So~m+eL^d#)kVa61>f0X;*8S8l@1&FXp91LsbC zC?mBi7vXs`WO38dHzEIgt6pHP?_ysmZ#IYSGxoS)&9IMy`+fR!!PPQAzs#9}0>iSW zui1q9WP0qrA+*>GR}d-PQXKfPl=IME+hSb~g5Pre!#g?bWplUZEp^@R7@I832+&5} zP2V1eVFx#-=i;i(i$C)Nxb=qLMbDnoAn=oH-?I6qtO5ZYF~>=STIGBnHu2=X|A zh|i}qa&1@NElhN0V&aq|?F!f`ri+B!5C>|6*Sd-f`fgwj+mP^{lm!A>xOcWtTpHa zsjQE?4*d!2x2FUdROG%3(oI74iU;QN7#b%k-Ea|9l9EZOV2y=RAnCH|x986rYYhuy zBVj;WCbwub3^3Ymm~W~#c(GVUM66xYZ!jq=0)sXauOXEVJp{x|AUD4_Zep3O1QgM6 zRKYltV=aS75wtd^6GM>-vTkAkT7x-U8BaN!xa9SbTe%Y0I^sSZsU1oE!0v=Tz!wwSK zgC^II`i<1E8{?K*H!H?F@x-!Z*sU-BzT7||FYOcE1FDyQdwvI|9SU5$^+UNq^F6#1 zI`1^u4VSq8eYiMm9;f~tpuESvCEwDR`U7gEdB1xlzX$Vv!7ser9t?Y~+dY5-V*q(T zhQFiyq>Ca7X2umWfd*nGl;pNe$;?TT*^IY!a5ta_4G`X8yytl#t2K{O0Awvf*a)}m zvmybiU0=H>t~U6!WtfsE??23{pn_xk8ej4JotmaSzCw`)@U8vD?KHDdp2xI+G-i z31)^B!DudfC-_Q>gFDPzv$w@oF&VPi@B$D{$YEeT+AU*iNJtQo0aHv!@nhs_N<_lK zSj}gqq~{iCyOvj%IBCX+;6o6V%PM!S@8wQDKSuD`^V@7cvE0CW=L<`le!+a_x7iJc zGFx5pB9H=WN{-QS_FwSX&qi8=Et+7Dp;ISj+~%?Cp|zUbew{*hG614!0&CW6bl8@0 zUbI7~7*0wVqgPKtd$?%~CZ!bNbY^W%O1RL;f`(U;|L!0Co!|cUC11b3eEH&EIH{aw z>3BSj%T`qn>vTXFm#|T9zBmpx@YC&)4qGEymAR5n^BdV8~`FLjULJ|OORl+WL5g9&I~%uZTkBo8tlex^IBWfKOkB!6&R8$uJC4FPv1XO+XtE5L8VY*> zu^=KTkCPllY9aFxZNfvH3|L;$olL_#TY?73yzx*rvv=bS)J%u^_eGhm=7 zSLPH9r!6KJ5#%@`0k`VD+4Pre?mDdk>(CsQBNGm&+WU($8c`UG>obmWvAN_E%PABx zVnPTz$MO6*A`q) z6thEac@|*i+MX3I+}?mj%4}!yy+eNNirdX>wnHI^v}P(_4g^37C$4~oDSHVLMQm}> z`e>9Qu-o%xiJ1B9t%S#+mB6c&oiU}KWt^WSQPyQxyi&Y}G?#@5D!(RfjI#Z9+L#iD zv{y#vk{;C4UQt%PV4Iu!kn18c#BSj*bm$|DH$)gf!x~*^Z!&j~6RBzB$>>wYIIt); z;}VbxbSBp3p6C^Kq4v!ut)D(l6Ig2r#dbh_DKV!H)OYZeL(YO#1ToaHV2@ z37^fENX#0vEr<~%*AlpI`L6c8-@|{)jRSsrec(rXnp9-)u-W15oy>6QY-_eU=pWn$ za2T#J=);e+mh0oxZ1@gtSm8LaGEk}5mZPF+bTR{*thvJeAqTtWOh$5Imo>oq(AMcw%yj(7QtQuWXPV%9M&smq zKG8UlAR7tO8a=n8&O=O&2&l_}F*e$GS}}zqhD7U>f>M5u*myWvHm8$3esrkHJ5$GA zM-dYzTGX?3>F!RCYQTE)5fU`zKE~Cq$Md9?0TCiC-9KtDg+{~e&LZbN8y4DeBg|k@ zlOOEVe+dwg6buEUx5REBXtjR+P8~=2QQFgd~+Lfd}ZnT4MN+O||QTl=q zNHfC#&}tejls;>}absUDiMx8sEJ#X8tj(*7T*00DA7l9Wq(4ncLY-N=4TMS#FU(A% zRFnGpU%V`?9zP7d6i`0THN5VR3PkpNb`C{SkP9hf0E#9MGYhi)yslwkT$jA0m{(+4g{I zA}oZkqU9o%Tj6GesApKjUYUD`rEYw-q!roZP8ku}5M?xv1q4}C06uRa%Q+ToM5qq~^nw70&!=xm9iL!>M&5=B19KC&2fv-nOD?-qO4S{wIN=~( zu~`X7RD13$p)kDuYT2@lKt1##2+j>MHv4`8+$MFC^^N4tQSFWWOE?l4ey^Zi`jNL= z$)c08x4Tpd%%`(!<+Y=deohc%gw9!kjUWjMyw7L-O!PEL7&2O0fQb~K zz=okUE7C{#hbR3T`~NM9{!k7iz+kPL-GLCV-_PMdqZTts!PF-qL^-;%;5v z=DAUQ?ypjM`-x(;3)m2tvtX|MUP=w z-rI7zhn|;K7J9#jBi|3&Z^zBU4o!Y3jc?iPQZ6g4hZ16MMMfH(VW+)l6V7uA8m*3q@wl zwjrx(ZjFVjg9<^_BDTSSSwIVW4eIkrKTRri@Ni^;xXAkT1_Ac@^z4^C&iFp&GBm^j zCgE;J>#FfMPDdrZgjoQV1YA#-W$#<&gVRD&9aE`o5ydEQtT*Rln8m6!lDspp0%qeB zwIRz7C2!omN5YHG1Ggps3k}vrE6*`;3`Z=WB64E^21z*{iz`TFa1I95G>zjp9fKx1 zZjJ;iV(kaYM%uEnT1yc%f`k&z$Cm`3HHXHz#Jvd*2?W8Mo_*d5?WCP-w|yeG-}Vh9xPNjx!ilP-1veeN?jtV>(rqf|ZEX&MWeIyTJMR84M@| z)(B=hHthr|@L9B33rM7fZZ z#Ej>&i5GchhN6+wk@2jxW*Q|;N}ZqsdS$iXf$8BCXHH z8Vk_d+xKBf?yrNC79sh*B6$u0UH9ZLL^JAsXsoba6R}yvb8Th4Y|nF2ZO=27L|qR6 zewz{)`ymsRE^SoTghWfE-zwjXKEgos0r~HEk8B9eC<4iWQTF$_-<1B}OYUCcp8H#Q z;iaV%ANJ!6=l1D2OyBRt%G}OIqYUQ2zVCGfly|Okxq#Yl7g6N9uj;Fpoe>*aBi?VG zyFT;2=-cdk-*{yDG}glvJLkk_S5sqeZ!=>UhV6y-tud^dFVlm(v9a4avsTNz$ilQl z{ZR_Z0$D9F9@%an@RrkZJf=9E4Kovwd(XRn zb1iB~SsPT<&6QhJM}-K1h!k55HX6n;p}F##v%jJ^wkA1|qPqK3sE8Vk z(c|%HJRV_TYeBOh5=2USzY?~(GJ#2kVk9RyjgZR21kM>p3Sg48)&bZ_3+D54Nc_$l z6Jv?K1WAI3NRA3b@YFbvK^tb4%#hKWn1OA3CKUM89DpfLK5)@83msJ zVEQOnS=RN7f&_6%y|O-^A^qi>6lK%!@JuU4p2$heK@bqdg%P#T zuPyKC9*nMwVktYlm>lGaU3to2+T956v!3T@#`i@&4P%y$6XT>tP^A=b(kJWtq=Q&l z>uDUP5tdI;wn3@BlP*IdsM^9Yl~k^@#G2g)T%YDy6B8+=#z|?-WN?%c1e}-%N;#Vq zjDSwP3q(YtVrFK20w9kg5uHzGHm8&G?FN=#zEmq*t6}O6xC0gj2zPFT?qF}ShlsW5 zIbXR0*|_YGkvV9X_xQPCi?-v6J}($HX3?1Elu(V_e`L5#4zWeU!FZ!?(aIFe%T9H^ zZ=%+|)kQY9K~Du*+BkM;R|>M`y~|v05x;mLc_)4Su(^j#AxgxHGj8KTch0kKz~UL# z`tx!{MA?bhZ>ZkOh}{Ha8VR-nRFjE7dy13UsX-%TO)9RKfW;YhjtaH znil=s`i4!JrO(CC!=dDkxy7H<+1Ol?GeI$-DEB9>S5YpFR7HzpZvLWZU~9h8z8J&= zmPiDfxv;JfkFLr|UK+^37>zma!($=}rg|Km`?7|YAcIeV{H657b2(FGRX1!b+k5QeFi{JiYCcAo>$uMnddW< z^1zYveN*fFDcPdM&QnfK=arvYc9ld#s(emI7obR)Nlc9QBYm<`=0{3>i3#C{+6$lI zH@A7kWw+@wi{)mbLgH0~c{>{m-{2`-t0ie&Q3P@45RkSlJ1(|%91T`J=+d?nf+RAn zURkf%AWPY-Ntd0uys!&c0Y~Tfa1*tLQqKCr_lEk!DQ3g+sKi;hL~f?I;Ykvek>p8g zbLJ@RkfVEHX#z=#OoQ)sHVkGxO-d=!nxCFV3H;)ul~SXW=jUfIlTwQ44B%{_lw)Tm z<>FZY=Cjspt!7q4O32UJ%$NrZb8b9W`!Bmy;|*Cyqk#MQTLe^X{8@DnW$<33?-=S^HdW;qyIT0H%d z_n*0u-0+(7oOv{FAa=jy3YROCa3dE78J9noUww67^7{q23@rk^slx9Ev?tBbs6sTD z;0qHe>~L}`?ja}0GqBjmL%D21vTSy>WhJMtl@{{>d8D;~R!9;jQ#(kO!0K+!`SdHZ;?I8iVO{aUjCK9qpJ7Mn+|aJ; zY8mSa24h{j?vc$&zntCBtU%YTE3jhi{CS3PbmtCUSMd5m;={u2Sl4c~E6_bWpu>au=EL#N zzL}0#10d_%V0Im_t`1vtI52GI&YVD|fbxk8L2#1cSTe}X_$?3zx z2esO6g%$Kb505YF$}ig4@G({}$NBv5_|P35d36@r46Nzj*gqd@eB#(*T~`2yE|9AJG9J;RS9tm=U4KEP+ zAitUJlv-c7W4o?c9q3=Z3aPv6I(k_Bv|7=1-MYFd+jZ!=18@NR!?$)8>tS_|G&)}6 zYl<`O`9MVLif+ZB>*(>Zb2H+Fv929Gx>@WF0RrgJ;mOqxX28Uck64jjO#a=)9oDXM z?}o#Q)jg=In|&cDMtDPdN8Q824}U_P{*`%Q zd{7S$cX#yIsh>)HI9U7g;g6?>aRQswFgiSR>({Wq`n9#|`ojDT(NB-#`PVQ1;`FZ% zclW^St6yhdfmgh~;{M?NK79GgT@(S|O!Bb3+Eb zye_Rli2rvVzV|YE_9LDB=j*!x^r5(k?Z(gk9`^&%jJXfvb01FNkY-oo9Qtxd2mkpY zn{`7tnZp5xS3l?dR}AP65hUXNHJwEo_Sc;e=)>m*Ptl^hTUpCzkHb9<_d_;khF2VV z9FXQ!I{qt$0}ewNz`mG-{T=QP{(SCV)4OuOaKPc;2(yf580#_Xqlr7bEM-U4d=`aw92BiXK0pBmWj&JO4WGfUZLq073kTTPM1F z5!!qmRq#Cm=oRP)ghS_73~T^2p#w3{k(kEmPyb|8-NTA??N*>WcxcwG=nTK`>TuxN zVP%VT{XVgJE2sl?syhJG0qY^0N?7IC|38Ny?*QO|9zPJeL)X|ntN^+@zw)o>9H8NK z?N-CJgA3<#|P@@k<^Eg9uAMV zi98# zDyy{z#=0_AbXeKi2Q^K{Papo|rz_SDE7r9G9x0B^+EEv`BJ3ct+x_sGuo^l%;^CpY zJ5WdTFnv(ps0Vrg9f(Mg>f|Hry1L(4akvAUfS#HCJhvXcJUl+EcO72b7pHFbx> z_twU*?pF9m#Dh`cW*UP#>O7u4bokx^Yu9z%19crbtn2D9E_I#XRJ!9~MQ1Ji44Mb35BBq{pcX?}-&%*9p~8*WGy#@1DQ^pR@P* zk(=4F#7-(1WL&AMJP||n?1|v#Q^@im_=Rhe7QJgAp|`N0g;C)gx`V!4Twk-KY}GR@IcuKgok5jw+km? zz%hr-2jL$#`3Mg1)4D?muAR#@yv9FA{ZIXaKvYlB#=$Zip#eJ(L5N4Z`g20KucCoy z8h(op0w)K!(|*D z@CeW&K|I2-U_3t3gM>iyNaEGn(HQ64gAkD7g62GqPr%b*pic})escf-AOJ~3K~xVo zv$H#Y)%Jq3b&k=K_@AE-|NQ0hpO61HoWpKE0o}EJZ||=_(*clsu%k!u`OnW9VjTYv zfMOnmc&0{c-MM$~<%eCjzg~COra{x}(d@6y9?c%ts|R2n94FXOz_RU3c}H=)MsG*8#-6+Q%L z5Kz>9g~kFTX>d)+%cchB@e217<~X1G;`4dc5;!YX)L+>(;kj!)<`v-H@Av!t{(7C! zT-OWL{ED&P6`f!7>m68J0(}9fYIG*B*jkfaYzR= zEpUyqxVXkL^mu=hi6uiYNae&3`}BwTB= zrt)nv_|^ntA}@dTdVV8)6I&h^MVfzz&SCc?lJ<7~z-{j~5bub9tER)v-d)|Y}+ zmdqd`CPmN^Y-!Y%Km}VhwK!(tA$%Zq zb}d*lQUSzf%kcd!?Y~fT^9#gGQNO0zljbZ*LrDo~vv%V`D#QleXeMmx!pr zvG+BvXltHiPHES8Lzzl;qkLdV)S}bLW2g2#t<6@pghPmGucT5R$*!M&mHbIm`|-pi zG6s48X$@mSBPlYECGyH(#&OWP*V>ps;Zj82Zifg;>(LlC{5&XzKAwY!iV6ee<7uRW z>WATM3~Q~F#Ar{az??2!Ap@z-yD5!Oz@W4y;A|KpdVq;X7_bCXuZHL0<;=gm9K!)_ zuifrlW?Hn}x&VIY56?sY^70}{4&H*%@EJG|o+yWO!F2Q_>LCf zPxZx<+F|xjnG2_n_CC#~EmatQ`A@m>4@e~a?hR(e;@{JTXkfcg+*|t&&iB;~H^YU_ zvxeF{<8vgCOtn5^w?!6T5!Tx&wj|8S#HhNiu41geN!o6U)SZtWB?~5G zXkk|ijSsuHgrYGlwepN?Mo6-y_ChizuQ30}S#vkJEEKk3l<42371gyF z@jrWfKqV6sAa7tC;0<|i4vfq%FE7XA%h2~AEn~2fr?SwJ)1>=Pih=Pof}k`h$e_dl z)oaDDqw$?YkwNZHW-N#PKN&l+$}U4oQUQ25zWjxrgZp9%Ik-SQyr#91K0NnBUjm+U z!48e^pRw*@&C>=;keUdRc?1P<1K+C{erKcwKbg%~fXJ#@RFbY;>xn9@2FAi4XZ!x6 z?yM}X{T!3LJ^#?1_z z7=y}D@3uAy0iZ!kudox^?t*-H?J!Eghc8EiC_$zLB$$W@RFlgKx^v!5r5S4!uqWS* zkQ`Y!0%GEV&y8gaP-18sy6^JPZIB7!g*i-RT26PKr-eRdEk*_%w6=jyZ+<_r*2F1xVxs{K3<`!M zdq+_@j(|#no!;BV3pSb&XG2Oe!H!_iaM1nX@M6Z_{?khmmD%0e+is6`DhbQQ``Y&| zk^=YM)D@(Oj)MWiNEklC50n>b`O(?eL(WMJHrf!Lz3-|7+B9oSH;u2!N zMM<3spw@L*dd8H7dT(NvDRPU`rykmj8oLVKgllRSv}|N!lC~5Ep0?1~J?p}*(ARqd z*G;u~#rop9)i>wjSGsLfiGnP!$^g%pmJ!7pT=K9e?OVXVMA%))v@gznS32Yu>E;Wh zxI(vGx8eNP{W6(*ecCSZ!l!B>Jno#jw~p7A%R1Gh{Rx=nB^SE5N4jOk477PzAj7oT{PQ^Glwy8I;7Z|$WHfm})# zztvMnLA{Qs)UEc~s>^{;&PLhLaTb0wav`0OUX&w9kyhTHLcww+^+ETrI0-03L1SJ+cH1;mt`Td!>mqCrLcNE*y25ljC#Ua~OnXQD(B( zGBBPA(I<@vfYSQ2QUDptBjoW!3_hQ%8l)POH}HE_+Doc=!#@Df7OW|DX2QZq^DC{Q zL^z#~41OMl==T=i|0e16We`n7sa4XqY)Zf~!LlNZEK5m3lsw4OI(KU++30tpi)W@MeE5mdS2LPu4N*48)+v89uD{pH0A)2 ztEA+{LA(c^pSRI2y$A2@-4q5f6AUk9EB#_+9B**e2GDeWv*bbM^tC1lA{lo>g!_z9 zLi+{N?#uK@n+9y;g?3KqV7FQHW~7gIN+O4FJXf;L-3H zcB4|n1RnV?^Z<+*y@b(pyEeOS?V=*kzCsW|k+KZ!qZZM*rCHT zm2bt3{9bxpb~S#k-qRU^F5cHI?q^l2?zOpw3sZ+K$@GOJ;RXinmTunLt|L>`AB>)JYxy;QcCw~pLlyPG!Upy_1Q@-Bfx=pLT`LTFf#3lKbQOv}KYwf%UE~ zM09ln=<45d*?zYSx>l;?h4x&BH#;@E4Q2G=I5E0S-KM1z=F087%^Eb-Otf)IyE1U< z(yst$@NU0omDonl<-49_%zaW(wWfQ7kE~g-{Qe3BXC^PP|^yJ-29R}Mia~ky!t}FPVNGVAMU~Ijgu8mig&ZuL~ zm`4kYv|y?rBSM7Sa{#-Rm$HMzU^XyhC?wccpk}4^%OJ8G63(o&e(qIIG%`jDPL_mV z{@oCf)b#ALW8UA*5(5h@kPx)kl7C|Bl%_4K@C2Ci`8VcXYnwy^0^+mL7}y)lL<=7x zZ!+v@1~x7?vb%T@FKxM-dvc3c4hdU@R46Ymq~9QeqBq7|RawMFmWjv)U1KVu%6n?T zd@pz;BBeA31v0yGkEWFaf#(4bC=; zs4Q8_>&P=#CC+n5yMCA!3@|Rl4Jl*j2sKxmZ5cCdJag@G<0TAjjY-a-G8Vt!BaHBn z(afjubQ+D3@f2wX3|bFb^B8Q74u>9qIT?U;$feUrkibBs4vKqieme%85DI}>j3`KH zFAWMFy^{-BW@hNaK)OG^j5wMDFi0&A!x4BHPsh`Fwo|*4rJAw-?<<%{ks{?s9QSq) z062!E3hDo$nQy>sN=|FVlJ(fu`(@2xn19Xqy-)yL+k-EUzt&4h ztAEF~r`sU%{N$EtyF2FIC`CgM;?FGtPqshIn>qL+bus*Cll^B~1ySuXs%vie;ePD! z?tA(6OEf^aRXnAtLcLX7<$KKOA~P2fBX=+~r5E2Im7-NTiZmt0ZdDL3jmB!^XzPSn zk-YK+`2g=IJbG!f#LgR8y~HsE14lN!&z{9}72Du|Y)s*wV*N{d^m*0O@l2$2PfTRa zoNQSZ92$buiaZ0D?=iuNFfy|Nbd@a&(A8(W@*7=7VKN^xD6I#g!Hd>~@_X=n3ky4% zzYK>#`qGGkUrXEy$b2DzG_)IRNxEQ6309dK;o4G-jm@D+0{Wnnjq)yiIXkse=Oi>HE&;iSde_1-x ztqIU6BkFbN7J2TCY&35b^EuTO7Fyq6CerX6dhY~;WzHCcsDMsT5^N)Gt}yzB-db_u z)Iq>LzbF+5uqult^P0pW%R4#vn-s#?1-G0e$psmPM_U?Fmj3oc5>gRDdXqsBz;ZQI z<`So~DYVcM=U`b?C^#Qn654nX^KiXbv|z3$=v?yUU>Wpgg>D_m@aFS0U}#NJM-1(& zSV^AH2Q4E=$wNOJ`NTOZp7xH_3Q`jti4-yO%kk`)(p_`{#qdndMIXcl$4ME!*665i(4;-2m)v(&w45!+zHi<{6ooe9w(}OQg2e zbDQs@gvhm=659gV{&3SU!)y8#3S85)1*FO(@f`T5OM|&eFR$Bfy_+H+P8YK}-8@BT zGS#Go?hdHyDl%@Dh#%e0v#@VvbEml$uCC;g+ZOX&K;Ldl`Z^vzCnSqm@oC6;3(vO; zvO#+{=2;1?)mL2eM!I%|)~EaPlT4@A4xH_q(76QH3toG>A#L8)$^N$97425cbI(7t z!<~?+t#{EB>IYNSv+K4(oVtEA)ufkltri@c+WDx>|5HfAxBkfhcLjdD$NoEZ%NMgx zfXK>4LM|~|fgtav+t$7!GA4EG{mQ;py~-)d8qk&)8X2%!%NQ+`ObKXg8k{XV^TK=2 z+Xvq9Pvqt71f+#5oT@y90i?NXd_#0h@kEdGlFqGLY|h3IX^={ytySkF0lFte#LTu# ztS*)yR?I0fFc(G|iSHoGOsrCeA;?f0#_z^FYdsK{$pDsYO2{2P^`ClOz4CLhTOx44 z$!0zPdna#CDUs0}MGptv4tSjlz(G(5TBF5sgD%y7@83L?k46*Fnp6;Zs*(T+4oaEwQ8^lbg!#iCI&GZ-t`mkdA*0QeF?a&H+806mtwoV^Q9ncqZDy)$pB7IcqB5DiSj2?D86*idnWo;y z(D|2_34Loy?^Z7cU3jX)S7HKqXKx0M!$Cb0&d1a80dFCJL8)_p(tb0u@qXoCGMY|G zYtZQ9SCXs~toQz?t(3lsWDaSZ_empYbTVdTVqwcAVRy<8YDuF8LBE+db8!g_?x$i+{R% z7qTW#x0vU6?emJVvM9E!PSCBkO?wBmd%jdR73tx%#b$Ouy@cuo%fB%Lnu;0}f8cUmQy3^jiDTjd?WN&9sc**5Rq=~}2WL5N*smaE& zDWy8VK5N%Y3zCq9VT;85E-bd?_~p85Ful9#9|Sgmx4Dj(!N2+pq6`VL#YlETkQ8B< zO|^1nGoBc%N$27@1LRZUl6o3A6BKxh1wbHzW%wd!NE7nH$srSYBXIfrY52!OKQewd z<~WWoXC~0+fuLzTBN|5Y^U(jb*V&r^#L+o0rxYoB@MRQWIY%a%hQr}6hl4dZS&YUI zJX9s$1PCb$sGv#p6fDRY*^nnx#$R5Jz0%%J1wq!qt}?mnIF0~}zVtuNnYE48u+R`zlhQbR|#xcy! zU7S@_Ylw)6L&>1L8U_bH9Ull5vMg+fG$g^=WmYu*_GY#{z#&1STBG;M^3(VPOnuP0;XVBg>GKm)#eM&L=#7 z>cKdlPiX-D&v`UFj+%27i;CFq3_xiaqm#4Y6C0RQxcd=lSQ5q>HaIISi$H`KG(c-2 zMo(l(LlaIsg2v;S&qrcDKyp8vjXj-Dl0NLP`(}UqTc!TDzkcq=^ULoi^nEs=W%e{E z-vp^Ok)&}n^W}o7!L7v&xY?V3jFODg868t``@uWByWwYf(O7Gri+nJE4%2+smbpG+ z2TaLsW1i4<6|k!yZoBQJ(IOatmyRPf2X&RzTLJo#L%eN6IB&bL+&kbsK)IknFFZrm z8OjX$rWtn?7%kt}Ui;?U7hF!j*GBZ$bDKbLB1zqDz=>+6J)g=5!Wj z*X^Q)(A9L2ZY#n3HaBT=%yXO~fBfQ%?SdoTEjc+GcTD15w0Xeo_NrG`RwvZEl3BFI z_Z5k`UB)L+5pWo zrS!mv(PrG*4@ACgG02H!A7pPVX~uCheXk9}l(xlrCq@pw^u~uNF+QSn!;2DzsZ+Dc z)siGl<`hz`c0oW0O@RJ9Srv}0i3cN)wN)CLx428i9yKzMXcmzluRY%FqFJ&AwX`NN zg}Obb(30;Uu+;ol7BEy%+zCnMr1eoJqir#ISzKdjUF{VSO&O;r&PnJaumyuhk~aqT z=(&oo>xq)NFi>b;M5A(FCMdc@*>|u7DGz1~j-zMaY2cOC7`IM>C2Qc18N!rQVp()f6lh|+5LfhJO$*4kM6V)*l? z9+pRA09NrSbUdEVCzE_nbvGyfZ+zkGf^5Y8_r%4G*8Dta)2C#f`+Pi9OR zyO8|60k@k!`(Zc$7|n^}jh!aXV!y+6o;DJv6*QQp73i2EhQ0?RfGN{2x(Prxb@PO_ zD?132*IEI-7OYBWr zv<>9+DWaRHn)$A@YJQVL-nMISxCI{Pl>}k80WaHjD?9tJ?Hafi^jMSVyOdgP3z|eR zq&9KT?`a6OIpmmD=(bxW{_|Q)TYDyLjTL%E`OP&crCl#X1g<Ub|76=&)r*xCof; zka>#s-WDCu&6wJ@P}dbX=2%$CM2@;KxQiKR-~*oEG4$>VG`KCHb0KL=BViLm zm$cnQij)h}+7+XNIj5ha@*5|KBVW7R=)bc0y~BlM69tllCTSxFG9_ErRAx$oX3SB6 zY8&xqap5R==T&XBl0Gx9wAMtulnCa&7D#l9EKf(Il?F3u<2{0zD+~<@vW)R~CL*mA z17t_UMyO5j&xt$`xFR-yx=@n7SMd#V_dE;=7=ho786z=;+5E?&AsQq>Y7oeaZP-v3LU^V)i%lnN}Z|+00i)6Vq;ZVRmpq^FOeLglnlN!JdPZB{W~$nUSQ}& zZZ+$%Q{PK(M}H@{wMK1BS~C!d4M!wWX}+?Rci{@&#v%r^e|Zx zEc3{K4&u-wM?pI;Ar*;4rA?Uh?@2Kx+zIG{lFQ#mUbm z5kO}iVJ+Hy@t(bT*7Gp*pZf!kHX&XImjC+9y=Yo&B zko8Ek>8?VbQ_1d_=M89CtxIm*={vlrXwt@%clh+rRe;e@1&on zGV*NeJa$^asf_>HsgR)Vs@hAbR5(oyzI?&c2LO2b+xOqzIeVKe$L7aTcVL zF$taCo@FtTSA}ybnSraf{I&{*j7e0I?0xX$Hf4mP6GMqKc(lxkbjn-6qLNfbS&e4^ zUJf`zl(ht3&^aARhaR}YFa+of4qSq)V_S&K0ZKzl$*^ZlWU5>@rHm7i1yD1Fl$UiP^fc|vPK-#E6J#$3=bd-GxJFgS`iUeVMS^pjH$de-#Y7t zOF)JRJM=oG8hx%=QsjF`Kr(EgWGVs?nG_u4Bbst+ne+I+kG~zBKMks9zy^_KTMd}Y zVmH{FEm&$I>a*T<_$8lq9OJeKHY&8hYdNu-_!Yda!GsF8Cf_Dyd6Zg7lGbE83dO!$ zw&amoK_OVlKUai{*iKN{krX{>yt4HPtYk(N1}CQ$k`C_Mlh!C+02p@~n+N{7WgshPykkVSeMC0`?B=m6v; zg-?2xd}xX-F#eKPzdUWN<5LA2u{9$Jxvj;0IAmvI@I_I1CYKbL&!yOVrL1=+T8={^ z_8NbqA!v|BF_~USeq`etm0!$BYpp;;gYQ-VW#YE>EF)tqSZS>!ozExIq*TvL=kw7A z^!_QSVHGJ0GM3rsejuXLXvQUfr`I$PpGF301v13O5QvlM4?vJoYem!_tp)l|@^BdJ z`D~5x`aI<2fwHjR7@0N_02^R_m(^Zz+x=*7;9)rY(T@pj&Kx<{?3Q^ixA^~AChv8G3)gKs+1%-iw7R83Z5_m&-?Z}V{y{+sX% z{FXO@kUJlq-vH(dsfw;5z*G#J_KrMXUGd0_>UQg-Q=K0dLrMAXgR9XsT+}5>}wq2#tks2Esd;q?E!-pq)`+^To`0!1B z`NIOuZg>50yWN(i56dLndQtpPy*puP>z_ud6%{T~1TAOJ~3K~(wL?mNX#BBKZ+i&*pEVY7G0pZ03tr@;xK9i=QKakeGpl#Sx8B~sD7R>A!&xW8aM*_eG zdd^K?@hHJn(z61T_oF~B>8`m^4zM|M7iu-?V$xRw@R-rllAru zIrMuBp-p#~fciD5!;s0up7*3dMixGW5)uT-)&e|^BXN{$mcC*{OI6BD;gBF}P5q!@ z26^UmIkJ^}T~Js9n5FMQWC}_kiPW+v1?9}G|NXI?_qe+0iDe7^O|4Z@GJIgcrcOo3 z)Gv{rRw=5Md~aW@n@BjNvn?Ao8d_?yCe+x7$bi@|#qh$MPTrfOSK8BAh?15#^}RA+ zYj}7j!;+6U^!=dwmzQJ7)RzE}9weZ(WE@As;9gT03K5Tn0UBgK5WwU41Og5R-xg8E zD!T7!IE=>P%!8JJ-eb&(SrZgNGhn#XX0mba2y_A)ut=}k+YPt&1}4&feSSVL|I_)1 zLiC4Vd^AH^oteElVAt)Y>9&SF-NLmH_p+{c74I@0?ABz6d0Ox@mLR5JP0Yo6z5!AWYMitVA78ywz^^E4^-O`b^EOsj>0A(kPs(Md|L~UsMf? zDHq$`TZMbLx4YZWHcdZE<8OsYshrVbrBsdO@i$q>?b~$cdQ|Nc4Jq$Sad+J&c+HE| zZRPc6R4s#*sN(cS&+RH8Y?rC`CBG($TZeRYS6fV$4Fzj?ko9-Ez4*JoN819gczs3t z0ci0-G~d2YyZLYS@5FBBZg7BuYajr?Inf9q8iX(X|E`jA&i|}@!HMOU{55<-)brvT zL<0a$2tf@TgmX?fcX4h9u>XW}5MXu=&NYo_h)4)Q1PBJ4<=5Bu5MYLL{+HN+0XX5{ zAY2|FoOA5bfSq$r>;xRc34ir)fMdXc9b3L!oO6N%Uz}*@-~UN#dPtOF>)>Dk2mxk5 zIOqH{`AHEFJAVz18P2)JIqOgD1mNJ{L<8r90~$D|A07a~j-7L_VCQE{#1TP&0O0@# z>lh9W^rRkz5P%>OkB{W|a{21mf!R9eoNI(2f)F@-ditcF{Hz;yvCbLC?s8!`A;8Y@ z_*FEo0>U}>NX=7`h!p~GUKnUl625>?kT(|%rgk$S27I+kYet2*Y>>LT& z!3pO8XX8RRu(NOu^zisdV7At80XSxM&Iu8=m$S~Vi4$-P^X1Fsa(Tpiz~SP55@+?R zV|D;YVfgs*HrKS@Q#E00MSGI5@Ghd?7)C9vuTL2r(4T}5jvWLb8t0tAt7tTYfS*I*ob&7DZ#)}f-Df=l1Zv)8sT;h?3{HFJD?Fl zkZ@_1g%f}f5Du>Kmtf)V9G7OtL5K$u5D#$9rJLWCj{$*V5*@H}t`P*`gcEQV2YP%^ zVz+b5E-jM-!#Ows;T#-$zF-rql0rGRXIM<1jl80PjFjz&Y0trF;VU6^9@a9tP9HYHe{~L|2LWlIhv3hV*k3S6()Ux6#;IezUwa4iOPjR2*M-)zdWR{&+7 zSuSs0RD%XVnzhYNSz%>nf|BHo$Fa=$+In!vG{C8s& z{K*@j319BhnH%iW@nb>;Hb2X7lx+hYpzB@23X)YlA(S zr2BCV=dI$A4%Ze<7jN!4-8*|R{CnUP-@f6)2jCUo{$I4O_#ni$-3>GE@L|8ZVt2ct ziD2377>=%)^`0&x~^pu$CP=fCTB`36CNGe&#P{1};t@peJx6NIWXI-P6Ovr>7?X zUoQNI{mRT9q$cd)tV08k5G0!2?&HJ5Vxc(VPUk#kY=m<{c$knd88cV_>{z_A()v$A zum~e}PLLpmbu64<=bW<)xc7wc_IDoBg}1(Q0Veq!z+n&o;CM7&zOZHIm~nCL;vAg2 zpb>u>{`B$F)6fsi!vieN?&A0>$Mp`NM1-Ys&PM8e$Eo*0 zs#|2CGlnKKf&f8JpFWa)a6SxZ&N)01NcgB6^ho0Ikqy&(r=Ol6@cO#jiAQo5$L?ZBD}=-4GP1i| zNZ^6Q@bTjVk^6FPL?a}Tco2^SAx6fzeHezP=Z|c@d_7*|->Juea58_K z$BVO;y@(X;g8GL3-b@iA4OX0&wqFLU!OmHJsUS(Ao$`lEpWIn`?sDG!{dV!kN@J> zImf_jv)g%$H!YEpe}iAK#JmxIT=(H4&0X*sFhs;L)6`tAO>_15>sla3Ojk6!41=!M zi2bGtKu=d(uV}6T)HXkZ#H;k`HI04)A2tO(_UXNSyzFcEX*kN_01>7xkJ@Hzy>IgK zxcAr41k3japHH*ewylqs z{NEYP96)*7bb-#%06uI$M$cggp7K#9@6*8c4e$l{007^<;ajp(d5@>}z+Q!6+;0B0VL+NH6^{GuGt15vN?N;A@a`5iYA9=;2x4QI!@Fv)S{JVk zgV=zQXY-nd&5N#i0+G%}DiVa??HxZIn+%Bwv}8CgMGY#6u2QnvEX*;8B-hM`AT!G> za}%0`v}|qEHdrbScugcr{%I%gC#TrC&PoL zWwn?fIcpIZTC$@yKk;4mv9qoBEhP^gL46Y0_43zflR+A;$YFo%m z8YY5)#mO3m)}#~>dEU$CL$9>9fHBOLE!Q%}>l$~qhx2xiCqTpU9n$Mck*!jP@b&qi z++vwC?N-B@v67;bZ*n$}EE;*^LvhbW+JdD1S*pQ~Cfh)kLVnDk5vm6O8@1A+`e9Ns z2;!AVq0x@))kxA#e@iv5VpNkND9V)i)GZLnOkNy*X+ob!^1hYKjyQoZkmv4fbD*m> zK?0;EucwTndo!;V^EQ3E;FvMPoJZ{$2SF#2OXe^KBG6hCzp<N%BGUaq;ZpZQ@R) zuCdhQOnTQVP4PS+3LfLBahk&CW!S;8vJ9oZ?=g;}G4N76L?hF0FXwnLNqQi#IT;w^ zIr5S~pk4!?m`>Cml@}EB$29@3=Ci>db+2Lgd>kYD#u{_h!+|vMiGY#x z0sSz(9R0Q-_D(+*lC;(uptCtyjDZ9_t~)_JxubAX2P|tfJog&MBYWb9MeiAOYz?3b z+3=tl6lZmsR-EE#ixs@I+U}A@)~`~cyMkN1E}>6_7{%I~eA*%?Z|eBsEpkHQmuv`+ z_yH_MBnn!^PXsYGdkNp{j+_@qMkcCGzhHcwuc2G9U&>ZDFZH)-A8h|Mpc%EI^Srv4 ztnR$Y!q^l%`By>r=`JUveS<5qwSnFeVeFRU-B{FuvfQ>?`=Mmn)RdLB-8xOVzTMW2 zYHP=!1@*pri_U}+Jx`lAO#^%YKH$R#eEWhAz&C_E`IqnhC+|Nz;Tx_u?B1c--*ChA z2W~r?&FeClq2)6>y+>JQgdJWy8FVj=Qc4XhPe}%R-zp z<&6&eK`X6CW-~@f?s^e;-F#M8}iC@9vFo6k9=UQ0TuLI%I)i;xB$wlnAqhWGchT#Dphcv}c?Et&y0}mdhF3nnj602RqQj-!D6% zdBGYF1a=_Vy@1)6lL6`2Z5RPE_-+_Mt6{8~K2SQl{KCSQPon(vuy2ciFtUkkzQ-up zDKT4u3Ljx(7#Ou8XzgQdW`<$yr$!T-k%5Em)j^%dvqaDv9i-NW0~;QZVDmFnZr5 zI}#DjBaboSGd3@Gm<^?$2SvslN2AFr^3gy5_$9t`1}z!-2pD4!n{W){-8-ylm}>yh zl|XZaD&~7wd74UkriX^pJ>W7;_t8)Jy>5w$7M+62#=%Sy_SPj`K{K5)fwf&-+PuVL z^RFYoxt^G5JJiS@neSr1?oDtw;Vmb>X%pOcZ%V3_A8hYN3frEAZ@}5^&hkym4cBds z^G=8|7g8H<^)+^@rRjdoOYhRQoQmI^@2}9bwHDomu1Nb+9=yNUOJ0LHc}aS&qSQ5e zLHkfhZD7mGeZ~|C(^ER+oJcSq!iPUR0iMY54PX8MJeUTaJnsazZ{M%C-41xy-FExi z>+5B=!%fJULLzuSC+>2<_;UbF+2N6w zscs#BD;0$uKmWGaZZV3A9h;`^S@Z@fAoZ+<0bt7*KU@}kP>QE`OHr-*=(Q3S zpE*foQdMinBA&IZXR&C^r8(02QOBH@h3^K|+n()tD^gDPuSU<3WEnHl4W4f6p+ z#3OU83rL@9F#gF#YEYWU_}UwA96d5NnzUA=n0dsrhGd+9-;K36mrd_+!|awB&d%r1 zlDo(B^YrA~>AwturwKm=Sc@Y}Z{@SQ33nR_i)O6sZ-+vFdY+b^EU6o7DlUAg0*j@- z$NVOSj+ZvCf`JZ&{>Hq8Pf^4k(-uU06V7Klmmo?~`wezKLCL@JrxF_Mw$|&OpLRKh zEw_ziWm(B-srw-q{uF?Yb6rD&?rPW1(C z1x3k!K94h+*G~`8weX?7gsI+8r8Z)lGSI-cFMtQqPx*Ww-UHu5Hu?hsyW_+A8*uyf z9k19mZl28UwVm4bcEe5HOP<)Orpo3H$S5oYw)r2Fjn)=FB)K}HM1{0CXjm;py}}>e ztLI?=B$K63v!lX}HykvzrPnZlIjcOsl{2cj5ww9mrG&M-u;WeDMg|By>4Q?_b$Ciwv&5Th&WIq}Ab>l;Y9)iH$4^+D5BB8%h~NGh2eBK||{3DU@PaL#(qZ z`=+`j)=BIT$TAAkb%1dW>cAnFDt+k1QI1W<^|8#%hG-y3V7s)!DQ_G?f9Ma-pLpb` z1v!E^qGpZ)8pskFM2qTCsgK801wI+L*CyYT!?g5(Da^{*Uyd%YvGwRSN^tn_CU7ap zb2IEFr-TWFl+*Xogp9D-Kp(Uwn3KtwYlhb0mNv|urRAgh@jMds{j-K;4TjQ*v1Qq) zez2@D8g+PPkUhSDM@5oAUbGR$jL>ud7~{!8dt@DGAIwnZ3{v4KHd-2>wX&l$V52nw zWH<^`V`LjDqW~bs@VW`5lF`Dl)mr`K`5A1F$KSoL>nVCYf}p`YgDn%04L7VUDrrze zo(Z20-Im*a7Uaa7TFOHh>L+2)Vz^qUfCu zXJHIa{o(J12gnAnUL=EjLzGCpjb4Ai0fGP*`;g*~i5@;`Eksaa@Lfzcb~HKRI}d&T zn}{uzMcrapR@bvU39@)9C&OtbW5G0sk-338(K?pbj z(d#FH=EBy6J}riCY1_G4BL!~fE_e_Q5A^uZG#BR_*m|V__q9-Z2)%_wFgs^osS(1} z?NOeB>56VH=bXdEePsY@&?Lw?_!c|}=f1korN>cL!Z$8CFP;K-ximsN>IXF7iy__CHNLVXZ@V})=rSX1Cj29esCVoHh=@E{^RHWKu=GOz2t}k z2?zmpeq#YH9LnDyoRv7zm3sXb0RhYGF79%14nhbBxQlBDqIrY^GpD{shbY)0oS$~L zgw~G3Ljx|bXq3RtIp-M8Tae)`j&{+G{x zcEH#10^bhXkh6{O!ast7EQJtY$Ih#I&?w_X;BV`0<9=U_2@36YyR=`=RrKay!_`s`0@ZD zz z*zI;Z%&GOPZacdI*Lm5hRlK$<{fxE3#SC0A`%bJT;D(}iEA=V1U2_cz4>efweT4fa zj%y!!$>u_k!T-)4z!h_7M8tIp-}lX6*Vxl|-CcbP<8{In0LL6(I+Sl=oYCwWH_h@#wHdO;?I8^>l+xUGmUopjoRo|%EEQMe4Wi)6T?16m>&vv*@ zxX!CY^|d&r4@E<>Y?B-Q?!^*w=oj>3X!ra571#ma0iY{pX76vV-L*k;y%rs-1vWrU zyQxKI?e%uM6-noUn_yS=hCw~G&Iy*OXx~$mGdq-zl#a%03Zq?S6bbok#Yh+*v z5j|ztXjO^zW3m7#W|ma7D>1XBWQv7sZIQK^`A%ka8kgB3Z6y*f= zGvhN>Y#BJdyc|hsMWhEJVsk>-0ES|D3Z-37Ac&@NDA@KP`)*@yPgc~0K={#`P#dw- zUf5esJFAYen9{akgmDtN{6wNxhJD+|Z<^wRzSV1FXj1kLePNx8E$xa@w!2KB%0SLA zV@Nq?e)hOXT?Yz+91j2RSFOnyW6tOCWc}<)O{6K*2Z&@gxQth97j+Y#|062c60!Hd z6lWeo;*-dFFD4aDfx>SRFN!XUEfqQXA#<;KNn}TZ!eA&QiM{wat>{HH2Y5Bvfm1RZ z6p=iiN6tpjUNzYkoez{3!55(TZ4*LHl$l&pWAOH9Xp2Z49$}uk42~8%p@b1hW&Wuc zNkJ8_h_G<0bjd0H&~Z5=c&v^rk=#D@pX4t7}NcPac%BhC(P@MORZzm9VS9T&$!#RRvv0D zx!~;<(Yf8ovv#YQ-(Y%&YiSpW|KfOU+s!$rUMIc(|8hWno;=?sfOo|h=Isx6k>%XY z+ccr-!1KIpE+1liDlm)}ihw4;S)Vk{9+ zdN$h{pK-zc=E_v2Vrdf*DW!-G(z^jNa|tt2>D@aU6n=Cot|iAVFLU~#7r0q zp@d+N4oL*kvShE8Hax)4_kG{5D5*h z%OXCXSPlXF$SptgMF4llx;pO47-5o<1naHeNCo7|w%}bb7^FTO{^2kBK$$I1%G<<@ zC!-IB22H0TL|6hn8BrI(vmwIsXaNbSa8>k+W@#WcBLLM8PywN%*u*}5mVw5=78_C@ zq?CFdf>~kQ*u|3|J18cH5|R=cU~gd^tgp-Q5|Q-4%kUBB1y?-;XlXPQ<#<8{fEQ8U z#+P+yMqETi_48yIAaU^>qKKjIIN!*E=`Mq#{F<6X2Qc>-b!XxGP`0K-_;1d!}|t;e%Dg;_cS z44jNDe6^qnq!j~4-=7HJ-43<48#;Ly)L;5%YsMFIDnpj}Hg&sqZ)2sEwMw_Hs@Fb# zD|m4Sp%;B((>9ikl;*p%h;GW}axJF0L_#evdpG3>nx@scx^3V&)g0gMR~ZQv&YR|~ z7-Qb%giLS5BX3&qZG+P39_yl**e-EA+DLNA0v~TNkADqTceqcokF@P}K_f2lZOJpK zO@1#c>VTn|E}4;yWMcLKW;ZJy8c(ZXq0+k=|AaFUy3_f zkHaWqYLaDAdCR``ev%gq3`!jaEu;JwfXH^M^2BAkB3F#!%xV7pbn2Dj72q!xk=724 z;k{?eKCjTd=Ox&bZ)}GibaqNxp_G`EUJzwN>X1VR9`l_9cliRg)%eS>gvwqdJDMC@ zs3Z_#J-Jo}GA3DQ8coqJ77-aqjAm(%zF@M;Xql}0UhBco31?dYC9q|d1R@=0n6y$k zKWzbM@=n5(wc{+Z%3i_tE;HOU!57(g&A*Z@s8YeRwTn6R)c4@A+UI59=X))!33kmD znVC1}*x}bVHhMrMzTHy}YWM_(rBkYc5X-!^l6&0qv+gyI9IhtdKM4TVGFz=cOy;z~ zQ_c?^NkmDLKq5LrmW*fS3WYKO#()@>*{~WkDV@l;!6;j$S_e>!9)&iJ9JC&K_8np) zb0&2Mp%c$oR#cgq;%IHDr^sMHX-$xfF@4mGR%<4y(>4oro^UjoL}IwqRM`N{yj51> zvR5{C4Mv5XECsoWppuU`X|S3J!?NmW zv>b@h%R-tLrC>UN)q%7EP5=`rNdz82niOe}0VrgH5ftLA?=FBftPeetf;4n^X43p} z1RyE&#u`9dh5?=>w8Du&q&dpu`7Uc%f>K%q={>~rNLUN%Ne#-poCgp{o&ilnBLHa6 z=SHGl$15BpNqw^Bc=B?SJG`TU0z3iON%{AE|Ex63=$jEW`BaDZtnA!w_tR|QFYscg z60&c4hR@jwIsLqwfBm#8B5VN8^E3fnyU@eyx{SNmLL>_Vx$c))yen}3Hik|a{0-5J z3DcBY+`J62|8jc_?S`ryrk|;9+yQ)TcL!ci^IH?~iz~GlOt+B%MkzhT&M_>%?Cq%w44kRJtQ+9XT0lRlzbURDeeJ^yNi;VM!0zCu3`@rn@ z=E3xT#fQHIKH$T5eDL~r_;LFN;N9+BBi{YE-mVF`l&v;Nlf&n+kkhdRcIK?QwOQh{ z3`txoiQyitW2-t!J~idNa~BnPEEi@R$CvZ@pn3pgd5nl4ePjuch>-Lt zBw)vq#&UQ*Joi1b9Y+|jlG};L!aJImRpaOv=u_ExtvdJ`zPv3>s_r&ukgchM++- zs9p`d4@xWtZHV8FHm+nx9M>tX}7};yP0Gh@^)DfP}c=A0nZDt0c%lS2+%C= zUCK*s{S*BctmVB6FXk@1C@%yI4M}k3qFau*2__0N)hsf< zGxEfF&U21H1THegg-IU)QH1o7vKnoVBLva$>eUg}^jVXjL=}fnAC#%xSSgSaJs0Om z)MWol^vw6hP;vySH1)%SmuDzuMUMz_Gk8ZZj5i`VzaCJC^r9paWX$Z-ve`uD7a@ze z;ImpsfPzAi-u1nDpOrV5<8A_x=H^62slJNG3KZ(c?P<-D&-UJtNo zv6_bHTsq=L2gkkH9;X8y3J1Z=F24#WQycZS=kfW8_DFhqm*)r5h5o=CrUxv{+*eb^ z#|RhivYeOT^bBQFeF3cW6cE~p*3_!$I$PLg$Etx)tP>ms_!Trz9lc=8f<|Z>eQ0oO zy(4BAwH>7G!Z-v0oYBTg?<*)E&@0vkB->W{-U6oYNl0yA`%sV!ql!z{2{i$@t}paU zU|rXK2(N3RqeyS9G)gxVCE`d8+T<5xv{vXG9*> zf`O(ss<7iGadF53mlw&#>uqW}$rvt$rl15Rg~8Va3mMdl7-)OLEo2&|oP+rI@yjJI z&0kT*Xm3Bj3U8(?^<`wOgt<1Xjwp#$#%jLEs$KtdE3z6eRGiEt8%Y3y**4h7d&B^9j zR`xYJ&X+Cl1y{Vj;?+$!=GO&;_Se4LM7%dXWHOCHvTq2#^iY85Lq9kHrPer|&%h4n zQl=3+H!{`6DM081r1$&mAEzMy*zNI`dz`=HbpCk)aQgK5Q^ij&udhFUzUH(`Y!CO3 zdVwOOfEuF|Iss$`-~S-@fH+Wv?@l>uzJz)a36@mY+*Sh{be3pADGm;{3f>zwIYqSFI1WMf;wOlqy7 zt|ACYIWm4ocDMdgQiVmbr}|w|Jc$1G?bo`NNHYeb6E(3yR+^sI&2dcul(@L2IqG z;x8LZu;t-UKm7V&k6qWcnZ_xdUy=TZBeZ!y^8mD@5r{o@=3q=+!%8pGSy4XosC&%J z5Q8mwFL1Wwp&@I5?L}b7rlA8gp_M!y$BhopH;E4vr3}$DfIuDvZK#kqsG3dFB$J$4 z834ccT}ySSwSl(5_ot779rNhg<71bm6rWe0M!fqfc-=Hc*G6009|f9XjCp_oiS@tyEEWzlB)5T^6UM{%caxIrIiJ171C^q*QxV-(1?L-N2DX?^udE917-?13p z&QNk54KsJx{xdY~TL)x2g6Yd9>d3PLyS)@^+kO;1FWWX>mmuy2A3E-r#dEm*SV_Z! z_9Y+aiD~pD*I#UI9?5MckG?Ezws*YPL}vOrpWAp<`ZXc{*9%_p`t!W``Sa(WJF&~G zz{kG3^k{X3N`R9ATmk6e5PRU1tP%6YXNY+h1RKfE?i2xZ-cq>R5R(>D|}w>e!`9Yg-cxW!eej2J2}O&gppghZ2yGgUf z-Z<1GERqJ>yGMCv<`ngI`*(+)0;xa4MNc?udOc)$5u&?&uFEW--V=ZX#BHm z2_h)v3zLuq zTHqtsyTJ8D6P}E;T0W1_b!`ao4ssz&kAyYO2|P+m-D#s*-HGq7%qq8|GPS7>hvopV z73(h#UzRm6R;=f@l)oOFi0f$@XaliG@oNisIcbJi9`-qPxmbap&o_8@cwkf8)@JV2 znYtvhgdwyZD|)dgYYd?v#};CNh8lntp{eV-*64Z?ussZFF_8Xu>mH5r9SeQz%ND@) zZP#|bEkl4$tIMa=3cxGev-^q7rZM_pRNHnAp^>o$8UT=EoDMZW3&D1k=+7JIZ`Mhe zB0`E}lhS>8`q#@Mv0aK=XLx8q`LLN{wJb`dG?||H;$0TKiMOR6@Dc&~p-9Hddzy#M zEfK-(rKPZpY$4mo>Ml{z#S*Sd{O#PR_=>_^dsB)jZiCgbJ#;(My4(QYo5_siT8eWv z3p*0c;XZm6E;C#oz;n5T>t$97*e3G&r%X8Jj{)WXme1UL2;BHYIl#Lq&c^5JUo_+A zpP#X*@a*a5D!lXjjAvj|0cYSD&lPaSbA`<_@Qmjql77bS9?!t@DZIJcW52=1bJZ)j z)#~;7X|;O6uv!IQy5vwd{%ak7ul&D<(ZkCdMO7HEt|~-JxM9GsM)bj35Afb7=S3m_SR%=ukFbq#HchxUnz7*TxO}~a}z_4Bq zZt#v;qdyyfs;Xpw^!?ymu}_0%*uLD+R28R}(=ZIfQ}9o7!K_a*)4%b88?fT~UpEbc zZ&x@I(eP(jud!a!4a0!pX}};)!{9x!06^CMJ5M6T0Vk&?pc;nCG+4n6gUHi>p>nGM z!@8>0tOfv8rK$?#9l!kR`=%m9hHCAd0fRr7d-4umgZ(!;sK(@J=In zXX=0Tum0y>>%)3oxj}|%0EU%BFS2myxnUTb2%NX&b6@WN$LfobCp$d#@$!iKoOs-5 zB?jE#OEo&3jsF{p+gf?|xFP!)7bGHg_on$*{}ZapKJ^%a+Z&RZS~x=v!&9){L$x;K z9Yuzxr$6Km>yOjAf|CK_;GX*LGN8J_ukE0FYs;bs*JvhT$2*YQS>^48tl|_j!lJWGE-Y zAcG5gCm5ba$&UBllwiqO-Z}&;R^F#>fI#A(=}idZ|Kqqfx;l=-;86Jsb_qa_d+3j3 zx(dQVlJzE0Y}}VGyfc-x_79OTdiXjKum(85e5ooLzq{_~3Ey4)%Qy4OFV9#F&Q<`b zH8B8EtydM@Fj!RP&in#%S5?*1cZ=cwuA0MLW8kD32Cl&{U=3@(|Lb+dyWy96_w*#k z4)?tK<-YnuV4tdCfQbBIhyH1J`cVze8<~dFH~7<24OPX8)h{*7UDeC;@XLw^;Fn<- zhN`+-4NjiEV8F9~0DOVC^&k#I_w@9=>%RAXo<0b8cc**#!-`a4P#9LL)hk|q;{5XZ zV*W-y{N?@&hX4Hi`+z5Z6q{=G1bC;RP?BM?<-ZtKB#&c!|4~-d=wI6>b5)A!&7&a`)pAoBXUVr3>EeAOHC|E581` z!45B5yu1XrKV0x~4eLK|@U+8qjVJtcuP;{&m)D;^@%p-iYyH3^m)rUbe zfeJ(VNl)jh^pMSd5+)sh0c-4ch4eZ79$f4q5ACVw(-}CIM0H}L&jl3?;2b}(19pGG z*Awvd^?X{N&hC8r{Au@jwa7Ly?`6pZ!;>aNmCqouC;&plIZ?~P(~%*H271yRTSL}V z69)R0upl_pNuh|K0;zl#zoB6nT;5rmmtPI2Rj>hY!HB`r&}u#dI<~e}Y>Zx1aU=<& zH{8ktF$`$6Gt^c@`rg;>lgHD7ftGh9mNyF>9ILi@^;~k2GCGW8Or6b0O8|o23kJ#+ zX}^zs7B+0j20$-v*+(OHyUS_?$#iZ^K|xCxucI+4rZz6dXpjIO9v&XF8Cm3zo|eg6 zlsB`RCkieoEXroZ6vfTad8IJ_D*FZ9jLFXW1&WlN@}Q`k_ji)@R*G~MG(q~4nM?xF zufuiSKlOcAs}N?H9j~;@jqz3YQQ#kPZl*1e$@i?dPzXSyM--~6Swzds`Y{wc{NgR7 zr>?0~;0>b|H*AT~N-=Z=FOvI7VVt}%E=+V*-|4?N=6^r6k0qSy^^_4z2**%n?yC*@^3 z&j`;Jwq!*&@%`9Nn(Oi?k`ULC$qX{8^*XWRxGYiVa~;NISq-w?+=`&dj(QOw9#D~d-2?hN{k|&8w!THZfIb%@?~j=&(4aEGfmTrjktl6C%9XZ zac0ex^4Qx20KEWSJq8zmP6UL3J~WL6dYgMtO|=-Y8tpQ*^3tW{pCybIF%GTBgQ1uE zPU`kv6DGd^5!&dfQ~vIVlwvhBNVo zOtI@+a1|{oM|l~tSoKj^L=|_#&FBO_06I?QzzK=RIa~0VEav}dnFcV1BEd8=jj*9j9YGon|OsX_UnpkoPk`nUODpmil5J~KjB{A1;-x|F}wMQ`d7o{`Ip{Z@^ll| z*zIt>#~#?9@clD>9H%#SIGwRa5JvCk>o^tv+U;=$@B=sjXY9UW{}=xm?stA& z*B|)2di}JL)e6~|#f3+5X3mk=S3&{e7`VVR4mgyFxq7JvE4*7k5GS=@ozUyTbv~H*4nx@Gz+l{YHTGEjQVUvrs$A^ zQqC9wS}W0)V}hQYIC=LvOz1g&)AhZ0#E=;kogE2sk>4tb*_L8@GxI{I`^V%u|< zXt!{>-N$8HGGPQg4rr1iTXwiAY3F%%0p=O+pN zGVt9DVoTOJpSyckiShc0rp{xicWG)rrF8S&-MF6uj=zp#c?T{{HkUE z2By|L2wJiKAQT=R_;A1@1U5IAhv$Tw2eOg=Xpddl!$W#OI}Ms>T5U|UX%dRCuAyrj z`@U-hB2EYx@3iDCRvZM<|K7oP2WtpnpiFH*(~2Cs_V{}zBYGBbpyESg8Y&TIt?j)V zJYceWyC1m-K*W$RwS_zXv%OxgZ-S0@^rpG5TM1IHh3faRS%5$zW?KY9+a+|Bq2NpD zpM1RmVaM-Y7I^6K?MYB`1|Kgsj?HCr!z3;O^vjIm^~M_b6OPhvpPkK{JpQsN-c6cz z4xzWp+j@DgC3HKR18i>L^20jE)<5m@7MMmz&Jk9~yuU4fJR7f1V!$WQO?fm4WR z+1=y(9oU~v{}JaOqq+mT*IzK40jyRhd_JE)@3?d{{4ixkYG+IcDBFpmpR{x3<6T8g zMG7+j|KB5y4pN&Y6!NUdY%5&(lv700m|APYlt)%R9#!D8LJy*t9#(mB%DEg45pyxY z$SzrNzjfWeI~aiWCUeV4Gob=#SVwOG1xG_GjSVKUv50yLyV17;&K!xwrQS5HgKJ_& zGLDuht`APABzl2}&02K85t9|>h8+2*gPh6t&o&z-8HIKcLxA`O(cN)hqGqF4x$`FNy2^a1Om>9 zO(7rOL!oKhIOis7 zNEcZ2gqF9T2Z2~;^v(3MgIMAb8KrX^^+>Hfn#Z2{pv?n~miAHlo;rH1@^{<+ZwCJ> zn|}wX#r~sOVyCeH03ZNKL_t(-|2+Yt53Du16d)rIDzrsBf?|)}l9E8J;vx(o3KpG%bwYt6j8mwMuItX>@%Q8L*oj!U&;&`MT2%m^Anqx2 zO^pp-;eP`|6VWgL{nOL;0pE;aRmm_2{5qX;p&Qb7B4Vh9!LLV}JM&QA|Lxt~lW$=h z)=#0qieHE|uo@t-IjLG#)w&v1L*Bqvt$nMes<4WOZ#6ih*jAcg@0xdw*5f0BWfF@rn}J>X*7 z*pm%SWX=Ik`8rlrwT424>I=cUVUS_KAWs-1wyaeZ{PjX;<2xomU7;F8mrbKPgeO(jjy}IFRHq8PZq`n4cWd0Ot7=`X*P(%UP#D(X zO!&(rjz(Zt2?bO3_RaFBV#0@g^Zndkvu3i4rPs1?OzucL-%GxIk!`Ao`9i3^%vkC@&i=|{K&d`34FOT>%aZtu>Mcq`#=8Q z)9Us4Gqx`Q&Ad#Z#~R35?1~n_*f8e13b$F4-Po&F0-^Brm(Qug@Wv~33(i~X*0KF- z{24!VeVKhSYkym>flFNEb=G`_v0ZMv1=g7p#U*TQX!eU6w%x$@EN(w%I*OOjg!ckW zIvUrpA@cGv-PfD1*vGg1jCJ~Xxz%YfYYuNN#|;g#9^Ot{*TywEd?GsAod#Wfc?Gy<8J4-2ktDN&REIM6>m}e zTqy4%>tmyvO*0gH%tqwzGEoAoh=^_b&QMdcw7iX#e9ecZscRJ#*)okgm{8*wvwCCa z+*sirDZg^pCZ=I~PTa=$93xu452aCOi$SFljW!=YxUD@IlwUjj4C8728_^ofQ}f z#J)GJ8XMk}cckv~S)=sbZ(a9mU6ZupBOqcJ6=Y0$vTqL}T z^FB*Gx6^_}vS;L^z$CcIjOJhWyY7PhThSm!K)T0A5lh`|oK0}eeapD_I-!$& zFWfex{|dhGdYjFT?P&{zcdv-p6dUqBoVzSot!xX17 zmn;6t*V4Xi-}}Zaw(osQzRg=Ihzt@h`2*grQDi~cZ|gBGGik@0`?=5+dMVic3w~az zms9oniqh2KPiiX!|J`1^@n|i2878A|uG(PUK{c(NPApRi5NlwEU26W@1AFXzr(lM3 zPpLsL=6K^g#nVWp(YIgcAJ~0G@Rk0$$Nq%x0QS3k>~T7M-+L|g`Q#U)cK;GP0H@EF zl^ew2MPUWJ-ahszeWi#nlx&xaLC@<3Rr$~s-<@P>$dJdE7(3nH5=E2#8cxGc2T1uB2H|G6NhSQtw9fo;_isgF&{`cR0JJ$8z9Ue%E>z%d!TjB&1f%YhBG^9>`8m^rC2y8E{>$OnD z6nOz$)P)FaC@S@Fn#3F4zHnJQv&w*}S&ZghI{0zkFe3d?!VzOJ8fuRX+7a)GK-`Fd zy!L|{%6PAuQNWbIz5;?1Loj6tYx95ad~~7?$Sb^QvzYO0a9Wm(hg2dbR_ofCLW%T}pz#iUuG&KH^}63gU!{P2=@e@X{kc zDv2niXpEmRi|hEU0Ss(cK7E<&E+;g zD+CbRn{X@sY0)Y9g6np)&bTgZU4g3p6lV4Na(U-V+mE2(%R35$4?+3O`-uAb9%!DS z`f;wY$(&9~=$yr^Z?E$%(lBRQN~kQ}ySxd_^N)TcSZ6-L%eCowROA-GPq%(KZ(m>Y zjIfVkVlG6X{r7y4?}-4*-wVm4EcEj%^B#fHNE+yKMhc$;nBD_8jkzjCH{m(95-w(d zN5*=ezXM7g`~7Zz!gu`ezR{DO#1r;=oba;U{SW4=oc_zt%j>6M1qkpH zcrC$nF`k!QZF8auGj=dOBhtsM6#JZay!YM0MQI17(oe z&94nPwvV0XZUbGIb+MBMe5f^}by`je`e%tsu$>_2L?UtRIN|1|+Y^r>sXg=w$W=Or zy!}(03#5&eUaVIwQnPLv0@jZDWKDiEI=5XQpbcS-@mVk-pCL%ni@QVV*mLI6k^TL6 zY`eZW96Sh)la(HtRsu(=Ld=OQ!J}-t(zXB|RP7*EAaE(xEi{U{4A97%!YK(hCL@s_ z`nukehK)XYjtjTHqbSsk4pS;P5wU&Nstn}*G2uft=C=5#88ti0W6;TH0~niQ*;|mQ z#mcLYBc3ru{(JIEoZ((+t)fvhVp`aDM%xj|M!=eN9lDVcCRD8x3E{)(VFUF%PY?7< z>8`iUmyUCQLVv;tWHV2P-xiF?*R_c2J3FtGsqB_C^@C#F zA0Gpg6KsSC>4B~n4Ij$gS!ff?d=y{|EP!K>zR-6^SR4!i{PufXnN3~NS@OIYiK3Kc z=>yLVoS-}QwXa?oQfqXr*sk}bCGsC1kH^PjagH<(G&LdCcH;;?wyDU7r{mCTRA-%S zyEtU7@cHThy!?E{>uU9B_382k`b%i26ya_P_l@m)Dz-6m#dEb+|& z>Mjx68DSpZco)JZPIrsVB7nYT2>Z{zE+59wo7-uEmkj)Fv*VDTitStNjBzJ6MPB=M zCKQhjB=LyMbN?a)zh38H_&Vta-F}Qye-}FY_i|bJHmIMy8AwQN-vY0Y&v;dX+;V)A zY2o@7iv4dy&joqGl&lBb*shenw$xtqA#NL-^3W2bC6PAXRTx3T97PCvJ=pH}gUSW zjIKXtU^@DB;xk60m1SgarUhq3ne_My z=3+7_z>9YyCVfOOqBkm`eF0RYp;0l=-8V-GoB?3~O9NW;a3an(52fyYT|icaTtm{^ zwr_t|eyz18Ac{fKF~%8>GK9&w@m!$MBzSBs7&7X{F(Jz?%x16s&AV|7kL#f{6~)Eo zESm%4g@V)c0`@M2$iTEQ9zFNAM=w)Hmw@K7G(oR>3Hlv!K1-V-c@~APU=}VkO{O{s z>KuWcjGd(!2Q$Yp*SGCB9dhpWz*peixnc<<=%dN$L{wajSRV!A1hb)FKEbik&BXN( z7-L|(OI|+3QnP6WO88prWrppLv(6H^++tX^EDVA&!@i&>VmXM5Pn7jsZd5bmG{0En zu6D^W9`y5p=`+ruKU&l@#sEz^%mpm+19cko>dy)Be5 zH%MHRLDQRYVz98sOYYE{Ta5U2fz?g1f|qyB&=n}OJJ(H2#xA`GG57Gkj!BB+JKF`D zl=;3~mO4Pk&cp3zyu6$%i2A6(1^>G!H1d*NDX3r~OK^LWW*Z^5urmt|TcjYU3-hM& zL9*Ushy6Yx*Zj4^?u>KBL+?vW8*J?6g6ZAJX9GB&7Od`a!uov1ZWkB4KjAb93m@t5 z(;hgz0^6?!*vWtS&!1jDf7*V=UW%E7@wDFtJo znD@prvzo{rhDGCM-t%AjamiRp&m8&_Qo?M4G_$_q>@P|L;x&a*FzAzcT3EZ9z;`0S@dl4ZC0%Ukv6i83 z$~dibG7}*|q$P}}0OM+NdH>Akn8^s5DT5}k$?iSLkhfWz6x93)^3$YIL6kV)fS!@% zr4;nK#F2M&9+Tj15loehutmQ}qR3>5P--jQm20gMdV>Ve1O2g+wjEEUiKhF08?2b7R_4$jkKtAd7p9nO zT=Zj!J01nXZw;Mrc4?*g78 zloTL}6d_%2`#znkcq|pA>zqiiwx>BX{HByRX9M3a!8u9Fm?AO?zR}y(P6hn0{t+^I zhyt&#KUes?MeJ%Yyb}i9UXp@k|TaM$_uc z<|Zq;U~qArsa_^?fEk2cU}>+#QNPSTbe*m}r;|V84zigc)Fn`QeV+{8PIv!$3%gIY z=|&LDvhVd}Nx8AO@f*nJm)AXtc{gtZR+KJGe;tx$651`Sj$^yklAe!CDg(@*pk$If zDLLl3;6p}wRfWp@4f@9J@WRzdxT&IGxTo;pflo{lCQS>+1jc5BRjl->k0B&$wK0 zeFc8TUQrntAmq}+z`jYT>T@pO=lIn2q$MpJskBE?E@U3&$5}?i>1MbYnKN#*fFoSa z+2(8?)o2y00Qhi>u$hr$93v-sTbi29XIKPfS&v#gaFfn4s zdQG!;vt?b2^ymdH%Bh);6jB;^`#_l(MkL5*gyob=B~M{*k-IeNDSFb^OK4mV_^D@> z*%7=l6paB0pD~#PE8dWJ6tpbGrWBC3=>E%tNlE$uOX-~#nLC?LLX_kXxR{%ATAM@E z+(OXN#3|DpJ>R%${CH9ne~NseyrDK((}`r-gKR7r`+8N-?h3dl4N4c5#EFxnFvPM) zxj5#W4-`q|(L3pT>t!FtFgZ?=tZM_K1!CYJv>+Rp!#5{lZI?uF{(`fxrg@;I9FOR2 zm@FMTkZ6bw;`0-=5~(2ueGjps4?^2_J*CtRz1{nrJ#M{+{(UwBFic%IsYNy-gsZ(hQ2nK@5y{wxTZ zZv17lfIzn;n>)eA*F{8F1nzC#AfzwXGGFlWp0r^zLPh`!W9gdofG4VU1?J@K_%K)En z&gY1ybCTL4X-`6XNbRFqc2Nfsw(5laU(Tm9PGQ|U|Nd_GYK%wjmH+1X$HlqTs>08o ztCyD>r;bTp7$pmZ;#VoW{c zFq)d0gzxQvr$@w-9RY$UDy_`oJS*a8rLxTOz*&(wA?u$9;$}}+<~b^`VkP77rBDjy z{sW^y^^!2u<%e-{jr(>(Becp1#M<7l){X9EE`FJzXR44^Lyw{f5i4Ch52{GKE4jer zHtS~?R#G%uEEm_`w5j{HgN(RPic^guW3UL>Oo2Ys=HP+2Xg~zLjCtrmUE$(U$pgxR zNv_`(V2KNzURb02K*W(Txo%qbaA`mhnQNmXGV`t}et(skNi7JNprch}QwNR2G{r-p zi0o=C5(gKhQ9);%>9IU2?Oh<`or{f?<54TYcbRrtVrfY#mE#e5LTtDx1wLBKKuxQA zS-mPo6|$^2P1im0?98qr#Zk?j%W2BOW&FGoDu45lQ{FwhwbR`NCq)a*>z+RoGuG{$uu=t9M;>&P00bQZM%NM{6p zhlV0X9v}O*gR@h;WG}8qr&;R<0>q=pKg6=z-;)mjU^@_AKP^W`ibLGZx@n9CdTDL% z>rtdOYz}ozcE8)lwzE;;On4;iYf<6UwN`qudEbI~9SV&y%8(H0tn*VMvbG|5zvd=W z4*UOZXQX6Az1Pj3YtWneNNnEtcFGx<*iBp(@#p4kum`+hF7d|enkg%`GYN31OTN6l z+aFl_HWU0;&9rcs8ufIof%X4rlDrpJbm|J_4p9M=q>%@(7-QW|uFt4_$FCPXl(- z$ZAzCN)`Bf?V)EBahyuRI0E00CKx|(D*w75xi}Xx=z_N%Dd(gIIbnzM`2=9M3zFwu zQi|+x`aTLrBEH|<--mztMWqe+y2JVF)&uSn&S!kWdG-1lT&2eoQ21p8p+`KhilJSb z%!RMC=rsu%4Tw|oQzSR$T65A$WzRz=dATD>jagu#Mzc1$W|L!d!yw*}kl-v%RKJ)E zK9PN>xY2H8dWDjA)?tDx#}q>Gy;h`TN?T4=ncYB=g>x6xZwCbA6L_BSc{$R8zA8-R z5v*#A0eZ0_lCFCecTGUgF>_p?H5Fx~G6g$R00>>vnBX6gv#Pm5n54(heVT*1d}5T&QJ7uzC2KC(<>L4Y7J}NT^Lg_HLOPX?~ zJECYYU|y!2b+5Weyi49_nHyy~+|Za$&$-W>vTf_VNdWf1Z$}$E=pKyqDK-bP_ie;} z{2~AwB1*;e9ppgjKJ1x;1FZFtp-@acm^2U2w7)&}?a?Q@``c+0{itvUbX{NLKpucL zDyeFa5F3jd28NV$ZJ4^zpt0?-`^Te*)ikiM72z8$yNiSdPZiPQh&+!ab!2-;q@m%PCRt7PxG#w-z%J z&(}b8XA9j$`K7 z3le-DL%kzGzPSa~Gu)h3RUr85TdQ7X#5ZqVIN2%KZf+_!!qIzO$?*ERouTJjfSAkw zl#lswOq_f<>TH+!Zjo8BQWgsTBm7;`AOO$;S$fdPB9w{cJEaoSwD#iS(?};z0Q8iG zj*fNlmwiIPNwaY-1sfQxrq8D(ZX5gE{uFY-_i;U^8U7wY`feY=^yviPd^+v+ek0Cd z*}gt)IpDe(b&3VO$ovxWd2o`teR5Od z#b>>Ng3+~Mtqg;MwPS`=GU-R)3yP$?3&FdWWXYl|B@nB$U$286ZN7Y~GR zBF@^NMWD&5`J_?_6UKONhmy%uK;Iq#nz|_lf!tC$r=K%G;sKU6hr`36p%I`HiJf3G zkC=d^5(%9Er2{NH4?@H(JwpiSsDlpJC#}Jsab-0We|i$1xzg z_%LBa1l^IG`HO`Oi056YFtzuJ4&Dm4kKgq`Cd`XmoCT;%2CjZPHAKjSI361w}d$=i<{xMOTp)(prGJ(d|(n@Guz)RO6F|^pMv9)Q1BcY}h!e2_WBwlKfJfj!b;#!S0%_yTqS$EG z4FvYL-@1SL4I+(h&}glVpW4{R){66%Cc4%Q*&aL4Gz6iJ)>(@lBE5|AB^YgBn4q)t zmpDh4001BWNklcx0&um$;6*fcia+GT$iO5%jkLOfNhss{z?_fb%vX_r5#7M;LS}MePsPN3y0X# zyrap;Ham`^%Uv|^2qKUTHh3%j{iYiGBk1||-&1Ym^#xMB%HQ0okpD>u24}r`l2HJ2 zQu(&#gGoD(!`^;G0*n3{B{@F2CJ^dCJW5F^Ftq(F)Ei56wE|+mOOB#<5x8bhILI{i zKm@@FF`qIRJp$blf}bZHio5dHJ+R;JCQ52#;thCvyK@k7c(*(MJAl(}A3iYZKs+rS z-rVoL?r{cAr-Y@bjdH(b<0U5m1p2AYh#QS5ka3_Bzn6h#^ zG9#a!aLUxis;sqbDDuZg`dA%^Al8SS#K`PE$TVC552y5V++1DPrWQ|xx=bPiLGOB> z_HG&~732~idRP@*n*|J#@N$+!i0v$I)v4Sq5?3I#IsE;v54B?F#&*+)3}b+>Or|?1 z^gRHSQN}otxi3U{>CMvGSu)MRY{g|We>L)K6K@P%D`R{wRsix8_a?jyEu&(|F+~PW z;Nq1y$_8@W%b9{L($6}|t`tEf;v&h%ynFi1(LOV{Zmk+@ZWxK>=-E90d=0usj1*|D&CXfz3Eg0?-n?zm8H?Ry-FgMo>1 zls@8w0H_P-xZZFF6S&X3;v zm}r{jAjZ(PehlrqSOw7rrZX+97it>?91KIbMjWhb<3t zmBx7i@tzaRJw+w-IU}UcH?maD1@F8YS9rqdgp>Ez7`4tp`kV;rdoS!bfB)`@=QB*#SZY1v*npPD0t(Gi&2Xe6tGehvnv*4nTvIS>>DHM(lSG4!QJm`=b+ z-`c)0H?MkE=zPLP`^b%mU=5%&o7%uy>%;<%1iVw!bfU;<8M}P!^Y%nmfZy7-Q8Y&V z9zX@NuBU(?q;Qv%QWb&}ahS)nxxmx1*6c-kKXI8EFT1{X02*VoPTmw8XB%ODA}Qn& zjO>`ecAy4S;?^*_Y0upPNkxH}+SED}gE*Pl_!FoExe%5r%SH+?M4NgxOh`7Fk++0r zOko|dqfLsr2dTnjLkepNC=i2B z2yvDGx?@MwH8s#k^7OXS8z`Xne#*XRz^JiFSDor{1e`&wvn#v=S+N$NIn?;}4XqehTC}|tKTW5DC@SN{ zFeHre^EL-SY;fVp&9KXgWDk*Ki@#cZT0mZzHN^Jv0mZ>YwS2k3wqCC9vXN5&I2CPN zK7_lkw>i-u<}F1I*CqMyy8@3}hhtmnlrKv<i=n zNWPAE`lDNM#SL5N&C(^5Pd~0P809k3B|le?ZIX!MW&-pF(eo{V2a52G=~|Y0czn1o z0lLh2AX+l`Ckf%~Qtru8-%Hrzw)nhD6lYRmDujPbU5mmef571q7M9sA3I_9 zH4xHiQGT`e_t@>uKmH?5cs-wAo>xDI)u+$Hr}Jl7tw?c>3S*XaNa7Hm!_7Vhm2m`g z3BHQU2Gf+gp+>u1$^5)ZYBqKZdEBd2a8k=AWrd4%R=H=ikQ;3!j(yvh8fCZAq|QD{ z?)|JFF5hUaG#${})-=sGQ@6t2`u_IG6%_56vs+=#NHa^}PND!2@ow2x+%|AjPs1KQp04{VXZ(L&9eRw@Z=PYMwlJsC{g0d zLQs;NceU0rbdXAkvz>GY@$)E~rXX?FA)(bXJCL&!5-QRd2;4M-MBWptDTb3pWwf&j z(&x-->0_7)Lc}XOrxQb$mlQ_1*$ox`Sh^wA+a96nwyT{Lp8@aUk@pvaw_TH22PfmC z>`cO4Ix2H)1CF)oQz1 zUEW5q-jU-5hq@3va(RzS{t%a&H{e|+O6Um~yFruBWBNA1$L%^-IDAY?@NpJ-*{rR^ z*2^m2sHfPxIVIS9#JBF6vDx`Mi}r9AU^`c4YziiNA&&CKiQQzTAKTeR-q`f(T)!SS z^`}SAvzt8Yfm$~6T7=I0U}X2an7>pVhad9YQct0%#b%ueOj*M4>ejQslkYZ1X7SVg zlpS3c0*n(zb{SEmk$cwVMt0}Z#LqeXp$s70Wu|zMy&lo^J@9>x2#aS}I>6%nKBD*g zfT2C#y#E^6<$K^ea6j(G?ko0t{P+?6`SmM)czXRF0M0*l0Pgp|{TZj%?>}D7!^<#y zt}3xvg&Kw9Mo2#vxIlbK*29xm%9EZTP(I1vLdEpiTzg2yT5>3o8iDjq8mLm6Q^+qS z#F;C@)~rZtyT;TgZJ;4}n_EQB5*S=kDbSeFF+jxk`vh*$KbR)fbxz&dW;AogWA-DL zYBb>>7Wl2}tcWqJX_8=5rZ<8}-?kq4mW@#*ZcqgkE@GWbjnZZxCXG?WfI;T0<)}uH zjLTErVb6}c$I*=2=tG^3*ZAZ$N~C{$JpTG{(2C+j<^z+b`V<5PVuP~8$FBeaQAR_* zfe1xzjTMX~W@i<&HVuTZeYhx85onwRvDr`^(Ue{a>C9Z)mXBvKb%W6ijEQ5;&THZC zwyYh=K)z&yTA;O+h*Es7%E+ap8Wg|`go5_F$+(e{G(XM-t#+Vyoj@6XNNupNP^Qt1 zVQG;V_f5x1Y~)Y9(XzF@7)>p79OV;f0>IRJuyEVw5iPRV4&x94O@dp9d&6lw`fI{h zRhU0K3skK#Hk^QMTdLpcZ@<=c-F00F(p`T03t>ziSfIkjyLf~YdJtl*6<w6%0shjYxVMpIW(wFyf`DOc&1>cYfznQ`E*S@ZA z66GHxa5EE)F>!E$t*=X>i;oK_vdY5tJ!ir=3TK>hK%FwZchk1%oX-yGSAql^8obE_b>2hO&`uMJ!jXYC3 z`4D)TaA@Clfyqr05qATQi-cCo$jK>YsV}o4*j$t*DayE~^l9?OY;*X*iWi=K&)Alq!l-Q!bnk=cI>j zNRgtV;E$8dtkz{|URmfnmS#0szBeF2W#dnwTS`$^gbQd}g3xmC_9UN7P>KKW?J6sO!*vXy{tHuD2wqQ3Fj)8rWcoBPqPyDX0gA zGC?+Gd7)VsyNxAe?jXdqDu*6mZ>5(G21*+RHbPiwJ#t2$8D53K!z>h+Q<;Y2^o0u4 zu>I=Orxmui8C^Y*VO-v%PPcO|_g(Sy=0j+20@q7-iESCDvb_c6H#ZUfMFh|MP`6@E;#&vN%v<=WX=bNwP zM_#tLu13RSvK(OK&&fCV@lV_qIw#h-fX)e0XBBPcG%+#l_*tNl)W=AcARj=2d7>IR z3pjyJJv>+^X-1~fh%#i)@19PXJI6WWl6}U?X#oHu7jjI#yBpVYJ^|;`ZnsBF@ZRsS z-{Jd@q!u~jbUtC{CDEt!-#zvj%1;#a4mh2{s?M1KUjq7jKPxz)(5nDvq)x>12`{Jf z3!Xpy*UxenYU)`SGX<>=vqBDeFlvbzRkYG4oTfZ_E@hyz7WgbIK>!Qa!~_95ZNOI< z_=?sbqsIayET^@uHLi)>^j`fep&BVgcbYaKe=J>P3J^y_dZwve43ZGZA(2Dz~o*#Wr1RO(z+an?$X35%zTyNmOWy}ioH*gqBvdkRwBd*;2P)8@vmy)1vLFbNAf^PMw3x;K1}!bEY2&hdI*ql( z7@vtZ;G&10bBU7TCX+BX~C4baLQbGw+{pa7R(xDvReflg2|q@|2%j*NRgk1XSYmN4{~ z)hVjUCE(DHk8)BgAO9Lr!YF)Zkqw@!PQ|yOFwKA{=~~Vz+RniSb~ean!9;b#V*rcR zC$Hqt6BwyYC8R-;Tq{+OOtJDG!d9$^$^EfIUsrHk%Ofr#Z%+Jww7t)7BT1JeXjC#N ze~eb5!h5Nj4Ib(Pm{>G+w7?v?_OL+rasJ=E&T;!#eM~H{KoQf^0C`AFyZ1Nxg3l?s z#63L!84*-wb?*v^Dv1)wV1$RexjlPkK(AEF$2Kv-nV_7@t@{e(7)QgvA#lcQ;lywC z3m3X%wqq7p({|TCNiV(;qdPY2j>-C@hB2hTE;u2xBGQVAi1BeR+>AUTW`QdjZPT4} zTRN~f-jW(wyk+pCqOc+9O-ezRV6Q^nz^MxhuxyQZ(M=I!NvvmMiXc$XyQiJdrBNPk z)J6E0XnG1%0Llo%Xo9ZF{Y@ zJ)i;IMJ-q{q}`1cPJ(7)>d;Aw9}K(0p{N&y&#vf+gk+$)n^p{qj>l3l6t)jcY`_Eu zR)UTlz-;&XxO7cTP9{>EOQouVQeZ`p=TOz=?Nf(zZ@z{W7IVBzh8hcC3Md- zRBA1qSba$A&b8N_vk6-b)e`gi`aLm2I?h}4^YroazZ;5um_L5TOl{!4CZvmt^%{}u zs)pUK5kHUjMz6)YujX0i*YZ=JOGsUGiJoV%|M@%l+xN)8`h25ka0M<`lpEokQH8po z{r}U~TxTIzZH4HuH{W>{JyXR=W_~fw(rV1PQGO!Ff950V8U}?iC>$7ymzff7PlbL% zEHcUj?-MZK1Yp4Wv0|gMEaNnTkjH;hXhU$qdefpE@U4hwi7+>^#p}n%!kr^B(4j%_ z8SAwKeT&?>ZQCHw-fS>DW56Jij?*B5jTY_DuG`cN*|vBd0_+Z{iYKfe*Xsf8h5$T2 zFHR?S{tNS`P&Oon1=uomr1eO`z=7Ol0JPP8@^+~HHz|q|CY4!O$J;7NvUVJYVmOAW zFanVxB`U)Vf*8kwF8$I`NBYRTw?@Q6M7iOXqmM)ZWB8*nob{Zez~#_n*#X!R_D znYfHmxh+iGEIY)g6GBv!P(*$Kwum-YgY@4&{q3&P#X?{$MoGmZ(kY$H%IHU=?CNN+>+5IH*sFvs|8DuIqu4dYQBqU3@)vh=43pv5 zN8#82+R3jX8b%V=~cBx_R*N0;*YyYROua&;c_q$w=koAl-eqt=JpqY))i>0iL~wza`LQn015-* z%Cz~ouS+{2PEHwuIUU#<*d!SW=sDVN)M=e1EevP(`}AHee5eZiQ_LLV8nB@@U>Tw3 za2=RRQxx%JrW!+M(Xw;FBRyAiqjXpvl=jKuG<^?#cN*JH_gm^U ztiWh-!b2e4%iaMkr#S5JtSq8b&K3rwRsXBrcECRX9nm(@&nVdFYA`Uv8U`D747SVw z8^k7N83kI$sv>pFY4KL1!8Hk2#nw_j&vh2CyFCBjFaPo{6|OnolsWvnk>dToQOI$R z4@JYZX5c*glB>CAz0SSTdG628MfBhYI+xWAPqx=TqEViRJ??K1))76wj&=g)^K0ch zeJ(iT^UX^$Mb7fW8Np~f4UF@&mvhby`#f>zJ{KQjtP{CW9ProJ&JcyAxBB^Jti^r= z6Z0QI&jC6|BUd{U|273nTpy(2n#%z~&|H#y@puIw(39r9s0x1QkX3voMFfpyrL4%Q zC~X~N62;K#*o2p{a*Jp(S4lvo-xp?hkeKdMMOC*GGCKZpogW`D+@}Jquh(eX0YmiY zXxnxzvEOaG37|Rb4Z=~h*kBE8wo(ve*W)wukWW;EqDPk za2hT+7)W|qSXy0hY1Z3b7w9?2@Q_VjZ_A6Q7!rauqCAwU&@o%cG9{lNx_A)J+EOz+ z##iP}vj(Y<*Bo{MYw_slTl89p(6sZR)#E_n4UppeopY^We#b*`Mz_^($vo} zDAL`)c9jb}k%A(_hokK}MMRPy9`(v`8Y0rny#MVhp1y4RK6J1>obxDS4t+H7)CU%^%+3%?%gvQ)Lro+yrNIfYJ%r<0cA4Sh@LtGBUDUZbbkdo697;LOHhl6u@bCC)LT9wrXmz!T)W)c7gcljTu zOZ472pZ_SSj1SuM?m}QSkbW>O9{qc@f9;Zd9SOn z*m(8v?%=zkk@F<|@O~nH86|VC(st!_p6WhNHZ{d>Unem7JUtiZA3FH+k9??Ejg1(0 zG#NcpQLCJiMhQLtPy-=joQ%RZzMrCJP!E`ho^QD{6?MOgBucab)n(1fiFGcSYhQ>a zi-I0)H3K-9kMKVy4Rp*(5lor|#({~BzZxcLjCI|F*bdo+V;F^guPfv&X!SH;Jq!u8 zCO5kFF_X;!I{#C&-4G?oKjGA3y#`KrJ_QOHDc(f@@>&8~vdQ%cm5e*sSO;H^VLi0% z2EZ^#AL6NPHvb~W(8tv9W0I&m{df1+v!e&;e_m*atvqD}+$nOMCHF#; zHZ87c=xJ7b5MT0$o~Z~xb}r(CKw67x)36iO#}N#4-F8c2sb$8hLnbG@CKVlZp<7Lp zGn!!H9%ignRWUk_r$Ser?0hNYS2I^Gf`$AYY^~vK-;s9O(lNOmMiVRx4Q6)c`1Pxk zY;ucw!_9y-h;CVq9U|JOwF!2l$*HF*uD$E^?&+x`eLNgTYNL1_D0c)B0aN`g!wDYg z$HY9w&Ku+Mm(ZUM=oFP5kmDz->ZgL>OpJHtQ;VmBY>VJG7Fl_vMrx4g-x9+1K-le` zetp`4d2iVo4smlqFBRJ^U7=mc-IfjjD-~*=B#i|k2|6TI1!v0K&R(d%a4W@?aWjvW z0ZJzClx&}AT-?ZNqExPo?sM5YkHp$VjP)E)^bzvxJ?i9K1{Y6;Vala2%5rcH0`>#% zx7_c3-C@_Uv22Ys7MAVTy*t?M%Z_$k@op43bwVj&>lO7|ePkH9*E-UKZVPnezOwrV zz(D|(kx((#;|iN_M>49)#!J9Ih2zi~o7O&skY>ZOV$8~`F3}Hu-<#XY`yqY~H z1>Rkqe|T4L{@$5-opebywYrHgZXOynT+xRVGT&yM={x2}Q2?fTA`Ki3gj1MG(F)Io zvFfX%vT&P!r{^{Xqjig!4-*Dzh5(97z1Ex{H3KX*cA`06<8&IUGTQbOOqGWr`Zk|t zPUa~h>EyE!+X9R4izJos_e04!5806;A#REEevYp-C#F6PnKnl|NWb84YTGr|En0bY zJgN=wyop_g&m(O~+ioHezY*cbfC10{Bv=|P+RX-=7XNKH4bSi23@_(~l@`xek$3={ za#)I0Gg=Z*_7kt1%u0g}hQSfKQzb+f0y?qO@>-fA_gvZslvHN&?jRVpnw=sQ+Xksj zy^Ou+7vZx95)Y(_x+fCW>voZfatTN=xo~DGH&|AJi<#Nr>({UQ{Xuuzvg#W- zWVVN3B;eTW_g@`<0Vz;4p5@Rx7*=Ov^X`S}%}dNiuhTTrn5ugTz)szg001BWNklC^D~wOmCJiDs7|A2X#km4$x8R!&J_itI3FYgcg3#VjVqZ-RRQyFG8X1xY|1tpcwXcm?+IJV3`UI$1Dp(3q z`hlve%q`66?d6$Dj4}}1BIQaPjz|2)oz~J6LAt|k2kMwf?j9nN^g%8JKY8~R(iK4+ zq2E%N@iZ8G{686Ap?Wxke0bTJNHV-!%Y$KSL!UkuSKvUvQJ4tF<5j$DH(*5~-C)Ox zh=?3BS+;PY0XyU7?DxF9!`)&5V0B+74Nh>*>i&KPu1$jg!vl3{NEvK*Uxitp$0+!9 zB$pj^2u`FQu`e((us@uV_*&s+%*wETm_&WOZGZf4%x(M-J-^nEuRi#Us{#inqW8Xb zdY*m%^Z4Sv-rV&RB=KspTlfL=T#?SnmG3p1c3j_aO(wmy?wP*tDfdSt9N&9REW>p> zB4R$o71+6tUp`INiRvqAPH^DO01%` zzJ~AM`ay~zaB-BTqBrDeVK%XCqVw$djekg*m@_1o>P>xk%R*j3Vz zs0%03n$*Z6INfm?e30&-j=@GCsUqVnb&5!|oVWRy=)R>1$Ox>2$wsQt- z2~_ZinFHpsCUy9Fpnh9uE;ya&I^Vr$A1#BmRoo=80a3u#iZHi-FANU|MCeEYN8}?a z(Uua!AcGM%$EFAL%wy6)WVNKC@rxq`I33N@$ssnqmSifIJ4EWVQkra#$e_~{*-R(c zkZoPgDYsZEQrRWL5eaXebigG3nk(d+jkhU~(0MixElSzjn)7aosRAr*09AoB<`F`y zT%;^ELG$hhD5bo&Np{p!>KYgztGgX5u-#`xqGe`7U^u6CJFTCg7K`)Uo$`zG{Uy@5=QHqn#=ZO}W9?OPj1Vk-o>y+<#joZ{vt`eT4T+t~e>Kqvj~b#+tdGQ#$+ zwK(LphU4<2>lN4gO7u*Hhe3uTA4BQ+Ie$*e!8hlYP<`iaM?~O*Six3?8Q*{ZqW=i0 zn2MQ$P;d&JdH%+7MI^*HjjK2!Hv#v{HP!+jgTP_h95@UufXB@+3^k=((YKSQWps+6 z#L(+0bDV*8Tjr;HL;JXH+tasiCt#h#8~L@?l}LND9)ya;dGNSyMeHGJ z=~LTofXxu3D$j*6pAg=G$!;+WLwxtsbBi^8{g3VQ^YA>J|K<5kx>>_=pSrvZqPrD= zlDQq19CWF=N%St)zJ~+=Uk``fmO7=KWAUMrWmcBSKA`6b4VYiW-6D<+2hXlpEY2`; z_Ri3xcYT*OdPdyMG>k}%r@Yl4?BX2-78236i@4gkj3$^JJ0)yk$Tute*c8aA^eOtS zqK*OpV?dn0w-prQVwDGD4H&N1yKPTn&$(2fCZ2QUh+!*Q(IogtfgQ6wSbNA)7BGu; zS2iG&6w;P$n6#X6K@d`aKemjKTEiM^P1qkOLhJ;rKr?bHSUr<)?Uhm6XOfByhC;_y z7SYKV_=cLT*l;C`XqcGLD+&_!%Gk5I*weA%7;@1mBhOBEUw(b+6djLjr1I{v^n}y3 zlH!MpT)UILk4jY{q0ChK#knGrB)d}+!E#6=QPIjMF(S-aWIvf?vlR+`q#UdHb$74}3UsQAmMxWL0pbRKS-l^(qgAq{SiyXf|Kr4%Gch*s(hR3_Jk@cZ^L?4sft6 z9rDZuMEy<^Gh49gU>zA_7zRvC`EtmAyZFYgNVU&f5*2HDp#k!4aku#NzE}`|PX(^I zQ_bRfeaHLassJn&>P{^@0G#jf9+XI=%DqtJzgguUi+85kwvq6c9GQamNwE=Z?%5T9 ztwV6j&TRh@C^HOdc7x$?2L^DrxLe%ay<)LgEN(O%u0B)|yv_s4TcCHoC-TD-mXRUd zYV`xq_VpwDTEXbm9}rE9w-@J7TR8uywt4&(_w}Q*afvJ3(9Dbu^@{5%u0>rYYe%4g z@&ASM#x(GW>M0~~&)|cBttOgRIvPbI*l|UqA-cB&;w4u=1&kA%5?!Y$xSANF?OB)5-3$JZarz1 z(d;zO63Ajja2qJrXR`B+y^)3EPSb-LIo25hY)7K2R8P!_X2my_Ly z!E6m{O{C_Lay~9M$FVCHA}UKeiYi8f;Xpxz5DL_!JKaSH6WazubWEx->nb#Td^`e^ zjzP3QB?+0QMx}e|H6Qnhot=~eCLPW?8hTUCFh$Y(C(LMuhpyQ4#7#$TdX*2i-$N6W zW>S?Zq(;z_y_Dg?_DwFS?zg*+_Ew4sBl$I=TS)8fB&` z@q`W-dbF?vr1*Y)pSdg)nmCkJq;?EqYl2HT3egMczJDTS^ZSvBohYt@7de+jSpNN> zv8A2LWIupTuDyX{>U2=1tG^eox*~->?yF_CI9Re`6PTtG(YDxj+lh!N0xG2ko?Jkf8rWsIg)PeyT#(}^=@&G z#p|N-KYl%rQ?5(I8aVm$4GjIqaAlHBN8CG$w#Q|7w`ha?a*JUI zy5$U&XK85^V(9hgS3`u+V)ros?fS7DGu#12w^;wF#N-nG66y5FHxE&~Au8wmN#ui=%%yF$ z0B%aT7?B16dcM7d%d&tHQ&DROjD zG)1v2rzq{CF}tlMQebxjM7wGyLZJ@Lu$5|JTwX%9&&Zd&eXe=0VV3ZY9juAvh;ojFO1THEuE<7Hr zOUCIS(yAvSMX7=&B?4op@2k;H1Xvsmm>3jw@I-LXagybl=O0a?j>MfCJrOjV6Qrv9 z9`O!$I*-`NkJE}s^6m*w*M{(AOx z`c<6d%d2LQOEk#t2RCs|Ik8YQX-V*UwCSn0Vq9yIW(bY4td@XRrpDC>UcA?s?;Ut& zx11cfi`ei}{_DFt+%4P!3oPyzH#HX{SLu)VX!+w04enMS1rW}2y#EFajY>%}+kbeT zL(C&*?hLh8-)H(~&dn9?tNLo8^7pLh=cz%`9D1fviF>+lpVLFfpq6e2(!@z8RTU&v zUih4=Uq}VLmDcE_y_-1&rOmF`j^?@?x!zcg>a4d3lu4y@iHUj{(fN5DRS>5VytdJ2 zZV3NtA2$Go7$4XUF`O{xY@a?ltcsE@`RZ@NG@ph6!?122<1eMv@Db~Efb;7$3Jbnq z%^^PxgSH7S9JzefT zt*`FF4n&dV32U8+J*4aiiiy+0O0#oa#i$Zs9FtKXSE5!$ij)>{!nhVkv-DN9TLcWS z4RDi{ifuw=+LJ7jI;wA_<+6tLa)l-D1g2e2HalSCLt%|&pbvebC816Kf? zVZ(c9A}EFvKfw^-l9b?Tk`h=RRTU+fXh99tRR$Vt?4HqYx4RvS-o{OpH8WX+V`sVi z@m>62i5;elA)LEOU{J!ZLdsGel4`QQr)l{QAnJEto_c*SBaF_NZPw%5l1Qp!iLrNp za?xshc1S6ZqmkK65FUUFbV5NS(@DUd+~>M0uAm&34a)#2MbRRfRNg;yTm7Z)MF7Fp zLBoKpw0j#PsF^T!6R+x_xJ3Zbs9+(R2(jZxgH(kL=eTEdu~^(K?worMy9A8v&A|s7 zCJ7=%L|W~3TOHgIEl~%Sw$mUqCrw>1FXZrLOCUNN*z!@VX4q*8uG%4(n%%M^N)Cm|a5 zCK^RH%(ePrrouy!4@tKiGdmQER7JHE?JpyZXna#1xh3W;RUVdI;gnyJc;ip{4!jq~ zw!q?Uad)@4lka~3s?M8OzrKop^oNR$)h*4&>*T-x9vEGIJIkXNbo8yJ#E%*4TYHM@ z71y`wx)4A5{GSL3N;>U`=ptX3R6b<#)2hSD@`S8dY)j(t03|3yNi_~9? zvIZz46P^J7!mR_=7>>TJV32am1R_z4D#GD-{QYRY^jd>Vh^TWZSi@ByXbk@aSPMtJ z=OX~EwRB_F$$X>fLrKRd^X-WS6BA4VR3DZa$LtI&tRgXpAX0#G@#5DTiOIrlnCmBg0nt3q;)@1ETwWwA)7yI;3`FPl-Ka_sS_QozxtEaOL)!Fo81!tKwEhF|`X zZ-DaxZRdGfZ%L6Bm5KsLqC-l8*M$5I(RP8+ZS~V`N19;RaRFus63Yq9p09n_D&R@9tLbZ+~%)DLdKZ<4EBnqDdkR3)tfkYzP2)SYs`x z5d|h#W-Bep9qo3^FzkY>kR^~7gAN=F|KnF#`Q zTfhpaWTFID6ZPjNCCLDNfPI z0ubq~?mMERIWi1lj3Ef`?oLq8a=E-*&e!WTS?}?*a_o4j8k76Fu;NV%ejm{M)Ki5b zrxGe)vVE}$k#L1z9d2!@%eomMNAu)K-=&Vmy82P7hFnJ8LAgz;?#V4?N#}q!<~KE# zn%ynVceqwSq2o&$zT(Dw%K&DI=wn|lu*^HB!#V?v)DuVt3SZ2c|e2*P6x8_+#T?ZYU z?Ah=f<1>QLd|PZ%x0TGmV|D8=io$u&K*yfBNAmfEVI2e^@fbE3ggP>{s&q>J<5)Bc-dDfw9a5{-)wUF5B&1M*$7ytbeUeE6QNs0U|C6*;` zZzV!9p@Fj9o12JjgOr_^rKLPqgac2>xjm#(KbJFfA*Y`~)g1VP4mn{iOxRlEi&i7< zIhy6cl?nyHy9^sw2utj44#otM-Pi&zj`C_qW+5_<%|VKuS3W3E{e3Q z#)`Vs$`&lu+-PZxcxa~enTZtj9W2-!3-+48{QK9v?zgvg*J&A4U`HayN%47Hcs{rq z3=^Qyb)DYMg3M}KjEo&o_CyEshr!)kqF!fsZ_KXOMB+`TnB2HToH;mmdp8rD>a->{ z+z~9m4t8AWrki0$C0i~}($J*4zN0)zI~INvh9yGU*=z;LLB_SEZAfFu)Lf~K?U+Gi zDi_1L8!@*oPn(2!D!R^-j4D}5QZ8WVJZ${?d3kpy%{s#7|g(NKhlXN0Fg_5oOv?sTUWa6B9j z?%+(pGcc~8`_(;Oael=T?-zENhfq`##q6eXElScODtEIKgy1}Z3#CbcowRbf(96i~ zyTaEw{%x9wQE)dDsqv{rHYDBBjo56*P^84gD8Ef;8ZJK#%MSP*sBJn!o8ujp&B9;A zW@II*;EJ$a&1Isz-j;66LDaHe?=~@gQ}J;>Ln)u{zpF^OeT1WzUrkD!!HM|>o|OJc!KW$xg* zeT)$K6oLj%$kL1T8qX)J*CJLPh7&?)_huNLTY=+&sE$I95`2sM$htiN7@pB?0&yP1 z)Ip2V;#368tYyE@ZX{9sG@MSry8Y7z1BT~k+54TE`@2`*(-khZ6j0e^7ZW^4D&J}h zX3DBRfvl~IC(M9C$8}I}t@Ls8b0p{24Q^7Jy4a_~<1`LEQ{&-6LXdU3lElZvj z6f+-=dvu%^t{L+Ztx1z66Cx5PIZ!KplcFuwu6KJA`*EmjRh zUHpayp37A~$U<_2B}nz%G#x2b6U6#E8dg%|q3f*>Clekn9iK$}Pvf{=Xgwe-pefoa;za7la{NEF3NAV6qs8I}vH>`W=zx z;~`Q$thx>W|KlEqBN+B@6eAh}bvsS{E>xpPITJ|+Hf(z8LkcV@;-ldMXxr14#3Dbo z2C^}RZJdQjMH!Q;@_>zFKHg}QA_BDTx=u4-9UDcuoZOTADGG?iC+y`C2U&My}L z=b_%VmfPjIdnVbP1P46|eox~v{It->MMn=-7wyI&in>bS@yr%s4Hrg^(rSr!@H;cE9>D7|snPuuo9z& z6?Dt;ax%Tt{ykk!)WIAlWnhxwO`|B?;3u%v0KphGW@0UuEcw-p{n5nkmYFe^kWyj- z6|h1k$W?K)Axr>D?Et7{6af#RUoc?Vz&}eqc5JqT;OPLPvtjd)g%!acF0$B}R(=GA zXxp5Sv@pmaqD?n5m=kLiZtc(*7*-d?Ae489p#rqKvb9oeFazWg%ur@o^=io2jol zL>ms){7!PRW05x!<+;6*Mqx1S24A66zGSNODJKxD;opDzjdwdDNnDOh=u8%>KqPvA+cCbJRZu3oN1A6XyiZ4q9BAqmJxqqBoxW1fJ zqRHP_?j2Pba|i#8q&=bJY(q59?QkJ7C>}5Un>g$?^SCdSt$FAwQZ9#|hqZ8ZWhcHM zO6+cQ)^-yyT(6k{t)QhpGHnD58?u^6DWceu7k6j`%dm%Fx*XOjXa39o1#={=WJt+o zL%hCW4`86%>JA2bar0oXO4VdRXPR&@$FHvI6hR}(d<=v1mbBXM_vUb-@50#BTK5P+O682@6mkhL7=r*Jj(7jM@Mrfboao&h-rftjUMiQAyXD&Iww$f9 zRL4YWV}t@mMMpP>gVpyDwBs5(j9%df9t;kWr7<~NvBW0=R~mHlQ%UDxua*b4#UTR)t*^Q-Oh_Q5Q3Aj|je{QPM;^+NMX1NH1jI#vyLN z2j*=-b#cVNZc@#5Ty6){bXUuZWFFjlej{&kfgpKB2qAx0q9N>$haWFDw=_Ah^2DJ4|J!sB1blm zeZl^tOrT_ThR{pXpn?kV;wuCyFws@pvx4^nZ43P zy+(-NzJ;EX!9MXQP##1KdoaJ@EB*QuQVKb4T5hSH#9U2okn$TpnAjaYEDxBN3o z&r1HVm8Brdc^*B}jzHkACfsNT1_upvo5cx3i_>$Ubk`e{N(bbyLh+xAijGRpfp!=M zv=Rd@dg9?37}~ZKjE&Q};GxIg7Swi&VMyqE-L?Qu-@XM^$Pn>r`&dg**1$^9V!dg_GrMhp z^?+yGx9#cfdJkZMSQRZ)iZP*r;s%^tIm0++xe+?uX^=^48__MgF=`U#1*Y;+The{x zo7n-RO&H)Di{=2Bm8<E!5u<#UU#r<~px;KaaynE`20{%`hgZbJWcVGH&m!Y;AXUw#3#&;wlXb`CDd#$xdw4h_C`*hPo zfKw&;!UVfFdpaiimKn|<8!y_9#SLzz+YDj^d3Q^uc zze4E@Mhq8H6U+A}W_vvByX{VO+lZ92O2&oBAke_h?4hJWDn62x=%f?g(r}=nWBJS( z-tYe*o|fJ@92mMI>WGd6nx;6kphV z4@1YhPT@yV;l@4Ixp8+6Avrk3D(JwZH&Vr5d0X4?B-+{`Qx#%krcu>8Qx%1Zk0ctM z5J(xt+2JF-gWfAaLO$LF-tHEQX0cezM2gp(^lCLCvqRS4I3p&~!{e>`BdYS6a00ILfwxLhu6`x9^(E(35u6P}a5n#nj_wPB22!k=D-;SxhtPCz50 zx$Usopl#7^fE6w${PYu6z~yqeoGzEsYSCU!mrHwDwHsVcxI~(IwYoH`%b$nK<&s0=uPNxg-=QUbfZ~@jowUUv#VfxA0g05oXeA^-6}19gOo(LZ;jKa+kS z`b?icH)y;sFSHLA-iK4$EaerOaGHZ`W2d)&^PnG=`PBO*7QShk#(RbbH(+@3@Ze?v zz0^$u2H3M_FuViU1MnWq?3vjEP1AVq0r+?T@;~!p|JfQ%4@AV?!+QpNk&Nj9fE&gO z zH1N%mnx&kIq!`u?jrZ&=d+(OvG{v(85AXep1-ftv8Z4Wo_Y3%N?R;7tJcB*F^W`ny zEI|Y`o)-;~m$k$rJhky*h~YDq1bRS2@Jsk5@B)`E7XXHDWP?K6$3{PR5H!)}hlU#O zm!cqP=)pI@#bGH0bPrIxjLiOpz)geZbJI`*PiQ_<_s}$rZ-8crW(oLE0Q0lcdV}Q> z0KCh`wp_x$faQaDIOnW));a6Edw~a-<;tLGpa>pNpwADE;rS)Ljtke^Iq!Yry*>U9 z!@eO6cxDfFGB^-Mw=c(Nts##e1-44>)-5;aOg< zK_f#izh>iJzOnTV9t?IbjK9dx_b>eH0s4%lp{99gnuW{}R5kH5K!e7kY2ZDY1}sO> z0Gv-<)2OELO_R!w-UDbBE#?|t*RX&xKz5Bq=6>!y2ra?bIKXCg0W#y4Po`DXpX z|FYZt^7J?K*e!hH7ngX!!%ZfK=!|_a-(J|hyg2wvLmGg8(8~r52=EM8_6>V9-g`Fg z#lOgyd+;(Hl7e^V*H7=4_qW9xaF6RJKD~xf8ppTK;I*`GZ0c#<7e6+TsSeIJ04R>T z^k)rV@R#TG1opmJHgI77;{780RobI2%L9<}OU)9Ek9WL}hvBQbHI~4#f%gCd-jxZu z)P&n1Aoxa}=+Vfnpa3)v@?6J0yf_tef;{5oruOjO`-R7g_wvtqIKYM9g`*TbY=g!- z#G68nr1^|y2_F%q%tB49C^QQ+4H~*$uJ6~^x9c6QcetK$earvu-f#z87P$W;aJ$;` zECuPl6^!*8-hemY?G2wk6=&`3!%fLD!0|Wy;jim^4(o0d=rgDZQv@cU%a?%B7h`Yw z6o&VJ2m6{z^Yv>sVG;0v_h6dusw=k3Fbv&=8>CF|4>kt~w|nl{1?{M`4C&wRu; zZoE&EQY;mDz!Mtkly{zIK3iN-y#J_bn?9w#aWb3wZ+!XeFvopb{m1{*TpC07|Sa0y>0jEC)?B4t&=o_mRms8tru-V}BjP|G1 zWfd9pbs(oN{|c-KcHTrOySYJoNIXW-Iey+SiW`VCf>%WJb<;itAaT~3!sLa$n^ zTC{5nviE4Py5M=Z;DYrgoLG^Itk$ca8Z0i0SHaL1z{5A*!#4>3K?Co-Z?KR-=o|0R z5ZFD?B<2`3a79=YG9`Z^dkcTWSc~T2)OiN zmJ^iHpy9?p$j#yL0?*z>^9`ZwJcIF>9_X_ZbQfmX0H*{3zWl|0Jsz3;1Ca-u%lMCr zVyfpC%K>03qW|>spZ@pVPCqORvzFl> z=mDPKJv;vb$Bb}OdH|kdNO%K$Ci?uKnkC||J>u-^8{bgVF#L;gFE2~q#QCBT3>^S- z9?;x)G*~w9jas5v!(IFfGZ_BGg}c#v9~{>L3+(+;KZJQ7@XZofAnlQ4IRVR}k_Q14 z8Va+|5)C~xzA3;^6QCb7b-iyWqb?75{c85%7xvuvrlBR8ra>c6iC--EMf&BMrfFF4 z^a4;=5|&FW34S3j9Iisx7&d6A(Ilfg%z;>jf6FEE5Jg)rN&6kZlG$udVI>Vp>MgUyW=CJ!F;zM`e8kBdwuKQ=hh@{Jqgw)4%59Xm6nUAZDTtkjjOcTiIhzOg zB>*%ebV&g&o9f?k348)RA%N_6;0i48HsXWd3Ix2u8}RlzLDESAvIO4ZH)mk^W9a#u z|9*s?sRMl$O64Y0lusHdqL1DuZEy0)Z;B~`!hh?ZLb(=RZ|UI?&RYLc%=7HgG)?na zrig};v`#tSkb*H&-$ z7$h7aQSdPfmxlrE8mH&j?}#9GhB#@&BYJ)YfalY&KDEJ%Bfr%;xIv3{yX<8=wZVxm zNlG>Yp4X>%T0(^4MiklW@WF#!G=^cosoiXV^^jh6y>4^ksYpEs-WgW%76yROUi7fz5CG!~Xb1cb&XeA(+Z43h53Z!mitXp^x%K)`l0^c3rG=Cx?V2`Jlo|T zA!LGRt`5WuXAX`{P+741sP4qZnO+gOX|GQbXN(()lFE&!%OR3PiYslRroJ!wi>Xp; z*OfRDk;nc(q@k!1Vg`MBDrYFJ^aGT7979>V=+v64AI6vnF17Gw{kT*v+uT3E7{`c2 zmxt7d3XBx_u96m)c8^dn#sIpbAUZGAHeBgBNOi%hI6j{JWeQgf9_3=h+cwxKtBxJV z6Dd9sV6vDAE^w&^&lHS&h^J}|jxk7#a+ZkhfkjR|OExy6a8v_DEt3*E^6_130j_hchd4bO5x1`qJsAEdgeK05eDt^B*Z`tk-U%vvo{%MN?AC3~7LqtmVT9I~aV2wT65CaT! zU1;{VsU_f+wY%Y?`>zY7?pL4h|EIrRJv`jsKb)8AScUa+7 zB&zpl-m&_tIyfDoH*h?TcCEbuc+yB0;-KP{vXMWwacomLIE$9kLQJ1r4%Mi0qrS6( zE6$wkHQh(ysg(VEk~J$kCBBhjy_ep-_=6yeW^yr77Vd`LAbmQ;mG*$Ma?yy+gkSt^3+HpVX7Mwgd`z0@UuH+rpE3WTS z4GR4ankEfLgdhK^L}KN`T*f?Rpw`a61 z9{<$JM;lHpT5LArtcL+1r7`R;77M&z`2<>&?LSnEQI2K?(j|dl^#TIVPXNR=uAxkV zWjHNmJKgPc2P8+NIL(bAT^L=YNIL@1sUSN$#-L{AsbfBj_?cyc2v^TGQHjY0z3Pap z^ibuyFK{?hmTcAI7xQHqKW0bB<#G@LOo7P`Z1{tCq%3_G?d3DIVOwwp};B^)Q+ zi77-72nI_a1$NxAv2Z}wV`Mcrqe3p1>uA_XM2>PI4lAXjTQL<`z^Qc}3XWsqb23)4;{_i6Ren62gaZXHkZgmZSVyrL^R##g>Sjg>zswhM;wf?~ZMd zE_^Hi)DdYA>9}ruL==pfqcobGW6O@gOyZLR zhSt>Yx~(R2urdjCU;6Fe_Hd35rWoXMqxI-ghe9~VM4+yN6(ee5cA@#t%Fe|)sKf6^ z2I<{)3mlFBTiub`Y9|O@v0*+Qjp3YoLb`(ympU#W8by(FJgbX4xbw@);pO;WaSuE^ zJUsMRJ>1{lWA)d->k8-CbaoFsyj}llu{2j_;0%8R$Vx&XbpV?=fjgJ&p7DEExZU2s zOrsR5Dk%_ieS(gl!st)lUdhUFq@B%sJq31Qjv_Ue`CRnUL_ZEUBkC{Tq?~a?{>&pg zKNXyMUG|uvnHQ?tZDxo9Gj7}QaxyX}rT z9U6^Xa?qBki9sDp+%%V`(#`b%rH=}AD2lDklxa6*J%efb)+@hLuoX@EP00E26hg|uX|(cm)&mLYjZ@ff(bdL zmXA`b>BJFC_5J+(a(?-L?y-7VJ>dRxpaxeD*VX_0 z{(gVG@Jg+N^Mu{cV6TA5O52URftp|dF5HYLt{3S;Q*l#QF|b@ALYm+ZH|Z&K5iz=% z?k&d{IpsQlJTr!5UmR{>s@_ z-Sn!v328^0JFZKGlhR+=)?9K-;*Z-?QK6iM>lWy_+X1j_VSyP6B5z>nMiU`p#?&{? zl=KnNPB%ITb)dwE=eJHvX$OqR^b~$vM-%9*jnA(@k>_qSSad(tS3k}HlnLvF5S3pb%yK*8E50=UG_bEsuA z*pl86b?o8_ph}1{o+ydRiW5D3`Jzehtub)Mu$$wT(wyRqQ3U8tp>uEu0b?8sxmqdh zoM9L^!i<84ohh#vLiGt3PMTD)sNBHK-ezAbvANl!b*1*MLpROU`Xx*J#6Uy+2ssG6+k3s>Z$!~JQ4Q{_2Vjl?52eu!n!zZ9x%|<}t~y)vl;fE?Frb*=*o_b&KJ+tCW2@4c4Oqc{mmP#E z)zG^9cG-G978_MD@+m|lI%meBtSWGs=7nt~VUDhd*c|O4Ym}eQ-Uto5IP*{#43!7m z2mwy>N*N$rIe32G-C^;mmUc{}8Y_$m>5t?b1*Cp|kGro9(4hv&X^K{{0>IyAoo6Ow zF2W#ZU~>GnE5%-69#x&*Qb%;;eKCv~MTU3c0Q#;c(ntKBbY_9Li2@xi=4zhz#gB~R zBs4DD1I?PPPwG3IvR66{TlkJnPR}x^c~gptz|aakC$K86b}0t%R1wD*>7s!$OAzbi zF`d6Jr5@`!`Z+=1p^b9oAwcS?&9Tr35X zT@S+vBInp_aKbP=htzI~{T42}ZP%wkyr7f5I;y}EL%wdY!D$$PcC#5y&*6^)l)o-c z*Xue93OJU6g}sY4b?XRH3?$B^Ei)x~ zacdcZdzUv5vEo=6Rs`olKAck33Q_`;@;+p2`~Io#1@Ib9CCJi#GM?HPJni@Z z1Eo7fN(^y3xi}z*?Vzi7KXFYcMK_9QyL;-lJBg$~(tyUOUv2tJ7zX~d0Ag$vb>3R;3VqAG?e9rC;=JXTpkU`a8h<3r>okv<(p--paCj?dJT{o1tIgU=jnbe%Pljsxc2EJqn;9l_p+jb zq|-ml&OP_sbI{8f5^mmA=o#Q(C4QiypCR`|;WbJ32y(2;hM@K812C=ZxTT zs>q8(L*oi}=cvcc;OTXi4l0u-qbUdC5g9^nG=ZMa&-Qdm=3`gcXAIEcXpSEbV6vwZ z$Ik5W&>#NviOBFjp29=}fsVb%(Ez4HOh7pHWHqx(ih%w|zx;WyCpJf6+GG_t%UU<& z+g)2e@qf0){OR!ViO*-pd>YQ@lZ7J!hQSU44o}CApANq~(VJ`#elG)M_lf>kuJjvC!UMbL0x|e7VshHm&=-4uI zs}hzfm(Xzg);#1L`()%_pfcp3E|xwM*#H0_07*naRP4Wf1HNI?;=AvFFA+&sVdHmA zrtcBY0X-|cD(EPEHnnlMQ2t?*>fXWM(N)|IF6ApJMBz5LuD%3vl!*oa86vQ?6!&H@ z6CH?-j1%)vlwp;_BmE7VR#Hb6ff-=j>MPKVYPI}{nBijJi1%}!v^+P>jJa)Fpv@FA z3gS735tb_D$TO#xT%~k}(3Lb+*cFNg;b_ZfZaj9lC5W#7v?$PX7ql6;%z+o~9z(R? zoc*fNJxrKznIqV~O!Gq*jH1PkW6DDA@V(}!!)|MJNtAAM9e|f#f9)Q-E~~@47C_g{ zxJZdG3so=aiSmhvcF~Uy-SjYBe(e%r-?fRtIHF;JmrzR@Zxw07iREA^OW3#I)GR}diCu0r)6RcDiMN!N4nZwlG zfE#T>y5%rWApEuLs3%Pz zIvkD%L$C-*g_NzAQ#?&rW}=jiZQE^RfJgyYhrTB_SbI9B1;GeIsG>Bq^nFq^mV0}2y@xae#W*vqa>A-nxGI=&jA?g17pZ@U^(cy47 z<20NsyMaJj6FV;DT&tpmVUzoH)FZ5>Ex5?mrlKkwQciXJiIs;n_Wb(wRZpLumiX+` zAFTQBKdo0k(YgZ4LB1ihfqS!6;odGutHQXNm}dsqhRmBP z2npq|^zAHqO*asIjx(%?4+p!(TsaXc1(j1>c%R~~NJZQR-;$7(BAKYuOMHW9Ezn@I ziU0h514-YNbX;-L-xR(f4-Nu1P%;-7@+zYEuHcus9Jr`=z0!)Fsx01Gj!wjVPkfI_ zD>O@o!x7*imK_9WGQ)L|xso$sHEl~J(pazGt5nMyx|16{AigtrN&pOj(X^Sqohssa zzT_8%k+>;9-tGbDFkPYmI*K$}R5Fehm}^Z(R|4&r*z1*!q`JYRmnmJ-(~(_3k?xlIxqhXl z6I*A~yB1USF`N0HaC$l%h%oR?VVnRHYli{Wo`B=w5Yyf=$sy?ZU<^x0)w++BVo$VV zce1CWIhI=JA_tc%LNsW^`Qzc~;21;YK?cUOd|k*C zbfk|*duD!qrZW%L!a(=rn3w60KK$uF z{zv`O5kLRT79a~80hs=1`kvVi)hZ^+T}o`$b*H2TbW|wn!FVPdQoLyhA*%Wkt1X+L z%?iX8lXw~cn?Pj0&@9shRZnj9j#3&*A&ygk$LIuA6B-OChV!P!3xTI(o z@roAsy$P8qi|V%9?Y7%?@3-4T70=6p?JTh=3P3C0Xjy;_mIVvCZM*H>V+p?3+iiz! zw=C#7wSE5{8*G;ifbG0Y%d%kVyKVQr#k_3MF7mcZx1{qR87`BUN>A8sF#*dY&d||n zx<#)rFZgZQEEC$!dynz6Ttnq4d`<76R4@ouPAta7Nnh+y6@tH^^5Q2euAFe}Nhv5l zF71v0kPqn&NKqf&^N5k59N1&rE24%BZM+wd{F%KNoO&oYz_Vkp2N+KIMh2ujvzYXT zkQD@9=)$g-%<*xzCn&XH#6*(hd=3RD_Uwnp-aPJi&Uzdm`l(DM*AzH0$8vi}-j6 zJdgJH;rMrtj~=iKyNzckFD|^ni`PZhO7T%;$AIT%FToglqMdwc1@a2OCdAMvG?1%Y zK7Prx8I2;ZU}%3dI}dM1_|Y@G^6;Br<}EL6ykuuE6cmy3-j55=VAqh^c}dmqn>P*R zL-K`0b8H%l=`TLzzrcGqkETH*My)=-6a*zFjp7~by>C=7?3SPrhtICg?+Es#>^+pH z{az_`wb&KMoXpJYRFI5svm&`DDt|hlph&5h z1rR>MCtF%Y$_Fo6fc8W?FpeA?}lA4Yq!<7X#c9{WaH?|*puU>=Qs9<4pIa%}x)kKLa3YB&1L z>0&pY=)>bUjPCg_!|C$!c^rA;6aW`2fZ2K9?0fPX0}<_ZG;aLmWnjy8^xjiUd?2M7b{p?UMF!q`HIdDVv>%}XJxO;S4Fg_ojAn<8 zsvb1drp2@mz|T9Vrnv4t-&9`SE!&*?ruw?$Uz)7zd=dW+0=Pkaz%Z4W;hSu@GOHX9w<06dOZvW07@1ZvED%iOzbsM&- z_%+D`oA6EJ%_z5$dEC(s4(z?h#)mseMGt8rC=m9>{N#ZVFaEO+*(c1N87xssAPss{ zJX8n2TAXivEne-QAXRK0_rP?$4~Atu-~L{CumXXUV$1K|fBIj5EoQ-YZG@y9REG}u z?YEH9m#}J=JT8_fj9xN;UY51&0!xVQ3)Jpb&~J-wnSKlCS@86~&e(3T?Y0ZHWme&` zNJ0w)*DqUj6GOk>0v(nG%NEOoWx=vpFfZHqkpNnO#oGn)Y6GY(I&7i3 z?RFauTy3`!?Xql_8C|zk+wBJ1t-@9<%d*9GS+LB@G)>DgW4mD6p<9+EoQ-zdscpAl z4xkw=wh|N51_g^$1t|t{QJZ<;;j{nhy!WahwMX9bBx|J!(RE&J6rA^HRNQ7&*iB=U zT9Yyfq445IH*T7yk&WiF!|2(2Kl*Xx5gzP4ONJ1<_n-!(JOey>@5YeP#Q{Le_RPcR z7w^?3lxjuxL@?o3EUxKb91o9AKm0)0kDfhykIz0@%Sm{O=eT*P=Hu}QuLg;AbKb@5 zkv%B_9v{u|@zLydo84~Tcpe!Whi0STf1qYhMgfoeJ%9_3k}ZLhJ{bN-k{)6#8+nFO zUa3t347P^lpUp%civ+I$M6a%qRc03yyB=1XaMh6(mym|x0Cb)|JlJg z_$I!}*EaZJ6Oi+B3pZCQT=;dWe=H#vUa6F_p!U!TUhN+H-F^?%Y#P9C06;an{T_fM zp2$~Mach=yK=4J-Rshg@vlqxFnj1y%P^6SnP0k7S3JKiCZzbahxzK!R=0ZJTEn?=6$ufo06dzF0)c4n6~S8%wKpH2DXhJU zl-hY&0NFQwYyjUV0F7_3-(zopGErB4Vj93JC*Mgcojx#~60hL>=+k}9*0cAi{7}eI zqe=s&h*lwap2Kq`3rU^UQGAdJE3`mod4E}5NfmDuueI~}q6m!seS@!?kX#7VIfUPb zXcb9K`EHAEuLXLRo@DWSuL`U5P2UdQD=~D)7P*tIqT;$iHF_mLk(PXcv3Q5%6`#=^? z0%Mm7H$##L7dc~+;jLOINzcZzY?V;b?e_hG1=wJkA{o4_zr6fx3t&;(ZTOcKP%W^8 z*+hvD$08^hn6NCE=Ve|N%-e0(DYXPXd|8(57BhaEfGzq5EL#=6*LDfmd6_UTSh@vx zzunFYps-n>woqFvTeRC{Gs}@CYrAgSEs>U28>sj1p*pB#*>u2?8T#%aQ2xs@&A%=4 zyq#w#g+~P}(>zUI#;@OfQJb#{$}5TiWO8RK_{c1Hq0u(NIQz&(yG$)Oc#nPK;hp!5 zSEJ`)97gY)$B1!c&wd<79|E?$#L~*s=yzZRW&H-8z4rp3$B>0RdPa!E9@z(yVSO_S zY^5EkhJHAH`1s*R)uABZkR^yLuemM(xdR$0J7fIcf=gPh^xLBBvz6 zNHxq*q#DVe@@PENMggF`p`PJKwkcUK2cO3r@&Z8b1J5i~IEMpbmPMACp%g&F2AVq-yaiu^M&~s)LeWGd71qJ75GDw28MCLXM@Ls7#DR>-@ z=Fq5d7D~4A@)IX{{`30M> z9s0-*HyWfUmY!VHswofKr>xN8^Y$>k@!tE`W&uaPT4cPuOQ4BO8lj^1cyB zb&-#j^)*967KZ>^M4L_xOPbI1fJ<^7|i@f+FX~#rxohrc#mUfJbu9onOY# zZ2R_g^ZIqOeO=zY{_AD9{MXaFO~3CSy(0FD4-1)cEa*9&y$u26!QPL7R|e2fh_D6) zYcB7h_mC7rRa{WHrW>H~fMSVzRU+F}aAQnL^I-u{k^s+uC)%Ug6(PncaoYnP8-lFI zAYfmK2bAR@|Lk^GcLjn_VO?$I=(tA7CsA(E zD5o}28MY&-$pmf5t?W~6h9(@gQrL&vn1~c9uT&FO%N?K^kTmFuAW2`OJTl5UM4n*@ z^i~E$P^2kllLyI%@_8{-MK)nw)hm@F?i5w^hCCxGL2${7-GpL5s3kP`@;hjQuZfCo zihtstufW$WzGx@~Xf(SR)}63vy_TyxOD3)0Wn4BZ>iWiiuh`sG(+`54d*~f@v^V>m zA%LCoP>qMfW{qhH6zS*Ddxu65;79LdbCKpW81Umb(iI}U(R8Q+EGwCvQp(GcEWC(| zO~SN3YV02SP2+q}_W6Rvjw@!ke9ANY=mGU^`}dy|6x23wx@rk?c!HkW7Tx;-(JEn- zqo{WgWd*if_?@oBR$-aZ34&d!uPZP+qEDr^YJu9S8NY?!6miH_2&);onM zp3-G2Vvhybs`uD#(P6n9vv zSAIuk2SpOG418uDnFk(6uw!=qvxoEK8r49h+*rjP8^=u(dh}kCYm~5E-g|-Uij;Q@ z586@qfa*?X)nLEd@0B7&Pe1&$+v)MMKid}wcINaA3LXw1MF3v@dVU$ljZz~pvK`0K z?9HRrzVY6Rx`LTUd0nH_240@TaU6Z)doufe=e-~8=)vAQ24gH41n=2Lv)@JqxtLdq z_Pd>;9nlU>kcxtb_oHAgMMOITU}PS~0e<7*z2yL$1x|+nyjKIW_ddWjr4&?5HHTN86h#!578wppQ^Ad8 zrF~%0ZV@dTwR`-~?3EK1+(*e<12huoy@3a`hFADJ6i|3quj`=|;K$K3dq6!t((%#D zZ#FwLDdJn@?O*HqX!%YXZk@uayocH=BNUWZQRoAB5NWR*Gbuo+pn8Z4t@mXS5nhma zTndjH`88WZDJtE^gm(syaaWM;OL?^3uQogi;8~a+Mahm&C1Bu5ZG37Lr9C>Ue+clh zc?4Kb5?Q>7CpJ)$8fZwOxK%28C7|A4-yuqQA5xD!0p9DL44Kih#}_P`u(@<+?=K!(@yFDV49B=8S7&d5Pzv2-)1KNQeL849Cc&V3CICr@82u+j_ zRvh`Y2CGY)#!S{t3$1DQsFYF4`wA{=c!b6%R@IhI^k38LprUx$`~dcfd?-~ztvQ07 z_a5U|zFiZ#{{otKN|92;HYf^fU`N>R8z_%>D=MvpsLo351X}|d*0gW-%8wp?Y(UtH zz$-~Dq_dL*S|yQ7bvkrBe=3pX`O3zV%;8eX61Ulepls~%?iH#*^Yw0yw^#T^;eOG( z+TEBEyIlzz!as!2Z%i1PYSo;IRUc=bt{V7LQIS&X9m?S*rJ+ORZj2&|A`oS0zGG-O%yev>kNL;8E-Fs}eNg0f-3Vs@k!gj$H*uDpr zkQIU!P*E6N!0$OCX;E3or%ekwv|FfcyDUN{Z?WyLz0!n4ErtqsR|FgKo(r}Cm3DZ) zbU+uC9%|cl57=Uw=IvIjmlrHEw(kLKmkvrT+wC&_>$2?>0M#wavP^TgMb|w5+iChO z^58)uf~~?dZ@YH;{yo%oJI~v0yWO@^jETt@dYZ6IGZsw0VVT?R{emt2^*8hnSOO8h zEKAou$hp9_+de#E+5A3Fuiw7&8`pmM9t}w$6mLln0nBluQUN+UrNU2{dHn2sgT101 zh!pKhKdZ!j(j?8l4sr0{_r zRU_&ZY+`dhff4WFH_m%_jDADy&KRXeW|5l;<}bBtoatu|+6hiRK0ZAif7;Q$A))|t z8^A@?uJ_*aII?phye1;&*)eLeqhn61jUrhIlql%qx)cQ)xBcW) zkZb~umyHjg6pfF2x{iRYLDRqi{&Ub(^p79{6oLjP@IV3TDJ86%cMhYkR&(K=@*=6> z-J3&%s^%t2$)|qc)c>j6%M;;Vx;kEY#X@SR>%~1v zlYO#^^otaY8CX;Rx_|+xw3N*(?8B<0dq_ctE{syN57$&FwGYx2Q9LQ7;$0Lr3NEM` z0-;fHijA~V4YNzUcmw52fECCcpBi8wwcF9i-hXCl0^PIU@5%I}g3eB6hLrN~GJzEuovLB} z?A_?y0zWW&u!RcGegiZ?rLZT{Lp9(a?3Uh3#C&mmi&B2iv0b2=2ISzupYt$={~QJ4 za$6}Mmp-qkk+zgl;XHCAE4?pZaa^f_LL*VssuC(B(3xj7Je)%lIrRqEYyvs$6_zFh zgO`6^U-9}q{C9Yb))88R_CdK3-Z-w4w-p+`;+Pe#rCC|FQAjLefe`OfzE5nEYS2ih zg%l2tds05O%T=SWp^a)38qb>`=Qq0#N-4=jRuF8nQOlQdf*head$ZyG0{7S$P=qf=bVGCuFF|SZTw;_iQm2-uFxe&uQWy9sE@O7RF zKaKPTVh@Kd*idxEdzZGy$?Kx+Fi&mQ%3tObHPS&0s^{uMvp}Tu>B#=gnB|}+2_J7C zrjRAxPSYjW({*C~5$*LJe#CSMMtCWx1;NX13jTdla^%267v86hXDN7yMBl!L2h0;N zPgDHT!7pT@YE0)67mI|vl z$6K3!9QvLa$($8rz$Y2teYOq;hhCDqIL`G_n$V}< z{$&omVE{Hpb`$}u@*G;nmf2b6Kd?{;aa-g_o1O^PG5|v+NITQCZj6d{Vp8o26KW2D zE%zMPqSsrRxn~A_I(+=}^obom+d*EbLC}(LMn&XI;ThETAkty5SOP?c!s;lS=txL( z@Yz6~SeFzu;ybg(T$?U2mxuq$^DlO=M$SB!1|aE7S^&K<*|$N`nc4E`rbo{zWJlbW zkEC_*2Ok`}A(~_*FAoaR%JW&d8aC z^|weid|W0!%552+7v>!FLmGBK4xx@V1VnE=ag_~TG%;k>$PasAFkgrrrQL`UNGI;+O`? z+3lq;<}lC)T)%ntMj(K-%Qh;vjN;rnRn@Ij6L&7C$dU76Zh;d@Bbw-0A6&_`ILh_l zfs=zFxp1LZPCI1fI#UAs9JZTvjZfIK;HYcbmaIQ zudn#}if`ZN6@zr}S0R+i2Zh-V-HD&(+s-j-6BoK;g!g9TPQ0bGxa^paIw-!AF1pXG z?TaMOmrXoi3xabDCa?uNO8DVAg|)CJqHB|Xx|iw|mf9PE^*2vPSi&jayIiFPH)8YF z&e5W7m7g*tU_DnEdtJ=*&VMO?epy4@@{i!k0!v0jJhuT^mtJz+)$0SQZadV68oZ^; zY;ei&p5)+Lv9FtRo{RkMJYk;j@FReEy0l$N^$r!qG|l0oy5f*hw)nh?VT`}@(593| zNpNg)9Ha~eU6zyM}z0AmO+3}*Bp zz>9mw1M_e`WdIU(#mca~TwDY8c8s${Psv?1c;vh226gRDhjK-+$#6IxatU-2dS(Fl z^zq|AeEej^{U}G?k^{)~z#u^6+7Il>91bwg_I!phV0Hl!a}2`?`>rIQpi1wmP+2Mn z;v-%7`*ZTxWf#E%0JyU~TM6{I@`7c+konWcL$7IYI5C{HG4qjNXs|9v8{YI*GY0xV zRKRPEHU0~Mx0upd#wae!pC7?Wls`16V7tCyuR#={c6giC!}N`X133kz&+7mnITUgMPG0XC$MA0+ifUw6f6VJ{l||V zKmCXQ^UweME&DFZ?%i`JFN-9R@=4%eI~`GZ{7=;~as}xU$Dt2WQD=O)&Mx6-Om41h z>4;P4=)FW&tw9F3>HeE6Cmk@zZIPphLVi|;r$hu8m_uBFdho!+U?w;4t;FOIJk%d} zIAeGQ%#CpPnP+ntK;nmD*fX#V%ykC8n=hwp0na>iBTg5%1NCnsW`G_8UtemokDG|ie zkPZX_Kd*TOGN9h@UnJ>S*rO8H>Y1{B8NP; z37n=lZOQZw5#}{S{+(rC2MYcF`(j9P_0(PG(oSYKB6A#^@ z3$L6YQGd5StteF8X1K#N&mCH{T>||xE+I}P#1zhu_{9mp+)aR3KF<>_ zbNlcxw;e7s0*MaHQxvfP)7*9Fx^{|?IkM5++(n!}#f+5z+~@A0o2Cx)1uY&w{P^;h zU-5zouk+@=cKqK{y&7|oCQ8}hxn6|>+zQb@%&^R0*3>`sM$of(O9u|Y$v_B&H-rP@ z%)|LS91cAZB`8XeTm>9~gDk7j$5ewzK3NkJKU;v$0Zy|kHru%3xm!z}HVhCCA$*1N zs>spbclGpS-VDrqCL97$=j!@9IDa_JaDXQL>Eow=`1DDbk6ugo0?DWJAXwrpa)WOg|-aP80Qv!Lc>6orH5HN5s&5-;Ee zxMHJ^k&k5l^zrGbC(ArUPd+YN7t|-C@EFZuO4^HbpOYSoQ+!2tMZxF6uq%Qwnctvf zGN!xEX8q%!@f*nbjr@4(bCp=4_DDi!qL<7OY*{k=Du?p4+kH{JE+=184fZ%8Y| zywawpm&b>Bl`%_1>xyi3zW7!GT?*JRIC`VhY~j93%Azzmr} z$B$3XKmWY$ErblbqOTXQQHIX((pxU=-q)BTU)3_dDgY*;JDrVC257*+fNc?|D)8Uj zh0axfy*5+7i=ipQ$GX`<$3qEDLdYZ!j0o$)mT+D13lb#z;}Vsac~ zh&i7o6yZ1Q|4RmwtNo+4Fi)TEq~oNa=}_0v_L_D~9Jwp2d?6bu_WU}_nsC#FKin<0 zKybo;*((~j@YpAS7XaU`S2v;m^E(wPj%&1z6#CN5ZAk}cOJB$Gi)Pqf*8e&9nU}uSmDRS2Gm!qMh{3gmhFRm*(C(FxXZ`qzL4#%7( ztc^ZWT%0tmQe<@oG}IHoWb0*-iyeowYMj5|CB^bFwR$4~#;r%whrgAKtl>w24H5OgmqQ8|b3>FMLArvn%mSQ>ziLm+o9 ztXZ$K#LFVb@lA3z{n!;=@lFb1Ep5Qn`Vb=+6D!)A|M1h3>0vpAj7P>jkcs3Zmn^7x z`rZ(T+{yCbC@{f7j^uQ;G9Z!idaU6b+o4MTy2`$(mQ>tGEa7X8+P%TT@ht@H;Bd9y zla`IyR?Di+pp&DF!G=_I0UAusaeN@+Ii_{q%5AhmH^Yxzy)Eg~O^nSS9ik(8i4lq! zX=PwN9CS}ER=6Q$ERtn*xY}4NmC3zUtdOl7zkjJc%2h94Hvw+n%rYz(%5^EOOi#ei z&(A4vun1Uk!1L{n`OQOJXB5M2H&GYq(u%saZEkrw@8O8GJ&nV@znA9t5Zqv%YttVf{3)| zfiYzIj-v{O`HFJp+m%BzV`_tlqC-hSw{6DIE8Vf6-fjhyyNFn$0HZ^}FsBs5f?)1y zBs`UR4Iy+dZN}XlGVxpxkOOm}Ff2zCpme43-cBl6smzu0{Uzbt3qG6lN$ zp~FLm8Muh(S=i|dx>kf7ZTk@T?N)v}{C&F2(=>HmhpwBZKx)tVBy=l%O1K6yrul*v z-H(scKflP)w4`;@JaY_g3M6z;)CPbP zF|>TD{4lCxP#@&Uq`pn!F7K)?3oM%GHC&{OPBsV;_6rI=0Bt-&`nLTtc41 z5VEWQ(pnIw3#nacXQCU+2&cPH^NB$a8j14xFQbF$#xhC8%I%7FTE4-HUT3H(t`!=t z{(B`pF0;opts$U9OI8eT9c-+jsVC7VajCnDI|^H-YYAR`gNMlIdNsii?;$vgE!V}@s z?O<>=eLq-RUh{Yh4B*_E;M~Z4gK}Ge)Ya`mRlDZSyA{Pyc`bR(gRRuP&y(l-^l;MK_QLnsw1waVQ?M zYeMoia;2*_Q7Vc!r91)-nlZ>@YCxt|GICB6yxEOS==u770PZN8X?=htUB1qn3aaIg@n(*y+I9f{b7_`jFp zExM?EnCiEl3yJewiJXgxy@+L_=3#odp@^QQLj2IB8Ne(U$&%%Y`JOQ0@`B6`=R%-E z3(WKMtJDza+N7?=1PB!kbW(}Z}_^n@AUVZ7+;iRyrk>v9hsP7W zj|T$I%xMc)$<-Jjjxre1MRUyM6!QWU=Uzae5>GJN$*hU6HDTIAdW<@*azkuI(#ON$ z&{wTWdj(#rZ>9;3hZBcNf@nRg!*oZvP{pu^Au<$_!L{5QHx{S$pi;SuM6h^wIOci_ zSrF-xBVGncnoXpfhJg2|W`i_E=26d3Yb>?V}MobEo$CjzuF z?qsWzDE+4Npl}8giB<({ywFq*CDe1$rFe>JTJheU%EglhXniH&DwPt1n=J47nGXjt zPf;tw7@nE0xk={XO5FiN=0LpxF>{`xUEdKgvzp8ShOn9d58_=14(b>500+2!4QBFc zmuoZ^PBO20JGv@ANVuE$Q%rMUY7^s|-6XQ2If7;x&=UX~%rOe+TucgfsKBwvA;L)E zoRrLX>;TMoL8*K$0q_j8-Bcab6?Dfe6m>H15Yjp_-4nWph|%Y{177AtXiw;Z(jyN$ zCc3yoE2<4twj`0PN7qi6v!O`W1ugkB*GJh&P13aw=rCR6t)}k7j}tCuN;M4VDJ^ zByy{;Xfp@2PbIr%9X}7l6Rn4k6SpFo$Si**GRDXr&ug7Rc96*AMryA+*46m-dN?`m zRu#h+R%jQr2q2I-P)|&m40U!$ zwE@TtLj)bhhncSk|2zyu1fX|3R7Wp6(ZIT=zSr!GgH4T-&@=6gF+DR|JII1y4(8+G z$)4=_d0^mRv@v=`R}HZC6kLB+%?Mseo1#EgexWBKBDQP{0Bzx%6rRLa^F#tqhBXft zJ|`k*ePB2^8|Xs-gI!UQrNvD((3T|yys}HUb+5nK$EQ2IEXrv$NX)qg4f>_*KSLELBqHhyME5r2 zVNEDWi;U1x<5EBxQxI~1Kw4iJpd=BqChcO!F&<&WXhBWOxW-~d>-UZ~i@Oh!(0gAQK)q+lG^|6cG0*IWLAq2I?ozGe6S#DJzO#z;Rb6l+@h(Iym<~BQQbcJ{$ zBjbls{4CPpDfr<n+c3k~y)QNn4SI&=cTWehPu z^YD(C(a9SoU9*UlMT;B``2m>F%@H4WLC(>3T{jmPx+`!#!USOlv~7m$0NSpb=PB5l zbaIS>p4;vrNI{~qqiY|c8=#=?wtM`sd;Ia`&;JKr=H%qjZZ_`}M;e;$@_Nj?GN*}~ z>G^y<9S%PkI%Vp~NqKII@fRVAhxWXC?|ck*f*JtQ6FTWB=4233$># zkMqDMYe`Hdh=>QEHxaGtwaSA|Y+T(ZswsHJlkz!i)vUm1)rGxZ3DU8^y1E_S8lcvf6429qYlLOoDQk_pVG zYGGwq%ZCG9*?okjYuPRi*Qr?UgJL_s@V+$?t(&o7wI_`s4q~{Q0B=Q375jbPhlTih zNt2* z3092d^d!gNR@*d1r0PB;o=d^(?ofb(rJvqW@!GQU`R`uSNJ zDyit#nkv0kyiShFswyb2nb}$x14BIs1M|(kINN7tTVaB=!&Rbw4?#Q>>?5eEg0Gp+ zqJp_HsH_nNztNmYt_An~2MIi!L$#uNxzl3pet+84f!zT7tToZ`ux>uYiy;t$h)6s- zc-_+%<|em{bidw#ZW4~ddB^J(M%I)5LCZ3SFlx4LoiVRDUlO{a!1uKPYE3`iq!tH( z?~X}xqCTh~lC%9#kbWKM%O&EsIF)TVs zN%_Knwmdih#4@AI?sn0*cKp+~o+JX$WXlKy^0}>)7^2jT5H`)wm8NyI@&n>#+y&6w zp%7Oj>$kR(_v}O^5yuAC%yclNZZkd=jYpSJZpDa)p91J)7BJA*nfC3XNTdMe^GooL z4zrM#PQJ2yyUT<&4o%MSBf2gKIRx|0fzfW;fU{?jpaf7J!Su8y#oLDmDLwLcE_LDI zD$HH`AhMb6;m2wE6;r^_^D8#XrrEyI{cd=Pp<~Gy$D^p{VffEKKhwu2BG?F>5!{Sf zz?x&`VF<%3!P|k3rq?irn29YrFh~JI5CXmTwD~Z9nkm8&iuxkckXq0 zt+-ycXXbMyw76k7kUTnM^x_%LmeS^`o1?R^I?}FOW4LmF4^>I!hGJ~)4}0_#`$+`o zLp~x+74qX1z>3{T4IT#k{Eu*-=;=s?oMm>IGZuD^i0F9Gy>Y_{<%7#BrK+wE_$Dn{ zn)b#eNcUy2u60lJQ=UuAQ-I=8E!@8?jfA4vyjv;rulUO1=5=?g3IGo0TZ72bqOqCX z=R2$Sid|2iwE-wlJQmGQAQ3<{QPnTzK)##^s7)N*ec z6I>~a^_GF>b*bb~+==!I%o`#id$JTKWma2DD&aK4X}r-Ksn0W^HjD{Gf&~+i#Sk3G z!Wnk>|0USC@!y(~ylusCqXqB~B*+<<&XE<4(&rAryCV$zX@6UOACzbcW|WMp%Z zXp|Cwg(sK!1bd`V!N;aM6B#06ttC}q&5`o8@QNu+WV2=b%Hq+NTSad~u_veGR1csMRRh8c{(S<*%y3%6zty*D?2 z!6#1oxHwHBf}zFvo%2+mP2PC|JO;m)+KM&BYwvZ5T(Hw2a89j{yQU@%!? zvblerr(7Mb{OL&d2})JVG^6%rDHJZj5VzdBsY4mW_Qs=Dwb?ZXN zC1f;I4)0;awP>A{fO~CuuvS_yC9lb<#U6}=Tyof@N*o~9Q8PP-)6Wjj+Ca>^Q!-V+ zOozTdR-%8Vbps*=soVwqTo`0rP2f3)G}=qY>dYkdf|%lk<(gtQii)no9l~U#By+3E zh=U2Ej`tQ7SIreaPq{faDjd|6fJ^QVD25>RFw31IvZ3-z?Rt*5h+(}8SU>1%|ahbD!{IrJSl zhrV%UoGZ@cDSx63@k)QAs6_uQMQkIGG-iX$k%$%`T^rcV(Ozvz5OoTngF*6Jns3Cc zkt$~-<)=)*EXs;|FgR1oQ$a#^os9MYT^oefQ%0y^sj%a67VAKkWrS&q|{ZTBD&4`7-LiapTv zkCK&$?#G8o>XyeAFQL+zTf7znXquuYYvnjo)}&0as<(r{9RB6>^NG*L{z*pD94AOR z1kyMJzy;iJ=#QxYUm2ubm&Zx4$n2huhfl`?-`HA%eKVyEz+r&19D8Gx7(}p$<^D*d zBh{ky=M?||AOJ~3K~zV_!y)AbaHN8+;{{f$f9bLOeCA=`r{0i6Va4;{24;@^K@!9# z7VkKhuKdu3T;SSMCqySe=fe}FEIpzEHbejt;uCr0lPP9)Hqyj=yHTC+pzfc3 zI#S=S-TVpl%wimib1o}kO3w@3XA8gT97aPrF1gpN=E;m(I1^c^<5GK>Xtl#}$v>@{ z!@96gO}92(_mM@XP5|tQCFPOUs(80nHJ6x*=&D&7_dljmG?n!?S)8D+^rKX6*Sfr6 ztC9|y$hp6PALW(hRd7!W9TW$x$(a5CI-kyf?a2&A<3uc;z)b6bB8oyxy#f&l!JFQg z!3JEl*=%OL`TFj4{IdN1*A1}yk{RDZ6HJB}Oef?rgKGXNzZ#%E)sPCg-hjx4RjYqs+o_SU0yK6_^yLJ}Ri-BW? z9wMqX+1{>voYMgn?taw)IDU)c)b;A&ZmAS*^RGIGq2SgDkaF;t;v!sSzW2B5lY@N; z)eW!PUnt}x)SQ>7S3-Y+11G^8*Y^yT387&_ao{~t8Wi`~o7q^mA2+c!5^ouL>%m;Z zaQ!wNy*hUd=6OO08R^75xtmL-wvhLh>~3;&E(ZZiB|;l9bjkbH2GLWD4WB1q?%KjW zxzcbHkuKrABW*2Wlgf^|ivr;e>o=--==7=<9lD5nr-XZ_=>l~51((0f7ocs?b#3>s zDlWQ8d4l$#owKK3A%g)h&%&fnQkR%#!#gO<~K08Aa(y$Lx4uG1@>+M2Fs(AsN(! zm!+k+kl0eG?<cE%j~K7joH^n5;$KK3TOktQAY=RnU>{J*@{ zgkP`>VynqSvtf=s;B^;F6OrjdVPN2FZIDnoSMYE;<0w)^wtPDG`fxP8F`C&~w(NKq zQg1mEsMkw8pUx-rMjE4o$YgcJSzbfuYjo~zk=6wo)&0|_pAJul!GSG<2Z>Xt=H*v3 zN!-Muu8pWaXmd==x(=O-dM91!JlL(Lx4GmC<83Ya6I~m|xx4#MVSrq?1D8{ewaXnD z3SplVygM?);N&g?)Xx?r?4Mn-a(jd*YESq|W4My`t~tcp#ES@C))~B-YOT&2GRG|5 zj>L8GS#~&M2u9A9kxDkk09)7|7U4De#@(cl`bv!y|Wgk}og726QgeGgP~$UEhxUhPL?TsdRUDZO8dwZowd;Ydp0k zKB=##!SW<>0oMB)q2(cuN3N3%Wvl67dJ1!L6eKcN+&A4)t=>o@&kjh}b=TFrFNHKy zB1+^#fmf-R-jKW8>FYYS`e?@8hDx!h1$i?SZg*7Z`$#8m#@wr+RTl_AHh6Yiw;+lZ zhsIkY9M}41cXj>ij^-843pZ46BHzSUx5k~&)9U28LVs@vmajJ*N_9Xlwu4moZ`AWQ z;XHHnaiwZIAQ`ZtdXz9OA|WAyw0@I7j^To#{Tdq7xNnA|{|3tWezm~>p#feni?4Dk zI)=&wZk{Va#BKZKlJ9*eacft;CLrnvqgzB@j>0BSB)>IfyfN8o+xLnY7m^-vn_xF#}KPQn4zRjEO-n~ZRRhrO6YD4XA9Kfly zqHHG8AVWRz*|Mb1r$t0qxM2+vo}Zt8IUEh?U{_b{D;)gKvah{m9xPkO|M1htgUMMc zVOe!<9fIN<73tTx4=z9A!k-$J2OhKt^67jAp(o=2cR+~0%DTgHi7cz(weoa1JDfQQeh5hfUTG2v9H1pfOt3y% zuIZ`O(n|miNAv0F@a$kuHn)tKYooo@Mbm|JgZif@lDW@;vwbh&+O9SB9w<00Y8S-l zz>x9hjTM%i(`+MecjY_6b@Gb_OY!!Hln2F&kuHb5*MgR9A&k_@iJ~hYNfZ)li{iBG zy+$5A;?(#_<^CK3F~t+H;Gy-c6oGqlocF^QkctA5=l%qS6Wg%d?Fs(Prvc1_`_Nfz zH8co#-Kg)eabK2KT=4aKd`|$r;P)@%@4)uUm%si#{uTJ$e^comEE?YO3{tf4DyQEV zRYIDLk2K%eQt2&9USE%*CCNZsDr!^09N|`CXjfHDL_oSZZ^Bd2(&(P<?`y=RxSD-ecz+&S7rZgyF%BmvOciN0tE`; zUV|PG1t5TatX2@fs>iBFyTS?u(Dy(O2oxpId-N&#vRw83YE@#jTJ?R4vczhI70|cn z`^gEdfYoZXav#>Zj}5QsfucaRLf`s-u2#cuidEmcZwR16FM6zopO*#t9#~=J{_9bS zRoC~cRk>QNP^?xN&;#EB8Tuam%D;Kv_X1*7q9|7@v@P1-wtd&H(66e`{0q7c849uL z;&BRhjlu;iv04=G@UT8Msy)v90h_$~Sl=*1}o{0M^Rf&?`4ey4TQ&=vlN?S?>>t$S~_u+~0W zYnhq(z}5nIw3e;Skqa^a+$S1i!`HAD011Ggu5U>S5CJ*S^`m9?)8GbTthMJVFXKK! zF?{=Atv$H26xKor3n;3-tlxfdePylHo(AV!2m|a7%+}ssUAar+KGIs);ST^S{G;gp zCt()TP3Wq8M2&U8HTwx z!sh01Fo(y3JsbeG7KYg#9uKy$#vm84;RXsoT*Cqo@Tb8LfHi`0Kmct0p2-f1OyodL zS0t_l04anO!oQ`pZctdTe^VgS%39~vQ{*jnXSK|nHAPr zA#(rdSZgii+Az`u2qdI%uXoRmHLy7>U=3iyvl}0H za-R%0jX(&I1C!?n*2c?VhegMR4+Vz@O0b0$7FL9z0Fl8GK*GJN1$y9M!4{9!=DG9j zFb{vfWB=3$|7Q7QMHUPohd>5N$n)pt=jZ1qetdd5GP>vIu6XVW?!J9~d^|osAD@nS z9=y-|dkHIqzlYXcHDhrlg5yn?K5aNJura^^7>!92p1qtbAmD#REYQz6kjwFzxIb6I z9Y&7iKY?5z6A%`BfMr>f&=n6s@%R~ertYPa$d-y6m;MQGG9xe_0>oB=qf%O2_9suF5r2AoBN%{in8YI9r_YWycLC+8u z&)J(i%W*1J7pos!+l&5Wd(agiz#2ICD{q(1Q2_3S`^7#9w z-w&Sj_l2KL{HU|A77Ep^fH_Rjv%4c~he1kVz!H%X76J_6zJnaG2gE5W>1aD)JoG zy=S^VvN?o19|Ep{>u_!nI_Dq5&FSmI*mk4XnlOQ-@0Nq|e57!2-V$AlqHJ4~D7`^O z35@)q0dz|Y^h7fq2+|>@8!@`X)4vn4IZ8FU?mW@$OfACkczN+HT+&K#UG^mOC@JN< z-a33filXd-*GB8O@3KYfE(HqLTiK#5x)w$G&^`b+U-<(oZ(}p0mqZuksCyC*ZHp2? zw4JD>OO$QrowGygONa8tyLgnqhldh3?Vz20C~t1s?gM`1-{j?(y^$woW@7S6qoKi{ zLXZcuL1RpC*I_o!l*$;$YPl7Q8QJM{fhRm&_-|d5yI=19>Gyy5Me!LK;-RMvvA0Hp zjpp6nx0Wl~R1*p$6qhE+r%uCRy!sFvtsi(GADQuXv-#P(pD3c;zS*;O$z@&|%e+iK zkJ2J|@k|G8tCwc!wc2dzx9(c$gddGcgZulP)_Sw931n!}s4=6aoQzV*aY(4M@Rn(7 z-EfdqAVSixL3vgI#tlb_FzcO$0?0>#g$(mS7-M)U-<;+s1bYOzRHOxnTuSypV#uK1 zVGQPmK@O(lArX0`j;mav<@Y^u3}$TtzkXC`1BKiUxsxkg-N7;8-ca(Ni6O zl9X05V1}%%krxV0#eB?$2AT^~vy_SUmt9qAp;O<7BTxhQpOpnJ?C$^F9dVQ^I-P(Mvg`tcm^_@UXZP@!U|Ww_2uQ&5m+6s zo>sqp`R#9BEO2?215K>68$K5@H{+fceDNfuolf%g2X%q>8dvE3FsXpX=_?ZckgyPc zxLh4c;xRsY48hjHFo8j9uycx_hEWaP%;&6z5~uu+e_}G1kqIZytoO0ul@yJ}AYn2u z7+3l7K2Nkbq5I+P&@(62zRVyBCY2S?WXveC%*c{XJuY63M*%=)m#Zs&IzHQrmp7{w zDo|yZf!!Hvh*w1#azcg9lUC*QSBH|tE76#dK<26j8a+nOOM`mshfbRc_YLzovB=WR zbLwUpwHQ8xmpM(LA`qMXq(Q(8lS7)=l@=_Cs#==H49W14edlSEOQ#1q?g1^Z_Ue?=%;~Sh{YE za2KI(2x4jHKX2Q%MA?-QdA8vL+in3vmxEDs(#7aOdHe7;A$z6s@|L0~$~MZo+xB5} zkPi2iPF72)ICZY}^m73D^NJlKgM*f{-rDPidGmJdHKW>T9C&&8 z^$FQb2qp|efOc5DB&mutYi^PS-U|*SmIFM->S+Lq48v$G6R(G%)l*{Z(42-hr&Z%b z@;q5Eq;w|KR4G8BiS6GcDP;M;jGFk2_l;ezYXWvA^cK0{A<4U+@N0Pzs7P(h0Cx*$1Gm`rrqg9&beLDJbu7@UGf@M(>fIU+|7o>7|auvbL)g>;ko`A!zcgLrv%hlB-t{^W@r&5`*zh2^(b0t{AQqWui)T5>XWSysX)1^k1)KyM6OGQ@ zh-|d)G8{f}F^Cg{>0a<0lYvqAoS&lZ8I>1JF-CoIiK5T=-n5BB5G7t2skUti&JsaN zXA6G;&YrT1{25rGyZ}DGJRX6AIX=CZlf^}jtZVmSX*Xy0L@_VPoPls=f}7=RH)dYb z<&Nk8p4tTxs+!PfW`jw{61}F|XC0D;hsRpdWUP)yH>H~eKuXC@q3&nN*g?o>%<=)a zQ_$>}KbqWbn7tW)u6t)v#F}FUdzCyjYU#qga^`d%IvafKHUuB&2{;|RDq3`Ho4U@0 za`X}H98Q;s(7B8_+=EMxKppt?9B&aAXs?QPULtLXRzYeA62DwH z^s-2LA_vCWC8)IRgM;CYOKyV&_DHwgK9t2*4xY#KlNM#^J?Su*1L9%0N-caRV;hgQ za~+ZnkrybtwoURNLyP0hO^cvYzb)~hbGwXZlf5~ek}feUsX{SB&%wP0($71WCm0+7 zndj>B+pN5z&p&TFI_*!43TQ5$xVzLJp1$q>)8C!myb$aN^2PKPB)DSVnS)S;h<|=RCTN|kjQs-1nHr84X`1hyh=YA$v(wC4 z)$0&F9OK9XQVw_1XhxC(8#!PPoe?D9aUT+Gf0gpd9^N02;{6}`XhQ8{@QFz@#w3Z9 znwU{bf=N?dXh`%4*Ka|po7nNpa}%T&Cr=#p7InN7WA4rTbCM9bDNgc#Uu5R#32*w# zesx@30yrFgcey&^@)EebT>bD8*Q?8`%N4qpmp5K=F9BlcQ7h}z;f69?0WCmy6WmYo zlh4i>tSLPoAHz+-4JVck-u*3YkT80Jy-cbB^DWyR14>B|u$d+4X!=i1QJQYmB7Os3;qTqA0!gYm^!2=a@?p-J;!0?m7W9@zk2rOt&uKcP~tHA)d27 zLk8d~N~^Y^K>5LU#{ocB&LgtB&;?i)@m>6j7ue?b zk_BiRKe!wN-7;e6^hlTK=n`d#_QOD>Bek^iW+MxS6!HznRJ3!|x>5c!K z4(6*8?L+(UcMeP!zk29^7vKWO7Us#(Ka82Z!aKB+$u6>tPUd)$^79|v-rn3i(;q(m z!{?8`1ZyIEzf6z%5O)cvouZ$<{{-!Qc6(1wyYv)m*7nWOJ$|Kr1AKND0V;T|sJaYhu)zO|xT-ovPPF)xf#V zb6<=x8gha#q@UT7MQGWFfO%wF9UCU2apN@8AVJTSQo*Eeyz6<5Q(VsY8um#fXX|hB zHjcp}8M_J1d~G2zzUj?Op!k^%|K!^*r_;-`Q*a~C99n(KWp0ia87?ocal{i2r;|A0 z+0%V)-)~f?YXzVv{Qw|VeguveYz`F;j&*!W7ECrUItgBx^*|X;D`~+qn}*>y#R_Z; zCFLD@wUQhqI6UC95zb3d1rgN3u862w*Us?8?`GKbM0%&mkTWv56^qOq50-DTVn<}S zKRfap#Hdgj_SJ)^$Oj-%k{_6w(-Tc&87GL-NeM%%HnHLXh7a*81HJ1Ebx4s)_YdJ9 zJ-w=>3u}gy!=4wEQ7#Jr=#P-A)#?hDmnUS#9ACHz>9ahdlRwo$_#E#(LvLySWc+FB zCb6ixSjttBYoeNXzZ={?=nUgeuc{d0_FBfR%P{jZVq+zHJ31RQ;27uxiVj}}^NKdI z(F5EaaVK zP|Mvw_6{oSa-i8qXW%&VZm`twBy`&XZCQR5vSz$fT~XdRkX#NKg%6#lth?cZ+92O9 zQIj8I6O)fg-9Vk}zu)caid_EM0^XuCavHZZRuUjHa+FOP{w0`W zMR>88%qegog3-{>s+QsCdBh>R6LD*=m;FgE?NLGa!{Z!>NDM0)iV+igUmh)IXly&*@t%T)1$vf%6N+rXZ`d`lB=Q(QK5hPk2UKBRPd32C+7&}Pj# z*d z1>Na*G8snD8G~K-zX&=nqBk?*p(h|ue&Ra~L!K&PJ$8uYv5-p9U}<%ReU3rmj?x+C zHA<)E@Q-~Q`#yR!7gu3*KJq^K;5OH2&Z4hV31tQ26ASrqvC zw)mT0IU&akL;KtdBr@f>CJv{}KJ`z>_V%lruim|TrvLhH|5x0<*BDIfDnFj;VdiJX z{Wp7TtD^q0dw9rjI&rASvuAvyG;9Di_k8!4pr3BufrzIIZ*q9!-64_pawka))XQOM zmQzkNK>I-)=XX?S_)f zK=O$sL=31Jy!XvxmB&tvPUOp}-?dhx$nQAVoUv0)S*5US>c+KuF#zA16M4rx#O{Ou z03ZNKL_t(as_@YvccD0B4E%td;yzfsk;S_eNP z@WL`hBUd|ej^*Abk(c>aiP*?8F65qD$s7%AG#Cxlq z6M41WSeQp6Kf^hByxh3rw;}Y(OQ!QWrD@h9{v?erJ7edZ0MWBOb2OM+^Cy7|9#deP zddA7*<4!)X?RZ3%pGJZ42?fBT-DYZ*OpHW%HF*CKpdcGGI~bZ95{{}8$>2!CY|KQ@ zopv9N(o#9@7J2f%i-L34Ga*x**=|_CNmZK-7>!{Ei^F>~Kt<~fZ8mQEy>J^GKc7Uv zd}@S-oT`Neg1y{z0nwxDffmIIz5AH-^ZLZq4nV&W0`cD~k({#dC*H%G+yUr2AL-(b zwC{U#tJMl9(0=P)(|4T^=vSrl16&ELR%@Wd3TS(vM=#Lz=pAS-oC#mwXTWN;Dpo6j zzVH2e!=JLdIK@iz==sJtchW=ZJ%iEW1g)F;3>LX+mTRP_* zBjWkKd3k((esgLIROMG+|5^3JqwmE#*3kZ>sCE@L11T$N(eFQrsSCFA=aA>U_U(UgHH{! zf1Ptqat>YAKWW!iLwpq}I12=wJ*EeP)fdBKQqCXCGs;JXcqMwFgEtT%*(>$|hcd;emJNKSYvb zW;1p+d){Xcbgiy#6$tilu+~~nGrdJ^A7aheD>hV&>UR74a@=7z-Ay4BywD@Z`JzN zxine>2n&X{gM$SdH*Sza*kJ%-a3u52A;Nhix?3%THL$r6)(W-<2dl5>S|}yR8Gy0( znzPx%Y zT10z4hGF(@jqaug|2XTszSy`Evew#QcNWb2Mz>N30Z9L;5FiPWL*(Jsi(ELrD6+^V zPGnL9Z#wHt3eWkJc~3X?bC3Y66M_rxPIWE3v0(TFk{6e&({qpKJbO8U(mB~pUb#hP zGsNi(`Lz(Yc2rLjfz_A(t%Vd&%pch7t>tJ>S^aHB3Un{=LTc^)pR zAVC80mBE`V+LQS~;*8Jo9C&&gmp3OM&V06DI6 zK}v|+vdLCij*B{<7Q6opj6FN9|8?+l?p^H$_cR)8 z5J#?R7|r>!s@zpgmJfV*OddNPJ%wQJ7CB*@NqECI2ZgP*heMbX!jfXs&lNP7**QZy zA%qa*?lJ+$$you4u!<#*js*;)kU4VXfcpgqVMTtWAVAk76xrrr9b^_3f*{DU54%6G zvz7z(p2N+9ks!@Jvz>^c&*Y|rjykkuS^Dt6 zg_pW_E6TuLkJJ-$^)pZ|eUTne8Hnwuo`|U}H?5~|3ltr?a>jFyIPcbzzb(o#@Z2et zU3gc%Hg@-+O^>8|@GXN~i{NwDwMF6Iplxx3@}Vq4hIn}cmu}cbACLkCN)%|jw(ZI& zy)MhPY)jm>QE$?vG<^ZI?ZX3r@}_)jap(@0>+738{IV%;`M&Y`Bya}2$=(P&zowT3 zonBsEo`rk!+duh}%g_J&yMK@U`};Ae;*E?v@lsQ@0f6R?=$?6x{jRCEKScLAD<-$%F_c3H2W$bCuJN8p?S>S zTyf}klVGsk1Ny>b7su>$xq7+0d;x>`<>dvVP?KutJTPZi%sD;3Xw|UXgeH?f_2dU~ zK}$K*W9c>d^bpqWdPJM$AoJwSd7gU%w+d)puITY3F@0XL8TvZl9aus#w`+NoY|K>9 z?B&lUl=9q7Ycy2~%+S+k*;zL+z)WVDjh|2dG)+_Ik2U#x*UHRU&^~F-OO?T6a|;in zqxaoyQ4E^nTS9+bZS4D^4?ZT&YXp6SQEjn~~2td4R+h5@(#2L2jZ1>ROVPvJ}^f9HAtauMQ zlx5j^W5KXp_|T!n3GL}rl%SIS7^n$E%0D8_UK8zE-!bbK&Q_PF>|$Iq9Q^FM=VyVk z#D}*0`sNS*_`mt}|Be0K{jAs z6`E)~JujwNHM>#c*WzRm3r|sGDG3C_1`G0c3dQ#^>?X{;d$A~)2f&TK-`8q`rMf3a zxd{z2(0aXI*R^IQZ`^E#d7pwi+u(^fKD@>N#?U;TFzKx$o?3?mUzOQ>n|j5`*hncA z)^$xvvF0cN@z&OEi-fdeJQ$75X6InV5Ek{u0Tb78u0UXT(NQACOSGGA>mYs7yZMyj zd(vJt-AnP3Ji!fGlEb*-$&-@ywVilgD*T1jb&6Z2R*Gw_QCoik#eq{oe=l4JcL;eAMj#|B#QE5N{jUF z9F$B_0*Z*BBtX!6*Dnzo6?q)!J+Hy@fRc@Y*@xD;@qnhp&X0HQInF=;`lsJrWcK)y zolZapDP=04P89}7x5egTG0z|Urb#WIC%BnDN#LAr$A}i6c5m(`2~iYGN%sezow*0} z>^z=0h@{gb?ev*C*N$>#@DtJCY|qS^jY;goy{c#6cd}tHL$gY^ zyJz+ilSIbQPJXT?;_ty%-yc}q-1x)l+LQq=OZcqs=#CezZEEosp>we11KO@YfwJh@4qaP(UXc7#)(T9` z9=HpRXmEUBUD38u+eW`zt#37G z9z6-&02-S$_Jlo=Q$sW3q6Lmmz!S2C9FxK5mL)3B6Re?}#x$|}qzc4CzfQt#dN{#; z_T|O_F4vP7o|c8k!9goVUdD$R`Z5zQn^EMd3;V?m21)-yXq_AI+os-BROzJ*7fw?# zBypn&VAgt%p&5%t781jA&4x)6)rnKYQUnQ&oaqQK+RV1taRr*+q2w=PMiv$+nV2*< z?RPs>SDVcm#5+z%OrD6z!QlGs+s(E%I{D_rbb{z8N0blSCa6Qg9rYSAC&_mut4-Y+Jcg(zQ zVv=nffpu^d7;}CmA+V?0RpxUxcH^X(p=F8Bts5rQRwMQs@+%zOm<3NvYmqYSgUhhf zp*!)m)9SBqV7z(b+06NQIQ_P#*CSs?lrEy9&9h`~*z6H31K40epg+GzgmV*0((6h~ zVpGhFW(VuS&^Ial*CCY~6B3(sv;UmW9D^G|REF+)(+5KKPtcjxf|gtQWJAti}T zCs73=;)WMJdjl?{DmLwnpHP$3MBEP6?+uvQr>+xKnj7dn#(7aw?8#^MY%=~GeKy#D zWS9XM#yn+w@nkM8zI}PY%k$~^MA4^V!C@|LIc3tl_bHLjpF~xrZWjR+AVaf}j1)$@wo!&O#1(6; znNhh^fv_2ByrXPr5;BP>xw zQAA*l+qNtnJL?$YA{t+m=T#h|_Qt?mm!9}8W8!Od5tgUb;mx6Y)mXwj8r;eOh- zEtd2qfp{J|4m%V$;Z*%8Vaq%0@ArPCY=DXadsqPtYY^&6{S*wN?`&rB(`o4Y3D3;S z#ihgS&p-TO^#@<;J3lRkfD`guSe34SUKr5;RnpbV4YIC1nj^B~)9H)@t$!?u4J%n~ z*XxQZM;>!hC-Tt6V5$vZz!=>$&<14Kpy9+oVgR>@_IQKuZg`#tAJgI0iQZ&fhLci~ zS_2ii3=SCRUJ$RqH^~FU-`&H)ERwA&1FG$EAhmQkA6sJ1jQ$clQh^rHF{Ri6h6vs-R&8>do8D zwl;w4DIyaQ`9jpr;Zv5!?xfg-eeY>WoZl~Pas|B-z8ZMSdD19FZS^t zJ1~b}sleAQ^xo0g4S1^8qOr5jt7PJMU=U;o3W@qEN}DBltijnsQ%H@~I4j}`J##$U zI|AeUr&O~R=ESi3;OS0!4x=eih4Ber*R^xDsCFy>Cv0-c)>K92cKmk8n&E_bHbb2~u;xvo68?6i6Fe%#9Ye|w5_atAH zB7jI~rKJw?1E0?A#&n}u8zxW#4IQxHU?`X1<0XC&e$O3_X)M;BvcGEWCY-RedqC>U zb&T0bNfA90$bgx{6yYZsSDa4Ks%s_pN9nIJdoq1_8FmPu*-P3;1*0XJMXwB0l~QlF zRDl`XfJi4T@ZmhP^9$0hk~`BgB>CRsxy$32stz}c0dUjYzrWK;k#cbl?&kYC28;n@ zy?wiO=sBgI&6v81E=XagG$bYtv>-bdyxsl2A{T9q#8f$1iR4%(FceWVGhiA>Igavk zw_8<_efpB*cTk1_)^e(Sx?m_ ztXWbFX&+Zpy!#yUFS)s2fbWYKI_eh)OK!S>@;l4yBXK&JS&uk^mH?_G5l}%lNr@yf zdJ)a&;72)yEM@|AM~x5x-gBI_cv@|V-pNkP6RAWV8bh(0dG_*@kv1`cwZD&k5RS$6#Gw-*=o4Ihx%mlxRn1YG)iCttqHbm84Rz1V=H0ZZeiRK4FzkYZK=iHvp6#A94Pxi~y3;nMfo4#`(VHDOM0 z0rYRg%~#XkUj;NcGR^q3KYibezDK`uU!unfaP|>BdSv~o?^~=^=(`Sm*LR&Wtib9s zv@KRW+77E8_$(NL^nJgYAmE~3_2mkEhZTU&uqs#RSN*CF9wL3)d9w>|@6n?LR_$;; zq6eZWN8k5-53E)z1P6^iGTW>8UxAf3?pSqQ@0>4nvaLSzktjr_8I#xPBs%lJf2SV zm+#hJ{^|WUY!8iv6$C+I)cx)*o3NIxHTh;s|Ls=X9mI!k4y+GfZs?1*w}=1Z|9t3n z;u%Ng)3eKVLYCR#2^SDnCiULT-BSmfBt8rt_}yoCf+tHgtZpV zOv3viSXj2k9;~%&5llP`OwztRID3fDo(#x}zPJ{`b<~UC!(h$f!{I}7;67u^e6SA( zm`B(HaJBjI+du!a%^|mZfIh(D;2kBrJ%+VH;9%J`NuAxPmwSKW4Z)bcWteklMxQj(~ULJwE(=~2BNKp2>ifi7TA*~{t37e;4~-@aU!=aap714~zuD9_2} z)<1>0L+4_cFeSyg3pQdVF@{l#LwEcFfARAX+!DF>2@#|325Y35nTD8;C7gYQ2XGcZ zE`%TmdpMZKr6aTuVG zlEW-yjj_fK!)3I>3c98o)*$x-5`fJi$j@W+1*E3xGbCv1|G`RN0GQs>B0-fp?cVJ<@>Vi(i6A7ZN`in486v?yD|A>{tmcv@uOhon(E&H&sm@QcBer+p8;Km(+Rw5yrhl1 zc_|dd?AF*Y&FoWSH-x|X#&2R7thSpP`u)Q%PsWSDPp9s=&xQ-0c|_3{=0AV?U;gk9 z{(xOCCIvkpnV5MJZB%8&2Gu;K?e6}*BCmfigT5~qzkBH@i~-fvTCFv?)|tU5H0Zp? zs?l^pkgi{lf}phVoe&{&oThx0({57JXm{;~AF^SWa=`48#=(X`%zHK(8q!fgObG{* z?EYyS$+~DI463)Ab-e|V)_ZPZy>#SA%ah*vp})v1n0JorydFKTRaGfAj>?U^=fL{& zn6#jZ)Z1DqKx0o(1kHhw8qz4of?bo)&Ll}uqC$prJxNlsF~7XqQzh3*xntBroQ?4s zjpekw%k2pA2DCTkANenK=IIdmt)b~`%b-h-q(t0$^ zcob&`cHNfo!Zfahk(@lmiD2oRFv7PQGA~n7G}kopf|DwZc{Lu{hx^iiobhCIUd>?6 z>l@s(63Y6+kT=Ydh)&1fqJw$9klxOC2z6ky2kUWIF#|h5vuV8bv)9SI?o&-5xH^(C zkRVeHA&n-H7;%huU&!Tooj#nFliXNiRv;5700L$f=1W?R(X%?9c3!pV07e0g-0c0-uO}LeM72d2yxu=W zon@9zrjntSIC>{l*Px~`yWr?e0Hh?S8fp#w5goUjx;F>tVEB6?W;2J*%@? zf%Z)Q-uDL3NFZq8JO8@)Wt3hN#UNd1y{6bpK-w-ux0DEGas`HTYXk}N1hWr4faML) zmZ>4g%~$Qi1KJP6Z#l&53_K(j9z`_e@XC@BXwkM^S>B{3 zAML|~gU4O>0CWXzT9oM8^5zC@*LH2&wYQ0myM*(wE5p{KEz1(+ZQHh|;tEXQIFpmw zDrV?A?MuqER~u5A?%s2w0p4??i4au8k3! zAHDnYufHOIOa8s=_sRmNmp9zK$dfcPQ!WA-IZe+ZV7G7X>0UY6H>B~hUZ?0ViD!Wq zNYqtLHN3OF-zPA0qrqsrTgHHuC$bf%+|W*E*6>KPDW&ucKt!af%IOHrP#1H19bXaV zMtdyI1l}8?$J3|@4|8<=3JBVj8fhpq8V}8h4XUboyM0@&>qh%zHL8+=T!R5k(?}IP zR#Qw*eAaD2AgV~wx+cvoX*VhQMIi`-X=u{VXqxqzQr;xhKpk^3I736#&AC0q$R(yQZP0L2Mob19}_| zlb*aj+j@UiN#d4p89JWgX|WI2TW&YR85l%oE-y_L3V!YPxY=0)(I}n8VNC;6K9O7R zM`e7yXGWzIB)OJhw;70ob|l`AL~0$J%M7TZH6igi@*8v395dVj6@#+5@tUJiYXwo| zG=z#&#d^P_`B~hwF#)71x2UDnc6N=DrU3y}MIdu=dh^2B33PRZBc7gqgX4jZ$LAMw zI>nAm_k1+xp%N{D%U8`8X!>km*|_05bQ>%Wk~HMp_myIlAr-EjMD#TBVstiq?qg#+ zhYypfYOoICjiqPA4>kZ2DnxA2qVj5qX2C>t6E`Y8j3=%)M8p*hh*v7S-BMNaet!-I z%W-DlC{l{~dxBXe>b7?YqWDQ2jPe?x(%;L@oPEgg;5khhldU~QO%qR zng^?oCVu=J>bDp|34PY0Pb^F=`I5`hmL*ygMcZ}W zDWglhLfW#MZAMz(emKMzwjtNBz=wynECL^279|R&eZDQr7O|TU8K3A+U8{%7f<{%L z{z+Ze)qcOP>)Ju(zxv}`?cfoXH zj}5T?x9aY%!S_&vpZ!l8RQTpEw7%Q>nY8g7-Q8c@fuQP5z1`ps^*{g3|HAwmfSym? zSW>LicEd!v`wf8Kpu+>HAHMwl4}S2ue0gZaMccLjt!@ioAD+rxm?`Pbp$Wyc<}nL`ACrVl<&+kbTElfae25BvNX#-K;BB8D>dn z7+|9T)9}90PSia}65|tCMG+zg|DidP!6fO&@7}G~)lN5tSvUSn-HYqG+HAJ#wc2?v zPlsIxM>M8cPg$a1PPpfZk;ItxkOWl`kq1{4JSjjEuZ^I+^!?KG zLL(FMmTF0CB$3g~I3p9E6M%7(&50@U63LllzmsovY@8Qc8X!(Gzz!dZoz^i7B#hCl zIdxTc-4=;@*zfYCMAI0eN|G8X4c-fcqA_8dmuS7IYQalrk+8Dzx%AS(3JXWP-t2J z9VQwM0J{7aLT3c__biMq6Xv;SgNIz%wGTc7yDW-$0M)y;>&o`VbKgUBb}@kYWE)W46zEDkwCzA72SH5N z24lL?cRsd-|Bl1yHzhp&E(4tRnv*iv>_v9IB-Dy_3fL1-&1m*_T!U#%HEqDm_xR>s z^DbyN8V0D|)Qr1SrE_Xwae6_vy0|bWBRhE_=-ux9FaB!#^MAL$Bff83jqm<1^yVk( zCqGwBqqZB`Y5dhMc6=B55goNz1q*kEzQ5;vwb`z}`pN%z|NcGeJBKdodeiI)sH%$e z9qBvw6mwN8wW-x-^pC)|M^sn%L7xBM2WT2(*|+=;zEj5c+(~kEe^+7Dzu-S)=#xs*XuP&?2R7_u1CtbegLGmfm=D{Z^7Rx&d=CA4lBj3yKZz_>Ko2ee6vDbwG;0AZcm3UuL~$Mwy~MUF{XIVaXg%|Hw(hhVF@Qr?Q*}X4AS>OsxiGb@*|K` zxlE%o&k8L{YQ~0vV>aLC(odXsh+*!j}1 zSFpf^dJs^&xy-Jsr^f@HeuMt7 zCT1Gtgxd}XJHEvI9v*l#P3z0N?~2omhS&T zaE^$qiKH+Xy&HTzP?rgpqjQn*#P|h7x(*y!R*$5s?}yw zueYD6%S-HWzuz-6rG@e!KG@x3C-0T20b=OEAlXABu1MAEEtpNy@T7@7{mMy8r6S2} z8lMB$Xbx&Q6IskLEnC&=?dIKfT>}eGb83Czh0jJy5Kx7Ago87h1dJD#Bwl0$+Wz?6 z&o&z{G-D6lXyZj1Zpl&-z>f8{Qc%!A6JZw2i$*Xo^1LBfPfs)P;(1DPx@VVmF{sA* zm9(p2eP}fAnQK-&*maG5J0_Bh180V-Op4aq+M(w~=MhdNe1^k%9$u?xfVYaOx*8dG z%XC?aWFQg4u!bUv!qe#DN9?7dUI{v*9?hKjrI5KNr(A6SB*~Xy2_01i3>%-=N5(r> zjSo9jbDQ}ZKQ!OXkzW$NK+D`S&$Q9Ar7QO5&+zvQDG*N~b@CZ0>>)ZmJ^?FaM{wqp zX5r`Ks{d%K^XY497-2NTe5U1aGkSz%66QuT%*^K%D?Cc5kuy{y2M#%>29XvkWf2MiP)?M$O(6|43#JaaU%vzx;WUfMmK z;eh?7nuwW;H(mDT1;Epj`yV(SUw-`$r`76(*&ti0ye}zgh|X6FA`A<=*s!fx#8YvO zk~FLc(pNs`_RN79S$Gpl%4`%l7&Cw9Xnu;cwEZPso)oA0694VSB=S5=HxG^R*PuyJ z=AgP_Kq(*CnoNn1QkqoY?#zRt(loKpH}JTDO~U}x22=xpZpP^^^x7VL^3Z*ByPOgw zXD6;jtxkd(XwkV(<^yB;uRui?i5z)^Ionj1;cTP*N8I@Az?++q>Z9|n$0!Szx?K#% zS$^6vL=8rXvMlk?I<~kd+XvvG9iL-@r@OXw;Ml92yD`fidm6*n4tjgFh+~XDBv8MM zJaX~*mylmGRCB8EElwHX+pf!gSA5|*3x5?rdC`7&@LqP~)W*NPzuRoz@jGhv$;|FO z$H(Xy1fqJY9I^G;mtQAq%$}L~Th4yRPZwE!B`=Ss%S#yMyI=fbv)$L*pEaypG!bjw zz1Q1~x?^f~>}FQl)(qgj(VDT>GZ01kUIWgeRt1OWkRFs>fO(`y5al3z7HqT zXb0Tyn)~V=RBeB{ez&c6|ERq@!z99k=rCoZ-ZMOUPQx)+60J8sR+ZZCcY2dmqj~>~10s!i|t}EJ~cUDfO(eW1vCFx0#h4dI&RIJG;U@*uapuBvQplRajwIoB>FM%vrD=V0~j`v5`(Tph#IRIXW20xLA{_Y zAeUqwd#uci?@G~g+HSMJ>G?>wkFS1MY-k*joDu}Qh)V!?nu-n65i@a=`!4je%kxV& z4wH&Go8VdQ8S#N8r=@EA5_!o90HU~-tD#vUTvg`AS%rsBOvbd7Fov-U2GTO3 zz}5Y=q~(YyfiZNiEdyRg`|tpVmM45HoSeg1I(Nl6Xdh5@5%N?*CQ9kxcw63t7#Ek4 zc#HN!puQ(`Ie@Zl+p;X%ht`wK9|i5s+4=z!$2~_yQ&HG2|Eos*A#1{(fr>VSn)Y}1 z*z2r3)&Irk#aCb9;aBL|)`5FRe<$uCAKLcBkNf*OwSC9;gga*Ky0i8`jcPXit7^SL zUDM{LKlimqrlxTeR|BP)_sn|>owhdbMJ|y(1|@PLVJFHzrWws zKl$03zNY*C{k`k32`nT_-{Nf;4d&8ehT3fEdcAM74topc@k7GP^BK_^X4k;bB$*;1 ztt(Y;H`_{8K7wH2Kx3PY;TiklG>%QP1Cu0DRI6$YfE(?*$A~D2F{Da)^lXMn#kJ`N z7L}RFt+vjoKx>DC%tzK2#6TRz(8d(BdNSnMsLH@OXS10U?|5l~8T-SyzxMmx{o8sY zeROy-SY%>5vg~Y7sr6>9h^DPUoYoJ|w!+A;u2X!aY4*+|sT54}3<4G%q~ z^LLHnjlD?^E72TNT6`FdQ)7}lBj+W!_;H3~2gw?!!284rgu;?AZ#x}^jX7WcJOh_$ zft~sPSbLuzNs=@>?0Kbq-u{KRhbDZdqQnSF*_iCb7I$-mX#oXj8k!-s0%i|$7#{b^ ztNtKeb)D;82xtxq?9PFJS^`>NF0oB9Aa;Wp)JE>Qca5dTXPNe81`lTDKO!Qldq`y$ zs;jahBm9TC*|Yb(?>(84&2pq;ljG#0qe*OJ$N&EyfZmTW^oK~{@ynyEIf2w}kC3mD zWDgO|_6>sja+ZueUX++5N%Tl=@p@JQ9bN++f`8mB3O@#oMK|W%JM7C2D9e3!7kxRV zyMlh7(0^lwJ<8XZc+a5(@O*#&@!S8t<^NG`HqtbqnToILy2iEz1bg{*`zLp~F3Gd0Mbvy<1(ss{!2nMz%MQrtMp(0cKwC zV!`zl*Vn>d$o7jilaCMnAp;-KG`I4_|Hhjdyjoqq`_-?muhzW11v3jTAY0i&Hth!< zRRQygW!r4m%Z{ewE#y{sT`yL=y=i)c-UqfY{?YH<vem&6)BRCGhDk9 z@@BnS)C+DziW6q}7;hA#M3h2?NtAg+Lx;fe+cT^}@AFl}oy!q4JGqp-WSNm7=3_s2 zTDXg%;5u|%q1j4-?PT3bLENe0%QA7GlhLp_V?ie$z{W2g^;t@qlS!o;b$?AVId~wb ziV2m+GKrEo0)*c!pE%FgrPZwv03QMSkC1=#@c8hNd6tv*VmYEq<$FQr?>drU)8NK? z6J`d33u)cCoW2plIHl0~Ct}gty|pI@BV6@nLZrJG=QbA4ND3_%k)mx<@u4r!kJv;8 zTqE*fv4)&e{qSH^b25b-Yw8#x4VrYG@?x%ik8QH-;Z-){AN=qY=lFa3@M!U1A0HoK zfA@gLr>AFn`Us)7;tbpBUfNzxuX=I3R~p^r;(H8$>CYY!kpBf>i9Zao`OJ6D0PA!^ z+y_VffEwG0La&+b)lOOLA~77!jWx|lZpO!(nt+~pqGlOpOMw#+#{f&Q5C=#b2F$Q& z6LufO!*R-#@6SE+`Jxw(xE`LGa597IN#y4dbnYikaYz8VoXQyf%XsLdDxQGlV_aSK z!i;^_&7zJODAC>ROYHIbb+BA6F_AlmZo)n8W+$E;$827Oh=?tr`A+b^8U?yl>POyt|`W^;XAH`m-Y{gW^h#RYixXIEE0{nSiC1-V(_H`RdbQ%s4P@KKs?KV$T61#)X>s*ujKu;s;|_NoE32EWeDS~k_7{Kl zvw!?2|MB16{MDeAV0l4V7u$)NW{caJLo{^QXE5Vv|5}{gqzb@X)DBx|&S0m-;))mR zBf2SwoC8555k1RP+t!C-$zrj-zPeh~ycG$`YvED(D1^P$sOy5KltFurL=(vNwyoE3 z>UDfl1UpxhoH~d`hdgE!b*}}4YrrT_6l3XuNIUTmJ0(+DFluOopxL(dx?X_WF)Cx3 z1hmOXlSa?n11R8PRJ)w8X6dbpV`r$4YB^c?Mc~?Vb8X+z&x@LQRmYDkURQ8w^)vv*jAh3!b<}j3gq-$b6a(mUR6|D<43`q8F?1Q5NEdpyP{d ztsI-yofMS@4zNhKYH{=!VqlPplSaPYc%09>Vx3;Z>)vkSrVeE9{Qo@~C^_3?V%k48@t7%jc>Q(*@#8 z4(0D%?)Xrl?Dv4$#S4#S5Fs(ki@OM36cK-a_yFAb?+yClzUd(Sp(u(pGK({CU}Wqr z(f+Cyu%JMjoJLP{BrhFWaa3&k5ckX=F z+V{b)^2L`8w$3HsK{>n!_J9wuF(rkcEk~b~dvpLOUjQAtZvi0BJ>d8I96(;?9@wW( z^x-GpqXXrH+@p(Gg2Pw%Yu9-IUC8r$jU3o}k9~>P9zM@QP$GaF;ZHstdp-_d%;DiF z&vWnh$SFrom;oM`mEq?BLhj*_=kZ{XQC{XgWd}Yz>|g)*PhB%t`waoAj%uENwx+7u z{nn~jRjXlHQ2X3G6hHcuUi&NS+U5Gn)$Fb6HzwwQF+r)h)6f6; z)z#1HFMhrI>R*1NR%ropse?TvY=M9!FDt4lajoubMsJr_YrDNsQILZ=sN+QdAi8Vy z@{g`Ov)!oO3ZU)QVg=bMT!;(OVGRp`UH~y61Z=7M^xcx@%W6qf*Tnqp-J75MeEsED zy1i+C{IexmeEqjuwQdx8HR-sQU9*+;M?e0fY}eSXW#XcqDN=zcV%bqRbkbNP4`owfU{Cj zym<<_Ks6au60D&P?^&Er@ObUV_ zHbf?*EP^OTtPhz{;bW9R@n4B}Su2T`jKH82M;77_ovOe=YI-cJ`bf4ZMCXOnch=L->tV~toK4gF4V`S$J9lW#$UYRL}7A~IMWOrt$o2o0c5X0AJePMp!$Q^4}Q4ce|x{( zJXwn;d3Fy^&)M_AfZ$^AB%{}vn(;QRFa#w9g?~2&#-LJg0X2XD4Zk={g=fEL$c&`X z0EnwtLV$WA+-91v@}$R^z5RPqh_sZKM*$d8#;MGc=O}bMS==kTrErpZH?i?45DgI@k$p423*xtv$kPSgTqS!)N}Cs zUKT=CqnWCpaj@csBhl|8KhdK(>9`{)&D2UTVPYekOhD=4P`rvt(;bwBQ|Nu4#0VI; zkXxy621aqOFylMqF6fg_Fo3h~{L0V2Y}UiiGQBJZVFb;|d+!N3Qb;xppGdw7;ory? zJ%07x`~4o+`y9E?L4oa!V3%@&FZXy)IRKB&hZJt)9?0Rn#~$xHAV&Z3u{GPSXN1_ynVO2{^gr5eto<7?G_6p->ai)(1I5I1Y3bC*?yDJ zYPGI+?M>=)fjS2^A;b9c)1T<&e0QsMD-f2ZC8rRmQ>YBMdBI>}rvxxl4E+?bt=ny^ zI*1As@BZwn{t4e~)NZVS<2kq6U2G8USN8F2L?mrfUtZ3C`0DO%YwFrCnUK_*GK7!T zMTIKJiAAOWBOGT6_#HhV(+AR|MaikCI%zddraekvBCx6ETye#unlUV38)pSpMMEZU z8-p+U_+zL7hMCkl7+hU_I-47@q5mglsTx3u*Z>(s6oi^*6?p+#Xd`lORisfDlbU-q zhAN=q4A*lOf$F^qWHdRb>9eLIfGz+PA!C-8Z{Ms|%s^E!&&;fb#&l={)b*Mw2F;lW z^SL2aC4gcG@cn&4qG>{jS=vNEiZLfOMn!Ea;#zn^5h_ccr0k$-Z4|Mnq9RbZc$7hn zsoV@!(>!WZ7`amiKs5z*V_I(}B~=yOX`Emsy#9_C001BWNkln7~MvxT=AIkF8!VkPzDP~R77KDrdSbaL{-&7 z6e0=Bq@^X`Y$ieg2Fh5#K;4M+9rAM1UU^#l2;+~Y0Fl!IrXXTKi|HbLiUl-b=#+9S zC$J!7Q)jB`WVAUQ(!|42gge6F9RgT6h4`vus9?&9$LBqsU~oZ2LBxt9*gam0X^iN< zb8%LHGBR9^W}bdZXcC)iMnHdfR|=pR1yi8P3m_p&LtutU(3xrqdq?U4OFy^8w>}2G z>9t%e$grxTsvdzn0;T6p!iEq%fEH;~g@{26adCGQ2B|9GRFw>qW*M;oyL2&C;xh&& zh=nRGD?>a0=rN9o7`orG#6dWmUwE9w^+ER+7l(`TBjodZ_QMO9C)quI`}fcL?)l>J zN%U|?4jTo9d8W5$*GZ8h(C``_&e0y2%@`98usAJG{S_XdErAI0c?t=i(m)Zo$`K+y zW;SWGT2cSb)$#tk|EBC%#2|^)m7`Hhy}C|E4>a|_l1PaOP84oBJcl7pWB`rL z>pFe9;|54ieo!#Vur>e+g@WcpM9gG}0K7Ftv7U&0T>yx5`Gv1*!j@$OwMo95<=VS)&f z69}UP)}zWh%SLzsUT}jmlBbB>lQk0v2Jk zjcY>gG9MS32i-;zrAB*|HjKlzfs;+ab?n`b$KObZfa#g+w(S$|1dvvmq1iFUbmOe> z&y8x(&Y>wLV`)+X=8-zHh^hqVfTCD4$8h6xjM7VCN5(f}Qa%FIoa2UAf^e1iFd5|$!1rpNUqUakvT|6#gFFa10X{g;c>*#d8h*?}4?6)*dG0+j z^2l>|WPA9;JiH`P^>E?V#kO(aY;)_ICc&Z+1`{cY?$e zN^2ZPyFv*Syc*6YniovJz|b=Iml z0qdL@OQM?8khY*2SHE1fq^ z8@sh9>{q|DCuLc#*B~dm-+>hF>7WXD?HPh29he%BDqwU*JSq0juvI-zQpt#{Fo2=j zP?d?5SSa>nYMPOQSQU5Qs1rDas#sWsLPS*6sa0sa4v~8xb9MDeJ+GiqP9W-ZJRuMi zst&4lmSJAaMAbH$ln*u)X;l?YT_B2}q|%CQTZ^Ewh%~hm3C92t5oZJU3;=IGyZUUs zHl!Y6m<>^&Q^5)w2`S?F)w-(Yu#=Jz$*6(|*O^|TTis04!2RYqYLhRDpRp4anb&CJY%j5LgdDA$1A2N4Xw z1d-wFUAVLcstN+BK^R=&j%2F6B9@_uMbkjAX(Z|=lBRe;j~VE6e@KHSr@vjX3?5m% zutE}4Ne3ZEsNN!*62ASDN0h0mODvDXp9`f`J!)47{~j;K@f$H7?Xrl9BN zXHY?!1?truKfw%;e6PB2;tv(bGIidB$`kdB>U~--6>3JhkyL?*w5~b6uBu72N9%pT=OD6A4^YFIBDhre7}(gb!*U(gK`yGLA&g3yYT1Vjb10Y~s) zMpcVQflI1LD~!hZ*91{VqNP<~0)U>CKn@CEw+GW7#L%-6lzxQDvF_oF>La{u!q5?! z4u2ce)e#5#Jjs_!{9qQqa83mO9_1`YImkI)2b>M$GatryR9TbH{VWGCqq6kaqs-$m z%*x#79`6B<9Nl}scR-0Gi|&zsI;k#dLMZp%=Na-cM~=x8>nUO9_?8aC z{l8+H)%A*3OLy0*+!36@L0$A#X95$Pf}<#|+x^|))te`j{@eeD@)^p~Cy9y&viI5H zNi;Kydc9M1R@6GRy8ii6EZU7gEWoIje8s9vsvzyBQi3IAteM|3Es03g5>y~NDDQMnH)@c4~>l@k{+ z7by%AGi4fe8w#rs4gcM%RagsAxmR_n2E+^)2-cshKV2`Qa1l^(aw6zb7l5*=+3+E~~dc{*<925Kv-o z!wQ^42?S(ZFDnA9CZ} z<G=^ssD4&6Le9fRL!;k?naEUv5}JA@Fiv7)#YrkJvyKl_8t4`(&^u@w zz$zIp&XK924&n6fQMd!~y_su@nzIq+OJaJ}`@R{G5-f^OyE@bhs+Sb*!n{Jw93W1b zSCgrOC__U3^6I;t7wB_S=VV|Kai5Z~epjr^EjF;yE@W(iHxJ zzzld$P-^qh)?)yjDKxPw}9+DkG3o-@_+yZNF8OQUw%ssNoRj@ z&eNWSvr%2pVKZe;=JFx}a}*d@fVAod`Cu3yhJv((mBzBK@wjrwt3+Tj`Ynag)I>M| zyE&q|HwWeCkaQXK%>!ZkJ(SZE4DCHAV8JL_9_gVy5Olxr9daPc21&F>4)XrJ-|u~1 z=J433Bk>-2z~3G@!Gp>lAjjVCy-y;Qy$^kP;Q*q3dEb?@GADSS!*_!QIugttJ~bwK z5ASni-lvAb0YDG`3m7^NVr`GS^!oJiu9mBx*Icnx zfpw}BFf=hhtZ-EE@-5d_Fd!9G3&5yCu@&ry-puKjH2)lU3#skK-E72(UcF-hc3j!(FJ2it* zsLRxtAlp?11>Dy^TiP=fBCWF;6pT}+eT|Yksthp%VHyF*2Kqu&?7fOrb+9U`>f$vG z5QVscIMn8H^@f-UP}N4_f-{;rL|o`5Q&?5CS*9?!Cq-+;grg59B7u!gtv@}Z4d<;F zv8_O@ScwgP3MV4>_o^)bH5HiaIfr++4=_zc0V@hC6rmMUT^WkI6H!$O1gWSfQDFEP z#K)A$XeOpp#Nw?gh&kw#BLNAQI&B1?c&`XRrXH%!XG#E^)2I{HxOagA?64s9b08^9 z6^Z|$@y~s*oru)IFi}-Sai`P7^vS3bh{g>#gZx^xFa!n9dAYo--@vLuL8JkShs_%4 z(CNlS0L$V6V2<5R>STcJV`?hu%Be{Gayo7o3jZwU&?9|N2b>ykqVhI@rXqFMrV9>Y zpr=#^3`fWN5ml)AVYNQfV@1bu%uppb87|)8;^NiQQwA7ZYA~DbV^U`BRyph-rRj^rt>on2`POQ5N8#ST~RDcXKD@a8t zLN}EWaVq03)o{e31gn91hsiR!xVX4DyfV)hj}P~c-~OF``}eMU|8)4>0e)beaeCv% zTP!o;BgY(b+Apw<7!ew%^YMrr?ZtbAv&y6qkETTN&}26HK~C$$<_CcmY6j+R37VI5f9T?-e88Whl*qlFcSdERN*XT28Kf~c%Timp5O7Jv7|eZ`+KBXd%w&Y(Y{w)2Xg8JFUw1N ziIc_*Lohnv=?M8#g`_a3mS9E{@sk;Q}Ry|#pMAfJ`qmwD-tzwX}e(d~dT`hxiBzM$_-3^*PcJaWn+_V;5g z%OHWt^W5(};PVnsPahxd?(A1LYTL`V>+0&-snymI1!g$#F$-vF;3E*6-#vcx@juDe zp1Ka$qnt&mJ4c3({I~mhxy*RJ+p2oi*4A&An6ukib-G&e`j@p@ZMOpF0%4FW1Be+= zQ(e-VPf6FX->9}0(kdL}YsQlBry^{(jqJAKtleREyW4)b{pMfU%PU^LUAEg6qS|ld z8LBEfk)4D_GXTfv<+FAx?bq$lNa{>Sh^SEEWb% z9TZMgow&dP8YZWZ&|eHfL8{JVP*fF@4ZUgMaN+bmERCV)&&y>sCs?Z@uo0y}t;B{Q zB``7f%&f!>x@Oas4T-h!{uUrpGQctzUia)Akj(P|C-chHjs^-id1ihkTyrl@t{Yhm$&?dZq8r2qR$xOL0ry7_6;|L~Q z`;!(cNm3i0g9^lr+PI_@TK<%bA=J#Z4mcHJ(v63O{T(TBU87)9C88)rQv;1pBYL-p zuy+mW9|~J~<-+7N%jxj^?1BB$1uh=DXD3kaaR8fGsyer`oJdmFzrF=iJnIAE= z;nysueB{0C$0YY4=kQ$w(2E7S4tWXW-gi0WL8=ikvH)+1XUHV=6o9Yyk z$SptrX*DNjLnAE(ZVki{Lo1XP1~}YxuhxH9mV4v`c& z?N-$pt?-l2<~yV9H-gsn-O}Mvr}+Xv#r*ayDd4|SyAwzoq+nt{wRerS+t})_P~sqJ zkga_E<*st>?Jutkscn^v5@Uc+Bl+3oPwTfozp^`#7F=flNo$p9`6=6->eqp>a8U$i zKx~?A+wOKX@$wgM*Pkz0)qdTmIB6}{^ZK&hZf>mI9G+y@xKK`%`%ow#I?%)O$Mv8P!+X_k?e`*ReI!P>;i>9G=iXzF%-12{2rRTHtQ3)1A&z(4#y*53yfI0{77zyNP9=j*yca_WPs zRSi%&8j6{b0>S_Wn#H{rsZ-6y(C6sXQ~@}m-VFm(gyx2T-jui^FwL2mi5bWy76ibl z*VVZHJzevo>h*+t#b9ScKm~BJw~Na))J8|c2}_Uf!q7oRDG5Wz2Qa_TfS+;kbYbx9 zFMv=lY4t<90}?QYLPxJ8K557w*@X4yqyQxVeT1O{bPlYWo*Q;yTRu;s)xJVZX8{0d z7IwtJNkb;xAJT7R)C9%P*w+jr3pyS??1zw-ZV#ZlLpeh^ zLl^Q&mL+x_&IcU^kB_bca0l%7C0?UElM|D!R?3tqfjwSz*{fHX9uC`^FRQ9jUAK2f`UeDqgcfc!Ynx+=vnp*}K+YPRN zfkhp2+_xL4uXwX!Gzc~vM*$aD$QASU7HuzG!5VWy1jKb9-h(;(CcsW|)=Oclh^v?RFjZ=0L~}Kn6JP-0#o=cm-sK zLzWnW)Xd(5;N>FrN;{0)9SVv2QwIlWj%)~0=e|ph5#gkyl}(t-1;TCPz^;$OPId}1 z{04}ijRpoTWPhLm>X>^d)Ar$%EGWQgakaj_0=U_>!I}laE=4{}BgI5oY1(GBUU3Zi z6&W??hs)7Q1LlxbCz8~_G5s<|G;m#~&z}Y{oLwXP&VF9RFtfAv{v*?fm}$Tgy87Fu z8T=pI3u_Mp#RB!Z;3DA(Iqk6jU{m)v5Pgz%*C(6cwD~`gHOvJD>yBf;iay0~oGw?y zu!4B$Q`(ojxUxzbr_o?U7%VLDJKWo@j32NM&_De9(rz5AH1s`s+ zAH_TNw}y*nKP>N$0J02+!;mlXqDX`L6deYqAC;1ekwmKFLc`KZPcqCrS!U2%m z+xVf)$hm@DZ)KD2v>VS^84BiEmOVZ`J^~Mi!^6{aafs>bMGA2|acelbv^>Psh)n-F zSSLgislkGVd9X5(<2yS2IG%nsf4@i+{@|cJy{VX*X7EY+iJbqTBb%jouN`_z+7u8w zx_U9UlDQ6_8GU^EGh3wPyI4%-uy`k8$ZNrc8$D0OAXi`>46&zSSHb{Vu4S=im^moqHbNAFl1RVm$Y1nK>L|0wU@ zgML18#48hm?Zz>FCun!1B^e{pmJdGy1<1a5zqvbblH zW7`Kxch>FqK!0ngHG ze*Np!yLYR1?-r|dyQvop@QPPF@yi0x;vks)*Z+gqe+}&R-CciR?sva~G`v~|uOw+& z-q!WcxczM{O>=wG)T?^pUp1c4S6IK}jo|jTBHISCjR9%WU;(s?AwaZ04kTp;&}_E9 z`CsMTzqrQrN`S@H;_AA7$K2e?&2Kl`8`<34$hJM5e57r|_j$G8qeSTVSK)D79e7nU zWU-Zv$PHLtW!YrQ(wz*@Sy`4P%Cej7W_Qck*jo@~N`>$C*!K$ifTv#_x;?TC!XZ<1 zWJlIlqX1W60l2nlnZu0cj{AmXv<4uwMZ(EK8fj{98}Q*#qGQ6)4d7Y_6vaZE6KRGh z*Cqn*7!mGzae+YGVzpjhUoUFjHe2C@Zc^&$S*xV&ZBs9{T(2M^z0XgAeNIH$Z2>fk zh|;2+UO4cO=f|r8<3O@A=X_LU001BWNkldRgc~Ot@*mxA>7a^xaJU4Ns znm8+k(>Zkv8+pM+U%Rj=;ewg#(2$S@R=<`M5FGhbeef3Xxl1EwUK?P=* z=&`;2V)_`n;1fCZygLu-Anu&O-IS8BAemef*~c>F?_u~30plkc8)K1umB6R zK;amWreUrJcv&x|ryt10L}B2s}JJyXWUL+_)IU-Jcr*JVE%Q#cC1? z&B>ULdAPr0gncwfr>1psUflcQFgUtd1tunYZt_oY7UJXAPfSs#aiK4a`hg#jG3!*s zCvtF=>~BmH7lj760_vK#x05#%h_oCCg~<<255vK=u0Q+&Kv9JKA=e0m+~i7!x8h>U zYbjP3qi0FZjW4I+oGL5xq3-2~1?c_!9He+z z!ts*&V%AHSzmEpG1N6i*k;rhxU0Hq$Z;V#EFi> zcfs4vm*^gW{i`g0m1WQ7u={#jf!BZb)9PvoUMfVt(d|}ki||X^IBolE#)m&R917h( zK>i*-$Y*%%_kUj%hAuCC18aqx+cx;gySW9~maG*kSSYM2!Nq>+AW~TI^{?us;>+LI z?TrlvqL@Rhgi;1Eb4_GOobn==MIEoZt#x)|*Ke1bueO$}%O(Hq7rU>w^39g*-|nPU zkUKw4g2dlBX)UvfMcbN~Vob*BO1>qBg{ZQnZBZji4l$y3-TXc>%Ia*hJm6 z14LA;6P0!gz&Y!zirV{KW1Ggwy{dz=VUN%A+RW!rbykul633oQF?K~0BS-*HRn@$9 z8k;a(*|>jF<`OPEkkc)NEEvdty62s`HW@-7f#yLW^P6ua+q9- zanVto!ZXcM4 z2NF%TW>MK-5Gty{-^x%y%k{cqazqr=D5NyDc!(m3A_g~1Mbak{3kv^HG&G4vJR}_G z*ovYroHBZktSCN-ejy{5h;iBaSV$w$ypUo<;>btqfD9LhhbQ1EH!yg5xW9it@>@6( zBZu+9MYRCWla(9{ab^&G;f`g{bc~{g(<3#iYNGAT{XJ9$)ldrfO!@$Ux>y&A-ydfj z@`>s^JsA*kPRA}^lN&+^-Go#FqW3n*Ttnt1Xg&v5ur1VtCx2uYGsYZ5AW#Jei3|C4 zgeWfJB+ejJ7*I$UVFFdDqq~2wg9I*Wk}`VAp7Ma64~K_`r|fVb6vS0QR8fdd?1lN1 zyv|07WgUAR_9+~_GuqHS7=#D>qJnxXVaBKyKgtA&$wP$+eT*qADgBBXE(b2s}6S+;dXi^{tsiM0S4J6boXN z_AWL%4>?+h0ZF|gc_ia7;|b{Z&}>XaWPLO9Bqe7wf8Gb#hJtvQvtn|T8jy=d8X=l9 z7}o?l7b<9OK!(VG4ME59o+xt)L9=>6pS=4XuFrnrH%I^W8oPbJY2 zp68yTi(UUgd%*8OM1k1#KB^-|>4Tn-`+aYn5hAd2p!42$`#dL5j(rF3yTDGrPoKFT zAzmPc8X`xYd%ySalbmU zU)H*{D#|t9{%T$SVntkOYwtGJe`Bq+ysqnIZQGrQ=6Qs)(LQk!!ycp@qkT+2#L6-+ z(Ur&vSe7W!ys<3!cuf!9e<6@2v|4sKo*bhiy^KmzQtnyavsQL%_CC z&79MC0HMQ$`ReMkpZ)mSLEFaKpjD1ucN$hhMN~HrHkYJ;I_KQ)#AFoqSJE{1)~Xe` zzw4KIb**c6>O#i5!YHb+uoX0CqwIP!KbP85imB)}Mi?S>zk!!aQ*makO7g<%!;k5- z1+H(PW3K0$sJUjtL`reD(*vd> z=0-=xsX;nVP?1^1b`sFS>AoKtpQh12OG`HfQgd`rm9Me05k`yuQwGh zR}0FF7uD2Zs9C_!L4oN;nm-v@tOkFQDVhwuM#G|~gN?0BMTk6z>PI-7lEVaP@3f|; z%U};aIBfPtUU3xh8UbuzfQQ4=!vmfkpR&E|?ejr!+TfR56ciw?O!ejnSQ((B-VjWyPderBh;(@i2yT)ib|-e zC=sdX$dgb9mQ~H5wGWNOe6+)4`{v3P3uY&+9X5x(Y+OdWM46NcV^_a??-=jNP?v%7 zNXHl~U6e5G^iY`4n?BNBhrR`-0t{vod;ih<_>Zv7xK)=8Q=HGj%h{x@t}!@?B79kl zQNEzfctQ6(iXePZ3Nn#IM~Ow3V0gKorJvoW|Hb!Db@_?RqU)l*qMU{!mgQ@p>+bHb z2VT!gyzbC-xI@sx}XLqUx(1d@<{G6{IwhD zNjd;{^Ur?CpZwF?f891;Y(iC+Yd%v@ilKrFX|~b`w&1IJ@uNS;@D1+%z3j1Ql8R#? zH5NBF^7D7{i=XosU&waLGLp>p;;D8c+ncT23NvuU%;0OrO)QPCu4}$t;3f?GHia3U zuejWPvAO!$YPG0;v)Q6v$<0=hMwVOfYJr-A)>+1H)%NNRX&ThbtLqvy)>kV4w|}v1 zH;pu{w9Tyu81-s>_3rxm9p8NM*Ig$cmsuP`-F`Bj%2U;T(g1ZpSq``7^;j_v+;v?y zi-T$(hb?B9?T7n*ct-b(8A@bU(Y}H_q#_v~D?TS7YpL=kBCRxVbzN*ZhE*liM9iEE zbwCH8U948jHGl>U587EU;9L;AhJ>XcJFVM^B1Fc5fl-l*fo7DS$015wHZ3n!1>mF= zcT{^DRkeyF@EsI%0&Zf>(YcpulR;5%oc-m-?>o6>FAO#g>+v+E+D&!+;8gAuK$rY z$}R^2?WiVS)N2Me(mFo5V8;b}>D3J~&c2jmJ?J?V2anY#$5qX9#NqQl1&`!2Lk1z3rM{BIiXqaDpYTy$B)d4wCeMC~_5IKI z>h&-|85PcVP&~)`TrfLG-=z~DnIQ9U>E6p!0Dq)%iaEv7&z1!MiD9jy>mQ|07xX9Z zh8&OxHfG2Pc@SF6P=-I}10wZ!Iju0qeiF;~LaiOs*Z3(#9hhOChtAJEFr&x;$G0j8 z*rQ7sh&hnMcR+`H5s2xW0PlUi2PmKA-M8;1``vYacF1o+B@FUzYGCy6%&I_DlNYpZ>eQ zYW3!Zk_Ul`s4@}2ODut!Q4wsSBDex8tkqqk^xrQ2_!E8H+q=6mGxYY-Hc%_5pxQRd z|NJduNxD=9SqoUj9drk6p;q;8ziCA0bF4mJRdeR1CFbpyR#k{m|Mc?iX1m)oiZ)5U z+>x{BgaEP7irczE3)!@B-wM<}UoZdk%EFD|60^D7@`+C=G)|Wr6>bY$z^L2?FM4mk0X%Bep)3ERa?C~BQ4tRW(TACCg;3)CWJoq{f zoV1dvkhCh!sde^unW{QyrisO7B`Bo_f{Ecc*4h#*(!KcAF8`)PwP!fnS#+bSl z3pfze(ar4f(da2CJIR|;4GxH1jo0DU-3X1 zgx`qAp190J!FnW3ZS+FG)R^&P)sZimo(+>6F`mJkPeT+%(1%2uxZdrJ8AJGQ(LE3}u3-K=r;S2S*P7%wnyz zccb$-KVuS5Ff&&~84>l}G|PI<%#CxgwyY`UCi15Q>qLe6OVW_?)1s(NHWJh4YSY9&)QQjd&lHYW}wjX)dVKFwpv zlZxgDb7Pp0c>z&K3-}oCLSYLY_Oz+|qe}H0M&sSqs3weYhiXufI+t7v`}9Fd6RC*^ zl}9Gn#KeGdbb;rU)N8C(M3B4t@yrw}gyC*Ptx8|xN=+D|_|N+?fSIG>c%yeU5PwFhP$_T?U!&43cK4trp~$83f~Joc<3x*Y&4%gFSWWqifH zD}nBHc)t?m40rp!t1q2UiL#rV?605Fi_k(%$iJ%F+-djc~Z;%vAO z<$l&-|H&_Zd3gO#|J`4;*xbaf6d830pvDSZ*NZF03b>KBMQl0SCf0CsBUjh;=RZE& z{l{jrUB8pXHKYX^Fk`#f{zb#9ny=R^HTVj$<+c&DX|KLoy}QEIb-md%n_u5t{d|qO zX5LDCB+=Y7W9y7_^vkffZ<_52SF3fsz1bv^v%S8)s{j1D*)(VpHOhc2M8GV}92@Kw z09aa)FBu|S6hcXO=uGh48vpx1D(3M?i zAw3*AK(T){o4o=6WT$LH@3v7eq)7xZ12wpqG`cYstLwl$PvoyGa;j={i3e`BZN26q z(St>}d(!)9OuVfo@7xosa@^rJ6hk?ZSPpO^t>8a#_C7z3^rzH+2SR({W6zKfXu>ab)O`k%Et-#IAx=W=h~Fuzsxi>m0g) zL%&{f4+ac5T^w+nJQ2(R)( zpjCvr1&1<7BIyqAX8x7Ta~u!_D0ou23DXR#3cW9mZ|x_y-nvU>g5O9#Y>ca=Qf3Vk zN-+HsI58Kc4W;u5X@x_CvP@+a(PbiHXn7Gd50Ef&=nVZuvXS0Uqw9c9_FyT6KpB%H&YLvA|w z@WETpbwH_gck|6R)xZ5;{>%SaquGK0ZkV%rCZl$1ZM9aL4XrnHzr+4_K+Wl@)ok~7 z-`&yO-Tn99Z}wZdy+Z}x4j5m{1X3H~jrT56VXpYintu1&-S+RdV5r~R*2zrJ>>DET z9vWYWYWm4Xfp<()ZT|MQX5N3l=Y1WY%D7tfE!K^j1@^8iv#l9i-QDtbTi12kj9fsO z?RKlw`u3LVeZ8-j3%3*MfU+zl{MO02aFouC0}{Y06A?*?5*^-4xhiFe)eW>0<>Z4? zqLjbHNJ9HXayUkq~AJAu90ar7c0W&aw*{IAH=F=TzR%1l!4yt0V zc^Z)-FH17G29YtS>m8Bmt)_a!W0=`AqqU#&3KorEKmdhBmCRCz3LFBd%6Wzitr;Tl zn6yjtI+SDze%ab80Sz>OttoC!*T@Rg#D~S>h6ct^dUB|!B9JP4%@KwfqzWR#99=+a zp1@ZeR|dC&z(HMO2!&zn_Iu#AP_CmaYE^jPr^n1(o3!2>E&~VCDCYncjQ}`R!w?av zq5we|ugd6s`y%k;BA1~|fxf9zCca#Ib zczlNEpC5tO0X8q(lj}41h7HL3 zhk>YYo~E&6%z34`D4h0duxsi~d*V$iDCl4m!0h}tNzv!55ZnkPR!~G$HKR8t!zcaI z@z~<=(HtMoc*0OOGKHVx&8A##lgon!_4tc>ys_}+l3h*yvP^=+pWg%xBqfwg)7j*f zY9Y+%U1&Ib;ym1V+~?o6-wGRW12B3clpg2N(4z>RYN`EsF&IphLQ{JwMHqI$?}ZZc zBAWQdq?)5_U&QKH*i@(yqN(6L98KJ(c}Awcjhxd!e==(^96M83;fuQ7)J1v6bVi zkx8DN+BV_tyX>{q|MV9h{|K)4L!Zus6hOnkzWHr~yY=07iomGZBT0_j-kx#y-Q8}x ze{6Zbzx}&AR>U>qcI|i9TgEM6z(La( z1&0G^fPK>oK)Go)n>AP1|8C3MdQvp#jXUd}(<0Oj-+T1G-_=C!A~Xa2Vtv0|->!i* zy81jn&#q>}p&RZ$ToFM#813P;uX{+8-3le7lnxT33@_2n^H7(v>-1`c z4l6*)PJ0=>glDWvphF3b!=ZEAxo)Q2`@WVqPYmftXaF&Fiere2y=474L(;+ zB8-fj2DO9>LR2qDoZ#e%45MIj#6EM_>P&sii<~%k)f$0cOetfYsB6V%HJd9Eq?+)a zoYcs}Etn3|7!hpz0k9ep#Rr<-Mz1ayA)uqY)}xAl%kn{W4IRN;Hq zUdR0Xw!S4&1ge33*atO46%p0@8k^1LyWiCJ_r!oJ-8Af`%G-Vb*31o4MM@DEYa(p9 zzTbnO?$-3b-qtk(xc%QZ`@dKG{XN&L)}&NbH%-szc_=$J*JMydw5}M0hM5@^syo`= z@9X<|JiEj#Uj@`7VWIneyQjNbR8yrzt{ZMh5$*B(M6Z^w0F|0c)B5u5{qL^kY=|pY z=)%Aq)@XCI9t={HlEG-=ksg^T#XuQxBykv8cHPz1uhUJ?72;l?C^*TpbN`F zO1cyk^`6s{3q#XT1zNAUZer0q=O-!N^}L~_Xg&w(M$4vB6_If;_@#L{vWqctA#PJC zLoRUz<%)bL21TD&GN?UQqNb z3ZZ%GR|6XB*Yrm`UVu~6V>(3HGzLXqyX|uoc)SltwJC8K=1DL(p>)awR~WISBTm$0 zJ3jwSLDSD?toWPccluMUJmBt6jG{oxJp{2mu?Ga4-^?QV1QS&3bA5F_KRunAKOP^C zkH-(d>({gAb9OO!y1$Qy8*?5_3OOfz88Mr|W(l#~4d&uZQWVoeGs2`l9X;m-#24{k z;pZavy1I^=XaCz3`Wmbs_zoqf4&o{zexhl2_Uy*F8a5|=zQs^hMOD8!>Xl`rz;*I8 zMUQP_RJgsRjpCpJ0vFA5M9e%!LD`SR|| zZ4~|NVvvh{vPU}&UZF`gah~Ak&kCHoF-8e!AZ4U;^xWaIy6LRK9`SRTV(9RurGy?i zd+0LLU_8Xn)+GXXjxyP}4Upk`>5~pK8odkh3@0S%$`UBcuIsuEKv$M28;t>m9&S3M zgvN6@yh9;Z0l+8(I{*M607*naR9J^eu)p;UZtvDiR0Gvo@phm4s{_Cm_|4tsx4SL& zHT6tDQp5F+UZt={eP8o_zjIFkfo^I2-I^5mzNWQO3j7`McFnsj-`BWP#E3$UDj)Uk zEvjTKx%HTsfPL*mBw5vw1`Cbf;5I$g+JIf@iucU7Yqi1vlqvB zHMDg0D_UzQQDP-mE1=U_OF*uq!@X`GNvs?+meP5zln*j3sg!-CL%Y}ZdZ8{CdpKaN z4*<&5FQW!%wellyC9zroo&1Y$0F;Lghl4MQKcHC_SdyZ@@u9qB~hX?iNTWf_^3IZunWME z%ZB_qKuS?sIIf9NlOe#QpHBofv~QYqI1@9zOKkFWAx-@-NL@96jGCRevow0;m^2E^ zpXsZ)>BubL1Tv$LMH3+};z9S=ECJ8wY_Yps>JPO7iY*B4z7MP|%ovO(R3&90Ke^yw z0y+aj&kcHEe@K`XA8=5`dB!%`0u_-<3#Z_z`<*3b%K(0q<%wxpRkqWiwR$WH*VwbUObm+%D1q zVUlzk0~AG{CFGQN4kno*saMbi`Z@%oga(;}QRm_XMUeBtL$BJEW8gOlb*E@#nM3e$ z;@>XP&*cjrHBw5TbE1vJ;Vu;GC*G-y<^2BiGM)6uXD%Y?5SQ3>NM#&1H|2u{w1d%Q zImOVU_r(J`nbG^)RD_)(+OHXVH1ROC{lwx&Bp zgt~6>%3uXF18X8$<4)0U74a6Jinlf0x}~$p7VLf`uL-K6eck6GlP}J*1MBtucJtjW z)@$tdn6U10=g3Pnj|{XdJ@l2p$|GRiw}VPJ4q3{T2iZ~kBjG@{TxoRrpdX-R=sT4C zCd>7)mWdRklv#noQPh!^2J{1T=Z*1J?m3ev0r?ja(1-Ws;ozn64-dYm(!B?y`iqDoB6AGCx0XC{C z*Vbry%>a!%4w1O&p#aea{`xQ~BDYe~L}{8}7*rJ@G}3rDSnPJS!^I|{xj71YIBtok zierJ=smo|K~Yi2uM1q}Tf=KS~+*2a+e zmlN3Wrupp#MLh;ZFGJ5z78y*+`txXn*y!?t8WX5LuSiOS6PziCC!w~xX=c3JKmp%O z78#1%)~zqtXF{P^=S(SUO7R#o9zQ+$&pe*Z2?Di|Dz$%ycJ}a@|d!_UIDb0q{t+%U)KNDJ+K0blUPJ`$-Rb2l|ch zHbBBb2CyDXLAr@k(*3oJ(ccpC$0PRJEv>(6wnR)^Wz#d)OvGxfTnj%4yL)c7;QJc9 z?Q4rfKo!jyx6DNJcZ!&KOO7gTP$>|wL;bsYf4}w2Utd6W8~_t@!*#>=HQlM|c1_>$ z`Zu(#*K`lAYvLNWq}F~rM{5N|Tr+QbcB28HzPtTyv#Ee;UDdP$gX@L}v?k`pVdzYr zcSm%$=551uqRCrV?!W@Wz2_~d?{4`Xyx;c}xa$)@MO4!avwRSBe(bGQrPID24*hM> z2dzsfCA2;`0IfSuOFujuWYmC^Si$3L?T3iVZP(pFt|YM1y2DE1pq<}`mMC!(2dz^W zb-FBNhZ~6ppu^3oA7xsWp=u-bO3Kv=&~X1fbe-0n)@8C;>`(#+bn#rztJPVz@+{Bg zEbVm8GLsDlwCV;*pMCAdfFT!XN*7i#(=bggEgS`TLzZUB(7>sBDCr+}ADXT@=E4F= zeR~`Q%+LDiB#_uny!&CnzaW{Jz?p0b%y&jk%sRcxaXc(?$>cn zNHiW&&}0fzxG-#2MO7Qu;Xbg7NTltKLN>uK*u4uG+U<5w%KP;)M|+mgIYU&DqJ;Pz zb~EspogJeb8tH)erJYZ{NG4Jm$}CvSXJkAn1$_h-&*m9t1{FEVA%Kl(E^H-khCwEVn?qyOiZTIjyCDqDVz<_@~z zKt*>0?Cvo%QXV*yQFn>gT!!yG!JMC3s(GDAf03S4?helM0VT>VVCeYCU8XC^sBQ^p zS-rmhPk(>+x3vDv-Trrkx(4t28`f;G-|qL=BdycKRlM|OKR@gJw3}&Y2cXfplc#N=BmX3b*Kk)Q$NXP*+uv)FUgMQFm z-y5i%lZKQMD~$v4ra=h_4UO(bI*o_F#S*1nl{g%<`UJW^kdnq?&WRV%a zb3=j(=Gf$5xDm(4)BG97qeIW^akJiX!Z;Kc@+!an0nii(fkJsLQf9PNXVDkNSyS?XIq;Oj=TUn0?nEO$mo$ zC{R))@IA$pmSO#w6d;pNzs#tJ8=@?;$oT$6Re_2O4sud5*xcgwmZAf}n6>5408L7j zV0_^^XJWFcYG+#5K|#v&?WbWT9t{10$nd02qZqt%50?!%$hx^0*tRggP-_F|mG~dO z10WZHEtRL!#h~uf#9w2e$|8hZYhdA{l}{(X>YqM`o;#na?c*&<{}UJ6A_W#gECd!p zoRZiVpYP&QwS{nREId?kKa#)+r=Jpc`k#E%ix2%?VBtXX$^Qg^e1p^IWKaILL2yj{;`8fs!b$iGb2^`hwE#h?!K8@VcVquS+-UP3ro&x{{Y(p zZHtE*4=s2PGU6Jbif)xq*VS4;-B=6TvIU534OT>Ix!i9bfOh%KhW{&?Z3DEh27+M$ zx)#C(^&*W@uvQ3REH~z#EfI-dk@|+rj9`RdFgN_r^1f;Qao=qJ(6)`WY%K#!ispwie9w6ofA+CkRocI514QMIEQlRCQ4@Bbn*Wd7=eXc+JVn(7|_+*r-1h9Cs zSgcBc1s03N8|VIw(+Q`a^y1Cpbi(P>Ego#X-w3F%_!Pm9w6q5`y>`4=uaK)9?GDa+I11S}v+xG;FgvV=JK2WGLrVu8g% zE_^zRmcU7O3m~S6-@L(_6>b({27%e>bizq%KVDD3>C|-{bf-@MPN(DXXph~aojpC- zll|G)xrJqRR{8A%xOI^tg8^zSgikFU#6?i}VF;cb=dLal(b5VVrap$Tur?TDhU|m6 zaG?yag2a5OXij1-uIEAk*K^QZ(EOT62m=>P!UAd2p@lUtEldj+MQ&Rd>%X7+5+Qe5 z6cv^VYKi$0m}53WF`o&6w)LSB0zN)M2r;*8VibFio()_0ln=vgNSPraNTFDU6yLc! zFl&u9b`}yq{6!9bFkr#frjt8cSb-TZ-`s4LO3huU?0hb0E@pk!fq=Cx#6^S~H?zhC z^~?avW)2~QZChilu`ZU~1>69FmR~Qg?Ht^X0C!jWh;N@F0O9hxU9O20BFz*K$?3$z z8;;@6A(gpbdW1+4fCLE_urP<6Sy%}7haChmLCR#*;M%K`*gW7!I1fgm>C zfIfJf{OD0cVu=F9T+C*$b_VeC&yQzgo}U=)kB?73;tA&`dwzB`6cwVH$;F)r8%DHW zJ^->A=y6v@E}%phcV*|vLa?M_>GQf;3!6OiAkY#ZU=D7<7M6kb#Y8=8 zd2q#T8tUZoP3Ew3&|LVm^0~O4r|;>*;@OHp(oo^Y8KDqlVJ-h`t+CcvfjPt+VlFTj z^Z77D6A&Ra#V7u7e0l`{@k;!=@306k_=Lq`u~;llK8En+uK;9EfdV`&A}!|g-cBA^ z=UIpTth*$3P~;Fj{NxllZ4b#80w*DG5)!9Vk|^g8&q;_=*SXX}gs8yq?h-h4-RT4f zaf%-fWV@{Nu%o~0*b^b!2d8eoK66`6GVS5gR69kS7Wj07PHs-r%%lfTcXp~ zcQ^B2)7+935KNY>ZEPT{TEN0Ku#HavyQ%0`RDDBqvj#2Eqng%QE6{Q?7ynjKZChH- zA=b?wAle6u11y7ReS5RqkeypGBR_fgoS--f+PXCdOB)g!EPs7XG;g`JO$)Bsau}69 z){7MA`WkJ+e`xK)o`3km!~cD6hy{V029|+?ZBP8rpl#8%qHWuM*gpL3AKLBS+8VI1 z2cV&Ez7aQ6-`|6qSy^0Nor)P>J$0{Vr`L;DpXyz^`|;E~SUVSj)W84L70mgccdr*u z5DPDTuHHy27C6b(0*f~%eGu|Zbt6xw4!~kjo-jN8q;Wbe8GyieiU*c zSBNy_`2@9M$$OYa=A>RloXJWDF zv<4P90S-?8cF}uK5(B)H=ehI6?Tq(bti(jrsa*8 zFRc{;6HKXomp6VFW-ScI)x`pHimO-5cM{95mjtpd?6-#nE?~?G!xpCXDO^)iEyvh8 z_5pPhFJpj2byID=p>MvX@_Od-^ZbXpuutI*%326vt-#!pn5C(aDSWc9)(XHF3x*Yd zplgMq0*RO=7=O(=7;O!fO3bg74Z0)&wgabFc1xaJLVbOEbMrNUErhj#9BQ|@46+%E|`vtlmhAxtewQ39?{kfjwp3UP0gT;_@EV^o&F5k{_W_VU z2m05Biy(yC4LIy*+XUub3!1Z!r3}EGvMmpKfE13(+R-+0Zif-A(@&bin3mzMX4qen zCkB?6+9`XF-><$Fx*PgHgT!fpouwWtxK@K;DjfaTGE^NP< zdWjdFV@YfE^=5f}Jr_iCBBGgqFxIjmLAF@J`VT;BLY$Mu%=UqfwzZfODIo+|0AdCU zpa|RSBDv+N5kG9Bpi2=Z+L)3yAP;K4;KRBR=@lkuQ#bo`a3G zX6}aoO=ZZtt%Z$4fz#*Ez7l`=okOT6tsxx;=NP;TRJ2T?a6&>y9y;h2PCX)C00|-= z2tdl=(e{^GA~pQXK4T#OAr?aPM;T#sWS37TkwV~;v(G3?&r^5kPF?mAKUbbKx~}s$ zdw`2YV9Wb=J!PX~h@nNQYFV5xdwsf^y~cU|=?{N6?f+3&zTQ~%=Zd}-q~=R%?UDtt zoi{KB0$2-dZfHY7p{lO&^_spROBQW|+J$VB&n`CHEXA*HRI?O{1~G@R|G1}LFV%PI=H_~Ny%fu(5Hk`?BuHJ;H`lgh z+ioobI53Qbv9`q@{@FUV%*81Q1Aee=Yi+~L12+%Wwm=)=!I>1%dddI1U0Cz_^{dyj zr$t`JSiqj_r(*HyYKE&{oL>F(vEBcFmb;T!2%I1nkODZJ@Y4dP(*kd9-iXx=1oYu> z!s)bFoDM(sd!&VQa`asssO zPGKbajCWwM5DUBk zvB0VKL|*{%jd-&VZ{*A+izh=K=x}n0@h2R+^JDk;$TMqaR|Lzj>K2@==WUb~X9kG3b7-NXuE=;nrSZMY3aSrMgu&MC`z?uXy$VI^<5< zo{<&?tz`=$$05xeAazTdz&u&kEi7nGHs!+Ir<=g;#8(TzS~1{M{bhcEK0-i+Hp0j> zU)e@V$nSmt<928Rz{w#XT(}|Rrzd_oKLS|1e)S5=g(RSu2NDPcFu$J9=Cdr)+3gO~ zqimDEw02g~yhyUj)9n}y!I2xOp1`xoN-tnjYR&S11WmVMBAi!2p1_`u*XkT=h=5ld zW)cF{^K9-WLs(df)UuuToT>Z*7K$E_g!F4LR`&WEyNR!$F_a!KAz3& zyqLjSpXw}%Byi2Z8rarVF(Ix23uYg~9#LufAZV1Lx7h+76(__EFT z9*n8$e%JNK5Y*Dng5$w8Zk2s-cy^%O zPv{|GK)GU0ogJGoAnYPk;R5|8+i}tM!_0Z#PQeH?+Z;(ePez-jCu1 zIlSlnx^J`hEwy2zRx?N`r8Ya&YgoCuTW|jMj+wdUCNrH$T$vM972j{G^_{wNttepS z9d?-DrxI>=`I}IyVG_00oq4N zIzKuW?FcO)UA|!1r+G&ey!V(ZohP(DXt^pO@t_X?Zf;guucU-_O@%;NO6~F_gD^fA zL_=aF0WG`Oaw|(fYG|#y8!6LAL_#{paqSH_eEhs?E-cHk>jn>q%>JXb2IOiLH2H^M zA}LEZq;<#;@-}#`buqrx6Yx}i_3HF-s$+wO>PxDKZi|YHi}t`&BVI2rEeKSx*O~ED z3m6U6Yy}lj8ys8ml72gmTGFEG8Lv#k2ABLmL*s+0a!qp8dIPF_aCwuCvLIwOdB;x? znP8K8evwPG;LMcN%RdW%a#6FHZldECy2mD($BLk#b?QtL!j<@9R6}ePN{*eghAIxK z^SY^3Osya%TjpZ2e=imOh4bJEeefVHJ-9zi^~CwX5{H17Wj4-8z+7l|!NQmQy=jRy~@Urq@Z`L@< zq7DjIg0sdO3chL3D@;IjyH?c(RB&UMYXmDMO8i5-(}yD8q~jfD;-yej)INKUfL&cT zPU@~uK`B%f6p3F(_kG}eJK?xbq zbLLFvxM=5e(4i~KGO+TBC$WN0ls`n+jZS(ykJ8<9?XrH7?d0H*OA=OOW*8%- z2DAsqoj-j*-ndVF(4B+PgU4ir?(l@4Pctz;pJ#o<#u!#mMYKTyGYlv($&1N%H97cb zUW|D+Jm{gLs>rOmc&dGbgC!Zow6eStFKwTpkS0|CsFYH-Yf@C#9M)gc17@D?TQV?) z!`^dXQJ4C`!EaL6@gOfFy(}j#WRq~V6iuXuP&JAmjM3PmCi)cjMziPvp7oELGt^^% z>ISO1fKo3u_wdUguYbS|Py{T`7gx(9mViTcVzyjeve$NhTi`XYFb3lFh)B07*naRE4m;WC`Rv4cK7{htA>bN~DZ*S$a3(4lr8dzjwPo)~5dBzq$L%jk+V+ zY@H2blMUa2En@>zVC>0t4Rc5euT%x4>fIJ~UBMZ7443>ceAc1z#Jt~c8TI{t8lGka zTwugz0A{mU4?t#N_M8ExM2SZ{CWVTtgTeo#dqDT_ zUp0W68$BuWoLB`JmrRlv2tEeZWCu zB_*H_+RLl~?P%dchY}JiEj79>?2$UaLvTPMAZhO@?qRcwnlAx~!=ZEFI*hTd>oTVp zDZNv5$V8N3ho)C691f*p+)LR>$Oo-Et>a$NeI3GJIb$YXQSpe!Y-1CbhQySVN8WPY zEThP&IC^PL9EJ{}h)sbW9QWQ7h7*bs1S&{TjvZ6f=u8ii)M8`c+>M>VRsw)c8sx)+ z;5QQuK260%j^I+_*)#xEx3?fNyLu`eYq+#{P7vUx8M=>MG_oZSF=tLty=e+_46}{f z(&%cJ^vdUpyfdox9!|_)5LMADa%z9UV+3ft-RuOgJX8wqaOQSkHxUkW4$kNo9O2ni~^CJ-z z7yoezH;==x^(3HDG)NoiQ<=gph#Lm8@*zcz zs3%bE9~&}ty$AM+*Icbh5mWBO%;_LR#ywxMgwH(nd&eH;x&{L(q+Wa57}KjbqFprQ zrk@2|aou8HRp%*&JoD8a zaO9kakWaGWlm(W35rDqH4Chcb=b@#K(9VBHe-TdC0U^mWJ}>}-R3Z|Pmct;uEJIHm zuFQdM8la-%ZzMVphos8^RxT&4L(2S(6Ot4?Yl#79?h*4q08{qoj?z4v|MvTTRR2T$ z?Z3IZ#b!@bS9|LHOvg8vsR2OzH^4UeM_LoWyx*b8@=&t)3qL{vLT?&YMC)53;(cDh zY&<5ORRJr1(N~{rJ|0IhA0FdzqPxM*bh>Hkl094J`TqwWMfrg5AKt$QIw?!wmnG0a z>xY8`%DZ403f z{vD#O;?Skej8RskbtlIq9GN^4?$^Rt*BXFatu$7^!Nnq$tEWQssWtq9*x(^~X$f8hs8Apf}Ax51NQAzmMh$v8Bwxl1pOK1Cdc_fa$1*&P3GGlOO)+EmLaHhfY&5%?&8`T?$M)05 zWBUP5kHB+~N#V25xxaAgKHbf}6Vf0T@I<*(QTXH_mIY*^w;IML1l$VE26jQkhWiswL z0mO+BBq!IO8J8#1X}dt=H<~9m>VJwgb-2lY3V_a5WaoM3zt_6FU<*Ad>2Q3S)-eRJ zPkZZ;ZO~tYk0^tpr0f5+ivcaq!1MV$I$YN^vPAf!1(qmVoUee{0F^*$zf8|C>pwy# z9I|v#-3g>lz;t>drNg^p9l2ZqNU{6!l-^?6|F|ss3sQf0_sIH}U*FyR z*`M8SsHPg*eO4lgNg4i@-U8cH_17@hd(>zu=b^~}h>6$ZK;lrWubkm>6NFg_%{-sY zuK$z)Q@*tM`pnMCOP{kBIQ2r3bW_5|X_r2LJHqR(d+30JCyC#`hrE%i5^y=&CD5gB zE>|TEU8moda^=zr1NYqZNFJTWN&?cWHC(u1DSe4UdVpMZPR4w2Kj{*e@D39U34hVtN^`=6(RouIre8y>myJ0e4f7{TO?(|)C?I@T2y+0k$G{( zNi$twm;)tAhS}?$$GD=nED{*z`Iq=#(}!dG5thTIq!@~)F#$#L<8C4^8&8CLw|5v+1#PHuRUcG}*5M7C zO}*Qp+4G(Os5`|)fyRW583)F%<`{_W_A*W3?0%_opRJf{HqOzyfQsd$aJ}o@R&mAE zhEz2bijquLloQ{B_?_5B0Bjw44(hCW4-`;Isf}w=#9-pd8eMq!DHRPTO5$F1jWo@d zf(87bk{G7cim2%mNEz7i)b6mTDkv2wSI3I;~t^l=i9BN#157(A70On|C$ zDbEtGfk)tH0J~2uS^!Hd0lZe%Z>|^X#S#FPO8^Vth!#n+b$k5S?mhwSha*}XdrU0> zoMj7K$=Ovxe`=p~F@$|x=h_NOf8vf>E_+!vM@kwB=W?=KQRWEP0ZQ4u931b($QYpK!0pG%fsZV?k@@h+#OuCcPd{`I zC?)ivlZQ^0fGk}mW#`2}x|A!dRvN(JeV}_K$^&Ex7r%0VE)U7wmR{Q(YC~$NC1j7F%dYGCjp&1REPb|D zD}fHrPu=;dES`A=`m*gd1K^_a7&I2 zxFpVfHm%ExXzIN$`#M!dtU6v=y8Oat^7~A~4FvZw>x^mEIqwPT^Mq5}m6yfi0zFkx z1&^~5rcxz90L}pL{QMlmD9Tl(eLha1KF3A9z*oimX^NMNFUHMhRfx%C5Q_2&>U+O9 z-(ZZTR7I|kHd(kt4xKr{*q1U7iBLGr2KT?rCwqQ9UwYXFf5KCT^YEVKl!U$IMR4)P>|;TmWfSGV$KSX4fP zj{zn&frke7DyPDy#BB>mY92lNaOaor3=RK}pF zD%vPi>p(6fwWA$qAsL!YhVAlZZQ7w|q~LHtz6 zCQbj+pU6PxjB#9*LCOsUAjt& z*1_qe3>0^GNq6Y_3X8LP2@3nN{G|idgIxMx=8}|a+$ObjRhv~=uKelUl$|~}?ppS{ z*3N%(KI^AfznDKg2E@P^J6jCq3KQ^!(+&>0{s;9(j64R6r$$DlagM;(&zu!P9^MEk zOjFba(WUD9kg#)!e*F-q6u6id-hdf|hWik=*vv{sHp-!Us1 z#A$PH{J?;-7a{NFz7d9LuwKFWx%IMu zF_(NeOq8r*@r!4B4ziY=8?@|@dO-zIu6+Iisd4I-!W^;B3t#4PVRzsxlb&kPv(%$j z(bQFe6lKk$W^#wdU${h5VT?B6YsY3ppqp$` z7|2?3QwbPU72V$5DOGS@F=g+IPOX7uR{<9$*Ek z*`JZq_L{J{B+3L=UR6>tj|v&CEaJHKK53BBSV1>|S5p%g=e1>Laa2JmxGAk5R6t`~ zBx*L^QX31TK$(%KjDx{Q0R0?D7Rs69K@p25*~He*M+Azx?*w&GPNrx0|o7 z@k;=oaE;xk;}IX<9f1XKeZBnjZtoEB0>E2bV+mlnS#I8bg~cZ6$TxtA#8 z1|s~ZFT=;JNBWa+nYDiRpTFro-Tv8MvI>#fjo)_y>jq7w)@#BoaK9#kV&0>s{dT)n ziZ*NB-2>!YztHpzg}^%S&>k}TbXI1bM9;DuT#(FHrF>Dbk=aGWMoT?1Uy-3fG@O0X zPMUp$42*P;{gg67^S%_&jrMXuE!}x|3aKSfuB1EwkShtu?w|pU13Kt(6^`6#OS*ph zsDtOBE+IQetX6;yA@9KrQES&J*u_Ue`fKMTLs~;?$m}5shIih>E_4^@AZT*8Luz#X z=kA1cCrbqH4w;NGw^Kbo<2B)t0cJyR>f4Lec7_@0+6F`o<>+gq6!TN<27wFY3g;m@rZL?Eh=IR>P=c>{wpnq7urn*#QbfStoxYOP^328P3HQsp$iymo5G# znOt2?(W1elgz1I^&V4PS#i@fHilV%q4UzZDDS%mdHM@Fxd^|q?w6nGwUIj|aAtrT4 z`&^+s7rc;1>y@hR?(USLde^vyKetbFhg!ft@&-&5uu-*X`2HRQC`E-LfDGsCJXI(R zn;JmPM8t&DInf1E7f_xdr!}yTBb^wanpts@kj>e{$a%FtJ6Sgan8stoyq$m?Bz482 zAq0#ru7sd8R({6`RiHMg4TDL!vQon-nH6nV7$`z7VBwFx33oTxlT3}3sA@0BD>s6a zt4Z#2;|xIt+rge^%YZp24>C>3-Y5a?GEp$#bUYq_BDXza_PzEN1$yNUoF2~fBWrM zZMN6@bN$HcgG*z|Nh;(cl!_T9@~%SCoBXWXRl|kUd^&Q zQF;*8yJ+bC|5EEt_EveiD`go>*UGd#QeHxqV+X-WPeA~{hkyBhpU|nV*7e;T-)}4I z8;_y)4BRRJbO-#7P*;Qvhf<>e~H)XA0!o=vw?QGnsaF6GEtd|LjKNQWVFXfBgI&lDdW@2rF7QXk%< zytx4+aKOQvF#|aKxA$@dVAZ?a^@8jUhZ3@c^kR9}Us#q=K;ld`bgF=ompmZL-j_oM z9@-Zxd{5!(whOAIle`$-+5Xpz&Gg9%7Y zc}}O3XEV|H1fZxgn{XN+1v7GvqXerkH3n6YlI3QIa*9Y9o0N4RPnu>Oggjv!M!lZ5 znmGQktc9oF1_UZ9$CVnxMMb1G3DK<*K_qj-v4O`et3W{&trhQUX1=UR2&h9B>%As@mP~@j*EgX@p0MWtL1Cpv3>V$|NG~ zXaiZj!~($e^#&goEsnrqi6s^v9^0?NEB3&${or1Fbia9g#BP5LEP>@_xqSQf+qawl z@K=A;;;%n^JpTUO?)Sfc|MBAw*zH{C(W_Ul%+=L2?2;+BDScOC*GZI}24q({WEpfC za!Tb8nOi9l8s;*?hN(O8>Rz1t}R*Q`h+Zd;0E< zZZ~L{H=s%Z1giM{-XUh*C$2Q>wG&d$X0u$3>`-Aj<#8f$3H3)DEE6$D`ih)>j?hx# z2175GsQek^_vnf3M?jmU^nI^gbTu4YW{0FZ-2o2|-NQraG#<%$>jQuT^g+rMWbE*R zlXOd2cBw(gfJM8R}&P z8N2@I3RQvD0GnMCs!25()L=A36?{({1Jy0eo|*exlcESizoIo!Rq?jru#qP}it{54 zvV4V5TI~sPC*)uN6$RyS;rMAvlXm)Nv-iL;jJi%c4#5pjk-Fu2OAKsO6oVIFXKWWX z704xLSl{0_`#k{O*Qoc-xqyh)8@0c` zXXd4pnOs9&=Ez@?ZpcjK(P^xtlq;>f_;Uw<-Ct#iE?9O$VpT#XcvJ=m-v5dWg7oR_ zpoYAOhbbi_x(7Wtbe*V9MKE=%d&Iyb8_9v zvP9RR>&m{_5Uy(w(NRRkuD`B3g!+aor3>ac1lYZTc6eL%?&vy=GSpH-Vg+dDVRGn8 zAgLXo`^Y(-UnNRkz!2{fU1m})1YcnOFlxex31k#xj!w%s)E5K?y=)3#yCtWLmL4W#?h$IR$xv3N6 z6H>|s6+*rc#bMCI5SuR`V0g;ed9WQCI!cVl9=~SO@XGqQma(w}2W_!8{2FJ5Bz1Ie z|59YWEJ+p`183kdNKNx$61hWf0l7X44rt2C1R)|+tYFu%r-0W>e$(*#}FAfOrDt*h+JZwhty!0 zsUo09rK;QYhPn2k9;B!u$4_(Zv%m}$;EIa|hS=K_WHWi_{{ik}H z(#E~oB@rkUep6KBNgvMHqET*t;*95sCaNx}JtQ-m26Y_;zMRQ;iK?93Wi~^aZ-q^W8UBFmvwJ`2SP(2F;NpX_nXn0}kK=3eg#0lBr?X zOlEG@sM~gO(@e7NQ)$+0=AhL{d(ug_{R8?%(n)_{=Cr26teMvOG<6s&t1+9h=`?25 zE<@9d41h^b;B&$~7&^E+;6MbkYH6%2GKfF`4u|9U^Y^_s#JqUTy+_Ye@$v9~+mM_g z%Ywl$J6bJNgYIlhLF6XbCCxzTq_fpempBhT-1M|4j`@qk^A}()JzY#pPnqKU{CbQ3 zIsRqz^Up5KTg;G$oOHP7!z0emfBov+yVvLEvcKMaxW-56)z02ELrPfTGd$)6mhM+r z;46VXLAivy$LO~qB_v8<2f4FodkO5yb+SA!cdwr(=O{-!rN@*+o36uI?1L*TtpjLkMFLCn#5v2T&1MUhW2^cl|LDB2$$52Ik87|r+f z_f_@wd(iI)o43^s8dq*eHPAHQf8Tun{iLroZqd^6c0{P&zG>>3>pCYoiJJ>dA?yTW zcgXVs#aQU)Oe)+jtxM!{mVP!F+q!GC1zbI!+qOV43Lyf1x^QtM?G`i9S(pF-AOJ~3 zK~&w7M0U_ugC0Be>JBLE?wIYj+1qxK=wNhl* zpeduBfjBg5XK&{99pZVO zw(%rt-N%@C4&BX6sanl#3Yi0|85*rQocfu^QV>R1^yx^4LE$q4v%yNsICWMHKv=CX zk6Fxu#g-K?_;sksxIlEm-e=}*GDEasi0bJg&Ql5YbD1)q9uLA}p=k)zI1QfIL!Q_R z;Y+JA^vf9N9Qgs*rx6b60oFtA$vS130C+&}knO|$4nVp*fA#9OuYdizM8Es+Z2+Bd z4+)872>|!f!R4gHVBQR%d|o~;%a2mx;|_o<0a=zyDINCi(L)Z1JAwVBguI5lE^)mp zU!V7{pP!%GUG6+yFQu(PM1p&y_W*9Nge;}pl^>9l@5c3hEe?`(SN>L-PAXYojo^458z*Q^V%S(7el{OG;grb$UZ9|dwz&Ceo zYYo7=N#dseYcLt;!cfoFt6*9T6|9qlOL!D+ixsV9AlkghJG(lRU$!LLu>yqYt0p1jiAaCuQ@Y$Zw+l^m$a|$L(=I%X~!>kD%m)mIGX~HF;88 z&j;&iY#4&&{{V}RhPx*O1e1v78EHXNyyHd1PyydKY9g7)R`ofLts`(bMy5>ts)?$M zRtk)|IkK2I^7XK=g-9_wg$#W;uA7e4us9-eC$fxbtq;-a>gsC%O>e|UJ%@}w;**Us5MvLPcdDl|7=py`LX;@KJEv#7UpOB5lB z7QjA9p$4REbqEm_3q+BMHTHfA5~An1kky{r&$)@uVTX;XuBSd2vqrALG)w@_&Hy~_ z+dG7Uma(C-0JuzT=~z8^NT((a{>s+KDiA7KRg|G-nlaqfikR!BrmVvH3N@oq(im4O`)>E~gMVK-U})+06S@qSKnbKJ z9^B4SKqh6fls%ls#xhCn`=yjOiA;Jc`>=2tE;FU~U|R0(cFmFOifE ztpg9%J?|d4zsC|~3GDi7?5=Ts{_g7aH&@?m{_2|_K79E7ci;VReZAT37N7s+?5nep zJ}iQU>;k}6bVZlLnqwE+!jj6lTb@6ee(rwEQFwWS3zVK|4klk`_zG={{o(NukIiNS zY~Isqv#Q=!Z}4_aX!w2I*rMH#=Hf|KD!qBLs<8Rbe-Gy9d0xg#^SndoeDYJ z4!e`{$Z&?UMOXN|!x1oFT%c{+AAc+^E|6c?wT5=v0$b#HP|et)>(Fk46$jsWoX>_^ znmEOZPlVqs+M=CN?gao`SgVrGiD#_0bYbNmHgeJJ;jzv3`R9NT2-KNFXzj@rEIuA9 z2~R4c`7~?`4N9j@27bg|jnRB+mb%O#OWf2oPNLD^J>ziRWH@c95!xz0!A;Q2gT&U^ zWRv(ro;XjBwPy?_mHE0M3;n4&BC$RFHE`zH>Iz^q>dVWDM6{|_lvNlADOOBRaL>WI zu-Avc!EKsaOHZfS^EMz<6;%~BHS;ln6cBu@7=zS08`l*aWL^P{^1W_cjDMV78P1Lc z4?Gc2fQVM!Q;z~3kXA$r;HJh*B|5Q-0df_e5da);mWacF0N(2!4|l`iFoPDrR{{?` zfGkQt2bkEK9a|TVYAOt+<1AnbiTWq&3Qk(ID_|3-tKC!*Km_&p$k@%J+L>l?F#*$T zedwNC8_y;z^%IbSh^_#?>ZS%Wt*Y93att>kPp!3CaeV_cgp8=lDyph% zRng`K+%VrT6k`S3t(j}SsX?R^<7N|dPx|t*%iycCqA;R~?6i}?sI4H3nd{LW{q*QS z0MlyCRDfH*n>&i04LM;wS7uAA>S_3Em^+qYcRs0r`i z+vKOY2A`^{H!Faf?;8TG-d;t;!7lqd5lQYU+lJWmd?FvVYLkmlb8vznE(Q!;__&bP z6Q#4d#KAS9wHVs^WY3cci(^UAM5Qpf4wEg5uDu;mbKxc|7?9@^dhXT%_PiYkVuz#) z+}`Fx5YL7Ej6kH^b;vIqoA34Fg8;s0Z(;4O2g?mi6FmoI$l&kX22+61@VOn93tFpz z>9)4*x>+0epG>6B4u@!v+EHL~?4J0_=WP6JFQf@P@}PzhdMa@M-kLDOP2tq|Nug|m zrd)FHPCCMrq0nMp9MwRnll6)G#4kjF_sAqvmPh`~iZj$qp@6Yoj~I*wAY@rKiEW#_ zVO%~|09LCjA~emwY0n;1wK3MZgs1LoRw8Zm zT5+>+9gA<~-6o2#SUescj7V11RaL!VD6Z?K-avka0RVM|^4a-i^(Qz~8-9gjtw zBb%^7w5Cn+$Z0<3w~_0PL#go?&_2K1uV?Z(@yl2LW0Eed z-U1TX?E3x#@F4H4Uz~G`8@b_f8d|cnAUa6@+W`r7mgz0OE%DsFEj=&G_3{e9dMV|- z{0M9yKlZ&$F!IOCb4ckpWa*_G_LZ^(WOCV(CLjaV0zmwNHd2?RA{x?@w|K{qiKm7LH z-+cGox8Hud*2&k?Ih|ZAzPkC|3qmkv#r^vKB z!I(P=IJAQ9tYTo|{xEEw2N>@7tS)>|$cU4Q_Y0}M6X0|zHI^j(r|cf z+ZIj)k~=j|J8#K<QW2A8_S0N}U?t`G}l;qTGZ* z6(PIwYnMTU%CMMI+vnOUJiY+6(tOFAY_9S&{Ve3Km0QnUt*&Uj=9`;|l9flREob&X ztM%3T&6_J`M?G7ZG?a)cJRw9Lq_1NL;pmfHRV&Jf6*Cdn0J946y)yp{u4_jvJNuO2 znLcPq-3-JDDBWeZ!k&?E1A!F}P9YgcA@Xb9v#6)3h-8=wICC@)GLIkDoB`SD$_A!1 z%#3=ntKus>KAOkJs~1;q-u^pP<7V?c5uv*3qeI(lRD`Rmuiw1>Ei2UAtnfx*#oR=M zuad7!Z-%2ARXU9RjL*&vmZ{sr{&;GT{!jfF<%JByx2lXZ;u z=h%?~x${%%ZhDGxcHR**u6|@IB7iFwSi}IhR^#okUeVQ>iCjGyPuJzSaoyjkjaNjg z>dn_zS0H5XZR9L|$zYE;~~zuKE;1q?~$gKos$pj8$&U>0x^-h*R$t!p*L5IQuu!mJc~ycOKi z!e~Qn*Clvrr${Go>6El3%PqJyFsLy$C|mj2zxu*D#n7!-9TO0zM%E!)XDZV0^9Y*D zw!`xwJn2?>?2mNPOoLCs`JYj3%)jD90-Ni;m-6PLghU^BU?iiUV*b)pZXx|P60iW< zA@31_m!-Vkef%Jwmt}drJb(TC{QUW=*Zqf^n~xv*-8JreEFmG~4gl6W>=M6gi{K^P zYiUxJWmzIg916ZaFXg?2Oi-5aw07z2H>5;a_CNxOzLd!|ZqS#%{xx2e9-I5qyPqpb z#@$Jv>=Pu|$?F|<30}P_pZ_1<{Ppi&zy43(e*5ir-+u1p5@i>X&^A|Ns>|pK)v&&y~Q4CxH#p@YC zI~589?jY?PP_7{0^bTF-tHXj1I^C4Al(p(q$ zQ6XS)f|K^>xf{;CZ6|c~2%;yofGwVKZ5}5MEjo00k+*}zN8VlzvXC~vn0}lyt1AE( z9^P#Mw0T}w&yW@^T6A68p|~i#hn?>Rg}1?J$886(y$tUN<*& zpt|5-!Jk!zq4Mu$gQ_|fTYC&Wm<*^P{B2~rn8y>z$Q4fc;xI}c>Cg`lqvqoWVz}4= zqM))$ISf7jQm~@=Qx{zU;t?6GuimUF`+qm@?couDR_j*X{i{Fuli&T@f4}(y-`xCt z!yBU2s;V-khBsy*&Wa>?%$%4N01)92<&RmP^mqVpNV5I@0a*FqjiFyV=I_))emY&u zd;pD_PAmr@hYDhkGE0kkaqqmKa1i}^OASmR@@eR7Jwmb>y;!Y?Rux+e?OZtgBs?Qj zgldI4tV!^B%XPziV|(a;=xIgSD&wZ98Fh2B2CyQwK`~jl%wvzBbV}~1tEbUF% zSS#!_Y|1-5*KD_8OvS~vV!-z2$_D|Sn)(czPh4)E2MzvQ2l+CFj(6YvCmDj~@T&)s5Is8} zJG@kS)L8~#8airzIuYpb4r+}2Q1kTT&U@BXc3h0R5~1NN&v{h61}8Vr?gK+SdOEpQ6%sf&AHh zSpGz6V|x_+lqv%I_r5o?iSMCTm_iZwri*YoMYG$3DLVO~lCG5S>G$CQl)UrooY6MSdW3nB+3S9paWdlsN2W_G3jY`J_ zL#n8vF?%cKS~*uU{sQ_an-rM^#~DRgQl_R0GBk#Igj2RK+%comMOSnzamLYt3^2?-M$vwT!J=nmzsZ_IIJJ+pIOhzc zGQyz5Rd&+MUSiA4TywKQeZ#CQWv=X`DyxVpX7IP)Q-(KRSL;;;LIbKdHw@53Gw zULJkO1o_T*Yw1{BDf@?y*C-P_UzhKa^Vjdr*SqIe*FSuR`5ee_0Md)Rz3pZxhhxS|F=#w;54AfN_T2`A^suaexq!t- z5Vjsk7kS&YKx^|{rn4J+BDqa?@32LSt)C}Yin?=_8=cRQxfoXk+OBnOBe}bRt@TmN z$2Eka$dRMnc4IzE8}j;=gg%()AwHxy!9yS8(WjQiXl8FQf5$u$nf&88@Y$FtkEar7 zV)*P2uftOcnSz?6csn{qsUt4W1C&)ZPgi!hc>a8%)yhH73==qVlwIi3wZlW5>ziHE zTBBS05LF6U2C@;mHw?vD27oN<%&eGCQraU7CS-aQO)}t3SXK zQuhc^6oInrks59$<^GEW_T2!mhx7@qS3q5@tN-~g|FYTO`}co8vV9Ixj9w4fS%fm` zA7Jo+6iE*xDGuPrK0Q!{D_()s#wv}nszQCFX_$pUoRlmN(jbSQp2z^A!EE@rg;Zb% zaoRn1%+{lmCOBap3}w~IB2h4B1XQbG0_Px+o8l_fFyGwp=Dm{<+rCH@7-(*g!R7^4 zS66S|u2%$5)-bqM4RdCl*xB*Lc1Fi_^TfEMf~or~g^rHS+m1C2`y0gDN7P^+wlMCR z#yyX5>?=o9Q|1d;3En|t6iRthZ+GtmH>hXL$sKTGiRWfMf=#FkmsJA-(bXj1h$dJb zSr(RwI}0QgE;!7BgvQ#2>DWipB?|W9p#Rnc&@b`6&I)}(QiQbv{0nvyxKh)xPLC%_ z#jv=8k0%q8A3VLzF=Pmu<&?l3808~2xqSMt`(vR;Kf-7ynXnatvX}BkN|aaY^7;9z z*Gc*O`ue;6`Uj8A??*IyFZ(6XL++%sxK(2J@g61aXMop5srUqy+0puqZ+15c)@2Du ztjh-^80hB`Up&E4?jd`J)UW>P)vuqQ|A+tcZ~ykg^$&Ca`@%Snp?!6kLtM^m!nz<^ zE9fUB0(n5c4!#_nqizQjWL3g#*N)jPfnRg?WSQN7iwm5>lkExi*l*n03ctc5>>v^F z>3nw|X)*{T0wuwil^z(_`GUS9Ba$(=Z!GB>RM+jX^ItI| zJ5hF6iwFh?)xg*V49*kz)^kre8q@_xe9Bmp@9ZA3s+#i-Gv9!*>~0f47REFcgn0U3 zTG5~xrggQxx?-rBYqeqJMcZ80RISG(Vdi5Xoe{a93Qu^cu!vuUo*4EK&Wa~W^%K$# zB5?Emy>bTL4#czKd0LE5f$%{VeCiQIGzVO#iJeddnFX^kLUh0(8rfG`GY2XKnuffE zelAR~8RjADe4xVt5ohYLK~o3FfJBy=M|C)0h1D7rHufkgLcLzUef#DuHn_R@erV4D zs|@zeQSP6CX;PNYfuw(s>Omg%(X*o_)yU{b!3wCF!K&WeG&Q4Xxc0JsB4A~8 zV%)rUSCE?O>dkNe-CLh9LaSkZ@F41l}> zn}_sJCL&P9>|zMLAR~a{G+YZc2C1KLyzpFrmG=-?44nar8$0NY0y7uTT~Adgd|F#z zMZ}a*wVq1o2q%{RGQU2>p*#K)>IXjRi8R(^tLdtd`o&ak_Cy~)#?Zm%@r?3}bS(8a`FUa7>(sY2`18>O9gFh$pL$&BY2$Q2y{Y?gkplPSC~pXq4(Uk-`XpJs z2;Pzc&V+i8Zqe^0x;W3D<>y~ty^adpecs?<*n4nb_t>Y{@3H58pQjR1?)tv(_j~MQ z4=k|XqfgTkWs1H>KRFHbd+=f(V-GC$0AiH+W0dB3+NX;Yh}{RCM$jpe@GR`6=^lGV zw@CMYnm%8@{?qH*-CeU2K$<{zfUr%XwbnY(2{a%e60IQ;Kto3&5h#j8AQ#XA5J7Oj z{7d*Y774U=kVq#QcK13#p`igi0^n9dLlkcF|JJVrNC2%96p8yKNrt~ANdo(_hIU7- zr|4M#!u~NY@a$O*p|x(&esbw5>nITyNeAr@F!5*TL2z!{BT0@_Y~*XgL!y0b4pC$LAap}RY1x1IgO7N2yhb)u2@j-?Zkpwrs=eI!YtQ9uA% zAG))JH~J-E9EXfB27=vt zV`VoZLGD28n~eWN+vX&U{e%4!W89W;1{kQ}(~bS3``Iuc1T8`2U$jSPw?20!t3)|al z=P``1-z)ZgiG6b#7$6qz7E=sJ*R_~o1jLYo7$i1`(%*dk4iaL#ABBM+A|Z@zN;92P z#xVA-i~)kM2V*amKt?ZKT&>F`-8RxF!6udpMhWW_VH9o^-)`jQw*IG|c-xq!VR>sn zLXa^4U5e$}7%2IZQ8gegFJG+JZ&vGST?xKbppu9LOjAp(42TqwRK_%0u!JFHTf|A} zhn~sAbqxt6VEhdmyVEBsadlNzOWR=pWF(AXv)M8v1W-#mY8irofRup3l5Ar+bRaCs zD?u>{G6JS<3?d={1Bf^yVS6=z7zRebASPiTVgO)cue-6o7%&@FMnnLhZno-YD4?8a>pB!nf-F&1#&K!-k- z`>tb|=g*_A%sr-}e9(SS-N%w0Fgj z=^)Dp4liA}|Lx;G#xjrh3#4(JrV9_C(~~oU6pH{r_YX)@zuA7@@6qr7v@Cz~{Po}8 zZMx{JO8dkX4I~iI2}G-tL;y%Mx*RQ&5kLc?fJof8*0!?mVttVm-S*R+ z)}Pu|>(*jAt#y~^7SEz2%C**LktCje*4inCePbjE5{sF&KT=_lq6hkp%GI-D8xz7m zX~!rh!E8@!-D(@HBCJGR2cWmGpHui(S|o``60LzGXbnG8n0)T3%Vy!Q)>>bEc zBk2Sh=sM_6&;UAYJ4C><#C^0LXD?`xBpP_uVyj!NlTHH~U6L0NX!R!zo#2@UkUVoA zo%oZ2)>=b5bnd#1)`tX$q6a=0hn)c!VFVlk8&GWQ(Ts4wXg=ZvAi(pc3M%^gG63Q4D zA&e0Nq_ikl4m)&6)ka|vpyKLsNkqmNBMcOb5o{m-27rUs{(up~p&wx)c&zM6Uk$0ff3Fg5oOUq95Qpbtky4=%bVs_7`%D;@+B?bZ*FC_F%V4yV;Zp( zB*+LOO{17IB4cY4KowoaphhamM#@OaxRFLl(@3+CpQV(Igb?(bug#KFBLyw#%^Qv{ zO_XCvFfj5~Zhr*Cis)5!1tO5ip<}V6sveNCrgpcy zJrhZ0%WB$mF#(8#pk+mumoW(#ww*~C!|ylDwI8>Pn_}AehSNPQ0U#4Fz-I;wSimTv z3P4FB62=%7LO^8Mifq@9jW95Apn!<286x})Un+~9{k1jtY{0cJ1}3&sSD4{aGK__E z1`x&wkN`4w`DmCCAppk)5XdsbF)24e3Pz|EWn^L^iUpAX2@?f4lxS57Q3?S;ks&)= z*t^sq^V6v(>1RS_5CbtG79+_O8`z#T{AuXw7G%fAP`N8_pZ<2c zfF1fs49tRSHDm1HOF{@^?9+oz!+JO2FOT#aQv&%|l`-fd?$Iw#Nj8#kvt-Ikm+2V9 z;(RVj03U$|33jwiko?x(<&w=LQN=wNLc(4J26IF@!y3g!ku>tGPTHBVhmT1v;1pJj(muQ1mpKje#QQUJ`^W+f zz)1<{)0Hnn9ivk-2Je|0?vpQoI}))do}Tr5MUepvQQn~ng_tVJY=u5EquFfg%4Zw~ zi=0-)ak`|2tz|`+&KN{OPAce`pKO_IFgLN$!t>?SAT2#Gx>iu&%-K2EQYu$`ss=62 zDCRkM=zKy}&p>pb!+xKf=`_tA`W|?Q`ZPvtV#De&*3H4}K-Jgu+bgW!^Y>o)(t!Ey zF^U&y9-%vcfCCN@qBEQ^xaOMZ%{oI};i{s#WKks+l zf8Bfly3AG15wk5rv_2QL-$O;TVl-3ZmZ3*|u~UXC`xIzB!+T*YxAK~+qkxm3yVO>5 zPjfq6b$pj+Q#mZxioq*y+LmQO5!=cJO%keAV^`i+gv#0o-dGh1bJH}N;mB)d)O>YC ztMwXmWly8#debm!25y{IC?jRVb@_x(S;b9#vgZ@6T+QQH5uup*rWqrU$hDO}3t})? zDVMcC$;cHBj?QpOahB04!^#RX0!1;q^?;0AnS?!BYe>Su$T|qwnLQ>|lguBd{wJqj zc1wR5g)*}fV_Alow0T}jL1VRHMO+7IDOqUDGl+Q<2denfP8QkZfR3bH6Nh#v#v~b& zk$DB$j0m4E0G_(Qr$mRRg=5oP#_=IDslX*#Oh$|y;CQb z!N&La<)E`X{$b+W{2=ilcfT+3&Fj~%%H-ew{@cIl@2@9j81CH?vUi{v{g}xz-MRd^ zwpV%II``VfpBYP(xJF`;wpFk_{Vc-(E^<~L?$|%*Hb&rNX(5wosBaSCQ!o@%$mVz zaGSv=!Ru0w;POya<};ROYIvS%^s|$*zL^IBWgd~Z#&lDzFDXSw+nd02$HiB!2vwEY zN!e%>Nt67YnhC_!3Si}C5yaf6`u)%Yl>(C@qKa14>Z(?}xoN-+6EY%2eDj{+vs6Ij zj5wys-HIFUggtFNs|KP98D$8LjM;8aM9d91v*KDm?$quyD<36U0ki@XVFiGBLr2bW zirIdIV&y{xZIOtYCZmQ&UfaS#o=dv8J=jh{6rUJLCRdHapvdu3sxLoWe~BAX z*kt~;q>yEqnvTpi_rEO4*MHFiNYgT1rs*7cU8KMR`a!>tCMg!czQ0GB zLSix1cZ7mxyQ36~6iCZ*i8PIodU1vO!Q}z=Df%8Mu>T`(KAVRZ>(^!aXCHTe*ms@X zDnY*o_8)tsK)O#;^wQ&2piCD%qwM!5wAwR?$|3=fr0`1UI8W2QM;!OvVzEqPq)3o1 zhVxi>H8>UvD@sX2iFRtGD|_tsJ<4?P`o)Vs+}>^eWpj3B*T)mPc%Rq>^aP2OI*UXk zfX;QI6Cin}k98Hp!a+C4fsa+nB5@qQND`e`$+g|K5J}=!>@A!Y_QS2R*=jiwAQ@EB z1&Tl_Vbv$ChPFD~W9^1lS7@|eMPUWIUH9qY;^NPrCI5W4x%>19ZQFKEYMfl+;$mGu zM1|H`>mGX3CYMEivF`qP+jd%aT6dq?4(K#AbTKHe(ONA-s5p5xsCyk8O!7dY(sn3- z2y!KZN+FW+xZDSCZBt%A)!Jsg9(*gIJ9pa5KN{HzI z@01=^VIh=z0}-uO!pg>tnI0l0Z6$=rVm2lQgdiwmq%^}4qA?S(29?4@LI^X6{Fq@R z3>(9SVT?hHxGa^4VGJ`Hw&(5^YK4izbBt#y_Nji6Ldl95<)e0Y_9*<_L9mL?$u%`F z!Wcf1^aKmIaj16@v9K}{uQfCVY>Y5prA2S{@ECfvdh_z~N>Cohf@n#!j6o4JphmGf z1K`8qwtbWmCIJqBFy;llxulnpSjFC{yFuSIngp;7x&3`IU+&fqIc{h z4JI~hm|+0^JYYI;^4b}D^$d&?+6WjJEK9n)d|AC%8KPl;pi$=KDhw3CF!*+(e%e|U z5i6M6jr@G;HTook#iq+>U0%Li^N-v2-~VB&IIfnTAz+Mbn7I)qHnEV(dMyh8weLF? zJ=e3!p%{QTBYH*|s){Zzjj(-?6tmfEU1N%+0mCS;9eeB;$6o$nK(&8GCV+bn)1vXFsZwC>#ab4L=u%Hokv;c&0 z>It~&0}@kxu7Ppmx09;DP?jN%5gTJbFeU@yjN+I9ql^KISU|*1vH~Nt5ita1Ld3(E z;n1revl+&XfumY_ke66-UuH%8>=j`GFtPX|kxVegNj{8m3hYtRZ3P|_JT+((aA(5F zOMd2SE-n+o>X-uQ83&S>;T_}^AVvt7MS1lXkoRSp!pW8I`?N0u>{&u$FR@PpSp2Z> zANKu&l>#S7(F5r{9?}u8dL?u@!pp@n?Sa%@h@>nR=q*Csdt93WK-vSqo#f5OKi>V> z`bC_c%iVw7KRhH$AWioVy@jj^7JIo*O9#4pAWau31L=N5h##obz=eaasP|&n|P#Rvzy+2V(x!)u2`t*64F3S9eKYr{ED$>Rysn%jQ zByiP)I?;eg1a#L%T?AX7mJC#=n2TrKi~462_)eQU07ESj5owX2$O|oi4u!}Ip*!88 zZCm~6PTv8Y29g3m;yFw0A^M3T#CCQV+G&&%jii8XTdnV2T|WD$@3wavtpRU77F~xHMG`fJB?23PNQ>;=Z-J* z%+UUrb>S)-(IN4bh@b9or@O?L@&#gZVG+Nz^GF=AJ5&QsPT0d!-D*IiC;*LC=UVHc zu$MN`T8m$Zq5YndBZa&FO3*|58bPg*KJSXPUr{`pf&U-bY5#e%qTtuGXUX> zFGYd~NQ6k9i2@oC5&8pd`k>v9-Xd)6K6UNL6fUGdqy(mHqEzI!H z76L+Kf?@=)exd}Q)QKAR_!Lt$qZy9hejFkE%Ws^l{m59Fk)z95DSN)g%E(Ck}j*ua!JDO#|zCNTdSH+6t0N{(K7(c5|@=&5*S7xhLN`o%UdA?nAy}sWI$M2wQN8K z7y}Ym3KE$R9Ei3M+;!b%bFEEki|L?~LU?k}ksgV&QICn33l6lH3OVwSBAxez1R`lW z=VsCAR<{sI@kv8#Jj>BSZ@TvG!-sA6vDEHH|~ zVf3MTFBws6o1pvjDbJJj#pPCSJ9HXA)ao8dQLNUhi_43PXY1{D`(gV5w;FeVMyK&? zUFb-+n{C%>t+lWWY?Q#GXIpou6C~P`;+_A&8C5vs*p3h~2MTOIb?u$@D*zf0NdgqU z{?d`Nj>m_CtocA{>*+iuL9Q*C>xgdcz__bA)Ubd41sED9^F3!!dL*Qw6Rq!{0i8f= zB!wvaVYRlo?4Mfb#CMK%Jh4HZ-gZcAeWhESut(aWg=nFLfPUz)KScY-D3TnVc`pZt zp$$wN46I^`p$#Cw(&9e4yp)Ei*KpeqxUB(u{pbcPo z9{XH2h{yUlhct#K4V96t>GmEMhC_aE-%*=E*r@Zl9n)RBuBQANDDSFXILb7)Hqwj@nQdH465qo+sl{g zN3NA@Af*IL7Er6JYRmk7^AFj`%mFYN91IRP95jdZxF_10g8L|TYXh$HSwW3hLLeLPM`ruF zRLp@-O*j!6YH-=FRJa>98%q*n2cToRyu2)z1Y-uNh;gJSfLhdzyxGXjt@-hNqYPG8 zpsN1qr_Z-P@N_n43?f9aAj8|{{U4-^rIN-NswyLdWM=tU8DoTCTe)NmAZpYVOZwcv z1nAjA=gOJuWq5Ika_R4XkqI<)gYAt0gb-{bSP80x5F%SnE8EBwWwJ3)LPXx~C(bOF zK!8Ck$k<<9C=$o=Gl-}pC|?$8EZ=JY10|shj6~g7s}my#%*MK8IQm&YEWH8Ih@Poh ziJ=}kApV18q|$kURnKOuY#y(g zF;Bkrmr&FKe)+_VHMk%@;)%ttU;SIekG=c|^gvmb*7>au1P{Y2y?3I(0IwGT&D$f! z1Mu*G^Z`gqkG7Xy{*a{UVvvTUJkfN7&abA9X{^vj4 z{c(SH2lRjTe7(wX_s1S-k2Fcseed|^1$tm_D+Ct{``g~CM;89L7fG^MEU*WX5{uNU zq|^S7-9F9ZyhLgJ?0_gm+V>7aFHQhx;9);iaRB>0_Isq<_s^EgRayT2zufZOzeJJ4 zpL%fQ&`1*D{K>S|&?3<~i3(99zDiC6q5=)kc>q0t=Ha{Dwx2rPb=oqv-JR|_-E~@P zz1`|XKi;*T zQk_&2TDd}^krb_-AZrWZ@M(L8_VU@YtD@M7yRPdJ>p+s|R_h`v)~}x3blZR4{4;KW z4*1k{(10kOMft_EyMNxg=7QEpgmx1S44je{$!XB3kA4zGUTD3=w$T`Lkw*f;-LT|Ozb$Ru{>O0#&$V)>rtn(k#b0lMp0ab-P(ES1-!TWw|C2P|VKK$q~PSEmq*vcVbc0+i1k@Z4?U#5d(_Z+TJ3os%1unDX#JwP zys4W;-dwGJ^FRFNcdDtRWC2A2%E$=&2pSIygR}kNus@3r+Dy^&xQZ}Q6pd0*;qf$i zXl+;Gry^-D7|NJq>-xddtLJEG1d~<)dmox%CEmKi(aV>YWM^pXHg-uQb%R>+_V%-s zhK&SaU72cq^ZrM^{Rd;%sM&l#7-N*Wjlc~{dE00Z=+abV`B^0!Fqn;ZMkk;qZlEL} z>i}6*)?bqdFD~iL*X7r5sH!46ITK{-7tChEMuLQZF~Sf^h$Z+Ikw7V+q?>F&pz>%; zkPsQ5Vw5piTSgNb=cX775&BmeV`7j|2H;qfex9O?^B-hz18FCrUZ5j{H<-h8#m0E_ zoYDFvl_V+>@zO*q%1D$X5c#DfTgw?E28@C-!!e0*zXn<9dr=G+R2e{!Jf&I{MC=wV zj&AP>W~L{Y0z1`mtB~<1ATlw^7=9{ktxJS(yuNK=7$fH6<|v~u6B5BYhYlFpRvel@ z=J5;E(vf0~r}^(7#YAi)|ykDH`i1Ax4NE#)gq+yl#d z0O*%XD_L;(+eVz&%0G;L%cb?@cqk!vL2;oq=(yf|TfSPpd;Qz*cDw#w-t_l?OiJ`f z&YxphCfC=Hr41Gw*}T*7QJ;SUuCIGQ;tJ=MZ@!0I+W0{vy&UQY!?eQW zD0C4n?;G;r;k+#0U0r?q@k7TC(+WPgYPli%ughH~^u<`t=8YtBpzB=K7zSCdGh{&9 z4aH#Fw%rB=hhd(Hi|uP){jTV?+YkTvp$%L)+78HlULpcMA}Iy-w+Vf1xT=K+pfD9JRzLzMsb05d;5Lv05 zVS1uB=J;ZrV;jaW+7i5gZN->#I0V@Q)qKOb@iY2@8Sc{?P(gw@4aOsbj#j8(p7xN*h(bk`~|37Q*_air!UJ0I5 z#%1s$%~+ACh{8qyqYzTnZAhAe4RrRy7`EF6#tXFfVPEE-n15}a_Q8$CJ{SczdUw%T zz}j+3K%*+5P!EEG2`WidvdHfSc~iL$_g?an5veNgZX!#S85zOfygc`O=R2qFno*7S z2~198_cs7{KUClUfJgI_2zS~F!k7xchtoY~pK7Kz$7u=SW4+P*aL{nqp+dc@z#tT$ z3j*j&E8t)yvu{}b))_; zwB}eYE)Tk+bgMr5Iy{ESepYg4AWO2}c*nE@vEJiGFg~3^se*HgsShL5`6v=TP)KIp zCX_7W^Ay)bkrK|A%X3cidkb#?T&Gt_a=u)>O1DeoDG|SV700yt=6cKQ6D44h@}1|O z-fM))GQUp0L;9S2KV~i{XC|W9r?f~5F8uy-ls15bh7lKu&3Pz%LPDz~p>2L$!Ziw<}(Ei!~#dk5Y?I-Jw zxUpf8!mf!+5$eO#1o!s1m+y|y4gVYiN#k5TP)v}8S^r^S(;Omt0T(@$9L6n$3 z^<89y*y$ciV(RgE40|m7!@v#QZOH^82}Z8%fOJeZ0fiHbL(pC#eXDhTFl==u78*UT z%wQmG*pxOEAtH_sLZn7%DnxY9YT7jjGJ^{<#L;NT{ajz^u`a&h@&_>{vg=~SxbIaC zUL?~{Y%lKK0|XBxqsYL6an5dG);t2 zZfa>L*E9RuAj?o^4Mvg45q!|0qwL|cjwIPnfjuI4h%haIcg+X;uJYaH-B;_cqO>6XP|~;q1nE z^4Up%aRxcW&<#otQCXJDCr^Iy?AhzruWMsrt@HB2D$qa`I^(;GYp#J^hItse*r!9K zRbAC?4t5wK+f|kJ@<6x<5Qf;**(NjSsdlv<^)9Q{FXjlb`Tb^>b>O;2fG`Yt6k1mR zcAH%gV)5d|uFkSe7G^;Q-Vh!|g3gxNi9v=etF;wdP@@jRu+r&;fI-!D-IF4u18>a^=!mtJcJ^QHY9#4-ke^6JoovyfX@Lm3*-79+;e#-Fu zJPh&iF8JY;{{$d{v_r5pyI|Jt0?q&=`!@{0CTC>ngl%A+-tusK=Fwv)&pS^B{V(Uan}+e(FMeR2Kn!$d z1%2ceNW&}bm7&4kDyHQ!hO{zLfq-fiJuT%U0;o*oBd4ECnQM% zP^|G@LVnJ9LMtNLZnp)BI9XntpC^QGew&-4Y=hJ9aX;}x@=b8GO}dthZJz~rB%$0v z?foSRUtc}ij?H%>Kf6g9kD|iOq>kL%(8-(|Tkf#g#v%uSQRI%n4k3vNK3GShlLUC1 zr&rhc^>2^(f|=Vt?_3e>g_3icBTtD4N$e*HeE5JYz`4yb>|*Ej1crblCV%CxVj}AZ z!*0+t$!&^!Ya^T)EXg2z>r^3iRwR%Rat59L;!?FWwu?S(fspLuBL9j@@W0ph_Md9plv(o@W5 zjy$8$(D2q|Z)0rS*4%8h=C{H2K*m|lyeDX8x7ec5ICbVlK-rWiqiF}%%Lvibe0U0A z+U(1lGS%&S0O}yy>=rMchI3>ai*oBRiSE+sRY$T0Js8{U zvUxby@UPaGw5lB1w|9yQ00coe4>xbJS_hI>2OwD=mmtL0mbzD$xKj+X*HyQY5c&vW zFhz0xdH|!Vp8#|R6t?~8=m&$J2A(_QS`7hjbrb=2C$kz5^)}pmc&<$#cwnjKx^f*3 zcdq3%0>fno2y0Z%##hKt1tHJ|C{9CF-=CgvK#(9GV9w=ucw&J3!IQUhrUQWF;gQ(o zq20eq*Bz@LUs-Ciypa*z0h7?P&%nQ>tk=7INsD8Kj4QZjVSAHN0*Z$y51XuuvEitu zfr|ptVhenpK5-rmb zHXWQv>P||>efmsDoNK_qAp47NZE&TPtlUfN@4-a@;5iYPw-hrMvE{o6lJh)YX$)O# z863yUJl}%xiTDwSfV9|NZU5;a`CpdFY88X?q{y#{m{2g2KG0Ia_w|H=h^PQVN+8xV zjU^~Am{EXPjvwg~!1;3Zi}U9oPB~9gGmT6r$(gtLcbdFhCCgXK_&P1NIawxEAA@AI zIww$`GjqYbm9o%r&(0Z^N2oS8pWTp?zHjqCsEaiw()MvC3;ocUOK+~^0dncFEK8sK zQI51Wr7O0vpO7scAc;W<`EY&5IM1)IuD4gewTF(`h0gFH)9$t5kYHKUI7wbDt)(I~=gSnk7>q5&Oe|(Ydr(9-*{H(33_JNqJ=K)z_^P3vginZ)xd%l#=7cvp&H7 znC2J-a6451?yVPHCL8WC`YEP&#~)0DiMRS{KrI8nv+h^#HahdlMw7uMfCkY3Dr=>L z=OF0SYIS>id)s^%uIjeI%rn@s?1URr-Gtce%d)&Far@z>#J1@|RxtD6A&R0W5rA2= z)N*Psa@8eW8zF9=Ji&fnmL+h85@<@?Hcff!0Un|)0Ni?r8kF8=kZ*|(XaKDxd9reZ zEe+r`(9MdU{c3=+K?GnK;cU6Q-~8cdF}=bVL)Tfg1Hv%Kg372cDqFPA>R>$&Uj)0i z@3T#Xsv5Kt0=ulrvfayzmlwZ!arv9KyUfV~sjyft!g-jz$vQ+;S5**(i&Fdn9#`(ac*uy72sV+B=t7c|+|@zsy^f&U2- z`#S1ZZFHhvs-h?1f-lA7~~Hgu7vp2`T50p{9RgHZCOgOapd-6lOB1r9K8?6oi5e zdS*UyV`;Wq4qrc1K#>E`47lWix#&bYtC)~ji(x}4<`UP}*W0VhL4t*^M*{u71N7Xz zQD^QXF%b=f5=#PzmdtV)+qZSIJEZw=4+sFo#07I&08D09S%3gq4&LkA17al{-895E zbq4bF$NQ_*(Ht;*Vwo4ixw=k9%KHICkCzx4G#^uLXai(QRt#cUkj`cCeK(+JOs(4E z%w(rV+zoX8Kt@(Lr6he-8?hDlL;(){#a$Teo86%!rqKQ8?fjj(%%HxO;vXBs{Jwx` zYlYOmS-Ovq{-X2={hc{nzHfyrQucg~-)oVaA?Nea16INTl(^kDWvW@{4i0-7!pHp^QB=mAVWi=r~Z>`8Q60#ASsk>=FP zn-sSVaI2B8*HP-4NG{7EAAK8P)|7Z>aq?`|hrKjfp#snOOms{M4FES~89jOO?Afz# zUjL5w)fj)(Ap*E4rwS3Gt~1n?O`+?7U5y}Etb^U<`_0?kxS(&?T~rx<|C=|z{7)~} z7xUe3c0ChW)xjL|d5~#xv;*clpsLotS_8-~cgQeIT&aTjIt;R1Rv|!G_44d$Ao{Js zFkAqb2SEq~VciKQ!T|GmZKcOY6unyet>aI!5F5?013>_ro)XRjO*jXdOP*ULNv0X) zV4!5SD7c!3VHH+&g`l>PEIl0WiS+Oo9<`jbCclGD3^Ecr_oR3AFl!yULI{&r5>x{W z{Qw{yQtK5QG~6-Dhvaru2V>6rh?IMvfgh&ggmwm0^>{q2gKD97yf!-Ps*CZd0pJeR zNAc+X^bz1gLY^@0;hT|vm@%b84u47^?z5ch!7KV%F5M8j&l1dLxc83>LLU6;mdqH) zr-$g7XiTmg$K%~VO%Ftr&~e%80N(MjmkD$TVvimN4cPlYF2_BKkA#SI>RLS?;?a`2 z@E97@j3wAN2wO9x>@(ZRRENnd_r$uqY$9nSK27~edvc=oz@C{?#&UU{(29`*IfG0b z1QM3{Hs5N!L~ipzPKI3Ob#a}@WQnCE_RKUUNs=N@eYR<2x*E<>*H5$pc*`2j#?nT0 z*eZ4WSATW!m*>g#b#Z-7GGBrVfCcB<$)2cB(=qQ5XykH_qh*q(Q?i;FGudc4Q zmskBxnM%ENWaCt;K#oy<1R^5e*AP}ZIg8*96ZTiHJ})C-KzE`g7uyv1)~2Ei@Um?@ z=%<-Tbg;eYvlOH4qx~hTQm4vKPidZt)JVhFG zR`?_O+5C{R;gXM$6f{yw9KOeYU`!sJV>(tv>|!;$`U!PKEIA&8`Pe|mhZlv!X!6?4 z#~xNg4@Pev2S9xASmB@cSei83KcKnoV5EZ-ft$vlO>gDF!zwzPeO02wZQ0zsvoLzZ zy*A~$8=RH1S!4v&vr>yHP)4%|-V+Z%T9(a+o7>XJnWHCXEByQ{if|T1rU$Q?qC}|` z)_auY)S~7dx7t-tfqfKB9bNL7mPSXoEhAvMdh!+aGP)cvfBf z>gi^q(Q|!-?hHFb6#V|{H-G=1E?&M^zqx$dW5TR5CH+2_u&PmQzOI0315}&L=8hW@ zv)a`!p29Sh)u;ksmKvH3;gD`U$8^Up@qGHOF#!h#2FwQYN0X85p)92 ztLkArbm)p^h7uE<*j^3DX_tcze~PHXV(4xm{d{ILGZ~0%4nTMKS$RsAM_7djtB!uR zY9Gvlpq`s6s2Vq4)}L^955XrmAzOzJ{0>7qVrc%iVQ6|--7y;fxle05qH>eRCD0E& z!^SGacmNe0k`)hvRQfSK-HCJ?YzsL9yl+ggMi08rko81F&X+vMmn3w_=8hP}2Z{u-?v5j%-~vEGq%*y{ z=ku#qum1AYGQE=5S4(CBau6E~O~l;$LnK5AA-~qahFilJQ^I+k=hr|%T^)eUw9b#0 zL@3fL9uc(iM_Ehr~m#;Y!Cle_L& z!qruJeR-t?;xIFUp3MfQEVsw+72Whldyl8a@{Jz*h`)zk2py0+yLz0P7=Al(iZ z0V93pd@L+TwB{Q=k>mmlNxl#11Ck4{^plukDvH8@WE5tU$c=DElk@NaB;acdI}zx| z20-px3Sv-VGWiKkPT)yey4g_Xk>!H1NlWa3GIHQ@IWhvV(0STJT1>4^^AvajlxNcjD4V^9vVrjidGh3| z*}D(hn~lZLv+}l+N=JZccZ`6}fTP(rA5bES*0*NGktU&=C@N8QJ%-0r9NM;{#2!F2 zjl$_Y?~j$~9eOaV4scCvtLpO*K=x*cp1Tjv1Kp6P$wFj!vw8okU%lA8-BddRns=LQ zUC)Dgs1>b_K)TvoIyz&Mt`}+|H_K4hb}e<)$r{2CRaGGjfBE9#>B}$+syErD&T0dp z10W3N^B0S7vB@@7mD$EN00mUX4z-!w>(MAi8>3GU6_FFgNI7 zbX7Yu03B+MU3i@GuIx4F9_3M&r0!S^j5o|YKn+xNV30im0QbOM*gRr!ihD`-e$8Cl z=XwXD<*;{zKZi9xulnsd4+7ivBYei8;(+)0kqmNY{kjLM7;#1qqGtlRT-iZQoQGii z$OaRUd1lDNqtIDi9PAenC5cb5G~NyT(+(zbSuEvh(7;Z^$CBJF-h4 zI7JBE!pO{!Y}`3qDC?8WA=h>t#K1kXHY{!NC;)OW7gt4*ESJlKG^orOfQ$h`vCTO> zU!AYw^MZ3wVx3&zo19@HhBQQ}1XG+4Npe*LL;y>_L!|@)QVaQgzb_FyKY#TLAsJlHmJ(Oz^MLl$k+Ahj*C^py+#GrLPsVaU6rd#TDm;MbC%C zV0ZY&na-v$psUgkyW57if*+ijI#AmO9qXvF;pU?aAbgkR|Mc7MkmmjyU~-e5KI)cn^|qjR(6(?A02=?rGpvHD5fMi7`CLD79@n+*MevOK+y{- z;OL1ZKfrJ^4!WAjjfI!?!swLNZkovR&Z5;b%+AW~ z>*nUB(dHSR7e!H7-ZL}<$GMoTDGQS@vUMc#B8?Gf!ulppLCn2yEL#kJE2 zF3yd#<#PApwAW;G0DFe$ww!v?=xkaxD9e3=eG@%7`^C?_n_Qdp5%@x{kvL zm|=E1a1_A}8l-8oT%KWiTb8$oR*`LtED=SwW$!dHX5%|y$t;@Q-$zGIfOV>?YS$j3 zI*=4s^YwhQ%R0+CBVWD7%HBFnw}2wRS-HftOuvwxv4U zn!w0QT&Z;hM*tpnc6L>NY=QtmXpwZNIq4czfXe$6p5O$h@{{!MeO=mjT29=uUEf;B zKTg~pS1)u6POQt-uxI<&z-J$nOl+RxKZ2eyrddCao(EU?YD(t1}Y+;NALpta=yGs zi)+JG!DYxi9s#;f+ZhVkrg~^$fTPM6D?l+uYUmbQ1sqn0-jout)KVfV{XY`1<&TY5@oPc7q(mU~aRn z-LZ!?Jh*$9KUX^$_(#*{ZqLLY6x@Am3;g!-8hNTqPFl-j#SaEOAD`y=L_{EplXE&> zYKd~Ez9t46YzGFD|6_CDm{@XgeQj>c+%{qoL(8=Xy~l&1kXET10SOz+6rW=2wIOAv zvh9GDWR{GAogqRV3Xr22+kcjQ8y_}ek0qfQ1r#LzT!uRGEcB8RSdUF8ARAJVpU_U@wnXvAg^ z?U1~G;JR_3ud_Kf@Fk?LC4VGc!_?xlMZW&!iG`~rMmXBCzfrj?k#>KKN}wzoq&Llt z=bc5XugX=4cYkR264&McW@U++ zGC~SR2hmALqAAL~)|8Y{6d5jB$9zZ8U^`17Lez{*Kr|~HMJNGGJ>YDLoBd7s;RfZ| z**f}*zqxt+&F#&NWu0dwZaWHkW-P2-0=)T9mXSC00L(Pyu2c^W^m5S7wb2hw;g&mAhrr#{`%#7j?3R{y86CeOqBu1=Ih1g%|@@W zs1mQ?Nmo7T22UW5UH&71f2t~X*1I`C9izx?Zq`3roVU1o20 zJsi`@3WS;r-dt|Ni*WsNzWaLP@|rae1mQ2&FP^UF@2hN=Y3eu&t2yRjRa+P2pkt83 zs)lh@9v#W9pHQRZA?s{j411Y{EB@6Q=PIlFqhMfXh%i9bv(W}gh7SuLs)M>h^^h3{ zjw9*%P>eB@h;+Y)Bi7h`XZ-*n{m^o^4WRgb~L8bJU6^ErYF^B~BK z)a3qCh)?&Y0-qXu@;aYkJ3zal%_ETai1c!3M&S>E+Q7-dv4}c8`f;ywuoxQjAa3s{ zZDU3u`7`L5hI&+=Ad5pF%fkl9V=N1n@sd_6&U0dR_#NMJUwX>m^7@?*v45mU`}rBd zxN3aVYT6;4thU1+FyaSC!*?IXhI_W>=?H(`K{Q7ts-NC=Q||d5IGK9bH>dkY^3y%h zJ%F53=7M>-N>&LmqhQ30C3CUme3c}G^DS@PEn=Wx8QY^tpoEYk2PmN==PgkZ!%q?- z@YaMiQrGa+Kh?>qURy zosPiVtU`M==iSlFAGi<68HVf1PI92?KB{6LQ5iI14E$pi6*+uO!(2INJG3?^ETuVBzODF4dB8m%s6l*b zLAgJg-&3#p8TAy7N34nFeEVdP4*u=CyuI=WNCc3k8b+TzdxmE}FSlr#o9(*>p3Oip zdJX^$R?pzABLFw$Y`f7=xzt)@z_?;)Epn+Lx)qg_WfVoxv=f<>W48IBC+-YD6y27( zpKyORMT4^3mp7Z}+4|>y`-?wZesjAiXJ~GL$T6$F#Vs1`GTobRq-8k;qO&Jwx41#Im0@5 zdWnstSgSXe73K)$A=WiA1eFzR1TLfu0bq_`9lpJMzk9oJg$%Xr`+M=?<;BI~A1r#V zY6M}$`8&IA9sO$>9co(-mwWGR_(BY{9Muphk6?5- z)N5BqKK7GgG{((^7~$jaz?$PYyZvJwiop;V>+Zvy5xko@M*RSxZw^gRIr8Yb)_tD{ zLsXiOu2A7qdvbCL(ca(P93-SPR?qwpt=k(KKeU{YV1tjVONmx1q6a|iXeG8DEJ;6VeZ)>h_s7+&a$wi` zz_Z=$H*-xh`lsPBENpNm9P6qMC$I$*rj%-kN#D2^=jLM3X4M9q_#W<0u*cME(468C zaEHEh&BVM+V(mAPb4;|12}C$gV#?{e{JXAg)6Nw9?h=S&Yzwv^kqAgASpo%6XP!4cH0AA(!mXT`@JCg~NBr#EXop26QD z-lo@A+k-1utF5kq+)$wobTP1y5>O~(M7R1=`&{De!LHYZ3EwfiB7Jcnv0%eS|*yxb&MzmQ_`XM zf}A>o>{)6)+B-;xlz$Jb{U04R;K)c0E*3ZP$=y-XeZ;ws zYA=v^IRDkU&Z^C2X0#e`QtN;KxVTuq!LF{W5n2lnz6_scs5hvp3%qZ#cSMI;lm4 zk-wd5dl%Y00DC}$zZoOx`pDs`@vsQQh4q~(Jw#XqmF505jMhz{f$@*NuW)yF@<`l2 zYVpa#r(Vv{VQ3drbsomUE_&HqfkfR^xncd#Nk)x_^su}tY z58fdk#BL9Y)ZN;+b#3d8og7eHT}zlxi9gnxFo@`c?p3vKZasMS;Cql}>z_Y=#Ypol zBqOFJQ<3EIe6?D}^xLa#0X|>FK0UwAzZ(E0Y2B=~3r3;m9ezTIk9diM{5+KmAU3;F zIFFMolQ(o|o!637Wyo+k|2UJeXz$;f^w0e!R8&-h%^&zvJK3NR>+HD2W6 zs^FY^$8j8M0UI5mV;*7{F!*?25fUSbfx)FtpBKTId{}wQU`E6eX}TpkUjiVcd2xBQ z)hw*bV}iFRu5B%#hr(oGjZX=Zn3f5xmNYaIGya&8&HQj^Q8Um+_npIBe3x=+n-n{1 zI~sOSI0(|VI77F262T{5>ey|D742b7J)}eGs>%raBKTPDYjdmK)rTe=9{*(Uw`%*U(MkW$ae=eHiOTJbMbE(M=Q#TcH}CN7^+0&x>6pJ;4Wm5(GrZf}z#`$sGiDba zJfQsGw%<*$2c|}YjPhn0VUK8v1_xqjL_j%dz5JK;q_~L_0?AwKYx8$Hfd=z zCyhbDLw`Q=vkfudpWRNo5XAlceT zcAG)#SyiEO-R=UbS(pa^-n`k&*Yo+s0(DjIs%%qNHGtiVU%mY0ujiYu-|XI7+}t6q zr@{Q?qTaaZxo1N41}~m27GZFiWvIds&;pKdj&P0|)f$UAsvWW_FnZbDrh5BgGoR0Q zRTX0K*DqdHL3WwF-D&NI7Cf&*0AYp-*kwDs4b~Uy>NizYbph3N1t1F$APj3Q5z*9j zXfdKSx(IrGcSj^UX)IwKR=TOq1cVHx2L?wD&P^DEz4rGrT8_$1J?~fhQy}!{JrDO6 zj^KJ_g9ArqbmKWe;B-}v1RSHE>*Ml|{vsI!t=kD9tnYWNEf+(Cn1@wR>7)D!CnqP5 zPEUeI{=G1)A)|Mz_4_g?W9&6M!h(|QfOsqnmW;fW_(=KC{f`&}%c?2rjw2&|=M{KpZgSLI_DJU@cZ8CYcW{(kK9)3moZq5B z9hZ%x@k8!ik_&^eyJj^2C^+{)OIm@rVBDQP5?-{JJ-!E}#T6LOlk*tJbAV~f1yey3 zpRefE65AY%gs{z-R}@QHZFPo-NzWji<&_qd$I7yNv#TdEB7#oTQY8@<(%!P|Q<#cOeuk!-r zTPZmk-Eg842OVy*yGm^pOTso^5;$kd?ZIZ|T*q~H60h7c;j(w-cDg3$07lya64{xY zMbB|O4v8F;%xn{3-yZ51ZJ6neJV4LK#t{GLyw|s~82Mms-_d-hJ{a8f-0+7KhBF@{ zJKQ^nnh)h5Y)%0`FrW=)BmM(3MxTCU-(61+{j*_b3Jly0&Gt=<74lIzgcTo0U1Im) zd$jH%0-9#~?p?Hcwpz`$+byCMp8Y&RgxBAcH(U2(C9pD(vz#G9dE1QQzMoh;+n_;H zmR@9(8&M}9*-tUG8(umFb4CmTc(-V*t44WSMgWYQBbs{UKEj80ucK#Qef9INUgLG6 z;kYKw8z<%4q<43MjPgkYc++iJ&df@U0J}LRaw%=LV{}ORSxjn`&&Oy`9qy+^3aG31 zRj^**?FJ73xX|QRhX^oVFY2tCzYN29_~z?Pw%K*SX|u!TZT8|<>x;j?c=P6cmhF%M zPoaAU0c?J=$#zwUFgy&u3sIw9FJ2(1QPtX#S(D*m7_MKg=a?f1-qxGC-l4Xi4^RQ~ z`8?cY>-Bsw$3J9ms%#e;tv0a0dOfcK)NeD5&32p3`o;R?#rpS`Z^wQZwG&Mpz$SPb zmycjRHvliQc)B_cX&p&Ma74v1q-g8Px`R|df`|W&x{U{CPGejf9)sLHhPM70p}T$I zz|}iEs*MgD5%fb;yt56Jor4TH_*%~~U^fPJWl+1mAS=|kuj)Jh)1&*77N^3M@3DRY zIffN|Y@Xvod_;IDMjKK1^oxju4=d$gR8N@$oo;QAgXeCF^`8M}y)$b+qaj^+M$TAs@`JhT|!U)+! zw;U^H_k^@hB*9WUh-nNh8DOF~CW+IN)&KB6`oMM0%lI5I+jKYr`MNZ~c>!Q~4k9MU zop(twfGy|D$cybV_Ro{^>-3tzg+v_3E8u#|1V8o(T(BwRv!%}alX!9dd=)RZ-#{{$ z3UE$@<*TJ1Q*o8%`RL?GBL8Cb>YS4Q-H6$o`bA6t=jmmk%{t7bZo0P!eoU(*KF=AD zDFfsu-(ZV4Px*QameBrpNsQdd_M_ao zBj>vC;HZ0YB#F72X>4j?vZ8d4pkzDIWdq9frgN|EU<@txjya-f^h^LWdiFcNly3Gz zeV<%UkMg)nkB42HtQ9;5IZ7i;`B3?aTq4)Ek}ZBP-|5#2VG-ZS4&VHX_ z((LaV++ly$Oi!nXrYLXGOtl!}?(XiczB73#Q=H!2HK(W32AJx&Z=eBAG0~ff2F-Me zJ2ZEgPNGw@$){*e_tVoU?tp08Or}vYonku0zMLYuJDr~1HFaGFt5pD?{&?3kr_FM3wovQ`GboyAYror9m-RUGa2~LCkWIt<8FrD5_ad&rjcZvp>+AYS^64-Z>Y4CUw z{L^>;_vXK*>aJ>s@T&C?0CkHNqwgA3Yu^L_Rg3I>_Om~mx2US`Pej|cp69i#2iWfr z@PZHsy~US-ScFyf5x}><`8Iq1F%Y>-B2&IIZg%HBQ?0W9x+1#t-^M-T79`*cww7<%(k2N)yJ%DKekot#enCTooOqy9sq%mgSUQ$er^Y!f$eB) zfzii3pgnMN4uRH#=b>uRwrDGO-l(+}t$snvIa+x3TC2J@27s{NonS*R(0*3$pVzhr zJF34#Ymc@Ev@L2tv_J^a;zR(rKf(P8Cin!jzywf$QcCFmAQUix5)c3sSg~TIln{U- z7~Cxk7Epi!Ci)|)0|TrBaup!-I|P)nZ?G7Tx}^a^t4b9Z5Ks*Bex;z403d`JHU*#{ zln_t~f|8jaAxH=)p_BlGUaTI^g@O`x`Knu+5)9?&s?BaFU?L#mFP7`)D?}5PN+~E+ zLJ26PHxN)tD6_T7EL#joI-vyU1guJ>z{*j~n*BtNYLtQ!P{0I22#8inF#*v`L9kM+ z6qGHJvR=KiyJq%AbuSu>CE#2}0`P$e;t7awav~svQ2LN61t{p}j_UVAOoS2w5WY~# z?zB>nic48cAinsM_~}d(JCub2Bnk2A>C-=*{HYL-vp=d*feBE|vMkz!W^^Koyac4e zBr6MFAekivvk>y>;;BlL_uE3DT%0Fjmb@=^QWdM&>Q5I-E{Y6gUJ9ku)0vP^yRy(1 z>GM}l|Lpwf`~OQZiwWg~@+4AmlzcH;Oo}Yc^Y>+qur4%Ii zhnylx=nJJ($^V>Xe<-_(gHjOsWT_bbB7QZCp65jgmBDAFlu|-OLY1r_1t#W*4=x0^ zx~u@<+t((*L}Ovq{S^}kb5bW7TPt&G8b~2bSDofHNhoG8D?nc(<|bB32^K8W3H|YU z%W0`^DF74BC*`&Lp)|5@smvv>?`6Oznm}g_enE>^%tU|74kpM76R2+6%(j9h)C8m; zeEV1CBG1Zni&EO16%cwJC81gf05hPqhmN6?hOkO8AOwW@ODUO^Ac9g{nyXs~C`=kPN)VACA73mWW(rUfeS}B=JQ0`(vL_Ev5EGCc zk95ICDUja}bV`8|K!Ihyh5cC<_E&)k0D^D_5+9fV5;SoxrU?k74~YAfE8eEb6z^(6WA%qVi(GSoUPHlu`21S?VKgb*Phgb=fZnoMB&2n7H! zu{%gU#02W(fyeH|xhLd6j?v#4%D%4b7K#4&0Fyz_+k^7mav-7TIqSXAPV3xn&uf}y z+nhyDE>_=M;@$6VwJ5}TF?U3f6!UX3@-a^fgV1j)z8xC@OV;ir$>k zu+SyEGk14N+`^j~G4+{UXs37HH)Xl~5Is9XS(YW9J&Azw9m=Lp2cMz5y)m0TYk;yW zpG0W9saN9Ga^jIzL-*3{zSZ#zQEAe}k9-B=Our*Mb;mPiyX?)^c=_vf5Z0SFn;;vL zgaLpsT)YT^`2w2?AvRxcvZ~S+WWDeg2m^!xF8|B#!~gut`C_s8hc}hhB?J%9s3Cwr zXO{%P4jXH`fI2`phZcKe)$YIOl*G)o6`G9-7hzas6#~q|P{(&yVTiCoU5E4ai>4tr|Kp8wb4*eUD@H{{#JOE(^EGFK`4MLpHiPkXRU+d?dYb-%vkr zj)UV@=zwdkyHAcuX!rWkmy+Sd>s}J#9OM1T{iFLwpRk`|%3w0uX9D|VgLtj?mTxE@ z%1!_NpexGNZyIL8vLo`aSx`5n9WckA<5qdZBNO$(fdh#vjlFEym1SGt%3}tdU8Nr- zbiP9DxTsn_x69J*y2r=D5|~&JW@9h=uv|nQBkf2Z`fZv5q%tL7`k~5eexZyI$tgQRgrE@ z5MG)WV7yvAUnZ1tu>uv4lJoOqi9|b4ONx)T zljSSIDo?kFrCE`DK$t_LI`vqZIt~$ZB)a}kqdH*q4in!xslXv0oO4b&U)jWVBY01t zb7cIX)pV~gA&^mS*r*g9q|SAk1(yt!2c%;MwHd{>;B?!&XLRy#?Z44Eto2$UGHkKQ z5GA(R^z7t#!&)@ho>xE;Ox1Ei! z`J*hc??`#cDyn-qh&!x3&_vSQ4i^q>{O3&>2UJq7O5}kFwNeC;Wqi7t##$GuwsdC^x3ST}MBE=4%1~Po`+5 zm_~PZckrH_Ui{VkUtfFges>4#wF;wjq{NN0*yhxb&Uel9uEFVeefwrVolddG=^oMa z4tJ-x!?eM4+5pX6T~3-QPJug2Ck>iuG@YCV)3Jcrv60qoho@5n4eqAXJJsx)GMGG` z#=&WM_YoiKJ({MuYwmgm8r?SU(M<17?}ABy;B>N|oKBnlbh<}#f@yPi+MMeB+c(V= z)8-b_De!pu_@*rX@n2v6*WDjap)_~tuy#j4lx8?P0=TvOpa(C@KDOVt;g|ErVb}&u zt4;)3;X!y1aTu<>_~jg)xBWlTpIyAn-flPB3_x2W4B&~-6P_nLPqdnfMvH8-{fl4! z$NKxM{@8k=TVw0279jvnqvsHThsSYy(tf#EJob>aRgDvb@H8P=qpIQ6)>5y9(MJC) z{&K$l_Wk$m_w{-;4}pzWorv1|zO977Nws?XvnRRUXaDl;?pu6pk+lG@3K4n`Ek2@p|1n-IAn<+qv2EM- zW82nk+t#8!LH!YJi~0n0YqSh)$31uYjY_nhcDEZauU@F@2yKh@`0dOr5m9w1wB zjE!y`gj{t*wg;~@uV_BleRJz9qa(gOj7uOrXDQ5O+P|zxXo%K(fLw1eqN35F)ueI= zVLo(!f)hSz?-bg5rC?}goMTGo_gI5m3sKXyQb(%7%&4JoL=4 zo)aOI>PXFrfKq}L>rw)sFcGXI0Hug9d72P_>ongfH7UgxA|gVeN(e=QB$pZUVnzuj z09eucB2}$gBvAyC3eQ(6i4@Ty&yeyCLMawAnye;~K>1#AUP3@FW>l6%T9ipVyZG~e zpQoJukpJnQFTPkPRz<1GBIj+&h0G~JQBqMV;95YOf3cj2=#SfMmni`OMM|+Ckx&AZ z-(CNo1s5bDffMd74}yXq_{-(11gl-T1<53W0#xBERuuVwl5!_p+RW5#fQf))C}2W; z*#S^c69}V*GVGuL#KgRZoU(yav6&D+ntC*sx{~(hQ-HF+cK0kR2rh+!LV1mH*Ik4Y za8EOKhJr*9Ek&}Tm_$N=B21v5nRfdngaCZIGqU4ip=8f&vVtnXihtN9T8L_(heefyUB+7n=U;@%(RY!aC>tFJIM8SX;=e3<~Lc1`YyUne!&L)3h>hp+^YmWU#xWwbo= z{`PNH?>64M-!&cfJT$@U+32RTfh(cI`wkr6O27t}L}<`>W6S3E0(S7+rqDmNdDsb8c`Li9&(9bxk=Fx!`9r2Xq|ryiUj#@-3! z7UgW_%D(sIiP5B1KY@Y_j_RfL*XAjkQ6bGgw9)i6Mn;mu|ftk-yx9ZRV`BD~ec4{x*G#nW(Jg%xTYbr^<~ zF$k%gL=qE8I0sN?S%vC-RsHpRv8clhYRs_+s;b82=4)j3Q+hk*n6CrWm075}C4DY; zpgq%G%okae)m3I_W24Lt!+Ed+5LQ`MW3yRYtgEc9H#-|T=sHvMdmkJzeG6;1)v|-1 zp|zx_sv`^f|MC?a(;@eE(FdK8BVn{wKZn)eJXW2DbU2VucS`7?e7fiPLnm&=1?)P5 z{eeB!RCJ&v+97&Vyue7JQQ;os>hrt;r@Ww>}cj|VlbU2&kMTBHS0-~bAep`VikjF z%S=de&iyS`t7V?&+ZY$GmT5}YX_^oizUx@7-5$s`C6Q0(=jUJ)MSk&@=P_`d7Q7`X zV@4r)ON1h4&Y8I|%o)I20>|V_mJH-ctT{*CrdI_QWYoTW`;=aH96wL+d|PZmQq!`` zv1Uk#66R~y#LH4{G;k{KTnYi-Cpq90wTB=bbeA2g4Gd^Vd9122AQzdp=GbwL0oO;? zT#sDt*(4IOO~A%TdOO&W<3$u{FM(XjA~zzg4)rBEVyS>Op>{K6$P(VNr{0}ddxCpI znNGoOlM+ZPbEkrH18bQJ=SCd4`q=65U5srp zQg=x*`1+b&ofC-DTwAD+Ph5L^uv{8z=Z@)(j9YT_H~;hM6y7(#(`|VB5@mTe{P47Ag3Z?*n$w<>zQc%$ zo?@yA;M2X9K%Y+UFb$$f*-Q*E+)SHkbc*Q&UNgn?4$}!vEvG&O(CjgtP6rz?MKncp zI-T6rXqpm}U^MBmQPMkamNkT(e!jW{qN0w+5l7BHPh4JZh~MsnKq}B zU=N&3_tR#N$sTw6yVL2ZkxuWMW;&fdo<4s2-~QX{*MBJa(+S$vYdg(y;DtSf*A6tU zFv_e$de4Js+wa?K`?38{S0C&4M0j(w89vr^^=+NL`PkOgv;VMeM4P?MTC2Z3fw%tq zXMgthFFt;3v&&S|sGfi)!f@ez`Lp%*ZCY!hv38|&9smykVu&Ers@4{*=e1c~w;>(_ zCqRR?J@L@OgV(mL*P?BK7GVG{4Cg-!SM&L|Z@>STW$;3veKub_ZpF5(+VBKz=!Iy% z_ly#}f)->i){8G+e3^Y)ZQp;dH^Cf?4n2oK_&CI4FZR53xJ>J9-F}a{ZQFLSUWBXg zv3R|;v-L`f8_{&xGv2HWNjaQYH0k>!!L2$3-?WbzOGw*794Ke_$tA^1& zn-f>phZFZ64T~Rpr3b>E)#r@}LmUXLk4<(wps#ndKnpJ%2&20__5cV}t??o8+zN!F z>(HY75by%DEvgo=CqhpEZTpbOyKP%fw5>T-EzH98y#K_AxgWJB_xn4jd#g7ST8}%> zqG^6hOq3D=Y+n&jB@{z3RL)$Y7a&jElBE!2`86_3s-Zx7{=qCz{|5mmO1_}Q(?T);x;gNdbzNQA8&oaS{nJQDk(7La}8Ul`w)opN#ZRO@x?5 zi8w*2MGuO59icFSU;q;+!`rByv$Epsj*I%i96pwsS67EulV-9s+oc_sU40@;^NkZt zgA>Ihgy?v40kAwV$DNIISE-2*vl-163Aa!u3X^2T85)RGSDXRe} zXkMHFQUXGp=yzf=Aprp;l~l?Dl%<5?poy=zG zu4N?yQlzBfllQwFk}qZyaau~TD_JU@%x1Kj2ymWCQL;*Am`}&P{70p zXJI72Ju#^-#?I)*!D15u1trY=#`a(Jz%a)EumhJ+rDpObU?t&CXabs;l8FL@PXrLn zeCTt00!U#M?@DMnJ%I!XA($=4t@=ICKX3`97_4|#$RBo`mrz!|m1x$Q!3s2iQoTnq z`49`OaRy6=6J&rS(zfa&)Zo^eK?uwu zd=U|SA>sriz-$huxq}5DgtRrRi3M<)K^I2Ot*KyEO6iG*(ff+NwZMD}(__%dHiVG~ zlZeDjnBi7vf|(|yCaM=c>t825GfNYtlrugvl!7#;3{b2zGi?SH-6NuJeE14#+_z!d zKa{zk&A6>tMI_d%FRs&TE=yuoN}>cS7LlMN79vs9qEJxa98ksV)xYCEmRyzsq)wDl zN=OB%ASH0p*B;raVs6zG>14qY(Grn|)S}$|fPwa+$S9Z7 z6j1~iW9IJX=->Y$da}gj@AUg`OUvPoRn&(rZ;cyAV$xh1;{iReSiS{j%@iISNpZ(m zdk?aCQ7@A2U$PDvGvF5GZ5gfpAKKofM{+F95<3>|M&m~oP08!-(E^E?^nhifg$(P0 z9_53X(PT~yAXP&RwQ4m$uLSf`TF!sa@6fh@S>>V!m|TonnUH4T38;G*-zet(Hi~<5(<4gm~Zo`0D1SIg4W8 zC8F!7RWxnfqEY5{G2%Fm&SON;50}5azR|WGEpU0${PVN(3*fT3YR`ZcantDZLFM)w z$7iq4+7>rgH?eihR!(VgggA~P<2o0|QG~NNzEYcZrkU3Bvro^W_zE}8%{5xB%WWFO zFQfLiXs(CUemu+(1kkiitemqW6M{yS#M`uCW&~1d3>6j(6u+Fk@q>Av|OUIZ(fNjifx2OE`*gFb)D_30Wl0rF zpadZ`I$X(xA|QD~a8kEg_Yv|n3_TTsdl@o!M2_vFV%1sKIvf}Dp?PHAQ6M{3F2F3AEAJj) zuLdEEMTSG?hJ;Q!DT956iGE962HjvBDiE8JQD-h(?I&nD1P)nL0!Sfub$iq-;dYrdz_sAL?bQU9Ox;f}Xkbhr@Bfpim{bNPT2Ocg0L0p#ziY1=ZIl z_ip35O~R{Yxz!Cq$gUX-M(@njftff>NpfLtYHCJADY%juEhtUbrL?C37vM!jDREJ< zu=XU>w~>H=3LW(f&>q^-E7_?0q#t2iHC6_H0=Rfv{(adSJ4r}W-Rv&e{pYNj0O>| zf4F)5`aC+1ai!|$K#QBJYh`9erR!y_%+V2;+qC&V}-u8Id*h@h6YzZTs3H8 z6}PS5iX!E;r;@cB0CC$kh?^L(!rJi}n&$fE1~x{g1fEObSy6qZ26cPsc zq3^MbRJ4i(mCX=DAJ%d>7R#I%gL6M^>msd+J(JWgybor)J4V|o7p6OP@H_v)yFBI0nF z1WMJNx3f=b-v+GDYcLUd#6tN`Q<{ZBfTeBX;r-_X5$U817yS@3LMdgQ?{xrrsS|sZ zcdtSW-}K*BquK4aqLI!ZV%=ofF*F!PZ#5-^7?rxHHlogrfpmgXxFfG-O1AH-voVx9 zt1UpaqxbZ;QnLaz!Xhy_uW<>k64tBOMH@?3EV z;?x9ClSr9a5Ww1>mYZw?Qu?F9^A2FUORn}`mT!r zrC?LIx1tWuAdN?4D$IRPq0uw-KwO=<(r&vxdd!C>wmN>#+w1YWPuHi0)3AHc3HBtD zyQdwr$xMsbHn-WU)~KA6rL>05A^iMTtEL*XpZ4Mf(sNpUA*!BQV^iqcgR&qJDNC3p zOw~&5I)@mk=NHXz~GCRB@55b?AU{hCYkV%qAhmSrcgs;s!BZB8t=&#%FOHo%Md$EgD1$ zXSY$)Ad1e;&J5CvhU;zm96tQev}bXA-Nuc|@{VzRbB(6O4RjP^jOfz{Xqv05rfCo0 z&S(TbYW?mY1F#PgcNkhHLM1leX&hW>y*1zm{6#ai7!ia7;Xcg0 zI6^+~{2C=eEWh-lel(yV28k@q^RZapZjYD~J%%QunPzldMbeE)8^Jsyx=TYmz9a2{5D@B$Q@}erVABkECL8Pf5QOH$QX^)l3Wb)$0(bMGdS>Lm@ z*4b)#!_dtaBnK2aXHv(WI`&ZDiZ?UepL=~6jvvJ9z4Zc_z!B<|`2c!7v91nv3_y13 z9n~Vx86#zOuUE1@$|1lSX%QgVf&UKm2hlxcEskx9m9?Mo{4UfuhbcN#Trt@E1N!h0 z6%x4siHzTrOl~eZOu->^Ch@NEjJj{Ak>^mD07yOi1oDu%1IsWIRaMCKTHoz#Eu^#6 z4BOno+IF72uvZ?b)(nKs!%5^Qj6M!DTFj6IDDRZPo`s~rEOEj~Y)hbR15D}~Sr!C; z@XDv3KLDG3nA!go)b$1k6u!OR+`9sf!1OsMXtc~`= z{ysxe;}*TX8~0{U=1Rw+mhqst^(0AvK(|J2kmz3xq)(81UzSCU$xkL|B1EkNo=jY` zL9^NytTCK&<7L`eB;7>DA=t$x1{4}eL40+2_4;4Fe);qB>%X{a2T>sgamVM;`NjFw zU)CyVaIM0+e@1) zZIlu^KU`&d#LDw5LVOlm5rk4^m=Bx8?be5lO`|sAx@~~?Wpvg;X+iWT+ChoVqWJa8 z=B90L4xN@!>`!od;`sm|b-&p*HsaewmQ4??mAzc__vkPjQ;FkjHz7#>xnA0gg$dxM~! z4a_l9Dk|CMwyWHfGzW1}URKPSP@YU)98EXC(NA7HJ#C(vJ)ul! z{1!Tf2Ui#)L(AxX+(q#rScs1atA-~s4}xGEJrOEqW+Uu@P6Mfic)fEGypPqa^C37i z&4Tctv%6x(_};M*N9?C2?IYXnAhPa1KbpwiVR*5Jo^H*GuH4=3Jn%{G2Bu@vA4-MK zy|XoEQ~vp#+g8d$13d<(f;4*85S<6<*_w}Et!WA5z`EkfaY7_}H&Sz^&RLnI-}Rxa zm^$v#Fzs(gr1T*bmle!)?pM7CX-Wi^*0?ZqCun=;^L|xvzsPvl;m&BH6QD+E-^fhz zU=1L!UduLeudeIF1o5Fp@YCc0xVr`FdzXI3kD#9uB#DB~8~;1C#q0=r0G!MLBuU_^ zM-q*hli82abHJgZJz2@7u8|}sc>A{Bl=}e$SJIONsOR-;GjrJQ`X0&L@!h-@okN!Bi`rof`-Fgd( zqnGFL*~R(wRdaoLjX3^i|J9eDzj~Er8G#@e49R5$E>`8Y->zgWqv-kQXfkPjVtLRe zZewi<(L_3M4!CI$8K%=o0yHo%@+IKv-6%p7W8b>C*)wML;aeOxjfSRIH_chBsP7vM zTwATyjn1O@{3RMRzrObAXMb|y`h3Lkk9;zyU5H}e&)Y-*#+I+{=MZu8cXNwwK8T^4 zA%WgThsVq2e%r4$dmMB;R@U$YN5i+AgKWm(1A6E<8thiv=!4(j8O`&H=Z6l@A%`x8 z1`m0RVLBfL@Uff=ZT$E@^Nz5Y}$GCLpjxct!2zi9Q9EH*2OBgK?u^xXm zb|z%hTnFwe;n)g^%w$=I333PKPT7}GNNJjafl5~W9mP(S89+yQNGU3dp2sHe{VBFC zvM(+wS@PQ93p)3#+bd_+kmR#p}RBh+gejEf-#4@ z!w1Z&&De#WEje)X50VT?g3S!L)AX&59jtqmhx7A@1j%e;MG&)D5~XMFZc&!^THWwC z17;ij#{ezQlG(<6ZR5rs0(jimv_ciujm_+6c9hI#Gt3dFEW+78I7R+@cs#}|!tD46 z$4HKQS;o;ox1oQ%zsF2X2JV3wHk-|6Gs6ZC06)w&kDJ*slG(|-+mbgMY##3)@2wm~ z8GbxG;^7gq$IasmQ8YW6MNu?MaIAJ{Gn>seIGQOB?W5D^70+hh{P4ry{D=QAnM@ie z3xa8nZ>HAVw`o=08xY0DUe|cHNV?`+W^=$?YrN;`{d;( zpZtCvOae?cz%)*$>Dedoc^c)Plt29L=Cb(o_3QufPyXbO|M5Sb9>4sXHP+wpcbDaF zR@e2-ZdcPky}0=DpZw=l*Ioa%eA?i}WINeyvBh>81V9i>0bm7Z${@h|a>Fqw^NQYQzPw1@~LuW9Qvr7V{~#nIElvvP7UL4#9mkuimJyPY~F0?K+oIXz%EVqXd(>~{V`YN{<+2M;0L0iWo6 z#ADN|z2lL)Dznp&tv6>nIacl4+V%NZc{=Z<>?%yKV`z7cDW=A|lnB6N*J0O9ajbj! zI~9@pRb5&Wy!n)O{P=c zBPj_4njQo1xxTL})LRhkI)H1H-Nw83)lTn=>hU*D3A?WDFgczcPj?+FM~Eq=%vBAW zQbwSuHXk6+ly=%60;b!22OLvK$uR-wcDpHdyN-A0)cf6TN7LgSS2a&R6#|61KIUC_ zj9o60Znu*a&!@;=3PGZ-cR;1=t#`Z=^F&OKX*v~RzN>aM*E>u_LUg>lu6VcGCA3Ru zN&tQODQJo{>KoqSJwyIpDtO0#^EcP&JQ4G0RlhIm9WYI&yZJob@iB8%@9N!j{@L=g zT)h0vzh_K4hMeqnQ=*sjS%##>PVRnN@^5M`ce|SP>0K*_ZSgV_^LbIP>YEbU34t-0 zPG-Opo}Zs!j^g$RlZm=qcG&H@-R>Abxa%|jjvd2|Zl^D+W19r&WXUPRnsAC^^RKtV za4Z`zonoqv-E=ygPLt_WOsC0odOV#c5QM4vComP5&p~rwI>mOn+wBPItGj8a&;Kca z9jmK>raH_|U#C;;T0J$}29s82t$nA{-8UnM|id(^O28x%#)8n0!Zdm65=d zdbeYneFx{f`{>UxJcZQ`py`kPGI^fIJA=Qi&&baH4($(303FlZ$iUrjRqh8S?6=1I z(f7^c9q;P*?{Dh5+I5}s%|^{#-PK)9^J99MOuCM5>K$mO?mO>m9Czq;zM$X?001BW zNkl6r`|UM$J51-=Yo)hu zVaEh!2kgMi`X0F3VK=2+z3V7BPKatuu-jpZoeDF$+3mon*~wKT5Y3k_`M10)El033 z2WhGW=;lO57$R}*JUGU&@_Rn^tZ9bFyBlovu~jt~QE{TYHxiuJ^#+=kcDUNa6JR7+ zfcymaK(Lu_aF2SP1OV>q%|6>a&w>-+t>2M|`a{}f^UVPFn+I$XoFD*d)7?08wx{Qw z>wNA9`Q*HJ1*z|miSNZdCUMLj$g}7nW z{EB0=c>Cv9PtWw<{11QfM_+y^*ZAsJvQ!qB)DvwDHR`L}yCHj3~0{eugzYbEwnSp+%b;<7qrX2K$D?jsbFHg)i1r zJ4W0XYSh??DEHx5X-JxDv^T1~F>>S@XP$PW_3Wh&lDK98z5K?gaiTbGeY1-Z#(2=X z*dBQI0~+WbBl+lS643$2Xh#p-IO2+-%tNv0#yw-`w9yV(@?Og^;Nyqm(V~f(*fV|6 z!x^J#p3od0AMJL5in233OooV6@;$e;d&qk2^J9)!5Pp~2kis#|O9wu%!-3-odHKcg!I{WJ-2bII>8W#O;_z+Xk(`qv!Bk z<+jmqk_#=ANr*9>RzYH2=WEml&M8$-|=q<|nuhE%63n8><6XcjmnQV&uh5K~88D$;BLfoi>8S5iW2l}Lazf$+&C%R&IpdmQ8_n->ZtZ zg9f%DU(#mA+K$FaqXRqV9=k3ym3`oA2c#gPs;b;81tIWR4rW7Yubl%;UBzK$Zq}a0hV}X5+yI>r z0JqZ=WmTnVmZGXcLdT{7(Kp3cYAHcnFt0l=A`#kXoRoaqt3P3PAB%VCt)lZYRS9Mu`M8q8ANpK3hwII_%=OjU0`-XM(<}MjZIMh#`1OSR2c5jk8 zK!UjvR}>nV&gRIHQ$RU{ByKz5UN7Nb%OB?6pEHk~hUJ=1fCTm3zW;Tvq~7>rV00Vy zwT;=FtE;Qc!^22Lejr7S21v4j_MT8ECvvnLt&8IZ(C+E^dHWm!cm%fqo}cOYc?;aX zecwzP^oC~5)ARHD=kQPe^iRHAUR-`7SKpQn>tugR0hChy>Q`S~t``65&%Pw!fBn^0 zyZ3zbllaATgQjWXxVgd0Gqf)a0&@ixQLm!47`5L~g?1wY?o=rsZM!#ucUov^yEP?rR1JG_ zY5f25Gh)Iwu8Q`eziq6KIw$>&7QO+H z5GfdiP8Oz2q#{kZ?EPIrh5!U%{YI9BD#;5Fr$ikf534zpffLo%22w_^W6?KzmHiI&q2)6cUNP%QJ-W zQ*sV~F%jLfPH{tmyqclwBBbp~82}#}23Nu7pohps3EV3b>_Occ*7Fz%g8XET2h_eVrJO%jCDT8y%BeNvxgcu^(5DcgV0Y;@=cB3ynWj=&BQW%7D-q_R_6pp z4$$cx9yI#w^|%I}H2bV*{PY~Ye|}FO66qonLJ%{glx0~yF+YcR@qF}RGI@S}exk6s zyZ!QyE-seKfBV&Hy^_q-PwoBta7vrx!;iJ-@5+^B8az2S(JEVng%ZQ33}4P6{JR!$wO zm(G+;b<>z*VSO{=sBc63ASdh{fk%3L^ZT|7RuF#oUH;hDk0=kh@!rBHAu$+!)MJzuVe^dnAb zgXFc)*(z^GLh?{G14xNzGI{sVJrP(kfr&&1qy*+_Rje;QTVw*I48bVCpNTYukfmgV zU{v5`x&Wi(a!KS9$G#5#6mp_EL7<#T4%-tb^Z*^@=&j0V$l!X7YHSRg6|QElX*e7JXFfEE z)i}EwaegG%RAK~tSAccl80)6^k=8tx&vx%29XlE3?!igNc<4PvGc&7JLOxV`fR@tqY`i_Oq<~cHJ*TGRxG=D~-c+r=mC|(6N;M*~TncfYutA z_md-YOx1bMVv(oI3;?6-j1gZLrkacHD%Jl8CZs7+A}SdLstTlLvX)mCVgW^!doX+; z(C+5|-N+r%n>USJJATMg>_G62Z{af$=kcTw{<2-6yDH`Sk%&TY`*d;fUhrh0_{P?-rE5!RQ*ujulZzx;)iyk4!JpQn@9xS=&@&@^b{vj|Nb$7s)* zsEM1XX>PPb9W+L2jeqk9HtsV<^lzGR_rxv^_-YP=4t{Rk zuF(c@>}RYDLRqW}p0aSXr+NH@<_V9-$4A?32ZXAN-r7Zs9 zbs#$-#$F$fJA$@AuNNsT38$v$d6qN4r8{il{*z~*0pLSY7E3=9Pz?`9NMvLy3e~Du zk@PhOmx+RN{0fJE|tpQPrFxNiBCEh?*SW81)2_gcQ zRly9Xcw%OTlodoMNC@UaN2QSM=F+ueK^ci0%#sUc>irie{g?;y{sHOPT=KqQgLdHe zx4H8=jmEUJA{34qfPCuOiRb8igW-Y(*Xrbt5~X5&dhM!!>bV0QAvd$$%TCAc)V!OrE6mG95uiwp4?ilVBj z0EH|{B-{M z_x|+aOQLL5tXJz&mXf(50@73nS}qrV_CGDZ{`%|7)k@uCFD@3V6;_u8+lrEoFS50g z)DUU53PhKe>*aF!<;Air5r6cw7ylVT-&1J}DBgJBQ)01P>}q{`Xy}MW+JQL2Lz1z>@0zbh zu{~tkNji4jxc4JatOg{)-+}lZ!`>z@u|Ky)2I2sQR$~}>qty5_4*vwU`i*guJ!9WD z^yTPJbQl7tLp zi8ZqX30dR=MT0VM$@fbvv85X(Yx<$*=xPo2{uB&uW~bqEZZ$CMK1e1P<)kLd$^gEaWo zU(|qoGuTjj^vTt-E$Kn&|FalxZav zp}+4c5|R3>5w3>fa{V6De9|^xl-Y7ot{_)y5~050tU`>4n26Gl&>`iXMCgtC zhIgZGtcr-yq$^h(#u(nA^knbYfI>wOZ#)yY%{@?~-XOs^fgC6gx!M8Kz^0x9_kC30 zUTmOak8!USUXO`6YO4k@!jg?LT%O;)eLKHKga8h0t2q>~33v!{1LV)1IH46m|W5Sx#QO=miRz+cWanXb%gz>JA_0xej-2 zV?-VCOSRzt{=fVuU;eX;%hmew+pjAry^FDsYhZP`US2G}_{A5C#p0`9eUl0TuwIu| z`Du_cr|J?E88aB1>bZIkA6D!27hf#Wl*+O?f`X4K@L5yr4S=f~+mNT!&8^DOzPYhk zgFVTrq!Y~$(Y295U^j3gJ^X=jJhNSl=q3qz8eNZ6_8RQs#*o7*+8hQHw#^{RrqLnR zLvKO7z;*~%5u??EqinFv|2)v?aLywU-#>zrjt=}j{?T?!@)5hOf{{z{Hx3SV!L)Yi zbH_LGW{XXXSm~h;Vdw!~w^N$<3C&aYc=Y1v3D3{EbIu19dreB@MW-mO2aU0yWAv!L z9}1OIwf`LYaX;LH3=>Z{hE>>86w@e9*X*;xtmA3o3OYz80cG5__c@nlcD-2L6c6&~ znSt5u-bz!Ek|3*gwrGe)I6&qP3|_zXG5cHloD2Inn-H|f7er!R6pTtqT$f^zlPIb; zRbST+8Rc5i&+;r2C?!B7C1)9D8A(|w8Ls3)sJgHn93eUZt_q|b5fo04AW9)F2*mO` z*)b|Gt@QatM493O1*HUpR8~?-hDwV_2?SYCWkxF}N<&(!s<%DUSY_%^D5#WgtcRh0 zoGGV8N+{(U$wbJ_@sUIz60Fhu;p7gYvBLC61s>`&BzS>!W9Zz(aT*Uf=TL_On$>3M z5Qd7K-fGP@4fl*-HwO4a0uXjeC7@IusY2Wx5K;)0RA|U`o#3p>8tgCAnlb->0-Xm} zQRnn%lEu)S86B0(XCfapSvztiy1Fn5m3GP|hcHNZFpoUPzN()W>HSSJL6lYNlDYGA zG?FtAWmKXdP1APen_{_0iHJ+q;9ezm?o|u`&>|Fhw*G3x>;!Qu^$&MMSX?Y=AuhlB zw_J2onY(yON-xF|sK8}e0@=lqtAdM;bo6J(U?I}%XA2Ngq|^^cd|8Oa$h8rUT-|C6eXrixxR_q|H3lA}hVsKka(9oDDopIWkh`tU)!io zySQl)N3EkjY1$T%My^(gY<1twjTsy>GU^itqw$;u%?54UM^;B#!l75EK6_^59ybo= z(->ND$3CBGAR!c=jpoOoQ`dLd3av39q$8h-9w&VFLHmb39Q|k}drTiQMn%UMwZ|U5 z80nl8y}yl}lziyiZtRq%-^0hJ#}_Yl#|XCC>2hBXI(Vh)^>s8>06j<}d-qL8i1|SZ zk4BZy+><@L*N@2KfRb&yyPxJ@qqIy%;l65x!5sE&hkO_Wi9z-mSxuz3I|eNshU`9L zXB~QnVdq|#5`9R+F~E3g(^O}nBUj}tTjrT4ssdDk2^9)dlDmaS7j#j|HCH8tsUTuz z$#Pv#o~M#KWwczDa(ju3YHw&b|nIs%e63u0nCyqh4?Z<3jS91cdA=2HBd({5HjvJN@igQG z_0`}->I{v2JBO&YK-wZeCHXNYPUwPngQ7ZcNPtLLcEh#r?fBny8hx0Jh6B%plk=JeJ!}G ziq$$@2u3g1F?_wxMC6n$^YWXue6v;!p@W}nxmf%x|8{NBvpGLHx z%U@hv{_0!Rpu&VaTP!XXlB;t49T)ceQQg)u%@>^r<+{|v6ILUN7&wiL0t68vR1WZ# zxp0GPpeAFsf@khjM#3>L*9h`CfV;Q*p(KHWCjtv#vYMmMd~ za0qRYXSEHD+oWhM*&3&G(BK0{tCwLoEsi6x**_vvrTwU2<1ny3h@{6_2^H(yywoY_ zLk#U~y=!kbps2@xR7+y4eL40v)me+3ltjvu@cH@a`FS##Y>qH}v=v#a;uu#LbYtwZ z%L*T^VAGg*!&6<*$9bk6l`8+Z3cc#k0*UTG?^7Q?tMn%wKF~AShp%XxI@V=Phv(J< zkdh#gI`wZ3**bgK4R%`EeRA5JOjNQGsUYE1-s!L;gg=0oJJ%Y593B&)$rRDhpMw}Jw_6jGX!`l0}-)WC|Fx$@*E6zVoaR3K@XELxXES*$@Ef;tEzWrt$K2_Y!d zB5Dsor_AWM5)e#!)}*E_0)j!z>p>mk!##t_hCtzL_%;K3$Xn;D6VU)Y4`^xQFXjee z!b4irV{n78Ll87S>GleCY#VF2bF>Sg5gTGT!;s_)F1A#~^y~q1}LNSVo|NRxLi5+)&ANb5$20U z)fKX=Xs?{OTr8P+ovx5}isGx@6rU}Z%ZtV8a!tS@TU>m3u_`WC>q{z!426`8u1bHl zq?F|4TD!hjnVv@bf{4;ABS9h+sZgB`lvEYr?%@u21!Gb@j-G)U1(3`!$31Y`D?080AjwYv{BPfXU*FafmvL(wpGdTPZQ~%E zF*7m;heQDIQonhP&tHG~&;RK^`sVA^dc7V~bU9~srSi2<7VFEetK}jSnF|;CI+x)c zDMQ-+JC+F@u)-PzYxLZlNAahKTC_K~Zkih{rEU>LXHk6CT1AM-^)?C%mv6N@;vl}( z5s9?T-b)AgRpsUv`vcSXvD$m>lOIRbKL$g87=`ao&PLig-J{nS>B*kx*}8eeBeM$6 zMkZ=7Qk1dXgxDjYpO23wM|kmwrygEegDUr#&`0xj4jIE*1z~Q1bO2F&SQl#TKlTVI zHWaZ-0kI!2+#U9J?K`9hDM+9t`iwimU7jRBmlB1B%@;PIa19|rCCba?y6G~XT9K3mLVy`lM)kCrGRNCr9kdZ z;ka*aB9@YSf?j(?GeANBB;^|e!e}_d)F!`!2*QApODG@WX?sCdV%b=8> zhF^rEj0jYg1ufHTDY!%@Wu?8n3xUP*Vp-6-d{e4DQ}Q=)JqD)SP0fBIQT!+3LT?ig`{{ z+h2k?YRl@*gWQnENKn@s4TFOL3magwG2gmRFb7^;AW7zl+X#Q)y#N3p07*naRM}Uf z2Fka{5}eL(dy6|wdDj6FAE_#G_~C7dw;Lch_3-QF6n6@NBMIs`f;r|0Fi-9Q+}E{k zUc6Tl>iZgZ#qHa>yX+)5Jsm#I-`{OU(X(}T9+1%W z=0S-=>ST6;{QK{J^Y-oA1ZbK`^P-92c&NE-t@5vkp-eWS*uq1<(rtU$`U1Kxk^lVS z_4==Qb-B`a!vT8cYEQ<=1S$)@{I*;!GXbw`qn5Fj1%HETl}YAOa_{?6RY<{{E|y9^ zy`Jy{FPxsg1}f3oLr02*Z3k}1F%UPgHG5O2Ottt$=jWfEoyCn(6RQTiIM$hj$|pK@ zbpk3p+_1|)gywbh@+`&=&DGV-Z?7%>)>QX(d=tlKaU7jp|8Ua`bO+ir+7PSl0W{hU zMJp~U96_ZjxxH~$C4C_GWuRb24WS5iv zn98IVavb_p532Qf@$`h}BTVq1Na)TtryZBolCO1u6$SDEr0g1Kj0imRHDGfX_EyS1 z3qF+9?SIKI7!=y4N=hQfpx+*bGB#!B&f8J;E9A;8TI|)|DHH-BIVN+ozo!~DDt#hz zsOd(DJ$*C-p{zJ05<>HdooiXwg(FEbGz=Pcr$C(V5?C$r3lLf7 zO$+3TvIJxKS^g!_x>y&TWbN8gWob$|$pRHaq?CnJQddeAsiZ6$I_gZ*{goLLo zcZ`t93hC5LNeD9H9zlXVi$ro9GYmXBpj*OzAQAbTXwSnct+zRFed`-B`-qS-n?8R) z^yHj>ec2;)@I39o_YonAE!t=d-AjW#D61!g9`j0`dpOWLe5i<$QK^at_d*S@TByxMxO&!ET`*({zXr9d}YRA7hooDuR6=qfG>CP;9#uExubZ0th4Ys8~$j*$f@H#Ig%63i{j8sxUq z&)B#nNq}0z>!6or)DOT6L55@oyuyk7V2%0#b)6)r?`pVK7c)b78`q85d4idTs)1xS zul0)V&2|_BtNR`6&8&uk*SEMknV;0B+58mun;Q2zLQn+mci(-l2=yl* zd`h0?&rgUZ&(C0<48c_lG?67x6$*6B*&Gq7Zzy)%ynK1~{`vXMYE|{mQo~B6iUXmF zS>@InOASpVuL`;RB1Q^_Ufj+F~Vhy>uw@MDpF8s zn=hjC7&m{>T;1GU;l?oh3a={d#!b`QH0Pg3=bxWlUH%%aBKG6Ps7&J4&wJ4sHv>}L zOAgTovf0c0)5FnPuj_UQIvWgxA6_`4`hGNyfe!)bNEtu3+8%BcNyqMszAr~St{`fy z_}=Stb*bpsQPvo-OFXc!Ycz(A8W%6CnGb9iYV585=?OZBVN<}fHEw1euZ(`w5YGh&rLQLZpj)k+SjbV$RZVk?O1&Ce9Z*cc_YTU13oQ zA_2$_;G&`sX%@01)0RafLda605F%%WEDJDKdb?AFa+R4uWt<5ZT&_#mdy+$ll)*(& zcIrmU(ml`vB&iPt`^p%berBo#%q-~#@%bTeUG_iqIQDfLj< z4fX8v+(PHQj+y&iq7X#Pl{JDPDE|`M{@NXc%Y)(38V(S5#uwU_T{_o;!zzeF@7`c@ z>O75yl_L=iWY=aqc@NNX*T3$0hlD=2>~hbxAmhl!Ny`H|yKm0H58b&G8>!a5i%+Oj z9Ja~LwW=iR1D&R2RcRer->jL2sQNvng#dvihapv$Ym*2hsJFS`)i*1ay!@jjtw^pa zJ^qrJmHb9Hw%^{lMCOpCDuqW&+5twnF2!>3jl3+&HHtx_GC~mL0)(Pi106vyB*2vC zNRd%al&!jNQR<0#3xYs}VkMd1R8{3jpxHgS*lLY);r z&?DnJ;I7oB9-E$TMgrVgblPu2f&{Msy#&-ia+)AXlDo3Uw>6R)b$xe=yW2bnkZexR z=cl;8y{hZ`#3(H0#rSx8J=Tc1ap2t;|9! zunrQ;WrH+Eya0fB;y0B=u~GY4 zDs)6$+C*pP&kR|X4$M`>L!?9(7fZ^pUX{g)xGHV4AXh1+;B{G+VtFCfWmOh_qkLs% zl9l68Wzh4*mrFtP&1y9PznHveJ(#7UOd5;r9G8)%b(JhJ`Yu8=h~t~4`TX_y&o5qI zHCI3U@ayXs}3SoHn$^nCPU0w@ga z0y$qc>`^X`7MLZ`xNkH*AkQ6Gg7!hZHezq!S8L~@752Fbx53{Bn-mg6j=i{W7iH6- z;0WH^Os(b(4SLQsCE6X7Wp-qg6N(1b&s}N3ioPL)9?KqbB>_ss-vK=nd4+zBS=e#$ z(n<%bhjqH3`Y)}E^+F)eg_N1BD%EIclc*VTB{`=wrA!cml*v{{f)_-RR0|ixLR4I_ ztYpeUXQr@(%)3wsR9Z@-B)45rNreuJqO7DcAP80Y7hob5sgRZSWv+C^m&iDgsbIo& zQTBVGwL0t)%rs&=9QM6sI(1s>qgfUVg<3jhNt}ORy5^rc?3Vi7K$PJ%A%q8{LzQvk zCUguvzIxor{&Cmza0MQ@GMGo_z&zqt?P`T>sG*9#>z!KA<6Un7y}m^oBYN&HZql5Z zT@F+n23)F%Cx=5plH;nUP%b$t8t&!W<}y<{Xd81)umYD(8zb&(JUmCrVZ;;l29?x9 zKKAv{%4G-|L%WR&A<%^giE;{4=vsssZCxHDTwL|F)tc9NN8mMuYyG-U435iux5wp`|7 zQOH7-qa;g!7TIFCytv4-JY`fBzj?DNtAed3pVlQ2K{$dRE8HKPJC02sC=7Kb4(NEZ zc^d?;aE|)!ZC!7YRZz|xCyKa z+@{8@HSVY#y|u#A^-ST?66k|kdb1A=qEAmX^1iQ=IiM`1?-Za_*meUIj|e2irpDbv za#x?8pZxS^b$xsL{gtAjb+cem+}-20-fXgy;51R~ljUtaNAPfm+q*k$@ob%*9gwX5 zQY$){Cs~3T^=*w=lDzuq?f2im{r>-e#`zoIE>XWH0B|x-P|s^%695S6&87~Nq+GMI zllXbkOePjR_s}_V)UjIekP4xae%$+`zG%ea;unk6YQ4Nz6l-a%ob~e+0F#tJj*Bm{ zZ@!Y1$0Sw5yKbsqUM!c(i~RC(_1EjaK7Nr53DjQB+q6yJhj-(V>00UC#->%UMbkFt zpT1P+`SSAD%}whdF};xME1OSI+*#!gF# zOSkYIRvnEQLpaco4mPQeUS#QQGCPoHi0C^YP4nDx&tqhygQ52rH1=g8PIIH4nRHt2 z?8G-RciIwm4?+zq@*a{NiF8p2VxTtBJyjuhye`*SS_zQ}N(-q}E^Ko@RJ1fRRY(^i z&BBa`C4&f`Ez|)l2qL4jWJV>4@(@Z>!QhV4G!1j+H}Ixvfb6QOWCn>eRn>WxBtWT< zm6C^chPBGfJfIUI1*niEJQh&_CXsshh=#NPClO_hnfRBC4{b>AUj+!2ubRr?s$%O*EvC1RHj5522n z?^b~x;+bn+U9W6v7wkrZurJ^w?Q=os%FgH$>}>{wR0yT$pv>$=Y6t`YVgeI8bHD0x zjbAR7UtWCs)i-IXoJ|JJ!4}$^w$qS0W^~;bX}*Ipe$FsW-eIdi;JIq`Ne089FpH$%8n`QR%^Mg7$I!zvQnPuGKtZ~ zguY6h?WEPaQC0R@IXX`g9PjWCUx5<5yW4CYG26^A!_f=?k^r;W{e68~-(qu%Aphha zUYz~(XY=F})bG$<W5k*fd_168}MUYa=Uq8K0d0kx%=DqIQ`_^-@dzj^X75$s9m$v&m-^%9N`Gq*xi^N z{a%Xn@fh{{x_&(V{L4*U|6kw!`Q~=x>OMBW43F3x&1aZBY-Y#x=_5`bA5M>svm@k5 z@JaN^WAu2(kI%qQ5KM!BgWx#`089WxQ9PY)x4^dTVc9mocKe^41uw+-s;cK~)B z0PKJ%;dobLvYXSqxRKZYPg!>abl3p^rq~fBB>wQf$S=S7%j0SHpMAQhtFC6A5~hTm z8`6`eR!+LO_~Oeyx>)^Y{g?m#yW&IcTKYmwq`c6-D10)22%iSg#Y$mT(t4K|NH;^%XbPrx4;&0jNm*9rqiI^ zZUZ!Bi%%x6fB*M?_uIDl-8&$FTH1EIZMWO@-Ru0koo@dMe}#8Vb7RmmfOs2EJ~_+J z5Cju6%{!pQwB5Gvw(-j#`u($ae|3Wf2!Lh_vx&iU&wXYKZ1pc5w4Mf-?m_J>unmB~ zmMhe@0`W8mroc47cDuz^eJ%(zdTz}+91tFu|93ZKJ9R+nbbLGezYn122G|0D{et|1V|l_ZvBO?}>eC zieDDL#gMC_r0Pu-W?FsK_B3YXUJqh&1GIb+VI(EHIDB+vYicNAkFDK@eac z3}h2v5!^+_L42=guyGJga3{0sh8rG5>T#+zQzenIj>s=Xo|?|XIs8>s>hUcI-BMMN zJR}dv&-t9s_wylWKtq$g6aZ)twJ?Ql|A=T!)pJ5a%*vp(m@R4zZC(%!4XA3E30W$|YLO}MAI8-eH zvFiska`Tq14;`D`BakMDR`yE(J9VZpo9*``&$Y@$L-JddYptsFwxJ-K+mby?V%y1J zt(9p`)c|{}$ea^x4loEr4s^ZOS~EESsazcBNf-pg;~)rwNJ~#cpoKJnY!6UM>z<=D zpr8c{C8BcxM4BTwtdZxsbfC4;xubzncpPYQ@`ci@859Pglp0EDEl$AW?>!lh#~cM1 z6Eo>tmWd?F?1ct`F@GLM%FdTxTsRym?lL-OXVRke*AV6y(w0;5#9fH;b z5I77pJAi}G0fE388gdI|oZK8}4SfsIAZ;#wZ4Z&7kwbLVqdaJUp|!dE9CK+p1luj` z)yzQM6b&IT0D_qB5VQuf{Zs=C(rbHeKeTU>w$~#&WcIi9;{guH+_W5!!vt!^^aR+0 zK=p|scp5or$E;b~`xH^tCMFQu^QQI2xP-t0A?OfH2#L9L97p$h8bm}yK^R6nA!aQ- zK+~9)UoFgOf(FJOKO6^#<7gV?bET^bU27^C)5G!0&tGVV)^Bl|;M7Ag2TYonG_*s) z@*s+sAUfAXx-5}9fF=bb(6w}&fw9Mv2aMkQZ%%cNU>rsdrVyoc0tN|@rd*Ut7BUwG zzyG73fB3Us{5-<&%hNAUo_+rRygXYZbJ24V`v}OD$|cEfRj%fVS}3(pYOd7FTqTJt z6BV1zLNu!HTw06mA|Pfm=f`6L90UPSVD<%`{tSDM@Z#6XTH4)&2ycu%TyX<84BkEt zg9)H8zp#3XqQfggRi%V$Z1PP+#@0)K@i)hyaR^nLX z5Il(x&miDYRj--=kdsf&n9oEcu>mR7Wi$ekWO{rANIZ{E&*sNR$45UuCc-zgJtjRZ`b9OOYab_uYeoclP0@i)EIj3#9(g_YcPV z{&0V}TweV3GEGe`Uk&221AiaG<+F>6g+(rMJkZB559tde6k+fnN} znk4Y;LXoU{fbI!%@9z8%i_FTPU%k=qbx3IDj*!D^)5I0sTTi-5-b{tceOhI?N5s*h zKn{BV0x4Yge5{0 zL&WHWD`V_=EC5f~iy|I@C5I$AkMbz;qR5LSkvukyF)C2b^Jp@Wvw168jU{0oO{1d; zMC5EP07oM}nn*H|(=%zp%sEFa5Fm*nZ#0U`ahzh*R@%pLB5?vqYOYOMCd`5vSDEu7 zabu9zn1i>DW0Sm%zvXL9?(DVW1$kZb$+alGDMDzO#k7Lkj4Ze>=Wc#brRw<^X2L(`d>ffEPsx1PNE< zZguPOfQY?_=clpcV0iO+JdGw(p3Fsn7*P%Z5=bJ4hesd2|KVc~I6XZ(Jv+_g#P-?T zcvDKNb|v4&^CzZL#yNAs>_r}rB97W~Gz=bj#-hIAZ2+Js@Wl%}{Q=(o8D5+KN)=VU zh&v75J`Sx_voUyHL$t+K=v(>Xtu@lbqPRdYczOV(jJSF26>J5e1~-QrABDh;!L?Qu z5vbN;=QnqkSC5W=05`Zi{{mIAIG|=X0A>J!y+^7jik2N7HiXb?`QSkjsH+)v9}S*9 zJ^%HuXXode=(#4*!wo;}`XKIx!CxFa`o~Y7UZ|@t&Sx*Ku4b3#g;D_k_020Fvuf!U zCi1bky@kkOG>S1xYOO_*7@;#Nqq!}eWQ4=RD4xfOBoLgOoJ`Ip)1&E64yR{lk;GL; zV~m)2!bj7|9P`spPv-HwhhG1Uu!dJd3@cmY3_gDP(_?=h7Z(@l$xuzrJorgNV?3H+0x&KzrXIE z?2r8l)z*P4Lu8rn`@;i&jQt_}i)@)LyI45|(#-e$blJ{2N$a4Ns=#dxgr=1>-Nw+y z2fhuxZlJ{4^y41&M!F$OPFt?nuZPZUve|!4qlViz>2I#C-IO|Ly$*!&zeT0}ZNPuH zZKwj^)vNj)W5=u6P4#sO!trc6n(!zZC6yTmk2nF~$vl=>0x+f?Ml2AFqUleVPv`TqnNdob z3~-adkR;NUeAmUNQRKzud-Zd<9=xzHA|rE-jkA)h9pjcO;@=K5w}wj{F)_Clw6#c~ zfwhs>5;aNNuDhzcYN;Qj^1x{-VXb`GSiH1RYd2TkcC#8$Hd=M!siGRR7I`3HmPj z{i3+)Uw(^_-3d3P`H6-kBbE891{S544 z10!sJ>#TrVbsu0I)VTQ$7{CfP?&=Q^3@{kf57t^EvI5W_U{zQ_#{h#>adUTmzW451 zgVEmg*Iy1$s6jQkH%Oj*pI}52KUco-X2-X0lpI zGJp9JK@de0J`BfEIG%>%hZK$pz}ea7FMjtsB}uoU!zKRTF>$IIn4Qjm+RET>bycR7qEUT%17eG29e`kMKqP#9kAT2Yv zB}$*tvfT0g{T=`L^5uL!OD{590~xY3CAjF7JMZrFN;jP^n|VyDYHAE4S}QKv@o%=m3?A3 zfYz0s1RHA>v?U}UI0OO-H9CiCdK8_RSgp-!HA$^+Ku>E;RIQcj)oOs5i72pt*^N4O zrJ9T$z$!bs?WDGR#1YA%9jl74hl^E&u=^07*naR7sxXP7;PZV$PMyMU5h2 z8uheks|Ls+gdB`V2Z_ene3s`r;wd9QS!$g-=;d0QwgrI`J{(JqWWLa3j$|)R7Lq5D z~2pb#N5Gf_yyH8b=Lx!%Z4YB9LYxvRAy76V%shOU^~iM4B{c-E3O7ZWY^Z zdkoT~ODE5j*n=(_w>qCIC}^^G4F)4b^l-dbsKsY5If_VYGKv+4$pL}wwwXC(tu>Pd z7^S_}DU~ZYU=9&zXvc&?YJdq$h(ajBTtkC6LKI>e@nquA0}&k>Nou0TJpIK#_{9g~ z@h6{t^6BR%XDU|uR#{=1=L2x&ZLSXZZ17;0Hg$)n(ugLICIIRbqCPLRjZ?tB%N_O&14Sh~kE!HsJE^@@inx zx^KR%JKwa(=B*TUy%GgXUF=R=rEq=~)B=j)=JH>k?EUyyJ$-ul#TS99+a4g?!|WXQ zh&MWIF90`i0jQ#YyZhnK?rw_n&wdS6+{>T`>r#*ojUDV6H3)z!brl4G3wOFZ{fmP~ zfAPJiUtC;#c7A?-ettE-dR2Ur`Mn-`HHv!q{P}6b$H#|~#MVq>1O`iD)fbyy1BcVY zqoc!Dq|&?DX`ko~vWD3k7;W|BW|#b+_|74CleS2gk<`pFMl|{N!Tjx1EF6 zEku?VX_{U9@E^Sc96bN)XJ$>yizP0QWwlF&58&ci_CKWm%23#iiMBt)(9f1z5*ioF zbU(}dVdV}zY;sDL%f)iJNYgd9V;?@SKLmy*E_{Q5t*z?PM$|EEOu5_G*l&~=uNNhx z*;@2W>ThUs+I;XmVchHTknFW|GPcvw={ELy&CG5~-eOe{cl!6;s=ZJCTah z3gc)sD^mbkcHYXkG4SRJxo;2zPY5Ur(btT?f+uPXYZC;0_Ld=ua1-E7}vf24w z+r=AleIrbz&5GA^HZA^D)|~+vZAU%%mW#mKxF)QLc)JU9(l5D|0!i~BuMKTvy+?U# zN$Qm|qCj#M7*5vAD^w{%wJ>Bfneb>dKl!YRo#YMGi)W*MAXc5z7;XcMB(YZBj0r}< z5Sdo~deSP#ZTt%(bJfQH^5|$X{rU8eG5`3}Pv^539!u`gJYf`qx7Y1}*N{HZQ==05T|0)GW1YYWvLB1}oh4F#-laCZ@V@ z0HA;86u6t;?md3%_M76)2Cf9t>7KeNirX#X4Y#3`Rin-54@_0z-hc292fLFOAOBBk zcH8XW%9a^64Eg{Ab9e>-(074gFu(u-!qLtk7`6{paal-DzP|qYVx@Z5mv8Uxz4!Jz zfA7ItgPnfg2}-43t@l^9=|EY4Q;py4u zr>Cb|I6G5~U<##7@emlGes9%(rtpZxy$=f5AqMOkKsdoD{$ z+L}=rQoto2+2VRJ&%S%S1H$qmGi#fE$46FXX+^TTfQxd8vaB#%2@G-Y{prDX4wlce zdal;^w4~TZ$*=N@%%XLQ0Mcs4^eUJ-s z;lp>~x~}UE-C;$@wrT}kcL>8LQ;Bj-^-)$1A0<#CEmK=XShlENG>r1FT{+t2m(gXE z+pKeQ)~gl!Sf`?K&w4uOc?i%3DQ^FyvMe`9=(@O&;J4}sw=mGCIQM$<-KKZzCCiFv z&+taSXKoukX9YN~s)d}*&Rnm|sjC9Dc9^IkU%u^Sco*ZPq&wu$>*x!^9_b3VFmXWK zBd~U;#RRt&aY#c$_lQbZ64cOe(nimci>@l`I<3@z(~!2UUDsN(Lqy~Va;jQyN$0vH zx*?l4NOEn7Z^x7=Yppdo1Te^MgBe6zw@N$GUXNjN;1~gkhC?8#p8uvcu_;Ds?UC*f zkwoOcSwG97B+S+K_x4KsvhOMV{F3KVO@WCVs144ivIgu!(M0BnpqI$$k zQI9xQh~u1Pr14ni5n@Lxog@O%xhCe2iItL^zz&7uK!*TpD2-b{Dj}`IdMP~a1@M#Xv)KoC?Kg$QC)v_AK7fd zif&XH0&VIIsg|LJ>_9sN2h2>NN9+(YF`Gg?035Pr(QxT-R=_aCzFw(f1Cgj~{Z6h?$HxHC2n7GZ~nJiqnB%?b^pyb z-^4Tk3Jii^`eg9n-w)N*&6j_Jum5mY$YAOMD+?ft%>ua_0}T6(*y1k0-C!CZ>_a6T z$wh@L2OW*a>b{>~(8oc5Y=Eq_)!_gGKoFp?!jK!R2IwOw21WnQw57lw1YcW--v|1D zg8}-36>jdXZ~K$o>ns}-#r|}9b5q=2o!_I{*pPK2Fs*y*{U7W+esKQrU#jyfYtK>3 zH~L-Pd0_M^eG8!b2nGXS5QG@*JwV^VUD5o&{-Tu1dMmZkUtfP6?u73>e)H+0x8C}@ zyF7Gm?o=kL9x!rU(fZ5Z|DHoSIy%%uWujRlhY;u5CS!pZ52MM$_r8DlFgQJZ@#5?h z%#$#Dcz76$$E>vi%*-oMa~taQdd?ezelIun2OZ6>L0cur$9w={U=ZGAnDl3hO>$d?|)Q|A5~8 z;X6Cm?(=6aD~r6c24p@^7UgI}`#b(MQ2IUe;1*@2A}R4l0I>g>*Zy$--Ep==`uio; zMjHTJ->;#w!Oc7S?v4-N++T%qZ*=6z{B-4G>)gmqDe z@$l%XCps9qZ0@9KhPH&H?84}+BgJ|Jev8Al1DYXxLi@~?##5u!l&pdMa5n*ThOX|T zEY}qz!>Wr=1LxfifF|@`_3HV}H}K6j=CX#?)pOqIVCW46g#)d7MD26^dgp>$(ap2I zwSjMag$6o<0)QB79)TLY7A$USNJu*xx~FwcR8}<6tw^qQu5Xnzpjp;5Dg=fDBCDa$ z#+AV8EXp1j=ouud;b=f3*BzBeHCL?LQ}2}#hbYN~9VVC-LOW&*VkeL*C5hE(P)^Nr zNh$`l?m65!_6~YI$AJ302R7;&htLC%n+-A% zzySepLW8G3>_jSek~jyn187k_a>l`fh$0GE6GMkuj~t>~Jy)Vg1Ed2Dog>k));iDx z-Gc)}fHstKPY~w{v53|Z1VlYOi*J>Pk{r}yvfdK9QRC#Al!m?)1u7+mXsr^BoT*3T z5Ic?&1x^sqFeDv7S7s=+QlK+Z(aU5INd-#ndVTavEq?<5qiabv4GIb$G)d z-Dn`1;Jrq%pzj+5(?)QNZd+#3Wr0b1vh zE4L2g>>$l0hsu1T)of}FM~oD$_AMbIYu&>JUNhMft~;3699xGyhaB^L4<6WYwBtZK z@Eq0-!O?K+;6M{O3?}B%$@9Fz(Au%%fY2FD#=(P7&GlC&XOky~@Bi%h{rBJh+3|bt zJ$~}N!zV`%A3u5W@cT~=A0AFc)XPQ8sQL{Na)P4~T1_2+y?{An5`q}OE|SC=!p7n# z7ijG{`XNt$bnx(lhr#>oOyD#(gf04m%1mq95R7O0a~N~=9_N!R^P(aWh7;n2i27L@x?PmAwF&V6in+FfRv-h28Q5372)%7pO zs>L9$l@2Ok@aP9W*quK5;xB)FJHP5U;gg4tr$>hmA5I=l zALv9al#r2S_ImwZueXK6tZ7*nWqI)Z@xdei|YT#E2xFx|) zudm178GmPba4}!@(sFr`4X6IjcSmJfxEYnGq_(BSR{lP{`{Q>fJJXZj%x8aG`mXP~ zu7Rz-@4IjT*WYmq?2P@PZ&WVSD@(XpSsDs25cgWqLp}#{e$RCnhn)VTf=3izdKyy1KcOUp`5U6xy* ztu>OvcJ>n#DNXb_p*F}HcMl!ecZ zd9q3m><~c{z*VLlW0EfLa40HAfP|q0UG( z*BghzshdJ@z!5xaKW0ei_WZu%knWWr2gq}!k>}I{JdT2B5>3ZE1_chW1}7?CERsYt zRM{gLk3uGhGK>}kTI-vDz+MzE2Lz48AsqmQ^k)JS3+()!(mF|0@>K%#IEdtTT5IQ) z60Jm3u0#>@!-rF?OQn<{*`o(z4$VW{2@T^5CiKW?G$q$iT3d)MqD7G?y3MuI(+->- z_c#ng3bcscpjx-d3II(NQEQ+5#sN>XXssy>zzosVm7ptFSLvK9vXzN7Y3Lkqz!fL0 zAtKP4i9is6)}pyGh18Xx*?K&R9lEebbE40a=fT?rEQAL@WxqWNMs9U76uHDT%kVEz?de(qW>kagbddS~0z3b?c zYv0FaABZb4zxCy$7S~SJa?ogVXv-koB4z>uW{~SZgEW&vWX8k};4nE_>ySN7j?oka z#6c7RPN{TH%vhM1C>T9JM7L*9bNSKx-~agsfBwVhd*ybJlC>cxx2Y*yxq zo;;lXgX2RC`Ky;ntQ4af>pNuT8W`lUi85k-cJ|fplma+p3IS$>L=PwY;K5ieast9Ii~weu1oSWprvZmdOpbQ)TxpFE z&``SRan$XDPD}ez(*|0j!q8^sum9#dZwBEbxQ}s*yRZHY)YrDm4;bJE#T|+}LoIiI zs)uPY=x<1vi>tfA>Ta!=u=%vWpa2T2rml0>hgwxVm+>-o@4=9JQQf(074g$L>SXA2_|Na8`qUh3&CYPzACAS%H3mRe{X> zyHdAvxmKc_RqxSG@ZO`hCU5QD^_`omTix$_z24&Mn=cm&4KU>tAPgvs7!gsRHRSUb z&yr;EljGx`{p`=j(KMOUVy-^_Y<~7)0R`&e$>HPU<0DNxfBCXlz2UmOF1&K#yC_Te z=1(7RQKsL0@8Dv#ync3FsSVcrkzIes9~}(+9ZJ(4N@PaY0XIv_;SP(xOI&MUln)dJAX{97B_Z9KiS z7HywHz!pT3*KpF#A{%lk*J!yBLld;X(a?m(P>yWIL}M!3zAY0`1Z)CFHfFWD(`XSi z7=s*W2XL4jYNk_3S5M=nicr_&aD|~6Y*CSEbG^TU^%B0eE?dV^(^0h}EiBQgjo)s4 zoGZ)ib;QGVU_t~qWXr$I;6Ujv_pBKX8G^hTQotgxkXj6Mo~vqvp#hA%fSD=cDL)9q zD4-FbZ$&Gua+N2NLu*5==ExJJpvsURMB$V}=Fo7iNJJ79=SmcmhU7{);2w$AItV$O zJYa{Rb&s@BU#R$Y7;rF-bfV`;t{r9OD-46$E1hu=_Q-+KWB@Y=1Ti!!8{GsmbI1Wg zhp7jMq24vvF;$N`%!LfGZ}V%yh_oZRyca;*6Vt{78dX2nS`4$VrAOv0N>v3{8%9W_ ze%2arEICaM$Z*mX4XQN*LS{7Bl%(mp$dqlJs<{H#=JVy1TEe?u{>v>Wth+y!fVR9c zca$9KK%3h7ih7b|%{sobnC+syO)iq0cHytxKl{)or&XW}1E~oP$l!J7o}DA!N}Sj8 zKkdORf$dyr(EMo#2B zpdbpz}Z!L~DZ9qE!!Yn0p`mlYa{AVRi|ecgykGHG7+-fI-7dyXzY0 z0Iyp?5LjqBnC{|6ZC2o|tt+UpK)9_!Z#QWCr`x%KZBD$!BNu^-FmMm{K2w*UefHVw zN(R@7x?uO|+aZGUFFwOnWrbI7vGSp=e{WY0h5-<|E)ck|`Gw{<48j4-yFuUvs@S&O z_K|Z30fN2h?(Xgsz>AC7Uw!f7;>E=xU9Gm}TG}w#7y=j$eZcqq{e2%um&>#R{?cq~iCdbb8T{dJ==-oWc3GM>HG|nQO&9Qe z6FHf-R?~G#&MNc_<7#K43b(sK-&cO;-%~ZX{hPy%@pIFpZ2N+pB1j*oqZ>Ql9{S^L zb%3p1Z3HcAb&G2yknM6qyn&umz5x`tyE6m)S8z*wvssbmHN{4?11qmvwAra`Q#HG_ zDsbH@RB~x&^EI3Eti>(!=(Wbnre`g|~h$jMJ;@!j$bw{8z$^+!ib{Cn&yfrj*G?EY*}M9 z0Ry8cqQgS~ayCyOVx!I>v2etPKRFb^{Ij{3SVBp1TfYPdqG%*dxuhvlG@iMhNZwcj za)Tz5*xZ&!9=PT0EP}ZW9kxz+0*TQU6W_~5H=)klq-58{QrwE&YdI2k4WPSM2e<2M z8zaaq9nkA^wAv1wy^R%d$Cz!c7j1OCuEqG;7dAY|xji7o{b7eylk<(f-*#JMW)G6z zbHhN(_x-+2wAv@z9UNQsfJTPNY)a-fuEb_18zVe6{%@YNT2pFKEP2xHr>3TNTJ4ebU~g>vWaQZ- zasbhEB$9t}HanXo@mvy9&YR5IR~j>W9w)hU69(+HU}|jhstPw6dA$!l_@_`;8%7uk zMHl?K?JSgzsKc%Qbb~($LkBI3Xl1JeTgou=b`|M(XV zPyYI3ago6Q#ugZQ=cfno(|6xFNHaYD>*tGQinQ^d7{d48_22zR@8BZ)KYw#!Hu{h<%+?{9#!w2FhSz-hKbnr6#1O|i@}Y#1u1CR=-G zfS}*NR`~n-fS;ymnk}oilP1V}9a^SHk?s5Y{{Aq{mRXuD(nY&q5eBj^v0T(99a&f1 z(2Z(ut+ypQuisAZLCW`F=+_68pdFmv%~IL+GX5LGwi-UI7ud{t@jEFre#g;d13;tc z1X~2u0MG-d*KdV44FI?74O%YI+n!ib;ba@GAgwq9W{+R{FzmoVV=mFMgGJ*p3$Pch zg^p~r$K*e60Op3j#*ow8MGT(m;m`9#*7xuR9VF&t3Wf0IQ@UIb88$j2% zAJ}F!-TF!ept~+5IV#MG$__x*;+?sHVq76`@w|wcr_sb?p3h=2mdcf(M8uWnaP_F= z_0)_Ja}-qx!?p|Ld4gDC8*nT@bQnz@PaygHY*w4cGBbnYIEMMcQ54T*ernKn!pu`1 zdEi7uAS?`yssU2W22tlSi<7)T95yT1i@-b*$#W5pM*!z7FABk2WX2pJVn{5p2y(`# zf{)2P=iY1MDrQ~-UhC%x>-f*uGPMyocadM$(Sf_5FmLyoR_|*CeK(!dZb9-j1itQX zzBxSW&f45_^~viHZL`I^vo>yH>#c{l-s9KX)o>g9^ZhO3HEhkBp32-=Pwn!;74Y`D z9D;P>&2w&rg>%=fJC049b(7d5xrpQv8?5UkaV`Q$;`mG+A4VVjZ9Y6+37#~?>>&&#@F09(o{ojAOgULBmU_4Xat#`p2|E)8XIzk z9qodF5o2odiD1!lTqVexU5gC5T6h2eAOJ~3K~zQ&a*2(3j39x;aULg<%*2lB=W#pV z#`BPDcESokSECTyX`L>5Zm8VQpy4_Nu;?lsS}?k(&E5W#SJ0xcl~w*?z1XnLbi3G{ zRFBMWg_d0|JZxO-um=>X$$U{o06dyLdU1ZWrG0MYzz_sM2q4^Z-3b7t_I6$DJ~cst zK`<~oq14^w<^1aEayGl#4(?SoFaXq*3T#6a02KsKH&DPOuvZLJg{0SawzW!id5KGP zb$PXW^=P{LgQt(4K6>=OAAIq@{PkyxMe6&0nx?C7zIg>4M$?ZzdjI6p(_el3sYyo> z*mS}MMpr!a+3fU}zm$(Y`uTtKpZwx~{Gb1_0ZGPit>GQ-OX;goW_odQ@xy=eE`aCH zE-ZS+Iu6|T{o#2385XIHGlXB`!)1oyu+B3X`u_Of;NkwhKZKukKydwkR^wj`fozE3 zK8E{4e~Hw_wpf$73`5(}G4|{I$Wo-sWes?N6j?<8uM?sje46?=@E`g^e~~@ESS&34 zT@%VFu)uJf`410(ba|0&V~(q@rmY&y`+#rPTW`B74OT%T@hQ1g0a?mX@QMRPyu_j9eiKkbnz5UCz40xxQD&-u28Wc5)yKhI`Sm9yUYNKKZ{y*buK@(0HUq;pQ?6~RmPFv?5Kn5VhqplI`uW{$ zRcrtA&BH3&!9xccwX-7HPImQppf60pzg=&cMdI(;x(y37DgZ zc@%lTXw)7^R9vhF&LJXkEI`a$8*Nn+5?;hS@sQ;6vzZvDKoJIyyeQA@_#!@wAu@_0 z9@P(sgeGl`$Z{Zp6PC`&6YC z+FsfjmGjzZ%#k-Rn%k^>YlL6VkFfD=#57{tLu1oT!OT&_nBvP>a(0$5BNoA#Oeg%| z@!`k6lG8I`yLg^sJ=av4v%vE&XaDS%{Lx2;AAE51@yBOT9luiF3Zyd28+nK^ity3# zF|(YVoMJ8l&(4d*ReSBg6Jo;ffVmi44Kdk?)yYp}R)-MD+Q3c3n(Vb75_xB$rpfwg zjad^Bj~N07xUneN?V`Ryp_M_ssb_F2ZG_uh#8S*IUZeg{K?hK z+$&{}?j9z=-ofN);X+-h^YhEAtMi+gS}(l}n=nNM8#-R^oiZD|gaU%Q5QD2h;C3Oj zY8`_Bz#Y`xl~Pxi!S2F!UDpZ+^u@SFeZ^y1>e_i?8H@JAngIG^F^Rz0W@Rodrl~3nLjAYCVn9;cyIGpkrC=50PeR`t0Na2DTbR z+0E-StIZZ!+Ax(qhDJ)U-$v%XKRh@X?+^D4`n}IhuF8~&=ue6`|vF? zuiKoZfE8;D{e7z;vDwvrjU5e1>o=&*H^YE^f8Sp$pI=-okY?+S8h#33xd3p1{UH{> zGVMw-($^8lzJD*r{H>15={@MVUc57?8NN=o;Wt>erk}0rvmx@gWPPV-a@qZ^cmvyc z=?XCq?+Y``@XE=1Fc{igTt!d+Nh9~XmA2gQ9=wJZ@_U}lwQVa)gQ0;AnT;yrd&B*; zd6RKZ=3s~XZCkU-R*bwYj-0oy5Va`5=ua5A7}qoD&goa)%d(xUyAM4Z!ia&+NW^Z| ztK!YQ?liohdX`BYfNl?|-ItL~UX~olc{CZ>lxGhDK`x0P5lkvN)IMIDWJQs91{UFZ zwz~e9?IDe&dAv(5@kn?&jYgx&unWKZCPy-HCrHF)(CCpc5b!Qn3`WZ>$C0ZY`G~{ z=kT6U!TOyl8$V^RxMEE{N@*Es8kuqQj%n@#D!E;*+yEViDlza5DQ6rzf#F zp*iv@sI`4uz~;7_v$;IaX0uODMn5?|KKW#Re{i`6!HD^zpB#@EXQ!u_1K_;6ISL@P zgiVC2i$Z`ruRCzQ25rn2q7e=w@ANFOSiPPS^CIN&)>Bxw(hS{`_83v%0sY4h9@sZl zMZ2J`E)^VX?E#YZm z9z6;lO$USiH<`LCR$)WeuU1&~@2sU=QCk3-EefzIP!xqy#R}QA(;u!@SUFe$t2?Y# zSgp`s6<8GoiUP#|1+I&$>+4Kit3s(K)8OyF{dVzA(2pZxdMp zBOupnHx%lITIFEQ6Q!8(XMZ;N|NiYfy)NC#qM-@hbK$#wit@WV`;f@Ig zbkmMwM2*#4W6%t&75b%FS(YhEm&&xPa{b(D`Swau--Yk{zA2GR%Reql0A*FE=en)p zytG6K-%ZnW-}m1=m|o217wHAE41YwHrYK9e<#696A7xe=6N_wl?YpjjFw9aH*CkwI zVx88o(#9Q{1D&?jQJW)$s`bWR!!0|7gY8$@v3bq_DzW7V`mi1;RXJalqAXK#U8Jcg zamdniSSJ?xzUe!5qqcI<-R2K%$~ax)W|*P2B|)opaNXd#L^(ubf7tG>z0!H(RS$g! z)!n9t{t6}jRCnh(OpwUru6@gLdhJ&Y%^-5B@~Qfst2Kd`nC@MpF*;pH6_VAm!fKT$ zS@VRdz)n}L$yiIJqYYS~yY_swgRQk=Ha@@FF~u+dLSo)1!jkpErltVP)aZ9C=PLBv z3PN;%fXVum!5UAaovK*vnyJ4eT~%5cTil%BAqdSP97N-2%oG9y5tZagp69vJ5Dn#& z0wS#=eXF6xIHef#S8JI^5L5W6b*^+Sl3Q!4JlDP2;#fm_92~qi^#WQh<9Qw@i?5PJ zlK09S7&%Nm4#p3nC|o9sm$RkTq9rGCm_smB?RDH_3PMCFU1|}C(ok9(%WI`Y0ivO_ z&cW3&35l4sD1itPksGB{FV}gG;jp90`l^sNMrB}AE2t`$7&e|Jpa4uw9bxlC?YcQq zw>ZyK)Ee6iYkF(WT-~?1a!}dQ^+3iH!W4E^NqjcQuk}1Pb)U8y@D@MiZv9|0fUU|7 zJKlW`Gehh3fES+jA_vo?1cT^C5x7;2B4G@RN#j$5akt*bHw`IMbdqR&5_ z|IMdoXD=6Op_JU_lIM~qv6?S#W@pLmqWAW6{A4)euN$U^ZKl<6j>HO>ke-$%9 zG!on@QD&fdtD$qzS|=Jwu9VhFt3->~Fw0!8WwTaCQ*vn0qLmgM22|!cubobEWquoZ z%ntRmCNQzTy#!4x0#dx(0?#_vo>rSRN{@h>iHDD=HasH{9i?gpasVVgZ=&B3W1Bk%2LN_g}@yQ`t9`WK?U49FnVAgr44{~foX`o1GQ@7djnDX{Q>qy7zX&m zHCFxlL5u4QD^vy@7!Fp~#m%KN_y)u4>q`^WZC?Gxi`otPs}TJ@Fd7uN8w6bw>jA<6 z1}0E^u!6dlVt%F6C05zq-h(&ad_4NQk1$wCrce|p?C!77?^k?#Q91Bg>yZ`I3WF6O z1y-t9p~&v~{lRKgACxt>>|y{ED6&F*eVrAnVmRXOz4>?c{?3Et{PM}$-+y@)&*#rr zBS&7#&C)1)x|Ly#bZ3tHy133dh)6$*#2k%Um^NaM_ zfYTa7+i2=?!vGBc`7T`l;QKohf9K2ROJt=#9J{`Y;c&RK19#|yTz_W-e`kO6o#}ME z;|^Vv>AI0xxdkVtW#fK8l}&~VlT(uVL)Rs^1eYooyc$AIeRpTag-`m8{fPkDYmS2PIsKC$R#3sRq-${ZYH=D5Bfg9aPVy6M%pbwj4P~Ao^Z!hkDISPHmX#SXr~NmCn&T zY>cy)e$6y?oS!%;! zuniwKMkPdI1}D@EMeL6k1&`l55QVcBGbKwc$*nd?Ha*Irdl(-+(2V6*vCK4(8$c3E z4njy_ED3Z@8em6so@+P;93cm^=A0NpqAAgo134(yS{bM+8pacbh=^H4i}m8jl}@yZ zRg!3}lvWxGZEd$=P1X>GP#fDh78#qHUlZA*w`BKFm2FJA9W`WqS|G+`O@pZJY|aL* z3)wonX=68S5Uz2)qqVr7jV@reLR*R78UZ(L_quelhuZRG)8)~Q_MEEcI_Ny%>g&~5 zP&j6QXH3!wx!7M!go_s3KOtkTB?jv?fd}ahlIALOyXDSooNZvoZ&HJCbL*gcFYwCQ z+F(r!@mm%pt%0-ykKvG=W@71HY4#UFNDj^Tx4-)8^mmI~32t*cs8E7jBiHEla$vrY z`B%MzC^-IpbgO6*1fPGdMCZAPiEoePW)C=+XCyb&=D!iXqYXLC`K4Xs*pUUbln*9LH7lo$#K z?w4?Edu^1`DFpx8%4`SsBr&MyJr@(vgv7<9h3 z7q|g%u5hVvsi5wxE~Ra45e9W-VE|m-T)BI@uG_?TccZq8_8URi_>%;t9I`h%zH(WCP(UR+(y>a`Wsfp+1xHRj4FqeB1)3gAk?>NvtcVO{mo z?3h`tI-e`0aIhPE@6UF3|M3TT&pSCit4alv8a%z_b-90Rs#54G4Ar&@|}0~_YV#h%ZqCI-5;j+*Pz+ieBa+69=vm4EA)nAvtBdN zZxj~8ec$(SFx(&dzLgsI9ieU7)#3V^`PPQ49a=>|mie!-t=LDJrs*mJ9r^}19Dpy37rfFJ9 z6H?r#1h$Iv>I;6lU5_ywc7D&WJ@*@bfmL3L7^Z%EoyN{2OE-1a zTb0+}7WutRs`H9bh1oZS%st@MJ#(nu_Ssv$S3JCRnsiI~k;j1KYqlPcJO+a?+Ljg! zk)$dgtVF5ZX=iV1qnKaw5Wi2>(VBYhR4r9mx@}o^cY^ozB62ekpC^@60QEGw$rWD@ z82*+Sbhat$c_Wua4)&rEv($>SN?qJ&OaN0y$UrPs6dXlU5eQdmz>x%HWNBN72H z9Yqkt^BH(v)rd-NgcXs;9?#EWD@%!tiauwIAbA`oJY|L#OHwIt%#pC7=Q`~>-vEKF z3F48JJwy^sBZ*lg7OR5DfxJ~9m~=WzS7f?r8dLYxO4Q-qqjK=J^tVc&TFu3`&Yg*5 zZ>!i%ao4(CMy1j48VOMAciy7I_tv$*wi*O$$$P)^y#lmro%YVXZM(y>(TLtgZ(cxIV8CXPw*{iRy>gX~f?pAV|i@>R|r8QP- ztB@5M8Faf!P*qig!M#YjhKkC)2^tXY)(ff|6|{xUVQr3Axp1u2B^E|gVx-AHaAz`9 zn%BWD0G!ua;QuZbb*2@)8 z7gy@y3J1HvqeoBw;s@t1cIRJwQEVA*G&tNfzuW)@ScgD?;7VZ^l~6itgY}?t6I27> z&IO7~oCA{r*b8?j!8h+t`O`Cd=e2i$|G%`e`EeXc)BBUIq!cg16pE~(7LaVTa@D&% zm`d1QqjL}Tba}9VXRsH~9t?OdKKSat%18TH4a0D^FXL+XGT9gJW)yYx4z&2I?^S{0R>CfYZnx?O}fUl(1&=|xr__ieR*|RB9|MK#kjRW|;VadhP zM=WI=$5J+dW8cWKo&uDb?NKTlpiXOET`N@!A1I|P;a0+_Ey{(AW8j@yuT#zIXk@5@ zzkRiq*v8MMKCphhHQKiUa_GRdGP_$R6XH1beP2$?6iAiPrY3D&$~aE_vQ)<_`BYmt z4vh>P^(>o(%X^s{dMl)pV|JEbKJd;z;Ni>Ghjs669DS619EaY=laJ$GIQr2k9S%pU zu zQcFw0#$%^CT5D-jHnQ$g0SOSHshNy8(S=72)Ie7Uf;M@^jL(;I2+k6%6q%wBj6CBk z%ZWr~BgMkxQ8QZwXUn*lt6F2$2PT4m(Bb9^1kONA5s2p*XSy)!_(xnh$F*vwhDD3N zp+Am@>hp>3Ig18lt%)p?3(XTX(9a2Y8=P8I*Isobx+~zD(?axf9CpMbTBCrvNV6e< zRL)}Ss@|$qfNF*hVn7wz9pDD)XY~?00r8gpYwKCIiWyxXT@y0yrD?f4mgghaf!=_G z`d{;gi9+r$#FkCECtMGGA}Flz-M2}SF?5LeNbLjIj0FN)!r6@Gk=Cr7F;@91yQ*tfP1U3wLo)$U z6on$JKq92&EIP+IF>mtCYLg^M!kf(2dx#oj>dId;1~b&3dgx(J@EinYLAp}J9%&L0 z5jUmE%^3XDRdPiE1fw7rb=b@|0E(T3$c-A|*Hrh72Hofp3hV-mZcOQ1F!YjOcWdDl zn2hkn8Gd-LooO^Vk^lhK?=b=pXz$r9>?}Y5yf3i6#%;$m28yxK(0YY8Ek}F2D*_Y& zaE)U{k7jwr22X<dxVA>K+2=`NCkf0mw|1Luckgc#6h$#B&M^DM&(3_{o0kCR+KJYu zVY12)f^%ET(t3ot&NR!oVYm%yXeqbrt^XT;@#irV(s$eX4?Yx>?7UhpYH_jf7xCq< z-zlY}lsT-4OCWJm8R)7RoVcC^re*WWn4n3Z3*~NT7t3< z_)?WhDJ3DLgaVYpLdFYUzAj&_(^PF0O2=chTsc*i>T><;UoEDe$?fYD5=gDYHrPBz zJxeG6>va0lxK!Kq>r`#KQdq`P%Cua!O7hxXt$IiZ`%XchY75K^@Q3>NQ3AN#-I}v~G#VrLI2s-9Mh`itJ#V>U2x`eq>JyRs zI(dNU)>eRA@kZp-mfHgp(E|d~Ek117g>GfnG1Y$@&0(aQmczDO?f3|zd(-F6q9R*! zgNCQYbmaEST^4O?w|j39mN1YDA++pb*ZQt2*>LxH#w9hYj2w=4lp+wU*ssgBcO=Q3*VF z>8OE%WR+>}OG{|s0;vPD>wH{CXWqC~&|Gh-k%}SF)pyBilW8vdC(LnGEGWzJZ(h(} z{WV1-Rvo*VIl-G3-$gI4X5cEXta{c*tg1jXpHVo+60@)VV_?G!60J{`t6tEfwtk0b#5cgCI3ga8a58ql2t|P)n2&&<1!is}Yum|w zf7?^!0TxeD+-iU`Fh&8K1(-cSay>db!`t^Jwqcgl+4M2AvIcPW6xVG&^kz4ix8(ZJ zemGAWL;h2!rmKDb}ymcAKV1ZE!)UQl)7MAdO>RO1WL9>G~a{udQkLss3FrOF>QL^yhJW zsa~yBsxuh%XkohW;X|dRPAZg2tzU1ST`W|oIdpnUlv%d|N>yuG-EwCA4yJocTilkw zHr)>V!OG#5^Qx2`b;y?S+|k};Tezx$-X&!dvFN-{{eN4}^(oToz0+_HA5N1zY)8AV ztkv^)6kr?xqw#3${r-gA8}O%j(dKr-_o1aPkn%7 z%|aFfsifYC%{@R(OHgs^jXc!A==gZD<32k_y?vdr0T1FM7lICqd*D^f6=)#gp|den zj%1}Na#eR@DGYTp5w2Ri!HO%9n0F{GesntvtlTjWbzvsS^_!7*Y> zC`O%k?(PB1^&dCTq&df<4FDjqfo6}J4LEdv1p=G}0I+dl z(73_Pq}v;&B}aEI3}Mu=jt89QNdR28+R}`G0F&bF+v55<`0|V3%L~*Ry4Qtq=RQ+7 zMt!iu4GN5c32!VKn{)l^b(u~V7qOInx?ZcaQJ6+LOJ9B_<7Y8ay#DoCrI4}o z{a8-@MLg&~SrY&N6oW}bK~(i6rheSZFIz1po4BwqWs3EsTB~)6veUf<092|}if0$k z7S9&1fAdb zP1moCLX}D>_)1FYt5TH?oKD;0T|X5j2#vJ7-}2SGinqB5G`7fg?0~)FoE?uO^ya49ow<&Q zMeg}L+?J?7tYOa*)GqzgVRjp%fk!|5TBt)xZ z15QkPohY0|Gu>qnZ0rW3p6#KnIERf_R}Pg=PzVa4InG2p7kLJg>mYmRHL;HM06_Os zWCqa&hya2JAp}*Gb)&%`L8784VnkWCc_8~U>_by)8bS<(W%a5$0$23oxINHX)2Bul z#Z0xgiY8ucG<1{nZRQ`Ufn>^nuiR~hs(kO~8SNrd=NRLiC!DG^gRc zok$%U-DJ7Bp_9W&8V!6i`N)Wu>j7xxexT%z9$VujW2+}@()KOp8-=s*m(S0aGkSTM zeD~d()&-LRK^a$@4ZiwibhXN_l8pKtF)6PvM-+{8*zf0xgbjTMF{jF8_1_jDu$Bcf0YUF#w!}@W&{3*zHh` z$7A3FFt!X3U4*!6+vGa{r+9RSy8_7va0%=*{e$oD;jZ|AdDve;`vYVEc@Sodv!880St>w!rNmnfxX`bVvP2C?A1nnNXor;;?Jd= z%ag~DBPkz4KKA6FJbt_gJvrL1_dl*bU@sp(e*8Fo{HK4q_>;wAI+d}UdZW=^lhj69 zceQiS9<_B*+b4w_M_4MgR1!x3eNFqTg-A1m+6Ne*FQSq*R!woIwO@m;EhHYjk-98 z{$t-;nQHxYFU`o$bJX+xsI(o7LrBPx0}Sc+9aM(AVi_GCM)$%&j_->H&HnTDqkU^d zBLI&cd1H(X@#pRoCy(&xbo}w8xe1(VyaRensk*A)GL9JV4u?|=vgg>m#r)%0v3Sr` z>P{_t)rH+P^sUaiEiR#h_=5QkQe8(*HJHPo01lls^dI*y`3``mPa;0R^A6tWNdw`+ z{o{v2PhcESaTkAQ0U{bHaDeBzGRWm|;c(!pvlqVyMxMYa0Tc2(4_tW+cn0g|L4c~m zq2P_haUB{2U5zl%uk>06+=C&Y5s8UM6C%%>1e3|cn{Ihq6u&*_LVS3qM0s(j_z-{& z@C+-$iYs^^&nt?oOuyr_KmqS0pnxWXNpPS*%%UI&06IO; zsdsupC**m6h5;N7CTik&Cnv#_=oFRaV;l$v;DjI!htmTcCSV*~7_!$Un04uL08X7t z2N5if;?R4g2f#yM2_6JY?7r1(10uM1jT&>{d0u@kA1WMh@H{YU{K>&Pcn1%s@J>A( zz#5jPL3#&x0BatYUX^gZ6{o$k?lAZ@HQyP%A>?`RJkL8EYTm@*P=hh_%e{jES&(7= z9R|*M)L)ImJwxmI-pLJYqXuh$K%Iq~s}gwx51u{}UT60_^nj1%8+vebxYuy$^gBGS zxvCuWw=vY5lnJPF>^yiLdE2DeUgZT>tz$smJo@~vp3gVwZ#@!Oc6e8~akRtXffLL+h2V4lR1*r58r=(^?z1LQsi7! zF2%F?@z}$`{G1*P;?9EyOmx)%!2>4bP3QpclsuRp96V2BE18j{S@zrQyX;UzG(BJb z#5<*Jk^vQ}(?Zi4;T?dYfES9%{Ih8JlgV;EnFcfqXnIN!C;$b9P6_XTz@vz~D5Ck4 zKATUxz=Nkx@6+M#ezk!cnDVvam?v!!9+Q3)#LZ^tEO9V0y7{KSB*2rWW)TyUw9w1y zNz))$JOzNH!280MItB=w!bf0NVDvOVFaoZ-JGHy*y68q?Hw_MVZQ)Q`$dh3~aXiAY zYrP#X-492&(Fu^^@-n!%c>2Xzarrkbk30a1)^Z2dVIt+bVlt{R9k%27P5*rbP`tm^ z8}(2B_=)&;fBc{R3ny8Qu)%WFlQsZCik|=CJS6_+e_V3;52Qq^M~ZHJjZ!tw={$mj zgxV^#RdOn24EWNIVOsa4C{xpB&tJq-DdRYf@nVX!R2p^XuD$IG5BCu1 z%h@(t+cBZbf!A8mTYl1#2cGn$HRK<9Wjld$EDZf%W&<+F5ivEh1QF>5YrQzsd|K( zy3db}>5`ykW`zfi^?*TVCmOgS$3J9ZR79fw?$ChcEbg~_btT_Dh@9H_WpYX$d7xDX zIgK%yyXSuk&EWL3?|an*r|f{*E3qka9k^$Aj)b}q79N@rXglZi#x_8n+EDJ*JrLSg z5BH1NYLglby5-DSwgGSokM;THr8u9@t~N=MC()3Pz6|Nbx0e9_>iNaDmsn*R2oQvB z<{gIN#q-a9`PFhZ2X8i4m#ZYnvy2<$#o&O1>Q7qNC8Lv1CZeW~A|ve1F*)g$2zgfJ zoLw~po;qRQqR{HO|JogjQ4#c` z8~uRBt|z6BKSn!uUvF%T<-ruRyV4s+Q5QvVd5MdQ;OV@0zX3*V8eUs`4{B&&gk7Oi z(KY_A)!niFC?)`s_qqrXU(BEUn}7X}zWy2s=M=i9u~yG?@%(%i&0f5GvCV(?59Ns? zXIxR|OF;RhP5?{Uh#O^Os@9kaO^#Q}SS}WyeYTiNUoSyH$+FjluFg#RE)D}y0%@(0 zm9h;7p#UFvCKpPo*H~i>lqGy@-<4^q7K?bjwnA97B&zQ=<&!4Oyk4ize3{Dh)q1Pa z5~T*%L6-;W0z_DaZ2r47i#DMJ)t9$`k9ax-kgm7bmcB%(`axzNL$>wsC(xIq&GGX4 z3-EgoIt*>*(DSl~x9jhmyUh_6y{LdCXor4y4AQtOqWfj9JCXVTPvbt>DQpe^{X3`wiD<}R_vSaMu7<`iL=R4rM1j^Vx%DnS zHvQduuD)Sa?PUl@QrBS){ktFlVTg)N`k9>lFpJ4RkzhN?ZH6mVCvHXnOqrqkL0nQUi~yn;BLi2UBWE9p!Q@ht@T}Z9{Z5xm zt)vA|aVJwS07@I|MlFViZ6?dnL|IK`Vf9d4f*N&o?^Fpng1A2{;K9vy+HemS189Ot zTc&d_G{l2jW5>Tu=jpE2HgeI)lW?z0u-&`9CxyGd0kyvAZj6W9;+n%KiYQ6CA#~(< z^6hu|w}y%_kWP*w5b@P!#SF&P#l?BF!kf*eVxGc z;Es$Yv@ZnuByn>sWGI+H`t&e67%_TesQ`x3ZSrJbyz(YoqvkD$FxzKHsD(r zqB3xUR&=+~mt$9P>W<}Nk z*T7p~1pM>!*^j_~|2ntO762g#vnV=0KaZC9`sIt?zD=!q?nyRXrB>+{jGfavDF-}KyW**V%JYea2* zi>kCKP3R|{`_u?(S<(+HftG96=1DaMA-OkAQ#LOg0_qV(e$;JlnS|6M_*Hdn`%$q> zN8;Cp|5^?BZ@70en|&0=Hl8_ag2TcXtvM1vkg!t)&WBi4wi&o^K7@)ZKnTj3*n`kY zg@K%NFcVQoVa}Yf!S@!mU4r!Gm5cOzg9VF ztsaI|a0g;kWm!%)JI+Ehi(%s@}|jYe)}%7|hksz>C_lrjw=Tj@jP?{%IH> z&BxBhjvdTm=p=T57<^iwuQ5b~#`k-*f27ag*z@EC?7?MMj#?}Cdn1@Cm+*}H{ z4?%HJC;+k+7@AsR1`Eq>=z@0iSG8W=nY*cg5aBYSO=imy+M{SbGIS<7Kc8LY8Rrav zt2bAhEIFT@pP$d8Ii7!Mr1Q5g-fVQoY=MT5!>wxt+0k}I?GvE_gdKTzwq9Qs`qPCV z0ycuGiWxAFpoprBnK?@?U#wP9w47aBfH@)x2^DYjw@Fag48NVTH6#vAcx9Z0-(47o)nYoQGuNyP}du&_ich^ZJK)# z1OX#m8jWbY0wj>yP#-Qs8kBIh~qSk*HXz+HT!F5&?sfy z0!2b%`YhJPk&9=s)y<_^*ZR}PXE9=l)R@+K_x-7^u2U+tLVN1Ri>Zu#1t2X;(*{QB z%0WNYUbt$HOsrJ(9izH$GfVm15;E568R!&JjxYu=#%QE}!^!yfANQb-M}(wfL04S2hCxeEXx0$A%P>g^I5 zXq|2JJ$M9;O~f}hQ5OB9S8>x()uJNoy`P9G%R>%c~&KV&8?OfutclP&|yP(=)o5T=UXAh}F^B;0ubB4QA-9D}py zgh)h)B4io6PNgjfqj|{ndr3HF5FMRNXcz-+RpQVj>QPNCX}FyWpq^7`6Hr6J8t%KF z)Xw?f$b<=_TjbZ?HR^;f$W_V~aY79_jt$bhK1#MUwHAux7}5@Rf_lM-dc@SB;hsJ!L&=T?^!K`dshWc$fQcfaO~&6P2`8C}Q!Qy8(JUn78D|OE!LxIXC2C#C pxYT@J)=h4?G*+oGV;6%20K_6)JpQkkiG`>1vkHoVnkPvD+a$lUsblk+$AM zYPj3t@wvw1WtP-8S*vxQ({7{OS&GnQH{kIb5$>jnYhd#+kO=%GB$$!r?+|x>SP6X^P2YhR9@-&|QqqOnAkO ztk`a#*ss3eM{>YLYQ4?Y>uQY3N_N9)n$>8U)eoPwcSy7z@oq5J!G|jqSa7+$7r3}aHQN9 zFN08WyIhLSYo6IyeZfwA$8Mt8K3}nxv)pcv%vOZUaHQKRN11Y(&uN_5PJ72xdBACy z(@%H6Zlv5kW3)P5uPH>8Z=>68q1tAf*=U>CXqwbZcf>SRr$A=6E>NsETdjJh*d92K zZKB*mYPmUHuTp!%OK`j~Q?4UGmoihP6DN2wQl&#|yEIj(GgYWHSE&;xcQI0>H(Rbk zX}U2{q%l*bH(07~px0=g+GLp5YMa$bZ@fWjxmSnJ;O6s5aKm|*(CzW~L~Xodm)CZe z(14%QT6@1ZTeUAtpXcoLV2{vHdBUf?-$7!uJX@$YSEyNt%!Q-X_4xc{h{#fOyiD1|pOB66;%0%Ik<(`{i!u*RTvll#_>B22(JwBoW zb+wfwiLJW>^6K3?;BH-bG6DqX*Y8Avc<}@YO2?;57di6OrbF7Rh>Riu9-J_hX2OJK zpd*ML4Z4|UXzols@FGFNk9eZ~)M&(GjD|)vjFf61?~IU8$le6<;^n~u&J%!$Y1Ycd zXwf#Bi2*VJwQANUG`K+LueZnR!qC}}`7yyF{Q_{1` zE+R^L12429kwgc!^4UYC6}q-SMEC55fADWPEIPBhe!?V$xp@JXq7$WZ%7?fb|0@>uN zufP?A{7g0r^w0yc38&kztnRwu1{V{<^NGbYV65@R9eZ5C$d6zlg%l=OkmHBnjKKpB z8YCS}G%o7^b1yP%F*CI`-+b@YS7Slv)=ayhgAQ`2&`SVYNKNx4Rb+g#$!zyv!PZma z;q})oq;pFzqD)ct%+t{SKttMUmmv7yX27i@9$)LwLJM8oLQ6lAOd*2Q6im~%-&JI; zdFC$|{vqOuFWxvUC)lG&}d#Ly9Jn&oRe3 ztFvyo<*ds-dw&yAG>Z_o?2bk(y^|8f6u}R_4)NP>ABGuNgm1z%I)0;v9xtT-g7dQo z0DT7WC@_8Xnp`h=>cZzQf(Y185d|r!`cNXUA&gwyjv|9-pZlUG2r_U$e$=C1{rX42 zC}@Hd`~U+O3iqKGXyJf^NT2{Lf`bMWfDU|E0vQ~r00?Rj3|5FCDP|Z$D`+qlXixwL z{ga4ftYHnaP#_NfQb9x$q7WNPNa6|~h=wLkFM_d%q7xOs0S@f2KZyWh`*1MCRKy_; zPB5VlgrEgsU;~LtT;c;;$i^yiV1-H4ngF*r#4kGGj!sxX0mdi|EtC-(1V~~US4hZ0 z3X%YF0Nl@DImcsC3E~Jr+0Qx5jrbJ~b9pC^}aD$bZ;Nl2__=G|HFd5J^ zU@o9Z%^wcp3BDZVDTi51Rj7grR4_s%RFDZLd@&WuTqZN0z)p4sF^D6?feCa}h$axz zo8Y8^N7x|$P8Apdk6+vYBnH}tf*SOo1sy0Pb}-Km?L!y3z-KKcO3{9nB9)400zkhQ zhaGtIqaNj`DI4maedLo36a|4wLD0_;s6rRSOl1=?no2y{)Cn@BDM|ZNh>5Ng1ThF| zPytbiTd0E#`ShkYiRl2DI@O*`_2%0g3RIyoL%1OfnCjJ109vz~3MW4$wmVVKsm#7HeMKJbCd7T^Gs$d;9%JI7|KYng5R--d;p^)zzD@64sZZQSop#i&M<~4%;64u*u&&lg)vG3 bVPKf}#3)X&idSr6W4QRmFdlJ90s;U#UXQr2 diff --git a/extensions/pluginx/samples/HelloSocial/res/qqweibo.gif b/extensions/pluginx/samples/HelloSocial/res/qqweibo.gif deleted file mode 100644 index bf50564745aef1878719758372c2578173cc6c16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2700 zcmV;73Ul>GNk%w1VKM+R0QUd@*zu?&!sY+}|0BKQM9JeRwcIY$?Q7EOb!sTVs z>kOXM>i5zat=qEVP?X%`G={-ErOUGS2F7-0qg*>MYFZg3{S&-0%>x-2-T| zYuN7I^y~$5yW{rk^!xo=&FDqd>@dXU4yM?O;OrT;;7Z!>8M)yLn9!Kn*$kZ14W!mO zyWH*h@kPJd8nE2V?dlb@-ookPBbv|6>hzo22obd2FwyHB&FW*#>wr61m`8*XbR}=poYV$?W84$hZ-#+a1yC z60Y1D#paFEsTRfN6~g2XsM!mf(jd+14WQJsq*4k8p!88)$NMf>#XML!|Li_&*~Pe z+o9p+9lhhV<>dMO`X0F8U)}6>(c~Vr-yO#1uH)pT-ro_N(hsZJO4sc9{r*tP;C+@-xZj8@uA^ z_wXLV^RWtC%)rm)Z`SY*%^4e1$@9K)$RQL{3priJ;dUg-SG>h z))>R(6tCQ(;`2St=@!7_{r>*t_V5j#)dz~nC(Y^*u-prY#~;e*yXfO6(d#A9>%Hdm z6}aE@`}R81><_Km7s%%mz~c<4*B8m?3!>Bunb8iS)(xT728PG1;V-7%AP}L|`TPCY z@#vo085XJ03ZT;*v)wk=?GTd8M$qPO(B#DE)=JRkd(1WP_WLoR)8_E_>-PI2#^)%< z=Z@4M^!w#~+3FOd%#PRKKEU3S;_wKZ(O<#hZmHE)%;*!a-7~-7pW21H<*s($?Io|s z{{H(Pz~sN^?L4@^wc^Zr!s7>s#)Ze^3Wml;M1%A^8LW00930EC2ui05SkF000R80RIUbmq~&I8DtXT!gZ#hLx&3!$}ngS ziW4UhB9Qp;(hMq#4$odjpC`SO}giDb%_FMHYTB~&N_&inyNlq5-_X{shg8f~c^ zYSolbux@SQ@Uu+)vh7h~dvfK>yMOclcvPW;kvi!4%-Pau+9YiOoTrvP-NctKdUm|} zvuV%vS>ENg1aF}@^N2b|#L&thb_gKAAh~ov%LAPdFhYE(MOWW_U+AX=1^#u18)o70 zfQJP!VB+A4EDGQPEn5h3;Q*^qXWxAzyz*g)v*eJ28c*ofn=^PA(E%$C4${gPOfWIV z2e~-N${2){Gr|CL(AOG=U*wnxi2vn4S&#!3SY#y*iqZibZ&*-52^O3;MuP%$K!_j- zWGUU29C}GX6x(&-BalJ%c7g>RIEYCMZ7%|6I3v%0^DxFhl-VaL%;y7$zblV2@vDUpT{D*Y>>`W5Q6|y z8d2>8>V%ePK`Mc;7)U8VkgUK1 z$q0bSH{h7ivN@=rlCCKYJIn^M5ZjW7KB5Saj0GBp0Y-}g1R-)9aVRo_0CuRb#vM;b zJ@o~voH9iey!-;O8cFE?gJcXP3}I~;LAMyl*J1-)*=J&`$3qY?lyri`-4DpX7{ zMc#T}vGw194^aW(WFLM&9EsP#_}el-UJ(>faB>7Nmal@j=Dg(Xc^zGkVL_xEgnROdq7aErtc?|L=!OEuW;P(0P-LeopW2XQh8`5)3#f>o1Su$vY#;#%X-Go` zdr`krWCI$6;9m^?fN%=|IHG6=NFo9cp@TdyuoCLi0}PH4-xnS4Ff=i8|F}l zJfy-YB5?^qxMK_52%0@Y5CXKJEd)$tL?3n~iWU~288NIP7PB}2P^5s1UA*BLa+twY zSYi?c5QHFVz>XRSq8x0DWD~z(1~dtP2?%I`6fJVaj6|RceH21FZjg{bB4Lm^+($bO z6M}r?BMyRSA|qz0h;Q_P2|4o`23}AA7@z_po~(i}L)i`u81n|CH03ENL5BgLfgAcD z#UZ`{hZ$rc3rt7`%6P?uUG`EAR?LVnNkGm!fI+v!e)AbpUhhkqHk5Am9!I07nlHpn{sJ00Ri<=p7p%2Tur;pao@t zQ19S@SKJ{Jf6#(ScY)HBYCr}60Kf}Ppoapq;00KHfk%7EQ;YyLs6s^qBE&#cqY5(< znb3k-m&(*wyZ`{{hy~On0E4>P6$U)*=_f@RRsSFB*ufH`83i3^70`OcD@wr!O+acVFXBmo@|6XC{cB(Y ziv=wI4E6|LV1Y={KDY7%dIVc#b69${8hHfUG8_mtKbDN_`@r(0t_~g z-xVkr!pl{LGQ1Jt4JUZPApWowW=vx%6k)`mXuyX%yy0!wfD10}aExPIV;UFX#w3=* zjE5X!YW$eVLoTw7k4$AM2O}6G_CN!wEaeZ^;~sthv6QP^sdk5BmF2P-JFr0$^hhvptrRZ~%GF0Cmm)jo1J=qya>(l)SMt zx6~|evxB1608F*_#z^_xTK2j?_QXck!)yB8TmW*+*_143tJL zkN~;o0B_3QrZV=wM75}G_P0KwmSpV7S45Go*yr~7*jMYpLT!P8DtO8Ofy?;QRQAF{ z=IizVT)ZQMy5FBN7QErzoG^88VU3%G@4!j=-(8)ESpaUp_0m)TbjlS>uH~;m0At1g zh1M-xwfN6Z&we6V!_yL4qX}`$_|Q=K)>l7xn*g@v0Fc=UV!}dyp%bFl8*auPP_V<+ z?liyJeTjL%o>Lxy(-4cze!RRWqstX|&hPa5O{2(kqnr5CQvd(}A^8LW004ggEC2ui z05SkF000O7fPaDugoTEN5Q&P5jE#{40;L?M452jH6=m;v?XwqAn!h;8=mU>>yB~|FljUVvL^rm!V zSFd3ID~^>)Wkl7DGCqtr%8l(-HcY*Ky>aU4zfMve+$H+qLy{Z_`zHN+Q?NcD#|+Qq zRrf68BuQ#S*4nVLXsm9XICeiZSg_#3=gn>9 z-=idW{$@iv4H}Hl7*PZk7+Vr)VBkb{XpAui2ogkSL_`kcJZxMyLb{XqKQP4m<2X#+zgmPyh}z z#5g03514U5mK<*BN)s2DQG<_RreWxzhK{IUb`mH6CmCNz5F?c|Jn=vUB5c8D6ksR? zsGwkmsi>kqIuSw$W0U|V4pL5fX9t&NdO{(bmbBHU8K8m2sl4`jYJ(tD0cQ|X(pY1x zTbuv^tzbBG>jfeVF@~1g`o9+?-`|Ifcn^n~5 zDh(ZUEX2Z^9&*CS7Fh6|a!jRL#EUcxTmTsg7<^~KPY8jm$Rm?%0R-QLp`2HMW)P#Q zau%?Ik|iYFaR)*)t-}Md7LxPSB`?ymawlLx!xTk#?RD2X;7|n)3S6B%A;jWMhc3k9k4HX31SVXtMHiT>eZ%V(z%cdZXAeR8?WCI?IT1wEu?68> z1poT*v7>;ty@Yh}h2OdBt~>A0fAKpC!&eVG445B(!WPb(UIzd@)ZsV(^yCxag7r55 zp}zXDzur3LZgfw?1K?LsK@R{tKz;=LN1(>=>kA+d+ULIap@0tMBf=M~&;v|GAqpb6 zpB28)zy8rdfEcvE3eac0B9u=HJ!qf^E&zlr@F0RA)ItSO7XS>dF8~@8p!EXqfc{aS zej^M300RK6`vHIg{i_2H)E9sv8nK8m#NhCFz`qAD(1Am&-uid|!4O)Zh7q{H5w{4# z6}WJH7tjI&MX1Fu60wI?q<|K=XhaRN(TEqgAEqvlfEE(*jRBw{3M&wvBPQUFf7DFMc~j*)4{ z+WWK`-w*-D*`;~b<^0<+<|qO5S^)q60P8gY^RSKb2W*;Om9j=<2&Wa?;{;)Z>BK=cMKD`g;KWq5!Aa%I$_Wq}kT*nn>dt0Grv?jos?U zJ2vOwY>C_GrKqRO&d#mp@Ve&L+uPfn;_d(c|Ms`4?m__k<2t3&y>!##nc?iIhkW(Li>UM z(B-Y8hkq_ z6>!qxy2r@V#i{D|`dP->hP%e(GZ&i0#_M}&UdY?R?ezS_B7Du-{K_W!&ML>@-M)@@ zyX*7d!iDqu{H^BhwCVB7m~!a7V(MK))#R1BR#jEL)bCXdaM9wbmD}E$pQ7Fg0ud1r+4A@Mt`dgV z<>SXuw(9ZUG9(u6mQYtwd(S= z>GGfB?)&@uzr(+(A&df#O(0sV^@*Y;MXG)-Z&%j!A9`H zQ@qEHw5phL(cp8_;?Avqd(`B9)8l;7xg)@IG#-_E4{|NhgrkpBGq zq|mnZw|;cb;IYo9xznQiy&twwv9yZ`_HA^8LW00930EC2ui05SkF000R80RIUbVMH2>gB%ia=)kaHLxl&W9eMG> zg9s5ujFc(k%h!*OA9wT;D3FwqGpG)*>2oQF%S|w2%G~5KNFO$Ax*Q-x$VwAb$Z+8T zK-7#GH)lMEBU$DU091qyV8Y4rQp=h(tzN>3>A(RiR^lK-RMdN}8Mz}IoaLJHC6j3tHJf(ISKD=wsyNJjJJF9lJ zvevI-%VrqG%{e2tb_c_ZYco$w#Bmb;H!isJSvRp%KX)B{ItO89_=vFLM#g1CsDKNn zdQ<#PLU-Xp)^6xU5yfKcN!NiwGVozU9Q9#_haIWK&8B$d*t_ z6~!obRx?nz`6DmFpnw4&e(*C-u6H=lYkk`R`&}2*RH03>=$24O0Ry78W|a?&vB5sV znBasTew@Os1GvQE#vxtq$T>puj;re#8@xG}7qG z?+86?iWw@K38F~CD5s2t6zc+zXc9`q9CHJ31QJL+9PHzX#z!0xMYjM%;qPv}p+bft zQY4*l(o9RCMI8k|QwKgN@7P9nP*g1w$>tHTGQd*H$0 zbI4Fb>WoLCPVGa`p1CY?L@$RdveaUL0k~Ulz&I=93=b&Myc0n1!!vP=8$29;#u?1W zk-hb`$dN)jNYrmX5)`B$hXD~>e|;jAVu3_-P>uzZLwL&2L@&^nz8aul9R9mr1WwQn zDzqUCHprj`ZBdCfP+<}ph=2$UkOfKTL4Z9|1v|FE4&l{6fw2(AYg~~D5sGjL5zq%3 zUZKGr`p^cipu!3Na414&WPuyj=vhUC=R!@KV+0+DjR~?~!zDQ52C(oU0#ZQ(8X(|@ zHfTc%aIl0jF5wY_umlr@caayKBMJ-YfFvGa#z!C_9X(8iBrHGxA`rm>F!-Vm(cp{; zn30TcFa;YgA_5+e;~ZyTK|&HyMlw#q9zBc!0Y)K#PI{66H1Od%C@=vWn9`JK&;uhe zVgyH?Lm38PK^9J_fh%N^2%gMkCoLdI4HB}Hr;NruE|QUqIFb)F=ot&r0L(4)5CH_x z!XxynvY#(8UdU2n0@!!U7g}Mgn4h%T6W$ zgBonZBDUH8O<`(eBO4J0Iry*(;hmG4y6A)kmk|mHj3N{WPy-MMut`tevxl9?!!{wn z(Jy=gpaAW_KzSen;SGYL6L4k*87ct+T+;?>h-NNf@KPY|K?NMm=^Jjd5eN9R0~ff1 zFc^6cjjCV~S+qeqB+*iQGNYcIBtj@P=mlfoG^bx!Lm7O^RR;j|4ztLJ2rN+q2;fwu zHb@07Ex?RWK-Hm=sA(s#p@O>BwFUm@s!u<{feSE!0~^W68op51Ja_?*>v*a|IqAt~ zzyP1?@IoFKU{@7jBNV>iDoFV1SHObw6NF`eF@#{tbi}{{L>R>=p7F;RTr(Y=*uyU< zYu7LTWFQxt{XqzJ8-l)Sf&-cL=|(>&@L zV1RZRaE&710k^v4?QVCl0}cQ~6D;s)aDDoRP&C5048TS;gy4nx-oOi6sD=-Waop|x zLLQ;`14zU>Uh=Zwywb=mSHZD{3>2XS{r!c6CCq^1_E!`wC_;d9LEsRq;=|quu{RD( z4r%Owx4HeuAMlWY1QekWEr_v%!$gp|o~gf2tb$xb#ilv}~(HisE` z632)$Bs_3|3wXdAbI7xr_sr!y&!Nq2jzM;Qn$=QleV%#0qi047c8 zN>92Bd>F<*9MO$3>>$#h4mG1KZD|mc;T+~5i6i&`4s*Kt)v%7WtYf`{JEWQ<|6qkV Wz`*NX`})_w4z{p=tpJh)1OPjI2V9Z> diff --git a/extensions/pluginx/samples/HelloSocial/res/twitter.gif b/extensions/pluginx/samples/HelloSocial/res/twitter.gif deleted file mode 100644 index 72b0f308387a5b5622d549bbf4764f886b2f15ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2193 zcmXAodpMM71IC}321Apxio_I2Wee4!v<^v9YO3ARner{GzCvx3lJhu}lueS_QA)LZ ziTYA(jnkN{Q;fzChQT@|W2X0=_w_#Wtnd2n|9{tg-S>6Y>v^QvX8)4m!fnmfF%z#$(Mgi}Q67Q5S zyq7GN!wFKoxC0v;o3QSf86_b}l6De&j6(U7kXDH#D)qiLEOUfv!r-$pGG+jODu@3P zm+(iUS$P=Bo5K{+9Rre?1cfB*&6EL)kS}Y-k2q+_9FAmdXn2u!T zyp#;>R?&p&6^*K+Vmw2JkC4cvR&hXtD=DD22XX* z4n=$=1R``$go7cJK8TgbVHE~zFgQe_mkQX1LwXln(12t(EK@)nq7VrQB*?E7A14uL zM^{JTg#nUYkB*4(_g~4}2^igt12GyPQ3nn^KPbit$ZS%d?;+NFz;BI1huMDyRLL@G zM>7`EJ+rnG=Z;XPdPuD%G)$tDF=~!jU8{hhJ*q-EygE)9y;0Jd)N_RD&wc#{0xDic zCikn%Yt;rHRrES!_DR(sr!;F|%QPvUfpNXWMHzLxn`GC)ny-|#kPPg@FAo#vy9wSX zku?F&%(f5Wp3TH1DY;Vg&0U~KAEAOe3FjIGtrpSipks^5O{grBLn#5JB+}}dfe>Eo zC0qrH8#26jjN}ece$C2vlT_pY_4><9!Z5{bM@%uP+f3#T5l5t|P>JfSlsqiL7`^bI z2s_w;)5Iu!7&1SouMR;_jern=HUw%As70U)fgS{;2sEPqX9>Ze0f2xVn9cv3089js zw(Gj*eSaq4dA8>we$jcjVsDXGUc?7&%cM&d^3*9?PsYkUOMOQ7KMFFr#0qE{DDmT2 zU*=f23O&ng7T-N^y6pzRzyABGW94D}k&i=uvn9vOe|om7&v<9GW0-3BFP3h$`=gqR zQnQBrirwNo4I1?3WX>Sgh>W)@i9Mbu%;@9!ej$Coe?f0?uy5B`(SGykW z#yV2DY5P`JL|ScsH&=D$DDPP8r=;mEQvqd(MCx$8#$Q&NKe2b+Z>&3_bwX%kT;|}f zu1`ADmN-@-{*5s zVFoSwhKHw;U0Bdm5gkK5xPI(pis7_=>`nhL8SO$^=~tHpmSKvgL#&9Tas#@JBs0L{ zidt1#V;X!XNh5YL(1CYO<8fHt(p2L;Ol|9+QZ1HHqR)%%Hz{vn)W3Q`XGMu@eb~`# zr<$~;j*rLV?8)|IhOzO1K^^1D@WZS}o&AGZiyKSwB6ss_EHWJ?|4v?%sDHCoN0LP3 zYj5vLhtqj?l^RrGNEybc?1v^pSH04@!kyNnWkQJW?k~s^K9&v)u%0GZZ zMAwRinhT{m><2ofTt;eM0N-3QAl_V4Hfj`7RC@ebO?XDD`{rei!l^2)vq5*qOU@pi z@pyI1`h*?MV9s2G;Q;#Y6pI$^3(P+m6ws3=7rpN^O*=(-u3^;Ye4VBsZPGqKQ{$<_kf z7slHd@=`Z+$ulB%@E2xt9QTy$z81VgW{I9K25tF~wPssrVgi3U>{oo(mdUlQ)R+3AXK=33+SU!Iuwq37>d7 posBR.x) { - line += 1; - row = 0; - pos = cc.pAdd(beginPos, cc.p(posStep.x * row, posStep.y * line)); - } - row += 1; - menuItem.x = pos.x; - menuItem.y = pos.y; - } - - var label = cc.LabelTTF.create("Reload all plugins", "Arial", 24); - var menuItem = cc.MenuItemLabel.create(label, this.reloadPluginMenuCallback, this); - menuItem.setAnchorPoint(0.5, 0); - pMenu.addChild(menuItem, 0); - menuItem.x = posBC.x; - menuItem.y = posBC.y; - }, - //a selector callback - menuCloseCallback: function (sender) { - MySocialManager.getInstance().unloadSocialPlugin(); - MySocialManager.getInstance().loadSocialPlugin(); - }, - eventMenuCallback: function (sender) { - var info = {}; - info["SharedText"] = "Share message : HelloSocial!"; - info["SharedImagePath"] = "http://www.cocos2d-x.org/images/banner-left.png"; - info["SharedURLPath"] = "http://www.cocos2d-x.org"; - - var mode = sender.getTag() - TAG_SHARE_BY_SNWEIBO + 1; - MySocialManager.getInstance().shareByMode(info, mode); - }, - reloadPluginMenuCallback: function (sender) { - MySocialManager.purgeManager(); - } -}); - -var MyScene = cc.Scene.extend({ - onEnter: function () { - this._super(); - var layer = new MyLayer(); - this.addChild(layer); - layer.init(); - } -}); diff --git a/extensions/pluginx/samples/HelloSocial/src/resource.js b/extensions/pluginx/samples/HelloSocial/src/resource.js deleted file mode 100644 index e2b1500aa3..0000000000 --- a/extensions/pluginx/samples/HelloSocial/src/resource.js +++ /dev/null @@ -1,19 +0,0 @@ -var s_CloseNormal = "res/CloseNormal.png"; -var s_CloseSelected = "res/CloseSelected.png"; -var s_Background = "res/Background.png"; -var s_qzone = "res/qzone.gif"; -var s_snweibo = "res/snweibo.gif"; -var s_qqweibo = "res/qqweibo.gif"; -var s_facebook = "res/facebook.gif"; -var s_twitter = "res/twitter.gif"; - -var g_ressources = [ - {src:s_CloseNormal}, - {src:s_CloseSelected}, - {src:s_Background}, - {src:s_qzone}, - {src:s_facebook}, - {src:s_twitter}, - {src:s_qqweibo}, - {src:s_snweibo} -]; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 9b05e274dd..c2a80c9cac 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -365,24 +365,9 @@ "pluginx" : [ "core", - "extensions/pluginx/protocols/Config.js", - "extensions/pluginx/protocols/PluginUtils.js", - "extensions/pluginx/protocols/PluginProtocol.js", - "extensions/pluginx/protocols/ProtocolSocial.js", - "extensions/pluginx/protocols/ProtocolAds.js", - "extensions/pluginx/protocols/ProtocolAnalytics.js", - - "extensions/pluginx/protocols/PluginFactory.js", - "extensions/pluginx/protocols/PluginManager.js", - - - "extensions/pluginx/plugins/SocialWeibo.js", - "extensions/pluginx/plugins/SocialQQWeibo.js", - "extensions/pluginx/plugins/SocialQzone.js", - "extensions/pluginx/plugins/SocialTwitter.js", - "extensions/pluginx/plugins/SocialFacebook.js", - - "extensions/pluginx/plugins/AnalyticsFlurry.js" + "extensions/pluginx/Plugin.js", + "extensions/pluginx/platform/facebook_sdk.js", + "extensions/pluginx/platform/facebook.js" ], "spine":[ "core", From 66032145e37b67f3aa6b0aaac613c138d628a4c8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Jun 2014 13:46:05 +0800 Subject: [PATCH 0198/1564] Issue #5625: Fixed a bug that cc._formatString may be wrong --- CCDebugger.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CCDebugger.js b/CCDebugger.js index 46bf66c6cc..97f7d9131e 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -267,7 +267,11 @@ cc._logToWebPage = function (msg) { //to make sure the cc.log, cc.warn, cc.error and cc.assert would not throw error before init by debugger mode. cc._formatString = function(arg){ if(typeof arg === 'object'){ - return JSON.stringify(arg); + try{ + return JSON.stringify(arg); + }catch(err){ + return ""; + } }else{ return arg; } From e6938a4597e1d4e6bbd70e3472158610fb3bfd39 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 30 Jun 2014 16:52:17 +0800 Subject: [PATCH 0199/1564] Fixed #5626: call setUpdateEnabled(false) in onExit function --- extensions/ccui/uiwidgets/UITextField.js | 5 +++++ extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 5 +++++ extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 9e67344ae0..7811481d31 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -284,6 +284,11 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setUpdateEnabled(true); }, + onExit:function(){ + this.setUpdateEnabled(false); + ccui.Layout.prototype.onExit.call(this); + }, + initRenderer: function () { this._textFieldRender = ccui.UICCTextField.create("input words here", "Thonburi", 20); cc.Node.prototype.addChild.call(this, this._textFieldRender, ccui.TextField.RENDERER_ZORDER, -1); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 3b01e8f9e4..f8b5c8095f 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -91,6 +91,11 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this.setUpdateEnabled(true); }, + onExit:function(){ + this.setUpdateEnabled(false); + ccui.Layout.prototype.onExit.call(this); + }, + /** * Add a widget to a page of pageview. * @param {ccui.Widget} widget diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 3ff57c850c..615b68c7ab 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -137,6 +137,11 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.setUpdateEnabled(true); }, + onExit:function(){ + this.setUpdateEnabled(false); + ccui.Layout.prototype.onExit.call(this); + }, + initRenderer: function () { ccui.Layout.prototype.initRenderer.call(this); this._innerContainer = ccui.Layout.create(); From c66ff8754cd07b05a64a19dbbf13c2484c86e4ba Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Jun 2014 16:56:37 +0800 Subject: [PATCH 0200/1564] Issue #5627: Keyboard failure in the ie11 --- cocos2d/core/platform/CCInputManager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 002bd0e41b..02e07c7842 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -445,7 +445,6 @@ cc.inputManager = /** @lends cc.inputManager# */{ _touchEvent.call(selfPointer, [selfPointer.getTouchByXY(event.clientX, event.clientY, pos)]); event.stopPropagation(); - event.preventDefault(); }, false); })(eventName, _pointerEventsMap[eventName]); } From be9c90963e184178c6d2c395db294b55d6ac40ec Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 30 Jun 2014 17:07:59 +0800 Subject: [PATCH 0201/1564] Issue #5600: migrate ccui.Widget and ccui.Layout --- cocos2d/core/base-nodes/CCNode.js | 4 + .../ccui/base-classes/CCProtectedNode.js | 44 +- extensions/ccui/base-classes/UIWidget.js | 442 ++++--- extensions/ccui/layouts/UILayout.js | 1048 ++++++++++++++--- extensions/ccui/layouts/UILayoutDefine.js | 115 -- extensions/ccui/layouts/UILayoutManager.js | 460 ++++++++ extensions/ccui/layouts/UILayoutParameter.js | 119 +- extensions/ccui/system/CocosGUI.js | 18 + extensions/ccui/system/UIHelper.js | 2 - .../uiwidgets/scroll-widget/UIListView.js | 26 +- moduleConfig.json | 3 +- tools/build.xml | 2 +- tools/jsdoc_toolkit/build.xml | 2 +- 13 files changed, 1803 insertions(+), 482 deletions(-) delete mode 100644 extensions/ccui/layouts/UILayoutDefine.js create mode 100644 extensions/ccui/layouts/UILayoutManager.js diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index ccbfe2bd68..db19443fba 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2271,6 +2271,10 @@ cc.NodeRGBA = cc.Node.extend(/** @lends cc.NodeRGBA# */{ this._cascadeOpacityEnabled = false; }, + _updateColor: function(){ + //TODO + }, + /** * Get the opacity of Node * @returns {number} opacity diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index a2b5afda8a..d84ef2429a 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -33,6 +33,7 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod }, ctor: function(){ + cc.NodeRGBA.prototype.ctor.call(this); this._protectedChildren = []; }, @@ -45,7 +46,7 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod */ addProtectedChild: function(child, localZOrder, tag){ cc.assert(child != null, "child must be non-nil"); - cc.assert(child.parent, "child already added. It can't be added again"); + cc.assert(!child.parent, "child already added. It can't be added again"); localZOrder = localZOrder || child.getLocalZOrder(); if(tag) @@ -64,9 +65,9 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod child.onEnterTransitionDidFinish(); } if(this._cascadeColorEnabled) - this.updateDisplayedColor(); + this._enableCascadeColor(); if (this._cascadeOpacityEnabled) - this.updateDisplayedOpacity(); + this._enableCascadeOpacity(); }, /** @@ -334,7 +335,7 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod cc.Node.prototype.onEnter.call(this); var locChildren = this._protectedChildren; for(var i = 0, len = locChildren.length;i< len;i++) - locChildren.onEnter(); + locChildren[i].onEnter(); }, /** @@ -348,14 +349,14 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod cc.Node.prototype.onEnterTransitionDidFinish.call(this); var locChildren = this._protectedChildren; for(var i = 0, len = locChildren.length;i< len;i++) - locChildren.onEnterTransitionDidFinish(); + locChildren[i].onEnterTransitionDidFinish(); }, onExit:function(){ cc.Node.prototype.onExit.call(this); var locChildren = this._protectedChildren; for(var i = 0, len = locChildren.length;i< len;i++) - locChildren.onExit(); + locChildren[i].onExit(); }, /** @@ -368,20 +369,25 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod cc.Node.prototype.onExitTransitionDidStart.call(this); var locChildren = this._protectedChildren; for(var i = 0, len = locChildren.length;i< len;i++) - locChildren.onExitTransitionDidStart(); + locChildren[i].onExitTransitionDidStart(); }, updateDisplayedOpacity: function(parentOpacity){ this._displayedOpacity = this._realOpacity * parentOpacity/255.0; - this.updateColor(); + this._updateColor(); if (this._cascadeOpacityEnabled){ var i,len, locChildren = this._children, _opacity = this._displayedOpacity; - for(i = 0, len = locChildren.length;i < len; i++) - locChildren[i].updateDisplayedOpacity(_opacity); + for(i = 0, len = locChildren.length;i < len; i++){ + if(locChildren[i].updateDisplayedOpacity) + locChildren[i].updateDisplayedOpacity(_opacity); + } + locChildren = this._protectedChildren; - for(i = 0, len = locChildren.length;i < len; i++) - locChildren[i].updateDisplayedOpacity(_opacity); + for(i = 0, len = locChildren.length;i < len; i++){ + if(locChildren[i].updateDisplayedOpacity) + locChildren[i].updateDisplayedOpacity(_opacity); + } } }, @@ -390,16 +396,20 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod displayedColor.r = realColor.r * parentColor.r/255.0; displayedColor.g = realColor.g * parentColor.g/255.0; displayedColor.b = realColor.b * parentColor.b/255.0; - this.updateColor(); + this._updateColor(); if (this._cascadeColorEnabled){ var i, len, locChildren = this._children; - for(i = 0, len = locChildren.length; i < len; i++) - locChildren[i].updateDisplayedColor(displayedColor); + for(i = 0, len = locChildren.length; i < len; i++){ + if(locChildren[i].updateDisplayedColor) + locChildren[i].updateDisplayedColor(displayedColor); + } locChildren = this._protectedChildren; - for(i =0, len = locChildren.length; i < len; i++) - locChildren[i].updateDisplayedColor(displayedColor); + for(i =0, len = locChildren.length; i < len; i++) { + if (locChildren[i].updateDisplayedColor) + locChildren[i].updateDisplayedColor(displayedColor); + } } }, diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 27be338c6a..f90adf658d 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -29,7 +29,7 @@ * var uiWidget = ccui.Widget.create(); * this.addChild(uiWidget); * @class - * @extends ccui.Node + * @extends cc.ProtectedNode * * @property {Number} xPercent - Position x in percentage of width * @property {Number} yPercent - Position y in percentage of height @@ -50,8 +50,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ _enabled: true, ///< Highest control of widget _bright: true, ///< is this widget bright _touchEnabled: false, ///< is this widget touch endabled - _touchPassedEnabled: false, ///< is the touch event should be passed - _focus: false, ///< is the widget on focus + _brightStyle: null, ///< bright style _updateEnabled: false, ///< is "update" method scheduled @@ -121,29 +120,34 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {boolean} */ init: function () { - if (cc.Node.prototype.init.call(this)) { + if (cc.ProtectedNode.prototype.init.call(this)) { this._layoutParameterDictionary = {}; this._widgetChildren = []; this.initRenderer(); this.setBright(true); this.ignoreContentAdaptWithSize(true); this.setAnchorPoint(cc.p(0.5, 0.5)); + this.setTouchEnabled(true); + this.setCascadeColorEnabled(true); + this.setCascadeOpacityEnabled(true); } return true; }, onEnter: function () { this.updateSizeAndPosition(); - cc.Node.prototype.onEnter.call(this); + cc.ProtectedNode.prototype.onEnter.call(this); }, onExit: function(){ - + this.unscheduleUpdate(); + cc.ProtectedNode.prototype.onExit.call(this); }, visit: function (ctx) { - if (this._enabled) { - cc.Node.prototype.visit.call(this, ctx); + if (this._visible) { + this.adaptRenderers(); + cc.ProtectedNode.prototype.visit.call(this, ctx); } }, @@ -235,32 +239,62 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ return null; }, - setFocusEnabled: function(enable){ - this._focusEnabled = enable; - }, - - isFocusEnabled: function(){ - return this._focusEnabled; - }, - _updateContentSizeWithTextureSize: function(size){ - + var locSize = this._size; + if (this._ignoreSize) { + locSize.width = size.width; + locSize.height = size.height; + } else { + locSize.width = this._customSize.width; + locSize.height = this._customSize.height; + } + this.onSizeChanged(); }, _isAncestorsEnabled: function(){ + var parentWidget = this._getAncensterWidget(this); + if (parentWidget == null) + return true; + if (parentWidget && !parentWidget.isEnabled()) + return false; + return parentWidget._isAncestorsEnabled(); }, _getAncensterWidget: function(node){ + if (null == node) + return null; + + var parent = node.getParent(); + if (null == parent) + return null; + if (parent instanceof ccui.Widget) + return parent; + else + return this._getAncensterWidget(parent.getParent()); }, _isAncestorsVisible: function(node){ + if (null == node) + return true; + + var parent = node.getParent(); + if (parent && !parent.isVisible()) + return false; + return this._isAncestorsVisible(parent); }, _cleanupWidget: function(){ + //clean up _touchListener + this._eventDispatcher.removeEventListener(this._touchListener); + //cleanup focused widget and focus navigation controller + if (this._focusedWidget == this){ + //delete + this._focusedWidget = null; + } }, /** @@ -309,12 +343,13 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setEnabled: function (enabled) { this._enabled = enabled; - var arrayChildren = this._widgetChildren; + //TODO need test +/* var arrayChildren = this._widgetChildren; var childrenCount = arrayChildren.length; for (var i = 0; i < childrenCount; i++) { var child = arrayChildren[i]; child.setEnabled(enabled); - } + }*/ }, /** @@ -523,51 +558,34 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Size} [parentSize] parent size */ updateSizeAndPosition: function (parentSize) { + if(!parentSize){ + var widgetParent = this.getWidgetParent(); + if(widgetParent) + parentSize = widgetParent.getLayoutSize(); + else + parentSize = this._parent.getContentSize(); + } + + var locSize; switch (this._sizeType) { case ccui.Widget.SIZE_ABSOLUTE: - var locSize; - if (this._ignoreSize) { - locSize = this.getContentSize(); - } - else { - locSize = this._customSize; - } + locSize = this._ignoreSize? this.getContentSize():this._customSize; this._size.width = locSize.width; this._size.height = locSize.height; - var pSize, spx = 0, spy = 0; - var widgetParent = this.getWidgetParent(); - if (widgetParent) { - pSize = widgetParent.getSize(); - } else { - pSize = this._parent.getContentSize(); - } - if (pSize.width > 0) { - spx = this._customSize.width / pSize.width; + var spx = 0, spy = 0; + if (parentSize.width > 0) { + spx = this._customSize.width / parentSize.width; } - if (pSize.height > 0) { - spy = this._customSize.height / pSize.height; + if (parentSize.height > 0) { + spy = this._customSize.height / parentSize.height; } this._sizePercent.x = spx; this._sizePercent.y = spy; break; case ccui.Widget.SIZE_PERCENT: - var widgetParent = this.getWidgetParent(); - 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 { - cSize.width = this._parent.getContentSize().width * this._sizePercent.x; - cSize.height = this._parent.getContentSize().height * this._sizePercent.y; - } - var locSize; - if (this._ignoreSize) { - locSize = this.getContentSize(); - } - else { - locSize = cSize; - } + var cSize = cc.size(parentSize.width * this._sizePercent.x , parentSize.height * this._sizePercent.y); + locSize = this._ignoreSize? this.getVirtualRendererSize(): cSize; this._size.width = locSize.width; this._size.height = locSize.height; this._customSize.width = cSize.width; @@ -580,30 +598,16 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ var absPos = this.getPosition(); switch (this.positionType) { case ccui.Widget.POSITION_ABSOLUTE: - var widgetParent = this.getWidgetParent(); - var pSize; - if (widgetParent) { - pSize = widgetParent.getSize(); - } else { - pSize = this._parent.getContentSize(); - } - if (pSize.width <= 0 || pSize.height <= 0) { + if (parentSize.width <= 0 || parentSize.height <= 0) { this._positionPercent.x = 0; this._positionPercent.y = 0; } else { - this._positionPercent.x = absPos.x / pSize.width; - this._positionPercent.y = absPos.y / pSize.height; + this._positionPercent.x = absPos.x / parentSize.width; + this._positionPercent.y = absPos.y / parentSize.height; } break; case ccui.Widget.POSITION_PERCENT: - var widgetParent = this.getWidgetParent(); - var pSize; - if (widgetParent) { - pSize = widgetParent.getSize(); - } else { - pSize = this._parent.getContentSize(); - } - absPos = cc.p(pSize.width * this._positionPercent.x, pSize.height * this._positionPercent.y); + absPos = cc.p(parentSize.width * this._positionPercent.x, parentSize.height * this._positionPercent.y); break; default: break; @@ -632,14 +636,11 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} ignore true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ ignoreContentAdaptWithSize: function (ignore) { + if(this._ignoreSize == ignore) + return; + this._ignoreSize = ignore; - var locSize; - if (this._ignoreSize) { - locSize = this.getContentSize(); - } - else { - locSize = this._customSize; - } + var locSize = this._ignoreSize ? this.getContentSize(): this._customSize; this._size.width = locSize.width; this._size.height = locSize.height; this.onSizeChanged(); @@ -678,7 +679,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Point} */ getSizePercent: function () { - return this._sizePercent; + return cc.p(this._sizePercent); }, _getWidthPercent: function () { return this._sizePercent.x; @@ -692,12 +693,12 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Point} world position of widget. */ getWorldPosition: function () { - return this.convertToWorldSpace(cc.p(0, 0)); + return this.convertToWorldSpace(cc.p(this._anchorPoint.x * this._contentSize.width, this._anchorPoint.y * this._contentSize.height)); }, /** * Gets the Virtual Renderer of widget. - * @returns {cc.Node} + * @returns {ccui.Widget} */ getVirtualRenderer: function () { return this; @@ -707,16 +708,19 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * Gets the content size of widget. Content size is widget's texture size. */ getVirtualRendererSize:function(){ - + return cc.size(this._contentSize); }, /** * call back function called when size changed. */ onSizeChanged: function () { - for (var i = 0; i < this._widgetChildren.length; i++) { - var child = this._widgetChildren[i]; - child.updateSizeAndPosition(); + this.setContentSize(this._size); + var locChildren = this.getChildren(); + for (var i = 0, len = locChildren.length; i < len; i++) { + var child = locChildren[i]; + if(child) + child.updateSizeAndPosition(); } }, @@ -770,7 +774,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {boolean} true if the widget is highlighted, false if the widget is not highlighted . */ isHighlighted: function(){ - return true; + return this._highlight; }, /** @@ -778,7 +782,16 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param highlight true if the widget is highlighted, false if the widget is not highlighted. */ setHighlighted:function(highlight){ - + if (highlight == this._highlight) + return; + this._highlight = highlight; + if (this._bright) { + if (this._highlight) + this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT); + else + this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL); + } else + this.onPressStateChangedToDisabled(); }, /** @@ -811,7 +824,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {boolean} whether the widget is focused or not */ isFocused: function () { - return this._focus; + return this._focused; }, /** @@ -820,20 +833,10 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {boolean} focus pass true to let the widget get focus or pass false to let the widget lose focus */ setFocused: function (focus) { - if (focus == this._focus) { - return; - } this._focus = focus; - if (this._bright) { - if (this._focus) { - this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT); - } - else { - this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL); - } - } - else { - this.onPressStateChangedToDisabled(); + //make sure there is only one focusedWidget + if (focus) { + this._focusedWidget = this; } }, @@ -842,7 +845,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {boolean} true represent the widget could accept focus, false represent the widget couldn't accept focus */ isFocusEnabled: function(){ - return true; + return this._focusEnabled; }, /** @@ -850,7 +853,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} enable true represent the widget could accept focus, false represent the widget couldn't accept focus */ setFocusEnabled: function(enable){ - + this._focused = enable; }, /** @@ -863,35 +866,70 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @return the next focused widget in a layout */ findNextFocusedWidget: function( direction, current){ - + if (null == this.onNextFocusedWidget || null == this.onNextFocusedWidget(direction) ) { + var isLayout = current instanceof ccui.Layout; + if (this.isFocused() || isLayout) { + var layout = this.getParent(); + if (null == layout){ + //the outer layout's default behaviour is : loop focus + if (isLayout) + return current.findNextFocusedWidget(direction, current); + return current; + } else { + return layout.findNextFocusedWidget(direction, current); + } + } else + return current; + } else { + var getFocusWidget = this.onNextFocusedWidget(direction); + this.dispatchFocusEvent(this, getFocusWidget); + return getFocusWidget; + } }, /** * when a widget calls this method, it will get focus immediately. */ requestFocus: function(){ - + if (this == this._focusedWidget) + return; + this.dispatchFocusEvent(this._focusedWidget, this); }, /** * no matter what widget object you call this method on , it will return you the exact one focused widget */ getCurrentFocusedWidget: function(){ - + return this._focusedWidget; }, /** * call this method with parameter true to enable the Android Dpad focus navigation feature + * @note it doesn't implemented on Web * @param {Boolean} enable set true to enable dpad focus navigation, otherwise disable dpad focus navigation */ enableDpadNavigation: function(enable){ - + // + /*if (enable) { + if (nullptr == _focusNavigationController) + { + _focusNavigationController = new FocusNavigationController; + if (_focusedWidget) { + _focusNavigationController.setFirstFocsuedWidget(_focusedWidget); + } + } + } + else + { + CC_SAFE_DELETE(_focusNavigationController); + } + _focusNavigationController.enableFocusNavigation(enable);*/ }, /** *

* When a widget lose/get focus, this method will be called. Be Caution when you provide your own version,
- * you must call widget->setFocused(true/false) to change the focus state of the current focused widget; + * you must call widget.setFocused(true/false) to change the focus state of the current focused widget; *

*/ onFocusChanged: null, @@ -908,7 +946,9 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Touch} touch */ interceptTouchEvent: function(eventType, sender, touch){ - + var widgetParent = this.getWidgetParent(); + if (widgetParent) + widgetParent.interceptTouchEvent(eventType,sender,touch); }, /** @@ -917,7 +957,12 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {ccui.Widget} widgetGetFocus */ onFocusChange: function(widgetLostFocus, widgetGetFocus){ + //only change focus when there is indeed a get&lose happens + if (widgetLostFocus) + widgetLostFocus.setFocused(false); + if (widgetGetFocus) + widgetGetFocus.setFocused(true); }, /** @@ -926,7 +971,19 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {ccui.Widget} widgetGetFocus */ dispatchFocusEvent: function(widgetLostFocus, widgetGetFocus){ + //if the widgetLoseFocus doesn't get focus, it will use the previous focused widget instead + if (widgetLostFocus && !widgetLostFocus.isFocused()) + widgetLostFocus = this._focusedWidget; + + if (widgetGetFocus != widgetLostFocus){ + if (widgetGetFocus) + widgetGetFocus.onFocusChanged(widgetLostFocus, widgetGetFocus); + if (widgetLostFocus) + widgetLostFocus.onFocusChanged(widgetLostFocus, widgetGetFocus); + + cc.eventManager.dispatchEvent(new cc.EventFocus(widgetLostFocus, widgetGetFocus)); + } }, /** @@ -945,7 +1002,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * To set the bright style of widget. - * @param {ccui.Widget.BRIGHT_STYLE_NONE|ccui.Widget.BRIGHT_STYLE_NORMAL|ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT} style BRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state. + * @param {Number} style BRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state. */ setBrightStyle: function (style) { if (this._brightStyle == style) { @@ -990,51 +1047,50 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, onTouchBegan: function (touch, event) { - var touchPoint = touch.getLocation(); - this._touchBeganPosition.x = touchPoint.x; - this._touchBeganPosition.y = touchPoint.y; - this._hitted = this.isEnabled() && this.isTouchEnabled() && this.hitTest(touchPoint) && this.isClippingParentContainsPoint(touchPoint); + this._hitted = false; + if (this.isVisible() && this.isEnabled() && this._isAncestorsEnabled() && this._isAncestorsVisible(this) ){ + var touchPoint = touch.getLocation(); + this._touchBeganPosition.x = touchPoint.x; + this._touchBeganPosition.y = touchPoint.y; + if(this.hitTest(this._touchBeganPosition) && this.isClippingParentContainsPoint(this._touchBeganPosition)) + this._hitted = true; + } if (!this._hitted) { return false; } - this.setFocused(true); + this.setHighlighted(true); var widgetParent = this.getWidgetParent(); if (widgetParent) { - widgetParent.checkChildInfo(0, this, touchPoint); + widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_BAGAN, this, touch); } this.pushDownEvent(); - return !this._touchPassedEnabled; + return true; }, onTouchMoved: function (touch, event) { var touchPoint = touch.getLocation(); this._touchMovePosition.x = touchPoint.x; this._touchMovePosition.y = touchPoint.y; - this.setFocused(this.hitTest(touchPoint)); + this.setHighlighted(this.hitTest(touchPoint)); var widgetParent = this.getWidgetParent(); - if (widgetParent) { - widgetParent.checkChildInfo(1, this, touchPoint); - } + if (widgetParent) + widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touchPoint); this.moveEvent(); }, - onTouchEnded: function (touch, event) { var touchPoint = touch.getLocation(); this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; - var focus = this._focus; - this.setFocused(false); var widgetParent = this.getWidgetParent(); - if (widgetParent) { - widgetParent.checkChildInfo(2, this, touchPoint); - } - if (focus) { + if (widgetParent) + widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_ENDED, this, touch); + var highlight = this._highlight; + this.setHighlighted(false); + if (highlight) this.releaseUpEvent(); - } - else { + else this.cancelUpEvent(); - } }, /** @@ -1042,7 +1098,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Point} touchPoint */ onTouchCancelled: function (touchPoint) { - this.setFocused(false); + this.setHighlighted(false); this.cancelUpEvent(); }, @@ -1055,8 +1111,10 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, //call back function called widget's state changed to dark. - pushDownEvent: function () { + if (this._touchEventCallback) + this._touchEventCallback(this, ccui.Widget.TOUCH_BAGAN); + if (this._touchEventListener && this._touchEventSelector) { if (this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN); @@ -1064,6 +1122,9 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, moveEvent: function () { + if (this._touchEventCallback) + this._touchEventCallback(this, ccui.Widget.TOUCH_MOVED); + if (this._touchEventListener && this._touchEventSelector) { if (this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_MOVED); @@ -1071,6 +1132,9 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, releaseUpEvent: function () { + if (this._touchEventCallback) + this._touchEventCallback(this, ccui.Widget.TOUCH_ENDED); + if (this._touchEventListener && this._touchEventSelector) { if (this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED); @@ -1078,8 +1142,12 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, cancelUpEvent: function () { + if (this._touchEventCallback) + this._touchEventCallback(this, ccui.Widget.TOUCH_CANCELED); + if (this._touchEventSelector) { - this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_CANCELED); + if (this._touchEventSelector) + this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_CANCELED); } }, @@ -1093,19 +1161,25 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Object} target */ addTouchEventListener: function (selector, target) { - this._touchEventSelector = selector; - this._touchEventListener = target; + if(target === undefined) + this._touchEventCallback = selector; + else { + this._touchEventSelector = selector; + this._touchEventListener = target; + } }, /** * Checks a point if is in widget's space * @param {cc.Point} pt - * @returns {boolean} true if the point is in widget's space, flase otherwise. + * @returns {boolean} true if the point is in widget's space, false otherwise. */ hitTest: function (pt) { - var nsp = this.convertToNodeSpace(pt); - var bb = cc.rect(-this._size.width * this._anchorPoint.x, -this._size.height * this._anchorPoint.y, this._size.width, this._size.height); - return (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height); + //TODO need test +/* var bb = cc.rect(-this._size.width * this._anchorPoint.x, -this._size.height * this._anchorPoint.y, this._size.width, this._size.height); + return (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height);*/ + var bb = cc.rect(0,0, this._contentSize.width, this._contentSize.height); + return cc.rectContainsPoint(bb, this.convertToNodeSpace(pt)); }, isClippingParentContainsPoint: function(pt){ @@ -1123,19 +1197,12 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ parent = parent.getParent(); } - if (!this._affectByClipping) { + if (!this._affectByClipping) return true; - } - if (clippingParent) { - var bRet = false; - if (clippingParent.hitTest(pt)) { - bRet = true; - } - if (bRet) { + if (clippingParent.hitTest(pt)) return clippingParent.clippingParentAreaContainPoint(pt); - } return false; } return true; @@ -1169,7 +1236,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * Changes the position (x,y) of the widget . * The original point (0,0) is at the left-bottom corner of screen. * @param {cc.Point||Number} pos - * @param {Number} posY + * @param {Number} [posY] */ setPosition: function (pos, posY) { if (this._running) { @@ -1191,7 +1258,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ } } - cc.Node.prototype.setPosition.apply(this, arguments); + cc.Node.prototype.setPosition.call(this, pos, posY); }, setPositionX: function (x) { @@ -1241,20 +1308,16 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._positionPercent.x = percent; if (this._running) { var widgetParent = this.getWidgetParent(); - if (widgetParent) { - var absX = widgetParent.width * percent; - this.setPositionX(absX); - } + if (widgetParent) + this.setPositionX(widgetParent.width * percent); } }, _setYPercent: function (percent) { this._positionPercent.y = percent; if (this._running) { var widgetParent = this.getWidgetParent(); - if (widgetParent) { - var absY = widgetParent.height * percent; - this.setPositionY(absY); - } + if (widgetParent) + this.setPositionY(widgetParent.height * percent); } }, @@ -1267,7 +1330,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Point} The percent (x,y) of the widget in OpenGL coordinates */ getPositionPercent: function () { - return this._positionPercent; + return cc.p(this._positionPercent); }, _getXPercent: function () { @@ -1279,7 +1342,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Changes the position type of the widget - * @param {ccui.Widget.POSITION_ABSOLUTE|ccui.Widget.POSITION_PERCENT} type the position type of widget + * @param {Number} type the position type of widget */ setPositionType: function (type) { this.positionType = type; @@ -1287,7 +1350,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Gets the position type of the widget - * @returns {ccui.Widget.POSITION_ABSOLUTE|ccui.Widget.POSITION_PERCENT} the position type of widget + * @returns {Number} the position type of widget */ getPositionType: function () { return this.positionType; @@ -1295,7 +1358,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Sets whether the widget should be flipped horizontally or not. - * @param {Boolean} flipX true if the widget should be flipped horizaontally, false otherwise. + * @param {Boolean} flipX true if the widget should be flipped horizontally, false otherwise. */ setFlippedX: function (flipX) { this._flippedX = flipX; @@ -1308,7 +1371,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * It only flips the texture of the widget, and not the texture of the widget's children.
* Also, flipping the texture doesn't alter the anchorPoint.
* If you want to flip the anchorPoint too, and/or to flip the children too use:
- * widget->setScaleX(sprite->getScaleX() * -1); + * widget.setScaleX(sprite.getScaleX() * -1); *

* @returns {Boolean} true if the widget is flipped horizontally, false otherwise. */ @@ -1331,7 +1394,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * It only flips the texture of the widget, and not the texture of the widget's children.
* Also, flipping the texture doesn't alter the anchorPoint.
* If you want to flip the anchorPoint too, and/or to flip the children too use:
- * widget->setScaleY(widget->getScaleY() * -1); + * widget.setScaleY(widget.getScaleY() * -1); *

* @returns {Boolean} true if the widget is flipped vertically, false otherwise. */ @@ -1467,7 +1530,10 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {ccui.LayoutParameter} parameter */ setLayoutParameter: function (parameter) { + if(!parameter) + return; this._layoutParameterDictionary[parameter.getLayoutType()] = parameter; + this._layoutParameterType = parameter.getLayoutType(); }, /** @@ -1476,6 +1542,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {ccui.LayoutParameter} */ getLayoutParameter: function (type) { + type = type || this._layoutParameterType; return this._layoutParameterDictionary[type]; }, @@ -1517,20 +1584,28 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setVisible(widget.isVisible()); this.setBright(widget.isBright()); this.setTouchEnabled(widget.isTouchEnabled()); - this._touchPassedEnabled = false; this.setLocalZOrder(widget.getLocalZOrder()); this.setUpdateEnabled(widget.isUpdateEnabled()); this.setTag(widget.getTag()); this.setName(widget.getName()); this.setActionTag(widget.getActionTag()); - this._ignoreSize = widget._ignoreSize; - this._size = cc.size(widget._size.width, widget._size.height); - this._customSize = cc.size(widget._customSize.width, widget._customSize.height); + + this._ignoreSize.width = widget._ignoreSize.width; + this._ignoreSize.height = widget._ignoreSize.height; + this._size.width = widget._size.width; + this._size.height = widget._size.height; + this._customSize.width = widget._customSize.width; + this._customSize.height = widget._customSize.height; + this.copySpecialProperties(widget); this._sizeType = widget.getSizeType(); - this._sizePercent = cc.p(widget._sizePercent.x, widget._sizePercent.y); + this._sizePercent.x = widget._sizePercent.x; + this._sizePercent.y = widget._sizePercent.y; + this.positionType = widget.positionType; - this._positionPercent = cc.p(widget._positionPercent.x, widget._positionPercent.y); + this._positionPercent.x = widget._positionPercent.x; + this._positionPercent.y = widget._positionPercent.y; + this.setPosition(widget.getPosition()); this.setAnchorPoint(widget.getAnchorPoint()); this.setScaleX(widget.getScaleX()); @@ -1542,6 +1617,13 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setFlippedY(widget.isFlippedY()); this.setColor(widget.getColor()); this.setOpacity(widget.getOpacity()); + + this._touchEventCallback = widget._touchEventCallback; + this._touchEventListener = widget._touchEventListener; + this._touchEventSelector = widget._touchEventSelector; + this._focused = widget._focused; + this._focusEnabled = widget._focusEnabled; + for (var key in widget._layoutParameterDictionary) { var parameter = widget._layoutParameterDictionary[key]; if (parameter) @@ -1595,7 +1677,8 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {Number} */ getOpacity: function () { - return this._color.a; + //return this._color.a; //TODO + return this._displayedOpacity; }, updateTextureColor: function () { @@ -1605,10 +1688,8 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ updateTextureOpacity: function (opacity) { for(var p in this._children){ var item = this._children[p]; - if(item && item.RGBAProtocol){ + if(item && item.RGBAProtocol) item.setOpacity(opacity); - } - } }, @@ -1727,4 +1808,13 @@ ccui.Widget.SIZE_PERCENT = 1; //position type ccui.Widget.POSITION_ABSOLUTE = 0; -ccui.Widget.POSITION_PERCENT = 1; \ No newline at end of file +ccui.Widget.POSITION_PERCENT = 1; + +cc.EventFocus = cc.Event.extend({ + _widgetGetFocus: null, + _widgetLoseFocus: null, + ctor: function(widgetLoseFocus, widgetGetFocus){ + this._widgetGetFocus = widgetGetFocus; + this._widgetLoseFocus = widgetLoseFocus; + } +}); \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 140b732fac..a212a28599 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -34,7 +34,7 @@ * */ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ - _clippingEnabled: null, + _clippingEnabled: false, _backGroundScale9Enabled: null, _backGroundImage: null, _backGroundImageFileName: null, @@ -62,6 +62,30 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _backGroundImageColor: null, _finalPositionX: 0, _finalPositionY: 0, + + //clipping + _currentStencilEnabled: 0, + _currentStencilWriteMask: 0, + _currentStencilFunc: 0, + _currentStencilRef:0, + _currentStencilValueMask:0, + _currentStencilFail:0, + _currentStencilPassDepthFail:0, + _currentStencilPassDepthPass:0, + _currentDepthWriteMask:0, + + _currentAlphaTestEnabled:0, + _currentAlphaTestFunc:0, + _currentAlphaTestRef:0, + + _backGroundImageOpacity:0, + + _mask_layer_le: 0, + + _loopFocus: false, + _passFocusToChild: false, + _isFocusPassing:false, + /** * allocates and initializes a UILayout. * Constructor of ccui.Layout @@ -96,16 +120,123 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._clippingStencil) this._clippingStencil.onExit(); }, + + /** + * If a layout is loop focused which means that the focus movement will be inside the layout + * @param {Boolean} loop pass true to let the focus movement loop inside the layout + */ + setLoopFocus: function(loop){ + this._loopFocus = loop; + }, + + /** + * Gets whether enable focus loop + * @returns {boolean} If focus loop is enabled, then it will return true, otherwise it returns false. The default value is false. + */ + isLoopFocus: function(){ + return this._loopFocus; + }, + + /** + * @param pass To specify whether the layout pass its focus to its child + */ + setPassFocusToChild: function(pass){ + this._passFocusToChild = pass; + }, + + /** + * @returns {boolean} To query whether the layout will pass the focus to its children or not. The default value is true + */ + isPassFocusToChild: function(){ + return this._passFocusToChild; + }, + + /** + * When a widget is in a layout, you could call this method to get the next focused widget within a specified direction. + * If the widget is not in a layout, it will return itself + * @param direction the direction to look for the next focused widget in a layout + * @param current the current focused widget + * @returns {ccui.Widget} return the index of widget in the layout + */ + findNextFocusedWidget: function(direction, current){ + if (this._isFocusPassing || this.isFocused()) { + var parent = this.getParent(); + this._isFocusPassing = false; + + if (this._passFocusToChild) { + var w = this._passFocusToChild(direction, current); + if (w instanceof ccui.Layout && parent) { + parent._isFocusPassing = true; + return parent.findNextFocusedWidget(direction, this); + } + return w; + } + + if (null == parent) + return this; + parent._isFocusPassing = true; + return parent.findNextFocusedWidget(direction, this); + } else if(current.isFocused() || current instanceof ccui.Layout) { + if (this._layoutType == ccui.Layout.LINEAR_HORIZONTAL) { + switch (direction){ + case ccui.Widget.LEFT: + return this._getPreviousFocusedWidget(direction, current); + break; + case ccui.Widget.RIGHT: + return this._getNextFocusedWidget(direction, current); + break; + case ccui.Widget.DOWN: + case ccui.Widget.UP: + if (this._isLastWidgetInContainer(this, direction)){ + if (this._isWidgetAncestorSupportLoopFocus(current, direction)) + return this.findNextFocusedWidget(direction, this); + return current; + } else { + return this.findNextFocusedWidget(direction, this); + } + break; + default: + cc.assert(0, "Invalid Focus Direction"); + return current; + } + } else if (this._layoutType == ccui.Layout.LINEAR_VERTICAL) { + switch (direction){ + case ccui.Widget.LEFT: + case ccui.Widget.RIGHT: + if (this._isLastWidgetInContainer(this, direction)) { + if (this._isWidgetAncestorSupportLoopFocus(current, direction)) + return this.findNextFocusedWidget(direction, this); + return current; + } + else + return this.findNextFocusedWidget(direction, this); + break; + case ccui.Widget.DOWN: + return this._getNextFocusedWidget(direction, current); + break; + case ccui.Widget.UP: + return this._getPreviousFocusedWidget(direction, current); + break; + default: + cc.assert(0, "Invalid Focus Direction"); + return current; + } + } else { + cc.assert(0, "Un Supported Layout type, please use VBox and HBox instead!!!"); + return current; + } + } else + return current; + }, + + onPassFocusToChild: null, + init: function () { - if (cc.Node.prototype.init.call(this)) { - this._layoutParameterDictionary = {}; - this._widgetChildren = []; - this.initRenderer(); - this.setBright(true); + if (ccui.Widget.prototype.init.call(this)) { this.ignoreContentAdaptWithSize(false); this.setSize(cc.size(0, 0)); this.setAnchorPoint(0, 0); - this.initStencil(); + this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); return true; } return false; @@ -142,20 +273,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Adds a widget to the container. * @param {ccui.Widget} widget - * @param {Number} zOrder - * @param {Number} tag + * @param {Number} [zOrder] + * @param {Number} [tag] */ addChild: function (widget, zOrder, tag) { - if (!(widget instanceof ccui.Widget)) { - throw "the child add to Layout must a type of cc.Widget"; + if ((widget instanceof ccui.Widget)) { + this.supplyTheLayoutParameterLackToChild(widget); } - this.supplyTheLayoutParameterLackToChild(widget); ccui.Widget.prototype.addChild.call(this, widget, zOrder, tag); this._doLayoutDirty = true; }, /** - * Remove widget + * Remove child widget from ccui.Layout * @param {ccui.Widget} widget * @param {Boolean} cleanup */ @@ -165,13 +295,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Remove all widget + * Removes all children from the container with a cleanup. * @param {Boolean} cleanup */ removeAllChildren: function (cleanup) { ccui.Widget.prototype.removeAllChildren.call(this, cleanup); + this._doLayoutDirty = true; }, + /** + * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. + * @param {Boolean} cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + */ removeAllChildrenWithCleanup: function(cleanup){ ccui.Widget.prototype.removeAllChildrenWithCleanup(cleanup); this._doLayoutDirty = true; @@ -186,9 +321,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, visit: function (ctx) { - if (!this._enabled) { + if (!this._visible) return; - } + this.adaptRenderers(); + this._doLayout(); + if (this._clippingEnabled) { switch (this._clippingType) { case ccui.Layout.CLIPPING_STENCIL: @@ -200,9 +337,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ default: break; } - } - else { - cc.Node.prototype.visit.call(this, ctx); + } else { + ccui.Widget.prototype.visit.call(this, ctx); } }, @@ -366,6 +502,88 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // we are done using this layer, decrement ccui.Layout._layer--; + + //TODO new Code + /*if(!_visible) + return; + + uint32_t flags = processParentFlags(parentTransform, parentFlags); + + // IMPORTANT: + // To ease the migration to v3.0, we still support the Mat4 stack, + // but it is deprecated and your code should not rely on it + Director* director = Director.getInstance(); + CCASSERT(nullptr != director, "Director is null when seting matrix stack"); + director.pushMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW); + director.loadMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW, _modelViewTransform); + //Add group command + + _groupCommand.init(_globalZOrder); + renderer.addCommand(&_groupCommand); + + renderer.pushGroup(_groupCommand.getRenderQueueID()); + + _beforeVisitCmdStencil.init(_globalZOrder); + _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout.onBeforeVisitStencil, this); + renderer.addCommand(&_beforeVisitCmdStencil); + + _clippingStencil.visit(renderer, _modelViewTransform, flags); + + _afterDrawStencilCmd.init(_globalZOrder); + _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout.onAfterDrawStencil, this); + renderer.addCommand(&_afterDrawStencilCmd); + + int i = 0; // used by _children + int j = 0; // used by _protectedChildren + + sortAllChildren(); + sortAllProtectedChildren(); + + // + // draw children and protectedChildren zOrder < 0 + // + for( ; i < _children.size(); i++ ) + { + auto node = _children.at(i); + + if ( node && node.getLocalZOrder() < 0 ) + node.visit(renderer, _modelViewTransform, flags); + else + break; + } + + for( ; j < _protectedChildren.size(); j++ ) + { + auto node = _protectedChildren.at(j); + + if ( node && node.getLocalZOrder() < 0 ) + node.visit(renderer, _modelViewTransform, flags); + else + break; + } + + // + // draw self + // + this.draw(renderer, _modelViewTransform, flags); + + // + // draw children and protectedChildren zOrder >= 0 + // + for(auto it=_protectedChildren.cbegin()+j; it != _protectedChildren.cend(); ++it) + (*it).visit(renderer, _modelViewTransform, flags); + + for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) + (*it).visit(renderer, _modelViewTransform, flags); + + + _afterVisitCmdStencil.init(_globalZOrder); + _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout.onAfterVisitStencil, this); + renderer.addCommand(&_afterVisitCmdStencil); + + renderer.popGroup(); + + director.popMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW);*/ }, _stencilClippingVisitForCanvas: function (ctx) { @@ -465,16 +683,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {Boolean} able */ setClippingEnabled: function (able) { - if (able == this._clippingEnabled) { + if (able == this._clippingEnabled) return; - } this._clippingEnabled = able; switch (this._clippingType) { case ccui.Layout.CLIPPING_STENCIL: - if (able) { + if (able){ + this._clippingStencil = cc.DrawNode.create(); + if (this._running) + this._clippingStencil.onEnter(); this.setStencilClippingSize(this._size); - } - else { + } else { + if (this._running) + this._clippingStencil.onExit(); this._clippingStencil = null; } break; @@ -539,7 +760,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingParent = parent; firstClippingParentFounded = true; } - if (parent._clippingType == ccui.Layout.CLIPPING_SCISSOR) { this._handleScissor = false; break; @@ -597,12 +817,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.setContentSize(this._size); + //this.setContentSize(this._size); //TODO need test this.setStencilClippingSize(this._size); this._doLayoutDirty = true; this._clippingRectDirty = true; if (this._backGroundImage) { - this._backGroundImage.setPosition(this._size.width / 2.0, this._size.height / 2.0); + this._backGroundImage.setPosition(this._size.width * 0.5, this._size.height * 0.5); if (this._backGroundScale9Enabled) { if (this._backGroundImage instanceof cc.Scale9Sprite) { this._backGroundImage.setPreferredSize(this._size); @@ -625,16 +845,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._backGroundScale9Enabled == able) { return; } - cc.Node.prototype.removeChild.call(this, this._backGroundImage, true); + this.removeProtectedChild(this._backGroundImage); + //cc.Node.prototype.removeChild.call(this, this._backGroundImage, true); this._backGroundImage = null; this._backGroundScale9Enabled = able; - if (this._backGroundScale9Enabled) { + /* if (this._backGroundScale9Enabled) { this._backGroundImage = cc.Scale9Sprite.create(); } else { this._backGroundImage = cc.Sprite.create(); } - cc.Node.prototype.addChild.call(this, this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1); + cc.Node.prototype.addChild.call(this, this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1);*/ + this.addBackGroundImage(); this.setBackGroundImage(this._backGroundImageFileName, this._bgImageTexType); this.setBackGroundImageCapInsets(this._backGroundImageCapInsets); }, @@ -657,42 +879,53 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return; } texType = texType || ccui.Widget.LOCAL_TEXTURE; - if (this._backGroundImage == null) { + if (this._backGroundImage == null) this.addBackGroundImage(); - } this._backGroundImageFileName = fileName; this._bgImageTexType = texType; - switch (this._bgImageTexType) { - case ccui.Widget.LOCAL_TEXTURE: - this._backGroundImage.initWithFile(fileName); - break; - case ccui.Widget.PLIST_TEXTURE: - this._backGroundImage.initWithSpriteFrameName(fileName); - break; - default: - break; - } if (this._backGroundScale9Enabled) { - this._backGroundImage.setPreferredSize(this._size); + var bgiScale9 = this._backGroundImage; + switch (this._bgImageTexType) { + case ccui.Widget.LOCAL_TEXTURE: + bgiScale9.initWithFile(fileName); + break; + case ccui.Widget.PLIST_TEXTURE: + bgiScale9.initWithSpriteFrameName(fileName); + break; + default: + break; + } + bgiScale9.setPreferredSize(this._size); + } else { + var sprite = this._backGroundImage; + switch (this._bgImageTexType){ + case ccui.Widget.LOCAL_TEXTURE: + sprite.setTexture(fileName); + break; + case ccui.Widget.PLIST_TEXTURE: + sprite.setSpriteFrame(fileName); + break; + default: + break; + } } this._backGroundImageTextureSize = this._backGroundImage.getContentSize(); this._backGroundImage.setPosition(this._size.width / 2.0, this._size.height / 2.0); - this.updateBackGroundImageColor(); + this._updateBackGroundImageColor(); }, /** - * Sets a background image capinsets for layout, if the background image is a scale9 render. + * Sets a background image CapInsets for layout, if the background image is a scale9 render. * @param {cc.Rect} capInsets */ setBackGroundImageCapInsets: function (capInsets) { this._backGroundImageCapInsets = capInsets; - if (this._backGroundScale9Enabled) { + if (this._backGroundScale9Enabled) this._backGroundImage.setCapInsets(capInsets); - } }, /** - * Get background image cap insets. + * Gets background image cap insets. * @returns {cc.Rect} */ getBackGroundImageCapInsets: function () { @@ -709,15 +942,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Layout.LINEAR_HORIZONTAL: case ccui.Layout.LINEAR_VERTICAL: var layoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.LINEAR); - if (!layoutParameter) { + if (!layoutParameter) locChild.setLayoutParameter(ccui.LinearLayoutParameter.create()); - } break; case ccui.Layout.RELATIVE: var layoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.RELATIVE); - if (!layoutParameter) { + if (!layoutParameter) locChild.setLayoutParameter(ccui.RelativeLayoutParameter.create()); - } break; default: break; @@ -731,11 +962,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._backGroundScale9Enabled) { this._backGroundImage = cc.Scale9Sprite.create(); this._backGroundImage.setPreferredSize(this._size); - } - else { + } else { this._backGroundImage = cc.Sprite.create(); } - cc.Node.prototype.addChild.call(this, this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1); + this.addProtectedChild(this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1); this._backGroundImage.setPosition(this._size.width / 2.0, this._size.height / 2.0); }, @@ -743,10 +973,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * Remove the background image of layout. */ removeBackGroundImage: function () { - if (!this._backGroundImage) { + if (!this._backGroundImage) return; - } - cc.Node.prototype.removeChild.call(this, this._backGroundImage, true); + this.removeProtectedChild(this._backGroundImage); this._backGroundImage = null; this._backGroundImageFileName = ""; this._backGroundImageTextureSize = cc.size(0, 0); @@ -757,29 +986,28 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Layout.BG_COLOR_NONE|ccui.Layout.BG_COLOR_SOLID|ccui.Layout.BG_COLOR_GRADIENT} type */ setBackGroundColorType: function (type) { - if (this._colorType == type) { + if (this._colorType == type) return; - } switch (this._colorType) { case ccui.Layout.BG_COLOR_NONE: if (this._colorRender) { - cc.Node.prototype.removeChild.call(this, this._colorRender, true); + this.removeProtectedChild(this._colorRender); this._colorRender = null; } if (this._gradientRender) { - cc.Node.prototype.removeChild.call(this, this._gradientRender, true); + this.removeProtectedChild(this._gradientRender); this._gradientRender = null; } break; case ccui.Layout.BG_COLOR_SOLID: if (this._colorRender) { - cc.Node.prototype.removeChild.call(this, this._colorRender, true); + this.removeProtectedChild(this._colorRender); this._colorRender = null; } break; case ccui.Layout.BG_COLOR_GRADIENT: if (this._gradientRender) { - cc.Node.prototype.removeChild.call(this, this._gradientRender, true); + this.removeProtectedChild(this._gradientRender); this._gradientRender = null; } break; @@ -795,7 +1023,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._colorRender.setContentSize(this._size); this._colorRender.setOpacity(this._opacity); this._colorRender.setColor(this._color); - cc.Node.prototype.addChild.call(this, this._colorRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1); + this.addProtectedChild(this._colorRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1); break; case ccui.Layout.BG_COLOR_GRADIENT: this._gradientRender = cc.LayerGradient.create(cc.color(255, 0, 0, 255), cc.color(0, 255, 0, 255)); @@ -804,7 +1032,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._gradientRender.setStartColor(this._startColor); this._gradientRender.setEndColor(this._endColor); this._gradientRender.setVector(this._alongVector); - cc.Node.prototype.addChild.call(this, this._gradientRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1); + this.addProtectedChild(this._gradientRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1); break; default: break; @@ -931,10 +1159,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._backGroundImageColor.g = color.g; this._backGroundImageColor.b = color.b; - this.updateBackGroundImageColor(); - if (color.a !== undefined && !color.a_undefined) { - this.setBackGroundImageOpacity(color.a); - } + this._updateBackGroundImageColor(); }, /** @@ -963,8 +1188,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this._backGroundImageColor.a; }, - updateBackGroundImageColor: function () { - this._backGroundImage.setColor(this._backGroundImageColor); + _updateBackGroundImageColor: function () { + if(this._backGroundImage) + this._backGroundImage.setColor(this._backGroundImageColor); }, /** @@ -981,11 +1207,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ setLayoutType: function (type) { this._layoutType = type; - var layoutChildrenArray = this._widgetChildren; + var layoutChildrenArray = this._children; var locChild = null; for (var i = 0; i < layoutChildrenArray.length; i++) { locChild = layoutChildrenArray[i]; - this.supplyTheLayoutParameterLackToChild(locChild); + if(locChild) + this.supplyTheLayoutParameterLackToChild(locChild); } this._doLayoutDirty = true; }, @@ -1023,13 +1250,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var locFinalPosX = locAP.x * locSize.width; var locFinalPosY = topBoundary - ((1 - locAP.y) * locSize.height); switch (locChildGravity) { - case ccui.LINEAR_GRAVITY_NONE: - case ccui.LINEAR_GRAVITY_LEFT: + case ccui.LinearLayoutParameter.NONE: + case ccui.LinearLayoutParameter.LEFT: break; - case ccui.LINEAR_GRAVITY_RIGHT: + case ccui.LinearLayoutParameter.RIGHT: locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); break; - case ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL: + case ccui.LinearLayoutParameter.CENTER_HORIZONTAL: locFinalPosX = layoutSize.width / 2 - locSize.width * (0.5 - locAP.x); break; default: @@ -1058,13 +1285,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var locFinalPosX = leftBoundary + (locAP.x * locSize.width); var locFinalPosY = layoutSize.height - (1 - locAP.y) * locSize.height; switch (locChildGravity) { - case ccui.LINEAR_GRAVITY_NONE: - case ccui.LINEAR_GRAVITY_TOP: + case ccui.LinearLayoutParameter.NONE: + case ccui.LinearLayoutParameter.TOP: break; - case ccui.LINEAR_GRAVITY_BOTTOM: + case ccui.LinearLayoutParameter.BOTTOM : locFinalPosY = locAP.y * locSize.height; break; - case ccui.LINEAR_GRAVITY_CENTER_VERTICAL: + case ccui.LinearLayoutParameter.CENTER_VERTICAL: locFinalPosY = layoutSize.height / 2 - locSize.height * (0.5 - locAP.y); break; default: @@ -1114,45 +1341,45 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } } switch (locAlign) { - case ccui.RELATIVE_ALIGN_NONE: - case ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT: + case ccui.RelativeLayoutParameter.NONE: + case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT: locFinalPosX = locAP.x * locSize.width; locFinalPosY = layoutSize.height - ((1 - locAP.y) * locSize.height); break; - case ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL: + case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL: locFinalPosX = layoutSize.width * 0.5 - locSize.width * (0.5 - locAP.x); locFinalPosY = layoutSize.height - ((1 - locAP.y) * locSize.height); break; - case ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT: + case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT: locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); locFinalPosY = layoutSize.height - ((1 - locAP.y) * locSize.height); break; - case ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL: + case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL: locFinalPosX = locAP.x * locSize.width; locFinalPosY = layoutSize.height * 0.5 - locSize.height * (0.5 - locAP.y); break; - case ccui.RELATIVE_ALIGN_PARENT_CENTER: + case ccui.RelativeLayoutParameter.CENTER_IN_PARENT: locFinalPosX = layoutSize.width * 0.5 - locSize.width * (0.5 - locAP.x); locFinalPosY = layoutSize.height * 0.5 - locSize.height * (0.5 - locAP.y); break; - case ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL: + case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL: locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); locFinalPosY = layoutSize.height * 0.5 - locSize.height * (0.5 - locAP.y); break; - case ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM: + case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM: locFinalPosX = locAP.x * locSize.width; locFinalPosY = locAP.y * locSize.height; break; - case ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL: + case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL: locFinalPosX = layoutSize.width * 0.5 - locSize.width * (0.5 - locAP.x); locFinalPosY = locAP.y * locSize.height; break; - case ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM: + case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM: locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); locFinalPosY = locAP.y * locSize.height; break; - case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT: + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1163,7 +1390,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locationLeft + locAP.x * locSize.width; } break; - case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1175,7 +1402,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locRelativeWidget.getLeftBoundary() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; } break; - case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT: + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1186,7 +1413,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; } break; - case ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP: + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1197,7 +1424,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; } break; - case ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1209,7 +1436,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosY = locRelativeWidget.getBottomBoundary() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; } break; - case ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM: + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1220,7 +1447,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; } break; - case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP: + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1231,7 +1458,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locationLeft + locAP.x * locSize.width; } break; - case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1243,7 +1470,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosY = locRelativeWidget.getBottomBoundary() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; } break; - case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM: + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1254,7 +1481,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locationLeft + locAP.x * locSize.width; } break; - case ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP: + case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1265,7 +1492,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locationLeft + locAP.x * locSize.width; } break; - case ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1277,7 +1504,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locFinalPosX = locRelativeWidget.getLeftBoundary() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; } break; - case ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM: + case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN: if (locRelativeWidget) { if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { continue; @@ -1299,87 +1526,87 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } //handle margin switch (locAlign) { - case ccui.RELATIVE_ALIGN_NONE: - case ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT: + case ccui.RelativeLayoutParameter.NONE: + case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT: locFinalPosX += locMargin.left; locFinalPosY -= locMargin.top; break; - case ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL: + case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL: locFinalPosY -= locMargin.top; break; - case ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT: + case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT: locFinalPosX -= locMargin.right; locFinalPosY -= locMargin.top; break; - case ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL: + case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL: locFinalPosX += locMargin.left; break; - case ccui.RELATIVE_ALIGN_PARENT_CENTER: + case ccui.RelativeLayoutParameter.CENTER_IN_PARENT: break; - case ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL: + case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL: locFinalPosX -= locMargin.right; break; - case ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM: + case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM: locFinalPosX += locMargin.left; locFinalPosY += locMargin.bottom; break; - case ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL: + case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL: locFinalPosY += locMargin.bottom; break; - case ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM: + case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM: locFinalPosX -= locMargin.right; locFinalPosY += locMargin.bottom; break; - case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT: + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN: locFinalPosY += locMargin.bottom; - 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) { + if (locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL + && locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.PARENT_TOP_LEFT + && locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.NONE + && locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT) { locFinalPosY += locRelativeWidgetMargin.top; } locFinalPosX += locMargin.left; locFinalPosX += locMargin.left; break; - case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER: locFinalPosY += locMargin.bottom; break; - case ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT: + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN: locFinalPosY += locMargin.bottom; locFinalPosX -= locMargin.right; break; - case ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP: + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN: locFinalPosX -= locMargin.right; locFinalPosY -= locMargin.top; break; - case ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER: locFinalPosX -= locMargin.right; break; - case ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM: + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN: locFinalPosX -= locMargin.right; locFinalPosY += locMargin.bottom; break; break; - case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP: + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN: locFinalPosX += locMargin.left; locFinalPosY -= locMargin.top; break; - case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER: locFinalPosX += locMargin.left; break; - case ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM: + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN: locFinalPosX += locMargin.left; locFinalPosY += locMargin.bottom; break; - case ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP: + case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN: locFinalPosY -= locMargin.top; locFinalPosX += locMargin.left; break; - case ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER: + case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER: locFinalPosY -= locMargin.top; break; - case ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM: + case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN: locFinalPosY -= locMargin.top; locFinalPosX -= locMargin.right; break; @@ -1395,24 +1622,565 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _doLayout: function () { - if (!this._doLayoutDirty) { + if (!this._doLayoutDirty) return; - } + + var executant = this._createLayoutManager(); //TODO create a layout manager every calling _doLayout? + if (executant) + executant._doLayout(this); + this._doLayoutDirty = false; + }, + + _createLayoutManager: function(){ + var layoutMgr = null; switch (this._layoutType) { - case ccui.Layout.ABSOLUTE: case ccui.Layout.LINEAR_VERTICAL: - this.doLayout_LINEAR_VERTICAL(); + layoutMgr = ccui.LinearVerticalLayoutManager.create(); break; case ccui.Layout.LINEAR_HORIZONTAL: - this.doLayout_LINEAR_HORIZONTAL(); + layoutMgr = ccui.LinearHorizontalLayoutManager.create(); break; case ccui.Layout.RELATIVE: - this.doLayout_RELATIVE(); - break; - default: + layoutMgr = ccui.RelativeLayoutManager.create(); break; } - this._doLayoutDirty = false; + return layoutMgr; + }, + + _getLayoutContentSize: function(){ + return this.getSize(); + }, + + _getLayoutElements: function(){ + return this.getChildren(); + }, + + //clipping + _onBeforeVisitStencil: function(){ + /*s_layer++; + GLint mask_layer = 0x1 << s_layer; + GLint mask_layer_l = mask_layer - 1; + _mask_layer_le = mask_layer | mask_layer_l; + _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); + glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); + glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); + glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); + glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); + glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); + + glEnable(GL_STENCIL_TEST); + CHECK_GL_ERROR_DEBUG(); + glStencilMask(mask_layer); + glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); + glDepthMask(GL_FALSE); + glStencilFunc(GL_NEVER, mask_layer, mask_layer); + glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP); + + this.drawFullScreenQuadClearStencil(); + + glStencilFunc(GL_NEVER, mask_layer, mask_layer); + glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);*/ + }, + + _drawFullScreenQuadClearStencil:function(){ + /*Director* director = Director.getInstance(); + CCASSERT(nullptr != director, "Director is null when seting matrix stack"); + + director.pushMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION); + director.loadIdentityMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION); + + director.pushMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW); + director.loadIdentityMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW); + + DrawPrimitives.drawSolidRect(Vec2(-1,-1), Vec2(1,1), Color4F(1, 1, 1, 1)); + + director.popMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION); + director.popMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW);*/ + }, + + _onAfterDrawStencil: function(){ +/* glDepthMask(_currentDepthWriteMask); + glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);*/ + }, + + _onAfterVisitStencil: function(){ + /* glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); + glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); + glStencilMask(_currentStencilWriteMask); + if (!_currentStencilEnabled) + { + glDisable(GL_STENCIL_TEST); + } + s_layer--;*/ + }, + + _onAfterVisitScissor: function(){ + /*Rect clippingRect = getClippingRect(); + glEnable(GL_SCISSOR_TEST); + auto glview = Director.getInstance().getOpenGLView(); + glview.setScissorInPoints(clippingRect.origin.x, clippingRect.origin.y, clippingRect.size.width, clippingRect.size.height);*/ + }, + + _onAfterVisitScissor: function(){ + //glDisable(GL_SCISSOR_TEST); + }, + + _updateBackGroundImageOpacity: function(){ + if (this._backGroundImage) + this._backGroundImage.setOpacity(this._backGroundImageOpacity); + }, + + _updateBackGroundImageRGBA: function(){ + if (this._backGroundImage) { + this._backGroundImage.setColor(this._backGroundImageColor); + this._backGroundImage.setOpacity(this._backGroundImageOpacity); + } + }, + + _getLayoutAccumulatedSize: function(){ + var children = this.getChildren(); + var layoutSize = cc.size(0, 0); + var widgetCount =0; + for(var i = 0, len = children.length; i < len; i++) { + var layout = children[i]; + if (null != layout && layout instanceof ccui.Layout) + layoutSize = layoutSize + layout._getLayoutAccumulatedSize(); + else { + if (layout instanceof ccui.Widget) { + widgetCount++; + var m = w.getLayoutParameter().getMargin(); + layoutSize = layoutSize + w.getSize() + cc.size(m.right + m.left, m.top + m.bottom) * 0.5; + } + } + } + + //substract extra size + var type = this.getLayoutType(); + if (type == ccui.Layout.LINEAR_HORIZONTAL) + layoutSize.height = layoutSize.height - layoutSize.height/widgetCount * (widgetCount-1); + + if (type == ccui.Layout.LINEAR_VERTICAL) + layoutSize.width = layoutSize.width - layoutSize.width/widgetCount * (widgetCount-1); + return layoutSize; + }, + + _findNearestChildWidgetIndex: function(direction, baseWidget){ + if (baseWidget == null || baseWidget == this) + return this._findFirstFocusEnabledWidgetIndex(); + + var index = 0, locChildren = this.getChildren(); + var count = locChildren.length; + var widgetPosition; + + var distance = cc.FLT_MAX, found = 0; + if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT || direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) { + widgetPosition = this._getWorldCenterPoint(baseWidget); + while (index < count) { + var w = locChildren[index]; + if (w && w instanceof ccui.Widget && w.isFocusEnabled()) { + var length = (w instanceof ccui.Layout)? w._calculateNearestDistance(baseWidget) + : cc.pLength(cc.pSub(this._getWorldCenterPoint(w), widgetPosition)); + + if (length < distance){ + found = index; + distance = length; + } + } + index++; + } + return found; + } + cc.assert(0, "invalid focus direction!"); + return 0; + }, + + _findFarestChildWidgetIndex: function(direction, baseWidget){ + if (baseWidget == null || baseWidget == this) + return this._findFirstFocusEnabledWidgetIndex(); + + var index = 0; + var count = this.getChildren().size(); + + var distance = -cc.FLT_MAX; + var found = 0; + if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT || direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) { + var widgetPosition = this._getWorldCenterPoint(baseWidget); + while (index < count) { + if (w && w instanceof ccui.Widget && w.isFocusEnabled()) { + var length = (w instanceof ccui.Layout)?w._calculateFarestDistance(baseWidget) + : cc.pLength(cc.pSub(this._getWorldCenterPoint(w), widgetPosition)); + + if (length > distance){ + found = index; + distance = length; + } + } + index++; + } + return found; + } + cc.assert(0, "invalid focus direction!!!"); + return 0; + }, + + _calculateNearestDistance: function(baseWidget){ + var distance = cc.FLT_MAX; + var widgetPosition = this._getWorldCenterPoint(baseWidget); + var locChildren = this._children; + + for (var i = 0, len = locChildren.length; i < len; i++) { + var widget = locChildren[i]; + var length; + if (widget instanceof ccui.Layout) + length = widget._calculateNearestDistance(baseWidget); + else { + if (widget instanceof ccui.Widget && widget.isFocusEnabled()) + length = cc.pLength(cc.pSub(this._getWorldCenterPoint(widget), widgetPosition)); + else + continue; + } + + if (length < distance) + distance = length; + } + return distance; + }, + + _calculateFarestDistance:function(baseWidget){ + var distance = -cc.FLT_MAX; + var widgetPosition = this._getWorldCenterPoint(baseWidget); + var locChildren = this._children; + + for (var i = 0, len = locChildren.length; i < len; i++) { + var layout = locChildren[i]; + var length; + if (layout instanceof ccui.Layout) + length = layout._calculateFarestDistance(baseWidget); + else { + if (layout instanceof ccui.Widget && layout.isFocusEnabled()) { + var wPosition = this._getWorldCenterPoint(w); + length = cc.pLength(cc.pSub(wPosition, widgetPosition)); + } else + continue; + } + + if (length > distance) + distance = length; + } + return distance; + }, + + _findProperSearchingFunctor: function(direction, baseWidget){ + if (baseWidget == null) + return; + + var previousWidgetPosition = this._getWorldCenterPoint(baseWidget); + var widgetPosition = this._getWorldCenterPoint(this._findFirstNonLayoutWidget()); + if (direction == ccui.Widget.LEFT) { + if (previousWidgetPosition.x > widgetPosition.x) + this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); + else + this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + }else if(direction == ccui.Widget.RIGHT){ + if (previousWidgetPosition.x > widgetPosition.x) + this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + else + this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); + }else if(direction == ccui.Widget.DOWN){ + if (previousWidgetPosition.y > widgetPosition.y) + this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); + else + this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + }else if(direction == ccui.Widget.UP){ + if (previousWidgetPosition.y < widgetPosition.y) + this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); + else + this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + }else + cc.assert(0, "invalid direction!"); + }, + + _findFirstNonLayoutWidget:function(){ + var locChildren = this._children; + for(var i = 0, len = locChildren.length; i < len; i++) { + var child = locChildren[i]; + if (child instanceof ccui.Layout){ + var widget = child._findFirstNonLayoutWidget(); + if(widget) + return widget; + } else{ + if (child instanceof cc.Widget) + return child; + } + } + return null; + }, + + _findFirstFocusEnabledWidgetIndex: function(){ + var index = 0, locChildren = this.getChildren(); + var count = locChildren.length; + while (index < count) { + var w = locChildren[index]; + if (w && w instanceof ccui.Widget && w.isFocusEnabled()) + return index; + index++; + } + //cc.assert(0, "invalid operation"); + return 0; + }, + + _findFocusEnabledChildWidgetByIndex: function(index){ + var widget = this._getChildWidgetByIndex(index); + + if (widget){ + if (widget.isFocusEnabled()) + return widget; + index = index + 1; + return this._findFocusEnabledChildWidgetByIndex(index); + } + return null; + }, + + _getWorldCenterPoint: function(widget){ + //FIXEDME: we don't need to calculate the content size of layout anymore + var widgetSize = widget instanceof ccui.Layout ? widget._getLayoutAccumulatedSize() : widget.getSize(); + // CCLOG("contnet size : width = %f, height = %f", widgetSize.width, widgetSize.height); + return widget.convertToWorldSpace(cc.p(widgetSize.width /2, widgetSize.height /2)); + }, + + _getNextFocusedWidget: function(direction, current){ + var nextWidget = null, locChildren = this._children; + var previousWidgetPos = locChildren.indexOf(current); + previousWidgetPos = previousWidgetPos + 1; + if (previousWidgetPos < locChildren.length) { + nextWidget = this._getChildWidgetByIndex(previousWidgetPos); + //handle widget + if (nextWidget) { + if (nextWidget.isFocusEnabled()) { + if (nextWidget instanceof ccui.Layout) { + nextWidget._isFocusPassing = true; + return nextWidget.findNextFocusedWidget(direction, nextWidget); + } else { + this.dispatchFocusEvent(current, nextWidget); + return nextWidget; + } + } else + return this._getNextFocusedWidget(direction, nextWidget); + } else + return current; + } else { + if (this._loopFocus) { + if (this._checkFocusEnabledChild()) { + previousWidgetPos = 0; + nextWidget = this._getChildWidgetByIndex(previousWidgetPos); + if (nextWidget.isFocusEnabled()) { + if (nextWidget instanceof ccui.Layout) { + nextWidget._isFocusPassing = true; + return nextWidget.findNextFocusedWidget(direction, nextWidget); + } else { + this.dispatchFocusEvent(current, nextWidget); + return nextWidget; + } + } else + return this._getNextFocusedWidget(direction, nextWidget); + } else { + if (current instanceof ccui.Layout) + return current; + else + return this._focusedWidget; + } + } else{ + if (this._isLastWidgetInContainer(current, direction)){ + if (this._isWidgetAncestorSupportLoopFocus(this, direction)) + return this.findNextFocusedWidget(direction, this); + if (current instanceof ccui.Layout) + return current; + else + return this._focusedWidget; + } else + return this.findNextFocusedWidget(direction, this); + } + } + }, + + _getPreviousFocusedWidget: function(direction, current){ + var nextWidget = null, locChildren = this._children; + var previousWidgetPos = locChildren.indexOf(current); + previousWidgetPos = previousWidgetPos - 1; + if (previousWidgetPos >= 0){ + nextWidget = this._getChildWidgetByIndex(previousWidgetPos); + if (nextWidget.isFocusEnabled()) { + if (nextWidget instanceof ccui.Layout){ + nextWidget._isFocusPassing = true; + return nextWidget.findNextFocusedWidget(direction, nextWidget); + } + this.dispatchFocusEvent(current, nextWidget); + return nextWidget; + } else + //handling the disabled widget, there is no actual focus lose or get, so we don't need any envet + return this._getPreviousFocusedWidget(direction, nextWidget); + }else { + if (this._loopFocus){ + if (this._checkFocusEnabledChild()) { + previousWidgetPos = locChildren.length -1; + nextWidget = this._getChildWidgetByIndex(previousWidgetPos); + if (nextWidget.isFocusEnabled()){ + if (nextWidget instanceof ccui.Layout){ + nextWidget._isFocusPassing = true; + return nextWidget.findNextFocusedWidget(direction, nextWidget); + } else { + this.dispatchFocusEvent(current, nextWidget); + return nextWidget; + } + } else + return this._getPreviousFocusedWidget(direction, nextWidget); + } else { + if (current instanceof ccui.Layout) + return current; + else + return this._focusedWidget; + } + } else { + if (this._isLastWidgetInContainer(current, direction)) { + if (this._isWidgetAncestorSupportLoopFocus(this, direction)) + return this.findNextFocusedWidget(direction, this); + + if (current instanceof ccui.Layout) + return current; + else + return this._focusedWidget; + } else + return this.findNextFocusedWidget(direction, this); + } + } + }, + + _getChildWidgetByIndex: function (index) { + var locChildren = this._children; + var size = locChildren.length; + var count = 0, oldIndex = index; + while (index < size) { + var firstChild = locChildren[index]; + if (firstChild && firstChild instanceof ccui.Widget) + return firstChild; + count++; + index++; + } + + var begin = 0; + while (begin < oldIndex) { + var child = locChildren[begin]; + if (child && child instanceof ccui.Widget) + return child; + count++; + begin++; + } + return null; + }, + + _isLastWidgetInContainer:function(widget, direction){ + var parent = widget.getParent(); + if (parent instanceof ccui.Layout) + return true; + + var container = parent.getChildren(); + var index = container.indexOf(widget); + if (parent.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) { + if (direction == ccui.Widget.LEFT) { + if (index == 0) + return true * this._isLastWidgetInContainer(parent, direction); + else + return false; + } + if (direction == ccui.Widget.RIGHT) { + if (index == container.length - 1) + return true * this._isLastWidgetInContainer(parent, direction); + else + return false; + } + if (direction == ccui.Widget.DOWN) + return this._isLastWidgetInContainer(parent, direction); + + if (direction == ccui.Widget.UP) + return this._isLastWidgetInContainer(parent, direction); + } else if(parent.getLayoutType() == ccui.Layout.LINEAR_VERTICAL){ + if (direction == ccui.Widget.UP){ + if (index == 0) + return true * this._isLastWidgetInContainer(parent, direction); + else + return false; + } + if (direction == ccui.Widget.DOWN) { + if (index == container.length - 1) + return true * this._isLastWidgetInContainer(parent, direction); + else + return false; + } + if (direction == ccui.Widget.LEFT) + return this._isLastWidgetInContainer(parent, direction); + + if (direction == ccui.Widget.RIGHT) + return this._isLastWidgetInContainer(parent, direction); + }else { + cc.assert(0, "invalid layout Type"); + return false; + } + return false; + }, + + _isWidgetAncestorSupportLoopFocus: function(widget, direction){ + var parent = widget.getParent(); + if (parent == null) + return false; + if (parent.isLoopFocus()) { + var layoutType = parent.getLayoutType(); + if (layoutType == ccui.Layout.LINEAR_HORIZONTAL) { + if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT) + return true; + else + return this._isWidgetAncestorSupportLoopFocus(parent, direction); + } + if (layoutType == ccui.Layout.LINEAR_VERTICAL){ + if (direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) + return true; + else + return this._isWidgetAncestorSupportLoopFocus(parent, direction); + } else + cc.assert(0, "invalid layout type"); + } else + return this._isWidgetAncestorSupportLoopFocus(parent, direction); + }, + + _passFocusToChild: function(direction, current){ + if (this._checkFocusEnabledChild()) { + var previousWidget = this.getCurrentFocusedWidget(); + this._findProperSearchingFunctor(direction, previousWidget); + + var index = this.onPassFocusToChild(direction, previousWidget); //TODO need check + + var widget = this._getChildWidgetByIndex(index); + if (widget instanceof ccui.Layout) { + widget._isFocusPassing = true; + return widget.findNextFocusedWidget(direction, widget); + } else { + this.dispatchFocusEvent(current, widget); + return widget; + } + }else + return this; + }, + + _checkFocusEnabledChild: function(){ + var locChildren = this._children; + for(var i = 0, len = locChildren.length; i < len; i++){ + var widget = locChildren[i]; + if (widget && widget instanceof ccui.Widget && widget.isFocusEnabled()) + return true; + } + return false; }, /** @@ -1443,6 +2211,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.setLayoutType(layout._layoutType); this.setClippingEnabled(layout._clippingEnabled); this.setClippingType(layout._clippingType); + this._loopFocus = layout._loopFocus; + this._passFocusToChild = layout._passFocusToChild; } }); ccui.Layout._init_once = null; diff --git a/extensions/ccui/layouts/UILayoutDefine.js b/extensions/ccui/layouts/UILayoutDefine.js deleted file mode 100644 index baac1615e2..0000000000 --- a/extensions/ccui/layouts/UILayoutDefine.js +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -//LinearGravity -/** - * @ignore - */ -ccui.LINEAR_GRAVITY_NONE = 0; -ccui.LINEAR_GRAVITY_LEFT = 1; -ccui.LINEAR_GRAVITY_TOP = 2; -ccui.LINEAR_GRAVITY_RIGHT = 3; -ccui.LINEAR_GRAVITY_BOTTOM = 4; -ccui.LINEAR_GRAVITY_CENTER_VERTICAL = 5; -ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL = 6; - -//RelativeAlign -ccui.RELATIVE_ALIGN_NONE = 0; -ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT = 1; -ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL = 2; -ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT = 3; -ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL = 4; -ccui.RELATIVE_ALIGN_PARENT_CENTER = 5; -ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL = 6; -ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM = 7; -ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL = 8; -ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM = 9; - -ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT = 10; -ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER = 11; -ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT = 12; - -ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP = 13; -ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER = 14; -ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM = 15; - -ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP = 16; -ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER = 17; -ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM = 18; - -ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP = 19; -ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER = 20; -ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM = 21; - -/** - * Base class for ccui.Margin - * @class - * @extends ccui.Class - */ -ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ - left: 0, - top: 0, - right: 0, - bottom: 0, - ctor: function (margin, top, right, bottom) { - if (margin && top === undefined) { - this.left = margin.left; - this.top = margin.top; - this.right = margin.right; - this.bottom = margin.bottom; - } - if (bottom !== undefined) { - this.left = margin; - this.top = top; - this.right = right; - this.bottom = bottom; - } - }, - /** - * set margin - * @param {Number} l - * @param {Number} t - * @param {Number} r - * @param {Number} b - */ - setMargin: function (l, t, r, b) { - this.left = l; - this.top = t; - this.right = r; - this.bottom = b; - }, - /** - * check is equals - * @param {ccui.Margin} target - * @returns {boolean} - */ - equals: function (target) { - return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom); - } -}); - -ccui.MarginZero = function(){ - return new ccui.Margin(0,0,0,0); -}; \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js new file mode 100644 index 0000000000..080603d7be --- /dev/null +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -0,0 +1,460 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccui.LayoutManager = ccui.Class.extend({ + _doLayout: function(layout){} +}); + +ccui.LinearVerticalLayoutManager = ccui.LayoutManager.extend({ + _doLayout: function(layout){ + var layoutSize = layout._getLayoutContentSize(); + var container = layout._getLayoutElements(); + var topBoundary = layoutSize.height; + + for (var i = 0, len = container.length; i < len; i++) { + var child = container[i]; + if (child) { + var layoutParameter = child.getLayoutParameter(); + + if (layoutParameter){ + var childGravity = layoutParameter.getGravity(); + var ap = child.getAnchorPoint(); + var cs = child.getContentSize(); + var finalPosX = ap.x * cs.width; + var finalPosY = topBoundary - ((1.0-ap.y) * cs.height); + switch (childGravity){ + case ccui.LinearLayoutParameter.NONE: + case ccui.LinearLayoutParameter.LEFT: + break; + case ccui.LinearLayoutParameter.RIGHT: + finalPosX = layoutSize.width - ((1.0 - ap.x) * cs.width); + break; + case ccui.LinearLayoutParameter.CENTER_HORIZONTAL: + finalPosX = layoutSize.width / 2.0 - cs.width * (0.5-ap.x); + break; + default: + break; + } + var mg = layoutParameter.getMargin(); + finalPosX += mg.left; + finalPosY -= mg.top; + child.setPosition(finalPosX, finalPosY); + topBoundary = child.getPositionX() - child.getAnchorPoint().y * child.getContentSize().height - mg.bottom; + } + } + } + } +}); + +ccui.LinearVerticalLayoutManager.create = function(){ + return new ccui.LinearVerticalLayoutManager(); +}; + +ccui.LinearHorizontalLayoutManager = ccui.LayoutManager.extend({ + _doLayout: function(layout){ + var layoutSize = layout._getLayoutContentSize(); + var container = layout._getLayoutElements(); + var leftBoundary = 0.0; + for (var i = 0, len = container.length; i < len; i++) { + var child = container[i]; + if (child) { + var layoutParameter = child.getLayoutParameter(); + if (layoutParameter){ + var childGravity = layoutParameter.getGravity(); + var ap = child.getAnchorPoint(); + var cs = child.getSize(); + var finalPosX = leftBoundary + (ap.x * cs.width); + var finalPosY = layoutSize.height - (1.0 - ap.y) * cs.height; + switch (childGravity){ + case ccui.LinearLayoutParameter.NONE: + case ccui.LinearLayoutParameter.TOP: + break; + case ccui.LinearLayoutParameter.BOTTOM: + finalPosY = ap.y * cs.height; + break; + case ccui.LinearLayoutParameter.CENTER_VERTICAL: + finalPosY = layoutSize.height / 2.0 - cs.height * (0.5 - ap.y); + break; + default: + break; + } + var mg = layoutParameter.getMargin(); + finalPosX += mg.left; + finalPosY -= mg.top; + child.setPosition(finalPosX, finalPosY); + leftBoundary = child.getRightBoundary() + mg.right; + } + } + } + } +}); + +ccui.LinearHorizontalLayoutManager.create = function(){ + return new ccui.LinearHorizontalLayoutManager(); +}; + +ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ + _unlayoutChildCount: null, + _widgetChildren: null, + _widget: null, + _finalPositionX:0, + _finalPositionY:0, + _relativeWidgetLP:null, + + _doLayout: function(layout){ + this._widgetChildren = this._getAllWidgets(layout); + + var locChildren = this._widgetChildren; + while (this._unlayoutChildCount > 0) { + for (var i = 0, len = locChildren.length; i < len; i++) { + this._widget = locChildren[i]; + + var layoutParameter = this._widget.getLayoutParameter(); + if (layoutParameter){ + if (layoutParameter._put) + continue; + + var ret = this._caculateFinalPositionWithRelativeWidget(layout); + if (!ret) + continue; + + this._caculateFinalPositionWithRelativeAlign(); + + this._widget.setPosition(this._finalPositionX, this._finalPositionY); + layoutParameter._put = true; + } + } + this._unlayoutChildCount--; + } + this._widgetChildren.length = 0; + }, + + _getAllWidgets: function(layout){ + var container = layout._getLayoutElements(); + var widgetChildren = []; //TODO + for (var i = 0, len = container.length; i < len; i++){ + var child = container[i]; + if (child) { + var layoutParameter = child.getLayoutParameter(); + layoutParameter._put = false; + this._unlayoutChildCount++; + widgetChildren.push(child); + } + } + return widgetChildren; + }, + + _getRelativeWidget: function(widget){ + var relativeWidget = null; + var layoutParameter = widget.getLayoutParameter(); + var relativeName = layoutParameter.getRelativeToWidgetName(); + + if (relativeName && relativeName.length != 0) { + var locChildren = this._widgetChildren; + for(var i = 0, len = locChildren.length; i < len; i++){ + var child = locChildren[i]; + if (child){ + var rlayoutParameter = child.getLayoutParameter(); + if (rlayoutParameter && rlayoutParameter.getRelativeName() == relativeName) { + relativeWidget = child; + this._relativeWidgetLP = rlayoutParameter; + break; + } + } + } + } + return relativeWidget; + }, + + _caculateFinalPositionWithRelativeWidget: function(layout){ //TODO typo + var locWidget = this._widget; + var ap = locWidget.getAnchorPoint(); + var cs = locWidget.getSize(); + + this._finalPositionX = 0.0; + this._finalPositionY = 0.0; + + var relativeWidget = this._getRelativeWidget(locWidget); + var layoutParameter = locWidget.getLayoutParameter(); + var align = layoutParameter.getAlign(); + var layoutSize = layout._getLayoutContentSize(); + + switch (align) { + case ccui.RelativeLayoutParameter.NONE: + case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT: + this._finalPositionX = ap.x * cs.width; + this._finalPositionY = layoutSize.height - ((1.0 - ap.y) * cs.height); + break; + case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL: + this._finalPositionX = layoutSize.width * 0.5 - cs.width * (0.5 - ap.x); + this._finalPositionY = layoutSize.height - ((1.0 - ap.y) * cs.height); + break; + case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT: + this._finalPositionX = layoutSize.width - ((1.0 - ap.x) * cs.width); + this._finalPositionY = layoutSize.height - ((1.0 - ap.y) * cs.height); + break; + case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL: + this._finalPositionX = ap.x * cs.width; + this._finalPositionY = layoutSize.height * 0.5 - cs.height * (0.5 - ap.y); + break; + case ccui.RelativeLayoutParameter.CENTER_IN_PARENT: + this._finalPositionX = layoutSize.width * 0.5 - cs.width * (0.5 - ap.x); + this._finalPositionY = layoutSize.height * 0.5 - cs.height * (0.5 - ap.y); + break; + case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL: + this._finalPositionX = layoutSize.width - ((1.0 - ap.x) * cs.width); + this._finalPositionY = layoutSize.height * 0.5 - cs.height * (0.5 - ap.y); + break; + case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM: + this._finalPositionX = ap.x * cs.width; + this._finalPositionY = ap.y * cs.height; + break; + case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL: + this._finalPositionX = layoutSize.width * 0.5 - cs.width * (0.5 - ap.x); + this._finalPositionY = ap.y * cs.height; + break; + case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM: + this._finalPositionX = layoutSize.width - ((1.0 - ap.x) * cs.width); + this._finalPositionY = ap.y * cs.height; + break; + + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN: + if (relativeWidget){ + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationTop = relativeWidget.getTopBoundary(); + var locationLeft = relativeWidget.getLeftBoundary(); + this._finalPositionY = locationTop + ap.y * cs.height; + this._finalPositionX = locationLeft + ap.x * cs.width; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER: + if (relativeWidget){ + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var rbs = relativeWidget.getSize(); + var locationTop = relativeWidget.getTopBoundary(); + this._finalPositionY = locationTop + ap.y * cs.height; + this._finalPositionX = relativeWidget.getLeftBoundary() + rbs.width * 0.5 + ap.x * cs.width - cs.width * 0.5; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN: + if (relativeWidget) { + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationTop = relativeWidget.getTopBoundary(); + var locationRight = relativeWidget.getRightBoundary(); + this._finalPositionY = locationTop + ap.y * cs.height; + this._finalPositionX = locationRight - (1.0 - ap.x) * cs.width; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN: + if (relativeWidget){ + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationTop = relativeWidget.getTopBoundary(); + var locationLeft = relativeWidget.getLeftBoundary(); + this._finalPositionY = locationTop - (1.0 - ap.y) * cs.height; + this._finalPositionX = locationLeft - (1.0 - ap.x) * cs.width; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER: + if (relativeWidget) { + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var rbs = relativeWidget.getSize(); + var locationLeft = relativeWidget.getLeftBoundary(); + this._finalPositionX = locationLeft - (1.0 - ap.x) * cs.width; + this._finalPositionY = relativeWidget.getBottomBoundary() + rbs.height * 0.5 + ap.y * cs.height - cs.height * 0.5; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN: + if (relativeWidget) { + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationBottom = relativeWidget.getBottomBoundary(); + var locationLeft = relativeWidget.getLeftBoundary(); + this._finalPositionY = locationBottom + ap.y * cs.height; + this._finalPositionX = locationLeft - (1.0 - ap.x) * cs.width; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN: + if (relativeWidget){ + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationTop = relativeWidget.getTopBoundary(); + var locationRight = relativeWidget.getRightBoundary(); + this._finalPositionY = locationTop - (1.0 - ap.y) * cs.height; + this._finalPositionX = locationRight + ap.x * cs.width; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER: + if (relativeWidget){ + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var rbs = relativeWidget.getSize(); + var locationRight = relativeWidget.getRightBoundary(); + this._finalPositionX = locationRight + ap.x * cs.width; + this._finalPositionY = relativeWidget.getBottomBoundary() + rbs.height * 0.5 + ap.y * cs.height - cs.height * 0.5; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN: + if (relativeWidget){ + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationBottom = relativeWidget.getBottomBoundary(); + var locationRight = relativeWidget.getRightBoundary(); + this._finalPositionY = locationBottom + ap.y * cs.height; + this._finalPositionX = locationRight + ap.x * cs.width; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN: + if (relativeWidget){ + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationBottom = relativeWidget.getBottomBoundary(); + var locationLeft = relativeWidget.getLeftBoundary(); + this._finalPositionY = locationBottom - (1.0 - ap.y) * cs.height; + this._finalPositionX = locationLeft + ap.x * cs.width; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER: + if (relativeWidget) { + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var rbs = relativeWidget.getSize(); + var locationBottom = relativeWidget.getBottomBoundary(); + + this._finalPositionY = locationBottom - (1.0 - ap.y) * cs.height; + this._finalPositionX = relativeWidget.getLeftBoundary() + rbs.width * 0.5 + ap.x * cs.width - cs.width * 0.5; + } + break; + case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN: + if (relativeWidget) { + if (this._relativeWidgetLP && !this._relativeWidgetLP._put) + return false; + var locationBottom = relativeWidget.getBottomBoundary(); + var locationRight = relativeWidget.getRightBoundary(); + this._finalPositionY = locationBottom - (1.0 - ap.y) * cs.height; + this._finalPositionX = locationRight - (1.0 - ap.x) * cs.width; + } + break; + default: + break; + } + return true; + }, + + _caculateFinalPositionWithRelativeAlign: function(){ + var layoutParameter = this._widget.getLayoutParameter(); + + var mg = layoutParameter.getMargin(); + var align = layoutParameter.getAlign(); + + //handle margin + switch (align) { + case ccui.RelativeLayoutParameter.NONE: + case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT: + this._finalPositionX += mg.left; + this._finalPositionY -= mg.top; + break; + case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL: + this._finalPositionY -= mg.top; + break; + case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT: + this._finalPositionX -= mg.right; + this._finalPositionY -= mg.top; + break; + case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL: + this._finalPositionX += mg.left; + break; + case ccui.RelativeLayoutParameter.CENTER_IN_PARENT: + break; + case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL: + this._finalPositionX -= mg.right; + break; + case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM: + this._finalPositionX += mg.left; + this._finalPositionY += mg.bottom; + break; + case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL: + this._finalPositionY += mg.bottom; + break; + case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM: + this._finalPositionX -= mg.right; + this._finalPositionY += mg.bottom; + break; + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN: + this._finalPositionY += mg.bottom; + this._finalPositionX += mg.left; + break; + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN: + this._finalPositionY += mg.bottom; + this._finalPositionX -= mg.right; + break; + case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER: + this._finalPositionY += mg.bottom; + break; + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN: + this._finalPositionX -= mg.right; + this._finalPositionY -= mg.top; + break; + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN: + this._finalPositionX -= mg.right; + this._finalPositionY += mg.bottom; + break; + case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER: + this._finalPositionX -= mg.right; + break; + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN: + this._finalPositionX += mg.left; + this._finalPositionY -= mg.top; + break; + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN: + this._finalPositionX += mg.left; + this._finalPositionY += mg.bottom; + break; + case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER: + this._finalPositionX += mg.left; + break; + case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN: + this._finalPositionY -= mg.top; + this._finalPositionX += mg.left; + break; + case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN: + this._finalPositionY -= mg.top; + this._finalPositionX -= mg.right; + break; + case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER: + this._finalPositionY -= mg.top; + break; + default: + break; + } + } +}); + +ccui.RelativeLayoutManager.create = function(){ + return new ccui.RelativeLayoutManager(); +}; \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 7a496ae5b9..5419f762fd 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -24,7 +24,58 @@ ****************************************************************************/ /** - * Base class for ccui.LayoutParameter + * Base class for ccui.Margin + * @class + * @extends ccui.Class + */ +ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ + left: 0, + top: 0, + right: 0, + bottom: 0, + ctor: function (margin, top, right, bottom) { + if (margin && top === undefined) { + this.left = margin.left; + this.top = margin.top; + this.right = margin.right; + this.bottom = margin.bottom; + } + if (bottom !== undefined) { + this.left = margin; + this.top = top; + this.right = right; + this.bottom = bottom; + } + }, + /** + * set margin + * @param {Number} l + * @param {Number} t + * @param {Number} r + * @param {Number} b + */ + setMargin: function (l, t, r, b) { + this.left = l; + this.top = t; + this.right = r; + this.bottom = b; + }, + /** + * check is equals + * @param {ccui.Margin} target + * @returns {boolean} + */ + equals: function (target) { + return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom); + } +}); + +ccui.MarginZero = function(){ + return new ccui.Margin(0,0,0,0); +}; + +/** + * Layout parameter define * @class * @extends ccui.Class */ @@ -102,10 +153,15 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * var uiLayoutParameter = ccui.LayoutParameter.create(); */ ccui.LayoutParameter.create = function () { - var parameter = new ccui.LayoutParameter(); - return parameter; + return new ccui.LayoutParameter(); }; +// Constants +//layout parameter type +ccui.LayoutParameter.NONE = 0; +ccui.LayoutParameter.LINEAR = 1; +ccui.LayoutParameter.RELATIVE = 2; + /** * Base class for ccui.LinearLayoutParameter * @class @@ -115,13 +171,13 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL _linearGravity: null, ctor: function () { ccui.LayoutParameter.prototype.ctor.call(this); - this._linearGravity = ccui.LINEAR_GRAVITY_NONE; + this._linearGravity = ccui.LinearLayoutParameter.NONE; this._layoutParameterType = ccui.LayoutParameter.LINEAR; }, /** * Sets LinearGravity parameter for LayoutParameter. - * @param {ccui.LINEAR_GRAVITY_NONE|ccui.LINEAR_GRAVITY_TOP|ccui.LINEAR_GRAVITY_RIGHT|ccui.LINEAR_GRAVITY_BOTTOM|ccui.LINEAR_GRAVITY_CENTER_VERTICAL|ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL} gravity + * @param {Number} gravity */ setGravity: function (gravity) { this._linearGravity = gravity; @@ -129,7 +185,7 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL /** * Gets LinearGravity parameter for LayoutParameter. - * @returns {ccui.LINEAR_GRAVITY_NONE|ccui.LINEAR_GRAVITY_TOP|ccui.LINEAR_GRAVITY_RIGHT|ccui.LINEAR_GRAVITY_BOTTOM|ccui.LINEAR_GRAVITY_CENTER_VERTICAL|ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL} + * @returns {Number} */ getGravity: function () { return this._linearGravity; @@ -168,10 +224,19 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL * var uiLinearLayoutParameter = ccui.LinearLayoutParameter.create(); */ ccui.LinearLayoutParameter.create = function () { - var parameter = new ccui.LinearLayoutParameter(); - return parameter; + return new ccui.LinearLayoutParameter(); }; +// Constants +//Linear layout parameter LinearGravity +ccui.LinearLayoutParameter.NONE = 0; +ccui.LinearLayoutParameter.LEFT = 1; +ccui.LinearLayoutParameter.TOP = 2; +ccui.LinearLayoutParameter.RIGHT = 3; +ccui.LinearLayoutParameter.BOTTOM = 4; +ccui.LinearLayoutParameter.CENTER_VERTICAL = 5; +ccui.LinearLayoutParameter.CENTER_HORIZONTAL = 6; + /** * Base class for ccui.RelativeLayoutParameter * @class @@ -184,7 +249,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat _put:false, ctor: function () { ccui.LayoutParameter.prototype.ctor.call(this); - this._relativeAlign = ccui.RELATIVE_ALIGN_NONE; + this._relativeAlign = ccui.RelativeLayoutParameter.NONE; this._relativeWidgetName = ""; this._relativeLayoutName = ""; this._put = false; @@ -244,7 +309,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat * @returns {ccui.RelativeLayoutParameter} */ createCloneInstance:function(){ - return ccui.RelativeLayoutParameter.create(); + return ccui.RelativeLayoutParameter.create(); //TODO }, /** @@ -268,13 +333,33 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat * var uiRelativeLayoutParameter = ccui.RelativeLayoutParameter.create(); */ ccui.RelativeLayoutParameter.create = function () { - var parameter = new ccui.RelativeLayoutParameter(); - return parameter; + return new ccui.RelativeLayoutParameter(); }; - // Constants -//layout parameter type -ccui.LayoutParameter.NONE = 0; -ccui.LayoutParameter.LINEAR = 1; -ccui.LayoutParameter.RELATIVE = 2; \ No newline at end of file +//Relative layout parameter RelativeAlign +ccui.RelativeLayoutParameter.NONE = 0; +ccui.RelativeLayoutParameter.PARENT_TOP_LEFT = 1; +ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL = 2; +ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT = 3; +ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL = 4; + +ccui.RelativeLayoutParameter.CENTER_IN_PARENT = 5; + +ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL = 6; +ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM = 7; +ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL = 8; +ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM = 9; + +ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN = 10; +ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER = 11; +ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN = 12; +ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN = 13; +ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER = 14; +ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN = 15; +ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN = 16; +ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER = 17; +ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN = 18; +ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN = 19; +ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER = 20; +ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN = 21; \ No newline at end of file diff --git a/extensions/ccui/system/CocosGUI.js b/extensions/ccui/system/CocosGUI.js index bcd9f7c123..83f75333b7 100644 --- a/extensions/ccui/system/CocosGUI.js +++ b/extensions/ccui/system/CocosGUI.js @@ -28,6 +28,7 @@ */ var ccui = ccui || {}; +//These classes defines are use for jsDoc /** * The same as cc.Class * @class @@ -43,6 +44,23 @@ ccui.Class.extend = ccui.Class.extend || cc.Class.extend; ccui.Node = ccui.Node || cc.Node; ccui.Node.extend = ccui.Node.extend || cc.Node.extend; +/** + * that same as cc.NodeRGBA + * @class + * @extends ccui.Node + */ +ccui.NodeRGBA = ccui.NodeRGBA || cc.NodeRGBA; +ccui.NodeRGBA.extend = ccui.NodeRGBA.extend || cc.NodeRGBA.extend; + + +/** + * that same as cc.Node + * @class + * @extends ccui.NodeRGBA + */ +ccui.ProtectedNode = ccui.ProtectedNode || cc.ProtectedNode; +ccui.ProtectedNode.extend = ccui.ProtectedNode.extend || cc.ProtectedNode.extend; + /** * Cocos GUI version * @type {String} diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index fff3af6778..94f0c8b9c9 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -119,6 +119,4 @@ ccui.helper = { } return null; } - }; -ccui.helper; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 61b13b2f35..b1e45eed3d 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -119,13 +119,13 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ var defaultLp = ccui.LinearLayoutParameter.create(); switch (this._gravity) { case ccui.ListView.GRAVITY_LEFT: - defaultLp.setGravity(ccui.LINEAR_GRAVITY_LEFT); + defaultLp.setGravity(ccui.LinearLayoutParameter.LEFT); break; case ccui.ListView.GRAVITY_RIGHT: - defaultLp.setGravity(ccui.LINEAR_GRAVITY_RIGHT); + defaultLp.setGravity(ccui.LinearLayoutParameter.RIGHT); break; case ccui.ListView.GRAVITY_CENTER_HORIZONTAL: - defaultLp.setGravity(ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL); + defaultLp.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL); break; default: break; @@ -147,13 +147,13 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } switch (this._gravity) { case ccui.ListView.GRAVITY_LEFT: - llp.setGravity(ccui.LINEAR_GRAVITY_LEFT); + llp.setGravity(ccui.LinearLayoutParameter.LEFT); break; case ccui.ListView.GRAVITY_RIGHT: - llp.setGravity(ccui.LINEAR_GRAVITY_RIGHT); + llp.setGravity(ccui.LinearLayoutParameter.RIGHT); break; case ccui.ListView.GRAVITY_CENTER_HORIZONTAL: - llp.setGravity(ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL); + llp.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL); break; default: break; @@ -166,13 +166,13 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ var defaultLp = ccui.LinearLayoutParameter.create(); switch (this._gravity) { case ccui.ListView.GRAVITY_TOP: - defaultLp.setGravity(ccui.LINEAR_GRAVITY_TOP); + defaultLp.setGravity(ccui.LinearLayoutParameter.TOP); break; case ccui.ListView.GRAVITY_BOTTOM: - defaultLp.setGravity(ccui.LINEAR_GRAVITY_BOTTOM); + defaultLp.setGravity(ccui.LinearLayoutParameter.BOTTOM ); break; case ccui.ListView.GRAVITY_CENTER_VERTICAL: - defaultLp.setGravity(ccui.LINEAR_GRAVITY_CENTER_VERTICAL); + defaultLp.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL); break; default: break; @@ -194,13 +194,13 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } switch (this._gravity) { case ccui.ListView.GRAVITY_TOP: - llp.setGravity(ccui.LINEAR_GRAVITY_TOP); + llp.setGravity(ccui.LinearLayoutParameter.TOP); break; case ccui.ListView.GRAVITY_BOTTOM: - llp.setGravity(ccui.LINEAR_GRAVITY_BOTTOM); + llp.setGravity(ccui.LinearLayoutParameter.BOTTOM); break; case ccui.ListView.GRAVITY_CENTER_VERTICAL: - llp.setGravity(ccui.LINEAR_GRAVITY_CENTER_VERTICAL); + llp.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL); break; default: break; @@ -288,7 +288,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * Returns a item whose index is same as the parameter. * @param {Number} index - * @returns {cc.Widget} + * @returns {ccui.Widget} */ getItem: function (index) { if (index < 0 || index >= this._items.length) { diff --git a/moduleConfig.json b/moduleConfig.json index a41b46b1b7..17dbbd9d52 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -262,11 +262,12 @@ ], "ccui" : [ "core", "gui", "actions", "labels", "text-input","clipping-nodes", + "extensions/ccui/base-classes/CCProtectedNode.js", "extensions/ccui/system/CocosGUI.js", "extensions/ccui/base-classes/UIWidget.js", "extensions/ccui/layouts/UILayout.js", "extensions/ccui/layouts/UILayoutParameter.js", - "extensions/ccui/layouts/UILayoutDefine.js", + "extensions/ccui/layouts/UILayoutManager.js", "extensions/ccui/layouts/UIHBox.js", "extensions/ccui/layouts/UIRelativeBox.js", "extensions/ccui/layouts/UIVBox.js", diff --git a/tools/build.xml b/tools/build.xml index 8afae20eab..8d468fd909 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -164,7 +164,7 @@ - + diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml index a47b4b2f11..9913c209fb 100644 --- a/tools/jsdoc_toolkit/build.xml +++ b/tools/jsdoc_toolkit/build.xml @@ -159,7 +159,7 @@ - + From d64722444897c4d9079e445bc379a3e88d5f87ce Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 30 Jun 2014 17:46:57 +0800 Subject: [PATCH 0202/1564] Improve some docs --- cocos2d/core/CCConfiguration.js | 1 + cocos2d/core/event-manager/CCEventManager.js | 4 +++- cocos2d/core/platform/CCSAXParser.js | 1 - cocos2d/core/sprites/CCAnimationCache.js | 3 ++- cocos2d/core/sprites/CCSpriteFrameCache.js | 6 ++++-- cocos2d/core/textures/CCTextureCache.js | 3 ++- cocos2d/shaders/CCShaderCache.js | 3 ++- extensions/ccui/system/UIHelper.js | 3 ++- extensions/cocostudio/action/CCActionManager.js | 1 + .../cocostudio/armature/utils/CCArmatureDataManager.js | 1 + extensions/cocostudio/reader/GUIReader.js | 1 + extensions/cocostudio/reader/SceneReader.js | 1 + 12 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/CCConfiguration.js b/cocos2d/core/CCConfiguration.js index 54ef6f2de6..cdaccb93b5 100644 --- a/cocos2d/core/CCConfiguration.js +++ b/cocos2d/core/CCConfiguration.js @@ -26,6 +26,7 @@ /** * @namespace cc.configuration contains some openGL variables + * @name cc.configuration */ cc.configuration = /** @lends cc.configuration# */{ // Type constants diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index e235a8202d..2d65c5e25f 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -101,7 +101,9 @@ cc.__getListenerID = function (event) { }; /** - * @namespace

+ * @namespace + * @name cc.eventManager + *

* This class manages event listener subscriptions and event dispatching.
*
* The EventListener list is managed in such a way that event listeners can be added and removed even
diff --git a/cocos2d/core/platform/CCSAXParser.js b/cocos2d/core/platform/CCSAXParser.js index d4cbeedc49..fb094d205e 100644 --- a/cocos2d/core/platform/CCSAXParser.js +++ b/cocos2d/core/platform/CCSAXParser.js @@ -25,7 +25,6 @@ ****************************************************************************/ /** - * * @namespace A SAX Parser * @name cc.saxParser */ diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 1980a7aa8f..5697b3fbef 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -26,8 +26,9 @@ /** * @namespace + * @name cc.animationCache *

- * Singleton that manages the Animations.
+ * cc.animationCache is a singleton that manages the Animations.
* It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
*
* example
diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 4d89fe1947..3f493638fb 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -25,8 +25,10 @@ ****************************************************************************/ /** - * @namespace

- * Singleton that handles the loading of the sprite frames. It saves in a cache the sprite frames.
+ * @namespace + * @name cc.spriteFrameCache + *

+ * cc.spriteFrameCache is a singleton that handles the loading of the sprite frames. It saves in a cache the sprite frames.
*
* example
* // add SpriteFrames to spriteFrameCache With File
diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 13da9eed16..c60c396126 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -25,7 +25,8 @@ ****************************************************************************/ /** - * @namespace The global cache for cc.Texture2D + * @namespace cc.textureCache is the global cache for cc.Texture2D + * @name cc.textureCache */ cc.textureCache = /** @lends cc.textureCache# */{ _textures: {}, diff --git a/cocos2d/shaders/CCShaderCache.js b/cocos2d/shaders/CCShaderCache.js index 894122046e..e103325f6e 100644 --- a/cocos2d/shaders/CCShaderCache.js +++ b/cocos2d/shaders/CCShaderCache.js @@ -25,7 +25,8 @@ ****************************************************************************/ /** - * @namespace Singleton object that stores manages GL shaders + * @namespace cc.shaderCache is a singleton object that stores manages GL shaders + * @name cc.shaderCache */ cc.shaderCache = /** @lends cc.shaderCache# */{ diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index fff3af6778..de11840dcc 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -24,8 +24,9 @@ ****************************************************************************/ /** + * @namespace + * @name ccui.helper * UI Helper - * @type {Object} */ ccui.helper = { /** diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index a4a9becbbf..8deeb70e36 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -25,6 +25,7 @@ /** * @namespace Base singleton object for ccs.ActionManager + * @name ccs.actionManager */ ccs.actionManager = /** @lends ccs.actionManager# */{ _actionDic: {}, diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 573f6d4a41..b1b8960a50 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -36,6 +36,7 @@ ccs.RelativeData = function(){ /** * @namespace Format and manage armature configuration and armature animation + * @name ccs.armatureDataManager */ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ _animationDatas: {}, diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index da642efd68..a412b1ae7c 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -24,6 +24,7 @@ ****************************************************************************/ /** * @namespace Base object for ccs.uiReader + * @name ccs.uiReader */ ccs.uiReader = /** @lends ccs.uiReader# */{ _filePath: "", diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 9f6f44dd0c..239f82c7fa 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -25,6 +25,7 @@ /** * @namespace Base singleton object for ccs.sceneReader + * @name ccs.sceneReader */ ccs.sceneReader = /** @lends ccs.sceneReader# */{ _baseBath:"", From 9dd0fbe0929cebded72b5d25e9cf723b9dd47202 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 30 Jun 2014 20:25:20 +0800 Subject: [PATCH 0203/1564] Issue #5600: Sync ccui.Widget to -x latest code --- cocos2d/core/base-nodes/CCNode.js | 32 ++++- extensions/ccui/base-classes/UIWidget.js | 145 +---------------------- extensions/ccui/layouts/UILayout.js | 2 +- extensions/ccui/uiwidgets/UIButton.js | 10 +- 4 files changed, 40 insertions(+), 149 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index db19443fba..49408c1017 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -174,6 +174,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _rotationRadiansY: 0, _className: "Node", _showNode: false, + _name: "", ///
* Returns a custom user data pointer
@@ -1109,7 +1126,20 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return node; } } - //throw "not found"; + return null; + }, + + getChildByName: function(name){ + if(!name){ + cc.log("Invalid name"); + return null; + } + + var locChildren = this._children; + for(var i = 0, len = locChildren.length; i < len; i++){ + if(locChildren[i]._name == name) + return locChildren[i]; + } return null; }, // composition: ADD diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index f90adf658d..7009bb1e41 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -73,7 +73,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ _focusEnabled: true, _ignoreSize: false, - _widgetChildren: null, _affectByClipping: false, _sizeType: null, @@ -89,7 +88,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ _flippedX: false, _flippedY: false, _opacity: 255, - _focusEnabled: false, _highlight: false, _touchEventCallback: null, @@ -104,7 +102,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._size = cc.size(0, 0); this._customSize = cc.size(0, 0); this._layoutParameterDictionary = {}; - this._widgetChildren = []; this._sizeType = ccui.Widget.SIZE_ABSOLUTE; this._sizePercent = cc.p(0, 0); this.positionType = ccui.Widget.POSITION_ABSOLUTE; @@ -122,7 +119,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ init: function () { if (cc.ProtectedNode.prototype.init.call(this)) { this._layoutParameterDictionary = {}; - this._widgetChildren = []; this.initRenderer(); this.setBright(true); this.ignoreContentAdaptWithSize(true); @@ -151,86 +147,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, - sortAllChildren: function () { - this._reorderWidgetChildDirty = this._reorderChildDirty; - cc.Node.prototype.sortAllChildren.call(this); - if (this._reorderWidgetChildDirty) { - var _children = this._widgetChildren; - var i, j, length = _children.length, tempChild; - - // insertion sort - for (i = 0; i < length; i++) { - var tempItem = _children[i]; - j = i - 1; - tempChild = _children[j]; - - //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller - while (j >= 0 && ( tempItem._localZOrder < tempChild._localZOrder || - ( tempItem._localZOrder == tempChild._localZOrder && tempItem.arrivalOrder < tempChild.arrivalOrder ))) { - _children[j + 1] = tempChild; - j = j - 1; - tempChild = _children[j]; - } - _children[j + 1] = tempItem; - } - - //don't need to check children recursively, that's done in visit of each child - - this._reorderWidgetChildDirty = false; - } - }, - - /** - * Adds a child to the container. - * @param {ccui.Widget} widget - * @param {Number} zOrder - * @param {Number} tag - */ - addChild: function (widget, zOrder, tag) { - if (widget instanceof ccui.Widget) { - cc.Node.prototype.addChild.call(this, widget, zOrder, tag); - this._widgetChildren.push(widget); - return; - } - if (widget instanceof cc.Node) { - cc.log("Please use addNode to add a CCNode."); - return; - } - }, - - /** - * - * @param tag - * @returns {ccui.Widget} - */ - getChildByTag: function (tag) { - var __children = this._widgetChildren; - if (__children != null) { - for (var i = 0; i < __children.length; i++) { - var node = __children[i]; - if (node && node.tag == tag) - return node; - } - } - return null; - }, - - /** - * Return an array of children - * @returns {Array} - */ - getChildren: function () { - return this._widgetChildren; - }, - - /** - * get the count of children - * @returns {Number} - */ - getChildrenCount: function () { - return this._widgetChildren.length; - }, - getWidgetParent: function () { var widget = this.getParent(); if (widget instanceof ccui.Widget) { @@ -297,42 +213,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, - /** - * remove child - * @param {ccui.Widget} widget - * @param {Boolean} cleanup - */ - removeChild: function (widget, cleanup) { - if (!(widget instanceof ccui.Widget)) { - cc.log("child must a type of ccui.Widget"); - return; - } - cc.Node.prototype.removeChild.call(this, widget, cleanup); - cc.arrayRemoveObject(this._widgetChildren, widget); - }, - - removeChildByTag: function (tag, cleanup) { - var child = this.getChildByTag(tag); - - if (child == null) { - cc.log("cocos2d: removeChildByTag(tag = " + tag + "): child not found!"); - } - else { - this.removeChild(child, cleanup); - } - }, - - /** - * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. - */ - removeAllChildren: function (cleanup) { - for (var i = 0; i < this._widgetChildren.length; i++) { - var widget = this._widgetChildren[i]; - cc.Node.prototype.removeChild.call(this, widget, cleanup); - } - this._widgetChildren.length = 0; - }, - /** *

* Sets whether the widget is enabled
@@ -343,29 +223,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setEnabled: function (enabled) { this._enabled = enabled; - //TODO need test -/* var arrayChildren = this._widgetChildren; - var childrenCount = arrayChildren.length; - for (var i = 0; i < childrenCount; i++) { - var child = arrayChildren[i]; - child.setEnabled(enabled); - }*/ - }, - - /** - * Gets a child from the container with its name - * @param {string} name - * @returns {ccui.Widget} - */ - getChildByName: function (name) { - var arrayChildren = this._widgetChildren; - var childrenCount = arrayChildren.length; - for (var i = 0; i < childrenCount; i++) { - var child = arrayChildren[i]; - if (child.getName() == name) { - return child; - } - } }, /** @@ -719,7 +576,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ var locChildren = this.getChildren(); for (var i = 0, len = locChildren.length; i < len; i++) { var child = locChildren[i]; - if(child) + if(child instanceof ccui.Widget) child.updateSizeAndPosition(); } }, diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index a212a28599..1d14ca499d 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1211,7 +1211,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var locChild = null; for (var i = 0; i < layoutChildrenArray.length; i++) { locChild = layoutChildrenArray[i]; - if(locChild) + if(locChild instanceof ccui.Widget) this.supplyTheLayoutParameterLackToChild(locChild); } this._doLayoutDirty = true; diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 3107a10787..4c80340490 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -838,14 +838,18 @@ _p = null; /** * allocates and initializes a UIButton. - * @constructs + * @param {string} [normalImage] normal state texture name + * @param {string} [selectedImage] selected state texture name + * @param {string} [disableImage] disabled state texture name + * @param {string} [texType] * @return {ccui.Button} * @example * // example * var uiButton = ccui.Button.create(); */ -ccui.Button.create = function () { - return new ccui.Button; +ccui.Button.create = function (normalImage, selectedImage, disableImage, texType) { + if(normalImage === undefined) + return new ccui.Button(); }; // Constants From 7ccb4664a188011af9eb7ef904a5eea2fd57ed2c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Jun 2014 20:29:05 +0800 Subject: [PATCH 0204/1564] Issue #5592: Facebook plugin --- extensions/pluginx/platform/facebook.js | 87 ++++++++++++++++++++----- 1 file changed, 69 insertions(+), 18 deletions(-) diff --git a/extensions/pluginx/platform/facebook.js b/extensions/pluginx/platform/facebook.js index e2b5ae1bca..05bf452740 100644 --- a/extensions/pluginx/platform/facebook.js +++ b/extensions/pluginx/platform/facebook.js @@ -190,26 +190,77 @@ } }, + /** + * shareInfo parameters support both AnySDK style and facebook style + * 1. AnySDK style + * - title + * - site + * - siteUrl + * - text + * - imageUrl + * - imagePath + * + * 2. Facebook style + * - caption + * - name + * - link + * - description + * - picture + */ dialog: function(options, callback){ - FB.ui({ - method: 'share', - name: options['title'], - caption: options['caption'], - description: options['text'], - href: options['link'], - picture: options['imageUrl'] - }, - function(response) { - if (response) { - if(response.post_id) - typeof callback === 'function' && callback(0, errMsg[0]); - else - typeof callback === 'function' && callback(3, errMsg[3]); - } else { - typeof callback === 'function' && callback(4, errMsg[4]); - } - }); + if(!options){ + return; + } + + options['method'] = options['dialog'] == 'share_open_graph' ? 'share_open_graph' : 'share'; + delete options['dialog']; + + options['name'] = options['site'] || options['name']; + delete options['site']; + delete options['name']; + + options['href'] = options['siteUrl'] || options['link']; + delete options['siteUrl']; + delete options['link']; + + options['picture'] = options['imageUrl'] || options['imagePath'] || options['photo'] || options['picture']; + delete options['imageUrl']; + delete options['imagePath']; + delete options['photo']; + + + options['caption'] = options['title'] || options['caption']; + delete options['title']; + + options['description'] = options['text'] || options['description']; + delete options['text']; + delete options['description']; + + if(options['method'] == 'share_open_graph' && options['url']){ + if(options['url']){ + options['action_properties'] = JSON.stringify({ + object: options['url'] + }); + }else{ + return; + } + }else{ + if(!options['href']){ + return; + } + } + FB.ui(options, + function(response) { + if (response) { + if(response.post_id) + typeof callback === 'function' && callback(0, errMsg[0]); + else + typeof callback === 'function' && callback(3, errMsg[3]); + } else { + typeof callback === 'function' && callback(4, errMsg[4]); + } + }); }, ui: FB.ui, From db94b2178cc5a0db1d37196e1caf303c22dea8bd Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 1 Jul 2014 11:53:37 +0800 Subject: [PATCH 0205/1564] Issue #5600: sync ccui.Widget, ccui.Button, ccui.CheckBox, ccui.ImageView, ccui.LoadingBar, ccui.RichText --- extensions/ccui/base-classes/UIWidget.js | 2 +- extensions/ccui/uiwidgets/UIButton.js | 393 +++++++++--------- extensions/ccui/uiwidgets/UICheckBox.js | 222 ++++++---- extensions/ccui/uiwidgets/UIImageView.js | 140 +++---- extensions/ccui/uiwidgets/UILoadingBar.js | 219 +++++----- extensions/ccui/uiwidgets/UIRichText.js | 104 ++--- .../uiwidgets/scroll-widget/UIScrollView.js | 44 +- 7 files changed, 601 insertions(+), 523 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 7009bb1e41..eb2332f18a 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -64,7 +64,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ _name: "default", _widgetType: null, _actionTag: 0, - _size: cc.size(0, 0), + _size: cc.size(0,0), _customSize: null, _layoutParameterDictionary: null, _layoutParameterType:0, diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 4c80340490..11b7b2833c 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -56,7 +56,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _pressedTextureSize: null, _disabledTextureSize: null, pressedActionEnabled: false, - _titleColor: cc.color.WHITE, + _titleColor: null, _normalTextureScaleXInSize: 1, _normalTextureScaleYInSize: 1, _pressedTextureScaleXInSize: 1, @@ -66,6 +66,13 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _disabledTextureLoaded: false, _cascadeOpacityEnabled: true, _className: "Button", + _normalTextureAdaptDirty: true, + _pressedTextureAdaptDirty: true, + _disabledTextureAdaptDirty: true, + + _fontName: "Thonburi", + _fontSize: 12, + _type: 0, /** * allocates and initializes a UIButton. @@ -82,14 +89,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._normalTextureSize = cc.size(locSize.width, locSize.height); this._pressedTextureSize = cc.size(locSize.width, locSize.height); this._disabledTextureSize = cc.size(locSize.width, locSize.height); - + this._titleColor = cc.color.WHITE; ccui.Widget.prototype.ctor.call(this); }, - init: function () { + init: function (normalImage, selectedImage,disableImage, texType) { if (ccui.Widget.prototype.init.call(this)) { this.setTouchEnabled(true); - return true; + if(normalImage === undefined) + return true; + this.loadTextures(normalImage, selectedImage,disableImage, texType); } return false; }, @@ -99,10 +108,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer = cc.Sprite.create(); this._buttonDisableRenderer = cc.Sprite.create(); this._titleRenderer = cc.LabelTTF.create(""); - cc.Node.prototype.addChild.call(this, this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER); - cc.Node.prototype.addChild.call(this, this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER); - cc.Node.prototype.addChild.call(this, this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER); - cc.Node.prototype.addChild.call(this, this._titleRenderer, ccui.Button.TITLE_RENDERER_ZORDER); + this.addProtectedChild(this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER, -1); + this.addProtectedChild(this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER, -1); + this.addProtectedChild(this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER, -1); + this.addProtectedChild(this._titleRenderer, ccui.Button.TITLE_RENDERER_ZORDER, -1); }, /** @@ -110,22 +119,21 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {Boolean} able */ setScale9Enabled: function (able) { - if (this._scale9Enabled == able) { + if (this._scale9Enabled == able) return; - } + this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; this._scale9Enabled = able; - cc.Node.prototype.removeChild.call(this, this._buttonNormalRenderer, true); - cc.Node.prototype.removeChild.call(this, this._buttonClickedRenderer, true); - cc.Node.prototype.removeChild.call(this, this._buttonDisableRenderer, true); + this.removeProtectedChild(this._buttonNormalRenderer); + this.removeProtectedChild(this._buttonClickedRenderer); + this.removeProtectedChild(this._buttonDisableRenderer); if (this._scale9Enabled) { this._buttonNormalRenderer = cc.Scale9Sprite.create(); this._buttonClickedRenderer = cc.Scale9Sprite.create(); this._buttonDisableRenderer = cc.Scale9Sprite.create(); - } - else { + } else { this._buttonNormalRenderer = cc.Sprite.create(); this._buttonClickedRenderer = cc.Sprite.create(); this._buttonDisableRenderer = cc.Sprite.create(); @@ -134,15 +142,15 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.loadTextureNormal(this._normalFileName, this._normalTexType); this.loadTexturePressed(this._clickedFileName, this._pressedTexType); this.loadTextureDisabled(this._disabledFileName, this._disabledTexType); - cc.Node.prototype.addChild.call(this, this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER); - cc.Node.prototype.addChild.call(this, this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER); - cc.Node.prototype.addChild.call(this, this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER); + + this.addProtectedChild(this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER, -1); + this.addProtectedChild(this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER, -1); + this.addProtectedChild(this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER, -1); if (this._scale9Enabled) { var ignoreBefore = this._ignoreSize; this.ignoreContentAdaptWithSize(false); this._prevIgnoreSize = ignoreBefore; - } - else { + } else { this.ignoreContentAdaptWithSize(this._prevIgnoreSize); } this.setCapInsetsNormalRenderer(this._capInsetsNormal); @@ -159,10 +167,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return this._scale9Enabled; }, - /** - * ignoreContentAdaptWithSize - * @param {Boolean} ignore - */ ignoreContentAdaptWithSize: function (ignore) { if (!this._scale9Enabled || (this._scale9Enabled && !ignore)) { ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, ignore); @@ -170,6 +174,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } }, + getVirtualRendererSize: function(){ + return this._normalTextureSize; + }, + /** * Load textures for button. * @param {String} normal @@ -189,50 +197,47 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureNormal: function (normal, texType) { - if (!normal) { + if (!normal) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._normalFileName = normal; this._normalTexType = texType; - var buttonNormalRenderer = this._buttonNormalRenderer; - switch (this._normalTexType) { - case ccui.Widget.LOCAL_TEXTURE: - buttonNormalRenderer.initWithFile(normal); - break; - case ccui.Widget.PLIST_TEXTURE: - buttonNormalRenderer.initWithSpriteFrameName(normal); - break; - default: - break; - } - - var buttonRenderSize = buttonNormalRenderer.getContentSize(); - if (buttonNormalRenderer.textureLoaded()) { - this._normalTextureSize.width = buttonRenderSize.width; - this._normalTextureSize.height = buttonRenderSize.height; - } else { - buttonNormalRenderer.addLoadedEventListener(function () { - this._normalTextureSize = buttonNormalRenderer.getContentSize(); - if (buttonNormalRenderer.setCapInsets) { - buttonNormalRenderer.setCapInsets(this._capInsetsNormal); - } - this.normalTextureScaleChangedWithSize(); - }, this); - this._normalTextureSize.width = this._customSize.width; - this._normalTextureSize.height = this._customSize.height; - } if (this._scale9Enabled) { - buttonNormalRenderer.setCapInsets(this._capInsetsNormal); + var normalRendererScale9 = this._buttonNormalRenderer; + switch (this._normalTexType){ + case ccui.Widget.LOCAL_TEXTURE: + normalRendererScale9.initWithFile(normal); + break; + case ccui.Widget.PLIST_TEXTURE: + normalRendererScale9.initWithSpriteFrameName(normal); + break; + default: + break; + } + normalRendererScale9.setCapInsets(this._capInsetsNormal); + } else { + var normalRenderer = this._buttonNormalRenderer; + switch (this._normalTexType){ + case ccui.Widget.LOCAL_TEXTURE: + normalRenderer.setTexture(normal); + break; + case ccui.Widget.PLIST_TEXTURE: + normalRenderer.setSpriteFrame(normal); + break; + default: + break; + } } - - this.normalTextureScaleChangedWithSize(); - this.updateColorToRenderer(buttonNormalRenderer); - this.updateAnchorPoint(); + this._normalTextureSize = this._buttonNormalRenderer.getContentSize(); this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(buttonNormalRenderer); + + this._buttonNormalRenderer.setColor(this.getColor()); + this._buttonNormalRenderer.setOpacity(this.getOpacity()); + + this._updateContentSizeWithTextureSize(this._normalTextureSize); this._normalTextureLoaded = true; + this._normalTextureAdaptDirty = true; }, /** @@ -241,48 +246,46 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexturePressed: function (selected, texType) { - if (!selected) { + if (!selected) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._clickedFileName = selected; this._pressedTexType = texType; - var clickedRenderer = this._buttonClickedRenderer; - switch (this._pressedTexType) { - case ccui.Widget.LOCAL_TEXTURE: - clickedRenderer.initWithFile(selected); - break; - case ccui.Widget.PLIST_TEXTURE: - clickedRenderer.initWithSpriteFrameName(selected); - break; - default: - break; - } - - if (clickedRenderer.textureLoaded()) { - this._pressedTextureSize = clickedRenderer.getContentSize(); - } else { - clickedRenderer.addLoadedEventListener(function () { - this._pressedTextureSize = clickedRenderer.getContentSize(); - if (clickedRenderer.setCapInsets) { - clickedRenderer.setCapInsets(this._capInsetsNormal); - } - this.pressedTextureScaleChangedWithSize(); - }, this); - this._pressedTextureSize.width = this._customSize.width; - this._pressedTextureSize.height = this._customSize.height; - } - if (this._scale9Enabled) { - clickedRenderer.setCapInsets(this._capInsetsNormal); + var clickedRendererScale9 = this._buttonClickedRenderer; + switch (this._pressedTexType) { + case ccui.Widget.LOCAL_TEXTURE: + clickedRendererScale9.initWithFile(selected); + break; + case ccui.Widget.PLIST_TEXTURE: + clickedRendererScale9.initWithSpriteFrameName(selected); + break; + default: + break; + } + clickedRendererScale9.setCapInsets(this._capInsetsPressed); + } else { + var clickedRenderer = this._buttonClickedRenderer; + switch (this._pressedTexType) { + case ccui.Widget.LOCAL_TEXTURE: + clickedRenderer.setTexture(selected); + break; + case ccui.Widget.PLIST_TEXTURE: + clickedRenderer.setSpriteFrame(selected); + break; + default: + break; + } } - this.updateColorToRenderer(clickedRenderer); - this.pressedTextureScaleChangedWithSize(); - this.updateAnchorPoint(); + this._pressedTextureSize = this._buttonClickedRenderer.getContentSize(); this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(this._buttonDisableRenderer); + + this._buttonDisableRenderer.setColor(this.getColor()); + this._buttonDisableRenderer.setOpacity(this.getOpacity()); + this._pressedTextureLoaded = true; + this._pressedTextureAdaptDirty = true; }, /** @@ -297,42 +300,40 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._disabledFileName = disabled; this._disabledTexType = texType; - var disableRenderer = this._buttonDisableRenderer; - switch (this._disabledTexType) { - case ccui.Widget.LOCAL_TEXTURE: - disableRenderer.initWithFile(disabled); - break; - case ccui.Widget.PLIST_TEXTURE: - disableRenderer.initWithSpriteFrameName(disabled); - break; - default: - break; - } - - if (disableRenderer.textureLoaded()) { - this._disabledTextureSize = disableRenderer.getContentSize(); - } else { - disableRenderer.addLoadedEventListener(function () { - this._disabledTextureSize = disableRenderer.getContentSize(); - if (disableRenderer.setCapInsets) { - disableRenderer.setCapInsets(this._capInsetsNormal); - } - this.disabledTextureScaleChangedWithSize(); - }, this); - this._disabledTextureSize.width = this._customSize.width; - this._disabledTextureSize.height = this._customSize.height; - } - if (this._scale9Enabled) { - disableRenderer.setCapInsets(this._capInsetsNormal); + var disabledScale9 = this._buttonDisableRenderer; + switch (this._disabledTexType) { + case ccui.Widget.LOCAL_TEXTURE: + disabledScale9.initWithFile(disabled); + break; + case ccui.Widget.PLIST_TEXTURE: + disabledScale9.initWithSpriteFrameName(disabled); + break; + default: + break; + } + disabledScale9.setCapInsets(this._capInsetsDisabled); + } else { + var disabledRenderer = this._buttonDisableRenderer; + switch (this._disabledTexType) { + case ccui.Widget.LOCAL_TEXTURE: + disabledRenderer.setTexture(disabled); + break; + case ccui.Widget.PLIST_TEXTURE: + disabledRenderer.setSpriteFrame(disabled); + break; + default: + break; + } } - this.updateColorToRenderer(disableRenderer); - this.disabledTextureScaleChangedWithSize(); - this.updateAnchorPoint(); + this._disabledTextureSize = this._buttonDisableRenderer.getContentSize(); this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(this._buttonDisableRenderer); + this._buttonDisableRenderer.setColor(this.getColor()); + this._buttonDisableRenderer.setOpacity(this.getOpacity()); + this._disabledTextureLoaded = true; + this._disabledTextureAdaptDirty = true; }, /** @@ -371,9 +372,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ setCapInsetsPressedRenderer: function (capInsets) { this._capInsetsPressed = capInsets; - if (!this._scale9Enabled) { + if (!this._scale9Enabled) return; - } this._buttonClickedRenderer.setCapInsets(capInsets); }, @@ -391,9 +391,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ setCapInsetsDisabledRenderer: function (capInsets) { this._capInsetsDisabled = capInsets; - if (!this._scale9Enabled) { + if (!this._scale9Enabled) return; - } this._buttonDisableRenderer.setCapInsets(capInsets); }, @@ -410,20 +409,20 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setVisible(false); this._buttonDisableRenderer.setVisible(false); if (this._pressedTextureLoaded) { - if (this.pressedActionEnabled) { + if (this.pressedActionEnabled){ this._buttonNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); - this._buttonDisableRenderer.stopAllActions(); - var zoomAction = cc.ScaleTo.create(0.05, 1.0); - var zoomAction1 = cc.ScaleTo.create(0.05, 1.0); - var zoomAction2 = cc.ScaleTo.create(0.05, 1.0); + var zoomAction = cc.ScaleTo.create(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); this._buttonNormalRenderer.runAction(zoomAction); - this._buttonClickedRenderer.runAction(zoomAction1); - this._buttonDisableRenderer.runAction(zoomAction2); + this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); } } else { - this._buttonNormalRenderer.stopAllActions(); - this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + if (this._scale9Enabled) + this.updateTexturesRGBA(); + else { + this._buttonNormalRenderer.stopAllActions(); + this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + } } }, @@ -435,20 +434,20 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this.pressedActionEnabled) { this._buttonNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); - this._buttonDisableRenderer.stopAllActions(); - var zoomAction = cc.ScaleTo.create(0.05, 1.1); - var zoomAction1 = cc.ScaleTo.create(0.05, 1.1); - var zoomAction2 = cc.ScaleTo.create(0.05, 1.1); - this._buttonNormalRenderer.runAction(zoomAction); - this._buttonClickedRenderer.runAction(zoomAction1); - this._buttonDisableRenderer.runAction(zoomAction2); + var zoomAction = cc.ScaleTo.create(0.05, this._pressedTextureScaleXInSize + 0.1,this._pressedTextureScaleYInSize + 0.1); + this._buttonClickedRenderer.runAction(zoomAction); + this._buttonNormalRenderer.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1); } } else { this._buttonNormalRenderer.setVisible(true); this._buttonClickedRenderer.setVisible(true); this._buttonDisableRenderer.setVisible(false); - this._buttonNormalRenderer.stopAllActions(); - this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); + if (this._scale9Enabled) + this._buttonNormalRenderer.setColor(cc.Color.GRAY); + else { + this._buttonNormalRenderer.stopAllActions(); + this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); + } } }, @@ -499,18 +498,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, updateFlippedX: function () { - this._titleRenderer.setFlippedX(this._flippedX); + var flip = this._flippedX ? -1.0 : 1.0; + this._titleRenderer.setScaleX(flip); if (this._scale9Enabled) { - if (this._flippedX) { - this._buttonNormalRenderer.setScaleX(-1); - this._buttonClickedRenderer.setScaleX(-1); - this._buttonDisableRenderer.setScaleX(-1); - } - else { - this._buttonNormalRenderer.setScaleX(1); - this._buttonClickedRenderer.setScaleX(1); - this._buttonDisableRenderer.setScaleX(1); - } + this._buttonNormalRenderer.setScaleX(flip); + this._buttonClickedRenderer.setScaleX(flip); + this._buttonDisableRenderer.setScaleX(flip); } else { this._buttonNormalRenderer.setFlippedX(this._flippedX); this._buttonClickedRenderer.setFlippedX(this._flippedX); @@ -519,18 +512,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, updateFlippedY: function () { - this._titleRenderer.setFlippedY(this._flippedY); + var flip = this._flippedY ? -1.0 : 1.0; + this._titleRenderer.setScaleY(flip); if (this._scale9Enabled) { - if (this._flippedX) { - this._buttonNormalRenderer.setScaleY(-1); - this._buttonClickedRenderer.setScaleX(-1); - this._buttonDisableRenderer.setScaleX(-1); - } - else { - this._buttonNormalRenderer.setScaleY(1); - this._buttonClickedRenderer.setScaleY(1); - this._buttonDisableRenderer.setScaleY(1); - } + this._buttonNormalRenderer.setScaleY(flip); + this._buttonClickedRenderer.setScaleY(flip); + this._buttonDisableRenderer.setScaleY(flip); } else { this._buttonNormalRenderer.setFlippedY(this._flippedY); this._buttonClickedRenderer.setFlippedY(this._flippedY); @@ -538,6 +525,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } }, + updateTexturesRGBA: function(){ + this._buttonNormalRenderer.setColor(this.getColor()); + this._buttonClickedRenderer.setColor(this.getColor()); + this._buttonDisableRenderer.setColor(this.getColor()); + + this._buttonNormalRenderer.setOpacity(this.getOpacity()); + this._buttonClickedRenderer.setOpacity(this.getOpacity()); + this._buttonDisableRenderer.setOpacity(this.getOpacity()); + }, + /** * override "setAnchorPoint" of widget. * @param {cc.Point|Number} point The anchor point of UIButton or The anchor point.x of UIButton. @@ -576,6 +573,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); + this.updateTitleLocation(); this.normalTextureScaleChangedWithSize(); this.pressedTextureScaleChangedWithSize(); this.disabledTextureScaleChangedWithSize(); @@ -609,10 +607,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ default: return null; } - } - else { + } else return this._buttonDisableRenderer; - } }, normalTextureScaleChangedWithSize: function () { @@ -620,16 +616,14 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (!this._scale9Enabled) { this._buttonNormalRenderer.setScale(1.0); this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1; - this._size.width = this._normalTextureSize.width; - this._size.height = this._normalTextureSize.height; + //this._size.width = this._normalTextureSize.width; + //this._size.height = this._normalTextureSize.height; //TODO need test } - } - else { + } else { if (this._scale9Enabled) { this._buttonNormalRenderer.setPreferredSize(this._size); this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1; - } - else { + } else { var textureSize = this._normalTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._buttonNormalRenderer.setScale(1.0); @@ -643,6 +637,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._normalTextureScaleYInSize = scaleY; } } + this._buttonNormalRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, pressedTextureScaleChangedWithSize: function () { @@ -651,13 +646,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setScale(1.0); this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1; } - } - else { + } else { if (this._scale9Enabled) { this._buttonClickedRenderer.setPreferredSize(this._size); this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1; - } - else { + } else { var textureSize = this._pressedTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._buttonClickedRenderer.setScale(1.0); @@ -671,18 +664,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._pressedTextureScaleYInSize = scaleY; } } + this._buttonClickedRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, disabledTextureScaleChangedWithSize: function () { if (this._ignoreSize) { - if (!this._scale9Enabled) { + if (!this._scale9Enabled) this._buttonDisableRenderer.setScale(1.0); - } - } - else { - if (this._scale9Enabled) { + } else { + if (this._scale9Enabled) this._buttonDisableRenderer.setPreferredSize(this._size); - } else { var textureSize = this._disabledTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { @@ -695,6 +686,26 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonDisableRenderer.setScaleY(scaleY); } } + this._buttonDisableRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); + }, + + adaptRenderers: function(){ + if (this._normalTextureAdaptDirty) { + this.normalTextureScaleChangedWithSize(); + this._normalTextureAdaptDirty = false; + } + if (this._pressedTextureAdaptDirty) { + this.pressedTextureScaleChangedWithSize(); + this._pressedTextureAdaptDirty = false; + } + if (this._disabledTextureAdaptDirty) { + this.disabledTextureScaleChangedWithSize(); + this._disabledTextureAdaptDirty = false; + } + }, + + updateTitleLocation: function(){ + this._titleRenderer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); }, /** @@ -729,7 +740,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._titleColor.r = color.r; this._titleColor.g = color.g; this._titleColor.b = color.b; - this._titleRenderer.setColor(color); + this._titleRenderer.updateDisplayedColor(color); }, /** @@ -848,8 +859,11 @@ _p = null; * var uiButton = ccui.Button.create(); */ ccui.Button.create = function (normalImage, selectedImage, disableImage, texType) { + var btn = new ccui.Button(); if(normalImage === undefined) - return new ccui.Button(); + return btn; + + btn.init(normalImage, selectedImage, disableImage, texType) }; // Constants @@ -857,3 +871,6 @@ ccui.Button.NORMAL_RENDERER_ZORDER = -2; ccui.Button.PRESSED_RENDERER_ZORDER = -2; ccui.Button.DISABLED_RENDERER_ZORDER = -2; ccui.Button.TITLE_RENDERER_ZORDER = -1; + +ccui.Button.SYSTEM = 0; +ccui.Button.TTF = 1; diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index bbe2a81cc1..6efdb77252 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -38,7 +38,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _frontCrossDisabledRenderer: null, _isSelected: true, _checkBoxEventListener: null, - _checkBoxEventSelector: null, + _checkBoxEventSelector:null, + _checkBoxEventCallback: null, _backGroundTexType: ccui.Widget.LOCAL_TEXTURE, _backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE, _frontCrossTexType: ccui.Widget.LOCAL_TEXTURE, @@ -51,6 +52,12 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _frontCrossDisabledFileName: "", _className: "CheckBox", + _backGroundBoxRendererAdaptDirty:true, + _backGroundSelectedBoxRendererAdaptDirty:true, + _frontCrossRendererAdaptDirty: true, + _backGroundBoxDisabledRendererAdaptDirty: true, + _frontCrossDisabledRendererAdaptDirty: true, + /** * allocates and initializes a UICheckBox. * Constructor of ccui.CheckBox @@ -66,7 +73,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._isSelected = true; this.setTouchEnabled(true); this.setSelectedState(false); - this.loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType); + if(backGround === undefined) + this.loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType); return true; } return false; @@ -78,11 +86,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossRenderer = cc.Sprite.create(); this._backGroundBoxDisabledRenderer = cc.Sprite.create(); this._frontCrossDisabledRenderer = cc.Sprite.create(); - cc.Node.prototype.addChild.call(this, this._backGroundBoxRenderer, ccui.CheckBox.BOX_RENDERER_ZORDER, -1); - cc.Node.prototype.addChild.call(this, this._backGroundSelectedBoxRenderer, ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER, -1); - cc.Node.prototype.addChild.call(this, this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1); - cc.Node.prototype.addChild.call(this, this._backGroundBoxDisabledRenderer, ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER, -1); - cc.Node.prototype.addChild.call(this, this._frontCrossDisabledRenderer, ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER, -1); + this.addProtectedChild(this._backGroundBoxRenderer, ccui.CheckBox.BOX_RENDERER_ZORDER, -1); + this.addProtectedChild(this._backGroundSelectedBoxRenderer, ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER, -1); + this.addProtectedChild(this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1); + this.addProtectedChild(this._backGroundBoxDisabledRenderer, ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER, -1); + this.addProtectedChild(this._frontCrossDisabledRenderer, ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER, -1); }, /** @@ -108,36 +116,38 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGround: function (backGround, texType) { - if (!backGround) { + if (!backGround) return; - } + texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundFileName = backGround; this._backGroundTexType = texType; var bgBoxRenderer = this._backGroundBoxRenderer; switch (this._backGroundTexType) { case ccui.Widget.LOCAL_TEXTURE: - bgBoxRenderer.initWithFile(backGround); + bgBoxRenderer.setTexture(backGround); break; case ccui.Widget.PLIST_TEXTURE: - bgBoxRenderer.initWithSpriteFrameName(backGround); + bgBoxRenderer.setSpriteFrame(backGround); break; default: break; } - this.backGroundTextureScaleChangedWithSize(); + this.backGroundTextureScaleChangedWithSize(); //TODO need test if (!bgBoxRenderer.textureLoaded()) { this._backGroundBoxRenderer.setContentSize(this._customSize); bgBoxRenderer.addLoadedEventListener(function () { this.backGroundTextureScaleChangedWithSize(); }, this); } - this.backGroundTextureScaleChangedWithSize(); - this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.updateColorToRenderer(bgBoxRenderer); + this._backGroundBoxRenderer.setColor(this.getColor()); + this._backGroundBoxRenderer.setOpacity(this.getOpacity()); + + this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); + this._backGroundBoxRendererAdaptDirty = true; }, /** * Load backGroundSelected texture for checkbox. @@ -145,27 +155,28 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGroundSelected: function (backGroundSelected, texType) { - if (!backGroundSelected) { + if (!backGroundSelected) return; - } + texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundSelectedFileName = backGroundSelected; this._backGroundSelectedTexType = texType; switch (this._backGroundSelectedTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._backGroundSelectedBoxRenderer.initWithFile(backGroundSelected); + this._backGroundSelectedBoxRenderer.setTexture(backGroundSelected); break; case ccui.Widget.PLIST_TEXTURE: - this._backGroundSelectedBoxRenderer.initWithSpriteFrameName(backGroundSelected); + this._backGroundSelectedBoxRenderer.setSpriteFrame(backGroundSelected); break; default: break; } - this.backGroundSelectedTextureScaleChangedWithSize(); - this.updateAnchorPoint(); + this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(this._backGroundSelectedBoxRenderer); + this._backGroundSelectedBoxRenderer.setColor(this.getColor()); + this._backGroundSelectedBoxRenderer.setOpacity(this.getOpacity()); + this._backGroundSelectedBoxRendererAdaptDirty = true; }, /** @@ -174,27 +185,26 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureFrontCross: function (cross, texType) { - if (!cross) { + if (!cross) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossFileName = cross; this._frontCrossTexType = texType; switch (this._frontCrossTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._frontCrossRenderer.initWithFile(cross); + this._frontCrossRenderer.setTexture(cross); break; case ccui.Widget.PLIST_TEXTURE: - this._frontCrossRenderer.initWithSpriteFrameName(cross); + this._frontCrossRenderer.setSpriteFrame(cross); break; default: break; } - this.frontCrossTextureScaleChangedWithSize(); - this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(this._frontCrossRenderer); + this._frontCrossRenderer.setColor(this.getColor()); + this._frontCrossRenderer.setOpacity(this.getOpacity()); + this._frontCrossRendererAdaptDirty = true; }, /** @@ -203,27 +213,26 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGroundDisabled: function (backGroundDisabled, texType) { - if (!backGroundDisabled) { + if (!backGroundDisabled) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundDisabledFileName = backGroundDisabled; this._backGroundDisabledTexType = texType; switch (this._backGroundDisabledTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._backGroundBoxDisabledRenderer.initWithFile(backGroundDisabled); + this._backGroundBoxDisabledRenderer.setTexture(backGroundDisabled); break; case ccui.Widget.PLIST_TEXTURE: - this._backGroundBoxDisabledRenderer.initWithSpriteFrameName(backGroundDisabled); + this._backGroundBoxDisabledRenderer.setSpriteFrame(backGroundDisabled); break; default: break; } - this.backGroundDisabledTextureScaleChangedWithSize(); - this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(this._backGroundBoxDisabledRenderer); + this._backGroundBoxDisabledRenderer.setColor(this.getColor()); + this._backGroundBoxDisabledRenderer.setOpacity(this.getOpacity()); + this._backGroundBoxDisabledRendererAdaptDirty = true; }, /** @@ -232,27 +241,26 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureFrontCrossDisabled: function (frontCrossDisabled, texType) { - if (!frontCrossDisabled) { + if (!frontCrossDisabled) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossDisabledFileName = frontCrossDisabled; this._frontCrossDisabledTexType = texType; switch (this._frontCrossDisabledTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._frontCrossDisabledRenderer.initWithFile(frontCrossDisabled); + this._frontCrossDisabledRenderer.setTexture(frontCrossDisabled); break; case ccui.Widget.PLIST_TEXTURE: - this._frontCrossDisabledRenderer.initWithSpriteFrameName(frontCrossDisabled); + this._frontCrossDisabledRenderer.setSpriteFrame(frontCrossDisabled); break; default: break; } - this.frontCrossDisabledTextureScaleChangedWithSize(); - this.updateAnchorPoint(); this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(this._frontCrossDisabledRenderer); + this._frontCrossDisabledRenderer.setColor(this.getColor()); + this._frontCrossDisabledRenderer.setOpacity(this.getOpacity()); + this._frontCrossDisabledRendererAdaptDirty = true; }, onTouchEnded: function (touch, event) { @@ -302,9 +310,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, setSelectedState: function (selected) { - if (selected == this._isSelected) { + if (selected == this._isSelected) return; - } this._isSelected = selected; this._frontCrossRenderer.setVisible(this._isSelected); }, @@ -314,14 +321,28 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, selectedEvent: function () { - if (this._checkBoxEventListener && this._checkBoxEventSelector) { + if(this._checkBoxEventCallback) + this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_SELECTED); + if (this._checkBoxEventListener && this._checkBoxEventSelector) this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_SELECTED); - } }, unSelectedEvent: function () { - if (this._checkBoxEventListener && this._checkBoxEventSelector) { + if(this._checkBoxEventCallback) + this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_UNSELECTED); + if (this._checkBoxEventListener && this._checkBoxEventSelector) this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_UNSELECTED); + }, + + releaseUpEvent: function(){ + cc.Widget.prototype.releaseUpEvent.call(this); + + if (this._isSelected){ + this.setSelectedState(false); + this.unSelectedEvent(); + } else { + this.setSelectedState(true); + this.selectedEvent(); } }, @@ -335,6 +356,14 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._checkBoxEventListener = target; }, + addEventListener: function(callback){ + this._checkBoxEventCallback = callback; + }, + + getVirtualRendererSize: function(){ + return this._backGroundBoxRenderer.getContentSize(); + }, + updateFlippedX: function () { this._backGroundBoxRenderer.setFlippedX(this._flippedX); this._backGroundSelectedBoxRenderer.setFlippedX(this._flippedX); @@ -392,11 +421,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.backGroundTextureScaleChangedWithSize(); - this.backGroundSelectedTextureScaleChangedWithSize(); - this.frontCrossTextureScaleChangedWithSize(); - this.backGroundDisabledTextureScaleChangedWithSize(); - this.frontCrossDisabledTextureScaleChangedWithSize(); + this._backGroundBoxRendererAdaptDirty = true; + this._backGroundSelectedBoxRendererAdaptDirty = true; + this._frontCrossRendererAdaptDirty = true; + this._backGroundBoxDisabledRendererAdaptDirty = true; + this._frontCrossDisabledRendererAdaptDirty = true; }, /** @@ -422,15 +451,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, backGroundTextureScaleChangedWithSize: function () { - if (this._ignoreSize) { + if (this._ignoreSize) this._backGroundBoxRenderer.setScale(1.0); - var locBackSize = this._backGroundBoxRenderer.getContentSize(); - this._size.width = locBackSize.width; - this._size.height = locBackSize.height; - } - else { + else{ var textureSize = this._backGroundBoxRenderer.getContentSize(); - if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { + if (textureSize.width <= 0.0 || textureSize.height <= 0.0){ this._backGroundBoxRenderer.setScale(1.0); return; } @@ -439,13 +464,13 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundBoxRenderer.setScaleX(scaleX); this._backGroundBoxRenderer.setScaleY(scaleY); } + this._backGroundBoxRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, backGroundSelectedTextureScaleChangedWithSize: function () { if (this._ignoreSize) { this._backGroundSelectedBoxRenderer.setScale(1.0); - } - else { + } else { var textureSize = this._backGroundSelectedBoxRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._backGroundSelectedBoxRenderer.setScale(1.0); @@ -461,8 +486,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ frontCrossTextureScaleChangedWithSize: function () { if (this._ignoreSize) { this._frontCrossRenderer.setScale(1.0); - } - else { + } else { var textureSize = this._frontCrossRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._frontCrossRenderer.setScale(1.0); @@ -478,8 +502,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ backGroundDisabledTextureScaleChangedWithSize: function () { if (this._ignoreSize) { this._backGroundBoxDisabledRenderer.setScale(1.0); - } - else { + }else { var textureSize = this._backGroundBoxDisabledRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._backGroundBoxDisabledRenderer.setScale(1.0); @@ -495,8 +518,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ frontCrossDisabledTextureScaleChangedWithSize: function () { if (this._ignoreSize) { this._frontCrossDisabledRenderer.setScale(1.0); - } - else { + } else { var textureSize = this._frontCrossDisabledRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._frontCrossDisabledRenderer.setScale(1.0); @@ -534,16 +556,44 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, createCloneInstance: function () { - return ccui.CheckBox.create(); //TODO should it do anything? + return ccui.CheckBox.create(); }, copySpecialProperties: function (uiCheckBox) { - this.loadTextureBackGround(uiCheckBox._backGroundFileName, uiCheckBox._backGroundTexType); - this.loadTextureBackGroundSelected(uiCheckBox._backGroundSelectedFileName, uiCheckBox._backGroundSelectedTexType); - this.loadTextureFrontCross(uiCheckBox._frontCrossFileName, uiCheckBox._frontCrossTexType); - this.loadTextureBackGroundDisabled(uiCheckBox._backGroundDisabledFileName, uiCheckBox._backGroundDisabledTexType); - this.loadTextureFrontCrossDisabled(uiCheckBox._frontCrossDisabledFileName, uiCheckBox._frontCrossDisabledTexType); - this.setSelectedState(uiCheckBox._isSelected); + if (uiCheckBox instanceof ccui.CheckBox) { + this.loadTextureBackGround(uiCheckBox._backGroundFileName, uiCheckBox._backGroundTexType); + this.loadTextureBackGroundSelected(uiCheckBox._backGroundSelectedFileName, uiCheckBox._backGroundSelectedTexType); + this.loadTextureFrontCross(uiCheckBox._frontCrossFileName, uiCheckBox._frontCrossTexType); + this.loadTextureBackGroundDisabled(uiCheckBox._backGroundDisabledFileName, uiCheckBox._backGroundDisabledTexType); + this.loadTextureFrontCrossDisabled(uiCheckBox._frontCrossDisabledFileName, uiCheckBox._frontCrossDisabledTexType); + this.setSelectedState(uiCheckBox._isSelected); + this._checkBoxEventListener = uiCheckBox._checkBoxEventListener; + this._checkBoxEventSelector = uiCheckBox._checkBoxEventSelector; + this._checkBoxEventCallback = uiCheckBox._checkBoxEventCallback; + } + }, + + adaptRenderers: function(){ + if (this._backGroundBoxRendererAdaptDirty){ + this.backGroundTextureScaleChangedWithSize(); + this._backGroundBoxRendererAdaptDirty = false; + } + if (this._backGroundSelectedBoxRendererAdaptDirty) { + this.backGroundSelectedTextureScaleChangedWithSize(); + this._backGroundSelectedBoxRendererAdaptDirty = false; + } + if (this._frontCrossRendererAdaptDirty){ + this.frontCrossTextureScaleChangedWithSize(); + this._frontCrossRendererAdaptDirty = false; + } + if (this._backGroundBoxDisabledRendererAdaptDirty) { + this.backGroundDisabledTextureScaleChangedWithSize(); + this._backGroundBoxDisabledRendererAdaptDirty = false; + } + if (this._frontCrossDisabledRendererAdaptDirty) { + this.frontCrossDisabledTextureScaleChangedWithSize(); + this._frontCrossDisabledRendererAdaptDirty = false; + } } }); @@ -558,7 +608,12 @@ _p = null; /** * allocates and initializes a UICheckBox. - * @constructs + * @param {string} [backGround] backGround texture. + * @param {string} [backGroundSeleted] backGround selected state texture. + * @param {string} [cross] cross texture. + * @param {string} [backGroundDisabled] cross dark state texture. + * @param {string} [frontCrossDisabled] cross dark state texture. + * @param {Number} [texType] * @return {ccui.CheckBox} * @example * // example @@ -566,16 +621,11 @@ _p = null; */ ccui.CheckBox.create = function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { var widget = new ccui.CheckBox(); - if (widget && widget.init(backGround, - backGroundSeleted, - cross, - backGroundDisabled, - frontCrossDisabled, - texType)) - { - return widget; - } - return null; + if(backGround === undefined) + widget.init(); + else + widget.init(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); + return widget; }; // Constants diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index d47250d9ac..77853a6f37 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.Button + * The ImageView control of Cocos GUI * @class * @extends ccui.Widget */ @@ -37,6 +37,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ _imageTexType: ccui.Widget.LOCAL_TEXTURE, _imageTextureSize: null, _className:"ImageView", + _imageRendererAdaptDirty: true, /** * allocates and initializes a UIImageView. @@ -51,6 +52,12 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ ccui.Widget.prototype.ctor.call(this); }, + init: function(imageFileName, texType){ + if(imageFileName !== undefined) + this.loadTexture(imageFileName, texType); + return true; + }, + initRenderer: function () { this._imageRenderer = cc.Sprite.create(); cc.Node.prototype.addChild.call(this, this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); @@ -62,51 +69,38 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexture: function (fileName, texType) { - if (!fileName) { + if (!fileName) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._textureFile = fileName; this._imageTexType = texType; var imageRenderer = this._imageRenderer; switch (this._imageTexType) { case ccui.Widget.LOCAL_TEXTURE: - imageRenderer.initWithFile(fileName); + if (this._scale9Enabled) { + imageRenderer.initWithFile(fileName); + imageRenderer.setCapInsets(this._capInsets); + } else + imageRenderer.setTexture(fileName); break; case ccui.Widget.PLIST_TEXTURE: - imageRenderer.initWithSpriteFrameName(fileName); + if (this._scale9Enabled) { + imageRenderer.initWithSpriteFrameName(fileName); + imageRenderer.setCapInsets(this._capInsets); + } else + imageRenderer.setSpriteFrame(fileName); break; default: break; } - - var locRendererSize = imageRenderer.getContentSize(); - if(imageRenderer.textureLoaded()){ - this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locRendererSize.width; - this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locRendererSize.height; - }else{ - imageRenderer.addLoadedEventListener(function(){ - var locSize = imageRenderer.getContentSize(); - this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locSize.width; - this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locSize.height; - if (imageRenderer.setCapInsets) { - imageRenderer.setCapInsets(this._capInsets); - } - this.imageTextureScaleChangedWithSize(); - },this); - this._imageTextureSize.width = this._customSize.width; - this._imageTextureSize.height = this._customSize.height; - } - - if (this._scale9Enabled) { - imageRenderer.setCapInsets(this._capInsets); - } - - this.imageTextureScaleChangedWithSize(); - this.updateAnchorPoint(); + this._imageTextureSize = imageRenderer.getContentSize(); this.updateFlippedX(); this.updateFlippedY(); - this.updateRGBAToRenderer(imageRenderer); + imageRenderer.setColor(this.getColor()); + imageRenderer.setOpacity(this.getOpacity()); + + this._updateContentSizeWithTextureSize(this._imageTextureSize); + this._imageRendererAdaptDirty = true; }, /** @@ -114,28 +108,28 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {cc.Rect} rect */ setTextureRect: function (rect) { - if (!this._scale9Enabled){ + if (!this._scale9Enabled) this._imageRenderer.setTextureRect(rect); - var locRendererSize = this._imageRenderer.getContentSize(); - this.imageTextureScaleChangedWithSize(); - this._imageTextureSize.width = locRendererSize.width; - this._imageTextureSize.height = locRendererSize.height; - } }, updateFlippedX: function () { - if (this._scale9Enabled) { + if (this._scale9Enabled) this._imageRenderer.setScaleX(this._flippedX ? -1 : 1); - } else { + else this._imageRenderer.setFlippedX(this._flippedX); - } }, updateFlippedY: function () { - if (this._scale9Enabled) { + if (this._scale9Enabled) this._imageRenderer.setScaleY(this._flippedY ? -1 : 1); - } else { + else this._imageRenderer.setFlippedY(this._flippedY); + }, + + adaptRenderers: function(){ + if (this._imageRendererAdaptDirty){ + this.imageTextureScaleChangedWithSize(); + this._imageRendererAdaptDirty = false; } }, @@ -144,35 +138,30 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {Boolean} able */ setScale9Enabled: function (able) { - if (this._scale9Enabled == able) { + if (this._scale9Enabled == able) return; - } - this._scale9Enabled = able; - cc.Node.prototype.removeChild.call(this, this._imageRenderer, true); + this.removeProtectedChild(this._imageRenderer); this._imageRenderer = null; if (this._scale9Enabled) { this._imageRenderer = cc.Scale9Sprite.create(); - } - else { + } else { this._imageRenderer = cc.Sprite.create(); } this.loadTexture(this._textureFile, this._imageTexType); - cc.Node.prototype.addChild.call(this, this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); + this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); if (this._scale9Enabled) { var ignoreBefore = this._ignoreSize; this.ignoreContentAdaptWithSize(false); this._prevIgnoreSize = ignoreBefore; - } - else { + } else this.ignoreContentAdaptWithSize(this._prevIgnoreSize); - } this.setCapInsets(this._capInsets); }, /** - * Get button is using scale9 renderer or not. + * Get button is using scale9 renderer or not. * @returns {Boolean} */ isScale9Enabled:function(){ @@ -196,9 +185,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ */ setCapInsets: function (capInsets) { this._capInsets = capInsets; - if (!this._scale9Enabled) { + if (!this._scale9Enabled) return; - } this._imageRenderer.setCapInsets(capInsets); }, @@ -236,7 +224,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.imageTextureScaleChangedWithSize(); + this._imageRendererAdaptDirty = true; }, /** @@ -263,26 +251,22 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ imageTextureScaleChangedWithSize: function () { if (this._ignoreSize) { - if (!this._scale9Enabled) { + if (!this._scale9Enabled) this._imageRenderer.setScale(1.0); - this._size = this._imageTextureSize; - } - } - else { - if (this._scale9Enabled) { + } else { + if (this._scale9Enabled) this._imageRenderer.setPreferredSize(this._size); - } else { var textureSize = this._imageRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._imageRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; var scaleY = this._size.height / textureSize.height; - this._imageRenderer.setScaleX(scaleX); - this._imageRenderer.setScaleY(scaleY); + this._imageRenderer.setScaleX(this._size.width / textureSize.width); + this._imageRenderer.setScaleY(this._size.height / textureSize.height); } } + this._imageRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, updateTextureColor: function () { @@ -301,29 +285,39 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ return "ImageView"; }, + getVirtualRendererSize: function(){ + + }, + createCloneInstance:function(){ return ccui.ImageView.create(); }, copySpecialProperties: function (imageView) { - this._prevIgnoreSize = imageView._prevIgnoreSize; - this.setScale9Enabled(imageView._scale9Enabled); - this.loadTexture(imageView._textureFile, imageView._imageTexType); - this.setCapInsets(imageView._capInsets); + if(imageView instanceof ccui.ImageView){ + this._prevIgnoreSize = imageView._prevIgnoreSize; + this.setScale9Enabled(imageView._scale9Enabled); + this.loadTexture(imageView._textureFile, imageView._imageTexType); + this.setCapInsets(imageView._capInsets); + } } }); /** * allocates and initializes a UIImageView. - * @constructs + * @param {string} imageFileName + * @param {Number} texType * @return {ccui.ImageView} * @example * // example * var uiImageView = ccui.ImageView.create(); */ -ccui.ImageView.create = function () { - return new ccui.ImageView(); +ccui.ImageView.create = function (imageFileName, texType) { + var imageView = new ccui.ImageView(); + if(imageFileName !== undefined) + imageView.init(imageFileName, texType); + return imageView; }; // Constants diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 44565cb3ea..8d4728125b 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -32,7 +32,7 @@ * @property {Number} percent - The current progress of loadingbar */ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ - _barType: null, + _direction: null, _percent: 100, _totalLength: 0, _barRenderer: null, @@ -44,6 +44,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _textureFile: "", _isTextureLoaded: false, _className: "LoadingBar", + _barRendererAdaptDirty: true, /** * allocates and initializes a UILoadingBar. @@ -53,7 +54,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ * var uiLoadingBar = new ccui.LoadingBar; */ ctor: function () { - this._barType = ccui.LoadingBar.TYPE_LEFT; + this._direction = ccui.LoadingBar.TYPE_LEFT; this._barRendererTextureSize = cc.size(0, 0); this._capInsets = cc.rect(0, 0, 0, 0); ccui.Widget.prototype.ctor.call(this); @@ -66,146 +67,114 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, /** - * Changes the progress direction of loadingbar. + * Changes the progress direction of LoadingBar. * LoadingBarTypeLeft means progress left to right, LoadingBarTypeRight otherwise. * @param {ccui.LoadingBar.TYPE_LEFT | ccui.LoadingBar.TYPE_RIGHT} dir */ setDirection: function (dir) { - if (this._barType == dir) { + if (this._direction == dir) return; - } - this._barType = dir; - - switch (this._barType) { + this._direction = dir; + switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: this._barRenderer.setAnchorPoint(0.0, 0.5); this._barRenderer.setPosition(-this._totalLength * 0.5, 0.0); - if (!this._scale9Enabled) { + if (!this._scale9Enabled) this._barRenderer.setFlippedX(false); - } break; case ccui.LoadingBar.TYPE_RIGHT: this._barRenderer.setAnchorPoint(1.0, 0.5); this._barRenderer.setPosition(this._totalLength * 0.5, 0.0); - if (!this._scale9Enabled) { + if (!this._scale9Enabled) this._barRenderer.setFlippedX(true); - } break; } }, /** - * Gets the progress direction of loadingbar. + * Gets the progress direction of LoadingBar. * LoadingBarTypeLeft means progress left to right, LoadingBarTypeRight otherwise. * @returns {ccui.LoadingBar.TYPE_LEFT | ccui.LoadingBar.TYPE_RIGHT} */ getDirection: function () { - return this._barType; + return this._direction; }, /** - * Load texture for loadingbar. + * Load texture for LoadingBar. * @param {String} texture * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexture: function (texture, texType) { - if (!texture) { + if (!texture) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._renderBarTexType = texType; this._textureFile = texture; 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); + barRenderer.setCapInsets(this._capInsets); + } else + barRenderer.setTexture(texture); break; case ccui.Widget.PLIST_TEXTURE: - barRenderer.initWithSpriteFrameName(texture); + if (this._scale9Enabled) { + barRenderer.initWithSpriteFrameName(texture); + barRenderer.setCapInsets(this._capInsets); + } else + barRenderer.setSpriteFrame(texture); break; default: break; } - if (this._scale9Enabled) { - barRenderer.setCapInsets(this._capInsets); - } - this.updateColorToRenderer(barRenderer); - - var textLoaded = barRenderer.textureLoaded(); - this._isTextureLoaded = textLoaded; - if (!textLoaded) { - this._barRendererTextureSize.width = this._customSize.width; - this._barRendererTextureSize.height = this._customSize.height; - barRenderer.addLoadedEventListener(function () { - this._isTextureLoaded = true; - if (barRenderer.setCapInsets) { - barRenderer.setCapInsets(this._capInsets); - } - var locSize = barRenderer.getContentSize(); - this._barRendererTextureSize.width = locSize.width; - this._barRendererTextureSize.height = locSize.height; - this.barRendererScaleChangedWithSize(); - this.setPercent(this._percent); - }, this); - } else { - var locBarSize = barRenderer.getContentSize(); - this._barRendererTextureSize.width = locBarSize.width; - this._barRendererTextureSize.height = locBarSize.height; - } + barRenderer.setColor(this.getColor()); + barRenderer.setOpacity(this.getOpacity()); + this._barRendererTextureSize = barRenderer.getContentSize(); - switch (this._barType) { + switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: - barRenderer.setAnchorPoint(0.0, 0.5); - if (!this._scale9Enabled) { + barRenderer.setAnchorPoint(0.0,0.5); + if (!this._scale9Enabled) barRenderer.setFlippedX(false); - } break; case ccui.LoadingBar.TYPE_RIGHT: - barRenderer.setAnchorPoint(1.0, 0.5); - if (!this._scale9Enabled) { + barRenderer.setAnchorPoint(1.0,0.5); + if (!this._scale9Enabled) barRenderer.setFlippedX(true); - } break; } this.barRendererScaleChangedWithSize(); + this._updateContentSizeWithTextureSize(this._barRendererTextureSize); + this._barRendererAdaptDirty = true; }, /** - * Sets if loadingbar is using scale9 renderer. + * Sets if LoadingBar is using scale9 renderer. * @param {Boolean} enabled */ setScale9Enabled: function (enabled) { - if (this._scale9Enabled == enabled) { + if (this._scale9Enabled == enabled) return; - } this._scale9Enabled = enabled; - cc.Node.prototype.removeChild.call(this, this._barRenderer, true); - this._barRenderer = null; - if (this._scale9Enabled) { - this._barRenderer = cc.Scale9Sprite.create(); - } - else { - this._barRenderer = cc.Sprite.create(); - } + this.removeProtectedChild(this._barRenderer); + this._barRenderer = this._scale9Enabled? cc.Scale9Sprite.create():cc.Sprite.create(); this.loadTexture(this._textureFile, this._renderBarTexType); - cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); + this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); if (this._scale9Enabled) { var ignoreBefore = this._ignoreSize; this.ignoreContentAdaptWithSize(false); this._prevIgnoreSize = ignoreBefore; - } - else { + } else this.ignoreContentAdaptWithSize(this._prevIgnoreSize); - } this.setCapInsets(this._capInsets); this.setPercent(this._percent); }, /** - * Get loadingBar is using scale9 renderer or not.. + * Get LoadingBar is using scale9 renderer or not.. * @returns {Boolean} */ isScale9Enabled: function () { @@ -213,15 +182,13 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, /** - * Sets capinsets for loadingbar, if loadingbar is using scale9 renderer. + * Sets capinsets for LoadingBar, if LoadingBar is using scale9 renderer. * @param {cc.Rect} capInsets */ setCapInsets: function (capInsets) { this._capInsets = capInsets; - if (!this._scale9Enabled) { - return; - } - this._barRenderer.setCapInsets(capInsets); + if (this._scale9Enabled) + this._barRenderer.setCapInsets(capInsets); }, /** @@ -234,40 +201,41 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ /** * The current progress of loadingbar - * @param {number} percent + * @param {number} percent percent value from 1 to 100. */ setPercent: function (percent) { - if (percent < 0 || percent > 100) { + if (percent < 0 || percent > 100) return; - } - if (this._totalLength <= 0) { + if (this._totalLength <= 0) return; - } this._percent = percent; - if (!this._isTextureLoaded) { + if (!this._isTextureLoaded) return; - } var res = this._percent / 100.0; if (this._scale9Enabled) this.setScale9Scale(); else { - var x = 0, y = 0; - if (this._renderBarTexType == ccui.Widget.PLIST_TEXTURE) { - var barNode = this._barRenderer; - if (barNode) { - var rect = barNode.getTextureRect(); - x = rect.x; - y = rect.y; - } - } - this._barRenderer.setTextureRect(cc.rect(x, y, this._barRendererTextureSize.width * res, this._barRendererTextureSize.height)); +/* var x = 0, y = 0; //TODO need test + if (this._renderBarTexType == ccui.Widget.PLIST_TEXTURE) { + var barNode = this._barRenderer; + if (barNode) { + var rect = barNode.getTextureRect(); + x = rect.x; + y = rect.y; + } + } + this._barRenderer.setTextureRect(cc.rect(x, y, this._barRendererTextureSize.width * res, this._barRendererTextureSize.height));*/ + var spriteRenderer = this._barRenderer; + var rect = spriteRenderer.getTextureRect(); + rect.size.width = this._barRendererTextureSize.width * res; + spriteRenderer.setTextureRect(rect, spriteRenderer.isTextureRectRotated(), rect.size); } }, /** - * Gets the progress direction of loadingbar. - * @returns {number} + * Gets the progress direction of LoadingBar. + * @returns {number} percent value from 1 to 100. */ getPercent: function () { return this._percent; @@ -275,7 +243,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.barRendererScaleChangedWithSize(); + this._barRendererAdaptDirty = true; }, /** @@ -289,6 +257,10 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } }, + getVirtualRendererSize:function(){ + return this._barRendererTextureSize; + }, + /** * override "getContentSize" method of widget. * @returns {cc.Size} @@ -312,44 +284,47 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, barRendererScaleChangedWithSize: function () { + var locBarRender = this._barRenderer; if (this._ignoreSize) { if (!this._scale9Enabled) { this._totalLength = this._barRendererTextureSize.width; - this._barRenderer.setScale(1.0); - this._size.width = this._barRendererTextureSize.width; - this._size.height = this._barRendererTextureSize.height; + locBarRender.setScale(1.0); } - } - else { + } else { this._totalLength = this._size.width; - if (this._scale9Enabled) { + if (this._scale9Enabled) this.setScale9Scale(); - } else { - var textureSize = this._barRendererTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._barRenderer.setScale(1.0); + locBarRender.setScale(1.0); return; } var scaleX = this._size.width / textureSize.width; var scaleY = this._size.height / textureSize.height; - this._barRenderer.setScaleX(scaleX); - this._barRenderer.setScaleY(scaleY); + locBarRender.setScaleX(scaleX); + locBarRender.setScaleY(scaleY); } } - switch (this._barType) { + switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: - this._barRenderer.setPosition(-this._totalLength * 0.5, 0.0); + locBarRender.setPosition(0, this._contentSize.height * 0.5); break; case ccui.LoadingBar.TYPE_RIGHT: - this._barRenderer.setPosition(this._totalLength * 0.5, 0.0); + locBarRender.setPosition(this._totalLength, this._contentSize.height * 0.5); break; default: break; } }, + adaptRenderers: function(){ + if (this._barRendererAdaptDirty){ + this.barRendererScaleChangedWithSize(); + this._barRendererAdaptDirty = false; + } + }, + setScale9Scale: function () { var width = (this._percent) / 100 * this._totalLength; this._barRenderer.setPreferredSize(cc.size(width, this._size.height)); @@ -376,12 +351,14 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, copySpecialProperties: function (loadingBar) { - this._prevIgnoreSize = loadingBar._prevIgnoreSize; - this.setScale9Enabled(loadingBar._scale9Enabled); - this.loadTexture(loadingBar._textureFile, loadingBar._renderBarTexType); - this.setCapInsets(loadingBar._capInsets); - this.setPercent(loadingBar._percent); - this.setDirection(loadingBar._barType); + if(loadingBar instanceof ccui.LoadingBar){ + this._prevIgnoreSize = loadingBar._prevIgnoreSize; + this.setScale9Enabled(loadingBar._scale9Enabled); + this.loadTexture(loadingBar._textureFile, loadingBar._renderBarTexType); + this.setCapInsets(loadingBar._capInsets); + this.setPercent(loadingBar._percent); + this.setDirection(loadingBar._direction); + } } }); @@ -399,14 +376,20 @@ _p = null; /** * allocates and initializes a UILoadingBar. - * @constructs + * @param {string} textureName + * @param {Number} percentage * @return {ccui.LoadingBar} * @example * // example * var uiLoadingBar = ccui.LoadingBar.create(); */ -ccui.LoadingBar.create = function () { - return new ccui.LoadingBar(); +ccui.LoadingBar.create = function (textureName, percentage) { + var loadingBar = new ccui.LoadingBar(); + if(textureName !== undefined) + loadingBar.loadTexture(textureName); + if(percentage !== undefined) + loadingBar.setPercent(percentage); + return loadingBar; }; // Constants diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 8892664e12..f890ea5081 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -33,6 +33,7 @@ ccui.RichElement = ccui.Class.extend(/** @lends ccui.RichElement# */{ tag: 0, color: null, ctor: function () { + this.type = 0; this.tag = 0; this.color = cc.color(255, 255, 255, 255); }, @@ -56,7 +57,7 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# fontSize: 0, ctor: function () { ccui.RichElement.prototype.ctor.call(this); - this.type = ccui.RichElement.TYPE_TEXT; + this.type = ccui.RichElement.TEXT; this.text = ""; this.fontName = ""; this.fontSize = 0; @@ -96,7 +97,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage textureType: 0, ctor: function () { ccui.RichElement.prototype.ctor.call(this); - this.type = ccui.RichElement.TYPE_IMAGE; + this.type = ccui.RichElement.IMAGE; this.filePath = ""; this.textureRect = cc.rect(0, 0, 0, 0); this.textureType = 0; @@ -130,7 +131,7 @@ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElement customNode: null, ctor: function () { ccui.RichElement.prototype.ctor.call(this); - this.type = ccui.RichElement.TYPE_CUSTOM; + this.type = ccui.RichElement.CUSTOM; this.customNode = null; }, init: function (tag, color, opacity, customNode) { @@ -186,8 +187,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ initRenderer: function () { this._elementRenderersContainer = cc.Node.create(); - this._elementRenderersContainer.setAnchorPoint(cc.p(0.5, 0.5)); - cc.Node.prototype.addChild.call(this,this._elementRenderersContainer, 0, -1); + this._elementRenderersContainer.setAnchorPoint(0.5, 0.5); + this.addProtectedChild(this._elementRenderersContainer, 0, -1); }, /** @@ -214,11 +215,10 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @param {ccui.RichElement} element */ removeElement: function (element) { - if (typeof element === "number") { + if (typeof element === "number") this._richElements.splice(element, 1); - } else { + else cc.arrayRemoveObject(this._richElements, element); - } this._formatTextDirty = true; }, @@ -226,40 +226,41 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ if (this._formatTextDirty) { this._elementRenderersContainer.removeAllChildren(); this._elementRenders.length = 0; + var i, element, locRichElements = this._richElements; if (this._ignoreSize) { this.addNewLine(); - for (var i = 0; i < this._richElements.length; i++) { - var element = this._richElements[i]; + for (i = 0; i < locRichElements.length; i++) { + element = locRichElements[i]; var elementRenderer = null; switch (element.type) { - case ccui.RichElement.TYPE_TEXT: + case ccui.RichElement.TEXT: elementRenderer = cc.LabelTTF.create(element.text, element.fontName, element.fontSize); break; - case ccui.RichElement.TYPE_IMAGE: + case ccui.RichElement.IMAGE: elementRenderer = cc.Sprite.create(element.filePath); break; - case ccui.RichElement.TYPE_CUSTOM: + case ccui.RichElement.CUSTOM: elementRenderer = element.customNode; break; default: break; } elementRenderer.setColor(element.color); + elementRenderer.setOpacity(element.color.a); this.pushToContainer(elementRenderer); } - } - else { + } else { this.addNewLine(); - for (var i = 0; i < this._richElements.length; i++) { - var element = this._richElements[i]; + for (i = 0; i < locRichElements.length; i++) { + element = locRichElements[i]; switch (element.type) { - case ccui.RichElement.TYPE_TEXT: + case ccui.RichElement.TEXT: this.handleTextRenderer(element.text, element.fontName, element.fontSize, element.color); break; - case ccui.RichElement.TYPE_IMAGE: - this.handleImageRenderer(element.filePath, element.color); + case ccui.RichElement.IMAGE: + this.handleImageRenderer(element.filePath, element.color, element.color.a); break; - case ccui.RichElement.TYPE_CUSTOM: + case ccui.RichElement.CUSTOM: this.handleCustomRenderer(element.customNode); break; default: @@ -293,14 +294,15 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ if (leftLength > 0) { var leftRenderer = cc.LabelTTF.create(leftWords.substr(0, leftLength), fontName, fontSize); leftRenderer.setColor(color); + leftRenderer.setColor(color.a); this.pushToContainer(leftRenderer); } this.addNewLine(); this.handleTextRenderer(cutWords, fontName, fontSize, color); - } - else { + } else { textRenderer.setColor(color); + textRenderer.setOpacity(color.a); this.pushToContainer(textRenderer); } }, @@ -327,10 +329,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this.addNewLine(); this.pushToContainer(renderer); this._leftSpaceWidth -= imgSize.width; - } - else { + } else this.pushToContainer(renderer); - } }, addNewLine: function () { @@ -339,30 +339,27 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ }, formatRenderers: function () { + var newContentSizeHeight = 0, locRenderersContainer = this._elementRenderersContainer; + var locElementRenders = this._elementRenders; if (this._ignoreSize) { var newContentSizeWidth = 0; - var newContentSizeHeight = 0; - - var row = this._elementRenders[0]; + var row = locElementRenders[0]; var nextPosX = 0; for (var j = 0; j < row.length; j++) { var l = row[j]; l.setAnchorPoint(cc.p(0, 0)); l.setPosition(cc.p(nextPosX, 0)); - this._elementRenderersContainer.addChild(l, 1, j); + locRenderersContainer.addChild(l, 1, j); var iSize = l.getContentSize(); newContentSizeWidth += iSize.width; newContentSizeHeight = Math.max(newContentSizeHeight, iSize.height); nextPosX += iSize.width; } - this._elementRenderersContainer.setContentSize(cc.size(newContentSizeWidth, newContentSizeHeight)); - } - else { - var newContentSizeHeight = 0; + locRenderersContainer.setContentSize(cc.size(newContentSizeWidth, newContentSizeHeight)); + } else { var maxHeights = []; - - for (var i = 0; i < this._elementRenders.length; i++) { - var row = this._elementRenders[i]; + for (var i = 0; i < locElementRenders.length; i++) { + var row = locElementRenders[i]; var maxHeight = 0; for (var j = 0; j < row.length; j++) { var l = row[j]; @@ -372,10 +369,9 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ newContentSizeHeight += maxHeights[i]; } - var nextPosY = this._customSize.height; - for (var i = 0; i < this._elementRenders.length; i++) { - var row = this._elementRenders[i]; + for (var i = 0; i < locElementRenders.length; i++) { + var row = locElementRenders[i]; var nextPosX = 0; nextPosY -= (maxHeights[i] + this._verticalSpace); @@ -383,22 +379,23 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var l = row[j]; l.setAnchorPoint(cc.p(0, 0)); l.setPosition(cc.p(nextPosX, nextPosY)); - this._elementRenderersContainer.addChild(l, 1, i * 10 + j); + locRenderersContainer.addChild(l, 1, i * 10 + j); nextPosX += l.getContentSize().width; } } - this._elementRenderersContainer.setContentSize(this._size); + locRenderersContainer.setContentSize(this._size); } this._elementRenders.length = 0; if (this._ignoreSize) { - var s = this.getContentSize(); + var s = this.getVirtualRendererSize(); this._size.width = s.width; this._size.height = s.height; - } - else { + } else { this._size.width = this._customSize.width; this._size.height = this._customSize.height; } + this._updateContentSizeWithTextureSize(this._size); + locRenderersContainer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); }, /** @@ -406,9 +403,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @param {cc.Node} renderer */ pushToContainer: function (renderer) { - if (this._elementRenders.length <= 0) { + if (this._elementRenders.length <= 0) return; - } this._elementRenders[this._elementRenders.length - 1].push(renderer); }, @@ -436,6 +432,10 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._elementRenderersContainer.setAnchorPoint(pt); }, + getVirtualRendererSize: function(){ + return this._elementRenderersContainer.getContentSize(); + }, + /** * Get content size * @returns {cc.Size} @@ -453,6 +453,10 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._formatTextDirty = true; ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, ignore); } + }, + + getDescription: function(){ + return "RichText"; } }); @@ -468,6 +472,6 @@ ccui.RichText.create = function(){ // Constants //Rich element type -ccui.RichElement.TYPE_TEXT = 0; -ccui.RichElement.TYPE_IMAGE = 1; -ccui.RichElement.TYPE_CUSTOM = 2; \ No newline at end of file +ccui.RichElement.TEXT = 0; +ccui.RichElement.IMAGE = 1; +ccui.RichElement.CUSTOM = 2; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 9c11b2c8b0..5aad198532 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1160,33 +1160,63 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return scrollEnabled; }, + /** + * Scroll inner container to bottom boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToBottom: function (time, attenuated) { this.startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), 0), time, attenuated); }, + /** + * Scroll inner container to top boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToTop: function (time, attenuated) { this.startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), this._size.height - this._innerContainer.getSize().height), time, attenuated); }, + /** + * Scroll inner container to left boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToLeft: function (time, attenuated) { this.startAutoScrollChildrenWithDestination(cc.p(0, this._innerContainer.getPositionY()), time, attenuated); }, + /** + * Scroll inner container to right boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToRight: function (time, attenuated) { this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, this._innerContainer.getPositionY()), time, attenuated); }, + /** + * Scroll inner container to top and left boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToTopLeft: function (time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.startAutoScrollChildrenWithDestination(cc.p(0, this._size.height - this._innerContainer.getSize().height), time, attenuated); }, + /** + * Scroll inner container to top and right boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToTopRight: function (time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, this._size.height - this._innerContainer.getSize().height), time, attenuated); @@ -1194,7 +1224,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollToBottomLeft: function (time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.startAutoScrollChildrenWithDestination(cc.p(0, 0), time, attenuated); @@ -1202,7 +1232,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollToBottomRight: function (time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll diretcion is not both!"); return; } this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, 0), time, attenuated); @@ -1524,7 +1554,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * set direction + * Changes scroll direction of scrollview. * @param {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} dir */ setDirection: function (dir) { @@ -1532,7 +1562,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get direction + * Gets scroll direction of scrollview. * @returns {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} */ getDirection: function () { @@ -1572,7 +1602,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get inner container + * Gets inner container of scrollview. Inner container is the container of scrollview's children. * @returns {ccui.Layout} */ getInnerContainer: function () { From 76d3c1b44de21b35f0b1ab91a6432bc3559fb7d0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 1 Jul 2014 11:57:49 +0800 Subject: [PATCH 0206/1564] Issue #5600: update ui --- extensions/ccui/uiwidgets/UISlider.js | 318 +++++++++++++------ extensions/ccui/uiwidgets/UIText.js | 371 ++++++++++++++-------- extensions/ccui/uiwidgets/UITextAtlas.js | 178 +++++++---- extensions/ccui/uiwidgets/UITextBMFont.js | 186 ++++++----- extensions/ccui/uiwidgets/UITextField.js | 338 +++++++++++++------- 5 files changed, 903 insertions(+), 488 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index e2f126165d..246f35dd5d 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -58,6 +58,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _ballDTexType: ccui.Widget.LOCAL_TEXTURE, _isTextureLoaded: false, _className: "Slider", + _barRendererAdaptDirty: true, + _progressBarRendererDirty: true, /** * allocates and initializes a UISlider. * Constructor of ccui.Slider @@ -74,7 +76,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ init: function () { if (ccui.Widget.prototype.init.call(this)) { - this.setTouchEnabled(true); +// this.setTouchEnabled(true); return true; } return false; @@ -113,24 +115,47 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var barRenderer = this._barRenderer; switch (this._barTexType) { case ccui.Widget.LOCAL_TEXTURE: - barRenderer.initWithFile(fileName); +// barRenderer.initWithFile(fileName); + if (this._scale9Enabled) + { + barRenderer.initWithFile(fileName); + } + else + { + barRenderer.setTexture(fileName); + } break; case ccui.Widget.PLIST_TEXTURE: - barRenderer.initWithSpriteFrameName(fileName); +// barRenderer.initWithSpriteFrameName(fileName); + if (this._scale9Enabled) + { + barRenderer.initWithSpriteFrameName(fileName); + } + else + { + barRenderer.setSpriteFrame(fileName); + } + break; default: break; } - this.updateColorToRenderer(barRenderer); - this.barRendererScaleChangedWithSize(); +// this.updateColorToRenderer(barRenderer); +// this.barRendererScaleChangedWithSize(); + barRenderer.setColor(this.getColor()); + barRenderer.setOpacity(this.getOpacity()); - if (!barRenderer.textureLoaded()) { - barRenderer.addLoadedEventListener(function () { - this.barRendererScaleChangedWithSize(); - }, this); - } +// if (!barRenderer.textureLoaded()) { +// barRenderer.addLoadedEventListener(function () { +// this.barRendererScaleChangedWithSize(); +// }, this); +// } +// +// this.progressBarRendererScaleChangedWithSize(); - this.progressBarRendererScaleChangedWithSize(); + this._barRendererAdaptDirty = true; + this._progressBarRendererDirty = true; + this.updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); }, /** @@ -148,32 +173,54 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var progressBarRenderer = this._progressBarRenderer; switch (this._progressBarTexType) { case ccui.Widget.LOCAL_TEXTURE: - progressBarRenderer.initWithFile(fileName); +// progressBarRenderer.initWithFile(fileName); + if (this._scale9Enabled) + { + progressBarRenderer.initWithFile(fileName); + } + else + { + progressBarRenderer.setTexture(fileName); + } break; case ccui.Widget.PLIST_TEXTURE: - progressBarRenderer.initWithSpriteFrameName(fileName); +// progressBarRenderer.initWithSpriteFrameName(fileName); + if (this._scale9Enabled) + { + progressBarRenderer.initWithSpriteFrameName(fileName); + } + else + { + progressBarRenderer.setSpriteFrame(fileName); + } break; default: break; } - this.updateColorToRenderer(progressBarRenderer); - progressBarRenderer.setAnchorPoint(0.0, 0.5); - var locSize = progressBarRenderer.getContentSize(); - this._progressBarTextureSize.width = locSize.width; - this._progressBarTextureSize.height = locSize.height; - this.progressBarRendererScaleChangedWithSize(); - - var textLoaded = progressBarRenderer.textureLoaded(); - this._isTextureLoaded = textLoaded; - if (!textLoaded) { - progressBarRenderer.addLoadedEventListener(function () { - this._isTextureLoaded = true; - var locSize = progressBarRenderer.getContentSize(); - this._progressBarTextureSize.width = locSize.width; - this._progressBarTextureSize.height = locSize.height; - this.progressBarRendererScaleChangedWithSize(); - }, this); - } +// this.updateColorToRenderer(progressBarRenderer); +// progressBarRenderer.setAnchorPoint(0.0, 0.5); +// var locSize = progressBarRenderer.getContentSize(); +// this._progressBarTextureSize.width = locSize.width; +// this._progressBarTextureSize.height = locSize.height; +// this.progressBarRendererScaleChangedWithSize(); +// +// var textLoaded = progressBarRenderer.textureLoaded(); +// this._isTextureLoaded = textLoaded; +// if (!textLoaded) { +// progressBarRenderer.addLoadedEventListener(function () { +// this._isTextureLoaded = true; +// var locSize = progressBarRenderer.getContentSize(); +// this._progressBarTextureSize.width = locSize.width; +// this._progressBarTextureSize.height = locSize.height; +// this.progressBarRendererScaleChangedWithSize(); +// }, this); +// } + this._progressBarRenderer.setColor(this.getColor()); + this._progressBarRenderer.setOpacity(this.getOpacity()); + + this._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); + this._progressBarTextureSize = this._progressBarRenderer.getContentSize(); + this._progressBarRendererDirty = true; }, /** @@ -200,8 +247,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } this.loadBarTexture(this._textureFile, this._barTexType); this.loadProgressBarTexture(this._progressBarTextureFile, this._progressBarTexType); - cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); - cc.Node.prototype.addChild.call(this, this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); +// cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); +// cc.Node.prototype.addChild.call(this, this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); + this.addProtectedChild(this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); + this.addProtectedChild(this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); if (this._scale9Enabled) { var ignoreBefore = this._ignoreSize; this.ignoreContentAdaptWithSize(false); @@ -309,15 +358,19 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballNTexType = texType; switch (this._ballNTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._slidBallNormalRenderer.initWithFile(normal); +// this._slidBallNormalRenderer.initWithFile(normal); + this._slidBallNormalRenderer.setTexture(normal); break; case ccui.Widget.PLIST_TEXTURE: - this._slidBallNormalRenderer.initWithSpriteFrameName(normal); +// this._slidBallNormalRenderer.initWithSpriteFrameName(normal); + this._slidBallNormalRenderer.setSpriteFrame(normal); break; default: break; } - this.updateColorToRenderer(this._slidBallNormalRenderer); +// this.updateColorToRenderer(this._slidBallNormalRenderer); + this._slidBallNormalRenderer.setColor(this.getColor()); + this._slidBallNormalRenderer.setOpacity(this.getOpacity()); }, /** @@ -334,15 +387,19 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballPTexType = texType; switch (this._ballPTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._slidBallPressedRenderer.initWithFile(pressed); +// this._slidBallPressedRenderer.initWithFile(pressed); + this._slidBallPressedRenderer.setTexture(pressed); break; case ccui.Widget.PLIST_TEXTURE: - this._slidBallPressedRenderer.initWithSpriteFrameName(pressed); +// this._slidBallPressedRenderer.initWithSpriteFrameName(pressed); + this._slidBallPressedRenderer.setSpriteFrame(pressed); break; default: break; } - this.updateColorToRenderer(this._slidBallPressedRenderer); +// this.updateColorToRenderer(this._slidBallPressedRenderer); + this._slidBallPressedRenderer.setColor(this.getColor()); + this._slidBallPressedRenderer.setOpacity(this.getOpacity()); }, /** @@ -359,15 +416,19 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballDTexType = texType; switch (this._ballDTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._slidBallDisabledRenderer.initWithFile(disabled); +// this._slidBallDisabledRenderer.initWithFile(disabled); + this._slidBallDisabledRenderer.setTexture(disabled); break; case ccui.Widget.PLIST_TEXTURE: - this._slidBallDisabledRenderer.initWithSpriteFrameName(disabled); +// this._slidBallDisabledRenderer.initWithSpriteFrameName(disabled); + this._slidBallDisabledRenderer.setSpriteFrame(disabled); break; default: break; } - this.updateColorToRenderer(this._slidBallDisabledRenderer); +// this.updateColorToRenderer(this._slidBallDisabledRenderer); + this._slidBallDisabledRenderer.setColor(this.getColor()); + this._slidBallDisabledRenderer.setOpacity(this.getOpacity()); }, /** @@ -386,22 +447,37 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ return; } var dis = this._barLength * (percent / 100.0); - this._slidBallRenderer.setPosition(-this._barLength / 2.0 + dis, 0.0); +// this._slidBallRenderer.setPosition(-this._barLength / 2.0 + dis, 0.0); + this._slidBallRenderer.setPosition(cc.p(dis, this._barLength / 2)); if (this._scale9Enabled) { this._progressBarRenderer.setPreferredSize(cc.size(dis, this._progressBarTextureSize.height)); } else { - var x = 0, y = 0; - if (this._progressBarTexType == ccui.Widget.PLIST_TEXTURE) { - var barNode = this._progressBarRenderer; - if (barNode) { - var rect = barNode.getTextureRect(); - x = rect.x; - y = rect.y; - } - } - this._progressBarRenderer.setTextureRect(cc.rect(x, y, this._progressBarTextureSize.width * (percent / 100.0), this._progressBarTextureSize.height)); +// var x = 0, y = 0; +// if (this._progressBarTexType == ccui.Widget.PLIST_TEXTURE) { +// var barNode = this._progressBarRenderer; +// if (barNode) { +// var rect = barNode.getTextureRect(); +// x = rect.x; +// y = rect.y; +// } +// } +// this._progressBarRenderer.setTextureRect(cc.rect(x, y, this._progressBarTextureSize.width * (percent / 100.0), this._progressBarTextureSize.height)); + var spriteRenderer = this._progressBarRenderer; + var rect = spriteRenderer.getTextureRect(); + rect.width = this._progressBarTextureSize.width * res; + spriteRenderer.setTextureRect(rect, spriteRenderer.isTextureRectRotated(), rect.size); + } + }, + + hitTest: function(pt){ + var nsp = this._slidBallNormalRenderer.convertToNodeSpace(pt); + var ballSize = this._slidBallNormalRenderer.getContentSize(); + var ballRect = cc.rect(0,0, ballSize.width, ballSize.height); + if (ballRect.containsPoint(nsp)) { + return true; } + return false; }, onTouchBegan: function (touch, event) { @@ -416,10 +492,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ onTouchMoved: function (touch, event) { var touchPoint = touch.getLocation(); - this._touchMovePosition.x = touchPoint.x; - this._touchMovePosition.y = touchPoint.y; +// this._touchMovePosition.x = touchPoint.x; +// this._touchMovePosition.y = touchPoint.y; var nsp = this.convertToNodeSpace(touchPoint); - this._slidBallRenderer.setPosition(nsp.x, 0); +// this._slidBallRenderer.setPosition(nsp.x, 0); this.setPercent(this.getPercentWithBallPos(nsp.x)); this.percentChangedEvent(); }, @@ -438,7 +514,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * @returns {number} */ getPercentWithBallPos: function (px) { - return (((px - (-this._barLength / 2.0)) / this._barLength) * 100.0); + return ((px/this._barLength)*100); +// return (((px - (-this._barLength / 2.0)) / this._barLength) * 100.0); }, /** @@ -451,10 +528,17 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._sliderEventListener = target; }, + addEventListener: function(callback){ + this._eventCallback = callback; + }, + percentChangedEvent: function () { if (this._sliderEventListener && this._sliderEventSelector) { this._sliderEventSelector.call(this._sliderEventListener, this, ccui.Slider.EVENT_PERCENT_CHANGED); } + if (this._eventCallback) { + this._eventCallback(ccui.Slider.EVENT_PERCENT_CHANGED); + } }, /** @@ -467,23 +551,28 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.barRendererScaleChangedWithSize(); - this.progressBarRendererScaleChangedWithSize(); +// this.barRendererScaleChangedWithSize(); +// this.progressBarRendererScaleChangedWithSize(); + this._barRendererAdaptDirty = true; + this._progressBarRendererDirty = true; }, - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - getContentSize: function () { - var locContentSize = this._barRenderer.getContentSize(); - return cc.size(locContentSize.width, locContentSize.height); - }, - _getWidth: function () { - return this._barRenderer._getWidth(); + adaptRenderers: function(){ + if (this._barRendererAdaptDirty) + { + this.barRendererScaleChangedWithSize(); + this._barRendererAdaptDirty = false; + } + if (this._progressBarRendererDirty) + { + this.progressBarRendererScaleChangedWithSize(); + this._progressBarRendererDirty = false; + } + }, - _getHeight: function () { - return this._barRenderer._getHeight(); + + getVirtualRendererSize: function(){ + return this._barRenderer.getContentSize(); }, /** @@ -497,15 +586,17 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ barRendererScaleChangedWithSize: function () { if (this._ignoreSize) { this._barRenderer.setScale(1.0); - var locSize = this._barRenderer.getContentSize(); - this._size.width = locSize.width; - this._size.height = locSize.height; - this._barLength = locSize.width; +// var locSize = this._barRenderer.getContentSize(); +// this._size.width = locSize.width; +// this._size.height = locSize.height; + this._barLength = this._contentSize.width; } else { - this._barLength = this._size.width; +// this._barLength = this._size.width; + this._barLength = this._contentSize.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)); + this._barRenderer.setPreferredSize(this._contentSize); } else { var btextureSize = this._barRenderer.getContentSize(); @@ -513,12 +604,13 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRenderer.setScale(1.0); return; } - var bscaleX = this._size.width / btextureSize.width; - var bscaleY = this._size.height / btextureSize.height; + var bscaleX = this._contentSize.width / btextureSize.width; + var bscaleY = this._contentSize.height / btextureSize.height; this._barRenderer.setScaleX(bscaleX); this._barRenderer.setScaleY(bscaleY); } } + this._barRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); this.setPercent(this._percent); }, @@ -534,7 +626,8 @@ 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)); + this._progressBarRenderer.setPreferredSize(this._contentSize); this._progressBarTextureSize = this._progressBarRenderer.getContentSize(); } else { @@ -543,16 +636,32 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarRenderer.setScale(1.0); return; } - var pscaleX = this._size.width / ptextureSize.width; - var pscaleY = this._size.height / ptextureSize.height; + var pscaleX = this._contentSize.width / ptextureSize.width; + var pscaleY = this._contentSize.height / ptextureSize.height; this._progressBarRenderer.setScaleX(pscaleX); this._progressBarRenderer.setScaleY(pscaleY); } } - this._progressBarRenderer.setPosition(-this._barLength * 0.5, 0.0); +// this._progressBarRenderer.setPosition(-this._barLength * 0.5, 0.0); + this._progressBarRenderer.setPosition(0.0, this._contentSize.height / 2.0); this.setPercent(this._percent); }, +// /** +// * override "getContentSize" method of widget. +// * @returns {cc.Size} +// */ +// getContentSize: function () { +// var locContentSize = this._barRenderer.getContentSize(); +// return cc.size(locContentSize.width, locContentSize.height); +// }, +// _getWidth: function () { +// return this._barRenderer._getWidth(); +// }, +// _getHeight: function () { +// return this._barRenderer._getHeight(); +// }, + onPressStateChangedToNormal: function () { this._slidBallNormalRenderer.setVisible(true); this._slidBallPressedRenderer.setVisible(false); @@ -571,22 +680,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._slidBallDisabledRenderer.setVisible(true); }, - updateTextureColor: function () { - this.updateColorToRenderer(this._barRenderer); - this.updateColorToRenderer(this._progressBarRenderer); - this.updateColorToRenderer(this._slidBallNormalRenderer); - this.updateColorToRenderer(this._slidBallPressedRenderer); - this.updateColorToRenderer(this._slidBallDisabledRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._barRenderer); - this.updateOpacityToRenderer(this._progressBarRenderer); - this.updateOpacityToRenderer(this._slidBallNormalRenderer); - this.updateOpacityToRenderer(this._slidBallPressedRenderer); - this.updateOpacityToRenderer(this._slidBallDisabledRenderer); - }, - /** * Returns the "class name" of widget. * @returns {string} @@ -608,7 +701,27 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this.loadSlidBallTexturePressed(slider._slidBallPressedTextureFile, slider._ballPTexType); this.loadSlidBallTextureDisabled(slider._slidBallDisabledTextureFile, slider._ballDTexType); this.setPercent(slider.getPercent()); + this._sliderEventListener = slider._sliderEventListener; + this._sliderEventSelector = slider._sliderEventSelector; + this._eventCallback = slider._eventCallback; + } + +// updateTextureColor: function () { +// this.updateColorToRenderer(this._barRenderer); +// this.updateColorToRenderer(this._progressBarRenderer); +// this.updateColorToRenderer(this._slidBallNormalRenderer); +// this.updateColorToRenderer(this._slidBallPressedRenderer); +// this.updateColorToRenderer(this._slidBallDisabledRenderer); +// }, +// +// updateTextureOpacity: function () { +// this.updateOpacityToRenderer(this._barRenderer); +// this.updateOpacityToRenderer(this._progressBarRenderer); +// this.updateOpacityToRenderer(this._slidBallNormalRenderer); +// this.updateOpacityToRenderer(this._slidBallPressedRenderer); +// this.updateOpacityToRenderer(this._slidBallDisabledRenderer); +// } }); var _p = ccui.Slider.prototype; @@ -629,7 +742,12 @@ _p = null; * var uiSlider = ccui.Slider.create(); */ ccui.Slider.create = function () { - return new ccui.Slider(); + var widget = new ccui.Slider(); + if (widget && widget.init()) + { + return widget; + } + return null; }; // Constant diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 3041075c5b..6db7f05eb0 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ + /** * Base class for ccui.Button * @class @@ -39,10 +40,10 @@ * @property {Number} verticalAlign - Vertical Alignment of label: cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM * @property {Boolean} touchScaleEnabled - Indicate whether the label will scale when touching */ -ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ - touchScaleEnabled: false, - _normalScaleValueX: 0, - _normalScaleValueY: 0, +ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ + _touchScaleChangeEnabled: false, + _normalScaleValueX: 1, + _normalScaleValueY: 1, _fontName: "Thonburi", _fontSize: 10, _onSelectedScaleOffset:0.5, @@ -51,6 +52,8 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ _textVerticalAlignment: 0, _textHorizontalAlignment: 0, _className: "Text", + _type: null, + _labelRendererAdaptDirty: true, /** * allocates and initializes a UILabel. @@ -60,12 +63,18 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * var uiLabel = new ccui.Text(); */ ctor: function () { + this._type = ccui.Text.Type.SYSTEM; this._textAreaSize = cc.size(0, 0); ccui.Widget.prototype.ctor.call(this); }, - init: function () { + init: function (textContent, fontName, fontSize) { if (ccui.Widget.prototype.init.call(this)) { + if(arguments.length > 0){ + this.setString(textContent); + this.setFontName(fontName); + this.setFontSize(fontSize); + } return true; } return false; @@ -83,8 +92,7 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ */ setText: function (text) { cc.log("Please use the setString"); - this._labelRenderer.setString(text); - this.labelScaleChangedWithSize(); + this.setString(text); }, /** @@ -93,7 +101,9 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ */ setString: function (text) { this._labelRenderer.setString(text); - this.labelScaleChangedWithSize(); +// this.labelScaleChangedWithSize(); + this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._labelRendererAdaptDirty = true; }, /** @@ -119,8 +129,9 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @returns {Number} */ getStringLength: function () { - var str = this._labelRenderer.getString(); - return str.length; +// var str = this._labelRenderer.getString(); +// return str.length; + return this._labelRenderer.getStringLength(); }, /** @@ -131,6 +142,17 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._fontSize = size; this._labelRenderer.setFontSize(size); this.labelScaleChangedWithSize(); +// if (this._type == ccui.Text.Type.SYSTEM) { +// this._labelRenderer.setSystemFontSize(size); +// } +// else{ +// var config = this._labelRenderer.getTTFConfig(); +// config.fontSize = size; +// this._labelRenderer.setTTFConfig(config); +// } +// this._fontSize = size; +// this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); +// this._labelRendererAdaptDirty = true; }, /** @@ -149,27 +171,21 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._fontName = name; this._labelRenderer.setFontName(name); this.labelScaleChangedWithSize(); - }, - - /** - * Get font name - * @returns {string} - */ - 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(); +// if(FileUtils::getInstance()->isFileExist(name)) +// { +// TTFConfig config = _labelRenderer->getTTFConfig(); +// config.fontFilePath = name; +// config.fontSize = _fontSize; +// _labelRenderer->setTTFConfig(config); +// _type = Type::TTF; +// } +// else{ +// _labelRenderer->setSystemFontName(name); +// _type = Type::SYSTEM; +// } +// _fontName = name; +// updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); +// _labelRendererAdaptDirty = true; }, /** @@ -177,39 +193,29 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {cc.Size} size */ setTextAreaSize: function (size) { - this._textAreaSize.width = size.width; - this._textAreaSize.height = size.height; +// this._textAreaSize.width = size.width; +// this._textAreaSize.height = size.height; this._labelRenderer.setDimensions(size); - this.labelScaleChangedWithSize(); +// this.labelScaleChangedWithSize(); + + this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._labelRendererAdaptDirty = true; }, getTextAreaSize: function(){ return this._labelRenderer.getDimensions(); }, - _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 * @param {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT} alignment Horizontal Alignment */ setTextHorizontalAlignment: function (alignment) { - this._textHorizontalAlignment = alignment; +// this._textHorizontalAlignment = alignment; this._labelRenderer.setHorizontalAlignment(alignment); - this.labelScaleChangedWithSize(); +// this.labelScaleChangedWithSize(); + + this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._labelRendererAdaptDirty = true; }, /** @@ -217,7 +223,7 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @returns {TEXT_ALIGNMENT_LEFT|TEXT_ALIGNMENT_CENTER|TEXT_ALIGNMENT_RIGHT} */ getTextHorizontalAlignment: function () { - return this._textHorizontalAlignment; + return this._labelRenderer.getHorizontalAlignment(); }, /** @@ -225,9 +231,11 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} verticalAlignment */ setTextVerticalAlignment: function (alignment) { - this._textVerticalAlignment = alignment; +// this._textVerticalAlignment = alignment; this._labelRenderer.setVerticalAlignment(alignment); - this.labelScaleChangedWithSize(); +// this.labelScaleChangedWithSize(); + this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._labelRendererAdaptDirty = true; }, /** @@ -235,15 +243,7 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @returns {VERTICAL_TEXT_ALIGNMENT_TOP|VERTICAL_TEXT_ALIGNMENT_CENTER|VERTICAL_TEXT_ALIGNMENT_BOTTOM} */ getTextVerticalAlignment: function () { - return this._textVerticalAlignment; - }, - - /** - * Gets the touch scale enabled of label. - * @returns {Boolean} - */ - getTouchScaleChangeAble: function () { - return this.isTouchScaleChangeEnabled(); + return this._labelRenderer.getVerticalAlignment(); }, /** @@ -251,7 +251,7 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {Boolean} enable */ setTouchScaleChangeEnabled: function (enable) { - this.touchScaleEnabled = enable; + this._touchScaleChangeEnabled = enable; }, /** @@ -259,11 +259,11 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @returns {Boolean} */ isTouchScaleChangeEnabled: function () { - return this.touchScaleEnabled; + return this._touchScaleChangeEnabled; }, onPressStateChangedToNormal: function () { - if (!this.touchScaleEnabled) { + if (!this._touchScaleChangeEnabled) { return; } this._labelRenderer.setScaleX(this._normalScaleValueX); @@ -271,7 +271,7 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, onPressStateChangedToPressed: function () { - if (!this.touchScaleEnabled) { + if (!this._touchScaleChangeEnabled) { return; } this._labelRenderer.setScaleX(this._normalScaleValueX + this._onSelectedScaleOffset); @@ -282,55 +282,35 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, - updateFlippedX: function () { - this._labelRenderer.setFlippedX(this._flippedX); - }, +// this._labelRenderer.setFlippedX(this._flippedX); - updateFlippedY: function () { - this._labelRenderer.setFlippedY(this._flippedY); - }, - - /** - * override "setAnchorPoint" of widget. - * @param {cc.Point|Number} point The anchor point of UILabel or The anchor point.x of UILabel. - * @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); - } else { - ccui.Widget.prototype.setAnchorPoint.call(this, point, y); - this._labelRenderer.setAnchorPoint(point, y); + if (this._flippedX) + { + this._labelRenderer.setScaleX(-1.0); + } + else + { + this._labelRenderer.setScaleX(1.0); } - }, - _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); - this.labelScaleChangedWithSize(); +// this.labelScaleChangedWithSize(); + this._labelRendererAdaptDirty = true; }, - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - getContentSize: function () { - return this._labelRenderer.getContentSize(); - }, - _getWidth: function () { - return this._labelRenderer._getWidth(); + adaptRenderers: function(){ + if (this._labelRendererAdaptDirty) + { + this.labelScaleChangedWithSize(); + this._labelRendererAdaptDirty = false; + } }, - _getHeight: function () { - return this._labelRenderer._getHeight(); + + getVirtualRendererSize: function(){ + return this._labelRenderer.getContentSize(); }, /** @@ -343,33 +323,29 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ labelScaleChangedWithSize: function () { if (this._ignoreSize) { + this._labelRenderer.setDimensions(0, 0); + this._labelRenderer.setScale(1.0); - var renderSize = this._labelRenderer.getContentSize(); - this._size.width = renderSize.width; - this._size.height = renderSize.height; +// var renderSize = this._labelRenderer.getContentSize(); +// this._size.width = renderSize.width; +// this._size.height = renderSize.height; this._normalScaleValueX = this._normalScaleValueY = 1; } else { + this._labelRenderer.setDimensions(this._contentSize.width, this._contentSize.height); var textureSize = this._labelRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._labelRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; + var scaleX = this._contentSize.width / textureSize.width; + var scaleY = this._contentSize.height / textureSize.height; this._labelRenderer.setScaleX(scaleX); this._labelRenderer.setScaleY(scaleY); this._normalScaleValueX = scaleX; this._normalScaleValueY = scaleY; } - }, - - updateTextureColor: function () { - this.updateColorToRenderer(this._labelRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._labelRenderer); + this._labelRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, /** @@ -380,19 +356,134 @@ ccui.Label = ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ return "Label"; }, + enableShadow: function(shadowColor, offset, blurRadius){ + this._labelRenderer.enableShadow(shadowColor, offset, blurRadius); + }, + + enableOutline: function(outlineColor, outlineSize){ + this._labelRenderer.enableOutline(outlineColor, outlineSize); + }, + + enableGlow: function(glowColor){ + if (this._type == ccui.Text.Type.TTF) + this._labelRenderer.enableGlow(glowColor); + }, + + disableEffect: function(){ + this._labelRenderer.disableEffect(); + }, + createCloneInstance: function () { return ccui.Text.create(); }, - copySpecialProperties: function (uiLabel) { - this.setFontName(uiLabel._fontName); - this.setFontSize(uiLabel._labelRenderer.getFontSize()); - this.setString(uiLabel.getString()); - this.setTouchScaleChangeEnabled(uiLabel.touchScaleEnabled); - this.setTextAreaSize(uiLabel._textAreaSize); - this.setTextHorizontalAlignment(uiLabel._textHorizontalAlignment); - this.setTextVerticalAlignment(uiLabel._textVerticalAlignment); + /** + * Get font name + * @returns {string} + */ + getFontName: function () { + return this._fontName; + }, + + getType: function(){ + return this._type; } +// +// _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(); +// }, +// _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; +// }, +// +// /** +// * Gets the touch scale enabled of label. +// * @returns {Boolean} +// */ +// getTouchScaleChangeAble: function () { +// return this.isTouchScaleChangeEnabled(); +// }, +// +// updateFlippedY: function () { +// this._labelRenderer.setFlippedY(this._flippedY); +// }, +// +// /** +// * override "setAnchorPoint" of widget. +// * @param {cc.Point|Number} point The anchor point of UILabel or The anchor point.x of UILabel. +// * @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); +// } else { +// 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); +// }, +// +// /** +// * override "getContentSize" method of widget. +// * @returns {cc.Size} +// */ +// getContentSize: function () { +// return this._labelRenderer.getContentSize(); +// }, +// _getWidth: function () { +// return this._labelRenderer._getWidth(); +// }, +// _getHeight: function () { +// return this._labelRenderer._getHeight(); +// }, +// +// updateTextureColor: function () { +// this.updateColorToRenderer(this._labelRenderer); +// }, +// +// updateTextureOpacity: function () { +// this.updateOpacityToRenderer(this._labelRenderer); +// }, +// +// copySpecialProperties: function (uiLabel) { +// this.setFontName(uiLabel._fontName); +// this.setFontSize(uiLabel._labelRenderer.getFontSize()); +// this.setString(uiLabel.getString()); +// this.setTouchScaleChangeEnabled(uiLabel.touchScaleEnabled); +// this.setTextAreaSize(uiLabel._textAreaSize); +// this.setTextHorizontalAlignment(uiLabel._textHorizontalAlignment); +// this.setTextVerticalAlignment(uiLabel._textVerticalAlignment); +// } }); var _p = ccui.Text.prototype; @@ -436,8 +527,26 @@ _p = null; * // example * var uiLabel = ccui.Text.create(); */ -ccui.Label = ccui.Text.create = function () { - return new ccui.Text(); +ccui.Label = ccui.Text.create = function (textContent, fontName, fontSize) { + var widget = new ccui.Text(); + if(arguments.length > 0){ + if (widget && widget.init(textContent, fontName, fontSize)) + { + return widget; + } + }else{ + if (widget && widget.init()) + { + return widget; + } + } + return null; }; -ccui.Text.RENDERER_ZORDER = -1; \ No newline at end of file +ccui.Text.RENDERER_ZORDER = -1; + + +ccui.Text.Type = { + SYSTEM: 0, + TTF: 1 +}; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 5c44b711a7..eae4d36110 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -30,7 +30,7 @@ * * @property {String} string - Content string of the label */ -ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ +ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ _labelAtlasRenderer: null, _stringValue: "", _charMapFileName: "", @@ -38,6 +38,7 @@ ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# _itemHeight: 0, _startCharMap: "", _className: "TextAtlas", + _labelAtlasRendererAdaptDirty: null, /** * allocates and initializes a UILabelAtlas. @@ -52,7 +53,9 @@ ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# initRenderer: function () { this._labelAtlasRenderer = new cc.LabelAtlas(); - cc.Node.prototype.addChild.call(this, this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); + //cc.Node.prototype.addChild.call(this, this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); + this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5, 0.5)); + this.addProtectedChild(this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); }, /** @@ -69,16 +72,34 @@ ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# this._itemWidth = itemWidth; this._itemHeight = itemHeight; this._startCharMap = startCharMap; - var renderer = this._labelAtlasRenderer; - renderer.initWithString(stringValue, charMapFile, itemWidth, itemHeight, startCharMap[0]); - this.updateAnchorPoint(); - this.labelAtlasScaleChangedWithSize(); - - if (!renderer.textureLoaded()) { - renderer.addLoadedEventListener(function () { - this.labelAtlasScaleChangedWithSize(); - }, this); - } +// var renderer = this._labelAtlasRenderer; +// renderer.initWithString(stringValue, charMapFile, itemWidth, itemHeight, startCharMap[0]); +// this.updateAnchorPoint(); +// this.labelAtlasScaleChangedWithSize(); +// +// if (!renderer.textureLoaded()) { +// renderer.addLoadedEventListener(function () { +// this.labelAtlasScaleChangedWithSize(); +// }, this); +// } + this._labelAtlasRenderer.setCharMap(this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); + this._labelAtlasRenderer.setString(stringValue); + + this.updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); + this._labelAtlasRendererAdaptDirty = true; + + }, + + /** + * set string value for ui text atlas. + * @param {String} value + */ + setString: function (value) { + this._stringValue = value; + this._labelAtlasRenderer.setString(value); +// this.labelAtlasScaleChangedWithSize(); + this.updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); + this._labelAtlasRendererAdaptDirty = true; }, /** @@ -109,56 +130,27 @@ ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# return this._labelAtlasRenderer.getString(); }, - /** - * set string value for ui text atlas. - * @param {String} value - */ - setString: function (value) { - this._stringValue = value; - this._labelAtlasRenderer.setString(value); - this.labelAtlasScaleChangedWithSize(); - }, - - /** - * override "setAnchorPoint" of widget. - * @param {cc.Point|Number} point The anchor point of UILabelAtlas or The anchor point.x of UILabelAtlas. - * @param {Number} [y] The anchor point.y of UILabelAtlas. - */ - setAnchorPoint: function (point, y) { - if (y === undefined) { - 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); - } - }, - _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); + getStringLength: function(){ + return this._labelAtlasRenderer.getStringLength(); }, onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.labelAtlasScaleChangedWithSize(); +// this.labelAtlasScaleChangedWithSize(); + this._labelAtlasRendererAdaptDirty = true; }, - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - getContentSize: function () { - return this._labelAtlasRenderer.getContentSize(); - }, - _getWidth: function () { - return this._labelAtlasRenderer._getWidth(); + adaptRenderers: function(){ + if (this._labelAtlasRendererAdaptDirty) + { + this.labelAtlasScaleChangedWithSize(); + this._labelAtlasRendererAdaptDirty = false; + } + }, - _getHeight: function () { - return this._labelAtlasRenderer._getHeight(); + + getVirtualRendererSize: function(){ + return this._labelAtlasRenderer.getContentSize(); }, /** @@ -172,9 +164,9 @@ ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# labelAtlasScaleChangedWithSize: function () { if (this._ignoreSize) { this._labelAtlasRenderer.setScale(1.0); - var atlasRenderSize = this._labelAtlasRenderer.getContentSize(); - this._size.width = atlasRenderSize.width; - this._size.height = atlasRenderSize.height; +// var atlasRenderSize = this._labelAtlasRenderer.getContentSize(); +// this._size.width = atlasRenderSize.width; +// this._size.height = atlasRenderSize.height; } else { var textureSize = this._labelAtlasRenderer.getContentSize(); @@ -187,14 +179,7 @@ ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# this._labelAtlasRenderer.setScaleX(scaleX); this._labelAtlasRenderer.setScaleY(scaleY); } - }, - - updateTextureColor: function () { - this.updateColorToRenderer(this._labelAtlasRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._labelAtlasRenderer); + this._labelAtlasRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, /** @@ -210,8 +195,56 @@ ccui.LabelAtlas = ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# }, copySpecialProperties: function (labelAtlas) { - this.setProperty(labelAtlas._stringValue, labelAtlas._charMapFileName, labelAtlas._itemWidth, labelAtlas._itemHeight, labelAtlas._startCharMap); + if (labelAtlas){ + this.setProperty(labelAtlas._stringValue, labelAtlas._charMapFileName, labelAtlas._itemWidth, labelAtlas._itemHeight, labelAtlas._startCharMap); + } } + + +// /** +// * override "setAnchorPoint" of widget. +// * @param {cc.Point|Number} point The anchor point of UILabelAtlas or The anchor point.x of UILabelAtlas. +// * @param {Number} [y] The anchor point.y of UILabelAtlas. +// */ +// setAnchorPoint: function (point, y) { +// if (y === undefined) { +// 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); +// } +// }, +// _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); +// }, +// +// /** +// * override "getContentSize" method of widget. +// * @returns {cc.Size} +// */ +// getContentSize: function () { +// return this._labelAtlasRenderer.getContentSize(); +// }, +// _getWidth: function () { +// return this._labelAtlasRenderer._getWidth(); +// }, +// _getHeight: function () { +// return this._labelAtlasRenderer._getHeight(); +// }, +// +// updateTextureColor: function () { +// this.updateColorToRenderer(this._labelAtlasRenderer); +// }, +// +// updateTextureOpacity: function () { +// this.updateOpacityToRenderer(this._labelAtlasRenderer); +// } }); var _p = ccui.TextAtlas.prototype; @@ -231,8 +264,15 @@ _p = null; * // example * var uiLabelAtlas = ccui.TextAtlas.create(); */ -ccui.LabelAtlas.create = ccui.TextAtlas.create = function () { - return new ccui.TextAtlas(); +ccui.TextAtlas.create = function (stringValue, charMapFile, itemWidth, itemHeight, startCharMap) { + var widget = new ccui.TextAtlas(); + if(widget && widget.init()){ + if(arguments.length > 0){ + widget.setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); + } + return widget; + } + return null; }; // Constants diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 7fd76a22c7..91403f48a5 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -32,10 +32,11 @@ */ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFont# */{ _labelBMFontRenderer: null, - _fileHasInit: false, + _fntFileHasInit: false, _fntFileName: "", _stringValue: "", _className: "TextBMFont", + _labelBMFontRendererAdaptDirty: true, /** * allocates and initializes a UILabelBMFont. @@ -48,8 +49,10 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo ccui.Widget.prototype.ctor.call(this); }, initRenderer: function () { - this._labelBMFontRenderer = cc.LabelBMFont.create(); - cc.Node.prototype.addChild.call(this, this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); +// this._labelBMFontRenderer = cc.LabelBMFont.create(); +// cc.Node.prototype.addChild.call(this, this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); + this._labelBMFontRenderer = cc.Label.create(); + this.addProtectedChild(this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); }, /** @@ -61,17 +64,23 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return; } this._fntFileName = fileName; - this._labelBMFontRenderer.initWithString("", fileName); - this.updateAnchorPoint(); - this.labelBMFontScaleChangedWithSize(); - this._fileHasInit = true; - this.setString(this._stringValue); +// this._labelBMFontRenderer.initWithString("", fileName); +// this.updateAnchorPoint(); +// this.labelBMFontScaleChangedWithSize(); +// this._fileHasInit = true; +// this.setString(this._stringValue); +// +// if (!this._labelBMFontRenderer.textureLoaded()) { +// this._labelBMFontRenderer.addLoadedEventListener(function () { +// this.labelBMFontScaleChangedWithSize(); +// }, this); +// } + this._labelBMFontRenderer.setBMFontFilePath(fileName); - if (!this._labelBMFontRenderer.textureLoaded()) { - this._labelBMFontRenderer.addLoadedEventListener(function () { - this.labelBMFontScaleChangedWithSize(); - }, this); - } + this._labelBMFontRenderer.setColor(this.getColor()); + this._labelBMFontRenderer.setOpacity(this.getOpacity()); + this._fntFileHasInit = true; + this.setString(this._stringValue); }, /** @@ -81,12 +90,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo */ setText: function (value) { cc.log("Please use the setString"); - if (!value) { - return; - } - this._stringValue = value; - this._labelBMFontRenderer.setString(value); - this.labelBMFontScaleChangedWithSize(); + this.setString(value); }, /** @@ -94,12 +98,14 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo * @param {String} value */ setString: function (value) { - if (!value) { + this._stringValue = value; + if (!this._fntFileHasInit) + { return; } - this._stringValue = value; this._labelBMFontRenderer.setString(value); - this.labelBMFontScaleChangedWithSize(); + this.updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()); + this._labelBMFontRendererAdaptDirty = true; }, /** @@ -110,46 +116,27 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return this._stringValue; }, - /** - * override "setAnchorPoint" of widget. - * @param {cc.Point|Number} point The anchor point of UILabelBMFont or The anchor point.x of UILabelBMFont. - * @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); - } else { - 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); + getStringLength: function(){ + return this._labelBMFontRenderer.getStringLength(); }, onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.labelBMFontScaleChangedWithSize(); +// this.labelBMFontScaleChangedWithSize(); + this._labelBMFontRendererAdaptDirty = true; }, - /** - * get content size - * @returns {cc.Size} - */ - getContentSize: function () { - return this._labelBMFontRenderer.getContentSize(); - }, - _getWidth: function () { - return this._labelBMFontRenderer._getWidth(); + adaptRenderers: function(){ + if (this._labelBMFontRendererAdaptDirty) + { + this.labelBMFontScaleChangedWithSize(); + this._labelBMFontRendererAdaptDirty = false; + } + }, - _getHeight: function () { - return this._labelBMFontRenderer._getHeight(); + + getVirtualRendererSize: function(){ + return this._labelBMFontRenderer.getContentSize(); }, /** @@ -163,9 +150,9 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo labelBMFontScaleChangedWithSize: function () { if (this._ignoreSize) { this._labelBMFontRenderer.setScale(1.0); - var rendererSize = this._labelBMFontRenderer.getContentSize(); - this._size.width = rendererSize.width; - this._size.height = rendererSize.height; +// var rendererSize = this._labelBMFontRenderer.getContentSize(); +// this._size.width = rendererSize.width; +// this._size.height = rendererSize.height; } else { var textureSize = this._labelBMFontRenderer.getContentSize(); @@ -178,15 +165,53 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo this._labelBMFontRenderer.setScaleX(scaleX); this._labelBMFontRenderer.setScaleY(scaleY); } + this._labelBMFontRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, - updateTextureColor: function () { - this.updateColorToRenderer(this._labelBMFontRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._labelBMFontRenderer); - }, +// /** +// * override "setAnchorPoint" of widget. +// * @param {cc.Point|Number} point The anchor point of UILabelBMFont or The anchor point.x of UILabelBMFont. +// * @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); +// } else { +// 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); +// }, +// +// /** +// * get content size +// * @returns {cc.Size} +// */ +// getContentSize: function () { +// return this._labelBMFontRenderer.getContentSize(); +// }, +// _getWidth: function () { +// return this._labelBMFontRenderer._getWidth(); +// }, +// _getHeight: function () { +// return this._labelBMFontRenderer._getHeight(); +// }, +// +// updateTextureColor: function () { +// this.updateColorToRenderer(this._labelBMFontRenderer); +// }, +// +// updateTextureOpacity: function () { +// this.updateOpacityToRenderer(this._labelBMFontRenderer); +// }, /** * Returns the "class name" of widget. @@ -194,15 +219,15 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo */ getDescription: function () { return "LabelBMFont"; - }, - - createCloneInstance: function () { - return ccui.TextBMFont.create(); - }, - - copySpecialProperties: function (labelBMFont) { - this.setFntFile(labelBMFont._fntFileName); - this.setText(labelBMFont._stringValue); +// }, +// +// createCloneInstance: function () { +// return ccui.TextBMFont.create(); +// }, +// +// copySpecialProperties: function (labelBMFont) { +// this.setFntFile(labelBMFont._fntFileName); +// this.setText(labelBMFont._stringValue); } }); @@ -223,8 +248,17 @@ _p = null; * // example * var uiLabelBMFont = ccui.TextBMFont.create(); */ -ccui.LabelBMFont.create = ccui.TextBMFont.create = function () { - return new ccui.TextBMFont(); +ccui.TextBMFont.create = function (text, filename) { + var widget = new ccui.TextBMFont(); + if(widget && widget.init()){ + if(filename && text){ + widget.setFntFile(filename); + widget.setString(text); + } + return widget; + + } + return null; }; // Constants diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 14b40377b4..f12f3e9d5f 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -32,7 +32,7 @@ * @property {Number} maxLength - The max length of the text field * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password */ -ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ +ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ maxLengthEnabled: false, maxLength: 0, passwordEnabled: false, @@ -53,25 +53,16 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu this._insertText = false; this._deleteBackward = false; }, - init: function () { - if (ccui.Widget.prototype.init.call(this)) { - this.setTouchEnabled(true); - return true; - } - return false; - }, onEnter: function () { - cc.TextFieldTTF.prototype.onEnter.call(this); - cc.TextFieldTTF.prototype.setDelegate.call(this, this); + cc.TextFieldTTF.prototype.setDelegate(this); +// cc.TextFieldTTF.prototype.onEnter.call(this); +// cc.TextFieldTTF.prototype.setDelegate.call(this, this); }, - //CCTextFieldDelegate - onTextFieldAttachWithIME: function (sender) { this.setAttachWithIME(true); return false; }, - onTextFieldInsertText: function (sender, text, len) { if (len == 1 && text == "\n") { return false; @@ -85,68 +76,49 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu return false; }, - onTextFieldDeleteBackward: function (sender, delText, nLen) { this.setDeleteBackward(true); return false; }, - onTextFieldDetachWithIME: function (sender) { this.setDetachWithIME(true); return false; }, - insertText: function (text, len) { //todo need to delete - var str_text = text; - var locString = cc.TextFieldTTF.prototype.getString.call(this); - var str_len = locString.length; - var multiple, header; - if (text != "\n") { - if (this.maxLengthEnabled) { - multiple = 1; - header = text.charCodeAt(0); - if (header < 0 || header > 127) { - multiple = 3; - } - - if (str_len + len > this.maxLength * multiple) { - str_text = str_text.substr(0, this.maxLength * multiple); - len = this.maxLength * multiple; - } - } - } - cc.TextFieldTTF.prototype.insertText.call(this, str_text, len); - - // password - if (this.passwordEnabled) { - if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) { - this.setPasswordText(this._inputText); - } - } - }, - - _calcCharCount: function(pszText){ - var n = 0; - var ch = pszText; - if(!ch) { - if (0x80 != (0xC0 & ch)) - { - ++n; - } - ++pszText; - } - return n; - }, - - insertText: function(text, len){ +// var str_text = text; +// var locString = cc.TextFieldTTF.prototype.getString.call(this); +// var str_len = locString.length; +// var multiple, header; +// if (text != "\n") { +// if (this.maxLengthEnabled) { +// multiple = 1; +// header = text.charCodeAt(0); +// if (header < 0 || header > 127) { +// multiple = 3; +// } +// +// if (str_len + len > this.maxLength * multiple) { +// str_text = str_text.substr(0, this.maxLength * multiple); +// len = this.maxLength * multiple; +// } +// } +// } +// cc.TextFieldTTF.prototype.insertText.call(this, str_text, len); +// +// // password +// if (this.passwordEnabled) { +// if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) { +// this.setPasswordText(this._inputText); +// } +// } var input_text = text; - if (text !== "\n") + if (text != "\n") { if (this.maxLengthEnabled) { - var text_count = this._calcCharCount(this.getString()); - if (text_count >= this._maxLength) + var text_count = this.getString().length; + if (text_count >= this.maxLength) { // password if (this.passwordEnabled) @@ -160,42 +132,42 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu (cc.sys.os == cc.sys.OS_IOS) || (cc.sys.os == cc.sys.OS_OSX) || (cc.sys.os == cc.sys.OS_WINDOWS) - ) - var input_count = this._calcCharCount(text); - var total = text_count + input_count; - - if (total > this._maxLength) - { - var end = 0; - var length = this._maxLength - text_count; + ){ + var input_count = text.length; + var total = text_count + input_count; - for (var i = 0; i < length; ++i) + if (total > this.maxLength) { - var value = text[i]; + var end = 0; + var length = this.maxLength - text_count; - if (value >= 0 && value <= 127) // ascii - { - end++; - } - else + for (var i = 0; i < length; ++i) { - end += 3; + var value = text[i]; + + if (value >= 0 && value <= 127) // ascii + { + end++; + } + else + { + end += 3; + } } + input_text = input_text.substr(0, end); + len = end; } - input_text = input_text.substr(0, end); - len = end; - } - else if (cc.sys.os == cc.sys.OS_ANDROID) - { + }else if(cc.sys.os == cc.sys.OS_ANDROID){ var input_count = this._calcCharCount(text); - if (input_count > this._maxLength) + var total = text_count + input_count; + if (total > this.maxLength) { var ascii = 0; var unicode = 0; var end = 0; var count = 0; - for (var i = 0; i < input_count * 3; ++i) + for (var i = 0; i < total * 3; ++i) { var value = text[i]; @@ -213,7 +185,7 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu } } - if (count == this._maxLength) + if (count == this.maxLength) { break; } @@ -228,10 +200,14 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); // password - if (this.passwordEnabled && (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0)) + if (this.passwordEnabled) + { + if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) + { this.setPasswordText(this.getString()); + } + } }, - deleteBackward: function () { cc.TextFieldTTF.prototype.deleteBackward.call(this); @@ -242,45 +218,33 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu } } }, - openIME: function () { cc.TextFieldTTF.prototype.attachWithIME.call(this); }, - closeIME: function () { cc.TextFieldTTF.prototype.detachWithIME.call(this); }, - onDraw: function (sender) { - return false; - }, setMaxLengthEnabled: function (enable) { this.maxLengthEnabled = enable; }, - isMaxLengthEnabled: function () { return this.maxLengthEnabled; }, - setMaxLength: function (length) { this.maxLength = length; }, - getMaxLength: function () { return this.maxLength; }, - getCharCount: function () { return cc.TextFieldTTF.prototype.getCharCount.call(this); }, - setPasswordEnabled: function (enable) { this.passwordEnabled = enable; }, - isPasswordEnabled: function () { return this.passwordEnabled; }, - setPasswordStyleText: function (styleText) { if (styleText.length > 1) { return; @@ -291,49 +255,183 @@ ccui.UICCLabelField = ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccu } this._passwordStyleText = styleText; }, - setPasswordText: function (text) { +// var tempStr = ""; +// for (var i = 0; i < text.length; ++i) { +// tempStr += this._passwordStyleText; +// } +// cc.LabelTTF.prototype.setString.call(this, tempStr); var tempStr = ""; - for (var i = 0; i < text.length; ++i) { - tempStr += this._passwordStyleText; + var text_count = this._calcCharCount(text); + var max = text_count; + + if (this.maxLengthEnabled) + { + if (text_count > this.maxLength) + { + max = this.maxLength; + } + } + + for (var i = 0; i < max; ++i) + { + tempStr.append(this._passwordStyleText); } + cc.LabelTTF.prototype.setString.call(this, tempStr); }, - setAttachWithIME: function (attach) { this._attachWithIME = attach; }, - getAttachWithIME: function () { return this._attachWithIME; }, - setDetachWithIME: function (detach) { this._detachWithIME = detach; }, - getDetachWithIME: function () { return this._detachWithIME; }, - setInsertText: function (insert) { this._insertText = insert; }, - getInsertText: function () { return this._insertText; }, - setDeleteBackward: function (deleteBackward) { this._deleteBackward = deleteBackward; }, - getDeleteBackward: function () { return this._deleteBackward; + }, + init: function () { + if (ccui.Widget.prototype.init.call(this)) { + this.setTouchEnabled(true); + return true; + } + return false; + }, + _calcCharCount: function(pszText){ + var n = 0; + var ch = pszText; + if(!ch) { + if (0x80 != (0xC0 & ch)) + { + ++n; + } + ++pszText; + } + return n; + }, + + insertText: function(text, len){ +// var input_text = text; +// +// if (text !== "\n") +// { +// if (this.maxLengthEnabled) +// { +// var text_count = this._calcCharCount(this.getString()); +// if (text_count >= this._maxLength) +// { +// // password +// if (this.passwordEnabled) +// { +// this.setPasswordText(this.getString()); +// } +// return; +// } +// +// if ( +// (cc.sys.os == cc.sys.OS_IOS) || +// (cc.sys.os == cc.sys.OS_OSX) || +// (cc.sys.os == cc.sys.OS_WINDOWS) +// ) +// var input_count = this._calcCharCount(text); +// var total = text_count + input_count; +// +// if (total > this._maxLength) +// { +// var end = 0; +// var length = this._maxLength - text_count; +// +// for (var i = 0; i < length; ++i) +// { +// var value = text[i]; +// +// if (value >= 0 && value <= 127) // ascii +// { +// end++; +// } +// else +// { +// end += 3; +// } +// } +// input_text = input_text.substr(0, end); +// len = end; +// } +// else if (cc.sys.os == cc.sys.OS_ANDROID) +// { +// var input_count = this._calcCharCount(text); +// if (input_count > this._maxLength) +// { +// var ascii = 0; +// var unicode = 0; +// var end = 0; +// var count = 0; +// +// for (var i = 0; i < input_count * 3; ++i) +// { +// var value = text[i]; +// +// if (value >= 0 && value <= 127) // ascii +// { +// ascii++; +// count++; +// } +// else +// { +// unicode++; +// if (unicode % 3 == 0) +// { +// count++; +// } +// } +// +// if (count == this._maxLength) +// { +// break; +// } +// } +// end = ascii + unicode; +// input_text = input_text.substr(0, end); +// len = end; +// } +// } +// } +// } +// cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); +// +// // password +// if (this.passwordEnabled && (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0)) +// this.setPasswordText(this.getString()); + // password + if (this._passwordEnabled) + { + if (cc.TextFieldTTF.prototype.getCharCount() > 0) + { + this.setPasswordText(this.getString()); + } + } + + }, + onDraw: function (sender) { + return false; } }); -ccui.UICCLabelField.create = ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { +ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { var ret = new ccui.UICCTextField(); if (ret && ret.initWithString("", fontName, fontSize)) { if (placeholder) { @@ -410,7 +508,7 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# * @param {cc.Size} size */ setTouchSize: function (size) { - this._useTouchArea = true; +// this._useTouchArea = true; this._touchWidth = size.width; this._touchHeight = size.height; }, @@ -899,6 +997,22 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# } }); +ccui.TextField.create = function(placeholder, fontName, fontSize){ + var widget = new ccui.TextField(); + if (widget && widget.init()) + { + if(placeholder && fontName && fontSize){ + widget.setPlaceHolder(placeholder); + widget.setFontName(fontName); + widget.setFontSize(fontSize); + + } + return widget; + } + return null; + +}; + var _p = ccui.TextField.prototype; // Extended properties From 302f4987753a1ec1d6243e291c4e380e5c85b7fc Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 1 Jul 2014 14:04:18 +0800 Subject: [PATCH 0207/1564] Issue #5600: fixed some bug of cocos gui --- extensions/ccui/uiwidgets/UIImageView.js | 3 +- extensions/ccui/uiwidgets/UISlider.js | 7 +- extensions/ccui/uiwidgets/UIText.js | 17 ++-- extensions/ccui/uiwidgets/UITextAtlas.js | 4 +- extensions/ccui/uiwidgets/UITextBMFont.js | 2 +- .../uiwidgets/scroll-widget/UIScrollView.js | 77 +++++++++++++++++-- extensions/cocostudio/reader/GUIReader.js | 2 +- 7 files changed, 88 insertions(+), 24 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 77853a6f37..f09033cf90 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -53,6 +53,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, init: function(imageFileName, texType){ + ccui.Widget.prototype.init.call(this); if(imageFileName !== undefined) this.loadTexture(imageFileName, texType); return true; @@ -60,7 +61,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ initRenderer: function () { this._imageRenderer = cc.Sprite.create(); - cc.Node.prototype.addChild.call(this, this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); + this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); }, /** diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 246f35dd5d..f756f69fce 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -155,7 +155,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRendererAdaptDirty = true; this._progressBarRendererDirty = true; - this.updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); }, /** @@ -474,10 +474,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var nsp = this._slidBallNormalRenderer.convertToNodeSpace(pt); var ballSize = this._slidBallNormalRenderer.getContentSize(); var ballRect = cc.rect(0,0, ballSize.width, ballSize.height); - if (ballRect.containsPoint(nsp)) { - return true; - } - return false; + return cc.rectContainsPoint(ballRect, nsp); }, onTouchBegan: function (touch, event) { diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 6db7f05eb0..d0e0814629 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -102,7 +102,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ setString: function (text) { this._labelRenderer.setString(text); // this.labelScaleChangedWithSize(); - this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, @@ -198,7 +198,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRenderer.setDimensions(size); // this.labelScaleChangedWithSize(); - this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, getTextAreaSize: function(){ @@ -214,7 +214,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRenderer.setHorizontalAlignment(alignment); // this.labelScaleChangedWithSize(); - this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, @@ -228,13 +228,13 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ /** * Set Vertical Alignment of label - * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} verticalAlignment + * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} alignment */ setTextVerticalAlignment: function (alignment) { // this._textVerticalAlignment = alignment; this._labelRenderer.setVerticalAlignment(alignment); // this.labelScaleChangedWithSize(); - this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, @@ -323,16 +323,15 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ labelScaleChangedWithSize: function () { if (this._ignoreSize) { - this._labelRenderer.setDimensions(0, 0); + this._labelRenderer.setDimensions(cc.size(0, 0)); this._labelRenderer.setScale(1.0); // var renderSize = this._labelRenderer.getContentSize(); // this._size.width = renderSize.width; // this._size.height = renderSize.height; this._normalScaleValueX = this._normalScaleValueY = 1; - } - else { - this._labelRenderer.setDimensions(this._contentSize.width, this._contentSize.height); + } else { + this._labelRenderer.setDimensions(cc.size(this._contentSize.width, this._contentSize.height)); var textureSize = this._labelRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._labelRenderer.setScale(1.0); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index eae4d36110..92781d15b6 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -85,7 +85,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._labelAtlasRenderer.setCharMap(this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); this._labelAtlasRenderer.setString(stringValue); - this.updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; }, @@ -98,7 +98,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._stringValue = value; this._labelAtlasRenderer.setString(value); // this.labelAtlasScaleChangedWithSize(); - this.updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 91403f48a5..00ca29f735 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -104,7 +104,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return; } this._labelBMFontRenderer.setString(value); - this.updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()); this._labelBMFontRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 9f6583c0ac..2c262ab6d9 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -168,6 +168,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._innerContainer.setPosition(0, locSize.height - this._innerContainer.getSize().height); }, + /** + * Changes inner container size of scrollview.
+ * Inner container size must be larger than or equal scrollview's size. + * + * @param {cc.Size} size inner container size. + */ setInnerContainerSize: function (size) { var locSize = this._size; var innerSizeWidth = locSize.width; @@ -1227,6 +1233,11 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, this._size.height - this._innerContainer.getSize().height), time, attenuated); }, + /** + * Scroll inner container to bottom and left boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToBottomLeft: function (time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); @@ -1235,25 +1246,48 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.startAutoScrollChildrenWithDestination(cc.p(0, 0), time, attenuated); }, + /** + * Scroll inner container to bottom and right boundary of scrollview. + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToBottomRight: function (time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretcion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, 0), time, attenuated); }, + /** + * Scroll inner container to vertical percent position of scrollview. + * @param {Number} percent + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToPercentVertical: function (percent, time, attenuated) { var minY = this._size.height - this._innerContainer.getSize().height; var h = -minY; this.startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), minY + percent * h / 100), time, attenuated); }, + /** + * Scroll inner container to horizontal percent position of scrollview. + * @param {Number} percent + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToPercentHorizontal: function (percent, time, attenuated) { var w = this._innerContainer.getSize().width - this._size.width; this.startAutoScrollChildrenWithDestination(cc.p(-(percent * w / 100), this._innerContainer.getPositionY()), time, attenuated); }, + /** + * Scroll inner container to both direction percent position of scrollview. + * @param {Number} percent + * @param {Number} time + * @param {Boolean} attenuated + */ scrollToPercentBothDirection: function (percent, time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) { return; @@ -1264,65 +1298,98 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.startAutoScrollChildrenWithDestination(cc.p(-(percent.x * w / 100), minY + percent.y * h / 100), time, attenuated); }, + /** + * Move inner container to bottom boundary of scrollview. + */ jumpToBottom: function () { this.jumpToDestination(this._innerContainer.getPositionX(), 0); }, + /** + * Move inner container to top boundary of scrollview. + */ jumpToTop: function () { this.jumpToDestination(this._innerContainer.getPositionX(), this._size.height - this._innerContainer.getSize().height); }, + /** + * Move inner container to left boundary of scrollview. + */ jumpToLeft: function () { this.jumpToDestination(0, this._innerContainer.getPositionY()); }, + /** + * Move inner container to right boundary of scrollview. + */ jumpToRight: function () { this.jumpToDestination(this._size.width - this._innerContainer.getSize().width, this._innerContainer.getPositionY()); }, + /** + * Move inner container to top and left boundary of scrollview. + */ jumpToTopLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.jumpToDestination(0, this._size.height - this._innerContainer.getSize().height); }, + /** + * Move inner container to top and right boundary of scrollview. + */ jumpToTopRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.jumpToDestination(this._size.width - this._innerContainer.getSize().width, this._size.height - this._innerContainer.getSize().height); }, + /** + * Move inner container to bottom and left boundary of scrollview. + */ jumpToBottomLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.jumpToDestination(0, 0); }, + /** + * Move inner container to bottom and right boundary of scrollview. + */ jumpToBottomRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { - cc.log("Scroll diretion is not both!"); + cc.log("Scroll direction is not both!"); return; } this.jumpToDestination(this._size.width - this._innerContainer.getSize().width, 0); }, + /** + * Move inner container to vertical percent position of scrollview. + */ jumpToPercentVertical: function (percent) { var minY = this._size.height - this._innerContainer.getSize().height; var h = -minY; this.jumpToDestination(this._innerContainer.getPositionX(), minY + percent * h / 100); }, + /** + * Move inner container to horizontal percent position of scrollview. + */ jumpToPercentHorizontal: function (percent) { var w = this._innerContainer.getSize().width - this._size.width; this.jumpToDestination(-(percent * w / 100), this._innerContainer.getPositionY()); }, + /** + * Move inner container to both direction percent position of scrollview. + */ jumpToPercentBothDirection: function (percent) { if (this.direction != ccui.ScrollView.DIR_BOTH) { return; diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 8aeec20313..4d004feab6 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -903,7 +903,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ { render = ccs.ImageViewReader; } - else if (widget instanceof ccui.LabelAtlas) + else if (widget instanceof ccui.TextAtlas) { render = ccs.LabelAtlasReader; } From ca372af50ecd45ff96afa59a9e1209dd7870911b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 1 Jul 2014 15:21:19 +0800 Subject: [PATCH 0208/1564] Issue #5600: UIListView and UIPageView --- .../uiwidgets/scroll-widget/UIListView.js | 161 ++++-- .../uiwidgets/scroll-widget/UIPageView.js | 485 +++++++++++------- 2 files changed, 427 insertions(+), 219 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index b1e45eed3d..93b08e1edc 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -61,7 +61,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ init: function () { if (ccui.ScrollView.prototype.init.call(this)) { - this._items = []; +// this._items = []; this.setLayoutType(ccui.Layout.LINEAR_VERTICAL); return true; } @@ -86,9 +86,9 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ var totalHeight = (length - 1) * this._itemsMargin; for (var i = 0; i < length; i++) { var item = this._items[i]; - totalHeight += item.getSize().height; + totalHeight += item.getContentSize().height; } - var finalWidth = this._size.width; + var finalWidth = this._contentSize.width; var finalHeight = totalHeight; this.setInnerContainerSize(cc.size(finalWidth, finalHeight)); break; @@ -97,10 +97,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ var totalWidth = (length - 1) * this._itemsMargin; for (var i = 0; i < length; i++) { var item = this._items[i]; - totalWidth += item.getSize().width; + totalWidth += item.getContentSize().width; } var finalWidth = totalWidth; - var finalHeight = this._size.height; + var finalHeight = this._contentSize.height; this.setInnerContainerSize(cc.size(finalWidth, finalHeight)); break; default: @@ -114,7 +114,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: - var llp = item.getLayoutParameter(ccui.LayoutParameter.LINEAR); + var llp = item.getLayoutParameter(); +// var llp = item.getLayoutParameter(ccui.LayoutParameter.LINEAR); if (!llp) { var defaultLp = ccui.LinearLayoutParameter.create(); switch (this._gravity) { @@ -161,7 +162,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } break; case ccui.ScrollView.DIR_HORIZONTAL: - var llp = item.getLayoutParameter(ccui.LayoutParameter.LINEAR); +// var llp = item.getLayoutParameter(ccui.LayoutParameter.LINEAR); + var llp = item.getLayoutParameter(); if (!llp) { var defaultLp = ccui.LinearLayoutParameter.create(); switch (this._gravity) { @@ -220,7 +222,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ return; } var newItem = this._model.clone(); - this._items.push(newItem); +// this._items.push(newItem); this.remedyLayoutParameter(newItem); this.addChild(newItem); this._refreshViewDirty = true; @@ -236,8 +238,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } var newItem = this._model.clone(); this._items.splice(index, 0, newItem); - this.remedyLayoutParameter(newItem); this.addChild(newItem); + + this.remedyLayoutParameter(newItem); + this._refreshViewDirty = true; }, @@ -246,12 +250,47 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {ccui.Widget} item */ pushBackCustomItem: function (item) { - this._items.push(item); +// this._items.push(item); this.remedyLayoutParameter(item); this.addChild(item); this._refreshViewDirty = true; }, + addChild: function(widget, zOrder, tag){ + if(widget){ + if(zOrder && tag){ + ccui.ScrollView.prototype.addChild.call(this, widget, zOrder, tag); + + if (widget) + { + this._items.push(widget); + } + }else{ + ccui.ListView.prototype.addChild.call(this, widget, zOrder || widget.getLocalZOrder(), widget.getName()); + } + } + }, + + removeChild: function(widget, cleaup){ + if (widget) { + var index = this._items.indexOf(widget); + if(index > -1){ + this._items.splice(index, 1); + } + } + + ccui.ScrollView.prototype.removeChild.call(this, widget, cleaup); + }, + + removeAllChildren: function(){ + this.removeAllChildrenWithCleanup(true); + }, + + removeAllChildrenWithCleanup: function(cleanup){ + ccui.ScrollView.prototype.removeAllChildrenWithCleanup.call(this, cleanup); + this._items = []; + }, + /** * Push back custom item into listview. * @param {ccui.Widget} item @@ -259,8 +298,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ */ insertCustomItem: function (item, index) { this._items.splice(index, 0, item); + ccui.ScrollView.prototype.addChild.call(this, item); + this.remedyLayoutParameter(item); - this.addChild(item); +// this.addChild(item); this._refreshViewDirty = true; }, @@ -273,7 +314,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ if (!item) { return; } - cc.arrayRemoveObject(this._items, item); +// cc.arrayRemoveObject(this._items, item); this.removeChild(item); this._refreshViewDirty = true; }, @@ -285,6 +326,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this.removeItem(this._items.length - 1); }, + removeAllItems: function(){ + this.removeAllChildren(); + }, + /** * Returns a item whose index is same as the parameter. * @param {Number} index @@ -368,6 +413,32 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, + /** + * request refresh view + */ + requestRefreshView: function () { + this._refreshViewDirty = true; + }, + + refreshView: function () { + for (var i = 0; i < this._items.length; i++) { + var item = this._items[i]; + item.setLocalZOrder(i); + this.remedyLayoutParameter(item); + } + this.updateInnerContainerSize(); + }, + + doLayout: function(){ + ccui.Layout.prototype.doLayout.call(this); + + if (this._refreshViewDirty) + { + this.refreshView(); + this._refreshViewDirty = false; + } + }, + /** * add event listener * @param {Function} selector @@ -378,15 +449,29 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._listViewEventSelector = selector; }, - selectedItemEvent: function (state) { + addEventListener: function(callback){ + this._eventCallback = callback; + }, + + selectedItemEvent: function (event) { if(this._listViewEventSelector&&this._listViewEventListener){ switch(state){ case 0: - this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_START); + if (this._listViewEventListener && this._listViewEventSelector) + this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_START); + + if(this._eventCallback) + this._eventCallback(this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_START); + break; default: - this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_END); + if (this._listViewEventListener && this._listViewEventSelector) + this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_END); + + if (this._eventCallback) + this._eventCallback(this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_END); + break; } } @@ -403,7 +488,9 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } parent = parent.getParent(); } - this.selectedItemEvent(handleState); + if (sender.isHighlighted()) { + this.selectedItemEvent(handleState); + } } }, @@ -415,29 +502,13 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ return this._curSelectedIndex; }, - /** - * request refresh view - */ - requestRefreshView: function () { - this._refreshViewDirty = true; - }, - - refreshView: function () { - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; - item.setLocalZOrder(i); - this.remedyLayoutParameter(item); - } - this.updateInnerContainerSize(); - }, - - sortAllChildren: function () { - ccui.ScrollView.prototype.sortAllChildren.call(this); - if (this._refreshViewDirty) { - this.refreshView(); - this._refreshViewDirty = false; - } - }, +// sortAllChildren: function () { +// ccui.ScrollView.prototype.sortAllChildren.call(this); +// if (this._refreshViewDirty) { +// this.refreshView(); +// this._refreshViewDirty = false; +// } +// }, onSizeChanged: function () { ccui.ScrollView.prototype.onSizeChanged.call(this); @@ -469,6 +540,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this.setItemModel(listView._model); this.setItemsMargin(listView._itemsMargin); this.setGravity(listView._gravity); + + this._listViewEventListener = listView._listViewEventListener; + this._listViewEventSelector = listView._listViewEventSelector; + this._eventCallback = listView._eventCallback; + } }); @@ -480,7 +556,12 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * var uiPageView = ccui.ListView.create(); */ ccui.ListView.create = function () { - return new ccui.ListView(); + var widget = new ccui.ListView(); + if (widget && widget.init()) + { + return widget; + } + return null; }; // Constants diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 931a407822..bb50a0d818 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -47,6 +47,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _pageViewEventListener: null, _pageViewEventSelector: null, _className:"PageView", + _touchMoveDirection: null, + /** * allocates and initializes a UIPageView. * Constructor of ccui.PageView @@ -80,7 +82,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ init: function () { if (ccui.Layout.prototype.init.call(this)) { this.setClippingEnabled(true); - this.setTouchEnabled(true); +// this.setTouchEnabled(true); return true; } return false; @@ -103,13 +105,11 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {Boolean} forceCreate */ addWidgetToPage: function (widget, pageIdx, forceCreate) { - if (!widget) { - return; - } - if(pageIdx<0){ + if (!widget || pageIdx < 0) { return; } - var pageCount = this._pages.length; + + var pageCount = this.getPageCount(); if (pageIdx >= pageCount) { if (forceCreate) { if (pageIdx > pageCount) { @@ -134,7 +134,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ */ createPage: function () { var newPage = ccui.Layout.create(); - newPage.setSize(this.getSize()); +// newPage.setSize(this.getSize()); + newPage.setContentSize(this.getContentSize()); return newPage; }, @@ -143,25 +144,35 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {ccui.Layout} page */ addPage: function (page) { - if (!page) { - return; - } - if (page.getWidgetType() != ccui.Widget.TYPE_CONTAINER) { +// if (!page) { +// return; +// } +// if (page.getWidgetType() != ccui.Widget.TYPE_CONTAINER) { +// return; +// } +// if (this._pages.indexOf(page) != -1) { +// return; +// } +// var pSize = page.getSize(); +// var pvSize = this.getSize(); +// if (!(pSize.width==pvSize.width&&pSize.height==pvSize.height)) { +// cc.log("page size does not match pageview size, it will be force sized!"); +// page.setSize(pvSize); +// } +// page.setPosition(this.getPositionXByIndex(this._pages.length), 0); +// this._pages.push(page); +// this.addChild(page); +// this.updateBoundaryPages(); + if (!page || this._pages.indexOf(page) != -1) + { return; } - if (this._pages.indexOf(page) != -1) { - return; - } - var pSize = page.getSize(); - var pvSize = this.getSize(); - if (!(pSize.width==pvSize.width&&pSize.height==pvSize.height)) { - cc.log("page size does not match pageview size, it will be force sized!"); - page.setSize(pvSize); - } - page.setPosition(this.getPositionXByIndex(this._pages.length), 0); + + + this.addProtectedChild(page); this._pages.push(page); - this.addChild(page); - this.updateBoundaryPages(); + + this._doLayoutDirty = true; }, /** @@ -170,42 +181,61 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {Number} idx */ insertPage: function (page, idx) { - if (idx < 0) { - return; - } - if (!page) { - return; - } - if (page.getWidgetType() != ccui.Widget.TYPE_CONTAINER) { - return; - } - if (this._pages.indexOf(page) != -1) { +// if (idx < 0) { +// return; +// } +// if (!page) { +// return; +// } +// if (page.getWidgetType() != ccui.Widget.TYPE_CONTAINER) { +// return; +// } +// if (this._pages.indexOf(page) != -1) { +// return; +// } +// +// var pageCount = this._pages.length; +// if (idx >= pageCount) { +// this.addPage(page); +// } +// else { +// this._pages.splice(idx, 0, page); +// page.setPosition(this.getPositionXByIndex(idx), 0); +// this.addChild(page); +// var pSize = page.getSize(); +// var pvSize = this.getSize(); +// if (!pSize.equals(pvSize)) { +// cc.log("page size does not match pageview size, it will be force sized!"); +// page.setSize(pvSize); +// } +// var arrayPages = this._pages; +// var length = arrayPages.length; +// for (var i = (idx + 1); i < length; i++) { +// var behindPage = arrayPages[i]; +// var formerPos = behindPage.getPosition(); +// behindPage.setPosition(formerPos.x + this.getSize().width, 0); +// } +// this.updateBoundaryPages(); +// } + if (idx < 0 || !page || this._pages.indexOf(page) != -1) + { return; } - var pageCount = this._pages.length; - if (idx >= pageCount) { + + var pageCount = this.getPageCount(); + if (idx >= pageCount) + { this.addPage(page); } - else { - this._pages.splice(idx, 0, page); - page.setPosition(this.getPositionXByIndex(idx), 0); - this.addChild(page); - var pSize = page.getSize(); - var pvSize = this.getSize(); - if (!pSize.equals(pvSize)) { - cc.log("page size does not match pageview size, it will be force sized!"); - page.setSize(pvSize); - } - var arrayPages = this._pages; - var length = arrayPages.length; - for (var i = (idx + 1); i < length; i++) { - var behindPage = arrayPages[i]; - var formerPos = behindPage.getPosition(); - behindPage.setPosition(formerPos.x + this.getSize().width, 0); - } - this.updateBoundaryPages(); + else + { + this._pages[idx] = page; + this.addProtectedChild(page); + } + + this._doLayoutDirty = true; }, /** @@ -216,9 +246,15 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ if (!page) { return; } - this.removeChild(page); - this.updateChildrenPosition(); - this.updateBoundaryPages(); +// this.removeChild(page); +// this.updateChildrenPosition(); +// this.updateBoundaryPages(); + this.removeProtectedChild(page); + var index = this._pages.indexOf(page); + if(index > -1) + this._pages.splice(index, 1); + + this._doLayoutDirty = true; }, /** @@ -235,6 +271,15 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, + removeAllPages: function(){ + for(var p in this._pages) + { + var node = this._pages[p]; + this.removeProtectedChild(node); + } + this._pages = []; + }, + updateBoundaryPages: function () { if (this._pages.length <= 0) { this._leftChild = null; @@ -245,6 +290,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._rightChild = this._pages[this._pages.length-1]; }, + getPageCount: function(){ + return this._pages.length; + }, + /** * Get x position by index * @param {number} idx @@ -254,74 +303,45 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ return (this.getSize().width * (idx - this._curPageIdx)); }, - /** - * Add widget - * @param {ccui.Widget} widget - * @param {Number} zOrder - * @param {Number} tag - * @returns {boolean} - */ - addChild: function (widget, zOrder, tag) { - return ccui.Layout.prototype.addChild.call(this, widget, zOrder, tag); - }, - - /** - * remove widget child override - * @param {ccui.Widget} child - * @param {Boolean} cleanup - */ - removeChild: function (child, cleanup) { - if(cleanup) - cc.arrayRemoveObject(this._pages, child); - ccui.Layout.prototype.removeChild.call(this, child, cleanup); - }, - onSizeChanged: function () { ccui.Layout.prototype.onSizeChanged.call(this); this._rightBoundary = this.getSize().width; - this.updateChildrenSize(); - this.updateChildrenPosition(); +// this.updateChildrenSize(); +// this.updateChildrenPosition(); + this._doLayoutDirty = true; }, - updateChildrenSize: function () { - if(this._pages){ - if (!this._pages.length <= 0) { - return; - } - - var selfSize = this.getSize(); - for (var i = 0; i < this._pages.length; i++) { - var page = this._pages[i]; - page.setSize(selfSize); - } + updateAllPagesSize: function(){ + var selfSize = this.getContentSize(); + for (var p in this._pages) + { + var page = this._pages[p]; + page.setContentSize(selfSize); } + }, - updateChildrenPosition: function () { - if (!this._pages) { - return; - } + updateAllPagesPosition: function(){ + var pageCount = this.getPageCount(); - var pageCount = this._pages.length; - if (pageCount <= 0) { + if (pageCount <= 0) + { this._curPageIdx = 0; return; } - if (this._curPageIdx >= pageCount) { - this._curPageIdx = pageCount - 1; - } - var pageWidth = this.getSize().width; - var arrayPages = this._pages; - for (var i = 0; i < pageCount; i++) { - var page = arrayPages[i]; - page.setPosition((i - this._curPageIdx) * pageWidth, 0); + + if (this._curPageIdx >= pageCount) + { + this._curPageIdx = pageCount-1; } - }, - removeAllChildren: function (cleanup) { - if(cleanup) - this._pages.length = 0; - ccui.Layout.prototype.removeAllChildren.call(this, cleanup); + var pageWidth = this.getContentSize().width; + for (var i=0; i 0 ? 1 : 0; this._isAutoScrolling = true; @@ -342,41 +362,45 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ update: function (dt) { if (this._isAutoScrolling) { - switch (this._autoScrollDir) { - case 0: - var step = this._autoScrollSpeed * dt; - if (this._autoScrollDistance + step >= 0.0) { - step = -this._autoScrollDistance; - this._autoScrollDistance = 0.0; - this._isAutoScrolling = false; - } - else { - this._autoScrollDistance += step; - } - this.scrollPages(-step); - if(!this._isAutoScrolling){ - this.pageTurningEvent(); - } - break; - break; - case 1: - var step = this._autoScrollSpeed * dt; - if (this._autoScrollDistance - step <= 0.0) { - step = this._autoScrollDistance; - this._autoScrollDistance = 0.0; - this._isAutoScrolling = false; - } - else { - this._autoScrollDistance -= step; - } - this.scrollPages(step); - if(!this._isAutoScrolling){ - this.pageTurningEvent(); - } - break; - default: - break; - } + this.autoScroll(dt); + } + }, + + autoScroll: function(dt){ + switch (this._autoScrollDir) { + case 0: + var step = this._autoScrollSpeed * dt; + if (this._autoScrollDistance + step >= 0.0) { + step = -this._autoScrollDistance; + this._autoScrollDistance = 0.0; + this._isAutoScrolling = false; + } + else { + this._autoScrollDistance += step; + } + this.scrollPages(-step); + if(!this._isAutoScrolling){ + this.pageTurningEvent(); + } + break; + break; + case 1: + var step = this._autoScrollSpeed * dt; + if (this._autoScrollDistance - step <= 0.0) { + step = this._autoScrollDistance; + this._autoScrollDistance = 0.0; + this._isAutoScrolling = false; + } + else { + this._autoScrollDistance -= step; + } + this.scrollPages(step); + if(!this._isAutoScrolling){ + this.pageTurningEvent(); + } + break; + default: + break; } }, @@ -389,30 +413,46 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, onTouchMoved: function (touch,event) { - var touchPoint = touch.getLocation(); - this._touchMovePosition.x = touchPoint.x; - this._touchMovePosition.y = touchPoint.y; - this.handleMoveLogic(touchPoint); +// var touchPoint = touch.getLocation(); +// this._touchMovePosition.x = touchPoint.x; +// this._touchMovePosition.y = touchPoint.y; +// this.handleMoveLogic(touchPoint); + this.handleMoveLogic(touch); var widgetParent = this.getWidgetParent(); if (widgetParent) { - widgetParent.checkChildInfo(1, this, touchPoint); + widgetParent.checkChildInfo(1, this, touch); } this.moveEvent(); - if (!this.hitTest(touchPoint)) { - this.setFocused(false); - this.onTouchEnded(touch,event); - } +// if (!this.hitTest(touchPoint)) { +// this.setFocused(false); +// this.onTouchEnded(touch,event); +// } }, onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this.handleReleaseLogic(this._touchEndPosition); + this.handleReleaseLogic(touch); }, onTouchCancelled: function (touch, event) { - var touchPoint = touch.getLocation(); +// var touchPoint = touch.getLocation(); ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); - this.handleReleaseLogic(touchPoint); +// this.handleReleaseLogic(touchPoint); + this.handleReleaseLogic(touch); + }, + + doLayout: function(){ + if (!this._doLayoutDirty) + { + return; + } + + this.updateAllPagesPosition(); + this.updateAllPagesSize(); + this.updateBoundaryPages(); + + + this._doLayoutDirty = false; }, movePages: function (offset) { @@ -461,9 +501,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, handlePressLogic: function (touchPoint) { - var nsp = this.convertToNodeSpace(touchPoint); - this._touchMoveStartLocation = nsp.x; - this._touchStartLocation = nsp.x; +// var nsp = this.convertToNodeSpace(touchPoint); +// this._touchMoveStartLocation = nsp.x; +// this._touchStartLocation = nsp.x; + //np-op }, handleMoveLogic: function (touchPoint) { @@ -510,11 +551,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, - checkChildInfo: function (handleState, sender, touchPoint) { - if(this._enabled && this._touchEnabled) - this.interceptTouchEvent(handleState, sender, touchPoint); - }, - interceptTouchEvent: function (handleState, sender, touchPoint) { switch (handleState) { case 0: @@ -541,6 +577,9 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ if (this._pageViewEventListener && this._pageViewEventSelector) { this._pageViewEventSelector.call(this._pageViewEventListener, this, ccui.PageView.EVENT_TURNING); } + if (this._eventCallback) { + this._eventCallback(this, ccui.PageView.EVENT_TURNING); + } }, /** @@ -552,12 +591,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._pageViewEventListener = target; }, - /** - * get pages - * @returns {Array} - */ - getPages:function(){ - return this._pages; + addEventListener: function(callback){ + this._eventCallback = callback; }, /** @@ -568,6 +603,22 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ return this._curPageIdx; }, + /** + * get pages + * @returns {Array} + */ + getPages:function(){ + return this._pages; + }, + + getPage: function(index){ + if (index < 0 || index >= this.getPages().size()) + { + return null; + } + return this._pages[index]; + }, + /** * Returns the "class name" of widget. * @returns {string} @@ -590,13 +641,84 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ copySpecialProperties: function (pageView) { ccui.Layout.prototype.copySpecialProperties.call(this, pageView); - }, - - _doLayout: function () { - if (!this._doLayoutDirty) - return; - this._doLayoutDirty = false; } + + + + +// /** +// * Add widget +// * @param {ccui.Widget} widget +// * @param {Number} zOrder +// * @param {Number} tag +// * @returns {boolean} +// */ +// addChild: function (widget, zOrder, tag) { +// return ccui.Layout.prototype.addChild.call(this, widget, zOrder, tag); +// }, +// +// /** +// * remove widget child override +// * @param {ccui.Widget} child +// * @param {Boolean} cleanup +// */ +// removeChild: function (child, cleanup) { +// if(cleanup) +// cc.arrayRemoveObject(this._pages, child); +// ccui.Layout.prototype.removeChild.call(this, child, cleanup); +// }, +// +// updateChildrenSize: function () { +// if(this._pages){ +// if (!this._pages.length <= 0) { +// return; +// } +// +// var selfSize = this.getSize(); +// for (var i = 0; i < this._pages.length; i++) { +// var page = this._pages[i]; +// page.setSize(selfSize); +// } +// } +// }, +// +// updateChildrenPosition: function () { +// if (!this._pages) { +// return; +// } +// +// var pageCount = this._pages.length; +// if (pageCount <= 0) { +// this._curPageIdx = 0; +// return; +// } +// if (this._curPageIdx >= pageCount) { +// this._curPageIdx = pageCount - 1; +// } +// var pageWidth = this.getSize().width; +// var arrayPages = this._pages; +// for (var i = 0; i < pageCount; i++) { +// var page = arrayPages[i]; +// page.setPosition((i - this._curPageIdx) * pageWidth, 0); +// } +// }, +// +// removeAllChildren: function (cleanup) { +// if(cleanup) +// this._pages.length = 0; +// ccui.Layout.prototype.removeAllChildren.call(this, cleanup); +// }, +// +// checkChildInfo: function (handleState, sender, touchPoint) { +// if(this._enabled && this._touchEnabled) +// this.interceptTouchEvent(handleState, sender, touchPoint); +// }, +// +// _doLayout: function () { +// if (!this._doLayoutDirty) +// return; +// this._doLayoutDirty = false; +// } }); /** * allocates and initializes a UIPageView. @@ -607,7 +729,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * var uiPageView = ccui.PageView.create(); */ ccui.PageView.create = function () { - return new ccui.PageView(); + var widget = new ccui.PageView(); + if (widget && widget.init()) + { + return widget; + } + return null; }; // Constants From ef100e07ca19213c253c2dd009ee32fa8ae08f68 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 1 Jul 2014 15:59:00 +0800 Subject: [PATCH 0209/1564] Issue #5600: sync ccui.ScrollView --- .../uiwidgets/scroll-widget/UIScrollView.js | 1029 ++++++++--------- 1 file changed, 504 insertions(+), 525 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 2c262ab6d9..026ade7da6 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -37,42 +37,47 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _innerContainer: null, direction: null, - _touchBeganPoint: null, - _touchMovedPoint: null, - _touchEndedPoint: null, - _touchMovingPoint: null, _autoScrollDir: null, + _topBoundary: 0,//test _bottomBoundary: 0,//test _leftBoundary: 0, _rightBoundary: 0, + _bounceTopBoundary: 0, _bounceBottomBoundary: 0, _bounceLeftBoundary: 0, _bounceRightBoundary: 0, + _autoScroll: false, _autoScrollAddUpTime: 0, + _autoScrollOriginalSpeed: 0, _autoScrollAcceleration: 0, _isAutoScrollSpeedAttenuated: false, _needCheckAutoScrollDestination: false, _autoScrollDestination: null, + _bePressed: false, _slidTime: 0, _moveChildPoint: null, _childFocusCancelOffset: 0, + _leftBounceNeeded: false, _topBounceNeeded: false, _rightBounceNeeded: false, _bottomBounceNeeded: false, + bounceEnabled: false, _bouncing: false, _bounceDir: null, _bounceOriginalSpeed: 0, inertiaScrollEnabled: false, + _scrollViewEventListener: null, _scrollViewEventSelector: null, _className: "ScrollView", + _eventCallback: null, /** * allocates and initializes a UIScrollView. * Constructor of ccui.ScrollView @@ -84,10 +89,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ ccui.Layout.prototype.ctor.call(this); this._innerContainer = null; this.direction = ccui.ScrollView.DIR_NONE; - this._touchBeganPoint = cc.p(0, 0); - this._touchMovedPoint = cc.p(0, 0); - this._touchEndedPoint = cc.p(0, 0); - this._touchMovingPoint = cc.p(0, 0); this._autoScrollDir = cc.p(0, 0); this._topBoundary = 0;//test this._bottomBoundary = 0;//test @@ -119,12 +120,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.inertiaScrollEnabled = true; this._scrollViewEventListener = null; this._scrollViewEventSelector = null; - this.init(); }, init: function () { if (ccui.Layout.prototype.init.call(this)) { - this.setTouchEnabled(true); this.setClippingEnabled(true); this._innerContainer.setTouchEnabled(false); return true; @@ -134,18 +133,21 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ onEnter: function () { ccui.Layout.prototype.onEnter.call(this); - this.setUpdateEnabled(true); + this.scheduleUpdate(true); }, - onExit:function(){ - this.setUpdateEnabled(false); - ccui.Layout.prototype.onExit.call(this); + findNextFocusedWidget: function(direction, current){ + if (this.getLayoutType() == ccui.Layout.LINEAR_VERTICAL + || this.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) { + return this._innerContainer.findNextFocusedWidget(direction, current); + } else + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, current); }, initRenderer: function () { ccui.Layout.prototype.initRenderer.call(this); this._innerContainer = ccui.Layout.create(); - ccui.Layout.prototype.addChild.call(this, this._innerContainer); + this.addProtectedChild(this._innerContainer, 1, 1); }, onSizeChanged: function () { @@ -169,9 +171,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Changes inner container size of scrollview.
+ * Changes inner container size of ScrollView.
* Inner container size must be larger than or equal scrollview's size. - * * @param {cc.Size} size inner container size. */ setInnerContainerSize: function (size) { @@ -179,39 +180,37 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var innerSizeWidth = locSize.width; var innerSizeHeight = locSize.height; var originalInnerSize = this._innerContainer.getSize(); - if (size.width < locSize.width) { + if (size.width < locSize.width) cc.log("Inner width <= scrollview width, it will be force sized!"); - } - else { + else innerSizeWidth = size.width; - } - if (size.height < locSize.height) { + + if (size.height < locSize.height) cc.log("Inner height <= scrollview height, it will be force sized!"); - } - else { + else innerSizeHeight = size.height; - } + this._innerContainer.setSize(cc.size(innerSizeWidth, innerSizeHeight)); + var newInnerSize, offset; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: - var newInnerSize = this._innerContainer.getSize(); - var offset = originalInnerSize.height - newInnerSize.height; + newInnerSize = this._innerContainer.getSize(); + offset = originalInnerSize.height - newInnerSize.height; this.scrollChildren(0, offset); break; case ccui.ScrollView.DIR_HORIZONTAL: if (this._innerContainer.getRightBoundary() <= locSize.width) { - var newInnerSize = this._innerContainer.getSize(); - var offset = originalInnerSize.width - newInnerSize.width; + newInnerSize = this._innerContainer.getSize(); + offset = originalInnerSize.width - newInnerSize.width; this.scrollChildren(offset, 0); } break; case ccui.ScrollView.DIR_BOTH: - var newInnerSize = this._innerContainer.getSize(); + newInnerSize = this._innerContainer.getSize(); var offsetY = originalInnerSize.height - newInnerSize.height; var offsetX = 0; - if (this._innerContainer.getRightBoundary() <= locSize.width) { + if (this._innerContainer.getRightBoundary() <= locSize.width) offsetX = originalInnerSize.width - newInnerSize.width; - } this.scrollChildren(offsetX, offsetY); break; default: @@ -221,18 +220,14 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var innerSize = innerContainer.getSize(); var innerPos = innerContainer.getPosition(); var innerAP = innerContainer.getAnchorPoint(); - if (innerContainer.getLeftBoundary() > 0.0) { + if (innerContainer.getLeftBoundary() > 0.0) innerContainer.setPosition(innerAP.x * innerSize.width, innerPos.y); - } - if (innerContainer.getRightBoundary() < locSize.width) { + if (innerContainer.getRightBoundary() < locSize.width) innerContainer.setPosition(locSize.width - ((1.0 - innerAP.x) * innerSize.width), innerPos.y); - } - if (innerPos.y > 0.0) { + if (innerPos.y > 0.0) innerContainer.setPosition(innerPos.x, innerAP.y * innerSize.height); - } - if (innerContainer.getTopBoundary() < locSize.height) { + if (innerContainer.getTopBoundary() < locSize.height) innerContainer.setPosition(innerPos.x, locSize.height - (1.0 - innerAP.y) * innerSize.height); - } }, _setInnerWidth: function (width) { var locW = this._size.width, @@ -291,6 +286,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } }, + /** + * Gets inner container size of ScrollView.
+ * Inner container size must be larger than or equal scrollview's size. + * + * @return inner container size. + */ getInnerContainerSize: function () { return this._innerContainer.getSize(); }, @@ -303,17 +304,25 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Add widget - * @param {ccui.Widget} widget - * @param {Number} zOrder - * @param {Number} tag + * @param {cc.Node} widget + * @param {Number} [zOrder] + * @param {Number} [tag] * @returns {boolean} */ addChild: function (widget, zOrder, tag) { + if(!widget) + return; + zOrder = zOrder || widget.getLocalZOrder(); + tag = tag || widget.getTag(); return this._innerContainer.addChild(widget, zOrder, tag); }, - removeAllChildren: function (cleanup) { - this._innerContainer.removeAllChildren(cleanup); + removeAllChildren: function () { + this.removeAllChildrenWithCleanup(true); + }, + + removeAllChildrenWithCleanup: function(cleanup){ + this._innerContainer.removeAllChildrenWithCleanup(cleanup); }, /** @@ -435,8 +444,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.checkNeedBounce(); } } - } - else { + } else { if (this._needCheckAutoScrollDestination) { var xOffset = this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed; var yOffset = this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed; @@ -446,8 +454,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.stopAutoScrollChildren(); this.checkNeedBounce(); } - } - else { + } else { if (!this.scrollChildren(this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed, this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed)) { this.stopAutoScrollChildren(); this.checkNeedBounce(); @@ -468,56 +475,49 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, checkNeedBounce: function () { - if (!this.bounceEnabled) { + if (!this.bounceEnabled) return false; - } this.checkBounceBoundary(); if (this._topBounceNeeded || this._bottomBounceNeeded || this._leftBounceNeeded || this._rightBounceNeeded) { + var scrollVector, orSpeed; if (this._topBounceNeeded && this._leftBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0.0, this._size.height), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getTopBoundary())); - var orSpeed = cc.pLength(scrollVector) / 0.2; + scrollVector = cc.pSub(cc.p(0.0, this._size.height), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getTopBoundary())); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); - } - else if (this._topBounceNeeded && this._rightBounceNeeded) { - var scrollVector = cc.pSub(cc.p(this._size.width, this._size.height), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getTopBoundary())); - var orSpeed = cc.pLength(scrollVector) / 0.2; + } else if (this._topBounceNeeded && this._rightBounceNeeded) { + scrollVector = cc.pSub(cc.p(this._size.width, this._size.height), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getTopBoundary())); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); - } - else if (this._bottomBounceNeeded && this._leftBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getBottomBoundary())); - var orSpeed = cc.pLength(scrollVector) / 0.2; + } else if (this._bottomBounceNeeded && this._leftBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getBottomBoundary())); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); - } - else if (this._bottomBounceNeeded && this._rightBounceNeeded) { - var scrollVector = cc.pSub(cc.p(this._size.width, 0.0), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getBottomBoundary())); - var orSpeed = cc.pLength(scrollVector) / 0.2; + } else if (this._bottomBounceNeeded && this._rightBounceNeeded) { + scrollVector = cc.pSub(cc.p(this._size.width, 0.0), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getBottomBoundary())); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); - } - else if (this._topBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, this._size.height), cc.p(0.0, this._innerContainer.getTopBoundary())); - var orSpeed = cc.pLength(scrollVector) / 0.2; + } else if (this._topBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, this._size.height), cc.p(0.0, this._innerContainer.getTopBoundary())); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); - } - else if (this._bottomBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, 0), cc.p(0.0, this._innerContainer.getBottomBoundary())); - var orSpeed = cc.pLength(scrollVector) / 0.2; + } else if (this._bottomBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, 0), cc.p(0.0, this._innerContainer.getBottomBoundary())); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); - } - else if (this._leftBounceNeeded) { - var scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), 0.0)); - var orSpeed = cc.pLength(scrollVector) / 0.2; + } else if (this._leftBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), 0.0)); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); - } - else if (this._rightBounceNeeded) { - var scrollVector = cc.pSub(cc.p(this._size.width, 0), cc.p(this._innerContainer.getRightBoundary(), 0.0)); - var orSpeed = cc.pLength(scrollVector) / 0.2; + } else if (this._rightBounceNeeded) { + scrollVector = cc.pSub(cc.p(this._size.width, 0), cc.p(this._innerContainer.getRightBoundary(), 0.0)); + orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } @@ -531,32 +531,28 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (icBottomPos > this._bottomBoundary) { this.scrollToBottomEvent(); this._bottomBounceNeeded = true; - } - else { + } else { this._bottomBounceNeeded = false; } var icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos < this._topBoundary) { this.scrollToTopEvent(); this._topBounceNeeded = true; - } - else { + } else { this._topBounceNeeded = false; } var icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos < this._rightBoundary) { this.scrollToRightEvent(); this._rightBounceNeeded = true; - } - else { + } else { this._rightBounceNeeded = false; } var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos > this._leftBoundary) { this.scrollToLeftEvent(); this._leftBounceNeeded = true; - } - else { + } else { this._leftBounceNeeded = false; } }, @@ -595,8 +591,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (attenuated) { acceleration = -(2 * disLength) / (time * time); orSpeed = 2 * disLength / time; - } - else { + } else { this._needCheckAutoScrollDestination = true; orSpeed = disLength / time; } @@ -612,22 +607,18 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var finalOffsetY = dstY; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: - if (dstY <= 0) { + if (dstY <= 0) finalOffsetY = Math.max(dstY, this._size.height - this._innerContainer.getSize().height); - } break; case ccui.ScrollView.DIR_HORIZONTAL: - if (dstX <= 0) { + if (dstX <= 0) finalOffsetX = Math.max(dstX, this._size.width - this._innerContainer.getSize().width); - } break; case ccui.ScrollView.DIR_BOTH: - if (dstY <= 0) { + if (dstY <= 0) finalOffsetY = Math.max(dstY, this._size.height - this._innerContainer.getSize().height); - } - if (dstX <= 0) { + if (dstX <= 0) finalOffsetX = Math.max(dstX, this._size.width - this._innerContainer.getSize().width); - } break; default: break; @@ -635,7 +626,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._innerContainer.setPosition(finalOffsetX, finalOffsetY); }, - stopAutoScrollChildren: function () { this._autoScroll = false; this._autoScrollOriginalSpeed = 0; @@ -644,93 +634,84 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ bounceScrollChildren: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; - if (touchOffsetX > 0.0 && touchOffsetY > 0.0) //first quadrant //bounce to top-right - { - var realOffsetX = touchOffsetX; - var realOffsetY = touchOffsetY; - var icRightPos = this._innerContainer.getRightBoundary(); + var realOffsetX, realOffsetY, icRightPos, icTopPos, icBottomPos; + if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ //first quadrant //bounce to top-right + realOffsetX = touchOffsetX; + realOffsetY = touchOffsetY; + icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.bounceRightEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.bounceTopEvent(); scrollEnabled = false; } this.moveChildren(realOffsetX, realOffsetY); - } - else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) //second quadrant //bounce to top-left - { - var realOffsetX = touchOffsetX; - var realOffsetY = touchOffsetY; - var icLefrPos = this._innerContainer.getLeftBoundary(); + } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ //second quadrant //bounce to top-left + realOffsetX = touchOffsetX; + realOffsetY = touchOffsetY; + icLefrPos = this._innerContainer.getLeftBoundary(); if (icLefrPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLefrPos; this.bounceLeftEvent(); scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.bounceTopEvent(); scrollEnabled = false; } this.moveChildren(realOffsetX, realOffsetY); - } - else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) //third quadrant //bounce to bottom-left - { - var realOffsetX = touchOffsetX; - var realOffsetY = touchOffsetY; + }else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ //third quadrant //bounce to bottom-left + realOffsetX = touchOffsetX; + realOffsetY = touchOffsetY; var icLefrPos = this._innerContainer.getLeftBoundary(); if (icLefrPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLefrPos; this.bounceLeftEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.bounceBottomEvent(); scrollEnabled = false; } this.moveChildren(realOffsetX, realOffsetY); - } - else if (touchOffsetX > 0.0 && touchOffsetY < 0.0) //forth quadrant //bounce to bottom-right - { - var realOffsetX = touchOffsetX; - var realOffsetY = touchOffsetY; - var icRightPos = this._innerContainer.getRightBoundary(); + } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ //forth quadrant //bounce to bottom-right + realOffsetX = touchOffsetX; + realOffsetY = touchOffsetY; + icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.bounceRightEvent(); scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.bounceBottomEvent(); scrollEnabled = false; } this.moveChildren(realOffsetX, realOffsetY); - } - else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // bounce to top - { - var realOffsetY = touchOffsetY; - var icTopPos = this._innerContainer.getTopBoundary(); + } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // bounce to top + realOffsetY = touchOffsetY; + icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this.bounceTopEvent(); scrollEnabled = false; } this.moveChildren(0.0, realOffsetY); - } - else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) //bounce to bottom - { - var realOffsetY = touchOffsetY; - var icBottomPos = this._innerContainer.getBottomBoundary(); + } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) {//bounce to bottom + + realOffsetY = touchOffsetY; + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this.bounceBottomEvent(); @@ -740,18 +721,17 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0) //bounce to right { - var realOffsetX = touchOffsetX; - var icRightPos = this._innerContainer.getRightBoundary(); + realOffsetX = touchOffsetX; + icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this.bounceRightEvent(); scrollEnabled = false; } this.moveChildren(realOffsetX, 0.0); - } - else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) //bounce to left - { - var realOffsetX = touchOffsetX; + }else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ //bounce to left + + realOffsetX = touchOffsetX; var icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; @@ -765,17 +745,17 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ checkCustomScrollDestination: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; + var icBottomPos, icLeftPos, icRightPos, icTopPos; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical if (this._autoScrollDir.y > 0) { - var icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; } - } - else { - var icBottomPos = this._innerContainer.getBottomBoundary(); + } else { + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; @@ -784,14 +764,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; case ccui.ScrollView.DIR_HORIZONTAL: // horizontal if (this._autoScrollDir.x > 0) { - var icLeftPos = this._innerContainer.getLeftBoundary(); + icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; } - } - else { - var icLeftPos = this._innerContainer.getLeftBoundary(); + } else { + icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; @@ -799,85 +778,70 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } break; case ccui.ScrollView.DIR_BOTH: - if (touchOffsetX > 0.0 && touchOffsetY > 0.0) // up right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); + if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ // up right + icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; } - } - else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) // up left - { - var icRightPos = this._innerContainer.getRightBoundary(); + } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ // up left + icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icRightPos; scrollEnabled = false; } - var icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; } - } - else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) // down left - { - var icRightPos = this._innerContainer.getRightBoundary(); + } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ // down left + icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icRightPos; scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icTopPos; scrollEnabled = false; } - } - else if (touchOffsetX > 0.0 && touchOffsetY < 0.0) // down right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); + } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right + icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; } - var icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icTopPos; scrollEnabled = false; } - } - else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // up - { - var icBottomPos = this._innerContainer.getBottomBoundary(); + } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up + icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icBottomPos; scrollEnabled = false; } - } - else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) // left - { - var icRightPos = this._innerContainer.getRightBoundary(); + } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left + icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icRightPos; scrollEnabled = false; } - } - else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) // down - { - var icTopPos = this._innerContainer.getTopBoundary(); + } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down + icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { touchOffsetY = this._autoScrollDestination.y - icTopPos; scrollEnabled = false; } - } - else if (touchOffsetX > 0.0 && touchOffsetY == 0.0) // right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); + } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right + icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { touchOffsetX = this._autoScrollDestination.x - icLeftPos; scrollEnabled = false; @@ -890,7 +854,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return scrollEnabled; }, - getCurAutoScrollDistance: function (dt) { this._autoScrollOriginalSpeed -= this._autoScrollAcceleration * dt; return this._autoScrollOriginalSpeed * dt; @@ -899,271 +862,15 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollChildren: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; this.scrollingEvent(); - switch (this.direction) { + switch (this._direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical - var realOffset = touchOffsetY; - if (this.bounceEnabled) { - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { - realOffset = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { - realOffset = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - else { - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bottomBoundary) { - realOffset = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._topBoundary) { - realOffset = this._topBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - this.moveChildren(0.0, realOffset); + scrollEnabled = this.scrollChildrenVertical(touchOffsetX, touchOffsetY); break; case ccui.ScrollView.DIR_HORIZONTAL: // horizontal - var realOffset = touchOffsetX; - if (this.bounceEnabled) { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { - realOffset = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { - realOffset = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - } - else { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._rightBoundary) { - realOffset = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._leftBoundary) { - realOffset = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - } - this.moveChildren(realOffset, 0.0); + scrollEnabled = this.scrollChildrenHorizontal(touchOffsetX, touchOffsetY); break; case ccui.ScrollView.DIR_BOTH: - var realOffsetX = touchOffsetX; - var realOffsetY = touchOffsetY; - if (this.bounceEnabled) { - if (touchOffsetX > 0.0 && touchOffsetY > 0.0) // up right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { - realOffsetX = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { - realOffsetY = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) // up left - { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { - realOffsetX = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { - realOffsetY = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) // down left - { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { - realOffsetX = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { - realOffsetY = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX > 0.0 && touchOffsetY < 0.0) // down right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { - realOffsetX = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { - realOffsetY = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // up - { - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { - realOffsetY = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) // left - { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { - realOffsetX = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) // down - { - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { - realOffsetY = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX > 0.0 && touchOffsetY == 0.0) // right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { - realOffsetX = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - } - } - else { - if (touchOffsetX > 0.0 && touchOffsetY > 0.0) // up right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._leftBoundary) { - realOffsetX = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bottomBoundary) { - realOffsetY = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) // up left - { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._rightBoundary) { - realOffsetX = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bottomBoundary) { - realOffsetY = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX < 0 && touchOffsetY < 0) // down left - { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._rightBoundary) { - realOffsetX = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._topBoundary) { - realOffsetY = this._topBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX > 0 && touchOffsetY < 0) // down right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._leftBoundary) { - realOffsetX = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._topBoundary) { - realOffsetY = this._topBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) // up - { - var icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._bottomBoundary) { - realOffsetY = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX < 0.0 && touchOffsetY == 0.0) // left - { - var icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._rightBoundary) { - realOffsetX = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX == 0.0 && touchOffsetY < 0) // down - { - var icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._topBoundary) { - realOffsetY = this._topBoundary - icTopPos; - this.scrollToTopEvent(); - scrollEnabled = false; - } - } - else if (touchOffsetX > 0 && touchOffsetY == 0) // right - { - var icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._leftBoundary) { - realOffsetX = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); - scrollEnabled = false; - } - } - } - this.moveChildren(realOffsetX, realOffsetY); + scrollEnabled = this.scrollChildrenBoth(touchOffsetX, touchOffsetY); break; default: break; @@ -1171,8 +878,263 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return scrollEnabled; }, + scrollChildrenVertical: function(touchOffsetX, touchOffsetY){ + var realOffset = touchOffsetY; + var scrollEnabled = false; + var icBottomPos, icTopPos; + if (this.bounceEnabled) { + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { + realOffset = this._bounceBottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { + realOffset = this._bounceTopBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + + } + } else { + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bottomBoundary){ + realOffset = this._bottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._topBoundary) { + realOffset = this._topBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + } + } + this.moveChildren(0.0, realOffset); + return scrollEnabled; + }, + + scrollChildrenHorizontal: function(touchOffsetX, touchOffestY){ + var scrollEnabled; + var realOffset = touchOffsetX; + var icRightPos, icLeftPos; + if (this.bounceEnabled){ + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._bounceRightBoundary) + { + realOffset = this._bounceRightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) + { + realOffset = this._bounceLeftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + } else { + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._rightBoundary) { + realOffset = this._rightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._leftBoundary) + { + realOffset = this._leftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + } + this.moveChildren(realOffset, 0.0); + return scrollEnabled; + }, + + scrollChildrenBoth: function (touchOffsetX, touchOffsetY) { + var scrollEnabled = false; + var realOffsetX = touchOffsetX; + var realOffsetY = touchOffsetY; + var icLeftPos, icBottomPos, icRightPos, icTopPos; + if (this.bounceEnabled) { + if (touchOffsetX > 0.0 && touchOffsetY > 0.0) { // up right + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { + realOffsetX = this._bounceLeftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { + realOffsetY = this._bounceBottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) { // up left + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { + realOffsetX = this._bounceRightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { + realOffsetY = this._bounceBottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) { // down left + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { + realOffsetX = this._bounceRightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { + realOffsetY = this._bounceTopBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { + realOffsetX = this._bounceLeftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { + realOffsetY = this._bounceTopBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { + realOffsetY = this._bounceBottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { + realOffsetX = this._bounceRightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { + realOffsetY = this._bounceTopBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { + realOffsetX = this._bounceLeftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + } + } else { + if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ // up right + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._leftBoundary) { + realOffsetX = this._leftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bottomBoundary) { + realOffsetY = this._bottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ // up left + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._rightBoundary) { + realOffsetX = this._rightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bottomBoundary) { + realOffsetY = this._bottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ // down left + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._rightBoundary) { + realOffsetX = this._rightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._topBoundary) { + realOffsetY = this._topBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._leftBoundary) { + realOffsetX = this._leftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._topBoundary) { + realOffsetY = this._topBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) { // up + icBottomPos = this._innerContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= this._bottomBoundary) { + realOffsetY = this._bottomBoundary - icBottomPos; + this.scrollToBottomEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left + icRightPos = this._innerContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._rightBoundary) { + realOffsetX = this._rightBoundary - icRightPos; + this.scrollToRightEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down + icTopPos = this._innerContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= this._topBoundary) { + realOffsetY = this._topBoundary - icTopPos; + this.scrollToTopEvent(); + scrollEnabled = false; + } + } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right + icLeftPos = this._innerContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._leftBoundary) { + realOffsetX = this._leftBoundary - icLeftPos; + this.scrollToLeftEvent(); + scrollEnabled = false; + } + } + } + this.moveChildren(realOffsetX, realOffsetY); + return scrollEnabled; + }, + /** - * Scroll inner container to bottom boundary of scrollview. + * Scroll inner container to bottom boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1181,7 +1143,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to top boundary of scrollview. + * Scroll inner container to top boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1190,7 +1152,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to left boundary of scrollview. + * Scroll inner container to left boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1199,7 +1161,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to right boundary of scrollview. + * Scroll inner container to right boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1208,7 +1170,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to top and left boundary of scrollview. + * Scroll inner container to top and left boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1221,7 +1183,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to top and right boundary of scrollview. + * Scroll inner container to top and right boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1234,7 +1196,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to bottom and left boundary of scrollview. + * Scroll inner container to bottom and left boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1247,7 +1209,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to bottom and right boundary of scrollview. + * Scroll inner container to bottom and right boundary of ScrollView. * @param {Number} time * @param {Boolean} attenuated */ @@ -1260,7 +1222,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to vertical percent position of scrollview. + * Scroll inner container to vertical percent position of ScrollView. * @param {Number} percent * @param {Number} time * @param {Boolean} attenuated @@ -1272,7 +1234,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to horizontal percent position of scrollview. + * Scroll inner container to horizontal percent position of ScrollView. * @param {Number} percent * @param {Number} time * @param {Boolean} attenuated @@ -1283,15 +1245,14 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Scroll inner container to both direction percent position of scrollview. - * @param {Number} percent + * Scroll inner container to both direction percent position of ScrollView. + * @param {cc.Point} percent * @param {Number} time * @param {Boolean} attenuated */ scrollToPercentBothDirection: function (percent, time, attenuated) { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction != ccui.ScrollView.DIR_BOTH) return; - } var minY = this._size.height - this._innerContainer.getSize().height; var h = -minY; var w = this._innerContainer.getSize().width - this._size.width; @@ -1299,35 +1260,35 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Move inner container to bottom boundary of scrollview. + * Move inner container to bottom boundary of ScrollView. */ jumpToBottom: function () { this.jumpToDestination(this._innerContainer.getPositionX(), 0); }, /** - * Move inner container to top boundary of scrollview. + * Move inner container to top boundary of ScrollView. */ jumpToTop: function () { this.jumpToDestination(this._innerContainer.getPositionX(), this._size.height - this._innerContainer.getSize().height); }, /** - * Move inner container to left boundary of scrollview. + * Move inner container to left boundary of ScrollView. */ jumpToLeft: function () { this.jumpToDestination(0, this._innerContainer.getPositionY()); }, /** - * Move inner container to right boundary of scrollview. + * Move inner container to right boundary of ScrollView. */ jumpToRight: function () { this.jumpToDestination(this._size.width - this._innerContainer.getSize().width, this._innerContainer.getPositionY()); }, /** - * Move inner container to top and left boundary of scrollview. + * Move inner container to top and left boundary of ScrollView. */ jumpToTopLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1338,7 +1299,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Move inner container to top and right boundary of scrollview. + * Move inner container to top and right boundary of ScrollView. */ jumpToTopRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1349,7 +1310,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Move inner container to bottom and left boundary of scrollview. + * Move inner container to bottom and left boundary of ScrollView. */ jumpToBottomLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1360,7 +1321,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Move inner container to bottom and right boundary of scrollview. + * Move inner container to bottom and right boundary of ScrollView. */ jumpToBottomRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1371,7 +1332,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Move inner container to vertical percent position of scrollview. + * Move inner container to vertical percent position of ScrollView. */ jumpToPercentVertical: function (percent) { var minY = this._size.height - this._innerContainer.getSize().height; @@ -1380,7 +1341,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Move inner container to horizontal percent position of scrollview. + * Move inner container to horizontal percent position of ScrollView. */ jumpToPercentHorizontal: function (percent) { var w = this._innerContainer.getSize().width - this._size.width; @@ -1388,12 +1349,11 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Move inner container to both direction percent position of scrollview. + * Move inner container to both direction percent position of ScrollView. */ jumpToPercentBothDirection: function (percent) { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction != ccui.ScrollView.DIR_BOTH) return; - } var minY = this._size.height - this._innerContainer.getSize().height; var h = -minY; var w = this._innerContainer.getSize().width - this._size.width; @@ -1401,43 +1361,30 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, startRecordSlidAction: function () { - if (this._autoScroll) { + if (this._autoScroll) this.stopAutoScrollChildren(); - } - if (this._bouncing) { + if (this._bouncing) this.stopBounceChildren(); - } this._slidTime = 0.0; }, endRecordSlidAction: function () { if (!this.checkNeedBounce() && this.inertiaScrollEnabled) { - if (this._slidTime <= 0.016) { + if (this._slidTime <= 0.016) return; - } var totalDis = 0; var dir; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL : - totalDis = this._touchEndedPoint.y - this._touchBeganPoint.y; - if (totalDis < 0) { - dir = ccui.ScrollView.SCROLLDIR_DOWN; - } - else { - dir = ccui.ScrollView.SCROLLDIR_UP; - } + totalDis = this._touchEndPosition.y - this._touchBeganPosition.y; + dir = (totalDis < 0) ? ccui.ScrollView.SCROLLDIR_DOWN : ccui.ScrollView.SCROLLDIR_UP; break; case ccui.ScrollView.DIR_HORIZONTAL: - totalDis = this._touchEndedPoint.x - this._touchBeganPoint.x; - if (totalDis < 0) { - dir = ccui.ScrollView.SCROLLDIR_LEFT; - } - else { - dir = ccui.ScrollView.SCROLLDIR_RIGHT; - } + totalDis = this._touchEndPosition.x - this._touchBeganPosition.x; + dir = totalDis < 0 ? ccui.ScrollView.SCROLLDIR_LEFT : ccui.ScrollView.SCROLLDIR_RIGHT; break; case ccui.ScrollView.DIR_BOTH : - var subVector = cc.pSub(this._touchEndedPoint, this._touchBeganPoint); + var subVector = cc.pSub(this._touchEndPosition, this._touchBeganPosition); totalDis = cc.pLength(subVector); dir = cc.pNormalize(subVector); break; @@ -1450,17 +1397,18 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } }, - handlePressLogic: function (touchPoint) { - this._touchBeganPoint = this.convertToNodeSpace(touchPoint); - this._touchMovingPoint = this._touchBeganPoint; + handlePressLogic: function (touch) { +/* this._touchBeganPosition = this.convertToNodeSpace(touchPoint); + this._touchMovingPoint = this._touchBeganPosition;*/ this.startRecordSlidAction(); this._bePressed = true; }, - handleMoveLogic: function (touchPoint) { - this._touchMovedPoint = this.convertToNodeSpace(touchPoint); - var delta = cc.pSub(this._touchMovedPoint, this._touchMovingPoint); - this._touchMovingPoint = this._touchMovedPoint; + handleMoveLogic: function (touch) { +/* this._touchMovePosition = this.convertToNodeSpace(touchPoint); + var delta = cc.pSub(this._touchMovePosition, this._touchMovingPoint); + this._touchMovingPoint = this._touchMovePosition;*/ + var delta = cc.pSub(touch.getLocation(), touch.getPreviousLocation()); switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical this.scrollChildren(0.0, delta.y); @@ -1476,28 +1424,26 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } }, - handleReleaseLogic: function (touchPoint) { - this._touchEndedPoint = this.convertToNodeSpace(touchPoint); + handleReleaseLogic: function (touch) { this.endRecordSlidAction(); this._bePressed = false; }, onTouchBegan: function (touch, event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); - if (this._hitted) { + if (this._hitted) this.handlePressLogic(this._touchBeganPosition); - } return pass; }, onTouchMoved: function (touch, event) { ccui.Layout.prototype.onTouchMoved.call(this, touch, event); - this.handleMoveLogic(this._touchMovePosition); + this.handleMoveLogic(touch); }, onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this.handleReleaseLogic(this._touchEndPosition); + this.handleReleaseLogic(touch); }, onTouchCancelled: function (touch, event) { @@ -1509,19 +1455,16 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, update: function (dt) { - if (this._autoScroll) { + if (this._autoScroll) this.autoScrollChildren(dt); - } - if (this._bouncing) { + if (this._bouncing) this.bounceChildren(dt); - } this.recordSlidTime(dt); }, recordSlidTime: function (dt) { - if (this._bePressed) { + if (this._bePressed) this._slidTime += dt; - } }, /** @@ -1563,57 +1506,80 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, scrollToTopEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); - } + if (this._eventCallback) + this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_TOP); }, scrollToBottomEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); - } + if (this._eventCallback) + this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); }, scrollToLeftEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) { this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT); } + if (this._eventCallback) { + this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT); + } }, scrollToRightEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) { this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); } + if (this._eventCallback) { + this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); + } }, scrollingEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) { this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLLING); } + if (this._eventCallback) { + this._eventCallback(this,ccui.ScrollView.EVENT_SCROLLING); + } }, bounceTopEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) { this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_TOP); } + if (this._eventCallback) { + this._eventCallback(this,ccui.ScrollView.EVENT_BOUNCE_TOP); + } }, bounceBottomEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) { this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM); } + if (this._eventCallback) { + this._eventCallback(this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM); + } }, bounceLeftEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) { this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_LEFT); } + if (this._eventCallback) { + this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_LEFT); + } }, bounceRightEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) { this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); } + if (this._eventCallback) { + this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); + } }, /** @@ -1625,8 +1591,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._scrollViewEventListener = target; }, + addEventListener: function(callback){ + this._eventCallback = callback; + }, + /** - * Changes scroll direction of scrollview. + * Changes scroll direction of ScrollView. * @param {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} dir */ setDirection: function (dir) { @@ -1634,7 +1604,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Gets scroll direction of scrollview. + * Gets scroll direction of ScrollView. * @returns {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} */ getDirection: function () { @@ -1674,7 +1644,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Gets inner container of scrollview. Inner container is the container of scrollview's children. + * Gets inner container of ScrollView. Inner container is the container .of ScrollView's children. * @returns {ccui.Layout} */ getInnerContainer: function () { @@ -1711,16 +1681,25 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return "ScrollView"; }, + createCloneInstance: function(){ + return ccui.ScrollView.create(); + }, + copyClonedWidgetChildren: function (model) { ccui.Layout.prototype.copyClonedWidgetChildren.call(this, model); }, copySpecialProperties: function (scrollView) { - ccui.Layout.prototype.copySpecialProperties.call(this, scrollView); - this.setInnerContainerSize(scrollView.getInnerContainerSize()); - this.setDirection(scrollView.direction); - this.setBounceEnabled(scrollView.bounceEnabled); - this.setInertiaScrollEnabled(scrollView.inertiaScrollEnabled); + if(scrollView instanceof ccui.ScrollView) { + ccui.Layout.prototype.copySpecialProperties.call(this, scrollView); + this.setInnerContainerSize(scrollView.getInnerContainerSize()); + this.setDirection(scrollView.direction); + this.setBounceEnabled(scrollView.bounceEnabled); + this.setInertiaScrollEnabled(scrollView.inertiaScrollEnabled); + this._scrollViewEventListener = scrollView._scrollViewEventListener; + this._scrollViewEventSelector = scrollView._scrollViewEventSelector; + this._eventCallback = scrollView._eventCallback; + } } }); From 1c3748f87b3bfd146e23d3427733f5fe0ce9f30d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 1 Jul 2014 16:16:58 +0800 Subject: [PATCH 0210/1564] Issue #5600: Fixed a bug about UI position --- extensions/ccui/uiwidgets/UIText.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index d0e0814629..a298a4fe96 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -141,18 +141,12 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ setFontSize: function (size) { this._fontSize = size; this._labelRenderer.setFontSize(size); - this.labelScaleChangedWithSize(); -// if (this._type == ccui.Text.Type.SYSTEM) { -// this._labelRenderer.setSystemFontSize(size); -// } -// else{ -// var config = this._labelRenderer.getTTFConfig(); -// config.fontSize = size; -// this._labelRenderer.setTTFConfig(config); -// } +// this.labelScaleChangedWithSize(); +// var config = this._labelRenderer.getTTFConfig(); +// config.fontSize = size; // this._fontSize = size; -// this.updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); -// this._labelRendererAdaptDirty = true; + this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._labelRendererAdaptDirty = true; }, /** @@ -170,7 +164,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ setFontName: function (name) { this._fontName = name; this._labelRenderer.setFontName(name); - this.labelScaleChangedWithSize(); +// this.labelScaleChangedWithSize(); // if(FileUtils::getInstance()->isFileExist(name)) // { // TTFConfig config = _labelRenderer->getTTFConfig(); @@ -184,8 +178,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ // _type = Type::SYSTEM; // } // _fontName = name; -// updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); -// _labelRendererAdaptDirty = true; + this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); + this._labelRendererAdaptDirty = true; }, /** From 6ca856bb0201980d5b9d5240592b56f2bb6334f7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 1 Jul 2014 17:26:06 +0800 Subject: [PATCH 0211/1564] Issue #5600: correct some mistakes of Cocos GUI --- extensions/ccui/base-classes/UIWidget.js | 2 +- extensions/ccui/layouts/UILayout.js | 11 +++++--- extensions/ccui/uiwidgets/UIRichText.js | 5 +--- extensions/ccui/uiwidgets/UITextAtlas.js | 3 +-- extensions/ccui/uiwidgets/UITextBMFont.js | 26 ++++++++---------- .../uiwidgets/scroll-widget/UIListView.js | 27 ++++++------------- .../uiwidgets/scroll-widget/UIScrollView.js | 3 +-- 7 files changed, 30 insertions(+), 47 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index eb2332f18a..de72a66901 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1059,7 +1059,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (clippingParent) { if (clippingParent.hitTest(pt)) - return clippingParent.clippingParentAreaContainPoint(pt); + return clippingParent.isClippingParentContainsPoint(pt); return false; } return true; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 1d14ca499d..ea19c6788f 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -94,17 +94,20 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * var uiLayout = new ccui.Layout(); */ ctor: function () { + this._layoutType = ccui.Layout.ABSOLUTE; + this._widgetType = ccui.Widget.TYPE_CONTAINER; + this._clippingType = ccui.Layout.CLIPPING_STENCIL; + this._colorType = ccui.Layout.BG_COLOR_NONE; + ccui.Widget.prototype.ctor.call(this); this._backGroundImageCapInsets = cc.rect(0, 0, 0, 0); - this._colorType = ccui.Layout.BG_COLOR_NONE; + this._color = cc.color(255, 255, 255, 255); this._startColor = cc.color(255, 255, 255, 255); this._endColor = cc.color(255, 255, 255, 255); this._alongVector = cc.p(0, -1); this._backGroundImageTextureSize = cc.size(0, 0); - this._layoutType = ccui.Layout.ABSOLUTE; - this._widgetType = ccui.Widget.TYPE_CONTAINER; - this._clippingType = ccui.Layout.CLIPPING_STENCIL; + this._clippingRect = cc.rect(0, 0, 0, 0); this._backGroundImageColor = cc.color(255, 255, 255, 255); }, diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index f890ea5081..7f1d3fea82 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -180,9 +180,6 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._elementRenders = []; this._leftSpaceWidth = 0; this._verticalSpace = 0; - this._elementRenderersContainer = null; - - this.init(); }, initRenderer: function () { @@ -294,7 +291,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ if (leftLength > 0) { var leftRenderer = cc.LabelTTF.create(leftWords.substr(0, leftLength), fontName, fontSize); leftRenderer.setColor(color); - leftRenderer.setColor(color.a); + leftRenderer.setOpacity(color.a); this.pushToContainer(leftRenderer); } diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 92781d15b6..0f8251de75 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -82,8 +82,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ // this.labelAtlasScaleChangedWithSize(); // }, this); // } - this._labelAtlasRenderer.setCharMap(this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); - this._labelAtlasRenderer.setString(stringValue); + this._labelAtlasRenderer.initWithString(stringValue, this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 00ca29f735..8aaa59092a 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -51,7 +51,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo initRenderer: function () { // this._labelBMFontRenderer = cc.LabelBMFont.create(); // cc.Node.prototype.addChild.call(this, this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); - this._labelBMFontRenderer = cc.Label.create(); + this._labelBMFontRenderer = cc.LabelBMFont.create(); this.addProtectedChild(this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); }, @@ -64,18 +64,15 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return; } this._fntFileName = fileName; -// this._labelBMFontRenderer.initWithString("", fileName); -// this.updateAnchorPoint(); -// this.labelBMFontScaleChangedWithSize(); -// this._fileHasInit = true; -// this.setString(this._stringValue); -// -// if (!this._labelBMFontRenderer.textureLoaded()) { -// this._labelBMFontRenderer.addLoadedEventListener(function () { -// this.labelBMFontScaleChangedWithSize(); -// }, this); -// } - this._labelBMFontRenderer.setBMFontFilePath(fileName); + this._labelBMFontRenderer.initWithString("", fileName); + this.updateAnchorPoint(); + this.labelBMFontScaleChangedWithSize(); + + if (!this._labelBMFontRenderer.textureLoaded()) { + this._labelBMFontRenderer.addLoadedEventListener(function () { + this.labelBMFontScaleChangedWithSize(); + }, this); + } this._labelBMFontRenderer.setColor(this.getColor()); this._labelBMFontRenderer.setOpacity(this.getOpacity()); @@ -127,8 +124,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo }, adaptRenderers: function(){ - if (this._labelBMFontRendererAdaptDirty) - { + if (this._labelBMFontRendererAdaptDirty){ this.labelBMFontScaleChangedWithSize(); this._labelBMFontRendererAdaptDirty = false; } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 93b08e1edc..76d71f4d4d 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -56,7 +56,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._curSelectedIndex = 0; this._refreshViewDirty = true; - this.init(); + //this.init(); }, init: function () { @@ -256,18 +256,12 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._refreshViewDirty = true; }, - addChild: function(widget, zOrder, tag){ - if(widget){ - if(zOrder && tag){ - ccui.ScrollView.prototype.addChild.call(this, widget, zOrder, tag); - - if (widget) - { - this._items.push(widget); - } - }else{ - ccui.ListView.prototype.addChild.call(this, widget, zOrder || widget.getLocalZOrder(), widget.getName()); - } + addChild: function (widget, zOrder, tag) { + if (widget) { + zOrder = zOrder || widget.getLocalZOrder(); + tag = tag || widget.getTag(); + ccui.ScrollView.prototype.addChild.call(this, widget, zOrder, tag); + this._items.push(widget); } }, @@ -556,12 +550,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * var uiPageView = ccui.ListView.create(); */ ccui.ListView.create = function () { - var widget = new ccui.ListView(); - if (widget && widget.init()) - { - return widget; - } - return null; + return new ccui.ListView(); }; // Constants diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 026ade7da6..3e3b9cc80f 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -87,7 +87,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ ctor: function () { ccui.Layout.prototype.ctor.call(this); - this._innerContainer = null; this.direction = ccui.ScrollView.DIR_NONE; this._autoScrollDir = cc.p(0, 0); this._topBoundary = 0;//test @@ -311,7 +310,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ addChild: function (widget, zOrder, tag) { if(!widget) - return; + return false; zOrder = zOrder || widget.getLocalZOrder(); tag = tag || widget.getTag(); return this._innerContainer.addChild(widget, zOrder, tag); From 6d81c90997a5019867b6af1bec0dd6387f486605 Mon Sep 17 00:00:00 2001 From: akira_cn Date: Tue, 1 Jul 2014 17:42:38 +0800 Subject: [PATCH 0212/1564] fixed scrollView bugs on paused --- extensions/gui/scrollview/CCScrollView.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index dce7bfce37..7ae65761a4 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -302,6 +302,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ for (var i = 0; i < selChildren.length; i++) { selChildren[i].pause(); } + this._super(); }, /** @@ -313,6 +314,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ selChildren[i].resume(); } this._container.resume(); + this._super(); }, isDragging:function () { From 760cc613a47b345b41f5c69dc19b3fe366189fad Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 1 Jul 2014 17:47:36 +0800 Subject: [PATCH 0213/1564] Issue #5600: UICheckbox position error --- extensions/ccui/base-classes/UIWidget.js | 2 +- extensions/ccui/uiwidgets/UICheckBox.js | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index de72a66901..7f51a280dd 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -690,7 +690,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {boolean} focus pass true to let the widget get focus or pass false to let the widget lose focus */ setFocused: function (focus) { - this._focus = focus; + this._focused = focus; //make sure there is only one focusedWidget if (focus) { this._focusedWidget = this; diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 6efdb77252..a974d1b444 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -91,6 +91,16 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this.addProtectedChild(this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1); this.addProtectedChild(this._backGroundBoxDisabledRenderer, ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER, -1); this.addProtectedChild(this._frontCrossDisabledRenderer, ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER, -1); + + window.test = [ + this._backGroundBoxRenderer, + this._backGroundSelectedBoxRenderer, + this._frontCrossRenderer, + this._backGroundBoxDisabledRenderer, + this._frontCrossDisabledRenderer + ]; + + window.a = this; }, /** @@ -267,7 +277,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var touchPoint = touch.getLocation(); this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; - if (this._focus) { + if (this._focused) { this.releaseUpEvent(); if (this._isSelected) { this.setSelectedState(false); @@ -335,7 +345,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, releaseUpEvent: function(){ - cc.Widget.prototype.releaseUpEvent.call(this); + ccui.Widget.prototype.releaseUpEvent.call(this); if (this._isSelected){ this.setSelectedState(false); @@ -464,7 +474,14 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundBoxRenderer.setScaleX(scaleX); this._backGroundBoxRenderer.setScaleY(scaleY); } - this._backGroundBoxRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); + + var x = this._contentSize.width / 2; + var y = this._contentSize.height / 2; + this._backGroundBoxRenderer.setPosition(x, y); + this._backGroundSelectedBoxRenderer.setPosition(x, y); + this._frontCrossRenderer.setPosition(x, y); + this._backGroundBoxDisabledRenderer.setPosition(x, y); + this._frontCrossDisabledRenderer.setPosition(x, y); }, backGroundSelectedTextureScaleChangedWithSize: function () { From c58e1602295f527b898915c9b9cce74abdcca7ff Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 1 Jul 2014 18:07:05 +0800 Subject: [PATCH 0214/1564] Issue #5600: Fixed a bug about setColor --- extensions/ccui/base-classes/UIWidget.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 7f51a280dd..cdb40ac719 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1497,19 +1497,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ getActionTag: function () { return this._actionTag; }, - /** - * Set color - * @param {cc.Color} color - */ - setColor: function (color) { - this._color.r = color.r; - this._color.g = color.g; - this._color.b = color.b; - this.updateTextureColor(); - if (color.a !== undefined && !color.a_undefined) { - this.setOpacity(color.a); - } - }, /** * Get color @@ -1538,10 +1525,6 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ return this._displayedOpacity; }, - updateTextureColor: function () { - - }, - updateTextureOpacity: function (opacity) { for(var p in this._children){ var item = this._children[p]; From 387f71e16f60e6efe2216a01ad85a455b1d5d895 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 1 Jul 2014 18:17:05 +0800 Subject: [PATCH 0215/1564] Issue #5600: correct a mistake of ccui.UICheckBox --- extensions/ccui/base-classes/UIWidget.js | 7 +++++-- extensions/ccui/uiwidgets/UICheckBox.js | 22 ---------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 7f51a280dd..c754ec938c 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -121,6 +121,9 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._layoutParameterDictionary = {}; this.initRenderer(); this.setBright(true); + + this.onFocusChanged = this.onFocusChange.bind(this); + this.ignoreContentAdaptWithSize(true); this.setAnchorPoint(cc.p(0.5, 0.5)); this.setTouchEnabled(true); @@ -833,10 +836,10 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ widgetLostFocus = this._focusedWidget; if (widgetGetFocus != widgetLostFocus){ - if (widgetGetFocus) + if (widgetGetFocus && widgetGetFocus.onFocusChanged) widgetGetFocus.onFocusChanged(widgetLostFocus, widgetGetFocus); - if (widgetLostFocus) + if (widgetLostFocus && widgetGetFocus.onFocusChanged) widgetLostFocus.onFocusChanged(widgetLostFocus, widgetGetFocus); cc.eventManager.dispatchEvent(new cc.EventFocus(widgetLostFocus, widgetGetFocus)); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index a974d1b444..ce18ab6be5 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -273,28 +273,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledRendererAdaptDirty = true; }, - onTouchEnded: function (touch, event) { - var touchPoint = touch.getLocation(); - this._touchEndPosition.x = touchPoint.x; - this._touchEndPosition.y = touchPoint.y; - if (this._focused) { - this.releaseUpEvent(); - if (this._isSelected) { - this.setSelectedState(false); - this.unSelectedEvent(); - } - else { - this.setSelectedState(true); - this.selectedEvent(); - } - } - this.setFocused(false); - var widgetParent = this.getWidgetParent(); - if (widgetParent) { - widgetParent.checkChildInfo(2, this, touchPoint); - } - }, - onPressStateChangedToNormal: function () { this._backGroundBoxRenderer.setVisible(true); this._backGroundSelectedBoxRenderer.setVisible(false); From 624cb28a071f9044ab61450b09308711e992dda0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 1 Jul 2014 21:06:56 +0800 Subject: [PATCH 0216/1564] Issue #5600: Fixed a bug about UISlider --- extensions/ccui/uiwidgets/UISlider.js | 51 ++++++--------------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index f756f69fce..8a50fa04f2 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -76,7 +76,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ init: function () { if (ccui.Widget.prototype.init.call(this)) { -// this.setTouchEnabled(true); return true; } return false; @@ -115,7 +114,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var barRenderer = this._barRenderer; switch (this._barTexType) { case ccui.Widget.LOCAL_TEXTURE: -// barRenderer.initWithFile(fileName); if (this._scale9Enabled) { barRenderer.initWithFile(fileName); @@ -126,7 +124,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } break; case ccui.Widget.PLIST_TEXTURE: -// barRenderer.initWithSpriteFrameName(fileName); if (this._scale9Enabled) { barRenderer.initWithSpriteFrameName(fileName); @@ -140,18 +137,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ default: break; } -// this.updateColorToRenderer(barRenderer); -// this.barRendererScaleChangedWithSize(); barRenderer.setColor(this.getColor()); barRenderer.setOpacity(this.getOpacity()); -// if (!barRenderer.textureLoaded()) { -// barRenderer.addLoadedEventListener(function () { -// this.barRendererScaleChangedWithSize(); -// }, this); -// } -// -// this.progressBarRendererScaleChangedWithSize(); this._barRendererAdaptDirty = true; this._progressBarRendererDirty = true; @@ -173,7 +161,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var progressBarRenderer = this._progressBarRenderer; switch (this._progressBarTexType) { case ccui.Widget.LOCAL_TEXTURE: -// progressBarRenderer.initWithFile(fileName); if (this._scale9Enabled) { progressBarRenderer.initWithFile(fileName); @@ -184,7 +171,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } break; case ccui.Widget.PLIST_TEXTURE: -// progressBarRenderer.initWithSpriteFrameName(fileName); if (this._scale9Enabled) { progressBarRenderer.initWithSpriteFrameName(fileName); @@ -197,24 +183,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ default: break; } -// this.updateColorToRenderer(progressBarRenderer); -// progressBarRenderer.setAnchorPoint(0.0, 0.5); -// var locSize = progressBarRenderer.getContentSize(); -// this._progressBarTextureSize.width = locSize.width; -// this._progressBarTextureSize.height = locSize.height; -// this.progressBarRendererScaleChangedWithSize(); -// -// var textLoaded = progressBarRenderer.textureLoaded(); -// this._isTextureLoaded = textLoaded; -// if (!textLoaded) { -// progressBarRenderer.addLoadedEventListener(function () { -// this._isTextureLoaded = true; -// var locSize = progressBarRenderer.getContentSize(); -// this._progressBarTextureSize.width = locSize.width; -// this._progressBarTextureSize.height = locSize.height; -// this.progressBarRendererScaleChangedWithSize(); -// }, this); -// } this._progressBarRenderer.setColor(this.getColor()); this._progressBarRenderer.setOpacity(this.getOpacity()); @@ -443,12 +411,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ percent = 0; } this._percent = percent; - if (!this._isTextureLoaded) { - return; - } - var dis = this._barLength * (percent / 100.0); + var res = percent / 100.0; + var dis = this._barLength * res; // this._slidBallRenderer.setPosition(-this._barLength / 2.0 + dis, 0.0); - this._slidBallRenderer.setPosition(cc.p(dis, this._barLength / 2)); + this._slidBallRenderer.setPosition(cc.p(dis, this._contentSize.height / 2)); if (this._scale9Enabled) { this._progressBarRenderer.setPreferredSize(cc.size(dis, this._progressBarTextureSize.height)); } @@ -465,8 +431,11 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ // this._progressBarRenderer.setTextureRect(cc.rect(x, y, this._progressBarTextureSize.width * (percent / 100.0), this._progressBarTextureSize.height)); var spriteRenderer = this._progressBarRenderer; var rect = spriteRenderer.getTextureRect(); - rect.width = this._progressBarTextureSize.width * res; - spriteRenderer.setTextureRect(rect, spriteRenderer.isTextureRectRotated(), rect.size); +// spriteRenderer.setTextureRect(rect, spriteRenderer.isTextureRectRotated(), rect.size); + spriteRenderer.setTextureRect( + cc.rect(rect.x, rect.y, spriteRenderer.texture._contentSize.width * res, rect.height), + spriteRenderer.isTextureRectRotated() + ); } }, @@ -615,8 +584,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ if (this._ignoreSize) { if (!this._scale9Enabled) { var ptextureSize = this._progressBarTextureSize; - var pscaleX = this._size.width / ptextureSize.width; - var pscaleY = this._size.height / ptextureSize.height; + var pscaleX = this._contentSize.width / ptextureSize.width; + var pscaleY = this._contentSize.height / ptextureSize.height; this._progressBarRenderer.setScaleX(pscaleX); this._progressBarRenderer.setScaleY(pscaleY); } From 9ad6368b4971866124575a2cdfcb037f6afb776d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 1 Jul 2014 21:19:33 +0800 Subject: [PATCH 0217/1564] Issue #5600: Fixed a bug about UISlider --- extensions/ccui/uiwidgets/UISlider.js | 45 ++++++++++----------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 8a50fa04f2..cb67001834 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -76,6 +76,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ init: function () { if (ccui.Widget.prototype.init.call(this)) { +// this.setTouchEnabled(true); return true; } return false; @@ -187,7 +188,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarRenderer.setOpacity(this.getOpacity()); this._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); - this._progressBarTextureSize = this._progressBarRenderer.getContentSize(); + var tz = this._progressBarRenderer.getContentSize(); + this._progressBarTextureSize = {width: tz.width, height: tz.height}; this._progressBarRendererDirty = true; }, @@ -419,19 +421,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarRenderer.setPreferredSize(cc.size(dis, this._progressBarTextureSize.height)); } else { -// var x = 0, y = 0; -// if (this._progressBarTexType == ccui.Widget.PLIST_TEXTURE) { -// var barNode = this._progressBarRenderer; -// if (barNode) { -// var rect = barNode.getTextureRect(); -// x = rect.x; -// y = rect.y; -// } -// } -// this._progressBarRenderer.setTextureRect(cc.rect(x, y, this._progressBarTextureSize.width * (percent / 100.0), this._progressBarTextureSize.height)); var spriteRenderer = this._progressBarRenderer; var rect = spriteRenderer.getTextureRect(); -// spriteRenderer.setTextureRect(rect, spriteRenderer.isTextureRectRotated(), rect.size); spriteRenderer.setTextureRect( cc.rect(rect.x, rect.y, spriteRenderer.texture._contentSize.width * res, rect.height), spriteRenderer.isTextureRectRotated() @@ -481,7 +472,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ */ getPercentWithBallPos: function (px) { return ((px/this._barLength)*100); -// return (((px - (-this._barLength / 2.0)) / this._barLength) * 100.0); }, /** @@ -608,25 +598,24 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarRenderer.setScaleY(pscaleY); } } -// this._progressBarRenderer.setPosition(-this._barLength * 0.5, 0.0); this._progressBarRenderer.setPosition(0.0, this._contentSize.height / 2.0); this.setPercent(this._percent); }, -// /** -// * override "getContentSize" method of widget. -// * @returns {cc.Size} -// */ -// getContentSize: function () { -// var locContentSize = this._barRenderer.getContentSize(); -// return cc.size(locContentSize.width, locContentSize.height); -// }, -// _getWidth: function () { -// return this._barRenderer._getWidth(); -// }, -// _getHeight: function () { -// return this._barRenderer._getHeight(); -// }, + /** + * override "getContentSize" method of widget. + * @returns {cc.Size} + */ + getContentSize: function () { + var locContentSize = this._barRenderer.getContentSize(); + return cc.size(locContentSize.width, locContentSize.height); + }, + _getWidth: function () { + return this._barRenderer._getWidth(); + }, + _getHeight: function () { + return this._barRenderer._getHeight(); + }, onPressStateChangedToNormal: function () { this._slidBallNormalRenderer.setVisible(true); From 26fc773a24cb04cfb87bfa65e34f53d907bb4561 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 10:44:19 +0800 Subject: [PATCH 0218/1564] Issue #5600: Slider bug --- extensions/ccui/uiwidgets/UISlider.js | 42 +++++++++++++-------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index cb67001834..d577b70c66 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -86,8 +86,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRenderer = cc.Sprite.create(); this._progressBarRenderer = cc.Sprite.create(); this._progressBarRenderer.setAnchorPoint(0.0, 0.5); - cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); - cc.Node.prototype.addChild.call(this, this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); + this.addProtectedChild(this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); + this.addProtectedChild(this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); this._slidBallNormalRenderer = cc.Sprite.create(); this._slidBallPressedRenderer = cc.Sprite.create(); this._slidBallPressedRenderer.setVisible(false); @@ -97,7 +97,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._slidBallRenderer.addChild(this._slidBallNormalRenderer); this._slidBallRenderer.addChild(this._slidBallPressedRenderer); this._slidBallRenderer.addChild(this._slidBallDisabledRenderer); - cc.Node.prototype.addChild.call(this, this._slidBallRenderer, ccui.Slider.BALL_RENDERER_ZORDER, -1); + this.addProtectedChild(this._slidBallRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); }, /** @@ -217,8 +217,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } this.loadBarTexture(this._textureFile, this._barTexType); this.loadProgressBarTexture(this._progressBarTextureFile, this._progressBarTexType); -// cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); -// cc.Node.prototype.addChild.call(this, this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); this.addProtectedChild(this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); this.addProtectedChild(this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); if (this._scale9Enabled) { @@ -424,7 +422,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var spriteRenderer = this._progressBarRenderer; var rect = spriteRenderer.getTextureRect(); spriteRenderer.setTextureRect( - cc.rect(rect.x, rect.y, spriteRenderer.texture._contentSize.width * res, rect.height), + cc.rect(rect.x, rect.y, dis, rect.height), spriteRenderer.isTextureRectRotated() ); } @@ -660,23 +658,23 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._sliderEventSelector = slider._sliderEventSelector; this._eventCallback = slider._eventCallback; - } + }, -// updateTextureColor: function () { -// this.updateColorToRenderer(this._barRenderer); -// this.updateColorToRenderer(this._progressBarRenderer); -// this.updateColorToRenderer(this._slidBallNormalRenderer); -// this.updateColorToRenderer(this._slidBallPressedRenderer); -// this.updateColorToRenderer(this._slidBallDisabledRenderer); -// }, -// -// updateTextureOpacity: function () { -// this.updateOpacityToRenderer(this._barRenderer); -// this.updateOpacityToRenderer(this._progressBarRenderer); -// this.updateOpacityToRenderer(this._slidBallNormalRenderer); -// this.updateOpacityToRenderer(this._slidBallPressedRenderer); -// this.updateOpacityToRenderer(this._slidBallDisabledRenderer); -// } + updateTextureColor: function () { + this.updateColorToRenderer(this._barRenderer); + this.updateColorToRenderer(this._progressBarRenderer); + this.updateColorToRenderer(this._slidBallNormalRenderer); + this.updateColorToRenderer(this._slidBallPressedRenderer); + this.updateColorToRenderer(this._slidBallDisabledRenderer); + }, + + updateTextureOpacity: function () { + this.updateOpacityToRenderer(this._barRenderer); + this.updateOpacityToRenderer(this._progressBarRenderer); + this.updateOpacityToRenderer(this._slidBallNormalRenderer); + this.updateOpacityToRenderer(this._slidBallPressedRenderer); + this.updateOpacityToRenderer(this._slidBallDisabledRenderer); + } }); var _p = ccui.Slider.prototype; From 0a626ce4fa1ef70a889d5cae5ee6443cc484ddfd Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 2 Jul 2014 10:46:11 +0800 Subject: [PATCH 0219/1564] Issue #5600: correct some mistakes of ccui.Layout, ccui.PageView, ccui.ScrollView --- .../ccui/base-classes/CCProtectedNode.js | 2 +- extensions/ccui/base-classes/UIWidget.js | 16 +- extensions/ccui/layouts/UILayout.js | 195 +++++-------- extensions/ccui/uiwidgets/UIText.js | 80 +++--- .../uiwidgets/scroll-widget/UIListView.js | 7 +- .../uiwidgets/scroll-widget/UIPageView.js | 270 ++++-------------- .../uiwidgets/scroll-widget/UIScrollView.js | 61 ++-- 7 files changed, 210 insertions(+), 421 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index d84ef2429a..6bb2c346aa 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -191,7 +191,7 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod */ sortAllProtectedChildren: function(){ if (this._reorderProtectedChildDirty) { - var _children = this._children; + var _children = this._protectedChildren; // insertion sort var len = _children.length, i, j, tmp; diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index c754ec938c..c36c0b8606 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -934,7 +934,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setHighlighted(this.hitTest(touchPoint)); var widgetParent = this.getWidgetParent(); if (widgetParent) - widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touchPoint); + widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); this.moveEvent(); }, @@ -976,8 +976,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchEventCallback(this, ccui.Widget.TOUCH_BAGAN); if (this._touchEventListener && this._touchEventSelector) { - if (this._touchEventSelector) - this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN); + this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN); } }, @@ -986,8 +985,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchEventCallback(this, ccui.Widget.TOUCH_MOVED); if (this._touchEventListener && this._touchEventSelector) { - if (this._touchEventSelector) - this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_MOVED); + this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_MOVED); } }, @@ -996,8 +994,7 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchEventCallback(this, ccui.Widget.TOUCH_ENDED); if (this._touchEventListener && this._touchEventSelector) { - if (this._touchEventSelector) - this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED); + this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED); } }, @@ -1005,9 +1002,8 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (this._touchEventCallback) this._touchEventCallback(this, ccui.Widget.TOUCH_CANCELED); - if (this._touchEventSelector) { - if (this._touchEventSelector) - this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_CANCELED); + if (this._touchEventListener && this._touchEventSelector) { + this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_CANCELED); } }, diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index ea19c6788f..635bb72942 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -244,32 +244,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } return false; }, - initStencil: null, - _initStencilForWebGL: function () { - this._clippingStencil = cc.DrawNode.create(); - ccui.Layout._init_once = true; - if (ccui.Layout._init_once) { - cc.stencilBits = cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS); - if (cc.stencilBits <= 0) - cc.log("Stencil buffer is not enabled."); - ccui.Layout._init_once = false; - } - }, - _initStencilForCanvas: function () { - this._clippingStencil = cc.DrawNode.create(); - var locContext = cc._renderContext; + + __stencilDraw: function(ctx){ + var locContext = ctx || cc._renderContext; var stencil = this._clippingStencil; - stencil.draw = function () { - var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); - for (var i = 0; i < stencil._buffer.length; i++) { - var element = stencil._buffer[i]; - var vertices = element.verts; - var firstPoint = vertices[0]; - locContext.beginPath(); - locContext.moveTo(firstPoint.x * locEGL_ScaleX, -firstPoint.y * locEGL_ScaleY); - for (var j = 1, len = vertices.length; j < len; j++) - locContext.lineTo(vertices[j].x * locEGL_ScaleX, -vertices[j].y * locEGL_ScaleY); - } + var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); + for (var i = 0; i < stencil._buffer.length; i++) { + var element = stencil._buffer[i]; + var vertices = element.verts; + var firstPoint = vertices[0]; + locContext.beginPath(); + locContext.moveTo(firstPoint.x * locEGL_ScaleX, -firstPoint.y * locEGL_ScaleY); + for (var j = 1, len = vertices.length; j < len; j++) + locContext.lineTo(vertices[j].x * locEGL_ScaleX, -vertices[j].y * locEGL_ScaleY); } }, @@ -491,76 +478,28 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); // draw (according to the stencil test func) this node and its childs - cc.Node.prototype.visit.call(this, ctx); - - /////////////////////////////////// - // CLEANUP - - // manually restore the stencil state - gl.stencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); - gl.stencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); - gl.stencilMask(currentStencilWriteMask); - if (!currentStencilEnabled) - gl.disable(gl.STENCIL_TEST); - - // we are done using this layer, decrement - ccui.Layout._layer--; - - //TODO new Code - /*if(!_visible) - return; - - uint32_t flags = processParentFlags(parentTransform, parentFlags); - - // IMPORTANT: - // To ease the migration to v3.0, we still support the Mat4 stack, - // but it is deprecated and your code should not rely on it - Director* director = Director.getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - director.pushMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW); - director.loadMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW, _modelViewTransform); - //Add group command - - _groupCommand.init(_globalZOrder); - renderer.addCommand(&_groupCommand); - - renderer.pushGroup(_groupCommand.getRenderQueueID()); - - _beforeVisitCmdStencil.init(_globalZOrder); - _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout.onBeforeVisitStencil, this); - renderer.addCommand(&_beforeVisitCmdStencil); - - _clippingStencil.visit(renderer, _modelViewTransform, flags); - - _afterDrawStencilCmd.init(_globalZOrder); - _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout.onAfterDrawStencil, this); - renderer.addCommand(&_afterDrawStencilCmd); - - int i = 0; // used by _children - int j = 0; // used by _protectedChildren - - sortAllChildren(); - sortAllProtectedChildren(); + var i = 0; // used by _children + var j = 0; // used by _protectedChildren + this.sortAllChildren(); + this.sortAllProtectedChildren(); + var locChildren = this._children, locProtectChildren = this._protectedChildren; + var iLen = locChildren.length, jLen = locProtectChildren.length, child; // // draw children and protectedChildren zOrder < 0 // - for( ; i < _children.size(); i++ ) - { - auto node = _children.at(i); - - if ( node && node.getLocalZOrder() < 0 ) - node.visit(renderer, _modelViewTransform, flags); + for( ; i < iLen; i++ ){ + child = locChildren[i]; + if ( child && child.getLocalZOrder() < 0 ) + child.visit(); else break; } - for( ; j < _protectedChildren.size(); j++ ) - { - auto node = _protectedChildren.at(j); - - if ( node && node.getLocalZOrder() < 0 ) - node.visit(renderer, _modelViewTransform, flags); + for( ; j < jLen; j++ ) { + child = locProtectChildren[j]; + if ( child && child.getLocalZOrder() < 0 ) + child.visit(); else break; } @@ -568,25 +507,28 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // // draw self // - this.draw(renderer, _modelViewTransform, flags); + this.draw(); // // draw children and protectedChildren zOrder >= 0 // - for(auto it=_protectedChildren.cbegin()+j; it != _protectedChildren.cend(); ++it) - (*it).visit(renderer, _modelViewTransform, flags); - - for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) - (*it).visit(renderer, _modelViewTransform, flags); + for (; i < iLen; i++) + locChildren[i].visit(); + for (; j < jLen; j++) + locProtectChildren[j].visit(); + /////////////////////////////////// + // CLEANUP - _afterVisitCmdStencil.init(_globalZOrder); - _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout.onAfterVisitStencil, this); - renderer.addCommand(&_afterVisitCmdStencil); - - renderer.popGroup(); + // manually restore the stencil state + gl.stencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); + gl.stencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); + gl.stencilMask(currentStencilWriteMask); + if (!currentStencilEnabled) + gl.disable(gl.STENCIL_TEST); - director.popMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW);*/ + // we are done using this layer, decrement + ccui.Layout._layer--; }, _stencilClippingVisitForCanvas: function (ctx) { @@ -624,9 +566,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ context.globalCompositeOperation = "destination-over"; context.drawImage(locCache, 0, 0); context.restore(); - } - // Clip mode, fast, but only support cc.DrawNode - else { + } else { // Clip mode, fast, but only support cc.DrawNode var i, children = this._children, locChild; context.save(); @@ -637,25 +577,35 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // Clip mode doesn't support recusive stencil, so once we used a clip stencil, // so if it has ClippingNode as a child, the child must uses composition stencil. this._cangodhelpme(true); - var len = children.length; - if (len > 0) { - this.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - locChild = children[i]; - if (locChild._localZOrder < 0) - locChild.visit(context); - else - break; - } - this.draw(context); - for (; i < len; i++) { - children[i].visit(context); - } - } else - this.draw(context); - this._cangodhelpme(false); + this.sortAllChildren(); + this.sortAllProtectedChildren(); + + var j, locProtectChildren = this._protectedChildren; + var iLen = children, jLen = locProtectChildren.length; + + // draw children zOrder < 0 + for (i = 0; i < iLen; i++) { + locChild = children[i]; + if (locChild && locChild._localZOrder < 0) + locChild.visit(context); + else + break; + } + for (j = 0; j < jLen; j++) { + locChild = locProtectChildren[j]; + if (locChild && locChild._localZOrder < 0) + locChild.visit(context); + else + break; + } + //this.draw(context); + for (; i < iLen; i++) + children[i].visit(context); + for (; j < jLen; j++) + locProtectChildren[j].visit(context); + + this._cangodhelpme(false); context.restore(); } }, @@ -693,6 +643,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Layout.CLIPPING_STENCIL: if (able){ this._clippingStencil = cc.DrawNode.create(); + this._clippingStencil.draw = this.__stencilDraw.bind(this); if (this._running) this._clippingStencil.onEnter(); this.setStencilClippingSize(this._size); @@ -2225,11 +2176,11 @@ ccui.Layout._sharedCache = null; if (cc._renderType == cc._RENDER_TYPE_WEBGL) { //WebGL - ccui.Layout.prototype.initStencil = ccui.Layout.prototype._initStencilForWebGL; + //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 { - ccui.Layout.prototype.initStencil = ccui.Layout.prototype._initStencilForCanvas; + //ccui.Layout.prototype.initStencil = ccui.Layout.prototype._initStencilForCanvas; ccui.Layout.prototype.stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; ccui.Layout.prototype.scissorClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; } diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index a298a4fe96..386b4d645b 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -380,36 +380,36 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ getType: function(){ return this._type; - } -// -// _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(); -// }, -// _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; -// }, + }, + + _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(); + }, + _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; + }, // // /** // * Gets the touch scale enabled of label. @@ -468,15 +468,17 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ // this.updateOpacityToRenderer(this._labelRenderer); // }, // -// copySpecialProperties: function (uiLabel) { -// this.setFontName(uiLabel._fontName); -// this.setFontSize(uiLabel._labelRenderer.getFontSize()); -// this.setString(uiLabel.getString()); -// this.setTouchScaleChangeEnabled(uiLabel.touchScaleEnabled); -// this.setTextAreaSize(uiLabel._textAreaSize); -// this.setTextHorizontalAlignment(uiLabel._textHorizontalAlignment); -// this.setTextVerticalAlignment(uiLabel._textVerticalAlignment); -// } + copySpecialProperties: function (uiLabel) { + if(uiLabel instanceof uiLabel){ + this.setFontName(uiLabel._fontName); + this.setFontSize(uiLabel.getFontSize()); + this.setString(uiLabel.getString()); + this.setTouchScaleChangeEnabled(uiLabel.touchScaleEnabled); + this.setTextAreaSize(uiLabel._textAreaSize); + this.setTextHorizontalAlignment(uiLabel._labelRenderer.getHorizontalAlignment()); + this.setTextVerticalAlignment(uiLabel._labelRenderer.getVerticalAlignment()); + } + } }); var _p = ccui.Text.prototype; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 76d71f4d4d..260c8aa033 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -423,11 +423,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this.updateInnerContainerSize(); }, - doLayout: function(){ - ccui.Layout.prototype.doLayout.call(this); + _doLayout: function(){ + ccui.Layout.prototype._doLayout.call(this); - if (this._refreshViewDirty) - { + if (this._refreshViewDirty) { this.refreshView(); this._refreshViewDirty = false; } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index bb50a0d818..5e23da9f63 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -31,23 +31,23 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _curPageIdx: 0, _pages: null, - _touchMoveDir: null, + _touchMoveDirection: null, _touchStartLocation: 0, _touchMoveStartLocation: 0, _movePagePoint: null, - _leftChild: null, - _rightChild: null, + _leftBoundaryChild: null, + _rightBoundaryChild: null, _leftBoundary: 0, _rightBoundary: 0, _isAutoScrolling: false, _autoScrollDistance: 0, _autoScrollSpeed: 0, - _autoScrollDir: 0, + _autoScrollDirection: 0, _childFocusCancelOffset: 0, _pageViewEventListener: null, _pageViewEventSelector: null, _className:"PageView", - _touchMoveDirection: null, + _eventCallback: null, /** * allocates and initializes a UIPageView. @@ -60,29 +60,26 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ ccui.Layout.prototype.ctor.call(this); this._curPageIdx = 0; this._pages = []; - this._touchMoveDir = ccui.PageView.TOUCH_DIR_LEFT; + this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT; this._touchStartLocation = 0; this._touchMoveStartLocation = 0; this._movePagePoint = null; - this._leftChild = null; - this._rightChild = null; + this._leftBoundaryChild = null; + this._rightBoundaryChild = null; this._leftBoundary = 0; this._rightBoundary = 0; this._isAutoScrolling = false; this._autoScrollDistance = 0; this._autoScrollSpeed = 0; - this._autoScrollDir = 0; + this._autoScrollDirection = 0; this._childFocusCancelOffset = 5; this._pageViewEventListener = null; this._pageViewEventSelector = null; - - this.init(); }, init: function () { if (ccui.Layout.prototype.init.call(this)) { this.setClippingEnabled(true); -// this.setTouchEnabled(true); return true; } return false; @@ -90,12 +87,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ onEnter:function(){ ccui.Layout.prototype.onEnter.call(this); - this.setUpdateEnabled(true); - }, - - onExit:function(){ - this.setUpdateEnabled(false); - ccui.Layout.prototype.onExit.call(this); + this.scheduleUpdate(true); }, /** @@ -105,26 +97,22 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {Boolean} forceCreate */ addWidgetToPage: function (widget, pageIdx, forceCreate) { - if (!widget || pageIdx < 0) { + if (!widget || pageIdx < 0) return; - } var pageCount = this.getPageCount(); if (pageIdx >= pageCount) { if (forceCreate) { - if (pageIdx > pageCount) { - cc.log("pageIdx is %d, it will be added as page id [%d]", pageIdx, pageCount); - } + if (pageIdx > pageCount) + cc.log("pageIdx is %d, it will be added as page id [%d]", pageIdx, pageCount) var newPage = this.createPage(); newPage.addChild(widget); this.addPage(newPage); } - } - else { + } else { var page = this._pages[pageIdx]; - if (page) { + if (page) page.addChild(widget); - } } }, @@ -134,7 +122,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ */ createPage: function () { var newPage = ccui.Layout.create(); -// newPage.setSize(this.getSize()); newPage.setContentSize(this.getContentSize()); return newPage; }, @@ -144,34 +131,11 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {ccui.Layout} page */ addPage: function (page) { -// if (!page) { -// return; -// } -// if (page.getWidgetType() != ccui.Widget.TYPE_CONTAINER) { -// return; -// } -// if (this._pages.indexOf(page) != -1) { -// return; -// } -// var pSize = page.getSize(); -// var pvSize = this.getSize(); -// if (!(pSize.width==pvSize.width&&pSize.height==pvSize.height)) { -// cc.log("page size does not match pageview size, it will be force sized!"); -// page.setSize(pvSize); -// } -// page.setPosition(this.getPositionXByIndex(this._pages.length), 0); -// this._pages.push(page); -// this.addChild(page); -// this.updateBoundaryPages(); if (!page || this._pages.indexOf(page) != -1) - { return; - } - this.addProtectedChild(page); this._pages.push(page); - this._doLayoutDirty = true; }, @@ -181,60 +145,16 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {Number} idx */ insertPage: function (page, idx) { -// if (idx < 0) { -// return; -// } -// if (!page) { -// return; -// } -// if (page.getWidgetType() != ccui.Widget.TYPE_CONTAINER) { -// return; -// } -// if (this._pages.indexOf(page) != -1) { -// return; -// } -// -// var pageCount = this._pages.length; -// if (idx >= pageCount) { -// this.addPage(page); -// } -// else { -// this._pages.splice(idx, 0, page); -// page.setPosition(this.getPositionXByIndex(idx), 0); -// this.addChild(page); -// var pSize = page.getSize(); -// var pvSize = this.getSize(); -// if (!pSize.equals(pvSize)) { -// cc.log("page size does not match pageview size, it will be force sized!"); -// page.setSize(pvSize); -// } -// var arrayPages = this._pages; -// var length = arrayPages.length; -// for (var i = (idx + 1); i < length; i++) { -// var behindPage = arrayPages[i]; -// var formerPos = behindPage.getPosition(); -// behindPage.setPosition(formerPos.x + this.getSize().width, 0); -// } -// this.updateBoundaryPages(); -// } if (idx < 0 || !page || this._pages.indexOf(page) != -1) - { return; - } - var pageCount = this.getPageCount(); if (idx >= pageCount) - { this.addPage(page); - } - else - { + else { this._pages[idx] = page; this.addProtectedChild(page); - } - this._doLayoutDirty = true; }, @@ -246,14 +166,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ if (!page) { return; } -// this.removeChild(page); -// this.updateChildrenPosition(); -// this.updateBoundaryPages(); this.removeProtectedChild(page); var index = this._pages.indexOf(page); if(index > -1) this._pages.splice(index, 1); - this._doLayoutDirty = true; }, @@ -272,22 +188,21 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, removeAllPages: function(){ - for(var p in this._pages) - { - var node = this._pages[p]; - this.removeProtectedChild(node); + var locPages = this._pages; + for(var i = 0, len = locPages.length; i < len; i++){ + this.removeProtectedChild(locPages[i]); } - this._pages = []; + this._pages.length = 0; }, updateBoundaryPages: function () { if (this._pages.length <= 0) { - this._leftChild = null; - this._rightChild = null; + this._leftBoundaryChild = null; + this._rightBoundaryChild = null; return; } - this._leftChild = this._pages[0]; - this._rightChild = this._pages[this._pages.length-1]; + this._leftBoundaryChild = this._pages[0]; + this._rightBoundaryChild = this._pages[this._pages.length-1]; }, getPageCount: function(){ @@ -305,42 +220,32 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ onSizeChanged: function () { ccui.Layout.prototype.onSizeChanged.call(this); - this._rightBoundary = this.getSize().width; -// this.updateChildrenSize(); -// this.updateChildrenPosition(); + this._rightBoundary = this.getContentSize().width; this._doLayoutDirty = true; }, updateAllPagesSize: function(){ var selfSize = this.getContentSize(); - for (var p in this._pages) - { - var page = this._pages[p]; - page.setContentSize(selfSize); + var locPages = this._pages; + for (var i = 0, len = locPages.length; i < len; i++) { + locPages[i].setContentSize(selfSize); } - }, updateAllPagesPosition: function(){ var pageCount = this.getPageCount(); - - if (pageCount <= 0) - { + if (pageCount <= 0) { this._curPageIdx = 0; return; } if (this._curPageIdx >= pageCount) - { this._curPageIdx = pageCount-1; - } var pageWidth = this.getContentSize().width; - for (var i=0; i= this._pages.length) { + if (idx < 0 || idx >= this._pages.length) return; - } this._curPageIdx = idx; var curPage = this._pages[idx]; this._autoScrollDistance = -(curPage.getPosition().x); this._autoScrollSpeed = Math.abs(this._autoScrollDistance) / 0.2; - this._autoScrollDir = this._autoScrollDistance > 0 ? 1 : 0; + this._autoScrollDirection = this._autoScrollDistance > 0 ? 1 : 0; this._isAutoScrolling = true; }, @@ -367,9 +271,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, autoScroll: function(dt){ - switch (this._autoScrollDir) { + var step; + switch (this._autoScrollDirection) { case 0: - var step = this._autoScrollSpeed * dt; + step = this._autoScrollSpeed * dt; if (this._autoScrollDistance + step >= 0.0) { step = -this._autoScrollDistance; this._autoScrollDistance = 0.0; @@ -385,7 +290,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ break; break; case 1: - var step = this._autoScrollSpeed * dt; + step = this._autoScrollSpeed * dt; if (this._autoScrollDistance - step <= 0.0) { step = this._autoScrollDistance; this._autoScrollDistance = 0.0; @@ -405,28 +310,18 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, onTouchBegan: function (touch,event) { - var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch,event); - if (this._hitted){ - this.handlePressLogic(touch.getLocation()); - } + var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); + if (this._hitted) + this.handlePressLogic(touch); return pass; }, - onTouchMoved: function (touch,event) { -// var touchPoint = touch.getLocation(); -// this._touchMovePosition.x = touchPoint.x; -// this._touchMovePosition.y = touchPoint.y; -// this.handleMoveLogic(touchPoint); + onTouchMoved: function (touch, event) { this.handleMoveLogic(touch); var widgetParent = this.getWidgetParent(); - if (widgetParent) { - widgetParent.checkChildInfo(1, this, touch); - } + if (widgetParent) + widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); this.moveEvent(); -// if (!this.hitTest(touchPoint)) { -// this.setFocused(false); -// this.onTouchEnded(touch,event); -// } }, onTouchEnded: function (touch, event) { @@ -435,23 +330,18 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, onTouchCancelled: function (touch, event) { -// var touchPoint = touch.getLocation(); ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); -// this.handleReleaseLogic(touchPoint); this.handleReleaseLogic(touch); }, - doLayout: function(){ + _doLayout: function(){ if (!this._doLayoutDirty) - { return; - } this.updateAllPagesPosition(); this.updateAllPagesSize(); this.updateBoundaryPages(); - this._doLayoutDirty = false; }, @@ -466,28 +356,25 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, scrollPages: function (touchOffset) { - if (this._pages.length <= 0) { + if (this._pages.length <= 0) return false; - } - if (!this._leftChild || !this._rightChild) { + if (!this._leftBoundaryChild || !this._rightBoundaryChild) return false; - } var realOffset = touchOffset; - - switch (this._touchMoveDir) { + switch (this._touchMoveDirection) { case ccui.PageView.TOUCH_DIR_LEFT: // left - if (this._rightChild.getRightBoundary() + touchOffset <= this._rightBoundary) { - realOffset = this._rightBoundary - this._rightChild.getRightBoundary(); + if (this._rightBoundaryChild.getRightBoundary() + touchOffset <= this._rightBoundary) { + realOffset = this._rightBoundary - this._rightBoundaryChild.getRightBoundary(); this.movePages(realOffset); return false; } break; case ccui.PageView.TOUCH_DIR_RIGHT: // right - if (this._leftChild.getLeftBoundary() + touchOffset >= this._leftBoundary) { - realOffset = this._leftBoundary - this._leftChild.getLeftBoundary(); + if (this._leftBoundaryChild.getLeftBoundary() + touchOffset >= this._leftBoundary) { + realOffset = this._leftBoundary - this._leftBoundaryChild.getLeftBoundary(); this.movePages(realOffset); return false; } @@ -501,31 +388,22 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, handlePressLogic: function (touchPoint) { -// var nsp = this.convertToNodeSpace(touchPoint); -// this._touchMoveStartLocation = nsp.x; -// this._touchStartLocation = nsp.x; //np-op }, - handleMoveLogic: function (touchPoint) { - var nsp = this.convertToNodeSpace(touchPoint); - var offset = 0.0; - var moveX = nsp.x; - offset = moveX - this._touchMoveStartLocation; - this._touchMoveStartLocation = moveX; + handleMoveLogic: function (touch) { + var offset = touch.getLocation().x - touch.getPreviousLocation().x; if (offset < 0) { - this._touchMoveDir = ccui.PageView.TOUCH_DIR_LEFT; - } - else if (offset > 0) { - this._touchMoveDir = ccui.PageView.TOUCH_DIR_RIGHT; + this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT; + } else if (offset > 0) { + this._touchMoveDirection = ccui.PageView.TOUCH_DIR_RIGHT; } this.scrollPages(offset); }, handleReleaseLogic: function (touchPoint) { - if (this._pages.length <= 0) { + if (this._pages.length <= 0) return; - } var curPage = this._pages[this._curPageIdx]; if (curPage) { var curPagePos = curPage.getPosition(); @@ -544,8 +422,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this.scrollPages(-curPageLocation); else this.scrollToPage(this._curPageIdx - 1); - } - else { + } else { this.scrollToPage(this._curPageIdx); } } @@ -558,7 +435,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ break; case 1: var offset = 0; - offset = Math.abs(sender.getTouchStartPos().x - touchPoint.x); + offset = Math.abs(sender.getTouchBeganPosition().x - touchPoint.x); if (offset > this._childFocusCancelOffset) { sender.setFocused(false); this.handleMoveLogic(touchPoint); @@ -613,9 +490,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ getPage: function(index){ if (index < 0 || index >= this.getPages().size()) - { return null; - } return this._pages[index]; }, @@ -641,32 +516,13 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ copySpecialProperties: function (pageView) { ccui.Layout.prototype.copySpecialProperties.call(this, pageView); + this._eventCallback = pageView._eventCallback; + this._pageViewEventListener = pageView._pageViewEventListener; + this._pageViewEventSelector = pageView._pageViewEventSelector; } - -// /** -// * Add widget -// * @param {ccui.Widget} widget -// * @param {Number} zOrder -// * @param {Number} tag -// * @returns {boolean} -// */ -// addChild: function (widget, zOrder, tag) { -// return ccui.Layout.prototype.addChild.call(this, widget, zOrder, tag); -// }, -// -// /** -// * remove widget child override -// * @param {ccui.Widget} child -// * @param {Boolean} cleanup -// */ -// removeChild: function (child, cleanup) { -// if(cleanup) -// cc.arrayRemoveObject(this._pages, child); -// ccui.Layout.prototype.removeChild.call(this, child, cleanup); -// }, // // updateChildrenSize: function () { // if(this._pages){ diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 3e3b9cc80f..f2bfb391a0 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -861,7 +861,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollChildren: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; this.scrollingEvent(); - switch (this._direction) { + switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical scrollEnabled = this.scrollChildrenVertical(touchOffsetX, touchOffsetY); break; @@ -1397,16 +1397,11 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, handlePressLogic: function (touch) { -/* this._touchBeganPosition = this.convertToNodeSpace(touchPoint); - this._touchMovingPoint = this._touchBeganPosition;*/ this.startRecordSlidAction(); this._bePressed = true; }, handleMoveLogic: function (touch) { -/* this._touchMovePosition = this.convertToNodeSpace(touchPoint); - var delta = cc.pSub(this._touchMovePosition, this._touchMovingPoint); - this._touchMovingPoint = this._touchMovePosition;*/ var delta = cc.pSub(touch.getLocation(), touch.getPreviousLocation()); switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical @@ -1431,7 +1426,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ onTouchBegan: function (touch, event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); if (this._hitted) - this.handlePressLogic(this._touchBeganPosition); + this.handlePressLogic(touch); return pass; }, @@ -1449,10 +1444,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); }, - onTouchLongClicked: function (touchPoint) { - - }, - update: function (dt) { if (this._autoScroll) this.autoScrollChildren(dt); @@ -1468,42 +1459,36 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Intercept touch event - * @param {number} handleState + * @param {number} event * @param {ccui.Widget} sender - * @param {cc.Point} touchPoint + * @param {cc.Touch} touch */ - interceptTouchEvent: function (handleState, sender, touchPoint) { - switch (handleState) { - case 0: - this.handlePressLogic(touchPoint); + interceptTouchEvent: function (event, sender, touch) { + var touchPoint = touch.getLocation(); + switch (event) { + case ccui.Widget.TOUCH_BAGAN: + this._touchBeganPosition.x = touchPoint.x; + this._touchBeganPosition.y = touchPoint.y; + this.handlePressLogic(touch); break; - case 1: - var offset = cc.pSub(sender.getTouchStartPos(), touchPoint); - if (cc.pLength(offset) > this._childFocusCancelOffset) { - sender.setFocused(false); - this.handleMoveLogic(touchPoint); + case ccui.Widget.TOUCH_MOVED: + var offset = cc.pLength(cc.pSub(sender.getTouchBeganPosition(), touchPoint)); + if (offset > this._childFocusCancelOffset) { + sender.setHighlighted(false); + this._touchMovePosition.x = touchPoint.x; + this._touchMovePosition.y = touchPoint.y; + this.handleMoveLogic(touch); } break; - case 2: - this.handleReleaseLogic(touchPoint); - break; - case 3: - this.handleReleaseLogic(touchPoint); + case ccui.Widget.TOUCH_CANCELED: + case ccui.Widget.TOUCH_ENDED: + this._touchEndPosition.x = touchPoint.x; + this._touchEndPosition.y = touchPoint.y; + this.handleReleaseLogic(touch); break; } }, - /** - * - * @param {number} handleState - * @param {ccui.Widget} sender - * @param {cc.Point} touchPoint - */ - checkChildInfo: function (handleState, sender, touchPoint) { - if (this._enabled && this._touchEnabled) - this.interceptTouchEvent(handleState, sender, touchPoint); - }, - scrollToTopEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); From cc410f521ad1961b2648d7d3d7aa83d25a04d5c2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 11:55:53 +0800 Subject: [PATCH 0220/1564] Issue #5600: Fixed a bug about UISlider --- extensions/ccui/uiwidgets/UISlider.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index d577b70c66..33d792b69b 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -97,7 +97,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._slidBallRenderer.addChild(this._slidBallNormalRenderer); this._slidBallRenderer.addChild(this._slidBallPressedRenderer); this._slidBallRenderer.addChild(this._slidBallDisabledRenderer); - this.addProtectedChild(this._slidBallRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); + this.addProtectedChild(this._slidBallRenderer, ccui.Slider.BALL_RENDERER_ZORDER, -1); }, /** @@ -203,8 +203,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } this._scale9Enabled = able; - cc.Node.prototype.removeChild.call(this, this._barRenderer, true); - cc.Node.prototype.removeChild.call(this, this._progressBarRenderer, true); + this.removeProtectedChild(this._barRenderer, true); + this.removeProtectedChild(this._progressBarRenderer, true); this._barRenderer = null; this._progressBarRenderer = null; if (this._scale9Enabled) { From 259242a7dd23baf33ab154031bed50a06d63f553 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 13:34:52 +0800 Subject: [PATCH 0221/1564] Issue #5600: UILoadingBar --- extensions/ccui/uiwidgets/UILoadingBar.js | 27 ++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 8d4728125b..74beee46aa 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -132,7 +132,9 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } barRenderer.setColor(this.getColor()); barRenderer.setOpacity(this.getOpacity()); - this._barRendererTextureSize = barRenderer.getContentSize(); + var bz = barRenderer.getContentSize(); + this._barRendererTextureSize.width = bz.width; + this._barRendererTextureSize.height = bz.height; switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: @@ -209,27 +211,22 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ if (this._totalLength <= 0) return; this._percent = percent; - if (!this._isTextureLoaded) - return; + var res = this._percent / 100.0; if (this._scale9Enabled) this.setScale9Scale(); else { -/* var x = 0, y = 0; //TODO need test - if (this._renderBarTexType == ccui.Widget.PLIST_TEXTURE) { - var barNode = this._barRenderer; - if (barNode) { - var rect = barNode.getTextureRect(); - x = rect.x; - y = rect.y; - } - } - this._barRenderer.setTextureRect(cc.rect(x, y, this._barRendererTextureSize.width * res, this._barRendererTextureSize.height));*/ var spriteRenderer = this._barRenderer; var rect = spriteRenderer.getTextureRect(); - rect.size.width = this._barRendererTextureSize.width * res; - spriteRenderer.setTextureRect(rect, spriteRenderer.isTextureRectRotated(), rect.size); + this._barRenderer.setTextureRect( + cc.rect( + rect.x, + rect.y, + this._barRendererTextureSize.width * res, + this._barRendererTextureSize.height + ) + ); } }, From 2baf4d9a174055cabcb9c0d77c3c99fc48175cdb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 13:46:48 +0800 Subject: [PATCH 0222/1564] Issue #5600: Fixed a bug about UILabelAtlas --- cocos2d/core/base-nodes/CCAtlasNode.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index a3e5cd2b86..a754678219 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -247,8 +247,10 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ var context = ctx || cc._renderContext; cc.nodeDrawSetup(this); cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - context.uniform4fv(this._uniformColor, this._colorF32Array); - this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0); + if(this._uniformColor && this._colorF32Array){ + context.uniform4fv(this._uniformColor, this._colorF32Array); + this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0); + } }, /** From 2e62ab7024fed3e74d0636960a4cb7822119791b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 15:20:17 +0800 Subject: [PATCH 0223/1564] Issue #5600: Fixed a bug about Label line wrap --- extensions/ccui/base-classes/UIWidget.js | 10 +++++++--- extensions/ccui/uiwidgets/UIText.js | 7 +------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 752f902c82..62f9e0e07c 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -123,14 +123,18 @@ ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setBright(true); this.onFocusChanged = this.onFocusChange.bind(this); + this.onNextFocusedWidget = null; + this.setAnchorPoint(cc.p(0.5, 0.5)); this.ignoreContentAdaptWithSize(true); - this.setAnchorPoint(cc.p(0.5, 0.5)); - this.setTouchEnabled(true); + +// this.setTouchEnabled(true); this.setCascadeColorEnabled(true); this.setCascadeOpacityEnabled(true); + + return true; } - return true; + return false; }, onEnter: function () { diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 386b4d645b..61aa232c4c 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -277,7 +277,6 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, updateFlippedX: function () { -// this._labelRenderer.setFlippedX(this._flippedX); if (this._flippedX) { @@ -317,12 +316,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ labelScaleChangedWithSize: function () { if (this._ignoreSize) { - this._labelRenderer.setDimensions(cc.size(0, 0)); - + //this._labelRenderer.setDimensions(cc.size(0, 0)); this._labelRenderer.setScale(1.0); -// var renderSize = this._labelRenderer.getContentSize(); -// this._size.width = renderSize.width; -// this._size.height = renderSize.height; this._normalScaleValueX = this._normalScaleValueY = 1; } else { this._labelRenderer.setDimensions(cc.size(this._contentSize.width, this._contentSize.height)); From 9b9152fcc71d88f092cc889a543126e554cef422 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 2 Jul 2014 16:04:58 +0800 Subject: [PATCH 0224/1564] Feature #3949: Refactor cc.pool from class to singleton object --- cocos2d/core/CCDirector.js | 5 +++-- extensions/ccpool/CCPool.js | 36 ++++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index ab859e9b0d..ee1374126b 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -38,7 +38,9 @@ cc.GLToClipTransform = function (transformOut) { //---------------------------------------------------------------------------------------------------------------------- /** - * @namespace

+ * @namespace + * @name cc.director + *

* cc.director is a singleton of DisplayLinkDirector type director.
* Since the cc.director is a singleton, you don't need to call any constructor or create functions,
* the standard way to use it is by calling:
@@ -67,7 +69,6 @@ cc.GLToClipTransform = function (transformOut) { * - Scheduled timers & drawing are synchronizes with the refresh rate of the display
* - Only supports animation intervals of 1/60 1/30 & 1/15
*

- * @name cc.director */ cc.Director = cc.Class.extend(/** @lends cc.director# */{ //Variables diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 68252e931f..7b19770fd6 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -24,11 +24,27 @@ THE SOFTWARE. ****************************************************************************/ -var CCPool = cc.Class.extend({ - _pool: null, - ctor: function () { - this._pool = {}; - }, +/** + * @namespace + * @name cc.pool + *

+ * cc.pool is a singleton object serves as an object cache pool.
+ * It can helps you to improve your game performance for objects which need frequent release and recreate operations
+ * Some common use case is : + * 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects) + * 2. Blocks in candy crash (massive creation and recreation) + * etc... + *

+ * + * @example + * var sp = new cc.Sprite("a.png"); + * this.addChild(sp); + * cc.pool.putInPool(sp); + * + * cc.pool.getFromPool(cc.Sprite, "a.png"); + */ +cc.pool = { + _pool: {}, /** * Put the obj in pool @@ -113,12 +129,4 @@ var CCPool = cc.Class.extend({ } this._pool = {}; } -}); -CCPool._instance = null; -CCPool._getInstance = function () { - if (!CCPool._instance) { - CCPool._instance = new CCPool(); - } - return CCPool._instance; -} -cc.pool = CCPool._getInstance(); \ No newline at end of file +}; \ No newline at end of file From 2c5d19d48507ba4489e06f9b59df85ef4d7f9f52 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 2 Jul 2014 17:12:29 +0800 Subject: [PATCH 0225/1564] Issue #5600: correct some mistakes of ccui.Layout, ccui.ScrollView, ccui.ListView --- extensions/ccui/layouts/UILayout.js | 444 ++---------------- extensions/ccui/layouts/UILayoutManager.js | 2 +- .../uiwidgets/scroll-widget/UIListView.js | 96 +--- .../uiwidgets/scroll-widget/UIScrollView.js | 97 ++-- 4 files changed, 105 insertions(+), 534 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 635bb72942..446c7c28e4 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -582,7 +582,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.sortAllProtectedChildren(); var j, locProtectChildren = this._protectedChildren; - var iLen = children, jLen = locProtectChildren.length; + var iLen = children.length, jLen = locProtectChildren.length; // draw children zOrder < 0 for (i = 0; i < iLen; i++) { @@ -646,7 +646,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingStencil.draw = this.__stencilDraw.bind(this); if (this._running) this._clippingStencil.onEnter(); - this.setStencilClippingSize(this._size); + this.setStencilClippingSize(this._contentSize); } else { if (this._running) this._clippingStencil.onExit(); @@ -701,8 +701,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._clippingRectDirty) { var worldPos = this.convertToWorldSpace(cc.p(0, 0)); var t = this.nodeToWorldTransform(); - var scissorWidth = this._size.width * t.a; - var scissorHeight = this._size.height * t.d; + var scissorWidth = this._contentSize.width * t.a; + var scissorHeight = this._contentSize.height * t.d; var parentClippingRect; var parent = this; var firstClippingParentFounded = false; @@ -771,23 +771,22 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - //this.setContentSize(this._size); //TODO need test - this.setStencilClippingSize(this._size); + this.setStencilClippingSize(this._contentSize); this._doLayoutDirty = true; this._clippingRectDirty = true; if (this._backGroundImage) { - this._backGroundImage.setPosition(this._size.width * 0.5, this._size.height * 0.5); + this._backGroundImage.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); if (this._backGroundScale9Enabled) { if (this._backGroundImage instanceof cc.Scale9Sprite) { - this._backGroundImage.setPreferredSize(this._size); + this._backGroundImage.setPreferredSize(this._contentSize); } } } if (this._colorRender) { - this._colorRender.setContentSize(this._size); + this._colorRender.setContentSize(this._contentSize); } if (this._gradientRender) { - this._gradientRender.setContentSize(this._size); + this._gradientRender.setContentSize(this._contentSize); } }, @@ -829,9 +828,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ setBackGroundImage: function (fileName, texType) { - if (!fileName) { + if (!fileName) return; - } texType = texType || ccui.Widget.LOCAL_TEXTURE; if (this._backGroundImage == null) this.addBackGroundImage(); @@ -849,7 +847,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ default: break; } - bgiScale9.setPreferredSize(this._size); + bgiScale9.setPreferredSize(this._contentSize); } else { var sprite = this._backGroundImage; switch (this._bgImageTexType){ @@ -864,7 +862,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } } this._backGroundImageTextureSize = this._backGroundImage.getContentSize(); - this._backGroundImage.setPosition(this._size.width / 2.0, this._size.height / 2.0); + this._backGroundImage.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); this._updateBackGroundImageColor(); }, @@ -915,12 +913,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ addBackGroundImage: function () { if (this._backGroundScale9Enabled) { this._backGroundImage = cc.Scale9Sprite.create(); - this._backGroundImage.setPreferredSize(this._size); + this._backGroundImage.setPreferredSize(this._contentSize); } else { this._backGroundImage = cc.Sprite.create(); } this.addProtectedChild(this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1); - this._backGroundImage.setPosition(this._size.width / 2.0, this._size.height / 2.0); + this._backGroundImage.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, /** @@ -974,14 +972,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ break; case ccui.Layout.BG_COLOR_SOLID: this._colorRender = cc.LayerColor.create(); - this._colorRender.setContentSize(this._size); + this._colorRender.setContentSize(this._contentSize); this._colorRender.setOpacity(this._opacity); this._colorRender.setColor(this._color); this.addProtectedChild(this._colorRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1); break; case ccui.Layout.BG_COLOR_GRADIENT: this._gradientRender = cc.LayerGradient.create(cc.color(255, 0, 0, 255), cc.color(0, 255, 0, 255)); - this._gradientRender.setContentSize(this._size); + this._gradientRender.setContentSize(this._contentSize); this._gradientRender.setOpacity(this._opacity); this._gradientRender.setStartColor(this._startColor); this._gradientRender.setEndColor(this._endColor); @@ -1186,395 +1184,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._doLayoutDirty = true; }, - doLayout_LINEAR_VERTICAL: function () { - var layoutChildrenArray = this._widgetChildren; - var layoutSize = this.getSize(); - var topBoundary = layoutSize.height; - for (var i = 0; i < layoutChildrenArray.length; ++i) { - var locChild = layoutChildrenArray[i]; - if(locChild.name === "UItest"){ - void 0; - } - var locLayoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.LINEAR); - - if (locLayoutParameter) { - var locChildGravity = locLayoutParameter.getGravity(); - var locAP = locChild.getAnchorPoint(); - var locSize = locChild.getSize(); - var locFinalPosX = locAP.x * locSize.width; - var locFinalPosY = topBoundary - ((1 - locAP.y) * locSize.height); - switch (locChildGravity) { - case ccui.LinearLayoutParameter.NONE: - case ccui.LinearLayoutParameter.LEFT: - break; - case ccui.LinearLayoutParameter.RIGHT: - locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); - break; - case ccui.LinearLayoutParameter.CENTER_HORIZONTAL: - locFinalPosX = layoutSize.width / 2 - locSize.width * (0.5 - locAP.x); - break; - default: - break; - } - var locMargin = locLayoutParameter.getMargin(); - locFinalPosX += locMargin.left || 0; - locFinalPosY -= locMargin.top || 0; - locChild.setPosition(locFinalPosX, locFinalPosY); - topBoundary = locChild.getBottomBoundary() - locMargin.bottom; - } - } - }, - doLayout_LINEAR_HORIZONTAL: function () { - var layoutChildrenArray = this._widgetChildren; - var layoutSize = this.getSize(); - var leftBoundary = 0; - for (var i = 0; i < layoutChildrenArray.length; ++i) { - var locChild = layoutChildrenArray[i]; - var locLayoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.LINEAR); - - if (locLayoutParameter) { - var locChildGravity = locLayoutParameter.getGravity(); - var locAP = locChild.getAnchorPoint(); - var locSize = locChild.getSize(); - var locFinalPosX = leftBoundary + (locAP.x * locSize.width); - var locFinalPosY = layoutSize.height - (1 - locAP.y) * locSize.height; - switch (locChildGravity) { - case ccui.LinearLayoutParameter.NONE: - case ccui.LinearLayoutParameter.TOP: - break; - case ccui.LinearLayoutParameter.BOTTOM : - locFinalPosY = locAP.y * locSize.height; - break; - case ccui.LinearLayoutParameter.CENTER_VERTICAL: - locFinalPosY = layoutSize.height / 2 - locSize.height * (0.5 - locAP.y); - break; - default: - break; - } - var locMargin = locLayoutParameter.getMargin(); - locFinalPosX += locMargin.left; - locFinalPosY -= locMargin.top; - locChild.setPosition(locFinalPosX, locFinalPosY); - leftBoundary = locChild.getRightBoundary() + locMargin.right; - } - } - }, - doLayout_RELATIVE: function () { - var layoutChildrenArray = this._widgetChildren; - var length = layoutChildrenArray.length; - var unlayoutChildCount = length; - var layoutSize = this.getSize(); - - for (var i = 0; i < length; i++) { - var locChild = layoutChildrenArray[i]; - var locLayoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.RELATIVE); - locLayoutParameter._put = false; - } - - while (unlayoutChildCount > 0) { - for (var i = 0; i < length; i++) { - var locChild = layoutChildrenArray[i]; - var locLayoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.RELATIVE); - - if (locLayoutParameter) { - if (locLayoutParameter._put) { - continue; - } - var locAP = locChild.getAnchorPoint(); - var locSize = locChild.getSize(); - var locAlign = locLayoutParameter.getAlign(); - var locRelativeName = locLayoutParameter.getRelativeToWidgetName(); - var locRelativeWidget = null; - var locRelativeWidgetLP = null; - var locFinalPosX = 0; - var locFinalPosY = 0; - if (locRelativeName) { - locRelativeWidget = ccui.helper.seekWidgetByRelativeName(this, locRelativeName); - if (locRelativeWidget) { - locRelativeWidgetLP = locRelativeWidget.getLayoutParameter(ccui.LayoutParameter.RELATIVE); - } - } - switch (locAlign) { - case ccui.RelativeLayoutParameter.NONE: - case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT: - locFinalPosX = locAP.x * locSize.width; - locFinalPosY = layoutSize.height - ((1 - locAP.y) * locSize.height); - break; - case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL: - locFinalPosX = layoutSize.width * 0.5 - locSize.width * (0.5 - locAP.x); - locFinalPosY = layoutSize.height - ((1 - locAP.y) * locSize.height); - break; - case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT: - locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); - locFinalPosY = layoutSize.height - ((1 - locAP.y) * locSize.height); - break; - case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL: - locFinalPosX = locAP.x * locSize.width; - locFinalPosY = layoutSize.height * 0.5 - locSize.height * (0.5 - locAP.y); - break; - case ccui.RelativeLayoutParameter.CENTER_IN_PARENT: - locFinalPosX = layoutSize.width * 0.5 - locSize.width * (0.5 - locAP.x); - locFinalPosY = layoutSize.height * 0.5 - locSize.height * (0.5 - locAP.y); - break; - case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL: - locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); - locFinalPosY = layoutSize.height * 0.5 - locSize.height * (0.5 - locAP.y); - break; - case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM: - locFinalPosX = locAP.x * locSize.width; - locFinalPosY = locAP.y * locSize.height; - break; - case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL: - locFinalPosX = layoutSize.width * 0.5 - locSize.width * (0.5 - locAP.x); - locFinalPosY = locAP.y * locSize.height; - break; - case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM: - locFinalPosX = layoutSize.width - ((1 - locAP.x) * locSize.width); - locFinalPosY = locAP.y * locSize.height; - break; - - case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationBottom = locRelativeWidget.getTopBoundary(); - var locationLeft = locRelativeWidget.getLeftBoundary(); - locFinalPosY = locationBottom + locAP.y * locSize.height; - locFinalPosX = locationLeft + locAP.x * locSize.width; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var rbs = locRelativeWidget.getSize(); - var locationBottom = locRelativeWidget.getTopBoundary(); - - locFinalPosY = locationBottom + locAP.y * locSize.height; - locFinalPosX = locRelativeWidget.getLeftBoundary() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationBottom = locRelativeWidget.getTopBoundary(); - var locationRight = locRelativeWidget.getRightBoundary(); - locFinalPosY = locationBottom + locAP.y * locSize.height; - locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationTop = locRelativeWidget.getTopBoundary(); - var locationRight = locRelativeWidget.getLeftBoundary(); - locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; - locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var rbs = locRelativeWidget.getSize(); - var locationRight = locRelativeWidget.getLeftBoundary(); - locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; - - locFinalPosY = locRelativeWidget.getBottomBoundary() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationBottom = locRelativeWidget.getBottomBoundary(); - var locationRight = locRelativeWidget.getLeftBoundary(); - locFinalPosY = locationBottom + locAP.y * locSize.height; - locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationTop = locRelativeWidget.getTopBoundary(); - var locationLeft = locRelativeWidget.getRightBoundary(); - locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; - locFinalPosX = locationLeft + locAP.x * locSize.width; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var rbs = locRelativeWidget.getSize(); - var locationLeft = locRelativeWidget.getRightBoundary(); - locFinalPosX = locationLeft + locAP.x * locSize.width; - - locFinalPosY = locRelativeWidget.getBottomBoundary() + rbs.height * 0.5 + locAP.y * locSize.height - locSize.height * 0.5; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationBottom = locRelativeWidget.getBottomBoundary(); - var locationLeft = locRelativeWidget.getRightBoundary(); - locFinalPosY = locationBottom + locAP.y * locSize.height; - locFinalPosX = locationLeft + locAP.x * locSize.width; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationTop = locRelativeWidget.getBottomBoundary(); - var locationLeft = locRelativeWidget.getLeftBoundary(); - locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; - locFinalPosX = locationLeft + locAP.x * locSize.width; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var rbs = locRelativeWidget.getSize(); - var locationTop = locRelativeWidget.getBottomBoundary(); - - locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; - locFinalPosX = locRelativeWidget.getLeftBoundary() + rbs.width * 0.5 + locAP.x * locSize.width - locSize.width * 0.5; - } - break; - case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN: - if (locRelativeWidget) { - if (locRelativeWidgetLP && !locRelativeWidgetLP._put) { - continue; - } - var locationTop = locRelativeWidget.getBottomBoundary(); - var locationRight = locRelativeWidget.getRightBoundary(); - locFinalPosY = locationTop - (1 - locAP.y) * locSize.height; - locFinalPosX = locationRight - (1 - locAP.x) * locSize.width; - } - break; - default: - break; - } - var locRelativeWidgetMargin, locRelativeWidgetLPAlign; - var locMargin = locLayoutParameter.getMargin(); - if (locRelativeWidgetLP) { - locRelativeWidgetMargin = locRelativeWidgetLP.getMargin(); - locRelativeWidgetLPAlign = locRelativeWidgetLP.getAlign(); - } - //handle margin - switch (locAlign) { - case ccui.RelativeLayoutParameter.NONE: - case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT: - locFinalPosX += locMargin.left; - locFinalPosY -= locMargin.top; - break; - case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL: - locFinalPosY -= locMargin.top; - break; - case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT: - locFinalPosX -= locMargin.right; - locFinalPosY -= locMargin.top; - break; - case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL: - locFinalPosX += locMargin.left; - break; - case ccui.RelativeLayoutParameter.CENTER_IN_PARENT: - break; - case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL: - locFinalPosX -= locMargin.right; - break; - case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM: - locFinalPosX += locMargin.left; - locFinalPosY += locMargin.bottom; - break; - case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL: - locFinalPosY += locMargin.bottom; - break; - case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM: - locFinalPosX -= locMargin.right; - locFinalPosY += locMargin.bottom; - break; - - case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN: - locFinalPosY += locMargin.bottom; - if (locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL - && locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.PARENT_TOP_LEFT - && locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.NONE - && locRelativeWidgetLPAlign != ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT) { - locFinalPosY += locRelativeWidgetMargin.top; - } - locFinalPosX += locMargin.left; - locFinalPosX += locMargin.left; - break; - case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER: - locFinalPosY += locMargin.bottom; - break; - case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN: - locFinalPosY += locMargin.bottom; - locFinalPosX -= locMargin.right; - break; - case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN: - locFinalPosX -= locMargin.right; - locFinalPosY -= locMargin.top; - break; - case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER: - locFinalPosX -= locMargin.right; - break; - case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN: - locFinalPosX -= locMargin.right; - locFinalPosY += locMargin.bottom; - break; - break; - case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN: - locFinalPosX += locMargin.left; - locFinalPosY -= locMargin.top; - break; - case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER: - locFinalPosX += locMargin.left; - break; - case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN: - locFinalPosX += locMargin.left; - locFinalPosY += locMargin.bottom; - break; - case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN: - locFinalPosY -= locMargin.top; - locFinalPosX += locMargin.left; - break; - case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER: - locFinalPosY -= locMargin.top; - break; - case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN: - locFinalPosY -= locMargin.top; - locFinalPosX -= locMargin.right; - break; - default: - break; - } - locChild.setPosition(cc.p(locFinalPosX, locFinalPosY)); - locLayoutParameter._put = true; - unlayoutChildCount--; - } - } - } - }, - _doLayout: function () { if (!this._doLayoutDirty) return; @@ -1602,7 +1211,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _getLayoutContentSize: function(){ - return this.getSize(); + return this.getContentSize(); }, _getLayoutElements: function(){ @@ -1697,16 +1306,22 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _getLayoutAccumulatedSize: function(){ var children = this.getChildren(); var layoutSize = cc.size(0, 0); - var widgetCount =0; + var widgetCount = 0, locSize; for(var i = 0, len = children.length; i < len; i++) { var layout = children[i]; - if (null != layout && layout instanceof ccui.Layout) - layoutSize = layoutSize + layout._getLayoutAccumulatedSize(); - else { + if (null != layout && layout instanceof ccui.Layout){ + locSize = layout._getLayoutAccumulatedSize(); + layoutSize.width += locSize.width; + layoutSize.height += locSize.height; + // C++ layoutSize = layoutSize + layout.getLayoutAccumulatedSize(); + } else { if (layout instanceof ccui.Widget) { widgetCount++; var m = w.getLayoutParameter().getMargin(); - layoutSize = layoutSize + w.getSize() + cc.size(m.right + m.left, m.top + m.bottom) * 0.5; + locSize = w.getContentSize(); + // c++ layoutSize = layoutSize + w.getContentSize() + cc.size(m.right + m.left, m.top + m.bottom) * 0.5; + layoutSize.width += locSize.width + (m.right + m.left) * 0.5; + layoutSize.height += locSize.height + (m.top + m.bottom) * 0.5; } } } @@ -1900,8 +1515,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _getWorldCenterPoint: function(widget){ //FIXEDME: we don't need to calculate the content size of layout anymore - var widgetSize = widget instanceof ccui.Layout ? widget._getLayoutAccumulatedSize() : widget.getSize(); - // CCLOG("contnet size : width = %f, height = %f", widgetSize.width, widgetSize.height); + var widgetSize = widget instanceof ccui.Layout ? widget._getLayoutAccumulatedSize() : widget.getContentSize(); return widget.convertToWorldSpace(cc.p(widgetSize.width /2, widgetSize.height /2)); }, diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index 080603d7be..b4cbf2d907 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -60,7 +60,7 @@ ccui.LinearVerticalLayoutManager = ccui.LayoutManager.extend({ finalPosX += mg.left; finalPosY -= mg.top; child.setPosition(finalPosX, finalPosY); - topBoundary = child.getPositionX() - child.getAnchorPoint().y * child.getContentSize().height - mg.bottom; + topBoundary = child.getPositionY() - child.getAnchorPoint().y * child.getContentSize().height - mg.bottom; } } } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 260c8aa033..9d9c058a98 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -61,7 +61,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ init: function () { if (ccui.ScrollView.prototype.init.call(this)) { -// this._items = []; this.setLayoutType(ccui.Layout.LINEAR_VERTICAL); return true; } @@ -109,13 +108,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, remedyLayoutParameter: function (item) { - if (!item) { + if (!item) return; - } switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: var llp = item.getLayoutParameter(); -// var llp = item.getLayoutParameter(ccui.LayoutParameter.LINEAR); if (!llp) { var defaultLp = ccui.LinearLayoutParameter.create(); switch (this._gravity) { @@ -131,21 +128,16 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ default: break; } - if (this.getIndex(item) == 0) { + if (this.getIndex(item) == 0) defaultLp.setMargin(ccui.MarginZero()); - } - else { + else defaultLp.setMargin(new ccui.Margin(0.0, this._itemsMargin, 0.0, 0.0)); - } item.setLayoutParameter(defaultLp); - } - else { - if (this.getIndex(item) == 0) { + } else { + if (this.getIndex(item) == 0) llp.setMargin(ccui.MarginZero()); - } - else { + else llp.setMargin(new ccui.Margin(0, this._itemsMargin, 0, 0)); - } switch (this._gravity) { case ccui.ListView.GRAVITY_LEFT: llp.setGravity(ccui.LinearLayoutParameter.LEFT); @@ -162,7 +154,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } break; case ccui.ScrollView.DIR_HORIZONTAL: -// var llp = item.getLayoutParameter(ccui.LayoutParameter.LINEAR); var llp = item.getLayoutParameter(); if (!llp) { var defaultLp = ccui.LinearLayoutParameter.create(); @@ -179,21 +170,16 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ default: break; } - if (this.getIndex(item) == 0) { + if (this.getIndex(item) == 0) defaultLp.setMargin(ccui.MarginZero()); - } - else { + else defaultLp.setMargin(new ccui.Margin(this._itemsMargin, 0.0, 0.0, 0.0)); - } item.setLayoutParameter(defaultLp); - } - else { - if (this.getIndex(item) == 0) { + } else { + if (this.getIndex(item) == 0) llp.setMargin(ccui.MarginZero()); - } - else { + else llp.setMargin(new ccui.Margin(this._itemsMargin, 0.0, 0.0, 0.0)); - } switch (this._gravity) { case ccui.ListView.GRAVITY_TOP: llp.setGravity(ccui.LinearLayoutParameter.TOP); @@ -222,7 +208,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ return; } var newItem = this._model.clone(); -// this._items.push(newItem); this.remedyLayoutParameter(newItem); this.addChild(newItem); this._refreshViewDirty = true; @@ -238,8 +223,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } var newItem = this._model.clone(); this._items.splice(index, 0, newItem); - this.addChild(newItem); - + ccui.ScrollView.prototype.addChild.call(this, newItem); this.remedyLayoutParameter(newItem); this._refreshViewDirty = true; @@ -250,7 +234,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {ccui.Widget} item */ pushBackCustomItem: function (item) { -// this._items.push(item); this.remedyLayoutParameter(item); this.addChild(item); this._refreshViewDirty = true; @@ -268,12 +251,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ removeChild: function(widget, cleaup){ if (widget) { var index = this._items.indexOf(widget); - if(index > -1){ + if(index > -1) this._items.splice(index, 1); - } + ccui.ScrollView.prototype.removeChild.call(this, widget, cleaup); } - - ccui.ScrollView.prototype.removeChild.call(this, widget, cleaup); }, removeAllChildren: function(){ @@ -293,9 +274,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ insertCustomItem: function (item, index) { this._items.splice(index, 0, item); ccui.ScrollView.prototype.addChild.call(this, item); - this.remedyLayoutParameter(item); -// this.addChild(item); this._refreshViewDirty = true; }, @@ -305,10 +284,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ */ removeItem: function (index) { var item = this.getItem(index); - if (!item) { + if (!item) return; - } -// cc.arrayRemoveObject(this._items, item); this.removeChild(item); this._refreshViewDirty = true; }, @@ -404,7 +381,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ break; } ccui.ScrollView.prototype.setDirection.call(this, dir); - }, /** @@ -425,7 +401,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ _doLayout: function(){ ccui.Layout.prototype._doLayout.call(this); - if (this._refreshViewDirty) { this.refreshView(); this._refreshViewDirty = false; @@ -447,27 +422,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, selectedItemEvent: function (event) { - if(this._listViewEventSelector&&this._listViewEventListener){ - - switch(state){ - case 0: - if (this._listViewEventListener && this._listViewEventSelector) - this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_START); - - if(this._eventCallback) - this._eventCallback(this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_START); - - break; - default: - if (this._listViewEventListener && this._listViewEventSelector) - this._listViewEventSelector.call(this._listViewEventListener, this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_END); - - if (this._eventCallback) - this._eventCallback(this, ccui.ListView.LISTVIEW_ONSELECTEDITEM_END); - - break; - } - } + var eventEnum = (event == ccui.Widget.TOUCH_BAGAN) ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END; + if (this._listViewEventListener && this._listViewEventSelector) + this._listViewEventSelector.call(this._listViewEventListener, this, eventEnum); + if(this._eventCallback) + this._eventCallback(this, eventEnum); }, interceptTouchEvent: function (handleState, sender, touchPoint) { @@ -481,9 +440,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } parent = parent.getParent(); } - if (sender.isHighlighted()) { + if (sender.isHighlighted()) this.selectedItemEvent(handleState); - } } }, @@ -495,14 +453,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ return this._curSelectedIndex; }, -// sortAllChildren: function () { -// ccui.ScrollView.prototype.sortAllChildren.call(this); -// if (this._refreshViewDirty) { -// this.refreshView(); -// this._refreshViewDirty = false; -// } -// }, - onSizeChanged: function () { ccui.ScrollView.prototype.onSizeChanged.call(this); this._refreshViewDirty = true; @@ -556,8 +506,8 @@ ccui.ListView.create = function () { //listView event type ccui.ListView.EVENT_SELECTED_ITEM = 0; -ccui.LISTVIEW_ONSELECTEDITEM_START = 0; -ccui.LISTVIEW_ONSELECTEDITEM_END = 1; +ccui.ListView.ON_SELECTED_ITEM_START = 0; +ccui.ListView.ON_SELECTED_ITEM_END = 1; //listView gravity ccui.ListView.GRAVITY_LEFT = 0; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index f2bfb391a0..ae7a8fae35 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -151,7 +151,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ onSizeChanged: function () { ccui.Layout.prototype.onSizeChanged.call(this); - var locSize = this._size; + var locSize = this._contentSize; this._topBoundary = locSize.height; this._rightBoundary = locSize.width; var bounceBoundaryParameterX = locSize.width / 3; @@ -159,14 +159,14 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._bounceTopBoundary = locSize.height - bounceBoundaryParameterY; this._bounceBottomBoundary = bounceBoundaryParameterY; this._bounceLeftBoundary = bounceBoundaryParameterX; - this._bounceRightBoundary = this._size.width - bounceBoundaryParameterX; - var innerSize = this._innerContainer.getSize(); + this._bounceRightBoundary = this._contentSize.width - bounceBoundaryParameterX; + var innerSize = this._innerContainer.getContentSize(); var orginInnerSizeWidth = innerSize.width; var orginInnerSizeHeight = innerSize.height; var innerSizeWidth = Math.max(orginInnerSizeWidth, locSize.width); var innerSizeHeight = Math.max(orginInnerSizeHeight, locSize.height); - this._innerContainer.setSize(cc.size(innerSizeWidth, innerSizeHeight)); - this._innerContainer.setPosition(0, locSize.height - this._innerContainer.getSize().height); + this._innerContainer.setContentSize(cc.size(innerSizeWidth, innerSizeHeight)); + this._innerContainer.setPosition(0, locSize.height - this._innerContainer.getContentSize().height); }, /** @@ -175,10 +175,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {cc.Size} size inner container size. */ setInnerContainerSize: function (size) { - var locSize = this._size; + var locSize = this._contentSize; var innerSizeWidth = locSize.width; var innerSizeHeight = locSize.height; - var originalInnerSize = this._innerContainer.getSize(); + var originalInnerSize = this._innerContainer.getContentSize(); if (size.width < locSize.width) cc.log("Inner width <= scrollview width, it will be force sized!"); else @@ -193,19 +193,19 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var newInnerSize, offset; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: - newInnerSize = this._innerContainer.getSize(); + newInnerSize = this._innerContainer.getContentSize(); offset = originalInnerSize.height - newInnerSize.height; this.scrollChildren(0, offset); break; case ccui.ScrollView.DIR_HORIZONTAL: if (this._innerContainer.getRightBoundary() <= locSize.width) { - newInnerSize = this._innerContainer.getSize(); + newInnerSize = this._innerContainer.getContentSize(); offset = originalInnerSize.width - newInnerSize.width; this.scrollChildren(offset, 0); } break; case ccui.ScrollView.DIR_BOTH: - newInnerSize = this._innerContainer.getSize(); + newInnerSize = this._innerContainer.getContentSize(); var offsetY = originalInnerSize.height - newInnerSize.height; var offsetX = 0; if (this._innerContainer.getRightBoundary() <= locSize.width) @@ -216,7 +216,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; } var innerContainer = this._innerContainer; - var innerSize = innerContainer.getSize(); + var innerSize = innerContainer.getContentSize(); var innerPos = innerContainer.getPosition(); var innerAP = innerContainer.getAnchorPoint(); if (innerContainer.getLeftBoundary() > 0.0) @@ -229,7 +229,7 @@ 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, + var locW = this._contentSize.width, innerWidth = locW, container = this._innerContainer, oldInnerWidth = container.width; @@ -258,7 +258,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } }, _setInnerHeight: function (height) { - var locH = this._size.height, + var locH = this._contentSize.height, innerHeight = locH, container = this._innerContainer, oldInnerHeight = container.height; @@ -292,7 +292,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @return inner container size. */ getInnerContainerSize: function () { - return this._innerContainer.getSize(); + return this._innerContainer.getContentSize(); }, _getInnerWidth: function () { return this._innerContainer.width; @@ -454,7 +454,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.checkNeedBounce(); } } else { - if (!this.scrollChildren(this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed, this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed)) { + if (!this.scrollChildren(this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed, + this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed)) { this.stopAutoScrollChildren(); this.checkNeedBounce(); } @@ -480,12 +481,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (this._topBounceNeeded || this._bottomBounceNeeded || this._leftBounceNeeded || this._rightBounceNeeded) { var scrollVector, orSpeed; if (this._topBounceNeeded && this._leftBounceNeeded) { - scrollVector = cc.pSub(cc.p(0.0, this._size.height), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getTopBoundary())); + scrollVector = cc.pSub(cc.p(0.0, this._contentSize.height), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getTopBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._topBounceNeeded && this._rightBounceNeeded) { - scrollVector = cc.pSub(cc.p(this._size.width, this._size.height), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getTopBoundary())); + scrollVector = cc.pSub(cc.p(this._contentSize.width, this._contentSize.height), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getTopBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); @@ -495,12 +496,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._bottomBounceNeeded && this._rightBounceNeeded) { - scrollVector = cc.pSub(cc.p(this._size.width, 0.0), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getBottomBoundary())); + scrollVector = cc.pSub(cc.p(this._contentSize.width, 0.0), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getBottomBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._topBounceNeeded) { - scrollVector = cc.pSub(cc.p(0, this._size.height), cc.p(0.0, this._innerContainer.getTopBoundary())); + scrollVector = cc.pSub(cc.p(0, this._contentSize.height), cc.p(0.0, this._innerContainer.getTopBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); @@ -515,7 +516,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); } else if (this._rightBounceNeeded) { - scrollVector = cc.pSub(cc.p(this._size.width, 0), cc.p(this._innerContainer.getRightBoundary(), 0.0)); + scrollVector = cc.pSub(cc.p(this._contentSize.width, 0), cc.p(this._innerContainer.getRightBoundary(), 0.0)); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); this.startBounceChildren(orSpeed); @@ -607,17 +608,17 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: if (dstY <= 0) - finalOffsetY = Math.max(dstY, this._size.height - this._innerContainer.getSize().height); + finalOffsetY = Math.max(dstY, this._contentSize.height - this._innerContainer.getContentSize().height); break; case ccui.ScrollView.DIR_HORIZONTAL: if (dstX <= 0) - finalOffsetX = Math.max(dstX, this._size.width - this._innerContainer.getSize().width); + finalOffsetX = Math.max(dstX, this._contentSize.width - this._innerContainer.getContentSize().width); break; case ccui.ScrollView.DIR_BOTH: if (dstY <= 0) - finalOffsetY = Math.max(dstY, this._size.height - this._innerContainer.getSize().height); + finalOffsetY = Math.max(dstY, this._contentSize.height - this._innerContainer.getContentSize().height); if (dstX <= 0) - finalOffsetX = Math.max(dstX, this._size.width - this._innerContainer.getSize().width); + finalOffsetX = Math.max(dstX, this._contentSize.width - this._innerContainer.getContentSize().width); break; default: break; @@ -879,7 +880,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollChildrenVertical: function(touchOffsetX, touchOffsetY){ var realOffset = touchOffsetY; - var scrollEnabled = false; + var scrollEnabled = true; var icBottomPos, icTopPos; if (this.bounceEnabled) { icBottomPos = this._innerContainer.getBottomBoundary(); @@ -914,7 +915,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, scrollChildrenHorizontal: function(touchOffsetX, touchOffestY){ - var scrollEnabled; + var scrollEnabled = true; var realOffset = touchOffsetX; var icRightPos, icLeftPos; if (this.bounceEnabled){ @@ -952,7 +953,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, scrollChildrenBoth: function (touchOffsetX, touchOffsetY) { - var scrollEnabled = false; + var scrollEnabled = true; var realOffsetX = touchOffsetX; var realOffsetY = touchOffsetY; var icLeftPos, icBottomPos, icRightPos, icTopPos; @@ -1147,7 +1148,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToTop: function (time, attenuated) { - this.startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), this._size.height - this._innerContainer.getSize().height), time, attenuated); + this.startAutoScrollChildrenWithDestination( + cc.p(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height), time, attenuated); }, /** @@ -1165,7 +1167,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToRight: function (time, attenuated) { - this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, this._innerContainer.getPositionY()), time, attenuated); + this.startAutoScrollChildrenWithDestination( + cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()), time, attenuated); }, /** @@ -1178,7 +1181,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.startAutoScrollChildrenWithDestination(cc.p(0, this._size.height - this._innerContainer.getSize().height), time, attenuated); + this.startAutoScrollChildrenWithDestination(cc.p(0, this._contentSize.height - this._innerContainer.getContentSize().height), time, attenuated); }, /** @@ -1191,7 +1194,9 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, this._size.height - this._innerContainer.getSize().height), time, attenuated); + var inSize = this._innerContainer.getContentSize(); + this.startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - inSize.width, + this._contentSize.height - inSize.height), time, attenuated); }, /** @@ -1217,7 +1222,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.startAutoScrollChildrenWithDestination(cc.p(this._size.width - this._innerContainer.getSize().width, 0), time, attenuated); + this.startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, 0), time, attenuated); }, /** @@ -1227,7 +1232,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToPercentVertical: function (percent, time, attenuated) { - var minY = this._size.height - this._innerContainer.getSize().height; + var minY = this._contentSize.height - this._innerContainer.getContentSize().height; var h = -minY; this.startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), minY + percent * h / 100), time, attenuated); }, @@ -1239,7 +1244,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToPercentHorizontal: function (percent, time, attenuated) { - var w = this._innerContainer.getSize().width - this._size.width; + var w = this._innerContainer.getContentSize().width - this._contentSize.width; this.startAutoScrollChildrenWithDestination(cc.p(-(percent * w / 100), this._innerContainer.getPositionY()), time, attenuated); }, @@ -1252,9 +1257,9 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollToPercentBothDirection: function (percent, time, attenuated) { if (this.direction != ccui.ScrollView.DIR_BOTH) return; - var minY = this._size.height - this._innerContainer.getSize().height; + var minY = this._contentSize.height - this._innerContainer.getContentSize().height; var h = -minY; - var w = this._innerContainer.getSize().width - this._size.width; + var w = this._innerContainer.getContentSize().width - this._contentSize.width; this.startAutoScrollChildrenWithDestination(cc.p(-(percent.x * w / 100), minY + percent.y * h / 100), time, attenuated); }, @@ -1269,7 +1274,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Move inner container to top boundary of ScrollView. */ jumpToTop: function () { - this.jumpToDestination(this._innerContainer.getPositionX(), this._size.height - this._innerContainer.getSize().height); + this.jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height); }, /** @@ -1283,7 +1288,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Move inner container to right boundary of ScrollView. */ jumpToRight: function () { - this.jumpToDestination(this._size.width - this._innerContainer.getSize().width, this._innerContainer.getPositionY()); + this.jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()); }, /** @@ -1294,7 +1299,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.jumpToDestination(0, this._size.height - this._innerContainer.getSize().height); + this.jumpToDestination(0, this._contentSize.height - this._innerContainer.getContentSize().height); }, /** @@ -1305,7 +1310,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.jumpToDestination(this._size.width - this._innerContainer.getSize().width, this._size.height - this._innerContainer.getSize().height); + var inSize = this._innerContainer.getContentSize(); + this.jumpToDestination(this._contentSize.width - inSize.width, this._contentSize.height - inSize.height); }, /** @@ -1327,14 +1333,14 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.jumpToDestination(this._size.width - this._innerContainer.getSize().width, 0); + this.jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, 0); }, /** * Move inner container to vertical percent position of ScrollView. */ jumpToPercentVertical: function (percent) { - var minY = this._size.height - this._innerContainer.getSize().height; + var minY = this._contentSize.height - this._innerContainer.getContentSize().height; var h = -minY; this.jumpToDestination(this._innerContainer.getPositionX(), minY + percent * h / 100); }, @@ -1343,7 +1349,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Move inner container to horizontal percent position of ScrollView. */ jumpToPercentHorizontal: function (percent) { - var w = this._innerContainer.getSize().width - this._size.width; + var w = this._innerContainer.getContentSize().width - this._contentSize.width; this.jumpToDestination(-(percent * w / 100), this._innerContainer.getPositionY()); }, @@ -1353,9 +1359,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ jumpToPercentBothDirection: function (percent) { if (this.direction != ccui.ScrollView.DIR_BOTH) return; - var minY = this._size.height - this._innerContainer.getSize().height; + var inSize = this._innerContainer.getContentSize(); + var minY = this._contentSize.height - inSize.height; var h = -minY; - var w = this._innerContainer.getSize().width - this._size.width; + var w = inSize.width - this._contentSize.width; this.jumpToDestination(-(percent.x * w / 100), minY + percent.y * h / 100); }, From ecc4dd49b0efc186a09e4d25f302dbbd198a8a5f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 17:17:11 +0800 Subject: [PATCH 0226/1564] Issue #5600: update UITextField --- extensions/ccui/uiwidgets/UITextField.js | 258 +++++++++++++---------- 1 file changed, 144 insertions(+), 114 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index b2a2cdb519..999faff0c1 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -54,7 +54,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ this._deleteBackward = false; }, onEnter: function () { - cc.TextFieldTTF.prototype.setDelegate(this); + cc.TextFieldTTF.prototype.setDelegate.call(this, this); // cc.TextFieldTTF.prototype.onEnter.call(this); // cc.TextFieldTTF.prototype.setDelegate.call(this, this); }, @@ -128,73 +128,73 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ return; } - if ( - (cc.sys.os == cc.sys.OS_IOS) || - (cc.sys.os == cc.sys.OS_OSX) || - (cc.sys.os == cc.sys.OS_WINDOWS) - ){ - var input_count = text.length; - var total = text_count + input_count; - - if (total > this.maxLength) - { - var end = 0; - var length = this.maxLength - text_count; - - for (var i = 0; i < length; ++i) - { - var value = text[i]; - - if (value >= 0 && value <= 127) // ascii - { - end++; - } - else - { - end += 3; - } - } - input_text = input_text.substr(0, end); - len = end; - } - }else if(cc.sys.os == cc.sys.OS_ANDROID){ - var input_count = this._calcCharCount(text); - var total = text_count + input_count; - if (total > this.maxLength) - { - var ascii = 0; - var unicode = 0; - var end = 0; - var count = 0; - - for (var i = 0; i < total * 3; ++i) - { - var value = text[i]; - - if (value >= 0 && value <= 127) // ascii - { - ascii++; - count++; - } - else - { - unicode++; - if (unicode % 3 == 0) - { - count++; - } - } - - if (count == this.maxLength) - { - break; - } - } - end = ascii + unicode; - input_text = input_text.substr(0, end); - len = end; - } - } +// if ( +// (cc.sys.os == cc.sys.OS_IOS) || +// (cc.sys.os == cc.sys.OS_OSX) || +// (cc.sys.os == cc.sys.OS_WINDOWS) +// ){ +// var input_count = text.length; +// var total = text_count + input_count; +// +// if (total > this.maxLength) +// { +// var end = 0; +// var length = this.maxLength - text_count; +// +// for (var i = 0; i < length; ++i) +// { +// var value = text[i]; +// +// if (value >= 0 && value <= 127) // ascii +// { +// end++; +// } +// else +// { +// end += 3; +// } +// } +// input_text = input_text.substr(0, end); +// len = end; +// } +// }else if(cc.sys.os == cc.sys.OS_ANDROID){ +// var input_count = this._calcCharCount(text); +// var total = text_count + input_count; +// if (total > this.maxLength) +// { +// var ascii = 0; +// var unicode = 0; +// var end = 0; +// var count = 0; +// +// for (var i = 0; i < total * 3; ++i) +// { +// var value = text[i]; +// +// if (value >= 0 && value <= 127) // ascii +// { +// ascii++; +// count++; +// } +// else +// { +// unicode++; +// if (unicode % 3 == 0) +// { +// count++; +// } +// } +// +// if (count == this.maxLength) +// { +// break; +// } +// } +// end = ascii + unicode; +// input_text = input_text.substr(0, end); +// len = end; +// } +// } } } cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); @@ -456,7 +456,7 @@ ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { * @property {Number} maxLength - The max length of the text field * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password */ -ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ +ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _textFieldRender: null, _touchWidth: 0, _touchHeight: 0, @@ -472,6 +472,7 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# _insertTextSelector: null, _deleteBackwardSelector: null, _passwordStyleText: "", + _textFieldRendererAdaptDirty: true, /** * allocates and initializes a UITextField. @@ -504,7 +505,7 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# initRenderer: function () { this._textFieldRender = ccui.UICCTextField.create("input words here", "Thonburi", 20); - cc.Node.prototype.addChild.call(this, this._textFieldRender, ccui.TextField.RENDERER_ZORDER, -1); + this.addProtectedChild(this._textFieldRender, ccui.TextField.RENDERER_ZORDER, -1); }, @@ -526,15 +527,24 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# if (this._useTouchArea) { var nsp = this.convertToNodeSpace(pt); - var bb = cc.rect(-this._touchWidth * this._anchorPoint.x, -this._touchHeight * this._anchorPoint.y, this._touchWidth, this._touchHeight); - if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) + var bb = cc.rect( + -this._touchWidth * this._anchorPoint.x, + -this._touchHeight * this._anchorPoint.y, + this._touchWidth, this._touchHeight + ); + if ( + nsp.x >= bb.origin.x && + nsp.x <= bb.origin.x + bb.size.width && + nsp.y >= bb.origin.y && + nsp.y <= bb.origin.y + bb.size.height + ) { return true; } } else { - return ccui.Widget.hitTest(pt); + return ccui.Widget.prototype.hitTest.call(this, pt); } return false; @@ -555,22 +565,7 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */ setText: function (text) { cc.log("Please use the setString"); - if (!text) { - return; - } - text = String(text); - if (this.isMaxLengthEnabled()) { - text = text.substr(0, this.getMaxLength()); - } - if (this.isPasswordEnabled()) { - this._textFieldRender.setPasswordText(text); - this._textFieldRender.insertText(text, text.length); - } - else { - this._textFieldRender.setString(text); - } - this._textFieldRender.setString(text); - this.textfieldRendererScaleChangedWithSize(); + this.setString(text); }, /** @@ -587,13 +582,15 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# } if (this.isPasswordEnabled()) { this._textFieldRender.setPasswordText(text); + this._textFieldRender.setString(""); this._textFieldRender.insertText(text, text.length); } else { this._textFieldRender.setString(text); } - this._textFieldRender.setString(text); - this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; +// this.textfieldRendererScaleChangedWithSize(); + this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); }, /** @@ -601,7 +598,9 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */ setPlaceHolder: function (value) { this._textFieldRender.setPlaceHolder(value); - this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; +// this.textfieldRendererScaleChangedWithSize(); + this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); }, /** @@ -625,8 +624,11 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# * @param {cc.Size} size */ setFontSize: function (size) { +// this._textFieldRender.setFontSize(size); +// this.textfieldRendererScaleChangedWithSize(); this._textFieldRender.setFontSize(size); - this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; + this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); }, /** @@ -634,7 +636,7 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# * @param {cc.Size} size */ getFontSize: function () { - return this._textFieldRender.getFontSize(); + return this._textFieldRender.getSystemFontSize(); }, /** @@ -642,8 +644,12 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# * @param {String} name */ setFontName: function (name) { +// this._textFieldRender.setFontName(name); +// this.textfieldRendererScaleChangedWithSize(); this._textFieldRender.setFontName(name); - this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; + this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); + }, /** @@ -651,7 +657,7 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# * @param {cc.Size} size */ getFontName: function () { - return this._textFieldRender.getFontName(); + return this._textFieldRender.getSystemFontName(); }, /** @@ -668,7 +674,7 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */ getStringValue: function () { cc.log("Please use the getString"); - return this._textFieldRender.getString(); + return this.getString(); }, /** @@ -679,12 +685,20 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# return this._textFieldRender.getString(); }, + getStringLength: function(){ + return this._textFieldRender.getStringLength(); + }, + /** * touch began * @param {cc.Point} touchPoint */ onTouchBegan: function (touchPoint) { var pass = ccui.Widget.prototype.onTouchBegan.call(this, touchPoint); + if (this._hitted) + { + this._textFieldRender.attachWithIME(); + } return pass; }, @@ -771,13 +785,17 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# this.insertTextEvent(); this.setInsertText(false); - this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; +// this.textfieldRendererScaleChangedWithSize(); + this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); } if (this.getDeleteBackward()) { this.deleteBackwardEvent(); this.setDeleteBackward(false); - this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; +// this.textfieldRendererScaleChangedWithSize(); + this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); } }, @@ -847,24 +865,36 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_ATTACH_WITH_ME); } + if (this._eventCallback) { + this._eventCallback(this, 0); + } }, detachWithIMEEvent: function () { if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DETACH_WITH_ME); } + if (this._eventCallback) { + this._eventCallback(this, 1); + } }, insertTextEvent: function () { if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT); } + if (this._eventCallback) { + this._eventCallback(this, 2); + } }, deleteBackwardEvent: function () { if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD); } + if (this._eventCallback) { + this._eventCallback(this, 3); + } }, /** @@ -877,20 +907,20 @@ ccui.LabelField = ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# this._textFieldEventListener = target; }, - /** - * check hit - * @param {cc.Point} pt - * @returns {boolean} - */ - hitTest: function (pt) { - var nsp = this.convertToNodeSpace(pt); - var locSize = this._textFieldRender.getContentSize(); - var bb = cc.rect(-locSize.width * this._anchorPoint.x, -locSize.height * this._anchorPoint.y, locSize.width, locSize.height); - if (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height) { - return true; - } - return false; - }, +// /** +// * check hit +// * @param {cc.Point} pt +// * @returns {boolean} +// */ +// hitTest: function (pt) { +// var nsp = this.convertToNodeSpace(pt); +// var locSize = this._textFieldRender.getContentSize(); +// var bb = cc.rect(-locSize.width * this._anchorPoint.x, -locSize.height * this._anchorPoint.y, locSize.width, locSize.height); +// if (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height) { +// return true; +// } +// return false; +// }, /** * override "setAnchorPoint" of widget. @@ -1056,7 +1086,7 @@ _p = null; * // example * var uiTextField = ccui.TextField.create(); */ -ccui.LabelField.create = ccui.TextField.create = function () { +ccui.TextField.create = function () { return new ccui.TextField(); }; From ec026e0bf8ee51089790b6bd1352ac3bf7529d73 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 18:20:10 +0800 Subject: [PATCH 0227/1564] Issue #5600: Fixed a bug about UITextField --- extensions/ccui/uiwidgets/UITextField.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 999faff0c1..ef198bdab8 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -42,6 +42,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ _insertText: false, _deleteBackward: false, _className: "UICCTextField", + _textFieldRendererAdaptDirty: true, ctor: function () { cc.TextFieldTTF.prototype.ctor.call(this); this.maxLengthEnabled = false; @@ -523,6 +524,14 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._useTouchArea = enable; }, + adaptRenderers: function(){ + if (this._textFieldRendererAdaptDirty) + { + this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = false; + } + }, + hitTest: function(pt){ if (this._useTouchArea) { @@ -612,7 +621,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _setFont: function (font) { this._textFieldRender._setFont(font); - this.textfieldRendererScaleChangedWithSize(); +// this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; }, _getFont: function () { @@ -947,7 +957,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); - this.textfieldRendererScaleChangedWithSize(); +// this.textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = true; }, textfieldRendererScaleChangedWithSize: function () { @@ -968,6 +979,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRender.setScaleX(scaleX); this._textFieldRender.setScaleY(scaleY); } + this._textFieldRender.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, /** From a1971ba8c82e8fae36da1593fbdbec67b5415f76 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Wed, 2 Jul 2014 18:25:32 +0800 Subject: [PATCH 0228/1564] fixed the setter bug --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index e7cf1d91ae..9673e87b0f 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -232,7 +232,7 @@ if (cc.sys._supportWebAudio) { this._volumeNode["gain"].value = volume; }); /** @expose */ - _p.ended; + _p.paused; cc.defineGetterSetter(_p, "paused", function () { return this._paused; }); From b4ce195b01d9b515caad37cf54503af539050d27 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Wed, 2 Jul 2014 19:29:52 +0800 Subject: [PATCH 0229/1564] fixed the setter bug --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index e7cf1d91ae..9673e87b0f 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -232,7 +232,7 @@ if (cc.sys._supportWebAudio) { this._volumeNode["gain"].value = volume; }); /** @expose */ - _p.ended; + _p.paused; cc.defineGetterSetter(_p, "paused", function () { return this._paused; }); From e3ed0efa5264fb127ad8d3d69b672eb168171bf6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 2 Jul 2014 20:36:35 +0800 Subject: [PATCH 0230/1564] Issue #5600: Fixed a bug about UITextField --- extensions/ccui/uiwidgets/UITextField.js | 206 ----------------------- 1 file changed, 206 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index ef198bdab8..35fa2e4cd9 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -86,32 +86,6 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ return false; }, insertText: function (text, len) { //todo need to delete -// var str_text = text; -// var locString = cc.TextFieldTTF.prototype.getString.call(this); -// var str_len = locString.length; -// var multiple, header; -// if (text != "\n") { -// if (this.maxLengthEnabled) { -// multiple = 1; -// header = text.charCodeAt(0); -// if (header < 0 || header > 127) { -// multiple = 3; -// } -// -// if (str_len + len > this.maxLength * multiple) { -// str_text = str_text.substr(0, this.maxLength * multiple); -// len = this.maxLength * multiple; -// } -// } -// } -// cc.TextFieldTTF.prototype.insertText.call(this, str_text, len); -// -// // password -// if (this.passwordEnabled) { -// if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) { -// this.setPasswordText(this._inputText); -// } -// } var input_text = text; if (text != "\n") @@ -128,74 +102,6 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ } return; } - -// if ( -// (cc.sys.os == cc.sys.OS_IOS) || -// (cc.sys.os == cc.sys.OS_OSX) || -// (cc.sys.os == cc.sys.OS_WINDOWS) -// ){ -// var input_count = text.length; -// var total = text_count + input_count; -// -// if (total > this.maxLength) -// { -// var end = 0; -// var length = this.maxLength - text_count; -// -// for (var i = 0; i < length; ++i) -// { -// var value = text[i]; -// -// if (value >= 0 && value <= 127) // ascii -// { -// end++; -// } -// else -// { -// end += 3; -// } -// } -// input_text = input_text.substr(0, end); -// len = end; -// } -// }else if(cc.sys.os == cc.sys.OS_ANDROID){ -// var input_count = this._calcCharCount(text); -// var total = text_count + input_count; -// if (total > this.maxLength) -// { -// var ascii = 0; -// var unicode = 0; -// var end = 0; -// var count = 0; -// -// for (var i = 0; i < total * 3; ++i) -// { -// var value = text[i]; -// -// if (value >= 0 && value <= 127) // ascii -// { -// ascii++; -// count++; -// } -// else -// { -// unicode++; -// if (unicode % 3 == 0) -// { -// count++; -// } -// } -// -// if (count == this.maxLength) -// { -// break; -// } -// } -// end = ascii + unicode; -// input_text = input_text.substr(0, end); -// len = end; -// } -// } } } cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); @@ -324,109 +230,6 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ } return n; }, - - insertText: function(text, len){ -// var input_text = text; -// -// if (text !== "\n") -// { -// if (this.maxLengthEnabled) -// { -// var text_count = this._calcCharCount(this.getString()); -// if (text_count >= this._maxLength) -// { -// // password -// if (this.passwordEnabled) -// { -// this.setPasswordText(this.getString()); -// } -// return; -// } -// -// if ( -// (cc.sys.os == cc.sys.OS_IOS) || -// (cc.sys.os == cc.sys.OS_OSX) || -// (cc.sys.os == cc.sys.OS_WINDOWS) -// ) -// var input_count = this._calcCharCount(text); -// var total = text_count + input_count; -// -// if (total > this._maxLength) -// { -// var end = 0; -// var length = this._maxLength - text_count; -// -// for (var i = 0; i < length; ++i) -// { -// var value = text[i]; -// -// if (value >= 0 && value <= 127) // ascii -// { -// end++; -// } -// else -// { -// end += 3; -// } -// } -// input_text = input_text.substr(0, end); -// len = end; -// } -// else if (cc.sys.os == cc.sys.OS_ANDROID) -// { -// var input_count = this._calcCharCount(text); -// if (input_count > this._maxLength) -// { -// var ascii = 0; -// var unicode = 0; -// var end = 0; -// var count = 0; -// -// for (var i = 0; i < input_count * 3; ++i) -// { -// var value = text[i]; -// -// if (value >= 0 && value <= 127) // ascii -// { -// ascii++; -// count++; -// } -// else -// { -// unicode++; -// if (unicode % 3 == 0) -// { -// count++; -// } -// } -// -// if (count == this._maxLength) -// { -// break; -// } -// } -// end = ascii + unicode; -// input_text = input_text.substr(0, end); -// len = end; -// } -// } -// } -// } -// cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); -// -// // password -// if (this.passwordEnabled && (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0)) -// this.setPasswordText(this.getString()); - // password - if (this._passwordEnabled) - { - if (cc.TextFieldTTF.prototype.getCharCount() > 0) - { - this.setPasswordText(this.getString()); - } - } - - }, onDraw: function (sender) { return false; } @@ -712,15 +515,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ return pass; }, - /** - * touch ended - * @param touchPoint - */ - onTouchEnded: function (touchPoint) { - ccui.Widget.prototype.onTouchEnded.call(this, touchPoint); - this._textFieldRender.attachWithIME(); - }, - /** * @param {Boolean} enable */ From e8747e17cb9bb7aeef6fc192f61b5c06054e553f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 2 Jul 2014 23:11:16 +0800 Subject: [PATCH 0231/1564] Release #5636: Update engine version --- cocos2d/core/platform/CCConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 21627f37d4..e16d41eaad 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -33,7 +33,7 @@ * @constant * @type String */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 beta"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-html5 v3.0 RC0"; /** *

From 69fc317999e3df55c8f588ab0995dd448f61bc58 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 3 Jul 2014 09:33:07 +0800 Subject: [PATCH 0232/1564] Release #5636: Update build.xml for closure compiler --- tools/build.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/build.xml b/tools/build.xml index 8afae20eab..11128fb1ee 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,8 +5,8 @@ classpath="./compiler/compiler.jar"/> - + debug="false" output="./../lib/cocos2d-html5-v3.0-rc0-min.js"> + @@ -164,7 +164,7 @@ - + @@ -236,8 +236,8 @@ - + debug="false" output="./../lib/cocos2d-html5-v3.0-rc0-core-min.js"> + From 7adf252a209be9006f3313b10febd03211c6b6e4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 3 Jul 2014 10:17:25 +0800 Subject: [PATCH 0233/1564] Release #5636: Update authors --- AUTHORS.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 71af13094b..dcac9ce289 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -12,7 +12,7 @@ Core Developers: Ricardo Quesada - Huabin LING + Huabin LING (pandamicro) Sijie Wang @@ -62,6 +62,7 @@ keisuke hata(Square) @Seasons7 Code review, bug fix Marat Yakupov @moadib Various bug fixes Liang Wu @akira-cn Touch location fix for designResolution + ScrollView on paused bugs fix Jimmy Sambuo @jsambuo AudioEngine improvements @@ -170,9 +171,23 @@ Bruno Assarisse @bassarisse cc.LabelBMFont bug fix musikov @musikov cc.ClippingNode bug fix cc.fontLoader bug fix + Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode + JumpTo bug with wrong _delta position bug fix Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix +AaronRZH @AaronRZH Creation of a sequence objcet or a spawn object by using new method bug fix + +Xiaodong Liu @tianxing113 cc.Spawn.create bug fix + ccui.LoadingBar.setPercent crash bug fix + +Park Hyun Chen @sincntx Touch anywhere of screen to finish input when using cc.EditBox + +Ninja Lau @mutoo A typo bug in UILayout fix + One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix + +Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode + Retired Core Developers: Shengxiang Chen (Nero Chan) Xingsen Ma From 50f865d57211f1cb3920e39c18a713c8ea81e2a6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 10:30:42 +0800 Subject: [PATCH 0234/1564] Issue #5600: UITextField bug about password and event --- extensions/ccui/uiwidgets/UITextField.js | 60 ++++-------------------- 1 file changed, 9 insertions(+), 51 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 35fa2e4cd9..fff54172dc 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -56,8 +56,6 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ }, onEnter: function () { cc.TextFieldTTF.prototype.setDelegate.call(this, this); -// cc.TextFieldTTF.prototype.onEnter.call(this); -// cc.TextFieldTTF.prototype.setDelegate.call(this, this); }, //CCTextFieldDelegate onTextFieldAttachWithIME: function (sender) { @@ -163,13 +161,8 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ this._passwordStyleText = styleText; }, setPasswordText: function (text) { -// var tempStr = ""; -// for (var i = 0; i < text.length; ++i) { -// tempStr += this._passwordStyleText; -// } -// cc.LabelTTF.prototype.setString.call(this, tempStr); var tempStr = ""; - var text_count = this._calcCharCount(text); + var text_count = text.length; var max = text_count; if (this.maxLengthEnabled) @@ -182,7 +175,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ for (var i = 0; i < max; ++i) { - tempStr.append(this._passwordStyleText); + tempStr += this._passwordStyleText; } cc.LabelTTF.prototype.setString.call(this, tempStr); @@ -218,18 +211,6 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ } return false; }, - _calcCharCount: function(pszText){ - var n = 0; - var ch = pszText; - if(!ch) { - if (0x80 != (0xC0 & ch)) - { - ++n; - } - ++pszText; - } - return n; - }, onDraw: function (sender) { return false; } @@ -318,7 +299,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {cc.Size} size */ setTouchSize: function (size) { -// this._useTouchArea = true; this._touchWidth = size.width; this._touchHeight = size.height; }, @@ -401,7 +381,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRender.setString(text); } this._textFieldRendererAdaptDirty = true; -// this.textfieldRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); }, @@ -411,7 +390,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ setPlaceHolder: function (value) { this._textFieldRender.setPlaceHolder(value); this._textFieldRendererAdaptDirty = true; -// this.textfieldRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); }, @@ -424,7 +402,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _setFont: function (font) { this._textFieldRender._setFont(font); -// this.textfieldRendererScaleChangedWithSize(); this._textFieldRendererAdaptDirty = true; }, @@ -437,8 +414,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {cc.Size} size */ setFontSize: function (size) { -// this._textFieldRender.setFontSize(size); -// this.textfieldRendererScaleChangedWithSize(); this._textFieldRender.setFontSize(size); this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); @@ -457,8 +432,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {String} name */ setFontName: function (name) { -// this._textFieldRender.setFontName(name); -// this.textfieldRendererScaleChangedWithSize(); this._textFieldRender.setFontName(name); this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); @@ -506,11 +479,14 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * touch began * @param {cc.Point} touchPoint */ - onTouchBegan: function (touchPoint) { - var pass = ccui.Widget.prototype.onTouchBegan.call(this, touchPoint); - if (this._hitted) + onTouchBegan: function (touchPoint, unusedEvent) { + var self = this; + var pass = ccui.Widget.prototype.onTouchBegan.call(self, touchPoint, unusedEvent); + if (self._hitted) { - this._textFieldRender.attachWithIME(); + setTimeout(function(){ + self._textFieldRender.attachWithIME(); + }, 0); } return pass; }, @@ -590,7 +566,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setInsertText(false); this._textFieldRendererAdaptDirty = true; -// this.textfieldRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); } if (this.getDeleteBackward()) { @@ -598,7 +573,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setDeleteBackward(false); this._textFieldRendererAdaptDirty = true; -// this.textfieldRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); } }, @@ -711,21 +685,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldEventListener = target; }, -// /** -// * check hit -// * @param {cc.Point} pt -// * @returns {boolean} -// */ -// hitTest: function (pt) { -// var nsp = this.convertToNodeSpace(pt); -// var locSize = this._textFieldRender.getContentSize(); -// var bb = cc.rect(-locSize.width * this._anchorPoint.x, -locSize.height * this._anchorPoint.y, locSize.width, locSize.height); -// if (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height) { -// return true; -// } -// return false; -// }, - /** * override "setAnchorPoint" of widget. * @param {cc.Point|Number} point The anchor point of UILabelBMFont or The anchor point.x of UILabelBMFont. @@ -751,7 +710,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ onSizeChanged: function () { ccui.Widget.prototype.onSizeChanged.call(this); -// this.textfieldRendererScaleChangedWithSize(); this._textFieldRendererAdaptDirty = true; }, From 63b07862d6d7fb5959eda63d9354e7fc03b0cef1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 10:55:44 +0800 Subject: [PATCH 0235/1564] Issue #5600: Fixed a bug that UILayout in the WebGL --- extensions/ccui/layouts/UILayout.js | 66 ++++------------------------- 1 file changed, 9 insertions(+), 57 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 446c7c28e4..a8444fa80a 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -343,18 +343,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var gl = ctx || cc._renderContext; // if stencil buffer disabled - if (cc.stencilBits < 1) { - // draw everything, as if there where no stencil - cc.Node.prototype.visit.call(this, ctx); - return; - } + /*if (cc.stencilBits < 1) { + // draw everything, as if there where no stencil + cc.Node.prototype.visit.call(this, ctx); + return; + }*/ - // return fast (draw nothing, or draw everything if in inverted mode) if: - // - nil stencil node - // - or stencil node invisible: - if (!this._clippingStencil || !this._clippingStencil.isVisible()) { + if (!this._clippingStencil || !this._clippingStencil.isVisible()) return; - } // store the current stencil layer (position in the stencil buffer), // this will allow nesting up to n CCClippingNode, @@ -374,9 +370,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return; } - /////////////////////////////////// - // INIT - // increment the current layer ccui.Layout._layer++; @@ -419,9 +412,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // only disabling depth buffer update should do gl.depthMask(false); - /////////////////////////////////// - // CLEAR STENCIL BUFFER - // manually clear the stencil buffer by drawing a fullscreen rectangle on it // setup the stencil test func like this: // for each pixel in the fullscreen rectangle @@ -435,9 +425,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ //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)); - /////////////////////////////////// - // DRAW CLIPPING STENCIL - // setup the stencil test func like this: // for each pixel in the stencil node // never draw it into the frame buffer @@ -446,34 +433,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP); - - // draw the stencil node as if it was one of our child - // (according to the stencil test func/op and alpha (or alpha shader) test) cc.kmGLPushMatrix(); this.transform(); - this._clippingStencil.visit(); - cc.kmGLPopMatrix(); - // restore alpha test state - //if (this._alphaThreshold < 1) { - // XXX: we need to find a way to restore the shaders of the stencil node and its childs - //} + this._clippingStencil.visit(); // restore the depth test state gl.depthMask(currentDepthWriteMask); - //if (currentDepthTestEnabled) { - // glEnable(GL_DEPTH_TEST); - //} - - /////////////////////////////////// - // DRAW CONTENT - // setup the stencil test func like this: - // for each pixel of this node and its childs - // if all layers less than or equals to the current are set to 1 in the stencil buffer - // draw the pixel and keep the current layer in the stencil buffer - // else - // do not draw the pixel but keep the current layer in the stencil buffer gl.stencilFunc(gl.EQUAL, mask_layer_le, mask_layer_le); gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); @@ -485,9 +452,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.sortAllProtectedChildren(); var locChildren = this._children, locProtectChildren = this._protectedChildren; var iLen = locChildren.length, jLen = locProtectChildren.length, child; - // - // draw children and protectedChildren zOrder < 0 - // for( ; i < iLen; i++ ){ child = locChildren[i]; if ( child && child.getLocalZOrder() < 0 ) @@ -495,7 +459,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ else break; } - for( ; j < jLen; j++ ) { child = locProtectChildren[j]; if ( child && child.getLocalZOrder() < 0 ) @@ -503,23 +466,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ else break; } - - // - // draw self - // this.draw(); - - // - // draw children and protectedChildren zOrder >= 0 - // for (; i < iLen; i++) locChildren[i].visit(); for (; j < jLen; j++) locProtectChildren[j].visit(); - /////////////////////////////////// - // CLEANUP - // manually restore the stencil state gl.stencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); gl.stencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); @@ -529,6 +481,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // we are done using this layer, decrement ccui.Layout._layer--; + + cc.kmGLPopMatrix(); }, _stencilClippingVisitForCanvas: function (ctx) { @@ -1790,11 +1744,9 @@ ccui.Layout._sharedCache = null; 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 { - //ccui.Layout.prototype.initStencil = ccui.Layout.prototype._initStencilForCanvas; ccui.Layout.prototype.stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; ccui.Layout.prototype.scissorClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; } From fca00d3e5fe1383c9df0aec1bd4dbbd5ca8b18e3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 11:45:03 +0800 Subject: [PATCH 0236/1564] Issue #5600: Fixed a bug that UILayout --- extensions/ccui/layouts/UILayout.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index a8444fa80a..2a8c8d356e 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -597,7 +597,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Layout.CLIPPING_STENCIL: if (able){ this._clippingStencil = cc.DrawNode.create(); - this._clippingStencil.draw = this.__stencilDraw.bind(this); + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._clippingStencil.draw = this.__stencilDraw.bind(this); if (this._running) this._clippingStencil.onEnter(); this.setStencilClippingSize(this._contentSize); From f64f50c945bf0c8408e70a2a841ec9c356b4e766 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 3 Jul 2014 11:54:03 +0800 Subject: [PATCH 0237/1564] Release #5636: Move plugin-x to external --- {extensions => external}/pluginx/Plugin.js | 0 .../pluginx/platform/facebook.js | 0 .../pluginx/platform/facebook_sdk.js | 0 moduleConfig.json | 10 +++++----- tools/build.xml | 14 -------------- 5 files changed, 5 insertions(+), 19 deletions(-) rename {extensions => external}/pluginx/Plugin.js (100%) rename {extensions => external}/pluginx/platform/facebook.js (100%) rename {extensions => external}/pluginx/platform/facebook_sdk.js (100%) diff --git a/extensions/pluginx/Plugin.js b/external/pluginx/Plugin.js similarity index 100% rename from extensions/pluginx/Plugin.js rename to external/pluginx/Plugin.js diff --git a/extensions/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js similarity index 100% rename from extensions/pluginx/platform/facebook.js rename to external/pluginx/platform/facebook.js diff --git a/extensions/pluginx/platform/facebook_sdk.js b/external/pluginx/platform/facebook_sdk.js similarity index 100% rename from extensions/pluginx/platform/facebook_sdk.js rename to external/pluginx/platform/facebook_sdk.js diff --git a/moduleConfig.json b/moduleConfig.json index 4f34899cd7..067a60578c 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -371,9 +371,9 @@ "pluginx" : [ "core", - "extensions/pluginx/Plugin.js", - "extensions/pluginx/platform/facebook_sdk.js", - "extensions/pluginx/platform/facebook.js" + "external/pluginx/Plugin.js", + "external/pluginx/platform/facebook_sdk.js", + "external/pluginx/platform/facebook.js" ], "spine":[ "core", @@ -382,7 +382,7 @@ "extensions/spine/CCSkeleton.js", "extensions/spine/CCSkeletonAnimation.js" ], - "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "pluginx", "spine","ccpool"], + "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "spine", "ccpool"], "box2d" : [ "core", "physics", @@ -397,7 +397,7 @@ "socketio" : [ "external/socketio/socket.io.min.js" ], - "external" : ["box2d", "chipmunk", "socketio"] + "external" : ["box2d", "chipmunk", "socketio", "pluginx"] }, "bootFile" : "CCBoot.js" } \ No newline at end of file diff --git a/tools/build.xml b/tools/build.xml index 11128fb1ee..d65d7b205f 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -214,20 +214,6 @@ - - - - - - - - - - - - - - From 06bc81eec9a8cffb92bbe0ec54c73ee7b68dec31 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 11:59:19 +0800 Subject: [PATCH 0238/1564] Issue #5600: TODO NEW RENDERER --- extensions/ccui/layouts/UILayout.js | 60 +++-------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 2a8c8d356e..282a62fb87 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1175,75 +1175,27 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ //clipping _onBeforeVisitStencil: function(){ - /*s_layer++; - GLint mask_layer = 0x1 << s_layer; - GLint mask_layer_l = mask_layer - 1; - _mask_layer_le = mask_layer | mask_layer_l; - _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); - glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); - glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); - glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); - glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); - glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); - - glEnable(GL_STENCIL_TEST); - CHECK_GL_ERROR_DEBUG(); - glStencilMask(mask_layer); - glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); - glDepthMask(GL_FALSE); - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP); - - this.drawFullScreenQuadClearStencil(); - - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);*/ + //TODO NEW RENDERER }, _drawFullScreenQuadClearStencil:function(){ - /*Director* director = Director.getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - - director.pushMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION); - director.loadIdentityMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION); - - director.pushMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW); - director.loadIdentityMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW); - - DrawPrimitives.drawSolidRect(Vec2(-1,-1), Vec2(1,1), Color4F(1, 1, 1, 1)); - - director.popMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION); - director.popMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW);*/ + //TODO NEW RENDERER }, _onAfterDrawStencil: function(){ -/* glDepthMask(_currentDepthWriteMask); - glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);*/ + //TODO NEW RENDERER }, _onAfterVisitStencil: function(){ - /* glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); - glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); - glStencilMask(_currentStencilWriteMask); - if (!_currentStencilEnabled) - { - glDisable(GL_STENCIL_TEST); - } - s_layer--;*/ + //TODO NEW RENDERER }, _onAfterVisitScissor: function(){ - /*Rect clippingRect = getClippingRect(); - glEnable(GL_SCISSOR_TEST); - auto glview = Director.getInstance().getOpenGLView(); - glview.setScissorInPoints(clippingRect.origin.x, clippingRect.origin.y, clippingRect.size.width, clippingRect.size.height);*/ + //TODO NEW RENDERER }, _onAfterVisitScissor: function(){ - //glDisable(GL_SCISSOR_TEST); + //TODO NEW RENDERER }, _updateBackGroundImageOpacity: function(){ From 1177b51fbb21b439a4042ea0a394cdc23e7d2c52 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 12:06:32 +0800 Subject: [PATCH 0239/1564] Issue #5600: Restore code --- extensions/ccui/layouts/UILayoutParameter.js | 41 +++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 5419f762fd..4ba29fbd30 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -362,4 +362,43 @@ ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER = 17; ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN = 18; ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN = 19; ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER = 20; -ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN = 21; \ No newline at end of file +ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN = 21; + +/** + * @ignore + */ +ccui.LINEAR_GRAVITY_NONE = 0; +ccui.LINEAR_GRAVITY_LEFT = 1; +ccui.LINEAR_GRAVITY_TOP = 2; +ccui.LINEAR_GRAVITY_RIGHT = 3; +ccui.LINEAR_GRAVITY_BOTTOM = 4; +ccui.LINEAR_GRAVITY_CENTER_VERTICAL = 5; +ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL = 6; + +//RelativeAlign +ccui.RELATIVE_ALIGN_NONE = 0; +ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT = 1; +ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL = 2; +ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT = 3; +ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL = 4; +ccui.RELATIVE_ALIGN_PARENT_CENTER = 5; +ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL = 6; +ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM = 7; +ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL = 8; +ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM = 9; + +ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT = 10; +ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER = 11; +ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT = 12; + +ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP = 13; +ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER = 14; +ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM = 15; + +ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP = 16; +ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER = 17; +ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM = 18; + +ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP = 19; +ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER = 20; +ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM = 21; \ No newline at end of file From 24e264a075c16b0c9a722f57d6c00939aa26a09f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 3 Jul 2014 12:31:22 +0800 Subject: [PATCH 0240/1564] Release #5636: Separate pluginx and plugin-facebook --- moduleConfig.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/moduleConfig.json b/moduleConfig.json index 067a60578c..d0364ed985 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -371,10 +371,13 @@ "pluginx" : [ "core", - "external/pluginx/Plugin.js", + "external/pluginx/Plugin.js" + ], + "plugin-facebook" : [ "external/pluginx/platform/facebook_sdk.js", "external/pluginx/platform/facebook.js" ], + "spine":[ "core", From d1529688f978c4959b356bbf24ea42567ef712ac Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 12:33:51 +0800 Subject: [PATCH 0241/1564] Issue #5600: Fixed a bug about UICheckBox --- extensions/ccui/uiwidgets/UICheckBox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index ce18ab6be5..88a7384d40 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -72,7 +72,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ if (ccui.Widget.prototype.init.call(this)) { this._isSelected = true; this.setTouchEnabled(true); - this.setSelectedState(false); +// this.setSelectedState(false); if(backGround === undefined) this.loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType); return true; From 1b5e4ddf434473776649e3bc511a40dc3a7ab7bd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 14:38:20 +0800 Subject: [PATCH 0242/1564] Issue #5600: reader param --- extensions/ccui/layouts/UILayoutManager.js | 10 +++++----- .../cocostudio/reader/widgetreader/WidgetReader.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index b4cbf2d907..903acc4b70 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -190,7 +190,7 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ _caculateFinalPositionWithRelativeWidget: function(layout){ //TODO typo var locWidget = this._widget; var ap = locWidget.getAnchorPoint(); - var cs = locWidget.getSize(); + var cs = locWidget.getContentSize(); this._finalPositionX = 0.0; this._finalPositionY = 0.0; @@ -253,7 +253,7 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ if (relativeWidget){ if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getSize(); + var rbs = relativeWidget.getContentSize(); var locationTop = relativeWidget.getTopBoundary(); this._finalPositionY = locationTop + ap.y * cs.height; this._finalPositionX = relativeWidget.getLeftBoundary() + rbs.width * 0.5 + ap.x * cs.width - cs.width * 0.5; @@ -283,7 +283,7 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getSize(); + var rbs = relativeWidget.getContentSize(); var locationLeft = relativeWidget.getLeftBoundary(); this._finalPositionX = locationLeft - (1.0 - ap.x) * cs.width; this._finalPositionY = relativeWidget.getBottomBoundary() + rbs.height * 0.5 + ap.y * cs.height - cs.height * 0.5; @@ -313,7 +313,7 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ if (relativeWidget){ if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getSize(); + var rbs = relativeWidget.getContentSize(); var locationRight = relativeWidget.getRightBoundary(); this._finalPositionX = locationRight + ap.x * cs.width; this._finalPositionY = relativeWidget.getBottomBoundary() + rbs.height * 0.5 + ap.y * cs.height - cs.height * 0.5; @@ -343,7 +343,7 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var rbs = relativeWidget.getSize(); + var rbs = relativeWidget.getContentSize(); var locationBottom = relativeWidget.getBottomBoundary(); this._finalPositionY = locationBottom - (1.0 - ap.y) * cs.height; diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index a8738cbb7b..ee8dcc683b 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -93,7 +93,7 @@ ccs.WidgetReader = { case 2: parameter = new ccui.RelativeLayoutParameter(); var rParameter = parameter; - var relativeName = options["relativeName"]; + var relativeName = layoutParameterDic["relativeName"]; rParameter.setRelativeName(relativeName); var align = layoutParameterDic["align"]; rParameter.setAlign(align); From 165395b79aa2e002c5edfcc3a9f5eb16894aef88 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 15:14:39 +0800 Subject: [PATCH 0243/1564] Issue #5600: Fixed a bug about UILayout --- extensions/cocostudio/reader/widgetreader/WidgetReader.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index ee8dcc683b..5bf4ae9997 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -95,6 +95,8 @@ ccs.WidgetReader = { var rParameter = parameter; var relativeName = layoutParameterDic["relativeName"]; rParameter.setRelativeName(relativeName); + var relativeToName = layoutParameterDic["relativeToName"]; + rParameter.setRelativeToWidgetName(relativeToName); var align = layoutParameterDic["align"]; rParameter.setAlign(align); break; From 5cc3bf20103e9ca4418dad8e7e9bb7dee45b0136 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 3 Jul 2014 16:06:56 +0800 Subject: [PATCH 0244/1564] Release #5636: Fix issue of DirectorWebGL's viewport --- cocos2d/core/CCDirectorWebGL.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index f2be8bd5b2..5b7e0d837a 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -48,6 +48,10 @@ cc._tmp.DirectorWebGL = function () { _t.setViewport(); + var view = _t._openGLView, + ox = view._viewPortRect.x / view._scaleX, + oy = view._viewPortRect.y / view._scaleY; + switch (projection) { case cc.Director.PROJECTION_2D: cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); @@ -71,8 +75,8 @@ cc._tmp.DirectorWebGL = function () { cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLLoadIdentity(); - var eye = cc.kmVec3Fill(null, size.width / 2, size.height / 2, zeye); - var center = cc.kmVec3Fill(null, size.width / 2, size.height / 2, 0.0); + var eye = cc.kmVec3Fill(null, -ox + size.width / 2, -oy + size.height / 2, zeye); + var center = cc.kmVec3Fill(null, -ox + size.width / 2, -oy + size.height / 2, 0.0); var up = cc.kmVec3Fill(null, 0.0, 1.0, 0.0); cc.kmMat4LookAt(matrixLookup, eye, center, up); cc.kmGLMultMatrix(matrixLookup); @@ -299,9 +303,10 @@ cc._tmp.DirectorWebGL = function () { * Sets the glViewport */ _p.setViewport = function () { - if (this._openGLView) { + var view = this._openGLView; + if (view) { var locWinSizeInPoints = this._winSizeInPoints; - this._openGLView.setViewPortInPoints(0, 0, locWinSizeInPoints.width, locWinSizeInPoints.height); + view.setViewPortInPoints(-view._viewPortRect.x/view._scaleX, -view._viewPortRect.y/view._scaleY, locWinSizeInPoints.width, locWinSizeInPoints.height); } }; From f95e53cbcb1b4ad29504d68eb6b419ac8d28e913 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 3 Jul 2014 16:42:34 +0800 Subject: [PATCH 0245/1564] File mode --- external/chipmunk/chipmunk.js | 0 tools/compiler/compiler.jar | Bin 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 external/chipmunk/chipmunk.js mode change 100755 => 100644 tools/compiler/compiler.jar diff --git a/external/chipmunk/chipmunk.js b/external/chipmunk/chipmunk.js old mode 100755 new mode 100644 diff --git a/tools/compiler/compiler.jar b/tools/compiler/compiler.jar old mode 100755 new mode 100644 From 98c2351aafde6644820c88f8c563560af0733575 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 3 Jul 2014 17:35:20 +0800 Subject: [PATCH 0246/1564] Issue #5600: Advanced compression repair --- extensions/ccui/system/UIHelper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index f088e3a236..dfce55bde5 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -46,7 +46,7 @@ ccui.helper = { var length = arrayRootChildren.length; for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; - var res = this.seekWidgetByTag(child, tag); + var res = ccui.helper.seekWidgetByTag(child, tag); if (res != null) { return res; } @@ -71,7 +71,7 @@ ccui.helper = { var length = arrayRootChildren.length; for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; - var res = this.seekWidgetByName(child, name); + var res = ccui.helper.seekWidgetByName(child, name); if (res != null) { return res; } @@ -113,7 +113,7 @@ ccui.helper = { var arrayRootChildren = root.getChildren(); for (var i = 0; i < arrayRootChildren.length; i++) { var child = arrayRootChildren[i]; - var res = this.seekActionWidgetByActionTag(child, tag); + var res = ccui.helper.seekActionWidgetByActionTag(child, tag); if (res != null) { return res; } From b179aaad8adb071bcd89b962a02a262034c63d7c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 3 Jul 2014 17:54:23 +0800 Subject: [PATCH 0247/1564] Fixed #5636: update the file list of build.xml --- tools/build.xml | 5 +++++ tools/jsdoc_toolkit/build.xml | 25 ++++--------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/tools/build.xml b/tools/build.xml index d65d7b205f..282900b20f 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -54,6 +54,7 @@ + @@ -161,10 +162,14 @@ + + + + diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml index 9913c209fb..21b0d0827c 100644 --- a/tools/jsdoc_toolkit/build.xml +++ b/tools/jsdoc_toolkit/build.xml @@ -65,11 +65,6 @@ - @@ -91,7 +86,6 @@ - @@ -110,8 +104,6 @@ - @@ -128,17 +120,6 @@ - @@ -156,10 +137,14 @@ + + + + @@ -176,7 +161,6 @@ - @@ -186,7 +170,6 @@ - From d1fec776e83c71dee6a0cc265870e4933ca59d99 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 3 Jul 2014 18:57:12 +0800 Subject: [PATCH 0248/1564] Release #5636: Update change log --- CHANGELOG.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a5968b9245..ece6cf16d9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,36 @@ ChangeLog: +Cocos2d-html5-v3.0 RC0 @ July.3, 2014 + +* Added Facebook SDK plugin into Pluginx extension. +* Refactoration of gui system `ccui` for better performance, usage and maintainbility. +* Added `bake` function to `cc.Layer` to support layer baking. +* Added object pool extension: `cc.pool`. +* Added new easing functions: bezier action, quadratic actions, quartic actions, quintic actions, circle actions, cubic actions. +* Made `cc.loader` continue the counter process even if a resource failed to be loaded. +* Supported multiple property objects in `cc.Class.extend` function. +* Refactored `ccui.Widget`'s `getLeftInParent`, `getBottomInParent`, `getRightInParent`, `getTopInParent` to `getLeftBoundary`, `getBottomBoundary`, `getRightBoundary`, `getTopBoundary`. +* Refactored `cc.FadeIn.create(duration, toOpacity)` to `cc.FadeIn.create(duration)`. +* Refactroed all string access functions in `ccui` extension to `setString` and `getString`. +* Added `getContentSize` and `setContentSize` in `ccui` extension. +* Changed the default alpha value of `cc.Color` from `undefined` to 255. +* Made `cc.log` support formatted string. +* [JSB] Improved `cc.AssetsManager` with multi-thread downloading, download resuming support, compressed file support, better progression informations, possibility to retry failed assets. + +* Bugs fix: + 1. Fix bugs on creating sequence objcet or spawn object using new method. + 2. Fix a bug that `ccui.LoadingBar`'s `setPercent` function will crash when its texture is in a plist file and scale9Enabled is true. + 3. Fixed a bug of `cc.audioEngine` that it crashs when audio isn't correctly loaded and its duration is infinity. + 4. Correction of the calculation of `cc.visibleRect`. + 5. Fix `cc.Skin`'s bounding box calculation for canvas rendering. + 6. Fix an issue that `cc.TextureCache` doesn't handle loaded texture in some case. + 7. Fix an issue that texture rect could be zero sized in `initWithFile` function of `cc.Sprite`. + 8. Fix a bug on inverted ClippingNode with DrawNode as stencil in Canvas render mode. + 9. Fix a bug that `cc.SpriteFrame` didn't support initialization with texture name parameter. + 10. Fix a bug on `ccs.ArmatureAnimation`'s loop parameter. + 11. Fix a bug that `cc.JumpTo`'s `_delta` position calculation is incorrect. + 12. Fix a bug of `cc._audioLoader` that it doesn't work when it failed to load an audio file. + Cocos2d-html5-v3.0 beta @ May.23, 2014 * Refactored actions to make it more friendly and easy-to-use. From b0094e42b2e629c4ca5f9b2838a5b411b6916eba Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 4 Jul 2014 09:31:01 +0800 Subject: [PATCH 0249/1564] Fixed #5636: update the jsDoc information --- cocos2d/audio/CCAudio.js | 4 ++-- cocos2d/core/CCDirector.js | 3 +-- cocos2d/core/event-manager/CCEventManager.js | 3 +-- cocos2d/core/platform/CCEGLView.js | 4 ++-- cocos2d/core/platform/CCInputManager.js | 2 +- cocos2d/core/platform/CCSAXParser.js | 4 ++-- cocos2d/core/platform/CCScreen.js | 4 ++-- cocos2d/core/sprites/CCAnimationCache.js | 3 +-- cocos2d/core/sprites/CCSpriteFrameCache.js | 3 +-- cocos2d/core/textures/CCTextureCache.js | 4 ++-- cocos2d/particle/CCTIFFReader.js | 3 ++- cocos2d/shaders/CCShaderCache.js | 4 ++-- cocos2d/text-input/CCIMEDispatcher.js | 4 ++-- extensions/ccpool/CCPool.js | 3 +-- extensions/ccui/base-classes/UIWidget.js | 4 ++-- extensions/ccui/system/CocosGUI.js | 4 ++-- extensions/ccui/system/UIHelper.js | 3 +-- extensions/cocostudio/CocoStudio.js | 4 ++-- extensions/cocostudio/action/CCActionManager.js | 4 ++-- .../cocostudio/armature/utils/CCArmatureDataManager.js | 4 ++-- extensions/cocostudio/armature/utils/CCDataReaderHelper.js | 3 ++- .../cocostudio/armature/utils/CCSpriteFrameCacheHelper.js | 6 +++--- extensions/cocostudio/reader/GUIReader.js | 4 ++-- extensions/cocostudio/reader/SceneReader.js | 4 ++-- tools/jsdoc_toolkit/build.xml | 7 +++---- 25 files changed, 45 insertions(+), 50 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 9673e87b0f..90bbefb77a 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -251,8 +251,8 @@ if (cc.sys._supportWebAudio) { } /** - * @namespace A simple Audio Engine engine API. - * @name cc.audioEngine + * @namespace cc.audioEngine + * A simple Audio Engine engine API. */ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ _soundSupported: false, // if sound is not enabled, this engine's init() will return false diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index ee1374126b..0fe301360a 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -38,8 +38,7 @@ cc.GLToClipTransform = function (transformOut) { //---------------------------------------------------------------------------------------------------------------------- /** - * @namespace - * @name cc.director + * @namespace cc.director *

* cc.director is a singleton of DisplayLinkDirector type director.
* Since the cc.director is a singleton, you don't need to call any constructor or create functions,
diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 2d65c5e25f..e32653b4e9 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -101,8 +101,7 @@ cc.__getListenerID = function (event) { }; /** - * @namespace - * @name cc.eventManager + * @namespace cc.eventManager *

* This class manages event listener subscriptions and event dispatching.
*
diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 4439c38483..3d1222d79e 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -31,8 +31,8 @@ cc.Touches = []; cc.TouchesIntergerDict = {}; /** - * @namespace cc.view is the shared view object. - * @name cc.view + * @namespace cc.view + * cc.view is the shared view object. */ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _delegate: null, diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 02e07c7842..cf835edcb5 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -38,7 +38,7 @@ cc.UIInterfaceOrientationPortrait = 0; *

* This class manages all events of input. include: touch, mouse, accelerometer, keyboard
*

- * @namespace + * @namespace cc.inputManager */ cc.inputManager = /** @lends cc.inputManager# */{ _mousePressed: false, diff --git a/cocos2d/core/platform/CCSAXParser.js b/cocos2d/core/platform/CCSAXParser.js index fb094d205e..6e69fe20a4 100644 --- a/cocos2d/core/platform/CCSAXParser.js +++ b/cocos2d/core/platform/CCSAXParser.js @@ -25,8 +25,8 @@ ****************************************************************************/ /** - * @namespace A SAX Parser - * @name cc.saxParser + * @namespace cc.saxParser + * A SAX Parser */ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ _parser: null, diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index 3355f33dae..9ba0468030 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -25,9 +25,9 @@ ****************************************************************************/ /** - * @namespace The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + * @namespace cc.screen + * The fullscreen API provides an easy way for web content to be presented using the user's entire screen. * It's invalid on safari,QQbrowser and android browser - * @name cc.screen */ cc.screen = /** @lends cc.screen# */{ _supportsFullScreen: false, diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 5697b3fbef..22cfb05903 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -25,8 +25,7 @@ ****************************************************************************/ /** - * @namespace - * @name cc.animationCache + * @namespace cc.animationCache *

* cc.animationCache is a singleton that manages the Animations.
* It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 3f493638fb..6088c6a74a 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -25,8 +25,7 @@ ****************************************************************************/ /** - * @namespace - * @name cc.spriteFrameCache + * @namespace cc.spriteFrameCache *

* cc.spriteFrameCache is a singleton that handles the loading of the sprite frames. It saves in a cache the sprite frames.
*
diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index c60c396126..f38bed41b7 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -25,8 +25,8 @@ ****************************************************************************/ /** - * @namespace cc.textureCache is the global cache for cc.Texture2D - * @name cc.textureCache + * @namespace cc.textureCache + * cc.textureCache is the global cache for cc.Texture2D */ cc.textureCache = /** @lends cc.textureCache# */{ _textures: {}, diff --git a/cocos2d/particle/CCTIFFReader.js b/cocos2d/particle/CCTIFFReader.js index 4e24945021..3df3033e16 100644 --- a/cocos2d/particle/CCTIFFReader.js +++ b/cocos2d/particle/CCTIFFReader.js @@ -28,7 +28,8 @@ ****************************************************************************/ /** - * @namespace A tiff file reader, it can parse byte array to draw into a canvas + * @namespace cc.tiffReader + * A tiff file reader, it can parse byte array to draw into a canvas */ cc.tiffReader = /** @lends cc.tiffReader# */{ _littleEndian: false, diff --git a/cocos2d/shaders/CCShaderCache.js b/cocos2d/shaders/CCShaderCache.js index e103325f6e..5e72b8bed7 100644 --- a/cocos2d/shaders/CCShaderCache.js +++ b/cocos2d/shaders/CCShaderCache.js @@ -25,8 +25,8 @@ ****************************************************************************/ /** - * @namespace cc.shaderCache is a singleton object that stores manages GL shaders - * @name cc.shaderCache + * cc.shaderCache is a singleton object that stores manages GL shaders + * @namespace cc.shaderCache */ cc.shaderCache = /** @lends cc.shaderCache# */{ diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index df35dee6cf..e64f84393b 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -132,8 +132,8 @@ cc.IMEDelegate = cc.Class.extend(/** @lends cc.IMEDelegate# */{ }); /** - * @namespace Input Method Edit Message Dispatcher. - * @name cc.imeDispatcher + * Input Method Edit Message Dispatcher. + * @namespace cc.imeDispatcher */ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ _domInputControl:null, diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 7b19770fd6..1fc174a59f 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -25,8 +25,6 @@ ****************************************************************************/ /** - * @namespace - * @name cc.pool *

* cc.pool is a singleton object serves as an object cache pool.
* It can helps you to improve your game performance for objects which need frequent release and recreate operations
@@ -42,6 +40,7 @@ * cc.pool.putInPool(sp); * * cc.pool.getFromPool(cc.Sprite, "a.png"); + * @namespace cc.pool */ cc.pool = { _pool: {}, diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 62f9e0e07c..4bc5cf88c0 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -29,7 +29,7 @@ * var uiWidget = ccui.Widget.create(); * this.addChild(uiWidget); * @class - * @extends cc.ProtectedNode + * @extends ccui.ProtectedNode * * @property {Number} xPercent - Position x in percentage of width * @property {Number} yPercent - Position y in percentage of height @@ -46,7 +46,7 @@ * @property {String} name - The name of the widget * @property {Number} actionTag - The action tag of the widget */ -ccui.Widget = cc.ProtectedNode.extend(/** @lends ccui.Widget# */{ +ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _enabled: true, ///< Highest control of widget _bright: true, ///< is this widget bright _touchEnabled: false, ///< is this widget touch endabled diff --git a/extensions/ccui/system/CocosGUI.js b/extensions/ccui/system/CocosGUI.js index 83f75333b7..bebf832a00 100644 --- a/extensions/ccui/system/CocosGUI.js +++ b/extensions/ccui/system/CocosGUI.js @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ /** - * @namespace Base namespace of Cocos GUI - * @name ccui + * Base namespace of Cocos GUI + * @namespace ccui */ var ccui = ccui || {}; diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index dfce55bde5..4f24ed88a6 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -24,9 +24,8 @@ ****************************************************************************/ /** - * @namespace - * @name ccui.helper * UI Helper + * @namespace ccui.helper */ ccui.helper = { /** diff --git a/extensions/cocostudio/CocoStudio.js b/extensions/cocostudio/CocoStudio.js index f0febd3726..8dbf4c20f5 100644 --- a/extensions/cocostudio/CocoStudio.js +++ b/extensions/cocostudio/CocoStudio.js @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ /** - * @namespace Base namespace of cocostuidio - * @name ccs + * Base namespace of cocostuidio + * @namespace ccs */ var ccs = ccs || {}; diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index 8deeb70e36..f8eac214c6 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -24,8 +24,8 @@ ****************************************************************************/ /** - * @namespace Base singleton object for ccs.ActionManager - * @name ccs.actionManager + * Base singleton object for ccs.ActionManager + * @namespace ccs.actionManager */ ccs.actionManager = /** @lends ccs.actionManager# */{ _actionDic: {}, diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 869641a00a..25e2919262 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -35,8 +35,8 @@ ccs.RelativeData = function(){ }; /** - * @namespace Format and manage armature configuration and armature animation - * @name ccs.armatureDataManager + * Format and manage armature configuration and armature animation + * @namespace ccs.armatureDataManager */ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ _animationDatas: {}, diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index d3307cf1de..3344a31fb5 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -144,7 +144,8 @@ ccs.DataInfo = function () { }; /** - * @namespace CocoStudio data reader helper + * CocoStudio data reader helper + * @namespace ccs.dataReaderHelper */ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ _configFileList: [], diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index 93efbc3d68..4af2e58750 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -24,10 +24,10 @@ ****************************************************************************/ /** - * @namespace

- * The sprite frame cache helper + * The sprite frame cache helper + * @namespace ccs.spriteFrameCacheHelper */ -ccs.spriteFrameCacheHelper = /** @lends cc.spriteFrameCacheHelper# */ { +ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { _textureAtlasDic:{}, _imagePaths:[], diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 4d004feab6..448032ecd3 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ /** - * @namespace Base object for ccs.uiReader - * @name ccs.uiReader + * Base object for ccs.uiReader + * @namespace ccs.uiReader */ ccs.uiReader = /** @lends ccs.uiReader# */{ _filePath: "", diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index e9959824f8..1a55301526 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -24,8 +24,8 @@ ****************************************************************************/ /** - * @namespace Base singleton object for ccs.sceneReader - * @name ccs.sceneReader + * Base singleton object for ccs.sceneReader + * @namespace ccs.sceneReader */ ccs.sceneReader = /** @lends ccs.sceneReader# */{ _baseBath:"", diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml index 21b0d0827c..7989e11b42 100644 --- a/tools/jsdoc_toolkit/build.xml +++ b/tools/jsdoc_toolkit/build.xml @@ -157,10 +157,9 @@ - - - - + + + From 6c0e1ec36335ed34cf01a990f2a6dcd03d69891d Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 4 Jul 2014 10:11:18 +0800 Subject: [PATCH 0250/1564] Release #5636: Remove jsb change log --- CHANGELOG.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ece6cf16d9..8256672195 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -15,7 +15,6 @@ Cocos2d-html5-v3.0 RC0 @ July.3, 2014 * Added `getContentSize` and `setContentSize` in `ccui` extension. * Changed the default alpha value of `cc.Color` from `undefined` to 255. * Made `cc.log` support formatted string. -* [JSB] Improved `cc.AssetsManager` with multi-thread downloading, download resuming support, compressed file support, better progression informations, possibility to retry failed assets. * Bugs fix: 1. Fix bugs on creating sequence objcet or spawn object using new method. From 31b58bb342457732725af82c2e32c1829248626a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 4 Jul 2014 16:22:19 +0800 Subject: [PATCH 0251/1564] Release #5636: Update inline docs for jsdoc --- cocos2d/actions/CCActionTween.js | 10 +++- cocos2d/audio/CCAudio.js | 4 +- cocos2d/core/CCActionManager.js | 8 +-- cocos2d/core/CCCamera.js | 4 +- cocos2d/core/CCConfiguration.js | 3 +- cocos2d/core/CCDirector.js | 3 +- cocos2d/core/cocoa/CCAffineTransform.js | 25 +++++---- cocos2d/core/cocoa/CCGeometry.js | 28 +++------- cocos2d/core/event-manager/CCEventManager.js | 3 +- cocos2d/core/layers/CCLayer.js | 5 +- cocos2d/core/platform/CCClass.js | 1 + cocos2d/core/platform/CCEGLView.js | 3 +- cocos2d/core/platform/CCInputManager.js | 3 +- cocos2d/core/platform/CCSAXParser.js | 6 ++- cocos2d/core/platform/CCScreen.js | 3 +- cocos2d/core/platform/CCTypes.js | 54 ++++++------------- cocos2d/core/sprites/CCAnimationCache.js | 3 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 3 +- cocos2d/core/textures/CCTextureCache.js | 3 +- cocos2d/particle/CCTIFFReader.js | 5 +- cocos2d/shaders/CCShaderCache.js | 3 +- cocos2d/text-input/CCIMEDispatcher.js | 3 +- extensions/ccpool/CCPool.js | 5 +- extensions/ccui/system/CocosGUI.js | 5 +- extensions/ccui/system/UIHelper.js | 3 +- extensions/cocostudio/CocoStudio.js | 3 +- .../cocostudio/action/CCActionManager.js | 3 +- .../cocostudio/armature/datas/CCDatas.js | 45 ++++++++++++---- .../armature/display/CCDisplayManager.js | 4 +- .../armature/utils/CCArmatureDataManager.js | 3 +- .../armature/utils/CCDataReaderHelper.js | 3 +- .../utils/CCSpriteFrameCacheHelper.js | 3 +- .../armature/utils/CCTransformHelp.js | 8 ++- extensions/cocostudio/reader/GUIReader.js | 3 +- extensions/cocostudio/reader/SceneReader.js | 3 +- extensions/gui/scrollview/CCSorting.js | 21 +++++--- 36 files changed, 162 insertions(+), 133 deletions(-) diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index ae3b52a406..1107c3d8d4 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -29,9 +29,15 @@ * @extends cc.Class */ cc.ActionTweenDelegate = cc.Class.extend(/** @lends cc.ActionTweenDelegate */{ - updateTweenAction:function(value, key){ - } + /** + * @function + * @param value + * @param key + */ + updateTweenAction:function(value, key){ + + } }); /** diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 90bbefb77a..92b9137c40 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -251,8 +251,9 @@ if (cc.sys._supportWebAudio) { } /** - * @namespace cc.audioEngine * A simple Audio Engine engine API. + * @namespace + * @name cc.audioEngine */ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ _soundSupported: false, // if sound is not enabled, this engine's init() will return false @@ -678,7 +679,6 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { /** * Extended AudioEngine for single audio mode. - * @class */ cc.AudioEngineForSingle = cc.AudioEngine.extend({ _waitingEffIds: [], diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index 371f12be1f..3c36858180 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -51,10 +51,10 @@ cc.HashElement = cc.Class.extend(/** @lends cc.HashElement# */{ }); /** - * cc.ActionManager is a singleton that manages all the actions.
- * Normally you won't need to use this singleton directly. 99% of the cases you will use the CCNode interface, - * which uses this singleton. - * But there are some cases where you might need to use this singleton.
+ * cc.ActionManager is a class that can manage actions.
+ * Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface, + * which uses this class's singleton object. + * But there are some cases where you might need to use this class.
* Examples:
* - When you want to run an action where the target is different from a CCNode.
* - When you want to pause / resume the actions
diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js index 1f22cc11d6..a5ab2e4dc6 100644 --- a/cocos2d/core/CCCamera.js +++ b/cocos2d/core/CCCamera.js @@ -42,10 +42,8 @@ *
* - It is recommended to use it ONLY if you are going to create 3D effects. For 2D effecs, use the action CCFollow or position/scale/rotate. * *

- * @class - * @extends cc.Class */ -cc.Camera = cc.Class.extend(/** @lends cc.Action# */{ +cc.Camera = cc.Class.extend({ _eyeX:null, _eyeY:null, _eyeZ:null, diff --git a/cocos2d/core/CCConfiguration.js b/cocos2d/core/CCConfiguration.js index cdaccb93b5..8383533729 100644 --- a/cocos2d/core/CCConfiguration.js +++ b/cocos2d/core/CCConfiguration.js @@ -25,7 +25,8 @@ ****************************************************************************/ /** - * @namespace cc.configuration contains some openGL variables + * cc.configuration contains some openGL variables + * @namespace * @name cc.configuration */ cc.configuration = /** @lends cc.configuration# */{ diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 0fe301360a..1d2fc137c8 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -38,7 +38,6 @@ cc.GLToClipTransform = function (transformOut) { //---------------------------------------------------------------------------------------------------------------------- /** - * @namespace cc.director *

* cc.director is a singleton of DisplayLinkDirector type director.
* Since the cc.director is a singleton, you don't need to call any constructor or create functions,
@@ -68,6 +67,8 @@ cc.GLToClipTransform = function (transformOut) { * - Scheduled timers & drawing are synchronizes with the refresh rate of the display
* - Only supports animation intervals of 1/60 1/30 & 1/15
*

+ * @namespace + * @name cc.director */ cc.Director = cc.Class.extend(/** @lends cc.director# */{ //Variables diff --git a/cocos2d/core/cocoa/CCAffineTransform.js b/cocos2d/core/cocoa/CCAffineTransform.js index d539fa0e3a..cac9f5674e 100644 --- a/cocos2d/core/cocoa/CCAffineTransform.js +++ b/cocos2d/core/cocoa/CCAffineTransform.js @@ -25,7 +25,6 @@ ****************************************************************************/ /** - * @memberOf cc * @function * @param {Number} a * @param {Number} b @@ -44,7 +43,7 @@ cc.AffineTransform = function (a, b, c, d, tx, ty) { }; /** - * @memberOf cc + * * @function * @param {Number} a * @param {Number} b @@ -60,7 +59,7 @@ cc.AffineTransformMake = function (a, b, c, d, tx, ty) { }; /** - * @memberOf cc + * * @function * @param {cc.Point} point * @param {cc.AffineTransform} t @@ -77,7 +76,7 @@ cc._PointApplyAffineTransform = function (x, y, t) { }; /** - * @memberOf cc + * * @function * @param {cc.Size} size * @param {cc.AffineTransform} t @@ -89,7 +88,7 @@ cc.SizeApplyAffineTransform = function (size, t) { }; /** - * @memberOf cc + * * @function * @return {cc.AffineTransform} * Constructor @@ -99,7 +98,7 @@ cc.AffineTransformMakeIdentity = function () { }; /** - * @memberOf cc + * * @function * @return {cc.AffineTransform} * Constructor @@ -109,7 +108,7 @@ cc.AffineTransformIdentity = function () { }; /** - * @memberOf cc + * * @function * @param {cc.Rect} rect * @param {cc.AffineTransform} anAffineTransform @@ -159,7 +158,7 @@ cc._RectApplyAffineTransformIn = function(rect, anAffineTransform){ }; /** - * @memberOf cc + * * @function * @param {cc.AffineTransform} t * @param {Number} tx @@ -179,7 +178,7 @@ cc.AffineTransformTranslate = function (t, tx, ty) { }; /** - * @memberOf cc + * * @function * @param {cc.AffineTransform} t * @param {Number} sx @@ -192,7 +191,7 @@ cc.AffineTransformScale = function (t, sx, sy) { }; /** - * @memberOf cc + * * @function * @param {cc.AffineTransform} aTransform * @param {Number} anAngle @@ -214,7 +213,7 @@ cc.AffineTransformRotate = function (aTransform, anAngle) { /** * Concatenate `t2' to `t1' and return the result:
* t' = t1 * t2 - * @memberOf cc + * * @function * @param {cc.AffineTransform} t1 * @param {cc.AffineTransform} t2 @@ -232,7 +231,7 @@ cc.AffineTransformConcat = function (t1, t2) { /** * Return true if `t1' and `t2' are equal, false otherwise. - * @memberOf cc + * * @function * @param {cc.AffineTransform} t1 * @param {cc.AffineTransform} t2 @@ -245,7 +244,7 @@ cc.AffineTransformEqualToTransform = function (t1, t2) { /** * Get the invert value of an AffineTransform object - * @memberOf cc + * * @function * @param {cc.AffineTransform} t * @return {cc.AffineTransform} diff --git a/cocos2d/core/cocoa/CCGeometry.js b/cocos2d/core/cocoa/CCGeometry.js index ec2ad150de..7e56c5996e 100644 --- a/cocos2d/core/cocoa/CCGeometry.js +++ b/cocos2d/core/cocoa/CCGeometry.js @@ -29,12 +29,6 @@ // POINT // //-------------------------------------------------------- -/** - * @class - * @param {Number} x - * @param {Number} y - * Constructor - */ cc.Point = function (x, y) { this.x = x || 0; this.y = y || 0; @@ -42,6 +36,9 @@ cc.Point = function (x, y) { /** * Helper macro that creates a cc.Point. + * + * @class cc.Point + * @constructor * @param {Number|cc.Point} x a Number or a size object * @param {Number} y * @return {cc.Point} @@ -81,19 +78,14 @@ cc.pointEqualToPoint = function (point1, point2) { // //-------------------------------------------------------- -/** - * @class - * @param {Number} width - * @param {Number} height - * Constructor - */ cc.Size = function (width, height) { this.width = width || 0; this.height = height || 0; }; /** - * @function + * @class cc.Size + * @constructor * @param {Number|cc.Size} w width or a size object * @param {Number} h height * @return {cc.Size} @@ -133,14 +125,6 @@ cc.sizeEqualToSize = function (size1, size2) { // //-------------------------------------------------------- -/** - * @class - * @param {Number} x a Number value as x - * @param {Number} y a Number value as y - * @param {Number} width - * @param {Number} height - * Constructor - */ cc.Rect = function (x, y, width, height) { this.x = x||0; this.y = y||0; @@ -150,6 +134,8 @@ cc.Rect = function (x, y, width, height) { /** * Return a new Rect + * @class cc.Rect + * @constructor * @param {Number|cc.Rect} x a number or a rect object * @param {Number} y * @param {Number} w diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index e32653b4e9..7ab7666575 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -101,13 +101,14 @@ cc.__getListenerID = function (event) { }; /** - * @namespace cc.eventManager *

* This class manages event listener subscriptions and event dispatching.
*
* The EventListener list is managed in such a way that event listeners can be added and removed even
* from within an EventListener, while events are being dispatched. *

+ * @namespace + * @name cc.eventManager */ cc.eventManager = /** @lends cc.eventManager# */{ //Priority dirty flag diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 022da080ce..49e1b6cae2 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -48,17 +48,20 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ }, /** - * set the layer to cache all of children to a bake sprite, and draw itself by bake sprite. recommend using it in UI. + * set the layer to cache all of children to a bake sprite, and draw itself by bake sprite. recommend using it in UI. + * @function */ bake: null, /** * cancel the layer to cache all of children to a bake sprite. + * @function */ unbake: null, /** * Determines if the layer is baked. + * @function * @returns {boolean} */ isBaked: function(){ diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index a224bcc924..3f98a8af31 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -30,6 +30,7 @@ /** * @namespace + * @name cc */ var cc = cc || {}; diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 3d1222d79e..6a4dad23ba 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -31,8 +31,9 @@ cc.Touches = []; cc.TouchesIntergerDict = {}; /** - * @namespace cc.view * cc.view is the shared view object. + * @namespace + * @name cc.view */ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _delegate: null, diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index cf835edcb5..6d89064fe8 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -38,7 +38,8 @@ cc.UIInterfaceOrientationPortrait = 0; *

* This class manages all events of input. include: touch, mouse, accelerometer, keyboard
*

- * @namespace cc.inputManager + * @namespace + * @name cc.inputManager */ cc.inputManager = /** @lends cc.inputManager# */{ _mousePressed: false, diff --git a/cocos2d/core/platform/CCSAXParser.js b/cocos2d/core/platform/CCSAXParser.js index 6e69fe20a4..f3e8e57ba0 100644 --- a/cocos2d/core/platform/CCSAXParser.js +++ b/cocos2d/core/platform/CCSAXParser.js @@ -25,8 +25,9 @@ ****************************************************************************/ /** - * @namespace cc.saxParser * A SAX Parser + * @namespace + * @name cc.saxParser */ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ _parser: null, @@ -63,7 +64,8 @@ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ /** * - * @namespace A plist Parser + * A plist Parser + * @namespace * @name cc.plistParser */ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index 9ba0468030..d1661cfcff 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -25,9 +25,10 @@ ****************************************************************************/ /** - * @namespace cc.screen * The fullscreen API provides an easy way for web content to be presented using the user's entire screen. * It's invalid on safari,QQbrowser and android browser + * @namespace + * @name cc.screen */ cc.screen = /** @lends cc.screen# */{ _supportsFullScreen: false, diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 165b9f340f..5e14843fc9 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -24,14 +24,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * The color class - * @param {Number} r 0 to 255 - * @param {Number} g 0 to 255 - * @param {Number} b 0 to 255 - * @param {Number} a 0 to 255 - * @constructor - */ cc.Color = function (r, g, b, a) { this.r = r || 0; this.g = g || 0; @@ -54,6 +46,8 @@ cc.Color = function (r, g, b, a) { * * Alpha channel is optional. Default value is 255 * + * @class cc.Color + * @constructor * @param {Number|String|cc.Color} r * @param {Number} g * @param {Number} b @@ -72,6 +66,7 @@ cc.color = function (r, g, b, a) { /** * returns true if both ccColor3B are equal. Otherwise it returns false. + * @function * @param {cc.Color} color1 * @param {cc.Color} color2 * @return {Boolean} true if both ccColor3B are equal. Otherwise it returns false. @@ -90,21 +85,15 @@ cc.Acceleration = function (x, y, z, timestamp) { this.timestamp = timestamp || 0; }; -/** - * A vertex composed of 2 floats: x, y - * @Class - * @Construct - * @param {Number} x1 - * @param {Number} y1 - */ cc.Vertex2F = function (x1, y1) { this.x = x1 || 0; this.y = y1 || 0; }; /** - * helper macro that creates an Vertex2F type - * @function + * Helper macro that creates an Vertex2F type composed of 2 floats: x, y + * @class cc.Vertex2F + * @constructor * @param {Number} x * @param {Number} y * @return {cc.Vertex2F} @@ -113,14 +102,6 @@ cc.vertex2 = function (x, y) { return new cc.Vertex2F(x, y); }; -/** - * A vertex composed of 3 floats: x, y, z - * @Class - * @Construct - * @param {Number} x1 - * @param {Number} y1 - * @param {Number} z1 - */ cc.Vertex3F = function (x1, y1, z1) { this.x = x1 || 0; this.y = y1 || 0; @@ -128,8 +109,9 @@ cc.Vertex3F = function (x1, y1, z1) { }; /** - * helper macro that creates an Vertex3F type - * @function + * Helper macro that creates an Vertex3F type composed of 3 floats: x, y, z + * @class cc.Vertex3F + * @constructor * @param {Number} x * @param {Number} y * @param {Number} z @@ -139,21 +121,15 @@ cc.vertex3 = function (x, y, z) { return new cc.Vertex3F(x, y, z); }; -/** - * A texcoord composed of 2 floats: u, y - * @Class - * @Construct - * @param {Number} u1 - * @param {Number} v1 - */ cc.Tex2F = function (u1, v1) { this.u = u1 || 0; this.v = v1 || 0; }; /** - * helper macro that creates an Tex2F type - * @function + * Helper macro that creates an Tex2F type: A texcoord composed of 2 floats: u, y + * @class cc.Tex2F + * @constructor * @param {Number} u * @param {Number} v * @return {cc.Tex2F} @@ -164,8 +140,8 @@ cc.tex2 = function (u, v) { /** * Blend Function used for textures - * @Class - * @Construct + * @Class cc.BlendFunc + * @Constructor * @param {Number} src1 source blend function * @param {Number} dst1 destination blend function */ @@ -181,6 +157,7 @@ cc.blendFuncDisable = function () { /** * convert a string of color for style to Color. * e.g. "#ff06ff" to : cc.color(255,6,255) + * @function * @param {String} hex * @return {cc.Color} */ @@ -196,6 +173,7 @@ cc.hexToColor = function (hex) { /** * convert Color to a string of color for style. * e.g. cc.color(255,6,255) to : "#ff06ff" + * @function * @param {cc.Color} color * @return {String} */ diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 22cfb05903..2afc79c3ad 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -25,7 +25,6 @@ ****************************************************************************/ /** - * @namespace cc.animationCache *

* cc.animationCache is a singleton that manages the Animations.
* It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
@@ -33,6 +32,8 @@ * example
* cc.animationCache.addAnimation(animation,"animation1");
*

+ * @namespace + * @name cc.animationCache */ cc.animationCache = /** @lends cc.animationCache# */{ _animations: {}, diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 6088c6a74a..cdb47e7665 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -25,7 +25,6 @@ ****************************************************************************/ /** - * @namespace cc.spriteFrameCache *

* cc.spriteFrameCache is a singleton that handles the loading of the sprite frames. It saves in a cache the sprite frames.
*
@@ -33,6 +32,8 @@ * // add SpriteFrames to spriteFrameCache With File
* cc.spriteFrameCache.addSpriteFrames(s_grossiniPlist);
*

+ * @namespace + * @name cc.spriteFrameCache */ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ _CCNS_REG1 : /^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/, diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index f38bed41b7..a04b3dbc1e 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -25,8 +25,9 @@ ****************************************************************************/ /** - * @namespace cc.textureCache * cc.textureCache is the global cache for cc.Texture2D + * @namespace + * @name cc.textureCache */ cc.textureCache = /** @lends cc.textureCache# */{ _textures: {}, diff --git a/cocos2d/particle/CCTIFFReader.js b/cocos2d/particle/CCTIFFReader.js index 3df3033e16..0ad5120f98 100644 --- a/cocos2d/particle/CCTIFFReader.js +++ b/cocos2d/particle/CCTIFFReader.js @@ -28,8 +28,9 @@ ****************************************************************************/ /** - * @namespace cc.tiffReader * A tiff file reader, it can parse byte array to draw into a canvas + * @namespace + * @name cc.tiffReader */ cc.tiffReader = /** @lends cc.tiffReader# */{ _littleEndian: false, @@ -227,7 +228,7 @@ cc.tiffReader = /** @lends cc.tiffReader# */{ }, /** - * + * @function * @param {Array} tiffData * @param {HTMLCanvasElement} canvas * @returns {*} diff --git a/cocos2d/shaders/CCShaderCache.js b/cocos2d/shaders/CCShaderCache.js index 5e72b8bed7..00651dfe26 100644 --- a/cocos2d/shaders/CCShaderCache.js +++ b/cocos2d/shaders/CCShaderCache.js @@ -26,7 +26,8 @@ /** * cc.shaderCache is a singleton object that stores manages GL shaders - * @namespace cc.shaderCache + * @namespace + * @name cc.shaderCache */ cc.shaderCache = /** @lends cc.shaderCache# */{ diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index e64f84393b..613c7d8d77 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -133,7 +133,8 @@ cc.IMEDelegate = cc.Class.extend(/** @lends cc.IMEDelegate# */{ /** * Input Method Edit Message Dispatcher. - * @namespace cc.imeDispatcher + * @namespace + * @name cc.imeDispatcher */ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ _domInputControl:null, diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 1fc174a59f..cfd3310870 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -40,9 +40,10 @@ * cc.pool.putInPool(sp); * * cc.pool.getFromPool(cc.Sprite, "a.png"); - * @namespace cc.pool + * @namespace + * @name cc.pool */ -cc.pool = { +cc.pool = /** @lends cc.pool# */{ _pool: {}, /** diff --git a/extensions/ccui/system/CocosGUI.js b/extensions/ccui/system/CocosGUI.js index bebf832a00..52fb7a2269 100644 --- a/extensions/ccui/system/CocosGUI.js +++ b/extensions/ccui/system/CocosGUI.js @@ -23,8 +23,9 @@ THE SOFTWARE. ****************************************************************************/ /** - * Base namespace of Cocos GUI - * @namespace ccui + * Base namespace of Cocos GUI + * @namespace + * @name ccui */ var ccui = ccui || {}; diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 4f24ed88a6..0792ffabf7 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -25,7 +25,8 @@ /** * UI Helper - * @namespace ccui.helper + * @namespace + * @name ccui.helper */ ccui.helper = { /** diff --git a/extensions/cocostudio/CocoStudio.js b/extensions/cocostudio/CocoStudio.js index 8dbf4c20f5..db30e9692f 100644 --- a/extensions/cocostudio/CocoStudio.js +++ b/extensions/cocostudio/CocoStudio.js @@ -24,7 +24,8 @@ ****************************************************************************/ /** * Base namespace of cocostuidio - * @namespace ccs + * @namespace + * @name ccs */ var ccs = ccs || {}; diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index f8eac214c6..bd9979aaa6 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -25,7 +25,8 @@ /** * Base singleton object for ccs.ActionManager - * @namespace ccs.actionManager + * @namespace + * @name ccs.actionManager */ ccs.actionManager = /** @lends ccs.actionManager# */{ _actionDic: {}, diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index 3df3fe9b50..b6478b3b12 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -168,6 +168,7 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ /** * Copy data from node + * @function * @param {ccs.BaseData} node */ copy:function (node) { @@ -188,6 +189,7 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ /** * color setter + * @function * @param {cc.Color} color */ setColor:function(color){ @@ -199,6 +201,7 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ /** * color getter + * @function * @returns {cc.Color} */ getColor:function(){ @@ -207,6 +210,7 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ /** * Calculate two baseData's between value(to - from) and set to self + * @function * @param {ccs.BaseData} from * @param {ccs.BaseData} to * @param {Boolean} limit @@ -265,6 +269,7 @@ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ }, /** * change display name to texture type + * @function * @param {String} displayName * @returns {String} */ @@ -280,6 +285,7 @@ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ }, /** * copy data + * @function * @param {ccs.DisplayData} displayData */ copy:function (displayData) { @@ -301,6 +307,7 @@ ccs.SpriteDisplayData = ccs.DisplayData.extend(/** @lends ccs.SpriteDisplayData# }, /** * copy data + * @function * @param {ccs.SpriteDisplayData} displayData */ copy:function (displayData) { @@ -311,7 +318,7 @@ ccs.SpriteDisplayData = ccs.DisplayData.extend(/** @lends ccs.SpriteDisplayData# /** * Base class for ccs.ArmatureDisplayData objects. - * @class + * @class ccs.ArmatureDisplayData * @extends ccs.DisplayData */ ccs.ArmatureDisplayData = ccs.DisplayData.extend(/** @lends ccs.ArmatureDisplayData# */{ @@ -324,7 +331,7 @@ ccs.ArmatureDisplayData = ccs.DisplayData.extend(/** @lends ccs.ArmatureDisplayD /** * Base class for ccs.ParticleDisplayData objects. - * @class + * @class ccs.ParticleDisplayData * @extends ccs.DisplayData */ ccs.ParticleDisplayData = ccs.DisplayData.extend(/** @lends ccs.ParticleDisplayData# */{ @@ -335,7 +342,7 @@ ccs.ParticleDisplayData = ccs.DisplayData.extend(/** @lends ccs.ParticleDisplayD /** * Base class for ccs.BoneData objects. - * @class + * @class ccs.BoneData * @extends ccs.BaseData */ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ @@ -355,6 +362,7 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ }, /** * add display data + * @function * @param {ccs.DisplayData} displayData */ addDisplayData:function (displayData) { @@ -363,6 +371,7 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ /** * get display data + * @function * @param {Number} index * @returns {ccs.DisplayData} */ @@ -373,7 +382,7 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ /** * Base class for ccs.ArmatureData objects. - * @class + * @class ccs.ArmatureData * @extends ccs.Class */ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ @@ -390,6 +399,7 @@ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ }, /** * add bone data + * @function * @param {ccs.BoneData} boneData */ addBoneData:function (boneData) { @@ -397,6 +407,7 @@ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ }, /** * get bone datas + * @function * @returns {Object} */ getBoneDataDic:function () { @@ -404,6 +415,7 @@ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ }, /** * get bone data by bone name + * @function * @param {String} boneName * @returns {ccs.BoneData} */ @@ -414,7 +426,7 @@ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ /** * Base class for ccs.FrameData objects. - * @class + * @class ccs.FrameData * @extends ccs.BaseData */ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ @@ -448,6 +460,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ /** * copy data + * @function * @param frameData */ copy:function (frameData) { @@ -475,7 +488,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ /** * Base class for ccs.MovementBoneData objects. - * @class + * @class ccs.MovementBoneData * @extends ccs.Class */ ccs.MovementBoneData = ccs.Class.extend(/** @lends ccs.MovementBoneData# */{ @@ -496,6 +509,7 @@ ccs.MovementBoneData = ccs.Class.extend(/** @lends ccs.MovementBoneData# */{ }, /** * add frame data + * @function * @param {ccs.FrameData} frameData */ addFrameData:function (frameData) { @@ -503,6 +517,7 @@ ccs.MovementBoneData = ccs.Class.extend(/** @lends ccs.MovementBoneData# */{ }, /** * get frame data + * @function * @param {Number} index * @returns {ccs.FrameData} */ @@ -513,7 +528,7 @@ ccs.MovementBoneData = ccs.Class.extend(/** @lends ccs.MovementBoneData# */{ /** * Base class for ccs.MovementData objects. - * @class + * @class ccs.MovementData * @extends ccs.Class */ ccs.MovementData = ccs.Class.extend(/** @lends ccs.MovementData# */{ @@ -538,6 +553,7 @@ ccs.MovementData = ccs.Class.extend(/** @lends ccs.MovementData# */{ /** * add movement bone data + * @function * @param {ccs.MovementBoneData} movBoneData */ addMovementBoneData:function (movBoneData) { @@ -546,6 +562,7 @@ ccs.MovementData = ccs.Class.extend(/** @lends ccs.MovementData# */{ /** * get movement bone data + * @function * @param {String} boneName * @returns {ccs.MovementBoneData} */ @@ -556,7 +573,7 @@ ccs.MovementData = ccs.Class.extend(/** @lends ccs.MovementData# */{ /** * Base class for ccs.AnimationData objects. - * @class + * @class ccs.AnimationData * @extends ccs.Class */ ccs.AnimationData = ccs.Class.extend(/** @lends ccs.AnimationData# */{ @@ -569,6 +586,7 @@ ccs.AnimationData = ccs.Class.extend(/** @lends ccs.AnimationData# */{ }, /** * add movement data + * @function * @param {ccs.MovementData} moveData */ addMovement:function (moveData) { @@ -577,6 +595,7 @@ ccs.AnimationData = ccs.Class.extend(/** @lends ccs.AnimationData# */{ }, /** * get movement data + * @function * @param {String} moveName * @returns {ccs.MovementData} */ @@ -584,7 +603,7 @@ ccs.AnimationData = ccs.Class.extend(/** @lends ccs.AnimationData# */{ return this.moveDataDic[moveName]; }, /** - * + * @function * @returns {Number} */ getMovementCount:function () { @@ -594,6 +613,7 @@ ccs.AnimationData = ccs.Class.extend(/** @lends ccs.AnimationData# */{ /** * contour vertex + * @class ccs.ContourVertex2 * @param {Number} x * @param {Number} y * @constructor @@ -605,7 +625,7 @@ ccs.ContourVertex2 = function (x, y) { /** * Base class for ccs.ContourData objects. - * @class + * @class ccs.ContourData * @extends ccs.Class */ ccs.ContourData = ccs.Class.extend({ @@ -621,6 +641,7 @@ ccs.ContourData = ccs.Class.extend({ /** * add vertex + * @function * @param {cc.Point} p */ addVertex: function (p) { @@ -631,7 +652,7 @@ ccs.ContourData = ccs.Class.extend({ /** * Base class for ccs.TextureData objects. - * @class + * @class ccs.TextureData * @extends ccs.Class */ ccs.TextureData = ccs.Class.extend(/** @lends ccs.TextureData# */{ @@ -656,6 +677,7 @@ ccs.TextureData = ccs.Class.extend(/** @lends ccs.TextureData# */{ /** * set contourData + * @function * @param {ccs.ContourData} contourData */ addContourData:function (contourData) { @@ -664,6 +686,7 @@ ccs.TextureData = ccs.Class.extend(/** @lends ccs.TextureData# */{ /** * get contourData + * @function * @param {Number} index * @returns {ccs.ContourData} */ diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 149fa3193f..864940810b 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -25,10 +25,10 @@ /** * The display manager of CocoStudio - * @Class + * @Class ccs.DisplayManager * @extend cc.Class */ -ccs.DisplayManager = ccs.Class.extend(/** @lends cc.DisplayManager */{ +ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ _decoDisplayList:null, _currentDecoDisplay:null, _displayRenderNode:null, diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 25e2919262..63f67479f1 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -36,7 +36,8 @@ ccs.RelativeData = function(){ /** * Format and manage armature configuration and armature animation - * @namespace ccs.armatureDataManager + * @namespace + * @name ccs.armatureDataManager */ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ _animationDatas: {}, diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 3344a31fb5..68cf1ae042 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -145,7 +145,8 @@ ccs.DataInfo = function () { /** * CocoStudio data reader helper - * @namespace ccs.dataReaderHelper + * @namespace + * @name ccs.dataReaderHelper */ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ _configFileList: [], diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index 4af2e58750..1bcae9fed4 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -25,7 +25,8 @@ /** * The sprite frame cache helper - * @namespace ccs.spriteFrameCacheHelper + * @namespace + * @name ccs.spriteFrameCacheHelper */ ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { _textureAtlasDic:{}, diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index 4dea62f99a..9c95f0794d 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -24,7 +24,8 @@ ****************************************************************************/ /** - * @ignore + * @class ccs.TransformHelp + * @extend ccs.Class */ ccs.TransformHelp = ccs.TransformHelp || ccs.Class.extend({}); @@ -35,6 +36,7 @@ ccs.TransformHelp.helpPoint2 = cc.p(0, 0); /** * @function + * @static * @param {ccs.BaseData} bone * @return {cc.AffineTransform} * Constructor @@ -51,6 +53,7 @@ ccs.TransformHelp.transformFromParent = function (bone, parentBone) { /** * @function + * @static * @param {ccs.BaseData} node * @param {cc.AffineTransform} matrix */ @@ -74,6 +77,7 @@ ccs.TransformHelp.nodeToMatrix = function (node, matrix) { /** * @function + * @static * @param {cc.AffineTransform} matrix * @param {ccs.BaseData} node */ @@ -105,6 +109,7 @@ ccs.TransformHelp.matrixToNode = function (matrix, node) { /** * @function + * @static * @param {ccs.BaseData} target * @param {ccs.BaseData} source */ @@ -119,6 +124,7 @@ ccs.TransformHelp.nodeConcat = function (target, source) { /** * @function + * @static * @param {ccs.BaseData} target * @param {ccs.BaseData} source */ diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 448032ecd3..94e7881346 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -24,7 +24,8 @@ ****************************************************************************/ /** * Base object for ccs.uiReader - * @namespace ccs.uiReader + * @namespace + * @name ccs.uiReader */ ccs.uiReader = /** @lends ccs.uiReader# */{ _filePath: "", diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 1a55301526..90331eacb1 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -25,7 +25,8 @@ /** * Base singleton object for ccs.sceneReader - * @namespace ccs.sceneReader + * @namespace + * @name ccs.sceneReader */ ccs.sceneReader = /** @lends ccs.sceneReader# */{ _baseBath:"", diff --git a/extensions/gui/scrollview/CCSorting.js b/extensions/gui/scrollview/CCSorting.js index 0d9faa5c90..8d53f3c4c3 100644 --- a/extensions/gui/scrollview/CCSorting.js +++ b/extensions/gui/scrollview/CCSorting.js @@ -83,7 +83,8 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# * If the compare message does not result NSComparisonResult, sorting behavior * is not defined. It ignores duplicate entries and inserts next to it. * - * @param {object} addObject + * @function + * @param {Object} addObject Object to insert */ insertSortedObject:function (addObject) { if(!addObject) @@ -98,7 +99,8 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# * Removes an object with given key and value. If no object is found in array * with the key and value, no action is taken. * - * @param value to remove + * @function + * @param {Object} delObject Object to remove */ removeSortedObject:function (delObject) { if (this.count() == 0) { @@ -121,8 +123,9 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# * keep consistency of being sorted. If it is changed externally, it must be * sorted completely again. * - * @param value to set - * @param object the object which has the value + * @function + * @param {Number} tag Tag to set + * @param {Object} setObject The object which would be set */ setObjectID_ofSortedObject:function (tag, setObject) { var idx = this.indexOfSortedObject(setObject); @@ -158,8 +161,9 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# * Returns an object with given key and value. If no object is found, * it returns nil. * - * @param value to locate object - * @return object found or nil. + * @function + * @param {Number} tag Tag to locate object + * @return {Object|null} */ getObjectWithObjectID:function (tag) { return null; @@ -173,8 +177,9 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# * would have been located. If object must be located at the end of array, * it returns the length of the array, which is out of bound. * - * @param value to locate object - * @return index of an object found + * @function + * @param {Number} idxObj Id to locate object + * @return {Number} index of an object found */ indexOfSortedObject:function (idxObj) { var idx = 0; From d89ff6653f52045c9250886d2f13d54adec3ac12 Mon Sep 17 00:00:00 2001 From: mutoo Date: Sat, 5 Jul 2014 10:25:47 +0800 Subject: [PATCH 0252/1564] fix a transform error; --- extensions/cocostudio/armature/utils/CCTransformHelp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index 9c95f0794d..7aff58a6b8 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -69,7 +69,7 @@ ccs.TransformHelp.nodeToMatrix = function (node, matrix) { matrix.a = node.scaleX * Math.cos(node.skewY); matrix.b = node.scaleX * Math.sin(node.skewY); matrix.c = node.scaleY * Math.sin(node.skewX); - matrix.d = node.scaleY * Math.cos(node.skewY); + matrix.d = node.scaleY * Math.cos(node.skewX); } matrix.tx = node.x; matrix.ty = node.y; From d98e69fd741952253474dc1fd5db4956e544728b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 7 Jul 2014 10:07:06 +0800 Subject: [PATCH 0253/1564] Issue #5669: missing method about ccui.TextField --- extensions/ccui/uiwidgets/UIText.js | 2 +- extensions/ccui/uiwidgets/UITextField.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 61aa232c4c..fecc721ee8 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -464,7 +464,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ // }, // copySpecialProperties: function (uiLabel) { - if(uiLabel instanceof uiLabel){ + if(uiLabel instanceof ccui.Label){ this.setFontName(uiLabel._fontName); this.setFontSize(uiLabel.getFontSize()); this.setString(uiLabel.getString()); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index fff54172dc..3077cac765 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -793,6 +793,18 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setDetachWithIME(textField.getDetachWithIME()); this.setInsertText(textField.getInsertText()); this.setDeleteBackward(textField.getDeleteBackward()); + }, + + setTextAreaSize: function(size){ + this._textFieldRender.setDimensions(size.width,size.height); + }, + + setTextHorizontalAlignment: function(alignment){ + this._textFieldRender.setHorizontalAlignment(alignment); + }, + + setTextVerticalAlignment: function(alignment){ + this._textFieldRender.setVerticalAlignment(alignment); } }); From c9065b722027b2c4dfc811b75729fa5e304176f0 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 7 Jul 2014 11:18:16 +0800 Subject: [PATCH 0254/1564] Doc #5557: Add comment in CCBoot.js for redefined singletons --- CCBoot.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 1dfa85ced7..0821fbcb92 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1350,18 +1350,36 @@ cc._setup = function (el, width, height) { // Init singletons - // View + /** + * @type {cc.EGLView} + * @name cc.view + * cc.view is the shared view object. + */ cc.view = cc.EGLView._getInstance(); // register system events cc.inputManager.registerSystemEvent(cc._canvas); - // Director + /** + * @type {cc.Director} + * @name cc.director + */ cc.director = cc.Director._getInstance(); - if (cc.director.setOpenGLView)cc.director.setOpenGLView(cc.view); + if (cc.director.setOpenGLView) + cc.director.setOpenGLView(cc.view); + /** + * @type {cc.Size} + * @name cc.winSize + * cc.winSize is the alias object for the size of the current game window. + */ cc.winSize = cc.director.getWinSize(); // Parsers cc.saxParser = new cc.SAXParser(); + /** + * @type {cc.PlistParser} + * @name cc.plistParser + * A Plist Parser + */ cc.plistParser = new cc.PlistParser(); }; From 9fecfa183ff26195e449e4489760b6fcf69e9738 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 7 Jul 2014 11:24:14 +0800 Subject: [PATCH 0255/1564] Issue #5670: setText => setString --- .../reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index dc79791a06..c14bf56ebc 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -58,7 +58,7 @@ ccs.LabelBMFontReader = { } var text = options["text"]; - labelBMFont.setText(text); + labelBMFont.setString(text); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); From e3729b156a88e112bf5ab4021857ad3cdee31d24 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 7 Jul 2014 14:50:49 +0800 Subject: [PATCH 0256/1564] Issue #5670: CheckBoxReader --- .../CheckBoxReader/CheckBoxReader.js | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index cad0b311b5..fe6126fe95 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -40,21 +40,21 @@ ccs.CheckBoxReader = { var backGroundDic = options["backGroundBoxData"]; var backGroundType = backGroundDic["resourceType"]; + + var tp = jsonPath; + var backGroundFileName = backGroundDic["path"]; switch (backGroundType) { case 0: { - var tp_b = jsonPath; - var backGroundFileName = backGroundDic["path"]; - var backGroundFileName_tp = (backGroundFileName && backGroundFileName !== "") ? - tp_b + backGroundFileName : + var backGroundFileName_tp = backGroundFileName ? + tp + backGroundFileName : null; checkBox.loadTextureBackGround(backGroundFileName_tp); break; } case 1: { - var backGroundFileName = backGroundDic["path"]; checkBox.loadTextureBackGround(backGroundFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } @@ -64,21 +64,24 @@ ccs.CheckBoxReader = { var backGroundSelectedDic = options["backGroundBoxSelectedData"]; var backGroundSelectedType = backGroundSelectedDic["resourceType"]; + var backGroundSelectedFileName = backGroundSelectedDic["path"]; + if(backGroundSelectedFileName === null){ + backGroundSelectedType = backGroundType; + backGroundSelectedFileName = backGroundFileName; + } + switch (backGroundSelectedType) { case 0: { - var tp_bs = jsonPath; - var backGroundSelectedFileName = backGroundSelectedDic["path"]; - var backGroundSelectedFileName_tp = (backGroundSelectedFileName && backGroundSelectedFileName !== "") ? - tp_bs + backGroundSelectedFileName : + var backGroundSelectedFileName_tp = backGroundSelectedFileName ? + tp + backGroundSelectedFileName : null; checkBox.loadTextureBackGroundSelected(backGroundSelectedFileName_tp); break; } case 1: { - var backGroundSelectedFileName = backGroundSelectedDic["path"]; checkBox.loadTextureBackGroundSelected(backGroundSelectedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } @@ -88,21 +91,19 @@ ccs.CheckBoxReader = { var frontCrossDic = options["frontCrossData"]; var frontCrossType = frontCrossDic["resourceType"]; + var frontCrossFileName = frontCrossDic["path"]; switch (frontCrossType) { case 0: { - var tp_c = jsonPath; - var frontCrossFileName = frontCrossDic["path"]; - var frontCrossFileName_tp = (frontCrossFileName && frontCrossFileName !== "") ? - tp_c + frontCrossFileName : + var frontCrossFileName_tp = frontCrossFileName ? + tp + frontCrossFileName : null; checkBox.loadTextureFrontCross(frontCrossFileName_tp); break; } case 1: { - var frontCrossFileName = frontCrossDic["path"]; checkBox.loadTextureFrontCross(frontCrossFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } @@ -112,21 +113,19 @@ ccs.CheckBoxReader = { var backGroundDisabledDic = options["backGroundBoxDisabledData"]; var backGroundDisabledType = backGroundDisabledDic["resourceType"]; + var backGroundDisabledFileName = backGroundDisabledDic["path"]; switch (backGroundDisabledType) { case 0: { - var tp_bd = jsonPath; - var backGroundDisabledFileName = backGroundDisabledDic["path"]; - var backGroundDisabledFileName_tp = (backGroundDisabledFileName && backGroundDisabledFileName !== "") ? - tp_bd + backGroundDisabledFileName : + var backGroundDisabledFileName_tp = backGroundDisabledFileName ? + tp + backGroundDisabledFileName : null; checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); break; } case 1: { - var backGroundDisabledFileName = backGroundDisabledDic["path"]; checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } @@ -136,29 +135,26 @@ ccs.CheckBoxReader = { var frontCrossDisabledDic = options["frontCrossDisabledData"]; var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; + var frontCrossDisabledFileName = options["path"]; switch (frontCrossDisabledType) { case 0: { - var tp_cd = jsonPath; - var frontCrossDisabledFileName = options["path"]; - var frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && frontCrossDisabledFileName !== "") ? - tp_cd + frontCrossDisabledFileName : + var frontCrossDisabledFileName_tp = frontCrossDisabledFileName ? + tp + frontCrossDisabledFileName : null; checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); break; } case 1: { - var frontCrossDisabledFileName = options["path"]; checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } default: break; } - - + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file From c84528b3962995c7575212a4b1aefaacd50405ca Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 7 Jul 2014 15:23:51 +0800 Subject: [PATCH 0257/1564] Issue #5670: SliderReader --- .../widgetreader/SliderReader/SliderReader.js | 68 +++++++++---------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index 1f00049967..c0a23f408b 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -36,26 +36,28 @@ ccs.SliderReader = { var jsonPath = ccs.uiReader.getFilePath(); var slider = widget; + var tp = jsonPath; var barTextureScale9Enable = options["scale9Enable"]; slider.setScale9Enabled(barTextureScale9Enable); var bt = options["barFileName"]; var barLength = options["length"]; + + var imageFileNameDic = options["barFileNameData"]; + var imageFileType = imageFileNameDic["resourceType"]; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp; + if(bt){ if(barTextureScale9Enable){ - var imageFileNameDic = options["barFileNameData"]; - var imageFileType = options["resourceType"]; switch(imageFileType){ case 0: - var tp_b = jsonPath; - var imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = (imageFileName && imageFileName !== "" ) ? - ( tp_b + imageFileName ) : + imageFileName_tp = imageFileName ? + ( tp + imageFileName ) : null; slider.loadBarTexture(imageFileName_tp); break; case 1: - var imageFileName = imageFileNameDic["path"]; slider.loadBarTexture(imageFileName, 1 /*ui::UI_TEX_TYPE_PLIST*/); break; default: @@ -64,19 +66,14 @@ ccs.SliderReader = { slider.setSize(cc.size(barLength, slider.getContentSize().height)); } }else{ - var imageFileNameDic = options["barFileNameData"]; - var imageFileType = imageFileNameDic["resourceType"]; switch(imageFileType){ case 0: - var tp_b = jsonPath; - var imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = ( imageFileName && imageFileName !== "" ) ? - tp_b + imageFileName : + imageFileName_tp = imageFileName ? + tp + imageFileName : null; slider.loadBarTexture(imageFileName_tp); break; case 1: - var imageFileName = imageFileNameDic["path"]; slider.loadBarTexture(imageFileName, 1 /*ui::UI_TEX_TYPE_PLIST*/); break; default: @@ -85,17 +82,15 @@ ccs.SliderReader = { } var normalDic = options["ballNormalData"]; var normalType = normalDic["resourceType"]; + var normalFileName = normalDic["path"]; switch(normalType){ case 0: - var tp_n = jsonPath; - var normalFileName = normalDic["path"]; - var normalFileName_tp = ( normalFileName && (normalFileName !== "") ) ? - tp_n + normalFileName : + var normalFileName_tp = normalFileName ? + tp + normalFileName : null; slider.loadSlidBallTextureNormal(normalFileName_tp); break; case 1: - var normalFileName = normalDic["path"]; slider.loadSlidBallTextureNormal(normalFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; default: @@ -104,17 +99,19 @@ ccs.SliderReader = { var pressedDic = options["ballPressedData"]; var pressedType = pressedDic["resourceType"]; + var pressedFileName = pressedDic["path"]; + if(pressedFileName === null){ + pressedType = normalType; + pressedFileName = normalFileName; + } switch(pressedType){ case 0: - var tp_p = jsonPath; - var pressedFileName = pressedDic["path"]; - var pressedFileName_tp = ( pressedFileName && pressedFileName !== "" ) ? - tp_p + pressedFileName : + var pressedFileName_tp = pressedFileName ? + tp + pressedFileName : null; slider.loadSlidBallTexturePressed(pressedFileName_tp); break; case 1: - var pressedFileName = pressedDic["path"]; slider.loadSlidBallTexturePressed(pressedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; default: @@ -122,17 +119,15 @@ ccs.SliderReader = { } var disabledDic = options["ballDisabledData"]; var disabledType = disabledDic["resourceType"]; + var disabledFileName = disabledDic["path"]; switch(disabledType){ case 0: - var tp_d = jsonPath; - var disabledFileName = disabledDic["path"]; - var disabledFileName_tp = ( disabledFileName && disabledFileName !== "" ) ? - tp_d + disabledFileName : + var disabledFileName_tp = disabledFileName ? + tp + disabledFileName : null; slider.loadSlidBallTextureDisabled(disabledFileName_tp); break; case 1: - var disabledFileName = disabledDic["path"]; slider.loadSlidBallTextureDisabled(disabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; default: @@ -140,18 +135,19 @@ ccs.SliderReader = { } var progressBarDic = options["progressBarData"]; var progressBarType = progressBarDic["resourceType"]; + var imageProgressFileName = progressBarDic["path"]; + if(imageProgressFileName){ + + } switch (progressBarType){ case 0: - var tp_b = jsonPath; - var imageFileName = progressBarDic["path"]; - var imageFileName_tp = ( imageFileName && imageFileName !== "" ) ? - (tp_b + imageFileName) : + var imageProgressFileName_tp = imageProgressFileName ? + (tp + imageFileName) : null; - slider.loadProgressBarTexture(imageFileName_tp); + slider.loadProgressBarTexture(imageProgressFileName_tp); break; case 1: - var imageFileName = progressBarDic["path"]; - slider.loadProgressBarTexture(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + slider.loadProgressBarTexture(imageProgressFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; default: break; From c74d305dd5a65f0eead2df8f933e647f47a35acc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 7 Jul 2014 17:22:52 +0800 Subject: [PATCH 0258/1564] Fixed #5674: Add defaultPixelFormat property doc --- cocos2d/core/textures/CCTexture2D.js | 1 + cocos2d/core/textures/TexturesWebGL.js | 1 + 2 files changed, 2 insertions(+) diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 25e5f11e1e..5a3745d22d 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -110,6 +110,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * @extends cc.Class * * @property {WebGLTexture} name - <@readonly> WebGLTexture Object + * @property {Number} defaultPixelFormat - The default pixel format * @property {Number} pixelFormat - <@readonly> Pixel format of the texture * @property {Number} pixelsWidth - <@readonly> Width in pixels * @property {Number} pixelsHeight - <@readonly> Height in pixels diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index ba17755895..90042f6907 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -38,6 +38,7 @@ cc._tmp.WebGLTexture2D = function () { * @extends cc.Class * * @property {WebGLTexture} name - <@readonly> WebGLTexture Object + * @property {Number} defaultPixelFormat - The default pixel format * @property {Number} pixelFormat - <@readonly> Pixel format of the texture * @property {Number} pixelsWidth - <@readonly> Width in pixels * @property {Number} pixelsHeight - <@readonly> Height in pixels From 1ef1a44001483795c34c338c76f1c4f7266272d9 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 7 Jul 2014 17:24:07 +0800 Subject: [PATCH 0259/1564] Closed #5671: Refactor cc.Sprite's setColor for Performance --- CCBoot.js | 21 ++- cocos2d/core/sprites/CCSprite.js | 258 +++++++++++++++++-------------- 2 files changed, 153 insertions(+), 126 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 1dfa85ced7..46e0eca3bd 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1066,7 +1066,6 @@ cc._initSys = function (config, CONFIG_KEY) { sys.language = currLanguage; /** The type of browser */ - var browserType = sys.BROWSER_TYPE_UNKNOWN; var browserTypes = ua.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|opera|miuibrowser|firefox/i) || ua.match(/chrome|safari/i); @@ -1092,6 +1091,21 @@ cc._initSys = function (config, CONFIG_KEY) { renderType = cc._RENDER_TYPE_CANVAS; } + sys._canUseCanvasNewBlendModes = function(){ + var canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + var context = canvas.getContext('2d'); + context.fillStyle = '#000'; + context.fillRect(0,0,1,1); + context.globalCompositeOperation = 'multiply'; + context.fillStyle = '#fff'; + context.fillRect(0,0,1,1); + return context.getImageData(0,0,1,1).data[0] === 0; + }; + + //Whether or not the Canvas BlendModes are supported. + sys._supportCanvasNewBlendModes = sys._canUseCanvasNewBlendModes(); if (renderType == cc._RENDER_TYPE_WEBGL) { if (!win.WebGLRenderingContext @@ -1111,7 +1125,6 @@ cc._initSys = function (config, CONFIG_KEY) { cc._renderType = renderType; //++++++++++++++++++something about cc._renderTYpe and cc._supportRender end++++++++++++++++++++++++++++++ - // check if browser supports Web Audio // check Web Audio's context try { @@ -1135,7 +1148,6 @@ cc._initSys = function (config, CONFIG_KEY) { }; } - var capabilities = sys.capabilities = {"canvas": true}; if (cc._renderType == cc._RENDER_TYPE_WEBGL) capabilities["opengl"] = true; @@ -1544,9 +1556,7 @@ cc.game = { if (document["ccConfig"]) { self.config = _init(document["ccConfig"]); } else { - try { - var cocos_script = document.getElementsByTagName('script'); for(var i=0;i 0) { + ctx.globalAlpha = r * a; + ctx.drawImage(tintedImgCache[0], rect.x, rect.y, w, h, 0, 0, w, h); + } + if (g > 0) { + ctx.globalAlpha = g * a; + ctx.drawImage(tintedImgCache[1], rect.x, rect.y, w, h, 0, 0, w, h); + } + if (b > 0) { + ctx.globalAlpha = b * a; + ctx.drawImage(tintedImgCache[2], rect.x, rect.y, w, h, 0, 0, w, h); + } + + if (r + g + b < 1) { + ctx.globalAlpha = a; + ctx.drawImage(tintedImgCache[3], rect.x, rect.y, w, h, 0, 0, w, h); + } + + ctx.restore(); + return buff; +}; + /** * generate texture's cache for texture tint * @function * @param {HTMLImageElement} texture * @return {Array} */ - cc.generateTextureCacheForColor = function (texture) { if (texture.channelCache) { return texture.channelCache; @@ -102,103 +205,6 @@ cc.generateTextureCacheForColor.canvas = cc.newElement('canvas'); cc.generateTextureCacheForColor.tempCanvas = cc.newElement('canvas'); cc.generateTextureCacheForColor.tempCtx = cc.generateTextureCacheForColor.tempCanvas.getContext('2d'); -/** - * generate tinted texture - * source-in: Where source and destination overlaps and both are opaque, the source is displayed. - * Everywhere else transparency is displayed. - * @function - * @param {HTMLImageElement} texture - * @param {cc.Color} color - * @param {cc.Rect} rect - * @return {HTMLCanvasElement} - */ -cc.generateTintImage2 = function (texture, color, rect) { - if (!rect) { - rect = cc.rect(0, 0, texture.width, texture.height); - rect = cc.rectPixelsToPoints(rect); - } - - var buff = cc.newElement("canvas"); - var ctx = buff.getContext("2d"); - - if (buff.width != rect.width) buff.width = rect.width; - if (buff.height != rect.height) buff.height = rect.height; - ctx.save(); - - ctx.drawImage(texture, rect.x, rect.y, rect.width, rect.height, 0, 0, rect.width, rect.height); - - ctx.globalCompositeOperation = "source-in"; - ctx.globalAlpha = color.a / 255.0; - ctx.fillStyle = "rgb(" + color.r + "," + color.g + "," + color.b + ")"; - ctx.fillRect(0, 0, rect.width, rect.height); - ctx.restore(); - - return buff; -}; - -/** - * generate tinted texture - * lighter: The source and destination colors are added to each other, resulting in brighter colors, - * moving towards color values of 1 (maximum brightness for that color). - * @function - * @param {HTMLImageElement} texture - * @param {Array} tintedImgCache - * @param {cc.Color} color - * @param {cc.Rect} rect - * @param {HTMLCanvasElement} [renderCanvas] - * @return {HTMLCanvasElement} - */ -cc.generateTintImage = function (texture, tintedImgCache, color, rect, renderCanvas) { - if (!rect) - rect = cc.rect(0, 0, texture.width, texture.height); - - var r = color.r / 255; - var g = color.g / 255; - var b = color.b / 255; - - var w = Math.min(rect.width, tintedImgCache[0].width); - var h = Math.min(rect.height, tintedImgCache[0].height); - var buff = renderCanvas; - var ctx; - - // Create a new buffer if required - if (!buff) { - buff = cc.newElement("canvas"); - buff.width = w; - buff.height = h; - ctx = buff.getContext("2d"); - } else { - ctx = buff.getContext("2d"); - ctx.clearRect(0, 0, w, h); - } - - ctx.save(); - ctx.globalCompositeOperation = 'lighter'; - - // Make sure to keep the renderCanvas alpha in mind in case of overdraw - var a = ctx.globalAlpha; - if (r > 0) { - ctx.globalAlpha = r * a; - ctx.drawImage(tintedImgCache[0], rect.x, rect.y, w, h, 0, 0, w, h); - } - if (g > 0) { - ctx.globalAlpha = g * a; - ctx.drawImage(tintedImgCache[1], rect.x, rect.y, w, h, 0, 0, w, h); - } - if (b > 0) { - ctx.globalAlpha = b * a; - ctx.drawImage(tintedImgCache[2], rect.x, rect.y, w, h, 0, 0, w, h); - } - - if (r + g + b < 1) { - ctx.globalAlpha = a; - ctx.drawImage(tintedImgCache[3], rect.x, rect.y, w, h, 0, 0, w, h); - } - - ctx.restore(); - return buff; -}; - cc.cutRotateImageToCanvas = function (texture, rect) { if (!texture) return null; @@ -518,9 +524,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ * @override */ reorderChild:function (child, zOrder) { - cc.assert(child, cc._LogInfos.Sprite_reorderChild_2); - if(this._children.indexOf(child) === -1){ cc.log(cc._LogInfos.Sprite_reorderChild); return; @@ -825,7 +829,6 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ * mySprite.initWithFile("HelloHTML5World.png",cc.rect(0,0,480,320)); */ initWithFile:function (filename, rect) { - cc.assert(filename, cc._LogInfos.Sprite_initWithFile); var tex = cc.textureCache.textureForKey(filename); @@ -1017,19 +1020,15 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ if (!locElement) return; - var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); - if (cacheTextureForColor) { - this._colorized = true; - //generate color texture cache - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); - else { - locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.texture = locTexture; - } + this._colorized = true; + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) + cc.generateTintImage(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); + else { + locElement = cc.generateTintImage(this._originalTexture._htmlElementObj, this._displayedColor, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.texture = locTexture; } } }, @@ -1434,8 +1433,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; cc.NodeRGBA.prototype.setColor.call(_t, color3); - _t._changeTextureColor(); - _t._setNodeDirtyForCache(); }; _p.updateDisplayedColor = function (parentColor) { @@ -1453,9 +1450,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _t = this; if(typeof(newFrame) == "string"){ newFrame = cc.spriteFrameCache.getSpriteFrame(newFrame); - cc.assert(newFrame, cc._LogInfos.CCSpriteBatchNode_setSpriteFrame) - } _t.setNodeDirty(true); @@ -1519,7 +1514,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - _p.setTexture = function (texture) { var _t = this; if(texture && (typeof(texture) === "string")){ @@ -1533,7 +1527,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet - cc.assert(!texture || texture instanceof cc.Texture2D, cc._LogInfos.CCSpriteBatchNode_setTexture); if (_t._texture != texture) { @@ -1618,6 +1611,31 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.g_NumberOfDraws++; }; + if(!cc.sys._supportCanvasNewBlendModes) + _p._changeTextureColor = function () { + var locElement, locTexture = this._texture, locRect = this._textureRect_Canvas; //this.getTextureRect(); + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); + if (cacheTextureForColor) { + this._colorized = true; + //generate color texture cache + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) + cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); + else { + locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.texture = locTexture; + } + } + } + }; + delete _p; } else { cc.assert(typeof cc._tmp.WebGLSprite === "function", cc._LogInfos.MissingFile, "SpritesWebGL.js"); From 7f200a5c036232c7dbd45cf81a91c31c55a85e8d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 7 Jul 2014 17:31:28 +0800 Subject: [PATCH 0260/1564] Closed #5671: Refactor cc.Sprite's setColor for Performance --- cocos2d/core/sprites/CCSprite.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 499d31bf03..fd1ec2f084 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1611,7 +1611,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.g_NumberOfDraws++; }; - if(!cc.sys._supportCanvasNewBlendModes) + if(cc.sys._supportCanvasNewBlendModes) _p._changeTextureColor = function () { var locElement, locTexture = this._texture, locRect = this._textureRect_Canvas; //this.getTextureRect(); if (locTexture && locRect.validRect && this._originalTexture) { @@ -1624,9 +1624,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._colorized = true; //generate color texture cache if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); + cc.generateTintImageWithLight(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); else { - locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); + locElement = cc.generateTintImageWithLight(locElement, cacheTextureForColor, this._displayedColor, locRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); From 31a4918e2949f8eb522c91e206201a3c0fcd58f1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 7 Jul 2014 17:35:39 +0800 Subject: [PATCH 0261/1564] Closed #5671: Refactor cc.Sprite's setColor for Performance(remove the test code) --- cocos2d/core/sprites/CCSprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index fd1ec2f084..3c9dfc6dca 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1611,7 +1611,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.g_NumberOfDraws++; }; - if(cc.sys._supportCanvasNewBlendModes) + if(!cc.sys._supportCanvasNewBlendModes) _p._changeTextureColor = function () { var locElement, locTexture = this._texture, locRect = this._textureRect_Canvas; //this.getTextureRect(); if (locTexture && locRect.validRect && this._originalTexture) { From e073aaca5f72420dab761b6da4cd818d35a6c3a7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 8 Jul 2014 10:19:53 +0800 Subject: [PATCH 0262/1564] Issue #5670: UIImageView loadTexture --- extensions/ccui/uiwidgets/UIImageView.js | 40 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index f09033cf90..9d1cc081a3 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -70,36 +70,50 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexture: function (fileName, texType) { - if (!fileName) + if (!fileName) { return; + } texType = texType || ccui.Widget.LOCAL_TEXTURE; this._textureFile = fileName; this._imageTexType = texType; var imageRenderer = this._imageRenderer; switch (this._imageTexType) { case ccui.Widget.LOCAL_TEXTURE: - if (this._scale9Enabled) { - imageRenderer.initWithFile(fileName); - imageRenderer.setCapInsets(this._capInsets); - } else - imageRenderer.setTexture(fileName); + imageRenderer.initWithFile(fileName); break; case ccui.Widget.PLIST_TEXTURE: - if (this._scale9Enabled) { - imageRenderer.initWithSpriteFrameName(fileName); - imageRenderer.setCapInsets(this._capInsets); - } else - imageRenderer.setSpriteFrame(fileName); + imageRenderer.initWithSpriteFrameName(fileName); break; default: break; } - this._imageTextureSize = imageRenderer.getContentSize(); + + var locRendererSize = imageRenderer.getContentSize(); + if(imageRenderer.textureLoaded()){ + this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locRendererSize.width; + this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locRendererSize.height; + }else{ + imageRenderer.addLoadedEventListener(function(){ + var locSize = imageRenderer.getContentSize(); + this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locSize.width; + this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locSize.height; + if (imageRenderer.setCapInsets) { + imageRenderer.setCapInsets(this._capInsets); + } + this.imageTextureScaleChangedWithSize(); + },this); + this._imageTextureSize.width = this._customSize.width; + this._imageTextureSize.height = this._customSize.height; + } + + if (this._scale9Enabled) { + imageRenderer.setCapInsets(this._capInsets); + } + this.updateFlippedX(); this.updateFlippedY(); imageRenderer.setColor(this.getColor()); imageRenderer.setOpacity(this.getOpacity()); - this._updateContentSizeWithTextureSize(this._imageTextureSize); this._imageRendererAdaptDirty = true; }, From e1e26e6a476c25bf4ee540a99f7d41c1f2e518ef Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 8 Jul 2014 10:51:45 +0800 Subject: [PATCH 0263/1564] Refactor #5672: Refactor CCAffineTransform.js's functions to lowercase started --- cocos2d/core/base-nodes/CCNode.js | 28 +++++------ cocos2d/core/cocoa/CCAffineTransform.js | 44 ++++++++--------- cocos2d/core/layers/CCLayer.js | 2 +- cocos2d/core/sprites/CCSprite.js | 4 +- cocos2d/core/sprites/SpritesWebGL.js | 4 +- cocos2d/physics/CCPhysicsSprite.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 10 ++-- extensions/cocostudio/armature/CCBone.js | 6 +-- .../armature/display/CCDisplayFactory.js | 4 +- .../cocostudio/armature/display/CCSkin.js | 14 +++--- .../armature/physics/CCColliderDetector.js | 2 +- .../armature/utils/CCTransformHelp.js | 12 ++--- extensions/editbox/CCEditBox.js | 2 +- .../gui/control-extension/CCScale9Sprite.js | 48 +++++++++---------- 14 files changed, 91 insertions(+), 91 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 49408c1017..4d353db30c 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -189,7 +189,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _t._actionManager = director.getActionManager(); _t._scheduler = director.getScheduler(); _t._initializedNode = true; - _t._additionalTransform = cc.AffineTransformMakeIdentity(); + _t._additionalTransform = cc.affineTransformMakeIdentity(); if (cc.ComponentContainer) { _t._componentContainer = new cc.ComponentContainer(_t); } @@ -1093,7 +1093,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ getBoundingBox: function () { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - return cc._RectApplyAffineTransformIn(rect, this.nodeToParentTransform()); + return cc._rectApplyAffineTransformIn(rect, this.nodeToParentTransform()); }, /** @@ -1710,7 +1710,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ parentToNodeTransform: function () { if (this._inverseDirty) { - this._inverse = cc.AffineTransformInvert(this.nodeToParentTransform()); + this._inverse = cc.affineTransformInvert(this.nodeToParentTransform()); this._inverseDirty = false; } return this._inverse; @@ -1723,7 +1723,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ nodeToWorldTransform: function () { var t = this.nodeToParentTransform(); for (var p = this._parent; p != null; p = p.parent) - t = cc.AffineTransformConcat(t, p.nodeToParentTransform()); + t = cc.affineTransformConcat(t, p.nodeToParentTransform()); return t; }, @@ -1732,7 +1732,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.AffineTransform} */ worldToNodeTransform: function () { - return cc.AffineTransformInvert(this.nodeToWorldTransform()); + return cc.affineTransformInvert(this.nodeToWorldTransform()); }, /** @@ -1741,7 +1741,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} */ convertToNodeSpace: function (worldPoint) { - return cc.PointApplyAffineTransform(worldPoint, this.worldToNodeTransform()); + return cc.pointApplyAffineTransform(worldPoint, this.worldToNodeTransform()); }, /** @@ -1751,7 +1751,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ convertToWorldSpace: function (nodePoint) { nodePoint = nodePoint || cc.p(0,0); - return cc.PointApplyAffineTransform(nodePoint, this.nodeToWorldTransform()); + return cc.pointApplyAffineTransform(nodePoint, this.nodeToWorldTransform()); }, /** @@ -1991,7 +1991,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ getBoundingBoxToWorld: function () { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); var trans = this.nodeToWorldTransform(); - rect = cc.RectApplyAffineTransform(rect, this.nodeToWorldTransform()); + rect = cc.rectApplyAffineTransform(rect, this.nodeToWorldTransform()); //query child's BoundingBox if (!this._children) @@ -2011,8 +2011,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _getBoundingBoxToCurrentNode: function (parentTransform) { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var trans = (parentTransform == null) ? this.nodeToParentTransform() : cc.AffineTransformConcat(this.nodeToParentTransform(), parentTransform); - rect = cc.RectApplyAffineTransform(rect, trans); + var trans = (parentTransform == null) ? this.nodeToParentTransform() : cc.affineTransformConcat(this.nodeToParentTransform(), parentTransform); + rect = cc.rectApplyAffineTransform(rect, trans); //query child's BoundingBox if (!this._children) @@ -2078,16 +2078,16 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // 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(_t._skewY)), + t = cc.affineTransformConcat({a: 1.0, b: Math.tan(cc.degreesToRadians(_t._skewY)), c: Math.tan(cc.degreesToRadians(_t._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t); // adjust anchor point if (apx !== 0 || apy !== 0) - t = cc.AffineTransformTranslate(t, napx, napy); + t = cc.affineTransformTranslate(t, napx, napy); } if (_t._additionalTransformDirty) { - t = cc.AffineTransformConcat(t, _t._additionalTransform); + t = cc.affineTransformConcat(t, _t._additionalTransform); _t._additionalTransformDirty = false; } _t._transform = t; @@ -2241,7 +2241,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } if (_t._additionalTransformDirty) { - _t._transform = cc.AffineTransformConcat(t, _t._additionalTransform); + _t._transform = cc.affineTransformConcat(t, _t._additionalTransform); _t._additionalTransformDirty = false; } diff --git a/cocos2d/core/cocoa/CCAffineTransform.js b/cocos2d/core/cocoa/CCAffineTransform.js index cac9f5674e..a0cbafb1a2 100644 --- a/cocos2d/core/cocoa/CCAffineTransform.js +++ b/cocos2d/core/cocoa/CCAffineTransform.js @@ -54,7 +54,7 @@ cc.AffineTransform = function (a, b, c, d, tx, ty) { * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformMake = function (a, b, c, d, tx, ty) { +cc.affineTransformMake = function (a, b, c, d, tx, ty) { return {a: a, b: b, c: c, d: d, tx: tx, ty: ty}; }; @@ -66,11 +66,11 @@ cc.AffineTransformMake = function (a, b, c, d, tx, ty) { * @return {cc.Point} * Constructor */ -cc.PointApplyAffineTransform = function (point, t) { +cc.pointApplyAffineTransform = function (point, t) { return {x: t.a * point.x + t.c * point.y + t.tx, y: t.b * point.x + t.d * point.y + t.ty}; }; -cc._PointApplyAffineTransform = function (x, y, t) { +cc._pointApplyAffineTransform = function (x, y, t) { return {x: t.a * x + t.c * y + t.tx, y: t.b * x + t.d * y + t.ty}; }; @@ -83,7 +83,7 @@ cc._PointApplyAffineTransform = function (x, y, t) { * @return {cc.Size} * Constructor */ -cc.SizeApplyAffineTransform = function (size, t) { +cc.sizeApplyAffineTransform = function (size, t) { return {width: t.a * size.width + t.c * size.height, height: t.b * size.width + t.d * size.height}; }; @@ -93,7 +93,7 @@ cc.SizeApplyAffineTransform = function (size, t) { * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformMakeIdentity = function () { +cc.affineTransformMakeIdentity = function () { return {a: 1.0, b: 0.0, c: 0.0, d: 1.0, tx: 0.0, ty: 0.0}; }; @@ -103,7 +103,7 @@ cc.AffineTransformMakeIdentity = function () { * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformIdentity = function () { +cc.affineTransformIdentity = function () { return {a: 1.0, b: 0.0, c: 0.0, d: 1.0, tx: 0.0, ty: 0.0}; }; @@ -115,16 +115,16 @@ cc.AffineTransformIdentity = function () { * @return {cc.Rect} * Constructor */ -cc.RectApplyAffineTransform = function (rect, anAffineTransform) { +cc.rectApplyAffineTransform = function (rect, anAffineTransform) { var top = cc.rectGetMinY(rect); var left = cc.rectGetMinX(rect); var right = cc.rectGetMaxX(rect); var bottom = cc.rectGetMaxY(rect); - var topLeft = cc._PointApplyAffineTransform(left, top, anAffineTransform); - var topRight = cc._PointApplyAffineTransform(right, top, anAffineTransform); - var bottomLeft = cc._PointApplyAffineTransform(left, bottom, anAffineTransform); - var bottomRight = cc._PointApplyAffineTransform(right, bottom, anAffineTransform); + var topLeft = cc._pointApplyAffineTransform(left, top, anAffineTransform); + var topRight = cc._pointApplyAffineTransform(right, top, anAffineTransform); + var bottomLeft = cc._pointApplyAffineTransform(left, bottom, anAffineTransform); + var bottomRight = cc._pointApplyAffineTransform(right, bottom, anAffineTransform); var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); @@ -134,16 +134,16 @@ cc.RectApplyAffineTransform = function (rect, anAffineTransform) { return cc.rect(minX, minY, (maxX - minX), (maxY - minY)); }; -cc._RectApplyAffineTransformIn = function(rect, anAffineTransform){ +cc._rectApplyAffineTransformIn = function(rect, anAffineTransform){ var top = cc.rectGetMinY(rect); var left = cc.rectGetMinX(rect); var right = cc.rectGetMaxX(rect); var bottom = cc.rectGetMaxY(rect); - var topLeft = cc._PointApplyAffineTransform(left, top, anAffineTransform); - var topRight = cc._PointApplyAffineTransform(right, top, anAffineTransform); - var bottomLeft = cc._PointApplyAffineTransform(left, bottom, anAffineTransform); - var bottomRight = cc._PointApplyAffineTransform(right, bottom, anAffineTransform); + var topLeft = cc._pointApplyAffineTransform(left, top, anAffineTransform); + var topRight = cc._pointApplyAffineTransform(right, top, anAffineTransform); + var bottomLeft = cc._pointApplyAffineTransform(left, bottom, anAffineTransform); + var bottomRight = cc._pointApplyAffineTransform(right, bottom, anAffineTransform); var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); @@ -166,7 +166,7 @@ cc._RectApplyAffineTransformIn = function(rect, anAffineTransform){ * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformTranslate = function (t, tx, ty) { +cc.affineTransformTranslate = function (t, tx, ty) { return { a: t.a, b: t.b, @@ -186,7 +186,7 @@ cc.AffineTransformTranslate = function (t, tx, ty) { * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformScale = function (t, sx, sy) { +cc.affineTransformScale = function (t, sx, sy) { return {a: t.a * sx, b: t.b * sx, c: t.c * sy, d: t.d * sy, tx: t.tx, ty: t.ty}; }; @@ -198,7 +198,7 @@ cc.AffineTransformScale = function (t, sx, sy) { * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformRotate = function (aTransform, anAngle) { +cc.affineTransformRotate = function (aTransform, anAngle) { var fSin = Math.sin(anAngle); var fCos = Math.cos(anAngle); @@ -220,7 +220,7 @@ cc.AffineTransformRotate = function (aTransform, anAngle) { * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformConcat = function (t1, t2) { +cc.affineTransformConcat = function (t1, t2) { return {a: t1.a * t2.a + t1.b * t2.c, //a b: t1.a * t2.b + t1.b * t2.d, //b c: t1.c * t2.a + t1.d * t2.c, //c @@ -238,7 +238,7 @@ cc.AffineTransformConcat = function (t1, t2) { * @return {Boolean} * Constructor */ -cc.AffineTransformEqualToTransform = function (t1, t2) { +cc.affineTransformEqualToTransform = function (t1, t2) { return ((t1.a === t2.a) && (t1.b === t2.b) && (t1.c === t2.c) && (t1.d === t2.d) && (t1.tx === t2.tx) && (t1.ty === t2.ty)); }; @@ -250,7 +250,7 @@ cc.AffineTransformEqualToTransform = function (t1, t2) { * @return {cc.AffineTransform} * Constructor */ -cc.AffineTransformInvert = function (t) { +cc.affineTransformInvert = function (t) { var determinant = 1 / (t.a * t.d - t.b * t.c); return {a: determinant * t.d, b: -determinant * t.b, c: -determinant * t.c, d: determinant * t.a, tx: determinant * (t.c * t.ty - t.d * t.tx), ty: determinant * (t.b * t.tx - t.a * t.ty)}; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 49e1b6cae2..4e8ba026d9 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -729,7 +729,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //default size var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); var trans = this.nodeToWorldTransform(); - rect = cc.RectApplyAffineTransform(rect, this.nodeToWorldTransform()); + rect = cc.rectApplyAffineTransform(rect, this.nodeToWorldTransform()); //query child's BoundingBox if (!this._children || this._children.length === 0) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 3c9dfc6dca..196c3b391c 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1395,7 +1395,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._transformToBatch = _t.nodeToParentTransform(); } else { //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); - _t._transformToBatch = cc.AffineTransformConcat(_t.nodeToParentTransform(), locParent._transformToBatch); + _t._transformToBatch = cc.affineTransformConcat(_t.nodeToParentTransform(), locParent._transformToBatch); } } _t._recursiveDirty = false; @@ -1509,7 +1509,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t.dirty = false; } else { // using batch - _t._transformToBatch = cc.AffineTransformIdentity(); + _t._transformToBatch = cc.affineTransformIdentity(); _t.textureAtlas = _t._batchNode.textureAtlas; // weak ref } }; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 3f333fb003..8f001aa5a6 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -288,7 +288,7 @@ cc._tmp.WebGLSprite = function () { _t._transformToBatch = _t.nodeToParentTransform(); } else { //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); - _t._transformToBatch = cc.AffineTransformConcat(_t.nodeToParentTransform(), locParent._transformToBatch); + _t._transformToBatch = cc.affineTransformConcat(_t.nodeToParentTransform(), locParent._transformToBatch); } // @@ -466,7 +466,7 @@ cc._tmp.WebGLSprite = function () { _t._quadDirty = true; } else { // using batch - _t._transformToBatch = cc.AffineTransformIdentity(); + _t._transformToBatch = cc.affineTransformIdentity(); _t.textureAtlas = _t._batchNode.textureAtlas; // weak ref } }; diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 1afaa0498c..2d5e36830c 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -293,7 +293,7 @@ } // Rot, Translate Matrix - this._transform = cc.AffineTransformMake(c * locScaleX, s * locScaleX, + this._transform = cc.affineTransformMake(c * locScaleX, s * locScaleX, -s * locScaleY, c * locScaleY, x, y); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 080c24cc56..3c97312da0 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -365,16 +365,16 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ // 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)), + 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) - t = cc.AffineTransformTranslate(t, napx, napy); + t = cc.affineTransformTranslate(t, napx, napy); } if (this._additionalTransformDirty) { - t = cc.AffineTransformConcat(t, this._additionalTransform); + t = cc.affineTransformConcat(t, this._additionalTransform); this._additionalTransformDirty = false; } this._transform = t; @@ -451,7 +451,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ } if (this._additionalTransformDirty) { - this._transform = cc.AffineTransformConcat(this._transform, this._additionalTransform); + this._transform = cc.affineTransformConcat(this._transform, this._additionalTransform); this._additionalTransformDirty = false; } @@ -511,7 +511,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ boundingBox = cc.rect(minx, miny, maxx - minx, maxy - miny); } } - return cc.RectApplyAffineTransform(boundingBox, this.nodeToParentTransform()); + return cc.rectApplyAffineTransform(boundingBox, this.nodeToParentTransform()); }, /** diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index c6c02b90df..4d8fef1ab6 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -75,7 +75,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ this._childrenBone = []; this.parentBone = null; this.boneTransformDirty = true; - this._worldTransform = cc.AffineTransformMake(1, 0, 0, 1, 0, 0); + this._worldTransform = cc.affineTransformMake(1, 0, 0, 1, 0, 0); this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); this.blendDirty = false; }, @@ -212,7 +212,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ ccs.TransformHelp.nodeToMatrix(locWorldInfo, locWorldTransform); if (locArmatureParentBone) { - this._worldTransform = cc.AffineTransformConcat(locWorldTransform, locArmature.nodeToParentTransform()); + this._worldTransform = cc.affineTransformConcat(locWorldTransform, locArmature.nodeToParentTransform()); } } ccs.DisplayFactory.updateDisplay(this, dt, this.boneTransformDirty || locArmature.getArmatureTransformDirty()); @@ -461,7 +461,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ * @returns {cc.AffineTransform} */ nodeToWorldTransform: function () { - return cc.AffineTransformConcat(this._worldTransform, this._armature.nodeToWorldTransform()); + return cc.affineTransformConcat(this._worldTransform, this._armature.nodeToWorldTransform()); }, /** diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index 897b45c81d..2823790b80 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -96,10 +96,10 @@ ccs.DisplayFactory.updateDisplay = function (bone,dt, dirty) { helpTransform.tx = displayTransform.tx; helpTransform.ty = displayTransform.ty; var anchorPoint = node.getAnchorPointInPoints(); - anchorPoint = cc.PointApplyAffineTransform(anchorPoint, helpTransform); + anchorPoint = cc.pointApplyAffineTransform(anchorPoint, helpTransform); helpTransform.tx = anchorPoint.x; helpTransform.ty = anchorPoint.y; - var t = cc.AffineTransformConcat(helpTransform, bone.getArmature().nodeToParentTransform()); + var t = cc.affineTransformConcat(helpTransform, bone.getArmature().nodeToParentTransform()); detector.updateTransform(t); } } diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 7701ac2902..44d0d9a039 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -45,7 +45,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this._skinData = null; this.bone = null; this._displayName = ""; - this._skinTransform = cc.AffineTransformIdentity(); + this._skinTransform = cc.affineTransformIdentity(); this._armature = null; }, initWithSpriteFrameName: function (spriteFrameName) { @@ -91,11 +91,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, updateArmatureTransform: function () { - this._transform = cc.AffineTransformConcat(this._skinTransform, this.bone.nodeToArmatureTransform()); + this._transform = cc.affineTransformConcat(this._skinTransform, this.bone.nodeToArmatureTransform()); var locTransform = this._transform; var locArmature = this._armature; if (locArmature && locArmature.getBatchNode()) { - this._transform = cc.AffineTransformConcat(locTransform, locArmature.nodeToParentTransform()); + this._transform = cc.affineTransformConcat(locTransform, locArmature.nodeToParentTransform()); } if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTransform = this._transform; @@ -116,7 +116,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ transForm.c *= -1; transForm.b = [transForm.c, transForm.c = transForm.b][0]; } - return cc.RectApplyAffineTransform(rect, transForm); + return cc.rectApplyAffineTransform(rect, transForm); }, /** @@ -128,7 +128,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, nodeToWorldTransform: function () { - return cc.AffineTransformConcat(this._transform, this.bone.getArmature().nodeToWorldTransform()); + return cc.affineTransformConcat(this._transform, this.bone.getArmature().nodeToWorldTransform()); }, @@ -136,11 +136,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var displayTransform = this._transform; var anchorPoint = this._anchorPointInPoints; - anchorPoint = cc.PointApplyAffineTransform(anchorPoint, displayTransform); + anchorPoint = cc.pointApplyAffineTransform(anchorPoint, displayTransform); displayTransform.tx = anchorPoint.x; displayTransform.ty = anchorPoint.y; - return cc.AffineTransformConcat(displayTransform, this.bone.getArmature().nodeToWorldTransform()); + return cc.affineTransformConcat(displayTransform, this.bone.getArmature().nodeToWorldTransform()); } }); ccs.Skin.prototype.nodeToParentTransform = cc.Node.prototype._nodeToParentTransformForWebGL; diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index b907aba4a8..4f662cc923 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -278,7 +278,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ for (var j = 0; j < vs.length; j++) { locHelpPoint.x = vs[j].x; locHelpPoint.y = vs[j].y; - locHelpPoint = cc.PointApplyAffineTransform(locHelpPoint, t); + locHelpPoint = cc.pointApplyAffineTransform(locHelpPoint, t); if (shape) { shape.verts[j * 2] = locHelpPoint.x; shape.verts[j * 2 + 1] = locHelpPoint.y; diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index 7aff58a6b8..412c8610a3 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -29,8 +29,8 @@ */ ccs.TransformHelp = ccs.TransformHelp || ccs.Class.extend({}); -ccs.TransformHelp.helpMatrix1 = cc.AffineTransformMake(1, 0, 0, 1, 0, 0); -ccs.TransformHelp.helpMatrix2 = cc.AffineTransformMake(1, 0, 0, 1, 0, 0); +ccs.TransformHelp.helpMatrix1 = cc.affineTransformMake(1, 0, 0, 1, 0, 0); +ccs.TransformHelp.helpMatrix2 = cc.affineTransformMake(1, 0, 0, 1, 0, 0); ccs.TransformHelp.helpPoint1 = cc.p(0, 0); ccs.TransformHelp.helpPoint2 = cc.p(0, 0); @@ -45,8 +45,8 @@ ccs.TransformHelp.transformFromParent = function (bone, parentBone) { this.nodeToMatrix(bone, this.helpMatrix1); this.nodeToMatrix(parentBone, this.helpMatrix2); - this.helpMatrix2 = cc.AffineTransformInvert(this.helpMatrix2); - this.helpMatrix1 = cc.AffineTransformConcat(this.helpMatrix1, this.helpMatrix2); + this.helpMatrix2 = cc.affineTransformInvert(this.helpMatrix2); + this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2); this.matrixToNode(this.helpMatrix1, bone); }; @@ -88,13 +88,13 @@ ccs.TransformHelp.matrixToNode = function (matrix, node) { */ this.helpPoint1.x = 0; this.helpPoint1.y = 1; - this.helpPoint1 = cc.PointApplyAffineTransform(this.helpPoint1, matrix); + this.helpPoint1 = cc.pointApplyAffineTransform(this.helpPoint1, matrix); this.helpPoint1.x -= matrix.tx; this.helpPoint1.y -= matrix.ty; this.helpPoint2.x = 1; this.helpPoint2.y = 0; - this.helpPoint2 = cc.PointApplyAffineTransform(this.helpPoint2, matrix); + this.helpPoint2 = cc.pointApplyAffineTransform(this.helpPoint2, matrix); this.helpPoint2.x -= matrix.tx; this.helpPoint2.y -= matrix.ty; diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 3150ece3cf..0c34d3e763 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -662,7 +662,7 @@ _p = null; cc.EditBox.getRect = function (node) { var contentSize = node.getContentSize(); var rect = cc.rect(0, 0, contentSize.width, contentSize.height); - return cc.RectApplyAffineTransform(rect, node.nodeToWorldTransform()); + return cc.rectApplyAffineTransform(rect, node.nodeToWorldTransform()); }; /** diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index ab82a877da..d663eb8045 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -701,20 +701,20 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{ x += center_w; var rightbottombounds = cc.rect(x, y, right_w, bottom_h); - var t = cc.AffineTransformMakeIdentity(); + var t = cc.affineTransformMakeIdentity(); if (!rotated) { // CCLog("!rotated"); - t = cc.AffineTransformTranslate(t, rect.x, rect.y); - - cc._RectApplyAffineTransformIn(centerbounds, t); - cc._RectApplyAffineTransformIn(rightbottombounds, t); - cc._RectApplyAffineTransformIn(leftbottombounds, t); - cc._RectApplyAffineTransformIn(righttopbounds, t); - cc._RectApplyAffineTransformIn(lefttopbounds, t); - cc._RectApplyAffineTransformIn(rightcenterbounds, t); - cc._RectApplyAffineTransformIn(leftcenterbounds, t); - cc._RectApplyAffineTransformIn(centerbottombounds, t); - cc._RectApplyAffineTransformIn(centertopbounds, t); + t = cc.affineTransformTranslate(t, rect.x, rect.y); + + cc._rectApplyAffineTransformIn(centerbounds, t); + cc._rectApplyAffineTransformIn(rightbottombounds, t); + cc._rectApplyAffineTransformIn(leftbottombounds, t); + cc._rectApplyAffineTransformIn(righttopbounds, t); + cc._rectApplyAffineTransformIn(lefttopbounds, t); + cc._rectApplyAffineTransformIn(rightcenterbounds, t); + cc._rectApplyAffineTransformIn(leftcenterbounds, t); + cc._rectApplyAffineTransformIn(centerbottombounds, t); + cc._rectApplyAffineTransformIn(centertopbounds, t); // Centre this._centre = new cc.Sprite(); @@ -775,18 +775,18 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{ var rotatedcenterbottombounds = centerbottombounds; var rotatedcentertopbounds = centertopbounds; - t = cc.AffineTransformTranslate(t, rect.height + rect.x, rect.y); - t = cc.AffineTransformRotate(t, 1.57079633); - - centerbounds = cc.RectApplyAffineTransform(centerbounds, t); - rightbottombounds = cc.RectApplyAffineTransform(rightbottombounds, t); - leftbottombounds = cc.RectApplyAffineTransform(leftbottombounds, t); - righttopbounds = cc.RectApplyAffineTransform(righttopbounds, t); - lefttopbounds = cc.RectApplyAffineTransform(lefttopbounds, t); - rightcenterbounds = cc.RectApplyAffineTransform(rightcenterbounds, t); - leftcenterbounds = cc.RectApplyAffineTransform(leftcenterbounds, t); - centerbottombounds = cc.RectApplyAffineTransform(centerbottombounds, t); - centertopbounds = cc.RectApplyAffineTransform(centertopbounds, t); + t = cc.affineTransformTranslate(t, rect.height + rect.x, rect.y); + t = cc.affineTransformRotate(t, 1.57079633); + + centerbounds = cc.rectApplyAffineTransform(centerbounds, t); + rightbottombounds = cc.rectApplyAffineTransform(rightbottombounds, t); + leftbottombounds = cc.rectApplyAffineTransform(leftbottombounds, t); + righttopbounds = cc.rectApplyAffineTransform(righttopbounds, t); + lefttopbounds = cc.rectApplyAffineTransform(lefttopbounds, t); + rightcenterbounds = cc.rectApplyAffineTransform(rightcenterbounds, t); + leftcenterbounds = cc.rectApplyAffineTransform(leftcenterbounds, t); + centerbottombounds = cc.rectApplyAffineTransform(centerbottombounds, t); + centertopbounds = cc.rectApplyAffineTransform(centertopbounds, t); rotatedcenterbounds.x = centerbounds.x; rotatedcenterbounds.y = centerbounds.y; From 7f985ed6903101c36ea20d38a511ea6335731582 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 8 Jul 2014 11:08:42 +0800 Subject: [PATCH 0264/1564] Issue #5670: SliderReader --- .../reader/widgetreader/SliderReader/SliderReader.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index c0a23f408b..2ded592014 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -136,13 +136,10 @@ ccs.SliderReader = { var progressBarDic = options["progressBarData"]; var progressBarType = progressBarDic["resourceType"]; var imageProgressFileName = progressBarDic["path"]; - if(imageProgressFileName){ - - } switch (progressBarType){ case 0: var imageProgressFileName_tp = imageProgressFileName ? - (tp + imageFileName) : + (tp + imageProgressFileName) : null; slider.loadProgressBarTexture(imageProgressFileName_tp); break; From b3cab11ac767e917a82d1d1001742df432415be9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 8 Jul 2014 13:53:38 +0800 Subject: [PATCH 0265/1564] Fixed #5643: Add jsb only APIs definitions to support code ide --- jsb_apis.js | 451 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 451 insertions(+) create mode 100644 jsb_apis.js diff --git a/jsb_apis.js b/jsb_apis.js new file mode 100644 index 0000000000..e9fa16f8cd --- /dev/null +++ b/jsb_apis.js @@ -0,0 +1,451 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * @namespace jsb + * @name jsb + */ +var jsb = jsb || {}; + +/** + * @type {Object} + * @name jsb.fileUtils + * jsb.fileUtils is the native file utils singleton object, + * please refer to Cocos2d-x API to know how to use it. + * Only available in JSB + */ +jsb.fileUtils = { + + /** + * @method fullPathForFilename + * @param {String} arg0 + * @return {String} + */ + fullPathForFilename : function (str) + { + return ; + }, + + /** + * @method getStringFromFile + * @param {String} arg0 + * @return {String} + */ + getStringFromFile : function (str) + { + return ; + }, + + /** + * @method removeFile + * @param {String} arg0 + * @return {bool} + */ + removeFile : function (str) + { + return false; + }, + + /** + * @method isAbsolutePath + * @param {String} arg0 + * @return {bool} + */ + isAbsolutePath : function (str) + { + return false; + }, + + /** + * @method renameFile + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @return {bool} + */ + renameFile : function (str, str, str) + { + return false; + }, + + /** + * @method loadFilenameLookupDictionaryFromFile + * @param {String} arg0 + */ + loadFilenameLookupDictionaryFromFile : function (str) + { + }, + + /** + * @method isPopupNotify + * @return {bool} + */ + isPopupNotify : function () + { + return false; + }, + + /** + * @method getValueVectorFromFile + * @param {String} arg0 + * @return {Array} + */ + getValueVectorFromFile : function (str) + { + return new Array(); + }, + + /** + * @method getSearchPaths + * @return {Array} + */ + getSearchPaths : function () + { + return new Array(); + }, + + /** + * @method writeToFile + * @param {map_object} arg0 + * @param {String} arg1 + * @return {bool} + */ + writeToFile : function (map, str) + { + return false; + }, + + /** + * @method getValueMapFromFile + * @param {String} arg0 + * @return {map_object} + */ + getValueMapFromFile : function (str) + { + return map_object; + }, + + /** + * @method getFileSize + * @param {String} arg0 + * @return {long} + */ + getFileSize : function (str) + { + return 0; + }, + + /** + * @method removeDirectory + * @param {String} arg0 + * @return {bool} + */ + removeDirectory : function (str) + { + return false; + }, + + /** + * @method setSearchPaths + * @param {Array} arg0 + */ + setSearchPaths : function (array) + { + }, + + /** + * @method writeStringToFile + * @param {String} arg0 + * @param {String} arg1 + * @return {bool} + */ + writeStringToFile : function (str, str) + { + return false; + }, + + /** + * @method setSearchResolutionsOrder + * @param {Array} arg0 + */ + setSearchResolutionsOrder : function (array) + { + }, + + /** + * @method addSearchResolutionsOrder + * @param {String} arg0 + */ + addSearchResolutionsOrder : function (str) + { + }, + + /** + * @method addSearchPath + * @param {String} arg0 + */ + addSearchPath : function (str) + { + }, + + /** + * @method isFileExist + * @param {String} arg0 + * @return {bool} + */ + isFileExist : function (str) + { + return false; + }, + + /** + * @method purgeCachedEntries + */ + purgeCachedEntries : function () + { + }, + + /** + * @method fullPathFromRelativeFile + * @param {String} arg0 + * @param {String} arg1 + * @return {String} + */ + fullPathFromRelativeFile : function (str, str) + { + return ; + }, + + /** + * @method isDirectoryExist + * @param {String} arg0 + * @return {bool} + */ + isDirectoryExist : function (str) + { + return false; + }, + + /** + * @method getSearchResolutionsOrder + * @return {Array} + */ + getSearchResolutionsOrder : function () + { + return new Array(); + }, + + /** + * @method createDirectory + * @param {String} arg0 + * @return {bool} + */ + createDirectory : function (str) + { + return false; + }, + + /** + * @method createDirectories + * @param {String} arg0 + * @return {bool} + */ + createDirectories : function (str) + { + return false; + }, + + /** + * @method getWritablePath + * @return {String} + */ + getWritablePath : function () + { + return ; + } + +}; + +/** + * @class jsb.AssetsManager + * jsb.AssetsManager is the native AssetsManager for your game resources or scripts. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en + * Only available in JSB + */ +jsb.AssetsManager = { + + /** + * @method getState + * @return {jsb.AssetsManager::State} + */ + getState : function () + { + return 0; + }, + + /** + * @method checkUpdate + */ + checkUpdate : function () + { + }, + + /** + * @method getStoragePath + * @return {String} + */ + getStoragePath : function () + { + return ; + }, + + /** + * @method update + */ + update : function () + { + }, + + /** + * @method getLocalManifest + * @return {jsb.Manifest} + */ + getLocalManifest : function () + { + return cc.Manifest; + }, + + /** + * @method getRemoteManifest + * @return {jsb.Manifest} + */ + getRemoteManifest : function () + { + return cc.Manifest; + }, + + /** + * @method downloadFailedAssets + */ + downloadFailedAssets : function () + { + }, + + /** + * @method create + * @param {String} arg0 + * @param {String} arg1 + * @return {jsb.AssetsManager} + */ + create : function (str, str) + { + return cc.AssetsManager; + }, + + /** + * @method AssetsManager + * @constructor + * @param {String} arg0 + * @param {String} arg1 + */ + ctor : function (str, str) + { + } + +}; + +/** + * @class jsb.Manifest + */ +jsb.Manifest = { + + /** + * @method getManifestFileUrl + * @return {String} + */ + getManifestFileUrl : function () + { + return ; + }, + + /** + * @method isVersionLoaded + * @return {bool} + */ + isVersionLoaded : function () + { + return false; + }, + + /** + * @method isLoaded + * @return {bool} + */ + isLoaded : function () + { + return false; + }, + + /** + * @method getPackageUrl + * @return {String} + */ + getPackageUrl : function () + { + return ; + }, + + /** + * @method getVersion + * @return {String} + */ + getVersion : function () + { + return ; + }, + + /** + * @method getVersionFileUrl + * @return {String} + */ + getVersionFileUrl : function () + { + return ; + } +}; + +/** + * @type {Object} + * @name jsb.reflection + * jsb.reflection is a bridge to let you invoke Java static functions. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/reflection/en + * Only available on Android platform + */ +jsb.reflection = { + /** + * @method callStaticMethod + */ + callStaticMethod : function(){ + } +}; \ No newline at end of file From c843567f964ded1372d6fb200fe593d2ff9bf52f Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 9 Jul 2014 10:20:30 +0800 Subject: [PATCH 0266/1564] issue #5685: fix a bug of MenuItemToggle that callback is not correctly initialized when using new --- cocos2d/menus/CCMenuItem.js | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index d9d998cfc6..21df292b3d 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -1136,35 +1136,13 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ * //this is useful for constructing a toggler without a callback function (you wish to control the behavior from somewhere else) */ ctor: function (/*Multiple arguments follow*/) { - var argc = arguments.length, callback, target; - // passing callback. - if (typeof arguments[argc - 2] === 'function') { - callback = arguments[argc - 2]; - target = arguments[argc - 1]; - argc = argc - 2; - } else if (typeof arguments[argc - 1] === 'function') { - callback = arguments[argc - 1]; - argc = argc - 1; - } - - cc.MenuItem.prototype.ctor.call(this, callback, target); + cc.MenuItem.prototype.ctor.call(this); this._selectedIndex = 0; this.subItems = []; this._opacity = 0; this._color = cc.color.WHITE; - if (argc > 0) { - var locSubItems = this.subItems; - locSubItems.length = 0; - for (var i = 0; i < argc; i++) { - if (arguments[i]) - locSubItems.push(arguments[i]); - } - this._selectedIndex = cc.UINT_MAX; - this.setSelectedIndex(0); - this.setCascadeColorEnabled(true); - this.setCascadeOpacityEnabled(true); - } + this.initWithItems(Array.prototype.slice.apply(arguments)); }, /** From 4dfc4dff7c18b8f15571a5ede745d68d364ee29c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 9 Jul 2014 11:46:21 +0800 Subject: [PATCH 0267/1564] Issue #5688: merge cc.NodeRGBA to cc.Node --- .../base-nodes/BaseNodesPropertyDefine.js | 8 +- cocos2d/core/base-nodes/CCAtlasNode.js | 16 +- cocos2d/core/base-nodes/CCNode.js | 474 +++++++++--------- cocos2d/core/labelttf/CCLabelTTF.js | 6 +- cocos2d/core/layers/CCLayer.js | 4 - cocos2d/core/layers/CCLayerPropertyDefine.js | 20 - cocos2d/core/sprites/CCSprite.js | 20 +- cocos2d/core/sprites/SpritesWebGL.js | 16 +- cocos2d/labels/CCLabelAtlas.js | 4 +- cocos2d/labels/CCLabelBMFont.js | 24 +- cocos2d/menus/CCMenuItem.js | 6 +- cocos2d/motion-streak/CCMotionStreak.js | 6 +- cocos2d/parallax/CCParallaxNode.js | 12 +- cocos2d/progress-timer/CCProgressTimer.js | 8 +- cocos2d/tilemap/CCTMXTiledMap.js | 2 +- .../ccui/base-classes/CCProtectedNode.js | 4 +- extensions/ccui/system/CocosGUI.js | 10 +- extensions/cocostudio/CocoStudio.js | 8 - extensions/cocostudio/armature/CCArmature.js | 12 +- extensions/cocostudio/armature/CCBone.js | 16 +- .../gui/control-extension/CCScale9Sprite.js | 12 +- extensions/spine/CCSkeleton.js | 4 +- 22 files changed, 311 insertions(+), 381 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js index 82669c6f9e..ba1e23502e 100644 --- a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +++ b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js @@ -120,11 +120,7 @@ cc._tmp.PrototypeCCNode = function () { /** @expose */ _p.glServerState; cc.defineGetterSetter(_p, "glServerState", _p.getGLServerState, _p.setGLServerState); -}; -cc._tmp.PrototypeCCNodeRGBA = function () { - - var _p = cc.NodeRGBA.prototype; /** @expose */ _p.opacity; cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); @@ -140,6 +136,4 @@ cc._tmp.PrototypeCCNodeRGBA = function () { /** @expose */ _p.cascadeColor; cc.defineGetterSetter(_p, "cascadeColor", _p.isCascadeColorEnabled, _p.setCascadeColorEnabled); -}; - - +}; \ No newline at end of file diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index a754678219..ea2d959a0e 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -33,14 +33,14 @@ *

All features from cc.Node are valid, plus the following features:
* - opacity and RGB colors

* @class - * @extends cc.NodeRGBA + * @extends cc.Node * * @property {cc.Texture2D} texture - Current used texture * @property {cc.TextureAtlas} textureAtlas - Texture atlas for cc.AtlasNode * @property {Number} quadsToDraw - Number of quads to draw * */ -cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ +cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ textureAtlas: null, quadsToDraw: 0, @@ -74,7 +74,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ * var node = new cc.AtlasNode("pathOfTile", 16, 16, 1); */ ctor: function (tile, tileWidth, tileHeight, itemsToRender) { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._colorUnmodified = cc.color.WHITE; this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; this._ignoreContentScaleFactor = false; @@ -95,7 +95,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ getColor: function () { if (this._opacityModifyRGB) return this._colorUnmodified; - return cc.NodeRGBA.prototype.getColor.call(this); + return cc.Node.prototype.getColor.call(this); }, /** @@ -272,7 +272,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ temp.g = temp.g * locDisplayedOpacity / 255; temp.b = temp.b * locDisplayedOpacity / 255; } - cc.NodeRGBA.prototype.setColor.call(this, color3); + cc.Node.prototype.setColor.call(this, color3); if (this.texture) { var element = this._originalTexture.getHtmlElementObj(); @@ -299,7 +299,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ temp.g = temp.g * locDisplayedOpacity / 255; temp.b = temp.b * locDisplayedOpacity / 255; } - cc.NodeRGBA.prototype.setColor.call(this, color3); + cc.Node.prototype.setColor.call(this, color3); var locDisplayedColor = this._displayedColor; this._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, locDisplayedColor.b / 255.0, locDisplayedOpacity / 255.0]); @@ -313,7 +313,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ }, _setOpacityForCanvas: function (opacity) { - cc.NodeRGBA.prototype.setOpacity.call(this, opacity); + cc.Node.prototype.setOpacity.call(this, opacity); // special opacity for premultiplied textures if (this._opacityModifyRGB) { this.color = this._colorUnmodified; @@ -321,7 +321,7 @@ cc.AtlasNode = cc.NodeRGBA.extend(/** @lends cc.AtlasNode# */{ }, _setOpacityForWebGL: function (opacity) { - cc.NodeRGBA.prototype.setOpacity.call(this, opacity); + cc.Node.prototype.setOpacity.call(this, opacity); // special opacity for premultiplied textures if (this._opacityModifyRGB) { this.color = this._colorUnmodified; diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 49408c1017..f1b3409b12 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -176,6 +176,15 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _showNode: false, _name: "", ///
0) { - _t.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - child = children[i]; - if (child._localZOrder < 0) - child.visit(context); - else - break; - } - _t.draw(context); - for (; i < len; i++) { - children[i].visit(context); - } - } else - _t.draw(context); - - this._cacheDirty = false; - _t.arrivalOrder = 0; - context.restore(); - }; - - _p.transform = function (ctx) { - // transform for canvas - var context = ctx || cc._renderContext, eglViewer = cc.view; - - var t = this.nodeToParentTransform(); - context.transform(t.a, t.c, t.b, t.d, t.tx * eglViewer.getScaleX(), -t.ty * eglViewer.getScaleY()); - }; - - _p.nodeToParentTransform = function () { - var _t = this; - if (_t._transformDirty) { - var t = _t._transform;// quick reference - - // base position - t.tx = _t._position.x; - t.ty = _t._position.y; - - // rotation Cos and Sin - var Cos = 1, Sin = 0; - if (_t._rotationX) { - Cos = Math.cos(_t._rotationRadiansX); - Sin = Math.sin(_t._rotationRadiansX); - } - - // base abcd - t.a = t.d = Cos; - t.b = -Sin; - t.c = Sin; - - var lScaleX = _t._scaleX, lScaleY = _t._scaleY; - var appX = _t._anchorPointInPoints.x, appY = _t._anchorPointInPoints.y; - - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - - // skew - if (_t._skewX || _t._skewY) { - // offset the anchorpoint - var skx = Math.tan(-_t._skewX * Math.PI / 180); - var sky = Math.tan(-_t._skewY * Math.PI / 180); - if(skx === Infinity){ - skx = 99999999; - } - if(sky === Infinity){ - sky = 99999999; - } - var xx = appY * skx * sx; - var yy = appX * sky * sy; - t.a = Cos + -Sin * sky; - t.b = Cos * skx + -Sin; - t.c = Sin + Cos * sky; - t.d = Sin * skx + Cos; - t.tx += Cos * xx + -Sin * yy; - t.ty += Sin * xx + Cos * yy; - } - - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.c *= sx; - t.b *= sy; - t.d *= sy; - } - - // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * appY * sy; - t.ty -= Sin * -appX * sx + Cos * appY * sy; - - // if ignore anchorPoint - if (_t._ignoreAnchorPointForPosition) { - t.tx += appX; - t.ty += appY; - } - - if (_t._additionalTransformDirty) { - _t._transform = cc.AffineTransformConcat(t, _t._additionalTransform); - _t._additionalTransformDirty = false; - } - - _t._transformDirty = false; - } - return _t._transform; - }; - - _p = null; - -} else { - cc.assert(typeof cc._tmp.WebGLCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesWebGL.js"); - cc._tmp.WebGLCCNode(); - delete cc._tmp.WebGLCCNode; -} -cc.assert(typeof cc._tmp.PrototypeCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); -cc._tmp.PrototypeCCNode(); -delete cc._tmp.PrototypeCCNode; - - -/** - *

- * cc.NodeRGBA is a subclass of cc.Node that implements the CCRGBAProtocol protocol.
- *
- * All features from CCNode are valid, plus the following new features:
- * - opacity
- * - RGB colors
- *
- * Opacity/Color propagates into children that conform to the CCRGBAProtocol if cascadeOpacity/cascadeColor is enabled.
- *

- * - * @class - * @extends cc.Node - * - * @property {Number} opacity - Opacity of node - * @property {Boolean} opacityModifyRGB - Indicate whether or not the opacity modify color - * @property {Boolean} cascadeOpacity - Indicate whether or not it will set cascade opacity - * @property {cc.Color} color - Color of node - * @property {Boolean} cascadeColor - Indicate whether or not it will set cascade color - */ -cc.NodeRGBA = cc.Node.extend(/** @lends cc.NodeRGBA# */{ - RGBAProtocol: true, - _displayedOpacity: 255, - _realOpacity: 255, - _displayedColor: null, - _realColor: null, - _cascadeColorEnabled: false, - _cascadeOpacityEnabled: false, - - ctor: function () { - cc.Node.prototype.ctor.call(this); - this._displayedOpacity = 255; - this._realOpacity = 255; - this._displayedColor = cc.color(255, 255, 255, 255); - this._realColor = cc.color(255, 255, 255, 255); - this._cascadeColorEnabled = false; - this._cascadeOpacityEnabled = false; }, _updateColor: function(){ @@ -2498,22 +2351,6 @@ cc.NodeRGBA = cc.Node.extend(/** @lends cc.NodeRGBA# */{ } }, - /** - * add a child to node - * @overried - * @param {cc.Node} child A child node - * @param {Number} [zOrder=] Z order for drawing priority. Please refer to setZOrder(int) - * @param {Number} [tag=] A integer to identify the node easily. Please refer to setTag(int) - */ - addChild: function (child, zOrder, tag) { - cc.Node.prototype.addChild.call(this, child, zOrder, tag); - - if (this._cascadeColorEnabled) - this._enableCascadeColor(); - if (this._cascadeOpacityEnabled) - this._enableCascadeOpacity(); - }, - setOpacityModifyRGB: function (opacityValue) { }, @@ -2521,15 +2358,170 @@ cc.NodeRGBA = cc.Node.extend(/** @lends cc.NodeRGBA# */{ return false; } }); -cc.NodeRGBA.create = function () { - var res = new cc.NodeRGBA(); - res.init(); - return res; + +/** + * allocates and initializes a node. + * @constructs + * @return {cc.Node} + * @example + * // example + * var node = cc.Node.create(); + */ +cc.Node.create = function () { + return new cc.Node(); }; -cc.assert(typeof cc._tmp.PrototypeCCNodeRGBA === "function", cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); -cc._tmp.PrototypeCCNodeRGBA(); -delete cc._tmp.PrototypeCCNodeRGBA; +/** + * cc.Node's state callback type + * @constant + * @type Number + */ +cc.Node.StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7}; + +if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + + //redefine cc.Node + var _p = cc.Node.prototype; + _p.ctor = function () { + this._initNode(); + }; + + _p.setNodeDirty = function () { + var _t = this; + _t._setNodeDirtyForCache(); + _t._transformDirty === false && (_t._transformDirty = _t._inverseDirty = true); + }; + + _p.visit = function (ctx) { + var _t = this; + // quick return if not visible + if (!_t._visible) + return; + + //visit for canvas + var context = ctx || cc._renderContext, i; + var children = _t._children, child; + context.save(); + _t.transform(context); + var len = children.length; + if (len > 0) { + _t.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + child = children[i]; + if (child._localZOrder < 0) + child.visit(context); + else + break; + } + _t.draw(context); + for (; i < len; i++) { + children[i].visit(context); + } + } else + _t.draw(context); + + this._cacheDirty = false; + _t.arrivalOrder = 0; + context.restore(); + }; + + _p.transform = function (ctx) { + // transform for canvas + var context = ctx || cc._renderContext, eglViewer = cc.view; + + var t = this.nodeToParentTransform(); + context.transform(t.a, t.c, t.b, t.d, t.tx * eglViewer.getScaleX(), -t.ty * eglViewer.getScaleY()); + }; + + _p.nodeToParentTransform = function () { + var _t = this; + if (_t._transformDirty) { + var t = _t._transform;// quick reference + + // base position + t.tx = _t._position.x; + t.ty = _t._position.y; + + // rotation Cos and Sin + var Cos = 1, Sin = 0; + if (_t._rotationX) { + Cos = Math.cos(_t._rotationRadiansX); + Sin = Math.sin(_t._rotationRadiansX); + } + + // base abcd + t.a = t.d = Cos; + t.b = -Sin; + t.c = Sin; + + var lScaleX = _t._scaleX, lScaleY = _t._scaleY; + var appX = _t._anchorPointInPoints.x, appY = _t._anchorPointInPoints.y; + + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + + // skew + if (_t._skewX || _t._skewY) { + // offset the anchorpoint + var skx = Math.tan(-_t._skewX * Math.PI / 180); + var sky = Math.tan(-_t._skewY * Math.PI / 180); + if(skx === Infinity){ + skx = 99999999; + } + if(sky === Infinity){ + sky = 99999999; + } + var xx = appY * skx * sx; + var yy = appX * sky * sy; + t.a = Cos + -Sin * sky; + t.b = Cos * skx + -Sin; + t.c = Sin + Cos * sky; + t.d = Sin * skx + Cos; + t.tx += Cos * xx + -Sin * yy; + t.ty += Sin * xx + Cos * yy; + } + + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + t.a *= sx; + t.c *= sx; + t.b *= sy; + t.d *= sy; + } + + // adjust anchorPoint + t.tx += Cos * -appX * sx + -Sin * appY * sy; + t.ty -= Sin * -appX * sx + Cos * appY * sy; + + // if ignore anchorPoint + if (_t._ignoreAnchorPointForPosition) { + t.tx += appX; + t.ty += appY; + } + + if (_t._additionalTransformDirty) { + _t._transform = cc.AffineTransformConcat(t, _t._additionalTransform); + _t._additionalTransformDirty = false; + } + + _t._transformDirty = false; + } + return _t._transform; + }; + + _p = null; + +} else { + cc.assert(typeof cc._tmp.WebGLCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesWebGL.js"); + cc._tmp.WebGLCCNode(); + delete cc._tmp.WebGLCCNode; +} +cc.assert(typeof cc._tmp.PrototypeCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); +cc._tmp.PrototypeCCNode(); +delete cc._tmp.PrototypeCCNode; /** * Node on enter diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index a1e5e8b237..48297c50b6 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -227,7 +227,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ updateDisplayedOpacity: null, updateDisplayedOpacityForCanvas: function (parentOpacity) { - cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, parentOpacity); + cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); this._setColorsString(); }, @@ -1031,7 +1031,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _p = cc.LabelTTF.prototype; _p.setColor = function (color3) { - cc.NodeRGBA.prototype.setColor.call(this, color3); + cc.Node.prototype.setColor.call(this, color3); this._setColorsString(); }; @@ -1050,7 +1050,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; _p.updateDisplayedColor = function (parentColor) { - cc.NodeRGBA.prototype.updateDisplayedColor.call(this, parentColor); + cc.Node.prototype.updateDisplayedColor.call(this, parentColor); this._setColorsString(); }; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 49e1b6cae2..6e7227976b 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -454,10 +454,6 @@ cc.LayerRGBA = cc.Layer.extend(/** @lends cc.LayerRGBA# */{ } }); -cc.assert(typeof cc._tmp.PrototypeLayerRGBA === "function", cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); -cc._tmp.PrototypeLayerRGBA(); -delete cc._tmp.PrototypeLayerRGBA; - /** *

* CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
diff --git a/cocos2d/core/layers/CCLayerPropertyDefine.js b/cocos2d/core/layers/CCLayerPropertyDefine.js index f88eedf13d..0600fa1dd6 100644 --- a/cocos2d/core/layers/CCLayerPropertyDefine.js +++ b/cocos2d/core/layers/CCLayerPropertyDefine.js @@ -24,26 +24,6 @@ THE SOFTWARE. ****************************************************************************/ -cc._tmp.PrototypeLayerRGBA = function () { - var _p = cc.LayerRGBA.prototype; - // Extended properties - /** @expose */ - _p.opacityModifyRGB; - cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB); - /** @expose */ - _p.opacity; - cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); - /** @expose */ - _p.cascadeOpacity; - cc.defineGetterSetter(_p, "cascadeOpacity", _p.isCascadeOpacityEnabled, _p.setCascadeOpacityEnabled); - /** @expose */ - _p.color; - cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); - /** @expose */ - _p.cascadeColor; - cc.defineGetterSetter(_p, "cascadeColor", _p.isCascadeColorEnabled, _p.setCascadeColorEnabled); -}; - cc._tmp.PrototypeLayerColor = function () { var _p = cc.LayerColor.prototype; // Override properties diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 582b616703..a4fd9943bc 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -239,7 +239,7 @@ cc.cutRotateImageToCanvas = function (texture, rect) { * * The default anchorPoint in cc.Sprite is (0.5, 0.5).

* @class - * @extends cc.NodeRGBA + * @extends cc.Node * * @property {Boolean} dirty - Indicates whether the sprite needs to be updated. * @property {Boolean} flippedX - Indicates whether or not the spirte is flipped on x axis. @@ -257,7 +257,7 @@ cc.cutRotateImageToCanvas = function (texture, rect) { * var aSprite = new cc.Sprite(); * aSprite.initWithFile("HelloHTML5World.png",cc.rect(0,0,480,320)); */ -cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{ +cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ RGBAProtocol:true, dirty:false, atlasIndex:0, @@ -1183,13 +1183,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; _p.updateDisplayedOpacity = function (parentOpacity) { - cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, parentOpacity); + cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); this._setNodeDirtyForCache(); }; _p.ctor = function (fileName, rect, rotated) { var self = this; - cc.NodeRGBA.prototype.ctor.call(self); + cc.Node.prototype.ctor.call(self); self._shouldBeHidden = false; self._offsetPosition = cc.p(0, 0); self._unflippedOffsetPositionFromCenter = cc.p(0, 0); @@ -1222,7 +1222,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (arguments.length > 0) return _t.initWithFile(arguments[0], arguments[1]); - cc.NodeRGBA.prototype.init.call(_t); + cc.Node.prototype.init.call(_t); _t.dirty = _t._recursiveDirty = false; _t._opacityModifyRGB = true; @@ -1266,7 +1266,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._rect = cc.rect(0, 0, rect.width, rect.height); } - if (!cc.NodeRGBA.prototype.init.call(_t)) + if (!cc.Node.prototype.init.call(_t)) return false; _t._batchNode = null; @@ -1418,12 +1418,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { tag = child.tag; //cc.Node already sets isReorderChildDirty_ so this needs to be after batchNode check - cc.NodeRGBA.prototype.addChild.call(this, child, localZOrder, tag); + cc.Node.prototype.addChild.call(this, child, localZOrder, tag); this._hasChildren = true; }; _p.setOpacity = function (opacity) { - cc.NodeRGBA.prototype.setOpacity.call(this, opacity); + cc.Node.prototype.setOpacity.call(this, opacity); this._setNodeDirtyForCache(); }; @@ -1433,7 +1433,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if ((curColor.r === color3.r) && (curColor.g === color3.g) && (curColor.b === color3.b)) return; - cc.NodeRGBA.prototype.setColor.call(_t, color3); + cc.Node.prototype.setColor.call(_t, color3); _t._changeTextureColor(); _t._setNodeDirtyForCache(); }; @@ -1441,7 +1441,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateDisplayedColor = function (parentColor) { var _t = this; var oldColor = _t.color; - cc.NodeRGBA.prototype.updateDisplayedColor.call(_t, parentColor); + cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); var newColor = _t._displayedColor; if ((oldColor.r === newColor.r) && (oldColor.g === newColor.g) && (oldColor.b === newColor.b)) return; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 3f333fb003..7dd51d73de 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -43,13 +43,13 @@ cc._tmp.WebGLSprite = function () { }; _p.updateDisplayedOpacity = function (parentOpacity) { - cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, parentOpacity); + cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); this.updateColor(); }; _p.ctor = function (fileName, rect, rotated) { var self = this; - cc.NodeRGBA.prototype.ctor.call(self); + cc.Node.prototype.ctor.call(self); self._shouldBeHidden = false; self._offsetPosition = cc.p(0, 0); self._unflippedOffsetPositionFromCenter = cc.p(0, 0); @@ -81,7 +81,7 @@ cc._tmp.WebGLSprite = function () { if (arguments.length > 0) return _t.initWithFile(arguments[0], arguments[1]); - cc.NodeRGBA.prototype.init.call(_t); + cc.Node.prototype.init.call(_t); _t.dirty = _t._recursiveDirty = false; _t._opacityModifyRGB = true; @@ -125,7 +125,7 @@ cc._tmp.WebGLSprite = function () { rotated = rotated || false; - if (!cc.NodeRGBA.prototype.init.call(_t)) + if (!cc.Node.prototype.init.call(_t)) return false; _t._batchNode = null; @@ -382,22 +382,22 @@ cc._tmp.WebGLSprite = function () { } //cc.Node already sets isReorderChildDirty_ so _t needs to be after batchNode check - cc.NodeRGBA.prototype.addChild.call(_t, child, localZOrder, tag); + cc.Node.prototype.addChild.call(_t, child, localZOrder, tag); _t._hasChildren = true; }; _p.setOpacity = function (opacity) { - cc.NodeRGBA.prototype.setOpacity.call(this, opacity); + cc.Node.prototype.setOpacity.call(this, opacity); this.updateColor(); }; _p.setColor = function (color3) { - cc.NodeRGBA.prototype.setColor.call(this, color3); + cc.Node.prototype.setColor.call(this, color3); this.updateColor(); }; _p.updateDisplayedColor = function (parentColor) { - cc.NodeRGBA.prototype.updateDisplayedColor.call(this, parentColor); + cc.Node.prototype.updateDisplayedColor.call(this, parentColor); this.updateColor(); }; diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 0a9899b37e..193b2af818 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -184,7 +184,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ _addChildForCanvas: function(child, zOrder, tag){ child._lateChild = true; - cc.NodeRGBA.prototype.addChild.call(this, child, zOrder, tag); + cc.Node.prototype.addChild.call(this, child, zOrder, tag); }, /** @@ -215,7 +215,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ } else fontChar.initWithTexture(texture, rect); - cc.NodeRGBA.prototype.addChild.call(this, fontChar, 0, i); + cc.Node.prototype.addChild.call(this, fontChar, 0, i); } else { if (c == 32) { fontChar.init(); diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 9b308760d3..543208bc13 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -285,7 +285,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (cc._renderType == cc._RENDER_TYPE_WEBGL) { locChild.updateDisplayedOpacity(this._displayedOpacity); } else { - cc.NodeRGBA.prototype.updateDisplayedOpacity.call(locChild, this._displayedOpacity); + cc.Node.prototype.updateDisplayedOpacity.call(locChild, this._displayedOpacity); locChild.setNodeDirty(); } } @@ -322,7 +322,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (cc._renderType == cc._RENDER_TYPE_WEBGL) { locChild.updateDisplayedColor(this._displayedColor); } else { - cc.NodeRGBA.prototype.updateDisplayedColor.call(locChild, this._displayedColor); + cc.Node.prototype.updateDisplayedColor.call(locChild, this._displayedColor); locChild.setNodeDirty(); } } @@ -524,8 +524,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ fontChar.updateDisplayedColor(self._displayedColor); fontChar.updateDisplayedOpacity(self._displayedOpacity); } else { - cc.NodeRGBA.prototype.updateDisplayedColor.call(fontChar, self._displayedColor); - cc.NodeRGBA.prototype.updateDisplayedOpacity.call(fontChar, self._displayedOpacity); + cc.Node.prototype.updateDisplayedColor.call(fontChar, self._displayedColor); + cc.Node.prototype.updateDisplayedOpacity.call(fontChar, self._displayedOpacity); fontChar.setNodeDirty(); } @@ -953,22 +953,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var _p = cc.LabelBMFont.prototype; -// Extended properties -/** @expose */ -_p.opacityModifyRGB; -cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB); -/** @expose */ -_p.opacity; -cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); -/** @expose */ -_p.cascadeOpacity; -cc.defineGetterSetter(_p, "cascadeOpacity", _p.isCascadeOpacityEnabled, _p.setCascadeOpacityEnabled); -/** @expose */ -_p.color; -cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); -/** @expose */ -_p.cascadeColor; -cc.defineGetterSetter(_p, "cascadeColor", _p.isCascadeColorEnabled, _p.setCascadeColorEnabled); /** @expose */ _p.string; cc.defineGetterSetter(_p, "string", _p.getString, _p._setStringForSetter); diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index d9d998cfc6..dc9ef696fb 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -31,11 +31,11 @@ cc._globalFontNameRelease = false; /** * Subclass cc.MenuItem (or any subclass) to create your custom cc.MenuItem objects. * @class - * @extends cc.NodeRGBA + * @extends cc.Node * * @property {Boolean} enabled - Indicate whether item is enabled */ -cc.MenuItem = cc.NodeRGBA.extend(/** @lends cc.MenuItem# */{ +cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ _enabled: false, _target: null, _callback: null, @@ -48,7 +48,7 @@ cc.MenuItem = cc.NodeRGBA.extend(/** @lends cc.MenuItem# */{ * @param {cc.Node} target */ ctor: function (callback, target) { - var nodeP = cc.NodeRGBA.prototype; + var nodeP = cc.Node.prototype; nodeP.ctor.call(this); this._target = null; this._callback = null; diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index cd575a6093..9110f5aa5a 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -34,13 +34,13 @@ * length is the how many pixels the texture is stretched across. The texture
* is vertically aligned along the streak segment. * @class - * @extends cc.NodeRGBA + * @extends cc.Node * * @property {cc.Texture2D} texture - Texture used for the motion streak. * @property {Boolean} fastMode - Indicate whether use fast mode. * @property {Boolean} startingPositionInitialized - Indicate whether starting position initialized. */ -cc.MotionStreak = cc.NodeRGBA.extend(/** @lends cc.MotionStreak# */{ +cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ texture:null, fastMode:false, startingPositionInitialized:false, @@ -79,7 +79,7 @@ cc.MotionStreak = cc.NodeRGBA.extend(/** @lends cc.MotionStreak# */{ * @param {string|cc.Texture2D} texture texture filename or texture */ ctor: function (fade, minSeg, stroke, color, texture) { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._positionR = cc.p(0, 0); this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); this._vertexWebGLBuffer = cc._renderContext.createBuffer(); diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index afb25a7b72..22ae5920fa 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -107,7 +107,7 @@ cc.PointObject.create = function (ratio, offset) { * * @property {Array} parallaxArray - Parallax nodes array */ -cc.ParallaxNode = cc.NodeRGBA.extend(/** @lends cc.ParallaxNode# */{ +cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ parallaxArray:null, _lastPosition:null, @@ -131,7 +131,7 @@ cc.ParallaxNode = cc.NodeRGBA.extend(/** @lends cc.ParallaxNode# */{ * Constructor */ ctor:function () { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this.parallaxArray = []; this._lastPosition = cc.p(-100, -100); }, @@ -160,7 +160,7 @@ cc.ParallaxNode = cc.NodeRGBA.extend(/** @lends cc.ParallaxNode# */{ child.setPosition(this._position.x * ratio.x + offset.x, this._position.y * ratio.y + offset.y); - cc.NodeRGBA.prototype.addChild.call(this, child, z, child.tag); + cc.Node.prototype.addChild.call(this, child, z, child.tag); }, /** @@ -180,7 +180,7 @@ cc.ParallaxNode = cc.NodeRGBA.extend(/** @lends cc.ParallaxNode# */{ break; } } - cc.NodeRGBA.prototype.removeChild.call(this, child, cleanup); + cc.Node.prototype.removeChild.call(this, child, cleanup); }, /** @@ -189,7 +189,7 @@ cc.ParallaxNode = cc.NodeRGBA.extend(/** @lends cc.ParallaxNode# */{ */ removeAllChildren:function (cleanup) { this.parallaxArray.length = 0; - cc.NodeRGBA.prototype.removeAllChildren.call(this, cleanup); + cc.Node.prototype.removeAllChildren.call(this, cleanup); }, /** @@ -207,7 +207,7 @@ cc.ParallaxNode = cc.NodeRGBA.extend(/** @lends cc.ParallaxNode# */{ } this._lastPosition = pos; } - cc.NodeRGBA.prototype.visit.call(this); + cc.Node.prototype.visit.call(this); }, _absolutePosition:function () { diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 9b0e76503b..f9c916444d 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -30,7 +30,7 @@ * It renders the inner sprite according to the percentage.
* The progress can be Radial, Horizontal or vertical. * @class - * @extends cc.NodeRGBA + * @extends cc.Node * * @property {cc.Point} midPoint

- Midpoint is used to modify the progress start position.
* If you're using radials type then the midpoint changes the center point
@@ -46,7 +46,7 @@ * @property {cc.Sprite} sprite - The sprite to show the progress percentage. * @property {Boolean} reverseDir - Indicate whether the direction is reversed. */ -cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{ +cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ _type:null, _percentage:0.0, _sprite:null, @@ -170,7 +170,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{ ctor: null, _ctorForCanvas: function () { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._type = cc.ProgressTimer.TYPE_RADIAL; this._percentage = 0.0; @@ -189,7 +189,7 @@ cc.ProgressTimer = cc.NodeRGBA.extend(/** @lends cc.ProgressTimer# */{ }, _ctorForWebGL: function () { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._type = cc.ProgressTimer.TYPE_RADIAL; this._percentage = 0.0; this._midPoint = cc.p(0, 0); diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index ddfd9ff82a..1300a5a60b 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -106,7 +106,7 @@ cc.TMX_ORIENTATION_ISO = 2; * @property {Number} tileWidth - Width of a tile * @property {Number} tileHeight - Height of a tile */ -cc.TMXTiledMap = cc.NodeRGBA.extend(/** @lends cc.TMXTiledMap# */{ +cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ properties: null, mapOrientation: null, objectGroups: null, diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 6bb2c346aa..fe99f82b76 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Node +cc.ProtectedNode = cc.Node.extend({ _protectedChildren: null, _reorderProtectedChildDirty: false, @@ -33,7 +33,7 @@ cc.ProtectedNode = cc.NodeRGBA.extend({ //TODO merge cc.NodeRGBA to cc.Nod }, ctor: function(){ - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._protectedChildren = []; }, diff --git a/extensions/ccui/system/CocosGUI.js b/extensions/ccui/system/CocosGUI.js index 52fb7a2269..3ddb231317 100644 --- a/extensions/ccui/system/CocosGUI.js +++ b/extensions/ccui/system/CocosGUI.js @@ -45,19 +45,11 @@ ccui.Class.extend = ccui.Class.extend || cc.Class.extend; ccui.Node = ccui.Node || cc.Node; ccui.Node.extend = ccui.Node.extend || cc.Node.extend; -/** - * that same as cc.NodeRGBA - * @class - * @extends ccui.Node - */ -ccui.NodeRGBA = ccui.NodeRGBA || cc.NodeRGBA; -ccui.NodeRGBA.extend = ccui.NodeRGBA.extend || cc.NodeRGBA.extend; - /** * that same as cc.Node * @class - * @extends ccui.NodeRGBA + * @extends ccui.Node */ ccui.ProtectedNode = ccui.ProtectedNode || cc.ProtectedNode; ccui.ProtectedNode.extend = ccui.ProtectedNode.extend || cc.ProtectedNode.extend; diff --git a/extensions/cocostudio/CocoStudio.js b/extensions/cocostudio/CocoStudio.js index db30e9692f..10b70186af 100644 --- a/extensions/cocostudio/CocoStudio.js +++ b/extensions/cocostudio/CocoStudio.js @@ -44,14 +44,6 @@ ccs.Class.extend = ccs.Class.extend || cc.Class.extend; ccs.Node = ccs.Node || cc.Node; ccs.Node.extend = ccs.Node.extend || cc.Node.extend; -/** - * The same as cc.RBGA - * @class - * @extends ccs.Class - */ -ccs.NodeRGBA = ccs.NodeRGBA || cc.NodeRGBA; -ccs.NodeRGBA.extend = ccs.NodeRGBA.extend || cc.NodeRGBA.extend; - /** * The same as cc.Sprite * @class diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 080c24cc56..bf15673d60 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -26,7 +26,7 @@ /** * Base class for ccs.Armature objects. * @class - * @extends ccs.NodeRGBA + * @extends ccs.Node * * @property {ccs.Bone} parentBone - The parent bone of the armature node * @property {ccs.ArmatureAnimation} animation - The animation @@ -37,7 +37,7 @@ * @property {Object} body - The body of the armature * @property {ccs.ColliderFilter} colliderFilter - <@writeonly> The collider filter of the armature */ -ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ +ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ animation: null, armatureData: null, batchNode: null, @@ -64,7 +64,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ * var armature = new ccs.Armature(); */ ctor: function (name, parentBone) { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this.animation = null; this.armatureData = null; this.batchNode = null; @@ -91,7 +91,7 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ * @return {Boolean} */ init: function (name, parentBone) { - cc.NodeRGBA.prototype.init.call(this); + cc.Node.prototype.init.call(this); if (parentBone) { this._parentBone = parentBone; } @@ -163,11 +163,11 @@ ccs.Armature = ccs.NodeRGBA.extend(/** @lends ccs.Armature# */{ return true; }, onEnter: function () { - cc.NodeRGBA.prototype.onEnter.call(this); + cc.Node.prototype.onEnter.call(this); this.scheduleUpdate(); }, onExit: function () { - cc.NodeRGBA.prototype.onExit.call(this); + cc.Node.prototype.onExit.call(this); this.unscheduleUpdate(); }, /** diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index c6c02b90df..136ee3a9a9 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -26,7 +26,7 @@ /** * Base class for ccs.Bone objects. * @class - * @extends ccs.NodeRGBA + * @extends ccs.Node * * @property {ccs.BoneData} boneData - The bone data * @property {ccs.Armature} armature - The armature @@ -43,7 +43,7 @@ * @property {Boolean} blendDirty - Indicate whether the blend is dirty * */ -ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ +ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ _boneData: null, _armature: null, _childArmature: null, @@ -63,7 +63,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ _dataVersion: 0, _className: "Bone", ctor: function () { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._boneData = null; this._armature = null; this._childArmature = null; @@ -101,7 +101,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ * @return {Boolean} */ init: function (name) { - cc.NodeRGBA.prototype.init.call(this); + cc.Node.prototype.init.call(this); if (name) { this.name = name; } @@ -258,7 +258,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ */ updateDisplayedColor: function (color) { this._realColor = cc.color(255, 255, 255); - cc.NodeRGBA.prototype.updateDisplayedColor.call(this, color); + cc.Node.prototype.updateDisplayedColor.call(this, color); this.updateColor(); }, @@ -268,7 +268,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ */ updateDisplayedOpacity: function (opacity) { this._realOpacity = 255; - cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, opacity); + cc.Node.prototype.updateDisplayedOpacity.call(this, opacity); this.updateColor(); }, @@ -277,7 +277,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ * @param {cc.Color} color */ setColor: function (color) { - cc.NodeRGBA.prototype.setColor.call(this, color); + cc.Node.prototype.setColor.call(this, color); this.updateColor(); }, @@ -286,7 +286,7 @@ ccs.Bone = ccs.NodeRGBA.extend(/** @lends ccs.Bone# */{ * @param {Number} opacity 0-255 */ setOpacity: function (opacity) { - cc.NodeRGBA.prototype.setOpacity.call(this, opacity); + cc.Node.prototype.setOpacity.call(this, opacity); this.updateColor(); }, diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index ab82a877da..a4bedebf2f 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -37,7 +37,7 @@ * * @see http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html * @class - * @extends cc.NodeRGBA + * @extends cc.Node * * @property {cc.Size} preferredSize - The preferred size of the 9-slice sprite * @property {cc.Rect} capInsets - The cap insets of the 9-slice sprite @@ -46,7 +46,7 @@ * @property {Number} insetRight - The right inset of the 9-slice sprite * @property {Number} insetBottom - The bottom inset of the 9-slice sprite */ -cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{ +cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ RGBAProtocol: true, _spriteRect: null, @@ -199,7 +199,7 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{ }, ctor: function () { - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._spriteRect = cc.rect(0, 0, 0, 0); this._capInsetsInternal = cc.rect(0, 0, 0, 0); @@ -259,7 +259,7 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{ }, updateDisplayedOpacity: function(parentOpacity){ - cc.NodeRGBA.prototype.updateDisplayedOpacity.call(this, parentOpacity); + cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); this.setOpacity(this._displayedOpacity); }, @@ -290,7 +290,7 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{ }, updateDisplayedColor: function(parentColor){ - cc.NodeRGBA.prototype.updateDisplayedColor.call(this, parentColor); + cc.Node.prototype.updateDisplayedColor.call(this, parentColor); this.setColor(this._displayedColor); }, @@ -401,7 +401,7 @@ cc.Scale9Sprite = cc.NodeRGBA.extend(/** @lends cc.Scale9Sprite# */{ this._updatePositions(); this._positionsAreDirty = false; } - cc.NodeRGBA.prototype.visit.call(this, ctx); + cc.Node.prototype.visit.call(this, ctx); }, init: function () { diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index a4c8dd0d6f..c9acf2b8b7 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -43,7 +43,7 @@ sp.ATTACHMENT_TYPE = { BOUNDING_BOX: 2 }; -sp.Skeleton = cc.NodeRGBA.extend({ +sp.Skeleton = cc.Node.extend({ _skeleton: null, _rootBone: null, _timeScale: 1, @@ -54,7 +54,7 @@ sp.Skeleton = cc.NodeRGBA.extend({ _atlas: null, _blendFunc: null, ctor:function(){ - cc.NodeRGBA.prototype.ctor.call(this); + cc.Node.prototype.ctor.call(this); this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; }, init: function () { From df22d982c9a19b7297cc16c734799a229286ecda Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 9 Jul 2014 11:50:44 +0800 Subject: [PATCH 0268/1564] Issue #5688: merge cc.LayerRGBA to cc.Node --- cocos2d/core/layers/CCLayer.js | 282 +----------------- cocos2d/core/layers/CCLayerWebGL.js | 2 +- cocos2d/menus/CCMenu.js | 8 +- extensions/gui/control-extension/CCControl.js | 8 +- 4 files changed, 18 insertions(+), 282 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 6e7227976b..9d98a7ab03 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -190,270 +190,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { delete cc._tmp.LayerDefineForWebGL; } -/** - *

- * CCLayerRGBA is a subclass of CCLayer that implements the CCRGBAProtocol protocol using a solid color as the background.
- * All features from CCLayer are valid, plus the following new features that propagate into children that conform to the CCRGBAProtocol:
- * - opacity
- * - RGB colors - *

- * @class - * @extends cc.Layer - * - * @property {Number} opacity - Opacity of layer - * @property {Boolean} opacityModifyRGB - Indicate whether or not the opacity modify color - * @property {Boolean} cascadeOpacity - Indicate whether or not it will set cascade opacity - * @property {cc.Color} color - Color of layer - * @property {Boolean} cascadeColor - Indicate whether or not it will set cascade color - */ -cc.LayerRGBA = cc.Layer.extend(/** @lends cc.LayerRGBA# */{ - RGBAProtocol: true, - _displayedOpacity: 255, - _realOpacity: 255, - _displayedColor: null, - _realColor: null, - _cascadeOpacityEnabled: false, - _cascadeColorEnabled: false, - _className: "LayerRGBA", - - /** - * Constructor of cc.LayerRGBA - */ - ctor: function () { - cc.Layer.prototype.ctor.call(this); - this._displayedColor = cc.color(255, 255, 255, 255); - this._realColor = cc.color(255, 255, 255, 255); - }, - - init: function () { - var nodep = cc.Layer.prototype, _t = this; - _t._ignoreAnchorPointForPosition = true; - nodep.setAnchorPoint.call(_t, 0.5, 0.5); - nodep.setContentSize.call(_t, cc.winSize); - _t.cascadeOpacity = false; - _t.cascadeColor = false; - return true; - }, - - /** - * Get the opacity of Layer - * @returns {number} opacity - */ - getOpacity: function () { - return this._realOpacity; - }, - - /** - * Get the displayed opacity of Layer - * @returns {number} displayed opacity - */ - getDisplayedOpacity: function () { - return this._displayedOpacity; - }, - - /** - * Override synthesized setOpacity to recurse items - * @param {Number} opacity - */ - setOpacity: function (opacity) { - var _t = this; - _t._displayedOpacity = _t._realOpacity = opacity; - - var parentOpacity = 255, locParent = _t._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeOpacity) - parentOpacity = locParent.getDisplayedOpacity(); - _t.updateDisplayedOpacity(parentOpacity); - - _t._displayedColor.a = _t._realColor.a = opacity; - }, - - /** - * Update displayed opacity of Layer - * @param {Number} parentOpacity - */ - updateDisplayedOpacity: function (parentOpacity) { - var _t = this; - _t._displayedOpacity = 0 | (_t._realOpacity * parentOpacity / 255.0); - - if (_t._cascadeOpacityEnabled) { - var locChildren = _t._children, selItem; - for (var i = 0; i < locChildren.length; i++) { - selItem = locChildren[i]; - if (selItem && selItem.RGBAProtocol) - selItem.updateDisplayedOpacity(_t._displayedOpacity); - } - } - }, - - /** - * whether or not it will set cascade opacity. - * @returns {boolean} - */ - isCascadeOpacityEnabled: function () { - return this._cascadeOpacityEnabled; - }, - - /** - * Enable or disable cascade opacity - * @param {boolean} cascadeOpacityEnabled - */ - setCascadeOpacityEnabled: function (cascadeOpacityEnabled) { - if (this._cascadeOpacityEnabled === cascadeOpacityEnabled) - return; - - this._cascadeOpacityEnabled = cascadeOpacityEnabled; - if (cascadeOpacityEnabled) - this._enableCascadeOpacity(); - else - this._disableCascadeOpacity(); - }, - - _enableCascadeOpacity: function () { - var parentOpacity = 255, locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeOpacity) - parentOpacity = locParent.getDisplayedOpacity(); - this.updateDisplayedOpacity(parentOpacity); - }, - - _disableCascadeOpacity: function () { - this._displayedOpacity = this._realOpacity; - var selChildren = this._children, item; - for (var i = 0; i < selChildren.length; i++) { - item = selChildren[i]; - if (item && item.RGBAProtocol) - item.updateDisplayedOpacity(255); - } - }, - - /** - * Get the color of Layer - * @returns {cc.Color} - */ - getColor: function () { - var locRealColor = this._realColor; - return cc.color(locRealColor.r, locRealColor.g, locRealColor.b, locRealColor.a); - }, - - /** - * Get the displayed color of Layer - * @returns {cc.Color} - */ - getDisplayedColor: function () { - var locDisplayedColor = this._displayedColor; - return cc.color(locDisplayedColor.r, locDisplayedColor.g, locDisplayedColor.b); - }, - - /** - * Set the color of Layer - * @param {cc.Color} color - */ - setColor: function (color) { - var locDisplayed = this._displayedColor, locRealColor = this._realColor; - locDisplayed.r = locRealColor.r = color.r; - locDisplayed.g = locRealColor.g = color.g; - locDisplayed.b = locRealColor.b = color.b; - - var parentColor, locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeColor) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - this.updateDisplayedColor(parentColor); - - if (color.a !== undefined && !color.a_undefined) { - this.setOpacity(color.a); - } - }, - - /** - * update the displayed color of Node - * @param {cc.Color} parentColor - */ - updateDisplayedColor: function (parentColor) { - var locDisplayedColor = this._displayedColor, locRealColor = this._realColor; - locDisplayedColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); - locDisplayedColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); - locDisplayedColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - - if (this._cascadeColorEnabled) { - var locChildren = this._children, selItem; - for (var i = 0; i < locChildren.length; i++) { - selItem = locChildren[i]; - if (selItem && selItem.RGBAProtocol) - selItem.updateDisplayedColor(locDisplayedColor); - } - } - }, - - /** - * whether or not it will set cascade color. - * @returns {boolean} - */ - isCascadeColorEnabled: function () { - return this._cascadeColorEnabled; - }, - - /** - * Enable or disable cascade color - * @param {boolean} cascadeColorEnabled - */ - setCascadeColorEnabled: function (cascadeColorEnabled) { - if (this._cascadeColorEnabled === cascadeColorEnabled) - return; - this._cascadeColorEnabled = cascadeColorEnabled; - if (this._cascadeColorEnabled) - this._enableCascadeColor(); - else - this._disableCascadeColor(); - }, - - _enableCascadeColor: function () { - var parentColor , locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeColor) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - this.updateDisplayedColor(parentColor); - }, - - _disableCascadeColor: function () { - var locDisplayedColor = this._displayedColor, locRealColor = this._realColor; - locDisplayedColor.r = locRealColor.r; - locDisplayedColor.g = locRealColor.g; - locDisplayedColor.b = locRealColor.b; - - var selChildren = this._children, whiteColor = cc.color.WHITE, item, i; - for (i = 0; i < selChildren.length; i++) { - item = selChildren[i]; - if (item && item.RGBAProtocol) - item.updateDisplayedColor(whiteColor); - } - }, - - /** - * add a child to layer - * @overried - * @param {cc.Node} child A child node - * @param {Number} [zOrder=] Z order for drawing priority. Please refer to setLocalZOrder(int) - * @param {Number} [tag=] A integer to identify the node easily. Please refer to setTag(int) - */ - addChild: function (child, zOrder, tag) { - cc.Node.prototype.addChild.call(this, child, zOrder, tag); - - if (this._cascadeColorEnabled) - this._enableCascadeColor(); - if (this._cascadeOpacityEnabled) - this._enableCascadeOpacity(); - }, - - setOpacityModifyRGB: function (bValue) { - }, - - isOpacityModifyRGB: function () { - return false; - } -}); - /** *

* CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
@@ -462,9 +198,9 @@ cc.LayerRGBA = cc.Layer.extend(/** @lends cc.LayerRGBA# */{ *

  • RGB colors

  • *

    * @class - * @extends cc.LayerRGBA + * @extends cc.Layer */ -cc.LayerColor = cc.LayerRGBA.extend(/** @lends cc.LayerColor# */{ +cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ _blendFunc: null, _className: "LayerColor", @@ -521,12 +257,12 @@ cc.LayerColor = cc.LayerRGBA.extend(/** @lends cc.LayerColor# */{ }, setColor: function (color) { - cc.LayerRGBA.prototype.setColor.call(this, color); + cc.Layer.prototype.setColor.call(this, color); this._updateColor(); }, setOpacity: function (opacity) { - cc.LayerRGBA.prototype.setOpacity.call(this, opacity); + cc.Layer.prototype.setOpacity.call(this, opacity); this._updateColor(); }, @@ -596,12 +332,12 @@ cc.LayerColor = cc.LayerRGBA.extend(/** @lends cc.LayerColor# */{ _updateColor: null, updateDisplayedColor: function (parentColor) { - cc.LayerRGBA.prototype.updateDisplayedColor.call(this, parentColor); + cc.Layer.prototype.updateDisplayedColor.call(this, parentColor); this._updateColor(); }, updateDisplayedOpacity: function (parentOpacity) { - cc.LayerRGBA.prototype.updateDisplayedOpacity.call(this, parentOpacity); + cc.Layer.prototype.updateDisplayedOpacity.call(this, parentOpacity); this._updateColor(); }, @@ -636,12 +372,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerColor define start var _p = cc.LayerColor.prototype; _p.ctor = function (color, width, height) { - cc.LayerRGBA.prototype.ctor.call(this); + cc.Layer.prototype.ctor.call(this); this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); cc.LayerColor.prototype.init.call(this, color, width, height); }; - _p._setWidth = cc.LayerRGBA.prototype._setWidth; - _p._setHeight = cc.LayerRGBA.prototype._setHeight; + _p._setWidth = cc.Layer.prototype._setWidth; + _p._setHeight = cc.Layer.prototype._setHeight; _p._updateColor = function () { }; _p.draw = function (ctx) { diff --git a/cocos2d/core/layers/CCLayerWebGL.js b/cocos2d/core/layers/CCLayerWebGL.js index 7b4d26ee45..77a3579333 100644 --- a/cocos2d/core/layers/CCLayerWebGL.js +++ b/cocos2d/core/layers/CCLayerWebGL.js @@ -59,7 +59,7 @@ cc._tmp.WebGLLayerColor = function () { _t._verticesFloat32Buffer = cc._renderContext.createBuffer(); _t._colorsUint8Buffer = cc._renderContext.createBuffer(); - cc.LayerRGBA.prototype.ctor.call(_t); + cc.Layer.prototype.ctor.call(_t); _t._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); cc.LayerColor.prototype.init.call(_t, color, width, height); diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 37fddb1581..4b7a5705ff 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -50,11 +50,11 @@ cc.DEFAULT_PADDING = 5; * - You can add MenuItem objects in runtime using addChild:
    * - But the only accepted children are MenuItem objects

    * @class - * @extends cc.LayerRGBA + * @extends cc.Layer * * @property {Boolean} enabled - Indicates whether or not the menu is enabled */ -cc.Menu = cc.LayerRGBA.extend(/** @lends cc.Menu# */{ +cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ enabled: false, _color: null, @@ -76,7 +76,7 @@ cc.Menu = cc.LayerRGBA.extend(/** @lends cc.Menu# */{ * var myMenu2 = cc.Menu.create([menuitem1, menuitem2, menuitem3]); */ ctor: function (menuItems) { - cc.LayerRGBA.prototype.ctor.call(this); + cc.Layer.prototype.ctor.call(this); this._color = cc.color.WHITE; this.enabled = false; this._opacity = 255; @@ -209,7 +209,7 @@ cc.Menu = cc.LayerRGBA.extend(/** @lends cc.Menu# */{ * @return {Boolean} */ initWithArray: function (arrayOfItems) { - if (cc.LayerRGBA.prototype.init.call(this)) { + if (cc.Layer.prototype.init.call(this)) { this.enabled = true; // menu in the center of the screen diff --git a/extensions/gui/control-extension/CCControl.js b/extensions/gui/control-extension/CCControl.js index dd519f76ee..cb81b0bf1c 100644 --- a/extensions/gui/control-extension/CCControl.js +++ b/extensions/gui/control-extension/CCControl.js @@ -55,14 +55,14 @@ cc.CONTROL_STATE_INITIAL = 1 << 3; * certain events occur. * To use the CCControl you have to subclass it. * @class - * @extends cc.LayerRGBA + * @extends cc.Layer * * @property {Number} state - <@readonly> The current control state: cc.CONTROL_STATE_NORMAL | cc.CONTROL_STATE_HIGHLIGHTED | cc.CONTROL_STATE_DISABLED | cc.CONTROL_STATE_SELECTED | cc.CONTROL_STATE_INITIAL * @property {Boolean} enabled - Indicate whether the control node is enbaled * @property {Boolean} selected - Indicate whether the control node is selected * @property {Boolean} highlighted - Indicate whether the control node is highlighted */ -cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{ +cc.Control = cc.Layer.extend(/** @lends cc.Control# */{ _isOpacityModifyRGB: false, _hasVisibleParents: false, _touchListener: null, @@ -142,13 +142,13 @@ cc.Control = cc.LayerRGBA.extend(/** @lends cc.Control# */{ }, ctor: function () { - cc.LayerRGBA.prototype.ctor.call(this); + cc.Layer.prototype.ctor.call(this); this._dispatchTable = {}; this._color = cc.color.WHITE; }, init: function () { - if (cc.LayerRGBA.prototype.init.call(this)) { + if (cc.Layer.prototype.init.call(this)) { // Initialise instance variables this._state = cc.CONTROL_STATE_NORMAL; this._enabled = true; From 69ebd1c951757c007dd04880700c6bb81a74a3b5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 9 Jul 2014 11:57:32 +0800 Subject: [PATCH 0269/1564] Issue #5688: merge cc.LayerRGBA to cc.Layer --- cocos2d/core/layers/CCLayer.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 9d98a7ab03..ef6251fee7 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -47,6 +47,16 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ nodep.setContentSize.call(this, cc.winSize); }, + init: function(){ + var _t = this; + _t._ignoreAnchorPointForPosition = true; + _t.setAnchorPoint(0.5, 0.5); + _t.setContentSize(cc.winSize); + _t.cascadeOpacity = false; + _t.cascadeColor = false; + return true; + }, + /** * set the layer to cache all of children to a bake sprite, and draw itself by bake sprite. recommend using it in UI. * @function From fa571835cfc9beb6a5485847fd97aaa6b6a20bf9 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 9 Jul 2014 15:56:37 +0800 Subject: [PATCH 0270/1564] issue #5685:remove useless code in actioniterval --- cocos2d/actions/CCActionInterval.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index e845e9a719..5f8b44bf50 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -1117,9 +1117,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ * var actionBy = cc.RotateBy.create(2, 360); */ cc.RotateBy.create = function (duration, deltaAngleX, deltaAngleY) { - var rotateBy = new cc.RotateBy(); - rotateBy.initWithDuration(duration, deltaAngleX, deltaAngleY); - return rotateBy; + return new cc.RotateBy(duration, deltaAngleX, deltaAngleY); }; @@ -1504,10 +1502,7 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ * var actionBy = cc.SkewBy.create(2, 0, -90); */ cc.SkewBy.create = function (t, sx, sy) { - var skewBy = new cc.SkewBy(); - if (skewBy) - skewBy.initWithDuration(t, sx, sy); - return skewBy; + return new cc.SkewBy(t, sx, sy); }; @@ -2053,9 +2048,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ * var actionTo = cc.ScaleTo.create(2, 0.5, 2); */ cc.ScaleTo.create = function (duration, sx, sy) { //function overload - var scaleTo = new cc.ScaleTo(); - scaleTo.initWithDuration(duration, sx, sy); - return scaleTo; + return cc.ScaleTo(duration, sx, sy); }; @@ -2195,9 +2188,7 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ * var action = cc.Blink.create(2, 10); */ cc.Blink.create = function (duration, blinks) { - var blink = new cc.Blink(); - blink.initWithDuration(duration, blinks); - return blink; + return cc.Blink(duration, blinks); }; /** Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. @@ -2368,9 +2359,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ * var action = cc.FadeOut.create(1.0); */ cc.FadeOut.create = function (d) { - var action = new cc.FadeOut(); - action.initWithDuration(d, 0); - return action; + return cc.FadeOut(d, 0); }; /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. From bbf3e5161cb35bd5cd69fe6ad52c5eb8ea5ae89d Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 9 Jul 2014 16:03:59 +0800 Subject: [PATCH 0271/1564] issue #5685: fix bugs in create function --- cocos2d/actions/CCActionInterval.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 5f8b44bf50..025fbaa4a6 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2048,7 +2048,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ * var actionTo = cc.ScaleTo.create(2, 0.5, 2); */ cc.ScaleTo.create = function (duration, sx, sy) { //function overload - return cc.ScaleTo(duration, sx, sy); + return new cc.ScaleTo(duration, sx, sy); }; @@ -2188,7 +2188,7 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ * var action = cc.Blink.create(2, 10); */ cc.Blink.create = function (duration, blinks) { - return cc.Blink(duration, blinks); + return new cc.Blink(duration, blinks); }; /** Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. @@ -2359,7 +2359,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ * var action = cc.FadeOut.create(1.0); */ cc.FadeOut.create = function (d) { - return cc.FadeOut(d, 0); + return new cc.FadeOut(d, 0); }; /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. From 569afba05337e878f7f565c9634d2c3219cb6505 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 9 Jul 2014 16:10:56 +0800 Subject: [PATCH 0272/1564] Issue #5671: Fixed a bug about generateTintImage --- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/core/sprites/CCSpriteFrame.js | 2 +- cocos2d/core/sprites/SpritesWebGL.js | 2 +- cocos2d/particle/CCParticleSystem.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index f95f25f0ea..a1f8fed4ad 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1306,7 +1306,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { rect = cc.rect(0, 0, texture.width, texture.height); } - if(texture) { + if(texture && texture.url) { var _x = rect.x + rect.width, _y = rect.y + rect.height; if(_x > texture.width){ cc.error(cc._LogInfos.RectWidth, texture.url); diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index f710157cbd..3b8a221885 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -355,7 +355,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ } texture = this.getTexture(); - if(texture) { + if(texture && texture.url) { var _x, _y; if(rotated){ _x = rect.x + rect.height; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 521d681c01..e2450610ad 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -175,7 +175,7 @@ cc._tmp.WebGLSprite = function () { rect = cc.rect(0, 0, texture.width, texture.height); } - if(texture) { + if(texture && texture.url) { var _x, _y; if(rotated){ _x = rect.x + rect.height; diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 197b883a36..cc8bd3ce4c 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2440,7 +2440,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ cacheTextureForColor.tintCache.width = element.width; cacheTextureForColor.tintCache.height = element.height; } - cc.generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); + cc.generateTintImageWithLight(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); element = cacheTextureForColor.tintCache; } } From f383f18521af63bb420f998cd92b578ca240a39b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 9 Jul 2014 16:14:36 +0800 Subject: [PATCH 0273/1564] Issue #5671: Fixed a bug about generateTintImage --- cocos2d/core/base-nodes/CCAtlasNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index ea2d959a0e..29a74c3014 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -281,7 +281,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ var cacheTextureForColor = cc.textureCache.getTextureColors(element); if (cacheTextureForColor) { var textureRect = cc.rect(0, 0, element.width, element.height); - element = cc.generateTintImage(element, cacheTextureForColor, this._realColor, textureRect); + element = cc.generateTintImageWithLight(element, cacheTextureForColor, this._realColor, textureRect); var locTexture = new cc.Texture2D(); locTexture.initWithElement(element); locTexture.handleLoadedTexture(); From 12f69b9f586322661156356d10605a0bd1ccc7b9 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 10 Jul 2014 11:35:46 +0800 Subject: [PATCH 0274/1564] Fixed #5671: refactor other classes with new tint method. --- cocos2d/core/base-nodes/CCAtlasNode.js | 47 +++++++++++++++---- cocos2d/core/sprites/CCSprite.js | 23 +++++---- cocos2d/labels/CCLabelBMFont.js | 57 ++++++++++++++++------- cocos2d/particle/CCParticleSystem.js | 64 +++++++++++++++----------- 4 files changed, 129 insertions(+), 62 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 29a74c3014..14813518bf 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -273,19 +273,25 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ temp.b = temp.b * locDisplayedOpacity / 255; } cc.Node.prototype.setColor.call(this, color3); + this._changeTextureColor(); + }, - if (this.texture) { + _changeTextureColor: function(){ + var locTexture = this.getTexture(); + if (locTexture && this._originalTexture) { var element = this._originalTexture.getHtmlElementObj(); - if (!element) + if(!element) return; - var cacheTextureForColor = cc.textureCache.getTextureColors(element); - if (cacheTextureForColor) { - var textureRect = cc.rect(0, 0, element.width, element.height); - element = cc.generateTintImageWithLight(element, cacheTextureForColor, this._realColor, textureRect); - var locTexture = new cc.Texture2D(); - locTexture.initWithElement(element); + var locElement = locTexture.getHtmlElementObj(); + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement) + cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); + else { + locElement = cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); - this.texture = locTexture; + this.setTexture(locTexture); } } }, @@ -418,6 +424,29 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { _p.getTexture = _p._getTextureForCanvas; _p.setTexture = _p._setTextureForCanvas; _p._calculateMaxItems = _p._calculateMaxItemsForCanvas; + if(!cc.sys._supportCanvasNewBlendModes) + _p._changeTextureColor = function(){ + var locElement, locTexture = this.getTexture(); + if (locTexture && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + var element = this._originalTexture.getHtmlElementObj(); + var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(element); + if (cacheTextureForColor) { + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement) + cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect, locElement); + else { + locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.setTexture(locTexture); + } + } + } + }; } // Override properties diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index a1f8fed4ad..2d0e5f2252 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -32,13 +32,17 @@ * @param {HTMLCanvasElement} renderCanvas * @returns {HTMLCanvasElement} */ -cc.generateTintImage = function(image, color, rect, renderCanvas){ +cc.generateTintImageWithMultiply = function(image, color, rect, renderCanvas){ renderCanvas = renderCanvas || cc.newElement("canvas"); rect = rect || cc.rect(0,0, image.width, image.height); var context = renderCanvas.getContext( "2d" ); - renderCanvas.width = rect.width; - renderCanvas.height = rect.height; + if(renderCanvas.width != rect.width || renderCanvas.height != rect.height){ + renderCanvas.width = rect.width; + renderCanvas.height = rect.height; + }else{ + context.globalCompositeOperation = "source-over"; + } context.fillStyle = "rgb(" + color.r + "," + color.g + "," + color.b + ")"; context.fillRect(0, 0, rect.width, rect.height); @@ -66,7 +70,7 @@ cc.generateTintImage = function(image, color, rect, renderCanvas){ }; /** - * generate tinted texture + * generate tinted texture with lighter. * lighter: The source and destination colors are added to each other, resulting in brighter colors, * moving towards color values of 1 (maximum brightness for that color). * @function @@ -77,7 +81,7 @@ cc.generateTintImage = function(image, color, rect, renderCanvas){ * @param {HTMLCanvasElement} [renderCanvas] * @return {HTMLCanvasElement} */ -cc.generateTintImageWithLight = function (texture, tintedImgCache, color, rect, renderCanvas) { +cc.generateTintImage = function (texture, tintedImgCache, color, rect, renderCanvas) { if (!rect) rect = cc.rect(0, 0, texture.width, texture.height); @@ -1022,9 +1026,9 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ this._colorized = true; if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.generateTintImage(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); + cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); else { - locElement = cc.generateTintImage(this._originalTexture._htmlElementObj, this._displayedColor, locRect); + locElement = cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); @@ -1431,6 +1435,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var curColor = _t.color; if ((curColor.r === color3.r) && (curColor.g === color3.g) && (curColor.b === color3.b)) return; + cc.Node.prototype.setColor.call(_t, color3); }; _p.updateDisplayedColor = function (parentColor) { @@ -1622,9 +1627,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._colorized = true; //generate color texture cache if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.generateTintImageWithLight(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); + cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); else { - locElement = cc.generateTintImageWithLight(locElement, cacheTextureForColor, this._displayedColor, locRect); + locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 543208bc13..108ddc7bc3 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -330,25 +330,24 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, _changeTextureColor: function () { - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + if (cc._renderType == cc._RENDER_TYPE_WEBGL) return; - } - var locElement, locTexture = this.texture; - if (locTexture && locTexture.width > 0) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) + + var locTexture = this.getTexture(); + if (locTexture && locTexture.getContentSize().width>0) { + var element = this._originalTexture.getHtmlElementObj(); + if(!element) return; - var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); - if (cacheTextureForColor) { - if (locElement instanceof HTMLCanvasElement && !this._rectRotated) - cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); - else { - locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.texture = locTexture; - } + var locElement = locTexture.getHtmlElementObj(); + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement && !this._rectRotated) + cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); + else { + locElement = cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.setTexture(locTexture); } } }, @@ -953,6 +952,30 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var _p = cc.LabelBMFont.prototype; +if(cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes) + _p._changeTextureColor = function(){ + if(cc._renderType == cc._RENDER_TYPE_WEBGL) + return; + var locElement, locTexture = this.getTexture(); + if (locTexture && locTexture.getContentSize().width>0) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(this._originalTexture.getHtmlElementObj()); + if (cacheTextureForColor) { + if (locElement instanceof HTMLCanvasElement && !this._rectRotated) + cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); + else{ + locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.setTexture(locTexture); + } + } + } + }; + /** @expose */ _p.string; cc.defineGetterSetter(_p, "string", _p.getString, _p._setStringForSetter); diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index cc8bd3ce4c..fad06e33e5 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2118,10 +2118,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // color if (!this._dontTint || cc._renderType === cc._RENDER_TYPE_CANVAS) { - selParticle.color.r += (selParticle.deltaColor.r * dt); - selParticle.color.g += (selParticle.deltaColor.g * dt); - selParticle.color.b += (selParticle.deltaColor.b * dt); - selParticle.color.a += (selParticle.deltaColor.a * dt); + selParticle.color.r += 0|(selParticle.deltaColor.r * dt); + selParticle.color.g += 0|(selParticle.deltaColor.g * dt); + selParticle.color.b += 0|(selParticle.deltaColor.b * dt); + selParticle.color.a += 0|(selParticle.deltaColor.a * dt); selParticle.isChangeColor = true; } @@ -2399,14 +2399,12 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ else context.globalCompositeOperation = 'source-over'; + var element = this._texture.getHtmlElementObj(); for (var i = 0; i < this.particleCount; i++) { var particle = this._particles[i]; var lpx = (0 | (particle.size * 0.5)); if (this.drawMode == cc.ParticleSystem.TEXTURE_MODE) { - - var element = this._texture.getHtmlElementObj(); - // Delay drawing until the texture is fully loaded by the browser if (!element.width || !element.height) continue; @@ -2424,30 +2422,13 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ Math.max((1 / h) * size, 0.000001) ); - if (particle.rotation) context.rotate(cc.degreesToRadians(particle.rotation)); - context.translate(-(0 | (w / 2)), -(0 | (h / 2))); - if (particle.isChangeColor) { - - var cacheTextureForColor = cc.textureCache.getTextureColors(element); - if (cacheTextureForColor) { - // Create another cache for the tinted version - // This speeds up things by a fair bit - if (!cacheTextureForColor.tintCache) { - cacheTextureForColor.tintCache = cc.newElement('canvas'); - cacheTextureForColor.tintCache.width = element.width; - cacheTextureForColor.tintCache.height = element.height; - } - cc.generateTintImageWithLight(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); - element = cacheTextureForColor.tintCache; - } - } - - context.drawImage(element, 0, 0); + var drawElement = particle.isChangeColor ? this._changeTextureColor(element, particle.color, this._pointRect) : element; + if(drawElement) + context.drawImage(drawElement, 0, 0); context.restore(); - } else { context.save(); context.globalAlpha = particle.color.a / 255; @@ -2466,6 +2447,18 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ context.restore(); }, + _changeTextureColor: function(element, color, rect){ + color.r = 0|color.r; + color.g = 0|color.g; + color.b = 0|color.b; + if (!element.tintCache) { + element.tintCache = document.createElement('canvas'); + element.tintCache.width = element.width; + element.tintCache.height = element.height; + } + return cc.generateTintImageWithMultiply(element, color, rect, element.tintCache); + }, + _drawForWebGL:function (ctx) { if(!this._texture) return; @@ -2592,6 +2585,23 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ var _p = cc.ParticleSystem.prototype; +if(cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes) + _p._changeTextureColor = function (element, color, rect) { + var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(element); + if (cacheTextureForColor) { + // Create another cache for the tinted version + // This speeds up things by a fair bit + if (!cacheTextureForColor.tintCache) { + cacheTextureForColor.tintCache = document.createElement('canvas'); + cacheTextureForColor.tintCache.width = element.width; + cacheTextureForColor.tintCache.height = element.height; + } + cc.generateTintImage(element, cacheTextureForColor, color, rect, cacheTextureForColor.tintCache); + return cacheTextureForColor.tintCache; + } + return null + }; + // Extended properties /** @expose */ _p.opacityModifyRGB; From d3d05fd4208cc50f27b111c22140c8b55969fde4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 10 Jul 2014 11:46:15 +0800 Subject: [PATCH 0275/1564] Issue #5688: Fixed a bug about sprite set color --- cocos2d/core/sprites/CCSprite.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 2d0e5f2252..7218a13bc0 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1440,11 +1440,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateDisplayedColor = function (parentColor) { var _t = this; - var oldColor = _t.color; cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); - var newColor = _t._displayedColor; - if ((oldColor.r === newColor.r) && (oldColor.g === newColor.g) && (oldColor.b === newColor.b)) - return; + _t._changeTextureColor(); _t._setNodeDirtyForCache(); }; From 350519e9f075adf70cc9d52dd4dc3dda2a7503cf Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 10 Jul 2014 13:37:17 +0800 Subject: [PATCH 0276/1564] Issue #5699: delete RGBAProtocol --- cocos2d/actions/CCActionInterval.js | 42 +++++++++---------- cocos2d/core/base-nodes/CCAtlasNode.js | 1 - cocos2d/core/base-nodes/CCNode.js | 16 +++---- cocos2d/core/sprites/CCSprite.js | 1 - cocos2d/labels/CCLabelBMFont.js | 7 ++-- extensions/ccui/base-classes/UIWidget.js | 10 ++--- extensions/cocostudio/armature/CCBone.js | 2 +- .../armature/display/CCDisplayManager.js | 8 ++-- extensions/gui/control-extension/CCControl.js | 2 +- .../gui/control-extension/CCControlButton.js | 6 +-- .../gui/control-extension/CCMenuPassive.js | 5 +-- .../gui/control-extension/CCScale9Sprite.js | 5 +-- 12 files changed, 47 insertions(+), 58 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 025fbaa4a6..e317c0e184 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2241,10 +2241,9 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ */ update:function (time) { time = this._computeEaseTime(time); - if (this.target.RGBAProtocol) { - var fromOpacity = this._fromOpacity !== undefined ? this._fromOpacity : 255; - this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time; - } + var fromOpacity = this._fromOpacity !== undefined ? this._fromOpacity : 255; + this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time; + }, /** @@ -2252,9 +2251,9 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); - if(this.target.RGBAProtocol){ - this._fromOpacity = target.opacity; - } + + this._fromOpacity = target.opacity; + } }); @@ -2420,9 +2419,8 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); - if (this.target.RGBAProtocol) { - this._from = this.target.color; - } + + this._from = this.target.color; }, /** @@ -2431,7 +2429,7 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ update:function (time) { time = this._computeEaseTime(time); var locFrom = this._from, locTo = this._to; - if (locFrom && this.target.RGBAProtocol) { + if (locFrom) { this.target.color = cc.color(locFrom.r + (locTo.r - locFrom.r) * time, locFrom.g + (locTo.g - locFrom.g) * time, locFrom.b + (locTo.b - locFrom.b) * time); @@ -2514,12 +2512,12 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); - if (target.RGBAProtocol) { - var color = target.color; - this._fromR = color.r; - this._fromG = color.g; - this._fromB = color.b; - } + + var color = target.color; + this._fromR = color.r; + this._fromG = color.g; + this._fromB = color.b; + }, /** @@ -2527,11 +2525,11 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ */ update:function (time) { time = this._computeEaseTime(time); - if (this.target.RGBAProtocol) { - this.target.color = cc.color(this._fromR + this._deltaR * time, - this._fromG + this._deltaG * time, - this._fromB + this._deltaB * time); - } + + this.target.color = cc.color(this._fromR + this._deltaR * time, + this._fromG + this._deltaG * time, + this._fromB + this._deltaB * time); + }, /** diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 14813518bf..62c649c7e2 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -44,7 +44,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ textureAtlas: null, quadsToDraw: 0, - RGBAProtocol: true, //! chars per row _itemsPerRow: 0, //! chars per column diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 09640fb667..acff1364e8 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2182,7 +2182,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ this._displayedOpacity = this._realOpacity = opacity; var parentOpacity = 255, locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeOpacity) + if (locParent && locParent.cascadeOpacity) parentOpacity = locParent.getDisplayedOpacity(); this.updateDisplayedOpacity(parentOpacity); @@ -2199,7 +2199,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var selChildren = this._children; for (var i = 0; i < selChildren.length; i++) { var item = selChildren[i]; - if (item && item.RGBAProtocol) + if (item) item.updateDisplayedOpacity(this._displayedOpacity); } } @@ -2230,7 +2230,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _enableCascadeOpacity: function () { var parentOpacity = 255, locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeOpacity) + if (locParent && locParent.cascadeOpacity) parentOpacity = locParent.getDisplayedOpacity(); this.updateDisplayedOpacity(parentOpacity); }, @@ -2241,7 +2241,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var selChildren = this._children; for (var i = 0; i < selChildren.length; i++) { var item = selChildren[i]; - if (item && item.RGBAProtocol) + if (item) item.updateDisplayedOpacity(255); } }, @@ -2275,7 +2275,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ locDisplayedColor.b = locRealColor.b = color.b; var parentColor, locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeColor) + if (locParent && locParent.cascadeColor) parentColor = locParent.getDisplayedColor(); else parentColor = cc.color.WHITE; @@ -2300,7 +2300,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var selChildren = this._children; for (var i = 0; i < selChildren.length; i++) { var item = selChildren[i]; - if (item && item.RGBAProtocol) + if (item) item.updateDisplayedColor(locDispColor); } } @@ -2330,7 +2330,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _enableCascadeColor: function () { var parentColor , locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeColor) + if (locParent && locParent.cascadeColor) parentColor = locParent.getDisplayedColor(); else parentColor = cc.color.WHITE; @@ -2346,7 +2346,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var selChildren = this._children, whiteColor = cc.color.WHITE; for (var i = 0; i < selChildren.length; i++) { var item = selChildren[i]; - if (item && item.RGBAProtocol) + if (item) item.updateDisplayedColor(whiteColor); } }, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 7218a13bc0..58f9c2b007 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -268,7 +268,6 @@ cc.cutRotateImageToCanvas = function (texture, rect) { * aSprite.initWithFile("HelloHTML5World.png",cc.rect(0,0,480,320)); */ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ - RGBAProtocol:true, dirty:false, atlasIndex:0, textureAtlas:null, diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 108ddc7bc3..0a823f5b99 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -70,7 +70,6 @@ cc.LABEL_AUTOMATIC_WIDTH = -1; * @property {Number} boundingWidth - Width of the bounding box of label, the real content width is limited by boundingWidth */ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ - RGBAProtocol: true, _opacityModifyRGB: false, @@ -218,7 +217,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (this._cascadeColorEnabled) { var parentColor = cc.color.WHITE; var locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeColor) + if (locParent && locParent.cascadeColor) parentColor = locParent.getDisplayedColor(); this.updateDisplayedColor(parentColor); } @@ -246,7 +245,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (locChildren) { for (var i = 0; i < locChildren.length; i++) { var node = locChildren[i]; - if (node && node.RGBAProtocol) + if (node) node.opacityModifyRGB = this._opacityModifyRGB; } } @@ -269,7 +268,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (this._cascadeOpacityEnabled) { var parentOpacity = 255; var locParent = this._parent; - if (locParent && locParent.RGBAProtocol && locParent.cascadeOpacity) + if (locParent && locParent.cascadeOpacity) parentOpacity = locParent.getDisplayedOpacity(); this.updateDisplayedOpacity(parentOpacity); } diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 4bc5cf88c0..b782a84a06 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1531,22 +1531,18 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ updateTextureOpacity: function (opacity) { for(var p in this._children){ var item = this._children[p]; - if(item && item.RGBAProtocol) + if(item) item.setOpacity(opacity); } }, updateColorToRenderer: function (renderer) { - if (renderer.RGBAProtocol) { - renderer.setColor(this._color); - } + renderer.setColor(this._color); }, updateOpacityToRenderer: function (renderer) { - if (renderer.RGBAProtocol) { - renderer.setOpacity(this._color.a); - } + renderer.setOpacity(this._color.a); }, updateRGBAToRenderer: function(renderer){ diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 3efdfe0053..fe0c8e56c2 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -295,7 +295,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ */ updateColor: function () { var display = this.displayManager.getDisplayRenderNode(); - if (display && display.RGBAProtocol) { + if (display) { var locDisplayedColor = this._displayedColor; var locTweenData = this._tweenData; var locOpacity = this._displayedOpacity * locTweenData.a / 255; diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 864940810b..b64874e1a4 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -294,10 +294,10 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ }else if(displayRenderNode instanceof cc.ParticleSystem) { displayRenderNode.resetSystem(); } - if (displayRenderNode.RGBAProtocol) { - displayRenderNode.setColor(this._bone.getDisplayedColor()); - displayRenderNode.setOpacity(this._bone.getDisplayedOpacity()); - } + + displayRenderNode.setColor(this._bone.getDisplayedColor()); + displayRenderNode.setOpacity(this._bone.getDisplayedOpacity()); + displayRenderNode.retain(); this._displayType = this._currentDecoDisplay.getDisplayData().displayType; //todo diff --git a/extensions/gui/control-extension/CCControl.js b/extensions/gui/control-extension/CCControl.js index cb81b0bf1c..392a2c3af1 100644 --- a/extensions/gui/control-extension/CCControl.js +++ b/extensions/gui/control-extension/CCControl.js @@ -77,7 +77,7 @@ cc.Control = cc.Layer.extend(/** @lends cc.Control# */{ var children = this.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var selNode = children[i]; - if (selNode && selNode.RGBAProtocol) + if (selNode) selNode.setOpacityModifyRGB(opacityModifyRGB); } }, diff --git a/extensions/gui/control-extension/CCControlButton.js b/extensions/gui/control-extension/CCControlButton.js index fe89f4e54c..de8d89281d 100644 --- a/extensions/gui/control-extension/CCControlButton.js +++ b/extensions/gui/control-extension/CCControlButton.js @@ -102,7 +102,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ var label = this._titleLabel; if (label && label.setString) label.setString(this._currentTitle); - if (label && label.RGBAProtocol) + if (label) label.setColor(this._currentTitleColor); var locContentSize = this.getContentSize(); @@ -158,7 +158,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ }, initWithLabelAndBackgroundSprite: function (label, backgroundSprite) { - if (!label || !label.RGBAProtocol) + if (!label) throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): label should be non-null"; if (!backgroundSprite) throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): backgroundSprite should be non-null"; @@ -305,7 +305,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ var controlChildren = this.getChildren(); for (var i = 0; i < controlChildren.length; i++) { var selChild = controlChildren[i]; - if (selChild && selChild.RGBAProtocol) + if (selChild) selChild.setOpacity(opacity); }*/ var locTable = this._backgroundSpriteDispatchTable; diff --git a/extensions/gui/control-extension/CCMenuPassive.js b/extensions/gui/control-extension/CCMenuPassive.js index 4a0da21985..d603c007ba 100644 --- a/extensions/gui/control-extension/CCMenuPassive.js +++ b/extensions/gui/control-extension/CCMenuPassive.js @@ -51,7 +51,6 @@ cc.Spacer.horizontalSpacer = function (space) { * @extend cc.Layer */ cc.MenuPassive = cc.Layer.extend(/** @lends cc.MenuPassive# */{ - RGBAProtocol:true, _color:null, _opacity:0, @@ -73,7 +72,7 @@ cc.MenuPassive = cc.Layer.extend(/** @lends cc.MenuPassive# */{ if (this._children && this._children.length > 0) { for (var i = 0; i < this._children.length; i++) { - if (this._children[i] && this._children[i].RGBAProtocol) { + if (this._children[i]) { this._children[i].setColor(color); } } @@ -93,7 +92,7 @@ cc.MenuPassive = cc.Layer.extend(/** @lends cc.MenuPassive# */{ if (this._children && this._children.length > 0) { for (var i = 0; i < this._children.length; i++) { - if (this._children[i] && this._children[i].RGBAProtocol) { + if (this._children[i]) { this._children[i].setOpacity(opacity); } } diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 1223f30ab6..3122a806f1 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -47,7 +47,6 @@ * @property {Number} insetBottom - The bottom inset of the 9-slice sprite */ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ - RGBAProtocol: true, _spriteRect: null, _capInsetsInternal: null, @@ -252,7 +251,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var scaleChildren = this._scale9Image.getChildren(); for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; - if (selChild && selChild.RGBAProtocol) + if (selChild) selChild.setOpacity(opacity); } this._color.a = opacity; @@ -280,7 +279,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var scaleChildren = this._scale9Image.getChildren(); for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; - if (selChild && selChild.RGBAProtocol) + if (selChild) selChild.setColor(color); } From 0414959f24f547a077985f31df9423b5a75fab7e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 10 Jul 2014 16:35:07 +0800 Subject: [PATCH 0277/1564] Fixed #5671: correct a mistake of cc.LabelBMFont --- cocos2d/labels/CCLabelBMFont.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 0a823f5b99..4e86d0e7ef 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -222,10 +222,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this.updateDisplayedColor(parentColor); } } - - if (color.a !== undefined && !color.a_undefined) { - this.setOpacity(color.a); - } }, /** @@ -339,9 +335,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ return; var locElement = locTexture.getHtmlElementObj(); var textureRect = cc.rect(0, 0, element.width, element.height); - if (locElement instanceof HTMLCanvasElement && !this._rectRotated) + if (locElement instanceof HTMLCanvasElement && !this._rectRotated){ cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); - else { + this.setTexture(locTexture); + } else { locElement = cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); @@ -960,7 +957,7 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendMo locElement = locTexture.getHtmlElementObj(); if (!locElement) return; - var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(this._originalTexture.getHtmlElementObj()); + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); if (cacheTextureForColor) { if (locElement instanceof HTMLCanvasElement && !this._rectRotated) cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); From b2d07c803182d7d197e4267e1a80bb032c676688 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 10 Jul 2014 16:39:00 +0800 Subject: [PATCH 0278/1564] Fixed #5671: correct 2 mistakes of cc.AtlasNode and cc.ParticleSystem --- cocos2d/core/base-nodes/CCAtlasNode.js | 2 +- cocos2d/particle/CCParticleSystem.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 62c649c7e2..52bc85ec1a 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -431,7 +431,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { if (!locElement) return; var element = this._originalTexture.getHtmlElementObj(); - var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(element); + var cacheTextureForColor = cc.textureCache.getTextureColors(element); if (cacheTextureForColor) { var textureRect = cc.rect(0, 0, element.width, element.height); if (locElement instanceof HTMLCanvasElement) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index fad06e33e5..b0446a9789 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2587,7 +2587,7 @@ var _p = cc.ParticleSystem.prototype; if(cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes) _p._changeTextureColor = function (element, color, rect) { - var cacheTextureForColor = cc.TextureCache.getInstance().getTextureColors(element); + var cacheTextureForColor = cc.textureCache.getTextureColors(element); if (cacheTextureForColor) { // Create another cache for the tinted version // This speeds up things by a fair bit From ca321edf28c9cade1d308648c1c62c5bb9de47af Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 11 Jul 2014 17:51:13 +0800 Subject: [PATCH 0279/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 1. CCArmature 2. CCArmatureAnimation 3. CCBone 4. CCColliderDetector 5. CCDataReaderHelper 6. CCProcessBase 7. CCSpriteFrameCacheHelper 8. CCTransformHelp 9. CCTween 10. CCTweenFunction --- extensions/cocostudio/armature/CCArmature.js | 759 +++++++++++------- extensions/cocostudio/armature/CCBone.js | 423 ++++++---- .../armature/animation/CCArmatureAnimation.js | 510 +++++++----- .../armature/animation/CCProcessBase.js | 27 +- .../cocostudio/armature/animation/CCTween.js | 48 +- .../armature/physics/CCColliderDetector.js | 191 +++-- .../armature/utils/CCDataReaderHelper.js | 29 +- .../utils/CCSpriteFrameCacheHelper.js | 36 +- .../armature/utils/CCTransformHelp.js | 44 + .../armature/utils/CCTweenFunction.js | 47 +- 10 files changed, 1355 insertions(+), 759 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 3fb48e9969..85fdef326c 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -54,6 +54,9 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ _textureAtlasDic: null, _blendFunc: null, _className: "Armature", + _realAnchorPointInPoints: null, + + nodeToParentTransform: null, /** * Create a armature node. @@ -80,6 +83,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._body = null; this._textureAtlasDic = null; this._blendFunc = null; + this._realAnchorPointInPoints = cc.p(0, 0); parentBone && ccs.Armature.prototype.init.call(this, name, parentBone); }, @@ -98,55 +102,68 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.removeAllChildren(); this.animation = new ccs.ArmatureAnimation(); this.animation.init(this); + this._boneDic = {}; this._topBoneList = []; - this._textureAtlasDic = {}; + + //this._textureAtlasDic = {}; + this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; - this.name = (!name) ? "" : name; + + this.name = name || ""; + var armatureDataManager = ccs.armatureDataManager; + + var animationData; if (name != "") { //animationData - var animationData = armatureDataManager.getAnimationData(name); - if (!animationData) { - cc.log("AnimationData not exist! "); - return false; - } + animationData = armatureDataManager.getAnimationData(name); + + cc.assert(animationData, "AnimationData not exist!"); + this.animation.setAnimationData(animationData); //armatureData var armatureData = armatureDataManager.getArmatureData(name); + cc.assert(armatureData, ""); + this.armatureData = armatureData; //boneDataDic var boneDataDic = armatureData.getBoneDataDic(); for (var key in boneDataDic) { var bone = this.createBone(String(key)); + //! init bone's Tween to 1st movement's 1st frame do { var movData = animationData.getMovement(animationData.movementNames[0]); if (!movData) { break; } + var _movBoneData = movData.getMovementBoneData(bone.getName()); if (!_movBoneData || _movBoneData.frameList.length <= 0) { break; } + var frameData = _movBoneData.getFrameData(0); if (!frameData) { break; } + bone.getTweenData().copy(frameData); bone.changeDisplayWithIndex(frameData.displayIndex, false); } while (0); } + this.update(0); this.updateOffsetPoint(); } else { this.name = "new_armature"; - this.armatureData = new ccs.ArmatureData(); + this.armatureData = ccs.ArmatureData.create(); this.armatureData.name = this.name; - var animationData = new ccs.AnimationData(); + animationData = ccs.AnimationData.create(); animationData.name = this.name; armatureDataManager.addArmatureData(this.name, this.armatureData); @@ -162,14 +179,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.setCascadeColorEnabled(true); return true; }, - onEnter: function () { - cc.Node.prototype.onEnter.call(this); - this.scheduleUpdate(); - }, - onExit: function () { - cc.Node.prototype.onExit.call(this); - this.unscheduleUpdate(); - }, + /** * create a bone * @param {String} boneName @@ -180,9 +190,12 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (existedBone) { return existedBone; } + var boneData = this.armatureData.getBoneData(boneName); var parentName = boneData.parentName; + var bone = null; + if (parentName != "") { this.createBone(parentName); bone = ccs.Bone.create(boneName); @@ -194,6 +207,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ bone.setBoneData(boneData); bone.getDisplayManager().changeDisplayWithIndex(-1, false); + return bone; }, @@ -203,14 +217,9 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * @param {String} parentName */ addBone: function (bone, parentName) { - if (!bone) { - cc.log("Argument must be non-nil"); - return; - } - if (this._boneDic[bone.getName()]) { - cc.log("bone already added. It can't be added again"); - return; - } + + cc.assert(bone, "Argument must be non-nil"); + cc.assert(bone.getName() && !this._boneDic[bone.getName()], "bone already added. It can't be added again"); if (parentName) { var boneParent = this._boneDic[parentName]; @@ -225,6 +234,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._topBoneList.push(bone); } bone.setArmature(this); + this._boneDic[bone.getName()] = bone; this.addChild(bone); }, @@ -235,14 +245,13 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * @param {Boolean} recursion */ removeBone: function (bone, recursion) { - if (!bone) { - cc.log("bone must be added to the bone dictionary!"); - return; - } + cc.assert(bone, "bone must be added to the bone dictionary!"); bone.setArmature(null); bone.removeFromParent(recursion); + cc.arrayRemoveObject(this._topBoneList, bone); + delete this._boneDic[bone.getName()]; this.removeChild(bone, true); }, @@ -262,13 +271,13 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * @param {String} parentName */ changeBoneParent: function (bone, parentName) { - if (!bone) { - cc.log("bone must be added to the bone dictionary!"); - return; - } + cc.assert(bone, "bone must be added to the bone dictionary!"); + var parentBone = bone.getParentBone(); if (parentBone) { + cc.arrayRemoveObject(parentBone.getChildrenBone(), bone); + bone.setParentBone(null); } @@ -291,6 +300,13 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ return this._boneDic; }, + getNodeToParentTransform: function(){ + if (this._transformDirty) + this._armatureTransformDirty = true; + + return ccs.Node.prototype.getNodeToParentTransform.call(this); + }, + /** * Set contentSize and Calculate anchor point. */ @@ -306,6 +322,50 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ } }, + setAnchorPoint: function(point){ + if(point.x != this._anchorPoint.x || point.y != this._anchorPoint.y){ + this._anchorPoint.x = point.x; + this._anchorPoint.y = point.y; + this._anchorPointInPoints = cc.p( + this._contentSize.width * this._anchorPoint.x - this._offsetPoint.x, + this._contentSize.height * this._anchorPoint.y - this._offsetPoint.y + ); + this._realAnchorPointInPoints = cc.p( + this._contentSize.width * this._anchorPoint.x, + this._contentSize.height * this._anchorPoint.y + ); + this._transformDirty = this._inverseDirty = true; + } + }, + + getAnchorPointInPoints: function(){ + return this._realAnchorPointInPoints; + }, + + /** + * armatureAnimation setter + * @param {ccs.ArmatureAnimation} animation + */ + setAnimation: function (animation) { + this.animation = animation; + }, + + /** + * armatureAnimation getter + * @return {ccs.ArmatureAnimation} + */ + getAnimation: function () { + return this.animation; + }, + + /** + * armatureTransformDirty getter + * @returns {Boolean} + */ + getArmatureTransformDirty: function () { + return this._armatureTransformDirty; + }, + update: function (dt) { this.animation.update(dt); var locTopBoneList = this._topBoneList; @@ -315,203 +375,143 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = false; }, + draw: function (renderer, transform, flags) { - nodeToParentTransform: null, - - _nodeToParentTransformForWebGL: function () { - if (this._transformDirty) { - this._armatureTransformDirty = true; - // Translate values - var x = this._position.x; - var y = this._position.y; - var apx = this._anchorPointInPoints.x, napx = -apx; - var apy = this._anchorPointInPoints.y, napy = -apy; - var scx = this._scaleX, scy = this._scaleY; - - if (this._ignoreAnchorPointForPosition) { - x += apx; - y += apy; - } - - // Rotation values - // Change rotation code to handle X and Y - // If we skew with the exact same value for both x and y then we're simply just rotating - var cx = 1, sx = 0, cy = 1, sy = 0; - if (this._rotationX !== 0 || this._rotationY !== 0) { - cx = Math.cos(-this._rotationRadiansX); - sx = Math.sin(-this._rotationRadiansX); - cy = Math.cos(-this._rotationRadiansY); - sy = Math.sin(-this._rotationRadiansY); - } - - // Add offset point - x += cy * this._offsetPoint.x * this._scaleX + -sx * this._offsetPoint.y * this._scaleY; - y += sy * this._offsetPoint.x * this._scaleX + cx * this._offsetPoint.y * this._scaleY; - - var needsSkewMatrix = ( this._skewX || this._skewY ); - - // optimization: - // inline anchor point calculation if skew is not needed - // Adjusted transform calculation for rotational skew - if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { - x += cy * napx * scx + -sx * napy * scy; - y += sy * napx * scx + cx * napy * scy; - } - - // 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}; - - // 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); - - // adjust anchor point - if (apx !== 0 || apy !== 0) - t = cc.affineTransformTranslate(t, napx, napy); + var len = this._children.length; + for (var i=0; i -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - - // Add offset point - t.tx += Cos * this._offsetPoint.x * lScaleX + -Sin * this._offsetPoint.y * lScaleY; - t.ty += Sin * this._offsetPoint.x * lScaleX + Cos * this._offsetPoint.y * lScaleY; - - // skew - if (this._skewX || this._skewY) { - // offset the anchorpoint - var skx = Math.tan(-this._skewX * Math.PI / 180); - var sky = Math.tan(-this._skewY * Math.PI / 180); - var xx = appY * skx * sx; - var yy = appX * sky * sy; - t.a = Cos + -Sin * sky; - t.c = Cos * skx + -Sin; - t.b = Sin + Cos * sky; - t.d = Sin * skx + Cos; - t.tx += Cos * xx + -Sin * yy; - t.ty += Sin * xx + Cos * yy; - } + onExit: function () { + cc.Node.prototype.onExit.call(this); + this.unscheduleUpdate(); + }, - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.b *= sx; - t.c *= sy; - t.d *= sy; - } + visit: function(renderer, parentTransform, parentFlags){ + //quick return if not visible. children won't be drawn. + if (!this._visible) + { + return; + } - // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * -appY * sy; - t.ty += Sin * -appX * sx + Cos * -appY * sy; +// var flags = this.processParentFlags(parentTransform, parentFlags); - // if ignore anchorPoint - if (this._ignoreAnchorPointForPosition) { - t.tx += appX - t.ty += appY; - } + // IMPORTANT: + // To ease the migration to v3.0, we still support the Mat4 stack, + // but it is deprecated and your code should not rely on it + var director = cc.director; + cc.assert(null != director, "Director is null when seting matrix stack"); + director.pushMatrix(0); + director.loadMatrix(1, this._modelViewTransform); - if (this._additionalTransformDirty) { - this._transform = cc.affineTransformConcat(this._transform, this._additionalTransform); - this._additionalTransformDirty = false; - } - t.tx = t.tx | 0; - t.ty = t.ty | 0; - this._transformDirty = false; - } - return this._transform; - }, + this.sortAllChildren(); + this.draw(renderer, this._modelViewTransform, flags); - draw: function () { - //cc.g_NumberOfDraws++; - }, + // reset for next frame + this._orderOfArrival = 0; - /** - * conforms to cc.TextureProtocol protocol - * @param {cc.BlendFunc} blendFunc - */ - setBlendFunc: function (blendFunc) { - this._blendFunc = blendFunc; + director.popMatrix(0); }, - /** - * blendFunc getter - * @returns {cc.BlendFunc} - */ - getBlendFunc: function () { - return this._blendFunc; - }, + getBoundingBox: function(){ + var minx, miny, maxx, maxy = 0; - /** - * This boundingBox will calculate all bones' boundingBox every time - * @return {cc.rect} - */ - boundingBox: function () { - var minx = 0, miny = 0, maxx = 0, maxy = 0; var first = true; + var boundingBox = cc.rect(0, 0, 0, 0); - for (var i = 0; i < this._children.length; i++) { + + var len = this._children.length; + for (var i=0; i cc.rectGetMaxX(boundingBox) ? cc.rectGetMaxX(r) : cc.rectGetMaxX(boundingBox); - maxy = cc.rectGetMaxY(r) > cc.rectGetMaxY(boundingBox) ? cc.rectGetMaxY(r) : cc.rectGetMaxY(boundingBox); + else + { + minx = r.x < boundingBox.x ? r.x : boundingBox.x; + miny = r.y < boundingBox.y ? r.y : boundingBox.y; + maxx = r.x + r.width > boundingBox.x + boundingBox.width ? + r.x + r.width : + boundingBox.x + boundingBox.width; + maxy = r.y + r.height > boundingBox.y + boundingBox.height ? + r.y + r.height : + boundingBox.y + boundingBox.height; } - boundingBox = cc.rect(minx, miny, maxx - minx, maxy - miny); + + boundingBox.setRect(minx, miny, maxx - minx, maxy - miny); } + } - return cc.rectApplyAffineTransform(boundingBox, this.nodeToParentTransform()); + + return cc.rectApplyAffineTransform(boundingBox, this.getNodeToParentTransform()); }, /** @@ -532,10 +532,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ return null; }, - getTexureAtlasWithTexture: function () { - return null; - }, - /** * parent bone setter * @param {ccs.Bone} parentBone @@ -549,55 +545,113 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * set collider filter - * @param {ccs.ColliderFilter} filter + * return parent bone + * @returns {ccs.Bone} */ - setColliderFilter: function (filter) { - for (var key in this._boneDic) { - var bone = this._boneDic[key]; - bone.setColliderFilter(filter); - } + getParentBone: function () { + return this._parentBone; }, /** * draw contour */ drawContour: function () { - cc._drawingUtil.setDrawColor(255, 255, 255, 255); - cc._drawingUtil.setLineWidth(1); - for (var key in this._boneDic) { - var bone = this._boneDic[key]; - var bodyList = bone.getColliderBodyList(); - for (var i = 0; i < bodyList.length; i++) { - var body = bodyList[i]; +// cc._drawingUtil.setDrawColor(255, 255, 255, 255); +// cc._drawingUtil.setLineWidth(1); +// for (var key in this._boneDic) { +// var bone = this._boneDic[key]; +// var bodyList = bone.getColliderBodyList(); +// for (var i = 0; i < bodyList.length; i++) { +// var body = bodyList[i]; +// var vertexList = body.getCalculatedVertexList(); +// cc._drawingUtil.drawPoly(vertexList, vertexList.length, true); +// } +// } + for(var i=0; i -0.000001) ? 0.000001 : lScaleX, +// sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; +// +// // Add offset point +// t.tx += Cos * this._offsetPoint.x * lScaleX + -Sin * this._offsetPoint.y * lScaleY; +// t.ty += Sin * this._offsetPoint.x * lScaleX + Cos * this._offsetPoint.y * lScaleY; +// +// // skew +// if (this._skewX || this._skewY) { +// // offset the anchorpoint +// var skx = Math.tan(-this._skewX * Math.PI / 180); +// var sky = Math.tan(-this._skewY * Math.PI / 180); +// var xx = appY * skx * sx; +// var yy = appX * sky * sy; +// t.a = Cos + -Sin * sky; +// t.c = Cos * skx + -Sin; +// t.b = Sin + Cos * sky; +// t.d = Sin * skx + Cos; +// t.tx += Cos * xx + -Sin * yy; +// t.ty += Sin * xx + Cos * yy; +// } +// +// // scale +// if (lScaleX !== 1 || lScaleY !== 1) { +// t.a *= sx; +// t.b *= sx; +// t.c *= sy; +// t.d *= sy; +// } +// +// // adjust anchorPoint +// t.tx += Cos * -appX * sx + -Sin * -appY * sy; +// t.ty += Sin * -appX * sx + Cos * -appY * sy; +// +// // if ignore anchorPoint +// if (this._ignoreAnchorPointForPosition) { +// t.tx += appX +// t.ty += appY; +// } +// +// if (this._additionalTransformDirty) { +// this._transform = cc.affineTransformConcat(this._transform, this._additionalTransform); +// this._additionalTransformDirty = false; +// } +// +// t.tx = t.tx | 0; +// t.ty = t.ty | 0; +// this._transformDirty = false; +// } +// return this._transform; +// }, +// +// /** +// * This boundingBox will calculate all bones' boundingBox every time +// * @return {cc.rect} +// */ +// boundingBox: function () { +// var minx = 0, miny = 0, maxx = 0, maxy = 0; +// var first = true; +// var boundingBox = cc.rect(0, 0, 0, 0); +// for (var i = 0; i < this._children.length; i++) { +// var bone = this._children[i]; +// if (bone instanceof ccs.Bone) { +// var r = bone.getDisplayManager().getBoundingBox(); +// if (first) { +// minx = cc.rectGetMinX(r); +// miny = cc.rectGetMinY(r); +// maxx = cc.rectGetMaxX(r); +// maxy = cc.rectGetMaxY(r); +// +// first = false; +// } +// else { +// minx = cc.rectGetMinX(r) < cc.rectGetMinX(boundingBox) ? cc.rectGetMinX(r) : cc.rectGetMinX(boundingBox); +// miny = cc.rectGetMinY(r) < cc.rectGetMinY(boundingBox) ? cc.rectGetMinY(r) : cc.rectGetMinY(boundingBox); +// maxx = cc.rectGetMaxX(r) > cc.rectGetMaxX(boundingBox) ? cc.rectGetMaxX(r) : cc.rectGetMaxX(boundingBox); +// maxy = cc.rectGetMaxY(r) > cc.rectGetMaxY(boundingBox) ? cc.rectGetMaxY(r) : cc.rectGetMaxY(boundingBox); +// } +// boundingBox = cc.rect(minx, miny, maxx - minx, maxy - miny); +// } +// } +// return cc.rectApplyAffineTransform(boundingBox, this.nodeToParentTransform()); +// }, +// +// getTexureAtlasWithTexture: function () { +// return null; +// }, +// getName: function () { +// return this.name; +// }, +// setName: function (name) { +// this.name = name; +// } }); @@ -717,7 +924,7 @@ _p = null; */ ccs.Armature.create = function (name, parentBone) { var armature = new ccs.Armature(); - if (armature && armature.init(name, parentBone)) { + if (armature.init(name, parentBone)) { return armature; } return null; diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index fe0c8e56c2..54b1356057 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -80,38 +80,27 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this.blendDirty = false; }, - /** - * release objects - */ - release: function () { - CC_SAFE_RELEASE(this._tweenData); - for (var i = 0; i < this._childrenBone.length; i++) { - CC_SAFE_RELEASE(this._childrenBone[i]); - } - this._childrenBone = []; - CC_SAFE_RELEASE(this._tween); - CC_SAFE_RELEASE(this.displayManager); - CC_SAFE_RELEASE(this._boneData); - CC_SAFE_RELEASE(this._childArmature); - }, - /** * Initializes a CCBone with the specified name * @param {String} name * @return {Boolean} */ init: function (name) { - cc.Node.prototype.init.call(this); +// cc.Node.prototype.init.call(this); if (name) { this.name = name; } this._tweenData = new ccs.FrameData(); + this._tween = new ccs.Tween(); this._tween.init(this); + this.displayManager = new ccs.DisplayManager(); this.displayManager.init(this); + this._worldInfo = new ccs.BaseData(); this._boneData = new ccs.BaseData(); + return true; }, @@ -120,13 +109,18 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {ccs.BoneData} boneData */ setBoneData: function (boneData) { - if (!boneData) { - cc.log("boneData must not be null"); - return; +// if (!boneData) { +// cc.log("boneData must not be null"); +// return; +// } + cc.assert(boneData, "_boneData must not be null"); + + if(this._boneData != boneData){ + this._boneData = boneData; } - this._boneData = boneData; this.name = this._boneData.name; this.setLocalZOrder(this._boneData.zOrder); + this.displayManager.initDisplayList(boneData); }, @@ -181,14 +175,14 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ } if (this.boneTransformDirty) { if (this._dataVersion >= ccs.CONST_VERSION_COMBINED) { - var locBoneData = this._boneData; - locTweenData.x += locBoneData.x; - locTweenData.y += locBoneData.y; - locTweenData.skewX += locBoneData.skewX; - locTweenData.skewY += locBoneData.skewY; - locTweenData.scaleX += locBoneData.scaleX; - locTweenData.scaleY += locBoneData.scaleY; - +// var locBoneData = this._boneData; +// locTweenData.x += locBoneData.x; +// locTweenData.y += locBoneData.y; +// locTweenData.skewX += locBoneData.skewX; +// locTweenData.skewY += locBoneData.skewY; +// locTweenData.scaleX += locBoneData.scaleX; +// locTweenData.scaleY += locBoneData.scaleY; + ccs.TransformHelp.nodeConcat(this._tweenData, this._boneData); locTweenData.scaleX -= 1; locTweenData.scaleY -= 1; } @@ -239,16 +233,13 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * Rewrite visit ,when node draw, g_NumberOfDraws is changeless + * BlendFunc setter + * @param {cc.BlendFunc} blendFunc */ - visit: function (ctx) { - // quick return if not visible - if (!this._visible) - return; - - var node = this.getDisplayManager().getDisplayRenderNode(); - if (node) { - node.visit(ctx); + setBlendFunc: function (blendFunc) { + if (this._blendFunc.src != blendFunc.src || this._blendFunc.dst != blendFunc.dst) { + this._blendFunc = blendFunc; + this.blendDirty = true; } }, @@ -259,7 +250,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ updateDisplayedColor: function (color) { this._realColor = cc.color(255, 255, 255); cc.Node.prototype.updateDisplayedColor.call(this, color); - this.updateColor(); +// this.updateColor(); }, /** @@ -269,25 +260,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ updateDisplayedOpacity: function (opacity) { this._realOpacity = 255; cc.Node.prototype.updateDisplayedOpacity.call(this, opacity); - this.updateColor(); - }, - - /** - * set display color - * @param {cc.Color} color - */ - setColor: function (color) { - cc.Node.prototype.setColor.call(this, color); - this.updateColor(); - }, - - /** - * set display opacity - * @param {Number} opacity 0-255 - */ - setOpacity: function (opacity) { - cc.Node.prototype.setOpacity.call(this, opacity); - this.updateColor(); +// this.updateColor(); }, /** @@ -301,7 +274,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ var locOpacity = this._displayedOpacity * locTweenData.a / 255; var locColor = cc.color(locDisplayedColor.r * locTweenData.r / 255, locDisplayedColor.g * locTweenData.g / 255, locDisplayedColor.b * locTweenData.b / 255); display.setOpacity(locOpacity); - display.setColor(locColor); +// display.setColor(locColor); } }, @@ -323,14 +296,17 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {ccs.Bone} child */ addChildBone: function (child) { - if (!child) { - cc.log("Argument must be non-nil"); - return; - } - if (child.parentBone) { - cc.log("child already added. It can't be added again"); - return; - } +// if (!child) { +// cc.log("Argument must be non-nil"); +// return; +// } +// if (child.parentBone) { +// cc.log("child already added. It can't be added again"); +// return; +// } + cc.assert(child, "Argument must be non-nil"); + cc.assert(!child.parentBone, "child already added. It can't be added again"); + if (this._childrenBone.indexOf(child) < 0) { this._childrenBone.push(child); child.setParentBone(this); @@ -343,19 +319,39 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} recursion */ removeChildBone: function (bone, recursion) { - for (var i = 0; i < this._childrenBone.length; i++) { - if (this._childrenBone[i] == bone) { - if (recursion) { - var ccbones = bone._childrenBone; - for (var j = 0; j < ccbones.length; j++) { - bone.removeChildBone(ccbones[j], recursion); - } +// for (var i = 0; i < this._childrenBone.length; i++) { +// if (this._childrenBone[i] == bone) { +// if (recursion) { +// var ccbones = bone._childrenBone; +// for (var j = 0; j < ccbones.length; j++) { +// bone.removeChildBone(ccbones[j], recursion); +// } +// } +// bone.setParentBone(null); +// bone.displayManager.setCurrentDecorativeDisplay(null); +// cc.arrayRemoveObject(this._childrenBone, bone); +// } +// } + if (this._children.length > 0 && this._children.getIndex(bone) != -1 ) + { + if(recursion) + { + var ccbones = bone._children; + + for(var i=0; i 0) { + if(movementBoneData && movementBoneData.frameList.length > 0) + { this._tweenList.push(tween); - movementBoneData.duration = locMovementData.duration; + movementBoneData.duration = this._movementData.duration; tween.play(movementBoneData, durationTo, durationTween, loop, tweenEasing); tween.setProcessScale(this._processScale); - if (bone.getChildArmature()) { + + if (bone.getChildArmature()) + { bone.getChildArmature().getAnimation().setProcessScale(this._processScale); } - } else { - if (!bone.getIgnoreMovementBoneData()) { + } + else + { + if(!bone.isIgnoreMovementBoneData()) + { + //! this bone is not include in this movement, so hide it bone.getDisplayManager().changeDisplayWithIndex(-1, false); tween.stop(); } + } } + this._armature.update(0); + +// return; +// +// if (durationTo === undefined) { +// durationTo = -1; +// } +// +// if (loop === undefined) { +// loop = -1; +// } +// +// var locMovementData = this._movementData; +// //Get key frame count +// this._rawDuration = locMovementData.duration; +// this._movementID = animationName; +// this._processScale = this._speedScale * locMovementData.scale; +// //Further processing parameters +// durationTo = (durationTo == -1) ? locMovementData.durationTo : durationTo; +// var durationTween = locMovementData.durationTween; +// durationTween = (durationTween == 0) ? this._rawDuration : durationTween;//todo +// var tweenEasing = locMovementData.tweenEasing; +// +// if (loop < 0) { +// loop = locMovementData.loop; +// } else { +// loop = Boolean(loop); +// } +// +// this._onMovementList = false; +// ccs.ProcessBase.prototype.play.call(this, durationTo, tweenEasing); +// +// if (this._rawDuration == 0) { +// this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME; +// } +// else { +// if (loop) { +// this._loopType = ccs.ANIMATION_TYPE_TO_LOOP_FRONT; +// } +// else { +// this._loopType = ccs.ANIMATION_TYPE_NO_LOOP; +// } +// this._durationTween = durationTween; +// } +// +// this._tweenList = []; +// +// var movementBoneData; +// var dict = this._armature.getBoneDic(); +// for (var key in dict) { +// var bone = dict[key]; +// movementBoneData = locMovementData.getMovementBoneData(bone.getName()); +// var tween = bone.getTween(); +// if (movementBoneData && movementBoneData.frameList.length > 0) { +// this._tweenList.push(tween); +// movementBoneData.duration = locMovementData.duration; +// tween.play(movementBoneData, durationTo, durationTween, loop, tweenEasing); +// +// tween.setProcessScale(this._processScale); +// if (bone.getChildArmature()) { +// bone.getChildArmature().getAnimation().setProcessScale(this._processScale); +// } +// } else { +// if (!bone.getIgnoreMovementBoneData()) { +// bone.getDisplayManager().changeDisplayWithIndex(-1, false); +// tween.stop(); +// } +// } +// } +// this._armature.update(0); + }, + + /** + * Play animation with index, the o ther param is the same to play. + * @param {Number} animationIndex + * @param {Number} durationTo + * @param {Number} durationTween + * @param {Number} loop + * @param {Number} tweenEasing + */ + playByIndex: function (animationIndex, durationTo, durationTween, loop, tweenEasing) { + cc.log("playByIndex is deprecated. Use playWithIndex instead."); + this.playWithIndex(animationIndex, durationTo, durationTween, loop, tweenEasing); + }, + + /** + * Play animation with index, the other param is the same to play. + * @param {Number||Array} animationIndex + * @param {Number} durationTo + * @param {Number} loop + */ + playWithIndex: function (animationIndex, durationTo, loop) { +// if (typeof durationTo == "undefined") { +// durationTo = -1; +// } +// if (typeof loop == "undefined") { +// loop = -1; +// } +// var moveNames = this.animationData.movementNames; +// if (animationIndex < -1 || animationIndex >= moveNames.length) { +// return; +// } +// var animationName = moveNames[animationIndex]; +// this.play(animationName, durationTo, loop, 0); + var movName = this._animationData.movementNames; + cc.assert((animationIndex > -1) && (animationIndex < movName.length)); + + var animationName = movName[animationIndex]; + this.play(animationName, durationTo, loop); }, /** @@ -295,35 +410,36 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._onMovementList = true; this._movementIndex = 0; - for (var i = 0; i < movementNames.length; i++) { - this._movementList.push({name: movementNames[i], durationTo: durationTo}); - } +// for (var i = 0; i < movementNames.length; i++) { +// this._movementList.push({name: movementNames[i], durationTo: durationTo}); +// } + this._movementList = movementNames; + this.updateMovementList(); }, - updateMovementList: function () { - if (this._onMovementList) { - if (this._movementListLoop) { - var movementObj = this._movementList[this._movementIndex]; - this.play(movementObj.name, movementObj.durationTo, -1, 0); - this._movementIndex++; - if (this._movementIndex >= this._movementList.length) { - this._movementIndex = 0; - } - } - else { - if (this._movementIndex < this._movementList.length) { - var movementObj = this._movementList[this._movementIndex]; - this.play(movementObj.name, movementObj.durationTo, -1, 0); - this._movementIndex++; - } - else { - this._onMovementList = false; - } - } - this._onMovementList = true; + /** + * play by indexes + * @param movementIndexes + * @param {Number} durationTo + * @param {Boolean} loop + */ + playWithIndexes: function (movementIndexes, durationTo, loop) { + this._movementList = []; + this._movementListLoop = loop; + this._onMovementList = true; + this._movementIndex = 0; + + var movName = this.animationData.movementNames; + + for (var i = 0; i < movementIndexes.length; i++) { + var name = movName[movementIndexes[i]]; +// this._movementList.push({name: name, durationTo: durationTo}); + this._movementList.push(name); } + + this.updateMovementList(); }, /** @@ -360,73 +476,6 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this.ignoreFrameEvent = ignoreFrameEvent; }, - /** - * Go to specified frame and pause current movement. - * @param {Number} frameIndex - */ - gotoAndPause: function (frameIndex) { - this.gotoAndPlay(frameIndex); - this.pause(); - }, - - /** - * Play animation with index, the other param is the same to play. - * @param {Number||Array} animationIndex - * @param {Number} durationTo - * @param {Number} durationTween - * @param {Number} loop - * @param {Number} tweenEasing - */ - playWithIndex: function (animationIndex, durationTo, durationTween, loop, tweenEasing) { - if (typeof durationTo == "undefined") { - durationTo = -1; - } - if (typeof loop == "undefined") { - loop = -1; - } - var moveNames = this.animationData.movementNames; - if (animationIndex < -1 || animationIndex >= moveNames.length) { - return; - } - var animationName = moveNames[animationIndex]; - this.play(animationName, durationTo, loop, 0); - }, - - /** - * Play animation with index, the o ther param is the same to play. - * @param {Number} animationIndex - * @param {Number} durationTo - * @param {Number} durationTween - * @param {Number} loop - * @param {Number} tweenEasing - */ - playByIndex: function (animationIndex, durationTo, durationTween, loop, tweenEasing) { - cc.log("playByIndex is deprecated. Use playWithIndex instead."); - this.playWithIndex(animationIndex, durationTo, durationTween, loop, tweenEasing); - }, - - /** - * play by indexes - * @param movementIndexes - * @param {Number} durationTo - * @param {Boolean} loop - */ - playWithIndexes: function (movementIndexes, durationTo, loop) { - this._movementList = []; - this._movementListLoop = loop; - this._onMovementList = true; - this._movementIndex = 0; - - var movName = this.animationData.movementNames; - - for (var i = 0; i < movementIndexes.length; i++) { - var name = movName[movementIndexes[i]]; - this._movementList.push({name: name, durationTo: durationTo}); - } - - this.updateMovementList(); - }, - /** * get movement count * @return {Number} @@ -436,24 +485,58 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, 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); - } + ccs.ProcessBase.prototype.update.call(this, dt); +// if (ccs.ProcessBase.prototype.update.call(this, dt)) { +// for (var i = 0; i < this._tweenList.length; i++) { +// this._tweenList[i].update(dt); +// } +// } + for (var i = 0; i < this._tweenList.length; i++) { + this._tweenList[i].update(dt); + } + + if(this._frameEventQueue.length > 0 || this._movementEventQueue.length > 0) + { + this._armature.retain(); } var frameEvents = this._frameEventQueue; while (frameEvents.length > 0) { - var frameEvent = frameEvents.shift(); +// var frameEvent = frameEvents.shift(); + var event = frameEvents.pop(); + this.ignoreFrameEvent = true; - this.callFrameEvent([frameEvent.bone, frameEvent.frameEventName, frameEvent.originFrameIndex, frameEvent.currentFrameIndex]); + + if(this._frameEventTarget){ +// (_frameEventTarget->*_frameEventCallFunc)(event->bone, event->frameEventName, event->originFrameIndex, event->currentFrameIndex); + this._frameEventTarget._frameEventCallFunc(event.bone, event.frameEventName, event.originFrameIndex, event.currentFrameIndex); + } + + if(this._frameEventListener){ + this._frameEventListener(event.bone, event.frameEventName, event.originFrameIndex, event.currentFrameIndex); + } + +// this.callFrameEvent([frameEvent.bone, frameEvent.frameEventName, frameEvent.originFrameIndex, frameEvent.currentFrameIndex]); this.ignoreFrameEvent = false; } var movementEvents = this._movementEventQueue; while (movementEvents.length > 0) { - var movEvent = movementEvents.shift(); - this.callMovementEvent([movEvent.armature, movEvent.movementType, movEvent.movementID]); +// var movEvent = movementEvents.shift(); + var event = movementEvents.front(); + movementEvents.pop(); + + if(this._movementEventTarget) + { +// (_movementEventTarget->*_movementEventCallFunc)(event->armature, event->movementType, event->movementID); + this._movementEventTarget._movementEventCallFunc(event.armature, event.movementType, event.movementID); + } + + if (this._movementEventListener) + { + this._movementEventListener(event.armature, event.movementType, event.movementID); + } +// this.callMovementEvent([movEvent.armature, movEvent.movementType, movEvent.movementID]); } }, @@ -514,19 +597,13 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Object} target * @param {function} callFunc */ - setMovementEventCallFunc: function (callFunc, target) { - this._movementEvent = new ccs.AnimationEvent(target, callFunc); - }, + setMovementEventCallFunc: function (target, callFunc, listener) { +// this._movementEvent = new ccs.AnimationEvent(target, callFunc); + this._movementEventTarget = target; + this._movementEventCallFunc = callFunc; - /** - * call event - * @param {Array} args - */ - callMovementEvent: function (args) { - if (this._movementEvent) { - this._movementEvent.setArguments(args); - this._movementEvent.call(); - } + if(listener) + this._frameEventListener = listener; }, /** @@ -534,29 +611,18 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Object} target * @param {function} callFunc */ - setFrameEventCallFunc: function (callFunc, target) { - this._frameEvent = new ccs.AnimationEvent(target, callFunc); + setFrameEventCallFunc: function (target, callFunc) { +// this._frameEvent = new ccs.AnimationEvent(target, callFunc); + this._frameEventTarget = target; + this._frameEventCallFunc = callFunc; }, /** - * call event - * @param {Array} args + * userObject setter + * @param {Object} userObject */ - callFrameEvent: function (args) { - if (this._frameEvent) { - this._frameEvent.setArguments(args); - this._frameEvent.call(); - } - }, - - movementEvent: function (armature, movementType, movementID) { - if (this._movementEvent) { - var event = new ccs.MovementEvent(); - event.armature = armature; - event.movementType = movementType; - event.movementID = movementID; - this._movementEventQueue.push(event); - } + setUserObject: function (userObject) { + this.userObject = userObject; }, /** @@ -566,16 +632,87 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Number} currentFrameIndex */ frameEvent: function (bone, frameEventName, originFrameIndex, currentFrameIndex) { - if (this._frameEvent) { +// if (this._frameEvent) { + if (this._frameEvent && this._frameEventCallFunc || this._frameEventListener) { var frameEvent = new ccs.FrameEvent(); frameEvent.bone = bone; frameEvent.frameEventName = frameEventName; frameEvent.originFrameIndex = originFrameIndex; frameEvent.currentFrameIndex = currentFrameIndex; + this._frameEventQueue.push(frameEvent); } }, + movementEvent: function (armature, movementType, movementID) { +// if (this._movementEvent) { + if (this._movementEvent && this._movementEventCallFunc || this._movementEventListener) { + var event = new ccs.MovementEvent(); + event.armature = armature; + event.movementType = movementType; + event.movementID = movementID; + this._movementEventQueue.push(event); + } + }, + + updateMovementList: function () { + if (this._onMovementList) { + if (this._movementListLoop) { + var movementObj = this._movementList[this._movementIndex]; + this.play(movementObj.name, movementObj.durationTo, -1, 0); + this._movementIndex++; + if (this._movementIndex >= this._movementList.length) { + this._movementIndex = 0; + } + } + else { + if (this._movementIndex < this._movementList.length) { + var movementObj = this._movementList[this._movementIndex]; + this.play(movementObj.name, movementObj.durationTo, -1, 0); + this._movementIndex++; + } + else { + this._onMovementList = false; + } + } + this._onMovementList = true; + } + }, + + + + + /** + * Go to specified frame and pause current movement. + * @param {Number} frameIndex + */ + gotoAndPause: function (frameIndex) { + this.gotoAndPlay(frameIndex); + this.pause(); + }, + + /** + * call event + * @param {Array} args + */ + callMovementEvent: function (args) { + if (this._movementEvent) { + this._movementEvent.setArguments(args); + this._movementEvent.call(); + } + }, + + /** + * call event + * @param {Array} args + */ + callFrameEvent: function (args) { + if (this._frameEvent) { + this._frameEvent.setArguments(args); + this._frameEvent.call(); + } + }, + /** * animationData setter * @param {ccs.AnimationData} aniData @@ -591,13 +728,6 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# getAnimationData: function () { return this.animationData; }, - /** - * userObject setter - * @param {Object} userObject - */ - setUserObject: function (userObject) { - this.userObject = userObject; - }, /** * userObject getter diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index 4ccbdcadce..74c571659c 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -145,7 +145,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ * @param {Number} durationTo * @param {ccs.TweenType} tweenEasing */ - play: function (durationTo, tweenEasing) { + play: function (durationTo, tweenEasing, loop, tweenEasing) { this._isComplete = false; this._isPause = false; this._isPlaying = true; @@ -158,9 +158,15 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ if (this._isComplete || this._isPause) { return false; } - if (this._rawDuration <= 0) { + + /* + * Fileter the m_iDuration <=0 and dt >1 + * If dt>1, generally speaking the reason is the device is stuck. + */ + if (this._rawDuration <= 0 || dt > 1) { return false; } + var locNextFrameIndex = this._nextFrameIndex; var locCurrentFrame = this._currentFrame; if (locNextFrameIndex <= 0) { @@ -187,13 +193,6 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ return true; }, - /** - * update will call this handler, you can handle your logic here - */ - updateHandler: function () { - //override - }, - /** * goto frame * @param {Number} frameIndex @@ -220,6 +219,16 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ return this._curFrameIndex; }, + + + + /** + * update will call this handler, you can handle your logic here + */ + updateHandler: function () { + //override + }, + /** * whether the animation is pause * @returns {boolean} diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 71a47e9508..c5ea290f78 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -71,8 +71,12 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._bone = bone; this._tweenData = this._bone.getTweenData(); this._tweenData.displayIndex = -1; - var armature = bone.getArmature(); - if (armature) this.animation = armature.getAnimation(); +// var armature = bone.getArmature(); +// if (armature) this.animation = armature.getAnimation(); + + this._animation = this._bone.getArmature() != null ? + this._bone.getArmature().getAnimation() : + null; return true; }, @@ -85,7 +89,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @param {ccs.TweenType} tweenEasing */ play:function (movementBoneData, durationTo, durationTween, loop, tweenEasing) { - ccs.ProcessBase.prototype.play.call(this, durationTo, tweenEasing); + ccs.ProcessBase.prototype.play.call(this, durationTo, tweenEasing, loop, tweenEasing); if(loop){ this._loopType = ccs.ANIMATION_TYPE_TO_LOOP_FRONT; @@ -98,8 +102,10 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._fromIndex = this._toIndex = 0; var difMovement = movementBoneData != this._movementBoneData; + this._movementBoneData = movementBoneData; this._rawDuration = this._movementBoneData.duration; + var nextKeyFrame = this._movementBoneData.getFrameData(0); this._tweenData.displayIndex = nextKeyFrame.displayIndex; @@ -109,7 +115,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._tweenData.scaleY += 1; } - if (this._rawDuration == 0 || this._movementBoneData.frameList.length == 1) { + if (this._rawDuration == 0) { this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME; if (durationTo == 0) { this.setBetween(nextKeyFrame, nextKeyFrame); @@ -135,11 +141,14 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ gotoAndPlay: function (frameIndex) { ccs.ProcessBase.prototype.gotoFrame.call(this, frameIndex); + this._totalDuration = 0; this._betweenDuration = 0; this._fromIndex = this._toIndex = 0; + this._isPlaying = true; this._isComplete = this._isPause = false; + this._currentPercent = this._curFrameIndex / (this._rawDuration-1); this._currentFrame = this._nextFrameIndex * this._currentPercent; }, @@ -186,7 +195,9 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ } case ccs.ANIMATION_TYPE_TO_LOOP_FRONT: locLoopType = ccs.ANIMATION_TYPE_LOOP_FRONT; + this._nextFrameIndex = this._durationTween > 0 ? this._durationTween : 1; + if (this._movementBoneData.delay != 0) { this._currentFrame = (1 - this._movementBoneData.delay) * this._nextFrameIndex; locCurrentPercent = this._currentFrame / this._nextFrameIndex; @@ -267,16 +278,25 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ arriveKeyFrame:function (keyFrameData) { if (keyFrameData) { var locBone = this._bone; - var displayIndex = keyFrameData.displayIndex; var displayManager = locBone.getDisplayManager(); + + //! Change bone's display + var displayIndex = keyFrameData.displayIndex; + if (!displayManager.getForceChangeDisplay()) { displayManager.changeDisplayWithIndex(displayIndex, false); - var locRenderNode = displayManager.getDisplayRenderNode(); - if(locRenderNode) - locRenderNode.setBlendFunc(keyFrameData.blendFunc); +// var locRenderNode = displayManager.getDisplayRenderNode(); +// if(locRenderNode) +// locRenderNode.setBlendFunc(keyFrameData.blendFunc); } + + //! Update bone zorder, bone's zorder is determined by frame zorder and bone zorder this._tweenData.zOrder = keyFrameData.zOrder; locBone.updateZOrder(); + + //! Update blend type + this._bone.setBlendFunc(keyFrameData.blendFunc); + var childAramture = locBone.getChildArmature(); if (childAramture) { if (keyFrameData.movement != "") { @@ -285,7 +305,6 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ } } }, - /** * According to the percent to calculate current CCFrameData with tween effect * @param {Number} percent @@ -296,11 +315,13 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ if (!node) { node = this._tweenData; } + var locFrom = this._from; var locBetween = this._between; if (!locFrom.isTween){ percent = 0; } + node.x = locFrom.x + percent * locBetween.x; node.y = locFrom.y + percent * locBetween.y; node.scaleX = locFrom.scaleX + percent * locBetween.scaleX; @@ -309,6 +330,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ node.skewY = locFrom.skewY + percent * locBetween.skewY; this._bone.setTransformDirty(true); + if (node && locBetween.isUseColorInfo) this.tweenColorTo(percent, node); @@ -335,6 +357,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ currentPercent = ccs.fmodf(currentPercent,1); } var playedTime = (this._rawDuration-1) * currentPercent; + var from, to; var locTotalDuration = this._totalDuration,locBetweenDuration = this._betweenDuration, locToIndex = this._toIndex; // if play to current frame's front or back, then find current frame again @@ -345,12 +368,14 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ */ var length = this._movementBoneData.frameList.length; var frames = this._movementBoneData.frameList; + if (playedTime < frames[0].frameID){ from = to = frames[0]; this.setBetween(from, to); return currentPercent; } - else if (playedTime >= frames[length - 1].frameID) { + + if (playedTime >= frames[length - 1].frameID) { if (this._passLastFrame) { from = to = frames[length - 1]; this.setBetween(from, to); @@ -365,10 +390,12 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._fromIndex = locToIndex; from = frames[this._fromIndex]; locTotalDuration = from.frameID; + locToIndex = this._fromIndex + 1; if (locToIndex >= length) { locToIndex = 0; } + to = frames[locToIndex]; //! Guaranteed to trigger frame event @@ -402,6 +429,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ return currentPercent; }, + /** * animation setter * @param {ccs.ArmatureAnimation} animation diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index 4f662cc923..4c77d86eb0 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -35,13 +35,27 @@ ccs.PT_RATIO = 32; ccs.ColliderFilter = ccs.Class.extend(/** @lends ccs.ColliderFilter# */{ _collisionType: 0, _group: 0, + _categoryBits: 0, + _groupIndex: 0, + _maskBits: 0, ctor: function (collisionType, group) { this._collisionType = collisionType || 0; this._group = group || 0; }, updateShape: function (shape) { - shape.collision_type = this._collisionType; - shape.group = this._group; + + if(shape instanceof cp.Shape){ + shape.collision_type = this._collisionType; + shape.group = this._group; + }else if(shape instanceof Box2D.b2FilterData){ + + var filter = new Box2D.b2FilterData(); + filter.categoryBits = this._categoryBits; + filter.groupIndex = this._groupIndex; + filter.maskBits = this._maskBits; + + shape.SetFilterData(filter); + } } }); /** @@ -77,19 +91,27 @@ ccs.ColliderBody = ccs.Class.extend(/** @lends ccs.ColliderBody# */{ }, /** - * contourData setter - * @param {ccs.ContourData} contourData + * colliderFilter setter + * @param {ccs.ColliderFilter} colliderFilter */ - setContourData: function (contourData) { - this.coutourData = contourData; + setColliderFilter: function (colliderFilter) { + this.colliderFilter = colliderFilter; }, /** - * shape setter - * @return {ccs.Shape} + * get calculated vertex list + * @returns {Array} */ - getShape: function () { - return this.shape; + getCalculatedVertexList: function () { + return this._calculatedVertexList; + }, + + setB2Fixture: function(fixture){ + this._fixture = fixture; + }, + + getB2Fixture: function(){ + return this._fixture; }, /** @@ -101,27 +123,27 @@ ccs.ColliderBody = ccs.Class.extend(/** @lends ccs.ColliderBody# */{ }, /** - * colliderFilter getter - * @returns {ccs.ColliderFilter} + * shape setter + * @return {ccs.Shape} */ - getColliderFilter: function () { - return this.colliderFilter; + getShape: function () { + return this.shape; }, /** - * colliderFilter setter - * @param {ccs.ColliderFilter} colliderFilter + * contourData setter + * @param {ccs.ContourData} contourData */ - setColliderFilter: function (colliderFilter) { - this.colliderFilter = colliderFilter; + setContourData: function (contourData) { + this.coutourData = contourData; }, /** - * get calculated vertex list - * @returns {Array} + * colliderFilter getter + * @returns {ccs.ColliderFilter} */ - getCalculatedVertexList: function () { - return this._calculatedVertexList; + getColliderFilter: function () { + return this.colliderFilter; } }); @@ -140,6 +162,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ _body: null, _active: false, _filter: null, + helpPoint: cc.p(0, 0), ctor: function () { this._colliderBodyList = []; this._bone = null; @@ -162,6 +185,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ addContourData: function (contourData) { var colliderBody = new ccs.ColliderBody(contourData); this._colliderBodyList.push(colliderBody); + if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { var calculatedVertexList = colliderBody.getCalculatedVertexList(); var vertexList = contourData.vertexList; @@ -187,13 +211,32 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ * @param contourData */ removeContourData: function (contourData) { - var locColliderBodyList = this._colliderBodyList; - for (var i = 0; i < locColliderBodyList.length; i++) { - if (locColliderBodyList[i].getContourData() == contourData) { - locColliderBodyList.splice(i, 1); - return; +// var locColliderBodyList = this._colliderBodyList; +// for (var i = 0; i < locColliderBodyList.length; i++) { +// if (locColliderBodyList[i].getContourData() == contourData) { +// locColliderBodyList.splice(i, 1); +// return; +// } +// } + + var eraseList = []; + var i; + + for (i=0; igetB2Fixture()->GetShape(); shape = colliderBody.getShape(); } + var vs = contourData.vertexList; var cvs = colliderBody.getCalculatedVertexList(); + for (var j = 0; j < vs.length; j++) { locHelpPoint.x = vs[j].x; locHelpPoint.y = vs[j].y; locHelpPoint = cc.pointApplyAffineTransform(locHelpPoint, t); - if (shape) { - shape.verts[j * 2] = locHelpPoint.x; - shape.verts[j * 2 + 1] = locHelpPoint.y; - } + if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { var v = cc.p(0, 0); v.x = locHelpPoint.x; v.y = locHelpPoint.y; cvs[j] = v; } + + if (shape) { + shape.verts[j * 2] = locHelpPoint.x; + shape.verts[j * 2 + 1] = locHelpPoint.y; + } } if (shape) { 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; shape.axes[j].d = cp.v.dot(n, shape.verts[j]); +// var b = shape.verts[(i + 1) % shape.numVerts]; +// var n = cp.v.normalize(cp.v.perp(cp.v.sub(b, shape.verts[i]))); +// +// shape.planes[i].n = n; +// shape.planes[i].d = cp.v.dot(n, shape.verts[i]); } } } }, - getBody: function () { - return this._body; - }, + setBody: function (body) { this._body = body; var colliderBody; @@ -325,6 +390,10 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ colliderBody.setShape(shape); colliderBody.getColliderFilter().updateShape(shape); } + }, + + getBody: function () { + return this._body; } }); diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 68cf1ae042..be516741f0 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -28,9 +28,8 @@ */ ccs.CONST_VERSION = "version"; ccs.CONST_VERSION_2_0 = 2.0; -ccs.CONST_VERSION_COMBINED = 0.3; +//ccs.CONST_VERSION_COMBINED = 0.3; -ccs.CONST_SKELETON = "skeleton"; ccs.CONST_ARMATURES = "armatures"; ccs.CONST_ARMATURE = "armature"; ccs.CONST_BONE = "b"; @@ -44,6 +43,8 @@ ccs.CONST_FRAME = "f"; ccs.CONST_TEXTURE_ATLAS = "TextureAtlas"; ccs.CONST_SUB_TEXTURE = "SubTexture"; +ccs.CONST_SKELETON = "skeleton"; + ccs.CONST_A_NAME = "name"; ccs.CONST_A_DURATION = "dr"; ccs.CONST_A_FRAME_INDEX = "fi"; @@ -54,8 +55,6 @@ ccs.CONST_A_MOVEMENT_SCALE = "sc"; ccs.CONST_A_MOVEMENT_DELAY = "dl"; ccs.CONST_A_DISPLAY_INDEX = "dI"; -ccs.CONST_A_VERT = "vert"; -ccs.CONST_A_FRAG = "frag"; ccs.CONST_A_PLIST = "plist"; ccs.CONST_A_PARENT = "parent"; @@ -68,14 +67,11 @@ ccs.CONST_A_EVENT = "evt"; ccs.CONST_A_SOUND = "sd"; ccs.CONST_A_SOUND_EFFECT = "sdE"; ccs.CONST_A_TWEEN_EASING = "twE"; -ccs.CONST_A_TWEEN_ROTATION = "twR"; ccs.CONST_A_EASING_PARAM = "twEP"; +ccs.CONST_A_TWEEN_ROTATION = "twR"; ccs.CONST_A_IS_ARMATURE = "isArmature"; ccs.CONST_A_DISPLAY_TYPE = "displayType"; ccs.CONST_A_MOVEMENT = "mov"; -ccs.CONST_A_BLEND_TYPE = "bd"; -ccs.CONST_A_BLEND_SRC = "bd_src"; -ccs.CONST_A_BLEND_DST = "bd_dst"; ccs.CONST_A_X = "x"; ccs.CONST_A_Y = "y"; @@ -91,6 +87,10 @@ ccs.CONST_A_PIVOT_Y = "pY"; ccs.CONST_A_COCOS2D_PIVOT_X = "cocos2d_pX"; ccs.CONST_A_COCOS2D_PIVOT_Y = "cocos2d_pY"; +ccs.CONST_A_BLEND_TYPE = "bd"; +ccs.CONST_A_BLEND_SRC = "bd_src"; +ccs.CONST_A_BLEND_DST = "bd_dst"; + ccs.CONST_A_ALPHA = "a"; ccs.CONST_A_RED = "r"; ccs.CONST_A_GREEN = "g"; @@ -101,20 +101,14 @@ ccs.CONST_A_GREEN_OFFSET = "gM"; ccs.CONST_A_BLUE_OFFSET = "bM"; ccs.CONST_A_COLOR_TRANSFORM = "colorTransform"; ccs.CONST_A_TWEEN_FRAME = "tweenFrame"; -ccs.CONST_A_ROTATION = "rotation"; -ccs.CONST_A_USE_COLOR_INFO = "uci"; ccs.CONST_CONTOUR = "con"; ccs.CONST_CONTOUR_VERTEX = "con_vt"; -ccs.CONST_MOVEMENT_EVENT_FRAME = "movementEventFrame"; -ccs.CONST_SOUND_FRAME = "soundFrame"; - ccs.CONST_FL_NAN = "NaN"; ccs.CONST_FRAME_DATA = "frame_data"; ccs.CONST_MOVEMENT_BONE_DATA = "mov_bone_data"; -ccs.CONST_MOVEMENT_FRAME_DATA = "mov_frame_data"; ccs.CONST_MOVEMENT_DATA = "mov_data"; ccs.CONST_ANIMATION_DATA = "animation_data"; ccs.CONST_DISPLAY_DATA = "display_data"; @@ -156,6 +150,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ _asyncRefCount: 0, _asyncRefTotalCount: 0, + //LoadData don't need + setPositionReadScale: function (scale) { this._positionReadScale = scale; }, @@ -171,6 +167,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, addDataFromFile: function (filePath, isLoadSpriteFrame) { + + /* + * Check if file is already added to ArmatureDataManager, if then return. + */ if (this._configFileList.indexOf(filePath) != -1) { return; } @@ -189,6 +189,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ else if (str == ".json" || str == ".exportjson") { this.addDataFromJson(filePath, dataInfo, isLoadSpriteFrame); } + }, addDataFromFileAsync: function (filePath, target, selector, isLoadSpriteFrame) { diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index 1bcae9fed4..09a33af2b1 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -34,22 +34,22 @@ ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { addSpriteFrameFromFile:function (plistPath, imagePath) { cc.spriteFrameCache.addSpriteFrames(plistPath, imagePath); - }, - - getTexureAtlasWithTexture:function (texture) { - //todo - return null; - var textureName = texture.getName(); - var atlas = this._textureAtlasDic[textureName]; - if (atlas == null) { - atlas = cc.TextureAtlas.create(texture, 20); - this._textureAtlasDic[textureName] = atlas; - } - return atlas; - }, - - clear: function () { - this._textureAtlasDic = {}; - this._imagePaths = []; - } + } + +// getTexureAtlasWithTexture:function (texture) { +// //todo +// return null; +// var textureName = texture.getName(); +// var atlas = this._textureAtlasDic[textureName]; +// if (atlas == null) { +// atlas = cc.TextureAtlas.create(texture, 20); +// this._textureAtlasDic[textureName] = atlas; +// } +// return atlas; +// }, +// +// clear: function () { +// this._textureAtlasDic = {}; +// this._imagePaths = []; +// } }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index 412c8610a3..3b3fa25f65 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -33,6 +33,7 @@ ccs.TransformHelp.helpMatrix1 = cc.affineTransformMake(1, 0, 0, 1, 0, 0); ccs.TransformHelp.helpMatrix2 = cc.affineTransformMake(1, 0, 0, 1, 0, 0); ccs.TransformHelp.helpPoint1 = cc.p(0, 0); ccs.TransformHelp.helpPoint2 = cc.p(0, 0); +ccs.TransformHelp.helpParentNode = {}; /** * @function @@ -51,6 +52,49 @@ ccs.TransformHelp.transformFromParent = function (bone, parentBone) { this.matrixToNode(this.helpMatrix1, bone); }; +ccs.TransformHelp.transformToParent = function(node, parentNode){ + this.nodeToMatrix(node, this.helpMatrix1); + this.nodeToMatrix(parentNode, this.helpMatrix2); + + this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2); + + this.matrixToNode(this.helpMatrix1, node); +}; + +ccs.TransformHelp.transformFromParentWithoutScale = function(node, parentNode){ +// this.helpParentNode.copy(&parentNode); + + for(var p in parentNode){ + this.helpParentNode[p] = parentNode[p]; + } + this.helpParentNode.scaleX = 1; + this.helpParentNode.scaleY = 1; + + this.nodeToMatrix(node, this.helpMatrix1); + this.nodeToMatrix(this.helpParentNode, this.helpMatrix2); + + this.helpMatrix2 = cc.affineTransformInvert(this.helpMatrix2); + this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2); + + this.matrixToNode(this.helpMatrix1, node); +}; + +ccs.TransformHelp.transformToParentWithoutScale = function(node, parentNode){ + for(var p in parentNode){ + this.helpParentNode[p] = parentNode[p]; + } + this.helpParentNode.scaleX = 1; + this.helpParentNode.scaleY = 1; + + this.nodeToMatrix(node, this.helpMatrix1); + this.nodeToMatrix(this.helpParentNode, this.helpMatrix2); + + this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2); + + this.matrixToNode(this.helpMatrix1, node); + +}; + /** * @function * @static diff --git a/extensions/cocostudio/armature/utils/CCTweenFunction.js b/extensions/cocostudio/armature/utils/CCTweenFunction.js index 259b005065..80756ed595 100644 --- a/extensions/cocostudio/armature/utils/CCTweenFunction.js +++ b/extensions/cocostudio/armature/utils/CCTweenFunction.js @@ -161,13 +161,25 @@ ccs.TweenFunction.tweenTo = function (time, type, easingParam) { break; case ccs.TweenType.elasticEaseIn: - delta = this.elasticEaseIn(time, easingParam); + var period = 0.3; + if(null != easingParam){ + period = easingParam[0]; + } + delta = this.elasticEaseIn(time, period); break; case ccs.TweenType.elasticEaseOut: - delta = this.elasticEaseOut(time, easingParam); + var period = 0.3; + if(null != easingParam){ + period = easingParam[0]; + } + delta = this.elasticEaseOut(time, period); break; case ccs.TweenType.elasticEaseInOut: - delta = this.elasticEaseInOut(time, easingParam); + var period = 0.3; + if(null != easingParam){ + period = easingParam[0]; + } + delta = this.elasticEaseInOut(time, period); break; case ccs.TweenType.backEaseIn: @@ -459,4 +471,33 @@ ccs.TweenFunction.customEase = function (time, easingParam) { return easingParam[1] * tt * tt * tt + 3 * easingParam[3] * time * tt * tt + 3 * easingParam[5] * time * time * tt + easingParam[7] * time * time * time; } return time; +}; + +ccs.TweenFunction.easeIn = function(time, rate){ + return Math.pow(time, rate); +}; + +ccs.TweenFunction.easeOut = function(time, rate){ + return Math.pow(time, 1 / rate); +}; + +ccs.TweenFunction.easeInOut = function(time, rate){ + time *= 2; + if(time < 1){ + return 0.5 * Math.pow(time, rate); + }else{ + return 1 - 0.5 * Math.pow(2 - time, rate); + } +}; + +ccs.TweenFunction.quadraticIn = function(time){ + return Math.pow(time, 2); +}; + +ccs.TweenFunction.quadraticOut = function(time){ + return -time * (time - 2); +}; + +ccs.TweenFunction.bezieratFunction = function(a, b, c, d, t){ + return (Math.pow(1-t,3) * a + 3*t*(Math.pow(1-t,2))*b + 3*Math.pow(t,2)*(1-t)*c + Math.pow(t,3)*d ); }; \ No newline at end of file From 2bcd4a12531c8fbb4d4f4b8cfc4b94752b4226bb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 14 Jul 2014 10:20:13 +0800 Subject: [PATCH 0280/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 11. CCArmatureDataManager --- .../armature/utils/CCArmatureDataManager.js | 258 +++++++++++------- 1 file changed, 165 insertions(+), 93 deletions(-) diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 63f67479f1..d16334c968 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -46,30 +46,34 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ _autoLoadSpriteFile: false, _relativeDatas: {}, + s_sharedArmatureDataManager: null, + /** * remove armature cache data by configFilePath * @param {String} configFilePath */ removeArmatureFileInfo:function(configFilePath){ var data = this.getRelativeData(configFilePath); - for (var i = 0; i < data.armatures.length; i++) { - var obj = data.armatures[i]; - this.removeArmatureData(obj); - } - for (var i = 0; i < data.animations.length; i++) { - var obj = data.animations[i]; - this.removeAnimationData(obj); - } - for (var i = 0; i < data.textures.length; i++) { - var obj = data.textures[i]; - this.removeTextureData(obj); - } - for (var i = 0; i < data.plistFiles.length; i++) { - var obj = data.plistFiles[i]; - cc.spriteFrameCache.removeSpriteFramesFromFile(obj); + if(data){ + for (var i = 0; i < data.armatures.length; i++) { + var obj = data.armatures[i]; + this.removeArmatureData(obj); + } + for (var i = 0; i < data.animations.length; i++) { + var obj = data.animations[i]; + this.removeAnimationData(obj); + } + for (var i = 0; i < data.textures.length; i++) { + var obj = data.textures[i]; + this.removeTextureData(obj); + } + for (var i = 0; i < data.plistFiles.length; i++) { + var obj = data.plistFiles[i]; + cc.spriteFrameCache.removeSpriteFramesFromFile(obj); + } + delete this._relativeDatas[configFilePath]; + ccs.dataReaderHelper.removeConfigFile(configFilePath); } - delete this._relativeDatas[configFilePath]; - ccs.dataReaderHelper.removeConfigFile(configFilePath); }, /** @@ -78,20 +82,17 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * @param {ccs.ArmatureData} armatureData */ addArmatureData:function (id, armatureData, configFilePath) { - if (this._armarureDatas) { - var data = this.getRelativeData(configFilePath); +// if (this._armarureDatas) { +// var data = this.getRelativeData(configFilePath); +// data.armatures.push(id); +// this._armarureDatas[id] = armatureData; +// } + var data = this.getRelativeData(configFilePath); + if (data) + { data.armatures.push(id); - this._armarureDatas[id] = armatureData; } - }, - - /** - * remove armature data - * @param {string} id - */ - removeArmatureData:function(id){ - if (this._armarureDatas[id]) - delete this._armarureDatas[id]; + this._armarureDatas[id] = armatureData; }, /** @@ -108,11 +109,12 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * get armatureDatas - * @return {Object} + * remove armature data + * @param {string} id */ - getArmatureDatas:function () { - return this._armarureDatas; + removeArmatureData:function(id){ + if (this._armarureDatas[id]) + delete this._armarureDatas[id]; }, /** @@ -121,20 +123,16 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * @param {ccs.AnimationData} animationData */ addAnimationData:function (id, animationData, configFilePath) { - if (this._animationDatas) { - var data = this.getRelativeData(configFilePath); +// if (this._animationDatas) { +// var data = this.getRelativeData(configFilePath); +// data.animations.push(id); +// this._animationDatas[id] = animationData; +// } + var data = this.getRelativeData(configFilePath); + if(data){ data.animations.push(id); - this._animationDatas[id] = animationData; } - }, - - /** - * remove animation data - * @param {string} id - */ - removeAnimationData:function(id){ - if (this._animationDatas[id]) - delete this._animationDatas[id]; + this._animationDatas[id] = animationData; }, /** @@ -151,11 +149,12 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * get animationDatas - * @return {Object} + * remove animation data + * @param {string} id */ - getAnimationDatas:function () { - return this._animationDatas; + removeAnimationData:function(id){ + if (this._animationDatas[id]) + delete this._animationDatas[id]; }, /** @@ -164,20 +163,18 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * @param {ccs.TextureData} textureData */ addTextureData:function (id, textureData, configFilePath) { - if (this._textureDatas) { - var data = this.getRelativeData(configFilePath); +// if (this._textureDatas) { +// var data = this.getRelativeData(configFilePath); +// data.textures.push(id); +// this._textureDatas[id] = textureData; +// } + var data = this.getRelativeData(configFilePath); + if (data) + { data.textures.push(id); - this._textureDatas[id] = textureData; } - }, - /** - * remove texture data - * @param {string} id - */ - removeTextureData:function(id){ - if (this._textureDatas[id]) - delete this._textureDatas[id]; + this._textureDatas[id] = textureData; }, /** @@ -194,11 +191,12 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * get textureDatas - * @return {Object} + * remove texture data + * @param {string} id */ - getTextureDatas:function () { - return this._textureDatas; + removeTextureData:function(id){ + if (this._textureDatas[id]) + delete this._textureDatas[id]; }, /** @@ -213,20 +211,41 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * ccs.armatureDataManager.addArmatureFileInfo("res/test.png","res/test.plist","res/test.json"); */ addArmatureFileInfo:function (/*imagePath, plistPath, configFilePath*/) { +// var imagePath, plistPath, configFilePath; +// var isLoadSpriteFrame = false; +// if (arguments.length == 1) { +// configFilePath = arguments[0]; +// isLoadSpriteFrame = true; +// this.addRelativeData(configFilePath); +// } else if (arguments.length == 3){ +// imagePath = arguments[0]; +// plistPath = arguments[1]; +// configFilePath = arguments[2]; +// this.addRelativeData(configFilePath); +// this.addSpriteFrameFromFile(plistPath, imagePath, configFilePath); +// } +// ccs.dataReaderHelper.addDataFromFile(configFilePath,isLoadSpriteFrame); var imagePath, plistPath, configFilePath; - var isLoadSpriteFrame = false; - if (arguments.length == 1) { - configFilePath = arguments[0]; - isLoadSpriteFrame = true; - this.addRelativeData(configFilePath); - } else if (arguments.length == 3){ - imagePath = arguments[0]; - plistPath = arguments[1]; - configFilePath = arguments[2]; - this.addRelativeData(configFilePath); - this.addSpriteFrameFromFile(plistPath, imagePath, configFilePath); + switch(arguments.length){ + case 1: + configFilePath = arguments[0]; + + this.addRelativeData(configFilePath); + + this._autoLoadSpriteFile = true; + ccs.DataReaderHelper.addDataFromFile(configFilePath); + break; + case 3: + imagePath = arguments[0]; + plistPath = arguments[1]; + configFilePath = arguments[2]; + + this.addRelativeData(configFilePath); + + this._autoLoadSpriteFile = false; + ccs.DataReaderHelper.addDataFromFile(configFilePath); + this.addSpriteFrameFromFile(plistPath, imagePath); } - ccs.dataReaderHelper.addDataFromFile(configFilePath,isLoadSpriteFrame); }, /** @@ -238,24 +257,51 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * @param {Function} configFilePath */ addArmatureFileInfoAsync:function (/*imagePath, plistPath, configFilePath, target, selector*/) { +// var imagePath, plistPath, configFilePath, target, selector; +// var isLoadSpriteFrame = false; +// if (arguments.length == 3) { +// configFilePath = arguments[0]; +// selector = arguments[1]; +// target = arguments[2]; +// isLoadSpriteFrame = true; +// this.addRelativeData(configFilePath); +// } else if (arguments.length == 5){ +// imagePath = arguments[0]; +// plistPath = arguments[1]; +// configFilePath = arguments[2]; +// selector = arguments[3]; +// target = arguments[4]; +// this.addRelativeData(configFilePath); +// this.addSpriteFrameFromFile(plistPath, imagePath, configFilePath); +// } +// ccs.dataReaderHelper.addDataFromFileAsync(configFilePath,target,selector,isLoadSpriteFrame); + var imagePath, plistPath, configFilePath, target, selector; - var isLoadSpriteFrame = false; - if (arguments.length == 3) { - configFilePath = arguments[0]; - selector = arguments[1]; - target = arguments[2]; - isLoadSpriteFrame = true; - this.addRelativeData(configFilePath); - } else if (arguments.length == 5){ - imagePath = arguments[0]; - plistPath = arguments[1]; - configFilePath = arguments[2]; - selector = arguments[3]; - target = arguments[4]; - this.addRelativeData(configFilePath); - this.addSpriteFrameFromFile(plistPath, imagePath, configFilePath); + switch(arguments.length){ + case 3: + configFilePath = arguments[0]; + selector = arguments[1]; + target = arguments[2]; + + this.addRelativeData(configFilePath); + + this._autoLoadSpriteFile = true; + ccs.DataReaderHelper.addDataFromFileAsync("", "", configFilePath, target, selector); + break; + case 5: + imagePath = arguments[0]; + plistPath = arguments[1]; + configFilePath = arguments[2]; + target = arguments[3]; + selector = arguments[4]; + + this.addRelativeData(configFilePath); + + this._autoLoadSpriteFile = false; + ccs.DataReaderHelper.addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector); + this.addSpriteFrameFromFile(plistPath, imagePath); + } - ccs.dataReaderHelper.addDataFromFileAsync(configFilePath,target,selector,isLoadSpriteFrame); }, @@ -266,7 +312,9 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ */ addSpriteFrameFromFile:function (plistPath, imagePath, configFilePath) { var data = this.getRelativeData(configFilePath); - data.plistFiles.push(plistPath); + if(data){ + data.plistFiles.push(plistPath); + } ccs.spriteFrameCacheHelper.addSpriteFrameFromFile(plistPath, imagePath); }, @@ -274,6 +322,30 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ return this._autoLoadSpriteFile; }, + /** + * get armatureDatas + * @return {Object} + */ + getArmatureDatas:function () { + return this._armarureDatas; + }, + + /** + * get animationDatas + * @return {Object} + */ + getAnimationDatas:function () { + return this._animationDatas; + }, + + /** + * get textureDatas + * @return {Object} + */ + getTextureDatas:function () { + return this._textureDatas; + }, + /** * add RelativeData * @param {String} configFilePath From 166f731c60ea0baec3df868d466fd26703166f06 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 14 Jul 2014 10:23:38 +0800 Subject: [PATCH 0281/1564] Issue #5702: Migrate Armature's datas and dipslay to H5 --- extensions/cocostudio/armature/CCBone.js | 2 +- .../cocostudio/armature/datas/CCDatas.js | 337 +++++++++-------- .../armature/display/CCBatchNode.js | 46 ++- .../armature/display/CCDecorativeDisplay.js | 23 +- .../armature/display/CCDisplayFactory.js | 355 +++++++++--------- .../armature/display/CCDisplayManager.js | 305 +++++++-------- .../cocostudio/armature/display/CCSkin.js | 45 ++- .../armature/utils/CCTweenFunction.js | 19 +- .../cocostudio/armature/utils/CCUtilMath.js | 8 +- 9 files changed, 565 insertions(+), 575 deletions(-) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index fe0c8e56c2..b61a54e858 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -215,7 +215,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._worldTransform = cc.affineTransformConcat(locWorldTransform, locArmature.nodeToParentTransform()); } } - ccs.DisplayFactory.updateDisplay(this, dt, this.boneTransformDirty || locArmature.getArmatureTransformDirty()); + ccs.displayFactory.updateDisplay(this, dt, this.boneTransformDirty || locArmature.getArmatureTransformDirty()); var locChildrenBone = this._childrenBone; for (var i = 0; i < locChildrenBone.length; i++) { diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index b6478b3b12..101f57e65b 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -138,12 +138,17 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ x:0, y:0, zOrder:0, + /** + * x y skewX skewY scaleX scaleY used to calculate transform matrix + * skewX, skewY can have rotation effect + * To get more matrix information, you can have a look at this pape : http://www.senocular.com/flash/tutorials/transformmatrix/ + */ skewX:0, skewY:0, scaleX:1, scaleY:1, - tweenRotate:0, - isUseColorInfo:false, + tweenRotate:0, //! SkewX, SkewY, and TweenRotate effect the rotation + isUseColorInfo:false, //! Whether or not this frame have the color changed Info r:255, g:255, b:255, @@ -165,7 +170,6 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ this.a = 255; }, - /** * Copy data from node * @function @@ -235,23 +239,19 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ } if (limit) { - if (this.skewX > cc.PI) { - this.skewX -= ccs.M_PI_X_2; - } - if (this.skewX < -cc.PI) { - this.skewX += ccs.M_PI_X_2; - } - if (this.skewY > cc.PI) { - this.skewY -= ccs.M_PI_X_2; - } - if (this.skewY < -cc.PI) { - this.skewY += ccs.M_PI_X_2; - } + if (this.skewX > ccs.M_PI) + this.skewX -= ccs.DOUBLE_PI; + if (this.skewX < -ccs.M_PI) + this.skewX += ccs.DOUBLE_PI; + if (this.skewY > ccs.M_PI) + this.skewY -= ccs.DOUBLE_PI; + if (this.skewY < -ccs.M_PI) + this.skewY += ccs.DOUBLE_PI; } if (to.tweenRotate) { - this.skewX += to.tweenRotate * ccs.M_PI_X_2; - this.skewY -= to.tweenRotate * ccs.M_PI_X_2; + this.skewX += to.tweenRotate * ccs.DOUBLE_PI; + this.skewY -= to.tweenRotate * ccs.DOUBLE_PI; } } }); @@ -262,9 +262,9 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ * @extends ccs.Class */ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ - displayType:ccs.DISPLAY_TYPE_MAX, - displayName:"", - ctor:function () { + displayType: ccs.DISPLAY_TYPE_MAX, + displayName: "", + ctor: function () { this.displayType = ccs.DISPLAY_TYPE_MAX; }, /** @@ -278,9 +278,8 @@ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ var textureName = displayName; var startPos = textureName.lastIndexOf("."); - if (startPos != -1) { + if (startPos != -1) textureName = textureName.substring(0, startPos); - } return textureName; }, /** @@ -341,24 +340,30 @@ ccs.ParticleDisplayData = ccs.DisplayData.extend(/** @lends ccs.ParticleDisplayD }); /** - * Base class for ccs.BoneData objects. + *

    + * BoneData used to init a Bone.
    + * BoneData keeps a DisplayData list, a Bone can have many display to change.
    + * The display information saved in the DisplayData
    + *

    * @class ccs.BoneData * @extends ccs.BaseData */ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ - displayDataList:null, - name:"", - parentName:"", - boneDataTransform:null, - ctor:function () { + displayDataList: null, + name: "", + parentName: "", + boneDataTransform: null, + + ctor: function () { this.displayDataList = []; this.name = ""; this.parentName = ""; this.boneDataTransform = null; }, - init:function () { + init: function () { + this.displayDataList.length = 0; }, /** * add display data @@ -381,7 +386,11 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ }); /** - * Base class for ccs.ArmatureData objects. + *

    + * ArmatureData saved the Armature name and BoneData needed for the CCBones in this Armature
    + * When we create a Armature, we need to get each Bone's BoneData as it's init information.
    + * So we can get a BoneData from the Dictionary saved in the ArmatureData.
    + *

    * @class ccs.ArmatureData * @extends ccs.Class */ @@ -398,16 +407,14 @@ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ return true; }, /** - * add bone data - * @function + * adds bone data to dictionary * @param {ccs.BoneData} boneData */ addBoneData:function (boneData) { this.boneDataDic[boneData.name] = boneData; }, /** - * get bone datas - * @function + * gets bone data dictionary * @returns {Object} */ getBoneDataDic:function () { @@ -442,6 +449,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ blendFunc:0, frameID:0, isTween:true, + ctor:function () { ccs.BaseData.prototype.ctor.call(this); this.duration = 1; @@ -476,9 +484,9 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ this.isTween = frameData.isTween; this.easingParamNumber = frameData.easingParamNumber; - this.easingParams = []; - if (this.easingParamNumber != 0) { - for (var i = 0; i + * The animation data information of Cocos Armature. It include all movement information for the Armature.
    + * The struct is AnimationData -> MovementData -> MovementBoneData -> FrameData
    + * -> MovementFrameData
    + *

    * @class ccs.AnimationData * @extends ccs.Class */ -ccs.AnimationData = ccs.Class.extend(/** @lends ccs.AnimationData# */{ - moveDataDic:null, - movementNames:null, - name:"", - ctor:function () { - this.moveDataDic = {}; - this.movementNames = []; - }, - /** - * add movement data - * @function - * @param {ccs.MovementData} moveData - */ - addMovement:function (moveData) { - this.moveDataDic[moveData.name] = moveData; - this.movementNames.push(moveData.name); - }, - /** - * get movement data - * @function - * @param {String} moveName - * @returns {ccs.MovementData} - */ - getMovement:function (moveName) { - return this.moveDataDic[moveName]; - }, - /** - * @function - * @returns {Number} - */ - getMovementCount:function () { - return Object.keys(this.moveDataDic).length; - } -}); +ccs.AnimationData = function(){ + this.movementDataDic = {}; + this.movementNames = []; + this.name = ""; +}; + +/** + * adds movement data to the movement data dictionary + * @param {ccs.MovementData} moveData + */ +ccs.AnimationData.prototype.addMovement = function(moveData){ + this.movementDataDic[moveData.name] = moveData; + this.movementNames.push(moveData.name); +}; + +/** + * gets movement data from movement data dictionary + * @param {String} moveName + * @returns {ccs.MovementData} + */ +ccs.AnimationData.prototype.getMovement = function(moveName){ + return this.movementDataDic[moveName]; +}; + +/** + * gets the count of movement data dictionary + * @returns {Number} + */ +ccs.AnimationData.prototype.getMovementCount = function(){ + return Object.keys(this.movementDataDic).length; +}; /** * contour vertex @@ -624,73 +638,58 @@ ccs.ContourVertex2 = function (x, y) { }; /** - * Base class for ccs.ContourData objects. + * The Contour data information of Cocos Armature. * @class ccs.ContourData - * @extends ccs.Class + * @constructor */ -ccs.ContourData = ccs.Class.extend({ - vertexList:null, - ctor:function () { - this.vertexList = []; - }, +ccs.ContourData = function(){ + this.vertexList = []; +}; - init:function () { - this.vertexList = []; - return true; - }, +ccs.ContourData.prototype.init = function(){ + this.vertexList.length = 0; + return true; +}; - /** - * add vertex - * @function - * @param {cc.Point} p - */ - addVertex: function (p) { - var v = ccs.ContourVertex2(p.x, p.y); - this.vertexList.push(v); - } -}); +/** + * add a vertex object to vertex list + * @param {cc.Point} p + */ +ccs.ContourData.prototype.addVertex = function(p){ + //var v = new ccs.ContourVertex2(p.x, p.y); //ccs.ContourVertex2 is same as cc.Point, so we needn't create a ccs.ContourVertex2 object + this.vertexList.push(p); +}; /** - * Base class for ccs.TextureData objects. + * The texture data information of Cocos Armature * @class ccs.TextureData - * @extends ccs.Class */ -ccs.TextureData = ccs.Class.extend(/** @lends ccs.TextureData# */{ - height:0, - width:0, - pivotX:0, - pivotY:0, - name:"", - contourDataList:null, - ctor:function () { - this.height = 0; - this.width = 0; - this.pivotX = 0.5; - this.pivotY = 0.5; - this.name = ""; - this.contourDataList = []; - }, +ccs.TextureData = function(){ + this.height = 0; + this.width = 0; + this.pivotX = 0.5; + this.pivotY = 0.5; + this.name = ""; + this.contourDataList = []; +}; - init:function () { - this.contourDataList = []; - }, +ccs.TextureData.prototype.init = function(){ + this.contourDataList.length = 0; +}; - /** - * set contourData - * @function - * @param {ccs.ContourData} contourData - */ - addContourData:function (contourData) { - this.contourDataList.push(contourData); - }, +/** + * adds a contourData to contourDataList + * @param {ccs.ContourData} contourData + */ +ccs.TextureData.prototype.addContourData = function(contourData){ + this.contourDataList.push(contourData); +}; - /** - * get contourData - * @function - * @param {Number} index - * @returns {ccs.ContourData} - */ - getContourData:function (index) { - return this.contourDataList[index]; - } -}); +/** + * gets a contourData from contourDataList by index + * @param {Number} index + * @returns {ccs.ContourData} + */ +ccs.TextureData.prototype.getContourData = function(index){ + return this.contourDataList[index]; +}; diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index c5f51c9ea2..1e71bea2b8 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -23,12 +23,19 @@ THE SOFTWARE. ****************************************************************************/ -cc.BatchNode = cc.Node.extend({ +/** + * A batchNode to Armature + * @class ccs.BatchNode + * @extends cc.Node + */ +ccs.BatchNode = cc.Node.extend(/** @lends ccs.BatchNode# */{ _atlas:null, _className:"BatchNode", + ctor:function () { this._atlas = null; }, + init:function () { var ret = cc.Node.prototype.init.call(this); this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR)); @@ -37,16 +44,21 @@ cc.BatchNode = cc.Node.extend({ addChild:function (child, zOrder, tag) { cc.Node.prototype.addChild.call(this, child, zOrder, tag); - if (child instanceof cc.Armature) { + if (child instanceof cc.Armature) child.setBatchNode(this); - } + }, + + removeChild: function(child, cleanup){ + if (child instanceof cc.Armature) + child.setBatchNode(null); + cc.Node.prototype.removeChild.call(this, child, cleanup); }, visit:function (renderer, parentTransform, parentTransformUpdated) { // quick return if not visible. children won't be drawn. - if (!this._visible) { + if (!this._visible) return; - } + var dirty = parentTransformUpdated || this._transformUpdated; if(dirty) this._modelViewTransform = this.transform(parentTransform); @@ -55,27 +67,30 @@ cc.BatchNode = cc.Node.extend({ // IMPORTANT: // To ease the migration to v3.0, we still support the kmGL stack, // but it is deprecated and your code should not rely on it - this.kmGLPushMatrix(); - if (this.grid && this.grid.isActive()) { + cc.kmGLPushMatrixWitMat4(this._stackMatrix); + + if (this.grid && this.grid.isActive()) this.grid.beforeDraw(); - } this.sortAllChildren(); this.draw(renderer, this._modelViewTransform, dirty); // reset for next frame this.arrivalOrder = 0; - if (this.grid && this.grid.isActive()) { + if (this.grid && this.grid.isActive()) this.grid.afterDraw(this); - } - this.kmGLPopMatrix(); + + cc.kmGLPopMatrix(); }, draw:function (renderer, transform, transformUpdated) { + var locChildren = this._children; + if(locChildren.length === 0) + return; var child = null; - for (var i = 0; i < this._children.length; i++) { - child = this._children[i]; + for (var i = 0, len = locChildren.length; i < len; i++) { + child = locChildren[i]; child.visit(); if (child instanceof cc.Armature) { this._atlas = child.getTextureAtlas(); @@ -87,8 +102,9 @@ cc.BatchNode = cc.Node.extend({ } } }); -cc.BatchNode.create = function () { - var batchNode = new cc.BatchNode(); + +ccs.BatchNode.create = function () { + var batchNode = new ccs.BatchNode(); if (batchNode && batchNode.init()) { return batchNode; } diff --git a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js index 314c67f7bd..3b7207b688 100644 --- a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +++ b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js @@ -24,14 +24,14 @@ ****************************************************************************/ /** - * Base class for ccs.DecorativeDisplay + * Decorative a display node for Cocos Armature * @class * @extends ccs.Class */ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ - _display:null, - _colliderDetector:null, - _displayData:null, + _display: null, + _colliderDetector: null, + _displayData: null, ctor:function () { this._display = null; @@ -44,7 +44,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * display setter + * sets display node * @param {cc.Node} display */ setDisplay:function (display) { @@ -52,7 +52,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * display getter + * gets the display node * @returns {cc.Node} */ getDisplay:function () { @@ -60,7 +60,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * colliderDetector setter + * sets collide detector * @param {ccs.ColliderDetector} colliderDetector */ setColliderDetector:function (colliderDetector) { @@ -68,7 +68,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * colliderDetector getter + * sets collide detector * @returns {ccs.ColliderDetector} */ getColliderDetector:function () { @@ -76,7 +76,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * display data setter + * sets display data * @param {ccs.DisplayData} displayData */ setDisplayData:function (displayData) { @@ -84,12 +84,13 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * display data getter + * gets display data * @returns {ccs.DisplayData} */ getDisplayData:function () { return this._displayData; }, + release:function () { CC_SAFE_RELEASE(this._display); this._display = null; @@ -98,12 +99,10 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ CC_SAFE_RELEASE(this._colliderDetector); this._colliderDetector = null; } - }); /** * allocates and initializes a decorative display. - * @constructs * @return {ccs.DecorativeDisplay} * @example * // example diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index 2823790b80..1378655992 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -26,187 +26,184 @@ /** * @ignore */ -ccs.DisplayFactory = ccs.DisplayFactory || ccs.Class.extend({}); -ccs.DisplayFactory.addDisplay = function (bone, decoDisplay, displayData) { - switch (displayData.displayType) { - case ccs.DISPLAY_TYPE_SPRITE: - this.addSpriteDisplay(bone, decoDisplay, displayData); - break; - case ccs.DISPLAY_TYPE_PARTICLE: - this.addParticleDisplay(bone, decoDisplay, displayData); - break; - case ccs.DISPLAY_TYPE_ARMATURE: - this.addArmatureDisplay(bone, decoDisplay, displayData); - break; - default: - break; - } -}; -ccs.DisplayFactory.createDisplay = function (bone, decoDisplay) { - switch (decoDisplay.getDisplayData().displayType) { - case ccs.DISPLAY_TYPE_SPRITE: - this.createSpriteDisplay(bone, decoDisplay); - break; - case ccs.DISPLAY_TYPE_PARTICLE: - this.createParticleDisplay(bone, decoDisplay); - break; - case ccs.DISPLAY_TYPE_ARMATURE: - this.createArmatureDisplay(bone, decoDisplay); - break; - default: - break; - } -}; -ccs.DisplayFactory._helpTransform = {a:1, b:0, c:0, d:1, tx:0, ty:0}; -ccs.DisplayFactory.updateDisplay = function (bone,dt, dirty) { - var display = bone.getDisplayRenderNode(); - if(!display) - return; - - switch (bone.getDisplayRenderNodeType()) { - case ccs.DISPLAY_TYPE_SPRITE: - if (dirty){ - display.updateArmatureTransform(); - } - break; - case ccs.DISPLAY_TYPE_PARTICLE: - this.updateParticleDisplay(bone, display, dt); - break; - case ccs.DISPLAY_TYPE_ARMATURE: - this.updateArmatureDisplay(bone, display, dt); - break; - default: - var transform = bone.getNodeToArmatureTransform(); - display.setAdditionalTransform(transform); - break; - } - - if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { - if (dirty) { - var decoDisplay = bone.getDisplayManager().getCurrentDecorativeDisplay(); - var detector = decoDisplay.getColliderDetector(); - if (detector) { - var node = decoDisplay.getDisplay(); - var displayTransform = node.nodeToParentTransform(); - var helpTransform = this._helpTransform; - helpTransform.a = displayTransform.a; - helpTransform.b = displayTransform.b; - helpTransform.c = displayTransform.c; - helpTransform.d = displayTransform.d; - helpTransform.tx = displayTransform.tx; - helpTransform.ty = displayTransform.ty; - var anchorPoint = node.getAnchorPointInPoints(); - anchorPoint = cc.pointApplyAffineTransform(anchorPoint, helpTransform); - helpTransform.tx = anchorPoint.x; - helpTransform.ty = anchorPoint.y; - var t = cc.affineTransformConcat(helpTransform, bone.getArmature().nodeToParentTransform()); - detector.updateTransform(t); +ccs.displayFactory = { + addDisplay: function (bone, decoDisplay, displayData) { + switch (displayData.displayType) { + case ccs.DISPLAY_TYPE_SPRITE: + this.addSpriteDisplay(bone, decoDisplay, displayData); + break; + case ccs.DISPLAY_TYPE_PARTICLE: + this.addParticleDisplay(bone, decoDisplay, displayData); + break; + case ccs.DISPLAY_TYPE_ARMATURE: + this.addArmatureDisplay(bone, decoDisplay, displayData); + break; + default: + break; + } + }, + + createDisplay: function (bone, decoDisplay) { + switch (decoDisplay.getDisplayData().displayType) { + case ccs.DISPLAY_TYPE_SPRITE: + this.createSpriteDisplay(bone, decoDisplay); + break; + case ccs.DISPLAY_TYPE_PARTICLE: + this.createParticleDisplay(bone, decoDisplay); + break; + case ccs.DISPLAY_TYPE_ARMATURE: + this.createArmatureDisplay(bone, decoDisplay); + break; + default: + break; + } + }, + + _helpTransform: {a:1, b:0, c:0, d:1, tx:0, ty:0}, + updateDisplay: function (bone,dt, dirty) { + var display = bone.getDisplayRenderNode(); + if(!display) + return; + + switch (bone.getDisplayRenderNodeType()) { + case ccs.DISPLAY_TYPE_SPRITE: + if (dirty) + display.updateArmatureTransform(); + break; + case ccs.DISPLAY_TYPE_PARTICLE: + this.updateParticleDisplay(bone, display, dt); + break; + case ccs.DISPLAY_TYPE_ARMATURE: + this.updateArmatureDisplay(bone, display, dt); + break; + default: + display.setAdditionalTransform(bone.getNodeToArmatureTransform()); + break; + } + if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { + if (dirty) { + var decoDisplay = bone.getDisplayManager().getCurrentDecorativeDisplay(); + var detector = decoDisplay.getColliderDetector(); + if (detector) { + var node = decoDisplay.getDisplay(); + var displayTransform = node.nodeToParentTransform(); + var helpTransform = this._helpTransform; + helpTransform.a = displayTransform.a; + helpTransform.b = displayTransform.b; + helpTransform.c = displayTransform.c; + helpTransform.d = displayTransform.d; + helpTransform.tx = displayTransform.tx; + helpTransform.ty = displayTransform.ty; + var anchorPoint = node.getAnchorPointInPoints(); + anchorPoint = cc.pointApplyAffineTransform(anchorPoint, helpTransform); + helpTransform.tx = anchorPoint.x; + helpTransform.ty = anchorPoint.y; + var t = cc.affineTransformConcat(helpTransform, bone.getArmature().nodeToParentTransform()); + detector.updateTransform(t); + } } } - } - -}; -ccs.DisplayFactory.addSpriteDisplay = function (bone, decoDisplay, displayData) { - var sdp = new ccs.SpriteDisplayData(); - sdp.copy(displayData); - decoDisplay.setDisplayData(sdp); - this.createSpriteDisplay(bone, decoDisplay); -}; - -ccs.DisplayFactory.createSpriteDisplay = function (bone, decoDisplay) { - var skin = null; - var displayData = decoDisplay.getDisplayData(); - //! remove .xxx - var textureName = displayData.displayName; - var startPos = textureName.lastIndexOf("."); - if (startPos != -1) { - textureName = textureName.substring(0, startPos); - } - //! create display - if (textureName == "") { - skin = ccs.Skin.create(); - } - else { - skin = ccs.Skin.createWithSpriteFrameName(textureName + ".png"); - } - decoDisplay.setDisplay(skin); - skin.setBone(bone); - this.initSpriteDisplay(bone, decoDisplay, displayData.displayName, skin); - var armature = bone.getArmature(); - if (armature) { - if (armature.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED) - skin.setSkinData(displayData.skinData); + }, + + addSpriteDisplay: function (bone, decoDisplay, displayData) { + var sdp = new ccs.SpriteDisplayData(); + sdp.copy(displayData); + decoDisplay.setDisplayData(sdp); + this.createSpriteDisplay(bone, decoDisplay); + }, + + createSpriteDisplay: function (bone, decoDisplay) { + var skin = null; + var displayData = decoDisplay.getDisplayData(); + //! remove .xxx + var textureName = displayData.displayName; + var startPos = textureName.lastIndexOf("."); + if (startPos != -1) + textureName = textureName.substring(0, startPos); + //! create display + if (textureName == "") + skin = ccs.Skin.create(); else - skin.setSkinData(bone.getBoneData()); - } - - -}; - -ccs.DisplayFactory.initSpriteDisplay = function(bone, decoDisplay, displayName, skin){ - var textureName = displayName; - var startPos = textureName.lastIndexOf("."); - if (startPos != -1) { - textureName = textureName.substring(0, startPos); - } - var textureData = ccs.armatureDataManager.getTextureData(textureName); - if (textureData) { - //! Init display anchorPoint, every Texture have a anchor point - skin.setAnchorPoint(textureData.pivotX, textureData.pivotY); - } - if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { - if (textureData && textureData.contourDataList.length > 0) { - var colliderDetector = ccs.ColliderDetector.create(bone); - colliderDetector.addContourDataList(textureData.contourDataList); - decoDisplay.setColliderDetector(colliderDetector); + skin = ccs.Skin.createWithSpriteFrameName(textureName + ".png"); + + decoDisplay.setDisplay(skin); + skin.setBone(bone); + this.initSpriteDisplay(bone, decoDisplay, displayData.displayName, skin); + var armature = bone.getArmature(); + if (armature) { + if (armature.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED) + skin.setSkinData(displayData.skinData); + else + skin.setSkinData(bone.getBoneData()); } + }, + + initSpriteDisplay: function (bone, decoDisplay, displayName, skin) { + var textureName = displayName; + var startPos = textureName.lastIndexOf("."); + if (startPos != -1) + textureName = textureName.substring(0, startPos); + var textureData = ccs.armatureDataManager.getTextureData(textureName); + if (textureData) { + //! Init display anchorPoint, every Texture have a anchor point + skin.setAnchorPoint(textureData.pivotX, textureData.pivotY); + } + if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { + if (textureData && textureData.contourDataList.length > 0) { + var detector = ccs.ColliderDetector.create(bone); + detector.addContourDataList(textureData.contourDataList); + decoDisplay.setColliderDetector(detector); + } + } + }, + + addArmatureDisplay: function (bone, decoDisplay, displayData) { + var adp = new ccs.ArmatureDisplayData(); + adp.copy(displayData); + decoDisplay.setDisplayData(adp); + this.createArmatureDisplay(bone, decoDisplay); + }, + + createArmatureDisplay: function (bone, decoDisplay) { + var displayData = decoDisplay.getDisplayData(); + var armature = ccs.Armature.create(displayData.displayName, bone); + decoDisplay.setDisplay(armature); + }, + + updateArmatureDisplay: function (bone, armature, dt) { + if (armature) { + armature.sortAllChildren(); + armature.update(dt); + } + }, + + addParticleDisplay: function (bone, decoDisplay, displayData) { + var adp = new ccs.ParticleDisplayData(); + adp.copy(displayData); + decoDisplay.setDisplayData(adp); + this.createParticleDisplay(bone, decoDisplay); + }, + + createParticleDisplay: function (bone, decoDisplay) { + var displayData = decoDisplay.getDisplayData(); + var system = cc.ParticleSystem.create(displayData.displayName); + + system.removeFromParent(); + system.cleanup(); + + var armature = bone.getArmature(); + if (armature) + system.setParent(bone.getArmature()); + + decoDisplay.setDisplay(system); + }, + + updateParticleDisplay: function (bone, particleSystem, dt) { + var node = new ccs.BaseData(); + ccs.TransformHelp.matrixToNode(bone.nodeToArmatureTransform(), node); + particleSystem.setPosition(node.x, node.y); + particleSystem.setScaleX(node.scaleX); + particleSystem.setScaleY(node.scaleY); + particleSystem.update(dt); } -}; - -ccs.DisplayFactory.addArmatureDisplay = function (bone, decoDisplay, displayData) { - var adp = new ccs.ArmatureDisplayData(); - adp.copy(displayData); - decoDisplay.setDisplayData(adp); - - this.createArmatureDisplay(bone, decoDisplay); -}; -ccs.DisplayFactory.createArmatureDisplay = function (bone, decoDisplay) { - var displayData = decoDisplay.getDisplayData(); - var armature = ccs.Armature.create(displayData.displayName, bone); - decoDisplay.setDisplay(armature); -}; -ccs.DisplayFactory.updateArmatureDisplay = function (bone, armature, dt) { - if (armature) { - armature.sortAllChildren(); - armature.update(dt); - } -}; - -ccs.DisplayFactory.addParticleDisplay = function (bone, decoDisplay, displayData) { - var adp = new ccs.ParticleDisplayData(); - adp.copy(displayData); - decoDisplay.setDisplayData(adp); - this.createParticleDisplay(bone, decoDisplay); -}; -ccs.DisplayFactory.createParticleDisplay = function (bone, decoDisplay) { - var displayData = decoDisplay.getDisplayData(); - var system = cc.ParticleSystem.create(displayData.displayName); - - system.removeFromParent(); - system.cleanup(); - - var armature = bone.getArmature(); - if (armature) { - system.setParent(bone.getArmature()); - } - - decoDisplay.setDisplay(system); -}; -ccs.DisplayFactory.updateParticleDisplay = function (bone, particleSystem, dt) { - var node = new ccs.BaseData(); - ccs.TransformHelp.matrixToNode(bone.nodeToArmatureTransform(), node); - particleSystem.setPosition(node.x, node.y); - particleSystem.setScaleX(node.scaleX); - particleSystem.setScaleY(node.scaleY); - particleSystem.update(dt); -}; +}; \ No newline at end of file diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index b64874e1a4..2d4861308e 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -37,6 +37,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ _bone:null, _visible:true, _displayType: null, + ctor:function () { this._decoDisplayList = []; this._currentDecoDisplay = null; @@ -54,113 +55,80 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ return true; }, + /** + *

    + * Add display and use _DisplayData init the display.
    + * If index already have a display, then replace it.
    + * If index is current display index, then also change display to _index
    + *

    + * @param {ccs.DisplayData|cc.Node} display it include the display information, like DisplayType. If you want to create a sprite display, then create a SpriteDisplayData param + * @param {Number} index the index of the display you want to replace or add to. -1 : append display from back + */ addDisplay: function (display, index) { - - var decoDisplay = null; - - if( (index >= 0) && (index < this._decoDisplayList.length) ) - { - decoDisplay = this._decoDisplayList[index]; - } - else - { + var decoDisplay, locDisplayList = this._decoDisplayList; + if( (index >= 0) && (index < locDisplayList.length) ) + decoDisplay = locDisplayList[index]; + else{ decoDisplay = ccs.DecorativeDisplay.create(); - this._decoDisplayList.push(decoDisplay); + locDisplayList.push(decoDisplay); + } + + if(display instanceof ccs.DisplayData){ + cc.displayFactory.addDisplay(this._bone, decoDisplay, display); + //! if changed display index is current display index, then change current display to the new display + if(index == this._displayIndex) { + this._displayIndex = -1; + this.changeDisplayWithIndex(index, false); + } + return; } var displayData = null; - if (display instanceof ccs.Skin) - { - var skin = display; - skin.setBone(this._bone); + if (display instanceof ccs.Skin) { + display.setBone(this._bone); displayData = new ccs.SpriteDisplayData(); - - ccs.DisplayFactory.initSpriteDisplay(this._bone, decoDisplay, skin.getDisplayName(), skin); + ccs.displayFactory.initSpriteDisplay(this._bone, decoDisplay, display.getDisplayName(), display); var spriteDisplayData = decoDisplay.getDisplayData(); - if (spriteDisplayData instanceof ccs.SpriteDisplayData) - { - skin.setSkinData(spriteDisplayData.skinData); + if (spriteDisplayData instanceof ccs.SpriteDisplayData) { + display.setSkinData(spriteDisplayData.skinData); displayData.skinData = spriteDisplayData.skinData; - } - else - { + } else { var find = false; - - for (var i = this._decoDisplayList.length - 2; i>=0; i--) - { - var dd = this._decoDisplayList[i]; + for (var i = locDisplayList.length - 2; i >= 0; i--) { + var dd = locDisplayList[i]; var sdd = dd.getDisplayData(); - if (sdd instanceof ccs.SpriteDisplayData) - { + if (sdd instanceof ccs.SpriteDisplayData) { find = true; - skin.setSkinData(sdd.skinData); + display.setSkinData(sdd.skinData); displayData.skinData = sdd.skinData; break; } } -// -// if (!find) -// { -// BaseData baseData; -// skin.setSkinData(baseData); -// } + if (!find) + display.setSkinData(new ccs.BaseData()); } - } - else if (display instanceof cc.ParticleSystem) - { + } else if (display instanceof cc.ParticleSystem){ displayData = new ccs.ParticleDisplayData(); - display.removeFromParent(); display.cleanup(); - var armature = this._bone.getArmature(); if (armature) - { display.setParent(armature); - } - } - else if(display instanceof ccs.Armature) - { - var armature = display; + } else if(display instanceof ccs.Armature) { displayData = new ccs.ArmatureDisplayData(); - displayData.displayName = armature.getName(); - armature.setParentBone(this._bone); - } - else - { + displayData.displayName = display.getName(); + display.setParentBone(this._bone); + } else displayData = new ccs.DisplayData(); - } - decoDisplay.setDisplay(display); decoDisplay.setDisplayData(displayData); //! if changed display index is current display index, then change current display to the new display - if(index == this._displayIndex) - { + if(index == this._displayIndex) { this._displayIndex = -1; this.changeDisplayWithIndex(index, false); } -// var decoDisplay = null; -// if (index >= 0 && index < this._decoDisplayList.length) { -// decoDisplay = this._decoDisplayList[index]; -// } -// else { -// decoDisplay = ccs.DecorativeDisplay.create(); -// this._decoDisplayList.push(decoDisplay); -// } -// -// if(displayData instanceof ccs.DisplayData){ -// ccs.DisplayFactory.addDisplay(this._bone, decoDisplay, displayData); -// }else{ -// this._addDisplayOther(decoDisplay,displayData); -// } -// -// //! if changed display index is current display index, then change current display to the new display -// if (index == this._displayIndex) { -// this._displayIndex = -1; -// this.changeDisplayWithIndex(index, false); -// } }, _addDisplayOther:function(decoDisplay,display){ @@ -170,7 +138,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ skin.setBone(this._bone); displayData = new ccs.SpriteDisplayData(); displayData.displayName = skin.getDisplayName(); - ccs.DisplayFactory.initSpriteDisplay(this._bone, decoDisplay, skin.getDisplayName(), skin); + ccs.displayFactory.initSpriteDisplay(this._bone, decoDisplay, skin.getDisplayName(), skin); var spriteDisplayData = decoDisplay.getDisplayData(); if (spriteDisplayData instanceof ccs.SpriteDisplayData) skin.setSkinData(spriteDisplayData.skinData); @@ -211,7 +179,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ removeDisplay:function (index) { this._decoDisplayList.splice(index, 1); - if (index == this._displayIndex) { + if (index === this._displayIndex) { this.setCurrentDecorativeDisplay(null); } }, @@ -220,41 +188,43 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ return this._decoDisplayList; }, + /** + *

    + * Change display by index. You can just use this method to change display in the display list.
    + * The display list is just used for this bone, and it is the displays you may use in every frame.
    + * Note : if index is the same with prev index, the method will not effect
    + *

    + * @param {Number} index The index of the display you want to change + * @param {Number} force If true, then force change display to specified display, or current display will set to display index edit in the flash every key frame. + */ changeDisplayWithIndex:function (index, force) { if (index >= this._decoDisplayList.length) { cc.log("the index value is out of range"); return; } - this._forceChangeDisplay = force; - //this._displayIndex == -1, it means you want to hide you display - if (index < 0) { - this._displayIndex = index; - if (this._displayRenderNode) { - this._displayRenderNode.removeFromParent(true); - this.setCurrentDecorativeDisplay(null); - this._displayRenderNode = null; - } - return; - } - //if index is equal to current display index,then do nothing - if (this._displayIndex == index) { + if (this._displayIndex == index) return; - } + this._displayIndex = index; - var decoDisplay = this._decoDisplayList[this._displayIndex]; - if(!decoDisplay){ + //! If displayIndex < 0, it means you want to hide you display + if (index < 0) { + if(this._displayRenderNode) { + this._displayRenderNode.removeFromParentAndCleanup(true); + this.setCurrentDecorativeDisplay(null); + } return; } - this.setCurrentDecorativeDisplay(decoDisplay); + this.setCurrentDecorativeDisplay(this._decoDisplayList[index]); }, changeDisplayWithName: function (name, force) { - for (var i = 0; i < this._decoDisplayList.length; i++) { - if (this._decoDisplayList[i].getDisplayData().displayName == name) { + var locDisplayList = this._decoDisplayList; + for (var i = 0; i < locDisplayList.length; i++) { + if (locDisplayList[i].getDisplayData().displayName == name) { this.changeDisplayWithIndex(i, force); break; } @@ -264,47 +234,41 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ setCurrentDecorativeDisplay:function (decoDisplay) { var locCurrentDecoDisplay = this._currentDecoDisplay; if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { - if (locCurrentDecoDisplay && locCurrentDecoDisplay.getColliderDetector()) { + if (locCurrentDecoDisplay && locCurrentDecoDisplay.getColliderDetector()) locCurrentDecoDisplay.getColliderDetector().setActive(false); - } } this._currentDecoDisplay = decoDisplay; locCurrentDecoDisplay = this._currentDecoDisplay; if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { - if (locCurrentDecoDisplay && locCurrentDecoDisplay.getColliderDetector()) { + if (locCurrentDecoDisplay && locCurrentDecoDisplay.getColliderDetector()) locCurrentDecoDisplay.getColliderDetector().setActive(true); - } } - var displayRenderNode = locCurrentDecoDisplay == null ? null : locCurrentDecoDisplay.getDisplay(); - if (this._displayRenderNode) { - if (this._displayRenderNode instanceof ccs.Armature) { - this._bone.setChildArmature(null); - } - this._displayRenderNode.removeFromParent(true); - this._displayRenderNode = null; - } + var displayRenderNode = (!locCurrentDecoDisplay) ? null : locCurrentDecoDisplay.getDisplay(); + var locRenderNode = this._displayRenderNode, locBone = this._bone; + if (locRenderNode) { + if (locRenderNode instanceof ccs.Armature) + locBone.setChildArmature(null); + locRenderNode.removeFromParent(true); + } this._displayRenderNode = displayRenderNode; if (displayRenderNode) { - if (displayRenderNode instanceof ccs.Armature) { - this._bone.setChildArmature(displayRenderNode); - }else if(displayRenderNode instanceof cc.ParticleSystem) { + if (displayRenderNode instanceof ccs.Armature){ + locBone.setChildArmature(displayRenderNode); + displayRenderNode.setParentBone(locBone); + } else if(displayRenderNode instanceof cc.ParticleSystem) displayRenderNode.resetSystem(); - } - displayRenderNode.setColor(this._bone.getDisplayedColor()); - displayRenderNode.setOpacity(this._bone.getDisplayedOpacity()); + displayRenderNode.setColor(locBone.getDisplayedColor()); + displayRenderNode.setOpacity(locBone.getDisplayedOpacity()); - displayRenderNode.retain(); + this._displayRenderNode.setVisible(this._visible); this._displayType = this._currentDecoDisplay.getDisplayData().displayType; - //todo - //this._displayRenderNode.setVisible(this._visible); - }else{ + }else this._displayType = ccs.DISPLAY_TYPE_MAX; - } }, getDisplayRenderNode:function () { @@ -327,92 +291,97 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ return this._decoDisplayList[index]; }, + /** + *

    + * Use BoneData to init the display list. + * If display is a sprite, and it have texture info in the TextureData, then use TextureData to init the display node's anchor point + * If the display is a Armature, then create a new Armature + *

    + * @param {ccs.BoneData} boneData + */ initDisplayList:function (boneData) { - this._decoDisplayList = []; - if (!boneData) { + this._decoDisplayList.length = 0; + if (!boneData) return; - } - var displayList = boneData.displayDataList; + var displayList = boneData.displayDataList, decoList = this._decoDisplayList, locBone = this._bone; for (var i = 0; i < displayList.length; i++) { var displayData = displayList[i]; var decoDisplay = ccs.DecorativeDisplay.create(); decoDisplay.setDisplayData(displayData); - - ccs.DisplayFactory.createDisplay(this._bone, decoDisplay); - - this._decoDisplayList.push(decoDisplay); + ccs.displayFactory.createDisplay(locBone, decoDisplay); + decoList.push(decoDisplay); } }, + /** + * Check if the position is inside the bone. + * @param {cc.Point|Number} point + * @param {Number} [y] + * @returns {boolean} + */ containPoint: function (point, y) { - var p = cc.p(0, 0); - if (y === undefined) { - p.x = point.x; - p.y = point.y; - } else { - p.x = point; - p.y = y; - } - if (!this._visible || this._displayIndex < 0) { + if (y !== undefined) + point = cc.p(point, y); + + if (!this._visible || this._displayIndex < 0) return false; - } - var ret = false; - switch (this._currentDecoDisplay.getDisplayData().displayType) { - case ccs.DISPLAY_TYPE_SPRITE: - /* - * First we first check if the point is in the sprite content rect. If false, then we continue to check - * the contour point. If this step is also false, then we can say the bone not contain this point. - * - */ - var outPoint = cc.p(0, 0); - var sprite = this._currentDecoDisplay.getDisplay(); - sprite = sprite.getChildByTag(0); - ret = ccs.SPRITE_CONTAIN_POINT_WITH_RETURN(sprite, p, outPoint); - break; - default: - break; - } - return ret; + if(this._currentDecoDisplay.getDisplayData().displayType == ccs.DISPLAY_TYPE_SPRITE){ + /* + * First we first check if the point is in the sprite content rect. If false, then we continue to check + * the contour point. If this step is also false, then we can say the bone not contain this point. + * + */ + var sprite = this._currentDecoDisplay.getDisplay(); + sprite = sprite.getChildByTag(0); + return ccs.SPRITE_CONTAIN_POINT_WITH_RETURN(sprite, point); + } + return false; }, + /** + *

    + * Sets whether the display is visible
    + * The default value is true, a node is default to visible + *

    + * @param {boolean} visible + */ setVisible:function (visible) { - if (!this._displayRenderNode) { + if (!this._displayRenderNode) return; - } this._visible = visible; this._displayRenderNode.setVisible(visible); }, + /** + * Determines if the display is visible + * @returns {boolean} true if the node is visible, false if the node is hidden. + */ isVisible:function () { return this._visible; }, getContentSize:function () { - if (!this._displayRenderNode) { - return cc.size(0, 0); - } + if (!this._displayRenderNode) + return cc.size(0, 0); return this._displayRenderNode.getContentSize(); }, getBoundingBox:function () { - if (!this._displayRenderNode) { + if (!this._displayRenderNode) return cc.rect(0, 0, 0, 0); - } return this._displayRenderNode.getBoundingBox(); }, getAnchorPoint:function () { - if (!this._displayRenderNode) { + if (!this._displayRenderNode) return cc.p(0, 0); - } return this._displayRenderNode.getAnchorPoint(); }, getAnchorPointInPoints:function () { - if (!this._displayRenderNode) { + if (!this._displayRenderNode) return cc.p(0, 0); - } return this._displayRenderNode.getAnchorPointInPoints(); }, @@ -421,19 +390,17 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ }, release:function () { - this._decoDisplayList = []; + this._decoDisplayList = null; if (this._displayRenderNode) { this._displayRenderNode.removeFromParent(true); this._displayRenderNode = null; } } - }); ccs.DisplayManager.create = function (bone) { var displayManager = new ccs.DisplayManager(); - if (displayManager && displayManager.init(bone)) { + if (displayManager && displayManager.init(bone)) return displayManager; - } return null; }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 44d0d9a039..845d0cfdcb 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccs.Skin + * ccs.Bone uses ccs.Skin to displays on screen. * @class * @extends ccs.Sprite * @@ -40,6 +40,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ _displayName: "", _armature: null, _className: "Skin", + ctor: function () { cc.Sprite.prototype.ctor.call(this); this._skinData = null; @@ -48,16 +49,23 @@ 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); + if(spriteFrameName == "") + return false; + var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); this._displayName = spriteFrameName; - return ret; + if(frame) + return this.initWithSpriteFrame(frame); + return false; }, + initWithFile: function (fileName) { var ret = cc.Sprite.prototype.initWithFile.call(this, fileName); this._displayName = fileName; return ret; }, + setSkinData: function (skinData) { this._skinData = skinData; @@ -104,6 +112,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ locTransform.b = [locTransform.c, locTransform.c = locTransform.b][0]; } }, + /** returns a "local" axis aligned bounding box of the node.
    * The returned box is relative only to its parent. * @return {cc.Rect} @@ -131,7 +140,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return cc.affineTransformConcat(this._transform, this.bone.getArmature().nodeToWorldTransform()); }, - nodeToWorldTransformAR: function () { var displayTransform = this._transform; var anchorPoint = this._anchorPointInPoints; @@ -159,38 +167,43 @@ _p = null; /** * allocates and initializes a skin. - * @param {String} fileName - * @param {cc.Rect} rect + * @param {String} [fileName] fileName or sprite frame name + * @param {cc.Rect} [rect] * @returns {ccs.Skin} * @example * // example * var skin = ccs.Skin.create("res/test.png",cc.rect(0,0,50,50)); + * var skin = ccs.Skin.create("#test.png"); //=> ccs.Skin.createWithSpriteFrameName("test.png"); */ ccs.Skin.create = function (fileName, rect) { var argnum = arguments.length; - var sprite = new ccs.Skin(); - if (argnum === 0) { - if (sprite.init()) - return sprite; + var skin = new ccs.Skin(); + if (argnum === 0 || fileName == null || fileName == "") { + if (skin.init()) + return skin; } else { - if (sprite && sprite.initWithFile(fileName, rect)) - return sprite; + if(fileName[0] == "#"){ + if (skin && skin.initWithSpriteFrameName(fileName)) + return skin; + }else{ + if (skin && skin.initWithFile(fileName, rect)) + return skin; + } } return null; }; /** * allocates and initializes a skin. - * @param {String} pszSpriteFrameName + * @param {String} spriteFrameName * @returns {ccs.Skin} * @example * // example * var skin = ccs.Skin.createWithSpriteFrameName("test.png"); */ -ccs.Skin.createWithSpriteFrameName = function (pszSpriteFrameName) { +ccs.Skin.createWithSpriteFrameName = function (spriteFrameName) { var skin = new ccs.Skin(); - if (skin && skin.initWithSpriteFrameName(pszSpriteFrameName)) { + if (skin && skin.initWithSpriteFrameName(spriteFrameName)) return skin; - } return null; }; diff --git a/extensions/cocostudio/armature/utils/CCTweenFunction.js b/extensions/cocostudio/armature/utils/CCTweenFunction.js index 259b005065..f0fff132fa 100644 --- a/extensions/cocostudio/armature/utils/CCTweenFunction.js +++ b/extensions/cocostudio/armature/utils/CCTweenFunction.js @@ -76,8 +76,8 @@ ccs.TweenType = { ccs.TweenFunction = ccs.TweenFunction || ccs.Class.extend({}); -ccs.M_PI_X_2 = Math.PI * 2; -ccs.M_PI_2 = Math.PI / 2; +ccs.DOUBLE_PI = ccs.M_PI_X_2 = Math.PI * 2; +ccs.HALF_PI = ccs.M_PI_2 = Math.PI / 2; ccs.M_PI = Math.PI; ccs.TweenFunction.tweenTo = function (time, type, easingParam) { @@ -207,10 +207,10 @@ ccs.TweenFunction.linear = function (time) { // Sine Ease ccs.TweenFunction.sineEaseIn = function (time) { - return -1 * Math.cos(time * ccs.M_PI_2) + 1; + return -1 * Math.cos(time * ccs.HALF_PI) + 1; }; ccs.TweenFunction.sineEaseOut = function (time) { - return Math.sin(time * ccs.M_PI_2); + return Math.sin(time * ccs.HALF_PI); }; ccs.TweenFunction.sineEaseInOut = function (time) { return -0.5 * (Math.cos(ccs.M_PI * time) - 1); @@ -336,7 +336,7 @@ ccs.TweenFunction.elasticEaseIn = function (time, easingParam) { else { var s = period / 4; time = time - 1; - newT = -Math.pow(2, 10 * time) * Math.sin((time - s) * ccs.M_PI_X_2 / period); + newT = -Math.pow(2, 10 * time) * Math.sin((time - s) * ccs.DOUBLE_PI / period); } return newT; @@ -354,7 +354,7 @@ ccs.TweenFunction.elasticEaseOut = function (time, easingParam) { } else { var s = period / 4; - newT = Math.pow(2, -10 * time) * Math.sin((time - s) * ccs.M_PI_X_2 / period) + 1; + newT = Math.pow(2, -10 * time) * Math.sin((time - s) * ccs.DOUBLE_PI / period) + 1; } return newT; @@ -380,10 +380,9 @@ ccs.TweenFunction.elasticEaseInOut = function (time, easingParam) { time = time - 1; if (time < 0) { - newT = -0.5 * Math.pow(2, 10 * time) * Math.sin((time - s) * ccs.M_PI_X_2 / period); - } - else { - newT = Math.pow(2, -10 * time) * Math.sin((time - s) * ccs.M_PI_X_2 / period) * 0.5 + 1; + newT = -0.5 * Math.pow(2, 10 * time) * Math.sin((time - s) * ccs.DOUBLE_PI / period); + } else { + newT = Math.pow(2, -10 * time) * Math.sin((time - s) * ccs.DOUBLE_PI / period) * 0.5 + 1; } } return newT; diff --git a/extensions/cocostudio/armature/utils/CCUtilMath.js b/extensions/cocostudio/armature/utils/CCUtilMath.js index d03e7334d1..082ec35b12 100644 --- a/extensions/cocostudio/armature/utils/CCUtilMath.js +++ b/extensions/cocostudio/armature/utils/CCUtilMath.js @@ -37,13 +37,13 @@ var CC_SAFE_RELEASE = function (obj) { }; ccs.isSpriteContainPoint = function (sprite, point, outPoint) { - var p = cc.p(0, 0); + var p = sprite.convertToNodeSpace(point); if (outPoint) { - p = sprite.convertToNodeSpace(point); + outPoint.x = p.x; + outPoint.y = p.y; } var s = sprite.getContentSize(); - var r = cc.rect(0, 0, s.width, s.height); - return cc.rectContainsPoint(r, p); + return cc.rectContainsPoint(cc.rect(0, 0, s.width, s.height), p); }; ccs.SPRITE_CONTAIN_POINT = ccs.isSpriteContainPoint; ccs.SPRITE_CONTAIN_POINT_WITH_RETURN = ccs.isSpriteContainPoint; From c53ffeeee8ebdaf9080877ec17ff59de0f9b1cc4 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 14 Jul 2014 10:52:03 +0800 Subject: [PATCH 0282/1564] issue #5685: refactor create and ctor functions of transition --- cocos2d/transitions/CCTransition.js | 430 ++++++++++++++++++---------- 1 file changed, 286 insertions(+), 144 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 09e0da33b5..59e956443c 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -86,7 +86,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to transit with */ - ctor:function(t, scene){ + ctor:function (t, scene) { cc.Scene.prototype.ctor.call(this); if(t !== undefined && scene !== undefined) this.initWithDuration(t, scene); @@ -260,6 +260,16 @@ cc.TransitionScene.create = function (t, scene) { cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionSceneOriented# */{ _orientation:0, + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation + */ + ctor:function (t, scene, orientation) { + cc.TransitionScene.prototype.ctor.call(this); + orientation && this.initWithDuration(t, scene, orientation); + }, /** * initialize the transition * @param {Number} t time in seconds @@ -286,10 +296,7 @@ cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionS * var goHorizontal = cc.TransitionSceneOriented.create(0.5, thisScene, cc.TRANSITION_ORIENTATION_LEFT_OVER) */ cc.TransitionSceneOriented.create = function (t, scene, orientation) { - var tempScene = new cc.TransitionSceneOriented(); - tempScene.initWithDuration(t, scene, orientation); - - return tempScene; + return new cc.TransitionSceneOriented(t, scene, orientation); }; /** @@ -298,6 +305,16 @@ cc.TransitionSceneOriented.create = function (t, scene, orientation) { * @extends cc.TransitionScene */ cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZoom# */{ + + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * Custom On Enter callback * @override @@ -338,11 +355,7 @@ cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZo * var RotoZoomTrans = cc.TransitionRotoZoom.create(2, nextScene); */ cc.TransitionRotoZoom.create = function (t, scene) { - var tempScene = new cc.TransitionRotoZoom(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionRotoZoom(t, scene); }; /** @@ -351,6 +364,15 @@ cc.TransitionRotoZoom.create = function (t, scene) { * @extends cc.TransitionScene */ cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZoom# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * Custom on enter */ @@ -388,11 +410,7 @@ cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZo * @return {cc.TransitionJumpZoom} */ cc.TransitionJumpZoom.create = function (t, scene) { - var tempScene = new cc.TransitionJumpZoom(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionJumpZoom(t, scene); }; /** @@ -401,7 +419,15 @@ cc.TransitionJumpZoom.create = function (t, scene) { * @extends cc.TransitionScene */ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL# */{ - + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * Custom on enter */ @@ -449,11 +475,7 @@ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL * var MoveInLeft = cc.TransitionMoveInL.create(1, nextScene) */ cc.TransitionMoveInL.create = function (t, scene) { - var tempScene = new cc.TransitionMoveInL(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionMoveInL(t, scene); }; /** @@ -462,6 +484,15 @@ cc.TransitionMoveInL.create = function (t, scene) { * @extends cc.TransitionMoveInL */ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInR# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionMoveInL.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * Init */ @@ -480,11 +511,7 @@ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI * var MoveInRight = cc.TransitionMoveInR.create(1, nextScene) */ cc.TransitionMoveInR.create = function (t, scene) { - var tempScene = new cc.TransitionMoveInR(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionMoveInR(t, scene); }; /** @@ -493,7 +520,15 @@ cc.TransitionMoveInR.create = function (t, scene) { * @extends cc.TransitionMoveInL */ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInT# */{ - + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionMoveInL.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * init */ @@ -512,11 +547,7 @@ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI * var MoveInTop = cc.TransitionMoveInT.create(1, nextScene) */ cc.TransitionMoveInT.create = function (t, scene) { - var tempScene = new cc.TransitionMoveInT(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionMoveInT(t, scene); }; /** @@ -525,6 +556,15 @@ cc.TransitionMoveInT.create = function (t, scene) { * @extends cc.TransitionMoveInL */ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInB# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionMoveInL.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * init @@ -544,11 +584,7 @@ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI * var MoveinB = cc.TransitionMoveInB.create(1, nextScene) */ cc.TransitionMoveInB.create = function (t, scene) { - var tempScene = new cc.TransitionMoveInB(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionMoveInB(t, scene); }; /** @@ -567,6 +603,15 @@ cc.ADJUST_FACTOR = 0.5; * @extends cc.TransitionScene */ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideInL# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, _sceneOrder:function () { this._isInSceneOnTop = false; }, @@ -620,11 +665,7 @@ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideI * var myTransition = cc.TransitionSlideInL.create(1.5, nextScene) */ cc.TransitionSlideInL.create = function (t, scene) { - var tempScene = new cc.TransitionSlideInL(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionSlideInL(t, scene); }; /** @@ -633,6 +674,15 @@ cc.TransitionSlideInL.create = function (t, scene) { * @extends cc.TransitionSlideInL */ cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInR# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionSlideInL.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, _sceneOrder:function () { this._isInSceneOnTop = true; }, @@ -661,11 +711,7 @@ cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * var myTransition = cc.TransitionSlideInR.create(1.5, nextScene) */ cc.TransitionSlideInR.create = function (t, scene) { - var tempScene = new cc.TransitionSlideInR(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionSlideInR(t, scene); }; /** @@ -674,6 +720,15 @@ cc.TransitionSlideInR.create = function (t, scene) { * @extends cc.TransitionSlideInL */ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInB# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionSlideInL.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, _sceneOrder:function () { this._isInSceneOnTop = false; }, @@ -704,11 +759,7 @@ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * var myTransition = cc.TransitionSlideInB.create(1.5, nextScene) */ cc.TransitionSlideInB.create = function (t, scene) { - var tempScene = new cc.TransitionSlideInB(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionSlideInB(t, scene); }; /** @@ -717,6 +768,15 @@ cc.TransitionSlideInB.create = function (t, scene) { * @extends cc.TransitionSlideInL */ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInT# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionSlideInL.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, _sceneOrder:function () { this._isInSceneOnTop = true; }, @@ -747,11 +807,7 @@ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * var myTransition = cc.TransitionSlideInT.create(1.5, nextScene) */ cc.TransitionSlideInT.create = function (t, scene) { - var tempScene = new cc.TransitionSlideInT(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionSlideInT(t, scene); }; /** @@ -760,7 +816,15 @@ cc.TransitionSlideInT.create = function (t, scene) { * @extends cc.TransitionScene */ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShrinkGrow# */{ - + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * Custom on enter */ @@ -806,11 +870,7 @@ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShri * var myTransition = cc.TransitionShrinkGrow.create(1.5, nextScene) */ cc.TransitionShrinkGrow.create = function (t, scene) { - var tempScene = new cc.TransitionShrinkGrow(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionShrinkGrow(t, scene); }; /** @@ -820,6 +880,17 @@ cc.TransitionShrinkGrow.create = function (t, scene) { * @extends cc.TransitionSceneOriented */ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipX# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + */ + ctor:function (t, scene, o) { + cc.TransitionSceneOriented.prototype.ctor.call(this); + o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + scene && this.initWithDuration(t, scene, o); + }, /** * custom on enter @@ -875,12 +946,7 @@ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF * var myTransition = cc.TransitionFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_UP_OVER) */ cc.TransitionFlipX.create = function (t, scene, o) { - if (o == null) - o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; - - var tempScene = new cc.TransitionFlipX(); - tempScene.initWithDuration(t, scene, o); - return tempScene; + return new cc.TransitionFlipX(t, scene, o); }; /** @@ -891,6 +957,17 @@ cc.TransitionFlipX.create = function (t, scene, o) { */ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipY# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + */ + ctor:function (t, scene, o) { + cc.TransitionSceneOriented.prototype.ctor.call(this); + o = o || cc.TRANSITION_ORIENTATION_UP_OVER; + scene && this.initWithDuration(t, scene, o); + }, /** * custom on enter */ @@ -944,13 +1021,7 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF * var myTransition = cc.TransitionFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_RIGHT_OVER) */ cc.TransitionFlipY.create = function (t, scene, o) { - if (o == null) - o = cc.TRANSITION_ORIENTATION_UP_OVER; - - var tempScene = new cc.TransitionFlipY(); - tempScene.initWithDuration(t, scene, o); - - return tempScene; + return new cc.TransitionFlipY(t, scene, o); }; /** @@ -960,6 +1031,18 @@ cc.TransitionFlipY.create = function (t, scene, o) { * @extends cc.TransitionSceneOriented */ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipAngular# */{ + + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + */ + ctor:function (t, scene, o) { + cc.TransitionSceneOriented.prototype.ctor.call(this); + o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + scene && this.initWithDuration(t, scene, o); + }, /** * custom on enter */ @@ -1013,13 +1096,7 @@ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.Trans * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionFlipAngular.create = function (t, scene, o) { - if (o == null) - o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; - - var tempScene = new cc.TransitionFlipAngular(); - tempScene.initWithDuration(t, scene, o); - - return tempScene; + return new cc.TransitionFlipAngular(t, scene, o); }; /** @@ -1030,6 +1107,17 @@ cc.TransitionFlipAngular.create = function (t, scene, o) { */ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipX# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + */ + ctor:function (t, scene, o) { + cc.TransitionSceneOriented.prototype.ctor.call(this); + o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + scene && this.initWithDuration(t, scene, o); + }, /** * custom on enter */ @@ -1089,13 +1177,7 @@ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.Transit * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionZoomFlipX.create = function (t, scene, o) { - if (o == null) - o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; - - var tempScene = new cc.TransitionZoomFlipX(); - tempScene.initWithDuration(t, scene, o); - - return tempScene; + return new cc.TransitionZoomFlipX(t, scene, o); }; /** @@ -1106,6 +1188,17 @@ cc.TransitionZoomFlipX.create = function (t, scene, o) { */ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipY# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + */ + ctor:function (t, scene, o) { + cc.TransitionSceneOriented.prototype.ctor.call(this); + o = o || cc.TRANSITION_ORIENTATION_UP_OVER; + scene && this.initWithDuration(t, scene, o); + }, /** * custom on enter */ @@ -1163,13 +1256,7 @@ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.Transit * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionZoomFlipY.create = function (t, scene, o) { - if (o == null) - o = cc.TRANSITION_ORIENTATION_UP_OVER; - - var tempScene = new cc.TransitionZoomFlipY(); - tempScene.initWithDuration(t, scene, o); - - return tempScene; + return new cc.TransitionZoomFlipY(t, scene, o); }; /** @@ -1180,6 +1267,17 @@ cc.TransitionZoomFlipY.create = function (t, scene, o) { */ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipAngular# */{ + /** + * @constuctor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + */ + ctor:function (t, scene, o) { + cc.TransitionSceneOriented.prototype.ctor.call(this); + o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + scene && this.initWithDuration(t, scene, o); + }, /** * custom on enter */ @@ -1236,13 +1334,7 @@ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.T * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionZoomFlipAngular.create = function (t, scene, o) { - if (o == null) - o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; - - var tempScene = new cc.TransitionZoomFlipAngular(); - tempScene.initWithDuration(t, scene, o); - - return tempScene; + return new cc.TransitionZoomFlipAngular(t, scene, o); }; /** @@ -1256,9 +1348,10 @@ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ /** * Constructor */ - ctor:function () { + ctor:function (t, scene, color) { cc.TransitionScene.prototype.ctor.call(this); this._color = cc.color() + scene && this.initWithDuration(t, scene, color); }, /** @@ -1321,9 +1414,7 @@ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ * var myTransition = cc.TransitionFade.create(1.5, nextScene, cc.color(255,0,0))//fade to red */ cc.TransitionFade.create = function (t, scene, color) { - var transition = new cc.TransitionFade(); - transition.initWithDuration(t, scene, color); - return transition; + return new cc.TransitionFade(t, scene, color); }; /** @@ -1332,6 +1423,15 @@ cc.TransitionFade.create = function (t, scene, color) { * @extends cc.TransitionScene */ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCrossFade# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * custom on enter */ @@ -1425,9 +1525,7 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross * var myTransition = cc.TransitionCrossFade.create(1.5, nextScene) */ cc.TransitionCrossFade.create = function (t, scene) { - var Transition = new cc.TransitionCrossFade(); - Transition.initWithDuration(t, scene); - return Transition; + return new cc.TransitionCrossFade(t, scene); }; /** @@ -1436,6 +1534,17 @@ cc.TransitionCrossFade.create = function (t, scene) { * @extends cc.TransitionScene */ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTurnOffTiles# */{ + + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _sceneOrder:function () { this._isInSceneOnTop = false; }, @@ -1473,11 +1582,7 @@ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTu * var myTransition = cc.TransitionTurnOffTiles.create(1.5, nextScene) */ cc.TransitionTurnOffTiles.create = function (t, scene) { - var tempScene = new cc.TransitionTurnOffTiles(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionTurnOffTiles(t, scene); }; /** @@ -1487,6 +1592,15 @@ cc.TransitionTurnOffTiles.create = function (t, scene) { */ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplitCols# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * custom on enter */ @@ -1529,11 +1643,7 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit * var myTransition = cc.TransitionSplitCols.create(1.5, nextScene) */ cc.TransitionSplitCols.create = function (t, scene) { - var tempScene = new cc.TransitionSplitCols(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionSplitCols(t, scene); }; /** @@ -1542,6 +1652,16 @@ cc.TransitionSplitCols.create = function (t, scene) { * @extends cc.TransitionSplitCols */ cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionSplitRows# */{ + + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionSplitCols.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, /** * @return {*} */ @@ -1560,11 +1680,7 @@ cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionS * var myTransition = cc.TransitionSplitRows.create(1.5, nextScene) */ cc.TransitionSplitRows.create = function (t, scene) { - var tempScene = new cc.TransitionSplitRows(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionSplitRows(t, scene); }; /** @@ -1573,6 +1689,16 @@ cc.TransitionSplitRows.create = function (t, scene) { * @extends cc.TransitionScene */ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */{ + + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, _sceneOrder:function () { this._isInSceneOnTop = false; }, @@ -1622,10 +1748,7 @@ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# * var myTransition = cc.TransitionFadeTR.create(1.5, nextScene) */ cc.TransitionFadeTR.create = function (t, scene) { - var tempScene = new cc.TransitionFadeTR(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) - return tempScene; - return null; + return new cc.TransitionFadeTR(t, scene); }; /** @@ -1635,6 +1758,16 @@ cc.TransitionFadeTR.create = function (t, scene) { */ cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# */{ + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionFadeTR.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + /** * @param {cc.Size} size * @return {*} @@ -1654,10 +1787,7 @@ cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# * var myTransition = cc.TransitionFadeBL.create(1.5, nextScene) */ cc.TransitionFadeBL.create = function (t, scene) { - var tempScene = new cc.TransitionFadeBL(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) - return tempScene; - return null; + return new cc.TransitionFadeBL(t, scene); }; /** @@ -1667,6 +1797,16 @@ cc.TransitionFadeBL.create = function (t, scene) { */ cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# */{ + /** + * @constuctor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionFadeTR.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + /** * @param {cc.Size} size * @return {*} @@ -1686,11 +1826,7 @@ cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# * var myTransition = cc.TransitionFadeUp.create(1.5, nextScene) */ cc.TransitionFadeUp.create = function (t, scene) { - var tempScene = new cc.TransitionFadeUp(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionFadeUp(t, scene); }; /** @@ -1700,6 +1836,16 @@ cc.TransitionFadeUp.create = function (t, scene) { */ cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeDown# */{ + /** + * @constuctor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionFadeTR.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + /** * @param {cc.Size} size * @return {*} @@ -1719,9 +1865,5 @@ cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeD * var myTransition = cc.TransitionFadeDown.create(1.5, nextScene) */ cc.TransitionFadeDown.create = function (t, scene) { - var tempScene = new cc.TransitionFadeDown(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionFadeDown(t, scene); }; From 8340ace681f64556d4f75e142248b46da5edede9 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 14 Jul 2014 11:43:28 +0800 Subject: [PATCH 0283/1564] issue #5685: refactor create and ctor functions of TransitionPageTrun & TransitionProgress --- cocos2d/transitions/CCTransitionPageTurn.js | 16 ++- cocos2d/transitions/CCTransitionProgress.js | 112 ++++++++++++++------ 2 files changed, 94 insertions(+), 34 deletions(-) diff --git a/cocos2d/transitions/CCTransitionPageTurn.js b/cocos2d/transitions/CCTransitionPageTurn.js index 739db6f3ca..3184248ab1 100644 --- a/cocos2d/transitions/CCTransitionPageTurn.js +++ b/cocos2d/transitions/CCTransitionPageTurn.js @@ -36,6 +36,18 @@ * @extends cc.TransitionScene */ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTurn# */{ + + /** + * @constructor + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {Boolean} backwards + */ + ctor:function (t, scene, backwards) { + cc.TransitionScene.prototype.ctor.call(this); + this.initWithDuration(t, scene, backwards); + }, + /** * @type Boolean */ @@ -118,7 +130,5 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu * var myTransition = cc.TransitionPageTurn.create(1.5, nextScene, true)//true means backwards */ cc.TransitionPageTurn.create = function (t, scene, backwards) { - var transition = new cc.TransitionPageTurn(); - transition.initWithDuration(t, scene, backwards); - return transition; + return new cc.TransitionPageTurn(t, scene, backwards); }; diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index acabedd4bc..60e9ca3fcc 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -42,6 +42,16 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre _sceneToBeModified:null, _className:"TransitionProgress", + /** + * @constructor + * @param {Number} t time + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionScene.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _setAttrs: function(node, x, y) { node.attr({ x: x, @@ -125,11 +135,7 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre * @return {cc.TransitionProgress} */ cc.TransitionProgress.create = function (t, scene) { - var tempScene = new cc.TransitionProgress(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionProgress(t, scene); }; /** @@ -139,6 +145,17 @@ cc.TransitionProgress.create = function (t, scene) { * @extends cc.TransitionProgress */ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressRadialCCW# */{ + + /** + * @constructor + * @param {Number} t time + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionProgress.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); @@ -166,11 +183,7 @@ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.Tran * @return {cc.TransitionProgressRadialCCW} */ cc.TransitionProgressRadialCCW.create = function (t, scene) { - var tempScene = new cc.TransitionProgressRadialCCW(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionProgressRadialCCW(t, scene); }; /** @@ -180,6 +193,16 @@ cc.TransitionProgressRadialCCW.create = function (t, scene) { * @extends cc.TransitionProgress */ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressRadialCW# */{ + /** + * @constructor + * @param {Number} t time + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionProgress.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); @@ -211,7 +234,7 @@ cc.TransitionProgressRadialCW.create = function (t, scene) { if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { return tempScene; } - return null; + return new cc.TransitionProgressRadialCW(t, scene); }; /** @@ -221,6 +244,16 @@ cc.TransitionProgressRadialCW.create = function (t, scene) { * @extends cc.TransitionProgress */ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressHorizontal# */{ + /** + * @constructor + * @param {Number} t time + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionProgress.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); @@ -249,11 +282,7 @@ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.Tra * @return {cc.TransitionProgressHorizontal} */ cc.TransitionProgressHorizontal.create = function (t, scene) { - var tempScene = new cc.TransitionProgressHorizontal(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionProgressHorizontal(t, scene); }; /** @@ -262,6 +291,17 @@ cc.TransitionProgressHorizontal.create = function (t, scene) { * @extends cc.TransitionProgress */ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressVertical# */{ + + /** + * @constructor + * @param {Number} t time + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionProgress.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); @@ -290,11 +330,7 @@ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.Trans * @return {cc.TransitionProgressVertical} */ cc.TransitionProgressVertical.create = function (t, scene) { - var tempScene = new cc.TransitionProgressVertical(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionProgressVertical(t, scene); }; /** @@ -303,6 +339,17 @@ cc.TransitionProgressVertical.create = function (t, scene) { * @extends cc.TransitionProgress */ cc.TransitionProgressInOut = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressInOut# */{ + + /** + * @constructor + * @param {Number} t time + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionProgress.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); var pNode = cc.ProgressTimer.create(texture.sprite); @@ -338,11 +385,7 @@ cc.TransitionProgressInOut = cc.TransitionProgress.extend(/** @lends cc.Transiti * @return {cc.TransitionProgressInOut} */ cc.TransitionProgressInOut.create = function (t, scene) { - var tempScene = new cc.TransitionProgressInOut(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionProgressInOut(t, scene); }; /** @@ -351,6 +394,17 @@ cc.TransitionProgressInOut.create = function (t, scene) { * @extends cc.TransitionProgress */ cc.TransitionProgressOutIn = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressOutIn# */{ + + /** + * @constructor + * @param {Number} t time + * @param {cc.Scene} scene + */ + ctor:function (t, scene) { + cc.TransitionProgress.prototype.ctor.call(this); + scene && this.initWithDuration(t, scene); + }, + _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); var pNode = cc.ProgressTimer.create(texture.sprite); @@ -378,9 +432,5 @@ cc.TransitionProgressOutIn = cc.TransitionProgress.extend(/** @lends cc.Transiti * @return {cc.TransitionProgressOutIn} */ cc.TransitionProgressOutIn.create = function (t, scene) { - var tempScene = new cc.TransitionProgressOutIn(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { - return tempScene; - } - return null; + return new cc.TransitionProgressOutIn(t, scene); }; From 8b72021e23b069cd5256564b03cfee2a76f7dc24 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 14 Jul 2014 11:53:57 +0800 Subject: [PATCH 0284/1564] issue #5685: delete TransitionEaseScene --- cocos2d/transitions/CCTransition.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 59e956443c..2056ca4f8b 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -30,19 +30,6 @@ */ cc.SCENE_FADE = 4208917214; -/** - * cc.TransitionEaseScene can ease the actions of the scene protocol. - * @class - * @extends cc.Class - */ -cc.TransitionEaseScene = cc.Class.extend(/** @lends cc.TransitionEaseScene# */{ - /** - * returns the Ease action that will be performed on a linear action. - */ - easeActionWithAction:function () { - } -}); - /** * horizontal orientation Type where the Left is nearer * @constant From 0edd8a29b7eeeb90ec95d4a39bb9805753a517f4 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 14 Jul 2014 13:42:34 +0800 Subject: [PATCH 0285/1564] issue #5685: fix TransitionSceneOriented ctor bug --- cocos2d/transitions/CCTransition.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 2056ca4f8b..4a2a14fb8a 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -255,7 +255,7 @@ cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionS */ ctor:function (t, scene, orientation) { cc.TransitionScene.prototype.ctor.call(this); - orientation && this.initWithDuration(t, scene, orientation); + orientation != undefined && this.initWithDuration(t, scene, orientation); }, /** * initialize the transition From 42d1876f47f72a3065a5d5222a91073e985615cf Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 14 Jul 2014 14:20:16 +0800 Subject: [PATCH 0286/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Fix bug --- extensions/cocostudio/armature/CCArmature.js | 59 ++--- .../armature/animation/CCArmatureAnimation.js | 2 +- .../cocostudio/armature/display/CCSkin.js | 2 +- .../armature/utils/CCArmatureDataManager.js | 8 +- .../armature/utils/CCDataReaderHelper.js | 208 ++++++++++++++---- 5 files changed, 199 insertions(+), 80 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 85fdef326c..591cae8bfa 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -219,7 +219,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ addBone: function (bone, parentName) { cc.assert(bone, "Argument must be non-nil"); - cc.assert(bone.getName() && !this._boneDic[bone.getName()], "bone already added. It can't be added again"); + if(bone.getName()) + cc.assert(!this._boneDic[bone.getName()], "bone already added. It can't be added again"); if (parentName) { var boneParent = this._boneDic[parentName]; @@ -304,7 +305,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (this._transformDirty) this._armatureTransformDirty = true; - return ccs.Node.prototype.getNodeToParentTransform.call(this); + return ccs.Node.prototype.nodeToParentTransform.call(this); }, /** @@ -312,7 +313,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ */ updateOffsetPoint: function () { // Set contentsize and Calculate anchor point. - var rect = this.boundingBox(); + var rect = this.getBoundingBox(); this.setContentSize(rect); var locOffsetPoint = this._offsetPoint; locOffsetPoint.x = -rect.x; @@ -441,32 +442,32 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.unscheduleUpdate(); }, - visit: function(renderer, parentTransform, parentFlags){ - //quick return if not visible. children won't be drawn. - if (!this._visible) - { - return; - } - -// var flags = this.processParentFlags(parentTransform, parentFlags); - - // IMPORTANT: - // To ease the migration to v3.0, we still support the Mat4 stack, - // but it is deprecated and your code should not rely on it - var director = cc.director; - cc.assert(null != director, "Director is null when seting matrix stack"); - director.pushMatrix(0); - director.loadMatrix(1, this._modelViewTransform); - - - this.sortAllChildren(); - this.draw(renderer, this._modelViewTransform, flags); - - // reset for next frame - this._orderOfArrival = 0; - - director.popMatrix(0); - }, +// visit: function(renderer, parentTransform, parentFlags){ +// //quick return if not visible. children won't be drawn. +// if (!this._visible) +// { +// return; +// } +// +//// var flags = this.processParentFlags(parentTransform, parentFlags); +// +// // IMPORTANT: +// // To ease the migration to v3.0, we still support the Mat4 stack, +// // but it is deprecated and your code should not rely on it +// var director = cc.director; +// cc.assert(null != director, "Director is null when seting matrix stack"); +// director.pushMatrix(0); +// director.loadMatrix(1, this._modelViewTransform); +// +// +// this.sortAllChildren(); +// this.draw(renderer, this._modelViewTransform, flags); +// +// // reset for next frame +// this._orderOfArrival = 0; +// +// director.popMatrix(0); +// }, getBoundingBox: function(){ var minx, miny, maxx, maxy = 0; diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 980697e3d0..b642c5c352 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -391,7 +391,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# // } // var animationName = moveNames[animationIndex]; // this.play(animationName, durationTo, loop, 0); - var movName = this._animationData.movementNames; + var movName = this.animationData.movementNames; cc.assert((animationIndex > -1) && (animationIndex < movName.length)); var animationName = movName[animationIndex]; diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 845d0cfdcb..1e49cc5788 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -99,7 +99,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, updateArmatureTransform: function () { - this._transform = cc.affineTransformConcat(this._skinTransform, this.bone.nodeToArmatureTransform()); + this._transform = cc.affineTransformConcat(this.bone.getNodeToArmatureTransform(), this._skinTransform); var locTransform = this._transform; var locArmature = this._armature; if (locArmature && locArmature.getBatchNode()) { diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index d16334c968..3ba84b45da 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -233,7 +233,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ this.addRelativeData(configFilePath); this._autoLoadSpriteFile = true; - ccs.DataReaderHelper.addDataFromFile(configFilePath); + ccs.dataReaderHelper.addDataFromFile(configFilePath); break; case 3: imagePath = arguments[0]; @@ -243,7 +243,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ this.addRelativeData(configFilePath); this._autoLoadSpriteFile = false; - ccs.DataReaderHelper.addDataFromFile(configFilePath); + ccs.dataReaderHelper.addDataFromFile(configFilePath); this.addSpriteFrameFromFile(plistPath, imagePath); } }, @@ -286,7 +286,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ this.addRelativeData(configFilePath); this._autoLoadSpriteFile = true; - ccs.DataReaderHelper.addDataFromFileAsync("", "", configFilePath, target, selector); + ccs.dataReaderHelper.addDataFromFileAsync("", "", configFilePath, target, selector); break; case 5: imagePath = arguments[0]; @@ -298,7 +298,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ this.addRelativeData(configFilePath); this._autoLoadSpriteFile = false; - ccs.DataReaderHelper.addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector); + ccs.dataReaderHelper.addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector); this.addSpriteFrameFromFile(plistPath, imagePath); } diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index be516741f0..63659c5fff 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -143,6 +143,13 @@ ccs.DataInfo = function () { * @name ccs.dataReaderHelper */ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ + + ConfigType: { + DragonBone_XML: 0, + CocoStudio_JSON: 1, + CocoStudio_Binary: 2 + }, + _configFileList: [], _flashToolVersion: ccs.CONST_VERSION_2_0, _cocoStudioVersion: ccs.CONST_VERSION_COMBINED, @@ -150,6 +157,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ _asyncRefCount: 0, _asyncRefTotalCount: 0, + _dataQueue: null, + //LoadData don't need setPositionReadScale: function (scale) { @@ -160,13 +169,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return this._positionReadScale; }, - clear: function () { - this._configFileList = []; - this._asyncRefCount = 0; - this._asyncRefTotalCount = 0; - }, - - addDataFromFile: function (filePath, isLoadSpriteFrame) { + addDataFromFile: function (filePath) { /* * Check if file is already added to ArmatureDataManager, if then return. @@ -176,23 +179,34 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } this._configFileList.push(filePath); - this._initBaseFilePath(filePath); + //! find the base file path + var basefilePath = this._initBaseFilePath(filePath); + + // Read content from file + // Here the reader into the next process var str = cc.path.extname(filePath).toLowerCase(); var dataInfo = new ccs.DataInfo(); dataInfo.filename = filePath; - dataInfo.basefilePath = this._initBaseFilePath(filePath); + dataInfo.basefilePath = basefilePath; if (str == ".xml") { - this.addDataFromXML(filePath, dataInfo); + ccs.dataReaderHelper.addDataFromXML(filePath, dataInfo); } else if (str == ".json" || str == ".exportjson") { - this.addDataFromJson(filePath, dataInfo, isLoadSpriteFrame); + ccs.dataReaderHelper.addDataFromJson(filePath, dataInfo); + } + else if(str == ".csb"){ + ccs.dataReaderHelper.addDataFromBinaryCache(filePath, dataInfo); } }, - addDataFromFileAsync: function (filePath, target, selector, isLoadSpriteFrame) { + addDataFromFileAsync: function (imagePath, plistPath, filePath, target, selector) { + //TODO + /* + * Check if file is already added to ArmatureDataManager, if then return. + */ if (this._configFileList.indexOf(filePath) != -1) { if (target && selector) { if (this._asyncRefTotalCount == 0 && this._asyncRefCount == 0) @@ -202,17 +216,145 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } return; } + this._configFileList.push(filePath); + + //! find the base file path +// var basefilePath = this._initBaseFilePath(filePath); + this._asyncRefTotalCount++; this._asyncRefCount++; var self = this; var fun = function () { - self.addDataFromFile(filePath, isLoadSpriteFrame); + self.addDataFromFile(filePath); self._asyncRefCount--; self._asyncCallBack(target, selector, (self._asyncRefTotalCount - self._asyncRefCount) / self._asyncRefTotalCount); }; cc.director.getScheduler().scheduleCallbackForTarget(this, fun, 0.1, false); }, + /* + addDataAsyncCallBack: function(dt){ + //TODO + // the data is generated in loading thread + var dataQueue = this._dataQueue; + + _dataInfoMutex.lock(); + if (dataQueue->empty()) + { + _dataInfoMutex.unlock(); + } + else + { + DataInfo *pDataInfo = dataQueue->front(); + dataQueue->pop(); + _dataInfoMutex.unlock(); + + AsyncStruct *pAsyncStruct = pDataInfo->asyncStruct; + + + if (pAsyncStruct->imagePath != "" && pAsyncStruct->plistPath != "") + { + _getFileMutex.lock(); + ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str(), pDataInfo->filename.c_str()); + _getFileMutex.unlock(); + } + + while (!pDataInfo->configFileQueue.empty()) + { + std::string configPath = pDataInfo->configFileQueue.front(); + _getFileMutex.lock(); + ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str(),pDataInfo->filename.c_str()); + _getFileMutex.unlock(); + pDataInfo->configFileQueue.pop(); + } + + + Ref* target = pAsyncStruct->target; + SEL_SCHEDULE selector = pAsyncStruct->selector; + + --_asyncRefCount; + + if (target && selector) + { + (target->*selector)((_asyncRefTotalCount - _asyncRefCount) / (float)_asyncRefTotalCount); + target->release(); + } + + + delete pAsyncStruct; + delete pDataInfo; + + if (0 == _asyncRefCount) + { + _asyncRefTotalCount = 0; + Director::getInstance()->getScheduler()->unschedule(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this); + } + } + }, + */ + + removeConfigFile: function (configFile) { +// cc.arrayRemoveObject(this._configFileList, configFile); + var len = this._configFileList.length; + var it = this._configFileList[len]; + for (var i = 0;i " + ccs.CONST_ARMATURES + " > " + ccs.CONST_ARMATURE + ""); + var armatureDataManager = ccs.armatureDataManager; + for (var i = 0; i < armaturesXML.length; i++) { + var armatureData = this.decodeArmature(armaturesXML[i], dataInfo); + armatureDataManager.addArmatureData(armatureData.name, armatureData, dataInfo.filename); + } + + var animationsXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_ANIMATIONS + " > " + ccs.CONST_ANIMATION + ""); + for (var i = 0; i < animationsXML.length; i++) { + var animationData = this.decodeAnimation(animationsXML[i], dataInfo); + armatureDataManager.addAnimationData(animationData.name, animationData, dataInfo.filename); + } + + var texturesXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_TEXTURE_ATLAS + " > " + ccs.CONST_SUB_TEXTURE + ""); + for (var i = 0; i < texturesXML.length; i++) { + var textureData = this.decodeTexture(texturesXML[i], dataInfo); + armatureDataManager.addTextureData(textureData.name, textureData, dataInfo.filename); + } + skeleton = null; + }, + + + + + + + + + + + clear: function () { + this._configFileList = []; + this._asyncRefCount = 0; + this._asyncRefTotalCount = 0; + }, + _asyncCallBack: function (target, selector, percent) { if (target && (typeof(selector) == "string")) { target[selector](percent); @@ -249,33 +391,6 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } }, - addDataFromCache: function (skeleton, dataInfo) { - if (!skeleton) { - cc.log("XML error or XML is empty."); - return; - } - dataInfo.flashToolVersion = parseFloat(skeleton.getAttribute(ccs.CONST_VERSION)); - var armaturesXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_ARMATURES + " > " + ccs.CONST_ARMATURE + ""); - var armatureDataManager = ccs.armatureDataManager; - for (var i = 0; i < armaturesXML.length; i++) { - var armatureData = this.decodeArmature(armaturesXML[i], dataInfo); - armatureDataManager.addArmatureData(armatureData.name, armatureData, dataInfo.filename); - } - - var animationsXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_ANIMATIONS + " > " + ccs.CONST_ANIMATION + ""); - for (var i = 0; i < animationsXML.length; i++) { - var animationData = this.decodeAnimation(animationsXML[i], dataInfo); - armatureDataManager.addAnimationData(animationData.name, animationData, dataInfo.filename); - } - - var texturesXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_TEXTURE_ATLAS + " > " + ccs.CONST_SUB_TEXTURE + ""); - for (var i = 0; i < texturesXML.length; i++) { - var textureData = this.decodeTexture(texturesXML[i], dataInfo); - armatureDataManager.addTextureData(textureData.name, textureData, dataInfo.filename); - } - skeleton = null; - }, - decodeArmature: function (armatureXML, dataInfo) { var name = armatureXML.getAttribute(ccs.CONST_A_NAME); var armatureData = new ccs.ArmatureData(); @@ -674,6 +789,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, addDataFromJsonCache: function (dic, dataInfo, isLoadSpriteFrame) { dataInfo.contentScale = dic[ccs.CONST_CONTENT_SCALE] || 1; + + // Decode armatures var armatureDataArr = dic[ccs.CONST_ARMATURE_DATA] || []; var armatureData; for (var i = 0; i < armatureDataArr.length; i++) { @@ -681,6 +798,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ ccs.armatureDataManager.addArmatureData(armatureData.name, armatureData, dataInfo.filename); } + // Decode animations var animationDataArr = dic[ccs.CONST_ANIMATION_DATA] || []; var animationData; for (var i = 0; i < animationDataArr.length; i++) { @@ -688,6 +806,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ ccs.armatureDataManager.addAnimationData(animationData.name, animationData, dataInfo.filename); } + // Decode textures var textureDataArr = dic[ccs.CONST_TEXTURE_DATA] || []; var textureData; for (var i = 0; i < textureDataArr.length; i++) { @@ -695,7 +814,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ ccs.armatureDataManager.addTextureData(textureData.name, textureData, dataInfo.filename); } - if (isLoadSpriteFrame) { + // Auto load sprite file + var autoLoad = dataInfo.asyncStruct == null ? ccs.armatureDataManager.isAutoLoadSpriteFile() : dataInfo.asyncStruct.autoLoadSpriteFile; +// if (isLoadSpriteFrame) { + if (autoLoad) { var configFiles = dic[ccs.CONST_CONFIG_FILE_PATH] || []; var locFilePath, locPos, locPlistPath, locImagePath; for (var i = 0; i < configFiles.length; i++) { @@ -959,9 +1081,5 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ node.isUseColorInfo = true; delete colorDic; } - }, - - removeConfigFile: function (configFile) { - cc.arrayRemoveObject(this._configFileList, configFile); } }; \ No newline at end of file From 8bd70598a018ea2419ab748f13c3205ff39e0699 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 14 Jul 2014 15:26:30 +0800 Subject: [PATCH 0287/1564] Issue #5704: fixed a typo of ccui.Widget that rename _hitted to _hit --- extensions/ccui/base-classes/CCProtectedNode.js | 17 ++++++++--------- extensions/ccui/base-classes/UIWidget.js | 8 ++++---- extensions/ccui/uiwidgets/UISlider.js | 2 +- extensions/ccui/uiwidgets/UITextField.js | 2 +- .../ccui/uiwidgets/scroll-widget/UIPageView.js | 2 +- .../uiwidgets/scroll-widget/UIScrollView.js | 2 +- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index fe99f82b76..639ea1ee72 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -22,7 +22,12 @@ THE SOFTWARE. ****************************************************************************/ -cc.ProtectedNode = cc.Node.extend({ +/** + * A class inhert from cc.Node, use for saving some protected children in other list. + * @class + * @extends cc.Node + */ +cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ _protectedChildren: null, _reorderProtectedChildDirty: false, @@ -57,7 +62,6 @@ cc.ProtectedNode = cc.Node.extend({ child.setOrderOfArrival(cc.s_globalOrderOfArrival); //TODO USE PHYSICS - if(this._running){ child.onEnter(); // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter @@ -161,7 +165,6 @@ cc.ProtectedNode = cc.Node.extend({ } //TODO USE PHYSICS - if (cleanup) child.cleanup(); // set parent nil at the end @@ -306,14 +309,10 @@ cc.ProtectedNode = cc.Node.extend({ _t.draw(context); // draw children zOrder >= 0 for (; i < childLen; i++) { - if (locChildren[i]) { - locChildren[i].visit(); - } + locChildren[i] && locChildren[i].visit(); } for (; j < pLen; j++) { - if (locProtectedChildren[j]) { - locProtectedChildren[j].visit(); - } + locProtectedChildren[j] && locProtectedChildren[j].visit(); } _t.arrivalOrder = 0; diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index b782a84a06..e20b76c800 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -80,7 +80,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ positionType: null, _positionPercent: null, _reorderWidgetChildDirty: false, - _hitted: false, //TODO typo + _hit: false, _nodes: null, _touchListener: null, _color: null, @@ -911,15 +911,15 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, onTouchBegan: function (touch, event) { - this._hitted = false; + this._hit = false; if (this.isVisible() && this.isEnabled() && this._isAncestorsEnabled() && this._isAncestorsVisible(this) ){ var touchPoint = touch.getLocation(); this._touchBeganPosition.x = touchPoint.x; this._touchBeganPosition.y = touchPoint.y; if(this.hitTest(this._touchBeganPosition) && this.isClippingParentContainsPoint(this._touchBeganPosition)) - this._hitted = true; + this._hit = true; } - if (!this._hitted) { + if (!this._hit) { return false; } this.setHighlighted(true); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 33d792b69b..48af874135 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -437,7 +437,7 @@ 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) { + if (this._hit) { var nsp = this.convertToNodeSpace(this._touchBeganPosition); this.setPercent(this.getPercentWithBallPos(nsp.x)); this.percentChangedEvent(); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 3077cac765..d40f52ac19 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -482,7 +482,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ onTouchBegan: function (touchPoint, unusedEvent) { var self = this; var pass = ccui.Widget.prototype.onTouchBegan.call(self, touchPoint, unusedEvent); - if (self._hitted) + if (self._hit) { setTimeout(function(){ self._textFieldRender.attachWithIME(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 5e23da9f63..d16026de26 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -311,7 +311,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ onTouchBegan: function (touch,event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); - if (this._hitted) + if (this._hit) this.handlePressLogic(touch); return pass; }, diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index ae7a8fae35..1f09896509 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1432,7 +1432,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ onTouchBegan: function (touch, event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); - if (this._hitted) + if (this._hit) this.handlePressLogic(touch); return pass; }, From 5317b1db351848bee53d48a891a929f06e11bbce Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 14 Jul 2014 18:09:47 +0800 Subject: [PATCH 0288/1564] issue #5685: fix FadeIn & FadeOut bugs --- cocos2d/actions/CCActionInterval.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 025fbaa4a6..0e21da60c0 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2277,6 +2277,16 @@ cc.FadeTo.create = function (duration, opacity) { */ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ _reverseAction: null, + + /** + * @constructor + * @param {Number} duration duration in seconds + */ + ctor:function (duration) { + cc.FadeTo.prototype.ctor.call(this); + duration && this.initWithDuration(duration, 255); + }, + /** * @return {cc.ActionInterval} */ @@ -2317,7 +2327,7 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ * var action = cc.FadeIn.create(1.0); */ cc.FadeIn.create = function (duration) { - return new cc.FadeIn(duration, 255); + return new cc.FadeIn(duration); }; @@ -2327,6 +2337,16 @@ cc.FadeIn.create = function (duration) { * @extends cc.FadeTo */ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ + + /** + * @constructor + * @param {Number} duration duration in seconds + */ + ctor:function (duration) { + cc.FadeTo.prototype.ctor.call(this); + duration && this.initWithDuration(duration, 0); + }, + /** * @return {cc.ActionInterval} */ @@ -2359,7 +2379,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ * var action = cc.FadeOut.create(1.0); */ cc.FadeOut.create = function (d) { - return new cc.FadeOut(d, 0); + return new cc.FadeOut(d); }; /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. From 09985e81ac0451bf5e0ca70dff555defbe9a291b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 14 Jul 2014 18:23:07 +0800 Subject: [PATCH 0289/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Fix render bug --- extensions/cocostudio/armature/CCArmature.js | 58 ++--- extensions/cocostudio/armature/CCBone.js | 241 +++++++++--------- .../armature/display/CCDisplayManager.js | 5 +- .../armature/utils/CCDataReaderHelper.js | 220 ++++++++-------- 4 files changed, 264 insertions(+), 260 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 591cae8bfa..02d766bbd2 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -118,7 +118,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (name != "") { //animationData animationData = armatureDataManager.getAnimationData(name); - cc.assert(animationData, "AnimationData not exist!"); this.animation.setAnimationData(animationData); @@ -196,7 +195,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var bone = null; - if (parentName != "") { + if (parentName) { this.createBone(parentName); bone = ccs.Bone.create(boneName); this.addBone(bone, parentName); @@ -442,32 +441,32 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.unscheduleUpdate(); }, -// visit: function(renderer, parentTransform, parentFlags){ -// //quick return if not visible. children won't be drawn. -// if (!this._visible) -// { -// return; -// } -// -//// var flags = this.processParentFlags(parentTransform, parentFlags); -// -// // IMPORTANT: -// // To ease the migration to v3.0, we still support the Mat4 stack, -// // but it is deprecated and your code should not rely on it + visit: function(renderer, parentTransform, parentFlags){ + //quick return if not visible. children won't be drawn. + if (!this._visible) + { + return; + } + +// var flags = this.processParentFlags(parentTransform, parentFlags); + + // IMPORTANT: + // To ease the migration to v3.0, we still support the Mat4 stack, + // but it is deprecated and your code should not rely on it // var director = cc.director; // cc.assert(null != director, "Director is null when seting matrix stack"); // director.pushMatrix(0); // director.loadMatrix(1, this._modelViewTransform); -// -// -// this.sortAllChildren(); -// this.draw(renderer, this._modelViewTransform, flags); -// -// // reset for next frame -// this._orderOfArrival = 0; -// + + + this.sortAllChildren(); + this.draw(renderer, this._modelViewTransform); + + // reset for next frame + this._orderOfArrival = 0; + // director.popMatrix(0); -// }, + }, getBoundingBox: function(){ var minx, miny, maxx, maxy = 0; @@ -507,7 +506,10 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ boundingBox.y + boundingBox.height; } - boundingBox.setRect(minx, miny, maxx - minx, maxy - miny); + boundingBox.x = minx; + boundingBox.y = miny; + boundingBox.width = maxx - minx; + boundingBox.height = maxy - miny; } } @@ -695,14 +697,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.version = version; } - - - - - - - - // _nodeToParentTransformForWebGL: function () { // if (this._transformDirty) { // this._armatureTransformDirty = true; diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index eaf3ad0e8b..5cfa86902e 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -602,135 +602,130 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ getWorldInfo: function(){ return this._worldInfo; - } + }, + /** + * release objects + */ + release: function () { + CC_SAFE_RELEASE(this._tweenData); + for (var i = 0; i < this._childrenBone.length; i++) { + CC_SAFE_RELEASE(this._childrenBone[i]); + } + this._childrenBone = []; + CC_SAFE_RELEASE(this._tween); + CC_SAFE_RELEASE(this.displayManager); + CC_SAFE_RELEASE(this._boneData); + CC_SAFE_RELEASE(this._childArmature); + }, + /** + * Rewrite visit ,when node draw, g_NumberOfDraws is changeless + */ + visit: function (ctx) { + // quick return if not visible + if (!this._visible) + return; + var node = this.getDisplayManager().getDisplayRenderNode(); + if (node) { + node.visit(ctx); + } + }, + + /** + * set display color + * @param {cc.Color} color + */ + setColor: function (color) { + cc.Node.prototype.setColor.call(this, color); + this.updateColor(); + }, + /** + * set display opacity + * @param {Number} opacity 0-255 + */ + setOpacity: function (opacity) { + cc.Node.prototype.setOpacity.call(this, opacity); + this.updateColor(); + }, + /** + * child bone getter + * @return {Array} + */ + getChildrenBone: function () { + return this._childrenBone; + }, -// /** -// * release objects -// */ -// release: function () { -// CC_SAFE_RELEASE(this._tweenData); -// for (var i = 0; i < this._childrenBone.length; i++) { -// CC_SAFE_RELEASE(this._childrenBone[i]); -// } -// this._childrenBone = []; -// CC_SAFE_RELEASE(this._tween); -// CC_SAFE_RELEASE(this.displayManager); -// CC_SAFE_RELEASE(this._boneData); -// CC_SAFE_RELEASE(this._childArmature); -// }, -// -// /** -// * Rewrite visit ,when node draw, g_NumberOfDraws is changeless -// */ -// visit: function (ctx) { -// // quick return if not visible -// if (!this._visible) -// return; -// -// var node = this.getDisplayManager().getDisplayRenderNode(); -// if (node) { -// node.visit(ctx); -// } -// }, -// -// /** -// * set display color -// * @param {cc.Color} color -// */ -// setColor: function (color) { -// cc.Node.prototype.setColor.call(this, color); -// this.updateColor(); -// }, -// -// /** -// * set display opacity -// * @param {Number} opacity 0-255 -// */ -// setOpacity: function (opacity) { -// cc.Node.prototype.setOpacity.call(this, opacity); -// this.updateColor(); -// }, -// -// /** -// * child bone getter -// * @return {Array} -// */ -// getChildrenBone: function () { -// return this._childrenBone; -// }, -// -// /** -// * return world transform -// * @return {{a:0.b:0,c:0,d:0,tx:0,ty:0}} -// */ -// nodeToArmatureTransform: function () { -// return this._worldTransform; -// }, -// -// /** -// * Returns the world affine transform matrix. The matrix is in Pixels. -// * @returns {cc.AffineTransform} -// */ -// nodeToWorldTransform: function () { -// return cc.affineTransformConcat(this._worldTransform, this._armature.nodeToWorldTransform()); -// }, -// -// addSkin: function (skin, index) { -// index = index || 0; -// return this.displayManager.addSkin(skin, index); -// }, -// -// /** -// * get the collider body list in this bone. -// * @returns {*} -// */ -// getColliderBodyList: function () { -// var decoDisplay = this.displayManager.getCurrentDecorativeDisplay() -// if (decoDisplay) { -// var detector = decoDisplay.getColliderDetector() -// if (detector) { -// return detector.getColliderBodyList(); -// } -// } -// return []; -// }, -// -// /** -// * displayManager setter -// * @param {ccs.DisplayManager} -// */ -// setDisplayManager: function (displayManager) { -// this.displayManager = displayManager; -// }, -// -// /** -// * ignoreMovementBoneData getter -// * @return {Boolean} -// */ -// getIgnoreMovementBoneData: function () { -// return this.ignoreMovementBoneData; -// }, -// -// /** -// * name setter -// * @param {String} name -// */ -// setName: function (name) { -// this.name = name; -// }, -// -// /** -// * name getter -// * @return {String} -// */ -// getName: function () { -// return this.name; -// } + /** + * return world transform + * @return {{a:0.b:0,c:0,d:0,tx:0,ty:0}} + */ + nodeToArmatureTransform: function () { + return this._worldTransform; + }, + + /** + * Returns the world affine transform matrix. The matrix is in Pixels. + * @returns {cc.AffineTransform} + */ + nodeToWorldTransform: function () { + return cc.affineTransformConcat(this._worldTransform, this._armature.nodeToWorldTransform()); + }, + + addSkin: function (skin, index) { + index = index || 0; + return this.displayManager.addSkin(skin, index); + }, + + /** + * get the collider body list in this bone. + * @returns {*} + */ + getColliderBodyList: function () { + var decoDisplay = this.displayManager.getCurrentDecorativeDisplay() + if (decoDisplay) { + var detector = decoDisplay.getColliderDetector() + if (detector) { + return detector.getColliderBodyList(); + } + } + return []; + }, + + /** + * displayManager setter + * @param {ccs.DisplayManager} + */ + setDisplayManager: function (displayManager) { + this.displayManager = displayManager; + }, + + /** + * ignoreMovementBoneData getter + * @return {Boolean} + */ + getIgnoreMovementBoneData: function () { + return this.ignoreMovementBoneData; + }, + + /** + * name setter + * @param {String} name + */ + setName: function (name) { + this.name = name; + }, + + /** + * name getter + * @return {String} + */ + getName: function () { + return this.name; + } }); var _p = ccs.Bone.prototype; diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 2d4861308e..50a2dab2e2 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -32,7 +32,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ _decoDisplayList:null, _currentDecoDisplay:null, _displayRenderNode:null, - _displayIndex:-1, + _displayIndex: null, _forceChangeDisplay:false, _bone:null, _visible:true, @@ -42,7 +42,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this._decoDisplayList = []; this._currentDecoDisplay = null; this._displayRenderNode = null; - this._displayIndex = -1; + this._displayIndex = null; this._forceChangeDisplay = false; this._bone = null; this._visible = true; @@ -181,6 +181,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this._decoDisplayList.splice(index, 1); if (index === this._displayIndex) { this.setCurrentDecorativeDisplay(null); + this._displayIndex = -1; } }, diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 63659c5fff..a787a73f90 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -340,60 +340,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ skeleton = null; }, - - - - - - - - - - clear: function () { - this._configFileList = []; - this._asyncRefCount = 0; - this._asyncRefTotalCount = 0; - }, - - _asyncCallBack: function (target, selector, percent) { - if (target && (typeof(selector) == "string")) { - target[selector](percent); - } else if (target && (typeof(selector) == "function")) { - selector.call(target, percent); - } - }, - /** - * find the base file path - * @param filePath - * @returns {String} - * @private - */ - _initBaseFilePath: function (filePath) { - var path = filePath; - var pos = path.lastIndexOf("/"); - if (pos > -1) - path = path.substr(0, pos + 1); - else - path = ""; - return path; - }, - - addDataFromXML: function (xml, dataInfo) { - /* - * Need to get the full path of the xml file, or the Tiny XML can't find the xml at IOS - */ - var xmlStr = cc.loader.getRes(xml); - if (!xmlStr) throw "Please load the resource first : " + xml; - var skeletonXML = cc.saxParser.parse(xmlStr); - var skeleton = skeletonXML.documentElement; - if (skeleton) { - this.addDataFromCache(skeleton, dataInfo); - } - }, - decodeArmature: function (armatureXML, dataInfo) { - var name = armatureXML.getAttribute(ccs.CONST_A_NAME); var armatureData = new ccs.ArmatureData(); + armatureData.init(); + + var name = armatureXML.getAttribute(ccs.CONST_A_NAME); armatureData.name = name; var bonesXML = armatureXML.querySelectorAll(ccs.CONST_ARMATURE + " > " + ccs.CONST_BONE); @@ -418,6 +369,23 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return armatureData; }, + decodeArmatureFromJSON: function (json, dataInfo) { + var armatureData = new ccs.ArmatureData(); + + var name = json[ccs.CONST_A_NAME]; + if (name) { + armatureData.name = name; + } + + dataInfo.cocoStudioVersion = armatureData.dataVersion = json[ccs.CONST_VERSION] || 0.1; + + var boneDataList = json[ccs.CONST_BONE_DATA]; + for (var i = 0; i < boneDataList.length; i++) { + armatureData.addBoneData(this.decodeBoneFromJson(boneDataList[i], dataInfo)); + } + return armatureData; + }, + decodeBone: function (boneXML, parentXML, dataInfo) { var name = boneXML.getAttribute(ccs.CONST_A_NAME); @@ -439,6 +407,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } return boneData; }, + decodeBoneDisplay: function (displayXML, dataInfo) { var isArmature = parseFloat(displayXML.getAttribute(ccs.CONST_A_IS_ARMATURE)) || 0; var displayData = null; @@ -458,15 +427,18 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return displayData; }, - decodeAnimation: function (animationXML, dataInfo) { - var name = animationXML.getAttribute(ccs.CONST_A_NAME); var aniData = new ccs.AnimationData(); + + var name = animationXML.getAttribute(ccs.CONST_A_NAME); + var armatureData = ccs.armatureDataManager.getArmatureData(name); + aniData.name = name; var movementsXML = animationXML.querySelectorAll(ccs.CONST_ANIMATION + " > " + ccs.CONST_MOVEMENT); var movementXML = null; + for (var i = 0; i < movementsXML.length; i++) { movementXML = movementsXML[i]; var movementData = this.decodeMovement(movementXML, armatureData, dataInfo); @@ -476,10 +448,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, decodeMovement: function (movementXML, armatureData, dataInfo) { - var movName = movementXML.getAttribute(ccs.CONST_A_NAME); var movementData = new ccs.MovementData(); + + var movName = movementXML.getAttribute(ccs.CONST_A_NAME); movementData.name = movName; - var duration, durationTo, durationTween, loop = 0, tweenEasing = 0; + + var duration, durationTo, durationTween, loop, tweenEasing = 0; duration = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION)) || 0; movementData.duration = duration; @@ -533,6 +507,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ decodeMovementBone: function (movBoneXml, parentXml, boneData, dataInfo) { var movBoneData = new ccs.MovementBoneData(); + movBoneData.init(); + var scale, delay; if (movBoneXml) { @@ -565,8 +541,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var totalDuration = 0; var name = movBoneXml.getAttribute(ccs.CONST_A_NAME); + movBoneData.name = name; + var framesXML = movBoneXml.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_FRAME); + var j = 0; for (var ii = 0; ii < framesXML.length; ii++) { var frameXML = framesXML[ii]; @@ -612,6 +591,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } return movBoneData; }, + decodeFrame: function (frameXML, parentFrameXml, boneData, dataInfo) { var frameData = new ccs.FrameData(); frameData.movement = frameXML.getAttribute(ccs.CONST_A_MOVEMENT) || ""; @@ -737,6 +717,87 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return frameData; }, + decodeFrameFromJson: function (json, dataInfo) { + var frameData = new ccs.FrameData(); + + this.decodeNodeFromJson(frameData, json, dataInfo); + + frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; + frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX] || 0; + var bd_src = json[ccs.CONST_A_BLEND_SRC] || cc.BLEND_SRC; + var bd_dst = json[ccs.CONST_A_BLEND_DST] || cc.BLEND_DST; + frameData.blendFunc.src = bd_src; + frameData.blendFunc.dst = bd_dst; + frameData.duration = json[ccs.CONST_A_DURATION] || 0; + frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME]; + + frameData.event = json[ccs.CONST_A_EVENT] || null; + + if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) + frameData.duration = json[ccs.CONST_A_DURATION] || 0; + else + frameData.frameID = json[ccs.CONST_A_FRAME_INDEX] || 0; + + var twEPs = json[ccs.CONST_A_EASING_PARAM] || []; + for (var i = 0; i < twEPs.length; i++) { + var twEP = twEPs[i]; + frameData.easingParams[i] = twEP; + } + + return frameData; + }, + + + + + + + + + + + clear: function () { + this._configFileList = []; + this._asyncRefCount = 0; + this._asyncRefTotalCount = 0; + }, + + _asyncCallBack: function (target, selector, percent) { + if (target && (typeof(selector) == "string")) { + target[selector](percent); + } else if (target && (typeof(selector) == "function")) { + selector.call(target, percent); + } + }, + /** + * find the base file path + * @param filePath + * @returns {String} + * @private + */ + _initBaseFilePath: function (filePath) { + var path = filePath; + var pos = path.lastIndexOf("/"); + if (pos > -1) + path = path.substr(0, pos + 1); + else + path = ""; + return path; + }, + + addDataFromXML: function (xml, dataInfo) { + /* + * Need to get the full path of the xml file, or the Tiny XML can't find the xml at IOS + */ + var xmlStr = cc.loader.getRes(xml); + if (!xmlStr) throw "Please load the resource first : " + xml; + var skeletonXML = cc.saxParser.parse(xmlStr); + var skeleton = skeletonXML.documentElement; + if (skeleton) { + this.addDataFromCache(skeleton, dataInfo); + } + }, + decodeTexture: function (textureXML, dataInfo) { var textureData = new ccs.TextureData(); if (textureXML.getAttribute(ccs.CONST_A_NAME)) { @@ -834,23 +895,6 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ animationData = null; }, - decodeArmatureFromJSON: function (json, dataInfo) { - var armatureData = new ccs.ArmatureData(); - - var name = json[ccs.CONST_A_NAME]; - if (name) { - armatureData.name = name; - } - - dataInfo.cocoStudioVersion = armatureData.dataVersion = json[ccs.CONST_VERSION] || 0.1; - - var boneDataList = json[ccs.CONST_BONE_DATA]; - for (var i = 0; i < boneDataList.length; i++) { - armatureData.addBoneData(this.decodeBoneFromJson(boneDataList[i], dataInfo)); - } - return armatureData; - }, - decodeBoneFromJson: function (json, dataInfo) { var boneData = new ccs.BoneData(); this.decodeNodeFromJson(boneData, json, dataInfo); @@ -991,36 +1035,6 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return movementBoneData; }, - decodeFrameFromJson: function (json, dataInfo) { - var frameData = new ccs.FrameData(); - this.decodeNodeFromJson(frameData, json, dataInfo); - frameData.duration = json[ccs.CONST_A_DURATION] || 0; - frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; - frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX] || 0; - - var bd_src = json[ccs.CONST_A_BLEND_SRC] || cc.BLEND_SRC; - var bd_dst = json[ccs.CONST_A_BLEND_DST] || cc.BLEND_DST; - frameData.blendFunc.src = bd_src; - frameData.blendFunc.dst = bd_dst; - - frameData.event = json[ccs.CONST_A_EVENT] || null; - if (json[ccs.CONST_A_TWEEN_FRAME] !== undefined) { - frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME] - } - if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) - frameData.duration = json[ccs.CONST_A_DURATION] || 0; - else - frameData.frameID = json[ccs.CONST_A_FRAME_INDEX] || 0; - - var twEPs = json[ccs.CONST_A_EASING_PARAM] || []; - for (var i = 0; i < twEPs.length; i++) { - var twEP = twEPs[i]; - frameData.easingParams[i] = twEP; - } - - return frameData; - }, - decodeTextureFromJson: function (json) { var textureData = new ccs.TextureData(); textureData.name = json[ccs.CONST_A_NAME] || ""; From a9b15a35e476d467994527946371e7d676b23df5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 10:50:35 +0800 Subject: [PATCH 0290/1564] Issue #5704: refactor cc.Widget --- extensions/ccui/base-classes/UIWidget.js | 454 ++++++++++------------ extensions/ccui/layouts/UILayout.js | 27 +- extensions/ccui/uiwidgets/UIButton.js | 6 - extensions/ccui/uiwidgets/UICheckBox.js | 16 - extensions/ccui/uiwidgets/UIImageView.js | 8 - extensions/ccui/uiwidgets/UILoadingBar.js | 8 - extensions/ccui/uiwidgets/UISlider.js | 25 -- extensions/ccui/uiwidgets/UIText.js | 10 +- extensions/ccui/uiwidgets/UITextAtlas.js | 9 - extensions/ccui/uiwidgets/UITextBMFont.js | 9 - extensions/ccui/uiwidgets/UITextField.js | 8 - 11 files changed, 218 insertions(+), 362 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index e20b76c800..f7a46cbeb6 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -52,7 +52,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _touchEnabled: false, ///< is this widget touch endabled _brightStyle: null, ///< bright style - _updateEnabled: false, ///< is "update" method scheduled _touchBeganPosition: null, ///< touch began point _touchMovePosition: null, ///< touch moved point @@ -77,13 +76,12 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _sizeType: null, _sizePercent: null, - positionType: null, + _positionType: null, _positionPercent: null, _reorderWidgetChildDirty: false, _hit: false, _nodes: null, _touchListener: null, - _color: null, _className: "Widget", _flippedX: false, _flippedY: false, @@ -104,10 +102,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._layoutParameterDictionary = {}; this._sizeType = ccui.Widget.SIZE_ABSOLUTE; this._sizePercent = cc.p(0, 0); - this.positionType = ccui.Widget.POSITION_ABSOLUTE; + this._positionType = ccui.Widget.POSITION_ABSOLUTE; this._positionPercent = cc.p(0, 0); this._nodes = []; - this._color = cc.color(255, 255, 255, 255); this._layoutParameterType = ccui.LayoutParameter.NONE; this.init(); //TODO }, @@ -214,9 +211,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._eventDispatcher.removeEventListener(this._touchListener); //cleanup focused widget and focus navigation controller - if (this._focusedWidget == this){ + if (ccui.Widget._focusedWidget == this){ //delete - this._focusedWidget = null; + ccui.Widget._focusedWidget = null; } }, @@ -238,109 +235,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ initRenderer: function () { }, - /** - * add node for widget - * @param {cc.Node} node - * @param {Number} zOrder - * @param {Number} tag - */ - addNode: function (node, zOrder, tag) { - if (node instanceof ccui.Widget) { - cc.log("Please use addChild to add a Widget."); - return; - } - cc.Node.prototype.addChild.call(this, node, zOrder, tag); - this._nodes.push(node); - }, - - /** - * get node by tag - * @param {Number} tag - * @returns {cc.Node} - */ - getNodeByTag: function (tag) { - var _nodes = this._nodes; - for (var i = 0; i < _nodes.length; i++) { - var node = _nodes[i]; - if (node && node.getTag() == tag) { - return node; - } - } - return null; - }, - - /** - * get all node - * @returns {Array} - */ - getNodes: function () { - return this._nodes; - }, - - /** - * remove node - * @param {cc.Node} node - * @param {Boolean} cleanup - */ - removeNode: function (node, cleanup) { - cc.Node.prototype.removeChild.call(this, node); - cc.arrayRemoveObject(this._nodes, node); - }, - - /** - * remove node by tag - * @param {Number} tag - * @param {Boolean} cleanup - */ - removeNodeByTag: function (tag, cleanup) { - var node = this.getNodeByTag(tag); - if (!node) { - cc.log("cocos2d: removeNodeByTag(tag = %d): child not found!", tag); - } - else { - this.removeNode(node); - } - }, - - /** - * remove all node - */ - removeAllNodes: function () { - for (var i = 0; i < this._nodes.length; i++) { - var node = this._nodes[i]; - cc.Node.prototype.removeChild.call(this, node); - } - this._nodes.length = 0; - }, - - /** - * Changes the size that is widget's size - * @param {cc.Size} size that is widget's size - */ - setSize: function (size) { - var locW = this._customSize.width = size.width; - var locH = this._customSize.height = size.height; - if (this._ignoreSize) { - locW = this.width; - locH = this.height; - } - this._size.width = locW; - this._size.height = locH; - - if (this._running) { - var widgetParent = this.getWidgetParent(); - if (widgetParent) { - locW = widgetParent.width; - 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.onSizeChanged(); - }, _setWidth: function (w) { var locW = this._customSize.width = w; this._ignoreSize && (locW = this.width); @@ -379,8 +273,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (widgetParent) { width = widgetParent.width * percent.x; height = widgetParent.height * percent.y; - } - else { + } else { width = this._parent.width * percent.x; height = this._parent.height * percent.y; } @@ -460,7 +353,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } this.onSizeChanged(); var absPos = this.getPosition(); - switch (this.positionType) { + switch (this._positionType) { case ccui.Widget.POSITION_ABSOLUTE: if (parentSize.width <= 0 || parentSize.height <= 0) { this._positionPercent.x = 0; @@ -518,14 +411,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return this._ignoreSize; }, - /** - * Returns size of widget - * @returns {cc.Size} - */ - getSize: function () { - return cc.size(this._size); - }, - /** * Get custom size of widget * @returns {cc.Size} @@ -658,31 +543,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.onPressStateChangedToDisabled(); }, - /** - * Schedules the "update" method. - * @param enable - */ - setUpdateEnabled: function (enable) { - if (this._updateEnabled == enable) { - return; - } - this._updateEnabled = enable; - if (enable) { - this.scheduleUpdate(); - } - else { - this.unscheduleUpdate(); - } - }, - - /** - * is the "update" method scheduled. - * @returns {boolean} - */ - isUpdateEnabled: function () { - return this._updateEnabled; - }, - /** * Determines if the widget is on focused * @returns {boolean} whether the widget is focused or not @@ -700,7 +560,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._focused = focus; //make sure there is only one focusedWidget if (focus) { - this._focusedWidget = this; + ccui.Widget._focusedWidget = this; } }, @@ -755,16 +615,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * when a widget calls this method, it will get focus immediately. */ requestFocus: function(){ - if (this == this._focusedWidget) + if (this == ccui.Widget._focusedWidget) return; - this.dispatchFocusEvent(this._focusedWidget, this); + this.dispatchFocusEvent(ccui.Widget._focusedWidget, this); }, /** * no matter what widget object you call this method on , it will return you the exact one focused widget */ getCurrentFocusedWidget: function(){ - return this._focusedWidget; + return ccui.Widget._focusedWidget; }, /** @@ -773,21 +633,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} enable set true to enable dpad focus navigation, otherwise disable dpad focus navigation */ enableDpadNavigation: function(enable){ - // - /*if (enable) { - if (nullptr == _focusNavigationController) - { - _focusNavigationController = new FocusNavigationController; - if (_focusedWidget) { - _focusNavigationController.setFirstFocsuedWidget(_focusedWidget); - } - } - } - else - { - CC_SAFE_DELETE(_focusNavigationController); - } - _focusNavigationController.enableFocusNavigation(enable);*/ }, /** @@ -837,7 +682,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ dispatchFocusEvent: function(widgetLostFocus, widgetGetFocus){ //if the widgetLoseFocus doesn't get focus, it will use the previous focused widget instead if (widgetLostFocus && !widgetLostFocus.isFocused()) - widgetLostFocus = this._focusedWidget; + widgetLostFocus = ccui.Widget._focusedWidget; if (widgetGetFocus != widgetLostFocus){ if (widgetGetFocus && widgetGetFocus.onFocusChanged) @@ -924,9 +769,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } this.setHighlighted(true); var widgetParent = this.getWidgetParent(); - if (widgetParent) { - widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_BAGAN, this, touch); - } + if (widgetParent) + widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_BEGAN, this, touch); this.pushDownEvent(); return true; }, @@ -977,11 +821,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ //call back function called widget's state changed to dark. pushDownEvent: function () { if (this._touchEventCallback) - this._touchEventCallback(this, ccui.Widget.TOUCH_BAGAN); + this._touchEventCallback(this, ccui.Widget.TOUCH_BEGAN); - if (this._touchEventListener && this._touchEventSelector) { + if (this._touchEventListener && this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN); - } }, moveEvent: function () { @@ -1035,9 +878,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {boolean} true if the point is in widget's space, false otherwise. */ hitTest: function (pt) { - //TODO need test -/* var bb = cc.rect(-this._size.width * this._anchorPoint.x, -this._size.height * this._anchorPoint.y, this._size.width, this._size.height); - return (nsp.x >= bb.x && nsp.x <= bb.x + bb.width && nsp.y >= bb.y && nsp.y <= bb.y + bb.height);*/ var bb = cc.rect(0,0, this._contentSize.width, this._contentSize.height); return cc.rectContainsPoint(bb, this.convertToNodeSpace(pt)); }, @@ -1068,17 +908,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return true; }, - /** - * Checks a point if in parent's area. - * @deprecated - * @param {cc.Point} pt - * @returns {Boolean} - */ - clippingParentAreaContainPoint: function (pt) { - cc.log("clippingParentAreaContainPoint is deprecated. Please use isClippingParentContainsPoint instead."); - this.isClippingParentContainsPoint(pt); - }, - /** * Sends the touch event to widget's parent * @param {number} handleState @@ -1095,7 +924,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Changes the position (x,y) of the widget . * The original point (0,0) is at the left-bottom corner of screen. - * @param {cc.Point||Number} pos + * @param {cc.Point|Number} pos * @param {Number} [posY] */ setPosition: function (pos, posY) { @@ -1181,10 +1010,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, - updateAnchorPoint: function () { - this.setAnchorPoint(this.getAnchorPoint()); - }, - /** * Gets the percent (x,y) of the widget * @returns {cc.Point} The percent (x,y) of the widget in OpenGL coordinates @@ -1205,7 +1030,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Number} type the position type of widget */ setPositionType: function (type) { - this.positionType = type; + this._positionType = type; }, /** @@ -1213,7 +1038,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {Number} the position type of widget */ getPositionType: function () { - return this.positionType; + return this._positionType; }, /** @@ -1322,41 +1147,14 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return this.getBottomBoundary() + this._size.height; }, - /** - * Gets the touch began point of widget when widget is selected. - * @returns {cc.Point} the touch began point. - */ - getTouchStartPos: function () { - cc.log("getTouchStartPos is deprecated. Please use getTouchBeganPosition instead."); - return this.getTouchBeganPosition(); - }, - getTouchBeganPosition: function(){ return cc.p(this._touchBeganPosition); }, - /** - *Gets the touch move point of widget when widget is selected. - * @returns {cc.Point} the touch move point. - */ - getTouchMovePos: function () { - cc.log("getTouchMovePos is deprecated. Please use getTouchMovePosition instead."); - return this.getTouchMovePosition(); - }, - getTouchMovePosition: function(){ return cc.p(this._touchMovePosition); }, - /** - * Gets the touch end point of widget when widget is selected. - * @returns {cc.Point} the touch end point. - */ - getTouchEndPos: function () { - cc.log("getTouchEndPos is deprecated. Please use getTouchEndPosition instead."); - return this.getTouchEndPosition(); - }, - getTouchEndPosition:function(){ return cc.p(this._touchEndPosition); }, @@ -1436,7 +1234,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, copySpecialProperties: function (model) { - }, copyProperties: function (widget) { @@ -1462,7 +1259,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._sizePercent.x = widget._sizePercent.x; this._sizePercent.y = widget._sizePercent.y; - this.positionType = widget.positionType; + this._positionType = widget._positionType; this._positionPercent.x = widget._positionPercent.x; this._positionPercent.y = widget._positionPercent.y; @@ -1502,52 +1299,206 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * Get color - * @returns {cc.Color} + * Gets the left boundary position of this widget. + * @deprecated + * @returns {number} + */ + getLeftInParent: function(){ + cc.log("getLeftInParent is deprecated. Please use getLeftBoundary instead."); + return this.getLeftBoundary(); + }, + + /** + * Gets the bottom boundary position of this widget. + * @deprecated + * @returns {number} + */ + getBottomInParent: function(){ + cc.log("getBottomInParent is deprecated. Please use getBottomBoundary instead."); + return this.getBottomBoundary(); + }, + + /** + * Gets the right boundary position of this widget. + * @deprecated + * @returns {number} + */ + getRightInParent: function(){ + cc.log("getRightInParent is deprecated. Please use getRightBoundary instead."); + return this.getRightBoundary(); + }, + + /** + * Gets the top boundary position of this widget. + * @deprecated + * @returns {number} + */ + getTopInParent: function(){ + cc.log("getTopInParent is deprecated. Please use getTopBoundary instead."); + return this.getTopBoundary(); + }, + + /** + * Gets the touch end point of widget when widget is selected. + * @deprecated + * @returns {cc.Point} the touch end point. + */ + getTouchEndPos: function () { + cc.log("getTouchEndPos is deprecated. Please use getTouchEndPosition instead."); + return this.getTouchEndPosition(); + }, + + /** + *Gets the touch move point of widget when widget is selected. + * @deprecated + * @returns {cc.Point} the touch move point. + */ + getTouchMovePos: function () { + cc.log("getTouchMovePos is deprecated. Please use getTouchMovePosition instead."); + return this.getTouchMovePosition(); + }, + + /** + * Checks a point if in parent's area. + * @deprecated + * @param {cc.Point} pt + * @returns {Boolean} */ - getColor: function () { - return cc.color(this._color.r, this._color.g, this._color.b, this._color.a); + clippingParentAreaContainPoint: function (pt) { + cc.log("clippingParentAreaContainPoint is deprecated. Please use isClippingParentContainsPoint instead."); + this.isClippingParentContainsPoint(pt); + }, + + /** + * Gets the touch began point of widget when widget is selected. + * @deprecated + * @returns {cc.Point} the touch began point. + */ + getTouchStartPos: function () { + cc.log("getTouchStartPos is deprecated. Please use getTouchBeganPosition instead."); + return this.getTouchBeganPosition(); + }, + + /** + * Changes the size that is widget's size + * @deprecated + * @param {cc.Size} size that is widget's size + */ + setSize: function (size) { + //TODO where called onSizeChanged()? + //this.setContentSize(size); //the latest code of -x + + var locW = this._customSize.width = size.width; + var locH = this._customSize.height = size.height; + if (this._ignoreSize) { + locW = this.width; + locH = this.height; + } + this._size.width = locW; + this._size.height = locH; + + if (this._running) { + var widgetParent = this.getWidgetParent(); + if (widgetParent) { + locW = widgetParent.width; + 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.onSizeChanged(); }, /** - * Set opacity - * @param {Number} opacity + * Returns size of widget + * @deprecated + * @returns {cc.Size} */ - setOpacity: function (opacity) { - if(opacity === this._color.a) return; - this._color.a = opacity; - this.updateTextureOpacity(opacity); + getSize: function () { + return cc.size(this._size); }, /** - * Get opacity - * @returns {Number} + * add node for widget (this function is deleted in -x) + * @param {cc.Node} node + * @param {Number} zOrder + * @param {Number} tag + * @deprecated */ - getOpacity: function () { - //return this._color.a; //TODO - return this._displayedOpacity; + addNode: function (node, zOrder, tag) { + if (node instanceof ccui.Widget) { + cc.log("Please use addChild to add a Widget."); + return; + } + cc.Node.prototype.addChild.call(this, node, zOrder, tag); + this._nodes.push(node); }, - updateTextureOpacity: function (opacity) { - for(var p in this._children){ - var item = this._children[p]; - if(item) - item.setOpacity(opacity); + /** + * get node by tag + * @deprecated + * @param {Number} tag + * @returns {cc.Node} + */ + getNodeByTag: function (tag) { + var _nodes = this._nodes; + for (var i = 0; i < _nodes.length; i++) { + var node = _nodes[i]; + if (node && node.getTag() == tag) { + return node; + } } + return null; }, + /** + * get all node + * @deprecated + * @returns {Array} + */ + getNodes: function () { + return this._nodes; + }, - updateColorToRenderer: function (renderer) { - renderer.setColor(this._color); + /** + * remove node + * @deprecated + * @param {cc.Node} node + * @param {Boolean} cleanup + */ + removeNode: function (node, cleanup) { + cc.Node.prototype.removeChild.call(this, node); + cc.arrayRemoveObject(this._nodes, node); }, - updateOpacityToRenderer: function (renderer) { - renderer.setOpacity(this._color.a); + /** + * remove node by tag + * @deprecated + * @param {Number} tag + * @param {Boolean} [cleanup] + */ + removeNodeByTag: function (tag, cleanup) { + var node = this.getNodeByTag(tag); + if (!node) { + cc.log("cocos2d: removeNodeByTag(tag = %d): child not found!", tag); + } else { + this.removeNode(node); + } }, - updateRGBAToRenderer: function(renderer){ - renderer.setColor(this._color); - renderer.setOpacity(this._opacity); + /** + * remove all node + * @deprecated + */ + removeAllNodes: function () { + for (var i = 0; i < this._nodes.length; i++) { + var node = this._nodes[i]; + cc.Node.prototype.removeChild.call(this, node); + } + this._nodes.length = 0; } }); @@ -1614,6 +1565,11 @@ ccui.Widget.create = function () { return new ccui.Widget(); }; +ccui.Widget._focusedWidget = null; //both layout & widget will be stored in this variable + +ccui.Widget.getCurrentFocusedWidget = function(){ + return ccui.Widget._focusedWidget; +}; // Constants //bright style diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 282a62fb87..b9fed5918c 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -83,7 +83,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _mask_layer_le: 0, _loopFocus: false, - _passFocusToChild: false, + __passFocusToChild: false, _isFocusPassing:false, /** @@ -144,14 +144,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param pass To specify whether the layout pass its focus to its child */ setPassFocusToChild: function(pass){ - this._passFocusToChild = pass; + this.__passFocusToChild = pass; }, /** * @returns {boolean} To query whether the layout will pass the focus to its children or not. The default value is true */ isPassFocusToChild: function(){ - return this._passFocusToChild; + return this.__passFocusToChild; }, /** @@ -166,7 +166,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var parent = this.getParent(); this._isFocusPassing = false; - if (this._passFocusToChild) { + if (this.__passFocusToChild) { var w = this._passFocusToChild(direction, current); if (w instanceof ccui.Layout && parent) { parent._isFocusPassing = true; @@ -747,7 +747,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Sets background image use scale9 renderer. - * @param {Boolean} able + * @param {Boolean} able true that use scale9 renderer, false otherwise. */ setBackGroundImageScale9Enabled: function (able) { if (this._backGroundScale9Enabled == able) { @@ -823,7 +823,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Sets a background image CapInsets for layout, if the background image is a scale9 render. - * @param {cc.Rect} capInsets + * @param {cc.Rect} capInsets capinsets of background image. */ setBackGroundImageCapInsets: function (capInsets) { this._backGroundImageCapInsets = capInsets; @@ -947,7 +947,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get color type. + * Get background color type. * @returns {ccui.Layout.BG_COLOR_NONE|ccui.Layout.BG_COLOR_SOLID|ccui.Layout.BG_COLOR_GRADIENT} */ getBackGroundColorType: function () { @@ -964,21 +964,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._color.r = color.r; this._color.g = color.g; this._color.b = color.b; - if (this._colorRender) { + if (this._colorRender) this._colorRender.setColor(color); - } } else { this._startColor.r = color.r; this._startColor.g = color.g; this._startColor.b = color.b; - if (this._gradientRender) { + if (this._gradientRender) this._gradientRender.setStartColor(color); - } this._endColor = endColor; - if (this._gradientRender) { + if (this._gradientRender) this._gradientRender.setEndColor(endColor); - } } }, @@ -1631,7 +1628,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _passFocusToChild: function(direction, current){ if (this._checkFocusEnabledChild()) { - var previousWidget = this.getCurrentFocusedWidget(); + var previousWidget = ccui.Widget.getCurrentFocusedWidget(); this._findProperSearchingFunctor(direction, previousWidget); var index = this.onPassFocusToChild(direction, previousWidget); //TODO need check @@ -1687,7 +1684,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.setClippingEnabled(layout._clippingEnabled); this.setClippingType(layout._clippingType); this._loopFocus = layout._loopFocus; - this._passFocusToChild = layout._passFocusToChild; + this.__passFocusToChild = layout.__passFocusToChild; } }); ccui.Layout._init_once = null; diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 11b7b2833c..f308247902 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -790,12 +790,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return this._titleRenderer.font; }, - updateTextureColor: function () { - this.updateColorToRenderer(this._buttonNormalRenderer); - this.updateColorToRenderer(this._buttonClickedRenderer); - this.updateColorToRenderer(this._buttonDisableRenderer); - }, - /** * Returns the "class name" of widget. * @returns {string} diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 88a7384d40..0b34c67c53 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -526,22 +526,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } }, - updateTextureColor: function () { - this.updateColorToRenderer(this._backGroundBoxRenderer); - this.updateColorToRenderer(this._backGroundSelectedBoxRenderer); - this.updateColorToRenderer(this._frontCrossRenderer); - this.updateColorToRenderer(this._backGroundBoxDisabledRenderer); - this.updateColorToRenderer(this._frontCrossDisabledRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._backGroundBoxRenderer); - this.updateOpacityToRenderer(this._backGroundSelectedBoxRenderer); - this.updateOpacityToRenderer(this._frontCrossRenderer); - this.updateOpacityToRenderer(this._backGroundBoxDisabledRenderer); - this.updateOpacityToRenderer(this._frontCrossDisabledRenderer); - }, - /** * Returns the "class name" of widget. * @returns {string} diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 9d1cc081a3..490c8dcd23 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -284,14 +284,6 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._imageRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, - updateTextureColor: function () { - this.updateColorToRenderer(this._imageRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._imageRenderer); - }, - /** * Returns the "class name" of widget. * @returns {string} diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 74beee46aa..70142e2fd0 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -327,14 +327,6 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._barRenderer.setPreferredSize(cc.size(width, this._size.height)); }, - updateTextureColor: function () { - this.updateColorToRenderer(this._barRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._barRenderer); - }, - /** * Returns the "class name" of widget. * @returns {string} diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 48af874135..1dccc3b86f 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -326,17 +326,14 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballNTexType = texType; switch (this._ballNTexType) { case ccui.Widget.LOCAL_TEXTURE: -// this._slidBallNormalRenderer.initWithFile(normal); this._slidBallNormalRenderer.setTexture(normal); break; case ccui.Widget.PLIST_TEXTURE: -// this._slidBallNormalRenderer.initWithSpriteFrameName(normal); this._slidBallNormalRenderer.setSpriteFrame(normal); break; default: break; } -// this.updateColorToRenderer(this._slidBallNormalRenderer); this._slidBallNormalRenderer.setColor(this.getColor()); this._slidBallNormalRenderer.setOpacity(this.getOpacity()); }, @@ -355,17 +352,14 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballPTexType = texType; switch (this._ballPTexType) { case ccui.Widget.LOCAL_TEXTURE: -// this._slidBallPressedRenderer.initWithFile(pressed); this._slidBallPressedRenderer.setTexture(pressed); break; case ccui.Widget.PLIST_TEXTURE: -// this._slidBallPressedRenderer.initWithSpriteFrameName(pressed); this._slidBallPressedRenderer.setSpriteFrame(pressed); break; default: break; } -// this.updateColorToRenderer(this._slidBallPressedRenderer); this._slidBallPressedRenderer.setColor(this.getColor()); this._slidBallPressedRenderer.setOpacity(this.getOpacity()); }, @@ -384,17 +378,14 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballDTexType = texType; switch (this._ballDTexType) { case ccui.Widget.LOCAL_TEXTURE: -// this._slidBallDisabledRenderer.initWithFile(disabled); this._slidBallDisabledRenderer.setTexture(disabled); break; case ccui.Widget.PLIST_TEXTURE: -// this._slidBallDisabledRenderer.initWithSpriteFrameName(disabled); this._slidBallDisabledRenderer.setSpriteFrame(disabled); break; default: break; } -// this.updateColorToRenderer(this._slidBallDisabledRenderer); this._slidBallDisabledRenderer.setColor(this.getColor()); this._slidBallDisabledRenderer.setOpacity(this.getOpacity()); }, @@ -658,22 +649,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._sliderEventSelector = slider._sliderEventSelector; this._eventCallback = slider._eventCallback; - }, - - updateTextureColor: function () { - this.updateColorToRenderer(this._barRenderer); - this.updateColorToRenderer(this._progressBarRenderer); - this.updateColorToRenderer(this._slidBallNormalRenderer); - this.updateColorToRenderer(this._slidBallPressedRenderer); - this.updateColorToRenderer(this._slidBallDisabledRenderer); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._barRenderer); - this.updateOpacityToRenderer(this._progressBarRenderer); - this.updateOpacityToRenderer(this._slidBallNormalRenderer); - this.updateOpacityToRenderer(this._slidBallPressedRenderer); - this.updateOpacityToRenderer(this._slidBallDisabledRenderer); } }); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index fecc721ee8..d1323d4980 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -454,15 +454,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ // _getHeight: function () { // return this._labelRenderer._getHeight(); // }, -// -// updateTextureColor: function () { -// this.updateColorToRenderer(this._labelRenderer); -// }, -// -// updateTextureOpacity: function () { -// this.updateOpacityToRenderer(this._labelRenderer); -// }, -// + copySpecialProperties: function (uiLabel) { if(uiLabel instanceof ccui.Label){ this.setFontName(uiLabel._fontName); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 0f8251de75..23e14275f7 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -74,7 +74,6 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._startCharMap = startCharMap; // var renderer = this._labelAtlasRenderer; // renderer.initWithString(stringValue, charMapFile, itemWidth, itemHeight, startCharMap[0]); -// this.updateAnchorPoint(); // this.labelAtlasScaleChangedWithSize(); // // if (!renderer.textureLoaded()) { @@ -236,14 +235,6 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ // _getHeight: function () { // return this._labelAtlasRenderer._getHeight(); // }, -// -// updateTextureColor: function () { -// this.updateColorToRenderer(this._labelAtlasRenderer); -// }, -// -// updateTextureOpacity: function () { -// this.updateOpacityToRenderer(this._labelAtlasRenderer); -// } }); var _p = ccui.TextAtlas.prototype; diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 8aaa59092a..d6b66f6dbe 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -65,7 +65,6 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo } this._fntFileName = fileName; this._labelBMFontRenderer.initWithString("", fileName); - this.updateAnchorPoint(); this.labelBMFontScaleChangedWithSize(); if (!this._labelBMFontRenderer.textureLoaded()) { @@ -199,14 +198,6 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo // }, // _getHeight: function () { // return this._labelBMFontRenderer._getHeight(); -// }, -// -// updateTextureColor: function () { -// this.updateColorToRenderer(this._labelBMFontRenderer); -// }, -// -// updateTextureOpacity: function () { -// this.updateOpacityToRenderer(this._labelBMFontRenderer); // }, /** diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index d40f52ac19..7ce870d08f 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -756,14 +756,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ return this._textFieldRender; }, - updateTextureColor: function () { - this.updateColorToRenderer(this._textFieldRender); - }, - - updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._textFieldRender); - }, - /** * Returns the "class name" of widget. * @returns {string} From 67bfbf0537953d5a20a3835e65901c2b9ade9bbb Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 11:04:46 +0800 Subject: [PATCH 0291/1564] Issue #5704: modify "onSizeChanged" to "_onSizeChanged" --- extensions/ccui/base-classes/UIWidget.js | 22 +++++++++---------- extensions/ccui/layouts/UILayout.js | 19 ++++++++-------- extensions/ccui/uiwidgets/UIButton.js | 4 ++-- extensions/ccui/uiwidgets/UICheckBox.js | 4 ++-- extensions/ccui/uiwidgets/UIImageView.js | 4 ++-- extensions/ccui/uiwidgets/UILoadingBar.js | 4 ++-- extensions/ccui/uiwidgets/UISlider.js | 6 ++--- extensions/ccui/uiwidgets/UIText.js | 5 ++--- extensions/ccui/uiwidgets/UITextAtlas.js | 5 ++--- extensions/ccui/uiwidgets/UITextBMFont.js | 5 ++--- extensions/ccui/uiwidgets/UITextField.js | 4 ++-- .../uiwidgets/scroll-widget/UIListView.js | 4 ++-- .../uiwidgets/scroll-widget/UIPageView.js | 4 ++-- .../uiwidgets/scroll-widget/UIScrollView.js | 4 ++-- 14 files changed, 45 insertions(+), 49 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index f7a46cbeb6..3e46c6e089 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -168,7 +168,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ locSize.width = this._customSize.width; locSize.height = this._customSize.height; } - this.onSizeChanged(); + this._onSizeChanged(); }, _isAncestorsEnabled: function(){ @@ -245,7 +245,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ locW = widgetParent ? widgetParent.width : this._parent.width; this._sizePercent.x = locW > 0 ? this._customSize.width / locW : 0; } - this.onSizeChanged(); + this._onSizeChanged(); }, _setHeight: function (h) { var locH = this._customSize.height = h; @@ -257,7 +257,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ locH = widgetParent ? widgetParent.height : this._parent.height; this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0; } - this.onSizeChanged(); + this._onSizeChanged(); }, /** @@ -284,7 +284,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } this._customSize.width = width; this._customSize.height = height; - this.onSizeChanged(); + this._onSizeChanged(); }, _setWidthPercent: function (percent) { @@ -296,7 +296,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } this._ignoreSize || (this._size.width = width); this._customSize.width = width; - this.onSizeChanged(); + this._onSizeChanged(); }, _setHeightPercent: function (percent) { this._sizePercent.y = percent; @@ -307,7 +307,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } this._ignoreSize || (this._size.height = height); this._customSize.height = height; - this.onSizeChanged(); + this._onSizeChanged(); }, /** @@ -351,7 +351,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ default: break; } - this.onSizeChanged(); + this._onSizeChanged(); var absPos = this.getPosition(); switch (this._positionType) { case ccui.Widget.POSITION_ABSOLUTE: @@ -400,7 +400,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var locSize = this._ignoreSize ? this.getContentSize(): this._customSize; this._size.width = locSize.width; this._size.height = locSize.height; - this.onSizeChanged(); + this._onSizeChanged(); }, /** @@ -463,7 +463,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * call back function called when size changed. */ - onSizeChanged: function () { + _onSizeChanged: function () { this.setContentSize(this._size); var locChildren = this.getChildren(); for (var i = 0, len = locChildren.length; i < len; i++) { @@ -1286,7 +1286,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (parameter) this.setLayoutParameter(parameter.clone()); } - this.onSizeChanged(); + this._onSizeChanged(); }, /*temp action*/ @@ -1409,7 +1409,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._sizePercent.x = locW > 0 ? this._customSize.width / locW : 0; this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0; } - this.onSizeChanged(); + this._onSizeChanged(); }, /** diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index b9fed5918c..2d053242cf 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -264,7 +264,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * Adds a widget to the container. * @param {ccui.Widget} widget * @param {Number} [zOrder] - * @param {Number} [tag] + * @param {Number|string} [tag] tag or name */ addChild: function (widget, zOrder, tag) { if ((widget instanceof ccui.Widget)) { @@ -304,7 +304,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Gets if layout is clipping enabled. - * @returns {Boolean} + * @returns {Boolean} if layout is clipping enabled. */ isClippingEnabled: function () { return this._clippingEnabled; @@ -587,7 +587,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Changes if layout can clip it's content and locChild. - * @param {Boolean} able + * If you really need this, please enable it. But it would reduce the rendering efficiency. + * @param {Boolean} able clipping enabled. */ setClippingEnabled: function (able) { if (able == this._clippingEnabled) @@ -614,7 +615,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Set clipping type + * Sets clipping type * @param {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} type */ setClippingType: function (type) { @@ -628,7 +629,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get clipping type + * Gets clipping type * @returns {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} */ getClippingType: function () { @@ -724,8 +725,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this._clippingRect; }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this.setStencilClippingSize(this._contentSize); this._doLayoutDirty = true; this._clippingRectDirty = true; @@ -1055,7 +1056,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Set backGround image color + * Sets backGround image color * @param {cc.Color} color */ setBackGroundImageColor: function (color) { @@ -1067,7 +1068,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get backGround image color + * Gets backGround image Opacity * @param {Number} opacity */ setBackGroundImageOpacity: function (opacity) { diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index f308247902..e66e9a9262 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -571,8 +571,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._titleRenderer.setPositionY(this._size.height * (0.5 - this._anchorPoint.y)); }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this.updateTitleLocation(); this.normalTextureScaleChangedWithSize(); this.pressedTextureScaleChangedWithSize(); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 0b34c67c53..1e1d3adcb7 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -407,8 +407,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledRenderer._setAnchorY(value); }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._backGroundBoxRendererAdaptDirty = true; this._backGroundSelectedBoxRendererAdaptDirty = true; this._frontCrossRendererAdaptDirty = true; diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 490c8dcd23..2a708405a9 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -237,8 +237,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._imageRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 70142e2fd0..da7d680860 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -238,8 +238,8 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ return this._percent; }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._barRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 1dccc3b86f..dd4c0a1257 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -494,10 +494,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ return this._percent; }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); -// this.barRendererScaleChangedWithSize(); -// this.progressBarRendererScaleChangedWithSize(); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._barRendererAdaptDirty = true; this._progressBarRendererDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index d1323d4980..0dd6068a5c 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -288,9 +288,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ } }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); -// this.labelScaleChangedWithSize(); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._labelRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 23e14275f7..6b87115d31 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -132,9 +132,8 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ return this._labelAtlasRenderer.getStringLength(); }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); -// this.labelAtlasScaleChangedWithSize(); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._labelAtlasRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index d6b66f6dbe..be29d2338e 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -116,9 +116,8 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return this._labelBMFontRenderer.getStringLength(); }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); -// this.labelBMFontScaleChangedWithSize(); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._labelBMFontRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 7ce870d08f..f7e27e6f08 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -708,8 +708,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRender._setAnchorY(value); }, - onSizeChanged: function () { - ccui.Widget.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Widget.prototype._onSizeChanged.call(this); this._textFieldRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 9d9c058a98..399d600022 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -453,8 +453,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ return this._curSelectedIndex; }, - onSizeChanged: function () { - ccui.ScrollView.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.ScrollView.prototype._onSizeChanged.call(this); this._refreshViewDirty = true; }, diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index d16026de26..da5206e295 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -218,8 +218,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ return (this.getSize().width * (idx - this._curPageIdx)); }, - onSizeChanged: function () { - ccui.Layout.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Layout.prototype._onSizeChanged.call(this); this._rightBoundary = this.getContentSize().width; this._doLayoutDirty = true; }, diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 1f09896509..e5f8d51e3a 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -149,8 +149,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.addProtectedChild(this._innerContainer, 1, 1); }, - onSizeChanged: function () { - ccui.Layout.prototype.onSizeChanged.call(this); + _onSizeChanged: function () { + ccui.Layout.prototype._onSizeChanged.call(this); var locSize = this._contentSize; this._topBoundary = locSize.height; this._rightBoundary = locSize.width; From dddef02ef416a33657bd00788b871d2d7eb9fbc4 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 11:11:15 +0800 Subject: [PATCH 0292/1564] Issue #5704: rename "initRenderer" to "_initRenderer" --- extensions/ccui/base-classes/UIWidget.js | 4 ++-- extensions/ccui/uiwidgets/UIButton.js | 2 +- extensions/ccui/uiwidgets/UICheckBox.js | 12 +----------- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- extensions/ccui/uiwidgets/UIRichText.js | 2 +- extensions/ccui/uiwidgets/UISlider.js | 2 +- extensions/ccui/uiwidgets/UIText.js | 2 +- extensions/ccui/uiwidgets/UITextAtlas.js | 3 +-- extensions/ccui/uiwidgets/UITextBMFont.js | 4 +--- extensions/ccui/uiwidgets/UITextField.js | 2 +- .../ccui/uiwidgets/scroll-widget/UIScrollView.js | 4 ++-- 12 files changed, 14 insertions(+), 27 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 3e46c6e089..c1bee8e4c2 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -116,7 +116,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ init: function () { if (cc.ProtectedNode.prototype.init.call(this)) { this._layoutParameterDictionary = {}; - this.initRenderer(); + this._initRenderer(); this.setBright(true); this.onFocusChanged = this.onFocusChange.bind(this); @@ -232,7 +232,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * initializes renderer of widget. */ - initRenderer: function () { + _initRenderer: function () { }, _setWidth: function (w) { diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index e66e9a9262..5d07597d41 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -103,7 +103,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return false; }, - initRenderer: function () { + _initRenderer: function () { this._buttonNormalRenderer = cc.Sprite.create(); this._buttonClickedRenderer = cc.Sprite.create(); this._buttonDisableRenderer = cc.Sprite.create(); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 1e1d3adcb7..4b44ea1648 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -80,7 +80,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ return false; }, - initRenderer: function () { + _initRenderer: function () { this._backGroundBoxRenderer = cc.Sprite.create(); this._backGroundSelectedBoxRenderer = cc.Sprite.create(); this._frontCrossRenderer = cc.Sprite.create(); @@ -91,16 +91,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this.addProtectedChild(this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1); this.addProtectedChild(this._backGroundBoxDisabledRenderer, ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER, -1); this.addProtectedChild(this._frontCrossDisabledRenderer, ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER, -1); - - window.test = [ - this._backGroundBoxRenderer, - this._backGroundSelectedBoxRenderer, - this._frontCrossRenderer, - this._backGroundBoxDisabledRenderer, - this._frontCrossDisabledRenderer - ]; - - window.a = this; }, /** diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 2a708405a9..6611f8305c 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -59,7 +59,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ return true; }, - initRenderer: function () { + _initRenderer: function () { this._imageRenderer = cc.Sprite.create(); this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); }, diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index da7d680860..3934ea2d8c 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -60,7 +60,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ ccui.Widget.prototype.ctor.call(this); }, - initRenderer: function () { + _initRenderer: function () { this._barRenderer = cc.Sprite.create(); cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); this._barRenderer.setAnchorPoint(0.0, 0.5); diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 7f1d3fea82..5e31164c8f 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -182,7 +182,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._verticalSpace = 0; }, - initRenderer: function () { + _initRenderer: function () { this._elementRenderersContainer = cc.Node.create(); this._elementRenderersContainer.setAnchorPoint(0.5, 0.5); this.addProtectedChild(this._elementRenderersContainer, 0, -1); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index dd4c0a1257..218715b89b 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -82,7 +82,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ return false; }, - initRenderer: function () { + _initRenderer: function () { this._barRenderer = cc.Sprite.create(); this._progressBarRenderer = cc.Sprite.create(); this._progressBarRenderer.setAnchorPoint(0.0, 0.5); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 0dd6068a5c..13d372ef78 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -80,7 +80,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ return false; }, - initRenderer: function () { + _initRenderer: function () { this._labelRenderer = cc.LabelTTF.create(); cc.Node.prototype.addChild.call(this, this._labelRenderer, ccui.Text.RENDERER_ZORDER, -1); }, diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 6b87115d31..fae6200c08 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -51,9 +51,8 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ ccui.Widget.prototype.ctor.call(this); }, - initRenderer: function () { + _initRenderer: function () { this._labelAtlasRenderer = new cc.LabelAtlas(); - //cc.Node.prototype.addChild.call(this, this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5, 0.5)); this.addProtectedChild(this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); }, diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index be29d2338e..c3647667e6 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -48,9 +48,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo ctor: function () { ccui.Widget.prototype.ctor.call(this); }, - initRenderer: function () { -// this._labelBMFontRenderer = cc.LabelBMFont.create(); -// cc.Node.prototype.addChild.call(this, this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); + _initRenderer: function () { this._labelBMFontRenderer = cc.LabelBMFont.create(); this.addProtectedChild(this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); }, diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index f7e27e6f08..7828902ac2 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -288,7 +288,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ ccui.Layout.prototype.onExit.call(this); }, - initRenderer: function () { + _initRenderer: function () { this._textFieldRender = ccui.UICCTextField.create("input words here", "Thonburi", 20); this.addProtectedChild(this._textFieldRender, ccui.TextField.RENDERER_ZORDER, -1); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index e5f8d51e3a..f6bc9de27f 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -143,8 +143,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, current); }, - initRenderer: function () { - ccui.Layout.prototype.initRenderer.call(this); + _initRenderer: function () { + ccui.Layout.prototype._initRenderer.call(this); this._innerContainer = ccui.Layout.create(); this.addProtectedChild(this._innerContainer, 1, 1); }, From 0f20aec8acd2960264cbdd09f88ecec0804f07dc Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 15 Jul 2014 11:47:55 +0800 Subject: [PATCH 0293/1564] issue #5685: refactor create and ctor of ProgressTimer --- cocos2d/progress-timer/CCProgressTimer.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index f9c916444d..c9804d31cf 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -169,7 +169,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ ctor: null, - _ctorForCanvas: function () { + _ctorForCanvas: function (sprite) { cc.Node.prototype.ctor.call(this); this._type = cc.ProgressTimer.TYPE_RADIAL; @@ -186,9 +186,11 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._radius = 0; this._counterClockWise = false; this._barRect = cc.rect(0, 0, 0, 0); + + sprite && this._initWithSpriteForCanvas(sprite); }, - _ctorForWebGL: function () { + _ctorForWebGL: function (sprite) { cc.Node.prototype.ctor.call(this); this._type = cc.ProgressTimer.TYPE_RADIAL; this._percentage = 0.0; @@ -203,6 +205,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._vertexData = null; this._vertexArrayBuffer = null; this._vertexDataDirty = false; + + sprite && this._initWithSpriteForWebGL(sprite); }, /** @@ -936,10 +940,7 @@ cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDire * var progress = cc.ProgressTimer.create('progress.png') */ cc.ProgressTimer.create = function (sprite) { - var progressTimer = new cc.ProgressTimer(); - if (progressTimer.initWithSprite(sprite)) - return progressTimer; - return null; + return new cc.ProgressTimer(sprite); }; /** From 1dc418fddfd1e4394bb24dd39c053bbe6532495f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 11:54:59 +0800 Subject: [PATCH 0294/1564] Issue #5704: rename some function from "public" to "protected" --- extensions/ccui/base-classes/UIWidget.js | 72 ++++++++----------- extensions/ccui/layouts/UILayout.js | 10 +-- extensions/ccui/layouts/UILayoutParameter.js | 20 +++--- extensions/ccui/uiwidgets/UIButton.js | 22 +++--- extensions/ccui/uiwidgets/UICheckBox.js | 37 +++++----- extensions/ccui/uiwidgets/UIImageView.js | 14 ++-- extensions/ccui/uiwidgets/UILoadingBar.js | 6 +- extensions/ccui/uiwidgets/UISlider.js | 13 ++-- extensions/ccui/uiwidgets/UIText.js | 24 +++---- extensions/ccui/uiwidgets/UITextAtlas.js | 12 ++-- extensions/ccui/uiwidgets/UITextBMFont.js | 21 +++--- extensions/ccui/uiwidgets/UITextField.js | 31 +++----- .../uiwidgets/scroll-widget/UIListView.js | 8 +-- .../uiwidgets/scroll-widget/UIPageView.js | 12 ++-- .../uiwidgets/scroll-widget/UIScrollView.js | 10 +-- 15 files changed, 137 insertions(+), 175 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index c1bee8e4c2..cfa850bde6 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -146,16 +146,15 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ visit: function (ctx) { if (this._visible) { - this.adaptRenderers(); + this._adaptRenderers(); cc.ProtectedNode.prototype.visit.call(this, ctx); } }, getWidgetParent: function () { var widget = this.getParent(); - if (widget instanceof ccui.Widget) { + if (widget instanceof ccui.Widget) return widget; - } return null; }, @@ -211,10 +210,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._eventDispatcher.removeEventListener(this._touchListener); //cleanup focused widget and focus navigation controller - if (ccui.Widget._focusedWidget == this){ - //delete + if (ccui.Widget._focusedWidget == this) ccui.Widget._focusedWidget = null; - } }, /** @@ -771,7 +768,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var widgetParent = this.getWidgetParent(); if (widgetParent) widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_BEGAN, this, touch); - this.pushDownEvent(); + this._pushDownEvent(); return true; }, @@ -783,7 +780,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var widgetParent = this.getWidgetParent(); if (widgetParent) widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); - this.moveEvent(); + this._moveEvent(); }, onTouchEnded: function (touch, event) { @@ -796,9 +793,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var highlight = this._highlight; this.setHighlighted(false); if (highlight) - this.releaseUpEvent(); + this._releaseUpEvent(); else - this.cancelUpEvent(); + this._cancelUpEvent(); }, /** @@ -807,7 +804,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ onTouchCancelled: function (touchPoint) { this.setHighlighted(false); - this.cancelUpEvent(); + this._cancelUpEvent(); }, /** @@ -819,39 +816,32 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, //call back function called widget's state changed to dark. - pushDownEvent: function () { + _pushDownEvent: function () { if (this._touchEventCallback) this._touchEventCallback(this, ccui.Widget.TOUCH_BEGAN); - if (this._touchEventListener && this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN); }, - moveEvent: function () { + _moveEvent: function () { if (this._touchEventCallback) this._touchEventCallback(this, ccui.Widget.TOUCH_MOVED); - - if (this._touchEventListener && this._touchEventSelector) { + if (this._touchEventListener && this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_MOVED); - } }, - releaseUpEvent: function () { + _releaseUpEvent: function () { if (this._touchEventCallback) this._touchEventCallback(this, ccui.Widget.TOUCH_ENDED); - - if (this._touchEventListener && this._touchEventSelector) { + if (this._touchEventListener && this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED); - } }, - cancelUpEvent: function () { + _cancelUpEvent: function () { if (this._touchEventCallback) this._touchEventCallback(this, ccui.Widget.TOUCH_CANCELED); - - if (this._touchEventListener && this._touchEventSelector) { + if (this._touchEventListener && this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_CANCELED); - } }, longClickEvent: function () { @@ -1047,7 +1037,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setFlippedX: function (flipX) { this._flippedX = flipX; - this.updateFlippedX(); + this._updateFlippedX(); }, /** @@ -1070,7 +1060,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setFlippedY: function (flipY) { this._flippedY = flipY; - this.updateFlippedY(); + this._updateFlippedY(); }, /** @@ -1087,16 +1077,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return this._flippedY; }, - updateFlippedX: function () { - + _updateFlippedX: function () { }, - updateFlippedY: function () { - + _updateFlippedY: function () { }, - adaptRenderers: function(){ - + _adaptRenderers: function(){ }, /** @@ -1213,30 +1200,29 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, clone: function () { - var clonedWidget = this.createCloneInstance(); - clonedWidget.copyProperties(this); - clonedWidget.copyClonedWidgetChildren(this); + var clonedWidget = this._createCloneInstance(); + clonedWidget._copyProperties(this); + clonedWidget._copyClonedWidgetChildren(this); return clonedWidget; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.Widget.create(); }, - copyClonedWidgetChildren: function (model) { + _copyClonedWidgetChildren: function (model) { 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()); - } } }, - copySpecialProperties: function (model) { + _copySpecialProperties: function (model) { }, - copyProperties: function (widget) { + _copyProperties: function (widget) { this.setEnabled(widget.isEnabled()); this.setVisible(widget.isVisible()); this.setBright(widget.isBright()); @@ -1254,7 +1240,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._customSize.width = widget._customSize.width; this._customSize.height = widget._customSize.height; - this.copySpecialProperties(widget); + this._copySpecialProperties(widget); this._sizeType = widget.getSizeType(); this._sizePercent.x = widget._sizePercent.x; this._sizePercent.y = widget._sizePercent.y; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 2d053242cf..46fec9a83e 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -313,7 +313,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ visit: function (ctx) { if (!this._visible) return; - this.adaptRenderers(); + this._adaptRenderers(); this._doLayout(); if (this._clippingEnabled) { @@ -1664,15 +1664,15 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return "Layout"; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.Layout.create(); }, - copyClonedWidgetChildren: function (model) { - ccui.Widget.prototype.copyClonedWidgetChildren.call(this, model); + _copyClonedWidgetChildren: function (model) { + ccui.Widget.prototype._copyClonedWidgetChildren.call(this, model); }, - copySpecialProperties: function (layout) { + _copySpecialProperties: function (layout) { this.setBackGroundImageScale9Enabled(layout._backGroundScale9Enabled); this.setBackGroundImage(layout._backGroundImageFileName, layout._bgImageTexType); this.setBackGroundImageCapInsets(layout._backGroundImageCapInsets); diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 4ba29fbd30..47329a11b0 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -122,8 +122,8 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ }, clone:function(){ - var parameter = this.createCloneInstance(); - parameter.copyProperties(this); + var parameter = this._createCloneInstance(); + parameter._copyProperties(this); return parameter; }, @@ -131,7 +131,7 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * create clone instance. * @returns {ccui.LayoutParameter} */ - createCloneInstance:function(){ + _createCloneInstance:function(){ return ccui.LayoutParameter.create(); }, @@ -139,7 +139,7 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * copy properties * @param {ccui.LayoutParameter} model */ - copyProperties:function(model){ + _copyProperties:function(model){ this._margin = model._margin; } }); @@ -195,7 +195,7 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL * create clone instance. * @returns {ccui.LinearLayoutParameter} */ - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.LinearLayoutParameter.create(); }, @@ -203,8 +203,8 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL * copy properties * @param {ccui.LinearLayoutParameter} model */ - copyProperties: function (model) { - ccui.LayoutParameter.prototype.copyProperties.call(this, model); + _copyProperties: function (model) { + ccui.LayoutParameter.prototype._copyProperties.call(this, model); var parameter = model; if(parameter){ this.setAlign(parameter._relativeAlign); @@ -308,7 +308,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat * create clone instance. * @returns {ccui.RelativeLayoutParameter} */ - createCloneInstance:function(){ + _createCloneInstance:function(){ return ccui.RelativeLayoutParameter.create(); //TODO }, @@ -316,8 +316,8 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat * copy properties * @param {ccui.RelativeLayoutParameter} model */ - copyProperties:function(model){ - ccui.LayoutParameter.prototype.copyProperties.call(this, model); + _copyProperties:function(model){ + ccui.LayoutParameter.prototype._copyProperties.call(this, model); this.setAlign(model._relativeAlign); this.setRelativeToWidgetName(model._relativeWidgetName); this.setRelativeName(model._relativeLayoutName); diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 5d07597d41..490cb36b72 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -229,8 +229,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } } this._normalTextureSize = this._buttonNormalRenderer.getContentSize(); - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._buttonNormalRenderer.setColor(this.getColor()); this._buttonNormalRenderer.setOpacity(this.getOpacity()); @@ -278,8 +278,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } } this._pressedTextureSize = this._buttonClickedRenderer.getContentSize(); - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._buttonDisableRenderer.setColor(this.getColor()); this._buttonDisableRenderer.setOpacity(this.getOpacity()); @@ -327,8 +327,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } } this._disabledTextureSize = this._buttonDisableRenderer.getContentSize(); - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._buttonDisableRenderer.setColor(this.getColor()); this._buttonDisableRenderer.setOpacity(this.getOpacity()); @@ -497,7 +497,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return this._buttonNormalRenderer.isFlippedY(); }, - updateFlippedX: function () { + _updateFlippedX: function () { var flip = this._flippedX ? -1.0 : 1.0; this._titleRenderer.setScaleX(flip); if (this._scale9Enabled) { @@ -511,7 +511,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } }, - updateFlippedY: function () { + _updateFlippedY: function () { var flip = this._flippedY ? -1.0 : 1.0; this._titleRenderer.setScaleY(flip); if (this._scale9Enabled) { @@ -689,7 +689,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonDisableRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, - adaptRenderers: function(){ + _adaptRenderers: function(){ if (this._normalTextureAdaptDirty) { this.normalTextureScaleChangedWithSize(); this._normalTextureAdaptDirty = false; @@ -798,11 +798,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); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 4b44ea1648..3bce0522dc 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -134,15 +134,15 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } - this.backGroundTextureScaleChangedWithSize(); //TODO need test + this.backGroundTextureScaleChangedWithSize(); if (!bgBoxRenderer.textureLoaded()) { this._backGroundBoxRenderer.setContentSize(this._customSize); bgBoxRenderer.addLoadedEventListener(function () { this.backGroundTextureScaleChangedWithSize(); }, this); } - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._backGroundBoxRenderer.setColor(this.getColor()); this._backGroundBoxRenderer.setOpacity(this.getOpacity()); @@ -172,8 +172,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._backGroundSelectedBoxRenderer.setColor(this.getColor()); this._backGroundSelectedBoxRenderer.setOpacity(this.getOpacity()); this._backGroundSelectedBoxRendererAdaptDirty = true; @@ -200,8 +200,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._frontCrossRenderer.setColor(this.getColor()); this._frontCrossRenderer.setOpacity(this.getOpacity()); this._frontCrossRendererAdaptDirty = true; @@ -228,8 +228,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._backGroundBoxDisabledRenderer.setColor(this.getColor()); this._backGroundBoxDisabledRenderer.setOpacity(this.getOpacity()); this._backGroundBoxDisabledRendererAdaptDirty = true; @@ -256,8 +256,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); this._frontCrossDisabledRenderer.setColor(this.getColor()); this._frontCrossDisabledRenderer.setOpacity(this.getOpacity()); this._frontCrossDisabledRendererAdaptDirty = true; @@ -312,9 +312,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_UNSELECTED); }, - releaseUpEvent: function(){ - ccui.Widget.prototype.releaseUpEvent.call(this); - + _releaseUpEvent: function(){ + ccui.Widget.prototype._releaseUpEvent.call(this); if (this._isSelected){ this.setSelectedState(false); this.unSelectedEvent(); @@ -342,7 +341,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ return this._backGroundBoxRenderer.getContentSize(); }, - updateFlippedX: function () { + _updateFlippedX: function () { this._backGroundBoxRenderer.setFlippedX(this._flippedX); this._backGroundSelectedBoxRenderer.setFlippedX(this._flippedX); this._frontCrossRenderer.setFlippedX(this._flippedX); @@ -350,7 +349,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledRenderer.setFlippedX(this._flippedX); }, - updateFlippedY: function () { + _updateFlippedY: function () { this._backGroundBoxRenderer.setFlippedY(this._flippedY); this._backGroundSelectedBoxRenderer.setFlippedY(this._flippedY); this._frontCrossRenderer.setFlippedY(this._flippedY); @@ -524,11 +523,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ return "CheckBox"; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.CheckBox.create(); }, - copySpecialProperties: function (uiCheckBox) { + _copySpecialProperties: function (uiCheckBox) { if (uiCheckBox instanceof ccui.CheckBox) { this.loadTextureBackGround(uiCheckBox._backGroundFileName, uiCheckBox._backGroundTexType); this.loadTextureBackGroundSelected(uiCheckBox._backGroundSelectedFileName, uiCheckBox._backGroundSelectedTexType); @@ -542,7 +541,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } }, - adaptRenderers: function(){ + _adaptRenderers: function(){ if (this._backGroundBoxRendererAdaptDirty){ this.backGroundTextureScaleChangedWithSize(); this._backGroundBoxRendererAdaptDirty = false; diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 6611f8305c..d297890a57 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -110,8 +110,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ imageRenderer.setCapInsets(this._capInsets); } - this.updateFlippedX(); - this.updateFlippedY(); + this._updateFlippedX(); + this._updateFlippedY(); imageRenderer.setColor(this.getColor()); imageRenderer.setOpacity(this.getOpacity()); this._updateContentSizeWithTextureSize(this._imageTextureSize); @@ -127,21 +127,21 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._imageRenderer.setTextureRect(rect); }, - updateFlippedX: function () { + _updateFlippedX: function () { if (this._scale9Enabled) this._imageRenderer.setScaleX(this._flippedX ? -1 : 1); else this._imageRenderer.setFlippedX(this._flippedX); }, - updateFlippedY: function () { + _updateFlippedY: function () { if (this._scale9Enabled) this._imageRenderer.setScaleY(this._flippedY ? -1 : 1); else this._imageRenderer.setFlippedY(this._flippedY); }, - adaptRenderers: function(){ + _adaptRenderers: function(){ if (this._imageRendererAdaptDirty){ this.imageTextureScaleChangedWithSize(); this._imageRendererAdaptDirty = false; @@ -296,11 +296,11 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, - createCloneInstance:function(){ + _createCloneInstance:function(){ return ccui.ImageView.create(); }, - copySpecialProperties: function (imageView) { + _copySpecialProperties: function (imageView) { if(imageView instanceof ccui.ImageView){ this._prevIgnoreSize = imageView._prevIgnoreSize; this.setScale9Enabled(imageView._scale9Enabled); diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 3934ea2d8c..866c4cb5bd 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -315,7 +315,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } }, - adaptRenderers: function(){ + _adaptRenderers: function(){ if (this._barRendererAdaptDirty){ this.barRendererScaleChangedWithSize(); this._barRendererAdaptDirty = false; @@ -335,11 +335,11 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ return "LoadingBar"; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.LoadingBar.create(); }, - copySpecialProperties: function (loadingBar) { + _copySpecialProperties: function (loadingBar) { if(loadingBar instanceof ccui.LoadingBar){ this._prevIgnoreSize = loadingBar._prevIgnoreSize; this.setScale9Enabled(loadingBar._scale9Enabled); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 218715b89b..b1536d2b63 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -500,18 +500,15 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarRendererDirty = true; }, - adaptRenderers: function(){ - if (this._barRendererAdaptDirty) - { + _adaptRenderers: function(){ + if (this._barRendererAdaptDirty) { this.barRendererScaleChangedWithSize(); this._barRendererAdaptDirty = false; } - if (this._progressBarRendererDirty) - { + if (this._progressBarRendererDirty) { this.progressBarRendererScaleChangedWithSize(); this._progressBarRendererDirty = false; } - }, getVirtualRendererSize: function(){ @@ -630,11 +627,11 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ return "Slider"; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.Slider.create(); }, - copySpecialProperties: function (slider) { + _copySpecialProperties: function (slider) { this._prevIgnoreSize = slider._prevIgnoreSize; this.setScale9Enabled(slider._scale9Enabled); this.loadBarTexture(slider._textureFile, slider._barTexType); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 13d372ef78..44208463b1 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -276,16 +276,18 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, - updateFlippedX: function () { - + _updateFlippedX: function () { if (this._flippedX) - { this._labelRenderer.setScaleX(-1.0); - } else - { this._labelRenderer.setScaleX(1.0); - } + }, + + _updateFlippedY: function(){ + if (this._flippedY) + this._labelRenderer.setScaleY(-1.0); + else + this._labelRenderer.setScaleY(1.0); }, _onSizeChanged: function () { @@ -293,7 +295,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRendererAdaptDirty = true; }, - adaptRenderers: function(){ + _adaptRenderers: function(){ if (this._labelRendererAdaptDirty) { this.labelScaleChangedWithSize(); @@ -360,7 +362,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRenderer.disableEffect(); }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.Text.create(); }, @@ -413,10 +415,6 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ // return this.isTouchScaleChangeEnabled(); // }, // -// updateFlippedY: function () { -// this._labelRenderer.setFlippedY(this._flippedY); -// }, -// // /** // * override "setAnchorPoint" of widget. // * @param {cc.Point|Number} point The anchor point of UILabel or The anchor point.x of UILabel. @@ -454,7 +452,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ // return this._labelRenderer._getHeight(); // }, - copySpecialProperties: function (uiLabel) { + _copySpecialProperties: function (uiLabel) { if(uiLabel instanceof ccui.Label){ this.setFontName(uiLabel._fontName); this.setFontSize(uiLabel.getFontSize()); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index fae6200c08..3c67950470 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -136,9 +136,8 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._labelAtlasRendererAdaptDirty = true; }, - adaptRenderers: function(){ - if (this._labelAtlasRendererAdaptDirty) - { + _adaptRenderers: function(){ + if (this._labelAtlasRendererAdaptDirty) { this.labelAtlasScaleChangedWithSize(); this._labelAtlasRendererAdaptDirty = false; } @@ -186,14 +185,13 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ return "LabelAtlas"; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.TextAtlas.create(); }, - copySpecialProperties: function (labelAtlas) { - if (labelAtlas){ + _copySpecialProperties: function (labelAtlas) { + if (labelAtlas) this.setProperty(labelAtlas._stringValue, labelAtlas._charMapFileName, labelAtlas._itemWidth, labelAtlas._itemHeight, labelAtlas._startCharMap); - } } diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index c3647667e6..47fd9edc2d 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -119,12 +119,11 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo this._labelBMFontRendererAdaptDirty = true; }, - adaptRenderers: function(){ + _adaptRenderers: function(){ if (this._labelBMFontRendererAdaptDirty){ this.labelBMFontScaleChangedWithSize(); this._labelBMFontRendererAdaptDirty = false; } - }, getVirtualRendererSize: function(){ @@ -203,15 +202,15 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo */ getDescription: function () { return "LabelBMFont"; -// }, -// -// createCloneInstance: function () { -// return ccui.TextBMFont.create(); -// }, -// -// copySpecialProperties: function (labelBMFont) { -// this.setFntFile(labelBMFont._fntFileName); -// this.setText(labelBMFont._stringValue); + }, + + _createCloneInstance: function () { + return ccui.TextBMFont.create(); + }, + + _copySpecialProperties: function (labelBMFont) { + this.setFntFile(labelBMFont._fntFileName); + this.setString(labelBMFont._stringValue); } }); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 7828902ac2..ca6214a95f 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -307,39 +307,26 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._useTouchArea = enable; }, - adaptRenderers: function(){ - if (this._textFieldRendererAdaptDirty) - { + _adaptRenderers: function(){ + if (this._textFieldRendererAdaptDirty) { this.textfieldRendererScaleChangedWithSize(); this._textFieldRendererAdaptDirty = false; } }, hitTest: function(pt){ - if (this._useTouchArea) - { + if (this._useTouchArea) { var nsp = this.convertToNodeSpace(pt); var bb = cc.rect( -this._touchWidth * this._anchorPoint.x, -this._touchHeight * this._anchorPoint.y, this._touchWidth, this._touchHeight ); - if ( - nsp.x >= bb.origin.x && - nsp.x <= bb.origin.x + bb.size.width && - nsp.y >= bb.origin.y && - nsp.y <= bb.origin.y + bb.size.height - ) - { - return true; - } - } - else - { - return ccui.Widget.prototype.hitTest.call(this, pt); - } - return false; + return ( nsp.x >= bb.x && nsp.x <= bb.x + bb.width && + nsp.y >= bb.y && nsp.y <= bb.y + bb.height ); + } else + return ccui.Widget.prototype.hitTest.call(this, pt); }, /** @@ -768,11 +755,11 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRender.attachWithIME(); }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.TextField.create(); }, - copySpecialProperties: function (textField) { + _copySpecialProperties: function (textField) { this.setString(textField._textFieldRender.getString()); this.setPlaceHolder(textField.getString()); this.setFontSize(textField._textFieldRender.getFontSize()); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 399d600022..e799e8a093 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -466,11 +466,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ return "ListView"; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.ListView.create(); }, - copyClonedWidgetChildren: function (model) { + _copyClonedWidgetChildren: function (model) { var arrayItems = model.getItems(); for (var i = 0; i < arrayItems.length; i++) { var item = arrayItems[i]; @@ -478,8 +478,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } }, - copySpecialProperties: function (listView) { - ccui.ScrollView.prototype.copySpecialProperties.call(this, listView); + _copySpecialProperties: function (listView) { + ccui.ScrollView.prototype._copySpecialProperties.call(this, listView); this.setItemModel(listView._model); this.setItemsMargin(listView._itemsMargin); this.setGravity(listView._gravity); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index da5206e295..ebe63cd1fd 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -321,7 +321,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var widgetParent = this.getWidgetParent(); if (widgetParent) widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); - this.moveEvent(); + this._moveEvent(); }, onTouchEnded: function (touch, event) { @@ -502,11 +502,11 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ return "PageView"; }, - createCloneInstance: function () { + _createCloneInstance: function () { return ccui.PageView.create(); }, - copyClonedWidgetChildren: function (model) { + _copyClonedWidgetChildren: function (model) { var arrayPages = model.getPages(); for (var i = 0; i < arrayPages.length; i++) { var page = arrayPages[i]; @@ -514,15 +514,13 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, - copySpecialProperties: function (pageView) { - ccui.Layout.prototype.copySpecialProperties.call(this, pageView); + _copySpecialProperties: function (pageView) { + ccui.Layout.prototype._copySpecialProperties.call(this, pageView); this._eventCallback = pageView._eventCallback; this._pageViewEventListener = pageView._pageViewEventListener; this._pageViewEventSelector = pageView._pageViewEventSelector; } - - // // updateChildrenSize: function () { // if(this._pages){ diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index f6bc9de27f..7f6b442f8b 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1672,17 +1672,17 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return "ScrollView"; }, - createCloneInstance: function(){ + _createCloneInstance: function(){ return ccui.ScrollView.create(); }, - copyClonedWidgetChildren: function (model) { - ccui.Layout.prototype.copyClonedWidgetChildren.call(this, model); + _copyClonedWidgetChildren: function (model) { + ccui.Layout.prototype._copyClonedWidgetChildren.call(this, model); }, - copySpecialProperties: function (scrollView) { + _copySpecialProperties: function (scrollView) { if(scrollView instanceof ccui.ScrollView) { - ccui.Layout.prototype.copySpecialProperties.call(this, scrollView); + ccui.Layout.prototype._copySpecialProperties.call(this, scrollView); this.setInnerContainerSize(scrollView.getInnerContainerSize()); this.setDirection(scrollView.direction); this.setBounceEnabled(scrollView.bounceEnabled); From 001047504d79ab0df270d716a9067e849ba7ff9c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 14:23:29 +0800 Subject: [PATCH 0295/1564] Issue #5704: add some jsDoc document to ccui.Layout --- extensions/ccui/layouts/UILayout.js | 201 ++++++++++++++++++++-------- 1 file changed, 146 insertions(+), 55 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 46fec9a83e..b8a6661f70 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -82,9 +82,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _mask_layer_le: 0, - _loopFocus: false, - __passFocusToChild: false, - _isFocusPassing:false, + _loopFocus: false, //whether enable loop focus or not + __passFocusToChild: false, //on default, it will pass the focus to the next nearest widget + _isFocusPassing:false, //when finding the next focused widget, use this variable to pass focus between layout & widget /** * allocates and initializes a UILayout. @@ -268,7 +268,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ addChild: function (widget, zOrder, tag) { if ((widget instanceof ccui.Widget)) { - this.supplyTheLayoutParameterLackToChild(widget); + this._supplyTheLayoutParameterLackToChild(widget); } ccui.Widget.prototype.addChild.call(this, widget, zOrder, tag); this._doLayoutDirty = true; @@ -277,7 +277,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Remove child widget from ccui.Layout * @param {ccui.Widget} widget - * @param {Boolean} cleanup + * @param {Boolean} [cleanup=true] */ removeChild: function (widget, cleanup) { ccui.Widget.prototype.removeChild.call(this, widget, cleanup); @@ -319,10 +319,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._clippingEnabled) { switch (this._clippingType) { case ccui.Layout.CLIPPING_STENCIL: - this.stencilClippingVisit(ctx); + this._stencilClippingVisit(ctx); break; case ccui.Layout.CLIPPING_SCISSOR: - this.scissorClippingVisit(ctx); + this._scissorClippingVisit(ctx); break; default: break; @@ -337,7 +337,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._doLayout(); }, - stencilClippingVisit: null, + _stencilClippingVisit: null, _stencilClippingVisitForWebGL: function (ctx) { var gl = ctx || cc._renderContext; @@ -571,9 +571,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return cc.ClippingNode.prototype._godhelpme; }, - scissorClippingVisit: null, + _scissorClippingVisit: null, _scissorClippingVisitForWebGL: function (ctx) { - var clippingRect = this.getClippingRect(); + var clippingRect = this._getClippingRect(); var gl = ctx || cc._renderContext; if (this._handleScissor) { gl.enable(gl.SCISSOR_TEST); @@ -602,7 +602,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingStencil.draw = this.__stencilDraw.bind(this); if (this._running) this._clippingStencil.onEnter(); - this.setStencilClippingSize(this._contentSize); + this._setStencilClippingSize(this._contentSize); } else { if (this._running) this._clippingStencil.onExit(); @@ -636,7 +636,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this._clippingType; }, - setStencilClippingSize: function (size) { + _setStencilClippingSize: function (size) { if (this._clippingEnabled && this._clippingType == ccui.Layout.CLIPPING_STENCIL) { var rect = []; rect[0] = cc.p(0, 0); @@ -653,7 +653,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._doLayout(); }, - getClippingRect: function () { + _getClippingRect: function () { if (this._clippingRectDirty) { var worldPos = this.convertToWorldSpace(cc.p(0, 0)); var t = this.nodeToWorldTransform(); @@ -679,7 +679,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } if (this._clippingParent) { - parentClippingRect = this._clippingParent.getClippingRect(); + parentClippingRect = this._clippingParent._getClippingRect(); var finalX = worldPos.x - (scissorWidth * this._anchorPoint.x); var finalY = worldPos.y - (scissorHeight * this._anchorPoint.y); var finalWidth = scissorWidth; @@ -727,7 +727,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); - this.setStencilClippingSize(this._contentSize); + this._setStencilClippingSize(this._contentSize); this._doLayoutDirty = true; this._clippingRectDirty = true; if (this._backGroundImage) { @@ -751,21 +751,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {Boolean} able true that use scale9 renderer, false otherwise. */ setBackGroundImageScale9Enabled: function (able) { - if (this._backGroundScale9Enabled == able) { + if (this._backGroundScale9Enabled == able) return; - } this.removeProtectedChild(this._backGroundImage); - //cc.Node.prototype.removeChild.call(this, this._backGroundImage, true); this._backGroundImage = null; this._backGroundScale9Enabled = able; - /* if (this._backGroundScale9Enabled) { - this._backGroundImage = cc.Scale9Sprite.create(); - } - else { - this._backGroundImage = cc.Sprite.create(); - } - cc.Node.prototype.addChild.call(this, this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1);*/ - this.addBackGroundImage(); + this._addBackGroundImage(); this.setBackGroundImage(this._backGroundImageFileName, this._bgImageTexType); this.setBackGroundImageCapInsets(this._backGroundImageCapInsets); }, @@ -788,7 +779,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return; texType = texType || ccui.Widget.LOCAL_TEXTURE; if (this._backGroundImage == null) - this.addBackGroundImage(); + this._addBackGroundImage(); this._backGroundImageFileName = fileName; this._bgImageTexType = texType; if (this._backGroundScale9Enabled) { @@ -840,7 +831,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this._backGroundImageCapInsets; }, - supplyTheLayoutParameterLackToChild: function (locChild) { + _supplyTheLayoutParameterLackToChild: function (locChild) { if (!locChild) { return; } @@ -866,13 +857,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * init background image renderer. */ - addBackGroundImage: function () { + _addBackGroundImage: function () { if (this._backGroundScale9Enabled) { this._backGroundImage = cc.Scale9Sprite.create(); this._backGroundImage.setPreferredSize(this._contentSize); - } else { + } else this._backGroundImage = cc.Sprite.create(); - } this.addProtectedChild(this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1); this._backGroundImage.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, @@ -1117,7 +1107,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ for (var i = 0; i < layoutChildrenArray.length; i++) { locChild = layoutChildrenArray[i]; if(locChild instanceof ccui.Widget) - this.supplyTheLayoutParameterLackToChild(locChild); + this._supplyTheLayoutParameterLackToChild(locChild); } this._doLayoutDirty = true; }, @@ -1208,6 +1198,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } }, + /** + * get the content size of the layout, it will accumulate all its children's content size + * @returns {cc.Size} + * @private + */ _getLayoutAccumulatedSize: function(){ var children = this.getChildren(); var layoutSize = cc.size(0, 0); @@ -1241,6 +1236,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return layoutSize; }, + /** + * When the layout get focused, it the layout pass the focus to its child, it will use this method to determine which child
    + * will get the focus. The current algorithm to determine which child will get focus is nearest-distance-priority algorithm + * @param {Number} direction next focused widget direction + * @param {ccui.Widget} baseWidget + * @returns {Number} + * @private + */ _findNearestChildWidgetIndex: function(direction, baseWidget){ if (baseWidget == null || baseWidget == this) return this._findFirstFocusEnabledWidgetIndex(); @@ -1257,7 +1260,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (w && w instanceof ccui.Widget && w.isFocusEnabled()) { var length = (w instanceof ccui.Layout)? w._calculateNearestDistance(baseWidget) : cc.pLength(cc.pSub(this._getWorldCenterPoint(w), widgetPosition)); - if (length < distance){ found = index; distance = length; @@ -1267,11 +1269,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } return found; } - cc.assert(0, "invalid focus direction!"); + cc.log("invalid focus direction!"); return 0; }, - _findFarestChildWidgetIndex: function(direction, baseWidget){ + /** + * When the layout get focused, it the layout pass the focus to its child, it will use this method to determine which child + * will get the focus. The current algorithm to determine which child will get focus is farthest-distance-priority algorithm + * @param {Number} direction next focused widget direction + * @param {ccui.Widget} baseWidget + * @returns {Number} The index of child widget in the container + * @private + */ + _findFarthestChildWidgetIndex: function(direction, baseWidget){ if (baseWidget == null || baseWidget == this) return this._findFirstFocusEnabledWidgetIndex(); @@ -1284,9 +1294,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var widgetPosition = this._getWorldCenterPoint(baseWidget); while (index < count) { if (w && w instanceof ccui.Widget && w.isFocusEnabled()) { - var length = (w instanceof ccui.Layout)?w._calculateFarestDistance(baseWidget) + var length = (w instanceof ccui.Layout)?w._calculateFarthestDistance(baseWidget) : cc.pLength(cc.pSub(this._getWorldCenterPoint(w), widgetPosition)); - if (length > distance){ found = index; distance = length; @@ -1296,10 +1305,16 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } return found; } - cc.assert(0, "invalid focus direction!!!"); + cc.log("invalid focus direction!!!"); return 0; }, + /** + * calculate the nearest distance between the baseWidget and the children of the layout + * @param {ccui.Widget} baseWidget the base widget which will be used to calculate the distance between the layout's children and itself + * @returns {Number} return the nearest distance between the baseWidget and the layout's children + * @private + */ _calculateNearestDistance: function(baseWidget){ var distance = cc.FLT_MAX; var widgetPosition = this._getWorldCenterPoint(baseWidget); @@ -1316,14 +1331,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ else continue; } - if (length < distance) distance = length; } return distance; }, - _calculateFarestDistance:function(baseWidget){ + /** + * calculate the farthest distance between the baseWidget and the children of the layout + * @param baseWidget + * @returns {number} + * @private + */ + _calculateFarthestDistance:function(baseWidget){ var distance = -cc.FLT_MAX; var widgetPosition = this._getWorldCenterPoint(baseWidget); var locChildren = this._children; @@ -1332,7 +1352,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var layout = locChildren[i]; var length; if (layout instanceof ccui.Layout) - length = layout._calculateFarestDistance(baseWidget); + length = layout._calculateFarthestDistance(baseWidget); else { if (layout instanceof ccui.Widget && layout.isFocusEnabled()) { var wPosition = this._getWorldCenterPoint(w); @@ -1347,6 +1367,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return distance; }, + /** + * when a layout pass the focus to it's child, use this method to determine which algorithm to use, nearest or farthest distance algorithm or not + * @param direction + * @param baseWidget + * @private + */ _findProperSearchingFunctor: function(direction, baseWidget){ if (baseWidget == null) return; @@ -1357,26 +1383,31 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (previousWidgetPosition.x > widgetPosition.x) this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); else - this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); }else if(direction == ccui.Widget.RIGHT){ if (previousWidgetPosition.x > widgetPosition.x) - this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); else this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); }else if(direction == ccui.Widget.DOWN){ if (previousWidgetPosition.y > widgetPosition.y) this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); else - this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); }else if(direction == ccui.Widget.UP){ if (previousWidgetPosition.y < widgetPosition.y) this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); else - this.onPassFocusToChild = this._findFarestChildWidgetIndex.bind(this); + this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); }else cc.assert(0, "invalid direction!"); }, + /** + * find the first non-layout widget in this layout + * @returns {ccui.Widget} + * @private + */ _findFirstNonLayoutWidget:function(){ var locChildren = this._children; for(var i = 0, len = locChildren.length; i < len; i++) { @@ -1393,6 +1424,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return null; }, + /** + * find the first focus enabled widget index in the layout, it will recursive searching the child widget + * @returns {number} + * @private + */ _findFirstFocusEnabledWidgetIndex: function(){ var index = 0, locChildren = this.getChildren(); var count = locChildren.length; @@ -1402,13 +1438,17 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return index; index++; } - //cc.assert(0, "invalid operation"); return 0; }, + /** + * find a focus enabled child Widget in the layout by index + * @param index + * @returns {*} + * @private + */ _findFocusEnabledChildWidgetByIndex: function(index){ var widget = this._getChildWidgetByIndex(index); - if (widget){ if (widget.isFocusEnabled()) return widget; @@ -1418,12 +1458,25 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return null; }, + /** + * get the center point of a widget in world space + * @param {ccui.Widget} widget + * @returns {cc.Point} + * @private + */ _getWorldCenterPoint: function(widget){ //FIXEDME: we don't need to calculate the content size of layout anymore var widgetSize = widget instanceof ccui.Layout ? widget._getLayoutAccumulatedSize() : widget.getContentSize(); return widget.convertToWorldSpace(cc.p(widgetSize.width /2, widgetSize.height /2)); }, + /** + * this method is called internally by nextFocusedWidget. When the dir is Right/Down, then this method will be called + * @param {Number} direction + * @param {ccui.Widget} current the current focused widget + * @returns {ccui.Widget} the next focused widget + * @private + */ _getNextFocusedWidget: function(direction, current){ var nextWidget = null, locChildren = this._children; var previousWidgetPos = locChildren.indexOf(current); @@ -1479,6 +1532,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } }, + /** + * this method is called internally by nextFocusedWidget. When the dir is Left/Up, then this method will be called + * @param direction + * @param {ccui.Widget} current the current focused widget + * @returns {ccui.Widget} the next focused widget + * @private + */ _getPreviousFocusedWidget: function(direction, current){ var nextWidget = null, locChildren = this._children; var previousWidgetPos = locChildren.indexOf(current); @@ -1531,6 +1591,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } }, + /** + * find the nth element in the _children array. Only the Widget descendant object will be returned + * @param {Number} index + * @returns {ccui.Widget} + * @private + */ _getChildWidgetByIndex: function (index) { var locChildren = this._children; var size = locChildren.length; @@ -1554,6 +1620,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return null; }, + /** + * whether it is the last element according to all their parents + * @param {ccui.Widget} widget + * @param {Number} direction + * @returns {Boolean} + * @private + */ _isLastWidgetInContainer:function(widget, direction){ var parent = widget.getParent(); if (parent instanceof ccui.Layout) @@ -1597,13 +1670,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (direction == ccui.Widget.RIGHT) return this._isLastWidgetInContainer(parent, direction); - }else { - cc.assert(0, "invalid layout Type"); + } else { + cc.log("invalid layout Type"); return false; } - return false; }, + /** + * Lookup any parent widget with a layout type as the direction, if the layout is loop focused, then return true, otherwise it returns false. + * @param {ccui.Widget} widget + * @param {Number} direction + * @returns {Boolean} + * @private + */ _isWidgetAncestorSupportLoopFocus: function(widget, direction){ var parent = widget.getParent(); if (parent == null) @@ -1627,12 +1706,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this._isWidgetAncestorSupportLoopFocus(parent, direction); }, + /** + * pass the focus to the layout's next focus enabled child + * @param {Number} direction + * @param {ccui.Widget} current + * @returns {ccui.Widget} + * @private + */ _passFocusToChild: function(direction, current){ if (this._checkFocusEnabledChild()) { var previousWidget = ccui.Widget.getCurrentFocusedWidget(); this._findProperSearchingFunctor(direction, previousWidget); - var index = this.onPassFocusToChild(direction, previousWidget); //TODO need check + var index = this.onPassFocusToChild(direction, previousWidget); var widget = this._getChildWidgetByIndex(index); if (widget instanceof ccui.Layout) { @@ -1646,6 +1732,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this; }, + /** + * If there are no focus enabled child in the layout, it will return false, otherwise it returns true + * @returns {boolean} + * @private + */ _checkFocusEnabledChild: function(){ var locChildren = this._children; for(var i = 0, len = locChildren.length; i < len; i++){ @@ -1695,11 +1786,11 @@ ccui.Layout._sharedCache = null; if (cc._renderType == cc._RENDER_TYPE_WEBGL) { //WebGL - ccui.Layout.prototype.stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForWebGL; - ccui.Layout.prototype.scissorClippingVisit = ccui.Layout.prototype._scissorClippingVisitForWebGL; + ccui.Layout.prototype._stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForWebGL; + ccui.Layout.prototype._scissorClippingVisit = ccui.Layout.prototype._scissorClippingVisitForWebGL; } else { - ccui.Layout.prototype.stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; - ccui.Layout.prototype.scissorClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; + ccui.Layout.prototype._stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; + ccui.Layout.prototype._scissorClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; } ccui.Layout._getSharedCache = function () { return (cc.ClippingNode._sharedCache) || (cc.ClippingNode._sharedCache = cc.newElement("canvas")); From a4b2adb8997836bdbd60752d4afe92496953e577 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 15:37:08 +0800 Subject: [PATCH 0296/1564] Issue #5704: refactor ccui.LayoutManager for better performance. --- extensions/ccui/base-classes/UIWidget.js | 1 - extensions/ccui/layouts/UILayout.js | 18 +------- extensions/ccui/layouts/UILayoutManager.js | 50 ++++++++++------------ extensions/ccui/uiwidgets/UITextField.js | 9 ++-- 4 files changed, 27 insertions(+), 51 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index cfa850bde6..b79e9f404d 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1228,7 +1228,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setBright(widget.isBright()); this.setTouchEnabled(widget.isTouchEnabled()); this.setLocalZOrder(widget.getLocalZOrder()); - this.setUpdateEnabled(widget.isUpdateEnabled()); this.setTag(widget.getTag()); this.setName(widget.getName()); this.setActionTag(widget.getActionTag()); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index b8a6661f70..1e959e0b7c 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1131,28 +1131,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (!this._doLayoutDirty) return; - var executant = this._createLayoutManager(); //TODO create a layout manager every calling _doLayout? + var executant = ccui.getLayoutManager(this._layoutType); if (executant) executant._doLayout(this); this._doLayoutDirty = false; }, - _createLayoutManager: function(){ - var layoutMgr = null; - switch (this._layoutType) { - case ccui.Layout.LINEAR_VERTICAL: - layoutMgr = ccui.LinearVerticalLayoutManager.create(); - break; - case ccui.Layout.LINEAR_HORIZONTAL: - layoutMgr = ccui.LinearHorizontalLayoutManager.create(); - break; - case ccui.Layout.RELATIVE: - layoutMgr = ccui.RelativeLayoutManager.create(); - break; - } - return layoutMgr; - }, - _getLayoutContentSize: function(){ return this.getContentSize(); }, diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index 903acc4b70..c527a783dc 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -22,11 +22,19 @@ THE SOFTWARE. ****************************************************************************/ -ccui.LayoutManager = ccui.Class.extend({ - _doLayout: function(layout){} -}); +ccui.getLayoutManager = function (type) { + switch (type) { + case ccui.Layout.LINEAR_VERTICAL: + return ccui.linearVerticalLayoutManager; + case ccui.Layout.LINEAR_HORIZONTAL: + return ccui.linearHorizontalLayoutManager; + case ccui.Layout.RELATIVE: + return ccui.relativeLayoutManager; + } + return null; +}; -ccui.LinearVerticalLayoutManager = ccui.LayoutManager.extend({ +ccui.linearVerticalLayoutManager = { _doLayout: function(layout){ var layoutSize = layout._getLayoutContentSize(); var container = layout._getLayoutElements(); @@ -65,13 +73,9 @@ ccui.LinearVerticalLayoutManager = ccui.LayoutManager.extend({ } } } -}); - -ccui.LinearVerticalLayoutManager.create = function(){ - return new ccui.LinearVerticalLayoutManager(); }; -ccui.LinearHorizontalLayoutManager = ccui.LayoutManager.extend({ +ccui.linearHorizontalLayoutManager = { _doLayout: function(layout){ var layoutSize = layout._getLayoutContentSize(); var container = layout._getLayoutElements(); @@ -108,15 +112,11 @@ ccui.LinearHorizontalLayoutManager = ccui.LayoutManager.extend({ } } } -}); - -ccui.LinearHorizontalLayoutManager.create = function(){ - return new ccui.LinearHorizontalLayoutManager(); }; -ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ - _unlayoutChildCount: null, - _widgetChildren: null, +ccui.relativeLayoutManager = { + _unlayoutChildCount: 0, + _widgetChildren: [], _widget: null, _finalPositionX:0, _finalPositionY:0, @@ -135,11 +135,11 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ if (layoutParameter._put) continue; - var ret = this._caculateFinalPositionWithRelativeWidget(layout); + var ret = this._calculateFinalPositionWithRelativeWidget(layout); if (!ret) continue; - this._caculateFinalPositionWithRelativeAlign(); + this._calculateFinalPositionWithRelativeAlign(); this._widget.setPosition(this._finalPositionX, this._finalPositionY); layoutParameter._put = true; @@ -152,17 +152,17 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ _getAllWidgets: function(layout){ var container = layout._getLayoutElements(); - var widgetChildren = []; //TODO + var locWidgetChildren = this._widgetChildren; + locWidgetChildren.length = 0; for (var i = 0, len = container.length; i < len; i++){ var child = container[i]; if (child) { var layoutParameter = child.getLayoutParameter(); layoutParameter._put = false; this._unlayoutChildCount++; - widgetChildren.push(child); + locWidgetChildren.push(child); } } - return widgetChildren; }, _getRelativeWidget: function(widget){ @@ -187,7 +187,7 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ return relativeWidget; }, - _caculateFinalPositionWithRelativeWidget: function(layout){ //TODO typo + _calculateFinalPositionWithRelativeWidget: function(layout){ var locWidget = this._widget; var ap = locWidget.getAnchorPoint(); var cs = locWidget.getContentSize(); @@ -366,7 +366,7 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ return true; }, - _caculateFinalPositionWithRelativeAlign: function(){ + _calculateFinalPositionWithRelativeAlign: function(){ var layoutParameter = this._widget.getLayoutParameter(); var mg = layoutParameter.getMargin(); @@ -453,8 +453,4 @@ ccui.RelativeLayoutManager = ccui.LayoutManager.extend({ break; } } -}); - -ccui.RelativeLayoutManager.create = function(){ - return new ccui.RelativeLayoutManager(); }; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index ca6214a95f..7d458a4412 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -43,6 +43,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ _deleteBackward: false, _className: "UICCTextField", _textFieldRendererAdaptDirty: true, + ctor: function () { cc.TextFieldTTF.prototype.ctor.call(this); this.maxLengthEnabled = false; @@ -55,6 +56,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ this._deleteBackward = false; }, onEnter: function () { + cc.TextFieldTTF.prototype.onEnter.call(this); cc.TextFieldTTF.prototype.setDelegate.call(this, this); }, //CCTextFieldDelegate @@ -280,12 +282,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ onEnter: function () { ccui.Widget.prototype.onEnter.call(this); - this.setUpdateEnabled(true); - }, - - onExit:function(){ - this.setUpdateEnabled(false); - ccui.Layout.prototype.onExit.call(this); + this.scheduleUpdate(); }, _initRenderer: function () { From faddee296117550c0e7e328a7604c09fe6b233a6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 15 Jul 2014 16:26:20 +0800 Subject: [PATCH 0297/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Fix position bug --- extensions/cocostudio/armature/CCArmature.js | 104 ++------ extensions/cocostudio/armature/CCBone.js | 4 +- .../armature/animation/CCArmatureAnimation.js | 2 +- .../armature/animation/CCProcessBase.js | 4 +- .../cocostudio/armature/animation/CCTween.js | 2 +- .../cocostudio/armature/display/CCSkin.js | 232 ++++++++++++++---- .../armature/utils/CCDataReaderHelper.js | 66 +++-- 7 files changed, 249 insertions(+), 165 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 02d766bbd2..c2cd841849 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -300,6 +300,13 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ return this._boneDic; }, + /** + * @deprecated + */ + nodeToParentTransform: function(){ + return this.getNodeToParentTransform(); + }, + getNodeToParentTransform: function(){ if (this._transformDirty) this._armatureTransformDirty = true; @@ -375,62 +382,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = false; }, - draw: function (renderer, transform, flags) { - - var len = this._children.length; - for (var i=0; i= ccs.CONST_VERSION_COMBINED) { + if (this._armature.getArmatureData().dataVersion >= 0.3) { var zorder = this._tweenData.zOrder + this._boneData.zOrder; this.setLocalZOrder(zorder); } diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index b642c5c352..81968b9432 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -228,7 +228,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# var durationTween = this._movementData.durationTween == 0 ? this._rawDuration : this._movementData.durationTween; var tweenEasing = this._movementData.tweenEasing; - loop = (loop < 0) ? this._movementData.loop : loop; + loop = (!loop || loop < 0) ? this._movementData.loop : loop; this._onMovementList = false; diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index 74c571659c..03c4ea518d 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -167,7 +167,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ return false; } - var locNextFrameIndex = this._nextFrameIndex; + var locNextFrameIndex = this._nextFrameIndex === undefined ? 0 : this._nextFrameIndex; var locCurrentFrame = this._currentFrame; if (locNextFrameIndex <= 0) { this._currentPercent = 1; @@ -188,7 +188,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ */ locCurrentFrame = ccs.fmodf(locCurrentFrame, locNextFrameIndex); } - this._currentFrame = locCurrentFrame + this._currentFrame = locCurrentFrame; this.updateHandler(); return true; }, diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index c5ea290f78..99c8d39d8d 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -162,7 +162,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * update will call this handler, you can handle your logic here */ updateHandler:function () { - var locCurrentPercent = this._currentPercent; + var locCurrentPercent = this._currentPercent || 1; var locLoopType = this._loopType; if (locCurrentPercent >= 1) { switch (locLoopType) { diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 1e49cc5788..4722c65030 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -53,11 +53,20 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ initWithSpriteFrameName: function (spriteFrameName) { if(spriteFrameName == "") return false; - var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); + var pFrame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); + + this._displayName = spriteFrameName; + var ret = true; + if(pFrame){ + this.initWithSpriteFrame(pFrame); + }else{ + cc.log("Cann't find CCSpriteFrame with %s. Please check your .plist file", spriteFrameName); + ret = false; + } + this._displayName = spriteFrameName; - if(frame) - return this.initWithSpriteFrame(frame); - return false; + + return ret; }, initWithFile: function (fileName) { @@ -75,14 +84,17 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this.setRotationY(cc.radiansToDegrees(-skinData.skewY)); this.setPosition(skinData.x, skinData.y); - var localTransform = this.nodeToParentTransform(); - var skinTransform = this._skinTransform; - skinTransform.a = localTransform.a; - skinTransform.b = localTransform.b; - skinTransform.c = localTransform.c; - skinTransform.d = localTransform.d; - skinTransform.tx = localTransform.tx; - skinTransform.ty = localTransform.ty; +// var localTransform = this.nodeToParentTransform(); +// var skinTransform = this._skinTransform; +// skinTransform.a = localTransform.a; +// skinTransform.b = localTransform.b; +// skinTransform.c = localTransform.c; +// skinTransform.d = localTransform.d; +// skinTransform.tx = localTransform.tx; +// skinTransform.ty = localTransform.ty; + + //this.getNodeToParentTransform + this._skinTransform = this.nodeToParentTransform(); this.updateArmatureTransform(); }, @@ -90,42 +102,148 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return this._skinData; }, - setBone: function (bone) { - this.bone = bone; + updateArmatureTransform: function () { + this._transform = cc.affineTransformConcat(this.bone.getNodeToArmatureTransform(), this._skinTransform); +// var locTransform = this._transform; +// var locArmature = this._armature; +// if (locArmature && locArmature.getBatchNode()) { +// this._transform = cc.affineTransformConcat(locTransform, locArmature.nodeToParentTransform()); +// } +// if (cc._renderType === cc._RENDER_TYPE_CANVAS) { +// locTransform = this._transform; +// locTransform.b *= -1; +// locTransform.c *= -1; +// locTransform.b = [locTransform.c, locTransform.c = locTransform.b][0]; +// } }, - getBone: function () { - return this.bone; - }, + updateTransform: function(){ + // If it is not visible, or one of its ancestors is not visible, then do nothing: + if( !this._visible) + { + this._quad.br.vertices = this._quad.tl.vertices = this._quad.tr.vertices = this._quad.bl.vertices = cc.p(0, 0); + } + else + { + // + // calculate the Quad based on the Affine Matrix + // - updateArmatureTransform: function () { - this._transform = cc.affineTransformConcat(this.bone.getNodeToArmatureTransform(), this._skinTransform); - var locTransform = this._transform; - var locArmature = this._armature; - if (locArmature && locArmature.getBatchNode()) { - this._transform = cc.affineTransformConcat(locTransform, locArmature.nodeToParentTransform()); + var size = this._rect; + + var x1 = this._offsetPosition.x; + var y1 = this._offsetPosition.y; + + var x2 = x1 + size.width; + var y2 = y1 + size.height; + + var x = this._transform.tx; + var y = this._transform.ty; + + var cr = this._transform.a; + var sr = this._transform.b; + var cr2 = this._transform.c; + var sr2 = -this._transform.d; + var ax = x1 * cr - y1 * sr2 + x; + var ay = x1 * sr + y1 * cr2 + y; + + var bx = x2 * cr - y1 * sr2 + x; + var by = x2 * sr + y1 * cr2 + y; + + var cx = x2 * cr - y2 * sr2 + x; + var cy = x2 * sr + y2 * cr2 + y; + + var dx = x1 * cr - y2 * sr2 + x; + var dy = x1 * sr + y2 * cr2 + y; + + this.SET_VERTEX3F( + this._quad.bl.vertices, + this.RENDER_IN_SUBPIXEL(ax), + this.RENDER_IN_SUBPIXEL(ay), + this._localZOrder + ); + this.SET_VERTEX3F( + this._quad.br.vertices, + this.RENDER_IN_SUBPIXEL(bx), + this.RENDER_IN_SUBPIXEL(by), + this._localZOrder + ); + this.SET_VERTEX3F( + this._quad.tl.vertices, + this.RENDER_IN_SUBPIXEL(dx), + this.RENDER_IN_SUBPIXEL(dy), + this._localZOrder + ); + this.SET_VERTEX3F( + this._quad.tr.vertices, + this.RENDER_IN_SUBPIXEL(cx), + this.RENDER_IN_SUBPIXEL(cy), + this._localZOrder + ); } - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - locTransform = this._transform; - locTransform.b *= -1; - locTransform.c *= -1; - locTransform.b = [locTransform.c, locTransform.c = locTransform.b][0]; + + // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS + if (this._textureAtlas) + { + this._textureAtlas.updateQuad(this._quad, this._textureAtlas.getTotalQuads()); } }, - /** returns a "local" axis aligned bounding box of the node.
    - * The returned box is relative only to its parent. - * @return {cc.Rect} - */ - getBoundingBox: function () { - var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var transForm = this.nodeToParentTransform(); - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - transForm.b *= -1; - transForm.c *= -1; - transForm.b = [transForm.c, transForm.c = transForm.b][0]; + SET_VERTEX3F: function(_v_, _x_, _y_, _z_){ + (_v_).x = (_x_); + (_v_).y = (_y_); + (_v_).z = (_z_); + }, + + RENDER_IN_SUBPIXEL: function(__ARGS__){ + return Math.ceil(__ARGS__); + }, + + getNodeToWorldTransform: function(){ + return cc.affineTransformConcat( + this._bone.getArmature().getNodeToWorldTransform(), + this._transform + ); + }, + + getNodeToWorldTransformAR: function(){ + var displayTransform = this._transform; + var anchorPoint = this._anchorPointInPoints; + + anchorPoint = cc.pointApplyAffineTransform(anchorPoint, displayTransform); + displayTransform.tx = anchorPoint.x; + displayTransform.ty = anchorPoint.y; + + return cc.affineTransformConcat( + displayTransform, + this.bone.getArmature().nodeToWorldTransform() + ); + }, + +// draw: function(renderer, transform, flags){ +//// var mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); +// +// //TODO implement z order +// this._quadCommand.init( +// this._globalZOrder, +// this._texture.getName(), +// this.getGLProgramState(), +// this._blendFunc, +// this._quad, 1, mv); +// renderer.addCommand(this._quadCommand); +// }, + + setBone: function (bone) { + this.bone = bone; + var armature = this.bone.getArmature(); + if(armature) + { + this._armature = armature; } - return cc.rectApplyAffineTransform(rect, transForm); + }, + + getBone: function () { + return this.bone; }, /** @@ -136,19 +254,35 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return this._displayName; }, +// /** returns a "local" axis aligned bounding box of the node.
    +// * The returned box is relative only to its parent. +// * @return {cc.Rect} +// */ +// getBoundingBox: function () { +// var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); +// var transForm = this.nodeToParentTransform(); +// if (cc._renderType === cc._RENDER_TYPE_CANVAS) { +// transForm.b *= -1; +// transForm.c *= -1; +// transForm.b = [transForm.c, transForm.c = transForm.b][0]; +// } +// return cc.rectApplyAffineTransform(rect, transForm); +// }, + + /** + * @deprecated + * @returns {cc.AffineTransform} + */ nodeToWorldTransform: function () { - return cc.affineTransformConcat(this._transform, this.bone.getArmature().nodeToWorldTransform()); + return this.getNodeToWorldTransform(); }, + /** + * @deprecated + * @returns {cc.AffineTransform} + */ nodeToWorldTransformAR: function () { - var displayTransform = this._transform; - var anchorPoint = this._anchorPointInPoints; - - anchorPoint = cc.pointApplyAffineTransform(anchorPoint, displayTransform); - displayTransform.tx = anchorPoint.x; - displayTransform.ty = anchorPoint.y; - - return cc.affineTransformConcat(displayTransform, this.bone.getArmature().nodeToWorldTransform()); + return this.getNodeToWorldTransformAR(); } }); ccs.Skin.prototype.nodeToParentTransform = cc.Node.prototype._nodeToParentTransformForWebGL; diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index a787a73f90..4a4686a37a 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -239,45 +239,45 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var dataQueue = this._dataQueue; _dataInfoMutex.lock(); - if (dataQueue->empty()) + if (dataQueue.empty()) { _dataInfoMutex.unlock(); } else { - DataInfo *pDataInfo = dataQueue->front(); - dataQueue->pop(); + DataInfo *pDataInfo = dataQueue.front(); + dataQueue.pop(); _dataInfoMutex.unlock(); - AsyncStruct *pAsyncStruct = pDataInfo->asyncStruct; + AsyncStruct *pAsyncStruct = pDataInfo.asyncStruct; - if (pAsyncStruct->imagePath != "" && pAsyncStruct->plistPath != "") + if (pAsyncStruct.imagePath != "" && pAsyncStruct.plistPath != "") { _getFileMutex.lock(); - ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str(), pDataInfo->filename.c_str()); + ArmatureDataManager::getInstance().addSpriteFrameFromFile(pAsyncStruct.plistPath.c_str(), pAsyncStruct.imagePath.c_str(), pDataInfo.filename.c_str()); _getFileMutex.unlock(); } - while (!pDataInfo->configFileQueue.empty()) + while (!pDataInfo.configFileQueue.empty()) { - std::string configPath = pDataInfo->configFileQueue.front(); + std::string configPath = pDataInfo.configFileQueue.front(); _getFileMutex.lock(); - ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str(),pDataInfo->filename.c_str()); + ArmatureDataManager::getInstance().addSpriteFrameFromFile((pAsyncStruct.baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct.baseFilePath + configPath + ".png").c_str(),pDataInfo.filename.c_str()); _getFileMutex.unlock(); - pDataInfo->configFileQueue.pop(); + pDataInfo.configFileQueue.pop(); } - Ref* target = pAsyncStruct->target; - SEL_SCHEDULE selector = pAsyncStruct->selector; + Ref* target = pAsyncStruct.target; + SEL_SCHEDULE selector = pAsyncStruct.selector; --_asyncRefCount; if (target && selector) { - (target->*selector)((_asyncRefTotalCount - _asyncRefCount) / (float)_asyncRefTotalCount); - target->release(); + (target.*selector)((_asyncRefTotalCount - _asyncRefCount) / (float)_asyncRefTotalCount); + target.release(); } @@ -287,7 +287,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (0 == _asyncRefCount) { _asyncRefTotalCount = 0; - Director::getInstance()->getScheduler()->unschedule(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this); + Director::getInstance().getScheduler().unschedule(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this); } } }, @@ -1075,12 +1075,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ node.skewX = json[ccs.CONST_A_SKEW_X] || 0; node.skewY = json[ccs.CONST_A_SKEW_Y] || 0; - if (json[ccs.CONST_A_SCALE_X] !== undefined) { - node.scaleX = json[ccs.CONST_A_SCALE_X]; - } - if (json[ccs.CONST_A_SCALE_Y] !== undefined) { - node.scaleY = json[ccs.CONST_A_SCALE_Y]; - } + node.scaleX = json[ccs.CONST_A_SCALE_X] || 1; + node.scaleY = json[ccs.CONST_A_SCALE_Y] || 1; var colorDic = json[ccs.CONST_COLOR_INFO] || null; if (colorDic) { @@ -1095,5 +1091,33 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ node.isUseColorInfo = true; delete colorDic; } +// var colorDic; +// if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) +// { +// colorDic = json[0]; +// if (colorDic) +// { +// node.a = colorDic[ccs.CONST_A_ALPHA] || 255; +// node.r = colorDic[ccs.CONST_A_RED] || 255; +// node.g = colorDic[ccs.CONST_A_GREEN] || 255; +// node.b = colorDic[ccs.CONST_A_BLUE] || 255; +// +// node.isUseColorInfo = true; +// } +// } +// else +// { +// colorDic = json[ccs.CONST_COLOR_INFO] || null; +// if (colorDic) +// { +// node.a = DICTOOL.getIntValue_json(colorDic, A_ALPHA, 255); +// node.r = DICTOOL.getIntValue_json(colorDic, A_RED, 255); +// node.g = DICTOOL.getIntValue_json(colorDic, A_GREEN, 255); +// node.b = DICTOOL.getIntValue_json(colorDic, A_BLUE, 255); +// +// node.isUseColorInfo = true; +// } +// } + } }; \ No newline at end of file From 53067d73f6c48db0984c9dbfccc56bc8b15ac940 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 15 Jul 2014 17:37:54 +0800 Subject: [PATCH 0298/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Fix position bug --- .../armature/animation/CCArmatureAnimation.js | 2 +- .../armature/utils/CCDataReaderHelper.js | 9 ----- .../utils/CCSpriteFrameCacheHelper.js | 36 +++++++++---------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 81968b9432..2db85431aa 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -237,7 +237,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# if (this._rawDuration == 0) { - this._loopType = SINGLE_FRAME; + this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME; } else { diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 4a4686a37a..b9f2c7b7b9 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -747,15 +747,6 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return frameData; }, - - - - - - - - - clear: function () { this._configFileList = []; this._asyncRefCount = 0; diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index 09a33af2b1..1bcae9fed4 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -34,22 +34,22 @@ ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { addSpriteFrameFromFile:function (plistPath, imagePath) { cc.spriteFrameCache.addSpriteFrames(plistPath, imagePath); - } - -// getTexureAtlasWithTexture:function (texture) { -// //todo -// return null; -// var textureName = texture.getName(); -// var atlas = this._textureAtlasDic[textureName]; -// if (atlas == null) { -// atlas = cc.TextureAtlas.create(texture, 20); -// this._textureAtlasDic[textureName] = atlas; -// } -// return atlas; -// }, -// -// clear: function () { -// this._textureAtlasDic = {}; -// this._imagePaths = []; -// } + }, + + getTexureAtlasWithTexture:function (texture) { + //todo + return null; + var textureName = texture.getName(); + var atlas = this._textureAtlasDic[textureName]; + if (atlas == null) { + atlas = cc.TextureAtlas.create(texture, 20); + this._textureAtlasDic[textureName] = atlas; + } + return atlas; + }, + + clear: function () { + this._textureAtlasDic = {}; + this._imagePaths = []; + } }; \ No newline at end of file From 9240b79b281b3b0c8292c4e9bc99c441a513a13a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 18:18:08 +0800 Subject: [PATCH 0299/1564] Fixed #3546: fixed a bug of cc.Layer,cc.LayerColor --- cocos2d/core/layers/CCLayer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 480513f393..451480a3ac 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -156,11 +156,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //visit for canvas _t.sortAllChildren(); - // draw children zOrder < 0 + cc.view._setScaleXYForRenderTexture(); for (i = 0; i < len; i++) { children[i].visit(bakeContext); } - + cc.view._resetScale(); this._cacheDirty = false; } @@ -440,6 +440,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } var child; + cc.view._setScaleXYForRenderTexture(); //visit for canvas if (len > 0) { _t.sortAllChildren(); @@ -457,6 +458,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } } else _t.draw(bakeContext); + cc.view._resetScale(); this._cacheDirty = false; } From 2d8f52e31290e39f2cfbb31679fec518a8bba55f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 18:20:35 +0800 Subject: [PATCH 0300/1564] Issue #5704: refactor cc.Layout --- extensions/ccui/layouts/UILayout.js | 144 ++++++++------------- extensions/ccui/layouts/UILayoutManager.js | 58 +++------ 2 files changed, 74 insertions(+), 128 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 1e959e0b7c..27457264a7 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -245,7 +245,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return false; }, - __stencilDraw: function(ctx){ + __stencilDraw: function(ctx){ //Only for Canvas var locContext = ctx || cc._renderContext; var stencil = this._clippingStencil; var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); @@ -661,20 +661,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var scissorHeight = this._contentSize.height * t.d; var parentClippingRect; var parent = this; - var firstClippingParentFounded = false; + while (parent) { parent = parent.getParent(); - if (parent && parent instanceof ccui.Layout) { - if (parent.isClippingEnabled()) { - if (!firstClippingParentFounded) { - this._clippingParent = parent; - firstClippingParentFounded = true; - } - if (parent._clippingType == ccui.Layout.CLIPPING_SCISSOR) { - this._handleScissor = false; - break; - } - } + if (parent && parent instanceof ccui.Layout && parent.isClippingEnabled()) { + this._clippingParent = parent; + break; } } @@ -691,30 +683,25 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ finalWidth += leftOffset; } var rightOffset = (worldPos.x + scissorWidth) - (parentClippingRect.x + parentClippingRect.width); - if (rightOffset > 0) { + if (rightOffset > 0) finalWidth -= rightOffset; - } var topOffset = (worldPos.y + scissorHeight) - (parentClippingRect.y + parentClippingRect.height); - if (topOffset > 0) { + if (topOffset > 0) finalHeight -= topOffset; - } var bottomOffset = worldPos.y - parentClippingRect.y; if (bottomOffset < 0) { finalY = parentClippingRect.x; finalHeight += bottomOffset; } - if (finalWidth < 0) { + if (finalWidth < 0) finalWidth = 0; - } - if (finalHeight < 0) { + if (finalHeight < 0) finalHeight = 0; - } this._clippingRect.x = finalX; this._clippingRect.y = finalY; this._clippingRect.width = finalWidth; this._clippingRect.height = finalHeight; - } - else { + } else { this._clippingRect.x = worldPos.x - (scissorWidth * this._anchorPoint.x); this._clippingRect.y = worldPos.y - (scissorHeight * this._anchorPoint.y); this._clippingRect.width = scissorWidth; @@ -727,23 +714,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); - this._setStencilClippingSize(this._contentSize); + var locContentSize = this._contentSize; + this._setStencilClippingSize(locContentSize); this._doLayoutDirty = true; this._clippingRectDirty = true; if (this._backGroundImage) { - this._backGroundImage.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); - if (this._backGroundScale9Enabled) { - if (this._backGroundImage instanceof cc.Scale9Sprite) { - this._backGroundImage.setPreferredSize(this._contentSize); - } - } - } - if (this._colorRender) { - this._colorRender.setContentSize(this._contentSize); - } - if (this._gradientRender) { - this._gradientRender.setContentSize(this._contentSize); + this._backGroundImage.setPosition(locContentSize.width * 0.5, locContentSize.height * 0.5); + if (this._backGroundScale9Enabled && this._backGroundImage instanceof cc.Scale9Sprite) + this._backGroundImage.setPreferredSize(locContentSize); } + if (this._colorRender) + this._colorRender.setContentSize(locContentSize); + if (this._gradientRender) + this._gradientRender.setContentSize(locContentSize); }, /** @@ -809,7 +792,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } } this._backGroundImageTextureSize = this._backGroundImage.getContentSize(); - this._backGroundImage.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); + this._backGroundImage.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); this._updateBackGroundImageColor(); }, @@ -876,7 +859,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.removeProtectedChild(this._backGroundImage); this._backGroundImage = null; this._backGroundImageFileName = ""; - this._backGroundImageTextureSize = cc.size(0, 0); + this._backGroundImageTextureSize.width = 0; + this._backGroundImageTextureSize.height = 0; }, /** @@ -948,7 +932,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Sets background color for layout, if color type is Layout.COLOR_SOLID * @param {cc.Color} color - * @param {cc.Color} endColor + * @param {cc.Color} [endColor] */ setBackGroundColor: function (color, endColor) { if (!endColor) { @@ -961,10 +945,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._startColor.r = color.r; this._startColor.g = color.g; this._startColor.b = color.b; - if (this._gradientRender) this._gradientRender.setStartColor(color); - this._endColor = endColor; + + this._endColor.r = endColor.r; + this._endColor.g = endColor.g; + this._endColor.b = endColor.b; if (this._gradientRender) this._gradientRender.setEndColor(endColor); } @@ -1197,13 +1183,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ locSize = layout._getLayoutAccumulatedSize(); layoutSize.width += locSize.width; layoutSize.height += locSize.height; - // C++ layoutSize = layoutSize + layout.getLayoutAccumulatedSize(); } else { if (layout instanceof ccui.Widget) { widgetCount++; - var m = w.getLayoutParameter().getMargin(); - locSize = w.getContentSize(); - // c++ layoutSize = layoutSize + w.getContentSize() + cc.size(m.right + m.left, m.top + m.bottom) * 0.5; + var m = layout.getLayoutParameter().getMargin(); + locSize = layout.getContentSize(); layoutSize.width += locSize.width + (m.right + m.left) * 0.5; layoutSize.height += locSize.height + (m.top + m.bottom) * 0.5; } @@ -1233,8 +1217,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this._findFirstFocusEnabledWidgetIndex(); var index = 0, locChildren = this.getChildren(); - var count = locChildren.length; - var widgetPosition; + var count = locChildren.length, widgetPosition; var distance = cc.FLT_MAX, found = 0; if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT || direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) { @@ -1269,14 +1252,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (baseWidget == null || baseWidget == this) return this._findFirstFocusEnabledWidgetIndex(); - var index = 0; - var count = this.getChildren().size(); + var index = 0, locChildren = this.getChildren(); + var count = locChildren.length; - var distance = -cc.FLT_MAX; - var found = 0; + var distance = -cc.FLT_MAX, found = 0; if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT || direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) { var widgetPosition = this._getWorldCenterPoint(baseWidget); while (index < count) { + var w = locChildren[index]; if (w && w instanceof ccui.Widget && w.isFocusEnabled()) { var length = (w instanceof ccui.Layout)?w._calculateFarthestDistance(baseWidget) : cc.pLength(cc.pSub(this._getWorldCenterPoint(w), widgetPosition)); @@ -1305,8 +1288,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var locChildren = this._children; for (var i = 0, len = locChildren.length; i < len; i++) { - var widget = locChildren[i]; - var length; + var widget = locChildren[i], length; if (widget instanceof ccui.Layout) length = widget._calculateNearestDistance(baseWidget); else { @@ -1339,7 +1321,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ length = layout._calculateFarthestDistance(baseWidget); else { if (layout instanceof ccui.Widget && layout.isFocusEnabled()) { - var wPosition = this._getWorldCenterPoint(w); + var wPosition = this._getWorldCenterPoint(layout); length = cc.pLength(cc.pSub(wPosition, widgetPosition)); } else continue; @@ -1364,27 +1346,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var previousWidgetPosition = this._getWorldCenterPoint(baseWidget); var widgetPosition = this._getWorldCenterPoint(this._findFirstNonLayoutWidget()); if (direction == ccui.Widget.LEFT) { - if (previousWidgetPosition.x > widgetPosition.x) - this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); - else - this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); - }else if(direction == ccui.Widget.RIGHT){ - if (previousWidgetPosition.x > widgetPosition.x) - this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); - else - this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); - }else if(direction == ccui.Widget.DOWN){ - if (previousWidgetPosition.y > widgetPosition.y) - this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); - else - this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); - }else if(direction == ccui.Widget.UP){ - if (previousWidgetPosition.y < widgetPosition.y) - this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); - else - this.onPassFocusToChild = this._findFarthestChildWidgetIndex.bind(this); + this.onPassFocusToChild = (previousWidgetPosition.x > widgetPosition.x) ? this._findNearestChildWidgetIndex.bind(this) + : this._findFarthestChildWidgetIndex.bind(this); + } else if (direction == ccui.Widget.RIGHT) { + this.onPassFocusToChild = (previousWidgetPosition.x > widgetPosition.x) ? this._findFarthestChildWidgetIndex.bind(this) + : this._findNearestChildWidgetIndex.bind(this); + }else if(direction == ccui.Widget.DOWN) { + this.onPassFocusToChild = (previousWidgetPosition.y > widgetPosition.y) ? this._findNearestChildWidgetIndex.bind(this) + : this._findFarthestChildWidgetIndex.bind(this); + }else if(direction == ccui.Widget.UP) { + this.onPassFocusToChild = (previousWidgetPosition.y < widgetPosition.y) ? this._findNearestChildWidgetIndex.bind(this) + : this._findFarthestChildWidgetIndex.bind(this); }else - cc.assert(0, "invalid direction!"); + cc.log("invalid direction!"); }, /** @@ -1537,8 +1511,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.dispatchFocusEvent(current, nextWidget); return nextWidget; } else - //handling the disabled widget, there is no actual focus lose or get, so we don't need any envet - return this._getPreviousFocusedWidget(direction, nextWidget); + return this._getPreviousFocusedWidget(direction, nextWidget); //handling the disabled widget, there is no actual focus lose or get, so we don't need any envet }else { if (this._loopFocus){ if (this._checkFocusEnabledChild()) { @@ -1554,21 +1527,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } } else return this._getPreviousFocusedWidget(direction, nextWidget); - } else { - if (current instanceof ccui.Layout) - return current; - else - return this._focusedWidget; - } + } else + return (current instanceof ccui.Layout) ? current : this._focusedWidget; } else { if (this._isLastWidgetInContainer(current, direction)) { if (this._isWidgetAncestorSupportLoopFocus(this, direction)) return this.findNextFocusedWidget(direction, this); - if (current instanceof ccui.Layout) - return current; - else - return this._focusedWidget; + return (current instanceof ccui.Layout) ? current : this._focusedWidget; } else return this.findNextFocusedWidget(direction, this); } @@ -1583,8 +1549,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ _getChildWidgetByIndex: function (index) { var locChildren = this._children; - var size = locChildren.length; - var count = 0, oldIndex = index; + var size = locChildren.length, count = 0, oldIndex = index; while (index < size) { var firstChild = locChildren[index]; if (firstChild && firstChild instanceof ccui.Widget) @@ -1701,7 +1666,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._checkFocusEnabledChild()) { var previousWidget = ccui.Widget.getCurrentFocusedWidget(); this._findProperSearchingFunctor(direction, previousWidget); - var index = this.onPassFocusToChild(direction, previousWidget); var widget = this._getChildWidgetByIndex(index); @@ -1748,6 +1712,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _copySpecialProperties: function (layout) { + if(!(layout instanceof ccui.Layout)) + return; this.setBackGroundImageScale9Enabled(layout._backGroundScale9Enabled); this.setBackGroundImage(layout._backGroundImageFileName, layout._bgImageTexType); this.setBackGroundImageCapInsets(layout._backGroundImageCapInsets); diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index c527a783dc..011dca5735 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -243,10 +243,8 @@ ccui.relativeLayoutManager = { if (relativeWidget){ if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationTop = relativeWidget.getTopBoundary(); - var locationLeft = relativeWidget.getLeftBoundary(); - this._finalPositionY = locationTop + ap.y * cs.height; - this._finalPositionX = locationLeft + ap.x * cs.width; + this._finalPositionY = relativeWidget.getTopBoundary() + ap.y * cs.height; + this._finalPositionX = relativeWidget.getLeftBoundary() + ap.x * cs.width; } break; case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER: @@ -254,8 +252,7 @@ ccui.relativeLayoutManager = { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; var rbs = relativeWidget.getContentSize(); - var locationTop = relativeWidget.getTopBoundary(); - this._finalPositionY = locationTop + ap.y * cs.height; + this._finalPositionY = relativeWidget.getTopBoundary() + ap.y * cs.height; this._finalPositionX = relativeWidget.getLeftBoundary() + rbs.width * 0.5 + ap.x * cs.width - cs.width * 0.5; } break; @@ -263,20 +260,16 @@ ccui.relativeLayoutManager = { if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationTop = relativeWidget.getTopBoundary(); - var locationRight = relativeWidget.getRightBoundary(); - this._finalPositionY = locationTop + ap.y * cs.height; - this._finalPositionX = locationRight - (1.0 - ap.x) * cs.width; + this._finalPositionY = relativeWidget.getTopBoundary() + ap.y * cs.height; + this._finalPositionX = relativeWidget.getRightBoundary() - (1.0 - ap.x) * cs.width; } break; case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN: if (relativeWidget){ if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationTop = relativeWidget.getTopBoundary(); - var locationLeft = relativeWidget.getLeftBoundary(); - this._finalPositionY = locationTop - (1.0 - ap.y) * cs.height; - this._finalPositionX = locationLeft - (1.0 - ap.x) * cs.width; + this._finalPositionY = relativeWidget.getTopBoundary() - (1.0 - ap.y) * cs.height; + this._finalPositionX = relativeWidget.getLeftBoundary() - (1.0 - ap.x) * cs.width; } break; case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER: @@ -284,8 +277,7 @@ ccui.relativeLayoutManager = { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; var rbs = relativeWidget.getContentSize(); - var locationLeft = relativeWidget.getLeftBoundary(); - this._finalPositionX = locationLeft - (1.0 - ap.x) * cs.width; + this._finalPositionX = relativeWidget.getLeftBoundary() - (1.0 - ap.x) * cs.width; this._finalPositionY = relativeWidget.getBottomBoundary() + rbs.height * 0.5 + ap.y * cs.height - cs.height * 0.5; } break; @@ -293,20 +285,16 @@ ccui.relativeLayoutManager = { if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationBottom = relativeWidget.getBottomBoundary(); - var locationLeft = relativeWidget.getLeftBoundary(); - this._finalPositionY = locationBottom + ap.y * cs.height; - this._finalPositionX = locationLeft - (1.0 - ap.x) * cs.width; + this._finalPositionY = relativeWidget.getBottomBoundary() + ap.y * cs.height; + this._finalPositionX = relativeWidget.getLeftBoundary() - (1.0 - ap.x) * cs.width; } break; case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN: if (relativeWidget){ if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationTop = relativeWidget.getTopBoundary(); - var locationRight = relativeWidget.getRightBoundary(); - this._finalPositionY = locationTop - (1.0 - ap.y) * cs.height; - this._finalPositionX = locationRight + ap.x * cs.width; + this._finalPositionY = relativeWidget.getTopBoundary() - (1.0 - ap.y) * cs.height; + this._finalPositionX = relativeWidget.getRightBoundary() + ap.x * cs.width; } break; case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER: @@ -323,20 +311,16 @@ ccui.relativeLayoutManager = { if (relativeWidget){ if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationBottom = relativeWidget.getBottomBoundary(); - var locationRight = relativeWidget.getRightBoundary(); - this._finalPositionY = locationBottom + ap.y * cs.height; - this._finalPositionX = locationRight + ap.x * cs.width; + this._finalPositionY = relativeWidget.getBottomBoundary() + ap.y * cs.height; + this._finalPositionX = relativeWidget.getRightBoundary() + ap.x * cs.width; } break; case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN: if (relativeWidget){ if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationBottom = relativeWidget.getBottomBoundary(); - var locationLeft = relativeWidget.getLeftBoundary(); - this._finalPositionY = locationBottom - (1.0 - ap.y) * cs.height; - this._finalPositionX = locationLeft + ap.x * cs.width; + this._finalPositionY = relativeWidget.getBottomBoundary() - (1.0 - ap.y) * cs.height; + this._finalPositionX = relativeWidget.getLeftBoundary() + ap.x * cs.width; } break; case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER: @@ -344,9 +328,7 @@ ccui.relativeLayoutManager = { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; var rbs = relativeWidget.getContentSize(); - var locationBottom = relativeWidget.getBottomBoundary(); - - this._finalPositionY = locationBottom - (1.0 - ap.y) * cs.height; + this._finalPositionY = relativeWidget.getBottomBoundary() - (1.0 - ap.y) * cs.height; this._finalPositionX = relativeWidget.getLeftBoundary() + rbs.width * 0.5 + ap.x * cs.width - cs.width * 0.5; } break; @@ -354,10 +336,8 @@ ccui.relativeLayoutManager = { if (relativeWidget) { if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return false; - var locationBottom = relativeWidget.getBottomBoundary(); - var locationRight = relativeWidget.getRightBoundary(); - this._finalPositionY = locationBottom - (1.0 - ap.y) * cs.height; - this._finalPositionX = locationRight - (1.0 - ap.x) * cs.width; + this._finalPositionY = relativeWidget.getBottomBoundary() - (1.0 - ap.y) * cs.height; + this._finalPositionX = relativeWidget.getRightBoundary() - (1.0 - ap.x) * cs.width; } break; default: From 9508c697d0a3e868875fbbc9543d20b0751e4f80 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 15 Jul 2014 18:28:14 +0800 Subject: [PATCH 0301/1564] Fixed #3546: fixed a bug about bake layer that its position is incorrect when cc.view scaled. --- cocos2d/core/layers/CCLayer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 480513f393..451480a3ac 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -156,11 +156,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //visit for canvas _t.sortAllChildren(); - // draw children zOrder < 0 + cc.view._setScaleXYForRenderTexture(); for (i = 0; i < len; i++) { children[i].visit(bakeContext); } - + cc.view._resetScale(); this._cacheDirty = false; } @@ -440,6 +440,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } var child; + cc.view._setScaleXYForRenderTexture(); //visit for canvas if (len > 0) { _t.sortAllChildren(); @@ -457,6 +458,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } } else _t.draw(bakeContext); + cc.view._resetScale(); this._cacheDirty = false; } From 03d44caae91f72c895e328b9fe746b0940749374 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 16 Jul 2014 10:48:32 +0800 Subject: [PATCH 0302/1564] Issue #5704: sync ccui.HBox, ccui.VBox, ccui.RelativeBox --- extensions/ccui/layouts/UIHBox.js | 14 +++++++------- extensions/ccui/layouts/UILayout.js | 1 - extensions/ccui/layouts/UIRelativeBox.js | 12 ++++++------ extensions/ccui/layouts/UIVBox.js | 19 +++++++++---------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/extensions/ccui/layouts/UIHBox.js b/extensions/ccui/layouts/UIHBox.js index 394e9a8e97..1dd2075c43 100644 --- a/extensions/ccui/layouts/UIHBox.js +++ b/extensions/ccui/layouts/UIHBox.js @@ -24,12 +24,11 @@ ****************************************************************************/ /** - * Base class for ccui.HBox + * The horizontal box of Cocos UI. * @class * @extends ccui.Layout */ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ - init: function(){ if(ccui.Layout.prototype.init.call(this)){ this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL); @@ -40,7 +39,7 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ initWithSize: function(size){ if(this.init()){ - this.setSize(size); + this.setContentSize(size); return true; } return false; @@ -50,10 +49,11 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ ccui.HBox.create = function(size){ var widget = new ccui.HBox(); if(size){ - if(widget.initWithSize()){ + if(widget.initWithSize(size)) + return widget; + }else { + if(widget.init()) return widget; - } - return null; } - return widget; + return null; }; \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 27457264a7..db7af18297 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1533,7 +1533,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._isLastWidgetInContainer(current, direction)) { if (this._isWidgetAncestorSupportLoopFocus(this, direction)) return this.findNextFocusedWidget(direction, this); - return (current instanceof ccui.Layout) ? current : this._focusedWidget; } else return this.findNextFocusedWidget(direction, this); diff --git a/extensions/ccui/layouts/UIRelativeBox.js b/extensions/ccui/layouts/UIRelativeBox.js index b662ccacc2..87451f9c9b 100644 --- a/extensions/ccui/layouts/UIRelativeBox.js +++ b/extensions/ccui/layouts/UIRelativeBox.js @@ -24,12 +24,11 @@ ****************************************************************************/ /** - * Base class for ccui.RelativeBox + * The Relative box for Cocos UI layout. * @class * @extends ccui.Layout */ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ - init: function(){ if(ccui.Layout.prototype.init.call(this)){ this.setLayoutType(ccui.Layout.RELATIVE); @@ -50,10 +49,11 @@ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ ccui.RelativeBox.create = function(size){ var widget = new ccui.RelativeBox(); if(size){ - if(widget.initWithSize()){ + if(widget.initWithSize(size)) + return widget; + } else { + if(widget.init()) return widget; - } - return null; } - return widget; + return null; }; \ No newline at end of file diff --git a/extensions/ccui/layouts/UIVBox.js b/extensions/ccui/layouts/UIVBox.js index 01f34af4e2..9cf3d85bc5 100644 --- a/extensions/ccui/layouts/UIVBox.js +++ b/extensions/ccui/layouts/UIVBox.js @@ -24,23 +24,21 @@ ****************************************************************************/ /** - * Base class for ccui.RelativeBox + * The vertical box of Cocos UI. * @class * @extends ccui.Layout */ -ccui.VBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ - +ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ init: function(){ if(ccui.Layout.prototype.init.call(this)){ - this.setLayoutType(ccui.Layout.VERTICAL); + this.setLayoutType(ccui.Layout.LINEAR_VERTICAL); return true; } return false; }, - initWithSize: function(size){ if(this.init()){ - this.setSize(size); + this.setContentSize(size); return true; } return false; @@ -50,10 +48,11 @@ ccui.VBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ ccui.VBox.create = function(size){ var widget = new ccui.VBox(); if(size){ - if(widget.initWithSize()){ + if(widget.initWithSize(size)) + return widget; + } else { + if(widget.init()) return widget; - } - return null; } - return widget; + return null; }; \ No newline at end of file From bf2ea189e78e300f87cb08423306f1cc84e0f99f Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 16 Jul 2014 11:03:47 +0800 Subject: [PATCH 0303/1564] issue #5685: refactor create functions of ParticleExamples --- cocos2d/particle/CCParticleExamples.js | 157 +++++++++---------------- 1 file changed, 53 insertions(+), 104 deletions(-) diff --git a/cocos2d/particle/CCParticleExamples.js b/cocos2d/particle/CCParticleExamples.js index c8618c1833..bd6186f033 100644 --- a/cocos2d/particle/CCParticleExamples.js +++ b/cocos2d/particle/CCParticleExamples.js @@ -34,11 +34,10 @@ */ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{ /** - * initialize a fire particle system - * @return {Boolean} + * @constructor */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 300 : 150); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 300 : 150); }, /** @@ -110,11 +109,7 @@ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{ * var emitter = cc.ParticleFire.create(); */ cc.ParticleFire.create = function () { - var ret = new cc.ParticleFire(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleFire(); }; /** @@ -126,12 +121,12 @@ cc.ParticleFire.create = function () { * var emitter = cc.ParticleFireworks.create(); */ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# */{ + /** - * initialize a fireworks particle system - * @return {Boolean} + * @constructor */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1500 : 150); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1500 : 150); }, /** @@ -200,11 +195,7 @@ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# * var emitter = cc.ParticleFireworks.create(); */ cc.ParticleFireworks.create = function () { - var ret = new cc.ParticleFireworks(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleFireworks(); }; /** @@ -216,12 +207,12 @@ cc.ParticleFireworks.create = function () { * var emitter = cc.ParticleSun.create(); */ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{ + /** - * initialize a sun particle system - * @return {Boolean} + * @constructor */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 350 : 150); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 350 : 150); }, /** @@ -292,11 +283,7 @@ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{ * var emitter = cc.ParticleSun.create(); */ cc.ParticleSun.create = function () { - var ret = new cc.ParticleSun(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleSun(); }; //! @brief A particle system @@ -309,13 +296,12 @@ cc.ParticleSun.create = function () { * var emitter = cc.ParticleGalaxy.create(); */ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{ + /** - * initialize a galaxy particle system - * @return {Boolean} + * @constructor */ - init:function () { - //return this.initWithTotalParticles(200); - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); }, /** @@ -388,11 +374,7 @@ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{ * var emitter = cc.ParticleGalaxy.create(); */ cc.ParticleGalaxy.create = function () { - var ret = new cc.ParticleGalaxy(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleGalaxy(); }; /** @@ -404,12 +386,9 @@ cc.ParticleGalaxy.create = function () { * var emitter = cc.ParticleFlower.create(); */ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{ - /** - * initialize a flower particle system - * @return {Boolean} - */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 250 : 100); + + ctor : function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 250 : 100); }, /** @@ -483,11 +462,7 @@ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{ * var emitter = cc.ParticleFlower.create(); */ cc.ParticleFlower.create = function () { - var ret = new cc.ParticleFlower(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleFlower(); }; //! @brief A meteor particle system @@ -500,12 +475,12 @@ cc.ParticleFlower.create = function () { * var emitter = cc.ParticleMeteor.create(); */ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{ + /** - * initialize a meteor particle system - * @return {Boolean} + * @constructor */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 150 : 100); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 150 : 100); }, /** @@ -579,11 +554,7 @@ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{ * var emitter = cc.ParticleMeteor.create(); */ cc.ParticleMeteor.create = function () { - var ret = new cc.ParticleMeteor(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleMeteor(); }; /** @@ -595,12 +566,12 @@ cc.ParticleMeteor.create = function () { * var emitter = cc.ParticleSpiral.create(); */ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{ + /** - * initialize a spiral particle system - * @return {Boolean} + * @constructor */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 500 : 100); + ctor:function() { + cc.ParticleSystem.prototype.ctor.call(this,(cc._renderType === cc._RENDER_TYPE_WEBGL) ? 500 : 100); }, /** @@ -674,11 +645,7 @@ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{ * var emitter = cc.ParticleSpiral.create(); */ cc.ParticleSpiral.create = function () { - var ret = new cc.ParticleSpiral(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleSpiral(); }; /** @@ -690,13 +657,12 @@ cc.ParticleSpiral.create = function () { * var emitter = cc.ParticleExplosion.create(); */ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# */{ + /** - * initialize an explosion particle system - * @return {Boolean} + * @constructor */ - init:function () { - //return this.initWithTotalParticles(700); - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 300); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 300); }, /** @@ -769,11 +735,7 @@ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# * var emitter = cc.ParticleExplosion.create(); */ cc.ParticleExplosion.create = function () { - var ret = new cc.ParticleExplosion(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleExplosion(); }; /** @@ -785,13 +747,12 @@ cc.ParticleExplosion.create = function () { * var emitter = cc.ParticleSmoke.create(); */ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{ + /** - * initialize a smoke particle system - * @return {Boolean} + * @contructor */ - init:function () { - //return this.initWithTotalParticles(200); - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); }, /** @@ -861,11 +822,7 @@ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{ * var emitter = cc.ParticleFireworks.create(); */ cc.ParticleSmoke.create = function () { - var ret = new cc.ParticleSmoke(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleSmoke(); }; /** @@ -877,12 +834,12 @@ cc.ParticleSmoke.create = function () { * var emitter = cc.ParticleSnow.create(); */ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{ + /** - * initialize a snow particle system - * @return {Boolean} + * @constructor */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 250); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 250); }, /** @@ -956,11 +913,7 @@ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{ * var emitter = cc.ParticleSnow.create(); */ cc.ParticleSnow.create = function () { - var ret = new cc.ParticleSnow(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleSnow(); }; //! @brief A rain particle system @@ -973,12 +926,12 @@ cc.ParticleSnow.create = function () { * var emitter = cc.ParticleRain.create(); */ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{ + /** - * initialize a rain particle system - * @return {Boolean} + * @constructor */ - init:function () { - return this.initWithTotalParticles((cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1000 : 300); + ctor:function () { + cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1000 : 300); }, /** @@ -1052,9 +1005,5 @@ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{ * var emitter = cc.ParticleRain.create(); */ cc.ParticleRain.create = function () { - var ret = new cc.ParticleRain(); - if (ret.init()) { - return ret; - } - return null; + return new cc.ParticleRain(); }; From de023caa87b5fef05a30ad08a7f9111cf7fb6c19 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 16 Jul 2014 14:59:31 +0800 Subject: [PATCH 0304/1564] issue #5685: fix LayerMultiplex ctor bug --- cocos2d/core/layers/CCLayer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 480513f393..0d7bdf5bb9 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -803,7 +803,10 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ */ ctor: function (layers) { cc.Layer.prototype.ctor.call(this); - layers && cc.LayerMultiplex.prototype.initWithLayers.call(this, layers); + if (layers instanceof Array) + cc.LayerMultiplex.prototype.initWithLayers.call(this, layers); + else + cc.LayerMultiplex.prototype.initWithLayers.call(this, Array.prototype.slice.call(arguments)); }, /** From b664514404143561e226925446619d21337b6bd9 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 16 Jul 2014 15:11:57 +0800 Subject: [PATCH 0305/1564] issue #5685: fix LayerMultiplex.create --- cocos2d/core/layers/CCLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 0d7bdf5bb9..ac5c160968 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -877,6 +877,6 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ * var multiLayer = cc.LayerMultiple.create(layer1, layer2, layer3);//any number of layers */ cc.LayerMultiplex.create = function (/*Multiple Arguments*/) { - return new cc.LayerMultiplex(arguments); + return new cc.LayerMultiplex(Array.prototype.slice.call(arguments)); }; From 7bdddcaf5e110dbf5402d87e980017381c256e2b Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 16 Jul 2014 17:58:03 +0800 Subject: [PATCH 0306/1564] Docs: Complete some inline doc --- .../ccui/uiwidgets/scroll-widget/UIScrollView.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index ae7a8fae35..51aa645a97 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1265,6 +1265,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to bottom boundary of ScrollView. + * @function */ jumpToBottom: function () { this.jumpToDestination(this._innerContainer.getPositionX(), 0); @@ -1272,6 +1273,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to top boundary of ScrollView. + * @function */ jumpToTop: function () { this.jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height); @@ -1279,6 +1281,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to left boundary of ScrollView. + * @function */ jumpToLeft: function () { this.jumpToDestination(0, this._innerContainer.getPositionY()); @@ -1286,6 +1289,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to right boundary of ScrollView. + * @function */ jumpToRight: function () { this.jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()); @@ -1293,6 +1297,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to top and left boundary of ScrollView. + * @function */ jumpToTopLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1304,6 +1309,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to top and right boundary of ScrollView. + * @function */ jumpToTopRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1316,6 +1322,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to bottom and left boundary of ScrollView. + * @function */ jumpToBottomLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1327,6 +1334,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to bottom and right boundary of ScrollView. + * @function */ jumpToBottomRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1338,6 +1346,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to vertical percent position of ScrollView. + * @function + * @param {Number} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentVertical: function (percent) { var minY = this._contentSize.height - this._innerContainer.getContentSize().height; @@ -1347,6 +1357,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to horizontal percent position of ScrollView. + * @function + * @param {Number} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentHorizontal: function (percent) { var w = this._innerContainer.getContentSize().width - this._contentSize.width; @@ -1355,6 +1367,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to both direction percent position of ScrollView. + * @function + * @param {Number} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentBothDirection: function (percent) { if (this.direction != ccui.ScrollView.DIR_BOTH) From 5108bfa8debb3b2df9a6082f9f9ea2967403add3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 16 Jul 2014 17:59:08 +0800 Subject: [PATCH 0307/1564] Issue #5704: refactor ccui.PageView for better performance. --- CCBoot.js | 2 +- .../uiwidgets/scroll-widget/UIPageView.js | 304 +++++++----------- 2 files changed, 121 insertions(+), 185 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 671cfa9bb0..9b5b86e7d1 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1087,7 +1087,7 @@ cc._initSys = function (config, CONFIG_KEY) { var tempCanvas = cc.newElement("Canvas"); cc._supportRender = true; var notInWhiteList = webglWhiteList.indexOf(sys.browserType) == -1; - if (userRenderMode === 1 || (userRenderMode === 0 && (sys.isMobile || notInWhiteList))) { + if (userRenderMode === 1 || (userRenderMode === 0 && (sys.isMobile || notInWhiteList)) || (location.origin == "file://")) { renderType = cc._RENDER_TYPE_CANVAS; } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index ebe63cd1fd..cc48602683 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.PageView + * The PageView control of Cocos UI. * @class * @extends ccui.Layout */ @@ -39,10 +39,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _rightBoundaryChild: null, _leftBoundary: 0, _rightBoundary: 0, + _isAutoScrolling: false, _autoScrollDistance: 0, _autoScrollSpeed: 0, _autoScrollDirection: 0, + _childFocusCancelOffset: 0, _pageViewEventListener: null, _pageViewEventSelector: null, @@ -58,20 +60,13 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ */ ctor: function () { ccui.Layout.prototype.ctor.call(this); - this._curPageIdx = 0; this._pages = []; this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT; - this._touchStartLocation = 0; - this._touchMoveStartLocation = 0; + this._movePagePoint = null; this._leftBoundaryChild = null; this._rightBoundaryChild = null; - this._leftBoundary = 0; - this._rightBoundary = 0; - this._isAutoScrolling = false; - this._autoScrollDistance = 0; - this._autoScrollSpeed = 0; - this._autoScrollDirection = 0; + this._childFocusCancelOffset = 5; this._pageViewEventListener = null; this._pageViewEventSelector = null; @@ -91,21 +86,21 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Add a widget to a page of pageview. - * @param {ccui.Widget} widget - * @param {number} pageIdx - * @param {Boolean} forceCreate + * Add a widget to a page of PageView. + * @param {ccui.Widget} widget widget to be added to PageView. + * @param {number} pageIdx index of page. + * @param {Boolean} forceCreate if force create and there is no page exist, PageView would create a default page for adding widget. */ addWidgetToPage: function (widget, pageIdx, forceCreate) { if (!widget || pageIdx < 0) return; - var pageCount = this.getPageCount(); - if (pageIdx >= pageCount) { + var pageCount = this._getPageCount(); + if (pageIdx < 0 || pageIdx >= pageCount) { if (forceCreate) { if (pageIdx > pageCount) - cc.log("pageIdx is %d, it will be added as page id [%d]", pageIdx, pageCount) - var newPage = this.createPage(); + cc.log("pageIdx is %d, it will be added as page id [%d]", pageIdx, pageCount); + var newPage = this._createPage(); newPage.addChild(widget); this.addPage(newPage); } @@ -119,54 +114,55 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ /** * create page * @returns {ccui.Layout} + * @protected */ - createPage: function () { + _createPage: function () { var newPage = ccui.Layout.create(); newPage.setContentSize(this.getContentSize()); return newPage; }, /** - * Push back a page to pageview. + * Push back a page to PageView. * @param {ccui.Layout} page */ addPage: function (page) { if (!page || this._pages.indexOf(page) != -1) return; - this.addProtectedChild(page); + this.addChild(page); this._pages.push(page); this._doLayoutDirty = true; }, /** - * Inert a page to pageview. - * @param {ccui.Layout} page - * @param {Number} idx + * Insert a page to PageView. + * @param {ccui.Layout} page page to be added to PageView. + * @param {Number} idx index */ insertPage: function (page, idx) { if (idx < 0 || !page || this._pages.indexOf(page) != -1) return; - var pageCount = this.getPageCount(); + var pageCount = this._getPageCount(); if (idx >= pageCount) this.addPage(page); else { this._pages[idx] = page; - this.addProtectedChild(page); + this.addChild(page); } this._doLayoutDirty = true; }, /** - * Remove a page of pageview. + * Remove a page of PageView. * @param {ccui.Layout} page */ removePage: function (page) { if (!page) { return; } - this.removeProtectedChild(page); + this.removeChild(page); var index = this._pages.indexOf(page); if(index > -1) this._pages.splice(index, 1); @@ -174,38 +170,40 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Remove a page at index of pageview. + * Remove a page at index of PageView. * @param {number} index */ removePageAtIndex: function (index) { - if (index < 0 || index >= this._pages.length) { + if (index < 0 || index >= this._pages.length) return; - } var page = this._pages[index]; - if (page) { + if (page) this.removePage(page); - } }, + /** + * remove all pages from PageView + */ removeAllPages: function(){ var locPages = this._pages; for(var i = 0, len = locPages.length; i < len; i++){ - this.removeProtectedChild(locPages[i]); + this.removeChild(locPages[i]); } this._pages.length = 0; }, - updateBoundaryPages: function () { - if (this._pages.length <= 0) { + _updateBoundaryPages: function () { + var locPages = this._pages; + if (locPages.length <= 0) { this._leftBoundaryChild = null; this._rightBoundaryChild = null; return; } - this._leftBoundaryChild = this._pages[0]; - this._rightBoundaryChild = this._pages[this._pages.length-1]; + this._leftBoundaryChild = locPages[0]; + this._rightBoundaryChild = locPages[locPages.length - 1]; }, - getPageCount: function(){ + _getPageCount: function(){ return this._pages.length; }, @@ -214,8 +212,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {number} idx * @returns {number} */ - getPositionXByIndex: function (idx) { - return (this.getSize().width * (idx - this._curPageIdx)); + _getPositionXByIndex: function (idx) { + return (this.getContentSize().width * (idx - this._curPageIdx)); }, _onSizeChanged: function () { @@ -224,16 +222,15 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._doLayoutDirty = true; }, - updateAllPagesSize: function(){ + _updateAllPagesSize: function(){ var selfSize = this.getContentSize(); var locPages = this._pages; - for (var i = 0, len = locPages.length; i < len; i++) { + for (var i = 0, len = locPages.length; i < len; i++) locPages[i].setContentSize(selfSize); - } }, - updateAllPagesPosition: function(){ - var pageCount = this.getPageCount(); + _updateAllPagesPosition: function(){ + var pageCount = this._getPageCount(); if (pageCount <= 0) { this._curPageIdx = 0; return; @@ -244,14 +241,13 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var pageWidth = this.getContentSize().width; var locPages = this._pages; - for (var i=0; i< pageCount; i++){ + for (var i=0; i< pageCount; i++) locPages[i].setPosition(cc.p((i - this._curPageIdx) * pageWidth, 0)); - } }, /** - * scroll pageview to index. - * @param {number} idx + * scroll PageView to index. + * @param {number} idx index of page. */ scrollToPage: function (idx) { if (idx < 0 || idx >= this._pages.length) @@ -260,102 +256,98 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var curPage = this._pages[idx]; this._autoScrollDistance = -(curPage.getPosition().x); this._autoScrollSpeed = Math.abs(this._autoScrollDistance) / 0.2; - this._autoScrollDirection = this._autoScrollDistance > 0 ? 1 : 0; + this._autoScrollDirection = this._autoScrollDistance > 0 ? ccui.PageView.DIRECTION_RIGHT : ccui.PageView.DIRECTION_LEFT; this._isAutoScrolling = true; }, update: function (dt) { - if (this._isAutoScrolling) { - this.autoScroll(dt); - } + if (this._isAutoScrolling) + this._autoScroll(dt); + }, + + setLayoutType:function(type){ + + }, + + getLayoutType: function(){ + return ccui.Layout.ABSOLUTE; }, - autoScroll: function(dt){ + _autoScroll: function(dt){ var step; switch (this._autoScrollDirection) { - case 0: + case ccui.PageView.DIRECTION_LEFT: step = this._autoScrollSpeed * dt; if (this._autoScrollDistance + step >= 0.0) { step = -this._autoScrollDistance; this._autoScrollDistance = 0.0; this._isAutoScrolling = false; - } - else { + } else this._autoScrollDistance += step; - } - this.scrollPages(-step); - if(!this._isAutoScrolling){ - this.pageTurningEvent(); - } + this._scrollPages(-step); + if(!this._isAutoScrolling) + this._pageTurningEvent(); break; break; - case 1: + case ccui.PageView.DIRECTION_RIGHT: step = this._autoScrollSpeed * dt; if (this._autoScrollDistance - step <= 0.0) { step = this._autoScrollDistance; this._autoScrollDistance = 0.0; this._isAutoScrolling = false; - } - else { + } else this._autoScrollDistance -= step; - } - this.scrollPages(step); - if(!this._isAutoScrolling){ - this.pageTurningEvent(); - } + this._scrollPages(step); + if(!this._isAutoScrolling) + this._pageTurningEvent(); break; default: break; } }, - onTouchBegan: function (touch,event) { - var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); - if (this._hit) - this.handlePressLogic(touch); - return pass; - }, + // onTouchBegan logic at ccui.Layout onTouchMoved: function (touch, event) { - this.handleMoveLogic(touch); + this._handleMoveLogic(touch); var widgetParent = this.getWidgetParent(); if (widgetParent) - widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); + widgetParent._interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); this._moveEvent(); }, onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this.handleReleaseLogic(touch); + this._handleReleaseLogic(touch); }, onTouchCancelled: function (touch, event) { ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); - this.handleReleaseLogic(touch); + this._handleReleaseLogic(touch); }, _doLayout: function(){ if (!this._doLayoutDirty) return; - this.updateAllPagesPosition(); - this.updateAllPagesSize(); - this.updateBoundaryPages(); - + this._updateAllPagesPosition(); + this._updateAllPagesSize(); + this._updateBoundaryPages(); this._doLayoutDirty = false; }, - movePages: function (offset) { + _movePages: function (offset) { var arrayPages = this._pages; var length = arrayPages.length; for (var i = 0; i < length; i++) { var child = arrayPages[i]; - var pos = child.getPosition(); - child.setPosition(pos.x + offset, pos.y); + //var pos = child.getPosition(); + //child.setPosition(pos.x + offset, pos.y); + child.setPositionX(child.getPositionX() + offset); } }, - scrollPages: function (touchOffset) { + _scrollPages: function (touchOffset) { if (this._pages.length <= 0) return false; @@ -365,17 +357,18 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var realOffset = touchOffset; switch (this._touchMoveDirection) { case ccui.PageView.TOUCH_DIR_LEFT: // left - if (this._rightBoundaryChild.getRightBoundary() + touchOffset <= this._rightBoundary) { - realOffset = this._rightBoundary - this._rightBoundaryChild.getRightBoundary(); - this.movePages(realOffset); + var rightBoundary = this._rightBoundaryChild.getRightBoundary(); + if (rightBoundary + touchOffset <= this._rightBoundary) { + realOffset = this._rightBoundary - rightBoundary; + this._movePages(realOffset); return false; } break; - case ccui.PageView.TOUCH_DIR_RIGHT: // right - if (this._leftBoundaryChild.getLeftBoundary() + touchOffset >= this._leftBoundary) { - realOffset = this._leftBoundary - this._leftBoundaryChild.getLeftBoundary(); - this.movePages(realOffset); + var leftBoundary = this._leftBoundaryChild.getLeftBoundary(); + if (leftBoundary + touchOffset >= this._leftBoundary) { + realOffset = this._leftBoundary - leftBoundary; + this._movePages(realOffset); return false; } break; @@ -383,25 +376,20 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ break; } - this.movePages(realOffset); + this._movePages(realOffset); return true; }, - handlePressLogic: function (touchPoint) { - //np-op - }, - - handleMoveLogic: function (touch) { + _handleMoveLogic: function (touch) { var offset = touch.getLocation().x - touch.getPreviousLocation().x; - if (offset < 0) { + if (offset < 0) this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT; - } else if (offset > 0) { + else if (offset > 0) this._touchMoveDirection = ccui.PageView.TOUCH_DIR_RIGHT; - } - this.scrollPages(offset); + this._scrollPages(offset); }, - handleReleaseLogic: function (touchPoint) { + _handleReleaseLogic: function (touchPoint) { if (this._pages.length <= 0) return; var curPage = this._pages[this._curPageIdx]; @@ -413,50 +401,44 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var boundary = pageWidth / 2.0; if (curPageLocation <= -boundary) { if (this._curPageIdx >= pageCount - 1) - this.scrollPages(-curPageLocation); + this._scrollPages(-curPageLocation); else this.scrollToPage(this._curPageIdx + 1); } else if (curPageLocation >= boundary) { if (this._curPageIdx <= 0) - this.scrollPages(-curPageLocation); + this._scrollPages(-curPageLocation); else this.scrollToPage(this._curPageIdx - 1); - } else { + } else this.scrollToPage(this._curPageIdx); - } } }, - interceptTouchEvent: function (handleState, sender, touchPoint) { + _interceptTouchEvent: function (handleState, sender, touchPoint) { switch (handleState) { - case 0: - this.handlePressLogic(touchPoint); + case ccui.Widget.TOUCH_BEGAN: break; - case 1: + case ccui.Widget.TOUCH_MOVED: var offset = 0; offset = Math.abs(sender.getTouchBeganPosition().x - touchPoint.x); if (offset > this._childFocusCancelOffset) { sender.setFocused(false); - this.handleMoveLogic(touchPoint); + this._handleMoveLogic(touchPoint); } break; - case 2: - this.handleReleaseLogic(touchPoint); - break; - - case 3: + case ccui.Widget.TOUCH_ENDED: + case ccui.Widget.TOUCH_CANCELED: + this._handleReleaseLogic(touchPoint); break; } }, - pageTurningEvent: function () { - if (this._pageViewEventListener && this._pageViewEventSelector) { + _pageTurningEvent: function () { + if (this._pageViewEventListener && this._pageViewEventSelector) this._pageViewEventSelector.call(this._pageViewEventListener, this, ccui.PageView.EVENT_TURNING); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this, ccui.PageView.EVENT_TURNING); - } }, /** @@ -473,7 +455,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * get cur page index + * get current page index * @returns {number} */ getCurPageIndex: function () { @@ -481,13 +463,18 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * get pages + * get all pages of PageView * @returns {Array} */ getPages:function(){ return this._pages; }, + /** + * get a page from PageView by index + * @param {Number} index + * @returns {ccui.Layout} + */ getPage: function(index){ if (index < 0 || index >= this.getPages().size()) return null; @@ -520,59 +507,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._pageViewEventListener = pageView._pageViewEventListener; this._pageViewEventSelector = pageView._pageViewEventSelector; } - -// -// updateChildrenSize: function () { -// if(this._pages){ -// if (!this._pages.length <= 0) { -// return; -// } -// -// var selfSize = this.getSize(); -// for (var i = 0; i < this._pages.length; i++) { -// var page = this._pages[i]; -// page.setSize(selfSize); -// } -// } -// }, -// -// updateChildrenPosition: function () { -// if (!this._pages) { -// return; -// } -// -// var pageCount = this._pages.length; -// if (pageCount <= 0) { -// this._curPageIdx = 0; -// return; -// } -// if (this._curPageIdx >= pageCount) { -// this._curPageIdx = pageCount - 1; -// } -// var pageWidth = this.getSize().width; -// var arrayPages = this._pages; -// for (var i = 0; i < pageCount; i++) { -// var page = arrayPages[i]; -// page.setPosition((i - this._curPageIdx) * pageWidth, 0); -// } -// }, -// -// removeAllChildren: function (cleanup) { -// if(cleanup) -// this._pages.length = 0; -// ccui.Layout.prototype.removeAllChildren.call(this, cleanup); -// }, -// -// checkChildInfo: function (handleState, sender, touchPoint) { -// if(this._enabled && this._touchEnabled) -// this.interceptTouchEvent(handleState, sender, touchPoint); -// }, -// -// _doLayout: function () { -// if (!this._doLayoutDirty) -// return; -// this._doLayoutDirty = false; -// } }); /** * allocates and initializes a UIPageView. @@ -585,9 +519,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ ccui.PageView.create = function () { var widget = new ccui.PageView(); if (widget && widget.init()) - { return widget; - } return null; }; @@ -597,4 +529,8 @@ ccui.PageView.EVENT_TURNING = 0; //PageView touch direction ccui.PageView.TOUCH_DIR_LEFT = 0; -ccui.PageView.TOUCH_DIR_RIGHT = 1; \ No newline at end of file +ccui.PageView.TOUCH_DIR_RIGHT = 1; + +//PageView auto scroll direction +ccui.PageView.DIRECTION_LEFT = 0; +ccui.PageView.DIRECTION_RIGHT = 0; From 7249eace50179e9737b98b3880976c4b487b9eab Mon Sep 17 00:00:00 2001 From: Minh Quy Date: Thu, 17 Jul 2014 00:13:26 +0700 Subject: [PATCH 0308/1564] [Fix] - Check empty string for textureData Previous way which is used to check string is empty or null is not right because in case of string is empty the expression always false. --- cocos2d/particle/CCParticleSystem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index b0446a9789..faba8b1c03 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1608,7 +1608,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } else { var textureData = locValueForKey("textureImageData", dictionary); - if (textureData && textureData.length == 0) { + if (!textureData || textureData.length === 0) { tex = cc.textureCache.addImage(imgPath); if (!tex) return false; From 176d5cb204e46fc5376da59c0b8e8ce3e8bd7447 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 17 Jul 2014 14:42:12 +0800 Subject: [PATCH 0309/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Fix position bug 1. CCDataReaderHelper 2. async bug --- cocos2d/core/platform/CCMacro.js | 6 + .../armature/animation/CCArmatureAnimation.js | 2 +- .../cocostudio/armature/animation/CCTween.js | 2 +- .../cocostudio/armature/datas/CCDatas.js | 27 +- .../armature/utils/CCArmatureDataManager.js | 4 +- .../armature/utils/CCDataReaderHelper.js | 853 ++++++++++-------- 6 files changed, 522 insertions(+), 372 deletions(-) diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 92ff5fa8f9..8dc3af1ae4 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -398,6 +398,12 @@ cc.ONE_MINUS_SRC_COLOR = 0x301; */ cc.ONE_MINUS_DST_ALPHA = 0x305; +/** + * @constant + * @type Number + */ +cc.DST_COLOR = 0x0307; + /** * @constant * @type Number diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 2db85431aa..3de19d58bf 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -252,7 +252,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._durationTween = durationTween; } - var movementBoneData = null; + var movementBoneData; this._tweenList = []; var map = this._armature.getBoneDic(); diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 99c8d39d8d..b8ee0e01f3 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -89,7 +89,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @param {ccs.TweenType} tweenEasing */ play:function (movementBoneData, durationTo, durationTween, loop, tweenEasing) { - ccs.ProcessBase.prototype.play.call(this, durationTo, tweenEasing, loop, tweenEasing); + ccs.ProcessBase.prototype.play.call(this, durationTo, durationTween, loop, tweenEasing); if(loop){ this._loopType = ccs.ANIMATION_TYPE_TO_LOOP_FRONT; diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index 101f57e65b..ef983dd936 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -179,11 +179,14 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ this.x = node.x; this.y = node.y; this.zOrder = node.zOrder; + this.scaleX = node.scaleX; this.scaleY = node.scaleY; this.skewX = node.skewX; this.skewY = node.skewY; + this.tweenRotate = node.tweenRotate; + this.isUseColorInfo = node.isUseColorInfo; this.r = node.r; this.g = node.g; @@ -312,6 +315,9 @@ ccs.SpriteDisplayData = ccs.DisplayData.extend(/** @lends ccs.SpriteDisplayData# copy:function (displayData) { ccs.DisplayData.prototype.copy.call(this,displayData); this.skinData = displayData.skinData; + }, + SpriteDisplayData: function(){ + this.displayType = ccs.DISPLAY_TYPE_SPRITE; } }); @@ -364,6 +370,7 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ init: function () { this.displayDataList.length = 0; + return true; }, /** * add display data @@ -474,22 +481,24 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ copy:function (frameData) { ccs.BaseData.prototype.copy.call(this, frameData); this.duration = frameData.duration; - this.tweenEasing = frameData.tweenEasing; this.displayIndex = frameData.displayIndex; - this.movement = frameData.movement; - this.event = frameData.event; - this.sound = frameData.sound; - this.soundEffect = frameData.soundEffect; - this.blendFunc = frameData.blendFunc; - this.isTween = frameData.isTween; + this.tweenEasing = frameData.tweenEasing; this.easingParamNumber = frameData.easingParamNumber; - this.easingParams.length = 0; + +// this.movement = frameData.movement; +// this.event = frameData.event; +// this.sound = frameData.sound; +// this.soundEffect = frameData.soundEffect; +// this.easingParams.length = 0; if (this.easingParamNumber != 0){ for (var i = 0; i " + ccs.CONST_ARMATURES + " > " + ccs.CONST_ARMATURE + ""); var armatureDataManager = ccs.armatureDataManager; for (var i = 0; i < armaturesXML.length; i++) { @@ -326,6 +331,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ armatureDataManager.addArmatureData(armatureData.name, armatureData, dataInfo.filename); } + /* + * Begin decode animation data from xml + */ var animationsXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_ANIMATIONS + " > " + ccs.CONST_ANIMATION + ""); for (var i = 0; i < animationsXML.length; i++) { var animationData = this.decodeAnimation(animationsXML[i], dataInfo); @@ -337,7 +345,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var textureData = this.decodeTexture(texturesXML[i], dataInfo); armatureDataManager.addTextureData(textureData.name, textureData, dataInfo.filename); } - skeleton = null; + }, decodeArmature: function (armatureXML, dataInfo) { @@ -350,6 +358,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var bonesXML = armatureXML.querySelectorAll(ccs.CONST_ARMATURE + " > " + ccs.CONST_BONE); for (var i = 0; i < bonesXML.length; i++) { + /* + * If this bone have parent, then get the parent bone xml + */ var boneXML = bonesXML[i]; var parentName = boneXML.getAttribute(ccs.CONST_A_PARENT); var parentXML = null; @@ -371,6 +382,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ decodeArmatureFromJSON: function (json, dataInfo) { var armatureData = new ccs.ArmatureData(); + armatureData.init(); var name = json[ccs.CONST_A_NAME]; if (name) { @@ -381,34 +393,51 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var boneDataList = json[ccs.CONST_BONE_DATA]; for (var i = 0; i < boneDataList.length; i++) { - armatureData.addBoneData(this.decodeBoneFromJson(boneDataList[i], dataInfo)); + var boneData = this.decodeBoneFromJson(boneDataList[i], dataInfo); + armatureData.addBoneData(boneData); } return armatureData; }, decodeBone: function (boneXML, parentXML, dataInfo) { + var boneData = new ccs.BoneData(); + boneData.init(); var name = boneXML.getAttribute(ccs.CONST_A_NAME); - if (name == "") { - return; - } - var boneData = new ccs.BoneData(); boneData.name = name; + boneData.parentName = boneXML.getAttribute(ccs.CONST_A_PARENT) || ""; + boneData.zOrder = parseInt(boneXML.getAttribute(ccs.CONST_A_Z)) || 0; var displaysXML = boneXML.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_DISPLAY); - - var displayXML; for (var i = 0; i < displaysXML.length; i++) { - displayXML = displaysXML[i]; + var displayXML = displaysXML[i]; var displayData = this.decodeBoneDisplay(displayXML, dataInfo); boneData.addDisplayData(displayData); } return boneData; }, + decodeBoneFromJson: function (json, dataInfo) { + var boneData = new ccs.BoneData(); + boneData.init(); + + this.decodeNodeFromJson(boneData, json, dataInfo); + + boneData.name = json[ccs.CONST_A_NAME] || ""; + + boneData.parentName = json[ccs.CONST_A_PARENT] || ""; + var displayDataList = json[ccs.CONST_DISPLAY_DATA] || []; + for (var i = 0; i < displayDataList.length; i++) { + var locDisplayData = this.decodeBoneDisplayFromJson(displayDataList[i], dataInfo); + boneData.addDisplayData(locDisplayData); + } + return boneData; + }, + decodeBoneDisplay: function (displayXML, dataInfo) { + var isArmature = parseFloat(displayXML.getAttribute(ccs.CONST_A_IS_ARMATURE)) || 0; var displayData = null; @@ -420,6 +449,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ displayData = new ccs.SpriteDisplayData(); displayData.displayType = ccs.DISPLAY_TYPE_SPRITE; } + var displayName = displayXML.getAttribute(ccs.CONST_A_NAME) || ""; if (displayName) { displayData.displayName = displayName; @@ -427,6 +457,49 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return displayData; }, + decodeBoneDisplayFromJson: function (json, dataInfo) { + var displayType = json[ccs.CONST_A_DISPLAY_TYPE] || ccs.DISPLAY_TYPE_SPRITE; + var displayData = null; + + switch (displayType) { + case ccs.DISPLAY_TYPE_SPRITE: + displayData = new ccs.SpriteDisplayData(); + + displayData.displayName = json[ccs.CONST_A_NAME] || ""; + + var dicArray = json[ccs.CONST_SKIN_DATA] || []; + var dic = dicArray[0]; + if (dic) { + var skinData = displayData.skinData; + skinData.x = (dic[ccs.CONST_A_X] || 0) * this._positionReadScale; + skinData.y = (dic[ccs.CONST_A_Y] || 0) * this._positionReadScale; + skinData.scaleX = dic[ccs.CONST_A_SCALE_X] || 1; + skinData.scaleY = dic[ccs.CONST_A_SCALE_Y] || 1; + skinData.skewX = dic[ccs.CONST_A_SKEW_X] || 1; + skinData.skewY = dic[ccs.CONST_A_SKEW_Y] || 1; + + skinData.x *= dataInfo.contentScale; + skinData.y *= dataInfo.contentScale; + } + break; + case ccs.DISPLAY_TYPE_ARMATURE: + displayData = new ccs.ArmatureDisplayData(); + displayData.displayName = json[ccs.CONST_A_NAME] || ""; + break; + case ccs.DISPLAY_TYPE_PARTICLE: + displayData = new ccs.ParticleDisplayData(); + displayData.displayName = dataInfo.basefilePath + json[ccs.CONST_A_PLIST] || ""; + break; + default: + displayData = new ccs.SpriteDisplayData(); + break; + } + + displayData.displayType = displayType; + + return displayData; + }, + decodeAnimation: function (animationXML, dataInfo) { var aniData = new ccs.AnimationData(); @@ -447,6 +520,22 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return aniData; }, + decodeAnimationFromJson: function (json, dataInfo) { + var aniData = new ccs.AnimationData(); + + var name = json[ccs.CONST_A_NAME]; + if(name){ + aniData.name = json[ccs.CONST_A_NAME]; + } + + var movementDataList = json[ccs.CONST_MOVEMENT_DATA] || []; + for (var i = 0; i < movementDataList.length; i++) { + var locMovementData = this.decodeMovementFromJson(movementDataList[i], dataInfo); + aniData.addMovement(locMovementData); + } + return aniData; + }, + decodeMovement: function (movementXML, armatureData, dataInfo) { var movementData = new ccs.MovementData(); @@ -505,6 +594,34 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return movementData; }, + decodeMovementFromJson: function (json, dataInfo) { + var movementData = new ccs.MovementData(); + + movementData.loop = json[ccs.CONST_A_LOOP] || false; + movementData.durationTween = json[ccs.CONST_A_DURATION_TWEEN] || 0; + movementData.durationTo = json[ccs.CONST_A_DURATION_TO] || 0; + movementData.duration = json[ccs.CONST_A_DURATION] || 0; + + if(json[ccs.CONST_A_DURATION]){ + movementData.scale = 1; + }else{ + movementData.scale = json[ccs.CONST_A_MOVEMENT_SCALE] || 1; + } + + movementData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; + var name = json[ccs.CONST_A_NAME]; + if(name){ + movementData.name = name; + } + + var movementBoneList = json[ccs.CONST_MOVEMENT_BONE_DATA] || []; + for (var i = 0; i < movementBoneList.length; i++) { + var locMovementBoneData = this.decodeMovementBoneFromJson(movementBoneList[i], dataInfo); + movementData.addMovementBoneData(locMovementBoneData); + } + return movementData; + }, + decodeMovementBone: function (movBoneXml, parentXml, boneData, dataInfo) { var movBoneData = new ccs.MovementBoneData(); movBoneData.init(); @@ -528,7 +645,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var parentFrameXML = null; var parentXMLList = []; - //* get the parent frame xml list, we need get the origin data + /* + * get the parent frame xml list, we need get the origin data + */ if (parentXml != null) { var parentFramesXML = parentXml.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_FRAME); for (var i = 0; i < parentFramesXML.length; i++) { @@ -550,7 +669,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ for (var ii = 0; ii < framesXML.length; ii++) { var frameXML = framesXML[ii]; if (parentXml) { - //* in this loop we get the corresponding parent frame xml + /* + * in this loop we get the corresponding parent frame xml + */ while (j < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) { parentFrameXML = parentXMLList[j]; parentTotalDuration += currentDuration; @@ -583,97 +704,217 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } } - if (movBoneData.frameList.length > 0) { - var frameData = new ccs.FrameData(); - frameData.copy(movBoneData.frameList[movBoneData.frameList.length - 1]); - frameData.frameID = movBoneData.duration; - movBoneData.addFrameData(frameData); - } + var frameData = new ccs.FrameData(); + frameData.copy(movBoneData.frameList[movBoneData.frameList.length - 1]); + frameData.frameID = movBoneData.duration; + movBoneData.addFrameData(frameData); return movBoneData; }, + decodeMovementBoneFromJson: function (json, dataInfo) { + var movementBoneData = new ccs.MovementBoneData(); + movementBoneData.init(); + + movementBoneData.delay = json[ccs.CONST_A_MOVEMENT_DELAY] || 0; + + var name = json[ccs.CONST_A_NAME]; + if(name){ + movementBoneData.name = name; + } + + var length = json[ccs.CONST_FRAME_DATA] || []; + for (var i = 0; i < length; i++) + { + var dic = json[ccs.CONST_FRAME_DATA][i]; + var frameData = this.decodeFrame(dic, dataInfo); + movementBoneData.addFrameData(frameData); + + if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) + { + frameData.frameID = movementBoneData.duration; + movementBoneData.duration += frameData.duration; + } + } + + if (dataInfo.cocoStudioVersion < ccs.VERSION_CHANGE_ROTATION_RANGE) { + //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) + var frames = movementBoneData.frameList; + var pi = Math.PI; + for (var i = frames.length - 1; i >= 0; i--) { + if (i > 0) { + var difSkewX = frames[i].skewX - frames[i - 1].skewX; + var difSkewY = frames[i].skewY - frames[i - 1].skewY; + + if (difSkewX < -pi || difSkewX > pi) { + frames[i - 1].skewX = difSkewX < 0 ? frames[i - 1].skewX - 2 * pi : frames[i - 1].skewX + 2 * pi; + } + + if (difSkewY < -pi || difSkewY > pi) { + frames[i - 1].skewY = difSkewY < 0 ? frames[i - 1].skewY - 2 * pi : frames[i - 1].skewY + 2 * pi; + } + } + } + } + + if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) { + if (movementBoneData.frameList.length > 0) { + var frameData = new ccs.FrameData(); + frameData.copy(movementBoneData.frameList[movementBoneData.frameList.length - 1]); + movementBoneData.addFrameData(frameData); + frameData.frameID = movementBoneData.duration; + } + } + return movementBoneData; + }, + decodeFrame: function (frameXML, parentFrameXml, boneData, dataInfo) { + + var x = 0, y = 0, scale_x = 0, scale_y = 0, skew_x = 0, skew_y = 0, tweenRotate = 0; + var duration = 0, displayIndex = 0, zOrder = 0, tweenEasing = 0, blendType = 0; + var frameData = new ccs.FrameData(); - frameData.movement = frameXML.getAttribute(ccs.CONST_A_MOVEMENT) || ""; - frameData.event = frameXML.getAttribute(ccs.CONST_A_EVENT) || ""; - frameData.blendType = parseInt(frameXML.getAttribute(ccs.CONST_A_BLEND_TYPE)) || ccs.BLEND_TYPE_NORMAL; - - var blendFunc = frameData.blendFunc; - switch (frameData.blendType) { - case ccs.BLEND_TYPE_NORMAL: - blendFunc.src = cc.BLEND_SRC; - blendFunc.dst = cc.BLEND_DST; - break; - case ccs.BLEND_TYPE_ADD: - blendFunc.src = cc.SRC_ALPHA; - blendFunc.dst = cc.ONE; - break; - case ccs.BLEND_TYPE_MULTIPLY: - blendFunc.src = cc.ONE_MINUS_SRC_ALPHA; - blendFunc.dst = cc.ONE_MINUS_DST_COLOR; - break; - case ccs.BLEND_TYPE_SCREEN: - blendFunc.src = cc.ONE; - blendFunc.dst = cc.ONE_MINUS_DST_COLOR; - break; - default: - break; - } - frameData.sound = frameXML.getAttribute(ccs.CONST_A_SOUND) || ""; - frameData.soundEffect = frameXML.getAttribute(ccs.CONST_A_SOUND_EFFECT) || ""; + frameData.strMovement = frameXML.getAttribute(ccs.CONST_A_MOVEMENT) || ""; + frameData.movement = frameData.strMovement; + frameData.strEvent = frameXML.getAttribute(ccs.CONST_A_EVENT) || ""; + frameData.event = frameData.strEvent; + frameData.strSound = frameXML.getAttribute(ccs.CONST_A_SOUND) || ""; + frameData.sound = frameData.strSound; + frameData.strSoundEffect = frameXML.getAttribute(ccs.CONST_A_SOUND_EFFECT) || ""; + frameData.soundEffect = frameData.strSoundEffect; + var tweenFrame = false; var isTween = frameXML.getAttribute(ccs.CONST_A_TWEEN_FRAME); - if(isTween == null) - isTween = true; - frameData.isTween = Boolean(isTween); - if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { - frameData.x = parseFloat(frameXML.getAttribute(ccs.CONST_A_COCOS2DX_X)) || 0; - frameData.y = -parseFloat(frameXML.getAttribute(ccs.CONST_A_COCOS2DX_Y)) || 0; - } - else { - frameData.x = parseFloat(frameXML.getAttribute(ccs.CONST_A_X)) || 0; - frameData.y = -parseFloat(frameXML.getAttribute(ccs.CONST_A_Y)) || 0; - } - frameData.x *= this._positionReadScale; - frameData.y *= this._positionReadScale; - frameData.scaleX = parseFloat(frameXML.getAttribute(ccs.CONST_A_SCALE_X)) || 0; - frameData.scaleY = parseFloat(frameXML.getAttribute(ccs.CONST_A_SCALE_Y)) || 0; - frameData.skewX = cc.degreesToRadians(parseFloat(frameXML.getAttribute(ccs.CONST_A_SKEW_X)) || 0); - frameData.skewY = cc.degreesToRadians(-parseFloat(frameXML.getAttribute(ccs.CONST_A_SKEW_Y)) || 0); - frameData.duration = parseFloat(frameXML.getAttribute(ccs.CONST_A_DURATION)) || 0; - frameData.displayIndex = parseFloat(frameXML.getAttribute(ccs.CONST_A_DISPLAY_INDEX)) || 0; - frameData.zOrder = parseFloat(frameXML.getAttribute(ccs.CONST_A_Z)) || 0; - frameData.tweenRotate = parseFloat(frameXML.getAttribute(ccs.CONST_A_TWEEN_ROTATION)) || 0; - - var colorTransformXMLList = frameXML.querySelectorAll(ccs.CONST_FRAME + " > " + ccs.CONST_A_COLOR_TRANSFORM); - if (colorTransformXMLList.length > 0) { - var colorTransformXML = colorTransformXMLList[0]; - var alpha = 0, red = 0, green = 0, blue = 0; - var alphaOffset = 0, redOffset = 0, greenOffset = 0, blueOffset = 100; - - alpha = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_ALPHA)) || alpha; - red = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_RED)) || red; - green = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_GREEN)) || green; - blue = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_BLUE)) || blue; - - var str_alphaOffset = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA_OFFSET); - if (str_alphaOffset) { - alphaOffset = parseFloat(str_alphaOffset); + var x, y; + if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) + { + x = frameXML.getAttribute(ccs.CONST_A_COCOS2DX_X); + if(x) + { + frameData.x = x; + frameData.x *= this._positionReadScale; } - var str_redOffset = colorTransformXML.getAttribute(ccs.CONST_A_RED_OFFSET); - if (str_redOffset) { - redOffset = parseFloat(str_redOffset); + y = frameXML.getAttribute(ccs.CONST_A_COCOS2DX_Y); + if(y) + { + frameData.y = -y; + frameData.y *= this._positionReadScale; } - var str_greenOffset = colorTransformXML.getAttribute(ccs.CONST_A_GREEN_OFFSET); - if (str_redOffset) { - greenOffset = parseFloat(str_greenOffset); + } + else + { + x = frameXML.getAttribute(ccs.CONST_A_X); + if(x) + { + frameData.x = x; + frameData.x *= this._positionReadScale; } - var str_blueOffset = colorTransformXML.getAttribute(ccs.CONST_A_BLUE_OFFSET); - if (str_blueOffset) { - blueOffset = parseFloat(str_blueOffset); + y = frameXML.getAttribute(ccs.CONST_A_Y); + if(y) + { + frameData.y = -y; + frameData.y *= this._positionReadScale; } + } + + + scale_x = frameXML.getAttribute(ccs.CONST_A_SCALE_X); + if( scale_x != null ) + { + frameData.scaleX = scale_x; + } + scale_y = frameXML.getAttribute(ccs.CONST_A_SCALE_Y); + if( scale_y != null ) + { + frameData.scaleY = scale_y; + } + skew_x = frameXML.getAttribute(ccs.CONST_A_SKEW_X); + if( skew_x != null ) + { + frameData.skewX = cc.degreesToRadians(skew_x); + } + skew_y = frameXML.getAttribute(ccs.CONST_A_SKEW_Y); + if( skew_y != null ) + { + frameData.skewY = cc.degreesToRadians(-skew_y); + } + duration = frameXML.getAttribute(ccs.CONST_A_DURATION); + if( duration != null ) + { + frameData.duration = duration; + } + displayIndex = frameXML.getAttribute(ccs.CONST_A_DISPLAY_INDEX); + if( displayIndex != null ) + { + frameData.displayIndex = displayIndex; + } + zOrder = frameXML.getAttribute(ccs.CONST_A_Z); + if( zOrder != null ) + { + frameData.zOrder = zOrder; + } + tweenRotate = frameXML.getAttribute(ccs.CONST_A_TWEEN_ROTATE); + if( tweenRotate != null ) + { + frameData.tweenRotate = tweenRotate; + } + + blendType = frameXML.getAttribute(ccs.CONST_A_BLEND_TYPE); + if ( blendType != null ) + { + var blendFunc = frameData.blendFunc; + switch (blendType) + { + case ccs.BLEND_TYPE_NORMAL: + { + blendFunc.src = cc.BLEND_SRC; + blendFunc.dst = cc.BLEND_DST; + } + break; + case ccs.BLEND_TYPE_ADD: + { + blendFunc.src = cc.SRC_ALPHA; + blendFunc.dst = cc.ONE; + } + break; + case ccs.BLEND_TYPE_MULTIPLY: + { + blendFunc.src = cc.DST_COLOR; + blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + } + break; + case ccs.BLEND_TYPE_SCREEN: + { + blendFunc.src = cc.ONE; + blendFunc.dst = cc.ONE_MINUS_DST_COLOR; + } + break; + default: + { + frameData.blendFunc.src = cc.BLEND_SRC; + frameData.blendFunc.dst = cc.BLEND_DST; + } + break; + } + } + + var colorTransformXML = frameXML.querySelectorAll(ccs.CONST_FRAME + " > " + ccs.CONST_A_COLOR_TRANSFORM); + if (colorTransformXML) + { + colorTransformXML = colorTransformXML[0]; + var alpha, red, green, blue = 100; + var alphaOffset, redOffset, greenOffset, blueOffset = 0; + + alpha = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA); + red = colorTransformXML.getAttribute(ccs.CONST_A_RED); + green = colorTransformXML.getAttribute(ccs.CONST_A_GREEN); + blue = colorTransformXML.getAttribute(ccs.CONST_A_BLUE); + + alphaOffset = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA_OFFSET); + redOffset = colorTransformXML.getAttribute(ccs.CONST_A_RED_OFFSET); + greenOffset = colorTransformXML.getAttribute(ccs.CONST_A_GREEN_OFFSET); + blueOffset = colorTransformXML.getAttribute(ccs.CONST_A_BLUE_OFFSET); frameData.a = 2.55 * alphaOffset + alpha; frameData.r = 2.55 * redOffset + red; @@ -682,15 +923,21 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ frameData.isUseColorInfo = true; } - if (frameData.displayIndex == -1) { - frameData.a = 0; - } - var tweenEasing = frameXML.getAttribute(ccs.CONST_A_TWEEN_EASING); - if (tweenEasing) { - if (tweenEasing != ccs.CONST_FL_NAN) { - frameData.tweenEasing = tweenEasing == 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; - } else { + var _easing = frameXML.getAttribute(ccs.CONST_A_TWEEN_EASING); + if(_easing != null) + { + var str = _easing; + if(str != ccs.CONST_FL_NAN) + { + tweenEasing = frameXML.getAttribute(ccs.CONST_A_TWEEN_EASING); + if( tweenEasing ) + { + frameData.tweenEasing = tweenEasing == 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; + } + } + else + { frameData.tweenEasing = ccs.TweenType.linear; } } @@ -728,15 +975,22 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var bd_dst = json[ccs.CONST_A_BLEND_DST] || cc.BLEND_DST; frameData.blendFunc.src = bd_src; frameData.blendFunc.dst = bd_dst; - frameData.duration = json[ccs.CONST_A_DURATION] || 0; - frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME]; + frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME] || true; - frameData.event = json[ccs.CONST_A_EVENT] || null; + var event = json[ccs.CONST_A_EVENT]; + if(event != null){ + frameData.strEvent = event; + frameData.event = event; + } if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) - frameData.duration = json[ccs.CONST_A_DURATION] || 0; + { + frameData.duration = json[ccs.CONST_A_DURATION] || 1; + } else - frameData.frameID = json[ccs.CONST_A_FRAME_INDEX] || 0; + { + frameData.frameID = json[ccs.CONST_A_FRAME_INDEX]; + } var twEPs = json[ccs.CONST_A_EASING_PARAM] || []; for (var i = 0; i < twEPs.length; i++) { @@ -747,54 +1001,16 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return frameData; }, - clear: function () { - this._configFileList = []; - this._asyncRefCount = 0; - this._asyncRefTotalCount = 0; - }, - - _asyncCallBack: function (target, selector, percent) { - if (target && (typeof(selector) == "string")) { - target[selector](percent); - } else if (target && (typeof(selector) == "function")) { - selector.call(target, percent); - } - }, - /** - * find the base file path - * @param filePath - * @returns {String} - * @private - */ - _initBaseFilePath: function (filePath) { - var path = filePath; - var pos = path.lastIndexOf("/"); - if (pos > -1) - path = path.substr(0, pos + 1); - else - path = ""; - return path; - }, - - addDataFromXML: function (xml, dataInfo) { - /* - * Need to get the full path of the xml file, or the Tiny XML can't find the xml at IOS - */ - var xmlStr = cc.loader.getRes(xml); - if (!xmlStr) throw "Please load the resource first : " + xml; - var skeletonXML = cc.saxParser.parse(xmlStr); - var skeleton = skeletonXML.documentElement; - if (skeleton) { - this.addDataFromCache(skeleton, dataInfo); - } - }, - decodeTexture: function (textureXML, dataInfo) { var textureData = new ccs.TextureData(); + textureData.init(); + if (textureXML.getAttribute(ccs.CONST_A_NAME)) { textureData.name = textureXML.getAttribute(ccs.CONST_A_NAME); } + var px, py, width, height = 0; + if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { px = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_X)) || 0; py = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_Y)) || 0; @@ -803,6 +1019,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ px = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_X)) || 0; py = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_Y)) || 0; } + width = parseFloat(textureXML.getAttribute(ccs.CONST_A_WIDTH)) || 0; height = parseFloat(textureXML.getAttribute(ccs.CONST_A_HEIGHT)) || 0; @@ -812,15 +1029,42 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ textureData.pivotX = anchorPointX; textureData.pivotY = anchorPointY; + textureData.pivotX = anchorPointX; + textureData.pivotY = anchorPointY; + var contoursXML = textureXML.querySelectorAll(ccs.CONST_SUB_TEXTURE + " > " + ccs.CONST_CONTOUR); for (var i = 0; i < contoursXML.length; i++) { - this.decodeContour(contoursXML[i], dataInfo); + var contourData = this.decodeContour(contoursXML[i], dataInfo); + textureData.addContourData(contourData); + } + return textureData; + }, + + decodeTextureFromJson: function (json) { + var textureData = new ccs.TextureData(); + textureData.init(); + + var name = json[ccs.CONST_A_NAME]; + if(name != null) + textureData.name = name; + + textureData.width = json[ccs.CONST_A_WIDTH] || 0; + textureData.height = json[ccs.CONST_A_HEIGHT] || 0; + textureData.pivotX = json[ccs.CONST_A_PIVOT_X] || 0; + textureData.pivotY = json[ccs.CONST_A_PIVOT_Y] || 0; + + var contourDataList = json[ccs.CONST_CONTOUR_DATA] || []; + for (var i = 0; i < contourDataList.length; i++) { + var locContourData = this.decodeContourFromJson(contourDataList[i]); + textureData.contourDataList.push(locContourData); } return textureData; }, decodeContour: function (contourXML, dataInfo) { var contourData = new ccs.ContourData(); + contourData.init(); + var vertexDatasXML = contourXML.querySelectorAll(ccs.CONST_CONTOUR + " > " + ccs.CONST_CONTOUR_VERTEX); var vertexDataXML; for (var i = 0; i < vertexDatasXML.length; i++) { @@ -828,18 +1072,30 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var vertex = cc.p(0, 0); vertex.x = parseFloat(vertexDataXML.getAttribute(ccs.CONST_A_X)) || 0; vertex.y = parseFloat(vertexDataXML.getAttribute(ccs.CONST_A_Y)) || 0; - //vertex.y = - vertex.y;//todo + + vertex.y = - vertex.y; contourData.vertexList.push(vertex); } return contourData; }, - addDataFromJson: function (filePath, dataInfo, isLoadSpriteFrame) { - var fileContent = cc.loader.getRes(filePath); - this.addDataFromJsonCache(fileContent, dataInfo, isLoadSpriteFrame); + decodeContourFromJson: function (json) { + var contourData = new ccs.ContourData(); + contourData.init(); + + var vertexPointList = json[ccs.CONST_VERTEX_POINT] || []; + for (var i = vertexPointList.length - 1; i >= 0; i--) { + var dic = vertexPointList[i]; + var vertex = cc.p(0, 0); + vertex.x = dic[ccs.CONST_A_X] || 0; + vertex.y = dic[ccs.CONST_A_Y] || 0; + contourData.vertexList.push(vertex); + } + return contourData; }, - addDataFromJsonCache: function (dic, dataInfo, isLoadSpriteFrame) { + + addDataFromJsonCache: function (dic, dataInfo) { dataInfo.contentScale = dic[ccs.CONST_CONTENT_SCALE] || 1; // Decode armatures @@ -886,229 +1142,108 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ animationData = null; }, - decodeBoneFromJson: function (json, dataInfo) { - var boneData = new ccs.BoneData(); - this.decodeNodeFromJson(boneData, json, dataInfo); - boneData.name = json[ccs.CONST_A_NAME] || ""; - boneData.parentName = json[ccs.CONST_A_PARENT] || ""; - var displayDataList = json[ccs.CONST_DISPLAY_DATA] || []; - for (var i = 0; i < displayDataList.length; i++) { - var locDisplayData = this.decodeBoneDisplayFromJson(displayDataList[i], dataInfo); - boneData.addDisplayData(locDisplayData); - } - return boneData; - }, - - decodeBoneDisplayFromJson: function (json, dataInfo) { - var displayType = json[ccs.CONST_A_DISPLAY_TYPE] || ccs.DISPLAY_TYPE_SPRITE; - var displayData = null; - switch (displayType) { - case ccs.DISPLAY_TYPE_SPRITE: - displayData = new ccs.SpriteDisplayData(); - displayData.displayName = json[ccs.CONST_A_NAME] || ""; - - var dicArray = json[ccs.CONST_SKIN_DATA] || []; - var dic = dicArray[0]; - if (dic) { - var skinData = displayData.skinData; - skinData.x = (dic[ccs.CONST_A_X] || 0) * this._positionReadScale; - skinData.y = (dic[ccs.CONST_A_Y] || 0) * this._positionReadScale; - if (dic[ccs.CONST_A_SCALE_X] !== undefined) { - skinData.scaleX = dic[ccs.CONST_A_SCALE_X]; - } - if (dic[ccs.CONST_A_SCALE_Y] !== undefined) { - skinData.scaleY = dic[ccs.CONST_A_SCALE_Y]; - } - skinData.skewX = dic[ccs.CONST_A_SKEW_X] || 0; - skinData.skewY = dic[ccs.CONST_A_SKEW_Y] || 0; - - skinData.x *= dataInfo.contentScale; - skinData.y *= dataInfo.contentScale; - dic = null; - } - break; - case ccs.DISPLAY_TYPE_ARMATURE: - displayData = new ccs.ArmatureDisplayData(); - displayData.displayName = json[ccs.CONST_A_NAME] || ""; - break; - case ccs.DISPLAY_TYPE_PARTICLE: - displayData = new ccs.ParticleDisplayData(); - displayData.displayName = dataInfo.basefilePath + json[ccs.CONST_A_PLIST] || ""; - break; - default: - displayData = new ccs.SpriteDisplayData(); - break; - } - - displayData.displayType = displayType; - - return displayData; - }, - - decodeAnimationFromJson: function (json, dataInfo) { - var aniData = new ccs.AnimationData(); - aniData.name = json[ccs.CONST_A_NAME] || ""; - var movementDataList = json[ccs.CONST_MOVEMENT_DATA] || []; - for (var i = 0; i < movementDataList.length; i++) { - var locMovementData = this.decodeMovementFromJson(movementDataList[i], dataInfo); - aniData.addMovement(locMovementData); - } - return aniData; - }, + decodeNodeFromJson: function (node, json, dataInfo) { + node.x = (json[ccs.CONST_A_X] || 0) * this._positionReadScale; + node.y = (json[ccs.CONST_A_Y] || 0) * this._positionReadScale; - decodeMovementFromJson: function (json, dataInfo) { - var movementData = new ccs.MovementData(); + node.x *= dataInfo.contentScale; + node.y *= dataInfo.contentScale; - movementData.loop = json[ccs.CONST_A_LOOP] || false; - movementData.durationTween = json[ccs.CONST_A_DURATION_TWEEN] || 0; - movementData.durationTo = json[ccs.CONST_A_DURATION_TO] || 0; - movementData.duration = json[ccs.CONST_A_DURATION] || 0; - if (json[ccs.CONST_A_MOVEMENT_SCALE] !== undefined) { - movementData.scale = json[ccs.CONST_A_MOVEMENT_SCALE] - } - movementData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; - movementData.name = json[ccs.CONST_A_NAME] || ""; + node.zOrder = json[ccs.CONST_A_Z] || 0; - var movementBoneList = json[ccs.CONST_MOVEMENT_BONE_DATA] || []; - for (var i = 0; i < movementBoneList.length; i++) { - var locMovementBoneData = this.decodeMovementBoneFromJson(movementBoneList[i], dataInfo); - movementData.addMovementBoneData(locMovementBoneData); - } - return movementData; - }, + node.skewX = json[ccs.CONST_A_SKEW_X] || 0; + node.skewY = json[ccs.CONST_A_SKEW_Y] || 0; + node.scaleX = json[ccs.CONST_A_SCALE_X] || 1; + node.scaleY = json[ccs.CONST_A_SCALE_Y] || 1; - decodeMovementBoneFromJson: function (json, dataInfo) { - var movementBoneData = new ccs.MovementBoneData(); - movementBoneData.delay = json[ccs.CONST_A_MOVEMENT_DELAY] || 0; - if (json[ccs.CONST_A_MOVEMENT_SCALE] !== undefined) { - movementBoneData.scale = json[ccs.CONST_A_MOVEMENT_SCALE]; - } +// var colorDic = json[ccs.CONST_COLOR_INFO] || null; +// if (colorDic) { +// //compatible old version +// if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) { +// colorDic = colorDic[0]; +// } +// node.a = colorDic[ccs.CONST_A_ALPHA]; +// node.r = colorDic[ccs.CONST_A_RED]; +// node.g = colorDic[ccs.CONST_A_GREEN]; +// node.b = colorDic[ccs.CONST_A_BLUE]; +// node.isUseColorInfo = true; +// delete colorDic; +// } + var colorDic; + if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) + { + colorDic = json[0]; + if (colorDic) + { + node.a = colorDic[ccs.CONST_A_ALPHA] || 255; + node.r = colorDic[ccs.CONST_A_RED] || 255; + node.g = colorDic[ccs.CONST_A_GREEN] || 255; + node.b = colorDic[ccs.CONST_A_BLUE] || 255; - movementBoneData.name = json[ccs.CONST_A_NAME] || ""; - var frameDataList = json[ccs.CONST_FRAME_DATA] || []; - for (var i = 0; i < frameDataList.length; i++) { - var frameData = this.decodeFrameFromJson(frameDataList[i], dataInfo); - movementBoneData.addFrameData(frameData); - if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) { - frameData.frameID = movementBoneData.duration; - movementBoneData.duration += frameData.duration; + node.isUseColorInfo = true; } } + else + { + colorDic = json[ccs.CONST_COLOR_INFO] || null; + if (colorDic) + { + node.a = colorDic[ccs.CONST_A_ALPHA] || 255; + node.r = colorDic[ccs.CONST_A_RED] || 255; + node.g = colorDic[ccs.CONST_A_GREEN] || 255; + node.b = colorDic[ccs.CONST_A_BLUE] || 255; - if (dataInfo.cocoStudioVersion < ccs.VERSION_CHANGE_ROTATION_RANGE) { - //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) - var frames = movementBoneData.frameList; - var pi = Math.PI; - for (var i = frames.length - 1; i >= 0; i--) { - if (i > 0) { - var difSkewX = frames[i].skewX - frames[i - 1].skewX; - var difSkewY = frames[i].skewY - frames[i - 1].skewY; - - if (difSkewX < -pi || difSkewX > pi) { - frames[i - 1].skewX = difSkewX < 0 ? frames[i - 1].skewX - 2 * pi : frames[i - 1].skewX + 2 * pi; - } - - if (difSkewY < -pi || difSkewY > pi) { - frames[i - 1].skewY = difSkewY < 0 ? frames[i - 1].skewY - 2 * pi : frames[i - 1].skewY + 2 * pi; - } - } + node.isUseColorInfo = true; } } - if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) { - if (movementBoneData.frameList.length > 0) { - var frameData = new ccs.FrameData(); - frameData.copy(movementBoneData.frameList[movementBoneData.frameList.length - 1]); - movementBoneData.addFrameData(frameData); - frameData.frameID = movementBoneData.duration; - } - } - return movementBoneData; }, - decodeTextureFromJson: function (json) { - var textureData = new ccs.TextureData(); - textureData.name = json[ccs.CONST_A_NAME] || ""; - textureData.width = json[ccs.CONST_A_WIDTH] || 0; - textureData.height = json[ccs.CONST_A_HEIGHT] || 0; - textureData.pivotX = json[ccs.CONST_A_PIVOT_X] || 0; - textureData.pivotY = json[ccs.CONST_A_PIVOT_Y] || 0; + clear: function () { + this._configFileList = []; + this._asyncRefCount = 0; + this._asyncRefTotalCount = 0; + }, - var contourDataList = json[ccs.CONST_CONTOUR_DATA] || []; - for (var i = 0; i < contourDataList.length; i++) { - var locContourData = this.decodeContourFromJson(contourDataList[i]); - textureData.contourDataList.push(locContourData); + _asyncCallBack: function (target, selector, percent) { + if(selector && typeof target === 'function'){ + target.call(selector, percent); + } + if(selector && typeof target === 'string'){ + selector[target](percent); } - return textureData; + }, + /** + * find the base file path + * @param filePath + * @returns {String} + * @private + */ + _initBaseFilePath: function (filePath) { + var path = filePath; + var pos = path.lastIndexOf("/"); + if (pos > -1) + path = path.substr(0, pos + 1); + else + path = ""; + return path; }, - decodeContourFromJson: function (json) { - var contourData = new ccs.ContourData(); - var vertexPointList = json[ccs.CONST_VERTEX_POINT] || []; - for (var i = 0; i < vertexPointList.length; i++) { - var dic = vertexPointList[i]; - var vertex = cc.p(0, 0); - vertex.x = dic[ccs.CONST_A_X] || 0; - vertex.y = dic[ccs.CONST_A_Y] || 0; - contourData.vertexList.push(vertex); + addDataFromXML: function (xml, dataInfo) { + /* + * Need to get the full path of the xml file, or the Tiny XML can't find the xml at IOS + */ + var xmlStr = cc.loader.getRes(xml); + if (!xmlStr) throw "Please load the resource first : " + xml; + var skeletonXML = cc.saxParser.parse(xmlStr); + var skeleton = skeletonXML.documentElement; + if (skeleton) { + this.addDataFromCache(skeleton, dataInfo); } - return contourData; }, - decodeNodeFromJson: function (node, json, dataInfo) { - node.x = json[ccs.CONST_A_X] || 0; - node.y = json[ccs.CONST_A_Y] || 0; - - node.x *= dataInfo.contentScale; - node.y *= dataInfo.contentScale; - - node.zOrder = json[ccs.CONST_A_Z] || 0; - - node.skewX = json[ccs.CONST_A_SKEW_X] || 0; - node.skewY = json[ccs.CONST_A_SKEW_Y] || 0; - node.scaleX = json[ccs.CONST_A_SCALE_X] || 1; - node.scaleY = json[ccs.CONST_A_SCALE_Y] || 1; - - var colorDic = json[ccs.CONST_COLOR_INFO] || null; - if (colorDic) { - //compatible old version - if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) { - colorDic = colorDic[0]; - } - node.a = colorDic[ccs.CONST_A_ALPHA]; - node.r = colorDic[ccs.CONST_A_RED]; - node.g = colorDic[ccs.CONST_A_GREEN]; - node.b = colorDic[ccs.CONST_A_BLUE]; - node.isUseColorInfo = true; - delete colorDic; - } -// var colorDic; -// if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) -// { -// colorDic = json[0]; -// if (colorDic) -// { -// node.a = colorDic[ccs.CONST_A_ALPHA] || 255; -// node.r = colorDic[ccs.CONST_A_RED] || 255; -// node.g = colorDic[ccs.CONST_A_GREEN] || 255; -// node.b = colorDic[ccs.CONST_A_BLUE] || 255; -// -// node.isUseColorInfo = true; -// } -// } -// else -// { -// colorDic = json[ccs.CONST_COLOR_INFO] || null; -// if (colorDic) -// { -// node.a = DICTOOL.getIntValue_json(colorDic, A_ALPHA, 255); -// node.r = DICTOOL.getIntValue_json(colorDic, A_RED, 255); -// node.g = DICTOOL.getIntValue_json(colorDic, A_GREEN, 255); -// node.b = DICTOOL.getIntValue_json(colorDic, A_BLUE, 255); -// -// node.isUseColorInfo = true; -// } -// } - + addDataFromJson: function (filePath, dataInfo) { + var fileContent = cc.loader.getRes(filePath); + this.addDataFromJsonCache(fileContent, dataInfo); } }; \ No newline at end of file From 213737d125c15e3b539578fefd3c69aa3272a9c3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 17 Jul 2014 17:48:30 +0800 Subject: [PATCH 0310/1564] Issue #5704: remove the unused codes. --- extensions/ccui/base-classes/UIWidget.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index b79e9f404d..f54354be6e 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -125,7 +125,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.ignoreContentAdaptWithSize(true); -// this.setTouchEnabled(true); this.setCascadeColorEnabled(true); this.setCascadeOpacityEnabled(true); @@ -1576,7 +1575,7 @@ ccui.Widget.DOWN = 1; ccui.Widget.LOCAL_TEXTURE = 0; ccui.Widget.PLIST_TEXTURE = 1; -//touch event type //TODO why don't use a common define ? +//touch event type ccui.Widget.TOUCH_BEGAN = 0; ccui.Widget.TOUCH_MOVED = 1; ccui.Widget.TOUCH_ENDED = 2; From 0851c747a5ddf5e152e69a4888d1cca07d1817cb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 17 Jul 2014 18:08:56 +0800 Subject: [PATCH 0311/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Fixed bug 1. CCDataReaderHelper 2. CCDisplayFactory 3. CCArmatureAnimation --- .../armature/animation/CCArmatureAnimation.js | 69 ------------- .../armature/display/CCDisplayFactory.js | 50 +++++++--- .../armature/utils/CCDataReaderHelper.js | 97 +++---------------- 3 files changed, 45 insertions(+), 171 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 3de19d58bf..f09fbbd516 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -288,75 +288,6 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# } this._armature.update(0); - -// return; -// -// if (durationTo === undefined) { -// durationTo = -1; -// } -// -// if (loop === undefined) { -// loop = -1; -// } -// -// var locMovementData = this._movementData; -// //Get key frame count -// this._rawDuration = locMovementData.duration; -// this._movementID = animationName; -// this._processScale = this._speedScale * locMovementData.scale; -// //Further processing parameters -// durationTo = (durationTo == -1) ? locMovementData.durationTo : durationTo; -// var durationTween = locMovementData.durationTween; -// durationTween = (durationTween == 0) ? this._rawDuration : durationTween;//todo -// var tweenEasing = locMovementData.tweenEasing; -// -// if (loop < 0) { -// loop = locMovementData.loop; -// } else { -// loop = Boolean(loop); -// } -// -// this._onMovementList = false; -// ccs.ProcessBase.prototype.play.call(this, durationTo, tweenEasing); -// -// if (this._rawDuration == 0) { -// this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME; -// } -// else { -// if (loop) { -// this._loopType = ccs.ANIMATION_TYPE_TO_LOOP_FRONT; -// } -// else { -// this._loopType = ccs.ANIMATION_TYPE_NO_LOOP; -// } -// this._durationTween = durationTween; -// } -// -// this._tweenList = []; -// -// var movementBoneData; -// var dict = this._armature.getBoneDic(); -// for (var key in dict) { -// var bone = dict[key]; -// movementBoneData = locMovementData.getMovementBoneData(bone.getName()); -// var tween = bone.getTween(); -// if (movementBoneData && movementBoneData.frameList.length > 0) { -// this._tweenList.push(tween); -// movementBoneData.duration = locMovementData.duration; -// tween.play(movementBoneData, durationTo, durationTween, loop, tweenEasing); -// -// tween.setProcessScale(this._processScale); -// if (bone.getChildArmature()) { -// bone.getChildArmature().getAnimation().setProcessScale(this._processScale); -// } -// } else { -// if (!bone.getIgnoreMovementBoneData()) { -// bone.getDisplayManager().changeDisplayWithIndex(-1, false); -// tween.stop(); -// } -// } -// } -// this._armature.update(0); }, /** diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index 1378655992..a7cccc1ed5 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -77,7 +77,8 @@ ccs.displayFactory = { this.updateArmatureDisplay(bone, display, dt); break; default: - display.setAdditionalTransform(bone.getNodeToArmatureTransform()); + var transform = bone.getNodeToArmatureTransform(); + display.setAdditionalTransform(transform); break; } if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { @@ -87,18 +88,22 @@ ccs.displayFactory = { if (detector) { var node = decoDisplay.getDisplay(); var displayTransform = node.nodeToParentTransform(); - var helpTransform = this._helpTransform; - helpTransform.a = displayTransform.a; - helpTransform.b = displayTransform.b; - helpTransform.c = displayTransform.c; - helpTransform.d = displayTransform.d; - helpTransform.tx = displayTransform.tx; - helpTransform.ty = displayTransform.ty; var anchorPoint = node.getAnchorPointInPoints(); - anchorPoint = cc.pointApplyAffineTransform(anchorPoint, helpTransform); - helpTransform.tx = anchorPoint.x; - helpTransform.ty = anchorPoint.y; - var t = cc.affineTransformConcat(helpTransform, bone.getArmature().nodeToParentTransform()); +// anchorPoint = cc.pointApplyAffineTransform(anchorPoint, helpTransform); + anchorPoint = cc.pointApplyAffineTransform(anchorPoint, displayTransform); + displayTransform.x = anchorPoint.x; + displayTransform.y = anchorPoint.y; + +// var helpTransform = this._helpTransform; +// helpTransform.a = displayTransform.a; +// helpTransform.b = displayTransform.b; +// helpTransform.c = displayTransform.c; +// helpTransform.d = displayTransform.d; +// helpTransform.tx = displayTransform.tx; +// helpTransform.ty = displayTransform.ty; +// helpTransform.tx = anchorPoint.x; +// helpTransform.ty = anchorPoint.y; + var t = cc.affineTransformConcat(bone.getArmature().nodeToParentTransform(), displayTransform); detector.updateTransform(t); } } @@ -127,32 +132,43 @@ ccs.displayFactory = { skin = ccs.Skin.createWithSpriteFrameName(textureName + ".png"); decoDisplay.setDisplay(skin); + + if(skin == null){ + return; + } + skin.setBone(bone); this.initSpriteDisplay(bone, decoDisplay, displayData.displayName, skin); + var armature = bone.getArmature(); if (armature) { if (armature.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED) skin.setSkinData(displayData.skinData); else - skin.setSkinData(bone.getBoneData()); + skin.setSkinData(bone.boneData); } }, initSpriteDisplay: function (bone, decoDisplay, displayName, skin) { + //! remove .xxx var textureName = displayName; var startPos = textureName.lastIndexOf("."); + if (startPos != -1) textureName = textureName.substring(0, startPos); + var textureData = ccs.armatureDataManager.getTextureData(textureName); if (textureData) { //! Init display anchorPoint, every Texture have a anchor point skin.setAnchorPoint(textureData.pivotX, textureData.pivotY); } + if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { if (textureData && textureData.contourDataList.length > 0) { - var detector = ccs.ColliderDetector.create(bone); - detector.addContourDataList(textureData.contourDataList); - decoDisplay.setColliderDetector(detector); + //! create ContourSprite + var colliderDetector = ccs.ColliderDetector.create(bone); + colliderDetector.addContourDataList(textureData.contourDataList); + decoDisplay.setColliderDetector(colliderDetector); } } }, @@ -161,6 +177,7 @@ ccs.displayFactory = { var adp = new ccs.ArmatureDisplayData(); adp.copy(displayData); decoDisplay.setDisplayData(adp); + this.createArmatureDisplay(bone, decoDisplay); }, @@ -181,6 +198,7 @@ ccs.displayFactory = { var adp = new ccs.ParticleDisplayData(); adp.copy(displayData); decoDisplay.setDisplayData(adp); + this.createParticleDisplay(bone, decoDisplay); }, diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index b4a1bff876..64eac3daa6 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -28,7 +28,7 @@ */ ccs.CONST_VERSION = "version"; ccs.CONST_VERSION_2_0 = 2.0; -//ccs.CONST_VERSION_COMBINED = 0.3; +ccs.CONST_VERSION_COMBINED = 0.3; ccs.CONST_ARMATURES = "armatures"; ccs.CONST_ARMATURE = "armature"; @@ -152,7 +152,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ _configFileList: [], _flashToolVersion: ccs.CONST_VERSION_2_0, - _cocoStudioVersion: ccs.CONST_VERSION_COMBINED, +// _cocoStudioVersion: ccs.CONST_VERSION_COMBINED, _positionReadScale: 1, _asyncRefCount: 0, _asyncRefTotalCount: 0, @@ -209,11 +209,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (this._configFileList.indexOf(filePath) != -1) { if (target && selector) { if (this._asyncRefTotalCount == 0 && this._asyncRefCount == 0) -// this._asyncCallBack(target, selector, 1); - target.selector(1); + this._asyncCallBack(target, selector, 1); else -// this._asyncCallBack(target, selector, (this._asyncRefTotalCount - this._asyncRefCount) / this._asyncRefTotalCount); - target.selector((this._asyncRefTotalCount - this._asyncRefCount) / this._asyncRefTotalCount); + this._asyncCallBack(target, selector, (this._asyncRefTotalCount - this._asyncRefCount) / this._asyncRefTotalCount); } return; } @@ -233,67 +231,6 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ cc.director.getScheduler().scheduleCallbackForTarget(this, fun, 0.1, false); }, - /* - addDataAsyncCallBack: function(dt){ - //TODO - // the data is generated in loading thread - var dataQueue = this._dataQueue; - - _dataInfoMutex.lock(); - if (dataQueue.empty()) - { - _dataInfoMutex.unlock(); - } - else - { - DataInfo *pDataInfo = dataQueue.front(); - dataQueue.pop(); - _dataInfoMutex.unlock(); - - AsyncStruct *pAsyncStruct = pDataInfo.asyncStruct; - - - if (pAsyncStruct.imagePath != "" && pAsyncStruct.plistPath != "") - { - _getFileMutex.lock(); - ArmatureDataManager::getInstance().addSpriteFrameFromFile(pAsyncStruct.plistPath.c_str(), pAsyncStruct.imagePath.c_str(), pDataInfo.filename.c_str()); - _getFileMutex.unlock(); - } - - while (!pDataInfo.configFileQueue.empty()) - { - std::string configPath = pDataInfo.configFileQueue.front(); - _getFileMutex.lock(); - ArmatureDataManager::getInstance().addSpriteFrameFromFile((pAsyncStruct.baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct.baseFilePath + configPath + ".png").c_str(),pDataInfo.filename.c_str()); - _getFileMutex.unlock(); - pDataInfo.configFileQueue.pop(); - } - - - Ref* target = pAsyncStruct.target; - SEL_SCHEDULE selector = pAsyncStruct.selector; - - --_asyncRefCount; - - if (target && selector) - { - (target.*selector)((_asyncRefTotalCount - _asyncRefCount) / (float)_asyncRefTotalCount); - target.release(); - } - - - delete pAsyncStruct; - delete pDataInfo; - - if (0 == _asyncRefCount) - { - _asyncRefTotalCount = 0; - Director::getInstance().getScheduler().unschedule(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this); - } - } - }, - */ - removeConfigFile: function (configFile) { // cc.arrayRemoveObject(this._configFileList, configFile); var len = this._configFileList.length; @@ -475,8 +412,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ skinData.y = (dic[ccs.CONST_A_Y] || 0) * this._positionReadScale; skinData.scaleX = dic[ccs.CONST_A_SCALE_X] || 1; skinData.scaleY = dic[ccs.CONST_A_SCALE_Y] || 1; - skinData.skewX = dic[ccs.CONST_A_SKEW_X] || 1; - skinData.skewY = dic[ccs.CONST_A_SKEW_Y] || 1; + skinData.skewX = dic[ccs.CONST_A_SKEW_X]; + skinData.skewY = dic[ccs.CONST_A_SKEW_Y]; skinData.x *= dataInfo.contentScale; skinData.y *= dataInfo.contentScale; @@ -602,7 +539,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ movementData.durationTo = json[ccs.CONST_A_DURATION_TO] || 0; movementData.duration = json[ccs.CONST_A_DURATION] || 0; - if(json[ccs.CONST_A_DURATION]){ + if(json[ccs.CONST_A_DURATION] == null){ movementData.scale = 1; }else{ movementData.scale = json[ccs.CONST_A_MOVEMENT_SCALE] || 1; @@ -722,11 +659,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ movementBoneData.name = name; } - var length = json[ccs.CONST_FRAME_DATA] || []; + var framesData = json[ccs.CONST_FRAME_DATA] || []; + var length = framesData.length; for (var i = 0; i < length; i++) { var dic = json[ccs.CONST_FRAME_DATA][i]; - var frameData = this.decodeFrame(dic, dataInfo); + var frameData = this.decodeFrameFromJson(dic, dataInfo); movementBoneData.addFrameData(frameData); if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) @@ -736,7 +674,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } } - if (dataInfo.cocoStudioVersion < ccs.VERSION_CHANGE_ROTATION_RANGE) { + if (dataInfo.cocoStudioVersion <= ccs.VERSION_CHANGE_ROTATION_RANGE) { //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) var frames = movementBoneData.frameList; var pi = Math.PI; @@ -1156,19 +1094,6 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ node.scaleX = json[ccs.CONST_A_SCALE_X] || 1; node.scaleY = json[ccs.CONST_A_SCALE_Y] || 1; -// var colorDic = json[ccs.CONST_COLOR_INFO] || null; -// if (colorDic) { -// //compatible old version -// if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) { -// colorDic = colorDic[0]; -// } -// node.a = colorDic[ccs.CONST_A_ALPHA]; -// node.r = colorDic[ccs.CONST_A_RED]; -// node.g = colorDic[ccs.CONST_A_GREEN]; -// node.b = colorDic[ccs.CONST_A_BLUE]; -// node.isUseColorInfo = true; -// delete colorDic; -// } var colorDic; if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) { From 2e8cbeba633ef1c8fb4f1e05ec55cedb1d32c215 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 18 Jul 2014 10:17:51 +0800 Subject: [PATCH 0312/1564] =?UTF-8?q?Fixed=20#3546=EF=BC=9Afixed=20a=20bug?= =?UTF-8?q?=20of=20cc.LayerGradient,=20its=20drawing=20is=20incorrect=20wh?= =?UTF-8?q?en=20cc.view's=20scale=20doesn't=20equal=201.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos2d/core/layers/CCLayer.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 6fe9d1fa24..655d83c6c4 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -749,10 +749,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.globalCompositeOperation = 'lighter'; context.save(); - var locEGLViewer = cc.view, opacityf = _t._displayedOpacity / 255.0; - var tWidth = _t.width * locEGLViewer.getScaleX(), tHeight = _t.height * locEGLViewer.getScaleY(); - var tGradient = context.createLinearGradient(_t._gradientStartPoint.x, _t._gradientStartPoint.y, - _t._gradientEndPoint.x, _t._gradientEndPoint.y); + var opacityf = _t._displayedOpacity / 255.0; + var scaleX = cc.view.getScaleX(), scaleY = cc.view.getScaleY(); + var tWidth = _t.width * scaleX, tHeight = _t.height * scaleY; + var tGradient = context.createLinearGradient(_t._gradientStartPoint.x * scaleX, _t._gradientStartPoint.y * scaleY, + _t._gradientEndPoint.x * scaleX, _t._gradientEndPoint.y * scaleY); var locDisplayedColor = _t._displayedColor, locEndColor = _t._endColor; tGradient.addColorStop(0, "rgba(" + Math.round(locDisplayedColor.r) + "," + Math.round(locDisplayedColor.g) + "," + Math.round(locDisplayedColor.b) + "," + (opacityf * (_t._startOpacity / 255)).toFixed(4) + ")"); @@ -764,6 +765,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (_t._rotation != 0) context.rotate(_t._rotationRadians); context.restore(); + cc.g_NumberOfDraws++; }; _p._updateColor = function () { var _t = this; From da12d083059195fee93e4c549613a31f31dab0b7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 18 Jul 2014 11:48:24 +0800 Subject: [PATCH 0313/1564] Closed #581: fixed a bug of cc.TMXLayer that it can't display all map image when its type is hexagonal. --- cocos2d/tilemap/CCTMXLayer.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 008910b239..0db523312f 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -141,7 +141,10 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ locCanvas.width = 0 | (locContentSize.width * 1.5 * scaleFactor); locCanvas.height = 0 | (locContentSize.height * 1.5 * scaleFactor); - this._cacheContext.translate(0, locCanvas.height); + if(this.layerOrientation === cc.TMX_ORIENTATION_HEX) + this._cacheContext.translate(0, locCanvas.height - this._mapTileSize.height * 0.5); //translate for hexagonal + else + this._cacheContext.translate(0, locCanvas.height); var locTexContentSize = this._cacheTexture._contentSize; locTexContentSize.width = locCanvas.width; locTexContentSize.height = locCanvas.height; @@ -254,14 +257,22 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ var locSubCacheCanvasArr = this._subCacheCanvas; for(var i = 0; i < locSubCacheCount; i++){ var selSubCanvas = locSubCacheCanvasArr[i]; - context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * this._subCacheWidth, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); + if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) + context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, + posX + i * this._subCacheWidth, -(posY + locCanvasHeight) + this._mapTileSize.height * 0.5, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); + else + context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, + posX + i * this._subCacheWidth, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); } } else{ //context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, // posX, -(posY + locCacheCanvas.height ), locCacheCanvas.width, locCacheCanvas.height ); - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); + if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight) + this._mapTileSize.height * 0.5, locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); + else + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); } } }, From 322f080b89d1c1152b3be42df1a428daa31e5242 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 18 Jul 2014 13:37:51 +0800 Subject: [PATCH 0314/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Missing code synchronization --- .../cocostudio/armature/animation/CCTween.js | 20 ++++---- .../cocostudio/armature/datas/CCDatas.js | 4 +- .../armature/utils/CCDataReaderHelper.js | 47 ++++++++++++------- .../armature/utils/CCTransformHelp.js | 4 +- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index b8ee0e01f3..64065376b9 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -246,9 +246,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @param {Boolean} limit */ setBetween:function (from, to, limit) { - if (typeof limit == "undefined") { - limit = true; - } + limit = Boolean(limit); do { if (from.displayIndex < 0 && to.displayIndex >= 0) { @@ -366,20 +364,21 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * get frame length, if this._toIndex >= _length, then set this._toIndex to 0, start anew. * this._toIndex is next index will play */ - var length = this._movementBoneData.frameList.length; var frames = this._movementBoneData.frameList; + var length = frames.length; if (playedTime < frames[0].frameID){ from = to = frames[0]; this.setBetween(from, to); - return currentPercent; + return this._currentPercent; } if (playedTime >= frames[length - 1].frameID) { + // If _passLastFrame is true and playedTime >= frames[length - 1]->frameID, then do not need to go on. if (this._passLastFrame) { from = to = frames[length - 1]; this.setBetween(from, to); - return currentPercent; + return this._currentPercent; } this._passLastFrame = true; } else { @@ -399,8 +398,8 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ to = frames[locToIndex]; //! Guaranteed to trigger frame event - if(from.event&& !this.animation.isIgnoreFrameEvent()){ - this.animation.frameEvent(this._bone, from.event,from.frameID, playedTime); + if(from.strEvent && !this.animation.isIgnoreFrameEvent()){ + this.animation.frameEvent(this._bone, from.strEvent,from.frameID, playedTime); } if (playedTime == from.frameID|| (this._passLastFrame && this._fromIndex == length-1)){ @@ -412,18 +411,19 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ locBetweenDuration = to.frameID - from.frameID; this._frameTweenEasing = from.tweenEasing; this.setBetween(from, to, false); + this._totalDuration = locTotalDuration; this._betweenDuration = locBetweenDuration; this._toIndex = locToIndex; } - currentPercent = locBetweenDuration == 0 ? 0 : (playedTime - locTotalDuration) / locBetweenDuration; + currentPercent = locBetweenDuration == 0 ? 0 : (playedTime - this._totalDuration) / this._betweenDuration; /* * if frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween. */ var tweenType = (this._frameTweenEasing != ccs.TweenType.linear) ? this._frameTweenEasing : this._tweenEasing; - if (tweenType != ccs.TweenType.tweenEasingMax&&tweenType != ccs.TweenType.linear&& !this._passLastFrame) { + if (tweenType != ccs.TweenType.tweenEasingMax && tweenType != ccs.TweenType.linear && !this._passLastFrame) { currentPercent = ccs.TweenFunction.tweenTo(currentPercent, tweenType, this._from.easingParams); } return currentPercent; diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index ef983dd936..296e198bf0 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -253,8 +253,8 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ } if (to.tweenRotate) { - this.skewX += to.tweenRotate * ccs.DOUBLE_PI; - this.skewY -= to.tweenRotate * ccs.DOUBLE_PI; + this.skewX += to.tweenRotate * ccs.PI * 2; + this.skewY -= to.tweenRotate * ccs.PI * 2; } } }); diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 64eac3daa6..2d84863cc9 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -402,18 +402,21 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ case ccs.DISPLAY_TYPE_SPRITE: displayData = new ccs.SpriteDisplayData(); - displayData.displayName = json[ccs.CONST_A_NAME] || ""; + var name = json[ccs.CONST_A_NAME]; + if(name != null){ + displayData.displayName = name; + } var dicArray = json[ccs.CONST_SKIN_DATA] || []; var dic = dicArray[0]; if (dic) { var skinData = displayData.skinData; - skinData.x = (dic[ccs.CONST_A_X] || 0) * this._positionReadScale; - skinData.y = (dic[ccs.CONST_A_Y] || 0) * this._positionReadScale; + skinData.x = dic[ccs.CONST_A_X] * this._positionReadScale; + skinData.y = dic[ccs.CONST_A_Y] * this._positionReadScale; skinData.scaleX = dic[ccs.CONST_A_SCALE_X] || 1; skinData.scaleY = dic[ccs.CONST_A_SCALE_Y] || 1; - skinData.skewX = dic[ccs.CONST_A_SKEW_X]; - skinData.skewY = dic[ccs.CONST_A_SKEW_Y]; + skinData.skewX = dic[ccs.CONST_A_SKEW_X] || 1; + skinData.skewY = dic[ccs.CONST_A_SKEW_Y] || 1; skinData.x *= dataInfo.contentScale; skinData.y *= dataInfo.contentScale; @@ -421,11 +424,21 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ break; case ccs.DISPLAY_TYPE_ARMATURE: displayData = new ccs.ArmatureDisplayData(); - displayData.displayName = json[ccs.CONST_A_NAME] || ""; + var name = json[ccs.CONST_A_NAME]; + if(name != null){ + displayData.displayName = json[ccs.CONST_A_NAME]; + } break; case ccs.DISPLAY_TYPE_PARTICLE: displayData = new ccs.ParticleDisplayData(); - displayData.displayName = dataInfo.basefilePath + json[ccs.CONST_A_PLIST] || ""; + var plist = json[ccs.CONST_A_PLIST]; + if(plist != null){ + if(dataInfo.asyncStruct){ + displayData.displayName = dataInfo.asyncStruct.basefilePath + plist; + }else{ + displayData.displayName = dataInfo.basefilePath + plist; + } + } break; default: displayData = new ccs.SpriteDisplayData(); @@ -884,15 +897,15 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ //* recalculate frame data from parent frame data, use for translate matrix var helpNode = new ccs.BaseData(); if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { - helpNode.x = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_COCOS2DX_X)) || 0; - helpNode.y = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_COCOS2DX_Y)) || 0; + helpNode.x = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_COCOS2DX_X)); + helpNode.y = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_COCOS2DX_Y)); } else { - helpNode.x = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_X)) || 0; - helpNode.y = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_Y)) || 0; + helpNode.x = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_X)); + helpNode.y = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_Y)); } - helpNode.skewX = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_SKEW_X)) || 0; - helpNode.skewY = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_SKEW_Y)) || 0; + helpNode.skewX = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_SKEW_X)); + helpNode.skewY = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_SKEW_Y)); helpNode.y = -helpNode.y; helpNode.skewX = cc.degreesToRadians(helpNode.skewX); @@ -908,7 +921,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ this.decodeNodeFromJson(frameData, json, dataInfo); frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; - frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX] || 0; + frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX]; var bd_src = json[ccs.CONST_A_BLEND_SRC] || cc.BLEND_SRC; var bd_dst = json[ccs.CONST_A_BLEND_DST] || cc.BLEND_DST; frameData.blendFunc.src = bd_src; @@ -1081,13 +1094,13 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, decodeNodeFromJson: function (node, json, dataInfo) { - node.x = (json[ccs.CONST_A_X] || 0) * this._positionReadScale; - node.y = (json[ccs.CONST_A_Y] || 0) * this._positionReadScale; + node.x = json[ccs.CONST_A_X] * this._positionReadScale; + node.y = json[ccs.CONST_A_Y] * this._positionReadScale; node.x *= dataInfo.contentScale; node.y *= dataInfo.contentScale; - node.zOrder = json[ccs.CONST_A_Z] || 0; + node.zOrder = json[ccs.CONST_A_Z]; node.skewX = json[ccs.CONST_A_SKEW_X] || 0; node.skewY = json[ccs.CONST_A_SKEW_Y] || 0; diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index 3b3fa25f65..184076bfcc 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -42,9 +42,9 @@ ccs.TransformHelp.helpParentNode = {}; * @return {cc.AffineTransform} * Constructor */ -ccs.TransformHelp.transformFromParent = function (bone, parentBone) { +ccs.TransformHelp.transformFromParent = function (bone, parentNode) { this.nodeToMatrix(bone, this.helpMatrix1); - this.nodeToMatrix(parentBone, this.helpMatrix2); + this.nodeToMatrix(parentNode, this.helpMatrix2); this.helpMatrix2 = cc.affineTransformInvert(this.helpMatrix2); this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2); From 79daa5b5d5750d3cc4e34b7def9db9a7c06a7de2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 18 Jul 2014 18:22:33 +0800 Subject: [PATCH 0315/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Missing code synchronization --- extensions/cocostudio/armature/CCBone.js | 3 + .../armature/display/CCBatchNode.js | 3 +- .../cocostudio/armature/display/CCSkin.js | 13 ++-- .../armature/utils/CCDataReaderHelper.js | 62 +++++++++---------- 4 files changed, 43 insertions(+), 38 deletions(-) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 4f2cbd2ee2..4a9ccb1131 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -193,7 +193,10 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ locWorldInfo.y = locTweenData.y + this._position.y; locWorldInfo.scaleX = locTweenData.scaleX * this._scaleX; locWorldInfo.scaleY = locTweenData.scaleY * this._scaleY; + //_rotationZ_X locWorldInfo.skewX = locTweenData.skewX + this._skewX + this._rotationX; + //_rotationZ_y + //_rotationZ_y locWorldInfo.skewY = locTweenData.skewY + this._skewY - this._rotationY; if (this.parentBone) { diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index 1e71bea2b8..6f1b8d6d88 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -44,8 +44,9 @@ ccs.BatchNode = cc.Node.extend(/** @lends ccs.BatchNode# */{ addChild:function (child, zOrder, tag) { cc.Node.prototype.addChild.call(this, child, zOrder, tag); - if (child instanceof cc.Armature) + if (child instanceof cc.Armature){ child.setBatchNode(this); + } }, removeChild: function(child, cleanup){ diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 4722c65030..a23e1bed46 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -128,6 +128,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ // // calculate the Quad based on the Affine Matrix // + var transform = this.getNodeToParentTransform(); var size = this._rect; @@ -137,13 +138,13 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var x2 = x1 + size.width; var y2 = y1 + size.height; - var x = this._transform.tx; - var y = this._transform.ty; + var x = this.transform.tx; + var y = this.transform.ty; - var cr = this._transform.a; - var sr = this._transform.b; - var cr2 = this._transform.c; - var sr2 = -this._transform.d; + var cr = this.transform.a; + var sr = this.transform.b; + var cr2 = this.transform.c; + var sr2 = -this.transform.d; var ax = x1 * cr - y1 * sr2 + x; var ay = x1 * sr + y1 * cr2 + y; diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 2d84863cc9..4d97641993 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -215,7 +215,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } return; } - this._configFileList.push(filePath); +// this._configFileList.push(filePath); //! find the base file path // var basefilePath = this._initBaseFilePath(filePath); @@ -413,10 +413,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var skinData = displayData.skinData; skinData.x = dic[ccs.CONST_A_X] * this._positionReadScale; skinData.y = dic[ccs.CONST_A_Y] * this._positionReadScale; - skinData.scaleX = dic[ccs.CONST_A_SCALE_X] || 1; - skinData.scaleY = dic[ccs.CONST_A_SCALE_Y] || 1; - skinData.skewX = dic[ccs.CONST_A_SKEW_X] || 1; - skinData.skewY = dic[ccs.CONST_A_SKEW_Y] || 1; + skinData.scaleX = dic[ccs.CONST_A_SCALE_X] == null ? 1 : dic[ccs.CONST_A_SCALE_X]; + skinData.scaleY = dic[ccs.CONST_A_SCALE_Y] == null ? 1 : dic[ccs.CONST_A_SCALE_Y]; + skinData.skewX = dic[ccs.CONST_A_SKEW_X] == null ? 1 : dic[ccs.CONST_A_SKEW_X]; + skinData.skewY = dic[ccs.CONST_A_SKEW_Y] == null ? 1 : dic[ccs.CONST_A_SKEW_Y]; skinData.x *= dataInfo.contentScale; skinData.y *= dataInfo.contentScale; @@ -494,14 +494,14 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var duration, durationTo, durationTween, loop, tweenEasing = 0; - duration = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION)) || 0; - movementData.duration = duration; + duration = movementXML.getAttribute(ccs.CONST_A_DURATION); + movementData.duration = duration == null ? 0 : duration; - durationTo = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION_TO)) || 0; - movementData.durationTo = durationTo; + durationTo = movementXML.getAttribute(ccs.CONST_A_DURATION_TO); + movementData.durationTo = durationTo == null ? 0 : durationTo; - durationTween = parseFloat(movementXML.getAttribute(ccs.CONST_A_DURATION_TWEEN)) || 0; - movementData.durationTween = durationTween; + durationTween = movementXML.getAttribute(ccs.CONST_A_DURATION_TWEEN); + movementData.durationTween = durationTween == null ? 0 : durationTween; loop = movementXML.getAttribute(ccs.CONST_A_LOOP); movementData.loop = loop ? Boolean(parseFloat(loop)) : true; @@ -509,7 +509,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var easing = movementXML.getAttribute(ccs.CONST_A_TWEEN_EASING); if (easing) { if (easing != ccs.CONST_FL_NAN) { - tweenEasing = parseFloat(easing) || 0; + tweenEasing = easing == null ? 0 : easing; movementData.tweenEasing = tweenEasing == 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; } else { movementData.tweenEasing = ccs.TweenType.linear; @@ -547,7 +547,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ decodeMovementFromJson: function (json, dataInfo) { var movementData = new ccs.MovementData(); - movementData.loop = json[ccs.CONST_A_LOOP] || false; + movementData.loop = json[ccs.CONST_A_LOOP] == null ? false : json[ccs.CONST_A_LOOP]; movementData.durationTween = json[ccs.CONST_A_DURATION_TWEEN] || 0; movementData.durationTo = json[ccs.CONST_A_DURATION_TO] || 0; movementData.duration = json[ccs.CONST_A_DURATION] || 0; @@ -555,10 +555,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if(json[ccs.CONST_A_DURATION] == null){ movementData.scale = 1; }else{ - movementData.scale = json[ccs.CONST_A_MOVEMENT_SCALE] || 1; + movementData.scale = json[ccs.CONST_A_MOVEMENT_SCALE] == null ? 1 : json[ccs.CONST_A_MOVEMENT_SCALE]; } - movementData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; + movementData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] == null ? ccs.TweenType.linear : json[ccs.CONST_A_TWEEN_EASING]; var name = json[ccs.CONST_A_NAME]; if(name){ movementData.name = name; @@ -851,7 +851,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } var colorTransformXML = frameXML.querySelectorAll(ccs.CONST_FRAME + " > " + ccs.CONST_A_COLOR_TRANSFORM); - if (colorTransformXML) + if (colorTransformXML && colorTransformXML.length > 0) { colorTransformXML = colorTransformXML[0]; var alpha, red, green, blue = 100; @@ -922,11 +922,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX]; - var bd_src = json[ccs.CONST_A_BLEND_SRC] || cc.BLEND_SRC; - var bd_dst = json[ccs.CONST_A_BLEND_DST] || cc.BLEND_DST; + var bd_src = json[ccs.CONST_A_BLEND_SRC] == null ? cc.BLEND_SRC : json[ccs.CONST_A_BLEND_SRC]; + var bd_dst = json[ccs.CONST_A_BLEND_DST] == null ? cc.BLEND_DST : json[ccs.CONST_A_BLEND_DST]; frameData.blendFunc.src = bd_src; frameData.blendFunc.dst = bd_dst; - frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME] || true; + frameData.isTween = json[ccs.CONST_A_TWEEN_FRAME] == null ? true : json[ccs.CONST_A_TWEEN_FRAME]; var event = json[ccs.CONST_A_EVENT]; if(event != null){ @@ -936,7 +936,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) { - frameData.duration = json[ccs.CONST_A_DURATION] || 1; + frameData.duration = json[ccs.CONST_A_DURATION] == null ? 1 : json[ccs.CONST_A_DURATION]; } else { @@ -1047,7 +1047,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, addDataFromJsonCache: function (dic, dataInfo) { - dataInfo.contentScale = dic[ccs.CONST_CONTENT_SCALE] || 1; + dataInfo.contentScale = dic[ccs.CONST_CONTENT_SCALE] == null ? 1 : dic[ccs.CONST_CONTENT_SCALE]; // Decode armatures var armatureDataArr = dic[ccs.CONST_ARMATURE_DATA] || []; @@ -1104,8 +1104,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ node.skewX = json[ccs.CONST_A_SKEW_X] || 0; node.skewY = json[ccs.CONST_A_SKEW_Y] || 0; - node.scaleX = json[ccs.CONST_A_SCALE_X] || 1; - node.scaleY = json[ccs.CONST_A_SCALE_Y] || 1; + node.scaleX = json[ccs.CONST_A_SCALE_X] == null ? 1 : json[ccs.CONST_A_SCALE_X]; + node.scaleY = json[ccs.CONST_A_SCALE_Y] == null ? 1 : json[ccs.CONST_A_SCALE_Y]; var colorDic; if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) @@ -1113,10 +1113,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ colorDic = json[0]; if (colorDic) { - node.a = colorDic[ccs.CONST_A_ALPHA] || 255; - node.r = colorDic[ccs.CONST_A_RED] || 255; - node.g = colorDic[ccs.CONST_A_GREEN] || 255; - node.b = colorDic[ccs.CONST_A_BLUE] || 255; + node.a = colorDic[ccs.CONST_A_ALPHA] == null ? 255 : colorDic[ccs.CONST_A_ALPHA]; + node.r = colorDic[ccs.CONST_A_RED] == null ? 255 : colorDic[ccs.CONST_A_RED]; + node.g = colorDic[ccs.CONST_A_GREEN] == null ? 255 : colorDic[ccs.CONST_A_GREEN]; + node.b = colorDic[ccs.CONST_A_BLUE] == null ? 255 : colorDic[ccs.CONST_A_BLUE]; node.isUseColorInfo = true; } @@ -1126,10 +1126,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ colorDic = json[ccs.CONST_COLOR_INFO] || null; if (colorDic) { - node.a = colorDic[ccs.CONST_A_ALPHA] || 255; - node.r = colorDic[ccs.CONST_A_RED] || 255; - node.g = colorDic[ccs.CONST_A_GREEN] || 255; - node.b = colorDic[ccs.CONST_A_BLUE] || 255; + node.a = colorDic[ccs.CONST_A_ALPHA] == null ? 255 : colorDic[ccs.CONST_A_ALPHA]; + node.r = colorDic[ccs.CONST_A_RED] == null ? 255 : colorDic[ccs.CONST_A_RED]; + node.g = colorDic[ccs.CONST_A_GREEN] == null ? 255 : colorDic[ccs.CONST_A_GREEN]; + node.b = colorDic[ccs.CONST_A_BLUE] == null ? 255 : colorDic[ccs.CONST_A_BLUE]; node.isUseColorInfo = true; } From c054ec153cc99e93c83ba024b5b6b170523788fc Mon Sep 17 00:00:00 2001 From: Minh Quy Date: Sat, 19 Jul 2014 15:48:55 +0700 Subject: [PATCH 0316/1564] [Fix] - Already add child in menuItem If we use disabledImage as reference to selectedSprite, when disabledImage was added to View it causes warning --- cocos2d/menus/CCMenuItem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 9cf8ce328e..fce4720e95 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -705,9 +705,9 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ } else if (four !== undefined && typeof three === "function") { target = four; callback = three; - disabledImage = selectedSprite; + disabledImage = cc.Sprite.create(selectedSprite); } else if (three === undefined) { - disabledImage = selectedSprite; + disabledImage = cc.Sprite.create(selectedSprite); } this.initWithNormalSprite(normalSprite, selectedSprite, disabledImage, callback, target); } From 5fccc2554323752b0ba2ced7135ab1cb237fc1f1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 21 Jul 2014 11:58:46 +0800 Subject: [PATCH 0317/1564] Issue #5702: Migrate Cocostudio Armature from -x v3.2 rc0 Missing code synchronization --- extensions/cocostudio/armature/CCBone.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 4a9ccb1131..8887ff4a5d 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -214,6 +214,11 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._worldTransform = cc.affineTransformConcat(locWorldTransform, locArmature.nodeToParentTransform()); } } + + this._worldTransform = locWorldTransform; + this._tweenData = locTweenData; + this._worldInfo = locWorldInfo; + ccs.displayFactory.updateDisplay(this, dt, this.boneTransformDirty || locArmature.getArmatureTransformDirty()); var locChildrenBone = this._childrenBone; From 6abfa00267eb3ac166fcd2a3cc5c4c8a6cf8fc84 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 21 Jul 2014 16:03:49 +0800 Subject: [PATCH 0318/1564] Issue #5704: sync ccui.Widget, ccui.Button, ccui.CheckBox --- extensions/ccui/base-classes/UIWidget.js | 168 ++++++-------- extensions/ccui/layouts/UILayout.js | 8 +- extensions/ccui/system/UIHelper.js | 34 +-- extensions/ccui/uiwidgets/UIButton.js | 197 +++++------------ extensions/ccui/uiwidgets/UICheckBox.js | 209 +++++++----------- .../uiwidgets/scroll-widget/UIPageView.js | 4 + 6 files changed, 224 insertions(+), 396 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index f54354be6e..cd4df0ab84 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -63,7 +63,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _name: "default", _widgetType: null, _actionTag: 0, - _size: cc.size(0,0), _customSize: null, _layoutParameterDictionary: null, _layoutParameterType:0, @@ -97,7 +96,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchMovePosition = cc.p(0, 0); this._touchEndPosition = cc.p(0, 0); this._widgetType = ccui.Widget.TYPE_WIDGET; - this._size = cc.size(0, 0); this._customSize = cc.size(0, 0); this._layoutParameterDictionary = {}; this._sizeType = ccui.Widget.SIZE_ABSOLUTE; @@ -158,15 +156,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _updateContentSizeWithTextureSize: function(size){ - var locSize = this._size; - if (this._ignoreSize) { - locSize.width = size.width; - locSize.height = size.height; - } else { - locSize.width = this._customSize.width; - locSize.height = this._customSize.height; - } - this._onSizeChanged(); + this.setContentSize(this._ignoreSize ? size : this._customSize); }, _isAncestorsEnabled: function(){ @@ -231,26 +221,50 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _initRenderer: function () { }, + setContentSize: function(contentSize, height){ + var locWidth = (height === undefined) ? contentSize.width : contentSize; + var locHeight = (height === undefined) ? contentSize.height : height; + cc.Node.prototype.setContentSize.call(this, locWidth, locHeight); + + this._customSize.width = locWidth; + this._customSize.height = locHeight; + + if (this._ignoreSize) + this._contentSize = this.getVirtualRendererSize(); + + if (this._running) { + var widgetParent = this.getWidgetParent(); + var pSize = widgetParent ? widgetParent.getContentSize() : this._parent.getContentSize(); + this._sizePercent.x = (pSize.width > 0.0) ? locWidth / pSize.width : 0.0; + this._sizePercent.y = (pSize.height > 0.0) ? locHeight / pSize.height : 0.0; + } + this._onSizeChanged(); + }, + _setWidth: function (w) { - var locW = this._customSize.width = w; - this._ignoreSize && (locW = this.width); - this._size.width = locW; + this._customSize.width = w; + if(this._ignoreSize) + this._contentSize = this.getVirtualRendererSize(); + else + this._contentSize.width = w; if (this._running) { var widgetParent = this.getWidgetParent(); - locW = widgetParent ? widgetParent.width : this._parent.width; - this._sizePercent.x = locW > 0 ? this._customSize.width / locW : 0; + var locWidth = widgetParent ? widgetParent.width : this._parent.width; + this._sizePercent.x = locWidth > 0 ? this._customSize.width / locWidth : 0; } this._onSizeChanged(); }, _setHeight: function (h) { - var locH = this._customSize.height = h; - this._ignoreSize && (locH = this.height); - this._size.height = locH; + this._customSize.height = h; + if(this._ignoreSize) + this._contentSize = this.getVirtualRendererSize(); + else + this._contentSize.height = h; if (this._running) { var widgetParent = this.getWidgetParent(); - locH = widgetParent ? widgetParent.height : this._parent.height; + var locH = widgetParent ? widgetParent.height : this._parent.height; this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0; } this._onSizeChanged(); @@ -274,13 +288,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ height = this._parent.height * percent.y; } } - if (!this._ignoreSize) { - this._size.width = width; - this._size.height = height; - } + if (this._ignoreSize) + this.setContentSize(this.getVirtualRendererSize()); + else + this.setContentSize(width, height); + this._customSize.width = width; this._customSize.height = height; - this._onSizeChanged(); }, _setWidthPercent: function (percent) { @@ -290,9 +304,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var widgetParent = this.getWidgetParent(); width = (widgetParent ? widgetParent.width : this._parent.width) * percent; } - this._ignoreSize || (this._size.width = width); + if (this._ignoreSize) + this._setWidth(this.getVirtualRendererSize().width); + else + this._setWidth(width); this._customSize.width = width; - this._onSizeChanged(); }, _setHeightPercent: function (percent) { this._sizePercent.y = percent; @@ -301,9 +317,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var widgetParent = this.getWidgetParent(); height = (widgetParent ? widgetParent.height : this._parent.height) * percent; } - this._ignoreSize || (this._size.height = height); + if (this._ignoreSize) + this._setHeight(this.getVirtualRendererSize().height); + else + this._setHeight(height); this._customSize.height = height; - this._onSizeChanged(); }, /** @@ -322,25 +340,19 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var locSize; switch (this._sizeType) { case ccui.Widget.SIZE_ABSOLUTE: - locSize = this._ignoreSize? this.getContentSize():this._customSize; - this._size.width = locSize.width; - this._size.height = locSize.height; - - var spx = 0, spy = 0; - if (parentSize.width > 0) { - spx = this._customSize.width / parentSize.width; - } - if (parentSize.height > 0) { - spy = this._customSize.height / parentSize.height; - } - this._sizePercent.x = spx; - this._sizePercent.y = spy; + if(this._ignoreSize) + this.setContentSize(this.getVirtualRendererSize()); + else + this.setContentSize(this._customSize); + this._sizePercent.x = (parentSize.width > 0) ? this._customSize.width / parentSize.width : 0; + this._sizePercent.y = (parentSize.height > 0) ? this._customSize.height / parentSize.height : 0; break; case ccui.Widget.SIZE_PERCENT: var cSize = cc.size(parentSize.width * this._sizePercent.x , parentSize.height * this._sizePercent.y); - locSize = this._ignoreSize? this.getVirtualRendererSize(): cSize; - this._size.width = locSize.width; - this._size.height = locSize.height; + if(this._ignoreSize) + this.setContentSize(this.getVirtualRendererSize()); + else + this.setContentSize(cSize); this._customSize.width = cSize.width; this._customSize.height = cSize.height; break; @@ -352,8 +364,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ switch (this._positionType) { case ccui.Widget.POSITION_ABSOLUTE: if (parentSize.width <= 0 || parentSize.height <= 0) { - this._positionPercent.x = 0; - this._positionPercent.y = 0; + this._positionPercent.x = this._positionPercent.y = 0; } else { this._positionPercent.x = absPos.x / parentSize.width; this._positionPercent.y = absPos.y / parentSize.height; @@ -393,10 +404,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return; this._ignoreSize = ignore; - var locSize = this._ignoreSize ? this.getContentSize(): this._customSize; - this._size.width = locSize.width; - this._size.height = locSize.height; - this._onSizeChanged(); + this.setContentSize(ignore?this.getVirtualRendererSize():this._customSize); }, /** @@ -416,7 +424,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, getLayoutSize: function(){ - return cc.size(this._size); + return cc.size(this._contentSize); }, /** @@ -460,7 +468,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * call back function called when size changed. */ _onSizeChanged: function () { - this.setContentSize(this._size); var locChildren = this.getChildren(); for (var i = 0, len = locChildren.length; i < len; i++) { var child = locChildren[i]; @@ -469,20 +476,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, - /** - * Gets the content size of widget. - * @returns {cc.Size} - */ - getContentSize: function () { - return this._size; - }, - _getWidth: function () { - return this._size.width; - }, - _getHeight: function () { - return this._size.height; - }, - /** * Sets whether the widget is touch enabled. The default value is false, a widget is default to touch disabled * @param {Boolean} enable true if the widget is touch enabled, false if the widget is touch disabled. @@ -491,7 +484,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (this._touchEnabled === enable) return; - this._touchEnabled = enable; + this._touchEnabled = enable; //TODO need consider remove and re-add. if (this._touchEnabled) { this._touchListener = cc.EventListener.create({ event: cc.EventListener.TOUCH_ONE_BY_ONE, @@ -1106,7 +1099,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getLeftBoundary: function () { - return this.getPositionX() - this._getAnchorX() * this._size.width; + return this.getPositionX() - this._getAnchorX() * this._contentSize.width; }, /** @@ -1114,7 +1107,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getBottomBoundary: function () { - return this.getPositionY() - this._getAnchorY() * this._size.height; + return this.getPositionY() - this._getAnchorY() * this._contentSize.height; }, /** @@ -1122,7 +1115,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getRightBoundary: function () { - return this.getLeftBoundary() + this._size.width; + return this.getLeftBoundary() + this._contentSize.width; }, /** @@ -1130,7 +1123,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {number} */ getTopBoundary: function () { - return this.getBottomBoundary() + this._size.height; + return this.getBottomBoundary() + this._contentSize.height; }, getTouchBeganPosition: function(){ @@ -1233,8 +1226,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._ignoreSize.width = widget._ignoreSize.width; this._ignoreSize.height = widget._ignoreSize.height; - this._size.width = widget._size.width; - this._size.height = widget._size.height; + this.setContentSize(widget._contentSize); this._customSize.width = widget._customSize.width; this._customSize.height = widget._customSize.height; @@ -1369,31 +1361,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Size} size that is widget's size */ setSize: function (size) { - //TODO where called onSizeChanged()? - //this.setContentSize(size); //the latest code of -x - - var locW = this._customSize.width = size.width; - var locH = this._customSize.height = size.height; - if (this._ignoreSize) { - locW = this.width; - locH = this.height; - } - this._size.width = locW; - this._size.height = locH; - - if (this._running) { - var widgetParent = this.getWidgetParent(); - if (widgetParent) { - locW = widgetParent.width; - 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._onSizeChanged(); + this.setContentSize(size); }, /** @@ -1402,7 +1370,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Size} */ getSize: function () { - return cc.size(this._size); + return cc.getContentSize(); }, /** diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index db7af18297..b2f1a0b9b2 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1585,13 +1585,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (parent.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) { if (direction == ccui.Widget.LEFT) { if (index == 0) - return true * this._isLastWidgetInContainer(parent, direction); + return this._isLastWidgetInContainer(parent, direction); else return false; } if (direction == ccui.Widget.RIGHT) { if (index == container.length - 1) - return true * this._isLastWidgetInContainer(parent, direction); + return this._isLastWidgetInContainer(parent, direction); else return false; } @@ -1603,13 +1603,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } else if(parent.getLayoutType() == ccui.Layout.LINEAR_VERTICAL){ if (direction == ccui.Widget.UP){ if (index == 0) - return true * this._isLastWidgetInContainer(parent, direction); + return this._isLastWidgetInContainer(parent, direction); else return false; } if (direction == ccui.Widget.DOWN) { if (index == container.length - 1) - return true * this._isLastWidgetInContainer(parent, direction); + return this._isLastWidgetInContainer(parent, direction); else return false; } diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 0792ffabf7..e01d0c0514 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -36,20 +36,18 @@ ccui.helper = { * @returns {ccui.Widget} */ seekWidgetByTag: function (root, tag) { - if (!root) { + if (!root) return null; - } - if (root.getTag() == tag) { + if (root.getTag() == tag) return root; - } + var arrayRootChildren = root.getChildren(); var length = arrayRootChildren.length; for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; var res = ccui.helper.seekWidgetByTag(child, tag); - if (res != null) { + if (res != null) return res; - } } return null; }, @@ -61,20 +59,17 @@ ccui.helper = { * @returns {ccui.Widget} */ seekWidgetByName: function (root, name) { - if (!root) { + if (!root) return null; - } - if (root.getName() == name) { + if (root.getName() == name) return root; - } var arrayRootChildren = root.getChildren(); var length = arrayRootChildren.length; for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; var res = ccui.helper.seekWidgetByName(child, name); - if (res != null) { + if (res != null) return res; - } } return null; }, @@ -87,36 +82,31 @@ ccui.helper = { * @returns {ccui.Widget} */ seekWidgetByRelativeName: function (root, name) { - if (!root) { + if (!root) return null; - } var arrayRootChildren = root.getChildren(); var length = arrayRootChildren.length; for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; var layoutParameter = child.getLayoutParameter(ccui.LayoutParameter.RELATIVE); - if (layoutParameter && layoutParameter.getRelativeName() == name) { + if (layoutParameter && layoutParameter.getRelativeName() == name) return child; - } } return null; }, /*temp action*/ seekActionWidgetByActionTag: function (root, tag) { - if (!root) { + if (!root) return null; - } - if (root.getActionTag() == tag) { + if (root.getActionTag() == tag) return root; - } var arrayRootChildren = root.getChildren(); for (var i = 0; i < arrayRootChildren.length; i++) { var child = arrayRootChildren[i]; var res = ccui.helper.seekActionWidgetByActionTag(child, tag); - if (res != null) { + if (res != null) return res; - } } return null; } diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 490cb36b72..66173ff5b5 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -40,31 +40,37 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _buttonClickedRenderer: null, _buttonDisableRenderer: null, _titleRenderer: null, + _normalFileName: "", _clickedFileName: "", _disabledFileName: "", + _prevIgnoreSize: true, _scale9Enabled: false, -// CCRect _capInsets:null, + _capInsetsNormal: null, _capInsetsPressed: null, _capInsetsDisabled: null, + _normalTexType: ccui.Widget.LOCAL_TEXTURE, _pressedTexType: ccui.Widget.LOCAL_TEXTURE, _disabledTexType: ccui.Widget.LOCAL_TEXTURE, + _normalTextureSize: null, _pressedTextureSize: null, _disabledTextureSize: null, + pressedActionEnabled: false, _titleColor: null, _normalTextureScaleXInSize: 1, _normalTextureScaleYInSize: 1, _pressedTextureScaleXInSize: 1, _pressedTextureScaleYInSize: 1, + _normalTextureLoaded: false, _pressedTextureLoaded: false, _disabledTextureLoaded: false, - _cascadeOpacityEnabled: true, + _className: "Button", _normalTextureAdaptDirty: true, _pressedTextureAdaptDirty: true, @@ -85,17 +91,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._capInsetsNormal = cc.rect(0, 0, 0, 0); this._capInsetsPressed = cc.rect(0, 0, 0, 0); this._capInsetsDisabled = cc.rect(0, 0, 0, 0); - var locSize = this._size; - this._normalTextureSize = cc.size(locSize.width, locSize.height); - this._pressedTextureSize = cc.size(locSize.width, locSize.height); - this._disabledTextureSize = cc.size(locSize.width, locSize.height); + this._normalTextureSize = cc.size(0, 0); + this._pressedTextureSize = cc.size(0, 0); + this._disabledTextureSize = cc.size(0, 0); this._titleColor = cc.color.WHITE; ccui.Widget.prototype.ctor.call(this); + this.setTouchEnabled(true); }, init: function (normalImage, selectedImage,disableImage, texType) { if (ccui.Widget.prototype.init.call(this)) { - this.setTouchEnabled(true); if(normalImage === undefined) return true; this.loadTextures(normalImage, selectedImage,disableImage, texType); @@ -108,6 +113,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer = cc.Sprite.create(); this._buttonDisableRenderer = cc.Sprite.create(); this._titleRenderer = cc.LabelTTF.create(""); + this._titleRenderer.setAnchorPoint(0.5, 0.5); + this.addProtectedChild(this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER, -1); this.addProtectedChild(this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER, -1); this.addProtectedChild(this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER, -1); @@ -116,7 +123,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * Sets if button is using scale9 renderer. - * @param {Boolean} able + * @param {Boolean} able true that using scale9 renderer, false otherwise. */ setScale9Enabled: function (able) { if (this._scale9Enabled == able) @@ -281,9 +288,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._updateFlippedX(); this._updateFlippedY(); - this._buttonDisableRenderer.setColor(this.getColor()); - this._buttonDisableRenderer.setOpacity(this.getOpacity()); - this._pressedTextureLoaded = true; this._pressedTextureAdaptDirty = true; }, @@ -294,9 +298,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureDisabled: function (disabled, texType) { - if (!disabled) { + if (!disabled) return; - } + texType = texType || ccui.Widget.LOCAL_TEXTURE; this._disabledFileName = disabled; this._disabledTexType = texType; @@ -329,8 +333,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._disabledTextureSize = this._buttonDisableRenderer.getContentSize(); this._updateFlippedX(); this._updateFlippedY(); - this._buttonDisableRenderer.setColor(this.getColor()); - this._buttonDisableRenderer.setOpacity(this.getOpacity()); this._disabledTextureLoaded = true; this._disabledTextureAdaptDirty = true; @@ -352,9 +354,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ setCapInsetsNormalRenderer: function (capInsets) { this._capInsetsNormal = capInsets; - if (!this._scale9Enabled) { + if (!this._scale9Enabled) return; - } this._buttonNormalRenderer.setCapInsets(capInsets); }, @@ -418,7 +419,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } } else { if (this._scale9Enabled) - this.updateTexturesRGBA(); + this._updateTexturesRGBA(); else { this._buttonNormalRenderer.stopAllActions(); this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); @@ -427,26 +428,27 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, onPressStateChangedToPressed: function () { + var locNormalRenderer = this._buttonNormalRenderer; if (this._pressedTextureLoaded) { - this._buttonNormalRenderer.setVisible(false); + locNormalRenderer.setVisible(false); this._buttonClickedRenderer.setVisible(true); this._buttonDisableRenderer.setVisible(false); if (this.pressedActionEnabled) { - this._buttonNormalRenderer.stopAllActions(); + locNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); var zoomAction = cc.ScaleTo.create(0.05, this._pressedTextureScaleXInSize + 0.1,this._pressedTextureScaleYInSize + 0.1); this._buttonClickedRenderer.runAction(zoomAction); - this._buttonNormalRenderer.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1); + locNormalRenderer.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1); } } else { - this._buttonNormalRenderer.setVisible(true); + locNormalRenderer.setVisible(true); this._buttonClickedRenderer.setVisible(true); this._buttonDisableRenderer.setVisible(false); if (this._scale9Enabled) - this._buttonNormalRenderer.setColor(cc.Color.GRAY); + locNormalRenderer.setColor(cc.Color.GRAY); else { - this._buttonNormalRenderer.stopAllActions(); - this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); + locNormalRenderer.stopAllActions(); + locNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); } } }, @@ -459,44 +461,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); }, - setFlippedX: function(flippedX){ - this._titleRenderer.setFlippedX(flippedX); - if (this._scale9Enabled) - { - return; - } - this._buttonNormalRenderer.setFlippedX(flippedX); - this._buttonClickedRenderer.setFlippedX(flippedX); - this._buttonDisableRenderer.setFlippedX(flippedX); - }, - - setFlipY: function(flippedY){ - this._titleRenderer.setFlippedY(flippedY); - if (this._scale9Enabled) - { - return; - } - this._buttonNormalRenderer.setFlippedY(flippedY); - this._buttonClickedRenderer.setFlippedY(flippedY); - this._buttonDisableRenderer.setFlippedY(flippedY); - }, - - isFlippedX: function(){ - if (this._scale9Enabled) - { - return false; - } - return this._buttonNormalRenderer.isFlippedX(); - }, - - isFlippedY: function(){ - if (this._scale9Enabled) - { - return false; - } - return this._buttonNormalRenderer.isFlippedY(); - }, - _updateFlippedX: function () { var flip = this._flippedX ? -1.0 : 1.0; this._titleRenderer.setScaleX(flip); @@ -525,7 +489,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } }, - updateTexturesRGBA: function(){ + _updateTexturesRGBA: function(){ this._buttonNormalRenderer.setColor(this.getColor()); this._buttonClickedRenderer.setColor(this.getColor()); this._buttonDisableRenderer.setColor(this.getColor()); @@ -535,62 +499,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonDisableRenderer.setOpacity(this.getOpacity()); }, - /** - * override "setAnchorPoint" of widget. - * @param {cc.Point|Number} point The anchor point of UIButton or The anchor point.x of UIButton. - * @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); - } 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)); - }, - _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); - this.updateTitleLocation(); - this.normalTextureScaleChangedWithSize(); - this.pressedTextureScaleChangedWithSize(); - this.disabledTextureScaleChangedWithSize(); - }, - - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - 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; + this._updateTitleLocation(); + this._normalTextureAdaptDirty = true; + this._pressedTextureAdaptDirty = true; + this._disabledTextureAdaptDirty = true; }, /** @@ -611,17 +525,15 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return this._buttonDisableRenderer; }, - normalTextureScaleChangedWithSize: function () { + _normalTextureScaleChangedWithSize: function () { if (this._ignoreSize) { if (!this._scale9Enabled) { this._buttonNormalRenderer.setScale(1.0); this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1; - //this._size.width = this._normalTextureSize.width; - //this._size.height = this._normalTextureSize.height; //TODO need test } } else { if (this._scale9Enabled) { - this._buttonNormalRenderer.setPreferredSize(this._size); + this._buttonNormalRenderer.setPreferredSize(this._contentSize); this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1; } else { var textureSize = this._normalTextureSize; @@ -629,8 +541,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonNormalRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; + var scaleX = this._contentSize.width / textureSize.width; + var scaleY = this._contentSize.height / textureSize.height; this._buttonNormalRenderer.setScaleX(scaleX); this._buttonNormalRenderer.setScaleY(scaleY); this._normalTextureScaleXInSize = scaleX; @@ -640,7 +552,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonNormalRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, - pressedTextureScaleChangedWithSize: function () { + _pressedTextureScaleChangedWithSize: function () { if (this._ignoreSize) { if (!this._scale9Enabled) { this._buttonClickedRenderer.setScale(1.0); @@ -648,7 +560,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } } else { if (this._scale9Enabled) { - this._buttonClickedRenderer.setPreferredSize(this._size); + this._buttonClickedRenderer.setPreferredSize(this._contentSize); this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1; } else { var textureSize = this._pressedTextureSize; @@ -656,8 +568,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; + var scaleX = this._contentSize.width / textureSize.width; + var scaleY = this._contentSize.height / textureSize.height; this._buttonClickedRenderer.setScaleX(scaleX); this._buttonClickedRenderer.setScaleY(scaleY); this._pressedTextureScaleXInSize = scaleX; @@ -667,21 +579,21 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, - disabledTextureScaleChangedWithSize: function () { + _disabledTextureScaleChangedWithSize: function () { if (this._ignoreSize) { if (!this._scale9Enabled) this._buttonDisableRenderer.setScale(1.0); } else { if (this._scale9Enabled) - this._buttonDisableRenderer.setPreferredSize(this._size); + this._buttonDisableRenderer.setPreferredSize(this._contentSize); else { var textureSize = this._disabledTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._buttonDisableRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; + var scaleX = this._contentSize.width / textureSize.width; + var scaleY = this._contentSize.height / textureSize.height; this._buttonDisableRenderer.setScaleX(scaleX); this._buttonDisableRenderer.setScaleY(scaleY); } @@ -691,20 +603,20 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _adaptRenderers: function(){ if (this._normalTextureAdaptDirty) { - this.normalTextureScaleChangedWithSize(); + this._normalTextureScaleChangedWithSize(); this._normalTextureAdaptDirty = false; } if (this._pressedTextureAdaptDirty) { - this.pressedTextureScaleChangedWithSize(); + this._pressedTextureScaleChangedWithSize(); this._pressedTextureAdaptDirty = false; } if (this._disabledTextureAdaptDirty) { - this.disabledTextureScaleChangedWithSize(); + this._disabledTextureScaleChangedWithSize(); this._disabledTextureAdaptDirty = false; } }, - updateTitleLocation: function(){ + _updateTitleLocation: function(){ this._titleRenderer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); }, @@ -773,6 +685,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ setTitleFontName: function (fontName) { this._titleRenderer.setFontName(fontName); + this._fontName = fontName; }, /** @@ -854,10 +767,14 @@ _p = null; */ ccui.Button.create = function (normalImage, selectedImage, disableImage, texType) { var btn = new ccui.Button(); - if(normalImage === undefined) - return btn; - - btn.init(normalImage, selectedImage, disableImage, texType) + if(normalImage === undefined){ + if(btn && btn.init()) + return btn; + }else{ + if(btn && btn.init(normalImage, selectedImage, disableImage, texType)) + return btn; + } + return null; }; // Constants diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 3bce0522dc..78eb27f867 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -36,15 +36,19 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _frontCrossRenderer: null, _backGroundBoxDisabledRenderer: null, _frontCrossDisabledRenderer: null, + _isSelected: true, + _checkBoxEventListener: null, _checkBoxEventSelector:null, _checkBoxEventCallback: null, + _backGroundTexType: ccui.Widget.LOCAL_TEXTURE, _backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE, _frontCrossTexType: ccui.Widget.LOCAL_TEXTURE, _backGroundDisabledTexType: ccui.Widget.LOCAL_TEXTURE, _frontCrossDisabledTexType: ccui.Widget.LOCAL_TEXTURE, + _backGroundFileName: "", _backGroundSelectedFileName: "", _frontCrossFileName: "", @@ -67,12 +71,12 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ */ ctor: function () { ccui.Widget.prototype.ctor.call(this); + this.setTouchEnabled(true); }, init: function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { if (ccui.Widget.prototype.init.call(this)) { this._isSelected = true; - this.setTouchEnabled(true); -// this.setSelectedState(false); + this.setSelectedState(false); //TODO need test if(backGround === undefined) this.loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType); return true; @@ -86,6 +90,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossRenderer = cc.Sprite.create(); this._backGroundBoxDisabledRenderer = cc.Sprite.create(); this._frontCrossDisabledRenderer = cc.Sprite.create(); + this.addProtectedChild(this._backGroundBoxRenderer, ccui.CheckBox.BOX_RENDERER_ZORDER, -1); this.addProtectedChild(this._backGroundSelectedBoxRenderer, ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER, -1); this.addProtectedChild(this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1); @@ -134,21 +139,19 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } - this.backGroundTextureScaleChangedWithSize(); if (!bgBoxRenderer.textureLoaded()) { this._backGroundBoxRenderer.setContentSize(this._customSize); bgBoxRenderer.addLoadedEventListener(function () { - this.backGroundTextureScaleChangedWithSize(); + this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); }, this); } this._updateFlippedX(); this._updateFlippedY(); - this._backGroundBoxRenderer.setColor(this.getColor()); - this._backGroundBoxRenderer.setOpacity(this.getOpacity()); this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); this._backGroundBoxRendererAdaptDirty = true; }, + /** * Load backGroundSelected texture for checkbox. * @param {String} backGroundSelected @@ -174,8 +177,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateFlippedX(); this._updateFlippedY(); - this._backGroundSelectedBoxRenderer.setColor(this.getColor()); - this._backGroundSelectedBoxRenderer.setOpacity(this.getOpacity()); this._backGroundSelectedBoxRendererAdaptDirty = true; }, @@ -202,8 +203,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } this._updateFlippedX(); this._updateFlippedY(); - this._frontCrossRenderer.setColor(this.getColor()); - this._frontCrossRenderer.setOpacity(this.getOpacity()); this._frontCrossRendererAdaptDirty = true; }, @@ -230,8 +229,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } this._updateFlippedX(); this._updateFlippedY(); - this._backGroundBoxDisabledRenderer.setColor(this.getColor()); - this._backGroundBoxDisabledRenderer.setOpacity(this.getOpacity()); this._backGroundBoxDisabledRendererAdaptDirty = true; }, @@ -258,8 +255,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } this._updateFlippedX(); this._updateFlippedY(); - this._frontCrossDisabledRenderer.setColor(this.getColor()); - this._frontCrossDisabledRenderer.setOpacity(this.getOpacity()); this._frontCrossDisabledRendererAdaptDirty = true; }, @@ -298,14 +293,14 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ return this._isSelected; }, - selectedEvent: function () { + _selectedEvent: function () { if(this._checkBoxEventCallback) this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_SELECTED); if (this._checkBoxEventListener && this._checkBoxEventSelector) this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_SELECTED); }, - unSelectedEvent: function () { + _unSelectedEvent: function () { if(this._checkBoxEventCallback) this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_UNSELECTED); if (this._checkBoxEventListener && this._checkBoxEventSelector) @@ -316,10 +311,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ ccui.Widget.prototype._releaseUpEvent.call(this); if (this._isSelected){ this.setSelectedState(false); - this.unSelectedEvent(); + this._unSelectedEvent(); } else { this.setSelectedState(true); - this.selectedEvent(); + this._selectedEvent(); } }, @@ -327,12 +322,17 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * add event listener * @param {Function} selector * @param {Object} target + * @deprecated */ addEventListenerCheckBox: function (selector, target) { this._checkBoxEventSelector = selector; this._checkBoxEventListener = target; }, + /** + * add a call back function would called when checkbox is selected or unselected. + * @param {function} callback + */ addEventListener: function(callback){ this._checkBoxEventCallback = callback; }, @@ -357,45 +357,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledRenderer.setFlippedY(this._flippedY); }, - /** - * override "setAnchorPoint" of widget. - * @param {cc.Point|Number} point The anchor point of UICheckBox or The anchor point.x of UICheckBox. - * @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); - } - }, - _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); this._backGroundBoxRendererAdaptDirty = true; @@ -405,20 +366,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledRendererAdaptDirty = true; }, - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - getContentSize: function () { - return this._backGroundBoxRenderer.getContentSize(); - }, - _getWidth: function () { - return this._backGroundBoxRenderer._getWidth(); - }, - _getHeight: function () { - return this._backGroundBoxRenderer._getHeight(); - }, - /** * override "getVirtualRenderer" method of widget. * @returns {cc.Node} @@ -427,92 +374,94 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ return this._backGroundBoxRenderer; }, - backGroundTextureScaleChangedWithSize: function () { + _backGroundTextureScaleChangedWithSize: function () { + var locRenderer = this._backGroundBoxRenderer, locContentSize = this._contentSize; if (this._ignoreSize) - this._backGroundBoxRenderer.setScale(1.0); + locRenderer.setScale(1.0); else{ - var textureSize = this._backGroundBoxRenderer.getContentSize(); + var textureSize = locRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0){ - this._backGroundBoxRenderer.setScale(1.0); + locRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; - this._backGroundBoxRenderer.setScaleX(scaleX); - this._backGroundBoxRenderer.setScaleY(scaleY); + var scaleX = locContentSize.width / textureSize.width; + var scaleY = locContentSize.height / textureSize.height; + locRenderer.setScaleX(scaleX); + locRenderer.setScaleY(scaleY); } - - var x = this._contentSize.width / 2; - var y = this._contentSize.height / 2; - this._backGroundBoxRenderer.setPosition(x, y); - this._backGroundSelectedBoxRenderer.setPosition(x, y); - this._frontCrossRenderer.setPosition(x, y); - this._backGroundBoxDisabledRenderer.setPosition(x, y); - this._frontCrossDisabledRenderer.setPosition(x, y); + locRenderer.setPosition(locContentSize.width * 0.5, locContentSize.height * 0.5); }, - backGroundSelectedTextureScaleChangedWithSize: function () { - if (this._ignoreSize) { - this._backGroundSelectedBoxRenderer.setScale(1.0); - } else { - var textureSize = this._backGroundSelectedBoxRenderer.getContentSize(); + _backGroundSelectedTextureScaleChangedWithSize: function () { + var locRenderer = this._backGroundSelectedBoxRenderer, locContentSize = this._contentSize; + if (this._ignoreSize) + locRenderer.setScale(1.0); + else { + var textureSize = locRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._backGroundSelectedBoxRenderer.setScale(1.0); + locRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; - this._backGroundSelectedBoxRenderer.setScaleX(scaleX); - this._backGroundSelectedBoxRenderer.setScaleY(scaleY); + var scaleX = locContentSize.width / textureSize.width; + var scaleY = locContentSize.height / textureSize.height; + locRenderer.setScaleX(scaleX); + locRenderer.setScaleY(scaleY); } + locRenderer.setPosition(locContentSize.width * 0.5, locContentSize.height * 0.5); }, - frontCrossTextureScaleChangedWithSize: function () { - if (this._ignoreSize) { - this._frontCrossRenderer.setScale(1.0); - } else { - var textureSize = this._frontCrossRenderer.getContentSize(); + _frontCrossTextureScaleChangedWithSize: function () { + var locRenderer = this._frontCrossRenderer, locContentSize = this._contentSize; + if (this._ignoreSize) + locRenderer.setScale(1.0); + else { + var textureSize = locRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._frontCrossRenderer.setScale(1.0); + locRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; - this._frontCrossRenderer.setScaleX(scaleX); - this._frontCrossRenderer.setScaleY(scaleY); + var scaleX = locContentSize.width / textureSize.width; + var scaleY = locContentSize.height / textureSize.height; + locRenderer.setScaleX(scaleX); + locRenderer.setScaleY(scaleY); } + locRenderer.setPosition(locContentSize.width * 0.5, locContentSize.height * 0.5); }, - backGroundDisabledTextureScaleChangedWithSize: function () { - if (this._ignoreSize) { - this._backGroundBoxDisabledRenderer.setScale(1.0); - }else { - var textureSize = this._backGroundBoxDisabledRenderer.getContentSize(); + _backGroundDisabledTextureScaleChangedWithSize: function () { + var locRenderer = this._backGroundBoxDisabledRenderer, locContentSize = this._contentSize; + if (this._ignoreSize) + locRenderer.setScale(1.0); + else { + var textureSize = locRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._backGroundBoxDisabledRenderer.setScale(1.0); + locRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; - this._backGroundBoxDisabledRenderer.setScaleX(scaleX); - this._backGroundBoxDisabledRenderer.setScaleY(scaleY); + var scaleX = locContentSize.width / textureSize.width; + var scaleY = locContentSize.height / textureSize.height; + locRenderer.setScaleX(scaleX); + locRenderer.setScaleY(scaleY); } + locRenderer.setPosition(locContentSize.width * 0.5, locContentSize.height * 0.5); }, - frontCrossDisabledTextureScaleChangedWithSize: function () { + _frontCrossDisabledTextureScaleChangedWithSize: function () { + var locRenderer = this._frontCrossDisabledRenderer, locContentSize = this._contentSize; if (this._ignoreSize) { - this._frontCrossDisabledRenderer.setScale(1.0); + locRenderer.setScale(1.0); } else { - var textureSize = this._frontCrossDisabledRenderer.getContentSize(); + var textureSize = locRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._frontCrossDisabledRenderer.setScale(1.0); + locRenderer.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; - this._frontCrossDisabledRenderer.setScaleX(scaleX); - this._frontCrossDisabledRenderer.setScaleY(scaleY); + var scaleX = locContentSize.width / textureSize.width; + var scaleY = locContentSize.height / textureSize.height; + locRenderer.setScaleX(scaleX); + locRenderer.setScaleY(scaleY); } + locRenderer.setPosition(locContentSize.width * 0.5, locContentSize.height * 0.5); }, /** @@ -543,23 +492,23 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _adaptRenderers: function(){ if (this._backGroundBoxRendererAdaptDirty){ - this.backGroundTextureScaleChangedWithSize(); + this._backGroundTextureScaleChangedWithSize(); this._backGroundBoxRendererAdaptDirty = false; } if (this._backGroundSelectedBoxRendererAdaptDirty) { - this.backGroundSelectedTextureScaleChangedWithSize(); + this._backGroundSelectedTextureScaleChangedWithSize(); this._backGroundSelectedBoxRendererAdaptDirty = false; } if (this._frontCrossRendererAdaptDirty){ - this.frontCrossTextureScaleChangedWithSize(); + this._frontCrossTextureScaleChangedWithSize(); this._frontCrossRendererAdaptDirty = false; } if (this._backGroundBoxDisabledRendererAdaptDirty) { - this.backGroundDisabledTextureScaleChangedWithSize(); + this._backGroundDisabledTextureScaleChangedWithSize(); this._backGroundBoxDisabledRendererAdaptDirty = false; } if (this._frontCrossDisabledRendererAdaptDirty) { - this.frontCrossDisabledTextureScaleChangedWithSize(); + this._frontCrossDisabledTextureScaleChangedWithSize(); this._frontCrossDisabledRendererAdaptDirty = false; } } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index cc48602683..506ce41bd4 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -70,6 +70,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._childFocusCancelOffset = 5; this._pageViewEventListener = null; this._pageViewEventSelector = null; + this.setTouchEnabled(true); }, init: function () { @@ -307,6 +308,9 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, // onTouchBegan logic at ccui.Layout + onTouchBegan: function(touch, event){ + ccui.Widget.prototype.onTouchBegan.call(this, touch, event); + }, onTouchMoved: function (touch, event) { this._handleMoveLogic(touch); From f08d20546be950998ef095b4c1ee3a3a2a48c47d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 21 Jul 2014 18:37:14 +0800 Subject: [PATCH 0319/1564] Issue #5704: CCUIPreformance UILoadingBar UIRichText UISlider UIText UITextAtlas UITextBMFont UITextField --- extensions/ccui/uiwidgets/UILoadingBar.js | 47 +++---- extensions/ccui/uiwidgets/UIRichText.js | 73 +++++----- extensions/ccui/uiwidgets/UISlider.js | 87 +++++------- extensions/ccui/uiwidgets/UIText.js | 155 +++++----------------- extensions/ccui/uiwidgets/UITextAtlas.js | 85 ++++-------- extensions/ccui/uiwidgets/UITextBMFont.js | 75 +++-------- extensions/ccui/uiwidgets/UITextField.js | 147 +++++++++----------- 7 files changed, 230 insertions(+), 439 deletions(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 866c4cb5bd..020254f5ee 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -130,8 +130,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ default: break; } - barRenderer.setColor(this.getColor()); - barRenderer.setOpacity(this.getOpacity()); + var bz = barRenderer.getContentSize(); this._barRendererTextureSize.width = bz.width; this._barRendererTextureSize.height = bz.height; @@ -148,7 +147,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ barRenderer.setFlippedX(true); break; } - this.barRendererScaleChangedWithSize(); + this._barRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._barRendererTextureSize); this._barRendererAdaptDirty = true; }, @@ -162,7 +161,9 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ return; this._scale9Enabled = enabled; this.removeProtectedChild(this._barRenderer); - this._barRenderer = this._scale9Enabled? cc.Scale9Sprite.create():cc.Sprite.create(); + + this._barRenderer = this._scale9Enabled ? cc.Scale9Sprite.create() : cc.Sprite.create(); + this.loadTexture(this._textureFile, this._renderBarTexType); this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); if (this._scale9Enabled) { @@ -211,14 +212,14 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ if (this._totalLength <= 0) return; this._percent = percent; - var res = this._percent / 100.0; if (this._scale9Enabled) - this.setScale9Scale(); + this._setScale9Scale(); else { var spriteRenderer = this._barRenderer; var rect = spriteRenderer.getTextureRect(); + rect.width = this._barRendererTextureSize.width * res; this._barRenderer.setTextureRect( cc.rect( rect.x, @@ -243,6 +244,13 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._barRendererAdaptDirty = true; }, + _adaptRenderers: function(){ + if (this._barRendererAdaptDirty){ + this._barRendererScaleChangedWithSize(); + this._barRendererAdaptDirty = false; + } + }, + /** * override "ignoreContentAdaptWithSize" method of widget. * @param {Boolean}ignore @@ -258,20 +266,6 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ return this._barRendererTextureSize; }, - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - getContentSize: function () { - return this._barRendererTextureSize; - }, - _getWidth: function () { - return this._barRendererTextureSize.width; - }, - _getHeight: function () { - return this._barRendererTextureSize.height; - }, - /** * override "getContentSize" method of widget. * @returns {cc.Node} @@ -280,7 +274,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ return this._barRenderer; }, - barRendererScaleChangedWithSize: function () { + _barRendererScaleChangedWithSize: function () { var locBarRender = this._barRenderer; if (this._ignoreSize) { if (!this._scale9Enabled) { @@ -290,7 +284,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } else { this._totalLength = this._size.width; if (this._scale9Enabled) - this.setScale9Scale(); + this._setScale9Scale(); else { var textureSize = this._barRendererTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { @@ -315,14 +309,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } }, - _adaptRenderers: function(){ - if (this._barRendererAdaptDirty){ - this.barRendererScaleChangedWithSize(); - this._barRendererAdaptDirty = false; - } - }, - - setScale9Scale: function () { + _setScale9Scale: function () { var width = (this._percent) / 100 * this._totalLength; this._barRenderer.setPreferredSize(cc.size(width, this._size.height)); }, diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 5e31164c8f..a1dfe49e68 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -42,7 +42,8 @@ ccui.RichElement = ccui.Class.extend(/** @lends ccui.RichElement# */{ this.color.r = color.r; this.color.g = color.g; this.color.b = color.b; - this.color.a = opacity; + this.color.a = color.a; + this._opacity = opacity; } }); @@ -92,7 +93,7 @@ ccui.RichElementText.create = function (tag, color, opacity, text, fontName, fon * @extends ccui.RichElement */ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage# */{ - filePath: "", + _filePath: "", textureRect: null, textureType: 0, ctor: function () { @@ -104,7 +105,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage }, init: function (tag, color, opacity, filePath) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); - this.filePath = filePath; + this._filePath = filePath; } }); @@ -225,12 +226,13 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._elementRenders.length = 0; var i, element, locRichElements = this._richElements; if (this._ignoreSize) { - this.addNewLine(); + this._addNewLine(); for (i = 0; i < locRichElements.length; i++) { element = locRichElements[i]; var elementRenderer = null; switch (element.type) { case ccui.RichElement.TEXT: + //todo: There may be ambiguous elementRenderer = cc.LabelTTF.create(element.text, element.fontName, element.fontSize); break; case ccui.RichElement.IMAGE: @@ -244,21 +246,21 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } elementRenderer.setColor(element.color); elementRenderer.setOpacity(element.color.a); - this.pushToContainer(elementRenderer); + this._pushToContainer(elementRenderer); } } else { - this.addNewLine(); + this._addNewLine(); for (i = 0; i < locRichElements.length; i++) { element = locRichElements[i]; switch (element.type) { case ccui.RichElement.TEXT: - this.handleTextRenderer(element.text, element.fontName, element.fontSize, element.color); + this._handleTextRenderer(element.text, element.fontName, element.fontSize, element.color); break; case ccui.RichElement.IMAGE: - this.handleImageRenderer(element.filePath, element.color, element.color.a); + this._handleImageRenderer(element.filePath, element.color, element.color.a); break; case ccui.RichElement.CUSTOM: - this.handleCustomRenderer(element.customNode); + this._handleCustomRenderer(element.customNode); break; default: break; @@ -277,7 +279,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @param {Number} fontSize * @param {cc.Color} color */ - handleTextRenderer: function (text, fontName, fontSize, color) { + _handleTextRenderer: function (text, fontName, fontSize, color) { var textRenderer = cc.LabelTTF.create(text, fontName, fontSize); var textRendererWidth = textRenderer.getContentSize().width; this._leftSpaceWidth -= textRendererWidth; @@ -292,15 +294,15 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var leftRenderer = cc.LabelTTF.create(leftWords.substr(0, leftLength), fontName, fontSize); leftRenderer.setColor(color); leftRenderer.setOpacity(color.a); - this.pushToContainer(leftRenderer); + this._pushToContainer(leftRenderer); } - this.addNewLine(); - this.handleTextRenderer(cutWords, fontName, fontSize, color); + this._addNewLine(); + this._handleTextRenderer(cutWords, fontName, fontSize, color); } else { textRenderer.setColor(color); textRenderer.setOpacity(color.a); - this.pushToContainer(textRenderer); + this._pushToContainer(textRenderer); } }, @@ -310,27 +312,29 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @param {cc.Color} color * @param {Number} opacity */ - handleImageRenderer: function (filePath, color, opacity) { + _handleImageRenderer: function (filePath, color, opacity) { var imageRenderer = cc.Sprite.create(filePath); - this.handleCustomRenderer(imageRenderer); + this._handleCustomRenderer(imageRenderer); }, + _formarRenderers: function(){}, + /** * Handle custom renderer * @param {cc.Node} renderer */ - handleCustomRenderer: function (renderer) { + _handleCustomRenderer: function (renderer) { var imgSize = renderer.getContentSize(); this._leftSpaceWidth -= imgSize.width; if (this._leftSpaceWidth < 0) { - this.addNewLine(); - this.pushToContainer(renderer); + this._addNewLine(); + this._pushToContainer(renderer); this._leftSpaceWidth -= imgSize.width; } else - this.pushToContainer(renderer); + this._pushToContainer(renderer); }, - addNewLine: function () { + _addNewLine: function () { this._leftSpaceWidth = this._customSize.width; this._elementRenders.push([]); }, @@ -376,13 +380,22 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var l = row[j]; l.setAnchorPoint(cc.p(0, 0)); l.setPosition(cc.p(nextPosX, nextPosY)); - locRenderersContainer.addChild(l, 1, i * 10 + j); + locRenderersContainer.addChild(l, 1); nextPosX += l.getContentSize().width; } } - locRenderersContainer.setContentSize(this._size); + locRenderersContainer.setContentSize(this._contentSize); } this._elementRenders.length = 0; + + var length = this._elementRenders.length; + for (var i = 0; iisFileExist(name)) -// { -// TTFConfig config = _labelRenderer->getTTFConfig(); -// config.fontFilePath = name; -// config.fontSize = _fontSize; -// _labelRenderer->setTTFConfig(config); -// _type = Type::TTF; -// } -// else{ -// _labelRenderer->setSystemFontName(name); -// _type = Type::SYSTEM; -// } -// _fontName = name; this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, + /** + * Get font name + * @returns {string} + */ + getFontName: function () { + return this._fontName; + }, + + getType: function(){ + return this._type; + }, + /** * set textAreaSize * @param {cc.Size} size */ setTextAreaSize: function (size) { -// this._textAreaSize.width = size.width; -// this._textAreaSize.height = size.height; this._labelRenderer.setDimensions(size); -// this.labelScaleChangedWithSize(); - this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, + getTextAreaSize: function(){ return this._labelRenderer.getDimensions(); }, @@ -204,10 +192,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT} alignment Horizontal Alignment */ setTextHorizontalAlignment: function (alignment) { -// this._textHorizontalAlignment = alignment; this._labelRenderer.setHorizontalAlignment(alignment); -// this.labelScaleChangedWithSize(); - this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, @@ -225,9 +210,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} alignment */ setTextVerticalAlignment: function (alignment) { -// this._textVerticalAlignment = alignment; this._labelRenderer.setVerticalAlignment(alignment); -// this.labelScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, @@ -256,7 +239,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ return this._touchScaleChangeEnabled; }, - onPressStateChangedToNormal: function () { + _onPressStateChangedToNormal: function () { if (!this._touchScaleChangeEnabled) { return; } @@ -264,7 +247,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRenderer.setScaleY(this._normalScaleValueY); }, - onPressStateChangedToPressed: function () { + _onPressStateChangedToPressed: function () { if (!this._touchScaleChangeEnabled) { return; } @@ -272,22 +255,31 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRenderer.setScaleY(this._normalScaleValueY + this._onSelectedScaleOffset); }, - onPressStateChangedToDisabled: function () { + _onPressStateChangedToDisabled: function () { }, _updateFlippedX: function () { + if (this._flippedX) + { this._labelRenderer.setScaleX(-1.0); + } else + { this._labelRenderer.setScaleX(1.0); + } }, - _updateFlippedY: function(){ + _updateFlippedY: function () { if (this._flippedY) + { this._labelRenderer.setScaleY(-1.0); + } else + { this._labelRenderer.setScaleY(1.0); + } }, _onSizeChanged: function () { @@ -298,7 +290,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ _adaptRenderers: function(){ if (this._labelRendererAdaptDirty) { - this.labelScaleChangedWithSize(); + this._labelScaleChangedWithSize(); this._labelRendererAdaptDirty = false; } }, @@ -315,9 +307,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ return this._labelRenderer; }, - labelScaleChangedWithSize: function () { + _labelScaleChangedWithSize: function () { if (this._ignoreSize) { - //this._labelRenderer.setDimensions(cc.size(0, 0)); this._labelRenderer.setScale(1.0); this._normalScaleValueX = this._normalScaleValueY = 1; } else { @@ -366,92 +357,6 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ return ccui.Text.create(); }, - /** - * Get font name - * @returns {string} - */ - getFontName: function () { - return this._fontName; - }, - - getType: function(){ - return this._type; - }, - - _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(); - }, - _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; - }, -// -// /** -// * Gets the touch scale enabled of label. -// * @returns {Boolean} -// */ -// getTouchScaleChangeAble: function () { -// return this.isTouchScaleChangeEnabled(); -// }, -// -// /** -// * override "setAnchorPoint" of widget. -// * @param {cc.Point|Number} point The anchor point of UILabel or The anchor point.x of UILabel. -// * @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); -// } else { -// 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); -// }, -// -// /** -// * override "getContentSize" method of widget. -// * @returns {cc.Size} -// */ -// getContentSize: function () { -// return this._labelRenderer.getContentSize(); -// }, -// _getWidth: function () { -// return this._labelRenderer._getWidth(); -// }, -// _getHeight: function () { -// return this._labelRenderer._getHeight(); -// }, - _copySpecialProperties: function (uiLabel) { if(uiLabel instanceof ccui.Label){ this.setFontName(uiLabel._fontName); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 3c67950470..bef40db076 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -51,8 +51,9 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ ccui.Widget.prototype.ctor.call(this); }, - _initRenderer: function () { + initRenderer: function () { this._labelAtlasRenderer = new cc.LabelAtlas(); + //cc.Node.prototype.addChild.call(this, this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5, 0.5)); this.addProtectedChild(this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); }, @@ -71,16 +72,10 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._itemWidth = itemWidth; this._itemHeight = itemHeight; this._startCharMap = startCharMap; -// var renderer = this._labelAtlasRenderer; -// renderer.initWithString(stringValue, charMapFile, itemWidth, itemHeight, startCharMap[0]); -// this.labelAtlasScaleChangedWithSize(); -// -// if (!renderer.textureLoaded()) { -// renderer.addLoadedEventListener(function () { -// this.labelAtlasScaleChangedWithSize(); -// }, this); -// } - this._labelAtlasRenderer.initWithString(stringValue, this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); +// this._labelAtlasRenderer.initWithString(stringValue, this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); + + this._labelAtlasRenderer.setCharMap(this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); + this._labelAtlasRenderer.setString(stringValue); this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; @@ -94,7 +89,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ setString: function (value) { this._stringValue = value; this._labelAtlasRenderer.setString(value); -// this.labelAtlasScaleChangedWithSize(); +// this._labelAtlasScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; }, @@ -133,12 +128,14 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); +// this._labelAtlasScaleChangedWithSize(); this._labelAtlasRendererAdaptDirty = true; }, _adaptRenderers: function(){ - if (this._labelAtlasRendererAdaptDirty) { - this.labelAtlasScaleChangedWithSize(); + if (this._labelAtlasRendererAdaptDirty) + { + this._labelAtlasScaleChangedWithSize(); this._labelAtlasRendererAdaptDirty = false; } @@ -156,12 +153,9 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ return this._labelAtlasRenderer; }, - labelAtlasScaleChangedWithSize: function () { + _labelAtlasScaleChangedWithSize: function () { if (this._ignoreSize) { this._labelAtlasRenderer.setScale(1.0); -// var atlasRenderSize = this._labelAtlasRenderer.getContentSize(); -// this._size.width = atlasRenderSize.width; -// this._size.height = atlasRenderSize.height; } else { var textureSize = this._labelAtlasRenderer.getContentSize(); @@ -185,52 +179,27 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ return "LabelAtlas"; }, - _createCloneInstance: function () { - return ccui.TextAtlas.create(); + _updateTextureColor: function () { + this.updateColorToRenderer(this._labelAtlasRenderer); }, _copySpecialProperties: function (labelAtlas) { - if (labelAtlas) + if (labelAtlas){ this.setProperty(labelAtlas._stringValue, labelAtlas._charMapFileName, labelAtlas._itemWidth, labelAtlas._itemHeight, labelAtlas._startCharMap); - } + } + }, + _updateTextureOpacity: function () { + this.updateOpacityToRenderer(this._labelAtlasRenderer); + }, + + _updateTextureRGBA: function(){ + this.updateRGBAToRenderer(this._labelAtlasRenderer); + }, -// /** -// * override "setAnchorPoint" of widget. -// * @param {cc.Point|Number} point The anchor point of UILabelAtlas or The anchor point.x of UILabelAtlas. -// * @param {Number} [y] The anchor point.y of UILabelAtlas. -// */ -// setAnchorPoint: function (point, y) { -// if (y === undefined) { -// 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); -// } -// }, -// _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); -// }, -// -// /** -// * override "getContentSize" method of widget. -// * @returns {cc.Size} -// */ -// getContentSize: function () { -// return this._labelAtlasRenderer.getContentSize(); -// }, -// _getWidth: function () { -// return this._labelAtlasRenderer._getWidth(); -// }, -// _getHeight: function () { -// return this._labelAtlasRenderer._getHeight(); -// }, + _createCloneInstance: function () { + return ccui.TextAtlas.create(); + } }); var _p = ccui.TextAtlas.prototype; diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 47fd9edc2d..5a66ba711f 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -62,17 +62,8 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return; } this._fntFileName = fileName; - this._labelBMFontRenderer.initWithString("", fileName); - this.labelBMFontScaleChangedWithSize(); - - if (!this._labelBMFontRenderer.textureLoaded()) { - this._labelBMFontRenderer.addLoadedEventListener(function () { - this.labelBMFontScaleChangedWithSize(); - }, this); - } - - this._labelBMFontRenderer.setColor(this.getColor()); - this._labelBMFontRenderer.setOpacity(this.getOpacity()); + this._labelBMFontRenderer.setBMFontFilePath(fileName); + this.updateRGBAToRenderer(this._labelBMFontRenderer); this._fntFileHasInit = true; this.setString(this._stringValue); }, @@ -116,14 +107,16 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); +// this._labelBMFontScaleChangedWithSize(); this._labelBMFontRendererAdaptDirty = true; }, _adaptRenderers: function(){ if (this._labelBMFontRendererAdaptDirty){ - this.labelBMFontScaleChangedWithSize(); + this._labelBMFontScaleChangedWithSize(); this._labelBMFontRendererAdaptDirty = false; } + }, getVirtualRendererSize: function(){ @@ -138,12 +131,9 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return this._labelBMFontRenderer; }, - labelBMFontScaleChangedWithSize: function () { + _labelBMFontScaleChangedWithSize: function () { if (this._ignoreSize) { this._labelBMFontRenderer.setScale(1.0); -// var rendererSize = this._labelBMFontRenderer.getContentSize(); -// this._size.width = rendererSize.width; -// this._size.height = rendererSize.height; } else { var textureSize = this._labelBMFontRenderer.getContentSize(); @@ -159,42 +149,17 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo this._labelBMFontRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, -// /** -// * override "setAnchorPoint" of widget. -// * @param {cc.Point|Number} point The anchor point of UILabelBMFont or The anchor point.x of UILabelBMFont. -// * @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); -// } else { -// 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); -// }, -// -// /** -// * get content size -// * @returns {cc.Size} -// */ -// getContentSize: function () { -// return this._labelBMFontRenderer.getContentSize(); -// }, -// _getWidth: function () { -// return this._labelBMFontRenderer._getWidth(); -// }, -// _getHeight: function () { -// return this._labelBMFontRenderer._getHeight(); -// }, + _updateTextureColor: function () { + this.updateColorToRenderer(this._labelBMFontRenderer); + }, + + _updateTextureOpacity: function () { + this.updateOpacityToRenderer(this._labelBMFontRenderer); + }, + + _updateTextureRGBA: function(){ + this.updateRGBAToRenderer(this._labelBMFontRenderer); + }, /** * Returns the "class name" of widget. @@ -204,13 +169,13 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return "LabelBMFont"; }, - _createCloneInstance: function () { + createCloneInstance: function () { return ccui.TextBMFont.create(); }, - _copySpecialProperties: function (labelBMFont) { + copySpecialProperties: function (labelBMFont) { this.setFntFile(labelBMFont._fntFileName); - this.setString(labelBMFont._stringValue); + this.setText(labelBMFont._stringValue); } }); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 7d458a4412..45bfa4bd6d 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -33,9 +33,9 @@ * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password */ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ - maxLengthEnabled: false, - maxLength: 0, - passwordEnabled: false, + _maxLengthEnabled: false, + _maxLength: 0, + _passwordEnabled: false, _passwordStyleText: "", _attachWithIME: false, _detachWithIME: false, @@ -46,9 +46,9 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ ctor: function () { cc.TextFieldTTF.prototype.ctor.call(this); - this.maxLengthEnabled = false; - this.maxLength = 0; - this.passwordEnabled = false; + this._maxLengthEnabled = false; + this._maxLength = 0; + this._passwordEnabled = false; this._passwordStyleText = "*"; this._attachWithIME = false; this._detachWithIME = false; @@ -69,8 +69,8 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ return false; } this.setInsertText(true); - if (this.maxLengthEnabled) { - if (cc.TextFieldTTF.prototype.getCharCount.call(this) >= this.maxLength) { + if (this._maxLengthEnabled) { + if (cc.TextFieldTTF.prototype.getCharCount.call(this) >= this._maxLength) { return true; } } @@ -90,13 +90,13 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ if (text != "\n") { - if (this.maxLengthEnabled) + if (this._maxLengthEnabled) { var text_count = this.getString().length; - if (text_count >= this.maxLength) + if (text_count >= this._maxLength) { // password - if (this.passwordEnabled) + if (this._passwordEnabled) { this.setPasswordText(this.getString()); } @@ -107,7 +107,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); // password - if (this.passwordEnabled) + if (this._passwordEnabled) { if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) { @@ -120,7 +120,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) { // password - if (this.passwordEnabled) { + if (this._passwordEnabled) { this.setPasswordText(this._inputText); } } @@ -132,25 +132,25 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ cc.TextFieldTTF.prototype.detachWithIME.call(this); }, setMaxLengthEnabled: function (enable) { - this.maxLengthEnabled = enable; + this._maxLengthEnabled = enable; }, isMaxLengthEnabled: function () { - return this.maxLengthEnabled; + return this._maxLengthEnabled; }, setMaxLength: function (length) { - this.maxLength = length; + this._maxLength = length; }, getMaxLength: function () { - return this.maxLength; + return this._maxLength; }, getCharCount: function () { return cc.TextFieldTTF.prototype.getCharCount.call(this); }, setPasswordEnabled: function (enable) { - this.passwordEnabled = enable; + this._passwordEnabled = enable; }, isPasswordEnabled: function () { - return this.passwordEnabled; + return this._passwordEnabled; }, setPasswordStyleText: function (styleText) { if (styleText.length > 1) { @@ -167,11 +167,11 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ var text_count = text.length; var max = text_count; - if (this.maxLengthEnabled) + if (this._maxLengthEnabled) { - if (text_count > this.maxLength) + if (text_count > this._maxLength) { - max = this.maxLength; + max = this._maxLength; } } @@ -384,15 +384,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ return this._textFieldRender.getPlaceHolder(); }, - _setFont: function (font) { - this._textFieldRender._setFont(font); - this._textFieldRendererAdaptDirty = true; - }, - - _getFont: function () { - return this._textFieldRender._getFont(); - }, - /** * Set font size for text field content * @param {cc.Size} size @@ -538,22 +529,22 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ update: function (dt) { if (this.getAttachWithIME()) { - this.attachWithIMEEvent(); + this._attachWithIMEEvent(); this.setAttachWithIME(false); } if (this.getDetachWithIME()) { - this.detachWithIMEEvent(); + this._detachWithIMEEvent(); this.setDetachWithIME(false); } if (this.getInsertText()) { - this.insertTextEvent(); + this._insertTextEvent(); this.setInsertText(false); this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRender.getContentSize()); } if (this.getDeleteBackward()) { - this.deleteBackwardEvent(); + this._deleteBackwardEvent(); this.setDeleteBackward(false); this._textFieldRendererAdaptDirty = true; @@ -623,7 +614,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRender.setDeleteBackward(deleteBackward); }, - attachWithIMEEvent: function () { + _attachWithIMEEvent: function () { if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_ATTACH_WITH_ME); } @@ -632,7 +623,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ } }, - detachWithIMEEvent: function () { + _detachWithIMEEvent: function () { if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DETACH_WITH_ME); } @@ -641,7 +632,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ } }, - insertTextEvent: function () { + _insertTextEvent: function () { if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT); } @@ -650,7 +641,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ } }, - deleteBackwardEvent: function () { + _deleteBackwardEvent: function () { if (this._textFieldEventListener && this._textFieldEventSelector) { this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD); } @@ -661,35 +652,16 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * add event listener - * @param {Function} selector * @param {Object} target + * @param {Function} selector */ - addEventListenerTextField: function (selector, target) { + addEventListenerTextField: function (target, selector) { this._textFieldEventSelector = selector; this._textFieldEventListener = target; }, - /** - * override "setAnchorPoint" of widget. - * @param {cc.Point|Number} point The anchor point of UILabelBMFont or The anchor point.x of UILabelBMFont. - * @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); - } else { - 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); + addEventListener: function(callback){ + this._eventCallback = callback; }, _onSizeChanged: function () { @@ -697,14 +669,21 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRendererAdaptDirty = true; }, - textfieldRendererScaleChangedWithSize: function () { + _adaptRenderers: function(){ + if (this._textFieldRendererAdaptDirty) + { + this._textfieldRendererScaleChangedWithSize(); + this._textFieldRendererAdaptDirty = false; + } + }, + + _textfieldRendererScaleChangedWithSize: function () { if (this._ignoreSize) { + this._textFieldRender.setDimensions(0,0); this._textFieldRender.setScale(1.0); - var rendererSize = this.getContentSize(); - this._size.width = rendererSize.width; - this._size.height = rendererSize.height; } else { + this._textFieldRender.setDimensions(this._size.width, this._size.height); var textureSize = this.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._textFieldRender.setScale(1.0); @@ -718,19 +697,9 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRender.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - getContentSize: function () { + getVirtualRendererSize: function(){ return this._textFieldRender.getContentSize(); }, - _getWidth: function () { - return this._textFieldRender._getWidth(); - }, - _getHeight: function () { - return this._textFieldRender._getHeight(); - }, /** * override "getContentSize" method of widget. @@ -748,6 +717,18 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ return "TextField"; }, + _updateTextureColor: function () { + this.updateColorToRenderer(this._textFieldRender); + }, + + _updateTextureOpacity: function () { + this.updateOpacityToRenderer(this._textFieldRender); + }, + + _updateTextureRGBA: function(){ + this.updateRGBAToRenderer(this._textFieldRender); + }, + attachWithIME: function () { this._textFieldRender.attachWithIME(); }, @@ -819,14 +800,14 @@ cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize); _p.fontName; cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName); /** @expose */ -_p.maxLengthEnabled; -cc.defineGetterSetter(_p, "maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); +_p._maxLengthEnabled; +cc.defineGetterSetter(_p, "_maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); /** @expose */ -_p.maxLength; -cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength); +_p._maxLength; +cc.defineGetterSetter(_p, "_maxLength", _p.getMaxLength, _p.setMaxLength); /** @expose */ -_p.passwordEnabled; -cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); +_p._passwordEnabled; +cc.defineGetterSetter(_p, "_passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); _p = null; From b1ecadfe12bee24ed6f869f03c389b4d31b17827 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 22 Jul 2014 11:34:43 +0800 Subject: [PATCH 0320/1564] Issue #5704: Fix bugs --- extensions/ccui/base-classes/UIWidget.js | 5 +- extensions/ccui/layouts/UILayoutManager.js | 11 +- extensions/ccui/uiwidgets/UIImageView.js | 119 +++++++-------------- extensions/ccui/uiwidgets/UISlider.js | 12 ++- extensions/ccui/uiwidgets/UITextAtlas.js | 13 ++- extensions/ccui/uiwidgets/UITextBMFont.js | 7 +- 6 files changed, 74 insertions(+), 93 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index cd4df0ab84..00a94e7c7c 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -404,7 +404,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return; this._ignoreSize = ignore; - this.setContentSize(ignore?this.getVirtualRendererSize():this._customSize); + this.setContentSize( ignore ? this.getVirtualRendererSize() : this._customSize ); + this._onSizeChanged(); }, /** @@ -1370,7 +1371,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Size} */ getSize: function () { - return cc.getContentSize(); + return this.getContentSize(); }, /** diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index 011dca5735..aaccb414ac 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -114,9 +114,17 @@ ccui.linearHorizontalLayoutManager = { } }; +var ooo = []; + ccui.relativeLayoutManager = { _unlayoutChildCount: 0, - _widgetChildren: [], +// _widgetChildren: [], + get _widgetChildren(){ + return ooo; + }, + set _widgetChildren(a){ + ooo = a; + }, _widget: null, _finalPositionX:0, _finalPositionY:0, @@ -163,6 +171,7 @@ ccui.relativeLayoutManager = { locWidgetChildren.push(child); } } + return locWidgetChildren; }, _getRelativeWidget: function(widget){ diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index d297890a57..15b02cc61d 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -48,15 +48,19 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ */ ctor: function () { this._capInsets = cc.rect(0,0,0,0); - this._imageTextureSize = cc.size(this._size.width, this._size.height); + this._imageTextureSize = cc.size(this._capInsets.width, this._capInsets.height); ccui.Widget.prototype.ctor.call(this); }, init: function(imageFileName, texType){ - ccui.Widget.prototype.init.call(this); - if(imageFileName !== undefined) - this.loadTexture(imageFileName, texType); - return true; + if(ccui.Widget.prototype.init.call(this)){ + if(imageFileName === undefined) + this._imageTexType = ccui.Widget.LOCAL_TEXTURE; + else + this.loadTexture(imageFileName, texType); + return true; + } + return false; }, _initRenderer: function () { @@ -70,6 +74,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexture: function (fileName, texType) { + //TODO: May cause the resource file must be pre loaded if (!fileName) { return; } @@ -79,41 +84,31 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ var imageRenderer = this._imageRenderer; switch (this._imageTexType) { case ccui.Widget.LOCAL_TEXTURE: - imageRenderer.initWithFile(fileName); + if(this._scale9Enabled){ + imageRenderer.initWithFile(fileName); + imageRenderer.setCapInsets(this._capInsets); + }else{ + imageRenderer.setTexture(fileName); + } +// imageRenderer.initWithFile(fileName); break; case ccui.Widget.PLIST_TEXTURE: - imageRenderer.initWithSpriteFrameName(fileName); + if(this._scale9Enabled){ + imageRenderer.initWithSpriteFrameName(fileName); + imageRenderer.setCapInsets(this._capInsets); + }else{ + imageRenderer.setSpriteFrame(fileName); + } +// imageRenderer.initWithSpriteFrameName(fileName); break; default: break; } - var locRendererSize = imageRenderer.getContentSize(); - if(imageRenderer.textureLoaded()){ - this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locRendererSize.width; - this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locRendererSize.height; - }else{ - imageRenderer.addLoadedEventListener(function(){ - var locSize = imageRenderer.getContentSize(); - this._imageTextureSize.width = this._customSize.width ? this._customSize.width : locSize.width; - this._imageTextureSize.height = this._customSize.height ? this._customSize.height : locSize.height; - if (imageRenderer.setCapInsets) { - imageRenderer.setCapInsets(this._capInsets); - } - this.imageTextureScaleChangedWithSize(); - },this); - this._imageTextureSize.width = this._customSize.width; - this._imageTextureSize.height = this._customSize.height; - } - - if (this._scale9Enabled) { - imageRenderer.setCapInsets(this._capInsets); - } - + this._imageTextureSize = imageRenderer.getContentSize(); this._updateFlippedX(); this._updateFlippedY(); - imageRenderer.setColor(this.getColor()); - imageRenderer.setOpacity(this.getOpacity()); + this._updateContentSizeWithTextureSize(this._imageTextureSize); this._imageRendererAdaptDirty = true; }, @@ -141,13 +136,6 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._imageRenderer.setFlippedY(this._flippedY); }, - _adaptRenderers: function(){ - if (this._imageRendererAdaptDirty){ - this.imageTextureScaleChangedWithSize(); - this._imageRendererAdaptDirty = false; - } - }, - /** * Sets if button is using scale9 renderer. * @param {Boolean} able @@ -213,48 +201,21 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ return this._capInsets; }, - /** - * override "setAnchorPoint" of widget. - * @param {cc.Point|Number} point The anchor point of UIImageView or The anchor point.x of UIImageView. - * @param {Number} [y] The anchor point.y of UIImageView. - */ - setAnchorPoint: function (point, y) { - if(y === undefined){ - ccui.Widget.prototype.setAnchorPoint.call(this, point); - this._imageRenderer.setAnchorPoint(point); - } else { - ccui.Widget.prototype.setAnchorPoint.call(this, point, y); - this._imageRenderer.setAnchorPoint(point, y); - } - }, - _setAnchorX: function (value) { - ccui.Widget.prototype._setAnchorX.call(this, value); - this._imageRenderer._setAnchorX(value); - }, - _setAnchorY: function (value) { - ccui.Widget.prototype._setAnchorY.call(this, value); - this._imageRenderer._setAnchorY(value); - }, - - _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); this._imageRendererAdaptDirty = true; }, - /** - * override "getContentSize" method of widget. - * @returns {cc.Size} - */ - getContentSize: function () { + _adaptRenderers: function(){ + if (this._imageRendererAdaptDirty){ + this._imageTextureScaleChangedWithSize(); + this._imageRendererAdaptDirty = false; + } + }, + + getVirtualRendererSize: function(){ return this._imageTextureSize; }, - _getWidth: function () { - return this._imageTextureSize.width; - }, - _getHeight: function () { - return this._imageTextureSize.height; - }, /** * override "getVirtualRenderer" method of widget. @@ -264,21 +225,21 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ return this._imageRenderer; }, - imageTextureScaleChangedWithSize: function () { + _imageTextureScaleChangedWithSize: function () { if (this._ignoreSize) { if (!this._scale9Enabled) this._imageRenderer.setScale(1.0); } else { if (this._scale9Enabled) - this._imageRenderer.setPreferredSize(this._size); + this._imageRenderer.setPreferredSize(this._contentSize); else { var textureSize = this._imageRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._imageRenderer.setScale(1.0); return; } - this._imageRenderer.setScaleX(this._size.width / textureSize.width); - this._imageRenderer.setScaleY(this._size.height / textureSize.height); + this._imageRenderer.setScaleX(this._contentSize.width / textureSize.width); + this._imageRenderer.setScaleY(this._contentSize.height / textureSize.height); } } this._imageRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); @@ -292,10 +253,6 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ return "ImageView"; }, - getVirtualRendererSize: function(){ - - }, - _createCloneInstance:function(){ return ccui.ImageView.create(); }, diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 7de5510e84..ecd8f074a0 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -421,10 +421,14 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var nsp = this._slidBallNormalRenderer.convertToNodeSpace(pt); var ballSize = this._slidBallNormalRenderer.getContentSize(); var ballRect = cc.rect(0,0, ballSize.width, ballSize.height); - if (ballRect.containsPoint(nsp)) { +// if (ballRect.containsPoint(nsp)) { + if (nsp.x >= ballRect.x && + nsp.x <= (ballRect.x + ballRect.width) && + nsp.y >= ballRect.y && + nsp.y <= (ballRect.y +ballRect.height)) { return true; } - return cc.rectContainsPoint(ballRect, nsp); + return false; }, onTouchBegan: function (touch, event) { @@ -477,7 +481,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _percentChangedEvent: function () { if (this._sliderEventListener && this._sliderEventSelector) { - this._sliderEventSelector.call(this._sliderEventListener, this, ccui.Slider.EVENT_PERCENT_CHANGED); + this._sliderEventListener.call(this._sliderEventSelector, + this, + ccui.Slider.EVENT_PERCENT_CHANGED); } if (this._eventCallback) { this._eventCallback(ccui.Slider.EVENT_PERCENT_CHANGED); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index bef40db076..5a23a9dcb4 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -51,7 +51,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ ccui.Widget.prototype.ctor.call(this); }, - initRenderer: function () { + _initRenderer: function () { this._labelAtlasRenderer = new cc.LabelAtlas(); //cc.Node.prototype.addChild.call(this, this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5, 0.5)); @@ -74,8 +74,15 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._startCharMap = startCharMap; // this._labelAtlasRenderer.initWithString(stringValue, this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); - this._labelAtlasRenderer.setCharMap(this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); - this._labelAtlasRenderer.setString(stringValue); +// this._labelAtlasRenderer.setCharMap(this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); +// this._labelAtlasRenderer.setString(stringValue); + this._labelAtlasRenderer.initWithString( + stringValue, + this._charMapFileName, + this._itemWidth, + this._itemHeight, + this._startCharMap[0] + ); this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 5a66ba711f..3c597dfe58 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -62,10 +62,11 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return; } this._fntFileName = fileName; - this._labelBMFontRenderer.setBMFontFilePath(fileName); - this.updateRGBAToRenderer(this._labelBMFontRenderer); +// this._labelBMFontRenderer.setBMFontFilePath(fileName); + this._fntFileHasInit = true; - this.setString(this._stringValue); +// this.setString(this._stringValue); + this._labelBMFontRenderer.initWithString(this._stringValue, fileName); }, /** From ea8d563a7c7a735f1ff24a5f4b29de509205276f Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 22 Jul 2014 17:03:14 +0800 Subject: [PATCH 0321/1564] issue #5685: make SkeletonAnimation supporting operator new --- extensions/spine/CCSkeletonAnimation.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index 6347587daf..9c2b76dc15 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -139,6 +139,10 @@ sp.SkeletonAnimation = sp.Skeleton.extend({ _state: null, _target: null, _callback: null, + ctor: function (skeletonDataFile, atlasFile, scale) { + sp.Skeleton.prototype.ctor.call(this); + atlasFile && this.initWithArgs(skeletonDataFile, atlasFile, scale); + }, init: function () { this._super(); this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data)); @@ -217,7 +221,5 @@ sp.SkeletonAnimation.createWithData = function (skeletonData) { }; sp.SkeletonAnimation.create = function (skeletonDataFile, atlasFile/* or atlas*/, scale) { - var c = new sp.SkeletonAnimation(); - c.initWithArgs.apply(c, arguments); - return c; + return new sp.SkeletonAnimation(skeletonDataFile, atlasFile, scale); }; \ No newline at end of file From 411e04433e387149b2a20d2d0cb3ff8b301f13b7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 23 Jul 2014 09:57:32 +0800 Subject: [PATCH 0322/1564] Issue #5704: sync ccui.ScrollView and ccui.ListView --- extensions/ccui/layouts/UILayout.js | 2 +- extensions/ccui/layouts/UIRelativeBox.js | 2 +- .../uiwidgets/scroll-widget/UIListView.js | 157 ++-- .../uiwidgets/scroll-widget/UIScrollView.js | 853 +++++++++--------- 4 files changed, 498 insertions(+), 516 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index b2f1a0b9b2..cc8eb859b1 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -237,7 +237,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ init: function () { if (ccui.Widget.prototype.init.call(this)) { this.ignoreContentAdaptWithSize(false); - this.setSize(cc.size(0, 0)); + this.setContentSize(cc.size(0, 0)); this.setAnchorPoint(0, 0); this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this); return true; diff --git a/extensions/ccui/layouts/UIRelativeBox.js b/extensions/ccui/layouts/UIRelativeBox.js index 87451f9c9b..86a0b3863e 100644 --- a/extensions/ccui/layouts/UIRelativeBox.js +++ b/extensions/ccui/layouts/UIRelativeBox.js @@ -39,7 +39,7 @@ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ initWithSize: function(size){ if(this.init()){ - this.setSize(size); + this.setContentSize(size); return true; } return false; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index e799e8a093..fdc6008e13 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -33,11 +33,13 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ _items: null, _gravity: null, _itemsMargin: 0, - _listViewEventListener: null, - _listViewEventSelector: null, + _curSelectedIndex: 0, _refreshViewDirty: true, - _className:"ListView", + + _listViewEventListener: null, + _listViewEventSelector: null, + _eventCallback: null, /** * allocates and initializes a UIListView. * Constructor of ccui.ListView @@ -47,16 +49,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ */ ctor: function () { ccui.ScrollView.prototype.ctor.call(this); - this._model = null; this._items = []; this._gravity = ccui.ListView.GRAVITY_CENTER_HORIZONTAL; - this._itemsMargin = 0; - this._listViewEventListener = null; - this._listViewEventSelector = null; - this._curSelectedIndex = 0; - this._refreshViewDirty = true; + this.setTouchEnabled(true); - //this.init(); + this.init(); }, init: function () { @@ -68,51 +65,46 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * Sets a item model for listview. A model will be cloned for adding default item. + * Sets a item model for ListView. A model will be cloned for adding default item. * @param {ccui.Widget} model */ setItemModel: function (model) { - if (!model) { + if (!model) return; - } this._model = model; }, - updateInnerContainerSize: function () { + _updateInnerContainerSize: function () { + var locItems = this._items, length, i; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: - var length = this._items.length; + length = locItems.length; var totalHeight = (length - 1) * this._itemsMargin; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - totalHeight += item.getContentSize().height; + for (i = 0; i < length; i++) { + totalHeight += locItems[i].getContentSize().height; } - var finalWidth = this._contentSize.width; - var finalHeight = totalHeight; - this.setInnerContainerSize(cc.size(finalWidth, finalHeight)); + this.setInnerContainerSize(cc.size(this._contentSize.width, totalHeight)); break; case ccui.ScrollView.DIR_HORIZONTAL: - var length = this._items.length; + length = locItems.length; var totalWidth = (length - 1) * this._itemsMargin; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - totalWidth += item.getContentSize().width; + for (i = 0; i < length; i++) { + totalWidth += locItems[i].getContentSize().width; } - var finalWidth = totalWidth; - var finalHeight = this._contentSize.height; - this.setInnerContainerSize(cc.size(finalWidth, finalHeight)); + this.setInnerContainerSize(cc.size(totalWidth, this._contentSize.height)); break; default: break; } }, - remedyLayoutParameter: function (item) { + _remedyLayoutParameter: function (item) { if (!item) return; + var llp; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: - var llp = item.getLayoutParameter(); + llp = item.getLayoutParameter(); if (!llp) { var defaultLp = ccui.LinearLayoutParameter.create(); switch (this._gravity) { @@ -154,7 +146,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } break; case ccui.ScrollView.DIR_HORIZONTAL: - var llp = item.getLayoutParameter(); + llp = item.getLayoutParameter(); if (!llp) { var defaultLp = ccui.LinearLayoutParameter.create(); switch (this._gravity) { @@ -201,59 +193,69 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * Push back a default item(create by a cloned model) into listview. + * Push back a default item(create by a cloned model) into ListView. */ pushBackDefaultItem: function () { - if (!this._model) { + if (!this._model) return; - } var newItem = this._model.clone(); - this.remedyLayoutParameter(newItem); + this._remedyLayoutParameter(newItem); this.addChild(newItem); this._refreshViewDirty = true; }, /** - * Insert a default item(create by a cloned model) into listview. + * Insert a default item(create by a cloned model) into ListView. * @param {Number} index */ insertDefaultItem: function (index) { - if (!this._model) { + if (!this._model) return; - } var newItem = this._model.clone(); this._items.splice(index, 0, newItem); ccui.ScrollView.prototype.addChild.call(this, newItem); - this.remedyLayoutParameter(newItem); + this._remedyLayoutParameter(newItem); this._refreshViewDirty = true; }, /** - * Push back custom item into listview. + * Push back custom item into ListView. * @param {ccui.Widget} item */ pushBackCustomItem: function (item) { - this.remedyLayoutParameter(item); + this._remedyLayoutParameter(item); this.addChild(item); this._refreshViewDirty = true; }, + /** + * add child to ListView + * @param {cc.Node} widget + * @param {Number} [zOrder] + * @param {Number|String} [tag] tag or name + */ addChild: function (widget, zOrder, tag) { if (widget) { zOrder = zOrder || widget.getLocalZOrder(); - tag = tag || widget.getTag(); + tag = tag || widget.getName(); ccui.ScrollView.prototype.addChild.call(this, widget, zOrder, tag); - this._items.push(widget); + if(widget instanceof ccui.Widget) + this._items.push(widget); } }, - removeChild: function(widget, cleaup){ + /** + * remove child from ListView + * @param {cc.Node} widget + * @param {Boolean} [cleanup=true] + */ + removeChild: function(widget, cleanup){ if (widget) { var index = this._items.indexOf(widget); if(index > -1) this._items.splice(index, 1); - ccui.ScrollView.prototype.removeChild.call(this, widget, cleaup); + ccui.ScrollView.prototype.removeChild.call(this, widget, cleanup); } }, @@ -267,14 +269,14 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * Push back custom item into listview. + * Push back custom item into ListView. * @param {ccui.Widget} item * @param {Number} index */ insertCustomItem: function (item, index) { this._items.splice(index, 0, item); ccui.ScrollView.prototype.addChild.call(this, item); - this.remedyLayoutParameter(item); + this._remedyLayoutParameter(item); this._refreshViewDirty = true; }, @@ -286,12 +288,12 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ var item = this.getItem(index); if (!item) return; - this.removeChild(item); + this.removeChild(item, true); this._refreshViewDirty = true; }, /** - * Removes the last item of listview. + * Removes the last item of ListView. */ removeLastItem: function () { this.removeItem(this._items.length - 1); @@ -307,9 +309,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @returns {ccui.Widget} */ getItem: function (index) { - if (index < 0 || index >= this._items.length) { + if (index < 0 || index >= this._items.length) return null; - } return this._items[index]; }, @@ -323,15 +324,15 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * Returns the index of item. - * @param {ccui.Widget} item - * @returns {Number} + * @param {ccui.Widget} item the item which need to be checked. + * @returns {Number} the index of item. */ getIndex: function (item) { return this._items.indexOf(item); }, /** - * Changes the gravity of listview. + * Changes the gravity of ListView. * @param {ccui.ListView.GRAVITY_LEFT|ccui.ListView.GRAVITY_RIGHT|ccui.ListView.GRAVITY_CENTER_HORIZONTAL|ccui.ListView.GRAVITY_BOTTOM|ccui.ListView.GRAVITY_CENTER_VERTICAL} gravity */ setGravity: function (gravity) { @@ -391,12 +392,20 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, refreshView: function () { - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; + var locItems = this._items; + for (var i = 0; i < locItems.length; i++) { + var item = locItems[i]; item.setLocalZOrder(i); - this.remedyLayoutParameter(item); + this._remedyLayoutParameter(item); } - this.updateInnerContainerSize(); + this._updateInnerContainerSize(); + }, + + /** + * public the _doLayout for Editor + */ + doLayout: function(){ + this._doLayout(); }, _doLayout: function(){ @@ -411,6 +420,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * add event listener * @param {Function} selector * @param {Object} target + * @deprecated */ addEventListenerListView: function (selector, target) { this._listViewEventListener = target; @@ -421,17 +431,17 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._eventCallback = callback; }, - selectedItemEvent: function (event) { - var eventEnum = (event == ccui.Widget.TOUCH_BAGAN) ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END; + _selectedItemEvent: function (event) { + var eventEnum = (event == ccui.Widget.TOUCH_BEGAN) ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END; if (this._listViewEventListener && this._listViewEventSelector) this._listViewEventSelector.call(this._listViewEventListener, this, eventEnum); if(this._eventCallback) this._eventCallback(this, eventEnum); }, - interceptTouchEvent: function (handleState, sender, touchPoint) { - ccui.ScrollView.prototype.interceptTouchEvent.call(this, handleState, sender, touchPoint); - if (handleState != 1) { + _interceptTouchEvent: function (handleState, sender, touchPoint) { + ccui.ScrollView.prototype._interceptTouchEvent.call(this, handleState, sender, touchPoint); + if (handleState != ccui.Widget.TOUCH_MOVED) { var parent = sender; while (parent) { if (parent && parent.getParent() == this._innerContainer) { @@ -441,7 +451,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ parent = parent.getParent(); } if (sender.isHighlighted()) - this.selectedItemEvent(handleState); + this._selectedItemEvent(handleState); } }, @@ -479,15 +489,16 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, _copySpecialProperties: function (listView) { - ccui.ScrollView.prototype._copySpecialProperties.call(this, listView); - this.setItemModel(listView._model); - this.setItemsMargin(listView._itemsMargin); - this.setGravity(listView._gravity); - - this._listViewEventListener = listView._listViewEventListener; - this._listViewEventSelector = listView._listViewEventSelector; - this._eventCallback = listView._eventCallback; - + if(listView instanceof ccui.ListView){ + ccui.ScrollView.prototype._copySpecialProperties.call(this, listView); + this.setItemModel(listView._model); + this.setItemsMargin(listView._itemsMargin); + this.setGravity(listView._gravity); + + this._listViewEventListener = listView._listViewEventListener; + this._listViewEventSelector = listView._listViewEventSelector; + this._eventCallback = listView._eventCallback; + } } }); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 72dfcb98c9..9d26449eb0 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.ScrollView + * The ScrollView control of Cocos UI * @class * @extends ccui.Layout * @@ -39,8 +39,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ direction: null, _autoScrollDir: null, - _topBoundary: 0,//test - _bottomBoundary: 0,//test + _topBoundary: 0, + _bottomBoundary: 0, _leftBoundary: 0, _rightBoundary: 0, @@ -78,6 +78,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _scrollViewEventSelector: null, _className: "ScrollView", _eventCallback: null, + /** * allocates and initializes a UIScrollView. * Constructor of ccui.ScrollView @@ -89,36 +90,16 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ ccui.Layout.prototype.ctor.call(this); this.direction = ccui.ScrollView.DIR_NONE; this._autoScrollDir = cc.p(0, 0); - this._topBoundary = 0;//test - this._bottomBoundary = 0;//test - this._leftBoundary = 0; - this._rightBoundary = 0; - this._bounceTopBoundary = 0; - this._bounceBottomBoundary = 0; - this._bounceLeftBoundary = 0; - this._bounceRightBoundary = 0; - this._autoScroll = false; - this._autoScrollAddUpTime = 0; - this._autoScrollOriginalSpeed = 0; + this._autoScrollAcceleration = -1000; - this._isAutoScrollSpeedAttenuated = false; - this._needCheckAutoScrollDestination = false; this._autoScrollDestination = cc.p(0, 0); - this._bePressed = false; this._slidTime = 0; this._moveChildPoint = cc.p(0, 0); this._childFocusCancelOffset = 5; - this._leftBounceNeeded = false; - this._topBounceNeeded = false; - this._rightBounceNeeded = false; - this._bottomBounceNeeded = false; - this.bounceEnabled = false; - this._bouncing = false; this._bounceDir = cc.p(0, 0); this._bounceOriginalSpeed = 0; this.inertiaScrollEnabled = true; - this._scrollViewEventListener = null; - this._scrollViewEventSelector = null; + this.setTouchEnabled(true); }, init: function () { @@ -135,6 +116,14 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.scheduleUpdate(true); }, + /** + * When a widget is in a layout, you could call this method to get the next focused widget within a specified direction.
    + * If the widget is not in a layout, it will return itself + * + * @param {Number} direction the direction to look for the next focused widget in a layout + * @param {ccui.Widget} current the current focused widget + * @returns {ccui.Widget} + */ findNextFocusedWidget: function(direction, current){ if (this.getLayoutType() == ccui.Layout.LINEAR_VERTICAL || this.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) { @@ -159,63 +148,57 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._bounceTopBoundary = locSize.height - bounceBoundaryParameterY; this._bounceBottomBoundary = bounceBoundaryParameterY; this._bounceLeftBoundary = bounceBoundaryParameterX; - this._bounceRightBoundary = this._contentSize.width - bounceBoundaryParameterX; + this._bounceRightBoundary = locSize.width - bounceBoundaryParameterX; var innerSize = this._innerContainer.getContentSize(); - var orginInnerSizeWidth = innerSize.width; - var orginInnerSizeHeight = innerSize.height; - var innerSizeWidth = Math.max(orginInnerSizeWidth, locSize.width); - var innerSizeHeight = Math.max(orginInnerSizeHeight, locSize.height); - this._innerContainer.setContentSize(cc.size(innerSizeWidth, innerSizeHeight)); + this._innerContainer.setContentSize(cc.size(Math.max(innerSize.width, locSize.width), Math.max(innerSize.height, locSize.height))); this._innerContainer.setPosition(0, locSize.height - this._innerContainer.getContentSize().height); }, /** * Changes inner container size of ScrollView.
    - * Inner container size must be larger than or equal scrollview's size. + * Inner container size must be larger than or equal the size of ScrollView. * @param {cc.Size} size inner container size. */ setInnerContainerSize: function (size) { + var innerContainer = this._innerContainer; var locSize = this._contentSize; - var innerSizeWidth = locSize.width; - var innerSizeHeight = locSize.height; - var originalInnerSize = this._innerContainer.getContentSize(); + var innerSizeWidth = locSize.width, innerSizeHeight = locSize.height; + var originalInnerSize = innerContainer.getContentSize(); if (size.width < locSize.width) - cc.log("Inner width <= scrollview width, it will be force sized!"); + cc.log("Inner width <= ScrollView width, it will be force sized!"); else innerSizeWidth = size.width; if (size.height < locSize.height) - cc.log("Inner height <= scrollview height, it will be force sized!"); + cc.log("Inner height <= ScrollView height, it will be force sized!"); else innerSizeHeight = size.height; - this._innerContainer.setSize(cc.size(innerSizeWidth, innerSizeHeight)); + innerContainer.setContentSize(cc.size(innerSizeWidth, innerSizeHeight)); var newInnerSize, offset; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: - newInnerSize = this._innerContainer.getContentSize(); + newInnerSize = innerContainer.getContentSize(); offset = originalInnerSize.height - newInnerSize.height; - this.scrollChildren(0, offset); + this._scrollChildren(0, offset); break; case ccui.ScrollView.DIR_HORIZONTAL: - if (this._innerContainer.getRightBoundary() <= locSize.width) { - newInnerSize = this._innerContainer.getContentSize(); + if (innerContainer.getRightBoundary() <= locSize.width) { + newInnerSize = innerContainer.getContentSize(); offset = originalInnerSize.width - newInnerSize.width; - this.scrollChildren(offset, 0); + this._scrollChildren(offset, 0); } break; case ccui.ScrollView.DIR_BOTH: - newInnerSize = this._innerContainer.getContentSize(); + newInnerSize = innerContainer.getContentSize(); var offsetY = originalInnerSize.height - newInnerSize.height; - var offsetX = 0; - if (this._innerContainer.getRightBoundary() <= locSize.width) - offsetX = originalInnerSize.width - newInnerSize.width; - this.scrollChildren(offsetX, offsetY); + var offsetX = (innerContainer.getRightBoundary() <= locSize.width) ? originalInnerSize.width - newInnerSize.width : 0; + this._scrollChildren(offsetX, offsetY); break; default: break; } - var innerContainer = this._innerContainer; + var innerSize = innerContainer.getContentSize(); var innerPos = innerContainer.getPosition(); var innerAP = innerContainer.getAnchorPoint(); @@ -228,6 +211,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (innerContainer.getTopBoundary() < locSize.height) innerContainer.setPosition(innerPos.x, locSize.height - (1.0 - innerAP.y) * innerSize.height); }, + _setInnerWidth: function (width) { var locW = this._contentSize.width, innerWidth = locW, @@ -245,7 +229,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (container.getRightBoundary() <= locW) { var newInnerWidth = container.width; var offset = oldInnerWidth - newInnerWidth; - this.scrollChildren(offset, 0); + this._scrollChildren(offset, 0); } break; } @@ -273,7 +257,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ case ccui.ScrollView.DIR_BOTH: var newInnerHeight = innerHeight; var offset = oldInnerHeight - newInnerHeight; - this.scrollChildren(0, offset); + this._scrollChildren(0, offset); break; } var innerAY = container.anchorY; @@ -287,7 +271,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Gets inner container size of ScrollView.
    - * Inner container size must be larger than or equal scrollview's size. + * Inner container size must be larger than or equal ScrollView's size. * * @return inner container size. */ @@ -305,7 +289,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Add widget * @param {cc.Node} widget * @param {Number} [zOrder] - * @param {Number} [tag] + * @param {Number|string} [tag] tag or name * @returns {boolean} */ addChild: function (widget, zOrder, tag) { @@ -335,7 +319,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get inner children + * get inner container's children * @returns {Array} */ getChildren: function () { @@ -343,7 +327,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get the count of inner children + * get the count of inner container's children * @returns {Number} */ getChildrenCount: function () { @@ -368,201 +352,154 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return this._innerContainer.getChildByName(name); }, - /** - * Add node for scrollView - * @param {cc.Node}node - * @param {Number} zOrder - * @param {Number} tag - */ - addNode: function (node, zOrder, tag) { - this._innerContainer.addNode(node, zOrder, tag); - }, - - /** - * Get node by tag - * @param {Number} tag - * @returns {cc.Node} - */ - getNodeByTag: function (tag) { - return this._innerContainer.getNodeByTag(tag); - }, - - /** - * Get all node - * @returns {Array} - */ - getNodes: function () { - return this._innerContainer.getNodes(); - }, - - /** - * Remove a node - * @param {cc.Node} node - */ - removeNode: function (node) { - this._innerContainer.removeNode(node); - }, - - /** - * Remove a node by tag - * @param {Number} tag - */ - removeNodeByTag: function (tag) { - this._innerContainer.removeNodeByTag(tag); - }, - - /** - * Remove all node - */ - removeAllNodes: function () { - this._innerContainer.removeAllNodes(); - }, - - moveChildren: function (offsetX, offsetY) { - var pos = this._innerContainer.getPosition(); - this._moveChildPoint.x = pos.x + offsetX; - this._moveChildPoint.y = pos.y + offsetY; + _moveChildren: function (offsetX, offsetY) { + var locContainer = this._innerContainer; + //var pos = this._innerContainer.getPosition(); + this._moveChildPoint.x = locContainer.x + offsetX; + this._moveChildPoint.y = locContainer.y + offsetY; this._innerContainer.setPosition(this._moveChildPoint); }, - autoScrollChildren: function (dt) { + _autoScrollChildren: function (dt) { var lastTime = this._autoScrollAddUpTime; this._autoScrollAddUpTime += dt; if (this._isAutoScrollSpeedAttenuated) { var nowSpeed = this._autoScrollOriginalSpeed + this._autoScrollAcceleration * this._autoScrollAddUpTime; if (nowSpeed <= 0) { - this.stopAutoScrollChildren(); - this.checkNeedBounce(); + this._stopAutoScrollChildren(); + this._checkNeedBounce(); } else { var timeParam = lastTime * 2 + dt; var offset = (this._autoScrollOriginalSpeed + this._autoScrollAcceleration * timeParam * 0.5) * dt; var offsetX = offset * this._autoScrollDir.x; var offsetY = offset * this._autoScrollDir.y; - if (!this.scrollChildren(offsetX, offsetY)) { - this.stopAutoScrollChildren(); - this.checkNeedBounce(); + if (!this._scrollChildren(offsetX, offsetY)) { + this._stopAutoScrollChildren(); + this._checkNeedBounce(); } } } else { if (this._needCheckAutoScrollDestination) { var xOffset = this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed; var yOffset = this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed; - var notDone = this.checkCustomScrollDestination(xOffset, yOffset); - var scrollCheck = this.scrollChildren(xOffset, yOffset); + var notDone = this._checkCustomScrollDestination(xOffset, yOffset); + var scrollCheck = this._scrollChildren(xOffset, yOffset); if (!notDone || !scrollCheck) { - this.stopAutoScrollChildren(); - this.checkNeedBounce(); + this._stopAutoScrollChildren(); + this._checkNeedBounce(); } } else { - if (!this.scrollChildren(this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed, + if (!this._scrollChildren(this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed, this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed)) { - this.stopAutoScrollChildren(); - this.checkNeedBounce(); + this._stopAutoScrollChildren(); + this._checkNeedBounce(); } } } }, - bounceChildren: function (dt) { + _bounceChildren: function (dt) { var locSpeed = this._bounceOriginalSpeed; var locBounceDir = this._bounceDir; - if (locSpeed <= 0.0) { - this.stopBounceChildren(); - } - if (!this.bounceScrollChildren(locBounceDir.x * dt * locSpeed, locBounceDir.y * dt * locSpeed)) { - this.stopBounceChildren(); - } + if (locSpeed <= 0.0) + this._stopBounceChildren(); + if (!this._bounceScrollChildren(locBounceDir.x * dt * locSpeed, locBounceDir.y * dt * locSpeed)) + this._stopBounceChildren(); }, - checkNeedBounce: function () { + _checkNeedBounce: function () { if (!this.bounceEnabled) return false; - this.checkBounceBoundary(); - if (this._topBounceNeeded || this._bottomBounceNeeded || this._leftBounceNeeded || this._rightBounceNeeded) { + this._checkBounceBoundary(); + var locTopBounceNeeded = this._topBounceNeeded, locBottomBounceNeeded = this._bottomBounceNeeded, + locLeftBounceNeeded = this._leftBounceNeeded, locRightBounceNeeded = this._rightBounceNeeded; + + if (locTopBounceNeeded || locBottomBounceNeeded || locLeftBounceNeeded || locRightBounceNeeded) { var scrollVector, orSpeed; - if (this._topBounceNeeded && this._leftBounceNeeded) { - scrollVector = cc.pSub(cc.p(0.0, this._contentSize.height), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getTopBoundary())); + var locContentSize = this._contentSize, locInnerContainer = this._innerContainer; + if (locTopBounceNeeded && locLeftBounceNeeded) { + scrollVector = cc.pSub(cc.p(0.0, locContentSize.height), cc.p(locInnerContainer.getLeftBoundary(), locInnerContainer.getTopBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); - } else if (this._topBounceNeeded && this._rightBounceNeeded) { - scrollVector = cc.pSub(cc.p(this._contentSize.width, this._contentSize.height), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getTopBoundary())); + this._startBounceChildren(orSpeed); + } else if (locTopBounceNeeded && locRightBounceNeeded) { + scrollVector = cc.pSub(cc.p(locContentSize.width, locContentSize.height), cc.p(locInnerContainer.getRightBoundary(), locInnerContainer.getTopBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); - } else if (this._bottomBounceNeeded && this._leftBounceNeeded) { - scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), this._innerContainer.getBottomBoundary())); + this._startBounceChildren(orSpeed); + } else if (locBottomBounceNeeded && locLeftBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, 0), cc.p(locInnerContainer.getLeftBoundary(), locInnerContainer.getBottomBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); - } else if (this._bottomBounceNeeded && this._rightBounceNeeded) { - scrollVector = cc.pSub(cc.p(this._contentSize.width, 0.0), cc.p(this._innerContainer.getRightBoundary(), this._innerContainer.getBottomBoundary())); + this._startBounceChildren(orSpeed); + } else if (locBottomBounceNeeded && locRightBounceNeeded) { + scrollVector = cc.pSub(cc.p(locContentSize.width, 0.0), cc.p(locInnerContainer.getRightBoundary(), locInnerContainer.getBottomBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); - } else if (this._topBounceNeeded) { - scrollVector = cc.pSub(cc.p(0, this._contentSize.height), cc.p(0.0, this._innerContainer.getTopBoundary())); + this._startBounceChildren(orSpeed); + } else if (locTopBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, locContentSize.height), cc.p(0.0, locInnerContainer.getTopBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); - } else if (this._bottomBounceNeeded) { - scrollVector = cc.pSub(cc.p(0, 0), cc.p(0.0, this._innerContainer.getBottomBoundary())); + this._startBounceChildren(orSpeed); + } else if (locBottomBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, 0), cc.p(0.0, locInnerContainer.getBottomBoundary())); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); - } else if (this._leftBounceNeeded) { - scrollVector = cc.pSub(cc.p(0, 0), cc.p(this._innerContainer.getLeftBoundary(), 0.0)); + this._startBounceChildren(orSpeed); + } else if (locLeftBounceNeeded) { + scrollVector = cc.pSub(cc.p(0, 0), cc.p(locInnerContainer.getLeftBoundary(), 0.0)); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); - } else if (this._rightBounceNeeded) { - scrollVector = cc.pSub(cc.p(this._contentSize.width, 0), cc.p(this._innerContainer.getRightBoundary(), 0.0)); + this._startBounceChildren(orSpeed); + } else if (locRightBounceNeeded) { + scrollVector = cc.pSub(cc.p(locContentSize.width, 0), cc.p(locInnerContainer.getRightBoundary(), 0.0)); orSpeed = cc.pLength(scrollVector) / 0.2; this._bounceDir = cc.pNormalize(scrollVector); - this.startBounceChildren(orSpeed); + this._startBounceChildren(orSpeed); } return true; } return false; }, - checkBounceBoundary: function () { - var icBottomPos = this._innerContainer.getBottomBoundary(); + _checkBounceBoundary: function () { + var locContainer = this._innerContainer; + var icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos > this._bottomBoundary) { - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); this._bottomBounceNeeded = true; - } else { + } else this._bottomBounceNeeded = false; - } - var icTopPos = this._innerContainer.getTopBoundary(); + + var icTopPos = locContainer.getTopBoundary(); if (icTopPos < this._topBoundary) { - this.scrollToTopEvent(); + this._scrollToTopEvent(); this._topBounceNeeded = true; - } else { + } else this._topBounceNeeded = false; - } - var icRightPos = this._innerContainer.getRightBoundary(); + + var icRightPos = locContainer.getRightBoundary(); if (icRightPos < this._rightBoundary) { - this.scrollToRightEvent(); + this._scrollToRightEvent(); this._rightBounceNeeded = true; - } else { + } else this._rightBounceNeeded = false; - } - var icLeftPos = this._innerContainer.getLeftBoundary(); + + var icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos > this._leftBoundary) { - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); this._leftBounceNeeded = true; - } else { + } else this._leftBounceNeeded = false; - } }, - startBounceChildren: function (v) { + _startBounceChildren: function (v) { this._bounceOriginalSpeed = v; this._bouncing = true; }, - stopBounceChildren: function () { + _stopBounceChildren: function () { this._bouncing = false; this._bounceOriginalSpeed = 0.0; this._leftBounceNeeded = false; @@ -571,8 +508,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._bottomBounceNeeded = false; }, - startAutoScrollChildrenWithOriginalSpeed: function (dir, v, attenuated, acceleration) { - this.stopAutoScrollChildren(); + _startAutoScrollChildrenWithOriginalSpeed: function (dir, v, attenuated, acceleration) { + this._stopAutoScrollChildren(); this._autoScrollDir = dir; this._isAutoScrollSpeedAttenuated = attenuated; this._autoScrollOriginalSpeed = v; @@ -580,7 +517,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._autoScrollAcceleration = acceleration; }, - startAutoScrollChildrenWithDestination: function (des, time, attenuated) { + _startAutoScrollChildrenWithDestination: function (des, time, attenuated) { this._needCheckAutoScrollDestination = false; this._autoScrollDestination = des; var dis = cc.pSub(des, this._innerContainer.getPosition()); @@ -595,10 +532,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._needCheckAutoScrollDestination = true; orSpeed = disLength / time; } - this.startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, attenuated, acceleration); + this._startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, attenuated, acceleration); }, - jumpToDestination: function (dstX, dstY) { + _jumpToDestination: function (dstX, dstY) { if (dstX.x !== undefined) { dstY = dstX.y; dstX = dstX.x; @@ -626,224 +563,222 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._innerContainer.setPosition(finalOffsetX, finalOffsetY); }, - stopAutoScrollChildren: function () { + _stopAutoScrollChildren: function () { this._autoScroll = false; this._autoScrollOriginalSpeed = 0; this._autoScrollAddUpTime = 0; }, - bounceScrollChildren: function (touchOffsetX, touchOffsetY) { + _bounceScrollChildren: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; var realOffsetX, realOffsetY, icRightPos, icTopPos, icBottomPos; + var locContainer = this._innerContainer; if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ //first quadrant //bounce to top-right realOffsetX = touchOffsetX; realOffsetY = touchOffsetY; - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; - this.bounceRightEvent(); + this._bounceRightEvent(); scrollEnabled = false; } - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; - this.bounceTopEvent(); + this._bounceTopEvent(); scrollEnabled = false; } - this.moveChildren(realOffsetX, realOffsetY); + this._moveChildren(realOffsetX, realOffsetY); } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ //second quadrant //bounce to top-left realOffsetX = touchOffsetX; realOffsetY = touchOffsetY; - icLefrPos = this._innerContainer.getLeftBoundary(); + icLefrPos = locContainer.getLeftBoundary(); if (icLefrPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLefrPos; - this.bounceLeftEvent(); + this._bounceLeftEvent(); scrollEnabled = false; } - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; - this.bounceTopEvent(); + this._bounceTopEvent(); scrollEnabled = false; } - this.moveChildren(realOffsetX, realOffsetY); + this._moveChildren(realOffsetX, realOffsetY); }else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ //third quadrant //bounce to bottom-left realOffsetX = touchOffsetX; realOffsetY = touchOffsetY; - var icLefrPos = this._innerContainer.getLeftBoundary(); + var icLefrPos = locContainer.getLeftBoundary(); if (icLefrPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLefrPos; - this.bounceLeftEvent(); + this._bounceLeftEvent(); scrollEnabled = false; } - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; - this.bounceBottomEvent(); + this._bounceBottomEvent(); scrollEnabled = false; } - this.moveChildren(realOffsetX, realOffsetY); + this._moveChildren(realOffsetX, realOffsetY); } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ //forth quadrant //bounce to bottom-right realOffsetX = touchOffsetX; realOffsetY = touchOffsetY; - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; - this.bounceRightEvent(); + this._bounceRightEvent(); scrollEnabled = false; } - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; - this.bounceBottomEvent(); + this._bounceBottomEvent(); scrollEnabled = false; } - this.moveChildren(realOffsetX, realOffsetY); + this._moveChildren(realOffsetX, realOffsetY); } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // bounce to top realOffsetY = touchOffsetY; - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; - this.bounceTopEvent(); + this._bounceTopEvent(); scrollEnabled = false; } - this.moveChildren(0.0, realOffsetY); + this._moveChildren(0.0, realOffsetY); } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) {//bounce to bottom - realOffsetY = touchOffsetY; - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; - this.bounceBottomEvent(); + this._bounceBottomEvent(); scrollEnabled = false; } - this.moveChildren(0.0, realOffsetY); - } - else if (touchOffsetX > 0.0 && touchOffsetY == 0.0) //bounce to right - { + this._moveChildren(0.0, realOffsetY); + } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ //bounce to right realOffsetX = touchOffsetX; - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; - this.bounceRightEvent(); + this._bounceRightEvent(); scrollEnabled = false; } - this.moveChildren(realOffsetX, 0.0); + this._moveChildren(realOffsetX, 0.0); }else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ //bounce to left - realOffsetX = touchOffsetX; - var icLeftPos = this._innerContainer.getLeftBoundary(); + var icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + realOffsetX <= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; - this.bounceLeftEvent(); + this._bounceLeftEvent(); scrollEnabled = false; } - this.moveChildren(realOffsetX, 0.0); + this._moveChildren(realOffsetX, 0.0); } return scrollEnabled; }, - checkCustomScrollDestination: function (touchOffsetX, touchOffsetY) { + _checkCustomScrollDestination: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; var icBottomPos, icLeftPos, icRightPos, icTopPos; + var locContainer = this._innerContainer, locDestination = this._autoScrollDestination; switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical if (this._autoScrollDir.y > 0) { - icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icBottomPos; + icBottomPos = locContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= locDestination.y) { + touchOffsetY = locDestination.y - icBottomPos; scrollEnabled = false; } } else { - icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY <= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icBottomPos; + icBottomPos = locContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY <= locDestination.y) { + touchOffsetY = locDestination.y - icBottomPos; scrollEnabled = false; } } break; case ccui.ScrollView.DIR_HORIZONTAL: // horizontal if (this._autoScrollDir.x > 0) { - icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icLeftPos; + icLeftPos = locContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= locDestination.x) { + touchOffsetX = locDestination.x - icLeftPos; scrollEnabled = false; } } else { - icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX <= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icLeftPos; + icLeftPos = locContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX <= locDestination.x) { + touchOffsetX = locDestination.x - icLeftPos; scrollEnabled = false; } } break; case ccui.ScrollView.DIR_BOTH: if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ // up right - icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icLeftPos; + icLeftPos = locContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= locDestination.x) { + touchOffsetX = locDestination.x - icLeftPos; scrollEnabled = false; } - icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icBottomPos; + icBottomPos = locContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= locDestination.y) { + touchOffsetY = locDestination.y - icBottomPos; scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ // up left - icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icRightPos; + icRightPos = locContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= locDestination.x) { + touchOffsetX = locDestination.x - icRightPos; scrollEnabled = false; } - icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icBottomPos; + icBottomPos = locContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= locDestination.y) { + touchOffsetY = locDestination.y - icBottomPos; scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ // down left - icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icRightPos; + icRightPos = locContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= locDestination.x) { + touchOffsetX = locDestination.x - icRightPos; scrollEnabled = false; } - icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icTopPos; + icTopPos = locContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= locDestination.y) { + touchOffsetY = locDestination.y - icTopPos; scrollEnabled = false; } } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right - icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icLeftPos; + icLeftPos = locContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= locDestination.x) { + touchOffsetX = locDestination.x - icLeftPos; scrollEnabled = false; } - icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icTopPos; + icTopPos = locContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= locDestination.y) { + touchOffsetY = locDestination.y - icTopPos; scrollEnabled = false; } } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up - icBottomPos = this._innerContainer.getBottomBoundary(); - if (icBottomPos + touchOffsetY >= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icBottomPos; + icBottomPos = locContainer.getBottomBoundary(); + if (icBottomPos + touchOffsetY >= locDestination.y) { + touchOffsetY = locDestination.y - icBottomPos; scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left - icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icRightPos; + icRightPos = locContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= locDestination.x) { + touchOffsetX = locDestination.x - icRightPos; scrollEnabled = false; } } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down - icTopPos = this._innerContainer.getTopBoundary(); - if (icTopPos + touchOffsetY <= this._autoScrollDestination.y) { - touchOffsetY = this._autoScrollDestination.y - icTopPos; + icTopPos = locContainer.getTopBoundary(); + if (icTopPos + touchOffsetY <= locDestination.y) { + touchOffsetY = locDestination.y - icTopPos; scrollEnabled = false; } } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right - icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._autoScrollDestination.x) { - touchOffsetX = this._autoScrollDestination.x - icLeftPos; + icLeftPos = locContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= locDestination.x) { + touchOffsetX = locDestination.x - icLeftPos; scrollEnabled = false; } } @@ -859,18 +794,18 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return this._autoScrollOriginalSpeed * dt; }, - scrollChildren: function (touchOffsetX, touchOffsetY) { + _scrollChildren: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; - this.scrollingEvent(); + this._scrollingEvent(); switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical - scrollEnabled = this.scrollChildrenVertical(touchOffsetX, touchOffsetY); + scrollEnabled = this._scrollChildrenVertical(touchOffsetX, touchOffsetY); break; case ccui.ScrollView.DIR_HORIZONTAL: // horizontal - scrollEnabled = this.scrollChildrenHorizontal(touchOffsetX, touchOffsetY); + scrollEnabled = this._scrollChildrenHorizontal(touchOffsetX, touchOffsetY); break; case ccui.ScrollView.DIR_BOTH: - scrollEnabled = this.scrollChildrenBoth(touchOffsetX, touchOffsetY); + scrollEnabled = this._scrollChildrenBoth(touchOffsetX, touchOffsetY); break; default: break; @@ -878,258 +813,249 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return scrollEnabled; }, - scrollChildrenVertical: function(touchOffsetX, touchOffsetY){ + _scrollChildrenVertical: function(touchOffsetX, touchOffsetY){ var realOffset = touchOffsetY; var scrollEnabled = true; - var icBottomPos, icTopPos; + var icBottomPos, icTopPos, locContainer = this._innerContainer; if (this.bounceEnabled) { - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffset = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffset = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } else { - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary){ realOffset = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffset = this._topBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } - this.moveChildren(0.0, realOffset); + this._moveChildren(0.0, realOffset); return scrollEnabled; }, - scrollChildrenHorizontal: function(touchOffsetX, touchOffestY){ + _scrollChildrenHorizontal: function(touchOffsetX, touchOffestY){ var scrollEnabled = true; var realOffset = touchOffsetX; - var icRightPos, icLeftPos; + var icRightPos, icLeftPos, locContainer = this._innerContainer; if (this.bounceEnabled){ - icRightPos = this._innerContainer.getRightBoundary(); - if (icRightPos + touchOffsetX <= this._bounceRightBoundary) - { + icRightPos = locContainer.getRightBoundary(); + if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffset = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } - icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) - { + icLeftPos = locContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffset = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } } else { - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffset = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } - icLeftPos = this._innerContainer.getLeftBoundary(); - if (icLeftPos + touchOffsetX >= this._leftBoundary) - { + icLeftPos = locContainer.getLeftBoundary(); + if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffset = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } } - this.moveChildren(realOffset, 0.0); + this._moveChildren(realOffset, 0.0); return scrollEnabled; }, - scrollChildrenBoth: function (touchOffsetX, touchOffsetY) { + _scrollChildrenBoth: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; var realOffsetX = touchOffsetX; var realOffsetY = touchOffsetY; var icLeftPos, icBottomPos, icRightPos, icTopPos; + var locContainer = this._innerContainer; if (this.bounceEnabled) { if (touchOffsetX > 0.0 && touchOffsetY > 0.0) { // up right - icLeftPos = this._innerContainer.getLeftBoundary(); + icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffsetX = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } - - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffsetY = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) { // up left - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffsetX = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } - - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffsetY = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) { // down left - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffsetX = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } - - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffsetY = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right - icLeftPos = this._innerContainer.getLeftBoundary(); + icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffsetX = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } - - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffsetY = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffsetY = this._bounceBottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffsetX = this._bounceRightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffsetY = this._bounceTopBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right - icLeftPos = this._innerContainer.getLeftBoundary(); + icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffsetX = this._bounceLeftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } } } else { if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ // up right - icLeftPos = this._innerContainer.getLeftBoundary(); + icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } - - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ // up left - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } - - icBottomPos = this._innerContainer.getBottomBoundary(); + icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ // down left - icRightPos = this._innerContainer.getRightBoundary(); + icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } - - icTopPos = this._innerContainer.getTopBoundary(); + icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right - icLeftPos = this._innerContainer.getLeftBoundary(); + icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) { // up icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; - this.scrollToBottomEvent(); + this._scrollToBottomEvent(); scrollEnabled = false; } } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; - this.scrollToRightEvent(); + this._scrollToRightEvent(); scrollEnabled = false; } } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; - this.scrollToTopEvent(); + this._scrollToTopEvent(); scrollEnabled = false; } } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; - this.scrollToLeftEvent(); + this._scrollToLeftEvent(); scrollEnabled = false; } } } - this.moveChildren(realOffsetX, realOffsetY); + this._moveChildren(realOffsetX, realOffsetY); return scrollEnabled; }, @@ -1139,7 +1065,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToBottom: function (time, attenuated) { - this.startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), 0), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), 0), time, attenuated); }, /** @@ -1148,7 +1074,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToTop: function (time, attenuated) { - this.startAutoScrollChildrenWithDestination( + this._startAutoScrollChildrenWithDestination( cc.p(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height), time, attenuated); }, @@ -1158,7 +1084,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToLeft: function (time, attenuated) { - this.startAutoScrollChildrenWithDestination(cc.p(0, this._innerContainer.getPositionY()), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(0, this._innerContainer.getPositionY()), time, attenuated); }, /** @@ -1167,7 +1093,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToRight: function (time, attenuated) { - this.startAutoScrollChildrenWithDestination( + this._startAutoScrollChildrenWithDestination( cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()), time, attenuated); }, @@ -1181,7 +1107,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.startAutoScrollChildrenWithDestination(cc.p(0, this._contentSize.height - this._innerContainer.getContentSize().height), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(0, this._contentSize.height - this._innerContainer.getContentSize().height), time, attenuated); }, /** @@ -1195,7 +1121,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return; } var inSize = this._innerContainer.getContentSize(); - this.startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - inSize.width, + this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - inSize.width, this._contentSize.height - inSize.height), time, attenuated); }, @@ -1209,7 +1135,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.startAutoScrollChildrenWithDestination(cc.p(0, 0), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(0, 0), time, attenuated); }, /** @@ -1222,7 +1148,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, 0), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, 0), time, attenuated); }, /** @@ -1234,7 +1160,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollToPercentVertical: function (percent, time, attenuated) { var minY = this._contentSize.height - this._innerContainer.getContentSize().height; var h = -minY; - this.startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), minY + percent * h / 100), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), minY + percent * h / 100), time, attenuated); }, /** @@ -1245,7 +1171,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ scrollToPercentHorizontal: function (percent, time, attenuated) { var w = this._innerContainer.getContentSize().width - this._contentSize.width; - this.startAutoScrollChildrenWithDestination(cc.p(-(percent * w / 100), this._innerContainer.getPositionY()), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(-(percent * w / 100), this._innerContainer.getPositionY()), time, attenuated); }, /** @@ -1260,7 +1186,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var minY = this._contentSize.height - this._innerContainer.getContentSize().height; var h = -minY; var w = this._innerContainer.getContentSize().width - this._contentSize.width; - this.startAutoScrollChildrenWithDestination(cc.p(-(percent.x * w / 100), minY + percent.y * h / 100), time, attenuated); + this._startAutoScrollChildrenWithDestination(cc.p(-(percent.x * w / 100), minY + percent.y * h / 100), time, attenuated); }, /** @@ -1268,7 +1194,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @function */ jumpToBottom: function () { - this.jumpToDestination(this._innerContainer.getPositionX(), 0); + this._jumpToDestination(this._innerContainer.getPositionX(), 0); }, /** @@ -1276,7 +1202,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @function */ jumpToTop: function () { - this.jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height); + this._jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height); }, /** @@ -1284,7 +1210,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @function */ jumpToLeft: function () { - this.jumpToDestination(0, this._innerContainer.getPositionY()); + this._jumpToDestination(0, this._innerContainer.getPositionY()); }, /** @@ -1292,7 +1218,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @function */ jumpToRight: function () { - this.jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()); + this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()); }, /** @@ -1304,7 +1230,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.jumpToDestination(0, this._contentSize.height - this._innerContainer.getContentSize().height); + this._jumpToDestination(0, this._contentSize.height - this._innerContainer.getContentSize().height); }, /** @@ -1317,7 +1243,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return; } var inSize = this._innerContainer.getContentSize(); - this.jumpToDestination(this._contentSize.width - inSize.width, this._contentSize.height - inSize.height); + this._jumpToDestination(this._contentSize.width - inSize.width, this._contentSize.height - inSize.height); }, /** @@ -1329,7 +1255,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.jumpToDestination(0, 0); + this._jumpToDestination(0, 0); }, /** @@ -1341,7 +1267,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ cc.log("Scroll direction is not both!"); return; } - this.jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, 0); + this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, 0); }, /** @@ -1352,7 +1278,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ jumpToPercentVertical: function (percent) { var minY = this._contentSize.height - this._innerContainer.getContentSize().height; var h = -minY; - this.jumpToDestination(this._innerContainer.getPositionX(), minY + percent * h / 100); + this._jumpToDestination(this._innerContainer.getPositionX(), minY + percent * h / 100); }, /** @@ -1362,13 +1288,13 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ jumpToPercentHorizontal: function (percent) { var w = this._innerContainer.getContentSize().width - this._contentSize.width; - this.jumpToDestination(-(percent * w / 100), this._innerContainer.getPositionY()); + this._jumpToDestination(-(percent * w / 100), this._innerContainer.getPositionY()); }, /** * Move inner container to both direction percent position of ScrollView. * @function - * @param {Number} percent The destination vertical percent, accept value between 0 - 100 + * @param {cc.Point} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentBothDirection: function (percent) { if (this.direction != ccui.ScrollView.DIR_BOTH) @@ -1377,19 +1303,19 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var minY = this._contentSize.height - inSize.height; var h = -minY; var w = inSize.width - this._contentSize.width; - this.jumpToDestination(-(percent.x * w / 100), minY + percent.y * h / 100); + this._jumpToDestination(-(percent.x * w / 100), minY + percent.y * h / 100); }, - startRecordSlidAction: function () { + _startRecordSlidAction: function () { if (this._autoScroll) - this.stopAutoScrollChildren(); + this._stopAutoScrollChildren(); if (this._bouncing) - this.stopBounceChildren(); + this._stopBounceChildren(); this._slidTime = 0.0; }, - endRecordSlidAction: function () { - if (!this.checkNeedBounce() && this.inertiaScrollEnabled) { + _endRecordSlidAction: function () { + if (!this._checkNeedBounce() && this.inertiaScrollEnabled) { if (this._slidTime <= 0.016) return; var totalDis = 0; @@ -1412,53 +1338,53 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; } var orSpeed = Math.min(Math.abs(totalDis) / (this._slidTime), ccui.ScrollView.AUTO_SCROLL_MAX_SPEED); - this.startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, true, -1000); + this._startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, true, -1000); this._slidTime = 0; } }, - handlePressLogic: function (touch) { - this.startRecordSlidAction(); + _handlePressLogic: function (touch) { + this._startRecordSlidAction(); this._bePressed = true; }, - handleMoveLogic: function (touch) { + _handleMoveLogic: function (touch) { var delta = cc.pSub(touch.getLocation(), touch.getPreviousLocation()); switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical - this.scrollChildren(0.0, delta.y); + this._scrollChildren(0.0, delta.y); break; case ccui.ScrollView.DIR_HORIZONTAL: // horizontal - this.scrollChildren(delta.x, 0); + this._scrollChildren(delta.x, 0); break; case ccui.ScrollView.DIR_BOTH: // both - this.scrollChildren(delta.x, delta.y); + this._scrollChildren(delta.x, delta.y); break; default: break; } }, - handleReleaseLogic: function (touch) { - this.endRecordSlidAction(); + _handleReleaseLogic: function (touch) { + this._endRecordSlidAction(); this._bePressed = false; }, onTouchBegan: function (touch, event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); if (this._hit) - this.handlePressLogic(touch); + this._handlePressLogic(touch); return pass; }, onTouchMoved: function (touch, event) { ccui.Layout.prototype.onTouchMoved.call(this, touch, event); - this.handleMoveLogic(touch); + this._handleMoveLogic(touch); }, onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this.handleReleaseLogic(touch); + this._handleReleaseLogic(touch); }, onTouchCancelled: function (touch, event) { @@ -1467,30 +1393,30 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ update: function (dt) { if (this._autoScroll) - this.autoScrollChildren(dt); + this._autoScrollChildren(dt); if (this._bouncing) - this.bounceChildren(dt); - this.recordSlidTime(dt); + this._bounceChildren(dt); + this._recordSlidTime(dt); }, - recordSlidTime: function (dt) { + _recordSlidTime: function (dt) { if (this._bePressed) this._slidTime += dt; }, /** * Intercept touch event - * @param {number} event + * @param {number} event event type * @param {ccui.Widget} sender * @param {cc.Touch} touch */ - interceptTouchEvent: function (event, sender, touch) { + _interceptTouchEvent: function (event, sender, touch) { var touchPoint = touch.getLocation(); switch (event) { - case ccui.Widget.TOUCH_BAGAN: + case ccui.Widget.TOUCH_BEGAN: this._touchBeganPosition.x = touchPoint.x; this._touchBeganPosition.y = touchPoint.y; - this.handlePressLogic(touch); + this._handlePressLogic(touch); break; case ccui.Widget.TOUCH_MOVED: var offset = cc.pLength(cc.pSub(sender.getTouchBeganPosition(), touchPoint)); @@ -1498,98 +1424,86 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ sender.setHighlighted(false); this._touchMovePosition.x = touchPoint.x; this._touchMovePosition.y = touchPoint.y; - this.handleMoveLogic(touch); + this._handleMoveLogic(touch); } break; case ccui.Widget.TOUCH_CANCELED: case ccui.Widget.TOUCH_ENDED: this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; - this.handleReleaseLogic(touch); + this._handleReleaseLogic(touch); break; } }, - scrollToTopEvent: function () { + _scrollToTopEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); if (this._eventCallback) this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_TOP); }, - scrollToBottomEvent: function () { + _scrollToBottomEvent: function () { if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); if (this._eventCallback) this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); }, - scrollToLeftEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + _scrollToLeftEvent: function () { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT); - } }, - scrollToRightEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + _scrollToRightEvent: function () { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); - } }, - scrollingEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + _scrollingEvent: function () { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLLING); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this,ccui.ScrollView.EVENT_SCROLLING); - } }, - bounceTopEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + _bounceTopEvent: function () { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_TOP); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this,ccui.ScrollView.EVENT_BOUNCE_TOP); - } }, - bounceBottomEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + _bounceBottomEvent: function () { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM); - } }, - bounceLeftEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + _bounceLeftEvent: function () { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_LEFT); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_LEFT); - } }, - bounceRightEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) { + _bounceRightEvent: function () { + if (this._scrollViewEventListener && this._scrollViewEventSelector) this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); - } - if (this._eventCallback) { + if (this._eventCallback) this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); - } }, /** + * Add call back function called ScrollView event triggered * @param {Function} selector * @param {Object} target + * @deprecated */ addEventListenerScrollView: function (selector, target) { this._scrollViewEventSelector = selector; @@ -1603,6 +1517,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Changes scroll direction of ScrollView. * @param {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} dir + * Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll */ setDirection: function (dir) { this.direction = dir; @@ -1649,7 +1564,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Gets inner container of ScrollView. Inner container is the container .of ScrollView's children. + * Gets inner container of ScrollView. Inner container is the container of ScrollView's children. * @returns {ccui.Layout} */ getInnerContainer: function () { @@ -1705,6 +1620,62 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._scrollViewEventSelector = scrollView._scrollViewEventSelector; this._eventCallback = scrollView._eventCallback; } + }, + + /** + * Get node by tag + * @param {Number} tag + * @returns {cc.Node} + * @deprecated + */ + getNodeByTag: function (tag) { + return this._innerContainer.getNodeByTag(tag); + }, + + /** + * Get all nodes of inner container + * @returns {Array} + * @deprecated + */ + getNodes: function () { + return this._innerContainer.getNodes(); + }, + + /** + * Remove a node + * @param {cc.Node} node + * @deprecated + */ + removeNode: function (node) { + this._innerContainer.removeNode(node); + }, + + /** + * Remove a node by tag + * @param {Number} tag + * @deprecated + */ + removeNodeByTag: function (tag) { + this._innerContainer.removeNodeByTag(tag); + }, + + /** + * Remove all node + * @deprecated + */ + removeAllNodes: function () { + this._innerContainer.removeAllNodes(); + }, + + /** + * Add node for scrollView + * @param {cc.Node}node + * @param {Number} zOrder + * @param {Number} tag + * @deprecated + */ + addNode: function (node, zOrder, tag) { + this._innerContainer.addNode(node, zOrder, tag); } }); From b59374c4b200e1940ba127adb0d6ba1f1ccfca1a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 23 Jul 2014 12:52:26 +0800 Subject: [PATCH 0323/1564] Issue #4580: Fix image format constant inconsistence --- cocos2d/render-texture/CCRenderTexture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 723bbb24fb..7851ec7174 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -42,7 +42,7 @@ cc.IMAGE_FORMAT_PNG = 1; * @constant * @type Number */ -cc.IMAGE_FORMAT_RAWDATA = 2; +cc.IMAGE_FORMAT_RAWDATA = 9; /** * @param {Number} x From afe433cc3f1c33cf0f5a881b363a94af14b73748 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 23 Jul 2014 13:39:47 +0800 Subject: [PATCH 0324/1564] Issue #5703: Add customwidget support --- extensions/cocostudio/reader/GUIReader.js | 166 +++++++++++------- extensions/cocostudio/reader/SceneReader.js | 2 +- .../widgetreader/ButtonReader/ButtonReader.js | 12 +- .../CheckBoxReader/CheckBoxReader.js | 11 +- .../ImageViewReader/ImageViewReader.js | 12 +- .../LabelAtlasReader/LabelAtlasReader.js | 12 +- .../LabelBMFontReader/LabelBMFontReader.js | 12 +- .../widgetreader/LabelReader/LabelReader.js | 12 +- .../widgetreader/LayoutReader/LayoutReader.js | 8 +- .../ListViewReader/ListViewReader.js | 6 +- .../LoadingBarReader/LoadingBarReader.js | 8 +- .../PageViewReader/PageViewReader.js | 6 +- .../ScrollViewReader/ScrollViewReader.js | 8 +- .../widgetreader/SliderReader/SliderReader.js | 8 +- .../TextFieldReader/TextFieldReader.js | 8 +- .../reader/widgetreader/WidgetReader.js | 4 +- .../widgetreader/WidgetReaderProtocol.js | 2 +- .../cocostudio/trigger/ObjectFactory.js | 3 + 18 files changed, 171 insertions(+), 129 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 94e7881346..e03c4efab5 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -22,6 +22,36 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ + + +ccs.objectFactory.registerType("ButtonReader", ccui.ButtonReader); +ccs.objectFactory.registerType("CheckBoxReader", ccui.CheckBoxReader); +ccs.objectFactory.registerType("SliderReader", ccui.SliderReader); +ccs.objectFactory.registerType("ImageViewReader", ccui.ImageViewReader); +ccs.objectFactory.registerType("LoadingBarReader", ccui.LoadingBarReader); +ccs.objectFactory.registerType("TextAtlasReader", ccui.TextAtlasReader); +ccs.objectFactory.registerType("TextReader", ccui.TextReader); +ccs.objectFactory.registerType("TextBMFontReader", ccui.TextBMFontReader); +ccs.objectFactory.registerType("TextFieldReader", ccui.TextFieldReader); +ccs.objectFactory.registerType("LayoutReader", ccui.LayoutReader); +ccs.objectFactory.registerType("PageViewReader", ccui.PageViewReader); +ccs.objectFactory.registerType("ScrollViewReader", ccui.ScrollViewReader); +ccs.objectFactory.registerType("ListViewReader", ccui.ListViewReader); + +ccs.objectFactory.registerType("Button", ccui.Button); +ccs.objectFactory.registerType("CheckBox", ccui.CheckBox); +ccs.objectFactory.registerType("ImageView", ccui.ImageView); +ccs.objectFactory.registerType("Text", ccui.Text); +ccs.objectFactory.registerType("TextAtlas", ccui.TextAtlas); +ccs.objectFactory.registerType("TextBMFont", ccui.TextBMFont); +ccs.objectFactory.registerType("LoadingBar", ccui.LoadingBar); +ccs.objectFactory.registerType("Slider", ccui.Slider); +ccs.objectFactory.registerType("TextField", ccui.TextField); +ccs.objectFactory.registerType("Layout", ccui.Layout); +ccs.objectFactory.registerType("ListView", ccui.ListView); +ccs.objectFactory.registerType("PageView", ccui.PageView); +ccs.objectFactory.registerType("ScrollView", ccui.ScrollView); + /** * Base object for ccs.uiReader * @namespace @@ -139,8 +169,10 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ }, registerTypeAndCallBack: function(classType, ins, object, callback){ var factoryCreate = ccs.objectFactory; - var t = new ccs.TInfo(classType, object); + var t = new ccs.TInfo(classType, ins); factoryCreate.registerType(t); + var t2 = new ccs.TInfo(classType + "Reader", object); + factoryCreate.registerType(t2); if(object){ this._mapObject[classType] = object; @@ -820,60 +852,63 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ }, widgetFromJsonDictionary: function (data) { - var widget = null; var classname = data["classname"]; var uiOptions = data["options"]; - if (classname == "Button") { - widget = ccui.Button.create(); - } - else if (classname == "CheckBox") { - widget = ccui.CheckBox.create(); - } - else if (classname == "Label") { - widget = ccui.Text.create(); - } - else if (classname == "LabelAtlas") { - widget = ccui.TextAtlas.create(); - } - else if (classname == "LoadingBar") { - widget = ccui.LoadingBar.create(); - } else if (classname == "ScrollView") { - widget = ccui.ScrollView.create(); - } - else if (classname == "TextArea") { - widget = ccui.Text.create(); - } - else if (classname == "TextButton") { - widget = ccui.Button.create(); - } - else if (classname == "TextField") { - widget = ccui.TextField.create(); - } - else if (classname == "ImageView") { - widget = ccui.ImageView.create(); - } - else if (classname == "Panel") { - widget = ccui.Layout.create(); - } - else if (classname == "Slider") { - widget = ccui.Slider.create(); - } - else if (classname == "LabelBMFont") { - widget = ccui.TextBMFont.create(); - } - else if (classname == "DragPanel") { - widget = ccui.ScrollView.create(); - } - else if (classname == "ListView") { - widget = ccui.ListView.create(); - } - else if (classname == "PageView") { - widget = ccui.PageView.create(); - } - else if (classname == "Widget"){ - widget = ccui.Widget.create(); + var widget = ccs.objectFactory.createObject(classname); + if(!widget){ + if (classname == "Button") { + widget = ccui.Button.create(); + } + else if (classname == "CheckBox") { + widget = ccui.CheckBox.create(); + } + else if (classname == "Label") { + widget = ccui.Text.create(); + } + else if (classname == "LabelAtlas") { + widget = ccui.TextAtlas.create(); + } + else if (classname == "LoadingBar") { + widget = ccui.LoadingBar.create(); + } else if (classname == "ScrollView") { + widget = ccui.ScrollView.create(); + } + else if (classname == "TextArea") { + widget = ccui.Text.create(); + } + else if (classname == "TextButton") { + widget = ccui.Button.create(); + } + else if (classname == "TextField") { + widget = ccui.TextField.create(); + } + else if (classname == "ImageView") { + widget = ccui.ImageView.create(); + } + else if (classname == "Panel") { + widget = ccui.Layout.create(); + } + else if (classname == "Slider") { + widget = ccui.Slider.create(); + } + else if (classname == "LabelBMFont") { + widget = ccui.TextBMFont.create(); + } + else if (classname == "DragPanel") { + widget = ccui.ScrollView.create(); + } + else if (classname == "ListView") { + widget = ccui.ListView.create(); + } + else if (classname == "PageView") { + widget = ccui.PageView.create(); + } + else if (classname == "Widget"){ + widget = ccui.Widget.create(); + } } + // create widget reader to parse properties of widget var readerName = classname; switch(readerName){ @@ -887,7 +922,8 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ readerName = "Button"; break; } - readerName += "Reader"; + + readerName = readerName+"Reader"; var reader = ccs.objectFactory.createWidgetReaderProtocol(readerName); if(reader){ // widget parse with widget reader @@ -897,56 +933,56 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var render; if(widget instanceof ccui.Button){ - render = ccs.ButtonReader; + render = ccui.ButtonReader; }else if(widget instanceof ccui.CheckBox){ render = ccs.CheckBoxReader; }else if (widget instanceof ccui.ImageView) { - render = ccs.ImageViewReader; + render = ccui.ImageViewReader; } else if (widget instanceof ccui.TextAtlas) { - render = ccs.LabelAtlasReader; + render = ccui.LabelAtlasReader; } else if (widget instanceof ccui.LabelBMFont) { - render = ccs.LabelBMFontReader; + render = ccui.LabelBMFontReader; } else if (widget instanceof ccui.Text) { - render = ccs.LabelReader; + render = ccui.LabelReader; } else if (widget instanceof ccui.LoadingBar) { - render = ccs.LoadingBarReader; + render = ccui.LoadingBarReader; } else if (widget instanceof ccui.Slider) { - render = ccs.SliderReader; + render = ccui.SliderReader; } else if (widget instanceof ccui.TextField) { - render = ccs.TextFieldReader; + render = ccui.TextFieldReader; } else if (widget instanceof ccui.ListView) { - render = ccs.ListViewReader; + render = ccui.ListViewReader; } else if (widget instanceof ccui.ScrollView) { - render = ccs.ScrollViewReader; + render = ccui.ScrollViewReader; } else if (widget instanceof ccui.PageView) { - render = ccs.PageViewReader; + render = ccui.PageViewReader; } else if (widget instanceof ccui.Layout) { - render = ccs.LayoutReader; + render = ccui.LayoutReader; } else if (widget instanceof ccui.Widget) { - render = ccs.WidgetReader; + render = ccui.WidgetReader; } this.setPropsForAllWidgetFromJsonDictionary(render, widget, uiOptions); diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 90331eacb1..0a22c57823 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -28,7 +28,7 @@ * @namespace * @name ccs.sceneReader */ -ccs.sceneReader = /** @lends ccs.sceneReader# */{ +ccui.sceneReader = /** @lends ccs.sceneReader# */{ _baseBath:"", _listener:null, _selector:null, diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index c982593981..e10bd5872f 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ButtonReader = { +ccui.ButtonReader = { getInstance: function(){ - return ccs.ButtonReader; + return ccui.ButtonReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -154,8 +154,8 @@ ccs.ButtonReader = { { button.setTitleFontName(options["fontName"]); } - - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + + + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index fe6126fe95..c303c34362 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.CheckBoxReader = { +ccui.CheckBoxReader = { getInstance: function(){ - return ccs.CheckBoxReader; + return ccui.CheckBoxReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -55,6 +55,7 @@ ccs.CheckBoxReader = { } case 1: { + var backGroundFileName = backGroundDic["path"]; checkBox.loadTextureBackGround(backGroundFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } @@ -104,6 +105,7 @@ ccs.CheckBoxReader = { } case 1: { + var frontCrossFileName = frontCrossDic["path"]; checkBox.loadTextureFrontCross(frontCrossFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } @@ -126,6 +128,7 @@ ccs.CheckBoxReader = { } case 1: { + var backGroundDisabledFileName = backGroundDisabledDic["path"]; checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; } @@ -155,6 +158,6 @@ ccs.CheckBoxReader = { break; } - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 42f822cf2a..4ee2bcfabb 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ImageViewReader = { +ccui.ImageViewReader = { getInstance: function(){ - return ccs.ImageViewReader; + return ccui.ImageViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -92,8 +92,8 @@ ccs.ImageViewReader = { imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); } - - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + + + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 55056d22f1..f229856159 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LabelAtlasReader = { +ccui.LabelAtlasReader = { getInstance: function(){ - return ccs.LabelAtlasReader; + return ccui.LabelAtlasReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -65,9 +65,9 @@ ccs.LabelAtlasReader = { break; } } - - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + + + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index c14bf56ebc..df4cb61986 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LabelBMFontReader = { +ccui.LabelBMFontReader = { getInstance: function(){ - return ccs.LabelBMFontReader; + return ccui.LabelBMFontReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -59,8 +59,8 @@ ccs.LabelBMFontReader = { var text = options["text"]; labelBMFont.setString(text); - - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + + + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index 312e2064cd..9520b2b225 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LabelReader = { +ccui.LabelReader = { getInstance: function(){ - return ccs.LabelReader; + return ccui.LabelReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -68,8 +68,8 @@ ccs.LabelReader = { { label.setTextVerticalAlignment(options["vAlignment"]); } - - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + + + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index eb2426ab39..3f13480804 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LayoutReader = { +ccui.LayoutReader = { getInstance: function(){ - return ccs.LayoutReader; + return ccui.LayoutReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -116,6 +116,6 @@ ccs.LayoutReader = { panel.setLayoutType(options["layoutType"]); - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index d32d5929d1..8ad9c247f9 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ListViewReader = { +ccui.ListViewReader = { getInstance: function(){ - return ccs.ListViewReader; + return ccui.ListViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.ScrollViewReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.ScrollViewReader.setPropsFromJsonDictionary.call(this, widget, options); var listView = widget; diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index 3baa3daacf..f9c8e5fdeb 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LoadingBarReader = { +ccui.LoadingBarReader = { getInstance: function(){ - return ccs.LoadingBarReader; + return ccui.LoadingBarReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -77,6 +77,6 @@ ccs.LoadingBarReader = { loadingBar.setDirection(options["direction"]/*ui::LoadingBarType(options["direction"])*/); loadingBar.setPercent(options["percent"]); - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index 0210ce0ac7..aedb85c118 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -23,16 +23,16 @@ THE SOFTWARE. ****************************************************************************/ -ccs.PageViewReader = { +ccui.PageViewReader = { instancePageViewReader: null, getInstance: function(){ - return ccs.PageViewReader; + return ccui.PageViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index 2bd4c02c16..104b952ae4 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ScrollViewReader = { +ccui.ScrollViewReader = { getInstance: function(){ - return ccs.ScrollViewReader; + return ccui.ScrollViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); var scrollView = widget; @@ -46,6 +46,6 @@ ccs.ScrollViewReader = { scrollView.setBounceEnabled(options["bounceEnable"]); - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index 2ded592014..89922a2600 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.SliderReader = { +ccui.SliderReader = { getInstance: function(){ - return ccs.SliderReader; + return ccui.SliderReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -150,6 +150,6 @@ ccs.SliderReader = { break; } - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index c794f1f892..0e8076688e 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccs.TextFieldReader = { +ccui.TextFieldReader = { getInstance: function(){ - return ccs.TextFieldReader; + return ccui.TextFieldReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var textField = widget; var ph = options["placeHolder"]; @@ -86,7 +86,7 @@ ccs.TextFieldReader = { textField.setTextVerticalAlignment(va); } - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 5bf4ae9997..bbe8ca6385 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -23,10 +23,10 @@ THE SOFTWARE. ****************************************************************************/ -ccs.WidgetReader = { +ccui.WidgetReader = { getInstance: function(){ - return ccs.WidgetReader; + return ccui.WidgetReader; }, setPropsFromJsonDictionary: function(widget, options){ diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js index 833ef41ecb..c98be8aaf7 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ -ccs.WidgetReaderProtocol = ccs.Class.extend({ +ccui.WidgetReaderProtocol = ccui.Class.extend({ setPropsFromJsonDictionary: function(widget, options){ diff --git a/extensions/cocostudio/trigger/ObjectFactory.js b/extensions/cocostudio/trigger/ObjectFactory.js index 3c85b19658..e9518e7f79 100644 --- a/extensions/cocostudio/trigger/ObjectFactory.js +++ b/extensions/cocostudio/trigger/ObjectFactory.js @@ -40,6 +40,9 @@ ccs.objectFactory = { }, registerType: function (t) { + if(t._className == "CustomImageView"){ + void 0; + } this._typeMap[t._className] = t; }, From 3813cf0bfe1dbe879b53f8f59af06dc43b7fb77b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 23 Jul 2014 14:47:23 +0800 Subject: [PATCH 0325/1564] Issue #5703: Add customwidget support --- extensions/cocostudio/reader/GUIReader.js | 58 +++++++++---------- extensions/cocostudio/reader/SceneReader.js | 2 +- .../cocostudio/trigger/ObjectFactory.js | 3 - moduleConfig.json | 11 ++-- 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index e03c4efab5..a6c0d165ed 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -23,34 +23,33 @@ THE SOFTWARE. ****************************************************************************/ - -ccs.objectFactory.registerType("ButtonReader", ccui.ButtonReader); -ccs.objectFactory.registerType("CheckBoxReader", ccui.CheckBoxReader); -ccs.objectFactory.registerType("SliderReader", ccui.SliderReader); -ccs.objectFactory.registerType("ImageViewReader", ccui.ImageViewReader); -ccs.objectFactory.registerType("LoadingBarReader", ccui.LoadingBarReader); -ccs.objectFactory.registerType("TextAtlasReader", ccui.TextAtlasReader); -ccs.objectFactory.registerType("TextReader", ccui.TextReader); -ccs.objectFactory.registerType("TextBMFontReader", ccui.TextBMFontReader); -ccs.objectFactory.registerType("TextFieldReader", ccui.TextFieldReader); -ccs.objectFactory.registerType("LayoutReader", ccui.LayoutReader); -ccs.objectFactory.registerType("PageViewReader", ccui.PageViewReader); -ccs.objectFactory.registerType("ScrollViewReader", ccui.ScrollViewReader); -ccs.objectFactory.registerType("ListViewReader", ccui.ListViewReader); - -ccs.objectFactory.registerType("Button", ccui.Button); -ccs.objectFactory.registerType("CheckBox", ccui.CheckBox); -ccs.objectFactory.registerType("ImageView", ccui.ImageView); -ccs.objectFactory.registerType("Text", ccui.Text); -ccs.objectFactory.registerType("TextAtlas", ccui.TextAtlas); -ccs.objectFactory.registerType("TextBMFont", ccui.TextBMFont); -ccs.objectFactory.registerType("LoadingBar", ccui.LoadingBar); -ccs.objectFactory.registerType("Slider", ccui.Slider); -ccs.objectFactory.registerType("TextField", ccui.TextField); -ccs.objectFactory.registerType("Layout", ccui.Layout); -ccs.objectFactory.registerType("ListView", ccui.ListView); -ccs.objectFactory.registerType("PageView", ccui.PageView); -ccs.objectFactory.registerType("ScrollView", ccui.ScrollView); +new ccs.TInfo("ButtonReader", ccui.ButtonReader); +new ccs.TInfo("CheckBoxReader", ccui.CheckBoxReader); +new ccs.TInfo("SliderReader", ccui.SliderReader); +new ccs.TInfo("ImageViewReader", ccui.ImageViewReader); +new ccs.TInfo("LoadingBarReader", ccui.LoadingBarReader); +new ccs.TInfo("TextAtlasReader", ccui.TextAtlasReader); +new ccs.TInfo("TextReader", ccui.TextReader); +new ccs.TInfo("TextBMFontReader", ccui.TextBMFontReader); +new ccs.TInfo("TextFieldReader", ccui.TextFieldReader); +new ccs.TInfo("LayoutReader", ccui.LayoutReader); +new ccs.TInfo("PageViewReader", ccui.PageViewReader); +new ccs.TInfo("ScrollViewReader", ccui.ScrollViewReader); +new ccs.TInfo("ListViewReader", ccui.ListViewReader); + +new ccs.TInfo("Button", ccui.Button); +new ccs.TInfo("CheckBox", ccui.CheckBox); +new ccs.TInfo("ImageView", ccui.ImageView); +new ccs.TInfo("Text", ccui.Text); +new ccs.TInfo("TextAtlas", ccui.TextAtlas); +new ccs.TInfo("TextBMFont", ccui.TextBMFont); +new ccs.TInfo("LoadingBar", ccui.LoadingBar); +new ccs.TInfo("Slider", ccui.Slider); +new ccs.TInfo("TextField", ccui.TextField); +new ccs.TInfo("Layout", ccui.Layout); +new ccs.TInfo("ListView", ccui.ListView); +new ccs.TInfo("PageView", ccui.PageView); +new ccs.TInfo("ScrollView", ccui.ScrollView); /** * Base object for ccs.uiReader @@ -833,7 +832,8 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ return widget; }, setPropsForAllWidgetFromJsonDictionary: function(reader, widget, options){ - reader.setPropsFromJsonDictionary(widget, options); + if(reader && reader.setPropsFromJsonDictionary) + reader.setPropsFromJsonDictionary(widget, options); }, setPropsForAllCustomWidgetFromJsonDictionary: function(classType, widget, customOptions){ var guiReader = ccs.uiReader; diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 0a22c57823..90331eacb1 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -28,7 +28,7 @@ * @namespace * @name ccs.sceneReader */ -ccui.sceneReader = /** @lends ccs.sceneReader# */{ +ccs.sceneReader = /** @lends ccs.sceneReader# */{ _baseBath:"", _listener:null, _selector:null, diff --git a/extensions/cocostudio/trigger/ObjectFactory.js b/extensions/cocostudio/trigger/ObjectFactory.js index e9518e7f79..3c85b19658 100644 --- a/extensions/cocostudio/trigger/ObjectFactory.js +++ b/extensions/cocostudio/trigger/ObjectFactory.js @@ -40,9 +40,6 @@ ccs.objectFactory = { }, registerType: function (t) { - if(t._className == "CustomImageView"){ - void 0; - } this._typeMap[t._className] = t; }, diff --git a/moduleConfig.json b/moduleConfig.json index d0364ed985..837f4c2b21 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -328,10 +328,6 @@ "extensions/cocostudio/trigger/TriggerMng.js", "extensions/cocostudio/trigger/TriggerObj.js", - "extensions/cocostudio/reader/GUIReader.js", - "extensions/cocostudio/reader/SceneReader.js", - "extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js", - "extensions/cocostudio/reader/widgetreader/WidgetReader.js", "extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js", "extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js", @@ -345,7 +341,12 @@ "extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js", "extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js", "extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js", - "extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js" + "extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js", + + "extensions/cocostudio/reader/GUIReader.js", + "extensions/cocostudio/reader/SceneReader.js", + "extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js", + "extensions/cocostudio/reader/widgetreader/WidgetReader.js" ], "gui" : [ "core", "clipping-nodes", "render-texture", "actions", "progress-timer", From e3f848e93703bcc64da5884442e9f0a2574b3e1c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 23 Jul 2014 15:13:13 +0800 Subject: [PATCH 0326/1564] Issue #5703: Add customwidget support --- extensions/cocostudio/reader/GUIReader.js | 26 +++++++++---------- .../widgetreader/ButtonReader/ButtonReader.js | 8 +++--- .../CheckBoxReader/CheckBoxReader.js | 8 +++--- .../ImageViewReader/ImageViewReader.js | 8 +++--- .../LabelAtlasReader/LabelAtlasReader.js | 8 +++--- .../LabelBMFontReader/LabelBMFontReader.js | 8 +++--- .../widgetreader/LabelReader/LabelReader.js | 8 +++--- .../widgetreader/LayoutReader/LayoutReader.js | 8 +++--- .../ListViewReader/ListViewReader.js | 6 ++--- .../LoadingBarReader/LoadingBarReader.js | 8 +++--- .../PageViewReader/PageViewReader.js | 6 ++--- .../ScrollViewReader/ScrollViewReader.js | 8 +++--- .../widgetreader/SliderReader/SliderReader.js | 8 +++--- .../TextFieldReader/TextFieldReader.js | 8 +++--- .../reader/widgetreader/WidgetReader.js | 4 +-- .../widgetreader/WidgetReaderProtocol.js | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index a6c0d165ed..24456a8a63 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -933,56 +933,56 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var render; if(widget instanceof ccui.Button){ - render = ccui.ButtonReader; + render = ccs.ButtonReader; }else if(widget instanceof ccui.CheckBox){ render = ccs.CheckBoxReader; }else if (widget instanceof ccui.ImageView) { - render = ccui.ImageViewReader; + render = ccs.ImageViewReader; } else if (widget instanceof ccui.TextAtlas) { - render = ccui.LabelAtlasReader; + render = ccs.LabelAtlasReader; } else if (widget instanceof ccui.LabelBMFont) { - render = ccui.LabelBMFontReader; + render = ccs.LabelBMFontReader; } else if (widget instanceof ccui.Text) { - render = ccui.LabelReader; + render = ccs.LabelReader; } else if (widget instanceof ccui.LoadingBar) { - render = ccui.LoadingBarReader; + render = ccs.LoadingBarReader; } else if (widget instanceof ccui.Slider) { - render = ccui.SliderReader; + render = ccs.SliderReader; } else if (widget instanceof ccui.TextField) { - render = ccui.TextFieldReader; + render = ccs.TextFieldReader; } else if (widget instanceof ccui.ListView) { - render = ccui.ListViewReader; + render = ccs.ListViewReader; } else if (widget instanceof ccui.ScrollView) { - render = ccui.ScrollViewReader; + render = ccs.ScrollViewReader; } else if (widget instanceof ccui.PageView) { - render = ccui.PageViewReader; + render = ccs.PageViewReader; } else if (widget instanceof ccui.Layout) { - render = ccui.LayoutReader; + render = ccs.LayoutReader; } else if (widget instanceof ccui.Widget) { - render = ccui.WidgetReader; + render = ccs.WidgetReader; } this.setPropsForAllWidgetFromJsonDictionary(render, widget, uiOptions); diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index e10bd5872f..ebab0d784e 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.ButtonReader = { +ccs.ButtonReader = { getInstance: function(){ - return ccui.ButtonReader; + return ccs.ButtonReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -156,6 +156,6 @@ ccui.ButtonReader = { } - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index c303c34362..456198dd87 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.CheckBoxReader = { +ccs.CheckBoxReader = { getInstance: function(){ - return ccui.CheckBoxReader; + return ccs.CheckBoxReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -158,6 +158,6 @@ ccui.CheckBoxReader = { break; } - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 4ee2bcfabb..d384d1e8d4 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.ImageViewReader = { +ccs.ImageViewReader = { getInstance: function(){ - return ccui.ImageViewReader; + return ccs.ImageViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -94,6 +94,6 @@ ccui.ImageViewReader = { } - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index f229856159..7da423934d 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.LabelAtlasReader = { +ccs.LabelAtlasReader = { getInstance: function(){ - return ccui.LabelAtlasReader; + return ccs.LabelAtlasReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -67,7 +67,7 @@ ccui.LabelAtlasReader = { } - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index df4cb61986..32d9945d88 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.LabelBMFontReader = { +ccs.LabelBMFontReader = { getInstance: function(){ - return ccui.LabelBMFontReader; + return ccs.LabelBMFontReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -61,6 +61,6 @@ ccui.LabelBMFontReader = { labelBMFont.setString(text); - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index 9520b2b225..f3fbbfb13d 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.LabelReader = { +ccs.LabelReader = { getInstance: function(){ - return ccui.LabelReader; + return ccs.LabelReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -70,6 +70,6 @@ ccui.LabelReader = { } - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 3f13480804..eb2426ab39 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.LayoutReader = { +ccs.LayoutReader = { getInstance: function(){ - return ccui.LayoutReader; + return ccs.LayoutReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -116,6 +116,6 @@ ccui.LayoutReader = { panel.setLayoutType(options["layoutType"]); - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index 8ad9c247f9..d32d5929d1 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.ListViewReader = { +ccs.ListViewReader = { getInstance: function(){ - return ccui.ListViewReader; + return ccs.ListViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.ScrollViewReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.ScrollViewReader.setPropsFromJsonDictionary.call(this, widget, options); var listView = widget; diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index f9c8e5fdeb..3baa3daacf 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.LoadingBarReader = { +ccs.LoadingBarReader = { getInstance: function(){ - return ccui.LoadingBarReader; + return ccs.LoadingBarReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -77,6 +77,6 @@ ccui.LoadingBarReader = { loadingBar.setDirection(options["direction"]/*ui::LoadingBarType(options["direction"])*/); loadingBar.setPercent(options["percent"]); - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index aedb85c118..0210ce0ac7 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -23,16 +23,16 @@ THE SOFTWARE. ****************************************************************************/ -ccui.PageViewReader = { +ccs.PageViewReader = { instancePageViewReader: null, getInstance: function(){ - return ccui.PageViewReader; + return ccs.PageViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index 104b952ae4..2bd4c02c16 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.ScrollViewReader = { +ccs.ScrollViewReader = { getInstance: function(){ - return ccui.ScrollViewReader; + return ccs.ScrollViewReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); var scrollView = widget; @@ -46,6 +46,6 @@ ccui.ScrollViewReader = { scrollView.setBounceEnabled(options["bounceEnable"]); - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index 89922a2600..2ded592014 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.SliderReader = { +ccs.SliderReader = { getInstance: function(){ - return ccui.SliderReader; + return ccs.SliderReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); @@ -150,6 +150,6 @@ ccui.SliderReader = { break; } - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index 0e8076688e..c794f1f892 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -23,15 +23,15 @@ THE SOFTWARE. ****************************************************************************/ -ccui.TextFieldReader = { +ccs.TextFieldReader = { getInstance: function(){ - return ccui.TextFieldReader; + return ccs.TextFieldReader; }, setPropsFromJsonDictionary: function(widget, options){ - ccui.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var textField = widget; var ph = options["placeHolder"]; @@ -86,7 +86,7 @@ ccui.TextFieldReader = { textField.setTextVerticalAlignment(va); } - ccui.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index bbe8ca6385..5bf4ae9997 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -23,10 +23,10 @@ THE SOFTWARE. ****************************************************************************/ -ccui.WidgetReader = { +ccs.WidgetReader = { getInstance: function(){ - return ccui.WidgetReader; + return ccs.WidgetReader; }, setPropsFromJsonDictionary: function(widget, options){ diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js index c98be8aaf7..833ef41ecb 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ -ccui.WidgetReaderProtocol = ccui.Class.extend({ +ccs.WidgetReaderProtocol = ccs.Class.extend({ setPropsFromJsonDictionary: function(widget, options){ From 4cf5b1ef2a357c5beaa979732e18a268446974ea Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 23 Jul 2014 15:33:32 +0800 Subject: [PATCH 0327/1564] Issue #5704: modify codes for Cocos UI works well. --- cocos2d/core/CCDirector.js | 2 +- cocos2d/core/base-nodes/CCNode.js | 6 +- cocos2d/core/labelttf/CCLabelTTF.js | 19 ++- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/core/sprites/CCSpriteFrame.js | 8 +- cocos2d/tilemap/CCTMXObjectGroup.js | 2 +- extensions/ccui/base-classes/UIWidget.js | 1 - extensions/ccui/uiwidgets/UIButton.js | 2 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 16 +-- extensions/ccui/uiwidgets/UIRichText.js | 47 +++---- extensions/ccui/uiwidgets/UIText.js | 18 +-- extensions/ccui/uiwidgets/UITextAtlas.js | 18 ++- extensions/ccui/uiwidgets/UITextBMFont.js | 18 ++- extensions/ccui/uiwidgets/UITextField.js | 163 +++++++++------------- 15 files changed, 136 insertions(+), 188 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 1d2fc137c8..85ad9a6756 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -283,7 +283,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ * @return {cc.Size} */ getWinSize: function () { - return this._winSizeInPoints; + return cc.size(this._winSizeInPoints); }, /** diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index acff1364e8..bec56bbd96 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -733,7 +733,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} The anchor point of node. */ getAnchorPoint: function () { - return this._anchorPoint; + return cc.p(this._anchorPoint); }, /** @@ -810,7 +810,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} The anchor point in absolute pixels. */ getAnchorPointInPoints: function () { - return this._anchorPointInPoints; + return cc.p(this._anchorPointInPoints); }, _getWidth: function () { @@ -838,7 +838,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Size} The untransformed size of the node. */ getContentSize: function () { - return this._contentSize; + return cc.size(this._contentSize); }, /** diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 48297c50b6..2177148422 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -260,7 +260,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ * @return {cc.Size} */ getDimensions: function () { - return cc.size(this._dimensions.width, this._dimensions.height); + return cc.size(this._dimensions); }, /** @@ -651,11 +651,20 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ /** * set Dimensions of cc.LabelTTF - * @param {cc.Size} dim + * @param {cc.Size|Number} dim dimensions or width of dimensions + * @param {Number} [height] height of dimensions */ - setDimensions: function (dim) { - if (dim.width != this._dimensions.width || dim.height != this._dimensions.height) { - this._dimensions = dim; + setDimensions: function (dim, height) { + var width; + if(height === undefined){ + width = dim.width; + height = dim.height; + }else + width = dim; + + if (width != this._dimensions.width || height != this._dimensions.height) { + this._dimensions.width = width; + this._dimensions.height = height; this._updateString(); // Force udpate this._needUpdateTexture = true; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 58f9c2b007..1a0bfc8426 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -397,7 +397,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @return {cc.Point} */ getOffsetPosition:function () { - return this._offsetPosition; + return cc.p(this._offsetPosition); }, _getOffsetX: function () { diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 3b8a221885..65c7edf663 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -185,7 +185,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * @return {cc.Point} */ getOffsetInPixels:function () { - return this._offsetInPixels; + return cc.p(this._offsetInPixels); }, /** @@ -204,7 +204,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * @return {cc.Size} */ getOriginalSizeInPixels:function () { - return this._originalSizeInPixels; + return cc.size(this._originalSizeInPixels); }, /** @@ -222,7 +222,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * @return {cc.Size} */ getOriginalSize:function () { - return this._originalSize; + return cc.size(this._originalSize); }, /** @@ -296,7 +296,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * @return {cc.Point} */ getOffset:function () { - return this._offset; + return cc.p(this._offset); }, /** diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js index 89e00cb9b2..55fe09e324 100644 --- a/cocos2d/tilemap/CCTMXObjectGroup.js +++ b/cocos2d/tilemap/CCTMXObjectGroup.js @@ -51,7 +51,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ * @return {cc.Point} */ getPositionOffset:function () { - return this._positionOffset; + return cc.p(this._positionOffset); }, /** diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 00a94e7c7c..37845c47f8 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -337,7 +337,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ parentSize = this._parent.getContentSize(); } - var locSize; switch (this._sizeType) { case ccui.Widget.SIZE_ABSOLUTE: if(this._ignoreSize) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 66173ff5b5..ebc29748bb 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -182,7 +182,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, getVirtualRendererSize: function(){ - return this._normalTextureSize; + return cc.size(this._normalTextureSize); }, /** diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 15b02cc61d..a865a88d6b 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -214,7 +214,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, getVirtualRendererSize: function(){ - return this._imageTextureSize; + return cc.size(this._imageTextureSize); }, /** diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 020254f5ee..bae612eaf5 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -263,7 +263,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, getVirtualRendererSize:function(){ - return this._barRendererTextureSize; + return cc.size(this._barRendererTextureSize); }, /** @@ -275,14 +275,14 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, _barRendererScaleChangedWithSize: function () { - var locBarRender = this._barRenderer; + var locBarRender = this._barRenderer, locContentSize = this._contentSize; if (this._ignoreSize) { if (!this._scale9Enabled) { this._totalLength = this._barRendererTextureSize.width; locBarRender.setScale(1.0); } } else { - this._totalLength = this._size.width; + this._totalLength = locContentSize.width; if (this._scale9Enabled) this._setScale9Scale(); else { @@ -291,18 +291,18 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ locBarRender.setScale(1.0); return; } - var scaleX = this._size.width / textureSize.width; - var scaleY = this._size.height / textureSize.height; + var scaleX = locContentSize.width / textureSize.width; + var scaleY = locContentSize.height / textureSize.height; locBarRender.setScaleX(scaleX); locBarRender.setScaleY(scaleY); } } switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: - locBarRender.setPosition(0, this._contentSize.height * 0.5); + locBarRender.setPosition(0, locContentSize.height * 0.5); break; case ccui.LoadingBar.TYPE_RIGHT: - locBarRender.setPosition(this._totalLength, this._contentSize.height * 0.5); + locBarRender.setPosition(this._totalLength, locContentSize.height * 0.5); break; default: break; @@ -311,7 +311,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _setScale9Scale: function () { var width = (this._percent) / 100 * this._totalLength; - this._barRenderer.setPreferredSize(cc.size(width, this._size.height)); + this._barRenderer.setPreferredSize(cc.size(width, this._contentSize.height)); }, /** diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index a1dfe49e68..7157ea7caa 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -342,11 +342,12 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ formatRenderers: function () { var newContentSizeHeight = 0, locRenderersContainer = this._elementRenderersContainer; var locElementRenders = this._elementRenders; + var i, j, row, nextPosX, l; if (this._ignoreSize) { var newContentSizeWidth = 0; - var row = locElementRenders[0]; - var nextPosX = 0; - for (var j = 0; j < row.length; j++) { + row = locElementRenders[0]; + nextPosX = 0; + for (j = 0; j < row.length; j++) { var l = row[j]; l.setAnchorPoint(cc.p(0, 0)); l.setPosition(cc.p(nextPosX, 0)); @@ -359,11 +360,11 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ locRenderersContainer.setContentSize(cc.size(newContentSizeWidth, newContentSizeHeight)); } else { var maxHeights = []; - for (var i = 0; i < locElementRenders.length; i++) { - var row = locElementRenders[i]; + for (i = 0; i < locElementRenders.length; i++) { + row = locElementRenders[i]; var maxHeight = 0; - for (var j = 0; j < row.length; j++) { - var l = row[j]; + for (j = 0; j < row.length; j++) { + l = row[j]; maxHeight = Math.max(l.getContentSize().height, maxHeight); } maxHeights[i] = maxHeight; @@ -371,13 +372,13 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } var nextPosY = this._customSize.height; - for (var i = 0; i < locElementRenders.length; i++) { - var row = locElementRenders[i]; - var nextPosX = 0; + for (i = 0; i < locElementRenders.length; i++) { + row = locElementRenders[i]; + nextPosX = 0; nextPosY -= (maxHeights[i] + this._verticalSpace); - for (var j = 0; j < row.length; j++) { - var l = row[j]; + for (j = 0; j < row.length; j++) { + l = row[j]; l.setAnchorPoint(cc.p(0, 0)); l.setPosition(cc.p(nextPosX, nextPosY)); locRenderersContainer.addChild(l, 1); @@ -386,25 +387,15 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } locRenderersContainer.setContentSize(this._contentSize); } - this._elementRenders.length = 0; - var length = this._elementRenders.length; - for (var i = 0; i Date: Wed, 23 Jul 2014 16:20:44 +0800 Subject: [PATCH 0328/1564] issue #5740: refactor Scale9Sprite create & ctor --- .../gui/control-extension/CCScale9Sprite.js | 68 +++++++------------ 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 3122a806f1..a848169ee7 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -197,7 +197,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ locCenter.setPosition(leftWidth, bottomHeight); }, - ctor: function () { + /** + * @constructor + * @param file + * @param rect + * @param capInsets + * @returns {Scale9Sprite} + */ + ctor: function (file, rect, capInsets) { cc.Node.prototype.ctor.call(this); this._spriteRect = cc.rect(0, 0, 0, 0); this._capInsetsInternal = cc.rect(0, 0, 0, 0); @@ -209,6 +216,20 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._opacity = 255; this._capInsets = cc.rect(0, 0, 0, 0); this._loadedEventListeners = []; + + if(file != undefined){ + if(file instanceof cc.SpriteFrame) + this.initWithSpriteFrame(file, rect); + else{ + var frame = cc.spriteFrameCache.getSpriteFrame(file); + if(frame != null) + this.initWithSpriteFrame(frame, rect); + else + this.initWithFile(file, rect, capInsets); + } + }else{ + this.init(); + } }, /** Original sprite's size. */ @@ -931,56 +952,17 @@ _p = null; * @see initWithFile:rect:centerRegion: */ cc.Scale9Sprite.create = function (file, rect, capInsets) { - var pReturn; - if (arguments.length === 2) { - if (typeof(file) == "string") { - pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.initWithFile(file, rect)) { - return pReturn; - } - } else if (file instanceof cc.Rect) { - pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.initWithFile(file, capInsets)) { - return pReturn; - } - } - } else if (arguments.length === 3) { - pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.initWithFile(file, rect, capInsets)) { - return pReturn; - } - } else if (arguments.length === 1) { - pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.initWithFile(file)) { - return pReturn; - } - } else if (arguments.length === 0) { - pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.init()) { - return pReturn; - } - } - return null; + return new cc.Scale9Sprite(file, rect, capInsets); }; cc.Scale9Sprite.createWithSpriteFrame = function (spriteFrame, capInsets) { - var pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.initWithSpriteFrame(spriteFrame, capInsets)) { - return pReturn; - } - return null; + return new cc.Scale9Sprite(spriteFrame, capInsets); }; cc.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName, capInsets) { - if(!spriteFrameName) - throw "cc.Scale9Sprite.createWithSpriteFrameName(): spriteFrameName should be non-null"; - var pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.initWithSpriteFrameName(spriteFrameName, capInsets)) - return pReturn; - return null; + return new cc.Scale9Sprite(spriteFrameName, capInsets); }; - /** * @ignore */ From 6dc6a156d9d322754aa4d266f58379038ac8bc2f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 23 Jul 2014 16:26:34 +0800 Subject: [PATCH 0329/1564] Issue #5704: reformat some functions of ccui.TextField --- extensions/ccui/uiwidgets/UITextField.js | 55 ++++++++++++------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index fbd0e7978d..54d8e8cb36 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -125,43 +125,52 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ } } }, + openIME: function () { cc.TextFieldTTF.prototype.attachWithIME.call(this); }, + closeIME: function () { cc.TextFieldTTF.prototype.detachWithIME.call(this); }, + setMaxLengthEnabled: function (enable) { this._maxLengthEnabled = enable; }, + isMaxLengthEnabled: function () { return this._maxLengthEnabled; }, + setMaxLength: function (length) { this._maxLength = length; }, + getMaxLength: function () { return this._maxLength; }, + getCharCount: function () { return cc.TextFieldTTF.prototype.getCharCount.call(this); }, + setPasswordEnabled: function (enable) { this._passwordEnabled = enable; }, + isPasswordEnabled: function () { return this._passwordEnabled; }, + setPasswordStyleText: function (styleText) { - if (styleText.length > 1) { + if (styleText.length > 1) return; - } var header = styleText.charCodeAt(0); - if (header < 33 || header > 126) { + if (header < 33 || header > 126) return; - } this._passwordStyleText = styleText; }, + setPasswordText: function (text) { var tempStr = ""; var text_count = text.length; @@ -503,10 +512,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ return this._textFieldRenderer.isPasswordEnabled(); }, - /** - * @param {String} enable - */ - setPasswordStyleText: function (styleText) { + setPasswordStyleText: function(styleText){ this._textFieldRenderer.setPasswordStyleText(styleText); this._passwordStyleText = styleText; @@ -608,45 +614,38 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, _attachWithIMEEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) { + if (this._textFieldEventListener && this._textFieldEventSelector) this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_ATTACH_WITH_IME); - } - if (this._eventCallback) { - this._eventCallback(this, 0); - } + if (this._eventCallback) + this._eventCallback(this, ccui.TextField.EVENT_ATTACH_WITH_IME); }, _detachWithIMEEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) { + if (this._textFieldEventListener && this._textFieldEventSelector) this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DETACH_WITH_IME); - } - if (this._eventCallback) { - this._eventCallback(this, 1); - } + if (this._eventCallback) + this._eventCallback(this, ccui.TextField.EVENT_DETACH_WITH_IME); }, _insertTextEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) { + if (this._textFieldEventListener && this._textFieldEventSelector) this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT); - } - if (this._eventCallback) { - this._eventCallback(this, 2); - } + if (this._eventCallback) + this._eventCallback(this, ccui.TextField.EVENT_INSERT_TEXT); }, _deleteBackwardEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) { + if (this._textFieldEventListener && this._textFieldEventSelector) this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD); - } - if (this._eventCallback) { - this._eventCallback(this, 3); - } + if (this._eventCallback) + this._eventCallback(this, ccui.TextField.EVENT_DELETE_BACKWARD); }, /** * add event listener * @param {Object} target * @param {Function} selector + * @deprecated */ addEventListenerTextField: function (target, selector) { this._textFieldEventSelector = selector; From a3194822cad72412cd2723e7fd869979d3f1737a Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 23 Jul 2014 17:52:23 +0800 Subject: [PATCH 0330/1564] refactor ControlButton create & ctor --- .../gui/control-extension/CCControlButton.js | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/extensions/gui/control-extension/CCControlButton.js b/extensions/gui/control-extension/CCControlButton.js index de8d89281d..0a82508ba5 100644 --- a/extensions/gui/control-extension/CCControlButton.js +++ b/extensions/gui/control-extension/CCControlButton.js @@ -62,7 +62,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ _marginH: 0, _className: "ControlButton", - ctor: function () { + ctor: function (label, backgroundSprite, fontSize) { cc.Control.prototype.ctor.call(this); this._preferredSize = cc.size(0, 0); this._labelAnchorPoint = cc.p(0, 0); @@ -72,6 +72,15 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ this._titleColorDispatchTable = {}; this._titleLabelDispatchTable = {}; this._backgroundSpriteDispatchTable = {}; + + if(fontSize != undefined) + this.initWithTitleAndFontNameAndFontSize(label, backgroundSprite, fontSize); + else if(backgroundSprite != undefined) + this.initWithLabelAndBackgroundSprite(label, backgroundSprite); + else if(label != undefined) + this.initWithBackgroundSprite(label); + else + this.init(); }, init: function () { @@ -665,25 +674,8 @@ cc.defineGetterSetter(_p, "labelAnchor", _p.getLabelAnchorPoint, _p.setLabelAnch _p = null; -cc.ControlButton.create = function (label, backgroundSprite) { - var controlButton; - if (arguments.length == 0) { - controlButton = new cc.ControlButton(); - if (controlButton && controlButton.init()) { - return controlButton; - } - return null; - } else if (arguments.length == 1) { - controlButton = new cc.ControlButton(); - controlButton.initWithBackgroundSprite(arguments[0]); - } else if (arguments.length == 2) { - controlButton = new cc.ControlButton(); - controlButton.initWithLabelAndBackgroundSprite(label, backgroundSprite); - } else if (arguments.length == 3) { - controlButton = new cc.ControlButton(); - controlButton.initWithTitleAndFontNameAndFontSize(arguments[0], arguments[1], arguments[2]); - } - return controlButton; +cc.ControlButton.create = function (label, backgroundSprite, fontSize) { + return new cc.ControlButton(label, backgroundSprite, fontSize); }; From 06421d343a9fc6f41a90211f0e14364811b8e016 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 23 Jul 2014 18:07:12 +0800 Subject: [PATCH 0331/1564] Issue #5704: Fixed a bug of PageView, it can't touch on it --- .../ccui/uiwidgets/scroll-widget/UIListView.js | 4 ++-- .../ccui/uiwidgets/scroll-widget/UIPageView.js | 14 +++++--------- .../ccui/uiwidgets/scroll-widget/UIScrollView.js | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index fdc6008e13..9cddc6fabf 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -439,8 +439,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._eventCallback(this, eventEnum); }, - _interceptTouchEvent: function (handleState, sender, touchPoint) { - ccui.ScrollView.prototype._interceptTouchEvent.call(this, handleState, sender, touchPoint); + interceptTouchEvent: function (handleState, sender, touch) { + ccui.ScrollView.prototype.interceptTouchEvent.call(this, handleState, sender, touch); if (handleState != ccui.Widget.TOUCH_MOVED) { var parent = sender; while (parent) { diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 506ce41bd4..e03c690b2c 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -307,16 +307,11 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, - // onTouchBegan logic at ccui.Layout - onTouchBegan: function(touch, event){ - ccui.Widget.prototype.onTouchBegan.call(this, touch, event); - }, - onTouchMoved: function (touch, event) { this._handleMoveLogic(touch); var widgetParent = this.getWidgetParent(); if (widgetParent) - widgetParent._interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); + widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); this._moveEvent(); }, @@ -419,7 +414,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, - _interceptTouchEvent: function (handleState, sender, touchPoint) { + interceptTouchEvent: function (handleState, sender, touch) { + var touchPoint = touch.getLocation(); switch (handleState) { case ccui.Widget.TOUCH_BEGAN: break; @@ -428,12 +424,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ offset = Math.abs(sender.getTouchBeganPosition().x - touchPoint.x); if (offset > this._childFocusCancelOffset) { sender.setFocused(false); - this._handleMoveLogic(touchPoint); + this._handleMoveLogic(touch); } break; case ccui.Widget.TOUCH_ENDED: case ccui.Widget.TOUCH_CANCELED: - this._handleReleaseLogic(touchPoint); + this._handleReleaseLogic(touch); break; } }, diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 9d26449eb0..a3276c0ef9 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1410,7 +1410,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {ccui.Widget} sender * @param {cc.Touch} touch */ - _interceptTouchEvent: function (event, sender, touch) { + interceptTouchEvent: function (event, sender, touch) { var touchPoint = touch.getLocation(); switch (event) { case ccui.Widget.TOUCH_BEGAN: From 785f5d9bbf66d3d47e8097574f809ed0998733a1 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 23 Jul 2014 18:21:23 +0800 Subject: [PATCH 0332/1564] refactor colorpicker, potentiometer, slider, stepper, switch --- .../CCControlColourPicker.js | 8 +++-- .../CCControlPotentiometer.js | 31 +++++++++--------- .../gui/control-extension/CCControlSlider.js | 32 ++++++++++--------- .../gui/control-extension/CCControlStepper.js | 11 +++---- .../gui/control-extension/CCControlSwitch.js | 10 +++--- 5 files changed, 47 insertions(+), 45 deletions(-) diff --git a/extensions/gui/control-extension/CCControlColourPicker.js b/extensions/gui/control-extension/CCControlColourPicker.js index 03814ed519..029173da65 100644 --- a/extensions/gui/control-extension/CCControlColourPicker.js +++ b/extensions/gui/control-extension/CCControlColourPicker.js @@ -44,6 +44,10 @@ cc.ControlColourPicker = cc.Control.extend(/** @lends cc.ControlColourPicker# */ _background:null, _className:"ControlColourPicker", + ctor:function () { + cc.Control.prototype.ctor.call(this); + this.init(); + }, hueSliderValueChanged:function (sender, controlEvent) { this._hsv.h = sender.getHue(); @@ -170,9 +174,7 @@ cc.defineGetterSetter(_p, "background", _p.getBackground); _p = null; cc.ControlColourPicker.create = function () { - var pRet = new cc.ControlColourPicker(); - pRet.init(); - return pRet; + return new cc.ControlColourPicker(); }; // compatible with NPM diff --git a/extensions/gui/control-extension/CCControlPotentiometer.js b/extensions/gui/control-extension/CCControlPotentiometer.js index 0f29baf387..5589b75130 100644 --- a/extensions/gui/control-extension/CCControlPotentiometer.js +++ b/extensions/gui/control-extension/CCControlPotentiometer.js @@ -54,6 +54,21 @@ cc.ControlPotentiometer = cc.Control.extend(/** @lends cc.ControlPotentiometer# _maximumValue:1, _className:"ControlPotentiometer", + ctor:function (backgroundFile, progressFile, thumbFile) { + cc.Control.prototype.ctor.call(this); + if (thumbFile != undefined) { + // Prepare track for potentiometer + var backgroundSprite = cc.Sprite.create(backgroundFile); + + // Prepare thumb for potentiometer + var thumbSprite = cc.Sprite.create(thumbFile); + + // Prepare progress for potentiometer + var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); + this.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite); + } + }, + /** * * @param {cc.Sprite} trackSprite @@ -274,19 +289,5 @@ cc.defineGetterSetter(_p, "prevLocation", _p.getPreviousLocation, _p.setPrevious _p = null; cc.ControlPotentiometer.create = function (backgroundFile, progressFile, thumbFile) { - var pRet = new cc.ControlPotentiometer(); - if (pRet) { - // Prepare track for potentiometer - var backgroundSprite = cc.Sprite.create(backgroundFile); - - // Prepare thumb for potentiometer - var thumbSprite = cc.Sprite.create(thumbFile); - - // Prepare progress for potentiometer - var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); - if (pRet.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite)) { - return pRet; - } - } - return null; + return new cc.ControlPotentiometer(backgroundFile, progressFile, thumbFile); }; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index c762409c2b..19dd14d267 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -61,6 +61,22 @@ cc.ControlSlider = cc.Control.extend(/** @lends cc.ControlSlider# */{ _backgroundSprite:null, _className:"ControlSlider", + ctor:function (bgFile, progressFile, thumbFile) { + cc.Control.prototype.ctor.call(this); + if (thumbFile != undefined) { + // Prepare background for slider + bgSprite = cc.Sprite.create(bgFile); + + // Prepare progress for slider + progressSprite = cc.Sprite.create(progressFile); + + // Prepare thumb (menuItem) for slider + thumbSprite = cc.Sprite.create(thumbFile); + + this.initWithSprites(bgSprite, progressSprite, thumbSprite); + } + }, + getValue:function () { return this._value; }, @@ -287,19 +303,5 @@ _p = null; * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ cc.ControlSlider.create = function (bgFile, progressFile, thumbFile) { - if (typeof(bgFile) == "string") { - // Prepare background for slider - bgFile = cc.Sprite.create(bgFile); - - // Prepare progress for slider - progressFile = cc.Sprite.create(progressFile); - - // Prepare thumb (menuItem) for slider - thumbFile = cc.Sprite.create(thumbFile); - } - - var pRet = new cc.ControlSlider(); - pRet.initWithSprites(bgFile, progressFile, thumbFile); - return pRet; - + return new cc.ControlSlider(bgFile, progressFile, thumbFile); }; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js index 4dabaae3b1..ee3eeb8e8b 100644 --- a/extensions/gui/control-extension/CCControlStepper.js +++ b/extensions/gui/control-extension/CCControlStepper.js @@ -72,7 +72,7 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{ _touchedPart:cc.CONTROL_STEPPER_PARTNONE, _autorepeatCount:0, _className:"ControlStepper", - ctor:function () { + ctor:function (minusSprite, plusSprite) { cc.Control.prototype.ctor.call(this); this._minusSprite = null; this._plusSprite = null; @@ -88,6 +88,9 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{ this._touchInsideFlag = false; this._touchedPart = cc.CONTROL_STEPPER_PARTNONE; this._autorepeatCount = 0; + + plusSprite && this.initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite); + }, initWithMinusSpriteAndPlusSprite:function (minusSprite, plusSprite) { @@ -377,9 +380,5 @@ cc.defineGetterSetter(_p, "plusLabel", _p.getPlusLabel, _p.setPlusLabel); _p = null; cc.ControlStepper.create = function (minusSprite, plusSprite) { - var pRet = new cc.ControlStepper(); - if (pRet && pRet.initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite)) { - return pRet; - } - return null; + return new cc.ControlStepper(minusSprite, plusSprite); }; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js index 45981e936a..2b19590b8b 100644 --- a/extensions/gui/control-extension/CCControlSwitch.js +++ b/extensions/gui/control-extension/CCControlSwitch.js @@ -40,8 +40,10 @@ cc.ControlSwitch = cc.Control.extend(/** @lends cc.ControlSwitch# */{ /** A Boolean value that determines the off/on state of the switch. */ _on:false, _className:"ControlSwitch", - ctor:function () { + ctor:function (maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel) { cc.Control.prototype.ctor.call(this); + + offLabel && this.initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); }, /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ @@ -156,11 +158,7 @@ cc.ControlSwitch = cc.Control.extend(/** @lends cc.ControlSwitch# */{ /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ cc.ControlSwitch.create = function (maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel) { - var pRet = new cc.ControlSwitch(); - if (pRet && pRet.initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel)) { - return pRet; - } - return null; + return new cc.ControlSwitch(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); }; /** From 3320bf31424eaa56146c5828a0fd5427b37c60dc Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 23 Jul 2014 18:36:48 +0800 Subject: [PATCH 0333/1564] Issue #5703: Fix bug --- extensions/cocostudio/reader/GUIReader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 24456a8a63..3c5b7cc257 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -1016,7 +1016,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ { if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { - var position = child.getPosition(); + var position = child.getPositionPercent(); var anchor = widget.getAnchorPoint(); child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); } From 79781f61d7fd0b1f6c58dec461cf5c6691fe2ea6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 24 Jul 2014 13:45:09 +0800 Subject: [PATCH 0334/1564] Issue #5704: fixed some mistakes of ccui.Widget, ccui.RichText, ccui.Text --- extensions/ccui/base-classes/UIWidget.js | 6 +- extensions/ccui/uiwidgets/UIRichText.js | 92 ++++++++++++------------ extensions/ccui/uiwidgets/UIText.js | 22 ++++-- 3 files changed, 68 insertions(+), 52 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 37845c47f8..1e9ce20d62 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -242,11 +242,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _setWidth: function (w) { + cc.Node.prototype._setWidth.call(this, w); this._customSize.width = w; if(this._ignoreSize) this._contentSize = this.getVirtualRendererSize(); - else - this._contentSize.width = w; if (this._running) { var widgetParent = this.getWidgetParent(); @@ -256,11 +255,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._onSizeChanged(); }, _setHeight: function (h) { + cc.Node.prototype._setHeight.call(this, h); this._customSize.height = h; if(this._ignoreSize) this._contentSize = this.getVirtualRendererSize(); - else - this._contentSize.height = h; if (this._running) { var widgetParent = this.getWidgetParent(); diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 7157ea7caa..5bbfcacac4 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -29,21 +29,25 @@ * @extends ccui.Class */ ccui.RichElement = ccui.Class.extend(/** @lends ccui.RichElement# */{ - type: 0, - tag: 0, - color: null, + _type: 0, + _tag: 0, + _color: null, + _opacity:0, ctor: function () { - this.type = 0; - this.tag = 0; - this.color = cc.color(255, 255, 255, 255); + this._type = 0; + this._tag = 0; + this._color = cc.color(255, 255, 255, 255); }, init: function (tag, color, opacity) { - this.tag = tag; - this.color.r = color.r; - this.color.g = color.g; - this.color.b = color.b; - this.color.a = color.a; + this._tag = tag; + this._color.r = color.r; + this._color.g = color.g; + this._color.b = color.b; this._opacity = opacity; + if(opacity === undefined) + this._color.a = color.a; + else + this._color.a = opacity; } }); @@ -53,21 +57,21 @@ ccui.RichElement = ccui.Class.extend(/** @lends ccui.RichElement# */{ * @extends ccui.RichElement */ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# */{ - text: "", - fontName: "", - fontSize: 0, + _text: "", + _fontName: "", + _fontSize: 0, ctor: function () { ccui.RichElement.prototype.ctor.call(this); - this.type = ccui.RichElement.TEXT; - this.text = ""; - this.fontName = ""; - this.fontSize = 0; + this._type = ccui.RichElement.TEXT; + this._text = ""; + this._fontName = ""; + this._fontSize = 0; }, init: function (tag, color, opacity, text, fontName, fontSize) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); - this.text = text; - this.fontName = fontName; - this.fontSize = fontSize; + this._text = text; + this._fontName = fontName; + this._fontSize = fontSize; } }); @@ -94,14 +98,14 @@ ccui.RichElementText.create = function (tag, color, opacity, text, fontName, fon */ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage# */{ _filePath: "", - textureRect: null, - textureType: 0, + _textureRect: null, + _textureType: 0, ctor: function () { ccui.RichElement.prototype.ctor.call(this); - this.type = ccui.RichElement.IMAGE; - this.filePath = ""; - this.textureRect = cc.rect(0, 0, 0, 0); - this.textureType = 0; + this._type = ccui.RichElement.IMAGE; + this._filePath = ""; + this._textureRect = cc.rect(0, 0, 0, 0); + this._textureType = 0; }, init: function (tag, color, opacity, filePath) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); @@ -115,7 +119,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage * @param {cc.Color} color * @param {Number} opacity * @param {String} filePath - * @returns {ccui.RichElementText} + * @returns {ccui.RichElementImage} */ ccui.RichElementImage.create = function (tag, color, opacity, filePath) { var element = new ccui.RichElementImage(); @@ -129,15 +133,15 @@ ccui.RichElementImage.create = function (tag, color, opacity, filePath) { * @extends ccui.RichElement */ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElementCustomNode# */{ - customNode: null, + _customNode: null, ctor: function () { ccui.RichElement.prototype.ctor.call(this); - this.type = ccui.RichElement.CUSTOM; - this.customNode = null; + this._type = ccui.RichElement.CUSTOM; + this._customNode = null; }, init: function (tag, color, opacity, customNode) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); - this.customNode = customNode; + this._customNode = customNode; } }); @@ -147,7 +151,7 @@ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElement * @param {Number} color * @param {Number} opacity * @param {cc.Node} customNode - * @returns {RichElementText} + * @returns {ccui.RichElementCustomNode} */ ccui.RichElementCustomNode.create = function (tag, color, opacity, customNode) { var element = new ccui.RichElementCustomNode(); @@ -230,37 +234,37 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ for (i = 0; i < locRichElements.length; i++) { element = locRichElements[i]; var elementRenderer = null; - switch (element.type) { + switch (element._type) { case ccui.RichElement.TEXT: //todo: There may be ambiguous - elementRenderer = cc.LabelTTF.create(element.text, element.fontName, element.fontSize); + elementRenderer = cc.LabelTTF.create(element._text, element._fontName, element._fontSize); break; case ccui.RichElement.IMAGE: - elementRenderer = cc.Sprite.create(element.filePath); + elementRenderer = cc.Sprite.create(element._filePath); break; case ccui.RichElement.CUSTOM: - elementRenderer = element.customNode; + elementRenderer = element._customNode; break; default: break; } - elementRenderer.setColor(element.color); - elementRenderer.setOpacity(element.color.a); + elementRenderer.setColor(element._color); + elementRenderer.setOpacity(element._color.a); this._pushToContainer(elementRenderer); } } else { this._addNewLine(); for (i = 0; i < locRichElements.length; i++) { element = locRichElements[i]; - switch (element.type) { + switch (element._type) { case ccui.RichElement.TEXT: - this._handleTextRenderer(element.text, element.fontName, element.fontSize, element.color); + this._handleTextRenderer(element._text, element._fontName, element._fontSize, element._color); break; case ccui.RichElement.IMAGE: - this._handleImageRenderer(element.filePath, element.color, element.color.a); + this._handleImageRenderer(element._filePath, element._color, element._color.a); break; case ccui.RichElement.CUSTOM: - this._handleCustomRenderer(element.customNode); + this._handleCustomRenderer(element._customNode); break; default: break; @@ -348,7 +352,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ row = locElementRenders[0]; nextPosX = 0; for (j = 0; j < row.length; j++) { - var l = row[j]; + l = row[j]; l.setAnchorPoint(cc.p(0, 0)); l.setPosition(cc.p(nextPosX, 0)); locRenderersContainer.addChild(l, 1, j); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 9263be0cef..c619a675d9 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -169,6 +169,19 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ 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(); + }, + getType: function(){ return this._type; }, @@ -296,24 +309,25 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _labelScaleChangedWithSize: function () { + var locContentSize = this._contentSize; if (this._ignoreSize) { this._labelRenderer.setScale(1.0); this._normalScaleValueX = this._normalScaleValueY = 1; } else { - this._labelRenderer.setDimensions(cc.size(this._contentSize.width, this._contentSize.height)); + this._labelRenderer.setDimensions(cc.size(locContentSize.width, locContentSize.height)); var textureSize = this._labelRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._labelRenderer.setScale(1.0); return; } - var scaleX = this._contentSize.width / textureSize.width; - var scaleY = this._contentSize.height / textureSize.height; + var scaleX = locContentSize.width / textureSize.width; + var scaleY = locContentSize.height / textureSize.height; this._labelRenderer.setScaleX(scaleX); this._labelRenderer.setScaleY(scaleY); this._normalScaleValueX = scaleX; this._normalScaleValueY = scaleY; } - this._labelRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); + this._labelRenderer.setPosition(locContentSize.width / 2.0, locContentSize.height / 2.0); }, /** From ddeea8b00180b909626050e3b87d5b6db92283ad Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 24 Jul 2014 14:26:16 +0800 Subject: [PATCH 0335/1564] Issue #5703: Fix bug about position --- .../reader/widgetreader/WidgetReader.js | 88 +++++++++++++------ 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 5bf4ae9997..6c34ab7f5e 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -42,9 +42,22 @@ ccs.WidgetReader = { widget.setSizePercent(cc.p(options["sizePercentX"], options["sizePercentY"])); widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"])); - var w = options["width"]; - var h = options["height"]; - widget.setSize(cc.size(w, h)); + /* adapt screen */ + var w = 0; + var h = 0; + var adaptScreen = options["adaptScreen"]; + if (adaptScreen !== undefined) + { + var screenSize = cc.director.getWinSize(); + w = screenSize.width; + h = screenSize.height; + } + else + { + w = options["width"]; + h = options["height"]; + } + widget.setContentSize(cc.size(w, h)); widget.setTag(options["tag"]); widget.setActionTag(options["actiontag"]); @@ -58,26 +71,23 @@ ccs.WidgetReader = { widget.setPosition(cc.p(x, y)); - var sx = options["scalex"]; - if(sx){ - widget.setScaleX(sx); - } - var sy = options["scaleY"]; - if(sy){ - widget.setScaleY(sy); - } - var rt = options["rotation"]; - if(rt){ - widget.setRotation(rt); - } - var vb = options["visible"]; - if(vb){ + var sx = options["scalex"] || 1; + widget.setScaleX(sx); + + var sy = options["scaleY"] || 1; + widget.setScaleY(sy); + + var rt = options["rotation"] || 0; + widget.setRotation(rt); + + var vb = options["visible"] || false; + if(vb != null){ widget.setVisible(vb); } widget.setLocalZOrder(options["ZOrder"]); var layout = options["layoutParameter"]; - if(layout){ + if(layout != null){ var layoutParameterDic = options["layoutParameter"]; var paramType = layoutParameterDic["type"]; var parameter = null; @@ -103,7 +113,7 @@ ccs.WidgetReader = { default: break; } - if(parameter){ + if(parameter != null){ var mgl = layoutParameterDic["marginLeft"]; var mgt = layoutParameterDic["marginTop"]; var mgr = layoutParameterDic["marginRight"]; @@ -116,19 +126,43 @@ ccs.WidgetReader = { }, setColorPropsFromJsonDictionary: function(widget, options){ var op = options["opacity"]; - if(op){ + if(op != null){ widget.setOpacity(op); } var colorR = options["colorR"] || 255; var colorG = options["colorG"] || 255; var colorB = options["colorB"] || 255; widget.setColor(cc.color(colorR, colorG, colorB)); - var apx = options["anchorPointX"]; - var apxf = apx || (widget.getWidgetType() === ccs.WidgetType ? 0.5 : 0); - var apy = options["anchorPointY"]; - var apyf = apy || (widget.getWidgetType() === ccs.WidgetType ? 0.5 : 0); - widget.setAnchorPoint(cc.p(apxf, apyf)); -// widget.setFlipX(options["flipX"]); -// widget.setFlipX(options["flipY"]); + + ccs.WidgetReader.setAnchorPointForWidget(widget, options); + + widget.setFlippedX(options["flipX"]); + widget.setFlippedY(options["flipY"]); + }, + setAnchorPointForWidget: function(widget, options){ + if(options.name === "Image6"){ + void 0; + } + var isAnchorPointXExists = options["anchorPointX"]; + var anchorPointXInFile; + if (isAnchorPointXExists != null) { + anchorPointXInFile = options["anchorPointX"]; + }else{ + anchorPointXInFile = widget.getAnchorPoint().x; + } + + var isAnchorPointYExists = options["anchorPointY"]; + var anchorPointYInFile; + if (isAnchorPointYExists != null) { + anchorPointYInFile = options["anchorPointY"]; + } + else{ + anchorPointYInFile = widget.getAnchorPoint().y; + } + + if (isAnchorPointXExists || isAnchorPointYExists) { + widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); + } + } }; \ No newline at end of file From 52090257a14dfb4536da1fe778a75bc5d7d25ee6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 24 Jul 2014 16:38:58 +0800 Subject: [PATCH 0336/1564] Issue #5704: Fix bug about UISlider --- extensions/ccui/uiwidgets/UISlider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index ecd8f074a0..ac48007c22 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -185,7 +185,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); var tz = this._progressBarRenderer.getContentSize(); -// this._progressBarTextureSize = {width: tz.width, height: tz.height}; + this._progressBarTextureSize = {width: tz.width, height: tz.height}; this._progressBarRendererDirty = true; }, From 6e8086b4504f1f0372dd67ff5d1beb51d5429ebf Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 24 Jul 2014 16:59:07 +0800 Subject: [PATCH 0337/1564] Fixed #5704: Fixed a bug of GUIReader --- extensions/cocostudio/reader/GUIReader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 3c5b7cc257..765c1d5271 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -1012,7 +1012,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ } else { - if(widget instanceof ccui.Layout) + if(!(widget instanceof ccui.Layout)) { if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { From 70ba205fdbcc776414cfa0eb781089272f39f274 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 24 Jul 2014 17:29:47 +0800 Subject: [PATCH 0338/1564] Issue #5704: Fix bug about UIText --- extensions/ccui/uiwidgets/UIText.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index c619a675d9..789800aab0 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -369,7 +369,25 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this.setTextHorizontalAlignment(uiLabel._labelRenderer.getHorizontalAlignment()); this.setTextVerticalAlignment(uiLabel._labelRenderer.getVerticalAlignment()); } + }, + + _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; } + }); var _p = ccui.Text.prototype; From f6a13545bf0f63bead36e511a8bd24dc0d6bbabc Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 24 Jul 2014 17:51:32 +0800 Subject: [PATCH 0339/1564] Fixed #5704: correct a mistake of ccui.TextField --- extensions/ccui/uiwidgets/UITextField.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 54d8e8cb36..c2b8586913 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -764,14 +764,14 @@ cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize); _p.fontName; cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName); /** @expose */ -_p._maxLengthEnabled; -cc.defineGetterSetter(_p, "_maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); +_p.maxLengthEnabled; +cc.defineGetterSetter(_p, "maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); /** @expose */ -_p._maxLength; -cc.defineGetterSetter(_p, "_maxLength", _p.getMaxLength, _p.setMaxLength); +_p.maxLength; +cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength); /** @expose */ -_p._passwordEnabled; -cc.defineGetterSetter(_p, "_passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); +_p.passwordEnabled; +cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); _p = null; From 9caaa875ee2cd2e8fc3a2f0b6ae137b1b52c2dbe Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 24 Jul 2014 18:58:20 +0800 Subject: [PATCH 0340/1564] Issue #5704: CCUIPreformance - Omission of function recovery --- extensions/ccui/uiwidgets/UITextField.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index c2b8586913..d621d16a00 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -727,6 +727,14 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ setTextVerticalAlignment: function(alignment){ this._textFieldRenderer.setVerticalAlignment(alignment); + }, + _setFont: function (font) { + this._textFieldRender._setFont(font); + this._textFieldRendererAdaptDirty = true; + }, + + _getFont: function () { + return this._textFieldRender._getFont(); } }); @@ -764,14 +772,14 @@ cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize); _p.fontName; cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName); /** @expose */ -_p.maxLengthEnabled; -cc.defineGetterSetter(_p, "maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); +_p._maxLengthEnabled; +cc.defineGetterSetter(_p, "_maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); /** @expose */ -_p.maxLength; -cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength); +_p._maxLength; +cc.defineGetterSetter(_p, "_maxLength", _p.getMaxLength, _p.setMaxLength); /** @expose */ -_p.passwordEnabled; -cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); +_p._passwordEnabled; +cc.defineGetterSetter(_p, "_passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); _p = null; From 7c6030265895786a925b2e78ef493d9c576b3bc7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 24 Jul 2014 18:58:21 +0800 Subject: [PATCH 0341/1564] Fixed #5704: fixed a bug of ccui.TextField --- extensions/ccui/uiwidgets/UITextField.js | 89 +++++++++--------------- 1 file changed, 34 insertions(+), 55 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index c2b8586913..4bf3a3a40e 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -55,51 +55,46 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ this._insertText = false; this._deleteBackward = false; }, + onEnter: function () { cc.TextFieldTTF.prototype.onEnter.call(this); cc.TextFieldTTF.prototype.setDelegate.call(this, this); }, + //CCTextFieldDelegate onTextFieldAttachWithIME: function (sender) { this.setAttachWithIME(true); return false; }, + onTextFieldInsertText: function (sender, text, len) { - if (len == 1 && text == "\n") { + if (len == 1 && text == "\n") return false; - } - this.setInsertText(true); - if (this._maxLengthEnabled) { - if (cc.TextFieldTTF.prototype.getCharCount.call(this) >= this._maxLength) { - return true; - } - } - return false; + this.setInsertText(true); + return (this._maxLengthEnabled) && (cc.TextFieldTTF.prototype.getCharCount.call(this) >= this._maxLength); }, + onTextFieldDeleteBackward: function (sender, delText, nLen) { this.setDeleteBackward(true); return false; }, + onTextFieldDetachWithIME: function (sender) { this.setDetachWithIME(true); return false; }, - insertText: function (text, len) { //todo need to delete + + insertText: function (text, len) { var input_text = text; - if (text != "\n") - { - if (this._maxLengthEnabled) - { + if (text != "\n"){ + if (this._maxLengthEnabled){ var text_count = this.getString().length; - if (text_count >= this._maxLength) - { + if (text_count >= this._maxLength){ // password if (this._passwordEnabled) - { this.setPasswordText(this.getString()); - } return; } } @@ -107,23 +102,15 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ cc.TextFieldTTF.prototype.insertText.call(this, input_text, len); // password - if (this._passwordEnabled) - { - if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) - { - this.setPasswordText(this.getString()); - } - } + if (this._passwordEnabled && cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) + this.setPasswordText(this.getString()); }, + deleteBackward: function () { cc.TextFieldTTF.prototype.deleteBackward.call(this); - if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0) { - // password - if (this._passwordEnabled) { - this.setPasswordText(this._inputText); - } - } + if (cc.TextFieldTTF.prototype.getCharCount.call(this) > 0 && this._passwordEnabled) + this.setPasswordText(this._inputText); }, openIME: function () { @@ -176,45 +163,47 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ var text_count = text.length; var max = text_count; - if (this._maxLengthEnabled) - { - if (text_count > this._maxLength) - { - max = this._maxLength; - } - } + if (this._maxLengthEnabled && text_count > this._maxLength) + max = this._maxLength; for (var i = 0; i < max; ++i) - { tempStr += this._passwordStyleText; - } cc.LabelTTF.prototype.setString.call(this, tempStr); }, + setAttachWithIME: function (attach) { this._attachWithIME = attach; }, + getAttachWithIME: function () { return this._attachWithIME; }, + setDetachWithIME: function (detach) { this._detachWithIME = detach; }, + getDetachWithIME: function () { return this._detachWithIME; }, + setInsertText: function (insert) { this._insertText = insert; }, + getInsertText: function () { return this._insertText; }, + setDeleteBackward: function (deleteBackward) { this._deleteBackward = deleteBackward; }, + getDeleteBackward: function () { return this._deleteBackward; }, + init: function () { if (ccui.Widget.prototype.init.call(this)) { this.setTouchEnabled(true); @@ -222,6 +211,7 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ } return false; }, + onDraw: function (sender) { return false; } @@ -230,9 +220,8 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { var ret = new ccui.UICCTextField(); if (ret && ret.initWithString("", fontName, fontSize)) { - if (placeholder) { + if (placeholder) ret.setPlaceHolder(placeholder); - } return ret; } return null; @@ -291,7 +280,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _initRenderer: function () { this._textFieldRenderer = ccui.UICCTextField.create("input words here", "Thonburi", 20); this.addProtectedChild(this._textFieldRenderer, ccui.TextField.RENDERER_ZORDER, -1); - }, /** @@ -307,13 +295,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._useTouchArea = enable; }, - _adaptRenderers: function(){ - if (this._textFieldRendererAdaptDirty) { - this.textfieldRendererScaleChangedWithSize(); - this._textFieldRendererAdaptDirty = false; - } - }, - hitTest: function(pt){ if (this._useTouchArea) { var nsp = this.convertToNodeSpace(pt); @@ -460,8 +441,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ onTouchBegan: function (touchPoint, unusedEvent) { var self = this; var pass = ccui.Widget.prototype.onTouchBegan.call(self, touchPoint, unusedEvent); - if (self._hit) - { + if (self._hit) { setTimeout(function(){ self._textFieldRenderer.attachWithIME(); }, 0); @@ -669,7 +649,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, _textfieldRendererScaleChangedWithSize: function () { - if (this._ignoreSize) + if (!this._ignoreSize) this._textFieldRenderer.setDimensions(this._contentSize); this._textFieldRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, @@ -718,7 +698,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, setTextAreaSize: function(size){ - this._textFieldRenderer.setDimensions(size); + this.setContentSize(size); }, setTextHorizontalAlignment: function(alignment){ @@ -737,7 +717,6 @@ ccui.TextField.create = function(placeholder, fontName, fontSize){ widget.setPlaceHolder(placeholder); widget.setFontName(fontName); widget.setFontSize(fontSize); - } return widget; } From ae29f98bcbb5395f1ce37253c02b33fc4a8a2c16 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 24 Jul 2014 19:04:19 +0800 Subject: [PATCH 0342/1564] Fixed #5704: correct some properties of ccui.TextField. --- extensions/ccui/uiwidgets/UITextField.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index b244649fd0..84d3235917 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -751,14 +751,14 @@ cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize); _p.fontName; cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName); /** @expose */ -_p._maxLengthEnabled; -cc.defineGetterSetter(_p, "_maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); +_p.maxLengthEnabled; +cc.defineGetterSetter(_p, "maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled); /** @expose */ -_p._maxLength; -cc.defineGetterSetter(_p, "_maxLength", _p.getMaxLength, _p.setMaxLength); +_p.maxLength; +cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength); /** @expose */ -_p._passwordEnabled; -cc.defineGetterSetter(_p, "_passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); +_p.passwordEnabled; +cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled); _p = null; From cf2c0cda794614341b0b377a7de4bfd7f3b89d0b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 25 Jul 2014 10:57:24 +0800 Subject: [PATCH 0343/1564] Issue #5704: CCUIPreformance - Fixed a problem about checkbox default value --- extensions/ccui/layouts/UILayoutManager.js | 10 +- .../CheckBoxReader/CheckBoxReader.js | 133 +++--------------- .../reader/widgetreader/WidgetReader.js | 19 +++ 3 files changed, 42 insertions(+), 120 deletions(-) diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index aaccb414ac..bdfc713b40 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -114,17 +114,9 @@ ccui.linearHorizontalLayoutManager = { } }; -var ooo = []; - ccui.relativeLayoutManager = { _unlayoutChildCount: 0, -// _widgetChildren: [], - get _widgetChildren(){ - return ooo; - }, - set _widgetChildren(a){ - ooo = a; - }, + _widgetChildren: [], _widget: null, _finalPositionX:0, _finalPositionY:0, diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index 456198dd87..290f5ed978 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -32,130 +32,41 @@ ccs.CheckBoxReader = { setPropsFromJsonDictionary: function(widget, options){ ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - - - var jsonPath = ccs.uiReader.getFilePath(); - + var checkBox = widget; - + + //load background image var backGroundDic = options["backGroundBoxData"]; var backGroundType = backGroundDic["resourceType"]; + var backGroundTexturePath = ccs.WidgetReader.getResourcePath(backGroundDic, "path", backGroundType); + checkBox.loadTextureBackGround(backGroundTexturePath, backGroundType); - var tp = jsonPath; - var backGroundFileName = backGroundDic["path"]; - switch (backGroundType) - { - case 0: - { - var backGroundFileName_tp = backGroundFileName ? - tp + backGroundFileName : - null; - checkBox.loadTextureBackGround(backGroundFileName_tp); - break; - } - case 1: - { - var backGroundFileName = backGroundDic["path"]; - checkBox.loadTextureBackGround(backGroundFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); - break; - } - default: - break; - } - + //load background selected image var backGroundSelectedDic = options["backGroundBoxSelectedData"]; var backGroundSelectedType = backGroundSelectedDic["resourceType"]; - var backGroundSelectedFileName = backGroundSelectedDic["path"]; - if(backGroundSelectedFileName === null){ - backGroundSelectedType = backGroundType; - backGroundSelectedFileName = backGroundFileName; - } + var backGroundSelectedTexturePath = ccs.WidgetReader.getResourcePath(backGroundSelectedDic, "path", backGroundSelectedType); + checkBox.loadTextureBackGroundSelected(backGroundSelectedTexturePath, backGroundSelectedType); - switch (backGroundSelectedType) - { - case 0: - { - var backGroundSelectedFileName_tp = backGroundSelectedFileName ? - tp + backGroundSelectedFileName : - null; - checkBox.loadTextureBackGroundSelected(backGroundSelectedFileName_tp); - break; - } - case 1: - { - checkBox.loadTextureBackGroundSelected(backGroundSelectedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); - break; - } - default: - break; - } - + //load frontCross image var frontCrossDic = options["frontCrossData"]; var frontCrossType = frontCrossDic["resourceType"]; - var frontCrossFileName = frontCrossDic["path"]; - switch (frontCrossType) - { - case 0: - { - var frontCrossFileName_tp = frontCrossFileName ? - tp + frontCrossFileName : - null; - checkBox.loadTextureFrontCross(frontCrossFileName_tp); - break; - } - case 1: - { - var frontCrossFileName = frontCrossDic["path"]; - checkBox.loadTextureFrontCross(frontCrossFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); - break; - } - default: - break; - } - + var frontCrossFileName = ccs.WidgetReader.getResourcePath(frontCrossDic, "path", frontCrossType); + checkBox.loadTextureFrontCross(frontCrossFileName, frontCrossType); + + //load backGroundBoxDisabledData var backGroundDisabledDic = options["backGroundBoxDisabledData"]; var backGroundDisabledType = backGroundDisabledDic["resourceType"]; - var backGroundDisabledFileName = backGroundDisabledDic["path"]; - switch (backGroundDisabledType) - { - case 0: - { - var backGroundDisabledFileName_tp = backGroundDisabledFileName ? - tp + backGroundDisabledFileName : - null; - checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); - break; - } - case 1: - { - var backGroundDisabledFileName = backGroundDisabledDic["path"]; - checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); - break; - } - default: - break; - } - + var backGroundDisabledFileName = ccs.WidgetReader.getResourcePath(backGroundDisabledDic, "path", backGroundDisabledType); + checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, backGroundDisabledType); + + ///load frontCrossDisabledData var frontCrossDisabledDic = options["frontCrossDisabledData"]; var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; - var frontCrossDisabledFileName = options["path"]; - switch (frontCrossDisabledType) - { - case 0: - { - var frontCrossDisabledFileName_tp = frontCrossDisabledFileName ? - tp + frontCrossDisabledFileName : - null; - checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); - break; - } - case 1: - { - checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); - break; - } - default: - break; + var frontCrossDisabledFileName = ccs.WidgetReader.getResourcePath(frontCrossDisabledDic, "path", frontCrossDisabledType); + checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); + + if (options["selectedState"]){ + checkBox.setSelectedState(options["selectedState"]); } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 6c34ab7f5e..8042ce1612 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -164,5 +164,24 @@ ccs.WidgetReader = { widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); } + }, + getResourcePath: function(dict, key, texType){ + var jsonPath = ccs.uiReader.getFilePath(); + var imageFileName = dict[key]; + var imageFileName_tp; + if (null != imageFileName) + { + if (texType == 0) { + imageFileName_tp = jsonPath + imageFileName; + } + else if(texType == 1){ + imageFileName_tp = imageFileName; + } + else{ + cc.assert(0, "invalid TextureResType!!!"); + } + } + return imageFileName_tp; + } }; \ No newline at end of file From 645e6c9777a31bc6ce4e23573794b9c024b94965 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 25 Jul 2014 11:28:07 +0800 Subject: [PATCH 0344/1564] Issue #5704: CCUIPreformance - Fixed a problem about UIImageView resource loading --- extensions/ccui/uiwidgets/UIImageView.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index a865a88d6b..5923ecc3d9 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -88,18 +88,18 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ imageRenderer.initWithFile(fileName); imageRenderer.setCapInsets(this._capInsets); }else{ - imageRenderer.setTexture(fileName); +// imageRenderer.setTexture(fileName); + imageRenderer.initWithFile(fileName); } -// imageRenderer.initWithFile(fileName); break; case ccui.Widget.PLIST_TEXTURE: if(this._scale9Enabled){ imageRenderer.initWithSpriteFrameName(fileName); imageRenderer.setCapInsets(this._capInsets); }else{ - imageRenderer.setSpriteFrame(fileName); +// imageRenderer.setSpriteFrame(fileName); + imageRenderer.initWithSpriteFrameName(fileName); } -// imageRenderer.initWithSpriteFrameName(fileName); break; default: break; From 48385fc2b3269fad938ba72b9f01a0a81f213ca8 Mon Sep 17 00:00:00 2001 From: mutoo Date: Fri, 25 Jul 2014 14:51:32 +0800 Subject: [PATCH 0345/1564] fix child armature lost _parentBone issue; --- extensions/cocostudio/armature/display/CCDisplayManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index b64874e1a4..0a98899941 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -291,6 +291,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ if (displayRenderNode) { if (displayRenderNode instanceof ccs.Armature) { this._bone.setChildArmature(displayRenderNode); + displayRenderNode.setParentBone(this._bone); }else if(displayRenderNode instanceof cc.ParticleSystem) { displayRenderNode.resetSystem(); } From 558cd18fa821bf411d9c5fa527737e3c1efada42 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 25 Jul 2014 15:36:07 +0800 Subject: [PATCH 0346/1564] Issue #5704: CCUIPreformance 1. update uiReader 2. The default value of CheckBoxReader 3. The default value of ScrollViewReader --- extensions/ccui/uiwidgets/UIImageView.js | 5 +- extensions/cocostudio/reader/GUIReader.js | 262 ++++++++++++++++-- .../CheckBoxReader/CheckBoxReader.js | 8 + .../ScrollViewReader/ScrollViewReader.js | 6 +- .../cocostudio/trigger/ObjectFactory.js | 6 +- 5 files changed, 252 insertions(+), 35 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 5923ecc3d9..74169ae009 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -74,7 +74,6 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexture: function (fileName, texType) { - //TODO: May cause the resource file must be pre loaded if (!fileName) { return; } @@ -88,7 +87,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ imageRenderer.initWithFile(fileName); imageRenderer.setCapInsets(this._capInsets); }else{ -// imageRenderer.setTexture(fileName); + //SetTexture cannot load resource imageRenderer.initWithFile(fileName); } break; @@ -97,7 +96,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ imageRenderer.initWithSpriteFrameName(fileName); imageRenderer.setCapInsets(this._capInsets); }else{ -// imageRenderer.setSpriteFrame(fileName); + //SetTexture cannot load resource imageRenderer.initWithSpriteFrameName(fileName); } break; diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 765c1d5271..079d129fb2 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -23,33 +23,38 @@ THE SOFTWARE. ****************************************************************************/ -new ccs.TInfo("ButtonReader", ccui.ButtonReader); -new ccs.TInfo("CheckBoxReader", ccui.CheckBoxReader); -new ccs.TInfo("SliderReader", ccui.SliderReader); -new ccs.TInfo("ImageViewReader", ccui.ImageViewReader); -new ccs.TInfo("LoadingBarReader", ccui.LoadingBarReader); -new ccs.TInfo("TextAtlasReader", ccui.TextAtlasReader); -new ccs.TInfo("TextReader", ccui.TextReader); -new ccs.TInfo("TextBMFontReader", ccui.TextBMFontReader); -new ccs.TInfo("TextFieldReader", ccui.TextFieldReader); -new ccs.TInfo("LayoutReader", ccui.LayoutReader); -new ccs.TInfo("PageViewReader", ccui.PageViewReader); -new ccs.TInfo("ScrollViewReader", ccui.ScrollViewReader); -new ccs.TInfo("ListViewReader", ccui.ListViewReader); - -new ccs.TInfo("Button", ccui.Button); -new ccs.TInfo("CheckBox", ccui.CheckBox); -new ccs.TInfo("ImageView", ccui.ImageView); -new ccs.TInfo("Text", ccui.Text); -new ccs.TInfo("TextAtlas", ccui.TextAtlas); -new ccs.TInfo("TextBMFont", ccui.TextBMFont); -new ccs.TInfo("LoadingBar", ccui.LoadingBar); -new ccs.TInfo("Slider", ccui.Slider); -new ccs.TInfo("TextField", ccui.TextField); -new ccs.TInfo("Layout", ccui.Layout); -new ccs.TInfo("ListView", ccui.ListView); -new ccs.TInfo("PageView", ccui.PageView); -new ccs.TInfo("ScrollView", ccui.ScrollView); +(function(){ + var factoryCreate = ccs.objectFactory; + + factoryCreate.registerType({_className:"ButtonReader", _fun: ccs.ButtonReader}); + factoryCreate.registerType({_className: "CheckBoxReader", _fun: ccs.CheckBoxReader}); + factoryCreate.registerType({_className: "SliderReader", _fun: ccs.SliderReader}); + factoryCreate.registerType({_className: "ImageViewReader", _fun: ccs.ImageViewReader}); + factoryCreate.registerType({_className: "LoadingBarReader", _fun: ccs.LoadingBarReader}); + factoryCreate.registerType({_className: "TextAtlasReader", _fun: ccs.LabelAtlasReader}); + factoryCreate.registerType({_className: "TextReader", _fun: ccs.LabelReader}); + factoryCreate.registerType({_className: "TextBMFontReader", _fun: ccs.LabelBMFontReader}); + factoryCreate.registerType({_className: "TextFieldReader", _fun: ccs.TextFieldReader}); + factoryCreate.registerType({_className: "LayoutReader", _fun: ccs.LayoutReader}); + factoryCreate.registerType({_className: "PageViewReader", _fun: ccs.PageViewReader}); + factoryCreate.registerType({_className: "ScrollViewReader", _fun: ccs.ScrollViewReader}); + factoryCreate.registerType({_className: "ListViewReader", _fun: ccs.ListViewReader}); + + factoryCreate.registerType({_className: "Button", _fun: ccui.Button}); + factoryCreate.registerType({_className: "CheckBox", _fun: ccui.CheckBox}); + factoryCreate.registerType({_className: "ImageView", _fun: ccui.ImageView}); + factoryCreate.registerType({_className: "Text", _fun: ccui.Text}); + factoryCreate.registerType({_className: "TextAtlas", _fun: ccui.TextAtlas}); + factoryCreate.registerType({_className: "TextBMFont", _fun: ccui.TextBMFont}); + factoryCreate.registerType({_className: "LoadingBar", _fun: ccui.LoadingBar}); + factoryCreate.registerType({_className: "Slider", _fun: ccui.Slider}); + factoryCreate.registerType({_className: "TextField", _fun: ccui.TextField}); + factoryCreate.registerType({_className: "Layout", _fun: ccui.Layout}); + factoryCreate.registerType({_className: "ListView", _fun: ccui.ListView}); + factoryCreate.registerType({_className: "PageView", _fun: ccui.PageView}); + factoryCreate.registerType({_className: "ScrollView", _fun: ccui.ScrollView}); + +})(); /** * Base object for ccs.uiReader @@ -197,6 +202,141 @@ ccs.WidgetPropertiesReader = ccs.Class.extend({ createWidget: function (jsonDict, fullPath, fileName) { }, widgetFromJsonDictionary: function (data) { + }, + createGUI: function(classname){ + var name = this.getGUIClassName(classname); + + var object = ccs.objectFactory.createObject(name); + + return object; + }, + getGUIClassName: function(name){ + var convertedClassName = name; + if (name == "Panel") + { + convertedClassName = "Layout"; + } + else if (name == "TextArea") + { + convertedClassName = "Text"; + } + else if (name == "TextButton") + { + convertedClassName = "Button"; + } + else if (name == "Label") + { + convertedClassName = "Text"; + } + else if (name == "LabelAtlas") + { + convertedClassName = "TextAtlas"; + } + else if (name == "LabelBMFont") + { + convertedClassName = "TextBMFont"; + } + + + return convertedClassName; + }, + getWidgetReaderClassName: function(classname){ + // create widget reader to parse properties of widget + var readerName = classname; + if (readerName == "Panel") + { + readerName = "Layout"; + } + else if (readerName == "TextArea") + { + readerName = "Text"; + } + else if (readerName == "TextButton") + { + readerName = "Button"; + } + else if (readerName == "Label") + { + readerName = "Text"; + } + else if (readerName == "LabelAtlas") + { + readerName = "TextAtlas"; + } + else if (readerName == "LabelBMFont") + { + readerName = "TextBMFont"; + } + readerName += "Reader"; + return readerName; + }, + getWidgetReaderClassNameFromWidget: function(widget){ + var readerName; + + // 1st., custom widget parse properties of parent widget with parent widget reader + if (widget instanceof ccui.Button) + { + readerName = "ButtonReader"; + } + else if (widget instanceof ccui.CheckBox) + { + readerName = "CheckBoxReader"; + } + else if (widget instanceof ccui.ImageView) + { + readerName = "ImageViewReader"; + } + else if (widget instanceof ccui.TextAtlas) + { + readerName = "TextAtlasReader"; + } + else if (widget instanceof ccui.TextBMFont) + { + readerName = "TextBMFontReader"; + } + else if (widget instanceof ccui.Text) + { + readerName = "TextReader"; + } + else if (widget instanceof ccui.LoadingBar) + { + readerName = "LoadingBarReader"; + } + else if (widget instanceof ccui.Slider) + { + readerName = "SliderReader"; + } + else if (widget instanceof ccui.TextField) + { + readerName = "TextFieldReader"; + } + else if (widget instanceof ccui.ListView) + { + readerName = "ListViewReader"; + } + else if (widget instanceof ccui.PageView) + { + readerName = "PageViewReader"; + } + else if (widget instanceof ccui.ScrollView) + { + readerName = "ScrollViewReader"; + } + + else if (widget instanceof ccui.Layout) + { + readerName = "LayoutReader"; + } + else if (widget instanceof ccui.Widget) + { + readerName = "WidgetReader"; + } + + return readerName; + }, + createWidgetReaderProtocol: function(classname){ + var object = ccs.objectFactory.createObject(classname); + return object; } }); ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ @@ -854,7 +994,70 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var classname = data["classname"]; var uiOptions = data["options"]; - var widget = ccs.objectFactory.createObject(classname); + var widget = this.createGUI(classname); + + var readerName = this.getWidgetReaderClassName(classname); + + var reader = this.createWidgetReaderProtocol(readerName); + + if (reader) + { + // widget parse with widget reader + this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); + } + else + { + readerName = this.getWidgetReaderClassNameFromWidget(widget); + + reader = ccs.objectFactory.createObject(readerName); + + if (reader && widget) { + this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); + + // 2nd., custom widget parse with custom reader + var customProperty = uiOptions["customProperty"]; + var customJsonDict = JSON.parse(customProperty); + this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); + }else{ + cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); + } + + } + + var childrenItem = data["children"]; + for(var i=0; i Date: Fri, 25 Jul 2014 16:43:09 +0800 Subject: [PATCH 0347/1564] Issue #5704: CCUIPreformance - Fixed a bug about customWidget --- extensions/cocostudio/reader/GUIReader.js | 186 +--------------------- moduleConfig.json | 6 +- 2 files changed, 8 insertions(+), 184 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 079d129fb2..d930e14b4e 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -39,6 +39,7 @@ factoryCreate.registerType({_className: "PageViewReader", _fun: ccs.PageViewReader}); factoryCreate.registerType({_className: "ScrollViewReader", _fun: ccs.ScrollViewReader}); factoryCreate.registerType({_className: "ListViewReader", _fun: ccs.ListViewReader}); + factoryCreate.registerType({_className: "WidgetReader", _fun: ccs.WidgetReader}); factoryCreate.registerType({_className: "Button", _fun: ccui.Button}); factoryCreate.registerType({_className: "CheckBox", _fun: ccui.CheckBox}); @@ -175,8 +176,6 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ var factoryCreate = ccs.objectFactory; var t = new ccs.TInfo(classType, ins); factoryCreate.registerType(t); - var t2 = new ccs.TInfo(classType + "Reader", object); - factoryCreate.registerType(t2); if(object){ this._mapObject[classType] = object; @@ -986,7 +985,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ if (object && selector) { - object.selector.call(this, classType, widget, customOptions); + selector(classType, widget, customOptions); } }, @@ -996,6 +995,9 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var uiOptions = data["options"]; var widget = this.createGUI(classname); + if(uiOptions.tag === 15){ + void 0; + } var readerName = this.getWidgetReaderClassName(classname); var reader = this.createWidgetReaderProtocol(readerName); @@ -1057,184 +1059,6 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ } } return widget; - - if(!widget){ - if (classname == "Button") { - widget = ccui.Button.create(); - } - else if (classname == "CheckBox") { - widget = ccui.CheckBox.create(); - } - else if (classname == "Label") { - widget = ccui.Text.create(); - } - else if (classname == "LabelAtlas") { - widget = ccui.TextAtlas.create(); - } - else if (classname == "LoadingBar") { - widget = ccui.LoadingBar.create(); - } else if (classname == "ScrollView") { - widget = ccui.ScrollView.create(); - } - else if (classname == "TextArea") { - widget = ccui.Text.create(); - } - else if (classname == "TextButton") { - widget = ccui.Button.create(); - } - else if (classname == "TextField") { - widget = ccui.TextField.create(); - } - else if (classname == "ImageView") { - widget = ccui.ImageView.create(); - } - else if (classname == "Panel") { - widget = ccui.Layout.create(); - } - else if (classname == "Slider") { - widget = ccui.Slider.create(); - } - else if (classname == "LabelBMFont") { - widget = ccui.TextBMFont.create(); - } - else if (classname == "DragPanel") { - widget = ccui.ScrollView.create(); - } - else if (classname == "ListView") { - widget = ccui.ListView.create(); - } - else if (classname == "PageView") { - widget = ccui.PageView.create(); - } - else if (classname == "Widget"){ - widget = ccui.Widget.create(); - } - } - - if(uiOptions.tag === 15){ - void 0; - } - - // create widget reader to parse properties of widget - var readerName = classname; - switch(readerName){ - case "Panel": - readerName = "Layout"; - break; - case "TextArea": - readerName = "Label"; - break; - case "TextButton": - readerName = "Button"; - break; - } - - readerName = readerName+"Reader"; - var reader = ccs.objectFactory.createWidgetReaderProtocol(readerName); - if(reader){ - // widget parse with widget reader - this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); - }else{ - // 1st., custom widget parse properties of parent widget with parent widget reader - - var render; - if(widget instanceof ccui.Button){ - render = ccs.ButtonReader; - }else if(widget instanceof ccui.CheckBox){ - render = ccs.CheckBoxReader; - }else if (widget instanceof ccui.ImageView) - { - render = ccs.ImageViewReader; - } - else if (widget instanceof ccui.TextAtlas) - { - render = ccs.LabelAtlasReader; - } - else if (widget instanceof ccui.LabelBMFont) - { - render = ccs.LabelBMFontReader; - } - else if (widget instanceof ccui.Text) - { - render = ccs.LabelReader; - } - else if (widget instanceof ccui.LoadingBar) - { - render = ccs.LoadingBarReader; - } - else if (widget instanceof ccui.Slider) - { - render = ccs.SliderReader; - } - else if (widget instanceof ccui.TextField) - { - render = ccs.TextFieldReader; - } - else if (widget instanceof ccui.ListView) - { - render = ccs.ListViewReader; - } - else if (widget instanceof ccui.ScrollView) - { - render = ccs.ScrollViewReader; - } - else if (widget instanceof ccui.PageView) - { - render = ccs.PageViewReader; - } - else if (widget instanceof ccui.Layout) - { - render = ccs.LayoutReader; - } - else if (widget instanceof ccui.Widget) - { - render = ccs.WidgetReader; - } - - this.setPropsForAllWidgetFromJsonDictionary(render, widget, uiOptions); - - // 2nd., custom widget parse with custom reader - var customProperty = uiOptions["customProperty"]; - var customJsonDict = uiOptions; - if (!uiOptions) - { - cc.log("GetParseError"); - } - this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); - } - var childrenItem = data["children"]; - for(var i=0; i Date: Fri, 25 Jul 2014 16:47:30 +0800 Subject: [PATCH 0348/1564] Issue #5704: CCUIPreformance - Remove the debugging code --- extensions/cocostudio/reader/GUIReader.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index d930e14b4e..befa209b96 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -995,9 +995,6 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var uiOptions = data["options"]; var widget = this.createGUI(classname); - if(uiOptions.tag === 15){ - void 0; - } var readerName = this.getWidgetReaderClassName(classname); var reader = this.createWidgetReaderProtocol(readerName); From be0ed0ce7116f08bd99a5a9d0c9a64317eed7d39 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 26 Jul 2014 15:02:24 +0800 Subject: [PATCH 0349/1564] Issue #5704: Fixed a bug about CCControlSwitch The Node element is added again --- .../gui/control-extension/CCControlSwitch.js | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js index 2b19590b8b..525053f31d 100644 --- a/extensions/gui/control-extension/CCControlSwitch.js +++ b/extensions/gui/control-extension/CCControlSwitch.js @@ -235,10 +235,13 @@ cc.ControlSwitchSprite = cc.Sprite.extend({ this._clipper.setAnchorPoint(0.5, 0.5); this._clipper.setPosition(maskSize.width / 2, maskSize.height / 2); this._clipper.setStencil(this._stencil); - this._backRT = cc.RenderTexture.create(maskSize.width, maskSize.height); - this._clipper.addChild(this._backRT.getSprite()); this.addChild(this._clipper); + this._clipper.addChild(onSprite); + this._clipper.addChild(offSprite); + this._clipper.addChild(onLabel); + this._clipper.addChild(offLabel); + this.addChild(this._thumbSprite); this.needsLayout(); @@ -248,35 +251,32 @@ cc.ControlSwitchSprite = cc.Sprite.extend({ }, needsLayout:function () { - this._onSprite.setPosition(this._onSprite.getContentSize().width / 2 + this._sliderXPosition, - this._onSprite.getContentSize().height / 2); - this._offSprite.setPosition(this._onSprite.getContentSize().width + this._offSprite.getContentSize().width / 2 + this._sliderXPosition, - this._offSprite.getContentSize().height / 2); + var maskSize = this._maskSize; + this._onSprite.setPosition( + this._onSprite.getContentSize().width / 2 + this._sliderXPosition - maskSize.width / 2, + this._onSprite.getContentSize().height / 2 - maskSize.height / 2 + ); + this._offSprite.setPosition( + this._onSprite.getContentSize().width + this._offSprite.getContentSize().width / 2 + this._sliderXPosition - maskSize.width / 2, + this._offSprite.getContentSize().height / 2 - maskSize.height / 2 + ); if (this._onLabel) { - this._onLabel.setPosition(this._onSprite.getPositionX() - this._thumbSprite.getContentSize().width / 6, - this._onSprite.getContentSize().height / 2); + this._onLabel.setPosition( + this._onSprite.getPositionX() - this._thumbSprite.getContentSize().width / 6, + this._onSprite.getContentSize().height / 2 - maskSize.height / 2 + ); } if (this._offLabel) { - this._offLabel.setPosition(this._offSprite.getPositionX() + this._thumbSprite.getContentSize().width / 6, - this._offSprite.getContentSize().height / 2); + this._offLabel.setPosition( + this._offSprite.getPositionX() + this._thumbSprite.getContentSize().width / 6, + this._offSprite.getContentSize().height / 2 - maskSize.height / 2 + ); } - this._thumbSprite.setPosition(this._onSprite.getContentSize().width + this._sliderXPosition, - this._maskSize.height / 2); - -// this._backRT.begin(); -// -// this._onSprite.visit(); -// this._offSprite.visit(); -// -// if (this._onLabel) -// this._onLabel.visit(); -// if (this._offLabel) -// this._offLabel.visit(); -// -// this._backRT.end(); - - //this.setFlippedY(true); + this._thumbSprite.setPosition( + this._onSprite.getContentSize().width + this._sliderXPosition, + this._maskSize.height / 2 + ); }, setSliderXPosition:function (sliderXPosition) { From ad04996e08de06eff7b47136780003620e62aacc Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 26 Jul 2014 16:03:56 +0800 Subject: [PATCH 0350/1564] Issue #5704: Recovery test code --- extensions/cocostudio/reader/widgetreader/WidgetReader.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 8042ce1612..f1f2118b38 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -140,9 +140,6 @@ ccs.WidgetReader = { widget.setFlippedY(options["flipY"]); }, setAnchorPointForWidget: function(widget, options){ - if(options.name === "Image6"){ - void 0; - } var isAnchorPointXExists = options["anchorPointX"]; var anchorPointXInFile; if (isAnchorPointXExists != null) { From 445e8e75889f4c530471b66ecb0c6ca2ae9cb8f7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 26 Jul 2014 16:50:49 +0800 Subject: [PATCH 0351/1564] Closed #5757: migrate -x Scale9Sprite to CH5 --- .../gui/control-extension/CCScale9Sprite.js | 147 ++++++++++-------- 1 file changed, 80 insertions(+), 67 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index a848169ee7..a211548b94 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -47,7 +47,6 @@ * @property {Number} insetBottom - The bottom inset of the 9-slice sprite */ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ - _spriteRect: null, _capInsetsInternal: null, _positionsAreDirty: false, @@ -63,7 +62,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ _bottom: null, _bottomRight: null, - _colorUnmodified: null, _opacityModifyRGB: false, _originalSize: null, @@ -141,8 +139,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var sizableWidth = size.width - locTopLeftContentSize.width - locTopRight.getContentSize().width; var sizableHeight = size.height - locTopLeftContentSize.height - locBottomRight.getContentSize().height; + var horizontalScale = sizableWidth / locCenterContentSize.width; var verticalScale = sizableHeight / locCenterContentSize.height; + + locCenter.setScaleX(horizontalScale); + locCenter.setScaleY(verticalScale); + var rescaledWidth = locCenterContentSize.width * horizontalScale; var rescaledHeight = locCenterContentSize.height * verticalScale; @@ -162,8 +165,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ verticalScale = rescaledHeight/locCenterContentSize.height; } } - locCenter.setScaleX(horizontalScale); - locCenter.setScaleY(verticalScale); var locLeft = this._left, locRight = this._right, locTop = this._top, locBottom = this._bottom; var tempAP = cc.p(0, 0); @@ -199,9 +200,9 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ /** * @constructor - * @param file - * @param rect - * @param capInsets + * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame + * @param {cc.Rect} rect + * @param {cc.Rect} capInsets * @returns {Scale9Sprite} */ ctor: function (file, rect, capInsets) { @@ -209,11 +210,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._spriteRect = cc.rect(0, 0, 0, 0); this._capInsetsInternal = cc.rect(0, 0, 0, 0); - this._colorUnmodified = cc.color(255, 255, 255, 255); this._originalSize = cc.size(0, 0); this._preferredSize = cc.size(0, 0); - this._color = cc.color(255, 255, 255, 255); - this._opacity = 255; this._capInsets = cc.rect(0, 0, 0, 0); this._loadedEventListeners = []; @@ -261,57 +259,56 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, /** Opacity: conforms to CCRGBAProtocol protocol */ - getOpacity: function () { - return this._opacity; - }, setOpacity: function (opacity) { - if(!this._scale9Image){ + if(!this._scale9Image) return; - } - this._opacity = opacity; + cc.Node.prototype.setOpacity.call(this, opacity); var scaleChildren = this._scale9Image.getChildren(); for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; if (selChild) selChild.setOpacity(opacity); } - this._color.a = opacity; }, updateDisplayedOpacity: function(parentOpacity){ + if(!this._scale9Image) + return; + cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); - this.setOpacity(this._displayedOpacity); + var scaleChildren = this._scale9Image.getChildren(); + for (var i = 0; i < scaleChildren.length; i++) { + var selChild = scaleChildren[i]; + if (selChild) + selChild.updateDisplayedOpacity(parentOpacity); + } }, /** Color: conforms to CCRGBAProtocol protocol */ - getColor: function () { - var locColor = this._color; - return cc.color(locColor.r, locColor.g, locColor.b, locColor.a); - }, setColor: function (color) { - if(!this._scale9Image){ + if(!this._scale9Image) return; - } - var locColor = this._color; - locColor.r = color.r; - locColor.g = color.g; - locColor.b = color.b; + cc.Node.prototype.setColor.call(this, color); var scaleChildren = this._scale9Image.getChildren(); for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; if (selChild) selChild.setColor(color); } - - if (color.a !== undefined && !color.a_undefined) { - this.setOpacity(color.a); - } }, updateDisplayedColor: function(parentColor){ + if(!this._scale9Image) + return; + cc.Node.prototype.updateDisplayedColor.call(this, parentColor); - this.setColor(this._displayedColor); + var scaleChildren = this._scale9Image.getChildren(); + for (var i = 0; i < scaleChildren.length; i++) { + var selChild = scaleChildren[i]; + if (selChild) + selChild.updateDisplayedColor(parentColor); + } }, getCapInsets: function () { @@ -319,9 +316,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, setCapInsets: function (capInsets) { - if(!this._scale9Image){ + if(!this._scale9Image) return; - } //backup the contentSize var contentSize = this._contentSize; var tempWidth = contentSize.width, tempHeight = contentSize.height; @@ -407,10 +403,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ cc.Node.prototype.setContentSize.call(this, size, height); this._positionsAreDirty = true; }, + _setWidth: function (value) { cc.Node.prototype._setWidth.call(this, value); this._positionsAreDirty = true; }, + _setHeight: function (value) { cc.Node.prototype._setHeight.call(this, value); this._positionsAreDirty = true; @@ -428,15 +426,24 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); }, + /** + * Initializes a 9-slice sprite with a SpriteBatchNode. + * @param {cc.SpriteBatchNode} batchNode + * @param {cc.Rect} rect + * @param {boolean|cc.Rect} rotated + * @param {cc.Rect} [capInsets] + * @returns {boolean} + */ initWithBatchNode: function (batchNode, rect, rotated, capInsets) { if (capInsets === undefined) { capInsets = rotated; rotated = false; } - if (batchNode) { + if (batchNode) this.updateWithBatchNode(batchNode, rect, rotated, capInsets); - } + this.setCascadeColorEnabled(true); + this.setCascadeOpacityEnabled(true); this.setAnchorPoint(0.5, 0.5); this._positionsAreDirty = true; return true; @@ -449,11 +456,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * to resize the sprite will all it's 9-slice goodness intact. * It respects the anchorPoint too. * - * @param file The name of the texture file. - * @param rect The rectangle that describes the sub-part of the texture that - * is the whole image. If the shape is the whole texture, set this to the - * texture's full rect. - * @param capInsets The values to use for the cap insets. + * @param {String} file The name of the texture file. + * @param {cc.Rect} rect The rectangle that describes the sub-part of the texture that + * is the whole image. If the shape is the whole texture, set this to the texture's full rect. + * @param {cc.Rect} capInsets The values to use for the cap insets. */ initWithFile: function (file, rect, capInsets) { if (file instanceof cc.Rect) { @@ -552,26 +558,24 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * cap insets of a sprite. In both cases, you get back a new image and the * original sprite remains untouched. * - * @param capInsets The values to use for the cap insets. + * @param {cc.Rect} capInsets The values to use for the cap insets. */ resizableSpriteWithCapInsets: function (capInsets) { var pReturn = new cc.Scale9Sprite(); - if (pReturn && pReturn.initWithBatchNode(this._scale9Image, this._spriteRect, false, capInsets)) { + if (pReturn && pReturn.initWithBatchNode(this._scale9Image, this._spriteRect, false, capInsets)) return pReturn; - } return null; }, /** sets the premultipliedAlphaOpacity property. If set to NO then opacity will be applied as: glColor(R,G,B,opacity); - If set to YES then oapcity will be applied as: glColor(opacity, opacity, opacity, opacity ); + If set to YES then opacity will be applied as: glColor(opacity, opacity, opacity, opacity ); Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO @since v0.8 */ setOpacityModifyRGB: function (value) { - if(!this._scale9Image){ + if(!this._scale9Image) return; - } this._opacityModifyRGB = value; var scaleChildren = this._scale9Image.getChildren(); if (scaleChildren) { @@ -587,6 +591,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ return this._opacityModifyRGB; }, + /** + * + * @param {cc.SpriteBatchNode} batchNode + * @param {cc.Rect} originalRect + * @param {boolean} rotated + * @param {cc.Rect} capInsets + * @returns {boolean} + */ updateWithBatchNode: function (batchNode, originalRect, rotated, capInsets) { var opacity = this.getOpacity(); var color = this.getColor(); @@ -595,9 +607,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Release old sprites this.removeAllChildren(true); - if (this._scale9Image != batchNode){ + if (this._scale9Image != batchNode) this._scale9Image = batchNode; - } + + if(!this._scale9Image) + return false; + var tmpTexture = batchNode.getTexture(); var locLoaded = tmpTexture.isLoaded(); this._textureLoaded = locLoaded; @@ -606,7 +621,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._positionsAreDirty = true; this._callLoadedEventCallbacks(); },this); - return; + return true; } var locScale9Image = this._scale9Image; locScale9Image.removeAllChildren(true); @@ -652,8 +667,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ locCapInsetsInternal.width = capInsets.width; locCapInsetsInternal.height = capInsets.height; } - var w = rect.width; - var h = rect.height; + var w = rect.width, h = rect.height; // If there is no specified center region if (cc._rectEqualToZero(locCapInsetsInternal)) { @@ -664,18 +678,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ locCapInsetsInternal.height = h / 3; } - var left_w = locCapInsetsInternal.x; - var center_w = locCapInsetsInternal.width; - var right_w = w - (left_w + center_w); + var left_w = locCapInsetsInternal.x, center_w = locCapInsetsInternal.width, right_w = w - (left_w + center_w); - var top_h = locCapInsetsInternal.y; - var center_h = locCapInsetsInternal.height; - var bottom_h = h - (top_h + center_h); + var top_h = locCapInsetsInternal.y, center_h = locCapInsetsInternal.height, bottom_h = h - (top_h + center_h); // calculate rects // ... top row - var x = 0.0; - var y = 0.0; + var x = 0.0, y = 0.0; // top left var lefttopbounds = cc.rect(x, y, left_w, top_h); @@ -881,20 +890,22 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT); } - this.setContentSize(rect); + this.setContentSize(rect.width, rect.height); this.addChild(locScale9Image); if (this._spritesGenerated) { // Restore color and opacity this.setOpacity(opacity); - if(color.r !== 255 || color.g !== 255 || color.b !== 255){ - this.setColor(color); - } + this.setColor(color); } this._spritesGenerated = true; return true; }, + /** + * set the sprite frame of cc.Scale9Sprite + * @param {cc.SpriteFrame} spriteFrame + */ setSpriteFrame: function (spriteFrame) { var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); // the texture is rotated on Canvas render mode, so isRotated always is false. @@ -948,8 +959,10 @@ _p = null; /** * Creates a 9-slice sprite with a texture file, a delimitation zone and * with the specified cap insets. - * - * @see initWithFile:rect:centerRegion: + * @param {String|cc.SpriteFrame} file file name of texture or a cc.Sprite object + * @param {cc.Rect} rect the rect of the texture + * @param {cc.Rect} capInsets the cap insets of cc.Scale9Sprite + * @returns {cc.Scale9Sprite} */ cc.Scale9Sprite.create = function (file, rect, capInsets) { return new cc.Scale9Sprite(file, rect, capInsets); From 4d3f8d744b4e1617346a4c2f3a30414142c370ff Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 26 Jul 2014 17:17:22 +0800 Subject: [PATCH 0352/1564] Fixed #5757: fixed a bug of cc.Scale9Sprite after migrated --- extensions/gui/control-extension/CCScale9Sprite.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index a211548b94..6293e167e5 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -143,9 +143,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var horizontalScale = sizableWidth / locCenterContentSize.width; var verticalScale = sizableHeight / locCenterContentSize.height; - locCenter.setScaleX(horizontalScale); - locCenter.setScaleY(verticalScale); - var rescaledWidth = locCenterContentSize.width * horizontalScale; var rescaledHeight = locCenterContentSize.height * verticalScale; @@ -166,6 +163,9 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } } + locCenter.setScaleX(horizontalScale); + locCenter.setScaleY(verticalScale); + var locLeft = this._left, locRight = this._right, locTop = this._top, locBottom = this._bottom; var tempAP = cc.p(0, 0); locBottomLeft.setAnchorPoint(tempAP); From c604e494eca6f7915602d8e3c4dd1a86e7294521 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 28 Jul 2014 11:31:30 +0800 Subject: [PATCH 0353/1564] Issue #2010: Repair the scaling failure and some parameters may be failure problem --- .../widgetreader/ButtonReader/ButtonReader.js | 21 ++++++------------- .../ImageViewReader/ImageViewReader.js | 8 ++----- .../LabelAtlasReader/LabelAtlasReader.js | 7 ++----- .../LabelBMFontReader/LabelBMFontReader.js | 7 +------ .../widgetreader/LabelReader/LabelReader.js | 17 ++++++--------- .../widgetreader/LayoutReader/LayoutReader.js | 5 +---- .../widgetreader/SliderReader/SliderReader.js | 2 +- .../reader/widgetreader/WidgetReader.js | 4 ++-- 8 files changed, 21 insertions(+), 50 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index ebab0d784e..b9d9f7d0fa 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -33,7 +33,6 @@ ccs.ButtonReader = { ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - var jsonPath = ccs.uiReader.getFilePath(); var button = widget; @@ -119,21 +118,15 @@ ccs.ButtonReader = { button.setCapInsets(cc.rect(cx, cy, cw, ch)); var sw = options["scale9Width"]; var sh = options["scale9Height"]; - if (sw && sh) + if (sw != null && sh != null) { - var swf = options["scale9Width"]; - var shf = options["scale9Height"]; - button.setSize(cc.size(swf, shf)); + button.setSize(cc.size(sw, sh)); } } - var tt = options["text"]; - if (tt) + var text = options["text"]; + if (text != null) { - var text = options["text"]; - if (text) - { - button.setTitleText(text); - } + button.setTitleText(text); } var cr = options["textColorR"]; @@ -145,7 +138,7 @@ ccs.ButtonReader = { button.setTitleColor(cc.color(cri,cgi,cbi)); var fs = options["fontSize"]; - if (fs) + if (fs != null) { button.setTitleFontSize(options["fontSize"]); } @@ -154,8 +147,6 @@ ccs.ButtonReader = { { button.setTitleFontName(options["fontName"]); } - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index d384d1e8d4..64bfbe994f 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -32,8 +32,7 @@ ccs.ImageViewReader = { setPropsFromJsonDictionary: function(widget, options){ ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - - + var jsonPath = ccs.uiReader.getFilePath(); var imageView = widget; @@ -71,8 +70,7 @@ ccs.ImageViewReader = { scale9Enable = options["scale9Enable"]; } imageView.setScale9Enabled(scale9Enable); - - + if (scale9Enable) { var sw = options["scale9Width"]; @@ -92,8 +90,6 @@ ccs.ImageViewReader = { imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); } - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 7da423934d..46cf7e28c9 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -32,8 +32,7 @@ ccs.LabelAtlasReader = { setPropsFromJsonDictionary: function(widget, options){ ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - - + var jsonPath = ccs.uiReader.getFilePath(); var labelAtlas = widget; @@ -42,7 +41,7 @@ ccs.LabelAtlasReader = { var iw = options["itemWidth"]; var ih = options["itemHeight"]; var scm = options["startCharMap"]; - if (sv && cmf && iw && ih && scm){ + if (sv != null && cmf && iw != null && ih != null && scm != null){ var cmftDic = options["charMapFileData"]; var cmfType = cmftDic["resourceType"]; switch (cmfType){ @@ -65,8 +64,6 @@ ccs.LabelAtlasReader = { break; } } - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index 32d9945d88..86c5531405 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -29,11 +29,8 @@ ccs.LabelBMFontReader = { }, setPropsFromJsonDictionary: function(widget, options){ - - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - - + var jsonPath = ccs.uiReader.getFilePath(); var labelBMFont = widget; @@ -59,8 +56,6 @@ ccs.LabelBMFontReader = { var text = options["text"]; labelBMFont.setString(text); - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index f3fbbfb13d..d036c701e4 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -32,44 +32,39 @@ ccs.LabelReader = { setPropsFromJsonDictionary: function(widget, options){ ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - - - var jsonPath = ccs.uiReader.getFilePath(); - + var label = widget; var touchScaleChangeAble = options["touchScaleEnable"]; label.setTouchScaleChangeEnabled(touchScaleChangeAble); var text = options["text"]; label.setString(text); var fs = options["fontSize"]; - if (fs) + if (fs != null) { label.setFontSize(options["fontSize"]); } var fn = options["fontName"]; - if (fn) + if (fn != null) { label.setFontName(options["fontName"]); } var aw = options["areaWidth"]; var ah = options["areaHeight"]; - if (aw && ah) + if (aw != null && ah != null) { var size = cc.size(options["areaWidth"], options["areaHeight"]); label.setTextAreaSize(size); } var ha = options["hAlignment"]; - if (ha) + if (ha != null) { label.setTextHorizontalAlignment(options["hAlignment"]); } var va = options["vAlignment"]; - if (va) + if (va != null) { label.setTextVerticalAlignment(options["vAlignment"]); } - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index eb2426ab39..71bfc73880 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -39,7 +39,7 @@ ccs.LayoutReader = { var w = 0, h = 0; var adaptScreen = options["adaptScreen"]; - if (adaptScreen){ + if (adaptScreen != null){ var screenSize = cc.director.getWinSize(); w = screenSize.width; h = screenSize.height; @@ -104,7 +104,6 @@ ccs.LayoutReader = { } } - if (backGroundScale9Enable) { var cx = options["capInsetsX"]; @@ -114,8 +113,6 @@ ccs.LayoutReader = { panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); } panel.setLayoutType(options["layoutType"]); - - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index 2ded592014..ca442b8bd3 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -48,7 +48,7 @@ ccs.SliderReader = { var imageFileName = imageFileNameDic["path"]; var imageFileName_tp; - if(bt){ + if(bt != null){ if(barTextureScale9Enable){ switch(imageFileType){ case 0: diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index f1f2118b38..f46272a6ab 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -71,7 +71,7 @@ ccs.WidgetReader = { widget.setPosition(cc.p(x, y)); - var sx = options["scalex"] || 1; + var sx = options["scaleX"] || 1; widget.setScaleX(sx); var sy = options["scaleY"] || 1; @@ -157,7 +157,7 @@ ccs.WidgetReader = { anchorPointYInFile = widget.getAnchorPoint().y; } - if (isAnchorPointXExists || isAnchorPointYExists) { + if (isAnchorPointXExists != null || isAnchorPointYExists != null) { widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); } From dcf29e61512595f36ff7d2e884e9cea92472d691 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 28 Jul 2014 15:04:08 +0800 Subject: [PATCH 0354/1564] Issue #5702: Parameter error --- extensions/cocostudio/armature/CCArmature.js | 2 +- extensions/cocostudio/armature/display/CCDisplayFactory.js | 2 +- extensions/cocostudio/armature/display/CCSkin.js | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index c2cd841849..d40f5dcb30 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -325,7 +325,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ locOffsetPoint.x = -rect.x; locOffsetPoint.y = -rect.y; if (rect.width != 0 && rect.height != 0) { - this.setAnchorPoint(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height); + this.setAnchorPoint(cc.p(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height)); } }, diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index a7cccc1ed5..327392f209 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -160,7 +160,7 @@ ccs.displayFactory = { var textureData = ccs.armatureDataManager.getTextureData(textureName); if (textureData) { //! Init display anchorPoint, every Texture have a anchor point - skin.setAnchorPoint(textureData.pivotX, textureData.pivotY); + skin.setAnchorPoint(cc.p(textureData.pivotX, textureData.pivotY)); } if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index a23e1bed46..49c378db4d 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -209,11 +209,10 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ getNodeToWorldTransformAR: function(){ var displayTransform = this._transform; - var anchorPoint = this._anchorPointInPoints; - anchorPoint = cc.pointApplyAffineTransform(anchorPoint, displayTransform); - displayTransform.tx = anchorPoint.x; - displayTransform.ty = anchorPoint.y; + this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); + displayTransform.tx = this._anchorPointInPoints.x; + displayTransform.ty = this._anchorPointInPoints.y; return cc.affineTransformConcat( displayTransform, From 8d34a7c11e3d8b99864102d8b0c9524b2d5abdc9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 28 Jul 2014 17:14:30 +0800 Subject: [PATCH 0355/1564] Fixed #2022: Newline character not properly applied in labels --- cocos2d/core/labelttf/CCLabelTTF.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 2177148422..f3068c305d 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -160,7 +160,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ var baseNb = Math.floor(text.length * width / tWidth); // Next line is a line with line break var nextlinebreak = text.indexOf('\n'); - if (baseNb * 0.8 >= nextlinebreak && nextlinebreak > 0) return nextlinebreak + 1; + if (baseNb * 0.8 >= nextlinebreak && nextlinebreak > -1) return nextlinebreak + 1; // Text width smaller than requested width if (tWidth < width) return text.length; From 00ba094c32171cbd774881605b26803ad8ddf2a8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Jul 2014 10:20:14 +0800 Subject: [PATCH 0356/1564] Issue #5702: update armature transform --- extensions/cocostudio/armature/CCArmature.js | 67 +++++++++++++++++++ .../cocostudio/armature/display/CCSkin.js | 14 ++-- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index d40f5dcb30..6d5978dd3b 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -239,6 +239,73 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.addChild(bone); }, + visit: function(){ + if(!this._visible){ + return; + } + this.sortAllChildren(); + this.draw(); + this._orderOfArrival = 0; + }, + + draw: function(renderer, transform, flags){ + if (this._parentBone == null && this._batchNode == null) + { +// CC_NODE_DRAW_SETUP(); + } + + + for (var i=0; i Date: Tue, 29 Jul 2014 15:00:13 +0800 Subject: [PATCH 0357/1564] Issue #5702: migrate cc.Armature from -x --- .../core/platform/CCTypesPropertyDefine.js | 27 + cocos2d/core/platform/CCTypesWebGL.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 575 +++++++----------- extensions/cocostudio/armature/CCBone.js | 4 +- .../armature/display/CCDisplayManager.js | 6 +- 5 files changed, 248 insertions(+), 366 deletions(-) diff --git a/cocos2d/core/platform/CCTypesPropertyDefine.js b/cocos2d/core/platform/CCTypesPropertyDefine.js index 0fc7d68bc2..2e4ceab91d 100644 --- a/cocos2d/core/platform/CCTypesPropertyDefine.js +++ b/cocos2d/core/platform/CCTypesPropertyDefine.js @@ -134,6 +134,33 @@ cc._tmp.PrototypeColor = function () { /** @expose */ _p.GRAY; cc.defineGetterSetter(_p, "GRAY", _p._getGray); + + _p = cc.BlendFunc; + _p._disable = function(){ + return new cc.BlendFunc(cc.ONE, cc.ZERO); + }; + _p._alphaPremultiplied = function(){ + return new cc.BlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); + }; + _p._alphaNonPremultiplied = function(){ + return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); + }; + _p._additive = function(){ + return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE); + }; + + /** @expose */ + _p.DISABLE; + cc.defineGetterSetter(_p, "DISABLE", _p._disable); + /** @expose */ + _p.ALPHA_PREMULTIPLIED; + cc.defineGetterSetter(_p, "ALPHA_PREMULTIPLIED", _p._alphaPremultiplied); + /** @expose */ + _p.ALPHA_NON_PREMULTIPLIED; + cc.defineGetterSetter(_p, "ALPHA_NON_PREMULTIPLIED", _p._alphaNonPremultiplied); + /** @expose */ + _p.ADDITIVE; + cc.defineGetterSetter(_p, "ADDITIVE", _p._additive); }; diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index e2bdf6b35b..1e0ded857e 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -545,4 +545,4 @@ cc._tmp.WebGLColor = function () { enumerable: true } }); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index c2cd841849..92d7ced8ef 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -41,7 +41,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ animation: null, armatureData: null, batchNode: null, - name: "", _textureAtlas: null, _parentBone: null, _boneDic: null, @@ -56,8 +55,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ _className: "Armature", _realAnchorPointInPoints: null, - nodeToParentTransform: null, - /** * Create a armature node. * Constructor of ccs.Armature @@ -68,21 +65,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ */ ctor: function (name, parentBone) { cc.Node.prototype.ctor.call(this); - this.animation = null; - this.armatureData = null; - this.batchNode = null; this.name = ""; - this._textureAtlas = null; - this._parentBone = null; - this._boneDic = null; - this._topBoneList = null; + this._topBoneList = []; this._armatureIndexDic = {}; this._offsetPoint = cc.p(0, 0); - this.version = 0; this._armatureTransformDirty = true; - this._body = null; - this._textureAtlasDic = null; - this._blendFunc = null; this._realAnchorPointInPoints = cc.p(0, 0); parentBone && ccs.Armature.prototype.init.call(this, name, parentBone); @@ -90,28 +77,23 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ /** * Initializes a CCArmature with the specified name and CCBone - * @param {String} name - * @param {ccs.Bone} parentBone + * @param {String} [name] + * @param {ccs.Bone} [parentBone] * @return {Boolean} */ init: function (name, parentBone) { cc.Node.prototype.init.call(this); - if (parentBone) { + if (parentBone) this._parentBone = parentBone; - } this.removeAllChildren(); this.animation = new ccs.ArmatureAnimation(); this.animation.init(this); this._boneDic = {}; - this._topBoneList = []; - - //this._textureAtlasDic = {}; + this._topBoneList.length = 0; this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; - this.name = name || ""; - var armatureDataManager = ccs.armatureDataManager; var animationData; @@ -124,7 +106,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ //armatureData var armatureData = armatureDataManager.getArmatureData(name); - cc.assert(armatureData, ""); + cc.assert(armatureData, "ArmatureData not exist!"); this.armatureData = armatureData; @@ -136,19 +118,13 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ //! init bone's Tween to 1st movement's 1st frame do { var movData = animationData.getMovement(animationData.movementNames[0]); - if (!movData) { - break; - } + if (!movData) break; var _movBoneData = movData.getMovementBoneData(bone.getName()); - if (!_movBoneData || _movBoneData.frameList.length <= 0) { - break; - } + if (!_movBoneData || _movBoneData.frameList.length <= 0) break; var frameData = _movBoneData.getFrameData(0); - if (!frameData) { - break; - } + if (!frameData) break; bone.getTweenData().copy(frameData); bone.changeDisplayWithIndex(frameData.displayIndex, false); @@ -170,9 +146,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.animation.setAnimationData(animationData); } - if (cc._renderType === cc._RENDER_TYPE_WEBGL) { + if (cc._renderType === cc._RENDER_TYPE_WEBGL) this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR)); - } this.setCascadeOpacityEnabled(true); this.setCascadeColorEnabled(true); @@ -180,21 +155,19 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * create a bone + * create a bone with name * @param {String} boneName * @return {ccs.Bone} */ createBone: function (boneName) { var existedBone = this.getBone(boneName); - if (existedBone) { + if (existedBone) return existedBone; - } var boneData = this.armatureData.getBoneData(boneName); var parentName = boneData.parentName; var bone = null; - if (parentName) { this.createBone(parentName); bone = ccs.Bone.create(boneName); @@ -206,50 +179,44 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ bone.setBoneData(boneData); bone.getDisplayManager().changeDisplayWithIndex(-1, false); - return bone; }, /** - * add a bone - * @param {ccs.Bone} bone - * @param {String} parentName + * Add a Bone to this Armature + * @param {ccs.Bone} bone The Bone you want to add to Armature + * @param {String} parentName The parent Bone's name you want to add to. If it's null, then set Armature to its parent */ addBone: function (bone, parentName) { - cc.assert(bone, "Argument must be non-nil"); + var locBoneDic = this._boneDic; if(bone.getName()) - cc.assert(!this._boneDic[bone.getName()], "bone already added. It can't be added again"); + cc.assert(!locBoneDic[bone.getName()], "bone already added. It can't be added again"); if (parentName) { - var boneParent = this._boneDic[parentName]; - if (boneParent) { + var boneParent = locBoneDic[parentName]; + if (boneParent) boneParent.addChildBone(bone); - } - else { + else this._topBoneList.push(bone); - } - } - else { + } else this._topBoneList.push(bone); - } bone.setArmature(this); - this._boneDic[bone.getName()] = bone; + locBoneDic[bone.getName()] = bone; this.addChild(bone); }, /** - * remove a bone - * @param {ccs.Bone} bone - * @param {Boolean} recursion + * Remove a bone with the specified name. If recursion it will also remove child Bone recursively. + * @param {ccs.Bone} bone The bone you want to remove + * @param {Boolean} recursion Determine whether remove the bone's child recursion. */ removeBone: function (bone, recursion) { cc.assert(bone, "bone must be added to the bone dictionary!"); bone.setArmature(null); bone.removeFromParent(recursion); - cc.arrayRemoveObject(this._topBoneList, bone); delete this._boneDic[bone.getName()]; @@ -257,8 +224,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * get a bone by name - * @param {String} name + * Gets a bone with the specified name + * @param {String} name The bone's name you want to get * @return {ccs.Bone} */ getBone: function (name) { @@ -267,17 +234,15 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ /** * Change a bone's parent with the specified parent name. - * @param {ccs.Bone} bone - * @param {String} parentName + * @param {ccs.Bone} bone The bone you want to change parent + * @param {String} parentName The new parent's name */ changeBoneParent: function (bone, parentName) { cc.assert(bone, "bone must be added to the bone dictionary!"); var parentBone = bone.getParentBone(); if (parentBone) { - - cc.arrayRemoveObject(parentBone.getChildrenBone(), bone); - + cc.arrayRemoveObject(parentBone.getChildren(), bone); bone.setParentBone(null); } @@ -286,15 +251,14 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (boneParent) { boneParent.addChildBone(bone); cc.arrayRemoveObject(this._topBoneList, bone); - } else { + } else this._topBoneList.push(bone); - } } }, /** * Get CCArmature's bone dictionary - * @return {Object} + * @return {Object} Armature's bone dictionary */ getBoneDic: function () { return this._boneDic; @@ -310,7 +274,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ getNodeToParentTransform: function(){ if (this._transformDirty) this._armatureTransformDirty = true; - return ccs.Node.prototype.nodeToParentTransform.call(this); }, @@ -324,23 +287,29 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var locOffsetPoint = this._offsetPoint; locOffsetPoint.x = -rect.x; locOffsetPoint.y = -rect.y; - if (rect.width != 0 && rect.height != 0) { + if (rect.width != 0 && rect.height != 0) this.setAnchorPoint(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height); - } }, - setAnchorPoint: function(point){ - if(point.x != this._anchorPoint.x || point.y != this._anchorPoint.y){ - this._anchorPoint.x = point.x; - this._anchorPoint.y = point.y; - this._anchorPointInPoints = cc.p( - this._contentSize.width * this._anchorPoint.x - this._offsetPoint.x, - this._contentSize.height * this._anchorPoint.y - this._offsetPoint.y - ); - this._realAnchorPointInPoints = cc.p( - this._contentSize.width * this._anchorPoint.x, - this._contentSize.height * this._anchorPoint.y - ); + setAnchorPoint: function(point, y){ + var ax, ay; + if(y !== undefined){ + ax = point; + ay = y; + }else{ + ax = point.x; + ay = point.y; + } + var locAnchorPoint = this._anchorPoint; + if(ax != locAnchorPoint.x || ay != locAnchorPoint.y){ + var contentSize = this._contentSize ; + locAnchorPoint.x = ax; + locAnchorPoint.y = ay; + this._anchorPointInPoints.x = contentSize.width * locAnchorPoint.x - this._offsetPoint.x; + this._anchorPointInPoints.y = contentSize.height * locAnchorPoint.y - this._offsetPoint.y; + + this._realAnchorPointInPoints.x = contentSize.width * locAnchorPoint.x; + this._realAnchorPointInPoints.x = contentSize.height * locAnchorPoint.y; this._transformDirty = this._inverseDirty = true; } }, @@ -350,7 +319,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * armatureAnimation setter + * Sets animation to this Armature * @param {ccs.ArmatureAnimation} animation */ setAnimation: function (animation) { @@ -358,7 +327,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * armatureAnimation getter + * Gets the animation of this Armature. * @return {ccs.ArmatureAnimation} */ getAnimation: function () { @@ -376,12 +345,58 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ update: function (dt) { this.animation.update(dt); var locTopBoneList = this._topBoneList; - for (var i = 0; i < locTopBoneList.length; i++) { + for (var i = 0; i < locTopBoneList.length; i++) locTopBoneList[i].update(dt); - } this._armatureTransformDirty = false; }, + draw: function(ctx){ + if (this._parentBone == null && this._batchNode == null) { + // CC_NODE_DRAW_SETUP(); + } + + var locChildren = this._children; + var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + switch (selBone.getDisplayRenderNodeType()) { + case ccs.DISPLAY_TYPE_SPRITE: + if(node instanceof ccs.Skin){ + node.updateTransform(); + + var func = selBone.getBlendFunc(); + if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + node.setBlendFunc(selBone.getBlendFunc()); + else { + if ((this._blendFunc.src == alphaPremultiplied.src && this._blendFunc.dst == alphaPremultiplied.dst) + && !node.getTexture().hasPremultipliedAlpha()) + node.setBlendFunc(alphaNonPremultipled); + else + node.setBlendFunc(this._blendFunc); + } + node.draw(ctx); + } + break; + case ccs.DISPLAY_TYPE_ARMATURE: + node.draw(ctx); + break; + default: + node.visit(ctx); + break; + } + } else if(node instanceof cc.Node) { + node.visit(ctx); + // CC_NODE_DRAW_SETUP(); + } + } + }, + onEnter: function () { cc.Node.prototype.onEnter.call(this); this.scheduleUpdate(); @@ -392,52 +407,93 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.unscheduleUpdate(); }, - getBoundingBox: function(){ - var minx, miny, maxx, maxy = 0; + vist: null, + + _visitForCanvas: function(ctx){ + var context = ctx || cc._renderContext; + // quick return if not visible. children won't be drawn. + if (!this._visible) + return; + + //TODO need test + context.save(); + this.transform(context); + + this.sortAllChildren(); + this.draw(ctx); + + // reset for next frame + this._cacheDirty = false; + this.arrivalOrder = 0; + + context.restore(); + }, + + _visitForWebGL: function(){ + // quick return if not visible. children won't be drawn. + if (!this._visible) + return; + + var context = cc._renderContext, i, currentStack = cc.current_stack; + //cc.kmGLPushMatrixWitMat4(_t._stackMatrix); + //optimize performance for javascript + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; + + this.transform(); //TODO + + this.sortAllChildren(); + this.draw(context); + + // reset for next frame + this.arrivalOrder = 0; + + //cc.kmGLPopMatrix(); + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); + }, + + /** + * This boundingBox will calculate all bones' boundingBox every time + * @returns {cc.Rect} + */ + getBoundingBox: function(){ + var minX, minY, maxX, maxY = 0; var first = true; - var boundingBox = cc.rect(0, 0, 0, 0); + var boundingBox = cc.rect(0, 0, 0, 0), locChildren = this._children; - var len = this._children.length; - for (var i=0; i boundingBox.x + boundingBox.width ? - r.x + r.width : - boundingBox.x + boundingBox.width; - maxy = r.y + r.height > boundingBox.y + boundingBox.height ? - r.y + r.height : - boundingBox.y + boundingBox.height; + } else { + minX = r.x < boundingBox.x ? r.x : boundingBox.x; + minY = r.y < boundingBox.y ? r.y : boundingBox.y; + maxX = r.x + r.width > boundingBox.x + boundingBox.width ? + r.x + r.width : boundingBox.x + boundingBox.width; + maxY = r.y + r.height > boundingBox.y + boundingBox.height ? + r.y + r.height : boundingBox.y + boundingBox.height; } - boundingBox.x = minx; - boundingBox.y = miny; - boundingBox.width = maxx - minx; - boundingBox.height = maxy - miny; + boundingBox.x = minX; + boundingBox.y = minY; + boundingBox.width = maxX - minX; + boundingBox.height = maxY - minY; } - } - return cc.rectApplyAffineTransform(boundingBox, this.getNodeToParentTransform()); }, @@ -448,26 +504,24 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * @returns {ccs.Bone} */ getBoneAtPoint: function (x, y) { - for (var i = this._children.length - 1; i >= 0; i--) { - var child = this._children[i]; - if (child instanceof ccs.Bone) { - if (child.getDisplayManager().containPoint(x, y)) { - return child; - } - } + var locChildren = this._children; + for (var i = locChildren.length - 1; i >= 0; i--) { + var child = locChildren[i]; + if (child instanceof ccs.Bone && child.getDisplayManager().containPoint(x, y)) + return child; } return null; }, /** - * parent bone setter + * Sets parent bone of this Armature * @param {ccs.Bone} parentBone */ setParentBone: function (parentBone) { this._parentBone = parentBone; - for (var key in this._boneDic) { - var bone = this._boneDic[key]; - bone.setArmature(this); + var locBoneDic = this._boneDic; + for (var key in locBoneDic) { + locBoneDic[key].setArmature(this); } }, @@ -483,20 +537,9 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * draw contour */ drawContour: function () { -// cc._drawingUtil.setDrawColor(255, 255, 255, 255); -// cc._drawingUtil.setLineWidth(1); -// for (var key in this._boneDic) { -// var bone = this._boneDic[key]; -// var bodyList = bone.getColliderBodyList(); -// for (var i = 0; i < bodyList.length; i++) { -// var body = bodyList[i]; -// var vertexList = body.getCalculatedVertexList(); -// cc._drawingUtil.drawPoly(vertexList, vertexList.length, true); -// } -// } - for(var i=0; i -0.000001) ? 0.000001 : lScaleX, -// sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; -// -// // Add offset point -// t.tx += Cos * this._offsetPoint.x * lScaleX + -Sin * this._offsetPoint.y * lScaleY; -// t.ty += Sin * this._offsetPoint.x * lScaleX + Cos * this._offsetPoint.y * lScaleY; -// -// // skew -// if (this._skewX || this._skewY) { -// // offset the anchorpoint -// var skx = Math.tan(-this._skewX * Math.PI / 180); -// var sky = Math.tan(-this._skewY * Math.PI / 180); -// var xx = appY * skx * sx; -// var yy = appX * sky * sy; -// t.a = Cos + -Sin * sky; -// t.c = Cos * skx + -Sin; -// t.b = Sin + Cos * sky; -// t.d = Sin * skx + Cos; -// t.tx += Cos * xx + -Sin * yy; -// t.ty += Sin * xx + Cos * yy; -// } -// -// // scale -// if (lScaleX !== 1 || lScaleY !== 1) { -// t.a *= sx; -// t.b *= sx; -// t.c *= sy; -// t.d *= sy; -// } -// -// // adjust anchorPoint -// t.tx += Cos * -appX * sx + -Sin * -appY * sy; -// t.ty += Sin * -appX * sx + Cos * -appY * sy; -// -// // if ignore anchorPoint -// if (this._ignoreAnchorPointForPosition) { -// t.tx += appX -// t.ty += appY; -// } -// -// if (this._additionalTransformDirty) { -// this._transform = cc.affineTransformConcat(this._transform, this._additionalTransform); -// this._additionalTransformDirty = false; -// } -// -// t.tx = t.tx | 0; -// t.ty = t.ty | 0; -// this._transformDirty = false; -// } -// return this._transform; -// }, -// -// /** -// * This boundingBox will calculate all bones' boundingBox every time -// * @return {cc.rect} -// */ -// boundingBox: function () { -// var minx = 0, miny = 0, maxx = 0, maxy = 0; -// var first = true; -// var boundingBox = cc.rect(0, 0, 0, 0); -// for (var i = 0; i < this._children.length; i++) { -// var bone = this._children[i]; -// if (bone instanceof ccs.Bone) { -// var r = bone.getDisplayManager().getBoundingBox(); -// if (first) { -// minx = cc.rectGetMinX(r); -// miny = cc.rectGetMinY(r); -// maxx = cc.rectGetMaxX(r); -// maxy = cc.rectGetMaxY(r); -// -// first = false; -// } -// else { -// minx = cc.rectGetMinX(r) < cc.rectGetMinX(boundingBox) ? cc.rectGetMinX(r) : cc.rectGetMinX(boundingBox); -// miny = cc.rectGetMinY(r) < cc.rectGetMinY(boundingBox) ? cc.rectGetMinY(r) : cc.rectGetMinY(boundingBox); -// maxx = cc.rectGetMaxX(r) > cc.rectGetMaxX(boundingBox) ? cc.rectGetMaxX(r) : cc.rectGetMaxX(boundingBox); -// maxy = cc.rectGetMaxY(r) > cc.rectGetMaxY(boundingBox) ? cc.rectGetMaxY(r) : cc.rectGetMaxY(boundingBox); -// } -// boundingBox = cc.rect(minx, miny, maxx - minx, maxy - miny); -// } -// } -// return cc.rectApplyAffineTransform(boundingBox, this.nodeToParentTransform()); -// }, -// -// getTexureAtlasWithTexture: function () { -// return null; -// }, -// getName: function () { -// return this.name; -// }, -// setName: function (name) { -// this.name = name; -// } - }); -//if (cc._renderType == cc._RENDER_TYPE_WEBGL) { -// //WebGL -// ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForWebGL; -//} else { -// //Canvas -// ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForCanvas; -//} +if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + //WebGL + ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForWebGL; + //ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForWebGL; +} else { + //Canvas + ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForCanvas; + //ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForCanvas; +} var _p = ccs.Armature.prototype; @@ -833,9 +688,9 @@ cc.defineGetterSetter(_p, "colliderFilter", null, _p.setColliderFilter); _p = null; /** - * allocates and initializes a armature. - * @param {String} name - * @param {ccs.Bone} parentBone + * Allocates an armature, and use the ArmatureData named name in ArmatureDataManager to initializes the armature. + * @param {String} [name] Bone name + * @param {ccs.Bone} [parentBone] the parent bone * @return {ccs.Armature} * @example * // example diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 4a9ccb1131..275cd487a1 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -414,10 +414,10 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ /** * zOrder setter - * @param {Number} + * @param {Number} zOrder */ setLocalZOrder: function (zOrder) { - if (this._zOrder != zOrder) + if (this._localZOrder != zOrder) cc.Node.prototype.setLocalZOrder.call(this, zOrder); }, diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 50a2dab2e2..252271d8c3 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -321,12 +321,12 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ * @returns {boolean} */ containPoint: function (point, y) { - if (y !== undefined) - point = cc.p(point, y); - if (!this._visible || this._displayIndex < 0) return false; + if (y !== undefined) + point = cc.p(point, y); + if(this._currentDecoDisplay.getDisplayData().displayType == ccs.DISPLAY_TYPE_SPRITE){ /* * First we first check if the point is in the sprite content rect. If false, then we continue to check From d0dca257fc81b8d85c412e05c10b3e80d7b6fe82 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Jul 2014 15:05:37 +0800 Subject: [PATCH 0358/1564] =?UTF-8?q?Issue=20#5702:=20update=20CCSkin?= =?UTF-8?q?=E3=80=81CCBone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/cocostudio/armature/CCArmature.js | 2 - extensions/cocostudio/armature/CCBone.js | 363 ++++++++---------- .../cocostudio/armature/display/CCSkin.js | 41 +- 3 files changed, 184 insertions(+), 222 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 6d5978dd3b..90b2c98841 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -56,8 +56,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ _className: "Armature", _realAnchorPointInPoints: null, - nodeToParentTransform: null, - /** * Create a armature node. * Constructor of ccs.Armature diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 8887ff4a5d..9a526c360d 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -47,13 +47,13 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ _boneData: null, _armature: null, _childArmature: null, - displayManager: null, + _displayManager: null, ignoreMovementBoneData: false, _tween: null, _tweenData: null, name: "", _childrenBone: null, - parentBone: null, + _parentBone: null, boneTransformDirty: false, _worldTransform: null, _blendFunc: 0, @@ -64,20 +64,26 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ _className: "Bone", ctor: function () { cc.Node.prototype.ctor.call(this); - this._boneData = null; + this._tweenData = null; + this._parentBone = null; this._armature = null; this._childArmature = null; - this.displayManager = null; - this.ignoreMovementBoneData = false; + this._boneData = null; this._tween = null; - this._tweenData = null; - this.name = ""; - this._childrenBone = []; - this.parentBone = null; - this.boneTransformDirty = true; + this._displayManager = null; + this.ignoreMovementBoneData = false; + this._worldTransform = cc.affineTransformMake(1, 0, 0, 1, 0, 0); + this.boneTransformDirty = true; this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); this.blendDirty = false; + this._worldInfo = null; + + this._armatureParentBone = null; + this._dataVersion = 0; + + this.name = ""; + this._childrenBone = []; }, /** @@ -95,8 +101,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._tween = new ccs.Tween(); this._tween.init(this); - this.displayManager = new ccs.DisplayManager(); - this.displayManager.init(this); + this._displayManager = new ccs.DisplayManager(); + this._displayManager.init(this); this._worldInfo = new ccs.BaseData(); this._boneData = new ccs.BaseData(); @@ -109,21 +115,16 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {ccs.BoneData} boneData */ setBoneData: function (boneData) { -// if (!boneData) { -// cc.log("boneData must not be null"); -// return; -// } cc.assert(boneData, "_boneData must not be null"); if(this._boneData != boneData){ this._boneData = boneData; } - this.name = this._boneData.name; - this.setLocalZOrder(this._boneData.zOrder); - this.bonetest = true; + this.name = this._boneData.name; + this._localZOrder = this._boneData.zOrder; - this.displayManager.initDisplayList(boneData); + this._displayManager.initDisplayList(boneData); }, /** @@ -161,71 +162,63 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * update worldTransform * @param dt */ - update: function (dt) { - var locParentBone = this.parentBone; - var locArmature = this._armature; - var locTweenData = this._tweenData; - var locWorldTransform = this._worldTransform; - var locWorldInfo = this._worldInfo; - var locArmatureParentBone = this._armatureParentBone; + update: function (delta) { - if (locParentBone) { - this.boneTransformDirty = this.boneTransformDirty || locParentBone.isTransformDirty(); - } - if (locArmatureParentBone && !this.boneTransformDirty) { - this.boneTransformDirty = locArmatureParentBone.isTransformDirty(); + if (this._parentBone) + this._boneTransformDirty = this._boneTransformDirty || this._parentBone.isTransformDirty(); + + if (this._armatureParentBone && !this._boneTransformDirty) + { + this._boneTransformDirty = this._armatureParentBone.isTransformDirty(); } - if (this.boneTransformDirty) { - if (this._dataVersion >= ccs.CONST_VERSION_COMBINED) { -// var locBoneData = this._boneData; -// locTweenData.x += locBoneData.x; -// locTweenData.y += locBoneData.y; -// locTweenData.skewX += locBoneData.skewX; -// locTweenData.skewY += locBoneData.skewY; -// locTweenData.scaleX += locBoneData.scaleX; -// locTweenData.scaleY += locBoneData.scaleY; + + if (this._boneTransformDirty) + { + if (this._dataVersion >= ccs.CONST_VERSION_COMBINED) + { ccs.TransformHelp.nodeConcat(this._tweenData, this._boneData); - locTweenData.scaleX -= 1; - locTweenData.scaleY -= 1; + this._tweenData.scaleX -= 1; + this._tweenData.scaleY -= 1; } - locWorldInfo.x = locTweenData.x + this._position.x; - locWorldInfo.y = locTweenData.y + this._position.y; - locWorldInfo.scaleX = locTweenData.scaleX * this._scaleX; - locWorldInfo.scaleY = locTweenData.scaleY * this._scaleY; - //_rotationZ_X - locWorldInfo.skewX = locTweenData.skewX + this._skewX + this._rotationX; - //_rotationZ_y - //_rotationZ_y - locWorldInfo.skewY = locTweenData.skewY + this._skewY - this._rotationY; - - if (this.parentBone) { - this.applyParentTransform(this.parentBone); + this._worldInfo.copy(this._tweenData); + + this._worldInfo.x = this._tweenData.x + this._position.x; + this._worldInfo.y = this._tweenData.y + this._position.y; + this._worldInfo.scaleX = this._tweenData.scaleX * this._scaleX; + this._worldInfo.scaleY = this._tweenData.scaleY * this._scaleY; + this._worldInfo.skewX = this._tweenData.skewX + this._skewX + this._rotationX; + this._worldInfo.skewY = this._tweenData.skewY + this._skewY - this._rotationY; + + if(this._parentBone) + { + this.applyParentTransform(this._parentBone); } - else { - if (locArmatureParentBone) { - this.applyParentTransform(locArmatureParentBone); + else + { + if (this._armatureParentBone) + { + this.applyParentTransform(this._armatureParentBone); } } - ccs.TransformHelp.nodeToMatrix(locWorldInfo, locWorldTransform); + ccs.TransformHelp.nodeToMatrix(this._worldInfo, this._worldTransform); - if (locArmatureParentBone) { - this._worldTransform = cc.affineTransformConcat(locWorldTransform, locArmature.nodeToParentTransform()); + if (this._armatureParentBone) + { + //TODO TransformConcat + this._worldTransform = cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToParentTransform()); } } - this._worldTransform = locWorldTransform; - this._tweenData = locTweenData; - this._worldInfo = locWorldInfo; - - ccs.displayFactory.updateDisplay(this, dt, this.boneTransformDirty || locArmature.getArmatureTransformDirty()); + ccs.displayFactory.updateDisplay(this, delta, this._boneTransformDirty || this._armature.getArmatureTransformDirty()); - var locChildrenBone = this._childrenBone; - for (var i = 0; i < locChildrenBone.length; i++) { - locChildrenBone[i].update(dt); + for(var i=0; i= 0.3) { + if (this._armature.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED) { var zorder = this._tweenData.zOrder + this._boneData.zOrder; this.setLocalZOrder(zorder); } @@ -306,14 +297,6 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {ccs.Bone} child */ addChildBone: function (child) { -// if (!child) { -// cc.log("Argument must be non-nil"); -// return; -// } -// if (child.parentBone) { -// cc.log("child already added. It can't be added again"); -// return; -// } cc.assert(child, "Argument must be non-nil"); cc.assert(!child.parentBone, "child already added. It can't be added again"); @@ -329,19 +312,6 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} recursion */ removeChildBone: function (bone, recursion) { -// for (var i = 0; i < this._childrenBone.length; i++) { -// if (this._childrenBone[i] == bone) { -// if (recursion) { -// var ccbones = bone._childrenBone; -// for (var j = 0; j < ccbones.length; j++) { -// bone.removeChildBone(ccbones[j], recursion); -// } -// } -// bone.setParentBone(null); -// bone.displayManager.setCurrentDecorativeDisplay(null); -// cc.arrayRemoveObject(this._childrenBone, bone); -// } -// } if (this._children.length > 0 && this._children.getIndex(bone) != -1 ) { if(recursion) @@ -369,8 +339,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} recursion */ removeFromParent: function (recursion) { - if (this.parentBone) { - this.parentBone.removeChildBone(this, recursion); + if (this._parentBone) { + this._parentBone.removeChildBone(this, recursion); } }, @@ -381,7 +351,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {ccs.Bone} parent the parent bone. */ setParentBone: function (parent) { - this.parentBone = parent; + this._parentBone = parent; }, getParentBone: function(){ @@ -431,6 +401,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, getNodeToWorldTransform: function(){ + //TODO TransformConcat return cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToWorldTransform()); }, @@ -439,7 +410,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @returns {cc.Node} */ getDisplayRenderNode: function () { - return this.displayManager.getDisplayRenderNode(); + return this._displayManager.getDisplayRenderNode(); }, /** @@ -447,7 +418,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @returns {Number} */ getDisplayRenderNodeType: function () { - return this.displayManager.getDisplayRenderNodeType(); + return this._displayManager.getDisplayRenderNodeType(); }, /** @@ -461,7 +432,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ */ addDisplay: function (displayData, index) { index = index || 0; - return this.displayManager.addDisplay(displayData, index); + return this._displayManager.addDisplay(displayData, index); }, /** @@ -469,7 +440,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Number} index */ removeDisplay: function (index) { - this.displayManager.removeDisplay(index); + this._displayManager.removeDisplay(index); }, /** @@ -492,7 +463,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} force */ changeDisplayWithIndex: function (index, force) { - this.displayManager.changeDisplayWithIndex(index, force); + this._displayManager.changeDisplayWithIndex(index, force); }, /** @@ -501,7 +472,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} force */ changeDisplayWithName: function (name, force) { - this.displayManager.changeDisplayWithName(name, force); + this._displayManager.changeDisplayWithName(name, force); }, getColliderDetector: function(){ @@ -523,7 +494,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {cc.ColliderFilter} filter */ setColliderFilter: function (filter) { - var displayList = this.displayManager.getDecorativeDisplayList(); + var displayList = this._displayManager.getDecorativeDisplayList(); for (var i = 0; i < displayList.length; i++) { var locDecoDisplay = displayList[i]; var locDetector = locDecoDisplay.getColliderDetector(); @@ -554,7 +525,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} */ setTransformDirty: function (dirty) { - this.boneTransformDirty = dirty; + this._boneTransformDirty = dirty; }, /** @@ -562,7 +533,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @return {Boolean} */ isTransformDirty: function () { - return this.boneTransformDirty; + return this._boneTransformDirty; }, /** @@ -570,7 +541,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @return {ccs.DisplayManager} */ getDisplayManager: function () { - return this.displayManager; + return this._displayManager; }, /** @@ -579,7 +550,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} bool */ setIgnoreMovementBoneData: function (bool) { - this.ignoreMovementBoneData = bool; + this._ignoreMovementBoneData = bool; }, isIgnoreMovementBoneData: function(){ @@ -595,11 +566,11 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, setBlendDirty: function (dirty) { - this.blendDirty = dirty; + this._blendDirty = dirty; }, isBlendDirty: function () { - return this.blendDirty; + return this._blendDirty; }, /** @@ -614,52 +585,52 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ return this._worldInfo; }, - /** - * release objects - */ - release: function () { - CC_SAFE_RELEASE(this._tweenData); - for (var i = 0; i < this._childrenBone.length; i++) { - CC_SAFE_RELEASE(this._childrenBone[i]); - } - this._childrenBone = []; - CC_SAFE_RELEASE(this._tween); - CC_SAFE_RELEASE(this.displayManager); - CC_SAFE_RELEASE(this._boneData); - CC_SAFE_RELEASE(this._childArmature); - }, - - /** - * Rewrite visit ,when node draw, g_NumberOfDraws is changeless - */ - visit: function (ctx) { - // quick return if not visible - if (!this._visible) - return; - - var node = this.getDisplayManager().getDisplayRenderNode(); - if (node) { - node.visit(ctx); - } - }, - - /** - * set display color - * @param {cc.Color} color - */ - setColor: function (color) { - cc.Node.prototype.setColor.call(this, color); - this.updateColor(); - }, - - /** - * set display opacity - * @param {Number} opacity 0-255 - */ - setOpacity: function (opacity) { - cc.Node.prototype.setOpacity.call(this, opacity); - this.updateColor(); - }, +// /** +// * release objects +// */ +// release: function () { +// CC_SAFE_RELEASE(this._tweenData); +// for (var i = 0; i < this._childrenBone.length; i++) { +// CC_SAFE_RELEASE(this._childrenBone[i]); +// } +// this._childrenBone = []; +// CC_SAFE_RELEASE(this._tween); +// CC_SAFE_RELEASE(this.displayManager); +// CC_SAFE_RELEASE(this._boneData); +// CC_SAFE_RELEASE(this._childArmature); +// }, +// +// /** +// * Rewrite visit ,when node draw, g_NumberOfDraws is changeless +// */ +// visit: function (ctx) { +// // quick return if not visible +// if (!this._visible) +// return; +// +// var node = this.getDisplayManager().getDisplayRenderNode(); +// if (node) { +// node.visit(ctx); +// } +// }, +// +// /** +// * set display color +// * @param {cc.Color} color +// */ +// setColor: function (color) { +// cc.Node.prototype.setColor.call(this, color); +// this.updateColor(); +// }, +// +// /** +// * set display opacity +// * @param {Number} opacity 0-255 +// */ +// setOpacity: function (opacity) { +// cc.Node.prototype.setOpacity.call(this, opacity); +// this.updateColor(); +// }, /** * child bone getter @@ -670,55 +641,57 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** + * @deprecated * return world transform * @return {{a:0.b:0,c:0,d:0,tx:0,ty:0}} */ nodeToArmatureTransform: function () { - return this._worldTransform; + return this.getNodeToArmatureTransform(); }, /** + * @deprecated * Returns the world affine transform matrix. The matrix is in Pixels. * @returns {cc.AffineTransform} */ nodeToWorldTransform: function () { - return cc.affineTransformConcat(this._worldTransform, this._armature.nodeToWorldTransform()); - }, - - addSkin: function (skin, index) { - index = index || 0; - return this.displayManager.addSkin(skin, index); - }, - - /** - * get the collider body list in this bone. - * @returns {*} - */ - getColliderBodyList: function () { - var decoDisplay = this.displayManager.getCurrentDecorativeDisplay() - if (decoDisplay) { - var detector = decoDisplay.getColliderDetector() - if (detector) { - return detector.getColliderBodyList(); - } - } - return []; - }, + return this.getNodeToWorldTransform(); + }, + +// addSkin: function (skin, index) { +// index = index || 0; +// return this.displayManager.addSkin(skin, index); +// }, + +// /** +// * get the collider body list in this bone. +// * @returns {*} +// */ +// getColliderBodyList: function () { +// var decoDisplay = this.displayManager.getCurrentDecorativeDisplay() +// if (decoDisplay) { +// var detector = decoDisplay.getColliderDetector() +// if (detector) { +// return detector.getColliderBodyList(); +// } +// } +// return []; +// }, - /** - * displayManager setter - * @param {ccs.DisplayManager} - */ - setDisplayManager: function (displayManager) { - this.displayManager = displayManager; - }, +// /** +// * displayManager setter +// * @param {ccs.DisplayManager} +// */ +// setDisplayManager: function (displayManager) { +// this.displayManager = displayManager; +// }, /** * ignoreMovementBoneData getter * @return {Boolean} */ getIgnoreMovementBoneData: function () { - return this.ignoreMovementBoneData; + return this.isIgnoreMovementBoneData(); }, /** diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 336051a23a..f4fb97dc6c 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -55,7 +55,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return false; var pFrame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); - this._displayName = spriteFrameName; var ret = true; if(pFrame){ this.initWithSpriteFrame(pFrame); @@ -84,17 +83,10 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this.setRotationY(cc.radiansToDegrees(-skinData.skewY)); this.setPosition(skinData.x, skinData.y); -// var localTransform = this.nodeToParentTransform(); -// var skinTransform = this._skinTransform; -// skinTransform.a = localTransform.a; -// skinTransform.b = localTransform.b; -// skinTransform.c = localTransform.c; -// skinTransform.d = localTransform.d; -// skinTransform.tx = localTransform.tx; -// skinTransform.ty = localTransform.ty; - - //this.getNodeToParentTransform - this._skinTransform = this.nodeToParentTransform(); + this._skinTransform = this.getNodeToParentTransform ? + this.getNodeToParentTransform() : + this.nodeToParentTransform(); + this.updateArmatureTransform(); }, @@ -103,18 +95,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, updateArmatureTransform: function () { - this._transform = cc.affineTransformConcat(this.bone.getNodeToArmatureTransform(), this._skinTransform); -// var locTransform = this._transform; -// var locArmature = this._armature; -// if (locArmature && locArmature.getBatchNode()) { -// this._transform = cc.affineTransformConcat(locTransform, locArmature.nodeToParentTransform()); -// } -// if (cc._renderType === cc._RENDER_TYPE_CANVAS) { -// locTransform = this._transform; -// locTransform.b *= -1; -// locTransform.c *= -1; -// locTransform.b = [locTransform.c, locTransform.c = locTransform.b][0]; -// } + //TODO cc.TransformConcat + this._transform = cc.affineTransformConcat( + this.bone.getNodeToArmatureTransform(), + this._skinTransform + ); }, updateTransform: function(){ @@ -128,7 +113,9 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ // // calculate the Quad based on the Affine Matrix // - var transform = this.nodeToParentTransform(); + var transform = this.getNodeToParentTransform ? + this.getNodeToParentTransform() : + this.nodeToParentTransform(); var size = this._rect; @@ -157,6 +144,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var dx = x1 * cr - y2 * sr2 + x; var dy = x1 * sr + y2 * cr2 + y; + //TODO _positionZ this.SET_VERTEX3F( this._quad.bl.vertices, this.RENDER_IN_SUBPIXEL(ax), @@ -201,6 +189,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, getNodeToWorldTransform: function(){ + //TODO cc.TransformConcat return cc.affineTransformConcat( this._bone.getArmature().getNodeToWorldTransform(), this._transform @@ -210,10 +199,12 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ getNodeToWorldTransformAR: function(){ var displayTransform = this._transform; + //TODO cc.PointApplyTransform this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); displayTransform.tx = this._anchorPointInPoints.x; displayTransform.ty = this._anchorPointInPoints.y; + //TODO cc.TransformConcat return cc.affineTransformConcat( displayTransform, this.bone.getArmature().nodeToWorldTransform() From b73b16ab568f6277431fe1ae17915ded0bdcf0f2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Jul 2014 15:22:36 +0800 Subject: [PATCH 0359/1564] Issue #5702: Fixed a bug about cc.color.WHITE is not define --- cocos2d/core/platform/CCTypesPropertyDefine.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/platform/CCTypesPropertyDefine.js b/cocos2d/core/platform/CCTypesPropertyDefine.js index 2e4ceab91d..6e9e032871 100644 --- a/cocos2d/core/platform/CCTypesPropertyDefine.js +++ b/cocos2d/core/platform/CCTypesPropertyDefine.js @@ -135,17 +135,16 @@ cc._tmp.PrototypeColor = function () { _p.GRAY; cc.defineGetterSetter(_p, "GRAY", _p._getGray); - _p = cc.BlendFunc; - _p._disable = function(){ + cc.BlendFunc._disable = function(){ return new cc.BlendFunc(cc.ONE, cc.ZERO); }; - _p._alphaPremultiplied = function(){ + cc.BlendFunc._alphaPremultiplied = function(){ return new cc.BlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); }; - _p._alphaNonPremultiplied = function(){ + cc.BlendFunc._alphaNonPremultiplied = function(){ return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); }; - _p._additive = function(){ + cc.BlendFunc._additive = function(){ return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE); }; From fee3f9f2953ba6a6cd0096384e463a7a4ab5b209 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Jul 2014 17:46:18 +0800 Subject: [PATCH 0360/1564] Issue #5702: update CCTween and CCArmatureAnimation --- .../armature/animation/CCArmatureAnimation.js | 225 ++++++++---------- .../cocostudio/armature/animation/CCTween.js | 39 ++- 2 files changed, 121 insertions(+), 143 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index f09fbbd516..362cde0a56 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -87,45 +87,48 @@ ccs.FrameEvent = function () { * */ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# */{ - animationData: null, + _animationData: null, _movementData: null, _armature: null, _movementID: "", - _prevFrameIndex: 0, _toIndex: 0, _tweenList: null, - _frameEvent: null, - _movementEvent: null, _speedScale: 1, - ignoreFrameEvent: false, + _ignoreFrameEvent: false, _frameEventQueue: null, _movementEventQueue: null, - userObject: null, _movementList: null, _onMovementList: false, _movementListLoop: false, _movementIndex: 0, _movementEventListener: null, + _movementListDurationTo: -1, + _movementEventCallFunc: null, + ctor: function () { ccs.ProcessBase.prototype.ctor.call(this); - this.animationData = null; + + this._animationData = null; + this._speedScale = 1; this._movementData = null; - this._movementID = ""; this._armature = null; - this._prevFrameIndex = 0; + this._movementID = ""; this._toIndex = 0; - this._tweenList = []; - this._frameEvent = null; - this._movementEvent = null; - this._speedScale = 1; - this.ignoreFrameEvent = false; - this._frameEventQueue = []; - this._movementEventQueue = []; - this.userObject = null; + this._ignoreFrameEvent = false; this._movementList = []; - this._onMovementList = false; this._movementListLoop = false; - this._movementIndex = 0; + this._movementListDurationTo = -1; + + this._movementEventCallFunc = null; + this._frameEventCallFunc = null; + this._movementEventTarget = null; + this._frameEventTarget = null; + + this._movementEventListener = null; + this._frameEventListener = null; + + this._frameEventQueue = []; + this._movementEventQueue = []; }, /** @@ -210,9 +213,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * armature.getAnimation().play("run",-1,0);//not loop play */ play: function (animationName, durationTo, loop) { - cc.assert(this.animationData, "this.animationData can not be null"); + cc.assert(this._animationData, "this.animationData can not be null"); - this._movementData = this.animationData.getMovement(animationName); + this._movementData = this._animationData.getMovement(animationName); cc.assert(this._movementData, "this._movementData can not be null"); //! Get key frame count @@ -300,7 +303,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# */ playByIndex: function (animationIndex, durationTo, durationTween, loop, tweenEasing) { cc.log("playByIndex is deprecated. Use playWithIndex instead."); - this.playWithIndex(animationIndex, durationTo, durationTween, loop, tweenEasing); + this.playWithIndex(animationIndex, durationTo, loop); }, /** @@ -310,19 +313,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Number} loop */ playWithIndex: function (animationIndex, durationTo, loop) { -// if (typeof durationTo == "undefined") { -// durationTo = -1; -// } -// if (typeof loop == "undefined") { -// loop = -1; -// } -// var moveNames = this.animationData.movementNames; -// if (animationIndex < -1 || animationIndex >= moveNames.length) { -// return; -// } -// var animationName = moveNames[animationIndex]; -// this.play(animationName, durationTo, loop, 0); - var movName = this.animationData.movementNames; + var movName = this._animationData.movementNames; cc.assert((animationIndex > -1) && (animationIndex < movName.length)); var animationName = movName[animationIndex]; @@ -341,12 +332,8 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._onMovementList = true; this._movementIndex = 0; -// for (var i = 0; i < movementNames.length; i++) { -// this._movementList.push({name: movementNames[i], durationTo: durationTo}); -// } this._movementList = movementNames; - this.updateMovementList(); }, @@ -359,14 +346,14 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# playWithIndexes: function (movementIndexes, durationTo, loop) { this._movementList = []; this._movementListLoop = loop; + this._movementListDurationTo = durationTo; this._onMovementList = true; this._movementIndex = 0; - var movName = this.animationData.movementNames; + var movName = this._animationData.movementNames; for (var i = 0; i < movementIndexes.length; i++) { var name = movName[movementIndexes[i]]; -// this._movementList.push({name: name, durationTo: durationTo}); this._movementList.push(name); } @@ -390,8 +377,8 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# return; } - var ignoreFrameEvent = this.ignoreFrameEvent; - this.ignoreFrameEvent = true; + var ignoreFrameEvent = this._ignoreFrameEvent; + this._ignoreFrameEvent = true; this._isPlaying = true; this._isComplete = this._isPause = false; @@ -404,7 +391,16 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# tween.gotoAndPlay(frameIndex); } this._armature.update(0); - this.ignoreFrameEvent = ignoreFrameEvent; + this._ignoreFrameEvent = ignoreFrameEvent; + }, + + /** + * Go to specified frame and pause current movement. + * @param {Number} frameIndex + */ + gotoAndPause: function (frameIndex) { + this.gotoAndPlay(frameIndex); + this.pause(); }, /** @@ -412,16 +408,12 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @return {Number} */ getMovementCount: function () { - return this.animationData.getMovementCount(); + return this._animationData.getMovementCount(); }, update: function (dt) { ccs.ProcessBase.prototype.update.call(this, dt); -// if (ccs.ProcessBase.prototype.update.call(this, dt)) { -// for (var i = 0; i < this._tweenList.length; i++) { -// this._tweenList[i].update(dt); -// } -// } + for (var i = 0; i < this._tweenList.length; i++) { this._tweenList[i].update(dt); } @@ -433,13 +425,11 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# var frameEvents = this._frameEventQueue; while (frameEvents.length > 0) { -// var frameEvent = frameEvents.shift(); - var event = frameEvents.pop(); + var event = frameEvents.shift(); - this.ignoreFrameEvent = true; + this._ignoreFrameEvent = true; if(this._frameEventTarget){ -// (_frameEventTarget->*_frameEventCallFunc)(event->bone, event->frameEventName, event->originFrameIndex, event->currentFrameIndex); this._frameEventTarget._frameEventCallFunc(event.bone, event.frameEventName, event.originFrameIndex, event.currentFrameIndex); } @@ -447,19 +437,15 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._frameEventListener(event.bone, event.frameEventName, event.originFrameIndex, event.currentFrameIndex); } -// this.callFrameEvent([frameEvent.bone, frameEvent.frameEventName, frameEvent.originFrameIndex, frameEvent.currentFrameIndex]); - this.ignoreFrameEvent = false; + this._ignoreFrameEvent = false; } var movementEvents = this._movementEventQueue; while (movementEvents.length > 0) { -// var movEvent = movementEvents.shift(); - var event = movementEvents.front(); - movementEvents.pop(); + var event = movementEvents.shift(); if(this._movementEventTarget) { -// (_movementEventTarget->*_movementEventCallFunc)(event->armature, event->movementType, event->movementID); this._movementEventTarget._movementEventCallFunc(event.armature, event.movementType, event.movementID); } @@ -467,7 +453,6 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# { this._movementEventListener(event.armature, event.movementType, event.movementID); } -// this.callMovementEvent([movEvent.armature, movEvent.movementType, movEvent.movementID]); } }, @@ -492,7 +477,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# locCurrentPercent = 1; this._isComplete = true; this._isPlaying = false; + this.movementEvent(this._armature, ccs.MovementEventType.complete, this._movementID); + this.updateMovementList(); break; case ccs.ANIMATION_TYPE_TO_LOOP_FRONT: @@ -500,12 +487,14 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# locCurrentPercent = ccs.fmodf(locCurrentPercent, 1); this._currentFrame = this._nextFrameIndex == 0 ? 0 : ccs.fmodf(this._currentFrame, this._nextFrameIndex); this._nextFrameIndex = this._durationTween > 0 ? this._durationTween : 1; + this.movementEvent(this, ccs.MovementEventType.start, this._movementID); break; default: //locCurrentPercent = ccs.fmodf(locCurrentPercent, 1); this._currentFrame = ccs.fmodf(this._currentFrame, this._nextFrameIndex); this._toIndex = 0; + this.movementEvent(this._armature, ccs.MovementEventType.loopComplete, this._movementID); break; } @@ -528,13 +517,13 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Object} target * @param {function} callFunc */ - setMovementEventCallFunc: function (target, callFunc, listener) { -// this._movementEvent = new ccs.AnimationEvent(target, callFunc); - this._movementEventTarget = target; - this._movementEventCallFunc = callFunc; - - if(listener) - this._frameEventListener = listener; + setMovementEventCallFunc: function (target, callFunc) { + if(arguments.length == 1){ + this._frameEventListener = target; + }else if(arguments.length == 2){ + this._movementEventTarget = target; + this._movementEventCallFunc = callFunc; + } }, /** @@ -543,9 +532,12 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {function} callFunc */ setFrameEventCallFunc: function (target, callFunc) { -// this._frameEvent = new ccs.AnimationEvent(target, callFunc); - this._frameEventTarget = target; - this._frameEventCallFunc = callFunc; + if(arguments.length == 1){ + this._frameEventListener = target; + }else if(arguments.length == 2){ + this._frameEventTarget = target; + this._frameEventCallFunc = callFunc; + } }, /** @@ -553,7 +545,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Object} userObject */ setUserObject: function (userObject) { - this.userObject = userObject; + this._userObject = userObject; }, /** @@ -563,8 +555,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Number} currentFrameIndex */ frameEvent: function (bone, frameEventName, originFrameIndex, currentFrameIndex) { -// if (this._frameEvent) { - if (this._frameEvent && this._frameEventCallFunc || this._frameEventListener) { + if ((this._frameEvent && this._frameEventCallFunc) || this._frameEventListener) { var frameEvent = new ccs.FrameEvent(); frameEvent.bone = bone; frameEvent.frameEventName = frameEventName; @@ -576,8 +567,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, movementEvent: function (armature, movementType, movementID) { -// if (this._movementEvent) { - if (this._movementEvent && this._movementEventCallFunc || this._movementEventListener) { + if ((this._movementEvent && this._movementEventCallFunc) || this._movementEventListener) { var event = new ccs.MovementEvent(); event.armature = armature; event.movementType = movementType; @@ -590,7 +580,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, movementObj.durationTo, 0); this._movementIndex++; if (this._movementIndex >= this._movementList.length) { this._movementIndex = 0; @@ -599,7 +589,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, movementObj.durationTo, 0); this._movementIndex++; } else { @@ -610,46 +600,35 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# } }, +// /** +// * call event +// * @param {Array} args +// */ +// callMovementEvent: function (args) { +// if (this._movementEvent) { +// this._movementEvent.setArguments(args); +// this._movementEvent.call(); +// } +// }, - - - /** - * Go to specified frame and pause current movement. - * @param {Number} frameIndex - */ - gotoAndPause: function (frameIndex) { - this.gotoAndPlay(frameIndex); - this.pause(); - }, - - /** - * call event - * @param {Array} args - */ - callMovementEvent: function (args) { - if (this._movementEvent) { - this._movementEvent.setArguments(args); - this._movementEvent.call(); - } - }, - - /** - * call event - * @param {Array} args - */ - callFrameEvent: function (args) { - if (this._frameEvent) { - this._frameEvent.setArguments(args); - this._frameEvent.call(); - } - }, +// /** +// * call event +// * @param {Array} args +// */ +// callFrameEvent: function (args) { +// if (this._frameEvent) { +// this._frameEvent.setArguments(args); +// this._frameEvent.call(); +// } +// }, /** * animationData setter * @param {ccs.AnimationData} aniData */ - setAnimationData: function (aniData) { - this.animationData = aniData; + setAnimationData: function (data) { + if(this._animationData != data) + this._animationData = data; }, /** @@ -657,7 +636,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @return {ccs.AnimationData} */ getAnimationData: function () { - return this.animationData; + return this._animationData; }, /** @@ -665,7 +644,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @return {Object} */ getUserObject: function () { - return this.userObject; + return this._userObject; }, /** @@ -673,16 +652,16 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @returns {boolean} */ isIgnoreFrameEvent: function () { - return this.ignoreFrameEvent; - }, - - /** - * Sets whether the frame event is ignored - * @param {Boolean} bool - */ - setIgnoreFrameEvent: function (bool) { - this.ignoreFrameEvent = bool; + return this._ignoreFrameEvent; } + +// /** +// * Sets whether the frame event is ignored +// * @param {Boolean} bool +// */ +// setIgnoreFrameEvent: function (bool) { +// this.ignoreFrameEvent = bool; +// } }); var _p = ccs.ArmatureAnimation.prototype; diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 64065376b9..3bdb304623 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -46,15 +46,16 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ _passLastFrame:false, ctor:function () { ccs.ProcessBase.prototype.ctor.call(this); + this._movementBoneData = null; this._tweenData = null; - this._to = null; this._from = null; + this._to = null; this._between = null; this._bone = null; - this._movementBoneData = null; + this._frameTweenEasing = ccs.TweenType.linear; - this._toIndex = 0; this._fromIndex = 0; + this._toIndex = 0; this.animation = null; this._passLastFrame = false; }, @@ -71,8 +72,6 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._bone = bone; this._tweenData = this._bone.getTweenData(); this._tweenData.displayIndex = -1; -// var armature = bone.getArmature(); -// if (armature) this.animation = armature.getAnimation(); this._animation = this._bone.getArmature() != null ? this._bone.getArmature().getAnimation() : @@ -103,7 +102,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ var difMovement = movementBoneData != this._movementBoneData; - this._movementBoneData = movementBoneData; + this.setMovementBoneData(movementBoneData); this._rawDuration = this._movementBoneData.duration; var nextKeyFrame = this._movementBoneData.getFrameData(0); @@ -218,8 +217,6 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ break; default: this._currentFrame = ccs.fmodf(this._currentFrame, this._nextFrameIndex); - this._totalDuration = 0; - this._betweenDuration = 0; break; } } @@ -245,8 +242,13 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @param {ccs.FrameData} to * @param {Boolean} limit */ - setBetween:function (from, to, limit) { - limit = Boolean(limit); + setBetween:function (from, to) { + + var limit = true; + if(arguments[2] != null){ + limit = Boolean(limit); + } + do { if (from.displayIndex < 0 && to.displayIndex >= 0) { @@ -283,9 +285,6 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ if (!displayManager.getForceChangeDisplay()) { displayManager.changeDisplayWithIndex(displayIndex, false); -// var locRenderNode = displayManager.getDisplayRenderNode(); -// if(locRenderNode) -// locRenderNode.setBlendFunc(keyFrameData.blendFunc); } //! Update bone zorder, bone's zorder is determined by frame zorder and bone zorder @@ -435,7 +434,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @param {ccs.ArmatureAnimation} animation */ setAnimation:function (animation) { - this.animation = animation; + this._animation = animation; }, /** @@ -443,13 +442,13 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @return {ccs.ArmatureAnimation} */ getAnimation:function () { - return this.animation; - }, - - release:function () { - this._from = null; - this._between = null; + return this._animation; } + +// release:function () { +// this._from = null; +// this._between = null; +// } }); /** From 8e45174a571207441ebefbd7abe55148e5434c6c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 29 Jul 2014 17:54:53 +0800 Subject: [PATCH 0361/1564] Issue #5702: Debug for Armature --- cocos2d/core/base-nodes/BaseNodesWebGL.js | 3 +- cocos2d/core/base-nodes/CCNode.js | 39 +++++--- .../core/platform/CCTypesPropertyDefine.js | 16 ++-- extensions/cocostudio/armature/CCArmature.js | 2 +- extensions/cocostudio/armature/CCBone.js | 22 +---- .../cocostudio/armature/display/CCSkin.js | 96 ++++--------------- 6 files changed, 61 insertions(+), 117 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index 6aabe33b06..c3d640e7a9 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -145,6 +145,5 @@ cc._tmp.WebGLCCNode = function () { } }; - _p.nodeToParentTransform = _p._nodeToParentTransformForWebGL; - + _p.getNodeToParentTransform = _p._getNodeToParentTransformForWebGL; }; diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index bec56bbd96..3ccecb419a 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1044,6 +1044,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} Var The arrival order. */ setOrderOfArrival: function (Var) { + if(this.arrivalOrder == NaN) + debugger; this.arrivalOrder = Var; }, @@ -1109,7 +1111,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ getBoundingBox: function () { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - return cc._rectApplyAffineTransformIn(rect, this.nodeToParentTransform()); + return cc._rectApplyAffineTransformIn(rect, this.getNodeToParentTransform()); }, /** @@ -1710,7 +1712,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    Sets the additional transform.
    - * The additional transform will be concatenated at the end of nodeToParentTransform.
    + * The additional transform will be concatenated at the end of getNodeToParentTransform.
    * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
    *

    * @example @@ -1732,7 +1734,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * spriteA.setPosition(ccp(200, 200)); * * // Gets the spriteA's transform. - * var t = spriteA.nodeToParentTransform(); + * var t = spriteA.getNodeToParentTransform(); * * // Sets the additional transform to spriteB, spriteB's position will based on its pseudo parent i.e. spriteA. * spriteB.setAdditionalTransform(t); @@ -1741,7 +1743,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * spriteA.setScale(2); * * // Gets the spriteA's transform. - * t = spriteA.nodeToParentTransform(); + * t = spriteA.getNodeToParentTransform(); * * // Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA. * spriteB.setAdditionalTransform(t); @@ -1750,7 +1752,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * spriteA.setRotation(20); * * // Gets the spriteA's transform. - * t = spriteA.nodeToParentTransform(); + * t = spriteA.getNodeToParentTransform(); * * // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. * spriteB.setAdditionalTransform(t); @@ -1768,7 +1770,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ parentToNodeTransform: function () { if (this._inverseDirty) { - this._inverse = cc.affineTransformInvert(this.nodeToParentTransform()); + this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()); this._inverseDirty = false; } return this._inverse; @@ -1779,9 +1781,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.AffineTransform} */ nodeToWorldTransform: function () { - var t = this.nodeToParentTransform(); + var t = this.getNodeToParentTransform(); for (var p = this._parent; p != null; p = p.parent) - t = cc.affineTransformConcat(t, p.nodeToParentTransform()); + t = cc.affineTransformConcat(t, p.getNodeToParentTransform()); return t; }, @@ -1945,13 +1947,24 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ transform: null, + /** + * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
    + * The matrix is in Pixels. + * @function + * @return {cc.AffineTransform} + * @deprecated + */ + nodeToParentTransform: function(){ + return this.getNodeToParentTransform(); + }, + /** * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
    * The matrix is in Pixels. * @function * @return {cc.AffineTransform} */ - nodeToParentTransform: null, + getNodeToParentTransform: null, _setNodeDirtyForCache: function () { if (this._cacheDirty === false) { @@ -2069,7 +2082,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _getBoundingBoxToCurrentNode: function (parentTransform) { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var trans = (parentTransform == null) ? this.nodeToParentTransform() : cc.affineTransformConcat(this.nodeToParentTransform(), parentTransform); + var trans = (parentTransform == null) ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), parentTransform); rect = cc.rectApplyAffineTransform(rect, trans); //query child's BoundingBox @@ -2088,7 +2101,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return rect; }, - _nodeToParentTransformForWebGL: function () { + _getNodeToParentTransformForWebGL: function () { var _t = this; if (_t._transformDirty) { // Translate values @@ -2430,11 +2443,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { // transform for canvas var context = ctx || cc._renderContext, eglViewer = cc.view; - var t = this.nodeToParentTransform(); + var t = this.getNodeToParentTransform(); context.transform(t.a, t.c, t.b, t.d, t.tx * eglViewer.getScaleX(), -t.ty * eglViewer.getScaleY()); }; - _p.nodeToParentTransform = function () { + _p.getNodeToParentTransform = function () { var _t = this; if (_t._transformDirty) { var t = _t._transform;// quick reference diff --git a/cocos2d/core/platform/CCTypesPropertyDefine.js b/cocos2d/core/platform/CCTypesPropertyDefine.js index 6e9e032871..f0be5ac1de 100644 --- a/cocos2d/core/platform/CCTypesPropertyDefine.js +++ b/cocos2d/core/platform/CCTypesPropertyDefine.js @@ -149,17 +149,17 @@ cc._tmp.PrototypeColor = function () { }; /** @expose */ - _p.DISABLE; - cc.defineGetterSetter(_p, "DISABLE", _p._disable); + cc.BlendFunc.DISABLE; + cc.defineGetterSetter(cc.BlendFunc, "DISABLE", cc.BlendFunc._disable); /** @expose */ - _p.ALPHA_PREMULTIPLIED; - cc.defineGetterSetter(_p, "ALPHA_PREMULTIPLIED", _p._alphaPremultiplied); + cc.BlendFunc.ALPHA_PREMULTIPLIED; + cc.defineGetterSetter(cc.BlendFunc, "ALPHA_PREMULTIPLIED", cc.BlendFunc._alphaPremultiplied); /** @expose */ - _p.ALPHA_NON_PREMULTIPLIED; - cc.defineGetterSetter(_p, "ALPHA_NON_PREMULTIPLIED", _p._alphaNonPremultiplied); + cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + cc.defineGetterSetter(cc.BlendFunc, "ALPHA_NON_PREMULTIPLIED", cc.BlendFunc._alphaNonPremultiplied); /** @expose */ - _p.ADDITIVE; - cc.defineGetterSetter(_p, "ADDITIVE", _p._additive); + cc.BlendFunc.ADDITIVE; + cc.defineGetterSetter(cc.BlendFunc, "ADDITIVE", cc.BlendFunc._additive); }; diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 40b6192b9b..5e17c2c4d1 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -274,7 +274,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ getNodeToParentTransform: function(){ if (this._transformDirty) this._armatureTransformDirty = true; - return ccs.Node.prototype.nodeToParentTransform.call(this); + return ccs.Node.prototype.getNodeToParentTransform.call(this); }, /** diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 895841687b..fe3a84fbe3 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -160,7 +160,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ /** * update worldTransform - * @param dt + * @param {Number} delta */ update: function (delta) { @@ -168,14 +168,10 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._boneTransformDirty = this._boneTransformDirty || this._parentBone.isTransformDirty(); if (this._armatureParentBone && !this._boneTransformDirty) - { this._boneTransformDirty = this._armatureParentBone.isTransformDirty(); - } - if (this._boneTransformDirty) - { - if (this._dataVersion >= ccs.CONST_VERSION_COMBINED) - { + if (this._boneTransformDirty){ + if (this._dataVersion >= ccs.CONST_VERSION_COMBINED){ ccs.TransformHelp.nodeConcat(this._tweenData, this._boneData); this._tweenData.scaleX -= 1; this._tweenData.scaleY -= 1; @@ -191,24 +187,16 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._worldInfo.skewY = this._tweenData.skewY + this._skewY - this._rotationY; if(this._parentBone) - { this.applyParentTransform(this._parentBone); - } - else - { + else { if (this._armatureParentBone) - { this.applyParentTransform(this._armatureParentBone); - } } ccs.TransformHelp.nodeToMatrix(this._worldInfo, this._worldTransform); if (this._armatureParentBone) - { - //TODO TransformConcat - this._worldTransform = cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToParentTransform()); - } + this._worldTransform = cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToParentTransform()); //TODO TransformConcat } ccs.displayFactory.updateDisplay(this, delta, this._boneTransformDirty || this._armature.getArmatureTransformDirty()); diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index f4fb97dc6c..b8708914bd 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -54,17 +54,14 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ if(spriteFrameName == "") return false; var pFrame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); - var ret = true; - if(pFrame){ + if(pFrame) this.initWithSpriteFrame(pFrame); - }else{ - cc.log("Cann't find CCSpriteFrame with %s. Please check your .plist file", spriteFrameName); + else{ + cc.log("Can't find CCSpriteFrame with %s. Please check your .plist file", spriteFrameName); ret = false; } - this._displayName = spriteFrameName; - return ret; }, @@ -95,28 +92,22 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, updateArmatureTransform: function () { - //TODO cc.TransformConcat this._transform = cc.affineTransformConcat( this.bone.getNodeToArmatureTransform(), this._skinTransform ); }, - updateTransform: function(){ + _updateTransformForWebGL: function(){ + var locQuad = this._quad; // If it is not visible, or one of its ancestors is not visible, then do nothing: if( !this._visible) - { - this._quad.br.vertices = this._quad.tl.vertices = this._quad.tr.vertices = this._quad.bl.vertices = cc.p(0, 0); - } - else - { + locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y:0, z:0}; + else { // // calculate the Quad based on the Affine Matrix // - var transform = this.getNodeToParentTransform ? - this.getNodeToParentTransform() : - this.nodeToParentTransform(); - + var transform = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform(); var size = this._rect; var x1 = this._offsetPosition.x; @@ -144,38 +135,15 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var dx = x1 * cr - y2 * sr2 + x; var dy = x1 * sr + y2 * cr2 + y; - //TODO _positionZ - this.SET_VERTEX3F( - this._quad.bl.vertices, - this.RENDER_IN_SUBPIXEL(ax), - this.RENDER_IN_SUBPIXEL(ay), - this._localZOrder - ); - this.SET_VERTEX3F( - this._quad.br.vertices, - this.RENDER_IN_SUBPIXEL(bx), - this.RENDER_IN_SUBPIXEL(by), - this._localZOrder - ); - this.SET_VERTEX3F( - this._quad.tl.vertices, - this.RENDER_IN_SUBPIXEL(dx), - this.RENDER_IN_SUBPIXEL(dy), - this._localZOrder - ); - this.SET_VERTEX3F( - this._quad.tr.vertices, - this.RENDER_IN_SUBPIXEL(cx), - this.RENDER_IN_SUBPIXEL(cy), - this._localZOrder - ); + this.SET_VERTEX3F(locQuad.bl.vertices,this.RENDER_IN_SUBPIXEL(ax), this.RENDER_IN_SUBPIXEL(ay),this._vertexZ); + this.SET_VERTEX3F(locQuad.br.vertices,this.RENDER_IN_SUBPIXEL(bx), this.RENDER_IN_SUBPIXEL(by),this._vertexZ); + this.SET_VERTEX3F(locQuad.tl.vertices,this.RENDER_IN_SUBPIXEL(dx), this.RENDER_IN_SUBPIXEL(dy),this._vertexZ); + this.SET_VERTEX3F(locQuad.tr.vertices,this.RENDER_IN_SUBPIXEL(cx), this.RENDER_IN_SUBPIXEL(cy),this._vertexZ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS if (this._textureAtlas) - { - this._textureAtlas.updateQuad(this._quad, this._textureAtlas.getTotalQuads()); - } + this._textureAtlas.updateQuad(locQuad, this._textureAtlas.getTotalQuads()); }, SET_VERTEX3F: function(_v_, _x_, _y_, _z_){ @@ -211,26 +179,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ ); }, -// draw: function(renderer, transform, flags){ -//// var mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); -// -// //TODO implement z order -// this._quadCommand.init( -// this._globalZOrder, -// this._texture.getName(), -// this.getGLProgramState(), -// this._blendFunc, -// this._quad, 1, mv); -// renderer.addCommand(this._quadCommand); -// }, - setBone: function (bone) { this.bone = bone; var armature = this.bone.getArmature(); if(armature) - { this._armature = armature; - } }, getBone: function () { @@ -245,21 +198,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return this._displayName; }, -// /** returns a "local" axis aligned bounding box of the node.
    -// * The returned box is relative only to its parent. -// * @return {cc.Rect} -// */ -// getBoundingBox: function () { -// var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); -// var transForm = this.nodeToParentTransform(); -// if (cc._renderType === cc._RENDER_TYPE_CANVAS) { -// transForm.b *= -1; -// transForm.c *= -1; -// transForm.b = [transForm.c, transForm.c = transForm.b][0]; -// } -// return cc.rectApplyAffineTransform(rect, transForm); -// }, - /** * @deprecated * @returns {cc.AffineTransform} @@ -276,7 +214,13 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return this.getNodeToWorldTransformAR(); } }); -ccs.Skin.prototype.nodeToParentTransform = cc.Node.prototype._nodeToParentTransformForWebGL; +if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + ccs.Skin.prototype.updateTransform = ccs.Skin.prototype._updateTransformForWebGL; +}else{ + //ccs.Skin.prototype.updateTransform = cc.Sprite.prototype.updateTransform; +} +//ccs.Skin.prototype.nodeToParentTransform = cc.Node.prototype._getNodeToParentTransformForWebGL; + var _p = ccs.Skin.prototype; From f0eb197d3e790532bbbdd0ab1f2161a3949273b7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Jul 2014 18:02:43 +0800 Subject: [PATCH 0362/1564] Issue #5702: update CCTween and CCArmatureAnimation --- extensions/cocostudio/armature/animation/CCTween.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 3bdb304623..895df701d8 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -443,6 +443,10 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ */ getAnimation:function () { return this._animation; + }, + + setMovementBoneData: function(data){ + this._movementBoneData = data; } // release:function () { From f5c99b15a7b28ecc20e081913ef42b9864d08db4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 29 Jul 2014 18:13:57 +0800 Subject: [PATCH 0363/1564] Issue #5702: update CCNode - Change the transform interface --- cocos2d/core/base-nodes/CCNode.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 3ccecb419a..b82e8611f1 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1768,7 +1768,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * The matrix is in Pixels. * @return {cc.AffineTransform} */ - parentToNodeTransform: function () { + getParentToNodeTransform: function () { if (this._inverseDirty) { this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()); this._inverseDirty = false; @@ -1776,25 +1776,46 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return this._inverse; }, + /** + * @deprecated + */ + parentToNodeTransform: function () { + return this.getParentToNodeTransform(); + }, + /** * Returns the world affine transform matrix. The matrix is in Pixels. * @return {cc.AffineTransform} */ - nodeToWorldTransform: function () { + getNodeToWorldTransform: function () { var t = this.getNodeToParentTransform(); for (var p = this._parent; p != null; p = p.parent) t = cc.affineTransformConcat(t, p.getNodeToParentTransform()); return t; }, + /** + * @deprecated + */ + nodeToWorldTransform: function(){ + return this.getNodeToWorldTransform(); + }, + /** * Returns the inverse world affine transform matrix. The matrix is in Pixels. * @return {cc.AffineTransform} */ - worldToNodeTransform: function () { + getWorldToNodeTransform: function () { return cc.affineTransformInvert(this.nodeToWorldTransform()); }, + /** + * @deprecated + */ + worldToNodeTransform: function () { + return this.getWorldToNodeTransform(); + }, + /** * Converts a Point to node (local) space coordinates. The result is in Points. * @param {cc.Point} worldPoint From fef88242d5085d8ed8fa1b011e34458bd2e292c8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 30 Jul 2014 17:56:50 +0800 Subject: [PATCH 0364/1564] Issue #5771: popScene can't see ccs --- cocos2d/core/base-nodes/CCNode.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index bec56bbd96..77177c6e5b 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1510,9 +1510,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ this._running = false; this.pause(); this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExit); - if (this._componentContainer) { - this._componentContainer.removeAll(); - } }, // actions From 896e03d075455360e38015ebea1b87e9268e19cd Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 30 Jul 2014 23:38:37 +0800 Subject: [PATCH 0365/1564] Fixed #4735: Made cc.RenderTexture's beginWithClear accept color value from 0 - 255 --- cocos2d/render-texture/CCRenderTexture.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 7851ec7174..6c93182846 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -381,10 +381,10 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ /** * starts rendering to the texture while clearing the texture first.
    * This is more efficient then calling -clear first and then -begin - * @param {Number} r red 0-1 - * @param {Number} g green 0-1 - * @param {Number} b blue 0-1 - * @param {Number} a alpha 0-1 0 is transparent + * @param {Number} r red 0-255 + * @param {Number} g green 0-255 + * @param {Number} b blue 0-255 + * @param {Number} a alpha 0-255 0 is transparent * @param {Number} [depthValue=] * @param {Number} [stencilValue=] */ @@ -393,7 +393,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ depthValue = depthValue || gl.COLOR_BUFFER_BIT; stencilValue = stencilValue || (gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - this._beginWithClear(r, g, b, a, depthValue, stencilValue, (gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)); + this._beginWithClear(r / 255, g / 255, b / 255, a / 255, depthValue, stencilValue, (gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)); }, _beginWithClear: null, From f322bbc1b9cf4fd50d47dce3a43c46b7e2dbca08 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 31 Jul 2014 10:28:56 +0800 Subject: [PATCH 0366/1564] Fixed #5775: Correct behavior of cc.TransitionSlideInB and cc.TransitionSlideInT --- cocos2d/transitions/CCTransition.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 4a2a14fb8a..63249140f9 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -724,7 +724,7 @@ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * initializes the scenes */ initScenes:function () { - this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR); + this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)); }, /** @@ -732,7 +732,7 @@ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @return {cc.MoveBy} */ action:function () { - return cc.MoveBy.create(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))); + return cc.MoveBy.create(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)); } }); @@ -772,7 +772,7 @@ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * initializes the scenes */ initScenes:function () { - this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)); + this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR); }, /** @@ -780,7 +780,7 @@ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @return {cc.MoveBy} */ action:function () { - return cc.MoveBy.create(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)); + return cc.MoveBy.create(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))); } }); From 0fec701b82ce835d32019b2d42f4b55e2d769eaa Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 31 Jul 2014 13:27:21 +0800 Subject: [PATCH 0367/1564] Fixed #2030: Label text bounding error --- cocos2d/core/labelttf/CCLabelTTF.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index f3068c305d..fafa0c5beb 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -192,16 +192,26 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (found) return idfound; // Backward check when forward check failed - substr = text.substr(0, baseNb); + substr = text.substr(0, baseNb + 1); idfound = baseNb; while (result = reversre.exec(substr)) { // BUG: Not secured if check with result[0] - idfound = result[1].length; - substr = result[1]; + + if(substr !== result[0]){ + idfound = result[0].length; + substr = result[0]; + }else{ + idfound = result[1].length; + substr = result[1]; + //If the first is a symbol + if(result[2]){ + if(cc.LabelTTF._checkSymbol.test(result[2])){ + continue; + } + } + } l = this._measure(substr); if (l < width) { - if (enre.test(result[2])) - idfound++; break; } } @@ -1143,9 +1153,11 @@ cc.LabelTTF._textAlign = ["left", "center", "right"]; cc.LabelTTF._textBaseline = ["top", "middle", "bottom"]; // Class static properties for measure util -cc.LabelTTF._checkRegEx = /(.+?)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5]|[\uFE30-\uFFA0])/; -cc.LabelTTF._reverseCheckRegEx = /(.*)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5]|[\uFE30-\uFFA0])/; +cc.LabelTTF._checkRegEx = /(.+?|[\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; +cc.LabelTTF._reverseCheckRegEx = /(.*)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; cc.LabelTTF._checkEnRegEx = /[\s\-\/\\\:]/; +cc.LabelTTF._checkSymbol = /[\u007e\u0021\u0040\u0023\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u005f\u002b\u007b\u007d\u005b\u005d\u003a\u0026\u0071\u0075\u006f\u0074\u003b\u007c\u003b\u0026\u0023\u0033\u0039\u003b\u005c\u0026\u006c\u0074\u003b\u0026\u0067\u0074\u003b\u003f\u002c\u002e\u002f\uff01\u0040\uffe5\u2026\uff08\uff09\u2014\u002b\u3010\u3011\uff1a\u201c\u007c\uff1b\u2018\u3001\u300a\u300b\uff1f\uff0c\u3002\u3001\u000d\u000a]/; +cc.LabelTTF._checkCharacter = /[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF]/; // Only support style in this format: "18px Verdana" or "18px 'Helvetica Neue'" cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; From 26e39a2f52dde84f356bbc7f01882f17deb48a4d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 31 Jul 2014 21:38:51 +0800 Subject: [PATCH 0368/1564] Fixed #2031: Cocostudio bug 1. texture add listener 2. layout position 3. adaptScreen param error --- extensions/ccui/base-classes/UIWidget.js | 12 +++ extensions/ccui/layouts/UILayout.js | 13 ++- extensions/ccui/uiwidgets/UIButton.js | 70 +++++++++++-- extensions/ccui/uiwidgets/UICheckBox.js | 97 +++++++++++++++++-- extensions/ccui/uiwidgets/UIImageView.js | 35 ++++--- extensions/ccui/uiwidgets/UILoadingBar.js | 35 ++++++- extensions/ccui/uiwidgets/UISlider.js | 88 +++++++++-------- .../widgetreader/LayoutReader/LayoutReader.js | 2 +- .../reader/widgetreader/WidgetReader.js | 2 +- 9 files changed, 275 insertions(+), 79 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 1e9ce20d62..0585519704 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1449,6 +1449,18 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ cc.Node.prototype.removeChild.call(this, node); } this._nodes.length = 0; + }, + + _findLayout: function(){ + var layout = this._parent; + while(layout){ + if(layout._doLayout){ + layout._doLayoutDirty = true; + break; + }else{ + layout = layout._parent; + } + } } }); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index cc8eb859b1..5c0ba41cf9 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -332,11 +332,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } }, - sortAllChildren: function () { - ccui.Widget.prototype.sortAllChildren.call(this); - this._doLayout(); - }, - _stencilClippingVisit: null, _stencilClippingVisitForWebGL: function (ctx) { @@ -782,10 +777,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var sprite = this._backGroundImage; switch (this._bgImageTexType){ case ccui.Widget.LOCAL_TEXTURE: - sprite.setTexture(fileName); + //SetTexture cannot load resource + sprite.initWithFile(fileName); break; case ccui.Widget.PLIST_TEXTURE: - sprite.setSpriteFrame(fileName); + //SetTexture cannot load resource + sprite.initWithSpriteFrameName(fileName); break; default: break; @@ -1117,6 +1114,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (!this._doLayoutDirty) return; + this.sortAllChildren(); + var executant = ccui.getLayoutManager(this._layoutType); if (executant) executant._doLayout(this); diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index ebc29748bb..bda0c3a2bd 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -209,6 +209,26 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._normalFileName = normal; this._normalTexType = texType; + + var self = this; + if(!this._buttonNormalRenderer.texture || !this._buttonNormalRenderer.texture.isLoaded()){ + this._buttonNormalRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._normalTextureSize = self._buttonNormalRenderer.getContentSize(); + self._updateFlippedX(); + self._updateFlippedY(); + + self._buttonNormalRenderer.setColor(self.getColor()); + self._buttonNormalRenderer.setOpacity(self.getOpacity()); + + self._updateContentSizeWithTextureSize(self._normalTextureSize); + self._normalTextureLoaded = true; + self._normalTextureAdaptDirty = true; + }); + } + if (this._scale9Enabled) { var normalRendererScale9 = this._buttonNormalRenderer; switch (this._normalTexType){ @@ -226,10 +246,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var normalRenderer = this._buttonNormalRenderer; switch (this._normalTexType){ case ccui.Widget.LOCAL_TEXTURE: - normalRenderer.setTexture(normal); + //SetTexture cannot load resource + normalRenderer.initWithFile(normal); break; case ccui.Widget.PLIST_TEXTURE: - normalRenderer.setSpriteFrame(normal); + //SetTexture cannot load resource + normalRenderer.initWithSpriteFrameName(normal); break; default: break; @@ -258,6 +280,22 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._clickedFileName = selected; this._pressedTexType = texType; + + var self = this; + if(!this._buttonClickedRenderer.texture || !this._buttonClickedRenderer.texture.isLoaded()){ + this._buttonClickedRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._pressedTextureSize = self._buttonClickedRenderer.getContentSize(); + self._updateFlippedX(); + self._updateFlippedY(); + + self._pressedTextureLoaded = true; + self._pressedTextureAdaptDirty = true; + }); + } + if (this._scale9Enabled) { var clickedRendererScale9 = this._buttonClickedRenderer; switch (this._pressedTexType) { @@ -275,10 +313,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var clickedRenderer = this._buttonClickedRenderer; switch (this._pressedTexType) { case ccui.Widget.LOCAL_TEXTURE: - clickedRenderer.setTexture(selected); + //SetTexture cannot load resource + clickedRenderer.initWithFile(selected); break; case ccui.Widget.PLIST_TEXTURE: - clickedRenderer.setSpriteFrame(selected); + //SetTexture cannot load resource + clickedRenderer.initWithSpriteFrameName(selected); break; default: break; @@ -304,6 +344,22 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._disabledFileName = disabled; this._disabledTexType = texType; + + var self = this; + if(!this._buttonDisableRenderer.texture || !this._buttonDisableRenderer.texture.isLoaded()){ + this._buttonDisableRenderer.addLoadedEventListener(function() { + + self._findLayout(); + + self._disabledTextureSize = self._buttonDisableRenderer.getContentSize(); + self._updateFlippedX(); + self._updateFlippedY(); + + self._disabledTextureLoaded = true; + self._disabledTextureAdaptDirty = true; + }); + } + if (this._scale9Enabled) { var disabledScale9 = this._buttonDisableRenderer; switch (this._disabledTexType) { @@ -321,10 +377,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var disabledRenderer = this._buttonDisableRenderer; switch (this._disabledTexType) { case ccui.Widget.LOCAL_TEXTURE: - disabledRenderer.setTexture(disabled); + //SetTexture cannot load resource + disabledRenderer.initWithFile(disabled); break; case ccui.Widget.PLIST_TEXTURE: - disabledRenderer.setSpriteFrame(disabled); + //SetTexture cannot load resource + disabledRenderer.initWithSpriteFrameName(disabled); break; default: break; diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 78eb27f867..9d17d48d61 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -128,12 +128,29 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundFileName = backGround; this._backGroundTexType = texType; var bgBoxRenderer = this._backGroundBoxRenderer; + + var self = this; + if(!bgBoxRenderer.texture || !bgBoxRenderer.texture.isLoaded()){ + bgBoxRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._updateFlippedX(); + self._updateFlippedY(); + + self._updateContentSizeWithTextureSize(self._backGroundBoxRenderer.getContentSize()); + self._backGroundBoxRendererAdaptDirty = true; + }); + } + switch (this._backGroundTexType) { case ccui.Widget.LOCAL_TEXTURE: - bgBoxRenderer.setTexture(backGround); + //SetTexture cannot load resource + bgBoxRenderer.initWithFile(backGround); break; case ccui.Widget.PLIST_TEXTURE: - bgBoxRenderer.setSpriteFrame(backGround); + //SetTexture cannot load resource + bgBoxRenderer.initWithSpriteFrameName(backGround); break; default: break; @@ -164,12 +181,27 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundSelectedFileName = backGroundSelected; this._backGroundSelectedTexType = texType; + + var self = this; + if(!this._backGroundSelectedBoxRenderer.texture || !this._backGroundSelectedBoxRenderer.texture.isLoaded()){ + this._backGroundSelectedBoxRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._updateFlippedX(); + self._updateFlippedY(); + self._backGroundSelectedBoxRendererAdaptDirty = true; + }); + } + switch (this._backGroundSelectedTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._backGroundSelectedBoxRenderer.setTexture(backGroundSelected); + //SetTexture cannot load resource + this._backGroundSelectedBoxRenderer.initWithFile(backGroundSelected); break; case ccui.Widget.PLIST_TEXTURE: - this._backGroundSelectedBoxRenderer.setSpriteFrame(backGroundSelected); + //SetTexture cannot load resource + this._backGroundSelectedBoxRenderer.initWithSpriteFrameName(backGroundSelected); break; default: break; @@ -191,12 +223,27 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossFileName = cross; this._frontCrossTexType = texType; + + var self = this; + if(!this._frontCrossRenderer.texture || !this._frontCrossRenderer.texture.isLoaded()){ + this._frontCrossRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._updateFlippedX(); + self._updateFlippedY(); + self._frontCrossRendererAdaptDirty = true; + }); + } + switch (this._frontCrossTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._frontCrossRenderer.setTexture(cross); + //SetTexture cannot load resource + this._frontCrossRenderer.initWithFile(cross); break; case ccui.Widget.PLIST_TEXTURE: - this._frontCrossRenderer.setSpriteFrame(cross); + //SetTexture cannot load resource + this._frontCrossRenderer.initWithSpriteFrameName(cross); break; default: break; @@ -217,12 +264,27 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundDisabledFileName = backGroundDisabled; this._backGroundDisabledTexType = texType; + + var self = this; + if(!this._backGroundBoxDisabledRenderer.texture || !this._backGroundBoxDisabledRenderer.texture.isLoaded()){ + this._backGroundBoxDisabledRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._updateFlippedX(); + self._updateFlippedY(); + self._backGroundBoxDisabledRendererAdaptDirty = true; + }); + } + switch (this._backGroundDisabledTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._backGroundBoxDisabledRenderer.setTexture(backGroundDisabled); + //SetTexture cannot load resource + this._backGroundBoxDisabledRenderer.initWithFile(backGroundDisabled); break; case ccui.Widget.PLIST_TEXTURE: - this._backGroundBoxDisabledRenderer.setSpriteFrame(backGroundDisabled); + //SetTexture cannot load resource + this._backGroundBoxDisabledRenderer.initWithSpriteFrameName(backGroundDisabled); break; default: break; @@ -243,12 +305,27 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossDisabledFileName = frontCrossDisabled; this._frontCrossDisabledTexType = texType; + + var self = this; + if(!this._frontCrossDisabledRenderer.texture || !this._frontCrossDisabledRenderer.texture.isLoaded()){ + this._frontCrossDisabledRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._updateFlippedX(); + self._updateFlippedY(); + self._frontCrossDisabledRendererAdaptDirty = true; + }); + } + switch (this._frontCrossDisabledTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._frontCrossDisabledRenderer.setTexture(frontCrossDisabled); + //SetTexture cannot load resource + this._frontCrossDisabledRenderer.initWithFile(frontCrossDisabled); break; case ccui.Widget.PLIST_TEXTURE: - this._frontCrossDisabledRenderer.setSpriteFrame(frontCrossDisabled); + //SetTexture cannot load resource + this._frontCrossDisabledRenderer.initWithSpriteFrameName(frontCrossDisabled); break; default: break; diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 74169ae009..dda96f6abb 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -77,24 +77,37 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if (!fileName) { return; } + var self = this; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._textureFile = fileName; this._imageTexType = texType; - var imageRenderer = this._imageRenderer; - switch (this._imageTexType) { + var imageRenderer = self._imageRenderer; + if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ + imageRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._imageTextureSize = imageRenderer.getContentSize(); + self._updateFlippedX(); + self._updateFlippedY(); + self._updateContentSizeWithTextureSize(self._imageTextureSize); + self._imageRendererAdaptDirty = true; + }); + } + switch (self._imageTexType) { case ccui.Widget.LOCAL_TEXTURE: - if(this._scale9Enabled){ + if(self._scale9Enabled){ imageRenderer.initWithFile(fileName); - imageRenderer.setCapInsets(this._capInsets); + imageRenderer.setCapInsets(self._capInsets); }else{ //SetTexture cannot load resource imageRenderer.initWithFile(fileName); } break; case ccui.Widget.PLIST_TEXTURE: - if(this._scale9Enabled){ + if(self._scale9Enabled){ imageRenderer.initWithSpriteFrameName(fileName); - imageRenderer.setCapInsets(this._capInsets); + imageRenderer.setCapInsets(self._capInsets); }else{ //SetTexture cannot load resource imageRenderer.initWithSpriteFrameName(fileName); @@ -104,12 +117,12 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ break; } - this._imageTextureSize = imageRenderer.getContentSize(); - this._updateFlippedX(); - this._updateFlippedY(); + self._imageTextureSize = imageRenderer.getContentSize(); + self._updateFlippedX(); + self._updateFlippedY(); - this._updateContentSizeWithTextureSize(this._imageTextureSize); - this._imageRendererAdaptDirty = true; + self._updateContentSizeWithTextureSize(self._imageTextureSize); + self._imageRendererAdaptDirty = true; }, /** diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index bae612eaf5..625c5bdc71 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -112,20 +112,51 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._renderBarTexType = texType; this._textureFile = texture; var barRenderer = this._barRenderer; + + var self = this; + if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ + barRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + var bz = barRenderer.getContentSize(); + self._barRendererTextureSize.width = bz.width; + self._barRendererTextureSize.height = bz.height; + + switch (self._direction) { + case ccui.LoadingBar.TYPE_LEFT: + barRenderer.setAnchorPoint(0.0,0.5); + if (!self._scale9Enabled) + barRenderer.setFlippedX(false); + break; + case ccui.LoadingBar.TYPE_RIGHT: + barRenderer.setAnchorPoint(1.0,0.5); + if (!self._scale9Enabled) + barRenderer.setFlippedX(true); + break; + } + self._barRendererScaleChangedWithSize(); + self._updateContentSizeWithTextureSize(self._barRendererTextureSize); + self._barRendererAdaptDirty = true; + }); + } + switch (this._renderBarTexType) { case ccui.Widget.LOCAL_TEXTURE: if (this._scale9Enabled){ barRenderer.initWithFile(texture); barRenderer.setCapInsets(this._capInsets); } else - barRenderer.setTexture(texture); + //SetTexture cannot load resource + barRenderer.initWithFile(texture); break; case ccui.Widget.PLIST_TEXTURE: if (this._scale9Enabled) { barRenderer.initWithSpriteFrameName(texture); barRenderer.setCapInsets(this._capInsets); } else - barRenderer.setSpriteFrame(texture); + //SetTexture cannot load resource + barRenderer.initWithSpriteFrameName(texture); break; default: break; diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index ac48007c22..8f9168b0cc 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -112,27 +112,27 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._textureFile = fileName; this._barTexType = texType; var barRenderer = this._barRenderer; + + var self = this; + if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ + barRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._barRendererAdaptDirty = true; + self._progressBarRendererDirty = true; + self._updateContentSizeWithTextureSize(self._barRenderer.getContentSize()); + }); + } + switch (this._barTexType) { case ccui.Widget.LOCAL_TEXTURE: - if (this._scale9Enabled) - { - barRenderer.initWithFile(fileName); - } - else - { - barRenderer.setTexture(fileName); - } + //SetTexture cannot load resource + barRenderer.initWithFile(fileName); break; case ccui.Widget.PLIST_TEXTURE: - if (this._scale9Enabled) - { - barRenderer.initWithSpriteFrameName(fileName); - } - else - { - barRenderer.setSpriteFrame(fileName); - } - + //SetTexture cannot load resource + barRenderer.initWithSpriteFrameName(fileName); break; default: break; @@ -156,32 +156,32 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarTextureFile = fileName; this._progressBarTexType = texType; var progressBarRenderer = this._progressBarRenderer; + + var self = this; + if(!progressBarRenderer.texture || !progressBarRenderer.texture.isLoaded()){ + progressBarRenderer.addLoadedEventListener(function(){ + + self._findLayout(); + + self._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); + var tz = self._progressBarRenderer.getContentSize(); + self._progressBarTextureSize = {width: tz.width, height: tz.height}; + self._progressBarRendererDirty = true; + }); + } + switch (this._progressBarTexType) { case ccui.Widget.LOCAL_TEXTURE: - if (this._scale9Enabled) - { - progressBarRenderer.initWithFile(fileName); - } - else - { - progressBarRenderer.setTexture(fileName); - } + //SetTexture cannot load resource + progressBarRenderer.initWithFile(fileName); break; case ccui.Widget.PLIST_TEXTURE: - if (this._scale9Enabled) - { - progressBarRenderer.initWithSpriteFrameName(fileName); - } - else - { - progressBarRenderer.setSpriteFrame(fileName); - } + //SetTexture cannot load resource + progressBarRenderer.initWithSpriteFrameName(fileName); break; default: break; } -// this._progressBarRenderer.setColor(this.getColor()); -// this._progressBarRenderer.setOpacity(this.getOpacity()); this._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); var tz = this._progressBarRenderer.getContentSize(); @@ -331,10 +331,12 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballNTexType = texType; switch (this._ballNTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._slidBallNormalRenderer.setTexture(normal); + //SetTexture cannot load resource + this._slidBallNormalRenderer.initWithFile(normal); break; case ccui.Widget.PLIST_TEXTURE: - this._slidBallNormalRenderer.setSpriteFrame(normal); + //SetTexture cannot load resource + this._slidBallNormalRenderer.initWithSpriteFrameName(normal); break; default: break; @@ -355,10 +357,12 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballPTexType = texType; switch (this._ballPTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._slidBallPressedRenderer.setTexture(pressed); + //SetTexture cannot load resource + this._slidBallPressedRenderer.initWithFile(pressed); break; case ccui.Widget.PLIST_TEXTURE: - this._slidBallPressedRenderer.setSpriteFrame(pressed); + //SetTexture cannot load resource + this._slidBallPressedRenderer.initWithSpriteFrameName(pressed); break; default: break; @@ -379,10 +383,12 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballDTexType = texType; switch (this._ballDTexType) { case ccui.Widget.LOCAL_TEXTURE: - this._slidBallDisabledRenderer.setTexture(disabled); + //SetTexture cannot load resource + this._slidBallDisabledRenderer.initWithFile(disabled); break; case ccui.Widget.PLIST_TEXTURE: - this._slidBallDisabledRenderer.setSpriteFrame(disabled); + //SetTexture cannot load resource + this._slidBallDisabledRenderer.initWithSpriteFrameName(disabled); break; default: break; diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 71bfc73880..20180af180 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -39,7 +39,7 @@ ccs.LayoutReader = { var w = 0, h = 0; var adaptScreen = options["adaptScreen"]; - if (adaptScreen != null){ + if (adaptScreen){ var screenSize = cc.director.getWinSize(); w = screenSize.width; h = screenSize.height; diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index f46272a6ab..5c5c517a0e 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -46,7 +46,7 @@ ccs.WidgetReader = { var w = 0; var h = 0; var adaptScreen = options["adaptScreen"]; - if (adaptScreen !== undefined) + if (adaptScreen) { var screenSize = cc.director.getWinSize(); w = screenSize.width; From e821971b921a9e1c69e7ca062dbf88d3250ba099 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 1 Aug 2014 10:28:04 +0800 Subject: [PATCH 0369/1564] Fixed #2037: Text Wrap method --- cocos2d/core/labelttf/CCLabelTTF.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index fafa0c5beb..8fb993ebe4 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -160,7 +160,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ var baseNb = Math.floor(text.length * width / tWidth); // Next line is a line with line break var nextlinebreak = text.indexOf('\n'); - if (baseNb * 0.8 >= nextlinebreak && nextlinebreak > -1) return nextlinebreak + 1; + if (baseNb * 0.85 >= nextlinebreak && nextlinebreak > -1) return nextlinebreak + 1; // Text width smaller than requested width if (tWidth < width) return text.length; @@ -189,7 +189,12 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ idfound = index; substr = text.substr(index); } - if (found) return idfound; + if (found){ + if(cc.LabelTTF._checkSymbol.test(substr)){ + idfound--; + } + return idfound; + } // Backward check when forward check failed substr = text.substr(0, baseNb + 1); @@ -1156,7 +1161,7 @@ cc.LabelTTF._textBaseline = ["top", "middle", "bottom"]; cc.LabelTTF._checkRegEx = /(.+?|[\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; cc.LabelTTF._reverseCheckRegEx = /(.*)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; cc.LabelTTF._checkEnRegEx = /[\s\-\/\\\:]/; -cc.LabelTTF._checkSymbol = /[\u007e\u0021\u0040\u0023\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u005f\u002b\u007b\u007d\u005b\u005d\u003a\u0026\u0071\u0075\u006f\u0074\u003b\u007c\u003b\u0026\u0023\u0033\u0039\u003b\u005c\u0026\u006c\u0074\u003b\u0026\u0067\u0074\u003b\u003f\u002c\u002e\u002f\uff01\u0040\uffe5\u2026\uff08\uff09\u2014\u002b\u3010\u3011\uff1a\u201c\u007c\uff1b\u2018\u3001\u300a\u300b\uff1f\uff0c\u3002\u3001\u000d\u000a]/; +cc.LabelTTF._checkSymbol = /^[\u007e\u0021\u0040\u0023\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u005f\u002b\u007b\u007d\u005b\u005d\u003a\u0026\u0071\u0075\u006f\u0074\u003b\u007c\u003b\u0026\u0023\u0033\u0039\u003b\u005c\u0026\u006c\u0074\u003b\u0026\u0067\u0074\u003b\u003f\u002c\u002e\u002f\uff01\u0040\uffe5\u2026\uff08\uff09\u2014\u002b\u3010\u3011\uff1a\u201c\u007c\uff1b\u2018\u3001\u300a\u300b\uff1f\uff0c\u3002\u3001\u000d\u000a]/; cc.LabelTTF._checkCharacter = /[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF]/; // Only support style in this format: "18px Verdana" or "18px 'Helvetica Neue'" From b1af31c580b19a29973e7958c94c272ab1345027 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 1 Aug 2014 11:14:03 +0800 Subject: [PATCH 0370/1564] Issue #5779: Incoming parameter order of listener target, selector --> selector, target --- extensions/ccui/uiwidgets/UISlider.js | 4 ++-- extensions/ccui/uiwidgets/UITextField.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 8f9168b0cc..275afb29e5 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -476,7 +476,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * @param {Function} selector * @param {Object} target */ - addEventListenerSlider: function (target, selector) { + addEventListenerSlider: function (selector, target) { this._sliderEventSelector = selector; this._sliderEventListener = target; }, @@ -487,7 +487,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _percentChangedEvent: function () { if (this._sliderEventListener && this._sliderEventSelector) { - this._sliderEventListener.call(this._sliderEventSelector, + this._sliderEventSelector.call(this._sliderEventListener, this, ccui.Slider.EVENT_PERCENT_CHANGED); } diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 84d3235917..83fd086a82 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -627,7 +627,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {Function} selector * @deprecated */ - addEventListenerTextField: function (target, selector) { + addEventListenerTextField: function (selector, target) { this._textFieldEventSelector = selector; this._textFieldEventListener = target; }, From 709412ab10dd6b2121795e88bbe16eae0874dc9e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 1 Aug 2014 11:39:32 +0800 Subject: [PATCH 0371/1564] Issue #5702: fixed some bugs of Armature --- cocos2d/core/base-nodes/CCNode.js | 8 +- cocos2d/core/sprites/SpritesWebGL.js | 5 +- extensions/cocostudio/armature/CCArmature.js | 236 ++++++++++--- extensions/cocostudio/armature/CCBone.js | 103 +----- .../armature/animation/CCArmatureAnimation.js | 219 ++++-------- .../armature/animation/CCProcessBase.js | 43 ++- .../cocostudio/armature/animation/CCTween.js | 112 +++--- .../armature/display/CCDisplayManager.js | 17 +- .../cocostudio/armature/display/CCSkin.js | 70 ++-- .../armature/utils/CCArmatureDataManager.js | 37 +- .../armature/utils/CCDataReaderHelper.js | 328 ++++++------------ 11 files changed, 487 insertions(+), 691 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b82e8611f1..553dcce593 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -719,8 +719,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Boolean} Var true if the node is visible, false if the node is hidden. */ setVisible: function (Var) { - this._visible = Var; - this.setNodeDirty(); + if(this._visible != Var){ + this._visible = Var; + if(Var)this.setNodeDirty(); + } }, /** @@ -2537,7 +2539,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } if (_t._additionalTransformDirty) { - _t._transform = cc.AffineTransformConcat(t, _t._additionalTransform); + _t._transform = cc.affineTransformConcat(t, _t._additionalTransform); _t._additionalTransformDirty = false; } diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index e2450610ad..37c90a5c48 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -276,10 +276,7 @@ cc._tmp.WebGLSprite = function () { var locQuad = _t._quad, locParent = _t._parent; // If it is not visible, or one of its ancestors is not visible, then do nothing: if (!_t._visible || ( locParent && locParent != _t._batchNode && locParent._shouldBeHidden)) { - locQuad.br.vertices = {x: 0, y: 0, z: 0}; - locQuad.tl.vertices = {x: 0, y: 0, z: 0}; - locQuad.tr.vertices = {x: 0, y: 0, z: 0}; - locQuad.bl.vertices = {x: 0, y: 0, z: 0}; + locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; _t._shouldBeHidden = true; } else { _t._shouldBeHidden = false; diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 5e17c2c4d1..72c9b2a46b 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -50,7 +50,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ version: 0, _armatureTransformDirty: true, _body: null, - _textureAtlasDic: null, _blendFunc: null, _className: "Armature", _realAnchorPointInPoints: null, @@ -65,7 +64,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ */ ctor: function (name, parentBone) { cc.Node.prototype.ctor.call(this); - this.name = ""; + this._name = ""; this._topBoneList = []; this._armatureIndexDic = {}; this._offsetPoint = cc.p(0, 0); @@ -93,7 +92,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._topBoneList.length = 0; this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; - this.name = name || ""; + this._name = name || ""; var armatureDataManager = ccs.armatureDataManager; var animationData; @@ -134,15 +133,15 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.update(0); this.updateOffsetPoint(); } else { - this.name = "new_armature"; + this._name = "new_armature"; this.armatureData = ccs.ArmatureData.create(); - this.armatureData.name = this.name; + this.armatureData.name = this._name; animationData = ccs.AnimationData.create(); - animationData.name = this.name; + animationData.name = this._name; - armatureDataManager.addArmatureData(this.name, this.armatureData); - armatureDataManager.addAnimationData(this.name, animationData); + armatureDataManager.addArmatureData(this._name, this.armatureData); + armatureDataManager.addAnimationData(this._name, animationData); this.animation.setAnimationData(animationData); } @@ -264,19 +263,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ return this._boneDic; }, - /** - * @deprecated - */ - nodeToParentTransform: function(){ - return this.getNodeToParentTransform(); - }, - - getNodeToParentTransform: function(){ - if (this._transformDirty) - this._armatureTransformDirty = true; - return ccs.Node.prototype.getNodeToParentTransform.call(this); - }, - /** * Set contentSize and Calculate anchor point. */ @@ -368,19 +354,23 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ switch (selBone.getDisplayRenderNodeType()) { case ccs.DISPLAY_TYPE_SPRITE: if(node instanceof ccs.Skin){ - node.updateTransform(); - - var func = selBone.getBlendFunc(); - if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) - node.setBlendFunc(selBone.getBlendFunc()); - else { - if ((this._blendFunc.src == alphaPremultiplied.src && this._blendFunc.dst == alphaPremultiplied.dst) - && !node.getTexture().hasPremultipliedAlpha()) - node.setBlendFunc(alphaNonPremultipled); - else - node.setBlendFunc(this._blendFunc); + if(cc._renderType === cc._RENDER_TYPE_WEBGL){ + node.updateTransform(); + + var func = selBone.getBlendFunc(); + if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + node.setBlendFunc(selBone.getBlendFunc()); + else { + if ((this._blendFunc.src == alphaPremultiplied.src && this._blendFunc.dst == alphaPremultiplied.dst) + && !node.getTexture().hasPremultipliedAlpha()) + node.setBlendFunc(alphaNonPremultipled); + else + node.setBlendFunc(this._blendFunc); + } + node.draw(ctx); + } else { + node.visit(ctx); } - node.draw(ctx); } break; case ccs.DISPLAY_TYPE_ARMATURE: @@ -390,8 +380,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ node.visit(ctx); break; } - } else if(node instanceof cc.Node) { - node.visit(ctx); + } else if(selBone instanceof cc.Node) { + selBone.visit(ctx); // CC_NODE_DRAW_SETUP(); } } @@ -407,7 +397,157 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.unscheduleUpdate(); }, - vist: null, + _getNodeToParentTransformForWebGL: function () { + if (this._transformDirty) { + this._armatureTransformDirty = true; + // Translate values + var x = this._position.x; + var y = this._position.y; + var apx = this._anchorPointInPoints.x, napx = -apx; + var apy = this._anchorPointInPoints.y, napy = -apy; + var scx = this._scaleX, scy = this._scaleY; + + if (this._ignoreAnchorPointForPosition) { + x += apx; + y += apy; + } + + // Rotation values + // Change rotation code to handle X and Y + // If we skew with the exact same value for both x and y then we're simply just rotating + var cx = 1, sx = 0, cy = 1, sy = 0; + if (this._rotationX !== 0 || this._rotationY !== 0) { + cx = Math.cos(-this._rotationRadiansX); + sx = Math.sin(-this._rotationRadiansX); + cy = Math.cos(-this._rotationRadiansY); + sy = Math.sin(-this._rotationRadiansY); + } + + // Add offset point + x += cy * this._offsetPoint.x * this._scaleX + -sx * this._offsetPoint.y * this._scaleY; + y += sy * this._offsetPoint.x * this._scaleX + cx * this._offsetPoint.y * this._scaleY; + + var needsSkewMatrix = ( this._skewX || this._skewY ); + + // optimization: + // inline anchor point calculation if skew is not needed + // Adjusted transform calculation for rotational skew + if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { + x += cy * napx * scx + -sx * napy * scy; + y += sy * napx * scx + cx * napy * scy; + } + + // Build Transform Matrix + // Adjusted transform calculation for rotational skew + var t = this._transform; + t.a = cy * scx; + t.b = sy * scx; + t.c = -sx * scy; + t.d = cx * scy; + t.tx = x; + t.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); + + // adjust anchor point + if (apx !== 0 || apy !== 0) + t = cc.affineTransformTranslate(t, napx, napy); + } + + if (this._additionalTransformDirty) { + t = cc.affineTransformConcat(t, this._additionalTransform); + this._additionalTransformDirty = false; + } + this._transform = t; + this._transformDirty = false; + } + return this._transform; + }, + + _getNodeToParentTransformForCanvas: function () { + if (!this._transform) + 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 + // base position + t.tx = this._position.x; + t.ty = this._position.y; + + // rotation Cos and Sin + var Cos = 1, Sin = 0; + if (this._rotationX) { + Cos = Math.cos(-this._rotationRadiansX); + Sin = Math.sin(-this._rotationRadiansX); + } + + // base abcd + t.a = t.d = Cos; + t.c = -Sin; + t.b = Sin; + + var lScaleX = this._scaleX, lScaleY = this._scaleY; + var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; + + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + + // Add offset point + t.tx += Cos * this._offsetPoint.x * lScaleX + -Sin * this._offsetPoint.y * lScaleY; + t.ty += Sin * this._offsetPoint.x * lScaleX + Cos * this._offsetPoint.y * lScaleY; + + // skew + if (this._skewX || this._skewY) { + // offset the anchorpoint + var skx = Math.tan(-this._skewX * Math.PI / 180); + var sky = Math.tan(-this._skewY * Math.PI / 180); + var xx = appY * skx * sx; + var yy = appX * sky * sy; + t.a = Cos + -Sin * sky; + t.c = Cos * skx + -Sin; + t.b = Sin + Cos * sky; + t.d = Sin * skx + Cos; + t.tx += Cos * xx + -Sin * yy; + t.ty += Sin * xx + Cos * yy; + } + + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + t.a *= sx; + t.b *= sx; + t.c *= sy; + t.d *= sy; + } + + // adjust anchorPoint + t.tx += Cos * -appX * sx + -Sin * -appY * sy; + t.ty += Sin * -appX * sx + Cos * -appY * sy; + + // if ignore anchorPoint + if (this._ignoreAnchorPointForPosition) { + t.tx += appX; + t.ty += appY; + } + + if (this._additionalTransformDirty) { + this._transform = cc.affineTransformConcat(this._transform, this._additionalTransform); + this._additionalTransformDirty = false; + } + + t.tx = t.tx | 0; + t.ty = t.ty | 0; + this._transformDirty = false; + } + return this._transform; + }, + + visit: null, _visitForCanvas: function(ctx){ var context = ctx || cc._renderContext; @@ -434,10 +574,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (!this._visible) return; - var context = cc._renderContext, i, currentStack = cc.current_stack; + var context = cc._renderContext, currentStack = cc.current_stack; - //cc.kmGLPushMatrixWitMat4(_t._stackMatrix); - //optimize performance for javascript currentStack.stack.push(currentStack.top); cc.kmMat4Assign(this._stackMatrix, currentStack.top); currentStack.top = this._stackMatrix; @@ -449,9 +587,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ // reset for next frame this.arrivalOrder = 0; - - //cc.kmGLPopMatrix(); - //optimize performance for javascript currentStack.top = currentStack.stack.pop(); }, @@ -662,16 +797,15 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ } }); - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - //WebGL - ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForWebGL; - //ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForWebGL; -} else { - //Canvas - ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForCanvas; - //ccs.Armature.prototype.nodeToParentTransform = ccs.Armature.prototype._nodeToParentTransformForCanvas; -} + //WebGL + ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForWebGL; + ccs.Armature.prototype.getNodeToParentTransform = ccs.Armature.prototype._getNodeToParentTransformForWebGL; + } else { + //Canvas + ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForCanvas; + ccs.Armature.prototype.getNodeToParentTransform = ccs.Armature.prototype._getNodeToParentTransformForCanvas; + } var _p = ccs.Armature.prototype; diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index fe3a84fbe3..3ad71a79d2 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -35,7 +35,6 @@ * @property {Array} childrenBone - <@readonly> All children bones * @property {ccs.Tween} tween - <@readonly> Tween * @property {ccs.FrameData} tweenData - <@readonly> The tween data - * @property {Boolean} transformDirty - Indicate whether the transform is dirty * @property {ccs.ColliderFilter} colliderFilter - The collider filter * @property {ccs.DisplayManager} displayManager - The displayManager * @property {Boolean} ignoreMovementBoneData - Indicate whether force the bone to show When CCArmature play a animation and there isn't a CCMovementBoneData of this bone in this CCMovementData. @@ -51,10 +50,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ ignoreMovementBoneData: false, _tween: null, _tweenData: null, - name: "", - _childrenBone: null, _parentBone: null, - boneTransformDirty: false, + _boneTransformDirty: false, _worldTransform: null, _blendFunc: 0, blendDirty: false, @@ -74,16 +71,13 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this.ignoreMovementBoneData = false; this._worldTransform = cc.affineTransformMake(1, 0, 0, 1, 0, 0); - this.boneTransformDirty = true; + this._boneTransformDirty = true; this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); this.blendDirty = false; this._worldInfo = null; this._armatureParentBone = null; this._dataVersion = 0; - - this.name = ""; - this._childrenBone = []; }, /** @@ -94,7 +88,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ init: function (name) { // cc.Node.prototype.init.call(this); if (name) { - this.name = name; + this._name = name; } this._tweenData = new ccs.FrameData(); @@ -117,13 +111,11 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ setBoneData: function (boneData) { cc.assert(boneData, "_boneData must not be null"); - if(this._boneData != boneData){ + if(this._boneData != boneData) this._boneData = boneData; - } - this.name = this._boneData.name; + this.setName(this._boneData.name); this._localZOrder = this._boneData.zOrder; - this._displayManager.initDisplayList(boneData); }, @@ -163,7 +155,6 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Number} delta */ update: function (delta) { - if (this._parentBone) this._boneTransformDirty = this._boneTransformDirty || this._parentBone.isTransformDirty(); @@ -178,7 +169,6 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ } this._worldInfo.copy(this._tweenData); - this._worldInfo.x = this._tweenData.x + this._position.x; this._worldInfo.y = this._tweenData.y + this._position.y; this._worldInfo.scaleX = this._tweenData.scaleX * this._scaleX; @@ -194,18 +184,15 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ } ccs.TransformHelp.nodeToMatrix(this._worldInfo, this._worldTransform); - if (this._armatureParentBone) this._worldTransform = cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToParentTransform()); //TODO TransformConcat } ccs.displayFactory.updateDisplay(this, delta, this._boneTransformDirty || this._armature.getArmatureTransformDirty()); - for(var i=0; i= ccs.CONST_VERSION_COMBINED) { var zorder = this._tweenData.zOrder + this._boneData.zOrder; this.setLocalZOrder(zorder); - } - else { + } else { this.setLocalZOrder(this._tweenData.zOrder); } }, @@ -288,8 +274,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ cc.assert(child, "Argument must be non-nil"); cc.assert(!child.parentBone, "child already added. It can't be added again"); - if (this._childrenBone.indexOf(child) < 0) { - this._childrenBone.push(child); + if (this._children.indexOf(child) < 0) { + this._children.push(child); child.setParentBone(this); } }, @@ -300,26 +286,19 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} recursion */ removeChildBone: function (bone, recursion) { - if (this._children.length > 0 && this._children.getIndex(bone) != -1 ) - { - if(recursion) - { + if (this._children.length > 0 && this._children.getIndex(bone) != -1 ) { + if(recursion) { var ccbones = bone._children; - - for(var i=0; i 0) - { + if(movementBoneData && movementBoneData.frameList.length > 0) { this._tweenList.push(tween); movementBoneData.duration = this._movementData.duration; tween.play(movementBoneData, durationTo, durationTween, loop, tweenEasing); - tween.setProcessScale(this._processScale); if (bone.getChildArmature()) - { bone.getChildArmature().getAnimation().setProcessScale(this._processScale); - } - } - else - { - if(!bone.isIgnoreMovementBoneData()) - { + } else { + if(!bone.isIgnoreMovementBoneData()){ //! this bone is not include in this movement, so hide it bone.getDisplayManager().changeDisplayWithIndex(-1, false); tween.stop(); } - } } - this._armature.update(0); }, @@ -327,12 +294,13 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Boolean} loop */ playWithNames: function (movementNames, durationTo, loop) { - this._movementList = []; this._movementListLoop = loop; this._onMovementList = true; this._movementIndex = 0; - - this._movementList = movementNames; + if(movementNames instanceof Array) + this._movementList = movementNames; + else + this._movementList.length = 0; this.updateMovementList(); }, @@ -344,7 +312,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Boolean} loop */ playWithIndexes: function (movementIndexes, durationTo, loop) { - this._movementList = []; + this._movementList.length = 0; this._movementListLoop = loop; this._movementListDurationTo = durationTo; this._onMovementList = true; @@ -386,9 +354,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._currentPercent = this._curFrameIndex / (this._movementData.duration - 1); this._currentFrame = this._nextFrameIndex * this._currentPercent; - for (var i = 0; i < this._tweenList.length; i++) { - var tween = this._tweenList[i]; - tween.gotoAndPlay(frameIndex); + var locTweenList = this._tweenList; + for (var i = 0; i < locTweenList.length; i++) { + locTweenList[i].gotoAndPlay(frameIndex); } this._armature.update(0); this._ignoreFrameEvent = ignoreFrameEvent; @@ -414,45 +382,28 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# update: function (dt) { ccs.ProcessBase.prototype.update.call(this, dt); - for (var i = 0; i < this._tweenList.length; i++) { - this._tweenList[i].update(dt); - } - - if(this._frameEventQueue.length > 0 || this._movementEventQueue.length > 0) - { - this._armature.retain(); - } + var locTweenList = this._tweenList; + for (var i = 0; i < locTweenList.length; i++) + locTweenList[i].update(dt); - var frameEvents = this._frameEventQueue; + var frameEvents = this._frameEventQueue, event; while (frameEvents.length > 0) { - var event = frameEvents.shift(); - + event = frameEvents.shift(); this._ignoreFrameEvent = true; - - if(this._frameEventTarget){ - this._frameEventTarget._frameEventCallFunc(event.bone, event.frameEventName, event.originFrameIndex, event.currentFrameIndex); - } - - if(this._frameEventListener){ + if(this._frameEventCallFunc) + this._frameEventCallFunc.call(this._frameEventTarget, event.bone, event.frameEventName, event.originFrameIndex, event.currentFrameIndex); + if(this._frameEventListener) this._frameEventListener(event.bone, event.frameEventName, event.originFrameIndex, event.currentFrameIndex); - } - this._ignoreFrameEvent = false; } var movementEvents = this._movementEventQueue; while (movementEvents.length > 0) { - var event = movementEvents.shift(); - - if(this._movementEventTarget) - { - this._movementEventTarget._movementEventCallFunc(event.armature, event.movementType, event.movementID); - } - + event = movementEvents.shift(); + if(this._movementEventCallFunc) + this._movementEventCallFunc.call(this._movementEventTarget, event.armature, event.movementType, event.movementID); if (this._movementEventListener) - { this._movementEventListener(event.armature, event.movementType, event.movementID); - } } }, @@ -472,6 +423,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this.movementEvent(this._armature, ccs.MovementEventType.start, this._movementID); break; } + break; case ccs.ANIMATION_TYPE_MAX: case ccs.ANIMATION_TYPE_SINGLE_FRAME: locCurrentPercent = 1; @@ -487,14 +439,12 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# locCurrentPercent = ccs.fmodf(locCurrentPercent, 1); this._currentFrame = this._nextFrameIndex == 0 ? 0 : ccs.fmodf(this._currentFrame, this._nextFrameIndex); this._nextFrameIndex = this._durationTween > 0 ? this._durationTween : 1; - this.movementEvent(this, ccs.MovementEventType.start, this._movementID); break; default: //locCurrentPercent = ccs.fmodf(locCurrentPercent, 1); this._currentFrame = ccs.fmodf(this._currentFrame, this._nextFrameIndex); this._toIndex = 0; - this.movementEvent(this._armature, ccs.MovementEventType.loopComplete, this._movementID); break; } @@ -514,10 +464,10 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# /** * connect a event - * @param {Object} target * @param {function} callFunc + * @param {Object} target */ - setMovementEventCallFunc: function (target, callFunc) { + setMovementEventCallFunc: function (callFunc, target) { if(arguments.length == 1){ this._frameEventListener = target; }else if(arguments.length == 2){ @@ -528,10 +478,10 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# /** * connect a event - * @param {Object} target * @param {function} callFunc + * @param {Object} target */ - setFrameEventCallFunc: function (target, callFunc) { + setFrameEventCallFunc: function (callFunc, target) { if(arguments.length == 1){ this._frameEventListener = target; }else if(arguments.length == 2){ @@ -555,7 +505,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Number} currentFrameIndex */ frameEvent: function (bone, frameEventName, originFrameIndex, currentFrameIndex) { - if ((this._frameEvent && this._frameEventCallFunc) || this._frameEventListener) { + if ((this._frameEventTarget && this._frameEventCallFunc) || this._frameEventListener) { var frameEvent = new ccs.FrameEvent(); frameEvent.bone = bone; frameEvent.frameEventName = frameEventName; @@ -567,7 +517,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, movementEvent: function (armature, movementType, movementID) { - if ((this._movementEvent && this._movementEventCallFunc) || this._movementEventListener) { + if ((this._movementEventTarget && this._movementEventCallFunc) || this._movementEventListener) { var event = new ccs.MovementEvent(); event.armature = armature; event.movementType = movementType; @@ -578,53 +528,28 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# updateMovementList: function () { if (this._onMovementList) { + var movementObj, locMovementList = this._movementList; if (this._movementListLoop) { - var movementObj = this._movementList[this._movementIndex]; + movementObj = locMovementList[this._movementIndex]; this.play(movementObj, movementObj.durationTo, 0); this._movementIndex++; - if (this._movementIndex >= this._movementList.length) { + if (this._movementIndex >= locMovementList.length) this._movementIndex = 0; - } - } - else { - if (this._movementIndex < this._movementList.length) { - var movementObj = this._movementList[this._movementIndex]; + } else { + if (this._movementIndex < locMovementList.length) { + movementObj = locMovementList[this._movementIndex]; this.play(movementObj, movementObj.durationTo, 0); this._movementIndex++; - } - else { + } else this._onMovementList = false; - } } this._onMovementList = true; } }, -// /** -// * call event -// * @param {Array} args -// */ -// callMovementEvent: function (args) { -// if (this._movementEvent) { -// this._movementEvent.setArguments(args); -// this._movementEvent.call(); -// } -// }, - -// /** -// * call event -// * @param {Array} args -// */ -// callFrameEvent: function (args) { -// if (this._frameEvent) { -// this._frameEvent.setArguments(args); -// this._frameEvent.call(); -// } -// }, - /** * animationData setter - * @param {ccs.AnimationData} aniData + * @param {ccs.AnimationData} data */ setAnimationData: function (data) { if(this._animationData != data) @@ -654,14 +579,6 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# isIgnoreFrameEvent: function () { return this._ignoreFrameEvent; } - -// /** -// * Sets whether the frame event is ignored -// * @param {Boolean} bool -// */ -// setIgnoreFrameEvent: function (bool) { -// this.ignoreFrameEvent = bool; -// } }); var _p = ccs.ArmatureAnimation.prototype; diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index 03c4ea518d..d4c378c2b7 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -99,6 +99,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ _nextFrameIndex: 0, _curFrameIndex: null, _isLoopBack: false, + ctor: function () { this._processScale = 1; this._isComplete = true; @@ -141,31 +142,47 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * Play the Process - * @param {Number} durationTo - * @param {ccs.TweenType} tweenEasing + * Play animation by animation name. + * @param {Number} durationTo The frames between two animation changing-over. + * It's meaning is changing to this animation need how many frames + * -1 : use the value from MovementData get from flash design panel + * @param {Number} durationTween The frame count you want to play in the game. + * if _durationTween is 80, then the animation will played 80 frames in a loop + * -1 : use the value from MovementData get from flash design panel + * @param {Number} loop Whether the animation is loop + * loop < 0 : use the value from MovementData get from flash design panel + * loop = 0 : this animation is not loop + * loop > 0 : this animation is loop + * @param {Number} tweenEasing Tween easing is used for calculate easing effect + * TWEEN_EASING_MAX : use the value from MovementData get from flash design panel + * -1 : fade out + * 0 : line + * 1 : fade in + * 2 : fade in and out */ - play: function (durationTo, tweenEasing, loop, tweenEasing) { + play: function (durationTo, durationTween, loop, tweenEasing) { this._isComplete = false; this._isPause = false; this._isPlaying = true; this._currentFrame = 0; + /* + * Set m_iTotalFrames to durationTo, it is used for change tween between two animation. + * When changing end, m_iTotalFrames will be set to _durationTween + */ this._nextFrameIndex = durationTo; this._tweenEasing = tweenEasing; }, update: function (dt) { - if (this._isComplete || this._isPause) { + if (this._isComplete || this._isPause) return false; - } /* * Fileter the m_iDuration <=0 and dt >1 * If dt>1, generally speaking the reason is the device is stuck. */ - if (this._rawDuration <= 0 || dt > 1) { + if (this._rawDuration <= 0 || dt > 1) return false; - } var locNextFrameIndex = this._nextFrameIndex === undefined ? 0 : this._nextFrameIndex; var locCurrentFrame = this._currentFrame; @@ -179,7 +196,6 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ * animation speed slower or quicker. */ locCurrentFrame += this._processScale * (dt / this.animationInternal); - this._currentPercent = locCurrentFrame / locNextFrameIndex; /* @@ -199,12 +215,10 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ */ gotoFrame: function (frameIndex) { var locLoopType = this._loopType; - if (locLoopType == ccs.ANIMATION_TYPE_NO_LOOP) { + if (locLoopType == ccs.ANIMATION_TYPE_NO_LOOP) locLoopType = ccs.ANIMATION_TYPE_MAX; - } - else if (locLoopType == ccs.ANIMATION_TYPE_TO_LOOP_FRONT) { + else if (locLoopType == ccs.ANIMATION_TYPE_TO_LOOP_FRONT) locLoopType = ccs.ANIMATION_TYPE_LOOP_FRONT; - } this._loopType = locLoopType; this._curFrameIndex = frameIndex; this._nextFrameIndex = this._durationTween; @@ -219,9 +233,6 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ return this._curFrameIndex; }, - - - /** * update will call this handler, you can handle your logic here */ diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 895df701d8..bb7933581d 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -42,8 +42,9 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ _totalDuration:0, _toIndex:0, _fromIndex:0, - animation:null, + _animation:null, _passLastFrame:false, + ctor:function () { ccs.ProcessBase.prototype.ctor.call(this); this._movementBoneData = null; @@ -56,7 +57,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._frameTweenEasing = ccs.TweenType.linear; this._fromIndex = 0; this._toIndex = 0; - this.animation = null; + this._animation = null; this._passLastFrame = false; }, @@ -89,12 +90,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ */ play:function (movementBoneData, durationTo, durationTween, loop, tweenEasing) { ccs.ProcessBase.prototype.play.call(this, durationTo, durationTween, loop, tweenEasing); - - if(loop){ - this._loopType = ccs.ANIMATION_TYPE_TO_LOOP_FRONT; - }else{ - this._loopType = ccs.ANIMATION_TYPE_NO_LOOP; - } + this._loopType = (loop)?ccs.ANIMATION_TYPE_TO_LOOP_FRONT:ccs.ANIMATION_TYPE_NO_LOOP; this._totalDuration = 0; this._betweenDuration = 0; @@ -116,18 +112,16 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ if (this._rawDuration == 0) { this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME; - if (durationTo == 0) { + if (durationTo == 0) this.setBetween(nextKeyFrame, nextKeyFrame); - } else { + else this.setBetween(this._tweenData, nextKeyFrame); - } this._frameTweenEasing = ccs.TweenType.linear; } else if (this._movementBoneData.frameList.length > 1) { this._durationTween = durationTween * this._movementBoneData.scale; - if (loop && this._movementBoneData.delay != 0) { + if (loop && this._movementBoneData.delay != 0) this.setBetween(this._tweenData, this.tweenNodeTo(this.updateFrameData(1 - this._movementBoneData.delay), this._between)); - } else { if (!difMovement || durationTo == 0) this.setBetween(nextKeyFrame, nextKeyFrame); @@ -172,19 +166,16 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ break; case ccs.ANIMATION_TYPE_NO_LOOP: locLoopType = ccs.ANIMATION_TYPE_MAX; - if (this._durationTween <= 0) { + if (this._durationTween <= 0) locCurrentPercent = 1; - } - else { + else locCurrentPercent = (locCurrentPercent - 1) * this._nextFrameIndex / this._durationTween; - } if (locCurrentPercent >= 1) { locCurrentPercent = 1; this._isComplete = true; this._isPlaying = false; break; - } - else { + } else { this._nextFrameIndex = this._durationTween; this._currentFrame = locCurrentPercent * this._nextFrameIndex; this._totalDuration = 0; @@ -194,13 +185,11 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ } case ccs.ANIMATION_TYPE_TO_LOOP_FRONT: locLoopType = ccs.ANIMATION_TYPE_LOOP_FRONT; - this._nextFrameIndex = this._durationTween > 0 ? this._durationTween : 1; if (this._movementBoneData.delay != 0) { this._currentFrame = (1 - this._movementBoneData.delay) * this._nextFrameIndex; locCurrentPercent = this._currentFrame / this._nextFrameIndex; - } else { locCurrentPercent = 0; this._currentFrame = 0; @@ -221,36 +210,28 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ } } - if (locCurrentPercent < 1 && locLoopType < ccs.ANIMATION_TYPE_TO_LOOP_BACK) { + if (locCurrentPercent < 1 && locLoopType < ccs.ANIMATION_TYPE_TO_LOOP_BACK) locCurrentPercent = Math.sin(locCurrentPercent * cc.PI / 2); - } this._currentPercent = locCurrentPercent; this._loopType = locLoopType; - if (locLoopType > ccs.ANIMATION_TYPE_TO_LOOP_BACK) { + if (locLoopType > ccs.ANIMATION_TYPE_TO_LOOP_BACK) locCurrentPercent = this.updateFrameData(locCurrentPercent); - } - if (this._frameTweenEasing != ccs.TweenType.tweenEasingMax) { + if (this._frameTweenEasing != ccs.TweenType.tweenEasingMax) this.tweenNodeTo(locCurrentPercent); - } }, /** * Calculate the between value of _from and _to, and give it to between frame data * @param {ccs.FrameData} from * @param {ccs.FrameData} to - * @param {Boolean} limit + * @param {Boolean} [limit=true] */ - setBetween:function (from, to) { - - var limit = true; - if(arguments[2] != null){ - limit = Boolean(limit); - } - - do - { + setBetween:function (from, to, limit) { + if(limit === undefined) + limit = true; + do { if (from.displayIndex < 0 && to.displayIndex >= 0) { this._from.copy(to); this._between.subtract(to, to, limit); @@ -283,9 +264,8 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ //! Change bone's display var displayIndex = keyFrameData.displayIndex; - if (!displayManager.getForceChangeDisplay()) { + if (!displayManager.getForceChangeDisplay()) displayManager.changeDisplayWithIndex(displayIndex, false); - } //! Update bone zorder, bone's zorder is determined by frame zorder and bone zorder this._tweenData.zOrder = keyFrameData.zOrder; @@ -296,28 +276,25 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ var childAramture = locBone.getChildArmature(); if (childAramture) { - if (keyFrameData.movement != "") { + if (keyFrameData.movement != "") childAramture.getAnimation().play(keyFrameData.movement); - } } } }, /** * According to the percent to calculate current CCFrameData with tween effect * @param {Number} percent - * @param {ccs.FrameData} node + * @param {ccs.FrameData} [node] * @return {ccs.FrameData} */ tweenNodeTo:function (percent, node) { - if (!node) { + if (!node) node = this._tweenData; - } var locFrom = this._from; var locBetween = this._between; - if (!locFrom.isTween){ + if (!locFrom.isTween) percent = 0; - } node.x = locFrom.x + percent * locBetween.x; node.y = locFrom.y + percent * locBetween.y; @@ -327,7 +304,6 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ node.skewY = locFrom.skewY + percent * locBetween.skewY; this._bone.setTransformDirty(true); - if (node && locBetween.isUseColorInfo) this.tweenColorTo(percent, node); @@ -350,9 +326,9 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @return {Number} */ updateFrameData:function (currentPercent) { - if (currentPercent > 1 && this._movementBoneData.delay != 0) { + if (currentPercent > 1 && this._movementBoneData.delay != 0) currentPercent = ccs.fmodf(currentPercent,1); - } + var playedTime = (this._rawDuration-1) * currentPercent; var from, to; @@ -380,9 +356,8 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ return this._currentPercent; } this._passLastFrame = true; - } else { + } else this._passLastFrame = false; - } do { this._fromIndex = locToIndex; @@ -390,22 +365,17 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ locTotalDuration = from.frameID; locToIndex = this._fromIndex + 1; - if (locToIndex >= length) { + if (locToIndex >= length) locToIndex = 0; - } - to = frames[locToIndex]; //! Guaranteed to trigger frame event - if(from.strEvent && !this.animation.isIgnoreFrameEvent()){ - this.animation.frameEvent(this._bone, from.strEvent,from.frameID, playedTime); - } + if(from.strEvent && !this._animation.isIgnoreFrameEvent()) + this._animation.frameEvent(this._bone, from.strEvent,from.frameID, playedTime); - if (playedTime == from.frameID|| (this._passLastFrame && this._fromIndex == length-1)){ + if (playedTime == from.frameID|| (this._passLastFrame && this._fromIndex == length-1)) break; - } - } - while (playedTime < from.frameID || playedTime >= to.frameID); + } while (playedTime < from.frameID || playedTime >= to.frameID); locBetweenDuration = to.frameID - from.frameID; this._frameTweenEasing = from.tweenEasing; @@ -415,7 +385,6 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._betweenDuration = locBetweenDuration; this._toIndex = locToIndex; } - currentPercent = locBetweenDuration == 0 ? 0 : (playedTime - this._totalDuration) / this._betweenDuration; /* @@ -448,26 +417,29 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ setMovementBoneData: function(data){ this._movementBoneData = data; } - -// release:function () { -// this._from = null; -// this._between = null; -// } }); +var _p = ccs.Tween.prototype; + +// Extended properties +/** @expose */ +_p.animation; +cc.defineGetterSetter(_p, "animation", _p.getAnimation, _p.setAnimation); + +_p = null; + /** * allocates and initializes a ArmatureAnimation. * @constructs * @param {ccs.Bone} bone - * @return {ccs.ArmatureAnimation} + * @return {ccs.Tween} * @example * // example * var animation = ccs.ArmatureAnimation.create(); */ ccs.Tween.create = function (bone) { var tween = new ccs.Tween(); - if (tween && tween.init(bone)) { + if (tween && tween.init(bone)) return tween; - } return null; }; diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 054a310559..2430a92d3a 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -214,7 +214,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ //! If displayIndex < 0, it means you want to hide you display if (index < 0) { if(this._displayRenderNode) { - this._displayRenderNode.removeFromParentAndCleanup(true); + this._displayRenderNode.removeFromParent(true); this.setCurrentDecorativeDisplay(null); } return; @@ -257,15 +257,16 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this._displayRenderNode = displayRenderNode; if (displayRenderNode) { - if (displayRenderNode instanceof ccs.Armature){ + if (displayRenderNode instanceof ccs.Armature) { this._bone.setChildArmature(displayRenderNode); displayRenderNode.setParentBone(this._bone); - }else if(displayRenderNode instanceof cc.ParticleSystem) - if (displayRenderNode instanceof ccs.Armature){ - locBone.setChildArmature(displayRenderNode); - displayRenderNode.setParentBone(locBone); - }else if(displayRenderNode instanceof cc.ParticleSystem) - displayRenderNode.resetSystem(); + } else if (displayRenderNode instanceof cc.ParticleSystem) { + if (displayRenderNode instanceof ccs.Armature) { + locBone.setChildArmature(displayRenderNode); + displayRenderNode.setParentBone(locBone); + } else if (displayRenderNode instanceof cc.ParticleSystem) + displayRenderNode.resetSystem(); + } displayRenderNode.setColor(locBone.getDisplayedColor()); displayRenderNode.setOpacity(locBone.getDisplayedOpacity()); diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index b8708914bd..10dd75e48f 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -73,17 +73,20 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ setSkinData: function (skinData) { this._skinData = skinData; - this.setScaleX(skinData.scaleX); this.setScaleY(skinData.scaleY); this.setRotationX(cc.radiansToDegrees(skinData.skewX)); this.setRotationY(cc.radiansToDegrees(-skinData.skewY)); this.setPosition(skinData.x, skinData.y); - this._skinTransform = this.getNodeToParentTransform ? - this.getNodeToParentTransform() : - this.nodeToParentTransform(); - + var localTransform = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform(); + var skinTransform = this._skinTransform; + skinTransform.a = localTransform.a; + skinTransform.b = localTransform.b; + skinTransform.c = localTransform.c; + skinTransform.d = localTransform.d; + skinTransform.tx = localTransform.tx; + skinTransform.ty = localTransform.ty; this.updateArmatureTransform(); }, @@ -93,8 +96,8 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ updateArmatureTransform: function () { this._transform = cc.affineTransformConcat( - this.bone.getNodeToArmatureTransform(), - this._skinTransform + this._skinTransform, + this.bone.getNodeToArmatureTransform() ); }, @@ -113,16 +116,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var x1 = this._offsetPosition.x; var y1 = this._offsetPosition.y; - var x2 = x1 + size.width; - var y2 = y1 + size.height; + var x2 = x1 + size.width, y2 = y1 + size.height; + var x = transform.tx, y = transform.ty; - var x = transform.tx; - var y = transform.ty; - - var cr = transform.a; - var sr = transform.b; - var cr2 = transform.c; - var sr2 = -transform.d; + var cr = transform.a, sr = transform.b; + var cr2 = transform.d, sr2 = -transform.c; var ax = x1 * cr - y1 * sr2 + x; var ay = x1 * sr + y1 * cr2 + y; @@ -135,15 +133,17 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var dx = x1 * cr - y2 * sr2 + x; var dy = x1 * sr + y2 * cr2 + y; - this.SET_VERTEX3F(locQuad.bl.vertices,this.RENDER_IN_SUBPIXEL(ax), this.RENDER_IN_SUBPIXEL(ay),this._vertexZ); - this.SET_VERTEX3F(locQuad.br.vertices,this.RENDER_IN_SUBPIXEL(bx), this.RENDER_IN_SUBPIXEL(by),this._vertexZ); - this.SET_VERTEX3F(locQuad.tl.vertices,this.RENDER_IN_SUBPIXEL(dx), this.RENDER_IN_SUBPIXEL(dy),this._vertexZ); - this.SET_VERTEX3F(locQuad.tr.vertices,this.RENDER_IN_SUBPIXEL(cx), this.RENDER_IN_SUBPIXEL(cy),this._vertexZ); + var locVertexZ = this._vertexZ; + this.SET_VERTEX3F(locQuad.bl.vertices,this.RENDER_IN_SUBPIXEL(ax), this.RENDER_IN_SUBPIXEL(ay),locVertexZ); + this.SET_VERTEX3F(locQuad.br.vertices,this.RENDER_IN_SUBPIXEL(bx), this.RENDER_IN_SUBPIXEL(by),locVertexZ); + this.SET_VERTEX3F(locQuad.tl.vertices,this.RENDER_IN_SUBPIXEL(dx), this.RENDER_IN_SUBPIXEL(dy),locVertexZ); + this.SET_VERTEX3F(locQuad.tr.vertices,this.RENDER_IN_SUBPIXEL(cx), this.RENDER_IN_SUBPIXEL(cy),locVertexZ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS if (this._textureAtlas) this._textureAtlas.updateQuad(locQuad, this._textureAtlas.getTotalQuads()); + this._quadDirty = true; }, SET_VERTEX3F: function(_v_, _x_, _y_, _z_){ @@ -157,26 +157,16 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, getNodeToWorldTransform: function(){ - //TODO cc.TransformConcat - return cc.affineTransformConcat( - this._bone.getArmature().getNodeToWorldTransform(), - this._transform - ); + return cc.affineTransformConcat(this._transform,this.bone.getArmature().getNodeToWorldTransform()); }, getNodeToWorldTransformAR: function(){ var displayTransform = this._transform; - - //TODO cc.PointApplyTransform this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); displayTransform.tx = this._anchorPointInPoints.x; displayTransform.ty = this._anchorPointInPoints.y; - //TODO cc.TransformConcat - return cc.affineTransformConcat( - displayTransform, - this.bone.getArmature().nodeToWorldTransform() - ); + return cc.affineTransformConcat( displayTransform,this.bone.getArmature().nodeToWorldTransform()); }, setBone: function (bone) { @@ -196,22 +186,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ */ getDisplayName: function () { return this._displayName; - }, - - /** - * @deprecated - * @returns {cc.AffineTransform} - */ - nodeToWorldTransform: function () { - return this.getNodeToWorldTransform(); - }, - - /** - * @deprecated - * @returns {cc.AffineTransform} - */ - nodeToWorldTransformAR: function () { - return this.getNodeToWorldTransformAR(); } }); if (cc._renderType == cc._RENDER_TYPE_WEBGL) { diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 632d1d47f4..4ed785dffa 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -253,54 +253,31 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * @param {String} imagePath * @param {String} plistPath * @param {String} configFilePath + * @param {Function} selector * @param {Object} target - * @param {Function} configFilePath */ - addArmatureFileInfoAsync:function (/*imagePath, plistPath, configFilePath, target, selector*/) { -// var imagePath, plistPath, configFilePath, target, selector; -// var isLoadSpriteFrame = false; -// if (arguments.length == 3) { -// configFilePath = arguments[0]; -// selector = arguments[1]; -// target = arguments[2]; -// isLoadSpriteFrame = true; -// this.addRelativeData(configFilePath); -// } else if (arguments.length == 5){ -// imagePath = arguments[0]; -// plistPath = arguments[1]; -// configFilePath = arguments[2]; -// selector = arguments[3]; -// target = arguments[4]; -// this.addRelativeData(configFilePath); -// this.addSpriteFrameFromFile(plistPath, imagePath, configFilePath); -// } -// ccs.dataReaderHelper.addDataFromFileAsync(configFilePath,target,selector,isLoadSpriteFrame); - + addArmatureFileInfoAsync:function (/*imagePath, plistPath, configFilePath, selector, target*/) { var imagePath, plistPath, configFilePath, target, selector; switch(arguments.length){ case 3: configFilePath = arguments[0]; target = arguments[1]; selector = arguments[2]; - this.addRelativeData(configFilePath); - this._autoLoadSpriteFile = true; - ccs.dataReaderHelper.addDataFromFileAsync("", "", configFilePath, target, selector); + ccs.dataReaderHelper.addDataFromFileAsync("", "", configFilePath, selector,target); break; case 5: imagePath = arguments[0]; plistPath = arguments[1]; configFilePath = arguments[2]; - target = arguments[3]; - selector = arguments[4]; - + target = arguments[4]; + selector = arguments[3]; this.addRelativeData(configFilePath); this._autoLoadSpriteFile = false; ccs.dataReaderHelper.addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector); this.addSpriteFrameFromFile(plistPath, imagePath); - } }, @@ -309,12 +286,12 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name * @param {String} plistPath * @param {String} imagePath + * @param {String} configFilePath */ addSpriteFrameFromFile:function (plistPath, imagePath, configFilePath) { var data = this.getRelativeData(configFilePath); - if(data){ + if(data) data.plistFiles.push(plistPath); - } ccs.spriteFrameCacheHelper.addSpriteFrameFromFile(plistPath, imagePath); }, diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 4d97641993..a4408d40f8 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -143,7 +143,6 @@ ccs.DataInfo = function () { * @name ccs.dataReaderHelper */ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ - ConfigType: { DragonBone_XML: 0, CocoStudio_JSON: 1, @@ -170,13 +169,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, addDataFromFile: function (filePath) { - /* * Check if file is already added to ArmatureDataManager, if then return. */ - if (this._configFileList.indexOf(filePath) != -1) { + if (this._configFileList.indexOf(filePath) != -1) return; - } this._configFileList.push(filePath); //! find the base file path @@ -190,28 +187,24 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var dataInfo = new ccs.DataInfo(); dataInfo.filename = filePath; dataInfo.basefilePath = basefilePath; - if (str == ".xml") { + if (str == ".xml") ccs.dataReaderHelper.addDataFromXML(filePath, dataInfo); - } - else if (str == ".json" || str == ".exportjson") { + else if (str == ".json" || str == ".exportjson") ccs.dataReaderHelper.addDataFromJson(filePath, dataInfo); - } - else if(str == ".csb"){ + else if(str == ".csb") ccs.dataReaderHelper.addDataFromBinaryCache(filePath, dataInfo); - } - }, - addDataFromFileAsync: function (imagePath, plistPath, filePath, target, selector) { + addDataFromFileAsync: function (imagePath, plistPath, filePath, selector, target) { /* * Check if file is already added to ArmatureDataManager, if then return. */ if (this._configFileList.indexOf(filePath) != -1) { if (target && selector) { if (this._asyncRefTotalCount == 0 && this._asyncRefCount == 0) - this._asyncCallBack(target, selector, 1); + this._asyncCallBack(selector,target, 1); else - this._asyncCallBack(target, selector, (this._asyncRefTotalCount - this._asyncRefCount) / this._asyncRefTotalCount); + this._asyncCallBack(selector, target, (this._asyncRefTotalCount - this._asyncRefCount) / this._asyncRefTotalCount); } return; } @@ -226,32 +219,26 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var fun = function () { self.addDataFromFile(filePath); self._asyncRefCount--; - self._asyncCallBack(target, selector, (self._asyncRefTotalCount - self._asyncRefCount) / self._asyncRefTotalCount); + self._asyncCallBack(selector,target, (self._asyncRefTotalCount - self._asyncRefCount) / self._asyncRefTotalCount); }; cc.director.getScheduler().scheduleCallbackForTarget(this, fun, 0.1, false); }, removeConfigFile: function (configFile) { // cc.arrayRemoveObject(this._configFileList, configFile); - var len = this._configFileList.length; - var it = this._configFileList[len]; - for (var i = 0;i " + ccs.CONST_ARMATURES + " > " + ccs.CONST_ARMATURE + ""); - var armatureDataManager = ccs.armatureDataManager; - for (var i = 0; i < armaturesXML.length; i++) { + var armatureDataManager = ccs.armatureDataManager, i; + for (i = 0; i < armaturesXML.length; i++) { var armatureData = this.decodeArmature(armaturesXML[i], dataInfo); armatureDataManager.addArmatureData(armatureData.name, armatureData, dataInfo.filename); } @@ -272,25 +259,22 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ * Begin decode animation data from xml */ var animationsXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_ANIMATIONS + " > " + ccs.CONST_ANIMATION + ""); - for (var i = 0; i < animationsXML.length; i++) { + for (i = 0; i < animationsXML.length; i++) { var animationData = this.decodeAnimation(animationsXML[i], dataInfo); armatureDataManager.addAnimationData(animationData.name, animationData, dataInfo.filename); } var texturesXML = skeleton.querySelectorAll(ccs.CONST_SKELETON + " > " + ccs.CONST_TEXTURE_ATLAS + " > " + ccs.CONST_SUB_TEXTURE + ""); - for (var i = 0; i < texturesXML.length; i++) { + for (i = 0; i < texturesXML.length; i++) { var textureData = this.decodeTexture(texturesXML[i], dataInfo); armatureDataManager.addTextureData(textureData.name, textureData, dataInfo.filename); } - }, decodeArmature: function (armatureXML, dataInfo) { var armatureData = new ccs.ArmatureData(); armatureData.init(); - - var name = armatureXML.getAttribute(ccs.CONST_A_NAME); - armatureData.name = name; + armatureData.name = armatureXML.getAttribute(ccs.CONST_A_NAME); var bonesXML = armatureXML.querySelectorAll(ccs.CONST_ARMATURE + " > " + ccs.CONST_BONE); @@ -340,9 +324,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var boneData = new ccs.BoneData(); boneData.init(); - var name = boneXML.getAttribute(ccs.CONST_A_NAME); - boneData.name = name; - + boneData.name = boneXML.getAttribute(ccs.CONST_A_NAME); boneData.parentName = boneXML.getAttribute(ccs.CONST_A_PARENT) || ""; boneData.zOrder = parseInt(boneXML.getAttribute(ccs.CONST_A_Z)) || 0; @@ -374,15 +356,13 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, decodeBoneDisplay: function (displayXML, dataInfo) { - var isArmature = parseFloat(displayXML.getAttribute(ccs.CONST_A_IS_ARMATURE)) || 0; var displayData = null; if (isArmature == 1) { displayData = new ccs.ArmatureDisplayData(); displayData.displayType = ccs.DISPLAY_TYPE_ARMATURE; - } - else { + } else { displayData = new ccs.SpriteDisplayData(); displayData.displayType = ccs.DISPLAY_TYPE_SPRITE; } @@ -444,19 +424,14 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ displayData = new ccs.SpriteDisplayData(); break; } - displayData.displayType = displayType; - return displayData; }, decodeAnimation: function (animationXML, dataInfo) { var aniData = new ccs.AnimationData(); - var name = animationXML.getAttribute(ccs.CONST_A_NAME); - var armatureData = ccs.armatureDataManager.getArmatureData(name); - aniData.name = name; var movementsXML = animationXML.querySelectorAll(ccs.CONST_ANIMATION + " > " + ccs.CONST_MOVEMENT); @@ -472,7 +447,6 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ decodeAnimationFromJson: function (json, dataInfo) { var aniData = new ccs.AnimationData(); - var name = json[ccs.CONST_A_NAME]; if(name){ aniData.name = json[ccs.CONST_A_NAME]; @@ -488,20 +462,18 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ decodeMovement: function (movementXML, armatureData, dataInfo) { var movementData = new ccs.MovementData(); - - var movName = movementXML.getAttribute(ccs.CONST_A_NAME); - movementData.name = movName; + movementData.name = movementXML.getAttribute(ccs.CONST_A_NAME); var duration, durationTo, durationTween, loop, tweenEasing = 0; duration = movementXML.getAttribute(ccs.CONST_A_DURATION); - movementData.duration = duration == null ? 0 : duration; + movementData.duration = duration == null ? 0 : parseFloat(duration); durationTo = movementXML.getAttribute(ccs.CONST_A_DURATION_TO); - movementData.durationTo = durationTo == null ? 0 : durationTo; + movementData.durationTo = durationTo == null ? 0 : parseFloat(durationTo); durationTween = movementXML.getAttribute(ccs.CONST_A_DURATION_TWEEN); - movementData.durationTween = durationTween == null ? 0 : durationTween; + movementData.durationTween = durationTween == null ? 0 : parseFloat(durationTween); loop = movementXML.getAttribute(ccs.CONST_A_LOOP); movementData.loop = loop ? Boolean(parseFloat(loop)) : true; @@ -509,11 +481,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var easing = movementXML.getAttribute(ccs.CONST_A_TWEEN_EASING); if (easing) { if (easing != ccs.CONST_FL_NAN) { - tweenEasing = easing == null ? 0 : easing; + tweenEasing = easing == null ? 0 : parseFloat(easing); movementData.tweenEasing = tweenEasing == 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; - } else { + } else movementData.tweenEasing = ccs.TweenType.linear; - } } var movBonesXml = movementXML.querySelectorAll(ccs.CONST_MOVEMENT + " > " + ccs.CONST_BONE); @@ -522,9 +493,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ movBoneXml = movBonesXml[i]; var boneName = movBoneXml.getAttribute(ccs.CONST_A_NAME); - if (movementData.getMovementBoneData(boneName)) { + if (movementData.getMovementBoneData(boneName)) continue; - } var boneData = armatureData.getBoneData(boneName); var parentName = boneData.parentName; @@ -533,9 +503,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (parentName != "") { for (var j = 0; j < movBonesXml.length; j++) { parentXML = movBonesXml[j]; - if (parentName == parentXML.getAttribute(ccs.CONST_A_NAME)) { + if (parentName == parentXML.getAttribute(ccs.CONST_A_NAME)) break; - } } } var moveBoneData = this.decodeMovementBone(movBoneXml, parentXML, boneData, dataInfo); @@ -560,9 +529,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ movementData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] == null ? ccs.TweenType.linear : json[ccs.CONST_A_TWEEN_EASING]; var name = json[ccs.CONST_A_NAME]; - if(name){ + if(name) movementData.name = name; - } var movementBoneList = json[ccs.CONST_MOVEMENT_BONE_DATA] || []; for (var i = 0; i < movementBoneList.length; i++) { @@ -577,45 +545,34 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ movBoneData.init(); var scale, delay; - if (movBoneXml) { scale = parseFloat(movBoneXml.getAttribute(ccs.CONST_A_MOVEMENT_SCALE)) || 0; movBoneData.scale = scale; delay = parseFloat(movBoneXml.getAttribute(ccs.CONST_A_MOVEMENT_DELAY)) || 0; - if (delay > 0) { + if (delay > 0) delay -= 1; - } movBoneData.delay = delay; } - var length = 0; - var parentTotalDuration = 0; - var currentDuration = 0; - var parentFrameXML = null; - var parentXMLList = []; + var length = 0, parentTotalDuration = 0,currentDuration = 0; + var parentFrameXML = null,parentXMLList = []; /* * get the parent frame xml list, we need get the origin data */ if (parentXml != null) { var parentFramesXML = parentXml.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_FRAME); - for (var i = 0; i < parentFramesXML.length; i++) { + for (var i = 0; i < parentFramesXML.length; i++) parentXMLList.push(parentFramesXML[i]); - } length = parentXMLList.length; } - - var totalDuration = 0; - - var name = movBoneXml.getAttribute(ccs.CONST_A_NAME); - - movBoneData.name = name; + movBoneData.name = movBoneXml.getAttribute(ccs.CONST_A_NAME); var framesXML = movBoneXml.querySelectorAll(ccs.CONST_BONE + " > " + ccs.CONST_FRAME); - var j = 0; + var j = 0, totalDuration = 0; for (var ii = 0; ii < framesXML.length; ii++) { var frameXML = framesXML[ii]; if (parentXml) { @@ -629,16 +586,15 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ j++; } } - var frameData = this.decodeFrame(frameXML, parentFrameXML, boneData, dataInfo); - movBoneData.addFrameData(frameData); - frameData.frameID = totalDuration; - totalDuration += frameData.duration; + var boneFrameData = this.decodeFrame(frameXML, parentFrameXML, boneData, dataInfo); + movBoneData.addFrameData(boneFrameData); + boneFrameData.frameID = totalDuration; + totalDuration += boneFrameData.duration; movBoneData.duration = totalDuration; } //Change rotation range from (-180 -- 180) to (-infinity -- infinity) - var frames = movBoneData.frameList; - var pi = Math.PI; + var frames = movBoneData.frameList, pi = Math.PI; for (var i = frames.length - 1; i >= 0; i--) { if (i > 0) { var difSkewX = frames[i].skewX - frames[i - 1].skewX; @@ -664,24 +620,20 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ decodeMovementBoneFromJson: function (json, dataInfo) { var movementBoneData = new ccs.MovementBoneData(); movementBoneData.init(); - movementBoneData.delay = json[ccs.CONST_A_MOVEMENT_DELAY] || 0; var name = json[ccs.CONST_A_NAME]; - if(name){ + if(name) movementBoneData.name = name; - } var framesData = json[ccs.CONST_FRAME_DATA] || []; var length = framesData.length; - for (var i = 0; i < length; i++) - { + for (var i = 0; i < length; i++) { var dic = json[ccs.CONST_FRAME_DATA][i]; var frameData = this.decodeFrameFromJson(dic, dataInfo); movementBoneData.addFrameData(frameData); - if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) - { + if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED){ frameData.frameID = movementBoneData.duration; movementBoneData.duration += frameData.duration; } @@ -719,12 +671,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, decodeFrame: function (frameXML, parentFrameXml, boneData, dataInfo) { - var x = 0, y = 0, scale_x = 0, scale_y = 0, skew_x = 0, skew_y = 0, tweenRotate = 0; var duration = 0, displayIndex = 0, zOrder = 0, tweenEasing = 0, blendType = 0; var frameData = new ccs.FrameData(); - frameData.strMovement = frameXML.getAttribute(ccs.CONST_A_MOVEMENT) || ""; frameData.movement = frameData.strMovement; frameData.strEvent = frameXML.getAttribute(ccs.CONST_A_EVENT) || ""; @@ -734,138 +684,101 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ frameData.strSoundEffect = frameXML.getAttribute(ccs.CONST_A_SOUND_EFFECT) || ""; frameData.soundEffect = frameData.strSoundEffect; - var tweenFrame = false; var isTween = frameXML.getAttribute(ccs.CONST_A_TWEEN_FRAME); + frameData.isTween = isTween == undefined?true: Boolean(isTween); - var x, y; - if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) - { + if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { x = frameXML.getAttribute(ccs.CONST_A_COCOS2DX_X); - if(x) - { - frameData.x = x; + if(x){ + frameData.x = parseFloat(x); frameData.x *= this._positionReadScale; } y = frameXML.getAttribute(ccs.CONST_A_COCOS2DX_Y); - if(y) - { - frameData.y = -y; + if(y){ + frameData.y = -parseFloat(y); frameData.y *= this._positionReadScale; } - } - else - { + } else { x = frameXML.getAttribute(ccs.CONST_A_X); - if(x) - { - frameData.x = x; + if(x) { + frameData.x = parseFloat(x); frameData.x *= this._positionReadScale; } y = frameXML.getAttribute(ccs.CONST_A_Y); - if(y) - { - frameData.y = -y; + if(y) { + frameData.y = -parseFloat(y); frameData.y *= this._positionReadScale; } } - scale_x = frameXML.getAttribute(ccs.CONST_A_SCALE_X); if( scale_x != null ) - { - frameData.scaleX = scale_x; - } + frameData.scaleX = parseFloat(scale_x); scale_y = frameXML.getAttribute(ccs.CONST_A_SCALE_Y); if( scale_y != null ) - { - frameData.scaleY = scale_y; - } + frameData.scaleY = parseFloat(scale_y); skew_x = frameXML.getAttribute(ccs.CONST_A_SKEW_X); if( skew_x != null ) - { - frameData.skewX = cc.degreesToRadians(skew_x); - } + frameData.skewX = cc.degreesToRadians(parseFloat(skew_x)); skew_y = frameXML.getAttribute(ccs.CONST_A_SKEW_Y); if( skew_y != null ) - { - frameData.skewY = cc.degreesToRadians(-skew_y); - } + frameData.skewY = cc.degreesToRadians(-parseFloat(skew_y)); + duration = frameXML.getAttribute(ccs.CONST_A_DURATION); if( duration != null ) - { - frameData.duration = duration; - } + frameData.duration = parseFloat(duration); displayIndex = frameXML.getAttribute(ccs.CONST_A_DISPLAY_INDEX); if( displayIndex != null ) - { - frameData.displayIndex = displayIndex; - } + frameData.displayIndex = parseFloat(displayIndex); zOrder = frameXML.getAttribute(ccs.CONST_A_Z); if( zOrder != null ) - { - frameData.zOrder = zOrder; - } + frameData.zOrder = parseInt(zOrder); tweenRotate = frameXML.getAttribute(ccs.CONST_A_TWEEN_ROTATE); if( tweenRotate != null ) - { - frameData.tweenRotate = tweenRotate; - } + frameData.tweenRotate = parseFloat(tweenRotate); blendType = frameXML.getAttribute(ccs.CONST_A_BLEND_TYPE); - if ( blendType != null ) - { + if ( blendType != null ) { var blendFunc = frameData.blendFunc; - switch (blendType) - { + switch (blendType) { case ccs.BLEND_TYPE_NORMAL: - { blendFunc.src = cc.BLEND_SRC; blendFunc.dst = cc.BLEND_DST; - } break; case ccs.BLEND_TYPE_ADD: - { blendFunc.src = cc.SRC_ALPHA; blendFunc.dst = cc.ONE; - } break; case ccs.BLEND_TYPE_MULTIPLY: - { blendFunc.src = cc.DST_COLOR; blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - } break; case ccs.BLEND_TYPE_SCREEN: - { blendFunc.src = cc.ONE; blendFunc.dst = cc.ONE_MINUS_DST_COLOR; - } break; default: - { frameData.blendFunc.src = cc.BLEND_SRC; frameData.blendFunc.dst = cc.BLEND_DST; - } break; } } var colorTransformXML = frameXML.querySelectorAll(ccs.CONST_FRAME + " > " + ccs.CONST_A_COLOR_TRANSFORM); - if (colorTransformXML && colorTransformXML.length > 0) - { + if (colorTransformXML && colorTransformXML.length > 0) { colorTransformXML = colorTransformXML[0]; - var alpha, red, green, blue = 100; - var alphaOffset, redOffset, greenOffset, blueOffset = 0; + var alpha, red, green, blue; + var alphaOffset, redOffset, greenOffset, blueOffset; - alpha = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA); - red = colorTransformXML.getAttribute(ccs.CONST_A_RED); - green = colorTransformXML.getAttribute(ccs.CONST_A_GREEN); - blue = colorTransformXML.getAttribute(ccs.CONST_A_BLUE); + alpha = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA) || 0; + red = colorTransformXML.getAttribute(ccs.CONST_A_RED) || 0; + green = colorTransformXML.getAttribute(ccs.CONST_A_GREEN) || 0; + blue = colorTransformXML.getAttribute(ccs.CONST_A_BLUE) || 0; - alphaOffset = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA_OFFSET); - redOffset = colorTransformXML.getAttribute(ccs.CONST_A_RED_OFFSET); - greenOffset = colorTransformXML.getAttribute(ccs.CONST_A_GREEN_OFFSET); - blueOffset = colorTransformXML.getAttribute(ccs.CONST_A_BLUE_OFFSET); + alphaOffset = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA_OFFSET) || 0; + redOffset = colorTransformXML.getAttribute(ccs.CONST_A_RED_OFFSET) || 0; + greenOffset = colorTransformXML.getAttribute(ccs.CONST_A_GREEN_OFFSET) || 0; + blueOffset = colorTransformXML.getAttribute(ccs.CONST_A_BLUE_OFFSET) || 0; frameData.a = 2.55 * alphaOffset + alpha; frameData.r = 2.55 * redOffset + red; @@ -876,21 +789,13 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } var _easing = frameXML.getAttribute(ccs.CONST_A_TWEEN_EASING); - if(_easing != null) - { - var str = _easing; - if(str != ccs.CONST_FL_NAN) - { + if(_easing != null) { + if(_easing != ccs.CONST_FL_NAN){ tweenEasing = frameXML.getAttribute(ccs.CONST_A_TWEEN_EASING); if( tweenEasing ) - { - frameData.tweenEasing = tweenEasing == 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; - } - } - else - { + frameData.tweenEasing = (tweenEasing == 2) ? ccs.TweenType.sineEaseInOut : tweenEasing; + } else frameData.tweenEasing = ccs.TweenType.linear; - } } if (parentFrameXml) { @@ -899,8 +804,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { helpNode.x = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_COCOS2DX_X)); helpNode.y = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_COCOS2DX_Y)); - } - else { + } else { helpNode.x = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_X)); helpNode.y = parseFloat(parentFrameXml.getAttribute(ccs.CONST_A_Y)); } @@ -935,18 +839,13 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } if (dataInfo.cocoStudioVersion < ccs.CONST_VERSION_COMBINED) - { frameData.duration = json[ccs.CONST_A_DURATION] == null ? 1 : json[ccs.CONST_A_DURATION]; - } else - { frameData.frameID = json[ccs.CONST_A_FRAME_INDEX]; - } var twEPs = json[ccs.CONST_A_EASING_PARAM] || []; for (var i = 0; i < twEPs.length; i++) { - var twEP = twEPs[i]; - frameData.easingParams[i] = twEP; + frameData.easingParams[i] = twEPs[i]; } return frameData; @@ -960,19 +859,18 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ textureData.name = textureXML.getAttribute(ccs.CONST_A_NAME); } - var px, py, width, height = 0; + var px, py; if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { px = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_X)) || 0; py = parseFloat(textureXML.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_Y)) || 0; - } - else { + } else { px = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_X)) || 0; py = parseFloat(textureXML.getAttribute(ccs.CONST_A_PIVOT_Y)) || 0; } - width = parseFloat(textureXML.getAttribute(ccs.CONST_A_WIDTH)) || 0; - height = parseFloat(textureXML.getAttribute(ccs.CONST_A_HEIGHT)) || 0; + var width = parseFloat(textureXML.getAttribute(ccs.CONST_A_WIDTH)) || 0; + var height = parseFloat(textureXML.getAttribute(ccs.CONST_A_HEIGHT)) || 0; var anchorPointX = px / width; var anchorPointY = (height - py) / height; @@ -980,13 +878,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ textureData.pivotX = anchorPointX; textureData.pivotY = anchorPointY; - textureData.pivotX = anchorPointX; - textureData.pivotY = anchorPointY; - var contoursXML = textureXML.querySelectorAll(ccs.CONST_SUB_TEXTURE + " > " + ccs.CONST_CONTOUR); for (var i = 0; i < contoursXML.length; i++) { - var contourData = this.decodeContour(contoursXML[i], dataInfo); - textureData.addContourData(contourData); + textureData.addContourData(this.decodeContour(contoursXML[i], dataInfo)); } return textureData; }, @@ -1006,8 +900,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var contourDataList = json[ccs.CONST_CONTOUR_DATA] || []; for (var i = 0; i < contourDataList.length; i++) { - var locContourData = this.decodeContourFromJson(contourDataList[i]); - textureData.contourDataList.push(locContourData); + textureData.contourDataList.push(this.decodeContourFromJson(contourDataList[i])); } return textureData; }, @@ -1050,9 +943,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ dataInfo.contentScale = dic[ccs.CONST_CONTENT_SCALE] == null ? 1 : dic[ccs.CONST_CONTENT_SCALE]; // Decode armatures - var armatureDataArr = dic[ccs.CONST_ARMATURE_DATA] || []; + var armatureDataArr = dic[ccs.CONST_ARMATURE_DATA] || [], i; var armatureData; - for (var i = 0; i < armatureDataArr.length; i++) { + for (i = 0; i < armatureDataArr.length; i++) { armatureData = this.decodeArmatureFromJSON(armatureDataArr[i], dataInfo); ccs.armatureDataManager.addArmatureData(armatureData.name, armatureData, dataInfo.filename); } @@ -1060,7 +953,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ // Decode animations var animationDataArr = dic[ccs.CONST_ANIMATION_DATA] || []; var animationData; - for (var i = 0; i < animationDataArr.length; i++) { + for (i = 0; i < animationDataArr.length; i++) { animationData = this.decodeAnimationFromJson(animationDataArr[i], dataInfo); ccs.armatureDataManager.addAnimationData(animationData.name, animationData, dataInfo.filename); } @@ -1068,7 +961,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ // Decode textures var textureDataArr = dic[ccs.CONST_TEXTURE_DATA] || []; var textureData; - for (var i = 0; i < textureDataArr.length; i++) { + for (i = 0; i < textureDataArr.length; i++) { textureData = this.decodeTextureFromJson(textureDataArr[i], dataInfo); ccs.armatureDataManager.addTextureData(textureData.name, textureData, dataInfo.filename); } @@ -1079,7 +972,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (autoLoad) { var configFiles = dic[ccs.CONST_CONFIG_FILE_PATH] || []; var locFilePath, locPos, locPlistPath, locImagePath; - for (var i = 0; i < configFiles.length; i++) { + for (i = 0; i < configFiles.length; i++) { locFilePath = configFiles[i]; locPos = locFilePath.lastIndexOf("."); locFilePath = locFilePath.substring(0, locPos); @@ -1108,33 +1001,25 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ node.scaleY = json[ccs.CONST_A_SCALE_Y] == null ? 1 : json[ccs.CONST_A_SCALE_Y]; var colorDic; - if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) - { + if (dataInfo.cocoStudioVersion < ccs.VERSION_COLOR_READING) { colorDic = json[0]; - if (colorDic) - { + if (colorDic){ node.a = colorDic[ccs.CONST_A_ALPHA] == null ? 255 : colorDic[ccs.CONST_A_ALPHA]; node.r = colorDic[ccs.CONST_A_RED] == null ? 255 : colorDic[ccs.CONST_A_RED]; node.g = colorDic[ccs.CONST_A_GREEN] == null ? 255 : colorDic[ccs.CONST_A_GREEN]; node.b = colorDic[ccs.CONST_A_BLUE] == null ? 255 : colorDic[ccs.CONST_A_BLUE]; - node.isUseColorInfo = true; } - } - else - { + } else { colorDic = json[ccs.CONST_COLOR_INFO] || null; - if (colorDic) - { + if (colorDic){ node.a = colorDic[ccs.CONST_A_ALPHA] == null ? 255 : colorDic[ccs.CONST_A_ALPHA]; node.r = colorDic[ccs.CONST_A_RED] == null ? 255 : colorDic[ccs.CONST_A_RED]; node.g = colorDic[ccs.CONST_A_GREEN] == null ? 255 : colorDic[ccs.CONST_A_GREEN]; node.b = colorDic[ccs.CONST_A_BLUE] == null ? 255 : colorDic[ccs.CONST_A_BLUE]; - node.isUseColorInfo = true; } } - }, clear: function () { @@ -1143,13 +1028,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ this._asyncRefTotalCount = 0; }, - _asyncCallBack: function (target, selector, percent) { - if(selector && typeof target === 'function'){ - target.call(selector, percent); - } - if(selector && typeof target === 'string'){ - selector[target](percent); - } + _asyncCallBack: function (selector, target, percent) { + if(selector && typeof selector === 'function') + selector.call(target, percent); + if(target && selector && typeof selector === 'string') + target[selector](percent); }, /** * find the base file path @@ -1175,9 +1058,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (!xmlStr) throw "Please load the resource first : " + xml; var skeletonXML = cc.saxParser.parse(xmlStr); var skeleton = skeletonXML.documentElement; - if (skeleton) { + if (skeleton) this.addDataFromCache(skeleton, dataInfo); - } }, addDataFromJson: function (filePath, dataInfo) { From 519cd640932539a891463d17a927b3a2c3408043 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 1 Aug 2014 11:53:02 +0800 Subject: [PATCH 0372/1564] Issue #5702: Correct a mistake of CCArmatureDataManager --- .../cocostudio/armature/utils/CCArmatureDataManager.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 4ed785dffa..fde1769328 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -261,8 +261,8 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ switch(arguments.length){ case 3: configFilePath = arguments[0]; - target = arguments[1]; - selector = arguments[2]; + target = arguments[2]; + selector = arguments[1]; this.addRelativeData(configFilePath); this._autoLoadSpriteFile = true; ccs.dataReaderHelper.addDataFromFileAsync("", "", configFilePath, selector,target); @@ -276,10 +276,9 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ this.addRelativeData(configFilePath); this._autoLoadSpriteFile = false; - ccs.dataReaderHelper.addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector); + ccs.dataReaderHelper.addDataFromFileAsync(imagePath, plistPath, configFilePath, selector, target); this.addSpriteFrameFromFile(plistPath, imagePath); } - }, /** From f7adb8dd68ea7ee060a9582a49fd075617f0a2c1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 1 Aug 2014 14:27:57 +0800 Subject: [PATCH 0373/1564] Issue #5702: correct a mistake of cc.Armature that its anchorPoint is wrong. --- CCDebugger.js | 1 + cocos2d/core/base-nodes/CCNode.js | 20 ++- extensions/cocostudio/armature/CCArmature.js | 164 +------------------ 3 files changed, 17 insertions(+), 168 deletions(-) diff --git a/CCDebugger.js b/CCDebugger.js index 97f7d9131e..dabf228c84 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -59,6 +59,7 @@ cc._LogInfos = { Node_addChild_2: "child already added. It can't be added again", Node_addChild_3: "child must be non-null", Node_removeFromParentAndCleanup: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead", + Node_boundingBox: "boundingBox is deprecated. Use getBoundingBox instead", Node_removeChildByTag: "argument tag is an invalid tag", Node_removeChildByTag_2: "cocos2d: removeChildByTag(tag = %s): child not found!", Node_removeAllChildrenWithCleanup: "removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead", diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 63af0a23d0..c0f683f836 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1104,6 +1104,16 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } }, + /** + * Returns a "local" axis aligned bounding box of the node.
    + * @deprecated + * @return {cc.Rect} + */ + boundingBox: function(){ + cc.log(cc._LogInfos.Node_boundingBox); + return this.getBoundingBox(); + }, + /** * Returns a "local" axis aligned bounding box of the node.
    * The returned box is relative only to its parent. @@ -1212,7 +1222,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } child.setParent(this); - child.setOrderOfArrival(this.s_globalOrderOfArrival++); + child.setOrderOfArrival(cc.s_globalOrderOfArrival++); if( this._running ){ child.onEnter(); @@ -1234,14 +1244,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, - getName: function(){ - return this._name; - }, - - setName: function(name){ - this._name = name; - }, - // composition: REMOVE /** * Remove itself from its parent node. If cleanup is true, then also remove all actions and callbacks.
    diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 72c9b2a46b..10e45965b4 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -295,7 +295,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._anchorPointInPoints.y = contentSize.height * locAnchorPoint.y - this._offsetPoint.y; this._realAnchorPointInPoints.x = contentSize.width * locAnchorPoint.x; - this._realAnchorPointInPoints.x = contentSize.height * locAnchorPoint.y; + this._realAnchorPointInPoints.y = contentSize.height * locAnchorPoint.y; this._transformDirty = this._inverseDirty = true; } }, @@ -397,156 +397,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.unscheduleUpdate(); }, - _getNodeToParentTransformForWebGL: function () { - if (this._transformDirty) { - this._armatureTransformDirty = true; - // Translate values - var x = this._position.x; - var y = this._position.y; - var apx = this._anchorPointInPoints.x, napx = -apx; - var apy = this._anchorPointInPoints.y, napy = -apy; - var scx = this._scaleX, scy = this._scaleY; - - if (this._ignoreAnchorPointForPosition) { - x += apx; - y += apy; - } - - // Rotation values - // Change rotation code to handle X and Y - // If we skew with the exact same value for both x and y then we're simply just rotating - var cx = 1, sx = 0, cy = 1, sy = 0; - if (this._rotationX !== 0 || this._rotationY !== 0) { - cx = Math.cos(-this._rotationRadiansX); - sx = Math.sin(-this._rotationRadiansX); - cy = Math.cos(-this._rotationRadiansY); - sy = Math.sin(-this._rotationRadiansY); - } - - // Add offset point - x += cy * this._offsetPoint.x * this._scaleX + -sx * this._offsetPoint.y * this._scaleY; - y += sy * this._offsetPoint.x * this._scaleX + cx * this._offsetPoint.y * this._scaleY; - - var needsSkewMatrix = ( this._skewX || this._skewY ); - - // optimization: - // inline anchor point calculation if skew is not needed - // Adjusted transform calculation for rotational skew - if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { - x += cy * napx * scx + -sx * napy * scy; - y += sy * napx * scx + cx * napy * scy; - } - - // Build Transform Matrix - // Adjusted transform calculation for rotational skew - var t = this._transform; - t.a = cy * scx; - t.b = sy * scx; - t.c = -sx * scy; - t.d = cx * scy; - t.tx = x; - t.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); - - // adjust anchor point - if (apx !== 0 || apy !== 0) - t = cc.affineTransformTranslate(t, napx, napy); - } - - if (this._additionalTransformDirty) { - t = cc.affineTransformConcat(t, this._additionalTransform); - this._additionalTransformDirty = false; - } - this._transform = t; - this._transformDirty = false; - } - return this._transform; - }, - - _getNodeToParentTransformForCanvas: function () { - if (!this._transform) - 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 - // base position - t.tx = this._position.x; - t.ty = this._position.y; - - // rotation Cos and Sin - var Cos = 1, Sin = 0; - if (this._rotationX) { - Cos = Math.cos(-this._rotationRadiansX); - Sin = Math.sin(-this._rotationRadiansX); - } - - // base abcd - t.a = t.d = Cos; - t.c = -Sin; - t.b = Sin; - - var lScaleX = this._scaleX, lScaleY = this._scaleY; - var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; - - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - - // Add offset point - t.tx += Cos * this._offsetPoint.x * lScaleX + -Sin * this._offsetPoint.y * lScaleY; - t.ty += Sin * this._offsetPoint.x * lScaleX + Cos * this._offsetPoint.y * lScaleY; - - // skew - if (this._skewX || this._skewY) { - // offset the anchorpoint - var skx = Math.tan(-this._skewX * Math.PI / 180); - var sky = Math.tan(-this._skewY * Math.PI / 180); - var xx = appY * skx * sx; - var yy = appX * sky * sy; - t.a = Cos + -Sin * sky; - t.c = Cos * skx + -Sin; - t.b = Sin + Cos * sky; - t.d = Sin * skx + Cos; - t.tx += Cos * xx + -Sin * yy; - t.ty += Sin * xx + Cos * yy; - } - - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.b *= sx; - t.c *= sy; - t.d *= sy; - } - - // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * -appY * sy; - t.ty += Sin * -appX * sx + Cos * -appY * sy; - - // if ignore anchorPoint - if (this._ignoreAnchorPointForPosition) { - t.tx += appX; - t.ty += appY; - } - - if (this._additionalTransformDirty) { - this._transform = cc.affineTransformConcat(this._transform, this._additionalTransform); - this._additionalTransformDirty = false; - } - - t.tx = t.tx | 0; - t.ty = t.ty | 0; - this._transformDirty = false; - } - return this._transform; - }, - visit: null, _visitForCanvas: function(ctx){ @@ -798,14 +648,10 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }); if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - //WebGL - ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForWebGL; - ccs.Armature.prototype.getNodeToParentTransform = ccs.Armature.prototype._getNodeToParentTransformForWebGL; - } else { - //Canvas - ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForCanvas; - ccs.Armature.prototype.getNodeToParentTransform = ccs.Armature.prototype._getNodeToParentTransformForCanvas; - } + ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForWebGL; +} else { + ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForCanvas; +} var _p = ccs.Armature.prototype; From f895042c1083d91fb574b33880609dd44582531e Mon Sep 17 00:00:00 2001 From: joshuastray Date: Fri, 1 Aug 2014 15:34:27 +0800 Subject: [PATCH 0374/1564] Refactor #5684 : Add 2.x createWithXXX functions to support old API, deprecate all create.* functions --- cocos2d/actions/CCAction.js | 3 ++ cocos2d/actions/CCActionCamera.js | 1 + cocos2d/actions/CCActionCatmullRom.js | 5 ++- cocos2d/actions/CCActionEase.js | 38 +++++++++++++++++++ cocos2d/actions/CCActionInstant.js | 8 ++++ cocos2d/actions/CCActionInterval.js | 27 +++++++++++++ cocos2d/actions/CCActionTween.js | 6 +-- cocos2d/actions3d/CCActionGrid.js | 5 +++ cocos2d/actions3d/CCActionGrid3D.js | 9 +++++ cocos2d/actions3d/CCActionPageTurn3D.js | 1 + cocos2d/actions3d/CCActionTiledGrid.js | 12 ++++++ cocos2d/clipping-nodes/CCClippingNode.js | 1 + cocos2d/core/base-nodes/CCAtlasNode.js | 1 + cocos2d/core/base-nodes/CCNode.js | 2 +- cocos2d/core/labelttf/CCLabelTTF.js | 6 +++ cocos2d/core/layers/CCLayer.js | 4 ++ cocos2d/core/scenes/CCScene.js | 1 + cocos2d/core/sprites/CCAnimation.js | 8 ++++ cocos2d/core/sprites/CCSprite.js | 18 ++++++++- cocos2d/core/sprites/CCSpriteBatchNode.js | 7 ++++ cocos2d/core/sprites/CCSpriteFrame.js | 7 ++++ cocos2d/core/textures/CCTextureAtlas.js | 7 ++++ cocos2d/effects/CCGrid.js | 3 ++ cocos2d/labels/CCLabelAtlas.js | 1 + cocos2d/labels/CCLabelBMFont.js | 1 + cocos2d/menus/CCMenu.js | 1 + cocos2d/menus/CCMenuItem.js | 7 ++++ cocos2d/motion-streak/CCMotionStreak.js | 1 + cocos2d/node-grid/CCNodeGrid.js | 1 + cocos2d/parallax/CCParallaxNode.js | 1 + cocos2d/particle/CCParticleBatchNode.js | 1 + cocos2d/particle/CCParticleExamples.js | 11 ++++++ cocos2d/particle/CCParticleSystem.js | 7 ++++ cocos2d/physics/CCPhysicsSprite.js | 13 +++++++ .../progress-timer/CCActionProgressTimer.js | 2 + cocos2d/progress-timer/CCProgressTimer.js | 1 + cocos2d/render-texture/CCRenderTexture.js | 1 + cocos2d/shaders/CCGLProgram.js | 1 + cocos2d/shape-nodes/CCDrawNode.js | 1 + cocos2d/text-input/CCTextFieldTTF.js | 1 + cocos2d/tilemap/CCTMXLayer.js | 1 + cocos2d/tilemap/CCTMXTiledMap.js | 1 + cocos2d/tilemap/CCTMXXMLParser.js | 1 + cocos2d/tilemap/CCTileMapAtlas.js | 1 + cocos2d/transitions/CCTransition.js | 28 ++++++++++++++ cocos2d/transitions/CCTransitionPageTurn.js | 1 + cocos2d/transitions/CCTransitionProgress.js | 7 ++++ .../ccui/base-classes/CCProtectedNode.js | 1 + extensions/ccui/base-classes/UIWidget.js | 2 +- extensions/ccui/layouts/UILayout.js | 2 +- .../uiwidgets/scroll-widget/UIListView.js | 2 +- .../uiwidgets/scroll-widget/UIScrollView.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 1 + extensions/editbox/CCEditBox.js | 35 +++++++++-------- .../gui/control-extension/CCControlButton.js | 7 ++++ .../CCControlColourPicker.js | 4 ++ .../control-extension/CCControlHuePicker.js | 20 ++++++++-- .../CCControlPotentiometer.js | 7 ++++ .../CCControlSaturationBrightnessPicker.js | 19 ++++++++-- .../gui/control-extension/CCControlSlider.js | 2 +- .../gui/control-extension/CCControlStepper.js | 7 ++++ .../gui/control-extension/CCControlSwitch.js | 4 +- .../gui/control-extension/CCScale9Sprite.js | 13 +++++++ extensions/gui/scrollview/CCScrollView.js | 26 +++++++------ extensions/gui/scrollview/CCTableView.js | 22 +++++++---- 65 files changed, 395 insertions(+), 53 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 95350328da..1cd844d00c 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -182,6 +182,7 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ /** Allocates and initializes the action * @returns {cc.Action} * @example + * @deprecated * // example * var action = cc.Action.create(); */ @@ -365,6 +366,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ * @param {cc.ActionInterval} action * @param {Number} speed * @return {cc.Speed} + * @deprecated */ cc.Speed.create = function (action, speed) { return new cc.Speed(action, speed); @@ -557,6 +559,7 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ * @param {cc.Node} followedNode * @param {cc.Rect} rect * @return {cc.Follow|Null} returns the cc.Follow object on success + * @deprecated * @example * // example * // creates the action with a set boundary diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 267baef4a3..1a5402c5ae 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -227,6 +227,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ * @param {Number} angleX * @param {Number} deltaAngleX * @return {cc.OrbitCamera} + * @deprecated */ cc.OrbitCamera.create = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) { return new cc.OrbitCamera(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX); diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index c432e4d0da..03fefd43b5 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -271,6 +271,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * * @param {Array} points array of control points * @param {Number} tension * @return {cc.CardinalSplineTo} + * @deprecated * * @example * //create a cc.CardinalSplineTo @@ -387,6 +388,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# * @param {Array} points * @param {Number} tension * @return {cc.CardinalSplineBy} + * @deprecated */ cc.CardinalSplineBy.create = function (duration, points, tension) { return new cc.CardinalSplineBy(duration, points, tension); @@ -447,6 +449,7 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{ * @param {Number} dt * @param {Array} points * @return {cc.CatmullRomTo} + * @deprecated * * @example * var action1 = cc.CatmullRomTo.create(3, array); @@ -508,7 +511,7 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({ /** * Creates an action with a Cardinal Spline array of points and tension - * + * @deprecated * @example * var action1 = cc.CatmullRomBy.create(3, array); */ diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 80ce8f69f5..1b639e5dca 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -106,6 +106,7 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ /** creates the action of ActionEase * @param {cc.ActionInterval} action * @return {cc.ActionEase} + * @deprecated * @example * // example * var moveEase = cc.ActionEase.create(action); @@ -185,6 +186,7 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseRateAction} + * @deprecated * @example * // example * var moveEaseRateAction = cc.EaseRateAction.create(action, 3.0); @@ -221,6 +223,7 @@ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ }); /** Creates the action with the inner action and the rate parameter + * @deprecated * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseIn} @@ -272,6 +275,7 @@ cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ }); /** Creates the action with the inner action and the rate parameter + * @deprecated * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseOut} @@ -327,6 +331,7 @@ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ }); /** Creates the action with the inner action and the rate parameter + * @deprecated * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseInOut} @@ -382,6 +387,7 @@ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ }); /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseExponentialIn} * @example @@ -432,6 +438,7 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# * }); /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseExponentialOut} * @example @@ -489,6 +496,7 @@ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOu }); /** creates an EaseExponentialInOut action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseExponentialInOut} * @example @@ -547,6 +555,7 @@ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ }); /** creates an EaseSineIn action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseSineIn} * @example @@ -598,6 +607,7 @@ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ }); /** creates an EaseSineOut action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseSineOut} * @example @@ -649,6 +659,7 @@ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ }); /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseSineInOut} * @example @@ -736,6 +747,7 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ }); /** Creates the action with the inner action and the period in radians (default is 0.3) + * @deprecated * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElastic} @@ -784,6 +796,7 @@ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ }); /** Creates the action with the inner action and the period in radians (default is 0.3) + * @deprecated * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticIn} @@ -866,6 +879,7 @@ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ }); /** Creates the action with the inner action and the period in radians (default is 0.3) + * @deprecated * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticOut} @@ -947,6 +961,7 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ }); /** Creates the action with the inner action and the period in radians (default is 0.3) + * @deprecated * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticInOut} @@ -1026,6 +1041,7 @@ cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{ }); /** creates an ease bounce action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounce} * @example @@ -1066,6 +1082,7 @@ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ }); /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounceIn} * @example @@ -1133,6 +1150,7 @@ cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{ }); /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounceOut} * @example @@ -1191,6 +1209,7 @@ cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ }); /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounceInOut} * @example @@ -1253,6 +1272,7 @@ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBackIn} * @example @@ -1308,6 +1328,7 @@ cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ }); /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBackOut} * @example @@ -1370,6 +1391,7 @@ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ /** creates the action + * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBackInOut} * @example @@ -1444,6 +1466,7 @@ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionIn} */ @@ -1491,6 +1514,7 @@ cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActio /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionIn} */ @@ -1534,6 +1558,7 @@ cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActi /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1583,6 +1608,7 @@ cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticAc /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1624,6 +1650,7 @@ cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1666,6 +1693,7 @@ cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOu /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1711,6 +1739,7 @@ cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticAction /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1752,6 +1781,7 @@ cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1794,6 +1824,7 @@ cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOu /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1839,6 +1870,7 @@ cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticAction /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1880,6 +1912,7 @@ cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# * /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1922,6 +1955,7 @@ cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1967,6 +2001,7 @@ cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -2008,6 +2043,7 @@ cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{ /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -2050,6 +2086,7 @@ cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# * /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -2096,6 +2133,7 @@ cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOu /** * creates the action + * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} */ diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index c5bbb0d5c5..cc88440eb2 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -85,6 +85,7 @@ cc.Show = cc.ActionInstant.extend(/** @lends cc.Show# */{ } }); /** + * @deprecated * @return {cc.Show} * @example * // example @@ -119,6 +120,7 @@ cc.Hide = cc.ActionInstant.extend(/** @lends cc.Hide# */{ } }); /** + * @deprecated * @return {cc.Hide} * @example * // example @@ -154,6 +156,7 @@ cc.ToggleVisibility = cc.ActionInstant.extend(/** @lends cc.ToggleVisibility# */ }); /** + * @deprecated * @return {cc.ToggleVisibility} * @example * // example @@ -203,6 +206,7 @@ cc.RemoveSelf = cc.ActionInstant.extend({ /** * Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. * + * @deprecated * @param {Boolean} [isNeedCleanUp=true] * @return {cc.RemoveSelf} * @@ -270,6 +274,7 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ /** * Create a FlipX action to flip or unflip the target * + * @deprecated * @param {Boolean} flip Indicate whether the target should be flipped or not * @return {cc.FlipX} * @example @@ -334,6 +339,7 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{ /** * Create a FlipY action to flip or unflip the target * + * @deprecated * @param {Boolean} flip * @return {cc.FlipY} * @example @@ -401,6 +407,7 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ }); /** * Creates a Place action with a position + * @deprecated * @param {cc.Point|Number} pos * @param {Number} [y] * @return {cc.Place} @@ -515,6 +522,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ }); /** * Creates the action with the callback + * @deprecated * @param {function} selector * @param {object|null} [selectorTarget] * @param {*|null} [data] data for function, it accepts all data types. diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 4724475d58..1fc7d86c56 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -287,6 +287,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }); /** + * @deprecated * @param {Number} d duration in seconds * @return {cc.ActionInterval} * @example @@ -445,6 +446,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ } }); /** helper constructor to create an array of sequenceable actions + * @deprecated * @param {Array|cc.FiniteTimeAction} tempArray * @return {cc.Sequence} * @example @@ -632,6 +634,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ }); /** * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + * @deprecated * @param {cc.FiniteTimeAction} action * @param {Number} times * @return {cc.Repeat} @@ -750,6 +753,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }); /** * Create a acton which repeat forever + * @deprecated * @param {cc.FiniteTimeAction} action * @return {cc.RepeatForever} * @example @@ -878,6 +882,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ }); /** + * @deprecated * @param {Array|cc.FiniteTimeAction}tempArray * @return {cc.FiniteTimeAction} * @example @@ -1013,6 +1018,7 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ /** * Creates a RotateTo action with separate rotation angles + * @deprecated * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees. * @param {Number} [deltaAngleY] deltaAngleY in degrees. @@ -1108,6 +1114,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }); /** + * @deprecated * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY] deltaAngleY in degrees @@ -1237,6 +1244,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ }); /** + * @deprecated * @param {Number} duration duration in seconds * @param {cc.Point|Number} deltaPos * @param {Number} deltaY @@ -1316,6 +1324,7 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ } }); /** + * @deprecated * @param {Number} duration duration in seconds * @param {cc.Point} position * @param {Number} y @@ -1415,6 +1424,7 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ } }); /** + * @deprecated * @param {Number} t time in seconds * @param {Number} sx * @param {Number} sy @@ -1493,6 +1503,7 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ } }); /** + * @deprecated * @param {Number} t time in seconds * @param {Number} sx sx skew in degrees for X axis * @param {Number} sy sy skew in degrees for Y axis @@ -1630,6 +1641,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ }); /** + * @deprecated * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -1714,6 +1726,7 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ }); /** + * @deprecated * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -1868,6 +1881,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ }); /** + * @deprecated * @param {Number} t time in seconds * @param {Array} c Array of points * @return {cc.BezierBy} @@ -1941,6 +1955,7 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ } }); /** + * @deprecated * @param {Number} t * @param {Array} c array of points * @return {cc.BezierTo} @@ -2035,6 +2050,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ } }); /** + * @deprecated * @param {Number} duration * @param {Number} sx scale parameter in X * @param {Number} [sy] scale parameter in Y, if Null equal to sx @@ -2088,6 +2104,7 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ } }); /** + * @deprecated * @param {Number} duration duration in seconds * @param {Number} sx sx scale parameter in X * @param {Number|Null} [sy=] sy scale parameter in Y, if Null equal to sx @@ -2180,6 +2197,7 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ } }); /** + * @deprecated * @param {Number} duration duration in seconds * @param blinks blinks in times * @return {cc.Blink} @@ -2258,6 +2276,7 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ }); /** + * @deprecated * @param {Number} duration * @param {Number} opacity 0-255, 0 is transparent * @return {cc.FadeTo} @@ -2319,6 +2338,7 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ }); /** + * @deprecated * @param {Number} duration duration in seconds * @return {cc.FadeIn} * @example @@ -2371,6 +2391,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ }); /** + * @deprecated * @param {Number} d duration in seconds * @return {cc.FadeOut} * @example @@ -2458,6 +2479,7 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ }); /** + * @deprecated * @param {Number} duration * @param {Number} red 0-255 * @param {Number} green 0-255 @@ -2564,6 +2586,7 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ }); /** + * @deprecated * @param {Number} duration duration in seconds * @param {Number} deltaRed * @param {Number} deltaGreen @@ -2611,6 +2634,7 @@ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ }); /** + * @deprecated * @param {Number} d duration in seconds * @return {cc.DelayTime} * @example @@ -2710,6 +2734,7 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ }); /** + * @deprecated * @param {cc.FiniteTimeAction} action * @return {cc.ReverseTime} * @example @@ -2887,6 +2912,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ /** * create the animate with animation + * @deprecated * @param {cc.Animation} animation * @return {cc.Animate} * @example @@ -2981,6 +3007,7 @@ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{ /** * Create an action with the specified action and forced target + * @deprecated * @param {cc.Node} target * @param {cc.FiniteTimeAction} action * @return {cc.TargetedAction} diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index 1107c3d8d4..bae2ca0384 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -125,6 +125,7 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ /** * Creates an initializes the action with the property name (key), and the from and to parameters. + * @deprecated * @param {Number} duration * @param {String} key * @param {Number} from @@ -132,10 +133,7 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ * @return {cc.ActionTween} */ cc.ActionTween.create = function (duration, key, from, to) { - var ret = new cc.ActionTween(); - if (ret.initWithDuration(duration, key, from, to)) - return ret; - return null; + return new cc.ActionTween(duration, key, from, to); }; cc.action = cc.Action.create; diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index 36e03617b7..20dd62a3f5 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -101,6 +101,7 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ /** * creates the action with size and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.GridAction} @@ -155,6 +156,7 @@ cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{ /** * creates the action with size and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.Grid3DAction} @@ -208,6 +210,7 @@ cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{ /** * Creates the action with duration and grid size + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.TiledGrid3DAction} @@ -237,6 +240,7 @@ cc.StopGrid = cc.ActionInstant.extend(/** @lends cc.StopGrid# */{ /** * Allocates and initializes the action + * @deprecated * @return {cc.StopGrid} */ cc.StopGrid.create = function () { @@ -280,6 +284,7 @@ cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{ /** * creates an action with the number of times that the current grid will be reused + * @deprecated * @param {Number} times * @return {cc.ReuseGrid} */ diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index 2945f6a411..630fe8a9af 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -115,6 +115,7 @@ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ /** * Create a wave 3d action with duration, grid size, waves and amplitude + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -231,6 +232,7 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ /** * Create a Flip X 3D action with duration + * @deprecated * @param {Number} duration * @return {cc.FlipX3D} */ @@ -322,6 +324,7 @@ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ /** * Create a flip Y 3d action with duration + * @deprecated * @param {Number} duration * @return {cc.FlipY3D} */ @@ -467,6 +470,7 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ /** * creates a lens 3d action with center position, radius + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -606,6 +610,7 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ /** * creates a ripple 3d action with radius, number of waves, amplitude + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -678,6 +683,7 @@ cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{ /** * creates the action with a range, shake Z vertices, a grid and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -780,6 +786,7 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ /** * creates the action with amplitude, a grid and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -893,6 +900,7 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ /** * initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -1026,6 +1034,7 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ /** * creates the action with center position, number of twirls, amplitude, a grid size and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position diff --git a/cocos2d/actions3d/CCActionPageTurn3D.js b/cocos2d/actions3d/CCActionPageTurn3D.js index 1658230f96..2e41fde481 100644 --- a/cocos2d/actions3d/CCActionPageTurn3D.js +++ b/cocos2d/actions3d/CCActionPageTurn3D.js @@ -93,6 +93,7 @@ cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{ /** * create PageTurn3D action + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.PageTurn3D} diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index a4981dded6..4d6301a479 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -99,6 +99,7 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ /** * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -188,6 +189,7 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D /** * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -360,6 +362,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ /** * creates the action with a random seed, the grid size and the duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} seed @@ -450,6 +453,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ /** * creates the action with the grid size and the duration + * @deprecated * @param duration * @param gridSize * @return {cc.FadeOutTRTiles} @@ -480,6 +484,7 @@ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{ /** * creates the action with the grid size and the duration + * @deprecated * @param duration * @param gridSize * @return {cc.FadeOutBLTiles} @@ -516,6 +521,7 @@ cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{ /** * creates the action with the grid size and the duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutUpTiles} @@ -540,6 +546,7 @@ cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend(/** @lends cc.FadeOutDownTiles# * /** * creates the action with the grid size and the duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutDownTiles} @@ -655,6 +662,7 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ /** * creates the action with a random seed, the grid size and the duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number|Null} [seed=0] @@ -765,6 +773,7 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ /** * creates the action with a number of waves, the waves amplitude, the grid size and the duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -883,6 +892,7 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ /** * creates the action with the number of jumps, the sin amplitude, the grid size and the duration + * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} numberOfJumps @@ -952,6 +962,7 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ /** * creates the action with the number of rows to split and the duration + * @deprecated * @param {Number} duration * @param {Number} rows * @return {cc.SplitRows} @@ -1021,6 +1032,7 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ /** * creates the action with the number of columns to split and the duration + * @deprecated * @param {Number} duration * @param {Number} cols * @return {cc.SplitCols} diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 11735b7cca..6a741ebe2e 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -514,6 +514,7 @@ cc.ClippingNode._getSharedCache = function () { /** * Creates and initializes a clipping node with an other node as its stencil.
    * The stencil node will be retained. + * @deprecated * @param {cc.Node} [stencil=null] * @return {cc.ClippingNode} */ diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 52bc85ec1a..8137fbce74 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -463,6 +463,7 @@ _p.quadsToDraw; /** creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render + * @deprecated * @param {String} tile * @param {Number} tileWidth * @param {Number} tileHeight diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 77177c6e5b..ad85e68de8 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2358,7 +2358,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * allocates and initializes a node. - * @constructs + * @deprecated * @return {cc.Node} * @example * // example diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 8fb993ebe4..5b9be1d8fa 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1169,6 +1169,7 @@ cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; /** * creates a cc.LabelTTF from a font name, alignment, dimension and font size + * @deprecated * @param {String} text * @param {String|cc.FontDefinition} [fontName="Arial"] * @param {Number} [fontSize=16] @@ -1190,6 +1191,11 @@ cc.LabelTTF.create = function (text, fontName, fontSize, dimensions, hAlignment, return new cc.LabelTTF(text, fontName, fontSize, dimensions, hAlignment, vAlignment); }; +/** + * @deprecated + * @type {Function} + */ +cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create; if (cc.USE_LA88_LABELS) cc.LabelTTF._SHADER_PROGRAM = cc.SHADER_POSITION_TEXTURECOLOR; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 655d83c6c4..f7896579d7 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -83,6 +83,7 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ /** * creates a layer + * @deprecated * @example * // Example * var myLayer = cc.Layer.create(); @@ -361,6 +362,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ /** * creates a cc.Layer with color, width and height in Points + * @deprecated * @param {cc.Color} color * @param {Number|Null} [width=] * @param {Number|Null} [height=] @@ -730,6 +732,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ /** * creates a gradient layer + * @deprecated * @param {cc.Color} start starting color * @param {cc.Color} end ending color * @param {cc.Point|Null} v @@ -875,6 +878,7 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ /** * creates a cc.LayerMultiplex with one or more layers using a variable argument list. + * @deprecated * @return {cc.LayerMultiplex|Null} * @example * // Example diff --git a/cocos2d/core/scenes/CCScene.js b/cocos2d/core/scenes/CCScene.js index bdee48559f..8378171707 100644 --- a/cocos2d/core/scenes/CCScene.js +++ b/cocos2d/core/scenes/CCScene.js @@ -52,6 +52,7 @@ cc.Scene = cc.Node.extend(/** @lends cc.Scene# */{ /** * creates a scene + * @deprecated * @return {cc.Scene} * @example * // Example diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index 178cd63266..2d500873f3 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -134,6 +134,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ /** * Creates an animation frame. + * @deprecated * @param {cc.SpriteFrame} spriteFrame * @param {Number} delayUnits * @param {object} userInfo @@ -428,6 +429,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ /** * Creates an animation. + * @deprecated * @param {Array} frames * @param {Number} delay * @param {Number} [loops=1] @@ -458,3 +460,9 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ cc.Animation.create = function (frames, delay, loops) { return new cc.Animation(frames, delay, loops); }; + +/** + * @deprecated + * @type {Function} + */ +cc.Animation.createWithAnimationFrames = cc.Animation.create; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 1a0bfc8426..41f1b214be 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1125,7 +1125,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ /** * Create a sprite with image path or frame name or texture or spriteFrame. - * @constructs + * @deprecated * @param {String|cc.SpriteFrame|HTMLImageElement|cc.Texture2D} fileName The string which indicates a path to image file, e.g., "scene1/monster.png". * @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite. * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. @@ -1154,7 +1154,23 @@ cc.Sprite.create = function (fileName, rect, rotated) { return new cc.Sprite(fileName, rect, rotated); }; +/** + * @deprecated + * @type {Function} + */ +cc.Sprite.createWithTexture = cc.Sprite.create; +/** + * @deprecated + * @type {Function} + */ +cc.Sprite.createWithSpriteFrameName = cc.Sprite.create; + +/** + * @deprecated + * @type {Function} + */ +cc.Sprite.createWithSpriteFrame = cc.Sprite.create; /** * cc.Sprite invalid index on the cc.SpriteBatchNode * @constant diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index e9aff59993..45bea9c6b7 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -1114,6 +1114,7 @@ cc.defineGetterSetter(_p, "descendants", _p.getDescendants); * The capacity will be increased in 33% in runtime if it run out of space.
    * The file will be loaded using the TextureMgr.
    *

    + * @deprecated * @param {String|cc.Texture2D} fileImage * @param {Number} capacity * @return {cc.SpriteBatchNode} @@ -1129,3 +1130,9 @@ cc.defineGetterSetter(_p, "descendants", _p.getDescendants); cc.SpriteBatchNode.create = function (fileImage, capacity) { return new cc.SpriteBatchNode(fileImage, capacity); }; + +/** + * @deprecated + * @type {Function} + */ +cc.SpriteBatchNode.createWithTexture = cc.SpriteBatchNode.create; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 65c7edf663..d8f60a1807 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -390,6 +390,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * Create a cc.SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
    * The originalSize is the size in pixels of the frame before being trimmed. *

    + * @deprecated * @param {String|cc.Texture2D} filename * @param {cc.Rect} rect if parameters' length equal 2, rect in points, else rect in pixels * @param {Boolean} rotated @@ -412,6 +413,12 @@ cc.SpriteFrame.create = function (filename, rect, rotated, offset, originalSize) return new cc.SpriteFrame(filename,rect,rotated,offset,originalSize); }; +/** + * @deprecated + * @type {Function} + */ +cc.SpriteFrame.createWithTexture = cc.SpriteFrame.create; + cc.SpriteFrame._frameWithTextureForCanvas = function (texture, rect, rotated, offset, originalSize) { var spriteFrame = new cc.SpriteFrame(); spriteFrame._texture = texture; diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index 5dac079e9f..4568cc2596 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -631,6 +631,7 @@ cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads); /** *

    Creates a TextureAtlas with an filename and with an initial capacity for Quads.
    * The TextureAtlas capacity can be increased in runtime.

    + * @deprecated * @param {String|cc.Texture2D} fileName * @param {Number} capacity * @return {cc.TextureAtlas|Null} @@ -647,6 +648,12 @@ cc.TextureAtlas.create = function (fileName, capacity) { return new cc.TextureAtlas(fileName, capacity); }; +/** + * @deprecated + * @type {Function} + */ +cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create; + if (cc._renderType === cc._RENDER_TYPE_WEBGL) { cc.assert(typeof cc._tmp.WebGLTextureAtlas === "function", cc._LogInfos.MissingFile, "TexturesWebGL.js"); cc._tmp.WebGLTextureAtlas(); diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index a07ba5ef69..5393baa638 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -273,6 +273,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ /** * create one cc.GridBase Object + * @deprecated * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] @@ -481,6 +482,7 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ /** * create one Grid3D object + * @deprecated * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] @@ -718,6 +720,7 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ /** * create one TiledGrid3D object + * @deprecated * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 193b2af818..e8ae07a83c 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -393,6 +393,7 @@ cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); * a) string, fntFile
    * b) label, textureFilename, width, height, startChar
    *

    + * @deprecated * @param {String} strText * @param {String} charMapFile charMapFile or fntFile * @param {Number} [itemWidth=0] diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 4e86d0e7ef..1370b9823f 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -984,6 +984,7 @@ cc.defineGetterSetter(_p, "textAlign", _p._getAlignment, _p.setAlignment); /** * creates a bitmap font atlas with an initial string and the FNT file + * @deprecated * @param {String} str * @param {String} fntFile * @param {Number} [width=-1] diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 4b7a5705ff..9ed6de0cd6 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -607,6 +607,7 @@ _p.enabled; /** * create a new menu + * @deprecated * @param {...cc.MenuItem|null} menuItems * @return {cc.Menu} * @example diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index fce4720e95..5add14ac2f 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -183,6 +183,7 @@ cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled); /** * creates an empty menu item with target and callback
    * Not recommended to use the base class, should use more defined menu item classes + * @deprecated * @param {function|String} callback callback * @param {cc.Node} target * @return {cc.MenuItem} @@ -410,6 +411,7 @@ cc.defineGetterSetter(_p, "label", _p.getLabel, _p.setLabel); /** + * @deprecated * @param {cc.Node} label * @param {function|String|Null} [selector=] * @param {cc.Node|Null} [target=] @@ -469,6 +471,7 @@ cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# /** * create menu item from string with font + * @deprecated * @param {String} value the text to display * @param {String} charMapFile the character map file * @param {Number} itemWidth @@ -627,6 +630,7 @@ cc.MenuItemFont.fontName = function () { /** * create a menu item from string + * @deprecated * @param {String} value the text to display * @param {String|function|Null} callback the callback to run, either in function name or pass in the actual function * @param {cc.Node|Null} target the target to run callback @@ -961,6 +965,7 @@ cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledIm /** * create a menu item from sprite + * @deprecated * @param {Image} normalSprite normal state image * @param {Image|Null} selectedSprite selected state image * @param {Image|cc.Node|Null} three disabled state image OR target node @@ -1087,6 +1092,7 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ /** * creates a new menu item image + * @deprecated * @param {String} normalImage file name for normal state * @param {String} selectedImage image for selected state * @param {String|cc.Node} three Disabled image OR callback function @@ -1345,6 +1351,7 @@ cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIn /** * create a simple container class that "toggles" it's inner items
    * The inner items can be any MenuItem + * @deprecated * @return {cc.MenuItemToggle} * @example * // Example diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 9110f5aa5a..c1aadd3f96 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -495,6 +495,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ /** * creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename or texture + * @deprecated * @param {Number} fade time to fade * @param {Number} minSeg minimum segment size * @param {Number} stroke stroke's width diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index ace59b19ea..1d62318e00 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -143,6 +143,7 @@ cc.defineGetterSetter(_p, "target", null, _p.setTarget); /** * Creates a NodeGrid * Implementation cc.NodeGrid + * @deprecated * @return {cc.NodeGrid|null} */ cc.NodeGrid.create = function () { diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index 22ae5920fa..73f587d209 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -222,6 +222,7 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ }); /** + * @deprecated * @return {cc.ParallaxNode} * @example * //example diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index adbdc63f5f..8f6d93e24f 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -552,6 +552,7 @@ cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); /** * initializes the particle system with the name of a file on disk (for a list of supported formats look at the cc.Texture2D class), a capacity of particles + * @deprecated * @param {String|cc.Texture2D} fileImage * @param {Number} capacity * @return {cc.ParticleBatchNode} diff --git a/cocos2d/particle/CCParticleExamples.js b/cocos2d/particle/CCParticleExamples.js index bd6186f033..9d1b22c20b 100644 --- a/cocos2d/particle/CCParticleExamples.js +++ b/cocos2d/particle/CCParticleExamples.js @@ -103,6 +103,7 @@ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{ /** * Create a fire particle system + * @deprecated * @return {cc.ParticleFire} * * @example @@ -189,6 +190,7 @@ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# /** * Create a fireworks particle system + * @deprecated * @return {cc.ParticleFireworks} * * @example @@ -277,6 +279,7 @@ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{ /** * Create a sun particle system + * @deprecated * @return {cc.ParticleSun} * * @example @@ -368,6 +371,7 @@ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{ }); /** * Create a galaxy particle system + * @deprecated * @return {cc.ParticleGalaxy} * * @example @@ -456,6 +460,7 @@ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{ /** * Create a flower particle system + * @deprecated * @return {cc.ParticleFlower} * * @example @@ -548,6 +553,7 @@ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{ /** * Create a meteor particle system + * @deprecated * @return {cc.ParticleMeteor} * * @example @@ -639,6 +645,7 @@ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{ /** * Create a spiral particle system + * @deprecated * @return {cc.ParticleSpiral} * * @example @@ -729,6 +736,7 @@ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# /** * Create an explosion particle system + * @deprecated * @return {cc.ParticleExplosion} * * @example @@ -816,6 +824,7 @@ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{ /** * Create a smoke particle system + * @deprecated * @return {cc.ParticleSmoke} * * @example @@ -907,6 +916,7 @@ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{ /** * Create a snow particle system + * @deprecated * @return {cc.ParticleSnow} * * @example @@ -999,6 +1009,7 @@ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{ /** * Create a rain particle system + * @deprecated * @return {cc.ParticleRain} * * @example diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index faba8b1c03..d052c2ccfe 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2685,6 +2685,7 @@ cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); * This plist files can be create manually or with Particle Designer:
    * http://particledesigner.71squared.com/
    *

    + * @deprecated * @param {String|Number} plistFile * @return {cc.ParticleSystem} */ @@ -2692,6 +2693,12 @@ cc.ParticleSystem.create = function (plistFile) { return new cc.ParticleSystem(plistFile); }; +/** + * @deprecated + * @type {Function} + */ +cc.ParticleSystem.createWithTotalParticles = cc.ParticleSystem.create; + // Different modes /** * Mode A:Gravity + Tangential Accel + Radial Accel diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 2d5e36830c..48c8a54b15 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -366,6 +366,7 @@ /** * Create a PhysicsSprite with filename and rect + * @deprecated * @param {String|cc.Texture2D|cc.SpriteFrame} fileName * @param {cc.Rect} rect * @return {cc.PhysicsSprite} @@ -392,4 +393,16 @@ cc.PhysicsSprite.create = function (fileName, rect) { return new cc.PhysicsSprite(fileName, rect); }; + + /** + * @deprecated + * @type {Function} + */ + cc.PhysicsSprite.createWithSpriteFrameName = cc.PhysicsSprite.create; + + /** + * @deprecated + * @type {Function} + */ + cc.PhysicsSprite.createWithSpriteFrame = cc.PhysicsSprite.create; })(); diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index 7354ca41ad..f29590934d 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -97,6 +97,7 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ }); /** Creates and initializes with a duration and a percent + * @deprecated * @param {Number} duration duration in seconds * @param {Number} percent * @return {cc.ProgressTo} @@ -179,6 +180,7 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ }); /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage + * @deprecated * @param {Number} duration duration in seconds * @param {Number} fromPercentage * @param {Number} toPercentage diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index c9804d31cf..0b8800e7fa 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -933,6 +933,7 @@ cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDire /** * create a progress timer object with image file name that renders the inner sprite according to the percentage + * @deprecated * @param {cc.Sprite} sprite * @return {cc.ProgressTimer} * @example diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 6c93182846..c50883d72f 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -864,6 +864,7 @@ cc.defineGetterSetter(_p, "clearColorVal", _p.getClearColor, _p.setClearColor); /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid + * @deprecated * @param {Number} width * @param {Number} height * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index e8adba7d9f..ed6bb036d1 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -671,6 +671,7 @@ cc.GLProgram = cc.Class.extend({ /** * Create a cc.GLProgram object + * @deprecated * @param {String} vShaderFileName * @param {String} fShaderFileName * @returns {cc.GLProgram} diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 073b874f5d..474f386783 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -1066,6 +1066,7 @@ cc.DrawNode = cc._renderType == cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.Dr /** * Creates a DrawNode + * @deprecated * @return {cc.DrawNode} */ cc.DrawNode.create = function () { diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index 8a993671c3..c5b63f719c 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -415,6 +415,7 @@ cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder); /** * creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size + * @deprecated * @param {String} placeholder * @param {cc.Size} dimensions * @param {Number} alignment diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 0db523312f..4309b93322 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -1092,6 +1092,7 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); /** * Creates a cc.TMXLayer with an tile set info, a layer info and a map info + * @deprecated * @param {cc.TMXTilesetInfo} tilesetInfo * @param {cc.TMXLayerInfo} layerInfo * @param {cc.TMXMapInfo} mapInfo diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index 1300a5a60b..6acb29b6cf 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -436,6 +436,7 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); /** * Creates a TMX Tiled Map with a TMX file or content string. * Implementation cc.TMXTiledMap + * @deprecated * @param {String} tmxFile tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @return {cc.TMXTiledMap|undefined} diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index 909aadb93e..60654a9734 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -894,6 +894,7 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); /** * Creates a TMX Format with a tmx file or content string + * @deprecated * @param {String} tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @return {cc.TMXMapInfo} diff --git a/cocos2d/tilemap/CCTileMapAtlas.js b/cocos2d/tilemap/CCTileMapAtlas.js index ecfb854d56..e01b2d78a6 100644 --- a/cocos2d/tilemap/CCTileMapAtlas.js +++ b/cocos2d/tilemap/CCTileMapAtlas.js @@ -292,6 +292,7 @@ cc.TileMapAtlas = cc.AtlasNode.extend(/** @lends cc.TileMapAtlas# */{ /** *

    Creates a cc.TileMap with a tile file (atlas) with a map file and the width and height of each tile in points.
    * The tile file will be loaded using the TextureMgr.

    + * @deprecated * @param {String} tile * @param {String} mapFile * @param {Number} tileWidth diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 63249140f9..fc0bc58f00 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -229,6 +229,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ }); /** * creates a base transition with duration and incoming scene + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to transit with * @return {cc.TransitionScene|Null} @@ -274,6 +275,7 @@ cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionS /** * creates a base transition with duration and incoming scene + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation @@ -334,6 +336,7 @@ cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZo /** * Creates a Transtion rotation and zoom + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to work with * @return {cc.TransitionRotoZoom} @@ -392,6 +395,7 @@ cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZo /** * creates a scene transition that zooms then jump across the screen, the same for the incoming scene + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionJumpZoom} @@ -454,6 +458,7 @@ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL /** * creates an action that Move in from to the left the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInL} @@ -490,6 +495,7 @@ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI /** * create a scene transition that Move in from to the right the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInR} @@ -526,6 +532,7 @@ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI /** * Move in from to the top the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInT} @@ -563,6 +570,7 @@ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI /** * create a scene transition that Move in from to the bottom the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInB} @@ -644,6 +652,7 @@ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideI /** * create a transition that a new scene is slided from left + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInL} @@ -690,6 +699,7 @@ cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli /** * create Slide in the incoming scene from the right border. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInR} @@ -738,6 +748,7 @@ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli /** * create a Slide in the incoming scene from the bottom border. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInB} @@ -786,6 +797,7 @@ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli /** * create a Slide in the incoming scene from the top border. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInT} @@ -849,6 +861,7 @@ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShri /** * Shrink the outgoing scene while grow the incoming scene + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionShrinkGrow} @@ -921,6 +934,7 @@ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF /** * Flips the screen horizontally.
    * The front face is the outgoing scene and the back face is the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -996,6 +1010,7 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF /** * Flips the screen vertically.
    * The front face is the outgoing scene and the back face is the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1071,6 +1086,7 @@ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.Trans /** * Flips the screen half horizontally and half vertically.
    * The front face is the outgoing scene and the back face is the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1152,6 +1168,7 @@ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.Transit /** * Flips the screen horizontally doing a zoom out/in
    * The front face is the outgoing scene and the back face is the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1231,6 +1248,7 @@ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.Transit /** * Flips the screen vertically doing a little zooming out/in
    * The front face is the outgoing scene and the back face is the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1309,6 +1327,7 @@ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.T /** * Flips the screen half horizontally and half vertically doing a little zooming out/in.
    * The front face is the outgoing scene and the back face is the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1392,6 +1411,7 @@ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ /** * Fade out the outgoing scene and then fade in the incoming scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.Color} color @@ -1504,6 +1524,7 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross /** * Cross fades two scenes using the cc.RenderTexture object. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionCrossFade} @@ -1561,6 +1582,7 @@ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTu /** * Turn off the tiles of the outgoing scene in random order + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionTurnOffTiles} @@ -1622,6 +1644,7 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit /** * The odd columns goes upwards while the even columns goes downwards. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSplitCols} @@ -1659,6 +1682,7 @@ cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionS /** * The odd rows goes to the left while the even rows goes to the right. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSplitRows} @@ -1727,6 +1751,7 @@ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# /** * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeTR} @@ -1766,6 +1791,7 @@ cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# /** * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeBL} @@ -1805,6 +1831,7 @@ cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# /** * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeUp} @@ -1844,6 +1871,7 @@ cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeD /** * Fade the tiles of the outgoing scene from the top to the bottom. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeDown} diff --git a/cocos2d/transitions/CCTransitionPageTurn.js b/cocos2d/transitions/CCTransitionPageTurn.js index 3184248ab1..09cf8c05e2 100644 --- a/cocos2d/transitions/CCTransitionPageTurn.js +++ b/cocos2d/transitions/CCTransitionPageTurn.js @@ -121,6 +121,7 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu * Creates a base transition with duration and incoming scene.
    * If back is true then the effect is reversed to appear as if the incoming
    * scene is being turned from left over the outgoing scene. + * @deprecated * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {Boolean} backwards diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index 60e9ca3fcc..f08a4b948f 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -129,6 +129,7 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre /** * create a cc.TransitionProgress object + * @deprecated * @function * @param {Number} t time * @param {cc.Scene} scene @@ -178,6 +179,7 @@ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.Tran /** * create a cc.TransitionProgressRadialCCW object * @function + * @deprecated * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressRadialCCW} @@ -225,6 +227,7 @@ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.Trans /** * create a cc.TransitionProgressRadialCW object * @function + * @deprecated * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressRadialCW} @@ -277,6 +280,7 @@ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.Tra /** * create a cc.TransitionProgressHorizontal object * @function + * @deprecated * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressHorizontal} @@ -325,6 +329,7 @@ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.Trans /** * create a cc.TransitionProgressVertical object * @function + * @deprecated * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressVertical} @@ -380,6 +385,7 @@ cc.TransitionProgressInOut = cc.TransitionProgress.extend(/** @lends cc.Transiti /** * create a cc.TransitionProgressInOut object * @function + * @deprecated * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressInOut} @@ -427,6 +433,7 @@ cc.TransitionProgressOutIn = cc.TransitionProgress.extend(/** @lends cc.Transiti /** * create a cc.TransitionProgressOutIn object * @function + * @deprecated * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressOutIn} diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 639ea1ee72..2431fb772b 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -432,6 +432,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { /** * create a cc.ProtectedNode object; + * @deprecated */ cc.ProtectedNode.create = function(){ return new cc.ProtectedNode(); diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 0585519704..370df4cfe2 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1517,7 +1517,7 @@ _p = null; /** * allocates and initializes a UIWidget. - * @constructs + * @deprecated * @return {ccui.Widget} * @example * // example diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 5c0ba41cf9..c8096906c6 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1761,7 +1761,7 @@ _p = null; /** * allocates and initializes a UILayout. - * @constructs + * @deprecated * @return {ccui.Layout} * @example * // example diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 9cddc6fabf..8468f82c04 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -504,7 +504,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * allocates and initializes a UIListView. - * @constructs + * @deprecated * @example * // example * var uiPageView = ccui.ListView.create(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index a3276c0ef9..6340007d09 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1693,7 +1693,7 @@ _p = null; /** * allocates and initializes a UIScrollView. - * @constructs + * @deprecated * @return {ccui.ScrollView} * @example * // example diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 3fb48e9969..52528e4750 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -708,6 +708,7 @@ _p = null; /** * allocates and initializes a armature. + * @deprecated * @param {String} name * @param {ccs.Bone} parentBone * @return {ccs.Armature} diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 0c34d3e763..535b7c0690 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -226,14 +226,18 @@ cc.EditBox = cc.ControlButton.extend({ _className: "EditBox", /** - * * Constructor. - * */ - ctor: function (boxSize) { + * @constructor + * @param size + * @param normal9SpriteBg + * @param press9SpriteBg + * @param disabled9SpriteBg + */ + ctor: function (size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) { cc.ControlButton.prototype.ctor.call(this); this._textColor = cc.color.WHITE; this._placeholderColor = cc.color.GRAY; - this.setContentSize(boxSize); + this.setContentSize(size); var tmpDOMSprite = this._domInputSprite = new cc.Sprite(); tmpDOMSprite.draw = function () { }; //redefine draw function @@ -292,13 +296,21 @@ 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 = (size.width - 6) + "px"; + tmpDOMSprite.dom.style.height = (size.height - 6) + "px"; //this._domInputSprite.dom.style.borderWidth = "1px"; //this._domInputSprite.dom.style.borderStyle = "solid"; //this._domInputSprite.dom.style.borderRadius = "8px"; tmpDOMSprite.canvas.remove(); + + if (this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg)) { + if (press9SpriteBg) + this.setBackgroundSpriteForState(press9SpriteBg, cc.CONTROL_STATE_HIGHLIGHTED); + + if (disabled9SpriteBg) + this.setBackgroundSpriteForState(disabled9SpriteBg, cc.CONTROL_STATE_DISABLED); + } }, /** @@ -667,21 +679,14 @@ cc.EditBox.getRect = function (node) { /** * create a edit box with size and background-color or + * @deprecated * @param {cc.Size} size * @param {cc.Scale9Sprite } normal9SpriteBg * @param {cc.Scale9Sprite } [press9SpriteBg] * @param {cc.Scale9Sprite } [disabled9SpriteBg] */ cc.EditBox.create = function (size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) { - var edbox = new cc.EditBox(size); - if (edbox.initWithSizeAndBackgroundSprite(size, normal9SpriteBg)) { - if (press9SpriteBg) - edbox.setBackgroundSpriteForState(press9SpriteBg, cc.CONTROL_STATE_HIGHLIGHTED); - - if (disabled9SpriteBg) - edbox.setBackgroundSpriteForState(disabled9SpriteBg, cc.CONTROL_STATE_DISABLED); - } - return edbox; + return new cc.EditBox(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg); }; diff --git a/extensions/gui/control-extension/CCControlButton.js b/extensions/gui/control-extension/CCControlButton.js index 0a82508ba5..7d2773e1d1 100644 --- a/extensions/gui/control-extension/CCControlButton.js +++ b/extensions/gui/control-extension/CCControlButton.js @@ -674,6 +674,13 @@ cc.defineGetterSetter(_p, "labelAnchor", _p.getLabelAnchorPoint, _p.setLabelAnch _p = null; +/** + * @deprecated + * @param label + * @param backgroundSprite + * @param fontSize + * @returns {ControlButton} + */ cc.ControlButton.create = function (label, backgroundSprite, fontSize) { return new cc.ControlButton(label, backgroundSprite, fontSize); }; diff --git a/extensions/gui/control-extension/CCControlColourPicker.js b/extensions/gui/control-extension/CCControlColourPicker.js index 029173da65..7b5b357532 100644 --- a/extensions/gui/control-extension/CCControlColourPicker.js +++ b/extensions/gui/control-extension/CCControlColourPicker.js @@ -173,6 +173,10 @@ cc.defineGetterSetter(_p, "background", _p.getBackground); _p = null; +/** + * @deprecated + * @returns {ControlColourPicker} + */ cc.ControlColourPicker.create = function () { return new cc.ControlColourPicker(); }; diff --git a/extensions/gui/control-extension/CCControlHuePicker.js b/extensions/gui/control-extension/CCControlHuePicker.js index 92d5097bf2..5a425a3201 100644 --- a/extensions/gui/control-extension/CCControlHuePicker.js +++ b/extensions/gui/control-extension/CCControlHuePicker.js @@ -51,6 +51,16 @@ cc.ControlHuePicker = cc.Control.extend(/** @lends cc.ControlHuePicker# */{ _startPos:null, _className:"ControlHuePicker", + /** + * @constructor + * @param target + * @param pos + */ + ctor:function(target, pos) { + cc.Control.prototype.ctor.call(this); + pos && this.initWithTargetAndPos(target, pos); + }, + //maunally put in the setters getHue:function () { return this._hue; @@ -197,8 +207,12 @@ cc.defineGetterSetter(_p, "startPos", _p.getStartPos); _p = null; +/** + * @deprecated + * @param target + * @param pos + * @returns {ControlHuePicker} + */ cc.ControlHuePicker.create = function (target, pos) { - var pRet = new cc.ControlHuePicker(); - pRet.initWithTargetAndPos(target, pos); - return pRet; + return new cc.ControlHuePicker(target, pos); }; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlPotentiometer.js b/extensions/gui/control-extension/CCControlPotentiometer.js index 5589b75130..686fa3d7d2 100644 --- a/extensions/gui/control-extension/CCControlPotentiometer.js +++ b/extensions/gui/control-extension/CCControlPotentiometer.js @@ -288,6 +288,13 @@ cc.defineGetterSetter(_p, "prevLocation", _p.getPreviousLocation, _p.setPrevious _p = null; +/** + * @deprecated + * @param backgroundFile + * @param progressFile + * @param thumbFile + * @returns {ControlPotentiometer} + */ cc.ControlPotentiometer.create = function (backgroundFile, progressFile, thumbFile) { return new cc.ControlPotentiometer(backgroundFile, progressFile, thumbFile); }; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js index 00eff64a72..15110a4f3c 100644 --- a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js +++ b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js @@ -59,6 +59,15 @@ cc.ControlSaturationBrightnessPicker = cc.Control.extend(/** @lends cc.ControlSa _boxSize:0, _className:"ControlSaturationBrightnessPicker", + /** + * @constructor + * @param target + * @param pos + */ + ctor:function (target, pos) { + cc.Control.prototype.ctor.call(this); + pos && this.initWithTargetAndPos(target, pos); + }, getSaturation:function () { return this._saturation; }, @@ -237,8 +246,12 @@ cc.defineGetterSetter(_p, "startPos", _p.getStartPos); _p = null; +/** + * @constructor + * @param target + * @param pos + * @returns {ControlSaturationBrightnessPicker} + */ cc.ControlSaturationBrightnessPicker.create = function (target, pos) { - var pRet = new cc.ControlSaturationBrightnessPicker(); - pRet.initWithTargetAndPos(target, pos); - return pRet; + return new cc.ControlSaturationBrightnessPicker(target, pos); }; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index 19dd14d267..603e6d9325 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -299,7 +299,7 @@ _p = null; /** * Creates a slider with a given background sprite and a progress bar and a * thumb item. - * + * @deprecated * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ cc.ControlSlider.create = function (bgFile, progressFile, thumbFile) { diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js index ee3eeb8e8b..e681ff72de 100644 --- a/extensions/gui/control-extension/CCControlStepper.js +++ b/extensions/gui/control-extension/CCControlStepper.js @@ -379,6 +379,13 @@ cc.defineGetterSetter(_p, "plusLabel", _p.getPlusLabel, _p.setPlusLabel); _p = null; + +/** + * @constructor + * @param minusSprite + * @param plusSprite + * @returns {ControlStepper} + */ cc.ControlStepper.create = function (minusSprite, plusSprite) { return new cc.ControlStepper(minusSprite, plusSprite); }; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js index 525053f31d..47a10bf530 100644 --- a/extensions/gui/control-extension/CCControlSwitch.js +++ b/extensions/gui/control-extension/CCControlSwitch.js @@ -156,7 +156,9 @@ cc.ControlSwitch = cc.Control.extend(/** @lends cc.ControlSwitch# */{ } }); -/** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ +/** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. + * @deprecated + */ cc.ControlSwitch.create = function (maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel) { return new cc.ControlSwitch(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); }; diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 6293e167e5..8516c6434a 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -959,6 +959,7 @@ _p = null; /** * Creates a 9-slice sprite with a texture file, a delimitation zone and * with the specified cap insets. + * @deprecated * @param {String|cc.SpriteFrame} file file name of texture or a cc.Sprite object * @param {cc.Rect} rect the rect of the texture * @param {cc.Rect} capInsets the cap insets of cc.Scale9Sprite @@ -968,10 +969,22 @@ cc.Scale9Sprite.create = function (file, rect, capInsets) { return new cc.Scale9Sprite(file, rect, capInsets); }; +/** + * @deprecated + * @param spriteFrame + * @param capInsets + * @returns {Scale9Sprite} + */ cc.Scale9Sprite.createWithSpriteFrame = function (spriteFrame, capInsets) { return new cc.Scale9Sprite(spriteFrame, capInsets); }; +/** + * @deprecated + * @param spriteFrameName + * @param capInsets + * @returns {Scale9Sprite} + */ cc.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName, capInsets) { return new cc.Scale9Sprite(spriteFrameName, capInsets); }; diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 7ae65761a4..4ce3c4c6fe 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -102,7 +102,13 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ _touchListener: null, _className:"ScrollView", - ctor:function () { + /** + * @contructor + * @param size + * @param container + * @returns {ScrollView} + */ + ctor:function (size, container) { cc.Layer.prototype.ctor.call(this); this._contentOffset = cc.p(0,0); this._maxInset = cc.p(0, 0); @@ -113,6 +119,12 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._viewSize = cc.size(0, 0); this._parentScissorRect = new cc.Rect(0,0,0,0); this._tmpViewRect = new cc.Rect(0,0,0,0); + + if(container != undefined) + this.initWithViewSize(size, container); + else + this.initWithViewSize(cc.size(200, 200), null); + }, init:function () { @@ -921,19 +933,11 @@ _p = null; /** * Returns an autoreleased scroll view object. - * + * @deprecated * @param {cc.Size} size view size * @param {cc.Node} container parent object * @return {cc.ScrollView} scroll view object */ cc.ScrollView.create = function (size, container) { - var pRet = new cc.ScrollView(); - if (arguments.length == 2) { - if (pRet && pRet.initWithViewSize(size, container)) - return pRet; - } else { - if (pRet && pRet.init()) - return pRet; - } - return null; + return new cc.ScrollView(size, container); }; \ No newline at end of file diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js index 5fd24f0160..24176eb5e2 100644 --- a/extensions/gui/scrollview/CCTableView.js +++ b/extensions/gui/scrollview/CCTableView.js @@ -195,10 +195,21 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ _cellsPositions:null, //vector with all cell positions _touchedCell:null, - ctor:function () { + /** + * @constructor + * @param dataSource + * @param size + * @param container + */ + ctor:function (dataSource, size, container) { cc.ScrollView.prototype.ctor.call(this); this._oldDirection = cc.SCROLLVIEW_DIRECTION_NONE; this._cellsPositions = []; + + this.initWithViewSize(size, container); + this.setDataSource(dataSource); + this._updateCellPositions(); + this._updateContentSize(); }, __indexFromOffset:function (offset) { @@ -696,17 +707,12 @@ _p = null; /** * An initialized table view object - * + * @deprecated * @param {cc.TableViewDataSource} dataSource data source; * @param {cc.Size} size view size * @param {cc.Node} [container] parent object for cells * @return {cc.TableView} table view */ cc.TableView.create = function (dataSource, size, container) { - var table = new cc.TableView(); - table.initWithViewSize(size, container); - table.setDataSource(dataSource); - table._updateCellPositions(); - table._updateContentSize(); - return table; + return cc.TableView(dataSource, size, container); }; From 66c2033d63b74072c8fcfc95437f98cb12b71dc3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 1 Aug 2014 15:36:52 +0800 Subject: [PATCH 0375/1564] Issue #5702: fixed a bug of cc.Armature, cc.ArmatureAnimation --- cocos2d/core/base-nodes/CCNode.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 20 +++++++++++++++++-- .../armature/animation/CCArmatureAnimation.js | 3 ++- .../armature/animation/CCProcessBase.js | 5 ++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index c0f683f836..e0b6947c72 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -968,7 +968,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {String} name */ setName: function(name){ - this._name + this._name = name; }, /** diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 10e45965b4..fc560372f5 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -274,7 +274,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ locOffsetPoint.x = -rect.x; locOffsetPoint.y = -rect.y; if (rect.width != 0 && rect.height != 0) - this.setAnchorPoint(cc.p(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height)); + this.setAnchorPoint(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height); }, setAnchorPoint: function(point, y){ @@ -296,10 +296,26 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._realAnchorPointInPoints.x = contentSize.width * locAnchorPoint.x; this._realAnchorPointInPoints.y = contentSize.height * locAnchorPoint.y; - this._transformDirty = this._inverseDirty = true; + this.setNodeDirty(); } }, + _setAnchorX: function (x) { + if (this._anchorPoint.x === x) return; + this._anchorPoint.x = x; + this._anchorPointInPoints.x = this._contentSize.width * x - this._offsetPoint.x; + this._realAnchorPointInPoints.x = this._contentSize.width * x; + this.setNodeDirty(); + }, + + _setAnchorY: function (y) { + if (this._anchorPoint.y === y) return; + this._anchorPoint.y = y; + this._anchorPointInPoints.y = this._contentSize.height * y - this._offsetPoint.y; + this._realAnchorPointInPoints.y = this._contentSize.height * y; + this.setNodeDirty(); + }, + getAnchorPointInPoints: function(){ return this._realAnchorPointInPoints; }, diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 33d98993a0..a931f902c4 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -223,7 +223,8 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# var tweenEasing = this._movementData.tweenEasing; loop = (!loop || loop < 0) ? this._movementData.loop : loop; this._onMovementList = false; - ccs.ProcessBase.prototype.play(durationTo, durationTween, loop, tweenEasing); + + ccs.ProcessBase.prototype.play.call(this, durationTo, durationTween, loop, tweenEasing); if (this._rawDuration == 0) this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME; diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index d4c378c2b7..9af6f06399 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -175,14 +175,14 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ update: function (dt) { if (this._isComplete || this._isPause) - return false; + return; /* * Fileter the m_iDuration <=0 and dt >1 * If dt>1, generally speaking the reason is the device is stuck. */ if (this._rawDuration <= 0 || dt > 1) - return false; + return; var locNextFrameIndex = this._nextFrameIndex === undefined ? 0 : this._nextFrameIndex; var locCurrentFrame = this._currentFrame; @@ -206,7 +206,6 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ } this._currentFrame = locCurrentFrame; this.updateHandler(); - return true; }, /** From cc64e53c7999e4092dde284790f8775ee409e25d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 1 Aug 2014 15:38:44 +0800 Subject: [PATCH 0376/1564] Issue #5702: Fixed a bug about CCDataReaderHelper --- extensions/cocostudio/armature/CCBone.js | 22 +++++++------------ .../armature/utils/CCDataReaderHelper.js | 3 ++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 3ad71a79d2..9978baa5d0 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -596,20 +596,14 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ // return this.displayManager.addSkin(skin, index); // }, -// /** -// * get the collider body list in this bone. -// * @returns {*} -// */ -// getColliderBodyList: function () { -// var decoDisplay = this.displayManager.getCurrentDecorativeDisplay() -// if (decoDisplay) { -// var detector = decoDisplay.getColliderDetector() -// if (detector) { -// return detector.getColliderBodyList(); -// } -// } -// return []; -// }, + /** + * @deprecated + * get the collider body list in this bone. + * @returns {*} + */ + getColliderBodyList: function () { + return this.getColliderDetector(); + }, // /** // * displayManager setter diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index a4408d40f8..147f42044c 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -929,7 +929,8 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ contourData.init(); var vertexPointList = json[ccs.CONST_VERTEX_POINT] || []; - for (var i = vertexPointList.length - 1; i >= 0; i--) { + var len = vertexPointList.length; + for (var i = 0; i < len; i++) { var dic = vertexPointList[i]; var vertex = cc.p(0, 0); vertex.x = dic[ccs.CONST_A_X] || 0; From 5520dc9af6fa48e62406bb091995977f47e52eec Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 2 Aug 2014 13:38:58 +0800 Subject: [PATCH 0377/1564] Issue #5072: Fixed two bugs of ccs.DataReaderHelper and ccs.Skin --- .../cocostudio/armature/animation/CCTween.js | 12 ---------- .../cocostudio/armature/display/CCSkin.js | 23 +++++++++++++++---- .../armature/utils/CCDataReaderHelper.js | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index bb7933581d..5dfa330286 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -47,18 +47,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ ctor:function () { ccs.ProcessBase.prototype.ctor.call(this); - this._movementBoneData = null; - this._tweenData = null; - this._from = null; - this._to = null; - this._between = null; - this._bone = null; - this._frameTweenEasing = ccs.TweenType.linear; - this._fromIndex = 0; - this._toIndex = 0; - this._animation = null; - this._passLastFrame = false; }, /** @@ -295,7 +284,6 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ var locBetween = this._between; if (!locFrom.isTween) percent = 0; - node.x = locFrom.x + percent * locBetween.x; node.y = locFrom.y + percent * locBetween.y; node.scaleX = locFrom.scaleX + percent * locBetween.scaleX; diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 10dd75e48f..4a720a8c5b 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -134,10 +134,20 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var dy = x1 * sr + y2 * cr2 + y; var locVertexZ = this._vertexZ; - this.SET_VERTEX3F(locQuad.bl.vertices,this.RENDER_IN_SUBPIXEL(ax), this.RENDER_IN_SUBPIXEL(ay),locVertexZ); - this.SET_VERTEX3F(locQuad.br.vertices,this.RENDER_IN_SUBPIXEL(bx), this.RENDER_IN_SUBPIXEL(by),locVertexZ); - this.SET_VERTEX3F(locQuad.tl.vertices,this.RENDER_IN_SUBPIXEL(dx), this.RENDER_IN_SUBPIXEL(dy),locVertexZ); - this.SET_VERTEX3F(locQuad.tr.vertices,this.RENDER_IN_SUBPIXEL(cx), this.RENDER_IN_SUBPIXEL(cy),locVertexZ); + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + ax = 0 | ax; + ay = 0 | ay; + bx = 0 | bx; + by = 0 | by; + cx = 0 | cx; + cy = 0 | cy; + dx = 0 | dx; + dy = 0 | dy; + } + this.SET_VERTEX3F(locQuad.bl.vertices,ax, ay,locVertexZ); + this.SET_VERTEX3F(locQuad.br.vertices,bx, by,locVertexZ); + this.SET_VERTEX3F(locQuad.tl.vertices,dx, dy,locVertexZ); + this.SET_VERTEX3F(locQuad.tr.vertices,cx, cy,locVertexZ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS @@ -153,7 +163,10 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }, RENDER_IN_SUBPIXEL: function(__ARGS__){ - return Math.ceil(__ARGS__); + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) + return Math.ceil(__ARGS__); + else + return __ARGS__; }, getNodeToWorldTransform: function(){ diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 147f42044c..aef9070849 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -639,7 +639,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } } - if (dataInfo.cocoStudioVersion <= ccs.VERSION_CHANGE_ROTATION_RANGE) { + if (dataInfo.cocoStudioVersion < ccs.VERSION_CHANGE_ROTATION_RANGE) { //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) var frames = movementBoneData.frameList; var pi = Math.PI; From 965ad634887e4c51c1a4ec25b13532798ce6f270 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 2 Aug 2014 15:32:04 +0800 Subject: [PATCH 0378/1564] Issue #5695: Update Facebook plugin --- external/pluginx/Plugin.js | 240 ++++++------- external/pluginx/platform/facebook.js | 484 +++++++++++++------------- 2 files changed, 345 insertions(+), 379 deletions(-) diff --git a/external/pluginx/Plugin.js b/external/pluginx/Plugin.js index 7b8117712f..f2d003e8e9 100644 --- a/external/pluginx/Plugin.js +++ b/external/pluginx/Plugin.js @@ -1,152 +1,111 @@ -(function(w){ +(function(){ if(cc === undefined){ return; } var config = cc.game.config.plugin || {}; - var SDK = { - user: null, - share: null, - social: null - }; - var Plugin = { - getSDK: function(){ - return SDK; - }, - isSupportFunction: function(name){ - if(typeof this[name] === 'function'){ - return true; - }else{ - return false; - } + //Native plugin usage + var PluginManager = function(){}; + + PluginManager.prototype = { + constructor: PluginManager, + + /** + * @returns {PluginManager} + */ + getInstance: function(){ + return this; }, - getUserPlugin: function(){ - return { - callStringFuncWithParam: function(){ - return this.callFuncWithParam.apply(this, arguments); - }, - callFuncWithParam: function(name, opt){ - if(config['common'] && config['common']['user'] && pluginList[config['common']['user']]){ - var _plugin = pluginList[config['common']['user']]; - if(typeof _plugin.user[name] == 'function'){ - return _plugin.user[name](opt); - }else if(typeof _plugin[name] == 'function'){ - return _plugin[name](opt); - } - } - } - }; + + /** + * @param {String} pluginName + */ + loadPlugin: function(pluginName){ + }, - getSharePlugin: function(){ - return { - callStringFuncWithParam: function(){ - return this.callFuncWithParam.apply(this, arguments); - }, - callFuncWithParam: function(name, opt){ - if(config['common'] && config['common']['share'] && pluginList[config['common']['share']]){ - var _plugin = pluginList[config['common']['share']]; - if(typeof _plugin.share[name] == 'function'){ - return _plugin.share[name](opt); - }else if(typeof _plugin[name] == 'function'){ - return _plugin[name](opt); - } - } - } - }; - } - }; - var pluginList = {}; - - Plugin.extend = function(name, method){ - var use = false; - for(var p in config['common']){ - if(config['common'][p] == name){ - for(var o in method[p]){ - Plugin[o] = method[p][o]; - } - use = true; - SDK[p] = name; - } - } - if(use){ - method.init(config[name]); + /** + * + * @param pluginName + */ + unloadPlugin: function(pluginName){ + } - pluginList[name] = method; }; - var pluginManager = { - loadPlugin: function(pluginName){ - if(!pluginName){ - cc.log("PliginManager - PluginName error"); - return null; + var PluginAssembly = function(){}; + + PluginAssembly.prototype = { + constructor: PluginAssembly, + + /** + * @param {Boolean} debug + */ + setDebugMode: function(debug){}, + + /** + * @param {String} appKey + */ + startSession: function(appKey){}, + + /** + * @param {Boolean} Capture + */ + setCaptureUncaughtException: function(Capture){}, + + /** + * @param {String} funName + * @param {All} Params + */ + callFuncWithParam: function(funName){ + if(typeof this[funName] === 'function'){ + return this[funName].apply(this, Array.prototype.splice.call(arguments, 1)); + }else{ + cc.log("function is not define"); } - var info = pluginName.match(/[A-Z][a-z]+/g); + }, - if(info.length !== 2){ - cc.log("PliginManager - PluginName error"); - return null; - } + /** + * @param {String} funName + * @param {All} Params + */ + callStringFuncWithParam: function(funName){ + this.callFuncWithParam.apply(arguments); + }, - var pluginObj = { - setDebugMode: function(){}, - startSession: function(){}, - setCaptureUncaughtException: function(){}, - callFuncWithParam: function(funName){ - if(!pluginList[pluginN]){ - return; - } - var _fun = pluginList[pluginN]['common'][funName]; - if(_fun){ - var _arg = Array.prototype.slice.call(arguments, 1); - return _fun.apply(_fun, _arg); - } - return; - }, - getPluginName: function(){ - return pluginN; - }, - getPluginVersion: function(){ - return "1.0"; - }, - callStringFuncWithParam: function(){ - return pluginObj.callFuncWithParam.apply(pluginObj, arguments); - } - }; - var moduleN = info[0].toLowerCase(); - var pluginN = info[1].toLowerCase(); - if(!pluginList[pluginN]){ - cc.log("Plugin does not exist"); - return pluginObj; - } - pluginList[pluginN].init(); - for(var p in pluginList[pluginN][moduleN]){ - pluginObj[p] = pluginList[pluginN][moduleN][p]; - } - return pluginObj; + /** + * @returns {String} + */ + getPluginName: function(){ + return this._name; + }, + /** + * @returns {String} + */ + getPluginVersion: function(){ + return this._version; } }; - w['plugin'] = { - extend: Plugin.extend, - agentManager: Plugin, - AgentManager: { - getInstance: function(){ - return plugin.agentManager; - } - }, - PluginManager: { - getInstance: function(){ - return pluginManager; - } + PluginAssembly.extend = function(name, porp){ + var p, prototype = {}; + for(p in PluginAssembly.prototype){ + prototype[p] = PluginAssembly.prototype[p]; + } + for(p in porp){ + prototype[p] = porp[p]; } + var tmp = eval("(function " + name + "Plugin(){})"); + prototype.constructor = tmp; + tmp.prototype = prototype; + return tmp; }; - - plugin.PluginParam = function(type, value){ + //Param + var Param = function(type, value){ var paramType = plugin.PluginParam.ParamType,tmpValue; switch(type){ case paramType.TypeInt: @@ -170,7 +129,7 @@ return tmpValue }; - plugin.PluginParam.ParamType = { + Param.ParamType = { TypeInt:1, TypeFloat:2, TypeBool:3, @@ -178,7 +137,7 @@ TypeStringMap:5 }; - plugin.PluginParam.AdsResultCode = { + Param.AdsResultCode = { AdsReceived:0, FullScreenViewShown:1, FullScreenViewDismissed:2, @@ -188,18 +147,37 @@ UnknownError:6 }; - plugin.PluginParam.PayResultCode = { + Param.PayResultCode = { PaySuccess:0, PayFail:1, PayCancel:2, PayTimeOut:3 }; - plugin.PluginParam.ShareResultCode = { + Param.ShareResultCode = { ShareSuccess:0, ShareFail:1, ShareCancel:2, ShareTimeOut:3 }; -})(window); \ No newline at end of file + var PluginList = {}; + + var Plugin = { + + extend: function(name, extend){ + PluginList[name] = new (PluginAssembly.extend(name, extend)); + typeof PluginList[name].ctor === "function" && PluginList[name].ctor(config[name]); + }, + + PluginList: PluginList, + + PluginParam: Param, + + PluginManager: new PluginManager() + + }; + + window.plugin = Plugin; + +})(); \ No newline at end of file diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 05bf452740..fef4da6674 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -1,271 +1,259 @@ -(function(P){ - - - var name = "facebook"; - - var userInfo = { - //accessToken: "", - //expriesIn: "", - //signedRequest: "", - //userID: "" - }; - - var errMsg = { - '0': 'success', - '1': 'Unknown error', - '2': 'Network error', - '3': 'Without permission', - '4': 'Interrupt operation' - }; - - var configCache = {}; - var isInit = false; - - P.extend(name, { - init: function(config){ - if (!FB || isInit) { - return; +plugin.extend('facebook', { + name: "", + version: "", + loggedIn: false, + userInfo: null, + + HttpMethod: { + 'Get': 'get', + 'Post': 'post', + 'Delete': 'delete' + }, + + ctor: function(config){ + this.name = "facebook"; + this.version = "2.0"; + this.userInfo = {}; + + if (!FB) { + return; + } + + var self = this; + FB.init({ + appId : config['appId'], + xfbml : config['xfbml'], + version : config['version'] + }); + FB.getLoginStatus(function(response) { + if (response && response.status === 'connected') { + //login + self._isLogined = true; + //save user info + self.userInfo = response.authResponse; + }else{ + self._isLogined = false; } + }); + + plugin.FacebookAgent = this; + }, + + /** + * @returns {FacebookAgent} + */ + getInstance: function(){ + return this; + }, + + /** + * @param {Function} callback + * callback @param {Number} code + * callback @param {String} mag + */ + login: function(callback){ + var self = this; + FB.login(function(response) { + if (response.authResponse) { + //save user info + self.userInfo = response.authResponse; + typeof callback === 'function' && callback(0); + } else { + typeof callback === 'function' && callback(1); + } + }, { scope: '' }); + }, + + isLogedIn: function(callback){ + return this.isLoggedIn(callback); + }, + + /** + * @param {Function} callback + * @return {Boolean} + */ + isLoggedIn: function(callback){ + var self = this; + FB.getLoginStatus(function(response) { + if (response && response.status === 'connected') { + //login - save user info + self.userInfo = response.authResponse; + typeof callback === 'function' && callback(0); + }else{ + typeof callback === 'function' && callback(1); + } + }); + }, + + /** + * @param {Function} callback + */ + logout: function(callback){ + var self = this; + FB.logout(function(response) { + if(response.authResponse){ + // user is now logged out + self.userInfo = {}; + typeof callback === 'function' && callback(0); + }else{ + typeof callback === 'function' && callback(1); + } + }); + }, + + /** + * @param permissions + * @param callback + */ + requestPermissions: function(permissions, callback){ + var permissionsStr = permissions.join(','); + var self = this; + FB.login(function(response){ + if (response.authResponse) { + //save user info + self.userInfo = response.authResponse; + typeof callback === 'function' && callback(0); + } else { + typeof callback === 'function' && callback(1); + } + }, {scope: permissionsStr}); + }, + + /** + * @param {Function} callback + */ + requestAccessToken: function(callback){ + if(typeof callback !== 'function'){ + return; + } + + if(this.userInfo.accessToken){ + callback(0, this.userInfo.accessToken); + }else{ var self = this; - self._isLogined = false; - configCache = config; - FB.init({ - appId : config['appId'], - xfbml : config['xfbml'], - version : config['version'] - }); FB.getLoginStatus(function(response) { if (response && response.status === 'connected') { - //login - self._isLogined = true; - //save user info - userInfo = response.authResponse; + //login - save user info + self.userInfo = response.authResponse; + callback(0, response.authResponse.accessToken); }else{ - self._isLogined = false; + callback(1, undefined); } }); - isInit = true; - }, - - /* - User Class - */ - user: { - - login: function(callback){ - var self = this; - FB.login(function(response) { - if (response.authResponse) { - self._isLogined = true; - //save user info - userInfo = response.authResponse; - typeof callback === 'function' && callback(0, errMsg[0]); - } else { - typeof callback === 'function' && callback(1, errMsg[1]); - } - }, { scope: '' }); + } + }, + + /** + * @param info + * @param callback + */ + share: function(info, callback){ + FB.ui({ + method: 'share', + name: info['title'], + caption: info['caption'], + description: info['text'], + href: info['link'], + picture: info['imageUrl'] }, - - logout: function(callback){ - FB.logout(function(response) { - if(response.authResponse){ - // user is now logged out - self._isLogined = false; - userInfo = {}; - typeof callback === 'function' && callback(0, errMsg[0]); - }else{ - typeof callback === 'function' && callback(1, errMsg[1]); - } - }); - }, - - isLogined: function(callback){ - var self = this; - - FB.getLoginStatus(function(response) { - if (response && response.status === 'connected') { - self._isLogined = true; - //login - save user info - userInfo = response.authResponse; + function(response) { + if (response) { + if(response.post_id) typeof callback === 'function' && callback(0); - }else{ - self._isLogined = false; - typeof callback === 'function' && callback(1, errMsg[1]); - } - }); - return this._isLogined; - }, - - getUserId: function(){ - return userInfo['userID']; - }, - - getToken: function(){ - return userInfo['accessToken']; - } - }, - - /* - Share Class - */ - share:{ - /* - - info: { - site: - title: - caption: - link: - text: - imagePath: - imageUrl: - location: - - dialogMode: - - notifyText: - notifyIcon: - - comment: - } - - */ - share: function(info, callback){ - - FB.ui({ - method: 'share', - name: info['title'], - caption: info['caption'], - description: info['text'], - href: info['link'], - picture: info['imageUrl'] - }, - function(response) { - if (response) { - if(response.post_id) - typeof callback === 'function' && callback(0, errMsg[0]); - else - typeof callback === 'function' && callback(3, errMsg[3]); - } else { - typeof callback === 'function' && callback(4, errMsg[4]); - } - }); - } - }, - - /* - Social Class - */ - social: { - submitScore: function(callback){ - if(userInfo.userID){ - FB.api("/"+userInfo.userID+"/scores", 'post', {score: 100}, function(response){ - console.log(response); - if(response){ - typeof callback === 'function' && callback(0, errMsg[0]); - }else{ - typeof callback === 'function' && callback(1, errMsg[1]); - } - }); - }else{ - callback(3, errMsg[3]); - } - }, - showLeaderboard: function(callback){ - if(configCache['appId']){ - FB.api("/"+configCache['appId']+"/scores", function(response){ - if(response['error']){ - typeof callback === 'function' && callback(1, response['message']); - }else if(response['data']){ - typeof callback === 'function' && callback(0, response['data']); - } - }); + else + typeof callback === 'function' && callback(3); + } else { + typeof callback === 'function' && callback(4); } - }, - unlockAchievement: function(){ - - }, - showAchievements: function(){ - + }); + }, + + /** + * @param info + * @param callback + */ + dialog: function(info, callback){ + if(!info){ + return; + } + + info['method'] = info['dialog'] == 'share_open_graph' ? 'share_open_graph' : 'share'; + delete info['dialog']; + + info['name'] = info['site'] || info['name']; + delete info['site']; + delete info['name']; + + info['href'] = info['siteUrl'] || info['link']; + delete info['siteUrl']; + delete info['link']; + + info['picture'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; + delete info['imageUrl']; + delete info['imagePath']; + delete info['photo']; + delete info['image']; + + + info['caption'] = info['title'] || info['caption']; + delete info['title']; + + info['description'] = info['text'] || info['description']; + delete info['text']; + delete info['description']; + + if(info['method'] == 'share_open_graph' && info['url']){ + if(info['url']){ + info['action_properties'] = JSON.stringify({ + object: info['url'] + }); + }else{ + return; } - }, - - /** - * shareInfo parameters support both AnySDK style and facebook style - * 1. AnySDK style - * - title - * - site - * - siteUrl - * - text - * - imageUrl - * - imagePath - * - * 2. Facebook style - * - caption - * - name - * - link - * - description - * - picture - */ - dialog: function(options, callback){ - - if(!options){ + }else{ + if(!info['href']){ return; } + } - options['method'] = options['dialog'] == 'share_open_graph' ? 'share_open_graph' : 'share'; - delete options['dialog']; - - options['name'] = options['site'] || options['name']; - delete options['site']; - delete options['name']; - - options['href'] = options['siteUrl'] || options['link']; - delete options['siteUrl']; - delete options['link']; - - options['picture'] = options['imageUrl'] || options['imagePath'] || options['photo'] || options['picture']; - delete options['imageUrl']; - delete options['imagePath']; - delete options['photo']; + if( + info['method'] != 'share_open_graph' && + info['method'] != 'share_link' + ){ + cc.log('web is not supported what this it method'); + return; + } - - options['caption'] = options['title'] || options['caption']; - delete options['title']; - - options['description'] = options['text'] || options['description']; - delete options['text']; - delete options['description']; - - if(options['method'] == 'share_open_graph' && options['url']){ - if(options['url']){ - options['action_properties'] = JSON.stringify({ - object: options['url'] - }); - }else{ - return; - } - }else{ - if(!options['href']){ - return; - } - } - FB.ui(options, + FB.ui(info, function(response) { if (response) { if(response.post_id) - typeof callback === 'function' && callback(0, errMsg[0]); + typeof callback === 'function' && callback(0); else - typeof callback === 'function' && callback(3, errMsg[3]); + typeof callback === 'function' && callback(response.error_code, response.error_message); } else { - typeof callback === 'function' && callback(4, errMsg[4]); + typeof callback === 'function' && callback(1); } }); - }, - - ui: FB.ui, - api: FB.api - }); - + }, + + /** + * @param {String} path + * @param {Number} httpmethod + * @param {Object} params + * @param {Function} callback + */ + request: function(path, httpmethod, params, callback){ + FB.api(path, httpmethod, params, function(response){ + if(response.error){ + callback(response.error.code, "{}") + }else{ + callback(0, JSON.stringify(response)); + } + }); + }, -})(plugin); \ No newline at end of file + destroyInstance: function(){ + void 69; + } +}); \ No newline at end of file From b506231d9f4eb76a0d7b82d5020d7f0f66b8c8d1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 2 Aug 2014 16:06:59 +0800 Subject: [PATCH 0379/1564] Issue #5695: Update Facebook plugin --- external/pluginx/platform/facebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index fef4da6674..5604863dcf 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -78,7 +78,7 @@ plugin.extend('facebook', { if (response && response.status === 'connected') { //login - save user info self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0); + typeof callback === 'function' && callback(0, 'logged'); }else{ typeof callback === 'function' && callback(1); } From 2a7aae98fb944ef6567e35c3de8e7af206d97539 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 2 Aug 2014 16:13:31 +0800 Subject: [PATCH 0380/1564] Issue #5702: fixed a bug of ccs.ColliderDetector --- extensions/cocostudio/armature/CCBone.js | 24 ++++--- .../armature/display/CCDecorativeDisplay.js | 6 +- .../armature/display/CCDisplayFactory.js | 31 ++++---- .../armature/physics/CCColliderDetector.js | 71 ++++++------------- 4 files changed, 46 insertions(+), 86 deletions(-) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 9978baa5d0..5bb5e27d38 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -162,19 +162,21 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._boneTransformDirty = this._armatureParentBone.isTransformDirty(); if (this._boneTransformDirty){ + var locTweenData = this._tweenData; if (this._dataVersion >= ccs.CONST_VERSION_COMBINED){ - ccs.TransformHelp.nodeConcat(this._tweenData, this._boneData); - this._tweenData.scaleX -= 1; - this._tweenData.scaleY -= 1; + ccs.TransformHelp.nodeConcat(locTweenData, this._boneData); + locTweenData.scaleX -= 1; + locTweenData.scaleY -= 1; } - this._worldInfo.copy(this._tweenData); - this._worldInfo.x = this._tweenData.x + this._position.x; - this._worldInfo.y = this._tweenData.y + this._position.y; - this._worldInfo.scaleX = this._tweenData.scaleX * this._scaleX; - this._worldInfo.scaleY = this._tweenData.scaleY * this._scaleY; - this._worldInfo.skewX = this._tweenData.skewX + this._skewX + this._rotationX; - this._worldInfo.skewY = this._tweenData.skewY + this._skewY - this._rotationY; + var locWorldInfo = this._worldInfo; + locWorldInfo.copy(locTweenData); + locWorldInfo.x = locTweenData.x + this._position.x; + locWorldInfo.y = locTweenData.y + this._position.y; + locWorldInfo.scaleX = locTweenData.scaleX * this._scaleX; + locWorldInfo.scaleY = locTweenData.scaleY * this._scaleY; + locWorldInfo.skewX = locTweenData.skewX + this._skewX + this._rotationX; + locWorldInfo.skewY = locTweenData.skewY + this._skewY - this._rotationY; if(this._parentBone) this.applyParentTransform(this._parentBone); @@ -183,7 +185,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this.applyParentTransform(this._armatureParentBone); } - ccs.TransformHelp.nodeToMatrix(this._worldInfo, this._worldTransform); + ccs.TransformHelp.nodeToMatrix(locWorldInfo, this._worldTransform); if (this._armatureParentBone) this._worldTransform = cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToParentTransform()); //TODO TransformConcat } diff --git a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js index 3b7207b688..df21377f27 100644 --- a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +++ b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js @@ -92,11 +92,8 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, release:function () { - CC_SAFE_RELEASE(this._display); this._display = null; - CC_SAFE_RELEASE(this._displayData); this._displayData = null; - CC_SAFE_RELEASE(this._colliderDetector); this._colliderDetector = null; } }); @@ -110,8 +107,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ */ ccs.DecorativeDisplay.create = function () { var decorativeDisplay = new ccs.DecorativeDisplay(); - if (decorativeDisplay && decorativeDisplay.init()) { + if (decorativeDisplay && decorativeDisplay.init()) return decorativeDisplay; - } return null; }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index 327392f209..9595845ad9 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -88,22 +88,17 @@ ccs.displayFactory = { if (detector) { var node = decoDisplay.getDisplay(); var displayTransform = node.nodeToParentTransform(); - var anchorPoint = node.getAnchorPointInPoints(); -// anchorPoint = cc.pointApplyAffineTransform(anchorPoint, helpTransform); - anchorPoint = cc.pointApplyAffineTransform(anchorPoint, displayTransform); - displayTransform.x = anchorPoint.x; - displayTransform.y = anchorPoint.y; - -// var helpTransform = this._helpTransform; -// helpTransform.a = displayTransform.a; -// helpTransform.b = displayTransform.b; -// helpTransform.c = displayTransform.c; -// helpTransform.d = displayTransform.d; -// helpTransform.tx = displayTransform.tx; -// helpTransform.ty = displayTransform.ty; -// helpTransform.tx = anchorPoint.x; -// helpTransform.ty = anchorPoint.y; - var t = cc.affineTransformConcat(bone.getArmature().nodeToParentTransform(), displayTransform); + var helpTransform = this._helpTransform; + helpTransform.a = displayTransform.a; + helpTransform.b = displayTransform.b; + helpTransform.c = displayTransform.c; + helpTransform.d = displayTransform.d; + helpTransform.tx = displayTransform.tx; + helpTransform.ty = displayTransform.ty; + var anchorPoint = cc.pointApplyAffineTransform(node.getAnchorPointInPoints(), helpTransform); + helpTransform.tx = anchorPoint.x; + helpTransform.ty = anchorPoint.y; + var t = cc.affineTransformConcat(helpTransform, bone.getArmature().nodeToParentTransform()); detector.updateTransform(t); } } @@ -133,9 +128,8 @@ ccs.displayFactory = { decoDisplay.setDisplay(skin); - if(skin == null){ + if(skin == null) return; - } skin.setBone(bone); this.initSpriteDisplay(bone, decoDisplay, displayData.displayName, skin); @@ -198,7 +192,6 @@ ccs.displayFactory = { var adp = new ccs.ParticleDisplayData(); adp.copy(displayData); decoDisplay.setDisplayData(adp); - this.createParticleDisplay(bone, decoDisplay); }, diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index 4c77d86eb0..3408013866 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -43,7 +43,6 @@ ccs.ColliderFilter = ccs.Class.extend(/** @lends ccs.ColliderFilter# */{ this._group = group || 0; }, updateShape: function (shape) { - if(shape instanceof cp.Shape){ shape.collision_type = this._collisionType; shape.group = this._group; @@ -171,7 +170,7 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ this._filter = null; }, init: function (bone) { - this._colliderBodyList = []; + this._colliderBodyList.length = 0; if (bone) this._bone = bone; this._filter = new ccs.ColliderFilter(); @@ -211,39 +210,22 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ * @param contourData */ removeContourData: function (contourData) { -// var locColliderBodyList = this._colliderBodyList; -// for (var i = 0; i < locColliderBodyList.length; i++) { -// if (locColliderBodyList[i].getContourData() == contourData) { -// locColliderBodyList.splice(i, 1); -// return; -// } -// } - - var eraseList = []; - var i; - - for (i=0; igetB2Fixture()->GetShape(); @@ -370,23 +342,21 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ setBody: function (body) { this._body = body; - var colliderBody; - for (var i = 0; i < this._colliderBodyList.length; i++) { - colliderBody = this._colliderBodyList[i]; - var contourData = colliderBody.getContourData(); - var verts = []; + var colliderBody, locBodyList = this._colliderBodyList; + for (var i = 0; i < locBodyList.length; i++) { + colliderBody = locBodyList[i]; + var contourData = colliderBody.getContourData(), verts = []; var vs = contourData.vertexList; - for (var i = 0; i < vs.length; i++) { - var v = vs[i]; + for (var j = 0; j < vs.length; j++) { + var v = vs[j]; verts.push(v.x); verts.push(v.y); } 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); colliderBody.getColliderFilter().updateShape(shape); } @@ -414,8 +384,7 @@ _p = null; ccs.ColliderDetector.create = function (bone) { var colliderDetector = new ccs.ColliderDetector(); - if (colliderDetector && colliderDetector.init(bone)) { + if (colliderDetector && colliderDetector.init(bone)) return colliderDetector; - } return null; }; \ No newline at end of file From 4f0aad54a528b30c094b1248227798b89262ef48 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Sat, 2 Aug 2014 16:42:59 +0800 Subject: [PATCH 0381/1564] issue #5685: refactor ctor & create of ccui --- extensions/ccui/base-classes/UIWidget.js | 2 +- extensions/ccui/layouts/UILayout.js | 2 +- extensions/ccui/uiwidgets/UIButton.js | 16 ++++------- extensions/ccui/uiwidgets/UICheckBox.js | 13 ++++----- extensions/ccui/uiwidgets/UIImageView.js | 11 ++++---- extensions/ccui/uiwidgets/UILoadingBar.js | 16 ++++++----- extensions/ccui/uiwidgets/UIRichText.js | 28 +++++++++++-------- extensions/ccui/uiwidgets/UISlider.js | 9 ++---- extensions/ccui/uiwidgets/UIText.js | 22 +++++---------- extensions/ccui/uiwidgets/UITextAtlas.js | 15 ++++------ extensions/ccui/uiwidgets/UITextBMFont.js | 21 ++++++-------- extensions/ccui/uiwidgets/UITextField.js | 2 +- .../uiwidgets/scroll-widget/UIListView.js | 2 +- .../uiwidgets/scroll-widget/UIPageView.js | 7 ++--- .../uiwidgets/scroll-widget/UIScrollView.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 3 +- 16 files changed, 75 insertions(+), 96 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 0585519704..370df4cfe2 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1517,7 +1517,7 @@ _p = null; /** * allocates and initializes a UIWidget. - * @constructs + * @deprecated * @return {ccui.Widget} * @example * // example diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 5c0ba41cf9..c8096906c6 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1761,7 +1761,7 @@ _p = null; /** * allocates and initializes a UILayout. - * @constructs + * @deprecated * @return {ccui.Layout} * @example * // example diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index bda0c3a2bd..f76f0043b4 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -83,11 +83,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * allocates and initializes a UIButton. * Constructor of ccui.Button + * @constructor * @example * // example * var uiButton = new ccui.Button(); */ - ctor: function () { + ctor: function (normalImage, selectedImage, disableImage, texType) { this._capInsetsNormal = cc.rect(0, 0, 0, 0); this._capInsetsPressed = cc.rect(0, 0, 0, 0); this._capInsetsDisabled = cc.rect(0, 0, 0, 0); @@ -97,6 +98,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._titleColor = cc.color.WHITE; ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); + + texType && this.init(normalImage, selectedImage, disableImage, texType); }, init: function (normalImage, selectedImage,disableImage, texType) { @@ -814,6 +817,7 @@ _p = null; /** * allocates and initializes a UIButton. + * @deprecated * @param {string} [normalImage] normal state texture name * @param {string} [selectedImage] selected state texture name * @param {string} [disableImage] disabled state texture name @@ -824,15 +828,7 @@ _p = null; * var uiButton = ccui.Button.create(); */ ccui.Button.create = function (normalImage, selectedImage, disableImage, texType) { - var btn = new ccui.Button(); - if(normalImage === undefined){ - if(btn && btn.init()) - return btn; - }else{ - if(btn && btn.init(normalImage, selectedImage, disableImage, texType)) - return btn; - } - return null; + return new ccui.Button(normalImage, selectedImage, disableImage, texType); }; // Constants diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 9d17d48d61..8aa3fe6581 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -65,13 +65,16 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ /** * allocates and initializes a UICheckBox. * Constructor of ccui.CheckBox + * @constructor * @example * // example * var uiCheckBox = new ccui.CheckBox(); */ - ctor: function () { + ctor: function (backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType) { ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); + + texType && this.init(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); }, init: function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { if (ccui.Widget.prototype.init.call(this)) { @@ -602,6 +605,7 @@ _p = null; /** * allocates and initializes a UICheckBox. + * @deprecated * @param {string} [backGround] backGround texture. * @param {string} [backGroundSeleted] backGround selected state texture. * @param {string} [cross] cross texture. @@ -614,12 +618,7 @@ _p = null; * var uiCheckBox = ccui.CheckBox.create(); */ ccui.CheckBox.create = function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { - var widget = new ccui.CheckBox(); - if(backGround === undefined) - widget.init(); - else - widget.init(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); - return widget; + return ccui.CheckBox(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); }; // Constants diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index dda96f6abb..84876c6760 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -42,14 +42,17 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ /** * allocates and initializes a UIImageView. * Constructor of ccui.ImageView + * @constructor * @example * // example * var uiImageView = new ccui.ImageView; */ - ctor: function () { + ctor: function (imageFileName, texType) { this._capInsets = cc.rect(0,0,0,0); this._imageTextureSize = cc.size(this._capInsets.width, this._capInsets.height); ccui.Widget.prototype.ctor.call(this); + + texType && this.init(imageFileName, texType); }, init: function(imageFileName, texType){ @@ -282,6 +285,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ /** * allocates and initializes a UIImageView. + * @deprecated * @param {string} imageFileName * @param {Number} texType * @return {ccui.ImageView} @@ -290,10 +294,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * var uiImageView = ccui.ImageView.create(); */ ccui.ImageView.create = function (imageFileName, texType) { - var imageView = new ccui.ImageView(); - if(imageFileName !== undefined) - imageView.init(imageFileName, texType); - return imageView; + return ccui.ImageView(imageFileName, texType); }; // Constants diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 625c5bdc71..d37edb28c9 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -49,15 +49,21 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ /** * allocates and initializes a UILoadingBar. * Constructor of ccui.LoadingBar + * @constructor * @example * // example * var uiLoadingBar = new ccui.LoadingBar; */ - ctor: function () { + ctor: function (textureName, percentage) { this._direction = ccui.LoadingBar.TYPE_LEFT; this._barRendererTextureSize = cc.size(0, 0); this._capInsets = cc.rect(0, 0, 0, 0); ccui.Widget.prototype.ctor.call(this); + + if(textureName !== undefined) + this.loadTexture(textureName); + if(percentage !== undefined) + this.setPercent(percentage); }, _initRenderer: function () { @@ -383,6 +389,7 @@ _p = null; /** * allocates and initializes a UILoadingBar. + * @deprecated * @param {string} textureName * @param {Number} percentage * @return {ccui.LoadingBar} @@ -391,12 +398,7 @@ _p = null; * var uiLoadingBar = ccui.LoadingBar.create(); */ ccui.LoadingBar.create = function (textureName, percentage) { - var loadingBar = new ccui.LoadingBar(); - if(textureName !== undefined) - loadingBar.loadTexture(textureName); - if(percentage !== undefined) - loadingBar.setPercent(percentage); - return loadingBar; + return ccui.LoadingBar(textureName, percentage); }; // Constants diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 5bbfcacac4..8b6cd12659 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -60,12 +60,14 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# _text: "", _fontName: "", _fontSize: 0, - ctor: function () { + ctor: function (tag, color, opacity, text, fontName, fontSize) { ccui.RichElement.prototype.ctor.call(this); this._type = ccui.RichElement.TEXT; this._text = ""; this._fontName = ""; this._fontSize = 0; + + fontSize && this.init(tag, color, opacity, text, fontName, fontSize); }, init: function (tag, color, opacity, text, fontName, fontSize) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); @@ -77,6 +79,7 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# /** * Create a richElementText + * @deprecated * @param {Number} tag * @param {cc.Color} color * @param {Number} opacity @@ -86,9 +89,7 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# * @returns {ccui.RichElementText} */ ccui.RichElementText.create = function (tag, color, opacity, text, fontName, fontSize) { - var element = new ccui.RichElementText(); - element.init(tag, color, opacity, text, fontName, fontSize); - return element; + return new ccui.RichElementText(tag, color, opacity, text, fontName, fontSize); }; /** @@ -100,12 +101,14 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage _filePath: "", _textureRect: null, _textureType: 0, - ctor: function () { + ctor: function (tag, color, opacity, filePath) { ccui.RichElement.prototype.ctor.call(this); this._type = ccui.RichElement.IMAGE; this._filePath = ""; this._textureRect = cc.rect(0, 0, 0, 0); this._textureType = 0; + + filePath && this.init(tag, color, opacity, filePath); }, init: function (tag, color, opacity, filePath) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); @@ -115,6 +118,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage /** * Create a richElementImage + * @deprecated * @param {Number} tag * @param {cc.Color} color * @param {Number} opacity @@ -122,9 +126,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage * @returns {ccui.RichElementImage} */ ccui.RichElementImage.create = function (tag, color, opacity, filePath) { - var element = new ccui.RichElementImage(); - element.init(tag, color, opacity, filePath); - return element; + return ccui.RichElementImage(tag, color, opacity, filePath); }; /** @@ -134,10 +136,12 @@ ccui.RichElementImage.create = function (tag, color, opacity, filePath) { */ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElementCustomNode# */{ _customNode: null, - ctor: function () { + ctor: function (tag, color, opacity, customNode) { ccui.RichElement.prototype.ctor.call(this); this._type = ccui.RichElement.CUSTOM; this._customNode = null; + + customNode && this.init(tag, color, opacity, customNode); }, init: function (tag, color, opacity, customNode) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); @@ -147,6 +151,7 @@ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElement /** * Create a richElementCustomNode + * @deprecated * @param {Number} tag * @param {Number} color * @param {Number} opacity @@ -154,9 +159,7 @@ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElement * @returns {ccui.RichElementCustomNode} */ ccui.RichElementCustomNode.create = function (tag, color, opacity, customNode) { - var element = new ccui.RichElementCustomNode(); - element.init(tag, color, opacity, customNode); - return element; + return new ccui.RichElementCustomNode(tag, color, opacity, customNode); }; /** @@ -459,6 +462,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ /** * create a rich text + * @deprecated * @returns {RichText} * @example * var uiRichText = ccui.RichTex.create(); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 275afb29e5..1e78a0d561 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -649,19 +649,14 @@ _p = null; /** * allocates and initializes a UISlider. - * @constructs + * @deprecated * @return {ccui.Slider} * @example * // example * var uiSlider = ccui.Slider.create(); */ ccui.Slider.create = function () { - var widget = new ccui.Slider(); - if (widget && widget.init()) - { - return widget; - } - return null; + return new ccui.Slider(); }; // Constant diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 789800aab0..9cb6d10683 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -58,14 +58,18 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ /** * allocates and initializes a UILabel. * Constructor of ccui.Text + * @constructor * @example * // example * var uiLabel = new ccui.Text(); */ - ctor: function () { + ctor: function (textContent, fontName, fontSize) { this._type = ccui.Text.Type.SYSTEM; this._textAreaSize = cc.size(0, 0); ccui.Widget.prototype.ctor.call(this); + + fontSize && this.init(textContent, fontName, fontSize); + }, init: function (textContent, fontName, fontSize) { @@ -425,26 +429,14 @@ _p = null; /** * allocates and initializes a UILabel. - * @constructs + * @deprecated * @return {ccui.Text} * @example * // example * var uiLabel = ccui.Text.create(); */ ccui.Label = ccui.Text.create = function (textContent, fontName, fontSize) { - var widget = new ccui.Text(); - if(arguments.length > 0){ - if (widget && widget.init(textContent, fontName, fontSize)) - { - return widget; - } - }else{ - if (widget && widget.init()) - { - return widget; - } - } - return null; + return ccui.Text(textContent, fontName, fontSize); }; ccui.Text.RENDERER_ZORDER = -1; diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 8dd7d3bd3a..c345e4878f 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -43,12 +43,14 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ /** * allocates and initializes a UILabelAtlas. * Constructor of ccui.TextAtlas + * @constructor * @example * // example * var uiLabelAtlas = new ccui.TextAtlas(); */ - ctor: function () { + ctor: function (stringValue, charMapFile, itemWidth, itemHeight, startCharMap) { ccui.Widget.prototype.ctor.call(this); + startCharMap && this.setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); }, _initRenderer: function () { @@ -218,21 +220,14 @@ _p = null; /** * allocates and initializes a UILabelAtlas. - * @constructs + * @deprecated * @return {ccui.TextAtlas} * @example * // example * var uiLabelAtlas = ccui.TextAtlas.create(); */ ccui.TextAtlas.create = function (stringValue, charMapFile, itemWidth, itemHeight, startCharMap) { - var widget = new ccui.TextAtlas(); - if(widget && widget.init()){ - if(arguments.length > 0){ - widget.setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); - } - return widget; - } - return null; + return ccui.TextAtlas(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); }; // Constants diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 3d1ba852d0..a43679ead9 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -41,12 +41,18 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo /** * allocates and initializes a UILabelBMFont. * Constructor of ccui.TextBMFont + * @constructor * @example * // example * var uiLabelBMFont = new ccui.TextBMFont(); */ - ctor: function () { + ctor: function (text, filename) { ccui.Widget.prototype.ctor.call(this); + + if(filename != undefined){ + this.setFntFile(filename); + this.setString(text); + } }, _initRenderer: function () { this._labelBMFontRenderer = cc.LabelBMFont.create(); @@ -189,23 +195,14 @@ _p = null; /** * allocates and initializes a UILabelBMFont. - * @constructs + * @deprecated * @return {ccui.TextBMFont} * @example * // example * var uiLabelBMFont = ccui.TextBMFont.create(); */ ccui.TextBMFont.create = function (text, filename) { - var widget = new ccui.TextBMFont(); - if(widget && widget.init()){ - if(filename && text){ - widget.setFntFile(filename); - widget.setString(text); - } - return widget; - - } - return null; + return new ccui.ccui.TextBMFont(text, filename); }; // Constants diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 83fd086a82..b7f1d34ae5 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -764,7 +764,7 @@ _p = null; /** * allocates and initializes a UITextField. - * @constructs + * @deprecated * @return {ccui.TextField} * @example * // example diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 9cddc6fabf..8468f82c04 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -504,7 +504,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * allocates and initializes a UIListView. - * @constructs + * @deprecated * @example * // example * var uiPageView = ccui.ListView.create(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index e03c690b2c..5a84dbf3ab 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -510,17 +510,14 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }); /** * allocates and initializes a UIPageView. - * @constructs + * @deprecated * @return {ccui.PageView} * @example * // example * var uiPageView = ccui.PageView.create(); */ ccui.PageView.create = function () { - var widget = new ccui.PageView(); - if (widget && widget.init()) - return widget; - return null; + return new ccui.PageView(); }; // Constants diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index a3276c0ef9..6340007d09 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1693,7 +1693,7 @@ _p = null; /** * allocates and initializes a UIScrollView. - * @constructs + * @deprecated * @return {ccui.ScrollView} * @example * // example diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 3fb48e9969..fc88816411 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -81,7 +81,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._textureAtlasDic = null; this._blendFunc = null; - parentBone && ccs.Armature.prototype.init.call(this, name, parentBone); + name && ccs.Armature.prototype.init.call(this, name, parentBone); }, /** @@ -708,6 +708,7 @@ _p = null; /** * allocates and initializes a armature. + * @deprecated * @param {String} name * @param {ccs.Bone} parentBone * @return {ccs.Armature} From 88e0410a7f319f95f147ed5a5a43fe84076efe94 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 4 Aug 2014 11:11:13 +0800 Subject: [PATCH 0382/1564] Closed #5702: Fixed a bug of cc.Armature's drawContour --- extensions/cocostudio/armature/CCArmature.js | 25 +++++---------- extensions/cocostudio/armature/CCBone.js | 33 +++----------------- 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index fc560372f5..1012ed9039 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -538,28 +538,19 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * draw contour */ drawContour: function () { + cc._drawingUtil.setDrawColor(255, 255, 255, 255); + cc._drawingUtil.setLineWidth(1); var locBoneDic = this._boneDic; - for (var i = 0; i < locBoneDic.length; i++) { - var bone = locBoneDic[i]; + for (var key in locBoneDic) { + var bone = locBoneDic[key]; var detector = bone.getColliderDetector(); - - if (!detector) + if(!detector) continue; - var bodyList = detector.getColliderBodyList(); - - for (var j=0; i Date: Mon, 4 Aug 2014 11:37:18 +0800 Subject: [PATCH 0383/1564] Fixed #5783: Add Action3d lower case alias creation functions --- cocos2d/actions3d/CCActionGrid.js | 62 +++++++-- cocos2d/actions3d/CCActionGrid3D.js | 136 +++++++++++++++--- cocos2d/actions3d/CCActionPageTurn3D.js | 13 +- cocos2d/actions3d/CCActionTiledGrid.js | 175 ++++++++++++++++++++---- 4 files changed, 330 insertions(+), 56 deletions(-) diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index 20dd62a3f5..e7aa4607bb 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -101,14 +101,23 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ /** * creates the action with size and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.GridAction} */ -cc.GridAction.create = function (duration, gridSize) { +cc.gridAction = function (duration, gridSize) { return new cc.GridAction(duration, gridSize); }; +/** + * Please use cc.gridAction instead + * creates the action with size and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @return {cc.GridAction} + * @static + * @deprecated + */ +cc.GridAction.create = cc.gridAction; /** * Base class for cc.Grid3D actions.
    @@ -156,14 +165,23 @@ cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{ /** * creates the action with size and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.Grid3DAction} */ -cc.Grid3DAction.create = function (duration, gridSize) { +cc.grid3DAction = function (duration, gridSize) { return new cc.Grid3DAction(duration, gridSize); }; +/** + * Please use cc.grid3DAction instead + * creates the action with size and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @return {cc.Grid3DAction} + * @static + * @deprecated + */ +cc.Grid3DAction.create = cc.grid3DAction; /** * Base class for cc.TiledGrid3D actions @@ -210,14 +228,23 @@ cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{ /** * Creates the action with duration and grid size - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.TiledGrid3DAction} */ -cc.TiledGrid3DAction.create = function (duration, gridSize) { +cc.tiledGrid3DAction = function (duration, gridSize) { return new cc.TiledGrid3DAction(duration, gridSize); }; +/** + * Please use cc.tiledGrid3DAction instead + * Creates the action with duration and grid size + * @param {Number} duration + * @param {cc.Size} gridSize + * @return {cc.TiledGrid3DAction} + * @static + * @deprecated + */ +cc.TiledGrid3DAction.create = cc.tiledGrid3DAction; /** *

    @@ -240,12 +267,19 @@ cc.StopGrid = cc.ActionInstant.extend(/** @lends cc.StopGrid# */{ /** * Allocates and initializes the action - * @deprecated * @return {cc.StopGrid} */ -cc.StopGrid.create = function () { +cc.stopGrid = function () { return new cc.StopGrid(); }; +/** + * Please use cc.stopGrid instead + * Allocates and initializes the action + * @return {cc.StopGrid} + * @static + * @deprecated + */ +cc.StopGrid.create = cc.stopGrid; /** * cc.ReuseGrid action @@ -284,10 +318,18 @@ cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{ /** * creates an action with the number of times that the current grid will be reused - * @deprecated * @param {Number} times * @return {cc.ReuseGrid} */ -cc.ReuseGrid.create = function (times) { +cc.reuseGrid = function (times) { return new cc.ReuseGrid(times); }; +/** + * Please use cc.reuseGrid instead + * creates an action with the number of times that the current grid will be reused + * @param {Number} times + * @return {cc.ReuseGrid} + * @static + * @deprecated + */ +cc.ReuseGrid.create = cc.reuseGrid; diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index 630fe8a9af..e2c5544829 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -115,15 +115,25 @@ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ /** * Create a wave 3d action with duration, grid size, waves and amplitude - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves * @param {Number} amplitude */ -cc.Waves3D.create = function (duration, gridSize, waves, amplitude) { +cc.waves3D = function (duration, gridSize, waves, amplitude) { return new cc.Waves3D(duration, gridSize, waves, amplitude); }; +/** + * Please use cc.waves3D instead + * Create a wave 3d action with duration, grid size, waves and amplitude + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude + * @static + * @deprecated + */ +cc.Waves3D.create = cc.waves3D; /** * cc.FlipX3D action @@ -232,13 +242,21 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ /** * Create a Flip X 3D action with duration - * @deprecated * @param {Number} duration * @return {cc.FlipX3D} */ -cc.FlipX3D.create = function (duration) { +cc.flipX3D = function (duration) { return new cc.FlipX3D(duration); }; +/** + * Please use cc.flipX3D instead + * Create a Flip X 3D action with duration + * @param {Number} duration + * @return {cc.FlipX3D} + * @static + * @deprecated + */ +cc.FlipX3D.create = cc.flipX3D; /** * cc.FlipY3D action @@ -324,13 +342,21 @@ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ /** * Create a flip Y 3d action with duration - * @deprecated * @param {Number} duration * @return {cc.FlipY3D} */ -cc.FlipY3D.create = function (duration) { +cc.flipY3D = function (duration) { return new cc.FlipY3D(duration); }; +/** + * Please use cc.flipY3D instead + * Create a flip Y 3d action with duration + * @param {Number} duration + * @return {cc.FlipY3D} + * @static + * @deprecated + */ +cc.FlipY3D.create = cc.flipY3D; /** * cc.Lens3D action @@ -470,16 +496,27 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ /** * creates a lens 3d action with center position, radius - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position * @param {Number} radius * @return {cc.Lens3D} */ -cc.Lens3D.create = function (duration, gridSize, position, radius) { +cc.lens3D = function (duration, gridSize, position, radius) { return new cc.Lens3D(duration, gridSize, position, radius); }; +/** + * Please use cc.lens3D instead + * creates a lens 3d action with center position, radius + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {cc.Point} position + * @param {Number} radius + * @return {cc.Lens3D} + * @static + * @deprecated + */ +cc.Lens3D.create = cc.lens3D; /** * cc.Ripple3D action @@ -607,10 +644,8 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ } } }); - /** * creates a ripple 3d action with radius, number of waves, amplitude - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -619,9 +654,23 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ * @param {Number} amplitude * @return {cc.Ripple3D} */ -cc.Ripple3D.create = function (duration, gridSize, position, radius, waves, amplitude) { +cc.ripple3D = function (duration, gridSize, position, radius, waves, amplitude) { return new cc.Ripple3D(duration, gridSize, position, radius, waves, amplitude); }; +/** + * Please use cc.ripple3D instead + * creates a ripple 3d action with radius, number of waves, amplitude + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {cc.Point} position + * @param {Number} radius + * @param {Number} waves + * @param {Number} amplitude + * @return {cc.Ripple3D} + * @static + * @deprecated + */ +cc.Ripple3D.create = cc.ripple3D; /** * cc.Shaky3D action @@ -682,17 +731,28 @@ cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{ }); /** + * Please use cc.shaky3D instead * creates the action with a range, shake Z vertices, a grid and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range * @param {Boolean} shakeZ * @return {cc.Shaky3D} */ -cc.Shaky3D.create = function (duration, gridSize, range, shakeZ) { +cc.shaky3D = function (duration, gridSize, range, shakeZ) { return new cc.Shaky3D(duration, gridSize, range, shakeZ); }; +/** + * creates the action with a range, shake Z vertices, a grid and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} range + * @param {Boolean} shakeZ + * @return {cc.Shaky3D} + * @static + * @deprecated + */ +cc.Shaky3D.create = cc.shaky3D; /** * cc.Liquid action @@ -786,16 +846,27 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ /** * creates the action with amplitude, a grid and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves * @param {Number} amplitude * @return {cc.Liquid} */ -cc.Liquid.create = function (duration, gridSize, waves, amplitude) { +cc.liquid = function (duration, gridSize, waves, amplitude) { return new cc.Liquid(duration, gridSize, waves, amplitude); }; +/** + * Please use cc.liquid instead + * creates the action with amplitude, a grid and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude + * @return {cc.Liquid} + * @static + * @deprecated + */ +cc.Liquid.create = cc.liquid; /** * cc.Waves action @@ -900,7 +971,6 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ /** * initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -909,10 +979,25 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ * @param {Boolean} vertical * @return {cc.Waves} */ -cc.Waves.create = function (duration, gridSize, waves, amplitude, horizontal, vertical) { +cc.waves = function (duration, gridSize, waves, amplitude, horizontal, vertical) { return new cc.Waves(duration, gridSize, waves, amplitude, horizontal, vertical); }; +/** + * Please use cc.waves instead + * initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude + * @param {Boolean} horizontal + * @param {Boolean} vertical + * @return {cc.Waves} + * @static + * @deprecated + */ +cc.Waves.create = cc.waves; + /** @brief */ /** * cc.Twirl action @@ -1034,7 +1119,6 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ /** * creates the action with center position, number of twirls, amplitude, a grid size and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -1042,6 +1126,20 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ * @param {Number} amplitude * @return {cc.Twirl} */ -cc.Twirl.create = function (duration, gridSize, position, twirls, amplitude) { +cc.twirl = function (duration, gridSize, position, twirls, amplitude) { return new cc.Twirl(duration, gridSize, position, twirls, amplitude); }; + +/** + * Please use cc.twirl instead + * creates the action with center position, number of twirls, amplitude, a grid size and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {cc.Point} position + * @param {Number} twirls + * @param {Number} amplitude + * @return {cc.Twirl} + * @static + * @deprecated + */ +cc.Twirl.create = cc.twirl; \ No newline at end of file diff --git a/cocos2d/actions3d/CCActionPageTurn3D.js b/cocos2d/actions3d/CCActionPageTurn3D.js index 2e41fde481..5fb09ef0f8 100644 --- a/cocos2d/actions3d/CCActionPageTurn3D.js +++ b/cocos2d/actions3d/CCActionPageTurn3D.js @@ -93,11 +93,20 @@ cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{ /** * create PageTurn3D action - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.PageTurn3D} */ -cc.PageTurn3D.create = function (duration, gridSize) { +cc.pageTurn3D = function (duration, gridSize) { return new cc.PageTurn3D(duration, gridSize); }; +/** + * Please use cc.pageTurn3D instead + * create PageTurn3D action + * @param {Number} duration + * @param {cc.Size} gridSize + * @return {cc.PageTurn3D} + * @static + * @deprecated + */ +cc.PageTurn3D.create = cc.pageTurn3D; \ No newline at end of file diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index 4d6301a479..97f59d590d 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -99,16 +99,27 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ /** * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range * @param {Boolean} shakeZ * @return {cc.ShakyTiles3D} */ -cc.ShakyTiles3D.create = function (duration, gridSize, range, shakeZ) { +cc.shakyTiles3D = function (duration, gridSize, range, shakeZ) { return new cc.ShakyTiles3D(duration, gridSize, range, shakeZ); }; +/** + * Please use cc.shakyTiles3D instead + * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} range + * @param {Boolean} shakeZ + * @return {cc.ShakyTiles3D} + * @static + * @deprecated + */ +cc.ShakyTiles3D.create = cc.shakyTiles3D; /** * cc.ShatteredTiles3D action @@ -189,16 +200,27 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D /** * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range * @param {Boolean} shatterZ * @return {cc.ShatteredTiles3D} */ -cc.ShatteredTiles3D.create = function (duration, gridSize, range, shatterZ) { +cc.shatteredTiles3D = function (duration, gridSize, range, shatterZ) { return new cc.ShatteredTiles3D(duration, gridSize, range, shatterZ); }; +/** + * Please use cc.shatteredTiles3D instead + * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} range + * @param {Boolean} shatterZ + * @return {cc.ShatteredTiles3D} + * @static + * @deprecated + */ +cc.ShatteredTiles3D.create = cc.shatteredTiles3D; /** * A Tile composed of position, startPosition and delta @@ -362,15 +384,25 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ /** * creates the action with a random seed, the grid size and the duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} seed * @return {cc.ShuffleTiles} */ -cc.ShuffleTiles.create = function (duration, gridSize, seed) { +cc.shuffleTiles = function (duration, gridSize, seed) { return new cc.ShuffleTiles(duration, gridSize, seed); }; +/** + * Please use cc.shuffleTiles instead + * creates the action with a random seed, the grid size and the duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} seed + * @return {cc.ShuffleTiles} + * @static + * @deprecated + */ +cc.ShuffleTiles.create = cc.shuffleTiles; /** * cc.FadeOutTRTiles action. Fades out the tiles in a Top-Right direction @@ -453,14 +485,23 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ /** * creates the action with the grid size and the duration - * @deprecated * @param duration * @param gridSize * @return {cc.FadeOutTRTiles} */ -cc.FadeOutTRTiles.create = function (duration, gridSize) { +cc.fadeOutTRTiles = function (duration, gridSize) { return new cc.FadeOutTRTiles(duration, gridSize); }; +/** + * Please use cc.fadeOutTRTiles instead + * creates the action with the grid size and the duration + * @param duration + * @param gridSize + * @return {cc.FadeOutTRTiles} + * @static + * @deprecated + */ +cc.FadeOutTRTiles.create = cc.fadeOutTRTiles; /** * cc.FadeOutBLTiles action. Fades out the tiles in a Bottom-Left direction @@ -484,14 +525,23 @@ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{ /** * creates the action with the grid size and the duration - * @deprecated * @param duration * @param gridSize * @return {cc.FadeOutBLTiles} */ -cc.FadeOutBLTiles.create = function (duration, gridSize) { +cc.fadeOutBLTiles = function (duration, gridSize) { return new cc.FadeOutBLTiles(duration, gridSize); }; +/** + * Please use cc.fadeOutBLTiles instead + * creates the action with the grid size and the duration + * @param duration + * @param gridSize + * @return {cc.FadeOutBLTiles} + * @static + * @deprecated + */ +cc.FadeOutBLTiles.create = cc.fadeOutBLTiles; /** * cc.FadeOutUpTiles action. Fades out the tiles in upwards direction @@ -521,14 +571,23 @@ cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{ /** * creates the action with the grid size and the duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutUpTiles} */ -cc.FadeOutUpTiles.create = function (duration, gridSize) { +cc.fadeOutUpTiles = function (duration, gridSize) { return new cc.FadeOutUpTiles(duration, gridSize); }; +/** + * Please use cc.fadeOutUpTiles instead + * creates the action with the grid size and the duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @return {cc.FadeOutUpTiles} + * @static + * @deprecated + */ +cc.FadeOutUpTiles.create = cc.fadeOutUpTiles; /** * cc.FadeOutDownTiles action. Fades out the tiles in downwards direction @@ -546,14 +605,23 @@ cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend(/** @lends cc.FadeOutDownTiles# * /** * creates the action with the grid size and the duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutDownTiles} */ -cc.FadeOutDownTiles.create = function (duration, gridSize) { +cc.fadeOutDownTiles = function (duration, gridSize) { return new cc.FadeOutDownTiles(duration, gridSize); }; +/** + * Please use cc.fadeOutDownTiles instead + * creates the action with the grid size and the duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @return {cc.FadeOutDownTiles} + * @static + * @deprecated + */ +cc.FadeOutDownTiles.create = cc.fadeOutDownTiles; /** @@ -662,7 +730,6 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ /** * creates the action with a random seed, the grid size and the duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number|Null} [seed=0] @@ -675,9 +742,27 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ * // turnOffTiles with seed * var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y), 0); */ -cc.TurnOffTiles.create = function (duration, gridSize, seed) { +cc.turnOffTiles = function (duration, gridSize, seed) { return new cc.TurnOffTiles(duration, gridSize, seed); }; +/** + * Please use cc.turnOffTiles instead + * creates the action with a random seed, the grid size and the duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number|Null} [seed=0] + * @return {cc.TurnOffTiles} + * @static + * @deprecated + * @example + * // example + * // turnOffTiles without seed + * var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y)); + * + * // turnOffTiles with seed + * var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y), 0); + */ +cc.TurnOffTiles.create = cc.turnOffTiles; /** * cc.WavesTiles3D action. @@ -773,16 +858,27 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ /** * creates the action with a number of waves, the waves amplitude, the grid size and the duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves * @param {Number} amplitude * @return {cc.WavesTiles3D} */ -cc.WavesTiles3D.create = function (duration, gridSize, waves, amplitude) { +cc.wavesTiles3D = function (duration, gridSize, waves, amplitude) { return new cc.WavesTiles3D(duration, gridSize, waves, amplitude); }; +/** + * Please use cc.wavesTiles3D instead + * creates the action with a number of waves, the waves amplitude, the grid size and the duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude + * @return {cc.WavesTiles3D} + * @static + * @deprecated + */ +cc.WavesTiles3D.create = cc.wavesTiles3D; /** * cc.JumpTiles3D action. A sin function is executed to move the tiles across the Z axis @@ -892,16 +988,27 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ /** * creates the action with the number of jumps, the sin amplitude, the grid size and the duration - * @deprecated * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} numberOfJumps * @param {Number} amplitude * @return {cc.JumpTiles3D} */ -cc.JumpTiles3D.create = function (duration, gridSize, numberOfJumps, amplitude) { +cc.jumpTiles3D = function (duration, gridSize, numberOfJumps, amplitude) { return new cc.JumpTiles3D(duration, gridSize, numberOfJumps, amplitude); }; +/** + * Please use cc.jumpTiles3D instead + * creates the action with the number of jumps, the sin amplitude, the grid size and the duration + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} numberOfJumps + * @param {Number} amplitude + * @return {cc.JumpTiles3D} + * @static + * @deprecated + */ +cc.JumpTiles3D.create = cc.jumpTiles3D; /** * cc.SplitRows action @@ -962,14 +1069,23 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ /** * creates the action with the number of rows to split and the duration - * @deprecated * @param {Number} duration * @param {Number} rows * @return {cc.SplitRows} */ -cc.SplitRows.create = function (duration, rows) { +cc.splitRows = function (duration, rows) { return new cc.SplitRows(duration, rows); }; +/** + * Please use cc.splitRows instead + * creates the action with the number of rows to split and the duration + * @param {Number} duration + * @param {Number} rows + * @return {cc.SplitRows} + * @static + * @deprecated + */ +cc.SplitRows.create = cc.splitRows; /** * cc.SplitCols action @@ -1032,11 +1148,20 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ /** * creates the action with the number of columns to split and the duration - * @deprecated * @param {Number} duration * @param {Number} cols * @return {cc.SplitCols} */ -cc.SplitCols.create = function (duration, cols) { +cc.splitCols = function (duration, cols) { return new cc.SplitCols(duration, cols); -}; \ No newline at end of file +}; +/** + * Please use cc.splitCols instead + * creates the action with the number of columns to split and the duration + * @param {Number} duration + * @param {Number} cols + * @return {cc.SplitCols} + * @static + * @deprecated + */ +cc.SplitCols.create = cc.splitCols; \ No newline at end of file From 161b9dfae137c9cef8998e2c31fdb0db5767c035 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 4 Aug 2014 15:19:07 +0800 Subject: [PATCH 0384/1564] Fixed #5782: Improve comments --- cocos2d/actions3d/CCActionGrid.js | 7 ++++++- cocos2d/actions3d/CCActionGrid3D.js | 11 ++++++++++- cocos2d/actions3d/CCActionPageTurn3D.js | 1 + cocos2d/actions3d/CCActionTiledGrid.js | 23 ++++++++++++++--------- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index e7aa4607bb..e8c6fab6ae 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -101,6 +101,7 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ /** * creates the action with size and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.GridAction} @@ -165,6 +166,7 @@ cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{ /** * creates the action with size and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.Grid3DAction} @@ -228,6 +230,7 @@ cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{ /** * Creates the action with duration and grid size + * @function * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.TiledGrid3DAction} @@ -251,7 +254,7 @@ cc.TiledGrid3DAction.create = cc.tiledGrid3DAction; * cc.StopGrid action.
    * @warning Don't call this action if another grid action is active.
    * Call if you want to remove the the grid effect. Example:
    - * cc.Sequence.create(Lens.action(...), cc.StopGrid.create(...), null);
    + * cc.sequence(Lens.action(...), cc.stopGrid(...), null);
    *

    * @class * @extends cc.ActionInstant @@ -267,6 +270,7 @@ cc.StopGrid = cc.ActionInstant.extend(/** @lends cc.StopGrid# */{ /** * Allocates and initializes the action + * @function * @return {cc.StopGrid} */ cc.stopGrid = function () { @@ -318,6 +322,7 @@ cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{ /** * creates an action with the number of times that the current grid will be reused + * @function * @param {Number} times * @return {cc.ReuseGrid} */ diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index e2c5544829..d5918dbafe 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -115,6 +115,7 @@ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ /** * Create a wave 3d action with duration, grid size, waves and amplitude + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -242,6 +243,7 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ /** * Create a Flip X 3D action with duration + * @function * @param {Number} duration * @return {cc.FlipX3D} */ @@ -342,6 +344,7 @@ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ /** * Create a flip Y 3d action with duration + * @function * @param {Number} duration * @return {cc.FlipY3D} */ @@ -496,6 +499,7 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ /** * creates a lens 3d action with center position, radius + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -646,6 +650,7 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ }); /** * creates a ripple 3d action with radius, number of waves, amplitude + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -731,8 +736,8 @@ cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{ }); /** - * Please use cc.shaky3D instead * creates the action with a range, shake Z vertices, a grid and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -743,6 +748,7 @@ cc.shaky3D = function (duration, gridSize, range, shakeZ) { return new cc.Shaky3D(duration, gridSize, range, shakeZ); }; /** + * Please use cc.shaky3D instead * creates the action with a range, shake Z vertices, a grid and duration * @param {Number} duration * @param {cc.Size} gridSize @@ -846,6 +852,7 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ /** * creates the action with amplitude, a grid and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -971,6 +978,7 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ /** * initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -1119,6 +1127,7 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ /** * creates the action with center position, number of twirls, amplitude, a grid size and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position diff --git a/cocos2d/actions3d/CCActionPageTurn3D.js b/cocos2d/actions3d/CCActionPageTurn3D.js index 5fb09ef0f8..5fc0d8c4be 100644 --- a/cocos2d/actions3d/CCActionPageTurn3D.js +++ b/cocos2d/actions3d/CCActionPageTurn3D.js @@ -93,6 +93,7 @@ cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{ /** * create PageTurn3D action + * @function * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.PageTurn3D} diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index 97f59d590d..a44869a9b7 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -99,6 +99,7 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ /** * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -200,6 +201,7 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D /** * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -384,6 +386,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ /** * creates the action with a random seed, the grid size and the duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} seed @@ -485,6 +488,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ /** * creates the action with the grid size and the duration + * @function * @param duration * @param gridSize * @return {cc.FadeOutTRTiles} @@ -525,6 +529,7 @@ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{ /** * creates the action with the grid size and the duration + * @function * @param duration * @param gridSize * @return {cc.FadeOutBLTiles} @@ -571,6 +576,7 @@ cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{ /** * creates the action with the grid size and the duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutUpTiles} @@ -605,6 +611,7 @@ cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend(/** @lends cc.FadeOutDownTiles# * /** * creates the action with the grid size and the duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutDownTiles} @@ -730,6 +737,7 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ /** * creates the action with a random seed, the grid size and the duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number|Null} [seed=0] @@ -737,10 +745,10 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ * @example * // example * // turnOffTiles without seed - * var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y)); + * var toff = cc.turnOffTiles(this._duration, cc.size(x, y)); * * // turnOffTiles with seed - * var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y), 0); + * var toff = cc.turnOffTiles(this._duration, cc.size(x, y), 0); */ cc.turnOffTiles = function (duration, gridSize, seed) { return new cc.TurnOffTiles(duration, gridSize, seed); @@ -754,13 +762,6 @@ cc.turnOffTiles = function (duration, gridSize, seed) { * @return {cc.TurnOffTiles} * @static * @deprecated - * @example - * // example - * // turnOffTiles without seed - * var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y)); - * - * // turnOffTiles with seed - * var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y), 0); */ cc.TurnOffTiles.create = cc.turnOffTiles; @@ -858,6 +859,7 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ /** * creates the action with a number of waves, the waves amplitude, the grid size and the duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -988,6 +990,7 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ /** * creates the action with the number of jumps, the sin amplitude, the grid size and the duration + * @function * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} numberOfJumps @@ -1069,6 +1072,7 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ /** * creates the action with the number of rows to split and the duration + * @function * @param {Number} duration * @param {Number} rows * @return {cc.SplitRows} @@ -1148,6 +1152,7 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ /** * creates the action with the number of columns to split and the duration + * @function * @param {Number} duration * @param {Number} cols * @return {cc.SplitCols} From 4b5ee288b74baba92ce6bfa21c99778b8bb4e1ff Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 4 Aug 2014 15:19:38 +0800 Subject: [PATCH 0385/1564] Fixed #5782: Move lower case creation functions definitions --- cocos2d/actions/CCAction.js | 54 ++- cocos2d/actions/CCActionCamera.js | 21 +- cocos2d/actions/CCActionCatmullRom.js | 76 ++++- cocos2d/actions/CCActionEase.js | 362 +++++++++++++++----- cocos2d/actions/CCActionInstant.js | 123 +++++-- cocos2d/actions/CCActionInterval.js | 469 ++++++++++++++++++++------ cocos2d/actions/CCActionTween.js | 69 +--- 7 files changed, 874 insertions(+), 300 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 1cd844d00c..c9e0df1142 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -180,15 +180,24 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ } }); /** Allocates and initializes the action + * @function * @returns {cc.Action} * @example - * @deprecated * // example - * var action = cc.Action.create(); + * var action = cc.action(); */ -cc.Action.create = function () { +cc.action = function () { return new cc.Action(); }; +/** + * Please use cc.action instead + * Allocates and initializes the action + * @returns {cc.Action} + * @example + * @static + * @deprecated + */ +cc.Action.create = cc.action; /** @@ -361,16 +370,27 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ return this._innerAction; } }); -/** creates the action +/** creates the speed action + * @function * * @param {cc.ActionInterval} action * @param {Number} speed * @return {cc.Speed} - * @deprecated */ -cc.Speed.create = function (action, speed) { +cc.speed = function (action, speed) { return new cc.Speed(action, speed); }; +/** + * Please use cc.speed instead + * creates the action + * + * @param {cc.ActionInterval} action + * @param {Number} speed + * @return {cc.Speed} + * @static + * @deprecated + */ +cc.Speed.create = cc.speed; /** * cc.Follow is an action that "follows" a node. @@ -378,7 +398,7 @@ cc.Speed.create = function (action, speed) { * @example * //example * //Instead of using cc.Camera as a "follower", use this action instead. - * layer.runAction(cc.Follow.actionWithTarget(hero)); + * layer.runAction(cc.follow(hero)); * @class * @extends cc.Action @@ -556,22 +576,34 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ }); /** creates the action with a set boundary
    * creates the action with no boundary set + * @function * @param {cc.Node} followedNode * @param {cc.Rect} rect * @return {cc.Follow|Null} returns the cc.Follow object on success - * @deprecated * @example * // example * // creates the action with a set boundary * var sprite = cc.Sprite.create("spriteFileName"); - * var followAction = cc.Follow.create(sprite, cc.rect(0, 0, s.width * 2 - 100, s.height)); + * var followAction = cc.follow(sprite, cc.rect(0, 0, s.width * 2 - 100, s.height)); * this.runAction(followAction); * * // creates the action with no boundary set * var sprite = cc.Sprite.create("spriteFileName"); - * var followAction = cc.Follow.create(sprite); + * var followAction = cc.follow(sprite); * this.runAction(followAction); */ -cc.Follow.create = function (followedNode, rect) { +cc.follow = function (followedNode, rect) { return new cc.Follow(followedNode, rect); }; + +/** + * Please use cc.follow instead + * creates the action with a set boundary
    + * creates the action with no boundary set + * @param {cc.Node} followedNode + * @param {cc.Rect} rect + * @return {cc.Follow|Null} returns the cc.Follow object on success + * @static + * @deprecated + */ +cc.Follow.create = cc.follow; diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 1a5402c5ae..25275c9d74 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -86,7 +86,7 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{ }, reverse:function () { - return cc.ReverseTime.create(this); + return cc.reverseTime(this); } }); @@ -219,6 +219,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ /** * creates a cc.OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX + * @function * @param {Number} t time * @param {Number} radius * @param {Number} deltaRadius @@ -227,8 +228,22 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ * @param {Number} angleX * @param {Number} deltaAngleX * @return {cc.OrbitCamera} - * @deprecated */ -cc.OrbitCamera.create = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) { +cc.orbitCamera = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) { return new cc.OrbitCamera(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX); }; +/** + * Please use cc.orbitCamera instead + * creates a cc.OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX + * @param {Number} t time + * @param {Number} radius + * @param {Number} deltaRadius + * @param {Number} angleZ + * @param {Number} deltaAngleZ + * @param {Number} angleX + * @param {Number} deltaAngleX + * @return {cc.OrbitCamera} + * @static + * @deprecated + */ +cc.OrbitCamera.create = cc.orbitCamera; diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index 03fefd43b5..b16b4a4e93 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -116,7 +116,7 @@ cc.reverseControlPointsInline = function (controlPoints) { * * @example * //create a cc.CardinalSplineTo - * var action1 = cc.CardinalSplineTo.create(3, array, 0); + * var action1 = cc.cardinalSplineTo(3, array, 0); */ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# */{ /** Array of control points */ @@ -235,7 +235,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * */ reverse:function () { var reversePoints = cc.reverseControlPoints(this._points); - return cc.CardinalSplineTo.create(this._duration, reversePoints, this._tension); + return cc.cardinalSplineTo(this._duration, reversePoints, this._tension); }, /** @@ -271,15 +271,26 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * * @param {Array} points array of control points * @param {Number} tension * @return {cc.CardinalSplineTo} - * @deprecated * * @example * //create a cc.CardinalSplineTo - * var action1 = cc.CardinalSplineTo.create(3, array, 0); + * var action1 = cc.cardinalSplineTo(3, array, 0); */ -cc.CardinalSplineTo.create = function (duration, points, tension) { +cc.cardinalSplineTo = function (duration, points, tension) { return new cc.CardinalSplineTo(duration, points, tension); }; +/** + * Please use cc.cardinalSplineTo instead + * creates an action with a Cardinal Spline array of points and tension + * @function + * @param {Number} duration + * @param {Array} points array of control points + * @param {Number} tension + * @return {cc.CardinalSplineTo} + * @static + * @deprecated + */ +cc.CardinalSplineTo.create = cc.cardinalSplineTo; /** * Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline @@ -288,7 +299,7 @@ cc.CardinalSplineTo.create = function (duration, points, tension) { * * @example * //create a cc.CardinalSplineBy - * var action1 = cc.CardinalSplineBy.create(3, array, 0); + * var action1 = cc.cardinalSplineBy(3, array, 0); */ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# */{ _startPosition:null, @@ -354,7 +365,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# reverseArray[i] = current; p = current; } - return cc.CardinalSplineBy.create(this._duration, reverseArray, this._tension); + return cc.cardinalSplineBy(this._duration, reverseArray, this._tension); }, /** @@ -388,11 +399,22 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# * @param {Array} points * @param {Number} tension * @return {cc.CardinalSplineBy} - * @deprecated */ -cc.CardinalSplineBy.create = function (duration, points, tension) { +cc.cardinalSplineBy = function (duration, points, tension) { return new cc.CardinalSplineBy(duration, points, tension); }; +/** + * Please use cc.cardinalSplineBy instead + * creates an action with a Cardinal Spline array of points and tension + * @function + * @param {Number} duration + * @param {Array} points + * @param {Number} tension + * @return {cc.CardinalSplineBy} + * @static + * @deprecated + */ +cc.CardinalSplineBy.create = cc.cardinalSplineBy; /** *

    @@ -404,7 +426,7 @@ cc.CardinalSplineBy.create = function (duration, points, tension) { * @extends cc.CardinalSplineTo * * @example - * var action1 = cc.CatmullRomTo.create(3, array); + * var action1 = cc.catmullRomTo(3, array); */ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{ @@ -446,17 +468,27 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{ /** * creates an action with a Cardinal Spline array of points and tension + * @function * @param {Number} dt * @param {Array} points * @return {cc.CatmullRomTo} - * @deprecated * * @example - * var action1 = cc.CatmullRomTo.create(3, array); + * var action1 = cc.catmullRomTo(3, array); */ -cc.CatmullRomTo.create = function (dt, points) { +cc.catmullRomTo = function (dt, points) { return new cc.CatmullRomTo(dt, points); }; +/** + * Please use cc.catmullRomTo instead + * creates an action with a Cardinal Spline array of points and tension + * @param {Number} dt + * @param {Array} points + * @return {cc.CatmullRomTo} + * @static + * @deprecated + */ +cc.CatmullRomTo.create = cc.catmullRomTo; /** *

    @@ -468,7 +500,7 @@ cc.CatmullRomTo.create = function (dt, points) { * @extends cc.CardinalSplineBy * * @example - * var action1 = cc.CatmullRomBy.create(3, array); + * var action1 = cc.catmullRomBy(3, array); */ cc.CatmullRomBy = cc.CardinalSplineBy.extend({ @@ -511,10 +543,20 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({ /** * Creates an action with a Cardinal Spline array of points and tension - * @deprecated + * @function + * @param {Number} dt + * @param {Array} points + * @return {cc.CatmullRomBy} * @example - * var action1 = cc.CatmullRomBy.create(3, array); + * var action1 = cc.catmullRomBy(3, array); */ -cc.CatmullRomBy.create = function (dt, points) { +cc.catmullRomBy = function (dt, points) { return new cc.CatmullRomBy(dt, points); }; +/** + * Please use cc.catmullRomBy instead + * Creates an action with a Cardinal Spline array of points and tension + * @static + * @deprecated + */ +cc.CatmullRomBy.create = cc.catmullRomBy; diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 1b639e5dca..bf3495072c 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -106,14 +106,22 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ /** creates the action of ActionEase * @param {cc.ActionInterval} action * @return {cc.ActionEase} - * @deprecated * @example * // example - * var moveEase = cc.ActionEase.create(action); + * var moveEase = cc.actionEase(action); */ -cc.ActionEase.create = function (action) { +cc.actionEase = function (action) { return new cc.ActionEase(action); }; +/** + * Please use cc.actionEase instead + * creates the action of ActionEase + * @param {cc.ActionInterval} action + * @return {cc.ActionEase} + * @static + * @deprecated + */ +cc.ActionEase.create = cc.actionEase; /** * Base class for Easing actions with rate parameters @@ -186,14 +194,23 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseRateAction} - * @deprecated * @example * // example - * var moveEaseRateAction = cc.EaseRateAction.create(action, 3.0); + * var moveEaseRateAction = cc.easeRateAction(action, 3.0); */ -cc.EaseRateAction.create = function (action, rate) { +cc.easeRateAction = function (action, rate) { return new cc.EaseRateAction(action, rate); }; +/** + * Please use cc.easeRateAction instead + * Creates the action with the inner action and the rate parameter + * @param {cc.ActionInterval} action + * @param {Number} rate + * @return {cc.EaseRateAction} + * @static + * @deprecated + */ +cc.EaseRateAction.create = cc.easeRateAction; /** * cc.EaseIn action with a rate @@ -222,19 +239,26 @@ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ } }); -/** Creates the action with the inner action and the rate parameter +/** + * Creates the action with the inner action and the rate parameter + * @static * @deprecated * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseIn} - * @example - * // example - * var moveEaseIn = cc.EaseIn.create(action, 3.0); */ cc.EaseIn.create = function (action, rate) { return new cc.EaseIn(action, rate); }; +/** Creates the action easing object with the rate parameter + * @function + * @param {Number} rate + * @return {Object} + * @example + * // example + * action.easing(cc.easeIn(3.0)); + */ cc.easeIn = function (rate) { return { _rate: rate, @@ -275,18 +299,24 @@ cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ }); /** Creates the action with the inner action and the rate parameter + * @static * @deprecated * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseOut} - * @example - * // example - * var moveEaseOut = cc.EaseOut.create(action, 3.0); */ cc.EaseOut.create = function (action, rate) { return new cc.EaseOut(action, rate); }; +/** Creates the action easing object with the rate parameter + * @function + * @param {Number} rate + * @return {Object} + * @example + * // example + * action.easing(cc.easeOut(3.0)); + */ cc.easeOut = function (rate) { return { _rate: rate, @@ -331,18 +361,24 @@ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ }); /** Creates the action with the inner action and the rate parameter + * @static * @deprecated * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseInOut} - * @example - * // example - * var moveEaseInOut = cc.EaseInOut.create(action, 3.0); */ cc.EaseInOut.create = function (action, rate) { return new cc.EaseInOut(action, rate); }; +/** Creates the action easing object with the rate parameter + * @function + * @param {Number} rate + * @return {Object} + * @example + * // example + * action.easing(cc.easeInOut(3.0)); + */ cc.easeInOut = function (rate) { return { _rate: rate, @@ -387,12 +423,10 @@ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ }); /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseExponentialIn} - * @example - * // example - * var moveEaseExponentialIn = cc.EaseExponentialIn.create(action); */ cc.EaseExponentialIn.create = function (action) { return new cc.EaseExponentialIn(action); @@ -406,6 +440,14 @@ cc._easeExponentialInObj = { return cc._easeExponentialOutObj; } }; + +/** creates the action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeExponentialIn()); + */ cc.easeExponentialIn = function(){ return cc._easeExponentialInObj; }; @@ -438,12 +480,10 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# * }); /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseExponentialOut} - * @example - * // example - * var moveEaseExponentialOut = cc.EaseExponentialOut.create(action); */ cc.EaseExponentialOut.create = function (action) { return new cc.EaseExponentialOut(action); @@ -457,6 +497,12 @@ cc._easeExponentialOutObj = { return cc._easeExponentialInObj; } }; +/** creates the action easing object + * @return {cc.EaseExponentialOut} + * @example + * // example + * action.easing(cc.easeExponentialOut()); + */ cc.easeExponentialOut = function(){ return cc._easeExponentialOutObj; }; @@ -496,12 +542,10 @@ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOu }); /** creates an EaseExponentialInOut action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseExponentialInOut} - * @example - * // example - * var moveEaseExponentialInOut = cc.EaseExponentialInOut.create(action); */ cc.EaseExponentialInOut.create = function (action) { return new cc.EaseExponentialInOut(action); @@ -522,6 +566,14 @@ cc._easeExponentialInOutObj = { return cc._easeExponentialInOutObj; } }; +/** + * creates an EaseExponentialInOut action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeExponentialInOut()); + */ cc.easeExponentialInOut = function(){ return cc._easeExponentialInOutObj; }; @@ -555,12 +607,10 @@ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ }); /** creates an EaseSineIn action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseSineIn} - * @example - * // example - * var moveSineIn = cc.EaseSineIn.create(action); */ cc.EaseSineIn.create = function (action) { return new cc.EaseSineIn(action); @@ -574,6 +624,13 @@ cc._easeSineInObj = { return cc._easeSineOutObj; } }; +/** creates an EaseSineIn action + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeSineIn()); + */ cc.easeSineIn = function(){ return cc._easeSineInObj; }; @@ -607,12 +664,10 @@ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ }); /** creates an EaseSineOut action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseSineOut} - * @example - * // example - * var moveEaseOut = cc.EaseSineOut.create(action); */ cc.EaseSineOut.create = function (action) { return new cc.EaseSineOut(action); @@ -626,6 +681,13 @@ cc._easeSineOutObj = { return cc._easeSineInObj; } }; +/** creates an EaseSineOut action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeSineOut()); + */ cc.easeSineOut = function(){ return cc._easeSineOutObj; }; @@ -659,12 +721,10 @@ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ }); /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseSineInOut} - * @example - * // example - * var moveEaseSineInOut = cc.EaseSineInOut.create(action); */ cc.EaseSineInOut.create = function (action) { return new cc.EaseSineInOut(action); @@ -678,6 +738,13 @@ cc._easeSineInOutObj = { return cc._easeSineInOutObj; } }; +/** + * creates the action easing object + * @return {cc.EaseSineInOut} + * @example + * // example + * action.easing(cc.easeSineInOut()); + */ cc.easeSineInOut = function(){ return cc._easeSineInOutObj; }; @@ -747,13 +814,11 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ }); /** Creates the action with the inner action and the period in radians (default is 0.3) + * @static * @deprecated * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElastic} - * @example - * // example - * var moveEaseElastic = cc.EaseElastic.create(action, 3.0); */ cc.EaseElastic.create = function (action, period) { return new cc.EaseElastic(action, period); @@ -800,9 +865,6 @@ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticIn} - * @example - * // example - * var moveEaseElasticIn = cc.EaseElasticIn.create(action, 3.0); */ cc.EaseElasticIn.create = function (action, period) { return new cc.EaseElasticIn(action, period); @@ -821,6 +883,14 @@ cc._easeElasticInObj = { } }; +/** Creates the action easing obejct with the period in radians (default is 0.3) + * @function + * @param {Number} [period=0.3] + * @return {Object} + * @example + * // example + * action.easing(cc.easeElasticIn(3.0)); + */ cc.easeElasticIn = function (period) { if(period && period !== 0.3){ return { @@ -883,9 +953,6 @@ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticOut} - * @example - * // example - * var moveEaseElasticOut = cc.EaseElasticOut.create(action, 3.0); */ cc.EaseElasticOut.create = function (action, period) { return new cc.EaseElasticOut(action, period); @@ -900,7 +967,14 @@ cc._easeElasticOutObj = { return cc._easeElasticInObj; } }; - +/** Creates the action easing object with the period in radians (default is 0.3) + * @function + * @param {Number} [period=0.3] + * @return {Object} + * @example + * // example + * action.easing(cc.easeElasticOut(3.0)); + */ cc.easeElasticOut = function (period) { if(period && period !== 0.3){ return { @@ -965,14 +1039,19 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticInOut} - * @example - * // example - * var moveEaseElasticInOut = cc.EaseElasticInOut.create(action, 3.0); */ cc.EaseElasticInOut.create = function (action, period) { return new cc.EaseElasticInOut(action, period); }; +/** Creates the action easing object with the period in radians (default is 0.3) + * @function + * @param {Number} [period=0.3] + * @return {Object} + * @example + * // example + * action.easing(cc.easeElasticInOut(3.0)); + */ cc.easeElasticInOut = function (period) { period = period || 0.3; return { @@ -1041,12 +1120,10 @@ cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{ }); /** creates an ease bounce action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounce} - * @example - * // example - * var moveEaseBounce = cc.EaseBounce.create(action); */ cc.EaseBounce.create = function (action) { return new cc.EaseBounce(action); @@ -1082,12 +1159,10 @@ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ }); /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounceIn} - * @example - * // example - * var moveEaseBounceIn = cc.EaseBounceIn.create(action); */ cc.EaseBounceIn.create = function (action) { return new cc.EaseBounceIn(action); @@ -1116,6 +1191,13 @@ cc._easeBounceInObj = { return cc._easeBounceOutObj; } }; +/** creates the action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeBounceIn()); + */ cc.easeBounceIn = function(){ return cc._easeBounceInObj; }; @@ -1150,12 +1232,10 @@ cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{ }); /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounceOut} - * @example - * // example - * var moveEaseBounceOut = cc.EaseBounceOut.create(action); */ cc.EaseBounceOut.create = function (action) { return new cc.EaseBounceOut(action); @@ -1169,6 +1249,14 @@ cc._easeBounceOutObj = { return cc._easeBounceInObj; } }; +/** + * Creates the action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeBounceOut()); + */ cc.easeBounceOut = function(){ return cc._easeBounceOutObj; }; @@ -1209,12 +1297,10 @@ cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ }); /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBounceInOut} - * @example - * // example - * var moveEaseBounceInOut = cc.EaseBounceInOut.create(action); */ cc.EaseBounceInOut.create = function (action) { return new cc.EaseBounceInOut(action); @@ -1235,7 +1321,14 @@ cc._easeBounceInOutObj = { return cc._easeBounceInOutObj; } }; - +/** + * Creates the action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeBounceInOut()); + */ cc.easeBounceInOut = function(){ return cc._easeBounceInOutObj; }; @@ -1272,12 +1365,10 @@ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBackIn} - * @example - * // example - * var moveEaseBackIn = cc.EaseBackIn.create(action); */ cc.EaseBackIn.create = function (action) { return new cc.EaseBackIn(action); @@ -1292,7 +1383,13 @@ cc._easeBackInObj = { return cc._easeBackOutObj; } }; - +/** creates the action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeBackIn()); + */ cc.easeBackIn = function(){ return cc._easeBackInObj; }; @@ -1328,12 +1425,10 @@ cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ }); /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBackOut} - * @example - * // example - * var moveEaseBackOut = cc.EaseBackOut.create(action); */ cc.EaseBackOut.create = function (action) { return new cc.EaseBackOut(action); @@ -1349,7 +1444,13 @@ cc._easeBackOutObj = { return cc._easeBackInObj; } }; - +/** creates the action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeBackOut()); + */ cc.easeBackOut = function(){ return cc._easeBackOutObj; }; @@ -1391,12 +1492,10 @@ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ /** creates the action + * @static * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseBackInOut} - * @example - * // example - * var moveEaseBackInOut = cc.EaseBackInOut.create(action); */ cc.EaseBackInOut.create = function (action) { return new cc.EaseBackInOut(action); @@ -1417,7 +1516,13 @@ cc._easeBackInOutObj = { return cc._easeBackInOutObj; } }; - +/** creates the action easing object + * @function + * @return {Object} + * @example + * // example + * action.easing(cc.easeBackInOut()); + */ cc.easeBackInOut = function(){ return cc._easeBackInOutObj; }; @@ -1466,6 +1571,7 @@ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionIn} @@ -1474,6 +1580,14 @@ cc.EaseBezierAction.create = function(action){ return new cc.EaseBezierAction(action); }; +/** + * creates the action easing object + * @param {Number} p0 The first bezier parameter + * @param {Number} p1 The second bezier parameter + * @param {Number} p2 The third bezier parameter + * @param {Number} p3 The fourth bezier parameter + * @returns {Object} + */ cc.easeBezierAction = function(p0, p1, p2, p3){ return { easing: function(time){ @@ -1514,6 +1628,7 @@ cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActio /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionIn} @@ -1528,7 +1643,10 @@ cc._easeQuadraticActionIn = { return cc._easeQuadraticActionIn; } }; - +/** + * creates the action easing object + * @returns {Object} + */ cc.easeQuadraticActionIn = function(){ return cc._easeQuadraticActionIn; }; @@ -1558,6 +1676,7 @@ cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActi /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1572,7 +1691,11 @@ cc._easeQuadraticActionOut = { return cc._easeQuadraticActionOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuadraticActionOut = function(){ return cc._easeQuadraticActionOut; }; @@ -1608,6 +1731,7 @@ cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticAc /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1622,7 +1746,11 @@ cc._easeQuadraticActionInOut = { return cc._easeQuadraticActionInOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuadraticActionInOut = function(){ return cc._easeQuadraticActionInOut; }; @@ -1650,6 +1778,7 @@ cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1664,7 +1793,11 @@ cc._easeQuarticActionIn = { return cc._easeQuarticActionIn; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuarticActionIn = function(){ return cc._easeQuarticActionIn; }; @@ -1693,6 +1826,7 @@ cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOu /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1707,7 +1841,11 @@ cc._easeQuarticActionOut = { return cc._easeQuarticActionOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuarticActionOut = function(){ return cc._easeQuarticActionOut; }; @@ -1739,6 +1877,7 @@ cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticAction /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1753,7 +1892,11 @@ cc._easeQuarticActionInOut = { return cc._easeQuarticActionInOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuarticActionInOut = function(){ return cc._easeQuarticActionInOut; }; @@ -1781,6 +1924,7 @@ cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1795,7 +1939,11 @@ cc._easeQuinticActionIn = { return cc._easeQuinticActionIn; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuinticActionIn = function(){ return cc._easeQuinticActionIn; }; @@ -1824,6 +1972,7 @@ cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOu /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1838,7 +1987,11 @@ cc._easeQuinticActionOut = { return cc._easeQuinticActionOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuinticActionOut = function(){ return cc._easeQuinticActionOut; }; @@ -1870,6 +2023,7 @@ cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticAction /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1884,7 +2038,11 @@ cc._easeQuinticActionInOut = { return cc._easeQuinticActionInOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeQuinticActionInOut = function(){ return cc._easeQuinticActionInOut; }; @@ -1912,6 +2070,7 @@ cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# * /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1926,7 +2085,11 @@ cc._easeCircleActionIn = { return cc._easeCircleActionIn; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeCircleActionIn = function(){ return cc._easeCircleActionIn; }; @@ -1955,6 +2118,7 @@ cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -1969,7 +2133,11 @@ cc._easeCircleActionOut = { return cc._easeCircleActionOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeCircleActionOut = function(){ return cc._easeCircleActionOut; }; @@ -2001,6 +2169,7 @@ cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -2015,7 +2184,11 @@ cc._easeCircleActionInOut = { return cc._easeCircleActionInOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeCircleActionInOut = function(){ return cc._easeCircleActionInOut; }; @@ -2043,6 +2216,7 @@ cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{ /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -2057,7 +2231,11 @@ cc._easeCubicActionIn = { return cc._easeCubicActionIn; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeCubicActionIn = function(){ return cc._easeCubicActionIn; }; @@ -2086,6 +2264,7 @@ cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# * /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -2100,7 +2279,11 @@ cc._easeCubicActionOut = { return cc._easeCubicActionOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeCubicActionOut = function(){ return cc._easeCubicActionOut; }; @@ -2133,6 +2316,7 @@ cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOu /** * creates the action + * @static * @deprecated * @param action * @returns {cc.EaseQuadraticActionOut} @@ -2147,7 +2331,11 @@ cc._easeCubicActionInOut = { return cc._easeCubicActionInOut; } }; - +/** + * creates the action easing object + * @function + * @returns {Object} + */ cc.easeCubicActionInOut = function(){ return cc._easeCubicActionInOut; }; diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index cc88440eb2..3f5d73eb8c 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -85,15 +85,22 @@ cc.Show = cc.ActionInstant.extend(/** @lends cc.Show# */{ } }); /** - * @deprecated + * @function * @return {cc.Show} * @example * // example - * var showAction = cc.Show.create(); + * var showAction = cc.show(); */ -cc.Show.create = function () { +cc.show = function () { return new cc.Show(); }; +/** + * Please use cc.show instead + * @static + * @deprecated + * @return {cc.Show} + */ +cc.Show.create = cc.show; /** * Hide the node @@ -120,15 +127,21 @@ cc.Hide = cc.ActionInstant.extend(/** @lends cc.Hide# */{ } }); /** - * @deprecated + * @function * @return {cc.Hide} * @example * // example - * var hideAction = cc.Hide.create(); + * var hideAction = cc.hide(); */ -cc.Hide.create = function () { +cc.hide = function () { return new cc.Hide(); }; +/** + * @static + * @deprecated + * @return {cc.Hide} + */ +cc.Hide.create = cc.hide; /** Toggles the visibility of a node @@ -156,15 +169,22 @@ cc.ToggleVisibility = cc.ActionInstant.extend(/** @lends cc.ToggleVisibility# */ }); /** - * @deprecated + * @function * @return {cc.ToggleVisibility} * @example * // example - * var toggleVisibilityAction = cc.ToggleVisibility.create(); + * var toggleVisibilityAction = cc.toggleVisibility(); */ -cc.ToggleVisibility.create = function () { +cc.toggleVisibility = function () { return new cc.ToggleVisibility(); }; +/** + * Please use cc.toggleVisibility instead + * @static + * @deprecated + * @return {cc.ToggleVisibility} + */ +cc.ToggleVisibility.create = cc.toggleVisibility; cc.RemoveSelf = cc.ActionInstant.extend({ _isNeedCleanUp: true, @@ -206,17 +226,27 @@ cc.RemoveSelf = cc.ActionInstant.extend({ /** * Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. * - * @deprecated + * @function * @param {Boolean} [isNeedCleanUp=true] * @return {cc.RemoveSelf} * * @example * // example - * var removeSelfAction = cc.RemoveSelf.create(); + * var removeSelfAction = cc.removeSelf(); */ -cc.RemoveSelf.create = function(isNeedCleanUp){ +cc.removeSelf = function(isNeedCleanUp){ return new cc.RemoveSelf(isNeedCleanUp); }; +/** + * Please use cc.removeSelf instead + * Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + * + * @static + * @deprecated + * @param {Boolean} [isNeedCleanUp=true] + * @return {cc.RemoveSelf} + */ +cc.RemoveSelf.create = cc.removeSelf; /** * Flips the sprite horizontally @@ -274,15 +304,25 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ /** * Create a FlipX action to flip or unflip the target * - * @deprecated + * @function * @param {Boolean} flip Indicate whether the target should be flipped or not * @return {cc.FlipX} * @example - * var flipXAction = cc.FlipX.create(true); + * var flipXAction = cc.flipX(true); */ -cc.FlipX.create = function (flip) { +cc.flipX = function (flip) { return new cc.FlipX(flip); }; +/** + * Plese use cc.flipX instead + * Create a FlipX action to flip or unflip the target + * + * @static + * @deprecated + * @param {Boolean} flip Indicate whether the target should be flipped or not + * @return {cc.FlipX} + */ +cc.FlipX.create = cc.flipX; /** * Flips the sprite vertically @@ -339,15 +379,25 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{ /** * Create a FlipY action to flip or unflip the target * - * @deprecated + * @function * @param {Boolean} flip * @return {cc.FlipY} * @example - * var flipYAction = cc.FlipY.create(true); + * var flipYAction = cc.flipY(true); */ -cc.FlipY.create = function (flip) { +cc.flipY = function (flip) { return new cc.FlipY(flip); }; +/** + * Please use cc.flipY instead + * Create a FlipY action to flip or unflip the target + * + * @static + * @deprecated + * @param {Boolean} flip + * @return {cc.FlipY} + */ +cc.FlipY.create = cc.flipY; /** Places the node in a certain position @@ -407,18 +457,28 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ }); /** * Creates a Place action with a position - * @deprecated + * @function * @param {cc.Point|Number} pos * @param {Number} [y] * @return {cc.Place} * @example * // example - * var placeAction = cc.Place.create(cc.p(200, 200)); - * var placeAction = cc.Place.create(200, 200); + * var placeAction = cc.place(cc.p(200, 200)); + * var placeAction = cc.place(200, 200); */ -cc.Place.create = function (pos, y) { +cc.place = function (pos, y) { return new cc.Place(pos, y); }; +/** + * Please use cc.place instead + * Creates a Place action with a position + * @static + * @deprecated + * @param {cc.Point|Number} pos + * @param {Number} [y] + * @return {cc.Place} + */ +cc.Place.create = cc.place; /** Calls a 'callback' @@ -522,7 +582,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ }); /** * Creates the action with the callback - * @deprecated + * @function * @param {function} selector * @param {object|null} [selectorTarget] * @param {*|null} [data] data for function, it accepts all data types. @@ -530,11 +590,22 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ * @example * // example * // CallFunc without data - * var finish = cc.CallFunc.create(this.removeSprite, this); + * var finish = cc.callFunc(this.removeSprite, this); * * // CallFunc with data - * var finish = cc.CallFunc.create(this.removeFromParentAndCleanup, this._grossini, true); + * var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); */ -cc.CallFunc.create = function (selector, selectorTarget, data) { +cc.callFunc = function (selector, selectorTarget, data) { return new cc.CallFunc(selector, selectorTarget, data); }; +/** + * Please use cc.callFunc instead + * Creates the action with the callback + * @static + * @deprecated + * @param {function} selector + * @param {object|null} [selectorTarget] + * @param {*|null} [data] data for function, it accepts all data types. + * @return {cc.CallFunc} + */ +cc.CallFunc.create = cc.callFunc; diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 1fc7d86c56..4eece9c3db 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -41,7 +41,7 @@ * @extends cc.FiniteTimeAction * @Example * // example - * var pingPongAction = cc.Sequence.create(action, action.reverse()); + * var pingPongAction = cc.sequence(action, action.reverse()); */ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _elapsed:0, @@ -287,16 +287,24 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }); /** - * @deprecated + * @function * @param {Number} d duration in seconds * @return {cc.ActionInterval} * @example * // example - * var actionInterval = cc.ActionInterval.create(3); + * var actionInterval = cc.actionInterval(3); */ -cc.ActionInterval.create = function (d) { +cc.actionInterval = function (d) { return new cc.ActionInterval(d); }; +/** + * Please use cc.actionInterval instead + * @static + * @deprecated + * @param {Number} d duration in seconds + * @return {cc.ActionInterval} + */ +cc.ActionInterval.create = cc.actionInterval; /** Runs actions sequentially, one after another @@ -446,18 +454,18 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ } }); /** helper constructor to create an array of sequenceable actions - * @deprecated + * @function * @param {Array|cc.FiniteTimeAction} tempArray * @return {cc.Sequence} * @example * // example * // create sequence with actions - * var seq = cc.Sequence.create(act1, act2); + * var seq = cc.sequence(act1, act2); * * // create sequence with array - * var seq = cc.Sequence.create(actArray); + * var seq = cc.sequence(actArray); */ -cc.Sequence.create = function (/*Multiple Arguments*/tempArray) { +cc.sequence = function (/*Multiple Arguments*/tempArray) { var paramArray = (tempArray instanceof Array) ? tempArray : arguments; if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null)) cc.log("parameters should not be ending with null in Javascript"); @@ -469,6 +477,15 @@ cc.Sequence.create = function (/*Multiple Arguments*/tempArray) { } return prev; }; +/** + * Please use cc.sequence instead + * helper constructor to create an array of sequenceable actions + * @static + * @deprecated + * @param {Array|cc.FiniteTimeAction} tempArray + * @return {cc.Sequence} + */ +cc.Sequence.create = cc.sequence; /** creates the action * @param {cc.FiniteTimeAction} actionOne @@ -502,7 +519,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ * @param {cc.FiniteTimeAction} action * @param {Number} times * @example - * var rep = new cc.Repeat(cc.Sequence.create(jump2, jump1), 5); + * var rep = new cc.Repeat(cc.sequence(jump2, jump1), 5); */ ctor: function (action, times) { cc.ActionInterval.prototype.ctor.call(this); @@ -610,7 +627,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.Repeat.create(this._innerAction.reverse(), this._times); + var action = cc.repeat(this._innerAction.reverse(), this._times); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -634,17 +651,27 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ }); /** * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) - * @deprecated + * @function * @param {cc.FiniteTimeAction} action * @param {Number} times * @return {cc.Repeat} * @example * // example - * var rep = cc.Repeat.create(cc.Sequence.create(jump2, jump1), 5); + * var rep = cc.repeat(cc.sequence(jump2, jump1), 5); */ -cc.Repeat.create = function (action, times) { +cc.repeat = function (action, times) { return new cc.Repeat(action, times); }; +/** + * Please use cc.repeat instead + * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) + * @static + * @deprecated + * @param {cc.FiniteTimeAction} action + * @param {Number} times + * @return {cc.Repeat} + */ +cc.Repeat.create = cc.repeat; /** Repeats an action for ever.
    @@ -661,7 +688,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ * Create a acton which repeat forever * @param {cc.FiniteTimeAction} action * @example - * var repeat = new cc.RepeatForever(cc.RotateBy.create(1.0, 360)); + * var repeat = new cc.RepeatForever(cc.rotateBy(1.0, 360)); */ ctor:function (action) { cc.ActionInterval.prototype.ctor.call(this); @@ -728,7 +755,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.RepeatForever.create(this._innerAction.reverse()); + var action = cc.repeatForever(this._innerAction.reverse()); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -753,16 +780,25 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }); /** * Create a acton which repeat forever - * @deprecated + * @function * @param {cc.FiniteTimeAction} action * @return {cc.RepeatForever} * @example * // example - * var repeat = cc.RepeatForever.create(cc.RotateBy.create(1.0, 360)); + * var repeat = cc.repeatForever(cc.rotateBy(1.0, 360)); */ -cc.RepeatForever.create = function (action) { +cc.repeatForever = function (action) { return new cc.RepeatForever(action); }; +/** + * Please use cc.repeatForever instead + * Create a acton which repeat forever + * @static + * @deprecated + * @param {cc.FiniteTimeAction} action + * @return {cc.RepeatForever} + */ +cc.RepeatForever.create = cc.repeatForever; /** Spawn a new action immediately @@ -777,7 +813,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ * Constructor of cc.Spawn * @param {Array|cc.FiniteTimeAction} tempArray * @example - * var action = new cc.Spawn(cc.JumpBy.create(2, cc.p(300, 0), 50, 4), cc.RotateBy.create(2, 720)); + * var action = new cc.Spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720)); */ ctor:function (tempArray) { cc.ActionInterval.prototype.ctor.call(this); @@ -820,9 +856,9 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ 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(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(d2 - d1)); } ret = true; @@ -882,14 +918,15 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ }); /** - * @deprecated + * Create a spawn action which runs several actions in parallel + * @function * @param {Array|cc.FiniteTimeAction}tempArray * @return {cc.FiniteTimeAction} * @example * // example - * var action = cc.Spawn.create(cc.JumpBy.create(2, cc.p(300, 0), 50, 4), cc.RotateBy.create(2, 720)); + * var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720)); */ -cc.Spawn.create = function (/*Multiple Arguments*/tempArray) { +cc.spawn = function (/*Multiple Arguments*/tempArray) { var paramArray = (tempArray instanceof Array) ? tempArray : arguments; if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null)) cc.log("parameters should not be ending with null in Javascript"); @@ -901,6 +938,14 @@ cc.Spawn.create = function (/*Multiple Arguments*/tempArray) { } return prev; }; +/** + * Please use cc.spawn instead + * @static + * @deprecated + * @param {Array|cc.FiniteTimeAction}tempArray + * @return {cc.FiniteTimeAction} + */ +cc.Spawn.create = cc.spawn; /** * @param {cc.FiniteTimeAction} action1 @@ -1018,18 +1063,29 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ /** * Creates a RotateTo action with separate rotation angles - * @deprecated + * @function * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees. * @param {Number} [deltaAngleY] deltaAngleY in degrees. * @return {cc.RotateTo} * @example * // example - * var rotateTo = cc.RotateTo.create(2, 61.0); + * var rotateTo = cc.rotateTo(2, 61.0); */ -cc.RotateTo.create = function (duration, deltaAngleX, deltaAngleY) { +cc.rotateTo = function (duration, deltaAngleX, deltaAngleY) { return new cc.RotateTo(duration, deltaAngleX, deltaAngleY); }; +/** + * Please use cc.rotateTo instead + * Creates a RotateTo action with separate rotation angles + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {Number} deltaAngleX deltaAngleX in degrees. + * @param {Number} [deltaAngleY] deltaAngleY in degrees. + * @return {cc.RotateTo} + */ +cc.RotateTo.create = cc.rotateTo; /** Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute. @@ -1106,7 +1162,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ * @return {cc.RotateBy} */ reverse:function () { - var action = cc.RotateBy.create(this._duration, -this._angleX, -this._angleY); + var action = cc.rotateBy(this._duration, -this._angleX, -this._angleY); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -1114,18 +1170,28 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }); /** - * @deprecated + * @function * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY] deltaAngleY in degrees * @return {cc.RotateBy} * @example * // example - * var actionBy = cc.RotateBy.create(2, 360); + * var actionBy = cc.rotateBy(2, 360); */ -cc.RotateBy.create = function (duration, deltaAngleX, deltaAngleY) { +cc.rotateBy = function (duration, deltaAngleX, deltaAngleY) { return new cc.RotateBy(duration, deltaAngleX, deltaAngleY); }; +/** + * Please use cc.rotateBy instead + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {Number} deltaAngleX deltaAngleX in degrees + * @param {Number} [deltaAngleY] deltaAngleY in degrees + * @return {cc.RotateBy} + */ +cc.RotateBy.create = cc.rotateBy; /** @@ -1149,7 +1215,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ * @param {cc.Point|Number} deltaPos * @param {Number} [deltaY] * @example - * var actionTo = cc.MoveBy.create(2, cc.p(windowSize.width - 40, windowSize.height - 40)); + * var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40)); */ ctor:function (duration, deltaPos, deltaY) { cc.ActionInterval.prototype.ctor.call(this); @@ -1236,7 +1302,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ * MoveTo reverse is not implemented */ reverse:function () { - var action = cc.MoveBy.create(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); + var action = cc.moveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -1244,18 +1310,28 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ }); /** - * @deprecated + * @function * @param {Number} duration duration in seconds * @param {cc.Point|Number} deltaPos * @param {Number} deltaY * @return {cc.MoveBy} * @example * // example - * var actionTo = cc.MoveBy.create(2, cc.p(windowSize.width - 40, windowSize.height - 40)); + * var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40)); */ -cc.MoveBy.create = function (duration, deltaPos, deltaY) { +cc.moveBy = function (duration, deltaPos, deltaY) { return new cc.MoveBy(duration, deltaPos, deltaY); }; +/** + * Please use cc.moveBy instead + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {cc.Point|Number} deltaPos + * @param {Number} deltaY + * @return {cc.MoveBy} + */ +cc.MoveBy.create = cc.moveBy; /** @@ -1274,7 +1350,7 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ * @param {cc.Point|Number} position * @param {Number} y * @example - * var actionBy = cc.MoveTo.create(2, cc.p(80, 80)); + * var actionBy = new cc.MoveTo(2, cc.p(80, 80)); */ ctor:function (duration, position, y) { cc.MoveBy.prototype.ctor.call(this); @@ -1324,18 +1400,28 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ } }); /** - * @deprecated + * @function * @param {Number} duration duration in seconds * @param {cc.Point} position * @param {Number} y * @return {cc.MoveBy} * @example * // example - * var actionBy = cc.MoveTo.create(2, cc.p(80, 80)); + * var actionBy = cc.moveTo(2, cc.p(80, 80)); */ -cc.MoveTo.create = function (duration, position, y) { +cc.moveTo = function (duration, position, y) { return new cc.MoveTo(duration, position, y); }; +/** + * Please use cc.moveTo instead + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {cc.Point} position + * @param {Number} y + * @return {cc.MoveBy} + */ +cc.MoveTo.create = cc.moveTo; /** * Skews a cc.Node object to given angles by modifying it's skewX and skewY attributes @@ -1424,18 +1510,28 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ } }); /** - * @deprecated + * @function * @param {Number} t time in seconds * @param {Number} sx * @param {Number} sy * @return {cc.SkewTo} * @example * // example - * var actionTo = cc.SkewTo.create(2, 37.2, -37.2); + * var actionTo = cc.skewTo(2, 37.2, -37.2); */ -cc.SkewTo.create = function (t, sx, sy) { +cc.skewTo = function (t, sx, sy) { return new cc.SkewTo(t, sx, sy); }; +/** + * Please use cc.skewTo instead + * @static + * @deprecated + * @param {Number} t time in seconds + * @param {Number} sx + * @param {Number} sy + * @return {cc.SkewTo} + */ +cc.SkewTo.create = cc.skewTo; /** Skews a cc.Node object by skewX and skewY degrees * @class @@ -1496,25 +1592,35 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.SkewBy.create(this._duration, -this._skewX, -this._skewY); + var action = cc.skewBy(this._duration, -this._skewX, -this._skewY); this._cloneDecoration(action); this._reverseEaseList(action); return action; } }); /** - * @deprecated + * @function * @param {Number} t time in seconds * @param {Number} sx sx skew in degrees for X axis * @param {Number} sy sy skew in degrees for Y axis * @return {cc.SkewBy} * @example * // example - * var actionBy = cc.SkewBy.create(2, 0, -90); + * var actionBy = cc.skewBy(2, 0, -90); */ -cc.SkewBy.create = function (t, sx, sy) { +cc.skewBy = function (t, sx, sy) { return new cc.SkewBy(t, sx, sy); }; +/** + * Please use cc.skewBy instead + * @static + * @deprecated + * @param {Number} t time in seconds + * @param {Number} sx sx skew in degrees for X axis + * @param {Number} sy sy skew in degrees for Y axis + * @return {cc.SkewBy} + */ +cc.SkewBy.create = cc.skewBy; /** Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute. @@ -1633,7 +1739,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.JumpBy.create(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); + var action = cc.jumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -1641,7 +1747,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ }); /** - * @deprecated + * @function * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -1650,12 +1756,24 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ * @return {cc.JumpBy} * @example * // example - * var actionBy = cc.JumpBy.create(2, cc.p(300, 0), 50, 4); - * var actionBy = cc.JumpBy.create(2, 300, 0, 50, 4); + * var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4); + * var actionBy = cc.jumpBy(2, 300, 0, 50, 4); */ -cc.JumpBy.create = function (duration, position, y, height, jumps) { +cc.jumpBy = function (duration, position, y, height, jumps) { return new cc.JumpBy(duration, position, y, height, jumps); }; +/** + * Please use cc.jumpBy instead + * @static + * @deprecated + * @param {Number} duration + * @param {cc.Point|Number} position + * @param {Number} [y] + * @param {Number} height + * @param {Number} jumps + * @return {cc.JumpBy} + */ +cc.JumpBy.create = cc.jumpBy; /** Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute. * @class @@ -1726,7 +1844,7 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ }); /** - * @deprecated + * @function * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -1735,12 +1853,24 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ * @return {cc.JumpTo} * @example * // example - * var actionTo = cc.JumpTo.create(2, cc.p(300, 300), 50, 4); - * var actionTo = cc.JumpTo.create(2, 300, 300, 50, 4); + * var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4); + * var actionTo = cc.jumpTo(2, 300, 300, 50, 4); */ -cc.JumpTo.create = function (duration, position, y, height, jumps) { +cc.jumpTo = function (duration, position, y, height, jumps) { return new cc.JumpTo(duration, position, y, height, jumps); }; +/** + * Please use cc.jumpTo instead + * @static + * @deprecated + * @param {Number} duration + * @param {cc.Point|Number} position + * @param {Number} [y] + * @param {Number} height + * @param {Number} jumps + * @return {cc.JumpTo} + */ +cc.JumpTo.create = cc.jumpTo; /** * @function @@ -1873,7 +2003,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ cc.pAdd(locConfig[1], cc.pNeg(locConfig[2])), cc.pAdd(locConfig[0], cc.pNeg(locConfig[2])), cc.pNeg(locConfig[2]) ]; - var action = cc.BezierBy.create(this._duration, r); + var action = cc.bezierBy(this._duration, r); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -1881,18 +2011,27 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ }); /** - * @deprecated + * @function * @param {Number} t time in seconds * @param {Array} c Array of points * @return {cc.BezierBy} * @example * // example * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; - * var bezierForward = cc.BezierBy.create(3, bezier); + * var bezierForward = cc.bezierBy(3, bezier); */ -cc.BezierBy.create = function (t, c) { +cc.bezierBy = function (t, c) { return new cc.BezierBy(t, c); }; +/** + * Please use cc.bezierBy instead + * @static + * @deprecated + * @param {Number} t time in seconds + * @param {Array} c Array of points + * @return {cc.BezierBy} + */ +cc.BezierBy.create = cc.bezierBy; /** An action that moves the target with a cubic Bezier curve to a destination point. @@ -1955,18 +2094,27 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ } }); /** - * @deprecated + * @function * @param {Number} t * @param {Array} c array of points * @return {cc.BezierTo} * @example * // example * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; - * var bezierTo = cc.BezierTo.create(2, bezier); + * var bezierTo = cc.bezierTo(2, bezier); */ -cc.BezierTo.create = function (t, c) { +cc.bezierTo = function (t, c) { return new cc.BezierTo(t, c); }; +/** + * Please use cc.bezierTo instead + * @static + * @deprecated + * @param {Number} t + * @param {Array} c array of points + * @return {cc.BezierTo} + */ +cc.BezierTo.create = cc.bezierTo; /** Scales a cc.Node object to a zoom factor by modifying it's scale attribute. @@ -2050,7 +2198,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ } }); /** - * @deprecated + * @function * @param {Number} duration * @param {Number} sx scale parameter in X * @param {Number} [sy] scale parameter in Y, if Null equal to sx @@ -2058,14 +2206,24 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ * @example * // example * // It scales to 0.5 in both X and Y. - * var actionTo = cc.ScaleTo.create(2, 0.5); + * var actionTo = cc.scaleTo(2, 0.5); * * // It scales to 0.5 in x and 2 in Y - * var actionTo = cc.ScaleTo.create(2, 0.5, 2); + * var actionTo = cc.scaleTo(2, 0.5, 2); */ -cc.ScaleTo.create = function (duration, sx, sy) { //function overload +cc.scaleTo = function (duration, sx, sy) { //function overload return new cc.ScaleTo(duration, sx, sy); }; +/** + * Please use cc.scaleTo instead + * @static + * @deprecated + * @param {Number} duration + * @param {Number} sx scale parameter in X + * @param {Number} [sy] scale parameter in Y, if Null equal to sx + * @return {cc.ScaleTo} + */ +cc.ScaleTo.create = cc.scaleTo; /** Scales a cc.Node object a zoom factor by modifying it's scale attribute. @@ -2086,7 +2244,7 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.ScaleBy.create(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); + var action = cc.scaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -2104,21 +2262,31 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ } }); /** - * @deprecated + * @function * @param {Number} duration duration in seconds * @param {Number} sx sx scale parameter in X * @param {Number|Null} [sy=] sy scale parameter in Y, if Null equal to sx * @return {cc.ScaleBy} * @example * // example without sy, it scales by 2 both in X and Y - * var actionBy = cc.ScaleBy.create(2, 2); + * var actionBy = cc.scaleBy(2, 2); * * //example with sy, it scales by 0.25 in X and 4.5 in Y - * var actionBy2 = cc.ScaleBy.create(2, 0.25, 4.5); + * var actionBy2 = cc.scaleBy(2, 0.25, 4.5); */ -cc.ScaleBy.create = function (duration, sx, sy) { +cc.scaleBy = function (duration, sx, sy) { return new cc.ScaleBy(duration, sx, sy); }; +/** + * Please use cc.scaleBy instead + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {Number} sx sx scale parameter in X + * @param {Number|Null} [sy=] sy scale parameter in Y, if Null equal to sx + * @return {cc.ScaleBy} + */ +cc.ScaleBy.create = cc.scaleBy; /** Blinks a cc.Node object by modifying it's visible attribute * @class @@ -2190,24 +2358,33 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.Blink.create(this._duration, this._times); + var action = cc.blink(this._duration, this._times); this._cloneDecoration(action); this._reverseEaseList(action); return action; } }); /** - * @deprecated + * @function * @param {Number} duration duration in seconds * @param blinks blinks in times * @return {cc.Blink} * @example * // example - * var action = cc.Blink.create(2, 10); + * var action = cc.blink(2, 10); */ -cc.Blink.create = function (duration, blinks) { +cc.blink = function (duration, blinks) { return new cc.Blink(duration, blinks); }; +/** + * Please use cc.blink instead + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param blinks blinks in times + * @return {cc.Blink} + */ +cc.Blink.create = cc.blink; /** Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. * @warning This action doesn't support "reverse" @@ -2276,17 +2453,26 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ }); /** - * @deprecated + * @function * @param {Number} duration * @param {Number} opacity 0-255, 0 is transparent * @return {cc.FadeTo} * @example * // example - * var action = cc.FadeTo.create(1.0, 0); + * var action = cc.fadeTo(1.0, 0); */ -cc.FadeTo.create = function (duration, opacity) { +cc.fadeTo = function (duration, opacity) { return new cc.FadeTo(duration, opacity); }; +/** + * Please use cc.fadeTo instead + * @static + * @deprecated + * @param {Number} duration + * @param {Number} opacity 0-255, 0 is transparent + * @return {cc.FadeTo} + */ +cc.FadeTo.create = cc.fadeTo; /** Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
    * The "reverse" of this action is FadeOut @@ -2338,16 +2524,24 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ }); /** - * @deprecated + * @function * @param {Number} duration duration in seconds * @return {cc.FadeIn} * @example * //example - * var action = cc.FadeIn.create(1.0); + * var action = cc.fadeIn(1.0); */ -cc.FadeIn.create = function (duration) { +cc.fadeIn = function (duration) { return new cc.FadeIn(duration); }; +/** + * Please use cc.fadeIn instead + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @return {cc.FadeIn} + */ +cc.FadeIn.create = cc.fadeIn; /** Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. @@ -2391,16 +2585,24 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ }); /** - * @deprecated + * @function * @param {Number} d duration in seconds * @return {cc.FadeOut} * @example * // example - * var action = cc.FadeOut.create(1.0); + * var action = cc.fadeOut(1.0); */ -cc.FadeOut.create = function (d) { +cc.fadeOut = function (d) { return new cc.FadeOut(d); }; +/** + * Please use cc.fadeOut instead + * @static + * @deprecated + * @param {Number} d duration in seconds + * @return {cc.FadeOut} + */ +cc.FadeOut.create = cc.fadeOut; /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. * @warning This action doesn't support "reverse" @@ -2479,7 +2681,7 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ }); /** - * @deprecated + * @function * @param {Number} duration * @param {Number} red 0-255 * @param {Number} green 0-255 @@ -2487,11 +2689,22 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ * @return {cc.TintTo} * @example * // example - * var action = cc.TintTo.create(2, 255, 0, 255); + * var action = cc.tintTo(2, 255, 0, 255); */ -cc.TintTo.create = function (duration, red, green, blue) { +cc.tintTo = function (duration, red, green, blue) { return new cc.TintTo(duration, red, green, blue); }; +/** + * Please use cc.tintTo instead + * @static + * @deprecated + * @param {Number} duration + * @param {Number} red 0-255 + * @param {Number} green 0-255 + * @param {Number} blue 0-255 + * @return {cc.TintTo} + */ +cc.TintTo.create = cc.tintTo; /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. @@ -2578,7 +2791,7 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.TintBy.create(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); + var action = cc.tintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -2586,7 +2799,7 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ }); /** - * @deprecated + * @function * @param {Number} duration duration in seconds * @param {Number} deltaRed * @param {Number} deltaGreen @@ -2594,11 +2807,22 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ * @return {cc.TintBy} * @example * // example - * var action = cc.TintBy.create(2, -127, -255, -127); + * var action = cc.tintBy(2, -127, -255, -127); */ -cc.TintBy.create = function (duration, deltaRed, deltaGreen, deltaBlue) { +cc.tintBy = function (duration, deltaRed, deltaGreen, deltaBlue) { return new cc.TintBy(duration, deltaRed, deltaGreen, deltaBlue); }; +/** + * Please use cc.tintBy instead + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {Number} deltaRed + * @param {Number} deltaGreen + * @param {Number} deltaBlue + * @return {cc.TintBy} + */ +cc.TintBy.create = cc.tintBy; /** Delays the action a certain amount of seconds * @class @@ -2615,7 +2839,7 @@ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ * @return {cc.ActionInterval} */ reverse:function () { - var action = cc.DelayTime.create(this._duration); + var action = cc.delayTime(this._duration); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -2634,16 +2858,24 @@ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ }); /** - * @deprecated + * @function * @param {Number} d duration in seconds * @return {cc.DelayTime} * @example * // example - * var delay = cc.DelayTime.create(1); + * var delay = cc.delayTime(1); */ -cc.DelayTime.create = function (d) { +cc.delayTime = function (d) { return new cc.DelayTime(d); }; +/** + * Please use cc.delayTime instead + * @static + * @deprecated + * @param {Number} d duration in seconds + * @return {cc.DelayTime} + */ +cc.DelayTime.create = cc.delayTime; /** *

    @@ -2734,16 +2966,24 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ }); /** - * @deprecated + * @function * @param {cc.FiniteTimeAction} action * @return {cc.ReverseTime} * @example * // example - * var reverse = cc.ReverseTime.create(this); + * var reverse = cc.reverseTime(this); */ -cc.ReverseTime.create = function (action) { +cc.reverseTime = function (action) { return new cc.ReverseTime(action); }; +/** + * Please use cc.reverseTime instead + * @static + * @deprecated + * @param {cc.FiniteTimeAction} action + * @return {cc.ReverseTime} + */ +cc.ReverseTime.create = cc.reverseTime; /** Animates a sprite given the name of an Animation @@ -2893,7 +3133,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ } var newAnim = cc.Animation.create(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops()); newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame()); - var action = cc.Animate.create(newAnim); + var action = cc.animate(newAnim); this._cloneDecoration(action); this._reverseEaseList(action); @@ -2912,17 +3152,26 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ /** * create the animate with animation - * @deprecated + * @function * @param {cc.Animation} animation * @return {cc.Animate} * @example * // example * // create the animation with animation - * var anim = cc.Animate.create(dance_grey); + * var anim = cc.animate(dance_grey); */ -cc.Animate.create = function (animation) { +cc.animate = function (animation) { return new cc.Animate(animation); }; +/** + * Please use cc.animate instead + * create the animate with animation + * @static + * @deprecated + * @param {cc.Animation} animation + * @return {cc.Animate} + */ +cc.Animate.create = cc.animate; /** *

    @@ -3007,11 +3256,21 @@ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{ /** * Create an action with the specified action and forced target - * @deprecated + * @function * @param {cc.Node} target * @param {cc.FiniteTimeAction} action * @return {cc.TargetedAction} */ -cc.TargetedAction.create = function (target, action) { +cc.targetedAction = function (target, action) { return new cc.TargetedAction(target, action); }; +/** + * Please use cc.targetedAction instead + * Create an action with the specified action and forced target + * @static + * @deprecated + * @param {cc.Node} target + * @param {cc.FiniteTimeAction} action + * @return {cc.TargetedAction} + */ +cc.TargetedAction.create = cc.targetedAction; diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index bae2ca0384..76cc399073 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -48,13 +48,13 @@ cc.ActionTweenDelegate = cc.Class.extend(/** @lends cc.ActionTweenDelegate */{ * @extends cc.ActionInterval * @example * //For example, if you want to modify the "width" property of a target from 200 to 300 in 2 seconds, then: - * var modifyWidth = cc.ActionTween.create(2,"width",200,300) + * var modifyWidth = cc.actionTween(2,"width",200,300) * target.runAction(modifyWidth); * * //Another example: cc.ScaleTo action could be rewriten using cc.PropertyAction: * // scaleA and scaleB are equivalents - * var scaleA = cc.ScaleTo.create(2,3); - * var scaleB = cc.ActionTween.create(2,"scale",1,3); + * var scaleA = cc.scaleTo(2,3); + * var scaleB = cc.actionTween(2,"scale",1,3); */ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ key:"", @@ -113,7 +113,7 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ * @return {cc.ActionTween} */ reverse:function () { - return cc.ActionTween.create(this.duration, this.key, this.to, this.from); + return cc.actionTween(this.duration, this.key, this.to, this.from); }, clone:function(){ @@ -125,58 +125,25 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ /** * Creates an initializes the action with the property name (key), and the from and to parameters. - * @deprecated + * @function * @param {Number} duration * @param {String} key * @param {Number} from * @param {Number} to * @return {cc.ActionTween} */ -cc.ActionTween.create = function (duration, key, from, to) { +cc.actionTween = function (duration, key, from, to) { return new cc.ActionTween(duration, key, from, to); }; - -cc.action = cc.Action.create; -cc.speed = cc.Speed.create; -cc.follow = cc.Follow.create; -cc.orbitCamera = cc.OrbitCamera.create; -cc.cardinalSplineTo = cc.CardinalSplineTo.create; -cc.cardinalSplineBy = cc.CardinalSplineBy.create; -cc.catmullRomTo = cc.CatmullRomTo.create; -cc.catmullRomBy = cc.CatmullRomBy.create; -cc.show = cc.Show.create; -cc.hide = cc.Hide.create; -cc.toggleVisibility = cc.ToggleVisibility.create; -cc.removeSelf = cc.RemoveSelf.create; -cc.flipX = cc.FlipX.create; -cc.flipY = cc.FlipY.create; -cc.place = cc.Place.create; -cc.callFunc = cc.CallFunc.create; -cc.actionInterval = cc.ActionInterval.create; -cc.sequence = cc.Sequence.create; -cc.repeat = cc.Repeat.create; -cc.repeatForever = cc.RepeatForever.create; -cc.spawn = cc.Spawn.create; -cc.rotateTo = cc.RotateTo.create; -cc.rotateBy = cc.RotateBy.create; -cc.moveBy = cc.MoveBy.create; -cc.moveTo = cc.MoveTo.create; -cc.skewTo = cc.SkewTo.create; -cc.skewBy = cc.SkewBy.create; -cc.jumpBy = cc.JumpBy.create; -cc.jumpTo = cc.JumpTo.create; -cc.bezierBy = cc.BezierBy.create; -cc.bezierTo = cc.BezierTo.create; -cc.scaleTo = cc.ScaleTo.create; -cc.scaleBy = cc.ScaleBy.create; -cc.blink = cc.Blink.create; -cc.fadeTo = cc.FadeTo.create; -cc.fadeIn = cc.FadeIn.create; -cc.fadeOut = cc.FadeOut.create; -cc.tintTo = cc.TintTo.create; -cc.tintBy = cc.TintBy.create; -cc.delayTime = cc.DelayTime.create; -cc.reverseTime = cc.ReverseTime.create; -cc.animate = cc.Animate.create; -cc.targetedAction = cc.TargetedAction.create; -cc.actionTween = cc.ActionTween.create; \ No newline at end of file +/** + * Please use cc.actionTween instead + * Creates an initializes the action with the property name (key), and the from and to parameters. + * @static + * @deprecated + * @param {Number} duration + * @param {String} key + * @param {Number} from + * @param {Number} to + * @return {cc.ActionTween} + */ +cc.ActionTween.create = cc.actionTween; \ No newline at end of file From 7580a292f71de274a13b1d62b61af0c059a690a6 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 4 Aug 2014 15:56:14 +0800 Subject: [PATCH 0386/1564] Fixed #5782: Refactored all progress actions to lower case creation function --- .../progress-timer/CCActionProgressTimer.js | 36 +++++++++++++++---- cocos2d/transitions/CCTransitionProgress.js | 6 ++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index f29590934d..f49d33ab95 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -96,18 +96,29 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ } }); -/** Creates and initializes with a duration and a percent - * @deprecated +/** + * Creates and initializes with a duration and a percent + * @function * @param {Number} duration duration in seconds * @param {Number} percent * @return {cc.ProgressTo} * @example * // example - * var to = cc.ProgressTo.create(2, 100); + * var to = cc.progressTo(2, 100); */ -cc.ProgressTo.create = function (duration, percent) { +cc.progressTo = function (duration, percent) { return new cc.ProgressTo(duration, percent); }; +/** + * Please use cc.progressTo instead + * Creates and initializes with a duration and a percent + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {Number} percent + * @return {cc.ProgressTo} + */ +cc.ProgressTo.create = cc.progressTo; /** * Progress from a percentage to another percentage @@ -180,15 +191,26 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ }); /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage - * @deprecated + * @function * @param {Number} duration duration in seconds * @param {Number} fromPercentage * @param {Number} toPercentage * @return {cc.ProgressFromTo} * @example * // example - * var fromTO = cc.ProgressFromTo.create(2, 100.0, 0.0); + * var fromTO = cc.progressFromTo(2, 100.0, 0.0); */ -cc.ProgressFromTo.create = function (duration, fromPercentage, toPercentage) { +cc.progressFromTo = function (duration, fromPercentage, toPercentage) { return new cc.ProgressFromTo(duration, fromPercentage, toPercentage); }; +/** + * Please use cc.progressFromTo instead + * Creates and initializes the action with a duration, a "from" percentage and a "to" percentage + * @static + * @deprecated + * @param {Number} duration duration in seconds + * @param {Number} fromPercentage + * @param {Number} toPercentage + * @return {cc.ProgressFromTo} + */ +cc.ProgressFromTo.create = cc.progressFromTo; diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index f08a4b948f..e3699fd464 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -92,9 +92,9 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre var pNode = this._progressTimerNodeWithRenderTexture(texture); // create the blend action - var layerAction = cc.Sequence.create( - cc.ProgressFromTo.create(this._duration, this._from, this._to), - cc.CallFunc.create(this.finish, this)); + var layerAction = cc.sequence( + cc.progressFromTo(this._duration, this._from, this._to), + cc.callFunc(this.finish, this)); // run the blend action pNode.runAction(layerAction); From a15b8f03f4fece639ddb8fbc31a458cba213f327 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 4 Aug 2014 15:58:00 +0800 Subject: [PATCH 0387/1564] Issue #2037: Text wrap method --- cocos2d/core/labelttf/CCLabelTTF.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 5b9be1d8fa..752561c74f 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1158,7 +1158,7 @@ cc.LabelTTF._textAlign = ["left", "center", "right"]; cc.LabelTTF._textBaseline = ["top", "middle", "bottom"]; // Class static properties for measure util -cc.LabelTTF._checkRegEx = /(.+?|[\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; +cc.LabelTTF._checkRegEx = /(.+?)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; cc.LabelTTF._reverseCheckRegEx = /(.*)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; cc.LabelTTF._checkEnRegEx = /[\s\-\/\\\:]/; cc.LabelTTF._checkSymbol = /^[\u007e\u0021\u0040\u0023\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u005f\u002b\u007b\u007d\u005b\u005d\u003a\u0026\u0071\u0075\u006f\u0074\u003b\u007c\u003b\u0026\u0023\u0033\u0039\u003b\u005c\u0026\u006c\u0074\u003b\u0026\u0067\u0074\u003b\u003f\u002c\u002e\u002f\uff01\u0040\uffe5\u2026\uff08\uff09\u2014\u002b\u3010\u3011\uff1a\u201c\u007c\uff1b\u2018\u3001\u300a\u300b\uff1f\uff0c\u3002\u3001\u000d\u000a]/; From 7481c00edb307580d91e992a099489c6f7b93445 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 4 Aug 2014 18:18:10 +0800 Subject: [PATCH 0388/1564] issue #5685: fix bugs of create functions --- extensions/ccui/uiwidgets/UICheckBox.js | 2 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- extensions/ccui/uiwidgets/UIRichText.js | 2 +- extensions/ccui/uiwidgets/UIText.js | 2 +- extensions/ccui/uiwidgets/UITextAtlas.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 8aa3fe6581..97411bb1d8 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -618,7 +618,7 @@ _p = null; * var uiCheckBox = ccui.CheckBox.create(); */ ccui.CheckBox.create = function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { - return ccui.CheckBox(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); + return new ccui.CheckBox(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); }; // Constants diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 84876c6760..d643e54d86 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -294,7 +294,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * var uiImageView = ccui.ImageView.create(); */ ccui.ImageView.create = function (imageFileName, texType) { - return ccui.ImageView(imageFileName, texType); + return new ccui.ImageView(imageFileName, texType); }; // Constants diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index d37edb28c9..3a3f2cb0c4 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -398,7 +398,7 @@ _p = null; * var uiLoadingBar = ccui.LoadingBar.create(); */ ccui.LoadingBar.create = function (textureName, percentage) { - return ccui.LoadingBar(textureName, percentage); + return new ccui.LoadingBar(textureName, percentage); }; // Constants diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 8b6cd12659..5b8dd8a490 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -126,7 +126,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage * @returns {ccui.RichElementImage} */ ccui.RichElementImage.create = function (tag, color, opacity, filePath) { - return ccui.RichElementImage(tag, color, opacity, filePath); + return new ccui.RichElementImage(tag, color, opacity, filePath); }; /** diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 9cb6d10683..4784f8429d 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -436,7 +436,7 @@ _p = null; * var uiLabel = ccui.Text.create(); */ ccui.Label = ccui.Text.create = function (textContent, fontName, fontSize) { - return ccui.Text(textContent, fontName, fontSize); + return new ccui.Text(textContent, fontName, fontSize); }; ccui.Text.RENDERER_ZORDER = -1; diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index c345e4878f..30faf18f1c 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -227,7 +227,7 @@ _p = null; * var uiLabelAtlas = ccui.TextAtlas.create(); */ ccui.TextAtlas.create = function (stringValue, charMapFile, itemWidth, itemHeight, startCharMap) { - return ccui.TextAtlas(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); + return new ccui.TextAtlas(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); }; // Constants From 19e1482ac1cd79df3be89ec5ec6c5545c1cc39f3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 4 Aug 2014 19:51:20 +0800 Subject: [PATCH 0389/1564] Fixed #5704: fixed a bug of cc.ScrollView when setClippingEnabled is true --- cocos2d/particle/CCParticleSystem.js | 2 +- .../ccui/base-classes/CCProtectedNode.js | 2 +- extensions/ccui/layouts/UILayout.js | 18 +++++++++--------- .../uiwidgets/scroll-widget/UIScrollView.js | 4 ++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index d052c2ccfe..e58c2e56bf 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2117,7 +2117,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } // color - if (!this._dontTint || cc._renderType === cc._RENDER_TYPE_CANVAS) { + if (!this._dontTint || cc._renderType === cc._RENDER_TYPE_WEBGL) { selParticle.color.r += 0|(selParticle.deltaColor.r * dt); selParticle.color.g += 0|(selParticle.deltaColor.g * dt); selParticle.color.b += 0|(selParticle.deltaColor.b * dt); diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 2431fb772b..bdb53a3d74 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -262,7 +262,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ children[i] && children[i].visit(context); } for (; j < pLen; j++) { - locProtectedChildren[i] && locProtectedChildren[i].visit(context); + locProtectedChildren[j] && locProtectedChildren[j].visit(context); } this._cacheDirty = false; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index c8096906c6..d7791d96c3 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -489,7 +489,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } var context = ctx || cc._renderContext; // Composition mode, costy but support texture stencil - if (this._cangodhelpme() || this._clippingStencil instanceof cc.Sprite) { + //if (this._cangodhelpme() || this._clippingStencil instanceof cc.Sprite) { + if (this._clippingStencil instanceof cc.Sprite) { // Cache the current canvas, for later use (This is a little bit heavy, replace this solution with other walkthrough) var canvas = context.canvas; var locCache = ccui.Layout._getSharedCache(); @@ -500,7 +501,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ context.save(); // Draw everything first using node visit function - cc.Node.prototype.visit.call(this, context); + cc.ProtectedNode.prototype.visit.call(this, context); context.globalCompositeOperation = "destination-in"; @@ -525,7 +526,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // Clip mode doesn't support recusive stencil, so once we used a clip stencil, // so if it has ClippingNode as a child, the child must uses composition stencil. - this._cangodhelpme(true); + //this._cangodhelpme(true); this.sortAllChildren(); this.sortAllProtectedChildren(); @@ -554,17 +555,17 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ for (; j < jLen; j++) locProtectChildren[j].visit(context); - this._cangodhelpme(false); + //this._cangodhelpme(false); context.restore(); } }, - _godhelpme: false, + /*_godhelpme: false, _cangodhelpme: function (godhelpme) { if (godhelpme === true || godhelpme === false) cc.ClippingNode.prototype._godhelpme = godhelpme; return cc.ClippingNode.prototype._godhelpme; - }, + },*/ _scissorClippingVisit: null, _scissorClippingVisitForWebGL: function (ctx) { @@ -599,7 +600,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingStencil.onEnter(); this._setStencilClippingSize(this._contentSize); } else { - if (this._running) + if (this._running && this._clippingStencil) this._clippingStencil.onExit(); this._clippingStencil = null; } @@ -614,9 +615,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} type */ setClippingType: function (type) { - if (type == this._clippingType) { + if (type == this._clippingType) return; - } var clippingEnabled = this.isClippingEnabled(); this.setClippingEnabled(false); this._clippingType = type; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 6340007d09..1e9fd446d7 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1667,6 +1667,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._innerContainer.removeAllNodes(); }, + visit: function(ctx){ + this._super(ctx); + }, + /** * Add node for scrollView * @param {cc.Node}node From ce4134a9115e0f7a809e2d9e85d8d2fa9079abd4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 4 Aug 2014 20:21:56 +0800 Subject: [PATCH 0390/1564] Fixed #5785: requestAnimFrame doesn't work after re-focus on Samsung mobile --- CCBoot.js | 56 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 9b5b86e7d1..2fbab86c2c 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -822,6 +822,12 @@ cc.loader = { var onShow = function () { if (cc.eventManager && cc.game._eventShow) cc.eventManager.dispatchEvent(cc.game._eventShow); + + if(cc.game._intervalId){ + window.cancelAnimationFrame(cc.game._intervalId); + + cc.game._runMainLoop(); + } }; if (hidden) { @@ -834,6 +840,8 @@ cc.loader = { cc._addEventListener(win, "focus", onShow, false); } + win.onfocus = function(){ onShow() }; + if ("onpageshow" in window && "onpagehide" in window) { cc._addEventListener(win, "pagehide", onHidden, false); cc._addEventListener(win, "pageshow", onShow, false); @@ -1289,7 +1297,27 @@ cc._setup = function (el, width, height) { win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame || win.oRequestAnimationFrame || - win.msRequestAnimationFrame; + win.msRequestAnimationFrame || + function(callback){ + var self = this; + return setTimeout(function(){ + callback(); + }, 1000 / self.config[self.CONFIG_KEY.frameRate]); + }; + + win.cancelAnimationFrame = window.cancelAnimationFrame || + window.cancelRequestAnimationFrame || + window.msCancelRequestAnimationFrame || + window.mozCancelRequestAnimationFrame || + window.oCancelRequestAnimationFrame || + window.webkitCancelRequestAnimationFrame || + window.msCancelAnimationFrame || + window.mozCancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.oCancelAnimationFrame || + function(id){ + clearTimeout(id); + }; var element = cc.$(el) || cc.$('#' + el); var localCanvas, localContainer, localConStyle; @@ -1478,7 +1506,8 @@ cc.game = { setFrameRate: function (frameRate) { var self = this, config = self.config, CONFIG_KEY = self.CONFIG_KEY; config[CONFIG_KEY.frameRate] = frameRate; - if (self._intervalId) clearInterval(self._intervalId); + if (self._intervalId) + window.cancelAnimationFrame(self._intervalId); self._paused = true; self._runMainLoop(); }, @@ -1488,23 +1517,18 @@ cc.game = { */ _runMainLoop: function () { var self = this, callback, config = self.config, CONFIG_KEY = self.CONFIG_KEY, - win = window, frameRate = config[CONFIG_KEY.frameRate], director = cc.director; + director.setDisplayStats(config[CONFIG_KEY.showFPS]); - if (win.requestAnimFrame && frameRate == 60) { - callback = function () { - if (!self._paused) { - director.mainLoop(); - win.requestAnimFrame(callback); - } - }; - win.requestAnimFrame(callback); - } else { - callback = function () { + + callback = function () { + if (!self._paused) { director.mainLoop(); - }; - self._intervalId = setInterval(callback, 1000.0 / frameRate); - } + self._intervalId = window.requestAnimFrame(callback); + } + }; + + window.requestAnimFrame(callback); self._paused = false; }, From 75eded3f96673e42e88e6c6c543167bafdec0a5e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 4 Aug 2014 20:32:39 +0800 Subject: [PATCH 0391/1564] Fixed #5785: requestAnimFrame doesn't work after re-focus on Samsung mobile --- CCBoot.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 2fbab86c2c..d2130cfc02 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -840,7 +840,9 @@ cc.loader = { cc._addEventListener(win, "focus", onShow, false); } - win.onfocus = function(){ onShow() }; + if(navigator.userAgent.indexOf("MicroMessenger") > -1){ + win.onfocus = function(){ onShow() }; + } if ("onpageshow" in window && "onpagehide" in window) { cc._addEventListener(win, "pagehide", onHidden, false); From 33cc949dd014c8d98e08901b93006f41cdf2cbf9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 4 Aug 2014 20:55:40 +0800 Subject: [PATCH 0392/1564] Fixed #5785: requestAnimFrame doesn't work after re-focus on Samsung mobile --- CCBoot.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index d2130cfc02..71c0337abc 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1295,16 +1295,20 @@ cc._setup = function (el, width, height) { if (cc._setupCalled) return; else cc._setupCalled = true; var win = window; + var lastTime = new Date(); + var frameTime = 1000 / cc.game.config[cc.game.CONFIG_KEY.frameRate]; win.requestAnimFrame = win.requestAnimationFrame || win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame || win.oRequestAnimationFrame || win.msRequestAnimationFrame || function(callback){ - var self = this; - return setTimeout(function(){ - callback(); - }, 1000 / self.config[self.CONFIG_KEY.frameRate]); + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, frameTime - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; }; win.cancelAnimationFrame = window.cancelAnimationFrame || From 2bedf5e0999023e4bd62c517c126a7d1509ec6a3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 5 Aug 2014 11:28:06 +0800 Subject: [PATCH 0393/1564] Issue #2045: Newline, text boundary (fixed case 2) --- cocos2d/core/labelttf/CCLabelTTF.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 752561c74f..da499e650b 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -160,7 +160,14 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ var baseNb = Math.floor(text.length * width / tWidth); // Next line is a line with line break var nextlinebreak = text.indexOf('\n'); - if (baseNb * 0.85 >= nextlinebreak && nextlinebreak > -1) return nextlinebreak + 1; + if(nextlinebreak > -1){ + if (baseNb * 0.85 >= nextlinebreak){ + return nextlinebreak + 1; + } + text = text.substr(0, nextlinebreak + 1); + tWidth = this._measure(text); + } + // Text width smaller than requested width if (tWidth < width) return text.length; From a85984822ecc436ae0b31ef0961e13acc3a7f78f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 5 Aug 2014 14:44:04 +0800 Subject: [PATCH 0394/1564] Fixed #2039: widget.clone's problem --- extensions/ccui/layouts/UILayoutParameter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 47329a11b0..1e105bf14f 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -140,7 +140,10 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * @param {ccui.LayoutParameter} model */ _copyProperties:function(model){ - this._margin = model._margin; + this._margin.bottom = model._margin.bottom; + this._margin.left = model._margin.left; + this._margin.right = model._margin.right; + this._margin.top = model._margin.top; } }); From a4993ebb76a357197c5c7e495ea04c82ee8ea4bd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 5 Aug 2014 17:30:33 +0800 Subject: [PATCH 0395/1564] Issue #5702: Fixed CCScale9Sprite Fuzzy --- extensions/gui/control-extension/CCScale9Sprite.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 8516c6434a..86c7e79be5 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -306,8 +306,18 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var scaleChildren = this._scale9Image.getChildren(); for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; - if (selChild) - selChild.updateDisplayedColor(parentColor); + if (selChild){ + cc.Node.prototype.updateDisplayedColor.call(selChild, parentColor); + + if( + parentColor.r !== 255 || + parentColor.g !== 255 || + parentColor.b !== 255 + ){ + selChild._changeTextureColor(); + selChild._setNodeDirtyForCache(); + } + } } }, From 6726a1b02a3a1bf2cacc04c9dd694e7f9e998725 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 5 Aug 2014 18:10:20 +0800 Subject: [PATCH 0396/1564] Issue #5702: Fixed UIButton Fuzzy Key surrounding blur --- cocos2d/core/sprites/CCSprite.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 41f1b214be..49c58c53e4 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1455,7 +1455,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateDisplayedColor = function (parentColor) { var _t = this; + var oldColor = _t.color; cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); + var newColor = _t._displayedColor; + if ((oldColor.r === newColor.r) && (oldColor.g === newColor.g) && (oldColor.b === newColor.b)) + return; _t._changeTextureColor(); _t._setNodeDirtyForCache(); From 488b27a04842b72855cb794b5e1f900ea03ac4ed Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 5 Aug 2014 21:27:02 +0800 Subject: [PATCH 0397/1564] Fixed #5704: fixed a bug of ccui.Layout --- cocos2d/clipping-nodes/CCClippingNode.js | 3 +- cocos2d/core/platform/CCMacro.js | 2 +- extensions/ccui/layouts/UILayout.js | 62 ++---------------------- 3 files changed, 5 insertions(+), 62 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 6a741ebe2e..8ba9a0f246 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -153,7 +153,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // store the current stencil layer (position in the stencil buffer), // this will allow nesting up to n CCClippingNode, // where n is the number of bits of the stencil buffer. - cc.ClippingNode._layer = -1; // all the _stencilBits are in use? if (cc.ClippingNode._layer + 1 == cc.stencilBits) { @@ -504,7 +503,7 @@ _p.stencil; cc.ClippingNode._init_once = null; cc.ClippingNode._visit_once = null; -cc.ClippingNode._layer = null; +cc.ClippingNode._layer = -1; cc.ClippingNode._sharedCache = null; cc.ClippingNode._getSharedCache = function () { diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 8dc3af1ae4..f7b56c4200 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -426,7 +426,7 @@ cc.checkGLErrorDebug = function () { if (cc.renderMode == cc._RENDER_TYPE_WEBGL) { var _error = cc._renderContext.getError(); if (_error) { - cc.log(CC._localZOrder.checkGLErrorDebug, _error); + cc.log(cc._LogInfos.checkGLErrorDebug, _error); } } }; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index d7791d96c3..65c462550e 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -311,6 +311,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, visit: function (ctx) { + if(this._name == "list") + void(0); if (!this._visible) return; this._adaptRenderers(); @@ -337,21 +339,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _stencilClippingVisitForWebGL: function (ctx) { var gl = ctx || cc._renderContext; - // if stencil buffer disabled - /*if (cc.stencilBits < 1) { - // draw everything, as if there where no stencil - cc.Node.prototype.visit.call(this, ctx); - return; - }*/ - if (!this._clippingStencil || !this._clippingStencil.isVisible()) return; - // store the current stencil layer (position in the stencil buffer), - // this will allow nesting up to n CCClippingNode, - // where n is the number of bits of the stencil buffer. - ccui.Layout._layer = -1; - // all the _stencilBits are in use? if (ccui.Layout._layer + 1 == cc.stencilBits) { // warn once @@ -365,14 +355,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return; } - // increment the current layer ccui.Layout._layer++; - // mask of the current layer (ie: for layer 3: 00000100) var mask_layer = 0x1 << ccui.Layout._layer; - // mask of all layers less than the current (ie: for layer 3: 00000011) var mask_layer_l = mask_layer - 1; - // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) var mask_layer_le = mask_layer | mask_layer_l; // manually save the stencil state @@ -385,57 +371,28 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); var currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); - // enable stencil use gl.enable(gl.STENCIL_TEST); - // check for OpenGL error while enabling stencil test - //cc.checkGLErrorDebug(); - // all bits on the stencil buffer are readonly, except the current layer bit, - // this means that operation like glClear or glStencilOp will be masked with this value gl.stencilMask(mask_layer); - // manually save the depth test state - //GLboolean currentDepthTestEnabled = GL_TRUE; - //currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); var currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); - // disable depth test while drawing the stencil - //glDisable(GL_DEPTH_TEST); - // disable update to the depth buffer while drawing the stencil, - // as the stencil is not meant to be rendered in the real scene, - // it should never prevent something else to be drawn, - // only disabling depth buffer update should do gl.depthMask(false); - // manually clear the stencil buffer by drawing a fullscreen rectangle on it - // setup the stencil test func like this: - // for each pixel in the fullscreen rectangle - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 0 in the stencil buffer - // if in inverted mode: set the current layer value to 1 in the stencil buffer gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); gl.stencilOp(gl.ZERO, gl.KEEP, gl.KEEP); // 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)); - // setup the stencil test func like this: - // for each pixel in the stencil node - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 1 in the stencil buffer - // if in inverted mode: set the current layer value to 0 in the stencil buffer gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP); cc.kmGLPushMatrix(); this.transform(); - this._clippingStencil.visit(); - // restore the depth test state gl.depthMask(currentDepthWriteMask); - gl.stencilFunc(gl.EQUAL, mask_layer_le, mask_layer_le); gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); @@ -473,8 +430,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ gl.stencilMask(currentStencilWriteMask); if (!currentStencilEnabled) gl.disable(gl.STENCIL_TEST); - - // we are done using this layer, decrement ccui.Layout._layer--; cc.kmGLPopMatrix(); @@ -489,7 +444,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } var context = ctx || cc._renderContext; // Composition mode, costy but support texture stencil - //if (this._cangodhelpme() || this._clippingStencil instanceof cc.Sprite) { if (this._clippingStencil instanceof cc.Sprite) { // Cache the current canvas, for later use (This is a little bit heavy, replace this solution with other walkthrough) var canvas = context.canvas; @@ -526,8 +480,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // Clip mode doesn't support recusive stencil, so once we used a clip stencil, // so if it has ClippingNode as a child, the child must uses composition stencil. - //this._cangodhelpme(true); - this.sortAllChildren(); this.sortAllProtectedChildren(); @@ -555,18 +507,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ for (; j < jLen; j++) locProtectChildren[j].visit(context); - //this._cangodhelpme(false); context.restore(); } }, - /*_godhelpme: false, - _cangodhelpme: function (godhelpme) { - if (godhelpme === true || godhelpme === false) - cc.ClippingNode.prototype._godhelpme = godhelpme; - return cc.ClippingNode.prototype._godhelpme; - },*/ - _scissorClippingVisit: null, _scissorClippingVisitForWebGL: function (ctx) { var clippingRect = this._getClippingRect(); @@ -1729,7 +1673,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }); ccui.Layout._init_once = null; ccui.Layout._visit_once = null; -ccui.Layout._layer = null; +ccui.Layout._layer = -1; ccui.Layout._sharedCache = null; if (cc._renderType == cc._RENDER_TYPE_WEBGL) { From 3df4f6f0f37cb4e60406c7e76804f2c1a36b131c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 5 Aug 2014 21:31:43 +0800 Subject: [PATCH 0398/1564] Fixed #5704: remove the test codes. --- extensions/ccui/layouts/UILayout.js | 2 -- extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js | 4 ---- 2 files changed, 6 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 65c462550e..2ed1556b62 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -311,8 +311,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, visit: function (ctx) { - if(this._name == "list") - void(0); if (!this._visible) return; this._adaptRenderers(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 1e9fd446d7..6340007d09 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1667,10 +1667,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._innerContainer.removeAllNodes(); }, - visit: function(ctx){ - this._super(ctx); - }, - /** * Add node for scrollView * @param {cc.Node}node From abaa0a34725491bd1a383831eb257f7d8d388156 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 6 Aug 2014 11:40:09 +0800 Subject: [PATCH 0399/1564] Fixed #5704: fixed a bug of WidgetReader that it gets a incorrect value when color's value is 0 --- extensions/cocostudio/reader/GUIReader.js | 93 +++---------------- .../reader/widgetreader/WidgetReader.js | 76 ++++++--------- 2 files changed, 40 insertions(+), 129 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index befa209b96..a80bf939ff 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -107,8 +107,7 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ var ite = parseInt(te); var is = parseInt(s); - var version = it * 1000 + ih * 100 + ite * 10 + is; - return version; + return (it * 1000 + ih * 100 + ite * 10 + is); }, /** @@ -204,68 +203,39 @@ ccs.WidgetPropertiesReader = ccs.Class.extend({ }, createGUI: function(classname){ var name = this.getGUIClassName(classname); - - var object = ccs.objectFactory.createObject(name); - - return object; + return ccs.objectFactory.createObject(name); }, getGUIClassName: function(name){ var convertedClassName = name; if (name == "Panel") - { convertedClassName = "Layout"; - } else if (name == "TextArea") - { convertedClassName = "Text"; - } else if (name == "TextButton") - { convertedClassName = "Button"; - } else if (name == "Label") - { convertedClassName = "Text"; - } else if (name == "LabelAtlas") - { convertedClassName = "TextAtlas"; - } else if (name == "LabelBMFont") - { convertedClassName = "TextBMFont"; - } - - return convertedClassName; }, getWidgetReaderClassName: function(classname){ // create widget reader to parse properties of widget var readerName = classname; if (readerName == "Panel") - { readerName = "Layout"; - } else if (readerName == "TextArea") - { readerName = "Text"; - } else if (readerName == "TextButton") - { readerName = "Button"; - } else if (readerName == "Label") - { readerName = "Text"; - } else if (readerName == "LabelAtlas") - { readerName = "TextAtlas"; - } else if (readerName == "LabelBMFont") - { readerName = "TextBMFont"; - } readerName += "Reader"; return readerName; }, @@ -274,68 +244,38 @@ ccs.WidgetPropertiesReader = ccs.Class.extend({ // 1st., custom widget parse properties of parent widget with parent widget reader if (widget instanceof ccui.Button) - { readerName = "ButtonReader"; - } else if (widget instanceof ccui.CheckBox) - { readerName = "CheckBoxReader"; - } else if (widget instanceof ccui.ImageView) - { readerName = "ImageViewReader"; - } else if (widget instanceof ccui.TextAtlas) - { readerName = "TextAtlasReader"; - } else if (widget instanceof ccui.TextBMFont) - { readerName = "TextBMFontReader"; - } else if (widget instanceof ccui.Text) - { readerName = "TextReader"; - } else if (widget instanceof ccui.LoadingBar) - { readerName = "LoadingBarReader"; - } else if (widget instanceof ccui.Slider) - { readerName = "SliderReader"; - } else if (widget instanceof ccui.TextField) - { readerName = "TextFieldReader"; - } else if (widget instanceof ccui.ListView) - { readerName = "ListViewReader"; - } else if (widget instanceof ccui.PageView) - { readerName = "PageViewReader"; - } else if (widget instanceof ccui.ScrollView) - { readerName = "ScrollViewReader"; - } - else if (widget instanceof ccui.Layout) - { readerName = "LayoutReader"; - } else if (widget instanceof ccui.Widget) - { readerName = "WidgetReader"; - } return readerName; }, createWidgetReaderProtocol: function(classname){ - var object = ccs.objectFactory.createObject(classname); - return object; + return ccs.objectFactory.createObject(classname); } }); ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ @@ -823,10 +763,10 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ if (options["fontSize"] !== undefined) { textArea.setFontSize(options["fontSize"]); } - var cr = options["colorR"] + var cr = options["colorR"]; var cg = options["colorG"]; var cb = options["colorB"]; - textArea.setColor(cc.color(cr, cg, cb)); + textArea.setColor(cc.color((cr == null) ? 255 : cr, (cg == null) ? 255 : cg, (cb == null) ? 255 : cb)); textArea.setFontName(options["fontName"]); if (options["areaWidth"] !== undefined && options["areaHeight"] !== undefined) { var size = cc.size(options["areaWidth"], options["areaHeight"]); @@ -950,17 +890,14 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ cc.log("Read design size error!"); var winSize = cc.director.getWinSize(); ccs.uiReader.storeFileDesignSize(fileName, winSize); - } - else { + } else ccs.uiReader.storeFileDesignSize(fileName, cc.size(fileDesignWidth, fileDesignHeight)); - } var widgetTree = jsonDict["widgetTree"]; var widget = this.widgetFromJsonDictionary(widgetTree); var size = widget.getContentSize(); - if (size.width == 0 && size.height == 0) { + if (size.width == 0 && size.height == 0) widget.setSize(cc.size(fileDesignWidth, fileDesignHeight)); - } var actions = jsonDict["animation"]; var rootWidget = widget; @@ -1149,8 +1086,6 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ }, setPropsForButtonFromJsonDictionary: function (widget, options) { - - this.setPropsForWidgetFromJsonDictionary(widget, options); var button = widget; var scale9Enable = options["scale9Enable"]; @@ -1382,6 +1317,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var touchScaleChangeAble = options["touchScaleEnable"]; label.setTouchScaleChangeEnabled(touchScaleChangeAble); var text = options["text"]; + label.setString(text); if (options["fontSize"] !== undefined) { label.setFontSize(options["fontSize"]); @@ -1629,24 +1565,21 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setPropsForWidgetFromJsonDictionary(widget, options); var textArea = widget; textArea.setString(options["text"]); - if (options["fontSize"] !== undefined) { + if (options["fontSize"] !== undefined) textArea.setFontSize(options["fontSize"]); - } - var cr = options["colorR"] + var cr = options["colorR"]; var cg = options["colorG"]; var cb = options["colorB"]; - textArea.setColor(cc.color(cr, cg, cb)); + textArea.setColor(cc.color((cr==null)?255:cr, (cg==null)?255:cg, (cb==null)?255:cb)); textArea.setFontName(options["fontName"]); if (options["areaWidth"] !== undefined && options["areaHeight"] !== undefined) { var size = cc.size(options["areaWidth"], options["areaHeight"]); textArea.setTextAreaSize(size); } - if (options["hAlignment"]) { + if (options["hAlignment"]) textArea.setTextHorizontalAlignment(options["hAlignment"]); - } - if (options["vAlignment"]) { + if (options["vAlignment"]) textArea.setTextVerticalAlignment(options["vAlignment"]); - } this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 5c5c517a0e..29e354e18e 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -24,17 +24,14 @@ ****************************************************************************/ ccs.WidgetReader = { - getInstance: function(){ return ccs.WidgetReader; }, setPropsFromJsonDictionary: function(widget, options){ - var ignoreSizeExsit = options["ignoreSize"]; - if(ignoreSizeExsit){ + if(ignoreSizeExsit) widget.ignoreContentAdaptWithSize(ignoreSizeExsit); - } widget.setSizeType(options["sizeType"]); widget.setPositionType(options["positionType"]); @@ -43,21 +40,17 @@ ccs.WidgetReader = { widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"])); /* adapt screen */ - var w = 0; - var h = 0; + var w = 0, h = 0; var adaptScreen = options["adaptScreen"]; - if (adaptScreen) - { + if (adaptScreen) { var screenSize = cc.director.getWinSize(); w = screenSize.width; h = screenSize.height; - } - else - { + } else { w = options["width"]; h = options["height"]; } - widget.setContentSize(cc.size(w, h)); + widget.setContentSize(w, h); widget.setTag(options["tag"]); widget.setActionTag(options["actiontag"]); @@ -68,8 +61,7 @@ ccs.WidgetReader = { var x = options["x"]; var y = options["y"]; - widget.setPosition(cc.p(x, y)); - + widget.setPosition(x, y); var sx = options["scaleX"] || 1; widget.setScaleX(sx); @@ -81,9 +73,8 @@ ccs.WidgetReader = { widget.setRotation(rt); var vb = options["visible"] || false; - if(vb != null){ + if(vb != null) widget.setVisible(vb); - } widget.setLocalZOrder(options["ZOrder"]); var layout = options["layoutParameter"]; @@ -114,71 +105,58 @@ ccs.WidgetReader = { break; } if(parameter != null){ - var mgl = layoutParameterDic["marginLeft"]; - var mgt = layoutParameterDic["marginTop"]; - var mgr = layoutParameterDic["marginRight"]; - var mgb = layoutParameterDic["marginDown"]; + var mgl = layoutParameterDic["marginLeft"]||0; + var mgt = layoutParameterDic["marginTop"]||0; + var mgr = layoutParameterDic["marginRight"]||0; + var mgb = layoutParameterDic["marginDown"]||0; parameter.setMargin(mgl, mgt, mgr, mgb); widget.setLayoutParameter(parameter); } } - }, setColorPropsFromJsonDictionary: function(widget, options){ var op = options["opacity"]; - if(op != null){ + if(op != null) widget.setOpacity(op); - } - var colorR = options["colorR"] || 255; - var colorG = options["colorG"] || 255; - var colorB = options["colorB"] || 255; - widget.setColor(cc.color(colorR, colorG, colorB)); + var colorR = options["colorR"]; + var colorG = options["colorG"]; + var colorB = options["colorB"]; + widget.setColor(cc.color((colorR == null) ? 255 : colorR, (colorG == null) ? 255 : colorG, (colorB == null) ? 255 : colorB)); ccs.WidgetReader.setAnchorPointForWidget(widget, options); - widget.setFlippedX(options["flipX"]); widget.setFlippedY(options["flipY"]); }, setAnchorPointForWidget: function(widget, options){ var isAnchorPointXExists = options["anchorPointX"]; var anchorPointXInFile; - if (isAnchorPointXExists != null) { + if (isAnchorPointXExists != null) anchorPointXInFile = options["anchorPointX"]; - }else{ + else anchorPointXInFile = widget.getAnchorPoint().x; - } var isAnchorPointYExists = options["anchorPointY"]; var anchorPointYInFile; - if (isAnchorPointYExists != null) { + if (isAnchorPointYExists != null) anchorPointYInFile = options["anchorPointY"]; - } - else{ + else anchorPointYInFile = widget.getAnchorPoint().y; - } - if (isAnchorPointXExists != null || isAnchorPointYExists != null) { + if (isAnchorPointXExists != null || isAnchorPointYExists != null) widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); - } - }, + getResourcePath: function(dict, key, texType){ - var jsonPath = ccs.uiReader.getFilePath(); var imageFileName = dict[key]; var imageFileName_tp; - if (null != imageFileName) - { - if (texType == 0) { - imageFileName_tp = jsonPath + imageFileName; - } - else if(texType == 1){ + if (null != imageFileName) { + if (texType == 0) + imageFileName_tp = ccs.uiReader.getFilePath() + imageFileName; + else if(texType == 1) imageFileName_tp = imageFileName; - } - else{ + else cc.assert(0, "invalid TextureResType!!!"); - } } return imageFileName_tp; - } }; \ No newline at end of file From 4f9a2f809da7482a0de0ab5a746e87ea27af60fb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 6 Aug 2014 13:48:02 +0800 Subject: [PATCH 0400/1564] Fixed #2045: Reconstruction of the wrap algorithm 1. Change character ( The east to the West ) 2. Add cc.LabelTTF.wrapInspection to control letters ( check symbol that put in first place ) ... --- cocos2d/core/labelttf/CCLabelTTF.js | 169 +++++++++++++--------------- 1 file changed, 78 insertions(+), 91 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index da499e650b..125eef3995 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -154,83 +154,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _measure: function (text) { return this._getLabelContext().measureText(text).width; }, - _checkNextline: function (text, width) { - var tWidth = this._measure(text); - // Estimated word number per line - var baseNb = Math.floor(text.length * width / tWidth); - // Next line is a line with line break - var nextlinebreak = text.indexOf('\n'); - if(nextlinebreak > -1){ - if (baseNb * 0.85 >= nextlinebreak){ - return nextlinebreak + 1; - } - text = text.substr(0, nextlinebreak + 1); - tWidth = this._measure(text); - } - - // Text width smaller than requested width - if (tWidth < width) return text.length; - - var found = false, l = width + 1, idfound = -1, index = baseNb, result, - re = cc.LabelTTF._checkRegEx, - reversre = cc.LabelTTF._reverseCheckRegEx, - enre = cc.LabelTTF._checkEnRegEx, - substr = text.substr(baseNb); - - // Forward check - // Find next special caracter or chinese caracters - while (result = re.exec(substr)) { - index += result[0].length; - var tem = text.substr(0, index); - l = this._measure(tem); - if (result[2] == '\n' && l < width) { - found = true; - idfound = index; - break; - } - if (l > width) { - if (idfound != -1) - found = true; - break; - } - idfound = index; - substr = text.substr(index); - } - if (found){ - if(cc.LabelTTF._checkSymbol.test(substr)){ - idfound--; - } - return idfound; - } - - // Backward check when forward check failed - substr = text.substr(0, baseNb + 1); - idfound = baseNb; - while (result = reversre.exec(substr)) { - // BUG: Not secured if check with result[0] - - if(substr !== result[0]){ - idfound = result[0].length; - substr = result[0]; - }else{ - idfound = result[1].length; - substr = result[1]; - //If the first is a symbol - if(result[2]){ - if(cc.LabelTTF._checkSymbol.test(result[2])){ - continue; - } - } - } - l = this._measure(substr); - if (l < width) { - break; - } - } - - // Avoid when idfound == 0, the process may enter in a infinite loop - return idfound || 1; - }, /** * Prints out a description of this class @@ -849,6 +772,70 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return this._labelContext; }, + _checkWarp: function(strArr, i, maxWidth){ + var text = strArr[i]; + var allWidth = this._measure(text); + if(allWidth > maxWidth && text.length > 1){ + + var fuzzyLen = text.length * ( maxWidth / allWidth ) | 0; + var tmpText = text.substr(fuzzyLen); + var width = allWidth - this._measure(tmpText); + var sLine; + var pushNum = 0; + + //Exceeded the size + while(width > maxWidth){ + fuzzyLen *= maxWidth / width | 0; + tmpText = text.substr(fuzzyLen); + width = allWidth - this._measure(tmpText); + } + + //Find the truncation point + while(width < maxWidth){ + + if(tmpText){ + var exec = cc.LabelTTF._wordRex.exec(tmpText); + pushNum = exec ? exec[0].length : 1; + sLine = tmpText; + } + + fuzzyLen = fuzzyLen + pushNum; + + tmpText = text.substr(fuzzyLen); + + width = allWidth - this._measure(tmpText); + } + + fuzzyLen -= pushNum; + + var sText = text.substr(0, fuzzyLen); + + //symbol in the first + if(cc.LabelTTF.wrapInspection){ + if(cc.LabelTTF._symbolRex.test(sLine || tmpText)){ + var result = cc.LabelTTF._lastWordRex.exec(sText); + fuzzyLen -= result ? result[0].length : 0; + + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); + } + } + + //To judge whether a English words are truncated + if(cc.LabelTTF._firsrEnglish.test(sLine)){ + var result = cc.LabelTTF._lastEnglish.exec(sText); + if(result && sText !== result[0]){ + fuzzyLen -= result[0].length; + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); + } + } + + strArr[i] = sLine || tmpText; + strArr.splice(i, 0, sText); + } + }, + _updateTTF: function () { var locDimensionsWidth = this._dimensions.width, i, strLength; var locLineWidth = this._lineWidths; @@ -858,14 +845,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._measureConfig(); if (locDimensionsWidth !== 0) { // Content processing - var text = this._string; - this._strings = []; - for (i = 0, strLength = this._string.length; i < strLength;) { - // Find the index of next line - var next = this._checkNextline(text.substr(i), locDimensionsWidth); - var append = text.substr(i, next); - this._strings.push(append); - i += next; + this._strings = this._string.split('\n'); + + for(i = 0; i < this._strings.length; i++){ + this._checkWarp(this._strings, i, locDimensionsWidth); } } else { this._strings = this._string.split('\n'); @@ -1164,12 +1147,16 @@ cc.LabelTTF._textAlign = ["left", "center", "right"]; cc.LabelTTF._textBaseline = ["top", "middle", "bottom"]; -// Class static properties for measure util -cc.LabelTTF._checkRegEx = /(.+?)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; -cc.LabelTTF._reverseCheckRegEx = /(.*)([\s\n\r\-\/\\\:]|[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF\u3001])/; -cc.LabelTTF._checkEnRegEx = /[\s\-\/\\\:]/; -cc.LabelTTF._checkSymbol = /^[\u007e\u0021\u0040\u0023\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u005f\u002b\u007b\u007d\u005b\u005d\u003a\u0026\u0071\u0075\u006f\u0074\u003b\u007c\u003b\u0026\u0023\u0033\u0039\u003b\u005c\u0026\u006c\u0074\u003b\u0026\u0067\u0074\u003b\u003f\u002c\u002e\u002f\uff01\u0040\uffe5\u2026\uff08\uff09\u2014\u002b\u3010\u3011\uff1a\u201c\u007c\uff1b\u2018\u3001\u300a\u300b\uff1f\uff0c\u3002\u3001\u000d\u000a]/; -cc.LabelTTF._checkCharacter = /[\u4E00-\u9FA5\uFE30-\uFFA0\u3040-\u309F\u30A0-\u30FF]/; +//check the first character +cc.LabelTTF.wrapInspection = true; + +//Support: English French German +//Other as Oriental Language +cc.LabelTTF._wordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)/; +cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>、‘“》?。,!]/; +cc.LabelTTF._lastWordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)$/; +cc.LabelTTF._lastEnglish = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/; +cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; // Only support style in this format: "18px Verdana" or "18px 'Helvetica Neue'" cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; From f2a406751aa14a0e40675c50244722e0f001ffe6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 6 Aug 2014 13:57:35 +0800 Subject: [PATCH 0401/1564] Fixed #5702: Fixed CCScale9Sprite Fuzzy ( Distinguish webgl ) --- extensions/gui/control-extension/CCScale9Sprite.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 86c7e79be5..fc9d2373ac 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -310,9 +310,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ cc.Node.prototype.updateDisplayedColor.call(selChild, parentColor); if( - parentColor.r !== 255 || - parentColor.g !== 255 || - parentColor.b !== 255 + cc._renderType === cc._RENDER_TYPE_CANVAS && ( + parentColor.r !== 255 || + parentColor.g !== 255 || + parentColor.b !== 255 + + ) ){ selChild._changeTextureColor(); selChild._setNodeDirtyForCache(); From 0272deca6cea0f1ecd72b284e754153136d7fb2a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 6 Aug 2014 14:36:01 +0800 Subject: [PATCH 0402/1564] Fixed #5704: correct a mistake of cc.Sprite --- cocos2d/core/sprites/CCSprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 49c58c53e4..249b1d8636 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1455,7 +1455,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateDisplayedColor = function (parentColor) { var _t = this; - var oldColor = _t.color; + var oldColor = _t.getDisplayedColor(); cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); var newColor = _t._displayedColor; if ((oldColor.r === newColor.r) && (oldColor.g === newColor.g) && (oldColor.b === newColor.b)) From 03e8a79e1b32015eb733720fc087221245619360 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 6 Aug 2014 14:47:30 +0800 Subject: [PATCH 0403/1564] Fixed #5792: The bind method is not defined in the CCBoot --- CCBoot.js | 8 ++++++++ cocos2d/core/platform/CCClass.js | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 71c0337abc..082d98933e 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1703,3 +1703,11 @@ cc.game = { }; cc.game._initConfig(); //+++++++++++++++++++++++++something about CCGame end+++++++++++++++++++++++++++++ + +Function.prototype.bind = Function.prototype.bind || function (bind) { + var self = this; + return function () { + var args = Array.prototype.slice.call(arguments); + return self.apply(bind || null, args); + }; +}; \ No newline at end of file diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 3f98a8af31..41e94f09d5 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -218,14 +218,6 @@ ClassManager.compileSuper.ClassManager = ClassManager; }; return Class; }; - - Function.prototype.bind = Function.prototype.bind || function (bind) { - var self = this; - return function () { - var args = Array.prototype.slice.call(arguments); - return self.apply(bind || null, args); - }; - }; })(); /** From b3db4569df34dfa7fcbf094e27101f173f6baba2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 6 Aug 2014 15:49:39 +0800 Subject: [PATCH 0404/1564] Fixed #5702: The Ignore is empty when no set --- extensions/cocostudio/reader/widgetreader/WidgetReader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 29e354e18e..dc922e97ed 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -30,7 +30,7 @@ ccs.WidgetReader = { setPropsFromJsonDictionary: function(widget, options){ var ignoreSizeExsit = options["ignoreSize"]; - if(ignoreSizeExsit) + if(ignoreSizeExsit != null) widget.ignoreContentAdaptWithSize(ignoreSizeExsit); widget.setSizeType(options["sizeType"]); From 4c7d934080536f059dfdabeeabc35a5e9ae2cc8f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 6 Aug 2014 16:01:11 +0800 Subject: [PATCH 0405/1564] Fixed #5702: IgnoreSize copying error --- extensions/ccui/base-classes/UIWidget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 370df4cfe2..8ebc2d888f 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1222,8 +1222,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setName(widget.getName()); this.setActionTag(widget.getActionTag()); - this._ignoreSize.width = widget._ignoreSize.width; - this._ignoreSize.height = widget._ignoreSize.height; + this._ignoreSize = widget._ignoreSize; + this.setContentSize(widget._contentSize); this._customSize.width = widget._customSize.width; this._customSize.height = widget._customSize.height; From b22bb3e96e8f657b82c9f8a3e2abf593955a1508 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 6 Aug 2014 16:47:47 +0800 Subject: [PATCH 0406/1564] Fixed #5781: correct a bug of cc.WebAudio that sourceNode's playbackState is invalid --- cocos2d/audio/CCAudio.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 92b9137c40..409ef8e0a0 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -82,6 +82,9 @@ if (cc.sys._supportWebAudio) { sourceNode["connect"](volumeNode); volumeNode["connect"](_ctx["destination"]); sourceNode.loop = self._loop; + sourceNode.onended = function(){ + self._stopped = true; + }; self._paused = false; self._stopped = false; @@ -130,10 +133,13 @@ if (cc.sys._supportWebAudio) { if (self._loadState == -1) { self._loadState = 0; return; - } else if (self._loadState != 1) return; + } else if (self._loadState != 1) + return; var sourceNode = self._sourceNode; - if (!self._stopped && sourceNode && sourceNode["playbackState"] == 2) return;//playing + if (!self._stopped && sourceNode && sourceNode["playbackState"] == 2) + return;//playing + self.startTime = _ctx.currentTime; this._play(0); }, From 2bc36825404d1f8a6392e66b918056310710acef Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 6 Aug 2014 16:51:59 +0800 Subject: [PATCH 0407/1564] Fixed #5702: nodeToParentTransform -> getNodeToParentTransform --- cocos2d/physics/CCPhysicsSprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 48c8a54b15..af01005e32 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -266,7 +266,7 @@ cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegrees(this._body.a)); } }, - nodeToParentTransform:function () { + getNodeToParentTransform:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS) return this._nodeToParentTransformForCanvas(); From 3299173c0e07adef5bf5280ab83778c031f64f4c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 6 Aug 2014 17:31:23 +0800 Subject: [PATCH 0408/1564] Fixed #5702: nodeToParentTransform -> getNodeToParentTransform --- cocos2d/physics/CCPhysicsSprite.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index af01005e32..68a0370ac5 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -266,6 +266,12 @@ cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegrees(this._body.a)); } }, + /** + * @deprecated + */ + nodeToParentTransform: function(){ + return this.getNodeToParentTransform(); + }, getNodeToParentTransform:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS) return this._nodeToParentTransformForCanvas(); From 7eb368454f9f94e25d2dc2d690350d2251b2598b Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 6 Aug 2014 19:47:57 +0800 Subject: [PATCH 0409/1564] Issue #5781: Update ENGINE_VERSION and refactor some deprecated function usages --- cocos2d/core/base-nodes/CCNode.js | 6 +++--- cocos2d/core/platform/CCConfig.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index c275333105..52397a8948 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1807,7 +1807,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.AffineTransform} */ getWorldToNodeTransform: function () { - return cc.affineTransformInvert(this.nodeToWorldTransform()); + return cc.affineTransformInvert(this.getNodeToWorldTransform()); }, /** @@ -1823,7 +1823,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} */ convertToNodeSpace: function (worldPoint) { - return cc.pointApplyAffineTransform(worldPoint, this.worldToNodeTransform()); + return cc.pointApplyAffineTransform(worldPoint, this.getWorldToNodeTransform()); }, /** @@ -1833,7 +1833,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ convertToWorldSpace: function (nodePoint) { nodePoint = nodePoint || cc.p(0,0); - return cc.pointApplyAffineTransform(nodePoint, this.nodeToWorldTransform()); + return cc.pointApplyAffineTransform(nodePoint, this.getNodeToWorldTransform()); }, /** diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index e16d41eaad..e53e154939 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -33,7 +33,7 @@ * @constant * @type String */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-html5 v3.0 RC0"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC2"; /** *

    From f508139ea4b1542042f17371b76da6d0a9d10d04 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 6 Aug 2014 19:55:51 +0800 Subject: [PATCH 0410/1564] Fixed #5781: fixed bugs of ccui.LayoutParameter and ccs.ArmatureAnimation --- cocos2d/core/platform/CCConfig.js | 2 +- extensions/ccui/layouts/UILayoutParameter.js | 17 +++++++---------- extensions/cocostudio/armature/CCArmature.js | 12 ++++-------- extensions/cocostudio/armature/CCBone.js | 12 +++--------- .../armature/animation/CCArmatureAnimation.js | 10 ++++++++++ .../cocostudio/armature/display/CCSkin.js | 1 - 6 files changed, 25 insertions(+), 29 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index e16d41eaad..15590e8dc6 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -33,7 +33,7 @@ * @constant * @type String */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-html5 v3.0 RC0"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-html5 v3.0 RC2"; /** *

    diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 1e105bf14f..d0aaab313f 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -208,13 +208,8 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL */ _copyProperties: function (model) { ccui.LayoutParameter.prototype._copyProperties.call(this, model); - var parameter = model; - if(parameter){ - this.setAlign(parameter._relativeAlign); - this.setRelativeName(parameter._relativeLayoutName); - this.setRelativeToWidgetName(parameter._relativeWidgetName); + if (model instanceof ccui.LinearLayoutParameter) this.setGravity(model._linearGravity); - } } }); @@ -312,7 +307,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat * @returns {ccui.RelativeLayoutParameter} */ _createCloneInstance:function(){ - return ccui.RelativeLayoutParameter.create(); //TODO + return ccui.RelativeLayoutParameter.create(); }, /** @@ -321,9 +316,11 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat */ _copyProperties:function(model){ ccui.LayoutParameter.prototype._copyProperties.call(this, model); - this.setAlign(model._relativeAlign); - this.setRelativeToWidgetName(model._relativeWidgetName); - this.setRelativeName(model._relativeLayoutName); + if (mode instanceof ccui.RelativeLayoutParameter) { + this.setAlign(model._relativeAlign); + this.setRelativeToWidgetName(model._relativeWidgetName); + this.setRelativeName(model._relativeLayoutName); + } } }); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 1b3171fb8f..07060096b1 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -384,9 +384,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ node.setBlendFunc(this._blendFunc); } node.draw(ctx); - } else { + } else node.visit(ctx); - } } break; case ccs.DISPLAY_TYPE_ARMATURE: @@ -421,7 +420,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (!this._visible) return; - //TODO need test context.save(); this.transform(context); @@ -446,7 +444,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ cc.kmMat4Assign(this._stackMatrix, currentStack.top); currentStack.top = this._stackMatrix; - this.transform(); //TODO + this.transform(); this.sortAllChildren(); this.draw(context); @@ -608,9 +606,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ */ setColliderFilter: function (filter) { var locBoneDic = this._boneDic; - for (var key in locBoneDic) { + for (var key in locBoneDic) locBoneDic[key].setColliderFilter(filter); - } }, /** @@ -685,8 +682,7 @@ _p = null; */ ccs.Armature.create = function (name, parentBone) { var armature = new ccs.Armature(); - if (armature.init(name, parentBone)) { + if (armature.init(name, parentBone)) return armature; - } return null; }; diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 8a1ed469cb..9f3ce7d41c 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -333,9 +333,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ */ setChildArmature: function (armature) { if (this._childArmature != armature) { - if (armature == null && this._childArmature) { + if (armature == null && this._childArmature) this._childArmature.setParentBone(null); - } this._childArmature = armature; } }, @@ -370,7 +369,6 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, getNodeToWorldTransform: function(){ - //TODO TransformConcat return cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToWorldTransform()); }, @@ -452,7 +450,6 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ return detector; } return null; - }, /** @@ -468,7 +465,6 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ locDetector.setColliderFilter(filter); } } - }, /** @@ -479,9 +475,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ var decoDisplay = this.displayManager.getCurrentDecorativeDisplay(); if (decoDisplay) { var detector = decoDisplay.getColliderDetector(); - if (detector) { + if (detector) return detector.getColliderFilter(); - } } return null; }, @@ -636,8 +631,7 @@ _p = null; */ ccs.Bone.create = function (name) { var bone = new ccs.Bone(); - if (bone && bone.init(name)) { + if (bone && bone.init(name)) return bone; - } return null; }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index a931f902c4..decbb1632a 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -211,6 +211,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._movementData = this._animationData.getMovement(animationName); cc.assert(this._movementData, "this._movementData can not be null"); + durationTo = (durationTo === undefined) ? -1 : durationTo; + loop = (loop === undefined) ? -1 : loop; + //! Get key frame count this._rawDuration = this._movementData.duration; this._movementID = animationName; @@ -295,7 +298,11 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Boolean} loop */ playWithNames: function (movementNames, durationTo, loop) { + durationTo = (durationTo === undefined) ? -1 : durationTo; + loop = (loop === undefined) ? true : loop; + this._movementListLoop = loop; + this._movementListDurationTo = durationTo; this._onMovementList = true; this._movementIndex = 0; if(movementNames instanceof Array) @@ -313,6 +320,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Boolean} loop */ playWithIndexes: function (movementIndexes, durationTo, loop) { + durationTo = (durationTo === undefined) ? -1 : durationTo; + loop = (loop === undefined) ? true : loop; + this._movementList.length = 0; this._movementListLoop = loop; this._movementListDurationTo = durationTo; diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 4a720a8c5b..0063f32df9 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -178,7 +178,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); displayTransform.tx = this._anchorPointInPoints.x; displayTransform.ty = this._anchorPointInPoints.y; - return cc.affineTransformConcat( displayTransform,this.bone.getArmature().nodeToWorldTransform()); }, From ac7458743ab25de6772ad3270cccd5e7d53bdb9d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 29 Aug 2014 18:34:54 +0800 Subject: [PATCH 0411/1564] Fixed #5702: Fixed PageView about scrollAction --- extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 5a84dbf3ab..053bf04dfd 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -530,4 +530,4 @@ ccui.PageView.TOUCH_DIR_RIGHT = 1; //PageView auto scroll direction ccui.PageView.DIRECTION_LEFT = 0; -ccui.PageView.DIRECTION_RIGHT = 0; +ccui.PageView.DIRECTION_RIGHT = 1; From 359b25f83f897ad52970fe743121f29f12bdc91c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 29 Aug 2014 20:26:07 +0800 Subject: [PATCH 0412/1564] Fixed #5702: Fixed UIButton FuzzyKey surrounding blur --- cocos2d/core/sprites/CCSprite.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 249b1d8636..3fceab7d49 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -306,6 +306,9 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _newTextureWhenChangeColor: null, //hack property for LabelBMFont _className:"Sprite", + //Only for texture update judgment + _oldDisplayColor: cc.color.WHITE, + textureLoaded:function(){ return this._textureLoaded; }, @@ -1448,6 +1451,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.setColor = function (color3) { var _t = this; var curColor = _t.color; + this._oldDisplayColor = curColor; if ((curColor.r === color3.r) && (curColor.g === color3.g) && (curColor.b === color3.b)) return; cc.Node.prototype.setColor.call(_t, color3); @@ -1455,10 +1459,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateDisplayedColor = function (parentColor) { var _t = this; - var oldColor = _t.getDisplayedColor(); cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); - var newColor = _t._displayedColor; - if ((oldColor.r === newColor.r) && (oldColor.g === newColor.g) && (oldColor.b === newColor.b)) + var oColor = _t._oldDisplayColor; + var nColor = _t._displayedColor; + if (oColor.r === nColor.r && oColor.g === nColor.g && oColor.b === nColor.b) return; _t._changeTextureColor(); From ff27a7dced9976f9eae9b752665ade9509a4b1e8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 6 Aug 2014 22:36:14 +0800 Subject: [PATCH 0413/1564] Fixed #5781: fixed a bug of ccui.Layout --- cocos2d/core/labelttf/LabelTTFWebGL.js | 4 ++-- cocos2d/core/platform/CCConfig.js | 2 +- extensions/ccui/layouts/UILayout.js | 13 ++++++++++++- extensions/cocostudio/armature/CCArmature.js | 12 ++++++++++-- extensions/cocostudio/armature/display/CCSkin.js | 5 ++--- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/cocos2d/core/labelttf/LabelTTFWebGL.js b/cocos2d/core/labelttf/LabelTTFWebGL.js index afc167655d..fca3251d3a 100644 --- a/cocos2d/core/labelttf/LabelTTFWebGL.js +++ b/cocos2d/core/labelttf/LabelTTFWebGL.js @@ -109,7 +109,7 @@ cc._tmp.WebGLLabelTTF = function () { cc._drawingUtil.drawPoly(verticesG1, 4, true); } else if (cc.SPRITE_DEBUG_DRAW === 2) { // draw texture box - var drawSizeG2 = this.getTextureRect()._size; + var drawSizeG2 = this.getTextureRect(); var offsetPixG2X = this.offsetX, offsetPixG2Y = this.offsetY; var verticesG2 = [cc.p(offsetPixG2X, offsetPixG2Y), cc.p(offsetPixG2X + drawSizeG2.width, offsetPixG2Y), cc.p(offsetPixG2X + drawSizeG2.width, offsetPixG2Y + drawSizeG2.height), cc.p(offsetPixG2X, offsetPixG2Y + drawSizeG2.height)]; @@ -120,4 +120,4 @@ cc._tmp.WebGLLabelTTF = function () { //TODO: cc.Sprite.prototype._setTextureRectForWebGL _p.setTextureRect = cc.Sprite.prototype.setTextureRect; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 15590e8dc6..e53e154939 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -33,7 +33,7 @@ * @constant * @type String */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-html5 v3.0 RC2"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC2"; /** *

    diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 2ed1556b62..60491d7dfe 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -381,7 +381,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ gl.stencilOp(gl.ZERO, gl.KEEP, gl.KEEP); // draw a fullscreen solid rectangle to clear the stencil buffer - 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)); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc._drawingUtil.drawSolidRect(cc.p(-1,-1), cc.p(1,1), cc.color(255, 255, 255, 255)); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix(); gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 07060096b1..0c4a8460e6 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -357,6 +357,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ // CC_NODE_DRAW_SETUP(); } + ctx = ctx || cc._renderContext; + var locChildren = this._children; var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; for (var i = 0, len = locChildren.length; i< len; i++) { @@ -384,8 +386,14 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ node.setBlendFunc(this._blendFunc); } node.draw(ctx); - } else - node.visit(ctx); + } else{ + ctx.save(); + var t = node.getNodeToParentTransform(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * cc.view.getScaleX(), -t.ty * cc.view.getScaleY()); + node.draw(ctx); + ctx.restore(); + //node.visit(ctx); + } } break; case ccs.DISPLAY_TYPE_ARMATURE: diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 0063f32df9..78e2c6cf78 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -113,8 +113,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ var transform = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform(); var size = this._rect; - var x1 = this._offsetPosition.x; - var y1 = this._offsetPosition.y; + var x1 = this._offsetPosition.x, y1 = this._offsetPosition.y; var x2 = x1 + size.width, y2 = y1 + size.height; var x = transform.tx, y = transform.ty; @@ -203,7 +202,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ if (cc._renderType == cc._RENDER_TYPE_WEBGL) { ccs.Skin.prototype.updateTransform = ccs.Skin.prototype._updateTransformForWebGL; }else{ - //ccs.Skin.prototype.updateTransform = cc.Sprite.prototype.updateTransform; + //ccs.Skin.prototype.getNodeToParentTransform = cc.Node.prototype._getNodeToParentTransformForWebGL; } //ccs.Skin.prototype.nodeToParentTransform = cc.Node.prototype._getNodeToParentTransformForWebGL; From e314da034ba46332b2a3b084e18dee90d7a43953 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 7 Aug 2014 09:44:05 +0800 Subject: [PATCH 0414/1564] Fixed #5781: fixed a bug of cc.ClippingNode --- cocos2d/clipping-nodes/CCClippingNode.js | 16 +++++++++++----- extensions/ccui/layouts/UILayout.js | 1 - extensions/cocostudio/armature/CCArmature.js | 9 +-------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 8ba9a0f246..c40a0dfb29 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -225,8 +225,17 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ gl.stencilOp(!this.inverted ? gl.ZERO : gl.REPLACE, gl.KEEP, gl.KEEP); // 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.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc._drawingUtil.drawSolidRect(cc.p(-1,-1), cc.p(1,1), cc.color(255, 255, 255, 255)); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix(); /////////////////////////////////// // DRAW CLIPPING STENCIL @@ -266,9 +275,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // restore the depth test state gl.depthMask(currentDepthWriteMask); - //if (currentDepthTestEnabled) { - // glEnable(GL_DEPTH_TEST); - //} /////////////////////////////////// // DRAW CONTENT diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 60491d7dfe..36012a86e3 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -381,7 +381,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ gl.stencilOp(gl.ZERO, gl.KEEP, gl.KEEP); // draw a fullscreen solid rectangle to clear the stencil buffer - //cc._drawingUtil.drawSolidRect(cc.p(0, 0), cc.pFromSize(cc.director.getWinSize()), cc.color(255, 255, 255, 255)); cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLPushMatrix(); cc.kmGLLoadIdentity(); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 0c4a8460e6..fc5753e7ae 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -357,8 +357,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ // CC_NODE_DRAW_SETUP(); } - ctx = ctx || cc._renderContext; - var locChildren = this._children; var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; for (var i = 0, len = locChildren.length; i< len; i++) { @@ -387,12 +385,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ } node.draw(ctx); } else{ - ctx.save(); - var t = node.getNodeToParentTransform(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * cc.view.getScaleX(), -t.ty * cc.view.getScaleY()); - node.draw(ctx); - ctx.restore(); - //node.visit(ctx); + node.visit(ctx); } } break; From b669757fad3a746cb0bc8ffaac7a3d564fd07092 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 7 Aug 2014 10:43:42 +0800 Subject: [PATCH 0415/1564] Fixed #5798: UIText clone error --- extensions/ccui/uiwidgets/UIText.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 4784f8429d..92c009ad91 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -364,7 +364,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _copySpecialProperties: function (uiLabel) { - if(uiLabel instanceof ccui.Label){ + if(uiLabel instanceof ccui.Text){ this.setFontName(uiLabel._fontName); this.setFontSize(uiLabel.getFontSize()); this.setString(uiLabel.getString()); From f1f93af9d53e0ba98cfb46109e2545ae8b139f3f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 7 Aug 2014 10:59:35 +0800 Subject: [PATCH 0416/1564] Fixed #2046: the param model miss "l". --- extensions/ccui/layouts/UILayoutParameter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index d0aaab313f..3f876d38d8 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -316,7 +316,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat */ _copyProperties:function(model){ ccui.LayoutParameter.prototype._copyProperties.call(this, model); - if (mode instanceof ccui.RelativeLayoutParameter) { + if (model instanceof ccui.RelativeLayoutParameter) { this.setAlign(model._relativeAlign); this.setRelativeToWidgetName(model._relativeWidgetName); this.setRelativeName(model._relativeLayoutName); From 38562f734027f52ac136f7da9a7d7f043d3ced8d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 7 Aug 2014 11:31:59 +0800 Subject: [PATCH 0417/1564] Fixed #5781: update the Authors --- AUTHORS.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index dcac9ce289..c8ba9f0531 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -185,9 +185,13 @@ Park Hyun Chen @sincntx Touch anywhere of screen to finish input whe Ninja Lau @mutoo A typo bug in UILayout fix One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix + A transform error in CCTransformHelp.js fix + ccs.DisplayManager bug fix Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode +Minh Quy @MQuy cc.MenuItemSprite bug fix + Retired Core Developers: Shengxiang Chen (Nero Chan) Xingsen Ma From 0b9d8e55121f52e8135bf27028c97b45db793264 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 7 Aug 2014 15:01:06 +0800 Subject: [PATCH 0418/1564] Increased while cycle maximum ceiling. default 100 time --- cocos2d/core/labelttf/CCLabelTTF.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 125eef3995..dcc1459a9c 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -783,15 +783,21 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ var sLine; var pushNum = 0; + //Increased while cycle maximum ceiling. default 100 time + var checkWhile = 0; + //Exceeded the size - while(width > maxWidth){ - fuzzyLen *= maxWidth / width | 0; + while(width > maxWidth && checkWhile++ < 100){ + fuzzyLen *= maxWidth / width; + fuzzyLen = fuzzyLen | 0; tmpText = text.substr(fuzzyLen); width = allWidth - this._measure(tmpText); } + checkWhile = 0; + //Find the truncation point - while(width < maxWidth){ + while(width < maxWidth && checkWhile++ < 100){ if(tmpText){ var exec = cc.LabelTTF._wordRex.exec(tmpText); From a0dc914391620f20f8ab2e1eb2530295db30b631 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 7 Aug 2014 15:22:16 +0800 Subject: [PATCH 0419/1564] Fixed #5781: update the build.xml for v3.0 rc2 --- extensions/cocostudio/ActionManagerEx.js | 77 ------------------- .../cocostudio/action/CCActionManager.js | 1 - extensions/cocostudio/reader/GUIReader.js | 3 +- moduleConfig.json | 1 - tools/build.xml | 4 +- 5 files changed, 3 insertions(+), 83 deletions(-) delete mode 100644 extensions/cocostudio/ActionManagerEx.js diff --git a/extensions/cocostudio/ActionManagerEx.js b/extensions/cocostudio/ActionManagerEx.js deleted file mode 100644 index e8b91d681e..0000000000 --- a/extensions/cocostudio/ActionManagerEx.js +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -ccs.ActionManagerEx = ccs.Class.extend({ - - initWithDictionary: function(jsonName, dic, root){ - var path = jsonName; - var pos = path.lastIndexOf("/"); - var fileName = path.substr(pos+1,path.length()); - cc.log("filename == %s",fileName.toString()); - var actionList = []; - var actionCount = dic["actionlist"]; - for (var i=0; i + debug="false" output="./../lib/cocos2d-js-v3.0-rc2-min.js"> @@ -227,7 +227,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.0-rc2-core-min.js"> From 3141bc9b0fd160c964cb688c04c261824a8fa95f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 7 Aug 2014 15:37:24 +0800 Subject: [PATCH 0420/1564] Fixed #5977: Add cc.sys.platform and improve inline document --- CCBoot.js | 195 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 164 insertions(+), 31 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 082d98933e..56466a7339 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -887,149 +887,276 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Canvas of render type * @constant - * @type Number + * @type {Number} */ cc._RENDER_TYPE_CANVAS = 0; /** * WebGL of render type * @constant - * @type Number + * @type {Number} */ cc._RENDER_TYPE_WEBGL = 1; - var sys = cc.sys = {}; + /** + * System variables + * @memberof cc + * @global + * @type {Object} + * @name cc.sys + */ + cc.sys = {}; + var sys = cc.sys; /** * English language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_ENGLISH = "en"; /** * Chinese language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_CHINESE = "zh"; /** * French language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_FRENCH = "fr"; /** * Italian language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_ITALIAN = "it"; /** * German language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_GERMAN = "de"; /** * Spanish language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_SPANISH = "es"; /** * Russian language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_RUSSIAN = "ru"; /** * Korean language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_KOREAN = "ko"; /** * Japanese language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_JAPANESE = "ja"; /** * Hungarian language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_HUNGARIAN = "hu"; /** * Portuguese language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_PORTUGUESE = "pt"; /** * Arabic language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_ARABIC = "ar"; /** * Norwegian language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_NORWEGIAN = "no"; /** * Polish language code + * @memberof cc.sys * @constant - * @type Number + * @type {Number} */ sys.LANGUAGE_POLISH = "pl"; /** + * @memberof cc.sys * @constant * @type {string} */ sys.OS_WINDOWS = "Windows"; /** + * @memberof cc.sys * @constant * @type {string} */ sys.OS_IOS = "iOS"; /** + * @memberof cc.sys * @constant * @type {string} */ sys.OS_OSX = "OS X"; /** + * @memberof cc.sys * @constant * @type {string} */ sys.OS_UNIX = "UNIX"; /** + * @memberof cc.sys * @constant * @type {string} */ sys.OS_LINUX = "Linux"; /** + * @memberof cc.sys * @constant * @type {string} */ sys.OS_ANDROID = "Android"; sys.OS_UNKNOWN = "Unknown"; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.WINDOWS = 0; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.LINUX = 1; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.MACOS = 2; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.ANDROID = 3; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.IPHONE = 4; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.IPAD = 5; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.BLACKBERRY = 6; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.NACL = 7; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.EMSCRIPTEN = 8; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.TIZEN = 9; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.WINRT = 10; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.WP8 = 11; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.MOBILE_BROWSER = 100; + /** + * @memberof cc.sys + * @constant + * @default + * @type {Number} + */ + sys.DESKTOP_BROWSER = 101; + sys.BROWSER_TYPE_WECHAT = "wechat"; sys.BROWSER_TYPE_ANDROID = "androidbrowser"; sys.BROWSER_TYPE_IE = "ie"; @@ -1050,14 +1177,14 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Is native ? This is set to be true in jsb auto. * @constant - * @type Boolean + * @type {Boolean} */ sys.isNative = false; /** * WhiteList of browser for WebGL. * @constant - * @type Array + * @type {Array} */ var webglWhiteList = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI]; var multipleAudioWhiteList = [ @@ -1069,6 +1196,7 @@ cc._initSys = function (config, CONFIG_KEY) { var ua = nav.userAgent.toLowerCase(); sys.isMobile = ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1; + sys.platform = sys.isMobile ? sys.MOBILE_BROWSER : sys.DESKTOP_BROWSER; var currLanguage = nav.language; currLanguage = currLanguage ? currLanguage : nav.browserLanguage; @@ -1205,6 +1333,7 @@ cc._initSys = function (config, CONFIG_KEY) { str += "browserType : " + self.browserType + "\r\n"; str += "capabilities : " + JSON.stringify(self.capabilities) + "\r\n"; str += "os : " + self.os + "\r\n"; + str += "platform : " + self.platform + "\r\n"; cc.log(str); } }; @@ -1216,52 +1345,52 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Device oriented vertically, home button on the bottom * @constant - * @type Number + * @type {Number} */ cc.ORIENTATION_PORTRAIT = 0; /** * Device oriented vertically, home button on the top * @constant - * @type Number + * @type {Number} */ cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1; /** * Device oriented horizontally, home button on the right * @constant - * @type Number + * @type {Number} */ cc.ORIENTATION_LANDSCAPE_LEFT = 2; /** * Device oriented horizontally, home button on the left * @constant - * @type Number + * @type {Number} */ cc.ORIENTATION_LANDSCAPE_RIGHT = 3; /** * drawing primitive of game engine - * @type cc.DrawingPrimitive + * @type {cc.DrawingPrimitive} */ cc._drawingUtil = null; /** * main Canvas 2D/3D Context of game engine - * @type CanvasRenderingContext2D|WebGLRenderingContext + * @type {CanvasRenderingContext2D|WebGLRenderingContext} */ cc._renderContext = null; /** * main Canvas of game engine - * @type HTMLCanvasElement + * @type {HTMLCanvasElement} */ cc._canvas = null; /** * This Div element contain all game canvas - * @type HTMLDivElement + * @type {HTMLDivElement} */ cc._gameDiv = null; @@ -1448,6 +1577,10 @@ cc._setContextMenuEnable = function (enabled) { /** * An object to boot the game. + * @memberof cc + * @global + * @type {Object} + * @name cc.game */ cc.game = { DEBUG_MODE_NONE: 0, @@ -1467,7 +1600,7 @@ cc.game = { /** * Key of config * @constant - * @type Object + * @type {Object} */ CONFIG_KEY: { engineDir: "engineDir", @@ -1489,19 +1622,19 @@ cc.game = { /** * Config of game - * @type Object + * @type {Object} */ config: null, /** * Callback when the scripts of engine have been load. - * @type Function + * @type {Function} */ onStart: null, /** * Callback when game exits. - * @type Function + * @type {Function} */ onStop: null, From b70b9b17e4613b20c0f6c997d7bf5261c6a043e1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 7 Aug 2014 17:54:04 +0800 Subject: [PATCH 0421/1564] Fixed #5781: fixed a bug of cc.Sprite that its setVisible is invalid when using BatchNode --- cocos2d/core/sprites/CCSprite.js | 10 ++++++++++ cocos2d/core/sprites/SpritesWebGL.js | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 3fceab7d49..4bd128210d 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -558,6 +558,16 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ cc.Node.prototype.removeChild.call(this, child, cleanup); }, + /** + * visible setter (override cc.Node ) + * @param {Boolean} visible + * @override + */ + setVisible:function (visible) { + cc.Node.prototype.setVisible.call(this, visible); + this.setDirtyRecursively(true); + }, + /** * Removes all children from the container (override cc.Node ) * @param cleanup whether or not cleanup all running actions diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 37c90a5c48..56559d24f3 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -25,8 +25,6 @@ ****************************************************************************/ cc._tmp.WebGLSprite = function () { - - var _p = cc.Sprite.prototype; _p._spriteFrameLoadedCallback = function(spriteFrame){ From f4cefb23be50c31ba6d86bbb53e65f6942a29a11 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 7 Aug 2014 18:21:00 +0800 Subject: [PATCH 0422/1564] Fixed #5782: add a directory to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c99130832c..f5e28b036a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ aspnet_client node_modules /tools/jsdoc_toolkit-2.4.0 /package +/tools/jsdoc_toolkit/jsdoc_toolkit-2.4.0 From 0ed41e13af3b243c3fced76f5ceab57b09e82a8f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 7 Aug 2014 21:58:22 +0800 Subject: [PATCH 0423/1564] Fixed a bug of spine that it doesn't work on WebGL Update the CHANGELOG.txt --- CHANGELOG.txt | 33 ++++++++++++++++++++++++++++++++- extensions/spine/CCSkeleton.js | 4 ++-- extensions/spine/Spine.js | 3 +++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8256672195..0ad58663e4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,7 +1,38 @@ ChangeLog: -Cocos2d-html5-v3.0 RC0 @ July.3, 2014 +Cocos2d-html5-v3.0 RC2 @ Aug.8, 2014 + +* Fix ctor functions bugs to support new construction. +* Migrate Cocos UI and fixed bugs. +* Refactor Cocos UI for more stable and friendly user experience. +* Merge cc.NodeRGBA and cc.LayerRGBA to cc.Node. +* Upgrade Cocostudio reader to support version 1.5.x. +* Refactor cc.Sprite's setColor to improve its performance. +* Improve implementation of all Actions lower case alias creation functions. +* Upgrade Cocostudio Armature animation from Cocos2d-x v3.2. +* Upgrade cc.Scale9Sprite from Cocos2d-x 3.2. +* Improve cc.LabelTTF's line break algorithms to support multi-languages. +* Rename CCAffineTransform.js's functions to lowercase started functions. +* Made cc.RenderTexture's beginWithClear accept color value from 0-255. + +* Bugs fix: + 1. Fixed a bug of cc.WebAudio that sourceNode's playbackState is invalid on some browsers. + 2. Fixed a bug of cc.MenuItemToggle that callback is not correctly initialized when using new construction. + 3. Fixed a bug of ccui.Layout that its clipping area is incorrect. + 4. Fixed a bug of requestAnimFrame that it doesn't work after re-focus WeChat browser on Samsung mobile. + 5. Fixed a bug of CCBoot.js that bind function is undefined in Safari for iOS 5.1. + 6. Fixed a bug in cc.layer's bake function that its position is incorrect when cc.view is scaled. + 7. Fixed a bug of cc.LayerMultiplex. + 8. Fixed a bug of cc.TMXLayer that it can't display all map image when its type is hexagonal. + 9. Fixed a transform error in ccs.TransformHelp. + 10. Fixed a bug of cc.ControlSwitch. + 11. Fixed image format constant inconsistence. + 12. Fixed a bug of ccui.Widget that it is invisible after popScene. + 13. Correct behavior of cc.TransitionSlideInB and cc.TransitionSlideInT. + 14. Fixed bugs of ccui.Widget and ccui.Text's clone functions. + +Cocos2d-html5-v3.0 RC0 @ July.3, 2014 * Added Facebook SDK plugin into Pluginx extension. * Refactoration of gui system `ccui` for better performance, usage and maintainbility. * Added `bake` function to `cc.Layer` to support layer baking. diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index c9acf2b8b7..4c92b9381e 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -39,8 +39,8 @@ sp.VERTEX_INDEX = { sp.ATTACHMENT_TYPE = { REGION: 0, - REGION_SEQUENCE: 1, - BOUNDING_BOX: 2 + BOUNDING_BOX: 1, + REGION_SEQUENCE: 2 }; sp.Skeleton = cc.Node.extend({ diff --git a/extensions/spine/Spine.js b/extensions/spine/Spine.js index f6b6f699d2..a5bd20cc0f 100644 --- a/extensions/spine/Spine.js +++ b/extensions/spine/Spine.js @@ -44,6 +44,7 @@ spine.BoneData.prototype = { spine.SlotData = function (name, boneData) { this.name = name; this.boneData = boneData; + this.r = this.g = this.b = this.a = 1; //FOR google compiler Advance mode }; spine.SlotData.prototype = { r: 1, g: 1, b: 1, a: 1, @@ -819,6 +820,7 @@ spine.RegionAttachment = function (name) { this.offset.length = 8; this.uvs = []; this.uvs.length = 8; + this["type"] = spine.AttachmentType.region; //FOR advance mode }; spine.RegionAttachment.prototype = { @@ -903,6 +905,7 @@ spine.RegionAttachment.prototype = { spine.BoundingBoxAttachment = function (name) { this.name = name; this.vertices = []; + this["type"] = spine.AttachmentType.boundingBox; //FOR advance mode }; spine.BoundingBoxAttachment.prototype = { From 8674a1f8a8914618a25e5a5f097a31ca55a74714 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 8 Aug 2014 17:55:17 +0800 Subject: [PATCH 0424/1564] Fixed #599: fixed the bug that hexagonal tilemap on Canvas mode position is error --- cocos2d/tilemap/CCTMXLayer.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 4309b93322..95c4e173e3 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -142,7 +142,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ locCanvas.height = 0 | (locContentSize.height * 1.5 * scaleFactor); if(this.layerOrientation === cc.TMX_ORIENTATION_HEX) - this._cacheContext.translate(0, locCanvas.height - this._mapTileSize.height * 0.5); //translate for hexagonal + this._cacheContext.translate(0, locCanvas.height - (this._mapTileSize.height * 0.5)); //translate for hexagonal else this._cacheContext.translate(0, locCanvas.height); var locTexContentSize = this._cacheTexture._contentSize; @@ -253,23 +253,22 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ //direct draw image by canvas drawImage if (locCacheCanvas) { var locSubCacheCount = this._subCacheCount, locCanvasHeight = locCacheCanvas.height * eglViewer._scaleY; + var halfTileSize = this._mapTileSize.height * 0.5 * eglViewer._scaleY; if(locSubCacheCount > 0) { var locSubCacheCanvasArr = this._subCacheCanvas; for(var i = 0; i < locSubCacheCount; i++){ var selSubCanvas = locSubCacheCanvasArr[i]; if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * this._subCacheWidth, -(posY + locCanvasHeight) + this._mapTileSize.height * 0.5, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); + posX + i * this._subCacheWidth, -(posY + locCanvasHeight) + halfTileSize, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); else context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, posX + i * this._subCacheWidth, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); } } else{ - //context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - // posX, -(posY + locCacheCanvas.height ), locCacheCanvas.width, locCacheCanvas.height ); if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight) + this._mapTileSize.height * 0.5, locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); + posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); else context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, posX, -(posY + locCanvasHeight), locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); From 056c5cf2a1fe12d94c45e3ec3300f78df7837dff Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 9 Aug 2014 01:25:35 +0800 Subject: [PATCH 0425/1564] [Doc] Add change logs and authors --- AUTHORS.txt | 2 ++ CHANGELOG.txt | 53 +++++++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index c8ba9f0531..79d37c1cd8 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -187,10 +187,12 @@ Ninja Lau @mutoo A typo bug in UILayout fix One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix A transform error in CCTransformHelp.js fix ccs.DisplayManager bug fix + Fix child armature lost _parentBone issue; Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode Minh Quy @MQuy cc.MenuItemSprite bug fix + Check empty string for textureData Retired Core Developers: Shengxiang Chen (Nero Chan) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0ad58663e4..1c9273aacc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,34 +2,37 @@ ChangeLog: Cocos2d-html5-v3.0 RC2 @ Aug.8, 2014 -* Fix ctor functions bugs to support new construction. -* Migrate Cocos UI and fixed bugs. -* Refactor Cocos UI for more stable and friendly user experience. -* Merge cc.NodeRGBA and cc.LayerRGBA to cc.Node. -* Upgrade Cocostudio reader to support version 1.5.x. -* Refactor cc.Sprite's setColor to improve its performance. -* Improve implementation of all Actions lower case alias creation functions. -* Upgrade Cocostudio Armature animation from Cocos2d-x v3.2. -* Upgrade cc.Scale9Sprite from Cocos2d-x 3.2. -* Improve cc.LabelTTF's line break algorithms to support multi-languages. -* Rename CCAffineTransform.js's functions to lowercase started functions. +* Refactored Cocos UI for more stable and friendly user experience. +* Upgraded Cocostudio reader to support version 1.2 - 1.5.x. +* Upgraded Cocostudio Armature animation from Cocos2d-x v3.2. +* Added back 2.x createWithXXX functions and deprecate all create/createWithXXX functions. +* Merged cc.NodeRGBA and cc.LayerRGBA to cc.Node. +* Fixed ctor functions bugs to support new construction. +* Refactored cc.Sprite's setColor to improve its performance. +* Renamed CCAffineTransform.js's functions to lowercase started functions. +* Upgraded cc.Scale9Sprite from Cocos2d-x 3.2. +* Improved cc.LabelTTF's line break algorithms to support multi-languages. * Made cc.RenderTexture's beginWithClear accept color value from 0-255. +* Improved implementation of all Actions lower case alias creation functions. +* Added lower case creation functions for 3d actions and progress actions. +* Added cc.sys.platform API for detecting platform. +* Upgraded HelloWorld project with v3.0 APIs. * Bugs fix: - 1. Fixed a bug of cc.WebAudio that sourceNode's playbackState is invalid on some browsers. - 2. Fixed a bug of cc.MenuItemToggle that callback is not correctly initialized when using new construction. - 3. Fixed a bug of ccui.Layout that its clipping area is incorrect. - 4. Fixed a bug of requestAnimFrame that it doesn't work after re-focus WeChat browser on Samsung mobile. - 5. Fixed a bug of CCBoot.js that bind function is undefined in Safari for iOS 5.1. - 6. Fixed a bug in cc.layer's bake function that its position is incorrect when cc.view is scaled. - 7. Fixed a bug of cc.LayerMultiplex. - 8. Fixed a bug of cc.TMXLayer that it can't display all map image when its type is hexagonal. - 9. Fixed a transform error in ccs.TransformHelp. - 10. Fixed a bug of cc.ControlSwitch. - 11. Fixed image format constant inconsistence. - 12. Fixed a bug of ccui.Widget that it is invisible after popScene. - 13. Correct behavior of cc.TransitionSlideInB and cc.TransitionSlideInT. - 14. Fixed bugs of ccui.Widget and ccui.Text's clone functions. + 1. Fixed a transform error in ccs.TransformHelp. + 2. Fixed a bug of cc.MenuItemToggle that callback is not correctly initialized when using new construction. + 3. Fixed a bug in cc.layer's bake function that its position is incorrect when cc.view is scaled. + 4. Fixed a bug of cc.LayerMultiplex. + 5. Fixed a bug of cc.TMXLayer that it can't display all map image when its type is hexagonal. + 6. Fixed a bug of cc.ControlSwitch. + 7. Fixed image format constant inconsistence. + 8. Fixed a bug of ccui.Widget that it is invisible after popScene. + 9. Correct behavior of cc.TransitionSlideInB and cc.TransitionSlideInT. + 10. Fixed a bug of requestAnimFrame that it doesn't work after re-focus WeChat browser on Samsung mobile. + 11. Fixed bugs of ccui.Widget and ccui.Text's clone functions. + 12. Fixed a bug of ccui.Layout that its clipping area is incorrect. + 13. Fixed a bug of CCBoot.js that bind function is undefined in Safari for iOS 5.1. + 14. Fixed a bug of cc.WebAudio that sourceNode's playbackState is invalid on some browsers. Cocos2d-html5-v3.0 RC0 @ July.3, 2014 From f5bc605a5a446728d50a4b1c69257cc61a0bcf79 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 9 Aug 2014 01:30:57 +0800 Subject: [PATCH 0426/1564] [Doc] reverse order of bugs --- CHANGELOG.txt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1c9273aacc..e68a2e2bc4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,20 +19,20 @@ Cocos2d-html5-v3.0 RC2 @ Aug.8, 2014 * Upgraded HelloWorld project with v3.0 APIs. * Bugs fix: - 1. Fixed a transform error in ccs.TransformHelp. - 2. Fixed a bug of cc.MenuItemToggle that callback is not correctly initialized when using new construction. - 3. Fixed a bug in cc.layer's bake function that its position is incorrect when cc.view is scaled. - 4. Fixed a bug of cc.LayerMultiplex. - 5. Fixed a bug of cc.TMXLayer that it can't display all map image when its type is hexagonal. - 6. Fixed a bug of cc.ControlSwitch. - 7. Fixed image format constant inconsistence. - 8. Fixed a bug of ccui.Widget that it is invisible after popScene. - 9. Correct behavior of cc.TransitionSlideInB and cc.TransitionSlideInT. - 10. Fixed a bug of requestAnimFrame that it doesn't work after re-focus WeChat browser on Samsung mobile. - 11. Fixed bugs of ccui.Widget and ccui.Text's clone functions. - 12. Fixed a bug of ccui.Layout that its clipping area is incorrect. - 13. Fixed a bug of CCBoot.js that bind function is undefined in Safari for iOS 5.1. - 14. Fixed a bug of cc.WebAudio that sourceNode's playbackState is invalid on some browsers. + 1. Fixed a bug of cc.WebAudio that sourceNode's playbackState is invalid on some browsers. + 2. Fixed a bug of cc.MenuItemToggle that callback is not correctly initialized when using new construction. + 3. Fixed a bug of ccui.Layout that its clipping area is incorrect. + 4. Fixed a bug of requestAnimFrame that it doesn't work after re-focus WeChat browser on Samsung mobile. + 5. Fixed a bug of CCBoot.js that bind function is undefined in Safari for iOS 5.1. + 6. Fixed a bug in cc.layer's bake function that its position is incorrect when cc.view is scaled. + 7. Fixed a bug of cc.LayerMultiplex. + 8. Fixed a bug of cc.TMXLayer that it can't display all map image when its type is hexagonal. + 9. Fixed a transform error in ccs.TransformHelp. + 10. Fixed a bug of cc.ControlSwitch. + 11. Fixed image format constant inconsistence. + 12. Fixed a bug of ccui.Widget that it is invisible after popScene. + 13. Correct behavior of cc.TransitionSlideInB and cc.TransitionSlideInT. + 14. Fixed bugs of ccui.Widget and ccui.Text's clone functions. Cocos2d-html5-v3.0 RC0 @ July.3, 2014 From 970085fa9150c79bad13b8f3a08116604d8aee3c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 9 Aug 2014 16:29:56 +0800 Subject: [PATCH 0427/1564] Fixed #5803: Set the default value of ccui.Widget's _cascadeColorEnabled and _cascadeOpacityEnabled to false --- cocos2d/core/base-nodes/CCNode.js | 22 ++++--------- cocos2d/core/labelttf/CCLabelTTF.js | 4 +-- cocos2d/core/sprites/CCSprite.js | 6 +++- .../ccui/base-classes/CCProtectedNode.js | 32 +++++++++---------- extensions/ccui/base-classes/UIWidget.js | 6 +--- extensions/ccui/layouts/UILayout.js | 22 ++++++++++--- extensions/ccui/uiwidgets/UIImageView.js | 1 - extensions/ccui/uiwidgets/UIText.js | 2 +- 8 files changed, 49 insertions(+), 46 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 52397a8948..b1170294e0 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1209,17 +1209,14 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, addChildHelper: function(child, localZOrder, tag, name, setTag){ - if(!this._children){ + if(!this._children) this._children = []; - } this._insertChild(child, localZOrder); - - if(setTag){ + if(setTag) child.setTag(tag); - }else{ + else child.setName(name); - } child.setParent(this); child.setOrderOfArrival(cc.s_globalOrderOfArrival++); @@ -1227,21 +1224,14 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if( this._running ){ child.onEnter(); // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter - if (this._isTransitionFinished) { + if (this._isTransitionFinished) child.onEnterTransitionDidFinish(); - } } if (this._cascadeColorEnabled) - { this._enableCascadeColor(); - } - if (this._cascadeOpacityEnabled) - { this._enableCascadeOpacity(); - } - }, // composition: REMOVE @@ -2316,9 +2306,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ parentColor = cc.color.WHITE; this.updateDisplayedColor(parentColor); - if (color.a !== undefined && !color.a_undefined) { + /*if (color.a !== undefined && !color.a_undefined) { //setColor doesn't support changing opacity, please use setOpacity this.setOpacity(color.a); - } + }*/ }, /** diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index dcc1459a9c..c6e2bd455f 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -86,7 +86,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _lineWidths: null, _className: "LabelTTF", - /** * creates a cc.LabelTTF from a font name, alignment, dimension and font size * Constructor of cc.LabelTTF @@ -926,7 +925,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._string.length === 0) { locLabelCanvas.width = 1; - locLabelCanvas.height = locContentSize.height; + locLabelCanvas.height = locContentSize.height || 1; + this._texture && this._texture.handleLoadedTexture(); this.setTextureRect(cc.rect(0, 0, 1, locContentSize.height)); return true; } diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4bd128210d..131f9f3fd1 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -716,7 +716,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param frameIndex */ setDisplayFrameWithAnimationName:function (animationName, frameIndex) { - cc.assert(animationName, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3); var cache = cc.animationCache.getAnimation(animationName); @@ -1375,6 +1374,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t.texture = sender; _t.setTextureRect(locRect, _t._rectRotated); + //set the texture's color after the it loaded + var locColor = this._displayedColor; + if(locColor.r != 255 || locColor.g != 255 || locColor.b != 255) + _t._changeTextureColor(); + // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" _t.batchNode = _t._batchNode; diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index bdb53a3d74..f8a2cede76 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -208,9 +208,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ _children[j+1] = _children[j]; }else if(tmp._localZOrder === _children[j]._localZOrder && tmp.arrivalOrder < _children[j].arrivalOrder){ _children[j+1] = _children[j]; - }else{ + }else break; - } j--; } _children[j+1] = tmp; @@ -375,19 +374,19 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ this._displayedOpacity = this._realOpacity * parentOpacity/255.0; this._updateColor(); + var i,len, locChildren, _opacity = this._displayedOpacity; if (this._cascadeOpacityEnabled){ - var i,len, locChildren = this._children, _opacity = this._displayedOpacity; - for(i = 0, len = locChildren.length;i < len; i++){ - if(locChildren[i].updateDisplayedOpacity) - locChildren[i].updateDisplayedOpacity(_opacity); - } - - locChildren = this._protectedChildren; + locChildren = this._children; for(i = 0, len = locChildren.length;i < len; i++){ if(locChildren[i].updateDisplayedOpacity) locChildren[i].updateDisplayedOpacity(_opacity); } } + locChildren = this._protectedChildren; + for(i = 0, len = locChildren.length;i < len; i++){ + if(locChildren[i]) + locChildren[i].setOpacity(_opacity); + } }, updateDisplayedColor: function(parentColor){ @@ -397,18 +396,19 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ displayedColor.b = realColor.b * parentColor.b/255.0; this._updateColor(); + var i, len, locChildren; if (this._cascadeColorEnabled){ - var i, len, locChildren = this._children; + locChildren = this._children; for(i = 0, len = locChildren.length; i < len; i++){ if(locChildren[i].updateDisplayedColor) locChildren[i].updateDisplayedColor(displayedColor); } + } - locChildren = this._protectedChildren; - for(i =0, len = locChildren.length; i < len; i++) { - if (locChildren[i].updateDisplayedColor) - locChildren[i].updateDisplayedColor(displayedColor); - } + locChildren = this._protectedChildren; + for(i =0, len = locChildren.length; i < len; i++) { + if (locChildren[i]) + locChildren[i].setColor(realColor); } }, @@ -420,7 +420,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren = this._protectedChildren; for(i =0, len = locChildren.length; i < len; i++) - locChildren[i].updateDisplayedColor(white); + locChildren[i].setColor(white); } }); diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 8ebc2d888f..5c230869e4 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -122,10 +122,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setAnchorPoint(cc.p(0.5, 0.5)); this.ignoreContentAdaptWithSize(true); - - this.setCascadeColorEnabled(true); - this.setCascadeOpacityEnabled(true); - return true; } return false; @@ -911,7 +907,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (this._running) { var widgetParent = this.getWidgetParent(); if (widgetParent) { - var pSize = widgetParent.getSize(); + var pSize = widgetParent.getContentSize(); if (pSize.width <= 0 || pSize.height <= 0) { this._positionPercent.x = 0; this._positionPercent.y = 0; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 36012a86e3..2857f20d82 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -712,8 +712,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._addBackGroundImage(); this._backGroundImageFileName = fileName; this._bgImageTexType = texType; + var locBackgroundImage = this._backGroundImage; if (this._backGroundScale9Enabled) { - var bgiScale9 = this._backGroundImage; + var bgiScale9 = locBackgroundImage; switch (this._bgImageTexType) { case ccui.Widget.LOCAL_TEXTURE: bgiScale9.initWithFile(fileName); @@ -726,7 +727,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } bgiScale9.setPreferredSize(this._contentSize); } else { - var sprite = this._backGroundImage; + var sprite = locBackgroundImage; switch (this._bgImageTexType){ case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource @@ -740,9 +741,22 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ break; } } - this._backGroundImageTextureSize = this._backGroundImage.getContentSize(); - this._backGroundImage.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); + this._backGroundImageTextureSize = locBackgroundImage.getContentSize(); + locBackgroundImage.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); this._updateBackGroundImageColor(); + + /*//async load callback + var self = this; + if(!locBackgroundImage.texture || !locBackgroundImage.texture.isLoaded()){ + locBackgroundImage.addLoadedEventListener(function(){ + self._backGroundImageTextureSize = locBackgroundImage.getContentSize(); + locBackgroundImage.setPosition(self._contentSize.width * 0.5, self._contentSize.height * 0.5); + self._updateBackGroundImageColor(); + + self._imageRendererAdaptDirty = true; + self._findLayout(); + }); + }*/ }, /** diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index d643e54d86..7e25730863 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -87,7 +87,6 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ var imageRenderer = self._imageRenderer; if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ imageRenderer.addLoadedEventListener(function(){ - self._findLayout(); self._imageTextureSize = imageRenderer.getContentSize(); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 92c009ad91..73556206c1 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -85,7 +85,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _initRenderer: function () { - this._labelRenderer = cc.LabelTTF.create(); + this._labelRenderer = new cc.LabelTTF(); this.addProtectedChild(this._labelRenderer, ccui.Text.RENDERER_ZORDER, -1); }, From 9e87d59c80b6412ffde81125256f23bd76358e73 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 9 Aug 2014 17:42:17 +0800 Subject: [PATCH 0428/1564] CCBoot.js prepare function (cc.error is not define) --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 56466a7339..7d095e120d 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1797,7 +1797,7 @@ cc.game = { var self = this; var config = self.config, CONFIG_KEY = self.CONFIG_KEY, engineDir = config[CONFIG_KEY.engineDir], loader = cc.loader; if (!cc._supportRender) { - cc.error("Can not support render!") + console.error("Can not support render!") return; } self._prepareCalled = true; From b3902328b8e597239e32468d5984cbb975862c9b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 9 Aug 2014 18:32:53 +0800 Subject: [PATCH 0429/1564] Fixed #5803: UIBMFont supports async loading resource. --- CCBoot.js | 3 +-- cocos2d/labels/CCLabelBMFont.js | 1 - extensions/ccui/base-classes/UIWidget.js | 5 ++++ extensions/ccui/uiwidgets/UIImageView.js | 22 ++++++++-------- extensions/ccui/uiwidgets/UITextAtlas.js | 15 +---------- extensions/ccui/uiwidgets/UITextBMFont.js | 31 +++++++++-------------- 6 files changed, 31 insertions(+), 46 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 56466a7339..d6633a1850 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1797,8 +1797,7 @@ cc.game = { var self = this; var config = self.config, CONFIG_KEY = self.CONFIG_KEY, engineDir = config[CONFIG_KEY.engineDir], loader = cc.loader; if (!cc._supportRender) { - cc.error("Can not support render!") - return; + throw "The renderer doesn't support the renderMode " + config[CONFIG_KEY.renderMode]; } self._prepareCalled = true; diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 1370b9823f..c41bf090f1 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -70,7 +70,6 @@ cc.LABEL_AUTOMATIC_WIDTH = -1; * @property {Number} boundingWidth - Width of the bounding box of label, the real content width is limited by boundingWidth */ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ - _opacityModifyRGB: false, _string: "", diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 5c230869e4..e283d05940 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -369,6 +369,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ default: break; } + if(this._parent instanceof ccui.ImageView){ + var renderer = this._parent._imageRenderer; + if(renderer && !renderer._textureLoaded) + return; + } this.setPosition(absPos); }, diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 7e25730863..29be85e699 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -85,17 +85,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._textureFile = fileName; this._imageTexType = texType; var imageRenderer = self._imageRenderer; - if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ - imageRenderer.addLoadedEventListener(function(){ - self._findLayout(); - self._imageTextureSize = imageRenderer.getContentSize(); - self._updateFlippedX(); - self._updateFlippedY(); - self._updateContentSizeWithTextureSize(self._imageTextureSize); - self._imageRendererAdaptDirty = true; - }); - } switch (self._imageTexType) { case ccui.Widget.LOCAL_TEXTURE: if(self._scale9Enabled){ @@ -119,6 +109,18 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ break; } + if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ + imageRenderer.addLoadedEventListener(function(){ + self._findLayout(); + + self._imageTextureSize = imageRenderer.getContentSize(); + self._updateFlippedX(); + self._updateFlippedY(); + self._updateContentSizeWithTextureSize(self._imageTextureSize); + self._imageRendererAdaptDirty = true; + }); + } + self._imageTextureSize = imageRenderer.getContentSize(); self._updateFlippedX(); self._updateFlippedY(); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 30faf18f1c..95278087b2 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -142,8 +142,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ }, _adaptRenderers: function(){ - if (this._labelAtlasRendererAdaptDirty) - { + if (this._labelAtlasRendererAdaptDirty){ this._labelAtlasScaleChangedWithSize(); this._labelAtlasRendererAdaptDirty = false; } @@ -186,24 +185,12 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ return "LabelAtlas"; }, - _updateTextureColor: function () { - this.updateColorToRenderer(this._labelAtlasRenderer); - }, - _copySpecialProperties: function (labelAtlas) { if (labelAtlas){ this.setProperty(labelAtlas._stringValue, labelAtlas._charMapFileName, labelAtlas._itemWidth, labelAtlas._itemHeight, labelAtlas._startCharMap); } }, - _updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._labelAtlasRenderer); - }, - - _updateTextureRGBA: function(){ - this.updateRGBAToRenderer(this._labelAtlasRenderer); - }, - _createCloneInstance: function () { return ccui.TextAtlas.create(); } diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index a43679ead9..39ac5a2a6d 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -67,12 +67,20 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo if (!fileName) { return; } - this._fntFileName = fileName; + var _self = this; + _self._fntFileName = fileName; // this._labelBMFontRenderer.setBMFontFilePath(fileName); - this._fntFileHasInit = true; + _self._fntFileHasInit = true; // this.setString(this._stringValue); - this._labelBMFontRenderer.initWithString(this._stringValue, fileName); + _self._labelBMFontRenderer.initWithString(this._stringValue, fileName); + + var locRenderer = _self._labelBMFontRenderer; + if(!locRenderer._textureLoaded){ + locRenderer.addLoadedEventListener(function(){ + _self.updateSizeAndPosition(); + }); + } }, /** @@ -92,9 +100,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo setString: function (value) { this._stringValue = value; if (!this._fntFileHasInit) - { return; - } this._labelBMFontRenderer.setString(value); this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()); this._labelBMFontRendererAdaptDirty = true; @@ -123,7 +129,6 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo this._labelBMFontScaleChangedWithSize(); this._labelBMFontRendererAdaptDirty = false; } - }, getVirtualRendererSize: function(){ @@ -154,18 +159,6 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo locRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, - _updateTextureColor: function () { - this.updateColorToRenderer(this._labelBMFontRenderer); - }, - - _updateTextureOpacity: function () { - this.updateOpacityToRenderer(this._labelBMFontRenderer); - }, - - _updateTextureRGBA: function(){ - this.updateRGBAToRenderer(this._labelBMFontRenderer); - }, - /** * Returns the "class name" of widget. * @returns {string} @@ -180,7 +173,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo copySpecialProperties: function (labelBMFont) { this.setFntFile(labelBMFont._fntFileName); - this.setText(labelBMFont._stringValue); + this.setString(labelBMFont._stringValue); } }); From 0ec1893c9b962e7eb08a40629a99cd96a904542c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 11 Aug 2014 10:48:00 +0800 Subject: [PATCH 0430/1564] Issue #5803: Fixed a bug about Layout background --- extensions/ccui/base-classes/CCProtectedNode.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index f8a2cede76..5dca4120a7 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -384,8 +384,9 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } locChildren = this._protectedChildren; for(i = 0, len = locChildren.length;i < len; i++){ + var tmpOpacity = _opacity * locChildren[i].getOpacity() / 255; if(locChildren[i]) - locChildren[i].setOpacity(_opacity); + locChildren[i].setOpacity(tmpOpacity); } }, @@ -407,8 +408,14 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren = this._protectedChildren; for(i =0, len = locChildren.length; i < len; i++) { + + var tmpColor = locChildren[i]._realColor; + var tmpR = realColor.r * tmpColor.r / 255; + var tmpG = realColor.g * tmpColor.g / 255; + var tmpB = realColor.b * tmpColor.b / 255; + if (locChildren[i]) - locChildren[i].setColor(realColor); + locChildren[i].setColor(cc.color(tmpR, tmpG,tmpB)); } }, From 0ab40fd2cfcb52750dc0d89cd3abd1786228e023 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 11 Aug 2014 14:03:31 +0800 Subject: [PATCH 0431/1564] Issue #5803: Fixed a bug about Layout background --- extensions/ccui/base-classes/CCProtectedNode.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 5dca4120a7..6f8e07b8fd 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -384,9 +384,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } locChildren = this._protectedChildren; for(i = 0, len = locChildren.length;i < len; i++){ - var tmpOpacity = _opacity * locChildren[i].getOpacity() / 255; if(locChildren[i]) - locChildren[i].setOpacity(tmpOpacity); + locChildren[i].updateDisplayedOpacity(_opacity); } }, @@ -408,14 +407,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren = this._protectedChildren; for(i =0, len = locChildren.length; i < len; i++) { - - var tmpColor = locChildren[i]._realColor; - var tmpR = realColor.r * tmpColor.r / 255; - var tmpG = realColor.g * tmpColor.g / 255; - var tmpB = realColor.b * tmpColor.b / 255; - if (locChildren[i]) - locChildren[i].setColor(cc.color(tmpR, tmpG,tmpB)); + locChildren[i].updateDisplayedColor(displayedColor); } }, From 9075d41c00e97feb34295489271c301c23b79d54 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 11 Aug 2014 14:27:35 +0800 Subject: [PATCH 0432/1564] Issue #5803: Update the color when loaded resources --- extensions/ccui/base-classes/UIWidget.js | 7 +++++++ extensions/ccui/uiwidgets/UIButton.js | 10 ++++++++-- extensions/ccui/uiwidgets/UICheckBox.js | 20 +++++++++++++++++++- extensions/ccui/uiwidgets/UIImageView.js | 5 +++++ extensions/ccui/uiwidgets/UILoadingBar.js | 2 ++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index e283d05940..1fb8d19b58 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1462,7 +1462,14 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ layout = layout._parent; } } + }, + + _updateChildrenDisplayedRGBA: function(){ + + this.setColor(this.getColor()); + this.setOpacity(this.getOpacity()); } + }); var _p = ccui.Widget.prototype; diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index f76f0043b4..2492d38953 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -222,6 +222,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ self._normalTextureSize = self._buttonNormalRenderer.getContentSize(); self._updateFlippedX(); self._updateFlippedY(); + self._updateChildrenDisplayedRGBA(); self._buttonNormalRenderer.setColor(self.getColor()); self._buttonNormalRenderer.setOpacity(self.getOpacity()); @@ -264,8 +265,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._updateFlippedX(); this._updateFlippedY(); - this._buttonNormalRenderer.setColor(this.getColor()); - this._buttonNormalRenderer.setOpacity(this.getOpacity()); + this._updateChildrenDisplayedRGBA(); this._updateContentSizeWithTextureSize(this._normalTextureSize); this._normalTextureLoaded = true; @@ -293,6 +293,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ self._pressedTextureSize = self._buttonClickedRenderer.getContentSize(); self._updateFlippedX(); self._updateFlippedY(); + self._updateChildrenDisplayedRGBA(); self._pressedTextureLoaded = true; self._pressedTextureAdaptDirty = true; @@ -331,6 +332,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._updateFlippedX(); this._updateFlippedY(); + this._updateChildrenDisplayedRGBA(); + this._pressedTextureLoaded = true; this._pressedTextureAdaptDirty = true; }, @@ -357,6 +360,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ self._disabledTextureSize = self._buttonDisableRenderer.getContentSize(); self._updateFlippedX(); self._updateFlippedY(); + self._updateChildrenDisplayedRGBA(); self._disabledTextureLoaded = true; self._disabledTextureAdaptDirty = true; @@ -395,6 +399,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._updateFlippedX(); this._updateFlippedY(); + this._updateChildrenDisplayedRGBA(); + this._disabledTextureLoaded = true; this._disabledTextureAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 97411bb1d8..2f84b23b51 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -140,7 +140,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ self._updateFlippedX(); self._updateFlippedY(); - + self._updateChildrenDisplayedRGBA(); self._updateContentSizeWithTextureSize(self._backGroundBoxRenderer.getContentSize()); self._backGroundBoxRendererAdaptDirty = true; }); @@ -168,6 +168,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateFlippedX(); this._updateFlippedY(); + this._updateChildrenDisplayedRGBA(); + this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); this._backGroundBoxRendererAdaptDirty = true; }, @@ -193,6 +195,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ self._updateFlippedX(); self._updateFlippedY(); + self._updateChildrenDisplayedRGBA(); self._backGroundSelectedBoxRendererAdaptDirty = true; }); } @@ -212,6 +215,9 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateFlippedX(); this._updateFlippedY(); + + this._updateChildrenDisplayedRGBA(); + this._backGroundSelectedBoxRendererAdaptDirty = true; }, @@ -235,6 +241,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ self._updateFlippedX(); self._updateFlippedY(); + self._updateChildrenDisplayedRGBA(); self._frontCrossRendererAdaptDirty = true; }); } @@ -253,6 +260,9 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } this._updateFlippedX(); this._updateFlippedY(); + + this._updateChildrenDisplayedRGBA(); + this._frontCrossRendererAdaptDirty = true; }, @@ -276,6 +286,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ self._updateFlippedX(); self._updateFlippedY(); + self._updateChildrenDisplayedRGBA(); self._backGroundBoxDisabledRendererAdaptDirty = true; }); } @@ -294,6 +305,9 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } this._updateFlippedX(); this._updateFlippedY(); + + this._updateChildrenDisplayedRGBA(); + this._backGroundBoxDisabledRendererAdaptDirty = true; }, @@ -317,6 +331,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ self._updateFlippedX(); self._updateFlippedY(); + self._updateChildrenDisplayedRGBA(); self._frontCrossDisabledRendererAdaptDirty = true; }); } @@ -335,6 +350,9 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } this._updateFlippedX(); this._updateFlippedY(); + + this._updateChildrenDisplayedRGBA(); + this._frontCrossDisabledRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 29be85e699..b81c921338 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -116,6 +116,9 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ self._imageTextureSize = imageRenderer.getContentSize(); self._updateFlippedX(); self._updateFlippedY(); + + self._updateChildrenDisplayedRGBA(); + self._updateContentSizeWithTextureSize(self._imageTextureSize); self._imageRendererAdaptDirty = true; }); @@ -125,6 +128,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ self._updateFlippedX(); self._updateFlippedY(); + this._updateChildrenDisplayedRGBA(); + self._updateContentSizeWithTextureSize(self._imageTextureSize); self._imageRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 3a3f2cb0c4..a67449e1fe 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -141,6 +141,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ barRenderer.setFlippedX(true); break; } + self._updateChildrenDisplayedRGBA(); self._barRendererScaleChangedWithSize(); self._updateContentSizeWithTextureSize(self._barRendererTextureSize); self._barRendererAdaptDirty = true; @@ -184,6 +185,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ barRenderer.setFlippedX(true); break; } + this._updateChildrenDisplayedRGBA(); this._barRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._barRendererTextureSize); this._barRendererAdaptDirty = true; From 2e91eff0d36f871baf1ffd9cf55e23a093f94e64 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 11 Aug 2014 14:47:35 +0800 Subject: [PATCH 0433/1564] Issue #5803: Update the color when loaded resources --- extensions/ccui/uiwidgets/UISlider.js | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 1e78a0d561..dae0376785 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -118,6 +118,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ barRenderer.addLoadedEventListener(function(){ self._findLayout(); + self._updateChildrenDisplayedRGBA(); self._barRendererAdaptDirty = true; self._progressBarRendererDirty = true; @@ -137,6 +138,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ default: break; } + this._updateChildrenDisplayedRGBA(); this._barRendererAdaptDirty = true; this._progressBarRendererDirty = true; @@ -162,6 +164,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ progressBarRenderer.addLoadedEventListener(function(){ self._findLayout(); + self._updateChildrenDisplayedRGBA(); self._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); var tz = self._progressBarRenderer.getContentSize(); @@ -182,6 +185,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ default: break; } + this._updateChildrenDisplayedRGBA(); this._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); var tz = this._progressBarRenderer.getContentSize(); @@ -329,6 +333,15 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._slidBallNormalTextureFile = normal; this._ballNTexType = texType; + + var self = this; + if(!this._slidBallNormalRenderer.texture || !this._slidBallNormalRenderer.texture.isLoaded()){ + this._slidBallNormalRenderer.addLoadedEventListener(function(){ + + self._updateChildrenDisplayedRGBA(); + }); + } + switch (this._ballNTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource @@ -341,6 +354,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ default: break; } + this._updateChildrenDisplayedRGBA(); }, /** @@ -355,6 +369,15 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._slidBallPressedTextureFile = pressed; this._ballPTexType = texType; + + var self = this; + if(!this._slidBallPressedRenderer.texture || !this._slidBallPressedRenderer.texture.isLoaded()){ + this._slidBallPressedRenderer.addLoadedEventListener(function(){ + + self._updateChildrenDisplayedRGBA(); + }); + } + switch (this._ballPTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource @@ -367,6 +390,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ default: break; } + this._updateChildrenDisplayedRGBA(); }, /** @@ -381,6 +405,15 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._slidBallDisabledTextureFile = disabled; this._ballDTexType = texType; + + var self = this; + if(!this._slidBallDisabledRenderer.texture || !this._slidBallDisabledRenderer.texture.isLoaded()){ + this._slidBallDisabledRenderer.addLoadedEventListener(function(){ + + self._updateChildrenDisplayedRGBA(); + }); + } + switch (this._ballDTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource @@ -393,6 +426,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ default: break; } + this._updateChildrenDisplayedRGBA(); }, /** From 8b4f8087fc1b482b3993db55d01a49455151933f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 11 Aug 2014 16:10:22 +0800 Subject: [PATCH 0434/1564] Issue #5803: Update build.xml --- tools/build.xml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/build.xml b/tools/build.xml index fe942cffa7..c183315327 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -40,6 +40,7 @@ + @@ -162,7 +163,6 @@ - @@ -217,10 +217,28 @@ + + + + + + + + + + + + + + + + + + @@ -241,6 +259,7 @@ + From bb9932221a3a0bdfe2780a29b2c98b6c7725f94c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 11 Aug 2014 17:28:39 +0800 Subject: [PATCH 0435/1564] Fixed #2091: correct a mistake of ccui.ScrollView.removeAllChildreWithCleanup --- extensions/ccui/layouts/UILayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 2857f20d82..ad25dc4b92 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -298,7 +298,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {Boolean} cleanup true if all running actions on all children nodes should be cleanup, false otherwise. */ removeAllChildrenWithCleanup: function(cleanup){ - ccui.Widget.prototype.removeAllChildrenWithCleanup(cleanup); + ccui.Widget.prototype.removeAllChildrenWithCleanup.call(this, cleanup); this._doLayoutDirty = true; }, From be796876c23b87a0715a066b66f2ab43464cf088 Mon Sep 17 00:00:00 2001 From: Michael Yin Date: Tue, 12 Aug 2014 13:29:18 +0800 Subject: [PATCH 0436/1564] refactor: avoid repetition --- CCBoot.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index d6633a1850..ae0bb9767e 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1682,7 +1682,12 @@ cc.game = { } if (!self._prepareCalled) { self.prepare(function () { - if (cc._supportRender) { + self._prepared = true; + }); + } + 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); @@ -1690,23 +1695,9 @@ cc.game = { self._eventShow = self._eventShow || new cc.EventCustom(self.EVENT_SHOW); self._eventShow.setUserData(self); self.onStart(); + clearInterval(self._checkPrepare); } - }); - } 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); - } + }, 10); } }; document.body ? @@ -1842,4 +1833,4 @@ Function.prototype.bind = Function.prototype.bind || function (bind) { var args = Array.prototype.slice.call(arguments); return self.apply(bind || null, args); }; -}; \ No newline at end of file +}; From 0a5d21d897346c561043391a9f124950e7d72747 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 12 Aug 2014 14:53:53 +0800 Subject: [PATCH 0437/1564] Closed #5805: Refactor cc.async for use friendly --- CCBoot.js | 374 ++++++++++++++++----------- cocos2d/core/scenes/CCLoaderScene.js | 32 +-- 2 files changed, 240 insertions(+), 166 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index d6633a1850..116086d1fa 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -66,7 +66,7 @@ cc._isNodeJs = typeof require !== 'undefined' && require("fs"); * Iterate over an object or an array, executing a function for each matched element. * @param {object|array} obj * @param {function} iterator - * @param {object} context + * @param {object} [context] */ cc.each = function (obj, iterator, context) { if (!obj) @@ -104,120 +104,184 @@ cc.isCrossOrigin = function (url) { }; //+++++++++++++++++++++++++something about async begin+++++++++++++++++++++++++++++++ -cc.async = { - // Counter for cc.async - _counterFunc: function (err) { - var counter = this.counter; - if (counter.err) - return; - var length = counter.length; - var results = counter.results; - var option = counter.option; - var cb = option.cb, cbTarget = option.cbTarget, trigger = option.trigger, triggerTarget = option.triggerTarget; - if (err) { - counter.err = err; - if (cb) - return cb.call(cbTarget, err); - return; +/** + * Async Pool class, a helper of cc.async + * @param {Object|Array} srcObj + * @param {Number} limit the limit of parallel number + * @param {function} iterator + * @param {function} onEnd + * @param {object} target + * @constructor + */ +cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ + var self = this; + self._srcObj = srcObj; + self._limit = limit; + self._pool = []; + self._iterator = iterator; + self._iteratorTarget = target; + self._onEnd = onEnd; + self._onEndTarget = target; + self._results = srcObj instanceof Array ? [] : {}; + self._isErr = false; + + cc.each(srcObj, function(value, index){ + self._pool.push({index : index, value : value}); + }); + + self.size = self._pool.length; + self.finishedSize = 0; + self._workingSize = 0; + + self._limit = self._limit || self.size; + + self.onIterator = function(iterator, target){ + self._iterator = iterator; + self._iteratorTarget = target; + }; + + self.onEnd = function(endCb, endCbTarget){ + self._onEnd = endCb; + self._onEndTarget = endCbTarget; + }; + + self._handleItem = function(){ + var self = this; + if(self._pool.length == 0) + return; //return directly if the array's length = 0 + if(self._workingSize >= self._limit) + return; //return directly if the working size great equal limit number + var item = self._pool.shift(); + var value = item.value, index = item.index; + self._workingSize++; + self._iterator.call(self._iteratorTarget, value, index, function(err){ + if(self._isErr) + return; + + self.finishedSize++; + self._workingSize--; + if(err) { + self._isErr = true; + if(self._onEnd) + self._onEnd.call(self._onEndTarget, err); + return + } + + var arr = Array.prototype.slice.call(arguments); + arr.splice(0, 1); + self._results[this.index] = arr[0]; + if(self.finishedSize == self.size) { + if(self._onEnd) + self._onEnd.call(self._onEndTarget, null, self._results); + return + } + self._handleItem(); + }.bind(item), self); + }; + + self.flow = function(){ + var self = this; + if(self._pool.length == 0) { + if(self._onEnd) + self._onEnd.call(self._onEndTarget, null, []); + return; } - var result = Array.apply(null, arguments).slice(1); - var l = result.length; - if (l == 0) - result = null; - else if (l == 1) - result = result[0]; - results[this.index] = result; - counter.count--; - if (trigger) - trigger.call(triggerTarget, result, length - counter.count, length); - if (counter.count == 0 && cb) - cb.apply(cbTarget, [null, results]); - }, + for(var i = 0; i < self._limit; i++) + self._handleItem(); + } +}; - // Empty function for async. - _emptyFunc: function () { +cc.async = { + /** + * Do tasks series. + * @param {Array|Object} tasks + * @param {function} [cb] callback + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + series : function(tasks, cb, target){ + var asyncPool = new cc.AsyncPool(tasks, 1, function(func, index, cb1){ + func.call(target, cb1); + }, cb, target); + asyncPool.flow(); + return asyncPool; }, /** * Do tasks parallel. - * @param {array} tasks - * @param {object|function} [option] - * @param {function} [cb] - */ - parallel: function (tasks, option, cb) { - var async = cc.async; - if (cb !== undefined) { - if (typeof option == "function") - option = {trigger: option}; - option.cb = cb || option.cb; - } else if (option !== undefined) { - if (typeof option == "function") - option = {cb: option}; - } else if (tasks !== undefined) - option = {}; - else - throw "arguments error!"; - var isArr = tasks instanceof Array; - var li = isArr ? tasks.length : Object.keys(tasks).length; - if (li == 0) { - if (option.cb) - option.cb.call(option.cbTarget, null); - return; - } - var results = isArr ? [] : {}; - var counter = { length: li, count: li, option: option, results: results}; - - cc.each(tasks, function (task, index) { - if (counter.err) - return false; - var counterFunc = !option.cb && !option.trigger ? async._emptyFunc : async._counterFunc.bind({counter: counter, index: index});//bind counter and index - task(counterFunc, index); - }); + * @param {Array|Object} tasks + * @param {function} cb callback + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + parallel : function(tasks, cb, target){ + var asyncPool = new cc.AsyncPool(tasks, 0, function(func, index, cb1){ + func.call(target, cb1); + }, cb, target); + asyncPool.flow(); + return asyncPool; + }, + + /** + * Do tasks waterfall. + * @param {Array|Object} tasks + * @param {function} cb callback + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + waterfall : function(tasks, cb, target){ + var args = []; + var asyncPool = new cc.AsyncPool(tasks, 1, + function (func, index, cb1) { + args.push(function (err) { + args = Array.prototype.slice.apply(arguments); + args.splice(0, 1); + cb1.apply(null, arguments); + }); + func.apply(target, args); + }, function (err, results) { + if (!cb) + return; + if (err) + return cb.call(target, err); + cb.call(target, null, results[results.length - 1]); + }); + asyncPool.flow(); + return asyncPool; }, /** * Do tasks by iterator. - * The format of the option should be: - * { - * cb: function, - * target: object, - * iterator: function, - * iteratorTarget: function - * } - * @param {array} tasks - * @param {object|function} [option] - * @param {function} [cb] - */ - map: function (tasks, option, cb) { - var self = this; - var len = arguments.length; - if (typeof option == "function") - option = {iterator: option}; - if (len === 3) - option.cb = cb || option.cb; - else if(len < 2) - throw "arguments error!"; - if (typeof option == "function") - option = {iterator: option}; - if (cb !== undefined) - option.cb = cb || option.cb; - else if (tasks === undefined ) - throw "arguments error!"; - var isArr = tasks instanceof Array; - var li = isArr ? tasks.length : Object.keys(tasks).length; - if (li === 0) { - if (option.cb) - option.cb.call(option.cbTarget, null); - return; + * @param {Array|Object} tasks + * @param {function|Object} iterator + * @param {function} cb callback + * @param {Object} [target] + * @return {cc.AsyncPool} + */ + map : function(tasks, iterator, cb, target){ + var locIterator = iterator; + if(typeof(iterator) == "object"){ + cb = iterator.cb; + target = iterator.iteratorTarget; + locIterator = iterator.iterator; } - var results = isArr ? [] : {}; - var counter = { length: li, count: li, option: option, results: results}; - cc.each(tasks, function (task, index) { - if (counter.err) - return false; - var counterFunc = !option.cb ? self._emptyFunc : self._counterFunc.bind({counter: counter, index: index});//bind counter and index - option.iterator.call(option.iteratorTarget, task, index, counterFunc); - }); + var asyncPool = new cc.AsyncPool(tasks, 0, locIterator, cb, target); + asyncPool.flow(); + return asyncPool; + }, + + /** + * Do tasks by iterator limit. + * @param {Array|Object} tasks + * @param {Number} limit + * @param {function} iterator + * @param {function} cb callback + * @param {Object} [target] + */ + mapLimit : function(tasks, limit, iterator, cb, target){ + var asyncPool = new cc.AsyncPool(tasks, limit, iterator, cb, target); + asyncPool.flow(); + return asyncPool; } }; //+++++++++++++++++++++++++something about async end+++++++++++++++++++++++++++++++++ @@ -410,23 +474,24 @@ cc.loader = { * Load js files. * If the third parameter doesn't exist, then the baseDir turns to be "". * - * @param {string} [baseDir] The pre path for jsList. + * @param {string} [baseDir] The pre path for jsList or the list of js path. * @param {array} jsList List of js path. - * @param {function} [cb] Callback function + * @param {function} [cb] Callback function * @returns {*} */ loadJs: function (baseDir, jsList, cb) { var self = this, localJsCache = self._jsCache, args = self._getArgs4Js(arguments); + var preDir = args[0], list = args[1], callback = args[2]; if (navigator.userAgent.indexOf("Trident/5") > -1) { - self._loadJs4Dependency(args[0], args[1], 0, args[2]); + self._loadJs4Dependency(preDir, list, 0, callback); } else { - cc.async.map(args[1], function (item, index, cb1) { - var jsPath = cc.path.join(args[0], item); + cc.async.map(list, function (item, index, cb1) { + var jsPath = cc.path.join(preDir, item); if (localJsCache[jsPath]) return cb1(null); self._createScript(jsPath, false, cb1); - }, args[2]); + }, callback); } }, /** @@ -574,9 +639,8 @@ cc.loader = { var opt = { isCrossOrigin: true }; - if (cb !== undefined) { + if (cb !== undefined) opt.isCrossOrigin = option.isCrossOrigin == null ? opt.isCrossOrigin : option.isCrossOrigin; - } else if (option !== undefined) cb = option; @@ -654,12 +718,15 @@ cc.loader = { var type = path.extname(url); type = type ? type.toLowerCase() : ""; var loader = self._register[type]; - if (!loader) basePath = self.resPath; - else basePath = loader.getBasePath ? loader.getBasePath() : self.resPath; + if (!loader) + basePath = self.resPath; + else + basePath = loader.getBasePath ? loader.getBasePath() : self.resPath; } - url = cc.path.join(basePath || "", url) + url = cc.path.join(basePath || "", url); if (url.match(/[\/(\\\\)]lang[\/(\\\\)]/i)) { - if (langPathCache[url]) return langPathCache[url]; + if (langPathCache[url]) + return langPathCache[url]; var extname = path.extname(url) || ""; url = langPathCache[url] = url.substring(0, url.length - extname.length) + "_" + cc.sys.language + extname; } @@ -671,31 +738,47 @@ cc.loader = { * @param {string} res * @param {function|Object} [option] option or cb * @param {function} [cb] + * @return {cc.AsyncPool} */ - load: function (res, option, cb) { - if (cb !== undefined) { - if (typeof option == "function") - option = {trigger: option}; - } else if (option !== undefined) { - if (typeof option == "function") { - cb = option; - option = {}; - } - } else if (res !== undefined) - option = {}; - else + /** + * Load resources then call the callback. + * @param {string} resources + * @param {function|Object} [option] option or cb + * @param {function} [cb] + */ + load : function(resources, option, cb){ + var self = this; + var len = arguments.length; + if(len == 0) throw "arguments error!"; - option.cb = function (err, results) { - if (err) - cc.log(err); - if (cb) - cb(results); - }; - if (!(res instanceof Array)) - res = [res]; - option.iterator = this._loadResIterator; - option.iteratorTarget = this; - cc.async.map(res, option); + + if(len == 3){ + if(typeof option == "function"){ + if(typeof cb == "function") + option = {trigger : option, cb : cb }; + else + option = { cb : option, cbTarget : cb}; + } + }else if(len == 2){ + if(typeof option == "function") + option = {cb : option}; + } + + if(!(resources instanceof Array)) + resources = [resources]; + var asyncPool = new cc.AsyncPool(resources, 0, function(value, index, cb1, aPool){ + self._loadResIterator(value, index, function(err){ + if(err) + return cb1(err); + var arr = Array.prototype.slice.call(arguments); + arr.splice(0, 1); + if(option.trigger) + option.trigger.call(option.triggerTarget, arr, aPool.size, aPool.finishedSize); //call trigger + cb1(); + }); + }, option.cb, option.cbTarget); + asyncPool.flow(); + return asyncPool; }, _handleAliases: function (fileNames, cb) { @@ -744,7 +827,8 @@ cc.loader = { self.load(url, function (results) { self._handleAliases(results[0]["filenames"], cb); }); - } else self._handleAliases(dict["filenames"], cb); + } else + self._handleAliases(dict["filenames"], cb); }, /** @@ -755,7 +839,8 @@ cc.loader = { register: function (extNames, loader) { if (!extNames || !loader) return; var self = this; - if (typeof extNames == "string") return this._register[extNames.trim().toLowerCase()] = loader; + if (typeof extNames == "string") + return this._register[extNames.trim().toLowerCase()] = loader; for (var i = 0, li = extNames.length; i < li; i++) { self._register["." + extNames[i].trim().toLowerCase()] = loader; } @@ -786,14 +871,11 @@ cc.loader = { */ releaseAll: function () { var locCache = this.cache, aliases = this._aliases; - for (var key in locCache) { + for (var key in locCache) delete locCache[key]; - } - for (var key in aliases) { + for (var key in aliases) delete aliases[key]; - } } - }; //+++++++++++++++++++++++++something about loader end+++++++++++++++++++++++++++++ diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index f269bbb686..e3766b23ed 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -25,10 +25,10 @@ cc.LoaderScene = cc.Scene.extend({ _interval : null, - _length : 0, - _count : 0, _label : null, _className:"LoaderScene", + _loadingPool:null, + init : function(){ var self = this; @@ -37,7 +37,7 @@ cc.LoaderScene = cc.Scene.extend({ var logoHeight = 200; // bg - var bgLayer = self._bgLayer = cc.LayerColor.create(cc.color(32, 32, 32, 255)); + var bgLayer = self._bgLayer = new cc.LayerColor(cc.color(32, 32, 32, 255)); bgLayer.setPosition(cc.visibleRect.bottomLeft); self.addChild(bgLayer, 0); @@ -100,23 +100,15 @@ cc.LoaderScene = cc.Scene.extend({ var self = this; self.unschedule(self._startLoading); var res = self.resources; - self._length = res.length; - self._count = 0; - cc.loader.load(res, function(result, count){ self._count = count; }, function(){ - if(self.cb) - self.cb(); - }); - self.schedule(self._updatePercent); - }, - - _updatePercent: function () { - var self = this; - var count = self._count; - var length = self._length; - var percent = (count / length * 100) | 0; - percent = Math.min(percent, 100); - self._label.setString("Loading... " + percent + "%"); - if(count >= length) self.unschedule(self._updatePercent); + cc.loader.load(res, + function (result, count, loadedCount) { + var percent = (loadedCount / count * 100) | 0; + percent = Math.min(percent, 100); + self._label.setString("Loading... " + percent + "%"); + }, function () { + if (self.cb) + self.cb(); + }); } }); cc.LoaderScene.preload = function(resources, cb){ From eb8f0b6ee0379808eb57b8debbe8f073f517844b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 12 Aug 2014 14:58:29 +0800 Subject: [PATCH 0438/1564] Closed #5805: remove the test code --- cocos2d/core/scenes/CCLoaderScene.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index e3766b23ed..c920d21b56 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -27,7 +27,6 @@ cc.LoaderScene = cc.Scene.extend({ _interval : null, _label : null, _className:"LoaderScene", - _loadingPool:null, init : function(){ var self = this; From 5c2efcac3271d76099ac72f6b6264de475416733 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 12 Aug 2014 16:12:00 +0800 Subject: [PATCH 0439/1564] Fixed #5805: add a utility function of string --- CCBoot.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 116086d1fa..d595995b50 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -879,6 +879,49 @@ cc.loader = { }; //+++++++++++++++++++++++++something about loader end+++++++++++++++++++++++++++++ +/** + * A string tool to construct a string with format string. + * for example: cc.formatStr("a: %d, b: %b", a, b); + * @param {String} formatStr format String + * @returns {String} + */ +cc.formatStr = function(){ + var args = arguments; + var l = args.length; + if(l < 1) + return ""; + + var str = args[0]; + var needToFormat = true; + if(typeof str == "object"){ + str = JSON.stringify(str); + needToFormat = false; + } + for(var i = 1; i < l; ++i){ + var arg = args[i]; + arg = typeof arg == "object" ? JSON.stringify(arg) : arg; + if(needToFormat){ + while(true){ + var result = null; + if(typeof arg == "number"){ + result = str.match(/(%d)|(%s)/); + if(result){ + str = str.replace(/(%d)|(%s)/, arg); + break; + } + } + result = str.match(/%s/); + if(result) + str = str.replace(/%s/, arg); + else + str += " " + arg; + break; + } + }else + str += " " + arg; + } + return str; +}; //+++++++++++++++++++++++++something about window events begin+++++++++++++++++++++++++++ (function () { From 3ba8d8381394a25f80e700b9359ec8aeb010d447 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 12 Aug 2014 16:42:19 +0800 Subject: [PATCH 0440/1564] Issue #586: hexagonal tilemap on Canvas mode can't runAction --- cocos2d/core/sprites/CCSpriteBatchNode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 45bea9c6b7..f2917ebf8d 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -538,6 +538,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ // XXX: so, it should be AFTER the insertQuad sprite.dirty = true; sprite.updateTransform(); + sprite._setCachedParent(this); this._children.splice(index, 0, sprite); }, From 8de2ff1241aa5d2aaa48742d773958c67b9346fa Mon Sep 17 00:00:00 2001 From: mutoo Date: Tue, 12 Aug 2014 16:50:42 +0800 Subject: [PATCH 0441/1564] fix an unreachable bug fix; --- cocos2d/core/event-manager/CCEventManager.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 7ab7666575..02be6a6c5b 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -777,14 +777,13 @@ cc.eventManager = /** @lends cc.eventManager# */{ // Don't want any dangling pointers or the possibility of dealing with deleted objects.. delete _t._nodePriorityMap[listenerType.__instanceId]; cc.arrayRemoveObject(_t._dirtyNodes, listenerType); - var listeners = _t._nodeListenersMap[listenerType.__instanceId]; - if (!listeners) - return; - - var listenersCopy = cc.copyArray(listeners), i; - for (i = 0; i < listenersCopy.length; i++) - _t.removeListener(listenersCopy[i]); - listenersCopy.length = 0; + var listeners = _t._nodeListenersMap[listenerType.__instanceId], i; + if (listeners) { + var listenersCopy = cc.copyArray(listeners); + for (i = 0; i < listenersCopy.length; i++) + _t.removeListener(listenersCopy[i]); + listenersCopy.length = 0; + } // Bug fix: ensure there are no references to the node in the list of listeners to be added. // If we find any listeners associated with the destroyed node in this list then remove them. From 16765c53f55d18d01fc91c369396360afe1ad95f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 12 Aug 2014 18:18:25 +0800 Subject: [PATCH 0442/1564] Fixed #5805: refactor cc.log for more maintainability --- CCBoot.js | 6 ++- CCDebugger.js | 133 ++++++++++++++++++++++---------------------------- 2 files changed, 62 insertions(+), 77 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index d595995b50..a95b48b48c 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -881,8 +881,9 @@ cc.loader = { /** * A string tool to construct a string with format string. - * for example: cc.formatStr("a: %d, b: %b", a, b); - * @param {String} formatStr format String + * for example: + * cc.formatStr("a: %d, b: %b", a, b); + * cc.formatStr(a, b, c); * @returns {String} */ cc.formatStr = function(){ @@ -923,6 +924,7 @@ cc.formatStr = function(){ return str; }; + //+++++++++++++++++++++++++something about window events begin+++++++++++++++++++++++++++ (function () { var win = window, hidden, visibilityChange, _undef = "undefined"; diff --git a/CCDebugger.js b/CCDebugger.js index dabf228c84..6990dcfe01 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -266,91 +266,74 @@ cc._logToWebPage = function (msg) { }; //to make sure the cc.log, cc.warn, cc.error and cc.assert would not throw error before init by debugger mode. -cc._formatString = function(arg){ - if(typeof arg === 'object'){ - try{ +cc._formatString = function (arg) { + if (typeof arg === 'object') { + try { return JSON.stringify(arg); - }catch(err){ + } catch (err) { return ""; } - }else{ + } else return arg; - } }; -if (console.log) { - cc.log = function(msg){ - for (var i = 1; i < arguments.length; i++) { - msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); - } - console.log(msg); - }; - cc.warn = console.warn ? - function(msg){ - for (var i = 1; i < arguments.length; i++) { - msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); - } - console.warn(msg); - } : - cc.log; - cc.error = console.error ? - function(msg){ - for (var i = 1; i < arguments.length; i++) { - msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); - } - console.error(msg); - } : - cc.log; - cc.assert = function (cond, msg) { - if (!cond && msg) { - for (var i = 2; i < arguments.length; i++) { - msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); - } - throw msg; - } - }; -} - /** * Init Debug setting. * @function + * @param {Number} mode */ -var mode = cc.game.config[cc.game.CONFIG_KEY.debugMode]; -var ccGame = cc.game; - -//log -if (console.log && mode === ccGame.DEBUG_MODE_INFO) { -} -else if (mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE) - cc.log = cc._logToWebPage.bind(cc); -else -//Clear - cc.log = function () { - }; - -//warn -if (!mode || mode == ccGame.DEBUG_MODE_NONE || mode == ccGame.DEBUG_MODE_ERROR || mode == ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE) - cc.warn = function () { - }; -if (mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE || mode == ccGame.DEBUG_MODE_WARN_FOR_WEB_PAGE || !console.warn) - cc.warn = cc._logToWebPage.bind(cc); - - -//error and assert -if (!mode || mode == ccGame.DEBUG_MODE_NONE) { - cc.error = function () { - }; - cc.assert = function () { - }; -} else if (mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE || mode == ccGame.DEBUG_MODE_WARN_FOR_WEB_PAGE || mode == ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE || !console.error) { - cc.error = cc._logToWebPage.bind(cc); - cc.assert = function (cond, msg) { - if (!cond && msg) { - for (var i = 2; i < arguments.length; i++) { - msg = msg.replace("%s", arguments[i]); +cc._initDebugSetting = function (mode) { + var ccGame = cc.game; + if(mode == ccGame.DEBUG_MODE_NONE) + return; + + var locLog; + if(mode > ccGame.DEBUG_MODE_ERROR){ + //log to web page + locLog = cc._logToWebPage.bind(cc); + cc.error = function(){ + locLog("ERROR : " + cc.formatStr.apply(cc, arguments)); + }; + cc.assert = function(cond, msg) { + if (!cond && msg) { + for (var i = 2; i < arguments.length; i++) + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); + locLog("Assert: " + msg); } - cc._logToWebPage(msg); + }; + if(mode != ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE){ + cc.warn = function(){ + locLog("WARN : " + cc.formatStr.apply(cc, arguments)); + }; + } + if(mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE){ + cc.log = function(){ + locLog(cc.formatStr.apply(cc, arguments)); + }; } + } else { + //log to console + if(!console) //console is null when user doesn't open dev tool on IE9 + return; + + cc.error = function(){ + return console.error.apply(console, arguments); + }; + cc.assert = function (cond, msg) { + if (!cond && msg) { + for (var i = 2; i < arguments.length; i++) + msg = msg.replace(/(%s)|(%d)/, cc._formatString(arguments[i])); + throw msg; + } + }; + if(mode != ccGame.DEBUG_MODE_ERROR) + cc.warn = function(){ + return console.warn.apply(console, arguments); + }; + if(mode == ccGame.DEBUG_MODE_INFO) + cc.log = function(){ + return console.log.apply(console, arguments); + }; } -} - +}; +cc._initDebugSetting(cc.game.config[cc.game.CONFIG_KEY.debugMode]); //+++++++++++++++++++++++++something about log end+++++++++++++++++++++++++++++ \ No newline at end of file From cbd309a0236ef914959ab133ab8fe5a6355429eb Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 13 Aug 2014 01:17:31 +0800 Subject: [PATCH 0443/1564] Issue #5781: Fix audio end event issue in closure compile advanced mode --- cocos2d/audio/CCAudio.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 409ef8e0a0..5d9a881a30 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -82,6 +82,7 @@ if (cc.sys._supportWebAudio) { sourceNode["connect"](volumeNode); volumeNode["connect"](_ctx["destination"]); sourceNode.loop = self._loop; + /** @expose */ sourceNode.onended = function(){ self._stopped = true; }; From 7522a6f88df98b3123225911e8c665b99e1e3448 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 13 Aug 2014 09:39:24 +0800 Subject: [PATCH 0444/1564] Issue #5807: CCAudio load file is not incoming parameters --- CCBoot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index a95b48b48c..c2ecb4621e 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -762,6 +762,8 @@ cc.loader = { }else if(len == 2){ if(typeof option == "function") option = {cb : option}; + }else if(len == 1){ + option = {}; } if(!(resources instanceof Array)) From ee7bfd2a571db6f2fa2bea9812404115c284388d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 13 Aug 2014 11:01:00 +0800 Subject: [PATCH 0445/1564] Fixed #5805: remove an incorrect jsDoc document --- CCBoot.js | 1 - 1 file changed, 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index c2ecb4621e..720bce2237 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1848,7 +1848,6 @@ cc.game = { /** * Init config. - * @param cb * @returns {*} * @private */ From decbe76ab453ad70a661d85dcea6a03c46fe7820 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 13 Aug 2014 16:08:14 +0800 Subject: [PATCH 0446/1564] Issue #5809: EditBox create div error because lose id --- extensions/editbox/CCdomNode.js | 72 ++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index 35e22693a4..bf77114484 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -357,7 +357,11 @@ cc.DOM.methods = /** @lends cc.DOM# */{ //if dom does not have parent, but node has no parent and its running if (this.dom && !this.dom.parentNode) { if (!this.getParent()) { - this.dom.appendTo(cc.container); + if(this.dom.id == ""){ + cc.DOM._createEGLViewDiv(this); + }else{ + this.dom.appendTo(cc.container); + } } else { cc.DOM.parentDOM(this); } @@ -478,43 +482,47 @@ cc.DOM.parentDOM = function (x) { if (eglViewDiv) { p.dom.appendTo(eglViewDiv); } else { - eglViewDiv = cc.$new("div"); - eglViewDiv.id = "EGLViewDiv"; - - var eglViewer = cc.view; - var designSize = eglViewer.getDesignResolutionSize(); - var viewPortRect = eglViewer.getViewPortRect(); - var screenSize = eglViewer.getFrameSize(); - var pixelRatio = eglViewer.getDevicePixelRatio(); - var designSizeWidth = designSize.width, designSizeHeight = designSize.height; - if ((designSize.width === 0) && (designSize.height === 0)) { - designSizeWidth = screenSize.width; - designSizeHeight = screenSize.height; - } - - var viewPortWidth = viewPortRect.width/pixelRatio; - if ((viewPortRect.width === 0) && (viewPortRect.height === 0)) { - viewPortWidth = screenSize.width; - } - - eglViewDiv.style.position = 'absolute'; - //x.dom.style.display='block'; - eglViewDiv.style.width = designSizeWidth + "px"; - eglViewDiv.style.maxHeight = designSizeHeight + "px"; - eglViewDiv.style.margin = 0; - - eglViewDiv.resize(eglViewer.getScaleX()/pixelRatio, eglViewer.getScaleY()/pixelRatio); - eglViewDiv.style.left = (viewPortWidth - designSizeWidth) / 2 + "px"; - eglViewDiv.style.bottom = "0px"; - - p.dom.appendTo(eglViewDiv); - eglViewDiv.appendTo(cc.container); + cc.DOM._createEGLViewDiv(p); } } } return true; }; +cc.DOM._createEGLViewDiv = function(p){ + var eglViewDiv = cc.$new("div"); + eglViewDiv.id = "EGLViewDiv"; + + var eglViewer = cc.view; + var designSize = eglViewer.getDesignResolutionSize(); + var viewPortRect = eglViewer.getViewPortRect(); + var screenSize = eglViewer.getFrameSize(); + var pixelRatio = eglViewer.getDevicePixelRatio(); + var designSizeWidth = designSize.width, designSizeHeight = designSize.height; + if ((designSize.width === 0) && (designSize.height === 0)) { + designSizeWidth = screenSize.width; + designSizeHeight = screenSize.height; + } + + var viewPortWidth = viewPortRect.width/pixelRatio; + if ((viewPortRect.width === 0) && (viewPortRect.height === 0)) { + viewPortWidth = screenSize.width; + } + + eglViewDiv.style.position = 'absolute'; + //x.dom.style.display='block'; + eglViewDiv.style.width = designSizeWidth + "px"; + eglViewDiv.style.maxHeight = designSizeHeight + "px"; + eglViewDiv.style.margin = 0; + + eglViewDiv.resize(eglViewer.getScaleX()/pixelRatio, eglViewer.getScaleY()/pixelRatio); + eglViewDiv.style.left = (viewPortWidth - designSizeWidth) / 2 + "px"; + eglViewDiv.style.bottom = "0px"; + + p.dom.appendTo(eglViewDiv); + eglViewDiv.appendTo(cc.container); +}; + /** * @function * @private From 5d72f390c7ee52789b10b649afc15a2c097e874d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 13 Aug 2014 16:23:59 +0800 Subject: [PATCH 0447/1564] Correct a bug of cc.WebAudio that the stopped state is incorrect. --- cocos2d/audio/CCAudio.js | 34 +++++++++++++++++------ extensions/ccui/uiwidgets/UITextBMFont.js | 2 +- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 5d9a881a30..3b3e4ea372 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -82,10 +82,13 @@ if (cc.sys._supportWebAudio) { sourceNode["connect"](volumeNode); volumeNode["connect"](_ctx["destination"]); sourceNode.loop = self._loop; - /** @expose */ - sourceNode.onended = function(){ - self._stopped = true; - }; + sourceNode._stopped = false; + + if(!sourceNode["playbackState"]){ + sourceNode["onended"] = function(){ + this._stopped = true; + }; + } self._paused = false; self._stopped = false; @@ -122,7 +125,8 @@ if (cc.sys._supportWebAudio) { }, _stop: function () { var self = this, sourceNode = self._sourceNode; - if (self._stopped) return; + if (self._stopped) + return; if (sourceNode.stop) sourceNode.stop(0); else @@ -138,7 +142,7 @@ if (cc.sys._supportWebAudio) { return; var sourceNode = self._sourceNode; - if (!self._stopped && sourceNode && sourceNode["playbackState"] == 2) + if (!self._stopped && sourceNode && (sourceNode["playbackState"] == 2 || !sourceNode._stopped)) return;//playing self.startTime = _ctx.currentTime; @@ -247,7 +251,16 @@ if (cc.sys._supportWebAudio) { _p.ended; cc.defineGetterSetter(_p, "ended", function () { var sourceNode = this._sourceNode; - return !this._paused && (this._stopped || !sourceNode || sourceNode["playbackState"] == 3); + if(this._paused) + return false; + if(this._stopped && !sourceNode) + return true; + if(sourceNode["playbackState"] == null){ + return sourceNode._stopped; + } else { + return sourceNode["playbackState"] == 3; + } + }); /** @expose */ _p.played; @@ -316,7 +329,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ */ playMusic: function (url, loop) { var self = this; - if (!self._soundSupported) return; + if (!self._soundSupported) + return; var audio = self._currMusic; if (audio) @@ -326,7 +340,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ self._currMusic = audio; self._currMusicPath = url; } - if (!audio) return; + if (!audio) + return; audio.loop = loop || false; self._playMusic(audio); }, @@ -374,6 +389,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ _stopAudio: function (audio) { if (audio && !audio.ended) { if (audio.stop) {//cc.WebAudio + console.log("close audio:" + audio.__instanceId); audio.stop(); } else { if(audio.duration && audio.duration != Infinity) diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 39ac5a2a6d..d60c43d2a1 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -195,7 +195,7 @@ _p = null; * var uiLabelBMFont = ccui.TextBMFont.create(); */ ccui.TextBMFont.create = function (text, filename) { - return new ccui.ccui.TextBMFont(text, filename); + return new ccui.TextBMFont(text, filename); }; // Constants From e7000e182687faf95965998daa8dda3705d46c7d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 13 Aug 2014 16:30:46 +0800 Subject: [PATCH 0448/1564] Issue #5810 :Remove script label is added --- CCBoot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 4787dbb0b8..5b0c4e6f5c 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -516,10 +516,12 @@ cc.loader = { s.src = jsPath; self._jsCache[jsPath] = true; cc._addEventListener(s, 'load', function () { + s.parentNode.removeChild(s); this.removeEventListener('load', arguments.callee, false); cb(); }, false); cc._addEventListener(s, 'error', function () { + s.parentNode.removeChild(s); cb("Load " + jsPath + " failed!"); }, false); d.body.appendChild(s); From acf45d1b46fb639373bd4fad8225fd0ea350c4e3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 13 Aug 2014 18:30:28 +0800 Subject: [PATCH 0449/1564] Fixed #1977: SpriteFrame rect error --- cocos2d/core/sprites/CCSpriteFrame.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index d8f60a1807..ac5c0b7a2a 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -355,6 +355,10 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ } texture = this.getTexture(); + + this._rectInPixels = rect; + rect = this._rect = cc.rectPixelsToPoints(rect); + if(texture && texture.url) { var _x, _y; if(rotated){ @@ -372,8 +376,6 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ } } - this._rectInPixels = rect; - this._rect = cc.rectPixelsToPoints(rect); this._offsetInPixels.x = offset.x; this._offsetInPixels.y = offset.y; cc._pointPixelsToPointsOut(offset, this._offset); From 8b872feb1eccc24486939200a990876b95e7d21c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 14 Aug 2014 12:02:24 +0800 Subject: [PATCH 0450/1564] Fixed a bug of cc.AudioEngine that it doesn't work on firefox after it compiled with advanced mode --- cocos2d/audio/CCAudio.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 3b3e4ea372..e7b53cc916 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -255,18 +255,16 @@ if (cc.sys._supportWebAudio) { return false; if(this._stopped && !sourceNode) return true; - if(sourceNode["playbackState"] == null){ + if(sourceNode["playbackState"] == null) return sourceNode._stopped; - } else { + else return sourceNode["playbackState"] == 3; - } - }); /** @expose */ _p.played; cc.defineGetterSetter(_p, "played", function () { var sourceNode = this._sourceNode; - return sourceNode && sourceNode["playbackState"] == 2; + return sourceNode && (sourceNode["playbackState"] == 2 || !sourceNode._stopped); }); } @@ -389,7 +387,6 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ _stopAudio: function (audio) { if (audio && !audio.ended) { if (audio.stop) {//cc.WebAudio - console.log("close audio:" + audio.__instanceId); audio.stop(); } else { if(audio.duration && audio.duration != Infinity) @@ -430,8 +427,10 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ }, _resumeAudio: function (audio) { if (audio && !audio.ended) { - if (audio.resume) audio.resume();//cc.WebAudio - else audio.play(); + if (audio.resume) + audio.resume();//cc.WebAudio + else + audio.play(); } }, @@ -1026,7 +1025,11 @@ cc._audioLoader = { return this._supportedAudioTypes.indexOf(type.toLowerCase()) >= 0; }, _loadAudio: function (url, audio, cb, delFlag) { - var _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); + var _Audio; + if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") + _Audio = Audio; //The WebAudio of FireFox doesn't work after google closure compiler compiled with advanced mode + else + _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); if (arguments.length == 2) { cb = audio; audio = new _Audio(); From 01a250c3acb9e23de4fb65b32a039c33ab99b687 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 14 Aug 2014 15:23:59 +0800 Subject: [PATCH 0451/1564] Issue #5695: Update Facebook plugin 1. support app request 2. Compatibility adjustment --- external/pluginx/platform/facebook.js | 74 +++++++++++++++++---------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 5604863dcf..240e5bfc1d 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -12,7 +12,7 @@ plugin.extend('facebook', { ctor: function(config){ this.name = "facebook"; - this.version = "2.0"; + this.version = "1.0"; this.userInfo = {}; if (!FB) { @@ -20,11 +20,8 @@ plugin.extend('facebook', { } var self = this; - FB.init({ - appId : config['appId'], - xfbml : config['xfbml'], - version : config['version'] - }); + //This configuration will be read from the project.json. + FB.init(config); FB.getLoginStatus(function(response) { if (response && response.status === 'connected') { //login @@ -57,9 +54,9 @@ plugin.extend('facebook', { if (response.authResponse) { //save user info self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0); + typeof callback === 'function' && callback(0, JSON.stringify(response)); } else { - typeof callback === 'function' && callback(1); + typeof callback === 'function' && callback(1, JSON.stringify(response)); } }, { scope: '' }); }, @@ -78,9 +75,9 @@ plugin.extend('facebook', { if (response && response.status === 'connected') { //login - save user info self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0, 'logged'); + typeof callback === 'function' && callback(0, JSON.stringify(response)); }else{ - typeof callback === 'function' && callback(1); + typeof callback === 'function' && callback(1, JSON.stringify(response)); } }); }, @@ -94,9 +91,9 @@ plugin.extend('facebook', { if(response.authResponse){ // user is now logged out self.userInfo = {}; - typeof callback === 'function' && callback(0); + typeof callback === 'function' && callback(0, JSON.stringify(response)); }else{ - typeof callback === 'function' && callback(1); + typeof callback === 'function' && callback(1, JSON.stringify(response)); } }); }, @@ -106,17 +103,22 @@ plugin.extend('facebook', { * @param callback */ requestPermissions: function(permissions, callback){ + permissions.push("user_hometown"); var permissionsStr = permissions.join(','); var self = this; FB.login(function(response){ + console.log(response) if (response.authResponse) { //save user info self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0); + typeof callback === 'function' && callback(0, JSON.stringify(response)); } else { - typeof callback === 'function' && callback(1); + typeof callback === 'function' && callback(1, JSON.stringify(response)); } - }, {scope: permissionsStr}); + }, { + scope: permissionsStr, + return_scopes: true + }); }, /** @@ -159,11 +161,11 @@ plugin.extend('facebook', { function(response) { if (response) { if(response.post_id) - typeof callback === 'function' && callback(0); + typeof callback === 'function' && callback(0, JSON.stringify(response)); else - typeof callback === 'function' && callback(3); + typeof callback === 'function' && callback(3, JSON.stringify(response)); } else { - typeof callback === 'function' && callback(4); + typeof callback === 'function' && callback(4, JSON.stringify(response)); } }); }, @@ -177,7 +179,7 @@ plugin.extend('facebook', { return; } - info['method'] = info['dialog'] == 'share_open_graph' ? 'share_open_graph' : 'share'; + info['method'] = info['dialog']; delete info['dialog']; info['name'] = info['site'] || info['name']; @@ -218,7 +220,8 @@ plugin.extend('facebook', { if( info['method'] != 'share_open_graph' && - info['method'] != 'share_link' + info['method'] != 'share_link' && + info['method'] != 'apprequests' ){ cc.log('web is not supported what this it method'); return; @@ -228,11 +231,11 @@ plugin.extend('facebook', { function(response) { if (response) { if(response.post_id) - typeof callback === 'function' && callback(0); + typeof callback === 'function' && callback(0, JSON.stringify(response)); else - typeof callback === 'function' && callback(response.error_code, response.error_message); + typeof callback === 'function' && callback(response.error_code, JSON.stringify(response)); } else { - typeof callback === 'function' && callback(1); + typeof callback === 'function' && callback(1, JSON.stringify(response)); } }); }, @@ -246,14 +249,33 @@ plugin.extend('facebook', { request: function(path, httpmethod, params, callback){ FB.api(path, httpmethod, params, function(response){ if(response.error){ - callback(response.error.code, "{}") + callback(response.error.code, JSON.stringify(response)) }else{ callback(0, JSON.stringify(response)); } }); }, - destroyInstance: function(){ - void 69; + destroyInstance: function(){}, + + /** + * @param {Object} info + * @param {Function} callback + */ + pay: function(info, callback){ + /* + * Reference document + * https://developers.facebook.com/docs/payments/reference/paydialog + */ + + info.method = 'pay'; + + FB.ui(info, function(response) { + if(response.error_code){ + callback(response.error_code, JSON.stringify(response)); + }else{ + callback(0, JSON.stringify(response)); + } + }) } }); \ No newline at end of file From 3ca0602aa93d7aca16c5c581b815207c81716f7f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 14 Aug 2014 15:49:57 +0800 Subject: [PATCH 0452/1564] Issue #5695: Update Facebook plugin 1. support app request 2. Compatibility adjustment --- external/pluginx/platform/facebook.js | 1 - 1 file changed, 1 deletion(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 240e5bfc1d..a58cf0ac69 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -103,7 +103,6 @@ plugin.extend('facebook', { * @param callback */ requestPermissions: function(permissions, callback){ - permissions.push("user_hometown"); var permissionsStr = permissions.join(','); var self = this; FB.login(function(response){ From 7478d02f50eae84374731d125c2a9ff9b2b8fbfa Mon Sep 17 00:00:00 2001 From: mutoo Date: Thu, 14 Aug 2014 16:57:57 +0800 Subject: [PATCH 0453/1564] fix CCBone color/opacity update issue; --- extensions/cocostudio/armature/CCBone.js | 2 ++ .../armature/utils/CCDataReaderHelper.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 9f3ce7d41c..62e22f604a 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -230,6 +230,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ updateDisplayedColor: function (color) { this._realColor = cc.color(255, 255, 255); cc.Node.prototype.updateDisplayedColor.call(this, color); + this.updateColor(); }, /** @@ -239,6 +240,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ updateDisplayedOpacity: function (opacity) { this._realOpacity = 255; cc.Node.prototype.updateDisplayedOpacity.call(this, opacity); + this.updateColor(); }, /** diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index aef9070849..86fe19aee6 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -770,15 +770,15 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ var alpha, red, green, blue; var alphaOffset, redOffset, greenOffset, blueOffset; - alpha = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA) || 0; - red = colorTransformXML.getAttribute(ccs.CONST_A_RED) || 0; - green = colorTransformXML.getAttribute(ccs.CONST_A_GREEN) || 0; - blue = colorTransformXML.getAttribute(ccs.CONST_A_BLUE) || 0; - - alphaOffset = colorTransformXML.getAttribute(ccs.CONST_A_ALPHA_OFFSET) || 0; - redOffset = colorTransformXML.getAttribute(ccs.CONST_A_RED_OFFSET) || 0; - greenOffset = colorTransformXML.getAttribute(ccs.CONST_A_GREEN_OFFSET) || 0; - blueOffset = colorTransformXML.getAttribute(ccs.CONST_A_BLUE_OFFSET) || 0; + alpha = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_ALPHA)) || 0; + red = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_RED)) || 0; + green = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_GREEN)) || 0; + blue = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_BLUE)) || 0; + + alphaOffset = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_ALPHA_OFFSET)) || 0; + redOffset = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_RED_OFFSET)) || 0; + greenOffset = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_GREEN_OFFSET)) || 0; + blueOffset = parseFloat(colorTransformXML.getAttribute(ccs.CONST_A_BLUE_OFFSET)) || 0; frameData.a = 2.55 * alphaOffset + alpha; frameData.r = 2.55 * redOffset + red; From b994d6a2483cca25b34e31b59c61a5dc311cb830 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 14 Aug 2014 20:07:38 +0800 Subject: [PATCH 0454/1564] Fixed a mistake of cc.AudioEngine that it can't stop a music when the music is loop --- cocos2d/audio/CCAudio.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index e7b53cc916..5b13a71f82 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -389,10 +389,9 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (audio.stop) {//cc.WebAudio audio.stop(); } else { + audio.pause(); if(audio.duration && audio.duration != Infinity) audio.currentTime = audio.duration; - else - audio.pause(); } return true; } @@ -1026,7 +1025,8 @@ cc._audioLoader = { }, _loadAudio: function (url, audio, cb, delFlag) { var _Audio; - if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") + //if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") + if (cc.sys.browserType == "firefox") _Audio = Audio; //The WebAudio of FireFox doesn't work after google closure compiler compiled with advanced mode else _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); From 696ac893c0dade966f7307dcc45e316c13289411 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 14 Aug 2014 20:11:09 +0800 Subject: [PATCH 0455/1564] Fixed a mistake of cc.AudioEngine that it can't stop a music when the music is loop --- cocos2d/audio/CCAudio.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 5b13a71f82..d1894c50e3 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -1025,8 +1025,7 @@ cc._audioLoader = { }, _loadAudio: function (url, audio, cb, delFlag) { var _Audio; - //if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") - if (cc.sys.browserType == "firefox") + if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") _Audio = Audio; //The WebAudio of FireFox doesn't work after google closure compiler compiled with advanced mode else _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); From e7d53d47005957c01c65a8d60e6d7cfbbfba3843 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 14 Aug 2014 21:31:38 +0800 Subject: [PATCH 0456/1564] Issue #5695: Update Facebook plugin 1. share open graph --- external/pluginx/platform/facebook.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index a58cf0ac69..694e8a20d1 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -183,17 +183,15 @@ plugin.extend('facebook', { info['name'] = info['site'] || info['name']; delete info['site']; - delete info['name']; info['href'] = info['siteUrl'] || info['link']; delete info['siteUrl']; delete info['link']; - info['picture'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; + info['image'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; delete info['imageUrl']; delete info['imagePath']; delete info['photo']; - delete info['image']; info['caption'] = info['title'] || info['caption']; @@ -205,9 +203,20 @@ plugin.extend('facebook', { if(info['method'] == 'share_open_graph' && info['url']){ if(info['url']){ - info['action_properties'] = JSON.stringify({ - object: info['url'] - }); + var obj = {}; + if(info["preview_property"]) + obj[info["preview_property"]] = info["url"]; + else + obj["object"] = info["url"]; + + for(var p in info){ + if(p != "method" && p != "action_type" && p != "action_properties"){ + info[p] && (obj[p] = info[p]); + delete info[p]; + } + } + + info['action_properties'] = JSON.stringify(obj); }else{ return; } @@ -226,6 +235,7 @@ plugin.extend('facebook', { return; } + console.log(info); FB.ui(info, function(response) { if (response) { From 3b3894ff70b821050a2de22343650899c8c9a00a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 14 Aug 2014 22:04:22 +0800 Subject: [PATCH 0457/1564] Issue #5695: Update Facebook plugin 1. share open graph --- external/pluginx/platform/facebook.js | 1 - 1 file changed, 1 deletion(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 694e8a20d1..a96a326029 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -235,7 +235,6 @@ plugin.extend('facebook', { return; } - console.log(info); FB.ui(info, function(response) { if (response) { From 76663f681c277c46d4afe2f882a1dd4106133115 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 14 Aug 2014 22:06:02 +0800 Subject: [PATCH 0458/1564] Add some state check to cc.AudioEngine --- cocos2d/audio/CCAudio.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index d1894c50e3..d18bcf05d1 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -357,7 +357,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ audio.stop(); } else { audio.pause(); - audio.currentTime = 0; + if (audio.readyState > 2) + audio.currentTime = 0; } } this._musicPlayState = 2; @@ -390,7 +391,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ audio.stop(); } else { audio.pause(); - if(audio.duration && audio.duration != Infinity) + if (audio.readyState > 2 && audio.duration && audio.duration != Infinity) audio.currentTime = audio.duration; } return true; @@ -500,7 +501,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ var eff = effList[i]; if (eff.ended) { audio = eff; - audio.currentTime = 0; + if (audio.readyState > 2) + audio.currentTime = 0; if (window.chrome) audio.load(); break; @@ -839,7 +841,8 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { var self = this, audio = self._effectCache4Single[url], locLoader = cc.loader, waitings = self._waitingEffIds, pauseds = self._pausedEffIds, effects = self._effects; if (audio) { - audio.currentTime = 0; //reset current time + if (audio.readyState > 2) + audio.currentTime = 0; //reset current time } else { audio = self._getAudioByUrl(url); if (!audio) return null; @@ -871,7 +874,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { return; for (var key in sglCache) { var eff = sglCache[key]; - if(eff.duration && eff.duration != Infinity) + if (eff.readyState > 2 && eff.duration && eff.duration != Infinity) eff.currentTime = eff.duration; } waitings.length = 0; @@ -881,7 +884,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { for (var i = 0, li = list.length; i < li; i++) { var eff = list[i]; eff.loop = false; - if(eff.duration && eff.duration != Infinity) + if (eff.readyState > 2 && eff.duration && eff.duration != Infinity) eff.currentTime = eff.duration; } } @@ -899,7 +902,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { else self._resumeAudio(currEffect); } else if (self._needToResumeMusic) { var currMusic = self._currMusic; - if (currMusic.duration && currMusic.duration != Infinity) {//calculate current time + if (currMusic.readyState > 2 && currMusic.duration && currMusic.duration != Infinity) {//calculate current time var temp = currMusic.currentTime + self._expendTime4Music; temp = temp - currMusic.duration * ((temp / currMusic.duration) | 0); currMusic.currentTime = temp; @@ -927,7 +930,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { if (eff._isToPlay || eff.loop || (eff.duration && eff.currentTime + expendTime < eff.duration)) { self._currEffectId = effId; self._currEffect = eff; - if (!eff._isToPlay && eff.duration && eff.duration != Infinity) { + if (!eff._isToPlay && eff.readyState > 2 && eff.duration && eff.duration != Infinity) { var temp = eff.currentTime + expendTime; temp = temp - eff.duration * ((temp / eff.duration) | 0); eff.currentTime = temp; @@ -935,7 +938,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { eff._isToPlay = false; return eff; } else { - if(eff.duration && eff.duration != Infinity) + if (eff.readyState > 2 && eff.duration && eff.duration != Infinity) eff.currentTime = eff.duration; } } @@ -1025,7 +1028,8 @@ cc._audioLoader = { }, _loadAudio: function (url, audio, cb, delFlag) { var _Audio; - if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") + //if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") + if (cc.sys.browserType == "firefox") _Audio = Audio; //The WebAudio of FireFox doesn't work after google closure compiler compiled with advanced mode else _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); From 8b1ec61394890fefec734e1de87aeb92d0e3a2ca Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 14 Aug 2014 22:08:47 +0800 Subject: [PATCH 0459/1564] Add some state check to cc.AudioEngine --- cocos2d/audio/CCAudio.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index d18bcf05d1..e14e599cc9 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -1028,8 +1028,7 @@ cc._audioLoader = { }, _loadAudio: function (url, audio, cb, delFlag) { var _Audio; - //if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") - if (cc.sys.browserType == "firefox") + if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") _Audio = Audio; //The WebAudio of FireFox doesn't work after google closure compiler compiled with advanced mode else _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); From 36d95e430e0a0bd489ba37b40df0053d1ffac043 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 15 Aug 2014 11:34:55 +0800 Subject: [PATCH 0460/1564] Closed #5813: Refactor sprite's blendFunc to support more features on Canvas --- cocos2d/core/layers/CCLayer.js | 35 +++++++++++++++------ cocos2d/core/sprites/CCSprite.js | 38 +++++++++++++++-------- cocos2d/progress-timer/CCProgressTimer.js | 4 +-- cocos2d/render-texture/CCRenderTexture.js | 7 ++++- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index f7896579d7..18f8ffd0d3 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -277,7 +277,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ this._updateColor(); }, - _isLighterMode: false, + _blendFuncStr: "source", /** * Constructor of cc.LayerColor * @function @@ -327,13 +327,28 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ * @param {Number} dst */ setBlendFunc: function (src, dst) { - var _t = this; - if (dst === undefined) - _t._blendFunc = src; - else - _t._blendFunc = {src: src, dst: dst}; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) - _t._isLighterMode = (_t._blendFunc && (_t._blendFunc.src == 1) && (_t._blendFunc.dst == 771)); + var _t = this, locBlendFunc = this._blendFunc; + if (dst === undefined) { + locBlendFunc.src = src.src; + locBlendFunc.dst = src.dst; + } else { + locBlendFunc.src = src; + locBlendFunc.dst = dst; + } + if (cc._renderType === cc._RENDER_TYPE_CANVAS){ + if(!locBlendFunc){ + _t._blendFuncStr = "source"; + }else{ + if(( locBlendFunc.src == cc.SRC_ALPHA && locBlendFunc.dst == cc.ONE) || (locBlendFunc.src == cc.ONE && locBlendFunc.dst == cc.ONE)) + _t._blendFuncStr = "lighter"; + else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.SRC_ALPHA) + _t._blendFuncStr = "destination-in"; + else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) + _t._blendFuncStr = "destination-out"; + else + _t._blendFuncStr = "source"; + } + } }, _setWidth: null, @@ -748,8 +763,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _p = cc.LayerGradient.prototype; _p.draw = function (ctx) { var context = ctx || cc._renderContext, _t = this; - if (_t._isLighterMode) - context.globalCompositeOperation = 'lighter'; + if (_t._blendFuncStr != "source") + context.globalCompositeOperation = _t._blendFuncStr; context.save(); var opacityf = _t._displayedOpacity / 255.0; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 131f9f3fd1..09ea2e70a3 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -756,14 +756,14 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ return this._texture; }, - _quad:null, // vertex coords, texture coords and color info - _quadWebBuffer:null, - _quadDirty:false, - _colorized:false, - _isLighterMode:false, - _originalTexture:null, - _textureRect_Canvas:null, - _drawSize_Canvas:null, + _quad: null, // vertex coords, texture coords and color info + _quadWebBuffer: null, + _quadDirty: false, + _colorized: false, + _blendFuncStr: "source", + _originalTexture: null, + _textureRect_Canvas: null, + _drawSize_Canvas: null, /** * Constructor @@ -1235,7 +1235,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; _p.setBlendFunc = function (src, dst) { - var locBlendFunc = this._blendFunc; + var _t = this, locBlendFunc = this._blendFunc; if (dst === undefined) { locBlendFunc.src = src.src; locBlendFunc.dst = src.dst; @@ -1243,8 +1243,20 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locBlendFunc.src = src; locBlendFunc.dst = dst; } - this._isLighterMode = (locBlendFunc && - (( locBlendFunc.src == cc.SRC_ALPHA && locBlendFunc.dst == cc.ONE) || (locBlendFunc.src == cc.ONE && locBlendFunc.dst == cc.ONE))); + if (cc._renderType === cc._RENDER_TYPE_CANVAS){ + if(!locBlendFunc){ + _t._blendFuncStr = "source"; + }else{ + if(( locBlendFunc.src == cc.SRC_ALPHA && locBlendFunc.dst == cc.ONE) || (locBlendFunc.src == cc.ONE && locBlendFunc.dst == cc.ONE)) + _t._blendFuncStr = "lighter"; + else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.SRC_ALPHA) + _t._blendFuncStr = "destination-in"; + else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) + _t._blendFuncStr = "destination-out"; + else + _t._blendFuncStr = "source"; + } + } }; _p.init = function () { @@ -1580,8 +1592,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; var context = ctx || cc._renderContext; - if (_t._isLighterMode) - context.globalCompositeOperation = 'lighter'; + if (_t._blendFuncStr != "source") + context.globalCompositeOperation = _t._blendFuncStr; var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 0b8800e7fa..12ec6cc597 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -425,8 +425,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ var context = ctx || cc._renderContext; var locSprite = this._sprite; - if (locSprite._isLighterMode) - context.globalCompositeOperation = 'lighter'; + if (locSprite._blendFuncStr != "source") + context.globalCompositeOperation = locSprite._blendFuncStr; var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index c50883d72f..d5f984655b 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -393,7 +393,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ depthValue = depthValue || gl.COLOR_BUFFER_BIT; stencilValue = stencilValue || (gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - this._beginWithClear(r / 255, g / 255, b / 255, a / 255, depthValue, stencilValue, (gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)); + this._beginWithClear(r , g , b , a , depthValue, stencilValue, (gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)); }, _beginWithClear: null, @@ -417,6 +417,11 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, _beginWithClearForWebGL: function (r, g, b, a, depthValue, stencilValue, flags) { + r = r / 255; + g = g / 255; + b = b / 255; + a = a / 255; + this.begin(); var gl = cc._renderContext; From cc45939984c0a78ad0714952bf434f96a2a2bdc6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 15 Aug 2014 11:37:37 +0800 Subject: [PATCH 0461/1564] Issue #5695: Update Facebook plugin --- external/pluginx/platform/facebook.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index a96a326029..defd45b199 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -106,11 +106,11 @@ plugin.extend('facebook', { var permissionsStr = permissions.join(','); var self = this; FB.login(function(response){ - console.log(response) if (response.authResponse) { + var permissList = response.authResponse['grantedScopes'].split(","); //save user info self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0, JSON.stringify(response)); + typeof callback === 'function' && callback(0, JSON.stringify(permissList)); } else { typeof callback === 'function' && callback(1, JSON.stringify(response)); } From 87ecf7b62316ee62a550da8265ad632e137fffa3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 15 Aug 2014 11:44:02 +0800 Subject: [PATCH 0462/1564] Issue #5695: Update Facebook plugin --- external/pluginx/platform/facebook.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index defd45b199..64208c9018 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -54,9 +54,9 @@ plugin.extend('facebook', { if (response.authResponse) { //save user info self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0, JSON.stringify(response)); + typeof callback === 'function' && callback(0, "login success"); } else { - typeof callback === 'function' && callback(1, JSON.stringify(response)); + typeof callback === 'function' && callback(1, "login failed"); } }, { scope: '' }); }, @@ -75,9 +75,9 @@ plugin.extend('facebook', { if (response && response.status === 'connected') { //login - save user info self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0, JSON.stringify(response)); + typeof callback === 'function' && callback(0, "logged in"); }else{ - typeof callback === 'function' && callback(1, JSON.stringify(response)); + typeof callback === 'function' && callback(1, "logged out"); } }); }, @@ -91,9 +91,9 @@ plugin.extend('facebook', { if(response.authResponse){ // user is now logged out self.userInfo = {}; - typeof callback === 'function' && callback(0, JSON.stringify(response)); + typeof callback === 'function' && callback(0, "logout success"); }else{ - typeof callback === 'function' && callback(1, JSON.stringify(response)); + typeof callback === 'function' && callback(1, "logout failed"); } }); }, @@ -112,7 +112,7 @@ plugin.extend('facebook', { self.userInfo = response.authResponse; typeof callback === 'function' && callback(0, JSON.stringify(permissList)); } else { - typeof callback === 'function' && callback(1, JSON.stringify(response)); + typeof callback === 'function' && callback(1, "request failed"); } }, { scope: permissionsStr, @@ -241,9 +241,9 @@ plugin.extend('facebook', { if(response.post_id) typeof callback === 'function' && callback(0, JSON.stringify(response)); else - typeof callback === 'function' && callback(response.error_code, JSON.stringify(response)); + typeof callback === 'function' && callback(response.error_code, response.error_message); } else { - typeof callback === 'function' && callback(1, JSON.stringify(response)); + typeof callback === 'function' && callback(1, "Unknow error"); } }); }, From 3c178198b5d4905e858b3f9d7c8d42e7812d8db2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 15 Aug 2014 14:04:38 +0800 Subject: [PATCH 0463/1564] Closed #5813: refactor code of cc.Sprite.setBlendFunc and cc.LayerColor.setBlendFunc --- cocos2d/core/layers/CCLayer.js | 16 ++-------------- cocos2d/core/sprites/CCSprite.js | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 18f8ffd0d3..5c93cb343d 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -335,20 +335,8 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ locBlendFunc.src = src; locBlendFunc.dst = dst; } - if (cc._renderType === cc._RENDER_TYPE_CANVAS){ - if(!locBlendFunc){ - _t._blendFuncStr = "source"; - }else{ - if(( locBlendFunc.src == cc.SRC_ALPHA && locBlendFunc.dst == cc.ONE) || (locBlendFunc.src == cc.ONE && locBlendFunc.dst == cc.ONE)) - _t._blendFuncStr = "lighter"; - else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.SRC_ALPHA) - _t._blendFuncStr = "destination-in"; - else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) - _t._blendFuncStr = "destination-out"; - else - _t._blendFuncStr = "source"; - } - } + if (cc._renderType === cc._RENDER_TYPE_CANVAS) + _t._blendFuncStr = cc._getCompositeOperationByBlendFunc(locBlendFunc); }, _setWidth: null, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 09ea2e70a3..9b2eeb30bc 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -226,6 +226,21 @@ cc.cutRotateImageToCanvas = function (texture, rect) { return nCanvas; }; +cc._getCompositeOperationByBlendFunc = function(blendFunc){ + if(!blendFunc) + return "source"; + else{ + if(( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) + return "lighter"; + else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) + return "destination-in"; + else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) + return "destination-out"; + else + return "source"; + } +}; + /** *

    cc.Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
    * @@ -1243,20 +1258,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locBlendFunc.src = src; locBlendFunc.dst = dst; } - if (cc._renderType === cc._RENDER_TYPE_CANVAS){ - if(!locBlendFunc){ - _t._blendFuncStr = "source"; - }else{ - if(( locBlendFunc.src == cc.SRC_ALPHA && locBlendFunc.dst == cc.ONE) || (locBlendFunc.src == cc.ONE && locBlendFunc.dst == cc.ONE)) - _t._blendFuncStr = "lighter"; - else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.SRC_ALPHA) - _t._blendFuncStr = "destination-in"; - else if(locBlendFunc.src == cc.ZERO && locBlendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) - _t._blendFuncStr = "destination-out"; - else - _t._blendFuncStr = "source"; - } - } + if (cc._renderType === cc._RENDER_TYPE_CANVAS) + _t._blendFuncStr = cc._getCompositeOperationByBlendFunc(locBlendFunc); }; _p.init = function () { From f1bb7fb3d4b458fa9ff7ac77f878c632897ac9c8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 15 Aug 2014 14:38:09 +0800 Subject: [PATCH 0464/1564] Issue #5815: EditBox and CCScale9Sprite Performance of dislocation CCScale9Sprite splicing seam. EditBox IOS dislocation. --- extensions/editbox/CCEditBox.js | 1 + .../gui/control-extension/CCScale9Sprite.js | 96 +++++++++---------- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 535b7c0690..97e54eb089 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -254,6 +254,7 @@ cc.EditBox = cc.ControlButton.extend({ tmpEdTxt.style.height = "100%"; tmpEdTxt.style.active = 0; tmpEdTxt.style.outline = "medium"; + tmpEdTxt.style.padding = "0"; var onCanvasClick = function() { tmpEdTxt.blur(); }; diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index fc9d2373ac..2e7add991c 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -114,11 +114,11 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ insets = cc.rect(0, 0, 0, 0); } else { insets = this._spriteFrameRotated ? cc.rect(locInsetBottom, locInsetLeft, - locSpriteRect.width - locInsetRight - locInsetLeft, - locSpriteRect.height - locInsetTop - locInsetBottom) : + locSpriteRect.width - locInsetRight - locInsetLeft, + locSpriteRect.height - locInsetTop - locInsetBottom) : cc.rect(locInsetLeft, locInsetTop, - locSpriteRect.width - locInsetLeft - locInsetRight, - locSpriteRect.height - locInsetTop - locInsetBottom); + locSpriteRect.width - locInsetLeft - locInsetRight, + locSpriteRect.height - locInsetTop - locInsetBottom); } this.setCapInsets(insets); }, @@ -180,22 +180,22 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Position corners locBottomLeft.setPosition(0, 0); - locBottomRight.setPosition(leftWidth + rescaledWidth, 0); - locTopLeft.setPosition(0, bottomHeight + rescaledHeight); - locTopRight.setPosition(leftWidth + rescaledWidth, bottomHeight + rescaledHeight); + locBottomRight.setPosition( (leftWidth + rescaledWidth) + 0.5 | 0, 0); + locTopLeft.setPosition(0, (bottomHeight + rescaledHeight) + 0.5 | 0); + locTopRight.setPosition( (leftWidth + rescaledWidth) + 0.5 | 0, (bottomHeight + rescaledHeight) + 0.5 | 0); // Scale and position borders - locLeft.setPosition(0, bottomHeight); + locLeft.setPosition(0, (bottomHeight) + 0.5 | 0); locLeft.setScaleY(verticalScale); - locRight.setPosition(leftWidth + rescaledWidth, bottomHeight); + locRight.setPosition( (leftWidth + rescaledWidth) + 0.5 | 0, (bottomHeight) + 0.5 | 0); locRight.setScaleY(verticalScale); - locBottom.setPosition(leftWidth, 0); + locBottom.setPosition( (leftWidth) + 0.5 | 0, 0); locBottom.setScaleX(horizontalScale); - locTop.setPosition(leftWidth, bottomHeight + rescaledHeight); + locTop.setPosition( (leftWidth) + 0.5 | 0, (bottomHeight + rescaledHeight) + 0.5 | 0); locTop.setScaleX(horizontalScale); // Position centre - locCenter.setPosition(leftWidth, bottomHeight); + locCenter.setPosition( (leftWidth) + 0.5 | 0, (bottomHeight) + 0.5 | 0); }, /** @@ -239,24 +239,24 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ getPreferredSize: function () { return this._preferredSize; }, - _getPreferredWidth: function () { - return this._preferredSize.width; - }, - _getPreferredHeight: function () { - return this._preferredSize.height; - }, + _getPreferredWidth: function () { + return this._preferredSize.width; + }, + _getPreferredHeight: function () { + return this._preferredSize.height; + }, setPreferredSize: function (preferredSize) { this.setContentSize(preferredSize); this._preferredSize = preferredSize; }, - _setPreferredWidth: function (value) { - this._setWidth(value); - this._preferredSize.width = value; - }, - _setPreferredHeight: function (value) { - this._setHeight(value); - this._preferredSize.height = value; - }, + _setPreferredWidth: function (value) { + this._setWidth(value); + this._preferredSize.width = value; + }, + _setPreferredHeight: function (value) { + this._setHeight(value); + this._preferredSize.height = value; + }, /** Opacity: conforms to CCRGBAProtocol protocol */ setOpacity: function (opacity) { @@ -311,12 +311,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if( cc._renderType === cc._RENDER_TYPE_CANVAS && ( - parentColor.r !== 255 || - parentColor.g !== 255 || - parentColor.b !== 255 + parentColor.r !== 255 || + parentColor.g !== 255 || + parentColor.b !== 255 ) - ){ + ){ selChild._changeTextureColor(); selChild._setNodeDirtyForCache(); } @@ -413,19 +413,19 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * @param {Number} [height] The untransformed size's height of the Scale9Sprite. */ setContentSize: function (size, height) { - cc.Node.prototype.setContentSize.call(this, size, height); + cc.Node.prototype.setContentSize.call(this, size, height); this._positionsAreDirty = true; }, - _setWidth: function (value) { - cc.Node.prototype._setWidth.call(this, value); - this._positionsAreDirty = true; - }, + _setWidth: function (value) { + cc.Node.prototype._setWidth.call(this, value); + this._positionsAreDirty = true; + }, - _setHeight: function (value) { - cc.Node.prototype._setHeight.call(this, value); - this._positionsAreDirty = true; - }, + _setHeight: function (value) { + cc.Node.prototype._setHeight.call(this, value); + this._positionsAreDirty = true; + }, visit: function (ctx) { if (this._positionsAreDirty) { @@ -700,15 +700,15 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var x = 0.0, y = 0.0; // top left - var lefttopbounds = cc.rect(x, y, left_w, top_h); + var lefttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, top_h + 0.5 | 0); // top center x += left_w; - var centertopbounds = cc.rect(x, y, center_w, top_h); + var centertopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, top_h + 0.5 | 0); // top right x += center_w; - var righttopbounds = cc.rect(x, y, right_w, top_h); + var righttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, top_h + 0.5 | 0); // ... center row x = 0.0; @@ -716,15 +716,15 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ y += top_h; // center left - var leftcenterbounds = cc.rect(x, y, left_w, center_h); + var leftcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, center_h + 0.5 | 0); // center center x += left_w; - var centerbounds = cc.rect(x, y, center_w, center_h); + var centerbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, center_h + 0.5 | 0); // center right x += center_w; - var rightcenterbounds = cc.rect(x, y, right_w, center_h); + var rightcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, center_h + 0.5 | 0); // ... bottom row x = 0.0; @@ -733,15 +733,15 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ y += center_h; // bottom left - var leftbottombounds = cc.rect(x, y, left_w, bottom_h); + var leftbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, bottom_h + 0.5 | 0); // bottom center x += left_w; - var centerbottombounds = cc.rect(x, y, center_w, bottom_h); + var centerbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, bottom_h + 0.5 | 0); // bottom right x += center_w; - var rightbottombounds = cc.rect(x, y, right_w, bottom_h); + var rightbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, bottom_h + 0.5 | 0); var t = cc.affineTransformMakeIdentity(); if (!rotated) { From 8f08777788568a7b0addce64e0f906fc3b2862e1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 15 Aug 2014 16:50:34 +0800 Subject: [PATCH 0465/1564] Closed #5811: cc.Armature supports setting shader program --- extensions/cocostudio/armature/CCArmature.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index fc5753e7ae..4c9a79a095 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -146,7 +146,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.animation.setAnimationData(animationData); } if (cc._renderType === cc._RENDER_TYPE_WEBGL) - this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR)); + this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); this.setCascadeOpacityEnabled(true); this.setCascadeColorEnabled(true); @@ -367,6 +367,9 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (null == node) continue; + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + node.setShaderProgram(this._shaderProgram); + switch (selBone.getDisplayRenderNodeType()) { case ccs.DISPLAY_TYPE_SPRITE: if(node instanceof ccs.Skin){ From eec6c4003f922a2c168ff107d46d9295799c74b6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 15 Aug 2014 16:57:46 +0800 Subject: [PATCH 0466/1564] Issue #5816: CCScale9Sprite and CCSprite texture error 1. Update failed of texture, When the resource is not loaded and reload Texture 2. Resources exist, but not loaded, the use of second elements will not be updated bug --- cocos2d/core/sprites/CCSprite.js | 3 ++ .../gui/control-extension/CCScale9Sprite.js | 30 ++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 131f9f3fd1..447df3e933 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1329,7 +1329,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._rect.width = rect.width; _t._rect.height = rect.height; } + if(_t.texture) + _t.texture.removeLoadedEventListener(_t); texture.addLoadedEventListener(_t._textureLoadedCallback, _t); + _t.texture = texture; return true; } diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 2e7add991c..6366479090 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -490,21 +490,23 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var texture = cc.textureCache.textureForKey(file); if (!texture) { texture = cc.textureCache.addImage(file); - var locLoaded = texture.isLoaded(); - this._textureLoaded = locLoaded; - if(!locLoaded){ - texture.addLoadedEventListener(function(sender){ - // the texture is rotated on Canvas render mode, so isRotated always is false. - var preferredSize = this._preferredSize; - preferredSize = cc.size(preferredSize.width, preferredSize.height); - var size = sender.getContentSize(); - this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets); - this.setPreferredSize(preferredSize); - this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); - }, this); - } } + + var locLoaded = texture.isLoaded(); + this._textureLoaded = locLoaded; + if(!locLoaded){ + texture.addLoadedEventListener(function(sender){ + // the texture is rotated on Canvas render mode, so isRotated always is false. + var preferredSize = this._preferredSize; + preferredSize = cc.size(preferredSize.width, preferredSize.height); + var size = sender.getContentSize(); + this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets); + this.setPreferredSize(preferredSize); + this._positionsAreDirty = true; + this._callLoadedEventCallbacks(); + }, this); + } + return this.initWithBatchNode(cc.SpriteBatchNode.create(file, 9), rect, false, capInsets); }, From 3828521b4ab210c7a1c193ad1445d97121cbb9e2 Mon Sep 17 00:00:00 2001 From: mutoo Date: Sat, 16 Aug 2014 10:34:11 +0800 Subject: [PATCH 0467/1564] fix child armature setSpeedScale issue; --- .../cocostudio/armature/animation/CCArmatureAnimation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index decbb1632a..89a58e4b3f 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -181,7 +181,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# var bone = dict[key]; bone.getTween().setProcessScale(this._processScale); if (bone.getChildArmature()) - bone.getChildArmature().getAnimation().setProcessScale(this._processScale); + bone.getChildArmature().getAnimation().setSpeedScale(this._processScale); } }, @@ -252,7 +252,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# tween.setProcessScale(this._processScale); if (bone.getChildArmature()) - bone.getChildArmature().getAnimation().setProcessScale(this._processScale); + bone.getChildArmature().getAnimation().setSpeedScale(this._processScale); } else { if(!bone.isIgnoreMovementBoneData()){ //! this bone is not include in this movement, so hide it From a595113bdca1d68ef653fb7e60bdbcbbb4bca217 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 18 Aug 2014 10:43:58 +0800 Subject: [PATCH 0468/1564] Issue #5815: EditBox will create repeat the outer div when switching scene Create EditBox and runScene, switch back, You will find two div of id was EGLViewDiv --- extensions/editbox/CCdomNode.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index bf77114484..555e872ea6 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -490,8 +490,11 @@ cc.DOM.parentDOM = function (x) { }; cc.DOM._createEGLViewDiv = function(p){ - var eglViewDiv = cc.$new("div"); - eglViewDiv.id = "EGLViewDiv"; + var eglViewDiv = cc.$("#EGLViewDiv"); + if(!eglViewDiv){ + eglViewDiv = cc.$new("div"); + eglViewDiv.id = "EGLViewDiv"; + } var eglViewer = cc.view; var designSize = eglViewer.getDesignResolutionSize(); From 1ec1426188ed8b7b622b4abaf617b3bf8e4ddeec Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 18 Aug 2014 11:46:16 +0800 Subject: [PATCH 0469/1564] Fixed #5811: cc.Armature supports setting shader program --- extensions/cocostudio/armature/CCArmature.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 4c9a79a095..540bed7164 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -361,7 +361,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; for (var i = 0, len = locChildren.length; i< len; i++) { var selBone = locChildren[i]; - if (selBone) { + if (selBone && selBone.getDisplayRenderNode) { var node = selBone.getDisplayRenderNode(); if (null == node) @@ -400,6 +400,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ break; } } else if(selBone instanceof cc.Node) { + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + selBone.setShaderProgram(this._shaderProgram); selBone.visit(ctx); // CC_NODE_DRAW_SETUP(); } From 48c8a20f96e5c6748836f7a2a06fd7b9e52b8fb3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 18 Aug 2014 13:48:16 +0800 Subject: [PATCH 0470/1564] Issue #2107: LoadingBar setPercent is invalid. 1. setPercent is invalid when _scale9Enabled is true. 2. setPercent is invalid when setContentSize after setPercent --- extensions/ccui/uiwidgets/UILoadingBar.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index a67449e1fe..31f53f67c7 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -248,9 +248,9 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ setPercent: function (percent) { if (percent < 0 || percent > 100) return; + this._percent = percent; if (this._totalLength <= 0) return; - this._percent = percent; var res = this._percent / 100.0; if (this._scale9Enabled) @@ -270,6 +270,12 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } }, + setContentSize: function(contentSize, height){ + ccui.Widget.prototype.setContentSize.call(this, contentSize, height); + var locWidth = (height === undefined) ? contentSize.width : contentSize; + this._totalLength = locWidth; + }, + /** * Gets the progress direction of LoadingBar. * @returns {number} percent value from 1 to 100. From 518434b5f8c106501d06866d143322f269dfa194 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 18 Aug 2014 18:30:08 +0800 Subject: [PATCH 0471/1564] Fixed a bug of Armature reader that its isTween is incorrect. --- extensions/cocostudio/armature/utils/CCDataReaderHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 86fe19aee6..f2908d4320 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -685,7 +685,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ frameData.soundEffect = frameData.strSoundEffect; var isTween = frameXML.getAttribute(ccs.CONST_A_TWEEN_FRAME); - frameData.isTween = isTween == undefined?true: Boolean(isTween); + frameData.isTween = !(isTween != undefined && isTween == "false"); if (dataInfo.flashToolVersion >= ccs.CONST_VERSION_2_0) { x = frameXML.getAttribute(ccs.CONST_A_COCOS2DX_X); From a8739051143dc2850c746b6c50d4aa3a53961526 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 19 Aug 2014 10:38:31 +0800 Subject: [PATCH 0472/1564] Fixed #2114: fixed a bug of cc.pool and remove an incorrect define --- cocos2d/core/platform/CCMacro.js | 6 ------ extensions/ccpool/CCPool.js | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index f7b56c4200..0931ee61d7 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -398,12 +398,6 @@ cc.ONE_MINUS_SRC_COLOR = 0x301; */ cc.ONE_MINUS_DST_ALPHA = 0x305; -/** - * @constant - * @type Number - */ -cc.DST_COLOR = 0x0307; - /** * @constant * @type Number diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index cfd3310870..30cd4f9a3c 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -61,7 +61,8 @@ cc.pool = /** @lends cc.pool# */{ if (!this._pool[pid]) { this._pool[pid] = []; } - obj.unuse(); + if(obj.unuse) + obj.unuse(); //define by user. use to initialize the state of objects. obj.retain();//use for jsb this._pool[pid].push(obj); } @@ -75,10 +76,7 @@ cc.pool = /** @lends cc.pool# */{ hasObj: function (objClass) { var pid = objClass.prototype.__pid; var list = this._pool[pid]; - if (!list || list.length == 0) { - return false; - } - return true; + return (list && list.length > 0); }, /** @@ -92,7 +90,7 @@ cc.pool = /** @lends cc.pool# */{ if (list) { for (var i = 0; i < list.length; i++) { if (obj === list[i]) { - obj.release()//use for jsb + obj.release(); //use for jsb list.splice(i, 1); } } @@ -112,7 +110,8 @@ cc.pool = /** @lends cc.pool# */{ var args = Array.prototype.slice.call(arguments); args.shift(); var obj = list.pop(); - obj.reuse.apply(obj, args); + if(obj.reuse) + obj.reuse.apply(obj, args); //define by user. return obj; } }, @@ -121,10 +120,12 @@ cc.pool = /** @lends cc.pool# */{ * remove all objs in pool and reset the pool */ drainAllPools: function () { - for (var i in this._pool) { - for (var j = 0; j < this._pool[i].length; j++) { - var obj = this._pool[i][j]; - obj.release() + var locPool = this._pool; + for (var selKey in locPool) { + for (var j = 0; j < locPool[selKey].length; j++) { + var obj = locPool[selKey][j]; + if(obj && obj.release) + obj.release() } } this._pool = {}; From e41a7afab636ddda9f5ae67e80bc4ad540d21318 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 19 Aug 2014 13:36:45 +0800 Subject: [PATCH 0473/1564] Closed #5819: Sync some function name for JSB --- CCDebugger.js | 1 + cocos2d/core/textures/CCTextureCache.js | 14 ++++++++++++++ cocos2d/tilemap/CCTMXTiledMap.js | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/CCDebugger.js b/CCDebugger.js index 6990dcfe01..5bb6357bc1 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -190,6 +190,7 @@ cc._LogInfos = { textureCache_addPVRTCImage: "TextureCache:addPVRTCImage does not support on HTML5", textureCache_addETCImage: "TextureCache:addPVRTCImage does not support on HTML5", + textureCache_textureForKey: "textureForKey is deprecated. Please use getTextureForKey instead.", textureCache_addPVRImage: "addPVRImage does not support on HTML5", textureCache_addUIImage: "cocos2d: Couldn't add UIImage in TextureCache", textureCache_dumpCachedTextureInfo: "cocos2d: '%s' id=%s %s x %s", diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index a04b3dbc1e..878789dc74 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -90,11 +90,25 @@ cc.textureCache = /** @lends cc.textureCache# */{ * Returns an already created texture. Returns null if the texture doesn't exist. * @param {String} textureKeyName * @return {cc.Texture2D|Null} + * @deprecated * @example * //example * var key = cc.textureCache.textureForKey("hello.png"); */ textureForKey: function (textureKeyName) { + cc.log(cc._LogInfos.textureCache_textureForKey); + return this.getTextureForKey(textureKeyName); + }, + + /** + * Returns an already created texture. Returns null if the texture doesn't exist. + * @param {String} textureKeyName + * @return {cc.Texture2D|Null} + * @example + * //example + * var key = cc.textureCache.getTextureForKey("hello.png"); + */ + getTextureForKey: function(textureKeyName){ return this._textures[textureKeyName] || this._textures[cc.loader._aliases[textureKeyName]]; }, diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index 6acb29b6cf..9fdda77a0c 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -371,8 +371,19 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ * Return properties dictionary for tile GID * @param {Number} GID * @return {object} + * @deprecated */ propertiesForGID:function (GID) { + cc.log("propertiesForGID is deprecated. Please use getPropertiesForGID instead."); + return this.getPropertiesForGID[GID]; + }, + + /** + * Return properties dictionary for tile GID + * @param {Number} GID + * @return {object} + */ + getPropertiesForGID: function(GID) { return this._tileProperties[GID]; }, From 4f62382e23e385e375f0d358a9c74ad4c3e981fa Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 19 Aug 2014 14:38:45 +0800 Subject: [PATCH 0474/1564] Fixed #5820: pageView.getTouchBeganPosition() error PageView cannot correctly obtain the touch point when open TouchEnabled of Inside element --- extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 053bf04dfd..3a8eb1052f 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -418,8 +418,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var touchPoint = touch.getLocation(); switch (handleState) { case ccui.Widget.TOUCH_BEGAN: + this._touchBeganPosition.x = touchPoint.x; + this._touchBeganPosition.y = touchPoint.y; break; case ccui.Widget.TOUCH_MOVED: + this._touchMovePosition.x = touchPoint.x; + this._touchMovePosition.y = touchPoint.y; var offset = 0; offset = Math.abs(sender.getTouchBeganPosition().x - touchPoint.x); if (offset > this._childFocusCancelOffset) { @@ -428,6 +432,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } break; case ccui.Widget.TOUCH_ENDED: + this._touchEndPosition.x = touchPoint.x; + this._touchEndPosition.y = touchPoint.y; case ccui.Widget.TOUCH_CANCELED: this._handleReleaseLogic(touch); break; From 50ed791efbf36fd2eee0db1eb5128ec39ee8f86c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 19 Aug 2014 15:21:48 +0800 Subject: [PATCH 0475/1564] Replace some function callings from deprecated to new function name. --- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 8 ++++---- cocos2d/particle/CCParticleSystem.js | 4 ++-- extensions/gui/control-extension/CCScale9Sprite.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index a25ac00a19..f159d83017 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -861,7 +861,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ initWithFile:function (filename, rect) { cc.assert(filename, cc._LogInfos.Sprite_initWithFile); - var tex = cc.textureCache.textureForKey(filename); + var tex = cc.textureCache.getTextureForKey(filename); if (!tex) { tex = cc.textureCache.addImage(filename); return this.initWithTexture(tex, rect || cc.rect(0, 0, tex._contentSize.width, tex._contentSize.height)); diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index f2917ebf8d..717436f2ca 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -144,7 +144,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @return {Boolean} */ initWithFile: function (fileImage, capacity) { - var texture2D = cc.textureCache.textureForKey(fileImage); + var texture2D = cc.textureCache.getTextureForKey(fileImage); if (!texture2D) texture2D = cc.textureCache.addImage(fileImage); return this.initWithTexture(texture2D, capacity); @@ -165,7 +165,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @return {Boolean} */ init: function (fileImage, capacity) { - var texture2D = cc.textureCache.textureForKey(fileImage); + var texture2D = cc.textureCache.getTextureForKey(fileImage); if (!texture2D) texture2D = cc.textureCache.addImage(fileImage); return this.initWithTexture(texture2D, capacity); @@ -405,7 +405,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ var texture2D; capacity = capacity || cc.DEFAULT_SPRITE_BATCH_CAPACITY; if (typeof(fileImage) == "string") { - texture2D = cc.textureCache.textureForKey(fileImage); + texture2D = cc.textureCache.getTextureForKey(fileImage); if (!texture2D) texture2D = cc.textureCache.addImage(fileImage); } @@ -422,7 +422,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ var texture2D; capacity = capacity || cc.DEFAULT_SPRITE_BATCH_CAPACITY; if (typeof(fileImage) == "string") { - texture2D = cc.textureCache.textureForKey(fileImage); + texture2D = cc.textureCache.getTextureForKey(fileImage); if (!texture2D) texture2D = cc.textureCache.addImage(fileImage); } diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index e58c2e56bf..59d20a4141 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1601,7 +1601,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // Try to get the texture from the cache var textureName = locValueForKey("textureFileName", dictionary); var imgPath = cc.path.changeBasename(this._plistFile, textureName); - var tex = cc.textureCache.textureForKey(imgPath); + var tex = cc.textureCache.getTextureForKey(imgPath); if (tex) { this.setTexture(tex); @@ -1638,7 +1638,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ cc.textureCache.cacheImage(imgPath, canvasObj); - var addTexture = cc.textureCache.textureForKey(imgPath); + var addTexture = cc.textureCache.getTextureForKey(imgPath); if(!addTexture) cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture"); this.setTexture(addTexture); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 6366479090..6896e42102 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -487,7 +487,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if(!file) throw "cc.Scale9Sprite.initWithFile(): file should be non-null"; - var texture = cc.textureCache.textureForKey(file); + var texture = cc.textureCache.getTextureForKey(file); if (!texture) { texture = cc.textureCache.addImage(file); } From d1c51dd28c17080f0f45ad2b4999a126de1463d5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 19 Aug 2014 16:30:15 +0800 Subject: [PATCH 0476/1564] Fixed #5822: ImageView setColor error setColor error after setScale9Enabled. --- .../gui/control-extension/CCScale9Sprite.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 6366479090..895f07ae46 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -309,16 +309,17 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if (selChild){ cc.Node.prototype.updateDisplayedColor.call(selChild, parentColor); - if( - cc._renderType === cc._RENDER_TYPE_CANVAS && ( - parentColor.r !== 255 || - parentColor.g !== 255 || - parentColor.b !== 255 - - ) + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + if( + parentColor.r !== 255 || + parentColor.g !== 255 || + parentColor.b !== 255 ){ - selChild._changeTextureColor(); - selChild._setNodeDirtyForCache(); + selChild._changeTextureColor(); + selChild._setNodeDirtyForCache(); + } + }else{ + selChild.updateDisplayedColor(parentColor); } } } From 1054867a4879b8dba296b373a2c2220e14be485e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 19 Aug 2014 16:38:33 +0800 Subject: [PATCH 0477/1564] Fixed #5822: ImageView setColor error move cc.Node.prototype.updateDisplayedColor --- extensions/gui/control-extension/CCScale9Sprite.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 895f07ae46..372dbcccc3 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -307,9 +307,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; if (selChild){ - cc.Node.prototype.updateDisplayedColor.call(selChild, parentColor); - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + cc.Node.prototype.updateDisplayedColor.call(selChild, parentColor); if( parentColor.r !== 255 || parentColor.g !== 255 || From f322578853bfe30fd94bbe012abdcc2623042237 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Tue, 19 Aug 2014 18:40:11 +0800 Subject: [PATCH 0478/1564] fixed cc.sys.os bug --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 696cc41bf6..dc553cb6c4 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1436,9 +1436,9 @@ cc._initSys = function (config, CONFIG_KEY) { if (nav.appVersion.indexOf("Win") != -1) osName = sys.OS_WINDOWS; else if (iOS) osName = sys.OS_IOS; else if (nav.appVersion.indexOf("Mac") != -1) osName = sys.OS_OSX; + else if (isAndroid) osName = sys.OS_ANDROID; else if (nav.appVersion.indexOf("X11") != -1) osName = sys.OS_UNIX; else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; - else if (isAndroid) osName = sys.OS_ANDROID; sys.os = osName; // Forces the garbage collector From 0a5618c4d2595711cacac5ea44192d362f0c4a00 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 20 Aug 2014 11:06:34 +0800 Subject: [PATCH 0479/1564] Closed #5832: fixed a bug of RenderTexture that it doesn't support depthStencilFormat --- cocos2d/render-texture/CCRenderTexture.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index d5f984655b..b0910212b5 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -288,11 +288,12 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ this._depthRenderBuffer = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderBuffer); gl.renderbufferStorage(gl.RENDERBUFFER, depthStencilFormat, powW, powH); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); - - // if depth format is the one with stencil part, bind same render buffer as stencil attachment - //if (depthStencilFormat == gl.DEPTH24_STENCIL8) - // gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); + if(depthStencilFormat == gl.DEPTH_STENCIL) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); + else if(depthStencilFormat == gl.STENCIL_INDEX || depthStencilFormat == gl.STENCIL_INDEX8) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); + else if(depthStencilFormat == gl.DEPTH_COMPONENT16) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); } // check if it worked (probably worth doing :) ) From e79a520f363957524f09f6a14d1f4ce896b597bd Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 20 Aug 2014 13:39:17 +0800 Subject: [PATCH 0480/1564] Correct a mistake of cc.ParticleSystem --- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/particle/CCParticleSystem.js | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index f159d83017..95b9d16c2f 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -44,7 +44,7 @@ cc.generateTintImageWithMultiply = function(image, color, rect, renderCanvas){ context.globalCompositeOperation = "source-over"; } - context.fillStyle = "rgb(" + color.r + "," + color.g + "," + color.b + ")"; + context.fillStyle = "rgb(" + (0|color.r) + "," + (0|color.g) + "," + (0|color.b) + ")"; context.fillRect(0, 0, rect.width, rect.height); context.globalCompositeOperation = "multiply"; context.drawImage(image, diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 59d20a4141..da299cd454 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2118,10 +2118,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // color if (!this._dontTint || cc._renderType === cc._RENDER_TYPE_WEBGL) { - selParticle.color.r += 0|(selParticle.deltaColor.r * dt); - selParticle.color.g += 0|(selParticle.deltaColor.g * dt); - selParticle.color.b += 0|(selParticle.deltaColor.b * dt); - selParticle.color.a += 0|(selParticle.deltaColor.a * dt); + selParticle.color.r += selParticle.deltaColor.r * dt; + selParticle.color.g += selParticle.deltaColor.g * dt; + selParticle.color.b += selParticle.deltaColor.b * dt; + selParticle.color.a += selParticle.deltaColor.a * dt; selParticle.isChangeColor = true; } @@ -2448,9 +2448,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ }, _changeTextureColor: function(element, color, rect){ - color.r = 0|color.r; - color.g = 0|color.g; - color.b = 0|color.b; if (!element.tintCache) { element.tintCache = document.createElement('canvas'); element.tintCache.width = element.width; From 68d3c92ccad24a909896eac50b4ff8ebf252c99e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 20 Aug 2014 17:40:29 +0800 Subject: [PATCH 0481/1564] Issue #5835: modify The return value of the Facebook interface --- external/pluginx/platform/facebook.js | 104 +++++++++++++++++--------- 1 file changed, 69 insertions(+), 35 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 64208c9018..ef2aeab9d9 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -51,20 +51,20 @@ plugin.extend('facebook', { login: function(callback){ var self = this; FB.login(function(response) { - if (response.authResponse) { + if (response['authResponse']) { //save user info - self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0, "login success"); + self.userInfo = response['authResponse']; + typeof callback === 'function' && callback(0, { + accessToken: response['authResponse']['accessToken'] + }); } else { - typeof callback === 'function' && callback(1, "login failed"); + typeof callback === 'function' && callback(response['error_code'] || 1, { + error_message: "unknown" + }); } }, { scope: '' }); }, - isLogedIn: function(callback){ - return this.isLoggedIn(callback); - }, - /** * @param {Function} callback * @return {Boolean} @@ -72,12 +72,18 @@ plugin.extend('facebook', { isLoggedIn: function(callback){ var self = this; FB.getLoginStatus(function(response) { - if (response && response.status === 'connected') { + if (response && response['status'] === 'connected') { //login - save user info - self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0, "logged in"); + self.userInfo = response['authResponse']; + typeof callback === 'function' && callback(0, { + isLoggedIn: true, + accessToken: response['authResponse']['accessToken'] + }); }else{ - typeof callback === 'function' && callback(1, "logged out"); + typeof callback === 'function' && callback(0, { + isLoggedIn: false, + accessToken: "" + }); } }); }, @@ -88,12 +94,14 @@ plugin.extend('facebook', { logout: function(callback){ var self = this; FB.logout(function(response) { - if(response.authResponse){ + if(response['authResponse']){ // user is now logged out self.userInfo = {}; - typeof callback === 'function' && callback(0, "logout success"); + typeof callback === 'function' && callback(0, {}); }else{ - typeof callback === 'function' && callback(1, "logout failed"); + typeof callback === 'function' && callback(response['error_code'] || 1, { + error_message: response['error_message'] || "Unknown" + }); } }); }, @@ -106,13 +114,17 @@ plugin.extend('facebook', { var permissionsStr = permissions.join(','); var self = this; FB.login(function(response){ - if (response.authResponse) { - var permissList = response.authResponse['grantedScopes'].split(","); + if (response['authResponse']) { + var permissList = response['authResponse']['grantedScopes'].split(","); //save user info - self.userInfo = response.authResponse; - typeof callback === 'function' && callback(0, JSON.stringify(permissList)); + self.userInfo = response['authResponse']; + typeof callback === 'function' && callback(0, { + permissions: permissList + }); } else { - typeof callback === 'function' && callback(1, "request failed"); + typeof callback === 'function' && callback(response['error_code'] || 1, { + error_message: response['error_message'] || "Unknown" + }); } }, { scope: permissionsStr, @@ -133,12 +145,16 @@ plugin.extend('facebook', { }else{ var self = this; FB.getLoginStatus(function(response) { - if (response && response.status === 'connected') { + if (response && response['status'] === 'connected') { //login - save user info - self.userInfo = response.authResponse; - callback(0, response.authResponse.accessToken); + self.userInfo = response['authResponse']; + typeof callback === 'function' && callback(0, { + accessToken: response['authResponse']['accessToken'] + }); }else{ - callback(1, undefined); + typeof callback === 'function' && callback(response['error_code'] || 1, { + error_message: response['error_message'] || "Unknown" + }); } }); } @@ -159,12 +175,20 @@ plugin.extend('facebook', { }, function(response) { if (response) { - if(response.post_id) - typeof callback === 'function' && callback(0, JSON.stringify(response)); + if(response['post_id']) + typeof callback === 'function' && callback(0, { + didComplete: 1, + post_id: response['post_id'] + }); else - typeof callback === 'function' && callback(3, JSON.stringify(response)); + typeof callback === 'function' && callback(0, { + didComplete: 0, + post_id: undefined + }); } else { - typeof callback === 'function' && callback(4, JSON.stringify(response)); + typeof callback === 'function' && callback(1, { + error_message: "Unknown" + }); } }); }, @@ -238,12 +262,19 @@ plugin.extend('facebook', { FB.ui(info, function(response) { if (response) { - if(response.post_id) - typeof callback === 'function' && callback(0, JSON.stringify(response)); + if(response['post_id']) + typeof callback === 'function' && callback(0, { + didComplete: 1, + post_id: response['post_id'] + }); else - typeof callback === 'function' && callback(response.error_code, response.error_message); + typeof callback === 'function' && callback(response['error_code'] || 1, { + error_message: response['error_message'] + }); } else { - typeof callback === 'function' && callback(1, "Unknow error"); + typeof callback === 'function' && callback(1, { + error_message:"Unknow error" + }); } }); }, @@ -259,7 +290,7 @@ plugin.extend('facebook', { if(response.error){ callback(response.error.code, JSON.stringify(response)) }else{ - callback(0, JSON.stringify(response)); + callback(0, response); } }); }, @@ -277,12 +308,15 @@ plugin.extend('facebook', { */ info.method = 'pay'; + info.action = 'purchaseitem'; FB.ui(info, function(response) { if(response.error_code){ - callback(response.error_code, JSON.stringify(response)); + callback(response.error_code, { + error_message: response.error_message + }); }else{ - callback(0, JSON.stringify(response)); + callback(0, response); } }) } From 5e96d8d86630f278bd4979d5c17f5abedba591f9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 20 Aug 2014 17:50:50 +0800 Subject: [PATCH 0482/1564] Issue #5835: modify The return value of the Facebook interface --- external/pluginx/platform/facebook.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index ef2aeab9d9..8a9b95d04e 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -177,13 +177,12 @@ plugin.extend('facebook', { if (response) { if(response['post_id']) typeof callback === 'function' && callback(0, { - didComplete: 1, + didComplete: true, post_id: response['post_id'] }); else - typeof callback === 'function' && callback(0, { - didComplete: 0, - post_id: undefined + typeof callback === 'function' && callback(response.error_code || 1, { + error_message: "Unknown" }); } else { typeof callback === 'function' && callback(1, { @@ -264,7 +263,7 @@ plugin.extend('facebook', { if (response) { if(response['post_id']) typeof callback === 'function' && callback(0, { - didComplete: 1, + didComplete: true, post_id: response['post_id'] }); else From 175ee4d2b02235a406e635453b1ef137ac863e02 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 20 Aug 2014 18:43:37 +0800 Subject: [PATCH 0483/1564] Closed #5833: fixed a bug of cc.Scale9Sprite that it has a line on iOS device. --- cocos2d/labels/CCLabelBMFont.js | 2 +- .../gui/control-extension/CCScale9Sprite.js | 88 +++++++++++++++---- 2 files changed, 72 insertions(+), 18 deletions(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index c41bf090f1..f888d511a1 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -363,7 +363,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * init a bitmap font altas with an initial string and the FNT file + * init a bitmap font atlas with an initial string and the FNT file * @param {String} str * @param {String} fntFile * @param {Number} [width=-1] diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index dffdd31ba6..22ea0bb59c 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -62,6 +62,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ _bottom: null, _bottomRight: null, + //cache in canvas on Canvas mode + _cacheSprite: null, + _cacheCanvas: null, + _cacheContext: null, + _cacheTexture: null, + _scale9Dirty: true, + _opacityModifyRGB: false, _originalSize: null, @@ -149,17 +156,17 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var leftWidth = locBottomLeftContentSize.width; var bottomHeight = locBottomLeftContentSize.height; - if(cc._renderType == cc._RENDER_TYPE_WEBGL){ + if (cc._renderType == cc._RENDER_TYPE_WEBGL) { //browser is in canvas mode, need to manually control rounding to prevent overlapping pixels var roundedRescaledWidth = Math.round(rescaledWidth); - if(rescaledWidth != roundedRescaledWidth) { + if (rescaledWidth != roundedRescaledWidth) { rescaledWidth = roundedRescaledWidth; - horizontalScale = rescaledWidth/locCenterContentSize.width; + horizontalScale = rescaledWidth / locCenterContentSize.width; } var roundedRescaledHeight = Math.round(rescaledHeight); - if(rescaledHeight != roundedRescaledHeight) { + if (rescaledHeight != roundedRescaledHeight) { rescaledHeight = roundedRescaledHeight; - verticalScale = rescaledHeight/locCenterContentSize.height; + verticalScale = rescaledHeight / locCenterContentSize.height; } } @@ -180,22 +187,45 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Position corners locBottomLeft.setPosition(0, 0); - locBottomRight.setPosition( (leftWidth + rescaledWidth) + 0.5 | 0, 0); - locTopLeft.setPosition(0, (bottomHeight + rescaledHeight) + 0.5 | 0); - locTopRight.setPosition( (leftWidth + rescaledWidth) + 0.5 | 0, (bottomHeight + rescaledHeight) + 0.5 | 0); + locBottomRight.setPosition(leftWidth + rescaledWidth, 0); + locTopLeft.setPosition(0, bottomHeight + rescaledHeight); + locTopRight.setPosition(leftWidth + rescaledWidth, bottomHeight + rescaledHeight); // Scale and position borders - locLeft.setPosition(0, (bottomHeight) + 0.5 | 0); + locLeft.setPosition(0, bottomHeight); locLeft.setScaleY(verticalScale); - locRight.setPosition( (leftWidth + rescaledWidth) + 0.5 | 0, (bottomHeight) + 0.5 | 0); + locRight.setPosition(leftWidth + rescaledWidth, bottomHeight); locRight.setScaleY(verticalScale); - locBottom.setPosition( (leftWidth) + 0.5 | 0, 0); + locBottom.setPosition(leftWidth, 0); locBottom.setScaleX(horizontalScale); - locTop.setPosition( (leftWidth) + 0.5 | 0, (bottomHeight + rescaledHeight) + 0.5 | 0); + locTop.setPosition(leftWidth, bottomHeight + rescaledHeight); locTop.setScaleX(horizontalScale); // Position centre - locCenter.setPosition( (leftWidth) + 0.5 | 0, (bottomHeight) + 0.5 | 0); + locCenter.setPosition(leftWidth, bottomHeight); + }, + + _cacheScale9Sprite: function(){ + var size = this._contentSize, locCanvas = this._cacheCanvas; + var contentSizeChanged = false; + if(locCanvas.width != size.width || locCanvas.height != size.height){ + locCanvas.width = size.width; + locCanvas.height = size.height; + this._cacheContext.translate(0, size.height); + contentSizeChanged = true; + } + + //cc._renderContext = this._cacheContext; + cc.view._setScaleXYForRenderTexture(); + this._scale9Image.visit(this._cacheContext); + //cc._renderContext = cc._mainRenderContextBackup; + cc.view._resetScale(); + + if(contentSizeChanged) + this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); + + if(!this._cacheSprite.getParent()) + this.addChild(this._cacheSprite); }, /** @@ -215,6 +245,20 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._capInsets = cc.rect(0, 0, 0, 0); this._loadedEventListeners = []; + //cache + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); + locCacheCanvas.width = 1; + locCacheCanvas.height = 1; + this._cacheContext = locCacheCanvas.getContext("2d"); + var locTexture = this._cacheTexture = new cc.Texture2D(); + locTexture.initWithElement(locCacheCanvas); + locTexture.handleLoadedTexture(); + this._cacheSprite = new cc.Sprite(locTexture); + this._cacheSprite.setAnchorPoint(0,0); + this.addChild(this._cacheSprite); + } + if(file != undefined){ if(file instanceof cc.SpriteFrame) this.initWithSpriteFrame(file, rect); @@ -269,6 +313,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if (selChild) selChild.setOpacity(opacity); } + this._scale9Dirty = true; }, updateDisplayedOpacity: function(parentOpacity){ @@ -282,6 +327,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if (selChild) selChild.updateDisplayedOpacity(parentOpacity); } + this._scale9Dirty = true; }, /** Color: conforms to CCRGBAProtocol protocol */ @@ -296,6 +342,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if (selChild) selChild.setColor(color); } + this._scale9Dirty = true; }, updateDisplayedColor: function(parentColor){ @@ -322,6 +369,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } } } + this._scale9Dirty = true; }, getCapInsets: function () { @@ -431,6 +479,11 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if (this._positionsAreDirty) { this._updatePositions(); this._positionsAreDirty = false; + this._scale9Dirty = true; + } + if(this._scale9Dirty && cc._renderType === cc._RENDER_TYPE_CANVAS){ + this._scale9Dirty = false; + this._cacheScale9Sprite(); } cc.Node.prototype.visit.call(this, ctx); }, @@ -514,7 +567,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * Initializes a 9-slice sprite with an sprite frame and with the specified * cap insets. * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. + * to resize the sprite will all it's 9-slice goodness interact. * It respects the anchorPoint too. * * @param spriteFrame The sprite frame object. @@ -547,7 +600,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * Initializes a 9-slice sprite with an sprite frame name and with the specified * cap insets. * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. + * to resize the sprite will all it's 9-slice goodness interact. * It respects the anchorPoint too. * * @param spriteFrameName The sprite frame name. @@ -607,7 +660,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, /** - * + * Update the scale9Sprite with a SpriteBatchNode. * @param {cc.SpriteBatchNode} batchNode * @param {cc.Rect} originalRect * @param {boolean} rotated @@ -906,7 +959,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } this.setContentSize(rect.width, rect.height); - this.addChild(locScale9Image); + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this.addChild(locScale9Image); if (this._spritesGenerated) { // Restore color and opacity From bf3fde23f7192af0f1e2fb5880adb77972bd2af0 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Wed, 20 Aug 2014 16:39:07 +0300 Subject: [PATCH 0484/1564] fixed CCProgressTimer draw on canvas with colorized sprite --- cocos2d/progress-timer/CCProgressTimer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 12ec6cc597..8e6d147c46 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -469,7 +469,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ //draw sprite if (locSprite._texture && locTextureCoord.validRect) { var image = locSprite._texture.getHtmlElementObj(); - if (this._colorized) { + if (locSprite._colorized) { context.drawImage(image, 0, 0, locTextureCoord.width, locTextureCoord.height, flipXOffset, flipYOffset, locDrawSizeCanvas.width, locDrawSizeCanvas.height); From dc3f89311ebc208e493c29781cd94e638d4d17f0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 21 Aug 2014 10:28:03 +0800 Subject: [PATCH 0485/1564] Fixed #5833: add a check to cc.Scale9Sprite._cacheScale9Sprite --- extensions/gui/control-extension/CCScale9Sprite.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 22ea0bb59c..a3ba8e6ec9 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -206,6 +206,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, _cacheScale9Sprite: function(){ + if(!this._scale9Image) + return; var size = this._contentSize, locCanvas = this._cacheCanvas; var contentSizeChanged = false; if(locCanvas.width != size.width || locCanvas.height != size.height){ From ed1f7de5c551f9e9a9a34b1e161f24ad60850013 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 21 Aug 2014 10:53:31 +0800 Subject: [PATCH 0486/1564] Correct a mistake of cc.Scale9Sprite --- extensions/gui/control-extension/CCScale9Sprite.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index a3ba8e6ec9..d713123a35 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -278,12 +278,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ /** Original sprite's size. */ getOriginalSize: function () { - return this._originalSize; + return cc.size(this._originalSize); }, //if the preferredSize component is given as -1, it is ignored getPreferredSize: function () { - return this._preferredSize; + return cc.size(this._preferredSize); }, _getPreferredWidth: function () { return this._preferredSize.width; @@ -375,7 +375,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, getCapInsets: function () { - return this._capInsets; + return cc.rect(this._capInsets); }, setCapInsets: function (capInsets) { From 12f6cda0ee6fb8fd611b554b62965cc46a60b19d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 21 Aug 2014 11:30:09 +0800 Subject: [PATCH 0487/1564] Issue #5835: Add getPermissionList and modify callback --- external/pluginx/platform/facebook.js | 40 +++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 8a9b95d04e..e4cbcd9727 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -141,7 +141,9 @@ plugin.extend('facebook', { } if(this.userInfo.accessToken){ - callback(0, this.userInfo.accessToken); + callback(0, { + accessToken: this.userInfo['accessToken'] + }); }else{ var self = this; FB.getLoginStatus(function(response) { @@ -253,7 +255,7 @@ plugin.extend('facebook', { info['method'] != 'share_open_graph' && info['method'] != 'share_link' && info['method'] != 'apprequests' - ){ + ){ cc.log('web is not supported what this it method'); return; } @@ -267,9 +269,7 @@ plugin.extend('facebook', { post_id: response['post_id'] }); else - typeof callback === 'function' && callback(response['error_code'] || 1, { - error_message: response['error_message'] - }); + typeof callback === 'function' && callback(0, response); } else { typeof callback === 'function' && callback(1, { error_message:"Unknow error" @@ -287,13 +287,35 @@ plugin.extend('facebook', { request: function(path, httpmethod, params, callback){ FB.api(path, httpmethod, params, function(response){ if(response.error){ - callback(response.error.code, JSON.stringify(response)) + callback(response['error']['code'], { + error_message: response['error']['message'] || 'Unknown' + }) }else{ callback(0, response); } }); }, + getPermissionList: function(callback){ + FB.api("/me/permissions", function(response){ + if(response['data']){ + var permissionList = []; + for(var i=0; i Date: Thu, 21 Aug 2014 16:25:08 +0800 Subject: [PATCH 0488/1564] Closed #5838: Add UIScale9Sprite to ccui --- .../ccui/base-classes/UIScale9Sprite.js | 1077 +++++++++++++++++ extensions/ccui/layouts/UILayout.js | 4 +- extensions/ccui/uiwidgets/UIButton.js | 6 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- extensions/ccui/uiwidgets/UIRichText.js | 16 +- extensions/ccui/uiwidgets/UISlider.js | 7 +- moduleConfig.json | 5 +- tools/build.xml | 1 + tools/jsdoc_toolkit/build.xml | 1 + 10 files changed, 1103 insertions(+), 18 deletions(-) create mode 100644 extensions/ccui/base-classes/UIScale9Sprite.js diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js new file mode 100644 index 0000000000..2675d9a001 --- /dev/null +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -0,0 +1,1077 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2012 Neofect. All rights reserved. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + Created by Jung Sang-Taik on 2012-03-16 + ****************************************************************************/ + +/** + *

    + * A 9-slice sprite for cocos2d UI.
    + *
    + * 9-slice scaling allows you to specify how scaling is applied
    + * to specific areas of a sprite. With 9-slice scaling (3x3 grid),
    + * you can ensure that the sprite does not become distorted when
    + * scaled.
    + * @note: it will refactor in v3.1
    + * @see http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html
    + *

    + * @class + * @extends cc.Node + * + * @property {cc.Size} preferredSize - The preferred size of the 9-slice sprite + * @property {cc.Rect} capInsets - The cap insets of the 9-slice sprite + * @property {Number} insetLeft - The left inset of the 9-slice sprite + * @property {Number} insetTop - The top inset of the 9-slice sprite + * @property {Number} insetRight - The right inset of the 9-slice sprite + * @property {Number} insetBottom - The bottom inset of the 9-slice sprite + */ +ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ + _spriteRect: null, + _capInsetsInternal: null, + _positionsAreDirty: false, + + _scale9Image: null, + _topLeft: null, + _top: null, + _topRight: null, + _left: null, + _centre: null, + _right: null, + _bottomLeft: null, + _bottom: null, + _bottomRight: null, + + //cache in canvas on Canvas mode + _cacheSprite: null, + _cacheCanvas: null, + _cacheContext: null, + _cacheTexture: null, + _scale9Dirty: true, + + _opacityModifyRGB: false, + + _originalSize: null, + _preferredSize: null, + _opacity: 0, + _color: null, + _capInsets: null, + _insetLeft: 0, + _insetTop: 0, + _insetRight: 0, + _insetBottom: 0, + + _spritesGenerated: false, + _spriteFrameRotated: false, + _textureLoaded:false, + _loadedEventListeners: null, + _className:"Scale9Sprite", + + /** + * return texture is loaded + * @returns {boolean} + */ + textureLoaded:function(){ + return this._textureLoaded; + }, + + /** + * add texture loaded event listener + * @param {Function} callback + * @param {Object} target + */ + addLoadedEventListener:function(callback, target){ + this._loadedEventListeners.push({eventCallback:callback, eventTarget:target}); + }, + + _callLoadedEventCallbacks:function(){ + this._textureLoaded = true; + var locListeners = this._loadedEventListeners; + for(var i = 0, len = locListeners.length; i < len; i++){ + var selCallback = locListeners[i]; + selCallback.eventCallback.call(selCallback.eventTarget, this); + } + locListeners.length = 0; + }, + + _updateCapInset: function () { + var insets, locInsetLeft = this._insetLeft, locInsetTop = this._insetTop, locInsetRight = this._insetRight; + var locSpriteRect = this._spriteRect, locInsetBottom = this._insetBottom; + if (locInsetLeft === 0 && locInsetTop === 0 && locInsetRight === 0 && locInsetBottom === 0) { + insets = cc.rect(0, 0, 0, 0); + } else { + insets = this._spriteFrameRotated ? cc.rect(locInsetBottom, locInsetLeft, + locSpriteRect.width - locInsetRight - locInsetLeft, + locSpriteRect.height - locInsetTop - locInsetBottom) : + cc.rect(locInsetLeft, locInsetTop, + locSpriteRect.width - locInsetLeft - locInsetRight, + locSpriteRect.height - locInsetTop - locInsetBottom); + } + this.setCapInsets(insets); + }, + + _updatePositions: function () { + // Check that instances are non-NULL + if (!((this._topLeft) && (this._topRight) && (this._bottomRight) && + (this._bottomLeft) && (this._centre))) { + // if any of the above sprites are NULL, return + return; + } + + var size = this._contentSize; + var locTopLeft = this._topLeft, locTopRight = this._topRight, locBottomRight = this._bottomRight, locBottomLeft = this._bottomLeft; + var locCenter = this._centre, locCenterContentSize = this._centre.getContentSize(); + var locTopLeftContentSize = locTopLeft.getContentSize(); + var locBottomLeftContentSize = locBottomLeft.getContentSize(); + + var sizableWidth = size.width - locTopLeftContentSize.width - locTopRight.getContentSize().width; + var sizableHeight = size.height - locTopLeftContentSize.height - locBottomRight.getContentSize().height; + + var horizontalScale = sizableWidth / locCenterContentSize.width; + var verticalScale = sizableHeight / locCenterContentSize.height; + + var rescaledWidth = locCenterContentSize.width * horizontalScale; + var rescaledHeight = locCenterContentSize.height * verticalScale; + + var leftWidth = locBottomLeftContentSize.width; + var bottomHeight = locBottomLeftContentSize.height; + + if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + //browser is in canvas mode, need to manually control rounding to prevent overlapping pixels + var roundedRescaledWidth = Math.round(rescaledWidth); + if (rescaledWidth != roundedRescaledWidth) { + rescaledWidth = roundedRescaledWidth; + horizontalScale = rescaledWidth / locCenterContentSize.width; + } + var roundedRescaledHeight = Math.round(rescaledHeight); + if (rescaledHeight != roundedRescaledHeight) { + rescaledHeight = roundedRescaledHeight; + verticalScale = rescaledHeight / locCenterContentSize.height; + } + } + + locCenter.setScaleX(horizontalScale); + locCenter.setScaleY(verticalScale); + + var locLeft = this._left, locRight = this._right, locTop = this._top, locBottom = this._bottom; + var tempAP = cc.p(0, 0); + locBottomLeft.setAnchorPoint(tempAP); + locBottomRight.setAnchorPoint(tempAP); + locTopLeft.setAnchorPoint(tempAP); + locTopRight.setAnchorPoint(tempAP); + locLeft.setAnchorPoint(tempAP); + locRight.setAnchorPoint(tempAP); + locTop.setAnchorPoint(tempAP); + locBottom.setAnchorPoint(tempAP); + locCenter.setAnchorPoint(tempAP); + + // Position corners + locBottomLeft.setPosition(0, 0); + locBottomRight.setPosition(leftWidth + rescaledWidth, 0); + locTopLeft.setPosition(0, bottomHeight + rescaledHeight); + locTopRight.setPosition(leftWidth + rescaledWidth, bottomHeight + rescaledHeight); + + // Scale and position borders + locLeft.setPosition(0, bottomHeight); + locLeft.setScaleY(verticalScale); + locRight.setPosition(leftWidth + rescaledWidth, bottomHeight); + locRight.setScaleY(verticalScale); + locBottom.setPosition(leftWidth, 0); + locBottom.setScaleX(horizontalScale); + locTop.setPosition(leftWidth, bottomHeight + rescaledHeight); + locTop.setScaleX(horizontalScale); + + // Position centre + locCenter.setPosition(leftWidth, bottomHeight); + }, + + _cacheScale9Sprite: function(){ + if(!this._scale9Image) + return; + var size = this._contentSize, locCanvas = this._cacheCanvas; + var contentSizeChanged = false; + if(locCanvas.width != size.width || locCanvas.height != size.height){ + locCanvas.width = size.width; + locCanvas.height = size.height; + this._cacheContext.translate(0, size.height); + contentSizeChanged = true; + } + + //cc._renderContext = this._cacheContext; + cc.view._setScaleXYForRenderTexture(); + this._scale9Image.visit(this._cacheContext); + //cc._renderContext = cc._mainRenderContextBackup; + cc.view._resetScale(); + + if(contentSizeChanged) + this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); + + if(!this._cacheSprite.getParent()) + this.addChild(this._cacheSprite); + }, + + /** + * @constructor + * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame + * @param {cc.Rect} rect + * @param {cc.Rect} capInsets + * @returns {Scale9Sprite} + */ + ctor: function (file, rect, capInsets) { + cc.Node.prototype.ctor.call(this); + this._spriteRect = cc.rect(0, 0, 0, 0); + this._capInsetsInternal = cc.rect(0, 0, 0, 0); + + this._originalSize = cc.size(0, 0); + this._preferredSize = cc.size(0, 0); + this._capInsets = cc.rect(0, 0, 0, 0); + this._loadedEventListeners = []; + + //cache + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); + locCacheCanvas.width = 1; + locCacheCanvas.height = 1; + this._cacheContext = locCacheCanvas.getContext("2d"); + var locTexture = this._cacheTexture = new cc.Texture2D(); + locTexture.initWithElement(locCacheCanvas); + locTexture.handleLoadedTexture(); + this._cacheSprite = new cc.Sprite(locTexture); + this._cacheSprite.setAnchorPoint(0,0); + this.addChild(this._cacheSprite); + } + + if(file != undefined){ + if(file instanceof cc.SpriteFrame) + this.initWithSpriteFrame(file, rect); + else{ + var frame = cc.spriteFrameCache.getSpriteFrame(file); + if(frame != null) + this.initWithSpriteFrame(frame, rect); + else + this.initWithFile(file, rect, capInsets); + } + }else{ + this.init(); + } + }, + + /** Original sprite's size. */ + getOriginalSize: function () { + return cc.size(this._originalSize); + }, + + //if the preferredSize component is given as -1, it is ignored + getPreferredSize: function () { + return cc.size(this._preferredSize); + }, + _getPreferredWidth: function () { + return this._preferredSize.width; + }, + _getPreferredHeight: function () { + return this._preferredSize.height; + }, + setPreferredSize: function (preferredSize) { + this.setContentSize(preferredSize); + this._preferredSize = preferredSize; + }, + _setPreferredWidth: function (value) { + this._setWidth(value); + this._preferredSize.width = value; + }, + _setPreferredHeight: function (value) { + this._setHeight(value); + this._preferredSize.height = value; + }, + + /** Opacity: conforms to CCRGBAProtocol protocol */ + setOpacity: function (opacity) { + if(!this._scale9Image) + return; + cc.Node.prototype.setOpacity.call(this, opacity); + var scaleChildren = this._scale9Image.getChildren(); + for (var i = 0; i < scaleChildren.length; i++) { + var selChild = scaleChildren[i]; + if (selChild) + selChild.setOpacity(opacity); + } + this._scale9Dirty = true; + }, + + updateDisplayedOpacity: function(parentOpacity){ + if(!this._scale9Image) + return; + + cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); + var scaleChildren = this._scale9Image.getChildren(); + for (var i = 0; i < scaleChildren.length; i++) { + var selChild = scaleChildren[i]; + if (selChild) + selChild.updateDisplayedOpacity(parentOpacity); + } + this._scale9Dirty = true; + }, + + /** Color: conforms to CCRGBAProtocol protocol */ + setColor: function (color) { + if(!this._scale9Image) + return; + + cc.Node.prototype.setColor.call(this, color); + var scaleChildren = this._scale9Image.getChildren(); + for (var i = 0; i < scaleChildren.length; i++) { + var selChild = scaleChildren[i]; + if (selChild) + selChild.setColor(color); + } + this._scale9Dirty = true; + }, + + updateDisplayedColor: function(parentColor){ + if(!this._scale9Image) + return; + + cc.Node.prototype.updateDisplayedColor.call(this, parentColor); + var scaleChildren = this._scale9Image.getChildren(); + for (var i = 0; i < scaleChildren.length; i++) { + var selChild = scaleChildren[i]; + if (selChild){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + cc.Node.prototype.updateDisplayedColor.call(selChild, parentColor); + if( + parentColor.r !== 255 || + parentColor.g !== 255 || + parentColor.b !== 255 + ){ + selChild._changeTextureColor(); + selChild._setNodeDirtyForCache(); + } + }else{ + selChild.updateDisplayedColor(parentColor); + } + } + } + this._scale9Dirty = true; + }, + + getCapInsets: function () { + return cc.rect(this._capInsets); + }, + + setCapInsets: function (capInsets) { + if(!this._scale9Image) + return; + //backup the contentSize + var contentSize = this._contentSize; + var tempWidth = contentSize.width, tempHeight = contentSize.height; + + this.updateWithBatchNode(this._scale9Image, this._spriteRect, this._spriteFrameRotated, capInsets); + //restore the contentSize + this.setContentSize(tempWidth, tempHeight); + }, + + /** + * Gets the left side inset + * @returns {number} + */ + getInsetLeft: function () { + return this._insetLeft; + }, + + /** + * Sets the left side inset + * @param {Number} insetLeft + */ + setInsetLeft: function (insetLeft) { + this._insetLeft = insetLeft; + this._updateCapInset(); + }, + + /** + * Gets the top side inset + * @returns {number} + */ + getInsetTop: function () { + return this._insetTop; + }, + + /** + * Sets the top side inset + * @param {Number} insetTop + */ + setInsetTop: function (insetTop) { + this._insetTop = insetTop; + this._updateCapInset(); + }, + + /** + * Gets the right side inset + * @returns {number} + */ + getInsetRight: function () { + return this._insetRight; + }, + /** + * Sets the right side inset + * @param {Number} insetRight + */ + setInsetRight: function (insetRight) { + this._insetRight = insetRight; + this._updateCapInset(); + }, + + /** + * Gets the bottom side inset + * @returns {number} + */ + getInsetBottom: function () { + return this._insetBottom; + }, + /** + * Sets the bottom side inset + * @param {number} insetBottom + */ + setInsetBottom: function (insetBottom) { + this._insetBottom = insetBottom; + this._updateCapInset(); + }, + + /** + * Sets the untransformed size of the Scale9Sprite. + * @override + * @param {cc.Size|Number} size The untransformed size of the Scale9Sprite or The untransformed size's width of the Scale9Sprite. + * @param {Number} [height] The untransformed size's height of the Scale9Sprite. + */ + setContentSize: function (size, height) { + cc.Node.prototype.setContentSize.call(this, size, height); + this._positionsAreDirty = true; + }, + + _setWidth: function (value) { + cc.Node.prototype._setWidth.call(this, value); + this._positionsAreDirty = true; + }, + + _setHeight: function (value) { + cc.Node.prototype._setHeight.call(this, value); + this._positionsAreDirty = true; + }, + + visit: function (ctx) { + if (this._positionsAreDirty) { + this._updatePositions(); + this._positionsAreDirty = false; + this._scale9Dirty = true; + } + if(this._scale9Dirty && cc._renderType === cc._RENDER_TYPE_CANVAS){ + this._scale9Dirty = false; + this._cacheScale9Sprite(); + } + cc.Node.prototype.visit.call(this, ctx); + }, + + init: function () { + return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); + }, + + /** + * Initializes a 9-slice sprite with a SpriteBatchNode. + * @param {cc.SpriteBatchNode} batchNode + * @param {cc.Rect} rect + * @param {boolean|cc.Rect} rotated + * @param {cc.Rect} [capInsets] + * @returns {boolean} + */ + initWithBatchNode: function (batchNode, rect, rotated, capInsets) { + if (capInsets === undefined) { + capInsets = rotated; + rotated = false; + } + + if (batchNode) + this.updateWithBatchNode(batchNode, rect, rotated, capInsets); + this.setCascadeColorEnabled(true); + this.setCascadeOpacityEnabled(true); + this.setAnchorPoint(0.5, 0.5); + this._positionsAreDirty = true; + return true; + }, + + /** + * Initializes a 9-slice sprite with a texture file, a delimitation zone and + * with the specified cap insets. + * Once the sprite is created, you can then call its "setContentSize:" method + * to resize the sprite will all it's 9-slice goodness intact. + * It respects the anchorPoint too. + * + * @param {String} file The name of the texture file. + * @param {cc.Rect} rect The rectangle that describes the sub-part of the texture that + * is the whole image. If the shape is the whole texture, set this to the texture's full rect. + * @param {cc.Rect} capInsets The values to use for the cap insets. + */ + initWithFile: function (file, rect, capInsets) { + if (file instanceof cc.Rect) { + file = arguments[1]; + capInsets = arguments[0]; + rect = cc.rect(0, 0, 0, 0); + } else { + rect = rect || cc.rect(0, 0, 0, 0); + capInsets = capInsets || cc.rect(0, 0, 0, 0); + } + + if(!file) + throw "ccui.Scale9Sprite.initWithFile(): file should be non-null"; + + var texture = cc.textureCache.getTextureForKey(file); + if (!texture) { + texture = cc.textureCache.addImage(file); + } + + var locLoaded = texture.isLoaded(); + this._textureLoaded = locLoaded; + if(!locLoaded){ + texture.addLoadedEventListener(function(sender){ + // the texture is rotated on Canvas render mode, so isRotated always is false. + var preferredSize = this._preferredSize; + preferredSize = cc.size(preferredSize.width, preferredSize.height); + var size = sender.getContentSize(); + this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets); + this.setPreferredSize(preferredSize); + this._positionsAreDirty = true; + this._callLoadedEventCallbacks(); + }, this); + } + + return this.initWithBatchNode(cc.SpriteBatchNode.create(file, 9), rect, false, capInsets); + }, + + /** + * Initializes a 9-slice sprite with an sprite frame and with the specified + * cap insets. + * Once the sprite is created, you can then call its "setContentSize:" method + * to resize the sprite will all it's 9-slice goodness interact. + * It respects the anchorPoint too. + * + * @param spriteFrame The sprite frame object. + * @param capInsets The values to use for the cap insets. + */ + initWithSpriteFrame: function (spriteFrame, capInsets) { + if(!spriteFrame || !spriteFrame.getTexture()) + throw "ccui.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null"; + + capInsets = capInsets || cc.rect(0, 0, 0, 0); + var locLoaded = spriteFrame.textureLoaded(); + this._textureLoaded = locLoaded; + if(!locLoaded){ + spriteFrame.addLoadedEventListener(function(sender){ + // the texture is rotated on Canvas render mode, so isRotated always is false. + var preferredSize = this._preferredSize; + preferredSize = cc.size(preferredSize.width, preferredSize.height); + this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); + this.setPreferredSize(preferredSize); + this._positionsAreDirty = true; + this._callLoadedEventCallbacks(); + },this); + } + var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); + // the texture is rotated on Canvas render mode, so isRotated always is false. + return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets); + }, + + /** + * Initializes a 9-slice sprite with an sprite frame name and with the specified + * cap insets. + * Once the sprite is created, you can then call its "setContentSize:" method + * to resize the sprite will all it's 9-slice goodness interact. + * It respects the anchorPoint too. + * + * @param spriteFrameName The sprite frame name. + * @param capInsets The values to use for the cap insets. + */ + initWithSpriteFrameName: function (spriteFrameName, capInsets) { + if(!spriteFrameName) + throw "ccui.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null"; + capInsets = capInsets || cc.rect(0, 0, 0, 0); + + var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); + if (frame == null) { + cc.log("ccui.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"); + return false; + } + + return this.initWithSpriteFrame(frame, capInsets); + }, + + /** + * Creates and returns a new sprite object with the specified cap insets. + * You use this method to add cap insets to a sprite or to change the existing + * cap insets of a sprite. In both cases, you get back a new image and the + * original sprite remains untouched. + * + * @param {cc.Rect} capInsets The values to use for the cap insets. + */ + resizableSpriteWithCapInsets: function (capInsets) { + var pReturn = new ccui.Scale9Sprite(); + if (pReturn && pReturn.initWithBatchNode(this._scale9Image, this._spriteRect, false, capInsets)) + return pReturn; + return null; + }, + + /** sets the premultipliedAlphaOpacity property. + If set to NO then opacity will be applied as: glColor(R,G,B,opacity); + If set to YES then opacity will be applied as: glColor(opacity, opacity, opacity, opacity ); + Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO + @since v0.8 + */ + setOpacityModifyRGB: function (value) { + if(!this._scale9Image) + return; + this._opacityModifyRGB = value; + var scaleChildren = this._scale9Image.getChildren(); + if (scaleChildren) { + for (var i = 0, len = scaleChildren.length; i < len; i++) + scaleChildren[i].setOpacityModifyRGB(value); + } + }, + + /** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity); + @since v0.8 + */ + isOpacityModifyRGB: function () { + return this._opacityModifyRGB; + }, + + /** + * Update the scale9Sprite with a SpriteBatchNode. + * @param {cc.SpriteBatchNode} batchNode + * @param {cc.Rect} originalRect + * @param {boolean} rotated + * @param {cc.Rect} capInsets + * @returns {boolean} + */ + updateWithBatchNode: function (batchNode, originalRect, rotated, capInsets) { + var opacity = this.getOpacity(); + var color = this.getColor(); + var rect = cc.rect(originalRect.x, originalRect.y, originalRect.width, originalRect.height); + + // Release old sprites + this.removeAllChildren(true); + + if (this._scale9Image != batchNode) + this._scale9Image = batchNode; + + if(!this._scale9Image) + return false; + + var tmpTexture = batchNode.getTexture(); + var locLoaded = tmpTexture.isLoaded(); + this._textureLoaded = locLoaded; + if(!locLoaded){ + tmpTexture.addLoadedEventListener(function(sender){ + this._positionsAreDirty = true; + this._callLoadedEventCallbacks(); + },this); + return true; + } + var locScale9Image = this._scale9Image; + locScale9Image.removeAllChildren(true); + + //this._capInsets = capInsets; + var locCapInsets = this._capInsets; + locCapInsets.x = capInsets.x; + locCapInsets.y = capInsets.y; + locCapInsets.width = capInsets.width; + locCapInsets.height = capInsets.height; + this._spriteFrameRotated = rotated; + + var selTexture = locScale9Image.getTexture(); + + // If there is no given rect + if (cc._rectEqualToZero(rect)) { + // Get the texture size as original + var textureSize = selTexture.getContentSize(); + rect = cc.rect(0, 0, textureSize.width, textureSize.height); + } + + // Set the given rect's size as original size + this._spriteRect = rect; + var locSpriteRect = this._spriteRect; + locSpriteRect.x = rect.x; + locSpriteRect.y = rect.y; + locSpriteRect.width = rect.width; + locSpriteRect.height = rect.height; + + this._originalSize.width = rect.width; + this._originalSize.height = rect.height; + + var locPreferredSize = this._preferredSize; + if(locPreferredSize.width === 0 && locPreferredSize.height === 0){ + locPreferredSize.width = rect.width; + locPreferredSize.height = rect.height; + } + + var locCapInsetsInternal = this._capInsetsInternal; + if(capInsets){ + locCapInsetsInternal.x = capInsets.x; + locCapInsetsInternal.y = capInsets.y; + locCapInsetsInternal.width = capInsets.width; + locCapInsetsInternal.height = capInsets.height; + } + var w = rect.width, h = rect.height; + + // If there is no specified center region + if (cc._rectEqualToZero(locCapInsetsInternal)) { + // CCLog("... cap insets not specified : using default cap insets ..."); + locCapInsetsInternal.x = w / 3; + locCapInsetsInternal.y = h / 3; + locCapInsetsInternal.width = w / 3; + locCapInsetsInternal.height = h / 3; + } + + var left_w = locCapInsetsInternal.x, center_w = locCapInsetsInternal.width, right_w = w - (left_w + center_w); + + var top_h = locCapInsetsInternal.y, center_h = locCapInsetsInternal.height, bottom_h = h - (top_h + center_h); + + // calculate rects + // ... top row + var x = 0.0, y = 0.0; + + // top left + var lefttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, top_h + 0.5 | 0); + + // top center + x += left_w; + var centertopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, top_h + 0.5 | 0); + + // top right + x += center_w; + var righttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, top_h + 0.5 | 0); + + // ... center row + x = 0.0; + y = 0.0; + + y += top_h; + // center left + var leftcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, center_h + 0.5 | 0); + + // center center + x += left_w; + var centerbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, center_h + 0.5 | 0); + + // center right + x += center_w; + var rightcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, center_h + 0.5 | 0); + + // ... bottom row + x = 0.0; + y = 0.0; + y += top_h; + y += center_h; + + // bottom left + var leftbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, bottom_h + 0.5 | 0); + + // bottom center + x += left_w; + var centerbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, bottom_h + 0.5 | 0); + + // bottom right + x += center_w; + var rightbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, bottom_h + 0.5 | 0); + + var t = cc.affineTransformMakeIdentity(); + if (!rotated) { + // CCLog("!rotated"); + t = cc.affineTransformTranslate(t, rect.x, rect.y); + + cc._rectApplyAffineTransformIn(centerbounds, t); + cc._rectApplyAffineTransformIn(rightbottombounds, t); + cc._rectApplyAffineTransformIn(leftbottombounds, t); + cc._rectApplyAffineTransformIn(righttopbounds, t); + cc._rectApplyAffineTransformIn(lefttopbounds, t); + cc._rectApplyAffineTransformIn(rightcenterbounds, t); + cc._rectApplyAffineTransformIn(leftcenterbounds, t); + cc._rectApplyAffineTransformIn(centerbottombounds, t); + cc._rectApplyAffineTransformIn(centertopbounds, t); + + // Centre + this._centre = new cc.Sprite(); + this._centre.initWithTexture(selTexture, centerbounds); + locScale9Image.addChild(this._centre, 0, ccui.Scale9Sprite.POSITIONS_CENTRE); + + // Top + this._top = new cc.Sprite(); + this._top.initWithTexture(selTexture, centertopbounds); + locScale9Image.addChild(this._top, 1, ccui.Scale9Sprite.POSITIONS_TOP); + + // Bottom + this._bottom = new cc.Sprite(); + this._bottom.initWithTexture(selTexture, centerbottombounds); + locScale9Image.addChild(this._bottom, 1, ccui.Scale9Sprite.POSITIONS_BOTTOM); + + // Left + this._left = new cc.Sprite(); + this._left.initWithTexture(selTexture, leftcenterbounds); + locScale9Image.addChild(this._left, 1, ccui.Scale9Sprite.POSITIONS_LEFT); + + // Right + this._right = new cc.Sprite(); + this._right.initWithTexture(selTexture, rightcenterbounds); + locScale9Image.addChild(this._right, 1, ccui.Scale9Sprite.POSITIONS_RIGHT); + + // Top left + this._topLeft = new cc.Sprite(); + this._topLeft.initWithTexture(selTexture, lefttopbounds); + locScale9Image.addChild(this._topLeft, 2, ccui.Scale9Sprite.POSITIONS_TOPLEFT); + + // Top right + this._topRight = new cc.Sprite(); + this._topRight.initWithTexture(selTexture, righttopbounds); + locScale9Image.addChild(this._topRight, 2, ccui.Scale9Sprite.POSITIONS_TOPRIGHT); + + // Bottom left + this._bottomLeft = new cc.Sprite(); + this._bottomLeft.initWithTexture(selTexture, leftbottombounds); + locScale9Image.addChild(this._bottomLeft, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMLEFT); + + // Bottom right + this._bottomRight = new cc.Sprite(); + this._bottomRight.initWithTexture(selTexture, rightbottombounds); + locScale9Image.addChild(this._bottomRight, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT); + } else { + // set up transformation of coordinates + // to handle the case where the sprite is stored rotated + // in the spritesheet + // CCLog("rotated"); + var rotatedcenterbounds = centerbounds; + var rotatedrightbottombounds = rightbottombounds; + var rotatedleftbottombounds = leftbottombounds; + var rotatedrighttopbounds = righttopbounds; + var rotatedlefttopbounds = lefttopbounds; + var rotatedrightcenterbounds = rightcenterbounds; + var rotatedleftcenterbounds = leftcenterbounds; + var rotatedcenterbottombounds = centerbottombounds; + var rotatedcentertopbounds = centertopbounds; + + t = cc.affineTransformTranslate(t, rect.height + rect.x, rect.y); + t = cc.affineTransformRotate(t, 1.57079633); + + centerbounds = cc.rectApplyAffineTransform(centerbounds, t); + rightbottombounds = cc.rectApplyAffineTransform(rightbottombounds, t); + leftbottombounds = cc.rectApplyAffineTransform(leftbottombounds, t); + righttopbounds = cc.rectApplyAffineTransform(righttopbounds, t); + lefttopbounds = cc.rectApplyAffineTransform(lefttopbounds, t); + rightcenterbounds = cc.rectApplyAffineTransform(rightcenterbounds, t); + leftcenterbounds = cc.rectApplyAffineTransform(leftcenterbounds, t); + centerbottombounds = cc.rectApplyAffineTransform(centerbottombounds, t); + centertopbounds = cc.rectApplyAffineTransform(centertopbounds, t); + + rotatedcenterbounds.x = centerbounds.x; + rotatedcenterbounds.y = centerbounds.y; + + rotatedrightbottombounds.x = rightbottombounds.x; + rotatedrightbottombounds.y = rightbottombounds.y; + + rotatedleftbottombounds.x = leftbottombounds.x; + rotatedleftbottombounds.y = leftbottombounds.y; + + rotatedrighttopbounds.x = righttopbounds.x; + rotatedrighttopbounds.y = righttopbounds.y; + + rotatedlefttopbounds.x = lefttopbounds.x; + rotatedlefttopbounds.y = lefttopbounds.y; + + rotatedrightcenterbounds.x = rightcenterbounds.x; + rotatedrightcenterbounds.y = rightcenterbounds.y; + + rotatedleftcenterbounds.x = leftcenterbounds.x; + rotatedleftcenterbounds.y = leftcenterbounds.y; + + rotatedcenterbottombounds.x = centerbottombounds.x; + rotatedcenterbottombounds.y = centerbottombounds.y; + + rotatedcentertopbounds.x = centertopbounds.x; + rotatedcentertopbounds.y = centertopbounds.y; + + // Centre + this._centre = new cc.Sprite(); + this._centre.initWithTexture(selTexture, rotatedcenterbounds, true); + locScale9Image.addChild(this._centre, 0, ccui.Scale9Sprite.POSITIONS_CENTRE); + + // Top + this._top = new cc.Sprite(); + this._top.initWithTexture(selTexture, rotatedcentertopbounds, true); + locScale9Image.addChild(this._top, 1, ccui.Scale9Sprite.POSITIONS_TOP); + + // Bottom + this._bottom = new cc.Sprite(); + this._bottom.initWithTexture(selTexture, rotatedcenterbottombounds, true); + locScale9Image.addChild(this._bottom, 1, ccui.Scale9Sprite.POSITIONS_BOTTOM); + + // Left + this._left = new cc.Sprite(); + this._left.initWithTexture(selTexture, rotatedleftcenterbounds, true); + locScale9Image.addChild(this._left, 1, ccui.Scale9Sprite.POSITIONS_LEFT); + + // Right + this._right = new cc.Sprite(); + this._right.initWithTexture(selTexture, rotatedrightcenterbounds, true); + locScale9Image.addChild(this._right, 1, ccui.Scale9Sprite.POSITIONS_RIGHT); + + // Top left + this._topLeft = new cc.Sprite(); + this._topLeft.initWithTexture(selTexture, rotatedlefttopbounds, true); + locScale9Image.addChild(this._topLeft, 2, ccui.Scale9Sprite.POSITIONS_TOPLEFT); + + // Top right + this._topRight = new cc.Sprite(); + this._topRight.initWithTexture(selTexture, rotatedrighttopbounds, true); + locScale9Image.addChild(this._topRight, 2, ccui.Scale9Sprite.POSITIONS_TOPRIGHT); + + // Bottom left + this._bottomLeft = new cc.Sprite(); + this._bottomLeft.initWithTexture(selTexture, rotatedleftbottombounds, true); + locScale9Image.addChild(this._bottomLeft, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMLEFT); + + // Bottom right + this._bottomRight = new cc.Sprite(); + this._bottomRight.initWithTexture(selTexture, rotatedrightbottombounds, true); + locScale9Image.addChild(this._bottomRight, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT); + } + + this.setContentSize(rect.width, rect.height); + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this.addChild(locScale9Image); + + if (this._spritesGenerated) { + // Restore color and opacity + this.setOpacity(opacity); + this.setColor(color); + } + this._spritesGenerated = true; + return true; + }, + + /** + * set the sprite frame of ccui.Scale9Sprite + * @param {cc.SpriteFrame} spriteFrame + */ + setSpriteFrame: function (spriteFrame) { + var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); + // the texture is rotated on Canvas render mode, so isRotated always is false. + var locLoaded = spriteFrame.textureLoaded(); + this._textureLoaded = locLoaded; + if(!locLoaded){ + spriteFrame.addLoadedEventListener(function(sender){ + // the texture is rotated on Canvas render mode, so isRotated always is false. + var preferredSize = this._preferredSize; + preferredSize = cc.size(preferredSize.width, preferredSize.height); + this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); + this.setPreferredSize(preferredSize); + this._positionsAreDirty = true; + this._callLoadedEventCallbacks(); + },this); + } + this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0)); + + // Reset insets + this._insetLeft = 0; + this._insetTop = 0; + this._insetRight = 0; + this._insetBottom = 0; + } +}); + +var _p = ccui.Scale9Sprite.prototype; + +// Extended properties +/** @expose */ +_p.preferredSize; +cc.defineGetterSetter(_p, "preferredSize", _p.getPreferredSize, _p.setPreferredSize); +/** @expose */ +_p.capInsets; +cc.defineGetterSetter(_p, "capInsets", _p.getCapInsets, _p.setCapInsets); +/** @expose */ +_p.insetLeft; +cc.defineGetterSetter(_p, "insetLeft", _p.getInsetLeft, _p.setInsetLeft); +/** @expose */ +_p.insetTop; +cc.defineGetterSetter(_p, "insetTop", _p.getInsetTop, _p.setInsetTop); +/** @expose */ +_p.insetRight; +cc.defineGetterSetter(_p, "insetRight", _p.getInsetRight, _p.setInsetRight); +/** @expose */ +_p.insetBottom; +cc.defineGetterSetter(_p, "insetBottom", _p.getInsetBottom, _p.setInsetBottom); + +_p = null; + +/** + * Creates a 9-slice sprite with a texture file, a delimitation zone and + * with the specified cap insets. + * @deprecated + * @param {String|cc.SpriteFrame} file file name of texture or a cc.Sprite object + * @param {cc.Rect} rect the rect of the texture + * @param {cc.Rect} capInsets the cap insets of ccui.Scale9Sprite + * @returns {ccui.Scale9Sprite} + */ +ccui.Scale9Sprite.create = function (file, rect, capInsets) { + return new ccui.Scale9Sprite(file, rect, capInsets); +}; + +/** + * create a ccui.Scale9Sprite with Sprite frame. + * @deprecated + * @param {cc.SpriteFrame} spriteFrame + * @param {cc.Rect} capInsets + * @returns {ccui.Scale9Sprite} + */ +ccui.Scale9Sprite.createWithSpriteFrame = function (spriteFrame, capInsets) { + return new ccui.Scale9Sprite(spriteFrame, capInsets); +}; + +/** + * create a ccui.Scale9Sprite with a Sprite frame name + * @deprecated + * @param {string} spriteFrameName + * @param {cc.Rect} capInsets + * @returns {Scale9Sprite} + */ +ccui.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName, capInsets) { + return new ccui.Scale9Sprite(spriteFrameName, capInsets); +}; + +/** + * @ignore + */ +ccui.Scale9Sprite.POSITIONS_CENTRE = 0; +ccui.Scale9Sprite.POSITIONS_TOP = 1; +ccui.Scale9Sprite.POSITIONS_LEFT = 2; +ccui.Scale9Sprite.POSITIONS_RIGHT = 3; +ccui.Scale9Sprite.POSITIONS_BOTTOM = 4; +ccui.Scale9Sprite.POSITIONS_TOPRIGHT = 5; +ccui.Scale9Sprite.POSITIONS_TOPLEFT = 6; +ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index ad25dc4b92..178b0787e2 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -667,7 +667,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingRectDirty = true; if (this._backGroundImage) { this._backGroundImage.setPosition(locContentSize.width * 0.5, locContentSize.height * 0.5); - if (this._backGroundScale9Enabled && this._backGroundImage instanceof cc.Scale9Sprite) + if (this._backGroundScale9Enabled && this._backGroundImage instanceof ccui.Scale9Sprite) this._backGroundImage.setPreferredSize(locContentSize); } if (this._colorRender) @@ -805,7 +805,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ _addBackGroundImage: function () { if (this._backGroundScale9Enabled) { - this._backGroundImage = cc.Scale9Sprite.create(); + this._backGroundImage = ccui.Scale9Sprite.create(); this._backGroundImage.setPreferredSize(this._contentSize); } else this._backGroundImage = cc.Sprite.create(); diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 2492d38953..ebb00a4d22 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -140,9 +140,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.removeProtectedChild(this._buttonDisableRenderer); if (this._scale9Enabled) { - this._buttonNormalRenderer = cc.Scale9Sprite.create(); - this._buttonClickedRenderer = cc.Scale9Sprite.create(); - this._buttonDisableRenderer = cc.Scale9Sprite.create(); + this._buttonNormalRenderer = new ccui.Scale9Sprite(); + this._buttonClickedRenderer = new ccui.Scale9Sprite(); + this._buttonDisableRenderer = new ccui.Scale9Sprite(); } else { this._buttonNormalRenderer = cc.Sprite.create(); this._buttonClickedRenderer = cc.Sprite.create(); diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index b81c921338..2f98537a55 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -169,7 +169,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this.removeProtectedChild(this._imageRenderer); this._imageRenderer = null; if (this._scale9Enabled) { - this._imageRenderer = cc.Scale9Sprite.create(); + this._imageRenderer = new ccui.Scale9Sprite(); } else { this._imageRenderer = cc.Sprite.create(); } diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 31f53f67c7..f7004b4ec9 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -201,7 +201,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._scale9Enabled = enabled; this.removeProtectedChild(this._barRenderer); - this._barRenderer = this._scale9Enabled ? cc.Scale9Sprite.create() : cc.Sprite.create(); + this._barRenderer = this._scale9Enabled ? new ccui.Scale9Sprite() : cc.Sprite.create(); this.loadTexture(this._textureFile, this._renderBarTexType); this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 5b8dd8a490..3352f2235a 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -191,7 +191,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ }, _initRenderer: function () { - this._elementRenderersContainer = cc.Node.create(); + this._elementRenderersContainer = new cc.Node(); this._elementRenderersContainer.setAnchorPoint(0.5, 0.5); this.addProtectedChild(this._elementRenderersContainer, 0, -1); }, @@ -324,8 +324,6 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._handleCustomRenderer(imageRenderer); }, - _formarRenderers: function(){}, - /** * Handle custom renderer * @param {cc.Node} renderer @@ -364,7 +362,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ newContentSizeHeight = Math.max(newContentSizeHeight, iSize.height); nextPosX += iSize.width; } - locRenderersContainer.setContentSize(cc.size(newContentSizeWidth, newContentSizeHeight)); + locRenderersContainer.setContentSize(newContentSizeWidth, newContentSizeHeight); } else { var maxHeights = []; for (i = 0; i < locElementRenders.length; i++) { @@ -455,6 +453,16 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } }, + /** + * Gets the content size of ccui.RichText + * @override + * @return {cc.Size} + */ + getContentSize: function(){ + this.formatText(); + return cc.Node.prototype.getContentSize.l(this); + }, + getDescription: function(){ return "RichText"; } diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index dae0376785..96eef3c195 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -208,10 +208,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRenderer = null; this._progressBarRenderer = null; if (this._scale9Enabled) { - this._barRenderer = cc.Scale9Sprite.create(); - this._progressBarRenderer = cc.Scale9Sprite.create(); - } - else { + this._barRenderer = new ccui.Scale9Sprite(); + this._progressBarRenderer = new ccui.Scale9Sprite(); + } else { this._barRenderer = cc.Sprite.create(); this._progressBarRenderer = cc.Sprite.create(); } diff --git a/moduleConfig.json b/moduleConfig.json index 4b258aa6c8..e40302f7dc 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -232,8 +232,6 @@ "text-input", "menus", "tilemap", "parallax", "audio" ], - - "ccbreader" : [ "core", "audio", "gui", "menus", "particle", "actions", "labels", @@ -261,10 +259,11 @@ "extensions/ccpool/CCPool.js" ], "ccui" : [ - "core", "gui", "actions", "labels", "text-input","clipping-nodes", + "core", "actions", "labels", "text-input","clipping-nodes", "extensions/ccui/base-classes/CCProtectedNode.js", "extensions/ccui/system/CocosGUI.js", "extensions/ccui/base-classes/UIWidget.js", + "extensions/ccui/base-classes/UIScale9Sprite.js", "extensions/ccui/layouts/UILayout.js", "extensions/ccui/layouts/UILayoutParameter.js", "extensions/ccui/layouts/UILayoutManager.js", diff --git a/tools/build.xml b/tools/build.xml index c183315327..28f22b30ec 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -164,6 +164,7 @@ + diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml index 7989e11b42..40a9db45e4 100644 --- a/tools/jsdoc_toolkit/build.xml +++ b/tools/jsdoc_toolkit/build.xml @@ -139,6 +139,7 @@ + From 83b2f5f5d0fe0bbbe11e46f73571a55e9bc22644 Mon Sep 17 00:00:00 2001 From: Yang Yuchen Date: Thu, 21 Aug 2014 19:58:28 +0800 Subject: [PATCH 0489/1564] Detect the mouse in the touch screen tablet On a touch screen tablet(eg. Surface Pro) when using the web browser will be unable to detect the mouse, and when using the touch screen, the system will automatically block mouse. So do not have to deliberately blocked mouse. --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 696cc41bf6..cfb46436f7 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1422,7 +1422,7 @@ cc._initSys = function (config, CONFIG_KEY) { capabilities["opengl"] = true; if (docEle['ontouchstart'] !== undefined || nav.msPointerEnabled) capabilities["touches"] = true; - else if (docEle['onmouseup'] !== undefined) + if (docEle['onmouseup'] !== undefined) capabilities["mouse"] = true; if (docEle['onkeyup'] !== undefined) capabilities["keyboard"] = true; From 4344f6484a53a70cbdb1b9c9c77c4721518d953e Mon Sep 17 00:00:00 2001 From: mutoo Date: Fri, 22 Aug 2014 11:12:07 +0800 Subject: [PATCH 0490/1564] fix ui animation does not easing issue; --- extensions/cocostudio/action/CCActionFrame.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index b1c8a1cb54..b9f6d133a6 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -222,7 +222,7 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ } }, setEasingType: function(easingType){ - this._easingType = easingType; + this.easingType = easingType; } }); From 262bfbfaf1a0c0b736124d8ccef51a88c4a3b3e6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 22 Aug 2014 14:00:13 +0800 Subject: [PATCH 0491/1564] Issue #5830: add jsDoc to cc.ProtectedNode and ccui.Widget --- cocos2d/core/base-nodes/CCNode.js | 4 +- .../ccui/base-classes/CCProtectedNode.js | 68 ++++- extensions/ccui/base-classes/UIWidget.js | 266 ++++++++++++++---- moduleConfig.json | 2 +- 4 files changed, 279 insertions(+), 61 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b1170294e0..18be6ed605 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1464,7 +1464,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Event callback that is invoked every time when CCNode enters the 'stage'.
    * If the CCNode enters the 'stage' with a transition, this event is called when the transition starts.
    * During onEnter you can't access a "sister/brother" node.
    - * If you override onEnter, you shall call its parent's one, e.g., CCNode::onEnter(). + * If you override onEnter, you shall call its parent's one, e.g., this._super(); *

    */ onEnter: function () { @@ -1478,7 +1478,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ *

    * Event callback that is invoked when the CCNode enters in the 'stage'.
    * If the CCNode enters the 'stage' with a transition, this event is called when the transition finishes.
    - * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. CCNode::onEnterTransitionDidFinish() + * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. this._super(); *

    */ onEnterTransitionDidFinish: function () { diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 6f8e07b8fd..7e70e07ebf 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -37,14 +37,20 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ child._setLocalZOrder(z); }, + /** + * Constructor + * @function + */ ctor: function(){ cc.Node.prototype.ctor.call(this); this._protectedChildren = []; }, /** - * Adds a child to the container with z order and tag - * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. + *

    + * Adds a child to the container with z order and tag
    + * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
    + *

    * @param {cc.Node} child A child node * @param {Number} [localZOrder] Z order for drawing priority. Please refer to `setLocalZOrder(int)` * @param {Number} [tag] An integer to identify the node easily. Please refer to `setTag(int)` @@ -119,7 +125,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ }, /** - * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter + * Removes a child from the container by tag value.
    + * It will also cleanup all running actions depending on the cleanup parameter * @param {Number} tag * @param {Boolean} [cleanup=true] */ @@ -220,6 +227,11 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } }, + /** + * transforms and draws itself, and visit its children and protected children. + * @override + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx context of renderer + */ visit: null, _visitForCanvas: function(ctx){ @@ -257,12 +269,10 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ _t.draw(context); - for (; i < childLen; i++) { + for (; i < childLen; i++) children[i] && children[i].visit(context); - } - for (; j < pLen; j++) { + for (; j < pLen; j++) locProtectedChildren[j] && locProtectedChildren[j].visit(context); - } this._cacheDirty = false; _t.arrivalOrder = 0; @@ -322,6 +332,10 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ currentStack.top = currentStack.stack.pop(); }, + /** + * Stops itself and its children and protected children's all running actions and schedulers + * @override + */ cleanup: function(){ cc.Node.prototype.cleanup.call(this); var locChildren = this._protectedChildren; @@ -329,6 +343,10 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren[i].cleanup(); }, + /** + * Calls its parent's onEnter and calls its protected children's onEnter + * @override + */ onEnter: function(){ cc.Node.prototype.onEnter.call(this); var locChildren = this._protectedChildren; @@ -342,6 +360,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ * If the Node enters the 'stage' with a transition, this event is called when the transition finishes.
    * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish() *

    + * @override */ onEnterTransitionDidFinish: function(){ cc.Node.prototype.onEnterTransitionDidFinish.call(this); @@ -350,6 +369,10 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren[i].onEnterTransitionDidFinish(); }, + /** + * Calls its parent's onExit and calls its protected children's onExit + * @override + */ onExit:function(){ cc.Node.prototype.onExit.call(this); var locChildren = this._protectedChildren; @@ -370,6 +393,11 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren[i].onExitTransitionDidStart(); }, + /** + * Updates itself and its protected children displayed opacity, if opacity cascade is enable, its children also update. + * @param {Number} parentOpacity + * @override + */ updateDisplayedOpacity: function(parentOpacity){ this._displayedOpacity = this._realOpacity * parentOpacity/255.0; this._updateColor(); @@ -389,6 +417,11 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } }, + /** + * Updates itself and its protected children displayed color, if opacity cascade is enable, its children also update. + * @param {cc.Color} parentColor + * @override + */ updateDisplayedColor: function(parentColor){ var displayedColor = this._displayedColor, realColor = this._realColor; displayedColor.r = realColor.r * parentColor.r/255.0; @@ -412,7 +445,25 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } }, - disableCascadeColor: function(){ + _disableCascadeOpacity: function () { + this._displayedOpacity = this._realOpacity; + + var selChildren = this._children, i, item; + for (i = 0; i < selChildren.length; i++) { + item = selChildren[i]; + if (item) + item.updateDisplayedOpacity(255); + } + + selChildren = this._protectedChildren; + for (i = 0; i < selChildren.length; i++) { + item = selChildren[i]; + if (item) + item.updateDisplayedOpacity(255); + } + }, + + _disableCascadeColor: function(){ var white = cc.color.WHITE; var i, len, locChildren = this._children; for(i = 0, len = locChildren.length; i < len; i++) @@ -433,6 +484,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { /** * create a cc.ProtectedNode object; * @deprecated + * @return cc.ProtectedNode */ cc.ProtectedNode.create = function(){ return new cc.ProtectedNode(); diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 1fb8d19b58..c9560f07bb 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.Widget + * The base class for ccui controls and layout * @sample * var uiWidget = ccui.Widget.create(); * this.addChild(uiWidget); @@ -35,7 +35,7 @@ * @property {Number} yPercent - Position y in percentage of height * @property {Number} widthPercent - Width in percentage of parent width * @property {Number} heightPercent - Height in percentage of parent height - * @property {ccui.Widget} widgetParent - <@readonly> The direct parent when it's a widget also, otherwise equals null + * @property {ccui.Widget} widgetParent - <@readonly> The direct parent when it's a widget also, otherwise equals null * @property {Boolean} enabled - Indicate whether the widget is enabled * @property {Boolean} focused - Indicate whether the widget is focused * @property {ccui.Widget.SIZE_ABSOLUTE|ccui.Widget.SIZE_PERCENT} sizeType - The size type of the widget @@ -89,6 +89,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _touchEventCallback: null, + /** + * Constructor + * @function + */ ctor: function () { cc.ProtectedNode.prototype.ctor.call(this); this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; @@ -127,16 +131,29 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return false; }, + /** + * Calls updateSizeAndPosition and its parent's onEnter + * @override + */ onEnter: function () { this.updateSizeAndPosition(); cc.ProtectedNode.prototype.onEnter.call(this); }, + /** + * Calls unscheduleUpdate and its parent's onExit + * @override + */ onExit: function(){ this.unscheduleUpdate(); cc.ProtectedNode.prototype.onExit.call(this); }, + /** + * Calls _adaptRenderers(its subClass will override it) before calls its parent's visit. + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx + * @override + */ visit: function (ctx) { if (this._visible) { this._adaptRenderers(); @@ -144,6 +161,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, + /** + * The direct parent when it's a widget also, otherwise equals null + * @returns {ccui.Widget|null} + */ getWidgetParent: function () { var widget = this.getParent(); if (widget instanceof ccui.Widget) @@ -217,6 +238,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _initRenderer: function () { }, + /** + * Sets _customSize of ccui.Widget, if ignoreSize is true, the content size is its renderer's contentSize, otherwise the content size is parameter. + * and updates size percent by parent content size. At last, updates its children's size and position. + * @param {cc.Size|Number} contentSize content size or width of content size + * @param {Number} [height] + * @override + */ setContentSize: function(contentSize, height){ var locWidth = (height === undefined) ? contentSize.width : contentSize; var locHeight = (height === undefined) ? contentSize.height : height; @@ -266,7 +294,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Changes the percent that is widget's percent size - * @param {cc.Point} percent that is widget's percent size + * @param {cc.Point} percent that is widget's percent size, width and height value from 0 to 1. */ setSizePercent: function (percent) { this._sizePercent.x = percent.x; @@ -319,7 +347,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * update size and position + * updates its size by size type and its position by position type. * @param {cc.Size} [parentSize] parent size */ updateSizeAndPosition: function (parentSize) { @@ -407,7 +435,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * Gets the widget if is ignore it's size. + * Gets whether ignore the content size (custom size) * @returns {boolean} true that widget will ignore it's size, use texture size, false otherwise. */ isIgnoreContentAdaptWithSize: function () { @@ -415,19 +443,23 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * Get custom size of widget + * Get custom size of ccui.Widget * @returns {cc.Size} */ getCustomSize: function () { return cc.size(this._customSize); }, + /** + * Gets layout size of ccui.Widget. + * @returns {cc.Size} + */ getLayoutSize: function(){ return cc.size(this._contentSize); }, /** - * Returns size percent of widget + * Returns size percent of ccui.Widget * @returns {cc.Point} */ getSizePercent: function () { @@ -441,8 +473,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * Gets world position of widget. - * @returns {cc.Point} world position of widget. + * Gets world position of ccui.Widget. + * @returns {cc.Point} world position of ccui.Widget. */ getWorldPosition: function () { return this.convertToWorldSpace(cc.p(this._anchorPoint.x * this._contentSize.width, this._anchorPoint.y * this._contentSize.height)); @@ -499,7 +531,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * To set the bright style of widget. + * Returns whether or not touch is enabled. * @returns {boolean} true if the widget is touch enabled, false if the widget is touch disabled. */ isTouchEnabled: function () { @@ -547,9 +579,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ setFocused: function (focus) { this._focused = focus; //make sure there is only one focusedWidget - if (focus) { + if (focus) ccui.Widget._focusedWidget = this; - } }, /** @@ -587,9 +618,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (isLayout) return current.findNextFocusedWidget(direction, current); return current; - } else { + } else return layout.findNextFocusedWidget(direction, current); - } } else return current; } else { @@ -637,7 +667,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ onNextFocusedWidget: null, /** - * Sends the touch event to widget's parent + * Sends the touch event to widget's parent, its subclass will override it, e.g. ccui.ScrollView, ccui.PageView * @param {Number} eventType * @param {ccui.Widget} sender * @param {cc.Touch} touch @@ -657,7 +687,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ //only change focus when there is indeed a get&lose happens if (widgetLostFocus) widgetLostFocus.setFocused(false); - if (widgetGetFocus) widgetGetFocus.setFocused(true); }, @@ -675,10 +704,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (widgetGetFocus != widgetLostFocus){ if (widgetGetFocus && widgetGetFocus.onFocusChanged) widgetGetFocus.onFocusChanged(widgetLostFocus, widgetGetFocus); - if (widgetLostFocus && widgetGetFocus.onFocusChanged) widgetLostFocus.onFocusChanged(widgetLostFocus, widgetGetFocus); - cc.eventManager.dispatchEvent(new cc.EventFocus(widgetLostFocus, widgetGetFocus)); } }, @@ -692,13 +719,12 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (this._bright) { this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL); - } else { + } else this.onPressStateChangedToDisabled(); - } }, /** - * To set the bright style of widget. + * To set the bright style of ccui.Widget. * @param {Number} style BRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state. */ setBrightStyle: function (style) { @@ -720,7 +746,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * call back function called widget's state changed to normal. + * The call back function is calling when widget's state changed to normal. */ onPressStateChangedToNormal: function () { }, @@ -743,6 +769,21 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ didNotSelectSelf: function () { }, + /** + *

    + * The callback of touch began event.
    + * If the bounding box of ccui.Widget contains the touch point, it will do the following things:
    + * 1. sets highlight state,
    + * 2. sends event to parent widget by interceptTouchEvent
    + * 3. calls the callback of touch began event.
    + * 4. returns true,
    + * otherwise returns false directly.
    + *

    + * @override + * @param {cc.Touch} touch + * @param {cc.Event} event + * @returns {boolean} + */ onTouchBegan: function (touch, event) { this._hit = false; if (this.isVisible() && this.isEnabled() && this._isAncestorsEnabled() && this._isAncestorsVisible(this) ){ @@ -763,6 +804,14 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return true; }, + /** + *

    + * The callback of touch moved event.
    + * It sets the highlight state by touch, sends event to parent widget by interceptTouchEvent and calls the callback of touch moved event. + *

    + * @param {cc.Touch} touch + * @param {cc.Event} event + */ onTouchMoved: function (touch, event) { var touchPoint = touch.getLocation(); this._touchMovePosition.x = touchPoint.x; @@ -774,6 +823,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._moveEvent(); }, + /** + *

    + * The callback of touch end event + * It sends event to parent widget by interceptTouchEvent, + * calls the callback of touch end event (highlight= true) or touch canceled event (highlight= false). + * sets the highlight state to false , + *

    + * @param touch + * @param event + */ onTouchEnded: function (touch, event) { var touchPoint = touch.getLocation(); this._touchEndPosition.x = touchPoint.x; @@ -836,11 +895,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, longClickEvent: function () { - + //TODO it will implement in v3.1 }, /** - * Sets the touch event target/selector of the menu item + * Sets the touch event target/selector of the ccui.Widget * @param {Function} selector * @param {Object} target */ @@ -863,6 +922,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return cc.rectContainsPoint(bb, this.convertToNodeSpace(pt)); }, + /** + * returns whether clipping parent widget contains point. + * @param {cc.Point} pt location point + * @returns {Boolean} + */ isClippingParentContainsPoint: function(pt){ this._affectByClipping = false; var parent = this.getParent(); @@ -890,21 +954,21 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * Sends the touch event to widget's parent + * Calls the checkChildInfo of widget's parent, its subclass will override it. * @param {number} handleState * @param {ccui.Widget} sender * @param {cc.Point} touchPoint */ checkChildInfo: function (handleState, sender, touchPoint) { var widgetParent = this.getWidgetParent(); - if (widgetParent) { + if (widgetParent) widgetParent.checkChildInfo(handleState, sender, touchPoint); - } }, /** * Changes the position (x,y) of the widget . * The original point (0,0) is at the left-bottom corner of screen. + * @override * @param {cc.Point|Number} pos * @param {Number} [posY] */ @@ -1125,32 +1189,28 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return this.getBottomBoundary() + this._contentSize.height; }, + /** + * Gets the position of touch began event. + * @returns {cc.Point} + */ getTouchBeganPosition: function(){ return cc.p(this._touchBeganPosition); }, - getTouchMovePosition: function(){ - return cc.p(this._touchMovePosition); - }, - - getTouchEndPosition:function(){ - return cc.p(this._touchEndPosition); - }, - /** - * Sets the name of widget - * @param {String} name + * Gets the position of touch moved event + * @returns {cc.Point} */ - setName: function (name) { - this._name = name; + getTouchMovePosition: function(){ + return cc.p(this._touchMovePosition); }, /** - * Gets the name of widget - * @returns {string} + * Gets the position of touch end event + * @returns {cc.Point} */ - getName: function () { - return this._name; + getTouchEndPosition:function(){ + return cc.p(this._touchEndPosition); }, /** @@ -1190,6 +1250,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return "Widget"; }, + /** + * Clones a new widget. + * @returns {ccui.Widget} + */ clone: function () { var clonedWidget = this._createCloneInstance(); clonedWidget._copyProperties(this); @@ -1433,11 +1497,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ removeNodeByTag: function (tag, cleanup) { var node = this.getNodeByTag(tag); - if (!node) { + if (!node) cc.log("cocos2d: removeNodeByTag(tag = %d): child not found!", tag); - } else { + else this.removeNode(node); - } }, /** @@ -1458,14 +1521,12 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if(layout._doLayout){ layout._doLayoutDirty = true; break; - }else{ + }else layout = layout._parent; - } } }, _updateChildrenDisplayedRGBA: function(){ - this.setColor(this.getColor()); this.setOpacity(this.getOpacity()); } @@ -1537,45 +1598,150 @@ ccui.Widget.create = function () { ccui.Widget._focusedWidget = null; //both layout & widget will be stored in this variable +/** + * Gets the focused widget of current stage. + * @function + * @returns {null|ccui.Widget} + */ ccui.Widget.getCurrentFocusedWidget = function(){ return ccui.Widget._focusedWidget; }; // Constants //bright style +/** + * None bright style of ccui.Widget. + * @constant + * @type {number} + */ ccui.Widget.BRIGHT_STYLE_NONE = -1; +/** + * Normal bright style of ccui.Widget. + * @constant + * @type {number} + */ ccui.Widget.BRIGHT_STYLE_NORMAL = 0; +/** + * Light bright style of ccui.Widget. + * @constant + * @type {number} + */ ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT = 1; //widget type +/** + * The type code of Widget for ccui controls. + * @constant + * @type {number} + */ ccui.Widget.TYPE_WIDGET = 0; +/** + * The type code of Container for ccui controls. + * @constant + * @type {number} + */ ccui.Widget.TYPE_CONTAINER = 1; //Focus Direction +/** + * The left of Focus direction for ccui.Widget + * @constant + * @type {number} + */ ccui.Widget.LEFT = 0; +/** + * The right of Focus direction for ccui.Widget + * @constant + * @type {number} + */ ccui.Widget.RIGHT = 1; +/** + * The up of Focus direction for ccui.Widget + * @constant + * @type {number} + */ ccui.Widget.UP = 0; +/** + * The down of Focus direction for ccui.Widget + * @constant + * @type {number} + */ ccui.Widget.DOWN = 1; //texture resource type +/** + * The image file texture type of ccui.Widget loads. + * @constant + * @type {number} + */ ccui.Widget.LOCAL_TEXTURE = 0; +/** + * The sprite frame texture type of ccui.Widget loads. + * @constant + * @type {number} + */ ccui.Widget.PLIST_TEXTURE = 1; //touch event type +/** + * The touch began type of ccui.Widget's touch event + * @constant + * @type {number} + */ ccui.Widget.TOUCH_BEGAN = 0; +/** + * The touch moved type of ccui.Widget's touch event + * @constant + * @type {number} + */ ccui.Widget.TOUCH_MOVED = 1; +/** + * The touch end type of ccui.Widget's touch event + * @constant + * @type {number} + */ ccui.Widget.TOUCH_ENDED = 2; +/** + * The touch canceled type of ccui.Widget's touch event + * @constant + * @type {number} + */ ccui.Widget.TOUCH_CANCELED = 3; //size type +/** + * The absolute of ccui.Widget's size type. + * @constant + * @type {number} + */ ccui.Widget.SIZE_ABSOLUTE = 0; +/** + * The percent of ccui.Widget's size type. + * @constant + * @type {number} + */ ccui.Widget.SIZE_PERCENT = 1; //position type +/** + * The absolute of ccui.Widget's position type. + * @constant + * @type {number} + */ ccui.Widget.POSITION_ABSOLUTE = 0; +/** + * The percent of ccui.Widget's position type. + * @constant + * @type {number} + */ ccui.Widget.POSITION_PERCENT = 1; -cc.EventFocus = cc.Event.extend({ +/** + * The widget focus event. + * @class + * @extends cc.Event + */ +cc.EventFocus = cc.Event.extend(/** @lends cc.EventFocus# */{ _widgetGetFocus: null, _widgetLoseFocus: null, ctor: function(widgetLoseFocus, widgetGetFocus){ diff --git a/moduleConfig.json b/moduleConfig.json index e40302f7dc..1f8693b00b 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -254,7 +254,7 @@ "extensions/editbox/CCEditBox.js" ], "ccpool" : [ - "core", "gui", + "core", "extensions/ccpool/CCPool.js" ], From 392bbf9445aaba48c96a440700889cd179ec8297 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 22 Aug 2014 14:52:57 +0800 Subject: [PATCH 0492/1564] Test renderTexture setColor function --- template/src/myApp.js | 66 ++++++++++++++++++++++++++++++++++++++++ template/src/resource.js | 1 + 2 files changed, 67 insertions(+) diff --git a/template/src/myApp.js b/template/src/myApp.js index ec63dece90..3b1b22cd3f 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -1,3 +1,61 @@ +cc.Sprite.prototype.setBorder = function(cr, cg, cb, ca , r, f){ + var _dfc = cc.color.WHITE; + r = r || (arguments.length == 2 ? cg : 5); + f = f || 1;//精细度 + switch (arguments.length){ + case 0: cr = _dfc.r; cg = _dfc.g; cb = _dfc.b; ca = _dfc.a; break; + case 1: + case 2: cg = cr.g; cb = cr.b; ca = cr.a; cr = cr.r; break; + case 3: ca = _dfc.a; break; + } + var that = this, + x = that.x, y = that.y, + w = that.width, h = that.height, + dc = cc.size(w + r, h + r); + that.removeBorder(); + + var mTxt = new cc.RenderTexture(dc.width, dc.height), + cx = 0, ox = dc.width / 2, oy = dc.height / 2; + + var visitSprite = function(xx, yy){ + if(cc.sys.isNative){ + var spr = new cc.Sprite(that.getTexture()); + spr.attr({x : xx, y : yy, width : w, height : h}); + spr.visit(); + } else { + that.setPosition(xx, yy); + that.visit(); + } + }; + + mTxt.beginWithClear(0, 0, 0, 0); + for(var rd = 0; rd <= r; rd += f){ + cx = Math.sqrt(Math.pow(r, 2) - Math.pow(rd, 2)); + visitSprite(ox + rd, oy + cx); + visitSprite(ox - rd, oy + cx); + visitSprite(ox - rd, oy - cx); + visitSprite(ox + rd, oy - cx); + } + mTxt.end(); + that.setPosition(x, y); + + var nTxt = new cc.RenderTexture(dc.width, dc.height); + nTxt.setPosition(w / 2, h / 2); + + mTxt.setPosition(ox, oy); + mTxt.getSprite().setBlendFunc(cc.ZERO, cc.SRC_ALPHA); + nTxt.beginWithClear(cr, cg, cb, ca); + mTxt.visit(); + nTxt.end(); + + that.addChild(that.borderTex = nTxt, -1); + return nTxt; +}; + +cc.Sprite.prototype.removeBorder = function(){ + this.borderTex && this.borderTex.removeFromParent(true); +}; + var MyLayer = cc.Layer.extend({ helloLabel:null, sprite:null, @@ -44,6 +102,14 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height/this.sprite.getContentSize().height); this.addChild(this.sprite, 0); + + var hair = new cc.Sprite("style3.png"); + hair.setPosition(size.width / 2, size.height / 2); + this.addChild(hair, 10); + + //hair.setColor(cc.color.RED); + + window.hair = hair; } }); diff --git a/template/src/resource.js b/template/src/resource.js index 94284083d1..1e3eebe017 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -6,6 +6,7 @@ var g_resources = [ //image s_HelloWorld, s_CloseNormal, + "style3.png", s_CloseSelected //plist From eb19ec9369e053ae0f5dc4d54b5532ed1a063ba6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 22 Aug 2014 16:19:16 +0800 Subject: [PATCH 0493/1564] Issue #5829: Actions jsdoc --- cocos2d/actions/CCAction.js | 237 ++-- cocos2d/actions/CCActionCamera.js | 39 +- cocos2d/actions/CCActionCatmullRom.js | 124 +- cocos2d/actions/CCActionEase.js | 1599 +++++++++++++++++++------ cocos2d/actions/CCActionInstant.js | 258 +++- cocos2d/actions/CCActionInterval.js | 559 ++++++--- cocos2d/actions/CCActionTween.js | 31 +- 7 files changed, 2133 insertions(+), 714 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index c9e0df1142..85e99a66df 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -27,12 +27,14 @@ /** Default Action tag * @constant * @type {Number} + * @default */ cc.ACTION_TAG_INVALID = -1; /** * Base class for cc.Action objects. * @class + * * @extends cc.Class * * @property {cc.Node} target - The target will be set with the 'startWithTarget' method. When the 'stop' method is called, target will be set to nil. @@ -46,6 +48,10 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ tag:cc.ACTION_TAG_INVALID, //**************Public Functions*********** + + /** + * Constructor of cc.Action. + */ ctor:function () { this.originalTarget = null; this.target = null; @@ -54,8 +60,10 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ /** * to copy object with deep copy. - * @deprecated - * @return {object} + * + * @deprecated since v3.0 + * + * @return {cc.Action} */ copy:function () { cc.log("copy is deprecated. Please use clone instead."); @@ -63,7 +71,9 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ }, /** - * returns a clone of action + * to copy object with deep copy. + * returns a clone of action. + * * @return {cc.Action} */ clone:function () { @@ -75,7 +85,8 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ }, /** - * return true if the action has finished + * return true if the action has finished. + * * @return {Boolean} */ isDone:function () { @@ -84,6 +95,7 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ /** * called before the action start. It will also set the target. + * * @param {cc.Node} target */ startWithTarget:function (target) { @@ -92,35 +104,34 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ }, /** - * called after the action has finished. It will set the 'target' to nil. + * called after the action has finished. It will set the 'target' to nil.
    * IMPORTANT: You should never call "action stop" manually. Instead, use: "target.stopAction(action);" */ stop:function () { this.target = null; }, - /** called every frame with it's delta time. DON'T override unless you know what you are doing. + + /** + * called every frame with it's delta time.
    + * DON'T override unless you know what you are doing. * * @param {Number} dt */ - step:function (dt) { cc.log("[Action step]. override me"); }, /** -

    called once per frame. time a value between 0 and 1

    - -

    For example:
    - - 0 means that the action just started
    - - 0.5 means that the action is in the middle
    - - 1 means that the action is over

    - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { + update:function (dt) { cc.log("[Action update]. override me"); }, /** + * get the target. * * @return {cc.Node} */ @@ -128,7 +139,8 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ return this.target; }, - /** The action will modify the target properties. + /** + * The action will modify the target properties. * * @param {cc.Node} target */ @@ -137,6 +149,7 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ }, /** + * get the original target. * * @return {cc.Node} */ @@ -144,7 +157,8 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ return this.originalTarget; }, - /** Set the original target, since target can be nil.
    + /** + * Set the original target, since target can be nil.
    * Is the target that were used to run the action.
    * Unless you are doing something complex, like cc.ActionManager, you should NOT call this method.
    * The target is 'assigned', it is not 'retained'.
    @@ -155,7 +169,7 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ }, /** - * + * get tag number. * @return {Number} */ getTag:function () { @@ -163,49 +177,62 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ }, /** - * + * set tag number. * @param {Number} tag */ setTag:function (tag) { this.tag = tag; }, + /** - * Currently JavaScript Bindigns (JSB), in some cases, needs to use retain and release. This is a bug in JSB, - * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. - * This is a hack, and should be removed once JSB fixes the retain/release bug + * Currently JavaScript Bindigns (JSB), in some cases, needs to use retain and release. This is a bug in JSB,
    + * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB.
    + * This is a hack, and should be removed once JSB fixes the retain/release bug. */ retain:function () { }, + + /** + * Currently JavaScript Bindigns (JSB), in some cases, needs to use retain and release. This is a bug in JSB,
    + * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB.
    + * This is a hack, and should be removed once JSB fixes the retain/release bug. + */ release:function () { } }); -/** Allocates and initializes the action - * @function - * @returns {cc.Action} + +/** + * Allocates and initializes the action. + * + * @function cc.action + * @static + * @return {cc.Action} + * * @example - * // example + * // return {cc.Action} * var action = cc.action(); */ cc.action = function () { return new cc.Action(); }; + /** - * Please use cc.action instead - * Allocates and initializes the action - * @returns {cc.Action} - * @example + * Please use cc.action instead.
    + * Allocates and initializes the action. + * + * @deprecated since v3.0 * @static - * @deprecated + * @returns {cc.Action} */ cc.Action.create = cc.action; /** - *

    Base class actions that do have a finite time duration.
    + * Base class actions that do have a finite time duration.
    * Possible actions:
    - * - An action with a duration of 0 seconds
    - * - An action with a duration of 35.5 seconds

    - + * - An action with a duration of 0 seconds.
    + * - An action with a duration of 35.5 seconds. + * * Infinite time actions are valid * @class * @extends cc.Action @@ -214,12 +241,16 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ //! duration in seconds _duration:0, + /** + * Constructor of cc.FiniteTimeAction. + */ ctor:function () { cc.Action.prototype.ctor.call(this); this._duration = 0; }, - /** get duration in seconds of the action + /** + * get duration of the action. (seconds) * * @return {Number} */ @@ -227,7 +258,8 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ return this._duration * (this._times || 1); }, - /** set duration in seconds of the action + /** + * set duration of the action. (seconds) * * @param {Number} duration */ @@ -235,7 +267,12 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ this._duration = duration; }, - /** returns a reversed action + /** + * Returns a reversed action.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten * * @return {Null} */ @@ -245,7 +282,10 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ }, /** + * to copy object with deep copy. + * returns a clone of action. * + * @return {cc.FiniteTimeAction} */ clone:function () { return new cc.FiniteTimeAction(); @@ -253,9 +293,10 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ }); /** - * Changes the speed of an action, making it take longer (speed>1) - * or less (speed<1) time.
    + * Changes the speed of an action, making it take longer (speed > 1) + * or less (speed < 1) time.
    * Useful to simulate 'slow motion' or 'fast forward' effect. + * * @warning This action can't be Sequenceable because it is not an cc.IntervalAction * @class * @extends cc.Action @@ -265,7 +306,8 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ _innerAction:null, /** - * Constructor of cc.Speed + * Constructor of cc.Speed. + * * @param {cc.ActionInterval} action * @param {Number} speed */ @@ -278,20 +320,27 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** + * Gets the current running speed.
    + * Will get a percentage number, compared to the original speed. + * * @return {Number} */ getSpeed:function () { return this._speed; }, - /** alter the speed of the inner function in runtime + /** + * alter the speed of the inner function in runtime. + * * @param {Number} speed */ setSpeed:function (speed) { this._speed = speed; }, - /** initializes the action + /** + * initializes the action. + * * @param {cc.ActionInterval} action * @param {Number} speed * @return {Boolean} @@ -306,7 +355,9 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** - * returns a clone of action + * to copy object with deep copy. + * returns a clone of action. + * * @returns {cc.Speed} */ clone:function () { @@ -316,6 +367,8 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** + * called before the action start. It will also set the target. + * * @param {cc.Node} target */ startWithTarget:function (target) { @@ -324,7 +377,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** - * Stop the action + * Stop the action. */ stop:function () { this._innerAction.stop(); @@ -332,6 +385,9 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** + * called every frame with it's delta time.
    + * DON'T override unless you know what you are doing. + * * @param {Number} dt */ step:function (dt) { @@ -339,6 +395,8 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** + * return true if the action has finished. + * * @return {Boolean} */ isDone:function () { @@ -346,14 +404,20 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** + * returns a reversed action.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten + * * @return {cc.ActionInterval} */ reverse:function () { - return (cc.Speed.create(this._innerAction.reverse(), this._speed)); + return new cc.Speed(this._innerAction.reverse(), this._speed); }, /** - * + * Set inner Action. * @param {cc.ActionInterval} action */ setInnerAction:function (action) { @@ -363,6 +427,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ }, /** + * Get inner Action. * * @return {cc.ActionInterval} */ @@ -370,9 +435,11 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ return this._innerAction; } }); -/** creates the speed action - * @function + +/** + * creates the speed action. * + * @function cc.speed * @param {cc.ActionInterval} action * @param {Number} speed * @return {cc.Speed} @@ -380,26 +447,32 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ cc.speed = function (action, speed) { return new cc.Speed(action, speed); }; + /** - * Please use cc.speed instead - * creates the action + * Please use cc.speed instead. + * creates the action. * * @param {cc.ActionInterval} action * @param {Number} speed * @return {cc.Speed} * @static - * @deprecated + * @deprecated since v3.0 */ cc.Speed.create = cc.speed; /** * cc.Follow is an action that "follows" a node. - + * * @example * //example * //Instead of using cc.Camera as a "follower", use this action instead. * layer.runAction(cc.follow(hero)); - + * + * @property {Number} leftBoundary - world leftBoundary. + * @property {Number} rightBoundary - world rightBoundary. + * @property {Number} topBoundary - world topBoundary. + * @property {Number} bottomBoundary - world bottomBoundary. + * * @class * @extends cc.Action */ @@ -413,34 +486,21 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ // fast access to the screen dimensions _halfScreenSize:null, _fullScreenSize:null, + _worldRect:null, - /** world leftBoundary - * @Type {Number} - */ leftBoundary:0.0, - /** world rightBoundary - * @Type Number - */ rightBoundary:0.0, - /** world topBoundary - * @Type Number - */ topBoundary:0.0, - /** world bottomBoundary - * @Type {Number} - */ bottomBoundary:0.0, - _worldRect:null, /** - * creates the action with a set boundary
    - * creates the action with no boundary set + * creates the action with a set boundary.
    + * creates the action with no boundary set. * * Constructor of cc.Follow * @param {cc.Node} followedNode * @param {cc.Rect} rect * @example - * // example * // creates the action with a set boundary * var sprite = new cc.Sprite("spriteFileName"); * var followAction = new cc.Follow(sprite, cc.rect(0, 0, s.width * 2 - 100, s.height)); @@ -471,6 +531,12 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ : this.initWithTarget(followedNode); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.Follow} + */ clone:function () { var action = new cc.Follow(); var locRect = this._worldRect; @@ -480,21 +546,26 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ }, /** + * Get whether camera should be limited to certain area. + * * @return {Boolean} */ isBoundarySet:function () { return this._boundarySet; }, - /** alter behavior - turn on/off boundary + /** + * alter behavior - turn on/off boundary. + * * @param {Boolean} value */ setBoudarySet:function (value) { this._boundarySet = value; }, - /** initializes the action - * initializes the action with a set boundary + /** + * initializes the action with a set boundary. + * * @param {cc.Node} followedNode * @param {cc.Rect} [rect=] * @return {Boolean} @@ -540,6 +611,9 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ }, /** + * called every frame with it's delta time.
    + * DON'T override unless you know what you are doing. + * * @param {Number} dt */ step:function (dt) { @@ -560,6 +634,8 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ }, /** + * Return true if the action has finished. + * * @return {Boolean} */ isDone:function () { @@ -574,8 +650,11 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ cc.Action.prototype.stop.call(this); } }); -/** creates the action with a set boundary
    - * creates the action with no boundary set + +/** + * creates the action with a set boundary.
    + * creates the action with no boundary set. + * * @function * @param {cc.Node} followedNode * @param {cc.Rect} rect @@ -597,13 +676,13 @@ cc.follow = function (followedNode, rect) { }; /** - * Please use cc.follow instead - * creates the action with a set boundary
    - * creates the action with no boundary set + * Please use cc.follow instead. + * creates the action with a set boundary.
    + * creates the action with no boundary set. * @param {cc.Node} followedNode * @param {cc.Rect} rect * @return {cc.Follow|Null} returns the cc.Follow object on success * @static - * @deprecated + * @deprecated since v3.0 */ cc.Follow.create = cc.follow; diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 25275c9d74..97e3592b35 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -40,6 +40,9 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{ _upYOrig:0, _upZOrig:0, + /** + * Constructor of cc.ActionCamera. + */ ctor:function(){ var _t = this; cc.ActionInterval.prototype.ctor.call(_t); @@ -55,7 +58,11 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{ _t._upZOrig=0; }, - + /** + * called before the action start. It will also set the target. + * + * @param {cc.Node} target + */ startWithTarget:function (target) { var _t = this; cc.ActionInterval.prototype.startWithTarget.call(_t, target); @@ -78,13 +85,23 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{ }, /** + * to copy object with deep copy. * returns a new clone of the action + * * @returns {cc.ActionCamera} */ clone:function(){ return new cc.ActionCamera(); }, + /** + * returns a reversed action.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten + * + */ reverse:function () { return cc.reverseTime(this); } @@ -92,6 +109,7 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{ /** * Orbits the camera around the center of the screen using spherical coordinates + * * @class * @extends cc.ActionCamera */ @@ -180,6 +198,11 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ return {newRadius:newRadius, zenith:zenith, azimuth:azimuth}; }, + /** + * called before the action start. It will also set the target. + * + * @param {cc.Node} target + */ startWithTarget:function (target) { var _t = this; cc.ActionInterval.prototype.startWithTarget.call(_t, target); @@ -197,12 +220,23 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ _t._radX = cc.degreesToRadians(_t._angleX); }, + /** + * to copy object with deep copy. + * returns a new clone of the action + * + * @returns {cc.ActionCamera} + */ clone:function(){ var a = new cc.OrbitCamera(), _t = this; a.initWithDuration(_t._duration, _t._radius, _t._deltaRadius, _t._angleZ, _t._deltaAngleZ, _t._angleX, _t._deltaAngleX); return a; }, + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ update:function (dt) { dt = this._computeEaseTime(dt); var r = (this._radius + this._deltaRadius * dt) * cc.Camera.getZEye(); @@ -232,6 +266,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ cc.orbitCamera = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX) { return new cc.OrbitCamera(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX); }; + /** * Please use cc.orbitCamera instead * creates a cc.OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX @@ -244,6 +279,6 @@ cc.orbitCamera = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, * @param {Number} deltaAngleX * @return {cc.OrbitCamera} * @static - * @deprecated + * @deprecated since v3.0 */ cc.OrbitCamera.create = cc.orbitCamera; diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index b16b4a4e93..4296e92904 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -33,9 +33,10 @@ ****************************************************************************/ /** - *

    Returns the Cardinal Spline position for a given set of control points, tension and time CatmullRom Spline formula:
    - * s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt - tt)P4 - *

    + * Returns the Cardinal Spline position for a given set of control points, tension and time.
    + * CatmullRom Spline formula.
    + * s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt - tt)P4 + * * @function * @param {cc.Point} p0 * @param {cc.Point} p1 @@ -64,9 +65,9 @@ cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) { return cc.p(x, y); }; - /** * returns a new copy of the array reversed. + * * @return {Array} */ cc.reverseControlPoints = function (controlPoints) { @@ -77,15 +78,32 @@ cc.reverseControlPoints = function (controlPoints) { return newArray; }; -cc.copyControlPoints = function (controlPoints) { + +/** + * returns a new clone of the controlPoints + * + * @param controlPoints + * @returns {Array} + */ +cc.cloneControlPoints = function (controlPoints) { var newArray = []; for (var i = 0; i < controlPoints.length; i++) newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y)); return newArray; }; +/** + * returns a new clone of the controlPoints + * + * @deprecated since v3.0 + * @param controlPoints + * @returns {Array} + */ +cc.copyControlPoints = cc.cloneControlPoints; + /** * returns a point from the array + * * @param {Array} controlPoints * @param {Number} pos * @return {Array} @@ -96,7 +114,9 @@ cc.getControlPointAt = function (controlPoints, pos) { }; /** - * reverse the current control point array inline, without generating a new one + * reverse the current control point array inline, without generating a new one
    + * + * @param controlPoints */ cc.reverseControlPointsInline = function (controlPoints) { var len = controlPoints.length; @@ -110,7 +130,9 @@ cc.reverseControlPointsInline = function (controlPoints) { /** - * Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline + * Cardinal Spline path. {@link http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline} + * Absolute coordinates. + * * @class * @extends cc.ActionInterval * @@ -147,9 +169,11 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * /** * initializes the action with a duration and an array of points + * * @param {Number} duration * @param {Array} points array of control points * @param {Number} tension + * * @return {Boolean} */ initWithDuration:function (duration, points, tension) { @@ -166,6 +190,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * /** * returns a new clone of the action + * * @returns {cc.CardinalSplineTo} */ clone:function () { @@ -175,6 +200,8 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * }, /** + * called before the action start. It will also set the target. + * * @param {cc.Node} target */ startWithTarget:function (target) { @@ -186,23 +213,25 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); var p, lt; var ps = this._points; // eg. // p..p..p..p..p..p..p // 1..2..3..4..5..6..7 // want p to be 1, 2, 3, 4, 5, 6 - if (time == 1) { + if (dt == 1) { p = ps.length - 1; lt = 1; } else { var locDT = this._deltaT; - p = 0 | (time / locDT); - lt = (time - locDT * p) / locDT; + p = 0 | (dt / locDT); + lt = (dt - locDT * p) / locDT; } var newPos = cc.cardinalSplineAt( @@ -230,7 +259,9 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * }, /** - * reverse a new cc.CardinalSplineTo + * reverse a new cc.CardinalSplineTo.
    + * Along the track of movement in the opposite. + * * @return {cc.CardinalSplineTo} */ reverse:function () { @@ -240,6 +271,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * /** * update position of target + * * @param {cc.Point} newPos */ updatePosition:function (newPos) { @@ -249,6 +281,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * /** * Points getter + * * @return {Array} */ getPoints:function () { @@ -257,6 +290,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * /** * Points setter + * * @param {Array} points */ setPoints:function (points) { @@ -265,7 +299,8 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * }); /** - * creates an action with a Cardinal Spline array of points and tension + * creates an action with a Cardinal Spline array of points and tension. + * * @function * @param {Number} duration * @param {Array} points array of control points @@ -279,21 +314,25 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * cc.cardinalSplineTo = function (duration, points, tension) { return new cc.CardinalSplineTo(duration, points, tension); }; + /** - * Please use cc.cardinalSplineTo instead + * Please use cc.cardinalSplineTo instead.
    * creates an action with a Cardinal Spline array of points and tension + * * @function * @param {Number} duration * @param {Array} points array of control points * @param {Number} tension * @return {cc.CardinalSplineTo} * @static - * @deprecated + * @deprecated since v3.0 */ cc.CardinalSplineTo.create = cc.cardinalSplineTo; /** - * Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline + * Cardinal Spline path. {@link http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline} + * Relative coordinates. + * * @class * @extends cc.CardinalSplineTo * @@ -320,6 +359,8 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# }, /** + * called before the action start. It will also set the target. + * * @param {cc.Node} target */ startWithTarget:function (target) { @@ -330,6 +371,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# /** * reverse a new cc.CardinalSplineBy + * * @return {cc.CardinalSplineBy} */ reverse:function () { @@ -370,6 +412,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# /** * update position of target + * * @param {cc.Point} newPos */ updatePosition:function (newPos) { @@ -383,6 +426,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# /** * returns a new clone of the action + * * @returns {cc.CardinalSplineBy} */ clone:function () { @@ -393,35 +437,38 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# }); /** - * creates an action with a Cardinal Spline array of points and tension + * creates an action with a Cardinal Spline array of points and tension. + * * @function * @param {Number} duration * @param {Array} points * @param {Number} tension + * * @return {cc.CardinalSplineBy} */ cc.cardinalSplineBy = function (duration, points, tension) { return new cc.CardinalSplineBy(duration, points, tension); }; + /** - * Please use cc.cardinalSplineBy instead - * creates an action with a Cardinal Spline array of points and tension + * Please use cc.cardinalSplineBy instead. + * creates an action with a Cardinal Spline array of points and tension. * @function * @param {Number} duration * @param {Array} points * @param {Number} tension * @return {cc.CardinalSplineBy} * @static - * @deprecated + * @deprecated since v3.0 */ cc.CardinalSplineBy.create = cc.cardinalSplineBy; /** - *

    - * An action that moves the target with a CatmullRom curve to a destination point.
    - * A Catmull Rom is a Cardinal Spline with a tension of 0.5.
    - * http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline - *

    + * An action that moves the target with a CatmullRom curve to a destination point.
    + * A Catmull Rom is a Cardinal Spline with a tension of 0.5.
    + * {@link http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline} + * Absolute coordinates. + * * @class * @extends cc.CardinalSplineTo * @@ -447,7 +494,6 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{ /** * Initializes the action with a duration and an array of points * - * @function * @param {Number} dt * @param {Array} points */ @@ -467,7 +513,8 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{ }); /** - * creates an action with a Cardinal Spline array of points and tension + * creates an action with a Cardinal Spline array of points and tension. + * * @function * @param {Number} dt * @param {Array} points @@ -480,22 +527,23 @@ cc.catmullRomTo = function (dt, points) { return new cc.CatmullRomTo(dt, points); }; /** - * Please use cc.catmullRomTo instead - * creates an action with a Cardinal Spline array of points and tension + * Please use cc.catmullRomTo instead. + * creates an action with a Cardinal Spline array of points and tension. + * * @param {Number} dt * @param {Array} points * @return {cc.CatmullRomTo} * @static - * @deprecated + * @deprecated since v3.0 */ cc.CatmullRomTo.create = cc.catmullRomTo; /** - *

    - * An action that moves the target with a CatmullRom curve by a certain distance.
    - * A Catmull Rom is a Cardinal Spline with a tension of 0.5.
    - * http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline - *

    + * An action that moves the target with a CatmullRom curve by a certain distance.
    + * A Catmull Rom is a Cardinal Spline with a tension of 0.5.
    + * http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline + * Relative coordinates. + * * @class * @extends cc.CardinalSplineBy * @@ -557,6 +605,6 @@ cc.catmullRomBy = function (dt, points) { * Please use cc.catmullRomBy instead * Creates an action with a Cardinal Spline array of points and tension * @static - * @deprecated + * @deprecated since v3.0 */ cc.CatmullRomBy.create = cc.catmullRomBy; diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index bf3495072c..9dd9b140f8 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -29,7 +29,6 @@ * @class * @extends cc.ActionInterval */ - cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ _inner:null, @@ -47,7 +46,9 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ action && this.initWithAction(action); }, - /** initializes the action + /** + * initializes the action + * * @param {cc.ActionInterval} action * @return {Boolean} */ @@ -62,6 +63,12 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ return false; }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.ActionEase} + */ clone:function(){ var action = new cc.ActionEase(); action.initWithAction(this._inner.clone()); @@ -69,6 +76,8 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ }, /** + * called before the action start. It will also set the target. + * * @param {cc.Node} target */ startWithTarget:function (target) { @@ -85,25 +94,39 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ }, /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - this._inner.update(time1); + update:function (dt) { + this._inner.update(dt); }, /** + * Create new action to original operation effect opposite.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten * @return {cc.ActionInterval} */ reverse:function () { - return cc.ActionEase.create(this._inner.reverse()); + return new cc.ActionEase(this._inner.reverse()); }, + /** + * Get inner Action. + * + * @return {cc.ActionInterval} + */ getInnerAction:function(){ return this._inner; } }); -/** creates the action of ActionEase +/** + * creates the action of ActionEase + * * @param {cc.ActionInterval} action * @return {cc.ActionEase} * @example @@ -113,18 +136,21 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ cc.actionEase = function (action) { return new cc.ActionEase(action); }; + /** * Please use cc.actionEase instead * creates the action of ActionEase + * * @param {cc.ActionInterval} action * @return {cc.ActionEase} * @static - * @deprecated + * @deprecated since v3.0 */ cc.ActionEase.create = cc.actionEase; /** * Base class for Easing actions with rate parameters + * * @class * @extends cc.ActionEase */ @@ -148,7 +174,8 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ rate !== undefined && this.initWithAction(action, rate); }, - /** set rate value for the actions + /** + * set rate value for the actions * @param {Number} rate */ setRate:function (rate) { @@ -176,6 +203,12 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ return false; }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.ActionEase} + */ clone:function(){ var action = new cc.EaseRateAction(); action.initWithAction(this._inner.clone(), this._rate); @@ -183,14 +216,21 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ }, /** + * Create new action to original operation effect opposite.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten * @return {cc.EaseRateAction} */ reverse:function () { - return cc.EaseRateAction.create(this._inner.reverse(), 1 / this._rate); + return new cc.EaseRateAction(this._inner.reverse(), 1 / this._rate); } }); -/** Creates the action with the inner action and the rate parameter +/** + * Creates the action with the inner action and the rate parameter. + * * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseRateAction} @@ -201,37 +241,50 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ cc.easeRateAction = function (action, rate) { return new cc.EaseRateAction(action, rate); }; + /** - * Please use cc.easeRateAction instead - * Creates the action with the inner action and the rate parameter + * Please use cc.easeRateAction instead.
    + * Creates the action with the inner action and the rate parameter. + * * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseRateAction} * @static - * @deprecated + * @deprecated since v3.0 */ cc.EaseRateAction.create = cc.easeRateAction; /** - * cc.EaseIn action with a rate + * cc.EaseIn action with a rate. From slow to fast. + * * @class * @extends cc.EaseRateAction */ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ + /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - this._inner.update(Math.pow(time1, this._rate)); + update:function (dt) { + this._inner.update(Math.pow(dt, this._rate)); }, /** + * Create a cc.easeIn action. Opposite with the original motion trajectory. * @return {cc.EaseIn} */ reverse:function () { - return cc.EaseIn.create(this._inner.reverse(), 1 / this._rate); + return new cc.EaseIn(this._inner.reverse(), 1 / this._rate); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseIn} + */ clone:function(){ var action = new cc.EaseIn(); action.initWithAction(this._inner.clone(), this._rate); @@ -240,9 +293,14 @@ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ }); /** - * Creates the action with the inner action and the rate parameter + * Creates the action with the inner action and the rate parameter.
    + * From slow to fast. + * * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeIn instead. + * @example + * // example + * action.easing(cc.easeIn(3.0)); * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseIn} @@ -251,7 +309,10 @@ cc.EaseIn.create = function (action, rate) { return new cc.EaseIn(action, rate); }; -/** Creates the action easing object with the rate parameter +/** + * Creates the action easing object with the rate parameter.
    + * From slow to fast. + * * @function * @param {Number} rate * @return {Object} @@ -272,25 +333,34 @@ cc.easeIn = function (rate) { }; /** - * cc.EaseOut action with a rate + * cc.EaseOut action with a rate. From fast to slow. * @class * @extends cc.EaseRateAction */ cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - this._inner.update(Math.pow(time1, 1 / this._rate)); + update:function (dt) { + this._inner.update(Math.pow(dt, 1 / this._rate)); }, /** + * Create a cc.easeIn action. Opposite with the original motion trajectory. * @return {cc.EaseOut} */ reverse:function () { - return cc.EaseOut.create(this._inner.reverse(), 1 / this._rate); + return new cc.EaseOut(this._inner.reverse(), 1 / this._rate); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseOut} + */ clone:function(){ var action = new cc.EaseOut(); action.initWithAction(this._inner.clone(),this._rate); @@ -298,9 +368,15 @@ cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ } }); -/** Creates the action with the inner action and the rate parameter +/** + * Creates the action with the inner action and the rate parameter.
    + * From fast to slow. + * * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeOut instead. + * @example + * // example + * action.easing(cc.easeOut(3.0)); * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseOut} @@ -309,7 +385,10 @@ cc.EaseOut.create = function (action, rate) { return new cc.EaseOut(action, rate); }; -/** Creates the action easing object with the rate parameter +/** + * Creates the action easing object with the rate parameter.
    + * From fast to slow. + * * @function * @param {Number} rate * @return {Object} @@ -330,22 +409,31 @@ cc.easeOut = function (rate) { }; /** - * cc.EaseInOut action with a rate + * cc.EaseInOut action with a rate. + * Slow to fast then to slow. * @class * @extends cc.EaseRateAction */ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - time1 *= 2; - if (time1 < 1) - this._inner.update(0.5 * Math.pow(time1, this._rate)); + update:function (dt) { + dt *= 2; + if (dt < 1) + this._inner.update(0.5 * Math.pow(dt, this._rate)); else - this._inner.update(1.0 - 0.5 * Math.pow(2 - time1, this._rate)); + this._inner.update(1.0 - 0.5 * Math.pow(2 - dt, this._rate)); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseInOut} + */ clone:function(){ var action = new cc.EaseInOut(); action.initWithAction(this._inner.clone(), this._rate); @@ -353,16 +441,22 @@ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ }, /** + * Create a cc.EaseInOut action. Opposite with the original motion trajectory. * @return {cc.EaseInOut} */ reverse:function () { - return cc.EaseInOut.create(this._inner.reverse(), this._rate); + return new cc.EaseInOut(this._inner.reverse(), this._rate); } }); -/** Creates the action with the inner action and the rate parameter +/** + * Creates the action with the inner action and the rate parameter. + * Slow to fast then to slow. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeInOut instead. + * @example + * // example + * action.easing(cc.easeInOut(3.0)); * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseInOut} @@ -371,7 +465,9 @@ cc.EaseInOut.create = function (action, rate) { return new cc.EaseInOut(action, rate); }; -/** Creates the action easing object with the rate parameter +/** + * Creates the action easing object with the rate parameter. + * Slow to fast then to slow. * @function * @param {Number} rate * @return {Object} @@ -396,25 +492,36 @@ cc.easeInOut = function (rate) { }; /** - * cc.Ease Exponential In + * cc.Ease Exponential In. Slow to Fast.
    + * Reference easeInExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase */ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - this._inner.update(time1 === 0 ? 0 : Math.pow(2, 10 * (time1 - 1))); + update:function (dt) { + this._inner.update(dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1))); }, /** + * Create a cc.EaseExponentialOut action. Opposite with the original motion trajectory. * @return {cc.EaseExponentialOut} */ reverse:function () { - return cc.EaseExponentialOut.create(this._inner.reverse()); + return new cc.EaseExponentialOut(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseExponentialIn} + */ clone:function(){ var action = new cc.EaseExponentialIn(); action.initWithAction(this._inner.clone()); @@ -422,9 +529,15 @@ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ } }); -/** creates the action +/** + * Creates the action easing object with the rate parameter.
    + * Reference easeInExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeExponentialIn instead. + * @example + * // example + * action.easing(cc.easeExponentialIn()); * @param {cc.ActionInterval} action * @return {cc.EaseExponentialIn} */ @@ -441,7 +554,10 @@ cc._easeExponentialInObj = { } }; -/** creates the action easing object +/** + * Creates the action easing object with the rate parameter.
    + * Reference easeInExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @return {Object} * @example @@ -453,25 +569,36 @@ cc.easeExponentialIn = function(){ }; /** - * Ease Exponential Out + * Ease Exponential Out.
    + * Reference easeOutExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase */ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - this._inner.update(time1 == 1 ? 1 : (-(Math.pow(2, -10 * time1)) + 1)); + update:function (dt) { + this._inner.update(dt == 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1)); }, /** + * Create a cc.EaseExponentialIn action. Opposite with the original motion trajectory. * @return {cc.EaseExponentialIn} */ reverse:function () { - return cc.EaseExponentialIn.create(this._inner.reverse()); + return new cc.EaseExponentialIn(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseExponentialOut} + */ clone:function(){ var action = new cc.EaseExponentialOut(); action.initWithAction(this._inner.clone()); @@ -479,9 +606,15 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# * } }); -/** creates the action +/** + * Creates the action easing object with the rate parameter.
    + * Reference easeOutExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeExponentialOut instead. + * @example + * // example + * action.easing(cc.easeExponentialOut()); * @param {cc.ActionInterval} action * @return {cc.EaseExponentialOut} */ @@ -497,7 +630,12 @@ cc._easeExponentialOutObj = { return cc._easeExponentialInObj; } }; -/** creates the action easing object + +/** + * creates the action easing object.
    + * Reference easeOutExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * * @return {cc.EaseExponentialOut} * @example * // example @@ -508,32 +646,44 @@ cc.easeExponentialOut = function(){ }; /** - * Ease Exponential InOut + * Ease Exponential InOut.
    + * Reference easeInOutExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * * @class * @extends cc.ActionEase */ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOut# */{ /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { - if( time != 1 && time !== 0) { - time *= 2; - if (time < 1) - time = 0.5 * Math.pow(2, 10 * (time - 1)); + update:function (dt) { + if( dt != 1 && dt !== 0) { + dt *= 2; + if (dt < 1) + dt = 0.5 * Math.pow(2, 10 * (dt - 1)); else - time = 0.5 * (-Math.pow(2, -10 * (time - 1)) + 2); + dt = 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2); } - this._inner.update(time); + this._inner.update(dt); }, /** + * Create a cc.EaseExponentialInOut action. Opposite with the original motion trajectory. * @return {cc.EaseExponentialInOut} */ reverse:function () { - return cc.EaseExponentialInOut.create(this._inner.reverse()); + return new cc.EaseExponentialInOut(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseExponentialInOut} + */ clone:function(){ var action = new cc.EaseExponentialInOut(); action.initWithAction(this._inner.clone()); @@ -541,9 +691,15 @@ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOu } }); -/** creates an EaseExponentialInOut action +/** + * creates an EaseExponentialInOut action.
    + * Reference easeInOutExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeExponentialInOut instead. + * @example + * // example + * action.easing(cc.easeExponentialInOut()); * @param {cc.ActionInterval} action * @return {cc.EaseExponentialInOut} */ @@ -566,8 +722,11 @@ cc._easeExponentialInOutObj = { return cc._easeExponentialInOutObj; } }; + /** - * creates an EaseExponentialInOut action easing object + * creates an EaseExponentialInOut action easing object.
    + * Reference easeInOutExpo:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @return {Object} * @example @@ -579,26 +738,37 @@ cc.easeExponentialInOut = function(){ }; /** - * Ease Sine In + * Ease Sine In.
    + * Reference easeInSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase */ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - time1 = time1===0 || time1===1 ? time1 : -1 * Math.cos(time1 * Math.PI / 2) + 1; - this._inner.update(time1); + update:function (dt) { + dt = dt===0 || dt===1 ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1; + this._inner.update(dt); }, /** + * Create a cc.EaseSineOut action. Opposite with the original motion trajectory. * @return {cc.EaseSineOut} */ reverse:function () { - return cc.EaseSineOut.create(this._inner.reverse()); + return new cc.EaseSineOut(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseSineIn} + */ clone:function(){ var action = new cc.EaseSineIn(); action.initWithAction(this._inner.clone()); @@ -606,9 +776,15 @@ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ } }); -/** creates an EaseSineIn action +/** + * creates an EaseSineIn action.
    + * Reference easeInSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeSineIn instead. + * @example + * // example + * action.easing(cc.easeSineIn()); * @param {cc.ActionInterval} action * @return {cc.EaseSineIn} */ @@ -624,7 +800,10 @@ cc._easeSineInObj = { return cc._easeSineOutObj; } }; -/** creates an EaseSineIn action +/** + * creates an EaseSineIn action.
    + * Reference easeInSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @return {Object} * @example @@ -636,26 +815,37 @@ cc.easeSineIn = function(){ }; /** - * Ease Sine Out + * Ease Sine Out.
    + * Reference easeOutSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase */ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - time1 = time1===0 || time1===1 ? time1 : Math.sin(time1 * Math.PI / 2); - this._inner.update(time1); + update:function (dt) { + dt = dt===0 || dt===1 ? dt : Math.sin(dt * Math.PI / 2); + this._inner.update(dt); }, /** + * Create a cc.EaseSineIn action. Opposite with the original motion trajectory. * @return {cc.EaseSineIn} */ reverse:function () { - return cc.EaseSineIn.create(this._inner.reverse()); + return new cc.EaseSineIn(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseSineOut} + */ clone:function(){ var action = new cc.EaseSineOut(); action.initWithAction(this._inner.clone()); @@ -663,9 +853,15 @@ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ } }); -/** creates an EaseSineOut action +/** + * Creates an EaseSineOut action.
    + * Reference easeOutSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeSineOut instead. + * @example + * // example + * action.easing(cc.easeSineOut()); * @param {cc.ActionInterval} action * @return {cc.EaseSineOut} */ @@ -681,7 +877,11 @@ cc._easeSineOutObj = { return cc._easeSineInObj; } }; -/** creates an EaseSineOut action easing object + +/** + * Creates an EaseSineOut action easing object.
    + * Reference easeOutSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @return {Object} * @example @@ -693,19 +893,29 @@ cc.easeSineOut = function(){ }; /** - * Ease Sine InOut + * Ease Sine InOut.
    + * Reference easeInOutSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase */ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - time1 = time1===0 || time1===1 ? time1 : -0.5 * (Math.cos(Math.PI * time1) - 1); - this._inner.update(time1); + update:function (dt) { + dt = dt===0 || dt===1 ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1); + this._inner.update(dt); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseSineInOut} + */ clone:function(){ var action = new cc.EaseSineInOut(); action.initWithAction(this._inner.clone()); @@ -713,18 +923,25 @@ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ }, /** + * Create a cc.EaseSineInOut action. Opposite with the original motion trajectory. * @return {cc.EaseSineInOut} */ reverse:function () { - return cc.EaseSineInOut.create(this._inner.reverse()); + return new cc.EaseSineInOut(this._inner.reverse()); } }); -/** creates the action +/** + * Creates the action.
    + * Reference easeInOutSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated * @param {cc.ActionInterval} action * @return {cc.EaseSineInOut} + * @deprecated since v3.0
    Please use cc.easeSineInOut instead. + * @example + * // example + * action.easing(cc.easeSineInOut()); */ cc.EaseSineInOut.create = function (action) { return new cc.EaseSineInOut(action); @@ -738,8 +955,11 @@ cc._easeSineInOutObj = { return cc._easeSineInOutObj; } }; + /** - * creates the action easing object + * creates the action easing object.
    + * Reference easeInOutSine:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @return {cc.EaseSineInOut} * @example * // example @@ -750,7 +970,7 @@ cc.easeSineInOut = function(){ }; /** - * Ease Elastic abstract class + * Ease Elastic abstract class. * @class * @extends cc.ActionEase */ @@ -773,21 +993,24 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ action && this.initWithAction(action, period); }, - /** get period of the wave in radians. default is 0.3 + /** + * get period of the wave in radians. default is 0.3 * @return {Number} */ getPeriod:function () { return this._period; }, - /** set period of the wave in radians. + /** + * set period of the wave in radians. * @param {Number} period */ setPeriod:function (period) { this._period = period; }, - /** Initializes the action with the inner action and the period in radians (default is 0.3) + /** + * Initializes the action with the inner action and the period in radians (default is 0.3) * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {Boolean} @@ -799,13 +1022,21 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ }, /** - * @return {Null} + * Create a action. Opposite with the original motion trajectory.
    + * Will be overwrite. + * @return {null} */ reverse:function () { cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass."); return null; }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseElastic} + */ clone:function(){ var action = new cc.EaseElastic(); action.initWithAction(this._inner.clone(), this._period); @@ -813,9 +1044,10 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ } }); -/** Creates the action with the inner action and the period in radians (default is 0.3) +/** + * Creates the action with the inner action and the period in radians (default is 0.3). * @static - * @deprecated + * @deprecated since v3.0 * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElastic} @@ -825,34 +1057,45 @@ cc.EaseElastic.create = function (action, period) { }; /** - * Ease Elastic In action. + * Ease Elastic In action.
    + * Reference easeInElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.EaseElastic */ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { + update:function (dt) { var newT = 0; - if (time1 === 0 || time1 === 1) { - newT = time1; + if (dt === 0 || dt === 1) { + newT = dt; } else { var s = this._period / 4; - time1 = time1 - 1; - newT = -Math.pow(2, 10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period); + dt = dt - 1; + newT = -Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period); } this._inner.update(newT); }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseElasticOut} */ reverse:function () { - return cc.EaseElasticOut.create(this._inner.reverse(), this._period); + return new cc.EaseElasticOut(this._inner.reverse(), this._period); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseElasticIn} + */ clone:function(){ var action = new cc.EaseElasticIn(); action.initWithAction(this._inner.clone(), this._period); @@ -860,8 +1103,14 @@ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ } }); -/** Creates the action with the inner action and the period in radians (default is 0.3) - * @deprecated +/** + * Creates the action with the inner action and the period in radians (default is 0.3).
    + * Reference easeInElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @deprecated since v3.0
    Please use cc.easeElasticIn instead. + * @example + * // example + * action.easing(cc.easeElasticIn(3.0)); * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticIn} @@ -883,7 +1132,10 @@ cc._easeElasticInObj = { } }; -/** Creates the action easing obejct with the period in radians (default is 0.3) +/** + * Creates the action easing obejct with the period in radians (default is 0.3).
    + * Reference easeInElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @param {Number} [period=0.3] * @return {Object} @@ -901,9 +1153,6 @@ cc.easeElasticIn = function (period) { dt = dt - 1; return -Math.pow(2, 10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period); }, - /** - * @return {cc.EaseElasticIn} - */ reverse:function () { return cc.easeElasticOut(this._period); } @@ -913,34 +1162,45 @@ cc.easeElasticIn = function (period) { }; /** - * Ease Elastic Out action. + * Ease Elastic Out action.
    + * Reference easeOutElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.EaseElastic */ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { + update:function (dt) { var newT = 0; - if (time1 === 0 || time1 == 1) { - newT = time1; + if (dt === 0 || dt == 1) { + newT = dt; } else { var s = this._period / 4; - newT = Math.pow(2, -10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period) + 1; + newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period) + 1; } this._inner.update(newT); }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseElasticIn} */ reverse:function () { - return cc.EaseElasticIn.create(this._inner.reverse(), this._period); + return new cc.EaseElasticIn(this._inner.reverse(), this._period); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseElasticOut} + */ clone:function(){ var action = new cc.EaseElasticOut(); action.initWithAction(this._inner.clone(), this._period); @@ -948,8 +1208,14 @@ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ } }); -/** Creates the action with the inner action and the period in radians (default is 0.3) - * @deprecated +/** + * Creates the action with the inner action and the period in radians (default is 0.3).
    + * Reference easeOutElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @deprecated since v3.0
    Please use cc.easeElasticOut instead. + * @example + * // example + * action.easing(cc.easeElasticOut(3.0)); * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticOut} @@ -967,7 +1233,10 @@ cc._easeElasticOutObj = { return cc._easeElasticInObj; } }; -/** Creates the action easing object with the period in radians (default is 0.3) +/** + * Creates the action easing object with the period in radians (default is 0.3).
    + * Reference easeOutElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @param {Number} [period=0.3] * @return {Object} @@ -991,42 +1260,53 @@ cc.easeElasticOut = function (period) { }; /** - * Ease Elastic InOut action. + * Ease Elastic InOut action.
    + * Reference easeInOutElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.EaseElastic */ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { + update:function (dt) { var newT = 0; var locPeriod = this._period; - if (time1 === 0 || time1 == 1) { - newT = time1; + if (dt === 0 || dt == 1) { + newT = dt; } else { - time1 = time1 * 2; + dt = dt * 2; if (!locPeriod) locPeriod = this._period = 0.3 * 1.5; var s = locPeriod / 4; - time1 = time1 - 1; - if (time1 < 0) - newT = -0.5 * Math.pow(2, 10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / locPeriod); + dt = dt - 1; + if (dt < 0) + newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod); else - newT = Math.pow(2, -10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / locPeriod) * 0.5 + 1; + newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1; } this._inner.update(newT); }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseElasticInOut} */ reverse:function () { - return cc.EaseElasticInOut.create(this._inner.reverse(), this._period); + return new cc.EaseElasticInOut(this._inner.reverse(), this._period); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseElasticInOut} + */ clone:function(){ var action = new cc.EaseElasticInOut(); action.initWithAction(this._inner.clone(), this._period); @@ -1034,8 +1314,14 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ } }); -/** Creates the action with the inner action and the period in radians (default is 0.3) - * @deprecated +/** + * Creates the action with the inner action and the period in radians (default is 0.3).
    + * Reference easeInOutElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @deprecated since v3.0
    Please use cc.easeElasticInOut instead. + * @example + * // example + * action.easing(cc.easeElasticInOut(3.0)); * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticInOut} @@ -1044,7 +1330,10 @@ cc.EaseElasticInOut.create = function (action, period) { return new cc.EaseElasticInOut(action, period); }; -/** Creates the action easing object with the period in radians (default is 0.3) +/** + * Creates the action easing object with the period in radians (default is 0.3).
    + * Reference easeInOutElastic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @param {Number} [period=0.3] * @return {Object} @@ -1105,6 +1394,12 @@ cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{ return 7.5625 * time1 * time1 + 0.984375; }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBounce} + */ clone:function(){ var action = new cc.EaseBounce(); action.initWithAction(this._inner.clone()); @@ -1112,16 +1407,18 @@ cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{ }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseBounce} */ reverse:function () { - return cc.EaseBounce.create(this._inner.reverse()); + return new cc.EaseBounce(this._inner.reverse()); } }); -/** creates an ease bounce action +/** + * Creates an ease bounce action. * @static - * @deprecated + * @deprecated since v3.0 * @param {cc.ActionInterval} action * @return {cc.EaseBounce} */ @@ -1130,27 +1427,37 @@ cc.EaseBounce.create = function (action) { }; /** - * cc.EaseBounceIn action. + * cc.EaseBounceIn action.
    + * Eased bounce effect at the beginning. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.EaseBounce */ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - var newT = 1 - this.bounceTime(1 - time1); + update:function (dt) { + var newT = 1 - this.bounceTime(1 - dt); this._inner.update(newT); }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseBounceOut} */ reverse:function () { - return cc.EaseBounceOut.create(this._inner.reverse()); + return new cc.EaseBounceOut(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBounceIn} + */ clone:function(){ var action = new cc.EaseBounceIn(); action.initWithAction(this._inner.clone()); @@ -1158,9 +1465,14 @@ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ } }); -/** creates the action +/** + * Creates the action.
    + * Eased bounce effect at the beginning. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeBounceIn instead. + * @example + * // example + * action.easing(cc.easeBounceIn()); * @param {cc.ActionInterval} action * @return {cc.EaseBounceIn} */ @@ -1191,7 +1503,10 @@ cc._easeBounceInObj = { return cc._easeBounceOutObj; } }; -/** creates the action easing object + +/** + * Creates the action easing object.
    + * Eased bounce effect at the beginning. * @function * @return {Object} * @example @@ -1203,27 +1518,37 @@ cc.easeBounceIn = function(){ }; /** - * cc.EaseBounceOut action. + * cc.EaseBounceOut action.
    + * Eased bounce effect at the ending. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.EaseBounce */ cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { - var newT = this.bounceTime(time1); + update:function (dt) { + var newT = this.bounceTime(dt); this._inner.update(newT); }, /** - * @return {cc.ActionInterval} + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseBounceIn} */ reverse:function () { - return cc.EaseBounceIn.create(this._inner.reverse()); + return new cc.EaseBounceIn(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBounceOut} + */ clone:function(){ var action = new cc.EaseBounceOut(); action.initWithAction(this._inner.clone()); @@ -1231,9 +1556,14 @@ cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{ } }); -/** creates the action +/** + * Creates the action.
    + * Eased bounce effect at the ending. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeBounceOut instead. + * @example + * // example + * action.easing(cc.easeBounceOut()); * @param {cc.ActionInterval} action * @return {cc.EaseBounceOut} */ @@ -1249,8 +1579,10 @@ cc._easeBounceOutObj = { return cc._easeBounceInObj; } }; + /** - * Creates the action easing object + * Creates the action easing object.
    + * Eased bounce effect at the ending. * @function * @return {Object} * @example @@ -1262,26 +1594,35 @@ cc.easeBounceOut = function(){ }; /** - * cc.EaseBounceInOut action. + * cc.EaseBounceInOut action.
    + * Eased bounce effect at the begining and ending. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.EaseBounce */ cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { + update:function (dt) { var newT = 0; - if (time1 < 0.5) { - time1 = time1 * 2; - newT = (1 - this.bounceTime(1 - time1)) * 0.5; + if (dt < 0.5) { + dt = dt * 2; + newT = (1 - this.bounceTime(1 - dt)) * 0.5; } else { - newT = this.bounceTime(time1 * 2 - 1) * 0.5 + 0.5; + newT = this.bounceTime(dt * 2 - 1) * 0.5 + 0.5; } this._inner.update(newT); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBounceInOut} + */ clone:function(){ var action = new cc.EaseBounceInOut(); action.initWithAction(this._inner.clone()); @@ -1289,16 +1630,22 @@ cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseBounceInOut} */ reverse:function () { - return cc.EaseBounceInOut.create(this._inner.reverse()); + return new cc.EaseBounceInOut(this._inner.reverse()); } }); -/** creates the action +/** + * Creates the action.
    + * Eased bounce effect at the begining and ending. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeBounceInOut instead. + * @example + * // example + * action.easing(cc.easeBounceInOut()); * @param {cc.ActionInterval} action * @return {cc.EaseBounceInOut} */ @@ -1322,7 +1669,8 @@ cc._easeBounceInOutObj = { } }; /** - * Creates the action easing object + * Creates the action easing object.
    + * Eased bounce effect at the begining and ending. * @function * @return {Object} * @example @@ -1334,28 +1682,38 @@ cc.easeBounceInOut = function(){ }; /** - * cc.EaseBackIn action. + * cc.EaseBackIn action.
    + * In the opposite direction to move slowly, and then accelerated to the right direction. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.ActionEase */ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { + update:function (dt) { var overshoot = 1.70158; - time1 = time1===0 || time1==1 ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot); - this._inner.update(time1); + dt = dt===0 || dt==1 ? dt : dt * dt * ((overshoot + 1) * dt - overshoot); + this._inner.update(dt); }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseBackOut} */ reverse:function () { - return cc.EaseBackOut.create(this._inner.reverse()); + return new cc.EaseBackOut(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBackIn} + */ clone:function(){ var action = new cc.EaseBackIn(); action.initWithAction(this._inner.clone()); @@ -1364,9 +1722,14 @@ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ }); -/** creates the action +/** + * Creates the cc.EaseBackIn.
    + * In the opposite direction to move slowly, and then accelerated to the right direction. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeBackIn instead. + * @example + * // example + * action.easing(cc.easeBackIn()); * @param {cc.ActionInterval} action * @return {cc.EaseBackIn} */ @@ -1383,7 +1746,10 @@ cc._easeBackInObj = { return cc._easeBackOutObj; } }; -/** creates the action easing object + +/** + * Creates the action easing object.
    + * In the opposite direction to move slowly, and then accelerated to the right direction. * @function * @return {Object} * @example @@ -1395,28 +1761,38 @@ cc.easeBackIn = function(){ }; /** - * cc.EaseBackOut action. + * cc.EaseBackOut action.
    + * Fast moving more than the finish, and then slowly back to the finish. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.ActionEase */ cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { + update:function (dt) { var overshoot = 1.70158; - time1 = time1 - 1; - this._inner.update(time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1); + dt = dt - 1; + this._inner.update(dt * dt * ((overshoot + 1) * dt + overshoot) + 1); }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseBackIn} */ reverse:function () { - return cc.EaseBackIn.create(this._inner.reverse()); + return new cc.EaseBackIn(this._inner.reverse()); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBackOut} + */ clone:function(){ var action = new cc.EaseBackOut(); action.initWithAction(this._inner.clone()); @@ -1424,9 +1800,14 @@ cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ } }); -/** creates the action +/** + * Creates the action.
    + * Fast moving more than the finish, and then slowly back to the finish. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeBackOut instead. + * @example + * // example + * action.easing(cc.easeBackOut()); * @param {cc.ActionInterval} action * @return {cc.EaseBackOut} */ @@ -1444,7 +1825,9 @@ cc._easeBackOutObj = { return cc._easeBackInObj; } }; -/** creates the action easing object +/** + * Creates the action easing object.
    + * Fast moving more than the finish, and then slowly back to the finish. * @function * @return {Object} * @example @@ -1456,26 +1839,35 @@ cc.easeBackOut = function(){ }; /** - * cc.EaseBackInOut action. + * cc.EaseBackInOut action.
    + * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. * @class * @extends cc.ActionEase */ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ /** - * @param {Number} time1 + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time1) { + update:function (dt) { var overshoot = 1.70158 * 1.525; - time1 = time1 * 2; - if (time1 < 1) { - this._inner.update((time1 * time1 * ((overshoot + 1) * time1 - overshoot)) / 2); + dt = dt * 2; + if (dt < 1) { + this._inner.update((dt * dt * ((overshoot + 1) * dt - overshoot)) / 2); } else { - time1 = time1 - 2; - this._inner.update((time1 * time1 * ((overshoot + 1) * time1 + overshoot)) / 2 + 1); + dt = dt - 2; + this._inner.update((dt * dt * ((overshoot + 1) * dt + overshoot)) / 2 + 1); } }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBackInOut} + */ clone:function(){ var action = new cc.EaseBackInOut(); action.initWithAction(this._inner.clone()); @@ -1483,17 +1875,23 @@ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ }, /** + * Create a action. Opposite with the original motion trajectory. * @return {cc.EaseBackInOut} */ reverse:function () { - return cc.EaseBackInOut.create(this._inner.reverse()); + return new cc.EaseBackInOut(this._inner.reverse()); } }); -/** creates the action +/** + * Creates the action.
    + * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeBackInOut instead. + * @example + * // example + * action.easing(cc.easeBackInOut()); * @param {cc.ActionInterval} action * @return {cc.EaseBackInOut} */ @@ -1516,7 +1914,9 @@ cc._easeBackInOutObj = { return cc._easeBackInOutObj; } }; -/** creates the action easing object +/** + * Creates the action easing object.
    + * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. * @function * @return {Object} * @example @@ -1528,8 +1928,11 @@ cc.easeBackInOut = function(){ }; /** - * cc.EaseBezierAction action. - * @type {Function|*} + * cc.EaseBezierAction action.
    + * Manually set a 4 order Bessel curve.
    + * According to the set point, calculate the trajectory. + * @class + * @extends cc.ActionEase */ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ @@ -1538,6 +1941,10 @@ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ _p2: null, _p3: null, + /** + * Initialization requires the application of Bessel curve of action. + * @param {cc.Action} action + */ ctor: function(action){ cc.ActionEase.prototype.ctor.call(this, action); }, @@ -1546,21 +1953,46 @@ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ return (Math.pow(1-t,3) * a + 3*t*(Math.pow(1-t,2))*b + 3*Math.pow(t,2)*(1-t)*c + Math.pow(t,3)*d ); }, - update: function(time){ - var t = this._updateTime(this._p0, this._p1, this._p2, this._p3, time); + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + var t = this._updateTime(this._p0, this._p1, this._p2, this._p3, dt); this._inner.update(t); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseBezierAction} + */ clone: function(){ var action = new cc.EaseBezierAction(); action.initWithAction(this._inner.clone()); action.setBezierParamer(this._p0, this._p1, this._p2, this._p3); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseBezierAction} + */ reverse: function(){ - var action = cc.EaseBezierAction.create(this._inner.reverse()); + var action = new cc.EaseBezierAction(this._inner.reverse()); action.setBezierParamer(this._p3, this._p2, this._p1, this._p0); return action; }, + + /** + * Set of 4 reference point + * @param p0 + * @param p1 + * @param p2 + * @param p3 + */ setBezierParamer: function(p0, p1, p2, p3){ this._p0 = p0 || 0; this._p1 = p1 || 0; @@ -1570,23 +2002,33 @@ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ }); /** - * creates the action + * Creates the action.
    + * After creating the cc.EaseBezierAction, also need to manually call setBezierParamer.
    + * According to the set point, calculate the trajectory. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeBezierAction instead. + * @example + * // example + * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); * @param action - * @returns {cc.EaseQuadraticActionIn} + * @returns {cc.EaseBezierAction} */ cc.EaseBezierAction.create = function(action){ return new cc.EaseBezierAction(action); }; /** - * creates the action easing object + * Creates the action easing object.
    + * Into the 4 reference point.
    + * To calculate the motion curve. * @param {Number} p0 The first bezier parameter * @param {Number} p1 The second bezier parameter * @param {Number} p2 The third bezier parameter * @param {Number} p3 The fourth bezier parameter * @returns {Object} + * @example + * // example + * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); */ cc.easeBezierAction = function(p0, p1, p2, p3){ return { @@ -1599,10 +2041,12 @@ cc.easeBezierAction = function(p0, p1, p2, p3){ }; }; - /** - * cc.EaseQuadraticActionIn action. - * @type {Function|*} + * cc.EaseQuadraticActionIn action.
    + * Reference easeInQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionIn# */{ @@ -1610,26 +2054,46 @@ cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActio return Math.pow(time, 2); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuadraticActionIn} + */ clone: function(){ var action = new cc.EaseQuadraticActionIn(); action.initWithAction(this._inner.clone()); return action; }, + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuadraticActionIn} + */ reverse: function(){ - return cc.EaseQuadraticActionIn.create(this._inner.reverse()); + return new cc.EaseQuadraticActionIn(this._inner.reverse()); } }); /** - * creates the action + * Creates the cc.EaseQuadRaticActionIn.
    + * Reference easeInQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuadraticAction instead. + * @example + * //example + * action.easing(cc.easeQuadraticActionIn()); * @param action * @returns {cc.EaseQuadraticActionIn} */ @@ -1643,17 +2107,26 @@ cc._easeQuadraticActionIn = { return cc._easeQuadraticActionIn; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @returns {Object} + * @example + * //example + * action.easing(cc.easeQuadraticActionIn()); */ cc.easeQuadraticActionIn = function(){ return cc._easeQuadraticActionIn; }; /** - * cc.EaseQuadraticActionIn action. - * @type {Function|*} + * cc.EaseQuadraticActionIn action.
    + * Reference easeOutQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionOut# */{ @@ -1661,23 +2134,45 @@ cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActi return -time*(time-2); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuadraticActionOut} + */ clone: function(){ var action = new cc.EaseQuadraticActionOut(); action.initWithAction(); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuadraticActionOut} + */ reverse: function(){ - return cc.EaseQuadraticActionOut.create(this._inner.reverse()); + return new cc.EaseQuadraticActionOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeOutQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuadraticActionOut instead. + * @example + * //example + * action.easing(cc.easeQuadraticActionOut()); * @param action * @returns {cc.EaseQuadraticActionOut} */ @@ -1692,17 +2187,25 @@ cc._easeQuadraticActionOut = { } }; /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeOutQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeQuadraticActionOut()); */ cc.easeQuadraticActionOut = function(){ return cc._easeQuadraticActionOut; }; /** - * cc.EaseQuadraticActionInOut action. - * @type {Function|*} + * cc.EaseQuadraticActionInOut action.
    + * Reference easeInOutQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionInOut# */{ _updateTime: function(time){ @@ -1716,25 +2219,48 @@ cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticAc } return resultTime; }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuadraticActionInOut} + */ clone: function(){ var action = new cc.EaseQuadraticActionInOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuadraticActionInOut} + */ reverse: function(){ - return cc.EaseQuadraticActionInOut.create(this._inner.reverse()); + return new cc.EaseQuadraticActionInOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInOutQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuadraticActionInOut() instead. + * @example + * //example + * action.easing(cc.easeQuadraticActionInOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseQuadraticActionInOut} */ cc.EaseQuadraticActionInOut.create = function(action){ return new cc.EaseQuadraticActionInOut(action); @@ -1746,42 +2272,74 @@ cc._easeQuadraticActionInOut = { return cc._easeQuadraticActionInOut; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInOutQuad:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeQuadraticActionInOut()); */ cc.easeQuadraticActionInOut = function(){ return cc._easeQuadraticActionInOut; }; /** - * cc.EaseQuarticActionIn action. - * @type {Function|*} + * cc.EaseQuarticActionIn action.
    + * Reference easeInQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# */{ _updateTime: function(time){ return time * time * time * time; }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuarticActionIn} + */ clone: function(){ var action = new cc.EaseQuarticActionIn(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuarticActionIn} + */ reverse: function(){ - return cc.EaseQuarticActionIn.create(this._inner.reverse()); + return new cc.EaseQuarticActionIn(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuarticIn() instead. + * @example + * //example + * action.easing(cc.easeQuarticActionIn()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseQuarticActionIn} */ cc.EaseQuarticActionIn.create = function(action){ return new cc.EaseQuarticActionIn(action); @@ -1794,42 +2352,73 @@ cc._easeQuarticActionIn = { } }; /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeIntQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeQuarticActionIn()); */ cc.easeQuarticActionIn = function(){ return cc._easeQuarticActionIn; }; /** - * cc.EaseQuarticActionOut action. - * @type {Function|*} + * cc.EaseQuarticActionOut action.
    + * Reference easeOutQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOut# */{ _updateTime: function(time){ time -= 1; return -(time * time * time * time - 1); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuarticActionOut} + */ clone: function(){ var action = new cc.EaseQuarticActionOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuarticActionOut} + */ reverse: function(){ - return cc.EaseQuarticActionOut.create(this._inner.reverse()); + return new cc.EaseQuarticActionOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeOutQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuarticActionOut() instead. + * @example + * //example + * action.easing(cc.EaseQuarticActionOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseQuarticActionOut} */ cc.EaseQuarticActionOut.create = function(action){ return new cc.EaseQuarticActionOut(action); @@ -1841,18 +2430,27 @@ cc._easeQuarticActionOut = { return cc._easeQuarticActionOut; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeOutQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.QuarticActionOut()); */ cc.easeQuarticActionOut = function(){ return cc._easeQuarticActionOut; }; /** - * cc.EaseQuarticActionInOut action. - * @type {Function|*} + * cc.EaseQuarticActionInOut action.
    + * Reference easeInOutQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionInOut# */{ _updateTime: function(time){ @@ -1862,25 +2460,48 @@ cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticAction time -= 2; return -0.5 * (time * time * time * time - 2); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuarticActionInOut} + */ clone: function(){ var action = new cc.EaseQuarticActionInOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuarticActionInOut} + */ reverse: function(){ - return cc.EaseQuarticActionInOut.create(this._inner.reverse()); + return new cc.EaseQuarticActionInOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInOutQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuarticActionInOut() instead. + * @example + * //example + * action.easing(cc.easeQuarticActionInOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseQuarticActionInOut} */ cc.EaseQuarticActionInOut.create = function(action){ return new cc.EaseQuarticActionInOut(action); @@ -1893,7 +2514,9 @@ cc._easeQuarticActionInOut = { } }; /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInOutQuart:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} */ @@ -1902,32 +2525,58 @@ cc.easeQuarticActionInOut = function(){ }; /** - * cc.EaseQuinticActionIn action. - * @type {Function|*} + * cc.EaseQuinticActionIn action.
    + * Reference easeInQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# */{ _updateTime: function(time){ return time * time * time * time * time; }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuinticActionIn} + */ clone: function(){ var action = new cc.EaseQuinticActionIn(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuinticActionIn} + */ reverse: function(){ - return cc.EaseQuinticActionIn.create(this._inner.reverse()); + return new cc.EaseQuinticActionIn(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuinticActionIn() instead. + * @example + * //example + * action.easing(cc.easeQuinticActionIn()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseQuinticActionIn} */ cc.EaseQuinticActionIn.create = function(action){ return new cc.EaseQuinticActionIn(action); @@ -1939,43 +2588,75 @@ cc._easeQuinticActionIn = { return cc._easeQuinticActionIn; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeQuinticActionIn()); */ cc.easeQuinticActionIn = function(){ return cc._easeQuinticActionIn; }; /** - * cc.EaseQuinticActionOut action. - * @type {Function|*} + * cc.EaseQuinticActionOut action.
    + * Reference easeQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOut# */{ _updateTime: function(time){ time -=1; return (time * time * time * time * time + 1); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuinticActionOut} + */ clone: function(){ var action = new cc.EaseQuinticActionOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuinticActionOut} + */ reverse: function(){ - return cc.EaseQuinticActionOut.create(this._inner.reverse()); + return new cc.EaseQuinticActionOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeOutQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuadraticActionOut() instead. + * @example + * //example + * action.easing(cc.easeQuadraticActionOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseQuinticActionOut} */ cc.EaseQuinticActionOut.create = function(action){ return new cc.EaseQuinticActionOut(action); @@ -1988,17 +2669,25 @@ cc._easeQuinticActionOut = { } }; /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeOutQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeQuadraticActionOut()); */ cc.easeQuinticActionOut = function(){ return cc._easeQuinticActionOut; }; /** - * cc.EaseQuinticActionInOut action. - * @type {Function|*} + * cc.EaseQuinticActionInOut action.
    + * Reference easeInOutQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionInOut# */{ _updateTime: function(time){ @@ -2008,25 +2697,48 @@ cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticAction time -= 2; return 0.5 * (time * time * time * time * time + 2); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseQuinticActionInOut} + */ clone: function(){ var action = new cc.EaseQuinticActionInOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseQuinticActionInOut} + */ reverse: function(){ - return cc.EaseQuinticActionInOut.create(this._inner.reverse()); + return new cc.EaseQuinticActionInOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInOutQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeQuinticActionInOut() instead. + * @example + * //example + * action.easing(cc.easeQuinticActionInOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseQuinticActionInOut} */ cc.EaseQuinticActionInOut.create = function(action){ return new cc.EaseQuinticActionInOut(action); @@ -2038,42 +2750,74 @@ cc._easeQuinticActionInOut = { return cc._easeQuinticActionInOut; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInOutQuint:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeQuinticActionInOut()); */ cc.easeQuinticActionInOut = function(){ return cc._easeQuinticActionInOut; }; /** - * cc.EaseCircleActionIn action. - * @type {Function|*} + * cc.EaseCircleActionIn action.
    + * Reference easeInCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# */{ _updateTime: function(time){ return -1 * (Math.sqrt(1 - time * time) - 1); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseCircleActionIn} + */ clone: function(){ var action = new cc.EaseCircleActionIn(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseCircleActionIn} + */ reverse: function(){ - return cc.EaseCircleActionIn.create(this._inner.reverse()); + return new cc.EaseCircleActionIn(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeCircleActionIn() instead. + * @example + * //example + * action.easing(cc.easeCircleActionIn()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseCircleActionIn} */ cc.EaseCircleActionIn.create = function(action){ return new cc.EaseCircleActionIn(action); @@ -2085,43 +2829,75 @@ cc._easeCircleActionIn = { return cc._easeCircleActionIn; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeCircleActionIn()); */ cc.easeCircleActionIn = function(){ return cc._easeCircleActionIn; }; /** - * cc.EaseCircleActionOut action. - * @type {Function|*} + * cc.EaseCircleActionOut action.
    + * Reference easeOutCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# */{ _updateTime: function(time){ time = time - 1; return Math.sqrt(1 - time * time); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseCircleActionOut} + */ clone: function(){ var action = new cc.EaseCircleActionOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseCircleActionOut} + */ reverse: function(){ - return cc.EaseCircleActionOut.create(this._inner.reverse()); + return new cc.EaseCircleActionOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeOutCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeCircleActionOut() instead. + * @exampple + * //example + * actioneasing(cc.easeCircleActionOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseCircleActionOut} */ cc.EaseCircleActionOut.create = function(action){ return new cc.EaseCircleActionOut(action); @@ -2133,18 +2909,27 @@ cc._easeCircleActionOut = { return cc._easeCircleActionOut; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeOutCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @exampple + * //example + * actioneasing(cc.easeCircleActionOut()); */ cc.easeCircleActionOut = function(){ return cc._easeCircleActionOut; }; /** - * cc.EaseCircleActionInOut action. - * @type {Function|*} + * cc.EaseCircleActionInOut action.
    + * Reference easeInOutCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionInOut# */{ _updateTime: function(time){ @@ -2154,25 +2939,48 @@ cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn time -= 2; return 0.5 * (Math.sqrt(1 - time * time) + 1); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseCircleActionInOut} + */ clone: function(){ var action = new cc.EaseCircleActionInOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseCircleActionInOut} + */ reverse: function(){ - return cc.EaseCircleActionInOut.create(this._inner.reverse()); + return new cc.EaseCircleActionInOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInOutCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeCircleActionInOut instead. + * @example + * //example + * action.easing(cc.easeCircleActionInOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseCircleActionInOut} */ cc.EaseCircleActionInOut.create = function(action){ return new cc.EaseCircleActionInOut(action); @@ -2184,42 +2992,74 @@ cc._easeCircleActionInOut = { return cc._easeCircleActionInOut; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInOutCirc:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeCircleActionInOut()); */ cc.easeCircleActionInOut = function(){ return cc._easeCircleActionInOut; }; /** - * cc.EaseCubicActionIn action. - * @type {Function|*} + * cc.EaseCubicActionIn action.
    + * Reference easeInCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{ _updateTime: function(time){ return time * time * time; }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseCubicActionIn} + */ clone: function(){ var action = new cc.EaseCubicActionIn(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseCubicActionIn} + */ reverse: function(){ - return cc.EaseCubicActionIn.create(this._inner.reverse()); + return new cc.EaseCubicActionIn(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeCubicActionOut() instead. + * @example + * //example + * action.easing(cc.easeCubicActionIn()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseCubicActionIn} */ cc.EaseCubicActionIn.create = function(action){ return new cc.EaseCubicActionIn(action); @@ -2232,42 +3072,73 @@ cc._easeCubicActionIn = { } }; /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeCubicActionIn()); */ cc.easeCubicActionIn = function(){ return cc._easeCubicActionIn; }; /** - * cc.EaseCubicActionOut action. - * @type {Function|*} + * cc.EaseCubicActionOut action.
    + * Reference easeOutCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# */{ _updateTime: function(time){ time -= 1; return (time * time * time + 1); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseCubicActionOut} + */ clone: function(){ var action = new cc.EaseCubicActionOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseCubicActionOut} + */ reverse: function(){ - return cc.EaseCubicActionOut.create(this._inner.reverse()); + return new cc.EaseCubicActionOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeOutCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeCubicActionOut() instead. + * @example + * //example + * action.easing(cc.easeCubicActionOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseCubicActionOut} */ cc.EaseCubicActionOut.create = function(action){ return new cc.EaseCubicActionOut(action); @@ -2279,19 +3150,27 @@ cc._easeCubicActionOut = { return cc._easeCubicActionOut; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeOutCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} + * @example + * //example + * action.easing(cc.easeCubicActionOut()); */ cc.easeCubicActionOut = function(){ return cc._easeCubicActionOut; }; - /** - * cc.EaseCubicActionInOut action. - * @type {Function|*} + * cc.EaseCubicActionInOut action.
    + * Reference easeInOutCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} + * @class + * @extends cc.ActionEase */ cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOut# */{ _updateTime: function(time){ @@ -2301,25 +3180,48 @@ cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOu time -= 2; return 0.5 * (time * time * time + 2); }, - update: function(time){ - this._inner.update(this._updateTime(time)); + + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update: function(dt){ + this._inner.update(this._updateTime(dt)); }, + + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @returns {cc.EaseCubicActionInOut} + */ clone: function(){ var action = new cc.EaseCubicActionInOut(); action.initWithAction(this._inner.clone()); return action; }, + + /** + * Create a action. Opposite with the original motion trajectory. + * @return {cc.EaseCubicActionInOut} + */ reverse: function(){ - return cc.EaseCubicActionInOut.create(this._inner.reverse()); + return new cc.EaseCubicActionInOut(this._inner.reverse()); } }); /** - * creates the action + * Creates the action.
    + * Reference easeInOutCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.easeCubicActionInOut() instead. + * @example + * //example + * action.easing(cc.easeCubicActionInOut()); * @param action - * @returns {cc.EaseQuadraticActionOut} + * @returns {cc.EaseCubicActionInOut} */ cc.EaseCubicActionInOut.create = function(action){ return new cc.EaseCubicActionInOut(action); @@ -2331,8 +3233,11 @@ cc._easeCubicActionInOut = { return cc._easeCubicActionInOut; } }; + /** - * creates the action easing object + * Creates the action easing object.
    + * Reference easeInOutCubic:
    + * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @function * @returns {Object} */ diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index 3f5d73eb8c..067c747d04 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -25,13 +25,14 @@ ****************************************************************************/ /** - * Instant actions are immediate actions. They don't have a duration like + * Instant actions are immediate actions. They don't have a duration like. * the CCIntervalAction actions. * @class * @extends cc.FiniteTimeAction */ cc.ActionInstant = cc.FiniteTimeAction.extend(/** @lends cc.ActionInstant# */{ /** + * return true if the action has finished. * @return {Boolean} */ isDone:function () { @@ -39,6 +40,8 @@ cc.ActionInstant = cc.FiniteTimeAction.extend(/** @lends cc.ActionInstant# */{ }, /** + * called every frame with it's delta time.
    + * DON'T override unless you know what you are doing. * @param {Number} dt */ step:function (dt) { @@ -46,45 +49,78 @@ cc.ActionInstant = cc.FiniteTimeAction.extend(/** @lends cc.ActionInstant# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { + update:function (dt) { //nothing }, + /** + * returns a reversed action.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten + * @returns {cc.Action} + */ reverse:function(){ return this.clone(); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.FiniteTimeAction} + */ clone:function(){ return new cc.ActionInstant(); } }); -/** Show the node +/** + * Show the node. * @class * @extends cc.ActionInstant */ cc.Show = cc.ActionInstant.extend(/** @lends cc.Show# */{ + /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { + update:function (dt) { this.target.visible = true; }, /** - * @return {cc.FiniteTimeAction} + * returns a reversed action.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten + * @returns {cc.Hide} */ reverse:function () { - return cc.Hide.create(); + return new cc.Hide(); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.FiniteTimeAction} + */ clone:function(){ return new cc.Show(); } }); + /** + * Show the Node. * @function * @return {cc.Show} * @example @@ -94,39 +130,56 @@ cc.Show = cc.ActionInstant.extend(/** @lends cc.Show# */{ cc.show = function () { return new cc.Show(); }; + /** - * Please use cc.show instead + * Show the Node. Please use cc.show instead. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.show instead. * @return {cc.Show} */ cc.Show.create = cc.show; /** - * Hide the node + * Hide the node. * @class * @extends cc.ActionInstant */ cc.Hide = cc.ActionInstant.extend(/** @lends cc.Hide# */{ + /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { + update:function (dt) { this.target.visible = false; }, /** - * @return {cc.FiniteTimeAction} + * returns a reversed action.
    + * For example:
    + * - The action will be x coordinates of 0 move to 100.
    + * - The reversed action will be x of 100 move to 0. + * - Will be rewritten + * @returns {cc.Show} */ reverse:function () { - return cc.Show.create(); + return new cc.Show(); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.Hide} + */ clone:function(){ return new cc.Hide(); } }); + /** + * Hide the node. * @function * @return {cc.Hide} * @example @@ -136,39 +189,55 @@ cc.Hide = cc.ActionInstant.extend(/** @lends cc.Hide# */{ cc.hide = function () { return new cc.Hide(); }; + /** + * Hide the node. Please use cc.hide instead. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.hide instead. * @return {cc.Hide} + * @example + * // example + * var hideAction = cc.hide(); */ cc.Hide.create = cc.hide; - -/** Toggles the visibility of a node +/** + * Toggles the visibility of a node. * @class * @extends cc.ActionInstant */ cc.ToggleVisibility = cc.ActionInstant.extend(/** @lends cc.ToggleVisibility# */{ + /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { + update:function (dt) { this.target.visible = !this.target.visible; }, /** - * @return {cc.ToggleVisibility} + * returns a reversed action. + * @returns {cc.ToggleVisibility} */ reverse:function () { return new cc.ToggleVisibility(); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.ToggleVisibility} + */ clone:function(){ return new cc.ToggleVisibility(); } }); /** + * Toggles the visibility of a node. * @function * @return {cc.ToggleVisibility} * @example @@ -178,14 +247,20 @@ cc.ToggleVisibility = cc.ActionInstant.extend(/** @lends cc.ToggleVisibility# */ cc.toggleVisibility = function () { return new cc.ToggleVisibility(); }; + /** - * Please use cc.toggleVisibility instead + * Toggles the visibility of a node. Please use cc.toggleVisibility instead. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.toggleVisibility instead. * @return {cc.ToggleVisibility} */ cc.ToggleVisibility.create = cc.toggleVisibility; +/** + * Delete self in the next frame. + * @class + * @extends cc.ActionInstant + */ cc.RemoveSelf = cc.ActionInstant.extend({ _isNeedCleanUp: true, @@ -205,19 +280,38 @@ cc.RemoveSelf = cc.ActionInstant.extend({ isNeedCleanUp !== undefined && this.init(isNeedCleanUp); }, - update:function(time){ + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function(dt){ this.target.removeFromParent(this._isNeedCleanUp); }, + /** + * Init the cc.RemoveSelf with isNeedCleanUp. + * @param isNeedCleanUp + * @returns {boolean} + */ init:function(isNeedCleanUp){ this._isNeedCleanUp = isNeedCleanUp; return true; }, + /** + * returns a reversed action. + */ reverse:function(){ return new cc.RemoveSelf(this._isNeedCleanUp); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.ToggleVisibility} + */ clone:function(){ return new cc.RemoveSelf(this._isNeedCleanUp); } @@ -237,19 +331,20 @@ cc.RemoveSelf = cc.ActionInstant.extend({ cc.removeSelf = function(isNeedCleanUp){ return new cc.RemoveSelf(isNeedCleanUp); }; + /** - * Please use cc.removeSelf instead + * Please use cc.removeSelf instead. * Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. * * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.removeSelf instead. * @param {Boolean} [isNeedCleanUp=true] * @return {cc.RemoveSelf} */ cc.RemoveSelf.create = cc.removeSelf; /** - * Flips the sprite horizontally + * Flips the sprite horizontally. * @class * @extends cc.ActionInstant */ @@ -272,6 +367,7 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ }, /** + * initializes the action with a set flipX. * @param {Boolean} flip * @return {Boolean} */ @@ -281,19 +377,28 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { + update:function (dt) { this.target.flippedX = this._flippedX; }, /** - * @return {cc.FiniteTimeAction} + * returns a reversed action. + * @return {cc.FlipX} */ reverse:function () { - return cc.FlipX.create(!this._flippedX); + return new cc.FlipX(!this._flippedX); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.FiniteTimeAction} + */ clone:function(){ var action = new cc.FlipX(); action.initWithFlipX(this._flippedX); @@ -302,7 +407,7 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ }); /** - * Create a FlipX action to flip or unflip the target + * Create a FlipX action to flip or unflip the target. * * @function * @param {Boolean} flip Indicate whether the target should be flipped or not @@ -313,12 +418,13 @@ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ cc.flipX = function (flip) { return new cc.FlipX(flip); }; + /** - * Plese use cc.flipX instead + * Plese use cc.flipX instead. * Create a FlipX action to flip or unflip the target * * @static - * @deprecated + * @deprecated since v3.0
    Plese use cc.flipX instead. * @param {Boolean} flip Indicate whether the target should be flipped or not * @return {cc.FlipX} */ @@ -346,7 +452,9 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{ flip !== undefined && this.initWithFlipY(flip); }, + /** + * initializes the action with a set flipY. * @param {Boolean} flip * @return {Boolean} */ @@ -356,28 +464,37 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { - //this._super(); + update:function (dt) { this.target.flippedY = this._flippedY; }, /** - * @return {cc.FiniteTimeAction} + * returns a reversed action. + * @return {cc.FlipY} */ reverse:function () { - return cc.FlipY.create(!this._flippedY); + return new cc.FlipY(!this._flippedY); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.FlipY} + */ clone:function(){ var action = new cc.FlipY(); action.initWithFlipY(this._flippedY); return action; } }); + /** - * Create a FlipY action to flip or unflip the target + * Create a FlipY action to flip or unflip the target. * * @function * @param {Boolean} flip @@ -388,19 +505,20 @@ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{ cc.flipY = function (flip) { return new cc.FlipY(flip); }; + /** * Please use cc.flipY instead * Create a FlipY action to flip or unflip the target * * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.flipY instead. * @param {Boolean} flip * @return {cc.FlipY} */ cc.FlipY.create = cc.flipY; - -/** Places the node in a certain position +/** + * Places the node in a certain position * @class * @extends cc.ActionInstant */ @@ -432,8 +550,10 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ } }, - /** Initializes a Place action with a position - * @param {cc.Point} pos + /** + * Initializes a Place action with a position + * @param {number} x + * @param {number} y * @return {Boolean} */ initWithPosition: function (x, y) { @@ -443,20 +563,29 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { + update:function (dt) { this.target.setPosition(this._x, this._y); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.Place} + */ clone:function(){ var action = new cc.Place(); action.initWithPosition(this._x, this._y); return action; } }); + /** - * Creates a Place action with a position + * Creates a Place action with a position. * @function * @param {cc.Point|Number} pos * @param {Number} [y] @@ -469,11 +598,12 @@ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ cc.place = function (pos, y) { return new cc.Place(pos, y); }; + /** - * Please use cc.place instead - * Creates a Place action with a position + * Please use cc.place instead. + * Creates a Place action with a position. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.place instead. * @param {cc.Point|Number} pos * @param {Number} [y] * @return {cc.Place} @@ -481,7 +611,8 @@ cc.place = function (pos, y) { cc.Place.create = cc.place; -/** Calls a 'callback' +/** + * Calls a 'callback'. * @class * @extends cc.ActionInstant */ @@ -545,14 +676,16 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ - update:function (time) { - //this._super(target); + update:function (dt) { this.execute(); }, /** + * Get selectorTarget. * @return {object} */ getTargetCallback:function () { @@ -560,6 +693,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ }, /** + * Set selectorTarget. * @param {object} sel */ setTargetCallback:function (sel) { @@ -570,6 +704,12 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ } }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.CallFunc} + */ clone:function(){ var action = new cc.CallFunc(); if(this._selectorTarget){ @@ -580,6 +720,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ return action; } }); + /** * Creates the action with the callback * @function @@ -598,11 +739,12 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ cc.callFunc = function (selector, selectorTarget, data) { return new cc.CallFunc(selector, selectorTarget, data); }; + /** - * Please use cc.callFunc instead - * Creates the action with the callback + * Please use cc.callFunc instead. + * Creates the action with the callback. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.callFunc instead. * @param {function} selector * @param {object|null} [selectorTarget] * @param {*|null} [data] data for function, it accepts all data types. diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 4eece9c3db..085ea7043a 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -70,14 +70,16 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ d !== undefined && this.initWithDuration(d); }, - /** how many seconds had elapsed since the actions started to run. + /** + * How many seconds had elapsed since the actions started to run. * @return {Number} */ getElapsed:function () { return this._elapsed; }, - /** initializes the action + /** + * Initializes the action. * @param {Number} d duration in seconds * @return {Boolean} */ @@ -91,7 +93,8 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ return true; }, - /** returns true if the action has finished + /** + * Returns true if the action has finished. * @return {Boolean} */ isDone:function () { @@ -99,7 +102,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** - * Some additional parameters of cloning + * Some additional parameters of cloning. * @param {cc.Action} action * @private */ @@ -112,11 +115,6 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ action._repeatMethod = this._repeatMethod; }, - /** - * - * @param action - * @private - */ _reverseEaseList: function(action){ if(this._easeList){ action._easeList = []; @@ -127,7 +125,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** - * returns a new clone of the action + * Returns a new clone of the action. * @returns {cc.ActionInterval} */ clone:function () { @@ -136,6 +134,15 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ return action; }, + /** + * Implementation of ease motion. + * + * @example + * //example + * action.easeing(cc.easeIn(3.0)); + * @param {Object} easeObj + * @returns {cc.ActionInterval} + */ easing: function (easeObj) { if (this._easeList) this._easeList.length = 0; @@ -156,7 +163,10 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** - * @param {Number} dt delta time in seconds + * called every frame with it's delta time.
    + * DON'T override unless you know what you are doing. + * + * @param {Number} dt */ step:function (dt) { if (this._firstTick) { @@ -187,6 +197,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** + * Start this action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -196,7 +207,10 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** - * @return {Null} + * returns a reversed action.
    + * Will be overwrite. + * + * @return {null} */ reverse:function () { cc.log("cc.IntervalAction: reverse not implemented."); @@ -204,6 +218,8 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** + * Set amplitude rate. + * @warning It should be overridden in subclass. * @param {Number} amp */ setAmplitudeRate:function (amp) { @@ -212,7 +228,9 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** - * @return {Number} + * Get amplitude rate. + * @warning It should be overridden in subclass. + * @return {Number} 0 */ getAmplitudeRate:function () { // Abstract class needs implementation @@ -240,6 +258,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** + * Get this action speed. * @return {Number} */ getSpeed: function(){ @@ -247,7 +266,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }, /** - * + * Set this action speed. * @param {Number} speed * @returns {cc.ActionInterval} */ @@ -287,6 +306,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ }); /** + * An interval action is an action that takes place within a certain period of time. * @function * @param {Number} d duration in seconds * @return {cc.ActionInterval} @@ -297,17 +317,19 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ cc.actionInterval = function (d) { return new cc.ActionInterval(d); }; + /** - * Please use cc.actionInterval instead + * Please use cc.actionInterval instead. + * An interval action is an action that takes place within a certain period of time. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.actionInterval instead. * @param {Number} d duration in seconds * @return {cc.ActionInterval} */ cc.ActionInterval.create = cc.actionInterval; - -/** Runs actions sequentially, one after another +/** + * Runs actions sequentially, one after another. * @class * @extends cc.ActionInterval */ @@ -347,7 +369,8 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ } }, - /** initializes the action
    + /** + * Initializes the action
    * @param {cc.FiniteTimeAction} actionOne * @param {cc.FiniteTimeAction} actionTwo * @return {Boolean} @@ -376,6 +399,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -385,7 +409,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ }, /** - * stop the action + * stop the action. */ stop:function () { // Issue #1305 @@ -395,15 +419,16 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); var new_t, found = 0; var locSplit = this._split, locActions = this._actions, locLast = this._last; - if (time < locSplit) { + if (dt < locSplit) { // action[0] - new_t = (locSplit !== 0) ? time / locSplit : 1; + new_t = (locSplit !== 0) ? dt / locSplit : 1; if (found === 0 && locLast === 1) { // Reverse mode ? @@ -416,7 +441,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ } else { // action[1] found = 1; - new_t = (locSplit === 1) ? 1 : (time - locSplit) / (1 - locSplit); + new_t = (locSplit === 1) ? 1 : (dt - locSplit) / (1 - locSplit); if (locLast === -1) { // action[0] was skipped, execute it. @@ -444,7 +469,8 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.Sequence} */ reverse:function () { var action = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse()); @@ -453,6 +479,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ return action; } }); + /** helper constructor to create an array of sequenceable actions * @function * @param {Array|cc.FiniteTimeAction} tempArray @@ -477,11 +504,12 @@ cc.sequence = function (/*Multiple Arguments*/tempArray) { } return prev; }; + /** - * Please use cc.sequence instead + * Please use cc.sequence instead. * helper constructor to create an array of sequenceable actions * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.sequence instead. * @param {Array|cc.FiniteTimeAction} tempArray * @return {cc.Sequence} */ @@ -499,7 +527,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. @@ -560,6 +587,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -578,17 +606,18 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); 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) { + if (dt >= locNextDt) { + while (dt > locNextDt && this._total < locTimes) { locInnerAction.update(1); this._total++; locInnerAction.stop(); @@ -598,7 +627,7 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ } // fix for issue #1288, incorrect end value of repeat - if (time >= 1.0 && this._total < locTimes) + if (dt >= 1.0 && this._total < locTimes) this._total++; // don't set a instant action back or update it, it has no use because it has no duration @@ -608,15 +637,16 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ locInnerAction.stop(); } else { // issue #390 prevent jerk, use right update - locInnerAction.update(time - (locNextDt - locInnerAction._duration / locDuration)); + locInnerAction.update(dt - (locNextDt - locInnerAction._duration / locDuration)); } } } else { - locInnerAction.update((time * locTimes) % 1.0); + locInnerAction.update((dt * locTimes) % 1.0); } }, /** + * Return true if the action has finished. * @return {Boolean} */ isDone:function () { @@ -624,16 +654,18 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ }, /** - * @return {cc.ActionInterval} + * returns a reversed action. + * @return {cc.Repeat} */ reverse:function () { - var action = cc.repeat(this._innerAction.reverse(), this._times); + var action = new cc.Repeat(this._innerAction.reverse(), this._times); this._cloneDecoration(action); this._reverseEaseList(action); return action; }, /** + * Set inner Action. * @param {cc.FiniteTimeAction} action */ setInnerAction:function (action) { @@ -643,12 +675,14 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ }, /** + * Get inner Action. * @return {cc.FiniteTimeAction} */ getInnerAction:function () { return this._innerAction; } }); + /** * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) * @function @@ -662,11 +696,12 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ cc.repeat = function (action, times) { return new cc.Repeat(action, times); }; + /** * Please use cc.repeat instead * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.repeat instead. * @param {cc.FiniteTimeAction} action * @param {Number} times * @return {cc.Repeat} @@ -680,7 +715,6 @@ cc.Repeat.create = cc.repeat; * @class * @extends cc.ActionInterval */ - cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ _innerAction:null, //CCActionInterval @@ -721,6 +755,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -729,6 +764,8 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }, /** + * called every frame with it's delta time.
    + * DON'T override unless you know what you are doing. * @param dt delta time in seconds */ step:function (dt) { @@ -745,6 +782,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }, /** + * Return true if the action has finished. * @return {Boolean} */ isDone:function () { @@ -752,17 +790,18 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.RepeatForever} */ reverse:function () { - var action = cc.repeatForever(this._innerAction.reverse()); + var action = new cc.RepeatForever(this._innerAction.reverse()); this._cloneDecoration(action); this._reverseEaseList(action); return action; }, /** - * + * Set inner action. * @param {cc.ActionInterval} action */ setInnerAction:function (action) { @@ -772,12 +811,14 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ }, /** + * Get inner action. * @return {cc.ActionInterval} */ getInnerAction:function () { return this._innerAction; } }); + /** * Create a acton which repeat forever * @function @@ -790,11 +831,12 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ cc.repeatForever = function (action) { return new cc.RepeatForever(action); }; + /** * Please use cc.repeatForever instead * Create a acton which repeat forever * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.repeatForever instead. * @param {cc.FiniteTimeAction} action * @return {cc.RepeatForever} */ @@ -878,6 +920,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -896,18 +939,20 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this._one) - this._one.update(time); + this._one.update(dt); if (this._two) - this._two.update(time); + this._two.update(dt); }, /** - * @return {cc.FiniteTimeAction} + * Returns a reversed action. + * @return {cc.Spawn} */ reverse:function () { var action = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse()); @@ -918,7 +963,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ }); /** - * Create a spawn action which runs several actions in parallel + * Create a spawn action which runs several actions in parallel. * @function * @param {Array|cc.FiniteTimeAction}tempArray * @return {cc.FiniteTimeAction} @@ -938,10 +983,12 @@ cc.spawn = function (/*Multiple Arguments*/tempArray) { } return prev; }; + /** - * Please use cc.spawn instead + * Please use cc.spawn instead. + * Create a spawn action which runs several actions in parallel. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.spawn instead. * @param {Array|cc.FiniteTimeAction}tempArray * @return {cc.FiniteTimeAction} */ @@ -960,7 +1007,8 @@ cc.Spawn._actionOneTwo = function (action1, action2) { }; -/** Rotates a cc.Node object to a certain angle by modifying it's +/** + * Rotates a cc.Node object to a certain angle by modifying it's. * rotation attribute.
    * The direction will be decided by the shortest angle. * @class @@ -991,6 +1039,7 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ }, /** + * Initializes the action. * @param {Number} duration * @param {Number} deltaAngleX * @param {Number} deltaAngleY @@ -1017,6 +1066,7 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1043,26 +1093,29 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ }, /** - * RotateTo reverse not implemented + * RotateTo reverse not implemented. + * Will be overridden. */ reverse:function () { cc.log("cc.RotateTo.reverse(): it should be overridden in subclass."); }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this.target) { - this.target.rotationX = this._startAngleX + this._diffAngleX * time; - this.target.rotationY = this._startAngleY + this._diffAngleY * time; + this.target.rotationX = this._startAngleX + this._diffAngleX * dt; + this.target.rotationY = this._startAngleY + this._diffAngleY * dt; } } }); /** - * Creates a RotateTo action with separate rotation angles + * Creates a RotateTo action with separate rotation angles. + * To specify the angle of rotation. * @function * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees. @@ -1075,11 +1128,13 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ cc.rotateTo = function (duration, deltaAngleX, deltaAngleY) { return new cc.RotateTo(duration, deltaAngleX, deltaAngleY); }; + /** * Please use cc.rotateTo instead - * Creates a RotateTo action with separate rotation angles + * Creates a RotateTo action with separate rotation angles. + * To specify the angle of rotation. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.rotateTo instead. * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees. * @param {Number} [deltaAngleY] deltaAngleY in degrees. @@ -1088,7 +1143,9 @@ cc.rotateTo = function (duration, deltaAngleX, deltaAngleY) { cc.RotateTo.create = cc.rotateTo; -/** Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute. +/** + * Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute. + * Relative to its properties to modify. * @class * @extends cc.ActionInterval */ @@ -1113,6 +1170,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }, /** + * Initializes the action. * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY=] deltaAngleY in degrees @@ -1139,6 +1197,7 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1148,21 +1207,23 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this.target) { - this.target.rotationX = this._startAngleX + this._angleX * time; - this.target.rotationY = this._startAngleY + this._angleY * time; + this.target.rotationX = this._startAngleX + this._angleX * dt; + this.target.rotationY = this._startAngleY + this._angleY * dt; } }, /** + * Returns a reversed action. * @return {cc.RotateBy} */ reverse:function () { - var action = cc.rotateBy(this._duration, -this._angleX, -this._angleY); + var action = new cc.RotateBy(this._duration, -this._angleX, -this._angleY); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -1170,6 +1231,8 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ }); /** + * Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute. + * Relative to its properties to modify. * @function * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees @@ -1183,9 +1246,11 @@ cc.rotateBy = function (duration, deltaAngleX, deltaAngleY) { return new cc.RotateBy(duration, deltaAngleX, deltaAngleY); }; /** - * Please use cc.rotateBy instead + * Please use cc.rotateBy instead. + * Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute. + * Relative to its properties to modify. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.rotateBy instead. * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY] deltaAngleY in degrees @@ -1228,6 +1293,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ }, /** + * Initializes the action. * @param {Number} duration duration in seconds * @param {cc.Point} position * @param {Number} [y] @@ -1259,7 +1325,8 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ }, /** - * @param {Number} target + * Start the action with target. + * @param {cc.Node} target */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); @@ -1272,13 +1339,14 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this.target) { - var x = this._positionDelta.x * time; - var y = this._positionDelta.y * time; + var x = this._positionDelta.x * dt; + var y = this._positionDelta.y * dt; var locStartPosition = this._startPosition; if (cc.ENABLE_STACKABLE_ACTIONS) { var targetX = this.target.getPositionX(); @@ -1300,9 +1368,10 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ /** * MoveTo reverse is not implemented + * @return {cc.MoveBy} */ reverse:function () { - var action = cc.moveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); + var action = new cc.MoveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y)); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -1310,6 +1379,8 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ }); /** + * Create the action. + * Relative to its coordinate moves a certain distance. * @function * @param {Number} duration duration in seconds * @param {cc.Point|Number} deltaPos @@ -1323,7 +1394,8 @@ cc.moveBy = function (duration, deltaPos, deltaY) { return new cc.MoveBy(duration, deltaPos, deltaY); }; /** - * Please use cc.moveBy instead + * Please use cc.moveBy instead. + * Relative to its coordinate moves a certain distance. * @static * @deprecated * @param {Number} duration duration in seconds @@ -1360,6 +1432,7 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ }, /** + * Initializes the action. * @param {Number} duration duration in seconds * @param {cc.Point} position * @param {Number} y @@ -1391,6 +1464,7 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1399,7 +1473,10 @@ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ this._positionDelta.y = this._endPosition.y - target.getPositionY(); } }); + /** + * Create new action. + * Moving to the specified coordinates. * @function * @param {Number} duration duration in seconds * @param {cc.Point} position @@ -1413,9 +1490,10 @@ cc.moveTo = function (duration, position, y) { return new cc.MoveTo(duration, position, y); }; /** - * Please use cc.moveTo instead + * Please use cc.moveTo instead. + * Moving to the specified coordinates. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.moveTo instead. * @param {Number} duration duration in seconds * @param {cc.Point} position * @param {Number} y @@ -1453,6 +1531,7 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ }, /** + * Initializes the action. * @param {Number} t time in seconds * @param {Number} sx * @param {Number} sy @@ -1480,6 +1559,7 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1501,15 +1581,19 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ }, /** - * @param {Number} t time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (t) { - t = this._computeEaseTime(t); - this.target.skewX = this._startSkewX + this._deltaX * t; - this.target.skewY = this._startSkewY + this._deltaY * t; + update:function (dt) { + dt = this._computeEaseTime(dt); + this.target.skewX = this._startSkewX + this._deltaX * dt; + this.target.skewY = this._startSkewY + this._deltaY * dt; } }); /** + * Create new action. + * Skews a cc.Node object to given angles by modifying it's skewX and skewY attributes. + * Changes to the specified value. * @function * @param {Number} t time in seconds * @param {Number} sx @@ -1523,9 +1607,11 @@ cc.skewTo = function (t, sx, sy) { return new cc.SkewTo(t, sx, sy); }; /** - * Please use cc.skewTo instead + * Please use cc.skewTo instead. + * Skews a cc.Node object to given angles by modifying it's skewX and skewY attributes。 + * Changes to the specified value. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.skewTo instead. * @param {Number} t time in seconds * @param {Number} sx * @param {Number} sy @@ -1533,7 +1619,9 @@ cc.skewTo = function (t, sx, sy) { */ cc.SkewTo.create = cc.skewTo; -/** Skews a cc.Node object by skewX and skewY degrees +/** + * Skews a cc.Node object by skewX and skewY degrees. + * Relative to its attribute modification. * @class * @extends cc.SkewTo */ @@ -1551,6 +1639,7 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ }, /** + * Initializes the action. * @param {Number} t time in seconds * @param {Number} deltaSkewX skew in degrees for X axis * @param {Number} deltaSkewY skew in degrees for Y axis @@ -1578,6 +1667,7 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ }, /** + * Start the action width target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1589,16 +1679,20 @@ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.SkewBy} */ reverse:function () { - var action = cc.skewBy(this._duration, -this._skewX, -this._skewY); + var action = new cc.SkewBy(this._duration, -this._skewX, -this._skewY); this._cloneDecoration(action); this._reverseEaseList(action); return action; } }); + /** + * Skews a cc.Node object by skewX and skewY degrees.
    + * Relative to its attribute modification. * @function * @param {Number} t time in seconds * @param {Number} sx sx skew in degrees for X axis @@ -1612,7 +1706,9 @@ cc.skewBy = function (t, sx, sy) { return new cc.SkewBy(t, sx, sy); }; /** - * Please use cc.skewBy instead + * Please use cc.skewBy instead.
    + * Skews a cc.Node object by skewX and skewY degrees.
    + * Relative to its attribute modification. * @static * @deprecated * @param {Number} t time in seconds @@ -1623,7 +1719,9 @@ cc.skewBy = function (t, sx, sy) { cc.SkewBy.create = cc.skewBy; -/** Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute. +/** + * Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute. + * Relative to its movement. * @class * @extends cc.ActionInterval */ @@ -1654,6 +1752,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ height !== undefined && this.initWithDuration(duration, position, y, height, jumps); }, /** + * Initializes the action. * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -1693,6 +1792,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1706,16 +1806,17 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this.target) { - var frac = time * this._jumps % 1.0; + var frac = dt * this._jumps % 1.0; var y = this._height * 4 * frac * (1 - frac); - y += this._delta.y * time; + y += this._delta.y * dt; - var x = this._delta.x * time; + var x = this._delta.x * dt; var locStartPosition = this._startPosition; if (cc.ENABLE_STACKABLE_ACTIONS) { var targetX = this.target.getPositionX(); @@ -1736,10 +1837,11 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.JumpBy} */ reverse:function () { - var action = cc.jumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); + var action = new cc.JumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -1747,6 +1849,8 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ }); /** + * Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute. + * Relative to its movement. * @function * @param {Number} duration * @param {cc.Point|Number} position @@ -1763,7 +1867,9 @@ cc.jumpBy = function (duration, position, y, height, jumps) { return new cc.JumpBy(duration, position, y, height, jumps); }; /** - * Please use cc.jumpBy instead + * Please use cc.jumpBy instead.
    + * Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute.
    + * Relative to its movement. * @static * @deprecated * @param {Number} duration @@ -1775,7 +1881,9 @@ cc.jumpBy = function (duration, position, y, height, jumps) { */ cc.JumpBy.create = cc.jumpBy; -/** Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute. +/** + * Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute.
    + * Jump to the specified location. * @class * @extends cc.JumpBy */ @@ -1800,6 +1908,7 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ height !== undefined && this.initWithDuration(duration, position, y, height, jumps); }, /** + * Initializes the action. * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -1823,6 +1932,7 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ return false; }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1844,6 +1954,8 @@ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ }); /** + * Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute.
    + * Jump to the specified location. * @function * @param {Number} duration * @param {cc.Point|Number} position @@ -1860,7 +1972,9 @@ cc.jumpTo = function (duration, position, y, height, jumps) { return new cc.JumpTo(duration, position, y, height, jumps); }; /** - * Please use cc.jumpTo instead + * Please use cc.jumpTo instead. + * Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute.
    + * Jump to the specified location. * @static * @deprecated * @param {Number} duration @@ -1889,6 +2003,7 @@ cc.bezierAt = function (a, b, c, d, t) { }; /** An action that moves the target with a cubic Bezier curve by a certain distance. + * Relative to its movement. * @class * @extends cc.ActionInterval */ @@ -1914,6 +2029,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ c && this.initWithDuration(t, c); }, /** + * Initializes the action. * @param {Number} t time in seconds * @param {Array} c Array of points * @return {Boolean} @@ -1943,6 +2059,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1956,10 +2073,11 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ }, /** + * Called once per frame. Time is the number of seconds of a frame interval. * @param {Number} time */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this.target) { var locConfig = this._config; var xa = 0; @@ -1972,8 +2090,8 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ var yc = locConfig[1].y; var 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, dt); + var y = cc.bezierAt(ya, yb, yc, yd, dt); var locStartPosition = this._startPosition; if (cc.ENABLE_STACKABLE_ACTIONS) { @@ -1995,7 +2113,8 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.BezierBy} */ reverse:function () { var locConfig = this._config; @@ -2003,7 +2122,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ cc.pAdd(locConfig[1], cc.pNeg(locConfig[2])), cc.pAdd(locConfig[0], cc.pNeg(locConfig[2])), cc.pNeg(locConfig[2]) ]; - var action = cc.bezierBy(this._duration, r); + var action = new cc.BezierBy(this._duration, r); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -2011,6 +2130,8 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ }); /** + * An action that moves the target with a cubic Bezier curve by a certain distance. + * Relative to its movement. * @function * @param {Number} t time in seconds * @param {Array} c Array of points @@ -2024,7 +2145,9 @@ cc.bezierBy = function (t, c) { return new cc.BezierBy(t, c); }; /** - * Please use cc.bezierBy instead + * Please use cc.bezierBy instead. + * An action that moves the target with a cubic Bezier curve by a certain distance. + * Relative to its movement. * @static * @deprecated * @param {Number} t time in seconds @@ -2056,6 +2179,7 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ }, /** + * Initializes the action. * @param {Number} t time in seconds * @param {Array} c Array of points * @return {Boolean} @@ -2080,6 +2204,7 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -2094,6 +2219,7 @@ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ } }); /** + * An action that moves the target with a cubic Bezier curve to a destination point. * @function * @param {Number} t * @param {Array} c array of points @@ -2150,6 +2276,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ }, /** + * Initializes the action. * @param {Number} duration * @param {Number} sx * @param {Number} [sy=] @@ -2176,6 +2303,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -2187,17 +2315,19 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ }, /** + * Called once per frame. Time is the number of seconds of a frame interval. * @param {Number} time */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this.target) { - this.target.scaleX = this._startScaleX + this._deltaX * time; - this.target.scaleY = this._startScaleY + this._deltaY * time; + this.target.scaleX = this._startScaleX + this._deltaX * dt; + this.target.scaleY = this._startScaleY + this._deltaY * dt; } } }); /** + * Scales a cc.Node object to a zoom factor by modifying it's scale attribute. * @function * @param {Number} duration * @param {Number} sx scale parameter in X @@ -2215,7 +2345,8 @@ cc.scaleTo = function (duration, sx, sy) { //function overload return new cc.ScaleTo(duration, sx, sy); }; /** - * Please use cc.scaleTo instead + * Please use cc.scaleTo instead. + * Scales a cc.Node object to a zoom factor by modifying it's scale attribute. * @static * @deprecated * @param {Number} duration @@ -2227,12 +2358,14 @@ cc.ScaleTo.create = cc.scaleTo; /** Scales a cc.Node object a zoom factor by modifying it's scale attribute. + * Relative to its changes. * @class * @extends cc.ScaleTo */ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ /** - * @param {Number} target + * Start the action with target. + * @param {cc.Node} target */ startWithTarget:function (target) { cc.ScaleTo.prototype.startWithTarget.call(this, target); @@ -2241,10 +2374,11 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.ScaleBy} */ reverse:function () { - var action = cc.scaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); + var action = new cc.ScaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -2262,6 +2396,8 @@ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{ } }); /** + * Scales a cc.Node object a zoom factor by modifying it's scale attribute. + * Relative to its changes. * @function * @param {Number} duration duration in seconds * @param {Number} sx sx scale parameter in X @@ -2278,7 +2414,9 @@ cc.scaleBy = function (duration, sx, sy) { return new cc.ScaleBy(duration, sx, sy); }; /** - * Please use cc.scaleBy instead + * Please use cc.scaleBy instead. + * Scales a cc.Node object a zoom factor by modifying it's scale attribute. + * Relative to its changes. * @static * @deprecated * @param {Number} duration duration in seconds @@ -2309,6 +2447,7 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ }, /** + * Initializes the action. * @param {Number} duration duration in seconds * @param {Number} blinks blinks in times * @return {Boolean} @@ -2333,38 +2472,48 @@ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt time in seconds */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this.target && !this.isDone()) { var slice = 1.0 / this._times; - var m = time % slice; + var m = dt % slice; this.target.visible = (m > (slice / 2)); } }, + /** + * Start the action with target. + * @param {cc.Node} target + */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); this._originalState = target.visible; }, + /** + * stop the action + */ stop:function () { this.target.visible = this._originalState; cc.ActionInterval.prototype.stop.call(this); }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.Blink} */ reverse:function () { - var action = cc.blink(this._duration, this._times); + var action = new cc.Blink(this._duration, this._times); this._cloneDecoration(action); this._reverseEaseList(action); return action; } }); /** + * Blinks a cc.Node object by modifying it's visible attribute. * @function * @param {Number} duration duration in seconds * @param blinks blinks in times @@ -2377,7 +2526,8 @@ cc.blink = function (duration, blinks) { return new cc.Blink(duration, blinks); }; /** - * Please use cc.blink instead + * Please use cc.blink instead. + * Blinks a cc.Node object by modifying it's visible attribute. * @static * @deprecated * @param {Number} duration duration in seconds @@ -2408,6 +2558,7 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ }, /** + * Initializes the action. * @param {Number} duration duration in seconds * @param {Number} opacity * @return {Boolean} @@ -2432,6 +2583,7 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ }, /** + * Called once per frame. Time is the number of seconds of a frame interval. * @param {Number} time time in seconds */ update:function (time) { @@ -2442,17 +2594,17 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ }, /** - * @param {cc.Sprite} target + * Start this action with target. + * @param {cc.Node} target */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); - this._fromOpacity = target.opacity; - } }); /** + * Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. * @function * @param {Number} duration * @param {Number} opacity 0-255, 0 is transparent @@ -2465,7 +2617,8 @@ cc.fadeTo = function (duration, opacity) { return new cc.FadeTo(duration, opacity); }; /** - * Please use cc.fadeTo instead + * Please use cc.fadeTo instead. + * Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. * @static * @deprecated * @param {Number} duration @@ -2492,7 +2645,8 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.FadeOut} */ reverse:function () { var action = new cc.FadeOut(); @@ -2514,7 +2668,8 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ }, /** - * @param {cc.Sprite} target + * Start the action with target. + * @param {cc.Node} target */ startWithTarget:function (target) { if(this._reverseAction) @@ -2524,6 +2679,7 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ }); /** + * Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. * @function * @param {Number} duration duration in seconds * @return {cc.FadeIn} @@ -2535,7 +2691,8 @@ cc.fadeIn = function (duration) { return new cc.FadeIn(duration); }; /** - * Please use cc.fadeIn instead + * Please use cc.fadeIn instead. + * Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. * @static * @deprecated * @param {Number} duration duration in seconds @@ -2561,7 +2718,8 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.FadeIn} */ reverse:function () { var action = new cc.FadeIn(); @@ -2585,6 +2743,7 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ }); /** + * Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. * @function * @param {Number} d duration in seconds * @return {cc.FadeOut} @@ -2596,7 +2755,8 @@ cc.fadeOut = function (d) { return new cc.FadeOut(d); }; /** - * Please use cc.fadeOut instead + * Please use cc.fadeOut instead. + * Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. * @static * @deprecated * @param {Number} d duration in seconds @@ -2631,6 +2791,7 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ }, /** + * Initializes the action. * @param {Number} duration * @param {Number} red 0-255 * @param {Number} green 0-255 @@ -2658,7 +2819,8 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ }, /** - * @param {cc.Sprite} target + * Start the action with target. + * @param {cc.Node} target */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); @@ -2667,20 +2829,22 @@ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt time in seconds */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); var locFrom = this._from, locTo = this._to; if (locFrom) { - this.target.color = cc.color(locFrom.r + (locTo.r - locFrom.r) * time, - locFrom.g + (locTo.g - locFrom.g) * time, - locFrom.b + (locTo.b - locFrom.b) * time); + this.target.color = cc.color(locFrom.r + (locTo.r - locFrom.r) * dt, + locFrom.g + (locTo.g - locFrom.g) * dt, + locFrom.b + (locTo.b - locFrom.b) * dt); } } }); /** + * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. * @function * @param {Number} duration * @param {Number} red 0-255 @@ -2695,7 +2859,8 @@ cc.tintTo = function (duration, red, green, blue) { return new cc.TintTo(duration, red, green, blue); }; /** - * Please use cc.tintTo instead + * Please use cc.tintTo instead. + * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. * @static * @deprecated * @param {Number} duration @@ -2708,6 +2873,7 @@ cc.TintTo.create = cc.tintTo; /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. + * Relative to their own color change. * @class * @extends cc.ActionInterval */ @@ -2735,6 +2901,7 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ }, /** + * Initializes the action. * @param {Number} duration * @param {Number} deltaRed 0-255 * @param {Number} deltaGreen 0-255 @@ -2763,7 +2930,8 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ }, /** - * @param {cc.Sprite} target + * Start the action with target. + * @param {cc.Node} target */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); @@ -2776,22 +2944,24 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt time in seconds */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); - this.target.color = cc.color(this._fromR + this._deltaR * time, - this._fromG + this._deltaG * time, - this._fromB + this._deltaB * time); + this.target.color = cc.color(this._fromR + this._deltaR * dt, + this._fromG + this._deltaG * dt, + this._fromB + this._deltaB * dt); }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.TintBy} */ reverse:function () { - var action = cc.tintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); + var action = new cc.TintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -2799,6 +2969,8 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ }); /** + * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. + * Relative to their own color change. * @function * @param {Number} duration duration in seconds * @param {Number} deltaRed @@ -2813,7 +2985,9 @@ cc.tintBy = function (duration, deltaRed, deltaGreen, deltaBlue) { return new cc.TintBy(duration, deltaRed, deltaGreen, deltaBlue); }; /** - * Please use cc.tintBy instead + * Please use cc.tintBy instead. + * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. + * Relative to their own color change. * @static * @deprecated * @param {Number} duration duration in seconds @@ -2830,16 +3004,18 @@ cc.TintBy.create = cc.tintBy; */ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * Will be overwrite. + * @param {Number} dt time in seconds */ - update:function (time) { - }, + update:function (dt) {}, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.DelayTime} */ reverse:function () { - var action = cc.delayTime(this._duration); + var action = new cc.DelayTime(this._duration); this._cloneDecoration(action); this._reverseEaseList(action); return action; @@ -2858,6 +3034,7 @@ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{ }); /** + * Delays the action a certain amount of seconds * @function * @param {Number} d duration in seconds * @return {cc.DelayTime} @@ -2869,7 +3046,8 @@ cc.delayTime = function (d) { return new cc.DelayTime(d); }; /** - * Please use cc.delayTime instead + * Please use cc.delayTime instead. + * Delays the action a certain amount of seconds * @static * @deprecated * @param {Number} d duration in seconds @@ -2933,6 +3111,7 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ }, /** + * Start the action with target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -2941,15 +3120,17 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ }, /** - * @param {Number} time time in seconds + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt time in seconds */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); if (this._other) - this._other.update(1 - time); + this._other.update(1 - dt); }, /** + * Returns a reversed action. * @return {cc.ActionInterval} */ reverse:function () { @@ -2966,6 +3147,7 @@ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ }); /** + * Executes an action in reverse order, from time=duration to time=0. * @function * @param {cc.FiniteTimeAction} action * @return {cc.ReverseTime} @@ -2977,7 +3159,8 @@ cc.reverseTime = function (action) { return new cc.ReverseTime(action); }; /** - * Please use cc.reverseTime instead + * Please use cc.reverseTime instead. + * Executes an action in reverse order, from time=duration to time=0. * @static * @deprecated * @param {cc.FiniteTimeAction} action @@ -3072,6 +3255,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ }, /** + * Start the action with target. * @param {cc.Sprite} target */ startWithTarget:function (target) { @@ -3083,29 +3267,30 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - time = this._computeEaseTime(time); + update:function (dt) { + dt = this._computeEaseTime(dt); // if t==1, ignore. Animation should finish with t==1 - if (time < 1.0) { - time *= this._animation.getLoops(); + if (dt < 1.0) { + dt *= this._animation.getLoops(); // new loop? If so, reset frame counter - var loopNumber = 0 | time; + var loopNumber = 0 | dt; if (loopNumber > this._executedLoops) { this._nextFrame = 0; this._executedLoops++; } // new t for animations - time = time % 1.0; + dt = dt % 1.0; } var frames = this._animation.getFrames(); var numberOfFrames = frames.length, locSplitTimes = this._splitTimes; for (var i = this._nextFrame; i < numberOfFrames; i++) { - if (locSplitTimes[i] <= time) { + if (locSplitTimes[i] <= dt) { this.target.setSpriteFrame(frames[i].getSpriteFrame()); this._nextFrame = i + 1; } else { @@ -3116,7 +3301,8 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ }, /** - * @return {cc.ActionInterval} + * Returns a reversed action. + * @return {cc.Animate} */ reverse:function () { var locAnimation = this._animation; @@ -3133,7 +3319,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ } var newAnim = cc.Animation.create(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops()); newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame()); - var action = cc.animate(newAnim); + var action = new cc.Animate(newAnim); this._cloneDecoration(action); this._reverseEaseList(action); @@ -3222,18 +3408,29 @@ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{ return action; }, + /** + * Start the action with target. + * @param {cc.Node} target + */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); this._action.startWithTarget(this._forcedTarget); }, + /** + * stop the action + */ stop:function () { this._action.stop(); }, - update:function (time) { - time = this._computeEaseTime(time); - this._action.update(time); + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt + */ + update:function (dt) { + dt = this._computeEaseTime(dt); + this._action.update(dt); }, /** diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index 76cc399073..0c3e7f6057 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -25,19 +25,18 @@ ****************************************************************************/ /** + * * @class * @extends cc.Class */ cc.ActionTweenDelegate = cc.Class.extend(/** @lends cc.ActionTweenDelegate */{ /** - * @function + * Update Tween Action. * @param value * @param key */ - updateTweenAction:function(value, key){ - - } + updateTweenAction:function(value, key){} }); /** @@ -94,8 +93,10 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ } return false; }, + /** - * @param {cc.Node} target + * Start this tween with target. + * @param {cc.ActionTweenDelegate} target */ startWithTarget:function (target) { if(!target || !target.updateTweenAction) @@ -103,19 +104,30 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ cc.ActionInterval.prototype.startWithTarget.call(this, target); this.delta = this.to - this.from; }, + /** - * @param {Number} dt + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt */ update:function (dt) { this.target.updateTweenAction(this.to - this.delta * (1 - dt), this.key); }, + /** + * returns a reversed action. * @return {cc.ActionTween} */ reverse:function () { - return cc.actionTween(this.duration, this.key, this.to, this.from); + return new cc.ActionTween(this.duration, this.key, this.to, this.from); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.ActionTween} + */ clone:function(){ var action = new cc.ActionTween(); action.initWithDuration(this._duration, this.key, this.from, this.to); @@ -135,11 +147,12 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ cc.actionTween = function (duration, key, from, to) { return new cc.ActionTween(duration, key, from, to); }; + /** - * Please use cc.actionTween instead + * Please use cc.actionTween instead. * Creates an initializes the action with the property name (key), and the from and to parameters. * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.actionTween instead. * @param {Number} duration * @param {String} key * @param {Number} from From 5559d15200b21a66b5d305fe46a1c6b2c06275f1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 22 Aug 2014 17:05:05 +0800 Subject: [PATCH 0494/1564] Fixed a bug of cc.Sprite.setColor that it doesn't work when its originalTexture is Canvas element --- cocos2d/core/sprites/CCSprite.js | 4 +++- cocos2d/core/textures/CCTexture2D.js | 2 +- cocos2d/render-texture/CCRenderTexture.js | 4 ++++ template/src/myApp.js | 8 -------- template/src/resource.js | 1 - 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 95b9d16c2f..7cec843d87 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -34,6 +34,7 @@ */ cc.generateTintImageWithMultiply = function(image, color, rect, renderCanvas){ renderCanvas = renderCanvas || cc.newElement("canvas"); + rect = rect || cc.rect(0,0, image.width, image.height); var context = renderCanvas.getContext( "2d" ); @@ -1051,7 +1052,8 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ return; this._colorized = true; - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor + && this._originalTexture._htmlElementObj != locElement) cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); else { locElement = cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 5a3745d22d..4eb3dd82c9 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -167,7 +167,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { /** * HTMLElement Object getter - * @return {HTMLElement} + * @return {HTMLImageElement|HTMLCanvasElement} */ getHtmlElementObj: function () { return this._htmlElementObj; diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index b0910212b5..0a3f1098ac 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -130,6 +130,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ */ _ctorForCanvas: function (width, height, format, depthStencilFormat) { cc.Node.prototype.ctor.call(this); + this._cascadeColorEnabled = true; + this._cascadeOpacityEnabled = true; this._clearColor = cc.color(255, 255, 255, 255); this._clearColorStr = "rgba(255,255,255,1)"; @@ -158,6 +160,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ */ _ctorForWebGL: function (width, height, format, depthStencilFormat) { cc.Node.prototype.ctor.call(this); + this._cascadeColorEnabled = true; + this._cascadeOpacityEnabled = true; this._clearColor = cc.color(0, 0, 0, 0); if(width !== undefined && height !== undefined){ diff --git a/template/src/myApp.js b/template/src/myApp.js index 3b1b22cd3f..279dd05ba8 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -102,14 +102,6 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height/this.sprite.getContentSize().height); this.addChild(this.sprite, 0); - - var hair = new cc.Sprite("style3.png"); - hair.setPosition(size.width / 2, size.height / 2); - this.addChild(hair, 10); - - //hair.setColor(cc.color.RED); - - window.hair = hair; } }); diff --git a/template/src/resource.js b/template/src/resource.js index 1e3eebe017..94284083d1 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -6,7 +6,6 @@ var g_resources = [ //image s_HelloWorld, s_CloseNormal, - "style3.png", s_CloseSelected //plist From ee32f056bc9164b42d94e18b871323c27355a0f2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 22 Aug 2014 17:11:41 +0800 Subject: [PATCH 0495/1564] Remove the Test codes. --- template/src/myApp.js | 58 ------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/template/src/myApp.js b/template/src/myApp.js index 279dd05ba8..ec63dece90 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -1,61 +1,3 @@ -cc.Sprite.prototype.setBorder = function(cr, cg, cb, ca , r, f){ - var _dfc = cc.color.WHITE; - r = r || (arguments.length == 2 ? cg : 5); - f = f || 1;//精细度 - switch (arguments.length){ - case 0: cr = _dfc.r; cg = _dfc.g; cb = _dfc.b; ca = _dfc.a; break; - case 1: - case 2: cg = cr.g; cb = cr.b; ca = cr.a; cr = cr.r; break; - case 3: ca = _dfc.a; break; - } - var that = this, - x = that.x, y = that.y, - w = that.width, h = that.height, - dc = cc.size(w + r, h + r); - that.removeBorder(); - - var mTxt = new cc.RenderTexture(dc.width, dc.height), - cx = 0, ox = dc.width / 2, oy = dc.height / 2; - - var visitSprite = function(xx, yy){ - if(cc.sys.isNative){ - var spr = new cc.Sprite(that.getTexture()); - spr.attr({x : xx, y : yy, width : w, height : h}); - spr.visit(); - } else { - that.setPosition(xx, yy); - that.visit(); - } - }; - - mTxt.beginWithClear(0, 0, 0, 0); - for(var rd = 0; rd <= r; rd += f){ - cx = Math.sqrt(Math.pow(r, 2) - Math.pow(rd, 2)); - visitSprite(ox + rd, oy + cx); - visitSprite(ox - rd, oy + cx); - visitSprite(ox - rd, oy - cx); - visitSprite(ox + rd, oy - cx); - } - mTxt.end(); - that.setPosition(x, y); - - var nTxt = new cc.RenderTexture(dc.width, dc.height); - nTxt.setPosition(w / 2, h / 2); - - mTxt.setPosition(ox, oy); - mTxt.getSprite().setBlendFunc(cc.ZERO, cc.SRC_ALPHA); - nTxt.beginWithClear(cr, cg, cb, ca); - mTxt.visit(); - nTxt.end(); - - that.addChild(that.borderTex = nTxt, -1); - return nTxt; -}; - -cc.Sprite.prototype.removeBorder = function(){ - this.borderTex && this.borderTex.removeFromParent(true); -}; - var MyLayer = cc.Layer.extend({ helloLabel:null, sprite:null, From 370483f6652ab1fa668243a919b9799890f548bb Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 23 Aug 2014 10:05:14 +0800 Subject: [PATCH 0496/1564] Fixed #5832: fixed the bug of cc.RenderTexture that it doesn't run some actions on Canvas mode. --- cocos2d/render-texture/CCRenderTexture.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 0a3f1098ac..5dac392e3d 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -213,8 +213,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @function * @param {Number} width * @param {Number} height - * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format - * @param {Number} depthStencilFormat + * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} [format] + * @param {Number} [depthStencilFormat] * @return {Boolean} */ initWithWidthAndHeight: null, @@ -227,7 +227,12 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ var texture = new cc.Texture2D(); texture.initWithElement(locCacheCanvas); texture.handleLoadedTexture(); - this.sprite = cc.Sprite.create(texture); + var locSprite = this.sprite = cc.Sprite.create(texture); + locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); + // Disabled by default. + this.autoDraw = false; + // add sprite for backward compatibility + this.addChild(locSprite); return true; }, From 6552c7f2ec9a9810663510674a093933aab08926 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 23 Aug 2014 10:27:34 +0800 Subject: [PATCH 0497/1564] Issue #5835: modify The return value of the Facebook interface --- external/pluginx/platform/facebook.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index e4cbcd9727..7e58af110a 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -327,9 +327,10 @@ plugin.extend('facebook', { * Reference document * https://developers.facebook.com/docs/payments/reference/paydialog */ - - info.method = 'pay'; - info.action = 'purchaseitem'; + if(!info['method']) + info['method'] = 'pay'; + if(!info['action']) + info['action'] = 'purchaseitem'; FB.ui(info, function(response) { if(response['error_code']){ From 5680cb8fd484c12d85544f0951ef20ec49523f4a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 23 Aug 2014 11:17:17 +0800 Subject: [PATCH 0498/1564] Issue #5841: IOS Audio bug --- cocos2d/audio/CCAudio.js | 69 ++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index e14e599cc9..709329a5d1 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -333,15 +333,21 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ var audio = self._currMusic; if (audio) this._stopAudio(audio); - if (url != self._currMusicPath) { + if(cc.sys.isMobile && cc.sys.os == cc.sys.OS_IOS){ audio = self._getAudioByUrl(url); - self._currMusic = audio; + self._currMusic = audio.cloneNode(); self._currMusicPath = url; + }else{ + if (url != self._currMusicPath) { + audio = self._getAudioByUrl(url); + self._currMusic = audio; + self._currMusicPath = url; + } } - if (!audio) + if (!self._currMusic) return; - audio.loop = loop || false; - self._playMusic(audio); + self._currMusic.loop = loop || false; + self._playMusic(self._currMusic); }, _getAudioByUrl: function (url) { var locLoader = cc.loader, audio = locLoader.getRes(url); @@ -497,33 +503,42 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (!self._soundSupported) return null; var effList = this._getEffectList(url); - for (var i = 0, li = effList.length; i < li; i++) { - var eff = effList[i]; - if (eff.ended) { - audio = eff; - if (audio.readyState > 2) - audio.currentTime = 0; - if (window.chrome) - audio.load(); - break; + if(cc.sys.isMobile && cc.sys.os == cc.sys.OS_IOS){ + audio = this._getEffectAudio(effList, url); + }else{ + for (var i = 0, li = effList.length; i < li; i++) { + var eff = effList[i]; + if (eff.ended) { + audio = eff; + if (audio.readyState > 2) + audio.currentTime = 0; + if (window.chrome) + audio.load(); + break; + } } - } - if (!audio) { - if (effList.length >= this._maxAudioInstance) { - cc.log("Error: " + url + " greater than " + this._maxAudioInstance); - return null; + if (!audio) { + audio = this._getEffectAudio(effList, url); + audio && effList.push(audio); } - audio = self._getAudioByUrl(url); - if (!audio) - return null; - audio = audio.cloneNode(true); - if (self._effectPauseCb) - cc._addEventListener(audio, "pause", self._effectPauseCb); - audio.volume = this._effectsVolume; - effList.push(audio); } return audio; }, + _getEffectAudio: function(effList, url){ + var audio; + if (effList.length >= this._maxAudioInstance) { + cc.log("Error: " + url + " greater than " + this._maxAudioInstance); + return null; + } + audio = this._getAudioByUrl(url); + if (!audio) + return null; + audio = audio.cloneNode(true); + if (this._effectPauseCb) + cc._addEventListener(audio, "pause", this._effectPauseCb); + audio.volume = this._effectsVolume; + return audio; + }, /** * Play sound effect. * @param {String} url The path of the sound effect with filename extension. From 4611aaa0334c75850a718117804364e4e4b0ddfc Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 23 Aug 2014 12:17:25 +0800 Subject: [PATCH 0499/1564] Fixed #5830: update the ctor jsDoc of CCParticleExamples.js and CCTransition.js --- cocos2d/particle/CCParticleExamples.js | 39 +++---- cocos2d/transitions/CCTransition.js | 105 +++++++++++------- .../ccui/base-classes/CCProtectedNode.js | 1 + 3 files changed, 88 insertions(+), 57 deletions(-) diff --git a/cocos2d/particle/CCParticleExamples.js b/cocos2d/particle/CCParticleExamples.js index 9d1b22c20b..be67f46645 100644 --- a/cocos2d/particle/CCParticleExamples.js +++ b/cocos2d/particle/CCParticleExamples.js @@ -34,7 +34,8 @@ */ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{ /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 300 : 150); @@ -122,9 +123,9 @@ cc.ParticleFire.create = function () { * var emitter = cc.ParticleFireworks.create(); */ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1500 : 150); @@ -209,9 +210,9 @@ cc.ParticleFireworks.create = function () { * var emitter = cc.ParticleSun.create(); */ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 350 : 150); @@ -299,9 +300,9 @@ cc.ParticleSun.create = function () { * var emitter = cc.ParticleGalaxy.create(); */ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); @@ -480,9 +481,9 @@ cc.ParticleFlower.create = function () { * var emitter = cc.ParticleMeteor.create(); */ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 150 : 100); @@ -572,9 +573,9 @@ cc.ParticleMeteor.create = function () { * var emitter = cc.ParticleSpiral.create(); */ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function() { cc.ParticleSystem.prototype.ctor.call(this,(cc._renderType === cc._RENDER_TYPE_WEBGL) ? 500 : 100); @@ -664,9 +665,9 @@ cc.ParticleSpiral.create = function () { * var emitter = cc.ParticleExplosion.create(); */ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 300); @@ -755,9 +756,9 @@ cc.ParticleExplosion.create = function () { * var emitter = cc.ParticleSmoke.create(); */ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{ - /** - * @contructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); @@ -843,9 +844,9 @@ cc.ParticleSmoke.create = function () { * var emitter = cc.ParticleSnow.create(); */ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 250); @@ -936,9 +937,9 @@ cc.ParticleSnow.create = function () { * var emitter = cc.ParticleRain.create(); */ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{ - /** - * @constructor + * Constructor + * @function */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1000 : 300); diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index fc0bc58f00..f22dc6c974 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -70,6 +70,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ /** * creates a base transition with duration and incoming scene * Constructor of cc.TransitionScene + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to transit with */ @@ -249,7 +250,8 @@ cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionS _orientation:0, /** - * @constructor + * Constructor of TransitionSceneOriented + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation @@ -296,7 +298,8 @@ cc.TransitionSceneOriented.create = function (t, scene, orientation) { cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZoom# */{ /** - * @constructor + * Constructor of TransitionRotoZoom + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -355,7 +358,8 @@ cc.TransitionRotoZoom.create = function (t, scene) { */ cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZoom# */{ /** - * @constructor + * Constructor of TransitionJumpZoom + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -411,7 +415,8 @@ cc.TransitionJumpZoom.create = function (t, scene) { */ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL# */{ /** - * @constructor + * Constructor of TransitionMoveInL + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -477,7 +482,8 @@ cc.TransitionMoveInL.create = function (t, scene) { */ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInR# */{ /** - * @constructor + * Constructor of TransitionMoveInR + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -514,7 +520,8 @@ cc.TransitionMoveInR.create = function (t, scene) { */ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInT# */{ /** - * @constructor + * Constructor of TransitionMoveInT + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -551,7 +558,8 @@ cc.TransitionMoveInT.create = function (t, scene) { */ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInB# */{ /** - * @constructor + * Constructor of TransitionMoveInB + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -599,7 +607,8 @@ cc.ADJUST_FACTOR = 0.5; */ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideInL# */{ /** - * @constructor + * Constructor of TransitionSlideInL + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -671,7 +680,8 @@ cc.TransitionSlideInL.create = function (t, scene) { */ cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInR# */{ /** - * @constructor + * Constructor of TransitionSlideInR + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -718,7 +728,8 @@ cc.TransitionSlideInR.create = function (t, scene) { */ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInB# */{ /** - * @constructor + * Constructor of TransitionSlideInB + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -767,7 +778,8 @@ cc.TransitionSlideInB.create = function (t, scene) { */ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInT# */{ /** - * @constructor + * Constructor of TransitionSlideInT + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -816,7 +828,8 @@ cc.TransitionSlideInT.create = function (t, scene) { */ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShrinkGrow# */{ /** - * @constructor + * Constructor of TransitionShrinkGrow + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -881,7 +894,8 @@ cc.TransitionShrinkGrow.create = function (t, scene) { */ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipX# */{ /** - * @constructor + * Constructor of TransitionFlipX + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -959,7 +973,8 @@ cc.TransitionFlipX.create = function (t, scene, o) { cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipY# */{ /** - * @constructor + * Constructor of TransitionFlipY + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1033,9 +1048,9 @@ cc.TransitionFlipY.create = function (t, scene, o) { * @extends cc.TransitionSceneOriented */ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipAngular# */{ - /** - * @constructor + * Constructor of TransitionFlipAngular + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1111,7 +1126,8 @@ cc.TransitionFlipAngular.create = function (t, scene, o) { cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipX# */{ /** - * @constructor + * Constructor of TransitionZoomFlipX + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1193,7 +1209,8 @@ cc.TransitionZoomFlipX.create = function (t, scene, o) { cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipY# */{ /** - * @constructor + * Constructor of TransitionZoomFlipY + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1273,7 +1290,8 @@ cc.TransitionZoomFlipY.create = function (t, scene, o) { cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipAngular# */{ /** - * @constuctor + * Constructor of TransitionZoomFlipAngular + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1352,11 +1370,15 @@ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ _color:null, /** - * Constructor + * Constructor of TransitionFade + * @function + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o */ ctor:function (t, scene, color) { cc.TransitionScene.prototype.ctor.call(this); - this._color = cc.color() + this._color = cc.color(); scene && this.initWithDuration(t, scene, color); }, @@ -1366,17 +1388,17 @@ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ onEnter:function () { cc.TransitionScene.prototype.onEnter.call(this); - var l = cc.LayerColor.create(this._color); + var l = new cc.LayerColor(this._color); this._inScene.visible = false; this.addChild(l, 2, cc.SCENE_FADE); var f = this.getChildByTag(cc.SCENE_FADE); - var a = cc.Sequence.create( - cc.FadeIn.create(this._duration / 2), - cc.CallFunc.create(this.hideOutShowIn, this), //CCCallFunc.actionWithTarget:self selector:@selector(hideOutShowIn)], - cc.FadeOut.create(this._duration / 2), - cc.CallFunc.create(this.finish, this) //:self selector:@selector(finish)], + var a = cc.sequence( + cc.fadeIn(this._duration / 2), + cc.callFunc(this.hideOutShowIn, this), + cc.fadeOut(this._duration / 2), + cc.callFunc(this.finish, this) ); f.runAction(a); }, @@ -1431,7 +1453,8 @@ cc.TransitionFade.create = function (t, scene, color) { */ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCrossFade# */{ /** - * @constructor + * Constructor of TransitionCrossFade + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1544,7 +1567,8 @@ cc.TransitionCrossFade.create = function (t, scene) { cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTurnOffTiles# */{ /** - * @constructor + * Constructor of TransitionCrossFade + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1602,7 +1626,8 @@ cc.TransitionTurnOffTiles.create = function (t, scene) { cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplitCols# */{ /** - * @constructor + * Constructor of TransitionSplitCols + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1664,7 +1689,8 @@ cc.TransitionSplitCols.create = function (t, scene) { cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionSplitRows# */{ /** - * @constructor + * Constructor of TransitionSplitRows + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1702,7 +1728,8 @@ cc.TransitionSplitRows.create = function (t, scene) { cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */{ /** - * @constructor + * Constructor of TransitionFadeTR + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1769,9 +1796,9 @@ cc.TransitionFadeTR.create = function (t, scene) { * @extends cc.TransitionFadeTR */ cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# */{ - /** - * @constructor + * Constructor of TransitionFadeBL + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1811,7 +1838,8 @@ cc.TransitionFadeBL.create = function (t, scene) { cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# */{ /** - * @constuctor + * Constructor of TransitionFadeUp + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1822,10 +1850,10 @@ cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# /** * @param {cc.Size} size - * @return {*} + * @return {cc.FadeOutUpTiles} */ actionWithSize:function (size) { - return cc.FadeOutUpTiles.create(this._duration, size); + return new cc.FadeOutUpTiles(this._duration, size); } }); @@ -1851,7 +1879,8 @@ cc.TransitionFadeUp.create = function (t, scene) { cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeDown# */{ /** - * @constuctor + * Constructor of TransitionFadeDown + * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 7e70e07ebf..3096aa2df3 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -230,6 +230,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ /** * transforms and draws itself, and visit its children and protected children. * @override + * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx context of renderer */ visit: null, From fb2f3a04062b69a6e1a1c6269b4ffa390ce19793 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 10:04:29 +0800 Subject: [PATCH 0500/1564] Doc #5829: Fix issues in AtlasNode inline docs --- cocos2d/actions/CCActionInterval.js | 2 +- cocos2d/core/base-nodes/CCAtlasNode.js | 103 ++++++++++++++++--------- 2 files changed, 66 insertions(+), 39 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 4eece9c3db..16cc1e1606 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -688,7 +688,7 @@ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ * Create a acton which repeat forever * @param {cc.FiniteTimeAction} action * @example - * var repeat = new cc.RepeatForever(cc.rotateBy(1.0, 360)); + * var repeat = cc.rotateBy(1.0, 360).repeatForever(); */ ctor:function (action) { cc.ActionInterval.prototype.ctor.call(this); diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 8137fbce74..10de3ca45b 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -24,21 +24,19 @@ THE SOFTWARE. ****************************************************************************/ -/**

    cc.AtlasNode is a subclass of cc.Node that implements the cc.RGBAProtocol and
    - * cc.TextureProtocol protocol

    +/** + *

    cc.AtlasNode is a subclass of cc.Node, it knows how to render a TextureAtlas object.

    * - *

    It knows how to render a TextureAtlas object.
    - * If you are going to render a TextureAtlas consider subclassing cc.AtlasNode (or a subclass of cc.AtlasNode)

    + *

    If you are going to render a TextureAtlas consider subclassing cc.AtlasNode (or a subclass of cc.AtlasNode)

    + * + *

    All features from cc.Node are valid

    * - *

    All features from cc.Node are valid, plus the following features:
    - * - opacity and RGB colors

    * @class * @extends cc.Node * * @property {cc.Texture2D} texture - Current used texture * @property {cc.TextureAtlas} textureAtlas - Texture atlas for cc.AtlasNode * @property {Number} quadsToDraw - Number of quads to draw - * */ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ textureAtlas: null, @@ -59,12 +57,14 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ _opacityModifyRGB: false, _blendFunc: null, - _ignoreContentScaleFactor: false, // This variable is only used for CCLabelAtlas FPS display. So plz don't modify its value. + // This variable is only used for CCLabelAtlas FPS display. So plz don't modify its value. + _ignoreContentScaleFactor: false, _className: "AtlasNode", /** * Creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render * Constructor of cc.AtlasNode + * @constructor * @param {String} tile * @param {Number} tileWidth * @param {Number} tileHeight @@ -81,14 +81,18 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender); }, - /** updates the Atlas (indexed vertex array). - * Shall be overridden in subclasses + /** + * Updates the Atlas (indexed vertex array). + * Empty implementation, shall be overridden in subclasses + * @function */ updateAtlasValues: function () { cc.log(cc._LogInfos.AtlasNode_updateAtlasValues); }, - /** cc.AtlasNode - RGBA protocol + /** + * Get color value of the atlas node + * @function * @return {cc.Color} */ getColor: function () { @@ -98,6 +102,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** + * Set whether color should be changed with the opacity value, + * if true, node color will change while opacity changes. + * @function * @param {Boolean} value */ setOpacityModifyRGB: function (value) { @@ -107,13 +114,17 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** + * Get whether color should be changed with the opacity value + * @function * @return {Boolean} */ isOpacityModifyRGB: function () { return this._opacityModifyRGB; }, - /** cc.AtlasNode - CocosNodeTexture protocol + /** + * Get node's blend function + * @function * @return {cc.BlendFunc} */ getBlendFunc: function () { @@ -121,7 +132,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** - * BlendFunc setter + * Set node's blend function + * This function accept either cc.BlendFunc object or source value and destination value + * @function * @param {Number | cc.BlendFunc} src * @param {Number} dst */ @@ -133,13 +146,17 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** - * @param {cc.TextureAtlas} value + * Set the atlas texture + * @function + * @param {cc.TextureAtlas} value The texture */ setTextureAtlas: function (value) { this.textureAtlas = value; }, /** + * Get the atlas texture + * @function * @return {cc.TextureAtlas} */ getTextureAtlas: function () { @@ -147,6 +164,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** + * Get the number of quads to be rendered + * @function * @return {Number} */ getQuadsToDraw: function () { @@ -154,6 +173,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** + * Set the number of quads to be rendered + * @function * @param {Number} quadsToDraw */ setQuadsToDraw: function (quadsToDraw) { @@ -166,11 +187,13 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ _uniformColor: null, _colorF32Array: null, - /** initializes an cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render - * @param {String} tile - * @param {Number} tileWidth - * @param {Number} tileHeight - * @param {Number} itemsToRender + /** + * Initializes an cc.AtlasNode object with an atlas texture file name, the width, the height of each tile and the quantity of tiles to render + * @function + * @param {String} tile The atlas texture file name + * @param {Number} tileWidth The width of each tile + * @param {Number} tileHeight The height of each tile + * @param {Number} itemsToRender The quantity of tiles to be rendered * @return {Boolean} */ initWithTileFile: function (tile, tileWidth, tileHeight, itemsToRender) { @@ -181,11 +204,12 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** - * initializes an CCAtlasNode with a texture the width and height of each item measured in points and the quantity of items to render - * @param {cc.Texture2D} texture - * @param {Number} tileWidth - * @param {Number} tileHeight - * @param {Number} itemsToRender + * Initializes an CCAtlasNode with an atlas texture, the width, the height of each tile and the quantity of tiles to render + * @function + * @param {cc.Texture2D} texture The atlas texture + * @param {Number} tileWidth The width of each tile + * @param {Number} tileHeight The height of each tile + * @param {Number} itemsToRender The quantity of tiles to be rendered * @return {Boolean} */ initWithTexture: null, @@ -237,11 +261,13 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ return true; }, - draw: null, - /** - * @param {WebGLRenderingContext} ctx renderContext + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function + * @function + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ + draw: null, + _drawForWebGL: function (ctx) { var context = ctx || cc._renderContext; cc.nodeDrawSetup(this); @@ -253,8 +279,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** + * Set node's color * @function - * @param {cc.Color} color3 + * @param {cc.Color} color Color object created with cc.color(r, g, b). */ setColor: null, @@ -311,8 +338,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** + * Set node's opacity * @function - * @param {Number} opacity + * @param {Number} opacity The opacity value */ setOpacity: function (opacity) { }, @@ -337,9 +365,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ } }, - // cc.Texture protocol /** - * returns the used texture + * Get the current texture * @function * @return {cc.Texture2D} */ @@ -354,9 +381,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, /** - * sets a new texture. it will be retained + * Replace the current texture with a new one * @function - * @param {cc.Texture2D} texture + * @param {cc.Texture2D} texture The new texture */ setTexture: null, @@ -462,16 +489,16 @@ _p.textureAtlas; _p.quadsToDraw; -/** creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render - * @deprecated +/** + * Creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render + * @deprecated since v3.0, please use new construction instead + * @function + * @static * @param {String} tile * @param {Number} tileWidth * @param {Number} tileHeight * @param {Number} itemsToRender * @return {cc.AtlasNode} - * @example - * // example - * var node = cc.AtlasNode.create("pathOfTile", 16, 16, 1); */ cc.AtlasNode.create = function (tile, tileWidth, tileHeight, itemsToRender) { return new cc.AtlasNode(tile, tileWidth, tileHeight, itemsToRender); From 395a41d57158a458d74a398256e82706d1720f72 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 10:05:01 +0800 Subject: [PATCH 0501/1564] Doc #5829: Fix issues in Node inline docs(half done) --- .../base-nodes/BaseNodesPropertyDefine.js | 2 +- cocos2d/core/base-nodes/CCNode.js | 598 ++++++++++-------- 2 files changed, 338 insertions(+), 262 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js index ba1e23502e..0cd74ade60 100644 --- a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +++ b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js @@ -126,7 +126,7 @@ cc._tmp.PrototypeCCNode = function () { cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); /** @expose */ _p.opacityModifyRGB; - cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB); + cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB); /** @expose */ _p.cascadeOpacity; cc.defineGetterSetter(_p, "cascadeOpacity", _p.isCascadeOpacityEnabled, _p.setCascadeOpacityEnabled); diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b1170294e0..3dd5696753 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -32,92 +32,100 @@ cc.NODE_TAG_INVALID = -1; /** - * 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. - * @type Number + * 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. */ cc.s_globalOrderOfArrival = 1; -/**

    cc.Node is the main element. Anything thats gets drawn or contains things that get drawn is a cc.Node.
    - The most popular cc.Nodes are: cc.Scene, cc.Layer, cc.Sprite, cc.Menu.

    - -

    The main features of a cc.Node are:
    - - They can contain other cc.Node nodes (addChild, getChildByTag, removeChild, etc)
    - - They can schedule periodic callback (schedule, unschedule, etc)
    - - They can execute actions (runAction, stopAction, etc)

    - -

    Some cc.Node nodes provide extra functionality for them or their children.

    - -

    Subclassing a cc.Node usually means (one/all) of:
    - - overriding init to initialize resources and schedule callbacks
    - - create callbacks to handle the advancement of time
    - - overriding draw to render the node

    - -

    Features of cc.Node:
    - - position
    - - scale (x, y)
    - - rotation (in degrees, clockwise)
    - - anchor point
    - - size
    - - visible
    - - z-order
    - - openGL z position

    - -

    Default values:
    - - rotation: 0
    - - position: (x=0,y=0)
    - - scale: (x=1,y=1)
    - - contentSize: (x=0,y=0)
    - - anchorPoint: (x=0,y=0)

    - -

    Limitations:
    - - A cc.Node is a "void" object. It doesn't have a texture

    - -

    Order in transformations with grid disabled
    - -# The node will be translated (position)
    - -# The node will be rotated (rotation)
    - -# The node will be scaled (scale)
    - -

    Order in transformations with grid enabled
    - -# The node will be translated (position)
    - -# The node will be rotated (rotation)
    - -# The node will be scaled (scale)
    - -# The grid will capture the screen
    - -# The node will be moved according to the camera values (camera)
    - -# The grid will render the captured screen

    +/** + *

    cc.Node is the root class of all node. Anything that gets drawn or contains things that get drawn is a cc.Node.
    + * The most popular cc.Nodes are: cc.Scene, cc.Layer, cc.Sprite, cc.Menu.

    + * + *

    The main features of a cc.Node are:
    + * - They can contain other cc.Node nodes (addChild, getChildByTag, removeChild, etc)
    + * - They can schedule periodic callback (schedule, unschedule, etc)
    + * - They can execute actions (runAction, stopAction, etc)

    + * + *

    Some cc.Node nodes provide extra functionality for them or their children.

    + * + *

    Subclassing a cc.Node usually means (one/all) of:
    + * - overriding constructor function "ctor" to initialize resources and schedule callbacks
    + * - create callbacks to handle the advancement of time

    + * + *

    Features of cc.Node:
    + * - position
    + * - scale (x, y)
    + * - rotation (in degrees, clockwise)
    + * - anchor point
    + * - size
    + * - color
    + * - opacity
    + * - visible
    + * - z-order
    + * - WebGL z position

    + * + *

    Default values:
    + * - rotation: 0
    + * - position: (x=0,y=0)
    + * - scale: (x=1,y=1)
    + * - contentSize: (x=0,y=0)
    + * - anchorPoint: (x=0,y=0)
    + * - color: (r=255,g=255,b=255)
    + * - opacity: 255

    + * + *

    Limitations:
    + * - A cc.Node is a "void" object. It doesn't have a texture

    + * + *

    Order in transformations with grid disabled
    + * -# The node will be translated (position)
    + * -# The node will be rotated (rotation)
    + * -# The node will be scaled (scale)
    + * + *

    Order in transformations with grid enabled
    + * -# The node will be translated (position)
    + * -# The node will be rotated (rotation)
    + * -# The node will be scaled (scale)
    + * -# The grid will capture the screen
    + * -# The node will be moved according to the camera values (camera)
    + * -# The grid will render the captured screen

    * @class * @extends cc.Class * - * @property {Number} x - x axis position of node - * @property {Number} y - y axis position of node - * @property {Number} width - Width of node - * @property {Number} height - Height of node - * @property {Number} anchorX - Anchor point's position on x axis - * @property {Number} anchorY - Anchor point's position on y axis - * @property {Number} skewX - Skew x - * @property {Number} skewY - Skew y - * @property {Number} zIndex - Z order in depth which stands for the drawing order - * @property {Number} vertexZ - WebGL Z vertex of this node, z order works OK if all the nodes uses the same openGL Z vertex - * @property {Number} rotation - Rotation of node - * @property {Number} rotationX - Rotation on x axis - * @property {Number} rotationY - Rotation on y axis - * @property {Number} scale - Scale of node - * @property {Number} scaleX - Scale on x axis - * @property {Number} scaleY - Scale on y axis - * @property {Array} children - <@readonly> All children nodes - * @property {Number} childrenCount - <@readonly> Number of children - * @property {cc.Node} parent - Parent node - * @property {Boolean} visible - Indicate whether node is visible or not - * @property {Boolean} running - <@readonly> Indicate whether node is running or not - * @property {Boolean} ignoreAnchor - Indicate whether ignore the anchor point property for positionning - * @property {Number} tag - Tag of node - * @property {Object} userData - Custom user data - * @property {Object} userObject - User assigned CCObject, similar to userData, but instead of holding a void* it holds an id - * @property {Number} arrivalOrder - The arrival order, indicates which children is added previously - * @property {cc.ActionManager} actionManager - The CCActionManager object that is used by all actions. - * @property {cc.Scheduler} scheduler - cc.Scheduler used to schedule all "updates" and timers. - * @property {cc.GridBase} grid - grid object that is used when applying effects - * @property {cc.GLProgram} shaderProgram - The shader program currently used for this node - * @property {Number} glServerState - The state of OpenGL server side + * @property {Number} x - x axis position of node + * @property {Number} y - y axis position of node + * @property {Number} width - Width of node + * @property {Number} height - Height of node + * @property {Number} anchorX - Anchor point's position on x axis + * @property {Number} anchorY - Anchor point's position on y axis + * @property {Boolean} ignoreAnchor - Indicate whether ignore the anchor point property for positioning + * @property {Number} skewX - Skew x + * @property {Number} skewY - Skew y + * @property {Number} zIndex - Z order in depth which stands for the drawing order + * @property {Number} vertexZ - WebGL Z vertex of this node, z order works OK if all the nodes uses the same openGL Z vertex + * @property {Number} rotation - Rotation of node + * @property {Number} rotationX - Rotation on x axis + * @property {Number} rotationY - Rotation on y axis + * @property {Number} scale - Scale of node + * @property {Number} scaleX - Scale on x axis + * @property {Number} scaleY - Scale on y axis + * @property {Boolean} visible - Indicate whether node is visible or not + * @property {cc.Color} color - Color of node, default value is white: (255, 255, 255) + * @property {Boolean} cascadeColor - Indicate whether node's color value affect its child nodes, default value is false + * @property {Number} opacity - Opacity of node, default value is 255 + * @property {Boolean} opacityModifyRGB - <@readonly>Indicate whether opacity affect the color value, default value is false + * @property {Boolean} cascadeOpacity - Indicate whether node's opacity value affect its child nodes, default value is false + * @property {Array} children - <@readonly> All children nodes + * @property {Number} childrenCount - <@readonly> Number of children + * @property {cc.Node} parent - Parent node + * @property {Boolean} running - <@readonly> Indicate whether node is running or not + * @property {Number} tag - Tag of node + * @property {Object} userData - Custom user data + * @property {Object} userObject - User assigned CCObject, similar to userData, but instead of holding a void* it holds an id + * @property {Number} arrivalOrder - The arrival order, indicates which children is added previously + * @property {cc.ActionManager} actionManager - The CCActionManager object that is used by all actions. + * @property {cc.Scheduler} scheduler - cc.Scheduler used to schedule all "updates" and timers. + * @property {cc.GridBase} grid - grid object that is used when applying effects + * @property {cc.GLProgram} shaderProgram - The shader program currently used for this node + * @property {Number} glServerState - The state of OpenGL server side */ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _localZOrder: 0, ///< Local order (relative to its siblings) used to sort the node @@ -213,6 +221,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Initializes the instance of cc.Node + * @function * @returns {boolean} Whether the initialization was successful. */ init: function () { @@ -221,11 +230,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return true; }, - /** - * @param {Array} array - * @param {cc.Node.StateCallbackType} callbackType - * @private - */ _arrayMakeObjectsPerformSelector: function (array, callbackType) { if (!array || array.length === 0) return; @@ -289,16 +293,18 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * set the dirty node + * Sets node's dirty flag to true so that it can be updated in visit function of the next frame + * @function */ setNodeDirty: null, /** - *

    Properties configuration function
    - * All properties in attrs will be set to the node,
    - * when the setter of the node is available,
    - * the property will be set via setter function.
    - *

    + *

    Properties configuration function
    + * All properties in attrs will be set to the node,
    + * when the setter of the node is available,
    + * the property will be set via setter function.
    + *

    + * @function * @param {Object} attrs Properties to be set to node */ attr: function (attrs) { @@ -308,12 +314,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - *

    get the skew degrees in X
    - * The X skew angle of the node in degrees.
    - * This angle describes the shear distortion in the X direction.
    - * Thus, it is the angle between the Y axis and the left edge of the shape
    - * The default skewX angle is 0. Positive values distort the node in a CW direction.
    - *

    + *

    Returns the skew degrees in X
    + * The X skew angle of the node in degrees.
    + * This angle describes the shear distortion in the X direction.
    + * Thus, it is the angle between the Y axis and the left edge of the shape
    + * The default skewX angle is 0. Positive values distort the node in a CW direction.
    + *

    + * @function * @return {Number} The X skew angle of the node in degrees. */ getSkewX: function () { @@ -322,12 +329,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    - * Changes the X skew angle of the node in degrees.
    - *
    - * This angle describes the shear distortion in the X direction.
    - * Thus, it is the angle between the Y axis and the left edge of the shape
    - * The default skewX angle is 0. Positive values distort the node in a CW direction. + * Changes the X skew angle of the node in degrees.
    + *
    + * This angle describes the shear distortion in the X direction.
    + * Thus, it is the angle between the Y axis and the left edge of the shape
    + * The default skewX angle is 0. Positive values distort the node in a CW direction. *

    + * @function * @param {Number} newSkewX The X skew angle of the node in degrees. */ setSkewX: function (newSkewX) { @@ -336,12 +344,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - *

    get the skew degrees in Y
    + *

    Returns the skew degrees in Y
    * The Y skew angle of the node in degrees.
    * This angle describes the shear distortion in the Y direction.
    * Thus, it is the angle between the X axis and the bottom edge of the shape
    * The default skewY angle is 0. Positive values distort the node in a CCW direction.
    *

    + * @function * @return {Number} The Y skew angle of the node in degrees. */ getSkewY: function () { @@ -356,6 +365,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Thus, it is the angle between the X axis and the bottom edge of the shape
    * The default skewY angle is 0. Positive values distort the node in a CCW direction.
    *

    + * @function * @param {Number} newSkewY The Y skew angle of the node in degrees. */ setSkewY: function (newSkewY) { @@ -369,10 +379,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * The Node's parent will sort all its children based ont the LocalZOrder value.
    * If two nodes have the same LocalZOrder, then the node that was added first to the children's array
    * will be in front of the other node in the array.
    - *
    - * Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order )
    + *
    + * Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) + *
    * And Nodes that have LocalZOder values < 0 are the "left" subtree
    * While Nodes with LocalZOder >=0 are the "right" subtree.

    + * @function * @param {Number} localZOrder */ setLocalZOrder: function (localZOrder) { @@ -382,17 +394,14 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ cc.eventManager._setDirtyForNode(this); }, - /** - * Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing. - * @param {Number} localZOrder - * @private - */ + //Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing. _setLocalZOrder: function (localZOrder) { this._localZOrder = localZOrder; }, /** - * Gets the local Z order of this node. + * Returns the local Z order of this node. + * @function * @returns {Number} The local (relative to its siblings) Z order. */ getLocalZOrder: function () { @@ -400,9 +409,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * zOrder getter + * Returns z order of this node + * @function * @return {Number} - * @deprecated + * @deprecated since 3.0, please use getLocalZOrder instead */ getZOrder: function () { cc.log(cc._LogInfos.Node_getZOrder); @@ -418,8 +428,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * The larger number it is, the later this node will be drawn in each message loop.
    * Please refer to setVertexZ(float) for the difference. *

    + * @function * @param {Number} z Z order of this node. - * @deprecated + * @deprecated since 3.0, please use setLocalZOrder instead */ setZOrder: function (z) { cc.log(cc._LogInfos.Node_setZOrder); @@ -439,6 +450,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ *
    * Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their ancestors.
    * And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode.

    + * @function * @param {Number} globalZOrder */ setGlobalZOrder: function (globalZOrder) { @@ -449,7 +461,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Returns the Node's Global Z Order. + * Return the Node's Global Z Order. + * @function * @returns {number} The node's global Z order */ getGlobalZOrder: function () { @@ -457,7 +470,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Gets WebGL Z vertex of this node. + * Returns WebGL Z vertex of this node. + * @function * @return {Number} WebGL Z vertex of this node */ getVertexZ: function () { @@ -469,12 +483,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Sets the real WebGL Z vertex.
    *
    * Differences between openGL Z vertex and cocos2d Z order:
    - * - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children
    - * - OpenGL Z might require to set 2D projection
    - * - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0
    + * - WebGL Z modifies the Z vertex, and not the Z order in the relation between parent-children
    + * - WebGL Z might require to set 2D projection
    + * - cocos2d Z order works OK if all the nodes uses the same WebGL Z vertex. eg: vertexZ = 0
    *
    * @warning Use it at your own risk since it might break the cocos2d parent-children z order *

    + * @function * @param {Number} Var */ setVertexZ: function (Var) { @@ -482,7 +497,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. + * Returns the rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node clockwise. + * @function * @return {Number} The rotation of the node in degrees. */ getRotation: function () { @@ -498,6 +514,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * 0 is the default rotation angle.
    * Positive values rotate node clockwise, and negative values for anti-clockwise. *

    + * @function * @param {Number} newRotation The rotation of the node in degrees. */ setRotation: function (newRotation) { @@ -508,9 +525,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * The rotation (angle) of the node in degrees. 0 is the default rotation angle.
    - * Positive values rotate node CW. It only modifies the X rotation performing a horizontal rotational skew . - * (support only in WebGl rendering mode) + * Returns the X axis rotation (angle) which represent a horizontal rotational skew of the node in degrees.
    + * 0 is the default rotation angle. Positive values rotate node clockwise
    + * (support only in WebGL rendering mode) + * @function * @return {Number} The X rotation in degrees. */ getRotationX: function () { @@ -520,7 +538,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    * Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew.
    - *
    + * (support only in WebGL rendering mode)
    * 0 is the default rotation angle.
    * Positive values rotate node clockwise, and negative values for anti-clockwise. *

    @@ -533,8 +551,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * The rotation (angle) of the node in degrees. 0 is the default rotation angle.
    - * Positive values rotate node CW. It only modifies the Y rotation performing a vertical rotational skew . + * Returns the Y axis rotation (angle) which represent a vertical rotational skew of the node in degrees.
    + * 0 is the default rotation angle. Positive values rotate node clockwise
    + * (support only in WebGL rendering mode) + * @function * @return {Number} The Y rotation in degrees. */ getRotationY: function () { @@ -544,9 +564,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    * Sets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew.
    - *
    - * 0 is the default rotation angle.
    - * Positive values rotate node clockwise, and negative values for anti-clockwise. + * (support only in WebGL rendering mode)
    + * 0 is the default rotation angle.
    + * Positive values rotate node clockwise, and negative values for anti-clockwise. *

    * @param rotationY The Y rotation in degrees. */ @@ -556,9 +576,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ this.setNodeDirty(); }, - /** Get the scale factor of the node. - * @warning: Assert when _scaleX != _scaleY. - * @return {Number} + /** + * Returns the scale factor of the node. + * @warning: Assertion will fail when _scaleX != _scaleY. + * @function + * @return {Number} The scale factor */ getScale: function () { if (this._scaleX !== this._scaleY) @@ -567,7 +589,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time. + * Sets the scale factor of the node. 1.0 is the default scale factor. This function can modify the X and Y scale at the same time. + * @function * @param {Number} scale or scaleX value * @param {Number} [scaleY=] */ @@ -579,6 +602,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns the scale factor on X axis of this node + * @function * @return {Number} The scale factor on X axis. */ getScaleX: function () { @@ -590,6 +614,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Changes the scale factor on X axis of this node
    * The deafult value is 1.0 if you haven't changed it before *

    + * @function * @param {Number} newScaleX The scale factor on X axis. */ setScaleX: function (newScaleX) { @@ -599,6 +624,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns the scale factor on Y axis of this node + * @function * @return {Number} The scale factor on Y axis. */ getScaleY: function () { @@ -610,6 +636,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Changes the scale factor on Y axis of this node
    * The Default value is 1.0 if you haven't changed it before. *

    + * @function * @param {Number} newScaleY The scale factor on Y axis. */ setScaleY: function (newScaleY) { @@ -619,15 +646,16 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    - * Changes the position (x,y) of the node in OpenGL coordinates - * Usually we use ccp(x,y) to compose CCPoint object. - * The original point (0,0) is at the left-bottom corner of screen. - * and Passing two numbers (x,y) is much efficient than passing CCPoint object. + * Changes the position (x,y) of the node in cocos2d coordinates.
    + * The original point (0,0) is at the left-bottom corner of screen.
    + * Usually we use cc.p(x,y) to compose CCPoint object.
    + * and Passing two numbers (x,y) is more efficient than passing CCPoint object. *

    - * @param {cc.Point|Number} newPosOrxValue The position (x,y) of the node in coordinates or X coordinate for position + * @function + * @param {cc.Point|Number} newPosOrxValue The position (x,y) of the node in coordinates or the X coordinate for position * @param {Number} [yValue] Y coordinate for position * @example - * var size = cc.director.getWinSize(); + * var size = cc.winSize; * node.setPosition(size.width/2, size.height/2); */ setPosition: function (newPosOrxValue, yValue) { @@ -643,8 +671,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - *

    Position (x,y) of the node in OpenGL coordinates. (0,0) is the left-bottom corner.

    - * @const + *

    Returns a copy of the position (x,y) of the node in cocos2d coordinates. (0,0) is the left-bottom corner.

    + * @function * @return {cc.Point} The position (x,y) of the node in OpenGL coordinates */ getPosition: function () { @@ -652,6 +680,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** + *

    Returns the x axis position of the node in cocos2d coordinates.

    + * @function * @return {Number} */ getPositionX: function () { @@ -659,7 +689,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * @param {Number} x + *

    Sets the x axis position of the node in cocos2d coordinates.

    + * @function + * @param {Number} x The new position in x axis */ setPositionX: function (x) { this._position.x = x; @@ -667,6 +699,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** + *

    Returns the y axis position of the node in cocos2d coordinates.

    + * @function * @return {Number} */ getPositionY: function () { @@ -674,7 +708,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * @param {Number} y + *

    Sets the y axis position of the node in cocos2d coordinates.

    + * @function + * @param {Number} y The new position in y axis */ setPositionY: function (y) { this._position.y = y; @@ -682,7 +718,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Get the amount of children. + * Returns the amount of children. + * @function * @return {Number} The amount of children. */ getChildrenCount: function () { @@ -690,22 +727,24 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Return an array of children
    + * Returns an array of all children
    * Composing a "tree" structure is a very important feature of CCNode + * @function * @return {Array} An array of children * @example * //This sample code traverses all children nodes, and set their position to (0,0) * var allChildren = parent.getChildren(); - * for(var i = 0; i< allChildren.length; i++) { - * allChildren[i].setPosition(0,0); - * } + * for(var i = 0; i< allChildren.length; i++) { + * allChildren[i].setPosition(0,0); + * } */ getChildren: function () { return this._children; }, /** - * Determines if the node is visible + * Returns if the node is visible + * @function * @see setVisible(bool) * @return {Boolean} true if the node is visible, false if the node is hidden. */ @@ -715,23 +754,25 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Sets whether the node is visible
    - * The default value is true, a node is default to visible - * @param {Boolean} Var true if the node is visible, false if the node is hidden. + * The default value is true + * @function + * @param {Boolean} visible Pass true to make the node visible, false to hide the node. */ - setVisible: function (Var) { - if(this._visible != Var){ - this._visible = Var; - if(Var)this.setNodeDirty(); + setVisible: function (visible) { + if(this._visible != visible){ + this._visible = visible; + if(visible) this.setNodeDirty(); } }, /** - *

    anchorPoint is the point around which all transformations and positioning manipulations take place.
    + *

    Returns a copy of the anchor point.
    + * Anchor point is the point around which all transformations and positioning manipulations take place.
    * It's like a pin in the node where it is "attached" to its parent.
    * The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
    * But you can use values higher than (1,1) and lower than (0,0) too.
    - * The default anchorPoint is (0.5,0.5), so it starts in the center of the node.

    - * @const + * The default anchor point is (0.5,0.5), so it starts at the center of the node.

    + * @function * @return {cc.Point} The anchor point of node. */ getAnchorPoint: function () { @@ -742,14 +783,15 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ *

    * Sets the anchor point in percent.
    *
    - * anchorPoint is the point around which all transformations and positioning manipulations take place.
    + * anchor point is the point around which all transformations and positioning manipulations take place.
    * It's like a pin in the node where it is "attached" to its parent.
    * The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
    * But you can use values higher than (1,1) and lower than (0,0) too.
    - * The default anchorPoint is (0.5,0.5), so it starts in the center of the node. + * The default anchor point is (0.5,0.5), so it starts at the center of the node. *

    - * @param {cc.Point|Number} point The anchor point of node or The anchor point.x of node. - * @param {Number} [y] The anchor point.y of node. + * @function + * @param {cc.Point|Number} point The anchor point of node or The x axis anchor of node. + * @param {Number} [y] The y axis anchor of node. */ setAnchorPoint: function (point, y) { var locAnchorPoint = this._anchorPoint; @@ -805,10 +847,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * The anchorPoint in absolute pixels.
    - * you can only read it. If you wish to modify it, use anchorPoint instead - * @see getAnchorPoint() - * @const + * Returns a copy of the anchor point in absolute pixels.
    + * you can only read it. If you wish to modify it, use setAnchorPoint + * @see getAnchorPoint() + * @function * @return {cc.Point} The anchor point in absolute pixels. */ getAnchorPointInPoints: function () { @@ -833,10 +875,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - *

    The untransformed size of the node.
    + *

    Returns a copy the untransformed size of the node.
    * The contentSize remains the same no matter the node is scaled or rotated.
    - * All nodes has a size. Layer and Scene has the same size of the screen.

    - * @const + * All nodes has a size. Layer and Scene has the same size of the screen by default.

    + * @function * @return {cc.Size} The untransformed size of the node. */ getContentSize: function () { @@ -850,6 +892,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * The contentSize remains the same no matter the node is scaled or rotated.
    * All nodes has a size. Layer and Scene has the same size of the screen. *

    + * @function * @param {cc.Size|Number} size The untransformed size of the node or The untransformed size's width of the node. * @param {Number} [height] The untransformed size's height of the node. */ @@ -877,6 +920,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Returns whether or not the node accepts event callbacks.
    * Running means the node accept event callbacks like onEnter(), onExit(), update() *

    + * @function * @return {Boolean} Whether or not the node is running. */ isRunning: function () { @@ -884,8 +928,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Returns a pointer to the parent node - * @return {cc.Node} A pointer to the parent node + * Returns a reference to the parent node + * @function + * @return {cc.Node} A reference to the parent node */ getParent: function () { return this._parent; @@ -893,16 +938,18 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Sets the parent node - * @param {cc.Node} Var A pointer to the parent node + * @param {cc.Node} parent A reference to the parent node */ - setParent: function (Var) { - this._parent = Var; + setParent: function (parent) { + this._parent = parent; }, /** - * Gets whether the anchor point will be (0,0) when you position this node. + * Returns whether the anchor point will be ignored when you position this node.
    + * When anchor point ignored, position will be calculated based on the origin point (0, 0) in parent's coordinates. + * @function * @see ignoreAnchorPointForPosition(bool) - * @return {Boolean} true if the anchor point will be (0,0) when you position this node. + * @return {Boolean} true if the anchor point will be ignored when you position this node. */ isIgnoreAnchorPointForPosition: function () { return this._ignoreAnchorPointForPosition; @@ -910,12 +957,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    - * Sets whether the anchor point will be (0,0) when you position this node.
    - *
    + * Sets whether the anchor point will be ignored when you position this node.
    + * When anchor point ignored, position will be calculated based on the origin point (0, 0) in parent's coordinates.
    * This is an internal method, only used by CCLayer and CCScene. Don't call it outside framework.
    * The default value is false, while in CCLayer and CCScene are true *

    - * @param {Boolean} newValue true if anchor point will be (0,0) when you position this node + * @function + * @param {Boolean} newValue true if anchor point will be ignored when you position this node */ ignoreAnchorPointForPosition: function (newValue) { if (newValue != this._ignoreAnchorPointForPosition) { @@ -926,7 +974,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns a tag that is used to identify the node easily. - * + * @function * @return {Number} An integer that identifies the node. * @example * //You can set tags to node then identify them easily. @@ -957,14 +1005,17 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Changes the tag that is used to identify the node easily.
    * Please refer to getTag for the sample code. - * @param {Number} Var A integer that identifies the node. + * @function + * @see getTag() + * @param {Number} tag A integer that identifies the node. */ - setTag: function (Var) { - this.tag = Var; + setTag: function (tag) { + this.tag = tag; }, /** * Changes the name that is used to identify the node easily. + * @function * @param {String} name */ setName: function(name){ @@ -973,6 +1024,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns a string that is used to identify the node. + * @function * @returns {string} A string that identifies the node. */ getName: function(){ @@ -984,6 +1036,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Returns a custom user data pointer
    * You can set everything in UserData pointer, a data block, a structure or an object. *

    + * @function * @return {object} A custom user data pointer */ getUserData: function () { @@ -992,10 +1045,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    - * Sets a custom user data pointer
    - * You can set everything in UserData pointer, a data block, a structure or an object, etc. + * Sets a custom user data reference
    + * You can set everything in UserData reference, a data block, a structure or an object, etc. *

    - * @warning Don't forget to release the memory manually,especially before you change this data pointer, and before this node is autoreleased. + * @function + * @warning Don't forget to release the memory manually in JSB, especially before you change this data pointer, and before this node is autoreleased. * @param {object} Var A custom user data */ setUserData: function (Var) { @@ -1003,8 +1057,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Returns a user assigned CCObject.
    - * Similar to userData, but instead of holding a void* it holds an id + * Returns a user assigned cocos2d object.
    + * Similar to userData, but instead of holding all kinds of data it can only hold a cocos2d object + * @function * @return {object} A user assigned CCObject */ getUserObject: function () { @@ -1013,12 +1068,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    - * Returns a user assigned CCObject
    - * Similar to UserData, but instead of holding a void* it holds an object.
    - * The UserObject will be retained once in this method, and the previous UserObject (if existed) will be release.
    + * Sets a user assigned cocos2d object
    + * Similar to UserData, but instead of holding all kinds of data it can only hold a cocos2d object
    + * In JSB, the UserObject will be retained once in this method, and the previous UserObject (if existed) will be release.
    * The UserObject will be released in CCNode's destruction. *

    - * @param {object} newValue A user assigned CCObject + * @param {object} newValue A user cocos2d object */ setUserObject: function (newValue) { if (this.userObject != newValue) { @@ -1028,7 +1083,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** - * Returns the arrival order, indicates which children is added previously. + * Returns the arrival order, indicates which children should be added previously. + * @function * @return {Number} The arrival order. */ getOrderOfArrival: function () { @@ -1042,6 +1098,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * A node which called addChild subsequently will take a larger arrival order,
    * If two children have the same Z order, the child with larger arrival order will be drawn later. *

    + * @function * @warning This method is used internally for zOrder sorting, don't change this manually * @param {Number} Var The arrival order. */ @@ -1052,8 +1109,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - *

    Gets the CCActionManager object that is used by all actions.
    + *

    Returns the CCActionManager object that is used by all actions.
    * (IMPORTANT: If you set a new cc.ActionManager, then previously created actions are going to be removed.)

    + * @function * @see setActionManager() * @return {cc.ActionManager} A CCActionManager object. */ @@ -1066,6 +1124,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    Sets the cc.ActionManager object that is used by all actions.

    + * @function * @warning If you set a new CCActionManager, then previously created actions will be removed. * @param {cc.ActionManager} actionManager A CCActionManager object that is used by all actions. */ @@ -1078,9 +1137,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    - * cc.Scheduler used to schedule all "updates" and timers.
    - * IMPORTANT: If you set a new cc.Scheduler, then previously created timers/update are going to be removed. + * Returns the cc.Scheduler object used to schedule all "updates" and timers. *

    + * @function * @return {cc.Scheduler} A CCScheduler object. */ getScheduler: function () { @@ -1093,7 +1152,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    * Sets a CCScheduler object that is used to schedule all "updates" and timers.
    + * IMPORTANT: If you set a new cc.Scheduler, then previously created timers/update are going to be removed. *

    + * @function * @warning If you set a new CCScheduler, then previously created timers/update are going to be removed. * @param scheduler A cc.Scheduler object that is used to schedule all "update" and timers. */ @@ -1106,7 +1167,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns a "local" axis aligned bounding box of the node.
    - * @deprecated + * @deprecated since v3.0, please use getBoundingBox instead * @return {cc.Rect} */ boundingBox: function(){ @@ -1117,9 +1178,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns a "local" axis aligned bounding box of the node.
    * The returned box is relative only to its parent. - * @note This method returns a temporary variable, so it can't returns const CCRect& - * @const - * @return {cc.Rect} + * @function + * @return {cc.Rect} The calculated bounding box of the node */ getBoundingBox: function () { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); @@ -1128,6 +1188,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Stops all running actions and schedulers + * @function */ cleanup: function () { // actions @@ -1143,7 +1204,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // composition: GET /** - * Gets a child from the container given its tag + * Returns a child from the container given its tag + * @function * @param {Number} aTag An identifier to find the child node. * @return {cc.Node} a CCNode object whose tag equals to the input parameter */ @@ -1159,6 +1221,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return null; }, + /** + * Returns a child from the container given its name + * @function + * @param {Number} name An identifier to find the child node. + * @return {cc.Node} a CCNode object whose name equals to the input parameter + */ getChildByName: function(name){ if(!name){ cc.log("Invalid name"); @@ -1172,12 +1240,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } return null; }, + // composition: ADD - /**

    "add" logic MUST only be on this method

    + /**

    "add" logic MUST only be in this method

    * *

    If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.

    - * + * @function * @param {cc.Node} child A child node * @param {Number} [localZOrder=] Z order for drawing priority. Please refer to setZOrder(int) * @param {Number} [tag=] A integer to identify the node easily. Please refer to setTag(int) @@ -1239,6 +1308,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Remove itself from its parent node. If cleanup is true, then also remove all actions and callbacks.
    * If the cleanup parameter is not passed, it will force a cleanup.
    * If the node orphan, then nothing happens. + * @function * @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise. * @see removeFromParentAndCleanup(bool) */ @@ -1253,7 +1323,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Removes this node itself from its parent node.
    * If the node orphan, then nothing happens. - * @deprecated + * @deprecated since v3.0, please use removeFromParent() instead * @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise. */ removeFromParentAndCleanup: function (cleanup) { @@ -1263,10 +1333,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /**

    Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

    * If the cleanup parameter is not passed, it will force a cleanup.
    - *

    "remove" logic MUST only be on this method
    + *

    "remove" logic MUST only be on this method
    * If a class wants to extend the 'removeChild' behavior it only needs
    * to override this method

    - * + * @function * @param {cc.Node} child The child node which will be removed. * @param {Boolean|null} [cleanup=null] true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ @@ -1286,6 +1356,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter. * If the cleanup parameter is not passed, it will force a cleanup.
    + * @function * @param {Number} tag An integer number that identifies a child node * @param {Boolean} cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. * @see removeChildByTag(int, bool) @@ -1303,7 +1374,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. - * @deprecated + * @deprecated since v3.0, please use removeAllChildren() instead * @param {Boolean | null } cleanup */ removeAllChildrenWithCleanup: function (cleanup) { @@ -1314,6 +1385,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
    * If the cleanup parameter is not passed, it will force a cleanup.
    + * @function * @param {Boolean | null } cleanup true if all running actions on all children nodes should be cleanup, false otherwise. */ removeAllChildren: function (cleanup) { @@ -1342,11 +1414,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } }, - /** - * @param {cc.Node} child - * @param {Boolean} doCleanup - * @private - */ _detachChild: function (child, doCleanup) { // IMPORTANT: // -1st do onExit @@ -1367,11 +1434,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ cc.arrayRemoveObject(this._children, child); }, - /** helper used by reorderChild & add - * @param {cc.Node} child - * @param {Number} z - * @private - */ _insertChild: function (child, z) { this._reorderChildDirty = true; this._children.push(child); @@ -1380,6 +1442,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** Reorders a child according to a new z value.
    * The child MUST be already added. + * @function * @param {cc.Node} child An already added child node. It MUST be already added. * @param {Number} zOrder Z order for drawing priority. Please refer to setZOrder(int) */ @@ -1397,6 +1460,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Sorts the children array once before drawing, instead of every time when a child is added or reordered.
    * This approach can improves the performance massively. *

    + * @function * @note Don't call this manually unless a child added needs to be removed in the same frame */ sortAllChildren: function () { @@ -1428,18 +1492,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } }, - // draw - /**

    Override this method to draw your own node.
    - * The following GL states will be enabled by default:
    - - glEnableClientState(GL_VERTEX_ARRAY);
    - - glEnableClientState(GL_COLOR_ARRAY);
    - - glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    - - glEnable(GL_TEXTURE_2D);

    - -

    AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE

    - -

    But if you enable any other GL state, you should disable it after drawing your node.

    - * @param {CanvasContext} ctx + /** + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function + * @function + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ draw: function (ctx) { // override me @@ -1464,8 +1520,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Event callback that is invoked every time when CCNode enters the 'stage'.
    * If the CCNode enters the 'stage' with a transition, this event is called when the transition starts.
    * During onEnter you can't access a "sister/brother" node.
    - * If you override onEnter, you shall call its parent's one, e.g., CCNode::onEnter(). + * If you override onEnter, you must call its parent's onEnter function with this._super(). *

    + * @function */ onEnter: function () { this._isTransitionFinished = false; @@ -1478,8 +1535,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ *

    * Event callback that is invoked when the CCNode enters in the 'stage'.
    * If the CCNode enters the 'stage' with a transition, this event is called when the transition finishes.
    - * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. CCNode::onEnterTransitionDidFinish() + * If you override onEnterTransitionDidFinish, you shall call its parent's onEnterTransitionDidFinish with this._super() *

    + * @function */ onEnterTransitionDidFinish: function () { this._isTransitionFinished = true; @@ -1488,7 +1546,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    callback that is called every time the cc.Node leaves the 'stage'.
    - * If the cc.Node leaves the 'stage' with a transition, this callback is called when the transition starts.

    + * If the cc.Node leaves the 'stage' with a transition, this callback is called when the transition starts.
    + * If you override onExitTransitionDidStart, you shall call its parent's onExitTransitionDidStart with this._super()

    + * @function */ onExitTransitionDidStart: function () { this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExitTransitionDidStart); @@ -1499,8 +1559,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * callback that is called every time the cc.Node leaves the 'stage'.
    * If the cc.Node leaves the 'stage' with a transition, this callback is called when the transition finishes.
    * During onExit you can't access a sibling node.
    - * If you override onExit, you shall call its parent's one, e.g., CCNode::onExit(). + * If you override onExit, you shall call its parent's onExit with this._super(). *

    + * @function */ onExit: function () { this._running = false; @@ -1511,7 +1572,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // actions /** * Executes an action, and returns the action that is executed.
    - * The node becomes the action's target. Refer to CCAction::getTarget() + * The node becomes the action's target. Refer to cc.Action's getTarget() + * @function * @warning Starting from v0.8 actions don't retain their target anymore. * @param {cc.Action} action * @return {cc.Action} An Action pointer @@ -1526,6 +1588,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Stops and removes all actions from the running action list . + * @function */ stopAllActions: function () { this.actionManager && this.actionManager.removeAllActionsFromTarget(this); @@ -1533,6 +1596,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Stops and removes an action from the running action list. + * @function * @param {cc.Action} action An action object to be removed. */ stopAction: function (action) { @@ -1541,6 +1605,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Removes an action from the running action list by its tag. + * @function * @param {Number} tag A tag that indicates the action to be removed. */ stopActionByTag: function (tag) { @@ -1552,7 +1617,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Gets an action from the running action list by its tag. + * Returns an action from the running action list by its tag. + * @function * @see setTag(int), getTag(). * @param {Number} tag * @return {cc.Action} The action object with the given tag. @@ -1565,10 +1631,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return this.actionManager.getActionByTag(tag, this); }, - /** Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
    + /**

    Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
    * Composable actions are counted as 1 action. Example:
    * If you are running 1 Sequence of 7 actions, it will return 1.
    - * If you are running 7 Sequences of 2 actions, it will return 7. + * If you are running 7 Sequences of 2 actions, it will return 7.

    + * @function * @return {Number} The number of actions that are running plus the ones that are schedule to run */ getNumberOfRunningActions: function () { @@ -1578,10 +1645,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // cc.Node - Callbacks // timers /** - * schedules the "update" method.
    + *

    schedules the "update" method.
    * It will use the order number 0. This method will be called every frame.
    * Scheduled methods with a lower order value will be called before the ones that have a higher order value.
    - * Only one "update" method could be scheduled per node. + * Only one "update" method could be scheduled per node.

    + * @function */ scheduleUpdate: function () { this.scheduleUpdateWithPriority(0); @@ -1594,6 +1662,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Scheduled callback functions with a lower priority will be called before the ones that have a higher value.
    * Only one "update" callback function could be scheduled per node (You can't have 2 'update' callback functions).
    *

    + * @function * @param {Number} priority */ scheduleUpdateWithPriority: function (priority) { @@ -1601,7 +1670,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * unschedules the "update" method. + * Unschedules the "update" method. + * @function * @see scheduleUpdate(); */ unscheduleUpdate: function () { @@ -1609,9 +1679,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Schedules a custom selector.
    - * If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. - * + *

    Schedules a custom selector.
    + * If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.

    + * @function * @param {function} callback_fn A function wrapped as a selector * @param {Number} interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead. * @param {Number} repeat The selector will be executed (repeat + 1) times, you can use kCCRepeatForever for tick infinitely. @@ -1632,7 +1702,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Schedules a callback function that runs only once, with a delay of 0 or larger - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) + * @function + * @see schedule(function, float, unsigned int, float) * @param {function} callback_fn A function wrapped as a selector * @param {Number} delay The amount of time that the first tick will wait before execution. */ @@ -1642,7 +1713,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * unschedules a custom callback function. - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) + * @function + * @see schedule(function, float, unsigned int, float) * @param {function} callback_fn A function wrapped as a selector */ unschedule: function (callback_fn) { @@ -1654,8 +1726,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
    - * Actions are not affected by this method. + *

    unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
    + * Actions are not affected by this method.

    + * @function */ unscheduleAllCallbacks: function () { this.scheduler.unscheduleAllCallbacksForTarget(this); @@ -1664,7 +1737,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Resumes all scheduled selectors and actions.
    * This method is called internally by onEnter - * @deprecated + * @function + * @deprecated since v3.0, please use resume() instead */ resumeSchedulerAndActions: function () { cc.log(cc._LogInfos.Node_resumeSchedulerAndActions); @@ -1672,8 +1746,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Resumes all scheduled selectors and actions.
    - * This method is called internally by onEnter + *

    Resumes all scheduled selectors and actions.
    + * This method is called internally by onEnter

    */ resume: function () { this.scheduler.resumeTarget(this); @@ -1682,9 +1756,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Pauses all scheduled selectors and actions.
    - * This method is called internally by onExit - * @deprecated + *

    Pauses all scheduled selectors and actions.
    + * This method is called internally by onExit

    + * @deprecated since v3.0, please use pause instead + * @function */ pauseSchedulerAndActions: function () { cc.log(cc._LogInfos.Node_pauseSchedulerAndActions); @@ -1692,8 +1767,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Pauses all scheduled selectors and actions.
    - * This method is called internally by onExit + *

    Pauses all scheduled selectors and actions.
    + * This method is called internally by onExit

    + * @function */ pause: function () { this.scheduler.pauseTarget(this); @@ -2184,7 +2260,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Get the opacity of Node + * Returns the opacity of Node * @returns {number} opacity */ getOpacity: function () { @@ -2192,7 +2268,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Get the displayed opacity of Node + * Returns the displayed opacity of Node * @returns {number} displayed opacity */ getDisplayedOpacity: function () { @@ -2200,7 +2276,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Set the opacity of Node + * Sets the opacity of Node * @param {Number} opacity */ setOpacity: function (opacity) { @@ -2272,7 +2348,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Get the color of Node + * Returns the color of Node * @returns {cc.Color} */ getColor: function () { @@ -2281,7 +2357,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Get the displayed color of Node + * Returns the displayed color of Node * @returns {cc.Color} */ getDisplayedColor: function () { @@ -2290,7 +2366,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Set the color of Node. + * Sets the color of Node. * @param {cc.Color} color When color not set alpha like cc.color(128,128,128),only change the color. When color set alpha like cc.color(128,128,128,100),then change the color and alpha. */ setColor: function (color) { From 867ed5559363381ff52b35b060da15ff46563b37 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 25 Aug 2014 10:57:43 +0800 Subject: [PATCH 0502/1564] Issue #5695: Update Facebook plugin (static param) --- external/pluginx/platform/facebook.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 7e58af110a..b73a5b00eb 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -10,6 +10,8 @@ plugin.extend('facebook', { 'Delete': 'delete' }, + CodeSucceed: 0, + ctor: function(config){ this.name = "facebook"; this.version = "1.0"; From d86e6c0ac9287ade0a5717aea398b493c4b383f1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 25 Aug 2014 11:57:24 +0800 Subject: [PATCH 0503/1564] Issue #5695: Update Facebook plugin (Notes and compatible) --- external/pluginx/Plugin.js | 29 +++++++ external/pluginx/platform/facebook.js | 117 +++++++++++++++++++++----- 2 files changed, 123 insertions(+), 23 deletions(-) diff --git a/external/pluginx/Plugin.js b/external/pluginx/Plugin.js index f2d003e8e9..4693cb3ce0 100644 --- a/external/pluginx/Plugin.js +++ b/external/pluginx/Plugin.js @@ -1,3 +1,32 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * plugin manager + * @class + * + */ (function(){ if(cc === undefined){ diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index b73a5b00eb..b0a28a37b6 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -1,7 +1,40 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * Facebook APIs
    + * FacebookAgent... + * + * @property {String} name - plugin name + * @property {String} version - API version + * @property {Object} userInfo - store user data + * @property {Object} HttpMethod - store http method static param + * @property {Number} CodeSucceed - success code + */ plugin.extend('facebook', { name: "", version: "", - loggedIn: false, userInfo: null, HttpMethod: { @@ -12,6 +45,10 @@ plugin.extend('facebook', { CodeSucceed: 0, + /** + * Initialize Facebook sdk + * @param {Object} config + */ ctor: function(config){ this.name = "facebook"; this.version = "1.0"; @@ -39,6 +76,7 @@ plugin.extend('facebook', { }, /** + * Gets the current object * @returns {FacebookAgent} */ getInstance: function(){ @@ -46,9 +84,11 @@ plugin.extend('facebook', { }, /** + * Login to facebook * @param {Function} callback - * callback @param {Number} code - * callback @param {String} mag + * @example + * //example + * plugin.FacebookAgent.login(); */ login: function(callback){ var self = this; @@ -64,34 +104,47 @@ plugin.extend('facebook', { error_message: "unknown" }); } - }, { scope: '' }); + }, { scope: 'publish_actions' }); }, /** + * Checking login status * @param {Function} callback - * @return {Boolean} + * @example + * //example + * plugin.FacebookAgent.isLoggedIn(type, msg); */ isLoggedIn: function(callback){ var self = this; FB.getLoginStatus(function(response) { - if (response && response['status'] === 'connected') { - //login - save user info - self.userInfo = response['authResponse']; - typeof callback === 'function' && callback(0, { - isLoggedIn: true, - accessToken: response['authResponse']['accessToken'] - }); + if(response){ + if (response['status'] === 'connected') { + //login - save user info + self.userInfo = response['authResponse']; + typeof callback === 'function' && callback(0, { + isLoggedIn: true, + accessToken: response['authResponse']['accessToken'] + }); + }else{ + typeof callback === 'function' && callback(0, { + isLoggedIn: false, + accessToken: "" + }); + } }else{ - typeof callback === 'function' && callback(0, { - isLoggedIn: false, - accessToken: "" + typeof callback === 'function' && callback(1, { + error_message: 'Unknown' }); } }); }, /** + * Logout of facebook * @param {Function} callback + * @example + * //example + * plugin.FacebookAgent.logout(callback); */ logout: function(callback){ var self = this; @@ -109,8 +162,12 @@ plugin.extend('facebook', { }, /** + * Acquiring new permissions * @param permissions * @param callback + * @example + * //example + * plugin.FacebookAgent.requestPermissions(["manage_pages"], callback); */ requestPermissions: function(permissions, callback){ var permissionsStr = permissions.join(','); @@ -135,7 +192,11 @@ plugin.extend('facebook', { }, /** + * Acquiring AccessToken * @param {Function} callback + * @example + * //example + * plugin.FacebookAgent.requestPermissions(callback); */ requestAccessToken: function(callback){ if(typeof callback !== 'function'){ @@ -152,11 +213,11 @@ plugin.extend('facebook', { if (response && response['status'] === 'connected') { //login - save user info self.userInfo = response['authResponse']; - typeof callback === 'function' && callback(0, { + callback(0, { accessToken: response['authResponse']['accessToken'] }); }else{ - typeof callback === 'function' && callback(response['error_code'] || 1, { + callback(response['error_code'] || 1, { error_message: response['error_message'] || "Unknown" }); } @@ -165,6 +226,7 @@ plugin.extend('facebook', { }, /** + * Share something * @param info * @param callback */ @@ -197,6 +259,7 @@ plugin.extend('facebook', { }, /** + * Various pop * @param info * @param callback */ @@ -281,23 +344,32 @@ plugin.extend('facebook', { }, /** + * FB.api package * @param {String} path * @param {Number} httpmethod * @param {Object} params * @param {Function} callback */ request: function(path, httpmethod, params, callback){ + if(typeof params === 'function'){ + callback = params; + params = {}; + } FB.api(path, httpmethod, params, function(response){ if(response.error){ - callback(response['error']['code'], { + typeof callback === 'function' && callback(response['error']['code'], { error_message: response['error']['message'] || 'Unknown' }) }else{ - callback(0, response); + typeof callback === 'function' && callback(0, response); } }); }, + /** + * Get permission list + * @param callback + */ getPermissionList: function(callback){ FB.api("/me/permissions", function(response){ if(response['data']){ @@ -321,6 +393,7 @@ plugin.extend('facebook', { destroyInstance: function(){}, /** + * Payment request * @param {Object} info * @param {Function} callback */ @@ -329,10 +402,8 @@ plugin.extend('facebook', { * Reference document * https://developers.facebook.com/docs/payments/reference/paydialog */ - if(!info['method']) - info['method'] = 'pay'; - if(!info['action']) - info['action'] = 'purchaseitem'; + info['method'] = 'pay'; + info['action'] = 'purchaseitem'; FB.ui(info, function(response) { if(response['error_code']){ From cd7289749d87815248d44ce623bdc08c87af5878 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 13:53:53 +0800 Subject: [PATCH 0504/1564] Doc #5829: Fix issues in Node inline docs(half done) --- cocos2d/core/base-nodes/CCNode.js | 72 ++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 3dd5696753..4ba36c4935 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1778,10 +1778,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - *

    Sets the additional transform.
    + *

    Sets the additional transform.
    * The additional transform will be concatenated at the end of getNodeToParentTransform.
    * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
    *

    + * @function + * @param {cc.AffineTransform} additionalTransform The additional transform * @example * // create a batchNode * var batch= cc.SpriteBatchNode.create("Icon-114.png"); @@ -1833,6 +1835,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
    * The matrix is in Pixels. + * @function * @return {cc.AffineTransform} */ getParentToNodeTransform: function () { @@ -1844,14 +1847,16 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * @deprecated + * @function + * @deprecated since v3.0, please use getParentToNodeTransform instead */ parentToNodeTransform: function () { return this.getParentToNodeTransform(); }, /** - * Returns the world affine transform matrix. The matrix is in Pixels. + * Returns the world affine transform matrix. The matrix is in Pixels. + * @function * @return {cc.AffineTransform} */ getNodeToWorldTransform: function () { @@ -1862,7 +1867,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * @deprecated + * @function + * @deprecated since v3.0, please use getNodeToWorldTransform instead */ nodeToWorldTransform: function(){ return this.getNodeToWorldTransform(); @@ -1870,6 +1876,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns the inverse world affine transform matrix. The matrix is in Pixels. + * @function * @return {cc.AffineTransform} */ getWorldToNodeTransform: function () { @@ -1877,7 +1884,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * @deprecated + * @function + * @deprecated since v3.0, please use getWorldToNodeTransform instead */ worldToNodeTransform: function () { return this.getWorldToNodeTransform(); @@ -1885,6 +1893,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Converts a Point to node (local) space coordinates. The result is in Points. + * @function * @param {cc.Point} worldPoint * @return {cc.Point} */ @@ -1894,6 +1903,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Converts a Point to world space coordinates. The result is in Points. + * @function * @param {cc.Point} nodePoint * @return {cc.Point} */ @@ -1905,6 +1915,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Converts a Point to node (local) space coordinates. The result is in Points.
    * treating the returned/received node point as anchor relative. + * @function * @param {cc.Point} worldPoint * @return {cc.Point} */ @@ -1915,6 +1926,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Converts a local Point to world space coordinates.The result is in Points.
    * treating the returned/received node point as anchor relative. + * @function * @param {cc.Point} nodePoint * @return {cc.Point} */ @@ -1930,7 +1942,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** convenience methods which take a cc.Touch instead of cc.Point - * @param {cc.Touch} touch + * @function + * @param {cc.Touch} touch The touch object * @return {cc.Point} */ convertTouchToNodeSpace: function (touch) { @@ -1942,7 +1955,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * converts a cc.Touch (world coordinates) into a local coordiante. This method is AR (Anchor Relative). - * @param {cc.Touch}touch + * @function + * @param {cc.Touch} touch The touch object * @return {cc.Point} */ convertTouchToNodeSpaceAR: function (touch) { @@ -1952,9 +1966,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Update will be called automatically every frame if "scheduleUpdate" is called, and the node is "live"
    - * (override me) - * @param {Number} dt deltaTime + * Update will be called automatically every frame if "scheduleUpdate" is called when the node is "live".
    + * The default behavior is to invoke the visit function of node's componentContainer.
    + * Override me to implement your own update logic. + * @function + * @param {Number} dt Delta time since last update */ update: function (dt) { if (this._componentContainer && !this._componentContainer.isEmpty()) @@ -1969,6 +1985,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * As the result, you apply CCSpriteBatchNode's optimization on your customed CCNode.
    * e.g., batchNode->addChild(myCustomNode), while you can only addChild(sprite) before. *

    + * @function */ updateTransform: function () { // Recursively iterate over children @@ -1976,26 +1993,49 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, + *

    Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. - * This is a hack, and should be removed once JSB fixes the retain/release bug + * This is a hack, and should be removed once JSB fixes the retain/release bug
    + * You will need to retain an object if you created an engine object and haven't added it into the scene graph during the same frame.
    + * Otherwise, JSB's native autorelease pool will consider this object a useless one and release it directly,
    + * when you want to use it later, a "Invalid Native Object" error will be raised.
    + * The retain function can increase a reference count for the native object to avoid it being released,
    + * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    + * retain and release function call should be paired in developer's game code.

    + * @function + * @see release() */ retain: function () { }, + /** + *

    Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, + * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. + * This is a hack, and should be removed once JSB fixes the retain/release bug
    + * You will need to retain an object if you created an engine object and haven't added it into the scene graph during the same frame.
    + * Otherwise, JSB's native autorelease pool will consider this object a useless one and release it directly,
    + * when you want to use it later, a "Invalid Native Object" error will be raised.
    + * The retain function can increase a reference count for the native object to avoid it being released,
    + * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    + * retain and release function call should be paired in developer's game code.

    + * @function + * @see retain() + */ release: function () { }, /** - * gets a component by its name - * @param {String} name - * @return {cc.Component} gets a component by its name + * Returns a component identified by the name given + * @function + * @param {String} name The name to search for + * @return {cc.Component} The component found */ getComponent: function (name) { return this._componentContainer.getComponent(name); }, /** - * adds a component + * Adds a component + * @function * @param {cc.Component} component */ addComponent: function (component) { From c9c4f737929a1485b9dbd1977df01b07850c673c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 25 Aug 2014 13:56:54 +0800 Subject: [PATCH 0505/1564] Fixed #5844: UIButton color error --- extensions/ccui/uiwidgets/UIButton.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 2492d38953..a549821305 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -512,7 +512,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setVisible(true); this._buttonDisableRenderer.setVisible(false); if (this._scale9Enabled) - locNormalRenderer.setColor(cc.Color.GRAY); + locNormalRenderer.setColor(cc.color.GRAY); else { locNormalRenderer.stopAllActions(); locNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); From 3387fac1d9679edad1cddddd8f8039f518a9213d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 25 Aug 2014 14:49:38 +0800 Subject: [PATCH 0506/1564] Closed #5845: Fixed a bug of InputManager, its first touch move event's delta is wrong. --- cocos2d/core/platform/CCInputManager.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 6d89064fe8..740a8ac7a2 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -104,7 +104,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ cc.log(cc._LogInfos.inputManager_handleTouchesBegin, unusedIndex); continue; } - curTouch = this._touches[unusedIndex] = selTouch; + //curTouch = this._touches[unusedIndex] = curTouch; + curTouch = this._touches[unusedIndex] = new cc.Touch(); + curTouch._setPoint(selTouch._point); + curTouch._setPrevPoint(selTouch._prevPoint); locTouchIntDict[touchID] = unusedIndex; handleTouches.push(curTouch); } @@ -174,7 +177,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ } if(locTouches[index]){ locTouches[index]._setPoint(selTouch._point); - locTouches[index]._setPrevPoint(selTouch._prevPoint); //TODO + locTouches[index]._setPrevPoint(selTouch._prevPoint); handleTouches.push(locTouches[index]); this._removeUsedIndexBit(index); delete locTouchesIntDict[touchID]; From bd5c48b04e9d3449c60d2e8bf89435b6ecc7dad6 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Mon, 25 Aug 2014 15:39:52 +0800 Subject: [PATCH 0507/1564] change ccpool hasOjb to hasObject and change removeObj to removeObject --- extensions/ccpool/CCPool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 30cd4f9a3c..7df87e4507 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -73,7 +73,7 @@ cc.pool = /** @lends cc.pool# */{ * @param objClass * @returns {boolean} if this kind of obj is already in pool return true,else return false; */ - hasObj: function (objClass) { + hasObject: function (objClass) { var pid = objClass.prototype.__pid; var list = this._pool[pid]; return (list && list.length > 0); @@ -83,7 +83,7 @@ cc.pool = /** @lends cc.pool# */{ * Remove the obj if you want to delete it; * @param obj */ - removeObj: function (obj) { + removeObject: function (obj) { var pid = obj.constructor.prototype.__pid; if (pid) { var list = this._pool[pid]; @@ -104,7 +104,7 @@ cc.pool = /** @lends cc.pool# */{ * @returns {*} call the reuse function an return the obj */ getFromPool: function (objClass/*,args*/) { - if (this.hasObj(objClass)) { + if (this.hasObject(objClass)) { var pid = objClass.prototype.__pid; var list = this._pool[pid]; var args = Array.prototype.slice.call(arguments); From a570c2f117c309d1c823cd1871838962bf1b3d3f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 15:40:21 +0800 Subject: [PATCH 0508/1564] Doc #5829: Fix issues in Node inline docs and refactor Node's functions to match JSB --- .../base-nodes/BaseNodesPropertyDefine.js | 3 - cocos2d/core/base-nodes/CCNode.js | 164 ++++++++++-------- cocos2d/core/sprites/CCSprite.js | 4 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 6 +- cocos2d/core/sprites/SpritesWebGL.js | 2 +- extensions/editbox/CCdomNode.js | 2 +- 6 files changed, 101 insertions(+), 80 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js index 0cd74ade60..4bf8e9d429 100644 --- a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +++ b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js @@ -117,9 +117,6 @@ cc._tmp.PrototypeCCNode = function () { /** @expose */ _p.shaderProgram; cc.defineGetterSetter(_p, "shaderProgram", _p.getShaderProgram, _p.setShaderProgram); - /** @expose */ - _p.glServerState; - cc.defineGetterSetter(_p, "glServerState", _p.getGLServerState, _p.setGLServerState); /** @expose */ _p.opacity; diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 4ba36c4935..74352c2fe8 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -111,7 +111,7 @@ cc.s_globalOrderOfArrival = 1; * @property {cc.Color} color - Color of node, default value is white: (255, 255, 255) * @property {Boolean} cascadeColor - Indicate whether node's color value affect its child nodes, default value is false * @property {Number} opacity - Opacity of node, default value is 255 - * @property {Boolean} opacityModifyRGB - <@readonly>Indicate whether opacity affect the color value, default value is false + * @property {Boolean} opacityModifyRGB - Indicate whether opacity affect the color value, default value is false * @property {Boolean} cascadeOpacity - Indicate whether node's opacity value affect its child nodes, default value is false * @property {Array} children - <@readonly> All children nodes * @property {Number} childrenCount - <@readonly> Number of children @@ -235,7 +235,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return; var i, len = array.length, node; - var nodeCallbackType = cc.Node.StateCallbackType; + var nodeCallbackType = cc.Node._StateCallbackType; switch (callbackType) { case nodeCallbackType.onEnter: for (i = 0; i < len; i++) { @@ -1199,7 +1199,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ cc.eventManager.removeListeners(this); // timers - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.cleanup); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.cleanup); }, // composition: GET @@ -1273,11 +1273,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ cc.assert(child, cc._LogInfos.Node_addChild_3); cc.assert(child._parent === null, "child already added. It can't be added again"); - this.addChildHelper(child, localZOrder, tag, name, setTag); + this._addChildHelper(child, localZOrder, tag, name, setTag); }, - addChildHelper: function(child, localZOrder, tag, name, setTag){ + _addChildHelper: function(child, localZOrder, tag, name, setTag){ if(!this._children) this._children = []; @@ -1503,10 +1503,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // DON'T draw your stuff outside this method }, - /** performs OpenGL view-matrix transformation of it's ancestors.
    - * Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO)
    - * it's necessary to transform the ancestors again. - */ + // Internal use only, do not call it by yourself, transformAncestors: function () { if (this._parent != null) { this._parent.transformAncestors(); @@ -1527,7 +1524,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ onEnter: function () { this._isTransitionFinished = false; this._running = true;//should be running before resumeSchedule - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnter); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnter); this.resume(); }, @@ -1541,7 +1538,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ onEnterTransitionDidFinish: function () { this._isTransitionFinished = true; - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnterTransitionDidFinish); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnterTransitionDidFinish); }, /** @@ -1551,7 +1548,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function */ onExitTransitionDidStart: function () { - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExitTransitionDidStart); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExitTransitionDidStart); }, /** @@ -1566,7 +1563,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ onExit: function () { this._running = false; this.pause(); - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExit); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExit); }, // actions @@ -1989,7 +1986,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ updateTransform: function () { // Recursively iterate over children - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform); }, /** @@ -2024,7 +2021,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Returns a component identified by the name given + * Returns a component identified by the name given. * @function * @param {String} name The name to search for * @return {cc.Component} The component found @@ -2034,7 +2031,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Adds a component + * Adds a component to the node's component container. * @function * @param {cc.Component} component */ @@ -2043,15 +2040,17 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * removes a component by its name or a component - * @param {String|cc.Component} name + * Removes a component identified by the given name or removes the component object given + * @function + * @param {String|cc.Component} component */ - removeComponent: function (name) { - return this._componentContainer.remove(name); + removeComponent: function (component) { + return this._componentContainer.remove(component); }, /** - * removes all components + * Removes all components + * @function */ removeAllComponents: function () { this._componentContainer.removeAll(); @@ -2059,6 +2058,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ grid: null, + /** + *

    The cc.Node's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.Node()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    + * @constructor + */ ctor: null, /** @@ -2069,18 +2074,18 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ visit: null, /** - * Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes. + * Performs view-matrix transformation based on position, scale, rotation and other attributes. * @function - * @param {CanvasRenderingContext2D|null} ctx Render context + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx Render context */ transform: null, /** - * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
    - * The matrix is in Pixels. + *

    Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
    + * The matrix is in Pixels.

    * @function * @return {cc.AffineTransform} - * @deprecated + * @deprecated since v3.0, please use getNodeToParentTransform instead */ nodeToParentTransform: function(){ return this.getNodeToParentTransform(); @@ -2090,7 +2095,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
    * The matrix is in Pixels. * @function - * @return {cc.AffineTransform} + * @return {cc.AffineTransform} The affine transform object */ getNodeToParentTransform: null, @@ -2116,7 +2121,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns a camera object that lets you move the node using a gluLookAt + * @function * @return {cc.Camera} A CCCamera object that lets you move the node using a gluLookAt + * @deprecated since v3.0, no alternative function * @example * var camera = node.getCamera(); * camera.setEye(0, 0, 415/2); @@ -2130,16 +2137,22 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Returns a grid object that is used when applying effects + *

    Returns a grid object that is used when applying effects.
    + * This function have been deprecated, please use cc.NodeGrid to run grid actions

    + * @function * @return {cc.GridBase} A CCGrid object that is used when applying effects + * @deprecated since v3.0, no alternative function */ getGrid: function () { return this.grid; }, /** - * Changes a grid object that is used when applying effects + *

    Changes a grid object that is used when applying effects
    + * This function have been deprecated, please use cc.NodeGrid to run grid actions

    + * @function * @param {cc.GridBase} grid A CCGrid object that is used when applying effects + * @deprecated since v3.0, no alternative function */ setGrid: function (grid) { this.grid = grid; @@ -2147,7 +2160,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Return the shader program currently used for this node - * @return {cc.GLProgram} The shader program currelty used for this node + * @function + * @return {cc.GLProgram} The shader program currently used for this node */ getShaderProgram: function () { return this._shaderProgram; @@ -2160,9 +2174,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Since v2.0, each rendering node must set its shader program. * It should be set in initialize phase. *

    + * @function * @param {cc.GLProgram} newShaderProgram The shader program which fetchs from CCShaderCache. * @example - * node.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + * node.setGLProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); */ setShaderProgram: function (newShaderProgram) { this._shaderProgram = newShaderProgram; @@ -2170,7 +2185,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns the state of OpenGL server side. + * @function * @return {Number} The state of OpenGL server side. + * @deprecated since v3.0, no need anymore */ getGLServerState: function () { return this._glServerState; @@ -2178,19 +2195,23 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Sets the state of OpenGL server side. + * @function * @param {Number} state The state of OpenGL server side. + * @deprecated since v3.0, no need anymore */ setGLServerState: function (state) { this._glServerState = state; }, - /** returns a "world" axis aligned bounding box of the node.
    + /** + * Returns a "world" axis aligned bounding box of the node. + * @function * @return {cc.Rect} */ getBoundingBoxToWorld: function () { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var trans = this.nodeToWorldTransform(); - rect = cc.rectApplyAffineTransform(rect, this.nodeToWorldTransform()); + var trans = this.getNodeToWorldTransform(); + rect = cc.rectApplyAffineTransform(rect, this.getNodeToWorldTransform()); //query child's BoundingBox if (!this._children) @@ -2301,6 +2322,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns the opacity of Node + * @function * @returns {number} opacity */ getOpacity: function () { @@ -2308,7 +2330,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Returns the displayed opacity of Node + * Returns the displayed opacity of Node, + * the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + * @function * @returns {number} displayed opacity */ getDisplayedOpacity: function () { @@ -2317,6 +2341,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Sets the opacity of Node + * @function * @param {Number} opacity */ setOpacity: function (opacity) { @@ -2332,6 +2357,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Update displayed opacity + * @function * @param {Number} parentOpacity */ updateDisplayedOpacity: function (parentOpacity) { @@ -2347,7 +2373,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * whether or not it will set cascade opacity. + * Returns whether node's opacity value affect its child nodes. + * @function * @returns {boolean} */ isCascadeOpacityEnabled: function () { @@ -2355,7 +2382,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Enable or disable cascade opacity + * Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + * @function * @param {boolean} cascadeOpacityEnabled */ setCascadeOpacityEnabled: function (cascadeOpacityEnabled) { @@ -2389,6 +2417,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns the color of Node + * @function * @returns {cc.Color} */ getColor: function () { @@ -2397,7 +2426,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Returns the displayed color of Node + * Returns the displayed color of Node, + * the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + * @function * @returns {cc.Color} */ getDisplayedColor: function () { @@ -2406,8 +2437,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Sets the color of Node. - * @param {cc.Color} color When color not set alpha like cc.color(128,128,128),only change the color. When color set alpha like cc.color(128,128,128,100),then change the color and alpha. + *

    Sets the color of Node.
    + * When color doesn't include opacity value like cc.color(128,128,128), this function only change the color.
    + * When color include opacity like cc.color(128,128,128,100), then this function will change the color and the opacity.

    + * @function + * @param {cc.Color} color The new coloe given */ setColor: function (color) { var locDisplayedColor = this._displayedColor, locRealColor = this._realColor; @@ -2428,7 +2462,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * update the displayed color of Node + * Update the displayed color of Node + * @function * @param {cc.Color} parentColor */ updateDisplayedColor: function (parentColor) { @@ -2448,7 +2483,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * whether or not it will set cascade color. + * Returns whether node's color value affect its child nodes. + * @function * @returns {boolean} */ isCascadeColorEnabled: function () { @@ -2456,7 +2492,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Enable or disable cascade color + * Enable or disable cascade color, if cascade enabled, child nodes' opacity will be the cascade value of parent color and its own color. * @param {boolean} cascadeColorEnabled */ setCascadeColorEnabled: function (cascadeColorEnabled) { @@ -2492,32 +2528,35 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } }, + /** + * Set whether color should be changed with the opacity value, + * useless in cc.Node, but this function is overrided in some class to have such behavior. + * @function + * @param {Boolean} value + */ setOpacityModifyRGB: function (opacityValue) { }, + /** + * Get whether color should be changed with the opacity value + * @function + * @return {Boolean} + */ isOpacityModifyRGB: function () { return false; } }); /** - * allocates and initializes a node. - * @deprecated + * Allocates and initializes a node. + * @deprecated since v3.0, please use new construction instead. * @return {cc.Node} - * @example - * // example - * var node = cc.Node.create(); */ cc.Node.create = function () { return new cc.Node(); }; -/** - * cc.Node's state callback type - * @constant - * @type Number - */ -cc.Node.StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7}; +cc.Node._StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7}; if (cc._renderType === cc._RENDER_TYPE_CANVAS) { @@ -2662,19 +2701,4 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } cc.assert(typeof cc._tmp.PrototypeCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); cc._tmp.PrototypeCCNode(); -delete cc._tmp.PrototypeCCNode; - -/** - * 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 +delete cc._tmp.PrototypeCCNode; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 7cec843d87..dd58421496 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -530,7 +530,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ } if (this._batchNode) { - this._arrayMakeObjectsPerformSelector(_children, cc.Node.StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(_children, cc.Node._StateCallbackType.sortAllChildren); } //don't need to check children recursively, that's done in visit of each child @@ -1460,7 +1460,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { // recursively iterate over children if (_t._hasChildren) - _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node.StateCallbackType.updateTransform); + _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._StateCallbackType.updateTransform); }; _p.addChild = function (child, localZOrder, tag) { diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 717436f2ca..a9cee04765 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -1007,7 +1007,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //sorted now check all children if (locChildren.length > 0) { //first sort all children recursively based on zOrder - this._arrayMakeObjectsPerformSelector(locChildren, cc.Node.StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(locChildren, cc.Node._StateCallbackType.sortAllChildren); } this._reorderChildDirty = false; } @@ -1036,7 +1036,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //sorted now check all children if (childrenArr.length > 0) { //first sort all children recursively based on zOrder - this._arrayMakeObjectsPerformSelector(childrenArr, cc.Node.StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(childrenArr, cc.Node._StateCallbackType.sortAllChildren); var index = 0; //fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact) @@ -1061,7 +1061,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //cc.nodeDrawSetup(this); this._shaderProgram.use(); this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform); cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); this.textureAtlas.drawQuads(); diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 56559d24f3..8e894e080f 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -338,7 +338,7 @@ cc._tmp.WebGLSprite = function () { // recursively iterate over children if (_t._hasChildren) - _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node.StateCallbackType.updateTransform); + _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._StateCallbackType.updateTransform); if (cc.SPRITE_DEBUG_DRAW) { // draw bounding box diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index 555e872ea6..b13047b056 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -391,7 +391,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ this.unscheduleAllCallbacks(); // timers - this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.cleanup); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.cleanup); if (this.dom) { this.dom.remove(); } From 946e667111c9c425b46e01368235c58d6b277f81 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 25 Aug 2014 16:25:28 +0800 Subject: [PATCH 0509/1564] Fixed #5847: The gravity sensing numerical inversion in html5 --- CCBoot.js | 2 +- cocos2d/core/platform/CCInputExtension.js | 25 +++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index cfb46436f7..dc413d4e43 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1437,8 +1437,8 @@ cc._initSys = function (config, CONFIG_KEY) { else if (iOS) osName = sys.OS_IOS; else if (nav.appVersion.indexOf("Mac") != -1) osName = sys.OS_OSX; else if (nav.appVersion.indexOf("X11") != -1) osName = sys.OS_UNIX; - else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; else if (isAndroid) osName = sys.OS_ANDROID; + else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; sys.os = osName; // Forces the garbage collector diff --git a/cocos2d/core/platform/CCInputExtension.js b/cocos2d/core/platform/CCInputExtension.js index 17e7d4f44a..9a25d26d01 100644 --- a/cocos2d/core/platform/CCInputExtension.js +++ b/cocos2d/core/platform/CCInputExtension.js @@ -92,16 +92,29 @@ _p.didAccelerate = function (eventData) { return; var mAcceleration = _t._acceleration; + + var x, y, z; + if (_t._accelDeviceEvent == window.DeviceMotionEvent) { var eventAcceleration = eventData["accelerationIncludingGravity"]; - mAcceleration.x = _t._accelMinus * eventAcceleration.x * 0.1; - mAcceleration.y = _t._accelMinus * eventAcceleration.y * 0.1; - mAcceleration.z = eventAcceleration.z * 0.1; + x = _t._accelMinus * eventAcceleration.x * 0.1; + y = _t._accelMinus * eventAcceleration.y * 0.1; + z = eventAcceleration.z * 0.1; } else { - mAcceleration.x = (eventData["gamma"] / 90) * 0.981; - mAcceleration.y = -(eventData["beta"] / 90) * 0.981; - mAcceleration.z = (eventData["alpha"] / 90) * 0.981; + x = (eventData["gamma"] / 90) * 0.981; + y = -(eventData["beta"] / 90) * 0.981; + z = (eventData["alpha"] / 90) * 0.981; } + + if(cc.sys.os === cc.sys.OS_ANDROID){ + mAcceleration.x = -x; + mAcceleration.y = -y; + }else{ + mAcceleration.x = x; + mAcceleration.y = y; + } + mAcceleration.z = z; + mAcceleration.timestamp = eventData.timeStamp || Date.now(); var tmpX = mAcceleration.x; From 0cd84d5204ebb22950523ebceca054a824d5a221 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 16:44:20 +0800 Subject: [PATCH 0510/1564] Doc #5829: Fix issues in AffineTransform and Geometry inline docs --- cocos2d/core/cocoa/CCAffineTransform.js | 83 +++++++++++----------- cocos2d/core/cocoa/CCGeometry.js | 94 ++++++++++++++----------- 2 files changed, 96 insertions(+), 81 deletions(-) diff --git a/cocos2d/core/cocoa/CCAffineTransform.js b/cocos2d/core/cocoa/CCAffineTransform.js index a0cbafb1a2..4a1d9756dd 100644 --- a/cocos2d/core/cocoa/CCAffineTransform.js +++ b/cocos2d/core/cocoa/CCAffineTransform.js @@ -25,13 +25,18 @@ ****************************************************************************/ /** - * @function + *

    cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
    + * Please do not use its constructor directly, use cc.affineTransformMake alias function instead. + *

    + * @class cc.AffineTransform + * @constructor * @param {Number} a * @param {Number} b * @param {Number} c * @param {Number} d * @param {Number} tx * @param {Number} ty + * @see cc.affineTransformMake() */ cc.AffineTransform = function (a, b, c, d, tx, ty) { this.a = a; @@ -43,8 +48,9 @@ cc.AffineTransform = function (a, b, c, d, tx, ty) { }; /** - * + * Create a cc.AffineTransform object with all contents in the matrix * @function + * * @param {Number} a * @param {Number} b * @param {Number} c @@ -52,19 +58,18 @@ cc.AffineTransform = function (a, b, c, d, tx, ty) { * @param {Number} tx * @param {Number} ty * @return {cc.AffineTransform} - * Constructor */ cc.affineTransformMake = function (a, b, c, d, tx, ty) { return {a: a, b: b, c: c, d: d, tx: tx, ty: ty}; }; /** - * + * Apply the affine transformation on a point. * @function + * * @param {cc.Point} point * @param {cc.AffineTransform} t * @return {cc.Point} - * Constructor */ cc.pointApplyAffineTransform = function (point, t) { return {x: t.a * point.x + t.c * point.y + t.tx, y: t.b * point.x + t.d * point.y + t.ty}; @@ -76,44 +81,50 @@ cc._pointApplyAffineTransform = function (x, y, t) { }; /** - * + * Apply the affine transformation on a size. * @function + * * @param {cc.Size} size * @param {cc.AffineTransform} t * @return {cc.Size} - * Constructor */ cc.sizeApplyAffineTransform = function (size, t) { return {width: t.a * size.width + t.c * size.height, height: t.b * size.width + t.d * size.height}; }; /** - * + *

    Create a identity transformation matrix:
    + * [ 1, 0, 0,
    + * 0, 1, 0 ]

    * @function + * * @return {cc.AffineTransform} - * Constructor */ cc.affineTransformMakeIdentity = function () { return {a: 1.0, b: 0.0, c: 0.0, d: 1.0, tx: 0.0, ty: 0.0}; }; /** - * + *

    Create a identity transformation matrix:
    + * [ 1, 0, 0,
    + * 0, 1, 0 ]

    * @function + * * @return {cc.AffineTransform} - * Constructor + * @deprecated since v3.0, please use cc.affineTransformMakeIdentity() instead + * @see cc.affineTransformMakeIdentity() */ cc.affineTransformIdentity = function () { return {a: 1.0, b: 0.0, c: 0.0, d: 1.0, tx: 0.0, ty: 0.0}; }; /** - * + * Apply the affine transformation on a rect. * @function + * * @param {cc.Rect} rect * @param {cc.AffineTransform} anAffineTransform * @return {cc.Rect} - * Constructor */ cc.rectApplyAffineTransform = function (rect, anAffineTransform) { var top = cc.rectGetMinY(rect); @@ -158,13 +169,13 @@ cc._rectApplyAffineTransformIn = function(rect, anAffineTransform){ }; /** - * + * Create a new affine transformation with a base transformation matrix and a translation based on it. * @function - * @param {cc.AffineTransform} t - * @param {Number} tx - * @param {Number}ty + * + * @param {cc.AffineTransform} t The base affine transform object + * @param {Number} tx The translation on x axis + * @param {Number} ty The translation on y axis * @return {cc.AffineTransform} - * Constructor */ cc.affineTransformTranslate = function (t, tx, ty) { return { @@ -178,25 +189,23 @@ cc.affineTransformTranslate = function (t, tx, ty) { }; /** - * + * Create a new affine transformation with a base transformation matrix and a scale based on it. * @function - * @param {cc.AffineTransform} t - * @param {Number} sx - * @param {Number} sy + * @param {cc.AffineTransform} t The base affine transform object + * @param {Number} sx The scale on x axis + * @param {Number} sy The scale on y axis * @return {cc.AffineTransform} - * Constructor */ cc.affineTransformScale = function (t, sx, sy) { return {a: t.a * sx, b: t.b * sx, c: t.c * sy, d: t.d * sy, tx: t.tx, ty: t.ty}; }; /** - * + * Create a new affine transformation with a base transformation matrix and a rotation based on it. * @function - * @param {cc.AffineTransform} aTransform - * @param {Number} anAngle + * @param {cc.AffineTransform} aTransform The base affine transform object + * @param {Number} anAngle The angle to rotate * @return {cc.AffineTransform} - * Constructor */ cc.affineTransformRotate = function (aTransform, anAngle) { var fSin = Math.sin(anAngle); @@ -211,14 +220,12 @@ cc.affineTransformRotate = function (aTransform, anAngle) { }; /** - * Concatenate `t2' to `t1' and return the result:
    + * Concatenate a transform matrix to another and return the result:
    * t' = t1 * t2 - * * @function - * @param {cc.AffineTransform} t1 - * @param {cc.AffineTransform} t2 - * @return {cc.AffineTransform} - * Constructor + * @param {cc.AffineTransform} t1 The first transform object + * @param {cc.AffineTransform} t2 The transform object to concatenate + * @return {cc.AffineTransform} The result of concatenation */ cc.affineTransformConcat = function (t1, t2) { return {a: t1.a * t2.a + t1.b * t2.c, //a @@ -230,25 +237,21 @@ cc.affineTransformConcat = function (t1, t2) { }; /** - * Return true if `t1' and `t2' are equal, false otherwise. - * + * Return true if an affine transform equals to another, false otherwise. * @function * @param {cc.AffineTransform} t1 * @param {cc.AffineTransform} t2 * @return {Boolean} - * Constructor */ cc.affineTransformEqualToTransform = function (t1, t2) { return ((t1.a === t2.a) && (t1.b === t2.b) && (t1.c === t2.c) && (t1.d === t2.d) && (t1.tx === t2.tx) && (t1.ty === t2.ty)); }; /** - * Get the invert value of an AffineTransform object - * + * Get the invert transform of an AffineTransform object * @function * @param {cc.AffineTransform} t - * @return {cc.AffineTransform} - * Constructor + * @return {cc.AffineTransform} The inverted transform object */ cc.affineTransformInvert = function (t) { var determinant = 1 / (t.a * t.d - t.b * t.c); diff --git a/cocos2d/core/cocoa/CCGeometry.js b/cocos2d/core/cocoa/CCGeometry.js index 7e56c5996e..3cf6027382 100644 --- a/cocos2d/core/cocoa/CCGeometry.js +++ b/cocos2d/core/cocoa/CCGeometry.js @@ -24,28 +24,30 @@ THE SOFTWARE. ****************************************************************************/ -//-------------------------------------------------------- -// -// POINT -// -//-------------------------------------------------------- +/** + * cc.Point is the class for point object, please do not use its constructor to create points, use cc.p() alias function instead. + * @class cc.Point + * @constructor + * @param {Number} x + * @param {Number} y + * @see cc.p() + */ cc.Point = function (x, y) { this.x = x || 0; this.y = y || 0; }; /** - * Helper macro that creates a cc.Point. - * - * @class cc.Point - * @constructor + * Helper function that creates a cc.Point. + * @function * @param {Number|cc.Point} x a Number or a size object * @param {Number} y * @return {cc.Point} * @example * var point1 = cc.p(); - * var point2 = cc.p(100,100,100,100); + * var point2 = cc.p(100, 100); * var point3 = cc.p(point2); + * var point4 = cc.p({x: 100, y: 100}); */ cc.p = function (x, y) { // This can actually make use of "hidden classes" in JITs and thus decrease @@ -62,6 +64,7 @@ cc.p = function (x, y) { }; /** + * Check whether a point's value equals to another * @function * @param {cc.Point} point1 * @param {cc.Point} point2 @@ -72,27 +75,30 @@ cc.pointEqualToPoint = function (point1, point2) { }; -//-------------------------------------------------------- -// -// SIZE -// -//-------------------------------------------------------- - +/** + * cc.Size is the class for size object, please do not use its constructor to create sizes, use cc.size() alias function instead. + * @class cc.Size + * @constructor + * @param {Number} width + * @param {Number} height + * @see cc.size() + */ cc.Size = function (width, height) { this.width = width || 0; this.height = height || 0; }; /** - * @class cc.Size - * @constructor + * Helper function that creates a cc.Size. + * @function * @param {Number|cc.Size} w width or a size object * @param {Number} h height * @return {cc.Size} * @example * var size1 = cc.size(); - * var size2 = cc.size(100,100,100,100); + * var size2 = cc.size(100,100); * var size3 = cc.size(size2); + * var size4 = cc.size({width: 100, height: 100}); */ cc.size = function (w, h) { // This can actually make use of "hidden classes" in JITs and thus decrease @@ -109,6 +115,7 @@ cc.size = function (w, h) { }; /** + * Check whether a point's value equals to another * @function * @param {cc.Size} size1 * @param {cc.Size} size2 @@ -119,12 +126,14 @@ cc.sizeEqualToSize = function (size1, size2) { }; -//-------------------------------------------------------- -// -// RECT -// -//-------------------------------------------------------- - +/** + * cc.Rect is the class for rect object, please do not use its constructor to create rects, use cc.rect() alias function instead. + * @class cc.Rect + * @constructor + * @param {Number} width + * @param {Number} height + * @see cc.rect() + */ cc.Rect = function (x, y, width, height) { this.x = x||0; this.y = y||0; @@ -133,9 +142,8 @@ cc.Rect = function (x, y, width, height) { }; /** - * Return a new Rect - * @class cc.Rect - * @constructor + * Helper function that creates a cc.Rect. + * @function * @param {Number|cc.Rect} x a number or a rect object * @param {Number} y * @param {Number} w @@ -145,6 +153,7 @@ cc.Rect = function (x, y, width, height) { * var rect1 = cc.rect(); * var rect2 = cc.rect(100,100,100,100); * var rect3 = cc.rect(rect2); + * var rect4 = cc.rect({x: 100, y: 100, width: 100, height: 100}); */ cc.rect = function (x, y, w, h) { if (x === undefined) @@ -155,7 +164,7 @@ cc.rect = function (x, y, w, h) { }; /** - * whether the rect1 equals the rect2 + * Check whether a rect's value equals to another * @function * @param {cc.Rect} rect1 * @param {cc.Rect} rect2 @@ -170,7 +179,7 @@ cc._rectEqualToZero = function(rect){ }; /** - * return whether the rect1 contains rect2 + * Check whether the rect1 contains rect2 * @function * @param {cc.Rect} rect1 * @param {cc.Rect} rect2 @@ -185,39 +194,39 @@ cc.rectContainsRect = function (rect1, rect2) { }; /** - * return the rightmost x-value of 'rect' + * Returns the rightmost x-value of a rect * @function * @param {cc.Rect} rect - * @return {Number} + * @return {Number} The rightmost x value */ cc.rectGetMaxX = function (rect) { return (rect.x + rect.width); }; /** - * return the midpoint x-value of 'rect' + * Return the midpoint x-value of a rect * @function * @param {cc.Rect} rect - * @return {Number} + * @return {Number} The midpoint x value */ cc.rectGetMidX = function (rect) { return (rect.x + rect.width / 2.0); }; /** - * return the leftmost x-value of 'rect' + * Returns the leftmost x-value of a rect * @function * @param {cc.Rect} rect - * @return {Number} + * @return {Number} The leftmost x value */ cc.rectGetMinX = function (rect) { return rect.x; }; /** - * Return the topmost y-value of `rect' + * Return the topmost y-value of a rect * @function * @param {cc.Rect} rect - * @return {Number} + * @return {Number} The topmost y value */ cc.rectGetMaxY = function (rect) { return(rect.y + rect.height); @@ -227,23 +236,24 @@ cc.rectGetMaxY = function (rect) { * Return the midpoint y-value of `rect' * @function * @param {cc.Rect} rect - * @return {Number} + * @return {Number} The midpoint y value */ cc.rectGetMidY = function (rect) { return rect.y + rect.height / 2.0; }; /** - * Return the bottommost y-value of `rect' + * Return the bottommost y-value of a rect * @function * @param {cc.Rect} rect - * @return {Number} + * @return {Number} The bottommost y value */ cc.rectGetMinY = function (rect) { return rect.y; }; /** + * Check whether a rect contains a point * @function * @param {cc.Rect} rect * @param {cc.Point} point @@ -255,6 +265,7 @@ cc.rectContainsPoint = function (rect, point) { }; /** + * Check whether a rect intersect with another * @function * @param {cc.Rect} rectA * @param {cc.Rect} rectB @@ -269,6 +280,7 @@ cc.rectIntersectsRect = function (ra, rb) { }; /** + * Check whether a rect overlaps another * @function * @param {cc.Rect} rectA * @param {cc.Rect} rectB From efe03c033b008c01ab1269de954d49193a517026 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 25 Aug 2014 16:59:28 +0800 Subject: [PATCH 0511/1564] Fixed #5845: Fixed a bug of InputManager, its first touch move event's delta is wrong. --- cocos2d/core/event-manager/CCEventManager.js | 2 ++ cocos2d/core/event-manager/CCTouch.js | 4 ++++ cocos2d/core/platform/CCInputManager.js | 13 ++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 02be6a6c5b..4a268e48b9 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -319,6 +319,8 @@ cc.eventManager = /** @lends cc.eventManager# */{ _sortEventListenersOfSceneGraphPriorityDes : function(l1, l2){ var locNodePriorityMap = cc.eventManager._nodePriorityMap; + if(!l1 || !l2 || !l1._getSceneGraphPriority() || !l2._getSceneGraphPriority()) + debugger; return locNodePriorityMap[l2._getSceneGraphPriority().__instanceId] - locNodePriorityMap[l1._getSceneGraphPriority().__instanceId]; }, diff --git a/cocos2d/core/event-manager/CCTouch.js b/cocos2d/core/event-manager/CCTouch.js index 8e1550462c..d1b0c8a55b 100644 --- a/cocos2d/core/event-manager/CCTouch.js +++ b/cocos2d/core/event-manager/CCTouch.js @@ -122,6 +122,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** + * Gets the id of cc.Touch * @return {Number} */ getID:function () { @@ -129,9 +130,12 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** + * Gets the id of cc.Touch * @return {Number} + * @deprecated */ getId:function () { + cc.log("getId is deprecated. Please use getID instead.") return this._id; }, diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 740a8ac7a2..1b291853cc 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -104,9 +104,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ cc.log(cc._LogInfos.inputManager_handleTouchesBegin, unusedIndex); continue; } - //curTouch = this._touches[unusedIndex] = curTouch; - curTouch = this._touches[unusedIndex] = new cc.Touch(); - curTouch._setPoint(selTouch._point); + //curTouch = this._touches[unusedIndex] = selTouch; + curTouch = this._touches[unusedIndex] = new cc.Touch(selTouch._point.x, selTouch._point.y, selTouch.getID()); curTouch._setPrevPoint(selTouch._prevPoint); locTouchIntDict[touchID] = unusedIndex; handleTouches.push(curTouch); @@ -220,9 +219,9 @@ cc.inputManager = /** @lends cc.inputManager# */{ getPreTouch: function(touch){ var preTouch = null; var locPreTouchPool = this._preTouchPool; - var id = touch.getId(); + var id = touch.getID(); for (var i = locPreTouchPool.length - 1; i >= 0; i--) { - if (locPreTouchPool[i].getId() == id) { + if (locPreTouchPool[i].getID() == id) { preTouch = locPreTouchPool[i]; break; } @@ -235,9 +234,9 @@ cc.inputManager = /** @lends cc.inputManager# */{ setPreTouch: function(touch){ var find = false; var locPreTouchPool = this._preTouchPool; - var id = touch.getId(); + var id = touch.getID(); for (var i = locPreTouchPool.length - 1; i >= 0; i--) { - if (locPreTouchPool[i].getId() == id) { + if (locPreTouchPool[i].getID() == id) { locPreTouchPool[i] = touch; find = true; break; From da04f7f993aa1e715f7e0fd8d5eec9ad7a4182b1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 25 Aug 2014 17:03:03 +0800 Subject: [PATCH 0512/1564] Fixed #5845: Fixed a bug of InputManager, its first touch move event's delta is wrong. --- cocos2d/core/event-manager/CCEventManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 4a268e48b9..45e9ca73d2 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -320,7 +320,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ _sortEventListenersOfSceneGraphPriorityDes : function(l1, l2){ var locNodePriorityMap = cc.eventManager._nodePriorityMap; if(!l1 || !l2 || !l1._getSceneGraphPriority() || !l2._getSceneGraphPriority()) - debugger; + return -1; return locNodePriorityMap[l2._getSceneGraphPriority().__instanceId] - locNodePriorityMap[l1._getSceneGraphPriority().__instanceId]; }, From 2759d185022cb5c3840297b7d747374896235420 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 17:13:37 +0800 Subject: [PATCH 0513/1564] Fixed #5848: Use real texture pixel size in cc.SpriteFrame's initialization --- cocos2d/core/sprites/CCSpriteFrame.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index ac5c0b7a2a..e76c4c9bb0 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -368,10 +368,10 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ _x = rect.x + rect.width; _y = rect.y + rect.height; } - if(_x > texture.width){ + if(_x > texture.getPixelsWide()){ cc.error(cc._LogInfos.RectWidth, texture.url); } - if(_y > texture.height){ + if(_y > texture.getPixelsHigh()){ cc.error(cc._LogInfos.RectHeight, texture.url); } } From f940423ed454abf6ac56c825b0e75b28848dea9c Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 20:00:36 +0800 Subject: [PATCH 0514/1564] Fixed #5850: Move array utils functions together and put into CCMacro.js --- cocos2d/core/CCScheduler.js | 59 --------------- cocos2d/core/event-manager/CCEventManager.js | 12 ---- cocos2d/core/platform/CCMacro.js | 76 +++++++++++++++++++- 3 files changed, 75 insertions(+), 72 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index d68ecbc2e6..ce37a8c566 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -32,65 +32,6 @@ */ cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1; -/** - * Verify Array's Type - * @param {Array} arr - * @param {function} type - * @return {Boolean} - * @function - */ -cc.arrayVerifyType = function (arr, type) { - if (arr && arr.length > 0) { - for (var i = 0; i < arr.length; i++) { - if (!(arr[i] instanceof type)) { - cc.log(cc._LogInfos.arrayVerifyType); - return false; - } - } - } - return true; -}; - -/** - * Searches for the first occurance of object and removes it. If object is not found the function has no effect. - * @function - * @param {Array} arr Source Array - * @param {*} delObj remove object - */ -cc.arrayRemoveObject = function (arr, delObj) { - for (var i = 0, l = arr.length; i < l; i++) { - if (arr[i] == delObj) { - arr.splice(i, 1); - break; - } - } -}; - -/** - * Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. - * @function - * @param {Array} arr Source Array - * @param {Array} minusArr minus Array - */ -cc.arrayRemoveArray = function (arr, minusArr) { - for (var i = 0, l = minusArr.length; i < l; i++) { - cc.arrayRemoveObject(arr, minusArr[i]); - } -}; - -/** - * Inserts some objects at index - * @function - * @param {Array} arr - * @param {Array} addObjs - * @param {Number} index - * @return {Array} - */ -cc.arrayAppendObjectsToIndex = function(arr, addObjs,index){ - arr.splice.apply(arr, [index, 0].concat(addObjs)); - return arr; -}; - //data structures /** * A list double-linked list used for "updates with priority" diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 45e9ca73d2..89b53fe9ff 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -23,18 +23,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * copy an array's item to a new array (its performance is better than Array.slice) - * @param {Array} arr - * @returns {Array} - */ -cc.copyArray = function(arr){ - var i, len = arr.length, arr_clone = new Array(len); - for (i = 0; i < len; i += 1) - arr_clone[i] = arr[i]; - return arr_clone; -}; - cc._EventListenerVector = cc.Class.extend({ _fixedListeners: null, _sceneGraphListeners: null, diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 0931ee61d7..3b5d3d295d 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -710,4 +710,78 @@ cc.SELECTED_TAG = 8802; * @constant * @type Number */ -cc.DISABLE_TAG = 8803; \ No newline at end of file +cc.DISABLE_TAG = 8803; + + +// Array utils + +/** + * Verify Array's Type + * @param {Array} arr + * @param {function} type + * @return {Boolean} + * @function + */ +cc.arrayVerifyType = function (arr, type) { + if (arr && arr.length > 0) { + for (var i = 0; i < arr.length; i++) { + if (!(arr[i] instanceof type)) { + cc.log("element type is wrong!"); + return false; + } + } + } + return true; +}; + +/** + * Searches for the first occurance of object and removes it. If object is not found the function has no effect. + * @function + * @param {Array} arr Source Array + * @param {*} delObj remove object + */ +cc.arrayRemoveObject = function (arr, delObj) { + for (var i = 0, l = arr.length; i < l; i++) { + if (arr[i] == delObj) { + arr.splice(i, 1); + break; + } + } +}; + +/** + * Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. + * @function + * @param {Array} arr Source Array + * @param {Array} minusArr minus Array + */ +cc.arrayRemoveArray = function (arr, minusArr) { + for (var i = 0, l = minusArr.length; i < l; i++) { + cc.arrayRemoveObject(arr, minusArr[i]); + } +}; + +/** + * Inserts some objects at index + * @function + * @param {Array} arr + * @param {Array} addObjs + * @param {Number} index + * @return {Array} + */ +cc.arrayAppendObjectsToIndex = function(arr, addObjs,index){ + arr.splice.apply(arr, [index, 0].concat(addObjs)); + return arr; +}; + +/** + * Copy an array's item to a new array (its performance is better than Array.slice) + * @param {Array} arr + * @returns {Array} + */ +cc.copyArray = function(arr){ + var i, len = arr.length, arr_clone = new Array(len); + for (i = 0; i < len; i += 1) + arr_clone[i] = arr[i]; + return arr_clone; +}; \ No newline at end of file From b3fe52f86bb1965cf176bd30ec066ee48cf80c89 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 20:17:45 +0800 Subject: [PATCH 0515/1564] Doc #5829: Fix issues in event-manager inline docs --- cocos2d/core/base-nodes/CCNode.js | 26 +++++----- cocos2d/core/cocoa/CCAffineTransform.js | 4 +- cocos2d/core/cocoa/CCGeometry.js | 6 +-- cocos2d/core/event-manager/CCEvent.js | 50 +++++++++++++------ .../core/event-manager/CCEventExtension.js | 4 +- cocos2d/core/event-manager/CCEventListener.js | 27 +++++++++- cocos2d/core/event-manager/CCEventManager.js | 6 +-- cocos2d/core/event-manager/CCTouch.js | 31 ++++++------ .../ccui/base-classes/CCProtectedNode.js | 3 +- .../gui/control-extension/CCControlSlider.js | 2 +- 10 files changed, 101 insertions(+), 58 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 74352c2fe8..aa526f3f1c 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -745,7 +745,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns if the node is visible * @function - * @see setVisible(bool) + * @see cc.Node#setVisible * @return {Boolean} true if the node is visible, false if the node is hidden. */ isVisible: function () { @@ -849,7 +849,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns a copy of the anchor point in absolute pixels.
    * you can only read it. If you wish to modify it, use setAnchorPoint - * @see getAnchorPoint() + * @see cc.Node#getAnchorPoint * @function * @return {cc.Point} The anchor point in absolute pixels. */ @@ -948,7 +948,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Returns whether the anchor point will be ignored when you position this node.
    * When anchor point ignored, position will be calculated based on the origin point (0, 0) in parent's coordinates. * @function - * @see ignoreAnchorPointForPosition(bool) + * @see cc.Node#ignoreAnchorPointForPosition * @return {Boolean} true if the anchor point will be ignored when you position this node. */ isIgnoreAnchorPointForPosition: function () { @@ -1006,7 +1006,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Changes the tag that is used to identify the node easily.
    * Please refer to getTag for the sample code. * @function - * @see getTag() + * @see cc.Node#getTag * @param {Number} tag A integer that identifies the node. */ setTag: function (tag) { @@ -1112,7 +1112,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ *

    Returns the CCActionManager object that is used by all actions.
    * (IMPORTANT: If you set a new cc.ActionManager, then previously created actions are going to be removed.)

    * @function - * @see setActionManager() + * @see cc.Node#setActionManager * @return {cc.ActionManager} A CCActionManager object. */ getActionManager: function () { @@ -1310,7 +1310,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * If the node orphan, then nothing happens. * @function * @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise. - * @see removeFromParentAndCleanup(bool) + * @see cc.Node#removeFromParentAndCleanup */ removeFromParent: function (cleanup) { if (this._parent) { @@ -1359,7 +1359,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function * @param {Number} tag An integer number that identifies a child node * @param {Boolean} cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. - * @see removeChildByTag(int, bool) + * @see cc.Node#removeChildByTag */ removeChildByTag: function (tag, cleanup) { if (tag === cc.NODE_TAG_INVALID) @@ -1616,7 +1616,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns an action from the running action list by its tag. * @function - * @see setTag(int), getTag(). + * @see cc.Node#getTag and cc.Node#setTag * @param {Number} tag * @return {cc.Action} The action object with the given tag. */ @@ -1669,7 +1669,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Unschedules the "update" method. * @function - * @see scheduleUpdate(); + * @see cc.Node#scheduleUpdate */ unscheduleUpdate: function () { this.scheduler.unscheduleUpdateForTarget(this); @@ -1700,7 +1700,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Schedules a callback function that runs only once, with a delay of 0 or larger * @function - * @see schedule(function, float, unsigned int, float) + * @see cc.Node#schedule * @param {function} callback_fn A function wrapped as a selector * @param {Number} delay The amount of time that the first tick will wait before execution. */ @@ -1711,7 +1711,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * unschedules a custom callback function. * @function - * @see schedule(function, float, unsigned int, float) + * @see cc.Node#schedule * @param {function} callback_fn A function wrapped as a selector */ unschedule: function (callback_fn) { @@ -2000,7 +2000,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    * retain and release function call should be paired in developer's game code.

    * @function - * @see release() + * @see cc.Node#release */ retain: function () { }, @@ -2015,7 +2015,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    * retain and release function call should be paired in developer's game code.

    * @function - * @see retain() + * @see cc.Node#retain */ release: function () { }, diff --git a/cocos2d/core/cocoa/CCAffineTransform.js b/cocos2d/core/cocoa/CCAffineTransform.js index 4a1d9756dd..8839a8c9b3 100644 --- a/cocos2d/core/cocoa/CCAffineTransform.js +++ b/cocos2d/core/cocoa/CCAffineTransform.js @@ -36,7 +36,7 @@ * @param {Number} d * @param {Number} tx * @param {Number} ty - * @see cc.affineTransformMake() + * @see cc.affineTransformMake */ cc.AffineTransform = function (a, b, c, d, tx, ty) { this.a = a; @@ -112,7 +112,7 @@ cc.affineTransformMakeIdentity = function () { * * @return {cc.AffineTransform} * @deprecated since v3.0, please use cc.affineTransformMakeIdentity() instead - * @see cc.affineTransformMakeIdentity() + * @see cc.affineTransformMakeIdentity */ cc.affineTransformIdentity = function () { return {a: 1.0, b: 0.0, c: 0.0, d: 1.0, tx: 0.0, ty: 0.0}; diff --git a/cocos2d/core/cocoa/CCGeometry.js b/cocos2d/core/cocoa/CCGeometry.js index 3cf6027382..53d4b6bf14 100644 --- a/cocos2d/core/cocoa/CCGeometry.js +++ b/cocos2d/core/cocoa/CCGeometry.js @@ -30,7 +30,7 @@ * @constructor * @param {Number} x * @param {Number} y - * @see cc.p() + * @see cc.p */ cc.Point = function (x, y) { this.x = x || 0; @@ -81,7 +81,7 @@ cc.pointEqualToPoint = function (point1, point2) { * @constructor * @param {Number} width * @param {Number} height - * @see cc.size() + * @see cc.size */ cc.Size = function (width, height) { this.width = width || 0; @@ -132,7 +132,7 @@ cc.sizeEqualToSize = function (size1, size2) { * @constructor * @param {Number} width * @param {Number} height - * @see cc.rect() + * @see cc.rect */ cc.Rect = function (x, y, width, height) { this.x = x||0; diff --git a/cocos2d/core/event-manager/CCEvent.js b/cocos2d/core/event-manager/CCEvent.js index 402a410c86..74ac15c845 100644 --- a/cocos2d/core/event-manager/CCEvent.js +++ b/cocos2d/core/event-manager/CCEvent.js @@ -43,7 +43,8 @@ cc.Event = cc.Class.extend(/** @lends cc.Event# */{ /** * Gets the event type - * @returns {number} + * @function + * @returns {Number} */ getType: function () { return this._type; @@ -51,6 +52,7 @@ cc.Event = cc.Class.extend(/** @lends cc.Event# */{ /** * Stops propagation for current event + * @function */ stopPropagation: function () { this._isStopped = true; @@ -58,6 +60,7 @@ cc.Event = cc.Class.extend(/** @lends cc.Event# */{ /** * Checks whether the event has been stopped + * @function * @returns {boolean} */ isStopped: function () { @@ -70,6 +73,7 @@ cc.Event = cc.Class.extend(/** @lends cc.Event# */{ * note: It only be available when the event listener is associated with node.
    * It returns 0 when the listener is associated with fixed priority. *

    + * @function * @returns {cc.Node} The target with which the event associates. */ getCurrentTarget: function () { @@ -117,6 +121,7 @@ cc.Event.CUSTOM = 4; cc.EventCustom = cc.Event.extend(/** @lends cc.EventCustom# */{ _eventName: null, _userData: null, // User data + ctor: function (eventName) { cc.Event.prototype.ctor.call(this, cc.Event.CUSTOM); this._eventName = eventName; @@ -168,7 +173,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * sets scroll data + * Sets scroll data * @param {number} scrollX * @param {number} scrollY */ @@ -178,7 +183,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * gets scrollX data + * Returns the x axis scroll value * @returns {number} */ getScrollX: function () { @@ -186,7 +191,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * gets scrollY data + * Returns the y axis scroll value * @returns {number} */ getScrollY: function () { @@ -194,7 +199,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * Set cursor location + * Sets cursor location * @param {number} x * @param {number} y */ @@ -204,7 +209,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * Get cursor location + * Returns cursor location * @return {cc.Point} location */ getLocation: function () { @@ -212,7 +217,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * returns the current touch location in screen coordinates + * Returns the current cursor location in screen coordinates * @return {cc.Point} */ getLocationInView: function() { @@ -224,14 +229,26 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ this._prevY = y; }, + /** + * Returns the delta distance from the previous location to current location + * @return {cc.Point} + */ getDelta: function () { return {x: this._x - this._prevX, y: this._y - this._prevY}; }, + /** + * Returns the X axis delta distance from the previous location to current location + * @return {Number} + */ getDeltaX: function () { return this._x - this._prevX; }, + /** + * Returns the Y axis delta distance from the previous location to current location + * @return {Number} + */ getDeltaY: function () { return this._y - this._prevY; }, @@ -245,7 +262,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * Gets mouse button + * Returns mouse button * @returns {number} */ getButton: function () { @@ -253,7 +270,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * gets location X axis data + * Returns location X axis data * @returns {number} */ getLocationX: function () { @@ -261,7 +278,7 @@ cc.EventMouse = cc.Event.extend(/** @lends cc.EventMouse# */{ }, /** - * gets location Y axis data + * Returns location Y axis data * @returns {number} */ getLocationY: function () { @@ -372,7 +389,7 @@ cc.EventTouch = cc.Event.extend(/** @lends cc.EventTouch# */{ }, /** - * Gets event code + * Returns event code * @returns {number} */ getEventCode: function () { @@ -380,7 +397,7 @@ cc.EventTouch = cc.Event.extend(/** @lends cc.EventTouch# */{ }, /** - * Get touches of event + * Returns touches of event * @returns {Array} */ getTouches: function () { @@ -396,10 +413,11 @@ cc.EventTouch = cc.Event.extend(/** @lends cc.EventTouch# */{ } }); -cc.EventTouch.MAX_TOUCHES = 5; - /** - * The event code of Touch event. - * @type {Object} + * The maximum touch numbers + * @constant + * @type {Number} */ +cc.EventTouch.MAX_TOUCHES = 5; + cc.EventTouch.EventCode = {BEGAN: 0, MOVED: 1, ENDED: 2, CANCELLED: 3}; \ No newline at end of file diff --git a/cocos2d/core/event-manager/CCEventExtension.js b/cocos2d/core/event-manager/CCEventExtension.js index f6e27f370a..afa4c81550 100644 --- a/cocos2d/core/event-manager/CCEventExtension.js +++ b/cocos2d/core/event-manager/CCEventExtension.js @@ -44,7 +44,6 @@ cc.EventAcceleration = cc.Event.extend(/** @lends cc.EventAcceleration# */{ cc.EventKeyboard = cc.Event.extend(/** @lends cc.EventKeyboard# */{ _keyCode: 0, _isPressed: false, - ctor: function (keyCode, isPressed) { cc.Event.prototype.ctor.call(this, cc.Event.KEYBOARD); this._keyCode = keyCode; @@ -53,11 +52,10 @@ cc.EventKeyboard = cc.Event.extend(/** @lends cc.EventKeyboard# */{ }); - - //Acceleration cc._EventListenerAcceleration = cc.EventListener.extend({ _onAccelerationEvent: null, + ctor: function (callback) { this._onAccelerationEvent = callback; var selfPointer = this; diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 8de5e58269..2a3f03ba2a 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -194,12 +194,33 @@ cc.EventListener = cc.Class.extend(/** @lends cc.EventListener# */{ }, /** - * Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, + *

    Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. - * This is a hack, and should be removed once JSB fixes the retain/release bug + * This is a hack, and should be removed once JSB fixes the retain/release bug
    + * You will need to retain an object if you created a listener and haven't added it any target node during the same frame.
    + * Otherwise, JSB's native autorelease pool will consider this object a useless one and release it directly,
    + * when you want to use it later, a "Invalid Native Object" error will be raised.
    + * The retain function can increase a reference count for the native object to avoid it being released,
    + * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    + * retain and release function call should be paired in developer's game code.

    + * @function + * @see cc.EventListener#release */ retain:function () { }, + /** + *

    Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, + * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. + * This is a hack, and should be removed once JSB fixes the retain/release bug
    + * You will need to retain an object if you created a listener and haven't added it any target node during the same frame.
    + * Otherwise, JSB's native autorelease pool will consider this object a useless one and release it directly,
    + * when you want to use it later, a "Invalid Native Object" error will be raised.
    + * The retain function can increase a reference count for the native object to avoid it being released,
    + * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    + * retain and release function call should be paired in developer's game code.

    + * @function + * @see cc.EventListener#retain + */ release:function () { } }); @@ -407,6 +428,8 @@ cc._EventListenerTouchAllAtOnce.create = function(){ /** * Create a EventListener object by json object + * @function + * @static * @param {object} argObj a json object * @returns {cc.EventListener} * @example diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 89b53fe9ff..63e1a2de8c 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -90,10 +90,10 @@ cc.__getListenerID = function (event) { /** *

    - * This class manages event listener subscriptions and event dispatching.
    + * cc.eventManager object manages event listener subscriptions and event dispatching.
    *
    - * The EventListener list is managed in such a way that event listeners can be added and removed even
    - * from within an EventListener, while events are being dispatched. + * The EventListener list is managed in such way so that event listeners can be added and removed
    + * while events are being dispatched. *

    * @namespace * @name cc.eventManager diff --git a/cocos2d/core/event-manager/CCTouch.js b/cocos2d/core/event-manager/CCTouch.js index d1b0c8a55b..7f90e45700 100644 --- a/cocos2d/core/event-manager/CCTouch.js +++ b/cocos2d/core/event-manager/CCTouch.js @@ -36,7 +36,10 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ _startPoint:null, /** - * Constructor + * @constructor + * @param {Number} x + * @param {Number} y + * @param {Number} id */ ctor:function (x, y, id) { this._point = cc.p(x || 0, y || 0); @@ -44,7 +47,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * returns the current touch location in OpenGL coordinates + * Returns the current touch location in OpenGL coordinates * @return {cc.Point} */ getLocation:function () { @@ -54,7 +57,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * gets location X axis data + * Returns X axis location value * @returns {number} */ getLocationX: function () { @@ -62,7 +65,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * gets location Y axis data + * Returns Y axis location value * @returns {number} */ getLocationY: function () { @@ -70,7 +73,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * returns the previous touch location in OpenGL coordinates + * Returns the previous touch location in OpenGL coordinates * @return {cc.Point} */ getPreviousLocation:function () { @@ -80,7 +83,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * returns the start touch location in OpenGL coordinates + * Returns the start touch location in OpenGL coordinates * @returns {cc.Point} */ getStartLocation: function() { @@ -90,7 +93,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * returns the delta of 2 current touches locations in screen coordinates + * Returns the delta distance from the previous touche to the current one in screen coordinates * @return {cc.Point} */ getDelta:function () { @@ -98,7 +101,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * returns the current touch location in screen coordinates + * Returns the current touch location in screen coordinates * @return {cc.Point} */ getLocationInView: function() { @@ -106,7 +109,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * returns the previous touch location in screen coordinates + * Returns the previous touch location in screen coordinates * @return {cc.Point} */ getPreviousLocationInView: function(){ @@ -114,7 +117,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * returns the start touch location in screen coordinates + * Returns the start touch location in screen coordinates * @return {cc.Point} */ getStartLocationInView: function(){ @@ -122,7 +125,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * Gets the id of cc.Touch + * Returns the id of cc.Touch * @return {Number} */ getID:function () { @@ -130,9 +133,9 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * Gets the id of cc.Touch + * Returns the id of cc.Touch * @return {Number} - * @deprecated + * @deprecated since v3.0, please use getID() instead */ getId:function () { cc.log("getId is deprecated. Please use getID instead.") @@ -140,7 +143,7 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ }, /** - * set information to touch + * Sets information to touch * @param {Number} id * @param {Number} x * @param {Number} y diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 3096aa2df3..08f5b0e308 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -146,7 +146,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ /** * Removes all children from the container with a cleanup. - * @see `removeAllChildrenWithCleanup(bool)` + * @see cc.ProtectedNode#removeAllProtectedChildrenWithCleanup + * @deprecated since v3.0 please use removeAllProtectedChildrenWithCleanup instead */ removeAllProtectedChildren: function(){ this.removeAllProtectedChildrenWithCleanup(true); diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index 603e6d9325..e280bd556a 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -300,7 +300,7 @@ _p = null; * Creates a slider with a given background sprite and a progress bar and a * thumb item. * @deprecated - * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: + * @see cc.ControlSlider#ctor */ cc.ControlSlider.create = function (bgFile, progressFile, thumbFile) { return new cc.ControlSlider(bgFile, progressFile, thumbFile); From 480b85b935b52e3a60e24167f56be6ccd370b27c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 25 Aug 2014 20:34:16 +0800 Subject: [PATCH 0516/1564] Issue #5829: Actions3D jsdoc --- cocos2d/actions3d/CCActionGrid.js | 64 ++++-- cocos2d/actions3d/CCActionGrid3D.js | 136 ++++++++---- cocos2d/actions3d/CCActionTiledGrid.js | 287 ++++++++++++++++--------- 3 files changed, 331 insertions(+), 156 deletions(-) diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index e8c6fab6ae..7d1513e038 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -46,6 +46,12 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ gridSize && this.initWithDuration(duration, gridSize); }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.Action} + */ clone:function(){ var action = new cc.GridAction(); var locGridSize = this._gridSize; @@ -53,6 +59,11 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ return action; }, + /** + * called before the action start. It will also set the target. + * + * @param {cc.Node} target + */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); var newGrid = this.getGrid(); @@ -70,12 +81,16 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ } }, + /** + * Create a cc.EaseSineOut action. Opposite with the original motion trajectory. + * @return {cc.EaseSineOut} + */ reverse:function () { return cc.ReverseTime.create(this); }, /** - * initializes the action with size and duration + * Initializes the action with size and duration. * @param {Number} duration * @param {cc.Size} gridSize * @return {Boolean} @@ -90,7 +105,7 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ }, /** - * returns the grid + * Returns the grid. * @return {cc.GridBase} */ getGrid:function () { @@ -109,19 +124,20 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ cc.gridAction = function (duration, gridSize) { return new cc.GridAction(duration, gridSize); }; + /** - * Please use cc.gridAction instead - * creates the action with size and duration + * Please use cc.gridAction instead.
    + * Creates the action with size and duration. * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.GridAction} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.gridAction instead. */ cc.GridAction.create = cc.gridAction; /** - * Base class for cc.Grid3D actions.
    + * Base class for cc.Grid3D actions.
    * Grid3D actions can modify a non-tiled grid. * @class * @extends cc.GridAction @@ -130,10 +146,10 @@ cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{ /** * returns the grid - * @return {cc.GridBase} + * @return {cc.Grid3D} */ getGrid:function () { - return cc.Grid3D.create(this._gridSize); + return new cc.Grid3D(this._gridSize); }, /** @@ -148,7 +164,7 @@ cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{ /** * returns the non-transformed vertex than belongs to certain position in the grid * @param {cc.Point} position - * @return {*} + * @return {cc.Vertex3F} */ originalVertex:function (position) { return this.target.grid.originalVertex(position); @@ -175,18 +191,18 @@ cc.grid3DAction = function (duration, gridSize) { return new cc.Grid3DAction(duration, gridSize); }; /** - * Please use cc.grid3DAction instead - * creates the action with size and duration + * Please use cc.grid3DAction instead.
    + * creates the action with size and duration.
    * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.Grid3DAction} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.grid3DAction instead. */ cc.Grid3DAction.create = cc.grid3DAction; /** - * Base class for cc.TiledGrid3D actions + * Base class for cc.TiledGrid3D actions. * @class * @extends cc.GridAction */ @@ -221,10 +237,10 @@ cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{ /** * returns the grid - * @return {cc.GridBase} + * @return {cc.TiledGrid3D} */ getGrid:function () { - return cc.TiledGrid3D.create(this._gridSize); + return new cc.TiledGrid3D(this._gridSize); } }); @@ -238,6 +254,7 @@ cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{ cc.tiledGrid3DAction = function (duration, gridSize) { return new cc.TiledGrid3DAction(duration, gridSize); }; + /** * Please use cc.tiledGrid3DAction instead * Creates the action with duration and grid size @@ -245,7 +262,7 @@ cc.tiledGrid3DAction = function (duration, gridSize) { * @param {cc.Size} gridSize * @return {cc.TiledGrid3DAction} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.tiledGrid3DAction instead. */ cc.TiledGrid3DAction.create = cc.tiledGrid3DAction; @@ -260,6 +277,12 @@ cc.TiledGrid3DAction.create = cc.tiledGrid3DAction; * @extends cc.ActionInstant */ cc.StopGrid = cc.ActionInstant.extend(/** @lends cc.StopGrid# */{ + + /** + * called before the action start. It will also set the target. + * + * @param {cc.Node} target + */ startWithTarget:function (target) { cc.ActionInstant.prototype.startWithTarget.call(this, target); var grid = this.target.grid; @@ -281,7 +304,7 @@ cc.stopGrid = function () { * Allocates and initializes the action * @return {cc.StopGrid} * @static - * @deprecated + * @ deprecated since v3.0
    Please use cc.stopGrid instead. */ cc.StopGrid.create = cc.stopGrid; @@ -313,6 +336,11 @@ cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{ return true; }, + /** + * called before the action start. It will also set the target. + * + * @param {cc.Node} target + */ startWithTarget:function (target) { cc.ActionInstant.prototype.startWithTarget.call(this, target); if (this.target.grid && this.target.grid.isActive()) @@ -335,6 +363,6 @@ cc.reuseGrid = function (times) { * @param {Number} times * @return {cc.ReuseGrid} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.reuseGrid instead. */ cc.ReuseGrid.create = cc.reuseGrid; diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index d5918dbafe..139f378a17 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -25,7 +25,7 @@ ****************************************************************************/ /** - * cc.Waves3D action + * cc.Waves3D action. * @class * @extends cc.Grid3DAction */ @@ -96,7 +96,12 @@ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { var locGridSize = this._gridSize; var locAmplitude = this._amplitude, locPos = cc.p(0, 0); var locAmplitudeRate = this._amplitudeRate, locWaves = this._waves; @@ -105,8 +110,8 @@ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ locPos.x = i; locPos.y = j; var v = this.originalVertex(locPos); - v.z += (Math.sin(Math.PI * time * locWaves * 2 + (v.y + v.x) * 0.01) * locAmplitude * locAmplitudeRate); - //cc.log("v.z offset is" + (Math.sin(Math.PI * time * this._waves * 2 + (v.y + v.x) * 0.01) * this._amplitude * this._amplitudeRate)); + v.z += (Math.sin(Math.PI * dt * locWaves * 2 + (v.y + v.x) * 0.01) * locAmplitude * locAmplitudeRate); + //cc.log("v.z offset is" + (Math.sin(Math.PI * dt * this._waves * 2 + (v.y + v.x) * 0.01) * this._amplitude * this._amplitudeRate)); this.setVertex(locPos, v); } } @@ -114,7 +119,7 @@ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ }); /** - * Create a wave 3d action with duration, grid size, waves and amplitude + * Create a wave 3d action with duration, grid size, waves and amplitude. * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -125,19 +130,20 @@ cc.waves3D = function (duration, gridSize, waves, amplitude) { return new cc.Waves3D(duration, gridSize, waves, amplitude); }; /** - * Please use cc.waves3D instead - * Create a wave 3d action with duration, grid size, waves and amplitude + * Please use cc.waves3D instead.
    + * Create a wave 3d action with duration, grid size, waves and amplitude. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves * @param {Number} amplitude * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.waves3D instead. */ cc.Waves3D.create = cc.waves3D; /** - * cc.FlipX3D action + * cc.FlipX3D action.
    + * Flip around. * @class * @extends cc.Grid3DAction */ @@ -178,8 +184,13 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ return cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize); }, - update:function (time) { - var angle = Math.PI * time; // 180 degrees + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { + var angle = Math.PI * dt; // 180 degrees var mz = Math.sin(angle); angle = angle / 2.0; // x calculates degrees from 0 to 90 var mx = Math.cos(angle); @@ -242,7 +253,8 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ }); /** - * Create a Flip X 3D action with duration + * Create a Flip X 3D action with duration.
    + * Flip around. * @function * @param {Number} duration * @return {cc.FlipX3D} @@ -250,18 +262,21 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ cc.flipX3D = function (duration) { return new cc.FlipX3D(duration); }; + /** - * Please use cc.flipX3D instead - * Create a Flip X 3D action with duration + * Please use cc.flipX3D instead.
    + * Create a Flip X 3D action with duration.
    + * Flip around. * @param {Number} duration * @return {cc.FlipX3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.flipX3D instead. */ cc.FlipX3D.create = cc.flipX3D; /** - * cc.FlipY3D action + * cc.FlipY3D action.
    + * Upside down. * @class * @extends cc.FlipX3D */ @@ -278,8 +293,13 @@ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ else cc.GridAction.prototype.ctor.call(this); }, - update:function (time) { - var angle = Math.PI * time; // 180 degrees + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { + var angle = Math.PI * dt; // 180 degrees var mz = Math.sin(angle); angle = angle / 2.0; // x calculates degrees from 0 to 90 var my = Math.cos(angle); @@ -343,7 +363,8 @@ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ }); /** - * Create a flip Y 3d action with duration + * Create a flip Y 3d action with duration.
    + * Upside down. * @function * @param {Number} duration * @return {cc.FlipY3D} @@ -351,28 +372,30 @@ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ cc.flipY3D = function (duration) { return new cc.FlipY3D(duration); }; + /** - * Please use cc.flipY3D instead - * Create a flip Y 3d action with duration + * Please use cc.flipY3D instead.
    + * Create a flip Y 3d action with duration. * @param {Number} duration * @return {cc.FlipY3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.flipY3D instead. */ cc.FlipY3D.create = cc.flipY3D; /** - * cc.Lens3D action + * cc.Lens3D action.
    + * Upside down. * @class * @extends cc.FlipX3D */ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ - /* lens center position */ + //lens center position _position:null, _radius:0, - /** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */ + //lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect _lensEffect:0, - /** lens is concave. (true = concave, false = convex) default is convex i.e. false */ + //lens is concave. (true = concave, false = convex) default is convex i.e. false _concave:false, _dirty:false, @@ -454,7 +477,12 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { if (this._dirty) { var locGridSizeWidth = this._gridSize.width, locGridSizeHeight = this._gridSize.height; var locRadius = this._radius, locLensEffect = this._lensEffect; @@ -509,6 +537,7 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ cc.lens3D = function (duration, gridSize, position, radius) { return new cc.Lens3D(duration, gridSize, position, radius); }; + /** * Please use cc.lens3D instead * creates a lens 3d action with center position, radius @@ -518,7 +547,7 @@ cc.lens3D = function (duration, gridSize, position, radius) { * @param {Number} radius * @return {cc.Lens3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.lens3D instead. */ cc.Lens3D.create = cc.lens3D; @@ -623,7 +652,12 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { var locGridSizeWidth = this._gridSize.width, locGridSizeHeight = this._gridSize.height; var locPos = cc.p(0, 0), locRadius = this._radius; var locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate; @@ -641,13 +675,14 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ if (r < locRadius) { r = locRadius - r; var rate = Math.pow(r / locRadius, 2); - v.z += (Math.sin(time * Math.PI * locWaves * 2 + r * 0.1) * locAmplitude * locAmplitudeRate * rate); + v.z += (Math.sin(dt * Math.PI * locWaves * 2 + r * 0.1) * locAmplitude * locAmplitudeRate * rate); } this.setVertex(locPos, v); } } } }); + /** * creates a ripple 3d action with radius, number of waves, amplitude * @function @@ -662,6 +697,7 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ cc.ripple3D = function (duration, gridSize, position, radius, waves, amplitude) { return new cc.Ripple3D(duration, gridSize, position, radius, waves, amplitude); }; + /** * Please use cc.ripple3D instead * creates a ripple 3d action with radius, number of waves, amplitude @@ -673,7 +709,7 @@ cc.ripple3D = function (duration, gridSize, position, radius, waves, amplitude) * @param {Number} amplitude * @return {cc.Ripple3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.ripple3D instead. */ cc.Ripple3D.create = cc.ripple3D; @@ -716,7 +752,12 @@ cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { var locGridSizeWidth = this._gridSize.width, locGridSizeHeight = this._gridSize.height; var locRandRange = this._randRange, locShakeZ = this._shakeZ, locP = cc.p(0, 0); var v; @@ -747,6 +788,7 @@ cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{ cc.shaky3D = function (duration, gridSize, range, shakeZ) { return new cc.Shaky3D(duration, gridSize, range, shakeZ); }; + /** * Please use cc.shaky3D instead * creates the action with a range, shake Z vertices, a grid and duration @@ -756,7 +798,7 @@ cc.shaky3D = function (duration, gridSize, range, shakeZ) { * @param {Boolean} shakeZ * @return {cc.Shaky3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.shaky3D instead. */ cc.Shaky3D.create = cc.shaky3D; @@ -833,7 +875,12 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { var locSizeWidth = this._gridSize.width, locSizeHeight = this._gridSize.height, locPos = cc.p(0, 0); var locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate; var v; @@ -862,6 +909,7 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ cc.liquid = function (duration, gridSize, waves, amplitude) { return new cc.Liquid(duration, gridSize, waves, amplitude); }; + /** * Please use cc.liquid instead * creates the action with amplitude, a grid and duration @@ -871,7 +919,7 @@ cc.liquid = function (duration, gridSize, waves, amplitude) { * @param {Number} amplitude * @return {cc.Liquid} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.liquid instead. */ cc.Liquid.create = cc.liquid; @@ -956,7 +1004,12 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { var locSizeWidth = this._gridSize.width, locSizeHeight = this._gridSize.height, locPos = cc.p(0, 0); var locVertical = this._vertical, locHorizontal = this._horizontal; var locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate; @@ -1002,7 +1055,7 @@ cc.waves = function (duration, gridSize, waves, amplitude, horizontal, vertical) * @param {Boolean} vertical * @return {cc.Waves} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.waves instead. */ cc.Waves.create = cc.waves; @@ -1096,7 +1149,12 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * + * @param {Number} dt + */ + update:function (dt) { var c = this._position; var locSizeWidth = this._gridSize.width, locSizeHeight = this._gridSize.height, locPos = cc.p(0, 0); var amp = 0.1 * this._amplitude * this._amplitudeRate; @@ -1149,6 +1207,6 @@ cc.twirl = function (duration, gridSize, position, twirls, amplitude) { * @param {Number} amplitude * @return {cc.Twirl} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.twirl instead. */ cc.Twirl.create = cc.twirl; \ No newline at end of file diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index a44869a9b7..7c187b19d7 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -25,7 +25,8 @@ ****************************************************************************/ /** - * cc.ShakyTiles3D action + * cc.ShakyTiles3D action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -34,7 +35,7 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ _shakeZ:false, /** - * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration + * Creates the action with a range, whether or not to shake Z vertices, a grid size, and duration.
    * Constructor of cc.ShakyTiles3D * @param {Number} duration * @param {cc.Size} gridSize @@ -47,7 +48,7 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ }, /** - * initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration + * Initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -63,7 +64,11 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval.
    + * @param {Number} dt + */ + update:function (dt) { var locGridSize = this._gridSize, locRandRange = this._randRange; var locPos = cc.p(0, 0); for (var i = 0; i < locGridSize.width; ++i) { @@ -98,7 +103,8 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ }); /** - * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration + * Creates the action with a range, whether or not to shake Z vertices, a grid size, and duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -109,21 +115,24 @@ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ cc.shakyTiles3D = function (duration, gridSize, range, shakeZ) { return new cc.ShakyTiles3D(duration, gridSize, range, shakeZ); }; + /** - * Please use cc.shakyTiles3D instead - * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration + * Please use cc.shakyTiles3D instead.
    + * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range * @param {Boolean} shakeZ * @return {cc.ShakyTiles3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.shakyTiles3D instead. */ cc.ShakyTiles3D.create = cc.shakyTiles3D; /** - * cc.ShatteredTiles3D action + * cc.ShatteredTiles3D action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -133,7 +142,7 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D _shatterZ:false, /** - * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration + * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration.
    * Constructor of cc.ShatteredTiles3D * @param {Number} duration * @param {cc.Size} gridSize @@ -146,7 +155,7 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D }, /** - * initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration + * Initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration.
    * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -163,7 +172,11 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval.
    + * @param {Number} dt + */ + update:function (dt) { if (this._once === false) { var locGridSize = this._gridSize, locRandRange = this._randRange; var coords, locPos = cc.p(0, 0); @@ -200,7 +213,8 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D }); /** - * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration + * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -211,21 +225,23 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D cc.shatteredTiles3D = function (duration, gridSize, range, shatterZ) { return new cc.ShatteredTiles3D(duration, gridSize, range, shatterZ); }; + /** - * Please use cc.shatteredTiles3D instead - * creates the action with a range, whether of not to shatter Z vertices, a grid size and duration + * Please use cc.shatteredTiles3D instead.
    + * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range * @param {Boolean} shatterZ * @return {cc.ShatteredTiles3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.shatteredTiles3D instead. */ cc.ShatteredTiles3D.create = cc.shatteredTiles3D; /** - * A Tile composed of position, startPosition and delta + * A Tile composed of position, startPosition and delta. * @Class * @constructor * @param {cc.Point} [position=cc.p(0,0)] @@ -239,7 +255,8 @@ cc.Tile = function (position, startPosition, delta) { }; /** - * cc.ShuffleTiles action, Shuffle the tiles in random order + * cc.ShuffleTiles action, Shuffle the tiles in random order.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -250,7 +267,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ _tiles:null, /** - * creates the action with a random seed, the grid size and the duration + * Creates the action with a random seed, the grid size and the duration.
    * Constructor of cc.ShuffleTiles * @param {Number} duration * @param {cc.Size} gridSize @@ -265,7 +282,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ }, /** - * initializes the action with a random seed, the grid size and the duration + * Initializes the action with a random seed, the grid size and the duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} seed @@ -282,7 +299,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ }, /** - * shuffle + * Shuffle * @param {Array} array * @param {Number} len */ @@ -296,7 +313,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ }, /** - * get Delta + * Get Delta * @param {cc.Size} pos */ getDelta:function (pos) { @@ -307,7 +324,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ }, /** - * place Tile + * Place Tile * @param {cc.Point} pos * @param {cc.Tile} tile */ @@ -332,7 +349,7 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ }, /** - * start with target + * Start with target * @param {cc.Node} target */ startWithTarget:function (target) { @@ -367,7 +384,11 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ } }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt + */ + update:function (dt) { var tileIndex = 0, locGridSize = this._gridSize, locTiles = this._tiles; var selTile, locPos = cc.p(0, 0); for (var i = 0; i < locGridSize.width; ++i) { @@ -375,8 +396,8 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ locPos.x = i; locPos.y = j; selTile = locTiles[tileIndex]; - selTile.position.x = selTile.delta.width * time; - selTile.position.y = selTile.delta.height * time; + selTile.position.x = selTile.delta.width * dt; + selTile.position.y = selTile.delta.height * dt; this.placeTile(locPos, selTile); ++tileIndex; } @@ -385,7 +406,8 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ }); /** - * creates the action with a random seed, the grid size and the duration + * Creates the action with a random seed, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -395,25 +417,29 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ cc.shuffleTiles = function (duration, gridSize, seed) { return new cc.ShuffleTiles(duration, gridSize, seed); }; + /** - * Please use cc.shuffleTiles instead - * creates the action with a random seed, the grid size and the duration + * Please use cc.shuffleTiles instead.
    + * Creates the action with a random seed, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} seed * @return {cc.ShuffleTiles} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.shuffleTiles instead. */ cc.ShuffleTiles.create = cc.shuffleTiles; /** - * cc.FadeOutTRTiles action. Fades out the tiles in a Top-Right direction + * cc.FadeOutTRTiles action. Fades out the tiles in a Top-Right direction.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */{ /** + * Test function * @param {cc.Size} pos * @param {Number} time */ @@ -426,7 +452,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ }, /** - * turn on Tile + * Turn on Tile * @param {cc.Point} pos */ turnOnTile:function (pos) { @@ -434,7 +460,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ }, /** - * turn Off Tile + * Turn Off Tile * @param {cc.Point} pos */ turnOffTile:function (pos) { @@ -442,7 +468,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ }, /** - * transform tile + * Transform tile * @param {cc.Point} pos * @param {Number} distance */ @@ -465,7 +491,11 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ this.setTile(pos, coords); }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt + */ + update:function (dt) { var locGridSize = this._gridSize; var locPos = cc.p(0, 0), locSize = cc.size(0, 0), distance; for (var i = 0; i < locGridSize.width; ++i) { @@ -474,7 +504,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ locPos.y = j; locSize.width = i; locSize.height = j; - distance = this.testFunc(locSize, time); + distance = this.testFunc(locSize, dt); if (distance == 0) this.turnOffTile(locPos); else if (distance < 1) @@ -487,7 +517,8 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ }); /** - * creates the action with the grid size and the duration + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param duration * @param gridSize @@ -496,24 +527,28 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ cc.fadeOutTRTiles = function (duration, gridSize) { return new cc.FadeOutTRTiles(duration, gridSize); }; + /** - * Please use cc.fadeOutTRTiles instead - * creates the action with the grid size and the duration + * Please use cc.fadeOutTRTiles instead.
    + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param duration * @param gridSize * @return {cc.FadeOutTRTiles} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.fadeOutTRTiles instead. */ cc.FadeOutTRTiles.create = cc.fadeOutTRTiles; /** - * cc.FadeOutBLTiles action. Fades out the tiles in a Bottom-Left direction + * cc.FadeOutBLTiles action. Fades out the tiles in a Bottom-Left direction.
    + * Reference the test cases (Effects Test) * @class * @extends cc.FadeOutTRTiles */ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{ /** + * Test function * @param {cc.Size} pos * @param {Number} time */ @@ -528,7 +563,8 @@ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{ }); /** - * creates the action with the grid size and the duration + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param duration * @param gridSize @@ -537,19 +573,22 @@ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{ cc.fadeOutBLTiles = function (duration, gridSize) { return new cc.FadeOutBLTiles(duration, gridSize); }; + /** - * Please use cc.fadeOutBLTiles instead - * creates the action with the grid size and the duration + * Please use cc.fadeOutBLTiles instead.
    + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param duration * @param gridSize * @return {cc.FadeOutBLTiles} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.fadeOutBLTiles instead. */ cc.FadeOutBLTiles.create = cc.fadeOutBLTiles; /** - * cc.FadeOutUpTiles action. Fades out the tiles in upwards direction + * cc.FadeOutUpTiles action. Fades out the tiles in upwards direction.
    + * Reference the test cases (Effects Test) * @class * @extends cc.FadeOutTRTiles */ @@ -575,7 +614,8 @@ cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{ }); /** - * creates the action with the grid size and the duration + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -584,19 +624,22 @@ cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{ cc.fadeOutUpTiles = function (duration, gridSize) { return new cc.FadeOutUpTiles(duration, gridSize); }; + /** - * Please use cc.fadeOutUpTiles instead - * creates the action with the grid size and the duration + * Please use cc.fadeOutUpTiles instead.
    + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutUpTiles} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.fadeOutUpTiles instead. */ cc.FadeOutUpTiles.create = cc.fadeOutUpTiles; /** - * cc.FadeOutDownTiles action. Fades out the tiles in downwards direction + * cc.FadeOutDownTiles action. Fades out the tiles in downwards direction.
    + * Reference the test cases (Effects Test) * @class * @extends cc.FadeOutUpTiles */ @@ -610,7 +653,8 @@ cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend(/** @lends cc.FadeOutDownTiles# * }); /** - * creates the action with the grid size and the duration + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -620,20 +664,21 @@ cc.fadeOutDownTiles = function (duration, gridSize) { return new cc.FadeOutDownTiles(duration, gridSize); }; /** - * Please use cc.fadeOutDownTiles instead - * creates the action with the grid size and the duration + * Please use cc.fadeOutDownTiles instead.
    + * Creates the action with the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @return {cc.FadeOutDownTiles} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.fadeOutDownTiles instead. */ cc.FadeOutDownTiles.create = cc.fadeOutDownTiles; - /** * cc.TurnOffTiles action.
    - * Turn off the files in random order + * Turn off the files in random order.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -643,7 +688,7 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ _tilesOrder:null, /** - * creates the action with a random seed, the grid size and the duration + * Creates the action with a random seed, the grid size and the duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number|Null} [seed=0] @@ -661,7 +706,8 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ gridSize !== undefined && this.initWithDuration(duration, gridSize, seed); }, - /** initializes the action with a random seed, the grid size and the duration + /** + * Initializes the action with a random seed, the grid size and the duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number|Null} [seed=0] @@ -677,6 +723,7 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ }, /** + * Shuffle * @param {Array} array * @param {Number} len */ @@ -690,6 +737,7 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ }, /** + * Turn on tile. * @param {cc.Point} pos */ turnOnTile:function (pos) { @@ -697,6 +745,7 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ }, /** + * Turn off title. * @param {cc.Point} pos */ turnOffTile:function (pos) { @@ -704,6 +753,7 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ }, /** + * called before the action start. It will also set the target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -718,10 +768,11 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ }, /** - * @param {Number} time + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt */ - update:function (time) { - var l = 0 | (time * this._tilesCount), locGridSize = this._gridSize; + update:function (dt) { + var l = 0 | (dt * this._tilesCount), locGridSize = this._gridSize; var t,tilePos = cc.p(0,0), locTilesOrder = this._tilesOrder; for (var i = 0; i < this._tilesCount; i++) { t = locTilesOrder[i]; @@ -736,7 +787,8 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ }); /** - * creates the action with a random seed, the grid size and the duration + * Creates the action with a random seed, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -754,19 +806,21 @@ cc.turnOffTiles = function (duration, gridSize, seed) { return new cc.TurnOffTiles(duration, gridSize, seed); }; /** - * Please use cc.turnOffTiles instead - * creates the action with a random seed, the grid size and the duration + * Please use cc.turnOffTiles instead.
    + * Creates the action with a random seed, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @param {Number|Null} [seed=0] * @return {cc.TurnOffTiles} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.turnOffTiles instead. */ cc.TurnOffTiles.create = cc.turnOffTiles; /** - * cc.WavesTiles3D action. + * cc.WavesTiles3D action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -838,7 +892,11 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ return false; }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt + */ + update:function (dt) { var locGridSize = this._gridSize, locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate; var locPos = cc.p(0, 0), coords; for (var i = 0; i < locGridSize.width; i++) { @@ -846,7 +904,7 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ locPos.x = i; locPos.y = j; coords = this.originalTile(locPos); - coords.bl.z = (Math.sin(time * Math.PI * locWaves * 2 + + coords.bl.z = (Math.sin(dt * Math.PI * locWaves * 2 + (coords.bl.y + coords.bl.x) * 0.01) * locAmplitude * locAmplitudeRate); coords.br.z = coords.bl.z; coords.tl.z = coords.bl.z; @@ -858,7 +916,8 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ }); /** - * creates the action with a number of waves, the waves amplitude, the grid size and the duration + * creates the action with a number of waves, the waves amplitude, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -871,19 +930,21 @@ cc.wavesTiles3D = function (duration, gridSize, waves, amplitude) { }; /** * Please use cc.wavesTiles3D instead - * creates the action with a number of waves, the waves amplitude, the grid size and the duration + * creates the action with a number of waves, the waves amplitude, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves * @param {Number} amplitude * @return {cc.WavesTiles3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.wavesTiles3D instead. */ cc.WavesTiles3D.create = cc.wavesTiles3D; /** - * cc.JumpTiles3D action. A sin function is executed to move the tiles across the Z axis + * cc.JumpTiles3D action. A sin function is executed to move the tiles across the Z axis.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -954,9 +1015,13 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ return false; }, - update:function (time) { - var sinz = (Math.sin(Math.PI * time * this._jumps * 2) * this._amplitude * this._amplitudeRate ); - var sinz2 = (Math.sin(Math.PI * (time * this._jumps * 2 + 1)) * this._amplitude * this._amplitudeRate ); + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt + */ + update:function (dt) { + var sinz = (Math.sin(Math.PI * dt * this._jumps * 2) * this._amplitude * this._amplitudeRate ); + var sinz2 = (Math.sin(Math.PI * (dt * this._jumps * 2 + 1)) * this._amplitude * this._amplitudeRate ); var locGridSize = this._gridSize; var locGrid = this.target.grid; @@ -989,7 +1054,8 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ }); /** - * creates the action with the number of jumps, the sin amplitude, the grid size and the duration + * creates the action with the number of jumps, the sin amplitude, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {cc.Size} gridSize @@ -1000,21 +1066,24 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ cc.jumpTiles3D = function (duration, gridSize, numberOfJumps, amplitude) { return new cc.JumpTiles3D(duration, gridSize, numberOfJumps, amplitude); }; + /** * Please use cc.jumpTiles3D instead - * creates the action with the number of jumps, the sin amplitude, the grid size and the duration + * creates the action with the number of jumps, the sin amplitude, the grid size and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} numberOfJumps * @param {Number} amplitude * @return {cc.JumpTiles3D} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.jumpTiles3D instead. */ cc.JumpTiles3D.create = cc.jumpTiles3D; /** - * cc.SplitRows action + * cc.SplitRows action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -1044,7 +1113,11 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, cc.size(1, rows)); }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt + */ + update:function (dt) { var locGridSize = this._gridSize, locWinSizeWidth = this._winSize.width; var coords, direction, locPos = cc.p(0, 0); for (var j = 0; j < locGridSize.height; ++j) { @@ -1055,15 +1128,19 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ if ((j % 2 ) == 0) direction = -1; - coords.bl.x += direction * locWinSizeWidth * time; - coords.br.x += direction * locWinSizeWidth * time; - coords.tl.x += direction * locWinSizeWidth * time; - coords.tr.x += direction * locWinSizeWidth * time; + coords.bl.x += direction * locWinSizeWidth * dt; + coords.br.x += direction * locWinSizeWidth * dt; + coords.tl.x += direction * locWinSizeWidth * dt; + coords.tr.x += direction * locWinSizeWidth * dt; this.setTile(locPos, coords); } }, + /** + * called before the action start. It will also set the target. + * @param {cc.Node} target + */ startWithTarget:function (target) { cc.TiledGrid3DAction.prototype.startWithTarget.call(this, target); this._winSize = cc.director.getWinSizeInPixels(); @@ -1071,7 +1148,8 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ }); /** - * creates the action with the number of rows to split and the duration + * creates the action with the number of rows to split and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {Number} rows @@ -1080,19 +1158,22 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ cc.splitRows = function (duration, rows) { return new cc.SplitRows(duration, rows); }; + /** * Please use cc.splitRows instead - * creates the action with the number of rows to split and the duration + * creates the action with the number of rows to split and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {Number} rows * @return {cc.SplitRows} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.splitRows instead. */ cc.SplitRows.create = cc.splitRows; /** - * cc.SplitCols action + * cc.SplitCols action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction */ @@ -1121,7 +1202,11 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, cc.size(cols, 1)); }, - update:function (time) { + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @param {Number} dt + */ + update:function (dt) { var locGridSizeWidth = this._gridSize.width, locWinSizeHeight = this._winSize.height; var coords, direction, locPos = cc.p(0, 0); for (var i = 0; i < locGridSizeWidth; ++i) { @@ -1132,16 +1217,17 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ if ((i % 2 ) == 0) direction = -1; - coords.bl.y += direction * locWinSizeHeight * time; - coords.br.y += direction * locWinSizeHeight * time; - coords.tl.y += direction * locWinSizeHeight * time; - coords.tr.y += direction * locWinSizeHeight * time; + coords.bl.y += direction * locWinSizeHeight * dt; + coords.br.y += direction * locWinSizeHeight * dt; + coords.tl.y += direction * locWinSizeHeight * dt; + coords.tr.y += direction * locWinSizeHeight * dt; this.setTile(locPos, coords); } }, /** + * called before the action start. It will also set the target. * @param {cc.Node} target */ startWithTarget:function (target) { @@ -1151,7 +1237,8 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ }); /** - * creates the action with the number of columns to split and the duration + * creates the action with the number of columns to split and the duration.
    + * Reference the test cases (Effects Test) * @function * @param {Number} duration * @param {Number} cols @@ -1160,13 +1247,15 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ cc.splitCols = function (duration, cols) { return new cc.SplitCols(duration, cols); }; + /** - * Please use cc.splitCols instead - * creates the action with the number of columns to split and the duration + * Please use cc.splitCols instead. + * creates the action with the number of columns to split and the duration.
    + * Reference the test cases (Effects Test) * @param {Number} duration * @param {Number} cols * @return {cc.SplitCols} * @static - * @deprecated + * @deprecated since v3.0
    Please use cc.splitCols instead. */ cc.SplitCols.create = cc.splitCols; \ No newline at end of file From 4c63f6f607a0f358d4f1c077bb2e2e617276c4ba Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 25 Aug 2014 20:57:26 +0800 Subject: [PATCH 0517/1564] Issue #5829: Audio jsdoc --- cocos2d/audio/CCAudio.js | 172 ++++++++++++++++++++++++++++++++++----- 1 file changed, 151 insertions(+), 21 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 709329a5d1..a3c5563953 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -57,6 +57,10 @@ if (cc.sys._supportWebAudio) { _loadState: -1,//-1 : not loaded, 0 : waiting, 1 : loaded, -2 : load failed + /** + * creates an WebAudio with the src. + * @param src + */ ctor: function (src) { var self = this; self._events = {}; @@ -123,6 +127,7 @@ if (cc.sys._supportWebAudio) { } self._pauseTime = 0; }, + _stop: function () { var self = this, sourceNode = self._sourceNode; if (self._stopped) @@ -133,6 +138,10 @@ if (cc.sys._supportWebAudio) { sourceNode.noteOff(0); self._stopped = true; }, + + /** + * Play the audio. + */ play: function () { var self = this; if (self._loadState == -1) { @@ -148,11 +157,19 @@ if (cc.sys._supportWebAudio) { self.startTime = _ctx.currentTime; this._play(0); }, + + /** + * Pause the audio. + */ pause: function () { this._pauseTime = _ctx.currentTime; this._paused = true; this._stop(); }, + + /** + * Resume the pause audio. + */ resume: function () { var self = this; if (self._paused) { @@ -160,11 +177,19 @@ if (cc.sys._supportWebAudio) { this._play(offset); } }, + + /** + * Stop the play audio. + */ stop: function () { this._pauseTime = 0; this._paused = false; this._stop(); }, + + /** + * Load this audio. + */ load: function () { var self = this; if (self._loadState == 1) @@ -184,16 +209,31 @@ if (cc.sys._supportWebAudio) { request.send(); }, + /** + * Bind event to the audio element. + * @param {String} eventName + * @param {Function} event + */ addEventListener: function (eventName, event) { this._events[eventName] = event.bind(this); }, + + /** + * Remove event of audio element. + * @param {String} eventName + */ removeEventListener: function (eventName) { delete this._events[eventName]; }, + /** + * Checking webaudio support. + * @returns {Boolean} + */ canplay: function () { return cc.sys._supportWebAudio; }, + _onSuccess: function (buffer) { var self = this; self._buffer = buffer; @@ -207,12 +247,19 @@ if (cc.sys._supportWebAudio) { self._play(); self._loadState = 1;//loaded }, + _onError: function () { var error = this._events["error"]; if (error) error(); this._loadState = -2;//load failed }, + + /** + * to copy object with deep copy. + * + * @return {cc.WebAudio} + */ cloneNode: function () { var self = this, obj = new cc.WebAudio(self.src); obj.volume = self.volume; @@ -290,6 +337,9 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ _playings: [],//only store when window is hidden + /** + * creates an audio. + */ ctor: function () { var self = this; self._soundSupported = cc._audioLoader._supportedAudioTypes.length > 0; @@ -349,6 +399,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ self._currMusic.loop = loop || false; self._playMusic(self._currMusic); }, + _getAudioByUrl: function (url) { var locLoader = cc.loader, audio = locLoader.getRes(url); if (!audio) { @@ -357,6 +408,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ } return audio; }, + _playMusic: function (audio) { if (!audio.ended) { if (audio.stop) {//cc.WebAudio @@ -370,6 +422,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ this._musicPlayState = 2; audio.play(); }, + /** * Stop playing music. * @param {Boolean} releaseData If release the music data or not.As default value is false. @@ -431,6 +484,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ this._musicPlayState = 2; } }, + _resumeAudio: function (audio) { if (audio && !audio.ended) { if (audio.resume) @@ -474,6 +528,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ this._currMusic.volume = Math.min(Math.max(volume, 0), 1); } }, + /** * Whether the music is playing. * @return {Boolean} If is playing return true,or return false. @@ -498,6 +553,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ list = this._audioPool[url] = []; return list; }, + _getEffect: function (url) { var self = this, audio; if (!self._soundSupported) return null; @@ -524,6 +580,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ } return audio; }, + _getEffectAudio: function(effList, url){ var audio; if (effList.length >= this._maxAudioInstance) { @@ -539,6 +596,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ audio.volume = this._effectsVolume; return audio; }, + /** * Play sound effect. * @param {String} url The path of the sound effect with filename extension. @@ -699,6 +757,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ self._currMusic.pause(); } }, + /** * Called only when the hidden event of window occurs. * @private @@ -734,6 +793,12 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { this._super(audio); }, + /** + * Resume playing music. + * @example + * //example + * cc.audioEngine.resumeMusic(); + */ resumeMusic: function () { var self = this; if (self._musicPlayState == 1) { @@ -744,6 +809,15 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } }, + /** + * Play sound effect. + * @param {String} url The path of the sound effect with filename extension. + * @param {Boolean} loop Whether to loop the effect playing, default value is false + * @return {Number|null} the audio id + * @example + * //example + * var soundId = cc.audioEngine.playEffect(path); + */ playEffect: function (url, loop) { var self = this, currEffect = self._currEffect; var audio = loop ? self._getEffect(url) : self._getSingleEffect(url); @@ -767,9 +841,24 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } return audioId; }, + + /** + * Pause playing sound effect. + * @param {Number} audioID The return value of function playEffect. + * @example + * //example + * cc.audioEngine.pauseEffect(audioID); + */ pauseEffect: function (effectId) { cc.log("pauseEffect not supported in single audio mode!"); }, + + /** + * Pause all playing sound effect. + * @example + * //example + * cc.audioEngine.pauseAllEffects(); + */ pauseAllEffects: function () { var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds, currEffect = self._currEffect; if (!currEffect) return; @@ -780,9 +869,24 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { pauseds.push(self._currEffectId); currEffect.pause(); }, + + /** + * Resume playing sound effect. + * @param {Number} effectId The return value of function playEffect. + * @audioID + * //example + * cc.audioEngine.resumeEffect(audioID); + */ resumeEffect: function (effectId) { cc.log("resumeEffect not supported in single audio mode!"); }, + + /** + * Resume all playing sound effect + * @example + * //example + * cc.audioEngine.resumeAllEffects(); + */ resumeAllEffects: function () { var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; @@ -805,6 +909,14 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } } }, + + /** + * Stop playing sound effect. + * @param {Number} effectId The return value of function playEffect. + * @example + * //example + * cc.audioEngine.stopEffect(audioID); + */ stopEffect: function (effectId) { var self = this, currEffect = self._currEffect, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; if (currEffect && this._currEffectId == effectId) {//if the eff to be stopped is currEff @@ -819,6 +931,13 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } } }, + + /** + * Stop all playing sound effects. + * @example + * //example + * cc.audioEngine.stopAllEffects(); + */ stopAllEffects: function () { var self = this; self._stopAllEffects(); @@ -830,6 +949,13 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } }, + /** + * Unload the preloaded effect from internal buffer + * @param {String} url + * @example + * //example + * cc.audioEngine.unloadEffect(EFFECT_FILE); + */ unloadEffect: function (url) { var self = this, locLoader = cc.loader, locEffects = self._effects, effCache = self._effectCache4Single, effectList = self._getEffectList(url), currEffect = self._currEffect; @@ -846,12 +972,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { if (currEffect && currEffect.src == realUrl) self._stopAudio(currEffect);//need to stop currEff }, - /** - * When `loop == false`, one url one audio. - * @param url - * @returns {*} - * @private - */ + //When `loop == false`, one url one audio. _getSingleEffect: function (url) { var self = this, audio = self._effectCache4Single[url], locLoader = cc.loader, waitings = self._waitingEffIds, pauseds = self._pausedEffIds, effects = self._effects; @@ -882,6 +1003,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { audio._isToPlay = true;//custom flag return audio; }, + _stopAllEffects: function () { var self = this, currEffect = self._currEffect, audioPool = self._audioPool, sglCache = self._effectCache4Single, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; @@ -905,6 +1027,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } if (currEffect) self._stopAudio(currEffect); }, + _effectPauseCb: function () { var self = this; if (self._isHiddenMode) return;//in this mode, return @@ -928,6 +1051,7 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { self._needToResumeMusic = false; } }, + _getWaitingEffToPlay: function () { var self = this, waitings = self._waitingEffIds, effects = self._effects, currEffect = self._currEffect; @@ -989,24 +1113,18 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { */ cc._audioLoader = { _supportedAudioTypes: null, + + /** + * Get audio default path. + * @returns {cc.loader.audioPath|*} + */ getBasePath: function () { return cc.loader.audioPath; }, - /** - *

    - * pre-load the audio.
    - * note: If the preload audio type doesn't be supported on current platform, loader will use other audio format to try, but its key is still the origin audio format.
    - * for example: a.mp3 doesn't be supported on some browser, loader will load a.ogg, if a.ogg loads success, user still uses a.mp3 to play audio. - *

    - * @param {String} realUrl - * @param {String} url the key of the audio in the cc.loader.cache - * @param {Array|Null} res - * @param {Number} count - * @param {Array} tryArr the audio types were tried - * @param {cc.Audio} audio - * @param {function} cb callback - * @private - */ + + // pre-load the audio.
    + // note: If the preload audio type doesn't be supported on current platform, loader will use other audio format to try, but its key is still the origin audio format.
    + // for example: a.mp3 doesn't be supported on some browser, loader will load a.ogg, if a.ogg loads success, user still uses a.mp3 to play audio. _load: function (realUrl, url, res, count, tryArr, audio, cb) { var self = this, locLoader = cc.loader, path = cc.path; var types = this._supportedAudioTypes; @@ -1037,10 +1155,16 @@ cc._audioLoader = { locLoader.cache[url] = audio; }, + /** + * Check whether to support this type of file + * @param type + * @returns {boolean} + */ audioTypeSupported: function (type) { if (!type) return false; return this._supportedAudioTypes.indexOf(type.toLowerCase()) >= 0; }, + _loadAudio: function (url, audio, cb, delFlag) { var _Audio; if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") @@ -1078,11 +1202,16 @@ cc._audioLoader = { } return audio; }, + + /** + * Load this audio. + */ load: function (realUrl, url, res, cb) { var tryArr = []; this._load(realUrl, url, res, -1, tryArr, null, cb); } }; + cc._audioLoader._supportedAudioTypes = function () { var au = cc.newElement('audio'), arr = []; if (au.canPlayType) { @@ -1099,6 +1228,7 @@ cc._audioLoader._supportedAudioTypes = function () { } return arr; }(); + cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader); // Initialize Audio engine singleton From a3d3214c6bc9f4c44564e101883ce5aa6a6f8bc9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 25 Aug 2014 21:14:54 +0800 Subject: [PATCH 0518/1564] Issue #5829: ClippingNode jsdoc --- cocos2d/clipping-nodes/CCClippingNode.js | 65 ++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index c40a0dfb29..f92fa91817 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -31,6 +31,19 @@ */ cc.stencilBits = -1; +/** + *

    + * Sets the shader program for this node + * + * Since v2.0, each rendering node must set its shader program. + * It should be set in initialize phase. + *

    + * @function + * @param {cc.Node} node + * @param {cc.GLProgram} program The shader program which fetchs from CCShaderCache. + * @example + * cc.setGLProgram(node, cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + */ cc.setProgram = function (node, program) { node.shaderProgram = program; @@ -54,8 +67,8 @@ cc.setProgram = function (node, program) { * * @property {Number} alphaThreshold - Threshold for alpha value. * @property {Boolean} inverted - Indicate whether in inverted mode. - * @property {cc.Node} stencil - he cc.Node to use as a stencil to do the clipping. */ +//@property {cc.Node} stencil - he cc.Node to use as a stencil to do the clipping. cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ alphaThreshold: 0, inverted: false, @@ -80,7 +93,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ }, /** - * Initializes a clipping node with an other node as its stencil.
    + * Initializes a clipping node with an other node as its stencil.
    * The stencil node will be retained, and its parent will be set to this clipping node. * @param {cc.Node} [stencil=null] */ @@ -109,26 +122,65 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ this.inverted = false; }, + /** + *

    + * Event callback that is invoked every time when node enters the 'stage'.
    + * If the CCNode enters the 'stage' with a transition, this event is called when the transition starts.
    + * During onEnter you can't access a "sister/brother" node.
    + * If you override onEnter, you must call its parent's onEnter function with this._super(). + *

    + * @function + */ onEnter: function () { cc.Node.prototype.onEnter.call(this); this._stencil.onEnter(); }, + /** + *

    + * Event callback that is invoked when the node enters in the 'stage'.
    + * If the node enters the 'stage' with a transition, this event is called when the transition finishes.
    + * If you override onEnterTransitionDidFinish, you shall call its parent's onEnterTransitionDidFinish with this._super() + *

    + * @function + */ onEnterTransitionDidFinish: function () { cc.Node.prototype.onEnterTransitionDidFinish.call(this); this._stencil.onEnterTransitionDidFinish(); }, + /** + *

    + * callback that is called every time the node leaves the 'stage'.
    + * If the node leaves the 'stage' with a transition, this callback is called when the transition starts.
    + * If you override onExitTransitionDidStart, you shall call its parent's onExitTransitionDidStart with this._super() + *

    + * @function + */ onExitTransitionDidStart: function () { this._stencil.onExitTransitionDidStart(); cc.Node.prototype.onExitTransitionDidStart.call(this); }, + /** + *

    + * callback that is called every time the node leaves the 'stage'.
    + * If the node leaves the 'stage' with a transition, this callback is called when the transition finishes.
    + * During onExit you can't access a sibling node.
    + * If you override onExit, you shall call its parent's onExit with this._super(). + *

    + * @function + */ onExit: function () { this._stencil.onExit(); cc.Node.prototype.onExit.call(this); }, + /** + * Recursive method that visit its children and draw them + * @function + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx + */ visit: null, _visitForWebGL: function (ctx) { @@ -402,6 +454,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ }, /** + * Set stencil. * @function * @param {cc.Node} stencil */ @@ -472,7 +525,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ return this.inverted; }, - /** * set whether or not invert of stencil * @param {Boolean} inverted @@ -517,11 +569,14 @@ cc.ClippingNode._getSharedCache = function () { }; /** - * Creates and initializes a clipping node with an other node as its stencil.
    + * Creates and initializes a clipping node with an other node as its stencil.
    * The stencil node will be retained. - * @deprecated + * @deprecated since v3.0, please use getNodeToParentTransform instead * @param {cc.Node} [stencil=null] * @return {cc.ClippingNode} + * @example + * //example + * new cc.ClippingNode(stencil); */ cc.ClippingNode.create = function (stencil) { return new cc.ClippingNode(stencil); From 2baa506e53e79f9e110052c6ab9bf31161f6e3d2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 25 Aug 2014 21:35:59 +0800 Subject: [PATCH 0519/1564] Doc #5829: Fix issues in LabelTTF inline docs --- cocos2d/core/base-nodes/CCNode.js | 2 +- cocos2d/core/labelttf/CCLabelTTF.js | 98 ++++++++++++++--------------- 2 files changed, 47 insertions(+), 53 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index aa526f3f1c..2fbf5b6f20 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2441,7 +2441,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * When color doesn't include opacity value like cc.color(128,128,128), this function only change the color.
    * When color include opacity like cc.color(128,128,128,100), then this function will change the color and the opacity.

    * @function - * @param {cc.Color} color The new coloe given + * @param {cc.Color} color The new color given */ setColor: function (color) { var locDisplayedColor = this._displayedColor, locRealColor = this._realColor; diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index c6e2bd455f..271f64e74e 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -25,9 +25,9 @@ ****************************************************************************/ /** - * cc.LabelTTF is a subclass of cc.TextureNode that knows how to render text labels
    - * All features from cc.TextureNode are valid in cc.LabelTTF
    - * cc.LabelTTF objects are slow for js-binding on mobile devices.Consider using cc.LabelAtlas or cc.LabelBMFont instead.
    + * cc.LabelTTF is a subclass of cc.TextureNode that knows how to render text labels with system font or a ttf font file
    + * All features from cc.Sprite are valid in cc.LabelTTF
    + * cc.LabelTTF objects are slow for js-binding on mobile devices.
    * Consider using cc.LabelAtlas or cc.LabelBMFont instead.
    * @class * @extends cc.Sprite @@ -47,7 +47,6 @@ * @property {Number} shadowOffsetY - The y axis offset of shadow * @property {Number} shadowOpacity - The opacity of shadow * @property {Number} shadowBlur - The blur size of shadow - * */ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _dimensions: null, @@ -89,6 +88,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ /** * creates a cc.LabelTTF from a font name, alignment, dimension and font size * Constructor of cc.LabelTTF + * @constructor * @param {String} text * @param {String|cc.FontDefinition} [fontName="Arial"] * @param {Number} [fontSize=16] @@ -154,10 +154,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return this._getLabelContext().measureText(text).width; }, - /** - * Prints out a description of this class - * @return {String} - */ description: function () { return ""; }, @@ -167,16 +163,18 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _setColorsString: null, updateDisplayedColor: null, + setOpacity: null, updateDisplayedOpacity: null, + updateDisplayedOpacityForCanvas: function (parentOpacity) { cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); this._setColorsString(); }, /** - * returns the text of the label + * Returns the text of the label * @return {String} */ getString: function () { @@ -184,7 +182,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * return Horizontal Alignment of cc.LabelTTF + * Returns Horizontal Alignment of cc.LabelTTF * @return {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT} */ getHorizontalAlignment: function () { @@ -192,7 +190,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * return Vertical Alignment of cc.LabelTTF + * Returns Vertical Alignment of cc.LabelTTF * @return {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} */ getVerticalAlignment: function () { @@ -200,7 +198,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * return Dimensions of cc.LabelTTF + * Returns the dimensions of cc.LabelTTF, the dimension is the maximum size of the label, set it so that label will automatically change lines when necessary. + * @see cc.LabelTTF#setDimensions, cc.LabelTTF#boundingWidth and cc.LabelTTF#boundingHeight * @return {cc.Size} */ getDimensions: function () { @@ -208,7 +207,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * return font size of cc.LabelTTF + * Returns font size of cc.LabelTTF * @return {Number} */ getFontSize: function () { @@ -216,7 +215,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * return font name of cc.LabelTTF + * Returns font name of cc.LabelTTF * @return {String} */ getFontName: function () { @@ -224,7 +223,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * initializes the cc.LabelTTF with a font name, alignment, dimension and font size + * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, you should pass the correct arguments in constructor to initialize the label. * @param {String} label string * @param {String} fontName * @param {Number} fontSize @@ -263,7 +262,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * initializes the CCLabelTTF with a font name, alignment, dimension and font size + * Initializes the CCLabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, you should pass the correct arguments in constructor to initialize the label. * @param {String} text * @param {cc.FontDefinition} textDefinition * @return {Boolean} @@ -271,7 +270,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ initWithStringAndTextDefinition: null, /** - * set the text definition used by this label + * Sets the text definition used by this label * @param {cc.FontDefinition} theDefinition */ setTextDefinition: function (theDefinition) { @@ -280,7 +279,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * get the text definition used by this label + * Extract the text definition used by this label * @return {cc.FontDefinition} */ getTextDefinition: function () { @@ -288,10 +287,11 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * enable or disable shadow for the label - * @param {cc.Point} shadowOffset - * @param {Number} shadowOpacity (0 to 1) - * @param {Number} shadowBlur + * Enable or disable shadow for the label + * @param {Number} shadowOffsetX The x axis offset of the shadow + * @param {Number} shadowOffsetY The y axis offset of the shadow + * @param {Number} shadowOpacity The opacity of the shadow (0 to 1) + * @param {Number} shadowBlur The blur size of the shadow */ enableShadow: function (shadowOffsetX, shadowOffsetY, shadowOpacity, shadowBlur) { shadowOpacity = shadowOpacity || 0.5; @@ -383,7 +383,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * disable shadow rendering + * Disable shadow rendering */ disableShadow: function () { if (this._shadowEnabled) { @@ -393,9 +393,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * enable or disable stroke - * @param {cc.Color} strokeColor - * @param {Number} strokeSize + * Enable label stroke with stroke parameters + * @param {cc.Color} strokeColor The color of stroke + * @param {Number} strokeSize The size of stroke */ enableStroke: function (strokeColor, strokeSize) { if (this._strokeEnabled === false) @@ -447,7 +447,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * disable stroke + * Disable label stroke */ disableStroke: function () { if (this._strokeEnabled) { @@ -457,9 +457,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * set text tinting + * Sets the text fill color * @function - * @param {cc.Color} tintColor + * @param {cc.Color} fillColor The fill color of the label */ setFontFillColor: null, @@ -548,10 +548,11 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, _fontClientHeight: 18, + /** - * changes the string to render + * Changes the text content of the label * @warning Changing the string is as expensive as creating a new cc.LabelTTF. To obtain better performance use cc.LabelAtlas - * @param {String} text text for the label + * @param {String} text Text content for the label */ setString: function (text) { text = String(text); @@ -567,8 +568,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _updateString: function () { this._string = this._originalText; }, + /** - * set Horizontal Alignment of cc.LabelTTF + * Sets Horizontal Alignment of cc.LabelTTF * @param {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT} alignment Horizontal Alignment */ setHorizontalAlignment: function (alignment) { @@ -581,7 +583,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * set Vertical Alignment of cc.LabelTTF + * Sets Vertical Alignment of cc.LabelTTF * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} verticalAlignment */ setVerticalAlignment: function (verticalAlignment) { @@ -594,7 +596,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * set Dimensions of cc.LabelTTF + * Set Dimensions of cc.LabelTTF, the dimension is the maximum size of the label, set it so that label will automatically change lines when necessary. * @param {cc.Size|Number} dim dimensions or width of dimensions * @param {Number} [height] height of dimensions */ @@ -640,7 +642,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * set font size of cc.LabelTTF + * Sets font size of cc.LabelTTF * @param {Number} fontSize */ setFontSize: function (fontSize) { @@ -654,7 +656,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, /** - * set font name of cc.LabelTTF + * Sets font name of cc.LabelTTF * @param {String} fontName */ setFontName: function (fontName) { @@ -902,6 +904,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._anchorPointInPoints.y = (locStrokeShadowOffsetY * 0.5) + ((locSize.height - locStrokeShadowOffsetY) * locAP.y); }, + /** + * Returns the actual content size of the label, the content size is the real size that the label occupied while dimension is the outer bounding box of the label. + * @returns {cc.Size} The content size + */ getContentSize: function () { if (this._needUpdateTexture) this._updateTTF(); @@ -959,11 +965,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ cc.Sprite.prototype.visit.call(this, context); }, - /** - * Draw sprite to canvas - * @function - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx Render context of canvas, 2d or 3d - */ draw: null, _setTextureCoords: function (rect) { @@ -1169,7 +1170,9 @@ cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; /** * creates a cc.LabelTTF from a font name, alignment, dimension and font size - * @deprecated + * @deprecated since v3.0, please use the new construction instead + * @see cc.LabelTTF#ctor + * @static * @param {String} text * @param {String|cc.FontDefinition} [fontName="Arial"] * @param {Number} [fontSize=16] @@ -1177,22 +1180,13 @@ cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; * @param {Number} [hAlignment=cc.TEXT_ALIGNMENT_LEFT] * @param {Number} [vAlignment=cc.VERTICAL_TEXT_ALIGNMENT_TOP] * @return {cc.LabelTTF|Null} - * @example - * // Example - * 1. - * var myLabel = cc.LabelTTF.create('label text', 'Times New Roman', 32, cc.size(320,32), cc.TEXT_ALIGNMENT_LEFT); - * 2. - * var fontDef = new cc.FontDefinition(); - * fontDef.fontName = "Arial"; - * fontDef.fontSize = "32"; - * var myLabel = cc.LabelTTF.create('label text', fontDef); */ cc.LabelTTF.create = function (text, fontName, fontSize, dimensions, hAlignment, vAlignment) { return new cc.LabelTTF(text, fontName, fontSize, dimensions, hAlignment, vAlignment); }; /** - * @deprecated + * @deprecated since v3.0, please use the new construction instead * @type {Function} */ cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create; From e3bb3bbc0c12f14b72605a941007018816e32ffa Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 26 Aug 2014 01:24:40 +0800 Subject: [PATCH 0520/1564] Doc #5829: Improve constructor definitions and fix issues in Layer's inline docs --- cocos2d/core/base-nodes/CCAtlasNode.js | 15 +- cocos2d/core/base-nodes/CCNode.js | 8 +- cocos2d/core/cocoa/CCAffineTransform.js | 1 - cocos2d/core/cocoa/CCGeometry.js | 3 - cocos2d/core/event-manager/CCTouch.js | 12 +- cocos2d/core/labelttf/CCLabelTTF.js | 114 +++++++------ cocos2d/core/layers/CCLayer.js | 158 ++++++++++-------- .../gui/control-extension/CCControlSlider.js | 2 +- 8 files changed, 161 insertions(+), 152 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 10de3ca45b..a1bbb3ff23 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -31,9 +31,18 @@ * *

    All features from cc.Node are valid

    * + *

    You can create a cc.AtlasNode with an Atlas file, the width, the height of each item and the quantity of items to render

    + * * @class * @extends cc.Node * + * @param {String} tile + * @param {Number} tileWidth + * @param {Number} tileHeight + * @param {Number} itemsToRender + * @example + * var node = new cc.AtlasNode("pathOfTile", 16, 16, 1); + * * @property {cc.Texture2D} texture - Current used texture * @property {cc.TextureAtlas} textureAtlas - Texture atlas for cc.AtlasNode * @property {Number} quadsToDraw - Number of quads to draw @@ -62,15 +71,11 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ _className: "AtlasNode", /** - * Creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render - * Constructor of cc.AtlasNode - * @constructor + *

    Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.

    * @param {String} tile * @param {Number} tileWidth * @param {Number} tileHeight * @param {Number} itemsToRender - * @example - * var node = new cc.AtlasNode("pathOfTile", 16, 16, 1); */ ctor: function (tile, tileWidth, tileHeight, itemsToRender) { cc.Node.prototype.ctor.call(this); diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 2fbf5b6f20..85cdbe9a4a 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -87,6 +87,7 @@ cc.s_globalOrderOfArrival = 1; * -# The grid will capture the screen
    * -# The node will be moved according to the camera values (camera)
    * -# The grid will render the captured screen

    + * * @class * @extends cc.Class * @@ -2059,10 +2060,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ grid: null, /** - *

    The cc.Node's constructor.
    - * This function will automatically be invoked when you create a node using new construction: "var node = new cc.Node()".
    - * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    - * @constructor + *

    Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.

    + * @function */ ctor: null, @@ -2550,6 +2549,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Allocates and initializes a node. * @deprecated since v3.0, please use new construction instead. + * @see cc.Node * @return {cc.Node} */ cc.Node.create = function () { diff --git a/cocos2d/core/cocoa/CCAffineTransform.js b/cocos2d/core/cocoa/CCAffineTransform.js index 8839a8c9b3..1135c252a3 100644 --- a/cocos2d/core/cocoa/CCAffineTransform.js +++ b/cocos2d/core/cocoa/CCAffineTransform.js @@ -29,7 +29,6 @@ * Please do not use its constructor directly, use cc.affineTransformMake alias function instead. *

    * @class cc.AffineTransform - * @constructor * @param {Number} a * @param {Number} b * @param {Number} c diff --git a/cocos2d/core/cocoa/CCGeometry.js b/cocos2d/core/cocoa/CCGeometry.js index 53d4b6bf14..3b047b5742 100644 --- a/cocos2d/core/cocoa/CCGeometry.js +++ b/cocos2d/core/cocoa/CCGeometry.js @@ -27,7 +27,6 @@ /** * cc.Point is the class for point object, please do not use its constructor to create points, use cc.p() alias function instead. * @class cc.Point - * @constructor * @param {Number} x * @param {Number} y * @see cc.p @@ -78,7 +77,6 @@ cc.pointEqualToPoint = function (point1, point2) { /** * cc.Size is the class for size object, please do not use its constructor to create sizes, use cc.size() alias function instead. * @class cc.Size - * @constructor * @param {Number} width * @param {Number} height * @see cc.size @@ -129,7 +127,6 @@ cc.sizeEqualToSize = function (size1, size2) { /** * cc.Rect is the class for rect object, please do not use its constructor to create rects, use cc.rect() alias function instead. * @class cc.Rect - * @constructor * @param {Number} width * @param {Number} height * @see cc.rect diff --git a/cocos2d/core/event-manager/CCTouch.js b/cocos2d/core/event-manager/CCTouch.js index 7f90e45700..8a7c017aad 100644 --- a/cocos2d/core/event-manager/CCTouch.js +++ b/cocos2d/core/event-manager/CCTouch.js @@ -24,9 +24,13 @@ ****************************************************************************/ /** - * The data of touch event + * The touch event class * @class * @extends cc.Class + * + * @param {Number} x + * @param {Number} y + * @param {Number} id */ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ _point:null, @@ -35,12 +39,6 @@ cc.Touch = cc.Class.extend(/** @lends cc.Touch# */{ _startPointCaptured: false, _startPoint:null, - /** - * @constructor - * @param {Number} x - * @param {Number} y - * @param {Number} id - */ ctor:function (x, y, id) { this._point = cc.p(x || 0, y || 0); this._id = id || 0; diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 271f64e74e..6a6f0cea37 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -25,13 +25,28 @@ ****************************************************************************/ /** - * cc.LabelTTF is a subclass of cc.TextureNode that knows how to render text labels with system font or a ttf font file
    + *

    cc.LabelTTF is a subclass of cc.TextureNode that knows how to render text labels with system font or a ttf font file
    * All features from cc.Sprite are valid in cc.LabelTTF
    * cc.LabelTTF objects are slow for js-binding on mobile devices.
    * Consider using cc.LabelAtlas or cc.LabelBMFont instead.
    + * You can create a cc.LabelTTF from a font name, alignment, dimension and font size or a cc.FontDefinition object.

    * @class * @extends cc.Sprite * + * @param {String} text + * @param {String|cc.FontDefinition} [fontName="Arial"] + * @param {Number} [fontSize=16] + * @param {cc.Size} [dimensions=cc.size(0,0)] + * @param {Number} [hAlignment=cc.TEXT_ALIGNMENT_LEFT] + * @param {Number} [vAlignment=cc.VERTICAL_TEXT_ALIGNMENT_TOP] + * @example + * var myLabel = new cc.LabelTTF('label text', 'Times New Roman', 32, cc.size(320,32), cc.TEXT_ALIGNMENT_LEFT); + * + * var fontDef = new cc.FontDefinition(); + * fontDef.fontName = "Arial"; + * fontDef.fontSize = "32"; + * var myLabel = new cc.LabelTTF('label text', fontDef); + * * @property {String} string - Content string of label * @property {Number} textAlign - Horizontal Alignment of label: cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT * @property {Number} verticalAlign - Vertical Alignment of label: cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM @@ -86,23 +101,44 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _className: "LabelTTF", /** - * creates a cc.LabelTTF from a font name, alignment, dimension and font size - * Constructor of cc.LabelTTF - * @constructor - * @param {String} text - * @param {String|cc.FontDefinition} [fontName="Arial"] - * @param {Number} [fontSize=16] - * @param {cc.Size} [dimensions=cc.size(0,0)] - * @param {Number} [hAlignment=cc.TEXT_ALIGNMENT_LEFT] - * @param {Number} [vAlignment=cc.VERTICAL_TEXT_ALIGNMENT_TOP] - * @example - * var myLabel = new cc.LabelTTF('label text', 'Times New Roman', 32, cc.size(320,32), cc.TEXT_ALIGNMENT_LEFT); - * - * var fontDef = new cc.FontDefinition(); - * fontDef.fontName = "Arial"; - * fontDef.fontSize = "32"; - * var myLabel = new cc.LabelTTF('label text', fontDef); + * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, you should pass the correct arguments in constructor to initialize the label. + * @param {String} label string + * @param {String} fontName + * @param {Number} fontSize + * @param {cc.Size} [dimensions=] + * @param {Number} [hAlignment=] + * @param {Number} [vAlignment=] + * @return {Boolean} return false on error */ + initWithString: function (label, fontName, fontSize, dimensions, hAlignment, vAlignment) { + var strInfo; + if (label) + strInfo = label + ""; + else + strInfo = ""; + + fontSize = fontSize || 16; + dimensions = dimensions || cc.size(0, fontSize); + hAlignment = hAlignment || cc.TEXT_ALIGNMENT_LEFT; + vAlignment = vAlignment || cc.VERTICAL_TEXT_ALIGNMENT_TOP; + + this._opacityModifyRGB = false; + this._dimensions = cc.size(dimensions.width, dimensions.height); + this._fontName = fontName || "Arial"; + this._hAlignment = hAlignment; + this._vAlignment = vAlignment; + + //this._fontSize = (cc._renderType === cc._RENDER_TYPE_CANVAS) ? fontSize : fontSize * cc.contentScaleFactor(); + this._fontSize = fontSize; + this._fontStyleStr = this._fontSize + "px '" + fontName + "'"; + this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, this._fontSize); + this.string = strInfo; + this._setColorsString(); + this._updateTexture(); + this._needUpdateTexture = false; + return true; + }, + ctor: function (text, fontName, fontSize, dimensions, hAlignment, vAlignment) { cc.Sprite.prototype.ctor.call(this); @@ -222,45 +258,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return this._fontName; }, - /** - * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, you should pass the correct arguments in constructor to initialize the label. - * @param {String} label string - * @param {String} fontName - * @param {Number} fontSize - * @param {cc.Size} [dimensions=] - * @param {Number} [hAlignment=] - * @param {Number} [vAlignment=] - * @return {Boolean} return false on error - */ - initWithString: function (label, fontName, fontSize, dimensions, hAlignment, vAlignment) { - var strInfo; - if (label) - strInfo = label + ""; - else - strInfo = ""; - - fontSize = fontSize || 16; - dimensions = dimensions || cc.size(0, fontSize); - hAlignment = hAlignment || cc.TEXT_ALIGNMENT_LEFT; - vAlignment = vAlignment || cc.VERTICAL_TEXT_ALIGNMENT_TOP; - - this._opacityModifyRGB = false; - this._dimensions = cc.size(dimensions.width, dimensions.height); - this._fontName = fontName || "Arial"; - this._hAlignment = hAlignment; - this._vAlignment = vAlignment; - - //this._fontSize = (cc._renderType === cc._RENDER_TYPE_CANVAS) ? fontSize : fontSize * cc.contentScaleFactor(); - this._fontSize = fontSize; - this._fontStyleStr = this._fontSize + "px '" + fontName + "'"; - this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, this._fontSize); - this.string = strInfo; - this._setColorsString(); - this._updateTexture(); - this._needUpdateTexture = false; - return true; - }, - /** * Initializes the CCLabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, you should pass the correct arguments in constructor to initialize the label. * @param {String} text @@ -1171,7 +1168,7 @@ cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; /** * creates a cc.LabelTTF from a font name, alignment, dimension and font size * @deprecated since v3.0, please use the new construction instead - * @see cc.LabelTTF#ctor + * @see cc.LabelTTF * @static * @param {String} text * @param {String|cc.FontDefinition} [fontName="Arial"] @@ -1187,7 +1184,8 @@ cc.LabelTTF.create = function (text, fontName, fontSize, dimensions, hAlignment, /** * @deprecated since v3.0, please use the new construction instead - * @type {Function} + * @function + * @static */ cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 5c93cb343d..e9b4f71a22 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -25,9 +25,7 @@ ****************************************************************************/ /** cc.Layer is a subclass of cc.Node that implements the TouchEventsDelegate protocol.
    - * All features from cc.Node are valid, plus the following new features:
    - * It can receive iPhone Touches
    - * It can receive Accelerometer input + * All features from cc.Node are valid, plus the bake feature: Baked layer can cache a static layer to improve performance * @class * @extends cc.Node */ @@ -37,7 +35,7 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ _className: "Layer", /** - * Constructor of cc.Layer + *

    Constructor of cc.Layer, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor: function () { var nodep = cc.Node.prototype; @@ -47,6 +45,9 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ nodep.setContentSize.call(this, cc.winSize); }, + /** + * Initialization of the layer, please do not call this function by yourself, you should pass the parameters to constructor to initialize a layer + */ init: function(){ var _t = this; _t._ignoreAnchorPointForPosition = true; @@ -58,14 +59,18 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ }, /** - * set the layer to cache all of children to a bake sprite, and draw itself by bake sprite. recommend using it in UI. + * Sets the layer to cache all of children to a bake sprite, and draw itself by bake sprite. recommend using it in UI.
    + * This is useful only in html5 engine * @function + * @see cc.Layer#unbake */ bake: null, /** - * cancel the layer to cache all of children to a bake sprite. + * Cancel the layer to cache all of children to a bake sprite.
    + * This is useful only in html5 engine * @function + * @see cc.Layer#bake */ unbake: null, @@ -73,6 +78,7 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ * Determines if the layer is baked. * @function * @returns {boolean} + * @see cc.Layer#bake and cc.Layer#unbake */ isBaked: function(){ return this._isBaked; @@ -82,12 +88,9 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ }); /** - * creates a layer - * @deprecated - * @example - * // Example - * var myLayer = cc.Layer.create(); - * //Yes! it's that simple + * Creates a layer + * @deprecated since v3.0, please use the new construction instead + * @see cc.Layer * @return {cc.Layer|Null} */ cc.Layer.create = function () { @@ -205,18 +208,30 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { *

    * CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
    * All features from CCLayer are valid, plus the following new features:
    - *

    • opacity

    • - *
    • RGB colors

    - *

    + * opacity
    + * RGB colors

    * @class * @extends cc.Layer + * + * @param {cc.Color} [color=] The color of the layer + * @param {Number} [width=] The width of the layer + * @param {Number} [height=] The height of the layer + * + * @example + * // Example + * //Create a yellow color layer as background + * var yellowBackground = new cc.LayerColor(cc.color(255,255,0,255)); + * //If you didnt pass in width and height, it defaults to the same size as the canvas + * + * //create a yellow box, 200 by 200 in size + * var yellowBox = new cc.LayerColor(cc.color(255,255,0,255), 200, 200); */ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ _blendFunc: null, _className: "LayerColor", /** - * blendFunc getter + * Returns the blend function * @return {cc.BlendFunc} */ getBlendFunc: function () { @@ -224,8 +239,9 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ }, /** - * change width and height in Points - * @deprecated + * Changes width and height + * @deprecated since v3.0 please use setContentSize instead + * @see cc.Node#setContentSize * @param {Number} w width * @param {Number} h height */ @@ -235,8 +251,9 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ }, /** - * change width in Points - * @deprecated + * Changes width in Points + * @deprecated since v3.0 please use setContentSize instead + * @see cc.Node#setContentSize * @param {Number} w width */ changeWidth: function (w) { @@ -245,24 +262,17 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ /** * change height in Points - * @deprecated + * @deprecated since v3.0 please use setContentSize instead + * @see cc.Node#setContentSize * @param {Number} h height */ changeHeight: function (h) { this.height = h; }, - /** - * set OpacityModifyRGB of cc.LayerColor - * @param {Boolean} value - */ setOpacityModifyRGB: function (value) { }, - /** - * is OpacityModifyRGB - * @return {Boolean} - */ isOpacityModifyRGB: function () { return false; }, @@ -278,6 +288,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ }, _blendFuncStr: "source", + /** * Constructor of cc.LayerColor * @function @@ -288,6 +299,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ ctor: null, /** + * Initialization of the layer, please do not call this function by yourself, you should pass the parameters to constructor to initialize a layer * @param {cc.Color} [color=] * @param {Number} [width=] * @param {Number} [height=] @@ -322,9 +334,9 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ }, /** - * blendFunc setter - * @param {Number} src - * @param {Number} dst + * Sets the blend func, you can pass either a cc.BlendFunc object or source and destination value separately + * @param {Number|cc.BlendFunc} src + * @param {Number} [dst] */ setBlendFunc: function (src, dst) { var _t = this, locBlendFunc = this._blendFunc; @@ -355,29 +367,17 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ this._updateColor(); }, - /** - * Renders the layer - * @function - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx - */ draw: null }); /** - * creates a cc.Layer with color, width and height in Points - * @deprecated + * Creates a cc.Layer with color, width and height in Points + * @deprecated since v3.0 please use the new construction instead + * @see cc.LayerColor * @param {cc.Color} color * @param {Number|Null} [width=] * @param {Number|Null} [height=] * @return {cc.LayerColor} - * @example - * // Example - * //Create a yellow color layer as background - * var yellowBackground = cc.LayerColor.create(cc.color(255,255,0,255)); - * //If you didnt pass in width and height, it defaults to the same size as the canvas - * - * //create a yellow box, 200 by 200 in size - * var yellowBox = cc.LayerColor.create(cc.color(255,255,0,255), 200, 200); */ cc.LayerColor.create = function (color, width, height) { return new cc.LayerColor(color, width, height); @@ -529,6 +529,10 @@ delete cc._tmp.PrototypeLayerColor; * @class * @extends cc.LayerColor * + * @param {cc.Color} start Starting color + * @param {cc.Color} end Ending color + * @param {cc.Point} [v=cc.p(0, -1)] A vector defines the gradient direction, default direction is from top to bottom + * * @property {cc.Color} startColor - Start color of the color gradient * @property {cc.Color} endColor - End color of the color gradient * @property {Number} startOpacity - Start opacity of the color gradient @@ -549,9 +553,9 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ /** * Constructor of cc.LayerGradient - * @param {cc.Color} start starting color + * @param {cc.Color} start * @param {cc.Color} end - * @param {cc.Point|Null} v + * @param {cc.Point} [v=cc.p(0, -1)] */ ctor: function (start, end, v) { var _t = this; @@ -568,6 +572,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** + * Initialization of the layer, please do not call this function by yourself, you should pass the parameters to constructor to initialize a layer * @param {cc.Color} start starting color * @param {cc.Color} end * @param {cc.Point|Null} v @@ -603,7 +608,6 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ /** * Sets the untransformed size of the LayerGradient. - * @override * @param {cc.Size|Number} size The untransformed size of the LayerGradient or The untransformed size's width of the LayerGradient. * @param {Number} [height] The untransformed size's height of the LayerGradient. */ @@ -622,7 +626,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * get the starting color + * Returns the starting color * @return {cc.Color} */ getStartColor: function () { @@ -630,7 +634,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * set the starting color + * Sets the starting color * @param {cc.Color} color * @example * // Example @@ -642,7 +646,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * set the end gradient color + * Sets the end gradient color * @param {cc.Color} color * @example * // Example @@ -655,7 +659,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * get the end color + * Returns the end color * @return {cc.Color} */ getEndColor: function () { @@ -663,7 +667,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * set starting gradient opacity + * Sets starting gradient opacity * @param {Number} o from 0 to 255, 0 is transparent */ setStartOpacity: function (o) { @@ -672,7 +676,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * get the starting gradient opacity + * Returns the starting gradient opacity * @return {Number} */ getStartOpacity: function () { @@ -680,7 +684,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * set the end gradient opacity + * Sets the end gradient opacity * @param {Number} o */ setEndOpacity: function (o) { @@ -689,7 +693,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * get the end gradient opacity + * Returns the end gradient opacity * @return {Number} */ getEndOpacity: function () { @@ -697,7 +701,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** - * set vector + * Sets the direction vector of the gradient * @param {cc.Point} Var */ setVector: function (Var) { @@ -707,13 +711,15 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** + * Returns the direction vector of the gradient * @return {cc.Point} */ getVector: function () { return cc.p(this._alongVector.x, this._alongVector.y); }, - /** is Compressed Interpolation + /** + * Returns whether compressed interpolation is enabled * @return {Boolean} */ isCompressedInterpolation: function () { @@ -721,6 +727,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, /** + * Sets whether compressed interpolation is enabled * @param {Boolean} compress */ setCompressedInterpolation: function (compress) { @@ -734,8 +741,9 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }); /** - * creates a gradient layer - * @deprecated + * Creates a gradient layer + * @deprecated since v3.0, please use the new construction instead + * @see cc.layerGradient * @param {cc.Color} start starting color * @param {cc.Color} end ending color * @param {cc.Point|Null} v @@ -799,8 +807,12 @@ delete cc._tmp.PrototypeLayerGradient; * Features:
    *
    • - It supports one or more children
    • *
    • - Only one children will be active a time
    - * @class - * @extends cc.Layer + * @class + * @extends cc.Layer + * @param {Array} layers an array of cc.Layer + * @example + * // Example + * var multiLayer = new cc.LayerMultiple(layer1, layer2, layer3);//any number of layers */ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ _enabledLayer: 0, @@ -820,6 +832,7 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ }, /** + * Initialization of the layer multiplex, please do not call this function by yourself, you should pass the parameters to constructor to initialize a layer multiplex * @param {Array} layers an array of cc.Layer * @return {Boolean} */ @@ -834,7 +847,7 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ }, /** - * switches to a certain layer indexed by n.
    + * Switches to a certain layer indexed by n.
    * The current (old) layer will be removed from it's parent with 'cleanup:YES'. * @param {Number} n the layer index to switch to */ @@ -849,7 +862,8 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ this.addChild(this._layers[n]); }, - /** release the current layer and switches to another layer indexed by n.
    + /** + * Release the current layer and switches to another layer indexed by n.
    * The current (old) layer will be removed from it's parent with 'cleanup:YES'. * @param {Number} n the layer index to switch to */ @@ -868,6 +882,7 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ }, /** + * Add a layer to the multiplex layers list * @param {cc.Layer} layer */ addLayer: function (layer) { @@ -880,14 +895,11 @@ cc.LayerMultiplex = cc.Layer.extend(/** @lends cc.LayerMultiplex# */{ }); /** - * creates a cc.LayerMultiplex with one or more layers using a variable argument list. - * @deprecated + * Creates a cc.LayerMultiplex with one or more layers using a variable argument list. + * @deprecated since v3.0, please use new construction instead + * @see cc.LayerMultiplex * @return {cc.LayerMultiplex|Null} - * @example - * // Example - * var multiLayer = cc.LayerMultiple.create(layer1, layer2, layer3);//any number of layers */ cc.LayerMultiplex.create = function (/*Multiple Arguments*/) { return new cc.LayerMultiplex(Array.prototype.slice.call(arguments)); -}; - +}; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index e280bd556a..87fcf73b60 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -300,7 +300,7 @@ _p = null; * Creates a slider with a given background sprite and a progress bar and a * thumb item. * @deprecated - * @see cc.ControlSlider#ctor + * @see cc.ControlSlider */ cc.ControlSlider.create = function (bgFile, progressFile, thumbFile) { return new cc.ControlSlider(bgFile, progressFile, thumbFile); From 598ceaffd349a8e1404b2e2e86c5529f570c601e Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 26 Aug 2014 09:43:23 +0800 Subject: [PATCH 0521/1564] Doc #5829: Remove deprecated note for ProtectedNode#removeAllProtectedChildren --- extensions/ccui/base-classes/CCProtectedNode.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 08f5b0e308..5a2e1b6789 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -147,7 +147,6 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ /** * Removes all children from the container with a cleanup. * @see cc.ProtectedNode#removeAllProtectedChildrenWithCleanup - * @deprecated since v3.0 please use removeAllProtectedChildrenWithCleanup instead */ removeAllProtectedChildren: function(){ this.removeAllProtectedChildrenWithCleanup(true); From 962fd1c631e1193eaef593c9783bbeb28827cb38 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 26 Aug 2014 10:13:30 +0800 Subject: [PATCH 0522/1564] Issue #5830: add jsDocs to layouts --- CCBoot.js | 8 +- extensions/ccui/layouts/UIHBox.js | 40 ++- extensions/ccui/layouts/UILayout.js | 159 +++++++++--- extensions/ccui/layouts/UILayoutManager.js | 26 +- extensions/ccui/layouts/UILayoutParameter.js | 252 ++++++++++++++++--- extensions/ccui/layouts/UIRelativeBox.js | 40 ++- extensions/ccui/layouts/UIVBox.js | 40 ++- extensions/ccui/system/CocosGUI.js | 5 +- extensions/ccui/system/UIHelper.js | 9 +- extensions/ccui/uiwidgets/UIButton.js | 2 +- 10 files changed, 462 insertions(+), 119 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index dc413d4e43..985a56f02c 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -735,18 +735,12 @@ cc.loader = { return url; }, - /** - * Load resources then call the callback. - * @param {string} res - * @param {function|Object} [option] option or cb - * @param {function} [cb] - * @return {cc.AsyncPool} - */ /** * Load resources then call the callback. * @param {string} resources * @param {function|Object} [option] option or cb * @param {function} [cb] + * @return {cc.AsyncPool} */ load : function(resources, option, cb){ var self = this; diff --git a/extensions/ccui/layouts/UIHBox.js b/extensions/ccui/layouts/UIHBox.js index 1dd2075c43..e0aa8d997d 100644 --- a/extensions/ccui/layouts/UIHBox.js +++ b/extensions/ccui/layouts/UIHBox.js @@ -24,11 +24,28 @@ ****************************************************************************/ /** - * The horizontal box of Cocos UI. + * The horizontal box of Cocos UI. Its layout type is ccui.Layout.LINEAR_HORIZONTAL. * @class * @extends ccui.Layout */ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ + /** + * The constructor of ccui.HBox + * @function + * @param {cc.Size} [size] + */ + ctor: function(size){ + if(size) + this.initWithSize(size); + else + this.init(); + }, + + /** + * Initialize a HBox + * @override + * @returns {boolean} + */ init: function(){ if(ccui.Layout.prototype.init.call(this)){ this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL); @@ -37,6 +54,11 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ return false; }, + /** + * Initializes a HBox with size. + * @param size + * @returns {boolean} + */ initWithSize: function(size){ if(this.init()){ this.setContentSize(size); @@ -46,14 +68,12 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ } }); +/** + * Creates a HBox object + * @deprecated + * @param {cc.Size} size + * @returns {ccui.HBox} + */ ccui.HBox.create = function(size){ - var widget = new ccui.HBox(); - if(size){ - if(widget.initWithSize(size)) - return widget; - }else { - if(widget.init()) - return widget; - } - return null; + return new ccui.HBox(size); }; \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 178b0787e2..684acab664 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -24,7 +24,8 @@ ****************************************************************************/ /** - * Base class for ccui.Layout + * ccui.Layout is the base class of ccui.PageView and ccui.ScrollView, it does layout by layout manager + * and clips area by its _clippingStencil when clippingEnabled is true. * @class * @extends ccui.Widget * @@ -87,8 +88,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _isFocusPassing:false, //when finding the next focused widget, use this variable to pass focus between layout & widget /** - * allocates and initializes a UILayout. + * Allocates and initializes an UILayout. * Constructor of ccui.Layout + * @function * @example * // example * var uiLayout = new ccui.Layout(); @@ -111,6 +113,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingRect = cc.rect(0, 0, 0, 0); this._backGroundImageColor = cc.color(255, 255, 255, 255); }, + + /** + * Calls its parent's onEnter, and calls its clippingStencil's onEnter if clippingStencil isn't null. + * @override + */ onEnter: function(){ ccui.Widget.prototype.onEnter.call(this); if (this._clippingStencil) @@ -118,6 +125,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._doLayoutDirty = true; this._clippingRectDirty = true; }, + + /** + * Calls its parent's onExit, and calls its clippingStencil's onExit if clippingStencil isn't null. + * @override + */ onExit: function(){ ccui.Widget.prototype.onExit.call(this); if (this._clippingStencil) @@ -141,6 +153,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** + * Specifies whether the layout pass its focus to its child * @param pass To specify whether the layout pass its focus to its child */ setPassFocusToChild: function(pass){ @@ -148,6 +161,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** + * Returns whether the layout will pass the focus to its children or not. The default value is true * @returns {boolean} To query whether the layout will pass the focus to its children or not. The default value is true */ isPassFocusToChild: function(){ @@ -157,8 +171,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * When a widget is in a layout, you could call this method to get the next focused widget within a specified direction. * If the widget is not in a layout, it will return itself - * @param direction the direction to look for the next focused widget in a layout - * @param current the current focused widget + * @param {Number} direction the direction to look for the next focused widget in a layout + * @param {ccui.Widget} current the current focused widget * @returns {ccui.Widget} return the index of widget in the layout */ findNextFocusedWidget: function(direction, current){ @@ -232,8 +246,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return current; }, + /** + * To specify a user-defined functor to decide which child widget of the layout should get focused + * @function + * @param {Number} direction + * @param {ccui.Widget} current + */ onPassFocusToChild: null, + /** + * override "init" method of widget. + * @returns {boolean} + * @override + */ init: function () { if (ccui.Widget.prototype.init.call(this)) { this.ignoreContentAdaptWithSize(false); @@ -265,6 +290,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Widget} widget * @param {Number} [zOrder] * @param {Number|string} [tag] tag or name + * @override */ addChild: function (widget, zOrder, tag) { if ((widget instanceof ccui.Widget)) { @@ -275,9 +301,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Remove child widget from ccui.Layout + * Removes child widget from ccui.Layout, and sets the layout dirty flag to true. * @param {ccui.Widget} widget * @param {Boolean} [cleanup=true] + * @override */ removeChild: function (widget, cleanup) { ccui.Widget.prototype.removeChild.call(this, widget, cleanup); @@ -285,7 +312,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Removes all children from the container with a cleanup. + * Removes all children from the container with a cleanup, and sets the layout dirty flag to true. * @param {Boolean} cleanup */ removeAllChildren: function (cleanup) { @@ -294,7 +321,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. + * Removes all children from the container, do a cleanup to all running actions depending on the cleanup parameter, + * and sets the layout dirty flag to true. * @param {Boolean} cleanup true if all running actions on all children nodes should be cleanup, false otherwise. */ removeAllChildrenWithCleanup: function(cleanup){ @@ -310,6 +338,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this._clippingEnabled; }, + /** + *

    + * Calls adaptRenderers (its subclass will override it.) and do layout. + * If clippingEnabled is true, it will clip/scissor area. + *

    + * @override + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx + */ visit: function (ctx) { if (!this._visible) return; @@ -327,9 +363,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ default: break; } - } else { + } else ccui.Widget.prototype.visit.call(this, ctx); - } }, _stencilClippingVisit: null, @@ -563,7 +598,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Sets clipping type + * Sets clipping type to ccui.Layout * @param {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} type */ setClippingType: function (type) { @@ -576,7 +611,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Gets clipping type + * Gets clipping type of ccui.Layout * @returns {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} */ getClippingType: function () { @@ -596,10 +631,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } }, - rendererVisitCallBack: function () { - this._doLayout(); - }, - _getClippingRect: function () { if (this._clippingRectDirty) { var worldPos = this.convertToWorldSpace(cc.p(0, 0)); @@ -692,7 +723,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get background image is use scale9 renderer. + * Get whether background image is use scale9 renderer. * @returns {Boolean} */ isBackGroundImageScale9Enabled: function () { @@ -770,7 +801,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Gets background image cap insets. + * Gets background image capinsets of ccui.Layout. * @returns {cc.Rect} */ getBackGroundImageCapInsets: function () { @@ -800,9 +831,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } }, - /** - * init background image renderer. - */ _addBackGroundImage: function () { if (this._backGroundScale9Enabled) { this._backGroundImage = ccui.Scale9Sprite.create(); @@ -814,7 +842,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Remove the background image of layout. + * Remove the background image of ccui.Layout. */ removeBackGroundImage: function () { if (!this._backGroundImage) @@ -827,7 +855,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Sets Color Type for layout. + * Sets Color Type for ccui.Layout. * @param {ccui.Layout.BG_COLOR_NONE|ccui.Layout.BG_COLOR_SOLID|ccui.Layout.BG_COLOR_GRADIENT} type */ setBackGroundColorType: function (type) { @@ -864,14 +892,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Layout.BG_COLOR_NONE: break; case ccui.Layout.BG_COLOR_SOLID: - this._colorRender = cc.LayerColor.create(); + this._colorRender = new cc.LayerColor(); this._colorRender.setContentSize(this._contentSize); this._colorRender.setOpacity(this._opacity); this._colorRender.setColor(this._color); this.addProtectedChild(this._colorRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1); break; case ccui.Layout.BG_COLOR_GRADIENT: - this._gradientRender = cc.LayerGradient.create(cc.color(255, 0, 0, 255), cc.color(0, 255, 0, 255)); + this._gradientRender = new cc.LayerGradient(cc.color(255, 0, 0, 255), cc.color(0, 255, 0, 255)); this._gradientRender.setContentSize(this._contentSize); this._gradientRender.setOpacity(this._opacity); this._gradientRender.setStartColor(this._startColor); @@ -885,7 +913,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get background color type. + * Get background color type of ccui.Layout. * @returns {ccui.Layout.BG_COLOR_NONE|ccui.Layout.BG_COLOR_SOLID|ccui.Layout.BG_COLOR_GRADIENT} */ getBackGroundColorType: function () { @@ -920,7 +948,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get back ground color + * Gets background color of ccui.Layout, if color type is Layout.COLOR_SOLID. * @returns {cc.Color} */ getBackGroundColor: function () { @@ -929,7 +957,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get back ground start color + * Gets background start color of ccui.Layout * @returns {cc.Color} */ getBackGroundStartColor: function () { @@ -938,7 +966,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get back ground end color + * Gets background end color of ccui.Layout * @returns {cc.Color} */ getBackGroundEndColor: function () { @@ -947,7 +975,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Sets background opacity layout. + * Sets background opacity to ccui.Layout. * @param {number} opacity */ setBackGroundColorOpacity: function (opacity) { @@ -967,7 +995,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get background opacity value. + * Get background opacity value of ccui.Layout. * @returns {Number} */ getBackGroundColorOpacity: function () { @@ -987,7 +1015,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get background color value. + * Gets background color vector of ccui.Layout, if color type is Layout.COLOR_GRADIENT * @returns {cc.Point} */ getBackGroundColorVector: function () { @@ -1007,7 +1035,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Gets backGround image Opacity + * Sets backGround image Opacity * @param {Number} opacity */ setBackGroundImageOpacity: function (opacity) { @@ -1016,7 +1044,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get backGround image color + * Gets backGround image color * @returns {cc.Color} */ getBackGroundImageColor: function () { @@ -1025,7 +1053,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Get backGround image opacity + * Gets backGround image opacity * @returns {Number} */ getBackGroundImageOpacity: function () { @@ -1046,7 +1074,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Sets LayoutType. + * Sets LayoutType to ccui.Layout, LayoutManager will do layout by layout type.. * @param {ccui.Layout.ABSOLUTE|ccui.Layout.LINEAR_VERTICAL|ccui.Layout.LINEAR_HORIZONTAL|ccui.Layout.RELATIVE} type */ setLayoutType: function (type) { @@ -1062,7 +1090,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * Gets LayoutType. + * Gets LayoutType of ccui.Layout. * @returns {null} */ getLayoutType: function () { @@ -1070,7 +1098,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * request do layout + * request do layout, it will do layout at visit calls */ requestDoLayout: function () { this._doLayoutDirty = true; @@ -1134,7 +1162,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * get the content size of the layout, it will accumulate all its children's content size + * Gets the content size of the layout, it will accumulate all its children's content size * @returns {cc.Size} * @private */ @@ -1740,19 +1768,74 @@ ccui.Layout.create = function () { // Constants //layoutBackGround color type +/** + * The None of ccui.Layout's background color type + * @constant + * @type {number} + */ ccui.Layout.BG_COLOR_NONE = 0; +/** + * The solid of ccui.Layout's background color type, it will use a LayerColor to draw the background. + * @constant + * @type {number} + */ ccui.Layout.BG_COLOR_SOLID = 1; +/** + * The gradient of ccui.Layout's background color type, it will use a LayerGradient to draw the background. + * @constant + * @type {number} + */ ccui.Layout.BG_COLOR_GRADIENT = 2; //Layout type +/** + * The absolute of ccui.Layout's layout type. + * @type {number} + * @constant + */ ccui.Layout.ABSOLUTE = 0; +/** + * The vertical of ccui.Layout's layout type. + * @type {number} + * @constant + */ ccui.Layout.LINEAR_VERTICAL = 1; +/** + * The horizontal of ccui.Layout's layout type. + * @type {number} + * @constant + */ ccui.Layout.LINEAR_HORIZONTAL = 2; +/** + * The relative of ccui.Layout's layout type. + * @type {number} + * @constant + */ ccui.Layout.RELATIVE = 3; //Layout clipping type +/** + * The stencil of ccui.Layout's clipping type. + * @type {number} + * @constant + */ ccui.Layout.CLIPPING_STENCIL = 0; +/** + * The scissor of ccui.Layout's clipping type. + * @type {number} + * @constant + */ ccui.Layout.CLIPPING_SCISSOR = 1; +/** + * The zOrder value of ccui.Layout's image background. + * @type {number} + * @constant + */ ccui.Layout.BACKGROUND_IMAGE_ZORDER = -2; +/** + * The zOrder value of ccui.Layout's color background. + * @type {number} + * @constant + */ ccui.Layout.BACKGROUND_RENDERER_ZORDER = -2; \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index bdfc713b40..6440d97cc6 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -22,6 +22,11 @@ THE SOFTWARE. ****************************************************************************/ +/** + * Gets the layout manager by ccui.Layout's layout type. + * @param {Number} type + * @returns {ccui.linearVerticalLayoutManager|ccui.linearHorizontalLayoutManager|ccui.relativeLayoutManager|null} + */ ccui.getLayoutManager = function (type) { switch (type) { case ccui.Layout.LINEAR_VERTICAL: @@ -34,7 +39,12 @@ ccui.getLayoutManager = function (type) { return null; }; -ccui.linearVerticalLayoutManager = { +/** + * The linear vertical layout manager for ccui.Layout, it has a _doLayout function to do layout. + * @namespace + * @name ccui.linearVerticalLayoutManager + */ +ccui.linearVerticalLayoutManager = /** @lends ccui.linearVerticalLayoutManager# */{ _doLayout: function(layout){ var layoutSize = layout._getLayoutContentSize(); var container = layout._getLayoutElements(); @@ -75,7 +85,12 @@ ccui.linearVerticalLayoutManager = { } }; -ccui.linearHorizontalLayoutManager = { +/** + * The linear horizontal layout manager for ccui.Layout, it has a _doLayout function to do layout. + * @namespace + * @name ccui.linearHorizontalLayoutManager + */ +ccui.linearHorizontalLayoutManager = /** @lends ccui.linearHorizontalLayoutManager# */{ _doLayout: function(layout){ var layoutSize = layout._getLayoutContentSize(); var container = layout._getLayoutElements(); @@ -114,7 +129,12 @@ ccui.linearHorizontalLayoutManager = { } }; -ccui.relativeLayoutManager = { +/** + * The relative layout manager for ccui.Layout, it has a _doLayout function to do layout. + * @namespace + * @name ccui.relativeLayoutManager + */ +ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ _unlayoutChildCount: 0, _widgetChildren: [], _widget: null, diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 3f876d38d8..cfe07da250 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -27,12 +27,24 @@ * Base class for ccui.Margin * @class * @extends ccui.Class + * + * @property {Number} left - Left of margin + * @property {Number} top - Top of margin + * @property {Number} right - right of margin + * @property {Number} bottom - bottom of margin */ ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ left: 0, top: 0, right: 0, bottom: 0, + /** + * + * @param {Number|ccui.Margin} margin a margin or left + * @param {Number} [top] + * @param {Number} [right] + * @param {Number} [bottom] + */ ctor: function (margin, top, right, bottom) { if (margin && top === undefined) { this.left = margin.left; @@ -48,11 +60,11 @@ ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ } }, /** - * set margin - * @param {Number} l - * @param {Number} t - * @param {Number} r - * @param {Number} b + * Sets boundary of margin + * @param {Number} l left + * @param {Number} t top + * @param {Number} r right + * @param {Number} b bottom */ setMargin: function (l, t, r, b) { this.left = l; @@ -61,7 +73,7 @@ ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ this.bottom = b; }, /** - * check is equals + * Checks target whether equals itself. * @param {ccui.Margin} target * @returns {boolean} */ @@ -70,25 +82,35 @@ ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ } }); +/** + * Gets a zero margin object + * @function + * @returns {ccui.Margin} + */ ccui.MarginZero = function(){ return new ccui.Margin(0,0,0,0); }; /** - * Layout parameter define + * Layout parameter contains a margin and layout parameter type. It uses for ccui.LayoutManager. * @class * @extends ccui.Class */ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ _margin: null, _layoutParameterType: null, + + /** + * The constructor of ccui.LayoutParameter. + * @function + */ ctor: function () { this._margin = new ccui.Margin(); this._layoutParameterType = ccui.LayoutParameter.NONE; }, /** - * Sets Margin parameter for LayoutParameter. + * Sets Margin to LayoutParameter. * @param {ccui.Margin} margin */ setMargin: function (margin) { @@ -106,7 +128,7 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ }, /** - * Gets Margin parameter of LayoutParameter. + * Gets Margin of LayoutParameter. * @returns {ccui.Margin} */ getMargin: function () { @@ -115,12 +137,16 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ /** * Gets LayoutParameterType of LayoutParameter. - * @returns {ccui.UILayoutParameterType} + * @returns {Number} */ getLayoutType: function () { return this._layoutParameterType; }, + /** + * Clones a ccui.LayoutParameter object from itself. + * @returns {ccui.LayoutParameter} + */ clone:function(){ var parameter = this._createCloneInstance(); parameter._copyProperties(this); @@ -132,11 +158,11 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * @returns {ccui.LayoutParameter} */ _createCloneInstance:function(){ - return ccui.LayoutParameter.create(); + return new ccui.LayoutParameter(); }, /** - * copy properties + * copy properties from model. * @param {ccui.LayoutParameter} model */ _copyProperties:function(model){ @@ -161,17 +187,36 @@ ccui.LayoutParameter.create = function () { // Constants //layout parameter type +/** + * The none of ccui.LayoutParameter's type. + * @constant + * @type {number} + */ ccui.LayoutParameter.NONE = 0; +/** + * The linear of ccui.LayoutParameter's type. + * @constant + * @type {number} + */ ccui.LayoutParameter.LINEAR = 1; +/** + * The relative of ccui.LayoutParameter's type. + * @constant + * @type {number} + */ ccui.LayoutParameter.RELATIVE = 2; /** - * Base class for ccui.LinearLayoutParameter + * The linear of Layout parameter. its parameter type is ccui.LayoutParameter.LINEAR. * @class * @extends ccui.LayoutParameter */ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearLayoutParameter# */{ _linearGravity: null, + /** + * The constructor of ccui.LinearLayoutParameter. + * @function + */ ctor: function () { ccui.LayoutParameter.prototype.ctor.call(this); this._linearGravity = ccui.LinearLayoutParameter.NONE; @@ -179,7 +224,7 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL }, /** - * Sets LinearGravity parameter for LayoutParameter. + * Sets LinearGravity to LayoutParameter. * @param {Number} gravity */ setGravity: function (gravity) { @@ -187,25 +232,17 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL }, /** - * Gets LinearGravity parameter for LayoutParameter. + * Gets LinearGravity of LayoutParameter. * @returns {Number} */ getGravity: function () { return this._linearGravity; }, - /** - * create clone instance. - * @returns {ccui.LinearLayoutParameter} - */ _createCloneInstance: function () { return ccui.LinearLayoutParameter.create(); }, - /** - * copy properties - * @param {ccui.LinearLayoutParameter} model - */ _copyProperties: function (model) { ccui.LayoutParameter.prototype._copyProperties.call(this, model); if (model instanceof ccui.LinearLayoutParameter) @@ -227,16 +264,52 @@ ccui.LinearLayoutParameter.create = function () { // Constants //Linear layout parameter LinearGravity +/** + * The none of ccui.LinearLayoutParameter's linear gravity. + * @constant + * @type {number} + */ ccui.LinearLayoutParameter.NONE = 0; + +/** + * The left of ccui.LinearLayoutParameter's linear gravity. + * @constant + * @type {number} + */ ccui.LinearLayoutParameter.LEFT = 1; +/** + * The top of ccui.LinearLayoutParameter's linear gravity. + * @constant + * @type {number} + */ ccui.LinearLayoutParameter.TOP = 2; +/** + * The right of ccui.LinearLayoutParameter's linear gravity. + * @constant + * @type {number} + */ ccui.LinearLayoutParameter.RIGHT = 3; +/** + * The bottom of ccui.LinearLayoutParameter's linear gravity. + * @constant + * @type {number} + */ ccui.LinearLayoutParameter.BOTTOM = 4; +/** + * The center vertical of ccui.LinearLayoutParameter's linear gravity. + * @constant + * @type {number} + */ ccui.LinearLayoutParameter.CENTER_VERTICAL = 5; +/** + * The center horizontal of ccui.LinearLayoutParameter's linear gravity. + * @constant + * @type {number} + */ ccui.LinearLayoutParameter.CENTER_HORIZONTAL = 6; /** - * Base class for ccui.RelativeLayoutParameter + * The relative of layout parameter. Its layout parameter type is ccui.LayoutParameter.RELATIVE. * @class * @extends ccui.LayoutParameter */ @@ -245,6 +318,10 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat _relativeWidgetName: "", _relativeLayoutName: "", _put:false, + /** + * The constructor of ccui.RelativeLayoutParameter + * @function + */ ctor: function () { ccui.LayoutParameter.prototype.ctor.call(this); this._relativeAlign = ccui.RelativeLayoutParameter.NONE; @@ -256,7 +333,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat /** * Sets RelativeAlign parameter for LayoutParameter. - * @param {ccui.RELATIVE_ALIGN_*} align + * @param {Number} align */ setAlign: function (align) { this._relativeAlign = align; @@ -264,7 +341,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat /** * Gets RelativeAlign parameter for LayoutParameter. - * @returns {ccui.RELATIVE_ALIGN_*} + * @returns {Number} */ getAlign: function () { return this._relativeAlign; @@ -302,18 +379,10 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat return this._relativeLayoutName; }, - /** - * create clone instance. - * @returns {ccui.RelativeLayoutParameter} - */ _createCloneInstance:function(){ return ccui.RelativeLayoutParameter.create(); }, - /** - * copy properties - * @param {ccui.RelativeLayoutParameter} model - */ _copyProperties:function(model){ ccui.LayoutParameter.prototype._copyProperties.call(this, model); if (model instanceof ccui.RelativeLayoutParameter) { @@ -325,8 +394,9 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat }); /** - * allocates and initializes a RelativeLayoutParameter. - * @constructs + * Allocates and initializes a RelativeLayoutParameter. + * @function + * @deprecated * @return {ccui.RelativeLayoutParameter} * @example * // example @@ -338,30 +408,140 @@ ccui.RelativeLayoutParameter.create = function () { // Constants //Relative layout parameter RelativeAlign +/** + * The none of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.NONE = 0; +/** + * The parent's top left of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_TOP_LEFT = 1; +/** + * The parent's top center horizontal of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL = 2; +/** + * The parent's top right of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT = 3; +/** + * The parent's left center vertical of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL = 4; +/** + * The center in parent of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.CENTER_IN_PARENT = 5; +/** + * The parent's right center vertical of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL = 6; +/** + * The parent's left bottom of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM = 7; +/** + * The parent's bottom center horizontal of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL = 8; +/** + * The parent's right bottom of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM = 9; +/** + * The location above left align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN = 10; +/** + * The location above center of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER = 11; +/** + * The location above right align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN = 12; +/** + * The location left of top align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN = 13; +/** + * The location left of center of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER = 14; +/** + * The location left of bottom align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN = 15; +/** + * The location right of top align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN = 16; +/** + * The location right of center of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER = 17; +/** + * The location right of bottom align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN = 18; +/** + * The location below left align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN = 19; +/** + * The location below center of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER = 20; +/** + * The location below right align of ccui.RelativeLayoutParameter's relative align. + * @constant + * @type {number} + */ ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN = 21; /** diff --git a/extensions/ccui/layouts/UIRelativeBox.js b/extensions/ccui/layouts/UIRelativeBox.js index 86a0b3863e..5d57eb0f98 100644 --- a/extensions/ccui/layouts/UIRelativeBox.js +++ b/extensions/ccui/layouts/UIRelativeBox.js @@ -24,11 +24,28 @@ ****************************************************************************/ /** - * The Relative box for Cocos UI layout. + * The Relative box for Cocos UI layout. Its layout type is ccui.Layout.RELATIVE. * @class * @extends ccui.Layout */ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ + /** + * The constructor of ccui.RelativeBox + * @function + * @param {cc.Size} [size] + */ + ctor: function(size){ + if(size) + this.initWithSize(size); + else + this.init(); + }, + + /** + * Initializes a relative box + * @override + * @returns {boolean} + */ init: function(){ if(ccui.Layout.prototype.init.call(this)){ this.setLayoutType(ccui.Layout.RELATIVE); @@ -37,6 +54,11 @@ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ return false; }, + /** + * Initializes a relative box with size + * @param {cc.Size} [size] + * @returns {boolean} + */ initWithSize: function(size){ if(this.init()){ this.setContentSize(size); @@ -46,14 +68,12 @@ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ } }); +/** + * Creates a relative box + * @deprecated + * @param {cc.Size} size + * @returns {ccui.RelativeBox} + */ ccui.RelativeBox.create = function(size){ - var widget = new ccui.RelativeBox(); - if(size){ - if(widget.initWithSize(size)) - return widget; - } else { - if(widget.init()) - return widget; - } - return null; + return new ccui.RelativeBox(size); }; \ No newline at end of file diff --git a/extensions/ccui/layouts/UIVBox.js b/extensions/ccui/layouts/UIVBox.js index 9cf3d85bc5..93357320ac 100644 --- a/extensions/ccui/layouts/UIVBox.js +++ b/extensions/ccui/layouts/UIVBox.js @@ -24,11 +24,28 @@ ****************************************************************************/ /** - * The vertical box of Cocos UI. + * The vertical box of Cocos UI. Its layout type is ccui.Layout.LINEAR_VERTICAL. * @class * @extends ccui.Layout */ ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ + /** + * The constructor of ccui.VBox + * @function + * @param {cc.Size} size + */ + ctor: function(size){ + if(size) + this.initWithSize(size); + else + this.init(); + }, + + /** + * Initializes a VBox. + * @override + * @returns {boolean} + */ init: function(){ if(ccui.Layout.prototype.init.call(this)){ this.setLayoutType(ccui.Layout.LINEAR_VERTICAL); @@ -36,6 +53,12 @@ ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ } return false; }, + + /** + * Initializes a VBox with size. + * @param {cc.Size} size + * @returns {boolean} + */ initWithSize: function(size){ if(this.init()){ this.setContentSize(size); @@ -45,14 +68,11 @@ ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ } }); +/** + * Creates a VBox + * @param {cc.Size} size + * @returns {ccui.VBox} + */ ccui.VBox.create = function(size){ - var widget = new ccui.VBox(); - if(size){ - if(widget.initWithSize(size)) - return widget; - } else { - if(widget.init()) - return widget; - } - return null; + return new ccui.VBox(size); }; \ No newline at end of file diff --git a/extensions/ccui/system/CocosGUI.js b/extensions/ccui/system/CocosGUI.js index 3ddb231317..30622d0c97 100644 --- a/extensions/ccui/system/CocosGUI.js +++ b/extensions/ccui/system/CocosGUI.js @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ + /** - * Base namespace of Cocos GUI + * The namespace of Cocos UI * @namespace * @name ccui */ @@ -55,7 +56,7 @@ ccui.ProtectedNode = ccui.ProtectedNode || cc.ProtectedNode; ccui.ProtectedNode.extend = ccui.ProtectedNode.extend || cc.ProtectedNode.extend; /** - * Cocos GUI version + * Cocos UI version * @type {String} */ ccui.cocosGUIVersion = "CocosGUI v1.0.0.0"; \ No newline at end of file diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index e01d0c0514..8551397351 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * UI Helper + * UI Helper object contains some functions for seek widget * @namespace * @name ccui.helper */ @@ -95,7 +95,12 @@ ccui.helper = { return null; }, - /*temp action*/ + /** + * Finds a widget whose action tag equals to param name from root widget. + * @param {ccui.Widget} root + * @param {Number} tag + * @returns {ccui.Widget} + */ seekActionWidgetByActionTag: function (root, tag) { if (!root) return null; diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index ea9b145634..3a9969f4fd 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.Button + * The button controls of Cocos UI. * @class * @extends ccui.Widget * From e0a78d982f7adbeb2053a8c56324a75a139f1a0b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 26 Aug 2014 11:00:51 +0800 Subject: [PATCH 0523/1564] Issue #5829: ctor and init jsdoc --- cocos2d/actions/CCAction.js | 39 ++--- cocos2d/actions/CCActionCamera.js | 6 +- cocos2d/actions/CCActionCatmullRom.js | 40 +++-- cocos2d/actions/CCActionEase.js | 44 +++--- cocos2d/actions/CCActionInstant.js | 70 +++++---- cocos2d/actions/CCActionInterval.js | 191 ++++++++++++++--------- cocos2d/actions3d/CCActionGrid.js | 9 +- cocos2d/actions3d/CCActionGrid3D.js | 97 +++++++++--- cocos2d/actions3d/CCActionTiledGrid.js | 67 +++++--- cocos2d/audio/CCAudio.js | 6 +- cocos2d/clipping-nodes/CCClippingNode.js | 10 +- 11 files changed, 354 insertions(+), 225 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 85e99a66df..ee135695e3 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -50,7 +50,7 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ //**************Public Functions*********** /** - * Constructor of cc.Action. + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor:function () { this.originalTarget = null; @@ -242,7 +242,7 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ _duration:0, /** - * Constructor of cc.FiniteTimeAction. + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor:function () { cc.Action.prototype.ctor.call(this); @@ -300,14 +300,15 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ * @warning This action can't be Sequenceable because it is not an cc.IntervalAction * @class * @extends cc.Action + * @param {cc.ActionInterval} action + * @param {Number} speed */ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ _speed:0.0, _innerAction:null, /** - * Constructor of cc.Speed. - * + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {cc.ActionInterval} action * @param {Number} speed */ @@ -473,6 +474,19 @@ cc.Speed.create = cc.speed; * @property {Number} topBoundary - world topBoundary. * @property {Number} bottomBoundary - world bottomBoundary. * + * @param {cc.Node} followedNode + * @param {cc.Rect} rect + * @example + * // creates the action with a set boundary + * var sprite = new cc.Sprite("spriteFileName"); + * var followAction = new cc.Follow(sprite, cc.rect(0, 0, s.width * 2 - 100, s.height)); + * this.runAction(followAction); + * + * // creates the action with no boundary set + * var sprite = new cc.Sprite("spriteFileName"); + * var followAction = new cc.Follow(sprite); + * this.runAction(followAction); + * * @class * @extends cc.Action */ @@ -494,22 +508,11 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ bottomBoundary:0.0, /** + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    * creates the action with a set boundary.
    * creates the action with no boundary set. - * - * Constructor of cc.Follow - * @param {cc.Node} followedNode - * @param {cc.Rect} rect - * @example - * // creates the action with a set boundary - * var sprite = new cc.Sprite("spriteFileName"); - * var followAction = new cc.Follow(sprite, cc.rect(0, 0, s.width * 2 - 100, s.height)); - * this.runAction(followAction); - * - * // creates the action with no boundary set - * var sprite = new cc.Sprite("spriteFileName"); - * var followAction = new cc.Follow(sprite); - * this.runAction(followAction); + * @param {cc.Node} followedNode + * @param {cc.Rect} rect */ ctor:function (followedNode, rect) { cc.Action.prototype.ctor.call(this); diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 97e3592b35..5ac61d7ef2 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -41,7 +41,7 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{ _upZOrig:0, /** - * Constructor of cc.ActionCamera. + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor:function(){ var _t = this; @@ -126,8 +126,8 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ _radDeltaX: 0.0, /** - * creates a cc.OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX - * Constructor of cc.OrbitCamera + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates a cc.OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX. * @param {Number} t time * @param {Number} radius * @param {Number} deltaRadius diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index 4296e92904..ecc7b6babf 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -135,6 +135,9 @@ cc.reverseControlPointsInline = function (controlPoints) { * * @class * @extends cc.ActionInterval + * @param {Number} duration + * @param {Array} points array of control points + * @param {Number} tension * * @example * //create a cc.CardinalSplineTo @@ -149,16 +152,11 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# * _accumulatedDiff:null, /** - * Creates an action with a Cardinal Spline array of points and tension - * - * Constructor of cc.CardinalSplineTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates an action with a Cardinal Spline array of points and tension. * @param {Number} duration * @param {Array} points array of control points * @param {Number} tension - * - * @example - * //create a cc.CardinalSplineTo - * var action1 = new cc.CardinalSplineTo(3, array, 0); */ ctor: function (duration, points, tension) { cc.ActionInterval.prototype.ctor.call(this); @@ -335,6 +333,9 @@ cc.CardinalSplineTo.create = cc.cardinalSplineTo; * * @class * @extends cc.CardinalSplineTo + * @param {Number} duration + * @param {Array} points + * @param {Number} tension * * @example * //create a cc.CardinalSplineBy @@ -344,9 +345,8 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy# _startPosition:null, /** - * creates an action with a Cardinal Spline array of points and tension - * - * Constructor of cc.CardinalSplineBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates an action with a Cardinal Spline array of points and tension. * @param {Number} duration * @param {Array} points * @param {Number} tension @@ -471,6 +471,8 @@ cc.CardinalSplineBy.create = cc.cardinalSplineBy; * * @class * @extends cc.CardinalSplineTo + * @param {Number} dt + * @param {Array} points * * @example * var action1 = cc.catmullRomTo(3, array); @@ -478,14 +480,10 @@ cc.CardinalSplineBy.create = cc.cardinalSplineBy; cc.CatmullRomTo = cc.CardinalSplineTo.extend(/** @lends cc.CatmullRomTo# */{ /** - * creates an action with a Cardinal Spline array of points and tension - * - * Constructor of cc.CatmullRomTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates an action with a Cardinal Spline array of points and tension. * @param {Number} dt * @param {Array} points - * - * @example - * var action1 = new cc.CatmullRomTo(3, array); */ ctor: function(dt, points) { points && this.initWithDuration(dt, points); @@ -546,6 +544,8 @@ cc.CatmullRomTo.create = cc.catmullRomTo; * * @class * @extends cc.CardinalSplineBy + * @param {Number} dt + * @param {Array} points * * @example * var action1 = cc.catmullRomBy(3, array); @@ -553,14 +553,10 @@ cc.CatmullRomTo.create = cc.catmullRomTo; cc.CatmullRomBy = cc.CardinalSplineBy.extend({ /** - * Creates an action with a Cardinal Spline array of points and tension - * - * Constructor of cc.CatmullRomBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates an action with a Cardinal Spline array of points and tension. * @param {Number} dt * @param {Array} points - * - * @example - * var action1 = new cc.CatmullRomBy(3, array); */ ctor: function(dt, points) { cc.CardinalSplineBy.prototype.ctor.call(this); diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 9dd9b140f8..9ad27382cb 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -28,18 +28,18 @@ * Base class for Easing actions * @class * @extends cc.ActionInterval + * @param {cc.ActionInterval} action + * + * @example + * var moveEase = new cc.ActionEase(action); */ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ _inner:null, /** - * creates the action of ActionEase - * - * Constructor of cc.ActionEase + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates the action of ActionEase. * @param {cc.ActionInterval} action - * - * @example - * var moveEase = new cc.ActionEase(action); */ ctor: function (action) { cc.ActionInterval.prototype.ctor.call(this); @@ -153,20 +153,21 @@ cc.ActionEase.create = cc.actionEase; * * @class * @extends cc.ActionEase + * @param {cc.ActionInterval} action + * @param {Number} rate + * + * @example + * // example + * var moveEaseRateAction = new cc.EaseRateAction(action, 3.0); */ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ _rate:0, /** - * Creates the action with the inner action and the rate parameter - * - * Constructor of cc.EaseRateAction + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates the action with the inner action and the rate parameter. * @param {cc.ActionInterval} action * @param {Number} rate - * - * @example - * // example - * var moveEaseRateAction = new cc.EaseRateAction(action, 3.0); */ ctor: function(action, rate){ cc.ActionEase.prototype.ctor.call(this); @@ -973,19 +974,20 @@ cc.easeSineInOut = function(){ * Ease Elastic abstract class. * @class * @extends cc.ActionEase + * @param {cc.ActionInterval} action + * @param {Number} [period=0.3] + * @example + * // example + * var moveEaseElastic = new cc.EaseElastic(action, 3.0); */ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ _period: 0.3, - /** Creates the action with the inner action and the period in radians (default is 0.3) - * - * Constructor of cc.EaseElastic + /** + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates the action with the inner action and the period in radians (default is 0.3). * @param {cc.ActionInterval} action * @param {Number} [period=0.3] - * - * @example - * // example - * var moveEaseElastic = new cc.EaseElastic(action, 3.0); */ ctor:function(action, period){ cc.ActionEase.prototype.ctor.call(this); @@ -1933,6 +1935,7 @@ cc.easeBackInOut = function(){ * According to the set point, calculate the trajectory. * @class * @extends cc.ActionEase + * @param {cc.Action} action */ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ @@ -1942,6 +1945,7 @@ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ _p3: null, /** + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    * Initialization requires the application of Bessel curve of action. * @param {cc.Action} action */ diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index 067c747d04..43c2f3fc31 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -260,19 +260,19 @@ cc.ToggleVisibility.create = cc.toggleVisibility; * Delete self in the next frame. * @class * @extends cc.ActionInstant + * @param {Boolean} [isNeedCleanUp=true] + * + * @example + * // example + * var removeSelfAction = new cc.RemoveSelf(false); */ cc.RemoveSelf = cc.ActionInstant.extend({ _isNeedCleanUp: true, /** + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    * Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. - * - * Constructor of cc.RemoveSelf * @param {Boolean} [isNeedCleanUp=true] - * - * @example - * // example - * var removeSelfAction = new cc.RemoveSelf(false); */ ctor:function(isNeedCleanUp){ cc.FiniteTimeAction.prototype.ctor.call(this); @@ -290,7 +290,7 @@ cc.RemoveSelf = cc.ActionInstant.extend({ }, /** - * Init the cc.RemoveSelf with isNeedCleanUp. + * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. * @param isNeedCleanUp * @returns {boolean} */ @@ -347,18 +347,18 @@ cc.RemoveSelf.create = cc.removeSelf; * Flips the sprite horizontally. * @class * @extends cc.ActionInstant + * @param {Boolean} flip Indicate whether the target should be flipped or not + * + * @example + * var flipXAction = new cc.FlipX(true); */ cc.FlipX = cc.ActionInstant.extend(/** @lends cc.FlipX# */{ _flippedX:false, /** - * Create a FlipX action to flip or unflip the target - * - * Constructor of cc.FlipX + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a FlipX action to flip or unflip the target. * @param {Boolean} flip Indicate whether the target should be flipped or not - * - * @example - * var flipXAction = new cc.FlipX(true); */ ctor:function(flip){ cc.FiniteTimeAction.prototype.ctor.call(this); @@ -434,17 +434,18 @@ cc.FlipX.create = cc.flipX; * Flips the sprite vertically * @class * @extends cc.ActionInstant + * @param {Boolean} flip + * @example + * var flipYAction = new cc.FlipY(true); */ cc.FlipY = cc.ActionInstant.extend(/** @lends cc.FlipY# */{ _flippedY:false, /** - * Create a FlipY action to flip or unflip the target + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a FlipY action to flip or unflip the target. * - * Constructor of cc.FlipY * @param {Boolean} flip - * @example - * var flipYAction = new cc.FlipY(true); */ ctor: function(flip){ cc.FiniteTimeAction.prototype.ctor.call(this); @@ -521,20 +522,21 @@ cc.FlipY.create = cc.flipY; * Places the node in a certain position * @class * @extends cc.ActionInstant + * @param {cc.Point|Number} pos + * @param {Number} [y] + * @example + * var placeAction = new cc.Place.create(cc.p(200, 200)); + * var placeAction = new cc.Place.create(200, 200); */ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ _x: 0, _y: 0, /** - * Creates a Place action with a position - * - * Constructor of cc.Place + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates a Place action with a position. * @param {cc.Point|Number} pos * @param {Number} [y] - * @example - * var placeAction = new cc.Place.create(cc.p(200, 200)); - * var placeAction = new cc.Place.create(200, 200); */ ctor:function(pos, y){ cc.FiniteTimeAction.prototype.ctor.call(this); @@ -615,6 +617,16 @@ cc.Place.create = cc.place; * Calls a 'callback'. * @class * @extends cc.ActionInstant + * @param {function} selector + * @param {object|null} [selectorTarget] + * @param {*|null} [data] data for function, it accepts all data types. + * @example + * // example + * // CallFunc without data + * var finish = new cc.CallFunc(this.removeSprite, this); + * + * // CallFunc with data + * var finish = new cc.CallFunc(this.removeFromParentAndCleanup, this, true); */ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ _selectorTarget:null, @@ -623,19 +635,11 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{ _data:null, /** - * Creates a CallFunc action with the callback - * - * Constructor of cc.CallFunc + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates a CallFunc action with the callback. * @param {function} selector * @param {object|null} [selectorTarget] * @param {*|null} [data] data for function, it accepts all data types. - * @example - * // example - * // CallFunc without data - * var finish = new cc.CallFunc(this.removeSprite, this); - * - * // CallFunc with data - * var finish = new cc.CallFunc(this.removeFromParentAndCleanup, this, true); */ ctor:function(selector, selectorTarget, data){ cc.FiniteTimeAction.prototype.ctor.call(this); diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index e69878c72a..158caba1cc 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -39,9 +39,9 @@ * * @class * @extends cc.FiniteTimeAction - * @Example - * // example - * var pingPongAction = cc.sequence(action, action.reverse()); + * @param {Number} d duration in seconds + * @example + * var actionInterval = new cc.ActionInterval(3); */ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _elapsed:0, @@ -54,10 +54,8 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _speedMethod: false,//Compatible with speed class, Discard after can be deleted /** - * constructor of cc.ActionInterval + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} d duration in seconds - * @example - * var actionInterval = new cc.ActionInterval(3); */ ctor:function (d) { this._speed = 1; @@ -332,21 +330,23 @@ cc.ActionInterval.create = cc.actionInterval; * Runs actions sequentially, one after another. * @class * @extends cc.ActionInterval + * @param {Array|cc.FiniteTimeAction} tempArray + * @example + * // create sequence with actions + * var seq = new cc.Sequence(act1, act2); + * + * // create sequence with array + * var seq = new cc.Sequence(actArray); */ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ _actions:null, _split:null, _last:0, - /** Create an array of sequenceable actions - * Constructor of cc.Sequence + /** + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create an array of sequenceable actions. * @param {Array|cc.FiniteTimeAction} tempArray - * @example - * // create sequence with actions - * var seq = new cc.Sequence(act1, act2); - * - * // create sequence with array - * var seq = new cc.Sequence(actArray); */ ctor:function (tempArray) { cc.ActionInterval.prototype.ctor.call(this); @@ -532,6 +532,10 @@ cc.Sequence._actionOneTwo = function (actionOne, actionTwo) { * To repeat an action forever use the CCRepeatForever action. * @class * @extends cc.ActionInterval + * @param {cc.FiniteTimeAction} action + * @param {Number} times + * @example + * var rep = new cc.Repeat(cc.sequence(jump2, jump1), 5); */ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ _times:0, @@ -541,12 +545,10 @@ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{ _innerAction:null, //CCFiniteTimeAction /** - * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) - * Constructor of cc.Repeat + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30). * @param {cc.FiniteTimeAction} action * @param {Number} times - * @example - * var rep = new cc.Repeat(cc.sequence(jump2, jump1), 5); */ ctor: function (action, times) { cc.ActionInterval.prototype.ctor.call(this); @@ -714,15 +716,17 @@ cc.Repeat.create = cc.repeat; * @warning This action can't be Sequenceable because it is not an IntervalAction * @class * @extends cc.ActionInterval + * @param {cc.FiniteTimeAction} action + * @example + * var rep = new cc.RepeatForever(cc.sequence(jump2, jump1), 5); */ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{ _innerAction:null, //CCActionInterval /** - * Create a acton which repeat forever + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a acton which repeat forever. * @param {cc.FiniteTimeAction} action - * @example - * var repeat = cc.rotateBy(1.0, 360).repeatForever(); */ ctor:function (action) { cc.ActionInterval.prototype.ctor.call(this); @@ -839,6 +843,9 @@ cc.repeatForever = function (action) { * @deprecated since v3.0
    Please use cc.repeatForever instead. * @param {cc.FiniteTimeAction} action * @return {cc.RepeatForever} + * @param {Array|cc.FiniteTimeAction} tempArray + * @example + * var action = new cc.Spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720)); */ cc.RepeatForever.create = cc.repeatForever; @@ -852,10 +859,8 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ _two:null, /** - * Constructor of cc.Spawn + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Array|cc.FiniteTimeAction} tempArray - * @example - * var action = new cc.Spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720)); */ ctor:function (tempArray) { cc.ActionInterval.prototype.ctor.call(this); @@ -1013,6 +1018,11 @@ cc.Spawn._actionOneTwo = function (action1, action2) { * The direction will be decided by the shortest angle. * @class * @extends cc.ActionInterval + * @param {Number} duration duration in seconds + * @param {Number} deltaAngleX deltaAngleX in degrees. + * @param {Number} [deltaAngleY] deltaAngleY in degrees. + * @example + * var rotateTo = new cc.RotateTo(2, 61.0); */ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ _dstAngleX:0, @@ -1024,13 +1034,11 @@ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{ _diffAngleY:0, /** - * Creates a RotateTo action with x and y rotation angles - * Constructor of cc.RotateTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates a RotateTo action with x and y rotation angles. * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees. * @param {Number} [deltaAngleY] deltaAngleY in degrees. - * @example - * var rotateTo = new cc.RotateTo(2, 61.0); */ ctor:function (duration, deltaAngleX, deltaAngleY) { cc.ActionInterval.prototype.ctor.call(this); @@ -1148,6 +1156,11 @@ cc.RotateTo.create = cc.rotateTo; * Relative to its properties to modify. * @class * @extends cc.ActionInterval + * @param {Number} duration duration in seconds + * @param {Number} deltaAngleX deltaAngleX in degrees + * @param {Number} [deltaAngleY] deltaAngleY in degrees + * @example + * var actionBy = new cc.RotateBy(2, 360); */ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ _angleX:0, @@ -1156,12 +1169,10 @@ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{ _startAngleY:0, /** - * Constructor of cc.RotateBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration duration in seconds * @param {Number} deltaAngleX deltaAngleX in degrees * @param {Number} [deltaAngleY] deltaAngleY in degrees - * @example - * var actionBy = new cc.RotateBy(2, 360); */ ctor: function (duration, deltaAngleX, deltaAngleY) { cc.ActionInterval.prototype.ctor.call(this); @@ -1268,6 +1279,11 @@ cc.RotateBy.create = cc.rotateBy; *

    * @class * @extends cc.ActionInterval + * @param {Number} duration duration in seconds + * @param {cc.Point|Number} deltaPos + * @param {Number} [deltaY] + * @example + * var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40)); */ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ _positionDelta:null, @@ -1275,12 +1291,11 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ _previousPosition:null, /** - * Constructor of cc.MoveBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration duration in seconds * @param {cc.Point|Number} deltaPos * @param {Number} [deltaY] * @example - * var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40)); */ ctor:function (duration, deltaPos, deltaY) { cc.ActionInterval.prototype.ctor.call(this); @@ -1412,17 +1427,20 @@ cc.MoveBy.create = cc.moveBy; * movement will be the sum of individual movements. * @class * @extends cc.MoveBy + * @param {Number} duration duration in seconds + * @param {cc.Point|Number} position + * @param {Number} y + * @example + * var actionBy = new cc.MoveTo(2, cc.p(80, 80)); */ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{ _endPosition:null, /** - * Constructor of cc.MoveTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration duration in seconds * @param {cc.Point|Number} position * @param {Number} y - * @example - * var actionBy = new cc.MoveTo(2, cc.p(80, 80)); */ ctor:function (duration, position, y) { cc.MoveBy.prototype.ctor.call(this); @@ -1505,6 +1523,11 @@ cc.MoveTo.create = cc.moveTo; * Skews a cc.Node object to given angles by modifying it's skewX and skewY attributes * @class * @extends cc.ActionInterval + * @param {Number} t time in seconds + * @param {Number} sx + * @param {Number} sy + * @example + * var actionTo = new cc.SkewTo(2, 37.2, -37.2); */ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ _skewX:0, @@ -1517,12 +1540,10 @@ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{ _deltaY:0, /** - * Constructor of cc.SkewTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} t time in seconds * @param {Number} sx * @param {Number} sy - * @example - * var actionTo = new cc.SkewTo(2, 37.2, -37.2); */ ctor: function (t, sx, sy) { cc.ActionInterval.prototype.ctor.call(this); @@ -1624,11 +1645,14 @@ cc.SkewTo.create = cc.skewTo; * Relative to its attribute modification. * @class * @extends cc.SkewTo + * @param {Number} t time in seconds + * @param {Number} sx skew in degrees for X axis + * @param {Number} sy skew in degrees for Y axis */ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{ /** - * Constructor of cc.SkewBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} t time in seconds * @param {Number} sx skew in degrees for X axis * @param {Number} sy skew in degrees for Y axis @@ -1724,6 +1748,14 @@ cc.SkewBy.create = cc.skewBy; * Relative to its movement. * @class * @extends cc.ActionInterval + * @param {Number} duration + * @param {cc.Point|Number} position + * @param {Number} [y] + * @param {Number} height + * @param {Number} jumps + * @example + * var actionBy = new cc.JumpBy(2, cc.p(300, 0), 50, 4); + * var actionBy = new cc.JumpBy(2, 300, 0, 50, 4); */ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ _startPosition:null, @@ -1733,15 +1765,12 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{ _previousPosition:null, /** - * Constructor of JumpBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] * @param {Number} height * @param {Number} jumps - * @example - * var actionBy = new cc.JumpBy(2, cc.p(300, 0), 50, 4); - * var actionBy = new cc.JumpBy(2, 300, 0, 50, 4); */ ctor:function (duration, position, y, height, jumps) { cc.ActionInterval.prototype.ctor.call(this); @@ -1886,20 +1915,25 @@ cc.JumpBy.create = cc.jumpBy; * Jump to the specified location. * @class * @extends cc.JumpBy + * @param {Number} duration + * @param {cc.Point|Number} position + * @param {Number} [y] + * @param {Number} height + * @param {Number} jumps + * @example + * var actionTo = new cc.JumpTo(2, cc.p(300, 0), 50, 4); + * var actionTo = new cc.JumpTo(2, 300, 0, 50, 4); */ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{ _endPosition:null, /** - * Constructor of JumpTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] * @param {Number} height * @param {Number} jumps - * @example - * var actionTo = new cc.JumpTo(2, cc.p(300, 0), 50, 4); - * var actionTo = new cc.JumpTo(2, 300, 0, 50, 4); */ ctor:function (duration, position, y, height, jumps) { cc.JumpBy.prototype.ctor.call(this); @@ -2006,6 +2040,11 @@ cc.bezierAt = function (a, b, c, d, t) { * Relative to its movement. * @class * @extends cc.ActionInterval + * @param {Number} t time in seconds + * @param {Array} c Array of points + * @example + * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; + * var bezierForward = new cc.BezierBy(3, bezier); */ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ _config:null, @@ -2013,12 +2052,9 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ _previousPosition:null, /** - * Constructor of BezierBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} t time in seconds * @param {Array} c Array of points - * @example - * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; - * var bezierForward = new cc.BezierBy(3, bezier); */ ctor:function (t, c) { cc.ActionInterval.prototype.ctor.call(this); @@ -2028,6 +2064,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ c && this.initWithDuration(t, c); }, + /** * Initializes the action. * @param {Number} t time in seconds @@ -2160,16 +2197,19 @@ cc.BezierBy.create = cc.bezierBy; /** An action that moves the target with a cubic Bezier curve to a destination point. * @class * @extends cc.BezierBy + * @param {Number} t + * @param {Array} c array of points + * @example + * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; + * var bezierTo = new cc.BezierTo(2, bezier); */ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{ _toConfig:null, /** - * Constructor of cc.BezierTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} t * @param {Array} c array of points - * @example - * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)]; * var bezierTo = new cc.BezierTo(2, bezier); */ ctor:function (t, c) { @@ -2247,6 +2287,15 @@ cc.BezierTo.create = cc.bezierTo; * @warning This action doesn't support "reverse" * @class * @extends cc.ActionInterval + * @param {Number} duration + * @param {Number} sx scale parameter in X + * @param {Number} [sy] scale parameter in Y, if Null equal to sx + * @example + * // It scales to 0.5 in both X and Y. + * var actionTo = new cc.ScaleTo(2, 0.5); + * + * // It scales to 0.5 in x and 2 in Y + * var actionTo = new cc.ScaleTo(2, 0.5, 2); */ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ _scaleX:1, @@ -2259,16 +2308,10 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ _deltaY:0, /** - * Constructor of cc.ScaleTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration * @param {Number} sx scale parameter in X * @param {Number} [sy] scale parameter in Y, if Null equal to sx - * @example - * // It scales to 0.5 in both X and Y. - * var actionTo = new cc.ScaleTo(2, 0.5); - * - * // It scales to 0.5 in x and 2 in Y - * var actionTo = new cc.ScaleTo(2, 0.5, 2); */ ctor:function (duration, sx, sy) { cc.ActionInterval.prototype.ctor.call(this); @@ -3064,15 +3107,16 @@ cc.DelayTime.create = cc.delayTime; *

    * @class * @extends cc.ActionInterval + * @param {cc.FiniteTimeAction} action + * @example + * var reverse = new cc.ReverseTime(this); */ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{ _other:null, /** - * Constructor of cc.ReverseTime + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {cc.FiniteTimeAction} action - * @example - * var reverse = new cc.ReverseTime(this); */ ctor:function (action) { cc.ActionInterval.prototype.ctor.call(this); @@ -3172,6 +3216,10 @@ cc.ReverseTime.create = cc.reverseTime; /** Animates a sprite given the name of an Animation * @class * @extends cc.ActionInterval + * @param {cc.Animation} animation + * @example + * // create the animation with animation + * var anim = new cc.Animate(dance_grey); */ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ _animation:null, @@ -3181,12 +3229,9 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ _splitTimes:null, /** - * Constructor of cc.Animate - * create the animate with animation + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * create the animate with animation. * @param {cc.Animation} animation - * @example - * // create the animation with animation - * var anim = new cc.Animate(dance_grey); */ ctor:function (animation) { cc.ActionInterval.prototype.ctor.call(this); @@ -3366,14 +3411,16 @@ cc.Animate.create = cc.animate; *

    * @class * @extends cc.ActionInterval + * @param {cc.Node} target + * @param {cc.FiniteTimeAction} action */ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{ _action:null, _forcedTarget:null, /** - * Create an action with the specified action and forced target - * Constructor of cc.TargetedAction + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create an action with the specified action and forced target. * @param {cc.Node} target * @param {cc.FiniteTimeAction} action */ diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index 7d1513e038..d7aa8530a6 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -28,13 +28,14 @@ * Base class for Grid actions * @class * @extends cc.ActionInterval + * @param {Number} duration + * @param {cc.Size} gridSize */ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ _gridSize:null, /** - * Creates a grid action with duration and grid size - * Constructor of cc.GridAction + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration * @param {cc.Size} gridSize */ @@ -312,13 +313,13 @@ cc.StopGrid.create = cc.stopGrid; * cc.ReuseGrid action * @class * @extends cc.ActionInstant + * @param {Number} times */ cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{ _times:null, /** - * creates an action with the number of times that the current grid will be reused - * Constructor of cc.ReuseGrid + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} times */ ctor: function(times) { diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index 139f378a17..f9372d5782 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -25,9 +25,14 @@ ****************************************************************************/ /** - * cc.Waves3D action. + * cc.Waves3D action.
    + * Reference the test cases (Effects Advanced Test) * @class * @extends cc.Grid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude */ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ _waves: 0, @@ -35,7 +40,8 @@ cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{ _amplitudeRate: 0, /** - * Create a wave 3d action with duration, grid size, waves and amplitude + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a wave 3d action with duration, grid size, waves and amplitude. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -143,15 +149,17 @@ cc.Waves3D.create = cc.waves3D; /** * cc.FlipX3D action.
    - * Flip around. + * Flip around.
    + * Reference the test cases (Effects Test) * @class * @extends cc.Grid3DAction + * @param {Number} duration */ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ /** - * Create a Flip X 3D action with duration - * Constructor of cc.FlipX3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a Flip X 3D action with duration. * @param {Number} duration */ ctor: function(duration) { @@ -276,15 +284,17 @@ cc.FlipX3D.create = cc.flipX3D; /** * cc.FlipY3D action.
    - * Upside down. + * Upside down.
    + * Reference the test cases (Effects Test) * @class * @extends cc.FlipX3D + * @param {Number} duration */ cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{ /** - * Create a flip Y 3d action with duration - * Constructor of cc.FlipY3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a flip Y 3d action with duration. * @param {Number} duration */ ctor: function(duration) { @@ -385,9 +395,14 @@ cc.FlipY3D.create = cc.flipY3D; /** * cc.Lens3D action.
    - * Upside down. + * Upside down.
    + * Reference the test cases (Effects Test) * @class * @extends cc.FlipX3D + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {cc.Point} position + * @param {Number} radius */ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ //lens center position @@ -400,8 +415,8 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ _dirty:false, /** - * creates a lens 3d action with center position, radius - * Constructor of cc.Lens3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates a lens 3d action with center position, radius. * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -552,9 +567,16 @@ cc.lens3D = function (duration, gridSize, position, radius) { cc.Lens3D.create = cc.lens3D; /** - * cc.Ripple3D action + * cc.Ripple3D action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.Grid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {cc.Point} position + * @param {Number} radius + * @param {Number} waves + * @param {Number} amplitude */ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ /* center position */ @@ -565,8 +587,8 @@ cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{ _amplitudeRate: 0, /** - * creates a ripple 3d action with radius, number of waves, amplitude - * Constructor of cc.Ripple3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates a ripple 3d action with radius, number of waves, amplitude. * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position @@ -714,17 +736,22 @@ cc.ripple3D = function (duration, gridSize, position, radius, waves, amplitude) cc.Ripple3D.create = cc.ripple3D; /** - * cc.Shaky3D action + * cc.Shaky3D action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.Grid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} range + * @param {Boolean} shakeZ */ cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{ _randRange: 0, _shakeZ: false, /** - * Create a shaky3d action with a range, shake Z vertices - * Constructor of cc.Shaky3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a shaky3d action with a range, shake Z vertices. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -803,9 +830,14 @@ cc.shaky3D = function (duration, gridSize, range, shakeZ) { cc.Shaky3D.create = cc.shaky3D; /** - * cc.Liquid action + * cc.Liquid action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.Grid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude */ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ _waves: 0, @@ -813,8 +845,8 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ _amplitudeRate: 0, /** - * Create a liquid action with amplitude, a grid and duration - * Constructor of cc.Liquid + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a liquid action with amplitude, a grid and duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -924,9 +956,16 @@ cc.liquid = function (duration, gridSize, waves, amplitude) { cc.Liquid.create = cc.liquid; /** - * cc.Waves action + * cc.Waves action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.Grid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude + * @param {Boolean} horizontal + * @param {Boolean} vertical */ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ _waves: 0, @@ -936,8 +975,8 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ _horizontal: false, /** - * Create a wave action with amplitude, horizontal sin, vertical sin, a grid and duration - * Constructor of cc.Waves + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a wave action with amplitude, horizontal sin, vertical sin, a grid and duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -1061,9 +1100,15 @@ cc.Waves.create = cc.waves; /** @brief */ /** - * cc.Twirl action + * cc.Twirl action.
    + * Reference the test cases (Effects Test) * @class * @extends cc.Grid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {cc.Point} position + * @param {Number} twirls + * @param {Number} amplitude */ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ /* twirl center */ @@ -1073,8 +1118,8 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ _amplitudeRate: 0, /** - * Create a grid 3d action with center position, number of twirls, amplitude, a grid size and duration - * Constructor of cc.Twirl + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a grid 3d action with center position, number of twirls, amplitude, a grid size and duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index 7c187b19d7..41be41b231 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -29,14 +29,18 @@ * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} range + * @param {Boolean} shakeZ */ cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{ _randRange:0, _shakeZ:false, /** - * Creates the action with a range, whether or not to shake Z vertices, a grid size, and duration.
    - * Constructor of cc.ShakyTiles3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates the action with a range, whether or not to shake Z vertices, a grid size, and duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -135,6 +139,10 @@ cc.ShakyTiles3D.create = cc.shakyTiles3D; * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} range + * @param {Boolean} shatterZ */ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D# */{ _randRange:0, @@ -142,8 +150,8 @@ cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D _shatterZ:false, /** - * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration.
    - * Constructor of cc.ShatteredTiles3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} range @@ -259,6 +267,9 @@ cc.Tile = function (position, startPosition, delta) { * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} seed */ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ _seed:0, @@ -267,8 +278,8 @@ cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{ _tiles:null, /** - * Creates the action with a random seed, the grid size and the duration.
    - * Constructor of cc.ShuffleTiles + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates the action with a random seed, the grid size and the duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} seed @@ -681,6 +692,15 @@ cc.FadeOutDownTiles.create = cc.fadeOutDownTiles; * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number|Null} [seed=0] + * @example + * // turnOffTiles without seed + * var toff = new cc.TurnOffTiles(this._duration, cc.size(x, y)); + * + * // turnOffTiles with seed + * var toff = new cc.TurnOffTiles(this._duration, cc.size(x, y), 0); */ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ _seed:null, @@ -688,16 +708,11 @@ cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{ _tilesOrder:null, /** + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    * Creates the action with a random seed, the grid size and the duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number|Null} [seed=0] - * @example - * // turnOffTiles without seed - * var toff = new cc.TurnOffTiles(this._duration, cc.size(x, y)); - * - * // turnOffTiles with seed - * var toff = new cc.TurnOffTiles(this._duration, cc.size(x, y), 0); */ ctor:function (duration, gridSize, seed) { cc.GridAction.prototype.ctor.call(this); @@ -823,6 +838,10 @@ cc.TurnOffTiles.create = cc.turnOffTiles; * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} waves + * @param {Number} amplitude */ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ _waves:0, @@ -830,8 +849,8 @@ cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{ _amplitudeRate:0, /** - * creates the action with a number of waves, the waves amplitude, the grid size and the duration - * Constructor of cc.WavesTiles3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates the action with a number of waves, the waves amplitude, the grid size and the duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} waves @@ -947,6 +966,10 @@ cc.WavesTiles3D.create = cc.wavesTiles3D; * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {cc.Size} gridSize + * @param {Number} numberOfJumps + * @param {Number} amplitude */ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ _jumps:0, @@ -954,8 +977,8 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ _amplitudeRate:0, /** - * creates the action with the number of jumps, the sin amplitude, the grid size and the duration - * Constructor of cc.JumpTiles3D + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates the action with the number of jumps, the sin amplitude, the grid size and the duration. * @param {Number} duration * @param {cc.Size} gridSize * @param {Number} numberOfJumps @@ -1086,14 +1109,16 @@ cc.JumpTiles3D.create = cc.jumpTiles3D; * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {Number} rows */ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ _rows:0, _winSize:null, /** - * creates the action with the number of rows to split and the duration - * Constructor of cc.SplitRows + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates the action with the number of rows to split and the duration. * @param {Number} duration * @param {Number} rows */ @@ -1176,14 +1201,16 @@ cc.SplitRows.create = cc.splitRows; * Reference the test cases (Effects Test) * @class * @extends cc.TiledGrid3DAction + * @param {Number} duration + * @param {Number} cols */ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ _cols:0, _winSize:null, /** - * Creates the action with the number of columns to split and the duration - * Constructor of cc.SplitCols + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Creates the action with the number of columns to split and the duration. * @param {Number} duration * @param {Number} cols */ diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index a3c5563953..ec53b28e43 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -29,6 +29,7 @@ if (cc.sys._supportWebAudio) { /** * A class of Web Audio. * @class + * @param src * @extends cc.Class */ cc.WebAudio = cc.Class.extend({ @@ -58,7 +59,7 @@ if (cc.sys._supportWebAudio) { _loadState: -1,//-1 : not loaded, 0 : waiting, 1 : loaded, -2 : load failed /** - * creates an WebAudio with the src. + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param src */ ctor: function (src) { @@ -338,7 +339,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ _playings: [],//only store when window is hidden /** - * creates an audio. + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor: function () { var self = this; @@ -776,6 +777,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { /** * Extended AudioEngine for single audio mode. + * @namespace */ cc.AudioEngineForSingle = cc.AudioEngine.extend({ _waitingEffIds: [], diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index f92fa91817..b5eeb4cf4a 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -64,6 +64,7 @@ cc.setProgram = function (node, program) { *

    * @class * @extends cc.Node + * @param {cc.Node} [stencil=null] * * @property {Number} alphaThreshold - Threshold for alpha value. * @property {Boolean} inverted - Indicate whether in inverted mode. @@ -77,9 +78,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ _godhelpme: false, /** - * Creates and initializes a clipping node with an other node as its stencil. - * The stencil node will be retained. - * Constructor of cc.ClippingNode + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {cc.Node} [stencil=null] */ ctor: function (stencil) { @@ -93,11 +92,12 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ }, /** - * Initializes a clipping node with an other node as its stencil.
    - * The stencil node will be retained, and its parent will be set to this clipping node. + * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. + * @function * @param {cc.Node} [stencil=null] */ init: null, + _className: "ClippingNode", _initForWebGL: function (stencil) { From 72dc145768440c7dcf6cfdb9d9a0836d17a99eda Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 26 Aug 2014 11:04:00 +0800 Subject: [PATCH 0524/1564] Issue #5829: ctor and init jsdoc --- cocos2d/actions/CCActionInterval.js | 42 +++++++++++++++++++---------- cocos2d/actions/CCActionTween.js | 6 ++++- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 158caba1cc..47dffb5cdd 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2472,17 +2472,19 @@ cc.ScaleBy.create = cc.scaleBy; /** Blinks a cc.Node object by modifying it's visible attribute * @class * @extends cc.ActionInterval + * @param {Number} duration duration in seconds + * @param {Number} blinks blinks in times + * @example + * var action = new cc.Blink(2, 10); */ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{ _times:0, _originalState:false, /** - * Constructor of cc.Blink + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration duration in seconds * @param {Number} blinks blinks in times - * @example - * var action = new cc.Blink(2, 10); */ ctor:function (duration, blinks) { cc.ActionInterval.prototype.ctor.call(this); @@ -2583,17 +2585,19 @@ cc.Blink.create = cc.blink; * @warning This action doesn't support "reverse" * @class * @extends cc.ActionInterval + * @param {Number} duration + * @param {Number} opacity 0-255, 0 is transparent + * @example + * var action = new cc.FadeTo(1.0, 0); */ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ _toOpacity:0, _fromOpacity:0, /** - * Constructor of cc.FadeTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration * @param {Number} opacity 0-255, 0 is transparent - * @example - * var action = new cc.FadeTo(1.0, 0); */ ctor:function (duration, opacity) { cc.ActionInterval.prototype.ctor.call(this); @@ -2674,12 +2678,13 @@ cc.FadeTo.create = cc.fadeTo; * The "reverse" of this action is FadeOut * @class * @extends cc.FadeTo + * @param {Number} duration duration in seconds */ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ _reverseAction: null, /** - * @constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration duration in seconds */ ctor:function (duration) { @@ -2748,11 +2753,12 @@ cc.FadeIn.create = cc.fadeIn; * The "reverse" of this action is FadeIn * @class * @extends cc.FadeTo + * @param {Number} duration duration in seconds */ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ /** - * @constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration duration in seconds */ ctor:function (duration) { @@ -2811,19 +2817,23 @@ cc.FadeOut.create = cc.fadeOut; * @warning This action doesn't support "reverse" * @class * @extends cc.ActionInterval + * @param {Number} duration + * @param {Number} red 0-255 + * @param {Number} green 0-255 + * @param {Number} blue 0-255 + * @example + * var action = new cc.TintTo(2, 255, 0, 255); */ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{ _to:null, _from:null, /** - * Constructor of cc.TintTo + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration * @param {Number} red 0-255 * @param {Number} green 0-255 * @param {Number} blue 0-255 - * @example - * var action = new cc.TintTo(2, 255, 0, 255); */ ctor:function (duration, red, green, blue) { cc.ActionInterval.prototype.ctor.call(this); @@ -2919,6 +2929,12 @@ cc.TintTo.create = cc.tintTo; * Relative to their own color change. * @class * @extends cc.ActionInterval + * @param {Number} duration duration in seconds + * @param {Number} deltaRed + * @param {Number} deltaGreen + * @param {Number} deltaBlue + * @example + * var action = new cc.TintBy(2, -127, -255, -127); */ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ _deltaR:0, @@ -2930,13 +2946,11 @@ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{ _fromB:0, /** - * Constructor of cc.TintBy + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} duration duration in seconds * @param {Number} deltaRed * @param {Number} deltaGreen * @param {Number} deltaBlue - * @example - * var action = new cc.TintBy(2, -127, -255, -127); */ ctor:function (duration, deltaRed, deltaGreen, deltaBlue) { cc.ActionInterval.prototype.ctor.call(this); diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js index 0c3e7f6057..12490a4146 100644 --- a/cocos2d/actions/CCActionTween.js +++ b/cocos2d/actions/CCActionTween.js @@ -54,6 +54,10 @@ cc.ActionTweenDelegate = cc.Class.extend(/** @lends cc.ActionTweenDelegate */{ * // scaleA and scaleB are equivalents * var scaleA = cc.scaleTo(2,3); * var scaleB = cc.actionTween(2,"scale",1,3); + * @param {Number} duration + * @param {String} key + * @param {Number} from + * @param {Number} to */ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ key:"", @@ -62,8 +66,8 @@ cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{ delta:0, /** + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    * Creates an initializes the action with the property name (key), and the from and to parameters. - * Constructor of cc.ActionTween * @param {Number} duration * @param {String} key * @param {Number} from From 3319a02408458cf408f9fa2939be0f65865cc5fa Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 26 Aug 2014 11:20:04 +0800 Subject: [PATCH 0525/1564] Fixed #2170: fixed not working frameRate setting. --- CCBoot.js | 61 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index dc413d4e43..4ff8338af8 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1557,33 +1557,42 @@ cc._setup = function (el, width, height) { var win = window; var lastTime = new Date(); var frameTime = 1000 / cc.game.config[cc.game.CONFIG_KEY.frameRate]; - win.requestAnimFrame = win.requestAnimationFrame || - win.webkitRequestAnimationFrame || - win.mozRequestAnimationFrame || - win.oRequestAnimationFrame || - win.msRequestAnimationFrame || - function(callback){ - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, frameTime - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - win.cancelAnimationFrame = window.cancelAnimationFrame || - window.cancelRequestAnimationFrame || - window.msCancelRequestAnimationFrame || - window.mozCancelRequestAnimationFrame || - window.oCancelRequestAnimationFrame || - window.webkitCancelRequestAnimationFrame || - window.msCancelAnimationFrame || - window.mozCancelAnimationFrame || - window.webkitCancelAnimationFrame || - window.oCancelAnimationFrame || - function(id){ - clearTimeout(id); - }; + var stTime = function(callback){ + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, frameTime - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }; + + var ctTime = function(id){ + clearTimeout(id); + }; + + if(cc.game.config[cc.game.CONFIG_KEY.frameRate] != 60){ + win.requestAnimFrame = stTime; + win.cancelAnimationFrame = ctTime; + }else{ + win.requestAnimFrame = win.requestAnimationFrame || + win.webkitRequestAnimationFrame || + win.mozRequestAnimationFrame || + win.oRequestAnimationFrame || + win.msRequestAnimationFrame || + stTime; + win.cancelAnimationFrame = window.cancelAnimationFrame || + window.cancelRequestAnimationFrame || + window.msCancelRequestAnimationFrame || + window.mozCancelRequestAnimationFrame || + window.oCancelRequestAnimationFrame || + window.webkitCancelRequestAnimationFrame || + window.msCancelAnimationFrame || + window.mozCancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.oCancelAnimationFrame || + ctTime; + } var element = cc.$(el) || cc.$('#' + el); var localCanvas, localContainer, localConStyle; From 3297851ad182b918bcf2c4f171e62196bba9702f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 26 Aug 2014 14:22:08 +0800 Subject: [PATCH 0526/1564] Issue #5829: labels jsdoc --- cocos2d/actions/CCAction.js | 2 +- cocos2d/labels/CCLabelAtlas.js | 58 +++++--- cocos2d/labels/CCLabelBMFont.js | 242 +++++++++++++++++++++----------- 3 files changed, 201 insertions(+), 101 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index ee135695e3..9d79a1a059 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -61,7 +61,7 @@ cc.Action = cc.Class.extend(/** @lends cc.Action# */{ /** * to copy object with deep copy. * - * @deprecated since v3.0 + * @deprecated since v3.0 please use .clone * * @return {cc.Action} */ diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index e8ae07a83c..e54eb06c35 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -30,8 +30,23 @@ * @extends cc.AtlasNode * * @property {String} string - Content string of label + * + * @param {String} strText + * @param {String} charMapFile charMapFile or fntFile + * @param {Number} [itemWidth=0] + * @param {Number} [itemHeight=0] + * @param {Number} [startCharMap=""] + * @example + * //creates the cc.LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas + * var myLabel = new cc.LabelAtlas('Text to display', 'CharMapfile.png', 12, 20, ' ') + * + * //creates the cc.LabelAtlas with a string, a fnt file + * var myLabel = new cc.LabelAtlas('Text to display', 'CharMapFile.plist‘); */ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ + + //property String is Getter and Setter + // string to render _string: null, // the first char in the charmap @@ -43,22 +58,17 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ /** *

    - * Create a label atlas. - * It accepts two groups of parameters:
    - * a) string, fntFile
    - * b) label, textureFilename, width, height, startChar
    + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * Create a label atlas.
    + * It accepts two groups of parameters:
    + * a) string, fntFile
    + * b) label, textureFilename, width, height, startChar
    *

    * @param {String} strText * @param {String} charMapFile charMapFile or fntFile * @param {Number} [itemWidth=0] * @param {Number} [itemHeight=0] * @param {Number} [startCharMap=""] - * @example - * //creates the cc.LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas - * var myLabel = new cc.LabelAtlas('Text to display', 'CharMapfile.png', 12, 20, ' ') - * - * //creates the cc.LabelAtlas with a string, a fnt file - * var myLabel = new cc.LabelAtlas('Text to display', 'CharMapFile.plist‘); */ ctor: function (strText, charMapFile, itemWidth, itemHeight, startCharMap) { cc.AtlasNode.prototype.ctor.call(this); @@ -67,7 +77,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ }, /** - * return texture is loaded + * Return texture is loaded. * @returns {boolean} */ textureLoaded: function () { @@ -75,9 +85,9 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ }, /** - * add texture loaded event listener + * Add texture loaded event listener. * @param {Function} callback - * @param {Object} target + * @param {cc.Node} target */ addLoadedEventListener: function (callback, target) { if (!this._loadedEventListeners) @@ -96,13 +106,14 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ } locListeners.length = 0; }, + /** *

    - * initializes the cc.LabelAtlas with a string, a char map file(the atlas),
    - * the width and height of each element and the starting char of the atlas
    - * It accepts two groups of parameters:
    - * a) string, fntFile
    - * b) label, textureFilename, width, height, startChar
    + * initializes the cc.LabelAtlas with a string, a char map file(the atlas),
    + * the width and height of each element and the starting char of the atlas
    + * It accepts two groups of parameters:
    + * a) string, fntFile
    + * b) label, textureFilename, width, height, startChar
    *

    * @param {String} strText * @param {String|cc.Texture2D} charMapFile charMapFile or fntFile or texture file @@ -155,12 +166,14 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ }, /** + * Set the color. * @param {cc.Color} color3 */ setColor: function (color3) { cc.AtlasNode.prototype.setColor.call(this, color3); this.updateAtlasValues(); }, + /** * return the text of this label * @return {String} @@ -188,8 +201,8 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ }, /** - * @function * Atlas generation + * @function */ updateAtlasValues: null, @@ -347,6 +360,11 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ this.quadsToDraw = len; }, + /** + * set the opacity + * @function + * @param {Number} opacity + */ setOpacity: null, _setOpacityForCanvas: function (opacity) { @@ -393,7 +411,7 @@ cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); * a) string, fntFile
    * b) label, textureFilename, width, height, startChar
    *

    - * @deprecated + * @deprecated since v3.0 please use new cc.LabelAtlas * @param {String} strText * @param {String} charMapFile charMapFile or fntFile * @param {Number} [itemWidth=0] diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index f888d511a1..d175b5c73c 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -66,10 +66,31 @@ cc.LABEL_AUTOMATIC_WIDTH = -1; * @extends cc.SpriteBatchNode * * @property {String} string - Content string of label - * @property {enum} textAlign - Horizontal Alignment of label, cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT + * @property {Number} textAlign - Horizontal Alignment of label, cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT * @property {Number} boundingWidth - Width of the bounding box of label, the real content width is limited by boundingWidth + * + * @param {String} str + * @param {String} fntFile + * @param {Number} [width=-1] + * @param {Number} [alignment=cc.TEXT_ALIGNMENT_LEFT] + * @param {cc.Point} [imageOffset=cc.p(0,0)] + * + * @example + * // Example 01 + * var label1 = new cc.LabelBMFont("Test case", "test.fnt"); + * + * // Example 02 + * var label2 = new cc.LabelBMFont("test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT); + * + * // Example 03 + * var label3 = new cc.LabelBMFont("This is a \n test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT, cc.p(0,0)); */ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ + + //property string is Getter and Setter. + //property textAlign is Getter and Setter. + //property boundingWidth is Getter and Setter. + _opacityModifyRGB: false, _string: "", @@ -126,22 +147,13 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * creates a bitmap font atlas with an initial string and the FNT file - * Constructor of cc.LabelBMFont + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates a bitmap font atlas with an initial string and the FNT file. * @param {String} str * @param {String} fntFile * @param {Number} [width=-1] * @param {Number} [alignment=cc.TEXT_ALIGNMENT_LEFT] * @param {cc.Point} [imageOffset=cc.p(0,0)] - * @example - * // Example 01 - * var label1 = new cc.LabelBMFont("Test case", "test.fnt"); - * - * // Example 02 - * var label2 = new cc.LabelBMFont("test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT); - * - * // Example 03 - * var label3 = new cc.LabelBMFont("This is a \n test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT, cc.p(0,0)); */ ctor: function (str, fntFile, width, alignment, imageOffset) { var self = this; @@ -153,6 +165,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this.initWithString(str, fntFile, width, alignment, imageOffset); }, + /** * return texture is loaded * @returns {boolean} @@ -184,6 +197,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Draw this font. * @param {CanvasRenderingContext2D} ctx */ draw: function (ctx) { @@ -232,6 +246,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Set whether to support cc.RGBAProtocol protocol * @param {Boolean} opacityModifyRGB */ setOpacityModifyRGB: function (opacityModifyRGB) { @@ -246,10 +261,18 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } }, + /** + * Gets the real opacity. + * @returns {number} + */ getOpacity: function () { return this._realOpacity; }, + /** + * Gets the display opacity. + * @returns {number} + */ getDisplayedOpacity: function () { return this._displayedOpacity; }, @@ -271,6 +294,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this._displayedColor.a = this._realColor.a = opacity; }, + /** + * Override synthesized update pacity to recurse items + * @param parentOpacity + */ updateDisplayedOpacity: function (parentOpacity) { this._displayedOpacity = this._realOpacity * parentOpacity / 255.0; var locChildren = this._children; @@ -286,23 +313,47 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this._changeTextureColor(); }, + /** + * Checking cascade opacity enabled + * @returns {boolean} + */ isCascadeOpacityEnabled: function () { return false; }, + /** + * Set cascade opacity enabled + * @param {Boolean} cascadeOpacityEnabled + */ setCascadeOpacityEnabled: function (cascadeOpacityEnabled) { this._cascadeOpacityEnabled = cascadeOpacityEnabled; }, + /** + * Gets the real color.
    + * Create a new cc.Color clone in this real color. + * @returns {cc.Color} + */ getColor: function () { var locRealColor = this._realColor; return cc.color(locRealColor.r, locRealColor.g, locRealColor.b, locRealColor.a); }, + /** + * Gets the display color.
    + * Create a new cc.Color clone in this display color. + * @returns {cc.Color} + */ getDisplayedColor: function () { - return this._displayedColor; + var dc = this._displayedColor; + return cc.color(dc.r, dc.g, dc.b, dc.a); }, + /** + * Update the display color.
    + * Only update this label display color. + * @returns {cc.Color} + */ updateDisplayedColor: function (parentColor) { var locDispColor = this._displayedColor; var locRealColor = this._realColor; @@ -347,16 +398,24 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } }, + /** + * Checking cascade color enabled + * @returns {boolean} + */ isCascadeColorEnabled: function () { return false; }, + /** + * Override synthesized setOpacity to recurse items + * @param {Boolean} cascadeColorEnabled + */ setCascadeColorEnabled: function (cascadeColorEnabled) { this._cascadeColorEnabled = cascadeColorEnabled; }, /** - * init LabelBMFont + * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. */ init: function () { return this.initWithString(null, null, null, null, null); @@ -542,7 +601,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * update String + * Update String.
    + * Only update this label displa string. * @param {Boolean} fromUpdate */ updateString: function (fromUpdate) { @@ -562,7 +622,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * get the text of this label + * Gets the text of this label * @return {String} */ getString: function () { @@ -570,7 +630,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * set the text + * Set the text * @param {String} newString * @param {Boolean|null} needUpdateLabel */ @@ -590,7 +650,9 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * @deprecated + * Set the text.
    + * Change this Label display string. + * @deprecated since v3.0 please use .setString * @param label */ setCString: function (label) { @@ -598,7 +660,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * update Label + * Update Label.
    + * Update this Label display string and more... */ updateLabel: function () { var self = this; @@ -663,7 +726,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } // Whitespace. - if (cc.isspace_unicode(character)) { + if (this._isspace_unicode(character)) { last_word.push(character); multiline_string = multiline_string.concat(last_word); last_word.length = 0; @@ -680,7 +743,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var found = multiline_string.lastIndexOf(" "); if (found != -1) - cc.utf8_trim_ws(multiline_string); + this._utf8_trim_ws(multiline_string); else multiline_string = []; @@ -692,7 +755,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ startOfLine = -1; i++; } else { - cc.utf8_trim_ws(last_word); + this._utf8_trim_ws(last_word); last_word.push('\n'); multiline_string = multiline_string.concat(last_word); @@ -794,7 +857,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * Set text alignment + * Set text alignment. * @param {Number} alignment */ setAlignment: function (alignment) { @@ -807,6 +870,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Set the bounding width.
    + * max with display width. The exceeding string will be wrapping. * @param {Number} width */ setBoundingWidth: function (width) { @@ -819,6 +884,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Set the param to change English word warp according to whether the space.
    + * default is false. * @param {Boolean} breakWithoutSpace */ setLineBreakWithoutSpace: function (breakWithoutSpace) { @@ -827,8 +894,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Set scale.
    + * Input a number, will be decrease or increase the font size.
    * @param {Number} scale - * @param {Number} [scaleY=null] + * @param {Number} [scaleY=null] default is scale */ setScale: function (scale, scaleY) { cc.Node.prototype.setScale.call(this, scale, scaleY); @@ -836,6 +905,9 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Set scale of x.
    + * Input a number, will be decrease or increase the font size.
    + * Horizontal scale. * @param {Number} scaleX */ setScaleX: function (scaleX) { @@ -844,6 +916,9 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Set scale of x.
    + * Input a number, will be decrease or increase the font size.
    + * Longitudinal scale. * @param {Number} scaleY */ setScaleY: function (scaleY) { @@ -853,7 +928,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ //TODO /** - * set fnt file path + * set fnt file path.
    + * Change the fnt file path. * @param {String} fntFile */ setFntFile: function (fntFile) { @@ -892,6 +968,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** + * Return the fnt file path. * @return {String} */ getFntFile: function () { @@ -899,7 +976,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * set the AnchorPoint of the labelBMFont + * Set the AnchorPoint of the labelBMFont.
    + * In order to change the location of label. * @override * @param {cc.Point|Number} point The anchor point of labelBMFont or The anchor point.x of labelBMFont. * @param {Number} [y] The anchor point.y of labelBMFont. @@ -913,17 +991,18 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ cc.Node.prototype._setAnchor.call(this, p); this.updateLabel(); }, + _setAnchorX: function (x) { cc.Node.prototype._setAnchorX.call(this, x); this.updateLabel(); }, + _setAnchorY: function (y) { cc.Node.prototype._setAnchorY.call(this, y); this.updateLabel(); }, - _atlasNameFromFntFile: function (fntFile) { - }, + _atlasNameFromFntFile: function (fntFile) {}, _kerningAmountForFirst: function (first, second) { var ret = 0; @@ -942,6 +1021,45 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ _getLetterPosXRight: function (sp) { return sp.getPositionX() * this._scaleX + (sp._getWidth() * this._scaleX * sp._getAnchorX()); + }, + + //Checking whether the character is a whitespace + _isspace_unicode: function(ch){ + ch = ch.charCodeAt(0); + return ((ch >= 9 && ch <= 13) || ch == 32 || ch == 133 || ch == 160 || ch == 5760 + || (ch >= 8192 && ch <= 8202) || ch == 8232 || ch == 8233 || ch == 8239 + || ch == 8287 || ch == 12288) + }, + + _utf8_trim_ws: function(str){ + var len = str.length; + + if (len <= 0) + return; + + var last_index = len - 1; + + // Only start trimming if the last character is whitespace.. + if (this._isspace_unicode(str[last_index])) { + for (var i = last_index - 1; i >= 0; --i) { + if (this._isspace_unicode(str[i])) { + last_index = i; + } + else { + break; + } + } + this._utf8_trim_from(str, last_index); + } + }, + + //Trims str st str=[0, index) after the operation. + //Return value: the trimmed string. + _utf8_trim_from: function(str, index){ + var len = str.length; + if (index >= len || index < 0) + return; + str.splice(index, len); } }); @@ -983,7 +1101,7 @@ cc.defineGetterSetter(_p, "textAlign", _p._getAlignment, _p.setAlignment); /** * creates a bitmap font atlas with an initial string and the FNT file - * @deprecated + * @deprecated since v3.0 please use new cc.LabelBMFont * @param {String} str * @param {String} fntFile * @param {Number} [width=-1] @@ -1004,56 +1122,6 @@ cc.LabelBMFont.create = function (str, fntFile, width, alignment, imageOffset) { return new cc.LabelBMFont(str, fntFile, width, alignment, imageOffset); }; -/** - * @param {String} ch - * @return {Boolean} weather the character is a whitespace character. - */ -cc.isspace_unicode = function (ch) { - ch = ch.charCodeAt(0); - return ((ch >= 9 && ch <= 13) || ch == 32 || ch == 133 || ch == 160 || ch == 5760 - || (ch >= 8192 && ch <= 8202) || ch == 8232 || ch == 8233 || ch == 8239 - || ch == 8287 || ch == 12288) -}; - -/** - * @param {Array} str - */ -cc.utf8_trim_ws = function (str) { - var len = str.length; - - if (len <= 0) - return; - - var last_index = len - 1; - - // Only start trimming if the last character is whitespace.. - if (cc.isspace_unicode(str[last_index])) { - for (var i = last_index - 1; i >= 0; --i) { - if (cc.isspace_unicode(str[i])) { - last_index = i; - } - else { - break; - } - } - cc.utf8_trim_from(str, last_index); - } -}; - -/** - * Trims str st str=[0, index) after the operation. - * Return value: the trimmed string. - * @param {Array} str he string to trim - * @param {Number} index the index to start trimming from. - */ -cc.utf8_trim_from = function (str, index) { - var len = str.length; - if (index >= len || index < 0) - return; - str.splice(index, len); -}; - - cc._fntLoader = { INFO_EXP: /info [^\n]*(\n|$)/gi, COMMON_EXP: /common [^\n]*(\n|$)/gi, @@ -1079,6 +1147,13 @@ cc._fntLoader = { } return obj; }, + + /** + * Parse Fnt string. + * @param fntStr + * @param url + * @returns {{}} + */ parseFnt: function (fntStr, url) { var self = this, fnt = {}; //padding @@ -1089,7 +1164,7 @@ cc._fntLoader = { top: parseInt(paddingArr[1]), right: parseInt(paddingArr[2]), bottom: parseInt(paddingArr[3]) - } + }; //common var commonObj = self._parseStrToObj(fntStr.match(self.COMMON_EXP)[0]); @@ -1132,6 +1207,13 @@ cc._fntLoader = { return fnt; }, + /** + * load the fnt + * @param realUrl + * @param url + * @param res + * @param cb + */ load: function (realUrl, url, res, cb) { var self = this; cc.loader.loadTxt(realUrl, function (err, txt) { From 51dae0b244133bc927edd2cca6b3ed11341b27bf Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 26 Aug 2014 15:12:59 +0800 Subject: [PATCH 0527/1564] Issue #5829: labels jsdoc --- cocos2d/labels/CCLabelAtlas.js | 11 ++++++----- cocos2d/labels/CCLabelBMFont.js | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index e54eb06c35..83d20f1d51 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -406,10 +406,11 @@ cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); /** *

    - * Create a label atlas. - * It accepts two groups of parameters:
    - * a) string, fntFile
    - * b) label, textureFilename, width, height, startChar
    + * Please use new cc.LabelAtlas instead.
    + * Create a label atlas.
    + * It accepts two groups of parameters:
    + * a) string, fntFile
    + * b) label, textureFilename, width, height, startChar
    *

    * @deprecated since v3.0 please use new cc.LabelAtlas * @param {String} strText @@ -417,7 +418,7 @@ cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); * @param {Number} [itemWidth=0] * @param {Number} [itemHeight=0] * @param {Number} [startCharMap=""] - * @return {cc.LabelAtlas|Null} returns the LabelAtlas object on success + * @return {cc.LabelAtlas} returns the LabelAtlas object on success * @example * //Example * //creates the cc.LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index d175b5c73c..17874909d1 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -175,7 +175,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * add texture loaded event listener + * add texture loaded event listener.
    + * Will execute the callback in the loaded. * @param {Function} callback * @param {Object} target */ @@ -238,7 +239,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }, /** - * conforms to cc.RGBAProtocol protocol + * Conforms to cc.RGBAProtocol protocol. * @return {Boolean} */ isOpacityModifyRGB: function () { From bbaf4a144055626557a36ad1aa1949544167cc2e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 26 Aug 2014 15:59:01 +0800 Subject: [PATCH 0528/1564] Issue #5829: text-input jsdoc --- cocos2d/text-input/CCIMEDispatcher.js | 11 ++++-- cocos2d/text-input/CCTextFieldTTF.js | 54 +++++++++++++++++++++------ 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index 613c7d8d77..26a4bc0604 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -43,7 +43,7 @@ cc.IMEKeyboardNotificationInfo = function (begin, end, duration) { */ cc.IMEDelegate = cc.Class.extend(/** @lends cc.IMEDelegate# */{ /** - * Constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor:function () { cc.imeDispatcher.addDelegate(this); @@ -142,13 +142,16 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ _currentInputString:"", _lastClickPosition:null, /** - * Constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor:function () { this.impl = new cc.IMEDispatcher.Impl(); this._lastClickPosition = cc.p(0, 0); }, + /** + * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. + */ init:function () { if (cc.sys.isMobile) return; @@ -487,6 +490,8 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ }); /** + * Create the cc.IMEDispatcher.Imp Object.
    + * This is the inner class... * @class * @extends cc.Class * @name cc.IMEDispatcher.Impl @@ -495,7 +500,7 @@ cc.IMEDispatcher.Impl = cc.Class.extend(/** @lends cc.IMEDispatcher.Impl# */{ _delegateWithIme:null, _delegateList:null, /** - * Constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor:function () { this._delegateList = []; diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index c5b63f719c..3534b3ed61 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -89,6 +89,19 @@ cc.TextFieldDelegate = cc.Class.extend(/** @lends cc.TextFieldDelegate# */{ * @property {Number} charCount - <@readonly> Characators count * @property {String} placeHolder - Place holder for the field * @property {cc.Color} colorSpaceHolder + * + * @param {String} placeholder + * @param {cc.Size} dimensions + * @param {Number} alignment + * @param {String} fontName + * @param {Number} fontSize + * + * @example + * //example + * // When five parameters + * var textField = new cc.TextFieldTTF("", cc.size(100,50), cc.TEXT_ALIGNMENT_LEFT,"Arial", 32); + * // When three parameters + * var textField = new cc.TextFieldTTF("", "Arial", 32); */ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ delegate:null, @@ -101,19 +114,13 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ _className:"TextFieldTTF", /** - * creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size
    - * Constructor of cc.TextFieldTTF + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    + * creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size. * @param {String} placeholder * @param {cc.Size} dimensions * @param {Number} alignment * @param {String} fontName * @param {Number} fontSize - * @example - * //example - * // When five parameters - * var textField = cc.TextFieldTTF.create("", cc.size(100,50), cc.TEXT_ALIGNMENT_LEFT,"Arial", 32); - * // When three parameters - * var textField = cc.TextFieldTTF.create("", "Arial", 32); */ ctor:function (placeholder, dimensions, alignment, fontName, fontSize) { this.colorSpaceHolder = cc.color(127, 127, 127); @@ -132,6 +139,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Gets the delegate. * @return {cc.Node} */ getDelegate:function () { @@ -139,6 +147,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Set the delegate. * @param {cc.Node} value */ setDelegate:function (value) { @@ -146,6 +155,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Gets the char count. * @return {Number} */ getCharCount:function () { @@ -153,6 +163,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Gets the color of space holder. * @return {cc.Color} */ getColorSpaceHolder:function () { @@ -160,11 +171,13 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Gets the color of space holder. * @param {cc.Color} value */ setColorSpaceHolder:function (value) { this.colorSpaceHolder = value; }, + /** * Initializes the cc.TextFieldTTF with a font name, alignment, dimension and font size * @param {String} placeholder @@ -218,6 +231,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Gets the string * @return {String} */ getString:function () { @@ -225,6 +239,8 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Set the place holder.
    + * display this string if string equal "". * @param {String} text */ setPlaceHolder:function (text) { @@ -235,6 +251,8 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Gets the place holder.
    + * default display string. * @return {String} */ getPlaceHolder:function () { @@ -242,7 +260,8 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** - * @param {CanvasContext} ctx + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function. + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ draw:function (ctx) { //console.log("size",this._contentSize); @@ -264,6 +283,10 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this.color = color; }, + /** + * Recursive method that visit its children and draw them. + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx + */ visit: function(ctx){ this._super(ctx); }, @@ -288,6 +311,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Return whether to allow attach with IME. * @return {Boolean} */ canAttachWithIME:function () { @@ -301,6 +325,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Return whether to allow detach with IME. * @return {Boolean} */ canDetachWithIME:function () { @@ -314,7 +339,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** - * Delete backward + * Delete backward */ deleteBackward:function () { var strLen = this._inputText.length; @@ -349,6 +374,8 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** + * Append the text.
    + * Input the character. * @param {String} text * @param {Number} len */ @@ -382,7 +409,9 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ // if delegate hasn't process, detach with ime as default this.detachWithIME(); }, + /** + * Gets the input text. * @return {String} */ getContentText:function () { @@ -414,8 +443,9 @@ cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder); /** - * creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size - * @deprecated + * Please use new TextFieldTTF instead.
    + * Creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size. + * @deprecated since v3.0 Please use new TextFieldTTF instead. * @param {String} placeholder * @param {cc.Size} dimensions * @param {Number} alignment From 974134cea42656334cb9485736d60c5c955e4a0c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 26 Aug 2014 16:36:44 +0800 Subject: [PATCH 0529/1564] Issue #5829: Motionstreak jsdoc --- cocos2d/motion-streak/CCMotionStreak.js | 74 ++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index c1aadd3f96..2b9a3a65c8 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -39,6 +39,9 @@ * @property {cc.Texture2D} texture - Texture used for the motion streak. * @property {Boolean} fastMode - Indicate whether use fast mode. * @property {Boolean} startingPositionInitialized - Indicate whether starting position initialized. + * @example + * //example + * new cc.MotionStreak(2, 3, 32, cc.color.GREEN, s_streak); */ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ texture:null, @@ -55,7 +58,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ _nuPoints:0, _previousNuPoints:0, - /** Pointers */ + /* Pointers */ _pointVertexes:null, _pointState:null, @@ -115,6 +118,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Gets the texture. * @return {cc.Texture2D} */ getTexture:function () { @@ -122,6 +126,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Set the texture. * @param {cc.Texture2D} texture */ setTexture:function (texture) { @@ -130,6 +135,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Gets the blend func. * @return {cc.BlendFunc} */ getBlendFunc:function () { @@ -137,6 +143,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Set the blend func. * @param {Number} src * @param {Number} dst */ @@ -149,22 +156,50 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ } }, + /** + * Gets opacity. + * @warning cc.MotionStreak.getOpacity has not been supported. + * @returns {number} + */ getOpacity:function () { cc.log("cc.MotionStreak.getOpacity has not been supported."); return 0; }, + /** + * Set opacity. + * @warning cc.MotionStreak.setOpacity has not been supported. + * @param opacity + */ setOpacity:function (opacity) { cc.log("cc.MotionStreak.setOpacity has not been supported."); }, + /** + * set opacity modify RGB. + * @warning cc.MotionStreak.setOpacityModifyRGB has not been supported. + * @param value + */ setOpacityModifyRGB:function (value) { }, + /** + * Checking OpacityModifyRGB. + * @returns {boolean} + */ isOpacityModifyRGB:function () { return false; }, + /** + *

    + * callback that is called every time the node leaves the 'stage'.
    + * If the node leaves the 'stage' with a transition, this callback is called when the transition finishes.
    + * During onExit you can't access a sibling node.
    + * If you override onExit, you shall call its parent's onExit with this._super(). + *

    + * @function + */ onExit:function(){ cc.Node.prototype.onExit.call(this); if(this._verticesBuffer) @@ -175,6 +210,10 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ cc._renderContext.deleteBuffer(this._colorPointerBuffer); }, + /** + * Checking fast mode. + * @returns {boolean} + */ isFastMode:function () { return this.fastMode; }, @@ -187,10 +226,18 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this.fastMode = fastMode; }, + /** + * Checking starting position initialized. + * @returns {boolean} + */ isStartingPositionInitialized:function () { return this.startingPositionInitialized; }, + /** + * Set Starting Position Initialized. + * @param {Boolean} startingPositionInitialized + */ setStartingPositionInitialized:function (startingPositionInitialized) { this.startingPositionInitialized = startingPositionInitialized; }, @@ -286,8 +333,10 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** - * @override - * @param {cc.Point} position + * Set the position.
    + * + * @param {cc.Point|Number} position + * @param {Number} [yValue=undefined] If not exists, the first parameter must be cc.Point. */ setPosition:function (position, yValue) { this.startingPositionInitialized = true; @@ -301,6 +350,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Gets the position.x * @return {Number} */ getPositionX:function () { @@ -308,6 +358,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Set the position.x * @param {Number} x */ setPositionX:function (x) { @@ -317,6 +368,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Gets the position.y * @return {Number} */ getPositionY:function () { @@ -324,6 +376,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** + * Set the position.y * @param {Number} y */ setPositionY:function (y) { @@ -333,8 +386,9 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** - * @override - * @param {WebGLRenderingContext} ctx + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function + * @function + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ draw:function (ctx) { if (this._nuPoints <= 1) @@ -369,7 +423,10 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, /** - * @override + *

    schedules the "update" method.
    + * It will use the order number 0. This method will be called every frame.
    + * Scheduled methods with a lower order value will be called before the ones that have a higher order value.
    + * Only one "update" method could be scheduled per node.

    * @param {Number} delta */ update:function (delta) { @@ -494,8 +551,9 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }); /** - * creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename or texture - * @deprecated + * Please use new cc.MotionStreak instead.
    + * Creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename or texture + * @deprecated since v3.0 please use new cc.MotionStreak instead. * @param {Number} fade time to fade * @param {Number} minSeg minimum segment size * @param {Number} stroke stroke's width From 58b7f6bd0a0ce602c5f94c5a015d01b8da5d13a1 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Tue, 26 Aug 2014 17:09:57 +0800 Subject: [PATCH 0530/1564] add doc for folder menus --- cocos2d/menus/CCMenu.js | 62 +++++++----- cocos2d/menus/CCMenuItem.js | 190 ++++++++++++++++++++++++------------ 2 files changed, 167 insertions(+), 85 deletions(-) diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 9ed6de0cd6..7a6f52e24d 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -46,13 +46,14 @@ cc.MENU_HANDLER_PRIORITY = -128; cc.DEFAULT_PADDING = 5; /** - *

    Features and Limitation:
    +

    Features and Limitation:
    * - You can add MenuItem objects in runtime using addChild:
    * - But the only accepted children are MenuItem objects

    * @class * @extends cc.Layer - * - * @property {Boolean} enabled - Indicates whether or not the menu is enabled + * @param {...cc.MenuItem|null} menuItems} + * @example + * var layer = new cc.Menu(menuitem1, menuitem2, menuitem3); */ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ enabled: false, @@ -65,15 +66,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ _className: "Menu", /** - * Constructor of cc.Menu - * @function - * @param {...cc.MenuItem|null} menuItems - * - * @example - * // Example - * //there is no limit on how many menu item you can pass in - * var myMenu1 = cc.Menu.create(menuitem1, menuitem2, menuitem3); - * var myMenu2 = cc.Menu.create([menuitem1, menuitem2, menuitem3]); + * Constructor of cc.Menu override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor: function (menuItems) { cc.Layer.prototype.ctor.call(this); @@ -113,7 +106,14 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ } this.initWithArray(items); }, - + /** + *

    + * Event callback that is invoked every time when CCMenu enters the 'stage'.
    + * If the CCMenu enters the 'stage' with a transition, this event is called when the transition starts.
    + * During onEnter you can't access a "sister/brother" node.
    + * If you override onEnter, you must call its parent's onEnter function with this._super(). + *

    + */ onEnter: function () { var locListener = this._touchListener; if (!locListener._isRegistered()) @@ -122,6 +122,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** + * return the color for cc.Menu * @return {cc.Color} */ getColor: function () { @@ -130,6 +131,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** + * set the color for cc.Menu * @param {cc.Color} color */ setColor: function (color) { @@ -151,6 +153,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** + * return the opacity for this menu * @return {Number} */ getOpacity: function () { @@ -158,6 +161,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** + * set the opacity for this menu * @param {Number} opa */ setOpacity: function (opa) { @@ -205,7 +209,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ /** * initializes a cc.Menu with a Array of cc.MenuItem objects - * @param {Array} arrayOfItems + * @param {Array} array Of cc.MenuItem Items * @return {Boolean} */ initWithArray: function (arrayOfItems) { @@ -237,9 +241,10 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** + * add a child for cc.Menu * @param {cc.Node} child - * @param {Number|Null} [zOrder=] - * @param {Number|Null} [tag=] + * @param {Number|Null} [zOrder=] zOrder for the child + * @param {Number|Null} [tag=] tag for the child */ addChild: function (child, zOrder, tag) { if (!(child instanceof cc.MenuItem)) @@ -389,6 +394,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** * align menu items in rows + * @param {Number} * @example * // Example * menu.alignItemsInRows(5,3)//this will align items to 2 rows, first row with 5 items, second row with 3 @@ -483,8 +489,9 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** - * @param {cc.Node} child - * @param {boolean} cleanup + * remove a child from cc.Menu + * @param {cc.Node} child the child you want to remove + * @param {boolean} cleanup whether to cleanup */ removeChild: function (child, cleanup) { if (child == null) @@ -559,7 +566,12 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ }, /** - * custom on exit + *

    + * callback that is called every time the cc.Menu leaves the 'stage'.
    + * If the cc.Menu leaves the 'stage' with a transition, this callback is called when the transition finishes.
    + * During onExit you can't access a sibling node.
    + * If you override onExit, you shall call its parent's onExit with this._super(). + *

    */ onExit: function () { if (this._state == cc.MENU_STATE_TRACKING_TOUCH) { @@ -571,10 +583,16 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ } cc.Node.prototype.onExit.call(this); }, - + /** + * only use for jsbinding + * @param value + */ setOpacityModifyRGB: function (value) { }, - + /** + * only use for jsbinding + * @returns {boolean} + */ isOpacityModifyRGB: function () { return false; }, @@ -607,7 +625,7 @@ _p.enabled; /** * create a new menu - * @deprecated + * @deprecated since v3.0, please use new cc.Menu(menuitem1, menuitem2, menuitem3) to create a new menu * @param {...cc.MenuItem|null} menuItems * @return {cc.Menu} * @example diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 5add14ac2f..c8c4150541 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -32,8 +32,8 @@ cc._globalFontNameRelease = false; * Subclass cc.MenuItem (or any subclass) to create your custom cc.MenuItem objects. * @class * @extends cc.Node - * - * @property {Boolean} enabled - Indicate whether item is enabled + * @param {function|String} callback + * @param {cc.Node} target */ cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ _enabled: false, @@ -64,16 +64,22 @@ cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ }, /** - * MenuItem is selected + * return whether MenuItem is selected * @return {Boolean} */ isSelected: function () { return this._isSelected; }, - + /** + * only use for jsbinding + * @param value + */ setOpacityModifyRGB: function (value) { }, - + /** + * only use for jsbinding + * @returns {boolean} + */ isOpacityModifyRGB: function () { return false; }, @@ -82,7 +88,7 @@ cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ * set the target/selector of the menu item * @param {function|String} selector * @param {cc.Node} rec - * @deprecated + * @deprecated since v3.0 */ setTarget: function (selector, rec) { this._target = rec; @@ -90,7 +96,7 @@ cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ }, /** - * MenuItem is Enabled + * return whether MenuItem is Enabled * @return {Boolean} */ isEnabled: function () { @@ -106,6 +112,7 @@ cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ }, /** + * initializes a cc.MenuItem with callback * @param {function|String} callback * @param {cc.Node} target * @return {Boolean} @@ -132,14 +139,14 @@ cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ }, /** - * same as setIsSelected(true) + * set the cc.MenuItem selected same as setIsSelected(true) */ selected: function () { this._isSelected = true; }, /** - * same as setIsSelected(false) + * set the cc.MenuItem unselected same as setIsSelected(false) */ unselected: function () { this._isSelected = false; @@ -183,7 +190,7 @@ cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled); /** * creates an empty menu item with target and callback
    * Not recommended to use the base class, should use more defined menu item classes - * @deprecated + * @deprecated since v3.0, please use new cc.MenuItem(callback,target) instead * @param {function|String} callback callback * @param {cc.Node} target * @return {cc.MenuItem} @@ -200,6 +207,11 @@ cc.MenuItem.create = function (callback, target) { * - cc.LabelTTF
    * @class * @extends cc.MenuItem + * @param {cc.Node} label + * @param {function|String} selector + * @param {cc.Node} target + * @example + * var menuitemLabel = new cc.MenuItemLabel(label,selector,target); * * @property {String} string - Content string of label item * @property {cc.Node} label - Label of label item @@ -213,9 +225,6 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ /** * Constructor of cc.MenuItemLabel - * @param {cc.Node} label - * @param {function|String} selector - * @param {cc.Node} target */ ctor: function (label, selector, target) { cc.MenuItem.prototype.ctor.call(this, selector, target); @@ -236,6 +245,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * return the disable color for this cc.MenuItemLabel * @return {cc.Color} */ getDisabledColor: function () { @@ -243,6 +253,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * set the disable color for this cc.MenuItemLabel * @param {cc.Color} color */ setDisabledColor: function (color) { @@ -250,7 +261,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** - * return label of MenuItemLabel + * return label of cc.MenuItemLabel * @return {cc.Node} */ getLabel: function () { @@ -258,6 +269,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * set a label for cc.MenuItemLabel * @param {cc.Node} label */ setLabel: function (label) { @@ -277,6 +289,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * set enable value to cc.MenuItemLabel * @param {Boolean} enabled */ setEnabled: function (enabled) { @@ -293,6 +306,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * set opacity for cc.MenuItemLabel * @param {Number} opacity from 0-255 */ setOpacity: function (opacity) { @@ -300,6 +314,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * return the opacity of cc.MenuItemLabel * @return {Number} */ getOpacity: function () { @@ -307,6 +322,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * set the opacity for cc.MenuItemLabel * @param {cc.Color} color */ setColor: function (color) { @@ -314,6 +330,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * return the color of cc.MenuItemLabel * @return {cc.Color} */ getColor: function () { @@ -321,6 +338,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * initializes a cc.MenuItemLabel with a label * @param {cc.Node} label * @param {function|String} selector * @param {cc.Node} target @@ -340,6 +358,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ }, /** + * set the string for cc.MenuItemLabel * @param {String} label */ setString: function (label) { @@ -347,7 +366,10 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ this.width = this._label.width; this.height = this._label.height; }, - + /** + * return the string of cc.MenuItemLabel + * @returns {*|string|_p.string|ret.string|q.string|String} + */ getString: function () { return this._label.string; }, @@ -411,7 +433,7 @@ cc.defineGetterSetter(_p, "label", _p.getLabel, _p.setLabel); /** - * @deprecated + * @deprecated since v3.0 ,please use new cc.MenuItemLabel(label,selector,target) instead * @param {cc.Node} label * @param {function|String|Null} [selector=] * @param {cc.Node|Null} [target=] @@ -425,17 +447,20 @@ cc.MenuItemLabel.create = function (label, selector, target) { * Helper class that creates a MenuItemLabel class with a LabelAtlas * @class * @extends cc.MenuItemLabel + * @param {String} value + * @param {String} charMapFile + * @param {Number} itemWidth + * @param {Number} itemHeight + * @param {String} startCharMap a single character + * @param {function|String|Null} callback + * @param {cc.Node|Null} target + * @example + * var menuItem = new cc.MenuItemAtlasFont(param1,param2...); */ cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# */{ /** - * @param {String} value - * @param {String} charMapFile - * @param {Number} itemWidth - * @param {Number} itemHeight - * @param {String} startCharMap a single character - * @param {function|String|Null} callback - * @param {cc.Node|Null} target + the contructor of cc.MenuItemAtlasFont */ ctor: function (value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) { var label; @@ -447,6 +472,7 @@ cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# }, /** + * initializes a cc.MenuItemAtlasFont with string * @param {String} value * @param {String} charMapFile * @param {Number} itemWidth @@ -471,7 +497,7 @@ cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# /** * create menu item from string with font - * @deprecated + * @deprecated since v3.0 ,please use new cc.MenuItemAtlasFont() instead. * @param {String} value the text to display * @param {String} charMapFile the character map file * @param {Number} itemWidth @@ -495,6 +521,11 @@ cc.MenuItemAtlasFont.create = function (value, charMapFile, itemWidth, itemHeigh * Helper class that creates a CCMenuItemLabel class with a Label * @class * @extends cc.MenuItemLabel + * @param {String} value text for the menu item + * @param {function|String} callback + * @param {cc.Node} target + * @example + * var menuItem = new cc.MenuItemFont(value, callback, target); * * @property {Number} fontSize - Font size of font item * @property {String} fontName - Font name of font item @@ -505,9 +536,6 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ /** * Constructor of cc.MenuItemFont - * @param {String} value text for the menu item - * @param {function|String} callback - * @param {cc.Node} target */ ctor: function (value, callback, target) { var label; @@ -525,6 +553,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ }, /** + * initializes cc.MenuItemFont with string * @param {String} value text for the menu item * @param {function|String} callback * @param {cc.Node} target @@ -545,6 +574,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ }, /** + * set the font size for cc.MenuItemFont * @param {Number} s */ setFontSize: function (s) { @@ -553,7 +583,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ }, /** - * + *return the font size of cc.MenuItemFont * @return {Number} */ getFontSize: function () { @@ -561,6 +591,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ }, /** + * set the font name for cc.MenuItemFont * @param {String} name */ setFontName: function (name) { @@ -569,6 +600,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ }, /** + * return the font name for cc.MenuItemFont * @return {String} */ getFontName: function () { @@ -661,6 +693,19 @@ cc.MenuItemFont.create = function (value, callback, target) { * - disabled image
    * @class * @extends cc.MenuItem + * @param {Image|Null} normalSprite normal state image + * @param {Image|Null} selectedSprite selected state image + * @param {Image|cc.Node|Null} three disabled state image OR target node + * @param {String|function|cc.Node|Null} four callback function name in string or actual function, OR target Node + * @param {String|function|Null} five callback function name in string or actual function + * + * @example + * var item = new cc.MenuItemSprite(normalImage)//create a menu item from a sprite with no functionality + * var item = new cc.MenuItemSprite(normalImage, selectedImage)//create a menu Item, nothing will happen when clicked + * var item = new cc.MenuItemSprite(normalImage, SelectedImage, disabledImage)//same above, but with disabled state image + * var item = new cc.MenuItemSprite(normalImage, SelectedImage, 'callback', targetNode)//create a menu item, when clicked runs targetNode.callback() + * var item = new cc.MenuItemSprite(normalImage, SelectedImage, disabledImage, targetNode.callback, targetNode) + * //same as above, but with disabled image, and passing in callback function * * @property {cc.Sprite} normalImage - Sprite in normal state * @property {cc.Sprite} selectedImage - Sprite in selected state @@ -673,20 +718,6 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ /** * Constructor of cc.MenuItemSprite - * @param {Image|Null} normalSprite normal state image - * @param {Image|Null} selectedSprite selected state image - * @param {Image|cc.Node|Null} three disabled state image OR target node - * @param {String|function|cc.Node|Null} four callback function name in string or actual function, OR target Node - * @param {String|function|Null} five callback function name in string or actual function - * - * @example - * // Example - * var item = new cc.MenuItemSprite(normalImage)//create a menu item from a sprite with no functionality - * var item = new cc.MenuItemSprite(normalImage, selectedImage)//create a menu Item, nothing will happen when clicked - * var item = new cc.MenuItemSprite(normalImage, SelectedImage, disabledImage)//same above, but with disabled state image - * var item = new cc.MenuItemSprite(normalImage, SelectedImage, 'callback', targetNode)//create a menu item, when clicked runs targetNode.callback() - * var item = new cc.MenuItemSprite(normalImage, SelectedImage, disabledImage, targetNode.callback, targetNode) - * //same as above, but with disabled image, and passing in callback function */ ctor: function (normalSprite, selectedSprite, three, four, five) { cc.MenuItem.prototype.ctor.call(this); @@ -718,6 +749,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * return the normal status image(cc.Sprite) * @return {cc.Sprite} */ getNormalImage: function () { @@ -725,6 +757,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * set the normal status image(cc.Sprite) * @param {cc.Sprite} normalImage */ setNormalImage: function (normalImage) { @@ -754,6 +787,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * return the selected status image(cc.Sprite) of cc.MenuItemSprite * @return {cc.Sprite} */ getSelectedImage: function () { @@ -761,6 +795,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * set the selected status image(cc.Sprite) * @param {cc.Sprite} selectedImage */ setSelectedImage: function (selectedImage) { @@ -782,6 +817,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * return the disabled status of cc.MenuItemSprite * @return {cc.Sprite} */ getDisabledImage: function () { @@ -789,6 +825,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * set the disabled status image(cc.Sprite) * @param {cc.Sprite} disabledImage */ setDisabledImage: function (disabledImage) { @@ -809,6 +846,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * initializes cc.MenuItemSprite with a cc.Sprite * @param {cc.Node} normalSprite * @param {cc.Node} selectedSprite * @param {cc.Node} disabledSprite @@ -841,6 +879,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * set the color for cc.MenuItemSprite * @param {cc.Color} color */ setColor: function (color) { @@ -854,6 +893,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * return the color of cc.MenuItemSprite * @return {cc.Color} */ getColor: function () { @@ -861,6 +901,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * set the opacity for cc.MenuItemSprite * @param {Number} opacity 0 - 255 */ setOpacity: function (opacity) { @@ -874,6 +915,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * return the opacity of cc.MenuItemSprite * @return {Number} opacity from 0 - 255 */ getOpacity: function () { @@ -914,6 +956,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ }, /** + * set cc.MenuItemSprite enable to receive the touch event * @param {Boolean} bEnabled */ setEnabled: function (bEnabled) { @@ -965,7 +1008,7 @@ cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledIm /** * create a menu item from sprite - * @deprecated + * @deprecated since v3.0 please use new cc.MenuItemSprite(normalSprite, selectedSprite, three, four, five) instead * @param {Image} normalSprite normal state image * @param {Image|Null} selectedSprite selected state image * @param {Image|cc.Node|Null} three disabled state image OR target node @@ -999,16 +1042,18 @@ cc.MenuItemSprite.create = function (normalSprite, selectedSprite, three, four, * For best results try that all images are of the same size
    * @class * @extends cc.MenuItemSprite + * @param {string|null} normalImage + * @param {string|null} selectedImage + * @param {string|null} disabledImage + * @param {function|string|null} callback + * @param {cc.Node|null} target + * @example + * var menuItem = new cc.MenuItemImage(normalImage, selectedImage, three, four, five); */ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ /** * Constructor of cc.MenuItemImage - * @param {string|null} normalImage - * @param {string|null} selectedImage - * @param {string|null} disabledImage - * @param {function|string|null} callback - * @param {cc.Node|null} target */ ctor: function (normalImage, selectedImage, three, four, five) { var normalSprite = null, @@ -1065,6 +1110,7 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ }, /** + * initializes a cc.MenuItemImage * @param {string|null} normalImage * @param {string|null} selectedImage * @param {string|null} disabledImage @@ -1092,7 +1138,7 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ /** * creates a new menu item image - * @deprecated + * @deprecated since v3.0, please use new cc.MenuItemImage(normalImage, selectedImage, three, four, five) instead. * @param {String} normalImage file name for normal state * @param {String} selectedImage image for selected state * @param {String|cc.Node} three Disabled image OR callback function @@ -1120,6 +1166,17 @@ cc.MenuItemImage.create = function (normalImage, selectedImage, three, four, fiv * * @property {Array} subItems - Sub items * @property {Number} selectedIndex - Index of selected sub item + * + *@example + * // Example + * //create a toggle item with 2 menu items (which you can then toggle between them later) + * var toggler = new cc.MenuItemToggle( cc.MenuItemFont.create("On"), cc.MenuItemFont.create("Off"), this.callback, this) + * //Note: the first param is the target, the second is the callback function, afterwards, you can pass in any number of menuitems + * + * //if you pass only 1 variable, then it must be a cc.MenuItem + * var notYetToggler = new cc.MenuItemToggle(cc.MenuItemFont.create("On"));//it is useless right now, until you add more stuff to it + * notYetToggler.addSubItem(cc.MenuItemFont.create("Off")); + * //this is useful for constructing a toggler without a callback function (you wish to control the behavior from somewhere else) */ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ subItems: null, @@ -1130,17 +1187,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ /** * Constructor of cc.MenuItemToggle - * @example - * // Example - * //create a toggle item with 2 menu items (which you can then toggle between them later) - * var toggler = new cc.MenuItemToggle( cc.MenuItemFont.create("On"), cc.MenuItemFont.create("Off"), this.callback, this) - * //Note: the first param is the target, the second is the callback function, afterwards, you can pass in any number of menuitems - * - * //if you pass only 1 variable, then it must be a cc.MenuItem - * var notYetToggler = new cc.MenuItemToggle(cc.MenuItemFont.create("On"));//it is useless right now, until you add more stuff to it - * notYetToggler.addSubItem(cc.MenuItemFont.create("Off")); - * //this is useful for constructing a toggler without a callback function (you wish to control the behavior from somewhere else) - */ + */ ctor: function (/*Multiple arguments follow*/) { cc.MenuItem.prototype.ctor.call(this); @@ -1155,6 +1202,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * return the opacity of cc.MenuItemToggle * @return {Number} */ getOpacity: function () { @@ -1162,6 +1210,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * set the opacity for cc.MenuItemToggle * @param {Number} opacity */ setOpacity: function (opacity) { @@ -1175,6 +1224,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * return the color of cc.MenuItemToggle * @return {cc.Color} */ getColor: function () { @@ -1183,6 +1233,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * set the color for cc.MenuItemToggle * @param {cc.Color} Color */ setColor: function (color) { @@ -1203,6 +1254,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * return the index of selected * @return {Number} */ getSelectedIndex: function () { @@ -1210,6 +1262,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * set the seleceted index for cc.MenuItemToggle * @param {Number} SelectedIndex */ setSelectedIndex: function (SelectedIndex) { @@ -1229,7 +1282,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** - * similar to get children + * similar to get children,return the sumItem array. * @return {Array} */ getSubItems: function () { @@ -1237,6 +1290,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * set the subitem for cc.MenuItemToggle * @param {cc.MenuItem} subItems */ setSubItems: function (subItems) { @@ -1244,6 +1298,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * initializes a cc.MenuItemToggle with items * @param {cc.MenuItem} args[0...last-2] the rest in the array are cc.MenuItems * @param {function|String} args[last-1] the second item in the args array is the callback * @param {cc.Node} args[last] the first item in the args array is a target @@ -1278,6 +1333,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * add the subitem for cc.MenuItemToggle * @param {cc.MenuItem} item */ addSubItem: function (item) { @@ -1313,6 +1369,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** + * set the enable status for cc.MenuItemToggle * @param {Boolean} enabled */ setEnabled: function (enabled) { @@ -1333,7 +1390,14 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ selectedItem: function () { return this.subItems[this._selectedIndex]; }, - + /** + * *

    + * Event callback that is invoked every time when cc.MenuItemToggle enters the 'stage'.
    + * If the cc.MenuItemToggle enters the 'stage' with a transition, this event is called when the transition starts.
    + * During onEnter you can't access a "sister/brother" node.
    + * If you override onEnter, you must call its parent's onEnter function with this._super(). + *

    + */ onEnter: function () { cc.Node.prototype.onEnter.call(this); this.setSelectedIndex(this._selectedIndex); @@ -1351,7 +1415,7 @@ cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIn /** * create a simple container class that "toggles" it's inner items
    * The inner items can be any MenuItem - * @deprecated + * @deprecated since since v3.0 please use new cc.MenuItemToggle(params) instead * @return {cc.MenuItemToggle} * @example * // Example From 1d950f7bda0b35aa4cdc0d2f6f1276515f3680e1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 10:16:41 +0800 Subject: [PATCH 0531/1564] Issue #5829: Actions jsdoc (example and deprecated) --- cocos2d/actions/CCAction.js | 6 +- cocos2d/actions/CCActionCamera.js | 2 +- cocos2d/actions/CCActionCatmullRom.js | 11 +- cocos2d/actions/CCActionEase.js | 662 +++++++++++++++++++----- cocos2d/actions/CCActionInterval.js | 36 +- cocos2d/actions3d/CCActionPageTurn3D.js | 2 +- 6 files changed, 574 insertions(+), 145 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 9d79a1a059..b040a3660e 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -220,7 +220,7 @@ cc.action = function () { * Please use cc.action instead.
    * Allocates and initializes the action. * - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.action() instead. * @static * @returns {cc.Action} */ @@ -457,7 +457,7 @@ cc.speed = function (action, speed) { * @param {Number} speed * @return {cc.Speed} * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.speed() instead. */ cc.Speed.create = cc.speed; @@ -686,6 +686,6 @@ cc.follow = function (followedNode, rect) { * @param {cc.Rect} rect * @return {cc.Follow|Null} returns the cc.Follow object on success * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please cc.follow() instead. */ cc.Follow.create = cc.follow; diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index 5ac61d7ef2..f291d7e511 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -279,6 +279,6 @@ cc.orbitCamera = function (t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, * @param {Number} deltaAngleX * @return {cc.OrbitCamera} * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.orbitCamera() instead. */ cc.OrbitCamera.create = cc.orbitCamera; diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js index ecc7b6babf..285f2b6f6b 100644 --- a/cocos2d/actions/CCActionCatmullRom.js +++ b/cocos2d/actions/CCActionCatmullRom.js @@ -94,8 +94,7 @@ cc.cloneControlPoints = function (controlPoints) { /** * returns a new clone of the controlPoints - * - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.cloneControlPoints() instead. * @param controlPoints * @returns {Array} */ @@ -323,7 +322,7 @@ cc.cardinalSplineTo = function (duration, points, tension) { * @param {Number} tension * @return {cc.CardinalSplineTo} * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.cardinalSplineTo(duration, points, tension) instead. */ cc.CardinalSplineTo.create = cc.cardinalSplineTo; @@ -459,7 +458,7 @@ cc.cardinalSplineBy = function (duration, points, tension) { * @param {Number} tension * @return {cc.CardinalSplineBy} * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.cardinalSplineBy(duration, points, tension); */ cc.CardinalSplineBy.create = cc.cardinalSplineBy; @@ -532,7 +531,7 @@ cc.catmullRomTo = function (dt, points) { * @param {Array} points * @return {cc.CatmullRomTo} * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.catmullRomTo(dt, points) instead. */ cc.CatmullRomTo.create = cc.catmullRomTo; @@ -601,6 +600,6 @@ cc.catmullRomBy = function (dt, points) { * Please use cc.catmullRomBy instead * Creates an action with a Cardinal Spline array of points and tension * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please cc.catmullRomBy(dt, points) instead. */ cc.CatmullRomBy.create = cc.catmullRomBy; diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index 9ad27382cb..f53901a42e 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -30,6 +30,8 @@ * @extends cc.ActionInterval * @param {cc.ActionInterval} action * + * @deprecated since v3.0 Does not recommend the use of the base object. + * * @example * var moveEase = new cc.ActionEase(action); */ @@ -144,7 +146,7 @@ cc.actionEase = function (action) { * @param {cc.ActionInterval} action * @return {cc.ActionEase} * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.actionEase(action) instead. */ cc.ActionEase.create = cc.actionEase; @@ -156,9 +158,13 @@ cc.ActionEase.create = cc.actionEase; * @param {cc.ActionInterval} action * @param {Number} rate * + * @deprecated since v3.0 please cc.easeRateAction(action, 3.0); + * * @example - * // example - * var moveEaseRateAction = new cc.EaseRateAction(action, 3.0); + * //The old usage + * cc.EaseRateAction.create(action, 3.0); + * //The new usage + * var moveEaseRateAction = cc.easeRateAction(action, 3.0); */ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ _rate:0, @@ -251,7 +257,12 @@ cc.easeRateAction = function (action, rate) { * @param {Number} rate * @return {cc.EaseRateAction} * @static - * @deprecated since v3.0 + * @deprecated since v3.0 please use cc.easeRateAction(action, rate) + * @example + * //The old usage + * cc.EaseRateAction.create(action, 3.0); + * //The new usage + * var moveEaseRateAction = cc.easeRateAction(action, 3.0); */ cc.EaseRateAction.create = cc.easeRateAction; @@ -260,6 +271,14 @@ cc.EaseRateAction.create = cc.easeRateAction; * * @class * @extends cc.EaseRateAction + * + * @deprecated since v3.0 please use action.easing(cc.easeIn(3)); + * + * @example + * //The old usage + * cc.EaseIn.create(action, 3); + * //The new usage + * action.easing(cc.easeIn(3.0)); */ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ @@ -298,10 +317,14 @@ cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ * From slow to fast. * * @static - * @deprecated since v3.0
    Please use cc.easeIn instead. + * @deprecated since v3.0
    Please use action.easing(cc.easeIn(3)) + * * @example - * // example + * //The old usage + * cc.EaseIn.create(action, 3); + * //The new usage * action.easing(cc.easeIn(3.0)); + * * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseIn} @@ -335,8 +358,17 @@ cc.easeIn = function (rate) { /** * cc.EaseOut action with a rate. From fast to slow. + * * @class * @extends cc.EaseRateAction + * + * @deprecated since v3.0 please use action.easing(cc.easeOut(3)) + * + * @example + * //The old usage + * cc.EaseOut.create(action, 3); + * //The new usage + * action.easing(cc.easeOut(3.0)); */ cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ /** @@ -375,9 +407,13 @@ cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ * * @static * @deprecated since v3.0
    Please use cc.easeOut instead. + * * @example - * // example + * //The old usage + * cc.EaseOut.create(action, 3); + * //The new usage * action.easing(cc.easeOut(3.0)); + * * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseOut} @@ -410,10 +446,18 @@ cc.easeOut = function (rate) { }; /** - * cc.EaseInOut action with a rate. + * cc.EaseInOut action with a rate.
    * Slow to fast then to slow. * @class * @extends cc.EaseRateAction + * + * @deprecated since v3.0 please use action.easing(cc.easeInOut(3.0)) + * + * @example + * //The old usage + * cc.EaseInOut.create(action, 3); + * //The new usage + * action.easing(cc.easeInOut(3.0)); */ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ /** @@ -454,10 +498,14 @@ cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ * Creates the action with the inner action and the rate parameter. * Slow to fast then to slow. * @static - * @deprecated since v3.0
    Please use cc.easeInOut instead. + * @deprecated since v3.0
    Please use action.easing(cc.easeInOut(3.0)) + * * @example - * // example + * //The old usage + * cc.EaseInOut.create(action, 3); + * //The new usage * action.easing(cc.easeInOut(3.0)); + * * @param {cc.ActionInterval} action * @param {Number} rate * @return {cc.EaseInOut} @@ -467,13 +515,14 @@ cc.EaseInOut.create = function (action, rate) { }; /** - * Creates the action easing object with the rate parameter. + * Creates the action easing object with the rate parameter.
    * Slow to fast then to slow. * @function * @param {Number} rate * @return {Object} + * * @example - * // example + * //The new usage * action.easing(cc.easeInOut(3.0)); */ cc.easeInOut = function (rate) { @@ -498,6 +547,14 @@ cc.easeInOut = function (rate) { * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0 please action.easing(cc.easeExponentialIn()) + * + * @example + * //The old usage + * cc.EaseExponentialIn.create(action); + * //The new usage + * action.easing(cc.easeExponentialIn()); */ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ /** @@ -535,12 +592,15 @@ cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ * Reference easeInExpo:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeExponentialIn instead. - * @example - * // example - * action.easing(cc.easeExponentialIn()); + * @deprecated since v3.0
    Please use action.easing(cc.easeExponentialIn()) * @param {cc.ActionInterval} action * @return {cc.EaseExponentialIn} + * + * @example + * //The old usage + * cc.EaseExponentialIn.create(action); + * //The new usage + * action.easing(cc.easeExponentialIn()); */ cc.EaseExponentialIn.create = function (action) { return new cc.EaseExponentialIn(action); @@ -575,6 +635,14 @@ cc.easeExponentialIn = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0 please use action.easing(cc.easeExponentialOut()) + * + * @example + * //The old usage + * cc.EaseExponentialOut.create(action); + * //The new usage + * action.easing(cc.easeExponentialOut()); */ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# */{ /** @@ -612,12 +680,15 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# * * Reference easeOutExpo:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeExponentialOut instead. + * @deprecated since v3.0
    Please use action.easing(cc.easeExponentialOut()) + * @param {cc.ActionInterval} action + * @return {Object} + * * @example - * // example + * //The old usage + * cc.EaseExponentialOut.create(action); + * //The new usage * action.easing(cc.easeExponentialOut()); - * @param {cc.ActionInterval} action - * @return {cc.EaseExponentialOut} */ cc.EaseExponentialOut.create = function (action) { return new cc.EaseExponentialOut(action); @@ -637,7 +708,7 @@ cc._easeExponentialOutObj = { * Reference easeOutExpo:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * - * @return {cc.EaseExponentialOut} + * @return {Object} * @example * // example * action.easing(cc.easeExponentialOut()); @@ -653,6 +724,14 @@ cc.easeExponentialOut = function(){ * * @class * @extends cc.ActionEase + * + * @deprecated since v3.0 please use action.easing(cc.easeExponentialInOut) + * + * @example + * //The old usage + * cc.EaseExponentialInOut.create(action); + * //The new usage + * action.easing(cc.easeExponentialInOut()); */ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOut# */{ /** @@ -697,12 +776,15 @@ cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOu * Reference easeInOutExpo:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeExponentialInOut instead. - * @example - * // example - * action.easing(cc.easeExponentialInOut()); + * @deprecated since v3.0
    Please use action.easing(cc.easeExponentialInOut) * @param {cc.ActionInterval} action * @return {cc.EaseExponentialInOut} + * + * @example + * //The old usage + * cc.EaseExponentialInOut.create(action); + * //The new usage + * action.easing(cc.easeExponentialInOut()); */ cc.EaseExponentialInOut.create = function (action) { return new cc.EaseExponentialInOut(action); @@ -744,6 +826,14 @@ cc.easeExponentialInOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0 please use action.easing(cc.easeSineIn()) + * + * @example + * //The old usage + * cc.EaseSineIn.create(action); + * //The new usage + * action.easing(cc.easeSineIn()); */ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ /** @@ -782,12 +872,15 @@ cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ * Reference easeInSine:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeSineIn instead. - * @example - * // example - * action.easing(cc.easeSineIn()); + * @deprecated since v3.0
    Please use action.easing(cc.easeSineIn()) * @param {cc.ActionInterval} action * @return {cc.EaseSineIn} + * + * @example + * //The old usage + * cc.EaseSineIn.create(action); + * //The new usage + * action.easing(cc.easeSineIn()); */ cc.EaseSineIn.create = function (action) { return new cc.EaseSineIn(action); @@ -821,6 +914,14 @@ cc.easeSineIn = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0 please use action.easing(cc.easeSineOut()) + * + * @example + * //The old usage + * cc.EaseSineOut.create(action); + * //The new usage + * action.easing(cc.easeSineOut()); */ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ /** @@ -859,12 +960,15 @@ cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ * Reference easeOutSine:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeSineOut instead. - * @example - * // example - * action.easing(cc.easeSineOut()); + * @deprecated since v3.0
    Please use action.easing(cc.easeSineOut()) * @param {cc.ActionInterval} action * @return {cc.EaseSineOut} + * + * @example + * //The old usage + * cc.EaseSineOut.create(action); + * //The new usage + * action.easing(cc.easeSineOut()); */ cc.EaseSineOut.create = function (action) { return new cc.EaseSineOut(action); @@ -899,6 +1003,14 @@ cc.easeSineOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0 please use action.easing(cc.easeSineInOut()) + * + * @example + * //The old usage + * cc.EaseSineInOut.create(action); + * //The new usage + * action.easing(cc.easeSineInOut()); */ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ /** @@ -939,9 +1051,12 @@ cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ * @static * @param {cc.ActionInterval} action * @return {cc.EaseSineInOut} - * @deprecated since v3.0
    Please use cc.easeSineInOut instead. + * @deprecated since v3.0
    Please use action.easing(cc.easeSineInOut()) + * * @example - * // example + * //The old usage + * cc.EaseSineInOut.create(action); + * //The new usage * action.easing(cc.easeSineInOut()); */ cc.EaseSineInOut.create = function (action) { @@ -961,7 +1076,7 @@ cc._easeSineInOutObj = { * creates the action easing object.
    * Reference easeInOutSine:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} - * @return {cc.EaseSineInOut} + * @return {Object} * @example * // example * action.easing(cc.easeSineInOut()); @@ -976,9 +1091,8 @@ cc.easeSineInOut = function(){ * @extends cc.ActionEase * @param {cc.ActionInterval} action * @param {Number} [period=0.3] - * @example - * // example - * var moveEaseElastic = new cc.EaseElastic(action, 3.0); + * + * @deprecated since v3.0 Does not recommend the use of the base object. */ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ _period: 0.3, @@ -1049,7 +1163,7 @@ cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ /** * Creates the action with the inner action and the period in radians (default is 0.3). * @static - * @deprecated since v3.0 + * @deprecated since v3.0 Does not recommend the use of the base object. * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElastic} @@ -1065,6 +1179,14 @@ cc.EaseElastic.create = function (action, period) { * @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 + * + * @deprecated since v3.0 please use action.easing(cc.easeElasticIn()) + * + * @example + * //The old usage + * cc.EaseElasticIn.create(action, period); + * //The new usage + * action.easing(cc.easeElasticIn(period)); */ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ /** @@ -1109,10 +1231,14 @@ cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ * Creates the action with the inner action and the period in radians (default is 0.3).
    * Reference easeInElastic:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} - * @deprecated since v3.0
    Please use cc.easeElasticIn instead. + * @deprecated since v3.0
    Please use action.easing(cc.easeElasticIn(period)) + * * @example - * // example - * action.easing(cc.easeElasticIn(3.0)); + * //The old usage + * cc.EaseElasticIn.create(action, period); + * //The new usage + * action.easing(cc.easeElasticIn(period)); + * * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticIn} @@ -1170,6 +1296,14 @@ cc.easeElasticIn = function (period) { * @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 + * + * @deprecated since v3.0
    Please use action.easing(cc.easeElasticOut(period)) + * + * @example + * //The old usage + * cc.EaseElasticOut.create(action, period); + * //The new usage + * action.easing(cc.easeElasticOut(period)); */ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ /** @@ -1214,13 +1348,16 @@ cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ * Creates the action with the inner action and the period in radians (default is 0.3).
    * Reference easeOutElastic:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} - * @deprecated since v3.0
    Please use cc.easeElasticOut instead. - * @example - * // example - * action.easing(cc.easeElasticOut(3.0)); + * @deprecated since v3.0
    Please use action.easing(cc.easeElasticOut(period)) * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticOut} + * + * @example + * //The old usage + * cc.EaseElasticOut.create(action, period); + * //The new usage + * action.easing(cc.easeElasticOut(period)); */ cc.EaseElasticOut.create = function (action, period) { return new cc.EaseElasticOut(action, period); @@ -1268,6 +1405,14 @@ cc.easeElasticOut = function (period) { * @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 + * + * @deprecated since v3.0 please use action.easing(cc.easeElasticInOut()) + * + * @example + * //The old usage + * cc.EaseElasticInOut.create(action, period); + * //The new usage + * action.easing(cc.easeElasticInOut(period)); */ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ /** @@ -1320,13 +1465,16 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ * Creates the action with the inner action and the period in radians (default is 0.3).
    * Reference easeInOutElastic:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} - * @deprecated since v3.0
    Please use cc.easeElasticInOut instead. - * @example - * // example - * action.easing(cc.easeElasticInOut(3.0)); + * @deprecated since v3.0
    Please use action.easing(cc.easeElasticInOut(period)) * @param {cc.ActionInterval} action * @param {Number} [period=0.3] * @return {cc.EaseElasticInOut} + * + * @example + * //The old usage + * cc.EaseElasticInOut.create(action, period); + * //The new usage + * action.easing(cc.easeElasticInOut(period)); */ cc.EaseElasticInOut.create = function (action, period) { return new cc.EaseElasticInOut(action, period); @@ -1373,6 +1521,9 @@ cc.easeElasticInOut = function (period) { /** * cc.EaseBounce abstract class. + * + * @deprecated since v3.0 Does not recommend the use of the base object. + * * @class * @extends cc.ActionEase */ @@ -1420,7 +1571,7 @@ cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{ /** * Creates an ease bounce action. * @static - * @deprecated since v3.0 + * @deprecated since v3.0 Does not recommend the use of the base object. * @param {cc.ActionInterval} action * @return {cc.EaseBounce} */ @@ -1434,6 +1585,14 @@ cc.EaseBounce.create = function (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 + * + * @deprecated since v3.0 please use action.easing(cc.easeBounceIn()) + * + * @example + * //The old usage + * cc.EaseBounceIn.create(action); + * //The new usage + * action.easing(cc.easeBounceIn()); */ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ /** @@ -1471,12 +1630,15 @@ cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ * Creates the action.
    * Eased bounce effect at the beginning. * @static - * @deprecated since v3.0
    Please use cc.easeBounceIn instead. - * @example - * // example - * action.easing(cc.easeBounceIn()); + * @deprecated since v3.0
    Please use action.easing(cc.easeBounceIn()) * @param {cc.ActionInterval} action * @return {cc.EaseBounceIn} + * + * @example + * //The old usage + * cc.EaseBounceIn.create(action); + * //The new usage + * action.easing(cc.easeBounceIn()); */ cc.EaseBounceIn.create = function (action) { return new cc.EaseBounceIn(action); @@ -1525,6 +1687,14 @@ cc.easeBounceIn = function(){ * @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 + * + * @deprecated since v3.0 please use action.easing(cc.easeBounceOut()) + * + * @example + * //The old usage + * cc.EaseBounceOut.create(action); + * //The new usage + * action.easing(cc.easeBounceOut()); */ cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{ /** @@ -1562,12 +1732,15 @@ cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{ * Creates the action.
    * Eased bounce effect at the ending. * @static - * @deprecated since v3.0
    Please use cc.easeBounceOut instead. - * @example - * // example - * action.easing(cc.easeBounceOut()); + * @deprecated since v3.0 please use action.easing(cc.easeBounceOut()) * @param {cc.ActionInterval} action * @return {cc.EaseBounceOut} + * + * @example + * //The old usage + * cc.EaseBounceOut.create(action); + * //The new usage + * action.easing(cc.easeBounceOut()); */ cc.EaseBounceOut.create = function (action) { return new cc.EaseBounceOut(action); @@ -1601,6 +1774,14 @@ cc.easeBounceOut = function(){ * @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 + * + * @deprecated since v3.0
    Please use acton.easing(cc.easeBounceInOut()) + * + * @example + * //The old usage + * cc.EaseBounceInOut.create(action); + * //The new usage + * action.easing(cc.easeBounceInOut()); */ cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ /** @@ -1644,12 +1825,15 @@ cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ * Creates the action.
    * Eased bounce effect at the begining and ending. * @static - * @deprecated since v3.0
    Please use cc.easeBounceInOut instead. - * @example - * // example - * action.easing(cc.easeBounceInOut()); + * @deprecated since v3.0
    Please use action.easing(cc.easeBounceInOut()) * @param {cc.ActionInterval} action * @return {cc.EaseBounceInOut} + * + * @example + * //The old usage + * cc.EaseBounceInOut.create(action); + * //The new usage + * action.easing(cc.easeBounceInOut()); */ cc.EaseBounceInOut.create = function (action) { return new cc.EaseBounceInOut(action); @@ -1670,6 +1854,7 @@ cc._easeBounceInOutObj = { return cc._easeBounceInOutObj; } }; + /** * Creates the action easing object.
    * Eased bounce effect at the begining and ending. @@ -1689,6 +1874,14 @@ cc.easeBounceInOut = function(){ * @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 + * + * @deprecated since v3.0 please use action.easing(cc.easeBackIn()) + * + * @example + * //The old usage + * cc.EaseBackIn.create(action); + * //The new usage + * action.easing(cc.easeBackIn()); */ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ /** @@ -1728,12 +1921,15 @@ cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ * Creates the cc.EaseBackIn.
    * In the opposite direction to move slowly, and then accelerated to the right direction. * @static - * @deprecated since v3.0
    Please use cc.easeBackIn instead. - * @example - * // example - * action.easing(cc.easeBackIn()); + * @deprecated since v3.0
    Please use action.easing(cc.easeBackIn()) * @param {cc.ActionInterval} action * @return {cc.EaseBackIn} + * + * @example + * //The old usage + * cc.EaseBackIn.create(action); + * //The new usage + * action.easing(cc.easeBackIn()); */ cc.EaseBackIn.create = function (action) { return new cc.EaseBackIn(action); @@ -1768,6 +1964,14 @@ cc.easeBackIn = function(){ * @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 + * + * @deprecated since v3.0 please use action.easing(cc.easeBackOut()); + * + * @example + * //The old usage + * cc.EaseBackOut.create(action); + * //The new usage + * action.easing(cc.easeBackOut()); */ cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ /** @@ -1806,12 +2010,15 @@ cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ * Creates the action.
    * Fast moving more than the finish, and then slowly back to the finish. * @static - * @deprecated since v3.0
    Please use cc.easeBackOut instead. - * @example - * // example - * action.easing(cc.easeBackOut()); + * @deprecated since v3.0
    Please use action.easing(cc.easeBackOut()); * @param {cc.ActionInterval} action * @return {cc.EaseBackOut} + * + * @example + * //The old usage + * cc.EaseBackOut.create(action); + * //The new usage + * action.easing(cc.easeBackOut()); */ cc.EaseBackOut.create = function (action) { return new cc.EaseBackOut(action); @@ -1827,6 +2034,7 @@ cc._easeBackOutObj = { return cc._easeBackInObj; } }; + /** * Creates the action easing object.
    * Fast moving more than the finish, and then slowly back to the finish. @@ -1846,6 +2054,14 @@ cc.easeBackOut = function(){ * @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 + * + * @deprecated since v3.0
    Please use action.easing(cc.easeBackInOut()) + * + * @example + * //The old usage + * cc.EaseBackInOut.create(action); + * //The new usage + * action.easing(cc.easeBackInOut()); */ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ /** @@ -1890,12 +2106,16 @@ cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ * Creates the action.
    * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. * @static - * @deprecated since v3.0
    Please use cc.easeBackInOut instead. - * @example - * // example - * action.easing(cc.easeBackInOut()); * @param {cc.ActionInterval} action * @return {cc.EaseBackInOut} + * + * @deprecated since v3.0
    Please use action.easing(cc.easeBackInOut()) + * + * @example + * //The old usage + * cc.EaseBackInOut.create(action); + * //The new usage + * action.easing(cc.easeBackInOut()); */ cc.EaseBackInOut.create = function (action) { return new cc.EaseBackInOut(action); @@ -1916,6 +2136,7 @@ cc._easeBackInOutObj = { return cc._easeBackInOutObj; } }; + /** * Creates the action easing object.
    * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. @@ -1936,6 +2157,15 @@ cc.easeBackInOut = function(){ * @class * @extends cc.ActionEase * @param {cc.Action} action + * + * @deprecated since v3.0
    Please use action.easing(cc.easeBezierAction()) + * + * @example + * //The old usage + * var action = cc.EaseBezierAction.create(action); + * action.setBezierParamer(0.5, 0.5, 1.0, 1.0); + * //The new usage + * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); */ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ @@ -2010,12 +2240,17 @@ cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ * After creating the cc.EaseBezierAction, also need to manually call setBezierParamer.
    * According to the set point, calculate the trajectory. * @static - * @deprecated since v3.0
    Please use cc.easeBezierAction instead. - * @example - * // example - * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); * @param action * @returns {cc.EaseBezierAction} + * + * @deprecated since v3.0
    Please use action.easing(cc.easeBezierAction()) + * + * @example + * //The old usage + * var action = cc.EaseBezierAction.create(action); + * action.setBezierParamer(0.5, 0.5, 1.0, 1.0); + * //The new usage + * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); */ cc.EaseBezierAction.create = function(action){ return new cc.EaseBezierAction(action); @@ -2051,6 +2286,14 @@ cc.easeBezierAction = function(p0, p1, p2, p3){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticAction()) + * + * @example + * //The old usage + * cc.EaseQuadraticActionIn.create(action); + * //The new usage + * action.easing(cc.easeQuadraticActionIn()); */ cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionIn# */{ @@ -2094,12 +2337,16 @@ cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActio * Reference easeInQuad:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuadraticAction instead. - * @example - * //example - * action.easing(cc.easeQuadraticActionIn()); * @param action * @returns {cc.EaseQuadraticActionIn} + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticAction()) + * + * @example + * //The old usage + * cc.EaseQuadraticActionIn.create(action); + * //The new usage + * action.easing(cc.easeQuadraticActionIn()); */ cc.EaseQuadraticActionIn.create = function(action){ return new cc.EaseQuadraticActionIn(action); @@ -2131,6 +2378,14 @@ cc.easeQuadraticActionIn = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticActionOut()) + * + * @example + * //The old usage + * cc.EaseQuadraticActionOut.create(action); + * //The new usage + * action.easing(cc.easeQuadraticActionOut()); */ cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionOut# */{ @@ -2173,12 +2428,16 @@ cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActi * Reference easeOutQuad:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuadraticActionOut instead. - * @example - * //example - * action.easing(cc.easeQuadraticActionOut()); * @param action * @returns {cc.EaseQuadraticActionOut} + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticActionOut()) + * + * @example + * //The old usage + * cc.EaseQuadraticActionOut.create(action); + * //The new usage + * action.easing(cc.easeQuadraticActionOut()); */ cc.EaseQuadraticActionOut.create = function(action){ return new cc.EaseQuadraticActionOut(action); @@ -2210,6 +2469,14 @@ cc.easeQuadraticActionOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticActionInOut()) + * + * @example + * //The old usage + * cc.EaseQuadraticActionInOut.create(action); + * //The new usage + * action.easing(cc.easeQuadraticActionInOut()); */ cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionInOut# */{ _updateTime: function(time){ @@ -2259,10 +2526,15 @@ cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticAc * Reference easeInOutQuad:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuadraticActionInOut() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticActionInOut()) + * * @example - * //example + * //The old usage + * cc.EaseQuadraticActionInOut.create(action); + * //The new usage * action.easing(cc.easeQuadraticActionInOut()); + * * @param action * @returns {cc.EaseQuadraticActionInOut} */ @@ -2297,6 +2569,14 @@ cc.easeQuadraticActionInOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuarticActionIn()); + * + * @example + * //The old usage + * cc.EaseQuarticActionIn.create(action); + * //The new usage + * action.easing(cc.easeQuarticActionIn()); */ cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# */{ _updateTime: function(time){ @@ -2338,10 +2618,15 @@ cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# * Reference easeInQuart:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuarticIn() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuarticActionIn()); + * * @example - * //example + * //The old usage + * cc.EaseQuarticActionIn.create(action); + * //The new usage * action.easing(cc.easeQuarticActionIn()); + * * @param action * @returns {cc.EaseQuarticActionIn} */ @@ -2375,6 +2660,14 @@ cc.easeQuarticActionIn = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.QuarticActionOut()); + * + * @example + * //The old usage + * cc.EaseQuarticActionOut.create(action); + * //The new usage + * action.easing(cc.EaseQuarticActionOut()); */ cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOut# */{ _updateTime: function(time){ @@ -2417,10 +2710,15 @@ cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOu * Reference easeOutQuart:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuarticActionOut() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.QuarticActionOut()); + * * @example - * //example + * //The old usage + * cc.EaseQuarticActionOut.create(action); + * //The new usage * action.easing(cc.EaseQuarticActionOut()); + * * @param action * @returns {cc.EaseQuarticActionOut} */ @@ -2455,6 +2753,14 @@ cc.easeQuarticActionOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuarticActionInOut()); + * + * @example + * //The old usage + * cc.EaseQuarticActionInOut.create(action); + * //The new usage + * action.easing(cc.easeQuarticActionInOut()); */ cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionInOut# */{ _updateTime: function(time){ @@ -2500,10 +2806,15 @@ cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticAction * Reference easeInOutQuart:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuarticActionInOut() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuarticActionInOut()); + * * @example - * //example + * //The old usage + * cc.EaseQuarticActionInOut.create(action); + * //The new usage * action.easing(cc.easeQuarticActionInOut()); + * * @param action * @returns {cc.EaseQuarticActionInOut} */ @@ -2534,6 +2845,14 @@ cc.easeQuarticActionInOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuinticActionIn()); + * + * @example + * //The old usage + * cc.EaseQuinticActionIn.create(action); + * //The new usage + * action.easing(cc.easeQuinticActionIn()); */ cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# */{ _updateTime: function(time){ @@ -2575,10 +2894,15 @@ cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# * Reference easeInQuint:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuinticActionIn() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuinticActionIn()); + * * @example - * //example + * //The old usage + * cc.EaseQuinticActionIn.create(action); + * //The new usage * action.easing(cc.easeQuinticActionIn()); + * * @param action * @returns {cc.EaseQuinticActionIn} */ @@ -2613,6 +2937,14 @@ cc.easeQuinticActionIn = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticActionOut()); + * + * @example + * //The old usage + * cc.EaseQuinticActionOut.create(action); + * //The new usage + * action.easing(cc.easeQuadraticActionOut()); */ cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOut# */{ _updateTime: function(time){ @@ -2655,10 +2987,15 @@ cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOu * Reference easeOutQuint:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuadraticActionOut() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuadraticActionOut()); + * * @example - * //example + * //The old usage + * cc.EaseQuinticActionOut.create(action); + * //The new usage * action.easing(cc.easeQuadraticActionOut()); + * * @param action * @returns {cc.EaseQuinticActionOut} */ @@ -2672,6 +3009,7 @@ cc._easeQuinticActionOut = { return cc._easeQuinticActionOut; } }; + /** * Creates the action easing object.
    * Reference easeOutQuint:
    @@ -2692,6 +3030,14 @@ cc.easeQuinticActionOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuinticActionInOut()); + * + * @example + * //The old usage + * cc.EaseQuinticActionInOut.create(action); + * //The new usage + * action.easing(cc.easeQuinticActionInOut()); */ cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionInOut# */{ _updateTime: function(time){ @@ -2737,10 +3083,15 @@ cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticAction * Reference easeInOutQuint:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeQuinticActionInOut() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeQuinticActionInOut()); + * * @example - * //example + * //The old usage + * cc.EaseQuinticActionInOut.create(action); + * //The new usage * action.easing(cc.easeQuinticActionInOut()); + * * @param action * @returns {cc.EaseQuinticActionInOut} */ @@ -2775,6 +3126,14 @@ cc.easeQuinticActionInOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCircleActionIn()); + * + * @example + * //The old usage + * cc.EaseCircleActionIn.create(action); + * //The new usage + * action.easing(cc.easeCircleActionIn()); */ cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# */{ _updateTime: function(time){ @@ -2816,10 +3175,15 @@ cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# * * Reference easeInCirc:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeCircleActionIn() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCircleActionIn()); + * * @example - * //example + * //The old usage + * cc.EaseCircleActionIn.create(action); + * //The new usage * action.easing(cc.easeCircleActionIn()); + * * @param action * @returns {cc.EaseCircleActionIn} */ @@ -2854,6 +3218,14 @@ cc.easeCircleActionIn = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCircleActionOut()); + * + * @example + * //The old usage + * cc.EaseCircleActionOut.create(action); + * //The new usage + * action.easing(cc.easeCircleActionOut()); */ cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# */{ _updateTime: function(time){ @@ -2896,10 +3268,15 @@ cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# * Reference easeOutCirc:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeCircleActionOut() instead. - * @exampple - * //example - * actioneasing(cc.easeCircleActionOut()); + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCircleActionOut()); + * + * @example + * //The old usage + * cc.EaseCircleActionOut.create(action); + * //The new usage + * action.easing(cc.easeCircleActionOut()); + * * @param action * @returns {cc.EaseCircleActionOut} */ @@ -2934,6 +3311,14 @@ cc.easeCircleActionOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCircleActionInOut()); + * + * @example + * //The old usage + * cc.EaseCircleActionInOut.create(action); + * //The new usage + * action.easing(cc.easeCircleActionInOut()); */ cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionInOut# */{ _updateTime: function(time){ @@ -2979,10 +3364,15 @@ cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn * Reference easeInOutCirc:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeCircleActionInOut instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCircleActionInOut()); + * * @example - * //example + * //The old usage + * cc.EaseCircleActionInOut.create(action); + * //The new usage * action.easing(cc.easeCircleActionInOut()); + * * @param action * @returns {cc.EaseCircleActionInOut} */ @@ -3017,6 +3407,14 @@ cc.easeCircleActionInOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    action.easing(cc.easeCubicActionIn()); + * + * @example + * //The old usage + * cc.EaseCubicActionIn.create(action); + * //The new usage + * action.easing(cc.easeCubicActionIn()); */ cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{ _updateTime: function(time){ @@ -3058,10 +3456,15 @@ cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{ * Reference easeInCubic:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeCubicActionOut() instead. + * + * @deprecated since v3.0
    action.easing(cc.easeCubicActionIn()); + * * @example - * //example + * //The old usage + * cc.EaseCubicActionIn.create(action); + * //The new usage * action.easing(cc.easeCubicActionIn()); + * * @param action * @returns {cc.EaseCubicActionIn} */ @@ -3075,6 +3478,7 @@ cc._easeCubicActionIn = { return cc._easeCubicActionIn; } }; + /** * Creates the action easing object.
    * Reference easeInCubic:
    @@ -3095,6 +3499,14 @@ cc.easeCubicActionIn = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCubicActionOut()); + * + * @example + * //The old usage + * cc.EaseCubicActionOut.create(action); + * //The new usage + * action.easing(cc.easeCubicActionOut()); */ cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# */{ _updateTime: function(time){ @@ -3137,10 +3549,15 @@ cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# * * Reference easeOutCubic:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeCubicActionOut() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCubicActionOut()); + * * @example - * //example + * //The old usage + * cc.EaseCubicActionOut.create(action); + * //The new usage * action.easing(cc.easeCubicActionOut()); + * * @param action * @returns {cc.EaseCubicActionOut} */ @@ -3175,6 +3592,14 @@ cc.easeCubicActionOut = function(){ * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @class * @extends cc.ActionEase + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCubicActionInOut()); + * + * @example + * //The old usage + * cc.EaseCubicActionInOut.create(action); + * //The new usage + * action.easing(cc.easeCubicActionInOut()); */ cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOut# */{ _updateTime: function(time){ @@ -3220,10 +3645,15 @@ cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOu * Reference easeInOutCubic:
    * {@link http://www.zhihu.com/question/21981571/answer/19925418} * @static - * @deprecated since v3.0
    Please use cc.easeCubicActionInOut() instead. + * + * @deprecated since v3.0
    Please use action.easing(cc.easeCubicActionInOut()); + * * @example - * //example + * //The old usage + * cc.EaseCubicActionInOut.create(action); + * //The new usage * action.easing(cc.easeCubicActionInOut()); + * * @param action * @returns {cc.EaseCubicActionInOut} */ diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 47dffb5cdd..17f0080a22 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -1412,7 +1412,7 @@ cc.moveBy = function (duration, deltaPos, deltaY) { * Please use cc.moveBy instead. * Relative to its coordinate moves a certain distance. * @static - * @deprecated + * @deprecated since v3.0 please use cc.moveBy instead. * @param {Number} duration duration in seconds * @param {cc.Point|Number} deltaPos * @param {Number} deltaY @@ -1734,7 +1734,7 @@ cc.skewBy = function (t, sx, sy) { * Skews a cc.Node object by skewX and skewY degrees.
    * Relative to its attribute modification. * @static - * @deprecated + * @deprecated since v3.0 please use cc.skewBy instead. * @param {Number} t time in seconds * @param {Number} sx sx skew in degrees for X axis * @param {Number} sy sy skew in degrees for Y axis @@ -1900,7 +1900,7 @@ cc.jumpBy = function (duration, position, y, height, jumps) { * Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute.
    * Relative to its movement. * @static - * @deprecated + * @deprecated since v3.0 please use cc.jumpBy instead. * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -2010,7 +2010,7 @@ cc.jumpTo = function (duration, position, y, height, jumps) { * Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute.
    * Jump to the specified location. * @static - * @deprecated + * @deprecated since v3.0 please use cc.jumpTo instead. * @param {Number} duration * @param {cc.Point|Number} position * @param {Number} [y] @@ -2186,7 +2186,7 @@ cc.bezierBy = function (t, c) { * An action that moves the target with a cubic Bezier curve by a certain distance. * Relative to its movement. * @static - * @deprecated + * @deprecated since v3.0 please use cc.bezierBy instead. * @param {Number} t time in seconds * @param {Array} c Array of points * @return {cc.BezierBy} @@ -2275,7 +2275,7 @@ cc.bezierTo = function (t, c) { /** * Please use cc.bezierTo instead * @static - * @deprecated + * @deprecated since v3.0 please use cc.bezierTo instead. * @param {Number} t * @param {Array} c array of points * @return {cc.BezierTo} @@ -2391,7 +2391,7 @@ cc.scaleTo = function (duration, sx, sy) { //function overload * Please use cc.scaleTo instead. * Scales a cc.Node object to a zoom factor by modifying it's scale attribute. * @static - * @deprecated + * @deprecated since v3.0 please use cc.scaleTo instead. * @param {Number} duration * @param {Number} sx scale parameter in X * @param {Number} [sy] scale parameter in Y, if Null equal to sx @@ -2461,7 +2461,7 @@ cc.scaleBy = function (duration, sx, sy) { * Scales a cc.Node object a zoom factor by modifying it's scale attribute. * Relative to its changes. * @static - * @deprecated + * @deprecated since v3.0 please use cc.scaleBy() instead. * @param {Number} duration duration in seconds * @param {Number} sx sx scale parameter in X * @param {Number|Null} [sy=] sy scale parameter in Y, if Null equal to sx @@ -2574,7 +2574,7 @@ cc.blink = function (duration, blinks) { * Please use cc.blink instead. * Blinks a cc.Node object by modifying it's visible attribute. * @static - * @deprecated + * @deprecated since v3.0 please use cc.blink instead. * @param {Number} duration duration in seconds * @param blinks blinks in times * @return {cc.Blink} @@ -2667,7 +2667,7 @@ cc.fadeTo = function (duration, opacity) { * Please use cc.fadeTo instead. * Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. * @static - * @deprecated + * @deprecated since v3.0 please use cc.fadeTo instead. * @param {Number} duration * @param {Number} opacity 0-255, 0 is transparent * @return {cc.FadeTo} @@ -2742,7 +2742,7 @@ cc.fadeIn = function (duration) { * Please use cc.fadeIn instead. * Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255. * @static - * @deprecated + * @deprecated since v3.0 please use cc.fadeIn() instead. * @param {Number} duration duration in seconds * @return {cc.FadeIn} */ @@ -2807,7 +2807,7 @@ cc.fadeOut = function (d) { * Please use cc.fadeOut instead. * Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0. * @static - * @deprecated + * @deprecated since v3.0 please use cc.fadeOut instead. * @param {Number} d duration in seconds * @return {cc.FadeOut} */ @@ -2915,7 +2915,7 @@ cc.tintTo = function (duration, red, green, blue) { * Please use cc.tintTo instead. * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. * @static - * @deprecated + * @deprecated since v3.0 please use cc.tintTo instead. * @param {Number} duration * @param {Number} red 0-255 * @param {Number} green 0-255 @@ -3046,7 +3046,7 @@ cc.tintBy = function (duration, deltaRed, deltaGreen, deltaBlue) { * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one. * Relative to their own color change. * @static - * @deprecated + * @deprecated since v3.0 please use cc.tintBy instead. * @param {Number} duration duration in seconds * @param {Number} deltaRed * @param {Number} deltaGreen @@ -3106,7 +3106,7 @@ cc.delayTime = function (d) { * Please use cc.delayTime instead. * Delays the action a certain amount of seconds * @static - * @deprecated + * @deprecated since v3.0 please use cc.delaTime instead. * @param {Number} d duration in seconds * @return {cc.DelayTime} */ @@ -3220,7 +3220,7 @@ cc.reverseTime = function (action) { * Please use cc.reverseTime instead. * Executes an action in reverse order, from time=duration to time=0. * @static - * @deprecated + * @deprecated since v3.0 please use cc.reverseTime instead. * @param {cc.FiniteTimeAction} action * @return {cc.ReverseTime} */ @@ -3412,7 +3412,7 @@ cc.animate = function (animation) { * Please use cc.animate instead * create the animate with animation * @static - * @deprecated + * @deprecated since v3.0 please use cc.animate instead. * @param {cc.Animation} animation * @return {cc.Animate} */ @@ -3526,7 +3526,7 @@ cc.targetedAction = function (target, action) { * Please use cc.targetedAction instead * Create an action with the specified action and forced target * @static - * @deprecated + * @deprecated since v3.0 please use cc.targetedAction instead. * @param {cc.Node} target * @param {cc.FiniteTimeAction} action * @return {cc.TargetedAction} diff --git a/cocos2d/actions3d/CCActionPageTurn3D.js b/cocos2d/actions3d/CCActionPageTurn3D.js index 5fc0d8c4be..367531662c 100644 --- a/cocos2d/actions3d/CCActionPageTurn3D.js +++ b/cocos2d/actions3d/CCActionPageTurn3D.js @@ -108,6 +108,6 @@ cc.pageTurn3D = function (duration, gridSize) { * @param {cc.Size} gridSize * @return {cc.PageTurn3D} * @static - * @deprecated + * @deprecated since v3.0 please use cc.pageTurn3D instead. */ cc.PageTurn3D.create = cc.pageTurn3D; \ No newline at end of file From 560d727399433a31762c4574440a922c123d70bc Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 27 Aug 2014 10:20:46 +0800 Subject: [PATCH 0532/1564] Issue #5830: add jsDocs to uiwidgets --- .../ccui/base-classes/CCProtectedNode.js | 4 +- .../ccui/base-classes/UIScale9Sprite.js | 13 +- extensions/ccui/base-classes/UIWidget.js | 79 ++++----- extensions/ccui/layouts/UIHBox.js | 4 +- extensions/ccui/layouts/UILayout.js | 16 +- extensions/ccui/layouts/UILayoutParameter.js | 4 +- extensions/ccui/layouts/UIRelativeBox.js | 4 +- extensions/ccui/layouts/UIVBox.js | 2 +- extensions/ccui/uiwidgets/UIButton.js | 133 +++++++++++---- extensions/ccui/uiwidgets/UICheckBox.js | 112 ++++++++++--- extensions/ccui/uiwidgets/UIImageView.js | 54 ++++-- extensions/ccui/uiwidgets/UILoadingBar.js | 73 +++++--- extensions/ccui/uiwidgets/UIRichText.js | 158 +++++++++++++----- extensions/ccui/uiwidgets/UISlider.js | 141 +++++++++------- extensions/ccui/uiwidgets/UIText.js | 98 ++++++++--- extensions/ccui/uiwidgets/UITextAtlas.js | 49 +++--- extensions/ccui/uiwidgets/UITextBMFont.js | 21 ++- extensions/ccui/uiwidgets/UITextField.js | 39 ++--- .../uiwidgets/scroll-widget/UIListView.js | 13 +- .../uiwidgets/scroll-widget/UIPageView.js | 8 +- .../uiwidgets/scroll-widget/UIScrollView.js | 28 ++-- 21 files changed, 712 insertions(+), 341 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 5a2e1b6789..a0d5e828b5 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -38,7 +38,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ }, /** - * Constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @function */ ctor: function(){ @@ -484,7 +484,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { /** * create a cc.ProtectedNode object; - * @deprecated + * @deprecated since v3.0, please use new cc.ProtectedNode() instead. * @return cc.ProtectedNode */ cc.ProtectedNode.create = function(){ diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 2675d9a001..fa78d4cd68 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -233,7 +233,8 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, /** - * @constructor + * Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @function * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame * @param {cc.Rect} rect * @param {cc.Rect} capInsets @@ -492,6 +493,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ cc.Node.prototype.visit.call(this, ctx); }, + /** + * Initializes a ccui.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @returns {boolean} + */ init: function () { return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); }, @@ -1032,7 +1037,7 @@ _p = null; /** * Creates a 9-slice sprite with a texture file, a delimitation zone and * with the specified cap insets. - * @deprecated + * @deprecated since v3.0, please use new ccui.Scale9Sprite(file, rect, capInsets) instead. * @param {String|cc.SpriteFrame} file file name of texture or a cc.Sprite object * @param {cc.Rect} rect the rect of the texture * @param {cc.Rect} capInsets the cap insets of ccui.Scale9Sprite @@ -1044,7 +1049,7 @@ ccui.Scale9Sprite.create = function (file, rect, capInsets) { /** * create a ccui.Scale9Sprite with Sprite frame. - * @deprecated + * @deprecated since v3.0, please use "new ccui.Scale9Sprite(spriteFrame, capInsets)" instead. * @param {cc.SpriteFrame} spriteFrame * @param {cc.Rect} capInsets * @returns {ccui.Scale9Sprite} @@ -1055,7 +1060,7 @@ ccui.Scale9Sprite.createWithSpriteFrame = function (spriteFrame, capInsets) { /** * create a ccui.Scale9Sprite with a Sprite frame name - * @deprecated + * @deprecated since v3.0, please use "new ccui.Scale9Sprite(spriteFrameName, capInsets)" instead. * @param {string} spriteFrameName * @param {cc.Rect} capInsets * @returns {Scale9Sprite} diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index c9560f07bb..8d47a04594 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -90,7 +90,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _touchEventCallback: null, /** - * Constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @function */ ctor: function () { @@ -112,7 +112,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * initializes state of widget. + * initializes state of widget. please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. * @returns {boolean} */ init: function () { @@ -560,7 +560,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ else this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL); } else - this.onPressStateChangedToDisabled(); + this._onPressStateChangedToDisabled(); }, /** @@ -720,7 +720,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL); } else - this.onPressStateChangedToDisabled(); + this._onPressStateChangedToDisabled(); }, /** @@ -735,32 +735,23 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._brightStyle = style; switch (this._brightStyle) { case ccui.Widget.BRIGHT_STYLE_NORMAL: - this.onPressStateChangedToNormal(); + this._onPressStateChangedToNormal(); break; case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT: - this.onPressStateChangedToPressed(); + this._onPressStateChangedToPressed(); break; default: break; } }, - /** - * The call back function is calling when widget's state changed to normal. - */ - onPressStateChangedToNormal: function () { + _onPressStateChangedToNormal: function () { }, - /** - * call back function called widget's state changed to selected. - */ - onPressStateChangedToPressed: function () { + _onPressStateChangedToPressed: function () { }, - /** - * call back function called widget's state changed to dark. - */ - onPressStateChangedToDisabled: function () { + _onPressStateChangedToDisabled: function () { }, /** @@ -1339,7 +1330,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Gets the left boundary position of this widget. - * @deprecated + * @deprecated since v3.0, please use getLeftBoundary instead. * @returns {number} */ getLeftInParent: function(){ @@ -1349,7 +1340,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Gets the bottom boundary position of this widget. - * @deprecated + * @deprecated since v3.0, please use getBottomBoundary instead. * @returns {number} */ getBottomInParent: function(){ @@ -1359,7 +1350,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Gets the right boundary position of this widget. - * @deprecated + * @deprecated since v3.0, please use getRightBoundary instead. * @returns {number} */ getRightInParent: function(){ @@ -1369,7 +1360,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Gets the top boundary position of this widget. - * @deprecated + * @deprecated since v3.0, please use getTopBoundary instead. * @returns {number} */ getTopInParent: function(){ @@ -1379,7 +1370,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Gets the touch end point of widget when widget is selected. - * @deprecated + * @deprecated since v3.0, please use getTouchEndPosition instead. * @returns {cc.Point} the touch end point. */ getTouchEndPos: function () { @@ -1389,7 +1380,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** *Gets the touch move point of widget when widget is selected. - * @deprecated + * @deprecated since v3.0, please use getTouchMovePosition instead. * @returns {cc.Point} the touch move point. */ getTouchMovePos: function () { @@ -1399,7 +1390,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Checks a point if in parent's area. - * @deprecated + * @deprecated since v3.0, please use isClippingParentContainsPoint instead. * @param {cc.Point} pt * @returns {Boolean} */ @@ -1410,7 +1401,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Gets the touch began point of widget when widget is selected. - * @deprecated + * @deprecated since v3.0, please use getTouchBeganPosition instead. * @returns {cc.Point} the touch began point. */ getTouchStartPos: function () { @@ -1420,7 +1411,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Changes the size that is widget's size - * @deprecated + * @deprecated since v3.0, please use setContentSize instead. * @param {cc.Size} size that is widget's size */ setSize: function (size) { @@ -1429,7 +1420,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * Returns size of widget - * @deprecated + * @deprecated since v3.0, please use getContentSize instead. * @returns {cc.Size} */ getSize: function () { @@ -1437,11 +1428,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * add node for widget (this function is deleted in -x) + * Adds a node for widget (this function is deleted in -x) * @param {cc.Node} node * @param {Number} zOrder * @param {Number} tag - * @deprecated + * @deprecated since v3.0, please use addChild instead. */ addNode: function (node, zOrder, tag) { if (node instanceof ccui.Widget) { @@ -1453,8 +1444,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * get node by tag - * @deprecated + * Gets node by tag + * @deprecated since v3.0, please use getChildByTag instead. * @param {Number} tag * @returns {cc.Node} */ @@ -1470,8 +1461,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * get all node - * @deprecated + * Returns all children. + * @deprecated since v3.0, please use getChildren instead. * @returns {Array} */ getNodes: function () { @@ -1479,19 +1470,19 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * remove node - * @deprecated + * Removes a node from ccui.Widget + * @deprecated since v3.0, please use removeChild instead. * @param {cc.Node} node * @param {Boolean} cleanup */ removeNode: function (node, cleanup) { - cc.Node.prototype.removeChild.call(this, node); + cc.Node.prototype.removeChild.call(this, node, cleanup); cc.arrayRemoveObject(this._nodes, node); }, /** - * remove node by tag - * @deprecated + * Removes node by tag + * @deprecated since v3.0, please use removeChildByTag instead. * @param {Number} tag * @param {Boolean} [cleanup] */ @@ -1504,8 +1495,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, /** - * remove all node - * @deprecated + * Removes all node + * @deprecated since v3.0, please use removeAllChildren instead. */ removeAllNodes: function () { for (var i = 0; i < this._nodes.length; i++) { @@ -1530,7 +1521,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this.setColor(this.getColor()); this.setOpacity(this.getOpacity()); } - }); var _p = ccui.Widget.prototype; @@ -1744,6 +1734,11 @@ ccui.Widget.POSITION_PERCENT = 1; cc.EventFocus = cc.Event.extend(/** @lends cc.EventFocus# */{ _widgetGetFocus: null, _widgetLoseFocus: null, + /** + * Constructor function. + * @param {ccui.Widget} widgetLoseFocus + * @param {ccui.Widget} widgetGetFocus + */ ctor: function(widgetLoseFocus, widgetGetFocus){ this._widgetGetFocus = widgetGetFocus; this._widgetLoseFocus = widgetLoseFocus; diff --git a/extensions/ccui/layouts/UIHBox.js b/extensions/ccui/layouts/UIHBox.js index e0aa8d997d..ce5a7bb7b7 100644 --- a/extensions/ccui/layouts/UIHBox.js +++ b/extensions/ccui/layouts/UIHBox.js @@ -42,7 +42,7 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ }, /** - * Initialize a HBox + * Initialize a HBox. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @override * @returns {boolean} */ @@ -70,7 +70,7 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ /** * Creates a HBox object - * @deprecated + * @deprecated since v3.0, please use new ccui.HBox(size) instead. * @param {cc.Size} size * @returns {ccui.HBox} */ diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 684acab664..e2ea13a63a 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -255,7 +255,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ onPassFocusToChild: null, /** - * override "init" method of widget. + * override "init" method of widget. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @returns {boolean} * @override */ @@ -792,10 +792,16 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ /** * Sets a background image CapInsets for layout, if the background image is a scale9 render. - * @param {cc.Rect} capInsets capinsets of background image. + * @param {cc.Rect} capInsets capinsets of background image. */ setBackGroundImageCapInsets: function (capInsets) { - this._backGroundImageCapInsets = capInsets; + if(!capInsets) + return; + var locInsets = this._backGroundImageCapInsets; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; if (this._backGroundScale9Enabled) this._backGroundImage.setCapInsets(capInsets); }, @@ -805,7 +811,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @returns {cc.Rect} */ getBackGroundImageCapInsets: function () { - return this._backGroundImageCapInsets; + return cc.rect(this._backGroundImageCapInsets); }, _supplyTheLayoutParameterLackToChild: function (locChild) { @@ -1755,7 +1761,7 @@ _p = null; /** * allocates and initializes a UILayout. - * @deprecated + * @deprecated since v3.0, please use new ccui.Layout() instead. * @return {ccui.Layout} * @example * // example diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index cfe07da250..c226f6cabf 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -39,7 +39,7 @@ ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ right: 0, bottom: 0, /** - * + * Constructor of ccui.Margin. * @param {Number|ccui.Margin} margin a margin or left * @param {Number} [top] * @param {Number} [right] @@ -396,7 +396,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat /** * Allocates and initializes a RelativeLayoutParameter. * @function - * @deprecated + * @deprecated since v3.0, please use new ccui.RelativeLayoutParameter() instead. * @return {ccui.RelativeLayoutParameter} * @example * // example diff --git a/extensions/ccui/layouts/UIRelativeBox.js b/extensions/ccui/layouts/UIRelativeBox.js index 5d57eb0f98..500c9eee2b 100644 --- a/extensions/ccui/layouts/UIRelativeBox.js +++ b/extensions/ccui/layouts/UIRelativeBox.js @@ -42,7 +42,7 @@ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ }, /** - * Initializes a relative box + * Initializes a relative box. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @override * @returns {boolean} */ @@ -70,7 +70,7 @@ ccui.RelativeBox = ccui.Layout.extend(/** @lends ccui.RelativeBox# */{ /** * Creates a relative box - * @deprecated + * @deprecated since v3.0, please use new ccui.RelativeBox(size) instead. * @param {cc.Size} size * @returns {ccui.RelativeBox} */ diff --git a/extensions/ccui/layouts/UIVBox.js b/extensions/ccui/layouts/UIVBox.js index 93357320ac..53b88b6f58 100644 --- a/extensions/ccui/layouts/UIVBox.js +++ b/extensions/ccui/layouts/UIVBox.js @@ -42,7 +42,7 @@ ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ }, /** - * Initializes a VBox. + * Initializes a VBox. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @override * @returns {boolean} */ diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 3a9969f4fd..68db8c3902 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -81,9 +81,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _type: 0, /** - * allocates and initializes a UIButton. - * Constructor of ccui.Button - * @constructor + * Allocates and initializes a UIButton. + * Constructor of ccui.Button. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {String} normalImage + * @param {String} [selectedImage=""] + * @param {String} [disableImage=""] + * @param {Number} [texType=ccui.Widget.LOCAL_TEXTURE] * @example * // example * var uiButton = new ccui.Button(); @@ -102,6 +105,15 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ texType && this.init(normalImage, selectedImage, disableImage, texType); }, + /** + * Initializes a button. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @param {String} normalImage + * @param {String} [selectedImage=""] + * @param {String} [disableImage=""] + * @param {Number} [texType=ccui.Widget.LOCAL_TEXTURE] + * @returns {boolean} + * @override + */ init: function (normalImage, selectedImage,disableImage, texType) { if (ccui.Widget.prototype.init.call(this)) { if(normalImage === undefined) @@ -115,7 +127,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonNormalRenderer = cc.Sprite.create(); this._buttonClickedRenderer = cc.Sprite.create(); this._buttonDisableRenderer = cc.Sprite.create(); - this._titleRenderer = cc.LabelTTF.create(""); + this._titleRenderer = new cc.LabelTTF(""); this._titleRenderer.setAnchorPoint(0.5, 0.5); this.addProtectedChild(this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER, -1); @@ -170,13 +182,18 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * Get button is using scale9 renderer or not. + * Returns button is using scale9 renderer or not. * @returns {Boolean} */ isScale9Enabled: function () { return this._scale9Enabled; }, + /** + * Sets whether ignore the widget size + * @param {Boolean} ignore true that widget will ignore it's size, use texture size, false otherwise. Default value is true. + * @override + */ ignoreContentAdaptWithSize: function (ignore) { if (!this._scale9Enabled || (this._scale9Enabled && !ignore)) { ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, ignore); @@ -184,15 +201,19 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } }, + /** + * Returns the renderer size. + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return cc.size(this._normalTextureSize); }, /** * Load textures for button. - * @param {String} normal - * @param {String} selected - * @param {String} disabled + * @param {String} normal normal state of texture's filename. + * @param {String} selected selected state of texture's filename. + * @param {String} disabled disabled state of texture's filename. * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextures: function (normal, selected, disabled, texType) { @@ -203,7 +224,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * Load normal state texture for button. - * @param {String} normal + * @param {String} normal normal state of texture's filename. * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureNormal: function (normal, texType) { @@ -274,7 +295,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * Load selected state texture for button. - * @param {String} selected + * @param {String} selected selected state of texture's filename. * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexturePressed: function (selected, texType) { @@ -340,7 +361,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * Load dark state texture for button. - * @param {String} disabled + * @param {String} disabled disabled state of texture's filename. * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureDisabled: function (disabled, texType) { @@ -420,18 +441,24 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {cc.Rect} capInsets */ setCapInsetsNormalRenderer: function (capInsets) { - this._capInsetsNormal = capInsets; + if(!capInsets) + return; + var locInsets = this._capInsetsNormal; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; if (!this._scale9Enabled) return; this._buttonNormalRenderer.setCapInsets(capInsets); }, /** - * Get normal renderer cap insets . + * Returns normal renderer cap insets. * @returns {cc.Rect} */ getCapInsetsNormalRenderer:function(){ - return this._capInsetsNormal; + return cc.rect(this._capInsetsNormal); }, /** @@ -439,18 +466,24 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {cc.Rect} capInsets */ setCapInsetsPressedRenderer: function (capInsets) { - this._capInsetsPressed = capInsets; + if(!capInsets) + return; + var locInsets = this._capInsetsPressed; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; if (!this._scale9Enabled) return; this._buttonClickedRenderer.setCapInsets(capInsets); }, /** - * Get pressed renderer cap insets . + * Returns pressed renderer cap insets. * @returns {cc.Rect} */ getCapInsetsPressedRenderer: function () { - return this._capInsetsPressed; + return cc.rect(this._capInsetsPressed); }, /** @@ -458,21 +491,28 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {cc.Rect} capInsets */ setCapInsetsDisabledRenderer: function (capInsets) { - this._capInsetsDisabled = capInsets; + if(!capInsets) + return; + var locInsets = this._capInsetsDisabled; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; + if (!this._scale9Enabled) return; this._buttonDisableRenderer.setCapInsets(capInsets); }, /** - * Get disable renderer cap insets . + * Returns disable renderer cap insets. * @returns {cc.Rect} */ getCapInsetsDisabledRenderer: function () { - return this._capInsetsDisabled; + return cc.rect(this._capInsetsDisabled); }, - onPressStateChangedToNormal: function () { + _onPressStateChangedToNormal: function () { this._buttonNormalRenderer.setVisible(true); this._buttonClickedRenderer.setVisible(false); this._buttonDisableRenderer.setVisible(false); @@ -480,7 +520,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this.pressedActionEnabled){ this._buttonNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); - var zoomAction = cc.ScaleTo.create(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + var zoomAction = cc.scaleTo(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); this._buttonNormalRenderer.runAction(zoomAction); this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); } @@ -494,7 +534,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } }, - onPressStateChangedToPressed: function () { + _onPressStateChangedToPressed: function () { var locNormalRenderer = this._buttonNormalRenderer; if (this._pressedTextureLoaded) { locNormalRenderer.setVisible(false); @@ -503,7 +543,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this.pressedActionEnabled) { locNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); - var zoomAction = cc.ScaleTo.create(0.05, this._pressedTextureScaleXInSize + 0.1,this._pressedTextureScaleYInSize + 0.1); + var zoomAction = cc.scaleTo(0.05, this._pressedTextureScaleXInSize + 0.1,this._pressedTextureScaleYInSize + 0.1); this._buttonClickedRenderer.runAction(zoomAction); locNormalRenderer.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1); } @@ -520,7 +560,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ } }, - onPressStateChangedToDisabled: function () { + _onPressStateChangedToDisabled: function () { this._buttonNormalRenderer.setVisible(false); this._buttonClickedRenderer.setVisible(false); this._buttonDisableRenderer.setVisible(true); @@ -696,7 +736,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * set title text + * Sets title text to ccui.Button * @param {String} text */ setTitleText: function (text) { @@ -704,7 +744,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * get title text + * Returns title text of ccui.Button * @returns {String} text */ getTitleText: function () { @@ -712,7 +752,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * set title color + * Sets title color to ccui.Button. * @param {cc.Color} color */ setTitleColor: function (color) { @@ -723,7 +763,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * get title color + * Returns title color of ccui.Button * @returns {cc.Color} */ getTitleColor: function () { @@ -731,7 +771,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * set title fontSize + * Sets title fontSize to ccui.Button * @param {cc.Size} size */ setTitleFontSize: function (size) { @@ -739,7 +779,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * get title fontSize + * Returns title fontSize of ccui.Button. * @returns {cc.Size} */ getTitleFontSize: function () { @@ -747,7 +787,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * set title fontName + * Sets title fontName to ccui.Button. * @param {String} fontName */ setTitleFontName: function (fontName) { @@ -756,7 +796,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, /** - * get title fontName + * Gets title fontName of ccui.Button. * @returns {String} */ getTitleFontName: function () { @@ -772,6 +812,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * Returns the "class name" of widget. + * @override * @returns {string} */ getDescription: function () { @@ -797,7 +838,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.setTitleColor(uiButton.getTitleColor()); this.setPressedActionEnabled(uiButton.pressedActionEnabled); } - }); var _p = ccui.Button.prototype; @@ -823,7 +863,7 @@ _p = null; /** * allocates and initializes a UIButton. - * @deprecated + * @deprecated since v3.0, please use new ccui.Button() instead. * @param {string} [normalImage] normal state texture name * @param {string} [selectedImage] selected state texture name * @param {string} [disableImage] disabled state texture name @@ -838,10 +878,33 @@ ccui.Button.create = function (normalImage, selectedImage, disableImage, texType }; // Constants +/** + * The normal renderer's zOrder value. + * @constant + * @type {number} + */ ccui.Button.NORMAL_RENDERER_ZORDER = -2; +/** + * The pressed renderer's zOrder value. + * @constant + * @type {number} + */ ccui.Button.PRESSED_RENDERER_ZORDER = -2; +/** + * The disabled renderer's zOrder value. + * @constant + * @type {number} + */ ccui.Button.DISABLED_RENDERER_ZORDER = -2; +/** + * The title renderer's zOrder value. + * @constant + * @type {number} + */ ccui.Button.TITLE_RENDERER_ZORDER = -1; +/** + * @ignore + */ ccui.Button.SYSTEM = 0; ccui.Button.TTF = 1; diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 2f84b23b51..88cd5e578e 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.CheckBox + * The CheckBox control of Cocos UI. * @class * @extends ccui.Widget * @@ -64,24 +64,41 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ /** * allocates and initializes a UICheckBox. - * Constructor of ccui.CheckBox - * @constructor + * Constructor of ccui.CheckBox, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {String} backGround + * @param {String} backGroundSelected + * @param {String} cross + * @param {String} backGroundDisabled + * @param {String} frontCrossDisabled + * @param {Number} [texType=ccui.Widget.LOCAL_TEXTURE] * @example * // example * var uiCheckBox = new ccui.CheckBox(); */ - ctor: function (backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType) { + ctor: function (backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType) { ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); - texType && this.init(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); + texType && this.init(backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType); }, - init: function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { + + /** + * Initializes a checkBox. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @param {String} backGround + * @param {String} backGroundSelected + * @param {String} cross + * @param {String} backGroundDisabled + * @param {String} frontCrossDisabled + * @param {Number} [texType=ccui.Widget.LOCAL_TEXTURE] + * @returns {boolean} + * @override + */ + init: function (backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType) { if (ccui.Widget.prototype.init.call(this)) { this._isSelected = true; - this.setSelectedState(false); //TODO need test + this.setSelectedState(false); if(backGround === undefined) - this.loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType); + this.loadTextures(backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType); return true; } return false; @@ -102,7 +119,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, /** - * Load textures for checkbox. + * Loads textures for checkbox. * @param {String} backGround * @param {String} backGroundSelected * @param {String} cross @@ -119,8 +136,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, /** - * Load backGround texture for checkbox. - * @param {String} backGround + * Loads background texture for checkbox. + * @param {String} backGround background filename * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGround: function (backGround, texType) { @@ -175,7 +192,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, /** - * Load backGroundSelected texture for checkbox. + * Loads selected state of background texture for checkbox. * @param {String} backGroundSelected * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -222,7 +239,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, /** - * Load cross texture for checkbox. + * Loads cross texture for checkbox. * @param {String} cross * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -236,7 +253,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._frontCrossRenderer.texture || !this._frontCrossRenderer.texture.isLoaded()){ this._frontCrossRenderer.addLoadedEventListener(function(){ - self._findLayout(); self._updateFlippedX(); @@ -267,7 +283,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, /** - * Load backGroundDisabled texture for checkbox. + * Loads disabled state of backGround texture for checkbox. * @param {String} backGroundDisabled * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -281,7 +297,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._backGroundBoxDisabledRenderer.texture || !this._backGroundBoxDisabledRenderer.texture.isLoaded()){ this._backGroundBoxDisabledRenderer.addLoadedEventListener(function(){ - self._findLayout(); self._updateFlippedX(); @@ -312,7 +327,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, /** - * Load frontCrossDisabled texture for checkbox. + * Loads frontCrossDisabled texture for checkbox. * @param {String} frontCrossDisabled * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -356,21 +371,21 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledRendererAdaptDirty = true; }, - onPressStateChangedToNormal: function () { + _onPressStateChangedToNormal: function () { this._backGroundBoxRenderer.setVisible(true); this._backGroundSelectedBoxRenderer.setVisible(false); this._backGroundBoxDisabledRenderer.setVisible(false); this._frontCrossDisabledRenderer.setVisible(false); }, - onPressStateChangedToPressed: function () { + _onPressStateChangedToPressed: function () { this._backGroundBoxRenderer.setVisible(false); this._backGroundSelectedBoxRenderer.setVisible(true); this._backGroundBoxDisabledRenderer.setVisible(false); this._frontCrossDisabledRenderer.setVisible(false); }, - onPressStateChangedToDisabled: function () { + _onPressStateChangedToDisabled: function () { this._backGroundBoxRenderer.setVisible(false); this._backGroundSelectedBoxRenderer.setVisible(false); this._backGroundBoxDisabledRenderer.setVisible(true); @@ -380,6 +395,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } }, + /** + * Sets the selected state to ccui.CheckBox + * @param {Boolean} selected + */ setSelectedState: function (selected) { if (selected == this._isSelected) return; @@ -387,6 +406,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossRenderer.setVisible(this._isSelected); }, + /** + * Returns the selected state of ccui.CheckBox. + * @returns {boolean} + */ getSelectedState: function () { return this._isSelected; }, @@ -417,10 +440,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, /** - * add event listener + * add event listener to ccui.CheckBox. it would called when checkbox is selected or unselected. * @param {Function} selector * @param {Object} target - * @deprecated + * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerCheckBox: function (selector, target) { this._checkBoxEventSelector = selector; @@ -435,6 +458,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._checkBoxEventCallback = callback; }, + /** + * Returns the content size of Renderer. + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return this._backGroundBoxRenderer.getContentSize(); }, @@ -466,7 +493,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ /** * override "getVirtualRenderer" method of widget. - * @returns {cc.Node} + * @override + * @returns {cc.Node} the renderer of ccui.CheckBox. */ getVirtualRenderer: function () { return this._backGroundBoxRenderer; @@ -564,6 +592,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ /** * Returns the "class name" of widget. + * @override * @returns {string} */ getDescription: function () { @@ -623,7 +652,7 @@ _p = null; /** * allocates and initializes a UICheckBox. - * @deprecated + * @deprecated since v3.0, please use new ccui.CheckBox() instead. * @param {string} [backGround] backGround texture. * @param {string} [backGroundSeleted] backGround selected state texture. * @param {string} [cross] cross texture. @@ -641,12 +670,47 @@ ccui.CheckBox.create = function (backGround, backGroundSeleted, cross, backGroun // Constants //CheckBoxEvent type +/** + * The selected state of ccui.CheckBox's event. + * @constant + * @type {number} + */ ccui.CheckBox.EVENT_SELECTED = 0; +/** + * The unselected state of ccui.CheckBox's event. + * @constant + * @type {number} + */ ccui.CheckBox.EVENT_UNSELECTED = 1; //Render zorder +/** + * The normal background renderer's zOrder + * @constant + * @type {number} + */ ccui.CheckBox.BOX_RENDERER_ZORDER = -1; +/** + * The selected Background renderer's zOrder + * @constant + * @type {number} + */ ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER = -1; +/** + * The disabled Background renderer's zOrder + * @constant + * @type {number} + */ ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER = -1; +/** + * The normal front renderer's zOrder + * @constant + * @type {number} + */ ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER = -1; +/** + * The disabled front renderer's zOrder + * @constant + * @type {number} + */ ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER = -1; diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 2f98537a55..e71d8afced 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -40,9 +40,10 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ _imageRendererAdaptDirty: true, /** - * allocates and initializes a UIImageView. - * Constructor of ccui.ImageView - * @constructor + * allocates and initializes a ccui.ImageView. + * Constructor of ccui.ImageView, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {String} imageFileName + * @param {Number} [texType==ccui.Widget.LOCAL_TEXTURE] * @example * // example * var uiImageView = new ccui.ImageView; @@ -55,6 +56,12 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ texType && this.init(imageFileName, texType); }, + /** + * Initializes an imageView. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @param {String} imageFileName + * @param {Number} [texType==ccui.Widget.LOCAL_TEXTURE] + * @returns {boolean} + */ init: function(imageFileName, texType){ if(ccui.Widget.prototype.init.call(this)){ if(imageFileName === undefined) @@ -72,7 +79,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, /** - * Load textures for button. + * Loads textures for button. * @param {String} fileName * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -135,7 +142,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, /** - * set texture rect + * Sets texture rect * @param {cc.Rect} rect */ setTextureRect: function (rect) { @@ -185,7 +192,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, /** - * Get button is using scale9 renderer or not. + * Returns ImageView is using scale9 renderer or not. * @returns {Boolean} */ isScale9Enabled:function(){ @@ -193,7 +200,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, /** - * ignoreContentAdaptWithSize + * Ignore the imageView's custom size, true that imageView will ignore it's custom size, use renderer's content size, false otherwise. + * @override * @param {Boolean} ignore */ ignoreContentAdaptWithSize: function (ignore) { @@ -208,18 +216,25 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {cc.Rect} capInsets */ setCapInsets: function (capInsets) { - this._capInsets = capInsets; + if(!capInsets) + return; + var locInsets = this._capInsets; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; + if (!this._scale9Enabled) return; this._imageRenderer.setCapInsets(capInsets); }, /** - * Get cap insets. + * Returns cap insets of ccui.ImageView. * @returns {cc.Rect} */ getCapInsets:function(){ - return this._capInsets; + return cc.rect(this._capInsets); }, _onSizeChanged: function () { @@ -234,12 +249,17 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ } }, + /** + * Returns the image's texture size. + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return cc.size(this._imageTextureSize); }, /** - * override "getVirtualRenderer" method of widget. + * Returns the renderer of ccui.ImageView + * @override * @returns {cc.Node} */ getVirtualRenderer: function () { @@ -267,7 +287,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.ImageView. + * @override * @returns {string} */ getDescription: function () { @@ -290,8 +311,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }); /** - * allocates and initializes a UIImageView. - * @deprecated + * Allocates and initializes a UIImageView. + * @deprecated since v3.0, please use new ccui.ImageView() instead. * @param {string} imageFileName * @param {Number} texType * @return {ccui.ImageView} @@ -304,4 +325,9 @@ ccui.ImageView.create = function (imageFileName, texType) { }; // Constants +/** + * The zOrder value of ccui.ImageView's renderer. + * @constant + * @type {number} + */ ccui.ImageView.RENDERER_ZORDER = -1; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index f7004b4ec9..4ee694c239 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.LoadingBar + * The LoadingBar control of Cocos UI. * @class * @extends ccui.Widget * @@ -47,9 +47,10 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _barRendererAdaptDirty: true, /** - * allocates and initializes a UILoadingBar. - * Constructor of ccui.LoadingBar - * @constructor + * allocates and initializes a UILoadingBar.
    + * Constructor of ccui.LoadingBar, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {string} textureName + * @param {Number} percentage * @example * // example * var uiLoadingBar = new ccui.LoadingBar; @@ -73,7 +74,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, /** - * Changes the progress direction of LoadingBar. + * Changes the progress direction of LoadingBar.
    * LoadingBarTypeLeft means progress left to right, LoadingBarTypeRight otherwise. * @param {ccui.LoadingBar.TYPE_LEFT | ccui.LoadingBar.TYPE_RIGHT} dir */ @@ -98,7 +99,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, /** - * Gets the progress direction of LoadingBar. + * Returns the progress direction of LoadingBar.
    * LoadingBarTypeLeft means progress left to right, LoadingBarTypeRight otherwise. * @returns {ccui.LoadingBar.TYPE_LEFT | ccui.LoadingBar.TYPE_RIGHT} */ @@ -107,7 +108,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, /** - * Load texture for LoadingBar. + * Loads texture for LoadingBar. * @param {String} texture * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -216,7 +217,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, /** - * Get LoadingBar is using scale9 renderer or not.. + * Returns LoadingBar is using scale9 renderer or not.. * @returns {Boolean} */ isScale9Enabled: function () { @@ -228,21 +229,28 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ * @param {cc.Rect} capInsets */ setCapInsets: function (capInsets) { - this._capInsets = capInsets; + if(!capInsets) + return; + var locInsets = this._capInsets; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; + if (this._scale9Enabled) this._barRenderer.setCapInsets(capInsets); }, /** - * Get cap insets for loadingBar. + * Returns cap insets for loadingBar. * @returns {cc.Rect} */ getCapInsets: function () { - return this._capInsets; + return cc.rect(this._capInsets); }, /** - * The current progress of loadingbar + * The current progress of loadingBar * @param {number} percent percent value from 1 to 100. */ setPercent: function (percent) { @@ -270,14 +278,19 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } }, + /** + * Sets the contentSize of ccui.LoadingBar + * @override + * @param {Number|cc.Size} contentSize + * @param {Number} [height] + */ setContentSize: function(contentSize, height){ ccui.Widget.prototype.setContentSize.call(this, contentSize, height); - var locWidth = (height === undefined) ? contentSize.width : contentSize; - this._totalLength = locWidth; + this._totalLength = (height === undefined) ? contentSize.width : contentSize;; }, /** - * Gets the progress direction of LoadingBar. + * Returns the progress direction of LoadingBar. * @returns {number} percent value from 1 to 100. */ getPercent: function () { @@ -297,7 +310,8 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, /** - * override "ignoreContentAdaptWithSize" method of widget. + * Ignore the LoadingBar's custom size, if ignore is true that LoadingBar will ignore it's custom size, use renderer's content size, false otherwise. + * @override * @param {Boolean}ignore */ ignoreContentAdaptWithSize: function (ignore) { @@ -307,12 +321,17 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } }, + /** + * Returns the texture size of renderer. + * @returns {cc.Size|*} + */ getVirtualRendererSize:function(){ return cc.size(this._barRendererTextureSize); }, /** - * override "getContentSize" method of widget. + * Returns the renderer of ccui.LoadingBar + * @override * @returns {cc.Node} */ getVirtualRenderer: function () { @@ -396,8 +415,8 @@ cc.defineGetterSetter(_p, "percent", _p.getPercent, _p.setPercent); _p = null; /** - * allocates and initializes a UILoadingBar. - * @deprecated + * Allocates and initializes a UILoadingBar. + * @deprecated since v3.0, please use new ccui.LoadingBar() instead. * @param {string} textureName * @param {Number} percentage * @return {ccui.LoadingBar} @@ -411,7 +430,23 @@ ccui.LoadingBar.create = function (textureName, percentage) { // Constants //loadingBar Type + +/** + * The left direction of ccui.LoadingBar. + * @constant + * @type {number} + */ ccui.LoadingBar.TYPE_LEFT = 0; +/** + * The right direction of ccui.LoadingBar. + * @constant + * @type {number} + */ ccui.LoadingBar.TYPE_RIGHT = 1; +/** + * The zOrder value of ccui.LoadingBar's renderer. + * @constant + * @type {number} + */ ccui.LoadingBar.RENDERER_ZORDER = -1; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 3352f2235a..577e4a2da0 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.RichElement + * ccui.RichElement is the base class of RichElementText, RichElementImage etc. It has type, tag, color and opacity attributes. * @class * @extends ccui.Class */ @@ -33,11 +33,21 @@ ccui.RichElement = ccui.Class.extend(/** @lends ccui.RichElement# */{ _tag: 0, _color: null, _opacity:0, + /** + * Constructor of ccui.RichElement + */ ctor: function () { this._type = 0; this._tag = 0; this._color = cc.color(255, 255, 255, 255); }, + + /** + * Initializes a richElement. + * @param {Number} tag + * @param {cc.Color} color + * @param {Number} opacity + */ init: function (tag, color, opacity) { this._tag = tag; this._color.r = color.r; @@ -52,7 +62,7 @@ ccui.RichElement = ccui.Class.extend(/** @lends ccui.RichElement# */{ }); /** - * Base class for ccui.RichElementText + * The text element for RichText, it has text, fontName, fontSize attributes. * @class * @extends ccui.RichElement */ @@ -60,6 +70,15 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# _text: "", _fontName: "", _fontSize: 0, + /** + * Constructor of ccui.RichElementText + * @param {Number} tag + * @param {cc.Color} color + * @param {Number} opacity + * @param {String} text + * @param {String} fontName + * @param {Number} fontSize + */ ctor: function (tag, color, opacity, text, fontName, fontSize) { ccui.RichElement.prototype.ctor.call(this); this._type = ccui.RichElement.TEXT; @@ -69,6 +88,17 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# fontSize && this.init(tag, color, opacity, text, fontName, fontSize); }, + + /** + * Initializes a ccui.RichElementText. + * @param {Number} tag + * @param {cc.Color} color + * @param {Number} opacity + * @param {String} text + * @param {String} fontName + * @param {Number} fontSize + * @override + */ init: function (tag, color, opacity, text, fontName, fontSize) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); this._text = text; @@ -79,7 +109,7 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# /** * Create a richElementText - * @deprecated + * @deprecated since v3.0, please use new ccui.RichElementText() instead. * @param {Number} tag * @param {cc.Color} color * @param {Number} opacity @@ -93,7 +123,7 @@ ccui.RichElementText.create = function (tag, color, opacity, text, fontName, fon }; /** - * Base class for ccui.RichElementImage + * The image element for RichText, it has filePath, textureRect, textureType attributes. * @class * @extends ccui.RichElement */ @@ -101,6 +131,14 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage _filePath: "", _textureRect: null, _textureType: 0, + + /** + * Constructor of ccui.RichElementImage + * @param {Number} tag + * @param {cc.Color} color + * @param {Number} opacity + * @param {String} filePath + */ ctor: function (tag, color, opacity, filePath) { ccui.RichElement.prototype.ctor.call(this); this._type = ccui.RichElement.IMAGE; @@ -110,6 +148,15 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage filePath && this.init(tag, color, opacity, filePath); }, + + /** + * Initializes a ccui.RichElementImage + * @param {Number} tag + * @param {cc.Color} color + * @param {Number} opacity + * @param {String} filePath + * @override + */ init: function (tag, color, opacity, filePath) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); this._filePath = filePath; @@ -118,7 +165,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage /** * Create a richElementImage - * @deprecated + * @deprecated since v3.0, please use new ccui.RichElementImage() instead. * @param {Number} tag * @param {cc.Color} color * @param {Number} opacity @@ -130,12 +177,20 @@ ccui.RichElementImage.create = function (tag, color, opacity, filePath) { }; /** - * Base class for ccui.RichElementCustomNode + * The custom node element for RichText. * @class * @extends ccui.RichElement */ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElementCustomNode# */{ _customNode: null, + + /** + * Constructor of ccui.RichElementCustomNode + * @param {Number} tag + * @param {cc.Color} color + * @param {Number} opacity + * @param {cc.Node} customNode + */ ctor: function (tag, color, opacity, customNode) { ccui.RichElement.prototype.ctor.call(this); this._type = ccui.RichElement.CUSTOM; @@ -143,6 +198,15 @@ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElement customNode && this.init(tag, color, opacity, customNode); }, + + /** + * Initializes a ccui.RichElementCustomNode + * @param {Number} tag + * @param {cc.Color} color + * @param {Number} opacity + * @param {cc.Node} customNode + * @override + */ init: function (tag, color, opacity, customNode) { ccui.RichElement.prototype.init.call(this, tag, color, opacity); this._customNode = customNode; @@ -151,7 +215,7 @@ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElement /** * Create a richElementCustomNode - * @deprecated + * @deprecated since v3.0, please use new ccui.RichElementCustomNode() instead. * @param {Number} tag * @param {Number} color * @param {Number} opacity @@ -163,7 +227,7 @@ ccui.RichElementCustomNode.create = function (tag, color, opacity, customNode) { }; /** - * Base class for ccui.RichText + * The rich text control of Cocos UI. It receives text, image, and custom node as its children to display. * @class * @extends ccui.Widget */ @@ -177,7 +241,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ /** * create a rich text - * Constructor of ccui.RichText + * Constructor of ccui.RichText. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @example * var uiRichText = new ccui.RichTex(); */ @@ -227,6 +291,9 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._formatTextDirty = true; }, + /** + * Formats the richText's content. + */ formatText: function () { if (this._formatTextDirty) { this._elementRenderersContainer.removeAllChildren(); @@ -240,7 +307,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ switch (element._type) { case ccui.RichElement.TEXT: //todo: There may be ambiguous - elementRenderer = cc.LabelTTF.create(element._text, element._fontName, element._fontSize); + elementRenderer = new cc.LabelTTF(element._text, element._fontName, element._fontSize); break; case ccui.RichElement.IMAGE: elementRenderer = cc.Sprite.create(element._filePath); @@ -279,15 +346,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } }, - /** - * Handle text renderer - * @param {String} text - * @param {String} fontName - * @param {Number} fontSize - * @param {cc.Color} color - */ _handleTextRenderer: function (text, fontName, fontSize, color) { - var textRenderer = cc.LabelTTF.create(text, fontName, fontSize); + var textRenderer = new cc.LabelTTF(text, fontName, fontSize); var textRendererWidth = textRenderer.getContentSize().width; this._leftSpaceWidth -= textRendererWidth; if (this._leftSpaceWidth < 0) { @@ -298,7 +358,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var leftWords = curText.substr(0, leftLength); var cutWords = curText.substr(leftLength, curText.length - 1); if (leftLength > 0) { - var leftRenderer = cc.LabelTTF.create(leftWords.substr(0, leftLength), fontName, fontSize); + var leftRenderer = new cc.LabelTTF(leftWords.substr(0, leftLength), fontName, fontSize); leftRenderer.setColor(color); leftRenderer.setOpacity(color.a); this._pushToContainer(leftRenderer); @@ -313,21 +373,11 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } }, - /** - * Handle image renderer - * @param {String} filePath - * @param {cc.Color} color - * @param {Number} opacity - */ _handleImageRenderer: function (filePath, color, opacity) { var imageRenderer = cc.Sprite.create(filePath); this._handleCustomRenderer(imageRenderer); }, - /** - * Handle custom renderer - * @param {cc.Node} renderer - */ _handleCustomRenderer: function (renderer) { var imgSize = renderer.getContentSize(); this._leftSpaceWidth -= imgSize.width; @@ -344,6 +394,9 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._elementRenders.push([]); }, + /** + * Formats richText's renderer. + */ formatRenderers: function () { var newContentSizeHeight = 0, locRenderersContainer = this._elementRenderersContainer; var locElementRenders = this._elementRenders; @@ -404,25 +457,26 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ locRenderersContainer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); }, - /** - * Push renderer to container - * @param {cc.Node} renderer - */ _pushToContainer: function (renderer) { if (this._elementRenders.length <= 0) return; this._elementRenders[this._elementRenders.length - 1].push(renderer); }, - visit: function (renderer, parentTransform, parentFlags) { + /** + * Calls formatText before calls parent class' visit. + * @override + * @param ctx + */ + visit: function (ctx) { if (this._enabled) { this.formatText(); - ccui.Widget.prototype.visit.call(this, renderer, parentTransform, parentFlags); + ccui.Widget.prototype.visit.call(this, ctx); } }, /** - * Set vertical space + * Sets vertical space * @param {Number} space */ setVerticalSpace: function (space) { @@ -430,7 +484,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ }, /** - * Set anchor point + * Sets anchor point + * @override * @param {cc.Point} pt */ setAnchorPoint: function (pt) { @@ -438,13 +493,19 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._elementRenderersContainer.setAnchorPoint(pt); }, + /** + * Returns the renderer container's content size. + * @override + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return this._elementRenderersContainer.getContentSize(); }, /** - * Ignore content adapt with size + * Ignore the richText's custom size, If ignore is true that richText will ignore it's custom size, use renderer's content size, false otherwise. * @param {Boolean} ignore + * @override */ ignoreContentAdaptWithSize: function (ignore) { if (this._ignoreSize != ignore) { @@ -463,6 +524,10 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ return cc.Node.prototype.getContentSize.l(this); }, + /** + * Returns the class name of ccui.RichText. + * @returns {string} + */ getDescription: function(){ return "RichText"; } @@ -470,7 +535,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ /** * create a rich text - * @deprecated + * @deprecated since v3.0, please use new ccui.RichText() instead. * @returns {RichText} * @example * var uiRichText = ccui.RichTex.create(); @@ -481,6 +546,21 @@ ccui.RichText.create = function(){ // Constants //Rich element type +/** + * The text type of rich element. + * @constant + * @type {number} + */ ccui.RichElement.TEXT = 0; +/** + * The image type of rich element. + * @constant + * @type {number} + */ ccui.RichElement.IMAGE = 1; +/** + * The custom type of rich element. + * @constant + * @type {number} + */ ccui.RichElement.CUSTOM = 2; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 96eef3c195..f06cfd06a5 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.Slider + * The Slider control of Cocos UI. * @class * @extends ccui.Widget * @@ -60,9 +60,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _className: "Slider", _barRendererAdaptDirty: true, _progressBarRendererDirty: true, + /** * allocates and initializes a UISlider. - * Constructor of ccui.Slider + * Constructor of ccui.Slider. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @example * // example * var uiSlider = new ccui.Slider(); @@ -74,11 +75,13 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ ccui.Widget.prototype.ctor.call(this); }, + /** + * Initializes a ccui.Slider. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @returns {boolean} + * @override + */ init: function () { - if (ccui.Widget.prototype.init.call(this)) { - return true; - } - return false; + return ccui.Widget.prototype.init.call(this); }, _initRenderer: function () { @@ -92,7 +95,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._slidBallPressedRenderer.setVisible(false); this._slidBallDisabledRenderer = cc.Sprite.create(); this._slidBallDisabledRenderer.setVisible(false); - this._slidBallRenderer = cc.Node.create(); + this._slidBallRenderer = new cc.Node(); this._slidBallRenderer.addChild(this._slidBallNormalRenderer); this._slidBallRenderer.addChild(this._slidBallPressedRenderer); this._slidBallRenderer.addChild(this._slidBallDisabledRenderer); @@ -100,7 +103,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * Load texture for slider bar. + * Loads texture for slider bar. * @param {String} fileName * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -116,7 +119,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ barRenderer.addLoadedEventListener(function(){ - self._findLayout(); self._updateChildrenDisplayedRGBA(); @@ -146,7 +148,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * Load dark state texture for slider progress bar. + * Loads dark state texture for slider progress bar. * @param {String} fileName * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -162,7 +164,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!progressBarRenderer.texture || !progressBarRenderer.texture.isLoaded()){ progressBarRenderer.addLoadedEventListener(function(){ - self._findLayout(); self._updateChildrenDisplayedRGBA(); @@ -198,9 +199,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * @param {Boolean} able */ setScale9Enabled: function (able) { - if (this._scale9Enabled == able) { + if (this._scale9Enabled == able) return; - } this._scale9Enabled = able; this.removeProtectedChild(this._barRenderer, true); @@ -222,8 +222,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var ignoreBefore = this._ignoreSize; this.ignoreContentAdaptWithSize(false); this._prevIgnoreSize = ignoreBefore; - } - else { + } else { this.ignoreContentAdaptWithSize(this._prevIgnoreSize); } this.setCapInsetsBarRenderer(this._capInsetsBarRenderer); @@ -231,7 +230,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * Get slider is using scale9 renderer or not. + * Returns slider is using scale9 renderer or not. * @returns {Boolean} */ isScale9Enabled: function () { @@ -259,56 +258,57 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * Sets capinsets for slider, if slider is using scale9 renderer. + * Sets capinsets for slider's renderer, if slider is using scale9 renderer. * @param {cc.Rect} capInsets */ setCapInsetsBarRenderer: function (capInsets) { - this._capInsetsBarRenderer = capInsets; - if (!this._scale9Enabled) { + if(!capInsets) + return; + var locInsets = this._capInsetsBarRenderer; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; + if (!this._scale9Enabled) return; - } this._barRenderer.setCapInsets(capInsets); }, /** - * Get cap insets for slider. + * Returns cap insets for slider. * @returns {cc.Rect} */ getCapInsetsBarRenderer: function () { - return this._capInsetsBarRenderer; - }, - - setCapInsetProgressBarRebderer: function(capInsets){ - this._capInsetsProgressBarRenderer = capInsets; - if (!this._scale9Enabled) - { - return; - } - this._progressBarRenderer.setCapInsets(capInsets); + return cc.rect(this._capInsetsBarRenderer); }, /** - * Sets capinsets for slider, if slider is using scale9 renderer. + * Sets capinsets of ProgressBar for slider, if slider is using scale9 renderer. * @param {cc.Rect} capInsets */ setCapInsetProgressBarRenderer: function (capInsets) { - this._capInsetsProgressBarRenderer = capInsets; - if (!this._scale9Enabled) { + if(!capInsets) + return; + var locInsets = this._capInsetsProgressBarRenderer; + locInsets.x = capInsets.x; + locInsets.y = capInsets.y; + locInsets.width = capInsets.width; + locInsets.height = capInsets.height; + if (!this._scale9Enabled) return; - } this._progressBarRenderer.setCapInsets(capInsets); }, /** - * Get cap insets for slider. + * Returns cap insets of ProgressBar for slider. * @returns {cc.Rect} */ - getCapInsetsProgressBarRebderer: function () { - return this._capInsetsProgressBarRenderer; + getCapInsetsProgressBarRenderer: function () { + return cc.rect(this._capInsetsProgressBarRenderer); }, /** - * Load textures for slider ball. + * Loads textures for slider ball. * @param {String} normal * @param {String} pressed * @param {String} disabled @@ -321,7 +321,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * Load normal state texture for slider ball. + * Loads normal state texture for slider ball. * @param {String} normal * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -336,7 +336,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallNormalRenderer.texture || !this._slidBallNormalRenderer.texture.isLoaded()){ this._slidBallNormalRenderer.addLoadedEventListener(function(){ - self._updateChildrenDisplayedRGBA(); }); } @@ -357,7 +356,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * Load selected state texture for slider ball. + * Loads selected state texture for slider ball. * @param {String} pressed * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ @@ -433,19 +432,16 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * @param {number} percent */ setPercent: function (percent) { - if (percent > 100) { + if (percent > 100) percent = 100; - } - if (percent < 0) { + if (percent < 0) percent = 0; - } this._percent = percent; var res = percent / 100.0; var dis = this._barLength * res; this._slidBallRenderer.setPosition(cc.p(dis, this._contentSize.height / 2)); - if (this._scale9Enabled) { + if (this._scale9Enabled) this._progressBarRenderer.setPreferredSize(cc.size(dis, this._progressBarTextureSize.height)); - } else { var spriteRenderer = this._progressBarRenderer; var rect = spriteRenderer.getTextureRect(); @@ -456,18 +452,21 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } }, + /** + * test the point whether location in loadingBar's bounding box. + * @override + * @param {cc.Point} pt + * @returns {boolean} + */ hitTest: function(pt){ var nsp = this._slidBallNormalRenderer.convertToNodeSpace(pt); var ballSize = this._slidBallNormalRenderer.getContentSize(); var ballRect = cc.rect(0,0, ballSize.width, ballSize.height); // if (ballRect.containsPoint(nsp)) { - if (nsp.x >= ballRect.x && + return (nsp.x >= ballRect.x && nsp.x <= (ballRect.x + ballRect.width) && nsp.y >= ballRect.y && - nsp.y <= (ballRect.y +ballRect.height)) { - return true; - } - return false; + nsp.y <= (ballRect.y +ballRect.height)); }, onTouchBegan: function (touch, event) { @@ -496,7 +495,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * get percent with ballPos + * Returns percent with ball's position. * @param {cc.Point} px * @returns {number} */ @@ -514,6 +513,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._sliderEventListener = target; }, + /** + * Adds a callback + * @param {function} callback + */ addEventListener: function(callback){ this._eventCallback = callback; }, @@ -556,12 +559,16 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } }, + /** + * Returns the content size of bar renderer. + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return this._barRenderer.getContentSize(); }, /** - * override "getContentSize" method of widget. + * Returns the bar renderer. * @returns {cc.Node} */ getVirtualRenderer: function () { @@ -644,7 +651,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.LoadingBar. * @returns {string} */ getDescription: function () { @@ -682,7 +689,7 @@ _p = null; /** * allocates and initializes a UISlider. - * @deprecated + * @deprecated since v3.0, please use new ccui.Slider() instead. * @return {ccui.Slider} * @example * // example @@ -694,9 +701,29 @@ ccui.Slider.create = function () { // Constant //Slider event type +/** + * The percent change event flag of ccui.Slider. + * @constant + * @type {number} + */ ccui.Slider.EVENT_PERCENT_CHANGED = 0; //Render zorder +/** + * The zOrder value of ccui.Slider's base bar renderer. + * @constant + * @type {number} + */ ccui.Slider.BASEBAR_RENDERER_ZORDER = -3; +/** + * The zOrder value of ccui.Slider's progress bar renderer. + * @constant + * @type {number} + */ ccui.Slider.PROGRESSBAR_RENDERER_ZORDER = -2; +/** + * The zOrder value of ccui.Slider's ball renderer. + * @constant + * @type {number} + */ ccui.Slider.BALL_RENDERER_ZORDER = -1; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 73556206c1..964cb76077 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -25,7 +25,7 @@ /** - * Base class for ccui.Button + * The text control of Cocos UI. * @class * @extends ccui.Widget * @@ -57,8 +57,10 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ /** * allocates and initializes a UILabel. - * Constructor of ccui.Text - * @constructor + * Constructor of ccui.Text. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {String} textContent + * @param {String} fontName + * @param {Number} fontSize * @example * // example * var uiLabel = new ccui.Text(); @@ -72,6 +74,14 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, + /** + * Initializes a ccui.Text. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @param {String} textContent + * @param {String} fontName + * @param {Number} fontSize + * @returns {boolean} + * @override + */ init: function (textContent, fontName, fontSize) { if (ccui.Widget.prototype.init.call(this)) { if(arguments.length > 0){ @@ -90,8 +100,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Changes the value of label. - * @deprecated + * Changes the value of ccui.Text. + * @deprecated since v3.0, please use setString() instead. * @param {String} text */ setText: function (text) { @@ -100,7 +110,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Changes the value of label. + * Changes the value of ccui.Text. * @param {String} text */ setString: function (text) { @@ -110,8 +120,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Gets the string value of label. - * @deprecated + * Gets the string value of ccui.Text. + * @deprecated since v3.0, please use getString instead. * @returns {String} */ getStringValue: function () { @@ -120,7 +130,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Gets the string value of label. + * Gets the string value of ccui.Text. * @returns {String} */ getString: function () { @@ -128,7 +138,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Gets the string length of label. + * Gets the string length of ccui.Text. * @returns {Number} */ getStringLength: function () { @@ -136,7 +146,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * set fontSize + * Sets fontSize * @param {Number} size */ setFontSize: function (size) { @@ -147,7 +157,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Get font Size + * Returns font Size of ccui.Text * @returns {Number} */ getFontSize: function () { @@ -155,7 +165,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Set font name + * Sets font name * @return {String} name */ setFontName: function (name) { @@ -166,7 +176,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Get font name + * Returns font name of ccui.Text. * @returns {string} */ getFontName: function () { @@ -186,12 +196,16 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ return this._labelRenderer._getFont(); }, + /** + * Returns the type of ccui.Text. + * @returns {null} + */ getType: function(){ return this._type; }, /** - * set textAreaSize + * Sets text Area Size * @param {cc.Size} size */ setTextAreaSize: function (size) { @@ -200,12 +214,16 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._labelRendererAdaptDirty = true; }, + /** + * Returns renderer's dimension. + * @returns {cc.Size} + */ getTextAreaSize: function(){ return this._labelRenderer.getDimensions(); }, /** - * set Horizontal Alignment of cc.LabelTTF + * Sets Horizontal Alignment of cc.LabelTTF * @param {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT} alignment Horizontal Alignment */ setTextHorizontalAlignment: function (alignment) { @@ -215,7 +233,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Return Horizontal Alignment of label + * Returns Horizontal Alignment of label * @returns {TEXT_ALIGNMENT_LEFT|TEXT_ALIGNMENT_CENTER|TEXT_ALIGNMENT_RIGHT} */ getTextHorizontalAlignment: function () { @@ -223,7 +241,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Set Vertical Alignment of label + * Sets Vertical Alignment of label * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} alignment */ setTextVerticalAlignment: function (alignment) { @@ -233,7 +251,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Get text vertical alignment. + * Gets text vertical alignment. * @returns {VERTICAL_TEXT_ALIGNMENT_TOP|VERTICAL_TEXT_ALIGNMENT_CENTER|VERTICAL_TEXT_ALIGNMENT_BOTTOM} */ getTextVerticalAlignment: function () { @@ -271,7 +289,6 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _onPressStateChangedToDisabled: function () { - }, _updateFlippedX: function () { @@ -300,12 +317,17 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ } }, + /** + * Returns the renderer's content size. + * @override + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return this._labelRenderer.getContentSize(); }, /** - * override "getVirtualRenderer" method of widget. + * Returns the renderer of ccui.Text. * @returns {cc.Node} */ getVirtualRenderer: function () { @@ -335,28 +357,47 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.Text. * @returns {string} */ getDescription: function () { return "Label"; }, + /** + * Enables shadow style and sets color, offset and blur radius styles. + * @param {cc.Color} shadowColor + * @param {cc.Size} offset + * @param {Number} blurRadius + */ enableShadow: function(shadowColor, offset, blurRadius){ this._labelRenderer.enableShadow(shadowColor, offset, blurRadius); }, + /** + * Enables outline style and sets outline's color and size. + * @param {cc.Color} outlineColor + * @param {cc.Size} outlineSize + */ enableOutline: function(outlineColor, outlineSize){ this._labelRenderer.enableOutline(outlineColor, outlineSize); }, + /** + * Enables glow color + * @param glowColor + */ enableGlow: function(glowColor){ if (this._type == ccui.Text.Type.TTF) this._labelRenderer.enableGlow(glowColor); }, + /** + * Disables renderer's effect. + */ disableEffect: function(){ - this._labelRenderer.disableEffect(); + if(this._labelRenderer.disableEffect) + this._labelRenderer.disableEffect(); }, _createCloneInstance: function () { @@ -429,7 +470,7 @@ _p = null; /** * allocates and initializes a UILabel. - * @deprecated + * @deprecated since v3.0, please use new ccui.Text() instead. * @return {ccui.Text} * @example * // example @@ -439,9 +480,16 @@ ccui.Label = ccui.Text.create = function (textContent, fontName, fontSize) { return new ccui.Text(textContent, fontName, fontSize); }; +/** + * The zOrder value of ccui.Text's renderer. + * @constant + * @type {number} + */ ccui.Text.RENDERER_ZORDER = -1; - +/** + * @ignore + */ ccui.Text.Type = { SYSTEM: 0, TTF: 1 diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 95278087b2..9284c8e483 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.TextAtlas + * The text atlas control of Cocos UI. * @class * @extends ccui.Widget * @@ -41,9 +41,13 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ _labelAtlasRendererAdaptDirty: null, /** - * allocates and initializes a UILabelAtlas. - * Constructor of ccui.TextAtlas - * @constructor + * Allocates and initializes a UILabelAtlas.
    + * Constructor of ccui.TextAtlas, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {String} stringValue + * @param {String} charMapFile + * @param {number} itemWidth + * @param {number} itemHeight + * @param {String} startCharMap * @example * // example * var uiLabelAtlas = new ccui.TextAtlas(); @@ -55,7 +59,6 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ _initRenderer: function () { this._labelAtlasRenderer = new cc.LabelAtlas(); - //cc.Node.prototype.addChild.call(this, this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5, 0.5)); this.addProtectedChild(this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1); }, @@ -74,10 +77,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._itemWidth = itemWidth; this._itemHeight = itemHeight; this._startCharMap = startCharMap; -// this._labelAtlasRenderer.initWithString(stringValue, this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); -// this._labelAtlasRenderer.setCharMap(this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]); -// this._labelAtlasRenderer.setString(stringValue); this._labelAtlasRenderer.initWithString( stringValue, this._charMapFileName, @@ -88,24 +88,22 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; - }, /** - * set string value for ui text atlas. + * Sets string value for ui text atlas. * @param {String} value */ setString: function (value) { this._stringValue = value; this._labelAtlasRenderer.setString(value); -// this._labelAtlasScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); this._labelAtlasRendererAdaptDirty = true; }, /** - * set string value for labelatlas. - * @deprecated + * Sets string value for text atlas. + * @deprecated since v3.0, please use setString instead. * @param {String} value */ setStringValue: function (value) { @@ -114,8 +112,8 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ }, /** - * get string value for labelatlas. - * @deprecated + * get string value for text atlas. + * @deprecated since v3.0, please use getString instead. * @returns {String} */ getStringValue: function () { @@ -131,13 +129,16 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ return this._labelAtlasRenderer.getString(); }, + /** + * Returns the length of string. + * @returns {*|Number|long|int} + */ getStringLength: function(){ return this._labelAtlasRenderer.getStringLength(); }, _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); -// this._labelAtlasScaleChangedWithSize(); this._labelAtlasRendererAdaptDirty = true; }, @@ -146,15 +147,19 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ this._labelAtlasScaleChangedWithSize(); this._labelAtlasRendererAdaptDirty = false; } - }, + /** + * Returns the renderer's content size + * @overrider + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return this._labelAtlasRenderer.getContentSize(); }, /** - * override "getVirtualRenderer" method of widget. + * Returns the renderer of ccui.TextAtlas. * @returns {cc.Node} */ getVirtualRenderer: function () { @@ -178,7 +183,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.TextAtlas. * @returns {string} */ getDescription: function () { @@ -207,7 +212,7 @@ _p = null; /** * allocates and initializes a UILabelAtlas. - * @deprecated + * @deprecated since v3.0, please use new ccui.TextAtlas() instead. * @return {ccui.TextAtlas} * @example * // example @@ -218,4 +223,8 @@ ccui.TextAtlas.create = function (stringValue, charMapFile, itemWidth, itemHeigh }; // Constants +/** + * The zOrder value of ccui.TextAtlas's renderer. + * @type {number} + */ ccui.TextAtlas.RENDERER_ZORDER = -1; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index d60c43d2a1..d9fd490e89 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -39,9 +39,10 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo _labelBMFontRendererAdaptDirty: true, /** - * allocates and initializes a UILabelBMFont. - * Constructor of ccui.TextBMFont - * @constructor + * allocates and initializes a UILabelBMFont.
    + * Constructor of ccui.TextBMFont. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {String} text + * @param {String} filename * @example * // example * var uiLabelBMFont = new ccui.TextBMFont(); @@ -55,7 +56,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo } }, _initRenderer: function () { - this._labelBMFontRenderer = cc.LabelBMFont.create(); + this._labelBMFontRenderer = new cc.LabelBMFont(); this.addProtectedChild(this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); }, @@ -69,10 +70,8 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo } var _self = this; _self._fntFileName = fileName; -// this._labelBMFontRenderer.setBMFontFilePath(fileName); _self._fntFileHasInit = true; -// this.setString(this._stringValue); _self._labelBMFontRenderer.initWithString(this._stringValue, fileName); var locRenderer = _self._labelBMFontRenderer; @@ -85,7 +84,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo /** * set string value for labelbmfont - * @deprecated + * @deprecated since v3.0, please use setString instead. * @param {String} value */ setText: function (value) { @@ -167,11 +166,11 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo return "LabelBMFont"; }, - createCloneInstance: function () { - return ccui.TextBMFont.create(); + _createCloneInstance: function () { + return new ccui.TextBMFont(); }, - copySpecialProperties: function (labelBMFont) { + _copySpecialProperties: function (labelBMFont) { this.setFntFile(labelBMFont._fntFileName); this.setString(labelBMFont._stringValue); } @@ -188,7 +187,7 @@ _p = null; /** * allocates and initializes a UILabelBMFont. - * @deprecated + * @deprecated since v3.0, please use new ccui.TextBMFont() instead. * @return {ccui.TextBMFont} * @example * // example diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index b7f1d34ae5..ad8fd47d7e 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -24,7 +24,8 @@ ****************************************************************************/ /** - * Base class for ccui.UICCTextField + * The renderer of ccui.TextField. + * @private * @class * @extends cc.TextFieldTTF * @@ -32,7 +33,7 @@ * @property {Number} maxLength - The max length of the text field * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password */ -ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ +ccui._TextFieldRenderer = cc.TextFieldTTF.extend(/** @lends ccui._TextFieldRenderer# */{ _maxLengthEnabled: false, _maxLength: 0, _passwordEnabled: false, @@ -41,9 +42,12 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ _detachWithIME: false, _insertText: false, _deleteBackward: false, - _className: "UICCTextField", + _className: "_TextFieldRenderer", _textFieldRendererAdaptDirty: true, + /** + * Constructor of ccui._TextFieldRenderer. + */ ctor: function () { cc.TextFieldTTF.prototype.ctor.call(this); this._maxLengthEnabled = false; @@ -204,21 +208,13 @@ ccui.UICCTextField = cc.TextFieldTTF.extend(/** @lends ccui.UICCTextField# */{ return this._deleteBackward; }, - init: function () { - if (ccui.Widget.prototype.init.call(this)) { - this.setTouchEnabled(true); - return true; - } - return false; - }, - onDraw: function (sender) { return false; } }); -ccui.UICCTextField.create = function (placeholder, fontName, fontSize) { - var ret = new ccui.UICCTextField(); +ccui._TextFieldRenderer.create = function (placeholder, fontName, fontSize) { + var ret = new ccui._TextFieldRenderer(); if (ret && ret.initWithString("", fontName, fontSize)) { if (placeholder) ret.setPlaceHolder(placeholder); @@ -255,7 +251,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * allocates and initializes a UITextField. - * Constructor of ccui.TextField + * Constructor of ccui.TextField. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @example * // example * var uiTextField = new ccui.TextField(); @@ -264,6 +260,11 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ ccui.Widget.prototype.ctor.call(this); }, + /** + * Initializes a ccui.TextField. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @returns {boolean} + * @override + */ init: function(){ if(ccui.Widget.prototype.init.call(this)){ this.setTouchEnabled(true); @@ -278,7 +279,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, _initRenderer: function () { - this._textFieldRenderer = ccui.UICCTextField.create("input words here", "Thonburi", 20); + this._textFieldRenderer = ccui._TextFieldRenderer.create("input words here", "Thonburi", 20); this.addProtectedChild(this._textFieldRenderer, ccui.TextField.RENDERER_ZORDER, -1); }, @@ -320,7 +321,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * Changes the string value of textField. - * @deprecated + * @deprecated since v3.0, please use setString instead. * @param {String} text */ setText: function (text) { @@ -414,7 +415,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * get textField string value - * @deprecated + * @deprecated since v3.0, please use getString instead. * @returns {String} */ getStringValue: function () { @@ -625,7 +626,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * add event listener * @param {Object} target * @param {Function} selector - * @deprecated + * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerTextField: function (selector, target) { this._textFieldEventSelector = selector; @@ -764,7 +765,7 @@ _p = null; /** * allocates and initializes a UITextField. - * @deprecated + * @deprecated since v3.0, please use new ccui.TextField() instead. * @return {ccui.TextField} * @example * // example diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 8468f82c04..bdf7a3a62a 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -42,10 +42,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ _eventCallback: null, /** * allocates and initializes a UIListView. - * Constructor of ccui.ListView + * Constructor of ccui.ListView, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @example * // example - * var uiPageView = new ccui.ListView(); + * var aListView = new ccui.ListView(); */ ctor: function () { ccui.ScrollView.prototype.ctor.call(this); @@ -56,6 +56,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this.init(); }, + /** + * Initializes a ccui.ListView. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @returns {boolean} + * @override + */ init: function () { if (ccui.ScrollView.prototype.init.call(this)) { this.setLayoutType(ccui.Layout.LINEAR_VERTICAL); @@ -420,7 +425,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * add event listener * @param {Function} selector * @param {Object} target - * @deprecated + * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerListView: function (selector, target) { this._listViewEventListener = target; @@ -504,7 +509,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * allocates and initializes a UIListView. - * @deprecated + * @deprecated since v3.0, please use new ccui.ListView() instead. * @example * // example * var uiPageView = ccui.ListView.create(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 3a8eb1052f..bcfd04d4a7 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -53,7 +53,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ /** * allocates and initializes a UIPageView. - * Constructor of ccui.PageView + * Constructor of ccui.PageView. please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. * @example * // example * var uiPageView = new ccui.PageView(); @@ -73,6 +73,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this.setTouchEnabled(true); }, + /** + * Initializes a ccui.PageView. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @returns {boolean} + */ init: function () { if (ccui.Layout.prototype.init.call(this)) { this.setClippingEnabled(true); @@ -516,7 +520,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }); /** * allocates and initializes a UIPageView. - * @deprecated + * @deprecated since v3.0, please use new ccui.PageView() instead. * @return {ccui.PageView} * @example * // example diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 6340007d09..b97f498902 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -81,7 +81,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * allocates and initializes a UIScrollView. - * Constructor of ccui.ScrollView + * Constructor of ccui.ScrollView. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @example * // example * var uiScrollView = new ccui.ScrollView(); @@ -102,6 +102,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.setTouchEnabled(true); }, + /** + * Initializes a ccui.ScrollView. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @returns {boolean} + */ init: function () { if (ccui.Layout.prototype.init.call(this)) { this.setClippingEnabled(true); @@ -1503,7 +1507,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Add call back function called ScrollView event triggered * @param {Function} selector * @param {Object} target - * @deprecated + * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerScrollView: function (selector, target) { this._scrollViewEventSelector = selector; @@ -1623,28 +1627,28 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Get node by tag + * Returns a node by tag * @param {Number} tag * @returns {cc.Node} - * @deprecated + * @deprecated since v3.0, please use getChildByTag instead. */ getNodeByTag: function (tag) { return this._innerContainer.getNodeByTag(tag); }, /** - * Get all nodes of inner container + * Returns all nodes of inner container * @returns {Array} - * @deprecated + * @deprecated since v3.0, please use getChildren instead. */ getNodes: function () { return this._innerContainer.getNodes(); }, /** - * Remove a node + * Removes a node * @param {cc.Node} node - * @deprecated + * @deprecated since v3.0, please use removeChild instead. */ removeNode: function (node) { this._innerContainer.removeNode(node); @@ -1653,7 +1657,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Remove a node by tag * @param {Number} tag - * @deprecated + * @deprecated since v3.0, please use removeChildByTag instead. */ removeNodeByTag: function (tag) { this._innerContainer.removeNodeByTag(tag); @@ -1661,7 +1665,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Remove all node - * @deprecated + * @deprecated since v3.0, please use removeAllChildren instead. */ removeAllNodes: function () { this._innerContainer.removeAllNodes(); @@ -1672,7 +1676,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {cc.Node}node * @param {Number} zOrder * @param {Number} tag - * @deprecated + * @deprecated since v3.0, please use addChild instead. */ addNode: function (node, zOrder, tag) { this._innerContainer.addNode(node, zOrder, tag); @@ -1693,7 +1697,7 @@ _p = null; /** * allocates and initializes a UIScrollView. - * @deprecated + * @deprecated since v3.0, please use new ccui.ScrollView() instead. * @return {ccui.ScrollView} * @example * // example From d0fb163925782c26dcc1b906d8a10b15d9a194e0 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 27 Aug 2014 10:49:36 +0800 Subject: [PATCH 0533/1564] Doc #5829: Improve some inline docs --- cocos2d/core/base-nodes/CCNode.js | 2 +- cocos2d/core/layers/CCLayer.js | 4 ++-- cocos2d/core/platform/CCClass.js | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 85cdbe9a4a..88b8faa76a 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2060,7 +2060,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ grid: null, /** - *

    Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.

    + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @function */ ctor: null, diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index e9b4f71a22..f27a6ba2be 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -208,8 +208,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { *

    * CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
    * All features from CCLayer are valid, plus the following new features:
    - * opacity
    - * RGB colors

    + * - opacity
    + * - RGB colors

    * @class * @extends cc.Layer * diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 41e94f09d5..d3cb259575 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -23,18 +23,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -/* Managed JavaScript Inheritance - * Based on John Resig's Simple JavaScript Inheritance http://ejohn.org/blog/simple-javascript-inheritance/ - * MIT Licensed. - */ /** + * The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace * @namespace * @name cc */ var cc = cc || {}; -// var ClassManager = { id : (0|(Math.random()*998)), @@ -82,6 +78,10 @@ var ClassManager = { }; ClassManager.compileSuper.ClassManager = ClassManager; +/* Managed JavaScript Inheritance + * Based on John Resig's Simple JavaScript Inheritance http://ejohn.org/blog/simple-javascript-inheritance/ + * MIT Licensed. + */ (function () { var fnTest = /\b_super\b/; var config = cc.game.config; From 9bd98fadbe117324bfa52b73ddd4866c1d0ca1fc Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 27 Aug 2014 11:21:55 +0800 Subject: [PATCH 0534/1564] Issue #5830: add jsDocs to UITextBMFont.js and UITextField.js --- extensions/ccui/uiwidgets/UITextBMFont.js | 43 ++++-- extensions/ccui/uiwidgets/UITextField.js | 171 ++++++++++++++++------ 2 files changed, 157 insertions(+), 57 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index d9fd490e89..ca16daea0c 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccui.TextBMFont + * The TextBMFont control of Cocos UI, it rendered by LabelBMFont. * @class * @extends ccui.Widget * @@ -39,7 +39,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo _labelBMFontRendererAdaptDirty: true, /** - * allocates and initializes a UILabelBMFont.
    + * Allocates and initializes a TextBMFont.
    * Constructor of ccui.TextBMFont. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {String} text * @param {String} filename @@ -55,19 +55,20 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo this.setString(text); } }, + _initRenderer: function () { this._labelBMFontRenderer = new cc.LabelBMFont(); this.addProtectedChild(this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1); }, /** - * init a bitmap font atlas with an initial string and the FNT file + * Initializes a bitmap font atlas with an initial string and the FNT file * @param {String} fileName */ setFntFile: function (fileName) { - if (!fileName) { + if (!fileName) return; - } + var _self = this; _self._fntFileName = fileName; @@ -83,7 +84,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo }, /** - * set string value for labelbmfont + * Sets string value for TextBMFont * @deprecated since v3.0, please use setString instead. * @param {String} value */ @@ -93,7 +94,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo }, /** - * set string value for labelbmfont + * Sets string value for TextBMFont * @param {String} value */ setString: function (value) { @@ -106,20 +107,23 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo }, /** - * get string value for labelbmfont. + * Returns string value for TextBMFont. * @returns {String} */ getString: function () { return this._stringValue; }, + /** + * Returns the length of TextBMFont's string. + * @returns {Number} + */ getStringLength: function(){ return this._labelBMFontRenderer.getStringLength(); }, _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); -// this._labelBMFontScaleChangedWithSize(); this._labelBMFontRendererAdaptDirty = true; }, @@ -130,12 +134,18 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo } }, + /** + * Returns TextBMFont's content size + * @override + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return this._labelBMFontRenderer.getContentSize(); }, /** - * override "getVirtualRenderer" method of widget. + * Returns the renderer of TextBMFont + * @override * @returns {cc.Node} */ getVirtualRenderer: function () { @@ -144,9 +154,9 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo _labelBMFontScaleChangedWithSize: function () { var locRenderer = this._labelBMFontRenderer; - if (this._ignoreSize) { + if (this._ignoreSize) locRenderer.setScale(1.0); - } else { + else { var textureSize = locRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { locRenderer.setScale(1.0); @@ -159,11 +169,11 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.TextBMFont. * @returns {string} */ getDescription: function () { - return "LabelBMFont"; + return "TextBMFont"; }, _createCloneInstance: function () { @@ -198,4 +208,9 @@ ccui.TextBMFont.create = function (text, filename) { }; // Constants +/** + * The zOrder value of TextBMFont's renderer. + * @constant + * @type {number} + */ ccui.TextBMFont.RENDERER_ZORDER = -1; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index ad8fd47d7e..87cb4f8dbd 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -24,16 +24,10 @@ ****************************************************************************/ /** - * The renderer of ccui.TextField. - * @private - * @class - * @extends cc.TextFieldTTF - * - * @property {Boolean} maxLengthEnabled - Indicate whether max length limit is enabled - * @property {Number} maxLength - The max length of the text field - * @property {Boolean} passwordEnabled - Indicate whether the text field is for entering password + * @ignore */ -ccui._TextFieldRenderer = cc.TextFieldTTF.extend(/** @lends ccui._TextFieldRenderer# */{ +//it's a private class, it's a renderer of ccui.TextField. +ccui._TextFieldRenderer = cc.TextFieldTTF.extend({ _maxLengthEnabled: false, _maxLength: 0, _passwordEnabled: false, @@ -45,9 +39,6 @@ ccui._TextFieldRenderer = cc.TextFieldTTF.extend(/** @lends ccui._TextFieldRende _className: "_TextFieldRenderer", _textFieldRendererAdaptDirty: true, - /** - * Constructor of ccui._TextFieldRenderer. - */ ctor: function () { cc.TextFieldTTF.prototype.ctor.call(this); this._maxLengthEnabled = false; @@ -65,7 +56,6 @@ ccui._TextFieldRenderer = cc.TextFieldTTF.extend(/** @lends ccui._TextFieldRende cc.TextFieldTTF.prototype.setDelegate.call(this, this); }, - //CCTextFieldDelegate onTextFieldAttachWithIME: function (sender) { this.setAttachWithIME(true); return false; @@ -224,7 +214,7 @@ ccui._TextFieldRenderer.create = function (placeholder, fontName, fontSize) { }; /** - * Base class for ccui.TextField + * * @class * @extends ccui.Widget * @@ -252,12 +242,23 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * allocates and initializes a UITextField. * Constructor of ccui.TextField. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {string} placeholder + * @param {string} fontName + * @param {Number} fontSize * @example * // example * var uiTextField = new ccui.TextField(); */ - ctor: function () { + ctor: function (placeholder, fontName, fontSize) { ccui.Widget.prototype.ctor.call(this); + if (this.init()) { + if(placeholder) + this.setPlaceHolder(placeholder); + if(fontName) + this.setFontName(fontName); + if(fontSize) + this.setFontSize(fontSize); + } }, /** @@ -273,6 +274,10 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ return false; }, + /** + * Calls parent class' onEnter and schedules update function. + * @override + */ onEnter: function () { ccui.Widget.prototype.onEnter.call(this); this.scheduleUpdate(); @@ -284,7 +289,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * Set touch size + * Sets touch size of ccui.TextField. * @param {cc.Size} size */ setTouchSize: function (size) { @@ -292,10 +297,19 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._touchHeight = size.height; }, + /** + * Sets whether use touch area. + * @param enable + */ setTouchAreaEnabled: function(enable){ this._useTouchArea = enable; }, + /** + * Checks a point if is in ccui.TextField's space + * @param {cc.Point} pt + * @returns {boolean} + */ hitTest: function(pt){ if (this._useTouchArea) { var nsp = this.convertToNodeSpace(pt); @@ -312,7 +326,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * Get touch size. + * Returns touch size of ccui.TextField. * @returns {cc.Size} */ getTouchSize: function () { @@ -334,25 +348,25 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {String} text */ setString: function (text) { - if (!text) { + if (!text) return; - } + text = String(text); - if (this.isMaxLengthEnabled()) { + if (this.isMaxLengthEnabled()) text = text.substr(0, this.getMaxLength()); - } if (this.isPasswordEnabled()) { this._textFieldRenderer.setPasswordText(text); this._textFieldRenderer.setString(""); this._textFieldRenderer.insertText(text, text.length); - } else { + } else this._textFieldRenderer.setString(text); - } this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()); }, /** + * Sets the placeholder string.
    + * display this string if string equal "". * @param {String} value */ setPlaceHolder: function (value) { @@ -362,6 +376,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Returns the placeholder string. * @returns {String} */ getPlaceHolder: function () { @@ -369,7 +384,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * Set font size for text field content + * Sets font size for ccui.TextField. * @param {Number} size */ setFontSize: function (size) { @@ -380,7 +395,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * Get font size for text field content + * Gets font size of ccui.TextField. * @return {Number} size */ getFontSize: function () { @@ -388,7 +403,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * Set font name for text field content + * Sets font name for ccui.TextField * @param {String} name */ setFontName: function (name) { @@ -399,7 +414,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * Get font name for text field content + * Returns font name of ccui.TextField. * @return {String} font name */ getFontName: function () { @@ -414,7 +429,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * get textField string value + * Returns textField string value * @deprecated since v3.0, please use getString instead. * @returns {String} */ @@ -424,19 +439,23 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * get textField string value + * Returns string value of ccui.TextField. * @returns {String} */ getString: function () { return this._textFieldRenderer.getString(); }, + /** + * Returns the length of ccui.TextField. + * @returns {Number} + */ getStringLength: function(){ return this._textFieldRenderer.getStringLength(); }, /** - * touch began + * The touch began event callback handler. * @param {cc.Point} touchPoint */ onTouchBegan: function (touchPoint, unusedEvent) { @@ -451,6 +470,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Sets Whether to open string length limit for ccui.TextField. * @param {Boolean} enable */ setMaxLengthEnabled: function (enable) { @@ -458,6 +478,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Returns Whether to open string length limit. * @returns {Boolean} */ isMaxLengthEnabled: function () { @@ -465,6 +486,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Sets the max length of ccui.TextField. Only when you turn on the string length limit, it is valid. * @param {number} length */ setMaxLength: function (length) { @@ -473,6 +495,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Returns the max length of ccui.TextField. * @returns {number} length */ getMaxLength: function () { @@ -480,6 +503,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Sets whether to open setting string as password character. * @param {Boolean} enable */ setPasswordEnabled: function (enable) { @@ -487,12 +511,17 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Returns whether to open setting string as password character. * @returns {Boolean} */ isPasswordEnabled: function () { return this._textFieldRenderer.isPasswordEnabled(); }, + /** + * Sets the password style character, Only when you turn on setting string as password character, it is valid. + * @param styleText + */ setPasswordStyleText: function(styleText){ this._textFieldRenderer.setPasswordStyleText(styleText); this._passwordStyleText = styleText; @@ -501,6 +530,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Returns the password style character. * @returns {String} */ getPasswordStyleText: function () { @@ -519,21 +549,19 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ if (this.getInsertText()) { this._insertTextEvent(); this.setInsertText(false); - this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()); } if (this.getDeleteBackward()) { this._deleteBackwardEvent(); this.setDeleteBackward(false); - this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()); } }, /** - * get whether attach with IME. + * Returns whether attach with IME. * @returns {Boolean} */ getAttachWithIME: function () { @@ -541,7 +569,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * set attach with IME. + * Sets attach with IME. * @param {Boolean} attach */ setAttachWithIME: function (attach) { @@ -549,7 +577,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * get whether eetach with IME. + * Returns whether detach with IME. * @returns {Boolean} */ getDetachWithIME: function () { @@ -557,7 +585,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * set detach with IME. + * Sets detach with IME. * @param {Boolean} detach */ setDetachWithIME: function (detach) { @@ -565,7 +593,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * get insertText + * Returns insertText string of ccui.TextField. * @returns {String} */ getInsertText: function () { @@ -573,7 +601,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * set insertText + * Sets insertText string to ccui.TextField. * @param {String} insertText */ setInsertText: function (insertText) { @@ -581,6 +609,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Returns the delete backward of ccui.TextField. * @returns {Boolean} */ getDeleteBackward: function () { @@ -588,6 +617,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** + * Sets the delete backward of ccui.TextField. * @param {Boolean} deleteBackward */ setDeleteBackward: function (deleteBackward) { @@ -623,7 +653,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * add event listener + * Adds event listener to cuci.TextField. * @param {Object} target * @param {Function} selector * @deprecated since v3.0, please use addEventListener instead. @@ -633,6 +663,10 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldEventListener = target; }, + /** + * Adds event listener callback. + * @param {function} callback + */ addEventListener: function(callback){ this._eventCallback = callback; }, @@ -655,12 +689,16 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, + /** + * Returns the ccui.TextField's content size. + * @returns {cc.Size} + */ getVirtualRendererSize: function(){ return this._textFieldRenderer.getContentSize(); }, /** - * override "getContentSize" method of widget. + * Returns the renderer of ccui.TextField. * @returns {cc.Node} */ getVirtualRenderer: function () { @@ -668,13 +706,17 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.TextField. * @returns {string} */ getDescription: function () { return "TextField"; }, + /** + * Open keyboard and receive input text. + * @return {Boolean} + */ attachWithIME: function () { this._textFieldRenderer.attachWithIME(); }, @@ -698,14 +740,26 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setDeleteBackward(textField.getDeleteBackward()); }, + /** + * Sets the text area size to ccui.TextField. + * @param {cc.Size} size + */ setTextAreaSize: function(size){ this.setContentSize(size); }, + /** + * Sets the text horizontal alignment of ccui.TextField. + * @param alignment + */ setTextHorizontalAlignment: function(alignment){ this._textFieldRenderer.setHorizontalAlignment(alignment); }, + /** + * Sets the text vertical alignment of ccui.TextField. + * @param alignment + */ setTextVerticalAlignment: function(alignment){ this._textFieldRenderer.setVerticalAlignment(alignment); }, @@ -719,8 +773,15 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ } }); +/** + * Creates a ccui.TextField. + * @param {String} placeholder + * @param {String} fontName + * @param {Number} fontSize + * @returns {ccui.TextField} + */ ccui.TextField.create = function(placeholder, fontName, fontSize){ - var widget = new ccui.TextField(); + var widget = new ccui.TextField(placeholder, fontName, fontSize); if (widget && widget.init()) { if(placeholder && fontName && fontSize){ widget.setPlaceHolder(placeholder); @@ -730,7 +791,6 @@ ccui.TextField.create = function(placeholder, fontName, fontSize){ return widget; } return null; - }; var _p = ccui.TextField.prototype; @@ -777,9 +837,34 @@ ccui.TextField.create = function () { // Constants //TextField event +/** + * The attach with IME event flag of ccui.TextField + * @constant + * @type {number} + */ ccui.TextField.EVENT_ATTACH_WITH_IME = 0; +/** + * The detach with IME event flag of ccui.TextField + * @constant + * @type {number} + */ ccui.TextField.EVENT_DETACH_WITH_IME = 1; +/** + * The insert text event flag of ccui.TextField + * @constant + * @type {number} + */ ccui.TextField.EVENT_INSERT_TEXT = 2; +/** + * The delete backward event flag of ccui.TextField + * @constant + * @type {number} + */ ccui.TextField.EVENT_DELETE_BACKWARD = 3; +/** + * The zOrder value of ccui.TextField's renderer. + * @constant + * @type {number} + */ ccui.TextField.RENDERER_ZORDER = -1; \ No newline at end of file From dcb8612069ad13920fa587197a865fd4f0d20755 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 12:05:52 +0800 Subject: [PATCH 0535/1564] Issue #5829: Actions jsdoc --- cocos2d/actions/CCAction.js | 2 +- cocos2d/actions/CCActionCamera.js | 12 ++++++-- cocos2d/actions/CCActionEase.js | 4 +-- cocos2d/actions/CCActionInstant.js | 2 +- cocos2d/actions/CCActionInterval.js | 9 +++--- cocos2d/actions3d/CCActionGrid.js | 4 +-- cocos2d/motion-streak/CCMotionStreak.js | 3 ++ cocos2d/node-grid/CCNodeGrid.js | 29 ++++++++++++++++-- cocos2d/parallax/CCParallaxNode.js | 39 ++++++++++++++++++------- 9 files changed, 77 insertions(+), 27 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index b040a3660e..2b154b0cf2 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -411,7 +411,7 @@ cc.Speed = cc.Action.extend(/** @lends cc.Speed# */{ * - The reversed action will be x of 100 move to 0. * - Will be rewritten * - * @return {cc.ActionInterval} + * @return {cc.Speed} */ reverse:function () { return new cc.Speed(this._innerAction.reverse(), this._speed); diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index f291d7e511..dce8701cc5 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -103,12 +103,20 @@ cc.ActionCamera = cc.ActionInterval.extend(/** @lends cc.ActionCamera# */{ * */ reverse:function () { - return cc.reverseTime(this); + return new cc.ReverseTime(this); } }); /** - * Orbits the camera around the center of the screen using spherical coordinates + * Orbits the camera around the center of the screen using spherical coordinates. + * + * @param {Number} t time + * @param {Number} radius + * @param {Number} deltaRadius + * @param {Number} angleZ + * @param {Number} deltaAngleZ + * @param {Number} angleX + * @param {Number} deltaAngleX * * @class * @extends cc.ActionCamera diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js index f53901a42e..b117f91d2b 100644 --- a/cocos2d/actions/CCActionEase.js +++ b/cocos2d/actions/CCActionEase.js @@ -110,7 +110,7 @@ cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ * - The action will be x coordinates of 0 move to 100.
    * - The reversed action will be x of 100 move to 0. * - Will be rewritten - * @return {cc.ActionInterval} + * @return {cc.ActionEase} */ reverse:function () { return new cc.ActionEase(this._inner.reverse()); @@ -214,7 +214,7 @@ cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ * to copy object with deep copy. * returns a clone of action. * - * @returns {cc.ActionEase} + * @returns {cc.EaseRateAction} */ clone:function(){ var action = new cc.EaseRateAction(); diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index 43c2f3fc31..45aab879b0 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -310,7 +310,7 @@ cc.RemoveSelf = cc.ActionInstant.extend({ * to copy object with deep copy. * returns a clone of action. * - * @return {cc.ToggleVisibility} + * @return {cc.RemoveSelf} */ clone:function(){ return new cc.RemoveSelf(this._isNeedCleanUp); diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 17f0080a22..1d83b50f7d 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -1295,7 +1295,6 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ * @param {Number} duration duration in seconds * @param {cc.Point|Number} deltaPos * @param {Number} [deltaY] - * @example */ ctor:function (duration, deltaPos, deltaY) { cc.ActionInterval.prototype.ctor.call(this); @@ -1335,7 +1334,7 @@ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{ clone:function () { var action = new cc.MoveBy(); this._cloneDecoration(action); - action.initWithDuration(this._duration, this._positionDelta) + action.initWithDuration(this._duration, this._positionDelta); return action; }, @@ -2111,7 +2110,7 @@ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{ /** * Called once per frame. Time is the number of seconds of a frame interval. - * @param {Number} time + * @param {Number} dt */ update:function (dt) { dt = this._computeEaseTime(dt); @@ -2359,7 +2358,7 @@ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{ /** * Called once per frame. Time is the number of seconds of a frame interval. - * @param {Number} time + * @param {Number} dt */ update:function (dt) { dt = this._computeEaseTime(dt); @@ -3376,7 +3375,7 @@ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{ newArray.push(element.clone()); } } - var newAnim = cc.Animation.create(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops()); + var newAnim = new cc.Animation(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops()); newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame()); var action = new cc.Animate(newAnim); this._cloneDecoration(action); diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index d7aa8530a6..7d6f373dec 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -87,7 +87,7 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ * @return {cc.EaseSineOut} */ reverse:function () { - return cc.ReverseTime.create(this); + return new cc.ReverseTime(this); }, /** @@ -305,7 +305,7 @@ cc.stopGrid = function () { * Allocates and initializes the action * @return {cc.StopGrid} * @static - * @ deprecated since v3.0
    Please use cc.stopGrid instead. + * @deprecated since v3.0
    Please use cc.stopGrid instead. */ cc.StopGrid.create = cc.stopGrid; diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 2b9a3a65c8..dfff82207e 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -560,6 +560,9 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ * @param {Number} color * @param {string|cc.Texture2D} texture texture filename or texture * @return {cc.MotionStreak} + * @example + * //example + * new cc.MotionStreak(2, 3, 32, cc.color.GREEN, s_streak); */ cc.MotionStreak.create = function (fade, minSeg, stroke, color, texture) { return new cc.MotionStreak(fade, minSeg, stroke, color, texture); diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index 1d62318e00..e74889e805 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -36,14 +36,26 @@ cc.NodeGrid = cc.Node.extend({ grid: null, _target: null, + /** + * Gets the grid object. + * @returns {cc.GridBase} + */ getGrid: function () { return this.grid; }, + /** + * Set the grid object. + * @param {cc.GridBase} grid + */ setGrid: function (grid) { this.grid = grid; }, + /** + * Set the target + * @param {cc.Node} target + */ setTarget: function (target) { //var self = this; //self._target && self.removeChild(self._target); @@ -51,6 +63,14 @@ cc.NodeGrid = cc.Node.extend({ //self.addChild(self._target); }, + /**

    "add" logic MUST only be in this method

    + * + *

    If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.

    + * @function + * @param {cc.Node} child A child node + * @param {Number} [zOrder=] Z order for drawing priority. Please refer to setZOrder(int) + * @param {Number} [tag=] A integer to identify the node easily. Please refer to setTag(int) + */ addChild: function (child, zOrder, tag) { cc.Node.prototype.addChild.call(this, child, zOrder, tag); @@ -58,6 +78,9 @@ cc.NodeGrid = cc.Node.extend({ this._target = child; }, + /** + * Recursive method that visit its children and draw them + */ visit: function () { var self = this; // quick return if not visible @@ -141,10 +164,10 @@ cc.defineGetterSetter(_p, "target", null, _p.setTarget); /** - * Creates a NodeGrid + * Creates a NodeGrid.
    * Implementation cc.NodeGrid - * @deprecated - * @return {cc.NodeGrid|null} + * @deprecated since v3.0 please new cc.NodeGrid instead. + * @return {cc.NodeGrid} */ cc.NodeGrid.create = function () { return new cc.NodeGrid(); diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index 73f587d209..17fa743bc4 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -25,6 +25,8 @@ ****************************************************************************/ /** + * Parallax Object.
    + * Parallax required attributes are stored. * @class * @extends cc.Class */ @@ -33,14 +35,21 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ _offset:null, _child:null, + ctor: function(ratio, offset){ + cc.Class.prototype.ctor.call(this); + this.initWithCCPoint(ratio, offset); + }, + /** - * @return {cc.Point} + * Gets the ratio. + * @return {cc.Point} Not point, this is ratio. */ getRatio:function () { return this._ratio; }, /** + * Set the ratio. * @param {cc.Point} value */ setRatio:function (value) { @@ -48,6 +57,7 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ }, /** + * Gets the offset. * @return {cc.Point} */ getOffset:function () { @@ -55,6 +65,7 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ }, /** + * Set the offset. * @param {cc.Point} value */ setOffset:function (value) { @@ -62,6 +73,7 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ }, /** + * Gets the child. * @return {cc.Node} */ getChild:function () { @@ -69,6 +81,7 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ }, /** + * Set the child. * @param {cc.Node} value */ setChild:function (value) { @@ -76,7 +89,8 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ }, /** - * @param {cc.Point} ratio + * initializes cc.PointObject + * @param {cc.Point} ratio Not point, this is a ratio. * @param {cc.Point} offset * @return {Boolean} */ @@ -89,14 +103,14 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ }); /** + * Create a object to stored parallax data. * @param {cc.Point} ratio * @param {cc.Point} offset * @return {cc.PointObject} + * @deprecated since v3.0 please use new cc.PointObject() instead. */ cc.PointObject.create = function (ratio, offset) { - var ret = new cc.PointObject(); - ret.initWithCCPoint(ratio, offset); - return ret; + return new cc.PointObject(ratio, offset); }; /** @@ -114,6 +128,7 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ _className:"ParallaxNode", /** + * Gets the parallax array. * @return {Array} */ getParallaxArray:function () { @@ -121,6 +136,7 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ }, /** + * Set parallax array. * @param {Array} value */ setParallaxArray:function (value) { @@ -128,7 +144,7 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ }, /** - * Constructor + * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. */ ctor:function () { cc.Node.prototype.ctor.call(this); @@ -149,12 +165,12 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ */ addChild:function (child, z, ratio, offset) { if (arguments.length === 3) { - cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead") + cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead"); return; } if(!child) throw "cc.ParallaxNode.addChild(): child should be non-null"; - var obj = cc.PointObject.create(ratio, offset); + var obj = new cc.PointObject(ratio, offset); obj.setChild(child); this.parallaxArray.push(obj); @@ -193,7 +209,7 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ }, /** - * Visit + * Recursive method that visit its children and draw them */ visit:function () { var pos = this._absolutePosition(); @@ -222,11 +238,12 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ }); /** - * @deprecated + * Create new parallax node. + * @deprecated since v3.0 please use new cc.ParallaxNode() instead. * @return {cc.ParallaxNode} * @example * //example - * var voidNode = cc.ParallaxNode.create(); + * var voidNode = new cc.ParallaxNode(); */ cc.ParallaxNode.create = function () { return new cc.ParallaxNode(); From 5720431c4573ed6d20cb1926729c7f340e63c137 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 27 Aug 2014 14:07:59 +0800 Subject: [PATCH 0536/1564] Issue #5830: adds jsDocs to UIPageView.js and UIScrollView.js --- .../uiwidgets/scroll-widget/UIPageView.js | 114 ++++++++--- .../uiwidgets/scroll-widget/UIScrollView.js | 191 +++++++++++++----- 2 files changed, 235 insertions(+), 70 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index bcfd04d4a7..2fe966d284 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -27,6 +27,11 @@ * The PageView control of Cocos UI. * @class * @extends ccui.Layout + * @exmaple + * var pageView = new ccui.PageView(); + * pageView.setTouchEnabled(true); + * pageView.addPage(new ccui.Layout()); + * this.addChild(pageView); */ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _curPageIdx: 0, @@ -52,7 +57,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _eventCallback: null, /** - * allocates and initializes a UIPageView. + * Allocates and initializes a UIPageView. * Constructor of ccui.PageView. please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. * @example * // example @@ -85,6 +90,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ return false; }, + /** + * Calls the parent class' onEnter and schedules update function. + * @override + */ onEnter:function(){ ccui.Layout.prototype.onEnter.call(this); this.scheduleUpdate(true); @@ -116,11 +125,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, - /** - * create page - * @returns {ccui.Layout} - * @protected - */ _createPage: function () { var newPage = ccui.Layout.create(); newPage.setContentSize(this.getContentSize()); @@ -128,7 +132,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Push back a page to PageView. + * Adds a page to ccui.PageView. * @param {ccui.Layout} page */ addPage: function (page) { @@ -141,7 +145,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Insert a page to PageView. + * Inserts a page in the specified location. * @param {ccui.Layout} page page to be added to PageView. * @param {Number} idx index */ @@ -160,13 +164,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Remove a page of PageView. + * Removes a page from PageView. * @param {ccui.Layout} page */ removePage: function (page) { - if (!page) { + if (!page) return; - } this.removeChild(page); var index = this._pages.indexOf(page); if(index > -1) @@ -175,7 +178,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Remove a page at index of PageView. + * Removes a page at index of PageView. * @param {number} index */ removePageAtIndex: function (index) { @@ -187,13 +190,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * remove all pages from PageView + * Removes all pages from PageView */ removeAllPages: function(){ var locPages = this._pages; - for(var i = 0, len = locPages.length; i < len; i++){ + for(var i = 0, len = locPages.length; i < len; i++) this.removeChild(locPages[i]); - } this._pages.length = 0; }, @@ -265,15 +267,28 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._isAutoScrolling = true; }, + /** + * Called once per frame. Time is the number of seconds of a frame interval. + * @override + * @param {Number} dt + */ update: function (dt) { if (this._isAutoScrolling) this._autoScroll(dt); }, + /** + * Does nothing. ccui.PageView's layout type is ccui.Layout.ABSOLUTE. + * @override + * @param {Number} type + */ setLayoutType:function(type){ - }, + /** + * Returns the layout type of ccui.PageView. it's always ccui.Layout.ABSOLUTE. + * @returns {number} + */ getLayoutType: function(){ return ccui.Layout.ABSOLUTE; }, @@ -311,6 +326,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, + /** + * The touch moved event callback handler of ccui.PageView. + * @override + * @param {cc.Touch} touch + * @param {cc.Event} event + */ onTouchMoved: function (touch, event) { this._handleMoveLogic(touch); var widgetParent = this.getWidgetParent(); @@ -319,11 +340,22 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._moveEvent(); }, + /** + * The touch ended event callback handler of ccui.PageView. + * @override + * @param {cc.Touch} touch + * @param {cc.Event} event + */ onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); this._handleReleaseLogic(touch); }, + /** + * The touch canceled event callback handler of ccui.PageView. + * @param {cc.Touch} touch + * @param {cc.Event} event + */ onTouchCancelled: function (touch, event) { ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); this._handleReleaseLogic(touch); @@ -353,7 +385,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _scrollPages: function (touchOffset) { if (this._pages.length <= 0) return false; - if (!this._leftBoundaryChild || !this._rightBoundaryChild) return false; @@ -418,9 +449,15 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } }, - interceptTouchEvent: function (handleState, sender, touch) { + /** + * Intercept touch event, handle its child's touch event. + * @param {Number} event event type + * @param {ccui.Widget} sender + * @param {cc.Touch} touch + */ + interceptTouchEvent: function (event, sender, touch) { var touchPoint = touch.getLocation(); - switch (handleState) { + switch (event) { case ccui.Widget.TOUCH_BEGAN: this._touchBeganPosition.x = touchPoint.x; this._touchBeganPosition.y = touchPoint.y; @@ -452,20 +489,26 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** + * Adds event listener to ccui.PageView. * @param {Function} selector * @param {Object} target + * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerPageView: function (selector, target) { this._pageViewEventSelector = selector; this._pageViewEventListener = target; }, + /** + * Adds event listener to ccui.PageView. + * @param callback + */ addEventListener: function(callback){ this._eventCallback = callback; }, /** - * get current page index + * Returns current page index * @returns {number} */ getCurPageIndex: function () { @@ -473,7 +516,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * get all pages of PageView + * Returns all pages of PageView * @returns {Array} */ getPages:function(){ @@ -481,7 +524,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * get a page from PageView by index + * Returns a page from PageView by index * @param {Number} index * @returns {ccui.Layout} */ @@ -492,7 +535,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.PageView. * @returns {string} */ getDescription: function () { @@ -532,12 +575,37 @@ ccui.PageView.create = function () { // Constants //PageView event +/** + * The turning flag of ccui.PageView's event. + * @constant + * @type {number} + */ ccui.PageView.EVENT_TURNING = 0; //PageView touch direction +/** + * The left flag of ccui.PageView's touch direction. + * @constant + * @type {number} + */ ccui.PageView.TOUCH_DIR_LEFT = 0; +/** + * The right flag of ccui.PageView's touch direction. + * @constant + * @type {number} + */ ccui.PageView.TOUCH_DIR_RIGHT = 1; //PageView auto scroll direction +/** + * The right flag of ccui.PageView's auto scroll direction. + * @constant + * @type {number} + */ ccui.PageView.DIRECTION_LEFT = 0; +/** + * The right flag of ccui.PageView's auto scroll direction. + * @constant + * @type {number} + */ ccui.PageView.DIRECTION_RIGHT = 1; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index b97f498902..164d5c5585 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -80,7 +80,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _eventCallback: null, /** - * allocates and initializes a UIScrollView. + * Allocates and initializes a UIScrollView. * Constructor of ccui.ScrollView. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @example * // example @@ -115,6 +115,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return false; }, + /** + * Calls the parent class' onEnter and schedules update function. + * @override + */ onEnter: function () { ccui.Layout.prototype.onEnter.call(this); this.scheduleUpdate(true); @@ -238,13 +242,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; } var innerAX = container.anchorX; - if (container.getLeftBoundary() > 0.0) { + if (container.getLeftBoundary() > 0.0) container.x = innerAX * innerWidth; - } - if (container.getRightBoundary() < locW) { + if (container.getRightBoundary() < locW) container.x = locW - ((1.0 - innerAX) * innerWidth); - } }, + _setInnerHeight: function (height) { var locH = this._contentSize.height, innerHeight = locH, @@ -265,19 +268,17 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; } var innerAY = container.anchorY; - if (container.getLeftBoundary() > 0.0) { + if (container.getLeftBoundary() > 0.0) container.y = innerAY * innerHeight; - } - if (container.getRightBoundary() < locH) { + if (container.getRightBoundary() < locH) container.y = locH - ((1.0 - innerAY) * innerHeight); - } }, /** - * Gets inner container size of ScrollView.
    + * Returns inner container size of ScrollView.
    * Inner container size must be larger than or equal ScrollView's size. * - * @return inner container size. + * @return {cc.Size} inner container size. */ getInnerContainerSize: function () { return this._innerContainer.getContentSize(); @@ -290,7 +291,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Add widget + * Add child to ccui.ScrollView. * @param {cc.Node} widget * @param {Number} [zOrder] * @param {Number|string} [tag] tag or name @@ -304,16 +305,24 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return this._innerContainer.addChild(widget, zOrder, tag); }, + /** + * Removes all children. + */ removeAllChildren: function () { this.removeAllChildrenWithCleanup(true); }, + /** + * Removes all children. + * @param {Boolean} cleanup + */ removeAllChildrenWithCleanup: function(cleanup){ this._innerContainer.removeAllChildrenWithCleanup(cleanup); }, /** - * remove widget child override + * Removes widget child + * @override * @param {ccui.Widget} child * @param {Boolean} cleanup * @returns {boolean} @@ -323,7 +332,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get inner container's children + * Returns inner container's children * @returns {Array} */ getChildren: function () { @@ -331,7 +340,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get the count of inner container's children + * Gets the count of inner container's children * @returns {Number} */ getChildrenCount: function () { @@ -514,7 +523,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _startAutoScrollChildrenWithOriginalSpeed: function (dir, v, attenuated, acceleration) { this._stopAutoScrollChildren(); - this._autoScrollDir = dir; + this._autoScrollDir.x = dir.x; + this._autoScrollDir.y = dir.y; this._isAutoScrollSpeedAttenuated = attenuated; this._autoScrollOriginalSpeed = v; this._autoScroll = true; @@ -793,11 +803,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return scrollEnabled; }, - getCurAutoScrollDistance: function (dt) { - this._autoScrollOriginalSpeed -= this._autoScrollAcceleration * dt; - return this._autoScrollOriginalSpeed * dt; - }, - _scrollChildren: function (touchOffsetX, touchOffsetY) { var scrollEnabled = true; this._scrollingEvent(); @@ -1195,7 +1200,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to bottom boundary of ScrollView. - * @function */ jumpToBottom: function () { this._jumpToDestination(this._innerContainer.getPositionX(), 0); @@ -1203,7 +1207,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to top boundary of ScrollView. - * @function */ jumpToTop: function () { this._jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height); @@ -1211,7 +1214,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to left boundary of ScrollView. - * @function */ jumpToLeft: function () { this._jumpToDestination(0, this._innerContainer.getPositionY()); @@ -1219,7 +1221,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to right boundary of ScrollView. - * @function */ jumpToRight: function () { this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()); @@ -1227,7 +1228,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to top and left boundary of ScrollView. - * @function */ jumpToTopLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1239,7 +1239,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to top and right boundary of ScrollView. - * @function */ jumpToTopRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1252,7 +1251,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to bottom and left boundary of ScrollView. - * @function */ jumpToBottomLeft: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1264,7 +1262,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to bottom and right boundary of ScrollView. - * @function */ jumpToBottomRight: function () { if (this.direction != ccui.ScrollView.DIR_BOTH) { @@ -1276,7 +1273,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to vertical percent position of ScrollView. - * @function * @param {Number} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentVertical: function (percent) { @@ -1287,7 +1283,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to horizontal percent position of ScrollView. - * @function * @param {Number} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentHorizontal: function (percent) { @@ -1297,7 +1292,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Move inner container to both direction percent position of ScrollView. - * @function * @param {cc.Point} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentBothDirection: function (percent) { @@ -1374,6 +1368,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._bePressed = false; }, + /** + * The touch began event callback handler of ccui.ScrollView. + * @param {cc.Touch} touch + * @param {cc.Event} event + * @returns {boolean} + */ onTouchBegan: function (touch, event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); if (this._hit) @@ -1381,20 +1381,39 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ return pass; }, + /** + * The touch moved event callback handler of ccui.ScrollView. + * @param {cc.Touch} touch + * @param {cc.Event} event + */ onTouchMoved: function (touch, event) { ccui.Layout.prototype.onTouchMoved.call(this, touch, event); this._handleMoveLogic(touch); }, + /** + * The touch ended event callback handler of ccui.ScrollView. + * @param {cc.Touch} touch + * @param {cc.Event} event + */ onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); this._handleReleaseLogic(touch); }, + /** + * The touch canceled event callback of ccui.ScrollView. + * @param {cc.Touch} touch + * @param {cc.Event} event + */ onTouchCancelled: function (touch, event) { ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); }, + /** + * The update callback handler. + * @param {Number} dt + */ update: function (dt) { if (this._autoScroll) this._autoScrollChildren(dt); @@ -1409,7 +1428,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Intercept touch event + * Intercept touch event, handle its child's touch event. + * @override * @param {number} event event type * @param {ccui.Widget} sender * @param {cc.Touch} touch @@ -1504,7 +1524,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Add call back function called ScrollView event triggered + * Adds callback function called ScrollView event triggered * @param {Function} selector * @param {Object} target * @deprecated since v3.0, please use addEventListener instead. @@ -1514,6 +1534,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._scrollViewEventListener = target; }, + /** + * Adds callback function called ScrollView event triggered + * @param {function} callback + */ addEventListener: function(callback){ this._eventCallback = callback; }, @@ -1528,7 +1552,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Gets scroll direction of ScrollView. + * Returns scroll direction of ScrollView. * @returns {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} */ getDirection: function () { @@ -1536,7 +1560,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * set bounce enabled + * Sets bounce enabled * @param {Boolean} enabled */ setBounceEnabled: function (enabled) { @@ -1544,7 +1568,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get whether bounce is enabled + * Returns whether bounce is enabled * @returns {boolean} */ isBounceEnabled: function () { @@ -1552,7 +1576,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * set inertiaScroll enabled + * Sets inertiaScroll enabled * @param {boolean} enabled */ setInertiaScrollEnabled: function (enabled) { @@ -1560,7 +1584,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * get whether inertiaScroll is enabled + * Returns whether inertiaScroll is enabled * @returns {boolean} */ isInertiaScrollEnabled: function () { @@ -1576,7 +1600,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Sets LayoutType. + * Sets LayoutType of ccui.ScrollView. * @param {ccui.Layout.ABSOLUTE|ccui.Layout.LINEAR_VERTICAL|ccui.Layout.LINEAR_HORIZONTAL|ccui.Layout.RELATIVE} type */ setLayoutType: function (type) { @@ -1584,7 +1608,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Gets LayoutType. + * Returns the layout type of ccui.ScrollView. * @returns {ccui.Layout.ABSOLUTE|ccui.Layout.LINEAR_VERTICAL|ccui.Layout.LINEAR_HORIZONTAL|ccui.Layout.RELATIVE} */ getLayoutType: function () { @@ -1598,7 +1622,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.ScrollView. * @returns {string} */ getDescription: function () { @@ -1646,7 +1670,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Removes a node + * Removes a node from ccui.ScrollView. * @param {cc.Node} node * @deprecated since v3.0, please use removeChild instead. */ @@ -1655,7 +1679,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Remove a node by tag + * Removes a node by tag * @param {Number} tag * @deprecated since v3.0, please use removeChildByTag instead. */ @@ -1664,7 +1688,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, /** - * Remove all node + * Remove all node from ccui.ScrollView. * @deprecated since v3.0, please use removeAllChildren instead. */ removeAllNodes: function () { @@ -1673,7 +1697,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ /** * Add node for scrollView - * @param {cc.Node}node + * @param {cc.Node} node * @param {Number} zOrder * @param {Number} tag * @deprecated since v3.0, please use addChild instead. @@ -1709,24 +1733,97 @@ ccui.ScrollView.create = function () { // Constants //ScrollView direction +/** + * The none flag of ccui.ScrollView's direction. + * @constant + * @type {number} + */ ccui.ScrollView.DIR_NONE = 0; +/** + * The vertical flag of ccui.ScrollView's direction. + * @constant + * @type {number} + */ ccui.ScrollView.DIR_VERTICAL = 1; +/** + * The horizontal flag of ccui.ScrollView's direction. + * @constant + * @type {number} + */ ccui.ScrollView.DIR_HORIZONTAL = 2; +/** + * The both flag of ccui.ScrollView's direction. + * @constant + * @type {number} + */ ccui.ScrollView.DIR_BOTH = 3; //ScrollView event +/** + * The flag scroll to top of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_SCROLL_TO_TOP = 0; +/** + * The flag scroll to bottom of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM = 1; +/** + * The flag scroll to left of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_SCROLL_TO_LEFT = 2; +/** + * The flag scroll to right of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_SCROLL_TO_RIGHT = 3; +/** + * The scrolling flag of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_SCROLLING = 4; +/** + * The flag bounce top of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_BOUNCE_TOP = 5; +/** + * The flag bounce bottom of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_BOUNCE_BOTTOM = 6; +/** + * The flag bounce left of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_BOUNCE_LEFT = 7; +/** + * The flag bounce right of ccui.ScrollView's event. + * @constant + * @type {number} + */ ccui.ScrollView.EVENT_BOUNCE_RIGHT = 8; - +/** + * The auto scroll max speed of ccui.ScrollView. + * @constant + * @type {number} + */ ccui.ScrollView.AUTO_SCROLL_MAX_SPEED = 1000; + +/** + * @ignore + */ ccui.ScrollView.SCROLLDIR_UP = cc.p(0, 1); ccui.ScrollView.SCROLLDIR_DOWN = cc.p(0, -1); ccui.ScrollView.SCROLLDIR_LEFT = cc.p(-1, 0); From da5478d496081e180681f2557f6b8d0d229d5a9d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 14:09:48 +0800 Subject: [PATCH 0537/1564] Fixed #5865: JS and JSB's LabelTTF _dimensions are not unified --- cocos2d/core/labelttf/CCLabelTTF.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 6a6f0cea37..3d290465f4 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -118,7 +118,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ strInfo = ""; fontSize = fontSize || 16; - dimensions = dimensions || cc.size(0, fontSize); + dimensions = dimensions || cc.size(0, 0/*fontSize*/); hAlignment = hAlignment || cc.TEXT_ALIGNMENT_LEFT; vAlignment = vAlignment || cc.VERTICAL_TEXT_ALIGNMENT_TOP; From 19ee10d50e5c1b95058522616d3c9cf39746d9d5 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Wed, 27 Aug 2014 14:11:53 +0800 Subject: [PATCH 0538/1564] add doc for folder menus and transitions --- cocos2d/menus/CCMenu.js | 3 +- cocos2d/menus/CCMenuItem.js | 27 +- cocos2d/transitions/CCTransition.js | 425 ++++++++++++-------- cocos2d/transitions/CCTransitionPageTurn.js | 17 +- cocos2d/transitions/CCTransitionProgress.js | 51 ++- 5 files changed, 324 insertions(+), 199 deletions(-) diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 7a6f52e24d..799c3e54d3 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -46,7 +46,7 @@ cc.MENU_HANDLER_PRIORITY = -128; cc.DEFAULT_PADDING = 5; /** -

    Features and Limitation:
    + *

    Features and Limitation:
    * - You can add MenuItem objects in runtime using addChild:
    * - But the only accepted children are MenuItem objects

    * @class @@ -67,6 +67,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ /** * Constructor of cc.Menu override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @param {...cc.MenuItem|null} menuItems} */ ctor: function (menuItems) { cc.Layer.prototype.ctor.call(this); diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index c8c4150541..75758fb442 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -225,6 +225,9 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ /** * Constructor of cc.MenuItemLabel + * @param {cc.Node} label + * @param {function|String} selector + * @param {cc.Node} target */ ctor: function (label, selector, target) { cc.MenuItem.prototype.ctor.call(this, selector, target); @@ -460,7 +463,14 @@ cc.MenuItemLabel.create = function (label, selector, target) { cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# */{ /** - the contructor of cc.MenuItemAtlasFont + * the contructor of cc.MenuItemAtlasFont + * @param {String} value + * @param {String} charMapFile + * @param {Number} itemWidth + * @param {Number} itemHeight + * @param {String} startCharMap a single character + * @param {function|String|Null} callback + * @param {cc.Node|Null} target */ ctor: function (value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) { var label; @@ -536,6 +546,9 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ /** * Constructor of cc.MenuItemFont + * @param {String} value text for the menu item + * @param {function|String} callback + * @param {cc.Node} target */ ctor: function (value, callback, target) { var label; @@ -718,6 +731,11 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ /** * Constructor of cc.MenuItemSprite + * @param {Image|Null} normalSprite normal state image + * @param {Image|Null} selectedSprite selected state image + * @param {Image|cc.Node|Null} three disabled state image OR target node + * @param {String|function|cc.Node|Null} four callback function name in string or actual function, OR target Node + * @param {String|function|Null} five callback function name in string or actual function */ ctor: function (normalSprite, selectedSprite, three, four, five) { cc.MenuItem.prototype.ctor.call(this); @@ -1054,6 +1072,11 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ /** * Constructor of cc.MenuItemImage + * @param {string|null} normalImage + * @param {string|null} selectedImage + * @param {string|null} disabledImage + * @param {function|string|null} callback + * @param {cc.Node|null} target */ ctor: function (normalImage, selectedImage, three, four, five) { var normalSprite = null, @@ -1415,7 +1438,7 @@ cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIn /** * create a simple container class that "toggles" it's inner items
    * The inner items can be any MenuItem - * @deprecated since since v3.0 please use new cc.MenuItemToggle(params) instead + * @deprecated since v3.0 please use new cc.MenuItemToggle(params) instead * @return {cc.MenuItemToggle} * @example * // Example diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index f22dc6c974..3b37aeee99 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -58,6 +58,10 @@ cc.TRANSITION_ORIENTATION_DOWN_OVER = 1; /** * @class * @extends cc.Scene + * @param {Number} t time in seconds + * @param {cc.Scene} scene the scene to transit with + * @example + * var trans = new TransitionScene(time,scene); */ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ _inScene:null, @@ -70,7 +74,6 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ /** * creates a base transition with duration and incoming scene * Constructor of cc.TransitionScene - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to transit with */ @@ -114,7 +117,12 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ }, /** - * custom onEnter + *

    + * Event callback that is invoked every time when cc.TransitionScene enters the 'stage'.
    + * If the TransitionScene enters the 'stage' with a transition, this event is called when the transition starts.
    + * During onEnter you can't access a "sister/brother" node.
    + * If you override onEnter, you must call its parent's onEnter function with this._super(). + *

    */ onEnter:function () { cc.Node.prototype.onEnter.call(this); @@ -130,7 +138,12 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ }, /** - * custom onExit + *

    + * callback that is called every time the cc.TransitionScene leaves the 'stage'.
    + * If the cc.TransitionScene leaves the 'stage' with a transition, this callback is called when the transition finishes.
    + * During onExit you can't access a sibling node.
    + * If you override onExit, you shall call its parent's onExit with this._super(). + *

    */ onExit:function () { cc.Node.prototype.onExit.call(this); @@ -230,7 +243,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ }); /** * creates a base transition with duration and incoming scene - * @deprecated + * @deprecated since v3.0, please use new cc.TransitionScene(t,scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to transit with * @return {cc.TransitionScene|Null} @@ -245,13 +258,17 @@ cc.TransitionScene.create = function (t, scene) { * useful for when you want to make a transition happen between 2 orientations * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation + * @example + * var trans = new cc.TransitionSceneOriented(time,scene,orientation); */ cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionSceneOriented# */{ _orientation:0, /** * Constructor of TransitionSceneOriented - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation @@ -277,7 +294,7 @@ cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionS /** * creates a base transition with duration and incoming scene - * @deprecated + * @deprecated since v3.0 ,please use new cc.TransitionSceneOriented(t, scene, orientation) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation @@ -294,6 +311,10 @@ cc.TransitionSceneOriented.create = function (t, scene, orientation) { * Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionRotoZoom(t, scene); */ cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZoom# */{ @@ -324,27 +345,26 @@ cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZo anchorX: 0.5, anchorY: 0.5 }); - - var rotoZoom = cc.Sequence.create( - cc.Spawn.create(cc.ScaleBy.create(this._duration / 2, 0.001), - cc.RotateBy.create(this._duration / 2, 360 * 2)), - cc.DelayTime.create(this._duration / 2)); + + var rotoZoom = cc.sequence( + cc.spawn(cc.scaleBy(this._duration / 2, 0.001), + cc.rotateBy(this._duration / 2, 360 * 2)), + cc.delayTime(this._duration / 2)); this._outScene.runAction(rotoZoom); this._inScene.runAction( - cc.Sequence.create(rotoZoom.reverse(), - cc.CallFunc.create(this.finish, this))); + cc.sequence(rotoZoom.reverse(), + cc.callFunc(this.finish, this))); } }); /** * Creates a Transtion rotation and zoom - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionRotoZoom(t, scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to work with * @return {cc.TransitionRotoZoom} * @example - * // Example * var RotoZoomTrans = cc.TransitionRotoZoom.create(2, nextScene); */ cc.TransitionRotoZoom.create = function (t, scene) { @@ -355,11 +375,14 @@ cc.TransitionRotoZoom.create = function (t, scene) { * Zoom out and jump the outgoing scene, and then jump and zoom in the incoming * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionJumpZoom(t, scene); */ cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZoom# */{ /** * Constructor of TransitionJumpZoom - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -384,22 +407,22 @@ cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZo this._outScene.anchorX = 0.5; this._outScene.anchorY = 0.5; - var jump = cc.JumpBy.create(this._duration / 4, cc.p(-winSize.width, 0), winSize.width / 4, 2); - var scaleIn = cc.ScaleTo.create(this._duration / 4, 1.0); - var scaleOut = cc.ScaleTo.create(this._duration / 4, 0.5); + var jump = cc.jumpBy(this._duration / 4, cc.p(-winSize.width, 0), winSize.width / 4, 2); + var scaleIn = cc.scaleTo(this._duration / 4, 1.0); + var scaleOut = cc.scaleTo(this._duration / 4, 0.5); - var jumpZoomOut = cc.Sequence.create(scaleOut, jump); - var jumpZoomIn = cc.Sequence.create(jump, scaleIn); + var jumpZoomOut = cc.sequence(scaleOut, jump); + var jumpZoomIn = cc.sequence(jump, scaleIn); - var delay = cc.DelayTime.create(this._duration / 2); + var delay = cc.delayTime(this._duration / 2); this._outScene.runAction(jumpZoomOut); - this._inScene.runAction(cc.Sequence.create(delay, jumpZoomIn, cc.CallFunc.create(this.finish, this))); + this._inScene.runAction(cc.sequence(delay, jumpZoomIn, cc.callFunc(this.finish, this))); } }); /** * creates a scene transition that zooms then jump across the screen, the same for the incoming scene - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionJumpZoom(t, scene); * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionJumpZoom} @@ -412,11 +435,14 @@ cc.TransitionJumpZoom.create = function (t, scene) { * Move in from to the left the incoming scene. * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionMoveInL(time,scene); */ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL# */{ /** * Constructor of TransitionMoveInL - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -433,7 +459,7 @@ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL var action = this.action(); this._inScene.runAction( - cc.Sequence.create(this.easeActionWithAction(action), cc.CallFunc.create(this.finish, this)) + cc.sequence(this.easeActionWithAction(action), cc.callFunc(this.finish, this)) ); }, @@ -448,7 +474,7 @@ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL * returns the action that will be performed */ action:function () { - return cc.MoveTo.create(this._duration, cc.p(0, 0)); + return cc.moveTo(this._duration, cc.p(0, 0)); }, /** @@ -457,18 +483,17 @@ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL * @return {cc.EaseOut} */ easeActionWithAction:function (action) { - return cc.EaseOut.create(action, 2.0); + return cc.EaseOut(action, 2.0); } }); /** * creates an action that Move in from to the left the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionMoveInL(t, scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInL} * @example - * // Example * var MoveInLeft = cc.TransitionMoveInL.create(1, nextScene) */ cc.TransitionMoveInL.create = function (t, scene) { @@ -479,11 +504,14 @@ cc.TransitionMoveInL.create = function (t, scene) { * Move in from to the right the incoming scene. * @class * @extends cc.TransitionMoveInL + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionMoveInR(time,scene); */ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInR# */{ /** * Constructor of TransitionMoveInR - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -492,7 +520,7 @@ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI scene && this.initWithDuration(t, scene); }, /** - * Init + * Init function */ initScenes:function () { this._inScene.setPosition(cc.director.getWinSize().width, 0); @@ -501,12 +529,11 @@ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI /** * create a scene transition that Move in from to the right the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionMoveInR(t, scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInR} * @example - * // Example * var MoveInRight = cc.TransitionMoveInR.create(1, nextScene) */ cc.TransitionMoveInR.create = function (t, scene) { @@ -517,11 +544,14 @@ cc.TransitionMoveInR.create = function (t, scene) { * Move in from to the top the incoming scene. * @class * @extends cc.TransitionMoveInL + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionMoveInT(time,scene); */ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInT# */{ /** * Constructor of TransitionMoveInT - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -530,7 +560,7 @@ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI scene && this.initWithDuration(t, scene); }, /** - * init + * init function */ initScenes:function () { this._inScene.setPosition(0, cc.director.getWinSize().height); @@ -539,12 +569,11 @@ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI /** * Move in from to the top the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionMoveInT(t, scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInT} * @example - * // Example * var MoveInTop = cc.TransitionMoveInT.create(1, nextScene) */ cc.TransitionMoveInT.create = function (t, scene) { @@ -555,11 +584,14 @@ cc.TransitionMoveInT.create = function (t, scene) { * Move in from to the bottom the incoming scene. * @class * @extends cc.TransitionMoveInL + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionMoveInB(time,scene); */ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInB# */{ /** * Constructor of TransitionMoveInB - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -569,7 +601,7 @@ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI }, /** - * init + * init function */ initScenes:function () { this._inScene.setPosition(0, -cc.director.getWinSize().height); @@ -578,12 +610,11 @@ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI /** * create a scene transition that Move in from to the bottom the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionMoveInB(t, scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInB} * @example - * // Example * var MoveinB = cc.TransitionMoveInB.create(1, nextScene) */ cc.TransitionMoveInB.create = function (t, scene) { @@ -604,11 +635,14 @@ cc.ADJUST_FACTOR = 0.5; * a transition that a new scene is slided from left * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = cc.TransitionSlideInL(time,scene); */ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideInL# */{ /** * Constructor of TransitionSlideInL - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -631,7 +665,7 @@ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideI var outA = this.action(); var inAction = this.easeActionWithAction(inA); - var outAction = cc.Sequence.create(this.easeActionWithAction(outA), cc.CallFunc.create(this.finish, this)); + var outAction = cc.sequence(this.easeActionWithAction(outA), cc.callFunc(this.finish, this)); this._inScene.runAction(inAction); this._outScene.runAction(outAction); }, @@ -647,7 +681,7 @@ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideI * @return {cc.MoveBy} */ action:function () { - return cc.MoveBy.create(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0)); + return cc.moveBy(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0)); }, /** @@ -655,18 +689,17 @@ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideI * @return {*} */ easeActionWithAction:function (action) { - return cc.EaseOut.create(action, 2.0); + return cc.EaseInOut(action, 2.0); } }); /** * create a transition that a new scene is slided from left - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionSlideInL(t, scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInL} * @example - * // Example * var myTransition = cc.TransitionSlideInL.create(1.5, nextScene) */ cc.TransitionSlideInL.create = function (t, scene) { @@ -677,11 +710,14 @@ cc.TransitionSlideInL.create = function (t, scene) { * Slide in the incoming scene from the right border. * @class * @extends cc.TransitionSlideInL + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionSlideInR(time,scene); */ cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInR# */{ /** * Constructor of TransitionSlideInR - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -703,18 +739,17 @@ cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @return {cc.MoveBy} */ action:function () { - return cc.MoveBy.create(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0)); + return cc.moveBy(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0)); } }); /** * create Slide in the incoming scene from the right border. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionSlideInR(t, scene) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInR} * @example - * // Example * var myTransition = cc.TransitionSlideInR.create(1.5, nextScene) */ cc.TransitionSlideInR.create = function (t, scene) { @@ -725,11 +760,14 @@ cc.TransitionSlideInR.create = function (t, scene) { * Slide in the incoming scene from the bottom border. * @class * @extends cc.TransitionSlideInL + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionSlideInB(time,scene); */ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInB# */{ /** * Constructor of TransitionSlideInB - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -753,18 +791,17 @@ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @return {cc.MoveBy} */ action:function () { - return cc.MoveBy.create(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)); + return cc.moveBy(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)); } }); /** * create a Slide in the incoming scene from the bottom border. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionSlideInB(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInB} * @example - * // Example * var myTransition = cc.TransitionSlideInB.create(1.5, nextScene) */ cc.TransitionSlideInB.create = function (t, scene) { @@ -775,11 +812,14 @@ cc.TransitionSlideInB.create = function (t, scene) { * Slide in the incoming scene from the top border. * @class * @extends cc.TransitionSlideInL + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionSlideInT(time,scene); */ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInT# */{ /** * Constructor of TransitionSlideInT - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -803,18 +843,17 @@ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @return {cc.MoveBy} */ action:function () { - return cc.MoveBy.create(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))); + return cc.moveBy(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))); } }); /** * create a Slide in the incoming scene from the top border. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionSlideInT(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInT} * @example - * // Example * var myTransition = cc.TransitionSlideInT.create(1.5, nextScene) */ cc.TransitionSlideInT.create = function (t, scene) { @@ -825,11 +864,14 @@ cc.TransitionSlideInT.create = function (t, scene) { * Shrink the outgoing scene while grow the incoming scene * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionShrinkGrow(time,scene); */ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShrinkGrow# */{ /** * Constructor of TransitionShrinkGrow - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -868,18 +910,17 @@ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShri * @return {cc.EaseOut} */ easeActionWithAction:function (action) { - return cc.EaseOut.create(action, 2.0); + return cc.EaseOut(action, 2.0); } }); /** * Shrink the outgoing scene while grow the incoming scene - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionShrinkGrow(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionShrinkGrow} * @example - * // Example * var myTransition = cc.TransitionShrinkGrow.create(1.5, nextScene) */ cc.TransitionShrinkGrow.create = function (t, scene) { @@ -891,6 +932,11 @@ cc.TransitionShrinkGrow.create = function (t, scene) { * The front face is the outgoing scene and the back face is the incoming scene. * @class * @extends cc.TransitionSceneOriented + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + * @example + * var trans = new cc.TransitionFlipX(t,scene,o); */ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipX# */{ /** @@ -929,15 +975,15 @@ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF outAngleZ = 0; } - inA = cc.Sequence.create( - cc.DelayTime.create(this._duration / 2), cc.Show.create(), - cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0), - cc.CallFunc.create(this.finish, this) + inA = cc.sequence( + cc.delayTime(this._duration / 2), cc.show(), + cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0), + cc.callFunc(this.finish, this) ); - outA = cc.Sequence.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0), - cc.Hide.create(), cc.DelayTime.create(this._duration / 2) + outA = cc.sequence( + cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0), + cc.hide(), cc.delayTime(this._duration / 2) ); this._inScene.runAction(inA); @@ -948,15 +994,13 @@ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF /** * Flips the screen horizontally.
    * The front face is the outgoing scene and the back face is the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionFlipX(t, scene,o) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionFlipX} * @example - * // Example * var myTransition = cc.TransitionFlipX.create(1.5, nextScene) //default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * * //OR * var myTransition = cc.TransitionFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_UP_OVER) */ @@ -969,12 +1013,16 @@ cc.TransitionFlipX.create = function (t, scene, o) { * The front face is the outgoing scene and the back face is the incoming scene. * @class * @extends cc.TransitionSceneOriented + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + * @example + * var trans = new cc.TransitionFlipY(time,scene,0); */ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipY# */{ /** * Constructor of TransitionFlipY - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1025,15 +1073,13 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF /** * Flips the screen vertically.
    * The front face is the outgoing scene and the back face is the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionFlipY(t, scene,o) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionFlipY} * @example - * // Example * var myTransition = cc.TransitionFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER - * * //OR * var myTransition = cc.TransitionFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_RIGHT_OVER) */ @@ -1046,11 +1092,15 @@ cc.TransitionFlipY.create = function (t, scene, o) { * The front face is the outgoing scene and the back face is the incoming scene. * @class * @extends cc.TransitionSceneOriented + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + * @example + * var trans = cc.TransitionFlipAngular(time,scene,o); */ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipAngular# */{ /** * Constructor of TransitionFlipAngular - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1083,14 +1133,14 @@ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.Trans outAngleZ = 0; } - inA = cc.Sequence.create( - cc.DelayTime.create(this._duration / 2), cc.Show.create(), - cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0), - cc.CallFunc.create(this.finish, this) + inA = cc.sequence( + cc.delayTime(this._duration / 2), cc.show(), + cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0), + cc.callFunc(this.finish, this) ); - outA = cc.Sequence.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0), - cc.Hide.create(), cc.DelayTime.create(this._duration / 2) + outA = cc.sequence( + cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0), + cc.hide(), cc.delayTime(this._duration / 2) ); this._inScene.runAction(inA); @@ -1101,15 +1151,13 @@ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.Trans /** * Flips the screen half horizontally and half vertically.
    * The front face is the outgoing scene and the back face is the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new new cc.TransitionFlipAngular(t, scene, o) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionFlipAngular} * @example - * // Example * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * * //or * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ @@ -1122,12 +1170,16 @@ cc.TransitionFlipAngular.create = function (t, scene, o) { * The front face is the outgoing scene and the back face is the incoming scene. * @class * @extends cc.TransitionSceneOriented + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + * @example + * var trans = new cc.TransitionZoomFlipX(time,scene,o); */ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipX# */{ /** * Constructor of TransitionZoomFlipX - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1160,19 +1212,19 @@ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.Transit outAngleZ = 0; } - inA = cc.Sequence.create( - cc.DelayTime.create(this._duration / 2), - cc.Spawn.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0), - cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()), - cc.CallFunc.create(this.finish, this) + inA = cc.sequence( + cc.delayTime(this._duration / 2), + cc.spawn( + cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0), + cc.scaleTo(this._duration / 2, 1), cc.show()), + cc.callFunc(this.finish, this) ); - outA = cc.Sequence.create( - cc.Spawn.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0), - cc.ScaleTo.create(this._duration / 2, 0.5)), - cc.Hide.create(), - cc.DelayTime.create(this._duration / 2) + outA = cc.sequence( + cc.spawn( + cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0), + cc.scaleTo(this._duration / 2, 0.5)), + cc.hide(), + cc.delayTime(this._duration / 2) ); this._inScene.scale = 0.5; @@ -1184,15 +1236,13 @@ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.Transit /** * Flips the screen horizontally doing a zoom out/in
    * The front face is the outgoing scene and the back face is the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new new cc.TransitionZoomFlipX(t, scene, o) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionZoomFlipX} * @example - * // Example * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * * //OR * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ @@ -1205,12 +1255,16 @@ cc.TransitionZoomFlipX.create = function (t, scene, o) { * The front face is the outgoing scene and the back face is the incoming scene. * @class * @extends cc.TransitionSceneOriented + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + * @example + * var trans = new cc.TransitionZoomFlipY(t,scene,o); */ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipY# */{ /** * Constructor of TransitionZoomFlipY - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1243,18 +1297,18 @@ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.Transit outAngleZ = 0; } - inA = cc.Sequence.create( - cc.DelayTime.create(this._duration / 2), - cc.Spawn.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0), - cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()), - cc.CallFunc.create(this.finish, this)); + inA = cc.sequence( + cc.delayTime(this._duration / 2), + cc.spawn( + cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0), + cc.scaleTo(this._duration / 2, 1), cc.show()), + cc.callFunc(this.finish, this)); - outA = cc.Sequence.create( - cc.Spawn.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0), - cc.ScaleTo.create(this._duration / 2, 0.5)), - cc.Hide.create(), cc.DelayTime.create(this._duration / 2)); + outA = cc.sequence( + cc.spawn( + cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0), + cc.scaleTo(this._duration / 2, 0.5)), + cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.scale = 0.5; this._inScene.runAction(inA); @@ -1265,15 +1319,13 @@ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.Transit /** * Flips the screen vertically doing a little zooming out/in
    * The front face is the outgoing scene and the back face is the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new new cc.TransitionZoomFlipY(t, scene, o) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionZoomFlipY} * @example - * // Example * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER - * * //OR * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ @@ -1286,12 +1338,16 @@ cc.TransitionZoomFlipY.create = function (t, scene, o) { * The front face is the outgoing scene and the back face is the incoming scene. * @class * @extends cc.TransitionSceneOriented + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + * @example + * var trans = new cc.TransitionZoomFlipAngular(time,scene,o); */ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipAngular# */{ /** * Constructor of TransitionZoomFlipAngular - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1323,18 +1379,18 @@ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.T outAngleZ = 0; } - inA = cc.Sequence.create( - cc.DelayTime.create(this._duration / 2), - cc.Spawn.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0), - cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()), - cc.Show.create(), - cc.CallFunc.create(this.finish, this)); - outA = cc.Sequence.create( - cc.Spawn.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0), - cc.ScaleTo.create(this._duration / 2, 0.5)), - cc.Hide.create(), cc.DelayTime.create(this._duration / 2)); + inA = cc.sequence( + cc.delayTime(this._duration / 2), + cc.spawn( + cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0), + cc.scaleTo(this._duration / 2, 1), cc.show()), + cc.show(), + cc.callFunc(this.finish, this)); + outA = cc.sequence( + cc.spawn( + cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0), + cc.scaleTo(this._duration / 2, 0.5)), + cc.hide(), cc.delayTime(this._duration / 2)); this._inScene.scale = 0.5; this._inScene.runAction(inA); @@ -1345,15 +1401,13 @@ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.T /** * Flips the screen half horizontally and half vertically doing a little zooming out/in.
    * The front face is the outgoing scene and the back face is the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new new cc.TransitionZoomFlipAngular(t, scene, o) instead * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionZoomFlipAngular} * @example - * // Example * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * * //OR * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ @@ -1365,13 +1419,17 @@ cc.TransitionZoomFlipAngular.create = function (t, scene, o) { * Fade out the outgoing scene and then fade in the incoming scene. * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o + * @example + * var trans = new cc.TransitionFade(time,scene,color) */ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ _color:null, /** * Constructor of TransitionFade - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o @@ -1433,13 +1491,12 @@ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ /** * Fade out the outgoing scene and then fade in the incoming scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionFade(time,scene,color) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {cc.Color} color * @return {cc.TransitionFade} * @example - * // Example * var myTransition = cc.TransitionFade.create(1.5, nextScene, cc.color(255,0,0))//fade to red */ cc.TransitionFade.create = function (t, scene, color) { @@ -1450,11 +1507,14 @@ cc.TransitionFade.create = function (t, scene, color) { * Cross fades two scenes using the cc.RenderTexture object. * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionCrossFade(time,scene); */ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCrossFade# */{ /** * Constructor of TransitionCrossFade - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1517,9 +1577,9 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross outTexture.sprite.opacity = 255; // create the blend action - var layerAction = cc.Sequence.create( - cc.FadeTo.create(this._duration, 0), cc.CallFunc.create(this.hideOutShowIn, this), - cc.CallFunc.create(this.finish, this) + var layerAction = cc.sequence( + cc.fadeTo(this._duration, 0), cc.callFunc(this.hideOutShowIn, this), + cc.callFunc(this.finish, this) ); // run the blend action @@ -1547,12 +1607,11 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross /** * Cross fades two scenes using the cc.RenderTexture object. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionCrossFade(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionCrossFade} * @example - * // Example * var myTransition = cc.TransitionCrossFade.create(1.5, nextScene) */ cc.TransitionCrossFade.create = function (t, scene) { @@ -1563,12 +1622,15 @@ cc.TransitionCrossFade.create = function (t, scene) { * Turn off the tiles of the outgoing scene in random order * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionTurnOffTiles(time,scene); */ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTurnOffTiles# */{ /** * Constructor of TransitionCrossFade - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1590,9 +1652,9 @@ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTu var aspect = winSize.width / winSize.height; var x = 0 | (12 * aspect); var y = 12; - var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y)); + var toff = cc.turnOffTiles(this._duration, cc.size(x, y)); var action = this.easeActionWithAction(toff); - this._outScene.runAction(cc.Sequence.create(action, cc.CallFunc.create(this.finish, this), cc.StopGrid.create())); + this._outScene.runAction(cc.sequence(action, cc.callFunc(this.finish, this), cc.stopGrid())); }, /** @@ -1606,12 +1668,11 @@ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTu /** * Turn off the tiles of the outgoing scene in random order - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionTurnOffTiles(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionTurnOffTiles} * @example - * // Example * var myTransition = cc.TransitionTurnOffTiles.create(1.5, nextScene) */ cc.TransitionTurnOffTiles.create = function (t, scene) { @@ -1622,12 +1683,15 @@ cc.TransitionTurnOffTiles.create = function (t, scene) { * The odd columns goes upwards while the even columns goes downwards. * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionSplitCols(time,scene); */ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplitCols# */{ /** * Constructor of TransitionSplitCols - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1643,11 +1707,11 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit this._inScene.visible = false; var split = this.action(); - var seq = cc.Sequence.create( - split, cc.CallFunc.create(this.hideOutShowIn, this), split.reverse()); + var seq = cc.sequence( + split, cc.callFunc(this.hideOutShowIn, this), split.reverse()); this.runAction( - cc.Sequence.create(this.easeActionWithAction(seq), cc.CallFunc.create(this.finish, this), cc.StopGrid.create()) + cc.sequence(this.easeActionWithAction(seq), cc.callFunc(this.finish, this), cc.stopGrid()) ); }, @@ -1656,25 +1720,24 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit * @return {cc.EaseInOut} */ easeActionWithAction:function (action) { - return cc.EaseInOut.create(action, 3.0); + return cc.EaseInOut(action, 3.0); }, /** * @return {*} */ action:function () { - return cc.SplitCols.create(this._duration / 2.0, 3); + return cc.splitCols(this._duration / 2.0, 3); } }); /** * The odd columns goes upwards while the even columns goes downwards. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionSplitCols(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSplitCols} * @example - * // Example * var myTransition = cc.TransitionSplitCols.create(1.5, nextScene) */ cc.TransitionSplitCols.create = function (t, scene) { @@ -1685,12 +1748,15 @@ cc.TransitionSplitCols.create = function (t, scene) { * The odd rows goes to the left while the even rows goes to the right. * @class * @extends cc.TransitionSplitCols + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionSplitRows(time,scene); */ cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionSplitRows# */{ /** * Constructor of TransitionSplitRows - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1702,18 +1768,17 @@ cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionS * @return {*} */ action:function () { - return cc.SplitRows.create(this._duration / 2.0, 3); + return cc.splitRows(this._duration / 2.0, 3); } }); /** * The odd rows goes to the left while the even rows goes to the right. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionSplitRows(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSplitRows} * @example - * // Example * var myTransition = cc.TransitionSplitRows.create(1.5, nextScene) */ cc.TransitionSplitRows.create = function (t, scene) { @@ -1724,12 +1789,15 @@ cc.TransitionSplitRows.create = function (t, scene) { * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner. * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionFadeTR(time,scene); */ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */{ /** * Constructor of TransitionFadeTR - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1772,18 +1840,17 @@ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# * @return {*} */ actionWithSize:function (size) { - return cc.FadeOutTRTiles.create(this._duration, size); + return cc.fadeOutTRTiles(this._duration, size); } }); /** * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner. - * @deprecated + * @deprecated since v3.0 please use new cc.TransitionFadeTR(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeTR} * @example - * // Example * var myTransition = cc.TransitionFadeTR.create(1.5, nextScene) */ cc.TransitionFadeTR.create = function (t, scene) { @@ -1794,11 +1861,14 @@ cc.TransitionFadeTR.create = function (t, scene) { * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. * @class * @extends cc.TransitionFadeTR + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionFadeBL(time,scene) */ cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# */{ /** * Constructor of TransitionFadeBL - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1812,13 +1882,13 @@ cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# * @return {*} */ actionWithSize:function (size) { - return cc.FadeOutBLTiles.create(this._duration, size); + return cc.fadeOutBLTiles(this._duration, size); } }); /** * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionFadeBL(t, scene); * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeBL} @@ -1834,6 +1904,10 @@ cc.TransitionFadeBL.create = function (t, scene) { * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. * @class * @extends cc.TransitionFadeTR + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionFadeUp(time,scene); */ cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# */{ @@ -1859,12 +1933,11 @@ cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# /** * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionFadeUp(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeUp} * @example - * // Example * var myTransition = cc.TransitionFadeUp.create(1.5, nextScene) */ cc.TransitionFadeUp.create = function (t, scene) { @@ -1875,12 +1948,15 @@ cc.TransitionFadeUp.create = function (t, scene) { * Fade the tiles of the outgoing scene from the top to the bottom. * @class * @extends cc.TransitionFadeTR + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionFadeDown(time,scene); */ cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeDown# */{ /** * Constructor of TransitionFadeDown - * @function * @param {Number} t time in seconds * @param {cc.Scene} scene */ @@ -1894,18 +1970,17 @@ cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeD * @return {*} */ actionWithSize:function (size) { - return cc.FadeOutDownTiles.create( this._duration, size); + return cc.fadeOutDownTiles( this._duration, size); } }); /** * Fade the tiles of the outgoing scene from the top to the bottom. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionFadeDown(t, scene) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeDown} * @example - * // Example * var myTransition = cc.TransitionFadeDown.create(1.5, nextScene) */ cc.TransitionFadeDown.create = function (t, scene) { diff --git a/cocos2d/transitions/CCTransitionPageTurn.js b/cocos2d/transitions/CCTransitionPageTurn.js index 09cf8c05e2..b6f1800118 100644 --- a/cocos2d/transitions/CCTransitionPageTurn.js +++ b/cocos2d/transitions/CCTransitionPageTurn.js @@ -34,11 +34,15 @@ *

    cc.director.setDepthBufferFormat(kDepthBuffer16);

    * @class * @extends cc.TransitionScene + * @param {Number} t time in seconds + * @param {cc.Scene} scene + * @param {Boolean} backwards + * @example + * var trans = new cc.TransitionPageTurn(t, scene, backwards); */ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTurn# */{ /** - * @constructor * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {Boolean} backwards @@ -79,9 +83,9 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu */ actionWithSize:function (vector) { if (this._back) - return cc.ReverseTime.create(cc.PageTurn3D.create(this._duration, vector)); // Get hold of the PageTurn3DAction + return cc.reverseTime(cc.pageTurn3D(this._duration, vector)); // Get hold of the PageTurn3DAction else - return cc.PageTurn3D.create(this._duration, vector); // Get hold of the PageTurn3DAction + return cc.pageTurn3D(this._duration, vector); // Get hold of the PageTurn3DAction }, /** @@ -102,12 +106,12 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu var action = this.actionWithSize(cc.size(x, y)); if (!this._back) { - this._outScene.runAction( cc.Sequence.create(action,cc.CallFunc.create(this.finish, this),cc.StopGrid.create())); + this._outScene.runAction( cc.sequence(action,cc.CallFunc.create(this.finish, this),cc.StopGrid.create())); } else { // to prevent initial flicker this._inScene.visible = false; this._inScene.runAction( - cc.Sequence.create(cc.Show.create(),action, cc.CallFunc.create(this.finish, this), cc.StopGrid.create()) + cc.sequence(cc.show(),action, cc.callFunc(this.finish, this), cc.stopGrid()) ); } }, @@ -121,13 +125,12 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu * Creates a base transition with duration and incoming scene.
    * If back is true then the effect is reversed to appear as if the incoming
    * scene is being turned from left over the outgoing scene. - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionPageTurn(t, scene, backwards) instead. * @param {Number} t time in seconds * @param {cc.Scene} scene * @param {Boolean} backwards * @return {cc.TransitionPageTurn} * @example - * // Example * var myTransition = cc.TransitionPageTurn.create(1.5, nextScene, true)//true means backwards */ cc.TransitionPageTurn.create = function (t, scene, backwards) { diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index e3699fd464..7a26a54813 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -35,6 +35,10 @@ cc.SCENE_RADIAL = 0xc001; * cc.TransitionProgress transition. * @class * @extends cc.TransitionScene + * @param {Number} t time + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionProgress(time,scene); */ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgress# */{ _to:0, @@ -43,7 +47,6 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre _className:"TransitionProgress", /** - * @constructor * @param {Number} t time * @param {cc.Scene} scene */ @@ -63,6 +66,7 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre /** * @override + * custom on enter */ onEnter:function () { cc.TransitionScene.prototype.onEnter.call(this); @@ -104,6 +108,7 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre /** * @override + * custom on exit */ onExit:function () { // remove our layer and release all containing objects @@ -129,11 +134,13 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre /** * create a cc.TransitionProgress object - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionProgress(t, scene) instead. * @function * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgress} + * @example + * var trans = cc.TransitionProgress.create(time,scene); */ cc.TransitionProgress.create = function (t, scene) { return new cc.TransitionProgress(t, scene); @@ -144,11 +151,14 @@ cc.TransitionProgress.create = function (t, scene) { * A counter clock-wise radial transition to the next scene * @class * @extends cc.TransitionProgress + * @param {Number} t time + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionProgressRadialCCW(t, scene); */ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressRadialCCW# */{ /** - * @constructor * @param {Number} t time * @param {cc.Scene} scene */ @@ -178,11 +188,12 @@ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.Tran /** * create a cc.TransitionProgressRadialCCW object - * @function - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionProgressRadialCCW(t, scene) instead. * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressRadialCCW} + * @example + * var trans = cc.TransitionProgressRadialCCW.create(time,scene); */ cc.TransitionProgressRadialCCW.create = function (t, scene) { return new cc.TransitionProgressRadialCCW(t, scene); @@ -193,10 +204,13 @@ cc.TransitionProgressRadialCCW.create = function (t, scene) { * A counter colock-wise radial transition to the next scene * @class * @extends cc.TransitionProgress + * @param {Number} t time + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionProgressRadialCW(t, scene); */ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressRadialCW# */{ /** - * @constructor * @param {Number} t time * @param {cc.Scene} scene */ @@ -226,11 +240,12 @@ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.Trans /** * create a cc.TransitionProgressRadialCW object - * @function - * @deprecated + * @deprecated since v3.0,please use cc.TransitionProgressRadialCW(t, scene) instead. * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressRadialCW} + * @example + * var trans = cc.TransitionProgressRadialCW.create(time,scene); */ cc.TransitionProgressRadialCW.create = function (t, scene) { var tempScene = new cc.TransitionProgressRadialCW(); @@ -245,10 +260,13 @@ cc.TransitionProgressRadialCW.create = function (t, scene) { * A colock-wise radial transition to the next scene * @class * @extends cc.TransitionProgress + * @param {Number} t time + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionProgressHorizontal(t, scene); */ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressHorizontal# */{ /** - * @constructor * @param {Number} t time * @param {cc.Scene} scene */ @@ -279,11 +297,12 @@ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.Tra /** * create a cc.TransitionProgressHorizontal object - * @function - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionProgressHorizontal(t, scene) instead. * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressHorizontal} + * @example + * var trans = cc.TransitionProgressHorizontal.create(time,scene); */ cc.TransitionProgressHorizontal.create = function (t, scene) { return new cc.TransitionProgressHorizontal(t, scene); @@ -293,11 +312,14 @@ cc.TransitionProgressHorizontal.create = function (t, scene) { * cc.TransitionProgressVertical transition. * @class * @extends cc.TransitionProgress + * @param {Number} t time + * @param {cc.Scene} scene + * @example + * var trans = new cc.TransitionProgressVertical(t, scene); */ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressVertical# */{ /** - * @constructor * @param {Number} t time * @param {cc.Scene} scene */ @@ -328,11 +350,12 @@ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.Trans /** * create a cc.TransitionProgressVertical object - * @function - * @deprecated + * @deprecated since v3.0,please use new cc.TransitionProgressVertical(t, scene) instead. * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressVertical} + * @example + * var trans = cc.TransitionProgressVertical.create(time,scene); */ cc.TransitionProgressVertical.create = function (t, scene) { return new cc.TransitionProgressVertical(t, scene); From 9128cd86c8bda92bc5e886f8b95b9a44b0a86752 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 27 Aug 2014 14:23:44 +0800 Subject: [PATCH 0539/1564] Fixed #5037: Add property support to RichText --- extensions/ccui/uiwidgets/UIRichText.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 3352f2235a..4398cc8285 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -437,6 +437,14 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ ccui.Widget.prototype.setAnchorPoint.call(this, pt); this._elementRenderersContainer.setAnchorPoint(pt); }, + _setAnchorX: function (x) { + ccui.Widget.prototype._setAnchorX.call(this, x); + this._elementRenderersContainer._setAnchorX(x); + }, + _setAnchorY: function (y) { + ccui.Widget.prototype._setAnchorY.call(this, y); + this._elementRenderersContainer._setAnchorY(y); + }, getVirtualRendererSize: function(){ return this._elementRenderersContainer.getContentSize(); @@ -460,7 +468,15 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ */ getContentSize: function(){ this.formatText(); - return cc.Node.prototype.getContentSize.l(this); + return cc.Node.prototype.getContentSize.call(this); + }, + _getWidth: function() { + this.formatText(); + return cc.Node.prototype._getWidth.call(this); + }, + _getHeight: function() { + this.formatText(); + return cc.Node.prototype._getHeight.call(this); }, getDescription: function(){ From 4100a9b82ef8d040542209f8ef520c52fe3cfb8a Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Wed, 27 Aug 2014 14:49:40 +0800 Subject: [PATCH 0540/1564] add doc for folder menus and transitions --- cocos2d/transitions/CCTransition.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 3b37aeee99..2c60f5fc45 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -483,7 +483,7 @@ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL * @return {cc.EaseOut} */ easeActionWithAction:function (action) { - return cc.EaseOut(action, 2.0); + return new cc.EaseOut(action, 2.0); } }); @@ -689,7 +689,7 @@ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideI * @return {*} */ easeActionWithAction:function (action) { - return cc.EaseInOut(action, 2.0); + return new cc.EaseInOut(action, 2.0); } }); @@ -896,12 +896,12 @@ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShri anchorY: 0.5 }); - var scaleOut = cc.ScaleTo.create(this._duration, 0.01); - var scaleIn = cc.ScaleTo.create(this._duration, 1.0); + var scaleOut = cc.scaleTo(this._duration, 0.01); + var scaleIn = cc.scaleTo(this._duration, 1.0); this._inScene.runAction(this.easeActionWithAction(scaleIn)); this._outScene.runAction( - cc.Sequence.create(this.easeActionWithAction(scaleOut), cc.CallFunc.create(this.finish, this)) + cc.sequence(this.easeActionWithAction(scaleOut), cc.callFunc(this.finish, this)) ); }, @@ -910,7 +910,7 @@ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShri * @return {cc.EaseOut} */ easeActionWithAction:function (action) { - return cc.EaseOut(action, 2.0); + return new cc.EaseOut(action, 2.0); } }); @@ -1720,7 +1720,7 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit * @return {cc.EaseInOut} */ easeActionWithAction:function (action) { - return cc.EaseInOut(action, 3.0); + return new cc.EaseInOut(action, 3.0); }, /** From 6f6f1490397bbc14da7bad7001cca33f88d94d18 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 14:54:35 +0800 Subject: [PATCH 0541/1564] Fixed ##5866: cocostudio action error --- extensions/cocostudio/action/CCActionNode.js | 37 +++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index a69c1a7d75..660334030c 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -73,54 +73,51 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ frameTweenParameter.push(value); } + var actionFrame, actionArray; if (actionFrameDic["positionx"] !== undefined) { var positionX = actionFrameDic["positionx"]; var positionY = actionFrameDic["positiony"]; - var actionFrame = new ccs.ActionMoveFrame(); -// actionFrame.easingType = frameTweenType; -// actionFrame.frameIndex = frameInex; + actionFrame = new ccs.ActionMoveFrame(); + actionFrame.frameIndex = frameInex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setPosition(positionX, positionY); - var actionArray = this._frameArray[ccs.FRAME_TYPE_MOVE]; + actionArray = this._frameArray[ccs.FRAME_TYPE_MOVE]; actionArray.push(actionFrame); } if (actionFrameDic["scalex"] !== undefined) { var scaleX = actionFrameDic["scalex"]; var scaleY = actionFrameDic["scaley"]; - var actionFrame = new ccs.ActionScaleFrame(); -// actionFrame.easingType = frameTweenType; -// actionFrame.frameIndex = frameInex; + actionFrame = new ccs.ActionScaleFrame(); + actionFrame.frameIndex = frameInex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setScaleX(scaleX); actionFrame.setScaleY(scaleY); - var actionArray = this._frameArray[ccs.FRAME_TYPE_SCALE]; + actionArray = this._frameArray[ccs.FRAME_TYPE_SCALE]; actionArray.push(actionFrame); } if (actionFrameDic["rotation"] !== undefined) { var rotation = actionFrameDic["rotation"]; - var actionFrame = new ccs.ActionRotationFrame(); -// actionFrame.easingType = frameTweenType; -// actionFrame.frameIndex = frameInex; + actionFrame = new ccs.ActionRotationFrame(); + actionFrame.frameIndex = frameInex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setRotation(rotation); - var actionArray = this._frameArray[ccs.FRAME_TYPE_ROTATE]; + actionArray = this._frameArray[ccs.FRAME_TYPE_ROTATE]; actionArray.push(actionFrame); } if (actionFrameDic["opacity"] !== undefined) { var opacity = actionFrameDic["opacity"]; - var actionFrame = new ccs.ActionFadeFrame(); -// actionFrame.easingType = frameTweenType; -// actionFrame.frameIndex = frameInex; + actionFrame = new ccs.ActionFadeFrame(); + actionFrame.frameIndex = frameInex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setOpacity(opacity); - var actionArray = this._frameArray[ccs.FRAME_TYPE_FADE]; + actionArray = this._frameArray[ccs.FRAME_TYPE_FADE]; actionArray.push(actionFrame); } @@ -128,13 +125,12 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var colorR = actionFrameDic["colorr"]; var colorG = actionFrameDic["colorg"]; var colorB = actionFrameDic["colorb"]; - var actionFrame = new ccs.ActionTintFrame(); -// actionFrame.easingType = frameTweenType; -// actionFrame.frameIndex = frameInex; + actionFrame = new ccs.ActionTintFrame(); + actionFrame.frameIndex = frameInex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setColor(cc.color(colorR, colorG, colorB)); - var actionArray = this._frameArray[ccs.FRAME_TYPE_TINT]; + actionArray = this._frameArray[ccs.FRAME_TYPE_TINT]; actionArray.push(actionFrame); } actionFrameDic = null; @@ -304,7 +300,6 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ /** * Play the action. - * @param {Boolean} loop * @param {cc.CallFunc} fun */ playAction: function (fun) { From a1853620cc373a1b627d5e14424a154b2ac97a72 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 27 Aug 2014 14:55:18 +0800 Subject: [PATCH 0542/1564] Closed #5830: adds jsdocs to UIListView.js --- .../uiwidgets/scroll-widget/UIListView.js | 114 +++++++++++++++--- .../uiwidgets/scroll-widget/UIPageView.js | 7 +- 2 files changed, 100 insertions(+), 21 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index bdf7a3a62a..ea856d45e8 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -24,9 +24,19 @@ ****************************************************************************/ /** - * Base class for ccui.ListView + * The list view control of Cocos UI. * @class * @extends ccui.ScrollView + * @example + * var listView = new ccui.ListView(); + * // set list view ex direction + * listView.setDirection(ccui.ScrollView.DIR_VERTICAL); + * listView.setTouchEnabled(true); + * listView.setBounceEnabled(true); + * listView.setBackGroundImage("res/cocosui/green_edit.png"); + * listView.setBackGroundImageScale9Enabled(true); + * listView.setContentSize(cc.size(240, 130)); + * this.addChild(listView); */ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ _model: null, @@ -236,6 +246,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * add child to ListView + * @override * @param {cc.Node} widget * @param {Number} [zOrder] * @param {Number|String} [tag] tag or name @@ -252,6 +263,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * remove child from ListView + * @override * @param {cc.Node} widget * @param {Boolean} [cleanup=true] */ @@ -264,17 +276,24 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ } }, + /** + * Removes all children from ccui.ListView. + */ removeAllChildren: function(){ this.removeAllChildrenWithCleanup(true); }, + /** + * Removes all children from ccui.ListView and do a cleanup all running actions depending on the cleanup parameter. + * @param {Boolean} cleanup + */ removeAllChildrenWithCleanup: function(cleanup){ ccui.ScrollView.prototype.removeAllChildrenWithCleanup.call(this, cleanup); this._items = []; }, /** - * Push back custom item into ListView. + * Push back custom item into ccui.ListView. * @param {ccui.Widget} item * @param {Number} index */ @@ -298,12 +317,15 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * Removes the last item of ListView. + * Removes the last item of ccui.ListView. */ removeLastItem: function () { this.removeItem(this._items.length - 1); }, + /** + * Removes all items from ccui.ListView. + */ removeAllItems: function(){ this.removeAllChildren(); }, @@ -341,9 +363,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {ccui.ListView.GRAVITY_LEFT|ccui.ListView.GRAVITY_RIGHT|ccui.ListView.GRAVITY_CENTER_HORIZONTAL|ccui.ListView.GRAVITY_BOTTOM|ccui.ListView.GRAVITY_CENTER_VERTICAL} gravity */ setGravity: function (gravity) { - if (this._gravity == gravity) { + if (this._gravity == gravity) return; - } this._gravity = gravity; this._refreshViewDirty = true; }, @@ -353,15 +374,14 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {Number} margin */ setItemsMargin: function (margin) { - if (this._itemsMargin == margin) { + if (this._itemsMargin == margin) return; - } this._itemsMargin = margin; this._refreshViewDirty = true; }, /** - * Get the margin between each item. + * Returns the margin between each item. * @returns {Number} */ getItemsMargin:function(){ @@ -369,7 +389,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * Changes scroll direction of scrollview. + * Changes scroll direction of ccui.ListView. * @param {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} dir */ setDirection: function (dir) { @@ -390,12 +410,15 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * request refresh view + * Requests refresh list view. */ requestRefreshView: function () { this._refreshViewDirty = true; }, + /** + * Refreshes list view. + */ refreshView: function () { var locItems = this._items; for (var i = 0; i < locItems.length; i++) { @@ -407,7 +430,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * public the _doLayout for Editor + * provides a public _doLayout function for Editor. it calls _doLayout. */ doLayout: function(){ this._doLayout(); @@ -422,7 +445,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * add event listener + * Adds event listener to ccui.ListView. * @param {Function} selector * @param {Object} target * @deprecated since v3.0, please use addEventListener instead. @@ -432,6 +455,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._listViewEventSelector = selector; }, + /** + * Adds event listener to ccui.ListView. + * @param {function} callback + */ addEventListener: function(callback){ this._eventCallback = callback; }, @@ -444,9 +471,15 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._eventCallback(this, eventEnum); }, - interceptTouchEvent: function (handleState, sender, touch) { - ccui.ScrollView.prototype.interceptTouchEvent.call(this, handleState, sender, touch); - if (handleState != ccui.Widget.TOUCH_MOVED) { + /** + * Intercept touch event, handle its child's touch event. + * @param {Number} eventType + * @param {ccui.Widget} sender + * @param {cc.Touch} touch + */ + interceptTouchEvent: function (eventType, sender, touch) { + ccui.ScrollView.prototype.interceptTouchEvent.call(this, eventType, sender, touch); + if (eventType != ccui.Widget.TOUCH_MOVED) { var parent = sender; while (parent) { if (parent && parent.getParent() == this._innerContainer) { @@ -456,12 +489,12 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ parent = parent.getParent(); } if (sender.isHighlighted()) - this._selectedItemEvent(handleState); + this._selectedItemEvent(eventType); } }, /** - * get current selected index + * Returns current selected index * @returns {number} */ getCurSelectedIndex: function () { @@ -474,7 +507,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, /** - * Returns the "class name" of widget. + * Returns the "class name" of ccui.ListView. * @returns {string} */ getDescription: function () { @@ -520,15 +553,60 @@ ccui.ListView.create = function () { // Constants //listView event type +/** + * The flag selected item of ccui.ListView's event. + * @constant + * @type {number} + */ ccui.ListView.EVENT_SELECTED_ITEM = 0; +/** + * The flag selected item start of ccui.ListView's event. + * @constant + * @type {number} + */ ccui.ListView.ON_SELECTED_ITEM_START = 0; +/** + * The flag selected item end of ccui.ListView's event. + * @constant + * @type {number} + */ ccui.ListView.ON_SELECTED_ITEM_END = 1; //listView gravity +/** + * The left flag of ccui.ListView's gravity. + * @constant + * @type {number} + */ ccui.ListView.GRAVITY_LEFT = 0; +/** + * The right flag of ccui.ListView's gravity. + * @constant + * @type {number} + */ ccui.ListView.GRAVITY_RIGHT = 1; +/** + * The center horizontal flag of ccui.ListView's gravity. + * @constant + * @type {number} + */ ccui.ListView.GRAVITY_CENTER_HORIZONTAL = 2; +/** + * The top flag of ccui.ListView's gravity. + * @constant + * @type {number} + */ ccui.ListView.GRAVITY_TOP = 3; +/** + * The bottom flag of ccui.ListView's gravity. + * @constant + * @type {number} + */ ccui.ListView.GRAVITY_BOTTOM = 4; +/** + * The center vertical flag of ccui.ListView's gravity. + * @constant + * @type {number} + */ ccui.ListView.GRAVITY_CENTER_VERTICAL = 5; \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 2fe966d284..ef6c8cf8bd 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -451,13 +451,13 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ /** * Intercept touch event, handle its child's touch event. - * @param {Number} event event type + * @param {Number} eventType event type * @param {ccui.Widget} sender * @param {cc.Touch} touch */ - interceptTouchEvent: function (event, sender, touch) { + interceptTouchEvent: function (eventType, sender, touch) { var touchPoint = touch.getLocation(); - switch (event) { + switch (eventType) { case ccui.Widget.TOUCH_BEGAN: this._touchBeganPosition.x = touchPoint.x; this._touchBeganPosition.y = touchPoint.y; @@ -475,6 +475,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ case ccui.Widget.TOUCH_ENDED: this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; + break; case ccui.Widget.TOUCH_CANCELED: this._handleReleaseLogic(touch); break; From 990a647f42c7053351e69ee60cbe282c0b05faac Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 15:25:11 +0800 Subject: [PATCH 0543/1564] Issue #5829: particle jsdoc --- cocos2d/actions3d/CCActionGrid.js | 4 +- cocos2d/particle/CCPNGReader.js | 4 + cocos2d/particle/CCParticleBatchNode.js | 52 ++++++++---- cocos2d/particle/CCParticleExamples.js | 104 ++++++++++++++---------- cocos2d/particle/CCParticleSystem.js | 40 ++++++--- 5 files changed, 132 insertions(+), 72 deletions(-) diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index 7d6f373dec..b6ad42bcf1 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -83,8 +83,8 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ }, /** - * Create a cc.EaseSineOut action. Opposite with the original motion trajectory. - * @return {cc.EaseSineOut} + * Create a cc.ReverseTime action. Opposite with the original motion trajectory. + * @return {cc.ReverseTime} */ reverse:function () { return new cc.ReverseTime(this); diff --git a/cocos2d/particle/CCPNGReader.js b/cocos2d/particle/CCPNGReader.js index ee860be525..20667a2cbc 100644 --- a/cocos2d/particle/CCPNGReader.js +++ b/cocos2d/particle/CCPNGReader.js @@ -26,6 +26,10 @@ THE SOFTWARE. ****************************************************************************/ +/** + * A png file reader + * @name cc.tiffReader + */ cc.PNGReader = cc.Class.extend({ ctor:function(data){ var chunkSize, colors, delayDen, delayNum, frame, i, index, key, section, ccshort, text, _i, _j, _ref; diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 8f6d93e24f..52ec8bbd39 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -54,9 +54,21 @@ cc.PARTICLE_DEFAULT_CAPACITY = 500; *

    * @class * @extends cc.ParticleSystem + * @param {String|cc.Texture2D} fileImage + * @param {Number} capacity * * @property {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture - The used texture * @property {cc.TextureAtlas} textureAtlas - The texture atlas used for drawing the quads + * + * @example + * 1. + * //Create a cc.ParticleBatchNode with image path and capacity + * var particleBatchNode = new cc.ParticleBatchNode("res/grossini_dance.png",30); + * + * 2. + * //Create a cc.ParticleBatchNode with a texture and capacity + * var texture = cc.TextureCache.getInstance().addImage("res/grossini_dance.png"); + * var particleBatchNode = new cc.ParticleBatchNode(texture, 30); */ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ textureAtlas:null, @@ -318,8 +330,9 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ }, /** - * @override - * @param {CanvasContext} ctx + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function + * @function + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ draw:function (ctx) { //cc.PROFILER_STOP("CCParticleBatchNode - draw"); @@ -361,7 +374,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ /** * set the blending function used for the texture - * @param {Number|cc.BlencFunc} src + * @param {Number|Object} src * @param {Number} dst */ setBlendFunc:function (src, dst) { @@ -385,6 +398,11 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ // override visit. // Don't call visit on it's children + /** + * Recursive method that visit its children and draw them + * @function + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx + */ visit:function (ctx) { if (cc._renderType === cc._RENDER_TYPE_CANVAS) return; @@ -479,19 +497,19 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ return {newIndex:newIndex, oldIndex:oldIndex}; }, - /** - *

    - * don't use lazy sorting, reordering the particle systems quads afterwards would be too complex
    - * XXX research whether lazy sorting + freeing current quads and calloc a new block with size of capacity would be faster
    - * XXX or possibly using vertexZ for reordering, that would be fastest
    - * this helper is almost equivalent to CCNode's addChild, but doesn't make use of the lazy sorting
    - *

    - * @param {cc.ParticleSystem} child - * @param {Number} z - * @param {Number} aTag - * @return {Number} - * @private - */ + // + //

    + // don't use lazy sorting, reordering the particle systems quads afterwards would be too complex
    + // XXX research whether lazy sorting + freeing current quads and calloc a new block with size of capacity would be faster
    + // XXX or possibly using vertexZ for reordering, that would be fastest
    + // this helper is almost equivalent to CCNode's addChild, but doesn't make use of the lazy sorting
    + //

    + // @param {cc.ParticleSystem} child + // @param {Number} z + // @param {Number} aTag + // @return {Number} + // @private + // _addChildHelper:function (child, z, aTag) { if(!child) throw "cc.ParticleBatchNode._addChildHelper(): child should be non-null"; @@ -552,7 +570,7 @@ cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); /** * initializes the particle system with the name of a file on disk (for a list of supported formats look at the cc.Texture2D class), a capacity of particles - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleBatchNode(filename, capacity) instead. * @param {String|cc.Texture2D} fileImage * @param {Number} capacity * @return {cc.ParticleBatchNode} diff --git a/cocos2d/particle/CCParticleExamples.js b/cocos2d/particle/CCParticleExamples.js index be67f46645..7b1e90ef1a 100644 --- a/cocos2d/particle/CCParticleExamples.js +++ b/cocos2d/particle/CCParticleExamples.js @@ -30,12 +30,13 @@ * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleFire.create(); + * var emitter = new cc.ParticleFire(); */ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{ /** - * Constructor - * @function + *

    The cc.ParticleFire's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFire()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 300 : 150); @@ -104,7 +105,7 @@ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{ /** * Create a fire particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleFire() instead * @return {cc.ParticleFire} * * @example @@ -120,12 +121,13 @@ cc.ParticleFire.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleFireworks.create(); + * var emitter = new cc.ParticleFireworks(); */ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# */{ /** - * Constructor - * @function + *

    The cc.ParticleFireworks's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFireworks()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1500 : 150); @@ -191,7 +193,7 @@ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# /** * Create a fireworks particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleFireworks() instead. * @return {cc.ParticleFireworks} * * @example @@ -207,12 +209,13 @@ cc.ParticleFireworks.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleSun.create(); + * var emitter = new cc.ParticleSun(); */ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{ /** - * Constructor - * @function + *

    The cc.ParticleSun's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSun()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 350 : 150); @@ -280,7 +283,7 @@ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{ /** * Create a sun particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleSun() instead. * @return {cc.ParticleSun} * * @example @@ -297,12 +300,13 @@ cc.ParticleSun.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleGalaxy.create(); + * var emitter = new cc.ParticleGalaxy(); */ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{ /** - * Constructor - * @function + *

    The cc.ParticleGalaxy's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleGalaxy()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); @@ -372,7 +376,7 @@ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{ }); /** * Create a galaxy particle system - * @deprecated + * @deprecated since v3.0 please use new cc.OarticleGalaxy() instead. * @return {cc.ParticleGalaxy} * * @example @@ -388,10 +392,14 @@ cc.ParticleGalaxy.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleFlower.create(); + * var emitter = new cc.ParticleFlower(); */ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{ - + /** + *

    The cc.ParticleFlower's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleFlower()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    + */ ctor : function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 250 : 100); }, @@ -461,7 +469,7 @@ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{ /** * Create a flower particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleFlower() instead. * @return {cc.ParticleFlower} * * @example @@ -478,12 +486,13 @@ cc.ParticleFlower.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleMeteor.create(); + * var emitter = new cc.ParticleMeteor(); */ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{ /** - * Constructor - * @function + *

    The cc.ParticleMeteor's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleMeteor()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 150 : 100); @@ -554,7 +563,7 @@ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{ /** * Create a meteor particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleMeteor() instead. * @return {cc.ParticleMeteor} * * @example @@ -570,12 +579,14 @@ cc.ParticleMeteor.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleSpiral.create(); + * var emitter = new cc.ParticleSpiral(); */ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{ + /** - * Constructor - * @function + *

    The cc.ParticleSpiral's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSpiral()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function() { cc.ParticleSystem.prototype.ctor.call(this,(cc._renderType === cc._RENDER_TYPE_WEBGL) ? 500 : 100); @@ -646,7 +657,7 @@ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{ /** * Create a spiral particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleSpiral() instead. * @return {cc.ParticleSpiral} * * @example @@ -662,12 +673,13 @@ cc.ParticleSpiral.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleExplosion.create(); + * var emitter = new cc.ParticleExplosion(); */ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# */{ /** - * Constructor - * @function + *

    The cc.ParticleExplosion's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleExplosion()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 300); @@ -737,7 +749,7 @@ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# /** * Create an explosion particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleExplosion() instead. * @return {cc.ParticleExplosion} * * @example @@ -753,12 +765,14 @@ cc.ParticleExplosion.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleSmoke.create(); + * var emitter = new cc.ParticleSmoke(); */ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{ + /** - * Constructor - * @function + *

    The cc.ParticleSmoke's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSmoke()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 200 : 100); @@ -825,7 +839,7 @@ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{ /** * Create a smoke particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleSmoke() instead. * @return {cc.ParticleSmoke} * * @example @@ -841,12 +855,14 @@ cc.ParticleSmoke.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleSnow.create(); + * var emitter = new cc.ParticleSnow(); */ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{ + /** - * Constructor - * @function + *

    The cc.ParticleSnow's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleSnow()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 700 : 250); @@ -917,7 +933,7 @@ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{ /** * Create a snow particle system - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleSnow() instead. * @return {cc.ParticleSnow} * * @example @@ -934,12 +950,14 @@ cc.ParticleSnow.create = function () { * @extends cc.ParticleSystem * * @example - * var emitter = cc.ParticleRain.create(); + * var emitter = new cc.ParticleRain(); */ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{ + /** - * Constructor - * @function + *

    The cc.ParticleRain's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.ParticleRain()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    */ ctor:function () { cc.ParticleSystem.prototype.ctor.call(this, (cc._renderType === cc._RENDER_TYPE_WEBGL) ? 1000 : 300); @@ -1010,7 +1028,7 @@ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{ /** * Create a rain particle system - * @deprecated + * @deprecated since v3.0 please use cc.ParticleRain() instead. * @return {cc.ParticleRain} * * @example diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index da299cd454..acd0613f47 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1715,6 +1715,11 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ return true; }, + /** + * Unschedules the "update" method. + * @function + * @see scheduleUpdate(); + */ destroyParticleSystem:function () { this.unscheduleUpdate(); }, @@ -2199,17 +2204,20 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ this.postStep(); }, + /** + * update emitter's status (dt = 0) + */ updateWithNoTime:function () { this.update(0); }, - /** - * return the string found by key in dict. - * @param {string} key - * @param {object} dict - * @return {String} "" if not found; return the string if found. - * @private - */ + // + // return the string found by key in dict. + // @param {string} key + // @param {object} dict + // @return {String} "" if not found; return the string if found. + // @private + // _valueForKey:function (key, dict) { if (dict) { var pString = dict[key]; @@ -2239,6 +2247,12 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } }, + /** + * to copy object with deep copy. + * returns a clone of action. + * + * @return {cc.ParticleSystem} + */ clone:function () { var retParticle = new cc.ParticleSystem(); @@ -2682,7 +2696,7 @@ cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); * This plist files can be create manually or with Particle Designer:
    * http://particledesigner.71squared.com/
    *

    - * @deprecated + * @deprecated since v3.0 please use new cc.ParticleSysytem(plistFile) instead. * @param {String|Number} plistFile * @return {cc.ParticleSystem} */ @@ -2691,8 +2705,14 @@ cc.ParticleSystem.create = function (plistFile) { }; /** - * @deprecated - * @type {Function} + *

    return the string found by key in dict.
    + * This plist files can be create manually or with Particle Designer:
    + * http://particledesigner.71squared.com/
    + *

    + * @deprecated since v3.0 please use new cc.ParticleSysytem(plistFile) instead. + * @function + * @param {String|Number} plistFile + * @return {cc.ParticleSystem} */ cc.ParticleSystem.createWithTotalParticles = cc.ParticleSystem.create; From c79465a4263130623fe2de5ee7b450450d6ba120 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 27 Aug 2014 15:56:34 +0800 Subject: [PATCH 0544/1564] add jsdoc comments for cc.point function --- cocos2d/core/support/CCPointExtension.js | 44 +++++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/support/CCPointExtension.js index b7fc3096f2..fb3442fa05 100644 --- a/cocos2d/core/support/CCPointExtension.js +++ b/cocos2d/core/support/CCPointExtension.js @@ -356,6 +356,11 @@ cc.pRotateByAngle = function (v, pivot, angle) { /** * A general line-line intersection test + * indicating successful intersection of a line
    + * note that to truly test intersection for segments we have to make
    + * sure that s & t lie within [0..1] and for rays, make sure s & t > 0
    + * the hit point is p3 + t * (p4 - p3);
    + * the hit point also is p1 + s * (p2 - p1); * @param {cc.Point} A A is the startpoint for the first line P1 = (p1 - p2). * @param {cc.Point} B B is the endpoint for the first line P1 = (p1 - p2). * @param {cc.Point} C C is the startpoint for the second line P2 = (p3 - p4). @@ -363,11 +368,6 @@ cc.pRotateByAngle = function (v, pivot, angle) { * @param {cc.Point} retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)),
    * retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)). * @return {Boolean} - * indicating successful intersection of a line
    - * note that to truly test intersection for segments we have to make
    - * sure that s & t lie within [0..1] and for rays, make sure s & t > 0
    - * the hit point is p3 + t * (p4 - p3);
    - * the hit point also is p1 + s * (p2 - p1); */ cc.pLineIntersect = function (A, B, C, D, retP) { if ((A.x == B.x && A.y == B.y) || (C.x == D.x && C.y == D.y)) { @@ -456,48 +456,58 @@ cc.pSameAs = function (A, B) { // High Perfomance In Place Operationrs --------------------------------------- /** - * sets the position of the point to 0 - */ + * sets the position of the point to 0 + * @param {cc.Point} v + */ cc.pZeroIn = function(v) { v.x = 0; v.y = 0; }; /** - * copies the position of one point to another - */ + * copies the position of one point to another + * @param {cc.Point} v1 + * @param {cc.Point} v2 + */ cc.pIn = function(v1, v2) { v1.x = v2.x; v1.y = v2.y; }; /** - * multiplies the point with the given factor (inplace) - */ + * multiplies the point with the given factor (inplace) + * @param {cc.Point} point + * @param {Number} floatVar + */ cc.pMultIn = function(point, floatVar) { point.x *= floatVar; point.y *= floatVar; }; /** - * subtracts one point from another (inplace) - */ + * subtracts one point from another (inplace) + * @param {cc.Point} v1 + * @param {cc.Point{ v2 + */ cc.pSubIn = function(v1, v2) { v1.x -= v2.x; v1.y -= v2.y; }; /** - * adds one point to another (inplace) - */ + * adds one point to another (inplace) + * @param {cc.Point} v1 + * @param {cc.point} v2 + */ cc.pAddIn = function(v1, v2) { v1.x += v2.x; v1.y += v2.y; }; /** - * normalizes the point (inplace) - */ + * normalizes the point (inplace) + * @param {cc.Point{ v + */ cc.pNormalizeIn = function(v) { cc.pMultIn(v, 1.0 / Math.sqrt(v.x * v.x + v.y * v.y)); }; From 761af73900cc22e1462eda84c17979404020c815 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Wed, 27 Aug 2014 16:10:17 +0800 Subject: [PATCH 0545/1564] add jsdoc for folder progress-timer --- .../progress-timer/CCActionProgressTimer.js | 51 ++++++++++++------- cocos2d/progress-timer/CCProgressTimer.js | 27 ++++++++-- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index f49d33ab95..c61634847f 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -29,6 +29,10 @@ * Progress to percentage * @class * @extends cc.ActionInterval + * @param {Number} duration duration in seconds + * @param {Number} percent + * @example + * var to = new cc.ProgressTo(2, 100); */ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ _to:0, @@ -37,10 +41,6 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ /** * Creates a ProgressTo action with a duration and a percent * Constructor of cc.ProgressTo - * @param {Number} duration duration in seconds - * @param {Number} percent - * @example - * var to = new cc.ProgressTo(2, 100); */ ctor: function(duration, percent){ cc.ActionInterval.prototype.ctor.call(this); @@ -62,19 +62,26 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ } return false; }, - + /** + * return a new cc.ProgressTo, all the configuration is the same as the original + * @returns {cc.ProgressTo} + */ clone:function(){ var action = new cc.ProgressTo(); action.initWithDuration(this._duration, this._to); return action; }, - + /** + * reverse hasn't been supported + * @returns {null} + */ reverse: function(){ cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported."); return null; }, /** + * start with a target * @param {cc.Node} target */ startWithTarget:function (target) { @@ -88,6 +95,7 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ }, /** + * custom update * @param {Number} time time in seconds */ update:function (time) { @@ -113,10 +121,13 @@ cc.progressTo = function (duration, percent) { * Please use cc.progressTo instead * Creates and initializes with a duration and a percent * @static - * @deprecated + * @deprecated since v3.0,please use cc.progressTo instead. * @param {Number} duration duration in seconds * @param {Number} percent * @return {cc.ProgressTo} + * @example + * //example + * var progress = cc.ProgressTo.create(duration,percent); */ cc.ProgressTo.create = cc.progressTo; @@ -124,6 +135,11 @@ cc.ProgressTo.create = cc.progressTo; * Progress from a percentage to another percentage * @class * @extends cc.ActionInterval + * @param {Number} duration duration in seconds + * @param {Number} fromPercentage + * @param {Number} toPercentage + * @example + * var fromTo = new cc.ProgressFromTo(2, 100.0, 0.0); */ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ _to:0, @@ -132,11 +148,6 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ /** * Creates and initializes the action with a duration, a "from" percentage and a "to" percentage * Constructor of cc.ProgressFromTo - * @param {Number} duration duration in seconds - * @param {Number} fromPercentage - * @param {Number} toPercentage - * @example - * var fromTo = new cc.ProgressFromTo(2, 100.0, 0.0); */ ctor:function(duration, fromPercentage, toPercentage){ cc.ActionInterval.prototype.ctor.call(this); @@ -160,7 +171,10 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ } return false; }, - + /** + * return a new cc.ProgressTo, all the configuration is the same as the original + * @returns {cc.ProgressFromTo} + */ clone:function(){ var action = new cc.ProgressFromTo(); action.initWithDuration(this._duration, this._from, this._to); @@ -171,10 +185,11 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ * @return {cc.ActionInterval} */ reverse:function () { - return cc.ProgressFromTo.create(this._duration, this._to, this._from); + return cc.progressFromTo(this._duration, this._to, this._from); }, /** + * start with a target * @param {cc.Node} target */ startWithTarget:function (target) { @@ -198,19 +213,21 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ * @return {cc.ProgressFromTo} * @example * // example - * var fromTO = cc.progressFromTo(2, 100.0, 0.0); + * var fromTo = cc.progressFromTo(2, 100.0, 0.0); */ cc.progressFromTo = function (duration, fromPercentage, toPercentage) { return new cc.ProgressFromTo(duration, fromPercentage, toPercentage); }; /** - * Please use cc.progressFromTo instead * Creates and initializes the action with a duration, a "from" percentage and a "to" percentage * @static - * @deprecated + * @deprecated since v3.0,please use cc.ProgressFromTo(duration, fromPercentage, toPercentage) instead. * @param {Number} duration duration in seconds * @param {Number} fromPercentage * @param {Number} toPercentage * @return {cc.ProgressFromTo} + * @example + * //example + * var progress = cc.ProgressFromTo.create(duration, fromPercentage, toPercentage); */ cc.ProgressFromTo.create = cc.progressFromTo; diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 8e6d147c46..dcf6fdfba6 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -45,6 +45,7 @@ * @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. + * */ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ _type:null, @@ -131,14 +132,23 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._updateProgress(); } }, - + /** + * only use for jsbinding + * @param bValue + */ setOpacityModifyRGB:function (bValue) { }, - + /** + * only use for jsbinding + * @returns {boolean} + */ isOpacityModifyRGB:function () { return false; }, - + /** + * return if reverse direction + * @returns {boolean} + */ isReverseDirection:function () { return this._reverseDirection; }, @@ -167,6 +177,11 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ _vertexWebGLBuffer:null, _vertexDataDirty:false, + /** + * constructor of cc.cc.ProgressTimer + * @function + * @param {cc.Sprite} sprite + */ ctor: null, _ctorForCanvas: function (sprite) { @@ -219,7 +234,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ }, /** - * Opacity + * set opacity of sprite * @param {Number} opacity */ setOpacity:function (opacity) { @@ -244,6 +259,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ }, /** + * set reverse cc.ProgressTimer * @function * @param {Boolean} reverse */ @@ -266,6 +282,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ }, /** + * set sprite for cc.ProgressTimer * @function * @param {cc.Sprite} sprite */ @@ -933,7 +950,7 @@ cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDire /** * create a progress timer object with image file name that renders the inner sprite according to the percentage - * @deprecated + * @deprecated since v3.0,please use new cc.ProgressTimer(sprite) instead. * @param {cc.Sprite} sprite * @return {cc.ProgressTimer} * @example From cf971c9952a401ce55ee12b3990effb2e6de15a2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 16:15:55 +0800 Subject: [PATCH 0546/1564] Issue #5829: shape-nodes jsdoc --- cocos2d/shape-nodes/CCDrawNode.js | 101 +++++++----------------------- 1 file changed, 22 insertions(+), 79 deletions(-) diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 474f386783..f41987c4da 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -95,9 +95,11 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ _drawColor: null, _className:"DrawNodeCanvas", - /** - * Constructor of cc.DrawNode for Canvas - */ + /** + *

    The cc.DrawNodeCanvas's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.DrawNodeCanvas()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    + */ ctor: function () { cc.Node.prototype.ctor.call(this); this._buffer = []; @@ -108,10 +110,19 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ }, // ----common function start ---- + /** + * Gets the blend func + * @returns {Object} + */ getBlendFunc: function () { return this._blendFunc; }, + /** + * Set the blend func + * @param blendFunc + * @param dst + */ setBlendFunc: function (blendFunc, dst) { if (dst === undefined) { this._blendFunc.src = blendFunc.src; @@ -164,7 +175,7 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ * draws a rectangle given the origin and destination point measured in points. * @param {cc.Point} origin * @param {cc.Point} destination - * @param {cc.Color} fillColor + * @param {cc.Color} fillColor * @param {Number} lineWidth * @param {cc.Color} lineColor */ @@ -362,7 +373,7 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ }, /** - * draw a dot at a position, with a given radius and color + * draw a dot at a position, with a given radius and color * @param {cc.Point} pos * @param {Number} radius * @param {cc.Color} color @@ -457,6 +468,10 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ return this.drawPoly_(vertsCopy, fillColor, lineWidth, color); }, + /** + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context + */ draw: function (ctx) { var context = ctx || cc._renderContext, _t = this; if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) @@ -557,6 +572,7 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ } }); +//Just only a note cc.DrawNodeWebGL = cc.Node.extend({ _bufferCapacity:0, _buffer:null, @@ -608,26 +624,14 @@ cc.DrawNodeWebGL = cc.Node.extend({ return false; }, - /** - * line width setter - * @param {Number} width - */ setLineWidth: function (width) { this._lineWidth = width; }, - /** - * line width getter - * @returns {Number} - */ getLineWidth: function () { return this._lineWidth; }, - /** - * draw color setter - * @param {cc.Color} color - */ setDrawColor: function (color) { var locDrawColor = this._drawColor; locDrawColor.r = color.r; @@ -636,22 +640,10 @@ cc.DrawNodeWebGL = cc.Node.extend({ locDrawColor.a = color.a; }, - /** - * draw color getter - * @returns {cc.Color} - */ getDrawColor: function () { return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a); }, - /** - * draws a rectangle given the origin and destination point measured in points. - * @param {cc.Point} origin - * @param {cc.Point} destination - * @param {cc.Color} fillColor - * @param {Number} lineWidth - * @param {cc.Color} lineColor - */ drawRect: function (origin, destination, fillColor, lineWidth, lineColor) { lineWidth = lineWidth || this._lineWidth; lineColor = lineColor || this.getDrawColor(); @@ -664,17 +656,6 @@ cc.DrawNodeWebGL = cc.Node.extend({ this.drawPoly(vertices, fillColor, lineWidth, lineColor); }, - /** - * draws a circle given the center, radius and number of segments. - * @override - * @param {cc.Point} center center of circle - * @param {Number} radius - * @param {Number} angle angle in radians - * @param {Number} segments - * @param {Boolean} drawLineToCenter - * @param {Number} lineWidth - * @param {cc.Color} color - */ drawCircle: function (center, radius, angle, segments, drawLineToCenter, lineWidth, color) { lineWidth = lineWidth || this._lineWidth; color = color || this.getDrawColor(); @@ -695,16 +676,6 @@ cc.DrawNodeWebGL = cc.Node.extend({ this.drawSegment(vertices[i], vertices[i + 1], lineWidth, color); }, - /** - * draws a quad bezier path - * @override - * @param {cc.Point} origin - * @param {cc.Point} control - * @param {cc.Point} destination - * @param {Number} segments - * @param {Number} lineWidth - * @param {cc.Color} color - */ drawQuadBezier: function (origin, control, destination, segments, lineWidth, color) { lineWidth = lineWidth || this._lineWidth; color = color || this.getDrawColor(); @@ -721,17 +692,6 @@ cc.DrawNodeWebGL = cc.Node.extend({ this._drawSegments(vertices, lineWidth, color, false); }, - /** - * draws a cubic bezier path - * @override - * @param {cc.Point} origin - * @param {cc.Point} control1 - * @param {cc.Point} control2 - * @param {cc.Point} destination - * @param {Number} segments - * @param {Number} lineWidth - * @param {cc.Color} color - */ drawCubicBezier: function (origin, control1, control2, destination, segments, lineWidth, color) { lineWidth = lineWidth || this._lineWidth; color = color || this.getDrawColor(); @@ -748,27 +708,10 @@ cc.DrawNodeWebGL = cc.Node.extend({ this._drawSegments(vertices, lineWidth, color, false); }, - /** - * draw a CatmullRom curve - * @override - * @param {Array} points - * @param {Number} segments - * @param {Number} lineWidth - * @param {cc.Color} color - */ drawCatmullRom: function (points, segments, lineWidth, color) { this.drawCardinalSpline(points, 0.5, segments, lineWidth, color); }, - /** - * draw a cardinal spline path - * @override - * @param {Array} config - * @param {Number} tension - * @param {Number} segments - * @param {Number} lineWidth - * @param {cc.Color} color - */ drawCardinalSpline: function (config, tension, segments, lineWidth, color) { lineWidth = lineWidth || this._lineWidth; color = color || this.getDrawColor(); @@ -1066,7 +1009,7 @@ cc.DrawNode = cc._renderType == cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.Dr /** * Creates a DrawNode - * @deprecated + * @deprecated since v3.0 please use new cc.DrawNode() instead. * @return {cc.DrawNode} */ cc.DrawNode.create = function () { From 78d1a4ff1628357d116eda3d528a4a3949f9c2fe Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Wed, 27 Aug 2014 16:25:21 +0800 Subject: [PATCH 0547/1564] add jsdoc for folder progress-timer --- cocos2d/progress-timer/CCActionProgressTimer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index c61634847f..db5198b5d2 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -41,6 +41,8 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ /** * Creates a ProgressTo action with a duration and a percent * Constructor of cc.ProgressTo + * @param {Number} duration duration in seconds + * @param {Number} percent */ ctor: function(duration, percent){ cc.ActionInterval.prototype.ctor.call(this); @@ -148,6 +150,9 @@ cc.ProgressFromTo = cc.ActionInterval.extend(/** @lends cc.ProgressFromTo# */{ /** * Creates and initializes the action with a duration, a "from" percentage and a "to" percentage * Constructor of cc.ProgressFromTo + * @param {Number} duration duration in seconds + * @param {Number} fromPercentage + * @param {Number} toPercentage */ ctor:function(duration, fromPercentage, toPercentage){ cc.ActionInterval.prototype.ctor.call(this); From b7e09ca25fc5be4fd38628fc67639a965968caab Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 17:03:51 +0800 Subject: [PATCH 0548/1564] Issue #5829: RenderTexture jsdoc --- cocos2d/render-texture/CCRenderTexture.js | 82 ++++++++++++++++------- 1 file changed, 57 insertions(+), 25 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 5dac392e3d..cfcfdb4cca 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -70,29 +70,30 @@ cc.NextPOT = function (x) { * @extends cc.Node * * @property {cc.Sprite} sprite - The sprite. + * @property {cc.Sprite} clearFlags - Code for "auto" update. * @property {Number} clearDepthVal - Clear depth value. + * @property {Boolean} autoDraw - Indicate auto draw mode activate or not. * @property {Number} clearStencilVal - Clear stencil value. * @property {cc.Color} clearColorVal - Clear color value, valid only when "autoDraw" is true. - * @property {Boolean} autoDraw - Indicate auto draw mode activate or not. */ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ sprite:null, - /** - *

    Code for "auto" update
    - * Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT.
    - * They can be OR'ed. Valid when "autoDraw is YES.

    - * @public - */ + // + //

    Code for "auto" update
    + // Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT.
    + // They can be OR'ed. Valid when "autoDraw is YES.

    + // @public + // clearFlags:0, clearDepthVal:0, autoDraw:false, - /** - * the off-screen canvas for rendering and storing the texture - * @type HTMLCanvasElement - */ + // + // the off-screen canvas for rendering and storing the texture + // @type HTMLCanvasElement + // _cacheCanvas:null, /** * stores a reference to the canvas context object @@ -115,8 +116,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ _clearColorStr:null, _className:"RenderTexture", - ctor: null, - /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid * Constructor of cc.RenderTexture for Canvas @@ -127,7 +126,10 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @example * // Example * var rt = new cc.RenderTexture(width, height, format, depthStencilFormat) + * @function */ + ctor: null, + _ctorForCanvas: function (width, height, format, depthStencilFormat) { cc.Node.prototype.ctor.call(this); this._cascadeColorEnabled = true; @@ -147,17 +149,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ } }, - /** - * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid - * Constructor of cc.RenderTexture for WebGL - * @param {Number} width - * @param {Number} height - * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format - * @param {Number} depthStencilFormat - * @example - * // Example - * var rt = new cc.RenderTexture(width, height, format, depthStencilFormat) - */ _ctorForWebGL: function (width, height, format, depthStencilFormat) { cc.Node.prototype.ctor.call(this); this._cascadeColorEnabled = true; @@ -171,6 +162,10 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ } }, + /** + * Clear RenderTexture. + * @function + */ cleanup:null, _cleanupForCanvas:function () { @@ -195,7 +190,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, /** - * The sprite + * Gets the sprite * @return {cc.Sprite} */ getSprite:function () { @@ -203,6 +198,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, /** + * Set the sprite * @param {cc.Sprite} sprite */ setSprite:function (sprite) { @@ -210,6 +206,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, /** + * Initializes the instance of cc.RenderTexture * @function * @param {Number} width * @param {Number} height @@ -525,6 +522,14 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ this.end(); }, + /** + * clears the texture with rect. + * @function + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + */ clearRect:null, _clearRectForCanvas:function(x, y, width, height){ @@ -584,6 +589,11 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ gl.clearStencil(stencilClearValue); }, + /** + * Recursive method that visit its children and draw them + * @function + * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx + */ visit:null, _visitForCanvas:function (ctx) { @@ -630,6 +640,11 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ this.arrivalOrder = 0; }, + /** + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function + * @function + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context + */ draw:null, _drawForCanvas: function (ctx) { @@ -765,6 +780,10 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ return this.clearFlags; }, + /** + * Set the clearFlags + * @param {Number} clearFlags + */ setClearFlags:function (clearFlags) { this.clearFlags = clearFlags; }, @@ -811,6 +830,10 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ return this.clearDepthVal; }, + /** + * Set value for clearDepth. Valid only when autoDraw is true. + * @param {Number} clearDepth + */ setClearDepth:function (clearDepth) { this.clearDepthVal = clearDepth; }, @@ -823,6 +846,10 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ return this.clearStencilVal; }, + /** + * Set value for clear Stencil. Valid only when autoDraw is true + * @return {Number} + */ setClearStencil:function (clearStencil) { this.clearStencilVal = clearStencil; }, @@ -836,6 +863,11 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ return this.autoDraw; }, + /** + * When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons.
    + * Will be enabled in the future. + * @return {Boolean} + */ setAutoDraw:function (autoDraw) { this.autoDraw = autoDraw; } From db9f829ddb5495c8be5cb4dcbae3288d46b7c0e9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 17:06:40 +0800 Subject: [PATCH 0549/1564] Issue #5829: RenderTexture jsdoc --- cocos2d/render-texture/CCRenderTexture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index cfcfdb4cca..c795ea089c 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -911,7 +911,7 @@ cc.defineGetterSetter(_p, "clearColorVal", _p.getClearColor, _p.setClearColor); /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid - * @deprecated + * @deprecated since v3.0 please use new cc.RenderTexture() instead. * @param {Number} width * @param {Number} height * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format From e337789761ee84911c4074a2ba989754ad83394f Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 27 Aug 2014 17:07:52 +0800 Subject: [PATCH 0550/1564] add jsdoc comments for textures --- cocos2d/core/textures/CCTexture2D.js | 55 ++++++++++++++++++++++++ cocos2d/core/textures/CCTextureAtlas.js | 11 +++-- cocos2d/core/textures/TexturesWebGL.js | 57 +++++++++++++++++++++++-- 3 files changed, 117 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 4eb3dd82c9..f111b2db26 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -129,20 +129,35 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { url: null, + /** + * constructor of cc.Texture2D + */ ctor: function () { this._contentSize = cc.size(0, 0); this._isLoaded = false; this._htmlElementObj = null; }, + /** + * get width in pixels + * @return {Number} + */ getPixelsWide: function () { return this._contentSize.width; }, + /** + * get height of in pixels + * @return {Number} + */ getPixelsHigh: function () { return this._contentSize.height; }, + /** + * get content size + * @returns {cc.Size} + */ getContentSize: function () { var locScaleFactor = cc.contentScaleFactor(); return cc.size(this._contentSize.width / locScaleFactor, this._contentSize.height / locScaleFactor); @@ -155,10 +170,18 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return this._contentSize.height / cc.contentScaleFactor(); }, + /** + * get content size in pixels + * @returns {cc.Size} + */ getContentSizeInPixels: function () { return this._contentSize; }, + /** + * init with HTML element + * @param {HTMLImageElement|HTMLCanvasElement} element + */ initWithElement: function (element) { if (!element) return; @@ -173,10 +196,17 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return this._htmlElementObj; }, + /** + * check whether texture is loaded + * @returns {boolean} + */ isLoaded: function () { return this._isLoaded; }, + /** + * handle loaded texture + */ handleLoadedTexture: function () { var self = this if (self._isLoaded) return; @@ -194,6 +224,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { self._callLoadedEventCallbacks(); }, + /** + * description of cc.Texture2D + * @returns {string} + */ description: function () { return ""; }, @@ -281,16 +315,28 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //support only in WebGl rendering mode }, + /** + * init with ETC file + * @warning does not support on HTML5 + */ initWithETCFile: function (file) { cc.log(cc._LogInfos.Texture2D_initWithETCFile); return false; }, + /** + * init with PVR file + * @warning does not support on HTML5 + */ initWithPVRFile: function (file) { cc.log(cc._LogInfos.Texture2D_initWithPVRFile); return false; }, + /** + * init with PVRTC data + * @warning does not support on HTML5 + */ initWithPVRTCData: function (data, level, bpp, hasAlpha, length, pixelFormat) { cc.log(cc._LogInfos.Texture2D_initWithPVRTCData); return false; @@ -322,12 +368,21 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return -1; }, + /** + * add listener for loaded event + * @param {Function} callback + * @param {cc.Node} target + */ addLoadedEventListener: function (callback, target) { if (!this._loadedEventListeners) this._loadedEventListeners = []; this._loadedEventListeners.push({eventCallback: callback, eventTarget: target}); }, + /** + * remove listner for loaded event + * @param {cc.Node} target + */ removeLoadedEventListener: function (target) { if (!this._loadedEventListeners) return; diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index 4568cc2596..79d7e71f53 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -422,6 +422,11 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ this.dirty = true; }, + /** + * Removes a given number of quads at a given index + * @param {Number} index + * @param {Number} amount + */ removeQuadsAtIndex: function (index, amount) { cc.assert(index + amount <= this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadsAtIndex); @@ -631,7 +636,7 @@ cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads); /** *

    Creates a TextureAtlas with an filename and with an initial capacity for Quads.
    * The TextureAtlas capacity can be increased in runtime.

    - * @deprecated + * @deprecated since v3.0, please use new cc.TextureAtlas(fileName, capacity) instead * @param {String|cc.Texture2D} fileName * @param {Number} capacity * @return {cc.TextureAtlas|Null} @@ -649,8 +654,8 @@ cc.TextureAtlas.create = function (fileName, capacity) { }; /** - * @deprecated - * @type {Function} + * @deprecated since v3.0, please use new cc.TextureAtlas(texture) instead + * @function */ cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create; diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 90042f6907..7529f7e53b 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -71,12 +71,17 @@ cc._tmp.WebGLTexture2D = function () { url: null, _loadedEventListeners: null, - /*public:*/ + /** + * constructor of cc.Texture2D + */ ctor: function () { this._contentSize = cc.size(0, 0); this._pixelFormat = cc.Texture2D.defaultPixelFormat; }, + /** + * release texture + */ releaseTexture: function () { if (this._webTextureObj) cc._renderContext.deleteTexture(this._webTextureObj); @@ -130,24 +135,42 @@ cc._tmp.WebGLTexture2D = function () { return this._contentSize.height / cc.contentScaleFactor(); }, + /** + * get content size in pixels + * @return {cc.Size} + */ getContentSizeInPixels: function () { return this._contentSize; }, - /** texture max S */ + /** + * texture max S + * @return {Number} + */ getMaxS: function () { return this.maxS; }, + /** + * set texture max S + * @param {Number} maxS + */ setMaxS: function (maxS) { this.maxS = maxS; }, - /** texture max T */ + /** + * get texture max T + * @return {Number} + */ getMaxT: function () { return this.maxT; }, + /** + * set texture max T + * @param {Number} maxT + */ setMaxT: function (maxT) { this.maxT = maxT; }, @@ -176,10 +199,18 @@ cc._tmp.WebGLTexture2D = function () { return this._hasPremultipliedAlpha; }, + /** + * whether or not use mipmap + * @returns {Boolean} + */ hasMipmaps: function () { return this._hasMipmaps; }, + /** + * description + * @returns {string} + */ description: function () { var _t = this; return " Date: Wed, 27 Aug 2014 17:10:42 +0800 Subject: [PATCH 0551/1564] fix bug --- cocos2d/core/textures/TexturesWebGL.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 7529f7e53b..dd099d8dc3 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -201,7 +201,7 @@ cc._tmp.WebGLTexture2D = function () { /** * whether or not use mipmap - * @returns {Boolean} + * @return {Boolean} */ hasMipmaps: function () { return this._hasMipmaps; @@ -209,7 +209,7 @@ cc._tmp.WebGLTexture2D = function () { /** * description - * @returns {string} + * @return {string} */ description: function () { var _t = this; @@ -434,7 +434,7 @@ cc._tmp.WebGLTexture2D = function () { /** * whether texture is loaded - * @returns {Boolean} + * @return {Boolean} */ isLoaded: function () { return this._isLoaded; From 762cf4097887b446338a9c576f84fe22066616a9 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 27 Aug 2014 18:07:57 +0800 Subject: [PATCH 0552/1564] issue #5865: deprecate create function of cc.PhysicsDebugNode --- cocos2d/physics/CCPhysicsDebugNode.js | 58 +++++++++++++++------------ 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/cocos2d/physics/CCPhysicsDebugNode.js b/cocos2d/physics/CCPhysicsDebugNode.js index 44e6e70ede..b1fbc77675 100644 --- a/cocos2d/physics/CCPhysicsDebugNode.js +++ b/cocos2d/physics/CCPhysicsDebugNode.js @@ -125,19 +125,39 @@ cc.CONSTRAINT_COLOR = cc.color(0, 255, 0, 128); * @property {cp.Space} space Physic world space */ cc.PhysicsDebugNode = cc.DrawNode.extend({ - space:null, - - _spaceObj:null, + _space:null, _className:"PhysicsDebugNode", + /** + * constructor of cc.PhysicsDebugNode + * @param {cp.Space} space + */ + ctor: function () { + cc.DrawNode.prototype.ctor.call(this); + if(this.init()) + this._space = space; + }, + + /** + * get space + * @returns {cp.Space} + */ getSpace:function () { - return this.space; + return this._space; }, + /** + * set space + * @param {cp.Space} space + */ setSpace:function (space) { - this.space = space; + this._space = space; }, + /** + * draw + * @param {object} context + */ draw:function (context) { if (!this.space) return; @@ -149,26 +169,14 @@ cc.PhysicsDebugNode = cc.DrawNode.extend({ } }); -/** Create a debug node for an Objective-Chipmunk space. */ -cc.PhysicsDebugNode.debugNodeForChipmunkSpace = function (space) { - var node = new cc.PhysicsDebugNode(); - if (node.init()) { - node._spaceObj = space; - node.space = space.space; - return node; - } - return null; -}; - -/** Create a debug node for a regular Chipmunk space. */ -cc.PhysicsDebugNode.debugNodeForCPSpace = function (space) { - var node = new cc.PhysicsDebugNode(); - if (node.init()) { - node.space = space; - return node; - } - return null; +/** + * Create a debug node for a regular Chipmunk space. + * @deprecated since v3.0, please use new cc.PhysicsDebugNode(space) + * @param {cp.Space} space + * @return {cc.PhysicsDebugNode} + */ +cc.PhysicsDebugNode.create = function (space) { + return new cc.PhysicsDebugNode(space); }; -cc.PhysicsDebugNode.create = cc.PhysicsDebugNode.debugNodeForCPSpace; From 65cbb633e350e18c3ba594cd57b3cc673ce4abb3 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 27 Aug 2014 18:19:19 +0800 Subject: [PATCH 0553/1564] issue #5865: fix bugs of _space --- cocos2d/physics/CCPhysicsDebugNode.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cocos2d/physics/CCPhysicsDebugNode.js b/cocos2d/physics/CCPhysicsDebugNode.js index b1fbc77675..155a8219f9 100644 --- a/cocos2d/physics/CCPhysicsDebugNode.js +++ b/cocos2d/physics/CCPhysicsDebugNode.js @@ -113,6 +113,7 @@ cc.DrawConstraint = function (constraint, renderer) { cc.CONSTRAINT_COLOR = cc.color(0, 255, 0, 128); + /** *

    A Node that draws the components of a physics engine.
    * Supported physics engines:
    @@ -125,17 +126,16 @@ cc.CONSTRAINT_COLOR = cc.color(0, 255, 0, 128); * @property {cp.Space} space Physic world space */ cc.PhysicsDebugNode = cc.DrawNode.extend({ - _space:null, + _space:null, _className:"PhysicsDebugNode", /** * constructor of cc.PhysicsDebugNode * @param {cp.Space} space */ - ctor: function () { + ctor: function (space) { cc.DrawNode.prototype.ctor.call(this); - if(this.init()) - this._space = space; + this._space = space; }, /** @@ -159,11 +159,11 @@ cc.PhysicsDebugNode = cc.DrawNode.extend({ * @param {object} context */ draw:function (context) { - if (!this.space) + if (!this._space) return; - this.space.eachShape(cc.DrawShape.bind(this)); - this.space.eachConstraint(cc.DrawConstraint.bind(this)); + this._space.eachShape(cc.DrawShape.bind(this)); + this._space.eachConstraint(cc.DrawConstraint.bind(this)); cc.DrawNode.prototype.draw.call(this); this.clear(); } @@ -178,5 +178,3 @@ cc.PhysicsDebugNode = cc.DrawNode.extend({ cc.PhysicsDebugNode.create = function (space) { return new cc.PhysicsDebugNode(space); }; - - From e2654cca2b652eb3311fc571c398dd3f802cae74 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 18:24:00 +0800 Subject: [PATCH 0554/1564] Issue #5829: tilemap jsdoc --- cocos2d/tilemap/CCTGAlib.js | 36 ++++++++++++++++++++++++++--- cocos2d/tilemap/CCTMXLayer.js | 14 ++++++++++- cocos2d/tilemap/CCTMXObjectGroup.js | 11 +++++++++ cocos2d/tilemap/CCTileMapAtlas.js | 4 ++-- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/cocos2d/tilemap/CCTGAlib.js b/cocos2d/tilemap/CCTGAlib.js index e0114586b9..3bca0832f7 100644 --- a/cocos2d/tilemap/CCTGAlib.js +++ b/cocos2d/tilemap/CCTGAlib.js @@ -82,7 +82,7 @@ cc.ImageTGA = function (status, type, pixelDepth, width, height, imageData, flip }; /** - * load the image header field from stream. We only keep those that matter! + * load the image header field from stream. We only keep those that matter! * @param {Array} buffer * @param {Number} bufSize * @param {cc.ImageTGA} psInfo @@ -118,7 +118,7 @@ cc.tgaLoadHeader = function (buffer, bufSize, psInfo) { }; /** - * loads the image pixels. You shouldn't call this function directly + * loads the image pixels. You shouldn't call this function directly. * @param {Array} buffer * @param {Number} bufSize * @param {cc.ImageTGA} psInfo @@ -192,6 +192,13 @@ cc.tgaDestroy = function (psInfo) { psInfo = null; }; +/** + * Load RLE image data + * @param buffer + * @param bufSize + * @param psInfo + * @returns {boolean} + */ cc.tgaLoadRLEImageData = function (buffer, bufSize, psInfo) { var mode, total, i, index = 0 , skip = 0, flag = 0; var aux = [], runlength = 0; @@ -250,6 +257,10 @@ cc.tgaLoadRLEImageData = function (buffer, bufSize, psInfo) { return true; }; +/** + * ImageTGA Flip + * @param {cc.ImageTGA} psInfo + */ cc.tgaFlipImage = function (psInfo) { // mode equal the number of components for each pixel var mode = psInfo.pixelDepth / 8; @@ -275,20 +286,39 @@ cc.__setDataToArray = function (sourceData, destArray, startIndex) { destArray[startIndex + i] = sourceData[i]; }; - +/** + * Binary Stream Reader + * + * @class + * @param binaryData + */ cc.BinaryStreamReader = cc.Class.extend({ _binaryData:null, _offset:0, + /** + *

    The cc.BinaryStreamReader's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.BinaryStreamReader()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    + * @param binaryData + */ ctor:function (binaryData) { this._binaryData = binaryData; }, + /** + * Set the binaryData. + * @param binaryData + */ setBinaryData:function (binaryData) { this._binaryData = binaryData; this._offset = 0; }, + /** + * Gets the binaryData. + * @returns {Object} + */ getBinaryData:function () { return this._binaryData; }, diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 95c4e173e3..06142faa29 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -179,6 +179,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ /** * Return texture of cc.SpriteBatchNode + * @function * @return {cc.Texture2D} */ getTexture: null, @@ -189,6 +190,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ /** * don't call visit on it's children ( override visit of cc.Node ) + * @function * @override * @param {CanvasRenderingContext2D} ctx */ @@ -240,6 +242,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ /** * draw cc.SpriteBatchNode (override draw of cc.Node) + * @function * @param {CanvasRenderingContext2D} ctx */ draw:null, @@ -277,6 +280,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Gets layer size. * @return {cc.Size} */ getLayerSize:function () { @@ -284,6 +288,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Set layer size * @param {cc.Size} Var */ setLayerSize:function (Var) { @@ -313,6 +318,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Set the map tile size. * @param {cc.Size} Var */ setMapTileSize:function (Var) { @@ -342,6 +348,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Pointer to the map of tiles * @param {Array} Var */ setTiles:function (Var) { @@ -357,6 +364,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Tile set information for the layer * @param {cc.TMXTilesetInfo} Var */ setTileset:function (Var) { @@ -372,6 +380,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Layer orientation, which is the same as the map orientation * @param {Number} Var */ setLayerOrientation:function (Var) { @@ -387,6 +396,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * properties from the layer. They can be added using Tiled * @param {Array} Var */ setProperties:function (Var) { @@ -790,6 +800,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Gets the layer name * @return {String} */ getLayerName:function () { @@ -797,6 +808,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, /** + * Set the layer name * @param {String} layerName */ setLayerName:function (layerName) { @@ -1091,7 +1103,7 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); /** * Creates a cc.TMXLayer with an tile set info, a layer info and a map info - * @deprecated + * @deprecated since v3.0 please use new cc.TMXLayer(tilesetInfo, layerInfo, mapInfo) instead. * @param {cc.TMXTilesetInfo} tilesetInfo * @param {cc.TMXLayerInfo} layerInfo * @param {cc.TMXMapInfo} mapInfo diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js index 55fe09e324..ddeb400080 100644 --- a/cocos2d/tilemap/CCTMXObjectGroup.js +++ b/cocos2d/tilemap/CCTMXObjectGroup.js @@ -39,6 +39,11 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ _positionOffset: null, _objects: null, + /** + *

    The cc.TMXObjectGroup's constructor.
    + * This function will automatically be invoked when you create a node using new construction: "var node = new cc.TMXObjectGroup()".
    + * Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.

    + */ ctor:function () { this.groupName = ""; this._positionOffset = cc.p(0,0); @@ -55,6 +60,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ }, /** + * Offset position of child objects * @param {cc.Point} offset */ setPositionOffset:function (offset) { @@ -71,6 +77,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ }, /** + * List of properties stored in a dictionary * @param {object} Var */ setProperties:function (Var) { @@ -78,6 +85,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ }, /** + * Gets the Group name. * @return {String} */ getGroupName:function () { @@ -85,6 +93,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ }, /** + * Set the Group name * @param {String} groupName */ setGroupName:function (groupName) { @@ -120,6 +129,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ }, /** + * Gets the objects. * @return {Array} */ getObjects:function () { @@ -127,6 +137,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ }, /** + * Set the objects. * @param {object} objects */ setObjects:function (objects) { diff --git a/cocos2d/tilemap/CCTileMapAtlas.js b/cocos2d/tilemap/CCTileMapAtlas.js index e01b2d78a6..40d4f562e1 100644 --- a/cocos2d/tilemap/CCTileMapAtlas.js +++ b/cocos2d/tilemap/CCTileMapAtlas.js @@ -292,12 +292,12 @@ cc.TileMapAtlas = cc.AtlasNode.extend(/** @lends cc.TileMapAtlas# */{ /** *

    Creates a cc.TileMap with a tile file (atlas) with a map file and the width and height of each tile in points.
    * The tile file will be loaded using the TextureMgr.

    - * @deprecated + * @deprecated since v3.0 please use new cc.TileMapAtlas(tile, mapFile, tileWidth, tileHeight) instead. * @param {String} tile * @param {String} mapFile * @param {Number} tileWidth * @param {Number} tileHeight - * @return {Boolean|Null} + * @return {cc.TileMapAtlas} * @example * //example * var tmpAtlas = new cc.TileMapAtlas(); From 037aa48f4b38a9b1d1c101e22c71d0ea09fc0d13 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 27 Aug 2014 20:43:54 +0800 Subject: [PATCH 0555/1564] Closed #5694: correct the mistake of cc.loader in IE9,10. --- CCBoot.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index c9a7b55259..2a84449e73 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -574,12 +574,14 @@ cc.loader = { // IE-specific logic here xhr.setRequestHeader("Accept-Charset", "utf-8"); xhr.onreadystatechange = function () { - xhr.readyState == 4 && xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo); + if(xhr.readyState == 4) + xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo); }; } else { if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8"); xhr.onload = function () { - xhr.readyState == 4 && xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo); + if(xhr.readyState == 4) + xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo); }; } xhr.send(null); From 5cb75bdd658e658e8d885ee19169e40f7e151e9c Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Wed, 27 Aug 2014 20:45:09 +0800 Subject: [PATCH 0556/1564] add jsdoc for action manager cccamera ccpool --- cocos2d/core/CCActionManager.js | 4 ++++ cocos2d/core/CCCamera.js | 14 ++++++++------ extensions/ccpool/CCPool.js | 10 +++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index 3c36858180..a1b367faaf 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -27,6 +27,8 @@ /** * @class * @extends cc.Class + * @example + * var element = new cc.HashElement(); */ cc.HashElement = cc.Class.extend(/** @lends cc.HashElement# */{ actions:null, @@ -60,6 +62,8 @@ cc.HashElement = cc.Class.extend(/** @lends cc.HashElement# */{ * - When you want to pause / resume the actions
    * @class * @extends cc.Class + * @example + * var mng = new cc.ActionManager(); */ cc.ActionManager = cc.Class.extend({ _hashTargets:null, diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js index a5ab2e4dc6..5a62d4428c 100644 --- a/cocos2d/core/CCCamera.js +++ b/cocos2d/core/CCCamera.js @@ -58,7 +58,9 @@ cc.Camera = cc.Class.extend({ _dirty:null, _lookupMatrix:null, - + /** + * constructor of cc.Camera + */ ctor:function () { this._lookupMatrix = new cc.kmMat4(); this.restore(); @@ -129,7 +131,7 @@ cc.Camera = cc.Class.extend({ * @param {Number} eyeX * @param {Number} eyeY * @param {Number} eyeZ - * @deprecated This function will be deprecated sooner or later. + * @deprecated This function will be deprecated sooner or later please use setEye instead. */ setEyeXYZ:function (eyeX, eyeY, eyeZ) { this.setEye(eyeX,eyeY,eyeZ); @@ -154,7 +156,7 @@ cc.Camera = cc.Class.extend({ * @param {Number} centerX * @param {Number} centerY * @param {Number} centerZ - * @deprecated This function will be deprecated sooner or later. + * @deprecated This function will be deprecated sooner or later please use setCenter instead. */ setCenterXYZ:function (centerX, centerY, centerZ) { this.setCenter(centerX,centerY,centerZ); @@ -205,7 +207,7 @@ cc.Camera = cc.Class.extend({ * @param {Number} eyeY * @param {Number} eyeZ * @return {Object} - * @deprecated This function will be deprecated sooner or later. + * @deprecated This function will be deprecated sooner or later, please use getEye instead. */ getEyeXYZ:function (eyeX, eyeY, eyeZ) { return {x:this._eyeX , y:this._eyeY , z: this._eyeZ }; @@ -225,7 +227,7 @@ cc.Camera = cc.Class.extend({ * @param {Number} centerY * @param {Number} centerZ * @return {Object} - * @deprecated This function will be deprecated sooner or later. + * @deprecated This function will be deprecated sooner or later,please use getCenter instead. */ getCenterXYZ:function (centerX, centerY, centerZ) { return {x:this._centerX ,y:this._centerY ,z:this._centerZ }; @@ -245,7 +247,7 @@ cc.Camera = cc.Class.extend({ * @param {Number} upY * @param {Number} upZ * @return {Object} - * @deprecated This function will be deprecated sooner or later. + * @deprecated This function will be deprecated sooner or later,please use getUp instead. */ getUpXYZ:function (upX, upY, upZ) { return {x:this._upX,y:this._upY,z:this._upZ}; diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 7df87e4507..a4d2c13598 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -47,7 +47,7 @@ cc.pool = /** @lends cc.pool# */{ _pool: {}, /** - * Put the obj in pool + * Put the cc.Node object in pool * @param obj */ putInPool: function (obj) { @@ -69,7 +69,7 @@ cc.pool = /** @lends cc.pool# */{ }, /** - * Check if this kind of obj has already in pool + * Check if this kind of object has already in pool * @param objClass * @returns {boolean} if this kind of obj is already in pool return true,else return false; */ @@ -80,7 +80,7 @@ cc.pool = /** @lends cc.pool# */{ }, /** - * Remove the obj if you want to delete it; + * Remove the object if you want to delete it; * @param obj */ removeObject: function (obj) { @@ -99,7 +99,7 @@ cc.pool = /** @lends cc.pool# */{ }, /** - * Get the obj from pool + * Get the object from pool * @param args * @returns {*} call the reuse function an return the obj */ @@ -117,7 +117,7 @@ cc.pool = /** @lends cc.pool# */{ }, /** - * remove all objs in pool and reset the pool + * remove all object in pool and reset the pool */ drainAllPools: function () { var locPool = this._pool; From 9f6fadf76a5a86d4ca4abee2a2d8f0c1420a2691 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 27 Aug 2014 20:46:38 +0800 Subject: [PATCH 0557/1564] add jsdoc comments for physics --- cocos2d/physics/CCPhysicsDebugNode.js | 27 +++++- cocos2d/physics/CCPhysicsSprite.js | 117 +++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 5 deletions(-) diff --git a/cocos2d/physics/CCPhysicsDebugNode.js b/cocos2d/physics/CCPhysicsDebugNode.js index 155a8219f9..ecdbac0e58 100644 --- a/cocos2d/physics/CCPhysicsDebugNode.js +++ b/cocos2d/physics/CCPhysicsDebugNode.js @@ -34,7 +34,12 @@ as the private API may change with little or no warning. */ -// Helper. Converts an array of numbers into an array of vectors(x,y) +/** + * Converts an array of numbers into an array of vectors(x,y) + * @function + * @param {Array} verts + * @return {Array} + */ cc.__convertVerts = function (verts) { var ret = []; for (var i = 0; i < verts.length / 2; i++) { @@ -43,6 +48,12 @@ cc.__convertVerts = function (verts) { return ret; }; +/** + * color for body + * @function + * @param {cp.Body} body + * @return {cc.color} + */ cc.ColorForBody = function (body) { if (body.isRogue() || body.isSleeping()) { return cc.color(128, 128, 128, 128); @@ -53,6 +64,11 @@ cc.ColorForBody = function (body) { } }; +/** + * draw shape + * @param {cp.Shape} shape + * @param renderer + */ cc.DrawShape = function (shape, renderer) { var body = shape.body; var color = cc.ColorForBody(body); @@ -74,6 +90,11 @@ cc.DrawShape = function (shape, renderer) { } }; +/** + * draw constraint + * @param {cp.Constraint} constraint + * @param renderer + */ cc.DrawConstraint = function (constraint, renderer) { var body_a = constraint.a; var body_b = constraint.b; @@ -111,6 +132,10 @@ cc.DrawConstraint = function (constraint, renderer) { } }; +/** + * @constant + * @type {cc.color} + */ cc.CONSTRAINT_COLOR = cc.color(0, 255, 0, 128); diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 68a0370ac5..bd7238f664 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -91,32 +91,72 @@ } } }, + + /** + * set body + * @param {Box2D.Dynamics.b2Body} body + */ setBody:function (body) { this._body = body; }, + + /** + * get body + * @return {Box2D.Dynamics.b2Body} + */ getBody:function () { return this._body; }, + + /** + * set PTM ratio + * @param {Number} r + */ setPTMRatio:function (r) { this._PTMRatio = r; }, + + /** + * get PTM ration + * @return {Number} + */ getPTMRatio:function () { return this._PTMRatio; }, + + /** + * get position + * @return {cc.Point} + */ getPosition:function () { var pos = this._body.GetPosition(); var locPTMRatio =this._PTMRatio; return cc.p(pos.x * locPTMRatio, pos.y * locPTMRatio); }, + + /** + * set position + * @param {cc.Point} p + */ setPosition:function (p) { var angle = this._body.GetAngle(); var locPTMRatio =this._PTMRatio; this._body.setTransform(Box2D.b2Vec2(p.x / locPTMRatio, p.y / locPTMRatio), angle); this.setNodeDirty(); }, + + /** + * get rotation + * @return {Number} + */ getRotation:function () { return (this._ignoreBodyRotation ? cc.radiansToDegrees(this._rotationRadians) : cc.radiansToDegrees(this._body.GetAngle())); }, + + /** + * set rotation + * @param {Number} r + */ setRotation:function (r) { if (this._ignoreBodyRotation) { this._rotation = r; @@ -136,6 +176,9 @@ _syncRotation:function () { this._rotationRadians = this._body.GetAngle(); }, + /** + * visit + */ visit:function () { if (this._body && this._PTMRatio) { this._syncPosition(); @@ -147,6 +190,11 @@ } this._super(); }, + + /** + * set whether to ingore body's rotation + * @param {Boolean} b + */ setIgnoreBodyRotation: function(b) { this._ignoreBodyRotation = b; } @@ -206,25 +254,53 @@ } } }, + + /** + * set body + * @param {cp.Body} body + */ setBody:function (body) { this._body = body; }, + + /** + * get body + * @returns {cp.Body} + */ getBody:function () { return this._body; }, + + /** + * get position + * @return {cc.Point} + */ getPosition:function () { var locBody = this._body; return {x:locBody.p.x, y:locBody.p.y}; }, + /** + * get position x + * @return {Number} + */ getPositionX:function () { return this._body.p.x; }, + /** + * get position y + * @return {Number} + */ getPositionY:function () { return this._body.p.y; }, + /** + * set position + * @param {cc.Point|Number}newPosOrxValue + * @param {Number}yValue + */ setPosition:function (newPosOrxValue, yValue) { if (yValue === undefined) { this._body.p.x = newPosOrxValue.x; @@ -235,10 +311,20 @@ } //this._syncPosition(); }, + + /** + * set position x + * @param {Number} xValue + */ setPositionX:function (xValue) { this._body.p.x = xValue; //this._syncPosition(); }, + + /** + * set position y + * @param {Number} yValue + */ setPositionY:function (yValue) { this._body.p.y = yValue; //this._syncPosition(); @@ -250,9 +336,19 @@ cc.Sprite.prototype.setPosition.call(this, locBody.p.x, locBody.p.y); } }, + + /** + * get rotation + * @return {Number} + */ getRotation:function () { return this._ignoreBodyRotation ? cc.radiansToDegrees(this._rotationRadiansX) : -cc.radiansToDegrees(this._body.a); }, + + /** + * set rotation + * @param {Number} r + */ setRotation:function (r) { if (this._ignoreBodyRotation) { cc.Sprite.prototype.setRotation.call(this, r); @@ -267,11 +363,16 @@ } }, /** - * @deprecated + * @deprecated since v3.0, please use getNodeToParentTransform instead */ nodeToParentTransform: function(){ return this.getNodeToParentTransform(); }, + + /** + * get the affine transform matrix of node to parent coordinate frame + * @retur {cc.AffineTransform} + */ getNodeToParentTransform:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS) return this._nodeToParentTransformForCanvas(); @@ -349,11 +450,19 @@ return this._transform; }, + /** + * whether dirty + * @return {Boolean} + */ isDirty:function(){ return !this._body.isSleeping(); }, setDirty: function(){ }, + /** + * set whether to ignore ratation of body + * @param {Boolean} b + */ setIgnoreBodyRotation: function(b) { this._ignoreBodyRotation = b; } @@ -372,7 +481,7 @@ /** * Create a PhysicsSprite with filename and rect - * @deprecated + * @deprecated since v3.0, please use new cc.PhysicsSprite(fileName, rect) instead * @param {String|cc.Texture2D|cc.SpriteFrame} fileName * @param {cc.Rect} rect * @return {cc.PhysicsSprite} @@ -401,13 +510,13 @@ }; /** - * @deprecated + * @deprecated since v3.0, please use new cc.PhysicsSprite(spriteFrameName) instead * @type {Function} */ cc.PhysicsSprite.createWithSpriteFrameName = cc.PhysicsSprite.create; /** - * @deprecated + * @deprecated since v3.0, please use new cc.PhysicsSprite(spriteFrame) instead * @type {Function} */ cc.PhysicsSprite.createWithSpriteFrame = cc.PhysicsSprite.create; From 892d3de485423dc121dd46bfc393ae65880acccd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 20:59:43 +0800 Subject: [PATCH 0558/1564] Issue #5785: we chat change loop to setTimeout --- CCBoot.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 4ff8338af8..18ab16556a 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1571,7 +1571,10 @@ cc._setup = function (el, width, height) { clearTimeout(id); }; - if(cc.game.config[cc.game.CONFIG_KEY.frameRate] != 60){ + if(cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT){ + win.requestAnimFrame = stTime; + win.cancelAnimationFrame = ctTime; + }else if(cc.game.config[cc.game.CONFIG_KEY.frameRate] != 60){ win.requestAnimFrame = stTime; win.cancelAnimationFrame = ctTime; }else{ From 71a76a3cc0eaed107e8be9a528bacf706300ddc8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 27 Aug 2014 21:08:34 +0800 Subject: [PATCH 0559/1564] Texture2D's setTexParameters supports two types of parameters. --- cocos2d/core/textures/TexturesWebGL.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index dd099d8dc3..aec5fa2576 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -552,12 +552,18 @@ cc._tmp.WebGLTexture2D = function () { /** * sets the min filter, mag filter, wrap s and wrap t texture parameters.
    * If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. - * @param texParams + * @param {Object|Number} texParams texParams object or minFilter + * @param {Number} [magFilter] + * @param {Number} [wrapS] + * @param {Number} [wrapT] */ - setTexParameters: function (texParams) { + setTexParameters: function (texParams, magFilter, wrapS, wrapT) { var _t = this; var gl = cc._renderContext; + if(magFilter !== undefined) + texParams = {minFilter: texParams, magFilter: magFilter, wrapS: wrapS, wrapT: wrapT}; + cc.assert((_t._pixelsWide == cc.NextPOT(_t._pixelsWide) && _t._pixelsHigh == cc.NextPOT(_t._pixelsHigh)) || (texParams.wrapS == gl.CLAMP_TO_EDGE && texParams.wrapT == gl.CLAMP_TO_EDGE), "WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures"); From 78f0c93cf47f3e9c92b729650eade7b259a8f0cb Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 27 Aug 2014 21:10:14 +0800 Subject: [PATCH 0560/1564] add jsdoc comments for shaders --- cocos2d/shaders/CCGLProgram.js | 13 ++++++++++++- cocos2d/shaders/CCGLStateCache.js | 25 ++++++++++++++++++++++++- cocos2d/shaders/CCShaderCache.js | 13 ++++++++++--- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index ed6bb036d1..1aa820236f 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -122,6 +122,9 @@ cc.GLProgram = cc.Class.extend({ vShaderFileName && fShaderFileName && this.init(vShaderFileName, fShaderFileName); }, + /** + * destroy program + */ destroyProgram: function () { this._vertShader = null; this._fragShader = null; @@ -294,10 +297,18 @@ cc.GLProgram = cc.Class.extend({ return this._glContext.getUniformLocation(this._programObj, name); }, + /** + * get uniform MVP matrix + * @returns {WebGLUniformLocation} + */ getUniformMVPMatrix: function () { return this._uniforms[cc.UNIFORM_MVPMATRIX]; }, + /** + * get uniform sampler + * @returns {WebGLUniformLocation} + */ getUniformSampler: function () { return this._uniforms[cc.UNIFORM_SAMPLER]; }, @@ -671,7 +682,7 @@ cc.GLProgram = cc.Class.extend({ /** * Create a cc.GLProgram object - * @deprecated + * @deprecated since v3.0, please use new cc.GLProgram(vShaderFileName, fShaderFileName) instead * @param {String} vShaderFileName * @param {String} fShaderFileName * @returns {cc.GLProgram} diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js index b61645d64b..9fac3b5998 100644 --- a/cocos2d/shaders/CCGLStateCache.js +++ b/cocos2d/shaders/CCGLStateCache.js @@ -46,6 +46,7 @@ if (cc.ENABLE_GL_STATE_CACHE) { /** * Invalidates the GL state cache.
    * If CC_ENABLE_GL_STATE_CACHE it will reset the GL state cache. + * @function */ cc.glInvalidateStateCache = function () { cc.kmGLFreeAll(); @@ -67,6 +68,7 @@ cc.glInvalidateStateCache = function () { /** * Uses the GL program in case program is different than the current one.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly. + * @function * @param {WebGLProgram} program */ cc.glUseProgram = function (program) { @@ -85,6 +87,7 @@ if(!cc.ENABLE_GL_STATE_CACHE){ /** * Deletes the GL program. If it is the one that is being used, it invalidates it.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glDeleteProgram() directly. + * @function * @param {WebGLProgram} program */ cc.glDeleteProgram = function (program) { @@ -98,6 +101,7 @@ cc.glDeleteProgram = function (program) { /** * Uses a blending function in case it not already used.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly. + * @function * @param {Number} sfactor * @param {Number} dfactor */ @@ -109,6 +113,11 @@ cc.glBlendFunc = function (sfactor, dfactor) { } }; +/** + * @function + * @param {Number} sfactor + * @param {Number} dfactor + */ cc.setBlending = function (sfactor, dfactor) { var ctx = cc._renderContext; if ((sfactor === ctx.ONE) && (dfactor === ctx.ZERO)) { @@ -121,6 +130,11 @@ cc.setBlending = function (sfactor, dfactor) { } }; +/** + * @function + * @param {Number} sfactor + * @param {Number} dfactor + */ cc.glBlendFuncForParticle = function(sfactor, dfactor) { if ((sfactor !== cc._blendingSource) || (dfactor !== cc._blendingDest)) { cc._blendingSource = sfactor; @@ -143,6 +157,7 @@ if(!cc.ENABLE_GL_STATE_CACHE){ /** * Resets the blending mode back to the cached state in case you used glBlendFuncSeparate() or glBlendEquation().
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD. + * @function */ cc.glBlendResetToCache = function () { var ctx = cc._renderContext; @@ -155,6 +170,7 @@ cc.glBlendResetToCache = function () { /** * sets the projection matrix as dirty + * @function */ cc.setProjectionMatrixDirty = function () { cc._currentProjectionMatrix = -1; @@ -170,6 +186,7 @@ cc.setProjectionMatrixDirty = function () { *
    * These flags can be ORed. The flags that are not present, will be disabled. *

    + * @function * @param {cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_OORDS} flags */ cc.glEnableVertexAttribs = function (flags) { @@ -208,6 +225,7 @@ cc.glEnableVertexAttribs = function (flags) { /** * If the texture is not already bound, it binds it.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. + * @function * @param {cc.Texture2D} textureId */ cc.glBindTexture2D = function (textureId) { @@ -217,6 +235,7 @@ cc.glBindTexture2D = function (textureId) { /** * If the texture is not already bound to a given unit, it binds it.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. + * @function * @param {Number} textureUnit * @param {cc.Texture2D} textureId */ @@ -246,6 +265,7 @@ if (!cc.ENABLE_GL_STATE_CACHE){ /** * It will delete a given texture. If the texture was bound, it will invalidate the cached.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. + * @function * @param {WebGLTexture} textureId */ cc.glDeleteTexture = function (textureId) { @@ -255,6 +275,7 @@ cc.glDeleteTexture = function (textureId) { /** * It will delete a given texture. If the texture was bound, it will invalidate the cached for the given texture unit.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. + * @function * @param {Number} textureUnit * @param {WebGLTexture} textureId */ @@ -269,7 +290,8 @@ cc.glDeleteTextureN = function (textureUnit, textureId) { /** * If the vertex array is not already bound, it binds it.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindVertexArray() directly. - * @param vaoId + * @function + * @param {Number} vaoId */ cc.glBindVAO = function (vaoId) { if (!cc.TEXTURE_ATLAS_USE_VAO) @@ -289,6 +311,7 @@ cc.glBindVAO = function (vaoId) { /** * It will enable / disable the server side GL states.
    * If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly. + * @function * @param {Number} flags */ cc.glEnable = function (flags) { diff --git a/cocos2d/shaders/CCShaderCache.js b/cocos2d/shaders/CCShaderCache.js index 00651dfe26..72480c2727 100644 --- a/cocos2d/shaders/CCShaderCache.js +++ b/cocos2d/shaders/CCShaderCache.js @@ -273,7 +273,10 @@ cc.shaderCache = /** @lends cc.shaderCache# */{ this._loadDefaultShader(program, this.TYPE_POSITION_UCOLOR); }, - /** returns a GL program for a given key */ + /** + * returns a GL program for a given key + * @param {String} key + */ programForKey: function (key) { return this._programs[key]; }, @@ -281,13 +284,17 @@ cc.shaderCache = /** @lends cc.shaderCache# */{ /** * returns a GL program for a shader name * @param {String} shaderName - * @return cc.GLProgram + * @return {cc.GLProgram} */ getProgram: function (shaderName) { return this._programs[shaderName]; }, - /** adds a CCGLProgram to the cache for a given name */ + /** + * adds a CCGLProgram to the cache for a given name + * @param {cc.GLProgram} program + * @param {String} key + */ addProgram: function (program, key) { this._programs[key] = program; } From ddf7578c2bbc4a4f4fe67c9fb13e57c4fa76bd80 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 27 Aug 2014 21:20:04 +0800 Subject: [PATCH 0561/1564] Issue #5829: tilemap jsdoc --- cocos2d/tilemap/CCTMXTiledMap.js | 50 ++++++++++++++------ cocos2d/tilemap/CCTMXXMLParser.js | 77 +++++++++++++++++++------------ 2 files changed, 84 insertions(+), 43 deletions(-) diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index 9fdda77a0c..3863aa96f2 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -97,6 +97,9 @@ cc.TMX_ORIENTATION_ISO = 2; * object.getProperty(name_of_the_property);

    * @class * @extends cc.Node + * @param {String} tmxFile tmxFile fileName or content string + * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. + * * @property {Array} properties - Properties from the map. They can be added using tilemap editors * @property {Number} mapOrientation - Map orientation @@ -105,6 +108,18 @@ cc.TMX_ORIENTATION_ISO = 2; * @property {Number} mapHeight - Height of the map * @property {Number} tileWidth - Width of a tile * @property {Number} tileHeight - Height of a tile + * + * @example + * //example + * 1. + * //create a TMXTiledMap with file name + * var tmxTiledMap = new cc.TMXTiledMap("res/orthogonal-test1.tmx"); + * 2. + * //create a TMXTiledMap with content string and resource path + * var resources = "res/TileMaps"; + * var filePath = "res/TileMaps/orthogonal-test1.tmx"; + * var xmlStr = cc.loader.getRes(filePath); + * var tmxTiledMap = new cc.TMXTiledMap(xmlStr, resources); */ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ properties: null, @@ -123,17 +138,6 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ * Constructor of cc.TMXTiledMap * @param {String} tmxFile tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. - * @example - * //example - * 1. - * //create a TMXTiledMap with file name - * var tmxTiledMap = new cc.TMXTiledMap("res/orthogonal-test1.tmx"); - * 2. - * //create a TMXTiledMap with content string and resource path - * var resources = "res/TileMaps"; - * var filePath = "res/TileMaps/orthogonal-test1.tmx"; - * var xmlStr = cc.loader.getRes(filePath); - * var tmxTiledMap = new cc.TMXTiledMap(xmlStr, resources); */ ctor:function(tmxFile,resourcePath){ cc.Node.prototype.ctor.call(this); @@ -148,6 +152,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * Gets the map size. * @return {cc.Size} */ getMapSize:function () { @@ -155,6 +160,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * Set the map size. * @param {cc.Size} Var */ setMapSize:function (Var) { @@ -176,6 +182,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * Gets the tile size. * @return {cc.Size} */ getTileSize:function () { @@ -183,6 +190,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * Set the tile size * @param {cc.Size} Var */ setTileSize:function (Var) { @@ -212,6 +220,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * map orientation * @param {Number} Var */ setMapOrientation:function (Var) { @@ -227,6 +236,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * object groups * @param {Array} Var */ setObjectGroups:function (Var) { @@ -234,7 +244,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** - * properties + * Gets the properties * @return {object} */ getProperties:function () { @@ -242,6 +252,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * Set the properties * @param {object} Var */ setProperties:function (Var) { @@ -249,8 +260,9 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ }, /** + * Initializes the instance of cc.TMXTiledMap with tmxFile * @param {String} tmxFile - * @return {Boolean} + * @return {Boolean} Whether the initialization was successful. * @example * //example * var map = new cc.TMXTiledMap() @@ -272,6 +284,12 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ return true; }, + /** + * Initializes the instance of cc.TMXTiledMap with tmxString + * @param {String} tmxString + * @param {String} resourcePath + * @return {Boolean} Whether the initialization was successful. + */ initWithXML:function(tmxString, resourcePath){ this.width = 0; this.height = 0; @@ -310,6 +328,10 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ } }, + /** + * Return All layers array. + * @returns {Array} + */ allLayers: function () { var retArr = [], locChildren = this._children; for(var i = 0, len = locChildren.length;i< len;i++){ @@ -447,7 +469,7 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); /** * Creates a TMX Tiled Map with a TMX file or content string. * Implementation cc.TMXTiledMap - * @deprecated + * @deprecated since v3.0 please use new cc.TMXTiledMap(tmxFile,resourcePath) instead. * @param {String} tmxFile tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @return {cc.TMXTiledMap|undefined} diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index 60654a9734..0fe7435209 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -133,6 +133,7 @@ cc.TMXLayerInfo = cc.Class.extend(/** @lends cc.TMXLayerInfo# */{ }, /** + * Gets the Properties. * @return {Array} */ getProperties:function () { @@ -140,6 +141,7 @@ cc.TMXLayerInfo = cc.Class.extend(/** @lends cc.TMXLayerInfo# */{ }, /** + * Set the Properties. * @param {object} value */ setProperties:function (value) { @@ -159,38 +161,33 @@ cc.TMXLayerInfo = cc.Class.extend(/** @lends cc.TMXLayerInfo# */{ * This information is obtained from the TMX file.

    * @class * @extends cc.Class + * + * @property {string} name - Tileset name + * @property {number} firstGid - First grid + * @property {number} spacing - Spacing + * @property {number} margin - Margin + * @property {string} sourceImage - Filename containing the tiles (should be sprite sheet / texture atlas) + * @property {cc.Size|null} imageSize - Size in pixels of the image */ cc.TMXTilesetInfo = cc.Class.extend(/** @lends cc.TMXTilesetInfo# */{ - /** - * Tileset name - */ + //Tileset name name:"", - /** - * First grid - */ + //First grid firstGid:0, _tileSize:null, - /** - * Spacing - */ + //Spacing spacing:0, - /** - * Margin - */ + //Margin margin:0, - /** - * Filename containing the tiles (should be sprite sheet / texture atlas) - */ + //Filename containing the tiles (should be sprite sheet / texture atlas) sourceImage:"", - /** - * Size in pixels of the image - */ + //Size in pixels of the image imageSize:null, ctor:function () { @@ -199,6 +196,7 @@ cc.TMXTilesetInfo = cc.Class.extend(/** @lends cc.TMXTilesetInfo# */{ }, /** + * Return rect * @param {Number} gid * @return {cc.Rect} */ @@ -242,6 +240,19 @@ cc.TMXTilesetInfo = cc.Class.extend(/** @lends cc.TMXTilesetInfo# */{ * @property {Number} mapHeight - Height of the map * @property {Number} tileWidth - Width of a tile * @property {Number} tileHeight - Height of a tile + * + * @param {String} tmxFile fileName or content string + * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. + * @example + * 1. + * //create a TMXMapInfo with file name + * var tmxMapInfo = cc.TMXMapInfo.create("res/orthogonal-test1.tmx"); + * 2. + * //create a TMXMapInfo with content string and resource path + * var resources = "res/TileMaps"; + * var filePath = "res/TileMaps/orthogonal-test1.tmx"; + * var xmlStr = cc.loader.getRes(filePath); + * var tmxMapInfo = cc.TMXMapInfo.create(xmlStr, resources); */ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ properties:null, @@ -268,16 +279,6 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ * Constructor of cc.TMXMapInfo * @param {String} tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. - * @example - * 1. - * //create a TMXMapInfo with file name - * var tmxMapInfo = cc.TMXMapInfo.create("res/orthogonal-test1.tmx"); - * 2. - * //create a TMXMapInfo with content string and resource path - * var resources = "res/TileMaps"; - * var filePath = "res/TileMaps/orthogonal-test1.tmx"; - * var xmlStr = cc.loader.getRes(filePath); - * var tmxMapInfo = cc.TMXMapInfo.create(xmlStr, resources); */ ctor:function (tmxFile, resourcePath) { cc.SAXParser.prototype.ctor.apply(this); @@ -298,6 +299,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ } }, /** + * Gets Map orientation. * @return {Number} */ getOrientation:function () { @@ -305,6 +307,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Set the Map orientation. * @param {Number} value */ setOrientation:function (value) { @@ -320,6 +323,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Map width & height * @param {cc.Size} value */ setMapSize:function (value) { @@ -349,6 +353,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Tiles width & height * @param {cc.Size} value */ setTileSize:function (value) { @@ -378,6 +383,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Layers * @param {cc.TMXLayerInfo} value */ setLayers:function (value) { @@ -393,6 +399,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * tilesets * @param {cc.TMXTilesetInfo} value */ setTilesets:function (value) { @@ -408,6 +415,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * ObjectGroups * @param {cc.TMXObjectGroup} value */ setObjectGroups:function (value) { @@ -423,6 +431,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * parent element * @param {Object} value */ setParentElement:function (value) { @@ -438,6 +447,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * parent GID * @param {Number} value */ setParentGID:function (value) { @@ -453,6 +463,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Layer attribute * @param {Object} value */ setLayerAttribs:function (value) { @@ -468,6 +479,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Is reading storing characters stream * @param {Boolean} value */ setStoringCharacters:function (value) { @@ -483,6 +495,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Properties * @param {object} value */ setProperties:function (value) { @@ -813,6 +826,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Gets the tile properties. * @return {object} */ getTileProperties:function () { @@ -820,6 +834,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Set the tile properties. * @param {object} tileProperties */ setTileProperties:function (tileProperties) { @@ -827,6 +842,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Gets the currentString * @return {String} */ getCurrentString:function () { @@ -834,6 +850,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Set the currentString * @param {String} currentString */ setCurrentString:function (currentString) { @@ -841,6 +858,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Gets the tmxFileName * @return {String} */ getTMXFileName:function () { @@ -848,6 +866,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ }, /** + * Set the tmxFileName * @param {String} fileName */ setTMXFileName:function (fileName) { @@ -894,7 +913,7 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); /** * Creates a TMX Format with a tmx file or content string - * @deprecated + * @deprecated since v3.0 please use new cc.TMXMapInfo(tmxFile, resourcePath) instead. * @param {String} tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @return {cc.TMXMapInfo} From 24ac16235d97e75f7fcc493cd88b1a713a28bf42 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 27 Aug 2014 21:34:20 +0800 Subject: [PATCH 0562/1564] Fixed #5797: Fix a bug of cc.textureCache.addImage --- cocos2d/core/textures/CCTextureCache.js | 2 +- cocos2d/core/textures/TexturesWebGL.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 878789dc74..14e4c3dfee 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -359,7 +359,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (err) return cb ? cb(err) : err; cc.textureCache.handleLoadedTexture(url); - cb && cb(null, img); + cb && cb(target, img); }); } } diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index dd099d8dc3..5593976543 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -927,7 +927,7 @@ cc._tmp.WebGLTextureCache = function () { if (err) return cb ? cb(err) : err; cc.textureCache.handleLoadedTexture(url); - cb && cb(null, img); + cb && cb(target, img); }); } } From fc6a5398beec57ae2b2eae1bf51a76744fb6ef5e Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 28 Aug 2014 11:37:08 +0800 Subject: [PATCH 0563/1564] add jsdoc for scenes,CCDrawingPrimitives,CCConfiguration --- cocos2d/core/CCConfiguration.js | 2 ++ cocos2d/core/CCDrawingPrimitivesCanvas.js | 10 +++++-- cocos2d/core/CCDrawingPrimitivesWebGL.js | 6 +++- cocos2d/core/scenes/CCLoaderScene.js | 34 ++++++++++++++++++++--- cocos2d/core/scenes/CCScene.js | 6 ++-- cocos2d/core/scenes/CCSceneFile.js | 6 +++- 6 files changed, 53 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/CCConfiguration.js b/cocos2d/core/CCConfiguration.js index 8383533729..69cc55494a 100644 --- a/cocos2d/core/CCConfiguration.js +++ b/cocos2d/core/CCConfiguration.js @@ -28,6 +28,8 @@ * cc.configuration contains some openGL variables * @namespace * @name cc.configuration + * @example + * var textureSize = cc.configuration.getMaxTextureSize(); */ cc.configuration = /** @lends cc.configuration# */{ // Type constants diff --git a/cocos2d/core/CCDrawingPrimitivesCanvas.js b/cocos2d/core/CCDrawingPrimitivesCanvas.js index f88489e2b0..81596cb2e7 100644 --- a/cocos2d/core/CCDrawingPrimitivesCanvas.js +++ b/cocos2d/core/CCDrawingPrimitivesCanvas.js @@ -23,19 +23,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - +/** + * @const + * @type {number} + */ cc.PI2 = Math.PI * 2; /** - * Canvas of DrawingPrimitive implement version + * Canvas of DrawingPrimitive implement version use for canvasMode * @class * @extends cc.Class + * @param {CanvasRenderingContext2D} renderContext */ cc.DrawingPrimitiveCanvas = cc.Class.extend(/** @lends cc.DrawingPrimitiveCanvas# */{ _cacheArray:[], _renderContext:null, /** - * Constructor + * Constructor of cc.DrawingPrimitiveCanvas * @param {CanvasRenderingContext2D} renderContext */ ctor:function (renderContext) { diff --git a/cocos2d/core/CCDrawingPrimitivesWebGL.js b/cocos2d/core/CCDrawingPrimitivesWebGL.js index 54001668eb..f5461a01f5 100644 --- a/cocos2d/core/CCDrawingPrimitivesWebGL.js +++ b/cocos2d/core/CCDrawingPrimitivesWebGL.js @@ -25,7 +25,7 @@ ****************************************************************************/ /** - * Canvas of DrawingPrimitive implement version + * Canvas of DrawingPrimitive implement version use for WebGlMode * @class * @extends cc.Class */ @@ -37,6 +37,10 @@ cc.DrawingPrimitiveWebGL = cc.Class.extend(/** @lends cc.DrawingPrimitiveWebGL# _colorArray: null, _pointSizeLocation:-1, _pointSize:-1, + /** + * contructor of cc.DrawingPrimitiveWebGL + * @param ctx rendercontext + */ ctor:function (ctx) { if (ctx == null) ctx = cc._renderContext; diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index c920d21b56..f5ce7f20ad 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -22,12 +22,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - +/** + *

    cc.LoaderScene is a scene that you can load it when you loading files

    + *

    cc.LoaderScene can present thedownload progress

    + * @class + * @extends cc.Scene + * @example + * var lc = new cc.LoaderScene(); + */ cc.LoaderScene = cc.Scene.extend({ _interval : null, _label : null, _className:"LoaderScene", - + /** + * Contructor of cc.LoaderScene + * @returns {boolean} + */ init : function(){ var self = this; @@ -71,13 +81,17 @@ cc.LoaderScene = cc.Scene.extend({ logo.y = centerPos.y; self._bgLayer.addChild(logo, 10); }, - + /** + * custom onEnter + */ onEnter: function () { var self = this; cc.Node.prototype.onEnter.call(self); self.schedule(self._startLoading, 0.3); }, - + /** + * custom onExit + */ onExit: function () { cc.Node.prototype.onExit.call(this); var tmpStr = "Loading... 0%"; @@ -110,6 +124,18 @@ cc.LoaderScene = cc.Scene.extend({ }); } }); +/** + *

    cc.LoaderScene.preload can present a loaderScene with download progress.

    + *

    when all the resource are downloaded it will invoke call function

    + * @param resources + * @param cb + * @returns {cc.LoaderScene|*} + * @example + * //Example + * cc.LoaderScene.preload(g_resources, function () { + cc.director.runScene(new HelloWorldScene()); + }, this); + */ cc.LoaderScene.preload = function(resources, cb){ var _cc = cc; if(!_cc.loaderScene) { diff --git a/cocos2d/core/scenes/CCScene.js b/cocos2d/core/scenes/CCScene.js index 8378171707..31ff8520d6 100644 --- a/cocos2d/core/scenes/CCScene.js +++ b/cocos2d/core/scenes/CCScene.js @@ -36,10 +36,12 @@ *

    It is a good practice to use and cc.Scene as the parent of all your nodes.

    * @class * @extends cc.Node + * @example + * var scene = new cc.Scene(); */ cc.Scene = cc.Node.extend(/** @lends cc.Scene# */{ /** - * Constructor + * Constructor of cc.Scene */ _className:"Scene", ctor:function () { @@ -52,7 +54,7 @@ cc.Scene = cc.Node.extend(/** @lends cc.Scene# */{ /** * creates a scene - * @deprecated + * @deprecated since v3.0,please use new cc.Scene() instead. * @return {cc.Scene} * @example * // Example diff --git a/cocos2d/core/scenes/CCSceneFile.js b/cocos2d/core/scenes/CCSceneFile.js index de4b748d0c..724427480e 100644 --- a/cocos2d/core/scenes/CCSceneFile.js +++ b/cocos2d/core/scenes/CCSceneFile.js @@ -22,5 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - +/** + * It's the logo of Cocos2d-js (base64 image file) + * @type {string} base64 image file + * @private + */ cc._loaderImage = "data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAlAAD/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjM4MDBEMDY2QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjM4MDBEMDY1QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTk0OEM4OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2RTk0OEM5OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4ADkFkb2JlAGTAAAAAAf/bAIQADQkJCQoJDQoKDRMMCwwTFhENDREWGhUVFhUVGhkUFhUVFhQZGR0fIB8dGScnKionJzk4ODg5QEBAQEBAQEBAQAEODAwOEA4RDw8RFA4RDhQVERISERUfFRUXFRUfKB0ZGRkZHSgjJiAgICYjLCwoKCwsNzc1NzdAQEBAQEBAQEBA/8AAEQgAyACgAwEiAAIRAQMRAf/EALAAAAEFAQEAAAAAAAAAAAAAAAQAAgMFBgcBAQEAAwEBAAAAAAAAAAAAAAAAAQMEAgUQAAIBAgIEBwoLBgQGAwAAAAECAwAEEQUhMRIGQVFxsTITFGGBwdEiQlKSMzWRoeFicqKyI1NzFYJjJDQWB9KjVCbxwkNkJWXik3QRAAIBAgMFBQcDBQEAAAAAAAABAhEDIRIEMUFRcTJhwVIUBZGhsSJyEzOB0ULhYpIjUxX/2gAMAwEAAhEDEQA/AMJSpUqAVKlXuFAeUq9wpUB5XuFe4V6ooDzZHDox0CnGMinzwl7Z8NajaHeoO3vmTBZBtp9YUIqTEV5ROxHKnWRnaU8VRMhFBUjpV7hSoSeUq9pUB5Sr2lhQHlKvcK8oBV7hSFSRrtaKAZs07YNPM1pG2xJIAw1jSeandry/8X4m8VCKkWwaWwam7Xl/4v1W8VLtmX/i/VbxUoKkWwakSM407tmX/i/VbxUmzGwjQsjdY41IARie/U0IbZO0kNtCXnOCkEBeFu4KI3Bs7DNb27ya+jDx3kJeEnpJJEcQVbWDsk17u5urd591ucZkWhym2Vnd9RkCDEpFxDRpbw0bunu5mlp2De2FMLYXOD2wB2xbOeraUcYGJ72mlSUiqzzdzMd3Z3mixltA2yzcK/NlHM1DQyRXce1HocdNOEfJXZ88y9ZojOqhiBszIRiHQ8Y4cK5TvHuzLljHNMqxNoDjLFraHHnjPxcNCGVbxEUzYNTx5jZSxhpW6qTzlwJ+DCvO2Zf+L9VvFSgqyHYNLYNTdssPxfibxUu15f8Ai/VPiqCakOwa82DU/a8v/F+JvFTDdWPBL8R8VKCvYRYV5UzoMAy6QdIIqI0B4KJtxiRQwou16QoGUkntH5Tz0RbZbmF2hktraSVBo2lUkY8tDye0flPPXTslVUyiyVRsjqUOA4yMT8dW2ram2m6UVTNq9S7EIyUVJydMTn/6DnP+im9Wl+g5z/opvVrpteEhQWY4AaSTwAVf5WPiZh/9S5/zj7zltzlmYWkfWXNvJDGTgGcYDHirR7i7mSbwXParsFMrgb7w6jKw/wCmnc9I14kF3vpvCljbMyWMOJL4aEiB8qU/ObUK7HYWVrl1pFZWiCOCBQqKOLjPGTrNZZqKbUXVHq2nNwTuJRk1VpbgXN8s7Rk5ym0UQQzhIG2NAjhxHWbI+gCBVjBBFbwxwQqEiiUJGg1BVGAFe7dV28WYLYZFmF2Th1UD7JGjymGyn1iK5OyzIBGB1HgrLZhamzumQAGJwSqnSCh1q3GOCodxt4cxurdcpzuN4cyhiWaF5Bg09udUmnWw1H/jV9nFuJ7Quo+8h8peThFA+047vduyMtk7fYqTl07YFdfUufMPzT5p71UdtlmYXaGS2t3mQHAsgxANdadYJopLe4QS2867EsZ4QfCNYrCFbjdDPmgkYyWFxgVf04ifJf6ScNdRUW1XBb6FU5TjF5EpSSrGu/s5lN+g5z/opvVpfoOc/wCim9WtdHnatvObJXDW7xLGhB8nrPaY9/HCr+tEdPCVaSeDoYLnqF63lzW4/PFSW3ecxbI84VSzWUwUaSdg0DXXK5nvAipnd6qgKvWnQO7pri9ZUEmm3Vl2j1kr8pRlFRyquBNZjGxQ/S56Y1S2fu9OVueon11Szahoou06QoQUXadIVCD2FJJ7R+U89dMydv8Axdn+TH9muZye0flPPXQstlK5Tbka1gUjlC1q0vVLkeb6r+O3Tx9xcY1nt8c0NrZCyiOE1108NYjGv1joo7Js1jzKyScYLIvkzL6LDwHXVJksH9Sb49dKNq0tj1jA6uriOCL+02FWX7iVtZX1/AzaHTyeoauKn2MX9W79zebiZCuR5MjSrhfXuEtwTrUeZH+yNfdrRNcxI6IzhXlJEak6WIGJ2Rw4ChWnChndtlVBLMdQA0k1gbXNMzzDfDLs6mjaPKppJbWwJ1bOwwxw43OnHh71YT3DpfWUJmFlb5jHHDdeXBHIsrRea5TSqvxqG04cNN62vetoCS4tre5mgnkGE9q+3DKOkuI2WX6LDQRRHWDh1UCtwj7QRg2wdl8Djgw1qe7XvW0BQ3kfZ7mSLgU+T9E6RVbnuVrnWVSWqj+Lt8ZbRuHEdKPkYVcZ2MJY5fSGyeVar45+rkWQHAqccalPE5km1htWK5nK4Wnt5FuUBUwOMG4nGkA/BXUrW4S6torlOjMgcd/xVn7rLo7zKs0uEjCNeSvdwoBhgsZxX1l2j36k3Lu+uyprdj5Vs5A+i/lD48a0aaVJOPi7jB6lbzWozpjB48pf1NDXNN4vfl7+Z4BXS65pvF78vfzPAK71XTHmZ/S/yT+jvJ7L3fHytz1E+upbL+Qj5W56jfXWRnsIYKLtekKEFGWvSFQgyjk9o/Keet3YthlMP/5x9msJJ7R+U89biyb/AMXEv7gD6tadL1T+kwepRrC39ZkLDMbiwMvUHRPG0bjlGg8ore/23sxBldxfMPLupNhT8yL/AORNZbdzJ484scytxgLqJY5LZj6Q2sV5G1Vud1mjjyG0ij0NEGSZToKyhjtqw4waztuiXA3qKTbSxltfGhbZlE95ZtZqxVbgiOZhrER9ph3Svk9+pJILZ4Y4DGBFCUMKjRsGPobPFhUfW0NJmljE2xJcIrcI2vFUEln1lRXd6lrazXT9GCNpD+yNqoI7mOVduNw6nzlOIoPOUa6yye1XXcbMR5GdQ3xY0BSbj31/FcTQZirJ+q431q7anbHCTZ72Bw7lbPrKBMcBWNNgbMBBh+bsjBdni0VJ1lARZs6yWiupxCuMDy6KpS2IwOo6DTr3Mre3e5tZZVUM4ZBjqOOJoWO4jkXajcOOMHGgDISvWIrdAkKR80+TzVl908bPPL3LzxOuHdifxVfiTAg92qI/w+/8gGgSyN/mR7XPVlp0lF/3L3mbVKtu5Hjbk/8AHE2Fc03i9+Xv5ngFdKNc13i9+Xv5ngFaNV0x5nn+l/kn9HeEWXu+PlbnqJ9dS2Xu9OVueon11kZ7CGCjLXpCgxRlr0hUIPYUcntH5Tz1s8vb+Bt1/dqPirGSe0flPPWusG/g4Py15q06XqlyMWvVYQ+ruI9xJOqzO9hOto/sP8tbGOFIrmWeM7IuMDMnAXXQJOUjQeOsJk0nY96ip0CYunrjaHx1t+srPJUbXBm2LrFPikwTOb+T+VhbZxGMrDXp83x1QSy2tucJpUjPETp+Cn5/ftaRvKvtp3Kx48HG3erHMzOxZiWZtLMdJNQSbbL71Vk6yynViOkqnEEfOWtPbXi3EQkGg6mXiNckjeSJxJGxR10qw0GtxuxmvbImD4CZMFlA4fRfv0BqesqqzTMZNMEDbIHtHH2QeCiZJSqMQdOGiue53mz3czQwsRbIcNHnkec3c4qAMuriz68gTIToxwOOnlp0MjxMJYW741Gs3RVldtbygE/dMcHX/moDaxTiWNZB53B3arb8/wC+4SOF4sf/AKxU9kcBsfOGHfoUHtG/RbzY5Die5HHhXdvavqiZ9Q8Jdlq4/gbKua7xe/L38zwCuhpf2Uk/Zo50kmwJKIdogDjw1VzzeL35e/meAVp1LTgqY4nn+mRauzqmqwrjzCLL3fHytz1E+upLL+Qj5W56jfXWRnroYKLtekKEFF2vSFQg9hSSe0flPPWosm/hIfoLzVl5PaPynnrRWb/w0X0F5q06XqlyM2sVYx5gmbFre/t71NY2T+0h8VbSO5SWNJUOKSAMp7jDGspmMPaLRlXS6eWve1/FRO7WYdbZm1Y/eW/R7qHxHRXGojlm3ulid6aVbaW+OALvgCLq2Hm9WxHKWqjhj6xsK1e8dm15l4niG1LZkswGsxtrPeOmsvayBJA1VItlWjptLuTdPMo7LtjRDq9naK4+WF9IrUW7BaHOljGqVHB7w2hzVoZt87d8vaNYSLl02CcRsDEbJbj71Uu7UBkvJ7/D7q2QoDxySaAO8MTXdxRVMpRp5XZOWdF/ms7R5XdyKfKWJsO/5PhrG5XlNxmEywW6bTnTxAAcJNbGSMXkM1pjgbiNo1PziPJ+Os7u7m/6ReM00ZOgxSpqYYHT3wRXMKN4ll9zUG4bQfNshu8sZVuEA2hirA4qe/VOwwrVbzbww5mI44UKRRYkbWG0S3JWctbd7u5WFfOOLHiUdJqmaipfLsIsObhWe001lMkMVvJNjhghIALMcBxCs7fxXQmkupx1bXDswGPlaTidVaEyKNXkoo4eBV+Sq7L7Vs9zcBgeyQ4GQ/MB1crmoim2orezqcowTuSeEY48jQ7oZX2PLzdyLhNd6RjrEY6I7+uspvH78vfzPAK6UAAAFGAGgAcArmu8Xvy9/M8ArTfio24RW5nnaG67uou3H/KPuqT2X8hHytz1G+upLL3enK3PUb66ys9RDBRdr0hQgou06QqEGUkntH5Tz1e238vF9BeaqKT2j8p56vbb+Xi+gvNWjTdUuRn1XTHmTh8KrJTJlt8t1CPIY44cGnpJVjTJYkmjaN9Ib4u7V923njTethRauZJV3PaW1rfLIiXEDYg6R4VYc9CXW7thfOZbKdbGZtLW8uPVY/u3GrkNUkM9zlcxUjbhfWOA90cRq4gv4LhdqN+VToNYWmnRm9NNVWNTyHc6VWBv8wt4YeHqm6xyPmroq1Z7WGFLSxTq7WLSuPSdjrkfumq5yHXDUeA92oO2SKpVumNAaoJLMXH3myp0rpJ4uKhc3tbDM5BMri1zAj79j7KTiY8TcdBpcsith0286o+sPCagEX9Pzg4zXUCp6QYse8oouCG3tk6m1BYv05W6T+IdyolxbHDAAa2OgDlNCz3ryN2WxBd5PJMg1t81eId2ukqnLlTBbfcuY+9uJLiRcvtPvHdsHK+cfRHcHDWsyawjyy0WBcDI3lTP6TeIcFV+S5OmXx9bJg1048o8Cj0V8Jq2DVu09nL80up7OxHi+oal3P8AXB/IsZS8T/YOV65zvCcc7vfzPAK3ivWCz445zeH954BXOr6I8yfSfyz+jvCLP3fHytz1G+upLP3fHytz1E+usbPaQ0UXadIUIKLtekKhB7Ckk9o/Keer22/l4/oLzVRSe0flPPV7b/y8X0F5q0abqlyM+q6Y8yQsBTDMor1o8aiaE1pbluMqS3sbLLHIhSRQyngqukhaJ9uBjo+H5aOa3ao2t34qouRlLajTalGP8v0IY8ylXQ+PKPFU/bYXOLPge6CKia0LaxTOxHu1Q7cuBd9yPEJ7TbjXKO8CajbMIF6CNIeNvJHjqIWJ7tSpYkalqVblwIdyG+RGXur0hXYJFxal+Dhq5y3slkv3Y2pD0pTr+QUClpJRUdo9XW4OLrTHtM16cZLLWkeC7y4jvlNEpcRtw1Ux27Ci448NZrTFy3nn3IQWxlgGrDZ3pza7/M8ArZo+ArF5171uvp+CqdV0R5l/psUrs2vB3hdl7vTlbnqJ9dS2Xu+PlbnqJ9dY2eshooq16QoQUXa9IVCD2FLJ7RuU89WNtmUSQqkgYMgw0accKrpPaPynnrZWG4Vi+VWmY5tnMWXG+XrIYnA0rhj0mdcTgdNdwnKDqjmduM1SRR/qlr8/4KX6pa8T/BVzDuLZXudRZblmbxXcPUNPc3KqCIwrbOzgrHEnHjoyD+3eSXkht7DeKG4umDGOJVUklfouThXfmbnZ7Cvy1vt9pmv1W1+d8FL9VteJvgq5yrcOGfLmzHN80iyyETPbptAEFo2ZG8pmUa1OFNn3Ky6W/sbDKM5hv5bx2WTZA+7RF2y52WOPJTzE+z2Dy1vt9pT/AKpacTerS/U7Tib1a04/t7kDXPY03jhN0W6sQ7K7W3q2dnrMccaDy/8At80kuZfqWYxWNtlcvUPPhiGYhWDeUy7IwYU8xPs9g8tb7faUn6pacTerTxm9oOBvVq3v9z927aynuId44LiWKNnjhAXF2UYhRg516qpsryjLr21665zFLSTaK9U2GOA87SwqY37knRU+BzOzags0s1Oyr+BKM6sxwP6tSDPLMen6vy0rvdm3Sxlu7K/S7WDDrFUDUTxgnTU826eXW7KlxmqQuwDBXUKcD+1Xee/wXuKX5XDGWLapSVcOyhEM/seJ/V+WnjeGx4pPV+Wkm6kKZlFay3Jlt7iFpYZY8ASVK6DjtDDA0f8A0Tl340/1f8Ndx8xJVWXB0KbktFFpNzdVXAC/qOwA0CQni2flrO3Vwbm5lnI2TKxbDirX/wBE5d+NcfV/wVR7xZPa5U9utvI8nWhmbbw0YEAYYAVxfhfy5rlKR4Fulu6X7mW1mzT8S4Yis/5CPlbnqJ9dSWfu9OVueon11mZvQ2i7XpChKKtekKhBlNJ7R+U89bDfGTb3a3ZX0Lcj6kdY+T2j8p560288m1kWQr6MJ+ylSAr+2cnV5renjs3H1loX+3j9XvbbtxLN9lqW4UnV5jdnjtXHxihtyZNjeSBu5J9k1BJe7xy7W5CJ/wCzuD/mTVTf2+fq97LJuLrPsNRueS7W6aJ/38x+vLVXuY+xvHaNxbf2GoCezf8A36j/APsSf8w1sLnqczTefJluYoLm5uo5F61sBshItP1cNFYe1f8A3ir/APfE/wCZUe9bB94r5jwuPsrQFhmG4l/Z2M17HdW90tuu3IkTHaCjWdIw0VVZdks9/C06yJFEp2dp+E1bbqybGTZ8vpQD7L1XRv8A7blT96Oda7tpNuuNE37Cq9KSisjyuUoxrStKllHbLlWTXsMs8chuSuwEPDqwoLe5y+YRE/gLzmqRekvKKtd4327yM/ulHxmrHJStySWVRyrjxKI2XC/CTlnlPPKTpTdFbP0L1bgrf5Lp0G3dPhQHwV0S1lzBsns3sESR8Crh9WAJGjSOKuU3E+zdZQ3oJh8IArdZXFDmOTpHa3i2+YrI2KtKy4ricBsBuHHgFXSo440+Wa2qqxjvM9uMoy+WvzWpLCWWWE28HxL6e43ojgkeSCBY1Ri5BGIUDT51cl3vm276BBqSEH4WbxV0tlkyXJcxTMb+OW6uY9mGHrCzDQwwAbTp2uKuTZ9N1uYsfRRR8WPhrm419mSSjRyiqxVK7y23B/ftuTm2oSdJyzNVw3BFn7vTlbnqF9dS2fu9OVueon11lZuQ2iLdsGFD05H2dNQGV0ntG5Tz1dWm9N1b2kVq8EVwsI2UaQaQOKhmitZGLOmk68DhSFvY+gfWNSAg7z3Qvo7yKCKIohiaNR5LKxx8qpxvjcqS0VpbxvwOAcRQPZ7D0G9Y0uz2HoH1jUCpLY7zXlpbm3eKO5QuzjrBqZji3x17PvNcyT288VvDBJbMWUovS2hslW7mFQ9nsPQPrGl2ew9A+saCod/WNxtbYsrfb17WBxx5ddD2281xC88klvDcSXEnWuzrqOGGC9zRUPZ7D0G9Y0uzWHoH1jQVCLreq6ntZbaO3it1mGy7RjTs1X2mYy20ZiCq8ZOODcdEdmsPQb1jS7PYegfWNdJuLqnQiSUlRqpFLmryxtH1Ma7Qw2gNNPOdSt0oI27p007s9h6B9Y0uz2HoH1jXX3Z+I4+1b8IJdX89xLHKQFMXQUahpxoiPN5P+onfU+A0/s9h6DesaXZ7D0D6xpG7OLbUtu0StW5JJx2bBsmbtiSiEk+cxoCWWSaVpZOk2vDVo0VYdnsPQb1jSNvZcCH1jSd2c+p1XAmFqEOmOPEfaH+BQd1ueo211IzrgFUYKNAAqI1WztCpUqVCRUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoD/9k="; From 4099b38f6d04324884b52b187338d7a46c3bdf14 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 28 Aug 2014 11:40:02 +0800 Subject: [PATCH 0564/1564] add jsdoc comments for utils and effects --- cocos2d/core/utils/BinaryLoader.js | 7 +++++++ cocos2d/effects/CCGrabber.js | 24 +++++++++++++++++++++++- cocos2d/effects/CCGrid.js | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/utils/BinaryLoader.js b/cocos2d/core/utils/BinaryLoader.js index 6260636efa..9478bd06ae 100644 --- a/cocos2d/core/utils/BinaryLoader.js +++ b/cocos2d/core/utils/BinaryLoader.js @@ -27,6 +27,7 @@ /** * Load binary data by url. + * @function * @param {String} url * @param {Function} [cb] */ @@ -65,6 +66,12 @@ cc.loader._str2Uint8Array = function (strData) { return arrData; }; +/** + * Load binary data by url synchronously + * @function + * @param {String} url + * @return {Uint8Array} + */ cc.loader.loadBinarySync = function (url) { var self = this; var req = this.getXMLHttpRequest(); diff --git a/cocos2d/effects/CCGrabber.js b/cocos2d/effects/CCGrabber.js index a4dc754ff2..96f78b2fa5 100644 --- a/cocos2d/effects/CCGrabber.js +++ b/cocos2d/effects/CCGrabber.js @@ -24,7 +24,11 @@ THE SOFTWARE. ****************************************************************************/ -/** FBO class that grabs the the contents of the screen */ +/** + * FBO class that grabs the the contents of the screen + * @class + * @extends cc.Class + */ cc.Grabber = cc.Class.extend({ _FBO:null, _oldFBO:null, @@ -32,6 +36,9 @@ cc.Grabber = cc.Class.extend({ _gl:null, + /** + * constructor of cc.Grabber + */ ctor:function () { cc._checkWebGLRenderMode(); this._gl = cc._renderContext; @@ -41,6 +48,10 @@ cc.Grabber = cc.Class.extend({ this._FBO = this._gl.createFramebuffer(); }, + /** + * grab + * @param {cc.Texture2D} texture + */ grab:function (texture) { var locGL = this._gl; this._oldFBO = locGL.getParameter(locGL.FRAMEBUFFER_BINDING); @@ -56,6 +67,10 @@ cc.Grabber = cc.Class.extend({ locGL.bindFramebuffer(locGL.FRAMEBUFFER, this._oldFBO); }, + /** + * should be invoked before drawing + * @param {cc.Texture2D} texture + */ beforeRender:function (texture) { var locGL = this._gl; this._oldFBO = locGL.getParameter(locGL.FRAMEBUFFER_BINDING); @@ -76,12 +91,19 @@ cc.Grabber = cc.Class.extend({ // glColorMask(true, true, true, false); // #631 }, + /** + * should be invoked after drawing + * @param {cc.Texture2D} texture + */ afterRender:function (texture) { var locGL = this._gl; locGL.bindFramebuffer(locGL.FRAMEBUFFER, this._oldFBO); locGL.colorMask(true, true, true, true); // #631 }, + /** + * delete FBO + */ destroy:function(){ this._gl.deleteFramebuffer(this._FBO); } diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index 5393baa638..f93dfd40a0 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -720,7 +720,7 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ /** * create one TiledGrid3D object - * @deprecated + * @deprecated since v3.0, plese use new cc.TiledGrid3D(gridSize, texture, flipped) instead * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] From 02556e7f214d3f4093f5f6ba5c154c95185abde2 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 28 Aug 2014 11:58:03 +0800 Subject: [PATCH 0565/1564] add jsdoc comments for editbox --- extensions/editbox/CCEditBox.js | 30 +++++++++++++++++++++++------- extensions/editbox/CCdomNode.js | 6 +++--- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 97e54eb089..eae0db612b 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -145,6 +145,10 @@ cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3; */ cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4; +/** + * @class + * @extends cc.Class + */ cc.EditBoxDelegate = cc.Class.extend({ /** * This method is called when an edit box gains focus after keyboard is shown. @@ -226,11 +230,11 @@ cc.EditBox = cc.ControlButton.extend({ _className: "EditBox", /** - * @constructor - * @param size - * @param normal9SpriteBg - * @param press9SpriteBg - * @param disabled9SpriteBg + * constructor of cc.EditBox + * @param {cc.Size} size + * @param {cc.Scale9Sprite} normal9SpriteBg + * @param {cc.Scale9Sprite} press9SpriteBg + * @param {cc.Scale9Sprite} disabled9SpriteBg */ ctor: function (size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) { cc.ControlButton.prototype.ctor.call(this); @@ -551,6 +555,7 @@ cc.EditBox = cc.ControlButton.extend({ /* override functions */ /** * Set the delegate for edit box. + * @param {cc.EditBoxDelegate} delegate */ setDelegate: function (delegate) { this._delegate = delegate; @@ -611,7 +616,11 @@ cc.EditBox = cc.ControlButton.extend({ //this._editBoxImpl.openKeyboard(); }, - //HTML5 Only + /** + * @warning HTML5 Only + * @param {cc.Size} size + * @param {cc.color} bgColor + */ initWithBackgroundColor: function (size, bgColor) { this._edWidth = size.width; this.dom.style.width = this._edWidth.toString() + "px"; @@ -672,6 +681,12 @@ cc.defineGetterSetter(_p, "returnType", null, _p.setReturnType); _p = null; +/** + * get the rect of a node in world coordinate frame + * @function + * @param {cc.Node} node + * @return {cc.rect} + */ cc.EditBox.getRect = function (node) { var contentSize = node.getContentSize(); var rect = cc.rect(0, 0, contentSize.width, contentSize.height); @@ -680,11 +695,12 @@ cc.EditBox.getRect = function (node) { /** * create a edit box with size and background-color or - * @deprecated + * @deprecated since v3.0, please use new cc.EditBox(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) instead * @param {cc.Size} size * @param {cc.Scale9Sprite } normal9SpriteBg * @param {cc.Scale9Sprite } [press9SpriteBg] * @param {cc.Scale9Sprite } [disabled9SpriteBg] + * @return {cc.EditBox} */ cc.EditBox.create = function (size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) { return new cc.EditBox(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg); diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index b13047b056..3e12b701de 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -24,8 +24,8 @@ ****************************************************************************/ /** * the DOM object - * @class - * @type {Object} + * @namespace + * @name */ cc.DOM = {}; @@ -609,7 +609,7 @@ cc.DOM.placeHolder = function (x) { * It currently only supports cc.Sprite and cc.MenuItem * @function * @param {cc.Sprite|cc.MenuItem|Array} nodeObject - * * @example + * @example * // example * cc.DOM.convert(Sprite1, Sprite2, Menuitem); * From 70c4c9b44a9c6d858f35b16c068801e0d46a046c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 28 Aug 2014 14:40:50 +0800 Subject: [PATCH 0566/1564] Issue #5829: adds jsDocs to spine. --- extensions/cocostudio/reader/GUIReader.js | 2 +- extensions/spine/CCSkeleton.js | 217 ++++++++++++++++++---- extensions/spine/CCSkeletonAnimation.js | 108 +++++++++-- tools/jsdoc_toolkit/build.xml | 2 + 4 files changed, 281 insertions(+), 48 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 708ca8987d..e1184bc5e4 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -129,7 +129,7 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ }, /** - * create uiWidget from a josn file that exported by cocostudio UI editor + * create uiWidget from a josn file that exported by cocostudio UI editor * @param {String} fileName * @returns {ccui.Widget} */ diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 4c92b9381e..4990e727ef 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -24,8 +24,18 @@ THE SOFTWARE. ****************************************************************************/ +/** + * The main namespace of Spine, all classes, functions, properties and constants of Spine are defined in this namespace + * @namespace + * @name sp + */ var sp = sp || {}; +/** + * The vertex index of spine. + * @constant + * @type {{X1: number, Y1: number, X2: number, Y2: number, X3: number, Y3: number, X4: number, Y4: number}} + */ sp.VERTEX_INDEX = { X1: 0, Y1: 1, @@ -37,13 +47,28 @@ sp.VERTEX_INDEX = { Y4: 7 }; +/** + * The attachment type of spine. It contains three type: REGION(0), BOUNDING_BOX(1) and REGION_SEQUENCE(2). + * @constant + * @type {{REGION: number, BOUNDING_BOX: number, REGION_SEQUENCE: number}} + */ sp.ATTACHMENT_TYPE = { REGION: 0, BOUNDING_BOX: 1, REGION_SEQUENCE: 2 }; -sp.Skeleton = cc.Node.extend({ +/** + *

    + * The skeleton of Spine.
    + * Skeleton has a reference to a SkeletonData and stores the state for skeleton instance, + * which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible.
    + * Multiple skeletons can use the same SkeletonData (which includes all animations, skins, and attachments).
    + *

    + * @class + * @extends cc.Node + */ +sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ _skeleton: null, _rootBone: null, _timeScale: 1, @@ -53,10 +78,23 @@ sp.Skeleton = cc.Node.extend({ _ownsSkeletonData: null, _atlas: null, _blendFunc: null, - ctor:function(){ + + /** + * The constructor of sp.Skeleton. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + */ + ctor:function(skeletonDataFile, atlasFile, scale){ cc.Node.prototype.ctor.call(this); this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; + + if(arguments.length === 0) + this.init(); + else + this.initWithArgs(skeletonDataFile, atlasFile, scale); }, + + /** + * Initializes a sp.Skeleton. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + */ init: function () { cc.Node.prototype.init.call(this); this.setOpacityModifyRGB(true); @@ -66,21 +104,40 @@ sp.Skeleton = cc.Node.extend({ this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); this.scheduleUpdate(); }, - setDebugSolots:function(v){ - this._debugSlots = v; + + /** + * Sets whether open debug solots. + * @param {boolean} enable true to open, false to close. + */ + setDebugSolots:function(enable){ + this._debugSlots = enable; }, - setDebugBones:function(v){ - this._debugBones = v; + /** + * Sets whether open debug bones. + * @param {boolean} enable + */ + setDebugBones:function(enable){ + this._debugBones = enable; }, + /** + * Sets the time scale of sp.Skeleton. + * @param {Number} v + */ setTimeScale:function(v){ this._timeScale = v; }, - initWithArgs: function (/*multi arguments*/) { - var argSkeletonFile = arguments[0], argAtlasFile = arguments[1], - skeletonData, atlas, scale, ownsSkeletonData; + /** + * Initializes sp.Skeleton with Data. + * @param {spine.SkeletonData|String} skeletonDataFile + * @param {String|spine.Atlas|spine.SkeletonData} atlasFile atlas filename or atlas data or owns SkeletonData + * @param {Number} [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations. + */ + initWithArgs: function (skeletonDataFile, atlasFile, scale) { + var argSkeletonFile = skeletonDataFile, argAtlasFile = atlasFile, + skeletonData, atlas, ownsSkeletonData; if (typeof argSkeletonFile == 'string') { if (typeof argAtlasFile == 'string') { @@ -88,9 +145,9 @@ sp.Skeleton = cc.Node.extend({ sp._atlasLoader.setAtlasFile(argAtlasFile); atlas = new spine.Atlas(data, sp._atlasLoader); } else { - atlas = arguments[1]; + atlas = atlasFile; } - scale = arguments[2] || 1 / cc.director.getContentScaleFactor(); + scale = scale || 1 / cc.director.getContentScaleFactor(); var attachmentLoader = new spine.AtlasAttachmentLoader(atlas); var skeletonJsonReader = new spine.SkeletonJson(attachmentLoader); @@ -101,13 +158,17 @@ sp.Skeleton = cc.Node.extend({ atlas.dispose(skeletonJsonReader); ownsSkeletonData = true; } else { - skeletonData = arguments[0]; - ownsSkeletonData = arguments[1]; + skeletonData = skeletonDataFile; + ownsSkeletonData = atlasFile; } this.setSkeletonData(skeletonData, ownsSkeletonData); this.init(); }, + /** + * Returns the bounding box of sp.Skeleton. + * @returns {cc.Rect} + */ boundingBox: function () { var minX = cc.FLT_MAX, minY = cc.FLT_MAX, maxX = cc.FLT_MIN, maxY = cc.FLT_MIN; var scaleX = this.getScaleX(), scaleY = this.getScaleY(), vertices = [], @@ -118,7 +179,7 @@ sp.Skeleton = cc.Node.extend({ if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) continue; var attachment = slot.attachment; - sp.regionAttachment_computeWorldVertices(attachment, slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); + sp._regionAttachment_computeWorldVertices(attachment, slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); minX = Math.min(minX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); minY = Math.min(minY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY); maxX = Math.max(maxX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); @@ -127,39 +188,102 @@ sp.Skeleton = cc.Node.extend({ var position = this.getPosition(); return cc.rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY); }, + + /** + * Computes the world SRT from the local SRT for each bone. + */ updateWorldTransform: function () { this._skeleton.updateWorldTransform(); }, + + /** + * Sets the bones and slots to the setup pose. + */ setToSetupPose: function () { this._skeleton.setToSetupPose(); }, + + /** + * Sets the bones to the setup pose, using the values from the `BoneData` list in the `SkeletonData`. + */ setBonesToSetupPose: function () { this._skeleton.setBonesToSetupPose(); }, + + /** + * Sets the slots to the setup pose, using the values from the `SlotData` list in the `SkeletonData`. + */ setSlotsToSetupPose: function () { this._skeleton.setSlotsToSetupPose(); }, + + /** + * Finds a bone by name. This does a string comparison for every bone. + * @param {String} boneName + * @returns {spine.Bone} + */ findBone: function (boneName) { return this._skeleton.findBone(boneName); }, + + /** + * Finds a slot by name. This does a string comparison for every slot. + * @param {String} slotName + * @returns {spine.Slot} + */ findSlot: function (slotName) { return this._skeleton.findSlot(slotName); }, + + /** + * Finds a skin by name and makes it the active skin. This does a string comparison for every skin. Note that setting the skin does not change which attachments are visible. + * @param {string} skinName + * @returns {spine.Skin} + */ setSkin: function (skinName) { return this._skeleton.setSkinByName(skinName); }, + + /** + * Returns the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin. + * @param {String} slotName + * @param {String} attachmentName + * @returns {spine.RegionAttachment|spine.BoundingBoxAttachment} + */ getAttachment: function (slotName, attachmentName) { return this._skeleton.getAttachmentBySlotName(slotName, attachmentName); }, + + /** + * Sets the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin. + * @param {String} slotName + * @param {String} attachmentName + */ setAttachment: function (slotName, attachmentName) { - return this._skeleton.setAttachment(slotName, attachmentName); + this._skeleton.setAttachment(slotName, attachmentName); }, - setOpacityModifyRGB: function (v) { - this._premultipliedAlpha = v; + + /** + * Sets the premultiplied alpha value to sp.Skeleton. + * @param {Number} alpha + */ + setOpacityModifyRGB: function (alpha) { + this._premultipliedAlpha = alpha; }, + + /** + * Returns whether to enable premultiplied alpha. + * @returns {boolean} + */ isOpacityModifyRGB: function () { return this._premultipliedAlpha; }, + + /** + * Sets skeleton data to sp.Skeleton. + * @param {spine.SkeletonData} skeletonData + * @param {spine.SkeletonData} ownsSkeletonData + */ setSkeletonData: function (skeletonData, ownsSkeletonData) { this._skeleton = new spine.Skeleton(skeletonData); this._rootBone = this._skeleton.getRootBone(); @@ -170,9 +294,8 @@ sp.Skeleton = cc.Node.extend({ for (var i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { var slot = locSkeleton.drawOrder[i]; var attachment = slot.attachment; - if (!(attachment instanceof spine.RegionAttachment)) { + if (!(attachment instanceof spine.RegionAttachment)) continue; - } rendererObject = attachment.rendererObject; rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); var sprite = cc.Sprite.create(rendererObject.page._texture, rect, rendererObject.rotate); @@ -182,21 +305,48 @@ sp.Skeleton = cc.Node.extend({ } }, + /** + * Return the renderer of attachment. + * @param {spine.RegionAttachment|spine.BoundingBoxAttachment} regionAttachment + * @returns {cc.Node} + */ getTextureAtlas: function (regionAttachment) { return regionAttachment.rendererObject.page.rendererObject; }, + + /** + * Returns the blendFunc of sp.Skeleton. + * @returns {cc.BlendFunc} + */ getBlendFunc: function () { return this._blendFunc; }, - setBlendFunc: function (_blendFunc) { - this._blendFunc = _blendFunc; + + /** + * Sets the blendFunc of sp.Skeleton. + * @param {cc.BlendFunc|Number} src + * @param {Number} [dst] + */ + setBlendFunc: function (src, dst) { + var locBlendFunc = this._blendFunc; + if (dst === undefined) { + locBlendFunc.src = src.src; + locBlendFunc.dst = src.dst; + } else { + locBlendFunc.src = src; + locBlendFunc.dst = dst; + } }, + /** + * Update will be called automatically every frame if "scheduleUpdate" is called when the node is "live". + * @param {Number} dt Delta time since last update + */ update: function (dt) { this._skeleton.update(dt); if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - var color = this.getColor(), locSkeleton = this._skeleton; + var locSkeleton = this._skeleton; locSkeleton.updateWorldTransform(); var drawOrder = this._skeleton.drawOrder; for (var i = 0, n = drawOrder.length; i < n; i++) { @@ -227,6 +377,11 @@ sp.Skeleton = cc.Node.extend({ } }, + /** + * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function + * @function + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context + */ draw: null, _drawForWebGL: function () { @@ -389,14 +544,14 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { sp.Skeleton.prototype.draw = sp.Skeleton.prototype._drawForCanvas; } -sp.Skeleton.createWithData = function (skeletonData, ownsSkeletonData) { - var c = new sp.Skeleton(); - c.initWithArgs.apply(c, arguments); - return c; -}; - +/** + * Creates a skeleton object. + * @deprecated since v3.0, please use new sp.Skeleton(skeletonDataFile, atlasFile, scale) instead. + * @param {spine.SkeletonData|String} skeletonDataFile + * @param {String|spine.Atlas|spine.SkeletonData} atlasFile atlas filename or atlas data or owns SkeletonData + * @param {Number} [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations. + * @returns {sp.Skeleton} + */ sp.Skeleton.create = function (skeletonDataFile, atlasFile/* or atlas*/, scale) { - var c = new sp.Skeleton(); - c.initWithArgs.apply(c, arguments); - return c; + return new sp.Skeleton(skeletonDataFile, atlasFile, scale); }; \ No newline at end of file diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index 9c2b76dc15..54ce02582c 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -24,6 +24,9 @@ THE SOFTWARE. ****************************************************************************/ +/** + * @ignore + */ sp._atlasPage_createTexture_webGL = function (self, path) { var texture = cc.textureCache.addImage(path); self.rendererObject = cc.TextureAtlas.create(texture, 128); @@ -52,11 +55,10 @@ sp._atlasLoader = { sp._atlasPage_createTexture_canvas(page,texturePath); }, unload:function(obj){ - } }; -sp.regionAttachment_computeWorldVertices = function(self, x, y, bone, vertices){ +sp._regionAttachment_computeWorldVertices = function(self, x, y, bone, vertices){ var offset = self.offset; x += bone.worldX; y += bone.worldY; @@ -128,6 +130,11 @@ sp._regionAttachment_updateSlotForCanvas = function(self, slot, points) { points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2])); }; +/** + * The event type of spine skeleton animation. It contains event types: START(0), END(1), COMPLETE(2), EVENT(3). + * @constant + * @type {{START: number, END: number, COMPLETE: number, EVENT: number}} + */ sp.ANIMATION_EVENT_TYPE = { START: 0, END: 1, @@ -135,18 +142,32 @@ sp.ANIMATION_EVENT_TYPE = { EVENT: 3 }; -sp.SkeletonAnimation = sp.Skeleton.extend({ +/** + * The skeleton animation of spine. It updates animation's state and skeleton's world transform. + * @class + * @extends sp.Skeleton + * @example + * var spineBoy = new sp.SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); + * this.addChild(spineBoy, 4); + */ +sp.SkeletonAnimation = sp.Skeleton.extend(/** @lends sp.SkeletonAnimation# */{ _state: null, _target: null, _callback: null, - ctor: function (skeletonDataFile, atlasFile, scale) { - sp.Skeleton.prototype.ctor.call(this); - atlasFile && this.initWithArgs(skeletonDataFile, atlasFile, scale); - }, + + /** + * Initializes a sp.SkeletonAnimation. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @override + */ init: function () { - this._super(); + sp.Skeleton.prototype.init.call(this); this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data)); }, + + /** + * Sets animation state data to sp.SkeletonAnimation. + * @param {spine.AnimationStateData} stateData + */ setAnimationStateData: function (stateData) { var state = new spine.AnimationState(stateData); state.onStart = this._onAnimationStateStart.bind(this); @@ -155,38 +176,90 @@ sp.SkeletonAnimation = sp.Skeleton.extend({ state.onEvent = this._onAnimationStateEvent.bind(this); this._state = state; }, + + /** + * Mix applies all keyframe values, interpolated for the specified time and mixed with the current values.
    + * @param {String} fromAnimation + * @param {String} toAnimation + * @param {Number} duration + */ setMix: function (fromAnimation, toAnimation, duration) { this._state.data.setMixByName(fromAnimation, toAnimation, duration); }, + + /** + * Sets event listener of sp.SkeletonAnimation. + * @param {Object} target + * @param {Function} callback + */ setAnimationListener: function (target, callback) { this._target = target; this._callback = callback; }, + + /** + * Set the current animation. Any queued animations are cleared. + * @param {Number} trackIndex + * @param {String} name + * @param {Boolean} loop + * @returns {spine.TrackEntry|null} + */ setAnimation: function (trackIndex, name, loop) { var animation = this._skeleton.data.findAnimation(name); if (!animation) { cc.log("Spine: Animation not found: " + name); - return 0; + return null; } return this._state.setAnimation(trackIndex, animation, loop); }, + + /** + * Adds an animation to be played delay seconds after the current or last queued animation. + * @param {Number} trackIndex + * @param {String} name + * @param {Boolean} loop + * @param {Number} delay + * @returns {spine.TrackEntry|null} + */ addAnimation: function (trackIndex, name, loop, delay) { var animation = this._skeleton.data.findAnimation(name); if (!animation) { cc.log("Spine: Animation not found:" + name); - return 0; + return null; } return this._state.addAnimation(trackIndex, animation, loop, delay); }, + + /** + * Returns track entry by trackIndex. + * @param trackIndex + * @returns {spine.TrackEntry|null} + */ getCurrent: function (trackIndex) { return this._state.getCurrent(trackIndex); }, + + /** + * Clears all tracks of animation state. + */ clearTracks: function () { this._state.clearTracks(); }, + + /** + * Clears track of animation state by trackIndex. + * @param {Number} trackIndex + */ clearTrack: function (trackIndex) { this._state.clearTrack(trackIndex); }, + + /** + * Update will be called automatically every frame if "scheduleUpdate" is called when the node is "live". + * It updates animation's state and skeleton's world transform. + * @param {Number} dt Delta time since last update + * @override + */ update: function (dt) { this._super(dt); @@ -195,6 +268,7 @@ sp.SkeletonAnimation = sp.Skeleton.extend({ this._state.apply(this._skeleton); this._skeleton.updateWorldTransform(); }, + _onAnimationStateStart: function (trackIndex) { this._animationStateCallback(trackIndex, sp.ANIMATION_EVENT_TYPE.START, null, 0); }, @@ -214,12 +288,14 @@ sp.SkeletonAnimation = sp.Skeleton.extend({ } }); -sp.SkeletonAnimation.createWithData = function (skeletonData) { - var c = new sp.SkeletonAnimation(); - c.initWithArgs.apply(c, arguments); - return c; -}; - +/** + * Creates a skeleton animation object. + * @deprecated since v3.0, please use new sp.SkeletonAnimation(skeletonDataFile, atlasFile, scale) instead. + * @param {spine.SkeletonData|String} skeletonDataFile + * @param {String|spine.Atlas|spine.SkeletonData} atlasFile atlas filename or atlas data or owns SkeletonData + * @param {Number} [scale] scale can be specified on the JSON or binary loader which will scale the bone positions, image sizes, and animation translations. + * @returns {sp.Skeleton} + */ sp.SkeletonAnimation.create = function (skeletonDataFile, atlasFile/* or atlas*/, scale) { return new sp.SkeletonAnimation(skeletonDataFile, atlasFile, scale); }; \ No newline at end of file diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml index 40a9db45e4..515ac0dd82 100644 --- a/tools/jsdoc_toolkit/build.xml +++ b/tools/jsdoc_toolkit/build.xml @@ -192,6 +192,8 @@ + + From cef6a8da64095afbdf820a3a3842f3b09660f0d8 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 28 Aug 2014 15:11:24 +0800 Subject: [PATCH 0567/1564] add jsdoc comments for platform --- cocos2d/core/platform/CCClass.js | 5 +- cocos2d/core/platform/CCCommon.js | 22 +++- cocos2d/core/platform/CCEGLView.js | 88 ++++++++++--- cocos2d/core/platform/CCInputExtension.js | 2 + cocos2d/core/platform/CCInputManager.js | 89 ++++++++++++- cocos2d/core/platform/CCMacro.js | 26 +++- cocos2d/core/platform/CCSAXParser.js | 16 ++- cocos2d/core/platform/CCScreen.js | 5 + cocos2d/core/platform/CCTypes.js | 54 ++++++-- cocos2d/core/platform/CCTypesWebGL.js | 144 +++++++++++++++++++++- cocos2d/core/platform/CCVisibleRect.js | 7 +- cocos2d/core/platform/miniFramework.js | 2 +- extensions/editbox/CCdomNode.js | 2 +- 13 files changed, 417 insertions(+), 45 deletions(-) diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 41e94f09d5..d3b7bf5a11 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -34,7 +34,10 @@ */ var cc = cc || {}; -// +/** + * @namespace + * @name ClassManager + */ var ClassManager = { id : (0|(Math.random()*998)), diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index a9c3a7d7dc..40208411b8 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -38,6 +38,8 @@ cc.associateWithNative = function (jsObj, superclass) { /** * keymap + * @namespace + * @name cc.Key * @example * //Example * //to mark a keydown @@ -203,6 +205,12 @@ cc.FMT_WEBP = 4; */ cc.FMT_UNKNOWN = 5; +/** + * get image format by image data + * @function + * @param {Array} imgData + * @returns {Number} + */ cc.getImageFormatByData = function (imgData) { // if it is a png file buffer. if (imgData.length > 8 && imgData[0] == 0x89 @@ -225,10 +233,13 @@ cc.getImageFormatByData = function (imgData) { return cc.FMT_UNKNOWN; }; -// -// Another way to subclass: Using Google Closure. -// The following code was copied + pasted from goog.base / goog.inherits -// +/** + * Another way to subclass: Using Google Closure. + * The following code was copied + pasted from goog.base / goog.inherits + * @function + * @param {Function} childCtor + * @param {Function} parentCtor + */ cc.inherits = function (childCtor, parentCtor) { function tempCtor() {} tempCtor.prototype = parentCtor.prototype; @@ -242,6 +253,9 @@ cc.inherits = function (childCtor, parentCtor) { // } }; +/** + * @deprecated since v3.0, please use extend and _super + */ cc.base = function(me, opt_methodName, var_args) { var caller = arguments.callee.caller; if (caller.superClass_) { diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 6a4dad23ba..d75aa0d0a9 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -32,8 +32,8 @@ cc.TouchesIntergerDict = {}; /** * cc.view is the shared view object. - * @namespace - * @name cc.view + * @class + * @extend cc.Class */ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _delegate: null, @@ -81,6 +81,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ __resizeWithBrowserSize: false, _isAdjustViewPort: true, + /** + * Constructor of cc.EGLView + */ ctor: function () { var _t = this, d = document, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy; _t._frame = (cc.container.parentNode === d.body) ? d.documentElement : cc.container.parentNode; @@ -122,6 +125,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ this.setDesignResolutionSize(width, height, this._resolutionPolicy); }, + /** + * set whether to resize glview with browser wize + * @param {Number} enabled + */ resizeWithBrowserSize: function (enabled) { var adjustSize, _t = this; if (enabled) { @@ -141,6 +148,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ } }, + /** + * set callback function for resize + * @param {Function} callback + */ setResizeCallback: function (callback) { if (typeof callback == "function" || callback == null) { this._resizeCallback = callback; @@ -223,6 +234,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ this._initialized = true; }, + /** + * set whether to adjust view port + * @param enabled + */ adjustViewPort: function (enabled) { this._isAdjustViewPort = enabled; }, @@ -294,6 +309,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ /** * Open or close IME keyboard , subclass must implement this method. + * @param {Boolean} isOpen */ setIMEKeyboardState: function (isOpen) { }, @@ -515,6 +531,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ /** * Get whether GL_SCISSOR_TEST is enable + * @return {Boolean} */ isScissorEnabled: function () { var gl = cc._renderContext; @@ -551,6 +568,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ /** * Get the opengl view port rectangle. + * @return {cc.rect} */ getViewPortRect: function () { return this._viewPortRect; @@ -558,6 +576,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ /** * Get scale factor of the horizontal direction. + * @return {Number} */ getScaleX: function () { return this._scaleX; @@ -565,6 +584,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ /** * Get scale factor of the vertical direction. + * @return {Number} */ getScaleY: function () { return this._scaleY; @@ -572,6 +592,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ /** * Get device pixel ratio for retina display. + * @return {Number} */ getDevicePixelRatio: function() { return this._devicePixelRatio; @@ -579,6 +600,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ /** * Get the real location in view + * @param {Number} tx + * @param {Number} ty + * @param {cc.Point} relatedPos */ convertToLocationInView: function (tx, ty, relatedPos) { return {x: this._devicePixelRatio * (tx - relatedPos.left), y: this._devicePixelRatio * (relatedPos.top + relatedPos.height - ty)}; @@ -604,6 +628,11 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ } }); +/** + * @function + * @return {cc.EGLView} + * @private + */ cc.EGLView._getInstance = function () { if (!this._instance) { this._instance = this._instance || new cc.EGLView(); @@ -758,12 +787,20 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ (function () { // Container scale strategys + /** + * @class + * @extends cc.ContainerStrategy + */ var EqualToFrame = cc.ContainerStrategy.extend({ apply: function (view) { this._setupContainer(view, view._frameSize.width, view._frameSize.height); } }); + /** + * @class + * @extends cc.ContainerStrategy + */ var ProportionalToFrame = cc.ContainerStrategy.extend({ apply: function (view, designedResolution) { var frameW = view._frameSize.width, frameH = view._frameSize.height, containerStyle = cc.container.style, @@ -788,6 +825,10 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ } }); + /** + * @class + * @extends EqualToFrame + */ var EqualToWindow = EqualToFrame.extend({ preApply: function (view) { this._super(view); @@ -800,6 +841,10 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ } }); + /** + * @class + * @extends ProportionalToFrame + */ var ProportionalToWindow = ProportionalToFrame.extend({ preApply: function (view) { this._super(view); @@ -812,6 +857,10 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ } }); + /** + * @class + * @extends cc.ContainerStrategy + */ var OriginalContainer = cc.ContainerStrategy.extend({ apply: function (view) { this._setupContainer(view, cc._canvas.width, cc._canvas.height); @@ -919,6 +968,11 @@ cc.ResolutionPolicy = cc.Class.extend(/** @lends cc.ResolutionPolicy# */{ _containerStrategy: null, _contentStrategy: null, + /** + * Constructor of cc.ResolutionPolicy + * @param {cc.ContainerStrategy} containerStg + * @param {cc.ContentStrategy} contentStg + */ ctor: function (containerStg, contentStg) { this.setContainerStrategy(containerStg); this.setContentStrategy(contentStg); @@ -974,40 +1028,44 @@ cc.ResolutionPolicy = cc.Class.extend(/** @lends cc.ResolutionPolicy# */{ } }); -/* +/** * @memberOf cc.ResolutionPolicy# * @name EXACT_FIT - * @const + * @constant + * @type Number * @static * The entire application is visible in the specified area without trying to preserve the original aspect ratio.
    * Distortion can occur, and the application may appear stretched or compressed. */ cc.ResolutionPolicy.EXACT_FIT = 0; -/* +/** * @memberOf cc.ResolutionPolicy# * @name NO_BORDER - * @const + * @constant + * @type Number * @static * The entire application fills the specified area, without distortion but possibly with some cropping,
    * while maintaining the original aspect ratio of the application. */ cc.ResolutionPolicy.NO_BORDER = 1; -/* +/** * @memberOf cc.ResolutionPolicy# * @name SHOW_ALL - * @const + * @constant + * @type Number * @static * The entire application is visible in the specified area without distortion while maintaining the original
    * aspect ratio of the application. Borders can appear on two sides of the application. */ cc.ResolutionPolicy.SHOW_ALL = 2; -/* +/** * @memberOf cc.ResolutionPolicy# * @name FIXED_HEIGHT - * @const + * @constant + * @type Number * @static * The application takes the height of the design resolution size and modifies the width of the internal
    * canvas so that it fits the aspect ratio of the device
    @@ -1016,10 +1074,11 @@ cc.ResolutionPolicy.SHOW_ALL = 2; */ cc.ResolutionPolicy.FIXED_HEIGHT = 3; -/* +/** * @memberOf cc.ResolutionPolicy# * @name FIXED_WIDTH - * @const + * @constant + * @type Number * @static * The application takes the width of the design resolution size and modifies the height of the internal
    * canvas so that it fits the aspect ratio of the device
    @@ -1028,10 +1087,11 @@ cc.ResolutionPolicy.FIXED_HEIGHT = 3; */ cc.ResolutionPolicy.FIXED_WIDTH = 4; -/* +/** * @memberOf cc.ResolutionPolicy# * @name UNKNOWN - * @const + * @constant + * @type Number * @static * Unknow policy */ diff --git a/cocos2d/core/platform/CCInputExtension.js b/cocos2d/core/platform/CCInputExtension.js index 9a25d26d01..1d6c49bbcd 100644 --- a/cocos2d/core/platform/CCInputExtension.js +++ b/cocos2d/core/platform/CCInputExtension.js @@ -27,6 +27,7 @@ var _p = cc.inputManager; /** * whether enable accelerometer event + * @function * @param {Boolean} isEnable */ _p.setAccelerometerEnabled = function(isEnable){ @@ -47,6 +48,7 @@ _p.setAccelerometerEnabled = function(isEnable){ /** * set accelerometer interval value + * @function * @param {Number} interval */ _p.setAccelerometerInterval = function(interval){ diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 1b291853cc..de2f21a364 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -26,12 +26,26 @@ /** * ignore */ -cc.UIInterfaceOrientationLandscapeLeft = -90; +/** + * @constant + * @type {number} + */ +cc.UIInterfaceOrientationLandscapeLeft = -90; +/** + * @constant + * @type {number} + */ cc.UIInterfaceOrientationLandscapeRight = 90; - +/** + * @constant + * @type {number} + */ cc.UIInterfaceOrientationPortraitUpsideDown = 180; - +/** + * @constant + * @type {number} + */ cc.UIInterfaceOrientationPortrait = 0; /** @@ -91,6 +105,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ _glView: null, + /** + * @function + * @param {Array} touches + */ handleTouchesBegin: function (touches) { var selTouch, index, curTouch, touchID, handleTouches = [], locTouchIntDict = this._touchesIntegerDict; for(var i = 0, len = touches.length; i< len; i ++){ @@ -119,6 +137,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ } }, + /** + * @function + * @param {Array} touches + */ handleTouchesMove: function(touches){ var selTouch, index, touchID, handleTouches = [], locTouches = this._touches; for(var i = 0, len = touches.length; i< len; i ++){ @@ -144,6 +166,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ } }, + /** + * @function + * @param {Array} touches + */ handleTouchesEnd: function(touches){ var handleTouches = this.getSetOfTouchesEndOrCancel(touches); if(handleTouches.length > 0) { @@ -154,6 +180,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ } }, + /** + * @function + * @param {Array} touches + */ handleTouchesCancel: function(touches){ var handleTouches = this.getSetOfTouchesEndOrCancel(touches); if(handleTouches.length > 0) { @@ -164,6 +194,11 @@ cc.inputManager = /** @lends cc.inputManager# */{ } }, + /** + * @function + * @param {Array} touches + * @returns {Array} + */ getSetOfTouchesEndOrCancel: function(touches) { var selTouch, index, touchID, handleTouches = [], locTouches = this._touches, locTouchesIntDict = this._touchesIntegerDict; for(var i = 0, len = touches.length; i< len; i ++){ @@ -185,6 +220,11 @@ cc.inputManager = /** @lends cc.inputManager# */{ return handleTouches; }, + /** + * @function + * @param {HTMLElement} element + * @return {Object} + */ getHTMLElementPosition: function (element) { var docElem = document.documentElement; var win = window; @@ -216,6 +256,11 @@ cc.inputManager = /** @lends cc.inputManager# */{ }; }, + /** + * @function + * @param {cc.Touch} touch + * @return {cc.Touch} + */ getPreTouch: function(touch){ var preTouch = null; var locPreTouchPool = this._preTouchPool; @@ -231,6 +276,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ return preTouch; }, + /** + * @function + * @param {cc.Touch} touch + */ setPreTouch: function(touch){ var find = false; var locPreTouchPool = this._preTouchPool; @@ -252,6 +301,13 @@ cc.inputManager = /** @lends cc.inputManager# */{ } }, + /** + * @function + * @param {Number} tx + * @param {Number} ty + * @param {cc.Point} pos + * @return {cc.Touch} + */ getTouchByXY: function(tx, ty, pos){ var locPreTouch = this._preTouchPoint; var location = this._glView.convertToLocationInView(tx, ty, pos); @@ -262,6 +318,13 @@ cc.inputManager = /** @lends cc.inputManager# */{ return touch; }, + /** + * @function + * @param {cc.Point} location + * @param {cc.Point} pos + * @param {Number} eventType + * @returns {cc.EventMouse} + */ getMouseEvent: function(location, pos, eventType){ var locPreMouse = this._prevMousePoint; this._glView._convertMouseToLocationInView(location, pos); @@ -273,6 +336,12 @@ cc.inputManager = /** @lends cc.inputManager# */{ return mouseEvent; }, + /** + * @function + * @param {Touch} event + * @param {cc.Point} pos + * @return {cc.Point} + */ getPointByEvent: function(event, pos){ if (event.pageX != null) //not avalable in <= IE8 return {x: event.pageX, y: event.pageY}; @@ -282,6 +351,12 @@ cc.inputManager = /** @lends cc.inputManager# */{ return {x: event.clientX, y: event.clientY}; }, + /** + * @function + * @param {Touch} event + * @param {cc.Point} pos + * @returns {Array} + */ getTouchesByEvent: function(event, pos){ var touchArr = [], locView = this._glView; var touch_event, touch, preLocation; @@ -314,6 +389,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ return touchArr; }, + /** + * @function + * @param {HTMLElement} element + */ registerSystemEvent: function(element){ if(this._isRegisterEvent) return; @@ -514,6 +593,10 @@ cc.inputManager = /** @lends cc.inputManager# */{ _registerAccelerometerEvent: function(){}, + /** + * @function + * @param {Number} dt + */ update:function(dt){ if(this._accelCurTime > this._accelInterval){ this._accelCurTime -= this._accelInterval; diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 3b5d3d295d..077b3407bd 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -74,11 +74,11 @@ cc.UINT_MAX = 0xffffffff; * modified from c++ macro, you need to pass in the x and y variables names in string,
    * and then a reference to the whole object as third variable *

    - * @param x - * @param y - * @param ref + * @param {String} x + * @param {String} y + * @param {Object} ref * @function - * @deprecated + * @deprecated since v3.0 */ cc.swap = function (x, y, ref) { if ((typeof ref) == 'object' && (typeof ref.x) != 'undefined' && (typeof ref.y) != 'undefined') { @@ -149,6 +149,12 @@ cc.degreesToRadians = function (angle) { cc.radiansToDegrees = function (angle) { return angle * cc.DEG; }; +/** + * converts radians to degrees + * @param {Number} angle + * @return {Number} + * @function + */ cc.radiansToDegress = function (angle) { cc.log(cc._LogInfos.radiansToDegress); return angle * cc.DEG; @@ -249,6 +255,7 @@ cc.FLT_EPSILON = 0.0000001192092896; * On Mac it returns 1;
    * On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1 *

    + * @return {Number} * @function */ cc.contentScaleFactor = cc.IS_RETINA_DISPLAY_SUPPORTED ? function () { @@ -270,7 +277,8 @@ cc.pointPointsToPixels = function (points) { /** * Converts a Point in pixels to points - * @param {Point} pixels + * @param {cc.Rect} pixels + * @return {cc.Point} * @function */ cc.pointPixelsToPoints = function (pixels) { @@ -315,6 +323,7 @@ cc._sizePixelsToPointsOut = function (sizeInPixels, outSize) { /** * Converts a rect in pixels to points * @param {cc.Rect} pixel + * @return {cc.Rect} * @function */ cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ? function (pixel) { @@ -328,6 +337,7 @@ cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ? function (pixel) { /** * Converts a rect in points to pixels * @param {cc.Rect} point + * @return {cc.Rect} * @function */ cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function (point) { @@ -416,6 +426,10 @@ cc.ONE_MINUS_CONSTANT_ALPHA = 0x8004; */ cc.ONE_MINUS_CONSTANT_COLOR = 0x8002; +/** + * Check webgl error.Error will be shown in console if exists. + * @function + */ cc.checkGLErrorDebug = function () { if (cc.renderMode == cc._RENDER_TYPE_WEBGL) { var _error = cc._renderContext.getError(); @@ -777,7 +791,7 @@ cc.arrayAppendObjectsToIndex = function(arr, addObjs,index){ /** * Copy an array's item to a new array (its performance is better than Array.slice) * @param {Array} arr - * @returns {Array} + * @return {Array} */ cc.copyArray = function(arr){ var i, len = arr.length, arr_clone = new Array(len); diff --git a/cocos2d/core/platform/CCSAXParser.js b/cocos2d/core/platform/CCSAXParser.js index f3e8e57ba0..4100a49cc0 100644 --- a/cocos2d/core/platform/CCSAXParser.js +++ b/cocos2d/core/platform/CCSAXParser.js @@ -26,13 +26,16 @@ /** * A SAX Parser - * @namespace - * @name cc.saxParser + * @class + * @extends cc.Class */ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ _parser: null, _isSupportDOMParser: null, + /** + * Constructor of cc.SAXParser + */ ctor: function () { if (window.DOMParser) { this._isSupportDOMParser = true; @@ -42,6 +45,11 @@ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ } }, + /** + * @function + * @param {String} xmlTxt + * @return {Document} + */ parse : function(xmlTxt){ return this._parseXML(xmlTxt); }, @@ -65,8 +73,8 @@ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ /** * * A plist Parser - * @namespace - * @name cc.plistParser + * @class + * @extends cc.SAXParser */ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index d1661cfcff..89f1ddb8f8 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -75,6 +75,10 @@ cc.screen = /** @lends cc.screen# */{ ] ], + /** + * initialize + * @function + */ init: function () { this._fn = {}; var i, val, map = this._fnMap, valL; @@ -124,6 +128,7 @@ cc.screen = /** @lends cc.screen# */{ /** * exit the full mode. + * @return {Boolean} */ exitFullScreen: function () { return this._supportsFullScreen ? document[ this._fn.exitFullscreen ]() : true; diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 5e14843fc9..ecf4f8f977 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -24,6 +24,14 @@ THE SOFTWARE. ****************************************************************************/ +/** + * @class cc.Color + * @param {Number} r + * @param {Number} g + * @param {Number} b + * @param {Number} a + * @constructor + */ cc.Color = function (r, g, b, a) { this.r = r || 0; this.g = g || 0; @@ -46,13 +54,11 @@ cc.Color = function (r, g, b, a) { * * Alpha channel is optional. Default value is 255 * - * @class cc.Color - * @constructor * @param {Number|String|cc.Color} r * @param {Number} g * @param {Number} b * @param {Number} [a=255] - * @returns {cc.Color} + * @return {cc.Color} */ cc.color = function (r, g, b, a) { if (r === undefined) @@ -77,6 +83,12 @@ cc.colorEqual = function (color1, color2) { /** * the device accelerometer reports values for each axis in units of g-force + * @class cc.Acceleration + * @constructor + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {Number} timestamp */ cc.Acceleration = function (x, y, z, timestamp) { this.x = x || 0; @@ -85,6 +97,12 @@ cc.Acceleration = function (x, y, z, timestamp) { this.timestamp = timestamp || 0; }; +/** + * @class cc.Vertex2F + * @constructor + * @param {Number} x1 + * @param {Number} y1 + */ cc.Vertex2F = function (x1, y1) { this.x = x1 || 0; this.y = y1 || 0; @@ -92,8 +110,7 @@ cc.Vertex2F = function (x1, y1) { /** * Helper macro that creates an Vertex2F type composed of 2 floats: x, y - * @class cc.Vertex2F - * @constructor + * @function * @param {Number} x * @param {Number} y * @return {cc.Vertex2F} @@ -102,6 +119,13 @@ cc.vertex2 = function (x, y) { return new cc.Vertex2F(x, y); }; +/** + * @class cc.Vertex3F + * @constructor + * @param {Number} x1 + * @param {Number} y1 + * @param {Number} z1 + */ cc.Vertex3F = function (x1, y1, z1) { this.x = x1 || 0; this.y = y1 || 0; @@ -110,8 +134,7 @@ cc.Vertex3F = function (x1, y1, z1) { /** * Helper macro that creates an Vertex3F type composed of 3 floats: x, y, z - * @class cc.Vertex3F - * @constructor + * @function * @param {Number} x * @param {Number} y * @param {Number} z @@ -121,6 +144,12 @@ cc.vertex3 = function (x, y, z) { return new cc.Vertex3F(x, y, z); }; +/** + * @class cc.Tex2F + * @constructor + * @param {Number} u1 + * @param {Number} v1 + */ cc.Tex2F = function (u1, v1) { this.u = u1 || 0; this.v = v1 || 0; @@ -128,8 +157,7 @@ cc.Tex2F = function (u1, v1) { /** * Helper macro that creates an Tex2F type: A texcoord composed of 2 floats: u, y - * @class cc.Tex2F - * @constructor + * @function * @param {Number} u * @param {Number} v * @return {cc.Tex2F} @@ -150,6 +178,10 @@ cc.BlendFunc = function (src1, dst1) { this.dst = dst1; }; +/** + * @function + * @returns {cc.BlendFunc} + */ cc.blendFuncDisable = function () { return new cc.BlendFunc(cc.ONE, cc.ZERO); }; @@ -304,6 +336,10 @@ cc._Dictionary = cc.Class.extend({ } }); +/** + * @class cc.FontDefinition + * @constructor + */ cc.FontDefinition = function () { var _t = this; _t.fontName = "Arial"; diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index 1e0ded857e..97a54b9b36 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -29,6 +29,16 @@ cc._tmp = cc._tmp || {}; cc._tmp.WebGLColor = function () { //redefine some types with ArrayBuffer for WebGL + /** + * @class cc.Color + * @param {Number} r + * @param {Number}g + * @param {Number} b + * @param {Number} a + * @param {Array} arrayBuffer + * @param {Number} offset + * @returns {cc.Color} + */ cc.color = function (r, g, b, a, arrayBuffer, offset) { if (r === undefined) return new cc.Color(0, 0, 0, 255, arrayBuffer, offset); @@ -41,6 +51,16 @@ cc._tmp.WebGLColor = function () { return new cc.Color(r, g, b, a, arrayBuffer, offset); }; //redefine cc.Color + /** + * @class cc.Color + * @param {Number} r + * @param {Number}g + * @param {Number} b + * @param {Number} a + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.Color = function (r, g, b, a, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -60,6 +80,10 @@ cc._tmp.WebGLColor = function () { this.a_undefined = true; } }; + /** + * @constant + * @type {number} + */ cc.Color.BYTES_PER_ELEMENT = 4; var _p = cc.Color.prototype; @@ -103,6 +127,14 @@ cc._tmp.WebGLColor = function () { //redefine cc.Vertex2F + /** + * @class cc.Vertex2F + * @param {Number} x + * @param {Number}y + * @param {Array} arrayBuffer + * @param {Number}offset + * @constructor + */ cc.Vertex2F = function (x, y, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -112,6 +144,10 @@ cc._tmp.WebGLColor = function () { this._xF32[0] = x || 0; this._yF32[0] = y || 0; }; + /** + * @constant + * @type {number} + */ cc.Vertex2F.BYTES_PER_ELEMENT = 8; Object.defineProperties(cc.Vertex2F.prototype, { x: { @@ -135,6 +171,15 @@ cc._tmp.WebGLColor = function () { }); // redefine cc.Vertex3F + /** + * @class cc.Vertex3F + * @param {Number} x + * @param {Number} y + * @param {Number}z + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.Vertex3F = function (x, y, z, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -147,6 +192,10 @@ cc._tmp.WebGLColor = function () { this._zF32 = new Float32Array(locArrayBuffer, locOffset + Float32Array.BYTES_PER_ELEMENT * 2, 1); this._zF32[0] = z || 0; }; + /** + * @constant + * @type {number} + */ cc.Vertex3F.BYTES_PER_ELEMENT = 12; Object.defineProperties(cc.Vertex3F.prototype, { x: { @@ -179,6 +228,14 @@ cc._tmp.WebGLColor = function () { }); // redefine cc.Tex2F + /** + * @class cc.Tex2F + * @param {Number} u + * @param {Number} v + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.Tex2F = function (u, v, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -188,6 +245,10 @@ cc._tmp.WebGLColor = function () { this._uF32[0] = u || 0; this._vF32[0] = v || 0; }; + /** + * @constants + * @type {number} + */ cc.Tex2F.BYTES_PER_ELEMENT = 8; Object.defineProperties(cc.Tex2F.prototype, { u: { @@ -211,6 +272,16 @@ cc._tmp.WebGLColor = function () { }); //redefine cc.Quad2 + /** + * @class cc.Quad2 + * @param {cc.Vertex2F} tl + * @param {cc.Vertex2F} tr + * @param {cc.Vertex2F} bl + * @param {cc.Vertex2F} br + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.Quad2 = function (tl, tr, bl, br, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -221,11 +292,15 @@ cc._tmp.WebGLColor = function () { this._bl = bl ? new cc.Vertex2F(bl.x, bl.y, locArrayBuffer, locElementLen * 2) : new cc.Vertex2F(0, 0, locArrayBuffer, locElementLen * 2); this._br = br ? new cc.Vertex2F(br.x, br.y, locArrayBuffer, locElementLen * 3) : new cc.Vertex2F(0, 0, locArrayBuffer, locElementLen * 3); }; + /** + * @constant + * @type {number} + */ cc.Quad2.BYTES_PER_ELEMENT = 32; /** * A 3D Quad. 4 * 3 floats - * @Class + * @Class cc.Quad3 * @Construct * @param {cc.Vertex3F} bl1 * @param {cc.Vertex3F} br1 @@ -283,6 +358,15 @@ cc._tmp.WebGLColor = function () { }); //redefine cc.V3F_C4B_T2F + /** + * @class cc.V3F_C4B_T2F + * @param {cc.Vertex3F} vertices + * @param { cc.color} colors + * @param {cc.Tex2F} texCoords + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.V3F_C4B_T2F = function (vertices, colors, texCoords, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -295,6 +379,10 @@ cc._tmp.WebGLColor = function () { this._texCoords = texCoords ? new cc.Tex2F(texCoords.u, texCoords.v, locArrayBuffer, locOffset + locElementLen + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, locArrayBuffer, locOffset + locElementLen + cc.Color.BYTES_PER_ELEMENT); }; + /** + * @constant + * @type {number} + */ cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24; Object.defineProperties(cc.V3F_C4B_T2F.prototype, { vertices: { @@ -335,6 +423,16 @@ cc._tmp.WebGLColor = function () { }); //redefine cc.V3F_C4B_T2F_Quad + /** + * @cc.class cc.V3F_C4B_T2F_Quad + * @param {cc.V3F_C4B_T2F} tl + * @param {cc.V3F_C4B_T2F} bl + * @param {cc.V3F_C4B_T2F} tr + * @param {cc.V3F_C4B_T2F} br + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.V3F_C4B_T2F_Quad = function (tl, bl, tr, br, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -349,6 +447,10 @@ cc._tmp.WebGLColor = function () { this._br = br ? new cc.V3F_C4B_T2F(br.vertices, br.colors, br.texCoords, locArrayBuffer, locOffset + locElementLen * 3) : new cc.V3F_C4B_T2F(null, null, null, locArrayBuffer, locOffset + locElementLen * 3); }; + /** + * @constant + * @type {number} + */ cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96; Object.defineProperties(cc.V3F_C4B_T2F_Quad.prototype, { tl: { @@ -406,10 +508,19 @@ cc._tmp.WebGLColor = function () { enumerable: true } }); + /** + * @function + * @returns {cc.V3F_C4B_T2F_Quad} + */ cc.V3F_C4B_T2F_QuadZero = function () { return new cc.V3F_C4B_T2F_Quad(); }; + /** + * @function + * @param {cc.V3F_C4B_T2F_Quad} sourceQuad + * @return {cc.V3F_C4B_T2F_Quad} + */ cc.V3F_C4B_T2F_QuadCopy = function (sourceQuad) { if (!sourceQuad) return cc.V3F_C4B_T2F_QuadZero(); @@ -432,6 +543,11 @@ cc._tmp.WebGLColor = function () { }; }; + /** + * @function + * @param {Array} sourceQuads + * @returns {Array} + */ cc.V3F_C4B_T2F_QuadsCopy = function (sourceQuads) { if (!sourceQuads) return []; @@ -444,6 +560,15 @@ cc._tmp.WebGLColor = function () { }; //redefine cc.V2F_C4B_T2F + /** + * @class cc.V2F_C4B_T2F + * @param {new cc.Vertex2F} vertices + * @param {cc.color} colors + * @param {cc.Tex2F} texCoords + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.V2F_C4B_T2F = function (vertices, colors, texCoords, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -456,6 +581,10 @@ cc._tmp.WebGLColor = function () { this._texCoords = texCoords ? new cc.Tex2F(texCoords.u, texCoords.v, locArrayBuffer, locOffset + locElementLen + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, locArrayBuffer, locOffset + locElementLen + cc.Color.BYTES_PER_ELEMENT); }; + /** + * @constant + * @type {number} + */ cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20; Object.defineProperties(cc.V2F_C4B_T2F.prototype, { vertices: { @@ -494,6 +623,15 @@ cc._tmp.WebGLColor = function () { }); //redefine cc.V2F_C4B_T2F_Triangle + /** + * @class cc.V2F_C4B_T2F_Triangle + * @param {cc.V2F_C4B_T2F} a + * @param {cc.V2F_C4B_T2F} b + * @param {cc.V2F_C4B_T2F} c + * @param {Array} arrayBuffer + * @param {Number} offset + * @constructor + */ cc.V2F_C4B_T2F_Triangle = function (a, b, c, arrayBuffer, offset) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT); this._offset = offset || 0; @@ -506,6 +644,10 @@ cc._tmp.WebGLColor = function () { this._c = c ? new cc.V2F_C4B_T2F(c.vertices, c.colors, c.texCoords, locArrayBuffer, locOffset + locElementLen * 2) : new cc.V2F_C4B_T2F(null, null, null, locArrayBuffer, locOffset + locElementLen * 2); }; + /** + * @constant + * @type {number} + */ cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60; Object.defineProperties(cc.V2F_C4B_T2F_Triangle.prototype, { a: { diff --git a/cocos2d/core/platform/CCVisibleRect.js b/cocos2d/core/platform/CCVisibleRect.js index e33672a4a1..a7672dec0e 100644 --- a/cocos2d/core/platform/CCVisibleRect.js +++ b/cocos2d/core/platform/CCVisibleRect.js @@ -40,7 +40,8 @@ * @property {Number} width - Width of the screen * @property {Number} height - Height of the screen * - * @type Object + * @namespace + * @name cc.visibleRect */ cc.visibleRect = { topLeft:cc.p(0,0), @@ -55,6 +56,10 @@ cc.visibleRect = { width:0, height:0, + /** + * initialize + * @param {cc.Rect} visibleRect + */ init:function(visibleRect){ var w = this.width = visibleRect.width; var h = this.height = visibleRect.height; diff --git a/cocos2d/core/platform/miniFramework.js b/cocos2d/core/platform/miniFramework.js index daea2d3638..9b4d3e05bd 100644 --- a/cocos2d/core/platform/miniFramework.js +++ b/cocos2d/core/platform/miniFramework.js @@ -28,7 +28,7 @@ * the dollar sign, classic like jquery, this selector add extra methods to HTMLElement without touching its prototype
    * it is also chainable like jquery * @param {HTMLElement|String} x pass in a css selector in string or the whole HTMLElement - * @class + * @function * @return {cc.$} */ cc.$ = function (x) { diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index 3e12b701de..2fb5bd47af 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -25,7 +25,7 @@ /** * the DOM object * @namespace - * @name + * @name cc.DOM */ cc.DOM = {}; From 3ae6bbaf6099669b460438c038efcabfbb1098f5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 28 Aug 2014 16:00:53 +0800 Subject: [PATCH 0568/1564] Issue #5829: correct some jsDoc mistakes. --- cocos2d/core/CCDirector.js | 55 ++++++++++++++++--- cocos2d/transitions/CCTransitionProgress.js | 4 +- extensions/ccui/uiwidgets/UITextField.js | 27 ++------- extensions/cocostudio/CocoStudio.js | 3 +- .../control-extension/CCControlHuePicker.js | 6 +- .../CCControlSaturationBrightnessPicker.js | 12 ++-- .../gui/control-extension/CCControlStepper.js | 7 +-- .../gui/control-extension/CCScale9Sprite.js | 2 +- extensions/gui/scrollview/CCTableView.js | 2 +- 9 files changed, 70 insertions(+), 48 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 85ad9a6756..e6ac734b17 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -736,9 +736,48 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ } }); +/** + * The event projection changed of cc.Director + * @constant + * @type {string} + * @example + * cc.eventManager.addCustomListener(cc.Director.EVENT_PROJECTION_CHANGED, function(event) { + * cc.log("Projection changed."); + * }); + */ cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed"; + +/** + * The event after draw of cc.Director + * @constant + * @type {string} + * @example + * cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_DRAW, function(event) { + * cc.log("after draw event."); + * }); + */ cc.Director.EVENT_AFTER_DRAW = "director_after_draw"; + +/** + * The event after visit of cc.Director + * @constant + * @type {string} + * @example + * cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_VISIT, function(event) { + * cc.log("after visit event."); + * }); + */ cc.Director.EVENT_AFTER_VISIT = "director_after_visit"; + +/** + * The event after update of cc.Director + * @constant + * @type {string} + * @example + * cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_UPDATE, function(event) { + * cc.log("after update event."); + * }); + */ cc.Director.EVENT_AFTER_UPDATE = "director_after_update"; /*************************************************** @@ -808,30 +847,30 @@ cc.defaultFPS = 60; //Possible OpenGL projections used by director /** - * sets a 2D projection (orthogonal projection) + * The flag 2D projection of cc.Director (orthogonal projection) * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_2D = 0; /** - * sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500. + * The flag 3D projection with a fovy=60, znear=0.5f and zfar=1500. * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_3D = 1; /** - * it calls "updateProjection" on the projection delegate. + * The flag custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_CUSTOM = 3; /** - * Default projection is 3D projection + * The flag default projection of cc.Director, Default projection is 3D projection * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D; diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index 7a26a54813..8ab4f3216a 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -369,7 +369,7 @@ cc.TransitionProgressVertical.create = function (t, scene) { cc.TransitionProgressInOut = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressInOut# */{ /** - * @constructor + * The constructor of cc.TransitionProgressInOut. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} t time * @param {cc.Scene} scene */ @@ -425,7 +425,7 @@ cc.TransitionProgressInOut.create = function (t, scene) { cc.TransitionProgressOutIn = cc.TransitionProgress.extend(/** @lends cc.TransitionProgressOutIn# */{ /** - * @constructor + * The constructor of cc.TransitionProgressOutIn. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {Number} t time * @param {cc.Scene} scene */ diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 87cb4f8dbd..80ff8c504a 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -775,22 +775,17 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ /** * Creates a ccui.TextField. + * @deprecated since v3.0, please use new ccui.TextField() instead. * @param {String} placeholder * @param {String} fontName * @param {Number} fontSize * @returns {ccui.TextField} + * @example + * // example + * var uiTextField = ccui.TextField.create(); */ ccui.TextField.create = function(placeholder, fontName, fontSize){ - var widget = new ccui.TextField(placeholder, fontName, fontSize); - if (widget && widget.init()) { - if(placeholder && fontName && fontSize){ - widget.setPlaceHolder(placeholder); - widget.setFontName(fontName); - widget.setFontSize(fontSize); - } - return widget; - } - return null; + return new ccui.TextField(placeholder, fontName, fontSize); }; var _p = ccui.TextField.prototype; @@ -823,18 +818,6 @@ cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswor _p = null; -/** - * allocates and initializes a UITextField. - * @deprecated since v3.0, please use new ccui.TextField() instead. - * @return {ccui.TextField} - * @example - * // example - * var uiTextField = ccui.TextField.create(); - */ -ccui.TextField.create = function () { - return new ccui.TextField(); -}; - // Constants //TextField event /** diff --git a/extensions/cocostudio/CocoStudio.js b/extensions/cocostudio/CocoStudio.js index 10b70186af..fdb2ddcea8 100644 --- a/extensions/cocostudio/CocoStudio.js +++ b/extensions/cocostudio/CocoStudio.js @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ /** - * Base namespace of cocostuidio + * The main namespace of Cocostudio, all classes, functions, properties and constants of Spine are defined in this namespace * @namespace * @name ccs */ @@ -62,6 +62,7 @@ ccs.Component.extend = ccs.Component.extend || cc.Component.extend; /** * CocoStudio version + * @constant * @type {string} */ ccs.cocostudioVersion = "v1.3.0.0"; \ No newline at end of file diff --git a/extensions/gui/control-extension/CCControlHuePicker.js b/extensions/gui/control-extension/CCControlHuePicker.js index 5a425a3201..9c002740f4 100644 --- a/extensions/gui/control-extension/CCControlHuePicker.js +++ b/extensions/gui/control-extension/CCControlHuePicker.js @@ -52,9 +52,9 @@ cc.ControlHuePicker = cc.Control.extend(/** @lends cc.ControlHuePicker# */{ _className:"ControlHuePicker", /** - * @constructor - * @param target - * @param pos + * The constructor of cc.ControlHuePicker + * @param {cc.Node} target + * @param {cc.Point} pos position */ ctor:function(target, pos) { cc.Control.prototype.ctor.call(this); diff --git a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js index 15110a4f3c..a9045c43d0 100644 --- a/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js +++ b/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js @@ -60,9 +60,9 @@ cc.ControlSaturationBrightnessPicker = cc.Control.extend(/** @lends cc.ControlSa _className:"ControlSaturationBrightnessPicker", /** - * @constructor - * @param target - * @param pos + * The constructor of cc.ControlSaturationBrightnessPicker + * @param {cc.Node} target + * @param {cc.Point} pos position */ ctor:function (target, pos) { cc.Control.prototype.ctor.call(this); @@ -247,9 +247,9 @@ cc.defineGetterSetter(_p, "startPos", _p.getStartPos); _p = null; /** - * @constructor - * @param target - * @param pos + * Creates a cc.ControlSaturationBrightnessPicker + * @param {cc.Node} target + * @param {cc.Point} pos position * @returns {ControlSaturationBrightnessPicker} */ cc.ControlSaturationBrightnessPicker.create = function (target, pos) { diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js index e681ff72de..ae5599f5b7 100644 --- a/extensions/gui/control-extension/CCControlStepper.js +++ b/extensions/gui/control-extension/CCControlStepper.js @@ -379,11 +379,10 @@ cc.defineGetterSetter(_p, "plusLabel", _p.getPlusLabel, _p.setPlusLabel); _p = null; - /** - * @constructor - * @param minusSprite - * @param plusSprite + * Creates a cc.ControlStepper + * @param {cc.Sprite} minusSprite + * @param {cc.Sprite} plusSprite * @returns {ControlStepper} */ cc.ControlStepper.create = function (minusSprite, plusSprite) { diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index d713123a35..0d251496ef 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -231,7 +231,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, /** - * @constructor + * The constructor of cc.Scale9Sprite. Override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame * @param {cc.Rect} rect * @param {cc.Rect} capInsets diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js index 24176eb5e2..8ea6ee7b2b 100644 --- a/extensions/gui/scrollview/CCTableView.js +++ b/extensions/gui/scrollview/CCTableView.js @@ -196,7 +196,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ _touchedCell:null, /** - * @constructor + * The * @param dataSource * @param size * @param container From 926a37e4a38c8cb9ba79535490b6dd1e1d75071b Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 28 Aug 2014 16:17:31 +0800 Subject: [PATCH 0569/1564] Doc #5829: Improve inline docs for CCClass, CCCommon, CCConfig, CCEGLView --- cocos2d/core/platform/CCClass.js | 7 +- cocos2d/core/platform/CCCommon.js | 41 +++++----- cocos2d/core/platform/CCConfig.js | 78 ++++++++++-------- cocos2d/core/platform/CCEGLView.js | 125 +++++++++++++++++++---------- 4 files changed, 147 insertions(+), 104 deletions(-) diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index d3cb259575..b7739d7385 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -99,6 +99,7 @@ ClassManager.compileSuper.ClassManager = ClassManager; /** * Create a new Class that inherits from this Class + * @static * @param {object} props * @return {function} */ @@ -283,10 +284,10 @@ cc.defineGetterSetter = function (proto, prop, getter, setter, getterName, sette }; /** - * copy an new object + * Create a new object and copy all properties in an exist object to the new object * @function - * @param {object|Array} obj source object - * @return {Array|object} + * @param {object|Array} obj The source object + * @return {Array|object} The created object */ cc.clone = function (obj) { // Cloning is better if the new object is having the same prototype chain diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index a9c3a7d7dc..0895cc495e 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -37,24 +37,19 @@ cc.associateWithNative = function (jsObj, superclass) { }; /** - * keymap - * @example - * //Example - * //to mark a keydown - * cc.keyDown[65] = true; - * //or - * cc.keyMap[cc.KEY.a] - * - * //to mark a keyup - * do cc.keyDown[65] = false; + * Key map for keyboard event * - * //to find out if a key is down, check - * if(cc.keyDown[65]) - * //or - * if,(cc.keyDown[cc.KEY.space]) - * //if its undefined or false or null, its not pressed * @constant - * @type object + * @type {Object} + * @example + cc.eventManager.addListener({ + event: cc.EventListener.KEYBOARD, + onKeyPressed: function(keyCode, event){ + if (cc.KEY["a"] == keyCode) { + cc.log("A is pressed"); + } + } + }, this); */ cc.KEY = { backspace:8, @@ -164,46 +159,46 @@ cc.KEY = { /** * Image Format:JPG * @constant - * @type Number + * @type {Number} */ cc.FMT_JPG = 0; /** * Image Format:PNG * @constant - * @type Number + * @type {Number} */ cc.FMT_PNG = 1; /** * Image Format:TIFF * @constant - * @type Number + * @type {Number} */ cc.FMT_TIFF = 2; /** * Image Format:RAWDATA * @constant - * @type Number + * @type {Number} */ cc.FMT_RAWDATA = 3; /** * Image Format:WEBP * @constant - * @type Number + * @type {Number} */ cc.FMT_WEBP = 4; /** * Image Format:UNKNOWN * @constant - * @type Number + * @type {Number} */ cc.FMT_UNKNOWN = 5; -cc.getImageFormatByData = function (imgData) { +cc._getImageFormatByData = function (imgData) { // if it is a png file buffer. if (imgData.length > 8 && imgData[0] == 0x89 && imgData[1] == 0x50 diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index e53e154939..758349e22e 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -25,15 +25,13 @@ ****************************************************************************/ /** - *

    - * The current version of Cocos2d-html5 being used.
    + * The current version of Cocos2d-JS being used.
    * Please DO NOT remove this String, it is an important flag for bug tracking.
    * If you post a bug to forum, please attach this flag. - *

    - * @constant - * @type String + * @type {String} + * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC2"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC3"; /** *

    @@ -52,17 +50,19 @@ window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC2"; * - cc.QuadParticleSystem
    * - cc.TileMap
    *
    - * To enabled set it to 1. Disabled by default. + * To enabled set it to 1. Disabled by default.
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} */ cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; /** - * Position of the FPS (Default: 0,0 (bottom-left corner)) + * Position of the FPS (Default: 0,0 (bottom-left corner))
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h * @constant - * @type cc.Point + * @type {cc.Point} */ cc.DIRECTOR_STATS_POSITION = cc.p(0, 0); @@ -73,9 +73,10 @@ cc.DIRECTOR_STATS_POSITION = cc.p(0, 0); * Having a bigger number means a more reliable FPS
    *
    * Default value: 0.1f
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} */ cc.DIRECTOR_FPS_INTERVAL = 0.5; @@ -84,10 +85,11 @@ cc.DIRECTOR_FPS_INTERVAL = 0.5; * If enabled, the cc.Node objects (cc.Sprite, cc.Label,etc) will be able to render in subpixels.
    * If disabled, integer pixels will be used.
    *
    - * To enable set it to 1. Enabled by default. + * To enable set it to 1. Enabled by default.
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} */ cc.COCOSNODE_RENDER_SUBPIXEL = 1; @@ -96,10 +98,11 @@ cc.COCOSNODE_RENDER_SUBPIXEL = 1; * If enabled, the cc.Sprite objects rendered with cc.SpriteBatchNode will be able to render in subpixels.
    * If disabled, integer pixels will be used.
    *
    - * To enable set it to 1. Enabled by default. + * To enable set it to 1. Enabled by default.
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} */ cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1; @@ -108,10 +111,11 @@ cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1; * If most of your images have pre-multiplied alpha, set it to 1 (if you are going to use .PNG/.JPG file images).
    * Only set to 0 if ALL your images by-pass Apple UIImage loading system (eg: if you use libpng or PVR images)
    *
    - * To enable set it to a value different than 0. Enabled by default. + * To enable set it to a value different than 0. Enabled by default.
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} */ cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0; @@ -120,10 +124,11 @@ cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0; * Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas.
    * It seems it is the recommend way, but it is much slower, so, enable it at your own risk
    *
    - * To enable set it to a value different than 0. Disabled by default. + * To enable set it to a value different than 0. Disabled by default.
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} */ cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0; @@ -134,9 +139,10 @@ cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0; * So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.
    *
    * To disable it set it to 0. disable by default.(Not Supported on WebGL)
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} */ cc.TEXTURE_ATLAS_USE_VAO = 0; @@ -150,10 +156,11 @@ cc.TEXTURE_ATLAS_USE_VAO = 0; * To enable set it to a value different than 0. Disabled by default.
    *
    * This value governs only the PNG, GIF, BMP, images.
    - * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value. + * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it. */ cc.TEXTURE_NPOT_SUPPORT = 0; @@ -166,10 +173,11 @@ cc.TEXTURE_NPOT_SUPPORT = 0; * To enable set it to 1. Use 0 to disable it. Enabled by default.
    *
    * This value governs only the PNG, GIF, BMP, images.
    - * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value. + * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
    + * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h *

    * @constant - * @type Number + * @type {Number} * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it. */ cc.RETINA_DISPLAY_SUPPORT = 1; @@ -184,7 +192,7 @@ cc.RETINA_DISPLAY_SUPPORT = 1; * Platforms: Only used on Retina Display devices like iPhone 4. *

    * @constant - * @type String + * @type {String} */ cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd"; @@ -197,7 +205,7 @@ cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd"; * This feature is enabled by default. *

    * @constant - * @type Number + * @type {Number} */ cc.USE_LA88_LABELS = 1; @@ -212,7 +220,7 @@ cc.USE_LA88_LABELS = 1; * 2 -- draw texture box *

    * @constant - * @type Number + * @type {Number} */ cc.SPRITE_DEBUG_DRAW = 0; @@ -224,7 +232,7 @@ cc.SPRITE_DEBUG_DRAW = 0; * To enable set it to a value different than 0. Disabled by default. *

    * @constant - * @type Number + * @type {Number} */ cc.SPRITEBATCHNODE_DEBUG_DRAW = 0; @@ -236,7 +244,7 @@ cc.SPRITEBATCHNODE_DEBUG_DRAW = 0; * To enable set it to a value different than 0. Disabled by default.
    *

    * @constant - * @type Number + * @type {Number} */ cc.LABELBMFONT_DEBUG_DRAW = 0; @@ -248,21 +256,21 @@ cc.LABELBMFONT_DEBUG_DRAW = 0; * To enable set it to a value different than 0. Disabled by default. *

    * @constant - * @type Number + * @type {Number} */ cc.LABELATLAS_DEBUG_DRAW = 0; /** - * whether or not support retina display + * Whether or not support retina display * @constant - * @type Number + * @type {Number} */ cc.IS_RETINA_DISPLAY_SUPPORTED = 1; /** - * default engine + * Default engine * @constant - * @type String + * @type {String} */ cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas"; @@ -290,6 +298,6 @@ cc.ENABLE_STACKABLE_ACTIONS = 1; * If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on. *

    * @constant - * @type Number + * @type {Number} */ cc.ENABLE_GL_STATE_CACHE = 1; \ No newline at end of file diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 6a4dad23ba..0ca83c76a2 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -122,6 +122,11 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ this.setDesignResolutionSize(width, height, this._resolutionPolicy); }, + /** + * Sets whether resize canvas automatically when browser's size changed.
    + * Useful only on web. + * @param enabled Whether enable automatic resize with browser's resize event + */ resizeWithBrowserSize: function (enabled) { var adjustSize, _t = this; if (enabled) { @@ -141,6 +146,13 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ } }, + /** + * Sets the callback function for cc.view's resize action,
    + * this callback will be invoked before applying resolution policy,
    + * so you can do any additional modifications within the callback.
    + * Useful only on web. + * @param callback The callback function + */ setResizeCallback: function (callback) { if (typeof callback == "function" || callback == null) { this._resizeCallback = callback; @@ -216,20 +228,25 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _adjustSizeToBrowser: function () { }, - /** - * init - */ initialize: function () { this._initialized = true; }, + /** + * Sets whether the engine modify the "viewport" meta in your web page.
    + * It's enabled by default, we strongly suggest you not to disable it.
    + * And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden
    + * Only useful on web + * @param enabled Enable automatic modification to "viewport" meta + */ adjustViewPort: function (enabled) { this._isAdjustViewPort = enabled; }, /** - * Retina support is enabled by default for Apple device but disabled for other devices, - * it takes effect only when you called setDesignResolutionPolicy + * Retina support is enabled by default for Apple device but disabled for other devices,
    + * it takes effect only when you called setDesignResolutionPolicy
    + * Only useful on web * @param {Boolean} enabled Enable or disable retina display */ enableRetina: function(enabled) { @@ -237,7 +254,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Check whether retina display is enabled. + * Check whether retina display is enabled.
    + * Only useful on web * @return {Boolean} */ isRetinaEnabled: function() { @@ -245,8 +263,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * 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 + * 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.
    + * Only useful on web * @param {Boolean} enabled Enable or disable auto full screen on mobile devices */ enableAutoFullScreen: function(enabled) { @@ -254,8 +273,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Check whether auto full screen is enabled. - * @return {Boolean} + * Check whether auto full screen is enabled.
    + * Only useful on web + * @return {Boolean} Auto full screen enabled or not */ isAutoFullScreenEnabled: function() { return this._autoFullScreen; @@ -268,7 +288,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Get whether render system is ready(no matter opengl or canvas), + * Get whether render system is ready(no matter opengl or canvas),
    * this name is for the compatibility with cocos2d-x, subclass must implement this method. * @return {Boolean} */ @@ -299,9 +319,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - *

    - * The resolution translate on EGLView - *

    + * Sets the resolution translate on EGLView * @param {Number} offsetLeft * @param {Number} offsetTop */ @@ -310,9 +328,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - *

    - * get the resolution translate on EGLView - *

    + * Returns the resolution translate on EGLView * @return {cc.Size|Object} */ getContentTranslateLeftTop: function () { @@ -320,8 +336,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Get the frame size of EGL view. - * In general, it returns the screen size since the EGL view is a fullscreen view. + * Returns the frame size of the view.
    + * On native platforms, it returns the screen size since the view is a fullscreen view.
    + * On web, it returns the size of the canvas's outer DOM element. * @return {cc.Size} */ getFrameSize: function () { @@ -329,7 +346,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Set the frame size of EGL view. + * On native, it sets the frame size of view.
    + * On web, it sets the size of the canvas's outer DOM element. * @param {Number} width * @param {Number} height */ @@ -343,11 +361,14 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ cc.director.setProjection(cc.director.getProjection()); }, + /** + * Empty function + */ centerWindow: function () { }, /** - * Get the visible area size of OpenGL view port. + * Returns the visible area size of the view port. * @return {cc.Size} */ getVisibleSize: function () { @@ -355,19 +376,24 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Get the visible origin of OpenGL view port. + * Returns the visible origin of the view port. * @return {cc.Point} */ getVisibleOrigin: function () { return cc.p(this._visibleRect.x,this._visibleRect.y); }, + /** + * Returns whether developer can set content's scale factor. + * @return {Boolean} + */ canSetContentScaleFactor: function () { return true; }, /** - * Get the current resolution policy + * Returns the current resolution policy + * @see cc.ResolutionPolicy * @return {cc.ResolutionPolicy} */ getResolutionPolicy: function () { @@ -375,7 +401,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Set the current resolution policy + * Sets the current resolution policy + * @see cc.ResolutionPolicy * @param {cc.ResolutionPolicy|Number} resolutionPolicy */ setResolutionPolicy: function (resolutionPolicy) { @@ -400,16 +427,17 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Set the design resolution size. + * Sets the resolution policy with designed view size in points.
    + * The resolution policy include:
    + * [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
    + * [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
    + * [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
    + * [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
    + * [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
    + * [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy
    * @param {Number} width Design resolution width. * @param {Number} height Design resolution height. - * @param {cc.ResolutionPolicy|Number} resolutionPolicy The resolution policy desired, you may choose: - * [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched. - * [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut. - * [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown. - * [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width - * [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height - * [cc.ResolutionPolicy] Custom resolution policy, constructed by cc.ResolutionPolicy + * @param {cc.ResolutionPolicy|Number} resolutionPolicy The resolution policy desired */ setDesignResolutionSize: function (width, height, resolutionPolicy) { // Defensive code @@ -475,7 +503,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Get design resolution size. + * Returns the designed size for the view. * Default resolution size is the same as 'getFrameSize'. * @return {cc.Size} */ @@ -484,7 +512,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Set opengl view port rectangle with points. + * Sets view port rectangle with points. * @param {Number} x * @param {Number} y * @param {Number} w width @@ -499,7 +527,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Set Scissor rectangle with points. + * Sets Scissor rectangle with points. * @param {Number} x * @param {Number} y * @param {Number} w @@ -514,7 +542,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Get whether GL_SCISSOR_TEST is enable + * Returns whether GL_SCISSOR_TEST is enable */ isScissorEnabled: function () { var gl = cc._renderContext; @@ -522,7 +550,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Get the current scissor rectangle + * Returns the current scissor rectangle * @return {cc.Rect} */ getScissorRect: function () { @@ -533,6 +561,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** + * Sets the name of the view * @param {String} viewName */ setViewName: function (viewName) { @@ -542,7 +571,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * get view name + * Returns the name of the view * @return {String} */ getViewName: function () { @@ -550,35 +579,43 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }, /** - * Get the opengl view port rectangle. + * Returns the view port rectangle. + * @return {cc.Rect} */ getViewPortRect: function () { return this._viewPortRect; }, /** - * Get scale factor of the horizontal direction. + * Returns scale factor of the horizontal direction (X axis). + * @return {Number} */ getScaleX: function () { return this._scaleX; }, /** - * Get scale factor of the vertical direction. + * Returns scale factor of the vertical direction (Y axis). + * @return {Number} */ getScaleY: function () { return this._scaleY; }, /** - * Get device pixel ratio for retina display. + * Returns device pixel ratio for retina display. + * @return {Number} */ getDevicePixelRatio: function() { return this._devicePixelRatio; }, /** - * Get the real location in view + * Returns the real location in view for a translation based on a related position + * @param {Number} tx The X axis translation + * @param {Number} ty The Y axis translation + * @param {Object} relatedPos The related position object including "left", "top", "width", "height" informations + * @return {cc.Point} */ convertToLocationInView: function (tx, ty, relatedPos) { return {x: this._devicePixelRatio * (tx - relatedPos.left), y: this._devicePixelRatio * (relatedPos.top + relatedPos.height - ty)}; @@ -914,6 +951,8 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ * * @class * @extends cc.Class + * @param {cc.ContainerStrategy} containerStg The container strategy + * @param {cc.ContentStrategy} contentStg The content strategy */ cc.ResolutionPolicy = cc.Class.extend(/** @lends cc.ResolutionPolicy# */{ _containerStrategy: null, From 086cda0b7077045ee7c1a224af1836c1c5f31c5a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 28 Aug 2014 18:32:45 +0800 Subject: [PATCH 0570/1564] Doc #5829: Improve inline docs for CCDirector, CCEGLView --- cocos2d/core/CCDirector.js | 303 ++++++++++++++++++----------- cocos2d/core/CCDirectorWebGL.js | 36 ---- cocos2d/core/platform/CCEGLView.js | 13 +- 3 files changed, 204 insertions(+), 148 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 85ad9a6756..6eeadc5954 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -39,20 +39,21 @@ cc.GLToClipTransform = function (transformOut) { /** *

    - * cc.director is a singleton of DisplayLinkDirector type director.
    + * ATTENTION: USE cc.director INSTEAD OF cc.Director.
    + * cc.director is a singleton object which manage your game's logic flow.
    * Since the cc.director is a singleton, you don't need to call any constructor or create functions,
    * the standard way to use it is by calling:
    * - cc.director.methodName();
    * * It creates and handle the main Window and manages how and when to execute the Scenes.
    *
    - * The cc.Director is also responsible for:
    + * The cc.director is also responsible for:
    * - initializing the OpenGL context
    * - setting the OpenGL pixel format (default on is RGB565)
    * - setting the OpenGL pixel format (default on is RGB565)
    * - setting the OpenGL buffer depth (default one is 0-bit)
    * - setting the projection (default one is 3D)
    - * - setting the orientation (default one is Protrait)
    + * - setting the orientation (default one is Portrait)
    *
    *
    * The cc.director also sets the default OpenGL context:
    @@ -62,15 +63,15 @@ cc.GLToClipTransform = function (transformOut) { * - GL_TEXTURE_COORD_ARRAY is enabled
    *

    *

    - * With DisplayLinkDirector functionality, cc.director synchronizes timers with the refresh rate of the display.
    + * cc.director also synchronizes timers with the refresh rate of the display.
    * Features and Limitations:
    * - Scheduled timers & drawing are synchronizes with the refresh rate of the display
    * - Only supports animation intervals of 1/60 1/30 & 1/15
    *

    - * @namespace - * @name cc.director + * @class + * @name cc.Director */ -cc.Director = cc.Class.extend(/** @lends cc.director# */{ +cc.Director = cc.Class.extend(/** @lends cc.Director# */{ //Variables _landscape: false, _nextDeltaTimeZero: false, @@ -122,10 +123,6 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }); }, - /** - * initializes cc.director - * @return {Boolean} - */ init: function () { // scenes this._oldAnimationInterval = this._animationInterval = 1.0 / cc.defaultFPS; @@ -192,9 +189,24 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * convertToGL move to CCDirectorWebGL - * convertToUI move to CCDirectorWebGL + * Converts a view coordinate to an WebGL coordinate
    + * Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
    + * Implementation can be found in CCDirectorWebGL + * @function + * @param {cc.Point} uiPoint + * @return {cc.Point} */ + convertToGL: null, + + /** + * Converts an WebGL coordinate to a view coordinate
    + * Useful to convert node points to window points for calls such as glScissor
    + * Implementation can be found in CCDirectorWebGL + * @function + * @param {cc.Point} glPoint + * @return {cc.Point} + */ + convertToUI: null, /** * Draw the scene. This method is called every frame. Don't call it manually. @@ -246,17 +258,15 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ _afterVisitScene: null, /** - * end director + * End the life of director in the next frame */ end: function () { this._purgeDirectorInNextLoop = true; }, /** - *

    get the size in pixels of the surface. It could be different than the screen size.
    - * High-res devices might have a higher surface size than the screen size.
    - * Only available when compiled using SDK >= 4.0. - *

    + * Returns the size in pixels of the surface. It could be different than the screen size.
    + * High-res devices might have a higher surface size than the screen size. * @return {Number} */ getContentScaleFactor: function () { @@ -264,11 +274,9 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * This object will be visited after the main scene is visited.
    - * This object MUST implement the "visit" selector.
    - * Useful to hook a notification object, like CCNotifications (http://github.com/manucorporat/CCNotifications) - *

    + * This object will be visited after the main scene is visited.
    + * This object MUST implement the "visit" selector.
    + * Useful to hook a notification object * @return {cc.Node} */ getNotificationNode: function () { @@ -276,10 +284,8 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * returns the size of the OpenGL view in points.
    - * It takes into account any possible rotation (device orientation) of the window - *

    + * Returns the size of the WebGL view in points.
    + * It takes into account any possible rotation (device orientation) of the window * @return {cc.Size} */ getWinSize: function () { @@ -287,11 +293,9 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * returns the size of the OpenGL view in pixels.
    - * It takes into account any possible rotation (device orientation) of the window.
    - * On Mac winSize and winSizeInPixels return the same value. - *

    + * Returns the size of the OpenGL view in pixels.
    + * It takes into account any possible rotation (device orientation) of the window.
    + * On Mac winSize and winSizeInPixels return the same value. * @return {cc.Size} */ getWinSizeInPixels: function () { @@ -304,7 +308,28 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ */ /** - * pause director + * Returns the visible size of the running scene + * @function + * @return {cc.Size} + */ + getVisibleSize: null, + + /** + * Returns the visible origin of the running scene + * @function + * @return {cc.Point} + */ + getVisibleOrigin: null, + + /** + * Returns the z eye, only available in WebGL mode + * @function + * @return {Number} + */ + getZEye: null, + + /** + * Pause the director's ticker */ pause: function () { if (this._paused) @@ -317,12 +342,10 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * Pops out a scene from the queue.
    - * This scene will replace the running one.
    - * The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
    - * ONLY call it if there is a running scene. - *

    + * Pops out a scene from the queue.
    + * This scene will replace the running one.
    + * The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
    + * ONLY call it if there is a running scene. */ popScene: function () { @@ -349,7 +372,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * purge Director + * Purge the cc.director itself, including unschedule all schedule, remove all event listeners, clean up and exit the running scene, stops all animations, clear cached data. */ purgeDirector: function () { //cleanup scheduler @@ -384,12 +407,10 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
    - * The new scene will be executed.
    - * Try to avoid big stacks of pushed scenes to reduce memory allocation.
    - * ONLY call it if there is a running scene. - *

    + * Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
    + * The new scene will be executed.
    + * Try to avoid big stacks of pushed scenes to reduce memory allocation.
    + * ONLY call it if there is a running scene. * @param {cc.Scene} scene */ pushScene: function (scene) { @@ -403,7 +424,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * Run a scene. Replaces the running scene with a new one when the scene is running. + * Run a scene. Replaces the running scene with a new one or enter the first scene. * @param {cc.Scene} scene */ runScene: function (scene) { @@ -430,7 +451,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * resume director + * Resume director after pause, if the current scene is not paused, nothing will happen. */ resume: function () { if (!this._paused) { @@ -448,11 +469,8 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * The size in pixels of the surface. It could be different than the screen size.
    - * High-res devices might have a higher surface size than the screen size.
    - * Only available when compiled using SDK >= 4.0. - *

    + * The size in pixels of the surface. It could be different than the screen size.
    + * High-res devices might have a higher surface size than the screen size. * @param {Number} scaleFactor */ setContentScaleFactor: function (scaleFactor) { @@ -463,21 +481,22 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * enables/disables OpenGL depth test + * Enables or disables WebGL depth test.
    + * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + * @function * @param {Boolean} on - * - * setDepthTest move to CCDirectorCanvas/CCDirectorWebGL */ + setDepthTest: null, /** - * sets the default values based on the CCConfiguration info + * Sets the default values based on the CCConfiguration info */ setDefaultValues: function () { }, /** - * set next delta time is zero + * Sets whether next delta time equals to zero * @param {Boolean} nextDeltaTimeZero */ setNextDeltaTimeZero: function (nextDeltaTimeZero) { @@ -485,7 +504,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * set next scene + * Starts the registered next scene */ setNextScene: function () { var runningIsTransition = false, newIsTransition = false; @@ -518,7 +537,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * set Notification Node + * Sets Notification Node * @param {cc.Node} node */ setNotificationNode: function (node) { @@ -526,35 +545,68 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * CCDirector delegate. It shall implemente the CCDirectorDelegate protocol - * @return {cc.DirectorDelegate} + * Returns the cc.director delegate. + * @return {cc.DirectorDelegate} */ getDelegate: function () { return this._projectionDelegate; }, + /** + * Sets the cc.director delegate. It shall implement the CCDirectorDelegate protocol + * @return {cc.DirectorDelegate} + */ setDelegate: function (delegate) { this._projectionDelegate = delegate; }, /** - * Set the CCEGLView, where everything is rendered - * @param {*} openGLView - * - * setOpenGLView move to CCDirectorCanvas/CCDirectorWebGL - * setViewport move to CCDirectorWebGL + * Sets the view, where everything is rendered, do not call this function.
    + * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. + * @function + * @param {cc.view} openGLView */ + setOpenGLView: null, /** - * Sets an OpenGL projection + * Sets an OpenGL projection.
    + * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * @function * @param {Number} projection - * - * setProjection move to CCDiretorCanvas/CCDiretorWebGL */ + setProjection: null, + + /** + * Update the view port.
    + * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * @function + */ + setViewport: null, + + /** + * Get the CCEGLView, where everything is rendered.
    + * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * @function + * @return {cc.view} + */ + getOpenGLView: null, + + /** + * Sets an OpenGL projection.
    + * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * @function + * @return {Number} + */ + getProjection: null, /** - * shows the FPS in the screen + * Enables/disables OpenGL alpha blending.
    + * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * @function + * @param {Boolean} on */ + setAlphaBlending: null, + _showStats: function () { this._frames++; this._accumDt += this._deltaTime; @@ -578,11 +630,9 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * Whether or not the replaced scene will receive the cleanup message.
    - * If the new scene is pushed, then the old scene won't receive the "cleanup" message.
    - * If the new scene replaces the old one, the it will receive the "cleanup" message. - *

    + * Returns whether or not the replaced scene will receive the cleanup message.
    + * If the new scene is pushed, then the old scene won't receive the "cleanup" message.
    + * If the new scene replaces the old one, the it will receive the "cleanup" message. * @return {Boolean} */ isSendCleanupToScene: function () { @@ -590,7 +640,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * Get current running Scene. Director can only run one Scene at the time + * Returns current running Scene. Director can only run one Scene at the time * @return {cc.Scene} */ getRunningScene: function () { @@ -598,7 +648,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * Get the FPS value + * Returns the FPS value * @return {Number} */ getAnimationInterval: function () { @@ -606,7 +656,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * Whether or not to display the FPS on the bottom-left corner + * Returns whether or not to display the FPS informations * @return {Boolean} */ isDisplayStats: function () { @@ -614,7 +664,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * Display the FPS on the bottom-left corner + * Sets whether display the FPS on the bottom-left corner * @param {Boolean} displayStats */ setDisplayStats: function (displayStats) { @@ -622,7 +672,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * seconds per frame + * Returns seconds per frame * @return {Number} */ getSecondsPerFrame: function () { @@ -630,7 +680,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * is next delta time zero + * Returns whether next delta time equals to zero * @return {Boolean} */ isNextDeltaTimeZero: function () { @@ -638,7 +688,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * Whether or not the Director is paused + * Returns whether or not the Director is paused * @return {Boolean} */ isPaused: function () { @@ -646,7 +696,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * How many frames were called since the director started + * Returns how many frames were called since the director started * @return {Number} */ getTotalFrames: function () { @@ -654,23 +704,19 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - *

    - * Pops out all scenes from the queue until the root scene in the queue.
    - * This scene will replace the running one.
    - * Internally it will call `popToSceneStackLevel(1)` - *

    + * Pops out all scenes from the queue until the root scene in the queue.
    + * This scene will replace the running one.
    + * Internally it will call "popToSceneStackLevel(1)" */ popToRootScene: function () { this.popToSceneStackLevel(1); }, /** - *

    - * Pops out all scenes from the queue until it reaches `level`.
    - * If level is 0, it will end the director.
    - * If level is 1, it will pop all scenes until it reaches to root scene.
    - * If level is <= than the current stack level, it won't do anything. - *

    + * Pops out all scenes from the queue until it reaches "level".
    + * If level is 0, it will end the director.
    + * If level is 1, it will pop all scenes until it reaches to root scene.
    + * If level is <= than the current stack level, it won't do anything. * @param {Number} level */ popToSceneStackLevel: function (level) { @@ -703,27 +749,44 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ }, /** - * (cc.Scheduler associated with this director) + * Returns the cc.Scheduler associated with this director + * @return {cc.Scheduler} */ getScheduler: function () { return this._scheduler; }, + /** + * Sets the cc.Scheduler associated with this director + * @param {cc.Scheduler} scheduler + */ setScheduler: function (scheduler) { if (this._scheduler != scheduler) { this._scheduler = scheduler; } }, + /** + * Returns the cc.ActionManager associated with this director + * @return {cc.ActionManager} + */ getActionManager: function () { return this._actionManager; }, + /** + * Sets the cc.ActionManager associated with this director + * @param {cc.ActionManager} actionManager + */ setActionManager: function (actionManager) { if (this._actionManager != actionManager) { this._actionManager = actionManager; } }, + /** + * Returns the delta time since last frame + * @return {Number} + */ getDeltaTime: function () { return this._deltaTime; }, @@ -736,9 +799,29 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{ } }); +/** + * Event name for projection change + * @constant + * @type {String} + */ cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed"; +/** + * Event name for draw finish event in each frame + * @constant + * @type {String} + */ cc.Director.EVENT_AFTER_DRAW = "director_after_draw"; +/** + * Event name for after visit event in each frame + * @constant + * @type {String} + */ cc.Director.EVENT_AFTER_VISIT = "director_after_visit"; +/** + * Event name for after update event in each frame + * @constant + * @type {String} + */ cc.Director.EVENT_AFTER_UPDATE = "director_after_update"; /*************************************************** @@ -748,7 +831,7 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ invalid: false, /** - * start Animation + * Starts Animation */ startAnimation: function () { this._nextDeltaTimeZero = true; @@ -756,7 +839,7 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ }, /** - * main loop of director + * Run main loop of director */ mainLoop: function () { if (this._purgeDirectorInNextLoop) { @@ -769,15 +852,15 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ }, /** - * stop animation + * Stops animation */ stopAnimation: function () { this.invalid = true; }, /** - * set Animation Interval - * @param {Number} value + * Sets animation interval + * @param {Number} value the animation interval desired */ setAnimationInterval: function (value) { this._animationInterval = value; @@ -801,37 +884,37 @@ cc.Director._getInstance = function () { }; /** - * set default fps to 60 - * @type Number + * Default fps is 60 + * @type {Number} */ cc.defaultFPS = 60; //Possible OpenGL projections used by director /** - * sets a 2D projection (orthogonal projection) + * Constant for 2D projection (orthogonal projection) * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_2D = 0; /** - * sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500. + * Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_3D = 1; /** - * it calls "updateProjection" on the projection delegate. + * Constant for custom projection * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_CUSTOM = 3; /** * Default projection is 3D projection * @constant - * @type Number + * @type {Number} */ cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D; diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 5b7e0d837a..64c1407ef8 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -229,17 +229,6 @@ cc._tmp.DirectorWebGL = function () { _t._FPSLabel.setPosition(_t._FPSLabel.width / 2 + locStatsPosition.x, _t._FPSLabel.height / 2 + locStatsPosition.y); }; - - /** - *

    - * converts a UIKit coordinate to an OpenGL coordinate
    - * Useful to convert (multi) touches coordinates to the current layout (portrait or landscape) - *

    - * @param {cc.Point} uiPoint - * @return {cc.Point} - * - * convertToGL move to CCDirectorWebGL - */ _p.convertToGL = function (uiPoint) { var transform = new cc.kmMat4(); cc.GLToClipTransform(transform); @@ -259,12 +248,6 @@ cc._tmp.DirectorWebGL = function () { return cc.p(glCoord.x, glCoord.y); }; - /** - *

    converts an OpenGL coordinate to a UIKit coordinate
    - * Useful to convert node points to window points for calls such as glScissor

    - * @param {cc.Point} glPoint - * @return {cc.Point} - */ _p.convertToUI = function (glPoint) { var transform = new cc.kmMat4(); cc.GLToClipTransform(transform); @@ -299,9 +282,6 @@ cc._tmp.DirectorWebGL = function () { return (this._winSizeInPoints.height / 1.1566 ); }; - /** - * Sets the glViewport - */ _p.setViewport = function () { var view = this._openGLView; if (view) { @@ -310,26 +290,14 @@ cc._tmp.DirectorWebGL = function () { } }; - /** - * Get the CCEGLView, where everything is rendered - * @return {*} - */ _p.getOpenGLView = function () { return this._openGLView; }; - /** - * Sets an OpenGL projection - * @return {Number} - */ _p.getProjection = function () { return this._projection; }; - /** - * enables/disables OpenGL alpha blending - * @param {Boolean} on - */ _p.setAlphaBlending = function (on) { if (on) cc.glBlendFunc(cc.BLEND_SRC, cc.BLEND_DST); @@ -338,10 +306,6 @@ cc._tmp.DirectorWebGL = function () { //cc.checkGLErrorDebug(); }; - - /** - * sets the OpenGL default values - */ _p.setGLDefaultValues = function () { var _t = this; _t.setAlphaBlending(true); diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 0ca83c76a2..186de495ea 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -31,8 +31,17 @@ cc.Touches = []; cc.TouchesIntergerDict = {}; /** - * cc.view is the shared view object. - * @namespace + * cc.view is the singleton object which represents the game window.
    + * It's main task include:
    + * - Apply the design resolution policy
    + * - Provide interaction with the window, like resize event on web, retina display support, etc...
    + * - Manage the game view port which can be different with the window
    + * - Manage the content scale and translation
    + *
    + * Since the cc.view is a singleton, you don't need to call any constructor or create functions,
    + * the standard way to use it is by calling:
    + * - cc.view.methodName();
    + * @class * @name cc.view */ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ From f4dba2a68942e338abd3b8478d55ce280a67bf80 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 28 Aug 2014 21:03:33 +0800 Subject: [PATCH 0571/1564] Issue #5829: corrects some mistakes after added jsDocs. --- CCBoot.js | 15 ++-- cocos2d/actions3d/CCActionGrid3D.js | 10 +-- cocos2d/core/sprites/CCSpriteFrame.js | 8 +- cocos2d/parallax/CCParallaxNode.js | 1 - extensions/ccpool/CCPool.js | 3 +- extensions/cocostudio/action/CCActionFrame.js | 74 +++++++++++++++---- .../cocostudio/action/CCActionManager.js | 3 +- .../gui/control-extension/CCControlSwitch.js | 4 +- .../gui/control-extension/CCMenuPassive.js | 2 +- extensions/gui/scrollview/CCScrollView.js | 2 +- extensions/gui/scrollview/CCTableView.js | 4 +- template/src/myApp.js | 4 +- 12 files changed, 85 insertions(+), 45 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index a806dbe233..e5d5c4191c 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -167,8 +167,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ return } - var arr = Array.prototype.slice.call(arguments); - arr.splice(0, 1); + var arr = Array.prototype.slice.call(arguments, 1); self._results[this.index] = arr[0]; if(self.finishedSize == self.size) { if(self._onEnd) @@ -234,8 +233,7 @@ cc.async = { var asyncPool = new cc.AsyncPool(tasks, 1, function (func, index, cb1) { args.push(function (err) { - args = Array.prototype.slice.apply(arguments); - args.splice(0, 1); + args = Array.prototype.slice.call(arguments, 1); cb1.apply(null, arguments); }); func.apply(target, args); @@ -770,11 +768,10 @@ cc.loader = { self._loadResIterator(value, index, function(err){ if(err) return cb1(err); - var arr = Array.prototype.slice.call(arguments); - arr.splice(0, 1); + var arr = Array.prototype.slice.call(arguments, 1); if(option.trigger) - option.trigger.call(option.triggerTarget, arr, aPool.size, aPool.finishedSize); //call trigger - cb1(); + option.trigger.call(option.triggerTarget, arr[0], aPool.size, aPool.finishedSize); //call trigger + cb1(null, arr[0]); }); }, option.cb, option.cbTarget); asyncPool.flow(); @@ -824,7 +821,7 @@ cc.loader = { loadAliases: function (url, cb) { var self = this, dict = self.getRes(url); if (!dict) { - self.load(url, function (results) { + self.load(url, function (err, results) { self._handleAliases(results[0]["filenames"], cb); }); } else diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index f9372d5782..1332fd0e1f 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -921,8 +921,8 @@ cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{ locPos.x = i; locPos.y = j; v = this.originalVertex(locPos); - v.x = (v.x + (Math.sin(time * Math.PI * locWaves * 2 + v.x * .01) * locAmplitude * locAmplitudeRate)); - v.y = (v.y + (Math.sin(time * Math.PI * locWaves * 2 + v.y * .01) * locAmplitude * locAmplitudeRate)); + v.x = (v.x + (Math.sin(dt * Math.PI * locWaves * 2 + v.x * .01) * locAmplitude * locAmplitudeRate)); + v.y = (v.y + (Math.sin(dt * Math.PI * locWaves * 2 + v.y * .01) * locAmplitude * locAmplitudeRate)); this.setVertex(locPos, v); } } @@ -1059,9 +1059,9 @@ cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{ locPos.y = j; v = this.originalVertex(locPos); if (locVertical) - v.x = (v.x + (Math.sin(time * Math.PI * locWaves * 2 + v.y * .01) * locAmplitude * locAmplitudeRate)); + v.x = (v.x + (Math.sin(dt * Math.PI * locWaves * 2 + v.y * .01) * locAmplitude * locAmplitudeRate)); if (locHorizontal) - v.y = (v.y + (Math.sin(time * Math.PI * locWaves * 2 + v.x * .01) * locAmplitude * locAmplitudeRate)); + v.y = (v.y + (Math.sin(dt * Math.PI * locWaves * 2 + v.x * .01) * locAmplitude * locAmplitudeRate)); this.setVertex(locPos, v); } } @@ -1214,7 +1214,7 @@ cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{ avg.x = i - (locSizeWidth / 2.0); avg.y = j - (locSizeHeight / 2.0); - a = cc.pLength(avg) * Math.cos(Math.PI / 2.0 + time * Math.PI * locTwirls * 2) * amp; + a = cc.pLength(avg) * Math.cos(Math.PI / 2.0 + dt * Math.PI * locTwirls * 2) * amp; dX = Math.sin(a) * (v.y - c.y) + Math.cos(a) * (v.x - c.x); dY = Math.cos(a) * (v.y - c.y) - Math.sin(a) * (v.x - c.x); diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index e76c4c9bb0..dea5b6e84f 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -85,12 +85,10 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this._textureLoaded = false; if(filename !== undefined && rect !== undefined ){ - if(rotated === undefined || offset === undefined || originalSize === undefined){ + if(rotated === undefined || offset === undefined || originalSize === undefined) this.initWithTexture(filename, rect); - } - else{ + else this.initWithTexture(filename, rect, rotated, offset, originalSize) - } } }, @@ -359,7 +357,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this._rectInPixels = rect; rect = this._rect = cc.rectPixelsToPoints(rect); - if(texture && texture.url) { + if(texture && texture.url && texture.isLoaded()) { var _x, _y; if(rotated){ _x = rect.x + rect.height; diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index 17fa743bc4..24337ee2b8 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -36,7 +36,6 @@ cc.PointObject = cc.Class.extend(/** @lends cc.PointObject# */{ _child:null, ctor: function(ratio, offset){ - cc.Class.prototype.ctor.call(this); this.initWithCCPoint(ratio, offset); }, diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index a4d2c13598..96428f3974 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -107,8 +107,7 @@ cc.pool = /** @lends cc.pool# */{ if (this.hasObject(objClass)) { var pid = objClass.prototype.__pid; var list = this._pool[pid]; - var args = Array.prototype.slice.call(arguments); - args.shift(); + var args = Array.prototype.slice.call(arguments, 1); var obj = list.pop(); if(obj.reuse) obj.reuse.apply(obj, args); //define by user. diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index b9f6d133a6..efe9b3189c 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -25,15 +25,47 @@ //Action frame type /** - * @ignore + * The flag move action type of Cocostudio frame. + * @constant + * @type {number} */ ccs.FRAME_TYPE_MOVE = 0; +/** + * The flag scale action type of Cocostudio frame. + * @constant + * @type {number} + */ ccs.FRAME_TYPE_SCALE = 1; +/** + * The flag rotate action type of Cocostudio frame. + * @constant + * @type {number} + */ ccs.FRAME_TYPE_ROTATE = 2; +/** + * The flag tint action type of Cocostudio frame. + * @constant + * @type {number} + */ ccs.FRAME_TYPE_TINT = 3; +/** + * The flag fade action type of Cocostudio frame. + * @constant + * @type {number} + */ ccs.FRAME_TYPE_FADE = 4; +/** + * The max flag of Cocostudio frame. + * @constant + * @type {number} + */ ccs.FRAME_TYPE_MAX = 5; +/** + * The ease type of Cocostudio frame. + * @constant + * @type {Object} + */ ccs.FrameEaseType = { Custom : -1, @@ -82,16 +114,25 @@ ccs.FrameEaseType = { /** - * Base class for ccs.ActionFrame + * The action frame of Cocostudio. It's the base class of ccs.ActionMoveFrame, ccs.ActionScaleFrame etc. * @class * @extends ccs.Class + * + * @property {Number} frameType - frame type of ccs.ActionFrame + * @property {Number} easingType - easing type of ccs.ActionFrame + * @property {Number} frameIndex - frame index of ccs.ActionFrame + * @property {Number} time - time of ccs.ActionFrame */ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ frameType: 0, easingType: 0, frameIndex: 0, - frameTweenParameter: null, + _Parameter: null, time: 0, + + /** + * The constructor of cc.ActionFrame. + */ ctor: function () { this.frameType = 0; this.easingType = 0; @@ -100,11 +141,13 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ }, /** - * Gets the action of ActionFrame. - * @param {number} duration + * Returns the action of ActionFrame. its subClass need override it. + * @param {number} duration the duration time of ActionFrame + * @param {ccs.ActionFrame} srcFrame source frame. * @returns {null} */ - getAction: function (duration) { + getAction: function (duration, srcFrame) { + cc.log("Need a definition of for ActionFrame"); return null; }, @@ -215,12 +258,17 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ return resultAction; }, + + /** + * + * @param {Array} parameter + */ setEasingParameter: function(parameter){ this._Parameter = []; - for(var i=0;i The current container's minimum offset * @property {cc.Point} maxOffset - <@readonly> The current container's maximum offset diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js index 8ea6ee7b2b..45c510ab9e 100644 --- a/extensions/gui/scrollview/CCTableView.js +++ b/extensions/gui/scrollview/CCTableView.js @@ -43,7 +43,7 @@ cc.TABLEVIEW_FILL_BOTTOMUP = 1; * Abstract class for SWTableView cell node * @class * @abstract - * @extend cc.Node + * @extends cc.Node * * @property {Number} objectId - The index used internally by SWTableView and its subclasses */ @@ -178,7 +178,7 @@ cc.TableViewDataSource = cc.Class.extend(/** @lends cc.TableViewDataSource# */{ * this is a very basic, minimal implementation to bring UITableView-like component into cocos2d world. * * @class - * @extend cc.ScrollView + * @extends cc.ScrollView * * @property {cc.TableViewDataSource} dataSource - The data source of the table view * @property {cc.TableViewDelegate} delegate - The event delegate of the table view diff --git a/template/src/myApp.js b/template/src/myApp.js index ec63dece90..a1cd0c1e63 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -23,7 +23,7 @@ var MyLayer = cc.Layer.extend({ },this); closeItem.setAnchorPoint(0.5, 0.5); - var menu = cc.Menu.create(closeItem); + var menu = new cc.Menu(closeItem); menu.setPosition(0, 0); this.addChild(menu, 1); closeItem.setPosition(size.width - 20, 20); @@ -32,7 +32,7 @@ var MyLayer = cc.Layer.extend({ // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label - this.helloLabel = cc.LabelTTF.create("Hello World", "Impact", 38); + this.helloLabel = new cc.LabelTTF("Hello World", "Impact", 38); // position the label on the center of the screen this.helloLabel.setPosition(size.width / 2, size.height - 40); // add the label as a child to this layer From 0dc16b32242be4b10453f6fdb8d5a1bdc58e065f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 28 Aug 2014 22:55:41 +0800 Subject: [PATCH 0572/1564] Fixed a armature's bug and a actionFrame's bug. --- extensions/cocostudio/action/CCActionFrame.js | 34 +++++++++---------- extensions/cocostudio/action/CCActionNode.js | 10 +++--- .../armature/animation/CCArmatureAnimation.js | 3 +- .../armature/utils/CCTweenFunction.js | 9 +++-- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index efe9b3189c..8d23dfa368 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -135,7 +135,7 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ */ ctor: function () { this.frameType = 0; - this.easingType = 0; + this.easingType = ccs.FrameEaseType.Linear; this.frameIndex = 0; this.time = 0; }, @@ -316,9 +316,7 @@ ccs.ActionMoveFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionMoveFrame# */{ * @returns {cc.MoveTo} */ getAction: function (duration) { - var action = cc.moveTo(duration, this._position); - action.easingType = this.easingType || ccs.FrameEaseType.Linear; - return this._getEasingAction(action); + return this._getEasingAction(cc.moveTo(duration, this._position)); } }); @@ -375,9 +373,7 @@ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# * * @returns {cc.ScaleTo} */ getAction: function (duration) { - var action = cc.scaleTo(duration, this._scaleX, this._scaleY); - action.easingType = this.easingType || ccs.FrameEaseType.Linear; - return this._getEasingAction(action); + return this._getEasingAction(cc.scaleTo(duration, this._scaleX, this._scaleY)); } }); @@ -413,12 +409,20 @@ ccs.ActionRotationFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionRotationFr /** * Gets the CCAction of ActionFrame. * @param {number} duration + * @param {cc.ActionFrame} [srcFrame] * @returns {cc.RotateTo} */ - getAction: function (duration) { - var action = cc.rotateTo(duration, this._rotation); - action.easingType = this.easingType || ccs.FrameEaseType.Linear; - return this._getEasingAction(action); + getAction: function (duration, srcFrame) { + if(srcFrame === undefined) + return this._getEasingAction(cc.rotateTo(duration, this._rotation)); + else { + if (!(srcFrame instanceof cc.ActionRotationFrame)) + return this.getAction(duration); + else{ + var diffRotation = this._rotation - srcFrame._rotation; + return this._getEasingAction(cc.rotateBy(duration,diffRotation)); + } + } } }); @@ -457,9 +461,7 @@ ccs.ActionFadeFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionFadeFrame# */{ * @returns {cc.FadeTo} */ getAction: function (duration) { - var action = cc.fadeTo(duration, this._opacity); - action.easingType = this.easingType || ccs.FrameEaseType.Linear; - return this._getEasingAction(action); + return this._getEasingAction(cc.fadeTo(duration, this._opacity)); } }); @@ -502,8 +504,6 @@ ccs.ActionTintFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionTintFrame# */{ * @returns {cc.TintTo} */ getAction: function (duration) { - var action = cc.tintTo(duration, this._color.r, this._color.g, this._color.b); - action.easingType = this.easingType || ccs.FrameEaseType.Linear; - return this._getEasingAction(action); + return this._getEasingAction(cc.tintTo(duration, this._color.r, this._color.g, this._color.b)); } }); \ No newline at end of file diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index 660334030c..1aa197a416 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -65,6 +65,8 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var actionFrameDic = actionframelist[i]; var frameInex = actionFrameDic["frameid"]; var frameTweenType = actionFrameDic["tweenType"]; + if(frameTweenType == null) + frameTweenType = 0; var frameTweenParameterNum = actionFrameDic["tweenParameter"]; var frameTweenParameter = []; @@ -286,7 +288,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ } } if(locSequenceArray){ - var locSequence = cc.Sequence.create(locSequenceArray); + var locSequence = cc.sequence(locSequenceArray); if (locSequence != null) { locSpawnArray.push(locSequence); } @@ -294,7 +296,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ } this._action = null; - this._actionSpawn = cc.Spawn.create(locSpawnArray); + this._actionSpawn = cc.spawn(locSpawnArray); return this._actionSpawn; }, @@ -307,9 +309,9 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ return; } if(fun){ - this._action = cc.Sequence.create(this._actionSpawn,fun); + this._action = cc.sequence(this._actionSpawn,fun); }else{ - this._action = cc.Sequence.create(this._actionSpawn); + this._action = cc.sequence(this._actionSpawn); } this.runAction(); }, diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 89a58e4b3f..272d74c3c1 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -224,7 +224,8 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# var durationTween = this._movementData.durationTween == 0 ? this._rawDuration : this._movementData.durationTween; var tweenEasing = this._movementData.tweenEasing; - loop = (!loop || loop < 0) ? this._movementData.loop : loop; + //loop = (!loop || loop < 0) ? this._movementData.loop : loop; + loop = (loop < 0) ? this._movementData.loop : loop; this._onMovementList = false; ccs.ProcessBase.prototype.play.call(this, durationTo, durationTween, loop, tweenEasing); diff --git a/extensions/cocostudio/armature/utils/CCTweenFunction.js b/extensions/cocostudio/armature/utils/CCTweenFunction.js index 8f15d1509a..11cc1547c5 100644 --- a/extensions/cocostudio/armature/utils/CCTweenFunction.js +++ b/extensions/cocostudio/armature/utils/CCTweenFunction.js @@ -162,21 +162,21 @@ ccs.TweenFunction.tweenTo = function (time, type, easingParam) { case ccs.TweenType.elasticEaseIn: var period = 0.3; - if(null != easingParam){ + if(null != easingParam && easingParam.length > 0){ period = easingParam[0]; } delta = this.elasticEaseIn(time, period); break; case ccs.TweenType.elasticEaseOut: var period = 0.3; - if(null != easingParam){ + if(null != easingParam && easingParam.length > 0){ period = easingParam[0]; } delta = this.elasticEaseOut(time, period); break; case ccs.TweenType.elasticEaseInOut: var period = 0.3; - if(null != easingParam){ + if(null != easingParam && easingParam.length > 0){ period = easingParam[0]; } delta = this.elasticEaseInOut(time, period); @@ -454,8 +454,7 @@ ccs.TweenFunction.bounceEaseInOut = function (time) { if (time < 0.5) { time = time * 2; newT = (1 - ccs.bounceTime(1 - time)) * 0.5; - } - else { + } else { newT = ccs.bounceTime(time * 2 - 1) * 0.5 + 0.5; } From b0fcf24cf7dc1993e103c8b735d07c24d8fa3da6 Mon Sep 17 00:00:00 2001 From: Minh Quy Date: Thu, 28 Aug 2014 22:43:35 +0700 Subject: [PATCH 0573/1564] Add extend method for cc object I think we should add `cc.extend` method which help developer easily merge attributes of object to another object without using extra library like underscore --- CCBoot.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index e5d5c4191c..e89e818a7f 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -84,6 +84,25 @@ cc.each = function (obj, iterator, context) { } }; +/** + * Copy all of the properties in source objects to target object and return the target object. + * @param {object} target + * @param {object} *sources + * @returns {object} + */ +cc.extend = function(target) { + sources = arguments.length >= 2 ? Array.prototype.slice.call(arguments, 1) : []; + + cc.each(sources, function(src) { + for(var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }) + return target; +}; + /** * Check the url whether cross origin * @param {String} url From 3ac4afe67cd1655646c698a6fef26ea1c1d43c4b Mon Sep 17 00:00:00 2001 From: Minh Quy Date: Thu, 28 Aug 2014 22:53:31 +0700 Subject: [PATCH 0574/1564] [Fix] - Polyfill for bind In case of multi params from `bind` function, it leads wrong case because we only accept one param in `bind`. I think you should we `bind` function polyfill which provide by Mozilla [Function bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) --- CCBoot.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index e5d5c4191c..14ceb622a0 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1962,10 +1962,25 @@ cc.game = { cc.game._initConfig(); //+++++++++++++++++++++++++something about CCGame end+++++++++++++++++++++++++++++ -Function.prototype.bind = Function.prototype.bind || function (bind) { - var self = this; - return function () { - var args = Array.prototype.slice.call(arguments); - return self.apply(bind || null, args); - }; +Function.prototype.bind = Function.prototype.bind || function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; }; From b86652774289fda50a20b9070e4a6ba109d10589 Mon Sep 17 00:00:00 2001 From: Minh Quy Date: Thu, 28 Aug 2014 23:46:29 +0700 Subject: [PATCH 0575/1564] [Fix] - Facebook pluginx dialog There is a case when method is 'apprequests' and we don't need `href` attribute in `info`. If we check `info` doesn't have `href` attribute, Facebook Ui for 'apprequests' will be not trigger --- external/pluginx/platform/facebook.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index b0a28a37b6..a414c35a95 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -310,10 +310,6 @@ plugin.extend('facebook', { }else{ return; } - }else{ - if(!info['href']){ - return; - } } if( @@ -415,4 +411,4 @@ plugin.extend('facebook', { } }) } -}); \ No newline at end of file +}); From c0a4b722b04e0d3890f556819233e6004c03ea8a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Aug 2014 01:38:56 +0800 Subject: [PATCH 0576/1564] Doc #5829: Improve inline docs by refactoring @namespace to @class --- cocos2d/audio/CCAudio.js | 88 ++----------------- cocos2d/core/CCConfiguration.js | 4 +- cocos2d/core/event-manager/CCEventManager.js | 4 +- cocos2d/core/platform/CCCommon.js | 3 +- cocos2d/core/platform/CCInputManager.js | 2 +- cocos2d/core/platform/CCScreen.js | 4 +- cocos2d/core/platform/CCVisibleRect.js | 4 +- cocos2d/core/sprites/CCAnimationCache.js | 4 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 2 +- cocos2d/core/textures/CCTextureCache.js | 4 +- cocos2d/particle/CCTIFFReader.js | 4 +- cocos2d/shaders/CCShaderCache.js | 2 +- cocos2d/text-input/CCIMEDispatcher.js | 7 +- extensions/ccpool/CCPool.js | 2 +- extensions/ccui/layouts/UILayoutManager.js | 12 +-- extensions/ccui/system/UIHelper.js | 4 +- .../cocostudio/action/CCActionManager.js | 2 +- .../armature/utils/CCArmatureDataManager.js | 4 +- .../armature/utils/CCDataReaderHelper.js | 4 +- .../utils/CCSpriteFrameCacheHelper.js | 4 +- extensions/cocostudio/reader/GUIReader.js | 4 +- extensions/cocostudio/reader/SceneReader.js | 4 +- 22 files changed, 47 insertions(+), 125 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index ec53b28e43..21ff1e98f8 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -317,8 +317,8 @@ if (cc.sys._supportWebAudio) { } /** - * A simple Audio Engine engine API. - * @namespace + * cc.audioEngine is the singleton object, it provide simple audio APIs. + * @class * @name cc.audioEngine */ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ @@ -775,10 +775,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { - /** - * Extended AudioEngine for single audio mode. - * @namespace - */ + cc.AudioEngineForSingle = cc.AudioEngine.extend({ _waitingEffIds: [], _pausedEffIds: [], @@ -795,12 +792,6 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { this._super(audio); }, - /** - * Resume playing music. - * @example - * //example - * cc.audioEngine.resumeMusic(); - */ resumeMusic: function () { var self = this; if (self._musicPlayState == 1) { @@ -811,15 +802,6 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } }, - /** - * Play sound effect. - * @param {String} url The path of the sound effect with filename extension. - * @param {Boolean} loop Whether to loop the effect playing, default value is false - * @return {Number|null} the audio id - * @example - * //example - * var soundId = cc.audioEngine.playEffect(path); - */ playEffect: function (url, loop) { var self = this, currEffect = self._currEffect; var audio = loop ? self._getEffect(url) : self._getSingleEffect(url); @@ -844,23 +826,10 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { return audioId; }, - /** - * Pause playing sound effect. - * @param {Number} audioID The return value of function playEffect. - * @example - * //example - * cc.audioEngine.pauseEffect(audioID); - */ pauseEffect: function (effectId) { cc.log("pauseEffect not supported in single audio mode!"); }, - /** - * Pause all playing sound effect. - * @example - * //example - * cc.audioEngine.pauseAllEffects(); - */ pauseAllEffects: function () { var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds, currEffect = self._currEffect; if (!currEffect) return; @@ -872,23 +841,10 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { currEffect.pause(); }, - /** - * Resume playing sound effect. - * @param {Number} effectId The return value of function playEffect. - * @audioID - * //example - * cc.audioEngine.resumeEffect(audioID); - */ resumeEffect: function (effectId) { cc.log("resumeEffect not supported in single audio mode!"); }, - /** - * Resume all playing sound effect - * @example - * //example - * cc.audioEngine.resumeAllEffects(); - */ resumeAllEffects: function () { var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; @@ -912,13 +868,6 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } }, - /** - * Stop playing sound effect. - * @param {Number} effectId The return value of function playEffect. - * @example - * //example - * cc.audioEngine.stopEffect(audioID); - */ stopEffect: function (effectId) { var self = this, currEffect = self._currEffect, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; if (currEffect && this._currEffectId == effectId) {//if the eff to be stopped is currEff @@ -934,12 +883,6 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } }, - /** - * Stop all playing sound effects. - * @example - * //example - * cc.audioEngine.stopAllEffects(); - */ stopAllEffects: function () { var self = this; self._stopAllEffects(); @@ -951,13 +894,6 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { } }, - /** - * Unload the preloaded effect from internal buffer - * @param {String} url - * @example - * //example - * cc.audioEngine.unloadEffect(EFFECT_FILE); - */ unloadEffect: function (url) { var self = this, locLoader = cc.loader, locEffects = self._effects, effCache = self._effectCache4Single, effectList = self._getEffectList(url), currEffect = self._currEffect; @@ -1110,16 +1046,10 @@ if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { }); } -/** - * Resource loader for audio. - */ cc._audioLoader = { _supportedAudioTypes: null, - /** - * Get audio default path. - * @returns {cc.loader.audioPath|*} - */ + // Get audio default path. getBasePath: function () { return cc.loader.audioPath; }, @@ -1157,11 +1087,7 @@ cc._audioLoader = { locLoader.cache[url] = audio; }, - /** - * Check whether to support this type of file - * @param type - * @returns {boolean} - */ + //Check whether to support this type of file audioTypeSupported: function (type) { if (!type) return false; return this._supportedAudioTypes.indexOf(type.toLowerCase()) >= 0; @@ -1205,9 +1131,7 @@ cc._audioLoader = { return audio; }, - /** - * Load this audio. - */ + // Load this audio. load: function (realUrl, url, res, cb) { var tryArr = []; this._load(realUrl, url, res, -1, tryArr, null, cb); diff --git a/cocos2d/core/CCConfiguration.js b/cocos2d/core/CCConfiguration.js index 69cc55494a..e2be6b7ba8 100644 --- a/cocos2d/core/CCConfiguration.js +++ b/cocos2d/core/CCConfiguration.js @@ -25,8 +25,8 @@ ****************************************************************************/ /** - * cc.configuration contains some openGL variables - * @namespace + * cc.configuration is a singleton object which contains some openGL variables + * @class * @name cc.configuration * @example * var textureSize = cc.configuration.getMaxTextureSize(); diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 63e1a2de8c..e88250aea7 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -90,12 +90,12 @@ cc.__getListenerID = function (event) { /** *

    - * cc.eventManager object manages event listener subscriptions and event dispatching.
    + * cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.
    *
    * The EventListener list is managed in such way so that event listeners can be added and removed
    * while events are being dispatched. *

    - * @namespace + * @class * @name cc.eventManager */ cc.eventManager = /** @lends cc.eventManager# */{ diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index ce55717ed0..a15cca1ede 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -247,7 +247,8 @@ cc.inherits = function (childCtor, parentCtor) { }; /** - * @deprecated since v3.0, please use extend and _super + * @deprecated since v3.0, please use cc.Class.extend and _super + * @cc.Class.extend */ cc.base = function(me, opt_methodName, var_args) { var caller = arguments.callee.caller; diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index de2f21a364..9d72c97ed8 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -52,7 +52,7 @@ cc.UIInterfaceOrientationPortrait = 0; *

    * This class manages all events of input. include: touch, mouse, accelerometer, keyboard
    *

    - * @namespace + * @class * @name cc.inputManager */ cc.inputManager = /** @lends cc.inputManager# */{ diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index 89f1ddb8f8..130ebfbafb 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -26,8 +26,8 @@ /** * The fullscreen API provides an easy way for web content to be presented using the user's entire screen. - * It's invalid on safari,QQbrowser and android browser - * @namespace + * It's invalid on safari, QQbrowser and android browser + * @class * @name cc.screen */ cc.screen = /** @lends cc.screen# */{ diff --git a/cocos2d/core/platform/CCVisibleRect.js b/cocos2d/core/platform/CCVisibleRect.js index a7672dec0e..a2f6f01634 100644 --- a/cocos2d/core/platform/CCVisibleRect.js +++ b/cocos2d/core/platform/CCVisibleRect.js @@ -25,7 +25,7 @@ ****************************************************************************/ /** - * cc.visibleRect define the actual visible rect of the current view, + * cc.visibleRect is a singleton object which defines the actual visible rect of the current view, * it should represent the same rect as cc.view.getViewportRect() * * @property {cc.Point} topLeft - Top left coordinate of the screen related to the game scene @@ -40,7 +40,7 @@ * @property {Number} width - Width of the screen * @property {Number} height - Height of the screen * - * @namespace + * @class * @name cc.visibleRect */ cc.visibleRect = { diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 2afc79c3ad..911eff89b5 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -26,13 +26,13 @@ /** *

    - * cc.animationCache is a singleton that manages the Animations.
    + * cc.animationCache is a singleton object that manages the Animations.
    * It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
    *
    * example
    * cc.animationCache.addAnimation(animation,"animation1");
    *

    - * @namespace + * @class * @name cc.animationCache */ cc.animationCache = /** @lends cc.animationCache# */{ diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index cdb47e7665..496f5ac397 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -32,7 +32,7 @@ * // add SpriteFrames to spriteFrameCache With File
    * cc.spriteFrameCache.addSpriteFrames(s_grossiniPlist);
    *

    - * @namespace + * @class * @name cc.spriteFrameCache */ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 14e4c3dfee..8829055543 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -25,8 +25,8 @@ ****************************************************************************/ /** - * cc.textureCache is the global cache for cc.Texture2D - * @namespace + * cc.textureCache is a singleton object, it's the global cache for cc.Texture2D + * @class * @name cc.textureCache */ cc.textureCache = /** @lends cc.textureCache# */{ diff --git a/cocos2d/particle/CCTIFFReader.js b/cocos2d/particle/CCTIFFReader.js index 0ad5120f98..da832b4717 100644 --- a/cocos2d/particle/CCTIFFReader.js +++ b/cocos2d/particle/CCTIFFReader.js @@ -28,8 +28,8 @@ ****************************************************************************/ /** - * A tiff file reader, it can parse byte array to draw into a canvas - * @namespace + * cc.tiffReader is a singleton object, it's a tiff file reader, it can parse byte array to draw into a canvas + * @class * @name cc.tiffReader */ cc.tiffReader = /** @lends cc.tiffReader# */{ diff --git a/cocos2d/shaders/CCShaderCache.js b/cocos2d/shaders/CCShaderCache.js index 72480c2727..f78780ddb6 100644 --- a/cocos2d/shaders/CCShaderCache.js +++ b/cocos2d/shaders/CCShaderCache.js @@ -26,7 +26,7 @@ /** * cc.shaderCache is a singleton object that stores manages GL shaders - * @namespace + * @class * @name cc.shaderCache */ cc.shaderCache = /** @lends cc.shaderCache# */{ diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index 26a4bc0604..61786c3444 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -132,8 +132,8 @@ cc.IMEDelegate = cc.Class.extend(/** @lends cc.IMEDelegate# */{ }); /** - * Input Method Edit Message Dispatcher. - * @namespace + * cc.imeDispatcher is a singleton object which manage input message dispatching. + * @class * @name cc.imeDispatcher */ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ @@ -149,9 +149,6 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ this._lastClickPosition = cc.p(0, 0); }, - /** - * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. - */ init:function () { if (cc.sys.isMobile) return; diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 96428f3974..d738a8f590 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -40,7 +40,7 @@ * cc.pool.putInPool(sp); * * cc.pool.getFromPool(cc.Sprite, "a.png"); - * @namespace + * @class * @name cc.pool */ cc.pool = /** @lends cc.pool# */{ diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index 6440d97cc6..fcbfc98993 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -40,8 +40,8 @@ ccui.getLayoutManager = function (type) { }; /** - * The linear vertical layout manager for ccui.Layout, it has a _doLayout function to do layout. - * @namespace + * ccui.linearVerticalLayoutManager is a singleton object which is the linear vertical layout manager for ccui.Layout. + * @class * @name ccui.linearVerticalLayoutManager */ ccui.linearVerticalLayoutManager = /** @lends ccui.linearVerticalLayoutManager# */{ @@ -86,8 +86,8 @@ ccui.linearVerticalLayoutManager = /** @lends ccui.linearVerticalLayoutManager# }; /** - * The linear horizontal layout manager for ccui.Layout, it has a _doLayout function to do layout. - * @namespace + * ccui.linearHorizontalLayoutManager is a singleton object which is the linear horizontal layout manager for ccui.Layout + * @class * @name ccui.linearHorizontalLayoutManager */ ccui.linearHorizontalLayoutManager = /** @lends ccui.linearHorizontalLayoutManager# */{ @@ -130,8 +130,8 @@ ccui.linearHorizontalLayoutManager = /** @lends ccui.linearHorizontalLayoutManag }; /** - * The relative layout manager for ccui.Layout, it has a _doLayout function to do layout. - * @namespace + * ccui.relativeLayoutManager is the singleton object which is the relative layout manager for ccui.Layout, it has a _doLayout function to do layout. + * @class * @name ccui.relativeLayoutManager */ ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 8551397351..91cd9bd90f 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -24,8 +24,8 @@ ****************************************************************************/ /** - * UI Helper object contains some functions for seek widget - * @namespace + * ccui.helper is the singleton object which is the Helper object contains some functions for seek widget + * @class * @name ccui.helper */ ccui.helper = { diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index 907075c37b..abfa374a7c 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -25,7 +25,7 @@ /** * Base singleton object for ccs.ActionManager - * @namespace + * @class * @name ccs.actionManager */ ccs.actionManager = /** @lends ccs.actionManager# */{ diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index fde1769328..1e972b23f4 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -35,8 +35,8 @@ ccs.RelativeData = function(){ }; /** - * Format and manage armature configuration and armature animation - * @namespace + * ccs.armatureDataManager is a singleton object which format and manage armature configuration and armature animation + * @class * @name ccs.armatureDataManager */ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index f2908d4320..c6a0ef3b42 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -138,8 +138,8 @@ ccs.DataInfo = function () { }; /** - * CocoStudio data reader helper - * @namespace + * ccs.dataReaderHelper is a singleton object for reading CocoStudio data + * @class * @name ccs.dataReaderHelper */ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index 1bcae9fed4..9aabdd0504 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -24,8 +24,8 @@ ****************************************************************************/ /** - * The sprite frame cache helper - * @namespace + * ccs.spriteFrameCacheHelper is a singleton object, it's a sprite frame cache helper + * @class * @name ccs.spriteFrameCacheHelper */ ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index e1184bc5e4..d92c54e149 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -58,8 +58,8 @@ })(); /** - * Base object for ccs.uiReader - * @namespace + * ccs.uiReader is a singleton object which is the reader for Cocos Studio ui. + * @class * @name ccs.uiReader */ ccs.uiReader = /** @lends ccs.uiReader# */{ diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 90331eacb1..af1e7a9b84 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -24,8 +24,8 @@ ****************************************************************************/ /** - * Base singleton object for ccs.sceneReader - * @namespace + * ccs.sceneReader is the reader for Cocos Studio scene editor. + * @class * @name ccs.sceneReader */ ccs.sceneReader = /** @lends ccs.sceneReader# */{ From 8e3083da49bf5e4fcb5b918a07f3b1f9a5064ed4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Aug 2014 02:58:16 +0800 Subject: [PATCH 0577/1564] Doc #5829: Improve inline docs for CCScheduler --- cocos2d/core/CCScheduler.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index ce37a8c566..6f0e150e4e 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -36,7 +36,6 @@ cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1; /** * A list double-linked list used for "updates with priority" * @Class - * @Construct * @param {cc.ListEntry} prev * @param {cc.ListEntry} next * @param {cc.Class} target not retained (retained by hashUpdateEntry) @@ -54,9 +53,8 @@ cc.ListEntry = function (prev, next, target, priority, paused, markedForDeletion }; /** - * a update entry list + * A update entry list * @Class - * @Construct * @param {cc.ListEntry} list Which list does it belong to ? * @param {cc.ListEntry} entry entry in the list * @param {cc.Class} target hash key (retained) @@ -73,7 +71,6 @@ cc.HashUpdateEntry = function (list, entry, target, hh) { /** * Hash Element used for "selectors with interval" * @Class - * @Construct * @param {Array} timers * @param {cc.Class} target hash key (retained) * @param {Number} timerIndex @@ -234,9 +231,6 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ _currentTargetSalvaged:false, _updateHashLocked:false, //If true unschedule will not remove anything from a hash. Elements will only be marked for deletion. - /** - * Constructor - */ ctor:function () { var self = this; self._timeScale = 1.0; @@ -329,7 +323,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ }, /** - * returns time scale of scheduler + * Returns time scale of scheduler * @return {Number} */ getTimeScale:function () { @@ -632,7 +626,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ /** * Pause all selectors from all targets with a minimum priority.
    * You should only call this with kCCPriorityNonSystemMin or higher. - * @param minPriority + * @param {Number} minPriority */ pauseAllTargetsWithMinPriority:function (minPriority) { var idsWithSelectors = []; @@ -662,7 +656,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ /** * Resume selectors on a set of targets.
    * This can be useful for undoing a call to pauseAllCallbacks. - * @param targetsToResume + * @param {Array} targetsToResume */ resumeTargets:function (targetsToResume) { if (!targetsToResume) From 53a5ab118b4ad6a3345180b09dde60a79b7bde8f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Aug 2014 02:58:44 +0800 Subject: [PATCH 0578/1564] Doc #5829: Improve inline docs for sprites folder --- cocos2d/core/sprites/CCAnimation.js | 187 +++++++++---------- cocos2d/core/sprites/CCAnimationCache.js | 14 +- cocos2d/core/sprites/CCBakeSprite.js | 7 +- cocos2d/core/sprites/CCSprite.js | 197 +++++++++++---------- cocos2d/core/sprites/CCSpriteBatchNode.js | 116 ++++++------ cocos2d/core/sprites/CCSpriteFrame.js | 115 ++++++------ cocos2d/core/sprites/CCSpriteFrameCache.js | 52 +----- 7 files changed, 322 insertions(+), 366 deletions(-) diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index 2d500873f3..f72661c26b 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -34,35 +34,44 @@ *

    * @class * @extends cc.Class + * @param spriteFrame + * @param delayUnits + * @param userInfo + * @returns {AnimationFrame} */ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ _spriteFrame:null, _delayPerUnit:0, _userInfo:null, - /** - * Constructor of cc.AnimationFrame - * @param spriteFrame - * @param delayUnits - * @param userInfo - * @returns {AnimationFrame} - */ ctor:function (spriteFrame, delayUnits, userInfo) { this._spriteFrame = spriteFrame || null; this._delayPerUnit = delayUnits || 0; this._userInfo = userInfo || null; }, + /** + * Create a new animation frame and copy all contents into it + * @returns {AnimationFrame} + */ clone: function(){ var frame = new cc.AnimationFrame(); frame.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo); return frame; }, + /** + * Create a new animation frame and copy all contents into it + * @returns {AnimationFrame} + */ copyWithZone:function (pZone) { return cc.clone(this); }, + /** + * Create a new animation frame and copy all contents into it + * @returns {AnimationFrame} + */ copy:function (pZone) { var newFrame = new cc.AnimationFrame(); newFrame.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo); @@ -84,7 +93,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ }, /** - * cc.SpriteFrameName to be used + * Returns sprite frame to be used * @return {cc.SpriteFrame} */ getSpriteFrame:function () { @@ -92,7 +101,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ }, /** - * cc.SpriteFrameName to be used + * Sets sprite frame to be used * @param {cc.SpriteFrame} spriteFrame */ setSpriteFrame:function (spriteFrame) { @@ -100,7 +109,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ }, /** - * how many units of time the frame takes getter + * Returns how many units of time the frame takes getter * @return {Number} */ getDelayUnits:function () { @@ -108,7 +117,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ }, /** - * how many units of time the frame takes setter + * Sets how many units of time the frame takes setter * @param delayUnits */ setDelayUnits:function (delayUnits) { @@ -116,8 +125,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ }, /** - *

    A cc.AnimationFrameDisplayedNotification notification will be broadcasted when the frame is displayed with this dictionary as UserInfo.
    - * If UserInfo is nil, then no notification will be broadcasted.

    + * Returns the user custom information * @return {object} */ getUserInfo:function () { @@ -125,6 +133,7 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ }, /** + * Sets the user custom information * @param {object} userInfo */ setUserInfo:function (userInfo) { @@ -134,12 +143,11 @@ cc.AnimationFrame = cc.Class.extend(/** @lends cc.AnimationFrame# */{ /** * Creates an animation frame. - * @deprecated + * @deprecated since v3.0, please use the new construction instead * @param {cc.SpriteFrame} spriteFrame * @param {Number} delayUnits * @param {object} userInfo - * @example - * + * @see cc.AnimationFrame */ cc.AnimationFrame.create = function(spriteFrame,delayUnits,userInfo){ return new cc.AnimationFrame(spriteFrame,delayUnits,userInfo); @@ -150,23 +158,39 @@ cc.AnimationFrame.create = function(spriteFrame,delayUnits,userInfo){ * A cc.Animation object is used to perform animations on the cc.Sprite objects.
    *
    * The cc.Animation object contains cc.SpriteFrame objects, and a possible delay between the frames.
    - * You can animate a cc.Animation object by using the cc.Animate action. Example:
    + * You can animate a cc.Animation object by using the cc.Animate action. *

    * @class * @extends cc.Class + * @param {Array} frames + * @param {Number} delay + * @param {Number} [loops=1] * * @example - * //create an animation object - * var animation = cc.Animation.create(); + * // 1. Creates an empty animation + * var animation1 = new cc.Animation(); * - * //add a sprite frame to this animation - * animation.addFrameWithFile("grossini_dance_01.png"); + * // 2. Create an animation with sprite frames, delay and loops. + * var spriteFrames = []; + * var frame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); + * spriteFrames.push(frame); + * var animation1 = new cc.Animation(spriteFrames); + * var animation2 = new cc.Animation(spriteFrames, 0.2); + * var animation2 = new cc.Animation(spriteFrames, 0.2, 2); + * + * // 3. Create an animation with animation frames, delay and loops. + * var animationFrames = []; + * var frame = new cc.AnimationFrame(); + * animationFrames.push(frame); + * var animation1 = new cc.Animation(animationFrames); + * var animation2 = new cc.Animation(animationFrames, 0.2); + * var animation3 = new cc.Animation(animationFrames, 0.2, 2); * * //create an animate with this animation - * var action = cc.Animate.create(animation); + * var action = cc.animate(animation1); * * //run animate - * this._grossini.runAction(action); + * sprite.runAction(action); */ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ _frames:null, @@ -176,32 +200,6 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ _delayPerUnit:0, _totalDelayUnits:0, - /** - * Creates an animation. - * Constructor of cc.Animation - * @param {Array} frames - * @param {Number} delay - * @param {Number} [loops=1] - * @example - * // 1. Creates an empty animation - * var animation1 = new cc.Animation(); - * - * // 2. Create an animation with sprite frames, delay and loops. - * var spriteFrames = []; - * var frame = cache.getSpriteFrame("grossini_dance_01.png"); - * spriteFrames.push(frame); - * var animation1 = new cc.Animation(spriteFrames); - * var animation2 = new cc.Animation(spriteFrames, 0.2); - * var animation2 = new cc.Animation(spriteFrames, 0.2, 2); - * - * // 3. Create an animation with animation frames, delay and loops. - * var animationFrames = []; - * var frame = new cc.AnimationFrame(); - * animationFrames.push(frame); - * var animation1 = new cc.Animation(animationFrames); - * var animation2 = new cc.Animation(animationFrames, 0.2); - * var animation3 = new cc.Animation(animationFrames, 0.2, 2); - */ ctor:function (frames, delay, loops) { this._frames = []; @@ -224,7 +222,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ // attributes /** - * return array of CCAnimationFrames + * Returns the array of animation frames * @return {Array} */ getFrames:function () { @@ -232,7 +230,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * array of CCAnimationFrames setter + * Sets array of animation frames * @param {Array} frames */ setFrames:function (frames) { @@ -240,7 +238,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * adds a frame to a cc.Animation The frame will be added with one "delay unit". + * Adds a frame to a cc.Animation, the frame will be added with one "delay unit". * @param {cc.SpriteFrame} frame */ addSpriteFrame:function (frame) { @@ -276,7 +274,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * Initializes a cc.Animation with cc.AnimationFrame + * Initializes a cc.Animation with cc.AnimationFrame, do not call this method yourself, please pass parameters to constructor to initialize. * @param {Array} arrayOfAnimationFrames * @param {Number} delayPerUnit * @param {Number} [loops=1] @@ -299,6 +297,10 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ return true; }, + /** + * Clone the current animation + * @return {cc.Animation} + */ clone: function(){ var animation = new cc.Animation(); animation.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops); @@ -307,7 +309,8 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * @param {cc.Animation} pZone + * Clone the current animation + * @return {cc.Animation} */ copyWithZone:function (pZone) { var pCopy = new cc.Animation(); @@ -323,12 +326,17 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ return copyFrames; }, + /** + * Clone the current animation + * @param pZone + * @returns {cc.Animation} + */ copy:function (pZone) { return this.copyWithZone(null); }, /** - * return how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... + * Returns how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... * @return {Number} */ getLoops:function () { @@ -336,7 +344,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * set how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... + * Sets how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... * @param {Number} value */ setLoops:function (value) { @@ -344,7 +352,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * whether or not it shall restore the original frame when the animation finishes + * Sets whether or not it shall restore the original frame when the animation finishes * @param {Boolean} restOrigFrame */ setRestoreOriginalFrame:function (restOrigFrame) { @@ -352,7 +360,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * return whether or not it shall restore the original frame when the animation finishes + * Returns whether or not it shall restore the original frame when the animation finishes * @return {Boolean} */ getRestoreOriginalFrame:function () { @@ -360,7 +368,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * return duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit + * Returns duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit * @return {Number} */ getDuration:function () { @@ -368,7 +376,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * return Delay in seconds of the "delay unit" + * Returns delay in seconds of the "delay unit" * @return {Number} */ getDelayPerUnit:function () { @@ -376,7 +384,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * set Delay in seconds of the "delay unit" + * Sets delay in seconds of the "delay unit" * @param {Number} delayPerUnit */ setDelayPerUnit:function (delayPerUnit) { @@ -384,7 +392,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * return total Delay units of the cc.Animation. + * Returns total delay units of the cc.Animation. * @return {Number} */ getTotalDelayUnits:function () { @@ -392,7 +400,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ }, /** - * Initializes a cc.Animation with frames and a delay between frames + * Initializes a cc.Animation with frames and a delay between frames, do not call this method yourself, please pass parameters to constructor to initialize. * @param {Array} frames * @param {Number} delay * @param {Number} [loops=1] @@ -417,52 +425,53 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ return true; }, /** - * Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, + *

    Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. - * This is a hack, and should be removed once JSB fixes the retain/release bug + * This is a hack, and should be removed once JSB fixes the retain/release bug
    + * You will need to retain an object if you created an engine object and haven't added it into the scene graph during the same frame.
    + * Otherwise, JSB's native autorelease pool will consider this object a useless one and release it directly,
    + * when you want to use it later, a "Invalid Native Object" error will be raised.
    + * The retain function can increase a reference count for the native object to avoid it being released,
    + * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    + * retain and release function call should be paired in developer's game code.

    + * @function + * @see cc.Animation#release */ retain:function () { }, + /** + *

    Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB, + * and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB. + * This is a hack, and should be removed once JSB fixes the retain/release bug
    + * You will need to retain an object if you created an engine object and haven't added it into the scene graph during the same frame.
    + * Otherwise, JSB's native autorelease pool will consider this object a useless one and release it directly,
    + * when you want to use it later, a "Invalid Native Object" error will be raised.
    + * The retain function can increase a reference count for the native object to avoid it being released,
    + * you need to manually invoke release function when you think this object is no longer needed, otherwise, there will be memory learks.
    + * retain and release function call should be paired in developer's game code.

    + * @function + * @see cc.Animation#retain + */ release:function () { } }); /** * Creates an animation. - * @deprecated + * @deprecated since v3.0, please use new construction instead + * @see cc.Animation * @param {Array} frames * @param {Number} delay * @param {Number} [loops=1] * @return {cc.Animation} - * @example - * 1. - * //Creates an empty animation - * var animation1 = cc.Animation.create(); - * - * 2. - * //Create an animation with sprite frames , delay and loops. - * var spriteFrames = []; - * var frame = cache.getSpriteFrame("grossini_dance_01.png"); - * spriteFrames.push(frame); - * var animation1 = cc.Animation.create(spriteFrames); - * var animation2 = cc.Animation.create(spriteFrames, 0.2); - * var animation2 = cc.Animation.create(spriteFrames, 0.2, 2); - * - * 3. - * //Create an animation with animation frames , delay and loops. - * var animationFrames = []; - * var frame = new cc.AnimationFrame(); - * animationFrames.push(frame); - * var animation1 = cc.Animation.create(animationFrames); - * var animation2 = cc.Animation.create(animationFrames, 0.2); - * var animation3 = cc.Animation.create(animationFrames, 0.2, 2); */ cc.Animation.create = function (frames, delay, loops) { return new cc.Animation(frames, delay, loops); }; /** - * @deprecated + * @deprecated since v3.0, please use new construction instead + * @see cc.Animation * @type {Function} */ cc.Animation.createWithAnimationFrames = cc.Animation.create; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 911eff89b5..3788a3bda8 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -48,8 +48,8 @@ cc.animationCache = /** @lends cc.animationCache# */{ }, /** - * Deletes a cc.Animation from the cache. - * @param {String} name + * Deletes a cc.Animation from the cache. + * @param {String} name */ removeAnimation:function (name) { if (!name) { @@ -75,14 +75,6 @@ cc.animationCache = /** @lends cc.animationCache# */{ return null; }, - /** - *

    - * Adds an animation from an NSDictionary
    - * Make sure that the frames were previously loaded in the cc.SpriteFrameCache. - *

    - * @param {object} dictionary - * @param {String} plist - */ _addAnimationsWithDictionary:function (dictionary,plist) { var animations = dictionary["animations"]; if (!animations) { @@ -117,7 +109,7 @@ cc.animationCache = /** @lends cc.animationCache# */{ /** *

    - * Adds an animation from a plist file.
    + * Adds an animations from a plist file.
    * Make sure that the frames were previously loaded in the cc.SpriteFrameCache. *

    * @param {String} plist diff --git a/cocos2d/core/sprites/CCBakeSprite.js b/cocos2d/core/sprites/CCBakeSprite.js index f3a87e0fe7..5a9f0c44bf 100644 --- a/cocos2d/core/sprites/CCBakeSprite.js +++ b/cocos2d/core/sprites/CCBakeSprite.js @@ -22,7 +22,12 @@ THE SOFTWARE. ****************************************************************************/ -cc.BakeSprite = cc.Sprite.extend({ +/** + * cc.BakeSprite is a type of sprite that will be cached. + * @class + * @extend cc.Sprite + */ +cc.BakeSprite = cc.Sprite.extend(/** @lends cc.BakeSprite# */{ _cacheCanvas: null, _cacheContext: null, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index dd58421496..d2a380bd95 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -71,7 +71,7 @@ cc.generateTintImageWithMultiply = function(image, color, rect, renderCanvas){ }; /** - * generate tinted texture with lighter. + * Generate tinted texture with lighter. * lighter: The source and destination colors are added to each other, resulting in brighter colors, * moving towards color values of 1 (maximum brightness for that color). * @function @@ -134,7 +134,7 @@ cc.generateTintImage = function (texture, tintedImgCache, color, rect, renderCan }; /** - * generate texture's cache for texture tint + * Generates texture's cache for texture tint * @function * @param {HTMLImageElement} texture * @return {Array} @@ -267,6 +267,28 @@ cc._getCompositeOperationByBlendFunc = function(blendFunc){ * @class * @extends cc.Node * + * @param {String|cc.SpriteFrame|HTMLImageElement|cc.Texture2D} fileName The string which indicates a path to image file, e.g., "scene1/monster.png". + * @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite. + * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. + * @example + * + * 1.Create a sprite with image path and rect + * var sprite1 = new cc.Sprite("res/HelloHTML5World.png"); + * var sprite2 = new cc.Sprite("res/HelloHTML5World.png",cc.rect(0,0,480,320)); + * + * 2.Create a sprite with a sprite frame name. Must add "#" before frame name. + * var sprite = new cc.Sprite('#grossini_dance_01.png'); + * + * 3.Create a sprite with a sprite frame + * var spriteFrame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); + * var sprite = new cc.Sprite(spriteFrame); + * + * 4.Create a sprite with an existing texture contained in a CCTexture2D object + * After creation, the rect will be the size of the texture, and the offset will be (0,0). + * var texture = cc.textureCache.addImage("HelloHTML5World.png"); + * var sprite1 = new cc.Sprite(texture); + * var sprite2 = new cc.Sprite(texture, cc.rect(0,0,480,320)); + * * @property {Boolean} dirty - Indicates whether the sprite needs to be updated. * @property {Boolean} flippedX - Indicates whether or not the spirte is flipped on x axis. * @property {Boolean} flippedY - Indicates whether or not the spirte is flipped on y axis. @@ -278,10 +300,6 @@ cc._getCompositeOperationByBlendFunc = function(blendFunc){ * @property {cc.TextureAtlas} textureAtlas - The weak reference of the cc.TextureAtlas when the sprite is rendered using via cc.SpriteBatchNode. * @property {cc.SpriteBatchNode} batchNode - The batch node object if this sprite is rendered by cc.SpriteBatchNode. * @property {cc.V3F_C4B_T2F_Quad} quad - <@readonly> The quad (tex coords, vertex coords and color) information. - * - * @example - * var aSprite = new cc.Sprite(); - * aSprite.initWithFile("HelloHTML5World.png",cc.rect(0,0,480,320)); */ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ dirty:false, @@ -325,10 +343,19 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ //Only for texture update judgment _oldDisplayColor: cc.color.WHITE, + /** + * Returns whether the texture have been loaded + * @returns {boolean} + */ textureLoaded:function(){ return this._textureLoaded; }, + /** + * Add a event listener for texture loaded event. + * @param {Function} callback + * @param {Object} target + */ addLoadedEventListener:function(callback, target){ if(!this._loadedEventListeners) this._loadedEventListeners = []; @@ -347,15 +374,15 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Whether or not the Sprite needs to be updated in the Atlas - * @return {Boolean} true if the sprite needs to be updated in the Atlas, false otherwise. + * Returns whether or not the Sprite needs to be updated in the Atlas + * @return {Boolean} True if the sprite needs to be updated in the Atlas, false otherwise. */ isDirty:function () { return this.dirty; }, /** - * Makes the Sprite to be updated in the Atlas. + * Makes the sprite to be updated in the Atlas. * @param {Boolean} bDirty */ setDirty:function (bDirty) { @@ -379,7 +406,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Set the index used on the TextureAtlas. + * Sets the index used on the TextureAtlas. * @warning Don't modify this value unless you know what you are doing * @param {Number} atlasIndex */ @@ -388,7 +415,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * returns the rect of the cc.Sprite in points + * Returns the rect of the cc.Sprite in points * @return {cc.Rect} */ getTextureRect:function () { @@ -396,7 +423,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Gets the weak reference of the cc.TextureAtlas when the sprite is rendered using via cc.SpriteBatchNode + * Returns the weak reference of the cc.TextureAtlas when the sprite is rendered using via cc.SpriteBatchNode * @return {cc.TextureAtlas} */ getTextureAtlas:function () { @@ -412,7 +439,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex. + * Returns the offset position of the sprite. Calculated automatically by editors like Zwoptex. * @return {cc.Point} */ getOffsetPosition:function () { @@ -427,7 +454,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * conforms to cc.TextureProtocol protocol + * Returns the blend function * @return {cc.BlendFunc} */ getBlendFunc:function () { @@ -435,13 +462,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Initializes a sprite with an SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite + * Initializes a sprite with an SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite.
    + * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself, * @param {cc.SpriteFrame} spriteFrame A CCSpriteFrame object. It should includes a valid texture and a rect * @return {Boolean} true if the sprite is initialized properly, false otherwise. - * @example - * var spriteFrame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); - * var sprite = new cc.Sprite(); - * sprite.initWithSpriteFrame(spriteFrame); */ initWithSpriteFrame:function (spriteFrame) { @@ -466,6 +490,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * Initializes a sprite with a sprite frame name.
    * A cc.SpriteFrame will be fetched from the cc.SpriteFrameCache by name.
    * If the cc.SpriteFrame doesn't exist it will raise an exception.
    + * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself. * @param {String} spriteFrameName A key string that can fected a volid cc.SpriteFrame from cc.SpriteFrameCache * @return {Boolean} true if the sprite is initialized properly, false otherwise. * @example @@ -480,7 +505,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * tell the sprite to use batch node render. + * Tell the sprite to use batch node render. * @param {cc.SpriteBatchNode} batchNode */ useBatchNode:function (batchNode) { @@ -505,6 +530,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ this._rect.height = rect.height; }, + /** + * Sort all children of this sprite node. + * @override + */ sortAllChildren:function () { if (this._reorderChildDirty) { var _children = this._children; @@ -563,7 +592,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Removes a child from the sprite. (override cc.Node ) + * Removes a child from the sprite. * @param child * @param cleanup whether or not cleanup all running actions * @override @@ -575,7 +604,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * visible setter (override cc.Node ) + * Sets whether the sprite is visible or not. * @param {Boolean} visible * @override */ @@ -585,7 +614,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Removes all children from the container (override cc.Node ) + * Removes all children from the container. * @param cleanup whether or not cleanup all running actions * @override */ @@ -605,8 +634,8 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // /** - * set Recursively is or isn't Dirty - * used only when parent is cc.SpriteBatchNode + * Sets recursively the dirty flag. + * Used only when parent is cc.SpriteBatchNode * @param {Boolean} value */ setDirtyRecursively:function (value) { @@ -639,7 +668,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * IsRelativeAnchorPoint setter (override cc.Node ) + * Sets whether ignore anchor point for positioning * @param {Boolean} relative * @override */ @@ -677,12 +706,12 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ /** *

    - * Returns the flag which indicates whether the sprite is flipped horizontally or not.
    + * Returns the flag which indicates whether the sprite is flipped horizontally or not.
    *
    * It only flips the texture of the sprite, and not the texture of the sprite's children.
    * Also, flipping the texture doesn't alter the anchorPoint.
    * If you want to flip the anchorPoint too, and/or to flip the children too use:
    - * sprite->setScaleX(sprite->getScaleX() * -1);

    + * sprite.setScaleX(sprite.getScaleX() * -1);

    * @return {Boolean} true if the sprite is flipped horizontally, false otherwise. */ isFlippedX:function () { @@ -696,7 +725,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * It only flips the texture of the sprite, and not the texture of the sprite's children.
    * Also, flipping the texture doesn't alter the anchorPoint.
    * If you want to flip the anchorPoint too, and/or to flip the children too use:
    - * sprite->setScaleY(sprite->getScaleY() * -1);

    + * sprite.setScaleY(sprite.getScaleY() * -1);

    * @return {Boolean} true if the sprite is flipped vertically, false otherwise. */ isFlippedY:function () { @@ -707,29 +736,33 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // RGBA protocol // /** - * opacity: conforms to CCRGBAProtocol protocol + * Sets whether opacity modify color or not. * @function * @param {Boolean} modify */ setOpacityModifyRGB:null, /** - * return IsOpacityModifyRGB value + * Returns whether opacity modify color or not. * @return {Boolean} */ isOpacityModifyRGB:function () { return this._opacityModifyRGB; }, + /** + * Update the display opacity. + * @function + */ updateDisplayedOpacity: null, // Animation /** - * changes the display frame with animation name and index.
    + * Changes the display frame with animation name and index.
    * The animation name will be get from the CCAnimationCache - * @param animationName - * @param frameIndex + * @param {String} animationName + * @param {Number} frameIndex */ setDisplayFrameWithAnimationName:function (animationName, frameIndex) { cc.assert(animationName, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3); @@ -768,6 +801,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, // CCTextureProtocol + /** + * Returns the texture of the sprite node + * @returns {cc.Texture2D} + */ getTexture:function () { return this._texture; }, @@ -781,13 +818,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _textureRect_Canvas: null, _drawSize_Canvas: null, - /** - * Constructor - * @function - * @param {String|cc.SpriteFrame|cc.SpriteBatchNode|HTMLImageElement|cc.Texture2D} fileName sprite construct parameter - * @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite. - * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. - */ ctor: null, _softInit: function (fileName, rect, rotated) { @@ -838,7 +868,8 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ setBlendFunc: null, /** - * Initializes an empty sprite with nothing init. + * Initializes an empty sprite with nothing init.
    + * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself. * @function * @return {Boolean} */ @@ -846,18 +877,16 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ /** *

    - * Initializes a sprite with an image filename. + * Initializes a sprite with an image filename.
    * - * This method will find pszFilename from local file system, load its content to CCTexture2D, - * then use CCTexture2D to create a sprite. - * After initialization, the rect used will be the size of the image. The offset will be (0,0). + * This method will find pszFilename from local file system, load its content to CCTexture2D,
    + * then use CCTexture2D to create a sprite.
    + * After initialization, the rect used will be the size of the image. The offset will be (0,0).
    + * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself. *

    * @param {String} filename The path to an image file in local file system * @param {cc.Rect} rect The rectangle assigned the content area from texture. * @return {Boolean} true if the sprite is initialized properly, false otherwise. - * @example - * var mySprite = new cc.Sprite(); - * mySprite.initWithFile("HelloHTML5World.png",cc.rect(0,0,480,320)); */ initWithFile:function (filename, rect) { cc.assert(filename, cc._LogInfos.Sprite_initWithFile); @@ -877,39 +906,36 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ /** * Initializes a sprite with a texture and a rect in points, optionally rotated.
    - * After initialization, the rect used will be the size of the texture, and the offset will be (0,0). + * After initialization, the rect used will be the size of the texture, and the offset will be (0,0).
    + * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself. * @function * @param {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture A pointer to an existing CCTexture2D object. You can use a CCTexture2D object for many sprites. * @param {cc.Rect} rect Only the contents inside rect of this texture will be applied for this sprite. * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. * @return {Boolean} true if the sprite is initialized properly, false otherwise. - * @example - * var img =cc.textureCache.addImage("HelloHTML5World.png"); - * var mySprite = new cc.Sprite(); - * mySprite.initWithTexture(img,cc.rect(0,0,480,320)); */ initWithTexture: null, _textureLoadedCallback: null, /** - * updates the texture rect of the CCSprite in points. + * Updates the texture rect of the CCSprite in points. * @function * @param {cc.Rect} rect a rect of texture - * @param {Boolean} rotated - * @param {cc.Size} untrimmedSize + * @param {Boolean} [rotated] Whether or not the texture is rotated + * @param {cc.Size} [untrimmedSize] The original pixels size of the texture */ setTextureRect:null, // BatchNode methods /** - * updates the quad according the the rotation, position, scale values. + * Updates the quad according the the rotation, position, scale values. * @function */ updateTransform: null, /** - * Add child to sprite (override cc.Node ) + * Add child to sprite (override cc.Node) * @function * @param {cc.Sprite} child * @param {Number} localZOrder child's zOrder @@ -952,31 +978,35 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Opacity setter + * Sets opacity of the sprite * @function * @param {Number} opacity */ setOpacity:null, /** - * Color setter + * Sets color of the sprite * @function * @param {cc.Color} color3 */ setColor: null, + /** + * Updates the display color + * @function + */ updateDisplayedColor: null, // Frames /** - * Sets a new spriteFrame to the cc.Sprite. + * Sets a new sprite frame to the sprite. * @function * @param {cc.SpriteFrame|String} newFrame */ setSpriteFrame: null, /** - * Sets a new display frame to the cc.Sprite. + * Sets a new display frame to the sprite. * @param {cc.SpriteFrame|String} newFrame * @deprecated */ @@ -1019,7 +1049,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // CCTextureProtocol /** - * Texture of sprite setter + * Sets the texture of sprite * @function * @param {cc.Texture2D|String} texture */ @@ -1154,56 +1184,41 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ /** * Create a sprite with image path or frame name or texture or spriteFrame. - * @deprecated + * @deprecated since v3.0, please use new construction instead + * @see cc.Sprite * @param {String|cc.SpriteFrame|HTMLImageElement|cc.Texture2D} fileName The string which indicates a path to image file, e.g., "scene1/monster.png". * @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite. * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. * @return {cc.Sprite} A valid sprite object - * @example - * - * 1.Create a sprite with image path and rect - * var sprite1 = cc.Sprite.create("res/HelloHTML5World.png"); - * var sprite2 = cc.Sprite.create("res/HelloHTML5World.png",cc.rect(0,0,480,320)); - * - * 2.Create a sprite with a sprite frame name. Must add "#" before frame name. - * var sprite = cc.Sprite.create('#grossini_dance_01.png'); - * - * 3.Create a sprite with a sprite frame - * var spriteFrame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); - * var sprite = cc.Sprite.create(spriteFrame); - * - * 4.Create a sprite with an exsiting texture contained in a CCTexture2D object - * After creation, the rect will be the size of the texture, and the offset will be (0,0). - * var texture = cc.textureCache.addImage("HelloHTML5World.png"); - * var sprite1 = cc.Sprite.create(texture); - * var sprite2 = cc.Sprite.create(texture, cc.rect(0,0,480,320)); - * */ cc.Sprite.create = function (fileName, rect, rotated) { return new cc.Sprite(fileName, rect, rotated); }; /** - * @deprecated - * @type {Function} + * @deprecated since v3.0, please use new construction instead + * @see cc.Sprite + * @function */ cc.Sprite.createWithTexture = cc.Sprite.create; /** - * @deprecated - * @type {Function} + * @deprecated since v3.0, please use new construction instead + * @see cc.Sprite + * @function */ cc.Sprite.createWithSpriteFrameName = cc.Sprite.create; /** - * @deprecated - * @type {Function} + * @deprecated since v3.0, please use new construction instead + * @see cc.Sprite + * @function */ cc.Sprite.createWithSpriteFrame = cc.Sprite.create; /** * cc.Sprite invalid index on the cc.SpriteBatchNode * @constant - * @type Number + * @type {Number} */ cc.Sprite.INDEX_NOT_INITIALIZED = -1; diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index a9cee04765..e9031348d6 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -50,12 +50,19 @@ cc.DEFAULT_SPRITE_BATCH_CAPACITY = 29; * @class * @extends cc.Node * + * @param {String|cc.Texture2D} fileImage + * @param {Number} capacity + * @example + * + * // 1. create a SpriteBatchNode with image path + * var spriteBatchNode = new cc.SpriteBatchNode("res/animations/grossini.png", 50); + * + * // 2. create a SpriteBatchNode with texture + * var texture = cc.textureCache.addImage("res/animations/grossini.png"); + * var spriteBatchNode = new cc.SpriteBatchNode(texture,50); + * * @property {cc.TextureAtlas} textureAtlas - The texture atlas * @property {Array} descendants - <@readonly> Descendants of sprite batch node - * - * @example - * //create a SpriteBatchNode - * var parent2 = cc.SpriteBatchNode.create("res/animations/grossini.png", 50); */ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ textureAtlas: null, @@ -135,9 +142,10 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ /** *

    - * initializes a cc.SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
    + * Initializes a cc.SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
    * The capacity will be increased in 33% in runtime if it run out of space.
    - * The file will be loaded using the TextureMgr. + * The file will be loaded using the TextureMgr.
    + * Please pass parameters to constructor to initialize the sprite batch node, do not call this function yourself. *

    * @param {String} fileImage * @param {Number} capacity @@ -158,7 +166,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ *

    * initializes a cc.SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
    * The capacity will be increased in 33% in runtime if it run out of space.
    - * The file will be loaded using the TextureMgr. + * The file will be loaded using the TextureMgr.
    + * Please pass parameters to constructor to initialize the sprite batch node, do not call this function yourself. *

    * @param {String} fileImage * @param {Number} capacity @@ -172,7 +181,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * increase Atlas Capacity + * Increase Atlas Capacity */ increaseAtlasCapacity: function () { // if we're going beyond the current TextureAtlas's capacity, @@ -190,7 +199,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter. + * Removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter. * @warning Removing a child from a cc.SpriteBatchNode is very slow * @param {Number} index * @param {Boolean} doCleanup @@ -200,7 +209,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * rebuild index in order for child + * Rebuild index in order for child * @param {cc.Sprite} pobParent * @param {Number} index * @return {Number} @@ -232,7 +241,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * get highest atlas index in child + * Returns highest atlas index in child * @param {cc.Sprite} sprite * @return {Number} */ @@ -246,7 +255,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * get lowest atlas index in child + * Returns lowest atlas index in child * @param {cc.Sprite} sprite * @return {Number} */ @@ -260,7 +269,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * get atlas index for child + * Returns atlas index for child * @param {cc.Sprite} sprite * @param {Number} nZ * @return {Number} @@ -310,7 +319,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * set the source blending function for the texture + * Sets the source and destination blending function for the texture * @param {Number | cc.BlendFunc} src * @param {Number} dst */ @@ -322,7 +331,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * returns the blending function used for the texture + * Returns the blending function used for the texture * @return {cc.BlendFunc} */ getBlendFunc: function () { @@ -330,7 +339,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * (override reorderChild of cc.Node) + * Reorder children (override reorderChild of cc.Node) * @override * @param {cc.Sprite} child * @param {Number} zOrder @@ -353,9 +362,9 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * remove child from cc.SpriteBatchNode (override removeChild of cc.Node) + * Removes a child from cc.SpriteBatchNode (override removeChild of cc.Node) * @param {cc.Sprite} child - * @param cleanup + * @param {Boolean} cleanup */ removeChild: function (child, cleanup) { // explicit null handling @@ -376,27 +385,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ _useCache: false, _originalTexture: null, - /** - *

    - * Constructor - * creates a cc.SpriteBatchNodeCanvas with a file image (.png, .jpg etc) with a default capacity of 29 children.
    - * The capacity will be increased in 33% in runtime if it run out of space.
    - * The file will be loaded using the TextureMgr.
    - * Constructor of cc.SpriteBatchNode - *

    - * @function - * - * @param {String} fileImage - * @param {Number} capacity - * @example - * 1. - * //create a SpriteBatchNode with image path - * var spriteBatchNode = cc.SpriteBatchNode.create("res/animations/grossini.png", 50); - * 2. - * //create a SpriteBatchNode with texture - * var texture = cc.textureCache.addImage("res/animations/grossini.png"); - * var spriteBatchNode = cc.SpriteBatchNode.create(texture,50); - */ ctor: null, _ctorForCanvas: function (fileImage, capacity) { @@ -432,7 +420,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ texture2D && this.initWithTexture(texture2D, capacity); }, - /** *

    * Updates a quad at a certain index into the texture atlas. The CCSprite won't be added into the children array.
    @@ -634,8 +621,9 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ /** *

    - * initializes a CCSpriteBatchNode with a texture2d and capacity of children.
    - * The capacity will be increased in 33% in runtime if it run out of space. + * Initializes a cc.SpriteBatchNode with a texture2d and capacity of children.
    + * The capacity will be increased in 33% in runtime if it run out of space.
    + * Please pass parameters to constructor to initialize the sprite batch node, do not call this function yourself. *

    * @function * @param {cc.Texture2D} tex @@ -669,9 +657,9 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * add child helper - * @param {cc.Sprite} sprite - * @param {Number} index + * Insert a child + * @param {cc.Sprite} sprite The child sprite + * @param {Number} index The insert index */ insertChild: function (sprite, index) { sprite.batchNode = this; @@ -706,7 +694,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * addChild helper, faster than insertChild + * Add child at the end, faster than insert child * @function * @param {cc.Sprite} sprite */ @@ -748,7 +736,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * remove sprite from TextureAtlas + * Removes sprite from TextureAtlas * @function * @param {cc.Sprite} sprite */ @@ -807,7 +795,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, // CCTextureProtocol /** - * Return texture of cc.SpriteBatchNode + * Returns texture of the sprite batch node * @function * @return {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} */ @@ -822,7 +810,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * Texture of cc.SpriteBatchNode setter + * Sets the texture of the sprite batch node. * @function * @param {cc.Texture2D} texture */ @@ -841,7 +829,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * Don't call visit on it's children ( override visit of cc.Node ) + * Don't call visit on its children ( override visit of cc.Node ) * @function * @override * @param {CanvasRenderingContext2D} ctx @@ -897,7 +885,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - * Add child to cc.SpriteBatchNode (override addChild of cc.Node) + * Add child to the sprite batch node (override addChild of cc.Node) * @function * @override * @param {cc.Sprite} child @@ -945,8 +933,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, /** - *

    Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
    - * (override removeAllChildren of cc.Node)

    + * Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
    + * (override removeAllChildren of cc.Node) * @function * @param {Boolean} cleanup */ @@ -982,6 +970,9 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ this.textureAtlas.removeAllQuads(); }, + /** + * Sort all children nodes (override draw of cc.Node) + */ sortAllChildren: null, _sortAllChildrenForCanvas: function () { @@ -1047,8 +1038,9 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ this._reorderChildDirty = false; } }, + /** - * draw cc.SpriteBatchNode (override draw of cc.Node) + * Draw the sprite batch node (override draw of cc.Node) * @function */ draw: null, @@ -1115,25 +1107,19 @@ cc.defineGetterSetter(_p, "descendants", _p.getDescendants); * The capacity will be increased in 33% in runtime if it run out of space.
    * The file will be loaded using the TextureMgr.
    *

    - * @deprecated + * @deprecated since v3.0, please use new construction instead + * @see cc.SpriteBatchNode * @param {String|cc.Texture2D} fileImage * @param {Number} capacity * @return {cc.SpriteBatchNode} - * @example - * 1. - * //create a SpriteBatchNode with image path - * var spriteBatchNode = cc.SpriteBatchNode.create("res/animations/grossini.png", 50); - * 2. - * //create a SpriteBatchNode with texture - * var texture = cc.textureCache.addImage("res/animations/grossini.png"); - * var spriteBatchNode = cc.SpriteBatchNode.create(texture,50); */ cc.SpriteBatchNode.create = function (fileImage, capacity) { return new cc.SpriteBatchNode(fileImage, capacity); }; /** - * @deprecated - * @type {Function} + * @deprecated since v3.0, please use new construction instead + * @see cc.SpriteBatchNode + * @function */ cc.SpriteBatchNode.createWithTexture = cc.SpriteBatchNode.create; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index dea5b6e84f..5f06009d4d 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -35,9 +35,21 @@ * @class * @extends cc.Class * + * @param {String|cc.Texture2D} filename + * @param {cc.Rect} rect If parameters' length equal 2, rect in points, else rect in pixels + * @param {Boolean} [rotated] Whether the frame is rotated in the texture + * @param {cc.Point} [offset] The offset of the frame in the texture + * @param {cc.Size} [originalSize] The size of the frame in the texture + * * @example - * var texture = cc.textureCache.addImage(s_dragon_animation); - * var frame0 = cc.SpriteFrame.create(texture, cc.rect(132 * 0, 132 * 0, 132, 132)); + * // 1. Create a cc.SpriteFrame with image path + * var frame1 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128)); + * var frame2 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128),false,0,cc.size(90,128)); + * + * // 2. Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. + * var texture = cc.textureCache.addImage("res/grossini_dance.png"); + * var frame1 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128)); + * var frame2 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128),false,0,cc.size(90,128)); */ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ _offset:null, @@ -52,28 +64,6 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ _textureLoaded:false, _eventListeners:null, - /** - *

    - * Create a cc.SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
    - * The originalSize is the size in pixels of the frame before being trimmed.
    - * Constructor of cc.SpriteFrame - *

    - * - * @param {String|cc.Texture2D} filename - * @param {cc.Rect} rect if parameters' length equal 2, rect in points, else rect in pixels - * @param {Boolean} rotated - * @param {cc.Point} offset - * @param {cc.Size} originalSize - * @example - * // 1.Create a cc.SpriteFrame with image path - * var frame1 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128)); - * var frame2 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128),false,0,cc.size(90,128)); - * - * // 2.Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. - * var texture = cc.textureCache.addImage("res/grossini_dance.png"); - * var frame1 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128)); - * var frame2 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128),false,0,cc.size(90,128)); - */ ctor:function (filename, rect, rotated, offset, originalSize) { this._offset = cc.p(0, 0); this._offsetInPixels = cc.p(0, 0); @@ -92,11 +82,19 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ } }, - // attributes + /** + * Returns whether the texture have been loaded + * @returns {boolean} + */ textureLoaded:function(){ return this._textureLoaded; }, + /** + * Add a event listener for texture loaded event. + * @param {Function} callback + * @param {Object} target + */ addLoadedEventListener:function(callback, target){ if (this._eventListeners == null){ this._eventListeners = []; @@ -115,6 +113,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** + * Gets the rect of the frame in the texture * @return {cc.Rect} */ getRectInPixels:function () { @@ -123,6 +122,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** + * Sets the rect of the frame in the texture * @param {cc.Rect} rectInPixels */ setRectInPixels:function (rectInPixels) { @@ -137,9 +137,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - *

    - * return is rotated of SpriteFrame.
    - *

    + * Returns whether the sprite frame is rotated in the texture. * @return {Boolean} */ isRotated:function () { @@ -147,7 +145,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * set SpriteFrame is rotated + * Set whether the sprite frame is rotated in the texture. * @param {Boolean} bRotated */ setRotated:function (bRotated) { @@ -155,7 +153,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * get rect of the frame + * Returns the rect of the sprite frame in the texture * @return {cc.Rect} */ getRect:function () { @@ -164,7 +162,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * set rect of the frame + * Sets the rect of the sprite frame in the texture * @param {cc.Rect} rect */ setRect:function (rect) { @@ -179,7 +177,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * get offset of the frame + * Returns the offset of the sprite frame in the texture in pixel * @return {cc.Point} */ getOffsetInPixels:function () { @@ -187,7 +185,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * set offset of the frame + * Sets the offset of the sprite frame in the texture in pixel * @param {cc.Point} offsetInPixels */ setOffsetInPixels:function (offsetInPixels) { @@ -197,8 +195,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * get original size of the trimmed image - * @const + * Returns the original size of the trimmed image * @return {cc.Size} */ getOriginalSizeInPixels:function () { @@ -206,7 +203,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * set original size of the trimmed image + * Sets the original size of the trimmed image * @param {cc.Size} sizeInPixels */ setOriginalSizeInPixels:function (sizeInPixels) { @@ -215,8 +212,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * get original size of the trimmed image - * @const + * Returns the original size of the trimmed image * @return {cc.Size} */ getOriginalSize:function () { @@ -224,7 +220,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * set original size of the trimmed image + * Sets the original size of the trimmed image * @param {cc.Size} sizeInPixels */ setOriginalSize:function (sizeInPixels) { @@ -233,7 +229,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * get texture of the frame + * Returns the texture of the frame * @return {cc.Texture2D} */ getTexture:function () { @@ -249,7 +245,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * set texture of the frame, the texture is retained + * Sets the texture of the frame, the texture is retained automatically * @param {cc.Texture2D} texture */ setTexture:function (texture) { @@ -289,8 +285,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * Offset getter - * @const + * Returns the offset of the frame in the texture * @return {cc.Point} */ getOffset:function () { @@ -298,7 +293,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * offset setter + * Sets the offset of the frame in the texture * @param {cc.Point} offsets */ setOffset:function (offsets) { @@ -306,6 +301,10 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this._offset.y = offsets.y; }, + /** + * Clone the sprite frame + * @returns {SpriteFrame} + */ clone: function(){ var frame = new cc.SpriteFrame(); frame.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels); @@ -314,7 +313,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ }, /** - * copy a new SpriteFrame + * Copy the sprite frame * @return {cc.SpriteFrame} */ copyWithZone:function () { @@ -324,12 +323,17 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ return copy; }, + /** + * Copy the sprite frame + * @returns {cc.SpriteFrame} + */ copy:function () { return this.copyWithZone(); }, /** - * Initializes SpriteFrame with Texture, rect, rotated, offset and originalSize in pixels. + * Initializes SpriteFrame with Texture, rect, rotated, offset and originalSize in pixels.
    + * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself. * @param {String|cc.Texture2D} texture * @param {cc.Rect} rect if parameters' length equal 2, rect in points, else rect in pixels * @param {Boolean} [rotated=false] @@ -390,32 +394,23 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * Create a cc.SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
    * The originalSize is the size in pixels of the frame before being trimmed. *

    - * @deprecated + * @deprecated since v3.0, please use new construction instead + * @see cc.SpriteFrame * @param {String|cc.Texture2D} filename * @param {cc.Rect} rect if parameters' length equal 2, rect in points, else rect in pixels * @param {Boolean} rotated * @param {cc.Point} offset * @param {cc.Size} originalSize * @return {cc.SpriteFrame} - * @example - * 1. - * //Create a cc.SpriteFrame with image path - * var frame1 = cc.SpriteFrame.create("res/grossini_dance.png",cc.rect(0,0,90,128)); - * var frame2 = cc.SpriteFrame.create("res/grossini_dance.png",cc.rect(0,0,90,128),false,0,cc.size(90,128)); - * - * 2. - * //Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. - * var texture = cc.textureCache.addImage("res/grossini_dance.png"); - * var frame1 = cc.SpriteFrame.create(texture, cc.rect(0,0,90,128)); - * var frame2 = cc.SpriteFrame.create(texture, cc.rect(0,0,90,128),false,0,cc.size(90,128)); */ cc.SpriteFrame.create = function (filename, rect, rotated, offset, originalSize) { return new cc.SpriteFrame(filename,rect,rotated,offset,originalSize); }; /** - * @deprecated - * @type {Function} + * @deprecated since v3.0, please use new construction instead + * @see cc.SpriteFrame + * @function */ cc.SpriteFrame.createWithTexture = cc.SpriteFrame.create; diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 496f5ac397..189eaa2c00 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -43,70 +43,24 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ _spriteFramesAliases: {}, _frameConfigCache : {}, - /** - * Returns a Core Graphics rectangle structure corresponding to the data in a given string.
    - * The string is not localized, so items are always separated with a comma.
    - * If the string is not well-formed, the function returns cc.rect(0, 0, 0, 0). - * @function - * @param {String} content content A string object whose contents are of the form "{{x,y},{w, h}}",
    - * where x is the x coordinate, y is the y coordinate, w is the width, and h is the height.
    - * These components can represent integer or float values. - * @return {cc.Rect} A Core Graphics structure that represents a rectangle. - * Constructor - * @example - * // example - * var rect = this._rectFromString("{{3,2},{4,5}}"); - */ _rectFromString : function (content) { var result = this._CCNS_REG2.exec(content); if(!result) return cc.rect(0, 0, 0, 0); return cc.rect(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3]), parseFloat(result[4])); }, - /** - * Returns a Core Graphics point structure corresponding to the data in a given string. - * @function - * @param {String} content A string object whose contents are of the form "{x,y}", - * where x is the x coordinate and y is the y coordinate.
    - * The x and y values can represent integer or float values.
    - * The string is not localized, so items are always separated with a comma.
    - * @return {cc.Point} A Core Graphics structure that represents a point.
    - * If the string is not well-formed, the function returns cc.p(0,0). - * Constructor - * @example - * //example - * var point = this._pointFromString("{3.0,2.5}"); - */ _pointFromString : function (content) { var result = this._CCNS_REG1.exec(content); if(!result) return cc.p(0,0); return cc.p(parseFloat(result[1]), parseFloat(result[2])); }, - /** - * Returns a Core Graphics size structure corresponding to the data in a given string. - * @function - * @param {String} content A string object whose contents are of the form "{w, h}",
    - * where w is the width and h is the height.
    - * The w and h values can be integer or float values.
    - * The string is not localized, so items are always separated with a comma.
    - * @return {cc.Size} A Core Graphics structure that represents a size.
    - * If the string is not well-formed, the function returns cc.size(0,0). - * @example - * // example - * var size = this._sizeFromString("{3.0,2.5}"); - */ + _sizeFromString : function (content) { var result = this._CCNS_REG1.exec(content); if(!result) return cc.size(0, 0); return cc.size(parseFloat(result[1]), parseFloat(result[2])); }, - /** - * Get the real data structure of frame used by engine. - * @param url - * @returns {*} - * @private - */ _getFrameConfig : function(url){ var dict = cc.loader.getRes(url); @@ -317,7 +271,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ * Sprite Frames stored in this file will be removed.
    * It is convinient to call this method when a specific texture needs to be removed.
    *

    - * @param {String} url plist filename + * @param {String} url Plist filename */ removeSpriteFramesFromFile: function (url) { var self = this, spriteFrames = self._spriteFrames, @@ -337,7 +291,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ /** *

    * Removes all Sprite Frames associated with the specified textures.
    - * It is convinient to call this method when a specific texture needs to be removed. + * It is convenient to call this method when a specific texture needs to be removed. *

    * @param {HTMLImageElement|HTMLCanvasElement|cc.Texture2D} texture */ From 6244fcaf51c0b709ef4fa6506e740cb099860aed Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Aug 2014 03:24:40 +0800 Subject: [PATCH 0579/1564] Doc #5829: Improve inline docs --- cocos2d/core/CCActionManager.js | 5 +---- cocos2d/core/CCDirector.js | 2 +- cocos2d/core/CCScheduler.js | 2 ++ cocos2d/core/platform/CCSAXParser.js | 4 +++- cocos2d/core/platform/CCTypes.js | 3 ++- cocos2d/core/textures/CCTexture2D.js | 6 +----- cocos2d/shaders/CCGLProgram.js | 4 ++-- tools/build.xml | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index a1b367faaf..06006dc795 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -65,7 +65,7 @@ cc.HashElement = cc.Class.extend(/** @lends cc.HashElement# */{ * @example * var mng = new cc.ActionManager(); */ -cc.ActionManager = cc.Class.extend({ +cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ _hashTargets:null, _arrayTargets:null, _currentTarget:null, @@ -79,9 +79,6 @@ cc.ActionManager = cc.Class.extend({ return null; }, - /** - * Constructor - */ ctor:function () { this._hashTargets = {}; this._arrayTargets = []; diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 14735a4354..da06484a1d 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -846,7 +846,7 @@ cc.Director.EVENT_AFTER_UPDATE = "director_after_update"; /*************************************************** * implementation of DisplayLinkDirector **************************************************/ -cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.director# */{ +cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.Director# */{ invalid: false, /** diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 6f0e150e4e..08c3c9111c 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -36,6 +36,7 @@ cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1; /** * A list double-linked list used for "updates with priority" * @Class + * @name cc.ListEntry * @param {cc.ListEntry} prev * @param {cc.ListEntry} next * @param {cc.Class} target not retained (retained by hashUpdateEntry) @@ -55,6 +56,7 @@ cc.ListEntry = function (prev, next, target, priority, paused, markedForDeletion /** * A update entry list * @Class + * @name cc.HashUpdateEntry * @param {cc.ListEntry} list Which list does it belong to ? * @param {cc.ListEntry} entry entry in the list * @param {cc.Class} target hash key (retained) diff --git a/cocos2d/core/platform/CCSAXParser.js b/cocos2d/core/platform/CCSAXParser.js index 4100a49cc0..94ec96589d 100644 --- a/cocos2d/core/platform/CCSAXParser.js +++ b/cocos2d/core/platform/CCSAXParser.js @@ -27,6 +27,7 @@ /** * A SAX Parser * @class + * @name cc.saxParser * @extends cc.Class */ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ @@ -72,8 +73,9 @@ cc.SAXParser = cc.Class.extend(/** @lends cc.saxParser# */{ /** * - * A plist Parser + * cc.plistParser is a singleton object for parsing plist files * @class + * @name cc.plistParser * @extends cc.SAXParser */ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index ecf4f8f977..8c8c478857 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -25,12 +25,13 @@ ****************************************************************************/ /** + * Color class, please use cc.color() to construct a color * @class cc.Color * @param {Number} r * @param {Number} g * @param {Number} b * @param {Number} a - * @constructor + * @see cc.color */ cc.Color = function (r, g, b, a) { this.r = r || 0; diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index f111b2db26..8f3dae7130 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -120,8 +120,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * @property {Number} maxS - Texture max S * @property {Number} maxT - Texture max T */ - - cc.Texture2D = cc.Class.extend({ + cc.Texture2D = cc.Class.extend(/** @lends cc.Texture2D# */{ _contentSize: null, _isLoaded: false, _htmlElementObj: null, @@ -129,9 +128,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { url: null, - /** - * constructor of cc.Texture2D - */ ctor: function () { this._contentSize = cc.size(0, 0); this._isLoaded = false; diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 1aa820236f..cd922172cb 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -33,11 +33,11 @@ cc.HashUniformEntry = function (value, location, hh) { }; /** - * Class that implements a glProgram + * Class that implements a WebGL program * @class * @extends cc.Class */ -cc.GLProgram = cc.Class.extend({ +cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ _glContext: null, _programObj: null, _vertShader: null, diff --git a/tools/build.xml b/tools/build.xml index 28f22b30ec..525d886f18 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -62,7 +62,6 @@ - @@ -133,6 +132,7 @@ + From b8135aa2650bf344cabd45dcaaa4833be79f7706 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Aug 2014 04:03:13 +0800 Subject: [PATCH 0580/1564] Issue #5873: Reverse change to build.xml for Closure Compiler --- tools/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build.xml b/tools/build.xml index 525d886f18..28f22b30ec 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -62,6 +62,7 @@ + @@ -132,7 +133,6 @@ - From e77d67b593fc4c263060c44da02a2f7d9f92146d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 29 Aug 2014 10:11:19 +0800 Subject: [PATCH 0581/1564] Fixed three bugs that it sets to other value when the parameter is 0. --- cocos2d/core/platform/CCTypes.js | 6 +++--- cocos2d/core/platform/CCTypesWebGL.js | 5 ++--- extensions/ccui/base-classes/UIWidget.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index ecf4f8f977..c8f7eb689e 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -36,7 +36,7 @@ cc.Color = function (r, g, b, a) { this.r = r || 0; this.g = g || 0; this.b = b || 0; - this.a = a || 255; + this.a = (a == null) ? 255 : a; }; /** @@ -66,8 +66,8 @@ cc.color = function (r, g, b, a) { if (typeof r === "string") return cc.hexToColor(r); if (typeof r === "object") - return {r: r.r, g: r.g, b: r.b, a: r.a || 255}; - return {r: r, g: g, b: b, a: a || 255 }; + return {r: r.r, g: r.g, b: r.b, a: (r.a == null) ? 255 : r.a}; + return {r: r, g: g, b: b, a: (r.a == null) ? 255 : r.a}; }; /** diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index 97a54b9b36..2c833db598 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -74,11 +74,10 @@ cc._tmp.WebGLColor = function () { this._rU8[0] = r || 0; this._gU8[0] = g || 0; this._bU8[0] = b || 0; - this._aU8[0] = a || 255; + this._aU8[0] = (a == null) ? 255 : a; - if (a === undefined) { + if (a === undefined) this.a_undefined = true; - } }; /** * @constant diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 8d47a04594..0da4ae3379 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -972,7 +972,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._positionPercent.x = 0; this._positionPercent.y = 0; } else { - if (posY) { + if (posY == undefined) { this._positionPercent.x = pos / pSize.width; this._positionPercent.y = posY / pSize.height; } else { From 5e7ab28535fcc1e65840d976db68559b6166cb7d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 29 Aug 2014 13:52:31 +0800 Subject: [PATCH 0582/1564] Updates AUTHORS.txt --- AUTHORS.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 79d37c1cd8..1185eafd7e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -173,6 +173,7 @@ musikov @musikov cc.ClippingNode bug fix cc.fontLoader bug fix Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode JumpTo bug with wrong _delta position bug fix + cc.ProgressTimer bug fix Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix @@ -187,12 +188,19 @@ Ninja Lau @mutoo A typo bug in UILayout fix One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix A transform error in CCTransformHelp.js fix ccs.DisplayManager bug fix - Fix child armature lost _parentBone issue; + Fix child armature lost _parentBone issue + cc.eventManager bug fix + ccs.Bone bug fix + ccs.ActionFrame bug fix Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode Minh Quy @MQuy cc.MenuItemSprite bug fix - Check empty string for textureData + Check empty string for textureData + +Michael Yin @layerssss cc.game refactored + +Yang Yuchen @yycdef cc.sys bug fix Retired Core Developers: Shengxiang Chen (Nero Chan) From e8edfbf51002217f92b31fb83a04f6343365f87a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 29 Aug 2014 14:08:49 +0800 Subject: [PATCH 0583/1564] Fixed a bug of ccui.TextField --- extensions/ccui/uiwidgets/UITextField.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 80ff8c504a..ba51b5c263 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -251,14 +251,12 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ */ ctor: function (placeholder, fontName, fontSize) { ccui.Widget.prototype.ctor.call(this); - if (this.init()) { - if(placeholder) - this.setPlaceHolder(placeholder); - if(fontName) - this.setFontName(fontName); - if(fontSize) - this.setFontSize(fontSize); - } + if (placeholder) + this.setPlaceHolder(placeholder); + if (fontName) + this.setFontName(fontName); + if (fontSize) + this.setFontSize(fontSize); }, /** From 5fba6c55a2ac5a977e3e115f6b76693daea73ad4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Aug 2014 15:59:20 +0800 Subject: [PATCH 0584/1564] Update docs for RC3 release --- CHANGELOG.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e68a2e2bc4..aadb0744bd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,47 @@ ChangeLog: +Cocos2d-JS-v3.0 RC3 @ Aug.29, 2014 + +* Facebook SDK Beta: Unified the callback parameters for different platform. +* Facebook SDK Beta: Added payment API on Web platform. +* Facebook SDK Beta: Supported app request and share open graph API on Web platform. +* Facebook SDK Beta: Remove plugin configuration for Facebook SDK to simplify the usage. +* Facebook SDK Beta: Added test case for new features and improve all test cases. +* Cocos Console: Improved web compile with `--advanced` tag. +* Improved Cocos2d-JS inline docs to provide a better API reference document. +* Refactored cc.game for maintainability. +* Refactored cc.async to simplify and improve the usage. +* Added `cc.formatStr` for string formatting, for example: `cc.formatStr("a: %d, b: %b", a, b)`. +* Refactored cc.log to support formatted string. +* Refactored cc.pool's `hasObj` to `hasObject` and `removeObj` to `removeObject`. +* Added some state check to cc.audioEngine. +* Refactored sprite's blend function to support more features on Canvas. +* Refactored `cc.textureCache.textureForKey` to `cc.textureCache.getTextureForKey`, `cc.TMXTilemap#propertiesForGID` to `cc.TMXTilemap#getPropertiesForGID` to follow the standard API naming style. +* Detected mouse event on touch screen tablets. +* Support new construction for cc.PhysicsDebugNode and deprecated `cc.PhysicsDebugNode.create` +* Made cc.Texture2D's setTexParameters supports two types of parameters. +* Added test case for remote image loading. + +* Bugs fix: + 1. Fixed an issue of tilemap that it can't runAction in canvas render mode. + 2. Fixed an issue of cc.eventManager that its removeListeners' codes are unreachable. + 3. Fixed an issue of cc.EditBox that its position is incorrect. + 4. Fixed an issue of cc.WebAudio that its stopped state is incorrect. + 5. Fixed an issue of cc.audioEngine that it doesn't work on firefox after it compiled with advanced mode. + 6. Fixed an issue of ccs.Bone that it doesn't update color and opacity correctly. + 7. Fixed an issue of ccs.Armature that its setShaderProgram doesn't work. + 8. Fixed cc.Sprite and cc.Scale9Sprite's issue so that their texture loads incorrectly. + 9. Fixed an issue of ccui.LoadingBar that its setPercent is invalid. + 10. Fixed an issue of Armature reader that it can't parse isTween property. + 11. Fixed an issue of ccui.PageView that its getTouchBeganPosition returns incorrect value. + 12. Fixed an issue of ccui.ImageView that its setColor doesn't work. + 13. Fixed an issue of cc.RenderTexture that it doesn't support parameter depthStencilFormat. + 14. Fixed an issue of ccs.ArmatureAnimation.setSpeedScale. + 15. Fixed an issue of cc.Scale9Sprite that it has a line on iOS device. + 16. Fixed CCProgressTimer draw on canvas with colorized sprite + 17. Fixed an issue of cc.game that its frameRate setter is invalid. + 18. Fixed an issue of cc.loader that its callback state is incorrect. + Cocos2d-html5-v3.0 RC2 @ Aug.8, 2014 * Refactored Cocos UI for more stable and friendly user experience. From 3896ebcd2c423d0696b786332b2a4326cb79c412 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 1 Sep 2014 11:42:19 +0800 Subject: [PATCH 0585/1564] Closed #5879: Fixed a bug of cc.Menu that its item's touch priority is different to cc.eventManager --- cocos2d/menus/CCMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 799c3e54d3..85c2dd8252 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -602,7 +602,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ var touchLocation = touch.getLocation(); var itemChildren = this._children, locItemChild; if (itemChildren && itemChildren.length > 0) { - for (var i = 0; i < itemChildren.length; i++) { + for (var i = itemChildren.length - 1; i >= 0; i--) { locItemChild = itemChildren[i]; if (locItemChild.isVisible() && locItemChild.isEnabled()) { var local = locItemChild.convertToNodeSpace(touchLocation); From 058e5e217c5095f2be357645a7d7448c84d613e6 Mon Sep 17 00:00:00 2001 From: Minh Quy Date: Mon, 1 Sep 2014 12:07:59 +0700 Subject: [PATCH 0586/1564] Consider using function to check type of variable I think we should we function to check type of variable like underscore or lodash to make it more flexible or easier to test --- CCBoot.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 2b6e0d83e8..28972f639e 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -103,6 +103,63 @@ cc.extend = function(target) { return target; }; +/** + * Check the obj whether is function or not + * @param {*} obj + * @returns {boolean} + */ +cc.isFunction = function(obj) { + return typeof obj == 'function'; +}; + +/** + * Check the obj whether is number or not + * @param {*} obj + * @returns {boolean} + */ +cc.isNumber = function(obj) { + return typeof obj == 'number' || Object.prototype.toString.call(obj) == '[object Number]'; +}; + +/** + * Check the obj whether is string or not + * @param {*} obj + * @returns {boolean} + */ +cc.isString = function(obj) { + return typeof obj == 'string' || Object.prototype.toString.call(obj) == '[object String]'; +}; + +/** + * Check the obj whether is array or not + * @param {*} obj + * @returns {boolean} + */ +cc.isArray = function(obj) { + return Object.prototype.toString.call(obj) == '[object Array]'; +}; + +/** + * Check the obj whether is undefined or not + * @param {*} obj + * @returns {boolean} + */ + +cc.isUndefined = function(obj) { + return typeof obj == 'undefined'; +}; + +/** + * Check the obj whether is object or not + * @param {*} obj + * @returns {boolean} + */ +cc.isObject = function(obj) { + var type = typeof obj; + + return type == 'function' || (obj && type == 'object'); +} + /** * Check the url whether cross origin * @param {String} url From 133621984230e2eca7e2d307139dcb6b12745bd4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Sep 2014 15:53:07 +0800 Subject: [PATCH 0587/1564] Issue #5885: Micro message browser does not support the error event of audio --- cocos2d/audio/CCAudio.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 21ff1e98f8..ef50a7c882 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -1119,6 +1119,11 @@ cc._audioLoader = { this.removeEventListener(canplaythrough, arguments.callee, false); this.removeEventListener(error, arguments.callee, false); }, false); + + if(cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT){ + error = "emptied"; + } + cc._addEventListener(audio, error, function () { cb("load " + url + " failed"); if(delFlag){ From 59af126e4ad10557296a4a9ff547483803c9e0b8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Sep 2014 16:16:27 +0800 Subject: [PATCH 0588/1564] Issue #5884: Micro message browser does not support the error event of audio --- cocos2d/audio/CCAudio.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index ef50a7c882..770b3fac8e 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -1120,17 +1120,21 @@ cc._audioLoader = { this.removeEventListener(error, arguments.callee, false); }, false); - if(cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT){ - error = "emptied"; - } - - cc._addEventListener(audio, error, function () { + var audioCB = function () { + audio.removeEventListener("emptied", audioCB); + audio.removeEventListener(error, audioCB); cb("load " + url + " failed"); if(delFlag){ this.removeEventListener(canplaythrough, arguments.callee, false); this.removeEventListener(error, arguments.callee, false); } - }, false); + }; + + if(cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT){ + cc._addEventListener(audio, "emptied", audioCB, false); + } + + cc._addEventListener(audio, error, audioCB, false); audio.load(); } return audio; From 7c34ea64816af660857671070245173510d14c33 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 2 Sep 2014 10:21:16 +0800 Subject: [PATCH 0589/1564] Fixed #2210: replaces typeof with cc.isXXXX --- CCBoot.js | 21 +++++++-------- CCDebugger.js | 4 +-- cocos2d/audio/CCAudio.js | 2 +- cocos2d/core/CCDirector.js | 2 +- cocos2d/core/CCScheduler.js | 2 +- cocos2d/core/base-nodes/CCNode.js | 26 ++++++++----------- cocos2d/core/event-manager/CCEventManager.js | 4 +-- cocos2d/core/labelttf/CCLabelTTF.js | 4 +-- cocos2d/core/layers/CCLayer.js | 10 +++---- cocos2d/core/platform/CCEGLView.js | 4 +-- cocos2d/core/platform/CCInputManager.js | 2 +- cocos2d/core/platform/CCLoaders.js | 2 +- cocos2d/core/platform/CCMacro.js | 2 +- cocos2d/core/platform/CCTypes.js | 8 +++--- cocos2d/core/platform/CCTypesWebGL.js | 4 +-- cocos2d/core/scenes/CCLoaderScene.js | 3 ++- cocos2d/core/sprites/CCSprite.js | 13 +++++----- cocos2d/core/sprites/CCSpriteBatchNode.js | 4 +-- cocos2d/core/sprites/CCSpriteFrame.js | 2 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 2 +- cocos2d/core/sprites/SpritesWebGL.js | 5 ++-- cocos2d/core/textures/CCTexture2D.js | 4 +-- cocos2d/core/textures/CCTextureAtlas.js | 9 +++---- cocos2d/core/textures/CCTextureCache.js | 2 +- cocos2d/labels/CCLabelBMFont.js | 2 +- cocos2d/menus/CCMenuItem.js | 12 ++++----- cocos2d/motion-streak/CCMotionStreak.js | 2 +- cocos2d/particle/CCParticleBatchNode.js | 2 +- cocos2d/particle/CCParticleSystem.js | 2 +- cocos2d/physics/CCPhysicsSprite.js | 8 +++--- cocos2d/tilemap/CCTMXLayer.js | 2 +- extensions/ccb-reader/CCBAnimationManager.js | 2 +- extensions/ccb-reader/CCBReader.js | 2 +- extensions/ccb-reader/CCBValue.js | 8 +----- extensions/ccui/layouts/UILayoutParameter.js | 2 +- extensions/ccui/uiwidgets/UIRichText.js | 2 +- .../armature/utils/CCDataReaderHelper.js | 2 +- extensions/cocostudio/reader/SceneReader.js | 16 ++++++------ .../cocostudio/trigger/ObjectFactory.js | 2 +- .../gui/control-extension/CCInvocation.js | 2 +- extensions/spine/CCSkeleton.js | 4 +-- 41 files changed, 100 insertions(+), 113 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 28972f639e..45ce774aba 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -91,7 +91,7 @@ cc.each = function (obj, iterator, context) { * @returns {object} */ cc.extend = function(target) { - sources = arguments.length >= 2 ? Array.prototype.slice.call(arguments, 1) : []; + var sources = arguments.length >= 2 ? Array.prototype.slice.call(arguments, 1) : []; cc.each(sources, function(src) { for(var key in src) { @@ -99,7 +99,7 @@ cc.extend = function(target) { target[key] = src[key]; } } - }) + }); return target; }; @@ -144,7 +144,6 @@ cc.isArray = function(obj) { * @param {*} obj * @returns {boolean} */ - cc.isUndefined = function(obj) { return typeof obj == 'undefined'; }; @@ -158,7 +157,7 @@ cc.isObject = function(obj) { var type = typeof obj; return type == 'function' || (obj && type == 'object'); -} +}; /** * Check the url whether cross origin @@ -814,8 +813,8 @@ cc.loader = { /** * Load resources then call the callback. * @param {string} resources - * @param {function|Object} [option] option or cb - * @param {function} [cb] + * @param {function} [option] callback or trigger + * @param {function|Object} [cb] * @return {cc.AsyncPool} */ load : function(resources, option, cb){ @@ -1001,16 +1000,16 @@ cc.formatStr = function(){ //+++++++++++++++++++++++++something about window events begin+++++++++++++++++++++++++++ (function () { var win = window, hidden, visibilityChange, _undef = "undefined"; - if (typeof document.hidden !== _undef) { + if (!cc.isUndefined(document.hidden)) { hidden = "hidden"; visibilityChange = "visibilitychange"; - } else if (typeof document.mozHidden !== _undef) { + } else if (!cc.isUndefined(document.mozHidden)) { hidden = "mozHidden"; visibilityChange = "mozvisibilitychange"; - } else if (typeof document.msHidden !== _undef) { + } else if (!cc.isUndefined(document.msHidden)) { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; - } else if (typeof document.webkitHidden !== _undef) { + } else if (!cc.isUndefined(document.webkitHidden)) { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; } @@ -2039,7 +2038,7 @@ cc.game._initConfig(); //+++++++++++++++++++++++++something about CCGame end+++++++++++++++++++++++++++++ Function.prototype.bind = Function.prototype.bind || function (oThis) { - if (typeof this !== "function") { + if (!cc.isFunction(this)) { // closest thing possible to the ECMAScript 5 // internal IsCallable function throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); diff --git a/CCDebugger.js b/CCDebugger.js index 5bb6357bc1..59c381d74e 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -261,14 +261,14 @@ cc._logToWebPage = function (msg) { logListStyle.margin = 0; } - msg = typeof msg == "string" ? msg : JSON.stringify(msg); + msg = cc.isString(msg) ? msg : JSON.stringify(msg); logList.value = logList.value + msg + "\r\n"; logList.scrollTop = logList.scrollHeight; }; //to make sure the cc.log, cc.warn, cc.error and cc.assert would not throw error before init by debugger mode. cc._formatString = function (arg) { - if (typeof arg === 'object') { + if (cc.isObject(arg)) { try { return JSON.stringify(arg); } catch (err) { diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 770b3fac8e..156dca940d 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -1095,7 +1095,7 @@ cc._audioLoader = { _loadAudio: function (url, audio, cb, delFlag) { var _Audio; - if (typeof(window["cc"]) != "object" && cc.sys.browserType == "firefox") + if (!cc.isObject(window["cc"]) && cc.sys.browserType == "firefox") _Audio = Audio; //The WebAudio of FireFox doesn't work after google closure compiler compiled with advanced mode else _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index da06484a1d..0bb7a2fff4 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -1005,7 +1005,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (cc._fpsImage) { cc.Director._fpsImage.src = cc._fpsImage; } - cc.assert(typeof cc._tmp.DirectorWebGL === "function", cc._LogInfos.MissingFile, "CCDirectorWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.DirectorWebGL), cc._LogInfos.MissingFile, "CCDirectorWebGL.js"); cc._tmp.DirectorWebGL(); delete cc._tmp.DirectorWebGL; } \ No newline at end of file diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 08c3c9111c..df1f7354cc 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -148,7 +148,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ _doCallback:function(){ var self = this; - if (typeof(self._callback) == "string") + if (cc.isString(self._callback)) self._target[self._callback](self._elapsed); else // if (typeof(this._callback) == "function") { self._callback.call(self._target, self._elapsed); diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 88b8faa76a..63973e57b4 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1256,19 +1256,15 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var child = child; var localZOrder = localZOrder === undefined ? child._localZOrder : localZOrder; var tag, name, setTag = false; - switch(typeof tag){ - case 'undefined': - tag = undefined; - name = child._name; - break; - case 'string': - name = tag; - tag = undefined; - break; - case 'number': - setTag = true; - name = ""; - break; + if(cc.isUndefined(tag)){ + tag = undefined; + name = child._name; + } else if(cc.isString(tag)){ + name = tag; + tag = undefined; + } else if(cc.isNumber(tag)){ + setTag = true; + name = ""; } cc.assert(child, cc._LogInfos.Node_addChild_3); @@ -2695,10 +2691,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p = null; } else { - cc.assert(typeof cc._tmp.WebGLCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLCCNode), cc._LogInfos.MissingFile, "BaseNodesWebGL.js"); cc._tmp.WebGLCCNode(); delete cc._tmp.WebGLCCNode; } -cc.assert(typeof cc._tmp.PrototypeCCNode === "function", cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeCCNode), cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); cc._tmp.PrototypeCCNode(); delete cc._tmp.PrototypeCCNode; \ No newline at end of file diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index e88250aea7..91df05a151 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -647,7 +647,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ addListener: function (listener, nodeOrPriority) { cc.assert(listener && nodeOrPriority, cc._LogInfos.eventManager_addListener_2); if(!(listener instanceof cc.EventListener)){ - cc.assert(typeof nodeOrPriority !== "number", cc._LogInfos.eventManager_addListener_3); + cc.assert(!cc.isNumber(nodeOrPriority), cc._LogInfos.eventManager_addListener_3); listener = cc.EventListener.create(listener); } else { if(listener._isRegistered()){ @@ -659,7 +659,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ if (!listener.checkAvailable()) return; - if (typeof nodeOrPriority == "number") { + if (cc.isNumber(nodeOrPriority)) { if (nodeOrPriority == 0) { cc.log(cc._LogInfos.eventManager_addListener); return; diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 3d290465f4..3beac954aa 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1138,12 +1138,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p = null; } else { - cc.assert(typeof cc._tmp.WebGLLabelTTF === "function", cc._LogInfos.MissingFile, "LabelTTFWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLLabelTTF), cc._LogInfos.MissingFile, "LabelTTFWebGL.js"); cc._tmp.WebGLLabelTTF(); delete cc._tmp.WebGLLabelTTF; } -cc.assert(typeof cc._tmp.PrototypeLabelTTF === "function", cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeLabelTTF), cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js"); cc._tmp.PrototypeLabelTTF(); delete cc._tmp.PrototypeLabelTTF; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index f27a6ba2be..6738191c12 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -199,7 +199,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; p = null; }else{ - cc.assert(typeof cc._tmp.LayerDefineForWebGL === "function", cc._LogInfos.MissingFile, "CCLayerWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.LayerDefineForWebGL), cc._LogInfos.MissingFile, "CCLayerWebGL.js"); cc._tmp.LayerDefineForWebGL(); delete cc._tmp.LayerDefineForWebGL; } @@ -498,12 +498,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerColor define end _p = null; } else { - cc.assert(typeof cc._tmp.WebGLLayerColor === "function", cc._LogInfos.MissingFile, "CCLayerWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLLayerColor), cc._LogInfos.MissingFile, "CCLayerWebGL.js"); cc._tmp.WebGLLayerColor(); delete cc._tmp.WebGLLayerColor; } -cc.assert(typeof cc._tmp.PrototypeLayerColor === "function", cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeLayerColor), cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); cc._tmp.PrototypeLayerColor(); delete cc._tmp.PrototypeLayerColor; @@ -793,12 +793,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerGradient define end _p = null; } else { - cc.assert(typeof cc._tmp.WebGLLayerGradient === "function", cc._LogInfos.MissingFile, "CCLayerWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLLayerGradient), cc._LogInfos.MissingFile, "CCLayerWebGL.js"); cc._tmp.WebGLLayerGradient(); delete cc._tmp.WebGLLayerGradient; } -cc.assert(typeof cc._tmp.PrototypeLayerGradient === "function", cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeLayerGradient), cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); cc._tmp.PrototypeLayerGradient(); delete cc._tmp.PrototypeLayerGradient; diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 562acc5e0e..06f27ed6d6 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -164,10 +164,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ * this callback will be invoked before applying resolution policy,
    * so you can do any additional modifications within the callback.
    * Useful only on web. - * @param {Function} callback The callback function + * @param {Function|null} callback The callback function */ setResizeCallback: function (callback) { - if (typeof callback == "function" || callback == null) { + if (cc.isFunction(callback) || callback == null) { this._resizeCallback = callback; } }, diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 9d72c97ed8..c6121ad3e2 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -229,7 +229,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ var docElem = document.documentElement; var win = window; var box = null; - if (typeof element.getBoundingClientRect === 'function') { + if (cc.isFunction(element.getBoundingClientRect)) { box = element.getBoundingClientRect(); } else { if (element instanceof HTMLCanvasElement) { diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index dc23290abd..a941b39bbe 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -109,7 +109,7 @@ cc._fontLoader = { load : function(realUrl, url, res, cb){ var self = this; var type = res.type, name = res.name, srcs = res.srcs; - if(typeof res == "string"){ + if(cc.isString(res)){ type = cc.path.extname(res); name = cc.path.basename(res, type); self._loadFont(name, res, type); diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 077b3407bd..adb7e453f4 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -81,7 +81,7 @@ cc.UINT_MAX = 0xffffffff; * @deprecated since v3.0 */ cc.swap = function (x, y, ref) { - if ((typeof ref) == 'object' && (typeof ref.x) != 'undefined' && (typeof ref.y) != 'undefined') { + if (cc.isObject(ref) && !cc.isUndefined(ref.x) && !cc.isUndefined(ref.y)) { var tmp = ref[x]; ref[x] = ref[y]; ref[y] = tmp; diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 968b48da84..0b97a2fa27 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -64,9 +64,9 @@ cc.Color = function (r, g, b, a) { cc.color = function (r, g, b, a) { if (r === undefined) return {r: 0, g: 0, b: 0, a: 255}; - if (typeof r === "string") + if (cc.isString(r)) return cc.hexToColor(r); - if (typeof r === "object") + if (cc.isObject(r)) return {r: r.r, g: r.g, b: r.b, a: (r.a == null) ? 255 : r.a}; return {r: r, g: g, b: b, a: (r.a == null) ? 255 : r.a}; }; @@ -363,12 +363,12 @@ cc.FontDefinition = function () { }; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - cc.assert(typeof cc._tmp.WebGLColor === "function", cc._LogInfos.MissingFile, "CCTypesWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLColor), cc._LogInfos.MissingFile, "CCTypesWebGL.js"); cc._tmp.WebGLColor(); delete cc._tmp.WebGLColor; } -cc.assert(typeof cc._tmp.PrototypeColor === "function", cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeColor), cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js"); cc._tmp.PrototypeColor(); delete cc._tmp.PrototypeColor; diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index 2c833db598..e9e0151da6 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -42,11 +42,11 @@ cc._tmp.WebGLColor = function () { cc.color = function (r, g, b, a, arrayBuffer, offset) { if (r === undefined) return new cc.Color(0, 0, 0, 255, arrayBuffer, offset); - if (typeof r === "string") { + if (cc.isString(r)) { var color = cc.hexToColor(r); return new cc.Color(color.r, color.g, color.b, color.a); } - if (typeof r === "object") + if (cc.isObject(r)) return new cc.Color(r.r, r.g, r.b, r.a, r.arrayBuffer, r.offset); return new cc.Color(r, g, b, a, arrayBuffer, offset); }; diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index f5ce7f20ad..05cdab09d6 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -104,7 +104,8 @@ cc.LoaderScene = cc.Scene.extend({ * @param {Function|String} cb */ initWithResources: function (resources, cb) { - if(typeof resources == "string") resources = [resources]; + if(cc.isString(resources)) + resources = [resources]; this.resources = resources || []; this.cb = cb; }, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index d2a380bd95..307f9a77ff 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -823,7 +823,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _softInit: function (fileName, rect, rotated) { if (fileName === undefined) cc.Sprite.prototype.init.call(this); - else if (typeof(fileName) === "string") { + else if (cc.isString(fileName)) { if (fileName[0] === "#") { // Init with a sprite frame name var frameName = fileName.substr(1, fileName.length - 1); @@ -833,8 +833,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // Init with filename and rect cc.Sprite.prototype.init.call(this, fileName, rect); } - } - else if (typeof(fileName) === "object") { + } else if (cc.isObject(fileName)) { if (fileName instanceof cc.Texture2D) { // Init with texture and rect this.initWithTexture(fileName, rect, rotated); @@ -1520,7 +1519,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.setSpriteFrame = function (newFrame) { var _t = this; - if(typeof(newFrame) == "string"){ + if(cc.isString(newFrame)){ newFrame = cc.spriteFrameCache.getSpriteFrame(newFrame); cc.assert(newFrame, cc._LogInfos.CCSpriteBatchNode_setSpriteFrame) } @@ -1588,7 +1587,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.setTexture = function (texture) { var _t = this; - if(texture && (typeof(texture) === "string")){ + if(texture && (cc.isString(texture))){ texture = cc.textureCache.addImage(texture); _t.setTexture(texture); @@ -1710,12 +1709,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { delete _p; } else { - cc.assert(typeof cc._tmp.WebGLSprite === "function", cc._LogInfos.MissingFile, "SpritesWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLSprite), cc._LogInfos.MissingFile, "SpritesWebGL.js"); cc._tmp.WebGLSprite(); delete cc._tmp.WebGLSprite; } -cc.assert(typeof cc._tmp.PrototypeSprite === "function", cc._LogInfos.MissingFile, "SpritesPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeSprite), cc._LogInfos.MissingFile, "SpritesPropertyDefine.js"); cc._tmp.PrototypeSprite(); delete cc._tmp.PrototypeSprite; diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index e9031348d6..b32bed1f57 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -392,7 +392,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ var texture2D; capacity = capacity || cc.DEFAULT_SPRITE_BATCH_CAPACITY; - if (typeof(fileImage) == "string") { + if (cc.isString(fileImage)) { texture2D = cc.textureCache.getTextureForKey(fileImage); if (!texture2D) texture2D = cc.textureCache.addImage(fileImage); @@ -409,7 +409,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ var texture2D; capacity = capacity || cc.DEFAULT_SPRITE_BATCH_CAPACITY; - if (typeof(fileImage) == "string") { + if (cc.isString(fileImage)) { texture2D = cc.textureCache.getTextureForKey(fileImage); if (!texture2D) texture2D = cc.textureCache.addImage(fileImage); diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 5f06009d4d..9c5250bbfe 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -349,7 +349,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ originalSize = originalSize || rect; rotated = rotated || false; - if (typeof(texture) == "string"){ + if (cc.isString(texture)){ this._texture = null; this._textureFilename = texture; } else if (texture instanceof cc.Texture2D){ diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 189eaa2c00..c0d2e3b7ee 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -163,7 +163,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ texture = cc.textureCache.addImage(texturePath); }else if(texture instanceof cc.Texture2D){ //do nothing - }else if(typeof texture == "string"){//string + }else if(cc.isString(texture)){//string texture = cc.textureCache.addImage(texture); }else{ cc.assert(0, cc._LogInfos.spriteFrameCache_addSpriteFrames_3); diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 8e894e080f..86b3e34e30 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -398,9 +398,8 @@ cc._tmp.WebGLSprite = function () { _p.setSpriteFrame = function (newFrame) { var _t = this; - if(typeof(newFrame) == "string"){ + if(cc.isString(newFrame)){ newFrame = cc.spriteFrameCache.getSpriteFrame(newFrame); - cc.assert(newFrame, cc._LogInfos.Sprite_setSpriteFrame); } @@ -468,7 +467,7 @@ cc._tmp.WebGLSprite = function () { _p.setTexture = function (texture) { var _t = this; - if(texture && (typeof(texture) === "string")){ + if(texture && (cc.isString(texture))){ texture = cc.textureCache.addImage(texture); _t.setTexture(texture); diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 8f3dae7130..b094af561f 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -404,11 +404,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }); } else { - cc.assert(typeof cc._tmp.WebGLTexture2D === "function", cc._LogInfos.MissingFile, "TexturesWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLTexture2D), cc._LogInfos.MissingFile, "TexturesWebGL.js"); cc._tmp.WebGLTexture2D(); delete cc._tmp.WebGLTexture2D; } -cc.assert(typeof cc._tmp.PrototypeTexture2D === "function", cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeTexture2D), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); cc._tmp.PrototypeTexture2D(); delete cc._tmp.PrototypeTexture2D; \ No newline at end of file diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index 79d7e71f53..dca88d7a73 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -74,10 +74,9 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ ctor: function (fileName, capacity) { this._buffersVBO = []; - if (typeof(fileName) == "string") { + if (cc.isString(fileName)) { this.initWithFile(fileName, capacity); - } - else if (fileName instanceof cc.Texture2D) { + } else if (fileName instanceof cc.Texture2D) { this.initWithTexture(fileName, capacity); } }, @@ -660,11 +659,11 @@ cc.TextureAtlas.create = function (fileName, capacity) { cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - cc.assert(typeof cc._tmp.WebGLTextureAtlas === "function", cc._LogInfos.MissingFile, "TexturesWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLTextureAtlas), cc._LogInfos.MissingFile, "TexturesWebGL.js"); cc._tmp.WebGLTextureAtlas(); delete cc._tmp.WebGLTextureAtlas; } -cc.assert(typeof cc._tmp.PrototypeTextureAtlas === "function", cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); +cc.assert(cc.isFunction(cc._tmp.PrototypeTextureAtlas), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); cc._tmp.PrototypeTextureAtlas(); delete cc._tmp.PrototypeTextureAtlas; \ No newline at end of file diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 8829055543..9e29557c90 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -373,7 +373,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p = null; } else { - cc.assert(typeof cc._tmp.WebGLTextureCache === "function", cc._LogInfos.MissingFile, "TexturesWebGL.js"); + cc.assert(cc.isFunction(cc._tmp.WebGLTextureCache), cc._LogInfos.MissingFile, "TexturesWebGL.js"); cc._tmp.WebGLTextureCache(); delete cc._tmp.WebGLTextureCache; } \ No newline at end of file diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 17874909d1..7a18c5a03f 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -639,7 +639,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ newString = String(newString); if (needUpdateLabel == null) needUpdateLabel = true; - if (newString == null || typeof(newString) != "string") + if (newString == null || !cc.isString(newString)) newString = newString + ""; this._initialString = newString; diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 75758fb442..6f3b31bb7e 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -170,9 +170,9 @@ cc.MenuItem = cc.Node.extend(/** @lends cc.MenuItem# */{ var locTarget = this._target, locCallback = this._callback; if (!locCallback) return; - if (locTarget && (typeof(locCallback) == "string")) { + if (locTarget && cc.isString(locCallback)) { locTarget[locCallback](this); - } else if (locTarget && (typeof(locCallback) == "function")) { + } else if (locTarget && cc.isFunction(locCallback)) { locCallback.call(locTarget, this); } else locCallback(this); @@ -752,10 +752,10 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ disabledImage = three; callback = four; target = five; - } else if (four !== undefined && typeof four === "function") { + } else if (four !== undefined && cc.isFunction(four)) { disabledImage = three; callback = four; - } else if (four !== undefined && typeof three === "function") { + } else if (four !== undefined && cc.isFunction(three)) { target = four; callback = three; disabledImage = cc.Sprite.create(selectedSprite); @@ -1330,10 +1330,10 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ initWithItems: function (args) { var l = args.length; // passing callback. - if (typeof args[args.length - 2] === 'function') { + if (cc.isFunction(args[args.length - 2])) { this.initWithCallback(args[args.length - 2], args[args.length - 1]); l = l - 2; - } else if (typeof args[args.length - 1] === 'function') { + } else if (cc.isFunction(args[args.length - 1])) { this.initWithCallback(args[args.length - 1], null); l = l - 1; } else { diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index dfff82207e..0fafeae9a3 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -255,7 +255,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ if(!texture) throw "cc.MotionStreak.initWithFade(): Invalid filename or texture"; - if (typeof(texture) === "string") + if (cc.isString(texture)) texture = cc.textureCache.addImage(texture); cc.Node.prototype.setPosition.call(this, cc.p(0,0)); diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 52ec8bbd39..7711e178ca 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -96,7 +96,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ ctor:function (fileImage, capacity) { cc.Node.prototype.ctor.call(this); this._blendFunc = {src:cc.BLEND_SRC, dst:cc.BLEND_DST}; - if (typeof(fileImage) == "string") { + if (cc.isString(fileImage)) { this.init(fileImage, capacity); } else if (fileImage instanceof cc.Texture2D) { this.initWithTexture(fileImage, capacity); diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index acd0613f47..5e9f700298 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -364,7 +364,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ this._quadsArrayBuffer = null; } - if (!plistFile || typeof(plistFile) === "number") { + if (!plistFile || cc.isNumber(plistFile)) { var ton = plistFile || 100; this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); this.initWithTotalParticles(ton); diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index bd7238f664..2c295b9762 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -71,7 +71,7 @@ if (fileName === undefined) { cc.PhysicsSprite.prototype.init.call(this); - }else if (typeof(fileName) === "string") { + }else if (cc.isString(fileName)) { if (fileName[0] === "#") { //init with a sprite frame name var frameName = fileName.substr(1, fileName.length - 1); @@ -81,7 +81,7 @@ //init with filename and rect this.init(fileName, rect); } - }else if (typeof(fileName) === "object") { + }else if (cc.isObject(fileName)) { if (fileName instanceof cc.Texture2D) { //init with texture and rect this.initWithTexture(fileName, rect); @@ -234,7 +234,7 @@ if (fileName === undefined) { cc.PhysicsSprite.prototype.init.call(this); - }else if (typeof(fileName) === "string") { + }else if (cc.isString(fileName)) { if (fileName[0] === "#") { //init with a sprite frame name var frameName = fileName.substr(1, fileName.length - 1); @@ -244,7 +244,7 @@ //init with filename and rect this.init(fileName, rect); } - }else if (typeof(fileName) === "object") { + }else if (cc.isObject(fileName)) { if (fileName instanceof cc.Texture2D) { //init with texture and rect this.initWithTexture(fileName, rect); diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 06142faa29..15c5167456 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -1055,7 +1055,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ break; } } - if(typeof item != "number") + if(!cc.isNumber(item)) cc.log("cc.TMXLayer._atlasIndexForExistantZ(): TMX atlas index not found. Shall not happen"); return i; }, diff --git a/extensions/ccb-reader/CCBAnimationManager.js b/extensions/ccb-reader/CCBAnimationManager.js index d08e9b54a7..f5d3549c01 100644 --- a/extensions/ccb-reader/CCBAnimationManager.js +++ b/extensions/ccb-reader/CCBAnimationManager.js @@ -381,7 +381,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ runAnimations:function (name, tweenDuration) { tweenDuration = tweenDuration || 0; var nSeqId; - if(typeof(name) === "string") + if(cc.isString(name)) nSeqId = this._getSequenceId(name); else nSeqId = name; diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index 8cc51607fa..3b1105b028 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -1062,7 +1062,7 @@ cc.BuilderReader.load = function (ccbFilePath, owner, parentSize, ccbRootPath) { controller[outletName] = outletNode; } - if (controller.onDidLoadFromCCB && typeof(controller.onDidLoadFromCCB) == "function") + if (controller.onDidLoadFromCCB && cc.isFunction(controller.onDidLoadFromCCB)) controller.onDidLoadFromCCB(); // Setup timeline callbacks diff --git a/extensions/ccb-reader/CCBValue.js b/extensions/ccb-reader/CCBValue.js index 9f5924cae1..781c25d861 100644 --- a/extensions/ccb-reader/CCBValue.js +++ b/extensions/ccb-reader/CCBValue.js @@ -76,12 +76,6 @@ cc.BuilderValue = cc.Class.extend({ }); cc.BuilderValue.create = function (value) { - var ret = new cc.BuilderValue(); - if(ret){ - if(typeof(value) == "number"){ - - } - } - return ret; + return new cc.BuilderValue(); }; diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index c226f6cabf..0babd3ccf8 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -114,7 +114,7 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * @param {ccui.Margin} margin */ setMargin: function (margin) { - if(typeof margin === 'object'){ + if(cc.isObject(margin)){ this._margin.left = margin.left; this._margin.top = margin.top; this._margin.right = margin.right; diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 6c545faad2..5b171a090c 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -284,7 +284,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @param {ccui.RichElement} element */ removeElement: function (element) { - if (typeof element === "number") + if (cc.isNumber(element)) this._richElements.splice(element, 1); else cc.arrayRemoveObject(this._richElements, element); diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index c6a0ef3b42..af2dfa0e15 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -1030,7 +1030,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ }, _asyncCallBack: function (selector, target, percent) { - if(selector && typeof selector === 'function') + if(selector && cc.isFunction(selector)) selector.call(target, percent); if(target && selector && typeof selector === 'string') target[selector](percent); diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index af1e7a9b84..40f1e00ac9 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -302,25 +302,25 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ * @param {Object} dict */ setPropertyFromJsonDict: function (node, dict) { - var x = (typeof dict["x"] === 'undefined')?0:dict["x"]; - var y = (typeof dict["y"] === 'undefined')?0:dict["y"]; + var x = (cc.isUndefined(dict["x"]))?0:dict["x"]; + var y = (cc.isUndefined(dict["y"]))?0:dict["y"]; node.setPosition(x, y); - var bVisible = Boolean((typeof dict["visible"] === 'undefined')?1:dict["visible"]); + var bVisible = Boolean((cc.isUndefined(dict["visible"]))?1:dict["visible"]); node.setVisible(bVisible); - var nTag = (typeof dict["objecttag"] === 'undefined')?-1:dict["objecttag"]; + var nTag = (cc.isUndefined(dict["objecttag"]))?-1:dict["objecttag"]; node.setTag(nTag); - var nZorder = (typeof dict["zorder"] === 'undefined')?0:dict["zorder"]; + var nZorder = (cc.isUndefined(dict["zorder"]))?0:dict["zorder"]; node.setLocalZOrder(nZorder); - var fScaleX = (typeof dict["scalex"] === 'undefined')?1:dict["scalex"]; - var fScaleY = (typeof dict["scaley"] === 'undefined')?1:dict["scaley"]; + var fScaleX = (cc.isUndefined(dict["scalex"]))?1:dict["scalex"]; + var fScaleY = (cc.isUndefined(dict["scaley"]))?1:dict["scaley"]; node.setScaleX(fScaleX); node.setScaleY(fScaleY); - var fRotationZ = (typeof dict["rotation"] === 'undefined')?0:dict["rotation"]; + var fRotationZ = (cc.isUndefined(dict["rotation"]))?0:dict["rotation"]; node.setRotation(fRotationZ); }, setTarget : function(selector,listener){ diff --git a/extensions/cocostudio/trigger/ObjectFactory.js b/extensions/cocostudio/trigger/ObjectFactory.js index d9be8bbdc5..93ecec0568 100644 --- a/extensions/cocostudio/trigger/ObjectFactory.js +++ b/extensions/cocostudio/trigger/ObjectFactory.js @@ -34,7 +34,7 @@ ccs.objectFactory = { var o = null; var t = this._typeMap[className]; if (t) { - if(typeof t._fun == "function"){ + if(cc.isFunction(t._fun)){ o = new t._fun(); }else{ o = t._fun; diff --git a/extensions/gui/control-extension/CCInvocation.js b/extensions/gui/control-extension/CCInvocation.js index 881fec6865..82b0189a9d 100644 --- a/extensions/gui/control-extension/CCInvocation.js +++ b/extensions/gui/control-extension/CCInvocation.js @@ -54,7 +54,7 @@ cc.Invocation = cc.Class.extend(/** @lends cc.Invocation# */{ invoke:function(sender){ if (this._target && this._action) { - if (typeof(this._action) == "string") { + if (cc.isString(this._action)) { this._target[this._action](sender, this._controlEvent); } else{ this._action.call(this._target, sender, this._controlEvent); diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 4990e727ef..97a76a2150 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -139,8 +139,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ var argSkeletonFile = skeletonDataFile, argAtlasFile = atlasFile, skeletonData, atlas, ownsSkeletonData; - if (typeof argSkeletonFile == 'string') { - if (typeof argAtlasFile == 'string') { + if (cc.isString(argSkeletonFile)) { + if (cc.isString(argAtlasFile)) { var data = cc.loader.getRes(argAtlasFile); sp._atlasLoader.setAtlasFile(argAtlasFile); atlas = new spine.Atlas(data, sp._atlasLoader); From 38171dcee811082cfa714900ad15367e104bb46c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 2 Sep 2014 11:52:03 +0800 Subject: [PATCH 0590/1564] Issue #5888: Type resolution adaptation --- cocos2d/core/platform/CCEGLView.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 562acc5e0e..4cc290e087 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -174,8 +174,20 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _initFrameSize: function () { var locFrameSize = this._frameSize; - locFrameSize.width = this._frame.clientWidth; - locFrameSize.height = this._frame.clientHeight; + //To get the most likely for the actual display resolution data + var sWidth = Math.min(window.screen.availWidth, window.screen.width) * window.devicePixelRatio; + var sHeight = Math.min(window.screen.availHeight, window.screen.height) * window.devicePixelRatio; + //Calibration of the actual resolution may be smaller + if(this._frame.clientWidth >= sWidth * 0.8){ + locFrameSize.width = sWidth / window.devicePixelRatio; + }else{ + locFrameSize.width = this._frame.clientWidth; + } + if(this._frame.clientWidth >= sHeight * 0.8){ + locFrameSize.height = sHeight / window.devicePixelRatio; + }else{ + locFrameSize.height = this._frame.clientHeight; + } }, // hack @@ -188,7 +200,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _setViewPortMeta: function (width, height) { if (this._isAdjustViewPort) { - var viewportMetas = {"user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}, elems = document.getElementsByName("viewport"), vp, content; + var viewportMetas = {"user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0", width: "device-width"}, + elems = document.getElementsByName("viewport"), vp, content; if (elems.length == 0) { vp = cc.newElement("meta"); vp.name = "viewport"; From 01e990b89d17f763a223d9b5e50843888c28c023 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 2 Sep 2014 11:59:11 +0800 Subject: [PATCH 0591/1564] Issue #5888: Type resolution adaptation --- cocos2d/core/platform/CCEGLView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 4cc290e087..6f15281684 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -178,12 +178,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ var sWidth = Math.min(window.screen.availWidth, window.screen.width) * window.devicePixelRatio; var sHeight = Math.min(window.screen.availHeight, window.screen.height) * window.devicePixelRatio; //Calibration of the actual resolution may be smaller - if(this._frame.clientWidth >= sWidth * 0.8){ + if(cc.sys.isMobile && this._frame.clientWidth >= sWidth * 0.8){ locFrameSize.width = sWidth / window.devicePixelRatio; }else{ locFrameSize.width = this._frame.clientWidth; } - if(this._frame.clientWidth >= sHeight * 0.8){ + if(cc.sys.isMobile && this._frame.clientWidth >= sHeight * 0.8){ locFrameSize.height = sHeight / window.devicePixelRatio; }else{ locFrameSize.height = this._frame.clientHeight; From 0c3684c7ffcb1cf3f00df8853d27f0c0b34e93ac Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 3 Sep 2014 11:07:51 +0800 Subject: [PATCH 0592/1564] Fixed #5880: adds setPlaceHolderColor and setTextColor to ccui.TextField and refactors cc.Menu --- cocos2d/menus/CCMenu.js | 57 +----------------------- cocos2d/text-input/CCTextFieldTTF.js | 52 ++++++++++++--------- extensions/ccui/uiwidgets/UITextField.js | 28 +++++++++++- 3 files changed, 58 insertions(+), 79 deletions(-) diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 85c2dd8252..89ca402fb3 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -58,8 +58,6 @@ cc.DEFAULT_PADDING = 5; cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ enabled: false, - _color: null, - _opacity: 0, _selectedItem: null, _state: -1, _touchListener: null, @@ -67,7 +65,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ /** * Constructor of cc.Menu override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. - * @param {...cc.MenuItem|null} menuItems} + * @param {...cc.MenuItem|null} menuItems */ ctor: function (menuItems) { cc.Layer.prototype.ctor.call(this); @@ -122,59 +120,6 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ cc.Node.prototype.onEnter.call(this); }, - /** - * return the color for cc.Menu - * @return {cc.Color} - */ - getColor: function () { - var locColor = this._color; - return cc.color(locColor.r, locColor.g, locColor.b, locColor.a); - }, - - /** - * set the color for cc.Menu - * @param {cc.Color} color - */ - setColor: function (color) { - var locColor = this._color; - locColor.r = color.r; - locColor.g = color.g; - locColor.b = color.b; - - var locChildren = this._children; - if (locChildren && locChildren.length > 0) { - for (var i = 0; i < locChildren.length; i++) { - locChildren[i].setColor(color); - } - } - - if (color.a !== undefined && !color.a_undefined) { - this.setOpacity(color.a); - } - }, - - /** - * return the opacity for this menu - * @return {Number} - */ - getOpacity: function () { - return this._opacity; - }, - - /** - * set the opacity for this menu - * @param {Number} opa - */ - setOpacity: function (opa) { - this._opacity = opa; - var locChildren = this._children; - if (locChildren && locChildren.length > 0) { - for (var i = 0; i < locChildren.length; i++) - locChildren[i].setOpacity(opa); - } - this._color.a = opa; - }, - /** * return whether or not the menu will receive events * @return {Boolean} diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index 3534b3ed61..43d28e237c 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -107,6 +107,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ delegate:null, colorSpaceHolder:null, + _colorText: null, _lens:null, _inputText:"", _placeHolder:"", @@ -124,6 +125,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ */ ctor:function (placeholder, dimensions, alignment, fontName, fontSize) { this.colorSpaceHolder = cc.color(127, 127, 127); + this._colorText = cc.color(255,255,255, 255); cc.imeDispatcher.addDelegate(this); cc.LabelTTF.prototype.ctor.call(this); @@ -163,19 +165,33 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ }, /** - * Gets the color of space holder. + * Returns the color of space holder. * @return {cc.Color} */ getColorSpaceHolder:function () { - return this.colorSpaceHolder; + return cc.color(this.colorSpaceHolder); }, /** - * Gets the color of space holder. + * Sets the color of space holder. * @param {cc.Color} value */ setColorSpaceHolder:function (value) { - this.colorSpaceHolder = value; + this.colorSpaceHolder.r = value.r; + this.colorSpaceHolder.g = value.g; + this.colorSpaceHolder.b = value.b; + this.colorSpaceHolder.a = cc.isUndefined(value.a) ? 255 : value.a; + }, + + /** + * Sets the color of cc.TextFieldTTF's text. + * @param {cc.Color} textColor + */ + setTextColor:function(textColor){ + this._colorText.r = textColor.r; + this._colorText.g = textColor.g; + this._colorText.b = textColor.b; + this._colorText.a = cc.isUndefined(textColor.a) ? 255 : textColor.a; }, /** @@ -197,15 +213,13 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ initWithPlaceHolder:function (placeholder, dimensions, alignment, fontName, fontSize) { switch (arguments.length) { case 5: - if (placeholder) { + if (placeholder) this.setPlaceHolder(placeholder); - } return this.initWithString(this._placeHolder,fontName, fontSize, dimensions, alignment); break; case 3: - if (placeholder) { + if (placeholder) this.setPlaceHolder(placeholder); - } return this.initWithString(this._placeHolder, arguments[1], arguments[2]); break; default: @@ -223,10 +237,15 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this._inputText = text || ""; // if there is no input text, display placeholder instead - if (!this._inputText.length) + if (!this._inputText.length){ cc.LabelTTF.prototype.setString.call(this, this._placeHolder); - else + this.setColor(this.colorSpaceHolder); + } else { cc.LabelTTF.prototype.setString.call(this,this._inputText); + this.setColor(this._colorText); + } + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._updateTexture(); this._charCount = this._inputText.length; }, @@ -247,6 +266,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this._placeHolder = text || ""; if (!this._inputText.length) { cc.LabelTTF.prototype.setString.call(this,this._placeHolder); + this.setColor(this.colorSpaceHolder); } }, @@ -269,18 +289,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ if (this.delegate && this.delegate.onDraw(this)) return; - if (this._inputText && this._inputText.length > 0) { - cc.LabelTTF.prototype.draw.call(this, context); - return; - } - - // draw placeholder - var color = this.color; - this.color = this.colorSpaceHolder; - if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._updateTexture(); cc.LabelTTF.prototype.draw.call(this, context); - this.color = color; }, /** @@ -359,6 +368,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this._inputText = ""; this._charCount = 0; cc.LabelTTF.prototype.setString.call(this,this._placeHolder); + this.setColor(this.colorSpaceHolder); return; } diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index ba51b5c263..37d9c3912a 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -381,6 +381,30 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ return this._textFieldRenderer.getPlaceHolder(); }, + /** + * Returns the color of ccui.TextField's place holder. + * @returns {cc.Color} + */ + getPlaceHolderColor: function(){ + return this._textFieldRenderer.getPlaceHolderColor(); + }, + + /** + * Sets the place holder color to ccui.TextField. + * @param color + */ + setPlaceHolderColor: function(color){ + this._textFieldRenderer.setColorSpaceHolder(color); + }, + + /** + * Sets the text color to ccui.TextField + * @param textColor + */ + setTextColor: function(textColor){ + this._textFieldRenderer.setTextColor(textColor); + }, + /** * Sets font size for ccui.TextField. * @param {Number} size @@ -762,12 +786,12 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRenderer.setVerticalAlignment(alignment); }, _setFont: function (font) { - this._textFieldRender._setFont(font); + this._textFieldRenderer._setFont(font); this._textFieldRendererAdaptDirty = true; }, _getFont: function () { - return this._textFieldRender._getFont(); + return this._textFieldRenderer._getFont(); } }); From ec41dc423f3dcd3ed0b9f41c336f338e32a9aace Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 3 Sep 2014 16:26:02 +0800 Subject: [PATCH 0593/1564] Delete unnecessary files --- cocos2d/core/scenes/CCSceneFile.js | 30 ------------------------------ cocos2d/shaders/CCShaders.js | 4 ++-- 2 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 cocos2d/core/scenes/CCSceneFile.js diff --git a/cocos2d/core/scenes/CCSceneFile.js b/cocos2d/core/scenes/CCSceneFile.js deleted file mode 100644 index 724427480e..0000000000 --- a/cocos2d/core/scenes/CCSceneFile.js +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ -/** - * It's the logo of Cocos2d-js (base64 image file) - * @type {string} base64 image file - * @private - */ -cc._loaderImage = "data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAlAAD/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjM4MDBEMDY2QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjM4MDBEMDY1QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTk0OEM4OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2RTk0OEM5OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4ADkFkb2JlAGTAAAAAAf/bAIQADQkJCQoJDQoKDRMMCwwTFhENDREWGhUVFhUVGhkUFhUVFhQZGR0fIB8dGScnKionJzk4ODg5QEBAQEBAQEBAQAEODAwOEA4RDw8RFA4RDhQVERISERUfFRUXFRUfKB0ZGRkZHSgjJiAgICYjLCwoKCwsNzc1NzdAQEBAQEBAQEBA/8AAEQgAyACgAwEiAAIRAQMRAf/EALAAAAEFAQEAAAAAAAAAAAAAAAQAAgMFBgcBAQEAAwEBAAAAAAAAAAAAAAAAAQMEAgUQAAIBAgIEBwoLBgQGAwAAAAECAwAEEQUhMRIGQVFxsTITFGGBwdEiQlKSMzWRoeFicqKyI1NzFYJjJDQWB9KjVCbxwkNkJWXik3QRAAIBAgMFBQcDBQEAAAAAAAABAhEDIRIEMUFRcTJhwVIUBZGhsSJyEzOB0ULhYpIjUxX/2gAMAwEAAhEDEQA/AMJSpUqAVKlXuFAeUq9wpUB5XuFe4V6ooDzZHDox0CnGMinzwl7Z8NajaHeoO3vmTBZBtp9YUIqTEV5ROxHKnWRnaU8VRMhFBUjpV7hSoSeUq9pUB5Sr2lhQHlKvcK8oBV7hSFSRrtaKAZs07YNPM1pG2xJIAw1jSeandry/8X4m8VCKkWwaWwam7Xl/4v1W8VLtmX/i/VbxUoKkWwakSM407tmX/i/VbxUmzGwjQsjdY41IARie/U0IbZO0kNtCXnOCkEBeFu4KI3Bs7DNb27ya+jDx3kJeEnpJJEcQVbWDsk17u5urd591ucZkWhym2Vnd9RkCDEpFxDRpbw0bunu5mlp2De2FMLYXOD2wB2xbOeraUcYGJ72mlSUiqzzdzMd3Z3mixltA2yzcK/NlHM1DQyRXce1HocdNOEfJXZ88y9ZojOqhiBszIRiHQ8Y4cK5TvHuzLljHNMqxNoDjLFraHHnjPxcNCGVbxEUzYNTx5jZSxhpW6qTzlwJ+DCvO2Zf+L9VvFSgqyHYNLYNTdssPxfibxUu15f8Ai/VPiqCakOwa82DU/a8v/F+JvFTDdWPBL8R8VKCvYRYV5UzoMAy6QdIIqI0B4KJtxiRQwou16QoGUkntH5Tz0RbZbmF2hktraSVBo2lUkY8tDye0flPPXTslVUyiyVRsjqUOA4yMT8dW2ram2m6UVTNq9S7EIyUVJydMTn/6DnP+im9Wl+g5z/opvVrpteEhQWY4AaSTwAVf5WPiZh/9S5/zj7zltzlmYWkfWXNvJDGTgGcYDHirR7i7mSbwXParsFMrgb7w6jKw/wCmnc9I14kF3vpvCljbMyWMOJL4aEiB8qU/ObUK7HYWVrl1pFZWiCOCBQqKOLjPGTrNZZqKbUXVHq2nNwTuJRk1VpbgXN8s7Rk5ym0UQQzhIG2NAjhxHWbI+gCBVjBBFbwxwQqEiiUJGg1BVGAFe7dV28WYLYZFmF2Th1UD7JGjymGyn1iK5OyzIBGB1HgrLZhamzumQAGJwSqnSCh1q3GOCodxt4cxurdcpzuN4cyhiWaF5Bg09udUmnWw1H/jV9nFuJ7Quo+8h8peThFA+047vduyMtk7fYqTl07YFdfUufMPzT5p71UdtlmYXaGS2t3mQHAsgxANdadYJopLe4QS2867EsZ4QfCNYrCFbjdDPmgkYyWFxgVf04ifJf6ScNdRUW1XBb6FU5TjF5EpSSrGu/s5lN+g5z/opvVpfoOc/wCim9WtdHnatvObJXDW7xLGhB8nrPaY9/HCr+tEdPCVaSeDoYLnqF63lzW4/PFSW3ecxbI84VSzWUwUaSdg0DXXK5nvAipnd6qgKvWnQO7pri9ZUEmm3Vl2j1kr8pRlFRyquBNZjGxQ/S56Y1S2fu9OVueon11Szahoou06QoQUXadIVCD2FJJ7R+U89dMydv8Axdn+TH9muZye0flPPXQstlK5Tbka1gUjlC1q0vVLkeb6r+O3Tx9xcY1nt8c0NrZCyiOE1108NYjGv1joo7Js1jzKyScYLIvkzL6LDwHXVJksH9Sb49dKNq0tj1jA6uriOCL+02FWX7iVtZX1/AzaHTyeoauKn2MX9W79zebiZCuR5MjSrhfXuEtwTrUeZH+yNfdrRNcxI6IzhXlJEak6WIGJ2Rw4ChWnChndtlVBLMdQA0k1gbXNMzzDfDLs6mjaPKppJbWwJ1bOwwxw43OnHh71YT3DpfWUJmFlb5jHHDdeXBHIsrRea5TSqvxqG04cNN62vetoCS4tre5mgnkGE9q+3DKOkuI2WX6LDQRRHWDh1UCtwj7QRg2wdl8Djgw1qe7XvW0BQ3kfZ7mSLgU+T9E6RVbnuVrnWVSWqj+Lt8ZbRuHEdKPkYVcZ2MJY5fSGyeVar45+rkWQHAqccalPE5km1htWK5nK4Wnt5FuUBUwOMG4nGkA/BXUrW4S6torlOjMgcd/xVn7rLo7zKs0uEjCNeSvdwoBhgsZxX1l2j36k3Lu+uyprdj5Vs5A+i/lD48a0aaVJOPi7jB6lbzWozpjB48pf1NDXNN4vfl7+Z4BXS65pvF78vfzPAK71XTHmZ/S/yT+jvJ7L3fHytz1E+upbL+Qj5W56jfXWRnsIYKLtekKEFGWvSFQgyjk9o/Keet3YthlMP/5x9msJJ7R+U89biyb/AMXEv7gD6tadL1T+kwepRrC39ZkLDMbiwMvUHRPG0bjlGg8ore/23sxBldxfMPLupNhT8yL/AORNZbdzJ484scytxgLqJY5LZj6Q2sV5G1Vud1mjjyG0ij0NEGSZToKyhjtqw4waztuiXA3qKTbSxltfGhbZlE95ZtZqxVbgiOZhrER9ph3Svk9+pJILZ4Y4DGBFCUMKjRsGPobPFhUfW0NJmljE2xJcIrcI2vFUEln1lRXd6lrazXT9GCNpD+yNqoI7mOVduNw6nzlOIoPOUa6yye1XXcbMR5GdQ3xY0BSbj31/FcTQZirJ+q431q7anbHCTZ72Bw7lbPrKBMcBWNNgbMBBh+bsjBdni0VJ1lARZs6yWiupxCuMDy6KpS2IwOo6DTr3Mre3e5tZZVUM4ZBjqOOJoWO4jkXajcOOMHGgDISvWIrdAkKR80+TzVl908bPPL3LzxOuHdifxVfiTAg92qI/w+/8gGgSyN/mR7XPVlp0lF/3L3mbVKtu5Hjbk/8AHE2Fc03i9+Xv5ngFdKNc13i9+Xv5ngFaNV0x5nn+l/kn9HeEWXu+PlbnqJ9dS2Xu9OVueon11kZ7CGCjLXpCgxRlr0hUIPYUcntH5Tz1s8vb+Bt1/dqPirGSe0flPPWusG/g4Py15q06XqlyMWvVYQ+ruI9xJOqzO9hOto/sP8tbGOFIrmWeM7IuMDMnAXXQJOUjQeOsJk0nY96ip0CYunrjaHx1t+srPJUbXBm2LrFPikwTOb+T+VhbZxGMrDXp83x1QSy2tucJpUjPETp+Cn5/ftaRvKvtp3Kx48HG3erHMzOxZiWZtLMdJNQSbbL71Vk6yynViOkqnEEfOWtPbXi3EQkGg6mXiNckjeSJxJGxR10qw0GtxuxmvbImD4CZMFlA4fRfv0BqesqqzTMZNMEDbIHtHH2QeCiZJSqMQdOGiue53mz3czQwsRbIcNHnkec3c4qAMuriz68gTIToxwOOnlp0MjxMJYW741Gs3RVldtbygE/dMcHX/moDaxTiWNZB53B3arb8/wC+4SOF4sf/AKxU9kcBsfOGHfoUHtG/RbzY5Die5HHhXdvavqiZ9Q8Jdlq4/gbKua7xe/L38zwCuhpf2Uk/Zo50kmwJKIdogDjw1VzzeL35e/meAVp1LTgqY4nn+mRauzqmqwrjzCLL3fHytz1E+upLL+Qj5W56jfXWRnroYKLtekKEFF2vSFQg9hSSe0flPPWosm/hIfoLzVl5PaPynnrRWb/w0X0F5q06XqlyM2sVYx5gmbFre/t71NY2T+0h8VbSO5SWNJUOKSAMp7jDGspmMPaLRlXS6eWve1/FRO7WYdbZm1Y/eW/R7qHxHRXGojlm3ulid6aVbaW+OALvgCLq2Hm9WxHKWqjhj6xsK1e8dm15l4niG1LZkswGsxtrPeOmsvayBJA1VItlWjptLuTdPMo7LtjRDq9naK4+WF9IrUW7BaHOljGqVHB7w2hzVoZt87d8vaNYSLl02CcRsDEbJbj71Uu7UBkvJ7/D7q2QoDxySaAO8MTXdxRVMpRp5XZOWdF/ms7R5XdyKfKWJsO/5PhrG5XlNxmEywW6bTnTxAAcJNbGSMXkM1pjgbiNo1PziPJ+Os7u7m/6ReM00ZOgxSpqYYHT3wRXMKN4ll9zUG4bQfNshu8sZVuEA2hirA4qe/VOwwrVbzbww5mI44UKRRYkbWG0S3JWctbd7u5WFfOOLHiUdJqmaipfLsIsObhWe001lMkMVvJNjhghIALMcBxCs7fxXQmkupx1bXDswGPlaTidVaEyKNXkoo4eBV+Sq7L7Vs9zcBgeyQ4GQ/MB1crmoim2orezqcowTuSeEY48jQ7oZX2PLzdyLhNd6RjrEY6I7+uspvH78vfzPAK6UAAAFGAGgAcArmu8Xvy9/M8ArTfio24RW5nnaG67uou3H/KPuqT2X8hHytz1G+upLL3enK3PUb66ys9RDBRdr0hQgou06QqEGUkntH5Tz1e238vF9BeaqKT2j8p56vbb+Xi+gvNWjTdUuRn1XTHmTh8KrJTJlt8t1CPIY44cGnpJVjTJYkmjaN9Ib4u7V923njTethRauZJV3PaW1rfLIiXEDYg6R4VYc9CXW7thfOZbKdbGZtLW8uPVY/u3GrkNUkM9zlcxUjbhfWOA90cRq4gv4LhdqN+VToNYWmnRm9NNVWNTyHc6VWBv8wt4YeHqm6xyPmroq1Z7WGFLSxTq7WLSuPSdjrkfumq5yHXDUeA92oO2SKpVumNAaoJLMXH3myp0rpJ4uKhc3tbDM5BMri1zAj79j7KTiY8TcdBpcsith0286o+sPCagEX9Pzg4zXUCp6QYse8oouCG3tk6m1BYv05W6T+IdyolxbHDAAa2OgDlNCz3ryN2WxBd5PJMg1t81eId2ukqnLlTBbfcuY+9uJLiRcvtPvHdsHK+cfRHcHDWsyawjyy0WBcDI3lTP6TeIcFV+S5OmXx9bJg1048o8Cj0V8Jq2DVu09nL80up7OxHi+oal3P8AXB/IsZS8T/YOV65zvCcc7vfzPAK3ivWCz445zeH954BXOr6I8yfSfyz+jvCLP3fHytz1G+upLP3fHytz1E+usbPaQ0UXadIUIKLtekKhB7Ckk9o/Keer22/l4/oLzVRSe0flPPV7b/y8X0F5q0abqlyM+q6Y8yQsBTDMor1o8aiaE1pbluMqS3sbLLHIhSRQyngqukhaJ9uBjo+H5aOa3ao2t34qouRlLajTalGP8v0IY8ylXQ+PKPFU/bYXOLPge6CKia0LaxTOxHu1Q7cuBd9yPEJ7TbjXKO8CajbMIF6CNIeNvJHjqIWJ7tSpYkalqVblwIdyG+RGXur0hXYJFxal+Dhq5y3slkv3Y2pD0pTr+QUClpJRUdo9XW4OLrTHtM16cZLLWkeC7y4jvlNEpcRtw1Ux27Ci448NZrTFy3nn3IQWxlgGrDZ3pza7/M8ArZo+ArF5171uvp+CqdV0R5l/psUrs2vB3hdl7vTlbnqJ9dS2Xu+PlbnqJ9dY2eshooq16QoQUXa9IVCD2FLJ7RuU89WNtmUSQqkgYMgw0accKrpPaPynnrZWG4Vi+VWmY5tnMWXG+XrIYnA0rhj0mdcTgdNdwnKDqjmduM1SRR/qlr8/4KX6pa8T/BVzDuLZXudRZblmbxXcPUNPc3KqCIwrbOzgrHEnHjoyD+3eSXkht7DeKG4umDGOJVUklfouThXfmbnZ7Cvy1vt9pmv1W1+d8FL9VteJvgq5yrcOGfLmzHN80iyyETPbptAEFo2ZG8pmUa1OFNn3Ky6W/sbDKM5hv5bx2WTZA+7RF2y52WOPJTzE+z2Dy1vt9pT/AKpacTerS/U7Tib1a04/t7kDXPY03jhN0W6sQ7K7W3q2dnrMccaDy/8At80kuZfqWYxWNtlcvUPPhiGYhWDeUy7IwYU8xPs9g8tb7faUn6pacTerTxm9oOBvVq3v9z927aynuId44LiWKNnjhAXF2UYhRg516qpsryjLr21665zFLSTaK9U2GOA87SwqY37knRU+BzOzags0s1Oyr+BKM6sxwP6tSDPLMen6vy0rvdm3Sxlu7K/S7WDDrFUDUTxgnTU826eXW7KlxmqQuwDBXUKcD+1Xee/wXuKX5XDGWLapSVcOyhEM/seJ/V+WnjeGx4pPV+Wkm6kKZlFay3Jlt7iFpYZY8ASVK6DjtDDA0f8A0Tl340/1f8Ndx8xJVWXB0KbktFFpNzdVXAC/qOwA0CQni2flrO3Vwbm5lnI2TKxbDirX/wBE5d+NcfV/wVR7xZPa5U9utvI8nWhmbbw0YEAYYAVxfhfy5rlKR4Fulu6X7mW1mzT8S4Yis/5CPlbnqJ9dSWfu9OVueon11mZvQ2i7XpChKKtekKhBlNJ7R+U89bDfGTb3a3ZX0Lcj6kdY+T2j8p560288m1kWQr6MJ+ylSAr+2cnV5renjs3H1loX+3j9XvbbtxLN9lqW4UnV5jdnjtXHxihtyZNjeSBu5J9k1BJe7xy7W5CJ/wCzuD/mTVTf2+fq97LJuLrPsNRueS7W6aJ/38x+vLVXuY+xvHaNxbf2GoCezf8A36j/APsSf8w1sLnqczTefJluYoLm5uo5F61sBshItP1cNFYe1f8A3ir/APfE/wCZUe9bB94r5jwuPsrQFhmG4l/Z2M17HdW90tuu3IkTHaCjWdIw0VVZdks9/C06yJFEp2dp+E1bbqybGTZ8vpQD7L1XRv8A7blT96Oda7tpNuuNE37Cq9KSisjyuUoxrStKllHbLlWTXsMs8chuSuwEPDqwoLe5y+YRE/gLzmqRekvKKtd4327yM/ulHxmrHJStySWVRyrjxKI2XC/CTlnlPPKTpTdFbP0L1bgrf5Lp0G3dPhQHwV0S1lzBsns3sESR8Crh9WAJGjSOKuU3E+zdZQ3oJh8IArdZXFDmOTpHa3i2+YrI2KtKy4ricBsBuHHgFXSo440+Wa2qqxjvM9uMoy+WvzWpLCWWWE28HxL6e43ojgkeSCBY1Ri5BGIUDT51cl3vm276BBqSEH4WbxV0tlkyXJcxTMb+OW6uY9mGHrCzDQwwAbTp2uKuTZ9N1uYsfRRR8WPhrm419mSSjRyiqxVK7y23B/ftuTm2oSdJyzNVw3BFn7vTlbnqF9dS2fu9OVueon11lZuQ2iLdsGFD05H2dNQGV0ntG5Tz1dWm9N1b2kVq8EVwsI2UaQaQOKhmitZGLOmk68DhSFvY+gfWNSAg7z3Qvo7yKCKIohiaNR5LKxx8qpxvjcqS0VpbxvwOAcRQPZ7D0G9Y0uz2HoH1jUCpLY7zXlpbm3eKO5QuzjrBqZji3x17PvNcyT288VvDBJbMWUovS2hslW7mFQ9nsPQPrGl2ew9A+saCod/WNxtbYsrfb17WBxx5ddD2281xC88klvDcSXEnWuzrqOGGC9zRUPZ7D0G9Y0uzWHoH1jQVCLreq6ntZbaO3it1mGy7RjTs1X2mYy20ZiCq8ZOODcdEdmsPQb1jS7PYegfWNdJuLqnQiSUlRqpFLmryxtH1Ma7Qw2gNNPOdSt0oI27p007s9h6B9Y0uz2HoH1jXX3Z+I4+1b8IJdX89xLHKQFMXQUahpxoiPN5P+onfU+A0/s9h6DesaXZ7D0D6xpG7OLbUtu0StW5JJx2bBsmbtiSiEk+cxoCWWSaVpZOk2vDVo0VYdnsPQb1jSNvZcCH1jSd2c+p1XAmFqEOmOPEfaH+BQd1ueo211IzrgFUYKNAAqI1WztCpUqVCRUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoD/9k="; diff --git a/cocos2d/shaders/CCShaders.js b/cocos2d/shaders/CCShaders.js index 097d0167a0..a706a9ffe7 100644 --- a/cocos2d/shaders/CCShaders.js +++ b/cocos2d/shaders/CCShaders.js @@ -258,8 +258,8 @@ cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG = + "void main() \n" + "{ \n" + " vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n" - + " // mimic: glAlphaFunc(GL_GREATER) \n" - + " //pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value \n" + // mimic: glAlphaFunc(GL_GREATER) + //pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value + " if ( texColor.a <= CC_alpha_value ) \n" + " discard; \n" + " gl_FragColor = texColor * v_fragmentColor; \n" From 3bb06d0e5251b72c56f8fe02b33379149daede9d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 3 Sep 2014 17:34:40 +0800 Subject: [PATCH 0594/1564] facebook update --- external/pluginx/platform/facebook.js | 112 ++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 7 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index b0a28a37b6..a3885651be 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -86,25 +86,39 @@ plugin.extend('facebook', { /** * Login to facebook * @param {Function} callback + * @param {Array} permissions * @example * //example * plugin.FacebookAgent.login(); */ - login: function(callback){ + login: function(callback, permissions){ var self = this; + permissions = permissions || []; + if(!permissions.some(function(item){ + if(item == 'publish_actions') + return true; + })){ + permissions.push("publish_actions"); + } + var permissionsStr = permissions.join(','); FB.login(function(response) { if (response['authResponse']) { //save user info self.userInfo = response['authResponse']; + var permissList = response['authResponse']['grantedScopes'].split(","); typeof callback === 'function' && callback(0, { - accessToken: response['authResponse']['accessToken'] + accessToken: response['authResponse']['accessToken'], + permissions: permissList }); } else { typeof callback === 'function' && callback(response['error_code'] || 1, { error_message: "unknown" }); } - }, { scope: 'publish_actions' }); + }, { + scope: permissionsStr, + return_scopes: true + }); }, /** @@ -163,6 +177,7 @@ plugin.extend('facebook', { /** * Acquiring new permissions + * @deprecated since v3.0 * @param permissions * @param callback * @example @@ -214,7 +229,8 @@ plugin.extend('facebook', { //login - save user info self.userInfo = response['authResponse']; callback(0, { - accessToken: response['authResponse']['accessToken'] + accessToken: response['authResponse']['accessToken'], + }); }else{ callback(response['error_code'] || 1, { @@ -318,8 +334,7 @@ plugin.extend('facebook', { if( info['method'] != 'share_open_graph' && - info['method'] != 'share_link' && - info['method'] != 'apprequests' + info['method'] != 'share_link' ){ cc.log('web is not supported what this it method'); return; @@ -350,7 +365,7 @@ plugin.extend('facebook', { * @param {Object} params * @param {Function} callback */ - request: function(path, httpmethod, params, callback){ + api: function(path, httpmethod, params, callback){ if(typeof params === 'function'){ callback = params; params = {}; @@ -414,5 +429,88 @@ plugin.extend('facebook', { callback(0, response); } }) + }, + + /** + * Various pop + * @param info + * @param callback + */ + appRequest: function(info, callback){ + if(!info){ + return; + } + + info['method'] = "apprequests"; + delete info['dialog']; + + info['name'] = info['site'] || info['name']; + delete info['site']; + + info['href'] = info['siteUrl'] || info['link']; + delete info['siteUrl']; + delete info['link']; + + info['image'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; + delete info['imageUrl']; + delete info['imagePath']; + delete info['photo']; + + + info['caption'] = info['title'] || info['caption']; + delete info['title']; + + info['description'] = info['text'] || info['description']; + delete info['text']; + delete info['description']; + + if(info['method'] == 'share_open_graph' && info['url']){ + if(info['url']){ + var obj = {}; + if(info["preview_property"]) + obj[info["preview_property"]] = info["url"]; + else + obj["object"] = info["url"]; + + for(var p in info){ + if(p != "method" && p != "action_type" && p != "action_properties"){ + info[p] && (obj[p] = info[p]); + delete info[p]; + } + } + + info['action_properties'] = JSON.stringify(obj); + }else{ + return; + } + }else{ + if(!info['href']){ + return; + } + } + + if( + info['method'] != 'apprequests' + ){ + cc.log('web is not supported what this it method'); + return; + } + + FB.ui(info, + function(response) { + if (response) { + if(response['post_id']) + typeof callback === 'function' && callback(0, { + didComplete: true, + post_id: response['post_id'] + }); + else + typeof callback === 'function' && callback(0, response); + } else { + typeof callback === 'function' && callback(1, { + error_message:"Unknow error" + }); + } + }); } }); \ No newline at end of file From 8724880af3476a267e93aa2ffb3a9ca8ecb70dcb Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Sep 2014 14:25:24 +0800 Subject: [PATCH 0595/1564] Issue #5894: add jsDocs to Cocostudio. --- cocos2d/labels/CCLabelBMFont.js | 2 +- extensions/ccb-reader/CCBAnimationManager.js | 7 +- extensions/cocostudio/action/CCActionFrame.js | 59 ++++-- .../cocostudio/action/CCActionManager.js | 8 +- extensions/cocostudio/action/CCActionNode.js | 192 ++++++++---------- .../cocostudio/action/CCActionObject.js | 95 +++++---- .../cocostudio/trigger/ObjectFactory.js | 53 ++--- extensions/cocostudio/trigger/TriggerBase.js | 16 +- 8 files changed, 220 insertions(+), 212 deletions(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 7a18c5a03f..ab60c5f67e 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -603,7 +603,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ /** * Update String.
    - * Only update this label displa string. + * Only update this label display string. * @param {Boolean} fromUpdate */ updateString: function (fromUpdate) { diff --git a/extensions/ccb-reader/CCBAnimationManager.js b/extensions/ccb-reader/CCBAnimationManager.js index f5d3549c01..ec41be26ca 100644 --- a/extensions/ccb-reader/CCBAnimationManager.js +++ b/extensions/ccb-reader/CCBAnimationManager.js @@ -353,8 +353,8 @@ cc.BuilderAnimationManager = cc.Class.extend({ // Make callback at end of sequence var seq = this._getSequence(nSeqId); - var completeAction = cc.Sequence.create(cc.DelayTime.create(seq.getDuration() + tweenDuration), - cc.CallFunc.create(this._sequenceCompleted,this)); + var completeAction = cc.sequence(cc.delayTime(seq.getDuration() + tweenDuration), + cc.callFunc(this._sequenceCompleted,this)); this._rootNode.runAction(completeAction); // Playback callbacks and sounds @@ -640,8 +640,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ } } - var seq = cc.Sequence.create(actions); - node.runAction(seq); + node.runAction(cc.sequence(actions)); } }, diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 8d23dfa368..04c1dfa450 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -260,7 +260,7 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ }, /** - * + * Sets the easing parameter to action frame. * @param {Array} parameter */ setEasingParameter: function(parameter){ @@ -269,18 +269,25 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ this._Parameter.push(parameter[i]); }, + /** + * Sets the easing type to ccs.ActionFrame + * @param {Number} easingType + */ setEasingType: function(easingType){ this.easingType = easingType; } }); /** - * Base class for ccs.ActionMoveFrame + * The Cocostudio's move action frame. * @class * @extends ccs.ActionFrame */ ccs.ActionMoveFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionMoveFrame# */{ _position: null, + /** + * Construction of ccs.ActionMoveFrame + */ ctor: function () { ccs.ActionFrame.prototype.ctor.call(this); this._position = cc.p(0, 0); @@ -303,7 +310,7 @@ ccs.ActionMoveFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionMoveFrame# */{ }, /** - * Gets the move action position. + * Returns the move action position. * @returns {cc.Point} */ getPosition: function () { @@ -311,7 +318,7 @@ ccs.ActionMoveFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionMoveFrame# */{ }, /** - * Gets the CCAction of ActionFrame. + * Returns the CCAction of ActionFrame. * @param {number} duration * @returns {cc.MoveTo} */ @@ -321,13 +328,16 @@ ccs.ActionMoveFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionMoveFrame# */{ }); /** - * Base class for ccs.ActionScaleFrame + * The Cocostudio's scale action frame * @class * @extends ccs.ActionFrame */ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# */{ _scaleX: 1, _scaleY: 1, + /** + * Construction of ccs.ActionScaleFrame + */ ctor: function () { ccs.ActionFrame.prototype.ctor.call(this); this._scaleX = 1; @@ -344,8 +354,8 @@ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# * }, /** - * Gets the scale action scaleX. - * @returns {number} {number} + * Returns the scale action scaleX. + * @returns {number} */ getScaleX: function () { return this._scaleX; @@ -360,7 +370,7 @@ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# * }, /** - * Gets the scale action scaleY. + * Returns the scale action scaleY. * @returns {number} */ getScaleY: function () { @@ -368,8 +378,8 @@ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# * }, /** - * Gets the action of ActionFrame. - * @param duration + * Returns the action of ActionFrame. + * @param {number} duration * @returns {cc.ScaleTo} */ getAction: function (duration) { @@ -378,12 +388,15 @@ ccs.ActionScaleFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionScaleFrame# * }); /** - * Base class for ccs.ActionRotationFrame + * The Cocostudio's rotation action frame. * @class * @extends ccs.ActionFrame */ ccs.ActionRotationFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionRotationFrame# */{ _rotation: 0, + /** + * Construction of ccs.ActionRotationFrame + */ ctor: function () { ccs.ActionFrame.prototype.ctor.call(this); this._rotation = 0; @@ -399,7 +412,7 @@ ccs.ActionRotationFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionRotationFr }, /** - * Gets the rotate action rotation. + * Returns the rotate action rotation. * @returns {number} */ getRotation: function () { @@ -407,7 +420,7 @@ ccs.ActionRotationFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionRotationFr }, /** - * Gets the CCAction of ActionFrame. + * Returns the CCAction of ActionFrame. * @param {number} duration * @param {cc.ActionFrame} [srcFrame] * @returns {cc.RotateTo} @@ -427,12 +440,15 @@ ccs.ActionRotationFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionRotationFr }); /** - * Base class for ccs.ActionFadeFrame + * The Cocostudio's fade action frame. * @class * @extends ccs.ActionFrame */ ccs.ActionFadeFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionFadeFrame# */{ _opacity: 255, + /** + * Construction of ccs.ActionFadeFrame + */ ctor: function () { ccs.ActionFrame.prototype.ctor.call(this); this._opacity = 255; @@ -448,7 +464,7 @@ ccs.ActionFadeFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionFadeFrame# */{ }, /** - * Gets the fade action opacity. + * Returns the fade action opacity. * @returns {number} */ getOpacity: function () { @@ -456,8 +472,8 @@ ccs.ActionFadeFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionFadeFrame# */{ }, /** - * Gets the CCAction of ActionFrame. - * @param duration + * Returns a fade action with easing. + * @param {Number} duration * @returns {cc.FadeTo} */ getAction: function (duration) { @@ -466,12 +482,15 @@ ccs.ActionFadeFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionFadeFrame# */{ }); /** - * Base class for ccs.ActionTintFrame + * The Cocostudio's tint action frame. * @class * @extends ccs.ActionFrame */ ccs.ActionTintFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionTintFrame# */{ _color: null, + /** + * Construction of ccs.ActionTintFrame + */ ctor: function () { ccs.ActionFrame.prototype.ctor.call(this); this._color = cc.color(255, 255, 255, 255); @@ -490,7 +509,7 @@ ccs.ActionTintFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionTintFrame# */{ }, /** - * Gets the tint action color. + * Returns the color of tint action. * @returns {cc.Color} */ getColor: function () { @@ -499,7 +518,7 @@ ccs.ActionTintFrame = ccs.ActionFrame.extend(/** @lends ccs.ActionTintFrame# */{ }, /** - * Gets the action of ActionFrame. + * Returns a tint action with easing. * @param duration * @returns {cc.TintTo} */ diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index abfa374a7c..b990197870 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base singleton object for ccs.ActionManager + * Base singleton object for ccs.ActionManager. * @class * @name ccs.actionManager */ @@ -60,14 +60,12 @@ ccs.actionManager = /** @lends ccs.actionManager# */{ */ getActionByName: function (jsonName, actionName) { var actionList = this._actionDic[jsonName]; - if (!actionList) { + if (!actionList) return null; - } for (var i = 0; i < actionList.length; i++) { var locAction = actionList[i]; - if (actionName == locAction.getName()) { + if (actionName == locAction.getName()) return locAction; - } } return null; }, diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index 1aa197a416..5dfb2ee28a 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccs.ActionNode + * The Cocostudio's action node, it contains action target, action frame list and current frame index. it can be play action by calling playAciton. * @class * @extends ccs.Class */ @@ -33,24 +33,27 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ _destFrameIndex: 0, _unitTime: 0, _actionTag: 0, - _bject: null, + _object: null, _actionSpawn: null, _action: null, _frameArray: null, _frameArrayNum: 0, + + /** + * Construction of ccs.ActionNode + */ ctor: function () { this._currentFrameIndex = 0; this._destFrameIndex = 0; this._unitTime = 0.1; this._actionTag = 0; - this._bject = null; + this._object = null; this._actionSpawn = null; this._action = null; this._frameArray = []; this._frameArrayNum = ccs.FRAME_TYPE_MAX; - for (var i = 0; i < this._frameArrayNum; i++) { + for (var i = 0; i < this._frameArrayNum; i++) this._frameArray.push([]); - } }, /** @@ -60,10 +63,10 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ */ initWithDictionary: function (dic, root) { this.setActionTag(dic["ActionTag"]); - var actionframelist = dic["actionframelist"]; - for (var i = 0; i < actionframelist.length; i++) { - var actionFrameDic = actionframelist[i]; - var frameInex = actionFrameDic["frameid"]; + var actionFrameList = dic["actionframelist"]; + for (var i = 0; i < actionFrameList.length; i++) { + var actionFrameDic = actionFrameList[i]; + var frameIndex = actionFrameDic["frameid"]; var frameTweenType = actionFrameDic["tweenType"]; if(frameTweenType == null) frameTweenType = 0; @@ -80,7 +83,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var positionX = actionFrameDic["positionx"]; var positionY = actionFrameDic["positiony"]; actionFrame = new ccs.ActionMoveFrame(); - actionFrame.frameIndex = frameInex; + actionFrame.frameIndex = frameIndex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setPosition(positionX, positionY); @@ -92,7 +95,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var scaleX = actionFrameDic["scalex"]; var scaleY = actionFrameDic["scaley"]; actionFrame = new ccs.ActionScaleFrame(); - actionFrame.frameIndex = frameInex; + actionFrame.frameIndex = frameIndex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setScaleX(scaleX); @@ -104,7 +107,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ if (actionFrameDic["rotation"] !== undefined) { var rotation = actionFrameDic["rotation"]; actionFrame = new ccs.ActionRotationFrame(); - actionFrame.frameIndex = frameInex; + actionFrame.frameIndex = frameIndex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setRotation(rotation); @@ -115,7 +118,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ if (actionFrameDic["opacity"] !== undefined) { var opacity = actionFrameDic["opacity"]; actionFrame = new ccs.ActionFadeFrame(); - actionFrame.frameIndex = frameInex; + actionFrame.frameIndex = frameIndex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setOpacity(opacity); @@ -128,7 +131,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var colorG = actionFrameDic["colorg"]; var colorB = actionFrameDic["colorb"]; actionFrame = new ccs.ActionTintFrame(); - actionFrame.frameIndex = frameInex; + actionFrame.frameIndex = frameIndex; actionFrame.setEasingType(frameTweenType); actionFrame.setEasingParameter(frameTweenParameter); actionFrame.setColor(cc.color(colorR, colorG, colorB)); @@ -137,15 +140,14 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ } actionFrameDic = null; } - this.initActionNodeFromRoot(root); + this._initActionNodeFromRoot(root); }, - initActionNodeFromRoot: function (root) { + _initActionNodeFromRoot: function (root) { if (root instanceof ccui.Widget) { var widget = ccui.helper.seekActionWidgetByActionTag(root, this.getActionTag()); - if (widget) { + if (widget) this.setObject(widget); - } } }, @@ -155,11 +157,11 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ */ setUnitTime: function (time) { this._unitTime = time; - this.refreshActionProperty(); + this._refreshActionProperty(); }, /** - * Gets the time interval of frame. + * Returns the time interval of frame. * @returns {number} */ getUnitTime: function () { @@ -167,15 +169,15 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ }, /** - * Sets tag for ActionNode - * @param tag + * Sets tag to ccs.ActionNode + * @param {Number} tag */ setActionTag: function (tag) { this._actionTag = tag; }, /** - * Gets tag for ActionNode + * Returns the tag of ccs.ActionNode * @returns {number} */ getActionTag: function () { @@ -191,7 +193,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ }, /** - * Gets node which will run a action. + * Returns node which will run a action. * @returns {*} */ getObject: function () { @@ -199,82 +201,68 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ }, /** - * get actionNode + * Returns the target node of ccs.ActionNode * @returns {cc.Node} */ getActionNode: function () { - if (this._object instanceof cc.Node) { + if (this._object instanceof cc.Node) return this._object; - } - else if (this._object instanceof ccui.Widget) { - return this._object; - } return null; }, /** - * Insets a ActionFrame to ActionNode. + * Inserts an ActionFrame to ccs.ActionNode. * @param {number} index * @param {ccs.ActionFrame} frame */ insertFrame: function (index, frame) { - if (frame == null) { + if (frame == null) return; - } var frameType = frame.frameType; var array = this._frameArray[frameType]; array.splice(index, 0, frame); }, /** - * Pushs back a ActionFrame to ActionNode. + * Pushes back an ActionFrame to ccs.ActionNode. * @param {ccs.ActionFrame} frame */ addFrame: function (frame) { - if (!frame) { + if (!frame) return; - } var frameType = frame.frameType; var array = this._frameArray[frameType]; array.push(frame); }, /** - * Remove a ActionFrame from ActionNode. + * Removes an ActionFrame from ccs.ActionNode. * @param {ccs.ActionFrame} frame */ deleteFrame: function (frame) { - if (frame == null) { + if (frame == null) return; - } var frameType = frame.frameType; var array = this._frameArray[frameType]; cc.arrayRemoveObject(array, frame); }, /** - * Remove all ActionFrames from ActionNode. + * Removes all ActionFrames from ccs.ActionNode. */ clearAllFrame: function () { - for (var i = 0; i < this._frameArrayNum; i++) { - this._frameArray[i] = []; - } + for (var i = 0; i < this._frameArrayNum; i++) + this._frameArray[i].length = 0; }, - /** - * Refresh property of action - * @returns {null} - */ - refreshActionProperty: function () { - if (this._object == null) { + _refreshActionProperty: function () { + if (this._object == null) return null; - } var locSpawnArray = []; for (var i = 0; i < this._frameArrayNum; i++) { var locArray = this._frameArray[i]; - if (locArray.length <= 0) { + if (locArray.length <= 0) continue; - } var locSequenceArray = []; for (var j = 0; j < locArray.length; j++) { var locFrame = locArray[j]; @@ -282,16 +270,14 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var locSrcFrame = locArray[j - 1]; var locDuration = (locFrame.frameIndex - locSrcFrame.frameIndex) * this.getUnitTime(); var locAction = locFrame.getAction(locDuration); - if(locAction){ + if(locAction) locSequenceArray.push(locAction); - } } } if(locSequenceArray){ var locSequence = cc.sequence(locSequenceArray); - if (locSequence != null) { + if (locSequence != null) locSpawnArray.push(locSequence); - } } } @@ -301,33 +287,27 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ }, /** - * Play the action. + * Plays ccs.ActionNode's action. * @param {cc.CallFunc} fun */ playAction: function (fun) { - if (this._object == null || this._actionSpawn == null) { + if (this._object == null || this._actionSpawn == null) return; - } - if(fun){ - this._action = cc.sequence(this._actionSpawn,fun); - }else{ + if(fun) + this._action = cc.sequence(this._actionSpawn, fun); + else this._action = cc.sequence(this._actionSpawn); - } - this.runAction(); + this._runAction(); }, - /** - * Run action. - */ - runAction: function () { + _runAction: function () { var node = this.getActionNode(); - if (node != null && this._action != null) { + if (node != null && this._action != null) node.runAction(this._action); - } }, /** - * Stop action. + * Stops action. */ stopAction: function () { var node = this.getActionNode(); @@ -338,54 +318,49 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ }, /** - * Gets index of first ActionFrame. + * Returns index of first ActionFrame. * @returns {number} */ getFirstFrameIndex: function () { var locFrameindex = 99999; - var locIsFindFrame = false; - for (var i = 0; i < this._frameArrayNum; i++) { - var locArray = this._frameArray[i]; - if (locArray.length <= 0) { + var bFindFrame = false, locFrameArray = this._frameArray; + for (var i = 0, len = this._frameArrayNum; i < len; i++) { + var locArray = locFrameArray[i]; + if (locArray.length <= 0) continue; - } - locIsFindFrame = true; - var locFrame = locArray[0]; - var locFrameIndex = locFrame.frameIndex; + bFindFrame = true; + var locFrameIndex = locArray[0].frameIndex; locFrameindex = locFrameindex > locFrameIndex ? locFrameIndex : locFrameindex; } - if (!locIsFindFrame) { + if (!bFindFrame) locFrameindex = 0; - } return locFrameindex; }, /** - * Gets index of last ActionFrame. + * Returns the index of last ccs.ActionFrame. * @returns {number} */ getLastFrameIndex: function () { var locFrameindex = -1; - var locIsFindFrame = false; - for (var i = 0; i < this._frameArrayNum; i++) { - var locArray = this._frameArray[i]; - if (locArray.length <= 0) { + var locIsFindFrame = false ,locFrameArray = this._frameArray; + for (var i = 0, len = this._frameArrayNum; i < len; i++) { + var locArray = locFrameArray[i]; + if (locArray.length <= 0) continue; - } locIsFindFrame = true; var locFrame = locArray[locArray.length - 1]; var locFrameIndex = locFrame.frameIndex; locFrameindex = locFrameindex < locFrameIndex ? locFrameIndex : locFrameindex; } - if (!locIsFindFrame) { + if (!locIsFindFrame) locFrameindex = 0; - } return locFrameindex; }, /** * Updates action states to some time. - * @param time + * @param {Number} time * @returns {boolean} */ updateActionToTimeLine: function (time) { @@ -393,28 +368,25 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var locUnitTime = this.getUnitTime(); for (var i = 0; i < this._frameArrayNum; i++) { var locArray = this._frameArray[i]; - if (locArray == null) { + if (locArray == null) continue; - } for (var j = 0; j < locArray.length; j++) { var locFrame = locArray[j]; if (locFrame.frameIndex * locUnitTime == time) { - this.easingToFrame(1.0, 1.0, locFrame); + this._easingToFrame(1.0, 1.0, locFrame); locIsFindFrame = true; break; - } - else if (locFrame.frameIndex * locUnitTime > time) { + } else if (locFrame.frameIndex * locUnitTime > time) { if (j == 0) { - this.easingToFrame(1.0, 1.0, locFrame); + this._easingToFrame(1.0, 1.0, locFrame); locIsFindFrame = false; - } - else { + } else { var locSrcFrame = locArray[j - 1]; var locDuration = (locFrame.frameIndex - locSrcFrame.frameIndex) * locUnitTime; var locDelaytime = time - locSrcFrame.frameIndex * locUnitTime; - this.easingToFrame(locDuration, 1.0, locSrcFrame); - this.easingToFrame(locDuration, locDelaytime / locDuration, locFrame); + this._easingToFrame(locDuration, 1.0, locSrcFrame); + this._easingToFrame(locDuration, locDelaytime / locDuration, locFrame); locIsFindFrame = true; } break; @@ -424,26 +396,22 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ return locIsFindFrame; }, - /** - * Easing to frame - * @param {number} duration - * @param {number} delayTime - * @param {ccs.ActionFrame} destFrame - */ - easingToFrame: function (duration, delayTime, destFrame) { + _easingToFrame: function (duration, delayTime, destFrame) { var action = destFrame.getAction(duration); var node = this.getActionNode(); - if (action == null || node == null) { + if (action == null || node == null) return; - } action.startWithTarget(node); action.update(delayTime); }, + /** + * Returns if the action is done once time. + * @returns {Boolean} that if the action is done once time + */ isActionDoneOnce: function () { - if (this._action == null) { + if (this._action == null) return true; - } return this._action.isDone(); } }); \ No newline at end of file diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js index c47864194f..e33973093d 100644 --- a/extensions/cocostudio/action/CCActionObject.js +++ b/extensions/cocostudio/action/CCActionObject.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccs.ActionObject + * The Cocostudio's action object. * @class * @extends ccs.Class */ @@ -37,7 +37,12 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ _unitTime: 0, _currentTime: 0, _scheduler:null, + _callback: null, _fTotalTime: 0, + + /** + * Construction of ccs.ActionObject. + */ ctor: function () { this._actionNodeList = []; this._name = ""; @@ -47,12 +52,11 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ this._unitTime = 0.1; this._currentTime = 0; this._fTotalTime = 0; - this._scheduler = new cc.Scheduler(); - cc.director.getScheduler().scheduleUpdateForTarget(this._scheduler, 0, false); + this._scheduler = cc.director.getScheduler(); }, /** - * Sets name for object + * Sets name to ccs.ActionObject * @param {string} name */ setName: function (name) { @@ -60,7 +64,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ }, /** - * Gets name for object + * Returns name fo ccs.ActionObject * @returns {string} */ getName: function () { @@ -76,7 +80,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ }, /** - * Gets if the action will loop play. + * Returns if the action will loop play. * @returns {boolean} */ getLoop: function () { @@ -97,15 +101,15 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ }, /** - * Gets the time interval of frame. - * @returns {number} + * Returns the time interval of frame. + * @returns {number} the time interval of frame */ getUnitTime: function () { return this._unitTime; }, /** - * Gets the current time of frame. + * Returns the current time of frame. * @returns {number} */ getCurrentTime: function () { @@ -114,19 +118,23 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ /** * Sets the current time of frame. - * @param time + * @param {Number} time the current time of frame */ setCurrentTime: function (time) { this._currentTime = time; }, + /** + * Returns the total time of frame. + * @returns {number} the total time of frame + */ getTotalTime: function(){ return this._fTotalTime; }, /** - * Return if the action is playing. - * @returns {boolean} + * Returns if the action is playing. + * @returns {boolean} true if the action is playing, false the otherwise */ isPlaying: function () { return this._playing; @@ -163,9 +171,8 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ * @param {ccs.ActionNode} node */ addActionNode: function (node) { - if (!node) { + if (!node) return; - } this._actionNodeList.push(node); node.setUnitTime(this._unitTime); }, @@ -175,50 +182,49 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ * @param {ccs.ActionNode} node */ removeActionNode: function (node) { - if (node == null) { + if (node == null) return; - } cc.arrayRemoveObject(this._actionNodeList, node); }, /** - * Play the action. - * @param {cc.CallFunc} fun + * Plays the action. + * @param {cc.CallFunc} [fun] Action Call Back */ play: function (fun) { this.stop(); this.updateToFrameByTime(0); - var frameNum = this._actionNodeList.length; + var locActionNodeList = this._actionNodeList; + var frameNum = locActionNodeList.length; for (var i = 0; i < frameNum; i++) { - var locActionNode = this._actionNodeList[i]; - locActionNode.playAction(fun); + locActionNodeList[i].playAction(fun); } - if (this._loop) { + if (this._loop) this._scheduler.scheduleCallbackForTarget(this, this.simulationActionUpdate, 0, cc.REPEAT_FOREVER, 0, false); - } + if(fun !== undefined) + this._callback = fun; }, /** - * pause the action. + * Pauses the action. */ pause: function () { this._pause = true; }, /** - * stop the action. + * Stop the action. */ stop: function () { - for (var i = 0; i < this._actionNodeList.length; i++) { - var locActionNode = this._actionNodeList[i]; - locActionNode.stopAction(); - } + var locActionNodeList = this._actionNodeList; + for (var i = 0; i < locActionNodeList.length; i++) + locActionNodeList[i].stopAction(); this._scheduler.unscheduleCallbackForTarget(this, this.simulationActionUpdate); this._pause = false; }, /** - * Method of update frame . + * Updates frame by time. */ updateToFrameByTime: function (time) { this._currentTime = time; @@ -227,20 +233,27 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ locActionNode.updateActionToTimeLine(time); } }, + + /** + * scheduler update function + * @param {Number} dt delta time + */ simulationActionUpdate: function (dt) { - if (this._loop) { - var isEnd = true; - var actionNodeList = this._actionNodeList; - for (var i = 0; i < actionNodeList.length; i++) { - var actionNode = actionNodeList[i]; - if (actionNode.isActionDoneOnce() == false) { - isEnd = false; - break; - } + var isEnd = true, locNodeList = this._actionNodeList; + for(var i = 0, len = locNodeList.length; i < len; i++) { + if (!locNodeList[i].isActionDoneOnce()){ + isEnd = false; + break; } - if (isEnd) { + } + + if (isEnd){ + if (this._callback != null) + this._callback.execute(); + if (this._loop) this.play(); - } + else + this._scheduler.unschedule(this.simulationActionUpdate, this); } } }); \ No newline at end of file diff --git a/extensions/cocostudio/trigger/ObjectFactory.js b/extensions/cocostudio/trigger/ObjectFactory.js index 93ecec0568..c2bc197c82 100644 --- a/extensions/cocostudio/trigger/ObjectFactory.js +++ b/extensions/cocostudio/trigger/ObjectFactory.js @@ -23,60 +23,63 @@ THE SOFTWARE. ****************************************************************************/ -ccs.objectFactory = { +/** + * The singleton object that creating object factory, it creates object with class name, and manager the type mapping. + * @class + * @name ccs.objectFactory + */ +ccs.objectFactory = /** @lends ccs.objectFactory# */{ _typeMap: {}, - destroyInstance: function () { - this._instance = null; - }, - + /** + * Creates object with class name. if the the class name without register in type map, it returns null. + * @param {String} className + * @returns {*} + */ createObject: function (className) { var o = null; var t = this._typeMap[className]; if (t) { - if(cc.isFunction(t._fun)){ + if(cc.isFunction(t._fun)) o = new t._fun(); - }else{ + else o = t._fun; - } } return o; }, + /** + * Registers class type in type map. + * @param {ccs.TInfo} t + */ registerType: function (t) { this._typeMap[t._className] = t; }, + /** + * Creates ccui widget object. + * @param {String} name widget name + * @returns {ccui.Widget|null} + */ createGUI: function(name){ var object = null; - if(name === "Panel"){ + if(name === "Panel") name = "Layout"; - }else if(name === "TextArea"){ + else if(name === "TextArea") name = "Label"; - }else if(name === "TextButton"){ + else if(name === "TextButton") name = "Button"; - } var t = this._typeMap[name]; - if(t && t._fun){ + if(t && t._fun) object = t._fun; - } return object; }, - createWidgetReaderProtocol: function(name){ - var object = null; - - var t = this._typeMap[name]; - if(t && t._fun){ - object = t._fun; - } - - return object; + removeAll: function(){ + this._typeMap = {}; } - - }; ccs.TInfo = ccs.Class.extend({ diff --git a/extensions/cocostudio/trigger/TriggerBase.js b/extensions/cocostudio/trigger/TriggerBase.js index 36bf20b460..4c773e4476 100644 --- a/extensions/cocostudio/trigger/TriggerBase.js +++ b/extensions/cocostudio/trigger/TriggerBase.js @@ -23,19 +23,27 @@ THE SOFTWARE. ****************************************************************************/ +/** + * Sends event by trigger manager. + * @function + * @param {Number} event + */ ccs.sendEvent = function (event) { var triggerObjArr = ccs.triggerManager.get(event); - if (triggerObjArr == null) { + if (triggerObjArr == null) return; - } for (var i = 0; i < triggerObjArr.length; i++) { var triObj = triggerObjArr[i]; - if (triObj != null && triObj.detect()) { + if (triObj != null && triObj.detect()) triObj.done(); - } } }; +/** + * Registers a trigger class to objectFactory type map. + * @param {String} className + * @param {function} func + */ ccs.registerTriggerClass = function (className, func) { new ccs.TInfo(className, func); }; \ No newline at end of file From 75eab3ad427d4e0ae0244d1e723f721299502135 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Sep 2014 14:39:02 +0800 Subject: [PATCH 0596/1564] Closed #5898: Fixed a bug of cc.LabelBMFont that its content size is incorrect --- cocos2d/labels/CCLabelBMFont.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 7a18c5a03f..eae3b92c0c 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -596,7 +596,13 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ longestLine = nextFontPositionX; } - tmpSize.width = longestLine; + //If the last character processed has an xAdvance which is less that the width of the characters image, then we need + // to adjust the width of the string to take this into account, or the character will overlap the end of the bounding box + //TODO sync to -x + if(fontDef && fontDef.xAdvance < fontDef.rect.width) + tmpSize.width = longestLine - fontDef.xAdvance + fontDef.rect.width; + else + tmpSize.width = longestLine; tmpSize.height = totalHeight; self.setContentSize(cc.sizePixelsToPoints(tmpSize)); }, From 77ba1e08249389c99d7fd114561681cd5bdef060 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 4 Sep 2014 17:45:19 +0800 Subject: [PATCH 0597/1564] Issue #5902: LabelBMFont setColor is error --- CCBoot.js | 12 ++++++++++-- cocos2d/labels/CCLabelBMFont.js | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index e5d5c4191c..f22f1f7f92 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1361,8 +1361,16 @@ cc._initSys = function (config, CONFIG_KEY) { context.fillStyle = '#000'; context.fillRect(0,0,1,1); context.globalCompositeOperation = 'multiply'; - context.fillStyle = '#fff'; - context.fillRect(0,0,1,1); + + var canvas2 = document.createElement('canvas'); + canvas2.width = 1; + canvas2.height = 1; + var context2 = canvas2.getContext('2d'); + context2.fillStyle = '#fff'; + context2.fillRect(0,0,1,1); + + context.drawImage(canvas2, 0, 0, 1, 1); + return context.getImageData(0,0,1,1).data[0] === 0; }; diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 17874909d1..02ac988cf9 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -368,7 +368,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (cc._renderType == cc._RENDER_TYPE_WEBGL) { locChild.updateDisplayedColor(this._displayedColor); } else { - cc.Node.prototype.updateDisplayedColor.call(locChild, this._displayedColor); + if(cc.sys._supportCanvasNewBlendModes) + cc.Node.prototype.updateDisplayedColor.call(locChild, this._displayedColor); + else + locChild.updateDisplayedColor(this._displayedColor); locChild.setNodeDirty(); } } From 441dd129df0dab8636cec1e0f67834b56bf1008f Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 4 Sep 2014 20:38:42 +0800 Subject: [PATCH 0598/1564] no message --- external/pluginx/platform/facebook.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index b0995a25e8..18d068f2b1 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -38,12 +38,12 @@ plugin.extend('facebook', { userInfo: null, HttpMethod: { - 'Get': 'get', - 'Post': 'post', - 'Delete': 'delete' + 'GET': 'get', + 'POST': 'post', + 'DELETE': 'delete' }, - CodeSucceed: 0, + CODE_SUCCEED: 0, /** * Initialize Facebook sdk @@ -166,7 +166,7 @@ plugin.extend('facebook', { if(response['authResponse']){ // user is now logged out self.userInfo = {}; - typeof callback === 'function' && callback(0, {}); + typeof callback === 'function' && callback(0, {"isLoggedIn" : false}); }else{ typeof callback === 'function' && callback(response['error_code'] || 1, { error_message: response['error_message'] || "Unknown" @@ -229,7 +229,7 @@ plugin.extend('facebook', { //login - save user info self.userInfo = response['authResponse']; callback(0, { - accessToken: response['authResponse']['accessToken'], + accessToken: response['authResponse']['accessToken'] }); }else{ From 545d0adfffee5d031e869d2bd2addb59e56c29ed Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 4 Sep 2014 20:43:18 +0800 Subject: [PATCH 0599/1564] change Facebook function name --- external/pluginx/platform/facebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 18d068f2b1..fdeb924b29 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -91,7 +91,7 @@ plugin.extend('facebook', { * //example * plugin.FacebookAgent.login(); */ - login: function(callback, permissions){ + login: function(permissions,callback){ var self = this; permissions = permissions || []; if(!permissions.some(function(item){ From 21e285809e9e51d6bc47b5cedd5625b5795a75b9 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Sep 2014 22:15:11 +0800 Subject: [PATCH 0600/1564] Issue #5894: adds jsDocs to widget reader. --- cocos2d/audio/CCAudio.js | 2 +- cocos2d/core/event-manager/CCEventManager.js | 3 + extensions/cocostudio/reader/GUIReader.js | 494 +++++++++++++----- extensions/cocostudio/reader/SceneReader.js | 60 ++- .../widgetreader/ButtonReader/ButtonReader.js | 64 +-- .../CheckBoxReader/CheckBoxReader.js | 32 +- .../reader/widgetreader/WidgetReader.js | 30 +- .../widgetreader/WidgetReaderProtocol.js | 1 - extensions/cocostudio/trigger/TriggerMng.js | 133 ++++- extensions/cocostudio/trigger/TriggerObj.js | 102 +++- 10 files changed, 655 insertions(+), 266 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 156dca940d..ed77e3259a 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -426,7 +426,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ /** * Stop playing music. - * @param {Boolean} releaseData If release the music data or not.As default value is false. + * @param {Boolean} [releaseData] If release the music data or not.As default value is false. * @example * //example * cc.audioEngine.stopMusic(); diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 91df05a151..89957f64da 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -23,6 +23,9 @@ THE SOFTWARE. ****************************************************************************/ +/** + * @ignore + */ cc._EventListenerVector = cc.Class.extend({ _fixedListeners: null, _sceneGraphListeners: null, diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index d92c54e149..4ab2377069 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -70,8 +70,8 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ _mapParseSelector: {}, /** - * get version - * @param {String} str + * Gets the version number by version string. + * @param {String} str version string. * @returns {Number} */ getVersionInteger: function (str) { @@ -95,12 +95,7 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ strVersion = strVersion.substr(pos + 1, versionLength - 1); pos = strVersion.indexOf("."); - var s; - if (pos == -1) { - s = strVersion; - } else { - s = strVersion.substr(0, pos); - } + var s = (pos == -1) ? strVersion : strVersion.substr(0, pos); var it = parseInt(t); var ih = parseInt(h); @@ -111,7 +106,7 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ }, /** - * store file designSize + * stores the designSize of UI file. * @param {String} fileName * @param {cc.Size} size */ @@ -120,7 +115,7 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ }, /** - * + * Gets the design size by filename. * @param {String} fileName * @returns {cc.Size} */ @@ -129,7 +124,7 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ }, /** - * create uiWidget from a josn file that exported by cocostudio UI editor + * Creates uiWidget from a json file that exported by cocostudio UI editor * @param {String} fileName * @returns {ccui.Widget} */ @@ -164,48 +159,87 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ }, /** - * Clear data: Release all actions. + * Resets the states and clear the file design sizes. */ clear: function () { this._filePath = ""; this._olderVersion = false; this._fileDesignSizes = {}; }, + + /** + * Registers class type and callback. + * @param {String} classType + * @param {ccs.objectFactory} ins + * @param {Object} object + * @param {function} callback + */ registerTypeAndCallBack: function(classType, ins, object, callback){ var factoryCreate = ccs.objectFactory; var t = new ccs.TInfo(classType, ins); factoryCreate.registerType(t); - if(object){ + if(object) this._mapObject[classType] = object; - } - if(callback){ + if(callback) this._mapParseSelector[classType] = callback; - } }, + + /** + * Returns the file path + * @returns {string} + */ getFilePath: function(){ return this._filePath; }, + + /** + * Returns the parsed object map. + * @returns {Object} + */ getParseObjectMap: function(){ return this._mapObject; }, + + /** + * Returns the parsed callback map. + * @returns {*} + */ getParseCallBackMap: function(){ return this._mapParseSelector; } }; - -ccs.WidgetPropertiesReader = ccs.Class.extend({ +/** + * The base class of widget properties reader. It parse the foundation properties of widget. + * @class + * @extends ccs.Class + */ +ccs.WidgetPropertiesReader = ccs.Class.extend(/** @lends ccs.WidgetPropertiesReader# */{ _filePath: "", + + /** + * Create a widget object by json object. + * @param {Object} jsonDict + * @param {String} fullPath + * @param {String} fileName + */ createWidget: function (jsonDict, fullPath, fileName) { }, + + /** + * Parses the widget properties. + * @param {Object} data + */ widgetFromJsonDictionary: function (data) { }, - createGUI: function(classname){ - var name = this.getGUIClassName(classname); + + _createGUI: function(className){ + var name = this._getGUIClassName(className); return ccs.objectFactory.createObject(name); }, - getGUIClassName: function(name){ + + _getGUIClassName: function(name){ var convertedClassName = name; if (name == "Panel") convertedClassName = "Layout"; @@ -221,9 +255,10 @@ ccs.WidgetPropertiesReader = ccs.Class.extend({ convertedClassName = "TextBMFont"; return convertedClassName; }, - getWidgetReaderClassName: function(classname){ + + _getWidgetReaderClassName: function(className){ // create widget reader to parse properties of widget - var readerName = classname; + var readerName = className; if (readerName == "Panel") readerName = "Layout"; else if (readerName == "TextArea") @@ -239,9 +274,9 @@ ccs.WidgetPropertiesReader = ccs.Class.extend({ readerName += "Reader"; return readerName; }, - getWidgetReaderClassNameFromWidget: function(widget){ - var readerName; + _getWidgetReaderClassNameFromWidget: function(widget){ + var readerName = ""; // 1st., custom widget parse properties of parent widget with parent widget reader if (widget instanceof ccui.Button) readerName = "ButtonReader"; @@ -274,11 +309,25 @@ ccs.WidgetPropertiesReader = ccs.Class.extend({ return readerName; }, - createWidgetReaderProtocol: function(classname){ - return ccs.objectFactory.createObject(classname); + + _createWidgetReaderProtocol: function(className){ + return ccs.objectFactory.createObject(className); } }); -ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ + +/** + * The widget properties reader to parse Cocostudio exported file v0.3 -- v1.0 + * @class + * @extends ccs.WidgetPropertiesReader + */ +ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend(/** @lends ccs.WidgetPropertiesReader0250# */{ + /** + * Creates a widget by json object. + * @param {Object} jsonDict + * @param {string} fullPath + * @param {string} fileName + * @returns {*} + */ createWidget: function (jsonDict, fullPath, fileName) { this._filePath = fullPath == "" ? fullPath : cc.path.join(fullPath, "/"); var textures = jsonDict["textures"]; @@ -294,26 +343,27 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ cc.log("Read design size error!"); var winSize = cc.director.getWinSize(); ccs.uiReader.storeFileDesignSize(fileName, winSize); - } - else { + } else ccs.uiReader.storeFileDesignSize(fileName, cc.size(fileDesignWidth, fileDesignHeight)); - } var widgetTree = jsonDict["widgetTree"]; var widget = this.widgetFromJsonDictionary(widgetTree); var size = widget.getContentSize(); - if (size.width == 0 && size.height == 0) { + if (size.width == 0 && size.height == 0) widget.setSize(cc.size(fileDesignWidth, fileDesignHeight)); - } var actions = jsonDict["animation"]; - var rootWidget = widget; - ccs.actionManager.initWithDictionary(fileName, actions, rootWidget); - + ccs.actionManager.initWithDictionary(fileName, actions, widget); widgetTree = null; actions = null; return widget; }, + + /** + * Creates a widget by json dictionary. + * @param {Object} data + * @returns {ccui.Widget} + */ widgetFromJsonDictionary: function (data) { var widget = null; var classname = data["classname"]; @@ -321,55 +371,43 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ if (classname == "Button") { widget = ccui.Button.create(); this.setPropsForButtonFromJsonDictionary(widget, uiOptions); - } - else if (classname == "CheckBox") { + } else if (classname == "CheckBox") { widget = ccui.CheckBox.create(); this.setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); - } - else if (classname == "Label") { + } else if (classname == "Label") { widget = ccui.Text.create(); this.setPropsForLabelFromJsonDictionary(widget, uiOptions); - } - else if (classname == "LabelAtlas") { + } else if (classname == "LabelAtlas") { widget = ccui.TextAtlas.create(); this.setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); - } - else if (classname == "LoadingBar") { + } else if (classname == "LoadingBar") { widget = ccui.LoadingBar.create(); this.setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); } else if (classname == "ScrollView") { widget = ccui.ScrollView.create(); this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); - } - else if (classname == "TextArea") { + } else if (classname == "TextArea") { widget = ccui.Text.create(); this.setPropsForLabelFromJsonDictionary(widget, uiOptions); - } - else if (classname == "TextButton") { + } else if (classname == "TextButton") { widget = ccui.Button.create(); this.setPropsForButtonFromJsonDictionary(widget, uiOptions); - } - else if (classname == "TextField") { + } else if (classname == "TextField") { widget = ccui.TextField.create(); this.setPropsForTextFieldFromJsonDictionary(widget, uiOptions); - } - else if (classname == "ImageView") { + } else if (classname == "ImageView") { widget = ccui.ImageView.create(); this.setPropsForImageViewFromJsonDictionary(widget, uiOptions); - } - else if (classname == "Panel") { + } else if (classname == "Panel") { widget = ccui.Layout.create(); this.setPropsForLayoutFromJsonDictionary(widget, uiOptions); - } - else if (classname == "Slider") { + } else if (classname == "Slider") { widget = ccui.Slider.create(); this.setPropsForSliderFromJsonDictionary(widget, uiOptions); - } - else if (classname == "LabelBMFont") { + } else if (classname == "LabelBMFont") { widget = ccui.TextBMFont.create(); this.setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); - } - else if (classname == "DragPanel") { + } else if (classname == "DragPanel") { widget = ccui.ScrollView.create(); this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } @@ -377,21 +415,22 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ for (var i = 0; i < children.length; i++) { var subData = children[i]; var child = this.widgetFromJsonDictionary(subData); - if (child) { + if (child) widget.addChild(child); - } subData = null; } - uiOptions = null; return widget; }, - + /** + * Sets widget's properties from json dictionary. + * @param {ccui.Widget} widget + * @param {Object} options the json dictionary. + */ setPropsForWidgetFromJsonDictionary: function (widget, options) { - if (options["ignoreSize"] !== undefined) { + if (options["ignoreSize"] !== undefined) widget.ignoreContentAdaptWithSize(options["ignoreSize"]); - } var w = options["width"]; var h = options["height"]; @@ -422,9 +461,22 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var z = options["ZOrder"]; widget.setLocalZOrder(z); }, + + /** + * Sets all widgets' properties from json dictionary. + */ setPropsForAllWidgetFromJsonDictionary: function(){}, + + /** + * Sets all custom widget's properties from json dictionary. + */ setPropsForAllCustomWidgetFromJsonDictionary: function(){}, + /** + * Sets widget's color, anchor point, flipped properties from json object. + * @param {ccui.Widget} widget + * @param {Object} options json object. + */ setColorPropsForWidgetFromJsonDictionary: function (widget, options) { if (options["opacity"] !== undefined) { widget.setOpacity(options["opacity"]); @@ -442,6 +494,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ widget.setFlippedY(flipY); }, + /** + * Sets ccui.Button's properties from json object. + * @param {ccui.Button} widget + * @param {Object} options + */ setPropsForButtonFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var button = widget; @@ -462,26 +519,21 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var cw = options["capInsetsWidth"]; var ch = options["capInsetsHeight"]; - if (useMergedTexture) { + if (useMergedTexture) button.loadTextures(normalFileName, pressedFileName, disabledFileName, ccui.Widget.PLIST_TEXTURE); - } - else { + else button.loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } //button.setCapInsets(cc.rect(cx, cy, cw, ch)); if (options["scale9Width"] !== undefined && options["scale9Height"] !== undefined) { var swf = options["scale9Width"]; var shf = options["scale9Height"]; button.setSize(cc.size(swf, shf)); } - } - else { - if (useMergedTexture) { + } else { + if (useMergedTexture) button.loadTextures(normalFileName, pressedFileName, disabledFileName, ccui.Widget.PLIST_TEXTURE); - } - else { + else button.loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } } if (options["text"] !== undefined) { var text = options["text"] || ""; @@ -502,6 +554,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.CheckBox's properties from json object. + * @param {ccui.CheckBox} widget + * @param {Object} options + */ setPropsForCheckBoxFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var checkBox = widget; @@ -531,6 +588,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.ImageView's properties from json object. + * @param {ccui.ImageView} widget + * @param {Object} options + */ setPropsForImageViewFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); @@ -541,9 +603,8 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var tp_i = this._filePath; var imageFileName_tp = null; - if (imageFileName) { + if (imageFileName) imageFileName_tp = tp_i + imageFileName; - } var useMergedTexture = options["useMergedTexture"]; if (scale9Enable) { @@ -578,6 +639,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Text's properties from json object. + * @param {ccui.Text} widget + * @param {Object} options json dictionary + */ setPropsForLabelFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var label = widget; @@ -604,6 +670,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.TextAtlas' properties from json object. + * @param {ccui.TextAtlas} widget + * @param {Object} options + */ setPropsForLabelAtlasFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var labelAtlas = widget; @@ -615,12 +686,16 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ if (sv && cmf && iw && ih && scm && options["charMapFile"]) { var cmft = options["charMapFile"]; var cmf_tp = this._filePath + cmft; - labelAtlas.setProperty(options["stringValue"], cmf_tp, options["itemWidth"], options["itemHeight"], options["startCharMap"]); } this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Layout's properties from json object. + * @param {ccui.Layout} widget + * @param {Object} options + */ setPropsForLayoutFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var containerWidget = widget; @@ -673,7 +748,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, - + /** + * Sets ccui.ScrollView's properties from json dictionary. + * @param {ccui.ScrollView} widget + * @param {Object} options json dictionary. + */ setPropsForScrollViewFromJsonDictionary: function (widget, options) { this.setPropsForLayoutFromJsonDictionary(widget, options); var scrollView = widget; @@ -686,6 +765,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets the container's properties from json dictionary. + * @param {ccui.Widget} widget + * @param {Object} options json dictionary. + */ setPropsForContainerWidgetFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var containerWidget = widget; @@ -696,8 +780,12 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Slider's properties from json dictionary. + * @param {ccui.Slider} widget + * @param {Object} options json dictionary. + */ setPropsForSliderFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); var slider = widget; @@ -712,19 +800,16 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; if (useMergedTexture) { slider.loadBarTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } - else { + } else { slider.loadBarTexture(imageFileName_tp); } slider.setSize(cc.size(barLength, slider.getContentSize().height)); - } - else { + } else { var imageFileName = options["barFileName"]; var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; if (useMergedTexture) { slider.loadBarTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } - else { + } else { slider.loadBarTexture(imageFileName_tp); } } @@ -739,8 +824,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var disabledFileName_tp = disabledFileName ? this._filePath + disabledFileName : null; if (useMergedTexture) { slider.loadSlidBallTextures(normalFileName, pressedFileName, disabledFileName, ccui.Widget.PLIST_TEXTURE); - } - else { + } else { slider.loadSlidBallTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); } slider.setPercent(options["percent"]); @@ -749,13 +833,17 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; if (useMergedTexture) { slider.loadProgressBarTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } - else { + } else { slider.loadProgressBarTexture(imageFileName_tp); } this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.TextField's properties from json object. + * @param {ccui.TextField} widget + * @param {Object} options + */ setPropsForTextAreaFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var textArea = widget; @@ -781,6 +869,11 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Button's text properties from json dictionary. + * @param {ccui.Button} widget + * @param {Object} options + */ setPropsForTextButtonFromJsonDictionary: function (widget, options) { this.setPropsForButtonFromJsonDictionary(widget, options); @@ -790,15 +883,18 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var cgi = options["textColorG"] !== undefined ? options["textColorG"] : 255; var cbi = options["textColorB"] !== undefined ? options["textColorB"] : 255; textButton.setTitleColor(cc.color(cri, cgi, cbi)); - if (options["fontSize"] !== undefined) { + if (options["fontSize"] !== undefined) textButton.setTitleFontSize(options["fontSize"]); - } - if (options["fontName"] !== undefined) { + if (options["fontName"] !== undefined) textButton.setTitleFontName(options["fontName"]); - } this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.TextField's properties from json dictionary. + * @param {ccui.TextField} widget + * @param {Object} options json dictionary + */ setPropsForTextFieldFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var textField = widget; @@ -836,8 +932,12 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.LoadingBar's properties from json dictionary. + * @param {ccui.LoadingBar} widget + * @param {Object} options json dictionary + */ setPropsForLoadingBarFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); var loadingBar = widget; var useMergedTexture = options["useMergedTexture"]; @@ -845,8 +945,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; if (useMergedTexture) { loadingBar.loadTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } - else { + } else { loadingBar.loadTexture(imageFileName_tp); } loadingBar.setDirection(options["direction"]); @@ -854,14 +953,29 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.ListView's properties from json dictionary. + * @param {ccui.ListView} widget + * @param {Object} options json dictionary + */ setPropsForListViewFromJsonDictionary: function (widget, options) { this.setPropsForLayoutFromJsonDictionary(widget, options); }, + /** + * Sets ccui.PageView's properties from json dictionary. + * @param {ccui.PageView} widget + * @param {Object} options json dictionary + */ setPropsForPageViewFromJsonDictionary: function (widget, options) { this.setPropsForLayoutFromJsonDictionary(widget, options); }, + /** + * Sets ccui.TextBMFont's properties from json dictionary. + * @param {ccui.TextBMFont} widget + * @param {Object} options json dictionary + */ setPropsForLabelBMFontFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var labelBMFont = widget; @@ -874,7 +988,19 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({ } }); -ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ +/** + * The widget properties reader to parse Cocostudio exported file v1.0 higher. + * @class + * @extends ccs.WidgetPropertiesReader + */ +ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends ccs.WidgetPropertiesReader0300# */{ + /** + * Creates widget by json object. + * @param {Object} jsonDict json dictionary + * @param {String} fullPath + * @param {String} fileName + * @returns {ccui.Widget} + */ createWidget: function (jsonDict, fullPath, fileName) { this._filePath = fullPath == "" ? fullPath : cc.path.join(fullPath, "/"); var textures = jsonDict["textures"]; @@ -906,13 +1032,26 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ actions = null; return widget; }, + + /** + * Sets widget's foundation properties from json dictionary. + * @param {Object} reader widget reader + * @param {ccui.Widget} widget + * @param {Object} options json dictionary + */ setPropsForAllWidgetFromJsonDictionary: function(reader, widget, options){ if(reader && reader.setPropsFromJsonDictionary) reader.setPropsFromJsonDictionary(widget, options); }, + + /** + * Sets widget's custom properties from json dictionary + * @param {String} classType class type + * @param {ccui.Widget} widget + * @param {Object} customOptions + */ setPropsForAllCustomWidgetFromJsonDictionary: function(classType, widget, customOptions){ var guiReader = ccs.uiReader; - var object_map = guiReader.getParseObjectMap(); var object = object_map[classType]; @@ -920,29 +1059,27 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var selector = selector_map[classType]; if (object && selector) - { - selector(classType, widget, customOptions); - } - + selector.call(object, classType, widget, customOptions); }, - widgetFromJsonDictionary: function (data) { + /** + * Creates a widget from json dictionary. + * @param {Object} data json data + * @returns {ccui.Widget} + */ + widgetFromJsonDictionary: function (data) { var classname = data["classname"]; var uiOptions = data["options"]; - var widget = this.createGUI(classname); - - var readerName = this.getWidgetReaderClassName(classname); + var widget = this._createGUI(classname); - var reader = this.createWidgetReaderProtocol(readerName); + var readerName = this._getWidgetReaderClassName(classname); + var reader = this._createWidgetReaderProtocol(readerName); - if (reader) - { + if (reader){ // widget parse with widget reader this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); - } - else - { - readerName = this.getWidgetReaderClassNameFromWidget(widget); + } else { + readerName = this._getWidgetReaderClassNameFromWidget(widget); reader = ccs.objectFactory.createObject(readerName); @@ -964,21 +1101,13 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var child = this.widgetFromJsonDictionary(childrenItem[i]); if(child){ if(widget instanceof ccui.PageView) - { widget.addPage(child); - } - else - { - if(widget instanceof ccui.ListView) - { + else { + if(widget instanceof ccui.ListView){ widget.pushBackCustomItem(child); - } - else - { - if(!(widget instanceof ccui.Layout)) - { - if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) - { + } else { + if(!(widget instanceof ccui.Layout)) { + if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { var position = child.getPositionPercent(); var anchor = widget.getAnchorPoint(); child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); @@ -994,15 +1123,19 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ return widget; }, - + /** + * Sets widget's foundation properties from json dictionary. + * @param {ccui.Widget} widget + * @param {Object} options json dictionary + */ setPropsForWidgetFromJsonDictionary: function (widget, options) { var name = options["name"]; var widgetName = name ? name : "default"; widget.setName(widgetName); - if (options["ignoreSize"] !== undefined) { + if (options["ignoreSize"] !== undefined) widget.ignoreContentAdaptWithSize(options["ignoreSize"]); - } + widget.setSizeType(options["sizeType"]); widget.setPositionType(options["positionType"]); @@ -1021,18 +1154,14 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var y = options["y"]; widget.setPosition(cc.p(x, y)); - if (options["scaleX"] !== undefined) { + if (options["scaleX"] !== undefined) widget.setScaleX(options["scaleX"]); - } - if (options["scaleY"] !== undefined) { + if (options["scaleY"] !== undefined) widget.setScaleY(options["scaleY"]); - } - if (options["rotation"] !== undefined) { + if (options["rotation"] !== undefined) widget.setRotation(options["rotation"]); - } - if (options["visible"] !== undefined) { + if (options["visible"] !== undefined) widget.setVisible(options["visible"]); - } widget.setLocalZOrder(options["ZOrder"]); var layoutParameterDic = options["layoutParameter"]; @@ -1067,6 +1196,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ } }, + /** + * Sets widget's color, anchor point, flipped properties from json dictionary. + * @param {ccui.Widget} widget + * @param {Object} options json dictionary + */ setColorPropsForWidgetFromJsonDictionary: function (widget, options) { if (options["opacity"] !== undefined) { widget.setOpacity(options["opacity"]); @@ -1084,6 +1218,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ widget.setFlippedY(flipY); }, + /** + * Sets ccui.Button's properties from json dictionary. + * @param {ccui.Button} widget + * @param {Object} options json dictionary + */ setPropsForButtonFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var button = widget; @@ -1170,6 +1309,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.CheckBox's properties from json dictionary. + * @param {ccui.CheckBox} widget + * @param {Object} options json dictionary + */ setPropsForCheckBoxFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var checkBox = widget; @@ -1263,6 +1407,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.ImageView's properties from json dictionary. + * @param {ccui.ImageView} widget + * @param {Object} options json dictionary + */ setPropsForImageViewFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); @@ -1310,6 +1459,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Text's properties from json dictionary. + * @param {ccui.Text} widget + * @param {Object} options json dictionary + */ setPropsForLabelFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var label = widget; @@ -1337,6 +1491,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.TextAtlas's properties from json dictionary. + * @param {ccui.TextAtlas} widget + * @param {Object} options json dictionary + */ setPropsForLabelAtlasFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var labelAtlas = widget; @@ -1366,6 +1525,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Layout's properties from json dictionary. + * @param {ccui.Layout} widget + * @param {Object} options json dictionary + */ setPropsForLayoutFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var panel = widget; @@ -1427,7 +1591,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, - + /** + * Sets ccui.ScrollView's properties from json dictionary. + * @param {ccui.ScrollView} widget + * @param {Object} options json dictionary + */ setPropsForScrollViewFromJsonDictionary: function (widget, options) { this.setPropsForLayoutFromJsonDictionary(widget, options); var scrollView = widget; @@ -1440,6 +1608,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Slider's properties from json dictionary. + * @param {ccui.Slider} widget + * @param {Object} options json dictionary + */ setPropsForSliderFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var slider = widget; @@ -1560,6 +1733,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ slider.setPercent(options["percent"]); }, + /** + * Sets ccui.TextField's properties from json dictionary. + * @param {ccui.TextField} widget + * @param {Object} options json dictionary + */ setPropsForTextAreaFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var textArea = widget; @@ -1582,6 +1760,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.Button's text properties from json dictionary. + * @param {ccui.Button} widget + * @param {Object} options json dictionary + */ setPropsForTextButtonFromJsonDictionary: function (widget, options) { this.setPropsForButtonFromJsonDictionary(widget, options); @@ -1591,15 +1774,18 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ var cgi = options["textColorG"] !== undefined ? options["textColorG"] : 255; var cbi = options["textColorB"] !== undefined ? options["textColorB"] : 255; textButton.setTitleColor(cc.color(cri, cgi, cbi)); - if (options["fontSize"] !== undefined) { + if (options["fontSize"] !== undefined) textButton.setTitleFontSize(options["fontSize"]); - } - if (options["fontName"] !== undefined) { + if (options["fontName"] !== undefined) textButton.setTitleFontName(options["fontName"]); - } this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.TextField's text properties from json dictionary. + * @param {ccui.TextField} widget + * @param {Object} options json dictionary + */ setPropsForTextFieldFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var textField = widget; @@ -1637,6 +1823,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, + /** + * Sets ccui.LoadingBar's properties from json dictionary. + * @param {ccui.LoadingBar} widget + * @param {Object} options json dictionary + */ setPropsForLoadingBarFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var loadingBar = widget; @@ -1684,6 +1875,11 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ }, + /** + * Sets ccui.ListView's properties from json dictionary. + * @param {ccui.ListView} widget + * @param {Object} options json dictionary + */ setPropsForListViewFromJsonDictionary: function (widget, options) { this.setPropsForLayoutFromJsonDictionary(widget, options); var innerWidth = options["innerWidth"] || 0; @@ -1694,10 +1890,20 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({ widget.setItemsMargin(options["itemMargin"] || 0); }, + /** + * Sets ccui.PageView's properties from json dictionary. + * @param {ccui.PageView} widget + * @param {Object} options json dictionary + */ setPropsForPageViewFromJsonDictionary: function (widget, options) { this.setPropsForLayoutFromJsonDictionary(widget, options); }, + /** + * Sets ccui.TextBMFont's properties from json dictionary. + * @param {ccui.TextBMFont} widget + * @param {Object} options json dictionary + */ setPropsForLabelBMFontFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 40f1e00ac9..06dd286342 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -35,7 +35,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ _node: null, /** - * create node with json file that exported by CocoStudio scene editor + * Creates a node with json file that exported by CocoStudio scene editor * @param pszFileName * @returns {cc.Node} */ @@ -44,16 +44,16 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ do{ this._baseBath = cc.path.dirname(pszFileName); var jsonDict = cc.loader.getRes(pszFileName); - if (!jsonDict) throw "Please load the resource first : " + pszFileName; + if (!jsonDict) + throw "Please load the resource first : " + pszFileName; this._node = this.createObject(jsonDict, null); ccs.triggerManager.parse(jsonDict["Triggers"]||[]); }while(0); - return this._node; }, /** - * create object from data + * create UI object from data * @param {Object} inputFiles * @param {cc.Node} parenet * @returns {cc.Node} @@ -78,7 +78,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ if (!subDict) { break; } - var className = subDict["classname"]; + className = subDict["classname"]; var comName = subDict["name"]; var fileData = subDict["fileData"]; @@ -249,55 +249,51 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ var gameobjects = inputFiles["gameobjects"]; for (var i = 0; i < gameobjects.length; i++) { var subDict = gameobjects[i]; - if (!subDict) { + if (!subDict) break; - } this.createObject(subDict, gb); subDict = null; } - return gb; } return null; }, - - nodeByTag: function (parent, tag) { - if (parent == null) { + _nodeByTag: function (parent, tag) { + if (parent == null) return null; - } var retNode = null; var children = parent.getChildren(); - for (var i = 0; i < children.length; i++) { var child = children[i]; if (child && child.getTag() == tag) { retNode = child; break; - } - else { - retNode = this.nodeByTag(child, tag); - if (retNode) { + } else { + retNode = this._nodeByTag(child, tag); + if (retNode) break; - } } } return retNode; }, + /** + * Get a node by tag. + * @param {Number} tag + * @returns {cc.Node|null} + */ getNodeByTag: function (tag) { - if (this._node == null) { + if (this._node == null) return null; - } - if (this._node.getTag() == tag) { + if (this._node.getTag() == tag) return this._node; - } - return this.nodeByTag(this._node, tag); + return this._nodeByTag(this._node, tag); }, /** - * set property + * Sets properties from json dictionary. * @param {cc.Node} node * @param {Object} dict */ @@ -323,22 +319,32 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ var fRotationZ = (cc.isUndefined(dict["rotation"]))?0:dict["rotation"]; node.setRotation(fRotationZ); }, + + /** + * Sets the listener to reader. + * @param {function} selector + * @param {Object} listener the target object. + */ setTarget : function(selector,listener){ this._listener = listener; this._selector = selector; }, + _callSelector:function(obj,subDict){ - if(this._selector){ + if(this._selector) this._selector.call(this._listener,obj,subDict); - } }, + /** + * Returns the version of ccs.SceneReader. + * @returns {string} + */ version: function () { return "1.2.0.0"; }, /** - * Clear data + * Clear all triggers and stops all sounds. */ clear: function () { ccs.triggerManager.removeAll(); diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index b9d9f7d0fa..7cbfcc7bc8 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -23,93 +23,85 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ButtonReader = { - +/** + * The ccui.Button's properties reader for GUIReader. + * @class + * @name ccs.ButtonReader + **/ +ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ + /** + * Gets the ccs.ButtonReader. + * @deprecated since v3.0, please use ccs.ButtonReader directly. + * @returns {ccs.ButtonReader} + */ getInstance: function(){ return ccs.ButtonReader; }, + /** + * Sets ccui.Button's properties from json dictionary. + * @param {ccui.Button} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - var jsonPath = ccs.uiReader.getFilePath(); var button = widget; var scale9Enable = options["scale9Enable"]; button.setScale9Enabled(scale9Enable); - var normalDic = options["normalData"]; - var normalType = normalDic["resourceType"]; - switch (normalType) - { + var normalDic = options["normalData"], normalType = normalDic["resourceType"]; + switch (normalType) { case 0: - { var tp_n = jsonPath; var normalFileName = normalDic["path"]; var normalFileName_tp = (normalFileName && normalFileName !== "") ? - tp_n + normalFileName : - null; + tp_n + normalFileName : null; button.loadTextureNormal(normalFileName_tp); break; - } case 1: - { var normalFileName = normalDic["path"]; button.loadTextureNormal(normalFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; - } default: break; } var pressedDic = options["pressedData"]; var pressedType = pressedDic["resourceType"]; - switch (pressedType) - { + switch (pressedType) { case 0: - { var tp_p = jsonPath; var pressedFileName = pressedDic["path"]; var pressedFileName_tp = (pressedFileName && pressedFileName !== "") ? - tp_p + pressedFileName : - null;; + tp_p + pressedFileName : null; button.loadTexturePressed(pressedFileName_tp); break; - } case 1: - { var pressedFileName = pressedDic["path"]; button.loadTexturePressed(pressedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; - } default: break; } var disabledDic = options["disabledData"]; var disabledType = disabledDic["resourceType"]; - switch (disabledType) - { + switch (disabledType){ case 0: - { var tp_d = jsonPath; var disabledFileName = disabledDic["path"]; var disabledFileName_tp = (disabledFileName && disabledFileName !== "") ? - tp_d + disabledFileName : - null; + tp_d + disabledFileName : null; button.loadTextureDisabled(disabledFileName_tp); break; - } case 1: - { var disabledFileName = disabledDic["path"]; button.loadTextureDisabled(disabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; - } default: break; } - if (scale9Enable) - { + if (scale9Enable) { var cx = options["capInsetsX"]; var cy = options["capInsetsY"]; var cw = options["capInsetsWidth"]; @@ -119,15 +111,11 @@ ccs.ButtonReader = { var sw = options["scale9Width"]; var sh = options["scale9Height"]; if (sw != null && sh != null) - { button.setSize(cc.size(sw, sh)); - } } var text = options["text"]; if (text != null) - { button.setTitleText(text); - } var cr = options["textColorR"]; var cg = options["textColorG"]; @@ -139,14 +127,10 @@ ccs.ButtonReader = { button.setTitleColor(cc.color(cri,cgi,cbi)); var fs = options["fontSize"]; if (fs != null) - { button.setTitleFontSize(options["fontSize"]); - } var fn = options["fontName"]; if (fn) - { button.setTitleFontName(options["fontName"]); - } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index 4f163974ee..da88420db1 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -23,14 +23,27 @@ THE SOFTWARE. ****************************************************************************/ -ccs.CheckBoxReader = { - +/** + * The ccui.CheckBox's properties reader for GUIReader. + * @class + * @name ccs.CheckBoxReader + **/ +ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ + /** + * Gets the ccs.CheckBoxReader. + * @deprecated since v3.0, please use ccs.CheckBoxReader directly. + * @returns {ccs.CheckBoxReader} + */ getInstance: function(){ return ccs.CheckBoxReader; }, + /** + * Sets ccui.CheckBox's properties from json dictionary. + * @param {ccui.CheckBox} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var checkBox = widget; @@ -38,13 +51,13 @@ ccs.CheckBoxReader = { //load background image var backGroundDic = options["backGroundBoxData"]; var backGroundType = backGroundDic["resourceType"]; - var backGroundTexturePath = ccs.WidgetReader.getResourcePath(backGroundDic, "path", backGroundType); + var backGroundTexturePath = ccs.WidgetReader._getResourcePath(backGroundDic, "path", backGroundType); checkBox.loadTextureBackGround(backGroundTexturePath, backGroundType); //load background selected image var backGroundSelectedDic = options["backGroundBoxSelectedData"]; var backGroundSelectedType = backGroundSelectedDic["resourceType"]; - var backGroundSelectedTexturePath = ccs.WidgetReader.getResourcePath(backGroundSelectedDic, "path", backGroundSelectedType); + var backGroundSelectedTexturePath = ccs.WidgetReader._getResourcePath(backGroundSelectedDic, "path", backGroundSelectedType); if(!backGroundSelectedTexturePath){ backGroundSelectedType = backGroundType; backGroundSelectedTexturePath = backGroundTexturePath; @@ -54,13 +67,13 @@ ccs.CheckBoxReader = { //load frontCross image var frontCrossDic = options["frontCrossData"]; var frontCrossType = frontCrossDic["resourceType"]; - var frontCrossFileName = ccs.WidgetReader.getResourcePath(frontCrossDic, "path", frontCrossType); + var frontCrossFileName = ccs.WidgetReader._getResourcePath(frontCrossDic, "path", frontCrossType); checkBox.loadTextureFrontCross(frontCrossFileName, frontCrossType); //load backGroundBoxDisabledData var backGroundDisabledDic = options["backGroundBoxDisabledData"]; var backGroundDisabledType = backGroundDisabledDic["resourceType"]; - var backGroundDisabledFileName = ccs.WidgetReader.getResourcePath(backGroundDisabledDic, "path", backGroundDisabledType); + var backGroundDisabledFileName = ccs.WidgetReader._getResourcePath(backGroundDisabledDic, "path", backGroundDisabledType); if(!backGroundDisabledFileName){ backGroundDisabledType = frontCrossType; backGroundDisabledFileName = frontCrossFileName; @@ -70,12 +83,11 @@ ccs.CheckBoxReader = { ///load frontCrossDisabledData var frontCrossDisabledDic = options["frontCrossDisabledData"]; var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; - var frontCrossDisabledFileName = ccs.WidgetReader.getResourcePath(frontCrossDisabledDic, "path", frontCrossDisabledType); + var frontCrossDisabledFileName = ccs.WidgetReader._getResourcePath(frontCrossDisabledDic, "path", frontCrossDisabledType); checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); - if (options["selectedState"]){ + if (options["selectedState"]) checkBox.setSelectedState(options["selectedState"]); - } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index dc922e97ed..94aa8fbbd5 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -23,11 +23,26 @@ THE SOFTWARE. ****************************************************************************/ -ccs.WidgetReader = { +/** + * The ccui.Widget's properties reader for GUIReader. + * @class + * @name ccs.WidgetReader + **/ +ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ + /** + * Gets the ccs.WidgetReader. + * @deprecated since v3.0, please use ccs.WidgetReader directly. + * @returns {ccs.WidgetReader} + */ getInstance: function(){ return ccs.WidgetReader; }, + /** + * Sets widget's properties from json dictionary + * @param {ccui.Widget} widget + * @param {object} options + */ setPropsFromJsonDictionary: function(widget, options){ var ignoreSizeExsit = options["ignoreSize"]; if(ignoreSizeExsit != null) @@ -114,6 +129,12 @@ ccs.WidgetReader = { } } }, + + /** + * Sets widget's color, anchor point and flipped properties from json dictionary + * @param {ccui.Widget} widget + * @param {object} options + */ setColorPropsFromJsonDictionary: function(widget, options){ var op = options["opacity"]; if(op != null) @@ -123,11 +144,12 @@ ccs.WidgetReader = { var colorB = options["colorB"]; widget.setColor(cc.color((colorR == null) ? 255 : colorR, (colorG == null) ? 255 : colorG, (colorB == null) ? 255 : colorB)); - ccs.WidgetReader.setAnchorPointForWidget(widget, options); + ccs.WidgetReader._setAnchorPointForWidget(widget, options); widget.setFlippedX(options["flipX"]); widget.setFlippedY(options["flipY"]); }, - setAnchorPointForWidget: function(widget, options){ + + _setAnchorPointForWidget: function(widget, options){ var isAnchorPointXExists = options["anchorPointX"]; var anchorPointXInFile; if (isAnchorPointXExists != null) @@ -146,7 +168,7 @@ ccs.WidgetReader = { widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); }, - getResourcePath: function(dict, key, texType){ + _getResourcePath: function(dict, key, texType){ var imageFileName = dict[key]; var imageFileName_tp; if (null != imageFileName) { diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js index 833ef41ecb..5c26a77bc6 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js @@ -24,7 +24,6 @@ ****************************************************************************/ ccs.WidgetReaderProtocol = ccs.Class.extend({ - setPropsFromJsonDictionary: function(widget, options){ } diff --git a/extensions/cocostudio/trigger/TriggerMng.js b/extensions/cocostudio/trigger/TriggerMng.js index 3b2dd9c298..0603491486 100644 --- a/extensions/cocostudio/trigger/TriggerMng.js +++ b/extensions/cocostudio/trigger/TriggerMng.js @@ -23,16 +23,20 @@ THE SOFTWARE. ****************************************************************************/ -ccs.triggerManager = { +/** + * The trigger manager of Cocostudio + * @class + * @name ccs.triggerManager + */ +ccs.triggerManager = /** @lends ccs.triggerManager# */{ _eventTriggers: {}, _triggerObjs: {}, _movementDispatches: [], - destroyInstance: function () { - this.removeAll(); - this._instance = null; - }, - + /** + * Parses the triggers. + * @param {Array} triggers + */ parse: function (triggers) { for (var i = 0; i < triggers.length; ++i) { var subDict = triggers[i]; @@ -47,25 +51,42 @@ ccs.triggerManager = { } }, + /** + * Returns the event triggers by event id. + * @param {Number} event + * @returns {Array} + */ get: function (event) { return this._eventTriggers[event]; }, + /** + * Returns the trigger object by id + * @param {Number} id + * @returns {ccs.TriggerObj} + */ getTriggerObj: function (id) { return this._triggerObjs[id]; }, + /** + * Adds event and trigger object to trigger manager. + * @param event + * @param triggerObj + */ add: function (event, triggerObj) { var eventTriggers = this._eventTriggers[event]; - if (!eventTriggers) { + if (!eventTriggers) eventTriggers = []; - } if (eventTriggers.indexOf(triggerObj) == -1) { eventTriggers.push(triggerObj); this._eventTriggers[event] = eventTriggers; } }, + /** + * Removes all event triggers from manager. + */ removeAll: function () { for (var key in this._eventTriggers) { var triObjArr = this._eventTriggers[key]; @@ -77,20 +98,25 @@ ccs.triggerManager = { this._eventTriggers = {}; }, + /** + * Removes event object from trigger manager. + * @param {*} event + * @param {*} Obj + * @returns {Boolean} + */ remove: function (event, Obj) { - if (Obj) { + if (Obj) return this._removeObj(event, Obj); - } + var bRet = false; - do - { + do { var triObjects = this._eventTriggers[event]; - if (!triObjects) break; + if (!triObjects) + break; for (var i = 0; i < triObjects.length; i++) { var triObject = triObjects[i]; - if (triObject) { + if (triObject) triObject.removeAll(); - } } delete this._eventTriggers[event]; bRet = true; @@ -117,11 +143,15 @@ ccs.triggerManager = { return bRet; }, + /** + * Removes trigger object from manager + * @param {Number} id + * @returns {boolean} + */ removeTriggerObj: function (id) { var obj = this.getTriggerObj(id); - if (!obj) { + if (!obj) return false; - } var events = obj.getEvents(); for (var i = 0; i < events.length; i++) { var event = events[i]; @@ -129,14 +159,24 @@ ccs.triggerManager = { } return true; }, + + /** + * Returns the event triggers whether is empty. + * @returns {boolean} + */ isEmpty: function () { return !this._eventTriggers || this._eventTriggers.length <= 0; }, + /** + * Adds an armature movement callback to manager. + * @param {ccs.Armature} armature + * @param {function} callFunc + * @param {Object} target + */ addArmatureMovementCallBack: function (armature, callFunc, target) { - if (armature == null || target == null || callFunc == null) { + if (armature == null || target == null || callFunc == null) return; - } var locAmd, hasADD = false; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; @@ -153,23 +193,30 @@ ccs.triggerManager = { } }, + /** + * Removes armature movement callback from manager. + * @param {ccs.Armature} armature + * @param {Object} target + * @param {function} callFunc + */ removeArmatureMovementCallBack: function (armature, target, callFunc) { - if (armature == null || target == null || callFunc == null) { + if (armature == null || target == null || callFunc == null) return; - } var locAmd; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; - if (locAmd && locAmd[0] == armature) { + if (locAmd && locAmd[0] == armature) locAmd.removeAnimationEventCallBack(callFunc, target); - } } }, + /** + * Removes an armature's all movement callbacks. + * @param {ccs.Armature} armature + */ removeArmatureAllMovementCallBack: function (armature) { - if (armature == null) { + if (armature == null) return; - } var locAmd; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; @@ -180,21 +227,43 @@ ccs.triggerManager = { } }, + /** + * Removes all armature movement callbacks from ccs.triggerManager. + */ removeAllArmatureMovementCallBack: function () { - this._movementDispatches = []; + this._movementDispatches.length = 0; }, + /** + * Returns the version of ccs.triggerManager + * @returns {string} + */ version: function () { return "1.2.0.0"; } }; -ccs.ArmatureMovementDispatcher = ccs.Class.extend({ +/** + * The armature movement dispatcher for trigger manager. + * @class + * @extends ccs.Class + */ +ccs.ArmatureMovementDispatcher = ccs.Class.extend(/** @lends ccs.ArmatureMovementDispatcher# */{ _mapEventAnimation: null, + + /** + * Constructor of ArmatureMovementDispatcher. + */ ctor: function () { this._mapEventAnimation = []; }, + /** + * Calls armature movement events. + * @param {ccs.Armature} armature + * @param {Number} movementType + * @param {String} movementID + */ animationEvent: function (armature, movementType, movementID) { var locEventAni, locTarget, locFunc; for (var i = 0; i < this._mapEventAnimation.length; i++) { @@ -206,10 +275,20 @@ ccs.ArmatureMovementDispatcher = ccs.Class.extend({ } }, + /** + * Adds animation event callback to event animation list + * @param {function} callFunc + * @param {Object|null} [target] + */ addAnimationEventCallBack: function (callFunc, target) { this._mapEventAnimation.push([target, callFunc]); }, + /** + * Removes animation event callback from trigger manager. + * @param {function} callFunc + * @param {Object|null} [target] + */ removeAnimationEventCallBack: function (callFunc, target) { var locEventAni; for (var i = 0; i < this._mapEventAnimation.length; i++) { diff --git a/extensions/cocostudio/trigger/TriggerObj.js b/extensions/cocostudio/trigger/TriggerObj.js index ca31188aa7..3a3290c703 100644 --- a/extensions/cocostudio/trigger/TriggerObj.js +++ b/extensions/cocostudio/trigger/TriggerObj.js @@ -23,57 +23,112 @@ THE SOFTWARE. ****************************************************************************/ -ccs.BaseTriggerCondition = ccs.Class.extend({ +/** + * The base class of trigger condition. + * @class + * @extends ccs.Class + */ +ccs.BaseTriggerCondition = ccs.Class.extend(/** @lends ccs.BaseTriggerCondition# */{ + /** + * Construction of ccs.BaseTriggerCondition + */ ctor:function(){ - }, + /** + * initializes a BaseTriggerCondition class. + * @returns {boolean} + */ init: function () { return true; }, + /** + * Detects trigger condition + * @returns {boolean} + */ detect: function () { return true; }, + /** + * Serialize a BaseTriggerCondition object. + * @param jsonVal + */ serialize: function (jsonVal) { }, + /** + * Removes all condition + */ removeAll: function () { } }); -ccs.BaseTriggerAction = ccs.Class.extend({ - ctor:function(){ +/** + * The base class of trigger action + * @class + * @extends ccs.Class + */ +ccs.BaseTriggerAction = ccs.Class.extend(/** @lends ccs.BaseTriggerAction# */{ + /** + * Construction of ccs.BaseTriggerAction + */ + ctor:function(){ }, + /** + * Initializes a BaseTriggerAction object. + * @returns {boolean} + */ init: function () { return true; }, + /** + * Sets the action to done. + */ done: function () { - }, + /** + * Serializes a ccs.BaseTriggerAction object. + * @param jsonVal + */ serialize: function (jsonVal) { }, + /** + * Removes all actions. + */ removeAll: function () { } }); -ccs.TriggerObj = ccs.Class.extend({ +/** + * The trigger object of Cocostudio. + * @class + * @extends ccs.Class + */ +ccs.TriggerObj = ccs.Class.extend(/** @lends ccs.TriggerObj# */{ _cons: null, _acts: null, _id: 0, _enable: true, _vInt: null, + /** + * Construction of trigger object. + */ ctor: function () { this._id = 0; this._enable = true; }, + /** + * Initializes a ccs.TriggerObj + * @returns {boolean} + */ init: function () { this._cons = []; this._acts = []; @@ -81,6 +136,10 @@ ccs.TriggerObj = ccs.Class.extend({ return true; }, + /** + * Detects trigger's conditions. + * @returns {boolean} + */ detect: function () { if (!this._enable || this._cons.length == 0) { return true; @@ -89,26 +148,29 @@ ccs.TriggerObj = ccs.Class.extend({ var obj = null; for (var i = 0; i < this._cons.length; i++) { obj = this._cons[i]; - if (obj && obj.detect) { + if (obj && obj.detect) ret = ret && obj.detect(); - } } return ret; }, + /** + * Sets trigger's actions to done. + */ done: function () { - if (!this._enable || this._acts.length == 0) { + if (!this._enable || this._acts.length == 0) return; - } var obj; for (var i = 0; i < this._acts.length; i++) { obj = this._acts[i]; - if (obj && obj.done) { + if (obj && obj.done) obj.done(); - } } }, + /** + * Removes all condition and actions from ccs.TriggerObj. + */ removeAll: function () { var obj = null; for (var i = 0; i < this._cons.length; i++) { @@ -125,6 +187,10 @@ ccs.TriggerObj = ccs.Class.extend({ this._acts = []; }, + /** + * Serializes ccs.TriggerObj + * @param jsonVal + */ serialize: function (jsonVal) { this._id = jsonVal["id"] || 0; var conditions = jsonVal["conditions"] || []; @@ -168,14 +234,26 @@ ccs.TriggerObj = ccs.Class.extend({ } }, + /** + * Returns the id of ccs.TriggerObj. + * @returns {number} + */ getId: function () { return this._id; }, + /** + * Sets enable value. + * @param {Boolean} enable + */ setEnable: function (enable) { this._enable = enable; }, + /** + * Returns the events of ccs.TriggerObj. + * @returns {null|Array} + */ getEvents: function () { return this._vInt; } From 8a9326c4f63d2ab5279bc5e4032a6242b6eb3f58 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Sep 2014 22:40:47 +0800 Subject: [PATCH 0601/1564] Issue #5894: adds JsDocs to widget reader --- .../ImageViewReader/ImageViewReader.js | 32 +++++++++------ .../LabelAtlasReader/LabelAtlasReader.js | 18 +++++++- .../LabelBMFontReader/LabelBMFontReader.js | 22 +++++++--- .../widgetreader/LabelReader/LabelReader.js | 19 +++++++-- .../widgetreader/LayoutReader/LayoutReader.js | 20 +++++++-- .../ListViewReader/ListViewReader.js | 19 +++++++-- .../LoadingBarReader/LoadingBarReader.js | 19 +++++++-- .../PageViewReader/PageViewReader.js | 21 +++++++--- .../ScrollViewReader/ScrollViewReader.js | 23 +++++++---- .../widgetreader/SliderReader/SliderReader.js | 19 +++++++-- .../TextFieldReader/TextFieldReader.js | 41 +++++++++++-------- 11 files changed, 187 insertions(+), 66 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 64bfbe994f..6e27db35a9 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -23,42 +23,48 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ImageViewReader = { - +/** + * The ccui.ImageView's properties reader for GUIReader. + * @class + * @name ccs.ImageViewReader + **/ +ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ + /** + * Gets the ccs.ImageViewReader. + * @deprecated since v3.0, please use ccs.ImageViewReader directly. + * @returns {ccs.ImageViewReader} + */ getInstance: function(){ return ccs.ImageViewReader; }, + /** + * Sets ccui.ImageView's properties from json dictionary. + * @param {ccui.ImageView} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); var imageView = widget; - var imageFileNameDic = options["fileNameData"]; - var imageFileNameType = imageFileNameDic["resourceType"]; - switch (imageFileNameType) - { + var imageFileNameDic = options["fileNameData"], imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType){ case 0: - { var tp_i = jsonPath; var imageFileName = imageFileNameDic["path"]; var imageFileName_tp = null; - if (imageFileName && imageFileName !== "") - { + if (imageFileName && imageFileName !== "") { imageFileName_tp = tp_i + imageFileName; imageView.loadTexture(imageFileName_tp); } break; - } case 1: - { var imageFileName = imageFileNameDic["path"]; imageView.loadTexture(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); break; - } default: break; } diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 46cf7e28c9..d2c455282f 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -23,12 +23,26 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LabelAtlasReader = { - +/** + * The ccui.TextAtlas's properties reader for GUIReader. + * @class + * @name ccs.LabelAtlasReader + **/ +ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ + /** + * Gets the ccs.LabelAtlasReader. + * @deprecated since v3.0, please use ccs.LabelAtlasReader directly. + * @returns {ccs.LabelAtlasReader} + */ getInstance: function(){ return ccs.LabelAtlasReader; }, + /** + * Sets ccui.TextAtlas's properties from json dictionary. + * @param {ccui.TextAtlas} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index 86c5531405..99d60664de 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -23,11 +23,26 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LabelBMFontReader = { +/** + * The ccui.TextBMFont's properties reader for GUIReader. + * @class + * @name ccs.LabelBMFontReader + **/ +ccs.LabelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ + /** + * Gets the ccs.LabelBMFontReader. + * @deprecated since v3.0, please use ccs.LabelBMFontReader directly. + * @returns {ccs.LabelBMFontReader} + */ getInstance: function(){ return ccs.LabelBMFontReader; }, + /** + * Sets ccui.TextBMFont's properties from json dictionary. + * @param {ccui.TextBMFont} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); @@ -37,16 +52,13 @@ ccs.LabelBMFontReader = { var cmftDic = options["fileNameData"]; var cmfType = cmftDic["resourceType"]; - switch (cmfType) - { + switch (cmfType) { case 0: - { var tp_c = jsonPath; var cmfPath = cmftDic["path"]; var cmf_tp = tp_c + cmfPath; labelBMFont.setFntFile(cmf_tp); break; - } case 1: cc.log("Wrong res type of LabelAtlas!"); break; diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index d036c701e4..96fc34750c 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -23,14 +23,27 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LabelReader = { - +/** + * The ccui.Text's properties reader for GUIReader. + * @class + * @name ccs.LabelReader + **/ +ccs.LabelReader = /** @lends ccs.LabelReader# */{ + /** + * Gets the ccs.LabelReader. + * @deprecated since v3.0, please use ccs.LabelReader directly. + * @returns {ccs.LabelReader} + */ getInstance: function(){ return ccs.LabelReader; }, + /** + * Sets ccui.Text's properties from json dictionary. + * @param {ccui.Text} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var label = widget; diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 20180af180..d83ded8bd5 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -23,16 +23,28 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LayoutReader = { - +/** + * The ccui.Layout's properties reader for GUIReader. + * @class + * @name ccs.LayoutReader + **/ +ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ + /** + * Gets the ccs.LayoutReader. + * @deprecated since v3.0, please use ccs.LayoutReader directly. + * @returns {ccs.LayoutReader} + */ getInstance: function(){ return ccs.LayoutReader; }, + /** + * Sets ccui.Layout's properties from json dictionary. + * @param {ccui.Layout} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); - var jsonPath = ccs.uiReader.getFilePath(); var panel = widget; diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index d32d5929d1..919ec9d3b9 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -23,14 +23,27 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ListViewReader = { - +/** + * The ccui.ListView's properties reader for GUIReader. + * @class + * @name ccs.ListViewReader + **/ +ccs.ListViewReader = /** @lends ccs.ListViewReader# */{ + /** + * Gets the ccs.ListViewReader. + * @deprecated since v3.0, please use ccs.ListViewReader directly. + * @returns {ccs.ListViewReader} + */ getInstance: function(){ return ccs.ListViewReader; }, + /** + * Sets ccui.ListView's properties from json dictionary. + * @param {ccui.ListView} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.ScrollViewReader.setPropsFromJsonDictionary.call(this, widget, options); var listView = widget; diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index 3baa3daacf..0adcf7acb2 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -23,14 +23,27 @@ THE SOFTWARE. ****************************************************************************/ -ccs.LoadingBarReader = { - +/** + * The ccui.LoadingBar's properties reader for GUIReader. + * @class + * @name ccs.LoadingBarReader + **/ +ccs.LoadingBarReader = /** @lends ccs.LoadingBarReader# */{ + /** + * Gets the ccs.LoadingBarReader. + * @deprecated since v3.0, please use ccs.LoadingBarReader directly. + * @returns {ccs.LoadingBarReader} + */ getInstance: function(){ return ccs.LoadingBarReader; }, + /** + * Sets ccui.LoadingBar's properties from json dictionary. + * @param {ccui.LoadingBar} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index 0210ce0ac7..429d076ff5 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -23,16 +23,27 @@ THE SOFTWARE. ****************************************************************************/ -ccs.PageViewReader = { - - instancePageViewReader: null, - +/** + * The ccui.PageView's properties reader for GUIReader. + * @class + * @name ccs.PageViewReader + **/ +ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ + /** + * Gets the ccs.PageViewReader. + * @deprecated since v3.0, please use ccs.PageViewReader directly. + * @returns {ccs.PageViewReader} + */ getInstance: function(){ return ccs.PageViewReader; }, + /** + * Sets ccui.PageView's properties from json dictionary. + * @param {ccui.PageView} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index bca123d826..c91315a8e0 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -23,29 +23,38 @@ THE SOFTWARE. ****************************************************************************/ -ccs.ScrollViewReader = { - +/** + * The ccui.ScrollView's properties reader for GUIReader. + * @class + * @name ccs.ScrollViewReader + **/ +ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ + /** + * Gets the ccs.ScrollViewReader. + * @deprecated since v3.0, please use ccs.ScrollViewReader directly. + * @returns {ccs.ScrollViewReader} + */ getInstance: function(){ return ccs.ScrollViewReader; }, + /** + * Sets ccui.ScrollView's properties from json dictionary. + * @param {ccui.ScrollView} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); - var scrollView = widget; - var innerWidth = options["innerWidth"] || 200; var innerHeight = options["innerHeight"] || 200; scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); var direction = options["direction"] || 1; scrollView.setDirection(direction); - scrollView.setBounceEnabled(options["bounceEnable"]); - ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index ca442b8bd3..f2f3a66ea3 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -23,14 +23,27 @@ THE SOFTWARE. ****************************************************************************/ -ccs.SliderReader = { - +/** + * The ccui.Slider's properties reader for GUIReader. + * @class + * @name ccs.SliderReader + **/ +ccs.SliderReader = /** @lends ccs.SliderReader# */{ + /** + * Gets the ccs.SliderReader. + * @deprecated since v3.0, please use ccs.SliderReader directly. + * @returns {ccs.SliderReader} + */ getInstance: function(){ return ccs.SliderReader; }, + /** + * Sets ccui.Slider's properties from json dictionary. + * @param {ccui.Slider} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index c794f1f892..a152e23ce5 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -23,35 +23,44 @@ THE SOFTWARE. ****************************************************************************/ -ccs.TextFieldReader = { - +/** + * The ccui.TextField's properties reader for GUIReader. + * @class + * @name ccs.TextFieldReader + **/ +ccs.TextFieldReader = /** @lends ccs.TextFieldReader# */{ + /** + * Gets the ccs.TextFieldReader. + * @deprecated since v3.0, please use ccs.TextFieldReader directly. + * @returns {ccs.TextFieldReader} + */ getInstance: function(){ return ccs.TextFieldReader; }, + /** + * Sets ccui.TextField's properties from json dictionary. + * @param {ccui.TextField} widget + * @param {Object} options + */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var textField = widget; var ph = options["placeHolder"]; - if(ph){ + if(ph) textField.setPlaceHolder(ph); - } textField.setString(options["text"]); var fs = options["fontSize1"]; - if(fs){ + if(fs) textField.setFontSize(fs); - } var fn = options["fontName"]; - if(fn){ + if(fn) textField.setFontName(fn); - } var tsw = options["touchSizeWidth"]; var tsh = options["touchSizeHeight"]; - if(tsw && tsh){ + if(tsw && tsh) textField.setTouchSize(tsw, tsh); - } var dw = options["width"]; var dh = options["height"]; @@ -67,9 +76,8 @@ ccs.TextFieldReader = { } var passwordEnable = options["passwordEnable"]; textField.setPasswordEnabled(passwordEnable); - if(passwordEnable){ + if(passwordEnable) textField.setPasswordStyleText(options["passwordStyleText"]); - } var aw = options["areaWidth"]; var ah = options["areaHeight"]; @@ -78,15 +86,12 @@ ccs.TextFieldReader = { textField.setTextAreaSize(size); } var ha = options["hAlignment"]; - if(ha){ + if(ha) textField.setTextHorizontalAlignment(ha); - } var va = options["vAlignment"]; - if(va){ + if(va) textField.setTextVerticalAlignment(va); - } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - } }; \ No newline at end of file From d973a05a09712f320525188308e72900301eafb2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 5 Sep 2014 10:50:33 +0800 Subject: [PATCH 0602/1564] Issue #5894: adds jsDocs to Cocostudio component. --- .../cocostudio/components/CCComAttribute.js | 48 ++++++++++------- .../cocostudio/components/CCComAudio.js | 46 ++++++++++------ .../cocostudio/components/CCComController.js | 35 +++++------- .../cocostudio/components/CCComRender.js | 26 ++++++--- .../cocostudio/components/CCComponent.js | 54 +++++++++++++++++-- .../components/CCComponentContainer.js | 49 +++++++++++------ 6 files changed, 173 insertions(+), 85 deletions(-) diff --git a/extensions/cocostudio/components/CCComAttribute.js b/extensions/cocostudio/components/CCComAttribute.js index b1940b107f..3fd8f13a67 100644 --- a/extensions/cocostudio/components/CCComAttribute.js +++ b/extensions/cocostudio/components/CCComAttribute.js @@ -24,26 +24,35 @@ ****************************************************************************/ /** - * Base class for ccs.ComAttribute + * The attribute component for Cocostudio. * @class * @extends ccs.Component */ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ _jsonDict: null, _filePath: "", + + /** + * Construction of ccs.ComAttribute + */ ctor: function () { cc.Component.prototype.ctor.call(this); this._jsonDict = {}; this._filePath = ""; this._name = "CCComAttribute"; }, + + /** + * Initializes a ccs.ComAttribute + * @returns {boolean} + */ init: function () { this._jsonDict = {}; return true; }, /** - * Set int attribute + * Sets int attribute * @param {String} key * @param {number} value */ @@ -56,7 +65,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Set double attribute + * Sets double attribute * @param {String} key * @param {number} value */ @@ -69,7 +78,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Set float attribute + * Sets float attribute * @param {String} key * @param {number} value */ @@ -82,7 +91,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Set boolean attribute + * Sets boolean attribute * @param {String} key * @param {Boolean} value */ @@ -95,7 +104,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Set string attribute + * Sets string attribute * @param {String} key * @param {Boolean} value */ @@ -108,7 +117,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Set object attribute + * Sets object attribute * @param {String} key * @param {Object} value */ @@ -121,7 +130,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Get int value from attribute + * Returns int value from attribute * @param {String} key * @returns {Number} */ @@ -131,7 +140,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Get double value from attribute + * Returns double value from attribute * @param {String} key * @returns {Number} */ @@ -141,7 +150,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Get float value from attribute + * Returns float value from attribute * @param {String} key * @returns {Number} */ @@ -151,7 +160,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Get boolean value from attribute + * Returns boolean value from attribute * @param {String} key * @returns {Boolean} */ @@ -161,7 +170,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Get string value from attribute + * Returns string value from attribute * @param {String} key * @returns {String} */ @@ -171,7 +180,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * Get object value from attribute + * Returns object value from attribute * @param {String} key * @returns {Object} */ @@ -180,16 +189,16 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ }, /** - * - * @param path + * Parses json file. + * @param filename */ - parse:function(path){ - this._jsonDict = cc.loader.getRes(path); + parse:function(filename){ + this._jsonDict = cc.loader.getRes(filename); } }); /** * allocates and initializes a ComAttribute. - * @constructs + * @deprecated since v3.0, please use new construction instead. * @return {ccs.ComAttribute} * @example * // example @@ -197,8 +206,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ */ ccs.ComAttribute.create = function () { var com = new ccs.ComAttribute(); - if (com && com.init()) { + if (com && com.init()) return com; - } return null; }; \ No newline at end of file diff --git a/extensions/cocostudio/components/CCComAudio.js b/extensions/cocostudio/components/CCComAudio.js index 6654457225..6b99f6ae95 100644 --- a/extensions/cocostudio/components/CCComAudio.js +++ b/extensions/cocostudio/components/CCComAudio.js @@ -24,29 +24,42 @@ ****************************************************************************/ /** - * Base class for ccs.ComAudio + * The audio component for Cocostudio. * @class * @extends ccs.Component */ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ _filePath: "", _loop: false, + + /** + * Construction of ccs.ComAudio + */ ctor: function () { cc.Component.prototype.ctor.call(this); this._name = "Audio"; }, + + /** + * Initializes a ccs.ComAudio. + * @returns {boolean} + */ init: function () { return true; }, - onEnter: function () { - }, - + /** + * The callback calls when a audio component enter stage. + * @override + */ onExit: function () { this.stopBackgroundMusic(true); this.stopAllEffects(); }, + /** + * Stops all audios. + */ end: function () { cc.audioEngine.end(); }, @@ -61,8 +74,8 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ /** * Play background music - * @param {String} pszFilePath - * @param {Boolean} loop + * @param {String} [pszFilePath] + * @param {Boolean} [loop] */ playBackgroundMusic: function (pszFilePath, loop) { if(pszFilePath){ @@ -151,16 +164,15 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ /** * Play sound effect. - * @param {String} pszFilePath - * @param {Boolean} loop + * @param {String} [pszFilePath] + * @param {Boolean} [loop] * @returns {Boolean} */ playEffect: function (pszFilePath, loop) { - if (pszFilePath) { + if (pszFilePath) return cc.audioEngine.playEffect(pszFilePath, loop); - } else { + else return cc.audioEngine.playEffect(this._filePath, this._loop); - } }, /** @@ -235,7 +247,7 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ }, /** - * Set loop + * Sets audio component whether plays loop * @param {Boolean} loop */ setLoop: function (loop) { @@ -243,7 +255,7 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ }, /** - * File path Getter + * Returns the file path of audio component. * @returns {string} */ getFile: function () { @@ -251,16 +263,17 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ }, /** - * Whether is loop + * Returns audio component whether plays loop * @returns {boolean} */ isLoop: function () { return this._loop; } }); + /** * allocates and initializes a ComAudio. - * @constructs + * @deprecated since v3.0, please use new construction instead. * @return {ccs.ComAudio} * @example * // example @@ -268,8 +281,7 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ */ ccs.ComAudio.create = function () { var com = new ccs.ComAudio(); - if (com && com.init()) { + if (com && com.init()) return com; - } return null; }; \ No newline at end of file diff --git a/extensions/cocostudio/components/CCComController.js b/extensions/cocostudio/components/CCComController.js index 5bdb419a79..77ff94f6a2 100644 --- a/extensions/cocostudio/components/CCComController.js +++ b/extensions/cocostudio/components/CCComController.js @@ -24,36 +24,30 @@ ****************************************************************************/ /** - * Base class for ccs.ComController + * The controller component for Cocostudio. * @class * @extends ccs.Component */ ccs.ComController = ccs.Component.extend(/** @lends ccs.ComController# */{ + /** + * Construction of ccs.ComController. + */ ctor: function () { cc.Component.prototype.ctor.call(this); this._name = "ComController"; }, - init: function () { - return true; - }, + /** + * The callback calls when controller component enter stage. + * @override + */ onEnter: function () { if (this._owner != null) - { this._owner.scheduleUpdate(); - } - - }, - - onExit: function () { - - }, - - update: function (dt) { }, /** - * Enabled getter + * Returns controller component whether is enabled * @returns {Boolean} */ isEnabled: function () { @@ -61,16 +55,16 @@ ccs.ComController = ccs.Component.extend(/** @lends ccs.ComController# */{ }, /** - * Enabled setter + * Sets controller component whether is enabled * @param {Boolean} bool */ setEnabled: function (bool) { - this._enabled = b; + this._enabled = bool; } }); /** - * allocates and initializes a ComController. - * @constructs + * Allocates and initializes a ComController. + * @deprecated since v3.0, please use new construction instead. * @return {ccs.ComController} * @example * // example @@ -78,8 +72,7 @@ ccs.ComController = ccs.Component.extend(/** @lends ccs.ComController# */{ */ ccs.ComController.create = function () { var com = new ccs.ComController(); - if (com && com.init()) { + if (com && com.init()) return com; - } return null; }; \ No newline at end of file diff --git a/extensions/cocostudio/components/CCComRender.js b/extensions/cocostudio/components/CCComRender.js index 3b21e2ecc3..29a292c4c8 100644 --- a/extensions/cocostudio/components/CCComRender.js +++ b/extensions/cocostudio/components/CCComRender.js @@ -24,12 +24,17 @@ ****************************************************************************/ /** - * Base class for ccs.ComRender + * The render component for Cocostudio. * @class * @extends ccs.Component */ ccs.ComRender = ccs.Component.extend(/** @lends ccs.ComRender# */{ _render: null, + /** + * Construction of ccs.ComRender + * @param {cc.Node} node + * @param {String} comName + */ ctor: function (node, comName) { cc.Component.prototype.ctor.call(this); this._render = node; @@ -37,12 +42,17 @@ ccs.ComRender = ccs.Component.extend(/** @lends ccs.ComRender# */{ this.isRenderer = true; }, + /** + * The callback calls when a render component enter stage. + */ onEnter: function () { - if (this._owner) { + if (this._owner) this._owner.addChild(this._render); - } }, + /** + * The callback calls when a render component exit stage. + */ onExit: function () { if (this._owner) { this._owner.removeChild(this._render, true); @@ -51,7 +61,7 @@ ccs.ComRender = ccs.Component.extend(/** @lends ccs.ComRender# */{ }, /** - * Node getter + * Returns a render node * @returns {cc.Node} */ getNode: function () { @@ -59,16 +69,17 @@ ccs.ComRender = ccs.Component.extend(/** @lends ccs.ComRender# */{ }, /** - * Node setter + * Sets a render node to component. * @param {cc.Node} node */ setNode: function (node) { this._render = node; } }); + /** * allocates and initializes a ComRender. - * @constructs + * @deprecated since v3.0, please use new construction instead. * @return {ccs.ComRender} * @example * // example @@ -76,8 +87,7 @@ ccs.ComRender = ccs.Component.extend(/** @lends ccs.ComRender# */{ */ ccs.ComRender.create = function (node, comName) { var com = new ccs.ComRender(node, comName); - if (com && com.init()) { + if (com && com.init()) return com; - } return null; }; diff --git a/extensions/cocostudio/components/CCComponent.js b/extensions/cocostudio/components/CCComponent.js index a32daa9411..5084a9744a 100644 --- a/extensions/cocostudio/components/CCComponent.js +++ b/extensions/cocostudio/components/CCComponent.js @@ -33,57 +33,103 @@ cc.Component = cc.Class.extend(/** @lends cc.Component# */{ _name: "", _enabled: true, + /** + * Construction of cc.Component + */ ctor:function(){ this._owner = null; this._name = ""; this._enabled = true; }, + /** + * Initializes a cc.Component. + * @returns {boolean} + */ init:function(){ return true; }, + /** + * The callback when a component enter stage. + */ onEnter:function(){ - }, + /** + * The callback when a component exit stage. + */ onExit:function(){ - }, + /** + * The callback per every frame if it schedules update. + * @param delta + */ update:function(delta){ - }, + /** + * Serialize a component object. + * @param reader + */ serialize:function( reader){ - }, + /** + * Returns component whether is enabled. + * @returns {boolean} + */ isEnabled:function(){ return this._enabled; }, + /** + * Sets component whether is enabled. + * @param enable + */ setEnabled:function(enable){ this._enabled = enable; }, + /** + * Returns the name of cc.Component. + * @returns {string} + */ getName:function(){ return this._name; } , + /** + * Sets the name to cc.Component. + * @param {String} name + */ setName:function(name){ this._name = name; } , + /** + * Sets the owner to cc.Component. + * @param owner + */ setOwner:function(owner){ this._owner = owner; }, + /** + * Returns the owner of cc.Component. + * @returns {*} + */ getOwner:function(){ return this._owner; } }); +/** + * Allocates and initializes a component. + * @deprecated since v3.0, please use new construction instead. + * @return {cc.Component} + */ cc.Component.create = function(){ return new cc.Component(); }; diff --git a/extensions/cocostudio/components/CCComponentContainer.js b/extensions/cocostudio/components/CCComponentContainer.js index 06bf70e458..2b4c60446a 100644 --- a/extensions/cocostudio/components/CCComponentContainer.js +++ b/extensions/cocostudio/components/CCComponentContainer.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * The container of cc.Component + * The component container for Cocostudio, it has some components. * @class * @extends cc.Class */ @@ -32,11 +32,20 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ _components:null, _owner:null, + /** + * Construction of cc.ComponentContainer + * @param node + */ ctor:function(node){ this._components = null; this._owner = node; }, + /** + * Gets component by name. + * @param name + * @returns {*} + */ getComponent:function(name){ if(!name) throw "cc.ComponentContainer.getComponent(): name should be non-null"; @@ -44,6 +53,11 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ return this._components[name]; }, + /** + * Adds a component to container + * @param {cc.Component} component + * @returns {boolean} + */ add:function(component){ if(!component) throw "cc.ComponentContainer.add(): component should be non-null"; @@ -68,8 +82,8 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ }, /** - * - * @param {String|cc.Component} name + * Removes component from container by name or component object. + * @param {String|cc.Component} name component name or component object. * @returns {boolean} */ remove:function(name){ @@ -77,9 +91,9 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ throw "cc.ComponentContainer.remove(): name should be non-null"; if(!this._components) return false; - if(name instanceof cc.Component){ + if(name instanceof cc.Component) return this._removeByComponent(name); - }else{ + else { name = name.trim(); return this._removeByComponent(this._components[name]); } @@ -94,10 +108,12 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ return true; }, + /** + * Removes all components of container. + */ removeAll:function(){ if(!this._components) return; - var locComponents = this._components; for(var selKey in locComponents){ var selComponent = locComponents[selKey]; @@ -113,24 +129,27 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ this._components = {}; }, + /** + * Visit callback by director. it calls every frame. + * @param {Number} delta + */ visit:function(delta){ if(!this._components) return; var locComponents = this._components; - for(var selKey in locComponents){ + for(var selKey in locComponents) locComponents[selKey].update(delta); - } }, - isEmpty:function(){ - if(!this._components) + /** + * Returns the container whether is empty. + * @returns {boolean} + */ + isEmpty: function () { + if (!this._components) return true; - - for(var selkey in this._components){ - return false; - } - return true; + return this._components.length == 0; } }); From f63b11b794cfa4bc40e7550e2f038b11a019cf5e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 5 Sep 2014 13:46:35 +0800 Subject: [PATCH 0603/1564] Issue #5695: Modify the loing compatibility --- external/pluginx/platform/facebook.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index fdeb924b29..d18e7d6001 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -93,9 +93,12 @@ plugin.extend('facebook', { */ login: function(permissions,callback){ var self = this; - permissions = permissions || []; + if(typeof permissions == 'function'){ + callback = permissions; + permissions = []; + } if(!permissions.some(function(item){ - if(item == 'publish_actions') + if(item != 'publish_actions') return true; })){ permissions.push("publish_actions"); From 1e5e1be60523bb892b7ea551edc4c59ba722a370 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 5 Sep 2014 13:54:13 +0800 Subject: [PATCH 0604/1564] Issue #5695: Modify the loing compatibility --- external/pluginx/platform/facebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index d18e7d6001..119e8bed58 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -97,7 +97,7 @@ plugin.extend('facebook', { callback = permissions; permissions = []; } - if(!permissions.some(function(item){ + if(permissions.every(function(item){ if(item != 'publish_actions') return true; })){ From 6c8c03554630947cd0e88536af1c7d9b57919e58 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 5 Sep 2014 15:46:04 +0800 Subject: [PATCH 0605/1564] Issue #5906: The NO_BORDER coordinate system, the scaling error --- cocos2d/core/platform/CCEGLView.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index c742f37e9b..1bdbd4d9a2 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -510,8 +510,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ // reset director's member variables to fit visible rect var director = cc.director; - cc.winSize.width = director._winSizeInPoints.width = _t._visibleRect.width; - cc.winSize.height = director._winSizeInPoints.height = _t._visibleRect.height; + director._winSizeInPoints.width = _t._designResolutionSize.width; + director._winSizeInPoints.heihgt = _t._designResolutionSize.heihgt; + cc.winSize.width = director._winSizeInPoints.width; + cc.winSize.height = director._winSizeInPoints.height; policy.postApply(_t); @@ -947,13 +949,11 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ apply: function (view, designedResolution) { var containerW = cc._canvas.width, containerH = cc._canvas.height, designW = designedResolution.width, designH = designedResolution.height, - scaleX = containerW / designW, scaleY = containerH / designH, scale, - contentW, contentH; + scaleX = containerW / designW, scaleY = containerH / designH, scale; - scaleX < scaleY ? (scale = scaleY, contentW = designW * scale, contentH = containerH) - : (scale = scaleX, contentW = containerW, contentH = designH * scale); + scaleX < scaleY ? ( scale = scaleY ): ( scale = scaleX ); - return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); + return this._buildResult(containerW, containerH, containerW, containerH, scale, scale); } }); From 4e13823a94620ccf74350f833a8c19e24654a4f3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 5 Sep 2014 16:54:36 +0800 Subject: [PATCH 0606/1564] Issue #5820: UIPageView TOUCH_ENDED error --- extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index ef6c8cf8bd..34d44d7ff5 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -473,10 +473,9 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ } break; case ccui.Widget.TOUCH_ENDED: + case ccui.Widget.TOUCH_CANCELED: this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; - break; - case ccui.Widget.TOUCH_CANCELED: this._handleReleaseLogic(touch); break; } From 8a31ac22e15958f35c6aed3c50b571d4ba735150 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 5 Sep 2014 17:50:35 +0800 Subject: [PATCH 0607/1564] Issue #5908: setColor is error --- cocos2d/core/platform/CCTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 0b97a2fa27..fcc16a9b77 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -68,7 +68,7 @@ cc.color = function (r, g, b, a) { return cc.hexToColor(r); if (cc.isObject(r)) return {r: r.r, g: r.g, b: r.b, a: (r.a == null) ? 255 : r.a}; - return {r: r, g: g, b: b, a: (r.a == null) ? 255 : r.a}; + return {r: r, g: g, b: b, a: (a == null ? 255 : a)}; }; /** From 5f0274c42c387b5601ac332fc575fa1ef5f6abce Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 5 Sep 2014 18:22:56 +0800 Subject: [PATCH 0608/1564] Issue #5894: adds Cocostudio armature jsDocs. --- extensions/cocostudio/armature/CCArmature.js | 41 +++- extensions/cocostudio/armature/CCBone.js | 178 +++++++++++------- .../armature/animation/CCArmatureAnimation.js | 147 ++++++++++----- .../armature/animation/CCProcessBase.js | 62 +++--- .../cocostudio/armature/animation/CCTween.js | 47 +++-- 5 files changed, 316 insertions(+), 159 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 540bed7164..b7cc12c406 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccs.Armature objects. + * The main class of Armature, it plays armature animation, manages and updates bones' state. * @class * @extends ccs.Node * @@ -70,7 +70,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._offsetPoint = cc.p(0, 0); this._armatureTransformDirty = true; this._realAnchorPointInPoints = cc.p(0, 0); - name && ccs.Armature.prototype.init.call(this, name, parentBone); }, @@ -277,6 +276,12 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.setAnchorPoint(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height); }, + /** + * Sets armature's anchor point, because it need to consider offset point, so here is the override function. + * @override + * @param {cc.Point|Number} point point or x of point + * @param {Number} [y] y of point + */ setAnchorPoint: function(point, y){ var ax, ay; if(y !== undefined){ @@ -316,6 +321,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.setNodeDirty(); }, + /** + * Returns the anchor point in points of ccs.Armature. + * @override + * @returns {cc.Point} + */ getAnchorPointInPoints: function(){ return this._realAnchorPointInPoints; }, @@ -344,6 +354,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ return this._armatureTransformDirty; }, + /** + * The update callback of ccs.Armature, it updates animation's state and updates bone's state. + * @override + * @param {Number} dt + */ update: function (dt) { this.animation.update(dt); var locTopBoneList = this._topBoneList; @@ -352,6 +367,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = false; }, + /** + * Draws armature's display render node. + * @override + * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context + */ draw: function(ctx){ if (this._parentBone == null && this._batchNode == null) { // CC_NODE_DRAW_SETUP(); @@ -408,11 +428,19 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ } }, + /** + * The callback when ccs.Armature enter stage. + * @override + */ onEnter: function () { cc.Node.prototype.onEnter.call(this); this.scheduleUpdate(); }, + /** + * The callback when ccs.Armature exit stage. + * @override + */ onExit: function () { cc.Node.prototype.onExit.call(this); this.unscheduleUpdate(); @@ -531,7 +559,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * return parent bone + * Return parent bone of ccs.Armature. * @returns {ccs.Bone} */ getParentBone: function () { @@ -559,6 +587,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ } }, + setBody: function (body) { if (this._body == body) return; @@ -591,7 +620,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * conforms to cc.TextureProtocol protocol + * Sets the blendFunc to ccs.Armature * @param {cc.BlendFunc} blendFunc */ setBlendFunc: function (blendFunc) { @@ -599,7 +628,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * blendFunc getter + * Returns the blendFunc of ccs.Armature * @returns {cc.BlendFunc} */ getBlendFunc: function () { @@ -617,7 +646,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, /** - * Gets the armatureData of this Armature + * Returns the armatureData of ccs.Armature * @return {ccs.ArmatureData} */ getArmatureData: function () { diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 62e22f604a..8a4d1d78a5 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccs.Bone objects. + * The Bone of Armature, it has bone data, display manager and transform data for armature. * @class * @extends ccs.Node * @@ -53,12 +53,16 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ _parentBone: null, _boneTransformDirty: false, _worldTransform: null, - _blendFunc: 0, + _blendFunc: null, blendDirty: false, _worldInfo: null, _armatureParentBone: null, _dataVersion: 0, _className: "Bone", + + /** + * Construction of ccs.Bone. + */ ctor: function () { cc.Node.prototype.ctor.call(this); this._tweenData = null; @@ -81,15 +85,14 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * Initializes a CCBone with the specified name - * @param {String} name + * Initializes a ccs.Bone with the specified name + * @param {String} name bone name * @return {Boolean} */ init: function (name) { // cc.Node.prototype.init.call(this); - if (name) { + if (name) this._name = name; - } this._tweenData = new ccs.FrameData(); this._tween = new ccs.Tween(); @@ -105,7 +108,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * set the boneData + * Sets the boneData to ccs.Bone. * @param {ccs.BoneData} boneData */ setBoneData: function (boneData) { @@ -120,7 +123,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * boneData getter + * Returns boneData of ccs.Bone. * @return {ccs.BoneData} */ getBoneData: function () { @@ -128,7 +131,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * set the armature + * Sets the armature reference to ccs.Bone. * @param {ccs.Armature} armature */ setArmature: function (armature) { @@ -137,13 +140,12 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._tween.setAnimation(this._armature.getAnimation()); this._dataVersion = this._armature.getArmatureData().dataVersion; this._armatureParentBone = this._armature.getParentBone(); - } else { + } else this._armatureParentBone = null; - } }, /** - * armature getter + * Returns the armature reference of ccs.Bone. * @return {ccs.Armature} */ getArmature: function () { @@ -151,7 +153,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * update worldTransform + * Updates worldTransform by tween data and updates display state * @param {Number} delta */ update: function (delta) { @@ -179,10 +181,10 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ locWorldInfo.skewY = locTweenData.skewY + this._skewY - this._rotationY; if(this._parentBone) - this.applyParentTransform(this._parentBone); + this._applyParentTransform(this._parentBone); else { if (this._armatureParentBone) - this.applyParentTransform(this._armatureParentBone); + this._applyParentTransform(this._armatureParentBone); } ccs.TransformHelp.nodeToMatrix(locWorldInfo, this._worldTransform); @@ -198,7 +200,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._boneTransformDirty = false; }, - applyParentTransform: function (parent) { + _applyParentTransform: function (parent) { var locWorldInfo = this._worldInfo; var locParentWorldTransform = parent._worldTransform; var locParentWorldInfo = parent._worldInfo; @@ -213,18 +215,29 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * BlendFunc setter - * @param {cc.BlendFunc} blendFunc + * Sets BlendFunc to ccs.Bone. + * @param {cc.BlendFunc|Number} blendFunc blendFunc or src of blendFunc + * @param {Number} [dst] dst of blendFunc */ - setBlendFunc: function (blendFunc) { - if (this._blendFunc.src != blendFunc.src || this._blendFunc.dst != blendFunc.dst) { - this._blendFunc = blendFunc; + setBlendFunc: function (blendFunc, dst) { + var locBlendFunc = this._blendFunc, srcValue, dstValue; + if(dst === undefined){ + srcValue = blendFunc.src; + dstValue = blendFunc.dst; + } else { + srcValue = blendFunc; + dstValue = dst; + } + if (locBlendFunc.src != srcValue || locBlendFunc.dst != dstValue) { + locBlendFunc.src = srcValue; + locBlendFunc.dst = dstValue; this.blendDirty = true; } }, /** - * update display color + * Updates display color + * @override * @param {cc.Color} color */ updateDisplayedColor: function (color) { @@ -234,7 +247,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * update display opacity + * Updates display opacity * @param {Number} opacity */ updateDisplayedOpacity: function (opacity) { @@ -244,7 +257,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * update display color + * Updates display color */ updateColor: function () { var display = this._displayManager.getDisplayRenderNode(); @@ -259,7 +272,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * update display zOrder + * Updates display zOrder */ updateZOrder: function () { if (this._armature.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED) { @@ -271,7 +284,7 @@ ccs.Bone = ccs.Node.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 + * Adds 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) { @@ -306,31 +319,34 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * Remove itself from its parent CCBone. + * Removes itself from its parent ccs.Bone. * @param {Boolean} recursion */ removeFromParent: function (recursion) { - if (this._parentBone) { + if (this._parentBone) this._parentBone.removeChildBone(this, recursion); - } }, /** - * Set parent bone. + * Sets parent bone to ccs.Bone. * If _parent is NUll, then also remove this bone from armature. - * It will not set the CCArmature, if you want to add the bone to a CCArmature, you should use ccs.Armature.addBone(bone, parentName). + * It will not set the ccs.Armature, if you want to add the bone to a ccs.Armature, you should use ccs.Armature.addBone(bone, parentName). * @param {ccs.Bone} parent the parent bone. */ setParentBone: function (parent) { this._parentBone = parent; }, + /** + * Returns the parent bone of ccs.Bone. + * @returns {ccs.Bone} + */ getParentBone: function(){ return this._parentBone; }, /** - * child armature setter + * Sets ccs.Bone's child armature * @param {ccs.Armature} armature */ setChildArmature: function (armature) { @@ -342,7 +358,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * child armature getter + * Returns ccs.Bone's child armature. * @return {ccs.Armature} */ getChildArmature: function () { @@ -350,7 +366,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * tween getter + * Return the tween of ccs.Bone * @return {ccs.Tween} */ getTween: function () { @@ -358,7 +374,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * zOrder setter + * Sets the local zOrder to ccs.Bone. * @param {Number} zOrder */ setLocalZOrder: function (zOrder) { @@ -366,16 +382,25 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ cc.Node.prototype.setLocalZOrder.call(this, zOrder); }, + /** + * Return the worldTransform of ccs.Bone. + * @returns {cc.AffineTransform} + */ getNodeToArmatureTransform: function(){ return this._worldTransform; }, + /** + * Returns the world transform of ccs.Bone. + * @override + * @returns {cc.AffineTransform} + */ getNodeToWorldTransform: function(){ return cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToWorldTransform()); }, /** - * get render node + * Returns the display render node. * @returns {cc.Node} */ getDisplayRenderNode: function () { @@ -383,7 +408,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * get render node type + * Returns the type of display render node * @returns {Number} */ getDisplayRenderNodeType: function () { @@ -405,15 +430,16 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * remove display - * @param {Number} index + * Removes display by index. + * @param {Number} index display renderer's index */ removeDisplay: function (index) { this._displayManager.removeDisplay(index); }, /** - * change display by index + * Changes display by index + * @deprecated since v3.0, please use changeDisplayWithIndex instead. * @param {Number} index * @param {Boolean} force */ @@ -422,12 +448,19 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this.changeDisplayWithIndex(index, force); }, + /** + * Changes display by name + * @deprecated since v3.0, please use changeDisplayWithName instead. + * @param {String} name + * @param {Boolean} force + */ changeDisplayByName: function(name, force){ + cc.log("changeDisplayByName is deprecated. Use changeDisplayWithName instead."); this.changeDisplayWithName(name, force); }, /** - * change display with index + * Changes display with index * @param {Number} index * @param {Boolean} force */ @@ -436,7 +469,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * change display with name + * Changes display with name * @param {String} name * @param {Boolean} force */ @@ -444,6 +477,10 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._displayManager.changeDisplayWithName(name, force); }, + /** + * Returns the collide detector of ccs.Bone. + * @returns {*} + */ getColliderDetector: function(){ var decoDisplay = this._displayManager.getCurrentDecorativeDisplay(); if (decoDisplay){ @@ -455,22 +492,21 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * collider filter setter - * @param {cc.ColliderFilter} filter + * Sets collider filter to ccs.Bone. + * @param {ccs.ColliderFilter} filter */ setColliderFilter: function (filter) { var displayList = this._displayManager.getDecorativeDisplayList(); for (var i = 0; i < displayList.length; i++) { var locDecoDisplay = displayList[i]; var locDetector = locDecoDisplay.getColliderDetector(); - if (locDetector) { + if (locDetector) locDetector.setColliderFilter(filter); - } } }, /** - * collider filter getter + * Returns collider filter of ccs.Bone. * @returns {cc.ColliderFilter} */ getColliderFilter: function () { @@ -484,7 +520,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * transform dirty setter + * Sets ccs.Bone's transform dirty flag. * @param {Boolean} dirty */ setTransformDirty: function (dirty) { @@ -492,7 +528,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * transform dirty getter + * Returns ccs.Bone's transform dirty flag whether is dirty. * @return {Boolean} */ isTransformDirty: function () { @@ -508,7 +544,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * When CCArmature play a animation, if there is not a CCMovementBoneData of this bone in this CCMovementData, this bone will hide. + * When CCArmature play a animation, if there is not a CCMovementBoneData of this bone in this CCMovementData, this bone will hide.
    * Set IgnoreMovementBoneData to true, then this bone will also show. * @param {Boolean} bool */ @@ -516,51 +552,67 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._ignoreMovementBoneData = bool; }, + /** + * Returns whether is ignore movement bone data. + * @returns {Boolean} + */ isIgnoreMovementBoneData: function(){ return this._ignoreMovementBoneData; }, /** - * blendType getter + * Returns the blendFunc of ccs.Bone. * @return {cc.BlendFunc} */ getBlendFunc: function () { return this._blendFunc; }, + /** + * Sets blend dirty flag + * @param {Boolean} dirty + */ setBlendDirty: function (dirty) { this._blendDirty = dirty; }, + /** + * Returns the blend dirty flag whether is dirty. + * @returns {Boolean|*|ccs.Bone._blendDirty} + */ isBlendDirty: function () { return this._blendDirty; }, /** - * tweenData getter + * Returns the tweenData of ccs.Bone. * @return {ccs.FrameData} */ getTweenData: function () { return this._tweenData; }, + /** + * Returns the world information of ccs.Bone. + * @returns {ccs.BaseData} + */ getWorldInfo: function(){ return this._worldInfo; }, /** - * child bone getter + * Returns the children of ccs.Bone * @return {Array} - * @deprecated + * @deprecated since v3.0, please use getChildren instead. */ getChildrenBone: function () { return this._children; }, /** - * @deprecated - * return world transform - * @return {{a:0.b:0,c:0,d:0,tx:0,ty:0}} + * Returns the worldTransform of ccs.Bone. + * @return {cc.AffineTransform} + * @deprecated since v3.0, please use getNodeToArmatureTransform instead. */ nodeToArmatureTransform: function () { return this.getNodeToArmatureTransform(); @@ -576,9 +628,9 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * @deprecated - * get the collider body list in this bone. - * @returns {*} + * Returns the collider body list in this bone. + * @returns {Array|null} + * @deprecated since v3.0, please use getColliderDetector to get a delector, and calls its getColliderBodyList instead. */ getColliderBodyList: function () { var detector = this.getColliderDetector(); @@ -588,8 +640,9 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ }, /** - * ignoreMovementBoneData getter + * Returns whether is ignore movement bone data. * @return {Boolean} + * @deprecated since v3.0, please isIgnoreMovementBoneData instead. */ getIgnoreMovementBoneData: function () { return this.isIgnoreMovementBoneData(); @@ -624,8 +677,7 @@ cc.defineGetterSetter(_p, "colliderFilter", _p.getColliderFilter, _p.setCollider _p = null; /** - * allocates and initializes a bone. - * @constructs + * Allocates and initializes a bone. * @return {ccs.Bone} * @example * // example diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 272d74c3c1..566e24b24b 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -24,7 +24,8 @@ ****************************************************************************/ /** - * movement event type + * movement event type enum + * @constant * @type {Object} */ ccs.MovementEventType = { @@ -32,8 +33,10 @@ ccs.MovementEventType = { complete: 1, loopComplete: 2 }; + /** - * Base class for cc.MovementEvent objects. + * The animation event class, it has the callback, target and arguments. + * @deprecated since v3.0. * @class * @extends ccs.Class */ @@ -43,7 +46,7 @@ ccs.AnimationEvent = ccs.Class.extend(/** @lends ccs.AnimationEvent# */{ _selectorTarget: null, /** - * + * Constructor of ccs.AnimationEvent * @param {function} callFunc * @param {object} target * @param {object} [data] @@ -54,26 +57,36 @@ ccs.AnimationEvent = ccs.Class.extend(/** @lends ccs.AnimationEvent# */{ this._selectorTarget = target; }, call: function () { - if (this._callFunc) { + if (this._callFunc) this._callFunc.apply(this._selectorTarget, this._arguments); - } }, setArguments: function (args) { this._arguments = args; } }); + /** - * movement event + * The movement event class for Armature. * @constructor + * + * @property {ccs.Armature} armature - The armature reference of movement event. + * @property {Number} movementType - The type of movement. + * @property {String} movementID - The ID of movement. */ ccs.MovementEvent = function () { this.armature = null; - this.movementType = ""; + this.movementType = ccs.MovementEventType.start; this.movementID = ""; }; + /** - * frame event + * The frame event class for Armature. * @constructor + * + * @property {ccs.Bone} bone - The bone reference of frame event. + * @property {String} frameEventName - The name of frame event. + * @property {Number} originFrameIndex - The index of origin frame. + * @property {Number} currentFrameIndex - The index of current frame. */ ccs.FrameEvent = function () { this.bone = null; @@ -81,8 +94,9 @@ ccs.FrameEvent = function () { this.originFrameIndex = 0; this.currentFrameIndex = 0; }; + /** - * Base class for ccs.ArmatureAnimation objects. + * The Animation class for Armature, it plays armature animation, and controls speed scale and manages animation frame. * @class * @extends ccs.ProcessBase * @@ -91,7 +105,6 @@ ccs.FrameEvent = function () { * @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, @@ -117,6 +130,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# _movementEventListener: null, _frameEventListener: null, + /** + * The Construction of ccs.ArmatureAnimation + */ ctor: function () { ccs.ProcessBase.prototype.ctor.call(this); @@ -127,7 +143,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * init with a CCArmature + * Initializes with an armature object * @param {ccs.Armature} armature * @return {Boolean} */ @@ -137,6 +153,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# return true; }, + /** + * Pauses armature animation. + */ pause: function () { var locTweenList = this._tweenList; for (var i = 0; i < locTweenList.length; i++) @@ -144,6 +163,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# ccs.ProcessBase.prototype.pause.call(this); }, + /** + * Resumes armature animation. + */ resume: function () { var locTweenList = this._tweenList; for (var i = 0; i < locTweenList.length; i++) @@ -151,6 +173,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# ccs.ProcessBase.prototype.resume.call(this); }, + /** + * Stops armature animation. + */ stop: function () { var locTweenList = this._tweenList; for (var i = 0; i < locTweenList.length; i++) @@ -159,16 +184,26 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# ccs.ProcessBase.prototype.stop.call(this); }, + /** + * Sets animation play speed scale. + * @deprecated since v3.0, please use setSpeedScale instead. + * @param {Number} animationScale + */ setAnimationScale: function (animationScale) { - return this.setSpeedScale(animationScale); + this.setSpeedScale(animationScale); }, + /** + * Returns animation play speed scale. + * @deprecated since v3.0, please use getSpeedScale instead. + * @returns {Number} + */ getAnimationScale: function () { return this.getSpeedScale(); }, /** - * scale animation play speed + * Sets animation play speed scale. * @param {Number} speedScale */ setSpeedScale: function (speedScale) { @@ -185,6 +220,10 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# } }, + /** + * Returns animation play speed scale. + * @returns {Number} + */ getSpeedScale: function () { return this._speedScale; }, @@ -266,12 +305,13 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * Play animation with index, the o ther param is the same to play. + * Plays animation with index, the other param is the same to play. * @param {Number} animationIndex * @param {Number} durationTo * @param {Number} durationTween * @param {Number} loop - * @param {Number} tweenEasing + * @param {Number} [tweenEasing] + * @deprecated since v3.0, please use playWithIndex instead. */ playByIndex: function (animationIndex, durationTo, durationTween, loop, tweenEasing) { cc.log("playByIndex is deprecated. Use playWithIndex instead."); @@ -279,8 +319,8 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * Play animation with index, the other param is the same to play. - * @param {Number||Array} animationIndex + * Plays animation with index, the other param is the same to play. + * @param {Number|Array} animationIndex * @param {Number} durationTo * @param {Number} loop */ @@ -293,7 +333,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * play with names + * Plays animation with names * @param {Array} movementNames * @param {Number} durationTo * @param {Boolean} loop @@ -310,13 +350,12 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._movementList = movementNames; else this._movementList.length = 0; - this.updateMovementList(); }, /** - * play by indexes - * @param movementIndexes + * Plays animation by indexes + * @param {Array} movementIndexes * @param {Number} durationTo * @param {Boolean} loop */ @@ -341,14 +380,16 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * Go to specified frame and play current movement. - * You need first switch to the movement you want to play, then call this function. - * - * example : playByIndex(0); - * gotoAndPlay(0); - * playByIndex(1); - * gotoAndPlay(0); - * gotoAndPlay(15); + *

    + * Goes to specified frame and plays current movement.
    + * You need first switch to the movement you want to play, then call this function.
    + *
    + * example : playByIndex(0);
    + * gotoAndPlay(0);
    + * playByIndex(1);
    + * gotoAndPlay(0);
    + * gotoAndPlay(15);
    + *

    * @param {Number} frameIndex */ gotoAndPlay: function (frameIndex) { @@ -367,15 +408,14 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._currentFrame = this._nextFrameIndex * this._currentPercent; var locTweenList = this._tweenList; - for (var i = 0; i < locTweenList.length; i++) { + for (var i = 0; i < locTweenList.length; i++) locTweenList[i].gotoAndPlay(frameIndex); - } this._armature.update(0); this._ignoreFrameEvent = ignoreFrameEvent; }, /** - * Go to specified frame and pause current movement. + * Goes to specified frame and pauses current movement. * @param {Number} frameIndex */ gotoAndPause: function (frameIndex) { @@ -384,13 +424,17 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * get movement count + * Returns the length of armature's movements * @return {Number} */ getMovementCount: function () { return this._animationData.getMovementCount(); }, + /** + * Updates the state of ccs.Tween list, calls frame event's callback and calls movement event's callback. + * @param {Number} dt + */ update: function (dt) { ccs.ProcessBase.prototype.update.call(this, dt); @@ -420,9 +464,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * update will call this handler, you can handle your logic here + * Updates will call this handler, you can handle your logic here */ - updateHandler: function () { + updateHandler: function () { //TODO set it to protected in v3.1 var locCurrentPercent = this._currentPercent; if (locCurrentPercent >= 1) { switch (this._loopType) { @@ -465,7 +509,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * Get current movementID + * Returns the Id of current movement * @returns {String} */ getCurrentMovementID: function () { @@ -475,7 +519,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * connect a event + * Sets movement event callback to animation. * @param {function} callFunc * @param {Object} target */ @@ -489,7 +533,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * connect a event + * Sets frame event callback to animation. * @param {function} callFunc * @param {Object} target */ @@ -503,7 +547,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * userObject setter + * Sets user object to animation. * @param {Object} userObject */ setUserObject: function (userObject) { @@ -511,6 +555,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** + * Emits a frame event * @param {ccs.Bone} bone * @param {String} frameEventName * @param {Number} originFrameIndex @@ -523,11 +568,16 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# frameEvent.frameEventName = frameEventName; frameEvent.originFrameIndex = originFrameIndex; frameEvent.currentFrameIndex = currentFrameIndex; - this._frameEventQueue.push(frameEvent); } }, + /** + * Emits a movement event + * @param {ccs.Armature} armature + * @param {Number} movementType + * @param {String} movementID + */ movementEvent: function (armature, movementType, movementID) { if ((this._movementEventTarget && this._movementEventCallFunc) || this._movementEventListener) { var event = new ccs.MovementEvent(); @@ -538,6 +588,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# } }, + /** + * Updates movement list. + */ updateMovementList: function () { if (this._onMovementList) { var movementObj, locMovementList = this._movementList; @@ -560,7 +613,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * animationData setter + * Sets animation data to animation. * @param {ccs.AnimationData} data */ setAnimationData: function (data) { @@ -569,7 +622,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * animationData getter + * Returns animation data of animation. * @return {ccs.AnimationData} */ getAnimationData: function () { @@ -577,7 +630,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# }, /** - * userObject getter + * Returns the user object of animation. * @return {Object} */ getUserObject: function () { @@ -606,17 +659,15 @@ cc.defineGetterSetter(_p, "animationScale", _p.getAnimationScale, _p.setAnimatio _p = null; /** - * allocates and initializes a ArmatureAnimation. - * @constructs + * Allocates and initializes a ArmatureAnimation. * @return {ccs.ArmatureAnimation} * @example * // example * var animation = ccs.ArmatureAnimation.create(); */ -ccs.ArmatureAnimation.create = function (armature) { +ccs.ArmatureAnimation.create = function (armature) { //TODO it will be deprecated in v3.1 var animation = new ccs.ArmatureAnimation(); - if (animation && animation.init(armature)) { + if (animation && animation.init(armature)) return animation; - } return null; }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index 9af6f06399..9f2ec90f78 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -23,53 +23,52 @@ THE SOFTWARE. ****************************************************************************/ - //animation type /** - * the animation just have one frame + * The animation just have one frame * @constant * @type {number} */ ccs.ANIMATION_TYPE_SINGLE_FRAME = -4; /** - * the animation isn't loop + * The animation isn't loop * @constant * @type {number} */ ccs.ANIMATION_TYPE_NO_LOOP = -3; /** - * the animation to loop from front + * The animation to loop from front * @constant * @type {number} */ ccs.ANIMATION_TYPE_TO_LOOP_FRONT = -2; /** - * the animation to loop from back + * The animation to loop from back * @constant * @type {number} */ ccs.ANIMATION_TYPE_TO_LOOP_BACK = -1; /** - * the animation loop from front + * The animation loop from front * @constant * @type {number} */ ccs.ANIMATION_TYPE_LOOP_FRONT = 0; /** - * the animation loop from back + * The animation loop from back * @constant * @type {number} */ ccs.ANIMATION_TYPE_LOOP_BACK = 1; /** - * the animation max + * The animation max * @constant * @type {number} */ ccs.ANIMATION_TYPE_MAX = 2; /** - * Base class for ccs.ProcessBase objects. + * The Base Process class for Cocostudio. * @class * @extends ccs.Class * @@ -100,6 +99,9 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ _curFrameIndex: null, _isLoopBack: false, + /** + * Constructor of ccs.ProcessBase + */ ctor: function () { this._processScale = 1; this._isComplete = true; @@ -118,7 +120,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * Pause the Process + * Pauses the Process */ pause: function () { this._isPause = true; @@ -126,7 +128,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * Resume the Process + * Resumes the Process */ resume: function () { this._isPause = false; @@ -134,7 +136,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * Stop the Process + * Stops the Process */ stop: function () { this._isComplete = true; @@ -142,7 +144,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * Play animation by animation name. + * Plays animation by animation name. * @param {Number} durationTo The frames between two animation changing-over. * It's meaning is changing to this animation need how many frames * -1 : use the value from MovementData get from flash design panel @@ -173,6 +175,10 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ this._tweenEasing = tweenEasing; }, + /** + * Update process' state. + * @param {Number} dt + */ update: function (dt) { if (this._isComplete || this._isPause) return; @@ -209,7 +215,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * goto frame + * Goes to specified frame by frameIndex. * @param {Number} frameIndex */ gotoFrame: function (frameIndex) { @@ -224,7 +230,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * get currentFrameIndex + * Returns the index of current frame. * @return {Number} */ getCurrentFrameIndex: function () { @@ -233,14 +239,14 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * update will call this handler, you can handle your logic here + * Updates will call this handler, you can handle your logic here */ updateHandler: function () { //override }, /** - * whether the animation is pause + * Returns whether the animation is pause * @returns {boolean} */ isPause: function () { @@ -248,7 +254,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * whether the animation is complete + * Returns whether the animation is complete * @returns {boolean} */ isComplete: function () { @@ -256,7 +262,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * current percent getter + * Returns current percent of ccs.ProcessBase * @returns {number} */ getCurrentPercent: function () { @@ -264,7 +270,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * rawDuration getter + * Returns the raw duration of ccs.ProcessBase * @returns {number} */ getRawDuration: function () { @@ -272,7 +278,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * loop type getter + * Returns loop type of ccs.ProcessBase * @returns {number} */ getLoop: function () { @@ -280,7 +286,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * tween easing getter + * Returns tween easing of ccs.ProcessBase * @returns {number} */ getTweenEasing: function () { @@ -288,15 +294,15 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * animationInternal getter + * Returns animation interval of ccs.ProcessBase * @returns {number} */ - getAnimationInternal: function () { + getAnimationInternal: function () { //TODO rename getAnimationInternal to getAnimationInterval in v3.1 return this.animationInternal; }, /** - * animationInternal setter + * Sets animation interval to ccs.ProcessBase. * @param animationInternal */ setAnimationInternal: function (animationInternal) { @@ -304,7 +310,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * process scale getter + * Returns process scale * @returns {number} */ getProcessScale: function () { @@ -312,7 +318,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * process scale setter + * Sets process scale * @param processScale */ setProcessScale: function (processScale) { @@ -320,7 +326,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ }, /** - * whether the animation is playing + * Returns whether the animation is playing * @returns {boolean} */ isPlaying: function () { diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 5dfa330286..fb86b5ffd2 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * Base class for ccs.Tween objects. + * The tween class for Armature. * @class * @extends ccs.ProcessBase * @@ -45,13 +45,16 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ _animation:null, _passLastFrame:false, + /** + * Construction of ccs.Tween. + */ ctor:function () { ccs.ProcessBase.prototype.ctor.call(this); this._frameTweenEasing = ccs.TweenType.linear; }, /** - * init with a CCBone + * initializes a ccs.Tween with a CCBone * @param {ccs.Bone} bone * @return {Boolean} */ @@ -70,7 +73,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ }, /** - * Start the Process + * Plays the tween. * @param {ccs.MovementBoneData} movementBoneData * @param {Number} durationTo * @param {Number} durationTween @@ -121,6 +124,10 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this.tweenNodeTo(0); }, + /** + * Goes to specified frame and plays frame. + * @param {Number} frameIndex + */ gotoAndPlay: function (frameIndex) { ccs.ProcessBase.prototype.gotoFrame.call(this, frameIndex); @@ -135,6 +142,10 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._currentFrame = this._nextFrameIndex * this._currentPercent; }, + /** + * Goes to specified frame and pauses frame. + * @param {Number} frameIndex + */ gotoAndPause: function (frameIndex) { this.gotoAndPlay(frameIndex); this.pause(); @@ -217,7 +228,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @param {ccs.FrameData} to * @param {Boolean} [limit=true] */ - setBetween:function (from, to, limit) { + setBetween:function (from, to, limit) { //TODO set tweenColorTo to protected in v3.1 if(limit === undefined) limit = true; do { @@ -245,7 +256,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * Update display index and process the key frame event when arrived a key frame * @param {ccs.FrameData} keyFrameData */ - arriveKeyFrame:function (keyFrameData) { + arriveKeyFrame:function (keyFrameData) { //TODO set tweenColorTo to protected in v3.1 if (keyFrameData) { var locBone = this._bone; var displayManager = locBone.getDisplayManager(); @@ -270,13 +281,14 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ } } }, + /** * According to the percent to calculate current CCFrameData with tween effect * @param {Number} percent * @param {ccs.FrameData} [node] * @return {ccs.FrameData} */ - tweenNodeTo:function (percent, node) { + tweenNodeTo:function (percent, node) { //TODO set tweenColorTo to protected in v3.1 if (!node) node = this._tweenData; @@ -298,7 +310,12 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ return node; }, - tweenColorTo:function(percent,node){ + /** + * According to the percent to calculate current color with tween effect + * @param {Number} percent + * @param {ccs.FrameData} node + */ + tweenColorTo:function(percent,node){ //TODO set tweenColorTo to protected in v3.1 var locFrom = this._from; var locBetween = this._between; node.a = locFrom.a + percent * locBetween.a; @@ -313,7 +330,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @param {Number} currentPercent * @return {Number} */ - updateFrameData:function (currentPercent) { + updateFrameData:function (currentPercent) { //TODO set tweenColorTo to protected in v3.1 if (currentPercent > 1 && this._movementBoneData.delay != 0) currentPercent = ccs.fmodf(currentPercent,1); @@ -385,9 +402,8 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ return currentPercent; }, - /** - * animation setter + * Sets Armature animation to ccs.Tween. * @param {ccs.ArmatureAnimation} animation */ setAnimation:function (animation) { @@ -395,13 +411,17 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ }, /** - * animation getter + * Returns Armature animation of ccs.Tween. * @return {ccs.ArmatureAnimation} */ getAnimation:function () { return this._animation; }, + /** + * Sets movement bone data to ccs.Tween. + * @param data + */ setMovementBoneData: function(data){ this._movementBoneData = data; } @@ -417,15 +437,14 @@ cc.defineGetterSetter(_p, "animation", _p.getAnimation, _p.setAnimation); _p = null; /** - * allocates and initializes a ArmatureAnimation. - * @constructs + * Allocates and initializes a ArmatureAnimation. * @param {ccs.Bone} bone * @return {ccs.Tween} * @example * // example * var animation = ccs.ArmatureAnimation.create(); */ -ccs.Tween.create = function (bone) { +ccs.Tween.create = function (bone) { //TODO it will be deprecated in v3.1 var tween = new ccs.Tween(); if (tween && tween.init(bone)) return tween; From ec6b73fca57a312ad0c3d8bbaa6f3b02ab5f6889 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Sep 2014 10:10:49 +0800 Subject: [PATCH 0609/1564] Fixed #5914: Remote texture is fail --- CCBoot.js | 2 +- cocos2d/core/textures/CCTextureCache.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 2c81d77419..bd9300cc28 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -722,7 +722,7 @@ cc.loader = { cb = option; var img = new Image(); - if (opt.isCrossOrigin && location.origin != "file://") + if (opt.isCrossOrigin && location.origin != "file://", new RegExp(window.location.hostname).test(url)) img.crossOrigin = "Anonymous"; cc._addEventListener(img, "load", function () { diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 9e29557c90..e980a2c0ae 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -343,7 +343,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //remove judge var tex = locTexs[url] || locTexs[cc.loader._aliases[url]]; if (tex) { - cb && cb.call(target); + cb && cb.call(target, tex); return tex; } @@ -359,7 +359,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (err) return cb ? cb(err) : err; cc.textureCache.handleLoadedTexture(url); - cb && cb(target, img); + cb && cb.call(target, tex); }); } } From afee0e85c8d1bdde3eaf9cd326b6428593ca5e10 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Sep 2014 10:13:05 +0800 Subject: [PATCH 0610/1564] Fixed #5914: Remote texture is fail --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index bd9300cc28..50169c1bc4 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -722,7 +722,7 @@ cc.loader = { cb = option; var img = new Image(); - if (opt.isCrossOrigin && location.origin != "file://", new RegExp(window.location.hostname).test(url)) + if (opt.isCrossOrigin && location.origin != "file://" && new RegExp(window.location.hostname).test(url)) img.crossOrigin = "Anonymous"; cc._addEventListener(img, "load", function () { From cc3027d16bca12f6beba5991396d700d5efde616 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 9 Sep 2014 10:35:34 +0800 Subject: [PATCH 0611/1564] Remove removeAllChildrenWithCleanup's deprecated tag for uniting with -x --- cocos2d/core/base-nodes/CCNode.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 63973e57b4..87304fe7b9 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1371,11 +1371,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. - * @deprecated since v3.0, please use removeAllChildren() instead * @param {Boolean | null } cleanup */ removeAllChildrenWithCleanup: function (cleanup) { - cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup); + //cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup); //TODO It should be discuss in v3.0 this.removeAllChildren(cleanup); }, From 37a6631466f2b3893fa47ad26cc055e4e14dd3e4 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 9 Sep 2014 11:16:00 +0800 Subject: [PATCH 0612/1564] Issue #5894: adds Cocostudio datas' jsDocs --- .../cocostudio/armature/datas/CCDatas.js | 165 ++++++++++++++---- 1 file changed, 134 insertions(+), 31 deletions(-) diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index 296e198bf0..ec4fad918c 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -122,27 +122,55 @@ ccs.BLEND_TYPE_ALPHA = 12; */ ccs.BLEND_TYPE_ERASE = 13; - //DisplayType +/** + * The Sprite flag of display render type. + * @constant + * @type Number + */ ccs.DISPLAY_TYPE_SPRITE = 0; +/** + * The Armature flag of display render type. + * @constant + * @type Number + */ ccs.DISPLAY_TYPE_ARMATURE = 1; +/** + * The Particle flag of display render type. + * @constant + * @type Number + */ ccs.DISPLAY_TYPE_PARTICLE = 2; ccs.DISPLAY_TYPE_MAX = 3; /** - * Base class for ccs.BaseData objects. + *

    + * The base data class for Armature. it contains position, zOrder, skew, scale, color datas.
    + * x y skewX skewY scaleX scaleY used to calculate transform matrix
    + * skewX, skewY can have rotation effect
    + * To get more matrix information, you can have a look at this pape : http://www.senocular.com/flash/tutorials/transformmatrix/
    + *

    * @class * @extends ccs.Class + * + * @property {Number} x - x + * @property {Number} y - y + * @property {Number} zOrder - zOrder + * @property {Number} skewX - skewX + * @property {Number} skewY - skewY + * @property {Number} scaleX - scaleX + * @property {Number} scaleY - scaleY + * @property {Number} tweenRotate - tween Rotate + * @property {Number} isUseColorInfo - is Use Color Info + * @property {Number} r - r of color + * @property {Number} g - g of color + * @property {Number} b - b of color + * @property {Number} a - a of color */ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ x:0, y:0, zOrder:0, - /** - * x y skewX skewY scaleX scaleY used to calculate transform matrix - * skewX, skewY can have rotation effect - * To get more matrix information, you can have a look at this pape : http://www.senocular.com/flash/tutorials/transformmatrix/ - */ skewX:0, skewY:0, scaleX:1, @@ -154,6 +182,9 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ b:255, a:255, + /** + * Construction of ccs.BaseData + */ ctor:function () { this.x = 0; this.y = 0; @@ -195,7 +226,7 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ }, /** - * color setter + * Sets color to base data. * @function * @param {cc.Color} color */ @@ -207,7 +238,7 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ }, /** - * color getter + * Returns the color of ccs.BaseData * @function * @returns {cc.Color} */ @@ -260,18 +291,25 @@ ccs.BaseData = ccs.Class.extend(/** @lends ccs.BaseData# */{ }); /** - * Base class for ccs.DisplayData objects. + * The class use for save display data. * @class * @extends ccs.Class + * + * @property {Number} displayType - the display type + * @property {String} displayName - the display name */ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ displayType: ccs.DISPLAY_TYPE_MAX, displayName: "", + + /** + * Construction of ccs.DisplayData + */ ctor: function () { this.displayType = ccs.DISPLAY_TYPE_MAX; }, /** - * change display name to texture type + * Changes display name to texture type * @function * @param {String} displayName * @returns {String} @@ -285,6 +323,7 @@ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ textureName = textureName.substring(0, startPos); return textureName; }, + /** * copy data * @function @@ -297,12 +336,18 @@ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ }); /** - * Base class for ccs.SpriteDisplayData objects. + * The sprite display data class. * @class * @extends ccs.DisplayData + * + * @property {ccs.BaseData} skinData - the skin data */ ccs.SpriteDisplayData = ccs.DisplayData.extend(/** @lends ccs.SpriteDisplayData# */{ skinData:null, + + /** + * Construction of ccs.SpriteDisplayData + */ ctor:function () { this.skinData = new ccs.BaseData(); this.displayType = ccs.DISPLAY_TYPE_SPRITE; @@ -315,19 +360,18 @@ ccs.SpriteDisplayData = ccs.DisplayData.extend(/** @lends ccs.SpriteDisplayData# copy:function (displayData) { ccs.DisplayData.prototype.copy.call(this,displayData); this.skinData = displayData.skinData; - }, - SpriteDisplayData: function(){ - this.displayType = ccs.DISPLAY_TYPE_SPRITE; } }); /** - * Base class for ccs.ArmatureDisplayData objects. + * The armature display data class * @class ccs.ArmatureDisplayData * @extends ccs.DisplayData */ ccs.ArmatureDisplayData = ccs.DisplayData.extend(/** @lends ccs.ArmatureDisplayData# */{ - displayName:"", + /** + * Construction of ccs.ArmatureDisplayData + */ ctor:function () { this.displayName = ""; this.displayType = ccs.DISPLAY_TYPE_ARMATURE; @@ -335,11 +379,14 @@ ccs.ArmatureDisplayData = ccs.DisplayData.extend(/** @lends ccs.ArmatureDisplayD }); /** - * Base class for ccs.ParticleDisplayData objects. + * The particle display data class. * @class ccs.ParticleDisplayData * @extends ccs.DisplayData */ ccs.ParticleDisplayData = ccs.DisplayData.extend(/** @lends ccs.ParticleDisplayData# */{ + /** + * Construction of ccs.ParticleDisplayData + */ ctor:function () { this.displayType = ccs.DISPLAY_TYPE_PARTICLE; } @@ -353,6 +400,11 @@ ccs.ParticleDisplayData = ccs.DisplayData.extend(/** @lends ccs.ParticleDisplayD *

    * @class ccs.BoneData * @extends ccs.BaseData + * + * @property {Array} displayDataList - the display data list + * @property {String} name - the name of Bone + * @property {String} parentName - the parent name of bone + * @property {cc.AffineTransform} boneDataTransform - the bone transform data */ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ displayDataList: null, @@ -360,20 +412,26 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ parentName: "", boneDataTransform: null, + /** + * Construction of ccs.BoneData + */ ctor: function () { this.displayDataList = []; this.name = ""; this.parentName = ""; this.boneDataTransform = null; - }, + /** + * Initializes a ccs.BoneData + * @returns {boolean} + */ init: function () { this.displayDataList.length = 0; return true; }, /** - * add display data + * Adds display data to list * @function * @param {ccs.DisplayData} displayData */ @@ -382,7 +440,7 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ }, /** - * get display data + * Returns display data with index. * @function * @param {Number} index * @returns {ccs.DisplayData} @@ -400,35 +458,50 @@ ccs.BoneData = ccs.BaseData.extend(/** @lends ccs.BoneData# */{ *

    * @class ccs.ArmatureData * @extends ccs.Class + * + * @property {Object} boneDataDic - the bone data dictionary + * @property {String} name - the name of armature data + * @property {Number} dataVersion - the data version of armature data */ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ boneDataDic:null, name:"", dataVersion:0.1, + + /** + * Construction of ccs.ArmatureData + */ ctor:function () { this.boneDataDic = {}; this.name = ""; this.dataVersion = 0.1; }, + + /** + * Initializes a ccs.ArmatureData + * @returns {boolean} + */ init:function () { return true; }, + /** - * adds bone data to dictionary + * Adds bone data to dictionary * @param {ccs.BoneData} boneData */ addBoneData:function (boneData) { this.boneDataDic[boneData.name] = boneData; }, + /** - * gets bone data dictionary + * Gets bone data dictionary * @returns {Object} */ getBoneDataDic:function () { return this.boneDataDic; }, /** - * get bone data by bone name + * Gets bone data by bone name * @function * @param {String} boneName * @returns {ccs.BoneData} @@ -439,9 +512,22 @@ ccs.ArmatureData = ccs.Class.extend(/** @lends ccs.ArmatureData# */{ }); /** - * Base class for ccs.FrameData objects. + * FrameData saved the frame data needed for armature animation in this Armature. * @class ccs.FrameData * @extends ccs.BaseData + * + * @property {Number} duration - the duration of frame + * @property {Number} tweenEasing - the easing type of frame + * @property {Number} easingParamNumber - the count of easing parameters. + * @property {Object} easingParams - the dictionary of easing parameters. + * @property {Number} displayIndex - the display renderer index. + * @property {String} movement - the movement name. + * @property {String} event - the event name + * @property {String} sound - the sound path. + * @property {String} soundEffect - the sound effect path. + * @property {Object} blendFunc - the blendFunc of frame. + * @property {Number} frameID - the frame ID of frame + * @property {Boolean} isTween - the flag which frame whether is tween. */ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ duration:0, @@ -453,10 +539,13 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ event:"", sound:"", soundEffect:"", - blendFunc:0, + blendFunc:null, frameID:0, isTween:true, + /** + * Construction of ccs.FrameData. + */ ctor:function () { ccs.BaseData.prototype.ctor.call(this); this.duration = 1; @@ -492,6 +581,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ // this.soundEffect = frameData.soundEffect; // this.easingParams.length = 0; if (this.easingParamNumber != 0){ + this.easingParams.length = 0; for (var i = 0; i Date: Tue, 9 Sep 2014 11:17:58 +0800 Subject: [PATCH 0613/1564] Fixed #5914: Remote texture is fail --- CCBoot.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 50169c1bc4..a827edc8bc 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -722,20 +722,24 @@ cc.loader = { cb = option; var img = new Image(); - if (opt.isCrossOrigin && location.origin != "file://" && new RegExp(window.location.hostname).test(url)) + if (opt.isCrossOrigin && location.origin != "file://") img.crossOrigin = "Anonymous"; - cc._addEventListener(img, "load", function () { - this.removeEventListener('load', arguments.callee, false); - this.removeEventListener('error', arguments.callee, false); + var lcb = function () { + this.removeEventListener('load', lcb, false); + this.removeEventListener('error', ecb, false); if (cb) cb(null, img); - }); - cc._addEventListener(img, "error", function () { - this.removeEventListener('error', arguments.callee, false); + }; + + var ecb = function (msg) { + this.removeEventListener('error', ecb, false); if (cb) cb("load image failed"); - }); + }; + + cc._addEventListener(img, "load", lcb); + cc._addEventListener(img, "error", ecb); img.src = url; return img; }, From f64c95d28543f7773b0a4c4c686e67c6738b1056 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Sep 2014 11:55:47 +0800 Subject: [PATCH 0614/1564] Fixed #5914: Remote texture is fail --- CCBoot.js | 12 +++++++++--- cocos2d/core/textures/CCTextureCache.js | 3 ++- cocos2d/core/textures/TexturesWebGL.js | 7 ++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index a827edc8bc..96d017fa9b 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -732,10 +732,16 @@ cc.loader = { cb(null, img); }; - var ecb = function (msg) { + var ecb = function () { this.removeEventListener('error', ecb, false); - if (cb) - cb("load image failed"); + + if(img.crossOrigin.toLowerCase() == "anonymous"){ + opt.isCrossOrigin = false; + cc.loader.loadImg(url, opt, cb); + }else{ + typeof cb == "function" && cb("load image failed"); + } + }; cc._addEventListener(img, "load", lcb); diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index e980a2c0ae..a8290816c7 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -355,9 +355,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cb && cb.call(target); }); } else { - cc.loader.cache[url] = cc.loader.loadImg(url, function (err, img) { + cc.loader.loadImg(url, function (err, img) { if (err) return cb ? cb(err) : err; + cc.loader.cache[url] = img; cc.textureCache.handleLoadedTexture(url); cb && cb.call(target, tex); }); diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index f49a864c45..da092a1c8c 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -919,7 +919,7 @@ cc._tmp.WebGLTextureCache = function () { } var tex = locTexs[url] || locTexs[cc.loader._aliases[url]]; if (tex) { - cb && cb.call(target); + cb && cb.call(target, tex); return tex; } @@ -929,11 +929,12 @@ cc._tmp.WebGLTextureCache = function () { cb && cb.call(target); }); } else { - cc.loader.cache[url] = cc.loader.loadImg(url, function (err, img) { + cc.loader.loadImg(url, function (err, img) { if (err) return cb ? cb(err) : err; + cc.loader.cache[url] = img; cc.textureCache.handleLoadedTexture(url); - cb && cb(target, img); + cb && cb.call(target, tex); }); } } From f24d082b7bf3be1d2cc2148d50a410916914975d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Sep 2014 13:51:34 +0800 Subject: [PATCH 0615/1564] Issue #5906: The NO_BORDER coordinate system, the scaling error --- cocos2d/core/platform/CCEGLView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 1bdbd4d9a2..5ad4f1295d 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -511,7 +511,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ // reset director's member variables to fit visible rect var director = cc.director; director._winSizeInPoints.width = _t._designResolutionSize.width; - director._winSizeInPoints.heihgt = _t._designResolutionSize.heihgt; + director._winSizeInPoints.height = _t._designResolutionSize.height; cc.winSize.width = director._winSizeInPoints.width; cc.winSize.height = director._winSizeInPoints.height; From 44ac9ae7c888ab47f8b9edef0edf9f9e56e7cb14 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Sep 2014 14:48:36 +0800 Subject: [PATCH 0616/1564] Issue #5901: Facebook SDK Web's appRequest action info parameter seems wrap wrong informations --- external/pluginx/platform/facebook.js | 45 --------------------------- 1 file changed, 45 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 119e8bed58..43a15e2970 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -443,51 +443,6 @@ plugin.extend('facebook', { info['method'] = "apprequests"; delete info['dialog']; - info['name'] = info['site'] || info['name']; - delete info['site']; - - info['href'] = info['siteUrl'] || info['link']; - delete info['siteUrl']; - delete info['link']; - - info['image'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; - delete info['imageUrl']; - delete info['imagePath']; - delete info['photo']; - - - info['caption'] = info['title'] || info['caption']; - delete info['title']; - - info['description'] = info['text'] || info['description']; - delete info['text']; - delete info['description']; - - if(info['method'] == 'share_open_graph' && info['url']){ - if(info['url']){ - var obj = {}; - if(info["preview_property"]) - obj[info["preview_property"]] = info["url"]; - else - obj["object"] = info["url"]; - - for(var p in info){ - if(p != "method" && p != "action_type" && p != "action_properties"){ - info[p] && (obj[p] = info[p]); - delete info[p]; - } - } - - info['action_properties'] = JSON.stringify(obj); - }else{ - return; - } - }else{ - if(!info['href']){ - return; - } - } - if( info['method'] != 'apprequests' ){ From 6fdf8273ba4a61db626d20a653e076c65a88ed4a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 9 Sep 2014 15:13:30 +0800 Subject: [PATCH 0617/1564] Docs #5883: Complete jsb apis --- jsb_apis.js | 258 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 209 insertions(+), 49 deletions(-) diff --git a/jsb_apis.js b/jsb_apis.js index e9fa16f8cd..47818ce72d 100644 --- a/jsb_apis.js +++ b/jsb_apis.js @@ -29,16 +29,18 @@ var jsb = jsb || {}; /** - * @type {Object} - * @name jsb.fileUtils - * jsb.fileUtils is the native file utils singleton object, - * please refer to Cocos2d-x API to know how to use it. + * ATTENTION: USE jsb.fileUtils INSTEAD OF jsb.FileUtils.
    + * jsb.fileUtils is the native file utils' singleton object,
    + * please refer to Cocos2d-x's API to know how to use it.
    * Only available in JSB + * @class + * @name jsb.fileUtils + * @extend cc.Class */ -jsb.fileUtils = { +jsb.fileUtils = /** @lends jsb.FileUtils# */{ /** - * @method fullPathForFilename + * @function fullPathForFilename * @param {String} arg0 * @return {String} */ @@ -48,7 +50,7 @@ jsb.fileUtils = { }, /** - * @method getStringFromFile + * @function getStringFromFile * @param {String} arg0 * @return {String} */ @@ -58,7 +60,7 @@ jsb.fileUtils = { }, /** - * @method removeFile + * @function removeFile * @param {String} arg0 * @return {bool} */ @@ -68,7 +70,7 @@ jsb.fileUtils = { }, /** - * @method isAbsolutePath + * @function isAbsolutePath * @param {String} arg0 * @return {bool} */ @@ -78,7 +80,7 @@ jsb.fileUtils = { }, /** - * @method renameFile + * @function renameFile * @param {String} arg0 * @param {String} arg1 * @param {String} arg2 @@ -90,7 +92,7 @@ jsb.fileUtils = { }, /** - * @method loadFilenameLookupDictionaryFromFile + * @function loadFilenameLookupDictionaryFromFile * @param {String} arg0 */ loadFilenameLookupDictionaryFromFile : function (str) @@ -98,7 +100,7 @@ jsb.fileUtils = { }, /** - * @method isPopupNotify + * @function isPopupNotify * @return {bool} */ isPopupNotify : function () @@ -107,7 +109,7 @@ jsb.fileUtils = { }, /** - * @method getValueVectorFromFile + * @function getValueVectorFromFile * @param {String} arg0 * @return {Array} */ @@ -117,7 +119,7 @@ jsb.fileUtils = { }, /** - * @method getSearchPaths + * @function getSearchPaths * @return {Array} */ getSearchPaths : function () @@ -126,7 +128,7 @@ jsb.fileUtils = { }, /** - * @method writeToFile + * @function writeToFile * @param {map_object} arg0 * @param {String} arg1 * @return {bool} @@ -137,7 +139,7 @@ jsb.fileUtils = { }, /** - * @method getValueMapFromFile + * @function getValueMapFromFile * @param {String} arg0 * @return {map_object} */ @@ -147,7 +149,7 @@ jsb.fileUtils = { }, /** - * @method getFileSize + * @function getFileSize * @param {String} arg0 * @return {long} */ @@ -157,7 +159,7 @@ jsb.fileUtils = { }, /** - * @method removeDirectory + * @function removeDirectory * @param {String} arg0 * @return {bool} */ @@ -167,7 +169,7 @@ jsb.fileUtils = { }, /** - * @method setSearchPaths + * @function setSearchPaths * @param {Array} arg0 */ setSearchPaths : function (array) @@ -175,7 +177,7 @@ jsb.fileUtils = { }, /** - * @method writeStringToFile + * @function writeStringToFile * @param {String} arg0 * @param {String} arg1 * @return {bool} @@ -186,7 +188,7 @@ jsb.fileUtils = { }, /** - * @method setSearchResolutionsOrder + * @function setSearchResolutionsOrder * @param {Array} arg0 */ setSearchResolutionsOrder : function (array) @@ -194,7 +196,7 @@ jsb.fileUtils = { }, /** - * @method addSearchResolutionsOrder + * @function addSearchResolutionsOrder * @param {String} arg0 */ addSearchResolutionsOrder : function (str) @@ -202,7 +204,7 @@ jsb.fileUtils = { }, /** - * @method addSearchPath + * @function addSearchPath * @param {String} arg0 */ addSearchPath : function (str) @@ -210,7 +212,7 @@ jsb.fileUtils = { }, /** - * @method isFileExist + * @function isFileExist * @param {String} arg0 * @return {bool} */ @@ -220,14 +222,14 @@ jsb.fileUtils = { }, /** - * @method purgeCachedEntries + * @function purgeCachedEntries */ purgeCachedEntries : function () { }, /** - * @method fullPathFromRelativeFile + * @function fullPathFromRelativeFile * @param {String} arg0 * @param {String} arg1 * @return {String} @@ -238,7 +240,7 @@ jsb.fileUtils = { }, /** - * @method isDirectoryExist + * @function isDirectoryExist * @param {String} arg0 * @return {bool} */ @@ -248,7 +250,7 @@ jsb.fileUtils = { }, /** - * @method getSearchResolutionsOrder + * @function getSearchResolutionsOrder * @return {Array} */ getSearchResolutionsOrder : function () @@ -257,7 +259,7 @@ jsb.fileUtils = { }, /** - * @method createDirectory + * @function createDirectory * @param {String} arg0 * @return {bool} */ @@ -267,7 +269,7 @@ jsb.fileUtils = { }, /** - * @method createDirectories + * @function createDirectories * @param {String} arg0 * @return {bool} */ @@ -277,7 +279,7 @@ jsb.fileUtils = { }, /** - * @method getWritablePath + * @function getWritablePath * @return {String} */ getWritablePath : function () @@ -287,6 +289,164 @@ jsb.fileUtils = { }; +/** + * @class EventAssetsManager + */ +jsb.EventAssetsManager = { + + /** + * @function getAssetsManager + * @return {cc.AssetsManager} + */ + getAssetsManager : function ( + ) + { + return cc.AssetsManager; + }, + + /** + * @function getAssetId + * @return {String} + */ + getAssetId : function ( + ) + { + return ; + }, + + /** + * @function getCURLECode + * @return {int} + */ + getCURLECode : function ( + ) + { + return 0; + }, + + /** + * @function getMessage + * @return {String} + */ + getMessage : function ( + ) + { + return ; + }, + + /** + * @function getCURLMCode + * @return {int} + */ + getCURLMCode : function ( + ) + { + return 0; + }, + + /** + * @function getPercentByFile + * @return {float} + */ + getPercentByFile : function ( + ) + { + return 0; + }, + + /** + * @function getEventCode + * @return {cc.EventAssetsManager::EventCode} + */ + getEventCode : function ( + ) + { + return 0; + }, + + /** + * @function getPercent + * @return {float} + */ + getPercent : function ( + ) + { + return 0; + }, + + /** + * @function EventAssetsManager + * @constructor + * @param {String} arg0 + * @param {cc.AssetsManager} arg1 + * @param {cc.EventAssetsManager::EventCode} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @param {String} arg5 + * @param {String} arg6 + * @param {int} arg7 + * @param {int} arg8 + */ + EventAssetsManager : function ( + str, + assetsmanager, + eventcode, + float, + float, + str, + str, + int, + int + ) + { + } +}; + + +/** + * @class EventListenerAssetsManager + */ +jsb.EventListenerAssetsManager = { + + /** + * @function init + * @param {cc.AssetsManager} arg0 + * @param {function} arg1 + * @return {bool} + */ + init : function ( + assetsmanager, + func + ) + { + return false; + }, + + /** + * @function create + * @param {cc.AssetsManager} arg0 + * @param {function} arg1 + * @return {cc.EventListenerAssetsManager} + */ + create : function ( + assetsmanager, + func + ) + { + return cc.EventListenerAssetsManager; + }, + + /** + * @function EventListenerAssetsManager + * @constructor + */ + EventListenerAssetsManager : function ( + ) + { + } + +}; + /** * @class jsb.AssetsManager * jsb.AssetsManager is the native AssetsManager for your game resources or scripts. @@ -296,7 +456,7 @@ jsb.fileUtils = { jsb.AssetsManager = { /** - * @method getState + * @function getState * @return {jsb.AssetsManager::State} */ getState : function () @@ -305,14 +465,14 @@ jsb.AssetsManager = { }, /** - * @method checkUpdate + * @function checkUpdate */ checkUpdate : function () { }, /** - * @method getStoragePath + * @function getStoragePath * @return {String} */ getStoragePath : function () @@ -321,14 +481,14 @@ jsb.AssetsManager = { }, /** - * @method update + * @function update */ update : function () { }, /** - * @method getLocalManifest + * @function getLocalManifest * @return {jsb.Manifest} */ getLocalManifest : function () @@ -337,7 +497,7 @@ jsb.AssetsManager = { }, /** - * @method getRemoteManifest + * @function getRemoteManifest * @return {jsb.Manifest} */ getRemoteManifest : function () @@ -346,14 +506,14 @@ jsb.AssetsManager = { }, /** - * @method downloadFailedAssets + * @function downloadFailedAssets */ downloadFailedAssets : function () { }, /** - * @method create + * @function create * @param {String} arg0 * @param {String} arg1 * @return {jsb.AssetsManager} @@ -364,7 +524,7 @@ jsb.AssetsManager = { }, /** - * @method AssetsManager + * @function AssetsManager * @constructor * @param {String} arg0 * @param {String} arg1 @@ -381,7 +541,7 @@ jsb.AssetsManager = { jsb.Manifest = { /** - * @method getManifestFileUrl + * @function getManifestFileUrl * @return {String} */ getManifestFileUrl : function () @@ -390,7 +550,7 @@ jsb.Manifest = { }, /** - * @method isVersionLoaded + * @function isVersionLoaded * @return {bool} */ isVersionLoaded : function () @@ -399,7 +559,7 @@ jsb.Manifest = { }, /** - * @method isLoaded + * @function isLoaded * @return {bool} */ isLoaded : function () @@ -408,7 +568,7 @@ jsb.Manifest = { }, /** - * @method getPackageUrl + * @function getPackageUrl * @return {String} */ getPackageUrl : function () @@ -417,7 +577,7 @@ jsb.Manifest = { }, /** - * @method getVersion + * @function getVersion * @return {String} */ getVersion : function () @@ -426,7 +586,7 @@ jsb.Manifest = { }, /** - * @method getVersionFileUrl + * @function getVersionFileUrl * @return {String} */ getVersionFileUrl : function () @@ -440,11 +600,11 @@ jsb.Manifest = { * @name jsb.reflection * jsb.reflection is a bridge to let you invoke Java static functions. * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/reflection/en - * Only available on Android platform + * Only available on iOS/Mac/Android platform */ -jsb.reflection = { +jsb.reflection = /** @lends jsb.reflection# */{ /** - * @method callStaticMethod + * @function callStaticMethod */ callStaticMethod : function(){ } From 301a65eeee7f7148abcb8656d4cc9f325afecaa7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 9 Sep 2014 16:28:26 +0800 Subject: [PATCH 0618/1564] Fixed #5894: adds jsDocs to armature display and utils --- extensions/ccui/uiwidgets/UITextField.js | 2 +- .../armature/display/CCDecorativeDisplay.js | 21 ++- .../armature/display/CCDisplayManager.js | 55 ++++++- .../cocostudio/armature/display/CCSkin.js | 36 ++++ .../armature/physics/CCColliderDetector.js | 5 +- .../armature/utils/CCArmatureDataManager.js | 112 +++++-------- .../armature/utils/CCArmatureDefine.js | 4 + .../armature/utils/CCDataReaderHelper.js | 155 +++++++++++++++++- .../utils/CCSpriteFrameCacheHelper.js | 15 +- .../armature/utils/CCTransformHelp.js | 3 +- tools/jsdoc_toolkit/build.xml | 1 + 11 files changed, 325 insertions(+), 84 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 37d9c3912a..c2ded41bc2 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -346,7 +346,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {String} text */ setString: function (text) { - if (!text) + if (text == null) return; text = String(text); diff --git a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js index df21377f27..3a3b3116b6 100644 --- a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +++ b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js @@ -33,18 +33,25 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ _colliderDetector: null, _displayData: null, + /** + * Construction of ccs.DecorativeDisplay + */ ctor:function () { this._display = null; this._colliderDetector = null; this._displayData = null; }, + /** + * Initializes a ccs.DecorativeDisplay + * @returns {boolean} + */ init:function () { return true; }, /** - * sets display node + * Sets display node to decorative * @param {cc.Node} display */ setDisplay:function (display) { @@ -52,7 +59,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * gets the display node + * Returns the display node * @returns {cc.Node} */ getDisplay:function () { @@ -60,7 +67,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * sets collide detector + * Sets collide detector * @param {ccs.ColliderDetector} colliderDetector */ setColliderDetector:function (colliderDetector) { @@ -68,7 +75,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * sets collide detector + * Returns collide detector * @returns {ccs.ColliderDetector} */ getColliderDetector:function () { @@ -76,7 +83,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * sets display data + * Sets display data * @param {ccs.DisplayData} displayData */ setDisplayData:function (displayData) { @@ -84,7 +91,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }, /** - * gets display data + * Returns display data * @returns {ccs.DisplayData} */ getDisplayData:function () { @@ -99,7 +106,7 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ }); /** - * allocates and initializes a decorative display. + * Allocates and initializes a decorative display. * @return {ccs.DecorativeDisplay} * @example * // example diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 2430a92d3a..11f53cb9ad 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * The display manager of CocoStudio + * The display manager for CocoStudio Armature bone. * @Class ccs.DisplayManager * @extend cc.Class */ @@ -38,6 +38,9 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ _visible:true, _displayType: null, + /** + * Construction of ccs.DisplayManager. + */ ctor:function () { this._decoDisplayList = []; this._currentDecoDisplay = null; @@ -49,6 +52,11 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this._displayType = ccs.DISPLAY_TYPE_MAX; }, + /** + * Initializes a ccs.DisplayManager. + * @param bone + * @returns {boolean} + */ init:function (bone) { this._bone = bone; this.initDisplayList(bone.getBoneData()); @@ -177,6 +185,10 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ decoDisplay.setDisplayData(displayData); }, + /** + * Removes display node from list. + * @param {Number} index + */ removeDisplay:function (index) { this._decoDisplayList.splice(index, 1); if (index === this._displayIndex) { @@ -185,6 +197,10 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ } }, + /** + * Returns the display node list. + * @returns {Array} + */ getDecorativeDisplayList:function(){ return this._decoDisplayList; }, @@ -196,7 +212,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ * Note : if index is the same with prev index, the method will not effect
    *

    * @param {Number} index The index of the display you want to change - * @param {Number} force If true, then force change display to specified display, or current display will set to display index edit in the flash every key frame. + * @param {Boolean} force If true, then force change display to specified display, or current display will set to display index edit in the flash every key frame. */ changeDisplayWithIndex:function (index, force) { if (index >= this._decoDisplayList.length) { @@ -222,6 +238,11 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this.setCurrentDecorativeDisplay(this._decoDisplayList[index]); }, + /** + * Change display by name. @see changeDisplayWithIndex. + * @param {String} name + * @param {Boolean} force + */ changeDisplayWithName: function (name, force) { var locDisplayList = this._decoDisplayList; for (var i = 0; i < locDisplayList.length; i++) { @@ -232,6 +253,10 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ } }, + /** + * Sets current decorative display. + * @param {ccs.DecorativeDisplay} decoDisplay + */ setCurrentDecorativeDisplay:function (decoDisplay) { var locCurrentDecoDisplay = this._currentDecoDisplay; if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { @@ -277,22 +302,43 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this._displayType = ccs.DISPLAY_TYPE_MAX; }, + /** + * Returns the current display render node. + * @returns {cc.Node} + */ getDisplayRenderNode:function () { return this._displayRenderNode; }, + /** + * Returns the type of display render node. + * @returns {Number} + */ getDisplayRenderNodeType:function(){ return this._displayType; }, + /** + * Returns the index of display render node. + * @returns {Number} + */ getCurrentDisplayIndex:function () { return this._displayIndex; }, + /** + * Returns the current decorative display + * @returns {ccs.DecorativeDisplay} + */ getCurrentDecorativeDisplay:function () { return this._currentDecoDisplay; }, + /** + * Gets a decorative display by index. + * @param index + * @returns {ccs.DecorativeDisplay} + */ getDecorativeDisplayByIndex:function (index) { return this._decoDisplayList[index]; }, @@ -404,6 +450,11 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ } }); +/** + * Allocates and initializes a display manager with ccs.Bone. + * @param {ccs.Bone} bone + * @returns {ccs.DisplayManager} + */ ccs.DisplayManager.create = function (bone) { var displayManager = new ccs.DisplayManager(); if (displayManager && displayManager.init(bone)) diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 78e2c6cf78..c804c3b08b 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -41,6 +41,9 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ _armature: null, _className: "Skin", + /** + * Construction of ccs.Skin. + */ ctor: function () { cc.Sprite.prototype.ctor.call(this); this._skinData = null; @@ -50,6 +53,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this._armature = null; }, + /** + * Initializes with sprite frame name + * @param {String} spriteFrameName + * @returns {Boolean} + */ initWithSpriteFrameName: function (spriteFrameName) { if(spriteFrameName == "") return false; @@ -65,12 +73,21 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return ret; }, + /** + * Initializes with texture file name. + * @param {String} fileName + * @returns {Boolean} + */ initWithFile: function (fileName) { var ret = cc.Sprite.prototype.initWithFile.call(this, fileName); this._displayName = fileName; return ret; }, + /** + * Sets skin data to ccs.Skin. + * @param {ccs.BaseData} skinData + */ setSkinData: function (skinData) { this._skinData = skinData; this.setScaleX(skinData.scaleX); @@ -90,10 +107,17 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this.updateArmatureTransform(); }, + /** + * Returns skin date of ccs.Skin. + * @returns {ccs.BaseData} + */ getSkinData: function () { return this._skinData; }, + /** + * Updates armature skin's transform with skin transform and bone's transform. + */ updateArmatureTransform: function () { this._transform = cc.affineTransformConcat( this._skinTransform, @@ -168,6 +192,10 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return __ARGS__; }, + /** + * Returns skin's world transform. + * @returns {cc.AffineTransform} + */ getNodeToWorldTransform: function(){ return cc.affineTransformConcat(this._transform,this.bone.getArmature().getNodeToWorldTransform()); }, @@ -180,6 +208,10 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return cc.affineTransformConcat( displayTransform,this.bone.getArmature().nodeToWorldTransform()); }, + /** + * Sets the bone reference to ccs.Skin. + * @param bone + */ setBone: function (bone) { this.bone = bone; var armature = this.bone.getArmature(); @@ -187,6 +219,10 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this._armature = armature; }, + /** + * Returns the bone reference of ccs.Skin. + * @returns {null} + */ getBone: function () { return this.bone; }, diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index 3408013866..6b366bde77 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -27,6 +27,7 @@ * @ignore */ ccs.PT_RATIO = 32; + /** * Base class for ccs.ColliderFilter * @class @@ -38,16 +39,17 @@ ccs.ColliderFilter = ccs.Class.extend(/** @lends ccs.ColliderFilter# */{ _categoryBits: 0, _groupIndex: 0, _maskBits: 0, + ctor: function (collisionType, group) { this._collisionType = collisionType || 0; this._group = group || 0; }, + updateShape: function (shape) { if(shape instanceof cp.Shape){ shape.collision_type = this._collisionType; shape.group = this._group; }else if(shape instanceof Box2D.b2FilterData){ - var filter = new Box2D.b2FilterData(); filter.categoryBits = this._categoryBits; filter.groupIndex = this._groupIndex; @@ -57,6 +59,7 @@ ccs.ColliderFilter = ccs.Class.extend(/** @lends ccs.ColliderFilter# */{ } } }); + /** * Base class for ccs.ColliderBody * @class diff --git a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js index 1e972b23f4..89f06fb2d0 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDataManager.js @@ -24,7 +24,7 @@ ****************************************************************************/ /** - * RelativeData + * RelativeData uses to save plist files, armature files, animations and textures for armature data manager. * @constructor */ ccs.RelativeData = function(){ @@ -41,7 +41,7 @@ ccs.RelativeData = function(){ */ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ _animationDatas: {}, - _armarureDatas: {}, + _armatureDatas: {}, _textureDatas: {}, _autoLoadSpriteFile: false, _relativeDatas: {}, @@ -49,26 +49,27 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ s_sharedArmatureDataManager: null, /** - * remove armature cache data by configFilePath + * Removes armature cache data by configFilePath * @param {String} configFilePath */ removeArmatureFileInfo:function(configFilePath){ var data = this.getRelativeData(configFilePath); if(data){ - for (var i = 0; i < data.armatures.length; i++) { - var obj = data.armatures[i]; + var i, obj; + for (i = 0; i < data.armatures.length; i++) { + obj = data.armatures[i]; this.removeArmatureData(obj); } - for (var i = 0; i < data.animations.length; i++) { - var obj = data.animations[i]; + for ( i = 0; i < data.animations.length; i++) { + obj = data.animations[i]; this.removeAnimationData(obj); } - for (var i = 0; i < data.textures.length; i++) { - var obj = data.textures[i]; + for ( i = 0; i < data.textures.length; i++) { + obj = data.textures[i]; this.removeTextureData(obj); } - for (var i = 0; i < data.plistFiles.length; i++) { - var obj = data.plistFiles[i]; + for ( i = 0; i < data.plistFiles.length; i++) { + obj = data.plistFiles[i]; cc.spriteFrameCache.removeSpriteFramesFromFile(obj); } delete this._relativeDatas[configFilePath]; @@ -77,66 +78,54 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * Add armature data + * Adds armature data * @param {string} id The id of the armature data * @param {ccs.ArmatureData} armatureData */ addArmatureData:function (id, armatureData, configFilePath) { -// if (this._armarureDatas) { -// var data = this.getRelativeData(configFilePath); -// data.armatures.push(id); -// this._armarureDatas[id] = armatureData; -// } var data = this.getRelativeData(configFilePath); - if (data) - { + if (data){ data.armatures.push(id); } - this._armarureDatas[id] = armatureData; + this._armatureDatas[id] = armatureData; }, /** - * get armatureData by id + * Gets armatureData by id * @param {String} id * @return {ccs.ArmatureData} */ getArmatureData:function (id) { var armatureData = null; - if (this._armarureDatas) { - armatureData = this._armarureDatas[id]; + if (this._armatureDatas) { + armatureData = this._armatureDatas[id]; } return armatureData; }, /** - * remove armature data + * Removes armature data from armature data manager. * @param {string} id */ removeArmatureData:function(id){ - if (this._armarureDatas[id]) - delete this._armarureDatas[id]; + if (this._armatureDatas[id]) + delete this._armatureDatas[id]; }, /** - * add animation data + * Adds animation data to armature data manager. * @param {String} id * @param {ccs.AnimationData} animationData */ addAnimationData:function (id, animationData, configFilePath) { -// if (this._animationDatas) { -// var data = this.getRelativeData(configFilePath); -// data.animations.push(id); -// this._animationDatas[id] = animationData; -// } var data = this.getRelativeData(configFilePath); - if(data){ + if(data) data.animations.push(id); - } this._animationDatas[id] = animationData; }, /** - * get animationData by id + * Gets animationData by id * @param {String} id * @return {ccs.AnimationData} */ @@ -149,7 +138,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * remove animation data + * Removes animation data * @param {string} id */ removeAnimationData:function(id){ @@ -158,27 +147,20 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * add texture data + * Adds texture data to Armature data manager. * @param {String} id * @param {ccs.TextureData} textureData */ addTextureData:function (id, textureData, configFilePath) { -// if (this._textureDatas) { -// var data = this.getRelativeData(configFilePath); -// data.textures.push(id); -// this._textureDatas[id] = textureData; -// } var data = this.getRelativeData(configFilePath); - if (data) - { + if (data) { data.textures.push(id); } - this._textureDatas[id] = textureData; }, /** - * get textureData by id + * Gets textureData by id * @param {String} id * @return {ccs.TextureData} */ @@ -191,7 +173,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * remove texture data + * Removes texture data by id * @param {string} id */ removeTextureData:function(id){ @@ -200,7 +182,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * Add ArmatureFileInfo, it is managed by CCArmatureDataManager. + * Adds ArmatureFileInfo, it is managed by CCArmatureDataManager. * @param {String} imagePath * @param {String} plistPath * @param {String} configFilePath @@ -211,20 +193,6 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ * ccs.armatureDataManager.addArmatureFileInfo("res/test.png","res/test.plist","res/test.json"); */ addArmatureFileInfo:function (/*imagePath, plistPath, configFilePath*/) { -// var imagePath, plistPath, configFilePath; -// var isLoadSpriteFrame = false; -// if (arguments.length == 1) { -// configFilePath = arguments[0]; -// isLoadSpriteFrame = true; -// this.addRelativeData(configFilePath); -// } else if (arguments.length == 3){ -// imagePath = arguments[0]; -// plistPath = arguments[1]; -// configFilePath = arguments[2]; -// this.addRelativeData(configFilePath); -// this.addSpriteFrameFromFile(plistPath, imagePath, configFilePath); -// } -// ccs.dataReaderHelper.addDataFromFile(configFilePath,isLoadSpriteFrame); var imagePath, plistPath, configFilePath; switch(arguments.length){ case 1: @@ -249,7 +217,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * Add ArmatureFileInfo, it is managed by CCArmatureDataManager. + * Adds ArmatureFileInfo, it is managed by CCArmatureDataManager. * @param {String} imagePath * @param {String} plistPath * @param {String} configFilePath @@ -294,20 +262,24 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ ccs.spriteFrameCacheHelper.addSpriteFrameFromFile(plistPath, imagePath); }, + /** + * Returns whether or not need auto load sprite file + * @returns {boolean} + */ isAutoLoadSpriteFile:function(){ return this._autoLoadSpriteFile; }, /** - * get armatureDatas + * Returns armature Data of Armature data manager. * @return {Object} */ getArmatureDatas:function () { - return this._armarureDatas; + return this._armatureDatas; }, /** - * get animationDatas + * Returns animation data of Armature data manager. * @return {Object} */ getAnimationDatas:function () { @@ -315,7 +287,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * get textureDatas + * Returns texture data of Armature data manager. * @return {Object} */ getTextureDatas:function () { @@ -323,7 +295,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * add RelativeData + * Adds Relative data of Armature data manager. * @param {String} configFilePath */ addRelativeData: function (configFilePath) { @@ -332,7 +304,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ }, /** - * get RelativeData + * Gets RelativeData of Armature data manager. * @param {String} configFilePath * @returns {ccs.RelativeData} */ @@ -345,7 +317,7 @@ ccs.armatureDataManager = /** @lends ccs.armatureDataManager# */{ */ clear: function() { this._animationDatas = {}; - this._armarureDatas = {}; + this._armatureDatas = {}; this._textureDatas = {}; ccs.spriteFrameCacheHelper.clear(); ccs.dataReaderHelper.clear(); diff --git a/extensions/cocostudio/armature/utils/CCArmatureDefine.js b/extensions/cocostudio/armature/utils/CCArmatureDefine.js index 7ed4fd10ad..a7db1b9203 100644 --- a/extensions/cocostudio/armature/utils/CCArmatureDefine.js +++ b/extensions/cocostudio/armature/utils/CCArmatureDefine.js @@ -36,6 +36,10 @@ ccs.AUTO_ADD_SPRITE_FRAME_NAME_PREFIX = false; ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT = false; ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX = false; +/** + * Returns the version of Armature. + * @returns {string} + */ ccs.armatureVersion = function(){ return "v1.1.0.0"; }; diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index af2dfa0e15..1068296453 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -168,6 +168,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return this._positionReadScale; }, + /** + * Add armature data from file. + * @param {String} filePath + */ addDataFromFile: function (filePath) { /* * Check if file is already added to ArmatureDataManager, if then return. @@ -195,6 +199,14 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ ccs.dataReaderHelper.addDataFromBinaryCache(filePath, dataInfo); }, + /** + * Adds data from file with Async. + * @param {String} imagePath + * @param {String} plistPath + * @param {String} filePath + * @param {function} selector + * @param {Object} [target] + */ addDataFromFileAsync: function (imagePath, plistPath, filePath, selector, target) { /* * Check if file is already added to ArmatureDataManager, if then return. @@ -224,6 +236,10 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ cc.director.getScheduler().scheduleCallbackForTarget(this, fun, 0.1, false); }, + /** + * Removes config file from config file list. + * @param {String} configFile + */ removeConfigFile: function (configFile) { // cc.arrayRemoveObject(this._configFileList, configFile); var locFileList = this._configFileList; @@ -238,6 +254,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ cc.arrayRemoveObject(locFileList, configFile); }, + /** + * Translate XML export from Dragon Bone flash tool to data, and save them. When you add a new xml, the data already saved will be keeped. + * @param {Object} skeleton + * @param {ccs.DataInfo} dataInfo + */ addDataFromCache: function (skeleton, dataInfo) { if (!skeleton) { cc.log("XML error or XML is empty."); @@ -271,6 +292,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ } }, + /** + * decode xml armature data. + * @param {XMLDocument} armatureXML + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.ArmatureData} + */ decodeArmature: function (armatureXML, dataInfo) { var armatureData = new ccs.ArmatureData(); armatureData.init(); @@ -301,6 +328,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return armatureData; }, + /** + * decode json armature data. + * @param {Object} json + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.ArmatureData} + */ decodeArmatureFromJSON: function (json, dataInfo) { var armatureData = new ccs.ArmatureData(); armatureData.init(); @@ -320,6 +353,13 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return armatureData; }, + /** + * decode xml bone data. + * @param {XMLDocument} boneXML + * @param {XMLDocument} parentXML + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.BoneData} + */ decodeBone: function (boneXML, parentXML, dataInfo) { var boneData = new ccs.BoneData(); boneData.init(); @@ -338,6 +378,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return boneData; }, + /** + * decode json bone data. + * @param {Object} json json bone data. + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.BoneData} + */ decodeBoneFromJson: function (json, dataInfo) { var boneData = new ccs.BoneData(); boneData.init(); @@ -355,6 +401,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return boneData; }, + /** + * decode xml display data of bone + * @param {XMLDocument} displayXML + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.DisplayData} + */ decodeBoneDisplay: function (displayXML, dataInfo) { var isArmature = parseFloat(displayXML.getAttribute(ccs.CONST_A_IS_ARMATURE)) || 0; var displayData = null; @@ -374,6 +426,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return displayData; }, + /** + * Decodes json display data of bone. + * @param {Object} json + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.DisplayData} + */ decodeBoneDisplayFromJson: function (json, dataInfo) { var displayType = json[ccs.CONST_A_DISPLAY_TYPE] || ccs.DISPLAY_TYPE_SPRITE; var displayData = null; @@ -428,6 +486,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return displayData; }, + /** + * Decodes xml animation data. + * @param {XMLDocument} animationXML + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.AnimationData} + */ decodeAnimation: function (animationXML, dataInfo) { var aniData = new ccs.AnimationData(); var name = animationXML.getAttribute(ccs.CONST_A_NAME); @@ -445,6 +509,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return aniData; }, + /** + * Decodes animation json data. + * @param {Object} json + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.AnimationData} + */ decodeAnimationFromJson: function (json, dataInfo) { var aniData = new ccs.AnimationData(); var name = json[ccs.CONST_A_NAME]; @@ -460,6 +530,13 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return aniData; }, + /** + * Decodes xml movement data. + * @param {XMLDocument} movementXML + * @param {ccs.ArmatureData} armatureData + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.MovementData} + */ decodeMovement: function (movementXML, armatureData, dataInfo) { var movementData = new ccs.MovementData(); movementData.name = movementXML.getAttribute(ccs.CONST_A_NAME); @@ -513,6 +590,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return movementData; }, + /** + * Decodes json movement data. + * @param {Object} json + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.MovementData} + */ decodeMovementFromJson: function (json, dataInfo) { var movementData = new ccs.MovementData(); @@ -540,6 +623,14 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return movementData; }, + /** + * Decodes xml data of bone's movement. + * @param {XMLDocument} movBoneXml + * @param {XMLDocument} parentXml + * @param {ccs.BoneData} boneData + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.MovementBoneData} + */ decodeMovementBone: function (movBoneXml, parentXml, boneData, dataInfo) { var movBoneData = new ccs.MovementBoneData(); movBoneData.init(); @@ -617,6 +708,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return movBoneData; }, + /** + * Decodes json data of bone's movement. + * @param {Object} json + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.MovementBoneData} + */ decodeMovementBoneFromJson: function (json, dataInfo) { var movementBoneData = new ccs.MovementBoneData(); movementBoneData.init(); @@ -670,6 +767,14 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return movementBoneData; }, + /** + * Decodes xml data of frame. + * @param {XMLDocument} frameXML + * @param {XMLDocument} parentFrameXml + * @param {ccs.BoneData} boneData + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.FrameData} + */ decodeFrame: function (frameXML, parentFrameXml, boneData, dataInfo) { var x = 0, y = 0, scale_x = 0, scale_y = 0, skew_x = 0, skew_y = 0, tweenRotate = 0; var duration = 0, displayIndex = 0, zOrder = 0, tweenEasing = 0, blendType = 0; @@ -819,6 +924,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return frameData; }, + /** + * Decodes json data of frame. + * @param {Object} json + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.FrameData} + */ decodeFrameFromJson: function (json, dataInfo) { var frameData = new ccs.FrameData(); @@ -851,6 +962,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return frameData; }, + /** + * Decodes xml data of texture + * @param {XMLDocument} textureXML + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.TextureData} + */ decodeTexture: function (textureXML, dataInfo) { var textureData = new ccs.TextureData(); textureData.init(); @@ -885,6 +1002,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return textureData; }, + /** + * Decodes json data of Texture. + * @param json + * @returns {ccs.TextureData} + */ decodeTextureFromJson: function (json) { var textureData = new ccs.TextureData(); textureData.init(); @@ -905,6 +1027,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return textureData; }, + /** + * Decodes xml data of contour. + * @param {XMLDocument} contourXML + * @param {ccs.DataInfo} dataInfo + * @returns {ccs.ContourData} + */ decodeContour: function (contourXML, dataInfo) { var contourData = new ccs.ContourData(); contourData.init(); @@ -921,9 +1049,13 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ contourData.vertexList.push(vertex); } return contourData; - }, + /** + * Decodes json data of contour. + * @param {Object} json + * @returns {ccs.ContourData} + */ decodeContourFromJson: function (json) { var contourData = new ccs.ContourData(); contourData.init(); @@ -940,6 +1072,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return contourData; }, + /** + * Adds json armature data to armature data manager. + * @param {Object} dic json armature data + * @param {ccs.DataInfo} dataInfo + */ addDataFromJsonCache: function (dic, dataInfo) { dataInfo.contentScale = dic[ccs.CONST_CONTENT_SCALE] == null ? 1 : dic[ccs.CONST_CONTENT_SCALE]; @@ -987,6 +1124,12 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ animationData = null; }, + /** + * Decodes json data of node. + * @param node + * @param json + * @param dataInfo + */ decodeNodeFromJson: function (node, json, dataInfo) { node.x = json[ccs.CONST_A_X] * this._positionReadScale; node.y = json[ccs.CONST_A_Y] * this._positionReadScale; @@ -1051,6 +1194,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ return path; }, + /** + * Adds xml armature data to armature data manager. + * @param {XMLDocument} xml + * @param {ccs.DataInfo} dataInfo + */ addDataFromXML: function (xml, dataInfo) { /* * Need to get the full path of the xml file, or the Tiny XML can't find the xml at IOS @@ -1063,6 +1211,11 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ this.addDataFromCache(skeleton, dataInfo); }, + /** + * Adds json armature data to armature data manager. + * @param {String} filePath + * @param {ccs.DataInfo} dataInfo + */ addDataFromJson: function (filePath, dataInfo) { var fileContent = cc.loader.getRes(filePath); this.addDataFromJsonCache(fileContent, dataInfo); diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index 9aabdd0504..c0cda88ac6 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -32,11 +32,21 @@ ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { _textureAtlasDic:{}, _imagePaths:[], + /** + * Adds sprite frame from file + * @param plistPath + * @param imagePath + */ addSpriteFrameFromFile:function (plistPath, imagePath) { cc.spriteFrameCache.addSpriteFrames(plistPath, imagePath); }, - getTexureAtlasWithTexture:function (texture) { + /** + * Returns texture atlas with texture. + * @param texture + * @returns {*} + */ + getTextureAtlasWithTexture:function (texture) { //todo return null; var textureName = texture.getName(); @@ -48,6 +58,9 @@ ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { return atlas; }, + /** + * Clear the sprite frame cache's data. + */ clear: function () { this._textureAtlasDic = {}; this._imagePaths = []; diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index 184076bfcc..93084a8870 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -24,6 +24,7 @@ ****************************************************************************/ /** + * use to calculate the matrix of node from parent node * @class ccs.TransformHelp * @extend ccs.Class */ @@ -36,10 +37,10 @@ ccs.TransformHelp.helpPoint2 = cc.p(0, 0); ccs.TransformHelp.helpParentNode = {}; /** + * Calculate a BaseData's transform matrix from parent node. * @function * @static * @param {ccs.BaseData} bone - * @return {cc.AffineTransform} * Constructor */ ccs.TransformHelp.transformFromParent = function (bone, parentNode) { diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml index 515ac0dd82..5d84b167bd 100644 --- a/tools/jsdoc_toolkit/build.xml +++ b/tools/jsdoc_toolkit/build.xml @@ -21,6 +21,7 @@ + From 39d6c3b9ccf1bd3c913aa4de45306136678f5357 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Sep 2014 18:04:20 +0800 Subject: [PATCH 0619/1564] Issue #5888: Type resolution adaptation --- cocos2d/core/platform/CCEGLView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 5ad4f1295d..99dc753547 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -200,7 +200,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _setViewPortMeta: function (width, height) { if (this._isAdjustViewPort) { - var viewportMetas = {"user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0", width: "device-width"}, + var viewportMetas = {width: "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}, elems = document.getElementsByName("viewport"), vp, content; if (elems.length == 0) { vp = cc.newElement("meta"); From ba2016fcf79a7cae8fe51da1bdbfec74a2862d31 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 9 Sep 2014 18:04:52 +0800 Subject: [PATCH 0620/1564] Updates AUTHORS.txt --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 1185eafd7e..c4643197f3 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -197,6 +197,7 @@ Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix und Minh Quy @MQuy cc.MenuItemSprite bug fix Check empty string for textureData + Adds type check functions Michael Yin @layerssss cc.game refactored From 4a59c8eda8f67a826b2b330ffe005df213aa39ba Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Sep 2014 18:55:01 +0800 Subject: [PATCH 0621/1564] Issue #5888: Type resolution adaptation --- cocos2d/core/platform/CCEGLView.js | 67 +++++++++++++++++++----------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 99dc753547..d13dc3d2c5 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -200,39 +200,58 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _setViewPortMeta: function (width, height) { if (this._isAdjustViewPort) { - var viewportMetas = {width: "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}, - elems = document.getElementsByName("viewport"), vp, content; - if (elems.length == 0) { - vp = cc.newElement("meta"); - vp.name = "viewport"; - vp.content = ""; - document.head.appendChild(vp); + var viewportMetas, + elems = document.getElementsByName("viewport"), + vp, content; + + vp = document.getElementById("cocosMetaElement"); + if(vp){ + document.head.removeChild(vp); } - else vp = elems[0]; - // For avoiding Android Firefox issue, to remove once firefox fixes its issue. - if (cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX) { - vp.content = "initial-scale:1"; - return; - } + vp = cc.newElement("meta"); + vp.id = "cocosMetaElement"; + vp.name = "viewport"; + vp.content = ""; + + // For avoiding Android Firefox issue, to remove once firefox fixes its issue. + if (cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX) { + viewportMetas = {width: "device-width", "initial-scale": "1.0"}; - content = vp.content; + }else{ + viewportMetas = {width: "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}; + } + + content = ""; for (var key in viewportMetas) { + var a = true; var pattern = new RegExp(key); - if (!pattern.test(content)) { - content += (content == "" ? "" : ",") + key + "=" + viewportMetas[key]; + for(var i=0; i Date: Tue, 9 Sep 2014 19:20:41 +0800 Subject: [PATCH 0622/1564] Issue #5888: Type resolution adaptation --- cocos2d/core/platform/CCEGLView.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index d13dc3d2c5..b9c6e9aac3 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -222,21 +222,15 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ viewportMetas = {width: "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}; } - content = ""; + content = elems ? elems[0].content : ""; for (var key in viewportMetas) { - var a = true; var pattern = new RegExp(key); - for(var i=0; i Date: Tue, 9 Sep 2014 21:31:08 +0800 Subject: [PATCH 0623/1564] Update Engine Version --- cocos2d/core/platform/CCConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 758349e22e..aed123d15c 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC3"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 Final"; /** *

    From 9145620df1595fc6a79bfdeafa495a85eb708cb5 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 9 Sep 2014 23:41:58 +0800 Subject: [PATCH 0624/1564] Issue #5907: Fix issues of resolution policy's check --- cocos2d/core/platform/CCEGLView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index b9c6e9aac3..c6dcb27c5f 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -486,6 +486,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ return; } var _t = this; + var previousPolicy = _t._resolutionPolicy; _t.setResolutionPolicy(resolutionPolicy); var policy = _t._resolutionPolicy; if (policy) @@ -501,7 +502,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _t._setViewPortMeta(_t._frameSize.width, _t._frameSize.height); _t._initFrameSize(); // No change - if (resolutionPolicy == _t._resolutionPolicy + if (previousPolicy == _t._resolutionPolicy && width == _t._originalDesignResolutionSize.width && height == _t._originalDesignResolutionSize.height && frameW == _t._frameSize.width && frameH == _t._frameSize.height) return; From 299f9585b2d0a0111329eb0d60c94d6d9ecdcd8f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 10 Sep 2014 09:37:04 +0800 Subject: [PATCH 0625/1564] Issue #5907: Fix issues of viewport set --- cocos2d/core/platform/CCEGLView.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index c6dcb27c5f..0c9d4addfc 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -200,15 +200,15 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _setViewPortMeta: function (width, height) { if (this._isAdjustViewPort) { - var viewportMetas, - elems = document.getElementsByName("viewport"), - vp, content; - - vp = document.getElementById("cocosMetaElement"); + var vp = document.getElementById("cocosMetaElement"); if(vp){ document.head.removeChild(vp); } + var viewportMetas, + elems = document.getElementsByName("viewport"), + content; + vp = cc.newElement("meta"); vp.id = "cocosMetaElement"; vp.name = "viewport"; From ef4dc197cf98229ab935b29f4c36a276ae603f82 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 10 Sep 2014 11:49:37 +0800 Subject: [PATCH 0626/1564] Adds oupeng browser type and adds baidubox to multipleAudioWhiteList --- CCBoot.js | 7 +++++-- cocos2d/audio/CCAudio.js | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 96d017fa9b..dec23befb2 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1377,6 +1377,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.BROWSER_TYPE_BAIDU = "baidubrowser"; sys.BROWSER_TYPE_MAXTHON = "maxthon"; sys.BROWSER_TYPE_OPERA = "opera"; + sys.BROWSER_TYPE_OUPENG = "oupeng"; sys.BROWSER_TYPE_MIUI = "miuibrowser"; sys.BROWSER_TYPE_FIREFOX = "firefox"; sys.BROWSER_TYPE_SAFARI = "safari"; @@ -1397,7 +1398,7 @@ cc._initSys = function (config, CONFIG_KEY) { */ var webglWhiteList = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI]; var multipleAudioWhiteList = [ - sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, + sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_BAIDU_APP, sys.BROWSER_TYPE_SAFARI, sys.BROWSER_TYPE_UC, sys.BROWSER_TYPE_QQ, sys.BROWSER_TYPE_MOBILE_QQ, sys.BROWSER_TYPE_IE ]; @@ -1414,7 +1415,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** The type of browser */ var browserType = sys.BROWSER_TYPE_UNKNOWN; - var browserTypes = ua.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|opera|miuibrowser|firefox/i) + var browserTypes = ua.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i) || ua.match(/chrome|safari/i); if (browserTypes && browserTypes.length > 0) { browserType = browserTypes[0].toLowerCase(); @@ -1426,8 +1427,10 @@ cc._initSys = function (config, CONFIG_KEY) { } sys.browserType = browserType; + sys._supportMultipleAudio = multipleAudioWhiteList.indexOf(sys.browserType) > -1; + //++++++++++++++++++something about cc._renderTYpe and cc._supportRender begin++++++++++++++++++++++++++++ var userRenderMode = parseInt(config[CONFIG_KEY.renderMode]); var renderType = cc._RENDER_TYPE_WEBGL; diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index ed77e3259a..3038d2cbb7 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -773,9 +773,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ }); - -if (!cc.sys._supportWebAudio && cc.sys._supportMultipleAudio < 0) { - +if (!cc.sys._supportWebAudio && !cc.sys._supportMultipleAudio) { cc.AudioEngineForSingle = cc.AudioEngine.extend({ _waitingEffIds: [], _pausedEffIds: [], From 2d999746d6b45416c626748f7cac8a8436ae2e72 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 10 Sep 2014 14:45:09 +0800 Subject: [PATCH 0627/1564] Sets mobile browser's default target-densitydpi to high-dpi --- cocos2d/core/platform/CCEGLView.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 0c9d4addfc..840b0387eb 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -216,11 +216,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ // For avoiding Android Firefox issue, to remove once firefox fixes its issue. if (cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX) { - viewportMetas = {width: "device-width", "initial-scale": "1.0"}; - + viewportMetas = {"width": "device-width", "initial-scale": "1.0"}; }else{ - viewportMetas = {width: "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}; + viewportMetas = {"width": "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}; } + if(cc.sys.isMobile) + viewportMetas["target-densitydpi"] = "high-dpi"; content = elems ? elems[0].content : ""; for (var key in viewportMetas) { From fd757a6c7f13fea38e7f3d3d56fe9e5472a08ac5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Sep 2014 14:54:51 +0800 Subject: [PATCH 0628/1564] Issue #5920: Event binding methods are not uniform --- extensions/ccui/uiwidgets/UICheckBox.js | 35 +++--- extensions/ccui/uiwidgets/UISlider.js | 27 +++-- extensions/ccui/uiwidgets/UITextField.js | 53 +++++---- .../uiwidgets/scroll-widget/UIListView.js | 25 +++-- .../uiwidgets/scroll-widget/UIPageView.js | 25 +++-- .../uiwidgets/scroll-widget/UIScrollView.js | 105 ++++++++++-------- 6 files changed, 150 insertions(+), 120 deletions(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 88cd5e578e..8ddfb696cf 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -41,7 +41,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _checkBoxEventListener: null, _checkBoxEventSelector:null, - _checkBoxEventCallback: null, _backGroundTexType: ccui.Widget.LOCAL_TEXTURE, _backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE, @@ -415,17 +414,21 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, _selectedEvent: function () { - if(this._checkBoxEventCallback) - this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_SELECTED); - if (this._checkBoxEventListener && this._checkBoxEventSelector) - this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_SELECTED); + if(this._checkBoxEventSelector){ + if (this._checkBoxEventListener) + this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_SELECTED); + else + this._checkBoxEventSelector(this, ccui.CheckBox.EVENT_SELECTED); + } }, _unSelectedEvent: function () { - if(this._checkBoxEventCallback) - this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_UNSELECTED); - if (this._checkBoxEventListener && this._checkBoxEventSelector) - this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_UNSELECTED); + if(this._checkBoxEventSelector){ + if (this._checkBoxEventListener) + this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_UNSELECTED); + else + this._checkBoxEventSelector(this, ccui.CheckBox.EVENT_UNSELECTED); + } }, _releaseUpEvent: function(){ @@ -442,20 +445,21 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ /** * add event listener to ccui.CheckBox. it would called when checkbox is selected or unselected. * @param {Function} selector - * @param {Object} target + * @param {Object} [target=] * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerCheckBox: function (selector, target) { - this._checkBoxEventSelector = selector; - this._checkBoxEventListener = target; + this.addEventListener(selector, target); }, /** * add a call back function would called when checkbox is selected or unselected. - * @param {function} callback + * @param {Function} selector + * @param {Object} [target=] */ - addEventListener: function(callback){ - this._checkBoxEventCallback = callback; + addEventListener: function(selector, target){ + this._checkBoxEventSelector = selector; + this._checkBoxEventListener = target; }, /** @@ -613,7 +617,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this.setSelectedState(uiCheckBox._isSelected); this._checkBoxEventListener = uiCheckBox._checkBoxEventListener; this._checkBoxEventSelector = uiCheckBox._checkBoxEventSelector; - this._checkBoxEventCallback = uiCheckBox._checkBoxEventCallback; } }, diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index f06cfd06a5..55aad96b10 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -506,29 +506,29 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ /** * add event listener * @param {Function} selector - * @param {Object} target + * @param {Object} [target=] + * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerSlider: function (selector, target) { - this._sliderEventSelector = selector; - this._sliderEventListener = target; + this.addEventListener(selector, target); }, /** * Adds a callback - * @param {function} callback + * @param {Function} selector + * @param {Object} [target=] */ - addEventListener: function(callback){ - this._eventCallback = callback; + addEventListener: function(selector, target){ + this._sliderEventSelector = selector; + this._sliderEventListener = target; }, _percentChangedEvent: function () { - if (this._sliderEventListener && this._sliderEventSelector) { - this._sliderEventSelector.call(this._sliderEventListener, - this, - ccui.Slider.EVENT_PERCENT_CHANGED); - } - if (this._eventCallback) { - this._eventCallback(ccui.Slider.EVENT_PERCENT_CHANGED); + if(this._sliderEventSelector){ + if (this._sliderEventListener) + this._sliderEventSelector.call(this._sliderEventListener, this, ccui.Slider.EVENT_PERCENT_CHANGED); + else + this._sliderEventSelector(this, ccui.Slider.EVENT_PERCENT_CHANGED); } }, @@ -673,7 +673,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this.setPercent(slider.getPercent()); this._sliderEventListener = slider._sliderEventListener; this._sliderEventSelector = slider._sliderEventSelector; - this._eventCallback = slider._eventCallback; } }); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index c2ded41bc2..948688df29 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -647,50 +647,59 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, _attachWithIMEEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) - this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_ATTACH_WITH_IME); - if (this._eventCallback) - this._eventCallback(this, ccui.TextField.EVENT_ATTACH_WITH_IME); + if(this._textFieldEventSelector){ + if (this._textFieldEventListener) + this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_ATTACH_WITH_IME); + else + this._textFieldEventSelector(this, ccui.TextField.EVENT_ATTACH_WITH_IME); + } }, _detachWithIMEEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) - this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DETACH_WITH_IME); - if (this._eventCallback) - this._eventCallback(this, ccui.TextField.EVENT_DETACH_WITH_IME); + if(this._textFieldEventSelector){ + if (this._textFieldEventListener) + this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DETACH_WITH_IME); + else + this._textFieldEventSelector(this, ccui.TextField.EVENT_DETACH_WITH_IME); + } }, _insertTextEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) - this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT); - if (this._eventCallback) - this._eventCallback(this, ccui.TextField.EVENT_INSERT_TEXT); + if(this._textFieldEventSelector){ + if (this._textFieldEventListener) + this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT); + else + this._textFieldEventSelector(this, ccui.TextField.EVENT_INSERT_TEXT); + } }, _deleteBackwardEvent: function () { - if (this._textFieldEventListener && this._textFieldEventSelector) - this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD); - if (this._eventCallback) - this._eventCallback(this, ccui.TextField.EVENT_DELETE_BACKWARD); + if(this._textFieldEventSelector){ + if (this._textFieldEventListener) + this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD); + else + this._textFieldEventSelector(this, ccui.TextField.EVENT_DELETE_BACKWARD); + } }, /** * Adds event listener to cuci.TextField. - * @param {Object} target + * @param {Object} [target=] * @param {Function} selector * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerTextField: function (selector, target) { - this._textFieldEventSelector = selector; - this._textFieldEventListener = target; + this.addEventListener(selector, target); }, /** * Adds event listener callback. - * @param {function} callback + * @param {Object} [target=] + * @param {Function} selector */ - addEventListener: function(callback){ - this._eventCallback = callback; + addEventListener: function(selector, target){ + this._textFieldEventSelector = selector; + this._textFieldEventListener = target; }, _onSizeChanged: function () { diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index ea856d45e8..d484c8ac89 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -49,7 +49,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ _listViewEventListener: null, _listViewEventSelector: null, - _eventCallback: null, /** * allocates and initializes a UIListView. * Constructor of ccui.ListView, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. @@ -447,28 +446,31 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * Adds event listener to ccui.ListView. * @param {Function} selector - * @param {Object} target + * @param {Object} [target=] * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerListView: function (selector, target) { - this._listViewEventListener = target; - this._listViewEventSelector = selector; + this.addEventListener(selector, target); }, /** * Adds event listener to ccui.ListView. - * @param {function} callback + * @param {Function} selector + * @param {Object} [target=] */ - addEventListener: function(callback){ - this._eventCallback = callback; + addEventListener: function(selector, target){ + this._listViewEventListener = target; + this._listViewEventSelector = selector; }, _selectedItemEvent: function (event) { var eventEnum = (event == ccui.Widget.TOUCH_BEGAN) ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END; - if (this._listViewEventListener && this._listViewEventSelector) - this._listViewEventSelector.call(this._listViewEventListener, this, eventEnum); - if(this._eventCallback) - this._eventCallback(this, eventEnum); + if(this._listViewEventSelector){ + if (this._listViewEventListener) + this._listViewEventSelector.call(this._listViewEventListener, this, eventEnum); + else + this._listViewEventSelector(this, eventEnum); + } }, /** @@ -535,7 +537,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._listViewEventListener = listView._listViewEventListener; this._listViewEventSelector = listView._listViewEventSelector; - this._eventCallback = listView._eventCallback; } } }); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 34d44d7ff5..82f5357cb7 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -54,7 +54,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _pageViewEventListener: null, _pageViewEventSelector: null, _className:"PageView", - _eventCallback: null, /** * Allocates and initializes a UIPageView. @@ -482,29 +481,32 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, _pageTurningEvent: function () { - if (this._pageViewEventListener && this._pageViewEventSelector) - this._pageViewEventSelector.call(this._pageViewEventListener, this, ccui.PageView.EVENT_TURNING); - if (this._eventCallback) - this._eventCallback(this, ccui.PageView.EVENT_TURNING); + if(this._pageViewEventSelector){ + if (this._pageViewEventListener) + this._pageViewEventSelector.call(this._pageViewEventListener, this, ccui.PageView.EVENT_TURNING); + else + this._pageViewEventSelector(this, ccui.PageView.EVENT_TURNING); + } }, /** * Adds event listener to ccui.PageView. * @param {Function} selector - * @param {Object} target + * @param {Object} [target=] * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerPageView: function (selector, target) { - this._pageViewEventSelector = selector; - this._pageViewEventListener = target; + this.addEventListener(selector, target); }, /** * Adds event listener to ccui.PageView. - * @param callback + * @param {Function} selector + * @param {Object} [target=] */ - addEventListener: function(callback){ - this._eventCallback = callback; + addEventListener: function(selector, target){ + this._pageViewEventSelector = selector; + this._pageViewEventListener = target; }, /** @@ -556,7 +558,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _copySpecialProperties: function (pageView) { ccui.Layout.prototype._copySpecialProperties.call(this, pageView); - this._eventCallback = pageView._eventCallback; this._pageViewEventListener = pageView._pageViewEventListener; this._pageViewEventSelector = pageView._pageViewEventSelector; } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 164d5c5585..c0eb838d19 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -77,7 +77,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _scrollViewEventListener: null, _scrollViewEventSelector: null, _className: "ScrollView", - _eventCallback: null, /** * Allocates and initializes a UIScrollView. @@ -1461,85 +1460,104 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, _scrollToTopEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); - if (this._eventCallback) - this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_TOP); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); + } }, _scrollToBottomEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); - if (this._eventCallback) - this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); + } }, _scrollToLeftEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT); - if (this._eventCallback) - this._eventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT); + } }, _scrollToRightEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); - if (this._eventCallback) - this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); + } }, _scrollingEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLLING); - if (this._eventCallback) - this._eventCallback(this,ccui.ScrollView.EVENT_SCROLLING); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLLING); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLLING); + } }, _bounceTopEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_TOP); - if (this._eventCallback) - this._eventCallback(this,ccui.ScrollView.EVENT_BOUNCE_TOP); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_TOP); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_TOP); + } }, _bounceBottomEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM); - if (this._eventCallback) - this._eventCallback(this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM); + } }, _bounceLeftEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_LEFT); - if (this._eventCallback) - this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_LEFT); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_LEFT); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_LEFT); + } }, _bounceRightEvent: function () { - if (this._scrollViewEventListener && this._scrollViewEventSelector) - this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); - if (this._eventCallback) - this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); + if(this._scrollViewEventSelector){ + if (this._scrollViewEventListener) + this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); + else + this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); + } }, /** * Adds callback function called ScrollView event triggered * @param {Function} selector - * @param {Object} target + * @param {Object} [target=] * @deprecated since v3.0, please use addEventListener instead. */ addEventListenerScrollView: function (selector, target) { - this._scrollViewEventSelector = selector; - this._scrollViewEventListener = target; + this.addEventListener(selector, target); }, /** * Adds callback function called ScrollView event triggered - * @param {function} callback + * @param {Function} selector + * @param {Object} [target=] */ - addEventListener: function(callback){ - this._eventCallback = callback; + addEventListener: function(selector, target){ + this._scrollViewEventSelector = selector; + this._scrollViewEventListener = target; }, /** @@ -1646,7 +1664,6 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.setInertiaScrollEnabled(scrollView.inertiaScrollEnabled); this._scrollViewEventListener = scrollView._scrollViewEventListener; this._scrollViewEventSelector = scrollView._scrollViewEventSelector; - this._eventCallback = scrollView._eventCallback; } }, From edada5124978f46d55f01e34ea5db7cf9df7d9e5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 10 Sep 2014 15:16:35 +0800 Subject: [PATCH 0629/1564] Adds setTargetDensityDPI/getTargetDensityDPI to cc.view. --- cocos2d/core/platform/CCEGLView.js | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 840b0387eb..2797c173ee 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -30,6 +30,11 @@ cc.Touches = []; cc.TouchesIntergerDict = {}; +cc.DENSITYDPI_DEVICE = "device-dpi"; +cc.DENSITYDPI_HIGH = "high-dpi"; +cc.DENSITYDPI_MEDIUM = "medium-dpi"; +cc.DENSITYDPI_LOW = "low-dpi"; + /** * cc.view is the singleton object which represents the game window.
    * It's main task include:
    @@ -90,6 +95,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _frameZoomFactor: 1.0, __resizeWithBrowserSize: false, _isAdjustViewPort: true, + _targetDensityDPI: null, /** * Constructor of cc.EGLView @@ -121,6 +127,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _t._hDC = cc._canvas; _t._hRC = cc._renderContext; + _t._targetDensityDPI = cc.DENSITYDPI_HIGH; }, // Resize helper functions @@ -135,6 +142,30 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ this.setDesignResolutionSize(width, height, this._resolutionPolicy); }, + /** + *

    + * Sets view's target-densitydpi for android mobile browser. it can be set to:
    + * 1. cc.DENSITYDPI_DEVICE, value is "device-dpi"
    + * 2. cc.DENSITYDPI_HIGH, value is "high-dpi" (default value)
    + * 3. cc.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value)
    + * 4. cc.DENSITYDPI_LOW, value is "low-dpi"
    + * 5. Custom value, e.g: "480"
    + *

    + * @param {String} densityDPI + */ + setTargetDensityDPI: function(densityDPI){ + this._targetDensityDPI = densityDPI; + this._setViewPortMeta(); + }, + + /** + * Returns the current target-densitydpi value of cc.view. + * @returns {String} + */ + getTargetDensityDPI: function(){ + return this._targetDensityDPI; + }, + /** * Sets whether resize canvas automatically when browser's size changed.
    * Useful only on web. @@ -221,7 +252,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ viewportMetas = {"width": "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}; } if(cc.sys.isMobile) - viewportMetas["target-densitydpi"] = "high-dpi"; + viewportMetas["target-densitydpi"] = this._targetDensityDPI; content = elems ? elems[0].content : ""; for (var key in viewportMetas) { From d9b9a9339bf20e566f7e84da63f41a4946b48b4c Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 10 Sep 2014 15:18:28 +0800 Subject: [PATCH 0630/1564] [3.0 Release] Add Changelog --- CHANGELOG.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index aadb0744bd..75ce4c10cc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,26 @@ ChangeLog: +Cocos2d-JS-v3.0 Final @ Sep.10, 2014 + +* Facebook SDK Beta2: Added `appRequest` API. +* Facebook SDK Beta2: Added permission request in `login` API, removed `requestPermission` API. +* Facebook SDK Beta2: Renamed `request` API to `api`. +* Facebook SDK Beta2: Renamed `publishInstall` API to `activateApp`. +* Added some type check functions. +* Added audio support for wechat browser. +* Added setPlaceHolderColor and setTextColor to ccui.TextField. +* Added API reference for Cocos Studio extension. + +* Bugs fix: + 1. Fixed an issue of `cc.Menu` that its item's touch priority is different than cc.eventManager. + 2. Fixed an issue of `cc.view` that its NO_BORDER mode doesn't work correctly. + 3. Fixed an issue of `cc.LabelBMFont` that its content size is different than JSB. + 4. Fixed an issue of `cc.LabelBMFont` that its `setColor` is invalid on some mobile devices. + 5. Fixed an issue of `cc.PageView` that it can't receive TOUCH_CANCEL event. + 6. Fixed an issue of `cc.loader` that it can't load cross origin textures. + 7. Fixed an issue that Facebook SDK Web's `appRequest` wraps info parameter incorrectly. + 8. Fixed an issue of ccui widgets' `addEventListener` that it doesn't accept function's target as parameter. + Cocos2d-JS-v3.0 RC3 @ Aug.29, 2014 * Facebook SDK Beta: Unified the callback parameters for different platform. From 28f89308a29a6b6766eba8e082ad70fc8e990644 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 10 Sep 2014 15:32:58 +0800 Subject: [PATCH 0631/1564] [3.0 Release] Improve Changelog --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 75ce4c10cc..c1cd6f7650 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ Cocos2d-JS-v3.0 Final @ Sep.10, 2014 * Facebook SDK Beta2: Added permission request in `login` API, removed `requestPermission` API. * Facebook SDK Beta2: Renamed `request` API to `api`. * Facebook SDK Beta2: Renamed `publishInstall` API to `activateApp`. +* Added getter and setter function for browser's density dpi: `cc.view.setTargetDensityDPI`, `cc.view.getTargetDensityDPI`. * Added some type check functions. * Added audio support for wechat browser. * Added setPlaceHolderColor and setTextColor to ccui.TextField. From 2231c22530ff8255718765574fa30b4f4ba620b7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 10 Sep 2014 15:56:39 +0800 Subject: [PATCH 0632/1564] Fixed a bug of cc.Layer for bake --- cocos2d/core/base-nodes/CCNode.js | 1 - cocos2d/core/layers/CCLayer.js | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 87304fe7b9..9665a398e1 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1271,7 +1271,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ cc.assert(child._parent === null, "child already added. It can't be added again"); this._addChildHelper(child, localZOrder, tag, name, setTag); - }, _addChildHelper: function(child, localZOrder, tag, name, setTag){ diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 6738191c12..f68c3ec01f 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -126,6 +126,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; + p.addChild = function(child, localZOrder, tag){ + cc.Node.prototype.addChild.call(this, child, localZOrder, tag); + if(child._parent == this && this._isBaked) + child._setCachedParent(this); + }; + p.visit = function(ctx){ if(!this._isBaked){ cc.Node.prototype.visit.call(this, ctx); From 6b4ee24c2a28ecbf77787244f6fd90c9d21133f2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 10 Sep 2014 16:53:31 +0800 Subject: [PATCH 0633/1564] [Cocos2d-JS 3.0 Release] Update build.xml --- tools/build.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build.xml b/tools/build.xml index 28f22b30ec..f80dce9688 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.0-min.js"> @@ -246,7 +246,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.0-core-min.js"> From a0400c51c664b647a325feccabc39a8aa00b6315 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Sep 2014 19:42:02 +0800 Subject: [PATCH 0634/1564] 'Attr.ownerElement' is deprecated and has been removed from DOM4 --- CCBoot.js | 1 - 1 file changed, 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index dec23befb2..df7a453c80 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -977,7 +977,6 @@ cc.formatStr = function(){ var str = args[0]; var needToFormat = true; if(typeof str == "object"){ - str = JSON.stringify(str); needToFormat = false; } for(var i = 1; i < l; ++i){ From cf2dfa1343fc5815b857709c73c69daad4709ff8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Sep 2014 19:45:24 +0800 Subject: [PATCH 0635/1564] 'Attr.ownerElement' is deprecated and has been removed from DOM4 --- CCDebugger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCDebugger.js b/CCDebugger.js index 59c381d74e..5284b60e46 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -261,7 +261,7 @@ cc._logToWebPage = function (msg) { logListStyle.margin = 0; } - msg = cc.isString(msg) ? msg : JSON.stringify(msg); + msg = cc.isString(msg) ? msg : msg.toString(); logList.value = logList.value + msg + "\r\n"; logList.scrollTop = logList.scrollHeight; }; From ebd763acb49f017b8c5254946995c598663f0d08 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Sep 2014 19:49:40 +0800 Subject: [PATCH 0636/1564] 'Attr.ownerElement' is deprecated and has been removed from DOM4 --- CCBoot.js | 1 - 1 file changed, 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index df7a453c80..8655431f6a 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -981,7 +981,6 @@ cc.formatStr = function(){ } for(var i = 1; i < l; ++i){ var arg = args[i]; - arg = typeof arg == "object" ? JSON.stringify(arg) : arg; if(needToFormat){ while(true){ var result = null; From b5bb388c114d4a913a659617ef85ae5341c5cf76 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Sep 2014 20:45:01 +0800 Subject: [PATCH 0637/1564] Null does not support toString --- CCDebugger.js | 1 - 1 file changed, 1 deletion(-) diff --git a/CCDebugger.js b/CCDebugger.js index 5284b60e46..54be22d7c3 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -261,7 +261,6 @@ cc._logToWebPage = function (msg) { logListStyle.margin = 0; } - msg = cc.isString(msg) ? msg : msg.toString(); logList.value = logList.value + msg + "\r\n"; logList.scrollTop = logList.scrollHeight; }; From 38cc724fe5d7c58cdff52cc32d1471034dd78b2c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 10 Sep 2014 21:03:09 +0800 Subject: [PATCH 0638/1564] Fixed a bug of cc.LabelBMFont --- cocos2d/labels/CCLabelBMFont.js | 60 +++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 1a39e40525..bf602e24f9 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -44,7 +44,7 @@ cc.LABEL_AUTOMATIC_WIDTH = -1; *
  • - scaled
  • *
  • - translated
  • *
  • - tinted
  • - *
  • - chage the opacity
  • + *
  • - change the opacity
  • *
  • - It can be used as part of a menu item.
  • *
  • - anchorPoint can be used to align the "label"
  • *
  • - Supports AngelCode text format
  • @@ -1075,29 +1075,47 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var _p = cc.LabelBMFont.prototype; -if(cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes) - _p._changeTextureColor = function(){ - if(cc._renderType == cc._RENDER_TYPE_WEBGL) - return; - var locElement, locTexture = this.getTexture(); - if (locTexture && locTexture.getContentSize().width>0) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) +if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + if (!cc.sys._supportCanvasNewBlendModes) { + _p._changeTextureColor = function () { + if (cc._renderType == cc._RENDER_TYPE_WEBGL) return; - var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); - if (cacheTextureForColor) { - if (locElement instanceof HTMLCanvasElement && !this._rectRotated) - cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); - else{ - locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.setTexture(locTexture); + var locElement, locTexture = this.getTexture(); + if (locTexture && locTexture.getContentSize().width > 0) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); + if (cacheTextureForColor) { + if (locElement instanceof HTMLCanvasElement && !this._rectRotated) + cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); + else { + locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.setTexture(locTexture); + } } } - } - }; + }; + } else { + _p.setTexture = function (texture) { + var locChildren = this._children; + var locDisplayedColor = this._displayedColor; + for (var i = 0; i < locChildren.length; i++) { + var selChild = locChildren[i]; + var childDColor = selChild._displayedColor; + if (this._textureForCanvas != selChild._texture && (childDColor.r !== locDisplayedColor.r || + childDColor.g !== locDisplayedColor.g || childDColor.b !== locDisplayedColor.b)) + continue; + selChild.texture = texture; + } + this._textureForCanvas = texture; + }; + } +} + /** @expose */ _p.string; From 636b0d3333bb887b911d13d0f98cef4969f65b8e Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 10 Sep 2014 21:55:07 +0800 Subject: [PATCH 0639/1564] Issue #5907: Fix API reference issues --- CCBoot.js | 167 +++++++++++++++++++++++++------ cocos2d/core/platform/CCClass.js | 5 - jsb_apis.js | 41 ++++---- 3 files changed, 160 insertions(+), 53 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 8655431f6a..a7600d98cf 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -23,6 +23,11 @@ THE SOFTWARE. ****************************************************************************/ +/** + * The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace + * @namespace + * @name cc + */ var cc = cc || {}; cc._tmp = cc._tmp || {}; cc._LogInfos = {}; @@ -265,7 +270,10 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ } }; -cc.async = { +/** + * @class + */ +cc.async = /** @lends cc.async# */{ /** * Do tasks series. * @param {Array|Object} tasks @@ -360,7 +368,10 @@ cc.async = { //+++++++++++++++++++++++++something about async end+++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++something about path begin++++++++++++++++++++++++++++++++ -cc.path = { +/** + * @class + */ +cc.path = /** @lends cc.path# */{ /** * Join strings to be a path. * @example @@ -502,7 +513,11 @@ cc.path = { //+++++++++++++++++++++++++something about path end++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++something about loader start+++++++++++++++++++++++++++ -cc.loader = { +/** + * Loader for resource loading process. It's a singleton object. + * @class + */ +cc.loader = /** @lends cc.loader# */{ _jsCache: {},//cache for js _register: {},//register of loaders _langPathCache: {},//cache for lang path @@ -1107,9 +1122,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * System variables - * @memberof cc - * @global - * @type {Object} + * @namespace * @name cc.sys */ cc.sys = {}; @@ -1118,6 +1131,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * English language code * @memberof cc.sys + * @name LANGUAGE_ENGLISH * @constant * @type {Number} */ @@ -1126,6 +1140,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Chinese language code * @memberof cc.sys + * @name LANGUAGE_CHINESE * @constant * @type {Number} */ @@ -1134,6 +1149,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * French language code * @memberof cc.sys + * @name LANGUAGE_FRENCH * @constant * @type {Number} */ @@ -1142,6 +1158,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Italian language code * @memberof cc.sys + * @name LANGUAGE_ITALIAN * @constant * @type {Number} */ @@ -1150,6 +1167,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * German language code * @memberof cc.sys + * @name LANGUAGE_GERMAN * @constant * @type {Number} */ @@ -1158,14 +1176,25 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Spanish language code * @memberof cc.sys + * @name LANGUAGE_SPANISH * @constant * @type {Number} */ sys.LANGUAGE_SPANISH = "es"; + /** + * Spanish language code + * @memberof cc.sys + * @name LANGUAGE_DUTCH + * @constant + * @type {Number} + */ + sys.LANGUAGE_DUTCH = "du"; + /** * Russian language code * @memberof cc.sys + * @name LANGUAGE_RUSSIAN * @constant * @type {Number} */ @@ -1174,6 +1203,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Korean language code * @memberof cc.sys + * @name LANGUAGE_KOREAN * @constant * @type {Number} */ @@ -1182,6 +1212,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Japanese language code * @memberof cc.sys + * @name LANGUAGE_JAPANESE * @constant * @type {Number} */ @@ -1190,6 +1221,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Hungarian language code * @memberof cc.sys + * @name LANGUAGE_HUNGARIAN * @constant * @type {Number} */ @@ -1198,6 +1230,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Portuguese language code * @memberof cc.sys + * @name LANGUAGE_PORTUGUESE * @constant * @type {Number} */ @@ -1206,6 +1239,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Arabic language code * @memberof cc.sys + * @name LANGUAGE_ARABIC * @constant * @type {Number} */ @@ -1214,6 +1248,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Norwegian language code * @memberof cc.sys + * @name LANGUAGE_NORWEGIAN * @constant * @type {Number} */ @@ -1222,6 +1257,7 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Polish language code * @memberof cc.sys + * @name LANGUAGE_POLISH * @constant * @type {Number} */ @@ -1229,44 +1265,57 @@ cc._initSys = function (config, CONFIG_KEY) { /** * @memberof cc.sys + * @name OS_WINDOWS * @constant * @type {string} */ sys.OS_WINDOWS = "Windows"; /** * @memberof cc.sys + * @name OS_IOS * @constant * @type {string} */ sys.OS_IOS = "iOS"; /** * @memberof cc.sys + * @name OS_OSX * @constant * @type {string} */ sys.OS_OSX = "OS X"; /** * @memberof cc.sys + * @name OS_UNIX * @constant * @type {string} */ sys.OS_UNIX = "UNIX"; /** * @memberof cc.sys + * @name OS_LINUX * @constant * @type {string} */ sys.OS_LINUX = "Linux"; /** * @memberof cc.sys + * @name OS_ANDROID * @constant * @type {string} */ sys.OS_ANDROID = "Android"; + /** + * @memberof cc.sys + * @name OS_UNKNOWN + * @constant + * @type {string} + */ sys.OS_UNKNOWN = "Unknown"; /** * @memberof cc.sys + * @name WINDOWS * @constant * @default * @type {Number} @@ -1274,6 +1323,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.WINDOWS = 0; /** * @memberof cc.sys + * @name LINUX * @constant * @default * @type {Number} @@ -1281,6 +1331,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.LINUX = 1; /** * @memberof cc.sys + * @name MACOS * @constant * @default * @type {Number} @@ -1288,6 +1339,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.MACOS = 2; /** * @memberof cc.sys + * @name ANDROID * @constant * @default * @type {Number} @@ -1295,6 +1347,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.ANDROID = 3; /** * @memberof cc.sys + * @name IPHONE * @constant * @default * @type {Number} @@ -1302,6 +1355,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.IPHONE = 4; /** * @memberof cc.sys + * @name IPAD * @constant * @default * @type {Number} @@ -1309,6 +1363,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.IPAD = 5; /** * @memberof cc.sys + * @name BLACKBERRY * @constant * @default * @type {Number} @@ -1316,6 +1371,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.BLACKBERRY = 6; /** * @memberof cc.sys + * @name NACL * @constant * @default * @type {Number} @@ -1323,6 +1379,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.NACL = 7; /** * @memberof cc.sys + * @name EMSCRIPTEN * @constant * @default * @type {Number} @@ -1330,6 +1387,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.EMSCRIPTEN = 8; /** * @memberof cc.sys + * @name TIZEN * @constant * @default * @type {Number} @@ -1337,6 +1395,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.TIZEN = 9; /** * @memberof cc.sys + * @name WINRT * @constant * @default * @type {Number} @@ -1344,6 +1403,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.WINRT = 10; /** * @memberof cc.sys + * @name WP8 * @constant * @default * @type {Number} @@ -1351,6 +1411,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.WP8 = 11; /** * @memberof cc.sys + * @name MOBILE_BROWSER * @constant * @default * @type {Number} @@ -1358,6 +1419,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.MOBILE_BROWSER = 100; /** * @memberof cc.sys + * @name DESKTOP_BROWSER * @constant * @default * @type {Number} @@ -1384,16 +1446,12 @@ cc._initSys = function (config, CONFIG_KEY) { /** * Is native ? This is set to be true in jsb auto. - * @constant + * @memberof cc.sys + * @name isNative * @type {Boolean} */ sys.isNative = false; - /** - * WhiteList of browser for WebGL. - * @constant - * @type {Array} - */ var webglWhiteList = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI]; var multipleAudioWhiteList = [ sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_BAIDU_APP, @@ -1403,15 +1461,34 @@ cc._initSys = function (config, CONFIG_KEY) { var win = window, nav = win.navigator, doc = document, docEle = doc.documentElement; var ua = nav.userAgent.toLowerCase(); + /** + * Indicate whether system is mobile system + * @memberof cc.sys + * @name isMobile + * @type {Boolean} + */ sys.isMobile = ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1; + + /** + * Indicate the running platform + * @memberof cc.sys + * @name platform + * @type {Number} + */ sys.platform = sys.isMobile ? sys.MOBILE_BROWSER : sys.DESKTOP_BROWSER; var currLanguage = nav.language; currLanguage = currLanguage ? currLanguage : nav.browserLanguage; currLanguage = currLanguage ? currLanguage.split("-")[0] : sys.LANGUAGE_ENGLISH; + + /** + * Indicate the current language of the running system + * @memberof cc.sys + * @name language + * @type {String} + */ sys.language = currLanguage; - /** The type of browser */ var browserType = sys.BROWSER_TYPE_UNKNOWN; var browserTypes = ua.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i) || ua.match(/chrome|safari/i); @@ -1423,6 +1500,12 @@ cc._initSys = function (config, CONFIG_KEY) { browserType = sys.BROWSER_TYPE_ANDROID; else if (browserType == "trident") browserType = sys.BROWSER_TYPE_IE; } + /** + * Indicate the running browser type + * @memberof cc.sys + * @name browserType + * @type {String} + */ sys.browserType = browserType; @@ -1489,7 +1572,11 @@ cc._initSys = function (config, CONFIG_KEY) { sys._supportWebAudio = false; } - /** LocalStorage is a local storage component. + /** + * cc.sys.localStorage is a local storage component. + * @memberof cc.sys + * @name localStorage + * @type {Object} */ try { var localStorage = sys.localStorage = win.localStorage; @@ -1516,7 +1603,7 @@ cc._initSys = function (config, CONFIG_KEY) { if (win.DeviceMotionEvent || win.DeviceOrientationEvent) capabilities["accelerometer"] = true; - /** Get the os of system */ + // Get the os of system var iOS = ( ua.match(/(iPad|iPhone|iPod)/i) ? true : false ); var isAndroid = ua.match(/android/i) || nav.platform.match(/android/i) ? true : false; var osName = sys.OS_UNKNOWN; @@ -1526,23 +1613,51 @@ cc._initSys = function (config, CONFIG_KEY) { else if (nav.appVersion.indexOf("X11") != -1) osName = sys.OS_UNIX; else if (isAndroid) osName = sys.OS_ANDROID; else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; + + /** + * Indicate the running os name + * @memberof cc.sys + * @name os + * @type {String} + */ sys.os = osName; - // Forces the garbage collector + /** + * Forces the garbage collection + * @memberof cc.sys + * @name garbageCollect + * @function + */ sys.garbageCollect = function () { // N/A in cocos2d-html5 }; - // Dumps rooted objects + /** + * Dumps rooted objects + * @memberof cc.sys + * @name dumpRoot + * @function + */ sys.dumpRoot = function () { // N/A in cocos2d-html5 }; - // restarts the JS VM + /** + * Restart the JS VM + * @memberof cc.sys + * @name restartVM + * @function + */ sys.restartVM = function () { // N/A in cocos2d-html5 }; + /** + * Dump system informations + * @memberof cc.sys + * @name dump + * @function + */ sys.dump = function () { var self = this; var str = ""; @@ -1807,12 +1922,10 @@ cc._setContextMenuEnable = function (enabled) { /** * An object to boot the game. - * @memberof cc - * @global - * @type {Object} + * @class * @name cc.game */ -cc.game = { +cc.game = /** @lends cc.game# */{ DEBUG_MODE_NONE: 0, DEBUG_MODE_INFO: 1, DEBUG_MODE_WARN: 2, @@ -1880,10 +1993,7 @@ cc.game = { self._paused = true; self._runMainLoop(); }, - /** - * Run game. - * @private - */ + //Run game. _runMainLoop: function () { var self = this, callback, config = self.config, CONFIG_KEY = self.CONFIG_KEY, director = cc.director; @@ -1938,11 +2048,6 @@ cc.game = { }, false); }, - /** - * Init config. - * @returns {*} - * @private - */ _initConfig: function () { var self = this, CONFIG_KEY = self.CONFIG_KEY; var _init = function (cfg) { diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 6053894a3d..01b6643042 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -24,11 +24,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace - * @namespace - * @name cc - */ var cc = cc || {}; /** diff --git a/jsb_apis.js b/jsb_apis.js index 47818ce72d..1cf673dec1 100644 --- a/jsb_apis.js +++ b/jsb_apis.js @@ -23,8 +23,15 @@ ****************************************************************************/ /** - * @namespace jsb + * The namespace for jsb exclusive APIs, all APIs in this namespace should never be used in Web engine. + * So please check whether the running environment is native or not before any usage. + * @namespace * @name jsb + * @example + * + * if(cc.sys.isNative) { + * cc.log(cc.fileUtils.fullPathForFilename("test.js")); + * } */ var jsb = jsb || {}; @@ -37,7 +44,7 @@ var jsb = jsb || {}; * @name jsb.fileUtils * @extend cc.Class */ -jsb.fileUtils = /** @lends jsb.FileUtils# */{ +jsb.fileUtils = /** @lends jsb.fileUtils# */{ /** * @function fullPathForFilename @@ -290,9 +297,9 @@ jsb.fileUtils = /** @lends jsb.FileUtils# */{ }; /** - * @class EventAssetsManager + * @class */ -jsb.EventAssetsManager = { +jsb.EventAssetsManager = cc.Class.extend(/** @lends jsb.EventAssetsManager# */{ /** * @function getAssetsManager @@ -400,13 +407,13 @@ jsb.EventAssetsManager = { ) { } -}; +}); /** - * @class EventListenerAssetsManager + * @class */ -jsb.EventListenerAssetsManager = { +jsb.EventListenerAssetsManager = cc.Class.extend(/** @lends jsb.EventListenerAssetsManager# */{ /** * @function init @@ -445,15 +452,15 @@ jsb.EventListenerAssetsManager = { { } -}; +}); /** - * @class jsb.AssetsManager + * @class * jsb.AssetsManager is the native AssetsManager for your game resources or scripts. * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en * Only available in JSB */ -jsb.AssetsManager = { +jsb.AssetsManager = cc.Class.extend(/** @lends jsb.AssetsManager# */{ /** * @function getState @@ -533,12 +540,12 @@ jsb.AssetsManager = { { } -}; +}); /** - * @class jsb.Manifest + * @class */ -jsb.Manifest = { +jsb.Manifest = cc.Class.extend(/** @lends jsb.Manifest# */{ /** * @function getManifestFileUrl @@ -593,18 +600,18 @@ jsb.Manifest = { { return ; } -}; +}); /** - * @type {Object} - * @name jsb.reflection * jsb.reflection is a bridge to let you invoke Java static functions. * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/reflection/en * Only available on iOS/Mac/Android platform + * @class + * @name jsb.reflection */ jsb.reflection = /** @lends jsb.reflection# */{ /** - * @function callStaticMethod + * @function */ callStaticMethod : function(){ } From af37d52627214e66a1b3a4516bab18e2c6bb6165 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 10 Sep 2014 21:55:25 +0800 Subject: [PATCH 0640/1564] Fixed a bug of cc.LabelBMFont on IE 11 --- cocos2d/core/base-nodes/CCNode.js | 2 -- cocos2d/core/sprites/CCSprite.js | 1 - cocos2d/labels/CCLabelBMFont.js | 39 ++++++++++++++----------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 9665a398e1..98ea360ecf 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1104,8 +1104,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} Var The arrival order. */ setOrderOfArrival: function (Var) { - if(this.arrivalOrder == NaN) - debugger; this.arrivalOrder = Var; }, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 307f9a77ff..b23fda3671 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -89,7 +89,6 @@ cc.generateTintImage = function (texture, tintedImgCache, color, rect, renderCan var r = color.r / 255; var g = color.g / 255; var b = color.b / 255; - var w = Math.min(rect.width, tintedImgCache[0].width); var h = Math.min(rect.height, tintedImgCache[0].height); var buff = renderCanvas; diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index bf602e24f9..c200741499 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -368,10 +368,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (cc._renderType == cc._RENDER_TYPE_WEBGL) { locChild.updateDisplayedColor(this._displayedColor); } else { - if(cc.sys._supportCanvasNewBlendModes) - cc.Node.prototype.updateDisplayedColor.call(locChild, this._displayedColor); - else - locChild.updateDisplayedColor(this._displayedColor); + cc.Node.prototype.updateDisplayedColor.call(locChild, this._displayedColor); locChild.setNodeDirty(); } } @@ -1075,7 +1072,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var _p = cc.LabelBMFont.prototype; -if(cc._renderType === cc._RENDER_TYPE_CANVAS){ +if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (!cc.sys._supportCanvasNewBlendModes) { _p._changeTextureColor = function () { if (cc._renderType == cc._RENDER_TYPE_WEBGL) @@ -1087,9 +1084,10 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS){ return; var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); if (cacheTextureForColor) { - if (locElement instanceof HTMLCanvasElement && !this._rectRotated) + if (locElement instanceof HTMLCanvasElement && !this._rectRotated) { cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); - else { + this.setTexture(locTexture); + } else { locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); @@ -1099,21 +1097,20 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS){ } } }; - } else { - _p.setTexture = function (texture) { - var locChildren = this._children; - var locDisplayedColor = this._displayedColor; - for (var i = 0; i < locChildren.length; i++) { - var selChild = locChildren[i]; - var childDColor = selChild._displayedColor; - if (this._textureForCanvas != selChild._texture && (childDColor.r !== locDisplayedColor.r || - childDColor.g !== locDisplayedColor.g || childDColor.b !== locDisplayedColor.b)) - continue; - selChild.texture = texture; - } - this._textureForCanvas = texture; - }; } + _p.setTexture = function (texture) { + var locChildren = this._children; + var locDisplayedColor = this._displayedColor; + for (var i = 0; i < locChildren.length; i++) { + var selChild = locChildren[i]; + var childDColor = selChild._displayedColor; + if (this._textureForCanvas != selChild._texture && (childDColor.r !== locDisplayedColor.r || + childDColor.g !== locDisplayedColor.g || childDColor.b !== locDisplayedColor.b)) + continue; + selChild.texture = texture; + } + this._textureForCanvas = texture; + }; } From 91374994cd2f2b0b27018b6f75c918d5c35035d8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 11 Sep 2014 13:37:16 +0800 Subject: [PATCH 0641/1564] Fixed #5924: fixed a bug of cc.Component that its onExit isn't called. --- cocos2d/core/base-nodes/CCNode.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 98ea360ecf..0e9d6e48c1 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1557,6 +1557,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ this._running = false; this.pause(); this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExit); + this.removeAllComponents(); }, // actions @@ -2042,7 +2043,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, /** - * Removes all components + * Removes all components of cc.Node, it called when cc.Node is exiting from stage. * @function */ removeAllComponents: function () { From d49f2495711f9d30d647376b38362e50bc4b16f8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 11 Sep 2014 18:17:53 +0800 Subject: [PATCH 0642/1564] Issue #5925: Cannot read property 'content' of undefined CCEGLView.js:257 --- cocos2d/core/platform/CCEGLView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 2797c173ee..718bb4565d 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -254,7 +254,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ if(cc.sys.isMobile) viewportMetas["target-densitydpi"] = this._targetDensityDPI; - content = elems ? elems[0].content : ""; + content = (elems && elems.length>0) ? elems[0].content : ""; for (var key in viewportMetas) { var pattern = new RegExp(key); From 246c7570aaf6611ebf9b99fb9644e7238429c9eb Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 11 Sep 2014 18:28:22 +0800 Subject: [PATCH 0643/1564] Added fault tolerance to cc.Node for cc.Component. --- cocos2d/core/base-nodes/CCNode.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 0e9d6e48c1..36d59e3daf 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2021,7 +2021,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Component} The component found */ getComponent: function (name) { - return this._componentContainer.getComponent(name); + if(this._componentContainer) + return this._componentContainer.getComponent(name); + return null; }, /** @@ -2030,7 +2032,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {cc.Component} component */ addComponent: function (component) { - this._componentContainer.add(component); + if(this._componentContainer) + this._componentContainer.add(component); }, /** @@ -2039,7 +2042,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {String|cc.Component} component */ removeComponent: function (component) { - return this._componentContainer.remove(component); + if(this._componentContainer) + return this._componentContainer.remove(component); + return false; }, /** @@ -2047,7 +2052,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function */ removeAllComponents: function () { - this._componentContainer.removeAll(); + if(this._componentContainer) + this._componentContainer.removeAll(); }, grid: null, From 51d27cba10f6f0f15fc0e995a73b780a9221d35a Mon Sep 17 00:00:00 2001 From: SmallAiTT <536762164@qq.com> Date: Thu, 11 Sep 2014 20:32:19 +0800 Subject: [PATCH 0644/1564] Make cc.async.waterfall similar to async.waterfall of async.js. --- CCBoot.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index a7600d98cf..38cb4ddaee 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -313,19 +313,21 @@ cc.async = /** @lends cc.async# */{ */ waterfall : function(tasks, cb, target){ var args = []; + var lastResults = [null];//the array to store the last results var asyncPool = new cc.AsyncPool(tasks, 1, function (func, index, cb1) { args.push(function (err) { args = Array.prototype.slice.call(arguments, 1); + if(tasks.length - 1 == index) lastResults = lastResults.concat(args);//while the last task cb1.apply(null, arguments); }); func.apply(target, args); - }, function (err, results) { + }, function (err) { if (!cb) return; if (err) return cb.call(target, err); - cb.call(target, null, results[results.length - 1]); + cb.apply(target, lastResults); }); asyncPool.flow(); return asyncPool; From 353d481cd62a91b11f1c3568f7b2a11a434eb86a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 13 Sep 2014 21:10:12 +0800 Subject: [PATCH 0645/1564] Fixed #5930: Fix API name mistake --- extensions/ccui/uiwidgets/UIText.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 964cb76077..a56fe8210f 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -380,7 +380,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {cc.Size} outlineSize */ enableOutline: function(outlineColor, outlineSize){ - this._labelRenderer.enableOutline(outlineColor, outlineSize); + this._labelRenderer.enableStroke(outlineColor, outlineSize); }, /** From 837bc5056082be1dffb8a97c84ec91fc53d0dc03 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 14 Sep 2014 12:24:50 +0800 Subject: [PATCH 0646/1564] Fixed #5931: Change cc.winSize correctly after applying resolution policy --- cocos2d/core/platform/CCEGLView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 718bb4565d..d6049a1dec 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -558,10 +558,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ var director = cc.director; director._winSizeInPoints.width = _t._designResolutionSize.width; director._winSizeInPoints.height = _t._designResolutionSize.height; - cc.winSize.width = director._winSizeInPoints.width; - cc.winSize.height = director._winSizeInPoints.height; policy.postApply(_t); + cc.winSize.width = director._winSizeInPoints.width; + cc.winSize.height = director._winSizeInPoints.height; if (cc._renderType == cc._RENDER_TYPE_WEBGL) { // reset director's member variables to fit visible rect From 987c326616c02e9f4f681b930598edfb0b0733d0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 15 Sep 2014 10:30:45 +0800 Subject: [PATCH 0647/1564] Fixed #5927: fixed a mistake of ccs.LabelAtlasReader --- extensions/ccui/base-classes/UIWidget.js | 15 ++++++++------- extensions/cocostudio/reader/GUIReader.js | 18 ++++++++++-------- .../LabelAtlasReader/LabelAtlasReader.js | 11 ++--------- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 0da4ae3379..c1c82da4cb 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -517,13 +517,14 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchEnabled = enable; //TODO need consider remove and re-add. if (this._touchEnabled) { - this._touchListener = cc.EventListener.create({ - event: cc.EventListener.TOUCH_ONE_BY_ONE, - swallowTouches: true, - onTouchBegan: this.onTouchBegan.bind(this), - onTouchMoved: this.onTouchMoved.bind(this), - onTouchEnded: this.onTouchEnded.bind(this) - }); + if(!this._touchListener) + this._touchListener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: this.onTouchBegan.bind(this), + onTouchMoved: this.onTouchMoved.bind(this), + onTouchEnded: this.onTouchEnded.bind(this) + }); cc.eventManager.addListener(this._touchListener, this); } else { cc.eventManager.removeListener(this._touchListener); diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 4ab2377069..4a7271737b 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -678,15 +678,17 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend(/** @lends cc setPropsForLabelAtlasFromJsonDictionary: function (widget, options) { this.setPropsForWidgetFromJsonDictionary(widget, options); var labelAtlas = widget; - var sv = (options["stringValue"] !== undefined); - var cmf = (options["charMapFile"] !== undefined); - var iw = (options["itemWidth"] !== undefined); - var ih = (options["itemHeight"] !== undefined); - var scm = (options["startCharMap"] !== undefined); - if (sv && cmf && iw && ih && scm && options["charMapFile"]) { - var cmft = options["charMapFile"]; + + var cmft = options["charMapFile"], svValue = options["stringValue"], iwValue = options["itemWidth"]; + var ihValue = options["itemHeight"], scmValue = options["startCharMap"]; + var sv = (svValue !== undefined); + var cmf = (cmft !== undefined); + var iw = (iwValue !== undefined); + var ih = (ihValue !== undefined); + var scm = (scmValue !== undefined); + if (sv && cmf && iw && ih && scm && cmft) { var cmf_tp = this._filePath + cmft; - labelAtlas.setProperty(options["stringValue"], cmf_tp, options["itemWidth"], options["itemHeight"], options["startCharMap"]); + labelAtlas.setProperty(svValue, cmf_tp, iwValue, ihValue, scmValue); } this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index d2c455282f..05127cb8d6 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -44,14 +44,13 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ * @param {Object} options */ setPropsFromJsonDictionary: function(widget, options){ - ccs.WidgetReader.setPropsFromJsonDictionary.call(this, widget, options); var jsonPath = ccs.uiReader.getFilePath(); var labelAtlas = widget; var sv = options["stringValue"]; - var cmf = options["charMapFileData"] || options["charMapFile"]; + var cmf = options["charMapFileData"]; // || options["charMapFile"]; var iw = options["itemWidth"]; var ih = options["itemHeight"]; var scm = options["startCharMap"]; @@ -63,13 +62,7 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ var tp_c = jsonPath; var cmfPath = cmftDic["path"]; var cmf_tp = tp_c + cmfPath; - labelAtlas.setProperty( - options["stringValue"], - cmf_tp, - options["itemWidth"], - options["itemHeight"], - options["startCharMap"] - ); + labelAtlas.setProperty(sv, cmf_tp, iw, ih, scm); break; case 1: cc.log("Wrong res type of LabelAtlas!"); From ffcb42c94221c89f1d5f3cb97b5ac59f39a8062a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 15 Sep 2014 11:19:05 +0800 Subject: [PATCH 0648/1564] Fixed #5927: fixed a mistake of ccs.GUIReader --- extensions/cocostudio/reader/GUIReader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 4a7271737b..46c38714f1 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -679,7 +679,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend(/** @lends cc this.setPropsForWidgetFromJsonDictionary(widget, options); var labelAtlas = widget; - var cmft = options["charMapFile"], svValue = options["stringValue"], iwValue = options["itemWidth"]; + var cmft = options["charMapFileData"], svValue = options["stringValue"], iwValue = options["itemWidth"]; var ihValue = options["itemHeight"], scmValue = options["startCharMap"]; var sv = (svValue !== undefined); var cmf = (cmft !== undefined); From 09f47468612c846fce8c0852ddbc1321cb9ab903 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 16 Sep 2014 09:43:24 +0800 Subject: [PATCH 0649/1564] Fixed #2260: _removeByComponent method have bad "if" --- extensions/cocostudio/components/CCComponentContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/components/CCComponentContainer.js b/extensions/cocostudio/components/CCComponentContainer.js index 2b4c60446a..c1cc46ba09 100644 --- a/extensions/cocostudio/components/CCComponentContainer.js +++ b/extensions/cocostudio/components/CCComponentContainer.js @@ -100,7 +100,7 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ }, _removeByComponent:function(component){ - if(component) + if(!component) return false; component.onExit(); component.setOwner(null); From 0aea9fcdaa7178683372f005de1eb623c8ecd676 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 16 Sep 2014 09:50:22 +0800 Subject: [PATCH 0650/1564] Issue #5933: migrate rendererCanvas, node, labelTTF to v3.1 --- cocos2d/core/base-nodes/CCNode.js | 126 +++- cocos2d/core/labelttf/CCLabelTTF.js | 79 ++- cocos2d/core/renderer/RendererCanvas.js | 740 ++++++++++++++++++++++++ moduleConfig.json | 2 + 4 files changed, 894 insertions(+), 53 deletions(-) create mode 100644 cocos2d/core/renderer/RendererCanvas.js diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 36d59e3daf..e5894ea1a7 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -161,7 +161,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // Cached parent serves to construct the cached parent chain _cachedParent: null, _transformGLDirty: null, - _transform: null, + _transform: null, //local transform + _transformWorld: null, //world transform _inverse: null, //since 2.0 api @@ -194,6 +195,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _usingNormalizedPosition: false, _hashOfName: 0, + _curLevel: -1, //for new renderer + _rendererCmd:null, + _renderCmdDirty: false, + _initNode: function () { var _t = this; _t._anchorPoint = cc.p(0, 0); @@ -202,6 +207,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _t._position = cc.p(0, 0); _t._children = []; _t._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + _t._transformWorld = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; var director = cc.director; _t._actionManager = director.getActionManager(); @@ -763,6 +769,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if(this._visible != visible){ this._visible = visible; if(visible) this.setNodeDirty(); + cc.renderer.childrenOrderDirty = true; } }, @@ -1423,12 +1430,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // set parent nil at the end child.parent = null; + child._cachedParent = null; cc.arrayRemoveObject(this._children, child); }, _insertChild: function (child, z) { - this._reorderChildDirty = true; + cc.renderer.childrenOrderDirty = this._reorderChildDirty = true; this._children.push(child); child._setLocalZOrder(z); }, @@ -1440,8 +1448,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} zOrder Z order for drawing priority. Please refer to setZOrder(int) */ reorderChild: function (child, zOrder) { - cc.assert(child, cc._LogInfos.Node_reorderChild) - this._reorderChildDirty = true; + cc.assert(child, cc._LogInfos.Node_reorderChild); + cc.renderer.childrenOrderDirty = this._reorderChildDirty = true; child.arrivalOrder = cc.s_globalOrderOfArrival; cc.s_globalOrderOfArrival++; child._setLocalZOrder(zOrder); @@ -2542,7 +2550,16 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ isOpacityModifyRGB: function () { return false; - } + }, + + toRenderer: function(){ + //send the update to renderer. + }, + + _initRendererCmd: function(){ + }, + + _transformForRenderer: null }); /** @@ -2563,12 +2580,16 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _p = cc.Node.prototype; _p.ctor = function () { this._initNode(); + this._initRendererCmd(); }; _p.setNodeDirty = function () { var _t = this; - _t._setNodeDirtyForCache(); - _t._transformDirty === false && (_t._transformDirty = _t._inverseDirty = true); + if(_t._transformDirty === false){ + _t._setNodeDirtyForCache(); + _t._renderCmdDiry = _t._transformDirty = _t._inverseDirty = true; + cc.renderer.pushDirtyNode(this); + } }; _p.visit = function (ctx) { @@ -2577,11 +2598,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (!_t._visible) return; + if( _t._parent) + _t._curLevel = _t._parent._curLevel + 1; + //visit for canvas - var context = ctx || cc._renderContext, i; - var children = _t._children, child; - context.save(); - _t.transform(context); + var i, children = _t._children, child; + _t.toRenderer(); + _t.transform(); var len = children.length; if (len > 0) { _t.sortAllChildren(); @@ -2589,28 +2612,85 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { for (i = 0; i < len; i++) { child = children[i]; if (child._localZOrder < 0) - child.visit(context); + child.visit(); else break; } - _t.draw(context); + //_t.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); for (; i < len; i++) { - children[i].visit(context); + children[i].visit(); } - } else - _t.draw(context); - - this._cacheDirty = false; + } else{ + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); + } _t.arrivalOrder = 0; - context.restore(); + }; + + _p._transformForRenderer = function () { + var t = this.nodeToParentTransform(), worldT = this._transformWorld; + if(this._parent){ + var pt = this._parent._transformWorld; + //worldT = cc.AffineTransformConcat(t, pt); + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d + if(!this._skewX || this._skewY){ + var plt = this._parent._transform; + var xOffset = -(plt.b + plt.c) * t.ty ; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + }else{ + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty + } + } else { + worldT.a = t.a; + worldT.b = t.b; + worldT.c = t.c; + worldT.d = t.d; + worldT.tx = t.tx; + worldT.ty = t.ty; + } + this._renderCmdDiry = false; + if(!this._children || this._children.length === 0) + return; + var i, len, locChildren = this._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._transformForRenderer(); + } }; _p.transform = function (ctx) { // transform for canvas - var context = ctx || cc._renderContext, eglViewer = cc.view; - - var t = this.getNodeToParentTransform(); - context.transform(t.a, t.c, t.b, t.d, t.tx * eglViewer.getScaleX(), -t.ty * eglViewer.getScaleY()); + var t = this.nodeToParentTransform(), + worldT = this._transformWorld; //get the world transform + + if(this._parent){ + var pt = this._parent._transformWorld; + // cc.AffineTransformConcat is incorrect at get world transform + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d + + var plt = this._parent._transform; + var xOffset = -(plt.b + plt.c) * t.ty; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + } else { + worldT.a = t.a; + worldT.b = t.b; + worldT.c = t.c; + worldT.d = t.d; + worldT.tx = t.tx; + worldT.ty = t.ty; + } }; _p.getNodeToParentTransform = function () { diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 3beac954aa..1580f179af 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -135,10 +135,15 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this.string = strInfo; this._setColorsString(); this._updateTexture(); - this._needUpdateTexture = false; + this._setUpdateTextureDirty(); return true; }, + _setUpdateTextureDirty: function(){ + this._renderCmdDiry = this._needUpdateTexture = true; + cc.renderer.pushDirtyNode(this); + }, + ctor: function (text, fontName, fontSize, dimensions, hAlignment, vAlignment) { cc.Sprite.prototype.ctor.call(this); @@ -308,8 +313,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowBlur != shadowBlur) this._shadowBlur = shadowBlur; - - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); }, _getShadowOffsetX: function () { @@ -321,7 +325,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowOffset.x != x) { this._shadowOffset.x = x; - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -334,7 +338,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowOffset._y != y) { this._shadowOffset._y = y; - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -348,7 +352,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowOffset.x != offset.x || this._shadowOffset.y != offset.y) { this._shadowOffset.x = offset.x; this._shadowOffset.y = offset.y; - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -362,7 +366,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowOpacity != shadowOpacity) { this._shadowOpacity = shadowOpacity; this._setColorsString(); - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -375,7 +379,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowBlur != shadowBlur) { this._shadowBlur = shadowBlur; - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -385,7 +389,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ disableShadow: function () { if (this._shadowEnabled) { this._shadowEnabled = false; - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -408,8 +412,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._strokeSize !== strokeSize) this._strokeSize = strokeSize || 0; - - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); }, _getStrokeStyle: function () { @@ -425,8 +428,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ locStrokeColor.g = strokeStyle.g; locStrokeColor.b = strokeStyle.b; this._setColorsString(); - - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -436,10 +438,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _setLineWidth: function (lineWidth) { if (this._strokeEnabled === false) this._strokeEnabled = true; - if (this._strokeSize !== lineWidth) { this._strokeSize = lineWidth || 0; - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -449,7 +450,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ disableStroke: function () { if (this._strokeEnabled) { this._strokeEnabled = false; - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -559,7 +560,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._updateString(); // Force update - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, _updateString: function () { @@ -575,7 +576,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._hAlignment = alignment; // Force update - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -588,7 +589,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._vAlignment = verticalAlignment; // Force update - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -610,7 +611,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._dimensions.height = height; this._updateString(); // Force udpate - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -622,7 +623,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._dimensions.width = width; this._updateString(); // Force udpate - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -634,7 +635,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._dimensions.height = height; this._updateString(); // Force udpate - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -648,7 +649,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._fontStyleStr = fontSize + "px '" + this._fontName + "'"; this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, fontSize); // Force update - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -662,7 +663,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._fontStyleStr = this._fontSize + "px '" + fontName + "'"; this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, this._fontSize); // Force update - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -677,7 +678,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._fontStyleStr = fontStyle; this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize); // Force update - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }, @@ -1050,12 +1051,28 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.setColor = function (color3) { cc.Node.prototype.setColor.call(this, color3); - this._setColorsString(); }; + _p._transformForRenderer = function(){ + if (this._needUpdateTexture) { + this._needUpdateTexture = false; + this._updateTexture(); + this.toRenderer(); + } + cc.Node.prototype._transformForRenderer.call(this); + }; + + _p.toRenderer = function(){ + if (this._needUpdateTexture) { + this._needUpdateTexture = false; + this._updateTexture(); + } + cc.Sprite.prototype.toRenderer.call(this); + }; + _p._setColorsString = function () { - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); var locDisplayColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; var locStrokeColor = this._strokeColor, locFontFillColor = this._textFillColor; @@ -1077,7 +1094,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; cc.Sprite.prototype.setOpacity.call(this, opacity); this._setColorsString(); - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); }; //TODO: _p._updateDisplayedOpacityForCanvas @@ -1101,7 +1118,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextFillColor.b = tintColor.b; this._setColorsString(); - this._needUpdateTexture = true; + this._setUpdateTextureDirty(); } }; @@ -1114,9 +1131,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this.setContentSize(untrimmedSize); this.setVertexRect(rect); - var locTextureCoordRect = this._textureRect_Canvas; + var locTextureCoordRect = this._rendererCmd._textureCoord; locTextureCoordRect.x = rect.x; locTextureCoordRect.y = rect.y; + locTextureCoordRect.renderX = rect.x; + locTextureCoordRect.renderY = rect.y; locTextureCoordRect.width = rect.width; locTextureCoordRect.height = rect.height; locTextureCoordRect.validRect = !(locTextureCoordRect.width === 0 || locTextureCoordRect.height === 0 diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js new file mode 100644 index 0000000000..3d3ecb18eb --- /dev/null +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -0,0 +1,740 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.rendererCanvas = { + childrenOrderDirty: true, + _transformNodePool: [], //save nodes transform dirty + _renderCmds: [], //save renderer commands + + _isCacheToCanvasOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds + _cacheToCanvasCmds: [], // an array saves the renderer commands need for cache to other canvas + + /** + * drawing all renderer command to context (default is cc._renderContext) + * @param {CanvasRenderingContext2D} [ctx=cc._renderContext] + */ + rendering: function (ctx) { + var locCmds = this._renderCmds, + i, + len, + scaleX = cc.view.getScaleX(), + scaleY = cc.view.getScaleY(); + var context = ctx || cc._renderContext; + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(context, scaleX, scaleY); + } + }, + + /** + * drawing all renderer command to cache canvas' context + * @param {CanvasRenderingContext2D} ctx + */ + _renderingToCacheCanvas: function (ctx) { + var locCmds = this._cacheToCanvasCmds, i, len; + if (!ctx) + cc.log("The context of RenderTexture is invalid."); + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(ctx, 1, 1); + } + + locCmds.length = 0; + this._isCacheToCanvasOn = false; + }, + + resetFlag: function () { + this.childrenOrderDirty = false; + this._transformNodePool.length = 0; + }, + + transform: function () { + var locPool = this._transformNodePool; + //sort the pool + locPool.sort(this._sortNodeByLevelAsc); + + //transform node + for (var i = 0, len = locPool.length; i < len; i++) { + if (locPool[i]._renderCmdDiry) //TODO need modify name for LabelTTF + locPool[i]._transformForRenderer(); + } + locPool.length = 0; + }, + + transformDirty: function () { + return this._transformNodePool.length > 0; + }, + + _sortNodeByLevelAsc: function (n1, n2) { + return n1._curLevel - n2._curLevel; + }, + + pushDirtyNode: function (node) { + //if (this._transformNodePool.indexOf(node) === -1) + this._transformNodePool.push(node); + }, + + clearRenderCommands: function () { + this._renderCmds.length = 0; + }, + + pushRenderCommand: function (cmd) { + if (this._isCacheToCanvasOn) { + if (this._cacheToCanvasCmds.indexOf(cmd) === -1) + this._cacheToCanvasCmds.push(cmd); + } else { + if (this._renderCmds.indexOf(cmd) === -1) + this._renderCmds.push(cmd); + } + } +}; +cc.renderer = cc.rendererCanvas; + +cc.TextureRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; //reference of node's transformWorld + this._texture = null; + this._isLighterMode = false; + this._opacity = 1; + this._textureCoord = { + renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. + renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. + x: 0, //the x of texture coordinate for node. + y: 0, //the y of texture coordinate for node. + width: 0, + height: 0, + validRect: false // + }; + this._drawingRect = cc.rect(0, 0, 0, 0); +}; + +cc.TextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var _t = this; + var _node = _t._node; + var context = ctx || cc._renderContext, + locTextureCoord = _t._textureCoord; + if (!locTextureCoord.validRect || !_node._visible) + return; //draw nothing + + var t = this._transform, locDrawingRect = _t._drawingRect, image, curColor; + if(t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || _node._flippedX || _node._flippedY){ + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (_t._isLighterMode) + context.globalCompositeOperation = 'lighter'; + + if (_node._flippedX) + context.scale(-1, 1); + if (_node._flippedY) + context.scale(1, -1); + + if (_t._texture && locTextureCoord.validRect) { + if (_t._texture._isLoaded) { + context.globalAlpha = _t._opacity; + image = _t._texture._htmlElementObj; + + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locDrawingRect.x, + locDrawingRect.y, + locDrawingRect.width, + locDrawingRect.height + ); + + } + + } else if (!_t._texture && locTextureCoord.validRect) { + curColor = _t._color; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; + context.fillRect(locDrawingRect.x, locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + } + context.restore(); + } else { + if (_t._isLighterMode){ + context.save(); + context.globalCompositeOperation = 'lighter'; + } + + if (_t._texture && locTextureCoord.validRect) { + if (_t._texture._isLoaded) { + context.globalAlpha = _t._opacity; + image = _t._texture._htmlElementObj; + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + t.tx * scaleX + locDrawingRect.x, + -t.ty * scaleY + locDrawingRect.y, + locDrawingRect.width, + locDrawingRect.height + ); + } + } else if (!_t._texture && locTextureCoord.validRect && _node._displayedColor) { + curColor = _node._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; + context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + } + if (_t._isLighterMode) + context.restore(); + } + cc.g_NumberOfDraws++; +}; + +cc.RectRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._isLighterMode = false; + this._drawingRect = cc.rect(0, 0, 0, 0); + this._color = cc.color(255, 255, 255, 255); +}; + +cc.RectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, t = this._transform, curColor = this._color, locRect = this._drawingRect; + context.save(); + if (this._isLighterMode) + context.globalCompositeOperation = 'lighter'; + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," + + (0 | curColor.b) + "," + curColor.a + ")"; + context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); + + context.restore(); + cc.g_NumberOfDraws++; +}; + +cc.GradientRectRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; // {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._isLighterMode = false; + this._opacity = 1; + this._drawingRect = cc.rect(0, 0, 0, 0); + this._startColor = cc.color(255, 255, 255, 255); + this._endColor = cc.color(255, 255, 255, 255); + this._startPoint = cc.p(0, 0); + this._endPoint = cc.p(0, 0); +}; + +cc.GradientRectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, _t = this, t = this._transform; + context.save(); + if (_t._isLighterMode) + context.globalCompositeOperation = 'lighter'; + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + var opacity = _t._opacity, locRect = this._drawingRect; + var gradient = context.createLinearGradient(_t._startPoint.x, _t._startPoint.y, _t._endPoint.x, _t._endPoint.y); + var locStartColor = _t._startColor, locEndColor = _t._endColor; + gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," + + Math.round(locStartColor.b) + "," + (opacity * (locStartColor.a / 255)).toFixed(4) + ")"); + gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + + Math.round(locEndColor.b) + "," + (opacity * (locEndColor.a / 255)).toFixed(4) + ")"); + context.fillStyle = gradient; + context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); + + context.restore(); + cc.g_NumberOfDraws++; +}; + +cc.ParticleRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._isBlendAdditive = false; + this._drawMode = cc.ParticleSystem.SHAPE_MODE; + this._shapeType = cc.ParticleSystem.BALL_SHAPE; + this._texture = null; + this._pointRect = {x: 0, y: 0, width: 0, height: 0}; +}; + +cc.ParticleRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, t = this._transform; + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if (this._isBlendAdditive) + context.globalCompositeOperation = 'lighter'; + else + context.globalCompositeOperation = 'source-over'; + + var i, particle, lpx; + var particleCount = this._node.particleCount, particles = this._node._particles; + if (this._drawMode == cc.ParticleSystem.TEXTURE_MODE) { + // Delay drawing until the texture is fully loaded by the browser + if (!this._texture || !this._texture._isLoaded) { + context.restore(); + return; + } + var element = this._texture.getHtmlElementObj(); + if (!element.width || !element.height) { + context.restore(); + return; + } + + var textureCache = cc.textureCache, drawElement = element; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + + context.globalAlpha = particle.color.a / 255; + + context.save(); + context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); + + var size = Math.floor(particle.size / 4) * 4; + var w = this._pointRect.width; + var h = this._pointRect.height; + + context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); + + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + + if (particle.isChangeColor) { + var cacheTextureForColor = textureCache.getTextureColors(element); + if (cacheTextureForColor) { + // Create another cache for the tinted version + // This speeds up things by a fair bit + if (!cacheTextureForColor.tintCache) { + cacheTextureForColor.tintCache = cc.newElement('canvas'); + cacheTextureForColor.tintCache.width = element.width; + cacheTextureForColor.tintCache.height = element.height; + } + cc.generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); + drawElement = cacheTextureForColor.tintCache; + } + } + context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); + context.restore(); + } + } else { + var drawTool = cc._drawingUtil; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + context.globalAlpha = particle.color.a / 255; + + context.save(); + context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); + if (this._shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + drawTool.drawStar(context, lpx, particle.color); + } else + drawTool.drawColorBall(context, lpx, particle.color); + context.restore(); + } + } + context.restore(); + cc.g_NumberOfDraws++; +}; + +// the canvas implement of renderCommand for cc.ProgressTimer +cc.ProgressRenderCmdCanvas = function (node) { + this._PI180 = Math.PI / 180; + + this._node = node; + this._transform = node._transformWorld; + this._sprite = null; + this._type = cc.ProgressTimer.TYPE_RADIAL; + this._barRect = cc.rect(0, 0, 0, 0); + this._origin = cc.p(0,0); + this._radius = 0; + this._startAngle = 270; + this._endAngle = 270; + this._counterClockWise = false; +}; + +cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, locSprite = this._sprite; + + var locTextureCoord = locSprite._rendererCmd._textureCoord; + if (!locSprite._texture || !locTextureCoord.validRect) + return; + + var t = this._transform; + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (locSprite._isLighterMode) + context.globalCompositeOperation = 'lighter'; + + context.globalAlpha = locSprite._displayedOpacity / 255; + + var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; + var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; + locDrawSizeCanvas.width = locRect.width * scaleX; + locDrawSizeCanvas.height = locRect.height * scaleY; + + if (locSprite._flippedX) { + flipXOffset = -locOffsetPosition.x - locRect.width; + context.scale(-1, 1); + } + if (locSprite._flippedY) { + flipYOffset = locOffsetPosition.y; + context.scale(1, -1); + } + + flipXOffset *= scaleX; + flipYOffset *= scaleY; + + //clip + if (this._type == cc.ProgressTimer.TYPE_BAR) { + var locBarRect = this._barRect; + context.beginPath(); + context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); + context.clip(); + context.closePath(); + } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { + var locOriginX = this._origin.x * scaleX; + var locOriginY = this._origin.y * scaleY; + context.beginPath(); + context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); + context.lineTo(locOriginX, locOriginY); + context.clip(); + context.closePath(); + } + + //draw sprite + var image = locSprite._texture.getHtmlElementObj(); + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); + + + context.restore(); + cc.g_NumberOfDraws++; +}; + +// the canvas implement of renderCommand for cc.RenderTexture +cc.RenderTextureRenderCmdCanvas = function(node){ + this._node = node; + + this._transform = node._transformWorld; + this._clearFlags = node.clearFlags; + this.autoDraw = node.autoDraw; + + this._cacheCanvas = null; + this._cacheContext = null; + + this._sprite = null; +}; + +cc.RenderTextureRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + // auto draw flag + var context = ctx || cc._renderContext; + var locNode = this._node, cacheCanvas = this._cacheCanvas, cacheCtx = this._cacheContext; + if (this.autoDraw) { + locNode.begin(); + + if (this._clearFlags) { + cacheCtx.save(); + cacheCtx.fillStyle = this._clearColorStr; + cacheCtx.clearRect(0, 0, cacheCanvas.width, -cacheCanvas.height); + cacheCtx.fillRect(0, 0, cacheCanvas.width, -cacheCanvas.height); + cacheCtx.restore(); + } + + //! make sure all children are drawn + locNode.sortAllChildren(); + var locChildren = locNode._children; + var childrenLen = locChildren.length; + var selfSprite = this.sprite; + for (var i = 0; i < childrenLen; i++) { + var getChild = locChildren[i]; + if (getChild != selfSprite) + getChild.visit(); + } + locNode.end(); + } + cc.g_NumberOfDraws++; +}; + +cc.DrawNodeRenderCmdCanvas = function(node){ + this._node = node; + this._buffer = null; + this._drawColor = null; + this._blendFunc = null; +}; + +cc.DrawNodeRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext, _t = this; + if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) + context.globalCompositeOperation = 'lighter'; + + for (var i = 0; i < _t._buffer.length; i++) { + var element = _t._buffer[i]; + switch (element.type) { + case cc.DrawNode.TYPE_DOT: + _t._drawDot(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_SEGMENT: + _t._drawSegment(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_POLY: + _t._drawPoly(context, element, scaleX, scaleY); + break; + } + } +}; + +cc.DrawNodeRenderCmdCanvas.prototype._drawDot = function (ctx, element, scaleX, scaleY) { + var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; + + ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.beginPath(); + ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); + ctx.closePath(); + ctx.fill(); +}; + +cc.DrawNodeRenderCmdCanvas.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { + var locColor = element.lineColor; + var locFrom = element.verts[0]; + var locTo = element.verts[1]; + var locLineWidth = element.lineWidth; + var locLineCap = element.lineCap; + + ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.lineWidth = locLineWidth * scaleX; + ctx.beginPath(); + ctx.lineCap = locLineCap; + ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); + ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); + ctx.stroke(); +}; + +cc.DrawNodeRenderCmdCanvas.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { + var _node = this._node; + var locVertices = element.verts; + var locLineCap = element.lineCap; + var locFillColor = element.fillColor; + var locLineWidth = element.lineWidth; + var locLineColor = element.lineColor; + var locIsClosePolygon = element.isClosePolygon; + var locIsFill = element.isFill; + var locIsStroke = element.isStroke; + if (locVertices == null) + return; + + var firstPoint = locVertices[0]; + + ctx.lineCap = locLineCap; + + if (locFillColor) { + ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," + + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; + } + + if (locLineWidth) { + ctx.lineWidth = locLineWidth * scaleX; + } + if (locLineColor) { + ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," + + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; + } + var t = _node._transformWorld; + + ctx.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + ctx.beginPath(); + ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); + for (var i = 1, len = locVertices.length; i < len; i++) + ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); + + if (locIsClosePolygon) + ctx.closePath(); + + if (locIsFill) + ctx.fill(); + if (locIsStroke) + ctx.stroke(); + ctx.restore(); +}; + +cc.ClippingNodeSaveRenderCmdCanvas = function(node){ + this._node = node; +}; + +cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + + var context = ctx || cc._renderContext; + + context.save(); + + var t = this._node._transformWorld; + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); +}; + +cc.ClippingNodeClipRenderCmdCanvas = function(node){ + this._node = node; +}; + +cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + if (this._node.inverted) { + var canvas = context.canvas; + context.save(); + + context.setTransform(1, 0, 0, 1, 0, 0); + + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); + + context.restore(); + } + var t = cc.AffineTransformInvert(this._node._transformWorld); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.clip(); +}; + +cc.ClippingNodeRestoreRenderCmdCanvas = function(node){ + this._node = node; +}; + +cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + context.restore(); +}; + + +//CHIPMUNK +cc.PhysicsDebugNodeRenderCmdCanvas = function(node){ + this._node = node; + this._buffer = node._buffer; +}; + +cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + + var _node = this._node; + + if (!_node.space) + return; + + _node.space.eachShape(cc.DrawShape.bind(_node)); + _node.space.eachConstraint(cc.DrawConstraint.bind(_node)); + cc.DrawNodeRenderCmdCanvas.prototype.rendering.call(this, ctx, scaleX, scaleY); + _node.clear(); +}; + +cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; +cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; +cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; + +cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; + +cc.PhysicsSpriteTransformCmdCanvas = function(node){ + this._node = node; +}; + +cc.PhysicsSpriteTransformCmdCanvas.prototype.rendering = function(){ + if(this._node.transform){ + this._node.transform(); + } +}; + +//--- TMXLayer's render command --- +cc.TMXLayerRenderCmdCanvas = function(tmxLayer){ + this._node = tmxLayer; + + this._transform = tmxLayer._transformWorld; + this._childrenRenderCmds = []; +}; + +cc.TMXLayerRenderCmdCanvas.prototype._copyRendererCmds = function(rendererCmds){ + if(!rendererCmds) + return; + + var locCacheCmds = this._childrenRenderCmds; + locCacheCmds.length = 0; + for(var i = 0, len = rendererCmds.length; i < len; i++){ + locCacheCmds[i] = rendererCmds[i]; + } +}; + +cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function(scaleX, scaleY){ + //TODO + var locNode = this._node; + if(locNode._cacheDirty){ + var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; + + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + //reset the cache context + var t = cc.AffineTransformInvert(this._transform); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + for(var i = 0, len = locCacheCmds.length; i < len; i++){ + locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); + if(locCacheCmds[i]._node) + locCacheCmds[i]._node._cacheDirty = false; + } + locCacheContext.restore(); + locNode._cacheDirty = false; + } +}; + +cc.TMXLayerRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + this._renderingChildToCache(scaleX, scaleY); + + var context = ctx || cc._renderContext; + var node = this._node; + //context.globalAlpha = this._opacity / 255; + var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); + var locCacheCanvas = node._cacheCanvas, t = this._transform; + //direct draw image by canvas drawImage + if (locCacheCanvas) { + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + var locCanvasHeight = locCacheCanvas.height * scaleY; + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + + context.restore(); + } + cc.g_NumberOfDraws++; +}; diff --git a/moduleConfig.json b/moduleConfig.json index 1f8693b00b..ac20e4a6de 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -70,6 +70,8 @@ "cocos2d/core/event-manager/CCEventManager.js", "cocos2d/core/event-manager/CCEventExtension.js", + "cocos2d/core/renderer/RendererCanvas.js", + "cocos2d/core/base-nodes/BaseNodesWebGL.js", "cocos2d/core/base-nodes/BaseNodesPropertyDefine.js", "cocos2d/core/base-nodes/CCNode.js", From 742f8a73a7f6bcbf1165a039545a3e3c61befd12 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 16 Sep 2014 15:32:44 +0800 Subject: [PATCH 0651/1564] Issue #5935: Support timeline --- extensions/cocostudio/reader/GUIReader.js | 4 + .../reader/timeline/ActionTimeline.js | 455 +++++++++++ .../reader/timeline/ActionTimelineCache.js | 345 ++++++++ .../cocostudio/reader/timeline/Frame.js | 742 ++++++++++++++++++ .../cocostudio/reader/timeline/NodeReader.js | 469 +++++++++++ .../cocostudio/reader/timeline/TimeLine.js | 310 ++++++++ moduleConfig.json | 8 +- 7 files changed, 2332 insertions(+), 1 deletion(-) create mode 100644 extensions/cocostudio/reader/timeline/ActionTimeline.js create mode 100644 extensions/cocostudio/reader/timeline/ActionTimelineCache.js create mode 100644 extensions/cocostudio/reader/timeline/Frame.js create mode 100644 extensions/cocostudio/reader/timeline/NodeReader.js create mode 100644 extensions/cocostudio/reader/timeline/TimeLine.js diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 4ab2377069..00fbe74a47 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -193,6 +193,10 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ return this._filePath; }, + setFilePath: function(path){ + this._filePath = path; + }, + /** * Returns the parsed object map. * @returns {Object} diff --git a/extensions/cocostudio/reader/timeline/ActionTimeline.js b/extensions/cocostudio/reader/timeline/ActionTimeline.js new file mode 100644 index 0000000000..e40241c8dc --- /dev/null +++ b/extensions/cocostudio/reader/timeline/ActionTimeline.js @@ -0,0 +1,455 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + + +(function(studio){ + /** + * ActionTimelineData + * @name ccs.ActionTimelineData + * @extend ccs.Class + * @class + * + */ + studio.ActionTimelineData = studio.Class.extend({ + + _actionTag: 0, + + ctor: function(actionTag){ + this._init(actionTag); + }, + + _init: function(actionTag){ + this._actionTag = actionTag; + return true; + }, + + /** + * Set the action tag. + * @param {number} actionTag + */ + setActionTag: function(actionTag){ + this._actionTag = actionTag; + }, + + /** + * Gets the action tag. + */ + getActionTag: function(){ + return this._actionTag; + } + + }); + + /** + * Create new ActionTimelineData. + * + * @deprecated v3.0, please use new ccs.ActionTimelineData() instead. + * + * @name ccs.ActionTimelineData.create + * @function + * @param actionTag + * @returns {ccs.ActionTimelineData} + */ + studio.ActionTimelineData.create = function(actionTag){ + var ret = new studio.ActionTimelineData(); + ret._init(actionTag); + return ret; + }; + + + /** + * ActionTimeline + * @class + * @extend cc.Action + * + * @property gotoFrameAndPlay + * @property gotoFrameAndPause + */ + studio.ActionTimeline = cc.Action.extend({ + + _timelineMap: null, + _timelineList: null, + _duration: 0, + _time: null, + _timeSpeed: 1, + _frameInternal: 1/60, + _playing: false, + _currentFrame: 0, + _startFrame: 0, + _endFrame: 0, + _loop: null, + _frameEventListener: null, + + ctor: function(){ + cc.Action.prototype.ctor.call(this); + this._timelineMap = {}; + this._timelineList = []; + this.init(); + }, + + _gotoFrame: function(frameIndex){ + var size = this._timelineList.length; + for(var i = 0; i < size; i++) + { + this._timelineList[i]._gotoFrame(frameIndex); + } + }, + + _stepToFrame: function(frameIndex){ + var size = this._timelineList.length; + for(var i = 0; i < size; i++) + { + this._timelineList[i]._stepToFrame(frameIndex); + } + }, + + //emit frame event, call it when enter a frame + _emitFrameEvent: function(frame){ + if(this._frameEventListener) + { + this._frameEventListener(frame); + } + }, + + init: function(){ + return true; + }, + + /** + * Goto the specified frame index, and start playing from this index. + * @param startIndex The animation will play from this index. + * @param [endIndex=] The animation will end at this index. + * @param [currentFrameIndex=] set current frame index. + * @param [loop=] Whether or not the animation need loop. + */ + gotoFrameAndPlay: function(startIndex, endIndex, currentFrameIndex, loop){ + //Consolidation parameters + var i = 0, + argLen = arguments.length; + var num = [], + bool; + for(i; i= this._startFrame && frameIndex >= this._endFrame){ + this._currentFrame = frameIndex; + this._time = this._currentFrame * this._frameInternal; + }else{ + cc.log("frame index is not between start frame and end frame"); + } + + }, + + /** + * Get current frame. + * @returns {number} + */ + getCurrentFrame: function(){ + return this._currentFrame; + }, + + /** + * add Timeline to ActionTimeline + * @param {ccs.Timeline} timeline + */ + addTimeline: function(timeline){ + var tag = timeline.getActionTag(); + if (!this._timelineMap[tag]) { + this._timelineMap[tag] = []; + } + + if (!this._timelineMap[tag].some(function(item){ + if(item === timeline) + return true; + })) { + this._timelineList.push(timeline); + this._timelineMap[tag].push(timeline); + timeline.setActionTimeline(this); + } + + }, + + /** + * remove Timeline to ActionTimeline + * @param {ccs.Timeline} timeline + */ + removeTimeline: function(timeline){ + var tag = timeline.getActionTag(); + if (this._timelineMap[tag]) { + if(this._timelineMap[tag].some(function(item){ + if(item === timeline) + return true; + })) { + cc.arrayRemoveObject(this._timelineMap[tag], timeline); + cc.arrayRemoveObject(this._timelineList, timeline); + timeline.setActionTimeline(null); + } + } + }, + + /** + * Gets the timeline list + * @returns {array | null} + */ + getTimelines: function(){ + return this._timelineList; + }, + + /** + * Set the Frame event + * @param {function} listener + */ + setFrameEventCallFunc: function(listener){ + this._frameEventListener = listener; + }, + + /** + * remove event + */ + clearFrameEventCallFunc: function(){ + this._frameEventListener = null; + }, + + /** + * Clone this timeline + * @returns {ccs.ActionTimeline} + */ + clone: function(){ + var newAction = new studio.ActionTimeline(); + newAction.setDuration(this._duration); + newAction.setTimeSpeed(this._timeSpeed); + + for (var a in this._timelineMap) + { + var timelines = this._timelineMap[a]; + for(var b in timelines) + { + var timeline = timelines[b]; + var newTimeline = timeline.clone(); + newAction.addTimeline(newTimeline); + } + } + + return newAction; + + }, + + /** + * Reverse is not defined; + * @returns {null} + */ + reverse: function(){ + return null; + }, + + /** + * Stepping of this time line. + * @param {number} delta + */ + step: function(delta){ + if (!this._playing || this._timelineMap.length == 0 || this._duration == 0) + { + return; + } + + this._time += delta * this._timeSpeed; + this._currentFrame = this._time / this._frameInternal; + + this._stepToFrame(this._currentFrame); + + if(this._time > this._endFrame * this._frameInternal) + { + this._playing = this._loop; + if(!this._playing) + this._time = this._endFrame * this._frameInternal; + else + this.gotoFrameAndPlay(this._startFrame, this._endFrame, this._loop); + } + + }, + + _foreachNodeDescendant: function(parent, callback){ + callback(parent); + + var children = parent.getChildren(); + for (var i=0; igetStringFromFile(fileName); + var json = cc.loader.getRes(fileName); + + var node = this.loadNodeWithContent(json); + + // Load animation data from file + studio.ActionTimelineCache.loadAnimationActionWithContent(fileName, json); + + return node; + + }, + + /** + * load node with data. + * @param {Object} json + * @returns {cc.Node} + */ + loadNodeWithContent: function(json){ + // decode plist + var length = json[timeline.TEXTURES].length; + + for(var i=0; i= this._frames[0].getFrameIndex()) + needEnterFrame = true; + + from = to = this._frames[0]; + this._currentKeyFrameIndex = 0; + this._betweenDuration = this._frames[0].getFrameIndex(); + break; + } + else if(frameIndex >= this._frames[length - 1].getFrameIndex()) + { + from = to = this._frames[length - 1]; + this._currentKeyFrameIndex = this._frames[length - 1].getFrameIndex(); + this._betweenDuration = 0; + break; + } + + var target = -1; + var low = 0, + high = length - 1, + mid = 0; + while(low <= high){ + mid = Math.ceil(( low + high )/2); + if(frameIndex >= this._frames[mid].getFrameIndex() && frameIndex < this._frames[mid + 1].getFrameIndex()) + { + target = mid; + break; + } + if(this._frames[mid].getFrameIndex()>frameIndex) + high = mid - 1; + else + low = mid + 1; + } + + from = this._frames[target]; + to = this._frames[target+1]; + + if(target == 0 && this._currentKeyFrameIndex < from.getFrameIndex()) + needEnterFrame = true; + + this._currentKeyFrameIndex = from.getFrameIndex(); + this._betweenDuration = to.getFrameIndex() - from.getFrameIndex(); + } while (0); + + if(needEnterFrame || this._currentKeyFrame != from) + { + this._currentKeyFrame = from; + this._currentKeyFrame.onEnter(to); + } + + }, + + _updateCurrentKeyFrame: function(frameIndex){ + //! If play to current frame's front or back, then find current frame again + if (frameIndex < this._currentKeyFrameIndex || frameIndex >= this._currentKeyFrameIndex + this._betweenDuration) + { + var from = null; + var to = null; + + do + { + var length = this._frames.length; + + if (frameIndex < this._frames[0].getFrameIndex()) + { + from = to = this._frames[0]; + this._currentKeyFrameIndex = 0; + this._betweenDuration = this._frames[0].getFrameIndex(); + break; + } + else if(frameIndex >= this._frames[length - 1].getFrameIndex()) + { + from = to = this._frames[length - 1]; + this._currentKeyFrameIndex = this._frames[length - 1].getFrameIndex(); + this._betweenDuration = 0; + break; + } + + do{ + this._fromIndex = this._toIndex; + from = this._frames[this._fromIndex]; + this._currentKeyFrameIndex = from.getFrameIndex(); + + this._toIndex = this._fromIndex + 1; + if (this._toIndex >= length) + { + this._toIndex = 0; + } + + to = this._frames[this._toIndex]; + + if (frameIndex == from.getFrameIndex()) + { + break; + } + }while (frameIndex < from.getFrameIndex() || frameIndex >= to.getFrameIndex()); + + this._betweenDuration = to.getFrameIndex() - from.getFrameIndex(); + + } while (0); + + this._currentKeyFrame = from; + this._currentKeyFrame.onEnter(to); + } + } + +}); + +ccs.Timeline.create = function(){ + return new ccs.Timeline(); +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 1f8693b00b..e534662429 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -344,7 +344,13 @@ "extensions/cocostudio/reader/widgetreader/WidgetReader.js", "extensions/cocostudio/reader/GUIReader.js", - "extensions/cocostudio/reader/SceneReader.js" + "extensions/cocostudio/reader/SceneReader.js", + + "extensions/cocostudio/reader/timeline/ActionTimeline.js", + "extensions/cocostudio/reader/timeline/ActionTimelineCache.js", + "extensions/cocostudio/reader/timeline/Frame.js", + "extensions/cocostudio/reader/timeline/NodeReader.js", + "extensions/cocostudio/reader/timeline/Timeline.js" ], "gui" : [ "core", "clipping-nodes", "render-texture", "actions", "progress-timer", From 383fb39d1908eac75cf3e20b82761f561d47d20e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 16 Sep 2014 16:38:30 +0800 Subject: [PATCH 0652/1564] Issue #5936: Scale9Sprite - Effect of canvas and webgl mode is not the same --- extensions/gui/control-extension/CCScale9Sprite.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 0d251496ef..561916ce33 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -961,8 +961,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } this.setContentSize(rect.width, rect.height); - if(cc._renderType === cc._RENDER_TYPE_WEBGL) + if(cc._renderType === cc._RENDER_TYPE_WEBGL){ this.addChild(locScale9Image); + }else{ + if(!this._cacheSprite.getParent()) + this.addChild(this._cacheSprite); + } if (this._spritesGenerated) { // Restore color and opacity From 4f5b647ff7f38b5a8fe7cb89e0d9d15ba87b6634 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 16 Sep 2014 17:42:00 +0800 Subject: [PATCH 0653/1564] Issue #5937: LabelTTF support shadow color --- cocos2d/core/labelttf/CCLabelTTF.js | 48 ++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 3beac954aa..4a71b8ffd6 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -80,6 +80,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _shadowOpacity: 0, _shadowBlur: 0, _shadowColorStr: null, + _shadowColor: null, // font stroke _strokeEnabled: false, @@ -285,12 +286,25 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ /** * Enable or disable shadow for the label - * @param {Number} shadowOffsetX The x axis offset of the shadow - * @param {Number} shadowOffsetY The y axis offset of the shadow - * @param {Number} shadowOpacity The opacity of the shadow (0 to 1) - * @param {Number} shadowBlur The blur size of the shadow + * @param {cc.Color | Number} a Color or The x axis offset of the shadow + * @param {cc.Size | Number} b Size or The y axis offset of the shadow + * @param {Number} c The blur size of the shadow or The opacity of the shadow (0 to 1) + * @param {null | Number} d Null or The blur size of the shadow + * @example + * old: + * labelttf.enableShadow(shadowOffsetX, shadowOffsetY, shadowOpacity, shadowBlur); + * new: + * labelttf.enableShadow(shadowColor, offset, blurRadius); */ - enableShadow: function (shadowOffsetX, shadowOffsetY, shadowOpacity, shadowBlur) { + enableShadow: function (a, b, c, d) { + if(a.r != null && a.g != null && a.b != null && a.a != null){ + this._enableShadow(a, b, c); + }else{ + this._enableShadowNoneColor(a, b, c, d) + } + }, + + _enableShadowNoneColor: function(shadowOffsetX, shadowOffsetY, shadowOpacity, shadowBlur){ shadowOpacity = shadowOpacity || 0.5; if (false === this._shadowEnabled) this._shadowEnabled = true; @@ -312,6 +326,24 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._needUpdateTexture = true; }, + _enableShadow: function(shadowColor, offset, blurRadius){ + + if(!this._shadowColor){ + this._shadowColor = cc.color(255, 255, 255, 128); + } + this._shadowColor.r = shadowColor.r; + this._shadowColor.g = shadowColor.g; + this._shadowColor.b = shadowColor.b; + + var x, y, a, b; + x = offset.width || offset.x || 0; + y = offset.height || offset.y || 0; + a = (shadowColor.a != null) ? (shadowColor.a / 255) : 0.5; + b = blurRadius; + + this._enableShadowNoneColor(x, y, a, b); + }, + _getShadowOffsetX: function () { return this._shadowOffset.x; }, @@ -1057,10 +1089,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p._setColorsString = function () { this._needUpdateTexture = true; - var locDisplayColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; + var locDisplayColor = this._displayedColor, + locDisplayedOpacity = this._displayedOpacity, + locShadowColor = this._shadowColor || this._displayedColor; var locStrokeColor = this._strokeColor, locFontFillColor = this._textFillColor; - this._shadowColorStr = "rgba(" + (0 | (locDisplayColor.r * 0.5)) + "," + (0 | (locDisplayColor.g * 0.5)) + "," + (0 | (locDisplayColor.b * 0.5)) + "," + this._shadowOpacity + ")"; + this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r * 0.5)) + "," + (0 | (locShadowColor.g * 0.5)) + "," + (0 | (locShadowColor.b * 0.5)) + "," + this._shadowOpacity + ")"; this._fillColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locFontFillColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locFontFillColor.g)) + "," + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," From f65e2ed7f1bb4b3d632f9d12791ea07d7562030e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 16 Sep 2014 18:15:24 +0800 Subject: [PATCH 0654/1564] Issue #5938: Add getTitleRenderer to UIButton --- extensions/ccui/uiwidgets/UIButton.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 68db8c3902..752b48cb26 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -735,6 +735,15 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.pressedActionEnabled = enabled; }, + /** + * Get the title renderer. + * title ttf object. + * @returns {cc.LabelTTF} + */ + getTitleRenderer: function(){ + return this._titleRenderer; + }, + /** * Sets title text to ccui.Button * @param {String} text From 20fc8986faf97d1d4e4ce6fe913b102f94f9f468 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 17 Sep 2014 09:52:15 +0800 Subject: [PATCH 0655/1564] Issue #5933: migrate new renderer to v3.1 --- cocos2d/clipping-nodes/CCClippingNode.js | 37 ++++++-- cocos2d/core/CCDirector.js | 19 +++- cocos2d/core/base-nodes/CCNode.js | 2 + cocos2d/core/layers/CCLayer.js | 101 +++++++++++++------- cocos2d/core/sprites/CCSprite.js | 110 ++++++++-------------- cocos2d/core/sprites/SpritesWebGL.js | 4 +- cocos2d/particle/CCParticleSystem.js | 25 +++++ cocos2d/render-texture/CCRenderTexture.js | 40 ++++++-- cocos2d/shape-nodes/CCDrawNode.js | 11 ++- cocos2d/tilemap/CCTMXLayer.js | 80 ++++++++-------- template/project.json | 2 +- 11 files changed, 257 insertions(+), 174 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index b5eeb4cf4a..e5168d5601 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -74,6 +74,10 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ alphaThreshold: 0, inverted: false, + _rendererSaveCmd: null, + _rendererClipCmd: null, + _rendererRestoreCmd: null, + _stencil: null, _godhelpme: false, @@ -87,6 +91,10 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ this.alphaThreshold = 0; this.inverted = false; + this._rendererSaveCmd = new cc.ClippingNodeSaveRenderCmdCanvas(this); + this._rendererClipCmd = new cc.ClippingNodeClipRenderCmdCanvas(this); + this._rendererRestoreCmd = new cc.ClippingNodeRestoreRenderCmdCanvas(this); + stencil = stencil || null; cc.ClippingNode.prototype.init.call(this, stencil); }, @@ -466,16 +474,25 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ _setStencilForCanvas: function (stencil) { this._stencil = stencil; + if(stencil._buffer){ + for(var i=0; i 0) { - var subCacheW = this._subCacheWidth, subCacheH = locCacheCanvas.height; - for(i = 0; i < this._subCacheCount; i++) { - this._subCacheContext[i].drawImage(locCacheCanvas, i * subCacheW, 0, subCacheW, subCacheH, 0, 0, subCacheW, subCacheH); + var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view; + //begin cache + cc.renderer._isCacheToCanvasOn = true; + + this.sortAllChildren(); + for (i = 0, len = locChildren.length; i < len; i++) { + if (locChildren[i]){ + locChildren[i].visit(); + locChildren[i]._cacheDirty = false; } } - //reset Scale - eglViewer._resetScale(); + //copy cached render cmd array to TMXLayer renderer + this._rendererCmd._copyRendererCmds(cc.renderer._cacheToCanvasCmds); + + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + var t = cc.affineTransformInvert(this._transformWorld); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); + + //draw to cache canvas + cc.renderer._renderingToCacheCanvas(locCacheContext); + locCacheContext.restore(); this._cacheDirty = false; } - // draw RenderTexture - this.draw(ctx); - context.restore(); + cc.renderer.pushRenderCommand(this._rendererCmd); + }, + + //set the cache dirty flag for canvas + _setNodeDirtyForCache: function () { + this._cacheDirty = true; + if(cc.renderer._transformNodePool.indexOf(this) === -1) + cc.renderer.pushDirtyNode(this); + this._renderCmdDiry = true; }, /** diff --git a/template/project.json b/template/project.json index 0c277b291a..cd45a5926f 100644 --- a/template/project.json +++ b/template/project.json @@ -3,7 +3,7 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 0, + "renderMode" : 1, "engineDir":"../", "modules" : ["cocos2d"], From 2f8ee200b29404b8fc4d059b68ec878fbd4d2b8e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 17 Sep 2014 10:55:10 +0800 Subject: [PATCH 0656/1564] Issue #5935: Support timeline --- .../reader/timeline/ActionTimeline.js | 19 +- .../cocostudio/reader/timeline/Frame.js | 444 +++++++++++++++++- .../cocostudio/reader/timeline/TimeLine.js | 33 +- 3 files changed, 471 insertions(+), 25 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/ActionTimeline.js b/extensions/cocostudio/reader/timeline/ActionTimeline.js index e40241c8dc..4c692c7a80 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimeline.js +++ b/extensions/cocostudio/reader/timeline/ActionTimeline.js @@ -118,16 +118,14 @@ _stepToFrame: function(frameIndex){ var size = this._timelineList.length; - for(var i = 0; i < size; i++) - { + for(var i = 0; i < size; i++){ this._timelineList[i]._stepToFrame(frameIndex); } }, //emit frame event, call it when enter a frame _emitFrameEvent: function(frame){ - if(this._frameEventListener) - { + if(this._frameEventListener){ this._frameEventListener(frame); } }, @@ -346,8 +344,7 @@ newAction.setDuration(this._duration); newAction.setTimeSpeed(this._timeSpeed); - for (var a in this._timelineMap) - { + for (var a in this._timelineMap){ var timelines = this._timelineMap[a]; for(var b in timelines) { @@ -384,8 +381,7 @@ this._stepToFrame(this._currentFrame); - if(this._time > this._endFrame * this._frameInternal) - { + if(this._time > this._endFrame * this._frameInternal){ this._playing = this._loop; if(!this._playing) this._time = this._endFrame * this._frameInternal; @@ -413,13 +409,14 @@ startWithTarget: function(target){ cc.Action.prototype.startWithTarget.call(this, target); + var self = this; var callback = function(child){ var data = child.getUserObject(); if(data) { var actionTag = data.getActionTag(); - if(this._timelineMap[actionTag]) { - var timelines = this._timelineMap[actionTag]; + if(self._timelineMap[actionTag]) { + var timelines = self._timelineMap[actionTag]; for (var i=0; i Date: Wed, 17 Sep 2014 11:43:16 +0800 Subject: [PATCH 0657/1564] Issue #5933: migrate cc.ProgressTimer's renderer to v3.1 --- cocos2d/core/layers/CCLayer.js | 1 - cocos2d/core/renderer/RendererCanvas.js | 5 +- cocos2d/progress-timer/CCProgressTimer.js | 113 +++------------------- cocos2d/tilemap/CCTMXLayer.js | 2 + cocos2d/transitions/CCTransition.js | 3 +- 5 files changed, 23 insertions(+), 101 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 9feca77ce4..ddb26902df 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -792,7 +792,6 @@ cc.LayerGradient.create = function (start, end, v) { return new cc.LayerGradient(start, end, v); }; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerGradient define start var _p = cc.LayerGradient.prototype; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 3d3ecb18eb..728a917936 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -255,6 +255,7 @@ cc.GradientRectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scal context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); var opacity = _t._opacity, locRect = this._drawingRect; + //TODO need cache gradient object var gradient = context.createLinearGradient(_t._startPoint.x, _t._startPoint.y, _t._endPoint.x, _t._endPoint.y); var locStartColor = _t._startColor, locEndColor = _t._endColor; gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," @@ -625,7 +626,7 @@ cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, s context.restore(); } - var t = cc.AffineTransformInvert(this._node._transformWorld); + var t = cc.affineTransformInvert(this._node._transformWorld); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.clip(); }; @@ -703,7 +704,7 @@ cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function(scaleX, s locCacheContext.save(); locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); //reset the cache context - var t = cc.AffineTransformInvert(this._transform); + var t = cc.affineTransformInvert(this._transform); locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); for(var i = 0, len = locCacheCmds.length; i < len; i++){ diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index dcf6fdfba6..9cd255fcd9 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -164,13 +164,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ return cc.p(0,0); }, - _origin:null, - _startAngle:270, - _endAngle:270, - _radius:0, - _counterClockWise:false, - _barRect:null, - _vertexDataCount:0, _vertexData:null, _vertexArrayBuffer:null, @@ -194,14 +187,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._reverseDirection = false; this._sprite = null; - - this._origin = cc.p(0,0); - this._startAngle = 270; - this._endAngle = 270; - this._radius = 0; - this._counterClockWise = false; - this._barRect = cc.rect(0, 0, 0, 0); - + this._rendererCmd = new cc.ProgressRenderCmdCanvas(this); sprite && this._initWithSpriteForCanvas(sprite); }, @@ -291,6 +277,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ _setSpriteForCanvas:function (sprite) { if (this._sprite != sprite) { this._sprite = sprite; + this._rendererCmd._sprite = sprite; this.width = this._sprite.width; this.height = this._sprite.height; } @@ -319,8 +306,10 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ setType:null, _setTypeForCanvas:function (type) { - if (type !== this._type) + if (type !== this._type){ this._type = type; + this._rendererCmd._type = type; + } }, _setTypeForWebGL:function (type) { @@ -438,73 +427,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ */ draw:null, - _drawForCanvas:function (ctx) { - var context = ctx || cc._renderContext; - - var locSprite = this._sprite; - if (locSprite._blendFuncStr != "source") - context.globalCompositeOperation = locSprite._blendFuncStr; - - var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); - - context.globalAlpha = locSprite._displayedOpacity / 255; - var locRect = locSprite._rect, locContentSize = locSprite._contentSize, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; - var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height, locTextureCoord = locSprite._textureRect_Canvas; - locDrawSizeCanvas.width = locRect.width * locEGL_ScaleX; - locDrawSizeCanvas.height = locRect.height * locEGL_ScaleY; - - context.save(); - if (locSprite._flippedX) { - flipXOffset = -locOffsetPosition.x - locRect.width; - context.scale(-1, 1); - } - if (locSprite._flippedY) { - flipYOffset = locOffsetPosition.y; - context.scale(1, -1); - } - - flipXOffset *= locEGL_ScaleX; - flipYOffset *= locEGL_ScaleY; - - //clip - 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.ProgressTimer.TYPE_RADIAL) { - var locOriginX = this._origin.x * locEGL_ScaleX; - var locOriginY = this._origin.y * locEGL_ScaleY; - context.beginPath(); - context.arc(locOriginX, locOriginY, this._radius * locEGL_ScaleY, (Math.PI / 180) * this._startAngle, (Math.PI / 180) * this._endAngle, this._counterClockWise); - context.lineTo(locOriginX, locOriginY); - context.clip(); - context.closePath(); - } - - //draw sprite - if (locSprite._texture && locTextureCoord.validRect) { - var image = locSprite._texture.getHtmlElementObj(); - if (locSprite._colorized) { - context.drawImage(image, - 0, 0, locTextureCoord.width, locTextureCoord.height, - flipXOffset, flipYOffset, locDrawSizeCanvas.width, locDrawSizeCanvas.height); - } else { - context.drawImage(image, - locTextureCoord.x, locTextureCoord.y, locTextureCoord.width, locTextureCoord.height, - flipXOffset, flipYOffset, locDrawSizeCanvas.width , locDrawSizeCanvas.height); - } - } else if (locContentSize.width !== 0) { - var curColor = this.color; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; - context.fillRect(flipXOffset, flipYOffset, locContentSize.width * locEGL_ScaleX, locContentSize.height * locEGL_ScaleY); - } - - context.restore(); - cc.incrementGLDraws(1); - }, - _drawForWebGL:function (ctx) { var context = ctx || cc._renderContext; if (!this._vertexData || !this._sprite) @@ -810,10 +732,11 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ var locSprite = this._sprite; var sw = locSprite.width, sh = locSprite.height; var locMidPoint = this._midPoint; + var locCmd = this._rendererCmd; 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; + locCmd._radius = Math.round(Math.sqrt(sw * sw + sh * sh)); + var locStartAngle, locEndAngle, locCounterClockWise = false, locOrigin = locCmd._origin; locOrigin.x = sw * locMidPoint.x; locOrigin.y = -sh * locMidPoint.y; @@ -840,13 +763,13 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ locEndAngle= -locEndAngle; } - this._startAngle = locStartAngle; - this._endAngle = locEndAngle; - this._counterClockWise = locCounterClockWise; + locCmd._startAngle = locStartAngle; + locCmd._endAngle = locEndAngle; + locCmd._counterClockWise = locCounterClockWise; } else { var locBarChangeRate = this._barChangeRate; var percentageF = this._percentage / 100; - var locBarRect = this._barRect; + var locBarRect = locCmd._barRect; var drawedSize = cc.size((sw * (1 - locBarChangeRate.x)), (sh * (1 - locBarChangeRate.y))); var drawingSize = cc.size((sw - drawedSize.width) * percentageF, (sh - drawedSize.height) * percentageF); @@ -855,17 +778,13 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ var startPoint = cc.p(sw * locMidPoint.x, sh * locMidPoint.y); var needToLeft = startPoint.x - currentDrawSize.width / 2; - if (locMidPoint.x > 0.5) { - if (currentDrawSize.width / 2 >= sw - startPoint.x) { - needToLeft = sw - currentDrawSize.width; - } + if ((locMidPoint.x > 0.5) && (currentDrawSize.width / 2 >= sw - startPoint.x)) { + needToLeft = sw - currentDrawSize.width; } var needToTop = startPoint.y - currentDrawSize.height / 2; - if (locMidPoint.y > 0.5) { - if (currentDrawSize.height / 2 >= sh - startPoint.y) { - needToTop = sh - currentDrawSize.height; - } + if ((locMidPoint.y > 0.5) && (currentDrawSize.height / 2 >= sh - startPoint.y)) { + needToTop = sh - currentDrawSize.height; } //left pos diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index ce51ca2ad8..49366d56a8 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -799,6 +799,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this.tiles[zz] = 0; this._atlasIndexArray.splice(atlasIndex, 1); cc.SpriteBatchNode.prototype.removeChild.call(this, sprite, cleanup); + cc.renderer.childrenOrderDirty = true; }, /** @@ -1019,6 +1020,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this._reusedTile.initWithTexture(this._textureForCanvas, rect, false); this._reusedTile.batchNode = this; this._reusedTile.parent = this; + this._reusedTile._cachedParent = this; } return this._reusedTile; }, diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 2c60f5fc45..0524379ab8 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -106,7 +106,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ /** * stuff gets drawn here */ - draw:function () { + visit:function () { if (this._isInSceneOnTop) { this._outScene.visit(); this._inScene.visit(); @@ -114,6 +114,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ this._inScene.visit(); this._outScene.visit(); } + cc.Node.prototype.visit.call(this); }, /** From b5d711847ef51700c52059b61dc2aeaeb1412513 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 17 Sep 2014 14:43:45 +0800 Subject: [PATCH 0658/1564] Issue #5933: migrate new renderer of cc.ParallaxNode to v3.1 --- cocos2d/core/renderer/RendererCanvas.js | 1 - cocos2d/parallax/CCParallaxNode.js | 17 +++++++++++++++++ cocos2d/physics/CCPhysicsDebugNode.js | 3 +++ cocos2d/physics/CCPhysicsSprite.js | 19 +++++++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 728a917936..55db364435 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -648,7 +648,6 @@ cc.PhysicsDebugNodeRenderCmdCanvas = function(node){ }; cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var _node = this._node; if (!_node.space) diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index 24337ee2b8..6608be0dec 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -236,6 +236,23 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ } }); +if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + cc.ParallaxNode.prototype._transformForRenderer = function(){ + var pos = this._absolutePosition(); + if (!cc.pointEqualToPoint(pos, this._lastPosition)) { + var locParallaxArray = this.parallaxArray; + for (var i = 0, len = locParallaxArray.length; i < len; i++) { + var point = locParallaxArray[i]; + var child = point.getChild(); + child.setPosition(-pos.x + pos.x * point.getRatio().x + point.getOffset().x, + -pos.y + pos.y * point.getRatio().y + point.getOffset().y); + } + this._lastPosition = pos; + } + cc.Node.prototype._transformForRenderer.call(this); + }; +} + /** * Create new parallax node. * @deprecated since v3.0 please use new cc.ParallaxNode() instead. diff --git a/cocos2d/physics/CCPhysicsDebugNode.js b/cocos2d/physics/CCPhysicsDebugNode.js index ecdbac0e58..b56b60d28f 100644 --- a/cocos2d/physics/CCPhysicsDebugNode.js +++ b/cocos2d/physics/CCPhysicsDebugNode.js @@ -161,6 +161,9 @@ cc.PhysicsDebugNode = cc.DrawNode.extend({ ctor: function (space) { cc.DrawNode.prototype.ctor.call(this); this._space = space; + this._rendererCmd = new cc.PhysicsDebugNodeRenderCmdCanvas(this); + + cc.rendererCanvas.pushRenderCommand(this._rendererCmd); }, /** diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 2c295b9762..deb44d36a3 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -90,8 +90,15 @@ this.initWithSpriteFrame(fileName); } } + //this._transformCmd = new cc.PhysicsSpriteTransformCmdCanvas(this); + //cc.rendererCanvas.pushRenderCommand(this._transformCmd); }, + //visit: function(){ + // cc.Sprite.prototype.visit.call(this); + // cc.rendererCanvas.pushRenderCommand(this._transformCmd); + //}, + /** * set body * @param {Box2D.Dynamics.b2Body} body @@ -199,6 +206,7 @@ this._ignoreBodyRotation = b; } }; + var chipmunkAPI = { _ignoreBodyRotation:false, _body:null, //physics body @@ -253,6 +261,13 @@ this.initWithSpriteFrame(fileName); } } + this._transformCmd = new cc.PhysicsSpriteTransformCmdCanvas(this); + cc.rendererCanvas.pushRenderCommand(this._transformCmd); + }, + + visit: function(){ + cc.Sprite.prototype.visit.call(this); + cc.rendererCanvas.pushRenderCommand(this._transformCmd); }, /** @@ -371,7 +386,7 @@ /** * get the affine transform matrix of node to parent coordinate frame - * @retur {cc.AffineTransform} + * @return {cc.AffineTransform} */ getNodeToParentTransform:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS) @@ -460,7 +475,7 @@ setDirty: function(){ }, /** - * set whether to ignore ratation of body + * set whether to ignore rotation of body * @param {Boolean} b */ setIgnoreBodyRotation: function(b) { From 6af984ea5a3213cc8ab61833d7214e4a469c1d50 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 17 Sep 2014 16:23:57 +0800 Subject: [PATCH 0659/1564] Issue #5939: LabelAtlas._cascadeOpacityEnabled is false --- cocos2d/labels/CCLabelAtlas.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 83d20f1d51..9ec20983b7 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -73,6 +73,9 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ ctor: function (strText, charMapFile, itemWidth, itemHeight, startCharMap) { cc.AtlasNode.prototype.ctor.call(this); + this._cascadeOpacityEnabled = true; + this._cascadeColorEnabled = true; + charMapFile && cc.LabelAtlas.prototype.initWithString.call(this, strText, charMapFile, itemWidth, itemHeight, startCharMap); }, From 4928b47daaf8e8a08777109933d9cee61a2cc75f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 17 Sep 2014 16:49:42 +0800 Subject: [PATCH 0660/1564] Chipmunk new renderer --- cocos2d/core/renderer/RendererCanvas.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 55db364435..a874d4bd7d 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -650,11 +650,11 @@ cc.PhysicsDebugNodeRenderCmdCanvas = function(node){ cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ var _node = this._node; - if (!_node.space) + if (!_node._space) return; - _node.space.eachShape(cc.DrawShape.bind(_node)); - _node.space.eachConstraint(cc.DrawConstraint.bind(_node)); + _node._space.eachShape(cc.DrawShape.bind(_node)); + _node._space.eachConstraint(cc.DrawConstraint.bind(_node)); cc.DrawNodeRenderCmdCanvas.prototype.rendering.call(this, ctx, scaleX, scaleY); _node.clear(); }; From 10430ba952714710fb1a69fe32c44176f2f7ec1c Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 18 Sep 2014 16:58:27 +0800 Subject: [PATCH 0661/1564] Fixed #5942: Default event listener's paused value should be true --- cocos2d/core/event-manager/CCEventListener.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 2a3f03ba2a..8bf14c0b2c 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -41,7 +41,7 @@ cc.EventListener = cc.Class.extend(/** @lends cc.EventListener# */{ _fixedPriority: 0, // The higher the number, the higher the priority, 0 is for scene graph base priority. _node: null, // scene graph based priority - _paused: false, // Whether the listener is paused + _paused: true, // Whether the listener is paused _isEnabled: true, // Whether the listener is enabled /** From c9aa8a16dda21f633d8555717cad5fbb8b0ad6b9 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 18 Sep 2014 20:29:36 +0800 Subject: [PATCH 0662/1564] upgrade chipmunk.js to newest version --- external/chipmunk/chipmunk.js | 11095 ++++++++++++++++---------------- 1 file changed, 5662 insertions(+), 5433 deletions(-) diff --git a/external/chipmunk/chipmunk.js b/external/chipmunk/chipmunk.js index 92299ff62b..6f2fc2b459 100644 --- a/external/chipmunk/chipmunk.js +++ b/external/chipmunk/chipmunk.js @@ -1,1318 +1,1502 @@ (function(){ - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - Object.create = Object.create || function(o) { - function F() {} - F.prototype = o; - return new F(); - }; - +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +Object.create = Object.create || function(o) { + function F() {} + F.prototype = o; + return new F(); +}; + //var VERSION = CP_VERSION_MAJOR + "." + CP_VERSION_MINOR + "." + CP_VERSION_RELEASE; - var cp; - if(typeof exports === 'undefined'){ - cp = {}; - if(typeof window === 'object'){ - window["cp"] = cp; - } - } else { - cp = exports; - } - - var assert = function(value, message) - { - if (!value) { - throw new Error('Assertion failed: ' + message); - } - }; - - var assertSoft = function(value, message) - { - if(!value && console && console.warn) { - console.warn("ASSERTION FAILED: " + message); - if(console.trace) { - console.trace(); - } - } - }; - - var mymin = function(a, b) - { - return a < b ? a : b; - }; - var mymax = function(a, b) - { - return a > b ? a : b; - }; - - var min, max; - if (typeof window === 'object' && window.navigator.userAgent.indexOf('Firefox') > -1){ - // On firefox, Math.min and Math.max are really fast: - // http://jsperf.com/math-vs-greater-than/8 - min = Math.min; - max = Math.max; - } else { - // On chrome and safari, Math.min / max are slooow. The ternery operator above is faster - // than the builtins because we only have to deal with 2 arguments that are always numbers. - min = mymin; - max = mymax; - } - - /* The hashpair function takes two numbers and returns a hash code for them. - * Required that hashPair(a, b) === hashPair(b, a). - * Chipmunk's hashPair function is defined as: - * #define CP_HASH_COEF (3344921057ul) - * #define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF) - * But thats not suitable in javascript because multiplying by a large number will make the number - * a large float. - * - * The result of hashPair is used as the key in objects, so it returns a string. - */ - var hashPair = function(a, b) - { - //assert(typeof(a) === 'number', "HashPair used on something not a number"); - return a < b ? a + ' ' + b : b + ' ' + a; - }; - - var deleteObjFromList = function(arr, obj) - { - for(var i=0; i b ? a : b; +}; + +var min, max; +if (typeof window === 'object' && window.navigator.userAgent.indexOf('Firefox') > -1){ + // On firefox, Math.min and Math.max are really fast: + // http://jsperf.com/math-vs-greater-than/8 + min = Math.min; + max = Math.max; +} else { + // On chrome and safari, Math.min / max are slooow. The ternery operator above is faster + // than the builtins because we only have to deal with 2 arguments that are always numbers. + min = mymin; + max = mymax; +} + +/* The hashpair function takes two numbers and returns a hash code for them. + * Required that hashPair(a, b) === hashPair(b, a). + * Chipmunk's hashPair function is defined as: + * #define CP_HASH_COEF (3344921057ul) + * #define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF) + * But thats not suitable in javascript because multiplying by a large number will make the number + * a large float. + * + * The result of hashPair is used as the key in objects, so it returns a string. + */ +var hashPair = function(a, b) +{ + //assert(typeof(a) === 'number', "HashPair used on something not a number"); + return a < b ? a + ' ' + b : b + ' ' + a; +}; + +var deleteObjFromList = function(arr, obj) +{ + for(var i=0; i> 1; + for(var i=1; i maxx || (x == maxx && y > maxy)){ + maxx = x; + maxy = y; + end = i; + } + } + return [start, end]; +}; + +var SWAP = function(arr, idx1, idx2) +{ + var tmp = arr[idx1*2]; + arr[idx1*2] = arr[idx2*2]; + arr[idx2*2] = tmp; + + tmp = arr[idx1*2+1]; + arr[idx1*2+1] = arr[idx2*2+1]; + arr[idx2*2+1] = tmp; +}; + +var QHullPartition = function(verts, offs, count, a, b, tol) +{ + if(count === 0) return 0; + + var max = 0; + var pivot = offs; + + var delta = vsub(b, a); + var valueTol = tol * vlength(delta); + + var head = offs; + for(var tail = offs+count-1; head <= tail;){ + var v = new Vect(verts[head * 2], verts[head * 2 + 1]); + var value = vcross(delta, vsub(v, a)); + if(value > valueTol){ + if(value > max){ + max = value; + pivot = head; + } + + head++; + } else { + SWAP(verts, head, tail); + tail--; + } + } + + // move the new pivot to the front if it's not already there. + if(pivot != offs) SWAP(verts, offs, pivot); + return head - offs; +}; + +var QHullReduce = function(tol, verts, offs, count, a, pivot, b, resultPos) +{ + if(count < 0){ + return 0; + } else if(count == 0) { + verts[resultPos*2] = pivot.x; + verts[resultPos*2+1] = pivot.y; + return 1; + } else { + var left_count = QHullPartition(verts, offs, count, a, pivot, tol); + var left = new Vect(verts[offs*2], verts[offs*2+1]); + var index = QHullReduce(tol, verts, offs + 1, left_count - 1, a, left, pivot, resultPos); + + var pivotPos = resultPos + index++; + verts[pivotPos*2] = pivot.x; + verts[pivotPos*2+1] = pivot.y; + + var right_count = QHullPartition(verts, offs + left_count, count - left_count, pivot, b, tol); + var right = new Vect(verts[(offs+left_count)*2], verts[(offs+left_count)*2+1]); + return index + QHullReduce(tol, verts, offs + left_count + 1, right_count - 1, pivot, right, b, resultPos + index); + } +}; + +// QuickHull seemed like a neat algorithm, and efficient-ish for large input sets. +// My implementation performs an in place reduction using the result array as scratch space. +// +// Pass an Array into result to put the result of the calculation there. Otherwise, pass null +// and the verts list will be edited in-place. +// +// Expects the verts to be described in the same way as cpPolyShape - which is to say, it should +// be a list of [x1,y1,x2,y2,x3,y3,...]. +// +// tolerance is in world coordinates. Eg, 2. +cp.convexHull = function(verts, result, tolerance) +{ + if(result){ + // Copy the line vertexes into the empty part of the result polyline to use as a scratch buffer. + for (var i = 0; i < verts.length; i++){ + result[i] = verts[i]; + } + } else { + // If a result array was not specified, reduce the input instead. + result = verts; + } + + // Degenerate case, all points are the same. + var indexes = loopIndexes(verts); + var start = indexes[0], end = indexes[1]; + if(start == end){ + //if(first) (*first) = 0; + result.length = 2; + return result; + } + + SWAP(result, 0, start); + SWAP(result, 1, end == 0 ? start : end); + + var a = new Vect(result[0], result[1]); + var b = new Vect(result[2], result[3]); + + var count = verts.length >> 1; + //if(first) (*first) = start; + var resultCount = QHullReduce(tolerance, result, 2, count - 2, a, b, a, 1) + 1; + result.length = resultCount*2; + + assertSoft(polyValidate(result), + "Internal error: cpConvexHull() and cpPolyValidate() did not agree." + + "Please report this error with as much info as you can."); + return result; +}; /// Clamp @c f to be between @c min and @c max. - var clamp = function(f, minv, maxv) - { - return min(max(f, minv), maxv); - }; +var clamp = function(f, minv, maxv) +{ + return min(max(f, minv), maxv); +}; /// Clamp @c f to be between 0 and 1. - var clamp01 = cp.clamp01 = function(f) - { - return max(0, min(f, 1)); - }; +var clamp01 = function(f) +{ + return max(0, min(f, 1)); +}; /// Linearly interpolate (or extrapolate) between @c f1 and @c f2 by @c t percent. - var lerp = function(f1, f2, t) - { - return f1*(1 - t) + f2*t; - }; +var lerp = function(f1, f2, t) +{ + return f1*(1 - t) + f2*t; +}; /// Linearly interpolate from @c f1 to @c f2 by no more than @c d. - var lerpconst = function(f1, f2, d) - { - return f1 + clamp(f2 - f1, -d, d); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +var lerpconst = function(f1, f2, d) +{ + return f1 + clamp(f2 - f1, -d, d); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // I'm using an array tuple here because (at time of writing) its about 3x faster // than an object on firefox, and the same speed on chrome. - var numVects = 0; - - var traces = {}; +//var numVects = 0; - var Vect = cp.Vect = function(x, y) - { - this.x = x; - this.y = y; - numVects++; +var Vect = cp.Vect = function(x, y) +{ + this.x = x; + this.y = y; + //numVects++; // var s = new Error().stack; // traces[s] = traces[s] ? traces[s]+1 : 1; - }; +}; - cp.v = function (x,y) { return new Vect(x, y) }; +cp.v = function (x,y) { return new Vect(x, y) }; - var vzero = cp.vzero = new Vect(0,0); +var vzero = cp.vzero = new Vect(0,0); // The functions below *could* be rewritten to be instance methods on Vect. I don't // know how that would effect performance. For now, I'm keeping the JS similar to // the original C code. /// Vector dot product. - var vdot = cp.v.dot = function(v1, v2) - { - return v1.x*v2.x + v1.y*v2.y; - }; +var vdot = cp.v.dot = function(v1, v2) +{ + return v1.x*v2.x + v1.y*v2.y; +}; - var vdot2 = function(x1, y1, x2, y2) - { - return x1*x2 + y1*y2; - }; +var vdot2 = function(x1, y1, x2, y2) +{ + return x1*x2 + y1*y2; +}; /// Returns the length of v. - var vlength = cp.v.len = function(v) - { - return Math.sqrt(vdot(v, v)); - }; +var vlength = cp.v.len = function(v) +{ + return Math.sqrt(vdot(v, v)); +}; + +var vlength2 = cp.v.len2 = function(x, y) +{ + return Math.sqrt(x*x + y*y); +}; /// Check if two vectors are equal. (Be careful when comparing floating point numbers!) - var veql = cp.v.eql = function(v1, v2) - { - return (v1.x === v2.x && v1.y === v2.y); - }; +var veql = cp.v.eql = function(v1, v2) +{ + return (v1.x === v2.x && v1.y === v2.y); +}; /// Add two vectors - var vadd = cp.v.add = function(v1, v2) - { - return new Vect(v1.x + v2.x, v1.y + v2.y); - }; - - Vect.prototype.add = function(v2) - { - this.x += v2.x; - this.y += v2.y; - return this; - }; +var vadd = cp.v.add = function(v1, v2) +{ + return new Vect(v1.x + v2.x, v1.y + v2.y); +}; + +Vect.prototype.add = function(v2) +{ + this.x += v2.x; + this.y += v2.y; + return this; +}; /// Subtract two vectors. - var vsub = cp.v.sub = function(v1, v2) - { - return new Vect(v1.x - v2.x, v1.y - v2.y); - }; - - Vect.prototype.sub = function(v2) - { - this.x -= v2.x; - this.y -= v2.y; - return this; - }; +var vsub = cp.v.sub = function(v1, v2) +{ + return new Vect(v1.x - v2.x, v1.y - v2.y); +}; + +Vect.prototype.sub = function(v2) +{ + this.x -= v2.x; + this.y -= v2.y; + return this; +}; /// Negate a vector. - var vneg = cp.v.neg = function(v) - { - return new Vect(-v.x, -v.y); - }; - - Vect.prototype.neg = function() - { - this.x = -this.x; - this.y = -this.y; - return this; - }; +var vneg = cp.v.neg = function(v) +{ + return new Vect(-v.x, -v.y); +}; + +Vect.prototype.neg = function() +{ + this.x = -this.x; + this.y = -this.y; + return this; +}; /// Scalar multiplication. - var vmult = cp.v.mult = function(v, s) - { - return new Vect(v.x*s, v.y*s); - }; - - Vect.prototype.mult = function(s) - { - this.x *= s; - this.y *= s; - return this; - }; +var vmult = cp.v.mult = function(v, s) +{ + return new Vect(v.x*s, v.y*s); +}; + +Vect.prototype.mult = function(s) +{ + this.x *= s; + this.y *= s; + return this; +}; /// 2D vector cross product analog. /// The cross product of 2D vectors results in a 3D vector with only a z component. /// This function returns the magnitude of the z value. - var vcross = cp.v.cross = function(v1, v2) - { - return v1.x*v2.y - v1.y*v2.x; - }; +var vcross = cp.v.cross = function(v1, v2) +{ + return v1.x*v2.y - v1.y*v2.x; +}; - var vcross2 = function(x1, y1, x2, y2) - { - return x1*y2 - y1*x2; - }; +var vcross2 = function(x1, y1, x2, y2) +{ + return x1*y2 - y1*x2; +}; /// Returns a perpendicular vector. (90 degree rotation) - var vperp = cp.v.perp = function(v) - { - return new Vect(-v.y, v.x); - }; +var vperp = cp.v.perp = function(v) +{ + return new Vect(-v.y, v.x); +}; /// Returns a perpendicular vector. (-90 degree rotation) - var vpvrperp = cp.v.pvrperp = function(v) - { - return new Vect(v.y, -v.x); - }; +var vpvrperp = cp.v.pvrperp = function(v) +{ + return new Vect(v.y, -v.x); +}; /// Returns the vector projection of v1 onto v2. - var vproject = cp.v.project = function(v1, v2) - { - return vmult(v2, vdot(v1, v2)/vlengthsq(v2)); - }; +var vproject = cp.v.project = function(v1, v2) +{ + return vmult(v2, vdot(v1, v2)/vlengthsq(v2)); +}; - Vect.prototype.project = function(v2) - { - this.mult(vdot(this, v2) / vlengthsq(v2)); - return this; - }; +Vect.prototype.project = function(v2) +{ + this.mult(vdot(this, v2) / vlengthsq(v2)); + return this; +}; /// Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector. - var vrotate = cp.v.rotate = function(v1, v2) - { - return new Vect(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x); - }; - - Vect.prototype.rotate = function(v2) - { - this.x = this.x * v2.x - this.y * v2.y; - this.y = this.x * v2.y + this.y * v2.x; - return this; - }; +var vrotate = cp.v.rotate = function(v1, v2) +{ + return new Vect(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x); +}; + +Vect.prototype.rotate = function(v2) +{ + this.x = this.x * v2.x - this.y * v2.y; + this.y = this.x * v2.y + this.y * v2.x; + return this; +}; /// Inverse of vrotate(). - var vunrotate = cp.v.unrotate = function(v1, v2) - { - return new Vect(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y); - }; +var vunrotate = cp.v.unrotate = function(v1, v2) +{ + return new Vect(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y); +}; /// Returns the squared length of v. Faster than vlength() when you only need to compare lengths. - var vlengthsq = cp.v.lengthsq = function(v) - { - return vdot(v, v); - }; +var vlengthsq = cp.v.lengthsq = function(v) +{ + return vdot(v, v); +}; + +var vlengthsq2 = cp.v.lengthsq2 = function(x, y) +{ + return x*x + y*y; +}; /// Linearly interpolate between v1 and v2. - var vlerp = cp.v.lerp = function(v1, v2, t) - { - return vadd(vmult(v1, 1 - t), vmult(v2, t)); - }; +var vlerp = cp.v.lerp = function(v1, v2, t) +{ + return vadd(vmult(v1, 1 - t), vmult(v2, t)); +}; /// Returns a normalized copy of v. - var vnormalize = cp.v.normalize = function(v) - { - return vmult(v, 1/vlength(v)); - }; +var vnormalize = cp.v.normalize = function(v) +{ + return vmult(v, 1/vlength(v)); +}; /// Returns a normalized copy of v or vzero if v was already vzero. Protects against divide by zero errors. - var vnormalize_safe = cp.v.normalize_safe = function(v) - { - return (v.x === 0 && v.y === 0 ? vzero : vnormalize(v)); - }; +var vnormalize_safe = cp.v.normalize_safe = function(v) +{ + return (v.x === 0 && v.y === 0 ? vzero : vnormalize(v)); +}; /// Clamp v to length len. - var vclamp = cp.v.clamp = function(v, len) - { - return (vdot(v,v) > len*len) ? vmult(vnormalize(v), len) : v; - }; +var vclamp = cp.v.clamp = function(v, len) +{ + return (vdot(v,v) > len*len) ? vmult(vnormalize(v), len) : v; +}; /// Linearly interpolate between v1 towards v2 by distance d. - var vlerpconst = cp.v.lerpconst = function(v1, v2, d) - { - return vadd(v1, vclamp(vsub(v2, v1), d)); - }; +var vlerpconst = cp.v.lerpconst = function(v1, v2, d) +{ + return vadd(v1, vclamp(vsub(v2, v1), d)); +}; /// Returns the distance between v1 and v2. - var vdist = cp.v.dist = function(v1, v2) - { - return vlength(vsub(v1, v2)); - }; +var vdist = cp.v.dist = function(v1, v2) +{ + return vlength(vsub(v1, v2)); +}; /// Returns the squared distance between v1 and v2. Faster than vdist() when you only need to compare distances. - var vdistsq = cp.v.distsq = function(v1, v2) - { - return vlengthsq(vsub(v1, v2)); - }; +var vdistsq = cp.v.distsq = function(v1, v2) +{ + return vlengthsq(vsub(v1, v2)); +}; /// Returns true if the distance between v1 and v2 is less than dist. - var vnear = cp.v.near = function(v1, v2, dist) - { - return vdistsq(v1, v2) < dist*dist; - }; +var vnear = cp.v.near = function(v1, v2, dist) +{ + return vdistsq(v1, v2) < dist*dist; +}; /// Spherical linearly interpolate between v1 and v2. - var vslerp = cp.v.slerp = function(v1, v2, t) - { - var omega = Math.acos(vdot(v1, v2)); - - if(omega) { - var denom = 1/Math.sin(omega); - return vadd(vmult(v1, Math.sin((1 - t)*omega)*denom), vmult(v2, Math.sin(t*omega)*denom)); - } else { - return v1; - } - }; +var vslerp = cp.v.slerp = function(v1, v2, t) +{ + var omega = Math.acos(vdot(v1, v2)); + + if(omega) { + var denom = 1/Math.sin(omega); + return vadd(vmult(v1, Math.sin((1 - t)*omega)*denom), vmult(v2, Math.sin(t*omega)*denom)); + } else { + return v1; + } +}; /// Spherical linearly interpolate between v1 towards v2 by no more than angle a radians - var vslerpconst = cp.v.slerpconst = function(v1, v2, a) - { - var angle = Math.acos(vdot(v1, v2)); - return vslerp(v1, v2, min(a, angle)/angle); - }; +var vslerpconst = cp.v.slerpconst = function(v1, v2, a) +{ + var angle = Math.acos(vdot(v1, v2)); + return vslerp(v1, v2, min(a, angle)/angle); +}; /// Returns the unit length vector for the given angle (in radians). - var vforangle = cp.v.forangle = function(a) - { - return new Vect(Math.cos(a), Math.sin(a)); - }; +var vforangle = cp.v.forangle = function(a) +{ + return new Vect(Math.cos(a), Math.sin(a)); +}; /// Returns the angular direction v is pointing in (in radians). - var vtoangle = cp.v.toangle = function(v) - { - return Math.atan2(v.y, v.x); - }; +var vtoangle = cp.v.toangle = function(v) +{ + return Math.atan2(v.y, v.x); +}; /// Returns a string representation of v. Intended mostly for debugging purposes and not production use. - var vstr = cp.v.str = function(v) - { - return "(" + v.x.toFixed(3) + ", " + v.y.toFixed(3) + ")"; - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +var vstr = cp.v.str = function(v) +{ + return "(" + v.x.toFixed(3) + ", " + v.y.toFixed(3) + ")"; +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ /// Chipmunk's axis-aligned 2D bounding box type along with a few handy routines. - var numBB = 0; +var numBB = 0; // Bounding boxes are JS objects with {l, b, r, t} = left, bottom, right, top, respectively. - var BB = cp.BB = function(l, b, r, t) - { - this.l = l; - this.b = b; - this.r = r; - this.t = t; - - numBB++; - }; - - cp.bb = function(l, b, r, t) { return new BB(l, b, r, t); }; - - var bbNewForCircle = function(p, r) - { - return new BB( - p.x - r, - p.y - r, - p.x + r, - p.y + r - ); - }; +var BB = cp.BB = function(l, b, r, t) +{ + this.l = l; + this.b = b; + this.r = r; + this.t = t; + + numBB++; +}; + +cp.bb = function(l, b, r, t) { return new BB(l, b, r, t); }; + +var bbNewForCircle = function(p, r) +{ + return new BB( + p.x - r, + p.y - r, + p.x + r, + p.y + r + ); +}; /// Returns true if @c a and @c b intersect. - var bbIntersects = function(a, b) - { - return (a.l <= b.r && b.l <= a.r && a.b <= b.t && b.b <= a.t); - }; - var bbIntersects2 = function(bb, l, b, r, t) - { - return (bb.l <= r && l <= bb.r && bb.b <= t && b <= bb.t); - }; +var bbIntersects = function(a, b) +{ + return (a.l <= b.r && b.l <= a.r && a.b <= b.t && b.b <= a.t); +}; +var bbIntersects2 = function(bb, l, b, r, t) +{ + return (bb.l <= r && l <= bb.r && bb.b <= t && b <= bb.t); +}; /// Returns true if @c other lies completely within @c bb. - var bbContainsBB = function(bb, other) - { - return (bb.l <= other.l && bb.r >= other.r && bb.b <= other.b && bb.t >= other.t); - }; +var bbContainsBB = function(bb, other) +{ + return (bb.l <= other.l && bb.r >= other.r && bb.b <= other.b && bb.t >= other.t); +}; /// Returns true if @c bb contains @c v. - var bbContainsVect = function(bb, v) - { - return (bb.l <= v.x && bb.r >= v.x && bb.b <= v.y && bb.t >= v.y); - }; - var bbContainsVect2 = function(l, b, r, t, v) - { - return (l <= v.x && r >= v.x && b <= v.y && t >= v.y); - }; +var bbContainsVect = function(bb, v) +{ + return (bb.l <= v.x && bb.r >= v.x && bb.b <= v.y && bb.t >= v.y); +}; +var bbContainsVect2 = function(l, b, r, t, v) +{ + return (l <= v.x && r >= v.x && b <= v.y && t >= v.y); +}; /// Returns a bounding box that holds both bounding boxes. - var bbMerge = function(a, b){ - return new BB( - min(a.l, b.l), - min(a.b, b.b), - max(a.r, b.r), - max(a.t, b.t) - ); - }; +var bbMerge = function(a, b){ + return new BB( + min(a.l, b.l), + min(a.b, b.b), + max(a.r, b.r), + max(a.t, b.t) + ); +}; /// Returns a bounding box that holds both @c bb and @c v. - var bbExpand = function(bb, v){ - return new BB( - min(bb.l, v.x), - min(bb.b, v.y), - max(bb.r, v.x), - max(bb.t, v.y) - ); - }; +var bbExpand = function(bb, v){ + return new BB( + min(bb.l, v.x), + min(bb.b, v.y), + max(bb.r, v.x), + max(bb.t, v.y) + ); +}; /// Returns the area of the bounding box. - var bbArea = function(bb) - { - return (bb.r - bb.l)*(bb.t - bb.b); - }; +var bbArea = function(bb) +{ + return (bb.r - bb.l)*(bb.t - bb.b); +}; /// Merges @c a and @c b and returns the area of the merged bounding box. - var bbMergedArea = function(a, b) - { - return (max(a.r, b.r) - min(a.l, b.l))*(max(a.t, b.t) - min(a.b, b.b)); - }; +var bbMergedArea = function(a, b) +{ + return (max(a.r, b.r) - min(a.l, b.l))*(max(a.t, b.t) - min(a.b, b.b)); +}; - var bbMergedArea2 = function(bb, l, b, r, t) - { - return (max(bb.r, r) - min(bb.l, l))*(max(bb.t, t) - min(bb.b, b)); - }; +var bbMergedArea2 = function(bb, l, b, r, t) +{ + return (max(bb.r, r) - min(bb.l, l))*(max(bb.t, t) - min(bb.b, b)); +}; /// Return true if the bounding box intersects the line segment with ends @c a and @c b. - var bbIntersectsSegment = function(bb, a, b) - { - return (bbSegmentQuery(bb, a, b) != Infinity); - }; +var bbIntersectsSegment = function(bb, a, b) +{ + return (bbSegmentQuery(bb, a, b) != Infinity); +}; /// Clamp a vector to a bounding box. - var bbClampVect = function(bb, v) - { - var x = min(max(bb.l, v.x), bb.r); - var y = min(max(bb.b, v.y), bb.t); - return new Vect(x, y); - }; +var bbClampVect = function(bb, v) +{ + var x = min(max(bb.l, v.x), bb.r); + var y = min(max(bb.b, v.y), bb.t); + return new Vect(x, y); +}; // TODO edge case issue /// Wrap a vector to a bounding box. - var bbWrapVect = function(bb, v) - { - var ix = Math.abs(bb.r - bb.l); - var modx = (v.x - bb.l) % ix; - var x = (modx > 0) ? modx : modx + ix; - - var iy = Math.abs(bb.t - bb.b); - var mody = (v.y - bb.b) % iy; - var y = (mody > 0) ? mody : mody + iy; - - return new Vect(x + bb.l, y + bb.b); - }; - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - +var bbWrapVect = function(bb, v) +{ + var ix = Math.abs(bb.r - bb.l); + var modx = (v.x - bb.l) % ix; + var x = (modx > 0) ? modx : modx + ix; + + var iy = Math.abs(bb.t - bb.b); + var mody = (v.y - bb.b) % iy; + var y = (mody > 0) ? mody : mody + iy; + + return new Vect(x + bb.l, y + bb.b); +}; +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + /// Segment query info struct. - /* These are created using literals where needed. - typedef struct cpSegmentQueryInfo { - /// The shape that was hit, null if no collision occured. - cpShape *shape; - /// The normalized distance along the query segment in the range [0, 1]. - cpFloat t; - /// The normal of the surface hit. - cpVect n; - } cpSegmentQueryInfo; - */ - - var shapeIDCounter = 0; - - var CP_NO_GROUP = cp.NO_GROUP = 0; - var CP_ALL_LAYERS = cp.ALL_LAYERS = ~0; - - cp.resetShapeIdCounter = function() - { - shapeIDCounter = 0; - }; +/* These are created using literals where needed. +typedef struct cpSegmentQueryInfo { + /// The shape that was hit, null if no collision occured. + cpShape *shape; + /// The normalized distance along the query segment in the range [0, 1]. + cpFloat t; + /// The normal of the surface hit. + cpVect n; +} cpSegmentQueryInfo; +*/ + +var shapeIDCounter = 0; + +var CP_NO_GROUP = cp.NO_GROUP = 0; +var CP_ALL_LAYERS = cp.ALL_LAYERS = ~0; + +cp.resetShapeIdCounter = function() +{ + shapeIDCounter = 0; +}; /// The cpShape struct defines the shape of a rigid body. // /// Opaque collision shape struct. Do not create directly - instead use /// PolyShape, CircleShape and SegmentShape. - var Shape = cp.Shape = function(body) { - /// The rigid body this collision shape is attached to. - this.body = body; - - /// The current bounding box of the shape. - this.bb_l = this.bb_b = this.bb_r = this.bb_t = 0; - - this.hashid = shapeIDCounter++; - - /// Sensor flag. - /// Sensor shapes call collision callbacks but don't produce collisions. - this.sensor = false; - - /// Coefficient of restitution. (elasticity) - this.e = 0; - /// Coefficient of friction. - this.u = 0; - /// Surface velocity used when solving for friction. - this.surface_v = vzero; - - /// Collision type of this shape used when picking collision handlers. - this.collision_type = 0; - /// Group of this shape. Shapes in the same group don't collide. - this.group = 0; - // Layer bitmask for this shape. Shapes only collide if the bitwise and of their layers is non-zero. - this.layers = CP_ALL_LAYERS; - - this.space = null; - - // Copy the collision code from the prototype into the actual object. This makes collision - // function lookups slightly faster. - this.collisionCode = this.collisionCode; - }; - - Shape.prototype.setElasticity = function(e) { this.e = e; }; - Shape.prototype.setFriction = function(u) { this.body.activate(); this.u = u; }; - Shape.prototype.setLayers = function(layers) { this.body.activate(); this.layers = layers; }; - Shape.prototype.setSensor = function(sensor) { this.body.activate(); this.sensor = sensor; }; - Shape.prototype.setCollisionType = function(collision_type) { this.body.activate(); this.collision_type = collision_type; }; - Shape.prototype.getBody = function() { return this.body; }; - - Shape.prototype.active = function() - { -// return shape->prev || shape->body->shapeList == shape; - return this.body && this.body.shapeList.indexOf(this) !== -1; - }; - - Shape.prototype.setBody = function(body) - { - assert(!this.active(), "You cannot change the body on an active shape. You must remove the shape, then "); - this.body = body; - }; - - Shape.prototype.cacheBB = function() - { - return this.update(this.body.p, this.body.rot); - }; - - Shape.prototype.update = function(pos, rot) - { - assert(!isNaN(rot.x), 'Rotation is NaN'); - assert(!isNaN(pos.x), 'Position is NaN'); - this.cacheData(pos, rot); - }; - - Shape.prototype.getBB = function() - { - return new BB(this.bb_l, this.bb_b, this.bb_r, this.bb_t); - }; - - /* Not implemented - all these getters and setters. Just edit the object directly. - CP_DefineShapeStructGetter(cpBody*, body, Body); - void cpShapeSetBody(cpShape *shape, cpBody *body); - - CP_DefineShapeStructGetter(cpBB, bb, BB); - CP_DefineShapeStructProperty(cpBool, sensor, Sensor, cpTrue); - CP_DefineShapeStructProperty(cpFloat, e, Elasticity, cpFalse); - CP_DefineShapeStructProperty(cpFloat, u, Friction, cpTrue); - CP_DefineShapeStructProperty(cpVect, surface_v, SurfaceVelocity, cpTrue); - CP_DefineShapeStructProperty(cpDataPointer, data, UserData, cpFalse); - CP_DefineShapeStructProperty(cpCollisionType, collision_type, CollisionType, cpTrue); - CP_DefineShapeStructProperty(cpGroup, group, Group, cpTrue); - CP_DefineShapeStructProperty(cpLayers, layers, Layers, cpTrue); - */ +var Shape = cp.Shape = function(body) { + /// The rigid body this collision shape is attached to. + this.body = body; + + /// The current bounding box of the shape. + this.bb_l = this.bb_b = this.bb_r = this.bb_t = 0; + + this.hashid = shapeIDCounter++; + + /// Sensor flag. + /// Sensor shapes call collision callbacks but don't produce collisions. + this.sensor = false; + + /// Coefficient of restitution. (elasticity) + this.e = 0; + /// Coefficient of friction. + this.u = 0; + /// Surface velocity used when solving for friction. + this.surface_v = vzero; + + /// Collision type of this shape used when picking collision handlers. + this.collision_type = 0; + /// Group of this shape. Shapes in the same group don't collide. + this.group = 0; + // Layer bitmask for this shape. Shapes only collide if the bitwise and of their layers is non-zero. + this.layers = CP_ALL_LAYERS; + + this.space = null; + + // Copy the collision code from the prototype into the actual object. This makes collision + // function lookups slightly faster. + this.collisionCode = this.collisionCode; +}; + +Shape.prototype.setElasticity = function(e) { this.e = e; }; +Shape.prototype.setFriction = function(u) { this.body.activate(); this.u = u; }; +Shape.prototype.setLayers = function(layers) { this.body.activate(); this.layers = layers; }; +Shape.prototype.setSensor = function(sensor) { this.body.activate(); this.sensor = sensor; }; +Shape.prototype.setCollisionType = function(collision_type) { this.body.activate(); this.collision_type = collision_type; }; +Shape.prototype.getBody = function() { return this.body; }; + +Shape.prototype.active = function() +{ +// return shape->prev || (shape->body && shape->body->shapeList == shape); + return this.body && this.body.shapeList.indexOf(this) !== -1; +}; + +Shape.prototype.setBody = function(body) +{ + assert(!this.active(), "You cannot change the body on an active shape. You must remove the shape from the space before changing the body."); + this.body = body; +}; + +Shape.prototype.cacheBB = function() +{ + return this.update(this.body.p, this.body.rot); +}; + +Shape.prototype.update = function(pos, rot) +{ + assert(!isNaN(rot.x), 'Rotation is NaN'); + assert(!isNaN(pos.x), 'Position is NaN'); + this.cacheData(pos, rot); +}; + +Shape.prototype.pointQuery = function(p) +{ + var info = this.nearestPointQuery(p); + if (info.d < 0) return info; +}; + +Shape.prototype.getBB = function() +{ + return new BB(this.bb_l, this.bb_b, this.bb_r, this.bb_t); +}; + +/* Not implemented - all these getters and setters. Just edit the object directly. +CP_DefineShapeStructGetter(cpBody*, body, Body); +void cpShapeSetBody(cpShape *shape, cpBody *body); + +CP_DefineShapeStructGetter(cpBB, bb, BB); +CP_DefineShapeStructProperty(cpBool, sensor, Sensor, cpTrue); +CP_DefineShapeStructProperty(cpFloat, e, Elasticity, cpFalse); +CP_DefineShapeStructProperty(cpFloat, u, Friction, cpTrue); +CP_DefineShapeStructProperty(cpVect, surface_v, SurfaceVelocity, cpTrue); +CP_DefineShapeStructProperty(cpDataPointer, data, UserData, cpFalse); +CP_DefineShapeStructProperty(cpCollisionType, collision_type, CollisionType, cpTrue); +CP_DefineShapeStructProperty(cpGroup, group, Group, cpTrue); +CP_DefineShapeStructProperty(cpLayers, layers, Layers, cpTrue); +*/ /// Extended point query info struct. Returned from calling pointQuery on a shape. - var PointQueryExtendedInfo = function(shape){ - /// Shape that was hit, NULL if no collision occurred. - this.shape = shape; - /// Depth of the point inside the shape. - this.d = Infinity; - /// Direction of minimum norm to the shape's surface. - this.n = vzero; - }; - - var SegmentQueryInfo = function(shape, t, n){ - /// The shape that was hit, NULL if no collision occured. - this.shape = shape; - /// The normalized distance along the query segment in the range [0, 1]. - this.t = t; - /// The normal of the surface hit. - this.n = n; - }; +var PointQueryExtendedInfo = function(shape) +{ + /// Shape that was hit, NULL if no collision occurred. + this.shape = shape; + /// Depth of the point inside the shape. + this.d = Infinity; + /// Direction of minimum norm to the shape's surface. + this.n = vzero; +}; + +var NearestPointQueryInfo = function(shape, p, d) +{ + /// The nearest shape, NULL if no shape was within range. + this.shape = shape; + /// The closest point on the shape's surface. (in world space coordinates) + this.p = p; + /// The distance to the point. The distance is negative if the point is inside the shape. + this.d = d; +}; + +var SegmentQueryInfo = function(shape, t, n) +{ + /// The shape that was hit, NULL if no collision occured. + this.shape = shape; + /// The normalized distance along the query segment in the range [0, 1]. + this.t = t; + /// The normal of the surface hit. + this.n = n; +}; /// Get the hit point for a segment query. - SegmentQueryInfo.prototype.hitPoint = function(start, end) - { - return vlerp(start, end, this.t); - }; +SegmentQueryInfo.prototype.hitPoint = function(start, end) +{ + return vlerp(start, end, this.t); +}; /// Get the hit distance for a segment query. - SegmentQueryInfo.prototype.hitDist = function(start, end) - { - return vdist(start, end) * this.t; - }; +SegmentQueryInfo.prototype.hitDist = function(start, end) +{ + return vdist(start, end) * this.t; +}; // Circles. - var CircleShape = cp.CircleShape = function(body, radius, offset) - { - this.c = this.tc = offset; - this.r = radius; - - this.type = 'circle'; - - Shape.call(this, body); - }; - - CircleShape.prototype = Object.create(Shape.prototype); - - CircleShape.prototype.cacheData = function(p, rot) - { - //var c = this.tc = vadd(p, vrotate(this.c, rot)); - var c = this.tc = vrotate(this.c, rot).add(p); - //this.bb = bbNewForCircle(c, this.r); - var r = this.r; - this.bb_l = c.x - r; - this.bb_b = c.y - r; - this.bb_r = c.x + r; - this.bb_t = c.y + r; - }; +var CircleShape = cp.CircleShape = function(body, radius, offset) +{ + this.c = this.tc = offset; + this.r = radius; + + this.type = 'circle'; + + Shape.call(this, body); +}; + +CircleShape.prototype = Object.create(Shape.prototype); + +CircleShape.prototype.cacheData = function(p, rot) +{ + //var c = this.tc = vadd(p, vrotate(this.c, rot)); + var c = this.tc = vrotate(this.c, rot).add(p); + //this.bb = bbNewForCircle(c, this.r); + var r = this.r; + this.bb_l = c.x - r; + this.bb_b = c.y - r; + this.bb_r = c.x + r; + this.bb_t = c.y + r; +}; /// Test if a point lies within a shape. - CircleShape.prototype.pointQuery = function(p) - { - var delta = vsub(p, this.tc); - var distsq = vlengthsq(delta); - var r = this.r; - - if(distsq < r*r){ - var info = new PointQueryExtendedInfo(this); - - var dist = Math.sqrt(distsq); - info.d = r - dist; - info.n = vmult(delta, 1/dist); - return info; - } - }; - - var circleSegmentQuery = function(shape, center, r, a, b, info) - { - // offset the line to be relative to the circle - a = vsub(a, center); - b = vsub(b, center); - - var qa = vdot(a, a) - 2*vdot(a, b) + vdot(b, b); - var qb = -2*vdot(a, a) + 2*vdot(a, b); - var qc = vdot(a, a) - r*r; - - var det = qb*qb - 4*qa*qc; - - if(det >= 0) - { - var t = (-qb - Math.sqrt(det))/(2*qa); - if(0 <= t && t <= 1){ - return new SegmentQueryInfo(shape, t, vnormalize(vlerp(a, b, t))); - } - } - }; - - CircleShape.prototype.segmentQuery = function(a, b) - { - return circleSegmentQuery(this, this.tc, this.r, a, b); - }; +/*CircleShape.prototype.pointQuery = function(p) +{ + var delta = vsub(p, this.tc); + var distsq = vlengthsq(delta); + var r = this.r; + + if(distsq < r*r){ + var info = new PointQueryExtendedInfo(this); + + var dist = Math.sqrt(distsq); + info.d = r - dist; + info.n = vmult(delta, 1/dist); + return info; + } +};*/ + +CircleShape.prototype.nearestPointQuery = function(p) +{ + var deltax = p.x - this.tc.x; + var deltay = p.y - this.tc.y; + var d = vlength2(deltax, deltay); + var r = this.r; + + var nearestp = new Vect(this.tc.x + deltax * r/d, this.tc.y + deltay * r/d); + return new NearestPointQueryInfo(this, nearestp, d - r); +}; + +var circleSegmentQuery = function(shape, center, r, a, b, info) +{ + // offset the line to be relative to the circle + a = vsub(a, center); + b = vsub(b, center); + + var qa = vdot(a, a) - 2*vdot(a, b) + vdot(b, b); + var qb = -2*vdot(a, a) + 2*vdot(a, b); + var qc = vdot(a, a) - r*r; + + var det = qb*qb - 4*qa*qc; + + if(det >= 0) + { + var t = (-qb - Math.sqrt(det))/(2*qa); + if(0 <= t && t <= 1){ + return new SegmentQueryInfo(shape, t, vnormalize(vlerp(a, b, t))); + } + } +}; + +CircleShape.prototype.segmentQuery = function(a, b) +{ + return circleSegmentQuery(this, this.tc, this.r, a, b); +}; // The C API has these, and also getters. Its not idiomatic to // write getters and setters in JS. - /* - CircleShape.prototype.setRadius = function(radius) - { - this.r = radius; - } +/* +CircleShape.prototype.setRadius = function(radius) +{ + this.r = radius; +} - CircleShape.prototype.setOffset = function(offset) - { - this.c = offset; - }*/ +CircleShape.prototype.setOffset = function(offset) +{ + this.c = offset; +}*/ // Segment shape - var SegmentShape = cp.SegmentShape = function(body, a, b, r) - { - this.a = a; - this.b = b; - this.n = vperp(vnormalize(vsub(b, a))); - - this.ta = this.tb = this.tn = null; - - this.r = r; - - this.a_tangent = vzero; - this.b_tangent = vzero; - - this.type = 'segment'; - Shape.call(this, body); - }; - - SegmentShape.prototype = Object.create(Shape.prototype); - - SegmentShape.prototype.cacheData = function(p, rot) - { - this.ta = vadd(p, vrotate(this.a, rot)); - this.tb = vadd(p, vrotate(this.b, rot)); - this.tn = vrotate(this.n, rot); - - var l,r,b,t; - - if(this.ta.x < this.tb.x){ - l = this.ta.x; - r = this.tb.x; - } else { - l = this.tb.x; - r = this.ta.x; - } - - if(this.ta.y < this.tb.y){ - b = this.ta.y; - t = this.tb.y; - } else { - b = this.tb.y; - t = this.ta.y; - } - - var rad = this.r; - - this.bb_l = l - rad; - this.bb_b = b - rad; - this.bb_r = r + rad; - this.bb_t = t + rad; - }; - - SegmentShape.prototype.pointQuery = function(p) - { - if(!bbContainsVect2(this.bb_l, this.bb_b, this.bb_r, this.bb_t, p)) return; - - var a = this.ta; - var b = this.tb; - - var seg_delta = vsub(b, a); - var closest_t = clamp01(vdot(seg_delta, vsub(p, a))/vlengthsq(seg_delta)); - var closest = vadd(a, vmult(seg_delta, closest_t)); - - var delta = vsub(p, closest); - var distsq = vlengthsq(delta); - var r = this.r; - - if (distsq < r*r){ - var info = new PointQueryExtendedInfo(this); - - var dist = Math.sqrt(distsq); - info.d = r - dist; - info.n = vmult(delta, 1/dist); - return info; - } - }; - - SegmentShape.prototype.segmentQuery = function(a, b) - { - var n = this.tn; - var d = vdot(vsub(this.ta, a), n); - var r = this.r; - - var flipped_n = (d > 0 ? vneg(n) : n); - var n_offset = vsub(vmult(flipped_n, r), a); - - var seg_a = vadd(this.ta, n_offset); - var seg_b = vadd(this.tb, n_offset); - var delta = vsub(b, a); - - if(vcross(delta, seg_a)*vcross(delta, seg_b) <= 0){ - var d_offset = d + (d > 0 ? -r : r); - var ad = -d_offset; - var bd = vdot(delta, n) - d_offset; - - if(ad*bd < 0){ - return new SegmentQueryInfo(this, ad/(ad - bd), flipped_n); - } - } else if(r !== 0){ - var info1 = circleSegmentQuery(this, this.ta, this.r, a, b); - var info2 = circleSegmentQuery(this, this.tb, this.r, a, b); - - if (info1){ - return info2 && info2.t < info1.t ? info2 : info1; - } else { - return info2; - } - } - }; - - SegmentShape.prototype.setNeighbors = function(prev, next) - { - this.a_tangent = vsub(prev, this.a); - this.b_tangent = vsub(next, this.b); - }; - - SegmentShape.prototype.setEndpoints = function(a, b) - { - this.a = a; - this.b = b; - this.n = vperp(vnormalize(vsub(b, a))); - }; - - /* - cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius) - { - this.r = radius; - }*/ - - /* - CP_DeclareShapeGetter(cpSegmentShape, cpVect, A); - CP_DeclareShapeGetter(cpSegmentShape, cpVect, B); - CP_DeclareShapeGetter(cpSegmentShape, cpVect, Normal); - CP_DeclareShapeGetter(cpSegmentShape, cpFloat, Radius); - */ - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - +var SegmentShape = cp.SegmentShape = function(body, a, b, r) +{ + this.a = a; + this.b = b; + this.n = vperp(vnormalize(vsub(b, a))); + + this.ta = this.tb = this.tn = null; + + this.r = r; + + this.a_tangent = vzero; + this.b_tangent = vzero; + + this.type = 'segment'; + Shape.call(this, body); +}; + +SegmentShape.prototype = Object.create(Shape.prototype); + +SegmentShape.prototype.cacheData = function(p, rot) +{ + this.ta = vadd(p, vrotate(this.a, rot)); + this.tb = vadd(p, vrotate(this.b, rot)); + this.tn = vrotate(this.n, rot); + + var l,r,b,t; + + if(this.ta.x < this.tb.x){ + l = this.ta.x; + r = this.tb.x; + } else { + l = this.tb.x; + r = this.ta.x; + } + + if(this.ta.y < this.tb.y){ + b = this.ta.y; + t = this.tb.y; + } else { + b = this.tb.y; + t = this.ta.y; + } + + var rad = this.r; + + this.bb_l = l - rad; + this.bb_b = b - rad; + this.bb_r = r + rad; + this.bb_t = t + rad; +}; + +SegmentShape.prototype.nearestPointQuery = function(p) +{ + var closest = closestPointOnSegment(p, this.ta, this.tb); + + var deltax = p.x - closest.x; + var deltay = p.y - closest.y; + var d = vlength2(deltax, deltay); + var r = this.r; + + var nearestp = (d ? vadd(closest, vmult(new Vect(deltax, deltay), r/d)) : closest); + return new NearestPointQueryInfo(this, nearestp, d - r); +}; + +SegmentShape.prototype.segmentQuery = function(a, b) +{ + var n = this.tn; + var d = vdot(vsub(this.ta, a), n); + var r = this.r; + + var flipped_n = (d > 0 ? vneg(n) : n); + var n_offset = vsub(vmult(flipped_n, r), a); + + var seg_a = vadd(this.ta, n_offset); + var seg_b = vadd(this.tb, n_offset); + var delta = vsub(b, a); + + if(vcross(delta, seg_a)*vcross(delta, seg_b) <= 0){ + var d_offset = d + (d > 0 ? -r : r); + var ad = -d_offset; + var bd = vdot(delta, n) - d_offset; + + if(ad*bd < 0){ + return new SegmentQueryInfo(this, ad/(ad - bd), flipped_n); + } + } else if(r !== 0){ + var info1 = circleSegmentQuery(this, this.ta, this.r, a, b); + var info2 = circleSegmentQuery(this, this.tb, this.r, a, b); + + if (info1){ + return info2 && info2.t < info1.t ? info2 : info1; + } else { + return info2; + } + } +}; + +SegmentShape.prototype.setNeighbors = function(prev, next) +{ + this.a_tangent = vsub(prev, this.a); + this.b_tangent = vsub(next, this.b); +}; + +SegmentShape.prototype.setEndpoints = function(a, b) +{ + this.a = a; + this.b = b; + this.n = vperp(vnormalize(vsub(b, a))); +}; + +/* +cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius) +{ + this.r = radius; +}*/ + +/* +CP_DeclareShapeGetter(cpSegmentShape, cpVect, A); +CP_DeclareShapeGetter(cpSegmentShape, cpVect, B); +CP_DeclareShapeGetter(cpSegmentShape, cpVect, Normal); +CP_DeclareShapeGetter(cpSegmentShape, cpFloat, Radius); +*/ + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + /// Check that a set of vertexes is convex and has a clockwise winding. - var polyValidate = function(verts) - { - var len = verts.length; - for(var i=0; i 0){ - if(vcross2(bx - ax, by - ay, cx - bx, cy - by) > 0){ - return false; - } - } - - return true; - }; +var polyValidate = function(verts) +{ + var len = verts.length; + for(var i=0; i 0){ + if(vcross2(bx - ax, by - ay, cx - bx, cy - by) > 0){ + return false; + } + } + + return true; +}; /// Initialize a polygon shape. /// The vertexes must be convex and have a clockwise winding. - var PolyShape = cp.PolyShape = function(body, verts, offset) - { - assert(verts.length >= 4, "Polygons require some verts"); - assert(typeof(verts[0]) === 'number', 'Polygon verticies should be specified in a flattened list'); - // Fail if the user attempts to pass a concave poly, or a bad winding. - assert(polyValidate(verts), "Polygon is concave or has a reversed winding."); - - this.setVerts(verts, offset); - this.type = 'poly'; - Shape.call(this, body); - }; - - PolyShape.prototype = Object.create(Shape.prototype); - - var Axis = function(n, d) { - this.n = n; - this.d = d; - }; - - PolyShape.prototype.setVerts = function(verts, offset) - { - var len = verts.length; - var numVerts = len >> 1; - - // This a pretty bad way to do this in javascript. As a first pass, I want to keep - // the code similar to the C. - this.verts = new Array(len); - this.tVerts = new Array(len); - this.axes = new Array(numVerts); - this.tAxes = new Array(numVerts); - - for(var i=0; i>1] = new Axis(n, vdot2(n.x, n.y, ax, ay)); - this.tAxes[i>>1] = new Axis(new Vect(0,0), 0); - } - }; +var PolyShape = cp.PolyShape = function(body, verts, offset) +{ + this.setVerts(verts, offset); + this.type = 'poly'; + Shape.call(this, body); +}; + +PolyShape.prototype = Object.create(Shape.prototype); + +var SplittingPlane = function(n, d) +{ + this.n = n; + this.d = d; +}; + +SplittingPlane.prototype.compare = function(v) +{ + return vdot(this.n, v) - this.d; +}; + +PolyShape.prototype.setVerts = function(verts, offset) +{ + assert(verts.length >= 4, "Polygons require some verts"); + assert(typeof(verts[0]) === 'number', + 'Polygon verticies should be specified in a flattened list (eg [x1,y1,x2,y2,x3,y3,...])'); + + // Fail if the user attempts to pass a concave poly, or a bad winding. + assert(polyValidate(verts), "Polygon is concave or has a reversed winding. Consider using cpConvexHull()"); + + var len = verts.length; + var numVerts = len >> 1; + + // This a pretty bad way to do this in javascript. As a first pass, I want to keep + // the code similar to the C. + this.verts = new Array(len); + this.tVerts = new Array(len); + this.planes = new Array(numVerts); + this.tPlanes = new Array(numVerts); + + for(var i=0; i>1] = new SplittingPlane(n, vdot2(n.x, n.y, ax, ay)); + this.tPlanes[i>>1] = new SplittingPlane(new Vect(0,0), 0); + } +}; /// Initialize a box shaped polygon shape. - var BoxShape = cp.BoxShape = function(body, width, height) - { - var hw = width/2; - var hh = height/2; - - return BoxShape2(body, new BB(-hw, -hh, hw, hh)); - }; +var BoxShape = cp.BoxShape = function(body, width, height) +{ + var hw = width/2; + var hh = height/2; + + return BoxShape2(body, new BB(-hw, -hh, hw, hh)); +}; /// Initialize an offset box shaped polygon shape. - var BoxShape2 = cp.BoxShape2 = function(body, box) - { - var verts = [ - box.l, box.b, - box.l, box.t, - box.r, box.t, - box.r, box.b - ]; - - return new PolyShape(body, verts, vzero); - }; - - PolyShape.prototype.transformVerts = function(p, rot) - { - var src = this.verts; - var dst = this.tVerts; - - var l = Infinity, r = -Infinity; - var b = Infinity, t = -Infinity; - - for(var i=0; i (' + vx + ',' + vy + ')'); - - dst[i] = vx; - dst[i+1] = vy; - - l = min(l, vx); - r = max(r, vx); - b = min(b, vy); - t = max(t, vy); - } - - this.bb_l = l; - this.bb_b = b; - this.bb_r = r; - this.bb_t = t; - }; - - PolyShape.prototype.transformAxes = function(p, rot) - { - var src = this.axes; - var dst = this.tAxes; - - for(var i=0; i an) continue; - - var bn = vdot(b, n); - var t = (axes[i].d - an)/(bn - an); - if(t < 0 || 1 < t) continue; - - var point = vlerp(a, b, t); - var dt = -vcross(n, point); - var dtMin = -vcross2(n.x, n.y, verts[i*2], verts[i*2+1]); - var dtMax = -vcross2(n.x, n.y, verts[(i*2+2)%len], verts[(i*2+3)%len]); - - if(dtMin <= dt && dt <= dtMax){ - // josephg: In the original C code, this function keeps - // looping through axes after finding a match. I *think* - // this code is equivalent... - return new SegmentQueryInfo(this, t, n); - } - } - }; - - - PolyShape.prototype.getNumVerts = function() - { - return this.verts.length/2; - }; - - - PolyShape.prototype.getVert = function(idx) - { - return new Vect(this.verts[idx*2],this.verts[idx*2+1]); - }; - - PolyShape.prototype.valueOnAxis = function(n, d) - { - var verts = this.tVerts; - var m = vdot2(n.x, n.y, verts[0], verts[1]); - - for(var i=2; i 0) return false; - } - - return true; - }; - - PolyShape.prototype.containsVertPartial = function(vx, vy, n) - { - var axes = this.tAxes; - - for(var i=0; i 0) return false; - } - - return true; - }; +var BoxShape2 = cp.BoxShape2 = function(body, box) +{ + var verts = [ + box.l, box.b, + box.l, box.t, + box.r, box.t, + box.r, box.b, + ]; + + return new PolyShape(body, verts, vzero); +}; + +PolyShape.prototype.transformVerts = function(p, rot) +{ + var src = this.verts; + var dst = this.tVerts; + + var l = Infinity, r = -Infinity; + var b = Infinity, t = -Infinity; + + for(var i=0; i (' + vx + ',' + vy + ')'); + + dst[i] = vx; + dst[i+1] = vy; + + l = min(l, vx); + r = max(r, vx); + b = min(b, vy); + t = max(t, vy); + } + + this.bb_l = l; + this.bb_b = b; + this.bb_r = r; + this.bb_t = t; +}; + +PolyShape.prototype.transformAxes = function(p, rot) +{ + var src = this.planes; + var dst = this.tPlanes; + + for(var i=0; i 0) outside = true; + + var v1x = verts[i*2]; + var v1y = verts[i*2 + 1]; + var closest = closestPointOnSegment2(p.x, p.y, v0x, v0y, v1x, v1y); + + var dist = vdist(p, closest); + if(dist < minDist){ + minDist = dist; + closestPoint = closest; + } + + v0x = v1x; + v0y = v1y; + } + + return new NearestPointQueryInfo(this, closestPoint, (outside ? minDist : -minDist)); +}; + +PolyShape.prototype.segmentQuery = function(a, b) +{ + var axes = this.tPlanes; + var verts = this.tVerts; + var numVerts = axes.length; + var len = numVerts * 2; + + for(var i=0; i an) continue; + + var bn = vdot(b, n); + var t = (axes[i].d - an)/(bn - an); + if(t < 0 || 1 < t) continue; + + var point = vlerp(a, b, t); + var dt = -vcross(n, point); + var dtMin = -vcross2(n.x, n.y, verts[i*2], verts[i*2+1]); + var dtMax = -vcross2(n.x, n.y, verts[(i*2+2)%len], verts[(i*2+3)%len]); + + if(dtMin <= dt && dt <= dtMax){ + // josephg: In the original C code, this function keeps + // looping through axes after finding a match. I *think* + // this code is equivalent... + return new SegmentQueryInfo(this, t, n); + } + } +}; + +PolyShape.prototype.valueOnAxis = function(n, d) +{ + var verts = this.tVerts; + var m = vdot2(n.x, n.y, verts[0], verts[1]); + + for(var i=2; i 0) return false; + } + + return true; +}; + +PolyShape.prototype.containsVertPartial = function(vx, vy, n) +{ + var planes = this.tPlanes; + + for(var i=0; i 0) return false; + } + + return true; +}; // These methods are provided for API compatibility with Chipmunk. I recommend against using // them - just access the poly.verts list directly. - PolyShape.prototype.getNumVerts = function() { return this.verts.length / 2; }; - PolyShape.prototype.getVert = function(i) - { - return new Vect(this.verts[i * 2], this.verts[i * 2 + 1]); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +PolyShape.prototype.getNumVerts = function() { return this.verts.length / 2; }; +PolyShape.prototype.getVert = function(i) +{ + return new Vect(this.verts[i * 2], this.verts[i * 2 + 1]); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ /// @defgroup cpBody cpBody /// Chipmunk's rigid body type. Rigid bodies hold the physical properties of an object like @@ -1320,1169 +1504,1172 @@ /// They are given a shape by creating collision shapes (cpShape) that point to the body. /// @{ - var Body = cp.Body = function(m, i) { - /// Mass of the body. - /// Must agree with cpBody.m_inv! Use body.setMass() when changing the mass for this reason. - //this.m; - /// Mass inverse. - //this.m_inv; - - /// Moment of inertia of the body. - /// Must agree with cpBody.i_inv! Use body.setMoment() when changing the moment for this reason. - //this.i; - /// Moment of inertia inverse. - //this.i_inv; - - /// Position of the rigid body's center of gravity. - this.p = new Vect(0,0); - /// Velocity of the rigid body's center of gravity. - this.vx = this.vy = 0; - /// Force acting on the rigid body's center of gravity. - this.f = new Vect(0,0); - - /// Rotation of the body around it's center of gravity in radians. - /// Must agree with cpBody.rot! Use cpBodySetAngle() when changing the angle for this reason. - //this.a; - /// Angular velocity of the body around it's center of gravity in radians/second. - this.w = 0; - /// Torque applied to the body around it's center of gravity. - this.t = 0; - - /// Cached unit length vector representing the angle of the body. - /// Used for fast rotations using cpvrotate(). - //cpVect rot; - - /// Maximum velocity allowed when updating the velocity. - this.v_limit = Infinity; - /// Maximum rotational rate (in radians/second) allowed when updating the angular velocity. - this.w_limit = Infinity; - - // This stuff is all private. - this.v_biasx = this.v_biasy = 0; - this.w_bias = 0; - - this.space = null; - - this.shapeList = []; - this.arbiterList = null; // These are both wacky linked lists. - this.constraintList = null; - - // This stuff is used to track information on the collision graph. - this.nodeRoot = null; - this.nodeNext = null; - this.nodeIdleTime = 0; - - // Set this.m and this.m_inv - this.setMass(m); - - // Set this.i and this.i_inv - this.setMoment(i); - - // Set this.a and this.rot - this.rot = new Vect(0,0); - this.setAngle(0); - }; +var Body = cp.Body = function(m, i) { + /// Mass of the body. + /// Must agree with cpBody.m_inv! Use body.setMass() when changing the mass for this reason. + //this.m; + /// Mass inverse. + //this.m_inv; + + /// Moment of inertia of the body. + /// Must agree with cpBody.i_inv! Use body.setMoment() when changing the moment for this reason. + //this.i; + /// Moment of inertia inverse. + //this.i_inv; + + /// Position of the rigid body's center of gravity. + this.p = new Vect(0,0); + /// Velocity of the rigid body's center of gravity. + this.vx = this.vy = 0; + /// Force acting on the rigid body's center of gravity. + this.f = new Vect(0,0); + + /// Rotation of the body around it's center of gravity in radians. + /// Must agree with cpBody.rot! Use cpBodySetAngle() when changing the angle for this reason. + //this.a; + /// Angular velocity of the body around it's center of gravity in radians/second. + this.w = 0; + /// Torque applied to the body around it's center of gravity. + this.t = 0; + + /// Cached unit length vector representing the angle of the body. + /// Used for fast rotations using cpvrotate(). + //cpVect rot; + + /// Maximum velocity allowed when updating the velocity. + this.v_limit = Infinity; + /// Maximum rotational rate (in radians/second) allowed when updating the angular velocity. + this.w_limit = Infinity; + + // This stuff is all private. + this.v_biasx = this.v_biasy = 0; + this.w_bias = 0; + + this.space = null; + + this.shapeList = []; + this.arbiterList = null; // These are both wacky linked lists. + this.constraintList = null; + + // This stuff is used to track information on the collision graph. + this.nodeRoot = null; + this.nodeNext = null; + this.nodeIdleTime = 0; + + // Set this.m and this.m_inv + this.setMass(m); + + // Set this.i and this.i_inv + this.setMoment(i); + + // Set this.a and this.rot + this.rot = new Vect(0,0); + this.setAngle(0); +}; // I wonder if this should use the constructor style like Body... - var createStaticBody = function() - { - body = new Body(Infinity, Infinity); - body.nodeIdleTime = Infinity; - - return body; - }; - cp.StaticBody = createStaticBody; - - if (typeof DEBUG !== 'undefined' && DEBUG) { - var v_assert_nan = function(v, message){assert(v.x == v.x && v.y == v.y, message); }; - var v_assert_infinite = function(v, message){assert(Math.abs(v.x) !== Infinity && Math.abs(v.y) !== Infinity, message);}; - var v_assert_sane = function(v, message){v_assert_nan(v, message); v_assert_infinite(v, message);}; - - Body.prototype.sanityCheck = function() - { - assert(this.m === this.m && this.m_inv === this.m_inv, "Body's mass is invalid."); - assert(this.i === this.i && this.i_inv === this.i_inv, "Body's moment is invalid."); - - v_assert_sane(this.p, "Body's position is invalid."); - v_assert_sane(this.f, "Body's force is invalid."); - assert(this.vx === this.vx && Math.abs(this.vx) !== Infinity, "Body's velocity is invalid."); - assert(this.vy === this.vy && Math.abs(this.vy) !== Infinity, "Body's velocity is invalid."); - - assert(this.a === this.a && Math.abs(this.a) !== Infinity, "Body's angle is invalid."); - assert(this.w === this.w && Math.abs(this.w) !== Infinity, "Body's angular velocity is invalid."); - assert(this.t === this.t && Math.abs(this.t) !== Infinity, "Body's torque is invalid."); - - v_assert_sane(this.rot, "Internal error: Body's rotation vector is invalid."); - - assert(this.v_limit === this.v_limit, "Body's velocity limit is invalid."); - assert(this.w_limit === this.w_limit, "Body's angular velocity limit is invalid."); - }; - } else { - Body.prototype.sanityCheck = function(){}; - } - - Body.prototype.getPos = function() { return this.p; }; - Body.prototype.getVel = function() { return new Vect(this.vx, this.vy); }; - Body.prototype.getAngVel = function() { return this.w; }; +var createStaticBody = function() +{ + var body = new Body(Infinity, Infinity); + body.nodeIdleTime = Infinity; + + return body; +}; + +if (typeof DEBUG !== 'undefined' && DEBUG) { + var v_assert_nan = function(v, message){assert(v.x == v.x && v.y == v.y, message); }; + var v_assert_infinite = function(v, message){assert(Math.abs(v.x) !== Infinity && Math.abs(v.y) !== Infinity, message);}; + var v_assert_sane = function(v, message){v_assert_nan(v, message); v_assert_infinite(v, message);}; + + Body.prototype.sanityCheck = function() + { + assert(this.m === this.m && this.m_inv === this.m_inv, "Body's mass is invalid."); + assert(this.i === this.i && this.i_inv === this.i_inv, "Body's moment is invalid."); + + v_assert_sane(this.p, "Body's position is invalid."); + v_assert_sane(this.f, "Body's force is invalid."); + assert(this.vx === this.vx && Math.abs(this.vx) !== Infinity, "Body's velocity is invalid."); + assert(this.vy === this.vy && Math.abs(this.vy) !== Infinity, "Body's velocity is invalid."); + + assert(this.a === this.a && Math.abs(this.a) !== Infinity, "Body's angle is invalid."); + assert(this.w === this.w && Math.abs(this.w) !== Infinity, "Body's angular velocity is invalid."); + assert(this.t === this.t && Math.abs(this.t) !== Infinity, "Body's torque is invalid."); + + v_assert_sane(this.rot, "Body's rotation vector is invalid."); + + assert(this.v_limit === this.v_limit, "Body's velocity limit is invalid."); + assert(this.w_limit === this.w_limit, "Body's angular velocity limit is invalid."); + }; +} else { + Body.prototype.sanityCheck = function(){}; +} + +Body.prototype.getPos = function() { return this.p; }; +Body.prototype.getVel = function() { return new Vect(this.vx, this.vy); }; +Body.prototype.getAngVel = function() { return this.w; }; /// Returns true if the body is sleeping. - Body.prototype.isSleeping = function() - { - return this.nodeRoot !== null; - }; +Body.prototype.isSleeping = function() +{ + return this.nodeRoot !== null; +}; /// Returns true if the body is static. - Body.prototype.isStatic = function() - { - return this.nodeIdleTime === Infinity; - }; +Body.prototype.isStatic = function() +{ + return this.nodeIdleTime === Infinity; +}; /// Returns true if the body has not been added to a space. - Body.prototype.isRogue = function() - { - return this.space === null; - }; +Body.prototype.isRogue = function() +{ + return this.space === null; +}; // It would be nicer to use defineProperty for this, but its about 30x slower: // http://jsperf.com/defineproperty-vs-setter - Body.prototype.setMass = function(mass) - { - assert(mass > 0, "Mass must be positive and non-zero."); - - //activate is defined in cpSpaceComponent - this.activate(); - this.m = mass; - this.m_inv = 1/mass; - }; - - Body.prototype.setMoment = function(moment) - { - assert(moment > 0, "Moment of Inertia must be positive and non-zero."); - - this.activate(); - this.i = moment; - this.i_inv = 1/moment; - }; - - Body.prototype.addShape = function(shape) - { - this.shapeList.push(shape); - }; - - Body.prototype.removeShape = function(shape) - { - // This implementation has a linear time complexity with the number of shapes. - // The original implementation used linked lists instead, which might be faster if - // you're constantly editing the shape of a body. I expect most bodies will never - // have their shape edited, so I'm just going to use the simplest possible implemention. - deleteObjFromList(this.shapeList, shape); - }; - - var filterConstraints = function(node, body, filter) - { - if(node === filter){ - return node.next(body); - } else if(node.a === body){ - node.next_a = filterConstraints(node.next_a, body, filter); - } else { - node.next_b = filterConstraints(node.next_b, body, filter); - } - - return node; - }; - - Body.prototype.removeConstraint = function(constraint) - { - // The constraint must be in the constraints list when this is called. - this.constraintList = filterConstraints(this.constraintList, this, constraint); - }; - - Body.prototype.setPos = function(pos) - { - this.activate(); - this.sanityCheck(); - this.p = pos; - }; - - Body.prototype.setVel = function(velocity) - { - this.activate(); - this.vx = velocity.x; - this.vy = velocity.y; - }; - - Body.prototype.setAngVel = function(w) - { - this.activate(); - this.w = w; - }; - - Body.prototype.setAngleInternal = function(angle) - { - assert(!isNaN(angle), "Internal Error: Attempting to set body's angle to NaN"); - this.a = angle;//fmod(a, (cpFloat)M_PI*2.0f); - - //this.rot = vforangle(angle); - this.rot.x = Math.cos(angle); - this.rot.y = Math.sin(angle); - }; - - Body.prototype.setAngle = function(angle) - { - this.activate(); - this.sanityCheck(); - this.setAngleInternal(angle); - }; - - Body.prototype.velocity_func = function(gravity, damping, dt) - { - //this.v = vclamp(vadd(vmult(this.v, damping), vmult(vadd(gravity, vmult(this.f, this.m_inv)), dt)), this.v_limit); - var vx = this.vx * damping + (gravity.x + this.f.x * this.m_inv) * dt; - var vy = this.vy * damping + (gravity.y + this.f.y * this.m_inv) * dt; - - //var v = vclamp(new Vect(vx, vy), this.v_limit); - //this.vx = v.x; this.vy = v.y; - var v_limit = this.v_limit; - var lensq = vx * vx + vy * vy; - var scale = (lensq > v_limit*v_limit) ? v_limit / Math.sqrt(lensq) : 1; - this.vx = vx * scale; - this.vy = vy * scale; - - var w_limit = this.w_limit; - this.w = clamp(this.w*damping + this.t*this.i_inv*dt, -w_limit, w_limit); - - this.sanityCheck(); - }; - - Body.prototype.position_func = function(dt) - { - //this.p = vadd(this.p, vmult(vadd(this.v, this.v_bias), dt)); - - //this.p = this.p + (this.v + this.v_bias) * dt; - this.p.x += (this.vx + this.v_biasx) * dt; - this.p.y += (this.vy + this.v_biasy) * dt; - - this.setAngleInternal(this.a + (this.w + this.w_bias)*dt); - - this.v_biasx = this.v_biasy = 0; - this.w_bias = 0; - - this.sanityCheck(); - }; - - Body.prototype.resetForces = function() - { - this.activate(); - this.f = new Vect(0,0); - this.t = 0; - }; - - Body.prototype.applyForce = function(force, r) - { - this.activate(); - this.f = vadd(this.f, force); - this.t += vcross(r, force); - }; - - Body.prototype.applyImpulse = function(j, r) - { - this.activate(); - apply_impulse(this, j.x, j.y, r); - }; - - Body.prototype.getVelAtPoint = function(r) - { - return vadd(new Vect(this.vx, this.vy), vmult(vperp(r), this.w)); - }; +Body.prototype.setMass = function(mass) +{ + assert(mass > 0, "Mass must be positive and non-zero."); + + //activate is defined in cpSpaceComponent + this.activate(); + this.m = mass; + this.m_inv = 1/mass; +}; + +Body.prototype.setMoment = function(moment) +{ + assert(moment > 0, "Moment of Inertia must be positive and non-zero."); + + this.activate(); + this.i = moment; + this.i_inv = 1/moment; +}; + +Body.prototype.addShape = function(shape) +{ + this.shapeList.push(shape); +}; + +Body.prototype.removeShape = function(shape) +{ + // This implementation has a linear time complexity with the number of shapes. + // The original implementation used linked lists instead, which might be faster if + // you're constantly editing the shape of a body. I expect most bodies will never + // have their shape edited, so I'm just going to use the simplest possible implemention. + deleteObjFromList(this.shapeList, shape); +}; + +var filterConstraints = function(node, body, filter) +{ + if(node === filter){ + return node.next(body); + } else if(node.a === body){ + node.next_a = filterConstraints(node.next_a, body, filter); + } else { + node.next_b = filterConstraints(node.next_b, body, filter); + } + + return node; +}; + +Body.prototype.removeConstraint = function(constraint) +{ + // The constraint must be in the constraints list when this is called. + this.constraintList = filterConstraints(this.constraintList, this, constraint); +}; + +Body.prototype.setPos = function(pos) +{ + this.activate(); + this.sanityCheck(); + // If I allow the position to be set to vzero, vzero will get changed. + if (pos === vzero) { + pos = cp.v(0,0); + } + this.p = pos; +}; + +Body.prototype.setVel = function(velocity) +{ + this.activate(); + this.vx = velocity.x; + this.vy = velocity.y; +}; + +Body.prototype.setAngVel = function(w) +{ + this.activate(); + this.w = w; +}; + +Body.prototype.setAngleInternal = function(angle) +{ + assert(!isNaN(angle), "Internal Error: Attempting to set body's angle to NaN"); + this.a = angle;//fmod(a, (cpFloat)M_PI*2.0f); + + //this.rot = vforangle(angle); + this.rot.x = Math.cos(angle); + this.rot.y = Math.sin(angle); +}; + +Body.prototype.setAngle = function(angle) +{ + this.activate(); + this.sanityCheck(); + this.setAngleInternal(angle); +}; + +Body.prototype.velocity_func = function(gravity, damping, dt) +{ + //this.v = vclamp(vadd(vmult(this.v, damping), vmult(vadd(gravity, vmult(this.f, this.m_inv)), dt)), this.v_limit); + var vx = this.vx * damping + (gravity.x + this.f.x * this.m_inv) * dt; + var vy = this.vy * damping + (gravity.y + this.f.y * this.m_inv) * dt; + + //var v = vclamp(new Vect(vx, vy), this.v_limit); + //this.vx = v.x; this.vy = v.y; + var v_limit = this.v_limit; + var lensq = vx * vx + vy * vy; + var scale = (lensq > v_limit*v_limit) ? v_limit / Math.sqrt(lensq) : 1; + this.vx = vx * scale; + this.vy = vy * scale; + + var w_limit = this.w_limit; + this.w = clamp(this.w*damping + this.t*this.i_inv*dt, -w_limit, w_limit); + + this.sanityCheck(); +}; + +Body.prototype.position_func = function(dt) +{ + //this.p = vadd(this.p, vmult(vadd(this.v, this.v_bias), dt)); + + //this.p = this.p + (this.v + this.v_bias) * dt; + this.p.x += (this.vx + this.v_biasx) * dt; + this.p.y += (this.vy + this.v_biasy) * dt; + + this.setAngleInternal(this.a + (this.w + this.w_bias)*dt); + + this.v_biasx = this.v_biasy = 0; + this.w_bias = 0; + + this.sanityCheck(); +}; + +Body.prototype.resetForces = function() +{ + this.activate(); + this.f = new Vect(0,0); + this.t = 0; +}; + +Body.prototype.applyForce = function(force, r) +{ + this.activate(); + this.f = vadd(this.f, force); + this.t += vcross(r, force); +}; + +Body.prototype.applyImpulse = function(j, r) +{ + this.activate(); + apply_impulse(this, j.x, j.y, r); +}; + +Body.prototype.getVelAtPoint = function(r) +{ + return vadd(new Vect(this.vx, this.vy), vmult(vperp(r), this.w)); +}; /// Get the velocity on a body (in world units) at a point on the body in world coordinates. - Body.prototype.getVelAtWorldPoint = function(point) - { - return this.getVelAtPoint(vsub(point, this.p)); - }; +Body.prototype.getVelAtWorldPoint = function(point) +{ + return this.getVelAtPoint(vsub(point, this.p)); +}; /// Get the velocity on a body (in world units) at a point on the body in local coordinates. - Body.prototype.getVelAtLocalPoint = function(point) - { - return this.getVelAtPoint(vrotate(point, this.rot)); - }; - - Body.prototype.eachShape = function(func) - { - for(var i = 0, len = this.shapeList.length; i < len; i++) { - func(this.shapeList[i]); - } - }; - - Body.prototype.eachConstraint = function(func) - { - var constraint = this.constraintList; - while(constraint) { - var next = constraint.next(this); - func(constraint); - constraint = next; - } - }; - - Body.prototype.eachArbiter = function(func) - { - var arb = this.arbiterList; - while(arb){ - var next = arb.next(this); - - arb.swappedColl = (this === arb.body_b); - func(arb); - - arb = next; - } - }; +Body.prototype.getVelAtLocalPoint = function(point) +{ + return this.getVelAtPoint(vrotate(point, this.rot)); +}; + +Body.prototype.eachShape = function(func) +{ + for(var i = 0, len = this.shapeList.length; i < len; i++) { + func(this.shapeList[i]); + } +}; + +Body.prototype.eachConstraint = function(func) +{ + var constraint = this.constraintList; + while(constraint) { + var next = constraint.next(this); + func(constraint); + constraint = next; + } +}; + +Body.prototype.eachArbiter = function(func) +{ + var arb = this.arbiterList; + while(arb){ + var next = arb.next(this); + + arb.swappedColl = (this === arb.body_b); + func(arb); + + arb = next; + } +}; /// Convert body relative/local coordinates to absolute/world coordinates. - Body.prototype.local2World = function(v) - { - return vadd(this.p, vrotate(v, this.rot)); - }; +Body.prototype.local2World = function(v) +{ + return vadd(this.p, vrotate(v, this.rot)); +}; /// Convert body absolute/world coordinates to relative/local coordinates. - Body.prototype.world2Local = function(v) - { - return vunrotate(vsub(v, this.p), this.rot); - }; +Body.prototype.world2Local = function(v) +{ + return vunrotate(vsub(v, this.p), this.rot); +}; /// Get the kinetic energy of a body. - Body.prototype.kineticEnergy = function() - { - // Need to do some fudging to avoid NaNs - var vsq = this.vx*this.vx + this.vy*this.vy; - var wsq = this.w * this.w; - return (vsq ? vsq*this.m : 0) + (wsq ? wsq*this.i : 0); - }; - - /* Copyright (c) 2010 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - /** - @defgroup cpSpatialIndex cpSpatialIndex - - Spatial indexes are data structures that are used to accelerate collision detection - and spatial queries. Chipmunk provides a number of spatial index algorithms to pick from - and they are programmed in a generic way so that you can use them for holding more than - just Shapes. - - It works by using pointers to the objects you add and using a callback to ask your code - for bounding boxes when it needs them. Several types of queries can be performed an index as well - as reindexing and full collision information. All communication to the spatial indexes is performed - through callback functions. - - Spatial indexes should be treated as opaque structs. - This means you shouldn't be reading any of the fields directly. - - All spatial indexes define the following methods: - - // The number of objects in the spatial index. - count = 0; - - // Iterate the objects in the spatial index. @c func will be called once for each object. - each(func); - - // Returns true if the spatial index contains the given object. - // Most spatial indexes use hashed storage, so you must provide a hash value too. - contains(obj, hashid); - - // Add an object to a spatial index. - insert(obj, hashid); - - // Remove an object from a spatial index. - remove(obj, hashid); - - // Perform a full reindex of a spatial index. - reindex(); - - // Reindex a single object in the spatial index. - reindexObject(obj, hashid); - - // Perform a point query against the spatial index, calling @c func for each potential match. - // A pointer to the point will be passed as @c obj1 of @c func. - // func(shape); - pointQuery(point, func); - - // Perform a segment query against the spatial index, calling @c func for each potential match. - // func(shape); - segmentQuery(vect a, vect b, t_exit, func); - - // Perform a rectangle query against the spatial index, calling @c func for each potential match. - // func(shape); - query(bb, func); - - // Simultaneously reindex and find all colliding objects. - // @c func will be called once for each potentially overlapping pair of objects found. - // If the spatial index was initialized with a static index, it will collide it's objects against that as well. - reindexQuery(func); - */ - - var SpatialIndex = cp.SpatialIndex = function(staticIndex) - { - this.staticIndex = staticIndex; - - if(staticIndex){ - assert(!staticIndex.dynamicIndex, "This static index is already associated with a dynamic index."); - staticIndex.dynamicIndex = this; - } - }; +Body.prototype.kineticEnergy = function() +{ + // Need to do some fudging to avoid NaNs + var vsq = this.vx*this.vx + this.vy*this.vy; + var wsq = this.w * this.w; + return (vsq ? vsq*this.m : 0) + (wsq ? wsq*this.i : 0); +}; + +/* Copyright (c) 2010 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + @defgroup cpSpatialIndex cpSpatialIndex + + Spatial indexes are data structures that are used to accelerate collision detection + and spatial queries. Chipmunk provides a number of spatial index algorithms to pick from + and they are programmed in a generic way so that you can use them for holding more than + just Shapes. + + It works by using pointers to the objects you add and using a callback to ask your code + for bounding boxes when it needs them. Several types of queries can be performed an index as well + as reindexing and full collision information. All communication to the spatial indexes is performed + through callback functions. + + Spatial indexes should be treated as opaque structs. + This means you shouldn't be reading any of the fields directly. + + All spatial indexes define the following methods: + + // The number of objects in the spatial index. + count = 0; + + // Iterate the objects in the spatial index. @c func will be called once for each object. + each(func); + + // Returns true if the spatial index contains the given object. + // Most spatial indexes use hashed storage, so you must provide a hash value too. + contains(obj, hashid); + + // Add an object to a spatial index. + insert(obj, hashid); + + // Remove an object from a spatial index. + remove(obj, hashid); + + // Perform a full reindex of a spatial index. + reindex(); + + // Reindex a single object in the spatial index. + reindexObject(obj, hashid); + + // Perform a point query against the spatial index, calling @c func for each potential match. + // A pointer to the point will be passed as @c obj1 of @c func. + // func(shape); + pointQuery(point, func); + + // Perform a segment query against the spatial index, calling @c func for each potential match. + // func(shape); + segmentQuery(vect a, vect b, t_exit, func); + + // Perform a rectangle query against the spatial index, calling @c func for each potential match. + // func(shape); + query(bb, func); + + // Simultaneously reindex and find all colliding objects. + // @c func will be called once for each potentially overlapping pair of objects found. + // If the spatial index was initialized with a static index, it will collide it's objects against that as well. + reindexQuery(func); +*/ + +var SpatialIndex = cp.SpatialIndex = function(staticIndex) +{ + this.staticIndex = staticIndex; + + + if(staticIndex){ + if(staticIndex.dynamicIndex){ + throw new Error("This static index is already associated with a dynamic index."); + } + staticIndex.dynamicIndex = this; + } +}; // Collide the objects in an index against the objects in a staticIndex using the query callback function. - SpatialIndex.prototype.collideStatic = function(staticIndex, func) - { - if(staticIndex.count > 0){ - var query = staticIndex.query; - - this.each(function(obj) { - query(obj, new BB(obj.bb_l, obj.bb_b, obj.bb_r, obj.bb_t), func); - }); - } - }; - - - /* Copyright (c) 2009 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +SpatialIndex.prototype.collideStatic = function(staticIndex, func) +{ + if(staticIndex.count > 0){ + var query = staticIndex.query; + + this.each(function(obj) { + query(obj, new BB(obj.bb_l, obj.bb_b, obj.bb_r, obj.bb_t), func); + }); + } +}; + + +/* Copyright (c) 2009 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // This file implements a modified AABB tree for collision detection. - var BBTree = cp.BBTree = function(staticIndex) - { - SpatialIndex.call(this, staticIndex); - - this.velocityFunc = null; - - // This is a hash from object ID -> object for the objects stored in the BBTree. - this.leaves = {}; - // A count of the number of leaves in the BBTree. - this.count = 0; - - this.root = null; - - // An object pool of tree nodes and pairs. - //this.pooledNodes = []; - //this.pooledPairs = []; - - this.stamp = 0; - }; - - BBTree.prototype = Object.create(SpatialIndex.prototype); - - var numNodes = 0; - - var Node = function(tree, a, b) - { - //Node *node = NodeFromPool(tree); - this.obj = null; - //this.bb = bbMerge(a.bb, b.bb); - this.bb_l = min(a.bb_l, b.bb_l); - this.bb_b = min(a.bb_b, b.bb_b); - this.bb_r = max(a.bb_r, b.bb_r); - this.bb_t = max(a.bb_t, b.bb_t); - this.parent = null; - - this.setA(a); - this.setB(b); - numNodes++; - }; - - var numLeaves = 0; - var Leaf = function(tree, obj) - { - //Node *node = NodeFromPool(tree); - - this.obj = obj; - //this.bb = tree.getBB(obj); - tree.getBB(obj, this); - - this.parent = null; - - this.stamp = 1; - this.pairs = null; - numLeaves++; - }; +var BBTree = cp.BBTree = function(staticIndex) +{ + SpatialIndex.call(this, staticIndex); + + this.velocityFunc = null; + + // This is a hash from object ID -> object for the objects stored in the BBTree. + this.leaves = {}; + // A count of the number of leaves in the BBTree. + this.count = 0; + + this.root = null; + + // A linked list containing an object pool of tree nodes and pairs. + this.pooledNodes = null; + this.pooledPairs = null; + + this.stamp = 0; +}; + +BBTree.prototype = Object.create(SpatialIndex.prototype); + +var numNodes = 0; + +var Node = function(tree, a, b) +{ + this.obj = null; + this.bb_l = min(a.bb_l, b.bb_l); + this.bb_b = min(a.bb_b, b.bb_b); + this.bb_r = max(a.bb_r, b.bb_r); + this.bb_t = max(a.bb_t, b.bb_t); + this.parent = null; + + this.setA(a); + this.setB(b); +}; + +BBTree.prototype.makeNode = function(a, b) +{ + var node = this.pooledNodes; + if(node){ + this.pooledNodes = node.parent; + node.constructor(this, a, b); + return node; + } else { + numNodes++; + return new Node(this, a, b); + } +}; + +var numLeaves = 0; +var Leaf = function(tree, obj) +{ + this.obj = obj; + tree.getBB(obj, this); + + this.parent = null; + + this.stamp = 1; + this.pairs = null; + numLeaves++; +}; // **** Misc Functions - BBTree.prototype.getBB = function(obj, dest) - { - var velocityFunc = this.velocityFunc; - if(velocityFunc){ - var coef = 0.1; - var x = (obj.bb_r - obj.bb_l)*coef; - var y = (obj.bb_t - obj.bb_b)*coef; - - var v = vmult(velocityFunc(obj), 0.1); - - dest.bb_l = obj.bb_l + min(-x, v.x); - dest.bb_b = obj.bb_b + min(-y, v.y); - dest.bb_r = obj.bb_r + max( x, v.x); - dest.bb_t = obj.bb_t + max( y, v.y); - } else { - dest.bb_l = obj.bb_l; - dest.bb_b = obj.bb_b; - dest.bb_r = obj.bb_r; - dest.bb_t = obj.bb_t; - } - }; - - BBTree.prototype.getStamp = function() - { - var dynamic = this.dynamicIndex; - return (dynamic && dynamic.stamp ? dynamic.stamp : this.stamp); - }; - - BBTree.prototype.incrementStamp = function() - { - if(this.dynamicIndex && this.dynamicIndex.stamp){ - this.dynamicIndex.stamp++; - } else { - this.stamp++; - } - } +BBTree.prototype.getBB = function(obj, dest) +{ + var velocityFunc = this.velocityFunc; + if(velocityFunc){ + var coef = 0.1; + var x = (obj.bb_r - obj.bb_l)*coef; + var y = (obj.bb_t - obj.bb_b)*coef; + + var v = vmult(velocityFunc(obj), 0.1); + + dest.bb_l = obj.bb_l + min(-x, v.x); + dest.bb_b = obj.bb_b + min(-y, v.y); + dest.bb_r = obj.bb_r + max( x, v.x); + dest.bb_t = obj.bb_t + max( y, v.y); + } else { + dest.bb_l = obj.bb_l; + dest.bb_b = obj.bb_b; + dest.bb_r = obj.bb_r; + dest.bb_t = obj.bb_t; + } +}; + +BBTree.prototype.getStamp = function() +{ + var dynamic = this.dynamicIndex; + return (dynamic && dynamic.stamp ? dynamic.stamp : this.stamp); +}; + +BBTree.prototype.incrementStamp = function() +{ + if(this.dynamicIndex && this.dynamicIndex.stamp){ + this.dynamicIndex.stamp++; + } else { + this.stamp++; + } +} // **** Pair/Thread Functions +var numPairs = 0; // Objects created with constructors are faster than object literals. :( - var Pair = function(a, b) - { - this.a = a; this.b = b; - }; - - var Thread = function(leaf, next) - { - this.prev = null; - this.next = next; - this.leaf = leaf; - }; - -// Benchmark this code with object pools on & off. - /* - BBTree.prototype.pairRecycle = function(pair) - { - this.pooledPairs.push(pair); - }; - - BBTree.prototype.pairFromPool = function() - { - return this.pooledPairs.pop() || new Pair(null, null); - }; - */ - - Thread.prototype.unlink = function() - { - var next = this.next; - var prev = this.prev; - - if(next){ - if(next.a.leaf == this.leaf) next.a.prev = prev; else next.b.prev = prev; - } - - if(prev){ - if(prev.a.leaf == this.leaf) prev.a.next = next; else prev.b.next = next; - } else { - this.leaf.pairs = next; - } - }; - - Leaf.prototype.clearPairs = function(tree) - { - var pair = this.pairs, - next; - - this.pairs = null; - - while(pair){ - if(pair.a.leaf == this){ - next = pair.a.next; - pair.b.unlink(); - //tree.pairRecycle(pair); - pair = next; - } else { - next = pair.b.next; - pair.a.unlink(); - //tree.pairRecycle(pair); - pair = next; - } - } - } - - var pairInsert = function(a, b, tree) - { - var nextA = a.pairs, nextB = b.pairs; - var pair = new Pair(new Thread(a, nextA), new Thread(b, nextB)); - a.pairs = b.pairs = pair; - - //var pair = tree.pairFromPool(); - //Pair temp = {{null, a, nextA},{null, b, nextB}}; - //*pair = temp; - - if(nextA){ - if(nextA.a.leaf == a) nextA.a.prev = pair; else nextA.b.prev = pair; - } - - if(nextB){ - if(nextB.a.leaf == b) nextB.a.prev = pair; else nextB.b.prev = pair; - } - }; +var Pair = function(leafA, nextA, leafB, nextB) +{ + this.prevA = null; + this.leafA = leafA; + this.nextA = nextA; + + this.prevB = null; + this.leafB = leafB; + this.nextB = nextB; +}; + +BBTree.prototype.makePair = function(leafA, nextA, leafB, nextB) +{ + //return new Pair(leafA, nextA, leafB, nextB); + var pair = this.pooledPairs; + if (pair) + { + this.pooledPairs = pair.prevA; + + pair.prevA = null; + pair.leafA = leafA; + pair.nextA = nextA; + + pair.prevB = null; + pair.leafB = leafB; + pair.nextB = nextB; + + //pair.constructor(leafA, nextA, leafB, nextB); + return pair; + } else { + numPairs++; + return new Pair(leafA, nextA, leafB, nextB); + } +}; + +Pair.prototype.recycle = function(tree) +{ + this.prevA = tree.pooledPairs; + tree.pooledPairs = this; +}; + +var unlinkThread = function(prev, leaf, next) +{ + if(next){ + if(next.leafA === leaf) next.prevA = prev; else next.prevB = prev; + } + + if(prev){ + if(prev.leafA === leaf) prev.nextA = next; else prev.nextB = next; + } else { + leaf.pairs = next; + } +}; + +Leaf.prototype.clearPairs = function(tree) +{ + var pair = this.pairs, + next; + + this.pairs = null; + + while(pair){ + if(pair.leafA === this){ + next = pair.nextA; + unlinkThread(pair.prevB, pair.leafB, pair.nextB); + } else { + next = pair.nextB; + unlinkThread(pair.prevA, pair.leafA, pair.nextA); + } + pair.recycle(tree); + pair = next; + } +}; + +var pairInsert = function(a, b, tree) +{ + var nextA = a.pairs, nextB = b.pairs; + var pair = tree.makePair(a, nextA, b, nextB); + a.pairs = b.pairs = pair; + + if(nextA){ + if(nextA.leafA === a) nextA.prevA = pair; else nextA.prevB = pair; + } + + if(nextB){ + if(nextB.leafA === b) nextB.prevA = pair; else nextB.prevB = pair; + } +}; // **** Node Functions - /* - static void - NodeRecycle(bbTree *tree, Node *node) - { - node.parent = tree.pooledNodes; - tree.pooledNodes = node; - } - - static Node * - NodeFromPool(bbTree *tree) - { - Node *node = tree.pooledNodes; - - if(node){ - tree.pooledNodes = node.parent; - return node; - } else { - // Pool is exhausted, make more - } - }*/ - - Node.prototype.setA = function(value) - { - this.A = value; - value.parent = this; - }; - - Node.prototype.setB = function(value) - { - this.B = value; - value.parent = this; - }; - - /* - static inline cpBool - NodeIsLeaf(Node *node) - { - return (node.obj != null); - }*/ - Leaf.prototype.isLeaf = true; - Node.prototype.isLeaf = false; - - Node.prototype.otherChild = function(child) - { - return (this.A == child ? this.B : this.A); - }; - - Node.prototype.replaceChild = function(child, value, tree) - { - assertSoft(child == this.A || child == this.B, "Node is not a child of parent."); - - if(this.A == child){ - //NodeRecycle(tree, parent.A); - this.setA(value); - } else { - //NodeRecycle(tree, parent.B); - this.setB(value); - } - - for(var node=this; node; node = node.parent){ - //node.bb = bbMerge(node.A.bb, node.B.bb); - var a = node.A; - var b = node.B; - node.bb_l = min(a.bb_l, b.bb_l); - node.bb_b = min(a.bb_b, b.bb_b); - node.bb_r = max(a.bb_r, b.bb_r); - node.bb_t = max(a.bb_t, b.bb_t); - } - }; - - Node.prototype.bbArea = Leaf.prototype.bbArea = function() - { - return (this.bb_r - this.bb_l)*(this.bb_t - this.bb_b); - }; - - var bbTreeMergedArea = function(a, b) - { - return (max(a.bb_r, b.bb_r) - min(a.bb_l, b.bb_l))*(max(a.bb_t, b.bb_t) - min(a.bb_b, b.bb_b)); - }; +Node.prototype.recycle = function(tree) +{ + this.parent = tree.pooledNodes; + tree.pooledNodes = this; +}; + +Leaf.prototype.recycle = function(tree) +{ + // Its not worth the overhead to recycle leaves. +}; + +Node.prototype.setA = function(value) +{ + this.A = value; + value.parent = this; +}; + +Node.prototype.setB = function(value) +{ + this.B = value; + value.parent = this; +}; + +Leaf.prototype.isLeaf = true; +Node.prototype.isLeaf = false; + +Node.prototype.otherChild = function(child) +{ + return (this.A == child ? this.B : this.A); +}; + +Node.prototype.replaceChild = function(child, value, tree) +{ + assertSoft(child == this.A || child == this.B, "Node is not a child of parent."); + + if(this.A == child){ + this.A.recycle(tree); + this.setA(value); + } else { + this.B.recycle(tree); + this.setB(value); + } + + for(var node=this; node; node = node.parent){ + //node.bb = bbMerge(node.A.bb, node.B.bb); + var a = node.A; + var b = node.B; + node.bb_l = min(a.bb_l, b.bb_l); + node.bb_b = min(a.bb_b, b.bb_b); + node.bb_r = max(a.bb_r, b.bb_r); + node.bb_t = max(a.bb_t, b.bb_t); + } +}; + +Node.prototype.bbArea = Leaf.prototype.bbArea = function() +{ + return (this.bb_r - this.bb_l)*(this.bb_t - this.bb_b); +}; + +var bbTreeMergedArea = function(a, b) +{ + return (max(a.bb_r, b.bb_r) - min(a.bb_l, b.bb_l))*(max(a.bb_t, b.bb_t) - min(a.bb_b, b.bb_b)); +}; // **** Subtree Functions // Would it be better to make these functions instance methods on Node and Leaf? - var bbProximity = function(a, b) - { - return Math.abs(a.bb_l + a.bb_r - b.bb_l - b.bb_r) + Math.abs(a.bb_b + b.bb_t - b.bb_b - b.bb_t); - } +var bbProximity = function(a, b) +{ + return Math.abs(a.bb_l + a.bb_r - b.bb_l - b.bb_r) + Math.abs(a.bb_b + a.bb_t - b.bb_b - b.bb_t); +}; - var subtreeInsert = function(subtree, leaf, tree) - { +var subtreeInsert = function(subtree, leaf, tree) +{ // var s = new Error().stack; // traces[s] = traces[s] ? traces[s]+1 : 1; - if(subtree == null){ - return leaf; - } else if(subtree.isLeaf){ - return new Node(tree, leaf, subtree); - } else { - var cost_a = subtree.B.bbArea() + bbTreeMergedArea(subtree.A, leaf); - var cost_b = subtree.A.bbArea() + bbTreeMergedArea(subtree.B, leaf); - - if(cost_a === cost_b){ - cost_a = bbProximity(subtree.A, leaf); - cost_b = bbProximity(subtree.B, leaf); - } - - if(cost_b < cost_a){ - subtree.setB(subtreeInsert(subtree.B, leaf, tree)); - } else { - subtree.setA(subtreeInsert(subtree.A, leaf, tree)); - } - + if(subtree == null){ + return leaf; + } else if(subtree.isLeaf){ + return tree.makeNode(leaf, subtree); + } else { + var cost_a = subtree.B.bbArea() + bbTreeMergedArea(subtree.A, leaf); + var cost_b = subtree.A.bbArea() + bbTreeMergedArea(subtree.B, leaf); + + if(cost_a === cost_b){ + cost_a = bbProximity(subtree.A, leaf); + cost_b = bbProximity(subtree.B, leaf); + } + + if(cost_b < cost_a){ + subtree.setB(subtreeInsert(subtree.B, leaf, tree)); + } else { + subtree.setA(subtreeInsert(subtree.A, leaf, tree)); + } + // subtree.bb = bbMerge(subtree.bb, leaf.bb); - subtree.bb_l = min(subtree.bb_l, leaf.bb_l); - subtree.bb_b = min(subtree.bb_b, leaf.bb_b); - subtree.bb_r = max(subtree.bb_r, leaf.bb_r); - subtree.bb_t = max(subtree.bb_t, leaf.bb_t); - - return subtree; - } - }; - - Node.prototype.intersectsBB = Leaf.prototype.intersectsBB = function(bb) - { - return (this.bb_l <= bb.r && bb.l <= this.bb_r && this.bb_b <= bb.t && bb.b <= this.bb_t); - }; - - var subtreeQuery = function(subtree, bb, func) - { - //if(bbIntersectsBB(subtree.bb, bb)){ - if(subtree.intersectsBB(bb)){ - if(subtree.isLeaf){ - func(subtree.obj); - } else { - subtreeQuery(subtree.A, bb, func); - subtreeQuery(subtree.B, bb, func); - } - } - }; + subtree.bb_l = min(subtree.bb_l, leaf.bb_l); + subtree.bb_b = min(subtree.bb_b, leaf.bb_b); + subtree.bb_r = max(subtree.bb_r, leaf.bb_r); + subtree.bb_t = max(subtree.bb_t, leaf.bb_t); + + return subtree; + } +}; + +Node.prototype.intersectsBB = Leaf.prototype.intersectsBB = function(bb) +{ + return (this.bb_l <= bb.r && bb.l <= this.bb_r && this.bb_b <= bb.t && bb.b <= this.bb_t); +}; + +var subtreeQuery = function(subtree, bb, func) +{ + //if(bbIntersectsBB(subtree.bb, bb)){ + if(subtree.intersectsBB(bb)){ + if(subtree.isLeaf){ + func(subtree.obj); + } else { + subtreeQuery(subtree.A, bb, func); + subtreeQuery(subtree.B, bb, func); + } + } +}; /// Returns the fraction along the segment query the node hits. Returns Infinity if it doesn't hit. - var nodeSegmentQuery = function(node, a, b) - { - var idx = 1/(b.x - a.x); - var tx1 = (node.bb_l == a.x ? -Infinity : (node.bb_l - a.x)*idx); - var tx2 = (node.bb_r == a.x ? Infinity : (node.bb_r - a.x)*idx); - var txmin = min(tx1, tx2); - var txmax = max(tx1, tx2); - - var idy = 1/(b.y - a.y); - var ty1 = (node.bb_b == a.y ? -Infinity : (node.bb_b - a.y)*idy); - var ty2 = (node.bb_t == a.y ? Infinity : (node.bb_t - a.y)*idy); - var tymin = min(ty1, ty2); - var tymax = max(ty1, ty2); - - if(tymin <= txmax && txmin <= tymax){ - var min_ = max(txmin, tymin); - var max_ = min(txmax, tymax); - - if(0.0 <= max_ && min_ <= 1.0) return max(min_, 0.0); - } - - return Infinity; - }; - - var subtreeSegmentQuery = function(subtree, a, b, t_exit, func) - { - if(subtree.isLeaf){ - return func(subtree.obj); - } else { - var t_a = nodeSegmentQuery(subtree.A, a, b); - var t_b = nodeSegmentQuery(subtree.B, a, b); - - if(t_a < t_b){ - if(t_a < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.A, a, b, t_exit, func)); - if(t_b < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.B, a, b, t_exit, func)); - } else { - if(t_b < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.B, a, b, t_exit, func)); - if(t_a < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.A, a, b, t_exit, func)); - } - - return t_exit; - } - }; - - /* - static void - SubtreeRecycle(bbTree *tree, Node *node) - { - if(!NodeIsLeaf(node)){ - SubtreeRecycle(tree, node.A); - SubtreeRecycle(tree, node.B); - NodeRecycle(tree, node); - } - }*/ - - var subtreeRemove = function(subtree, leaf, tree) - { - if(leaf == subtree){ - return null; - } else { - var parent = leaf.parent; - if(parent == subtree){ - var other = subtree.otherChild(leaf); - other.parent = subtree.parent; - //NodeRecycle(tree, subtree); - return other; - } else { - parent.parent.replaceChild(parent, parent.otherChild(leaf), tree); - return subtree; - } - } - }; +var nodeSegmentQuery = function(node, a, b) +{ + var idx = 1/(b.x - a.x); + var tx1 = (node.bb_l == a.x ? -Infinity : (node.bb_l - a.x)*idx); + var tx2 = (node.bb_r == a.x ? Infinity : (node.bb_r - a.x)*idx); + var txmin = min(tx1, tx2); + var txmax = max(tx1, tx2); + + var idy = 1/(b.y - a.y); + var ty1 = (node.bb_b == a.y ? -Infinity : (node.bb_b - a.y)*idy); + var ty2 = (node.bb_t == a.y ? Infinity : (node.bb_t - a.y)*idy); + var tymin = min(ty1, ty2); + var tymax = max(ty1, ty2); + + if(tymin <= txmax && txmin <= tymax){ + var min_ = max(txmin, tymin); + var max_ = min(txmax, tymax); + + if(0.0 <= max_ && min_ <= 1.0) return max(min_, 0.0); + } + + return Infinity; +}; + +var subtreeSegmentQuery = function(subtree, a, b, t_exit, func) +{ + if(subtree.isLeaf){ + return func(subtree.obj); + } else { + var t_a = nodeSegmentQuery(subtree.A, a, b); + var t_b = nodeSegmentQuery(subtree.B, a, b); + + if(t_a < t_b){ + if(t_a < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.A, a, b, t_exit, func)); + if(t_b < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.B, a, b, t_exit, func)); + } else { + if(t_b < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.B, a, b, t_exit, func)); + if(t_a < t_exit) t_exit = min(t_exit, subtreeSegmentQuery(subtree.A, a, b, t_exit, func)); + } + + return t_exit; + } +}; + +BBTree.prototype.subtreeRecycle = function(node) +{ + if(node.isLeaf){ + this.subtreeRecycle(node.A); + this.subtreeRecycle(node.B); + node.recycle(this); + } +}; + +var subtreeRemove = function(subtree, leaf, tree) +{ + if(leaf == subtree){ + return null; + } else { + var parent = leaf.parent; + if(parent == subtree){ + var other = subtree.otherChild(leaf); + other.parent = subtree.parent; + subtree.recycle(tree); + return other; + } else { + parent.parent.replaceChild(parent, parent.otherChild(leaf), tree); + return subtree; + } + } +}; // **** Marking Functions - /* - typedef struct MarkContext { - bbTree *tree; - Node *staticRoot; - cpSpatialIndexQueryFunc func; - } MarkContext; - */ - - var bbTreeIntersectsNode = function(a, b) - { - return (a.bb_l <= b.bb_r && b.bb_l <= a.bb_r && a.bb_b <= b.bb_t && b.bb_b <= a.bb_t); - }; - - var markLeafQuery = function(subtree, leaf, left, tree, func) - { - if(bbTreeIntersectsNode(leaf, subtree)){ - if(subtree.isLeaf){ - if(left){ - pairInsert(leaf, subtree, tree); - } else { - if(subtree.stamp < leaf.stamp) pairInsert(subtree, leaf, tree); - if(func) func(leaf.obj, subtree.obj); - } - } else { - markLeafQuery(subtree.A, leaf, left, tree, func); - markLeafQuery(subtree.B, leaf, left, tree, func); - } - } - }; - - var markLeaf = function(leaf, tree, staticRoot, func) - { - if(leaf.stamp == tree.getStamp()){ - if(staticRoot) markLeafQuery(staticRoot, leaf, false, tree, func); - - for(var node = leaf; node.parent; node = node.parent){ - if(node == node.parent.A){ - markLeafQuery(node.parent.B, leaf, true, tree, func); - } else { - markLeafQuery(node.parent.A, leaf, false, tree, func); - } - } - } else { - var pair = leaf.pairs; - while(pair){ - if(leaf == pair.b.leaf){ - if(func) func(pair.a.leaf.obj, leaf.obj); - pair = pair.b.next; - } else { - pair = pair.a.next; - } - } - } - }; - - var markSubtree = function(subtree, tree, staticRoot, func) - { - if(subtree.isLeaf){ - markLeaf(subtree, tree, staticRoot, func); - } else { - markSubtree(subtree.A, tree, staticRoot, func); - markSubtree(subtree.B, tree, staticRoot, func); - } - }; +/* +typedef struct MarkContext { + bbTree *tree; + Node *staticRoot; + cpSpatialIndexQueryFunc func; +} MarkContext; +*/ + +var bbTreeIntersectsNode = function(a, b) +{ + return (a.bb_l <= b.bb_r && b.bb_l <= a.bb_r && a.bb_b <= b.bb_t && b.bb_b <= a.bb_t); +}; + +Leaf.prototype.markLeafQuery = function(leaf, left, tree, func) +{ + if(bbTreeIntersectsNode(leaf, this)){ + if(left){ + pairInsert(leaf, this, tree); + } else { + if(this.stamp < leaf.stamp) pairInsert(this, leaf, tree); + if(func) func(leaf.obj, this.obj); + } + } +}; + +Node.prototype.markLeafQuery = function(leaf, left, tree, func) +{ + if(bbTreeIntersectsNode(leaf, this)){ + this.A.markLeafQuery(leaf, left, tree, func); + this.B.markLeafQuery(leaf, left, tree, func); + } +}; + +Leaf.prototype.markSubtree = function(tree, staticRoot, func) +{ + if(this.stamp == tree.getStamp()){ + if(staticRoot) staticRoot.markLeafQuery(this, false, tree, func); + + for(var node = this; node.parent; node = node.parent){ + if(node == node.parent.A){ + node.parent.B.markLeafQuery(this, true, tree, func); + } else { + node.parent.A.markLeafQuery(this, false, tree, func); + } + } + } else { + var pair = this.pairs; + while(pair){ + if(this === pair.leafB){ + if(func) func(pair.leafA.obj, this.obj); + pair = pair.nextB; + } else { + pair = pair.nextA; + } + } + } +}; + +Node.prototype.markSubtree = function(tree, staticRoot, func) +{ + this.A.markSubtree(tree, staticRoot, func); + this.B.markSubtree(tree, staticRoot, func); +}; // **** Leaf Functions - Leaf.prototype.containsObj = function(obj) - { - return (this.bb_l <= obj.bb_l && this.bb_r >= obj.bb_r && this.bb_b <= obj.bb_b && this.bb_t >= obj.bb_t); - }; - - Leaf.prototype.update = function(tree) - { - var root = tree.root; - var obj = this.obj; - - //if(!bbContainsBB(this.bb, bb)){ - if(!this.containsObj(obj)){ - tree.getBB(this.obj, this); - - root = subtreeRemove(root, this, tree); - tree.root = subtreeInsert(root, this, tree); - - this.clearPairs(tree); - this.stamp = tree.getStamp(); - - return true; - } - - return false; - }; - - Leaf.prototype.addPairs = function(tree) - { - var dynamicIndex = tree.dynamicIndex; - if(dynamicIndex){ - var dynamicRoot = dynamicIndex.root; - if(dynamicRoot){ - markLeafQuery(dynamicRoot, this, true, dynamicIndex, null); - } - } else { - var staticRoot = tree.staticIndex.root; - markLeaf(this, tree, staticRoot, null); - } - }; +Leaf.prototype.containsObj = function(obj) +{ + return (this.bb_l <= obj.bb_l && this.bb_r >= obj.bb_r && this.bb_b <= obj.bb_b && this.bb_t >= obj.bb_t); +}; + +Leaf.prototype.update = function(tree) +{ + var root = tree.root; + var obj = this.obj; + + //if(!bbContainsBB(this.bb, bb)){ + if(!this.containsObj(obj)){ + tree.getBB(this.obj, this); + + root = subtreeRemove(root, this, tree); + tree.root = subtreeInsert(root, this, tree); + + this.clearPairs(tree); + this.stamp = tree.getStamp(); + + return true; + } + + return false; +}; + +Leaf.prototype.addPairs = function(tree) +{ + var dynamicIndex = tree.dynamicIndex; + if(dynamicIndex){ + var dynamicRoot = dynamicIndex.root; + if(dynamicRoot){ + dynamicRoot.markLeafQuery(this, true, dynamicIndex, null); + } + } else { + var staticRoot = tree.staticIndex.root; + this.markSubtree(tree, staticRoot, null); + } +}; // **** Insert/Remove - BBTree.prototype.insert = function(obj, hashid) - { - var leaf = new Leaf(this, obj); - - this.leaves[hashid] = leaf; - this.root = subtreeInsert(this.root, leaf, this); - this.count++; +BBTree.prototype.insert = function(obj, hashid) +{ + var leaf = new Leaf(this, obj); - leaf.stamp = this.getStamp(); - leaf.addPairs(this); - this.incrementStamp(); - }; + this.leaves[hashid] = leaf; + this.root = subtreeInsert(this.root, leaf, this); + this.count++; + + leaf.stamp = this.getStamp(); + leaf.addPairs(this); + this.incrementStamp(); +}; - BBTree.prototype.remove = function(obj, hashid) - { - var leaf = this.leaves[hashid]; +BBTree.prototype.remove = function(obj, hashid) +{ + var leaf = this.leaves[hashid]; - delete this.leaves[hashid]; - this.root = subtreeRemove(this.root, leaf, this); - this.count--; + delete this.leaves[hashid]; + this.root = subtreeRemove(this.root, leaf, this); + this.count--; - leaf.clearPairs(this); - //NodeRecycle(tree, leaf); - }; + leaf.clearPairs(this); + leaf.recycle(this); +}; - BBTree.prototype.contains = function(obj, hashid) - { - return this.leaves[hashid] != null; - }; +BBTree.prototype.contains = function(obj, hashid) +{ + return this.leaves[hashid] != null; +}; // **** Reindex - var voidQueryFunc = function(obj1, obj2){}; - - BBTree.prototype.reindexQuery = function(func) - { - if(!this.root) return; - - // LeafUpdate() may modify this.root. Don't cache it. - var hashid, - leaves = this.leaves; - for (hashid in leaves) - { - leaves[hashid].update(this); - } - - var staticIndex = this.staticIndex; - var staticRoot = staticIndex && staticIndex.root; - - markSubtree(this.root, this, staticRoot, func); - if(staticIndex && !staticRoot) this.collideStatic(this, staticIndex, func); - - this.incrementStamp(); - }; - - BBTree.prototype.reindex = function() - { - this.reindexQuery(voidQueryFunc); - }; - - BBTree.prototype.reindexObject = function(obj, hashid) - { - var leaf = this.leaves[hashid]; - if(leaf){ - if(leaf.update(this)) leaf.addPairs(this); - this.incrementStamp(); - } - }; +var voidQueryFunc = function(obj1, obj2){}; + +BBTree.prototype.reindexQuery = function(func) +{ + if(!this.root) return; + + // LeafUpdate() may modify this.root. Don't cache it. + var hashid, + leaves = this.leaves; + for (hashid in leaves) + { + leaves[hashid].update(this); + } + + var staticIndex = this.staticIndex; + var staticRoot = staticIndex && staticIndex.root; + + this.root.markSubtree(this, staticRoot, func); + if(staticIndex && !staticRoot) this.collideStatic(this, staticIndex, func); + + this.incrementStamp(); +}; + +BBTree.prototype.reindex = function() +{ + this.reindexQuery(voidQueryFunc); +}; + +BBTree.prototype.reindexObject = function(obj, hashid) +{ + var leaf = this.leaves[hashid]; + if(leaf){ + if(leaf.update(this)) leaf.addPairs(this); + this.incrementStamp(); + } +}; // **** Query - BBTree.prototype.pointQuery = function(point, func) - { - // The base collision object is the provided point. - if(this.root) subtreeQuery(this.root, new BB(point.x, point.y, point.x, point.y), func); - }; +// This has since been removed from upstream Chipmunk - which recommends you just use query() below +// directly. +BBTree.prototype.pointQuery = function(point, func) +{ + this.query(new BB(point.x, point.y, point.x, point.y), func); +}; - BBTree.prototype.segmentQuery = function(a, b, t_exit, func) - { - if(this.root) subtreeSegmentQuery(this.root, a, b, t_exit, func); - }; +BBTree.prototype.segmentQuery = function(a, b, t_exit, func) +{ + if(this.root) subtreeSegmentQuery(this.root, a, b, t_exit, func); +}; - BBTree.prototype.query = function(bb, func) - { - if(this.root) subtreeQuery(this.root, bb, func); - }; +BBTree.prototype.query = function(bb, func) +{ + if(this.root) subtreeQuery(this.root, bb, func); +}; // **** Misc - BBTree.prototype.count = function() - { - return this.count; - }; +BBTree.prototype.count = function() +{ + return this.count; +}; - BBTree.prototype.each = function(func) - { - var hashid; - for(hashid in this.leaves) - { - func(this.leaves[hashid].obj); - } - }; +BBTree.prototype.each = function(func) +{ + var hashid; + for(hashid in this.leaves) + { + func(this.leaves[hashid].obj); + } +}; // **** Tree Optimization - var bbTreeMergedArea2 = function(node, l, b, r, t) - { - return (max(node.bb_r, r) - min(node.bb_l, l))*(max(node.bb_t, t) - min(node.bb_b, b)); - }; - - var partitionNodes = function(tree, nodes, offset, count) - { - if(count == 1){ - return nodes[offset]; - } else if(count == 2) { - return new Node(tree, nodes[offset], nodes[offset + 1]); - } - - // Find the AABB for these nodes - //var bb = nodes[offset].bb; - var node = nodes[offset]; - var bb_l = node.bb_l, - bb_b = node.bb_b, - bb_r = node.bb_r, - bb_t = node.bb_t; - - var end = offset + count; - for(var i=offset + 1; i bb_t - bb_b); - - // Sort the bounds and use the median as the splitting point - var bounds = new Array(count*2); - if(splitWidth){ - for(var i=offset; i bb_t - bb_b); + + // Sort the bounds and use the median as the splitting point + var bounds = new Array(count*2); + if(splitWidth){ + for(var i=offset; inext = next; - if(prev.body_a === body) { - prev.thread_a_next = next; - } else { - prev.thread_b_next = next; - } - } else { - body.arbiterList = next; - } - - if(next){ - // cpArbiterThreadForBody(next, body)->prev = prev; - if(next.body_a === body){ - next.thread_a_prev = prev; - } else { - next.thread_b_prev = prev; - } - } - }; - - Arbiter.prototype.unthread = function() - { - unthreadHelper(this, this.body_a, this.thread_a_prev, this.thread_a_next); - unthreadHelper(this, this.body_b, this.thread_b_prev, this.thread_b_next); - this.thread_a_prev = this.thread_a_next = null; - this.thread_b_prev = this.thread_b_next = null; - }; +Arbiter.prototype.getDepth = function(i) +{ + return this.contacts[i].dist; +}; + +/* +Arbiter.prototype.threadForBody = function(body) +{ + return (this.body_a === body ? this.thread_a : this.thread_b); +};*/ + +var unthreadHelper = function(arb, body, prev, next) +{ + // thread_x_y is quite ugly, but it avoids making unnecessary js objects per arbiter. + if(prev){ + // cpArbiterThreadForBody(prev, body)->next = next; + if(prev.body_a === body) { + prev.thread_a_next = next; + } else { + prev.thread_b_next = next; + } + } else { + body.arbiterList = next; + } + + if(next){ + // cpArbiterThreadForBody(next, body)->prev = prev; + if(next.body_a === body){ + next.thread_a_prev = prev; + } else { + next.thread_b_prev = prev; + } + } +}; + +Arbiter.prototype.unthread = function() +{ + unthreadHelper(this, this.body_a, this.thread_a_prev, this.thread_a_next); + unthreadHelper(this, this.body_b, this.thread_b_prev, this.thread_b_next); + this.thread_a_prev = this.thread_a_next = null; + this.thread_b_prev = this.thread_b_next = null; +}; //cpFloat //cpContactsEstimateCrushingImpulse(cpContact *contacts, int numContacts) @@ -2853,255 +3038,255 @@ // return (1 - vmag/fsum); //} - Arbiter.prototype.update = function(contacts, handler, a, b) - { - // Arbiters without contact data may exist if a collision function rejected the collision. - if(this.contacts){ - // Iterate over the possible pairs to look for hash value matches. - for(var i=0; i= mindist*mindist) return; - - var dist = Math.sqrt(distsq); - - // Allocate and initialize the contact. - return new Contact( - vadd(p1, vmult(delta, 0.5 + (r1 - 0.5*mindist)/(dist ? dist : Infinity))), - (dist ? vmult(delta, 1/dist) : new Vect(1, 0)), - dist - mindist, - 0 - ); - }; +var circle2circleQuery = function(p1, p2, r1, r2) +{ + var mindist = r1 + r2; + var delta = vsub(p2, p1); + var distsq = vlengthsq(delta); + if(distsq >= mindist*mindist) return; + + var dist = Math.sqrt(distsq); + + // Allocate and initialize the contact. + return new Contact( + vadd(p1, vmult(delta, 0.5 + (r1 - 0.5*mindist)/(dist ? dist : Infinity))), + (dist ? vmult(delta, 1/dist) : new Vect(1, 0)), + dist - mindist, + 0 + ); +}; // Collide circle shapes. - var circle2circle = function(circ1, circ2) - { - var contact = circle2circleQuery(circ1.tc, circ2.tc, circ1.r, circ2.r); - return contact ? [contact] : NONE; - }; - - var circle2segment = function(circleShape, segmentShape) - { - var seg_a = segmentShape.ta; - var seg_b = segmentShape.tb; - var center = circleShape.tc; - - var seg_delta = vsub(seg_b, seg_a); - var closest_t = clamp01(vdot(seg_delta, vsub(center, seg_a))/vlengthsq(seg_delta)); - var closest = vadd(seg_a, vmult(seg_delta, closest_t)); - - var contact = circle2circleQuery(center, closest, circleShape.r, segmentShape.r); - if(contact){ - var n = contact.n; - - // Reject endcap collisions if tangents are provided. - return ( - (closest_t === 0 && vdot(n, segmentShape.a_tangent) < 0) || - (closest_t === 1 && vdot(n, segmentShape.b_tangent) < 0) - ) ? NONE : [contact]; - } else { - return NONE; - } - } +var circle2circle = function(circ1, circ2) +{ + var contact = circle2circleQuery(circ1.tc, circ2.tc, circ1.r, circ2.r); + return contact ? [contact] : NONE; +}; + +var circle2segment = function(circleShape, segmentShape) +{ + var seg_a = segmentShape.ta; + var seg_b = segmentShape.tb; + var center = circleShape.tc; + + var seg_delta = vsub(seg_b, seg_a); + var closest_t = clamp01(vdot(seg_delta, vsub(center, seg_a))/vlengthsq(seg_delta)); + var closest = vadd(seg_a, vmult(seg_delta, closest_t)); + + var contact = circle2circleQuery(center, closest, circleShape.r, segmentShape.r); + if(contact){ + var n = contact.n; + + // Reject endcap collisions if tangents are provided. + return ( + (closest_t === 0 && vdot(n, segmentShape.a_tangent) < 0) || + (closest_t === 1 && vdot(n, segmentShape.b_tangent) < 0) + ) ? NONE : [contact]; + } else { + return NONE; + } +} // Find the minimum separating axis for the given poly and axis list. // @@ -3110,246 +3295,246 @@ // is the fastest implementation. // // See: http://jsperf.com/return-two-values-from-function/2 - var last_MSA_min = 0; - var findMSA = function(poly, axes) - { - var min_index = 0; - var min = poly.valueOnAxis(axes[0].n, axes[0].d); - if(min > 0) return -1; - - for(var i=1; i 0) { - return -1; - } else if(dist > min){ - min = dist; - min_index = i; - } - } - - last_MSA_min = min; - return min_index; - }; +var last_MSA_min = 0; +var findMSA = function(poly, planes) +{ + var min_index = 0; + var min = poly.valueOnAxis(planes[0].n, planes[0].d); + if(min > 0) return -1; + + for(var i=1; i 0) { + return -1; + } else if(dist > min){ + min = dist; + min_index = i; + } + } + + last_MSA_min = min; + return min_index; +}; // Add contacts for probably penetrating vertexes. // This handles the degenerate case where an overlap was detected, but no vertexes fall inside // the opposing polygon. (like a star of david) - var findVertsFallback = function(poly1, poly2, n, dist) - { - var arr = []; - - var verts1 = poly1.tVerts; - for(var i=0; i>1))); - } - } - - var verts2 = poly2.tVerts; - for(var i=0; i>1))); - } - } - - return (arr.length ? arr : findVertsFallback(poly1, poly2, n, dist)); - }; +var findVerts = function(poly1, poly2, n, dist) +{ + var arr = []; + + var verts1 = poly1.tVerts; + for(var i=0; i>1))); + } + } + + var verts2 = poly2.tVerts; + for(var i=0; i>1))); + } + } + + return (arr.length ? arr : findVertsFallback(poly1, poly2, n, dist)); +}; // Collide poly shapes together. - var poly2poly = function(poly1, poly2) - { - var mini1 = findMSA(poly2, poly1.tAxes); - if(mini1 == -1) return NONE; - var min1 = last_MSA_min; - - var mini2 = findMSA(poly1, poly2.tAxes); - if(mini2 == -1) return NONE; - var min2 = last_MSA_min; - - // There is overlap, find the penetrating verts - if(min1 > min2) - return findVerts(poly1, poly2, poly1.tAxes[mini1].n, min1); - else - return findVerts(poly1, poly2, vneg(poly2.tAxes[mini2].n), min2); - }; +var poly2poly = function(poly1, poly2) +{ + var mini1 = findMSA(poly2, poly1.tPlanes); + if(mini1 == -1) return NONE; + var min1 = last_MSA_min; + + var mini2 = findMSA(poly1, poly2.tPlanes); + if(mini2 == -1) return NONE; + var min2 = last_MSA_min; + + // There is overlap, find the penetrating verts + if(min1 > min2) + return findVerts(poly1, poly2, poly1.tPlanes[mini1].n, min1); + else + return findVerts(poly1, poly2, vneg(poly2.tPlanes[mini2].n), min2); +}; // Like cpPolyValueOnAxis(), but for segments. - var segValueOnAxis = function(seg, n, d) - { - var a = vdot(n, seg.ta) - seg.r; - var b = vdot(n, seg.tb) - seg.r; - return min(a, b) - d; - }; +var segValueOnAxis = function(seg, n, d) +{ + var a = vdot(n, seg.ta) - seg.r; + var b = vdot(n, seg.tb) - seg.r; + return min(a, b) - d; +}; // Identify vertexes that have penetrated the segment. - var findPointsBehindSeg = function(arr, seg, poly, pDist, coef) - { - var dta = vcross(seg.tn, seg.ta); - var dtb = vcross(seg.tn, seg.tb); - var n = vmult(seg.tn, coef); - - var verts = poly.tVerts; - for(var i=0; i= dt && dt >= dtb){ - arr.push(new Contact(new Vect(vx, vy), n, pDist, hashPair(poly.hashid, i))); - } - } - } - }; +var findPointsBehindSeg = function(arr, seg, poly, pDist, coef) +{ + var dta = vcross(seg.tn, seg.ta); + var dtb = vcross(seg.tn, seg.tb); + var n = vmult(seg.tn, coef); + + var verts = poly.tVerts; + for(var i=0; i= dt && dt >= dtb){ + arr.push(new Contact(new Vect(vx, vy), n, pDist, hashPair(poly.hashid, i))); + } + } + } +}; // This one is complicated and gross. Just don't go there... // TODO: Comment me! - var seg2poly = function(seg, poly) - { - var arr = []; - - var axes = poly.tAxes; - var numVerts = axes.length; - - var segD = vdot(seg.tn, seg.ta); - var minNorm = poly.valueOnAxis(seg.tn, segD) - seg.r; - var minNeg = poly.valueOnAxis(vneg(seg.tn), -segD) - seg.r; - if(minNeg > 0 || minNorm > 0) return NONE; - - var mini = 0; - var poly_min = segValueOnAxis(seg, axes[0].n, axes[0].d); - if(poly_min > 0) return NONE; - for(var i=0; i 0){ - return NONE; - } else if(dist > poly_min){ - poly_min = dist; - mini = i; - } - } - - var poly_n = vneg(axes[mini].n); - - var va = vadd(seg.ta, vmult(poly_n, seg.r)); - var vb = vadd(seg.tb, vmult(poly_n, seg.r)); - if(poly.containsVert(va.x, va.y)) - arr.push(new Contact(va, poly_n, poly_min, hashPair(seg.hashid, 0))); - if(poly.containsVert(vb.x, vb.y)) - arr.push(new Contact(vb, poly_n, poly_min, hashPair(seg.hashid, 1))); - - // Floating point precision problems here. - // This will have to do for now. +var seg2poly = function(seg, poly) +{ + var arr = []; + + var planes = poly.tPlanes; + var numVerts = planes.length; + + var segD = vdot(seg.tn, seg.ta); + var minNorm = poly.valueOnAxis(seg.tn, segD) - seg.r; + var minNeg = poly.valueOnAxis(vneg(seg.tn), -segD) - seg.r; + if(minNeg > 0 || minNorm > 0) return NONE; + + var mini = 0; + var poly_min = segValueOnAxis(seg, planes[0].n, planes[0].d); + if(poly_min > 0) return NONE; + for(var i=0; i 0){ + return NONE; + } else if(dist > poly_min){ + poly_min = dist; + mini = i; + } + } + + var poly_n = vneg(planes[mini].n); + + var va = vadd(seg.ta, vmult(poly_n, seg.r)); + var vb = vadd(seg.tb, vmult(poly_n, seg.r)); + if(poly.containsVert(va.x, va.y)) + arr.push(new Contact(va, poly_n, poly_min, hashPair(seg.hashid, 0))); + if(poly.containsVert(vb.x, vb.y)) + arr.push(new Contact(vb, poly_n, poly_min, hashPair(seg.hashid, 1))); + + // Floating point precision problems here. + // This will have to do for now. // poly_min -= cp_collision_slop; // TODO is this needed anymore? - - if(minNorm >= poly_min || minNeg >= poly_min) { - if(minNorm > minNeg) - findPointsBehindSeg(arr, seg, poly, minNorm, 1); - else - findPointsBehindSeg(arr, seg, poly, minNeg, -1); - } - - // If no other collision points are found, try colliding endpoints. - if(arr.length === 0){ - var mini2 = mini * 2; - var verts = poly.tVerts; - - var poly_a = new Vect(verts[mini2], verts[mini2+1]); - - var con; - if((con = circle2circleQuery(seg.ta, poly_a, seg.r, 0, arr))) return [con]; - if((con = circle2circleQuery(seg.tb, poly_a, seg.r, 0, arr))) return [con]; - - var len = numVerts * 2; - var poly_b = new Vect(verts[(mini2+2)%len], verts[(mini2+3)%len]); - if((con = circle2circleQuery(seg.ta, poly_b, seg.r, 0, arr))) return [con]; - if((con = circle2circleQuery(seg.tb, poly_b, seg.r, 0, arr))) return [con]; - } - -// console.log(poly.tVerts, poly.tAxes); + + if(minNorm >= poly_min || minNeg >= poly_min) { + if(minNorm > minNeg) + findPointsBehindSeg(arr, seg, poly, minNorm, 1); + else + findPointsBehindSeg(arr, seg, poly, minNeg, -1); + } + + // If no other collision points are found, try colliding endpoints. + if(arr.length === 0){ + var mini2 = mini * 2; + var verts = poly.tVerts; + + var poly_a = new Vect(verts[mini2], verts[mini2+1]); + + var con; + if((con = circle2circleQuery(seg.ta, poly_a, seg.r, 0, arr))) return [con]; + if((con = circle2circleQuery(seg.tb, poly_a, seg.r, 0, arr))) return [con]; + + var len = numVerts * 2; + var poly_b = new Vect(verts[(mini2+2)%len], verts[(mini2+3)%len]); + if((con = circle2circleQuery(seg.ta, poly_b, seg.r, 0, arr))) return [con]; + if((con = circle2circleQuery(seg.tb, poly_b, seg.r, 0, arr))) return [con]; + } + +// console.log(poly.tVerts, poly.tPlanes); // console.log('seg2poly', arr); - return arr; - }; + return arr; +}; // This one is less gross, but still gross. // TODO: Comment me! - var circle2poly = function(circ, poly) - { - var axes = poly.tAxes; - - var mini = 0; - var min = vdot(axes[0].n, circ.tc) - axes[0].d - circ.r; - for(var i=0; i 0){ - return NONE; - } else if(dist > min) { - min = dist; - mini = i; - } - } - - var n = axes[mini].n; - - var verts = poly.tVerts; - var len = verts.length; - var mini2 = mini<<1; - - //var a = poly.tVerts[mini]; - //var b = poly.tVerts[(mini + 1)%poly.tVerts.length]; - var ax = verts[mini2]; - var ay = verts[mini2+1]; - var bx = verts[(mini2+2)%len]; - var by = verts[(mini2+3)%len]; - - var dta = vcross2(n.x, n.y, ax, ay); - var dtb = vcross2(n.x, n.y, bx, by); - var dt = vcross(n, circ.tc); - - if(dt < dtb){ - var con = circle2circleQuery(circ.tc, new Vect(bx, by), circ.r, 0, con); - return con ? [con] : NONE; - } else if(dt < dta) { - return [new Contact( - vsub(circ.tc, vmult(n, circ.r + min/2)), - vneg(n), - min, - 0 - )]; - } else { - var con = circle2circleQuery(circ.tc, new Vect(ax, ay), circ.r, 0, con); - return con ? [con] : NONE; - } - }; +var circle2poly = function(circ, poly) +{ + var planes = poly.tPlanes; + + var mini = 0; + var min = vdot(planes[0].n, circ.tc) - planes[0].d - circ.r; + for(var i=0; i 0){ + return NONE; + } else if(dist > min) { + min = dist; + mini = i; + } + } + + var n = planes[mini].n; + + var verts = poly.tVerts; + var len = verts.length; + var mini2 = mini<<1; + + //var a = poly.tVerts[mini]; + //var b = poly.tVerts[(mini + 1)%poly.tVerts.length]; + var ax = verts[mini2]; + var ay = verts[mini2+1]; + var bx = verts[(mini2+2)%len]; + var by = verts[(mini2+3)%len]; + + var dta = vcross2(n.x, n.y, ax, ay); + var dtb = vcross2(n.x, n.y, bx, by); + var dt = vcross(n, circ.tc); + + if(dt < dtb){ + var con = circle2circleQuery(circ.tc, new Vect(bx, by), circ.r, 0, con); + return con ? [con] : NONE; + } else if(dt < dta) { + return [new Contact( + vsub(circ.tc, vmult(n, circ.r + min/2)), + vneg(n), + min, + 0 + )]; + } else { + var con = circle2circleQuery(circ.tc, new Vect(ax, ay), circ.r, 0, con); + return con ? [con] : NONE; + } +}; // The javascripty way to do this would be either nested object or methods on the prototypes. // @@ -3357,1407 +3542,1451 @@ // See: http://jsperf.com/dispatch // These are copied from the prototypes into the actual objects in the Shape constructor. - CircleShape.prototype.collisionCode = 0; - SegmentShape.prototype.collisionCode = 1; - PolyShape.prototype.collisionCode = 2; - - CircleShape.prototype.collisionTable = [ - circle2circle, - circle2segment, - circle2poly - ]; - - SegmentShape.prototype.collisionTable = [ - null, - function(seg, seg2) { return NONE; }, // seg2seg - seg2poly - ]; - - PolyShape.prototype.collisionTable = [ - null, - null, - poly2poly - ]; - - var collideShapes = cp.collideShapes = function(a, b) - { - assert(a.collisionCode <= b.collisionCode, 'Collided shapes must be sorted by type'); - return a.collisionTable[b.collisionCode](a, b); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var defaultCollisionHandler = new CollisionHandler(); +CircleShape.prototype.collisionCode = 0; +SegmentShape.prototype.collisionCode = 1; +PolyShape.prototype.collisionCode = 2; + +CircleShape.prototype.collisionTable = [ + circle2circle, + circle2segment, + circle2poly +]; + +SegmentShape.prototype.collisionTable = [ + null, + function(segA, segB) { return NONE; }, // seg2seg + seg2poly +]; + +PolyShape.prototype.collisionTable = [ + null, + null, + poly2poly +]; + +var collideShapes = cp.collideShapes = function(a, b) +{ + assert(a.collisionCode <= b.collisionCode, 'Collided shapes must be sorted by type'); + return a.collisionTable[b.collisionCode](a, b); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var defaultCollisionHandler = new CollisionHandler(); /// Basic Unit of Simulation in Chipmunk - var Space = cp.Space = function() { - this.stamp = 0; - this.curr_dt = 0; - - this.bodies = []; - this.rousedBodies = []; - this.sleepingComponents = []; - - this.staticShapes = new BBTree(null); - this.activeShapes = new BBTree(this.staticShapes); - - this.arbiters = []; - this.contactBuffersHead = null; - this.cachedArbiters = {}; - //this.pooledArbiters = []; - - this.constraints = []; - - this.locked = 0; - - this.collisionHandlers = {}; - this.defaultHandler = defaultCollisionHandler; - - this.postStepCallbacks = []; - - /// Number of iterations to use in the impulse solver to solve contacts. - this.iterations = 10; - - /// Gravity to pass to rigid bodies when integrating velocity. - this.gravity = vzero; - - /// Damping rate expressed as the fraction of velocity bodies retain each second. - /// A value of 0.9 would mean that each body's velocity will drop 10% per second. - /// The default value is 1.0, meaning no damping is applied. - /// @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring. - this.damping = 1; - - /// Speed threshold for a body to be considered idle. - /// The default value of 0 means to let the space guess a good threshold based on gravity. - this.idleSpeedThreshold = 0; - - /// Time a group of bodies must remain idle in order to fall asleep. - /// Enabling sleeping also implicitly enables the the contact graph. - /// The default value of Infinity disables the sleeping algorithm. - this.sleepTimeThreshold = Infinity; - - /// Amount of encouraged penetration between colliding shapes.. - /// Used to reduce oscillating contacts and keep the collision cache warm. - /// Defaults to 0.1. If you have poor simulation quality, - /// increase this number as much as possible without allowing visible amounts of overlap. - this.collisionSlop = 0.1; - - /// Determines how fast overlapping shapes are pushed apart. - /// Expressed as a fraction of the error remaining after each second. - /// Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz. - this.collisionBias = Math.pow(1 - 0.1, 60); - - /// Number of frames that contact information should persist. - /// Defaults to 3. There is probably never a reason to change this value. - this.collisionPersistence = 3; - - /// Rebuild the contact graph during each step. Must be enabled to use the cpBodyEachArbiter() function. - /// Disabled by default for a small performance boost. Enabled implicitly when the sleeping feature is enabled. - this.enableContactGraph = false; - - /// The designated static body for this space. - /// You can modify this body, or replace it with your own static body. - /// By default it points to a statically allocated cpBody in the cpSpace struct. - this.staticBody = new Body(Infinity, Infinity); - this.staticBody.nodeIdleTime = Infinity; - - // Cache the collideShapes callback function for the space. - this.collideShapes = this.makeCollideShapes(); - }; - - Space.prototype.getCurrentTimeStep = function() { return this.curr_dt; }; +var Space = cp.Space = function() { + this.stamp = 0; + this.curr_dt = 0; + + this.bodies = []; + this.rousedBodies = []; + this.sleepingComponents = []; + + this.staticShapes = new BBTree(null); + this.activeShapes = new BBTree(this.staticShapes); + + this.arbiters = []; + this.contactBuffersHead = null; + this.cachedArbiters = {}; + //this.pooledArbiters = []; + + this.constraints = []; + + this.locked = 0; + + this.collisionHandlers = {}; + this.defaultHandler = defaultCollisionHandler; + + this.postStepCallbacks = []; + + /// Number of iterations to use in the impulse solver to solve contacts. + this.iterations = 10; + + /// Gravity to pass to rigid bodies when integrating velocity. + this.gravity = vzero; + + /// Damping rate expressed as the fraction of velocity bodies retain each second. + /// A value of 0.9 would mean that each body's velocity will drop 10% per second. + /// The default value is 1.0, meaning no damping is applied. + /// @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring. + this.damping = 1; + + /// Speed threshold for a body to be considered idle. + /// The default value of 0 means to let the space guess a good threshold based on gravity. + this.idleSpeedThreshold = 0; + + /// Time a group of bodies must remain idle in order to fall asleep. + /// Enabling sleeping also implicitly enables the the contact graph. + /// The default value of Infinity disables the sleeping algorithm. + this.sleepTimeThreshold = Infinity; + + /// Amount of encouraged penetration between colliding shapes.. + /// Used to reduce oscillating contacts and keep the collision cache warm. + /// Defaults to 0.1. If you have poor simulation quality, + /// increase this number as much as possible without allowing visible amounts of overlap. + this.collisionSlop = 0.1; + + /// Determines how fast overlapping shapes are pushed apart. + /// Expressed as a fraction of the error remaining after each second. + /// Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz. + this.collisionBias = Math.pow(1 - 0.1, 60); + + /// Number of frames that contact information should persist. + /// Defaults to 3. There is probably never a reason to change this value. + this.collisionPersistence = 3; + + /// Rebuild the contact graph during each step. Must be enabled to use the cpBodyEachArbiter() function. + /// Disabled by default for a small performance boost. Enabled implicitly when the sleeping feature is enabled. + this.enableContactGraph = false; + + /// The designated static body for this space. + /// You can modify this body, or replace it with your own static body. + /// By default it points to a statically allocated cpBody in the cpSpace struct. + this.staticBody = new Body(Infinity, Infinity); + this.staticBody.nodeIdleTime = Infinity; + + // Cache the collideShapes callback function for the space. + this.collideShapes = this.makeCollideShapes(); +}; + +Space.prototype.getCurrentTimeStep = function() { return this.curr_dt; }; + +Space.prototype.setIterations = function(iter) { this.iterations = iter; }; /// returns true from inside a callback and objects cannot be added/removed. - Space.prototype.isLocked = function() - { - return this.locked; - }; - - var assertSpaceUnlocked = function(space) - { - assert(!space.locked, "This addition/removal cannot be done safely during a call to cpSpaceStep() \ +Space.prototype.isLocked = function() +{ + return this.locked; +}; + +var assertSpaceUnlocked = function(space) +{ + assert(!space.locked, "This addition/removal cannot be done safely during a call to cpSpaceStep() \ or during a query. Put these calls into a post-step callback."); - }; +}; // **** Collision handler function management /// Set a collision handler to be used whenever the two shapes with the given collision types collide. /// You can pass null for any function you don't want to implement. - Space.prototype.addCollisionHandler = function(a, b, begin, preSolve, postSolve, separate) - { - assertSpaceUnlocked(this); - - // Remove any old function so the new one will get added. - this.removeCollisionHandler(a, b); - - var handler = new CollisionHandler(); - handler.a = a; - handler.b = b; - if(begin) handler.begin = begin; - if(preSolve) handler.preSolve = preSolve; - if(postSolve) handler.postSolve = postSolve; - if(separate) handler.separate = separate; - - this.collisionHandlers[hashPair(a, b)] = handler; - }; +Space.prototype.addCollisionHandler = function(a, b, begin, preSolve, postSolve, separate) +{ + assertSpaceUnlocked(this); + + // Remove any old function so the new one will get added. + this.removeCollisionHandler(a, b); + + var handler = new CollisionHandler(); + handler.a = a; + handler.b = b; + if(begin) handler.begin = begin; + if(preSolve) handler.preSolve = preSolve; + if(postSolve) handler.postSolve = postSolve; + if(separate) handler.separate = separate; + + this.collisionHandlers[hashPair(a, b)] = handler; +}; /// Unset a collision handler. - Space.prototype.removeCollisionHandler = function(a, b) - { - assertSpaceUnlocked(this); - - delete this.collisionHandlers[hashPair(a, b)]; - }; +Space.prototype.removeCollisionHandler = function(a, b) +{ + assertSpaceUnlocked(this); + + delete this.collisionHandlers[hashPair(a, b)]; +}; /// Set a default collision handler for this space. /// The default collision handler is invoked for each colliding pair of shapes /// that isn't explicitly handled by a specific collision handler. /// You can pass null for any function you don't want to implement. - Space.prototype.setDefaultCollisionHandler = function(begin, preSolve, postSolve, separate) - { - assertSpaceUnlocked(this); +Space.prototype.setDefaultCollisionHandler = function(begin, preSolve, postSolve, separate) +{ + assertSpaceUnlocked(this); - var handler = new CollisionHandler(); - if(begin) handler.begin = begin; - if(preSolve) handler.preSolve = preSolve; - if(postSolve) handler.postSolve = postSolve; - if(separate) handler.separate = separate; + var handler = new CollisionHandler(); + if(begin) handler.begin = begin; + if(preSolve) handler.preSolve = preSolve; + if(postSolve) handler.postSolve = postSolve; + if(separate) handler.separate = separate; - this.defaultHandler = handler; - }; + this.defaultHandler = handler; +}; - Space.prototype.lookupHandler = function(a, b) - { - return this.collisionHandlers[hashPair(a, b)] || this.defaultHandler; - }; +Space.prototype.lookupHandler = function(a, b) +{ + return this.collisionHandlers[hashPair(a, b)] || this.defaultHandler; +}; // **** Body, Shape, and Joint Management /// Add a collision shape to the simulation. /// If the shape is attached to a static body, it will be added as a static shape. - Space.prototype.addShape = function(shape) - { - var body = shape.body; - if(body.isStatic()) return this.addStaticShape(shape); - - assert(!shape.space, "This shape is already added to a space and cannot be added to another."); - assertSpaceUnlocked(this); - - body.activate(); - body.addShape(shape); - - shape.update(body.p, body.rot); - this.activeShapes.insert(shape, shape.hashid); - shape.space = this; - - return shape; - }; +Space.prototype.addShape = function(shape) +{ + var body = shape.body; + if(body.isStatic()) return this.addStaticShape(shape); + + assert(!shape.space, "This shape is already added to a space and cannot be added to another."); + assertSpaceUnlocked(this); + + body.activate(); + body.addShape(shape); + + shape.update(body.p, body.rot); + this.activeShapes.insert(shape, shape.hashid); + shape.space = this; + + return shape; +}; /// Explicity add a shape as a static shape to the simulation. - Space.prototype.addStaticShape = function(shape) - { - assert(!shape.space, "This shape is already added to a space and cannot be added to another."); - assertSpaceUnlocked(this); - - var body = shape.body; - body.addShape(shape); - - shape.update(body.p, body.rot); - this.staticShapes.insert(shape, shape.hashid); - shape.space = this; - - return shape; - }; +Space.prototype.addStaticShape = function(shape) +{ + assert(!shape.space, "This shape is already added to a space and cannot be added to another."); + assertSpaceUnlocked(this); + + var body = shape.body; + body.addShape(shape); + + shape.update(body.p, body.rot); + this.staticShapes.insert(shape, shape.hashid); + shape.space = this; + + return shape; +}; /// Add a rigid body to the simulation. - Space.prototype.addBody = function(body) - { - assert(!body.isStatic(), "Static bodies cannot be added to a space as they are not meant to be simulated."); - assert(!body.space, "This body is already added to a space and cannot be added to another."); - assertSpaceUnlocked(this); - - this.bodies.push(body); - body.space = this; - - return body; - }; +Space.prototype.addBody = function(body) +{ + assert(!body.isStatic(), "Static bodies cannot be added to a space as they are not meant to be simulated."); + assert(!body.space, "This body is already added to a space and cannot be added to another."); + assertSpaceUnlocked(this); + + this.bodies.push(body); + body.space = this; + + return body; +}; /// Add a constraint to the simulation. - Space.prototype.addConstraint = function(constraint) - { - assert(!constraint.space, "This shape is already added to a space and cannot be added to another."); - assertSpaceUnlocked(this); - - var a = constraint.a, b = constraint.b; - - a.activate(); - b.activate(); - this.constraints.push(constraint); - - // Push onto the heads of the bodies' constraint lists - constraint.next_a = a.constraintList; a.constraintList = constraint; - constraint.next_b = b.constraintList; b.constraintList = constraint; - constraint.space = this; - - return constraint; - }; - - Space.prototype.filterArbiters = function(body, filter) - { - for (var hash in this.cachedArbiters) - { - var arb = this.cachedArbiters[hash]; - - // Match on the filter shape, or if it's null the filter body - if( - (body === arb.body_a && (filter === arb.a || filter === null)) || - (body === arb.body_b && (filter === arb.b || filter === null)) - ){ - // Call separate when removing shapes. - if(filter && arb.state !== 'cached') arb.callSeparate(this); - - arb.unthread(); - - deleteObjFromList(this.arbiters, arb); - //this.pooledArbiters.push(arb); - - delete this.cachedArbiters[hash]; - } - } - }; +Space.prototype.addConstraint = function(constraint) +{ + assert(!constraint.space, "This shape is already added to a space and cannot be added to another."); + assertSpaceUnlocked(this); + + var a = constraint.a, b = constraint.b; + + a.activate(); + b.activate(); + this.constraints.push(constraint); + + // Push onto the heads of the bodies' constraint lists + constraint.next_a = a.constraintList; a.constraintList = constraint; + constraint.next_b = b.constraintList; b.constraintList = constraint; + constraint.space = this; + + return constraint; +}; + +Space.prototype.filterArbiters = function(body, filter) +{ + for (var hash in this.cachedArbiters) + { + var arb = this.cachedArbiters[hash]; + + // Match on the filter shape, or if it's null the filter body + if( + (body === arb.body_a && (filter === arb.a || filter === null)) || + (body === arb.body_b && (filter === arb.b || filter === null)) + ){ + // Call separate when removing shapes. + if(filter && arb.state !== 'cached') arb.callSeparate(this); + + arb.unthread(); + + deleteObjFromList(this.arbiters, arb); + //this.pooledArbiters.push(arb); + + delete this.cachedArbiters[hash]; + } + } +}; /// Remove a collision shape from the simulation. - Space.prototype.removeShape = function(shape) - { - var body = shape.body; - if(body.isStatic()){ - this.removeStaticShape(shape); - } else { - assert(this.containsShape(shape), - "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); - assertSpaceUnlocked(this); - - body.activate(); - body.removeShape(shape); - this.filterArbiters(body, shape); - this.activeShapes.remove(shape, shape.hashid); - shape.space = null; - } - }; +Space.prototype.removeShape = function(shape) +{ + var body = shape.body; + if(body.isStatic()){ + this.removeStaticShape(shape); + } else { + assert(this.containsShape(shape), + "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); + assertSpaceUnlocked(this); + + body.activate(); + body.removeShape(shape); + this.filterArbiters(body, shape); + this.activeShapes.remove(shape, shape.hashid); + shape.space = null; + } +}; /// Remove a collision shape added using addStaticShape() from the simulation. - Space.prototype.removeStaticShape = function(shape) - { - assert(this.containsShape(shape), - "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"); - assertSpaceUnlocked(this); - - var body = shape.body; - if(body.isStatic()) body.activateStatic(shape); - body.removeShape(shape); - this.filterArbiters(body, shape); - this.staticShapes.remove(shape, shape.hashid); - shape.space = null; - }; +Space.prototype.removeStaticShape = function(shape) +{ + assert(this.containsShape(shape), + "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"); + assertSpaceUnlocked(this); + + var body = shape.body; + if(body.isStatic()) body.activateStatic(shape); + body.removeShape(shape); + this.filterArbiters(body, shape); + this.staticShapes.remove(shape, shape.hashid); + shape.space = null; +}; /// Remove a rigid body from the simulation. - Space.prototype.removeBody = function(body) - { - assert(this.containsBody(body), - "Cannot remove a body that was not added to the space. (Removed twice maybe?)"); - assertSpaceUnlocked(this); - - body.activate(); +Space.prototype.removeBody = function(body) +{ + assert(this.containsBody(body), + "Cannot remove a body that was not added to the space. (Removed twice maybe?)"); + assertSpaceUnlocked(this); + + body.activate(); // this.filterArbiters(body, null); - deleteObjFromList(this.bodies, body); - body.space = null; - }; + deleteObjFromList(this.bodies, body); + body.space = null; +}; /// Remove a constraint from the simulation. - Space.prototype.removeConstraint = function(constraint) - { - assert(this.containsConstraint(constraint), - "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"); - assertSpaceUnlocked(this); - - constraint.a.activate(); - constraint.b.activate(); - deleteObjFromList(this.constraints, constraint); - - constraint.a.removeConstraint(constraint); - constraint.b.removeConstraint(constraint); - constraint.space = null; - }; +Space.prototype.removeConstraint = function(constraint) +{ + assert(this.containsConstraint(constraint), + "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"); + assertSpaceUnlocked(this); + + constraint.a.activate(); + constraint.b.activate(); + deleteObjFromList(this.constraints, constraint); + + constraint.a.removeConstraint(constraint); + constraint.b.removeConstraint(constraint); + constraint.space = null; +}; /// Test if a collision shape has been added to the space. - Space.prototype.containsShape = function(shape) - { - return (shape.space === this); - }; +Space.prototype.containsShape = function(shape) +{ + return (shape.space === this); +}; /// Test if a rigid body has been added to the space. - Space.prototype.containsBody = function(body) - { - return (body.space == this); - }; +Space.prototype.containsBody = function(body) +{ + return (body.space == this); +}; /// Test if a constraint has been added to the space. - Space.prototype.containsConstraint = function(constraint) - { - return (constraint.space == this); - }; +Space.prototype.containsConstraint = function(constraint) +{ + return (constraint.space == this); +}; - Space.prototype.uncacheArbiter = function(arb) - { - delete this.cachedArbiters[hashPair(arb.a.hashid, arb.b.hashid)]; - deleteObjFromList(this.arbiters, arb); - }; +Space.prototype.uncacheArbiter = function(arb) +{ + delete this.cachedArbiters[hashPair(arb.a.hashid, arb.b.hashid)]; + deleteObjFromList(this.arbiters, arb); +}; // **** Iteration /// Call @c func for each body in the space. - Space.prototype.eachBody = function(func) - { - this.lock(); { - var bodies = this.bodies; - - for(var i=0; i keThreshold ? 0 : body.nodeIdleTime + dt); - } - } - - // Awaken any sleeping bodies found and then push arbiters to the bodies' lists. - var arbiters = this.arbiters; - for(var i=0, count=arbiters.length; i keThreshold ? 0 : body.nodeIdleTime + dt); + } + } + + // Awaken any sleeping bodies found and then push arbiters to the bodies' lists. + var arbiters = this.arbiters; + for(var i=0, count=arbiters.length; i= 0, "Internal Error: Space lock underflow."); +Space.prototype.unlock = function(runPostStep) +{ + this.locked--; + assert(this.locked >= 0, "Internal Error: Space lock underflow."); - if(!this.locked && runPostStep){ - var waking = this.rousedBodies; - for(var i=0; i this.collisionPersistence){ - // The tail buffer is available, rotate the ring - var tail = head.next; - tail.stamp = stamp; - tail.contacts.length = 0; - this.contactBuffersHead = tail; - } else { - // Allocate a new buffer and push it into the ring - var buffer = new ContactBuffer(stamp, head); - this.contactBuffersHead = head.next = buffer; - } - }; - - cpContact * - cpContactBufferGetArray(cpSpace *space) - { - if(space.contactBuffersHead.numContacts + CP_MAX_CONTACTS_PER_ARBITER > CP_CONTACTS_BUFFER_SIZE){ - // contact buffer could overflow on the next collision, push a fresh one. - space.pushFreshContactBuffer(); - } - - cpContactBufferHeader *head = space.contactBuffersHead; - return ((cpContactBuffer *)head)->contacts + head.numContacts; - } - - void - cpSpacePushContacts(cpSpace *space, int count) - { - cpAssertHard(count <= CP_MAX_CONTACTS_PER_ARBITER, "Internal Error: Contact buffer overflow!"); - space.contactBuffersHead.numContacts += count; - } - - static void - cpSpacePopContacts(cpSpace *space, int count){ - space.contactBuffersHead.numContacts -= count; - } - */ +/* josephg: + * + * This code might be faster in JS than just allocating objects each time - I'm + * really not sure. If the contact buffer solution is used, there will also + * need to be changes in cpCollision.js to fill a passed array instead of creating + * new arrays each time. + * + * TODO: Benchmark me once chipmunk is working. + */ + +/* +var ContactBuffer = function(stamp, splice) +{ + this.stamp = stamp; + // Contact buffers are a circular linked list. + this.next = splice ? splice.next : this; + this.contacts = []; +}; + +Space.prototype.pushFreshContactBuffer = function() +{ + var stamp = this.stamp; + + var head = this.contactBuffersHead; + + if(!head){ + // No buffers have been allocated, make one + this.contactBuffersHead = new ContactBuffer(stamp, null); + } else if(stamp - head.next.stamp > this.collisionPersistence){ + // The tail buffer is available, rotate the ring + var tail = head.next; + tail.stamp = stamp; + tail.contacts.length = 0; + this.contactBuffersHead = tail; + } else { + // Allocate a new buffer and push it into the ring + var buffer = new ContactBuffer(stamp, head); + this.contactBuffersHead = head.next = buffer; + } +}; + +cpContact * +cpContactBufferGetArray(cpSpace *space) +{ + if(space.contactBuffersHead.numContacts + CP_MAX_CONTACTS_PER_ARBITER > CP_CONTACTS_BUFFER_SIZE){ + // contact buffer could overflow on the next collision, push a fresh one. + space.pushFreshContactBuffer(); + } + + cpContactBufferHeader *head = space.contactBuffersHead; + return ((cpContactBuffer *)head)->contacts + head.numContacts; +} + +void +cpSpacePushContacts(cpSpace *space, int count) +{ + cpAssertHard(count <= CP_MAX_CONTACTS_PER_ARBITER, "Internal Error: Contact buffer overflow!"); + space.contactBuffersHead.numContacts += count; +} + +static void +cpSpacePopContacts(cpSpace *space, int count){ + space.contactBuffersHead.numContacts -= count; +} +*/ // **** Collision Detection Functions - /* Use this to re-enable object pools. - static void * - cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space) - { - if(space.pooledArbiters.num == 0){ - // arbiter pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpArbiter); - cpAssertHard(count, "Internal Error: Buffer size too small."); +/* Use this to re-enable object pools. +static void * +cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space) +{ + if(space.pooledArbiters.num == 0){ + // arbiter pool is exhausted, make more + int count = CP_BUFFER_BYTES/sizeof(cpArbiter); + cpAssertHard(count, "Internal Error: Buffer size too small."); - cpArbiter *buffer = (cpArbiter *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(space.allocatedBuffers, buffer); + cpArbiter *buffer = (cpArbiter *)cpcalloc(1, CP_BUFFER_BYTES); + cpArrayPush(space.allocatedBuffers, buffer); - for(int i=0; i b.collisionCode){ - var temp = a; - a = b; - b = temp; - } - - // Narrow-phase collision detection. - //cpContact *contacts = cpContactBufferGetArray(space); - //int numContacts = cpCollideShapes(a, b, contacts); - var contacts = collideShapes(a, b); - if(contacts.length === 0) return; // Shapes are not colliding. - //cpSpacePushContacts(space, numContacts); - - // Get an arbiter from space.arbiterSet for the two shapes. - // This is where the persistant contact magic comes from. - var arbHash = hashPair(a.hashid, b.hashid); - var arb = space.cachedArbiters[arbHash]; - if (!arb){ - arb = space.cachedArbiters[arbHash] = new Arbiter(a, b); - } - - arb.update(contacts, handler, a, b); - - // Call the begin function first if it's the first step - if(arb.state == 'first coll' && !handler.begin(arb, space)){ - arb.ignore(); // permanently ignore the collision until separation - } - - if( - // Ignore the arbiter if it has been flagged - (arb.state !== 'ignore') && - // Call preSolve - handler.preSolve(arb, space) && - // Process, but don't add collisions for sensors. - !sensor - ){ - space.arbiters.push(arb); - } else { - //cpSpacePopContacts(space, numContacts); - - arb.contacts = null; - - // Normally arbiters are set as used after calling the post-solve callback. - // However, post-solve callbacks are not called for sensors or arbiters rejected from pre-solve. - if(arb.state !== 'ignore') arb.state = 'normal'; - } - - // Time stamp the arbiter so we know it was used recently. - arb.stamp = space.stamp; - }; - }; +Space.prototype.makeCollideShapes = function() +{ + // It would be nicer to use .bind() or something, but this is faster. + var space_ = this; + return function(a, b){ + var space = space_; + + // Reject any of the simple cases + if( + // BBoxes must overlap + //!bbIntersects(a.bb, b.bb) + !(a.bb_l <= b.bb_r && b.bb_l <= a.bb_r && a.bb_b <= b.bb_t && b.bb_b <= a.bb_t) + // Don't collide shapes attached to the same body. + || a.body === b.body + // Don't collide objects in the same non-zero group + || (a.group && a.group === b.group) + // Don't collide objects that don't share at least on layer. + || !(a.layers & b.layers) + ) return; + + var handler = space.lookupHandler(a.collision_type, b.collision_type); + + var sensor = a.sensor || b.sensor; + if(sensor && handler === defaultCollisionHandler) return; + + // Shape 'a' should have the lower shape type. (required by cpCollideShapes() ) + if(a.collisionCode > b.collisionCode){ + var temp = a; + a = b; + b = temp; + } + + // Narrow-phase collision detection. + //cpContact *contacts = cpContactBufferGetArray(space); + //int numContacts = cpCollideShapes(a, b, contacts); + var contacts = collideShapes(a, b); + if(contacts.length === 0) return; // Shapes are not colliding. + //cpSpacePushContacts(space, numContacts); + + // Get an arbiter from space.arbiterSet for the two shapes. + // This is where the persistant contact magic comes from. + var arbHash = hashPair(a.hashid, b.hashid); + var arb = space.cachedArbiters[arbHash]; + if (!arb){ + arb = space.cachedArbiters[arbHash] = new Arbiter(a, b); + } + + arb.update(contacts, handler, a, b); + + // Call the begin function first if it's the first step + if(arb.state == 'first coll' && !handler.begin(arb, space)){ + arb.ignore(); // permanently ignore the collision until separation + } + + if( + // Ignore the arbiter if it has been flagged + (arb.state !== 'ignore') && + // Call preSolve + handler.preSolve(arb, space) && + // Process, but don't add collisions for sensors. + !sensor + ){ + space.arbiters.push(arb); + } else { + //cpSpacePopContacts(space, numContacts); + + arb.contacts = null; + + // Normally arbiters are set as used after calling the post-solve callback. + // However, post-solve callbacks are not called for sensors or arbiters rejected from pre-solve. + if(arb.state !== 'ignore') arb.state = 'normal'; + } + + // Time stamp the arbiter so we know it was used recently. + arb.stamp = space.stamp; + }; +}; // Hashset filter func to throw away old arbiters. - Space.prototype.arbiterSetFilter = function(arb) - { - var ticks = this.stamp - arb.stamp; - - var a = arb.body_a, b = arb.body_b; - - // TODO should make an arbiter state for this so it doesn't require filtering arbiters for - // dangling body pointers on body removal. - // Preserve arbiters on sensors and rejected arbiters for sleeping objects. - // This prevents errant separate callbacks from happenening. - if( - (a.isStatic() || a.isSleeping()) && - (b.isStatic() || b.isSleeping()) - ){ - return true; - } - - // Arbiter was used last frame, but not this one - if(ticks >= 1 && arb.state != 'cached'){ - arb.callSeparate(this); - arb.state = 'cached'; - } - - if(ticks >= this.collisionPersistence){ - arb.contacts = null; - - //cpArrayPush(this.pooledArbiters, arb); - return false; - } - - return true; - }; +Space.prototype.arbiterSetFilter = function(arb) +{ + var ticks = this.stamp - arb.stamp; + + var a = arb.body_a, b = arb.body_b; + + // TODO should make an arbiter state for this so it doesn't require filtering arbiters for + // dangling body pointers on body removal. + // Preserve arbiters on sensors and rejected arbiters for sleeping objects. + // This prevents errant separate callbacks from happenening. + if( + (a.isStatic() || a.isSleeping()) && + (b.isStatic() || b.isSleeping()) + ){ + return true; + } + + // Arbiter was used last frame, but not this one + if(ticks >= 1 && arb.state != 'cached'){ + arb.callSeparate(this); + arb.state = 'cached'; + } + + if(ticks >= this.collisionPersistence){ + arb.contacts = null; + + //cpArrayPush(this.pooledArbiters, arb); + return false; + } + + return true; +}; // **** All Important cpSpaceStep() Function - var updateFunc = function(shape) - { - var body = shape.body; - shape.update(body.p, body.rot); - }; +var updateFunc = function(shape) +{ + var body = shape.body; + shape.update(body.p, body.rot); +}; /// Step the space forward in time by @c dt. - Space.prototype.step = function(dt) - { - // don't step if the timestep is 0! - if(dt === 0) return; - - assert(vzero.x === 0 && vzero.y === 0, "vzero is invalid"); - - this.stamp++; - - var prev_dt = this.curr_dt; - this.curr_dt = dt; - - var bodies = this.bodies; - var constraints = this.constraints; - var arbiters = this.arbiters; - - // Reset and empty the arbiter lists. - for(var i=0; imaxForce*(dt)) // a and b are bodies. - var relative_velocity = function(a, b, r1, r2){ - //var v1_sum = vadd(a.v, vmult(vperp(r1), a.w)); - var v1_sumx = a.vx + (-r1.y) * a.w; - var v1_sumy = a.vy + ( r1.x) * a.w; - - //var v2_sum = vadd(b.v, vmult(vperp(r2), b.w)); - var v2_sumx = b.vx + (-r2.y) * b.w; - var v2_sumy = b.vy + ( r2.x) * b.w; - +var relative_velocity = function(a, b, r1, r2){ + //var v1_sum = vadd(a.v, vmult(vperp(r1), a.w)); + var v1_sumx = a.vx + (-r1.y) * a.w; + var v1_sumy = a.vy + ( r1.x) * a.w; + + //var v2_sum = vadd(b.v, vmult(vperp(r2), b.w)); + var v2_sumx = b.vx + (-r2.y) * b.w; + var v2_sumy = b.vy + ( r2.x) * b.w; + // return vsub(v2_sum, v1_sum); - return new Vect(v2_sumx - v1_sumx, v2_sumy - v1_sumy); - }; - - var normal_relative_velocity = function(a, b, r1, r2, n){ - //return vdot(relative_velocity(a, b, r1, r2), n); - var v1_sumx = a.vx + (-r1.y) * a.w; - var v1_sumy = a.vy + ( r1.x) * a.w; - var v2_sumx = b.vx + (-r2.y) * b.w; - var v2_sumy = b.vy + ( r2.x) * b.w; - - return vdot2(v2_sumx - v1_sumx, v2_sumy - v1_sumy, n.x, n.y); - }; - - /* - var apply_impulse = function(body, j, r){ - body.v = vadd(body.v, vmult(j, body.m_inv)); - body.w += body.i_inv*vcross(r, j); - }; - - var apply_impulses = function(a, b, r1, r2, j) - { - apply_impulse(a, vneg(j), r1); - apply_impulse(b, j, r2); - }; - */ - - var apply_impulse = function(body, jx, jy, r){ + return new Vect(v2_sumx - v1_sumx, v2_sumy - v1_sumy); +}; + +var normal_relative_velocity = function(a, b, r1, r2, n){ + //return vdot(relative_velocity(a, b, r1, r2), n); + var v1_sumx = a.vx + (-r1.y) * a.w; + var v1_sumy = a.vy + ( r1.x) * a.w; + var v2_sumx = b.vx + (-r2.y) * b.w; + var v2_sumy = b.vy + ( r2.x) * b.w; + + return vdot2(v2_sumx - v1_sumx, v2_sumy - v1_sumy, n.x, n.y); +}; + +/* +var apply_impulse = function(body, j, r){ + body.v = vadd(body.v, vmult(j, body.m_inv)); + body.w += body.i_inv*vcross(r, j); +}; + +var apply_impulses = function(a, b, r1, r2, j) +{ + apply_impulse(a, vneg(j), r1); + apply_impulse(b, j, r2); +}; +*/ + +var apply_impulse = function(body, jx, jy, r){ // body.v = body.v.add(vmult(j, body.m_inv)); - body.vx += jx * body.m_inv; - body.vy += jy * body.m_inv; + body.vx += jx * body.m_inv; + body.vy += jy * body.m_inv; // body.w += body.i_inv*vcross(r, j); - body.w += body.i_inv*(r.x*jy - r.y*jx); - }; - - var apply_impulses = function(a, b, r1, r2, jx, jy) - { - apply_impulse(a, -jx, -jy, r1); - apply_impulse(b, jx, jy, r2); - }; - - var apply_bias_impulse = function(body, jx, jy, r) - { - //body.v_bias = vadd(body.v_bias, vmult(j, body.m_inv)); - body.v_biasx += jx * body.m_inv; - body.v_biasy += jy * body.m_inv; - body.w_bias += body.i_inv*vcross2(r.x, r.y, jx, jy); - }; - - /* - var apply_bias_impulses = function(a, b, r1, r2, j) - { - apply_bias_impulse(a, vneg(j), r1); - apply_bias_impulse(b, j, r2); - };*/ - - var k_scalar_body = function(body, r, n) - { - var rcn = vcross(r, n); - return body.m_inv + body.i_inv*rcn*rcn; - }; - - var k_scalar = function(a, b, r1, r2, n) - { - var value = k_scalar_body(a, r1, n) + k_scalar_body(b, r2, n); - assertSoft(value !== 0, "Unsolvable collision or constraint."); - - return value; - }; + body.w += body.i_inv*(r.x*jy - r.y*jx); +}; + +var apply_impulses = function(a, b, r1, r2, jx, jy) +{ + apply_impulse(a, -jx, -jy, r1); + apply_impulse(b, jx, jy, r2); +}; + +var apply_bias_impulse = function(body, jx, jy, r) +{ + //body.v_bias = vadd(body.v_bias, vmult(j, body.m_inv)); + body.v_biasx += jx * body.m_inv; + body.v_biasy += jy * body.m_inv; + body.w_bias += body.i_inv*vcross2(r.x, r.y, jx, jy); +}; + +/* +var apply_bias_impulses = function(a, b, r1, r2, j) +{ + apply_bias_impulse(a, vneg(j), r1); + apply_bias_impulse(b, j, r2); +};*/ + +var k_scalar_body = function(body, r, n) +{ + var rcn = vcross(r, n); + return body.m_inv + body.i_inv*rcn*rcn; +}; + +var k_scalar = function(a, b, r1, r2, n) +{ + var value = k_scalar_body(a, r1, n) + k_scalar_body(b, r2, n); + assertSoft(value !== 0, "Unsolvable collision or constraint."); + + return value; +}; // k1 and k2 are modified by the function to contain the outputs. - var k_tensor = function(a, b, r1, r2, k1, k2) - { - // calculate mass matrix - // If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross... - var k11, k12, k21, k22; - var m_sum = a.m_inv + b.m_inv; - - // start with I*m_sum - k11 = m_sum; k12 = 0; - k21 = 0; k22 = m_sum; - - // add the influence from r1 - var a_i_inv = a.i_inv; - var r1xsq = r1.x * r1.x * a_i_inv; - var r1ysq = r1.y * r1.y * a_i_inv; - var r1nxy = -r1.x * r1.y * a_i_inv; - k11 += r1ysq; k12 += r1nxy; - k21 += r1nxy; k22 += r1xsq; - - // add the influnce from r2 - var b_i_inv = b.i_inv; - var r2xsq = r2.x * r2.x * b_i_inv; - var r2ysq = r2.y * r2.y * b_i_inv; - var r2nxy = -r2.x * r2.y * b_i_inv; - k11 += r2ysq; k12 += r2nxy; - k21 += r2nxy; k22 += r2xsq; - - // invert - var determinant = k11*k22 - k12*k21; - assertSoft(determinant !== 0, "Unsolvable constraint."); - - var det_inv = 1/determinant; - - k1.x = k22*det_inv; k1.y = -k12*det_inv; - k2.x = -k21*det_inv; k2.y = k11*det_inv; - }; - - var mult_k = function(vr, k1, k2) - { - return new Vect(vdot(vr, k1), vdot(vr, k2)); - }; - - var bias_coef = function(errorBias, dt) - { - return 1 - Math.pow(errorBias, dt); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +var k_tensor = function(a, b, r1, r2, k1, k2) +{ + // calculate mass matrix + // If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross... + var k11, k12, k21, k22; + var m_sum = a.m_inv + b.m_inv; + + // start with I*m_sum + k11 = m_sum; k12 = 0; + k21 = 0; k22 = m_sum; + + // add the influence from r1 + var a_i_inv = a.i_inv; + var r1xsq = r1.x * r1.x * a_i_inv; + var r1ysq = r1.y * r1.y * a_i_inv; + var r1nxy = -r1.x * r1.y * a_i_inv; + k11 += r1ysq; k12 += r1nxy; + k21 += r1nxy; k22 += r1xsq; + + // add the influnce from r2 + var b_i_inv = b.i_inv; + var r2xsq = r2.x * r2.x * b_i_inv; + var r2ysq = r2.y * r2.y * b_i_inv; + var r2nxy = -r2.x * r2.y * b_i_inv; + k11 += r2ysq; k12 += r2nxy; + k21 += r2nxy; k22 += r2xsq; + + // invert + var determinant = k11*k22 - k12*k21; + assertSoft(determinant !== 0, "Unsolvable constraint."); + + var det_inv = 1/determinant; + + k1.x = k22*det_inv; k1.y = -k12*det_inv; + k2.x = -k21*det_inv; k2.y = k11*det_inv; +}; + +var mult_k = function(vr, k1, k2) +{ + return new Vect(vdot(vr, k1), vdot(vr, k2)); +}; + +var bias_coef = function(errorBias, dt) +{ + return 1 - Math.pow(errorBias, dt); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // TODO: Comment me! // a and b are bodies that the constraint applies to. - var Constraint = cp.Constraint = function(a, b) - { - /// The first body connected to this constraint. - this.a = a; - /// The second body connected to this constraint. - this.b = b; - - this.space = null; - - this.next_a = null; - this.next_b = null; - - /// The maximum force that this constraint is allowed to use. - this.maxForce = Infinity; - /// The rate at which joint error is corrected. - /// Defaults to pow(1 - 0.1, 60) meaning that it will - /// correct 10% of the error every 1/60th of a second. - this.errorBias = Math.pow(1 - 0.1, 60); - /// The maximum rate at which joint error is corrected. - this.maxBias = Infinity; - }; - - Constraint.prototype.activateBodies = function() - { - if(this.a) this.a.activate(); - if(this.b) this.b.activate(); - }; +var Constraint = cp.Constraint = function(a, b) +{ + /// The first body connected to this constraint. + this.a = a; + /// The second body connected to this constraint. + this.b = b; + + this.space = null; + + this.next_a = null; + this.next_b = null; + + /// The maximum force that this constraint is allowed to use. + this.maxForce = Infinity; + /// The rate at which joint error is corrected. + /// Defaults to pow(1 - 0.1, 60) meaning that it will + /// correct 10% of the error every 1/60th of a second. + this.errorBias = Math.pow(1 - 0.1, 60); + /// The maximum rate at which joint error is corrected. + this.maxBias = Infinity; +}; + +Constraint.prototype.activateBodies = function() +{ + if(this.a) this.a.activate(); + if(this.b) this.b.activate(); +}; /// These methods are overridden by the constraint itself. - Constraint.prototype.preStep = function(dt) {}; - Constraint.prototype.applyCachedImpulse = function(dt_coef) {}; - Constraint.prototype.applyImpulse = function() {}; - Constraint.prototype.getImpulse = function() { return 0; }; +Constraint.prototype.preStep = function(dt) {}; +Constraint.prototype.applyCachedImpulse = function(dt_coef) {}; +Constraint.prototype.applyImpulse = function() {}; +Constraint.prototype.getImpulse = function() { return 0; }; /// Function called before the solver runs. This can be overridden by the user /// to customize the constraint. /// Animate your joint anchors, update your motor torque, etc. - Constraint.prototype.preSolve = function(space) {}; +Constraint.prototype.preSolve = function(space) {}; /// Function called after the solver runs. This can be overridden by the user /// to customize the constraint. /// Use the applied impulse to perform effects like breakable joints. - Constraint.prototype.postSolve = function(space) {}; - - Constraint.prototype.next = function(body) - { - return (this.a === body ? this.next_a : this.next_b); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var PinJoint = cp.PinJoint = function(a, b, anchr1, anchr2) - { - Constraint.call(this, a, b); - - this.anchr1 = anchr1; - this.anchr2 = anchr2; - - // STATIC_BODY_CHECK - var p1 = (a ? vadd(a.p, vrotate(anchr1, a.rot)) : anchr1); - var p2 = (b ? vadd(b.p, vrotate(anchr2, b.rot)) : anchr2); - this.dist = vlength(vsub(p2, p1)); - - assertSoft(this.dist > 0, "You created a 0 length pin joint. A pivot joint will be much more stable."); - - this.r1 = this.r2 = null; - this.n = null; - this.nMass = 0; - - this.jnAcc = this.jnMax = 0; - this.bias = 0; - }; - - PinJoint.prototype = Object.create(Constraint.prototype); - - PinJoint.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - this.r1 = vrotate(this.anchr1, a.rot); - this.r2 = vrotate(this.anchr2, b.rot); - - var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); - var dist = vlength(delta); - this.n = vmult(delta, 1/(dist ? dist : Infinity)); - - // calculate mass normal - this.nMass = 1/k_scalar(a, b, this.r1, this.r2, this.n); - - // calculate bias velocity - var maxBias = this.maxBias; - this.bias = clamp(-bias_coef(this.errorBias, dt)*(dist - this.dist)/dt, -maxBias, maxBias); - - // compute max impulse - this.jnMax = this.maxForce * dt; - }; - - PinJoint.prototype.applyCachedImpulse = function(dt_coef) - { - var j = vmult(this.n, this.jnAcc*dt_coef); - apply_impulses(this.a, this.b, this.r1, this.r2, j.x, j.y); - }; - - PinJoint.prototype.applyImpulse = function() - { - var a = this.a; - var b = this.b; - var n = this.n; - - // compute relative velocity - var vrn = normal_relative_velocity(a, b, this.r1, this.r2, n); - - // compute normal impulse - var jn = (this.bias - vrn)*this.nMass; - var jnOld = this.jnAcc; - this.jnAcc = clamp(jnOld + jn, -this.jnMax, this.jnMax); - jn = this.jnAcc - jnOld; - - // apply impulse - apply_impulses(a, b, this.r1, this.r2, n.x*jn, n.y*jn); - }; - - PinJoint.prototype.getImpulse = function() - { - return Math.abs(this.jnAcc); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var SlideJoint = cp.SlideJoint = function(a, b, anchr1, anchr2, min, max) - { - Constraint.call(this, a, b); - - this.anchr1 = anchr1; - this.anchr2 = anchr2; - this.min = min; - this.max = max; - - this.r1 = this.r2 = this.n = null; - this.nMass = 0; - - this.jnAcc = this.jnMax = 0; - this.bias = 0; - }; - - SlideJoint.prototype = Object.create(Constraint.prototype); - - SlideJoint.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - this.r1 = vrotate(this.anchr1, a.rot); - this.r2 = vrotate(this.anchr2, b.rot); - - var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); - var dist = vlength(delta); - var pdist = 0; - if(dist > this.max) { - pdist = dist - this.max; - this.n = vnormalize_safe(delta); - } else if(dist < this.min) { - pdist = this.min - dist; - this.n = vneg(vnormalize_safe(delta)); - } else { - this.n = vzero; - this.jnAcc = 0; - } - - // calculate mass normal - this.nMass = 1/k_scalar(a, b, this.r1, this.r2, this.n); - - // calculate bias velocity - var maxBias = this.maxBias; - this.bias = clamp(-bias_coef(this.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // compute max impulse - this.jnMax = this.maxForce * dt; - }; - - SlideJoint.prototype.applyCachedImpulse = function(dt_coef) - { - var jn = this.jnAcc * dt_coef; - apply_impulses(this.a, this.b, this.r1, this.r2, this.n.x * jn, this.n.y * jn); - }; - - SlideJoint.prototype.applyImpulse = function() - { - if(this.n.x === 0 && this.n.y === 0) return; // early exit - - var a = this.a; - var b = this.b; - - var n = this.n; - var r1 = this.r1; - var r2 = this.r2; - - // compute relative velocity - var vr = relative_velocity(a, b, r1, r2); - var vrn = vdot(vr, n); - - // compute normal impulse - var jn = (this.bias - vrn)*this.nMass; - var jnOld = this.jnAcc; - this.jnAcc = clamp(jnOld + jn, -this.jnMax, 0); - jn = this.jnAcc - jnOld; - - // apply impulse - apply_impulses(a, b, this.r1, this.r2, n.x * jn, n.y * jn); - }; - - SlideJoint.prototype.getImpulse = function() - { - return Math.abs(this.jnAcc); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ +Constraint.prototype.postSolve = function(space) {}; + +Constraint.prototype.next = function(body) +{ + return (this.a === body ? this.next_a : this.next_b); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var PinJoint = cp.PinJoint = function(a, b, anchr1, anchr2) +{ + Constraint.call(this, a, b); + + this.anchr1 = anchr1; + this.anchr2 = anchr2; + + // STATIC_BODY_CHECK + var p1 = (a ? vadd(a.p, vrotate(anchr1, a.rot)) : anchr1); + var p2 = (b ? vadd(b.p, vrotate(anchr2, b.rot)) : anchr2); + this.dist = vlength(vsub(p2, p1)); + + assertSoft(this.dist > 0, "You created a 0 length pin joint. A pivot joint will be much more stable."); + + this.r1 = this.r2 = null; + this.n = null; + this.nMass = 0; + + this.jnAcc = this.jnMax = 0; + this.bias = 0; +}; + +PinJoint.prototype = Object.create(Constraint.prototype); + +PinJoint.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + this.r1 = vrotate(this.anchr1, a.rot); + this.r2 = vrotate(this.anchr2, b.rot); + + var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); + var dist = vlength(delta); + this.n = vmult(delta, 1/(dist ? dist : Infinity)); + + // calculate mass normal + this.nMass = 1/k_scalar(a, b, this.r1, this.r2, this.n); + + // calculate bias velocity + var maxBias = this.maxBias; + this.bias = clamp(-bias_coef(this.errorBias, dt)*(dist - this.dist)/dt, -maxBias, maxBias); + + // compute max impulse + this.jnMax = this.maxForce * dt; +}; + +PinJoint.prototype.applyCachedImpulse = function(dt_coef) +{ + var j = vmult(this.n, this.jnAcc*dt_coef); + apply_impulses(this.a, this.b, this.r1, this.r2, j.x, j.y); +}; + +PinJoint.prototype.applyImpulse = function() +{ + var a = this.a; + var b = this.b; + var n = this.n; + + // compute relative velocity + var vrn = normal_relative_velocity(a, b, this.r1, this.r2, n); + + // compute normal impulse + var jn = (this.bias - vrn)*this.nMass; + var jnOld = this.jnAcc; + this.jnAcc = clamp(jnOld + jn, -this.jnMax, this.jnMax); + jn = this.jnAcc - jnOld; + + // apply impulse + apply_impulses(a, b, this.r1, this.r2, n.x*jn, n.y*jn); +}; + +PinJoint.prototype.getImpulse = function() +{ + return Math.abs(this.jnAcc); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var SlideJoint = cp.SlideJoint = function(a, b, anchr1, anchr2, min, max) +{ + Constraint.call(this, a, b); + + this.anchr1 = anchr1; + this.anchr2 = anchr2; + this.min = min; + this.max = max; + + this.r1 = this.r2 = this.n = null; + this.nMass = 0; + + this.jnAcc = this.jnMax = 0; + this.bias = 0; +}; + +SlideJoint.prototype = Object.create(Constraint.prototype); + +SlideJoint.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + this.r1 = vrotate(this.anchr1, a.rot); + this.r2 = vrotate(this.anchr2, b.rot); + + var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); + var dist = vlength(delta); + var pdist = 0; + if(dist > this.max) { + pdist = dist - this.max; + this.n = vnormalize_safe(delta); + } else if(dist < this.min) { + pdist = this.min - dist; + this.n = vneg(vnormalize_safe(delta)); + } else { + this.n = vzero; + this.jnAcc = 0; + } + + // calculate mass normal + this.nMass = 1/k_scalar(a, b, this.r1, this.r2, this.n); + + // calculate bias velocity + var maxBias = this.maxBias; + this.bias = clamp(-bias_coef(this.errorBias, dt)*pdist/dt, -maxBias, maxBias); + + // compute max impulse + this.jnMax = this.maxForce * dt; +}; + +SlideJoint.prototype.applyCachedImpulse = function(dt_coef) +{ + var jn = this.jnAcc * dt_coef; + apply_impulses(this.a, this.b, this.r1, this.r2, this.n.x * jn, this.n.y * jn); +}; + +SlideJoint.prototype.applyImpulse = function() +{ + if(this.n.x === 0 && this.n.y === 0) return; // early exit + + var a = this.a; + var b = this.b; + + var n = this.n; + var r1 = this.r1; + var r2 = this.r2; + + // compute relative velocity + var vr = relative_velocity(a, b, r1, r2); + var vrn = vdot(vr, n); + + // compute normal impulse + var jn = (this.bias - vrn)*this.nMass; + var jnOld = this.jnAcc; + this.jnAcc = clamp(jnOld + jn, -this.jnMax, 0); + jn = this.jnAcc - jnOld; + + // apply impulse + apply_impulses(a, b, this.r1, this.r2, n.x * jn, n.y * jn); +}; + +SlideJoint.prototype.getImpulse = function() +{ + return Math.abs(this.jnAcc); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // Pivot joints can also be created with (a, b, pivot); - var PivotJoint = cp.PivotJoint = function(a, b, anchr1, anchr2) - { - Constraint.call(this, a, b); - - if(typeof anchr2 === 'undefined') { - var pivot = anchr1; - - anchr1 = (a ? a.world2Local(pivot) : pivot); - anchr2 = (b ? b.world2Local(pivot) : pivot); - } - - this.anchr1 = anchr1; - this.anchr2 = anchr2; - - this.r1 = this.r2 = vzero; - - this.k1 = new Vect(0,0); this.k2 = new Vect(0,0); - - this.jAcc = vzero; - - this.jMaxLen = 0; - this.bias = vzero; - }; - - PivotJoint.prototype = Object.create(Constraint.prototype); - - PivotJoint.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - this.r1 = vrotate(this.anchr1, a.rot); - this.r2 = vrotate(this.anchr2, b.rot); - - // Calculate mass tensor. Result is stored into this.k1 & this.k2. - k_tensor(a, b, this.r1, this.r2, this.k1, this.k2); - - // compute max impulse - this.jMaxLen = this.maxForce * dt; - - // calculate bias velocity - var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); - this.bias = vclamp(vmult(delta, -bias_coef(this.errorBias, dt)/dt), this.maxBias); - }; - - PivotJoint.prototype.applyCachedImpulse = function(dt_coef) - { - apply_impulses(this.a, this.b, this.r1, this.r2, this.jAcc.x * dt_coef, this.jAcc.y * dt_coef); - }; - - PivotJoint.prototype.applyImpulse = function() - { - var a = this.a; - var b = this.b; - - var r1 = this.r1; - var r2 = this.r2; - - // compute relative velocity - var vr = relative_velocity(a, b, r1, r2); - - // compute normal impulse - var j = mult_k(vsub(this.bias, vr), this.k1, this.k2); - var jOld = this.jAcc; - this.jAcc = vclamp(vadd(this.jAcc, j), this.jMaxLen); - - // apply impulse - apply_impulses(a, b, this.r1, this.r2, this.jAcc.x - jOld.x, this.jAcc.y - jOld.y); - }; - - PivotJoint.prototype.getImpulse = function() - { - return vlength(this.jAcc); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var GrooveJoint = cp.GrooveJoint = function(a, b, groove_a, groove_b, anchr2) - { - Constraint.call(this, a, b); - - this.grv_a = groove_a; - this.grv_b = groove_b; - this.grv_n = vperp(vnormalize(vsub(groove_b, groove_a))); - this.anchr2 = anchr2; - - this.grv_tn = null; - this.clamp = 0; - this.r1 = this.r2 = null; - - this.k1 = new Vect(0,0); - this.k2 = new Vect(0,0); - - this.jAcc = vzero; - this.jMaxLen = 0; - this.bias = null; - }; - - GrooveJoint.prototype = Object.create(Constraint.prototype); - - GrooveJoint.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - // calculate endpoints in worldspace - var ta = a.local2World(this.grv_a); - var tb = a.local2World(this.grv_b); - - // calculate axis - var n = vrotate(this.grv_n, a.rot); - var d = vdot(ta, n); - - this.grv_tn = n; - this.r2 = vrotate(this.anchr2, b.rot); - - // calculate tangential distance along the axis of r2 - var td = vcross(vadd(b.p, this.r2), n); - // calculate clamping factor and r2 - if(td <= vcross(ta, n)){ - this.clamp = 1; - this.r1 = vsub(ta, a.p); - } else if(td >= vcross(tb, n)){ - this.clamp = -1; - this.r1 = vsub(tb, a.p); - } else { - this.clamp = 0; - this.r1 = vsub(vadd(vmult(vperp(n), -td), vmult(n, d)), a.p); - } - - // Calculate mass tensor - k_tensor(a, b, this.r1, this.r2, this.k1, this.k2); - - // compute max impulse - this.jMaxLen = this.maxForce * dt; - - // calculate bias velocity - var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); - this.bias = vclamp(vmult(delta, -bias_coef(this.errorBias, dt)/dt), this.maxBias); - }; - - GrooveJoint.prototype.applyCachedImpulse = function(dt_coef) - { - apply_impulses(this.a, this.b, this.r1, this.r2, this.jAcc.x * dt_coef, this.jAcc.y * dt_coef); - }; - - GrooveJoint.prototype.grooveConstrain = function(j){ - var n = this.grv_tn; - var jClamp = (this.clamp*vcross(j, n) > 0) ? j : vproject(j, n); - return vclamp(jClamp, this.jMaxLen); - }; - - GrooveJoint.prototype.applyImpulse = function() - { - var a = this.a; - var b = this.b; - - var r1 = this.r1; - var r2 = this.r2; - - // compute impulse - var vr = relative_velocity(a, b, r1, r2); - - var j = mult_k(vsub(this.bias, vr), this.k1, this.k2); - var jOld = this.jAcc; - this.jAcc = this.grooveConstrain(vadd(jOld, j)); - - // apply impulse - apply_impulses(a, b, this.r1, this.r2, this.jAcc.x - jOld.x, this.jAcc.y - jOld.y); - }; - - GrooveJoint.prototype.getImpulse = function() - { - return vlength(this.jAcc); - }; - - GrooveJoint.prototype.setGrooveA = function(value) - { - this.grv_a = value; - this.grv_n = vperp(vnormalize(vsub(this.grv_b, value))); - - this.activateBodies(); - }; - - GrooveJoint.prototype.setGrooveB = function(value) - { - this.grv_b = value; - this.grv_n = vperp(vnormalize(vsub(value, this.grv_a))); - - this.activateBodies(); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var defaultSpringForce = function(spring, dist){ - return (spring.restLength - dist)*spring.stiffness; - }; - - var DampedSpring = cp.DampedSpring = function(a, b, anchr1, anchr2, restLength, stiffness, damping) - { - Constraint.call(this, a, b); - - this.anchr1 = anchr1; - this.anchr2 = anchr2; - - this.restLength = restLength; - this.stiffness = stiffness; - this.damping = damping; - this.springForceFunc = defaultSpringForce; - - this.target_vrn = this.v_coef = 0; - - this.r1 = this.r2 = null; - this.nMass = 0; - this.n = null; - }; - - DampedSpring.prototype = Object.create(Constraint.prototype); - - DampedSpring.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - this.r1 = vrotate(this.anchr1, a.rot); - this.r2 = vrotate(this.anchr2, b.rot); - - var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); - var dist = vlength(delta); - this.n = vmult(delta, 1/(dist ? dist : Infinity)); - - var k = k_scalar(a, b, this.r1, this.r2, this.n); - assertSoft(k !== 0, "Unsolvable this."); - this.nMass = 1/k; - - this.target_vrn = 0; - this.v_coef = 1 - Math.exp(-this.damping*dt*k); - - // apply this force - var f_spring = this.springForceFunc(this, dist); - apply_impulses(a, b, this.r1, this.r2, this.n.x * f_spring * dt, this.n.y * f_spring * dt); - }; - - DampedSpring.prototype.applyCachedImpulse = function(dt_coef){}; - - DampedSpring.prototype.applyImpulse = function() - { - var a = this.a; - var b = this.b; - - var n = this.n; - var r1 = this.r1; - var r2 = this.r2; - - // compute relative velocity - var vrn = normal_relative_velocity(a, b, r1, r2, n); - - // compute velocity loss from drag - var v_damp = (this.target_vrn - vrn)*this.v_coef; - this.target_vrn = vrn + v_damp; - - v_damp *= this.nMass; - apply_impulses(a, b, this.r1, this.r2, this.n.x * v_damp, this.n.y * v_damp); - }; - - DampedSpring.prototype.getImpulse = function() - { - return 0; - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var defaultSpringTorque = function(spring, relativeAngle){ - return (relativeAngle - spring.restAngle)*spring.stiffness; - } - - var DampedRotarySpring = cp.DampedRotarySpring = function(a, b, restAngle, stiffness, damping) - { - Constraint.call(this, a, b); - - this.restAngle = restAngle; - this.stiffness = stiffness; - this.damping = damping; - this.springTorqueFunc = defaultSpringTorque; - - this.target_wrn = 0; - this.w_coef = 0; - this.iSum = 0; - }; - - DampedRotarySpring.prototype = Object.create(Constraint.prototype); - - DampedRotarySpring.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - var moment = a.i_inv + b.i_inv; - assertSoft(moment !== 0, "Unsolvable spring."); - this.iSum = 1/moment; - - this.w_coef = 1 - Math.exp(-this.damping*dt*moment); - this.target_wrn = 0; - - // apply this torque - var j_spring = this.springTorqueFunc(this, a.a - b.a)*dt; - a.w -= j_spring*a.i_inv; - b.w += j_spring*b.i_inv; - }; +var PivotJoint = cp.PivotJoint = function(a, b, anchr1, anchr2) +{ + Constraint.call(this, a, b); + + if(typeof anchr2 === 'undefined') { + var pivot = anchr1; + + anchr1 = (a ? a.world2Local(pivot) : pivot); + anchr2 = (b ? b.world2Local(pivot) : pivot); + } + + this.anchr1 = anchr1; + this.anchr2 = anchr2; + + this.r1 = this.r2 = vzero; + + this.k1 = new Vect(0,0); this.k2 = new Vect(0,0); + + this.jAcc = vzero; + + this.jMaxLen = 0; + this.bias = vzero; +}; + +PivotJoint.prototype = Object.create(Constraint.prototype); + +PivotJoint.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + this.r1 = vrotate(this.anchr1, a.rot); + this.r2 = vrotate(this.anchr2, b.rot); + + // Calculate mass tensor. Result is stored into this.k1 & this.k2. + k_tensor(a, b, this.r1, this.r2, this.k1, this.k2); + + // compute max impulse + this.jMaxLen = this.maxForce * dt; + + // calculate bias velocity + var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); + this.bias = vclamp(vmult(delta, -bias_coef(this.errorBias, dt)/dt), this.maxBias); +}; + +PivotJoint.prototype.applyCachedImpulse = function(dt_coef) +{ + apply_impulses(this.a, this.b, this.r1, this.r2, this.jAcc.x * dt_coef, this.jAcc.y * dt_coef); +}; + +PivotJoint.prototype.applyImpulse = function() +{ + var a = this.a; + var b = this.b; + + var r1 = this.r1; + var r2 = this.r2; + + // compute relative velocity + var vr = relative_velocity(a, b, r1, r2); + + // compute normal impulse + var j = mult_k(vsub(this.bias, vr), this.k1, this.k2); + var jOld = this.jAcc; + this.jAcc = vclamp(vadd(this.jAcc, j), this.jMaxLen); + + // apply impulse + apply_impulses(a, b, this.r1, this.r2, this.jAcc.x - jOld.x, this.jAcc.y - jOld.y); +}; + +PivotJoint.prototype.getImpulse = function() +{ + return vlength(this.jAcc); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var GrooveJoint = cp.GrooveJoint = function(a, b, groove_a, groove_b, anchr2) +{ + Constraint.call(this, a, b); + + this.grv_a = groove_a; + this.grv_b = groove_b; + this.grv_n = vperp(vnormalize(vsub(groove_b, groove_a))); + this.anchr2 = anchr2; + + this.grv_tn = null; + this.clamp = 0; + this.r1 = this.r2 = null; + + this.k1 = new Vect(0,0); + this.k2 = new Vect(0,0); + + this.jAcc = vzero; + this.jMaxLen = 0; + this.bias = null; +}; + +GrooveJoint.prototype = Object.create(Constraint.prototype); + +GrooveJoint.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + // calculate endpoints in worldspace + var ta = a.local2World(this.grv_a); + var tb = a.local2World(this.grv_b); + + // calculate axis + var n = vrotate(this.grv_n, a.rot); + var d = vdot(ta, n); + + this.grv_tn = n; + this.r2 = vrotate(this.anchr2, b.rot); + + // calculate tangential distance along the axis of r2 + var td = vcross(vadd(b.p, this.r2), n); + // calculate clamping factor and r2 + if(td <= vcross(ta, n)){ + this.clamp = 1; + this.r1 = vsub(ta, a.p); + } else if(td >= vcross(tb, n)){ + this.clamp = -1; + this.r1 = vsub(tb, a.p); + } else { + this.clamp = 0; + this.r1 = vsub(vadd(vmult(vperp(n), -td), vmult(n, d)), a.p); + } + + // Calculate mass tensor + k_tensor(a, b, this.r1, this.r2, this.k1, this.k2); + + // compute max impulse + this.jMaxLen = this.maxForce * dt; + + // calculate bias velocity + var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); + this.bias = vclamp(vmult(delta, -bias_coef(this.errorBias, dt)/dt), this.maxBias); +}; + +GrooveJoint.prototype.applyCachedImpulse = function(dt_coef) +{ + apply_impulses(this.a, this.b, this.r1, this.r2, this.jAcc.x * dt_coef, this.jAcc.y * dt_coef); +}; + +GrooveJoint.prototype.grooveConstrain = function(j){ + var n = this.grv_tn; + var jClamp = (this.clamp*vcross(j, n) > 0) ? j : vproject(j, n); + return vclamp(jClamp, this.jMaxLen); +}; + +GrooveJoint.prototype.applyImpulse = function() +{ + var a = this.a; + var b = this.b; + + var r1 = this.r1; + var r2 = this.r2; + + // compute impulse + var vr = relative_velocity(a, b, r1, r2); + + var j = mult_k(vsub(this.bias, vr), this.k1, this.k2); + var jOld = this.jAcc; + this.jAcc = this.grooveConstrain(vadd(jOld, j)); + + // apply impulse + apply_impulses(a, b, this.r1, this.r2, this.jAcc.x - jOld.x, this.jAcc.y - jOld.y); +}; + +GrooveJoint.prototype.getImpulse = function() +{ + return vlength(this.jAcc); +}; + +GrooveJoint.prototype.setGrooveA = function(value) +{ + this.grv_a = value; + this.grv_n = vperp(vnormalize(vsub(this.grv_b, value))); + + this.activateBodies(); +}; + +GrooveJoint.prototype.setGrooveB = function(value) +{ + this.grv_b = value; + this.grv_n = vperp(vnormalize(vsub(value, this.grv_a))); + + this.activateBodies(); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var defaultSpringForce = function(spring, dist){ + return (spring.restLength - dist)*spring.stiffness; +}; + +var DampedSpring = cp.DampedSpring = function(a, b, anchr1, anchr2, restLength, stiffness, damping) +{ + Constraint.call(this, a, b); + + this.anchr1 = anchr1; + this.anchr2 = anchr2; + + this.restLength = restLength; + this.stiffness = stiffness; + this.damping = damping; + this.springForceFunc = defaultSpringForce; + + this.target_vrn = this.v_coef = 0; + + this.r1 = this.r2 = null; + this.nMass = 0; + this.n = null; +}; + +DampedSpring.prototype = Object.create(Constraint.prototype); + +DampedSpring.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + this.r1 = vrotate(this.anchr1, a.rot); + this.r2 = vrotate(this.anchr2, b.rot); + + var delta = vsub(vadd(b.p, this.r2), vadd(a.p, this.r1)); + var dist = vlength(delta); + this.n = vmult(delta, 1/(dist ? dist : Infinity)); + + var k = k_scalar(a, b, this.r1, this.r2, this.n); + assertSoft(k !== 0, "Unsolvable this."); + this.nMass = 1/k; + + this.target_vrn = 0; + this.v_coef = 1 - Math.exp(-this.damping*dt*k); + + // apply this force + var f_spring = this.springForceFunc(this, dist); + apply_impulses(a, b, this.r1, this.r2, this.n.x * f_spring * dt, this.n.y * f_spring * dt); +}; + +DampedSpring.prototype.applyCachedImpulse = function(dt_coef){}; + +DampedSpring.prototype.applyImpulse = function() +{ + var a = this.a; + var b = this.b; + + var n = this.n; + var r1 = this.r1; + var r2 = this.r2; + + // compute relative velocity + var vrn = normal_relative_velocity(a, b, r1, r2, n); + + // compute velocity loss from drag + var v_damp = (this.target_vrn - vrn)*this.v_coef; + this.target_vrn = vrn + v_damp; + + v_damp *= this.nMass; + apply_impulses(a, b, this.r1, this.r2, this.n.x * v_damp, this.n.y * v_damp); +}; + +DampedSpring.prototype.getImpulse = function() +{ + return 0; +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var defaultSpringTorque = function(spring, relativeAngle){ + return (relativeAngle - spring.restAngle)*spring.stiffness; +} + +var DampedRotarySpring = cp.DampedRotarySpring = function(a, b, restAngle, stiffness, damping) +{ + Constraint.call(this, a, b); + + this.restAngle = restAngle; + this.stiffness = stiffness; + this.damping = damping; + this.springTorqueFunc = defaultSpringTorque; + + this.target_wrn = 0; + this.w_coef = 0; + this.iSum = 0; +}; + +DampedRotarySpring.prototype = Object.create(Constraint.prototype); + +DampedRotarySpring.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + var moment = a.i_inv + b.i_inv; + assertSoft(moment !== 0, "Unsolvable spring."); + this.iSum = 1/moment; + + this.w_coef = 1 - Math.exp(-this.damping*dt*moment); + this.target_wrn = 0; + + // apply this torque + var j_spring = this.springTorqueFunc(this, a.a - b.a)*dt; + a.w -= j_spring*a.i_inv; + b.w += j_spring*b.i_inv; +}; // DampedRotarySpring.prototype.applyCachedImpulse = function(dt_coef){}; - DampedRotarySpring.prototype.applyImpulse = function() - { - var a = this.a; - var b = this.b; - - // compute relative velocity - var wrn = a.w - b.w;//normal_relative_velocity(a, b, r1, r2, n) - this.target_vrn; - - // compute velocity loss from drag - // not 100% certain spring is derived correctly, though it makes sense - var w_damp = (this.target_wrn - wrn)*this.w_coef; - this.target_wrn = wrn + w_damp; - - //apply_impulses(a, b, this.r1, this.r2, vmult(this.n, v_damp*this.nMass)); - var j_damp = w_damp*this.iSum; - a.w += j_damp*a.i_inv; - b.w -= j_damp*b.i_inv; - }; +DampedRotarySpring.prototype.applyImpulse = function() +{ + var a = this.a; + var b = this.b; + + // compute relative velocity + var wrn = a.w - b.w;//normal_relative_velocity(a, b, r1, r2, n) - this.target_vrn; + + // compute velocity loss from drag + // not 100% certain spring is derived correctly, though it makes sense + var w_damp = (this.target_wrn - wrn)*this.w_coef; + this.target_wrn = wrn + w_damp; + + //apply_impulses(a, b, this.r1, this.r2, vmult(this.n, v_damp*this.nMass)); + var j_damp = w_damp*this.iSum; + a.w += j_damp*a.i_inv; + b.w -= j_damp*b.i_inv; +}; // DampedRotarySpring.prototype.getImpulse = function(){ return 0; }; - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var RotaryLimitJoint = cp.RotaryLimitJoint = function(a, b, min, max) - { - Constraint.call(this, a, b); - - this.min = min; - this.max = max; - - this.jAcc = 0; - - this.iSum = this.bias = this.jMax = 0; - }; - - RotaryLimitJoint.prototype = Object.create(Constraint.prototype); - - RotaryLimitJoint.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - var dist = b.a - a.a; - var pdist = 0; - if(dist > this.max) { - pdist = this.max - dist; - } else if(dist < this.min) { - pdist = this.min - dist; - } - - // calculate moment of inertia coefficient. - this.iSum = 1/(1/a.i + 1/b.i); - - // calculate bias velocity - var maxBias = this.maxBias; - this.bias = clamp(-bias_coef(this.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // compute max impulse - this.jMax = this.maxForce * dt; - - // If the bias is 0, the joint is not at a limit. Reset the impulse. - if(!this.bias) this.jAcc = 0; - }; - - RotaryLimitJoint.prototype.applyCachedImpulse = function(dt_coef) - { - var a = this.a; - var b = this.b; - - var j = this.jAcc*dt_coef; - a.w -= j*a.i_inv; - b.w += j*b.i_inv; - }; - - RotaryLimitJoint.prototype.applyImpulse = function() - { - if(!this.bias) return; // early exit - - var a = this.a; - var b = this.b; - - // compute relative rotational velocity - var wr = b.w - a.w; - - // compute normal impulse - var j = -(this.bias + wr)*this.iSum; - var jOld = this.jAcc; - if(this.bias < 0){ - this.jAcc = clamp(jOld + j, 0, this.jMax); - } else { - this.jAcc = clamp(jOld + j, -this.jMax, 0); - } - j = this.jAcc - jOld; - - // apply impulse - a.w -= j*a.i_inv; - b.w += j*b.i_inv; - }; - - RotaryLimitJoint.prototype.getImpulse = function() - { - return Math.abs(joint.jAcc); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var RatchetJoint = cp.RatchetJoint = function(a, b, phase, ratchet) - { - Constraint.call(this, a, b); - - this.angle = 0; - this.phase = phase; - this.ratchet = ratchet; - - // STATIC_BODY_CHECK - this.angle = (b ? b.a : 0) - (a ? a.a : 0); - - this.iSum = this.bias = this.jAcc = this.jMax = 0; - }; - - RatchetJoint.prototype = Object.create(Constraint.prototype); - - RatchetJoint.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - var angle = this.angle; - var phase = this.phase; - var ratchet = this.ratchet; - - var delta = b.a - a.a; - var diff = angle - delta; - var pdist = 0; - - if(diff*ratchet > 0){ - pdist = diff; - } else { - this.angle = Math.floor((delta - phase)/ratchet)*ratchet + phase; - } - - // calculate moment of inertia coefficient. - this.iSum = 1/(a.i_inv + b.i_inv); - - // calculate bias velocity - var maxBias = this.maxBias; - this.bias = clamp(-bias_coef(this.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // compute max impulse - this.jMax = this.maxForce * dt; - - // If the bias is 0, the joint is not at a limit. Reset the impulse. - if(!this.bias) this.jAcc = 0; - }; - - RatchetJoint.prototype.applyCachedImpulse = function(dt_coef) - { - var a = this.a; - var b = this.b; - - var j = this.jAcc*dt_coef; - a.w -= j*a.i_inv; - b.w += j*b.i_inv; - }; - - RatchetJoint.prototype.applyImpulse = function() - { - if(!this.bias) return; // early exit - - var a = this.a; - var b = this.b; - - // compute relative rotational velocity - var wr = b.w - a.w; - var ratchet = this.ratchet; - - // compute normal impulse - var j = -(this.bias + wr)*this.iSum; - var jOld = this.jAcc; - this.jAcc = clamp((jOld + j)*ratchet, 0, this.jMax*Math.abs(ratchet))/ratchet; - j = this.jAcc - jOld; - - // apply impulse - a.w -= j*a.i_inv; - b.w += j*b.i_inv; - }; - - RatchetJoint.prototype.getImpulse = function(joint) - { - return Math.abs(joint.jAcc); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var GearJoint = cp.GearJoint = function(a, b, phase, ratio) - { - Constraint.call(this, a, b); - - this.phase = phase; - this.ratio = ratio; - this.ratio_inv = 1/ratio; - - this.jAcc = 0; - - this.iSum = this.bias = this.jMax = 0; - }; - - GearJoint.prototype = Object.create(Constraint.prototype); - - GearJoint.prototype.preStep = function(dt) - { - var a = this.a; - var b = this.b; - - // calculate moment of inertia coefficient. - this.iSum = 1/(a.i_inv*this.ratio_inv + this.ratio*b.i_inv); - - // calculate bias velocity - var maxBias = this.maxBias; - this.bias = clamp(-bias_coef(this.errorBias, dt)*(b.a*this.ratio - a.a - this.phase)/dt, -maxBias, maxBias); - - // compute max impulse - this.jMax = this.maxForce * dt; - }; - - GearJoint.prototype.applyCachedImpulse = function(dt_coef) - { - var a = this.a; - var b = this.b; - - var j = this.jAcc*dt_coef; - a.w -= j*a.i_inv*this.ratio_inv; - b.w += j*b.i_inv; - }; - - GearJoint.prototype.applyImpulse = function() - { - var a = this.a; - var b = this.b; - - // compute relative rotational velocity - var wr = b.w*this.ratio - a.w; - - // compute normal impulse - var j = (this.bias - wr)*this.iSum; - var jOld = this.jAcc; - this.jAcc = clamp(jOld + j, -this.jMax, this.jMax); - j = this.jAcc - jOld; - - // apply impulse - a.w -= j*a.i_inv*this.ratio_inv; - b.w += j*b.i_inv; - }; - - GearJoint.prototype.getImpulse = function() - { - return Math.abs(this.jAcc); - }; - - GearJoint.prototype.setRatio = function(value) - { - this.ratio = value; - this.ratio_inv = 1/value; - this.activateBodies(); - }; - - /* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - var SimpleMotor = cp.SimpleMotor = function(a, b, rate) - { - Constraint.call(this, a, b); - - this.rate = rate; - - this.jAcc = 0; - - this.iSum = this.jMax = 0; - }; - - SimpleMotor.prototype = Object.create(Constraint.prototype); - - SimpleMotor.prototype.preStep = function(dt) - { - // calculate moment of inertia coefficient. - this.iSum = 1/(this.a.i_inv + this.b.i_inv); - - // compute max impulse - this.jMax = this.maxForce * dt; - }; - - SimpleMotor.prototype.applyCachedImpulse = function(dt_coef) - { - var a = this.a; - var b = this.b; - - var j = this.jAcc*dt_coef; - a.w -= j*a.i_inv; - b.w += j*b.i_inv; - }; - - SimpleMotor.prototype.applyImpulse = function() - { - var a = this.a; - var b = this.b; - - // compute relative rotational velocity - var wr = b.w - a.w + this.rate; - - // compute normal impulse - var j = -wr*this.iSum; - var jOld = this.jAcc; - this.jAcc = clamp(jOld + j, -this.jMax, this.jMax); - j = this.jAcc - jOld; - - // apply impulse - a.w -= j*a.i_inv; - b.w += j*b.i_inv; - }; - - SimpleMotor.prototype.getImpulse = function() - { - return Math.abs(this.jAcc); - }; +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var RotaryLimitJoint = cp.RotaryLimitJoint = function(a, b, min, max) +{ + Constraint.call(this, a, b); + + this.min = min; + this.max = max; + + this.jAcc = 0; + + this.iSum = this.bias = this.jMax = 0; +}; + +RotaryLimitJoint.prototype = Object.create(Constraint.prototype); + +RotaryLimitJoint.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + var dist = b.a - a.a; + var pdist = 0; + if(dist > this.max) { + pdist = this.max - dist; + } else if(dist < this.min) { + pdist = this.min - dist; + } + + // calculate moment of inertia coefficient. + this.iSum = 1/(1/a.i + 1/b.i); + + // calculate bias velocity + var maxBias = this.maxBias; + this.bias = clamp(-bias_coef(this.errorBias, dt)*pdist/dt, -maxBias, maxBias); + + // compute max impulse + this.jMax = this.maxForce * dt; + + // If the bias is 0, the joint is not at a limit. Reset the impulse. + if(!this.bias) this.jAcc = 0; +}; + +RotaryLimitJoint.prototype.applyCachedImpulse = function(dt_coef) +{ + var a = this.a; + var b = this.b; + + var j = this.jAcc*dt_coef; + a.w -= j*a.i_inv; + b.w += j*b.i_inv; +}; + +RotaryLimitJoint.prototype.applyImpulse = function() +{ + if(!this.bias) return; // early exit + + var a = this.a; + var b = this.b; + + // compute relative rotational velocity + var wr = b.w - a.w; + + // compute normal impulse + var j = -(this.bias + wr)*this.iSum; + var jOld = this.jAcc; + if(this.bias < 0){ + this.jAcc = clamp(jOld + j, 0, this.jMax); + } else { + this.jAcc = clamp(jOld + j, -this.jMax, 0); + } + j = this.jAcc - jOld; + + // apply impulse + a.w -= j*a.i_inv; + b.w += j*b.i_inv; +}; + +RotaryLimitJoint.prototype.getImpulse = function() +{ + return Math.abs(joint.jAcc); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var RatchetJoint = cp.RatchetJoint = function(a, b, phase, ratchet) +{ + Constraint.call(this, a, b); + + this.angle = 0; + this.phase = phase; + this.ratchet = ratchet; + + // STATIC_BODY_CHECK + this.angle = (b ? b.a : 0) - (a ? a.a : 0); + + this.iSum = this.bias = this.jAcc = this.jMax = 0; +}; + +RatchetJoint.prototype = Object.create(Constraint.prototype); + +RatchetJoint.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + var angle = this.angle; + var phase = this.phase; + var ratchet = this.ratchet; + + var delta = b.a - a.a; + var diff = angle - delta; + var pdist = 0; + + if(diff*ratchet > 0){ + pdist = diff; + } else { + this.angle = Math.floor((delta - phase)/ratchet)*ratchet + phase; + } + + // calculate moment of inertia coefficient. + this.iSum = 1/(a.i_inv + b.i_inv); + + // calculate bias velocity + var maxBias = this.maxBias; + this.bias = clamp(-bias_coef(this.errorBias, dt)*pdist/dt, -maxBias, maxBias); + + // compute max impulse + this.jMax = this.maxForce * dt; + + // If the bias is 0, the joint is not at a limit. Reset the impulse. + if(!this.bias) this.jAcc = 0; +}; + +RatchetJoint.prototype.applyCachedImpulse = function(dt_coef) +{ + var a = this.a; + var b = this.b; + + var j = this.jAcc*dt_coef; + a.w -= j*a.i_inv; + b.w += j*b.i_inv; +}; + +RatchetJoint.prototype.applyImpulse = function() +{ + if(!this.bias) return; // early exit + + var a = this.a; + var b = this.b; + + // compute relative rotational velocity + var wr = b.w - a.w; + var ratchet = this.ratchet; + + // compute normal impulse + var j = -(this.bias + wr)*this.iSum; + var jOld = this.jAcc; + this.jAcc = clamp((jOld + j)*ratchet, 0, this.jMax*Math.abs(ratchet))/ratchet; + j = this.jAcc - jOld; + + // apply impulse + a.w -= j*a.i_inv; + b.w += j*b.i_inv; +}; + +RatchetJoint.prototype.getImpulse = function(joint) +{ + return Math.abs(joint.jAcc); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var GearJoint = cp.GearJoint = function(a, b, phase, ratio) +{ + Constraint.call(this, a, b); + + this.phase = phase; + this.ratio = ratio; + this.ratio_inv = 1/ratio; + + this.jAcc = 0; + + this.iSum = this.bias = this.jMax = 0; +}; + +GearJoint.prototype = Object.create(Constraint.prototype); + +GearJoint.prototype.preStep = function(dt) +{ + var a = this.a; + var b = this.b; + + // calculate moment of inertia coefficient. + this.iSum = 1/(a.i_inv*this.ratio_inv + this.ratio*b.i_inv); + + // calculate bias velocity + var maxBias = this.maxBias; + this.bias = clamp(-bias_coef(this.errorBias, dt)*(b.a*this.ratio - a.a - this.phase)/dt, -maxBias, maxBias); + + // compute max impulse + this.jMax = this.maxForce * dt; +}; + +GearJoint.prototype.applyCachedImpulse = function(dt_coef) +{ + var a = this.a; + var b = this.b; + + var j = this.jAcc*dt_coef; + a.w -= j*a.i_inv*this.ratio_inv; + b.w += j*b.i_inv; +}; + +GearJoint.prototype.applyImpulse = function() +{ + var a = this.a; + var b = this.b; + + // compute relative rotational velocity + var wr = b.w*this.ratio - a.w; + + // compute normal impulse + var j = (this.bias - wr)*this.iSum; + var jOld = this.jAcc; + this.jAcc = clamp(jOld + j, -this.jMax, this.jMax); + j = this.jAcc - jOld; + + // apply impulse + a.w -= j*a.i_inv*this.ratio_inv; + b.w += j*b.i_inv; +}; + +GearJoint.prototype.getImpulse = function() +{ + return Math.abs(this.jAcc); +}; + +GearJoint.prototype.setRatio = function(value) +{ + this.ratio = value; + this.ratio_inv = 1/value; + this.activateBodies(); +}; + +/* Copyright (c) 2007 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +var SimpleMotor = cp.SimpleMotor = function(a, b, rate) +{ + Constraint.call(this, a, b); + + this.rate = rate; + + this.jAcc = 0; + + this.iSum = this.jMax = 0; +}; + +SimpleMotor.prototype = Object.create(Constraint.prototype); + +SimpleMotor.prototype.preStep = function(dt) +{ + // calculate moment of inertia coefficient. + this.iSum = 1/(this.a.i_inv + this.b.i_inv); + + // compute max impulse + this.jMax = this.maxForce * dt; +}; + +SimpleMotor.prototype.applyCachedImpulse = function(dt_coef) +{ + var a = this.a; + var b = this.b; + + var j = this.jAcc*dt_coef; + a.w -= j*a.i_inv; + b.w += j*b.i_inv; +}; + +SimpleMotor.prototype.applyImpulse = function() +{ + var a = this.a; + var b = this.b; + + // compute relative rotational velocity + var wr = b.w - a.w + this.rate; + + // compute normal impulse + var j = -wr*this.iSum; + var jOld = this.jAcc; + this.jAcc = clamp(jOld + j, -this.jMax, this.jMax); + j = this.jAcc - jOld; + + // apply impulse + a.w -= j*a.i_inv; + b.w += j*b.i_inv; +}; + +SimpleMotor.prototype.getImpulse = function() +{ + return Math.abs(this.jAcc); +}; })(); From d6a5d24f23d4871716b4a21e0fbae3724201921e Mon Sep 17 00:00:00 2001 From: kimon Date: Thu, 18 Sep 2014 18:43:28 +0300 Subject: [PATCH 0663/1564] Applying canvas scaling to particles in html5 canvas rendering mode --- cocos2d/particle/CCParticleSystem.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 5e9f700298..0cecdc0ea0 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2414,6 +2414,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ context.globalCompositeOperation = 'source-over'; var element = this._texture.getHtmlElementObj(); + var locScaleX = cc.view.getScaleX(), locScaleY = cc.view.getScaleY(); + for (var i = 0; i < this.particleCount; i++) { var particle = this._particles[i]; var lpx = (0 | (particle.size * 0.5)); @@ -2432,8 +2434,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ var h = this._pointRect.height; context.scale( - Math.max((1 / w) * size, 0.000001), - Math.max((1 / h) * size, 0.000001) + Math.max(size * locScaleX / w, 0.000001), + Math.max(size * locScaleY / h, 0.000001) ); if (particle.rotation) From 60f3d48cbc7bd21f0d0a91b871ec000ad4477723 Mon Sep 17 00:00:00 2001 From: Claudio Freitas Date: Fri, 19 Sep 2014 02:19:01 -0300 Subject: [PATCH 0664/1564] Fixes the type of the property 'placeHolder' from Number to String. --- extensions/ccui/uiwidgets/UITextField.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 948688df29..463f526841 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -219,7 +219,7 @@ ccui._TextFieldRenderer.create = function (placeholder, fontName, fontSize) { * @extends ccui.Widget * * @property {String} string - The content string of the label - * @property {Number} placeHolder - The place holder of the text field + * @property {String} placeHolder - The place holder of the text field * @property {String} font - The text field font with a style string: e.g. "18px Verdana" * @property {String} fontName - The text field font name * @property {Number} fontSize - The text field font size From 78102af4c5d556b467899f4d153e3967e90a0b81 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 19 Sep 2014 16:51:05 +0800 Subject: [PATCH 0665/1564] Issue #5933: Clipping Node --- cocos2d/clipping-nodes/CCClippingNode.js | 172 ++++++++++++++++------- cocos2d/core/renderer/RendererCanvas.js | 91 +++++++++--- 2 files changed, 192 insertions(+), 71 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index e5168d5601..27899ed500 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -80,6 +80,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ _stencil: null, _godhelpme: false, + _clipElemType: null, /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. @@ -366,66 +367,42 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ }, _visitForCanvas: function (ctx) { - // return fast (draw nothing, or draw everything if in inverted mode) if: - // - nil stencil node - // - or stencil node invisible: + + this._transformDirty = false; + this.setNodeDirty(); + + // Composition mode, costy but support texture stencil + if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) { + this._clipElemType = true; + }else{ + this._clipElemType = false; + } + var context = ctx || cc._renderContext; + var i, children = this._children, locChild; + if (!this._stencil || !this._stencil.visible) { if (this.inverted) cc.Node.prototype.visit.call(this, ctx); // draw everything return; } - var context = ctx || cc._renderContext; - var canvas = context.canvas; - // Composition mode, costy but support texture stencil - if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) { - // Cache the current canvas, for later use (This is a little bit heavy, replace this solution with other walkthrough) - var locCache = cc.ClippingNode._getSharedCache(); - locCache.width = canvas.width; - locCache.height = canvas.height; - var locCacheCtx = locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - - context.save(); - // Draw everything first using node visit function - cc.Node.prototype.visit.call(this, context); - - context.globalCompositeOperation = this.inverted ? "destination-out" : "destination-in"; - - this.transform(context); - this._stencil.visit(); + if(this._rendererSaveCmd) + cc.renderer.pushRenderCommand(this._rendererSaveCmd); - context.restore(); + if(this._clipElemType){ - // Redraw the cached canvas, so that the cliped area shows the background etc. - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalCompositeOperation = "destination-over"; - context.drawImage(locCache, 0, 0); - context.restore(); - } - // Clip mode, fast, but only support cc.DrawNode - else { - var i, children = this._children, locChild; - - context.save(); - this.transform(context); + // Draw everything first using node visit function + cc.Node.prototype.visit.call(this, context); + }else{ this._stencil.visit(context); - if (this.inverted) { - context.save(); - - context.setTransform(1, 0, 0, 1, 0, 0); + } - context.moveTo(0, 0); - context.lineTo(0, canvas.height); - context.lineTo(canvas.width, canvas.height); - context.lineTo(canvas.width, 0); - context.lineTo(0, 0); - - context.restore(); - } - context.clip(); + if(this._rendererClipCmd) + cc.renderer.pushRenderCommand(this._rendererClipCmd); + if(this._clipElemType){ + this._stencil.visit(); + }else{ // Clip mode doesn't support recusive stencil, so once we used a clip stencil, // so if it has ClippingNode as a child, the child must uses composition stencil. this._cangodhelpme(true); @@ -440,16 +417,107 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ else break; } - this.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); for (; i < len; i++) { children[i].visit(context); } } else - this.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); this._cangodhelpme(false); - context.restore(); } + + if(this._rendererRestoreCmd) + cc.renderer.pushRenderCommand(this._rendererRestoreCmd); + + +// return; +// // return fast (draw nothing, or draw everything if in inverted mode) if: +// // - nil stencil node +// // - or stencil node invisible: +// if (!this._stencil || !this._stencil.visible) { +// if (this.inverted) +// cc.Node.prototype.visit.call(this, ctx); // draw everything +// return; +// } +// +// var context = ctx || cc._renderContext; +// var canvas = context.canvas; +// // Composition mode, costy but support texture stencil +// if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) { +// // Cache the current canvas, for later use (This is a little bit heavy, replace this solution with other walkthrough) +// var locCache = cc.ClippingNode._getSharedCache(); +// locCache.width = canvas.width; +// locCache.height = canvas.height; +// var locCacheCtx = locCache.getContext("2d"); +// locCacheCtx.drawImage(canvas, 0, 0); +// +// context.save(); +// // Draw everything first using node visit function +// cc.Node.prototype.visit.call(this, context); +// +// context.globalCompositeOperation = this.inverted ? "destination-out" : "destination-in"; +// +// this.transform(context); +// this._stencil.visit(); +// +// context.restore(); +// +// // Redraw the cached canvas, so that the cliped area shows the background etc. +// context.save(); +// context.setTransform(1, 0, 0, 1, 0, 0); +// context.globalCompositeOperation = "destination-over"; +// context.drawImage(locCache, 0, 0); +// context.restore(); +// } +// // Clip mode, fast, but only support cc.DrawNode +// else { +// var i, children = this._children, locChild; +// +// context.save(); +// this.transform(context); +// this._stencil.visit(context); +// if (this.inverted) { +// context.save(); +// +// context.setTransform(1, 0, 0, 1, 0, 0); +// +// context.moveTo(0, 0); +// context.lineTo(0, canvas.height); +// context.lineTo(canvas.width, canvas.height); +// context.lineTo(canvas.width, 0); +// context.lineTo(0, 0); +// +// context.restore(); +// } +// context.clip(); +// +// // Clip mode doesn't support recusive stencil, so once we used a clip stencil, +// // so if it has ClippingNode as a child, the child must uses composition stencil. +// this._cangodhelpme(true); +// var len = children.length; +// if (len > 0) { +// this.sortAllChildren(); +// // draw children zOrder < 0 +// for (i = 0; i < len; i++) { +// locChild = children[i]; +// if (locChild._localZOrder < 0) +// locChild.visit(context); +// else +// break; +// } +// this.draw(context); +// for (; i < len; i++) { +// children[i].visit(context); +// } +// } else +// this.draw(context); +// this._cangodhelpme(false); +// +// context.restore(); +// } }, /** diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index a874d4bd7d..b1ee325a04 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -597,13 +597,24 @@ cc.ClippingNodeSaveRenderCmdCanvas = function(node){ }; cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - + var node = this._node; var context = ctx || cc._renderContext; - context.save(); - - var t = this._node._transformWorld; - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if(node._clipElemType){ + var locCache = cc.ClippingNode._getSharedCache(); + var canvas = context.canvas; + locCache.width = canvas.width; + locCache.height = canvas.height; + var locCacheCtx = locCache.getContext("2d"); + locCacheCtx.drawImage(canvas, 0, 0); + context.save(); + }else{ + node.transform(); + var t = node._transformWorld; + context.save(); + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } }; cc.ClippingNodeClipRenderCmdCanvas = function(node){ @@ -611,24 +622,31 @@ cc.ClippingNodeClipRenderCmdCanvas = function(node){ }; cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + var node = this._node; var context = ctx || cc._renderContext; - if (this._node.inverted) { - var canvas = context.canvas; - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); + if(node._clipElemType){ + context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; + var t = node._transformWorld; + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + }else{ + context.restore(); + if (node.inverted) { + var canvas = context.canvas; + context.save(); - context.moveTo(0, 0); - context.lineTo(0, canvas.height); - context.lineTo(canvas.width, canvas.height); - context.lineTo(canvas.width, 0); - context.lineTo(0, 0); + context.setTransform(1, 0, 0, 1, 0, 0); - context.restore(); + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); + + context.restore(); + } + context.clip(); } - var t = cc.affineTransformInvert(this._node._transformWorld); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.clip(); }; cc.ClippingNodeRestoreRenderCmdCanvas = function(node){ @@ -636,8 +654,43 @@ cc.ClippingNodeRestoreRenderCmdCanvas = function(node){ }; cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + + var node = this._node; + var i, children = node._children, locChild; + var locCache = cc.ClippingNode._getSharedCache(); var context = ctx || cc._renderContext; - context.restore(); + if(node._clipElemType){ + context.restore(); + + // Redraw the cached canvas, so that the cliped area shows the background etc. + context.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.globalCompositeOperation = "destination-over"; + context.drawImage(locCache, 0, 0); + context.restore(); + }else{ + // so if it has ClippingNode as a child, the child must uses composition stencil. + node._cangodhelpme(true); + var len = children.length; + if (len > 0) { + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + locChild = children[i]; + if (locChild._localZOrder < 0) + locChild.visit(context); + else + break; + } + node.draw(context); + for (; i < len; i++) { + children[i].visit(context); + } + } else + node.draw(context); + node._cangodhelpme(false); + context.restore(); + } }; From 825466ecd0a5a4de7b03ecacc9e3acc57d94ea6f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 22 Sep 2014 09:46:13 +0800 Subject: [PATCH 0666/1564] Issue #5933: Clipping Node --- cocos2d/clipping-nodes/CCClippingNode.js | 96 ++---------------------- 1 file changed, 6 insertions(+), 90 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 27899ed500..e77097f065 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -368,9 +368,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ _visitForCanvas: function (ctx) { - this._transformDirty = false; - this.setNodeDirty(); - // Composition mode, costy but support texture stencil if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) { this._clipElemType = true; @@ -400,6 +397,8 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ if(this._rendererClipCmd) cc.renderer.pushRenderCommand(this._rendererClipCmd); + this.transform(); + if(this._clipElemType){ this._stencil.visit(); }else{ @@ -431,93 +430,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ if(this._rendererRestoreCmd) cc.renderer.pushRenderCommand(this._rendererRestoreCmd); - - -// return; -// // return fast (draw nothing, or draw everything if in inverted mode) if: -// // - nil stencil node -// // - or stencil node invisible: -// if (!this._stencil || !this._stencil.visible) { -// if (this.inverted) -// cc.Node.prototype.visit.call(this, ctx); // draw everything -// return; -// } -// -// var context = ctx || cc._renderContext; -// var canvas = context.canvas; -// // Composition mode, costy but support texture stencil -// if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) { -// // Cache the current canvas, for later use (This is a little bit heavy, replace this solution with other walkthrough) -// var locCache = cc.ClippingNode._getSharedCache(); -// locCache.width = canvas.width; -// locCache.height = canvas.height; -// var locCacheCtx = locCache.getContext("2d"); -// locCacheCtx.drawImage(canvas, 0, 0); -// -// context.save(); -// // Draw everything first using node visit function -// cc.Node.prototype.visit.call(this, context); -// -// context.globalCompositeOperation = this.inverted ? "destination-out" : "destination-in"; -// -// this.transform(context); -// this._stencil.visit(); -// -// context.restore(); -// -// // Redraw the cached canvas, so that the cliped area shows the background etc. -// context.save(); -// context.setTransform(1, 0, 0, 1, 0, 0); -// context.globalCompositeOperation = "destination-over"; -// context.drawImage(locCache, 0, 0); -// context.restore(); -// } -// // Clip mode, fast, but only support cc.DrawNode -// else { -// var i, children = this._children, locChild; -// -// context.save(); -// this.transform(context); -// this._stencil.visit(context); -// if (this.inverted) { -// context.save(); -// -// context.setTransform(1, 0, 0, 1, 0, 0); -// -// context.moveTo(0, 0); -// context.lineTo(0, canvas.height); -// context.lineTo(canvas.width, canvas.height); -// context.lineTo(canvas.width, 0); -// context.lineTo(0, 0); -// -// context.restore(); -// } -// context.clip(); -// -// // Clip mode doesn't support recusive stencil, so once we used a clip stencil, -// // so if it has ClippingNode as a child, the child must uses composition stencil. -// this._cangodhelpme(true); -// var len = children.length; -// if (len > 0) { -// this.sortAllChildren(); -// // draw children zOrder < 0 -// for (i = 0; i < len; i++) { -// locChild = children[i]; -// if (locChild._localZOrder < 0) -// locChild.visit(context); -// else -// break; -// } -// this.draw(context); -// for (; i < len; i++) { -// children[i].visit(context); -// } -// } else -// this.draw(context); -// this._cangodhelpme(false); -// -// context.restore(); -// } }, /** @@ -560,11 +472,14 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ scaleX = scaleX || cc.view.getScaleX(); scaleY = scaleY ||cc.view.getScaleY(); var context = ctx || cc._renderContext; + var t = this._node._transformWorld; + context.save(); context.beginPath(); for (var i = 0; i < stencil._buffer.length; i++) { var element = stencil._buffer[i]; var vertices = element.verts; + context.transform(t.a, t.b, t.c, t.d, t.tx, -t.ty); //cc.assert(cc.vertexListIsClockwise(vertices), // "Only clockwise polygons should be used as stencil"); @@ -573,6 +488,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ for (var j = 1, len = vertices.length; j < len; j++) context.lineTo(vertices[j].x * scaleX, -vertices[j].y * scaleY); } + context.restore(); }; } }, From 8fc7f78c2320809b4928e3059f956b8041fa8096 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 22 Sep 2014 10:10:20 +0800 Subject: [PATCH 0667/1564] Issue #5941: adds WebGL renderer to H5 --- cocos2d/core/base-nodes/BaseNodesWebGL.js | 67 +- cocos2d/core/layers/CCLayerWebGL.js | 12 +- cocos2d/core/renderer/RendererCanvas.js | 1288 ++++++++++----------- cocos2d/core/renderer/RendererWebGL.js | 177 +++ cocos2d/core/sprites/SpritesWebGL.js | 4 + cocos2d/shaders/CCGLProgram.js | 6 + moduleConfig.json | 1 + template/project.json | 2 +- 8 files changed, 897 insertions(+), 660 deletions(-) create mode 100644 cocos2d/core/renderer/RendererWebGL.js diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index c3d640e7a9..64f5582f21 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -49,10 +49,16 @@ cc._tmp.WebGLCCNode = function () { _t._transform4x4 = mat4; _t._glServerState = 0; _t._stackMatrix = new cc.kmMat4(); + this._initRendererCmd(); }; _p.setNodeDirty = function () { - this._transformDirty === false && (this._transformDirty = this._inverseDirty = true); + var _t = this; + if(_t._transformDirty === false){ + _t._setNodeDirtyForCache(); + _t._renderCmdDiry = _t._transformDirty = _t._inverseDirty = true; + cc.renderer.pushDirtyNode(this); + } }; _p.visit = function () { @@ -60,18 +66,23 @@ cc._tmp.WebGLCCNode = function () { // quick return if not visible if (!_t._visible) return; + + if( _t._parent) + _t._curLevel = _t._parent._curLevel + 1; + var context = cc._renderContext, i, currentStack = cc.current_stack; - //cc.kmGLPushMatrixWitMat4(_t._stackMatrix); //optimize performance for javascript currentStack.stack.push(currentStack.top); cc.kmMat4Assign(_t._stackMatrix, currentStack.top); currentStack.top = _t._stackMatrix; - var locGrid = _t.grid; + //TODO GridNode +/* var locGrid = _t.grid; if (locGrid && locGrid._active) - locGrid.beforeDraw(); + locGrid.beforeDraw();*/ + _t.toRenderer(); _t.transform(); var locChildren = _t._children; @@ -85,32 +96,65 @@ cc._tmp.WebGLCCNode = function () { else break; } - _t.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); // draw children zOrder >= 0 for (; i < childLen; i++) { if (locChildren[i]) { locChildren[i].visit(); } } - } else - _t.draw(context); + } else{ + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); + } _t.arrivalOrder = 0; - if (locGrid && locGrid._active) - locGrid.afterDraw(_t); + + //TODO GridNode +/* if (locGrid && locGrid._active) + locGrid.afterDraw(_t);*/ //cc.kmGLPopMatrix(); //optimize performance for javascript currentStack.top = currentStack.stack.pop(); }; + _p._transformForRenderer = function () { //TODO parentMatrix + var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, + parentMatrix = this._parent ? this._parent._stackMatrix : cc.current_stack.top; + + // Convert 3x3 into 4x4 matrix + var trans = this.nodeToParentTransform(); + var t4x4Mat = t4x4.mat; + t4x4Mat[0] = trans.a; + t4x4Mat[4] = trans.c; + t4x4Mat[12] = trans.tx; + t4x4Mat[1] = trans.b; + t4x4Mat[5] = trans.d; + t4x4Mat[13] = trans.ty; + + // Update Z vertex manually + t4x4Mat[14] = this._vertexZ; + + //optimize performance for Javascript + cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); + + this._renderCmdDiry = false; + if(!this._children || this._children.length === 0) + return; + var i, len, locChildren = this._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._transformForRenderer(); + } + }; + _p.transform = function () { var _t = this; //optimize performance for javascript var t4x4 = _t._transform4x4, topMat4 = cc.current_stack.top; // Convert 3x3 into 4x4 matrix - //cc.CGAffineToGL(_t.nodeToParentTransform(), _t._transform4x4.mat); var trans = _t.nodeToParentTransform(); var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; @@ -121,11 +165,10 @@ cc._tmp.WebGLCCNode = function () { t4x4Mat[13] = trans.ty; // Update Z vertex manually - //_t._transform4x4.mat[14] = _t._vertexZ; t4x4Mat[14] = _t._vertexZ; //optimize performance for Javascript - cc.kmMat4Multiply(topMat4, topMat4, t4x4); // = cc.kmGLMultMatrix(_t._transform4x4); + cc.kmMat4Multiply(topMat4, topMat4, t4x4); // XXX: Expensive calls. Camera should be integrated into the cached affine matrix if (_t._camera != null && !(_t.grid != null && _t.grid.isActive())) { diff --git a/cocos2d/core/layers/CCLayerWebGL.js b/cocos2d/core/layers/CCLayerWebGL.js index 77a3579333..4000438c2c 100644 --- a/cocos2d/core/layers/CCLayerWebGL.js +++ b/cocos2d/core/layers/CCLayerWebGL.js @@ -64,6 +64,9 @@ cc._tmp.WebGLLayerColor = function () { cc.LayerColor.prototype.init.call(_t, color, width, height); }; + _p._initRendererCmd = function(){ + this._rendererCmd = new cc.RectRenderCmdWebGL(this); + }; _p.setContentSize = function (size, height) { var locSquareVertices = this._squareVertices; if (height === undefined) { @@ -135,11 +138,14 @@ cc._tmp.WebGLLayerColor = function () { glContext.bufferData(glContext.ARRAY_BUFFER, this._squareColorsAB, glContext.STATIC_DRAW); }; //cc.LayerColor define end -} +}; cc._tmp.WebGLLayerGradient = function () { //cc.LayerGradient define start var _p = cc.LayerGradient.prototype; + _p._initRendererCmd = function(){ + this._rendererCmd = new cc.RectRenderCmdWebGL(this); + }; _p.draw = cc.LayerColor.prototype.draw; _p._updateColor = function () { var _t = this; @@ -185,6 +191,6 @@ cc._tmp.WebGLLayerGradient = function () { locSquareColor3.a = ((E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0 * c)))); _t._bindLayerColorsBufferData(); - } + }; //cc.LayerGradient define end -} \ No newline at end of file +}; \ No newline at end of file diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index a874d4bd7d..f92e44e5f8 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -1,6 +1,4 @@ /**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -24,101 +22,102 @@ THE SOFTWARE. ****************************************************************************/ -cc.rendererCanvas = { - childrenOrderDirty: true, - _transformNodePool: [], //save nodes transform dirty - _renderCmds: [], //save renderer commands - - _isCacheToCanvasOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds - _cacheToCanvasCmds: [], // an array saves the renderer commands need for cache to other canvas - - /** - * drawing all renderer command to context (default is cc._renderContext) - * @param {CanvasRenderingContext2D} [ctx=cc._renderContext] - */ - rendering: function (ctx) { - var locCmds = this._renderCmds, - i, - len, - scaleX = cc.view.getScaleX(), - scaleY = cc.view.getScaleY(); - var context = ctx || cc._renderContext; - for (i = 0, len = locCmds.length; i < len; i++) { - locCmds[i].rendering(context, scaleX, scaleY); - } - }, - - /** - * drawing all renderer command to cache canvas' context - * @param {CanvasRenderingContext2D} ctx - */ - _renderingToCacheCanvas: function (ctx) { - var locCmds = this._cacheToCanvasCmds, i, len; - if (!ctx) - cc.log("The context of RenderTexture is invalid."); - for (i = 0, len = locCmds.length; i < len; i++) { - locCmds[i].rendering(ctx, 1, 1); - } +if(cc._renderType === cc._RENDER_TYPE_CANVAS) { + cc.rendererCanvas = { + childrenOrderDirty: true, + _transformNodePool: [], //save nodes transform dirty + _renderCmds: [], //save renderer commands + + _isCacheToCanvasOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds + _cacheToCanvasCmds: [], // an array saves the renderer commands need for cache to other canvas + + /** + * drawing all renderer command to context (default is cc._renderContext) + * @param {CanvasRenderingContext2D} [ctx=cc._renderContext] + */ + rendering: function (ctx) { + var locCmds = this._renderCmds, + i, + len, + scaleX = cc.view.getScaleX(), + scaleY = cc.view.getScaleY(); + var context = ctx || cc._renderContext; + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(context, scaleX, scaleY); + } + }, + + /** + * drawing all renderer command to cache canvas' context + * @param {CanvasRenderingContext2D} ctx + */ + _renderingToCacheCanvas: function (ctx) { + var locCmds = this._cacheToCanvasCmds, i, len; + if (!ctx) + cc.log("The context of RenderTexture is invalid."); + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(ctx, 1, 1); + } - locCmds.length = 0; - this._isCacheToCanvasOn = false; - }, + locCmds.length = 0; + this._isCacheToCanvasOn = false; + }, - resetFlag: function () { - this.childrenOrderDirty = false; - this._transformNodePool.length = 0; - }, + resetFlag: function () { + this.childrenOrderDirty = false; + this._transformNodePool.length = 0; + }, - transform: function () { - var locPool = this._transformNodePool; - //sort the pool - locPool.sort(this._sortNodeByLevelAsc); + transform: function () { + var locPool = this._transformNodePool; + //sort the pool + locPool.sort(this._sortNodeByLevelAsc); - //transform node - for (var i = 0, len = locPool.length; i < len; i++) { - if (locPool[i]._renderCmdDiry) //TODO need modify name for LabelTTF - locPool[i]._transformForRenderer(); - } - locPool.length = 0; - }, - - transformDirty: function () { - return this._transformNodePool.length > 0; - }, - - _sortNodeByLevelAsc: function (n1, n2) { - return n1._curLevel - n2._curLevel; - }, - - pushDirtyNode: function (node) { - //if (this._transformNodePool.indexOf(node) === -1) - this._transformNodePool.push(node); - }, - - clearRenderCommands: function () { - this._renderCmds.length = 0; - }, - - pushRenderCommand: function (cmd) { - if (this._isCacheToCanvasOn) { - if (this._cacheToCanvasCmds.indexOf(cmd) === -1) - this._cacheToCanvasCmds.push(cmd); - } else { - if (this._renderCmds.indexOf(cmd) === -1) - this._renderCmds.push(cmd); + //transform node + for (var i = 0, len = locPool.length; i < len; i++) { + if (locPool[i]._renderCmdDiry) //TODO need modify name for LabelTTF + locPool[i]._transformForRenderer(); + } + locPool.length = 0; + }, + + transformDirty: function () { + return this._transformNodePool.length > 0; + }, + + _sortNodeByLevelAsc: function (n1, n2) { + return n1._curLevel - n2._curLevel; + }, + + pushDirtyNode: function (node) { + //if (this._transformNodePool.indexOf(node) === -1) + this._transformNodePool.push(node); + }, + + clearRenderCommands: function () { + this._renderCmds.length = 0; + }, + + pushRenderCommand: function (cmd) { + if (this._isCacheToCanvasOn) { + if (this._cacheToCanvasCmds.indexOf(cmd) === -1) + this._cacheToCanvasCmds.push(cmd); + } else { + if (this._renderCmds.indexOf(cmd) === -1) + this._renderCmds.push(cmd); + } } - } -}; -cc.renderer = cc.rendererCanvas; - -cc.TextureRenderCmdCanvas = function (node) { - this._node = node; - - this._transform = node._transformWorld; //reference of node's transformWorld - this._texture = null; - this._isLighterMode = false; - this._opacity = 1; - this._textureCoord = { + }; + cc.renderer = cc.rendererCanvas; + + cc.TextureRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; //reference of node's transformWorld + this._texture = null; + this._isLighterMode = false; + this._opacity = 1; + this._textureCoord = { renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. x: 0, //the x of texture coordinate for node. @@ -127,614 +126,615 @@ cc.TextureRenderCmdCanvas = function (node) { height: 0, validRect: false // }; - this._drawingRect = cc.rect(0, 0, 0, 0); -}; - -cc.TextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var _t = this; - var _node = _t._node; - var context = ctx || cc._renderContext, - locTextureCoord = _t._textureCoord; - if (!locTextureCoord.validRect || !_node._visible) - return; //draw nothing - - var t = this._transform, locDrawingRect = _t._drawingRect, image, curColor; - if(t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || _node._flippedX || _node._flippedY){ + this._drawingRect = cc.rect(0, 0, 0, 0); + }; + + cc.TextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var _t = this; + var _node = _t._node; + var context = ctx || cc._renderContext, + locTextureCoord = _t._textureCoord; + if (!locTextureCoord.validRect || !_node._visible) + return; //draw nothing + + var t = this._transform, locDrawingRect = _t._drawingRect, image, curColor; + if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || _node._flippedX || _node._flippedY) { + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (_t._isLighterMode) + context.globalCompositeOperation = 'lighter'; + + if (_node._flippedX) + context.scale(-1, 1); + if (_node._flippedY) + context.scale(1, -1); + + if (_t._texture && locTextureCoord.validRect) { + if (_t._texture._isLoaded) { + context.globalAlpha = _t._opacity; + image = _t._texture._htmlElementObj; + + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locDrawingRect.x, + locDrawingRect.y, + locDrawingRect.width, + locDrawingRect.height + ); + + } + + } else if (!_t._texture && locTextureCoord.validRect) { + curColor = _t._color; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; + context.fillRect(locDrawingRect.x, locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + } + context.restore(); + } else { + if (_t._isLighterMode) { + context.save(); + context.globalCompositeOperation = 'lighter'; + } + + if (_t._texture && locTextureCoord.validRect) { + if (_t._texture._isLoaded) { + context.globalAlpha = _t._opacity; + image = _t._texture._htmlElementObj; + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + t.tx * scaleX + locDrawingRect.x, + -t.ty * scaleY + locDrawingRect.y, + locDrawingRect.width, + locDrawingRect.height + ); + } + } else if (!_t._texture && locTextureCoord.validRect && _node._displayedColor) { + curColor = _node._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; + context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + } + if (_t._isLighterMode) + context.restore(); + } + cc.g_NumberOfDraws++; + }; + + cc.RectRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._isLighterMode = false; + this._drawingRect = cc.rect(0, 0, 0, 0); + this._color = cc.color(255, 255, 255, 255); + }; + + cc.RectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, t = this._transform, curColor = this._color, locRect = this._drawingRect; context.save(); + if (this._isLighterMode) + context.globalCompositeOperation = 'lighter'; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," + + (0 | curColor.b) + "," + curColor.a + ")"; + context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); + context.restore(); + cc.g_NumberOfDraws++; + }; + + cc.GradientRectRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; // {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._isLighterMode = false; + this._opacity = 1; + this._drawingRect = cc.rect(0, 0, 0, 0); + this._startColor = cc.color(255, 255, 255, 255); + this._endColor = cc.color(255, 255, 255, 255); + this._startPoint = cc.p(0, 0); + this._endPoint = cc.p(0, 0); + }; + + cc.GradientRectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, _t = this, t = this._transform; + context.save(); if (_t._isLighterMode) context.globalCompositeOperation = 'lighter'; + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (_node._flippedX) - context.scale(-1, 1); - if (_node._flippedY) - context.scale(1, -1); - - if (_t._texture && locTextureCoord.validRect) { - if (_t._texture._isLoaded) { - context.globalAlpha = _t._opacity; - image = _t._texture._htmlElementObj; - - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locDrawingRect.x, - locDrawingRect.y, - locDrawingRect.width, - locDrawingRect.height - ); + var opacity = _t._opacity, locRect = this._drawingRect; + //TODO need cache gradient object + var gradient = context.createLinearGradient(_t._startPoint.x, _t._startPoint.y, _t._endPoint.x, _t._endPoint.y); + var locStartColor = _t._startColor, locEndColor = _t._endColor; + gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," + + Math.round(locStartColor.b) + "," + (opacity * (locStartColor.a / 255)).toFixed(4) + ")"); + gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + + Math.round(locEndColor.b) + "," + (opacity * (locEndColor.a / 255)).toFixed(4) + ")"); + context.fillStyle = gradient; + context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); + context.restore(); + cc.g_NumberOfDraws++; + }; + + cc.ParticleRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._isBlendAdditive = false; + this._drawMode = cc.ParticleSystem.SHAPE_MODE; + this._shapeType = cc.ParticleSystem.BALL_SHAPE; + this._texture = null; + this._pointRect = {x: 0, y: 0, width: 0, height: 0}; + }; + + cc.ParticleRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, t = this._transform; + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if (this._isBlendAdditive) + context.globalCompositeOperation = 'lighter'; + else + context.globalCompositeOperation = 'source-over'; + + var i, particle, lpx; + var particleCount = this._node.particleCount, particles = this._node._particles; + if (this._drawMode == cc.ParticleSystem.TEXTURE_MODE) { + // Delay drawing until the texture is fully loaded by the browser + if (!this._texture || !this._texture._isLoaded) { + context.restore(); + return; } + var element = this._texture.getHtmlElementObj(); + if (!element.width || !element.height) { + context.restore(); + return; + } + + var textureCache = cc.textureCache, drawElement = element; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + + context.globalAlpha = particle.color.a / 255; + + context.save(); + context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); + + var size = Math.floor(particle.size / 4) * 4; + var w = this._pointRect.width; + var h = this._pointRect.height; + + context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); - } else if (!_t._texture && locTextureCoord.validRect) { - curColor = _t._color; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; - context.fillRect(locDrawingRect.x, locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + + if (particle.isChangeColor) { + var cacheTextureForColor = textureCache.getTextureColors(element); + if (cacheTextureForColor) { + // Create another cache for the tinted version + // This speeds up things by a fair bit + if (!cacheTextureForColor.tintCache) { + cacheTextureForColor.tintCache = cc.newElement('canvas'); + cacheTextureForColor.tintCache.width = element.width; + cacheTextureForColor.tintCache.height = element.height; + } + cc.generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); + drawElement = cacheTextureForColor.tintCache; + } + } + context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); + context.restore(); + } + } else { + var drawTool = cc._drawingUtil; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + context.globalAlpha = particle.color.a / 255; + + context.save(); + context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); + if (this._shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + drawTool.drawStar(context, lpx, particle.color); + } else + drawTool.drawColorBall(context, lpx, particle.color); + context.restore(); + } } context.restore(); - } else { - if (_t._isLighterMode){ - context.save(); + cc.g_NumberOfDraws++; + }; + +// the canvas implement of renderCommand for cc.ProgressTimer + cc.ProgressRenderCmdCanvas = function (node) { + this._PI180 = Math.PI / 180; + + this._node = node; + this._transform = node._transformWorld; + this._sprite = null; + this._type = cc.ProgressTimer.TYPE_RADIAL; + this._barRect = cc.rect(0, 0, 0, 0); + this._origin = cc.p(0, 0); + this._radius = 0; + this._startAngle = 270; + this._endAngle = 270; + this._counterClockWise = false; + }; + + cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, locSprite = this._sprite; + + var locTextureCoord = locSprite._rendererCmd._textureCoord; + if (!locSprite._texture || !locTextureCoord.validRect) + return; + + var t = this._transform; + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (locSprite._isLighterMode) context.globalCompositeOperation = 'lighter'; - } - if (_t._texture && locTextureCoord.validRect) { - if (_t._texture._isLoaded) { - context.globalAlpha = _t._opacity; - image = _t._texture._htmlElementObj; - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - t.tx * scaleX + locDrawingRect.x, - -t.ty * scaleY + locDrawingRect.y, - locDrawingRect.width, - locDrawingRect.height - ); - } - } else if (!_t._texture && locTextureCoord.validRect && _node._displayedColor) { - curColor = _node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; - context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + context.globalAlpha = locSprite._displayedOpacity / 255; + + var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; + var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; + locDrawSizeCanvas.width = locRect.width * scaleX; + locDrawSizeCanvas.height = locRect.height * scaleY; + + if (locSprite._flippedX) { + flipXOffset = -locOffsetPosition.x - locRect.width; + context.scale(-1, 1); } - if (_t._isLighterMode) - context.restore(); - } - cc.g_NumberOfDraws++; -}; - -cc.RectRenderCmdCanvas = function (node) { - this._node = node; - - this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._isLighterMode = false; - this._drawingRect = cc.rect(0, 0, 0, 0); - this._color = cc.color(255, 255, 255, 255); -}; - -cc.RectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, t = this._transform, curColor = this._color, locRect = this._drawingRect; - context.save(); - if (this._isLighterMode) - context.globalCompositeOperation = 'lighter'; - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," - + (0 | curColor.b) + "," + curColor.a + ")"; - context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); - - context.restore(); - cc.g_NumberOfDraws++; -}; - -cc.GradientRectRenderCmdCanvas = function (node) { - this._node = node; - - this._transform = node._transformWorld; // {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._isLighterMode = false; - this._opacity = 1; - this._drawingRect = cc.rect(0, 0, 0, 0); - this._startColor = cc.color(255, 255, 255, 255); - this._endColor = cc.color(255, 255, 255, 255); - this._startPoint = cc.p(0, 0); - this._endPoint = cc.p(0, 0); -}; - -cc.GradientRectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, _t = this, t = this._transform; - context.save(); - if (_t._isLighterMode) - context.globalCompositeOperation = 'lighter'; - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - var opacity = _t._opacity, locRect = this._drawingRect; - //TODO need cache gradient object - var gradient = context.createLinearGradient(_t._startPoint.x, _t._startPoint.y, _t._endPoint.x, _t._endPoint.y); - var locStartColor = _t._startColor, locEndColor = _t._endColor; - gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," - + Math.round(locStartColor.b) + "," + (opacity * (locStartColor.a / 255)).toFixed(4) + ")"); - gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," - + Math.round(locEndColor.b) + "," + (opacity * (locEndColor.a / 255)).toFixed(4) + ")"); - context.fillStyle = gradient; - context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); - - context.restore(); - cc.g_NumberOfDraws++; -}; - -cc.ParticleRenderCmdCanvas = function (node) { - this._node = node; - - this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._isBlendAdditive = false; - this._drawMode = cc.ParticleSystem.SHAPE_MODE; - this._shapeType = cc.ParticleSystem.BALL_SHAPE; - this._texture = null; - this._pointRect = {x: 0, y: 0, width: 0, height: 0}; -}; - -cc.ParticleRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, t = this._transform; - context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (this._isBlendAdditive) - context.globalCompositeOperation = 'lighter'; - else - context.globalCompositeOperation = 'source-over'; - - var i, particle, lpx; - var particleCount = this._node.particleCount, particles = this._node._particles; - if (this._drawMode == cc.ParticleSystem.TEXTURE_MODE) { - // Delay drawing until the texture is fully loaded by the browser - if (!this._texture || !this._texture._isLoaded) { - context.restore(); - return; + if (locSprite._flippedY) { + flipYOffset = locOffsetPosition.y; + context.scale(1, -1); } - var element = this._texture.getHtmlElementObj(); - if (!element.width || !element.height) { - context.restore(); - return; + + flipXOffset *= scaleX; + flipYOffset *= scaleY; + + //clip + if (this._type == cc.ProgressTimer.TYPE_BAR) { + var locBarRect = this._barRect; + context.beginPath(); + context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); + context.clip(); + context.closePath(); + } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { + var locOriginX = this._origin.x * scaleX; + var locOriginY = this._origin.y * scaleY; + context.beginPath(); + context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); + context.lineTo(locOriginX, locOriginY); + context.clip(); + context.closePath(); } - var textureCache = cc.textureCache, drawElement = element; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); + //draw sprite + var image = locSprite._texture.getHtmlElementObj(); + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); - context.globalAlpha = particle.color.a / 255; - context.save(); - context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); - - var size = Math.floor(particle.size / 4) * 4; - var w = this._pointRect.width; - var h = this._pointRect.height; - - context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); - - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - - if (particle.isChangeColor) { - var cacheTextureForColor = textureCache.getTextureColors(element); - if (cacheTextureForColor) { - // Create another cache for the tinted version - // This speeds up things by a fair bit - if (!cacheTextureForColor.tintCache) { - cacheTextureForColor.tintCache = cc.newElement('canvas'); - cacheTextureForColor.tintCache.width = element.width; - cacheTextureForColor.tintCache.height = element.height; - } - cc.generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); - drawElement = cacheTextureForColor.tintCache; - } + context.restore(); + cc.g_NumberOfDraws++; + }; + +// the canvas implement of renderCommand for cc.RenderTexture + cc.RenderTextureRenderCmdCanvas = function (node) { + this._node = node; + + this._transform = node._transformWorld; + this._clearFlags = node.clearFlags; + this.autoDraw = node.autoDraw; + + this._cacheCanvas = null; + this._cacheContext = null; + + this._sprite = null; + }; + + cc.RenderTextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + // auto draw flag + var context = ctx || cc._renderContext; + var locNode = this._node, cacheCanvas = this._cacheCanvas, cacheCtx = this._cacheContext; + if (this.autoDraw) { + locNode.begin(); + + if (this._clearFlags) { + cacheCtx.save(); + cacheCtx.fillStyle = this._clearColorStr; + cacheCtx.clearRect(0, 0, cacheCanvas.width, -cacheCanvas.height); + cacheCtx.fillRect(0, 0, cacheCanvas.width, -cacheCanvas.height); + cacheCtx.restore(); } - context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); - context.restore(); + + //! make sure all children are drawn + locNode.sortAllChildren(); + var locChildren = locNode._children; + var childrenLen = locChildren.length; + var selfSprite = this.sprite; + for (var i = 0; i < childrenLen; i++) { + var getChild = locChildren[i]; + if (getChild != selfSprite) + getChild.visit(); + } + locNode.end(); } - } else { - var drawTool = cc._drawingUtil; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); - context.globalAlpha = particle.color.a / 255; + cc.g_NumberOfDraws++; + }; + + cc.DrawNodeRenderCmdCanvas = function (node) { + this._node = node; + this._buffer = null; + this._drawColor = null; + this._blendFunc = null; + }; + + cc.DrawNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, _t = this; + if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) + context.globalCompositeOperation = 'lighter'; - context.save(); - context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - if (this._shapeType == cc.ParticleSystem.STAR_SHAPE) { - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - drawTool.drawStar(context, lpx, particle.color); - } else - drawTool.drawColorBall(context, lpx, particle.color); - context.restore(); + for (var i = 0; i < _t._buffer.length; i++) { + var element = _t._buffer[i]; + switch (element.type) { + case cc.DrawNode.TYPE_DOT: + _t._drawDot(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_SEGMENT: + _t._drawSegment(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_POLY: + _t._drawPoly(context, element, scaleX, scaleY); + break; + } } - } - context.restore(); - cc.g_NumberOfDraws++; -}; + }; -// the canvas implement of renderCommand for cc.ProgressTimer -cc.ProgressRenderCmdCanvas = function (node) { - this._PI180 = Math.PI / 180; - - this._node = node; - this._transform = node._transformWorld; - this._sprite = null; - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._barRect = cc.rect(0, 0, 0, 0); - this._origin = cc.p(0,0); - this._radius = 0; - this._startAngle = 270; - this._endAngle = 270; - this._counterClockWise = false; -}; - -cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, locSprite = this._sprite; - - var locTextureCoord = locSprite._rendererCmd._textureCoord; - if (!locSprite._texture || !locTextureCoord.validRect) - return; - - var t = this._transform; - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - if (locSprite._isLighterMode) - context.globalCompositeOperation = 'lighter'; - - context.globalAlpha = locSprite._displayedOpacity / 255; - - var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; - var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; - locDrawSizeCanvas.width = locRect.width * scaleX; - locDrawSizeCanvas.height = locRect.height * scaleY; - - if (locSprite._flippedX) { - flipXOffset = -locOffsetPosition.x - locRect.width; - context.scale(-1, 1); - } - if (locSprite._flippedY) { - flipYOffset = locOffsetPosition.y; - context.scale(1, -1); - } - - flipXOffset *= scaleX; - flipYOffset *= scaleY; - - //clip - if (this._type == cc.ProgressTimer.TYPE_BAR) { - var locBarRect = this._barRect; - context.beginPath(); - context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); - context.clip(); - context.closePath(); - } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { - var locOriginX = this._origin.x * scaleX; - var locOriginY = this._origin.y * scaleY; - context.beginPath(); - context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); - context.lineTo(locOriginX, locOriginY); - context.clip(); - context.closePath(); - } - - //draw sprite - var image = locSprite._texture.getHtmlElementObj(); - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); - - - context.restore(); - cc.g_NumberOfDraws++; -}; + cc.DrawNodeRenderCmdCanvas.prototype._drawDot = function (ctx, element, scaleX, scaleY) { + var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; -// the canvas implement of renderCommand for cc.RenderTexture -cc.RenderTextureRenderCmdCanvas = function(node){ - this._node = node; - - this._transform = node._transformWorld; - this._clearFlags = node.clearFlags; - this.autoDraw = node.autoDraw; - - this._cacheCanvas = null; - this._cacheContext = null; - - this._sprite = null; -}; - -cc.RenderTextureRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - // auto draw flag - var context = ctx || cc._renderContext; - var locNode = this._node, cacheCanvas = this._cacheCanvas, cacheCtx = this._cacheContext; - if (this.autoDraw) { - locNode.begin(); - - if (this._clearFlags) { - cacheCtx.save(); - cacheCtx.fillStyle = this._clearColorStr; - cacheCtx.clearRect(0, 0, cacheCanvas.width, -cacheCanvas.height); - cacheCtx.fillRect(0, 0, cacheCanvas.width, -cacheCanvas.height); - cacheCtx.restore(); + ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.beginPath(); + ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); + ctx.closePath(); + ctx.fill(); + }; + + cc.DrawNodeRenderCmdCanvas.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { + var locColor = element.lineColor; + var locFrom = element.verts[0]; + var locTo = element.verts[1]; + var locLineWidth = element.lineWidth; + var locLineCap = element.lineCap; + + ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.lineWidth = locLineWidth * scaleX; + ctx.beginPath(); + ctx.lineCap = locLineCap; + ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); + ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); + ctx.stroke(); + }; + + cc.DrawNodeRenderCmdCanvas.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { + var _node = this._node; + var locVertices = element.verts; + var locLineCap = element.lineCap; + var locFillColor = element.fillColor; + var locLineWidth = element.lineWidth; + var locLineColor = element.lineColor; + var locIsClosePolygon = element.isClosePolygon; + var locIsFill = element.isFill; + var locIsStroke = element.isStroke; + if (locVertices == null) + return; + + var firstPoint = locVertices[0]; + + ctx.lineCap = locLineCap; + + if (locFillColor) { + ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," + + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; } - //! make sure all children are drawn - locNode.sortAllChildren(); - var locChildren = locNode._children; - var childrenLen = locChildren.length; - var selfSprite = this.sprite; - for (var i = 0; i < childrenLen; i++) { - var getChild = locChildren[i]; - if (getChild != selfSprite) - getChild.visit(); + if (locLineWidth) { + ctx.lineWidth = locLineWidth * scaleX; } - locNode.end(); - } - cc.g_NumberOfDraws++; -}; - -cc.DrawNodeRenderCmdCanvas = function(node){ - this._node = node; - this._buffer = null; - this._drawColor = null; - this._blendFunc = null; -}; - -cc.DrawNodeRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext, _t = this; - if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) - context.globalCompositeOperation = 'lighter'; - - for (var i = 0; i < _t._buffer.length; i++) { - var element = _t._buffer[i]; - switch (element.type) { - case cc.DrawNode.TYPE_DOT: - _t._drawDot(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_SEGMENT: - _t._drawSegment(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_POLY: - _t._drawPoly(context, element, scaleX, scaleY); - break; + if (locLineColor) { + ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," + + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; } - } -}; - -cc.DrawNodeRenderCmdCanvas.prototype._drawDot = function (ctx, element, scaleX, scaleY) { - var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; - - ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.beginPath(); - ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); - ctx.closePath(); - ctx.fill(); -}; - -cc.DrawNodeRenderCmdCanvas.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { - var locColor = element.lineColor; - var locFrom = element.verts[0]; - var locTo = element.verts[1]; - var locLineWidth = element.lineWidth; - var locLineCap = element.lineCap; - - ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.lineWidth = locLineWidth * scaleX; - ctx.beginPath(); - ctx.lineCap = locLineCap; - ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); - ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); - ctx.stroke(); -}; - -cc.DrawNodeRenderCmdCanvas.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { - var _node = this._node; - var locVertices = element.verts; - var locLineCap = element.lineCap; - var locFillColor = element.fillColor; - var locLineWidth = element.lineWidth; - var locLineColor = element.lineColor; - var locIsClosePolygon = element.isClosePolygon; - var locIsFill = element.isFill; - var locIsStroke = element.isStroke; - if (locVertices == null) - return; - - var firstPoint = locVertices[0]; - - ctx.lineCap = locLineCap; - - if (locFillColor) { - ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," - + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; - } - - if (locLineWidth) { - ctx.lineWidth = locLineWidth * scaleX; - } - if (locLineColor) { - ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," - + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; - } - var t = _node._transformWorld; - - ctx.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - ctx.beginPath(); - ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); - for (var i = 1, len = locVertices.length; i < len; i++) - ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); - - if (locIsClosePolygon) - ctx.closePath(); + var t = _node._transformWorld; - if (locIsFill) - ctx.fill(); - if (locIsStroke) - ctx.stroke(); - ctx.restore(); -}; + ctx.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); -cc.ClippingNodeSaveRenderCmdCanvas = function(node){ - this._node = node; -}; + ctx.beginPath(); + ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); + for (var i = 1, len = locVertices.length; i < len; i++) + ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); -cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + if (locIsClosePolygon) + ctx.closePath(); - var context = ctx || cc._renderContext; + if (locIsFill) + ctx.fill(); + if (locIsStroke) + ctx.stroke(); + ctx.restore(); + }; - context.save(); + cc.ClippingNodeSaveRenderCmdCanvas = function (node) { + this._node = node; + }; - var t = this._node._transformWorld; - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); -}; + cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { -cc.ClippingNodeClipRenderCmdCanvas = function(node){ - this._node = node; -}; + var context = ctx || cc._renderContext; -cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext; - if (this._node.inverted) { - var canvas = context.canvas; context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); + var t = this._node._transformWorld; + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + }; - context.moveTo(0, 0); - context.lineTo(0, canvas.height); - context.lineTo(canvas.width, canvas.height); - context.lineTo(canvas.width, 0); - context.lineTo(0, 0); + cc.ClippingNodeClipRenderCmdCanvas = function (node) { + this._node = node; + }; - context.restore(); - } - var t = cc.affineTransformInvert(this._node._transformWorld); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.clip(); -}; + cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext; + if (this._node.inverted) { + var canvas = context.canvas; + context.save(); -cc.ClippingNodeRestoreRenderCmdCanvas = function(node){ - this._node = node; -}; + context.setTransform(1, 0, 0, 1, 0, 0); -cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext; - context.restore(); -}; + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); + + context.restore(); + } + var t = cc.affineTransformInvert(this._node._transformWorld); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.clip(); + }; + + cc.ClippingNodeRestoreRenderCmdCanvas = function (node) { + this._node = node; + }; + + cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext; + context.restore(); + }; //CHIPMUNK -cc.PhysicsDebugNodeRenderCmdCanvas = function(node){ - this._node = node; - this._buffer = node._buffer; -}; + cc.PhysicsDebugNodeRenderCmdCanvas = function (node) { + this._node = node; + this._buffer = node._buffer; + }; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var _node = this._node; + cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var _node = this._node; - if (!_node._space) - return; + if (!_node._space) + return; - _node._space.eachShape(cc.DrawShape.bind(_node)); - _node._space.eachConstraint(cc.DrawConstraint.bind(_node)); - cc.DrawNodeRenderCmdCanvas.prototype.rendering.call(this, ctx, scaleX, scaleY); - _node.clear(); -}; + _node._space.eachShape(cc.DrawShape.bind(_node)); + _node._space.eachConstraint(cc.DrawConstraint.bind(_node)); + cc.DrawNodeRenderCmdCanvas.prototype.rendering.call(this, ctx, scaleX, scaleY); + _node.clear(); + }; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; + cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; + cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; + cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; + cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; -cc.PhysicsSpriteTransformCmdCanvas = function(node){ - this._node = node; -}; + cc.PhysicsSpriteTransformCmdCanvas = function (node) { + this._node = node; + }; -cc.PhysicsSpriteTransformCmdCanvas.prototype.rendering = function(){ - if(this._node.transform){ - this._node.transform(); - } -}; + cc.PhysicsSpriteTransformCmdCanvas.prototype.rendering = function () { + if (this._node.transform) { + this._node.transform(); + } + }; //--- TMXLayer's render command --- -cc.TMXLayerRenderCmdCanvas = function(tmxLayer){ - this._node = tmxLayer; - - this._transform = tmxLayer._transformWorld; - this._childrenRenderCmds = []; -}; - -cc.TMXLayerRenderCmdCanvas.prototype._copyRendererCmds = function(rendererCmds){ - if(!rendererCmds) - return; - - var locCacheCmds = this._childrenRenderCmds; - locCacheCmds.length = 0; - for(var i = 0, len = rendererCmds.length; i < len; i++){ - locCacheCmds[i] = rendererCmds[i]; - } -}; - -cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function(scaleX, scaleY){ - //TODO - var locNode = this._node; - if(locNode._cacheDirty){ - var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; - - locCacheContext.save(); - locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - //reset the cache context - var t = cc.affineTransformInvert(this._transform); - locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - for(var i = 0, len = locCacheCmds.length; i < len; i++){ - locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); - if(locCacheCmds[i]._node) - locCacheCmds[i]._node._cacheDirty = false; + cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { + this._node = tmxLayer; + + this._transform = tmxLayer._transformWorld; + this._childrenRenderCmds = []; + }; + + cc.TMXLayerRenderCmdCanvas.prototype._copyRendererCmds = function (rendererCmds) { + if (!rendererCmds) + return; + + var locCacheCmds = this._childrenRenderCmds; + locCacheCmds.length = 0; + for (var i = 0, len = rendererCmds.length; i < len; i++) { + locCacheCmds[i] = rendererCmds[i]; } - locCacheContext.restore(); - locNode._cacheDirty = false; - } -}; - -cc.TMXLayerRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - this._renderingChildToCache(scaleX, scaleY); - - var context = ctx || cc._renderContext; - var node = this._node; - //context.globalAlpha = this._opacity / 255; - var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); - var locCacheCanvas = node._cacheCanvas, t = this._transform; - //direct draw image by canvas drawImage - if (locCacheCanvas) { - context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + }; + + cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function (scaleX, scaleY) { + //TODO + var locNode = this._node; + if (locNode._cacheDirty) { + var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; + + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + //reset the cache context + var t = cc.affineTransformInvert(this._transform); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + for (var i = 0, len = locCacheCmds.length; i < len; i++) { + locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); + if (locCacheCmds[i]._node) + locCacheCmds[i]._node._cacheDirty = false; + } + locCacheContext.restore(); + locNode._cacheDirty = false; + } + }; - var locCanvasHeight = locCacheCanvas.height * scaleY; - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + cc.TMXLayerRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + this._renderingChildToCache(scaleX, scaleY); - context.restore(); - } - cc.g_NumberOfDraws++; -}; + var context = ctx || cc._renderContext; + var node = this._node; + //context.globalAlpha = this._opacity / 255; + var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); + var locCacheCanvas = node._cacheCanvas, t = this._transform; + //direct draw image by canvas drawImage + if (locCacheCanvas) { + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + var locCanvasHeight = locCacheCanvas.height * scaleY; + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + + context.restore(); + } + cc.g_NumberOfDraws++; + }; +} diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js new file mode 100644 index 0000000000..1c004427f6 --- /dev/null +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -0,0 +1,177 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +if(cc._renderType === cc._RENDER_TYPE_WEBGL){ + cc.rendererWebGL = { + childrenOrderDirty: true, + _transformNodePool: [], //save nodes transform dirty + _renderCmds: [], //save renderer commands + + _isCacheToCanvasOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds + _cacheToCanvasCmds: [], // an array saves the renderer commands need for cache to other canvas + + /** + * drawing all renderer command to context (default is cc._renderContext) + * @param {WebGLRenderingContext} [ctx=cc._renderContext] + */ + rendering: function (ctx) { + var locCmds = this._renderCmds, + i, + len; + var context = ctx || cc._renderContext; + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(context); + } + }, + + //reset renderer's flag + resetFlag: function () { + this.childrenOrderDirty = false; + this._transformNodePool.length = 0; + }, + + //update the transform data + transform: function () { + var locPool = this._transformNodePool; + //sort the pool + locPool.sort(this._sortNodeByLevelAsc); + + //transform node + for (var i = 0, len = locPool.length; i < len; i++) { + if (locPool[i]._renderCmdDiry) //TODO need modify name for LabelTTF + locPool[i]._transformForRenderer(); + } + locPool.length = 0; + }, + + transformDirty: function () { + return this._transformNodePool.length > 0; + }, + + _sortNodeByLevelAsc: function (n1, n2) { + return n1._curLevel - n2._curLevel; + }, + + pushDirtyNode: function (node) { + //if (this._transformNodePool.indexOf(node) === -1) + this._transformNodePool.push(node); + }, + + clearRenderCommands: function () { + this._renderCmds.length = 0; + }, + + pushRenderCommand: function (cmd) { + if (this._isCacheToCanvasOn) { + if (this._cacheToCanvasCmds.indexOf(cmd) === -1) + this._cacheToCanvasCmds.push(cmd); + } else { + if (this._renderCmds.indexOf(cmd) === -1) + this._renderCmds.push(cmd); + } + } + }; + cc.renderer = cc.rendererWebGL; + + //sprite renderer command + cc.TextureRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.TextureRenderCmdWebGL.prototype.rendering = function(ctx){ + var _t = this._node; + if (!_t._textureLoaded) + return; + + var gl = ctx || cc._renderContext, locTexture = _t._texture; + //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); + + if (locTexture) { + if (locTexture._isLoaded) { + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + //optimize performance for javascript + cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); + if (_t._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.DYNAMIC_DRAW); + _t._quadDirty = false; + } + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + } else { + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + cc.glBindTexture2D(null); + + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); + if (_t._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.STATIC_DRAW); + _t._quadDirty = false; + } + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + cc.g_NumberOfDraws++; + }; + + //LayerColor renderer command + cc.RectRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.RectRenderCmdWebGL.prototype.rendering = function(ctx){ + var context = ctx || cc._renderContext; + var node = this._node; + + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + + // + // Attributes + // + context.bindBuffer(context.ARRAY_BUFFER, node._verticesFloat32Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); + + context.bindBuffer(context.ARRAY_BUFFER, node._colorsUint8Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); + + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + context.drawArrays(context.TRIANGLE_STRIP, 0, 4); + }; +} diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 1f99bd2203..a777077cc3 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -63,6 +63,10 @@ cc._tmp.WebGLSprite = function () { self._softInit(fileName, rect, rotated); }; + _p._initRendererCmd = function(){ + this._rendererCmd = new cc.TextureRenderCmdWebGL(this); + }; + _p.setBlendFunc = function (src, dst) { var locBlendFunc = this._blendFunc; if (dst === undefined) { diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index cd922172cb..fda6c89b7a 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -589,6 +589,12 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], false, cc.projection_matrix_stack.top.mat); }, + _setUniformForMVPMatrixWithMat4: function(modelViewMatrix){ + if(!modelViewMatrix) + throw "modelView matrix is undefined."; + this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], false, modelViewMatrix.mat); + this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], false, cc.projection_matrix_stack.top.mat); + }, /** * returns the vertexShader error log diff --git a/moduleConfig.json b/moduleConfig.json index 00e2f0ad86..15d36e340c 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -71,6 +71,7 @@ "cocos2d/core/event-manager/CCEventExtension.js", "cocos2d/core/renderer/RendererCanvas.js", + "cocos2d/core/renderer/RendererWebGL.js", "cocos2d/core/base-nodes/BaseNodesWebGL.js", "cocos2d/core/base-nodes/BaseNodesPropertyDefine.js", diff --git a/template/project.json b/template/project.json index cd45a5926f..0c277b291a 100644 --- a/template/project.json +++ b/template/project.json @@ -3,7 +3,7 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 1, + "renderMode" : 0, "engineDir":"../", "modules" : ["cocos2d"], From 5c4e68e0608c515894168e9c8c5837f7fe5f2e5b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 22 Sep 2014 11:30:11 +0800 Subject: [PATCH 0668/1564] Issue #5933: Scale9Sprite --- .../gui/control-extension/CCScale9Sprite.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 561916ce33..fcafb43679 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -27,6 +27,28 @@ Created by Jung Sang-Taik on 2012-03-16 ****************************************************************************/ +cc.Scale9SpriteStartCmd = function(node){ + this._node = node; +}; + +cc.Scale9SpriteStartCmd.prototype.rendering = function(ctx){ + ctx = ctx || cc._renderContext; + + var p = this._node._transformWorld; + ctx.save(); + ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); +}; + +cc.Scale9SpriteEndCmd = function(node){ + this._node = node; +}; + +cc.Scale9SpriteEndCmd.prototype.rendering = function(ctx){ + ctx = ctx || cc._renderContext; + ctx.restore(); +}; + + /** * A 9-slice sprite for cocos2d. * @@ -217,6 +239,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ contentSizeChanged = true; } + cc.renderer.pushRenderCommand(this._rendererStartCmd); //cc._renderContext = this._cacheContext; cc.view._setScaleXYForRenderTexture(); this._scale9Image.visit(this._cacheContext); @@ -247,6 +270,9 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._capInsets = cc.rect(0, 0, 0, 0); this._loadedEventListeners = []; + this._rendererStartCmd = new cc.Scale9SpriteStartCmd(this); + this._rendererCmd = new cc.Scale9SpriteEndCmd(this); + //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); From e583aada3eda5b80193aced313d3f5f6ec2fd593 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 22 Sep 2014 15:19:34 +0800 Subject: [PATCH 0669/1564] Issue #5933: setColor --- cocos2d/core/renderer/RendererCanvas.js | 34 +++++++++++++++++-------- cocos2d/core/sprites/CCSprite.js | 7 ++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 4a8d5b6621..702d14e14c 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -55,7 +55,7 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { var locCmds = this._cacheToCanvasCmds, i, len; if (!ctx) cc.log("The context of RenderTexture is invalid."); - for (i = 0, len = locCmds.length; i < len; i++) { + for (i = 0, len = locCmds.length; i < len; i++) { locCmds[i].rendering(ctx, 1, 1); } @@ -183,19 +183,31 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { if (_t._texture && locTextureCoord.validRect) { if (_t._texture._isLoaded) { + context.globalAlpha = _t._opacity; - image = _t._texture._htmlElementObj; - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, + var image = _t._node._texture.getHtmlElementObj(); + if (_t._node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, - locDrawingRect.width, - locDrawingRect.height - ); + locDrawingRect.width, + locDrawingRect.height); + } else { + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + t.tx * scaleX + locDrawingRect.x, + -t.ty * scaleY + locDrawingRect.y, + locDrawingRect.width, + locDrawingRect.height); + } } } else if (!_t._texture && locTextureCoord.validRect && _node._displayedColor) { curColor = _node._displayedColor; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 3732a7e673..7f960118f9 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1073,7 +1073,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, _changeTextureColor: function () { - var locElement, locTexture = this._texture, locRect = this._textureRect_Canvas; //this.getTextureRect(); + var locElement, locTexture = this._texture, locRect = this._rendererCmd._textureCoord; //this.getTextureRect(); if (locTexture && locRect.validRect && this._originalTexture) { locElement = locTexture.getHtmlElementObj(); if (!locElement) @@ -1258,7 +1258,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { self._newTextureWhenChangeColor = false; self._textureLoaded = true; - self._textureRect_Canvas = {x: 0, y: 0, width: 0, height:0, validRect: false}; self._drawSize_Canvas = cc.size(0, 0); self._softInit(fileName, rect, rotated); @@ -1626,6 +1625,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locCmd._isLighterMode = this._isLighterMode; locCmd._opacity = this._displayedOpacity / 255; + locCmd._color = this._displayedColor; + var _t = this, locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); var locRect = _t._rect, @@ -1651,7 +1652,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(!cc.sys._supportCanvasNewBlendModes) _p._changeTextureColor = function () { - var locElement, locTexture = this._texture, locRect = this._textureRect_Canvas; //this.getTextureRect(); + var locElement, locTexture = this._texture, locRect = this._rendererCmd._textureCoord; //this.getTextureRect(); if (locTexture && locRect.validRect && this._originalTexture) { locElement = locTexture.getHtmlElementObj(); if (!locElement) From 347fbf70e915a976e9484ee4ed141edac595d083 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 22 Sep 2014 17:33:09 +0800 Subject: [PATCH 0670/1564] Issue #5933: Remove toRenderer --- cocos2d/core/base-nodes/CCNode.js | 5 - cocos2d/core/labelttf/CCLabelTTF.js | 9 - cocos2d/core/layers/CCLayer.js | 40 --- cocos2d/core/renderer/RendererCanvas.js | 332 +++++++++++----------- cocos2d/core/sprites/CCSprite.js | 52 +--- cocos2d/particle/CCParticleSystem.js | 17 -- cocos2d/render-texture/CCRenderTexture.js | 11 - cocos2d/tilemap/CCTMXLayer.js | 1 - 8 files changed, 184 insertions(+), 283 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 5bc0b3ca9f..8f2dae9b87 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2554,10 +2554,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return false; }, - toRenderer: function(){ - //send the update to renderer. - }, - _initRendererCmd: function(){ }, @@ -2605,7 +2601,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //visit for canvas var i, children = _t._children, child; - _t.toRenderer(); _t.transform(); var len = children.length; if (len > 0) { diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 99835dc294..4b61dc5c36 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1090,19 +1090,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (this._needUpdateTexture) { this._needUpdateTexture = false; this._updateTexture(); - this.toRenderer(); } cc.Node.prototype._transformForRenderer.call(this); }; - _p.toRenderer = function(){ - if (this._needUpdateTexture) { - this._needUpdateTexture = false; - this._updateTexture(); - } - cc.Sprite.prototype.toRenderer.call(this); - }; - _p._setColorsString = function () { this._setUpdateTextureDirty(); diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index ddb26902df..254a42d3ed 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -419,23 +419,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locCmd._color.a = this._displayedOpacity / 255; }; - _p.toRenderer = function(){ - if(!this._rendererCmd) - return; - - var locCmd = this._rendererCmd; - var locColor = this._displayedColor; - locCmd._isLighterMode = this._isLighterMode; - - locCmd._color.r = locColor.r; - locCmd._color.g = locColor.g; - locCmd._color.b = locColor.b; - locCmd._color.a = this._displayedOpacity / 255; - - locCmd._drawingRect.width = this.width * cc.view.getScaleX(); - locCmd._drawingRect.height = this.height * cc.view.getScaleY(); - }; - _p.draw = function (ctx) { var context = ctx || cc._renderContext, _t = this; var locEGLViewer = cc.view, locDisplayedColor = _t._displayedColor; @@ -795,29 +778,6 @@ cc.LayerGradient.create = function (start, end, v) { if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //cc.LayerGradient define start var _p = cc.LayerGradient.prototype; - _p.toRenderer = function(){ - if(!this._rendererCmd) - return; - - var locCmd = this._rendererCmd; - //set the data to the rendererCmd - var locColor = this._displayedColor, locEndColor = this._endColor; - locCmd._isLighterMode = this._isLighterMode; - locCmd._opacity = this._displayedOpacity/255; - - locCmd._startColor.r = locColor.r; - locCmd._startColor.g = locColor.g; - locCmd._startColor.b = locColor.b; - locCmd._startColor.a = locColor.a; - - locCmd._endColor.r = locEndColor.r; - locCmd._endColor.g = locEndColor.g; - locCmd._endColor.b = locEndColor.b; - locCmd._endColor.a = locEndColor.a; - - locCmd._drawingRect.width = this.width * cc.view.getScaleX(); - locCmd._drawingRect.height = this.height * cc.view.getScaleY(); - }; _p._updateColor = function () { var _t = this; var locAlongVector = _t._alongVector, tWidth = _t.width * 0.5, tHeight = _t.height * 0.5; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 702d14e14c..ae8744612b 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -55,7 +55,7 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { var locCmds = this._cacheToCanvasCmds, i, len; if (!ctx) cc.log("The context of RenderTexture is invalid."); - for (i = 0, len = locCmds.length; i < len; i++) { + for (i = 0, len = locCmds.length; i < len; i++) { locCmds[i].rendering(ctx, 1, 1); } @@ -113,10 +113,6 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.TextureRenderCmdCanvas = function (node) { this._node = node; - this._transform = node._transformWorld; //reference of node's transformWorld - this._texture = null; - this._isLighterMode = false; - this._opacity = 1; this._textureCoord = { renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. @@ -124,37 +120,45 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { y: 0, //the y of texture coordinate for node. width: 0, height: 0, - validRect: false // + validRect: false + }; + this._drawingRect = { + //Sprite setTextureRect override ^.^ + get x(){ return node._offsetPosition.x; }, + get y(){ return node._offsetPosition.y - node._rect.height; }, + get width(){ return node._drawSize_Canvas.width; }, + get height(){ return node._drawSize_Canvas.height; } }; - this._drawingRect = cc.rect(0, 0, 0, 0); }; cc.TextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var _t = this; - var _node = _t._node; + var self = this, + node = self._node; + var context = ctx || cc._renderContext, - locTextureCoord = _t._textureCoord; - if (!locTextureCoord.validRect || !_node._visible) + locTextureCoord = self._textureCoord; + + if (!locTextureCoord.validRect || !node._visible) return; //draw nothing - var t = this._transform, locDrawingRect = _t._drawingRect, image, curColor; - if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || _node._flippedX || _node._flippedY) { + var t = node._transformWorld, locDrawingRect = self._drawingRect, image, curColor; + if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (_t._isLighterMode) + if (node._isLighterMode) context.globalCompositeOperation = 'lighter'; - if (_node._flippedX) + if (node._flippedX) context.scale(-1, 1); - if (_node._flippedY) + if (node._flippedY) context.scale(1, -1); - if (_t._texture && locTextureCoord.validRect) { - if (_t._texture._isLoaded) { - context.globalAlpha = _t._opacity; - image = _t._texture._htmlElementObj; + if (node._texture && locTextureCoord.validRect) { + if (node._texture._isLoaded) { + context.globalAlpha = node._opacity; + image = node._texture._htmlElementObj; context.drawImage(image, locTextureCoord.renderX, @@ -169,24 +173,24 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { } - } else if (!_t._texture && locTextureCoord.validRect) { - curColor = _t._color; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; + } else if (!node._texture && locTextureCoord.validRect) { + curColor = node._color; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._opacity + ")"; context.fillRect(locDrawingRect.x, locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); } context.restore(); } else { - if (_t._isLighterMode) { + if (node._isLighterMode) { context.save(); context.globalCompositeOperation = 'lighter'; } - if (_t._texture && locTextureCoord.validRect) { - if (_t._texture._isLoaded) { + if (node._texture && locTextureCoord.validRect) { + if (node._texture._isLoaded) { - context.globalAlpha = _t._opacity; - var image = _t._node._texture.getHtmlElementObj(); - if (_t._node._colorized) { + context.globalAlpha = node._opacity; + image = node._texture.getHtmlElementObj(); + if (node._colorized) { context.drawImage(image, 0, 0, @@ -209,12 +213,12 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { locDrawingRect.height); } } - } else if (!_t._texture && locTextureCoord.validRect && _node._displayedColor) { - curColor = _node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + _t._opacity + ")"; + } else if (!node._texture && locTextureCoord.validRect && node._displayedColor) { + curColor = node._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._opacity + ")"; context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); } - if (_t._isLighterMode) + if (node._isLighterMode) context.restore(); } cc.g_NumberOfDraws++; @@ -223,21 +227,33 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.RectRenderCmdCanvas = function (node) { this._node = node; - this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._isLighterMode = false; - this._drawingRect = cc.rect(0, 0, 0, 0); - this._color = cc.color(255, 255, 255, 255); + this._drawingRect = { + x: 0, + y: 0, + get width(){ + return node.width * cc.view.getScaleX(); + }, + get height(){ + return node.height * cc.view.getScaleY() + } + }; }; cc.RectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, t = this._transform, curColor = this._color, locRect = this._drawingRect; + var context = ctx || cc._renderContext, + node = this._node, + t = node._transformWorld, + curColor = node._displayedColor, + opacity = node._displayedOpacity / 255, + locRect = this._drawingRect; + context.save(); - if (this._isLighterMode) + if (node._isLighterMode) context.globalCompositeOperation = 'lighter'; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," - + (0 | curColor.b) + "," + curColor.a + ")"; + + (0 | curColor.b) + "," + opacity + ")"; context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); context.restore(); @@ -247,28 +263,33 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.GradientRectRenderCmdCanvas = function (node) { this._node = node; - this._transform = node._transformWorld; // {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._isLighterMode = false; - this._opacity = 1; - this._drawingRect = cc.rect(0, 0, 0, 0); - this._startColor = cc.color(255, 255, 255, 255); - this._endColor = cc.color(255, 255, 255, 255); + this._drawingRect = { + x: 0, + y: 0, + get width(){ return node.width * cc.view.getScaleX(); }, + get height(){ return node.height * cc.view.getScaleY(); } + }; this._startPoint = cc.p(0, 0); this._endPoint = cc.p(0, 0); }; cc.GradientRectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, _t = this, t = this._transform; + var context = ctx || cc._renderContext, + self = this, + node = self._node, + t = node._transformWorld; context.save(); - if (_t._isLighterMode) + if (node._isLighterMode) context.globalCompositeOperation = 'lighter'; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - var opacity = _t._opacity, locRect = this._drawingRect; + var opacity = node._displayedOpacity / 255, + locRect = this._drawingRect; //TODO need cache gradient object - var gradient = context.createLinearGradient(_t._startPoint.x, _t._startPoint.y, _t._endPoint.x, _t._endPoint.y); - var locStartColor = _t._startColor, locEndColor = _t._endColor; + var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); + var locStartColor = node._displayedColor, + locEndColor = node._endColor; gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," + Math.round(locStartColor.b) + "," + (opacity * (locStartColor.a / 255)).toFixed(4) + ")"); gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," @@ -282,34 +303,30 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.ParticleRenderCmdCanvas = function (node) { this._node = node; - - this._transform = node._transformWorld; //{a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._isBlendAdditive = false; - this._drawMode = cc.ParticleSystem.SHAPE_MODE; - this._shapeType = cc.ParticleSystem.BALL_SHAPE; - this._texture = null; - this._pointRect = {x: 0, y: 0, width: 0, height: 0}; }; cc.ParticleRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, t = this._transform; + var context = ctx || cc._renderContext, + node = this._node, + t = node._transformWorld, + pointRect = node._pointRect; context.save(); //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (this._isBlendAdditive) + if (node.isBlendAdditive()) context.globalCompositeOperation = 'lighter'; else context.globalCompositeOperation = 'source-over'; var i, particle, lpx; var particleCount = this._node.particleCount, particles = this._node._particles; - if (this._drawMode == cc.ParticleSystem.TEXTURE_MODE) { + if (cc.ParticleSystem.SHAPE_MODE == cc.ParticleSystem.TEXTURE_MODE) { // Delay drawing until the texture is fully loaded by the browser - if (!this._texture || !this._texture._isLoaded) { + if (!node._texture || !node._texture._isLoaded) { context.restore(); return; } - var element = this._texture.getHtmlElementObj(); + var element = node._texture.getHtmlElementObj(); if (!element.width || !element.height) { context.restore(); return; @@ -326,8 +343,8 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); var size = Math.floor(particle.size / 4) * 4; - var w = this._pointRect.width; - var h = this._pointRect.height; + var w = pointRect.width; + var h = pointRect.height; context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); @@ -360,7 +377,7 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { context.save(); context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - if (this._shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (cc.ParticleSystem.BALL_SHAPE == cc.ParticleSystem.STAR_SHAPE) { if (particle.rotation) context.rotate(cc.degreesToRadians(particle.rotation)); drawTool.drawStar(context, lpx, particle.color); @@ -373,12 +390,11 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.g_NumberOfDraws++; }; -// the canvas implement of renderCommand for cc.ProgressTimer + // the canvas implement of renderCommand for cc.ProgressTimer cc.ProgressRenderCmdCanvas = function (node) { this._PI180 = Math.PI / 180; this._node = node; - this._transform = node._transformWorld; this._sprite = null; this._type = cc.ProgressTimer.TYPE_RADIAL; this._barRect = cc.rect(0, 0, 0, 0); @@ -390,13 +406,15 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, locSprite = this._sprite; + var context = ctx || cc._renderContext, + node = this._node, + locSprite = this._sprite; var locTextureCoord = locSprite._rendererCmd._textureCoord; if (!locSprite._texture || !locTextureCoord.validRect) return; - var t = this._transform; + var t = node._transformWorld; context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); @@ -456,28 +474,24 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.g_NumberOfDraws++; }; -// the canvas implement of renderCommand for cc.RenderTexture + // the canvas implement of renderCommand for cc.RenderTexture cc.RenderTextureRenderCmdCanvas = function (node) { this._node = node; - this._transform = node._transformWorld; - this._clearFlags = node.clearFlags; - this.autoDraw = node.autoDraw; - + //CCRenderTexture _initWithWidthAndHeightForCanvas this._cacheCanvas = null; this._cacheContext = null; - - this._sprite = null; }; cc.RenderTextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { // auto draw flag - var context = ctx || cc._renderContext; + var context = ctx || cc._renderContext, + node = this._node; var locNode = this._node, cacheCanvas = this._cacheCanvas, cacheCtx = this._cacheContext; - if (this.autoDraw) { + if (node.autoDraw) { locNode.begin(); - if (this._clearFlags) { + if (node._clearFlags) { cacheCtx.save(); cacheCtx.fillStyle = this._clearColorStr; cacheCtx.clearRect(0, 0, cacheCanvas.width, -cacheCanvas.height); @@ -608,104 +622,104 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var context = ctx || cc._renderContext; + var node = this._node; + var context = ctx || cc._renderContext; - if(node._clipElemType){ - var locCache = cc.ClippingNode._getSharedCache(); - var canvas = context.canvas; - locCache.width = canvas.width; - locCache.height = canvas.height; - var locCacheCtx = locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - context.save(); - }else{ - node.transform(); - var t = node._transformWorld; - context.save(); - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } -}; + if(node._clipElemType){ + var locCache = cc.ClippingNode._getSharedCache(); + var canvas = context.canvas; + locCache.width = canvas.width; + locCache.height = canvas.height; + var locCacheCtx = locCache.getContext("2d"); + locCacheCtx.drawImage(canvas, 0, 0); + context.save(); + }else{ + node.transform(); + var t = node._transformWorld; + context.save(); + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } + }; cc.ClippingNodeClipRenderCmdCanvas = function (node) { this._node = node; }; -cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var node = this._node; - var context = ctx || cc._renderContext; + cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + var node = this._node; + var context = ctx || cc._renderContext; - if(node._clipElemType){ - context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; - var t = node._transformWorld; - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - }else{ - context.restore(); - if (node.inverted) { - var canvas = context.canvas; - context.save(); + if(node._clipElemType){ + context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; + var t = node._transformWorld; + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + }else{ + context.restore(); + if (node.inverted) { + var canvas = context.canvas; + context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); + context.setTransform(1, 0, 0, 1, 0, 0); - context.moveTo(0, 0); - context.lineTo(0, canvas.height); - context.lineTo(canvas.width, canvas.height); - context.lineTo(canvas.width, 0); - context.lineTo(0, 0); + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); - context.restore(); + context.restore(); + } + context.clip(); } - context.clip(); - } -}; + }; cc.ClippingNodeRestoreRenderCmdCanvas = function (node) { this._node = node; }; -cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var node = this._node; - var i, children = node._children, locChild; - var locCache = cc.ClippingNode._getSharedCache(); - var context = ctx || cc._renderContext; - if(node._clipElemType){ - context.restore(); + var node = this._node; + var i, children = node._children, locChild; + var locCache = cc.ClippingNode._getSharedCache(); + var context = ctx || cc._renderContext; + if(node._clipElemType){ + context.restore(); - // Redraw the cached canvas, so that the cliped area shows the background etc. - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalCompositeOperation = "destination-over"; - context.drawImage(locCache, 0, 0); - context.restore(); - }else{ - // so if it has ClippingNode as a child, the child must uses composition stencil. - node._cangodhelpme(true); - var len = children.length; - if (len > 0) { - node.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - locChild = children[i]; - if (locChild._localZOrder < 0) - locChild.visit(context); - else - break; - } - node.draw(context); - for (; i < len; i++) { - children[i].visit(context); - } - } else - node.draw(context); - node._cangodhelpme(false); - context.restore(); - } -}; + // Redraw the cached canvas, so that the cliped area shows the background etc. + context.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.globalCompositeOperation = "destination-over"; + context.drawImage(locCache, 0, 0); + context.restore(); + }else{ + // so if it has ClippingNode as a child, the child must uses composition stencil. + node._cangodhelpme(true); + var len = children.length; + if (len > 0) { + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + locChild = children[i]; + if (locChild._localZOrder < 0) + locChild.visit(context); + else + break; + } + node.draw(context); + for (; i < len; i++) { + children[i].visit(context); + } + } else + node.draw(context); + node._cangodhelpme(false); + context.restore(); + } + }; -//CHIPMUNK + //CHIPMUNK cc.PhysicsDebugNodeRenderCmdCanvas = function (node) { this._node = node; this._buffer = node._buffer; @@ -739,7 +753,7 @@ cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function(ctx, scaleX } }; -//--- TMXLayer's render command --- + //--- TMXLayer's render command --- cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { this._node = tmxLayer; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 7f960118f9..2fc81675e7 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1173,11 +1173,15 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ } this._quadDirty = true; }, - /** - * draw sprite to canvas - * @function - */ - draw: null + + visit: function(){ + cc.Node.prototype.visit.call(this); + var _t = this, locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); + var locRect = _t._rect, + locDrawSizeCanvas = _t._drawSize_Canvas; + locDrawSizeCanvas.width = locRect.width * locEGL_ScaleX; + locDrawSizeCanvas.height = locRect.height * locEGL_ScaleY; + } }); /** @@ -1444,7 +1448,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._offsetPosition.x = relativeOffset.x + (_t._contentSize.width - _t._rect.width) / 2; _t._offsetPosition.y = relativeOffset.y + (_t._contentSize.height - _t._rect.height) / 2; - this.toRenderer(); + _t._rendererCmd._drawingRect.x = _t._offsetPosition.x; + _t._rendererCmd._drawingRect.y = _t._offsetPosition.y - _t._rect.height; // rendering using batch node if (_t._batchNode) { @@ -1615,41 +1620,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - _p.toRenderer = function(){ - if(!this._rendererCmd) - return; - - var locCmd = this._rendererCmd; - //set the data to the rendererCmd - locCmd._texture = this._texture; - locCmd._isLighterMode = this._isLighterMode; - locCmd._opacity = this._displayedOpacity / 255; - - locCmd._color = this._displayedColor; - - var _t = this, locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); - - var locRect = _t._rect, - locOffsetPosition = _t._offsetPosition, - locDrawSizeCanvas = _t._drawSize_Canvas; - var flipXOffset = 0 | (locOffsetPosition.x), - flipYOffset = -locOffsetPosition.y - locRect.height; - locDrawSizeCanvas.width = locRect.width * locEGL_ScaleX; - locDrawSizeCanvas.height = locRect.height * locEGL_ScaleY; - - if (_t._flippedX) - flipXOffset = -locOffsetPosition.x - locRect.width; - if (_t._flippedY) - flipYOffset = locOffsetPosition.y; - flipXOffset *= locEGL_ScaleX; - flipYOffset *= locEGL_ScaleY; - - locCmd._drawingRect.x = flipXOffset; - locCmd._drawingRect.y = flipYOffset; - locCmd._drawingRect.width = locDrawSizeCanvas.width; - locCmd._drawingRect.height = locDrawSizeCanvas.height; - }; - if(!cc.sys._supportCanvasNewBlendModes) _p._changeTextureColor = function () { var locElement, locTexture = this._texture, locRect = this._rendererCmd._textureCoord; //this.getTextureRect(); diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 3755b5209e..61e28fae28 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -2601,23 +2601,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } this._quadsArrayBuffer = locQuadsArrayBuffer; return true; - }, - - toRenderer: function(){ - if(!this._rendererCmd) - return; - - var locCmd = this._rendererCmd; - locCmd._isBlendAdditive = this.isBlendAdditive(); - locCmd._drawMode = this.drawMode; - locCmd._shapeType = this.shapeType; - locCmd._texture = this._texture; - - var locRect = this._pointRect; - locCmd._pointRect.x = locRect.x; - locCmd._pointRect.y = locRect.y; - locCmd._pointRect.width = locRect.width; - locCmd._pointRect.height = locRect.height; } }); diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index b6f4accb1a..3fc89b71de 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -618,7 +618,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ ctx = ctx || cc._renderContext; this.transform(ctx); - this.toRenderer(); this.sprite.visit(ctx); // draw the RenderTexture this.arrivalOrder = 0; @@ -880,16 +879,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ */ setAutoDraw:function (autoDraw) { this.autoDraw = autoDraw; - }, - - toRenderer: function(){ - if(!this._rendererCmd) - return; - - var locCmd = this._rendererCmd; - locCmd._clearFlags = this.clearFlags; - locCmd.autoDraw = this.autoDraw; - locCmd._sprite = this.sprite; } }); diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 49366d56a8..87f164bb96 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -202,7 +202,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ if( this._parent) this._curLevel = this._parent._curLevel + 1; - this.toRenderer(); this.transform(); if (this._cacheDirty) { From 3a076ea087c91578e1ff007d70f4ce99bda20c34 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 22 Sep 2014 18:14:50 +0800 Subject: [PATCH 0671/1564] webgl rendering command for DrawNode, MotionStreak, ParticleSystem, ProgressTimer --- cocos2d/core/renderer/RendererWebGL.js | 126 ++++++++++++++++++++++ cocos2d/motion-streak/CCMotionStreak.js | 4 + cocos2d/particle/CCParticleSystem.js | 7 +- cocos2d/progress-timer/CCProgressTimer.js | 1 + cocos2d/shape-nodes/CCDrawNode.js | 4 + 5 files changed, 140 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 1c004427f6..dcb81cd090 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -174,4 +174,130 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); context.drawArrays(context.TRIANGLE_STRIP, 0, 4); }; + + cc.DrawNodeRenderCmdWebGL = function (node) { + this._node = node; + }; + + cc.DrawNodeRenderCmdWebGL.prototype.rendering = function(ctx){ + var _t = this._node; + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + _t._shaderProgram.use(); + _t._shaderProgram.setUniformsForBuiltins(); + _t._render(); + }; + + cc.MontionStreakCmdWebGL = function(node){ + this._node = node; + }; + + cc.MontionStreakCmdWebGL.prototype.rendering = function(ctx){ + var _t = this._node; + if (_t._nuPoints <= 1) + return; + + if(_t.texture && _t.texture.isLoaded()){ + ctx = ctx || cc._renderContext; + cc.nodeDrawSetup(_t); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + + cc.glBindTexture2D(_t.texture); + + //position + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._verticesBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._vertices, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); + + //texcoords + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._texCoordsBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._texCoords, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); + + //colors + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._colorPointerBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._colorPointer, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); + + ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, _t._nuPoints * 2); + cc.g_NumberOfDraws ++; + } + }; + + cc.ProgressRenderCmdWebGL = function (node) { + this._node = node; + }; + + cc.ProgressRenderCmdWebGL.prototype.rendering = function(ctx){ + var _t = this._node; + var context = ctx || cc._renderContext; + if (!_t._vertexData || !_t._sprite) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + var blendFunc = _t._sprite.getBlendFunc(); + cc.glBlendFunc(blendFunc.src, blendFunc.dst); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + cc.glBindTexture2D(_t._sprite.texture); + + context.bindBuffer(context.ARRAY_BUFFER, _t._vertexWebGLBuffer); + if(_t._vertexDataDirty){ + context.bufferData(context.ARRAY_BUFFER, _t._vertexArrayBuffer, context.DYNAMIC_DRAW); + _t._vertexDataDirty = false; + } + var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); + 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 (_t._type === cc.ProgressTimer.TYPE_RADIAL) + context.drawArrays(context.TRIANGLE_FAN, 0, _t._vertexDataCount); + else if (_t._type == cc.ProgressTimer.TYPE_BAR) { + if (!_t._reverseDirection) + context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount); + else { + context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount / 2); + context.drawArrays(context.TRIANGLE_STRIP, 4, _t._vertexDataCount / 2); + // 2 draw calls + cc.g_NumberOfDraws++; + } + } + cc.g_NumberOfDraws++; + }; + + cc.ParticleRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.ParticleRenderCmdWebGL.prototype.rendering = function(ctx){ + var _t = this._node; + if(!_t._texture) + return; + + var gl = ctx || cc._renderContext; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); + + cc.glBindTexture2D(_t._texture); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + + //cc.assert(this._particleIdx == this.particleCount, "Abnormal error in particle quad"); + + // + // Using VBO without VAO + // + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); + gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); + }; } diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 0fafeae9a3..a99cec9751 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -117,6 +117,10 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this.initWithFade(fade, minSeg, stroke, color, texture); }, + _initRendererCmd:function(){ + this._rendererCmd = new cc.MontionStreakCmdWebGL(this); + }, + /** * Gets the texture. * @return {cc.Texture2D} diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 3755b5209e..c520812c95 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -374,7 +374,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ }, _initRendererCmd: function(){ - this._rendererCmd = new cc.ParticleRenderCmdCanvas(this); + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._rendererCmd = new cc.ParticleRenderCmdCanvas(this); + else + this._rendererCmd = new cc.ParticleRenderCmdWebGL(this); }, /** @@ -2604,7 +2607,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ }, toRenderer: function(){ - if(!this._rendererCmd) + if(!this._rendererCmd || cc._renderType === cc._RENDER_TYPE_WEBGL) return; var locCmd = this._rendererCmd; diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 9cd255fcd9..835264ecb9 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -206,6 +206,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._vertexData = null; this._vertexArrayBuffer = null; this._vertexDataDirty = false; + this._rendererCmd = new cc.ProgressRenderCmdWebGL(this); sprite && this._initWithSpriteForWebGL(sprite); }, diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 7850968904..17d2f22ef3 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -617,6 +617,10 @@ cc.DrawNodeWebGL = cc.Node.extend({ this.init(); }, + + _initRendererCmd: function(){ + this._rendererCmd = new cc.DrawNodeRenderCmdWebGL(this); + }, init:function () { if (cc.Node.prototype.init.call(this)) { From aab516faef904dfd4354cf0d819e7645219b99d9 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 23 Sep 2014 09:42:39 +0800 Subject: [PATCH 0672/1564] Issue #5941: adds SpriteBatchNode and AtlasNode to new renderer for WebGL --- cocos2d/core/base-nodes/BaseNodesWebGL.js | 1 - cocos2d/core/base-nodes/CCAtlasNode.js | 4 + cocos2d/core/renderer/RendererCanvas.js | 154 +++++++++++----------- cocos2d/core/renderer/RendererWebGL.js | 96 +++++++++++++- cocos2d/core/sprites/CCSpriteBatchNode.js | 47 ++++--- cocos2d/core/textures/CCTextureAtlas.js | 8 -- cocos2d/render-texture/CCRenderTexture.js | 20 ++- 7 files changed, 216 insertions(+), 114 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index 64f5582f21..012d0ff23c 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -115,7 +115,6 @@ cc._tmp.WebGLCCNode = function () { /* if (locGrid && locGrid._active) locGrid.afterDraw(_t);*/ - //cc.kmGLPopMatrix(); //optimize performance for javascript currentStack.top = currentStack.stack.pop(); }; diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index a1bbb3ff23..448941d9b4 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -86,6 +86,10 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender); }, + _initRendererCmd: function () { + this._rendererCmd = new cc.AtlasNodeRenderCmdWebGL(this); + }, + /** * Updates the Atlas (indexed vertex array). * Empty implementation, shall be overridden in subclasses diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 4a8d5b6621..f1f4c0370e 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -if(cc._renderType === cc._RENDER_TYPE_CANVAS) { +if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.rendererCanvas = { childrenOrderDirty: true, _transformNodePool: [], //save nodes transform dirty @@ -596,101 +596,101 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; + var node = this._node; var context = ctx || cc._renderContext; - if(node._clipElemType){ - var locCache = cc.ClippingNode._getSharedCache(); - var canvas = context.canvas; - locCache.width = canvas.width; - locCache.height = canvas.height; - var locCacheCtx = locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - context.save(); - }else{ - node.transform(); - var t = node._transformWorld; - context.save(); - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } -}; + if (node._clipElemType) { + var locCache = cc.ClippingNode._getSharedCache(); + var canvas = context.canvas; + locCache.width = canvas.width; + locCache.height = canvas.height; + var locCacheCtx = locCache.getContext("2d"); + locCacheCtx.drawImage(canvas, 0, 0); + context.save(); + } else { + node.transform(); + var t = node._transformWorld; + context.save(); + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } + }; cc.ClippingNodeClipRenderCmdCanvas = function (node) { this._node = node; }; -cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var node = this._node; - var context = ctx || cc._renderContext; + cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var context = ctx || cc._renderContext; - if(node._clipElemType){ - context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; - var t = node._transformWorld; - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - }else{ - context.restore(); - if (node.inverted) { - var canvas = context.canvas; - context.save(); + if (node._clipElemType) { + context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; + var t = node._transformWorld; + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } else { + context.restore(); + if (node.inverted) { + var canvas = context.canvas; + context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); + context.setTransform(1, 0, 0, 1, 0, 0); - context.moveTo(0, 0); - context.lineTo(0, canvas.height); - context.lineTo(canvas.width, canvas.height); - context.lineTo(canvas.width, 0); - context.lineTo(0, 0); + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); - context.restore(); + context.restore(); + } + context.clip(); } - context.clip(); - } -}; + }; cc.ClippingNodeRestoreRenderCmdCanvas = function (node) { this._node = node; }; -cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var i, children = node._children, locChild; - var locCache = cc.ClippingNode._getSharedCache(); - var context = ctx || cc._renderContext; - if(node._clipElemType){ - context.restore(); + var node = this._node; + var i, children = node._children, locChild; + var locCache = cc.ClippingNode._getSharedCache(); + var context = ctx || cc._renderContext; + if (node._clipElemType) { + context.restore(); - // Redraw the cached canvas, so that the cliped area shows the background etc. - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalCompositeOperation = "destination-over"; - context.drawImage(locCache, 0, 0); - context.restore(); - }else{ - // so if it has ClippingNode as a child, the child must uses composition stencil. - node._cangodhelpme(true); - var len = children.length; - if (len > 0) { - node.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - locChild = children[i]; - if (locChild._localZOrder < 0) - locChild.visit(context); - else - break; - } - node.draw(context); - for (; i < len; i++) { - children[i].visit(context); - } - } else - node.draw(context); - node._cangodhelpme(false); - context.restore(); - } -}; + // Redraw the cached canvas, so that the cliped area shows the background etc. + context.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.globalCompositeOperation = "destination-over"; + context.drawImage(locCache, 0, 0); + context.restore(); + } else { + // so if it has ClippingNode as a child, the child must uses composition stencil. + node._cangodhelpme(true); + var len = children.length; + if (len > 0) { + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + locChild = children[i]; + if (locChild._localZOrder < 0) + locChild.visit(context); + else + break; + } + node.draw(context); + for (; i < len; i++) { + children[i].visit(context); + } + } else + node.draw(context); + node._cangodhelpme(false); + context.restore(); + } + }; //CHIPMUNK diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 1c004427f6..13cf49bc94 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -149,7 +149,7 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ cc.g_NumberOfDraws++; }; - //LayerColor renderer command + //LayerColor render command cc.RectRenderCmdWebGL = function(node){ this._node = node; }; @@ -174,4 +174,98 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); context.drawArrays(context.TRIANGLE_STRIP, 0, 4); }; + + //RenderTexture render command + cc.RenderTextureRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.RenderTextureRenderCmdWebGL.prototype.rendering = function(ctx){ + var gl = ctx || cc._renderContext; + var node = this._node; + if (node.autoDraw) { + node.begin(); + + var locClearFlags = this.clearFlags; + if (locClearFlags) { + var oldClearColor = [0.0, 0.0, 0.0, 0.0]; + var oldDepthClearValue = 0.0; + var oldStencilClearValue = 0; + + // backup and set + if (locClearFlags & gl.COLOR_BUFFER_BIT) { + oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); + gl.clearColor(node._clearColor.r/255, node._clearColor.g/255, node._clearColor.b/255, node._clearColor.a/255); + } + + if (locClearFlags & gl.DEPTH_BUFFER_BIT) { + oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + gl.clearDepth(node.clearDepthVal); + } + + if (locClearFlags & gl.STENCIL_BUFFER_BIT) { + oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); + gl.clearStencil(node.clearStencilVal); + } + + // clear + gl.clear(locClearFlags); + + // restore + if (locClearFlags & gl.COLOR_BUFFER_BIT) + gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); + + if (locClearFlags & gl.DEPTH_BUFFER_BIT) + gl.clearDepth(oldDepthClearValue); + + if (locClearFlags & gl.STENCIL_BUFFER_BIT) + gl.clearStencil(oldStencilClearValue); + } + + //! make sure all children are drawn + node.sortAllChildren(); + var locChildren = node._children; + for (var i = 0; i < locChildren.length; i++) { + var getChild = locChildren[i]; + if (getChild != node.sprite) + getChild.visit(); + } + node.end(); + } + }; + + cc.SpriteBatchNodeRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering = function(ctx){ + var node = this._node; + if (node.textureAtlas.totalQuads === 0) + return; + + //cc.nodeDrawSetup(this); + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + node._arrayMakeObjectsPerformSelector(node._children, cc.Node._StateCallbackType.updateTransform); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + + node.textureAtlas.drawQuads(); + }; + + cc.AtlasNodeRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.AtlasNodeRenderCmdWebGL.prototype.rendering = function(ctx){ + var context = ctx || cc._renderContext, node = this._node; + + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + if(node._uniformColor && node._colorF32Array){ + context.uniform4fv(node._uniformColor, node._colorF32Array); + node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); + } + }; } diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index b32bed1f57..e7dc41b556 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -219,9 +219,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ if (children && children.length > 0) { for (var i = 0; i < children.length; i++) { var obj = children[i]; - if (obj && (obj.zIndex < 0)) { + if (obj && (obj.zIndex < 0)) index = this.rebuildIndexInOrder(obj, index); - } } } // ignore self (batch node) @@ -232,9 +231,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ if (children && children.length > 0) { for (i = 0; i < children.length; i++) { obj = children[i]; - if (obj && (obj.zIndex >= 0)) { + if (obj && (obj.zIndex >= 0)) index = this.rebuildIndexInOrder(obj, index); - } } } return index; @@ -380,7 +378,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ cc.Node.prototype.removeChild.call(this, child, cleanup); }, - _mvpMatrix: null, _textureForCanvas: null, _useCache: false, _originalTexture: null, @@ -405,7 +402,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ _ctorForWebGL: function (fileImage, capacity) { cc.Node.prototype.ctor.call(this); - this._mvpMatrix = new cc.kmMat4(); var texture2D; capacity = capacity || cc.DEFAULT_SPRITE_BATCH_CAPACITY; @@ -413,13 +409,16 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ texture2D = cc.textureCache.getTextureForKey(fileImage); if (!texture2D) texture2D = cc.textureCache.addImage(fileImage); - } - else if (fileImage instanceof cc.Texture2D) + } else if (fileImage instanceof cc.Texture2D) texture2D = fileImage; - texture2D && this.initWithTexture(texture2D, capacity); }, + _initRendererCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this._rendererCmd = new cc.SpriteBatchNodeRenderCmdWebGL(this); + }, + /** *

    * Updates a quad at a certain index into the texture atlas. The CCSprite won't be added into the children array.
    @@ -706,8 +705,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ sprite.dirty = true; this._descendants.push(sprite); - var index = this._descendants.length - 1; - sprite.atlasIndex = index; + sprite.atlasIndex = this._descendants.length - 1; // add children recursively var children = sprite.children; @@ -845,7 +843,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ context.save(); this.transform(ctx); var i, locChildren = this._children; - if (locChildren) { this.sortAllChildren(); for (i = 0; i < locChildren.length; i++) { @@ -853,7 +850,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ locChildren[i].visit(context); } } - context.restore(); }, @@ -869,18 +865,29 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ // if (!this._visible) return; - cc.kmGLPushMatrix(); - var locGrid = this.grid; + + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; + +/* var locGrid = this.grid; if (locGrid && locGrid.isActive()) { locGrid.beforeDraw(); this.transformAncestors(); - } + }*/ + this.sortAllChildren(); this.transform(gl); - this.draw(gl); - if (locGrid && locGrid.isActive()) - locGrid.afterDraw(this); - cc.kmGLPopMatrix(); + //this.draw(gl); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); + +/* if (locGrid && locGrid.isActive()) + locGrid.afterDraw(this);*/ + + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); this.arrivalOrder = 0; }, diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index dca88d7a73..6555014ff5 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -256,7 +256,6 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ * textureAtlas.initWithTexture(texture, 3); */ initWithTexture: function (texture, capacity) { - cc.assert(texture, cc._LogInfos.TextureAtlas_initWithTexture); capacity = 0 | (capacity); @@ -293,9 +292,7 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ * @param {Number} index */ updateQuad: function (quad, index) { - cc.assert(quad, cc._LogInfos.TextureAtlas_updateQuad); - cc.assert(index >= 0 && index < this._capacity, cc._LogInfos.TextureAtlas_updateQuad_2); this._totalQuads = Math.max(index + 1, this._totalQuads); @@ -310,7 +307,6 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ * @param {Number} index */ insertQuad: function (quad, index) { - cc.assert(index < this._capacity, cc._LogInfos.TextureAtlas_insertQuad_2); this._totalQuads++; @@ -406,7 +402,6 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ * @param {Number} index */ removeQuadAtIndex: function (index) { - cc.assert(index < this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadAtIndex); var quadSize = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; @@ -427,7 +422,6 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ * @param {Number} amount */ removeQuadsAtIndex: function (index, amount) { - cc.assert(index + amount <= this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadsAtIndex); this._totalQuads -= amount; @@ -555,9 +549,7 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ if (amount === 0) return; } else { - cc.assert((newIndex + amount) <= this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_2); - cc.assert(oldIndex < this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_3); if (oldIndex == newIndex) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index b6f4accb1a..18465114df 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -150,7 +150,11 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, _initRendererCmd: function(){ - this._rendererCmd = new cc.RenderTextureRenderCmdCanvas(this); + //TODO need merge in some code + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._rendererCmd = new cc.RenderTextureRenderCmdCanvas(this); + else + this._rendererCmd = new cc.RenderTextureRenderCmdWebGL(this); }, _ctorForWebGL: function (width, height, format, depthStencilFormat) { @@ -284,9 +288,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ if (cc.configuration.checkForGLExtension("GL_QCOM")) { this._textureCopy = new cc.Texture2D(); - if (!this._textureCopy) { + if (!this._textureCopy) return false; - } this._textureCopy.initWithData(data, this._pixelFormat, powW, powH, cc.size(width, height)); } @@ -632,18 +635,21 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ cc.kmGLPushMatrix(); - var locGrid = this.grid; +/* var locGrid = this.grid; if (locGrid && locGrid.isActive()) { locGrid.beforeDraw(); this.transformAncestors(); - } + }*/ this.transform(ctx); + this.toRenderer(); + this.sprite.visit(); this.draw(ctx); - if (locGrid && locGrid.isActive()) - locGrid.afterDraw(this); + //TODO GridNode +/* if (locGrid && locGrid.isActive()) + locGrid.afterDraw(this);*/ cc.kmGLPopMatrix(); From 9b1dfb535ce644b49ab79c6a33d1bedc075279fc Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 23 Sep 2014 10:38:22 +0800 Subject: [PATCH 0673/1564] Issue #5933: Scale9Sprite --- .../ccui/base-classes/UIScale9Sprite.js | 31 +++++++++++++++++++ .../gui/control-extension/CCScale9Sprite.js | 20 +++++++----- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index fa78d4cd68..3c9a8126b2 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -27,6 +27,29 @@ Created by Jung Sang-Taik on 2012-03-16 ****************************************************************************/ + +ccui.Scale9SpriteStartCanvasCmd = function(node){ + this._node = node; +}; + +ccui.Scale9SpriteStartCanvasCmd.prototype.rendering = function(ctx){ + ctx = ctx || cc._renderContext; + + var p = this._node._transformWorld; + ctx.save(); + ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); +}; + +ccui.Scale9SpriteEndCanvasCmd = function(node){ + this._node = node; +}; + +ccui.Scale9SpriteEndCanvasCmd.prototype.rendering = function(ctx){ + ctx = ctx || cc._renderContext; + ctx.restore(); +}; + + /** *

    * A 9-slice sprite for cocos2d UI.
    @@ -219,6 +242,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ contentSizeChanged = true; } + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); + } + //cc._renderContext = this._cacheContext; cc.view._setScaleXYForRenderTexture(); this._scale9Image.visit(this._cacheContext); @@ -252,6 +279,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + + this._rendererCmd = new cc.Scale9SpriteEndCanvasCmd(this); + this._rendererStartCanvasCmd = new cc.Scale9SpriteStartCanvasCmd(this); + var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); locCacheCanvas.width = 1; locCacheCanvas.height = 1; diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index fcafb43679..bb59f21734 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -27,11 +27,11 @@ Created by Jung Sang-Taik on 2012-03-16 ****************************************************************************/ -cc.Scale9SpriteStartCmd = function(node){ +cc.Scale9SpriteStartCanvasCmd = function(node){ this._node = node; }; -cc.Scale9SpriteStartCmd.prototype.rendering = function(ctx){ +cc.Scale9SpriteStartCanvasCmd.prototype.rendering = function(ctx){ ctx = ctx || cc._renderContext; var p = this._node._transformWorld; @@ -39,16 +39,15 @@ cc.Scale9SpriteStartCmd.prototype.rendering = function(ctx){ ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); }; -cc.Scale9SpriteEndCmd = function(node){ +cc.Scale9SpriteEndCanvasCmd = function(node){ this._node = node; }; -cc.Scale9SpriteEndCmd.prototype.rendering = function(ctx){ +cc.Scale9SpriteEndCanvasCmd.prototype.rendering = function(ctx){ ctx = ctx || cc._renderContext; ctx.restore(); }; - /** * A 9-slice sprite for cocos2d. * @@ -239,7 +238,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ contentSizeChanged = true; } - cc.renderer.pushRenderCommand(this._rendererStartCmd); + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); + } + //cc._renderContext = this._cacheContext; cc.view._setScaleXYForRenderTexture(); this._scale9Image.visit(this._cacheContext); @@ -270,11 +272,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._capInsets = cc.rect(0, 0, 0, 0); this._loadedEventListeners = []; - this._rendererStartCmd = new cc.Scale9SpriteStartCmd(this); - this._rendererCmd = new cc.Scale9SpriteEndCmd(this); //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + + this._rendererCmd = new cc.Scale9SpriteEndCanvasCmd(this); + this._rendererStartCanvasCmd = new cc.Scale9SpriteStartCanvasCmd(this); + var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); locCacheCanvas.width = 1; locCacheCanvas.height = 1; From afc5e48ee7b1e33fd86135db8e71f6b04baf73e3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 23 Sep 2014 11:36:03 +0800 Subject: [PATCH 0674/1564] Issue #5941: add CustomRenderCmd to new renderer --- cocos2d/core/renderer/RendererCanvas.js | 11 +++++++++++ cocos2d/core/renderer/RendererWebGL.js | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 197c692efc..889c9f17e5 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -817,4 +817,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } cc.g_NumberOfDraws++; }; + + cc.CustomRenderCmdCanvas = function(node, func){ + this._node = node; + this._callback = func; + }; + + cc.CustomRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + if(!this._callback) + return; + this._callback.call(this.node, ctx, scaleX, scaleY); + }; } diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index d45e0fa714..99da9b3353 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -394,4 +394,15 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); } }; + + cc.CustomRenderCmdWebGL = function(node, func){ + this._node = node; + this._callback = func; + }; + + cc.CustomRenderCmdWebGL.prototype.rendering = function(ctx){ + if(!this._callback) + return; + this._callback.call(this.node, ctx); + }; } From b40cbf7a2256bc80b7978e7024933e7eaebbd8bb Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 23 Sep 2014 11:43:34 +0800 Subject: [PATCH 0675/1564] add ParticleRenderCmdWebGL --- cocos2d/core/renderer/RendererWebGL.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index dcb81cd090..e082f98689 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -300,4 +300,19 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; + + cc.ParticleBatchNodeRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.ParticleBatchNodeRenderCmdWebGL.prototype.rendering = function(ctx){ + var _t = this._node; + if (_t.textureAtlas.totalQuads == 0) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + _t.textureAtlas.drawQuads(); + }; } From 27fe3fe883292801993e0f91c2f5d816c950862e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 23 Sep 2014 11:54:59 +0800 Subject: [PATCH 0676/1564] Fixed IE9,IE10 IMG.crossOrign is not define. --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 38cb4ddaee..b362fc5b55 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -752,7 +752,7 @@ cc.loader = /** @lends cc.loader# */{ var ecb = function () { this.removeEventListener('error', ecb, false); - if(img.crossOrigin.toLowerCase() == "anonymous"){ + if(img.crossOrigin && img.crossOrigin.toLowerCase() == "anonymous"){ opt.isCrossOrigin = false; cc.loader.loadImg(url, opt, cb); }else{ From 22167832edf41f3996895d37e327a08ed7507d6c Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 23 Sep 2014 14:10:02 +0800 Subject: [PATCH 0677/1564] add webgl render command for TMXLayer --- cocos2d/core/renderer/RendererWebGL.js | 6 ++++++ cocos2d/tilemap/CCTMXLayer.js | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index de5a702831..5eb9e268ee 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -420,4 +420,10 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ return; this._callback.call(this.node, ctx); }; + + cc.TMXLayerRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.TMXLayerRenderCmdWebGL.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; } diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 87f164bb96..931385e5f0 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -118,7 +118,10 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, _initRendererCmd: function(){ - this._rendererCmd = new cc.TMXLayerRenderCmdCanvas(this); + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._rendererCmd = new cc.TMXLayerRenderCmdCanvas(this); + else + this._rendererCmd = new cc.TMXLayerRenderCmdWebGL(this); }, /** From e8c2334ed8734e41121bb59c7c75259348814b45 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 23 Sep 2014 15:13:41 +0800 Subject: [PATCH 0678/1564] Issue #5941: adds LabelTTF to new renderer for WebGL --- cocos2d/core/labelttf/LabelTTFWebGL.js | 8 +++++++ cocos2d/core/renderer/RendererCanvas.js | 2 +- cocos2d/core/renderer/RendererWebGL.js | 2 +- cocos2d/shaders/CCGLProgram.js | 30 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/labelttf/LabelTTFWebGL.js b/cocos2d/core/labelttf/LabelTTFWebGL.js index fca3251d3a..eeafc15f24 100644 --- a/cocos2d/core/labelttf/LabelTTFWebGL.js +++ b/cocos2d/core/labelttf/LabelTTFWebGL.js @@ -30,6 +30,14 @@ cc._tmp.WebGLLabelTTF = function () { _p.setColor = cc.Sprite.prototype.setColor; + _p._transformForRenderer = function(){ + if (this._needUpdateTexture) { + this._needUpdateTexture = false; + this._updateTexture(); + } + cc.Node.prototype._transformForRenderer.call(this); + }; + _p._setColorsString = function () { this._needUpdateTexture = true; var locStrokeColor = this._strokeColor, locFontFillColor = this._textFillColor; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 889c9f17e5..9cd11cca56 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -826,6 +826,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.CustomRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ if(!this._callback) return; - this._callback.call(this.node, ctx, scaleX, scaleY); + this._callback.call(this._node, ctx, scaleX, scaleY); }; } diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 99da9b3353..2bcdd3be5d 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -403,6 +403,6 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ cc.CustomRenderCmdWebGL.prototype.rendering = function(ctx){ if(!this._callback) return; - this._callback.call(this.node, ctx); + this._callback.call(this._node, ctx); }; } diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index fda6c89b7a..3a1fc7faed 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -571,6 +571,36 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); }, + _setUniformsForBuiltinsForRenderer: function (node) { + var matrixP = new cc.kmMat4(); + //var matrixMV = new cc.kmMat4(); + var matrixMVP = new cc.kmMat4(); + + cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, matrixP); + //cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, node._stackMatrix); + + cc.kmMat4Multiply(matrixMVP, matrixP, node._stackMatrix); + + this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], matrixP.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], node._stackMatrix.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], matrixMVP.mat, 1); + + if (this._usesTime) { + var director = cc.director; + // This doesn't give the most accurate global time value. + // Cocos2D doesn't store a high precision time value, so this will have to do. + // Getting Mach time per frame per shader using time could be extremely expensive. + var time = director.getTotalFrames() * director.getAnimationInterval(); + + this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME], time / 10.0, time, time * 2, time * 4); + this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME], time / 8.0, time / 4.0, time / 2.0, Math.sin(time)); + this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time)); + } + + if (this._uniforms[cc.UNIFORM_RANDOM01] != -1) + this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); + }, + /** * will update the MVP matrix on the MVP uniform if it is different than the previous call for this same shader program. */ From 69f62695d8affb147dc743226c6759855fe774e7 Mon Sep 17 00:00:00 2001 From: mutoo Date: Tue, 23 Sep 2014 16:24:57 +0800 Subject: [PATCH 0679/1564] fix UIWidget._positionPercent issue; --- extensions/ccui/base-classes/UIWidget.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index c1c82da4cb..9166593c39 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -974,11 +974,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._positionPercent.y = 0; } else { if (posY == undefined) { - this._positionPercent.x = pos / pSize.width; - this._positionPercent.y = posY / pSize.height; - } else { this._positionPercent.x = pos.x / pSize.width; this._positionPercent.y = pos.y / pSize.height; + } else { + this._positionPercent.x = pos / pSize.width; + this._positionPercent.y = posY / pSize.height; } } } From 4334b9709cbea661930c9bfdecbc550eedef4a4f Mon Sep 17 00:00:00 2001 From: mutoo Date: Tue, 23 Sep 2014 16:27:32 +0800 Subject: [PATCH 0680/1564] UILoadingBar: replaced addChild() with addProtectedChild() to add _barRenderer; --- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 4ee694c239..e83ebd7aa6 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -69,7 +69,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _initRenderer: function () { this._barRenderer = cc.Sprite.create(); - cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); + this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); this._barRenderer.setAnchorPoint(0.0, 0.5); }, From 0b1989aae17ab80d8e519155d8d562f0136acd31 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 23 Sep 2014 18:18:08 +0800 Subject: [PATCH 0681/1564] Issue #5933: Cocostudio --- cocos2d/core/base-nodes/CCNode.js | 2 +- cocos2d/core/renderer/RendererCanvas.js | 10 ++-- cocos2d/core/sprites/CCSprite.js | 11 ---- .../ccui/base-classes/CCProtectedNode.js | 9 ++- .../ccui/base-classes/UIScale9Sprite.js | 59 +++++++++---------- extensions/ccui/uiwidgets/UIButton.js | 3 + 6 files changed, 44 insertions(+), 50 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 8f2dae9b87..98e4cd2ead 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2635,7 +2635,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { worldT.b = t.a * pt.b + t.b * pt.d; //b worldT.c = t.c * pt.a + t.d * pt.c; //c worldT.d = t.c * pt.b + t.d * pt.d; //d - if(!this._skewX || this._skewY){ + if(this._skewX || this._skewY){ var plt = this._parent._transform; var xOffset = -(plt.b + plt.c) * t.ty ; var yOffset = -(plt.b + plt.c) * t.tx; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 889c9f17e5..0e1a3e34d5 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -126,8 +126,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //Sprite setTextureRect override ^.^ get x(){ return node._offsetPosition.x; }, get y(){ return node._offsetPosition.y - node._rect.height; }, - get width(){ return node._drawSize_Canvas.width; }, - get height(){ return node._drawSize_Canvas.height; } + get width(){ return node._rect.width; }, + get height(){ return node._rect.height; } }; }; @@ -167,8 +167,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextureCoord.height, locDrawingRect.x, locDrawingRect.y, - locDrawingRect.width, - locDrawingRect.height + locDrawingRect.width * scaleX, + locDrawingRect.height * scaleY ); } @@ -826,6 +826,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.CustomRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ if(!this._callback) return; - this._callback.call(this.node, ctx, scaleX, scaleY); + this._callback.call(this._node, ctx, scaleX, scaleY); }; } diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 1aa3537322..8cc665600e 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1172,17 +1172,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ locQuad.tr.texCoords.v = top; } this._quadDirty = true; - }, - - visit: function(){ - cc.Node.prototype.visit.call(this); - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - return; - var _t = this, locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); - var locRect = _t._rect, - locDrawSizeCanvas = _t._drawSize_Canvas; - locDrawSizeCanvas.width = locRect.width * locEGL_ScaleX; - locDrawSizeCanvas.height = locRect.height * locEGL_ScaleY; } }); diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index a0d5e828b5..be98a4dace 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -268,7 +268,9 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ break; } - _t.draw(context); +// _t.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); for (; i < childLen; i++) children[i] && children[i].visit(context); @@ -316,7 +318,10 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ else break; } - _t.draw(context); +// _t.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); + // draw children zOrder >= 0 for (; i < childLen; i++) { locChildren[i] && locChildren[i].visit(); diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 3c9a8126b2..04a4ea9fe8 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -27,29 +27,6 @@ Created by Jung Sang-Taik on 2012-03-16 ****************************************************************************/ - -ccui.Scale9SpriteStartCanvasCmd = function(node){ - this._node = node; -}; - -ccui.Scale9SpriteStartCanvasCmd.prototype.rendering = function(ctx){ - ctx = ctx || cc._renderContext; - - var p = this._node._transformWorld; - ctx.save(); - ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); -}; - -ccui.Scale9SpriteEndCanvasCmd = function(node){ - this._node = node; -}; - -ccui.Scale9SpriteEndCanvasCmd.prototype.rendering = function(ctx){ - ctx = ctx || cc._renderContext; - ctx.restore(); -}; - - /** *

    * A 9-slice sprite for cocos2d UI.
    @@ -242,10 +219,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ contentSizeChanged = true; } - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); - } - //cc._renderContext = this._cacheContext; cc.view._setScaleXYForRenderTexture(); this._scale9Image.visit(this._cacheContext); @@ -280,8 +253,17 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererCmd = new cc.Scale9SpriteEndCanvasCmd(this); - this._rendererStartCanvasCmd = new cc.Scale9SpriteStartCanvasCmd(this); + this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + ctx = ctx || cc._renderContext; + + var p = this._transformWorld; + ctx.save(); + ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); + }); + this._rendererEndCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + ctx = ctx || cc._renderContext; + ctx.restore(); + }); var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); locCacheCanvas.width = 1; @@ -326,6 +308,14 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ return this._preferredSize.height; }, setPreferredSize: function (preferredSize) { + + if (this._positionsAreDirty) { + this._updatePositions(); + this._positionsAreDirty = false; + this._scale9Dirty = true; + } + + this.setContentSize(preferredSize); this._preferredSize = preferredSize; }, @@ -512,16 +502,23 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, visit: function (ctx) { + if(!this._visible){ + return; + } + if (this._positionsAreDirty) { this._updatePositions(); this._positionsAreDirty = false; this._scale9Dirty = true; } - if(this._scale9Dirty && cc._renderType === cc._RENDER_TYPE_CANVAS){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); this._scale9Dirty = false; this._cacheScale9Sprite(); + + cc.Node.prototype.visit.call(this, ctx); + cc.renderer.pushRenderCommand(this._rendererEndCanvasCmd); } - cc.Node.prototype.visit.call(this, ctx); }, /** diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 752b48cb26..f89eb5a233 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -161,6 +161,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonDisableRenderer = cc.Sprite.create(); } + this._buttonClickedRenderer.setVisible(false); + this._buttonDisableRenderer.setVisible(false); + this.loadTextureNormal(this._normalFileName, this._normalTexType); this.loadTexturePressed(this._clickedFileName, this._pressedTexType); this.loadTextureDisabled(this._disabledFileName, this._disabledTexType); From 5c240d7e9ea6e0137eb95170120f7149bb782311 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 24 Sep 2014 10:22:40 +0800 Subject: [PATCH 0682/1564] Issue #5941: add renderTexture to new renderer for WebGL --- cocos2d/core/base-nodes/CCNode.js | 2 +- cocos2d/core/renderer/RendererWebGL.js | 25 ++++++++++++++++++----- cocos2d/render-texture/CCRenderTexture.js | 17 ++++++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 8f2dae9b87..98e4cd2ead 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2635,7 +2635,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { worldT.b = t.a * pt.b + t.b * pt.d; //b worldT.c = t.c * pt.a + t.d * pt.c; //c worldT.d = t.c * pt.b + t.d * pt.d; //d - if(!this._skewX || this._skewY){ + if(this._skewX || this._skewY){ var plt = this._parent._transform; var xOffset = -(plt.b + plt.c) * t.ty ; var yOffset = -(plt.b + plt.c) * t.tx; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 2263f1d5e0..57d8ae1957 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -28,8 +28,8 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ _transformNodePool: [], //save nodes transform dirty _renderCmds: [], //save renderer commands - _isCacheToCanvasOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds - _cacheToCanvasCmds: [], // an array saves the renderer commands need for cache to other canvas + _isCacheToBufferOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds + _cacheToBufferCmds: [], // an array saves the renderer commands need for cache to other canvas /** * drawing all renderer command to context (default is cc._renderContext) @@ -45,6 +45,21 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ } }, + /** + * drawing all renderer command to cache canvas' context + * @param {CanvasRenderingContext2D} ctx + */ + _renderingToBuffer: function (ctx) { + var locCmds = this._cacheToCanvasCmds, i, len; + ctx = ctx || cc._renderContext; + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(ctx, 1, 1); + } + + locCmds.length = 0; + this._isCacheToCanvasOn = false; + }, + //reset renderer's flag resetFlag: function () { this.childrenOrderDirty = false; @@ -83,9 +98,9 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ }, pushRenderCommand: function (cmd) { - if (this._isCacheToCanvasOn) { - if (this._cacheToCanvasCmds.indexOf(cmd) === -1) - this._cacheToCanvasCmds.push(cmd); + if (this._isCacheToBufferOn) { + if (this._cacheToBufferCmds.indexOf(cmd) === -1) + this._cacheToBufferCmds.push(cmd); } else { if (this._renderCmds.indexOf(cmd) === -1) this._renderCmds.push(cmd); diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 42cb2d59ec..505eafc63b 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -116,6 +116,13 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ _clearColorStr:null, _className:"RenderTexture", + //for WebGL + _beginWithClearCommand: null, + _clearDepthCommand: null, + _clearCommand: null, + _beginCommand: null, + _endCommand: null, + /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid * Constructor of cc.RenderTexture for Canvas @@ -153,8 +160,9 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ //TODO need merge in some code if(cc._renderType === cc._RENDER_TYPE_CANVAS) this._rendererCmd = new cc.RenderTextureRenderCmdCanvas(this); - else + else{ this._rendererCmd = new cc.RenderTextureRenderCmdWebGL(this); + } }, _ctorForWebGL: function (width, height, format, depthStencilFormat) { @@ -356,6 +364,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, _beginForWebGL: function () { + cc.renderer._isCacheToBufferOn = true; + // Save the current matrix cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLPushMatrix(); @@ -503,6 +513,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, _endForWebGL: function () { + cc.renderer._renderingToBuffer(); + var gl = cc._renderContext; var director = cc.director; gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO); @@ -641,7 +653,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }*/ this.transform(ctx); - this.toRenderer(); + //this.toRenderer(); this.sprite.visit(); this.draw(ctx); @@ -686,7 +698,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ if (getChild != selfSprite) getChild.visit(); } - this.end(); } }, From ae62f0b36b15ab5b10de955ee0a3d730565a3796 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 24 Sep 2014 10:32:15 +0800 Subject: [PATCH 0683/1564] add webgl render commands for PhysicsDebugNode and PhysicsSprite --- cocos2d/core/renderer/RendererCanvas.js | 4 ++-- cocos2d/core/renderer/RendererWebGL.js | 25 +++++++++++++++++++++++++ cocos2d/physics/CCPhysicsDebugNode.js | 9 ++++++--- cocos2d/physics/CCPhysicsSprite.js | 8 ++++---- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 9cd11cca56..3be84732b6 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -744,11 +744,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; - cc.PhysicsSpriteTransformCmdCanvas = function (node) { + cc.PhysicsSpriteTransformCmd = function (node) { this._node = node; }; - cc.PhysicsSpriteTransformCmdCanvas.prototype.rendering = function () { + cc.PhysicsSpriteTransformCmd.prototype.rendering = function () { if (this._node.transform) { this._node.transform(); } diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 2263f1d5e0..c020b446a9 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -426,4 +426,29 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ }; cc.TMXLayerRenderCmdWebGL.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; + + cc.PhysicsDebugNodeRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.PhysicsDebugNodeRenderCmdWebGL.prototype.rendering = function(ctx){ + var node = this._node; + if (!node._space) + return; + + node._space.eachShape(cc.DrawShape.bind(node)); + node._space.eachConstraint(cc.DrawConstraint.bind(node)); + cc.DrawNode.prototype.draw.call(node); + node.clear(); + }; + + cc.PhysicsSpriteTransformCmd = function (node) { + this._node = node; + }; + + cc.PhysicsSpriteTransformCmd.prototype.rendering = function () { + if (this._node.transform) { + this._node._transformForRenderer(); + } + }; } diff --git a/cocos2d/physics/CCPhysicsDebugNode.js b/cocos2d/physics/CCPhysicsDebugNode.js index b56b60d28f..0ce8fd171f 100644 --- a/cocos2d/physics/CCPhysicsDebugNode.js +++ b/cocos2d/physics/CCPhysicsDebugNode.js @@ -161,11 +161,14 @@ cc.PhysicsDebugNode = cc.DrawNode.extend({ ctor: function (space) { cc.DrawNode.prototype.ctor.call(this); this._space = space; - this._rendererCmd = new cc.PhysicsDebugNodeRenderCmdCanvas(this); - - cc.rendererCanvas.pushRenderCommand(this._rendererCmd); }, + _initRendererCmd:function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._rendererCmd = new cc.PhysicsDebugNodeRenderCmdCanvas(this); + else + this._rendererCmd = new cc.PhysicsDebugNodeRenderCmdWebGL(this); + }, /** * get space * @returns {cp.Space} diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index deb44d36a3..07b1970475 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -223,7 +223,7 @@ * var physicsSprite1 = cc.PhysicsSprite.create("res/HelloHTML5World.png"); * var physicsSprite2 = new cc.PhysicsSprite("res/HelloHTML5World.png",cc.rect(0,0,480,320)); * - * 2.Create a sprite with a sprite frame name. Must add "#" before fame name. + * 2.Create a sprite with a sprite frame name. Must add "#" before frame name. * var physicsSprite = new cc.PhysicsSprite('#grossini_dance_01.png'); * * 3.Create a sprite with a sprite frame @@ -261,13 +261,13 @@ this.initWithSpriteFrame(fileName); } } - this._transformCmd = new cc.PhysicsSpriteTransformCmdCanvas(this); - cc.rendererCanvas.pushRenderCommand(this._transformCmd); + this._transformCmd = new cc.PhysicsSpriteTransformCmd(this); + cc.renderer.pushRenderCommand(this._transformCmd); }, visit: function(){ cc.Sprite.prototype.visit.call(this); - cc.rendererCanvas.pushRenderCommand(this._transformCmd); + cc.renderer.pushRenderCommand(this._transformCmd); }, /** From 51c20903cd2f6f04edcad525bc8ac91edce72a9a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 24 Sep 2014 14:47:57 +0800 Subject: [PATCH 0684/1564] Issue #5941: Fixed a bug of cc.Sprite that its transform is incorrect when it flipped --- cocos2d/core/base-nodes/CCNode.js | 6 ++++-- cocos2d/core/sprites/CCSprite.js | 1 - extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 98e4cd2ead..e5bc3955cd 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2749,8 +2749,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * appY * sy; - t.ty -= Sin * -appX * sx + Cos * appY * sy; + if(!this._flippedX) //TODO modify for new renderer + t.tx += Cos * -appX * sx + -Sin * appY * sy; + if(!this._flippedY) + t.ty -= Sin * -appX * sx + Cos * appY * sy; // if ignore anchorPoint if (_t._ignoreAnchorPointForPosition) { diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 8cc665600e..6d075b954c 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1479,7 +1479,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; _p.addChild = function (child, localZOrder, tag) { - cc.assert(child, cc._LogInfos.CCSpriteBatchNode_addChild_2); if (localZOrder == null) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 4ee694c239..865b8f1dc4 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -286,7 +286,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ */ setContentSize: function(contentSize, height){ ccui.Widget.prototype.setContentSize.call(this, contentSize, height); - this._totalLength = (height === undefined) ? contentSize.width : contentSize;; + this._totalLength = (height === undefined) ? contentSize.width : contentSize; }, /** From 5688a94d065321467884c997cc8d783d2f5eb558 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 24 Sep 2014 18:06:47 +0800 Subject: [PATCH 0685/1564] Feature #5941: Activate WebGL for iOS TODO: need to specify version --- CCBoot.js | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 38cb4ddaee..1ec001f206 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1454,7 +1454,8 @@ cc._initSys = function (config, CONFIG_KEY) { */ sys.isNative = false; - var webglWhiteList = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI]; + var browserSupportWebGL = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI]; + var osSupportWebGL = [sys.OS_IOS, sys.OS_WINDOWS, sys.OS_OSX, sys.OS_LINUX]; var multipleAudioWhiteList = [ sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_BAIDU_APP, sys.BROWSER_TYPE_SAFARI, sys.BROWSER_TYPE_UC, sys.BROWSER_TYPE_QQ, sys.BROWSER_TYPE_MOBILE_QQ, sys.BROWSER_TYPE_IE @@ -1510,6 +1511,24 @@ cc._initSys = function (config, CONFIG_KEY) { */ sys.browserType = browserType; + // Get the os of system + var iOS = ( ua.match(/(iPad|iPhone|iPod)/i) ? true : false ); + var isAndroid = ua.match(/android/i) || nav.platform.match(/android/i) ? true : false; + var osName = sys.OS_UNKNOWN; + if (nav.appVersion.indexOf("Win") != -1) osName = sys.OS_WINDOWS; + else if (iOS) osName = sys.OS_IOS; + else if (nav.appVersion.indexOf("Mac") != -1) osName = sys.OS_OSX; + else if (nav.appVersion.indexOf("X11") != -1) osName = sys.OS_UNIX; + else if (isAndroid) osName = sys.OS_ANDROID; + else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; + + /** + * Indicate the running os name + * @memberof cc.sys + * @name os + * @type {String} + */ + sys.os = osName; sys._supportMultipleAudio = multipleAudioWhiteList.indexOf(sys.browserType) > -1; @@ -1519,8 +1538,8 @@ cc._initSys = function (config, CONFIG_KEY) { var renderType = cc._RENDER_TYPE_WEBGL; var tempCanvas = cc.newElement("Canvas"); cc._supportRender = true; - var notInWhiteList = webglWhiteList.indexOf(sys.browserType) == -1; - if (userRenderMode === 1 || (userRenderMode === 0 && (sys.isMobile || notInWhiteList)) || (location.origin == "file://")) { + var notSupportGL = browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1; + if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://")) { renderType = cc._RENDER_TYPE_CANVAS; } @@ -1564,7 +1583,7 @@ cc._initSys = function (config, CONFIG_KEY) { } } cc._renderType = renderType; - //++++++++++++++++++something about cc._renderTYpe and cc._supportRender end++++++++++++++++++++++++++++++ + //++++++++++++++++++something about cc._renderType and cc._supportRender end++++++++++++++++++++++++++++++ // check if browser supports Web Audio // check Web Audio's context @@ -1605,25 +1624,6 @@ cc._initSys = function (config, CONFIG_KEY) { if (win.DeviceMotionEvent || win.DeviceOrientationEvent) capabilities["accelerometer"] = true; - // Get the os of system - var iOS = ( ua.match(/(iPad|iPhone|iPod)/i) ? true : false ); - var isAndroid = ua.match(/android/i) || nav.platform.match(/android/i) ? true : false; - var osName = sys.OS_UNKNOWN; - if (nav.appVersion.indexOf("Win") != -1) osName = sys.OS_WINDOWS; - else if (iOS) osName = sys.OS_IOS; - else if (nav.appVersion.indexOf("Mac") != -1) osName = sys.OS_OSX; - else if (nav.appVersion.indexOf("X11") != -1) osName = sys.OS_UNIX; - else if (isAndroid) osName = sys.OS_ANDROID; - else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; - - /** - * Indicate the running os name - * @memberof cc.sys - * @name os - * @type {String} - */ - sys.os = osName; - /** * Forces the garbage collection * @memberof cc.sys From 51d989d32f14f09f5fdeac6be77d24df925585b2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 24 Sep 2014 23:59:45 +0800 Subject: [PATCH 0686/1564] Fixed #5948: Fix touch event bug with multitouch on iOS --- cocos2d/core/platform/CCInputManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index c6121ad3e2..3e4ebb8bea 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -574,7 +574,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); pos.left -= document.body.scrollLeft; pos.top -= document.body.scrollTop; - locView.handleTouchesCancel(selfPointer.getTouchesByEvent(event, pos)); + selfPointer.handleTouchesCancel(selfPointer.getTouchesByEvent(event, pos)); event.stopPropagation(); event.preventDefault(); }, false); From a0ed0a35f45a797172953f585b95dcc2c1bee785 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 25 Sep 2014 09:41:10 +0800 Subject: [PATCH 0687/1564] Remove Timeline.js --- .../cocostudio/reader/timeline/TimeLine.js | 323 ------------------ 1 file changed, 323 deletions(-) delete mode 100644 extensions/cocostudio/reader/timeline/TimeLine.js diff --git a/extensions/cocostudio/reader/timeline/TimeLine.js b/extensions/cocostudio/reader/timeline/TimeLine.js deleted file mode 100644 index 176c35419c..0000000000 --- a/extensions/cocostudio/reader/timeline/TimeLine.js +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -/** - * timeline object - * @class - * @extend ccs.Class - */ -ccs.Timeline = ccs.Class.extend({ - - //{ccs.Frame} - _frames: null, - //{ccs.Frame} - _currentKeyFrame: null, - //{Number} - _currentKeyFrameIndex: null, - //{Number} - _fromIndex: null, - //{Number} - _toIndex: null, - //{Number} - _betweenDuration: null, - //{Number} - _actionTag: null, - //{ccs.ActionTimeline} - _ActionTimeline: null, - //{cc.Node} - _node: null, - - ctor: function(){ - this._frames = []; - this._currentKeyFrame = null; - this._currentKeyFrameIndex = 0; - this._fromIndex = 0; - this._toIndex = 0; - this._betweenDuration = 0; - this._actionTag = 0; - this._ActionTimeline = null; - this._node = null; - }, - - _gotoFrame: function(frameIndex){ - if(this._frames.length == 0) - return; - - this._binarySearchKeyFrame(frameIndex); - this._apply(frameIndex); - }, - - _stepToFrame: function(frameIndex){ - if(this._frames.length == 0) - return; - - this._updateCurrentKeyFrame(frameIndex); - this._apply(frameIndex); - }, - - /** - * Get the frame list - * @returns {ccs.Frame} - */ - getFrames: function(){ - return this._frames; - }, - - /** - * push frame to frame list - * @param {ccs.Frame} frame - */ - addFrame: function(frame){ - this._frames.push(frame); - frame.setTimeline(this) - }, - - /** - * insert the frame to frame list - * @param {ccs.Frame} frame - * @param {Number} index - */ - insertFrame: function(frame, index){ - this._frames.splice(index, 0, frame); - frame.setTimeline(this); - - }, - - /** - * remove frame - * @param {ccs.Frame} frame - */ - removeFrame: function(frame){ - cc.arrayRemoveObject(this._frames, frame); - frame.setTimeline(null); - }, - - /** - * Set the action tag - * @param {Number} tag - */ - setActionTag: function(tag){ - this._actionTag = tag; - }, - - /** - * Gets the action tag - * return {Number} - */ - getActionTag: function(){ - return this._actionTag; - }, - - /** - * Set the node - * @param {cc.Node} node - */ - setNode: function(node){ - for (var i=0; i= this._frames[0].getFrameIndex()) - needEnterFrame = true; - - from = to = this._frames[0]; - this._currentKeyFrameIndex = 0; - this._betweenDuration = this._frames[0].getFrameIndex(); - break; - } - else if(frameIndex >= this._frames[length - 1].getFrameIndex()) - { - from = to = this._frames[length - 1]; - this._currentKeyFrameIndex = this._frames[length - 1].getFrameIndex(); - this._betweenDuration = 0; - break; - } - - var target = -1; - var low = 0, - high = length - 1, - mid = 0; - while(low <= high){ - mid = Math.ceil(( low + high )/2); - if(frameIndex >= this._frames[mid].getFrameIndex() && frameIndex < this._frames[mid + 1].getFrameIndex()) - { - target = mid; - break; - } - if(this._frames[mid].getFrameIndex()>frameIndex) - high = mid - 1; - else - low = mid + 1; - } - - from = this._frames[target]; - to = this._frames[target+1]; - - if(target == 0 && this._currentKeyFrameIndex < from.getFrameIndex()) - needEnterFrame = true; - - this._currentKeyFrameIndex = from.getFrameIndex(); - this._betweenDuration = to.getFrameIndex() - from.getFrameIndex(); - } while (0); - - if(needEnterFrame || this._currentKeyFrame != from) - { - this._currentKeyFrame = from; - this._currentKeyFrame.onEnter(to); - } - - }, - - _updateCurrentKeyFrame: function(frameIndex){ - //! If play to current frame's front or back, then find current frame again - if (frameIndex < this._currentKeyFrameIndex || frameIndex >= this._currentKeyFrameIndex + this._betweenDuration) - { - var from = null; - var to = null; - - do - { - var length = this._frames.length; - - if (frameIndex < this._frames[0].getFrameIndex()) - { - from = to = this._frames[0]; - this._currentKeyFrameIndex = 0; - this._betweenDuration = this._frames[0].getFrameIndex(); - break; - } - else if(frameIndex >= this._frames[length - 1].getFrameIndex()) - { - from = to = this._frames[length - 1]; - this._currentKeyFrameIndex = this._frames[length - 1].getFrameIndex(); - this._betweenDuration = 0; - break; - } - - do{ - this._fromIndex = this._toIndex; - from = this._frames[this._fromIndex]; - this._currentKeyFrameIndex = from.getFrameIndex(); - - this._toIndex = this._fromIndex + 1; - if (this._toIndex >= length) - { - this._toIndex = 0; - } - - to = this._frames[this._toIndex]; - - if (frameIndex == from.getFrameIndex()) - { - break; - } - }while (frameIndex < from.getFrameIndex() || frameIndex >= to.getFrameIndex()); - - this._betweenDuration = to.getFrameIndex() - from.getFrameIndex(); - - } while (0); - - this._currentKeyFrame = from; - this._currentKeyFrame.onEnter(to); - } - } - -}); - -/** - * Create the Timeline - * - * @deprecated v3.0, please use new ccs.Timeline() instead. - * @returns {ccs.Timeline} - */ -ccs.Timeline.create = function(){ - return new ccs.Timeline(); -}; \ No newline at end of file From 7e426dfb4751134358b577e4df3b063ee982b500 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 25 Sep 2014 09:43:51 +0800 Subject: [PATCH 0688/1564] Create Timeline.js --- .../cocostudio/reader/timeline/Timeline.js | 323 ++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 extensions/cocostudio/reader/timeline/Timeline.js diff --git a/extensions/cocostudio/reader/timeline/Timeline.js b/extensions/cocostudio/reader/timeline/Timeline.js new file mode 100644 index 0000000000..176c35419c --- /dev/null +++ b/extensions/cocostudio/reader/timeline/Timeline.js @@ -0,0 +1,323 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * timeline object + * @class + * @extend ccs.Class + */ +ccs.Timeline = ccs.Class.extend({ + + //{ccs.Frame} + _frames: null, + //{ccs.Frame} + _currentKeyFrame: null, + //{Number} + _currentKeyFrameIndex: null, + //{Number} + _fromIndex: null, + //{Number} + _toIndex: null, + //{Number} + _betweenDuration: null, + //{Number} + _actionTag: null, + //{ccs.ActionTimeline} + _ActionTimeline: null, + //{cc.Node} + _node: null, + + ctor: function(){ + this._frames = []; + this._currentKeyFrame = null; + this._currentKeyFrameIndex = 0; + this._fromIndex = 0; + this._toIndex = 0; + this._betweenDuration = 0; + this._actionTag = 0; + this._ActionTimeline = null; + this._node = null; + }, + + _gotoFrame: function(frameIndex){ + if(this._frames.length == 0) + return; + + this._binarySearchKeyFrame(frameIndex); + this._apply(frameIndex); + }, + + _stepToFrame: function(frameIndex){ + if(this._frames.length == 0) + return; + + this._updateCurrentKeyFrame(frameIndex); + this._apply(frameIndex); + }, + + /** + * Get the frame list + * @returns {ccs.Frame} + */ + getFrames: function(){ + return this._frames; + }, + + /** + * push frame to frame list + * @param {ccs.Frame} frame + */ + addFrame: function(frame){ + this._frames.push(frame); + frame.setTimeline(this) + }, + + /** + * insert the frame to frame list + * @param {ccs.Frame} frame + * @param {Number} index + */ + insertFrame: function(frame, index){ + this._frames.splice(index, 0, frame); + frame.setTimeline(this); + + }, + + /** + * remove frame + * @param {ccs.Frame} frame + */ + removeFrame: function(frame){ + cc.arrayRemoveObject(this._frames, frame); + frame.setTimeline(null); + }, + + /** + * Set the action tag + * @param {Number} tag + */ + setActionTag: function(tag){ + this._actionTag = tag; + }, + + /** + * Gets the action tag + * return {Number} + */ + getActionTag: function(){ + return this._actionTag; + }, + + /** + * Set the node + * @param {cc.Node} node + */ + setNode: function(node){ + for (var i=0; i= this._frames[0].getFrameIndex()) + needEnterFrame = true; + + from = to = this._frames[0]; + this._currentKeyFrameIndex = 0; + this._betweenDuration = this._frames[0].getFrameIndex(); + break; + } + else if(frameIndex >= this._frames[length - 1].getFrameIndex()) + { + from = to = this._frames[length - 1]; + this._currentKeyFrameIndex = this._frames[length - 1].getFrameIndex(); + this._betweenDuration = 0; + break; + } + + var target = -1; + var low = 0, + high = length - 1, + mid = 0; + while(low <= high){ + mid = Math.ceil(( low + high )/2); + if(frameIndex >= this._frames[mid].getFrameIndex() && frameIndex < this._frames[mid + 1].getFrameIndex()) + { + target = mid; + break; + } + if(this._frames[mid].getFrameIndex()>frameIndex) + high = mid - 1; + else + low = mid + 1; + } + + from = this._frames[target]; + to = this._frames[target+1]; + + if(target == 0 && this._currentKeyFrameIndex < from.getFrameIndex()) + needEnterFrame = true; + + this._currentKeyFrameIndex = from.getFrameIndex(); + this._betweenDuration = to.getFrameIndex() - from.getFrameIndex(); + } while (0); + + if(needEnterFrame || this._currentKeyFrame != from) + { + this._currentKeyFrame = from; + this._currentKeyFrame.onEnter(to); + } + + }, + + _updateCurrentKeyFrame: function(frameIndex){ + //! If play to current frame's front or back, then find current frame again + if (frameIndex < this._currentKeyFrameIndex || frameIndex >= this._currentKeyFrameIndex + this._betweenDuration) + { + var from = null; + var to = null; + + do + { + var length = this._frames.length; + + if (frameIndex < this._frames[0].getFrameIndex()) + { + from = to = this._frames[0]; + this._currentKeyFrameIndex = 0; + this._betweenDuration = this._frames[0].getFrameIndex(); + break; + } + else if(frameIndex >= this._frames[length - 1].getFrameIndex()) + { + from = to = this._frames[length - 1]; + this._currentKeyFrameIndex = this._frames[length - 1].getFrameIndex(); + this._betweenDuration = 0; + break; + } + + do{ + this._fromIndex = this._toIndex; + from = this._frames[this._fromIndex]; + this._currentKeyFrameIndex = from.getFrameIndex(); + + this._toIndex = this._fromIndex + 1; + if (this._toIndex >= length) + { + this._toIndex = 0; + } + + to = this._frames[this._toIndex]; + + if (frameIndex == from.getFrameIndex()) + { + break; + } + }while (frameIndex < from.getFrameIndex() || frameIndex >= to.getFrameIndex()); + + this._betweenDuration = to.getFrameIndex() - from.getFrameIndex(); + + } while (0); + + this._currentKeyFrame = from; + this._currentKeyFrame.onEnter(to); + } + } + +}); + +/** + * Create the Timeline + * + * @deprecated v3.0, please use new ccs.Timeline() instead. + * @returns {ccs.Timeline} + */ +ccs.Timeline.create = function(){ + return new ccs.Timeline(); +}; \ No newline at end of file From 5dd9ad92c52e08d121ec081862d73d6762068904 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 25 Sep 2014 11:36:48 +0800 Subject: [PATCH 0689/1564] Fixed #5949: Add type check in cc.loader --- CCBoot.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 1369842895..54665e56e9 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -789,7 +789,10 @@ cc.loader = /** @lends cc.loader# */{ var obj = self.cache[url]; if (obj) return cb(null, obj); - var loader = self._register[type.toLowerCase()]; + var loader = null; + if(type) { + self._register[type.toLowerCase()]; + } if (!loader) { cc.error("loader for [" + type + "] not exists!"); return cb(); From 9b0caede85b337450d419364a7bda5f79aca3438 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 25 Sep 2014 11:38:38 +0800 Subject: [PATCH 0690/1564] Fixed #5949: Add type check in cc.loader --- CCBoot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 54665e56e9..55203c2bfe 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -790,8 +790,8 @@ cc.loader = /** @lends cc.loader# */{ if (obj) return cb(null, obj); var loader = null; - if(type) { - self._register[type.toLowerCase()]; + if (type) { + loader = self._register[type.toLowerCase()]; } if (!loader) { cc.error("loader for [" + type + "] not exists!"); From c6613ae58c70fb12d3350d3c632a939665ad250d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 25 Sep 2014 15:12:35 +0800 Subject: [PATCH 0691/1564] Issue #5941: Let effects work. --- cocos2d/actions3d/CCActionGrid.js | 3 ++ cocos2d/core/base-nodes/BaseNodesWebGL.js | 9 ---- cocos2d/core/renderer/RendererWebGL.js | 8 ++-- cocos2d/node-grid/CCNodeGrid.js | 50 +++++++++++++++++++---- cocos2d/render-texture/CCRenderTexture.js | 4 +- 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index b6ad42bcf1..b29947eb42 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -67,6 +67,7 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ */ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); + cc.renderer.childrenOrderDirty = true; var newGrid = this.getGrid(); var t = this.target; var targetGrid = t.grid; @@ -286,6 +287,7 @@ cc.StopGrid = cc.ActionInstant.extend(/** @lends cc.StopGrid# */{ */ startWithTarget:function (target) { cc.ActionInstant.prototype.startWithTarget.call(this, target); + cc.renderer.childrenOrderDirty = true; var grid = this.target.grid; if (grid && grid.isActive()) grid.setActive(false); @@ -344,6 +346,7 @@ cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{ */ startWithTarget:function (target) { cc.ActionInstant.prototype.startWithTarget.call(this, target); + cc.renderer.childrenOrderDirty = true; if (this.target.grid && this.target.grid.isActive()) this.target.grid.setReuseGrid(this.target.grid.getReuseGrid() + this._times); } diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index 0b346cd51a..61903deea6 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -77,11 +77,6 @@ cc._tmp.WebGLCCNode = function () { cc.kmMat4Assign(_t._stackMatrix, currentStack.top); currentStack.top = _t._stackMatrix; - //TODO GridNode -/* var locGrid = _t.grid; - if (locGrid && locGrid._active) - locGrid.beforeDraw();*/ - //_t.toRenderer(); _t.transform(); @@ -111,10 +106,6 @@ cc._tmp.WebGLCCNode = function () { _t.arrivalOrder = 0; - //TODO GridNode -/* if (locGrid && locGrid._active) - locGrid.afterDraw(_t);*/ - //optimize performance for javascript currentStack.top = currentStack.stack.pop(); }; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 28f476360f..829583ae69 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -50,14 +50,14 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ * @param {CanvasRenderingContext2D} ctx */ _renderingToBuffer: function (ctx) { - var locCmds = this._cacheToCanvasCmds, i, len; + var locCmds = this._cacheToBufferCmds, i, len; ctx = ctx || cc._renderContext; for (i = 0, len = locCmds.length; i < len; i++) { - locCmds[i].rendering(ctx, 1, 1); + locCmds[i].rendering(ctx); } locCmds.length = 0; - this._isCacheToCanvasOn = false; + this._isCacheToBufferOn = false; }, //reset renderer's flag @@ -342,7 +342,7 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ if (node.autoDraw) { node.begin(); - var locClearFlags = this.clearFlags; + var locClearFlags = node.clearFlags; if (locClearFlags) { var oldClearColor = [0.0, 0.0, 0.0, 0.0]; var oldDepthClearValue = 0.0; diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index e74889e805..714ea7b1aa 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -35,6 +35,15 @@ cc.NodeGrid = cc.Node.extend({ grid: null, _target: null, + _gridBeginCommand:null, + _gridEndCommand:null, + + ctor: function(){ + cc.Node.prototype.ctor.call(this); + + this._gridBeginCommand = new cc.CustomRenderCmdWebGL(this, this.onGridBeginDraw); + this._gridEndCommand = new cc.CustomRenderCmdWebGL(this, this.onGridEndDraw); + }, /** * Gets the grid object. @@ -78,6 +87,18 @@ cc.NodeGrid = cc.Node.extend({ this._target = child; }, + onGridBeginDraw: function(){ + var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; + if (isWebGL && locGrid && locGrid._active) + locGrid.beforeDraw(); + }, + + onGridEndDraw: function(){ + var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; + if (isWebGL && locGrid && locGrid._active) + locGrid.afterDraw(this._target); + }, + /** * Recursive method that visit its children and draw them */ @@ -86,27 +107,40 @@ cc.NodeGrid = cc.Node.extend({ // quick return if not visible if (!self._visible) return; - - var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL; - var locGrid = self.grid; - if (isWebGL && locGrid && locGrid._active) - locGrid.beforeDraw(); + var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; self.transform(); + var beforeProjectionType = cc.director.PROJECTION_DEFAULT; + if (isWebGL && locGrid && locGrid._active){ + beforeProjectionType = cc.director.getProjection(); + locGrid.set2DProjection(); + } + cc.renderer.pushRenderCommand(this._gridBeginCommand); + + if(this._target) + this._target.visit(); + var locChildren = this._children; if (locChildren && locChildren.length > 0) { var childLen = locChildren.length; this.sortAllChildren(); // draw children - for (i = 0; i < childLen; i++) { + for (var i = 0; i < childLen; i++) { var child = locChildren[i]; child && child.visit(); } } - if (isWebGL && locGrid && locGrid._active) - locGrid.afterDraw(self._target); + if(isWebGL && locGrid && locGrid._active) + cc.director.setProjection(beforeProjectionType); + + cc.renderer.pushRenderCommand(this._gridEndCommand); + currentStack.top = currentStack.stack.pop(); }, _transformForWebGL: function () { diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 505eafc63b..9d13cdb68b 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -656,7 +656,9 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ //this.toRenderer(); this.sprite.visit(); - this.draw(ctx); + //this.draw(ctx); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); //TODO GridNode /* if (locGrid && locGrid.isActive()) From 0baea3fc9ab20302e258b27e507780bb3b6325ae Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 25 Sep 2014 16:31:13 +0800 Subject: [PATCH 0692/1564] add webglrender command for clipping node --- cocos2d/clipping-nodes/CCClippingNode.js | 106 +++++++++++++++-------- cocos2d/core/renderer/RendererWebGL.js | 5 +- 2 files changed, 74 insertions(+), 37 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index e77097f065..a1739092f3 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -78,6 +78,10 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ _rendererClipCmd: null, _rendererRestoreCmd: null, + _beforeVisitCmd: null, + _afterDrawStencilCmd: null, + _afterVisitCmd: null, + _stencil: null, _godhelpme: false, _clipElemType: null, @@ -91,15 +95,22 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ this._stencil = null; this.alphaThreshold = 0; this.inverted = false; - - this._rendererSaveCmd = new cc.ClippingNodeSaveRenderCmdCanvas(this); - this._rendererClipCmd = new cc.ClippingNodeClipRenderCmdCanvas(this); - this._rendererRestoreCmd = new cc.ClippingNodeRestoreRenderCmdCanvas(this); - stencil = stencil || null; cc.ClippingNode.prototype.init.call(this, stencil); }, + _initRendererCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + this._rendererSaveCmd = new cc.ClippingNodeSaveRenderCmdCanvas(this); + this._rendererClipCmd = new cc.ClippingNodeClipRenderCmdCanvas(this); + this._rendererRestoreCmd = new cc.ClippingNodeRestoreRenderCmdCanvas(this); + }else{ + this._beforeVisitCmd = new cc.CustomRenderCmdWebGL(this, this.onBeforeVisit); + this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this.onAfterDrawStencil); + this._afterVisitCmd = new cc.CustomRenderCmdWebGL(this, this.onAfterVisit); + } + }, + /** * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. * @function @@ -227,7 +238,27 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ cc.Node.prototype.visit.call(this, ctx); return; } + cc.renderer.pushRenderCommand(this._beforeVisitCmd); + + // draw the stencil node as if it was one of our child + // (according to the stencil test func/op and alpha (or alpha shader) test) + cc.kmGLPushMatrix(); + this.transform(); + this._stencil._stackMatrix = this._stackMatrix; + this._stencil.visit(); + cc.kmGLPopMatrix(); + + cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); + + // draw (according to the stencil test func) this node and its childs + cc.Node.prototype.visit.call(this, ctx); + cc.renderer.pushRenderCommand(this._afterVisitCmd); + + }, + + onBeforeVisit: function(ctx){ + var gl = gl || ctx; /////////////////////////////////// // INIT @@ -239,17 +270,17 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // mask of all layers less than the current (ie: for layer 3: 00000011) var mask_layer_l = mask_layer - 1; // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) - var mask_layer_le = mask_layer | mask_layer_l; - + //var mask_layer_le = mask_layer | mask_layer_l; + this._mask_layer_le = mask_layer | mask_layer_l; // manually save the stencil state - var currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); - var currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); - var currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); - var currentStencilRef = gl.getParameter(gl.STENCIL_REF); - var currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); - var currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); - var currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); - var currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); + this._currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); + this._currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); + this._currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); + this._currentStencilRef = gl.getParameter(gl.STENCIL_REF); + this._currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); + this._currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); + this._currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); + this._currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); // enable stencil use gl.enable(gl.STENCIL_TEST); @@ -263,8 +294,8 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // manually save the depth test state //GLboolean currentDepthTestEnabled = GL_TRUE; //currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); - var currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); - + //var currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); + this._currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); // disable depth test while drawing the stencil //glDisable(GL_DEPTH_TEST); // disable update to the depth buffer while drawing the stencil, @@ -321,21 +352,26 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // XXX: we should have a way to apply shader to all nodes without having to do this cc.setProgram(this._stencil, program); } - - // draw the stencil node as if it was one of our child - // (according to the stencil test func/op and alpha (or alpha shader) test) - cc.kmGLPushMatrix(); - this.transform(); - this._stencil.visit(); - cc.kmGLPopMatrix(); - + }, + _currentStencilFunc: null, + _currentStencilRef: null, + _currentStencilValueMask: null, + _currentStencilFail: null, + _currentStencilPassDepthFail: null, + _currentStencilPassDepthPass:null, + _currentStencilWriteMask:null, + _currentStencilEnabled:null, + _currentDepthWriteMask: null, + _mask_layer_le: null, + onAfterDrawStencil: function(ctx){ + var gl = gl || ctx; // restore alpha test state //if (this.alphaThreshold < 1) { // XXX: we need to find a way to restore the shaders of the stencil node and its childs //} // restore the depth test state - gl.depthMask(currentDepthWriteMask); + gl.depthMask(this._currentDepthWriteMask); /////////////////////////////////// // DRAW CONTENT @@ -346,20 +382,20 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // draw the pixel and keep the current layer in the stencil buffer // else // do not draw the pixel but keep the current layer in the stencil buffer - gl.stencilFunc(gl.EQUAL, mask_layer_le, mask_layer_le); + gl.stencilFunc(gl.EQUAL, this._mask_layer_le, this._mask_layer_le); gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + }, - // draw (according to the stencil test func) this node and its childs - cc.Node.prototype.visit.call(this, ctx); - + onAfterVisit: function(ctx){ + var gl = gl || ctx; /////////////////////////////////// // CLEANUP // manually restore the stencil state - gl.stencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); - gl.stencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); - gl.stencilMask(currentStencilWriteMask); - if (!currentStencilEnabled) + gl.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask); + gl.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass); + gl.stencilMask(this._currentStencilWriteMask); + if (!this._currentStencilEnabled) gl.disable(gl.STENCIL_TEST); // we are done using this layer, decrement @@ -572,7 +608,7 @@ cc.ClippingNode._getSharedCache = function () { /** * Creates and initializes a clipping node with an other node as its stencil.
    * The stencil node will be retained. - * @deprecated since v3.0, please use getNodeToParentTransform instead + * @deprecated since v3.0, please use "new cc.ClippingNode(stencil)" instead * @param {cc.Node} [stencil=null] * @return {cc.ClippingNode} * @example diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index c020b446a9..a474b49c18 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -183,7 +183,7 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ var _t = this._node; cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); _t._shaderProgram.use(); - _t._shaderProgram.setUniformsForBuiltins(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); _t._render(); }; @@ -198,7 +198,8 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ if(_t.texture && _t.texture.isLoaded()){ ctx = ctx || cc._renderContext; - cc.nodeDrawSetup(_t); + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); From c5717a14c55bd386a3b40a28643b3205e03108f4 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 25 Sep 2014 17:26:42 +0800 Subject: [PATCH 0693/1564] add Parallax.prototype._transformForRenderer for webgl --- cocos2d/parallax/CCParallaxNode.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index 6608be0dec..48fbb51616 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -233,11 +233,9 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ ret = cc.pAdd(ret, cn.getPosition()); } return ret; - } -}); + }, -if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - cc.ParallaxNode.prototype._transformForRenderer = function(){ + _transformForRenderer:function () { var pos = this._absolutePosition(); if (!cc.pointEqualToPoint(pos, this._lastPosition)) { var locParallaxArray = this.parallaxArray; @@ -245,13 +243,13 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS){ var point = locParallaxArray[i]; var child = point.getChild(); child.setPosition(-pos.x + pos.x * point.getRatio().x + point.getOffset().x, - -pos.y + pos.y * point.getRatio().y + point.getOffset().y); + -pos.y + pos.y * point.getRatio().y + point.getOffset().y); } this._lastPosition = pos; } cc.Node.prototype._transformForRenderer.call(this); - }; -} + } +}); /** * Create new parallax node. From 97eff1cef5f37087c60be4b4621f789a05514447 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 26 Sep 2014 14:20:34 +0800 Subject: [PATCH 0694/1564] Issue #5941: refactor UILayout for new renderer --- cocos2d/transitions/CCTransition.js | 25 ++- .../ccui/base-classes/UIScale9Sprite.js | 2 + extensions/ccui/layouts/UILayout.js | 189 ++++++++++-------- 3 files changed, 125 insertions(+), 91 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 0524379ab8..258f40dfb3 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -1690,6 +1690,11 @@ cc.TransitionTurnOffTiles.create = function (t, scene) { * var trans = new cc.TransitionSplitCols(time,scene); */ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplitCols# */{ + _gridProxy: null, + + _switchTargetToInscene: function(){ + this._gridProxy.setTarget(this._inScene); + }, /** * Constructor of TransitionSplitCols @@ -1698,6 +1703,7 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit */ ctor:function (t, scene) { cc.TransitionScene.prototype.ctor.call(this); + this._gridProxy = new cc.NodeGrid(); scene && this.initWithDuration(t, scene); }, /** @@ -1705,17 +1711,30 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit */ onEnter:function () { cc.TransitionScene.prototype.onEnter.call(this); - this._inScene.visible = false; + //this._inScene.visible = false; + this._gridProxy.setTarget(this._outScene); + this._gridProxy.onEnter(); var split = this.action(); var seq = cc.sequence( - split, cc.callFunc(this.hideOutShowIn, this), split.reverse()); + split, cc.callFunc(this._switchTargetToInscene, this), split.reverse()); - this.runAction( + this._gridProxy.runAction( cc.sequence(this.easeActionWithAction(seq), cc.callFunc(this.finish, this), cc.stopGrid()) ); }, + onExit: function(){ + this._gridProxy.setTarget(null); + this._gridProxy.onExit(); + cc.TransitionScene.prototype.onExit.call(this); + }, + + visit: function(){ + cc.TransitionScene.prototype.visit.call(this); + this._gridProxy.visit(); + }, + /** * @param {cc.ActionInterval} action * @return {cc.EaseInOut} diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 04a4ea9fe8..22b711e93c 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -518,6 +518,8 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ cc.Node.prototype.visit.call(this, ctx); cc.renderer.pushRenderCommand(this._rendererEndCanvasCmd); + }else{ + cc.Node.prototype.visit.call(this, ctx); } }, diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index e2ea13a63a..5605c39601 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -87,6 +87,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ __passFocusToChild: false, //on default, it will pass the focus to the next nearest widget _isFocusPassing:false, //when finding the next focused widget, use this variable to pass focus between layout & widget + //add renderer for webgl + _beforeVisitCmdStencil: null, + _afterDrawStencilCmd: null, + _afterVisitCmdStencil: null, + _beforeVisitCmdScissor: null, + _afterVisitCmdScissor: null, + /** * Allocates and initializes an UILayout. * Constructor of ccui.Layout @@ -112,6 +119,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingRect = cc.rect(0, 0, 0, 0); this._backGroundImageColor = cc.color(255, 255, 255, 255); + + this._beforeVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitStencil); + this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDrawStencil); + this._afterVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitStencil); + this._beforeVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitScissor); + this._afterVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitScissor); }, /** @@ -388,56 +401,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return; } - ccui.Layout._layer++; - - var mask_layer = 0x1 << ccui.Layout._layer; - var mask_layer_l = mask_layer - 1; - var mask_layer_le = mask_layer | mask_layer_l; - - // manually save the stencil state - var currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); - var currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); - var currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); - var currentStencilRef = gl.getParameter(gl.STENCIL_REF); - var currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); - var currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); - var currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); - var currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); - - gl.enable(gl.STENCIL_TEST); - - gl.stencilMask(mask_layer); - - var currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); - - gl.depthMask(false); - - gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(gl.ZERO, gl.KEEP, gl.KEEP); - - // draw a fullscreen solid rectangle to clear the stencil buffer - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc._drawingUtil.drawSolidRect(cc.p(-1,-1), cc.p(1,1), cc.color(255, 255, 255, 255)); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix(); + cc.renderer.pushRenderCommand(this._beforeVisitCmdStencil); - gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP); + //optimize performance for javascript + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; - cc.kmGLPushMatrix(); this.transform(); this._clippingStencil.visit(); - gl.depthMask(currentDepthWriteMask); - gl.stencilFunc(gl.EQUAL, mask_layer_le, mask_layer_le); - gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); // draw (according to the stencil test func) this node and its childs var i = 0; // used by _children @@ -461,21 +436,18 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ else break; } - this.draw(); + //this.draw(); //draw self + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); for (; i < iLen; i++) locChildren[i].visit(); for (; j < jLen; j++) locProtectChildren[j].visit(); - // manually restore the stencil state - gl.stencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); - gl.stencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); - gl.stencilMask(currentStencilWriteMask); - if (!currentStencilEnabled) - gl.disable(gl.STENCIL_TEST); - ccui.Layout._layer--; + cc.renderer.pushRenderCommand(this._afterVisitCmdStencil); - cc.kmGLPopMatrix(); + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); }, _stencilClippingVisitForCanvas: function (ctx) { @@ -556,16 +528,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _scissorClippingVisit: null, _scissorClippingVisitForWebGL: function (ctx) { - var clippingRect = this._getClippingRect(); - var gl = ctx || cc._renderContext; - if (this._handleScissor) { - gl.enable(gl.SCISSOR_TEST); - } - cc.view.setScissorInPoints(clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height); - cc.Node.prototype.visit.call(this); - if (this._handleScissor) { - gl.disable(gl.SCISSOR_TEST); - } + cc.renderer.pushRenderCommand(this._beforeVisitCmdScissor); + cc.ProtectedNode.prototype.visit.call(this); + cc.renderer.pushRenderCommand(this._afterVisitCmdScissor); }, /** @@ -775,19 +740,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._backGroundImageTextureSize = locBackgroundImage.getContentSize(); locBackgroundImage.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); this._updateBackGroundImageColor(); - - /*//async load callback - var self = this; - if(!locBackgroundImage.texture || !locBackgroundImage.texture.isLoaded()){ - locBackgroundImage.addLoadedEventListener(function(){ - self._backGroundImageTextureSize = locBackgroundImage.getContentSize(); - locBackgroundImage.setPosition(self._contentSize.width * 0.5, self._contentSize.height * 0.5); - self._updateBackGroundImageColor(); - - self._imageRendererAdaptDirty = true; - self._findLayout(); - }); - }*/ }, /** @@ -1131,28 +1083,89 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, //clipping - _onBeforeVisitStencil: function(){ - //TODO NEW RENDERER + _onBeforeVisitStencil: function(ctx){ + var gl = ctx || cc._renderContext; + + ccui.Layout._layer++; + + var mask_layer = 0x1 << ccui.Layout._layer; + var mask_layer_l = mask_layer - 1; + this._mask_layer_le = mask_layer | mask_layer_l; + + // manually save the stencil state + this._currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); + this._currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); + this._currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); + this._currentStencilRef = gl.getParameter(gl.STENCIL_REF); + this._currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); + this._currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); + this._currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); + this._currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); + + gl.enable(gl.STENCIL_TEST); + + gl.stencilMask(mask_layer); + + this._currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); + + gl.depthMask(false); + + gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); + gl.stencilOp(gl.ZERO, gl.KEEP, gl.KEEP); + + // draw a fullscreen solid rectangle to clear the stencil buffer + this._drawFullScreenQuadClearStencil(); + + gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); + gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP); }, _drawFullScreenQuadClearStencil:function(){ - //TODO NEW RENDERER + // draw a fullscreen solid rectangle to clear the stencil buffer + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc._drawingUtil.drawSolidRect(cc.p(-1,-1), cc.p(1,1), cc.color(255, 255, 255, 255)); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix(); }, - _onAfterDrawStencil: function(){ - //TODO NEW RENDERER + _onAfterDrawStencil: function(ctx){ + var gl = ctx || cc._renderContext; + gl.depthMask(this._currentDepthWriteMask); + gl.stencilFunc(gl.EQUAL, this._mask_layer_le, this._mask_layer_le); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); }, - _onAfterVisitStencil: function(){ - //TODO NEW RENDERER + _onAfterVisitStencil: function(ctx){ + var gl = ctx || cc._renderContext; + // manually restore the stencil state + gl.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask); + gl.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass); + gl.stencilMask(this._currentStencilWriteMask); + if (!this._currentStencilEnabled) + gl.disable(gl.STENCIL_TEST); + ccui.Layout._layer--; }, - _onAfterVisitScissor: function(){ - //TODO NEW RENDERER + _onBeforeVisitScissor: function(ctx){ + var clippingRect = this._getClippingRect(); + var gl = ctx || cc._renderContext; + if (this._handleScissor) { + gl.enable(gl.SCISSOR_TEST); + } + cc.view.setScissorInPoints(clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height); }, - _onAfterVisitScissor: function(){ - //TODO NEW RENDERER + _onAfterVisitScissor: function(ctx){ + if (this._handleScissor) { + gl.disable(gl.SCISSOR_TEST); + } }, _updateBackGroundImageOpacity: function(){ From 3d1427d871341630fcf9ce0b00e03e5e991811ac Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 26 Sep 2014 14:21:54 +0800 Subject: [PATCH 0695/1564] Issue #5933: UIText UITextField Atlas --- cocos2d/core/base-nodes/CCAtlasNode.js | 3 ++- extensions/ccui/base-classes/CCProtectedNode.js | 4 ++-- extensions/ccui/uiwidgets/UIText.js | 5 +++++ extensions/ccui/uiwidgets/UITextField.js | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 448941d9b4..f7bad055ea 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -87,7 +87,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ }, _initRendererCmd: function () { - this._rendererCmd = new cc.AtlasNodeRenderCmdWebGL(this); + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this._rendererCmd = new cc.AtlasNodeRenderCmdWebGL(this); }, /** diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index be98a4dace..efcfed8521 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -246,7 +246,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ var children = _t._children, child; var locChildren = _t._children, locProtectedChildren = this._protectedChildren; var childLen = locChildren.length, pLen = locProtectedChildren.length; - context.save(); +// context.save(); _t.transform(context); _t.sortAllChildren(); @@ -279,7 +279,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ this._cacheDirty = false; _t.arrivalOrder = 0; - context.restore(); +// context.restore(); }, _visitForWebGL: function(){ diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index a56fe8210f..61b162d32e 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -431,6 +431,11 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _getBoundingHeight: function () { return this._textAreaSize.height; + }, + + _transformForRenderer: function(){ + cc.Node.prototype.transform.call(this); + this._labelRenderer._transformForRenderer(); } }); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 463f526841..856a25e8bf 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -801,6 +801,11 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _getFont: function () { return this._textFieldRenderer._getFont(); + }, + + _transformForRenderer: function(){ + cc.Node.prototype.transform.call(this); + this._textFieldRenderer._transformForRenderer(); } }); From 1d48493c73773bacb95892f6c4b6e5ef0fbaeb36 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Fri, 26 Sep 2014 14:44:02 +0800 Subject: [PATCH 0696/1564] add webgl renderer command for spine --- cocos2d/core/renderer/RendererWebGL.js | 123 +++++++++++++++++++++++++ extensions/spine/CCSkeleton.js | 5 + 2 files changed, 128 insertions(+) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index a474b49c18..225b3c6b76 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -452,4 +452,127 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ this._node._transformForRenderer(); } }; + + cc.SkeletonRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.SkeletonRenderCmdWebGL.prototype.rendering = function(ctx){ + var node = this._node; + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); +// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); + var color = node.getColor(), locSkeleton = node._skeleton; + locSkeleton.r = color.r / 255; + locSkeleton.g = color.g / 255; + locSkeleton.b = color.b / 255; + locSkeleton.a = node.getOpacity() / 255; + if (node._premultipliedAlpha) { + locSkeleton.r *= locSkeleton.a; + locSkeleton.g *= locSkeleton.a; + locSkeleton.b *= locSkeleton.a; + } + + var additive,textureAtlas,attachment,slot, i, n, + quad = new cc.V3F_C4B_T2F_Quad(); + var locBlendFunc = node._blendFunc; + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + var regionTextureAtlas = node.getTextureAtlas(attachment); + + if (slot.data.additiveBlending != additive) { + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + additive = !additive; + cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); + } else if (regionTextureAtlas != textureAtlas && textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + textureAtlas = regionTextureAtlas; + + var quadCount = textureAtlas.getTotalQuads(); + if (textureAtlas.getCapacity() == quadCount) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) + return; + } + + sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + textureAtlas.updateQuad(quad, quadCount); + } + + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + + if(node._debugBones || node._debugSlots){ + + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + //cc.kmGLPushMatrixWitMat4(node._stackMatrix); + cc.current_stack.stack.push(cc.current_stack.top); + cc.current_stack.top = node._stackMatrix; + + var drawingUtil = cc._drawingUtil; + + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + quad = new cc.V3F_C4B_T2F_Quad(); + sp._regionAttachment_updateQuad(attachment, slot, quad); + + var points = []; + points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); + points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); + points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); + points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); + + drawingUtil.drawPoly(points, 4, true); + } + } + + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + if (i == 0) { + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + } + + cc.kmGLPopMatrix(); + } + }; } diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 97a76a2150..585d964fa6 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -92,6 +92,11 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ this.initWithArgs(skeletonDataFile, atlasFile, scale); }, + _initRendererCmd:function () { + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this._rendererCmd = new cc.SkeletonRenderCmdWebGL(this); + }, + /** * Initializes a sp.Skeleton. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. */ From 1dd854245bd010f500eecd4055628f2c58e49681 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 26 Sep 2014 16:27:54 +0800 Subject: [PATCH 0697/1564] Issue #5933: UIText UITextField UILayout(clipping) --- extensions/ccui/layouts/UILayout.js | 135 +++++++++++++++++------ extensions/ccui/uiwidgets/UIText.js | 1 + extensions/ccui/uiwidgets/UITextField.js | 2 + 3 files changed, 102 insertions(+), 36 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 5605c39601..9329d34582 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -94,6 +94,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _beforeVisitCmdScissor: null, _afterVisitCmdScissor: null, + _clipElemType: false, + /** * Allocates and initializes an UILayout. * Constructor of ccui.Layout @@ -120,11 +122,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingRect = cc.rect(0, 0, 0, 0); this._backGroundImageColor = cc.color(255, 255, 255, 255); - this._beforeVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitStencil); - this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDrawStencil); - this._afterVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitStencil); - this._beforeVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitScissor); - this._afterVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitScissor); + if(cc._renderType == cc._RENDER_TYPE_CANVAS){ + this._rendererSaveCmd = new cc.CustomRenderCmdCanvas(this, this._onRenderSaveCmd); + this._rendererSaveCmdSprite = new cc.CustomRenderCmdCanvas(this, this._onRenderSaveSpriteCmd); + this._rendererClipCmd = new cc.CustomRenderCmdCanvas(this, this._onRenderClipCmd); + this._rendererRestoreCmd = new cc.CustomRenderCmdCanvas(this, this._onRenderRestoreCmd); + + }else{ + this._beforeVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitStencil); + this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDrawStencil); + this._afterVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitStencil); + this._beforeVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitScissor); + this._afterVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitScissor); + } }, /** @@ -451,53 +461,46 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _stencilClippingVisitForCanvas: function (ctx) { - // return fast (draw nothing, or draw everything if in inverted mode) if: - // - nil stencil node - // - or stencil node invisible: if (!this._clippingStencil || !this._clippingStencil.isVisible()) { return; } + + var i, locChild; + if (this._stencil instanceof cc.Sprite) { + this._clipElemType = true; + }else{ + this._clipElemType = false; + } + var context = ctx || cc._renderContext; - // Composition mode, costy but support texture stencil - if (this._clippingStencil instanceof cc.Sprite) { - // Cache the current canvas, for later use (This is a little bit heavy, replace this solution with other walkthrough) - var canvas = context.canvas; - var locCache = ccui.Layout._getSharedCache(); - locCache.width = canvas.width; - locCache.height = canvas.height; - var locCacheCtx = locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - context.save(); - // Draw everything first using node visit function + this.transform(); + + if(this._rendererSaveCmd) + cc.renderer.pushRenderCommand(this._rendererSaveCmd); + + if (this._clipElemType) { cc.ProtectedNode.prototype.visit.call(this, context); - context.globalCompositeOperation = "destination-in"; + if(this._rendererSaveCmdSprite) + cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite); - this.transform(context); this._clippingStencil.visit(); - context.restore(); + }else{ + this._clippingStencil.visit(context); + } - // Redraw the cached canvas, so that the cliped area shows the background etc. - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalCompositeOperation = "destination-over"; - context.drawImage(locCache, 0, 0); - context.restore(); - } else { // Clip mode, fast, but only support cc.DrawNode - var i, children = this._children, locChild; + if(this._rendererClipCmd) + cc.renderer.pushRenderCommand(this._rendererClipCmd); - context.save(); - this.transform(context); - this._clippingStencil.visit(context); - context.clip(); + if (this._clipElemType) { - // Clip mode doesn't support recusive stencil, so once we used a clip stencil, - // so if it has ClippingNode as a child, the child must uses composition stencil. + }else{ this.sortAllChildren(); this.sortAllProtectedChildren(); + var children = this._children; var j, locProtectChildren = this._protectedChildren; var iLen = children.length, jLen = locProtectChildren.length; @@ -522,6 +525,66 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ for (; j < jLen; j++) locProtectChildren[j].visit(context); + if(this._rendererRestoreCmd) + cc.renderer.pushRenderCommand(this._rendererRestoreCmd); + } + }, + + _onRenderSaveCmd: function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + + if (this._clipElemType) { + var canvas = context.canvas; + this._locCache = ccui.Layout._getSharedCache(); + this._locCache.width = canvas.width; + this._locCache.height = canvas.height; + var locCacheCtx = this._locCache.getContext("2d"); + locCacheCtx.drawImage(canvas, 0, 0); + + context.save(); + }else{ + this.transform(); + var t = this._transformWorld; + context.save(); + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } + + }, + _onRenderSaveSpriteCmd: function(ctx){ + var context = ctx || cc._renderContext; + + if (this._clipElemType) { + context.globalCompositeOperation = "destination-in"; + + this.transform(context); + }else{} + }, + _onRenderClipCmd: function(ctx){ + + var context = ctx || cc._renderContext; + + if (this._clipElemType) { + + }else{ + context.restore(); + context.clip(); + } + }, + _onRenderRestoreCmd: function(ctx){ + + var context = ctx || cc._renderContext; + + if (this._clipElemType) { + context.restore(); + + // Redraw the cached canvas, so that the cliped area shows the background etc. + context.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.globalCompositeOperation = "destination-over"; + context.drawImage(this._node._locCache, 0, 0); + context.restore(); + }else{ context.restore(); } }, diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 61b162d32e..136396cafc 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -434,6 +434,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _transformForRenderer: function(){ + this._adaptRenderers(); cc.Node.prototype.transform.call(this); this._labelRenderer._transformForRenderer(); } diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 856a25e8bf..386ca68ce4 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -804,6 +804,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, _transformForRenderer: function(){ + + this._adaptRenderers(); cc.Node.prototype.transform.call(this); this._textFieldRenderer._transformForRenderer(); } From 976ced8bf7c13f686f94f616b3e8698c0ed118bd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 26 Sep 2014 16:53:56 +0800 Subject: [PATCH 0698/1564] Issue #5933: NodeGrid --- cocos2d/node-grid/CCNodeGrid.js | 44 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index 714ea7b1aa..58d33c2408 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -41,8 +41,10 @@ cc.NodeGrid = cc.Node.extend({ ctor: function(){ cc.Node.prototype.ctor.call(this); - this._gridBeginCommand = new cc.CustomRenderCmdWebGL(this, this.onGridBeginDraw); - this._gridEndCommand = new cc.CustomRenderCmdWebGL(this, this.onGridEndDraw); + if(cc._renderType === cc._RENDER_TYPE_WEBGL){ + this._gridBeginCommand = new cc.CustomRenderCmdWebGL(this, this.onGridBeginDraw); + this._gridEndCommand = new cc.CustomRenderCmdWebGL(this, this.onGridEndDraw); + } }, /** @@ -108,22 +110,27 @@ cc.NodeGrid = cc.Node.extend({ if (!self._visible) return; var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; - var currentStack = cc.current_stack; - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); - currentStack.top = this._stackMatrix; + if(isWebGL){ + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; + } self.transform(); - var beforeProjectionType = cc.director.PROJECTION_DEFAULT; - if (isWebGL && locGrid && locGrid._active){ - beforeProjectionType = cc.director.getProjection(); - locGrid.set2DProjection(); - } - cc.renderer.pushRenderCommand(this._gridBeginCommand); + if(isWebGL){ + var beforeProjectionType = cc.director.PROJECTION_DEFAULT; + if (isWebGL && locGrid && locGrid._active){ + beforeProjectionType = cc.director.getProjection(); + locGrid.set2DProjection(); + } + if(this._gridBeginCommand) + cc.renderer.pushRenderCommand(this._gridBeginCommand); - if(this._target) - this._target.visit(); + if(this._target) + this._target.visit(); + } var locChildren = this._children; if (locChildren && locChildren.length > 0) { @@ -136,11 +143,12 @@ cc.NodeGrid = cc.Node.extend({ } } - if(isWebGL && locGrid && locGrid._active) + if(isWebGL && locGrid && locGrid._active){ cc.director.setProjection(beforeProjectionType); - - cc.renderer.pushRenderCommand(this._gridEndCommand); - currentStack.top = currentStack.stack.pop(); + if(this._gridEndCommand) + cc.renderer.pushRenderCommand(this._gridEndCommand); + currentStack.top = currentStack.stack.pop(); + } }, _transformForWebGL: function () { From 13a43d198fe5753ff98d2356b5d0f0bc9c2f45ca Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 26 Sep 2014 18:51:06 +0800 Subject: [PATCH 0699/1564] Issue #5941: refactor ClippingNode for new renderer webgl --- cocos2d/clipping-nodes/CCClippingNode.js | 167 +++++++++--------- cocos2d/core/base-nodes/BaseNodesWebGL.js | 4 +- cocos2d/shaders/CCGLProgram.js | 24 +++ .../ccui/base-classes/CCProtectedNode.js | 31 ++++ 4 files changed, 144 insertions(+), 82 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index a1739092f3..684b24394a 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -31,30 +31,6 @@ */ cc.stencilBits = -1; -/** - *

    - * Sets the shader program for this node - * - * Since v2.0, each rendering node must set its shader program. - * It should be set in initialize phase. - *

    - * @function - * @param {cc.Node} node - * @param {cc.GLProgram} program The shader program which fetchs from CCShaderCache. - * @example - * cc.setGLProgram(node, cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); - */ -cc.setProgram = function (node, program) { - node.shaderProgram = program; - - var children = node.children; - if (!children) - return; - - for (var i = 0; i < children.length; i++) - cc.setProgram(children[i], program); -}; - /** *

    * cc.ClippingNode is a subclass of cc.Node.
    @@ -86,6 +62,18 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ _godhelpme: false, _clipElemType: null, + _currentStencilFunc: null, + _currentStencilRef: null, + _currentStencilValueMask: null, + _currentStencilFail: null, + _currentStencilPassDepthFail: null, + _currentStencilPassDepthPass:null, + _currentStencilWriteMask:null, + _currentStencilEnabled:null, + _currentDepthWriteMask: null, + _mask_layer_le: null, + + /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {cc.Node} [stencil=null] @@ -105,9 +93,9 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ this._rendererClipCmd = new cc.ClippingNodeClipRenderCmdCanvas(this); this._rendererRestoreCmd = new cc.ClippingNodeRestoreRenderCmdCanvas(this); }else{ - this._beforeVisitCmd = new cc.CustomRenderCmdWebGL(this, this.onBeforeVisit); - this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this.onAfterDrawStencil); - this._afterVisitCmd = new cc.CustomRenderCmdWebGL(this, this.onAfterVisit); + this._beforeVisitCmd = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisit); + this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDrawStencil); + this._afterVisitCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterVisit); } }, @@ -213,22 +201,13 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ return; } - // return fast (draw nothing, or draw everything if in inverted mode) if: - // - nil stencil node - // - or stencil node invisible: if (!this._stencil || !this._stencil.visible) { if (this.inverted) cc.Node.prototype.visit.call(this, ctx); // draw everything return; } - // store the current stencil layer (position in the stencil buffer), - // this will allow nesting up to n CCClippingNode, - // where n is the number of bits of the stencil buffer. - - // all the _stencilBits are in use? if (cc.ClippingNode._layer + 1 == cc.stencilBits) { - // warn once cc.ClippingNode._visit_once = true; if (cc.ClippingNode._visit_once) { cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its childs."); @@ -238,27 +217,54 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ cc.Node.prototype.visit.call(this, ctx); return; } + cc.renderer.pushRenderCommand(this._beforeVisitCmd); - // draw the stencil node as if it was one of our child - // (according to the stencil test func/op and alpha (or alpha shader) test) - cc.kmGLPushMatrix(); + //optimize performance for javascript + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; + this.transform(); - this._stencil._stackMatrix = this._stackMatrix; + //this._stencil._stackMatrix = this._stackMatrix; this._stencil.visit(); - cc.kmGLPopMatrix(); cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); // draw (according to the stencil test func) this node and its childs - cc.Node.prototype.visit.call(this, ctx); + var locChildren = this._children; + if (locChildren && locChildren.length > 0) { + var childLen = locChildren.length; + this.sortAllChildren(); + // draw children zOrder < 0 + for (var i = 0; i < childLen; i++) { + if (locChildren[i] && locChildren[i]._localZOrder < 0) + locChildren[i].visit(); + else + break; + } + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); + // draw children zOrder >= 0 + for (; i < childLen; i++) { + if (locChildren[i]) { + locChildren[i].visit(); + } + } + } else{ + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); + } cc.renderer.pushRenderCommand(this._afterVisitCmd); + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); }, - onBeforeVisit: function(ctx){ - var gl = gl || ctx; + _onBeforeVisit: function(ctx){ + var gl = ctx || cc._renderContext; /////////////////////////////////// // INIT @@ -316,22 +322,9 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); gl.stencilOp(!this.inverted ? gl.ZERO : gl.REPLACE, gl.KEEP, gl.KEEP); - // draw a fullscreen solid rectangle to clear the stencil buffer - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc._drawingUtil.drawSolidRect(cc.p(-1,-1), cc.p(1,1), cc.color(255, 255, 255, 255)); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix(); + this._drawFullScreenQuadClearStencil(); - /////////////////////////////////// // DRAW CLIPPING STENCIL - // setup the stencil test func like this: // for each pixel in the stencil node // never draw it into the frame buffer @@ -340,7 +333,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); gl.stencilOp(!this.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP); - if (this.alphaThreshold < 1) { + /*if (this.alphaThreshold < 1) { //TODO desktop // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST); @@ -351,20 +344,26 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // we need to recursively apply this shader to all the nodes in the stencil node // XXX: we should have a way to apply shader to all nodes without having to do this cc.setProgram(this._stencil, program); - } + }*/ }, - _currentStencilFunc: null, - _currentStencilRef: null, - _currentStencilValueMask: null, - _currentStencilFail: null, - _currentStencilPassDepthFail: null, - _currentStencilPassDepthPass:null, - _currentStencilWriteMask:null, - _currentStencilEnabled:null, - _currentDepthWriteMask: null, - _mask_layer_le: null, - onAfterDrawStencil: function(ctx){ - var gl = gl || ctx; + + _drawFullScreenQuadClearStencil: function () { + // draw a fullscreen solid rectangle to clear the stencil buffer + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255)); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix(); + }, + + _onAfterDrawStencil: function(ctx){ + var gl = ctx || cc._renderContext; // restore alpha test state //if (this.alphaThreshold < 1) { // XXX: we need to find a way to restore the shaders of the stencil node and its childs @@ -386,8 +385,8 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); }, - onAfterVisit: function(ctx){ - var gl = gl || ctx; + _onAfterVisit: function(ctx){ + var gl = ctx || cc._renderContext; /////////////////////////////////// // CLEANUP @@ -403,13 +402,9 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ }, _visitForCanvas: function (ctx) { - // Composition mode, costy but support texture stencil - if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) { - this._clipElemType = true; - }else{ - this._clipElemType = false; - } + this._clipElemType = (this._cangodhelpme() || this._stencil instanceof cc.Sprite); + var context = ctx || cc._renderContext; var i, children = this._children, locChild; @@ -485,7 +480,13 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ setStencil: null, _setStencilForWebGL: function (stencil) { + if(this._stencil == stencil) + return; + if(this._stencil) + this._stencil._parent = null; this._stencil = stencil; + if(this._stencil) + this._stencil._parent = this; }, _setStencilForCanvas: function (stencil) { @@ -574,6 +575,12 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ if (godhelpme === true || godhelpme === false) cc.ClippingNode.prototype._godhelpme = godhelpme; return cc.ClippingNode.prototype._godhelpme; + }, + + _transformForRenderer: function(parentMatrix){ + cc.Node.prototype._transformForRenderer.call(this, parentMatrix); + if(this._stencil) + this._stencil._transformForRenderer(this._stackMatrix); } }); diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index 61903deea6..ff723ece29 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -110,9 +110,9 @@ cc._tmp.WebGLCCNode = function () { currentStack.top = currentStack.stack.pop(); }; - _p._transformForRenderer = function () { //TODO parentMatrix + _p._transformForRenderer = function (pMatrix) { var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, - parentMatrix = this._parent ? this._parent._stackMatrix : cc.current_stack.top; + parentMatrix = pMatrix || (this._parent ? this._parent._stackMatrix : cc.current_stack.top); // Convert 3x3 into 4x4 matrix var trans = this.nodeToParentTransform(); diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 3a1fc7faed..cce2a218bd 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -726,3 +726,27 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ cc.GLProgram.create = function (vShaderFileName, fShaderFileName) { return new cc.GLProgram(vShaderFileName, fShaderFileName); }; + +/** + *

    + * Sets the shader program for this node + * + * Since v2.0, each rendering node must set its shader program. + * It should be set in initialize phase. + *

    + * @function + * @param {cc.Node} node + * @param {cc.GLProgram} program The shader program which fetches from CCShaderCache. + * @example + * cc.setGLProgram(node, cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + */ +cc.setProgram = function (node, program) { + node.shaderProgram = program; + + var children = node.children; + if (!children) + return; + + for (var i = 0; i < children.length; i++) + cc.setProgram(children[i], program); +}; diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index efcfed8521..44005b7844 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -485,6 +485,37 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForCanvas; }else{ cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForWebGL; + cc.ProtectedNode.prototype._transformForRenderer = function () { + var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, + parentMatrix = this._parent ? this._parent._stackMatrix : cc.current_stack.top; + + // Convert 3x3 into 4x4 matrix + var trans = this.nodeToParentTransform(); + var t4x4Mat = t4x4.mat; + t4x4Mat[0] = trans.a; + t4x4Mat[4] = trans.c; + t4x4Mat[12] = trans.tx; + t4x4Mat[1] = trans.b; + t4x4Mat[5] = trans.d; + t4x4Mat[13] = trans.ty; + + // Update Z vertex manually + t4x4Mat[14] = this._vertexZ; + + //optimize performance for Javascript + cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); + + this._renderCmdDiry = false; + if(!this._children || this._children.length === 0) + return; + var i, len, locChildren = this._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._transformForRenderer(); + } + locChildren = this._protectedChildren; + for( i = 0, len = locChildren.length; i< len; i++) + locChildren[i]._transformForRenderer(); + }; } /** From faeaccb516d89a4c46bc982dd7907188c9f9fb54 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 27 Sep 2014 17:44:26 +0800 Subject: [PATCH 0700/1564] Issue #5956: Add release for getFromPool --- extensions/ccpool/CCPool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index d738a8f590..5dafdf2a8a 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -63,7 +63,7 @@ cc.pool = /** @lends cc.pool# */{ } if(obj.unuse) obj.unuse(); //define by user. use to initialize the state of objects. - obj.retain();//use for jsb + obj.retain && obj.retain();//use for jsb this._pool[pid].push(obj); } }, @@ -109,6 +109,7 @@ cc.pool = /** @lends cc.pool# */{ var list = this._pool[pid]; var args = Array.prototype.slice.call(arguments, 1); var obj = list.pop(); + obj.release && obj.release();//use for jsb if(obj.reuse) obj.reuse.apply(obj, args); //define by user. return obj; From 1cb3fda2f1a105354371fdeb1a9af55470730ff2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 28 Sep 2014 10:36:12 +0800 Subject: [PATCH 0701/1564] Issue #5933: Armature --- extensions/cocostudio/armature/CCArmature.js | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index b7cc12c406..4704f0f6b3 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -71,6 +71,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = true; this._realAnchorPointInPoints = cc.p(0, 0); name && ccs.Armature.prototype.init.call(this, name, parentBone); + + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + this._rendererStartCmd = new cc.CustomRenderCmdCanvas(this, this._startRendererCmdForCanvas); + this._rendererEndCmd = new cc.CustomRenderCmdCanvas(this, this._endRendererCmdForCanvas); + } }, /** @@ -373,6 +378,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ draw: function(ctx){ + //TODO REMOVE THIS FUNCTION if (this._parentBone == null && this._batchNode == null) { // CC_NODE_DRAW_SETUP(); } @@ -458,7 +464,43 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.transform(context); this.sortAllChildren(); + + if(this._rendererStartCmd) + cc.renderer.pushRenderCommand(this._rendererStartCmd); this.draw(ctx); + if(this._rendererEndCmd) + cc.renderer.pushRenderCommand(this._rendererEndCmd); + + // reset for next frame + this._cacheDirty = false; + this.arrivalOrder = 0; + + context.restore(); + }, + + _startRendererCmdForCanvas: function(ctx){ + var context = ctx || cc._renderContext; + context.save(); + this.transform(context); + var t = this._transformWorld; + ctx.transform(t.a, t.b, t.c, t.d, t.tx, -t.ty); + + var locChildren = this._children; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + node.visit(); + } + } + }, + + _endRendererCmdForCanvas: function(ctx){ + var context = ctx || cc._renderContext; // reset for next frame this._cacheDirty = false; From 92de200445da18445221a44b64dcbee19f6853cd Mon Sep 17 00:00:00 2001 From: Jialong Zhai Date: Sun, 28 Sep 2014 14:44:26 +0800 Subject: [PATCH 0702/1564] Bug #5958 : typo in setAntiAliasTexParameters --- cocos2d/core/textures/TexturesWebGL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 61b94006da..b0b7c06608 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -542,7 +542,7 @@ _tmp.WebGLTexture2D = function () { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); else gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); //TODO /*#if CC_ENABLE_CACHE_TEXTURE_DATA ccTexParams texParams = {m_bHasMipmaps?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR,GL_LINEAR,GL_NONE,GL_NONE}; From 1bd76437df34a6be6d8597e73bcf36b83c1d8de0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 28 Sep 2014 18:03:59 +0800 Subject: [PATCH 0703/1564] Issue #5933: PageView Element does not automatically update --- .../ccui/base-classes/CCProtectedNode.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 44005b7844..be410e09d3 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -483,6 +483,42 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForCanvas; + cc.ProtectedNode.prototype._transformForRenderer = function () { + var t = this.nodeToParentTransform(), worldT = this._transformWorld; + if(this._parent){ + var pt = this._parent._transformWorld; + //worldT = cc.AffineTransformConcat(t, pt); + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d + if(this._skewX || this._skewY){ + var plt = this._parent._transform; + var xOffset = -(plt.b + plt.c) * t.ty ; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + }else{ + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty + } + } else { + worldT.a = t.a; + worldT.b = t.b; + worldT.c = t.c; + worldT.d = t.d; + worldT.tx = t.tx; + worldT.ty = t.ty; + } + this._renderCmdDiry = false; + var i, len, locChildren = this._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._transformForRenderer(); + } + locChildren = this._protectedChildren; + for( i = 0, len = locChildren.length; i< len; i++) + locChildren[i]._transformForRenderer(); + }; }else{ cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForWebGL; cc.ProtectedNode.prototype._transformForRenderer = function () { From da339e8682d7bf5f47a04a8e55d824f6a17d479e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 29 Sep 2014 10:15:50 +0800 Subject: [PATCH 0704/1564] Issue #5933: Armature doesn't update texture when play new animation --- extensions/cocostudio/armature/CCArmature.js | 2 +- extensions/cocostudio/armature/display/CCDisplayManager.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 4704f0f6b3..621f82cc59 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -494,7 +494,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (null == node) continue; - node.visit(); + node._transformForRenderer(); } } }, diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 11f53cb9ad..e2acca4bbe 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -236,6 +236,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ return; } this.setCurrentDecorativeDisplay(this._decoDisplayList[index]); + cc.renderer.childrenOrderDirty = true; }, /** From 50996f60818b438713bd9029fbe3a15bb3a0b590 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Mon, 29 Sep 2014 11:26:03 +0800 Subject: [PATCH 0705/1564] Feature #5950 Add Facebook API upgrade Facebook sdk --- external/pluginx/platform/facebook.js | 296 ++++++++++++++-------- external/pluginx/platform/facebook_sdk.js | 180 ++++++------- 2 files changed, 277 insertions(+), 199 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 119e8bed58..cbbd113571 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -44,12 +44,44 @@ plugin.extend('facebook', { }, CODE_SUCCEED: 0, + AppEvent: { + 'ACTIVATED_APP': "fb_mobile_activate_app", + 'COMPLETED_REGISTRATION': "fb_mobile_complete_registration", + 'VIEWED_CONTENT': "fb_mobile_content_view", + 'SEARCHED': "fb_mobile_search", + 'RATED': "fb_mobile_rate", + 'COMPLETED_TUTORIAL': "fb_mobile_tutorial_completion", + 'ADDED_TO_CART': "fb_mobile_add_to_cart", + 'ADDED_TO_WISHLIST': "fb_mobile_add_to_wishlist", + 'INITIATED_CHECKOUT': "fb_mobile_initiated_checkout", + 'ADDED_PAYMENT_INFO': "fb_mobile_add_payment_info", + 'PURCHASED': "fb_mobile_purchase", + 'ACHIEVED_LEVEL': "fb_mobile_level_achieved", + 'UNLOCKED_ACHIEVEMENT': "fb_mobile_achievement_unlocked", + 'SPENT_CREDITS': "fb_mobile_spent_credits" + }, + AppEventParam: { + 'CURRENCY': "fb_currency", + 'REGISTRATION_METHOD': "fb_registration_method", + 'CONTENT_TYPE': "fb_content_type", + 'CONTENT_ID': "fb_content_id", + 'SEARCH_STRING': "fb_search_string", + 'SUCCESS': "fb_success", + 'MAX_RATING_VALUE': "fb_max_rating_value", + 'PAYMENT_INFO_AVAILABLE': "fb_payment_info_available", + 'NUM_ITEMS': "fb_num_items", + 'DESCRIPTION': "fb_description" + }, + AppEventParamValue: { + 'VALUE_YES': "1", + 'VALUE_NO': "0" + }, /** * Initialize Facebook sdk * @param {Object} config */ - ctor: function(config){ + ctor: function (config) { this.name = "facebook"; this.version = "1.0"; this.userInfo = {}; @@ -61,28 +93,26 @@ plugin.extend('facebook', { var self = this; //This configuration will be read from the project.json. FB.init(config); - FB.getLoginStatus(function(response) { + FB.getLoginStatus(function (response) { if (response && response.status === 'connected') { //login self._isLogined = true; //save user info self.userInfo = response.authResponse; - }else{ + } else { self._isLogined = false; } }); plugin.FacebookAgent = this; }, - /** * Gets the current object * @returns {FacebookAgent} */ - getInstance: function(){ + getInstance: function () { return this; }, - /** * Login to facebook * @param {Function} callback @@ -91,20 +121,20 @@ plugin.extend('facebook', { * //example * plugin.FacebookAgent.login(); */ - login: function(permissions,callback){ + login: function (permissions, callback) { var self = this; - if(typeof permissions == 'function'){ + if (typeof permissions == 'function') { callback = permissions; permissions = []; } - if(permissions.every(function(item){ - if(item != 'publish_actions') + if (permissions.every(function (item) { + if (item != 'publish_actions') return true; - })){ + })) { permissions.push("publish_actions"); } var permissionsStr = permissions.join(','); - FB.login(function(response) { + FB.login(function (response) { if (response['authResponse']) { //save user info self.userInfo = response['authResponse']; @@ -123,7 +153,6 @@ plugin.extend('facebook', { return_scopes: true }); }, - /** * Checking login status * @param {Function} callback @@ -131,10 +160,10 @@ plugin.extend('facebook', { * //example * plugin.FacebookAgent.isLoggedIn(type, msg); */ - isLoggedIn: function(callback){ + isLoggedIn: function (callback) { var self = this; - FB.getLoginStatus(function(response) { - if(response){ + FB.getLoginStatus(function (response) { + if (response) { if (response['status'] === 'connected') { //login - save user info self.userInfo = response['authResponse']; @@ -142,13 +171,13 @@ plugin.extend('facebook', { isLoggedIn: true, accessToken: response['authResponse']['accessToken'] }); - }else{ + } else { typeof callback === 'function' && callback(0, { isLoggedIn: false, accessToken: "" }); } - }else{ + } else { typeof callback === 'function' && callback(1, { error_message: 'Unknown' }); @@ -163,14 +192,14 @@ plugin.extend('facebook', { * //example * plugin.FacebookAgent.logout(callback); */ - logout: function(callback){ + logout: function (callback) { var self = this; - FB.logout(function(response) { - if(response['authResponse']){ + FB.logout(function (response) { + if (response['authResponse']) { // user is now logged out self.userInfo = {}; - typeof callback === 'function' && callback(0, {"isLoggedIn" : false}); - }else{ + typeof callback === 'function' && callback(0, {"isLoggedIn": false}); + } else { typeof callback === 'function' && callback(response['error_code'] || 1, { error_message: response['error_message'] || "Unknown" }); @@ -187,10 +216,10 @@ plugin.extend('facebook', { * //example * plugin.FacebookAgent.requestPermissions(["manage_pages"], callback); */ - requestPermissions: function(permissions, callback){ + requestPermissions: function (permissions, callback) { var permissionsStr = permissions.join(','); var self = this; - FB.login(function(response){ + FB.login(function (response) { if (response['authResponse']) { var permissList = response['authResponse']['grantedScopes'].split(","); //save user info @@ -216,18 +245,18 @@ plugin.extend('facebook', { * //example * plugin.FacebookAgent.requestPermissions(callback); */ - requestAccessToken: function(callback){ - if(typeof callback !== 'function'){ + requestAccessToken: function (callback) { + if (typeof callback !== 'function') { return; } - if(this.userInfo.accessToken){ + if (this.userInfo.accessToken) { callback(0, { accessToken: this.userInfo['accessToken'] }); - }else{ + } else { var self = this; - FB.getLoginStatus(function(response) { + FB.getLoginStatus(function (response) { if (response && response['status'] === 'connected') { //login - save user info self.userInfo = response['authResponse']; @@ -235,7 +264,7 @@ plugin.extend('facebook', { accessToken: response['authResponse']['accessToken'] }); - }else{ + } else { callback(response['error_code'] || 1, { error_message: response['error_message'] || "Unknown" }); @@ -249,7 +278,7 @@ plugin.extend('facebook', { * @param info * @param callback */ - share: function(info, callback){ + share: function (info, callback) { FB.ui({ method: 'share', name: info['title'], @@ -258,9 +287,9 @@ plugin.extend('facebook', { href: info['link'], picture: info['imageUrl'] }, - function(response) { + function (response) { if (response) { - if(response['post_id']) + if (response['post_id']) typeof callback === 'function' && callback(0, { didComplete: true, post_id: response['post_id'] @@ -282,67 +311,73 @@ plugin.extend('facebook', { * @param info * @param callback */ - dialog: function(info, callback){ - if(!info){ + webDialog: function (info, callback) { + if (!info) { return; } + if (info['dialog'] === 'share_link') { + if (info['link']) { + info['method'] = 'share'; + info['href'] = info['link']; + } + } else { + info['method'] = info['dialog']; + delete info['dialog']; - info['method'] = info['dialog']; - delete info['dialog']; - - info['name'] = info['site'] || info['name']; - delete info['site']; + info['name'] = info['site'] || info['name']; + delete info['site']; - info['href'] = info['siteUrl'] || info['link']; - delete info['siteUrl']; - delete info['link']; + info['href'] = info['siteUrl'] || info['link']; + delete info['siteUrl']; + delete info['link']; - info['image'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; - delete info['imageUrl']; - delete info['imagePath']; - delete info['photo']; + info['image'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; + delete info['imageUrl']; + delete info['imagePath']; + delete info['photo']; - info['caption'] = info['title'] || info['caption']; - delete info['title']; + info['caption'] = info['title'] || info['caption']; + delete info['title']; - info['description'] = info['text'] || info['description']; - delete info['text']; - delete info['description']; + info['description'] = info['text'] || info['description']; + delete info['text']; + delete info['description']; - if(info['method'] == 'share_open_graph' && info['url']){ - if(info['url']){ - var obj = {}; - if(info["preview_property"]) - obj[info["preview_property"]] = info["url"]; - else - obj["object"] = info["url"]; + if (info['method'] == 'share_open_graph' && info['url']) { + if (info['url']) { + var obj = {}; + if (info["preview_property"]) + obj[info["preview_property"]] = info["url"]; + else + obj["object"] = info["url"]; - for(var p in info){ - if(p != "method" && p != "action_type" && p != "action_properties"){ - info[p] && (obj[p] = info[p]); - delete info[p]; + for (var p in info) { + if (p != "method" && p != "action_type" && p != "action_properties") { + info[p] && (obj[p] = info[p]); + delete info[p]; + } } + + info['action_properties'] = JSON.stringify(obj); + } else { + return; } + } - info['action_properties'] = JSON.stringify(obj); - }else{ + if ( + info['method'] != 'share_open_graph' && + info['method'] != 'share_link' + ) { + cc.log('web is not supported what this it method'); return; } } - if( - info['method'] != 'share_open_graph' && - info['method'] != 'share_link' - ){ - cc.log('web is not supported what this it method'); - return; - } - FB.ui(info, - function(response) { + function (response) { if (response) { - if(response['post_id']) + if (response['post_id']) typeof callback === 'function' && callback(0, { didComplete: true, post_id: response['post_id'] @@ -351,12 +386,14 @@ plugin.extend('facebook', { typeof callback === 'function' && callback(0, response); } else { typeof callback === 'function' && callback(1, { - error_message:"Unknow error" + error_message: "Unknow error" }); } }); }, - + canPresentDialog: function (map) { + return false; + }, /** * FB.api package * @param {String} path @@ -364,17 +401,17 @@ plugin.extend('facebook', { * @param {Object} params * @param {Function} callback */ - api: function(path, httpmethod, params, callback){ - if(typeof params === 'function'){ + api: function (path, httpmethod, params, callback) { + if (typeof params === 'function') { callback = params; params = {}; } - FB.api(path, httpmethod, params, function(response){ - if(response.error){ + FB.api(path, httpmethod, params, function (response) { + if (response.error) { typeof callback === 'function' && callback(response['error']['code'], { error_message: response['error']['message'] || 'Unknown' }) - }else{ + } else { typeof callback === 'function' && callback(0, response); } }); @@ -384,18 +421,20 @@ plugin.extend('facebook', { * Get permission list * @param callback */ - getPermissionList: function(callback){ - FB.api("/me/permissions", function(response){ - if(response['data']){ + getPermissionList: function (callback) { + FB.api("/me/permissions", function (response) { + if (response['data']) { var permissionList = []; - for(var i=0; i1?Number(arguments[1]):0;if(isNaN(j))j=0;var k=Math.min(Math.max(j,0),i.length);return i.indexOf(String(h),j)==k;};g.endsWith=function(h){var i=String(this);if(this==null)throw new TypeError('String.prototype.endsWith called on null or undefined');var j=i.length,k=String(h),l=arguments.length>1?Number(arguments[1]):j;if(isNaN(l))l=0;var m=Math.min(Math.max(l,0),j),n=m-k.length;if(n<0)return false;return i.lastIndexOf(k,n)==n;};g.contains=function(h){if(this==null)throw new TypeError('String.prototype.contains called on null or undefined');var i=String(this),j=arguments.length>1?Number(arguments[1]):0;if(isNaN(j))j=0;return i.indexOf(String(h),j)!=-1;};g.repeat=function(h){if(this==null)throw new TypeError('String.prototype.repeat called on null or undefined');var i=String(this),j=h?Number(h):0;if(isNaN(j))j=0;if(j<0||j===Infinity)throw RangeError();if(j===1)return i;if(j===0)return '';var k='';while(j){if(j&1)k+=i;if((j>>=1))i+=i;}return k;};e.exports=g;},null); __d("ES5Array",[],function(a,b,c,d,e,f){var g={};g.isArray=function(h){return Object.prototype.toString.call(h)=='[object Array]';};e.exports=g;},null); - __d("ES5Object",[],function(a,b,c,d,e,f){var g={};g.create=function(h){var i=typeof h;if(i!='object'&&i!='function')throw new TypeError('Object prototype may only be a Object or null');var j=new Function();j.prototype=h;return new j();};g.keys=function(h){var i=typeof h;if(i!='object'&&i!='function'||h===null)throw new TypeError('Object.keys called on non-object');var j=[];for(var k in h)if(Object.prototype.hasOwnProperty.call(h,k))j.push(k);var l=!({toString:true}).propertyIsEnumerable('toString'),m=['toString','toLocaleString','valueOf','hasOwnProperty','isPrototypeOf','prototypeIsEnumerable','constructor'];if(l)for(var n=0;n1)))/4)-ca((ga-1901+ha)/100)+ca((ga-1601+ha)/400);};}if(typeof JSON=="object"&&JSON){k.stringify=JSON.stringify;k.parse=JSON.parse;}if((m=typeof k.stringify=="function"&&!ea)){(ba=function(){return 1;}).toJSON=ba;try{m=k.stringify(0)==="0"&&k.stringify(new Number())==="0"&&k.stringify(new String())=='""'&&k.stringify(g)===j&&k.stringify(j)===j&&k.stringify()===j&&k.stringify(ba)==="1"&&k.stringify([ba])=="[1]"&&k.stringify([j])=="[null]"&&k.stringify(null)=="null"&&k.stringify([j,g,null])=="[null,null,null]"&&k.stringify({result:[ba,true,false,null,"\0\b\n\f\r\t"]})==l&&k.stringify(null,ba)==="1"&&k.stringify([1,2],null,1)=="[\n 1,\n 2\n]"&&k.stringify(new Date(-8.64e+15))=='"-271821-04-20T00:00:00.000Z"'&&k.stringify(new Date(8.64e+15))=='"+275760-09-13T00:00:00.000Z"'&&k.stringify(new Date(-62198755200000))=='"-000001-01-01T00:00:00.000Z"'&&k.stringify(new Date(-1))=='"1969-12-31T23:59:59.999Z"';}catch(fa){m=false;}}if(typeof k.parse=="function")try{if(k.parse("0")===0&&!k.parse(false)){ba=k.parse(l);if((r=ba.A.length==5&&ba.A[0]==1)){try{r=!k.parse('"\t"');}catch(fa){}if(r)try{r=k.parse("01")!=1;}catch(fa){}}}}catch(fa){r=false;}ba=l=null;if(!m||!r){if(!(h={}.hasOwnProperty))h=function(ga){var ha={},ia;if((ha.__proto__=null,ha.__proto__={toString:1},ha).toString!=g){h=function(ja){var ka=this.__proto__,la=ja in (this.__proto__=null,this);this.__proto__=ka;return la;};}else{ia=ha.constructor;h=function(ja){var ka=(this.constructor||ia).prototype;return ja in this&&!(ja in ka&&this[ja]===ka[ja]);};}ha=null;return h.call(this,ga);};i=function(ga,ha){var ia=0,ja,ka,la,ma;(ja=function(){this.valueOf=0;}).prototype.valueOf=0;ka=new ja();for(la in ka)if(h.call(ka,la))ia++;ja=ka=null;if(!ia){ka=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];ma=function(na,oa){var pa=g.call(na)=="[object Function]",qa,ra;for(qa in na)if(!(pa&&qa=="prototype")&&h.call(na,qa))oa(qa);for(ra=ka.length;qa=ka[--ra];h.call(na,qa)&&oa(qa));};}else if(ia==2){ma=function(na,oa){var pa={},qa=g.call(na)=="[object Function]",ra;for(ra in na)if(!(qa&&ra=="prototype")&&!h.call(pa,ra)&&(pa[ra]=1)&&h.call(na,ra))oa(ra);};}else ma=function(na,oa){var pa=g.call(na)=="[object Function]",qa,ra;for(qa in na)if(!(pa&&qa=="prototype")&&h.call(na,qa)&&!(ra=qa==="constructor"))oa(qa);if(ra||h.call(na,(qa="constructor")))oa(qa);};return ma(ga,ha);};if(!m){n={"\\":"\\\\",'"':'\\"',"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};o=function(ga,ha){return ("000000"+(ha||0)).slice(-ga);};p=function(ga){var ha='"',ia=0,ja;for(;ja=ga.charAt(ia);ia++)ha+='\\"\b\f\n\r\t'.indexOf(ja)>-1?n[ja]:ja<" "?"\\u00"+o(2,ja.charCodeAt(0).toString(16)):ja;return ha+'"';};q=function(ga,ha,ia,ja,ka,la,ma){var na=ha[ga],oa,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za,ab,bb,cb;if(typeof na=="object"&&na){oa=g.call(na);if(oa=="[object Date]"&&!h.call(na,"toJSON")){if(na>-1/0&&na<1/0){if(ea){ra=ca(na/86400000);for(pa=ca(ra/365.2425)+1970-1;ea(pa+1,0)<=ra;pa++);for(qa=ca((ra-ea(pa,0))/30.42);ea(pa,qa+1)<=ra;qa++);ra=1+ra-ea(pa,qa);sa=(na%86400000+86400000)%86400000;ta=ca(sa/3600000)%24;ua=ca(sa/60000)%60;va=ca(sa/1000)%60;wa=sa%1000;}else{pa=na.getUTCFullYear();qa=na.getUTCMonth();ra=na.getUTCDate();ta=na.getUTCHours();ua=na.getUTCMinutes();va=na.getUTCSeconds();wa=na.getUTCMilliseconds();}na=(pa<=0||pa>=10000?(pa<0?"-":"+")+o(6,pa<0?-pa:pa):o(4,pa))+"-"+o(2,qa+1)+"-"+o(2,ra)+"T"+o(2,ta)+":"+o(2,ua)+":"+o(2,va)+"."+o(3,wa)+"Z";}else na=null;}else if(typeof na.toJSON=="function"&&((oa!="[object Number]"&&oa!="[object String]"&&oa!="[object Array]")||h.call(na,"toJSON")))na=na.toJSON(ga);}if(ia)na=ia.call(ha,ga,na);if(na===null)return "null";oa=g.call(na);if(oa=="[object Boolean]"){return ""+na;}else if(oa=="[object Number]"){return na>-1/0&&na<1/0?""+na:"null";}else if(oa=="[object String]")return p(na);if(typeof na=="object"){for(ab=ma.length;ab--;)if(ma[ab]===na)throw TypeError();ma.push(na);xa=[];bb=la;la+=ka;if(oa=="[object Array]"){for(za=0,ab=na.length;za0)for(ja="",ia>10&&(ia=10);ja.length-1){z++;}else if("{}[]:,".indexOf(ia)>-1){z++;return ia;}else if(ia=='"'){for(ja="@",z++;z-1){ja+=t[ia];z++;}else if(ia=="u"){ka=++z;for(la=z+4;z="0"&&ia<="9"||ia>="a"&&ia<="f"||ia>="A"&&ia<="F"))u();}ja+=s("0x"+ga.slice(ka,z));}else u();}else{if(ia=='"')break;ja+=ia;z++;}}if(ga.charAt(z)=='"'){z++;return ja;}u();}else{ka=z;if(ia=="-"){ma=true;ia=ga.charAt(++z);}if(ia>="0"&&ia<="9"){if(ia=="0"&&(ia=ga.charAt(z+1),ia>="0"&&ia<="9"))u();ma=false;for(;z="0"&&ia<="9");z++);if(ga.charAt(z)=="."){la=++z;for(;la="0"&&ia<="9");la++);if(la==z)u();z=la;}ia=ga.charAt(z);if(ia=="e"||ia=="E"){ia=ga.charAt(++z);if(ia=="+"||ia=="-")z++;for(la=z;la="0"&&ia<="9");la++);if(la==z)u();z=la;}return +ga.slice(ka,z);}if(ma)u();if(ga.slice(z,z+4)=="true"){z+=4;return true;}else if(ga.slice(z,z+5)=="false"){z+=5;return false;}else if(ga.slice(z,z+4)=="null"){z+=4;return null;}u();}}return "$";};w=function(ga){var ha,ia,ja;if(ga=="$")u();if(typeof ga=="string"){if(ga.charAt(0)=="@")return ga.slice(1);if(ga=="["){ha=[];for(;;ia||(ia=true)){ga=v();if(ga=="]")break;if(ia)if(ga==","){ga=v();if(ga=="]")u();}else u();if(ga==",")u();ha.push(w(ga));}return ha;}else if(ga=="{"){ha={};for(;;ia||(ia=true)){ga=v();if(ga=="}")break;if(ia)if(ga==","){ga=v();if(ga=="}")u();}else u();if(ga==","||typeof ga!="string"||ga.charAt(0)!="@"||v()!=":")u();ha[ga.slice(1)]=w(v());}return ha;}u();}return ga;};y=function(ga,ha,ia){var ja=x(ga,ha,ia);if(ja===j){delete ga[ha];}else ga[ha]=ja;};x=function(ga,ha,ia){var ja=ga[ha],ka;if(typeof ja=="object"&&ja)if(g.call(ja)=="[object Array]"){for(ka=ja.length;ka--;)y(ja,ka,ia);}else i(ja,function(la){y(ja,la,ia);});return ia.call(ga,ha,ja);};k.parse=function(ga,ha){z=0;aa=ga;var ia=w(v());if(v()!="$")u();z=aa=null;return ha&&g.call(ha)=="[object Function]"?x((ba={},ba[""]=ia,ba),"",ha):ia;};}}}).call(this);},null); - __d("ES5",["ES5ArrayPrototype","ES5FunctionPrototype","ES5StringPrototype","ES5Array","ES5Object","ES5Date","JSON3"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=Array.prototype.slice,o=Object.prototype.toString,p={'JSON.stringify':m.stringify,'JSON.parse':m.parse},q={array:g,'function':h,string:i,Object:k,Array:j,Date:l};for(var r in q){if(!q.hasOwnProperty(r))continue;var s=q[r],t=r===r.toLowerCase()?window[r.replace(/^\w/,function(x){return x.toUpperCase();})].prototype:window[r];for(var u in s){if(!s.hasOwnProperty(u))continue;var v=t[u];p[r+'.'+u]=v&&/\{\s+\[native code\]\s\}/.test(v)?v:s[u];}}function w(x,y,z){var aa=n.call(arguments,3),ba=z?/\s(.*)\]/.exec(o.call(x).toLowerCase())[1]:x,ca=p[ba+'.'+y]||x[y];if(typeof ca==='function')return ca.apply(x,aa);}e.exports=w;},null); - var ES5 = require('ES5'); - __d("JSSDKRuntimeConfig",[],{"locale":"zh_CN","rtl":false,"revision":"1272844"});__d("JSSDKConfig",[],{"bustCache":true,"tagCountLogRate":0.01,"errorHandling":{"rate":4},"usePluginPipe":true,"features":{"kill_fragment":true,"xfbml_profile_pic_server":true,"error_handling":{"rate":4},"e2e_ping_tracking":{"rate":1.0e-6},"xd_timeout":{"rate":4,"value":30000},"use_bundle":true},"api":{"mode":"warn","whitelist":["Canvas","Canvas.Prefetcher","Canvas.Prefetcher.addStaticResource","Canvas.Prefetcher.setCollectionMode","Canvas.getPageInfo","Canvas.hideFlashElement","Canvas.scrollTo","Canvas.setAutoGrow","Canvas.setDoneLoading","Canvas.setSize","Canvas.setUrlHandler","Canvas.showFlashElement","Canvas.startTimer","Canvas.stopTimer","Data","Data.process","Data.query","Data.query:wait","Data.waitOn","Data.waitOn:wait","Event","Event.subscribe","Event.unsubscribe","Music.flashCallback","Music.init","Music.send","Payment","Payment.cancelFlow","Payment.continueFlow","Payment.init","Payment.lockForProcessing","Payment.unlockForProcessing","Payment.parse","Payment.setSize","ThirdPartyProvider","ThirdPartyProvider.init","ThirdPartyProvider.sendData","UA","UA.nativeApp","XFBML","XFBML.RecommendationsBar","XFBML.RecommendationsBar.markRead","XFBML.parse","addFriend","api","getAccessToken","getAuthResponse","getLoginStatus","getUserID","init","login","logout","publish","share","ui","ui:subscribe"]},"initSitevars":{"enableMobileComments":1,"iframePermissions":{"read_stream":false,"manage_mailbox":false,"manage_friendlists":false,"read_mailbox":false,"publish_checkins":true,"status_update":true,"photo_upload":true,"video_upload":true,"sms":false,"create_event":true,"rsvp_event":true,"offline_access":true,"email":true,"xmpp_login":false,"create_note":true,"share_item":true,"export_stream":false,"publish_stream":true,"publish_likes":true,"ads_management":false,"contact_email":true,"access_private_data":false,"read_insights":false,"read_requests":false,"read_friendlists":true,"manage_pages":false,"physical_login":false,"manage_groups":false,"read_deals":false}}});__d("UrlMapConfig",[],{"www":"www.facebook.com","m":"m.facebook.com","connect":"connect.facebook.net","business":"business.facebook.com","api_https":"api.facebook.com","api_read_https":"api-read.facebook.com","graph_https":"graph.facebook.com","fbcdn_http":"static.ak.fbcdn.net","fbcdn_https":"fbstatic-a.akamaihd.net","cdn_http":"static.ak.facebook.com","cdn_https":"s-static.ak.facebook.com"});__d("JSSDKXDConfig",[],{"XdUrl":"\/connect\/xd_arbiter.php?version=41","XdBundleUrl":"\/connect\/xd_arbiter\/V80PAcvrynR.js?version=41","Flash":{"path":"https:\/\/connect.facebook.net\/rsrc.php\/v1\/yR\/r\/ks_9ZXiQ0GL.swf"},"useCdn":true});__d("JSSDKCssConfig",[],{"rules":".fb_hidden{position:absolute;top:-10000px;z-index:10001}.fb_invisible{display:none}.fb_reset{background:none;border:0;border-spacing:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}.fb_reset>div{overflow:hidden}.fb_link img{border:none}\n.fb_dialog{background:rgba(82, 82, 82, .7);position:absolute;top:-10000px;z-index:10001}.fb_reset .fb_dialog_legacy{overflow:visible}.fb_dialog_advanced{padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.fb_dialog_content{background:#fff;color:#333}.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px}.fb_dialog_mobile .fb_dialog_close_icon{top:5px;left:5px;right:auto}.fb_dialog_padding{background-color:transparent;position:absolute;width:1px;z-index:-1}.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif)}.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif)}.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:25px;padding:20px}.fb_dialog_top_left,.fb_dialog_top_right,.fb_dialog_bottom_left,.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}.fb_dialog_vert_left,.fb_dialog_vert_right,.fb_dialog_horiz_top,.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}.fb_dialog_vert_left,.fb_dialog_vert_right{width:10px;height:100\u0025}.fb_dialog_vert_left{margin-left:-10px}.fb_dialog_vert_right{right:0;margin-right:-10px}.fb_dialog_horiz_top,.fb_dialog_horiz_bottom{width:100\u0025;height:10px}.fb_dialog_horiz_top{margin-top:-10px}.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}.fb_dialog_iframe{line-height:0}.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:15px;font-weight:bold;margin:0}.fb_dialog_content .dialog_title>span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}body.fb_hidden{-webkit-transform:none;height:100\u0025;margin:0;overflow:visible;position:absolute;top:-10000px;left:0;width:100\u0025}.fb_dialog.fb_dialog_mobile.loading{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ya\/r\/3rhSv5V8j3o.gif) white no-repeat 50\u0025 50\u0025;min-height:100\u0025;min-width:100\u0025;overflow:hidden;position:absolute;top:0;z-index:10001}.fb_dialog.fb_dialog_mobile.loading.centered{max-height:590px;min-height:590px;max-width:500px;min-width:500px}#fb-root #fb_dialog_ipad_overlay{background:rgba(0, 0, 0, .45);position:absolute;left:0;top:0;width:100\u0025;min-height:100\u0025;z-index:10000}#fb-root #fb_dialog_ipad_overlay.hidden{display:none}.fb_dialog.fb_dialog_mobile.loading iframe{visibility:hidden}.fb_dialog_content .dialog_header{-webkit-box-shadow:white 0 1px 1px -1px inset;background:-webkit-gradient(linear, 0\u0025 0\u0025, 0\u0025 100\u0025, from(#738ABA), to(#2C4987));border-bottom:1px solid;border-color:#1d4088;color:#fff;font:14px Helvetica, sans-serif;font-weight:bold;text-overflow:ellipsis;text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0;vertical-align:middle;white-space:nowrap}.fb_dialog_content .dialog_header table{-webkit-font-smoothing:subpixel-antialiased;height:43px;width:100\u0025}.fb_dialog_content .dialog_header td.header_left{font-size:13px;padding-left:5px;vertical-align:middle;width:60px}.fb_dialog_content .dialog_header td.header_right{font-size:13px;padding-right:5px;vertical-align:middle;width:60px}.fb_dialog_content .touchable_button{background:-webkit-gradient(linear, 0\u0025 0\u0025, 0\u0025 100\u0025, from(#4966A6), color-stop(.5, #355492), to(#2A4887));border:1px solid #29447e;-webkit-background-clip:padding-box;-webkit-border-radius:3px;-webkit-box-shadow:rgba(0, 0, 0, .117188) 0 1px 1px inset, rgba(255, 255, 255, .167969) 0 1px 0;display:inline-block;margin-top:3px;max-width:85px;line-height:18px;padding:4px 12px;position:relative}.fb_dialog_content .dialog_header .touchable_button input{border:none;background:none;color:#fff;font:12px Helvetica, sans-serif;font-weight:bold;margin:2px -12px;padding:2px 6px 3px 6px;text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0}.fb_dialog_content .dialog_header .header_center{color:#fff;font-size:17px;font-weight:bold;line-height:18px;text-align:center;vertical-align:middle}.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/y9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}#fb_dialog_loader_close{float:left}.fb_dialog.fb_dialog_mobile .fb_dialog_close_button{text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0}.fb_dialog.fb_dialog_mobile .fb_dialog_close_icon{visibility:hidden}\n.fb_iframe_widget{display:inline-block;position:relative}.fb_iframe_widget span{display:inline-block;position:relative;text-align:justify}.fb_iframe_widget iframe{position:absolute}.fb_iframe_widget_lift{z-index:1}.fb_hide_iframes iframe{position:relative;left:-10000px}.fb_iframe_widget_loader{position:relative;display:inline-block}.fb_iframe_widget_fluid{display:inline}.fb_iframe_widget_fluid span{width:100\u0025}.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/y9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_connect_bar_container div,.fb_connect_bar_container span,.fb_connect_bar_container a,.fb_connect_bar_container img,.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:14px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}.fb_connect_bar a:hover{color:#fff}.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}.fb_connect_bar div a,.fb_connect_bar span,.fb_connect_bar span a{color:#bac6da;font-size:12px;text-decoration:none}.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fbpluginrecommendationsbarleft,.fbpluginrecommendationsbarright{position:fixed !important;bottom:0;z-index:999}.fbpluginrecommendationsbarleft{left:10px}.fbpluginrecommendationsbarright{right:10px}","components":["css:fb.css.base","css:fb.css.dialog","css:fb.css.iframewidget","css:fb.css.connectbarwidget","css:fb.css.plugin.recommendationsbar"]});__d("ApiClientConfig",[],{"FlashRequest":{"swfUrl":"https:\/\/connect.facebook.net\/rsrc.php\/v1\/yW\/r\/PvklbuW2Ycn.swf"}});__d("JSSDKCanvasPrefetcherConfig",[],{"blacklist":[144959615576466],"sampleRate":500});__d("JSSDKPluginPipeConfig",[],{"threshold":0,"enabledApps":{"209753825810663":1,"187288694643718":1}});__d("JSSDKConnectBarConfig",[],{"imgs":{"buttonUrl":"rsrc.php\/v2\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/v2\/yo\/r\/UlIqmHJn-SK.gif"}}); - __d("QueryString",[],function(a,b,c,d,e,f){function g(k){var l=[];ES5(ES5('Object','keys',false,k).sort(),'forEach',true,function(m){var n=k[m];if(typeof n==='undefined')return;if(n===null){l.push(m);return;}l.push(encodeURIComponent(m)+'='+encodeURIComponent(n));});return l.join('&');}function h(k,l){var m={};if(k==='')return m;var n=k.split('&');for(var o=0;o>>0;for(var l=0;l9999?'+':''))+('00000'+Math.abs(i)).slice(0<=i&&i<=9999?-4:-6);return i+'-'+g(this.getUTCMonth()+1)+'-'+g(this.getUTCDate())+'T'+g(this.getUTCHours())+':'+g(this.getUTCMinutes())+':'+g(this.getUTCSeconds())+'.'+(this.getUTCMilliseconds()/1000).toFixed(3).slice(2,5)+'Z';}};e.exports=h;},null); + __d("ES6Number",[],function(a,b,c,d,e,f){var g={isFinite:function(h){return (typeof h=='number')&&isFinite(h);},isNaN:function(h){return (typeof h=='number')&&isNaN(h);}};e.exports=g;},null); + __d("ES",["ES5ArrayPrototype","ES5FunctionPrototype","ES5StringPrototype","ES5Array","ES5Object","ES5Date","JSON3","ES6Object","ES6ArrayPrototype","ES6DatePrototype","ES6Number"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=({}).toString,s={'JSON.stringify':m.stringify,'JSON.parse':m.parse},t={'Array.prototype':g,'Function.prototype':h,'String.prototype':i,Object:k,Array:j,Date:l},u={Object:n,'Array.prototype':o,'Date.prototype':p,Number:q};function v(x){for(var y in x){if(!x.hasOwnProperty(y))continue;var z=x[y],aa=y.split('.'),ba=aa.length==2?window[aa[0]][aa[1]]:window[y];for(var ca in z){if(!z.hasOwnProperty(ca))continue;var da=ba[ca];s[y+'.'+ca]=da&&/\{\s+\[native code\]\s\}/.test(da)?da:z[ca];}}}v(t);v(u);function w(x,y,z){var aa=Array.prototype.slice.call(arguments,3),ba=z?r.call(x).slice(8,-1)+'.prototype':x,ca=s[ba+'.'+y]||x[y];if(typeof ca==='function')return ca.apply(x,aa);}e.exports=w;},null); + var ES = require('ES'); + __d("JSSDKRuntimeConfig",[],{"locale":"zh_CN","rtl":false,"revision":"1425205"});__d("JSSDKConfig",[],{"bustCache":true,"tagCountLogRate":0.01,"errorHandling":{"rate":4},"usePluginPipe":true,"features":{"allow_non_canvas_app_events":false,"event_subscriptions_log":{"rate":0.01,"value":10000},"kill_fragment":true,"xfbml_profile_pic_server":true,"error_handling":{"rate":4},"e2e_ping_tracking":{"rate":1.0e-6},"xd_timeout":{"rate":4,"value":30000},"use_bundle":true,"launch_payment_dialog_via_pac":{"rate":100}},"api":{"mode":"warn","whitelist":["Canvas","Canvas.Prefetcher","Canvas.Prefetcher.addStaticResource","Canvas.Prefetcher.setCollectionMode","Canvas.getPageInfo","Canvas.hideFlashElement","Canvas.scrollTo","Canvas.setAutoGrow","Canvas.setDoneLoading","Canvas.setSize","Canvas.setUrlHandler","Canvas.showFlashElement","Canvas.startTimer","Canvas.stopTimer","Data","Data.process","Data.query","Data.query:wait","Data.waitOn","Data.waitOn:wait","Event","Event.subscribe","Event.unsubscribe","Music.flashCallback","Music.init","Music.send","Payment","Payment.cancelFlow","Payment.continueFlow","Payment.init","Payment.lockForProcessing","Payment.unlockForProcessing","Payment.parse","Payment.setSize","ThirdPartyProvider","ThirdPartyProvider.init","ThirdPartyProvider.sendData","UA","UA.nativeApp","XFBML","XFBML.RecommendationsBar","XFBML.RecommendationsBar.markRead","XFBML.parse","addFriend","api","getAccessToken","getAuthResponse","getLoginStatus","getUserID","init","login","logout","publish","share","ui","ui:subscribe","AppEvents","AppEvents.activateApp","AppEvents.logEvent","AppEvents.logPurchase","AppEvents.EventNames","AppEvents.ParameterNames"]},"initSitevars":{"enableMobileComments":1,"iframePermissions":{"read_stream":false,"manage_mailbox":false,"manage_friendlists":false,"read_mailbox":false,"publish_checkins":true,"status_update":true,"photo_upload":true,"video_upload":true,"sms":false,"create_event":true,"rsvp_event":true,"offline_access":true,"email":true,"xmpp_login":false,"create_note":true,"share_item":true,"export_stream":false,"publish_stream":true,"publish_likes":true,"ads_management":false,"contact_email":true,"access_private_data":false,"read_insights":false,"read_requests":false,"read_friendlists":true,"manage_pages":false,"physical_login":false,"manage_groups":false,"read_deals":false}}});__d("UrlMapConfig",[],{"www":"www.facebook.com","m":"m.facebook.com","connect":"connect.facebook.net","business":"business.facebook.com","api_https":"api.facebook.com","api_read_https":"api-read.facebook.com","graph_https":"graph.facebook.com","fbcdn_http":"static.ak.fbcdn.net","fbcdn_https":"fbstatic-a.akamaihd.net","cdn_http":"static.ak.facebook.com","cdn_https":"s-static.ak.facebook.com"});__d("JSSDKXDConfig",[],{"XdUrl":"\/connect\/xd_arbiter.php?version=41","XdBundleUrl":"\/connect\/xd_arbiter\/ZEbdHPQfV3x.js?version=41","Flash":{"path":"https:\/\/connect.facebook.net\/rsrc.php\/v1\/yR\/r\/ks_9ZXiQ0GL.swf"},"useCdn":true});__d("JSSDKCssConfig",[],{"rules":".fb_hidden{position:absolute;top:-10000px;z-index:10001}.fb_invisible{display:none}.fb_reset{background:none;border:0;border-spacing:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}.fb_reset>div{overflow:hidden}.fb_link img{border:none}\n.fb_dialog{background:rgba(82, 82, 82, .7);position:absolute;top:-10000px;z-index:10001}.fb_reset .fb_dialog_legacy{overflow:visible}.fb_dialog_advanced{padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.fb_dialog_content{background:#fff;color:#333}.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px}.fb_dialog_mobile .fb_dialog_close_icon{top:5px;left:5px;right:auto}.fb_dialog_padding{background-color:transparent;position:absolute;width:1px;z-index:-1}.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif)}.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yL\/r\/s816eWC-2sl.gif)}.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:25px;padding:20px}.fb_dialog_top_left,.fb_dialog_top_right,.fb_dialog_bottom_left,.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ye\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}.fb_dialog_vert_left,.fb_dialog_vert_right,.fb_dialog_horiz_top,.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}.fb_dialog_vert_left,.fb_dialog_vert_right{width:10px;height:100\u0025}.fb_dialog_vert_left{margin-left:-10px}.fb_dialog_vert_right{right:0;margin-right:-10px}.fb_dialog_horiz_top,.fb_dialog_horiz_bottom{width:100\u0025;height:10px}.fb_dialog_horiz_top{margin-top:-10px}.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}.fb_dialog_iframe{line-height:0}.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:15px;font-weight:bold;margin:0}.fb_dialog_content .dialog_title>span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}body.fb_hidden{-webkit-transform:none;height:100\u0025;margin:0;overflow:visible;position:absolute;top:-10000px;left:0;width:100\u0025}.fb_dialog.fb_dialog_mobile.loading{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/ya\/r\/3rhSv5V8j3o.gif) white no-repeat 50\u0025 50\u0025;min-height:100\u0025;min-width:100\u0025;overflow:hidden;position:absolute;top:0;z-index:10001}.fb_dialog.fb_dialog_mobile.loading.centered{max-height:590px;min-height:590px;max-width:500px;min-width:500px}#fb-root #fb_dialog_ipad_overlay{background:rgba(0, 0, 0, .45);position:absolute;left:0;top:0;width:100\u0025;min-height:100\u0025;z-index:10000}#fb-root #fb_dialog_ipad_overlay.hidden{display:none}.fb_dialog.fb_dialog_mobile.loading iframe{visibility:hidden}.fb_dialog_content .dialog_header{-webkit-box-shadow:white 0 1px 1px -1px inset;background:-webkit-gradient(linear, 0\u0025 0\u0025, 0\u0025 100\u0025, from(#738ABA), to(#2C4987));border-bottom:1px solid;border-color:#1d4088;color:#fff;font:14px Helvetica, sans-serif;font-weight:bold;text-overflow:ellipsis;text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0;vertical-align:middle;white-space:nowrap}.fb_dialog_content .dialog_header table{-webkit-font-smoothing:subpixel-antialiased;height:43px;width:100\u0025}.fb_dialog_content .dialog_header td.header_left{font-size:13px;padding-left:5px;vertical-align:middle;width:60px}.fb_dialog_content .dialog_header td.header_right{font-size:13px;padding-right:5px;vertical-align:middle;width:60px}.fb_dialog_content .touchable_button{background:-webkit-gradient(linear, 0\u0025 0\u0025, 0\u0025 100\u0025, from(#4966A6), color-stop(.5, #355492), to(#2A4887));border:1px solid #29447e;-webkit-background-clip:padding-box;-webkit-border-radius:3px;-webkit-box-shadow:rgba(0, 0, 0, .117188) 0 1px 1px inset, rgba(255, 255, 255, .167969) 0 1px 0;display:inline-block;margin-top:3px;max-width:85px;line-height:18px;padding:4px 12px;position:relative}.fb_dialog_content .dialog_header .touchable_button input{border:none;background:none;color:#fff;font:12px Helvetica, sans-serif;font-weight:bold;margin:2px -12px;padding:2px 6px 3px 6px;text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0}.fb_dialog_content .dialog_header .header_center{color:#fff;font-size:17px;font-weight:bold;line-height:18px;text-align:center;vertical-align:middle}.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/y9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}#fb_dialog_loader_close{float:left}.fb_dialog.fb_dialog_mobile .fb_dialog_close_button{text-shadow:rgba(0, 30, 84, .296875) 0 -1px 0}.fb_dialog.fb_dialog_mobile .fb_dialog_close_icon{visibility:hidden}\n.fb_iframe_widget{display:inline-block;position:relative}.fb_iframe_widget span{display:inline-block;position:relative;text-align:justify}.fb_iframe_widget iframe{position:absolute}.fb_iframe_widget_lift{z-index:1}.fb_hide_iframes iframe{position:relative;left:-10000px}.fb_iframe_widget_loader{position:relative;display:inline-block}.fb_iframe_widget_fluid{display:inline}.fb_iframe_widget_fluid span{width:100\u0025}.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/y9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fbpluginrecommendationsbarleft,.fbpluginrecommendationsbarright{position:fixed !important;bottom:0;z-index:999}.fbpluginrecommendationsbarleft{left:10px}.fbpluginrecommendationsbarright{right:10px}","components":["css:fb.css.base","css:fb.css.dialog","css:fb.css.iframewidget","css:fb.css.plugin.recommendationsbar"]});__d("ApiClientConfig",[],{"FlashRequest":{"swfUrl":"https:\/\/connect.facebook.net\/rsrc.php\/v1\/yW\/r\/PvklbuW2Ycn.swf"}});__d("JSSDKCanvasPrefetcherConfig",[],{"blacklist":[144959615576466],"sampleRate":500});__d("JSSDKPluginPipeConfig",[],{"threshold":0,"enabledApps":{"209753825810663":1,"187288694643718":1}}); + __d("QueryString",[],function(a,b,c,d,e,f){function g(k){var l=[];ES(ES('Object','keys',false,k).sort(),'forEach',true,function(m){var n=k[m];if(typeof n==='undefined')return;if(n===null){l.push(m);return;}l.push(encodeURIComponent(m)+'='+encodeURIComponent(n));});return l.join('&');}function h(k,l){var m={};if(k==='')return m;var n=k.split('&');for(var o=0;oh);},ie64:function(){return x.ie()&&r;},firefox:function(){return w()||i;},opera:function(){return w()||j;},webkit:function(){return w()||k;},safari:function(){return x.webkit();},chrome:function(){return w()||l;},windows:function(){return w()||o;},osx:function(){return w()||n;},linux:function(){return w()||p;},iphone:function(){return w()||s;},mobile:function(){return w()||(s||t||q||v);},nativeApp:function(){return w()||u;},android:function(){return w()||q;},ipad:function(){return w()||t;}};e.exports=x;},null); - __d("hasNamePropertyBug",["guid","UserAgent"],function(a,b,c,d,e,f,g,h){var i=h.ie()?undefined:false;function j(){var l=document.createElement("form"),m=l.appendChild(document.createElement("input"));m.name=g();i=m!==l.elements[m.name];l=m=null;return i;}function k(){return typeof i==='undefined'?j():i;}e.exports=k;},null); + __d("UserAgent_DEPRECATED",[],function(a,b,c,d,e,f){var g=false,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;function w(){if(g)return;g=true;var y=navigator.userAgent,z=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(y),aa=/(Mac OS X)|(Windows)|(Linux)/.exec(y);s=/\b(iPhone|iP[ao]d)/.exec(y);t=/\b(iP[ao]d)/.exec(y);q=/Android/i.exec(y);u=/FBAN\/\w+;/i.exec(y);v=/Mobile/i.exec(y);r=!!(/Win64/.exec(y));if(z){h=z[1]?parseFloat(z[1]):(z[5]?parseFloat(z[5]):NaN);if(h&&document&&document.documentMode)h=document.documentMode;var ba=/(?:Trident\/(\d+.\d+))/.exec(y);m=ba?parseFloat(ba[1])+4:h;i=z[2]?parseFloat(z[2]):NaN;j=z[3]?parseFloat(z[3]):NaN;k=z[4]?parseFloat(z[4]):NaN;if(k){z=/(?:Chrome\/(\d+\.\d+))/.exec(y);l=z&&z[1]?parseFloat(z[1]):NaN;}else l=NaN;}else h=i=j=l=k=NaN;if(aa){if(aa[1]){var ca=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(y);n=ca?parseFloat(ca[1].replace('_','.')):true;}else n=false;o=!!aa[2];p=!!aa[3];}else n=o=p=false;}var x={ie:function(){return w()||h;},ieCompatibilityMode:function(){return w()||(m>h);},ie64:function(){return x.ie()&&r;},firefox:function(){return w()||i;},opera:function(){return w()||j;},webkit:function(){return w()||k;},safari:function(){return x.webkit();},chrome:function(){return w()||l;},windows:function(){return w()||o;},osx:function(){return w()||n;},linux:function(){return w()||p;},iphone:function(){return w()||s;},mobile:function(){return w()||(s||t||q||v);},nativeApp:function(){return w()||u;},android:function(){return w()||q;},ipad:function(){return w()||t;}};e.exports=x;},null); + __d("hasNamePropertyBug",["guid","UserAgent_DEPRECATED"],function(a,b,c,d,e,f,g,h){var i=h.ie()?undefined:false;function j(){var l=document.createElement("form"),m=l.appendChild(document.createElement("input"));m.name=g();i=m!==l.elements[m.name];l=m=null;return i;}function k(){return typeof i==='undefined'?j():i;}e.exports=k;},null); __d("wrapFunction",[],function(a,b,c,d,e,f){var g={};function h(i,j,k){j=j||'default';return function(){var l=j in g?g[j](i,k):i;return l.apply(this,arguments);};}h.setWrapper=function(i,j){j=j||'default';g[j]=i;};e.exports=h;},null); __d("DOMEventListener",["wrapFunction"],function(a,b,c,d,e,f,g){var h,i;if(window.addEventListener){h=function(k,l,m){m.wrapper=g(m,'entry','DOMEventListener.add '+l);k.addEventListener(l,m.wrapper,false);};i=function(k,l,m){k.removeEventListener(l,m.wrapper,false);};}else if(window.attachEvent){h=function(k,l,m){m.wrapper=g(m,'entry','DOMEventListener.add '+l);k.attachEvent('on'+l,m.wrapper);};i=function(k,l,m){k.detachEvent('on'+l,m.wrapper);};}else i=h=function(){};var j={add:function(k,l,m){h(k,l,m);return {remove:function(){i(k,l,m);k=null;}};},remove:i};e.exports=j;},null); - __d("sdk.createIframe",["copyProperties","guid","hasNamePropertyBug","DOMEventListener"],function(a,b,c,d,e,f,g,h,i,j){function k(l){l=g({},l);var m,n=l.name||h(),o=l.root,p=l.style||{border:'none'},q=l.url,r=l.onload;if(i()){m=document.createElement('');j.root.innerHTML=('');k=true;setTimeout(function(){j.root.innerHTML=o;j.root.firstChild.src=j.url;j.onInsert&&j.onInsert(j.root.firstChild);},0);}else{var p=document.createElement('iframe');p.id=j.id;p.name=j.name;p.onload=m;p.scrolling='no';p.style.border='none';p.style.overflow='hidden';if(j.title)p.title=j.title;if(j.className)p.className=j.className;if(j.height!==undefined)p.style.height=j.height+'px';if(j.width!==undefined)if(j.width=='100%'){p.style.width=j.width;}else p.style.width=j.width+'px';j.root.appendChild(p);k=true;p.src=j.url;j.onInsert&&j.onInsert(p);}}e.exports=i;},null); + __d("Miny",[],function(a,b,c,d,e,f){var g='Miny1',h={encode:[],decode:{}},i='wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'.split('');function j(n){for(var o=h.encode.length;o=l)o[k in o?k:'log'](n);}var j={level:-1,Level:h,debug:ES5(i,'bind',true,null,'debug',h.DEBUG),info:ES5(i,'bind',true,null,'info',h.INFO),warn:ES5(i,'bind',true,null,'warn',h.WARNING),error:ES5(i,'bind',true,null,'error',h.ERROR)};e.exports=j;},null); - __d("Base64",[],function(a,b,c,d,e,f){var g='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';function h(l){l=(l.charCodeAt(0)<<16)|(l.charCodeAt(1)<<8)|l.charCodeAt(2);return String.fromCharCode(g.charCodeAt(l>>>18),g.charCodeAt((l>>>12)&63),g.charCodeAt((l>>>6)&63),g.charCodeAt(l&63));}var i='>___?456789:;<=_______'+'\0\1\2\3\4\5\6\7\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31'+'______\32\33\34\35\36\37 !"#$%&\'()*+,-./0123';function j(l){l=(i.charCodeAt(l.charCodeAt(0)-43)<<18)|(i.charCodeAt(l.charCodeAt(1)-43)<<12)|(i.charCodeAt(l.charCodeAt(2)-43)<<6)|i.charCodeAt(l.charCodeAt(3)-43);return String.fromCharCode(l>>>16,(l>>>8)&255,l&255);}var k={encode:function(l){l=unescape(encodeURI(l));var m=(l.length+2)%3;l=(l+'\0\0'.slice(m)).replace(/[\s\S]{3}/g,h);return l.slice(0,l.length+m-2)+'=='.slice(m);},decode:function(l){l=l.replace(/[^A-Za-z0-9+\/]/g,'');var m=(l.length+3)&3;l=(l+'AAA'.slice(m)).replace(/..../g,j);l=l.slice(0,l.length+m-3);try{return decodeURIComponent(escape(l));}catch(n){throw new Error('Not valid UTF-8');}},encodeObject:function(l){return k.encode(ES5('JSON','stringify',false,l));},decodeObject:function(l){return ES5('JSON','parse',false,k.decode(l));},encodeNums:function(l){return String.fromCharCode.apply(String,ES5(l,'map',true,function(m){return g.charCodeAt((m|-(m>63))&-(m>0)&63);}));}};e.exports=k;},null); + __d("sdk.Impressions",["sdk.Content","guid","insertIframe","Miny","QueryString","sdk.Runtime","UrlMap"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){function n(p){var q=l.getClientID();if(!p.api_key&&q)p.api_key=q;p.kid_directed_site=l.getKidDirectedSite();var r=m.resolve('www',true)+'/impression.php/'+h()+'/',s=k.appendToUrl(r,p);if(s.length>2000)if(p.payload&&typeof p.payload==='string'){var t=j.encode(p.payload);if(t&&t.length>>18),g.charCodeAt((l>>>12)&63),g.charCodeAt((l>>>6)&63),g.charCodeAt(l&63));}var i='>___?456789:;<=_______'+'\0\1\2\3\4\5\6\7\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31'+'______\32\33\34\35\36\37 !"#$%&\'()*+,-./0123';function j(l){l=(i.charCodeAt(l.charCodeAt(0)-43)<<18)|(i.charCodeAt(l.charCodeAt(1)-43)<<12)|(i.charCodeAt(l.charCodeAt(2)-43)<<6)|i.charCodeAt(l.charCodeAt(3)-43);return String.fromCharCode(l>>>16,(l>>>8)&255,l&255);}var k={encode:function(l){l=unescape(encodeURI(l));var m=(l.length+2)%3;l=(l+'\0\0'.slice(m)).replace(/[\s\S]{3}/g,h);return l.slice(0,l.length+m-2)+'=='.slice(m);},decode:function(l){l=l.replace(/[^A-Za-z0-9+\/]/g,'');var m=(l.length+3)&3;l=(l+'AAA'.slice(m)).replace(/..../g,j);l=l.slice(0,l.length+m-3);try{return decodeURIComponent(escape(l));}catch(n){throw new Error('Not valid UTF-8');}},encodeObject:function(l){return k.encode(ES('JSON','stringify',false,l));},decodeObject:function(l){return ES('JSON','parse',false,k.decode(l));},encodeNums:function(l){return String.fromCharCode.apply(String,ES(l,'map',true,function(m){return g.charCodeAt((m|-(m>63))&-(m>0)&63);}));}};e.exports=k;},null); __d("sdk.SignedRequest",["Base64"],function(a,b,c,d,e,f,g){function h(j){if(!j)return null;var k=j.split('.',2)[1].replace(/\-/g,'+').replace(/\_/g,'/');return g.decodeObject(k);}var i={parse:h};e.exports=i;},null); - __d("URIRFC3986",[],function(a,b,c,d,e,f){var g=new RegExp('^'+'([^:/?#]+:)?'+'(//'+'([^\\\\/?#@]*@)?'+'('+'\\[[A-Fa-f0-9:.]+\\]|'+'[^\\/?#:]*'+')'+'(:[0-9]*)?'+')?'+'([^?#]*)'+'(\\?[^#]*)?'+'(#.*)?'),h={parse:function(i){if(ES5(i,'trim',true)==='')return null;var j=i.match(g),k={};k.uri=j[0]?j[0]:null;k.scheme=j[1]?j[1].substr(0,j[1].length-1):null;k.authority=j[2]?j[2].substr(2):null;k.userinfo=j[3]?j[3].substr(0,j[3].length-1):null;k.host=j[2]?j[4]:null;k.port=j[5]?(j[5].substr(1)?parseInt(j[5].substr(1),10):null):null;k.path=j[6]?j[6]:null;k.query=j[7]?j[7].substr(1):null;k.fragment=j[8]?j[8].substr(1):null;k.isGenericURI=k.authority===null&&!!k.scheme;return k;}};e.exports=h;},null); - __d("createObjectFrom",[],function(a,b,c,d,e,f){function g(h,i){var j={},k=ES5('Array','isArray',false,i);if(typeof i=='undefined')i=true;for(var l=h.length;l--;)j[h[l]]=k?i[l]:i;return j;}e.exports=g;},null); + __d("URIRFC3986",[],function(a,b,c,d,e,f){var g=new RegExp('^'+'([^:/?#]+:)?'+'(//'+'([^\\\\/?#@]*@)?'+'('+'\\[[A-Fa-f0-9:.]+\\]|'+'[^\\/?#:]*'+')'+'(:[0-9]*)?'+')?'+'([^?#]*)'+'(\\?[^#]*)?'+'(#.*)?'),h={parse:function(i){if(ES(i,'trim',true)==='')return null;var j=i.match(g),k={};k.uri=j[0]?j[0]:null;k.scheme=j[1]?j[1].substr(0,j[1].length-1):null;k.authority=j[2]?j[2].substr(2):null;k.userinfo=j[3]?j[3].substr(0,j[3].length-1):null;k.host=j[2]?j[4]:null;k.port=j[5]?(j[5].substr(1)?parseInt(j[5].substr(1),10):null):null;k.path=j[6]?j[6]:null;k.query=j[7]?j[7].substr(1):null;k.fragment=j[8]?j[8].substr(1):null;k.isGenericURI=k.authority===null&&!!k.scheme;return k;}};e.exports=h;},null); + __d("createObjectFrom",[],function(a,b,c,d,e,f){function g(h,i){var j={},k=ES('Array','isArray',false,i);if(typeof i=='undefined')i=true;for(var l=h.length;l--;)j[h[l]]=k?i[l]:i;return j;}e.exports=g;},null); __d("URISchemes",["createObjectFrom"],function(a,b,c,d,e,f,g){var h=g(['fb','fbcf','fbconnect','fb-messenger','fbrpc','file','ftp','http','https','mailto','ms-app','itms','itms-apps','itms-services','market','svn+ssh','fbstaging','tel','sms']),i={isAllowed:function(j){if(!j)return true;return h.hasOwnProperty(j.toLowerCase());}};e.exports=i;},null); - __d("eprintf",[],function(a,b,c,d,e,f){var g=function(h){var i=ES5(Array.prototype.slice.call(arguments),'map',true,function(l){return String(l);}),j=h.split('%s').length-1;if(j!==i.length-1)return g('eprintf args number mismatch: %s',ES5('JSON','stringify',false,i));var k=1;return h.replace(/%s/g,function(l){return String(i[k++]);});};e.exports=g;},null); - __d("ex",["eprintf"],function(a,b,c,d,e,f,g){var h=function(){var i=Array.prototype.slice.call(arguments,0);i=ES5(i,'map',true,function(j){return String(j);});if(i[0].split('%s').length!==i.length)return h('ex args number mismatch: %s',ES5('JSON','stringify',false,i));return h._prefix+ES5('JSON','stringify',false,i)+h._suffix;};h._prefix='';e.exports=h;},null); - __d("invariant",[],function(a,b,c,d,e,f){"use strict";var g=function(h){if(!h){var i=new Error('Minified exception occured; use the non-minified dev environment for '+'the full error message and additional helpful warnings.');i.framesToPop=1;throw i;}};e.exports=g;},null); - __d("URIBase",["URIRFC3986","URISchemes","copyProperties","ex","invariant"],function(a,b,c,d,e,f,g,h,i,j,k){var l=new RegExp('[\\x00-\\x2c\\x2f\\x3b-\\x40\\x5c\\x5e\\x60\\x7b-\\x7f'+'\\uFDD0-\\uFDEF\\uFFF0-\\uFFFF'+'\\u2047\\u2048\\uFE56\\uFE5F\\uFF03\\uFF0F\\uFF1F]'),m=new RegExp('^(?:[^/]*:|'+'[\\x00-\\x1f]*/[\\x00-\\x1f]*/)');function n(p,q,r,s){if(!q)return true;if(q instanceof o){p.setProtocol(q.getProtocol());p.setDomain(q.getDomain());p.setPort(q.getPort());p.setPath(q.getPath());p.setQueryData(s.deserialize(s.serialize(q.getQueryData())));p.setFragment(q.getFragment());return true;}q=ES5(q.toString(),'trim',true);var t=g.parse(q)||{};if(!r&&!h.isAllowed(t.scheme))return false;p.setProtocol(t.scheme||'');if(!r&&l.test(t.host))return false;p.setDomain(t.host||'');p.setPort(t.port||'');p.setPath(t.path||'');if(r){p.setQueryData(s.deserialize(t.query)||{});}else try{p.setQueryData(s.deserialize(t.query)||{});}catch(u){return false;}p.setFragment(t.fragment||'');if(t.userinfo!==null)if(r){throw new Error(j('URI.parse: invalid URI (userinfo is not allowed in a URI): %s',p.toString()));}else return false;if(!p.getDomain()&&ES5(p.getPath(),'indexOf',true,'\\')!==-1)if(r){throw new Error(j('URI.parse: invalid URI (no domain but multiple back-slashes): %s',p.toString()));}else return false;if(!p.getProtocol()&&m.test(q))if(r){throw new Error(j('URI.parse: invalid URI (unsafe protocol-relative URLs): %s',p.toString()));}else return false;return true;}function o(p,q){"use strict";k(q);this.$URIBase0=q;this.$URIBase1='';this.$URIBase2='';this.$URIBase3='';this.$URIBase4='';this.$URIBase5='';this.$URIBase6={};n(this,p,true,q);}o.prototype.setProtocol=function(p){"use strict";k(h.isAllowed(p));this.$URIBase1=p;return this;};o.prototype.getProtocol=function(p){"use strict";return this.$URIBase1;};o.prototype.setSecure=function(p){"use strict";return this.setProtocol(p?'https':'http');};o.prototype.isSecure=function(){"use strict";return this.getProtocol()==='https';};o.prototype.setDomain=function(p){"use strict";if(l.test(p))throw new Error(j('URI.setDomain: unsafe domain specified: %s for url %s',p,this.toString()));this.$URIBase2=p;return this;};o.prototype.getDomain=function(){"use strict";return this.$URIBase2;};o.prototype.setPort=function(p){"use strict";this.$URIBase3=p;return this;};o.prototype.getPort=function(){"use strict";return this.$URIBase3;};o.prototype.setPath=function(p){"use strict";this.$URIBase4=p;return this;};o.prototype.getPath=function(){"use strict";return this.$URIBase4;};o.prototype.addQueryData=function(p,q){"use strict";if(Object.prototype.toString.call(p)==='[object Object]'){i(this.$URIBase6,p);}else this.$URIBase6[p]=q;return this;};o.prototype.setQueryData=function(p){"use strict";this.$URIBase6=p;return this;};o.prototype.getQueryData=function(){"use strict";return this.$URIBase6;};o.prototype.removeQueryData=function(p){"use strict";if(!ES5('Array','isArray',false,p))p=[p];for(var q=0,r=p.length;q0||this.getFragment());};o.prototype.toString=function(){"use strict";var p='';if(this.$URIBase1)p+=this.$URIBase1+'://';if(this.$URIBase2)p+=this.$URIBase2;if(this.$URIBase3)p+=':'+this.$URIBase3;if(this.$URIBase4){p+=this.$URIBase4;}else if(p)p+='/';var q=this.$URIBase0.serialize(this.$URIBase6);if(q)p+='?'+q;if(this.$URIBase5)p+='#'+this.$URIBase5;return p;};o.prototype.getOrigin=function(){"use strict";return this.$URIBase1+'://'+this.$URIBase2+(this.$URIBase3?':'+this.$URIBase3:'');};o.isValidURI=function(p,q){return n(new o(null,q),p,false,q);};e.exports=o;},null); - __d("sdk.URI",["Assert","QueryString","URIBase"],function(a,b,c,d,e,f,g,h,i){var j=/\.facebook\.com$/,k={serialize:function(o){return o?h.encode(o):'';},deserialize:function(o){return o?h.decode(o):{};}};for(var l in i)if(i.hasOwnProperty(l))n[l]=i[l];var m=i===null?null:i.prototype;n.prototype=ES5('Object','create',false,m);n.prototype.constructor=n;n.__superConstructor__=i;function n(o){"use strict";g.isString(o,'The passed argument was of invalid type.');if(!(this instanceof n))return new n(o);i.call(this,o,k);}n.prototype.isFacebookURI=function(){"use strict";return j.test(this.getDomain());};n.prototype.valueOf=function(){"use strict";return this.toString();};e.exports=n;},null); - __d("sdk.domReady",[],function(a,b,c,d,e,f){var g,h="readyState" in document?/loaded|complete/.test(document.readyState):!!document.body;function i(){if(!g)return;var l;while(l=g.shift())l();g=null;}function j(l){if(g){g.push(l);return;}else l();}if(!h){g=[];if(document.addEventListener){document.addEventListener('DOMContentLoaded',i,false);window.addEventListener('load',i,false);}else if(document.attachEvent){document.attachEvent('onreadystatechange',i);window.attachEvent('onload',i);}if(document.documentElement.doScroll&&window==window.top){var k=function(){try{document.documentElement.doScroll('left');}catch(l){setTimeout(k,0);return;}i();};k();}}e.exports=j;},3); - __d("sdk.Content",["sdk.domReady","Log","UserAgent"],function(a,b,c,d,e,f,g,h,i){var j,k,l={append:function(m,n){if(!n)if(!j){j=n=document.getElementById('fb-root');if(!n){h.warn('The "fb-root" div has not been created, auto-creating');j=n=document.createElement('div');n.id='fb-root';if(i.ie()||!document.body){g(function(){document.body.appendChild(n);});}else document.body.appendChild(n);}n.className+=' fb_reset';}else n=j;if(typeof m=='string'){var o=document.createElement('div');n.appendChild(o).innerHTML=m;return o;}else return n.appendChild(m);},appendHidden:function(m){if(!n){var n=document.createElement('div'),o=n.style;o.position='absolute';o.top='-10000px';o.width=o.height=0;n=l.append(n);}return l.append(m,n);},submitToTarget:function(m,n){var o=document.createElement('form');o.action=m.url;o.target=m.target;o.method=(n)?'GET':'POST';l.appendHidden(o);for(var p in m.params)if(m.params.hasOwnProperty(p)){var q=m.params[p];if(q!==null&&q!==undefined){var r=document.createElement('input');r.name=p;r.value=q;o.appendChild(r);}}o.submit();o.parentNode.removeChild(o);}};e.exports=l;},null); - __d("sdk.Event",[],function(a,b,c,d,e,f){var g={subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(h,i){var j=this.subscribers();if(!j[h]){j[h]=[i];}else j[h].push(i);},unsubscribe:function(h,i){var j=this.subscribers()[h];if(j)ES5(j,'forEach',true,function(k,l){if(k==i)j[l]=null;});},monitor:function(h,i){if(!i()){var j=this,k=function(){if(i.apply(i,arguments))j.unsubscribe(h,k);};this.subscribe(h,k);}},clear:function(h){delete this.subscribers()[h];},fire:function(h){var i=Array.prototype.slice.call(arguments,1),j=this.subscribers()[h];if(j)ES5(j,'forEach',true,function(k){if(k)k.apply(this,i);});}};e.exports=g;},null); - __d("Queue",["copyProperties"],function(a,b,c,d,e,f,g){var h={};function i(j){"use strict";this._opts=g({interval:0,processor:null},j);this._queue=[];this._stopped=true;}i.prototype._dispatch=function(j){"use strict";if(this._stopped||this._queue.length===0)return;if(!this._opts.processor){this._stopped=true;throw new Error('No processor available');}if(this._opts.interval){this._opts.processor.call(this,this._queue.shift());this._timeout=setTimeout(ES5(this._dispatch,'bind',true,this),this._opts.interval);}else while(this._queue.length)this._opts.processor.call(this,this._queue.shift());};i.prototype.enqueue=function(j){"use strict";if(this._opts.processor&&!this._stopped){this._opts.processor.call(this,j);}else this._queue.push(j);return this;};i.prototype.start=function(j){"use strict";if(j)this._opts.processor=j;this._stopped=false;this._dispatch();return this;};i.prototype.isStarted=function(){"use strict";return !this._stopped;};i.prototype.dispatch=function(){"use strict";this._dispatch(true);};i.prototype.stop=function(j){"use strict";this._stopped=true;if(j)clearTimeout(this._timeout);return this;};i.prototype.merge=function(j,k){"use strict";this._queue[k?'unshift':'push'].apply(this._queue,j._queue);j._queue=[];this._dispatch();return this;};i.prototype.getLength=function(){"use strict";return this._queue.length;};i.get=function(j,k){"use strict";var l;if(j in h){l=h[j];}else l=h[j]=new i(k);return l;};i.exists=function(j){"use strict";return j in h;};i.remove=function(j){"use strict";return delete h[j];};e.exports=i;},null); - __d("JSONRPC",["copyProperties","Log"],function(a,b,c,d,e,f,g,h){function i(j){this._counter=0;this._callbacks={};this.remote=ES5(function(k){this._context=k;return this.remote;},'bind',true,this);this.local={};this._write=j;}g(i.prototype,{stub:function(j){this.remote[j]=ES5(function(){var k=Array.prototype.slice.call(arguments),l={jsonrpc:'2.0',method:j};if(typeof k[k.length-1]=='function'){l.id=++this._counter;this._callbacks[l.id]=k.pop();}l.params=k;this._write(ES5('JSON','stringify',false,l),this._context||{method:j});},'bind',true,this);},read:function(j,k){var l=ES5('JSON','parse',false,j),m=l.id;if(!l.method){if(!this._callbacks[m]){h.warn('Could not find callback %s',m);return;}var n=this._callbacks[m];delete this._callbacks[m];delete l.id;delete l.jsonrpc;n(l);return;}var o=this,p=this.local[l.method],q;if(m){q=function(t,u){var v={jsonrpc:'2.0',id:m};v[t]=u;setTimeout(function(){o._write(ES5('JSON','stringify',false,v),k);},0);};}else q=function(){};if(!p){h.error('Method "%s" has not been defined',l.method);q('error',{code:-32601,message:'Method not found',data:l.method});return;}l.params.push(ES5(q,'bind',true,null,'result'));l.params.push(ES5(q,'bind',true,null,'error'));try{var s=p.apply(k||null,l.params);if(typeof s!=='undefined')q('result',s);}catch(r){h.error('Invokation of RPC method %s resulted in the error: %s',l.method,r.message);q('error',{code:-32603,message:'Internal error',data:r.message});}}});e.exports=i;},null); - __d("sdk.RPC",["Assert","JSONRPC","Queue"],function(a,b,c,d,e,f,g,h,i){var j=new i(),k=new h(function(m){j.enqueue(m);}),l={local:k.local,remote:k.remote,stub:ES5(k.stub,'bind',true,k),setInQueue:function(m){g.isInstanceOf(i,m);m.start(function(n){k.read(n);});},getOutQueue:function(){return j;}};e.exports=l;},null); - __d("sdk.Scribe",["QueryString","sdk.Runtime","UrlMap"],function(a,b,c,d,e,f,g,h,i){function j(l,m){if(typeof m.extra=='object')m.extra.revision=h.getRevision();(new Image()).src=g.appendToUrl(i.resolve('www',true)+'/common/scribe_endpoint.php',{c:l,m:ES5('JSON','stringify',false,m)});}var k={log:j};e.exports=k;},null); + __d("copyProperties",[],function(a,b,c,d,e,f){function g(h,i,j,k,l,m,n){h=h||{};var o=[i,j,k,l,m],p=0,q;while(o[p]){q=o[p++];for(var r in q)h[r]=q[r];if(q.hasOwnProperty&&q.hasOwnProperty('toString')&&(typeof q.toString!='undefined')&&(h.toString!==q.toString))h.toString=q.toString;}return h;}e.exports=g;},null); + __d("eprintf",[],function(a,b,c,d,e,f){var g=function(h){var i=ES(Array.prototype.slice.call(arguments),'map',true,function(l){return String(l);}),j=h.split('%s').length-1;if(j!==i.length-1)return g('eprintf args number mismatch: %s',ES('JSON','stringify',false,i));var k=1;return h.replace(/%s/g,function(l){return String(i[k++]);});};e.exports=g;},null); + __d("ex",["eprintf"],function(a,b,c,d,e,f,g){var h=function(){var i=Array.prototype.slice.call(arguments,0);i=ES(i,'map',true,function(j){return String(j);});if(i[0].split('%s').length!==i.length)return h('ex args number mismatch: %s',ES('JSON','stringify',false,i));return h._prefix+ES('JSON','stringify',false,i)+h._suffix;};h._prefix='';e.exports=h;},null); + __d("invariant",[],function(a,b,c,d,e,f){"use strict";var g=function(h,i,j,k,l,m,n,o){if(!h){var p;if(i===undefined){p=new Error('Minified exception occurred; use the non-minified dev environment '+'for the full error message and additional helpful warnings.');}else{var q=[j,k,l,m,n,o],r=0;p=new Error('Invariant Violation: '+i.replace(/%s/g,function(){return q[r++];}));}p.framesToPop=1;throw p;}};e.exports=g;},null); + __d("URIBase",["URIRFC3986","URISchemes","copyProperties","ex","invariant"],function(a,b,c,d,e,f,g,h,i,j,k){var l=new RegExp('[\\x00-\\x2c\\x2f\\x3b-\\x40\\x5c\\x5e\\x60\\x7b-\\x7f'+'\\uFDD0-\\uFDEF\\uFFF0-\\uFFFF'+'\\u2047\\u2048\\uFE56\\uFE5F\\uFF03\\uFF0F\\uFF1F]'),m=new RegExp('^(?:[^/]*:|'+'[\\x00-\\x1f]*/[\\x00-\\x1f]*/)');function n(p,q,r,s){if(!q)return true;if(q instanceof o){p.setProtocol(q.getProtocol());p.setDomain(q.getDomain());p.setPort(q.getPort());p.setPath(q.getPath());p.setQueryData(s.deserialize(s.serialize(q.getQueryData())));p.setFragment(q.getFragment());p.setForceFragmentSeparator(q.getForceFragmentSeparator());return true;}q=ES(q.toString(),'trim',true);var t=g.parse(q)||{};if(!r&&!h.isAllowed(t.scheme))return false;p.setProtocol(t.scheme||'');if(!r&&l.test(t.host))return false;p.setDomain(t.host||'');p.setPort(t.port||'');p.setPath(t.path||'');if(r){p.setQueryData(s.deserialize(t.query)||{});}else try{p.setQueryData(s.deserialize(t.query)||{});}catch(u){return false;}p.setFragment(t.fragment||'');if(t.fragment==='')p.setForceFragmentSeparator(true);if(t.userinfo!==null)if(r){throw new Error(j('URI.parse: invalid URI (userinfo is not allowed in a URI): %s',p.toString()));}else return false;if(!p.getDomain()&&ES(p.getPath(),'indexOf',true,'\\')!==-1)if(r){throw new Error(j('URI.parse: invalid URI (no domain but multiple back-slashes): %s',p.toString()));}else return false;if(!p.getProtocol()&&m.test(q))if(r){throw new Error(j('URI.parse: invalid URI (unsafe protocol-relative URLs): %s',p.toString()));}else return false;return true;}function o(p,q){"use strict";k(q);this.$URIBase0=q;this.$URIBase1='';this.$URIBase2='';this.$URIBase3='';this.$URIBase4='';this.$URIBase5='';this.$URIBase6={};this.$URIBase7=false;n(this,p,true,q);}o.prototype.setProtocol=function(p){"use strict";k(h.isAllowed(p));this.$URIBase1=p;return this;};o.prototype.getProtocol=function(p){"use strict";return this.$URIBase1;};o.prototype.setSecure=function(p){"use strict";return this.setProtocol(p?'https':'http');};o.prototype.isSecure=function(){"use strict";return this.getProtocol()==='https';};o.prototype.setDomain=function(p){"use strict";if(l.test(p))throw new Error(j('URI.setDomain: unsafe domain specified: %s for url %s',p,this.toString()));this.$URIBase2=p;return this;};o.prototype.getDomain=function(){"use strict";return this.$URIBase2;};o.prototype.setPort=function(p){"use strict";this.$URIBase3=p;return this;};o.prototype.getPort=function(){"use strict";return this.$URIBase3;};o.prototype.setPath=function(p){"use strict";this.$URIBase4=p;return this;};o.prototype.getPath=function(){"use strict";return this.$URIBase4;};o.prototype.addQueryData=function(p,q){"use strict";if(Object.prototype.toString.call(p)==='[object Object]'){i(this.$URIBase6,p);}else this.$URIBase6[p]=q;return this;};o.prototype.setQueryData=function(p){"use strict";this.$URIBase6=p;return this;};o.prototype.getQueryData=function(){"use strict";return this.$URIBase6;};o.prototype.removeQueryData=function(p){"use strict";if(!ES('Array','isArray',false,p))p=[p];for(var q=0,r=p.length;q0||this.getFragment());};o.prototype.toString=function(){"use strict";var p='';if(this.$URIBase1)p+=this.$URIBase1+'://';if(this.$URIBase2)p+=this.$URIBase2;if(this.$URIBase3)p+=':'+this.$URIBase3;if(this.$URIBase4){p+=this.$URIBase4;}else if(p)p+='/';var q=this.$URIBase0.serialize(this.$URIBase6);if(q)p+='?'+q;if(this.$URIBase5){p+='#'+this.$URIBase5;}else if(this.$URIBase7)p+='#';return p;};o.prototype.getOrigin=function(){"use strict";return this.$URIBase1+'://'+this.$URIBase2+(this.$URIBase3?':'+this.$URIBase3:'');};o.isValidURI=function(p,q){return n(new o(null,q),p,false,q);};e.exports=o;},null); + __d("sdk.URI",["Assert","QueryString","URIBase"],function(a,b,c,d,e,f,g,h,i){var j=/\.facebook\.com$/,k={serialize:function(o){return o?h.encode(o):'';},deserialize:function(o){return o?h.decode(o):{};}};for(var l in i)if(i.hasOwnProperty(l))n[l]=i[l];var m=i===null?null:i.prototype;n.prototype=ES('Object','create',false,m);n.prototype.constructor=n;n.__superConstructor__=i;function n(o){"use strict";g.isString(o,'The passed argument was of invalid type.');if(!(this instanceof n))return new n(o);i.call(this,o,k);}n.prototype.isFacebookURI=function(){"use strict";return j.test(this.getDomain());};n.prototype.valueOf=function(){"use strict";return this.toString();};e.exports=n;},null); + __d("sdk.Event",[],function(a,b,c,d,e,f){var g={SUBSCRIBE:'event.subscribe',UNSUBSCRIBE:'event.unsubscribe',subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(h,i){var j=this.subscribers();if(!j[h]){j[h]=[i];}else if(ES(j[h],'indexOf',true,i)==-1)j[h].push(i);if(h!=this.SUBSCRIBE&&h!=this.UNSUBSCRIBE)this.fire(this.SUBSCRIBE,h,j[h]);},unsubscribe:function(h,i){var j=this.subscribers()[h];if(j)ES(j,'forEach',true,function(k,l){if(k==i)j.splice(l,1);});if(h!=this.SUBSCRIBE&&h!=this.UNSUBSCRIBE)this.fire(this.UNSUBSCRIBE,h,j);},monitor:function(h,i){if(!i()){var j=this,k=function(){if(i.apply(i,arguments))j.unsubscribe(h,k);};this.subscribe(h,k);}},clear:function(h){delete this.subscribers()[h];},fire:function(h){var i=Array.prototype.slice.call(arguments,1),j=this.subscribers()[h];if(j)ES(j,'forEach',true,function(k){if(k)k.apply(this,i);});}};e.exports=g;},null); + __d("Queue",["copyProperties"],function(a,b,c,d,e,f,g){var h={};function i(j){"use strict";this._opts=g({interval:0,processor:null},j);this._queue=[];this._stopped=true;}i.prototype._dispatch=function(j){"use strict";if(this._stopped||this._queue.length===0)return;if(!this._opts.processor){this._stopped=true;throw new Error('No processor available');}if(this._opts.interval){this._opts.processor.call(this,this._queue.shift());this._timeout=setTimeout(ES(this._dispatch,'bind',true,this),this._opts.interval);}else while(this._queue.length)this._opts.processor.call(this,this._queue.shift());};i.prototype.enqueue=function(j){"use strict";if(this._opts.processor&&!this._stopped){this._opts.processor.call(this,j);}else this._queue.push(j);return this;};i.prototype.start=function(j){"use strict";if(j)this._opts.processor=j;this._stopped=false;this._dispatch();return this;};i.prototype.isStarted=function(){"use strict";return !this._stopped;};i.prototype.dispatch=function(){"use strict";this._dispatch(true);};i.prototype.stop=function(j){"use strict";this._stopped=true;if(j)clearTimeout(this._timeout);return this;};i.prototype.merge=function(j,k){"use strict";this._queue[k?'unshift':'push'].apply(this._queue,j._queue);j._queue=[];this._dispatch();return this;};i.prototype.getLength=function(){"use strict";return this._queue.length;};i.get=function(j,k){"use strict";var l;if(j in h){l=h[j];}else l=h[j]=new i(k);return l;};i.exists=function(j){"use strict";return j in h;};i.remove=function(j){"use strict";return delete h[j];};e.exports=i;},null); + __d("JSONRPC",["Log"],function(a,b,c,d,e,f,g){function h(i){"use strict";this.$JSONRPC0=0;this.$JSONRPC1={};this.remote=ES(function(j){this.$JSONRPC2=j;return this.remote;},'bind',true,this);this.local={};this.$JSONRPC3=i;}h.prototype.stub=function(i){"use strict";this.remote[i]=ES(function(){var j=Array.prototype.slice.call(arguments,0),k={jsonrpc:'2.0',method:i};if(typeof j[j.length-1]=='function'){k.id=++this.$JSONRPC0;this.$JSONRPC1[k.id]=j.pop();}k.params=j;this.$JSONRPC3(ES('JSON','stringify',false,k),this.$JSONRPC2||{method:i});},'bind',true,this);};h.prototype.read=function(i,j){"use strict";var k=ES('JSON','parse',false,i),l=k.id;if(!k.method){if(!this.$JSONRPC1[l]){g.warn('Could not find callback %s',l);return;}var m=this.$JSONRPC1[l];delete this.$JSONRPC1[l];delete k.id;delete k.jsonrpc;m(k);return;}var n=this,o=this.local[k.method],p;if(l){p=function(s,t){var u={jsonrpc:'2.0',id:l};u[s]=t;setTimeout(function(){n.$JSONRPC3(ES('JSON','stringify',false,u),j);},0);};}else p=function(){};if(!o){g.error('Method "%s" has not been defined',k.method);p('error',{code:-32601,message:'Method not found',data:k.method});return;}k.params.push(ES(p,'bind',true,null,'result'));k.params.push(ES(p,'bind',true,null,'error'));try{var r=o.apply(j||null,k.params);if(typeof r!=='undefined')p('result',r);}catch(q){g.error('Invokation of RPC method %s resulted in the error: %s',k.method,q.message);p('error',{code:-32603,message:'Internal error',data:q.message});}};e.exports=h;},null); + __d("sdk.RPC",["Assert","JSONRPC","Queue"],function(a,b,c,d,e,f,g,h,i){var j=new i(),k=new h(function(m){j.enqueue(m);}),l={local:k.local,remote:k.remote,stub:ES(k.stub,'bind',true,k),setInQueue:function(m){g.isInstanceOf(i,m);m.start(function(n){k.read(n);});},getOutQueue:function(){return j;}};e.exports=l;},null); + __d("sdk.Scribe",["QueryString","sdk.Runtime","UrlMap"],function(a,b,c,d,e,f,g,h,i){function j(l,m){if(typeof m.extra=='object')m.extra.revision=h.getRevision();(new Image()).src=g.appendToUrl(i.resolve('www',true)+'/common/scribe_endpoint.php',{c:l,m:ES('JSON','stringify',false,m)});}var k={log:j};e.exports=k;},null); __d("emptyFunction",["copyProperties"],function(a,b,c,d,e,f,g){function h(j){return function(){return j;};}function i(){}g(i,{thatReturns:h,thatReturnsFalse:h(false),thatReturnsTrue:h(true),thatReturnsNull:h(null),thatReturnsThis:function(){return this;},thatReturnsArgument:function(j){return j;}});e.exports=i;},null); __d("htmlSpecialChars",[],function(a,b,c,d,e,f){var g=/&/g,h=//g,j=/"/g,k=/'/g;function l(m){if(typeof m=='undefined'||m===null||!m.toString)return '';if(m===false){return '0';}else if(m===true)return '1';return m.toString().replace(g,'&').replace(j,'"').replace(k,''').replace(h,'<').replace(i,'>');}e.exports=l;},null); - __d("Flash",["DOMEventListener","DOMWrapper","QueryString","UserAgent","copyProperties","guid","htmlSpecialChars"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n={},o,p=h.getWindow().document;function q(v){var w=p.getElementById(v);if(w)w.parentNode.removeChild(w);delete n[v];}function r(){for(var v in n)if(n.hasOwnProperty(v))q(v);}function s(v){return v.replace(/\d+/g,function(w){return '000'.substring(w.length)+w;});}function t(v){if(!o){if(j.ie()>=9)g.add(window,'unload',r);o=true;}n[v]=v;}var u={embed:function(v,w,x,y){var z=l();v=m(v).replace(/&/g,'&');x=k({allowscriptaccess:'always',flashvars:y,movie:v},x||{});if(typeof x.flashvars=='object')x.flashvars=i.encode(x.flashvars);var aa=[];for(var ba in x)if(x.hasOwnProperty(ba)&&x[ba])aa.push('');var ca=w.appendChild(p.createElement('span')),da=''+aa.join('')+'';ca.innerHTML=da;var ea=ca.firstChild;t(z);return ea;},remove:q,getVersion:function(){var v='Shockwave Flash',w='application/x-shockwave-flash',x='ShockwaveFlash.ShockwaveFlash',y;if(navigator.plugins&&typeof navigator.plugins[v]=='object'){var z=navigator.plugins[v].description;if(z&&navigator.mimeTypes&&navigator.mimeTypes[w]&&navigator.mimeTypes[w].enabledPlugin)y=z.match(/\d+/g);}if(!y)try{y=(new ActiveXObject(x)).GetVariable('$version').match(/(\d+),(\d+),(\d+),(\d+)/);y=Array.prototype.slice.call(y,1);}catch(aa){}return y;},checkMinVersion:function(v){var w=u.getVersion();if(!w)return false;return s(w.join('.'))>=s(v);},isAvailable:function(){return !!u.getVersion();}};e.exports=u;},null); - __d("dotAccess",[],function(a,b,c,d,e,f){function g(h,i,j){var k=i.split('.');do{var l=k.shift();h=h[l]||j&&(h[l]={});}while(k.length&&h);return h;}e.exports=g;},null); - __d("GlobalCallback",["DOMWrapper","dotAccess","guid","wrapFunction"],function(a,b,c,d,e,f,g,h,i,j){var k,l,m={setPrefix:function(n){k=h(g.getWindow(),n,true);l=n;},create:function(n,o){if(!k)this.setPrefix('__globalCallbacks');var p=i();k[p]=j(n,'entry',o||'GlobalCallback');return l+'.'+p;},remove:function(n){var o=n.substring(l.length+1);delete k[o];}};e.exports=m;},null); - __d("XDM",["DOMEventListener","DOMWrapper","emptyFunction","Flash","GlobalCallback","guid","Log","UserAgent","wrapFunction"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p={},q={transports:[]},r=h.getWindow();function s(u){var v={},w=u.length,x=q.transports;while(w--)v[u[w]]=1;w=x.length;while(w--){var y=x[w],z=p[y];if(!v[y]&&z.isAvailable())return y;}}var t={register:function(u,v){m.debug('Registering %s as XDM provider',u);q.transports.push(u);p[u]=v;},create:function(u){if(!u.whenReady&&!u.onMessage){m.error('An instance without whenReady or onMessage makes no sense');throw new Error('An instance without whenReady or '+'onMessage makes no sense');}if(!u.channel){m.warn('Missing channel name, selecting at random');u.channel=l();}if(!u.whenReady)u.whenReady=i;if(!u.onMessage)u.onMessage=i;var v=u.transport||s(u.blacklist||[]),w=p[v];if(w&&w.isAvailable()){m.debug('%s is available',v);w.init(u);return v;}}};t.register('flash',(function(){var u=false,v,w=false,x=15000,y;return {isAvailable:function(){return j.checkMinVersion('8.0.24');},init:function(z){m.debug('init flash: '+z.channel);var aa={send:function(da,ea,fa,ga){m.debug('sending to: %s (%s)',ea,ga);v.postMessage(da,ea,ga);}};if(u){z.whenReady(aa);return;}var ba=z.root.appendChild(r.document.createElement('div')),ca=k.create(function(){k.remove(ca);clearTimeout(y);m.info('xdm.swf called the callback');var da=k.create(function(ea,fa){ea=decodeURIComponent(ea);fa=decodeURIComponent(fa);m.debug('received message %s from %s',ea,fa);z.onMessage(ea,fa);},'xdm.swf:onMessage');v.init(z.channel,da);z.whenReady(aa);},'xdm.swf:load');v=j.embed(z.flashUrl,ba,null,{protocol:location.protocol.replace(':',''),host:location.host,callback:ca,log:w});y=setTimeout(function(){m.warn('The Flash component did not load within %s ms - '+'verify that the container is not set to hidden or invisible '+'using CSS as this will cause some browsers to not load '+'the components',x);},x);u=true;}};})());t.register('postmessage',(function(){var u=false;return {isAvailable:function(){return !!r.postMessage;},init:function(v){m.debug('init postMessage: '+v.channel);var w='_FB_'+v.channel,x={send:function(y,z,aa,ba){if(r===aa){m.error('Invalid windowref, equal to window (self)');throw new Error();}m.debug('sending to: %s (%s)',z,ba);var ca=function(){aa.postMessage('_FB_'+ba+y,z);};if(n.ie()==8||n.ieCompatibilityMode()){setTimeout(ca,0);}else ca();}};if(u){v.whenReady(x);return;}g.add(r,'message',o(function(event){var y=event.data,z=event.origin||'native';if(!/^(https?:\/\/|native$)/.test(z)){m.debug('Received message from invalid origin type: %s',z);return;}if(typeof y!='string'){m.warn('Received message of type %s from %s, expected a string',typeof y,z);return;}m.debug('received message %s from %s',y,z);if(y.substring(0,w.length)==w)y=y.substring(w.length);v.onMessage(y,z);},'entry','onMessage'));v.whenReady(x);u=true;}};})());e.exports=t;},null); - __d("sdk.XD",["sdk.Content","sdk.Event","Log","QueryString","Queue","sdk.RPC","sdk.Runtime","sdk.Scribe","sdk.URI","UrlMap","JSSDKXDConfig","XDM","sdk.createIframe","sdk.feature","guid"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u){var v=new k(),w=new k(),x=new k(),y,z,aa=u(),ba=q.useCdn?'cdn':'www',ca=t('use_bundle')?q.XdBundleUrl:q.XdUrl,da=p.resolve(ba,false)+ca,ea=p.resolve(ba,true)+ca,fa=u(),ga=location.protocol+'//'+location.host,ha,ia=false,ja='Facebook Cross Domain Communication Frame',ka={},la=new k();l.setInQueue(la);function ma(sa){i.info('Remote XD can talk to facebook.com (%s)',sa);m.setEnvironment(sa==='canvas'?m.ENVIRONMENTS.CANVAS:m.ENVIRONMENTS.PAGETAB);}function na(sa,ta){if(!ta){i.error('No senderOrigin');throw new Error();}var ua=/^https?/.exec(ta)[0];switch(sa.xd_action){case 'proxy_ready':var va,wa;if(ua=='https'){va=x;wa=z;}else{va=w;wa=y;}if(sa.registered){ma(sa.registered);v=va.merge(v);}i.info('Proxy ready, starting queue %s containing %s messages',ua+'ProxyQueue',va.getLength());va.start(function(ya){ha.send(typeof ya==='string'?ya:j.encode(ya),ta,wa.contentWindow,fa+'_'+ua);});break;case 'plugin_ready':i.info('Plugin %s ready, protocol: %s',sa.name,ua);ka[sa.name]={protocol:ua};if(k.exists(sa.name)){var xa=k.get(sa.name);i.debug('Enqueuing %s messages for %s in %s',xa.getLength(),sa.name,ua+'ProxyQueue');(ua=='https'?x:w).merge(xa);}break;}if(sa.data)oa(sa.data,ta);}function oa(sa,ta){if(ta&&ta!=='native'&&!o(ta).isFacebookURI())return;if(typeof sa=='string'){if(/^FB_RPC:/.test(sa)){la.enqueue(sa.substring(7));return;}if(sa.substring(0,1)=='{'){try{sa=ES5('JSON','parse',false,sa);}catch(ua){i.warn('Failed to decode %s as JSON',sa);return;}}else sa=j.decode(sa);}if(!ta)if(sa.xd_sig==aa)ta=sa.xd_origin;if(sa.xd_action){na(sa,ta);return;}if(sa.access_token)m.setSecure(/^https/.test(ga));if(sa.cb){var va=ra._callbacks[sa.cb];if(!ra._forever[sa.cb])delete ra._callbacks[sa.cb];if(va)va(sa);}}function pa(sa,ta){if(sa=='facebook'){ta.relation='parent.parent';v.enqueue(ta);}else{ta.relation='parent.frames["'+sa+'"]';var ua=ka[sa];if(ua){i.debug('Enqueuing message for plugin %s in %s',sa,ua.protocol+'ProxyQueue');(ua.protocol=='https'?x:w).enqueue(ta);}else{i.debug('Buffering message for plugin %s',sa);k.get(sa).enqueue(ta);}}}l.getOutQueue().start(function(sa){pa('facebook','FB_RPC:'+sa);});function qa(sa){if(ia)return;var ta=g.appendHidden(document.createElement('div')),ua=r.create({blacklist:null,root:ta,channel:fa,flashUrl:q.Flash.path,whenReady:function(va){ha=va;var wa={channel:fa,origin:location.protocol+'//'+location.host,transport:ua,xd_name:sa},xa='#'+j.encode(wa);if(m.getSecure()!==true)y=s({url:da+xa,name:'fb_xdm_frame_http',id:'fb_xdm_frame_http',root:ta,'aria-hidden':true,title:ja,tabindex:-1});z=s({url:ea+xa,name:'fb_xdm_frame_https',id:'fb_xdm_frame_https',root:ta,'aria-hidden':true,title:ja,tabindex:-1});},onMessage:oa});if(!ua)n.log('jssdk_error',{appId:m.getClientID(),error:'XD_TRANSPORT',extra:{message:'Failed to create a valid transport'}});ia=true;}var ra={rpc:l,_callbacks:{},_forever:{},_channel:fa,_origin:ga,onMessage:oa,recv:oa,init:qa,sendToFacebook:pa,inform:function(sa,ta,ua,va){pa('facebook',{method:sa,params:ES5('JSON','stringify',false,ta||{}),behavior:va||'p',relation:ua});},handler:function(sa,ta,ua,va){var wa='#'+j.encode({cb:this.registerCallback(sa,ua,va),origin:ga+'/'+fa,domain:location.hostname,relation:ta||'opener'});return (location.protocol=='https:'?ea:da)+wa;},registerCallback:function(sa,ta,ua){ua=ua||u();if(ta)ra._forever[ua]=true;ra._callbacks[ua]=sa;return ua;}};h.subscribe('init:post',function(sa){qa(sa.xdProxyName);var ta=t('xd_timeout');if(ta)setTimeout(function(){var ua=z&&(!!y==w.isStarted()&&!!z==x.isStarted());if(!ua)n.log('jssdk_error',{appId:m.getClientID(),error:'XD_INITIALIZATION',extra:{message:'Failed to initialize in '+ta+'ms'}});},ta);});e.exports=ra;},null); - __d("sdk.Auth",["sdk.Cookie","copyProperties","sdk.createIframe","DOMWrapper","sdk.feature","sdk.getContextType","guid","sdk.Impressions","Log","ObservableMixin","sdk.Runtime","sdk.SignedRequest","UrlMap","sdk.URI","sdk.XD"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u){var v,w,x=new p();function y(ea,fa){var ga=q.getUserID(),ha='';if(ea)if(ea.userID){ha=ea.userID;}else if(ea.signedRequest){var ia=r.parse(ea.signedRequest);if(ia&&ia.user_id)ha=ia.user_id;}var ja=q.getLoginStatus(),ka=(ja==='unknown'&&ea)||(q.getUseCookie()&&q.getCookieUserID()!==ha),la=ga&&!ea,ma=ea&&ga&&ga!=ha,na=ea!=v,oa=fa!=(ja||'unknown');q.setLoginStatus(fa);q.setAccessToken(ea&&ea.accessToken||null);q.setUserID(ha);v=ea;var pa={authResponse:ea,status:fa};if(la||ma)x.inform('logout',pa);if(ka||ma)x.inform('login',pa);if(na)x.inform('authresponse.change',pa);if(oa)x.inform('status.change',pa);return pa;}function z(){return v;}function aa(ea,fa,ga){return function(ha){var ia;if(ha&&ha.access_token){var ja=r.parse(ha.signed_request);fa={accessToken:ha.access_token,userID:ja.user_id,expiresIn:parseInt(ha.expires_in,10),signedRequest:ha.signed_request};if(ha.granted_scopes)fa.grantedScopes=ha.granted_scopes;if(q.getUseCookie()){var ka=fa.expiresIn===0?0:ES5('Date','now',false)+fa.expiresIn*1000,la=g.getDomain();if(!la&&ha.base_domain)g.setDomain('.'+ha.base_domain);g.setSignedRequestCookie(ha.signed_request,ka);}ia='connected';y(fa,ia);}else if(ga==='logout'||ga==='login_status'){if(ha.error&&ha.error==='not_authorized'){ia='not_authorized';}else ia='unknown';y(null,ia);if(q.getUseCookie())g.clearSignedRequestCookie();}if(ha&&ha.https==1)q.setSecure(true);if(ea)ea({authResponse:fa,status:q.getLoginStatus()});return fa;};}function ba(ea){var fa,ga=ES5('Date','now',false);if(w){clearTimeout(w);w=null;}var ha=aa(ea,v,'login_status'),ia=t(s.resolve('www',true)+'/connect/ping').setQueryData({client_id:q.getClientID(),response_type:'token,signed_request,code',domain:location.hostname,origin:l(),redirect_uri:u.handler(function(ja){if(k('e2e_ping_tracking',true)){var ka={init:ga,close:ES5('Date','now',false),method:'ping'};o.debug('e2e: %s',ES5('JSON','stringify',false,ka));n.log(114,{payload:ka});}fa.parentNode.removeChild(fa);if(ha(ja))w=setTimeout(function(){ba(function(){});},1200000);},'parent'),sdk:'joey',kid_directed_site:q.getKidDirectedSite()});fa=i({root:j.getRoot(),name:m(),url:ia.toString(),style:{display:'none'}});}var ca;function da(ea,fa){if(!q.getClientID()){o.warn('FB.getLoginStatus() called before calling FB.init().');return;}if(ea)if(!fa&&ca=='loaded'){ea({status:q.getLoginStatus(),authResponse:z()});return;}else x.subscribe('FB.loginStatus',ea);if(!fa&&ca=='loading')return;ca='loading';var ga=function(ha){ca='loaded';x.inform('FB.loginStatus',ha);x.clearSubscribers('FB.loginStatus');};ba(ga);}h(x,{getLoginStatus:da,fetchLoginStatus:ba,setAuthResponse:y,getAuthResponse:z,parseSignedRequest:r.parse,xdResponseWrapper:aa});e.exports=x;},null); - __d("toArray",["invariant"],function(a,b,c,d,e,f,g){function h(i){var j=i.length;g(!ES5('Array','isArray',false,i)&&(typeof i==='object'||typeof i==='function'));g(typeof j==='number');g(j===0||(j-1) in i);if(i.hasOwnProperty)try{return Array.prototype.slice.call(i);}catch(k){}var l=Array(j);for(var m=0;m=0;}function q(z,aa){g.isTruthy(z,'element not specified');g.isString(aa);if(!p(z,aa))z.className=n(z,'className')+' '+aa;}function r(z,aa){g.isTruthy(z,'element not specified');g.isString(aa);var ba=new RegExp('\\s*'+aa,'g');z.className=ES5(n(z,'className').replace(ba,''),'trim',true);}function s(z,aa,ba){g.isString(z);aa=aa||document.body;ba=ba||'*';if(aa.querySelectorAll)return h(aa.querySelectorAll(ba+'.'+z));var ca=aa.getElementsByTagName(ba),da=[];for(var ea=0,fa=ca.length;ea=9)g.add(window,'unload',r);o=true;}n[v]=v;}var u={embed:function(v,w,x,y){var z=l();v=m(v).replace(/&/g,'&');x=k({allowscriptaccess:'always',flashvars:y,movie:v},x||{});if(typeof x.flashvars=='object')x.flashvars=i.encode(x.flashvars);var aa=[];for(var ba in x)if(x.hasOwnProperty(ba)&&x[ba])aa.push('');var ca=w.appendChild(p.createElement('span')),da=''+aa.join('')+'';ca.innerHTML=da;var ea=ca.firstChild;t(z);return ea;},remove:q,getVersion:function(){var v='Shockwave Flash',w='application/x-shockwave-flash',x='ShockwaveFlash.ShockwaveFlash',y;if(navigator.plugins&&typeof navigator.plugins[v]=='object'){var z=navigator.plugins[v].description;if(z&&navigator.mimeTypes&&navigator.mimeTypes[w]&&navigator.mimeTypes[w].enabledPlugin)y=z.match(/\d+/g);}if(!y)try{y=(new ActiveXObject(x)).GetVariable('$version').match(/(\d+),(\d+),(\d+),(\d+)/);y=Array.prototype.slice.call(y,1);}catch(aa){}return y;},checkMinVersion:function(v){var w=u.getVersion();if(!w)return false;return s(w.join('.'))>=s(v);},isAvailable:function(){return !!u.getVersion();}};e.exports=u;},null); + __d("XDM",["DOMEventListener","DOMWrapper","emptyFunction","Flash","GlobalCallback","guid","Log","UserAgent_DEPRECATED","wrapFunction"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p={},q={transports:[]},r=h.getWindow();function s(u){var v={},w=u.length,x=q.transports;while(w--)v[u[w]]=1;w=x.length;while(w--){var y=x[w],z=p[y];if(!v[y]&&z.isAvailable())return y;}}var t={register:function(u,v){m.debug('Registering %s as XDM provider',u);q.transports.push(u);p[u]=v;},create:function(u){if(!u.whenReady&&!u.onMessage){m.error('An instance without whenReady or onMessage makes no sense');throw new Error('An instance without whenReady or '+'onMessage makes no sense');}if(!u.channel){m.warn('Missing channel name, selecting at random');u.channel=l();}if(!u.whenReady)u.whenReady=i;if(!u.onMessage)u.onMessage=i;var v=u.transport||s(u.blacklist||[]),w=p[v];if(w&&w.isAvailable()){m.debug('%s is available',v);w.init(u);return v;}}};t.register('flash',(function(){var u=false,v,w=false,x=15000,y;return {isAvailable:function(){return j.checkMinVersion('8.0.24');},init:function(z){m.debug('init flash: '+z.channel);var aa={send:function(da,ea,fa,ga){m.debug('sending to: %s (%s)',ea,ga);v.postMessage(da,ea,ga);}};if(u){z.whenReady(aa);return;}var ba=z.root.appendChild(r.document.createElement('div')),ca=k.create(function(){k.remove(ca);clearTimeout(y);m.info('xdm.swf called the callback');var da=k.create(function(ea,fa){ea=decodeURIComponent(ea);fa=decodeURIComponent(fa);m.debug('received message %s from %s',ea,fa);z.onMessage(ea,fa);},'xdm.swf:onMessage');v.init(z.channel,da);z.whenReady(aa);},'xdm.swf:load');v=j.embed(z.flashUrl,ba,null,{protocol:location.protocol.replace(':',''),host:location.host,callback:ca,log:w});y=setTimeout(function(){m.warn('The Flash component did not load within %s ms - '+'verify that the container is not set to hidden or invisible '+'using CSS as this will cause some browsers to not load '+'the components',x);},x);u=true;}};})());t.register('postmessage',(function(){var u=false;return {isAvailable:function(){return !!r.postMessage;},init:function(v){m.debug('init postMessage: '+v.channel);var w='_FB_'+v.channel,x={send:function(y,z,aa,ba){if(r===aa){m.error('Invalid windowref, equal to window (self)');throw new Error();}m.debug('sending to: %s (%s)',z,ba);var ca=function(){aa.postMessage('_FB_'+ba+y,z);};if(n.ie()==8||n.ieCompatibilityMode()){setTimeout(ca,0);}else ca();}};if(u){v.whenReady(x);return;}g.add(r,'message',o(function(event){var y=event.data,z=event.origin||'native';if(!/^(https?:\/\/|native$)/.test(z)){m.debug('Received message from invalid origin type: %s',z);return;}if(typeof y!='string'){m.warn('Received message of type %s from %s, expected a string',typeof y,z);return;}m.debug('received message %s from %s',y,z);if(y.substring(0,w.length)==w)y=y.substring(w.length);v.onMessage(y,z);},'entry','onMessage'));v.whenReady(x);u=true;}};})());e.exports=t;},null); + __d("isFacebookURI",[],function(a,b,c,d,e,f){var g=null,h=['http','https'];function i(j){if(!g)g=new RegExp('(^|\\.)facebook\\.com$','i');if(j.isEmpty())return false;if(!j.getDomain()&&!j.getProtocol())return true;return (ES(h,'indexOf',true,j.getProtocol())!==-1&&g.test(j.getDomain()));}e.exports=i;},null); + __d("sdk.XD",["sdk.Content","sdk.Event","Log","QueryString","Queue","sdk.RPC","sdk.Runtime","sdk.Scribe","sdk.URI","UrlMap","JSSDKXDConfig","XDM","isFacebookURI","sdk.createIframe","sdk.feature","guid"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v){var w=new k(),x=new k(),y=new k(),z,aa,ba=v(),ca=q.useCdn?'cdn':'www',da=u('use_bundle')?q.XdBundleUrl:q.XdUrl,ea=p.resolve(ca,false)+da,fa=p.resolve(ca,true)+da,ga=v(),ha=location.protocol+'//'+location.host,ia,ja=false,ka='Facebook Cross Domain Communication Frame',la={},ma=new k();l.setInQueue(ma);function na(ta){i.info('Remote XD can talk to facebook.com (%s)',ta);m.setEnvironment(ta==='canvas'?m.ENVIRONMENTS.CANVAS:m.ENVIRONMENTS.PAGETAB);}function oa(ta,ua){if(!ua){i.error('No senderOrigin');throw new Error();}var va=/^https?/.exec(ua)[0];switch(ta.xd_action){case 'proxy_ready':var wa,xa;if(va=='https'){wa=y;xa=aa;}else{wa=x;xa=z;}if(ta.registered){na(ta.registered);w=wa.merge(w);}i.info('Proxy ready, starting queue %s containing %s messages',va+'ProxyQueue',wa.getLength());wa.start(function(za){ia.send(typeof za==='string'?za:j.encode(za),ua,xa.contentWindow,ga+'_'+va);});break;case 'plugin_ready':i.info('Plugin %s ready, protocol: %s',ta.name,va);la[ta.name]={protocol:va};if(k.exists(ta.name)){var ya=k.get(ta.name);i.debug('Enqueuing %s messages for %s in %s',ya.getLength(),ta.name,va+'ProxyQueue');(va=='https'?y:x).merge(ya);}break;}if(ta.data)pa(ta.data,ua);}function pa(ta,ua){if(ua&&ua!=='native'&&!s(o(ua)))return;if(typeof ta=='string'){if(/^FB_RPC:/.test(ta)){ma.enqueue(ta.substring(7));return;}if(ta.substring(0,1)=='{'){try{ta=ES('JSON','parse',false,ta);}catch(va){i.warn('Failed to decode %s as JSON',ta);return;}}else ta=j.decode(ta);}if(!ua)if(ta.xd_sig==ba)ua=ta.xd_origin;if(ta.xd_action){oa(ta,ua);return;}if(ta.access_token)m.setSecure(/^https/.test(ha));if(ta.cb){var wa=sa._callbacks[ta.cb];if(!sa._forever[ta.cb])delete sa._callbacks[ta.cb];if(wa)wa(ta);}}function qa(ta,ua){if(ta=='facebook'){ua.relation='parent.parent';w.enqueue(ua);}else{ua.relation='parent.frames["'+ta+'"]';var va=la[ta];if(va){i.debug('Enqueuing message for plugin %s in %s',ta,va.protocol+'ProxyQueue');(va.protocol=='https'?y:x).enqueue(ua);}else{i.debug('Buffering message for plugin %s',ta);k.get(ta).enqueue(ua);}}}l.getOutQueue().start(function(ta){qa('facebook','FB_RPC:'+ta);});function ra(ta){if(ja)return;var ua=g.appendHidden(document.createElement('div')),va=r.create({blacklist:null,root:ua,channel:ga,flashUrl:q.Flash.path,whenReady:function(wa){ia=wa;var xa={channel:ga,origin:location.protocol+'//'+location.host,transport:va,xd_name:ta},ya='#'+j.encode(xa);if(m.getSecure()!==true)z=t({url:ea+ya,name:'fb_xdm_frame_http',id:'fb_xdm_frame_http',root:ua,'aria-hidden':true,title:ka,tabindex:-1});aa=t({url:fa+ya,name:'fb_xdm_frame_https',id:'fb_xdm_frame_https',root:ua,'aria-hidden':true,title:ka,tabindex:-1});},onMessage:pa});if(!va)n.log('jssdk_error',{appId:m.getClientID(),error:'XD_TRANSPORT',extra:{message:'Failed to create a valid transport'}});ja=true;}var sa={rpc:l,_callbacks:{},_forever:{},_channel:ga,_origin:ha,onMessage:pa,recv:pa,init:ra,sendToFacebook:qa,inform:function(ta,ua,va,wa){qa('facebook',{method:ta,params:ES('JSON','stringify',false,ua||{}),behavior:wa||'p',relation:va});},handler:function(ta,ua,va,wa){var xa='#'+j.encode({cb:this.registerCallback(ta,va,wa),origin:ha+'/'+ga,domain:location.hostname,relation:ua||'opener'});return (location.protocol=='https:'?fa:ea)+xa;},registerCallback:function(ta,ua,va){va=va||v();if(ua)sa._forever[va]=true;sa._callbacks[va]=ta;return va;}};h.subscribe('init:post',function(ta){ra(ta.xdProxyName);var ua=u('xd_timeout');if(ua)setTimeout(function(){var va=aa&&(!!z==x.isStarted()&&!!aa==y.isStarted());if(!va)n.log('jssdk_error',{appId:m.getClientID(),error:'XD_INITIALIZATION',extra:{message:'Failed to initialize in '+ua+'ms'}});},ua);});e.exports=sa;},null); + __d("sdk.Auth",["sdk.Cookie","sdk.createIframe","DOMWrapper","sdk.feature","sdk.getContextType","guid","sdk.Impressions","Log","ObservableMixin","sdk.Runtime","sdk.SignedRequest","UrlMap","sdk.URI","sdk.XD"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u,v,w=new o();function x(da,ea){var fa=p.getUserID(),ga='';if(da)if(da.userID){ga=da.userID;}else if(da.signedRequest){var ha=q.parse(da.signedRequest);if(ha&&ha.user_id)ga=ha.user_id;}var ia=p.getLoginStatus(),ja=(ia==='unknown'&&da)||(p.getUseCookie()&&p.getCookieUserID()!==ga),ka=fa&&!da,la=da&&fa&&fa!=ga,ma=da!=u,na=ea!=(ia||'unknown');p.setLoginStatus(ea);p.setAccessToken(da&&da.accessToken||null);p.setUserID(ga);u=da;var oa={authResponse:da,status:ea};if(ka||la)w.inform('logout',oa);if(ja||la)w.inform('login',oa);if(ma)w.inform('authresponse.change',oa);if(na)w.inform('status.change',oa);return oa;}function y(){return u;}function z(da,ea,fa){return function(ga){var ha;if(ga&&ga.access_token){var ia=q.parse(ga.signed_request);ea={accessToken:ga.access_token,userID:ia.user_id,expiresIn:parseInt(ga.expires_in,10),signedRequest:ga.signed_request};if(ga.granted_scopes)ea.grantedScopes=ga.granted_scopes;if(p.getUseCookie()){var ja=ea.expiresIn===0?0:ES('Date','now',false)+ea.expiresIn*1000,ka=g.getDomain();if(!ka&&ga.base_domain)g.setDomain('.'+ga.base_domain);g.setSignedRequestCookie(ga.signed_request,ja);}ha='connected';x(ea,ha);}else if(fa==='logout'||fa==='login_status'){if(ga.error&&ga.error==='not_authorized'){ha='not_authorized';}else ha='unknown';x(null,ha);if(p.getUseCookie())g.clearSignedRequestCookie();}if(ga&&ga.https==1)p.setSecure(true);if(da)da({authResponse:ea,status:p.getLoginStatus()});return ea;};}function aa(da){var ea,fa=ES('Date','now',false);if(v){clearTimeout(v);v=null;}var ga=z(da,u,'login_status'),ha=s(r.resolve('www',true)+'/connect/ping').setQueryData({client_id:p.getClientID(),response_type:'token,signed_request,code',domain:location.hostname,origin:k(),redirect_uri:t.handler(function(ia){if(j('e2e_ping_tracking',true)){var ja={init:fa,close:ES('Date','now',false),method:'ping'};n.debug('e2e: %s',ES('JSON','stringify',false,ja));m.log(114,{payload:ja});}ea.parentNode.removeChild(ea);if(ga(ia))v=setTimeout(function(){aa(function(){});},1200000);},'parent'),sdk:'joey',kid_directed_site:p.getKidDirectedSite()});ea=h({root:i.getRoot(),name:l(),url:ha.toString(),style:{display:'none'}});}var ba;function ca(da,ea){if(!p.getClientID()){n.warn('FB.getLoginStatus() called before calling FB.init().');return;}if(da)if(!ea&&ba=='loaded'){da({status:p.getLoginStatus(),authResponse:y()});return;}else w.subscribe('FB.loginStatus',da);if(!ea&&ba=='loading')return;ba='loading';var fa=function(ga){ba='loaded';w.inform('FB.loginStatus',ga);w.clearSubscribers('FB.loginStatus');};aa(fa);}ES('Object','assign',false,w,{getLoginStatus:ca,fetchLoginStatus:aa,setAuthResponse:x,getAuthResponse:y,parseSignedRequest:q.parse,xdResponseWrapper:z});e.exports=w;},null); + __d("toArray",["invariant"],function(a,b,c,d,e,f,g){function h(i){var j=i.length;g(!ES('Array','isArray',false,i)&&(typeof i==='object'||typeof i==='function'));g(typeof j==='number');g(j===0||(j-1) in i);if(i.hasOwnProperty)try{return Array.prototype.slice.call(i);}catch(k){}var l=Array(j);for(var m=0;m=0;}function q(z,aa){g.isTruthy(z,'element not specified');g.isString(aa);if(!p(z,aa))z.className=n(z,'className')+' '+aa;}function r(z,aa){g.isTruthy(z,'element not specified');g.isString(aa);var ba=new RegExp('\\s*'+aa,'g');z.className=ES(n(z,'className').replace(ba,''),'trim',true);}function s(z,aa,ba){g.isString(z);aa=aa||document.body;ba=ba||'*';if(aa.querySelectorAll)return h(aa.querySelectorAll(ba+'.'+z));var ca=aa.getElementsByTagName(ba),da=[];for(var ea=0,fa=ca.length;ea2000){h.remove(n.callback);return false;}p.onerror=function(){q({error:{type:'http',message:'unknown error'}});};var r=function(){setTimeout(function(){q({error:{type:'http',message:'unknown error'}});},0);};if(p.addEventListener){p.addEventListener('load',r,false);}else p.onreadystatechange=function(){if(/loaded|complete/.test(this.readyState))r();};p.src=l;g.getRoot().appendChild(p);return true;}var k={execute:j};e.exports=k;},null); - __d("ApiClient",["ArgumentError","Assert","copyProperties","CORSRequest","FlashRequest","flattenObject","JSONPRequest","Log","ObservableMixin","sprintf","sdk.URI","UrlMap","ApiClientConfig"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){var t,u,v,w={get:true,post:true,'delete':true,put:true},x={fql_query:true,fql_multiquery:true,friends_get:true,notifications_get:true,stream_get:true,users_getinfo:true};function y(da,ea,fa,ga){if(v)fa=i({},v,fa);fa.access_token=fa.access_token||t;fa.pretty=fa.pretty||0;fa=l(fa);var ha={jsonp:m,cors:j,flash:k},ia;if(fa.transport){ia=[fa.transport];delete fa.transport;}else ia=['jsonp','cors','flash'];for(var ja=0;ja0);var la=y,ma=z;y=[];z=[];aa=null;ga('/','POST',{batch:ES('JSON','stringify',false,la),include_headers:false,batch_app_id:u||ca},function(na){if(ES('Array','isArray',false,na)){ES(na,'forEach',true,function(oa,pa){ma[pa](ES('JSON','parse',false,oa.body));});}else ES(ma,'forEach',true,function(oa){return oa({error:{message:'Fatal: batch call failed.'}});});});}function ja(la,ma){h.isObject(la);h.isString(la.method,'method missing');if(!ma)m.warn('No callback passed to the ApiClient');var na=la.method.toLowerCase().replace('.','_');la.format='json-strings';la.api_key=u;var oa=na in x?'api_read':'api',pa=q.resolve(oa)+'/restserver.php',qa=ES(ea,'bind',true,null,ma,'/restserver.php','get',la);da(pa,'get',la,qa);}var ka=ES('Object','assign',false,new n(),{setAccessToken:function(la){t=la;},setClientID:function(la){u=la;},setDefaultParams:function(la){v=la;},rest:ja,graph:ga,scheduleBatchCall:ha});j.setSwfUrl(r.FlashRequest.swfUrl);e.exports=ka;},null); __d("sdk.PlatformVersioning",["sdk.Runtime","ManagedError"],function(a,b,c,d,e,f,g,h){var i=/^v\d+\.\d\d?$/,j={REGEX:i,assertVersionIsSet:function(){if(!g.getVersion())throw new h('init not called with valid version');},assertValidVersion:function(k){if(!i.test(k))throw new h('invalid version specified');}};e.exports=j;},null); - __d("sdk.api",["ApiClient","sdk.PlatformVersioning","sdk.Runtime","sdk.URI"],function(a,b,c,d,e,f,g,h,i,j){var k;i.subscribe('ClientID.change',function(m){g.setClientID(m);});i.subscribe('AccessToken.change',function(m){k=m;g.setAccessToken(m);});g.setDefaultParams({sdk:'joey'});g.subscribe('request.complete',function(m,n,o,p){var q=false;if(p&&typeof p=='object')if(p.error){if(p.error=='invalid_token'||(p.error.type=='OAuthException'&&p.error.code==190))q=true;}else if(p.error_code)if(p.error_code=='190')q=true;if(q&&k===i.getAccessToken())i.setAccessToken(null);});g.subscribe('request.complete',function(m,n,o,p){if(((m=='/me/permissions'&&n==='delete')||(m=='/restserver.php'&&o.method=='Auth.revokeAuthorization'))&&p===true)i.setAccessToken(null);});function l(m){if(typeof m==='string'){if(i.getIsVersioned()){h.assertVersionIsSet();if(!/https?/.test(m)&&m.charAt(0)!=='/')m='/'+m;m=j(m).setDomain(null).setProtocol(null).toString();if(!h.REGEX.test(m.substring(1,ES5(m,'indexOf',true,'/',1))))m='/'+i.getVersion()+m;var n=[m].concat(Array.prototype.slice.call(arguments,1));g.graph.apply(g,n);}else g.graph.apply(g,arguments);}else g.rest.apply(g,arguments);}e.exports=l;},null); + __d("sdk.api",["ApiClient","sdk.PlatformVersioning","sdk.Runtime","sdk.URI"],function(a,b,c,d,e,f,g,h,i,j){var k;i.subscribe('ClientID.change',function(m){g.setClientID(m);});i.subscribe('AccessToken.change',function(m){k=m;g.setAccessToken(m);});g.setDefaultParams({sdk:'joey'});g.subscribe('request.complete',function(m,n,o,p){var q=false;if(p&&typeof p=='object')if(p.error){if(p.error=='invalid_token'||(p.error.type=='OAuthException'&&p.error.code==190))q=true;}else if(p.error_code)if(p.error_code=='190')q=true;if(q&&k===i.getAccessToken())i.setAccessToken(null);});g.subscribe('request.complete',function(m,n,o,p){if(((m=='/me/permissions'&&n==='delete')||(m=='/restserver.php'&&o.method=='Auth.revokeAuthorization'))&&p===true)i.setAccessToken(null);});function l(m){if(typeof m==='string'){if(i.getIsVersioned()){h.assertVersionIsSet();if(!/https?/.test(m)&&m.charAt(0)!=='/')m='/'+m;m=j(m).setDomain(null).setProtocol(null).toString();if(!h.REGEX.test(m.substring(1,ES(m,'indexOf',true,'/',1))))m='/'+i.getVersion()+m;var n=[m].concat(Array.prototype.slice.call(arguments,1));g.graph.apply(g,n);}else g.graph.apply(g,arguments);}else g.rest.apply(g,arguments);}e.exports=l;},null); __d("legacy:fb.api",["FB","sdk.api"],function(a,b,c,d,e,f,g,h){g.provide('',{api:h});},3); + __d("merge",[],function(a,b,c,d,e,f){"use strict";var g=function(h,i){return ES('Object','assign',false,{},h,i);};e.exports=g;},null); + __d("sdk.AppEvents",["Assert","sdk.Impressions","merge","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j){var k={COMPLETED_REGISTRATION:'fb_mobile_complete_registration',VIEWED_CONTENT:'fb_mobile_content_view',SEARCHED:'fb_mobile_search',RATED:'fb_mobile_rate',COMPLETED_TUTORIAL:'fb_mobile_tutorial_completion',ADDED_TO_CART:'fb_mobile_add_to_cart',ADDED_TO_WISHLIST:'fb_mobile_add_to_wishlist',INITIATED_CHECKOUT:'fb_mobile_initiated_checkout',ADDED_PAYMENT_INFO:'fb_mobile_add_payment_info',ACHIEVED_LEVEL:'fb_mobile_level_achieved',UNLOCKED_ACHIEVEMENT:'fb_mobile_achievement_unlocked',SPENT_CREDITS:'fb_mobile_spent_credits'},l={ACTIVATED_APP:'fb_mobile_activate_app',PURCHASED:'fb_mobile_purchase'},m={CURRENCY:'fb_currency',REGISTRATION_METHOD:'fb_registration_method',CONTENT_TYPE:'fb_content_type',CONTENT_ID:'fb_content_id',SEARCH_STRING:'fb_search_string',SUCCESS:'fb_success',MAX_RATING_VALUE:'fb_max_rating_value',PAYMENT_INFO_AVAILABLE:'fb_payment_info_available',NUM_ITEMS:'fb_num_items',LEVEL:'fb_level',DESCRIPTION:'fb_description'},n=40,o='^[0-9a-zA-Z_]+[0-9a-zA-Z _-]*$';function p(t,u,v,w){g.isTrue(q(u),'Invalid event name: '+u+'. '+'It must be between 1 and '+n+' characters, '+'and must be contain only alphanumerics, _, - or spaces, '+'starting with alphanumeric or _.');var x={ae:1,ev:u,vts:v,canvas:j.isCanvasEnvironment()?1:0};if(w)x.cd=w;h.impression({api_key:t,payload:ES('JSON','stringify',false,x)});}function q(t){if(t===null||t.length===0||t.length>n||!(new RegExp(o)).test(t))return false;return true;}function r(t,u,v,w){var x={};x[m.CURRENCY]=v;p(t,l.PURCHASED,u,i(w,x));}function s(t){p(t,l.ACTIVATED_APP);}e.exports={activateApp:s,logEvent:p,logPurchase:r,isValidEventName:q,EventNames:k,ParameterNames:m};},null); + __d("legacy:fb.appevents",["Assert","sdk.AppEvents","FB","sdk.feature","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j,k){i.provide('AppEvents',{logEvent:function(l,m,n){g.isTrue(j('allow_non_canvas_app_events')||k.isCanvasEnvironment(),'You can only use this function in Facebook Canvas environment');g.isString(l,'Invalid eventName');g.maybeNumber(m,'Invalid valueToSum');g.maybeObject(n,'Invalid params');var o=k.getClientID();g.isTrue(o!==null&&o.length>0,'You need to call FB.init() with App ID first.');h.logEvent(o,l,m,n);},logPurchase:function(l,m,n){g.isTrue(j('allow_non_canvas_app_events')||k.isCanvasEnvironment(),'You can only use this function in Facebook Canvas environment');g.isNumber(l,'Invalid purchaseAmount');g.isString(m,'Invalid currency');g.maybeObject(n,'Invalid params');var o=k.getClientID();g.isTrue(o!==null&&o.length>0,'You need to call FB.init() with App ID first.');h.logPurchase(o,l,m,n);},activateApp:function(){g.isTrue(j('allow_non_canvas_app_events')||k.isCanvasEnvironment(),'You can only use this function in Facebook Canvas environment');var l=k.getClientID();g.isTrue(l!==null&&l.length>0,'You need to call FB.init() with App ID first.');h.activateApp(l);},EventNames:h.EventNames,ParameterNames:h.ParameterNames});},3); __d("sdk.Canvas.Environment",["sdk.RPC"],function(a,b,c,d,e,f,g){function h(k){g.remote.getPageInfo(function(l){k(l.result);});}function i(k,l){g.remote.scrollTo({x:k||0,y:l||0});}g.stub('getPageInfo');g.stub('scrollTo');var j={getPageInfo:h,scrollTo:i};e.exports=j;},null); __d("sdk.Intl",["Log"],function(a,b,c,d,e,f,g){var h=('['+'.!?'+'\u3002'+'\uFF01'+'\uFF1F'+'\u0964'+'\u2026'+'\u0EAF'+'\u1801'+'\u0E2F'+'\uFF0E'+']');function i(l){if(typeof l!='string')return false;return !!l.match(new RegExp(h+'['+')"'+"'"+'\u00BB'+'\u0F3B'+'\u0F3D'+'\u2019'+'\u201D'+'\u203A'+'\u3009'+'\u300B'+'\u300D'+'\u300F'+'\u3011'+'\u3015'+'\u3017'+'\u3019'+'\u301B'+'\u301E'+'\u301F'+'\uFD3F'+'\uFF07'+'\uFF09'+'\uFF3D'+'\\s'+']*$'));}function j(l,m){if(m!==undefined)if(typeof m!='object'){g.error('The second arg to FB.Intl.tx() must be an Object for '+'FB.Intl.tx('+l+', ...)');}else{var n;for(var o in m)if(m.hasOwnProperty(o)){if(i(m[o])){n=new RegExp('\\{'+o+'\\}'+h+'*','g');}else n=new RegExp('\\{'+o+'\\}','g');l=l.replace(n,m[o]);}}return l;}function k(){throw new Error('Placeholder function');}k._=j;e.exports={tx:k};},null); - __d("sdk.Dialog",["sdk.Canvas.Environment","sdk.Content","sdk.DOM","DOMEventListener","sdk.Intl","ObservableMixin","sdk.Runtime","Type","UserAgent","sdk.feature"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q=590,r=500,s=240,t=575,u=function(){var y;if(p('dialog_resize_refactor')){var z=v();y=z&&(z.height>=q||z.width>=r);}else y=!!o.ipad();u=function(){return y;};return y;};function v(){if(p('dialog_resize_refactor')){var y=i.getViewportInfo();if(y.height&&y.width)return {width:Math.min(y.width,q),height:Math.min(y.height,r)};}return null;}var w=n.extend({constructor:function y(z,aa){this.parent();this.id=z;this.display=aa;this._e2e={};if(!x._dialogs){x._dialogs={};x._addOrientationHandler();}x._dialogs[z]=this;this.trackEvent('init');},trackEvent:function(y,z){if(this._e2e[y])return this;this._e2e[y]=z||ES5('Date','now',false);if(y=='close')this.inform('e2e:end',this._e2e);return this;},trackEvents:function(y){if(typeof y==='string')y=ES5('JSON','parse',false,y);for(var z in y)if(y.hasOwnProperty(z))this.trackEvent(z,y[z]);return this;}},l),x={newInstance:function(y,z){return new w(y,z);},_dialogs:null,_lastYOffset:0,_loaderEl:null,_overlayEl:null,_stack:[],_active:null,get:function(y){return x._dialogs[y];},_findRoot:function(y){while(y){if(i.containsCss(y,'fb_dialog'))return y;y=y.parentNode;}},_createWWWLoader:function(y){y=y?y:460;return x.create({content:('
    '+' '+'
    '+'
    '+' Facebook'+'
    '+'
    '+'
    '+''),width:y});},_createMobileLoader:function(){var y=o.nativeApp()?'':(''+' '+' '+' '+' '+' '+' '+' '+'
    '+' '+' '+'
    '+k.tx._("\u52a0\u8f7d\u4e2d...")+'
    '+'
    '+'
    ');return x.create({classes:'loading'+(u()?' centered':''),content:('
    '+y+'
    ')});},_restoreBodyPosition:function(){if(!u()){var y=document.getElementsByTagName('body')[0];i.removeCss(y,'fb_hidden');}},_showTabletOverlay:function(){if(!u())return;if(!x._overlayEl){x._overlayEl=document.createElement('div');x._overlayEl.setAttribute('id','fb_dialog_ipad_overlay');h.append(x._overlayEl,null);}x._overlayEl.className='';},_hideTabletOverlay:function(){if(u())x._overlayEl.className='hidden';},showLoader:function(y,z){x._showTabletOverlay();if(!x._loaderEl)x._loaderEl=x._findRoot(o.mobile()?x._createMobileLoader():x._createWWWLoader(z));if(!y)y=function(){};var aa=document.getElementById('fb_dialog_loader_close');i.removeCss(aa,'fb_hidden');aa.onclick=function(){x._hideLoader();x._restoreBodyPosition();x._hideTabletOverlay();y();};var ba=document.getElementById('fb_dialog_ipad_overlay');if(ba)ba.ontouchstart=aa.onclick;x._makeActive(x._loaderEl);},_hideLoader:function(){if(x._loaderEl&&x._loaderEl==x._active)x._loaderEl.style.top='-10000px';},_makeActive:function(y){x._setDialogSizes();x._lowerActive();x._active=y;if(m.isEnvironment(m.ENVIRONMENTS.CANVAS))g.getPageInfo(function(z){x._centerActive(z);});x._centerActive();},_lowerActive:function(){if(!x._active)return;x._active.style.top='-10000px';x._active=null;},_removeStacked:function(y){x._stack=ES5(x._stack,'filter',true,function(z){return z!=y;});},_centerActive:function(y){var z=x._active;if(!z)return;var aa=i.getViewportInfo(),ba=parseInt(z.offsetWidth,10),ca=parseInt(z.offsetHeight,10),da=aa.scrollLeft+(aa.width-ba)/2,ea=(aa.height-ca)/2.5;if(dafa)ga=fa;ga+=aa.scrollTop;if(o.mobile()){var ha=100;if(u()){ha+=(aa.height-ca)/2;}else{var ia=document.getElementsByTagName('body')[0];i.addCss(ia,'fb_hidden');if(p('dialog_resize_refactor'))ia.style.width='auto';ga=10000;}var ja=i.getByClass('fb_dialog_padding',z);if(ja.length)ja[0].style.height=ha+'px';}z.style.left=(da>0?da:0)+'px';z.style.top=(ga>0?ga:0)+'px';},_setDialogSizes:function(){if(!o.mobile()||u())return;for(var y in x._dialogs)if(x._dialogs.hasOwnProperty(y)){var z=document.getElementById(y);if(z){z.style.width=x.getDefaultSize().width+'px';z.style.height=x.getDefaultSize().height+'px';}}},getDefaultSize:function(){if(o.mobile()){var y=v();if(y)return y;if(o.ipad())return {width:r,height:q};if(o.android()){return {width:screen.availWidth,height:screen.availHeight};}else{var z=window.innerWidth,aa=window.innerHeight,ba=z/aa>1.2;return {width:z,height:Math.max(aa,(ba?screen.width:screen.height))};}}return {width:t,height:s};},_handleOrientationChange:function(y){var z=p('dialog_resize_refactor',false)?i.getViewportInfo().width:screen.availWidth;if(o.android()&&z==x._availScreenWidth){setTimeout(x._handleOrientationChange,50);return;}x._availScreenWidth=z;if(u()){x._centerActive();}else{var aa=x.getDefaultSize().width;for(var ba in x._dialogs)if(x._dialogs.hasOwnProperty(ba)){var ca=document.getElementById(ba);if(ca)ca.style.width=aa+'px';}}},_addOrientationHandler:function(){if(!o.mobile())return;var y="onorientationchange" in window?'orientationchange':'resize';x._availScreenWidth=p('dialog_resize_refactor',false)?i.getViewportInfo().width:screen.availWidth;j.add(window,y,x._handleOrientationChange);},create:function(y){y=y||{};var z=document.createElement('div'),aa=document.createElement('div'),ba='fb_dialog';if(y.closeIcon&&y.onClose){var ca=document.createElement('a');ca.className='fb_dialog_close_icon';ca.onclick=y.onClose;z.appendChild(ca);}ba+=' '+(y.classes||'');if(o.ie()){ba+=' fb_dialog_legacy';ES5(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],'forEach',true,function(fa){var ga=document.createElement('span');ga.className='fb_dialog_'+fa;z.appendChild(ga);});}else ba+=o.mobile()?' fb_dialog_mobile':' fb_dialog_advanced';if(y.content)h.append(y.content,aa);z.className=ba;var da=parseInt(y.width,10);if(!isNaN(da))z.style.width=da+'px';aa.className='fb_dialog_content';z.appendChild(aa);if(o.mobile()){var ea=document.createElement('div');ea.className='fb_dialog_padding';z.appendChild(ea);}h.append(z);if(y.visible)x.show(z);return aa;},show:function(y){var z=x._findRoot(y);if(z){x._removeStacked(z);x._hideLoader();x._makeActive(z);x._stack.push(z);if('fbCallID' in y)x.get(y.fbCallID).inform('iframe_show').trackEvent('show');}},hide:function(y){var z=x._findRoot(y);x._hideLoader();if(z==x._active){x._lowerActive();x._restoreBodyPosition();x._hideTabletOverlay();if('fbCallID' in y)x.get(y.fbCallID).inform('iframe_hide').trackEvent('hide');}},remove:function(y){y=x._findRoot(y);if(y){var z=x._active==y;x._removeStacked(y);if(z){x._hideLoader();if(x._stack.length>0){x.show(x._stack.pop());}else{x._lowerActive();x._restoreBodyPosition();x._hideTabletOverlay();}}else if(x._active===null&&x._stack.length>0)x.show(x._stack.pop());setTimeout(function(){y.parentNode.removeChild(y);},3000);}},isActive:function(y){var z=x._findRoot(y);return z&&z===x._active;}};e.exports=x;},null); - __d("sdk.Frictionless",["sdk.Auth","sdk.api","sdk.Event","sdk.Dialog"],function(a,b,c,d,e,f,g,h,i,j){var k={_allowedRecipients:{},_useFrictionless:false,_updateRecipients:function(){k._allowedRecipients={};h('/me/apprequestformerrecipients',function(l){if(!l||l.error)return;ES5(l.data,'forEach',true,function(m){k._allowedRecipients[m.recipient_id]=true;});});},init:function(){k._useFrictionless=true;g.getLoginStatus(function(l){if(l.status=='connected')k._updateRecipients();});i.subscribe('auth.login',function(l){if(l.authResponse)k._updateRecipients();});},_processRequestResponse:function(l,m){return function(n){var o=n&&n.updated_frictionless;if(k._useFrictionless&&o)k._updateRecipients();if(n){if(!m&&n.frictionless){j._hideLoader();j._restoreBodyPosition();j._hideIPadOverlay();}delete n.frictionless;delete n.updated_frictionless;}l&&l(n);};},isAllowed:function(l){if(!l)return false;if(typeof l==='number')return l in k._allowedRecipients;if(typeof l==='string')l=l.split(',');l=ES5(l,'map',true,function(o){return ES5(String(o),'trim',true);});var m=true,n=false;ES5(l,'forEach',true,function(o){m=m&&o in k._allowedRecipients;n=true;});return m&&n;}};i.subscribe('init:post',function(l){if(l.frictionlessRequests)k.init();});e.exports=k;},null); - __d("insertIframe",["guid","GlobalCallback"],function(a,b,c,d,e,f,g,h){function i(j){j.id=j.id||g();j.name=j.name||g();var k=false,l=false,m=function(){if(k&&!l){l=true;j.onload&&j.onload(j.root.firstChild);}},n=h.create(m);if(document.attachEvent){var o=('');j.root.innerHTML=('');k=true;setTimeout(function(){j.root.innerHTML=o;j.root.firstChild.src=j.url;j.onInsert&&j.onInsert(j.root.firstChild);},0);}else{var p=document.createElement('iframe');p.id=j.id;p.name=j.name;p.onload=m;p.scrolling='no';p.style.border='none';p.style.overflow='hidden';if(j.title)p.title=j.title;if(j.className)p.className=j.className;if(j.height!==undefined)p.style.height=j.height+'px';if(j.width!==undefined)if(j.width=='100%'){p.style.width=j.width;}else p.style.width=j.width+'px';j.root.appendChild(p);k=true;p.src=j.url;j.onInsert&&j.onInsert(p);}}e.exports=i;},null); - __d("sdk.Native",["copyProperties","Log","UserAgent"],function(a,b,c,d,e,f,g,h,i){var j='fbNativeReady',k={onready:function(l){if(!i.nativeApp()){h.error('FB.Native.onready only works when the page is rendered '+'in a WebView of the native Facebook app. Test if this is the '+'case calling FB.UA.nativeApp()');return;}if(window.__fbNative&&!this.nativeReady)g(this,window.__fbNative);if(this.nativeReady){l();}else{var m=function(n){window.removeEventListener(j,m);this.onready(l);};window.addEventListener(j,m,false);}}};e.exports=k;},null); + __d("sdk.Dialog",["sdk.Canvas.Environment","sdk.Content","sdk.DOM","DOMEventListener","sdk.Intl","ObservableMixin","sdk.Runtime","Type","UserAgent_DEPRECATED","sdk.feature"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q=590,r=500,s=240,t=575,u=function(){var y;if(p('dialog_resize_refactor')){var z=v();y=z&&(z.height>=q||z.width>=r);}else y=!!o.ipad();u=function(){return y;};return y;};function v(){if(p('dialog_resize_refactor')){var y=i.getViewportInfo();if(y.height&&y.width)return {width:Math.min(y.width,q),height:Math.min(y.height,r)};}return null;}var w=n.extend({constructor:function y(z,aa){this.parent();this.id=z;this.display=aa;this._e2e={};if(!x._dialogs){x._dialogs={};x._addOrientationHandler();}x._dialogs[z]=this;this.trackEvent('init');},trackEvent:function(y,z){if(this._e2e[y])return this;this._e2e[y]=z||ES('Date','now',false);if(y=='close')this.inform('e2e:end',this._e2e);return this;},trackEvents:function(y){if(typeof y==='string')y=ES('JSON','parse',false,y);for(var z in y)if(y.hasOwnProperty(z))this.trackEvent(z,y[z]);return this;}},l),x={newInstance:function(y,z){return new w(y,z);},_dialogs:null,_lastYOffset:0,_loaderEl:null,_overlayEl:null,_stack:[],_active:null,get:function(y){return x._dialogs[y];},_findRoot:function(y){while(y){if(i.containsCss(y,'fb_dialog'))return y;y=y.parentNode;}},_createWWWLoader:function(y){y=y?y:460;return x.create({content:('
    '+' '+'
    '+'
    '+' Facebook'+'
    '+'
    '+'
    '+''),width:y});},_createMobileLoader:function(){var y=o.nativeApp()?'':(''+' '+' '+' '+' '+' '+' '+' '+'
    '+' '+' '+'
    '+k.tx._("\u52a0\u8f7d\u4e2d...")+'
    '+'
    '+'
    ');return x.create({classes:'loading'+(u()?' centered':''),content:('
    '+y+'
    ')});},_restoreBodyPosition:function(){if(!u()){var y=document.getElementsByTagName('body')[0];i.removeCss(y,'fb_hidden');}},_showTabletOverlay:function(){if(!u())return;if(!x._overlayEl){x._overlayEl=document.createElement('div');x._overlayEl.setAttribute('id','fb_dialog_ipad_overlay');h.append(x._overlayEl,null);}x._overlayEl.className='';},_hideTabletOverlay:function(){if(u())x._overlayEl.className='hidden';},showLoader:function(y,z){x._showTabletOverlay();if(!x._loaderEl)x._loaderEl=x._findRoot(o.mobile()?x._createMobileLoader():x._createWWWLoader(z));if(!y)y=function(){};var aa=document.getElementById('fb_dialog_loader_close');i.removeCss(aa,'fb_hidden');aa.onclick=function(){x._hideLoader();x._restoreBodyPosition();x._hideTabletOverlay();y();};var ba=document.getElementById('fb_dialog_ipad_overlay');if(ba)ba.ontouchstart=aa.onclick;x._makeActive(x._loaderEl);},_hideLoader:function(){if(x._loaderEl&&x._loaderEl==x._active)x._loaderEl.style.top='-10000px';},_makeActive:function(y){x._setDialogSizes();x._lowerActive();x._active=y;if(m.isEnvironment(m.ENVIRONMENTS.CANVAS))g.getPageInfo(function(z){x._centerActive(z);});x._centerActive();},_lowerActive:function(){if(!x._active)return;x._active.style.top='-10000px';x._active=null;},_removeStacked:function(y){x._stack=ES(x._stack,'filter',true,function(z){return z!=y;});},_centerActive:function(y){var z=x._active;if(!z)return;var aa=i.getViewportInfo(),ba=parseInt(z.offsetWidth,10),ca=parseInt(z.offsetHeight,10),da=aa.scrollLeft+(aa.width-ba)/2,ea=(aa.height-ca)/2.5;if(dafa)ga=fa;ga+=aa.scrollTop;if(o.mobile()){var ha=100;if(u()){ha+=(aa.height-ca)/2;}else{var ia=document.getElementsByTagName('body')[0];i.addCss(ia,'fb_hidden');if(p('dialog_resize_refactor'))ia.style.width='auto';ga=10000;}var ja=i.getByClass('fb_dialog_padding',z);if(ja.length)ja[0].style.height=ha+'px';}z.style.left=(da>0?da:0)+'px';z.style.top=(ga>0?ga:0)+'px';},_setDialogSizes:function(){if(!o.mobile()||u())return;for(var y in x._dialogs)if(x._dialogs.hasOwnProperty(y)){var z=document.getElementById(y);if(z){z.style.width=x.getDefaultSize().width+'px';z.style.height=x.getDefaultSize().height+'px';}}},getDefaultSize:function(){if(o.mobile()){var y=v();if(y)return y;if(o.ipad())return {width:r,height:q};if(o.android()){return {width:screen.availWidth,height:screen.availHeight};}else{var z=window.innerWidth,aa=window.innerHeight,ba=z/aa>1.2;return {width:z,height:Math.max(aa,(ba?screen.width:screen.height))};}}return {width:t,height:s};},_handleOrientationChange:function(y){var z=p('dialog_resize_refactor',false)?i.getViewportInfo().width:screen.availWidth;if(o.android()&&z==x._availScreenWidth){setTimeout(x._handleOrientationChange,50);return;}x._availScreenWidth=z;if(u()){x._centerActive();}else{var aa=x.getDefaultSize().width;for(var ba in x._dialogs)if(x._dialogs.hasOwnProperty(ba)){var ca=document.getElementById(ba);if(ca)ca.style.width=aa+'px';}}},_addOrientationHandler:function(){if(!o.mobile())return;var y="onorientationchange" in window?'orientationchange':'resize';x._availScreenWidth=p('dialog_resize_refactor',false)?i.getViewportInfo().width:screen.availWidth;j.add(window,y,x._handleOrientationChange);},create:function(y){y=y||{};var z=document.createElement('div'),aa=document.createElement('div'),ba='fb_dialog';if(y.closeIcon&&y.onClose){var ca=document.createElement('a');ca.className='fb_dialog_close_icon';ca.onclick=y.onClose;z.appendChild(ca);}ba+=' '+(y.classes||'');if(o.ie()){ba+=' fb_dialog_legacy';ES(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],'forEach',true,function(fa){var ga=document.createElement('span');ga.className='fb_dialog_'+fa;z.appendChild(ga);});}else ba+=o.mobile()?' fb_dialog_mobile':' fb_dialog_advanced';if(y.content)h.append(y.content,aa);z.className=ba;var da=parseInt(y.width,10);if(!isNaN(da))z.style.width=da+'px';aa.className='fb_dialog_content';z.appendChild(aa);if(o.mobile()){var ea=document.createElement('div');ea.className='fb_dialog_padding';z.appendChild(ea);}h.append(z);if(y.visible)x.show(z);return aa;},show:function(y){var z=x._findRoot(y);if(z){x._removeStacked(z);x._hideLoader();x._makeActive(z);x._stack.push(z);if('fbCallID' in y)x.get(y.fbCallID).inform('iframe_show').trackEvent('show');}},hide:function(y){var z=x._findRoot(y);x._hideLoader();if(z==x._active){x._lowerActive();x._restoreBodyPosition();x._hideTabletOverlay();if('fbCallID' in y)x.get(y.fbCallID).inform('iframe_hide').trackEvent('hide');}},remove:function(y){y=x._findRoot(y);if(y){var z=x._active==y;x._removeStacked(y);if(z){x._hideLoader();if(x._stack.length>0){x.show(x._stack.pop());}else{x._lowerActive();x._restoreBodyPosition();x._hideTabletOverlay();}}else if(x._active===null&&x._stack.length>0)x.show(x._stack.pop());setTimeout(function(){y.parentNode.removeChild(y);},3000);}},isActive:function(y){var z=x._findRoot(y);return z&&z===x._active;}};e.exports=x;},null); + __d("sdk.Frictionless",["sdk.Auth","sdk.api","sdk.Event","sdk.Dialog"],function(a,b,c,d,e,f,g,h,i,j){var k={_allowedRecipients:{},_useFrictionless:false,_updateRecipients:function(){k._allowedRecipients={};h('/me/apprequestformerrecipients',function(l){if(!l||l.error)return;ES(l.data,'forEach',true,function(m){k._allowedRecipients[m.recipient_id]=true;});});},init:function(){k._useFrictionless=true;g.getLoginStatus(function(l){if(l.status=='connected')k._updateRecipients();});i.subscribe('auth.login',function(l){if(l.authResponse)k._updateRecipients();});},_processRequestResponse:function(l,m){return function(n){var o=n&&n.updated_frictionless;if(k._useFrictionless&&o)k._updateRecipients();if(n){if(!m&&n.frictionless){j._hideLoader();j._restoreBodyPosition();j._hideIPadOverlay();}delete n.frictionless;delete n.updated_frictionless;}l&&l(n);};},isAllowed:function(l){if(!l)return false;if(typeof l==='number')return l in k._allowedRecipients;if(typeof l==='string')l=l.split(',');l=ES(l,'map',true,function(o){return ES(String(o),'trim',true);});var m=true,n=false;ES(l,'forEach',true,function(o){m=m&&o in k._allowedRecipients;n=true;});return m&&n;}};i.subscribe('init:post',function(l){if(l.frictionlessRequests)k.init();});e.exports=k;},null); + __d("sdk.Native",["Log","UserAgent_DEPRECATED"],function(a,b,c,d,e,f,g,h){var i='fbNativeReady',j={onready:function(k){if(!h.nativeApp()){g.error('FB.Native.onready only works when the page is rendered '+'in a WebView of the native Facebook app. Test if this is the '+'case calling FB.UA.nativeApp()');return;}if(window.__fbNative&&!this.nativeReady)ES('Object','assign',false,this,window.__fbNative);if(this.nativeReady){k();}else{var l=function(m){window.removeEventListener(i,l);this.onready(k);};window.addEventListener(i,l,false);}}};e.exports=j;},null); __d("resolveURI",[],function(a,b,c,d,e,f){function g(h){if(!h)return window.location.href;h=h.replace(/&/g,'&').replace(/"/g,'"');var i=document.createElement('div');i.innerHTML='';return i.firstChild.href;}e.exports=g;},null); - __d("sdk.UIServer",["sdk.Auth","sdk.Content","createObjectFrom","copyProperties","sdk.Dialog","sdk.DOM","sdk.Event","flattenObject","sdk.Frictionless","sdk.getContextType","guid","insertIframe","Log","sdk.Native","QueryString","resolveURI","sdk.RPC","sdk.Runtime","JSSDKConfig","UrlMap","UserAgent","sdk.XD"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ba){var ca={transform:function(fa){if(fa.params.display==='touch'&&fa.params.access_token&&window.postMessage){fa.params.channel=ea._xdChannelHandler(fa.id,'parent');if(!aa.nativeApp())fa.params.in_iframe=1;return fa;}else return ea.genericTransform(fa);},getXdRelation:function(fa){var ga=fa.display;if(ga==='touch'&&window.postMessage&&fa.in_iframe)return 'parent';return ea.getXdRelation(fa);}},da={'stream.share':{size:{width:670,height:340},url:'sharer.php',transform:function(fa){if(!fa.params.u)fa.params.u=window.location.toString();fa.params.display='popup';return fa;}},apprequests:{transform:function(fa){fa=ca.transform(fa);fa.params.frictionless=o&&o._useFrictionless;if(fa.params.frictionless){if(o.isAllowed(fa.params.to)){fa.params.display='iframe';fa.params.in_iframe=true;fa.hideLoader=true;}fa.cb=o._processRequestResponse(fa.cb,fa.hideLoader);}fa.closeIcon=false;return fa;},getXdRelation:ca.getXdRelation},feed:ca,'permissions.oauth':{url:'dialog/oauth',size:{width:(aa.mobile()?null:475),height:(aa.mobile()?null:183)},transform:function(fa){if(!x.getClientID()){s.error('FB.login() called before FB.init().');return;}if(g.getAuthResponse()&&!fa.params.scope&&!fa.params.auth_type){s.error('FB.login() called when user is already connected.');fa.cb&&fa.cb({status:x.getLoginStatus(),authResponse:g.getAuthResponse()});return;}var ga=fa.cb,ha=fa.id;delete fa.cb;var ia=ES5('Object','keys',false,j(fa.params.response_type?i(fa.params.response_type.split(',')):{},{token:true,signed_request:true})).join(',');if(fa.params.display==='async'){j(fa.params,{client_id:x.getClientID(),origin:p(),response_type:ia,domain:location.hostname});fa.cb=g.xdResponseWrapper(ga,g.getAuthResponse(),'permissions.oauth');}else j(fa.params,{client_id:x.getClientID(),redirect_uri:v(ea.xdHandler(ga,ha,'opener',g.getAuthResponse(),'permissions.oauth')),origin:p(),response_type:ia,domain:location.hostname});return fa;}},'auth.logout':{url:'logout.php',transform:function(fa){if(!x.getClientID()){s.error('FB.logout() called before calling FB.init().');}else if(!g.getAuthResponse()){s.error('FB.logout() called without an access token.');}else{fa.params.next=ea.xdHandler(fa.cb,fa.id,'parent',g.getAuthResponse(),'logout');return fa;}}},'login.status':{url:'dialog/oauth',transform:function(fa){var ga=fa.cb,ha=fa.id;delete fa.cb;j(fa.params,{client_id:x.getClientID(),redirect_uri:ea.xdHandler(ga,ha,'parent',g.getAuthResponse(),'login_status'),origin:p(),response_type:'token,signed_request,code',domain:location.hostname});return fa;}}},ea={Methods:da,_loadedNodes:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(fa){if(fa.params.display=='dialog'||fa.params.display=='iframe')j(fa.params,{display:'iframe',channel:ea._xdChannelHandler(fa.id,'parent.parent')},true);return fa;},checkOauthDisplay:function(fa){var ga=fa.scope||fa.perms||x.getScope();if(!ga)return fa.display;var ha=ga.split(/\s|,/g);for(var ia=0;ia2000;},getDisplayMode:function(fa,ga){if(ga.display==='hidden'||ga.display==='none')return ga.display;var ha=x.isEnvironment(x.ENVIRONMENTS.CANVAS)||x.isEnvironment(x.ENVIRONMENTS.PAGETAB);if(ha&&!ga.display)return 'async';if(aa.mobile()||ga.display==='touch')return 'touch';if(!x.getAccessToken()&&(ga.display=='iframe'||ga.display=='dialog')&&!fa.loggedOutIframe){s.error('"dialog" mode can only be used when the user is connected.');return 'popup';}if(fa.connectDisplay&&!ha)return fa.connectDisplay;return ga.display||(x.getAccessToken()?'dialog':'popup');},getXdRelation:function(fa){var ga=fa.display;if(ga==='popup'||ga==='touch')return 'opener';if(ga==='dialog'||ga==='iframe'||ga==='hidden'||ga==='none')return 'parent';if(ga==='async')return 'parent.frames['+window.name+']';},popup:function(fa){var ga=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,ha=typeof window.screenY!='undefined'?window.screenY:window.screenTop,ia=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,ja=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),ka=aa.mobile()?null:fa.size.width,la=aa.mobile()?null:fa.size.height,ma=(ga<0)?window.screen.width+ga:ga,na=parseInt(ma+((ia-ka)/2),10),oa=parseInt(ha+((ja-la)/2.5),10),pa=[];if(ka!==null)pa.push('width='+ka);if(la!==null)pa.push('height='+la);pa.push('left='+na);pa.push('top='+oa);pa.push('scrollbars=1');if(fa.name=='permissions.request'||fa.name=='permissions.oauth')pa.push('location=1,toolbar=0');pa=pa.join(',');var qa;if(fa.post){qa=window.open('about:blank',fa.id,pa);if(qa){ea.setLoadedNode(fa,qa,'popup');h.submitToTarget({url:fa.url,target:fa.id,params:fa.params});}}else{qa=window.open(fa.url,fa.id,pa);if(qa)ea.setLoadedNode(fa,qa,'popup');}if(!qa)return;if(fa.id in ea._defaultCb)ea._popupMonitor();},setLoadedNode:function(fa,ga,ha){if(fa.params&&fa.params.display!='popup')ga.fbCallID=fa.id;ga={node:ga,type:ha,fbCallID:fa.id};ea._loadedNodes[fa.id]=ga;},getLoadedNode:function(fa){var ga=typeof fa=='object'?fa.id:fa,ha=ea._loadedNodes[ga];return ha?ha.node:null;},hidden:function(fa){fa.className='FB_UI_Hidden';fa.root=h.appendHidden('');ea._insertIframe(fa);},iframe:function(fa){fa.className='FB_UI_Dialog';var ga=function(){ea._triggerDefault(fa.id);};fa.root=k.create({onClose:ga,closeIcon:fa.closeIcon===undefined?true:fa.closeIcon,classes:(aa.ipad()?'centered':'')});if(!fa.hideLoader)k.showLoader(ga,fa.size.width);l.addCss(fa.root,'fb_dialog_iframe');ea._insertIframe(fa);},touch:function(fa){if(fa.params&&fa.params.in_iframe){if(fa.ui_created){k.showLoader(function(){ea._triggerDefault(fa.id);},0);}else ea.iframe(fa);}else if(aa.nativeApp()&&!fa.ui_created){fa.frame=fa.id;t.onready(function(){ea.setLoadedNode(fa,t.open(fa.url+'#cb='+fa.frameName),'native');});ea._popupMonitor();}else if(!fa.ui_created)ea.popup(fa);},async:function(fa){fa.params.redirect_uri=location.protocol+'//'+location.host+location.pathname;delete fa.params.access_token;w.remote.showDialog(fa.params,function(ga){var ha=ga.result;if(ha&&ha.e2e){var ia=k.get(fa.id);ia.trackEvents(ha.e2e);ia.trackEvent('close');delete ha.e2e;}fa.cb(ha);});},getDefaultSize:function(){return k.getDefaultSize();},_insertIframe:function(fa){ea._loadedNodes[fa.id]=false;var ga=function(ha){if(fa.id in ea._loadedNodes)ea.setLoadedNode(fa,ha,'iframe');};if(fa.post){r({url:'about:blank',root:fa.root,className:fa.className,width:fa.size.width,height:fa.size.height,id:fa.id,onInsert:ga,onload:function(ha){h.submitToTarget({url:fa.url,target:ha.name,params:fa.params});}});}else r({url:fa.url,root:fa.root,className:fa.className,width:fa.size.width,height:fa.size.height,id:fa.id,name:fa.frameName,onInsert:ga});},_handleResizeMessage:function(fa,ga){var ha=ea.getLoadedNode(fa);if(!ha)return;if(ga.height)ha.style.height=ga.height+'px';if(ga.width)ha.style.width=ga.width+'px';ba.inform('resize.ack',ga||{},'parent.frames['+ha.name+']');if(!k.isActive(ha))k.show(ha);},_triggerDefault:function(fa){ea._xdRecv({frame:fa},ea._defaultCb[fa]||function(){});},_popupMonitor:function(){var fa;for(var ga in ea._loadedNodes)if(ea._loadedNodes.hasOwnProperty(ga)&&ga in ea._defaultCb){var ha=ea._loadedNodes[ga];if(ha.type!='popup'&&ha.type!='native')continue;var ia=ha.node;try{if(ia.closed){ea._triggerDefault(ga);}else fa=true;}catch(ja){}}if(fa&&!ea._popupInterval){ea._popupInterval=setInterval(ea._popupMonitor,100);}else if(!fa&&ea._popupInterval){clearInterval(ea._popupInterval);ea._popupInterval=null;}},_xdChannelHandler:function(fa,ga){return ba.handler(function(ha){var ia=ea.getLoadedNode(fa);if(!ia)return;if(ha.type=='resize'){ea._handleResizeMessage(fa,ha);}else if(ha.type=='hide'){k.hide(ia);}else if(ha.type=='rendered'){var ja=k._findRoot(ia);k.show(ja);}else if(ha.type=='fireevent')m.fire(ha.event);},ga,true,null);},_xdNextHandler:function(fa,ga,ha,ia){if(ia)ea._defaultCb[ga]=fa;return ba.handler(function(ja){ea._xdRecv(ja,fa);},ha)+'&frame='+ga;},_xdRecv:function(fa,ga){var ha=ea.getLoadedNode(fa.frame);if(ha)if(ha.close){try{ha.close();if(/iPhone.*Version\/(5|6)/.test(navigator.userAgent)&&RegExp.$1!=='5')window.focus();ea._popupCount--;}catch(ia){}}else if(l.containsCss(ha,'FB_UI_Hidden')){setTimeout(function(){ha.parentNode.parentNode.removeChild(ha.parentNode);},3000);}else if(l.containsCss(ha,'FB_UI_Dialog'))k.remove(ha);delete ea._loadedNodes[fa.frame];delete ea._defaultCb[fa.frame];if(fa.e2e){var ja=k.get(fa.frame);ja.trackEvents(fa.e2e);ja.trackEvent('close');delete fa.e2e;}ga(fa);},_xdResult:function(fa,ga,ha,ia){return (ea._xdNextHandler(function(ja){fa&&fa(ja.result&&ja.result!=ea._resultToken&&ES5('JSON','parse',false,ja.result));},ga,ha,ia)+'&result='+encodeURIComponent(ea._resultToken));},xdHandler:function(fa,ga,ha,ia,ja){return ea._xdNextHandler(g.xdResponseWrapper(fa,ia,ja),ga,ha,true);}};w.stub('showDialog');e.exports=ea;},null); - __d("sdk.ui",["Assert","sdk.Impressions","Log","sdk.PlatformVersioning","sdk.Runtime","sdk.UIServer","copyProperties","sdk.feature"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){function o(p,q){g.isObject(p);g.maybeFunction(q);if(k.getIsVersioned()){j.assertVersionIsSet();if(p.version){j.assertValidVersion(p.version);}else p.version=k.getVersion();}p=m({},p);if(!p.method){i.error('"method" is a required parameter for FB.ui().');return null;}var r=p.method;if(p.redirect_uri){i.warn('When using FB.ui, you should not specify a redirect_uri.');delete p.redirect_uri;}if((r=='permissions.request'||r=='permissions.oauth')&&(p.display=='iframe'||p.display=='dialog'))p.display=l.checkOauthDisplay(p);var s=n('e2e_tracking',true);if(s)p.e2e={};var t=l.prepareCall(p,q||function(){});if(!t)return null;var u=t.params.display;if(u==='dialog'){u='iframe';}else if(u==='none')u='hidden';var v=l[u];if(!v){i.error('"display" must be one of "popup", '+'"dialog", "iframe", "touch", "async", "hidden", or "none"');return null;}if(s)t.dialog.subscribe('e2e:end',function(w){w.method=r;w.display=u;i.debug('e2e: %s',ES5('JSON','stringify',false,w));h.log(114,{payload:w});});v(t);return t.dialog;}e.exports=o;},null); - __d("legacy:fb.auth",["sdk.Auth","sdk.Cookie","copyProperties","sdk.Event","FB","Log","sdk.Runtime","sdk.SignedRequest","sdk.ui"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){k.provide('',{getLoginStatus:function(){return g.getLoginStatus.apply(g,arguments);},getAuthResponse:function(){return g.getAuthResponse();},getAccessToken:function(){return m.getAccessToken()||null;},getUserID:function(){return m.getUserID()||m.getCookieUserID();},login:function(p,q){if(q&&q.perms&&!q.scope){q.scope=q.perms;delete q.perms;l.warn('OAuth2 specification states that \'perms\' '+'should now be called \'scope\'. Please update.');}var r=m.isEnvironment(m.ENVIRONMENTS.CANVAS)||m.isEnvironment(m.ENVIRONMENTS.PAGETAB);o(i({method:'permissions.oauth',display:r?'async':'popup',domain:location.hostname},q||{}),p);},logout:function(p){o({method:'auth.logout',display:'hidden'},p);}});g.subscribe('logout',ES5(j.fire,'bind',true,j,'auth.logout'));g.subscribe('login',ES5(j.fire,'bind',true,j,'auth.login'));g.subscribe('authresponse.change',ES5(j.fire,'bind',true,j,'auth.authResponseChange'));g.subscribe('status.change',ES5(j.fire,'bind',true,j,'auth.statusChange'));j.subscribe('init:post',function(p){if(p.status)g.getLoginStatus();if(m.getClientID())if(p.authResponse){g.setAuthResponse(p.authResponse,'connected');}else if(m.getUseCookie()){var q=h.loadSignedRequest(),r;if(q){try{r=n.parse(q);}catch(s){h.clearSignedRequestCookie();}if(r&&r.user_id)m.setCookieUserID(r.user_id);}h.loadMeta();}});},3); - __d("sdk.Canvas.Plugin",["sdk.api","sdk.RPC","Log","UserAgent","sdk.Runtime","createArrayFrom"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m='CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000',n='CLSID:444785F1-DE89-4295-863A-D46C3A781394',o=null,p=!(j.osx()>=10.9&&(j.chrome()>=31||j.webkit()>=537.71||j.firefox()>=25));function q(aa){aa._hideunity_savedstyle={};aa._hideunity_savedstyle.left=aa.style.left;aa._hideunity_savedstyle.position=aa.style.position;aa._hideunity_savedstyle.width=aa.style.width;aa._hideunity_savedstyle.height=aa.style.height;aa.style.left='-10000px';aa.style.position='absolute';aa.style.width='1px';aa.style.height='1px';}function r(aa){if(aa._hideunity_savedstyle){aa.style.left=aa._hideunity_savedstyle.left;aa.style.position=aa._hideunity_savedstyle.position;aa.style.width=aa._hideunity_savedstyle.width;aa.style.height=aa._hideunity_savedstyle.height;}}function s(aa){aa._old_visibility=aa.style.visibility;aa.style.visibility='hidden';}function t(aa){aa.style.visibility=aa._old_visibility||'';delete aa._old_visibility;}function u(aa){var ba=aa.type?aa.type.toLowerCase():null,ca=ba==='application/x-shockwave-flash'||(aa.classid&&aa.classid.toUpperCase()==m);if(!ca)return false;var da=/opaque|transparent/i;if(da.test(aa.getAttribute('wmode')))return false;for(var ea=0;ea2000;},getDisplayMode:function(ea,fa){if(fa.display==='hidden'||fa.display==='none')return fa.display;var ga=w.isEnvironment(w.ENVIRONMENTS.CANVAS)||w.isEnvironment(w.ENVIRONMENTS.PAGETAB);if(ga&&!fa.display)return 'async';if(z.mobile()||fa.display==='touch')return 'touch';if(!w.getAccessToken()&&(fa.display=='iframe'||fa.display=='dialog')&&!ea.loggedOutIframe){r.error('"dialog" mode can only be used when the user is connected.');return 'popup';}if(ea.connectDisplay&&!ga)return ea.connectDisplay;return fa.display||(w.getAccessToken()?'dialog':'popup');},getXdRelation:function(ea){var fa=ea.display;if(fa==='popup'||fa==='touch')return 'opener';if(fa==='dialog'||fa==='iframe'||fa==='hidden'||fa==='none')return 'parent';if(fa==='async')return 'parent.frames['+window.name+']';},popup:function(ea){var fa=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,ga=typeof window.screenY!='undefined'?window.screenY:window.screenTop,ha=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,ia=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),ja=z.mobile()?null:ea.size.width,ka=z.mobile()?null:ea.size.height,la=(fa<0)?window.screen.width+fa:fa,ma=parseInt(la+((ha-ja)/2),10),na=parseInt(ga+((ia-ka)/2.5),10),oa=[];if(ja!==null)oa.push('width='+ja);if(ka!==null)oa.push('height='+ka);oa.push('left='+ma);oa.push('top='+na);oa.push('scrollbars=1');if(ea.name=='permissions.request'||ea.name=='permissions.oauth')oa.push('location=1,toolbar=0');oa=oa.join(',');var pa;if(ea.post){pa=window.open('about:blank',ea.id,oa);if(pa){da.setLoadedNode(ea,pa,'popup');h.submitToTarget({url:ea.url,target:ea.id,params:ea.params});}}else{pa=window.open(ea.url,ea.id,oa);if(pa)da.setLoadedNode(ea,pa,'popup');}if(!pa)return;if(ea.id in da._defaultCb)da._popupMonitor();},setLoadedNode:function(ea,fa,ga){if(ea.params&&ea.params.display!='popup')fa.fbCallID=ea.id;fa={node:fa,type:ga,fbCallID:ea.id};da._loadedNodes[ea.id]=fa;},getLoadedNode:function(ea){var fa=typeof ea=='object'?ea.id:ea,ga=da._loadedNodes[fa];return ga?ga.node:null;},hidden:function(ea){ea.className='FB_UI_Hidden';ea.root=h.appendHidden('');da._insertIframe(ea);},iframe:function(ea){ea.className='FB_UI_Dialog';var fa=function(){da._triggerDefault(ea.id);};ea.root=j.create({onClose:fa,closeIcon:ea.closeIcon===undefined?true:ea.closeIcon,classes:(z.ipad()?'centered':'')});if(!ea.hideLoader)j.showLoader(fa,ea.size.width);k.addCss(ea.root,'fb_dialog_iframe');da._insertIframe(ea);},touch:function(ea){if(ea.params&&ea.params.in_iframe){if(ea.ui_created){j.showLoader(function(){da._triggerDefault(ea.id);},0);}else da.iframe(ea);}else if(z.nativeApp()&&!ea.ui_created){ea.frame=ea.id;s.onready(function(){da.setLoadedNode(ea,s.open(ea.url+'#cb='+ea.frameName),'native');});da._popupMonitor();}else if(!ea.ui_created)da.popup(ea);},async:function(ea){ea.params.redirect_uri=location.protocol+'//'+location.host+location.pathname;delete ea.params.access_token;v.remote.showDialog(ea.params,function(fa){var ga=fa.result;if(ga&&ga.e2e){var ha=j.get(ea.id);ha.trackEvents(ga.e2e);ha.trackEvent('close');delete ga.e2e;}ea.cb(ga);});},getDefaultSize:function(){return j.getDefaultSize();},_insertIframe:function(ea){da._loadedNodes[ea.id]=false;var fa=function(ga){if(ea.id in da._loadedNodes)da.setLoadedNode(ea,ga,'iframe');};if(ea.post){q({url:'about:blank',root:ea.root,className:ea.className,width:ea.size.width,height:ea.size.height,id:ea.id,onInsert:fa,onload:function(ga){h.submitToTarget({url:ea.url,target:ga.name,params:ea.params});}});}else q({url:ea.url,root:ea.root,className:ea.className,width:ea.size.width,height:ea.size.height,id:ea.id,name:ea.frameName,onInsert:fa});},_handleResizeMessage:function(ea,fa){var ga=da.getLoadedNode(ea);if(!ga)return;if(fa.height)ga.style.height=fa.height+'px';if(fa.width)ga.style.width=fa.width+'px';aa.inform('resize.ack',fa||{},'parent.frames['+ga.name+']');if(!j.isActive(ga))j.show(ga);},_triggerDefault:function(ea){da._xdRecv({frame:ea},da._defaultCb[ea]||function(){});},_popupMonitor:function(){var ea;for(var fa in da._loadedNodes)if(da._loadedNodes.hasOwnProperty(fa)&&fa in da._defaultCb){var ga=da._loadedNodes[fa];if(ga.type!='popup'&&ga.type!='native')continue;var ha=ga.node;try{if(ha.closed){da._triggerDefault(fa);}else ea=true;}catch(ia){}}if(ea&&!da._popupInterval){da._popupInterval=setInterval(da._popupMonitor,100);}else if(!ea&&da._popupInterval){clearInterval(da._popupInterval);da._popupInterval=null;}},_xdChannelHandler:function(ea,fa){return aa.handler(function(ga){var ha=da.getLoadedNode(ea);if(!ha)return;if(ga.type=='resize'){da._handleResizeMessage(ea,ga);}else if(ga.type=='hide'){j.hide(ha);}else if(ga.type=='rendered'){var ia=j._findRoot(ha);j.show(ia);}else if(ga.type=='fireevent')l.fire(ga.event);},fa,true,null);},_xdNextHandler:function(ea,fa,ga,ha){if(ha)da._defaultCb[fa]=ea;return aa.handler(function(ia){da._xdRecv(ia,ea);},ga)+'&frame='+fa;},_xdRecv:function(ea,fa){var ga=da.getLoadedNode(ea.frame);if(ga)if(ga.close){try{ga.close();if(/iPhone.*Version\/(5|6)/.test(navigator.userAgent)&&RegExp.$1!=='5')window.focus();da._popupCount--;}catch(ha){}}else if(k.containsCss(ga,'FB_UI_Hidden')){setTimeout(function(){ga.parentNode.parentNode.removeChild(ga.parentNode);},3000);}else if(k.containsCss(ga,'FB_UI_Dialog'))j.remove(ga);delete da._loadedNodes[ea.frame];delete da._defaultCb[ea.frame];if(ea.e2e){var ia=j.get(ea.frame);ia.trackEvents(ea.e2e);ia.trackEvent('close');delete ea.e2e;}fa(ea);},_xdResult:function(ea,fa,ga,ha){return (da._xdNextHandler(function(ia){ea&&ea(ia.result&&ia.result!=da._resultToken&&ES('JSON','parse',false,ia.result));},fa,ga,ha)+'&result='+encodeURIComponent(da._resultToken));},xdHandler:function(ea,fa,ga,ha,ia){return da._xdNextHandler(g.xdResponseWrapper(ea,ha,ia),fa,ga,true);}};v.stub('showDialog');e.exports=da;},null); + __d("sdk.ui",["Assert","sdk.Impressions","Log","sdk.PlatformVersioning","sdk.Runtime","sdk.UIServer","sdk.feature"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){function n(o,p){g.isObject(o);g.maybeFunction(p);if(k.getIsVersioned()){j.assertVersionIsSet();if(o.version){j.assertValidVersion(o.version);}else o.version=k.getVersion();}o=ES('Object','assign',false,{},o);if(!o.method){i.error('"method" is a required parameter for FB.ui().');return null;}if(o.method=='pay.prompt')o.method='pay';var q=o.method;if(o.redirect_uri){i.warn('When using FB.ui, you should not specify a redirect_uri.');delete o.redirect_uri;}if((q=='permissions.request'||q=='permissions.oauth')&&(o.display=='iframe'||o.display=='dialog'))o.display=l.checkOauthDisplay(o);var r=m('e2e_tracking',true);if(r)o.e2e={};var s=l.prepareCall(o,p||function(){});if(!s)return null;var t=s.params.display;if(t==='dialog'){t='iframe';}else if(t==='none')t='hidden';var u=l[t];if(!u){i.error('"display" must be one of "popup", '+'"dialog", "iframe", "touch", "async", "hidden", or "none"');return null;}if(r)s.dialog.subscribe('e2e:end',function(v){v.method=q;v.display=t;i.debug('e2e: %s',ES('JSON','stringify',false,v));h.log(114,{payload:v});});u(s);return s.dialog;}e.exports=n;},null); + __d("legacy:fb.auth",["sdk.Auth","sdk.Cookie","copyProperties","sdk.Event","FB","Log","sdk.Runtime","sdk.SignedRequest","sdk.ui"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){k.provide('',{getLoginStatus:function(){return g.getLoginStatus.apply(g,arguments);},getAuthResponse:function(){return g.getAuthResponse();},getAccessToken:function(){return m.getAccessToken()||null;},getUserID:function(){return m.getUserID()||m.getCookieUserID();},login:function(p,q){if(q&&q.perms&&!q.scope){q.scope=q.perms;delete q.perms;l.warn('OAuth2 specification states that \'perms\' '+'should now be called \'scope\'. Please update.');}var r=m.isEnvironment(m.ENVIRONMENTS.CANVAS)||m.isEnvironment(m.ENVIRONMENTS.PAGETAB);o(i({method:'permissions.oauth',display:r?'async':'popup',domain:location.hostname},q||{}),p);},logout:function(p){o({method:'auth.logout',display:'hidden'},p);}});g.subscribe('logout',ES(j.fire,'bind',true,j,'auth.logout'));g.subscribe('login',ES(j.fire,'bind',true,j,'auth.login'));g.subscribe('authresponse.change',ES(j.fire,'bind',true,j,'auth.authResponseChange'));g.subscribe('status.change',ES(j.fire,'bind',true,j,'auth.statusChange'));j.subscribe('init:post',function(p){if(p.status)g.getLoginStatus();if(m.getClientID())if(p.authResponse){g.setAuthResponse(p.authResponse,'connected');}else if(m.getUseCookie()){var q=h.loadSignedRequest(),r;if(q){try{r=n.parse(q);}catch(s){h.clearSignedRequestCookie();}if(r&&r.user_id)m.setCookieUserID(r.user_id);}h.loadMeta();}});},3); __d("sdk.Canvas.IframeHandling",["DOMWrapper","sdk.RPC"],function(a,b,c,d,e,f,g,h){var i=null,j;function k(){var o=g.getWindow().document,p=o.body,q=o.documentElement,r=Math.max(p.offsetTop,0),s=Math.max(q.offsetTop,0),t=p.scrollHeight+r,u=p.offsetHeight+r,v=q.scrollHeight+s,w=q.offsetHeight+s;return Math.max(t,u,v,w);}function l(o){if(typeof o!='object')o={};var p=0,q=0;if(!o.height){o.height=k();p=16;q=4;}if(!o.frame)o.frame=window.name||'iframe_canvas';if(j){var r=j.height,s=o.height-r;if(s<=q&&s>=-p)return false;}j=o;h.remote.setSize(o);return true;}function m(o,p){if(p===undefined&&typeof o==='number'){p=o;o=true;}if(o||o===undefined){if(i===null)i=setInterval(function(){l();},p||100);l();}else if(i!==null){clearInterval(i);i=null;}}h.stub('setSize');var n={setSize:l,setAutoGrow:m};e.exports=n;},null); __d("sdk.Canvas.Navigation",["sdk.RPC"],function(a,b,c,d,e,f,g){function h(j){g.local.navigate=function(k){j({path:k});};g.remote.setNavigationEnabled(true);}g.stub('setNavigationEnabled');var i={setUrlHandler:h};e.exports=i;},null); - __d("sdk.Canvas.Tti",["sdk.RPC","sdk.Runtime"],function(a,b,c,d,e,f,g,h){function i(n,o){var p={appId:h.getClientID(),time:ES5('Date','now',false),name:o},q=[p];if(n)q.push(function(r){n(r.result);});g.remote.logTtiMessage.apply(null,q);}function j(){i(null,'StartIframeAppTtiTimer');}function k(n){i(n,'StopIframeAppTtiTimer');}function l(n){i(n,'RecordIframeAppTti');}g.stub('logTtiMessage');var m={setDoneLoading:l,startTimer:j,stopTimer:k};e.exports=m;},null); - __d("legacy:fb.canvas",["Assert","sdk.Canvas.Environment","sdk.Event","FB","sdk.Canvas.Plugin","sdk.Canvas.IframeHandling","Log","sdk.Canvas.Navigation","sdk.Runtime","sdk.Canvas.Tti"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){j.provide('Canvas',{setSize:function(q){g.maybeObject(q,'Invalid argument');return l.setSize.apply(null,arguments);},setAutoGrow:function(){return l.setAutoGrow.apply(null,arguments);},getPageInfo:function(q){g.isFunction(q,'Invalid argument');return h.getPageInfo.apply(null,arguments);},scrollTo:function(q,r){g.maybeNumber(q,'Invalid argument');g.maybeNumber(r,'Invalid argument');return h.scrollTo.apply(null,arguments);},setDoneLoading:function(q){g.maybeFunction(q,'Invalid argument');return p.setDoneLoading.apply(null,arguments);},startTimer:function(){return p.startTimer.apply(null,arguments);},stopTimer:function(q){g.maybeFunction(q,'Invalid argument');return p.stopTimer.apply(null,arguments);},getHash:function(q){g.isFunction(q,'Invalid argument');return n.getHash.apply(null,arguments);},setHash:function(q){g.isString(q,'Invalid argument');return n.setHash.apply(null,arguments);},setUrlHandler:function(q){g.isFunction(q,'Invalid argument');return n.setUrlHandler.apply(null,arguments);}});i.subscribe('init:post',function(q){if(o.isEnvironment(o.ENVIRONMENTS.CANVAS)){g.isTrue(!q.hideFlashCallback||!q.hidePluginCallback,'cannot specify deprecated hideFlashCallback and new hidePluginCallback');k._setHidePluginCallback(q.hidePluginCallback||q.hideFlashCallback);}});},3); - __d("sdk.Canvas.Prefetcher",["sdk.api","createArrayFrom","JSSDKCanvasPrefetcherConfig","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j){var k={AUTOMATIC:0,MANUAL:1},l=i.sampleRate,m=i.blacklist,n=k.AUTOMATIC,o=[];function p(){var u={object:'data',link:'href',script:'src'};if(n==k.AUTOMATIC)ES5(ES5('Object','keys',false,u),'forEach',true,function(v){var w=u[v];ES5(h(document.getElementsByTagName(v)),'forEach',true,function(x){if(x[w])o.push(x[w]);});});if(o.length===0)return;g(j.getClientID()+'/staticresources','post',{urls:ES5('JSON','stringify',false,o),is_https:location.protocol==='https:'});o=[];}function q(){if(!j.isEnvironment(j.ENVIRONMENTS.CANVAS)||!j.getClientID()||!l)return;if(Math.random()>1/l||m=='*'||~ES5(m,'indexOf',true,j.getClientID()))return;setTimeout(p,30000);}function r(u){n=u;}function s(u){o.push(u);}var t={COLLECT_AUTOMATIC:k.AUTOMATIC,COLLECT_MANUAL:k.MANUAL,addStaticResource:s,setCollectionMode:r,_maybeSample:q};e.exports=t;},null); + __d("sdk.Canvas.Plugin",["sdk.api","sdk.RPC","Log","UserAgent_DEPRECATED","sdk.Runtime","createArrayFrom"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m='CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000',n='CLSID:444785F1-DE89-4295-863A-D46C3A781394',o=null,p=!(j.osx()>=10.9&&(j.chrome()>=31||j.webkit()>=537.71||j.firefox()>=25));function q(aa){aa._hideunity_savedstyle={};aa._hideunity_savedstyle.left=aa.style.left;aa._hideunity_savedstyle.position=aa.style.position;aa._hideunity_savedstyle.width=aa.style.width;aa._hideunity_savedstyle.height=aa.style.height;aa.style.left='-10000px';aa.style.position='absolute';aa.style.width='1px';aa.style.height='1px';}function r(aa){if(aa._hideunity_savedstyle){aa.style.left=aa._hideunity_savedstyle.left;aa.style.position=aa._hideunity_savedstyle.position;aa.style.width=aa._hideunity_savedstyle.width;aa.style.height=aa._hideunity_savedstyle.height;}}function s(aa){aa._old_visibility=aa.style.visibility;aa.style.visibility='hidden';}function t(aa){aa.style.visibility=aa._old_visibility||'';delete aa._old_visibility;}function u(aa){var ba=aa.type?aa.type.toLowerCase():null,ca=ba==='application/x-shockwave-flash'||(aa.classid&&aa.classid.toUpperCase()==m);if(!ca)return false;var da=/opaque|transparent/i;if(da.test(aa.getAttribute('wmode')))return false;for(var ea=0;ea1/l||m=='*'||~ES(m,'indexOf',true,j.getClientID()))return;setTimeout(p,30000);}function r(u){n=u;}function s(u){o.push(u);}var t={COLLECT_AUTOMATIC:k.AUTOMATIC,COLLECT_MANUAL:k.MANUAL,addStaticResource:s,setCollectionMode:r,_maybeSample:q};e.exports=t;},null); __d("legacy:fb.canvas.prefetcher",["FB","sdk.Canvas.Prefetcher","sdk.Event","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j){g.provide('Canvas.Prefetcher',h);i.subscribe('init:post',function(k){if(j.isEnvironment(j.ENVIRONMENTS.CANVAS))h._maybeSample();});},3); - __d("legacy:fb.event",["FB","sdk.Event"],function(a,b,c,d,e,f,g,h){g.provide('Event',{subscribe:ES5(h.subscribe,'bind',true,h),unsubscribe:ES5(h.unsubscribe,'bind',true,h)});},3); + __d("legacy:fb.canvas.presence",["sdk.RPC","sdk.Event"],function(a,b,c,d,e,f,g,h){h.subscribe(h.SUBSCRIBE,i);h.subscribe(h.UNSUBSCRIBE,j);g.stub('useFriendsOnline');function i(k,l){if(k!='canvas.friendsOnlineUpdated')return;if(l.length===1)g.remote.useFriendsOnline(true);}function j(k,l){if(k!='canvas.friendsOnlineUpdated')return;if(l.length===0)g.remote.useFriendsOnline(false);}},3); + __d("legacy:fb.event",["FB","sdk.Event","sdk.Runtime","sdk.Scribe","sdk.feature"],function(a,b,c,d,e,f,g,h,i,j,k){var l=[],m=null,n=k('event_subscriptions_log',false);g.provide('Event',{subscribe:function(o,p){if(n){l.push(o);if(!m)m=setTimeout(function(){j.log('jssdk_error',{appId:i.getClientID(),error:'EVENT_SUBSCRIPTIONS_LOG',extra:{line:0,name:'EVENT_SUBSCRIPTIONS_LOG',script:'N/A',stack:'N/A',message:l.sort().join(',')}});l.length=0;m=null;},n);}return h.subscribe(o,p);},unsubscribe:ES(h.unsubscribe,'bind',true,h)});},3); __d("legacy:fb.frictionless",["FB","sdk.Frictionless"],function(a,b,c,d,e,f,g,h){g.provide('Frictionless',h);},3); - __d("sdk.init",["sdk.Cookie","sdk.ErrorHandling","sdk.Event","Log","ManagedError","sdk.PlatformVersioning","QueryString","sdk.Runtime","sdk.URI","copyProperties","createArrayFrom"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){function r(t){var u=(typeof t=='number'&&t>0)||(typeof t=='string'&&/^[0-9a-f]{21,}$|^[0-9]{1,21}$/.test(t));if(u)return t.toString();j.warn('Invalid App Id: Must be a number or numeric string representing '+'the application id.');return null;}function s(t){if(n.getInitialized())j.warn('FB.init has already been called - this could indicate a problem');if(n.getIsVersioned()){if(Object.prototype.toString.call(t)!=='[object Object]')throw new k('Invalid argument');if(t.authResponse)throw new k('Setting authResponse is not supported');if(!t.version)t.version=o(location.href).getQueryData().sdk_version;l.assertValidVersion(t.version);n.setVersion(t.version);}else{if(/number|string/.test(typeof t)){j.warn('FB.init called with invalid parameters');t={apiKey:t};}t=p({status:true},t||{});}var u=r(t.appId||t.apiKey);if(u!==null)n.setClientID(u);if('scope' in t)n.setScope(t.scope);if(t.cookie){n.setUseCookie(true);if(typeof t.cookie==='string')g.setDomain(t.cookie);}if(t.kidDirectedSite)n.setKidDirectedSite(true);n.setInitialized(true);i.fire('init:post',t);}setTimeout(function(){var t=/(connect\.facebook\.net|\.facebook\.com\/assets.php).*?#(.*)/;ES5(q(document.getElementsByTagName('script')),'forEach',true,function(u){if(u.src){var v=t.exec(u.src);if(v){var w=m.decode(v[2]);for(var x in w)if(w.hasOwnProperty(x)){var y=w[x];if(y=='0')w[x]=0;}s(w);}}});if(window.fbAsyncInit&&!window.fbAsyncInit.hasRun){window.fbAsyncInit.hasRun=true;h.unguard(window.fbAsyncInit)();}},0);e.exports=s;},null); + __d("sdk.init",["sdk.Cookie","sdk.ErrorHandling","sdk.Event","Log","ManagedError","sdk.PlatformVersioning","QueryString","sdk.Runtime","sdk.URI","createArrayFrom"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){function q(s){var t=(typeof s=='number'&&s>0)||(typeof s=='string'&&/^[0-9a-f]{21,}$|^[0-9]{1,21}$/.test(s));if(t)return s.toString();j.warn('Invalid App Id: Must be a number or numeric string representing '+'the application id.');return null;}function r(s){if(n.getInitialized())j.warn('FB.init has already been called - this could indicate a problem');if(n.getIsVersioned()){if(Object.prototype.toString.call(s)!=='[object Object]')throw new k('Invalid argument');if(s.authResponse)j.warn('Setting authResponse is not supported');if(!s.version)s.version=o(location.href).getQueryData().sdk_version;l.assertValidVersion(s.version);n.setVersion(s.version);}else{if(/number|string/.test(typeof s)){j.warn('FB.init called with invalid parameters');s={apiKey:s};}s=ES('Object','assign',false,{status:true},s||{});}var t=q(s.appId||s.apiKey);if(t!==null)n.setClientID(t);if('scope' in s)n.setScope(s.scope);if(s.cookie){n.setUseCookie(true);if(typeof s.cookie==='string')g.setDomain(s.cookie);}if(s.kidDirectedSite)n.setKidDirectedSite(true);n.setInitialized(true);i.fire('init:post',s);}setTimeout(function(){var s=/(connect\.facebook\.net|\.facebook\.com\/assets.php).*?#(.*)/;ES(p(document.getElementsByTagName('script')),'forEach',true,function(t){if(t.src){var u=s.exec(t.src);if(u){var v=m.decode(u[2]);for(var w in v)if(v.hasOwnProperty(w)){var x=v[w];if(x=='0')v[w]=0;}r(v);}}});if(window.fbAsyncInit&&!window.fbAsyncInit.hasRun){window.fbAsyncInit.hasRun=true;h.unguard(window.fbAsyncInit)();}},0);e.exports=r;},null); __d("legacy:fb.init",["FB","sdk.init"],function(a,b,c,d,e,f,g,h){g.provide('',{init:h});},3); - __d("legacy:fb.pay",["copyProperties","sdk.Runtime","sdk.UIServer","sdk.XD","FB"],function(a,b,c,d,e,f,g,h,i,j){b('FB');var k={error_code:1383001,error_message:'An unknown error caused the dialog to be closed'},l=function(m){return function(n){m(n&&n.response?ES5('JSON','parse',false,n.response):k);};};g(i.Methods,{'pay.prompt':{transform:function(m){var n=j.handler(l(m.cb),'parent.frames['+(window.name||'iframe_canvas')+']');m.params.channel=n;j.inform('Pay.Prompt',m.params);}},pay:{size:{width:555,height:120},connectDisplay:'popup',transform:function(m){m.cb=l(m.cb);if(!h.isEnvironment(h.ENVIRONMENTS.CANVAS)){m.params.order_info=ES5('JSON','stringify',false,m.params.order_info);return m;}var n=j.handler(m.cb,'parent.frames['+(window.name||'iframe_canvas')+']');m.params.channel=n;m.params.uiserver=true;j.inform('Pay.Prompt',m.params);}}});},3); + __d("legacy:fb.pay",["copyProperties","sdk.Runtime","sdk.UIServer","sdk.XD","sdk.feature","FB"],function(a,b,c,d,e,f,g,h,i,j,k){b('FB');var l={error_code:1383001,error_message:'An unknown error caused the dialog to be closed'},m=function(n){return function(o){if(o&&typeof o.response==='string'){n(ES('JSON','parse',false,o.response));}else if(typeof o==='object'){n(o);}else n(l);};};g(i.Methods,{pay:{size:{width:555,height:120},connectDisplay:'popup',transform:function(n){if(k('launch_payment_dialog_via_pac')){n.cb=m(n.cb);return n;}else{n.cb=m(n.cb);if(!h.isEnvironment(h.ENVIRONMENTS.CANVAS)){n.params.order_info=ES('JSON','stringify',false,n.params.order_info);return n;}var o=j.handler(n.cb,'parent.frames['+(window.name||'iframe_canvas')+']');n.params.channel=o;n.params.uiserver=true;j.inform('Pay.Prompt',n.params);}}}});},3); __d("legacy:fb.ui",["FB","sdk.ui"],function(a,b,c,d,e,f,g,h){g.provide('',{ui:h});},3); - __d("Miny",[],function(a,b,c,d,e,f){var g='Miny1',h={encode:[],decode:{}},i='wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'.split('');function j(n){for(var o=h.encode.length;o=0,'onrender() has been called too many times');};ES5(i(ca.getElementsByTagName('*')),'forEach',true,function(ka){if(!ea&&ka.getAttribute('fb-xfbml-state'))return;if(ka.nodeType!==1)return;var la=w(ka)||x(ka);if(!la)return;if(p.ie()<9&&ka.scopeName)ka=z(ka,la.xmlns,la.localName);ga++;ha++;var ma=new la.ctor(ka,la.xmlns,la.localName,y(ka));ma.subscribe('render',o(function(){ka.setAttribute('fb-xfbml-state','rendered');ia();}));var na=function(){if(ka.getAttribute('fb-xfbml-state')=='parsed'){t.subscribe('render.queue',na);}else{ka.setAttribute('fb-xfbml-state','parsed');ma.process();}};na();});t.inform('parse',fa,ha);var ja=30000;setTimeout(function(){if(ga>0)m.warn('%s tags failed to render in %s ms',ga,ja);},ja);ia();}t.subscribe('render',function(){var ca=t.getSubscribers('render.queue');t.clearSubscribers('render.queue');ES5(ca,'forEach',true,function(da){da();});});h(t,{registerTag:function(ca){var da=ca.xmlns+':'+ca.localName;g.isUndefined(q[da],da+' already registered');q[da]=ca;r[ca.xmlns+'-'+ca.localName]=ca;},parse:function(ca,da){aa(ca||document.body,da||function(){},true);},parseNew:function(){aa(document.body,function(){},false);}});if(k('log_tag_count')){var ba=function(ca,da){t.unsubscribe('parse',ba);setTimeout(ES5(l.log,'bind',true,null,102,{tag_count:da}),5000);};t.subscribe('parse',ba);}e.exports=t;},null); - __d("PluginPipe",["sdk.Content","copyProperties","sdk.feature","guid","insertIframe","Miny","ObservableMixin","JSSDKPluginPipeConfig","sdk.Runtime","UrlMap","UserAgent","XFBML"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){var s=new m(),t=n.threshold,u=[];function v(){return !!(i('plugin_pipe')&&o.getSecure()!==undefined&&(q.chrome()||q.firefox())&&n.enabledApps[o.getClientID()]);}function w(){var y=u;u=[];if(y.length<=t){ES5(y,'forEach',true,function(ba){k(ba.config);});return;}var z=y.length+1;function aa(){z--;if(z===0)x(y);}ES5(y,'forEach',true,function(ba){var ca={};for(var da in ba.config)ca[da]=ba.config[da];ca.url=p.resolve('www',o.getSecure())+'/plugins/plugin_pipe_shell.php';ca.onload=aa;k(ca);});aa();}r.subscribe('parse',w);function x(y){var z=document.createElement('span');g.appendHidden(z);var aa={};ES5(y,'forEach',true,function(fa){aa[fa.config.name]={plugin:fa.tag,params:fa.params};});var ba=ES5('JSON','stringify',false,aa),ca=l.encode(ba);ES5(y,'forEach',true,function(fa){var ga=document.getElementsByName(fa.config.name)[0];ga.onload=fa.config.onload;});var da=p.resolve('www',o.getSecure())+'/plugins/pipe.php',ea=j();k({url:'about:blank',root:z,name:ea,className:'fb_hidden fb_invisible',onload:function(){g.submitToTarget({url:da,target:ea,params:{plugins:ca.length=0,'onrender() has been called too many times');};ES(h(ba.getElementsByTagName('*')),'forEach',true,function(ja){if(!da&&ja.getAttribute('fb-xfbml-state'))return;if(ja.nodeType!==1)return;var ka=v(ja)||w(ja);if(!ka)return;if(o.ie()<9&&ja.scopeName)ja=y(ja,ka.xmlns,ka.localName);fa++;ga++;var la=new ka.ctor(ja,ka.xmlns,ka.localName,x(ja));la.subscribe('render',n(function(){ja.setAttribute('fb-xfbml-state','rendered');ha();}));var ma=function(){if(ja.getAttribute('fb-xfbml-state')=='parsed'){s.subscribe('render.queue',ma);}else{ja.setAttribute('fb-xfbml-state','parsed');la.process();}};ma();});s.inform('parse',ea,ga);var ia=30000;setTimeout(function(){if(fa>0)l.warn('%s tags failed to render in %s ms',fa,ia);},ia);ha();}s.subscribe('render',function(){var ba=s.getSubscribers('render.queue');s.clearSubscribers('render.queue');ES(ba,'forEach',true,function(ca){ca();});});ES('Object','assign',false,s,{registerTag:function(ba){var ca=ba.xmlns+':'+ba.localName;g.isUndefined(p[ca],ca+' already registered');p[ca]=ba;q[ba.xmlns+'-'+ba.localName]=ba;},parse:function(ba,ca){z(ba||document.body,ca||function(){},true);},parseNew:function(){z(document.body,function(){},false);}});if(j('log_tag_count')){var aa=function(ba,ca){s.unsubscribe('parse',aa);setTimeout(ES(k.log,'bind',true,null,102,{tag_count:ca}),5000);};s.subscribe('parse',aa);}e.exports=s;},null); + __d("PluginPipe",["sdk.Content","sdk.feature","guid","insertIframe","Miny","ObservableMixin","JSSDKPluginPipeConfig","sdk.Runtime","UrlMap","UserAgent_DEPRECATED","XFBML"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=new l(),s=m.threshold,t=[];function u(){return !!(h('plugin_pipe')&&n.getSecure()!==undefined&&(p.chrome()||p.firefox())&&m.enabledApps[n.getClientID()]);}function v(){var x=t;t=[];if(x.length<=s){ES(x,'forEach',true,function(aa){j(aa.config);});return;}var y=x.length+1;function z(){y--;if(y===0)w(x);}ES(x,'forEach',true,function(aa){var ba={};for(var ca in aa.config)ba[ca]=aa.config[ca];ba.url=o.resolve('www',n.getSecure())+'/plugins/plugin_pipe_shell.php';ba.onload=z;j(ba);});z();}q.subscribe('parse',v);function w(x){var y=document.createElement('span');g.appendHidden(y);var z={};ES(x,'forEach',true,function(ea){z[ea.config.name]={plugin:ea.tag,params:ea.params};});var aa=ES('JSON','stringify',false,z),ba=k.encode(aa);ES(x,'forEach',true,function(ea){var fa=document.getElementsByName(ea.config.name)[0];fa.onload=ea.config.onload;});var ca=o.resolve('www',n.getSecure())+'/plugins/pipe.php',da=i();j({url:'about:blank',root:y,name:da,className:'fb_hidden fb_invisible',onload:function(){g.submitToTarget({url:ca,target:da,params:{plugins:ba.length-1)?n:l;});},isValid:function(){for(var k=this.dom;k;k=k.parentNode)if(k==document.body)return true;},clear:function(){g.html(this.dom,'');}},i);e.exports=j;},null); - __d("sdk.XFBML.IframeWidget",["sdk.Arbiter","sdk.Auth","sdk.Content","copyProperties","sdk.DOM","sdk.Event","sdk.XFBML.Element","guid","insertIframe","QueryString","sdk.Runtime","sdk.ui","UrlMap","sdk.XD"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u=m.extend({_iframeName:null,_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',_widgetPipeEnabled:false,_borderReset:false,_repositioned:false,getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){return this._iframeName;},getIframeTitle:function(){return 'Facebook Social Plugin';},getChannelUrl:function(){if(!this._channelUrl){var y=this;this._channelUrl=t.handler(function(z){y.fire('xd.'+z.type,z);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},arbiterInform:function(event,y,z){t.sendToFacebook(this.getIframeName(),{method:event,params:ES5('JSON','stringify',false,y||{}),behavior:z||g.BEHAVIOR_PERSISTENT});},_arbiterInform:function(event,y,z){var aa='parent.frames["'+this.getIframeNode().name+'"]';t.inform(event,y,aa,z);},getDefaultWebDomain:function(){return s.resolve('www');},process:function(y){if(this._done){if(!this._allowReProcess&&!y)return;this.clear();}else this._oneTimeSetup();this._done=true;this._iframeName=this.getIframeName()||this._iframeName||n();if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();k.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){k.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',ES5(this.fire,'bind',true,this,'render'));var z=this.getSize()||{},aa=this.getFullyQualifiedURL();if(z.width=='100%')k.addCss(this.dom,'fb_iframe_widget_fluid');this.clear();o({url:aa,root:this.dom.appendChild(document.createElement('span')),name:this._iframeName,title:this.getIframeTitle(),className:q.getRtl()?'fb_rtl':'fb_ltr',height:z.height,width:z.width,onload:ES5(this.fire,'bind',true,this,'iframe.onload')});this._resizeFlow(z);this.loaded=false;this.subscribe('iframe.onload',ES5(function(){this.loaded=true;},'bind',true,this));},generateWidgetPipeIframeName:function(){v++;return 'fb_iframe_'+v;},getFullyQualifiedURL:function(){var y=this._getURL();y+='?'+p.encode(this._getQS());if(y.length>2000){y='about:blank';var z=ES5(function(){this._postRequest();this.unsubscribe('iframe.onload',z);},'bind',true,this);this.subscribe('iframe.onload',z);}return y;},_getWidgetPipeShell:function(){return s.resolve('www')+'/common/widget_pipe_shell.php';},_oneTimeSetup:function(){this.subscribe('xd.resize',ES5(this._handleResizeMsg,'bind',true,this));this.subscribe('xd.resize',ES5(this._bubbleResizeEvent,'bind',true,this));this.subscribe('xd.resize.iframe',ES5(this._resizeIframe,'bind',true,this));this.subscribe('xd.resize.flow',ES5(this._resizeFlow,'bind',true,this));this.subscribe('xd.resize.flow',ES5(this._bubbleResizeEvent,'bind',true,this));this.subscribe('xd.refreshLoginStatus',function(){h.getLoginStatus(function(){},true);});this.subscribe('xd.logout',function(){r({method:'auth.logout',display:'hidden'},function(){});});if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',ES5(this._makeVisible,'bind',true,this));this.subscribe('xd.verify',ES5(function(y){this.arbiterInform('xd/verify',y.token);},'bind',true,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();k.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){h.getLoginStatus(ES5(function(y){var z=y.status;l.subscribe('auth.statusChange',ES5(function(aa){if(!this.isValid())return;if(z=='unknown'||aa.status=='unknown')this.process(true);z=aa.status;},'bind',true,this));},'bind',true,this));},_handleResizeMsg:function(y){if(!this.isValid())return;this._resizeIframe(y);this._resizeFlow(y);if(!this._borderReset){this.getIframeNode().style.border='none';this._borderReset=true;}this._makeVisible();},_bubbleResizeEvent:function(y){var z={height:y.height,width:y.width,pluginID:this.getAttribute('plugin-id')};l.fire('xfbml.resize',z);},_resizeIframe:function(y){var z=this.getIframeNode();if(y.reposition==="true")this._repositionIframe(y);y.height&&(z.style.height=y.height+'px');y.width&&(z.style.width=y.width+'px');this._updateIframeZIndex();},_resizeFlow:function(y){var z=this.dom.getElementsByTagName('span')[0];y.height&&(z.style.height=y.height+'px');y.width&&(z.style.width=y.width+'px');this._updateIframeZIndex();},_updateIframeZIndex:function(){var y=this.dom.getElementsByTagName('span')[0],z=this.getIframeNode(),aa=z.style.height===y.style.height&&z.style.width===y.style.width,ba=aa?'removeCss':'addCss';k[ba](z,'fb_iframe_widget_lift');},_repositionIframe:function(y){var z=this.getIframeNode(),aa=parseInt(k.getStyle(z,'width'),10),ba=k.getPosition(z).x,ca=k.getViewportInfo().width,da=parseInt(y.width,10);if(ba+da>ca&&ba>da){z.style.left=aa-da+'px';this.arbiterInform('xd/reposition',{type:'horizontal'});this._repositioned=true;}else if(this._repositioned){z.style.left='0px';this.arbiterInform('xd/reposition',{type:'restore'});this._repositioned=false;}},_addLoader:function(){if(!this._loaderDiv){k.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){k.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return j({api_key:q.getClientID(),locale:q.getLocale(),sdk:'joey',kid_directed_site:q.getKidDirectedSite(),ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var y=this.getDefaultWebDomain(),z='';return y+'/plugins/'+z+this.getUrlBits().name+'.php';},_postRequest:function(){i.submitToTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}),v=0,w={};function x(){var y={};for(var z in w){var aa=w[z];y[z]={widget:aa.getUrlBits().name,params:aa._getQS()};}return y;}e.exports=u;},null); - __d("sdk.XFBML.Comments",["sdk.Event","sdk.XFBML.IframeWidget","QueryString","sdk.Runtime","JSSDKConfig","UrlMap","UserAgent"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=h.extend({_visibleAfter:'immediate',_refreshOnAuthChange:true,setupAndValidate:function(){var o={channel_url:this.getChannelUrl(),colorscheme:this.getAttribute('colorscheme'),skin:this.getAttribute('skin'),numposts:this.getAttribute('num-posts',10),width:this._getLengthAttribute('width'),href:this.getAttribute('href'),permalink:this.getAttribute('permalink'),publish_feed:this.getAttribute('publish_feed'),order_by:this.getAttribute('order_by'),mobile:this._getBoolAttribute('mobile')};if(!o.width&&!o.permalink)o.width=550;if(k.initSitevars.enableMobileComments&&m.mobile()&&o.mobile!==false){o.mobile=true;delete o.width;}if(!o.skin)o.skin=o.colorscheme;if(!o.href){o.migrated=this.getAttribute('migrated');o.xid=this.getAttribute('xid');o.title=this.getAttribute('title',document.title);o.url=this.getAttribute('url',document.URL);o.quiet=this.getAttribute('quiet');o.reverse=this.getAttribute('reverse');o.simple=this.getAttribute('simple');o.css=this.getAttribute('css');o.notify=this.getAttribute('notify');if(!o.xid){var p=ES5(document.URL,'indexOf',true,'#');if(p>0){o.xid=encodeURIComponent(document.URL.substring(0,p));}else o.xid=encodeURIComponent(document.URL);}if(o.migrated)o.href=l.resolve('www')+'/plugins/comments_v1.php?'+'app_id='+j.getClientID()+'&xid='+encodeURIComponent(o.xid)+'&url='+encodeURIComponent(o.url);}else{var q=this.getAttribute('fb_comment_id');if(!q){q=i.decode(document.URL.substring(ES5(document.URL,'indexOf',true,'?')+1)).fb_comment_id;if(q&&ES5(q,'indexOf',true,'#')>0)q=q.substring(0,ES5(q,'indexOf',true,'#'));}if(q){o.fb_comment_id=q;this.subscribe('render',ES5(function(){if(!window.location.hash)window.location.hash=this.getIframeNode().id;},'bind',true,this));}}this._attr=o;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',ES5(this._handleCommentMsg,'bind',true,this));this.subscribe('xd.commentCreated',ES5(this._handleCommentCreatedMsg,'bind',true,this));this.subscribe('xd.commentRemoved',ES5(this._handleCommentRemovedMsg,'bind',true,this));},getSize:function(){if(!this._attr.permalink)return {width:this._attr.mobile?'100%':this._attr.width,height:160};},getUrlBits:function(){return {name:'comments',params:this._attr};},getDefaultWebDomain:function(){return l.resolve(this._attr.mobile?'m':'www',true);},_handleCommentMsg:function(o){if(!this.isValid())return;g.fire('comments.add',{post:o.post,user:o.user,widget:this});},_handleCommentCreatedMsg:function(o){if(!this.isValid())return;var p={href:o.href,commentID:o.commentID,parentCommentID:o.parentCommentID};g.fire('comment.create',p);},_handleCommentRemovedMsg:function(o){if(!this.isValid())return;var p={href:o.href,commentID:o.commentID};g.fire('comment.remove',p);}});e.exports=n;},null); - __d("mergeArrays",[],function(a,b,c,d,e,f){function g(h,i){for(var j=0;j-1)?n:l;});},isValid:function(){for(var k=this.dom;k;k=k.parentNode)if(k==document.body)return true;},clear:function(){g.html(this.dom,'');}},i);e.exports=j;},null); + __d("sdk.XFBML.IframeWidget",["sdk.Arbiter","sdk.Auth","sdk.Content","sdk.DOM","sdk.Event","sdk.XFBML.Element","guid","insertIframe","QueryString","sdk.Runtime","sdk.ui","UrlMap","sdk.XD"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){var t=l.extend({_iframeName:null,_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',_widgetPipeEnabled:false,_borderReset:false,_repositioned:false,getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){return this._iframeName;},getIframeTitle:function(){return 'Facebook Social Plugin';},getChannelUrl:function(){if(!this._channelUrl){var x=this;this._channelUrl=s.handler(function(y){x.fire('xd.'+y.type,y);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},arbiterInform:function(event,x,y){s.sendToFacebook(this.getIframeName(),{method:event,params:ES('JSON','stringify',false,x||{}),behavior:y||g.BEHAVIOR_PERSISTENT});},_arbiterInform:function(event,x,y){var z='parent.frames["'+this.getIframeNode().name+'"]';s.inform(event,x,z,y);},getDefaultWebDomain:function(){return r.resolve('www');},process:function(x){if(this._done){if(!this._allowReProcess&&!x)return;this.clear();}else this._oneTimeSetup();this._done=true;this._iframeName=this.getIframeName()||this._iframeName||m();if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();j.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){j.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',ES(this.fire,'bind',true,this,'render'));var y=this.getSize()||{},z=this.getFullyQualifiedURL();if(y.width=='100%')j.addCss(this.dom,'fb_iframe_widget_fluid');this.clear();n({url:z,root:this.dom.appendChild(document.createElement('span')),name:this._iframeName,title:this.getIframeTitle(),className:p.getRtl()?'fb_rtl':'fb_ltr',height:y.height,width:y.width,onload:ES(this.fire,'bind',true,this,'iframe.onload')});this._resizeFlow(y);this.loaded=false;this.subscribe('iframe.onload',ES(function(){this.loaded=true;if(!this._isResizeHandled)j.addCss(this.dom,'fb_hide_iframes');},'bind',true,this));},generateWidgetPipeIframeName:function(){u++;return 'fb_iframe_'+u;},getFullyQualifiedURL:function(){var x=this._getURL();x+='?'+o.encode(this._getQS());if(x.length>2000){x='about:blank';var y=ES(function(){this._postRequest();this.unsubscribe('iframe.onload',y);},'bind',true,this);this.subscribe('iframe.onload',y);}return x;},_getWidgetPipeShell:function(){return r.resolve('www')+'/common/widget_pipe_shell.php';},_oneTimeSetup:function(){this.subscribe('xd.resize',ES(this._handleResizeMsg,'bind',true,this));this.subscribe('xd.resize',ES(this._bubbleResizeEvent,'bind',true,this));this.subscribe('xd.resize.iframe',ES(this._resizeIframe,'bind',true,this));this.subscribe('xd.resize.flow',ES(this._resizeFlow,'bind',true,this));this.subscribe('xd.resize.flow',ES(this._bubbleResizeEvent,'bind',true,this));this.subscribe('xd.refreshLoginStatus',function(){h.getLoginStatus(function(){},true);});this.subscribe('xd.logout',function(){q({method:'auth.logout',display:'hidden'},function(){});});if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',ES(this._makeVisible,'bind',true,this));this.subscribe('xd.verify',ES(function(x){this.arbiterInform('xd/verify',x.token);},'bind',true,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();j.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){h.getLoginStatus(ES(function(x){var y=x.status;k.subscribe('auth.statusChange',ES(function(z){if(!this.isValid())return;if(y=='unknown'||z.status=='unknown')this.process(true);y=z.status;},'bind',true,this));},'bind',true,this));},_handleResizeMsg:function(x){if(!this.isValid())return;this._resizeIframe(x);this._resizeFlow(x);if(!this._borderReset){this.getIframeNode().style.border='none';this._borderReset=true;}this._isResizeHandled=true;this._makeVisible();},_bubbleResizeEvent:function(x){var y={height:x.height,width:x.width,pluginID:this.getAttribute('plugin-id')};k.fire('xfbml.resize',y);},_resizeIframe:function(x){var y=this.getIframeNode();if(x.reposition==="true")this._repositionIframe(x);x.height&&(y.style.height=x.height+'px');x.width&&(y.style.width=x.width+'px');this._updateIframeZIndex();},_resizeFlow:function(x){var y=this.dom.getElementsByTagName('span')[0];x.height&&(y.style.height=x.height+'px');x.width&&(y.style.width=x.width+'px');this._updateIframeZIndex();},_updateIframeZIndex:function(){var x=this.dom.getElementsByTagName('span')[0],y=this.getIframeNode(),z=y.style.height===x.style.height&&y.style.width===x.style.width,aa=z?'removeCss':'addCss';j[aa](y,'fb_iframe_widget_lift');},_repositionIframe:function(x){var y=this.getIframeNode(),z=parseInt(j.getStyle(y,'width'),10),aa=j.getPosition(y).x,ba=j.getViewportInfo().width,ca=parseInt(x.width,10);if(aa+ca>ba&&aa>ca){y.style.left=z-ca+'px';this.arbiterInform('xd/reposition',{type:'horizontal'});this._repositioned=true;}else if(this._repositioned){y.style.left='0px';this.arbiterInform('xd/reposition',{type:'restore'});this._repositioned=false;}},_addLoader:function(){if(!this._loaderDiv){j.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){j.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return ES('Object','assign',false,{api_key:p.getClientID(),locale:p.getLocale(),sdk:'joey',kid_directed_site:p.getKidDirectedSite(),ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var x=this.getDefaultWebDomain(),y='';return x+'/plugins/'+y+this.getUrlBits().name+'.php';},_postRequest:function(){i.submitToTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}),u=0,v={};function w(){var x={};for(var y in v){var z=v[y];x[y]={widget:z.getUrlBits().name,params:z._getQS()};}return x;}e.exports=t;},null); + __d("sdk.XFBML.Comments",["sdk.Event","sdk.XFBML.IframeWidget","QueryString","sdk.Runtime","JSSDKConfig","UrlMap","UserAgent_DEPRECATED"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=h.extend({_visibleAfter:'immediate',_refreshOnAuthChange:true,setupAndValidate:function(){var o={channel_url:this.getChannelUrl(),colorscheme:this.getAttribute('colorscheme'),skin:this.getAttribute('skin'),numposts:this.getAttribute('num-posts',10),width:this._getLengthAttribute('width'),href:this.getAttribute('href'),permalink:this.getAttribute('permalink'),publish_feed:this.getAttribute('publish_feed'),order_by:this.getAttribute('order_by'),mobile:this._getBoolAttribute('mobile')};if(!o.width&&!o.permalink)o.width=550;if(k.initSitevars.enableMobileComments&&m.mobile()&&o.mobile!==false){o.mobile=true;delete o.width;}if(!o.skin)o.skin=o.colorscheme;if(!o.href){o.migrated=this.getAttribute('migrated');o.xid=this.getAttribute('xid');o.title=this.getAttribute('title',document.title);o.url=this.getAttribute('url',document.URL);o.quiet=this.getAttribute('quiet');o.reverse=this.getAttribute('reverse');o.simple=this.getAttribute('simple');o.css=this.getAttribute('css');o.notify=this.getAttribute('notify');if(!o.xid){var p=ES(document.URL,'indexOf',true,'#');if(p>0){o.xid=encodeURIComponent(document.URL.substring(0,p));}else o.xid=encodeURIComponent(document.URL);}if(o.migrated)o.href=l.resolve('www')+'/plugins/comments_v1.php?'+'app_id='+j.getClientID()+'&xid='+encodeURIComponent(o.xid)+'&url='+encodeURIComponent(o.url);}else{var q=this.getAttribute('fb_comment_id');if(!q){q=i.decode(document.URL.substring(ES(document.URL,'indexOf',true,'?')+1)).fb_comment_id;if(q&&ES(q,'indexOf',true,'#')>0)q=q.substring(0,ES(q,'indexOf',true,'#'));}if(q){o.fb_comment_id=q;this.subscribe('render',ES(function(){if(!window.location.hash)window.location.hash=this.getIframeNode().id;},'bind',true,this));}}this._attr=o;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',ES(this._handleCommentMsg,'bind',true,this));this.subscribe('xd.commentCreated',ES(this._handleCommentCreatedMsg,'bind',true,this));this.subscribe('xd.commentRemoved',ES(this._handleCommentRemovedMsg,'bind',true,this));},getSize:function(){if(!this._attr.permalink)return {width:this._attr.mobile?'100%':this._attr.width,height:160};},getUrlBits:function(){return {name:'comments',params:this._attr};},getDefaultWebDomain:function(){return l.resolve(this._attr.mobile?'m':'www',true);},_handleCommentMsg:function(o){if(!this.isValid())return;g.fire('comments.add',{post:o.post,user:o.user,widget:this});},_handleCommentCreatedMsg:function(o){if(!this.isValid())return;var p={href:o.href,commentID:o.commentID,parentCommentID:o.parentCommentID,message:o.message};g.fire('comment.create',p);},_handleCommentRemovedMsg:function(o){if(!this.isValid())return;var p={href:o.href,commentID:o.commentID};g.fire('comment.remove',p);}});e.exports=n;},null); + __d("sdk.XFBML.CommentsCount",["ApiClient","sdk.DOM","sdk.XFBML.Element","sprintf"],function(a,b,c,d,e,f,g,h,i,j){var k=i.extend({process:function(){h.addCss(this.dom,'fb_comments_count_zero');var l=this.getAttribute('href',window.location.href);g.scheduleBatchCall('/v2.1/'+encodeURIComponent(l),{fields:'share'},ES(function(m){var n=(m.share&&m.share.comment_count)||0;h.html(this.dom,j('%s',n));if(n>0)h.removeCss(this.dom,'fb_comments_count_zero');this.fire('render');},'bind',true,this));}});e.exports=k;},null); __d("safeEval",[],function(a,b,c,d,e,f){function g(h,i){if(h===null||typeof h==='undefined')return;if(typeof h!=='string')return h;if(/^\w+$/.test(h)&&typeof window[h]==='function')return window[h].apply(null,i||[]);return Function('return eval("'+h.replace(/"/g,'\\"')+'");').apply(null,i||[]);}e.exports=g;},null); - __d("sdk.Waitable",["sdk.Model"],function(a,b,c,d,e,f,g){var h=g.extend({constructor:function(){this.parent({Value:undefined});},error:function(i){this.inform("error",i);},wait:function(i,j){if(j)this.subscribe('error',j);this.monitor('Value.change',ES5(function(){var k=this.getValue();if(k!==undefined){this.value=k;i(k);return true;}},'bind',true,this));}});e.exports=h;},null); - __d("sdk.Query",["format","safeEval","Type","sdk.Waitable"],function(a,b,c,d,e,f,g,h,i,j){function k(p){return ES5(p.split(','),'map',true,function(q){return ES5(q,'trim',true);});}function l(p){var q=(/^\s*(\w+)\s*=\s*(.*)\s*$/i).exec(p),r,s,t='unknown';if(q){s=q[2];if(/^(["'])(?:\\?.)*?\1$/.test(s)){s=h(s);t='index';}else if(/^\d+\.?\d*$/.test(s))t='index';}if(t=='index'){r={type:'index',key:q[1],value:s};}else r={type:'unknown',value:p};return r;}function m(p){return typeof p==='string'?ES5('JSON','stringify',false,p):p;}var n=1,o=j.extend({constructor:function(){this.parent();this.name='v_'+n++;},hasDependency:function(p){if(arguments.length)this._hasDependency=p;return !!this._hasDependency;},parse:function(p){var q=g.apply(null,p),r=(/^select (.*?) from (\w+)\s+where (.*)$/i).exec(q);this.fields=k(r[1]);this.table=r[2];this.where=l(r[3]);for(var s=1;s%s',n));if(n>0)h.removeCss(this.dom,'fb_comments_count_zero');this.fire('render');},'bind',true,this));}});e.exports=k;},null); - __d("sdk.Anim",["sdk.DOM"],function(a,b,c,d,e,f,g){var h={ate:function(i,j,k,l){k=!isNaN(parseFloat(k))&&k>=0?k:750;var m=40,n={},o={},p=null,q=setInterval(ES5(function(){if(!p)p=ES5('Date','now',false);var r=1;if(k!=0)r=Math.min((ES5('Date','now',false)-p)/k,1);for(var s in j)if(j.hasOwnProperty(s)){var t=j[s];if(!n[s]){var u=g.getStyle(i,s);if(u===false)return;n[s]=this._parseCSS(u+'');}if(!o[s])o[s]=this._parseCSS(t.toString());var v='';ES5(n[s],'forEach',true,function(w,x){if(isNaN(o[s][x].numPart)&&o[s][x].textPart=='?'){v=w.numPart+w.textPart;}else if(isNaN(w.numPart)){v=w.textPart;}else v+=(w.numPart+Math.ceil((o[s][x].numPart-w.numPart)*Math.sin(Math.PI/2*r)))+o[s][x].textPart+' ';});g.setStyle(i,s,v);}if(r==1){clearInterval(q);if(l)l(i);}},'bind',true,this),m);},_parseCSS:function(i){var j=[];ES5(i.split(' '),'forEach',true,function(k){var l=parseInt(k,10);j.push({numPart:l,textPart:k.replace(l,'')});});return j;}};e.exports=h;},null); - __d("escapeHTML",[],function(a,b,c,d,e,f){var g=/[&<>"'\/]/g,h={'&':'&','<':'<','>':'>','"':'"',"'":''','/':'/'};function i(j){return j.replace(g,function(k){return h[k];});}e.exports=i;},null); __d("sdk.Helper",["sdk.ErrorHandling","sdk.Event","UrlMap","safeEval","sprintf"],function(a,b,c,d,e,f,g,h,i,j,k){var l={isUser:function(m){return m<2.2e+09||(m>=1e+14&&m<=100099999989999)||(m>=8.9e+13&&m<=89999999999999);},upperCaseFirstChar:function(m){if(m.length>0){return m.substr(0,1).toUpperCase()+m.substr(1);}else return m;},getProfileLink:function(m,n,o){if(!o&&m)o=k('%s/profile.php?id=%s',i.resolve('www'),m.uid||m.id);if(o)n=k('%s',o,n);return n;},invokeHandler:function(m,n,o){if(m)if(typeof m==='string'){g.unguard(j)(m,o);}else if(m.apply)g.unguard(m).apply(n,o||[]);},fireEvent:function(m,n){var o=n._attr.href;n.fire(m,o);h.fire(m,o,n);},executeFunctionByName:function(m){var n=Array.prototype.slice.call(arguments,1),o=m.split("."),p=o.pop(),q=window;for(var r=0;r'+''+'{2}'+''+''+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',t.tx._("\u4e0d\uff0c\u8c22\u8c22"),v.resolve('fbcdn')+'/'+k.imgs.buttonUrl,t.tx._("\u5173\u95ed"),y[this._picFieldName]||v.resolve('fbcdn')+'/'+k.imgs.missingProfileUrl,o(y.first_name),t.tx._("\u4f60\u597d\uff0c{firstName}\u3002\u003Cstrong>{siteName}\u003C\/strong>\u6b63\u5728\u4f7f\u7528 Facebook \u4e2a\u6027\u5316\u4f60\u7684\u4f53\u9a8c\u3002",{firstName:o(y.first_name),siteName:o(y.site_name)}),t.tx._("\u4e86\u89e3\u66f4\u591a"),y.profile_url,v.resolve('www')+'/sitetour/connect.php'));ES5(j(z.getElementsByTagName('a')),'forEach',true,function(da){da.onclick=ES5(this._clickHandler,'bind',true,this);},this);this._page=document.body;var ba=0;if(this._page.parentNode){ba=Math.round((parseFloat(m.getStyle(this._page.parentNode,'height'))-parseFloat(m.getStyle(this._page,'height')))/2);}else ba=parseInt(m.getStyle(this._page,'marginTop'),10);ba=isNaN(ba)?0:ba;this._initTopMargin=ba;if(!window.XMLHttpRequest){aa.className+=" fb_connect_bar_container_ie6";}else{aa.style.top=(-1*this._initialHeight)+'px';g.ate(aa,{top:'0px'},this._animationSpeed);}var ca={marginTop:this._initTopMargin+this._initialHeight+'px'};if(w.ie()){ca.backgroundPositionY=this._initialHeight+'px';}else ca.backgroundPosition='? '+this._initialHeight+'px';g.ate(this._page,ca,this._animationSpeed);},_clickHandler:function(y){y=y||window.event;var z=y.target||y.srcElement;while(z.nodeName!='A')z=z.parentNode;switch(z.className){case 'fb_bar_close':h({method:'Connect.connectBarMarkAcknowledged'});s.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(z.href);break;case 'fb_no_thanks':this._closeConnectBar();h({method:'Connect.connectBarMarkAcknowledged'});s.impression({lid:104,name:'widget_user_no_thanks'});h({method:'auth.revokeAuthorization',block:true},ES5(function(){this.fire('connectbar.ondeauth');p.fire('connectbar.ondeauth',this);r.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();},'bind',true,this));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var y={marginTop:this._initTopMargin+'px'};if(w.ie()){y.backgroundPositionY='0px';}else y.backgroundPosition='? 0px';var z=(this._animationSpeed==0)?0:300;g.ate(this._page,y,z);g.ate(this._container,{top:(-1*this._initialHeight)+'px'},z,function(aa){aa.parentNode.removeChild(aa);});this.fire('connectbar.onclose');p.fire('connectbar.onclose',this);r.invokeHandler(this.getAttribute('on-close'),this);}});e.exports=x;},null); - __d("sdk.XFBML.LoginButton",["sdk.Helper","IframePlugin"],function(a,b,c,d,e,f,g,h){var i=h.extend({constructor:function(j,k,l,m){this.parent(j,k,l,m);var n=h.getVal(m,'on_login');if(n)this.subscribe('login.status',function(o){g.invokeHandler(n,null,[o]);});},getParams:function(){return {scope:'string',perms:'string',size:'string',login_text:'text',show_faces:'bool',max_rows:'string',show_login_face:'bool',registration_url:'url_maybe',auto_logout_link:'bool',one_click:'bool',show_banner:'bool',auth_type:'string'};}});e.exports=i;},null); - __d("sdk.XFBML.Name",["copyProperties","sdk.Data","escapeHTML","sdk.Event","sdk.XFBML.Element","sdk.Helper","Log","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=k.extend({process:function(){g(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){m.error('"uid" is a required attribute for ');this.fire('render');return;}var p=[];if(this._firstnameonly){p.push('first_name');}else if(this._lastnameonly){p.push('last_name');}else p.push('name');if(this._subjectId){p.push('sex');if(this._subjectId==n.getUserID())this._reflexive=true;}var q;j.monitor('auth.statusChange',ES5(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=n.getUserID();if(!this._uid)return;if(l.isUser(this._uid)){q=h._selectByIndex(p,'user','uid',this._uid);}else q=h._selectByIndex(['name','id'],'profile','id',this._uid);q.wait(ES5(function(r){if(this._subjectId==this._uid){this._renderPronoun(r[0]);}else this._renderOther(r[0]);this.fire('render');},'bind',true,this));},'bind',true,this));},_renderPronoun:function(p){var q='',r=this._objective;if(this._subjectId){r=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==n.getUserID()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){q='your own';}else q='your';}else if(this._reflexive){q='yourself';}else q='you';}else switch(p.sex){case 'male':if(this._possessive){q=this._reflexive?'his own':'his';}else if(this._reflexive){q='himself';}else if(r){q='him';}else q='he';break;case 'female':if(this._possessive){q=this._reflexive?'her own':'her';}else if(this._reflexive){q='herself';}else if(r){q='her';}else q='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){q='their own';}else q='their';}else if(this._reflexive){q='themselves';}else if(r){q='them';}else q='they';}else if(this._possessive){if(this._reflexive){q='his/her own';}else q='his/her';}else if(this._reflexive){q='himself/herself';}else if(r){q='him/her';}else q='he/she';break;}if(this._getBoolAttribute('capitalize',false))q=l.upperCaseFirstChar(q);this.dom.innerHTML=q;},_renderOther:function(p){var q='',r='';if(this._uid==n.getUserID()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){q='your own';}else q='yourself';}else if(this._possessive){q='your';}else q='you';}else if(p){if(null===p.first_name)p.first_name='';if(null===p.last_name)p.last_name='';if(this._firstnameonly&&p.first_name!==undefined){q=i(p.first_name);}else if(this._lastnameonly&&p.last_name!==undefined)q=i(p.last_name);if(!q)q=i(p.name);if(q!==''&&this._possessive)q+='\'s';}if(!q)q=i(this.getAttribute('if-cant-see','Facebook User'));if(q){if(this._getBoolAttribute('capitalize',false))q=l.upperCaseFirstChar(q);if(p&&this._linked){r=l.getProfileLink(p,q,this.getAttribute('href',null));}else r=q;}this.dom.innerHTML=r;}});e.exports=o;},null); - __d("sdk.XFBML.RecommendationsBar",["sdk.Arbiter","DOMEventListener","sdk.Event","sdk.XFBML.IframeWidget","resolveURI","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=j.extend({getUrlBits:function(){return {name:'recommendations_bar',params:this._attr};},setupAndValidate:function(){function n(w,x){var y=0,z=null;function aa(){x();z=null;y=ES5('Date','now',false);}return function(){if(!z){var ba=ES5('Date','now',false);if(ba-y=this._attr.trigger;}}});e.exports=m;},null); - __d("sdk.XFBML.Registration",["sdk.Auth","sdk.Helper","sdk.XFBML.IframeWidget","sdk.Runtime","UrlMap"],function(a,b,c,d,e,f,g,h,i,j,k){var l=i.extend({_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={action:this.getAttribute('action'),border_color:this.getAttribute('border-color'),channel_url:this.getChannelUrl(),client_id:j.getClientID(),fb_only:this._getBoolAttribute('fb-only',false),fb_register:this._getBoolAttribute('fb-register',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),no_footer:this._getBoolAttribute('no-footer'),no_header:this._getBoolAttribute('no-header'),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600),target:this.getAttribute('target')};if(this._attr.onvalidate)this.subscribe('xd.validate',ES5(function(m){var n=ES5('JSON','parse',false,m.value),o=ES5(function(q){this.arbiterInform('Registration.Validation',{errors:q,id:m.id});},'bind',true,this),p=h.executeFunctionByName(this._attr.onvalidate,n,o);if(p)o(p);},'bind',true,this));this.subscribe('xd.authLogin',ES5(this._onAuthLogin,'bind',true,this));this.subscribe('xd.authLogout',ES5(this._onAuthLogout,'bind',true,this));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var m;if(!this._attr.fields){m=['name'];}else try{m=ES5('JSON','parse',false,this._attr.fields);}catch(n){m=this._attr.fields.split(/,/);}if(this._attr.width"'\/]/g,h={'&':'&','<':'<','>':'>','"':'"',"'":''','/':'/'};function i(j){return j.replace(g,function(k){return h[k];});}e.exports=i;},null); + __d("sdk.XFBML.Name",["ApiClient","escapeHTML","sdk.Event","sdk.XFBML.Element","sdk.Helper","Log","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=({}).hasOwnProperty,o=j.extend({process:function(){ES('Object','assign',false,this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){l.error('"uid" is a required attribute for ');this.fire('render');return;}var p=[];if(this._firstnameonly){p.push('first_name');}else if(this._lastnameonly){p.push('last_name');}else p.push('name');if(this._subjectId){p.push('gender');if(this._subjectId==m.getUserID())this._reflexive=true;}i.monitor('auth.statusChange',ES(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=m.getUserID();if(!this._uid)return;g.scheduleBatchCall('/v1.0/'+this._uid,{fields:p.join(',')},ES(function(q){if(n.call(q,'error')){l.warn('The name is not found for ID: '+this._uid);return;}if(this._subjectId==this._uid){this._renderPronoun(q);}else this._renderOther(q);this.fire('render');},'bind',true,this));},'bind',true,this));},_renderPronoun:function(p){var q='',r=this._objective;if(this._subjectId){r=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==m.getUserID()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){q='your own';}else q='your';}else if(this._reflexive){q='yourself';}else q='you';}else switch(p.gender){case 'male':if(this._possessive){q=this._reflexive?'his own':'his';}else if(this._reflexive){q='himself';}else if(r){q='him';}else q='he';break;case 'female':if(this._possessive){q=this._reflexive?'her own':'her';}else if(this._reflexive){q='herself';}else if(r){q='her';}else q='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){q='their own';}else q='their';}else if(this._reflexive){q='themselves';}else if(r){q='them';}else q='they';}else if(this._possessive){if(this._reflexive){q='his/her own';}else q='his/her';}else if(this._reflexive){q='himself/herself';}else if(r){q='him/her';}else q='he/she';break;}if(this._getBoolAttribute('capitalize',false))q=k.upperCaseFirstChar(q);this.dom.innerHTML=q;},_renderOther:function(p){var q='',r='';if(this._uid==m.getUserID()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){q='your own';}else q='yourself';}else if(this._possessive){q='your';}else q='you';}else if(p){if(null===p.first_name)p.first_name='';if(null===p.last_name)p.last_name='';if(this._firstnameonly&&p.first_name!==undefined){q=h(p.first_name);}else if(this._lastnameonly&&p.last_name!==undefined)q=h(p.last_name);if(!q)q=h(p.name);if(q!==''&&this._possessive)q+='\'s';}if(!q)q=h(this.getAttribute('if-cant-see','Facebook User'));if(q){if(this._getBoolAttribute('capitalize',false))q=k.upperCaseFirstChar(q);if(p&&this._linked){r=k.getProfileLink(p,q,this.getAttribute('href',null));}else r=q;}this.dom.innerHTML=r;}});e.exports=o;},null); + __d("sdk.XFBML.RecommendationsBar",["sdk.Arbiter","DOMEventListener","sdk.Event","sdk.XFBML.IframeWidget","resolveURI","sdk.Runtime"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=j.extend({getUrlBits:function(){return {name:'recommendations_bar',params:this._attr};},setupAndValidate:function(){function n(w,x){var y=0,z=null;function aa(){x();z=null;y=ES('Date','now',false);}return function(){if(!z){var ba=ES('Date','now',false);if(ba-y=this._attr.trigger;}}});e.exports=m;},null); + __d("sdk.XFBML.Registration",["sdk.Auth","sdk.Helper","sdk.XFBML.IframeWidget","sdk.Runtime","UrlMap"],function(a,b,c,d,e,f,g,h,i,j,k){var l=i.extend({_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={action:this.getAttribute('action'),border_color:this.getAttribute('border-color'),channel_url:this.getChannelUrl(),client_id:j.getClientID(),fb_only:this._getBoolAttribute('fb-only',false),fb_register:this._getBoolAttribute('fb-register',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),no_footer:this._getBoolAttribute('no-footer'),no_header:this._getBoolAttribute('no-header'),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600),target:this.getAttribute('target')};if(this._attr.onvalidate)this.subscribe('xd.validate',ES(function(m){var n=ES('JSON','parse',false,m.value),o=ES(function(q){this.arbiterInform('Registration.Validation',{errors:q,id:m.id});},'bind',true,this),p=h.executeFunctionByName(this._attr.onvalidate,n,o);if(p)o(p);},'bind',true,this));this.subscribe('xd.authLogin',ES(this._onAuthLogin,'bind',true,this));this.subscribe('xd.authLogout',ES(this._onAuthLogout,'bind',true,this));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var m;if(!this._attr.fields){m=['name'];}else try{m=ES('JSON','parse',false,this._attr.fields);}catch(n){m=this._attr.fields.split(/,/);}if(this._attr.width Date: Mon, 29 Sep 2014 11:49:37 +0800 Subject: [PATCH 0706/1564] Issue #5933: Armature update and Layout clipping --- cocos2d/core/renderer/RendererCanvas.js | 2 +- extensions/ccui/layouts/UILayout.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 18 ++++++++++++++++++ .../armature/display/CCDisplayManager.js | 4 +++- .../armature/physics/CCColliderDetector.js | 6 ++++-- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 74b4c2bf7b..a47dc036a6 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -293,7 +293,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," + Math.round(locStartColor.b) + "," + (opacity * (locStartColor.a / 255)).toFixed(4) + ")"); gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," - + Math.round(locEndColor.b) + "," + (opacity * (locEndColor.a / 255)).toFixed(4) + ")"); + + Math.round(locEndColor.b) + "," + (locEndColor.a!=null?(opacity * (locEndColor.a / 255)).toFixed(4):255) + ")"); context.fillStyle = gradient; context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 9329d34582..a2619c8a36 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -610,7 +610,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (able){ this._clippingStencil = cc.DrawNode.create(); if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._clippingStencil.draw = this.__stencilDraw.bind(this); + this._clippingStencil._rendererCmd.rendering = this.__stencilDraw.bind(this); if (this._running) this._clippingStencil.onEnter(); this._setStencilClippingSize(this._contentSize); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 621f82cc59..9322e256c8 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -725,6 +725,24 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ */ setVersion: function (version) { this.version = version; + }, + + _transformForRenderer: function(){ + + ccs.Node.prototype._transformForRenderer.call(this); + + var locChildren = this._children; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + node._transformForRenderer(); + } + } } }); diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index e2acca4bbe..edbed8e513 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -236,7 +236,6 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ return; } this.setCurrentDecorativeDisplay(this._decoDisplayList[index]); - cc.renderer.childrenOrderDirty = true; }, /** @@ -301,6 +300,9 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this._displayType = this._currentDecoDisplay.getDisplayData().displayType; }else this._displayType = ccs.DISPLAY_TYPE_MAX; + + + cc.renderer.childrenOrderDirty = true; }, /** diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index 6b366bde77..5666fde916 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -331,8 +331,10 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ 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; - shape.axes[j].d = cp.v.dot(n, shape.verts[j]); + if(shape.axes){ + shape.axes[j].n = n; + shape.axes[j].d = cp.v.dot(n, shape.verts[j]); + } // var b = shape.verts[(i + 1) % shape.numVerts]; // var n = cp.v.normalize(cp.v.perp(cp.v.sub(b, shape.verts[i]))); // From 6a5c5c89ec2835fc85c09f52e51816bf7f97f432 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 29 Sep 2014 15:14:55 +0800 Subject: [PATCH 0707/1564] Issue #5933: EditBox --- .../gui/control-extension/CCScale9Sprite.js | 123 +++++++++--------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index bb59f21734..f674da5cd1 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -27,27 +27,6 @@ Created by Jung Sang-Taik on 2012-03-16 ****************************************************************************/ -cc.Scale9SpriteStartCanvasCmd = function(node){ - this._node = node; -}; - -cc.Scale9SpriteStartCanvasCmd.prototype.rendering = function(ctx){ - ctx = ctx || cc._renderContext; - - var p = this._node._transformWorld; - ctx.save(); - ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); -}; - -cc.Scale9SpriteEndCanvasCmd = function(node){ - this._node = node; -}; - -cc.Scale9SpriteEndCanvasCmd.prototype.rendering = function(ctx){ - ctx = ctx || cc._renderContext; - ctx.restore(); -}; - /** * A 9-slice sprite for cocos2d. * @@ -238,10 +217,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ contentSizeChanged = true; } - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); - } - //cc._renderContext = this._cacheContext; cc.view._setScaleXYForRenderTexture(); this._scale9Image.visit(this._cacheContext); @@ -256,7 +231,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, /** - * The constructor of cc.Scale9Sprite. Override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @function * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame * @param {cc.Rect} rect * @param {cc.Rect} capInsets @@ -272,12 +248,20 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._capInsets = cc.rect(0, 0, 0, 0); this._loadedEventListeners = []; - //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererCmd = new cc.Scale9SpriteEndCanvasCmd(this); - this._rendererStartCanvasCmd = new cc.Scale9SpriteStartCanvasCmd(this); + this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + ctx = ctx || cc._renderContext; + + var p = this._transformWorld; + ctx.save(); + ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); + }); + this._rendererEndCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + ctx = ctx || cc._renderContext; + ctx.restore(); + }); var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); locCacheCanvas.width = 1; @@ -322,6 +306,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ return this._preferredSize.height; }, setPreferredSize: function (preferredSize) { + + if (this._positionsAreDirty) { + this._updatePositions(); + this._positionsAreDirty = false; + this._scale9Dirty = true; + } + + this.setContentSize(preferredSize); this._preferredSize = preferredSize; }, @@ -392,7 +384,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ parentColor.r !== 255 || parentColor.g !== 255 || parentColor.b !== 255 - ){ + ){ selChild._changeTextureColor(); selChild._setNodeDirtyForCache(); } @@ -508,18 +500,31 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, visit: function (ctx) { + if(!this._visible){ + return; + } + if (this._positionsAreDirty) { this._updatePositions(); this._positionsAreDirty = false; this._scale9Dirty = true; } - if(this._scale9Dirty && cc._renderType === cc._RENDER_TYPE_CANVAS){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); this._scale9Dirty = false; this._cacheScale9Sprite(); + + cc.Node.prototype.visit.call(this, ctx); + cc.renderer.pushRenderCommand(this._rendererEndCanvasCmd); + }else{ + cc.Node.prototype.visit.call(this, ctx); } - cc.Node.prototype.visit.call(this, ctx); }, + /** + * Initializes a ccui.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * @returns {boolean} + */ init: function () { return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); }, @@ -570,7 +575,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } if(!file) - throw "cc.Scale9Sprite.initWithFile(): file should be non-null"; + throw "ccui.Scale9Sprite.initWithFile(): file should be non-null"; var texture = cc.textureCache.getTextureForKey(file); if (!texture) { @@ -607,7 +612,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ */ initWithSpriteFrame: function (spriteFrame, capInsets) { if(!spriteFrame || !spriteFrame.getTexture()) - throw "cc.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null"; + throw "ccui.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null"; capInsets = capInsets || cc.rect(0, 0, 0, 0); var locLoaded = spriteFrame.textureLoaded(); @@ -640,12 +645,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ */ initWithSpriteFrameName: function (spriteFrameName, capInsets) { if(!spriteFrameName) - throw "cc.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null"; + throw "ccui.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null"; capInsets = capInsets || cc.rect(0, 0, 0, 0); var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); if (frame == null) { - cc.log("cc.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"); + cc.log("ccui.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"); return false; } @@ -661,7 +666,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * @param {cc.Rect} capInsets The values to use for the cap insets. */ resizableSpriteWithCapInsets: function (capInsets) { - var pReturn = new cc.Scale9Sprite(); + var pReturn = new ccui.Scale9Sprite(); if (pReturn && pReturn.initWithBatchNode(this._scale9Image, this._spriteRect, false, capInsets)) return pReturn; return null; @@ -848,47 +853,47 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Centre this._centre = new cc.Sprite(); this._centre.initWithTexture(selTexture, centerbounds); - locScale9Image.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE); + locScale9Image.addChild(this._centre, 0, ccui.Scale9Sprite.POSITIONS_CENTRE); // Top this._top = new cc.Sprite(); this._top.initWithTexture(selTexture, centertopbounds); - locScale9Image.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP); + locScale9Image.addChild(this._top, 1, ccui.Scale9Sprite.POSITIONS_TOP); // Bottom this._bottom = new cc.Sprite(); this._bottom.initWithTexture(selTexture, centerbottombounds); - locScale9Image.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM); + locScale9Image.addChild(this._bottom, 1, ccui.Scale9Sprite.POSITIONS_BOTTOM); // Left this._left = new cc.Sprite(); this._left.initWithTexture(selTexture, leftcenterbounds); - locScale9Image.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT); + locScale9Image.addChild(this._left, 1, ccui.Scale9Sprite.POSITIONS_LEFT); // Right this._right = new cc.Sprite(); this._right.initWithTexture(selTexture, rightcenterbounds); - locScale9Image.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT); + locScale9Image.addChild(this._right, 1, ccui.Scale9Sprite.POSITIONS_RIGHT); // Top left this._topLeft = new cc.Sprite(); this._topLeft.initWithTexture(selTexture, lefttopbounds); - locScale9Image.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT); + locScale9Image.addChild(this._topLeft, 2, ccui.Scale9Sprite.POSITIONS_TOPLEFT); // Top right this._topRight = new cc.Sprite(); this._topRight.initWithTexture(selTexture, righttopbounds); - locScale9Image.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT); + locScale9Image.addChild(this._topRight, 2, ccui.Scale9Sprite.POSITIONS_TOPRIGHT); // Bottom left this._bottomLeft = new cc.Sprite(); this._bottomLeft.initWithTexture(selTexture, leftbottombounds); - locScale9Image.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT); + locScale9Image.addChild(this._bottomLeft, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMLEFT); // Bottom right this._bottomRight = new cc.Sprite(); this._bottomRight.initWithTexture(selTexture, rightbottombounds); - locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT); + locScale9Image.addChild(this._bottomRight, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT); } else { // set up transformation of coordinates // to handle the case where the sprite is stored rotated @@ -947,56 +952,52 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Centre this._centre = new cc.Sprite(); this._centre.initWithTexture(selTexture, rotatedcenterbounds, true); - locScale9Image.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE); + locScale9Image.addChild(this._centre, 0, ccui.Scale9Sprite.POSITIONS_CENTRE); // Top this._top = new cc.Sprite(); this._top.initWithTexture(selTexture, rotatedcentertopbounds, true); - locScale9Image.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP); + locScale9Image.addChild(this._top, 1, ccui.Scale9Sprite.POSITIONS_TOP); // Bottom this._bottom = new cc.Sprite(); this._bottom.initWithTexture(selTexture, rotatedcenterbottombounds, true); - locScale9Image.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM); + locScale9Image.addChild(this._bottom, 1, ccui.Scale9Sprite.POSITIONS_BOTTOM); // Left this._left = new cc.Sprite(); this._left.initWithTexture(selTexture, rotatedleftcenterbounds, true); - locScale9Image.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT); + locScale9Image.addChild(this._left, 1, ccui.Scale9Sprite.POSITIONS_LEFT); // Right this._right = new cc.Sprite(); this._right.initWithTexture(selTexture, rotatedrightcenterbounds, true); - locScale9Image.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT); + locScale9Image.addChild(this._right, 1, ccui.Scale9Sprite.POSITIONS_RIGHT); // Top left this._topLeft = new cc.Sprite(); this._topLeft.initWithTexture(selTexture, rotatedlefttopbounds, true); - locScale9Image.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT); + locScale9Image.addChild(this._topLeft, 2, ccui.Scale9Sprite.POSITIONS_TOPLEFT); // Top right this._topRight = new cc.Sprite(); this._topRight.initWithTexture(selTexture, rotatedrighttopbounds, true); - locScale9Image.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT); + locScale9Image.addChild(this._topRight, 2, ccui.Scale9Sprite.POSITIONS_TOPRIGHT); // Bottom left this._bottomLeft = new cc.Sprite(); this._bottomLeft.initWithTexture(selTexture, rotatedleftbottombounds, true); - locScale9Image.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT); + locScale9Image.addChild(this._bottomLeft, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMLEFT); // Bottom right this._bottomRight = new cc.Sprite(); this._bottomRight.initWithTexture(selTexture, rotatedrightbottombounds, true); - locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT); + locScale9Image.addChild(this._bottomRight, 2, ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT); } this.setContentSize(rect.width, rect.height); - if(cc._renderType === cc._RENDER_TYPE_WEBGL){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) this.addChild(locScale9Image); - }else{ - if(!this._cacheSprite.getParent()) - this.addChild(this._cacheSprite); - } if (this._spritesGenerated) { // Restore color and opacity @@ -1008,7 +1009,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, /** - * set the sprite frame of cc.Scale9Sprite + * set the sprite frame of ccui.Scale9Sprite * @param {cc.SpriteFrame} spriteFrame */ setSpriteFrame: function (spriteFrame) { From e2734d5495dbc3900696715a8ba69d48e8057ae9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 29 Sep 2014 15:18:51 +0800 Subject: [PATCH 0708/1564] Issue #5933: cc.Scale9Sprite --- .../gui/control-extension/CCScale9Sprite.js | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index f674da5cd1..7f8b758f2f 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -522,7 +522,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, /** - * Initializes a ccui.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. + * Initializes a cc.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @returns {boolean} */ init: function () { @@ -575,7 +575,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } if(!file) - throw "ccui.Scale9Sprite.initWithFile(): file should be non-null"; + throw "cc.Scale9Sprite.initWithFile(): file should be non-null"; var texture = cc.textureCache.getTextureForKey(file); if (!texture) { @@ -612,7 +612,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ */ initWithSpriteFrame: function (spriteFrame, capInsets) { if(!spriteFrame || !spriteFrame.getTexture()) - throw "ccui.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null"; + throw "cc.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null"; capInsets = capInsets || cc.rect(0, 0, 0, 0); var locLoaded = spriteFrame.textureLoaded(); @@ -645,12 +645,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ */ initWithSpriteFrameName: function (spriteFrameName, capInsets) { if(!spriteFrameName) - throw "ccui.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null"; + throw "cc.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null"; capInsets = capInsets || cc.rect(0, 0, 0, 0); var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName); if (frame == null) { - cc.log("ccui.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"); + cc.log("cc.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"); return false; } @@ -666,7 +666,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * @param {cc.Rect} capInsets The values to use for the cap insets. */ resizableSpriteWithCapInsets: function (capInsets) { - var pReturn = new ccui.Scale9Sprite(); + var pReturn = new cc.Scale9Sprite(); if (pReturn && pReturn.initWithBatchNode(this._scale9Image, this._spriteRect, false, capInsets)) return pReturn; return null; @@ -853,47 +853,47 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Centre this._centre = new cc.Sprite(); this._centre.initWithTexture(selTexture, centerbounds); - locScale9Image.addChild(this._centre, 0, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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 @@ -952,47 +952,47 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Centre this._centre = new cc.Sprite(); this._centre.initWithTexture(selTexture, rotatedcenterbounds, true); - locScale9Image.addChild(this._centre, 0, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.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, ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT); + locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT); } this.setContentSize(rect.width, rect.height); @@ -1009,7 +1009,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, /** - * set the sprite frame of ccui.Scale9Sprite + * set the sprite frame of cc.Scale9Sprite * @param {cc.SpriteFrame} spriteFrame */ setSpriteFrame: function (spriteFrame) { From d9a6e09d8214525213a1934d79204b9595f695d0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 29 Sep 2014 16:33:23 +0800 Subject: [PATCH 0709/1564] Issue #5933: cc.ScrollView (tableview error) --- extensions/gui/scrollview/CCScrollView.js | 38 +++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 2c975ebad4..5cc6d509fe 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -120,6 +120,23 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._parentScissorRect = new cc.Rect(0,0,0,0); this._tmpViewRect = new cc.Rect(0,0,0,0); + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + this.startCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + ctx = ctx || cc.context; + ctx.save(); + ctx.save(); + this.transform(); + var t = this._transformWorld; + ctx.transform(t.a, t.b, t.c, t.d, t.tx, -t.ty); + cc.ScrollView.prototype._beforeDraw.call(this); + }); + this.endCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + ctx = ctx || cc.context; + cc.ScrollView.prototype._afterDraw.call(this); + ctx.restore(); + }); + } + if(container != undefined) this.initWithViewSize(size, container); else @@ -588,9 +605,11 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ var context = ctx || cc._renderContext; var i, locChildren = this._children, selChild, childrenLen; if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - context.save(); +// context.save(); this.transform(context); - this._beforeDraw(context); + if(this.startCmd) + cc.renderer.pushRenderCommand(this.startCmd); +// this._beforeDraw(context); if (locChildren && locChildren.length > 0) { childrenLen = locChildren.length; @@ -604,18 +623,24 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ break; } - this.draw(context); // self draw +// this.draw(context); // self draw + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); // draw children zOrder >= 0 for (; i < childrenLen; i++) locChildren[i].visit(context); } else{ - this.draw(context); // self draw +// this.draw(context); // self draw + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); } - this._afterDraw(); +// this._afterDraw(); + if(this.endCmd) + cc.renderer.pushRenderCommand(this.endCmd); - context.restore(); +// context.restore(); } else { cc.kmGLPushMatrix(); var locGrid = this.grid; @@ -823,6 +848,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ ctx.beginPath(); ctx.rect(startX, startY, getWidth, -getHeight); + ctx.restore(); ctx.clip(); ctx.closePath(); } else { From 1380d070fb717d6dcafb1b25354b865f5fd4e235 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 29 Sep 2014 17:20:09 +0800 Subject: [PATCH 0710/1564] add webgl renderer command for cc.ScrollView --- extensions/gui/scrollview/CCScrollView.js | 93 ++++++++++++++--------- 1 file changed, 58 insertions(+), 35 deletions(-) diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 2c975ebad4..2035a155e9 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -102,6 +102,9 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ _touchListener: null, _className:"ScrollView", + _beforeDrawCmd:null, + _afterDrawCmd:null, + /** * @contructor * @param size @@ -127,6 +130,13 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ }, + _initRendererCmd:function () { + if(cc._renderType === cc._RENDER_TYPE_WEBGL){ + this._beforeDrawCmd = new cc.CustomRenderCmdWebGL(this, this._onBeforeDraw); + this._afterDrawCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDraw); + } + }, + init:function () { return this.initWithViewSize(cc.size(200, 200), null); }, @@ -618,11 +628,11 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ context.restore(); } else { cc.kmGLPushMatrix(); - var locGrid = this.grid; - if (locGrid && locGrid.isActive()) { - locGrid.beforeDraw(); - this.transformAncestors(); - } +// var locGrid = this.grid; +// if (locGrid && locGrid.isActive()) { +// locGrid.beforeDraw(); +// this.transformAncestors(); +// } this.transform(context); this._beforeDraw(context); @@ -638,18 +648,22 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ } // this draw - this.draw(context); + //this.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); // draw children zOrder >= 0 for (; i < childrenLen; i++) locChildren[i].visit(); } else{ - this.draw(context); + //this.draw(context); + if(this._rendererCmd) + cc.renderer.pushRenderCommand(this._rendererCmd); } this._afterDraw(context); - if (locGrid && locGrid.isActive()) - locGrid.afterDraw(this); +// if (locGrid && locGrid.isActive()) +// locGrid.afterDraw(this); cc.kmGLPopMatrix(); } @@ -809,7 +823,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ _beforeDraw:function (context) { if (this._clippingToBounds) { this._scissorRestored = false; - var frame = this._getViewRect(), locEGLViewer = cc.view; + var locEGLViewer = cc.view; var scaleX = this.getScaleX(); var scaleY = this.getScaleY(); @@ -826,25 +840,31 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ ctx.clip(); ctx.closePath(); } else { - var EGLViewer = cc.view; - if(EGLViewer.isScissorEnabled()){ - this._scissorRestored = true; - this._parentScissorRect = EGLViewer.getScissorRect(); - //set the intersection of m_tParentScissorRect and frame as the new scissor rect - if (cc.rectIntersection(frame, this._parentScissorRect)) { - var locPSRect = this._parentScissorRect; - var x = Math.max(frame.x, locPSRect.x); - var y = Math.max(frame.y, locPSRect.y); - var xx = Math.min(frame.x + frame.width, locPSRect.x + locPSRect.width); - var yy = Math.min(frame.y + frame.height, locPSRect.y + locPSRect.height); - EGLViewer.setScissorInPoints(x, y, xx - x, yy - y); - } - }else{ - ctx.enable(ctx.SCISSOR_TEST); - //clip - EGLViewer.setScissorInPoints(frame.x, frame.y, frame.width, frame.height); - } + cc.renderer.pushRenderCommand(this._beforeDrawCmd); + } + } + }, + + _onBeforeDraw:function(){ + var EGLViewer = cc.view; + var frame = this._getViewRect(); + if(EGLViewer.isScissorEnabled()){ + this._scissorRestored = true; + this._parentScissorRect = EGLViewer.getScissorRect(); + //set the intersection of m_tParentScissorRect and frame as the new scissor rect + if (cc.rectIntersection(frame, this._parentScissorRect)) { + var locPSRect = this._parentScissorRect; + var x = Math.max(frame.x, locPSRect.x); + var y = Math.max(frame.y, locPSRect.y); + var xx = Math.min(frame.x + frame.width, locPSRect.x + locPSRect.width); + var yy = Math.min(frame.y + frame.height, locPSRect.y + locPSRect.height); + EGLViewer.setScissorInPoints(x, y, xx - x, yy - y); } + }else{ + var ctx = cc._renderContext; + ctx.enable(ctx.SCISSOR_TEST); + //clip + EGLViewer.setScissorInPoints(frame.x, frame.y, frame.width, frame.height); } }, /** @@ -853,13 +873,16 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ */ _afterDraw:function (context) { if (this._clippingToBounds && cc._renderType === cc._RENDER_TYPE_WEBGL) { - if (this._scissorRestored) { //restore the parent's scissor rect - var rect = this._parentScissorRect; - cc.view.setScissorInPoints(rect.x, rect.y, rect.width, rect.height) - }else{ - var ctx = context || cc._renderContext; - ctx.disable(ctx.SCISSOR_TEST); - } + cc.renderer.pushRenderCommand(this._afterDrawCmd); + } + }, + _onAfterDraw:function(){ + if (this._scissorRestored) { //restore the parent's scissor rect + var rect = this._parentScissorRect; + cc.view.setScissorInPoints(rect.x, rect.y, rect.width, rect.height) + }else{ + var ctx = cc._renderContext; + ctx.disable(ctx.SCISSOR_TEST); } }, /** From c95e6c3e123222c9854281055c1742ac2c45d083 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 29 Sep 2014 17:30:37 +0800 Subject: [PATCH 0711/1564] setNodeDirty when touch moved --- extensions/gui/scrollview/CCScrollView.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 2035a155e9..9a1c28a9d5 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -445,6 +445,8 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ if (!this.isVisible()) return; + this.setNodeDirty(); + if (this._touches.length === 1 && this._dragging) { // scrolling this._touchMoved = true; //var frameOriginal = this.getParent().convertToWorldSpace(this.getPosition()); From 377a786d32c930d9d70ad22941d91f1bfd354366 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 09:31:47 +0800 Subject: [PATCH 0712/1564] Issue #5933: Repair of bug in renderer --- cocos2d/core/renderer/RendererCanvas.js | 49 +++++++++++++------------ 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index a47dc036a6..dbed2b3e2f 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -147,8 +147,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (node._isLighterMode) - context.globalCompositeOperation = 'lighter'; + if (node._blendFuncStr) + context.globalCompositeOperation = node._blendFuncStr || 'lighter'; if (node._flippedX) context.scale(-1, 1); @@ -157,7 +157,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (node._texture && locTextureCoord.validRect) { if (node._texture._isLoaded) { - context.globalAlpha = node._opacity; + context.globalAlpha = (node._displayedOpacity / 255); image = node._texture._htmlElementObj; context.drawImage(image, @@ -175,20 +175,20 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } else if (!node._texture && locTextureCoord.validRect) { curColor = node._color; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._opacity + ")"; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; context.fillRect(locDrawingRect.x, locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); } context.restore(); } else { - if (node._isLighterMode) { + if (node._blendFuncStr) { context.save(); - context.globalCompositeOperation = 'lighter'; + context.globalCompositeOperation = node._blendFuncStr || 'lighter'; } if (node._texture && locTextureCoord.validRect) { if (node._texture._isLoaded) { - context.globalAlpha = node._opacity; + context.globalAlpha = (node._displayedOpacity / 255); image = node._texture.getHtmlElementObj(); if (node._colorized) { context.drawImage(image, @@ -196,10 +196,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { 0, locTextureCoord.width, locTextureCoord.height, - t.tx * scaleX + locDrawingRect.x, - -t.ty * scaleY + locDrawingRect.y, - locDrawingRect.width, - locDrawingRect.height); + (t.tx + locDrawingRect.x) * scaleY, + (-t.ty + locDrawingRect.y) * scaleY, + locDrawingRect.width * scaleX, + locDrawingRect.height * scaleX); } else { context.drawImage( image, @@ -207,18 +207,21 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, - t.tx * scaleX + locDrawingRect.x, - -t.ty * scaleY + locDrawingRect.y, - locDrawingRect.width, - locDrawingRect.height); + (t.tx + locDrawingRect.x) * scaleY, + (-t.ty + locDrawingRect.y) * scaleY, + locDrawingRect.width * scaleX, + locDrawingRect.height * scaleX); } } } else if (!node._texture && locTextureCoord.validRect && node._displayedColor) { + + context.globalAlpha = (node._displayedOpacity / 255); curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._opacity + ")"; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + } - if (node._isLighterMode) + if (node._blendFuncStr) context.restore(); } cc.g_NumberOfDraws++; @@ -248,8 +251,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locRect = this._drawingRect; context.save(); - if (node._isLighterMode) - context.globalCompositeOperation = 'lighter'; + if (node._blendFuncStr) + context.globalCompositeOperation = node._blendFuncStr || 'lighter'; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," @@ -279,8 +282,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { node = self._node, t = node._transformWorld; context.save(); - if (node._isLighterMode) - context.globalCompositeOperation = 'lighter'; + if (node._blendFuncStr) + context.globalCompositeOperation = node._blendFuncStr || 'lighter'; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); @@ -418,8 +421,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (locSprite._isLighterMode) - context.globalCompositeOperation = 'lighter'; + if (locSprite._blendFuncStr) + context.globalCompositeOperation = node._blendFuncStr || 'lighter'; context.globalAlpha = locSprite._displayedOpacity / 255; From a3e3879a7f70388020bffb621f31f2134e106ad2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 09:57:47 +0800 Subject: [PATCH 0713/1564] Issue #5933: Repair of bug in renderer (set color) --- cocos2d/core/renderer/RendererCanvas.js | 41 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index dbed2b3e2f..1f27551d03 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -160,16 +160,29 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.globalAlpha = (node._displayedOpacity / 255); image = node._texture._htmlElementObj; - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locDrawingRect.x, - locDrawingRect.y, - locDrawingRect.width * scaleX, - locDrawingRect.height * scaleY - ); + if (node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + locDrawingRect.x * scaleX, + locDrawingRect.y * scaleY, + locDrawingRect.width * scaleX, + locDrawingRect.height * scaleY + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locDrawingRect.x * scaleX, + locDrawingRect.y * scaleY, + locDrawingRect.width * scaleX, + locDrawingRect.height * scaleY + ); + } } @@ -196,10 +209,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { 0, locTextureCoord.width, locTextureCoord.height, - (t.tx + locDrawingRect.x) * scaleY, + (t.tx + locDrawingRect.x) * scaleX, (-t.ty + locDrawingRect.y) * scaleY, locDrawingRect.width * scaleX, - locDrawingRect.height * scaleX); + locDrawingRect.height * scaleY); } else { context.drawImage( image, @@ -207,10 +220,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, - (t.tx + locDrawingRect.x) * scaleY, + (t.tx + locDrawingRect.x) * scaleX, (-t.ty + locDrawingRect.y) * scaleY, locDrawingRect.width * scaleX, - locDrawingRect.height * scaleX); + locDrawingRect.height * scaleY); } } } else if (!node._texture && locTextureCoord.validRect && node._displayedColor) { From 7e8fe5c90bd4ce39b26fe0b693ca8ca994b3b789 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 30 Sep 2014 10:05:57 +0800 Subject: [PATCH 0714/1564] add webgl render command for Armature --- cocos2d/core/renderer/RendererWebGL.js | 63 ++++++++++++++++++++ extensions/cocostudio/armature/CCArmature.js | 7 ++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 67e62349e9..50c8e3b92e 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -590,4 +590,67 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ cc.kmGLPopMatrix(); } }; + + cc.ArmatureRenderCmdWebGL = function(node){ + this._node = node; + }; + + cc.ArmatureRenderCmdWebGL.prototype.rendering = function(ctx){ + var _t = this._node; + + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadMatrix(_t._stackMatrix); + + //TODO REMOVE THIS FUNCTION + if (_t._parentBone == null && _t._batchNode == null) { + // CC_NODE_DRAW_SETUP(); + } + + var locChildren = _t._children; + var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + node.setShaderProgram(_t._shaderProgram); + + switch (selBone.getDisplayRenderNodeType()) { + case ccs.DISPLAY_TYPE_SPRITE: + if(node instanceof ccs.Skin){ + node.updateTransform(); + + var func = selBone.getBlendFunc(); + if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + node.setBlendFunc(selBone.getBlendFunc()); + else { + if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) + && !node.getTexture().hasPremultipliedAlpha()) + node.setBlendFunc(alphaNonPremultipled); + else + node.setBlendFunc(_t._blendFunc); + } + node.draw(ctx); + } + break; + case ccs.DISPLAY_TYPE_ARMATURE: + node.draw(ctx); + break; + default: + node.visit(ctx); + break; + } + } else if(selBone instanceof cc.Node) { + selBone.setShaderProgram(_t._shaderProgram); + selBone.visit(ctx); + // CC_NODE_DRAW_SETUP(); + } + } + + cc.kmGLPopMatrix(); + }; } diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 9322e256c8..6f3309033e 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -71,10 +71,14 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = true; this._realAnchorPointInPoints = cc.p(0, 0); name && ccs.Armature.prototype.init.call(this, name, parentBone); + }, + _initRendererCmd:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS){ this._rendererStartCmd = new cc.CustomRenderCmdCanvas(this, this._startRendererCmdForCanvas); this._rendererEndCmd = new cc.CustomRenderCmdCanvas(this, this._endRendererCmdForCanvas); + }else{ + this._rendererCmd = new cc.ArmatureRenderCmdWebGL(this); } }, @@ -523,7 +527,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.transform(); this.sortAllChildren(); - this.draw(context); + //this.draw(context); + cc.renderer.pushRenderCommand(this._rendererCmd); // reset for next frame this.arrivalOrder = 0; From dbc06c58b9c39a070d0835c5033cc55985997c5b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 10:47:50 +0800 Subject: [PATCH 0715/1564] Issue #5933: studio transform error when async load img --- extensions/ccui/base-classes/UIWidget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 9166593c39..a8ecd23ff9 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1508,6 +1508,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _findLayout: function(){ + cc.renderer.childrenOrderDirty = true; var layout = this._parent; while(layout){ if(layout._doLayout){ From 7465520749537e51c6b89c13305602c76786039a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 12:40:59 +0800 Subject: [PATCH 0716/1564] Issue #5933: studio transform error --- extensions/ccui/base-classes/UIScale9Sprite.js | 4 ++-- extensions/cocostudio/armature/CCArmature.js | 4 ++-- extensions/gui/control-extension/CCScale9Sprite.js | 4 ++-- extensions/gui/scrollview/CCScrollView.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 22b711e93c..0fa32c0af8 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -253,12 +253,12 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx, scaleX, scaleY){ ctx = ctx || cc._renderContext; var p = this._transformWorld; ctx.save(); - ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); + ctx.transform(p.a, p.b, p.c, p.d, p.tx * scaleX, -p.ty * scaleY); }); this._rendererEndCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ ctx = ctx || cc._renderContext; diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 9322e256c8..57f372ada0 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -478,12 +478,12 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ context.restore(); }, - _startRendererCmdForCanvas: function(ctx){ + _startRendererCmdForCanvas: function(ctx, scaleX, scaleY){ var context = ctx || cc._renderContext; context.save(); this.transform(context); var t = this._transformWorld; - ctx.transform(t.a, t.b, t.c, t.d, t.tx, -t.ty); + ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); var locChildren = this._children; for (var i = 0, len = locChildren.length; i< len; i++) { diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 7f8b758f2f..32f943a5b2 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -251,12 +251,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx, scaleX, scaleY){ ctx = ctx || cc._renderContext; var p = this._transformWorld; ctx.save(); - ctx.transform(p.a, p.b, p.c, p.d, p.tx, -p.ty); + ctx.transform(p.a, p.b, p.c, p.d, p.tx * scaleX, -p.ty * scaleY); }); this._rendererEndCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ ctx = ctx || cc._renderContext; diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 5cc6d509fe..7c6a84b65c 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -121,13 +121,13 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._tmpViewRect = new cc.Rect(0,0,0,0); if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this.startCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ + this.startCmd = new cc.CustomRenderCmdCanvas(this, function(ctx, scaleX, scaleY){ ctx = ctx || cc.context; ctx.save(); ctx.save(); this.transform(); var t = this._transformWorld; - ctx.transform(t.a, t.b, t.c, t.d, t.tx, -t.ty); + ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); cc.ScrollView.prototype._beforeDraw.call(this); }); this.endCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ From a2764aa4bf16987e333a83352cfa8f602b4e7d11 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 13:34:06 +0800 Subject: [PATCH 0717/1564] Issue #5933: blend error --- cocos2d/core/renderer/RendererCanvas.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 1f27551d03..2e3051a08e 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -147,8 +147,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (node._blendFuncStr) - context.globalCompositeOperation = node._blendFuncStr || 'lighter'; + if (node._blendFunc) + context.globalCompositeOperation = node._blendFuncStr || 'source'; if (node._flippedX) context.scale(-1, 1); @@ -193,9 +193,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } context.restore(); } else { - if (node._blendFuncStr) { + if (node._blendFunc) { context.save(); - context.globalCompositeOperation = node._blendFuncStr || 'lighter'; + context.globalCompositeOperation = node._blendFuncStr || 'source'; } if (node._texture && locTextureCoord.validRect) { @@ -234,7 +234,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); } - if (node._blendFuncStr) + if (node._blendFunc) context.restore(); } cc.g_NumberOfDraws++; @@ -264,8 +264,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locRect = this._drawingRect; context.save(); - if (node._blendFuncStr) - context.globalCompositeOperation = node._blendFuncStr || 'lighter'; + if (node._blendFunc) + context.globalCompositeOperation = node._blendFuncStr || 'source'; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," @@ -295,8 +295,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { node = self._node, t = node._transformWorld; context.save(); - if (node._blendFuncStr) - context.globalCompositeOperation = node._blendFuncStr || 'lighter'; + if (node._blendFunc) + context.globalCompositeOperation = node._blendFuncStr || 'source'; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); @@ -434,8 +434,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (locSprite._blendFuncStr) - context.globalCompositeOperation = node._blendFuncStr || 'lighter'; + if (locSprite._blendFunc) + context.globalCompositeOperation = node._blendFuncStr || 'source'; context.globalAlpha = locSprite._displayedOpacity / 255; From ec522c4d068cbdd4ad750fe961ea13cf303b39a3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 14:09:24 +0800 Subject: [PATCH 0718/1564] Issue #5933: Node skew error ps: In September 23 mistakes --- cocos2d/core/base-nodes/CCNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index e5bc3955cd..9df687d51d 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2635,7 +2635,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { worldT.b = t.a * pt.b + t.b * pt.d; //b worldT.c = t.c * pt.a + t.d * pt.c; //c worldT.d = t.c * pt.b + t.d * pt.d; //d - if(this._skewX || this._skewY){ + if(!this._skewX || this._skewY){ var plt = this._parent._transform; var xOffset = -(plt.b + plt.c) * t.ty ; var yOffset = -(plt.b + plt.c) * t.tx; From faeb186f7c873feab9e4016323804fb88a00342e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 14:46:15 +0800 Subject: [PATCH 0719/1564] Issue #5933: Colloder Detector --- .../cocostudio/armature/physics/CCColliderDetector.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index 5666fde916..04b7e72b37 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -331,9 +331,9 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ var b = shape.verts[(j + 1) % shape.verts.length]; var n = cp.v.normalize(cp.v.perp(cp.v.sub(b, shape.verts[j]))); - if(shape.axes){ - shape.axes[j].n = n; - shape.axes[j].d = cp.v.dot(n, shape.verts[j]); + if(shape.planes){ + shape.planes[j].n = n; + shape.planes[j].d = cp.v.dot(n, shape.verts[j]); } // var b = shape.verts[(i + 1) % shape.numVerts]; // var n = cp.v.normalize(cp.v.perp(cp.v.sub(b, shape.verts[i]))); From 3b18d856e96f381e39e0e8a19f9f68a0c8742877 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 15:10:49 +0800 Subject: [PATCH 0720/1564] Issue #5933: Gradient layer --- cocos2d/core/layers/CCLayer.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 254a42d3ed..4f733529ec 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -481,12 +481,16 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { else break; } - _t.draw(bakeContext); +// _t.draw(bakeContext); + if(_t._rendererCmd) + cc.renderer.pushRenderCommand(_t._rendererCmd); for (; i < len; i++) { children[i].visit(bakeContext); } } else - _t.draw(bakeContext); +// _t.draw(bakeContext); + if(_t._rendererCmd) + cc.renderer.pushRenderCommand(_t._rendererCmd); cc.view._resetScale(); this._cacheDirty = false; } @@ -592,7 +596,13 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, _initRendererCmd: function(){ - this._rendererCmd = new cc.GradientRectRenderCmdCanvas(this); + if(!(this._rendererCmd instanceof cc.GradientRectRenderCmdCanvas)) + this._rendererCmd = new cc.GradientRectRenderCmdCanvas(this); + }, + + visit: function(){ + this._super(); + void 0; }, /** From 2b137baaf80e906014743ea844132bbfacfab71b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Sep 2014 15:14:24 +0800 Subject: [PATCH 0721/1564] Issue #5933: Remove test code --- cocos2d/core/layers/CCLayer.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 4f733529ec..18916a5ccc 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -481,16 +481,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { else break; } -// _t.draw(bakeContext); if(_t._rendererCmd) cc.renderer.pushRenderCommand(_t._rendererCmd); for (; i < len; i++) { children[i].visit(bakeContext); } } else -// _t.draw(bakeContext); - if(_t._rendererCmd) - cc.renderer.pushRenderCommand(_t._rendererCmd); + if(_t._rendererCmd) + cc.renderer.pushRenderCommand(_t._rendererCmd); cc.view._resetScale(); this._cacheDirty = false; } @@ -596,13 +594,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ }, _initRendererCmd: function(){ - if(!(this._rendererCmd instanceof cc.GradientRectRenderCmdCanvas)) - this._rendererCmd = new cc.GradientRectRenderCmdCanvas(this); - }, - - visit: function(){ - this._super(); - void 0; + this._rendererCmd = new cc.GradientRectRenderCmdCanvas(this); }, /** From 1c8d61968f4bba780adb8cb4a63dac92413d700f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 1 Oct 2014 16:42:50 +0800 Subject: [PATCH 0722/1564] Feature #5941: Desactivate WebGL for iOS version < 8 --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 55203c2bfe..9d518eb5a8 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1541,7 +1541,7 @@ cc._initSys = function (config, CONFIG_KEY) { var renderType = cc._RENDER_TYPE_WEBGL; var tempCanvas = cc.newElement("Canvas"); cc._supportRender = true; - var notSupportGL = browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1; + var notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1; if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://")) { renderType = cc._RENDER_TYPE_CANVAS; } From 662786059b5783dce2dfada87b345518201f0df7 Mon Sep 17 00:00:00 2001 From: QSJia Date: Wed, 8 Oct 2014 10:12:15 +0800 Subject: [PATCH 0723/1564] bugfix: typo in _initFrameSize --- cocos2d/core/platform/CCEGLView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index d6049a1dec..57739017d1 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -214,7 +214,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }else{ locFrameSize.width = this._frame.clientWidth; } - if(cc.sys.isMobile && this._frame.clientWidth >= sHeight * 0.8){ + if(cc.sys.isMobile && this._frame.clientHeight >= sHeight * 0.8){ locFrameSize.height = sHeight / window.devicePixelRatio; }else{ locFrameSize.height = this._frame.clientHeight; From 5ddf9788263b3ea6bd35b3e127ed8086a50b6ef3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 8 Oct 2014 15:37:52 +0800 Subject: [PATCH 0724/1564] Issue #5941: corrected mistakes of cc.ProtectedNode and ccui.Text --- cocos2d/core/renderer/RendererWebGL.js | 3 +-- extensions/ccui/base-classes/CCProtectedNode.js | 2 -- extensions/ccui/uiwidgets/UIText.js | 7 ------- extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 3 +-- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 50c8e3b92e..ffdf51bc88 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -71,10 +71,9 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ var locPool = this._transformNodePool; //sort the pool locPool.sort(this._sortNodeByLevelAsc); - //transform node for (var i = 0, len = locPool.length; i < len; i++) { - if (locPool[i]._renderCmdDiry) //TODO need modify name for LabelTTF + if (locPool[i]._renderCmdDiry) locPool[i]._transformForRenderer(); } locPool.length = 0; diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index be410e09d3..78a134dd4c 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -542,8 +542,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); this._renderCmdDiry = false; - if(!this._children || this._children.length === 0) - return; var i, len, locChildren = this._children; for(i = 0, len = locChildren.length; i< len; i++){ locChildren[i]._transformForRenderer(); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 136396cafc..fa76af5b65 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -431,14 +431,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _getBoundingHeight: function () { return this._textAreaSize.height; - }, - - _transformForRenderer: function(){ - this._adaptRenderers(); - cc.Node.prototype.transform.call(this); - this._labelRenderer._transformForRenderer(); } - }); var _p = ccui.Text.prototype; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 82f5357cb7..8cd56c715e 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -437,8 +437,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._scrollPages(-curPageLocation); else this.scrollToPage(this._curPageIdx + 1); - } - else if (curPageLocation >= boundary) { + } else if (curPageLocation >= boundary) { if (this._curPageIdx <= 0) this._scrollPages(-curPageLocation); else From d875ae7562f88e2c11b9a9092b378d746947d337 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Oct 2014 15:50:26 +0800 Subject: [PATCH 0725/1564] Issue #5933: cocostudio update text position --- extensions/ccui/uiwidgets/UIText.js | 9 +++++++++ extensions/ccui/uiwidgets/UITextField.js | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index fa76af5b65..36142e8fd8 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -431,6 +431,15 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _getBoundingHeight: function () { return this._textAreaSize.height; + }, + + _transformForRenderer: function(){ + this._adaptRenderers(); + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + cc.Node.prototype.transform.call(this); + else + cc.ProtectedNode.prototype._transformForRenderer.call(this); + this._labelRenderer._transformForRenderer(); } }); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 386ca68ce4..d8554f93a3 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -806,7 +806,10 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _transformForRenderer: function(){ this._adaptRenderers(); - cc.Node.prototype.transform.call(this); + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + cc.Node.prototype.transform.call(this); + else + cc.ProtectedNode.prototype._transformForRenderer.call(this); this._textFieldRenderer._transformForRenderer(); } }); From 7f8c67bcfae0a651ada066296b8ab7877f83efd3 Mon Sep 17 00:00:00 2001 From: Robert Rouhani Date: Wed, 8 Oct 2014 05:14:53 -0400 Subject: [PATCH 0726/1564] Added missing rotation property to TMX objects. --- cocos2d/tilemap/CCTMXXMLParser.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index 0fe7435209..613a59d185 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -769,6 +769,8 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ // Correct y position. (Tiled uses Flipped, cocos2d uses Standard) objectProp["y"] = parseInt(this.getMapSize().height * this.getTileSize().height) - y - objectProp["height"]; + + objectProp["rotation"] = parseInt(selObj.getAttribute('rotation')) || 0; var docObjProps = selObj.querySelectorAll("properties > property"); if (docObjProps) { From 143ed26f28051f175c307d19af9f900340253d68 Mon Sep 17 00:00:00 2001 From: Robert Rouhani Date: Wed, 8 Oct 2014 05:34:22 -0400 Subject: [PATCH 0727/1564] Fixed bug where resizing the screen caused cached canvases to draw at an incorrect offset. --- cocos2d/tilemap/CCTMXLayer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 15c5167456..8227b12da6 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -263,10 +263,10 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ var selSubCanvas = locSubCacheCanvasArr[i]; if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * this._subCacheWidth, -(posY + locCanvasHeight) + halfTileSize, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); + posX + i * this._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight) + halfTileSize, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); else context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * this._subCacheWidth, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); + posX + i * this._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); } } else{ if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) From a3c26e1fad4fe14b76261ab8e328752464d2ff30 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Oct 2014 17:41:57 +0800 Subject: [PATCH 0728/1564] Issue #5933: anchorPoint error --- .../ccui/base-classes/UIScale9Sprite.js | 19 +++++-------------- .../gui/control-extension/CCScale9Sprite.js | 19 +++++-------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 0fa32c0af8..2f1a344c50 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -219,6 +219,8 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ contentSizeChanged = true; } + //begin cache + cc.renderer._isCacheToCanvasOn = true; //cc._renderContext = this._cacheContext; cc.view._setScaleXYForRenderTexture(); this._scale9Image.visit(this._cacheContext); @@ -230,6 +232,9 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ if(!this._cacheSprite.getParent()) this.addChild(this._cacheSprite); + cc.renderer._isCacheToCanvasOn = false; + //draw to cache canvas + cc.renderer._renderingToCacheCanvas(this._cacheContext); }, /** @@ -253,18 +258,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx, scaleX, scaleY){ - ctx = ctx || cc._renderContext; - - var p = this._transformWorld; - ctx.save(); - ctx.transform(p.a, p.b, p.c, p.d, p.tx * scaleX, -p.ty * scaleY); - }); - this._rendererEndCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ - ctx = ctx || cc._renderContext; - ctx.restore(); - }); - var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); locCacheCanvas.width = 1; locCacheCanvas.height = 1; @@ -512,12 +505,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._scale9Dirty = true; } if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); this._scale9Dirty = false; this._cacheScale9Sprite(); cc.Node.prototype.visit.call(this, ctx); - cc.renderer.pushRenderCommand(this._rendererEndCanvasCmd); }else{ cc.Node.prototype.visit.call(this, ctx); } diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 32f943a5b2..5fe7d998a9 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -217,6 +217,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ contentSizeChanged = true; } + //begin cache + cc.renderer._isCacheToCanvasOn = true; //cc._renderContext = this._cacheContext; cc.view._setScaleXYForRenderTexture(); this._scale9Image.visit(this._cacheContext); @@ -228,6 +230,9 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if(!this._cacheSprite.getParent()) this.addChild(this._cacheSprite); + cc.renderer._isCacheToCanvasOn = false; + //draw to cache canvas + cc.renderer._renderingToCacheCanvas(this._cacheContext); }, /** @@ -251,18 +256,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererStartCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx, scaleX, scaleY){ - ctx = ctx || cc._renderContext; - - var p = this._transformWorld; - ctx.save(); - ctx.transform(p.a, p.b, p.c, p.d, p.tx * scaleX, -p.ty * scaleY); - }); - this._rendererEndCanvasCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ - ctx = ctx || cc._renderContext; - ctx.restore(); - }); - var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); locCacheCanvas.width = 1; locCacheCanvas.height = 1; @@ -510,12 +503,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._scale9Dirty = true; } if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - cc.renderer.pushRenderCommand(this._rendererStartCanvasCmd); this._scale9Dirty = false; this._cacheScale9Sprite(); cc.Node.prototype.visit.call(this, ctx); - cc.renderer.pushRenderCommand(this._rendererEndCanvasCmd); }else{ cc.Node.prototype.visit.call(this, ctx); } From 95105a24a6c3a18ef24cfd2a5e77d2788cff5af6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Oct 2014 17:53:08 +0800 Subject: [PATCH 0729/1564] Issue #5933: anchorPoint error --- extensions/ccui/base-classes/UIScale9Sprite.js | 12 ++++-------- extensions/gui/control-extension/CCScale9Sprite.js | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 2f1a344c50..b8ecb1ac29 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -221,20 +221,16 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ //begin cache cc.renderer._isCacheToCanvasOn = true; - //cc._renderContext = this._cacheContext; - cc.view._setScaleXYForRenderTexture(); - this._scale9Image.visit(this._cacheContext); - //cc._renderContext = cc._mainRenderContextBackup; - cc.view._resetScale(); + this._scale9Image.visit(); + + //draw to cache canvas + cc.renderer._renderingToCacheCanvas(this._cacheContext); if(contentSizeChanged) this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); if(!this._cacheSprite.getParent()) this.addChild(this._cacheSprite); - cc.renderer._isCacheToCanvasOn = false; - //draw to cache canvas - cc.renderer._renderingToCacheCanvas(this._cacheContext); }, /** diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 5fe7d998a9..462619d101 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -219,20 +219,16 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ //begin cache cc.renderer._isCacheToCanvasOn = true; - //cc._renderContext = this._cacheContext; - cc.view._setScaleXYForRenderTexture(); - this._scale9Image.visit(this._cacheContext); - //cc._renderContext = cc._mainRenderContextBackup; - cc.view._resetScale(); + this._scale9Image.visit(); + + //draw to cache canvas + cc.renderer._renderingToCacheCanvas(this._cacheContext); if(contentSizeChanged) this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); if(!this._cacheSprite.getParent()) this.addChild(this._cacheSprite); - cc.renderer._isCacheToCanvasOn = false; - //draw to cache canvas - cc.renderer._renderingToCacheCanvas(this._cacheContext); }, /** From f86232430e6dd0b272b9195cbf43d29663cbd4b8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Oct 2014 19:47:48 +0800 Subject: [PATCH 0730/1564] Issue #5933: scale9Sprite index --- extensions/gui/control-extension/CCScale9Sprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 462619d101..23a944d91c 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -228,7 +228,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); if(!this._cacheSprite.getParent()) - this.addChild(this._cacheSprite); + this.addChild(this._cacheSprite, -1); }, /** From 021f46ae51ce89cbd399f049aea15c9a59f87fd6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 8 Oct 2014 19:58:44 +0800 Subject: [PATCH 0731/1564] Issue #5941: improve canvas renderer's blendFunc --- cocos2d/core/renderer/RendererCanvas.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 2e3051a08e..dfaa27ac89 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -147,8 +147,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (node._blendFunc) - context.globalCompositeOperation = node._blendFuncStr || 'source'; + if (node._blendFuncStr != "source") + context.globalCompositeOperation = node._blendFuncStr; if (node._flippedX) context.scale(-1, 1); @@ -193,9 +193,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } context.restore(); } else { - if (node._blendFunc) { + if (node._blendFuncStr != "source") { context.save(); - context.globalCompositeOperation = node._blendFuncStr || 'source'; + context.globalCompositeOperation = node._blendFuncStr; } if (node._texture && locTextureCoord.validRect) { @@ -234,7 +234,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); } - if (node._blendFunc) + if (node._blendFuncStr != "source") context.restore(); } cc.g_NumberOfDraws++; @@ -264,8 +264,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locRect = this._drawingRect; context.save(); - if (node._blendFunc) - context.globalCompositeOperation = node._blendFuncStr || 'source'; + if (node._blendFuncStr != "source") + context.globalCompositeOperation = node._blendFuncStr; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," @@ -295,8 +295,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { node = self._node, t = node._transformWorld; context.save(); - if (node._blendFunc) - context.globalCompositeOperation = node._blendFuncStr || 'source'; + if (node._blendFuncStr != "source") + context.globalCompositeOperation = node._blendFuncStr; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); @@ -434,8 +434,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (locSprite._blendFunc) - context.globalCompositeOperation = node._blendFuncStr || 'source'; + if (locSprite._blendFuncStr != "source") + context.globalCompositeOperation = locSprite._blendFuncStr; context.globalAlpha = locSprite._displayedOpacity / 255; @@ -638,7 +638,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext; var node = this._node; var context = ctx || cc._renderContext; @@ -790,7 +789,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function (scaleX, scaleY) { - //TODO var locNode = this._node; if (locNode._cacheDirty) { var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; From ac2207c221f94441e48027d82ce87f5bff6b7a94 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Oct 2014 20:16:53 +0800 Subject: [PATCH 0732/1564] Issue #5933: setClippingType (only STENCIL of canvas) --- extensions/ccui/layouts/UILayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index e2ea13a63a..95826c0be5 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -602,7 +602,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} type */ setClippingType: function (type) { - if (type == this._clippingType) + if (type == this._clippingType || cc._renderType === cc._RENDER_TYPE_CANVAS) return; var clippingEnabled = this.isClippingEnabled(); this.setClippingEnabled(false); From 12e717eabe32c7ac222d6b8f506eff1347439624 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Oct 2014 20:26:26 +0800 Subject: [PATCH 0733/1564] Issue #5933: setClippingType (only STENCIL of canvas) --- extensions/ccui/layouts/UILayout.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 95826c0be5..1b9665f0ca 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -602,8 +602,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} type */ setClippingType: function (type) { - if (type == this._clippingType || cc._renderType === cc._RENDER_TYPE_CANVAS) + if (type == this._clippingType) return; + if(cc._renderType === cc._RENDER_TYPE_CANVAS && type == ccui.Layout.CLIPPING_SCISSOR){ + cc.log("Only supports STENCIL on canvas mode."); + return; + } var clippingEnabled = this.isClippingEnabled(); this.setClippingEnabled(false); this._clippingType = type; From a17ba8af4eac8b7bd26eea2fed1d51422826406a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 8 Oct 2014 21:27:27 +0800 Subject: [PATCH 0734/1564] Issue #5941: Let Sprite's camera works. --- cocos2d/actions/CCActionCamera.js | 1 + cocos2d/core/CCCamera.js | 15 +++++++++++++ cocos2d/core/base-nodes/BaseNodesWebGL.js | 27 ++++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/cocos2d/actions/CCActionCamera.js b/cocos2d/actions/CCActionCamera.js index dce8701cc5..0ff5786b71 100644 --- a/cocos2d/actions/CCActionCamera.js +++ b/cocos2d/actions/CCActionCamera.js @@ -256,6 +256,7 @@ cc.OrbitCamera = cc.ActionCamera.extend(/** @lends cc.OrbitCamera# */{ var k = Math.cos(za) * r + this._centerZOrig; this.target.getCamera().setEye(i, j, k); + this.target.setNodeDirty(); } }); diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js index 5a62d4428c..e93cda5a24 100644 --- a/cocos2d/core/CCCamera.js +++ b/cocos2d/core/CCCamera.js @@ -126,6 +126,21 @@ cc.Camera = cc.Class.extend({ cc.kmGLMultMatrix( this._lookupMatrix); }, + _locateForRenderer: function(matrix){ + if (this._dirty) { + var eye = new cc.kmVec3(), center = new cc.kmVec3(), up = new cc.kmVec3(); + + cc.kmVec3Fill( eye, this._eyeX, this._eyeY , this._eyeZ ); + cc.kmVec3Fill( center, this._centerX, this._centerY, this._centerZ); + + cc.kmVec3Fill( up, this._upX, this._upY, this._upZ); + cc.kmMat4LookAt( this._lookupMatrix, eye, center, up); + + this._dirty = false; + } + cc.kmMat4Multiply(matrix, matrix, this._lookupMatrix); + }, + /** * sets the eye values in points * @param {Number} eyeX diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index ff723ece29..bc3ac65d78 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -130,12 +130,37 @@ cc._tmp.WebGLCCNode = function () { //optimize performance for Javascript cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); + // XXX: Expensive calls. Camera should be integrated into the cached affine matrix + if (this._camera != null && !(this.grid != null && this.grid.isActive())) { + var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; + var translate = (apx !== 0.0 || apy !== 0.0); + if (translate){ + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + apx = 0 | apx; + apy = 0 | apy; + } + //cc.kmGLTranslatef(apx, apy, 0); + var translation = new cc.kmMat4(); + cc.kmMat4Translation(translation, apx, apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + + this._camera._locateForRenderer(stackMatrix); + + //cc.kmGLTranslatef(-apx, -apy, 0); + cc.kmMat4Translation(translation, -apx, -apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + } else { + this._camera.locate(); + } + } + this._renderCmdDiry = false; if(!this._children || this._children.length === 0) return; var i, len, locChildren = this._children; for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._transformForRenderer(); + locChildren[i]._transformForRenderer(stackMatrix); + //locChildren[i]._transformForRenderer(); } }; From fe8b2b3717bd961e092be17b76e5ad17ec923778 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 10:51:25 +0800 Subject: [PATCH 0735/1564] Issue #5933: TextureRenderCmdCanvas error _drawingRect is error --- cocos2d/core/renderer/RendererCanvas.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 2e3051a08e..509b16c88f 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -125,7 +125,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._drawingRect = { //Sprite setTextureRect override ^.^ get x(){ return node._offsetPosition.x; }, - get y(){ return node._offsetPosition.y - node._rect.height; }, + get y(){ return -node._offsetPosition.y - node._rect.height; }, get width(){ return node._rect.width; }, get height(){ return node._rect.height; } }; @@ -247,10 +247,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { x: 0, y: 0, get width(){ - return node.width * cc.view.getScaleX(); + return node.width; }, get height(){ - return node.height * cc.view.getScaleY() + return node.height; } }; }; @@ -270,7 +270,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," + (0 | curColor.b) + "," + opacity + ")"; - context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); + context.fillRect(locRect.x, locRect.y, locRect.width * scaleX, -locRect.height * scaleY); context.restore(); cc.g_NumberOfDraws++; @@ -282,8 +282,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._drawingRect = { x: 0, y: 0, - get width(){ return node.width * cc.view.getScaleX(); }, - get height(){ return node.height * cc.view.getScaleY(); } + get width(){ return node.width; }, + get height(){ return node.height; } }; this._startPoint = cc.p(0, 0); this._endPoint = cc.p(0, 0); @@ -311,7 +311,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + Math.round(locEndColor.b) + "," + (locEndColor.a!=null?(opacity * (locEndColor.a / 255)).toFixed(4):255) + ")"); context.fillStyle = gradient; - context.fillRect(locRect.x, locRect.y, locRect.width, -locRect.height); + context.fillRect(locRect.x, locRect.y, locRect.width * scaleX, -locRect.height * scaleY); context.restore(); cc.g_NumberOfDraws++; From 9d05fb7c8cf2d65385a0f8f3bd3e4058f0ae03cd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 11:43:50 +0800 Subject: [PATCH 0736/1564] Issue #5933: PhysicsSprite error (The calculation position of the delay) --- cocos2d/core/renderer/RendererCanvas.js | 12 ------------ cocos2d/core/renderer/RendererWebGL.js | 10 ---------- cocos2d/physics/CCPhysicsSprite.js | 16 ++++++++++++++-- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 4a5e27102b..9078e39c6b 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -757,18 +757,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; - cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; - - cc.PhysicsSpriteTransformCmd = function (node) { - this._node = node; - }; - - cc.PhysicsSpriteTransformCmd.prototype.rendering = function () { - if (this._node.transform) { - this._node.transform(); - } - }; - //--- TMXLayer's render command --- cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { this._node = tmxLayer; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index ffdf51bc88..aaaa516c14 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -457,16 +457,6 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ node.clear(); }; - cc.PhysicsSpriteTransformCmd = function (node) { - this._node = node; - }; - - cc.PhysicsSpriteTransformCmd.prototype.rendering = function () { - if (this._node.transform) { - this._node._transformForRenderer(); - } - }; - cc.SkeletonRenderCmdWebGL = function(node){ this._node = node; }; diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 07b1970475..a79399fd73 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -261,13 +261,25 @@ this.initWithSpriteFrame(fileName); } } - this._transformCmd = new cc.PhysicsSpriteTransformCmd(this); + + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._transformCmd = new cc.CustomRenderCmdCanvas(this, function(){ + if (this.transform) { + this.transform(); + } + }); + else + this._transformCmd = new cc.CustomRenderCmdWebGL(this, function(){ + if(this._transformForRenderer){ + this._transformForRenderer(); + } + }); cc.renderer.pushRenderCommand(this._transformCmd); }, visit: function(){ - cc.Sprite.prototype.visit.call(this); cc.renderer.pushRenderCommand(this._transformCmd); + cc.Sprite.prototype.visit.call(this); }, /** From b89e4402091fa05ecb0d19168b19ccd1f3f034b1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 13:57:27 +0800 Subject: [PATCH 0737/1564] Issue #5933: fixed spine debug mode --- cocos2d/core/renderer/RendererCanvas.js | 59 +++++++++ extensions/spine/CCSkeleton.js | 168 +----------------------- 2 files changed, 61 insertions(+), 166 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 9078e39c6b..359e87e8b0 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -830,4 +830,63 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; this._callback.call(this._node, ctx, scaleX, scaleY); }; + + cc.SkeletonRenderCmdCanvas = function(node){ + this._node = node; + }; + + cc.SkeletonRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ + var node = this._node; + ctx = ctx || cc._renderContext; + + if(!node._debugSlots && !node._debugBones){ + return; + } + var t = node._transformWorld; + ctx.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + var locSkeleton = node._skeleton; + var attachment,slot, i, n, drawingUtil = cc._drawingUtil; + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + var points = []; + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); + drawingUtil.drawPoly(points, 4, true); + } + } + + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + if (i === 0) + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + ctx.restore(); + }; } diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 585d964fa6..c847deea23 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -95,6 +95,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ _initRendererCmd:function () { if(cc._renderType === cc._RENDER_TYPE_WEBGL) this._rendererCmd = new cc.SkeletonRenderCmdWebGL(this); + else + this._rendererCmd = new cc.SkeletonRenderCmdCanvas(this); }, /** @@ -380,175 +382,9 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ selSprite.setRotation(- (slot.bone.worldRotation + attachment.rotation)); } } - }, - - /** - * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function - * @function - * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context - */ - draw: null, - - _drawForWebGL: function () { - cc.nodeDrawSetup(this); -// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - var color = this.getColor(), locSkeleton = this._skeleton; - locSkeleton.r = color.r / 255; - locSkeleton.g = color.g / 255; - locSkeleton.b = color.b / 255; - locSkeleton.a = this.getOpacity() / 255; - if (this._premultipliedAlpha) { - locSkeleton.r *= locSkeleton.a; - locSkeleton.g *= locSkeleton.a; - locSkeleton.b *= locSkeleton.a; - } - - var additive,textureAtlas,attachment,slot, i, n, - quad = new cc.V3F_C4B_T2F_Quad(); - var locBlendFunc = this._blendFunc; - - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - var regionTextureAtlas = this.getTextureAtlas(attachment); - - if (slot.data.additiveBlending != additive) { - if (textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - additive = !additive; - cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); - } else if (regionTextureAtlas != textureAtlas && textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - textureAtlas = regionTextureAtlas; - - var quadCount = textureAtlas.getTotalQuads(); - if (textureAtlas.getCapacity() == quadCount) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) - return; - } - - sp._regionAttachment_updateQuad(attachment, slot, quad, this._premultipliedAlpha); - textureAtlas.updateQuad(quad, quadCount); - } - - if (textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - - var drawingUtil = cc._drawingUtil; - if (this._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); - - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - quad = new cc.V3F_C4B_T2F_Quad(); - sp._regionAttachment_updateQuad(attachment, slot, quad); - - var points = []; - points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); - points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); - points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); - points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); - drawingUtil.drawPoly(points, 4, true); - } - } - - if (this._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); - } - - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); - if (i == 0) { - drawingUtil.setDrawColor(0, 255, 0, 255); - } - } - } - }, - - _drawForCanvas: function () { - if(!this._debugSlots && !this._debugBones){ - return; - } - var locSkeleton = this._skeleton; - var attachment,slot, i, n, drawingUtil = cc._drawingUtil; - if (this._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); - - var points = []; - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); - drawingUtil.drawPoly(points, 4, true); - } - } - - if (this._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); - } - - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); - if (i === 0) - drawingUtil.setDrawColor(0, 255, 0, 255); - } - } } }); -if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - sp.Skeleton.prototype.draw = sp.Skeleton.prototype._drawForWebGL; -}else{ - sp.Skeleton.prototype.draw = sp.Skeleton.prototype._drawForCanvas; -} - /** * Creates a skeleton object. * @deprecated since v3.0, please use new sp.Skeleton(skeletonDataFile, atlasFile, scale) instead. From edecbd3e76b0fffc062a1abd24d81a5293ed8144 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 15:16:29 +0800 Subject: [PATCH 0738/1564] Sprite setTexture. Listen for the load event. --- cocos2d/core/sprites/CCSprite.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index b23fda3671..fb5d4561a0 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1589,10 +1589,16 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(texture && (cc.isString(texture))){ texture = cc.textureCache.addImage(texture); _t.setTexture(texture); - //TODO var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); + //If image isn't loaded. Listen for the load event. + if(!texture._isLoaded){ + texture.addLoadedEventListener(function(){ + var size = texture.getContentSize(); + _t.setTextureRect(cc.rect(0,0, size.width, size.height)); + }, this); + } return; } From dcab6af69836477d2dc4979204d2dd8bda327550 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 15:23:59 +0800 Subject: [PATCH 0739/1564] Sprite setTexture. Listen for the load event. --- cocos2d/core/sprites/SpritesWebGL.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 86b3e34e30..7cd7363e2f 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -474,6 +474,13 @@ cc._tmp.WebGLSprite = function () { //TODO var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); + //If image isn't loaded. Listen for the load event. + if(!texture._isLoaded){ + texture.addLoadedEventListener(function(){ + var size = texture.getContentSize(); + _t.setTextureRect(cc.rect(0,0, size.width, size.height)); + }, this); + } return; } // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet From 6c87ac4c72429850d823eb4f68778211edd4d27e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 15:48:55 +0800 Subject: [PATCH 0740/1564] Issue #5933: RemoveChild must be update childrenDirty --- cocos2d/core/base-nodes/CCNode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 9df687d51d..e0e213899c 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1352,6 +1352,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ this._detachChild(child, cleanup); this.setNodeDirty(); + cc.renderer.childrenOrderDirty = true; }, /** From d921144395ff0a84b35e8aac5e29486af70bbdd5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 17:07:27 +0800 Subject: [PATCH 0741/1564] Issue #5933: Fixed repeat drawing scale9sprite bug --- extensions/ccui/base-classes/UIScale9Sprite.js | 3 ++- extensions/gui/control-extension/CCScale9Sprite.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index b8ecb1ac29..4cd4225b54 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -208,7 +208,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, _cacheScale9Sprite: function(){ - if(!this._scale9Image) + if(!this._scale9Image && !this._scale9Dirty) return; var size = this._contentSize, locCanvas = this._cacheCanvas; var contentSizeChanged = false; @@ -224,6 +224,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._scale9Image.visit(); //draw to cache canvas + this._cacheContext.clearRect(0, 0, size.width, -size.height); cc.renderer._renderingToCacheCanvas(this._cacheContext); if(contentSizeChanged) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 23a944d91c..08cc7ff535 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -206,7 +206,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, _cacheScale9Sprite: function(){ - if(!this._scale9Image) + if(!this._scale9Image && !this._scale9Dirty) return; var size = this._contentSize, locCanvas = this._cacheCanvas; var contentSizeChanged = false; @@ -222,6 +222,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._scale9Image.visit(); //draw to cache canvas + this._cacheContext.clearRect(0, 0, size.width, -size.height); cc.renderer._renderingToCacheCanvas(this._cacheContext); if(contentSizeChanged) From 2637fd3ccba8a1f8d409a2f9066a65142bd63fdd Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 9 Oct 2014 18:26:44 +0800 Subject: [PATCH 0742/1564] apprequest link comment --- external/pluginx/platform/facebook.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index cbbd113571..cdf8417b4e 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -495,7 +495,6 @@ plugin.extend('facebook', { delete info['imagePath']; delete info['photo']; - info['caption'] = info['title'] || info['caption']; delete info['title']; @@ -523,9 +522,9 @@ plugin.extend('facebook', { return; } } else { - if (!info['href']) { - return; - } + //if (!info['href']) { + // return; + //} } if ( From 8e32e79fd7620e1fbb09b20544e19af595e2a53b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Oct 2014 18:29:06 +0800 Subject: [PATCH 0743/1564] Issue #5933: webgl update position --- extensions/ccui/base-classes/UIWidget.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index a8ecd23ff9..ea96a97699 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -985,6 +985,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } cc.Node.prototype.setPosition.call(this, pos, posY); + //TODO CHECK HERE, WEBGL DOSEN'T UPDATE ELEMENT + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + cc.renderer.childrenOrderDirty = true; }, setPositionX: function (x) { From 2f1c074324e97d09333c86c1d1b41694e43f7328 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 10 Oct 2014 10:51:45 +0800 Subject: [PATCH 0744/1564] Fixed #5964: Overwrite existing viewport to support more devices --- cocos2d/core/platform/CCEGLView.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 57739017d1..e515d6a111 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -238,6 +238,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ var viewportMetas, elems = document.getElementsByName("viewport"), + currentVP = elems ? elems[0] : null, content; vp = cc.newElement("meta"); @@ -254,7 +255,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ if(cc.sys.isMobile) viewportMetas["target-densitydpi"] = this._targetDensityDPI; - content = (elems && elems.length>0) ? elems[0].content : ""; + content = currentVP ? currentVP.content : ""; for (var key in viewportMetas) { var pattern = new RegExp(key); @@ -276,6 +277,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ content ="width="+width+","+content; */ vp.content = content; + // For adopting certain android devices which don't support second viewport + currentVP.content = content; document.head.appendChild(vp); } From 6307da6a885589f628491deafb6376fd447c0d23 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Oct 2014 11:12:05 +0800 Subject: [PATCH 0745/1564] Issue #5933: Remove getter --- cocos2d/core/layers/CCLayer.js | 2 - cocos2d/core/renderer/RendererCanvas.js | 79 ++++++++++--------------- cocos2d/core/sprites/CCSprite.js | 3 - 3 files changed, 31 insertions(+), 53 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 18916a5ccc..23ea2fff94 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -402,11 +402,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; _p._setWidth = function(width){ cc.Node.prototype._setWidth.call(this, width); - this._rendererCmd._drawingRect.width = width; }; _p._setHeight = function(height){ cc.Node.prototype._setHeight.call(this, height); - this._rendererCmd._drawingRect.height = height; }; _p._updateColor = function () { var locCmd = this._rendererCmd; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 359e87e8b0..aeb78072a0 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -122,13 +122,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { height: 0, validRect: false }; - this._drawingRect = { - //Sprite setTextureRect override ^.^ - get x(){ return node._offsetPosition.x; }, - get y(){ return -node._offsetPosition.y - node._rect.height; }, - get width(){ return node._rect.width; }, - get height(){ return node._rect.height; } - }; }; cc.TextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { @@ -141,7 +134,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (!locTextureCoord.validRect || !node._visible) return; //draw nothing - var t = node._transformWorld, locDrawingRect = self._drawingRect, image, curColor; + var t = node._transformWorld, + locX = node._offsetPosition.x, + locY = -node._offsetPosition.y - node._rect.height, + locWidth = node._rect.width, + locHeight = node._rect.height, + image, + curColor; if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); //transform @@ -166,10 +165,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { 0, locTextureCoord.width, locTextureCoord.height, - locDrawingRect.x * scaleX, - locDrawingRect.y * scaleY, - locDrawingRect.width * scaleX, - locDrawingRect.height * scaleY + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY ); } else { context.drawImage(image, @@ -177,10 +176,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, - locDrawingRect.x * scaleX, - locDrawingRect.y * scaleY, - locDrawingRect.width * scaleX, - locDrawingRect.height * scaleY + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY ); } @@ -189,7 +188,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } else if (!node._texture && locTextureCoord.validRect) { curColor = node._color; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; - context.fillRect(locDrawingRect.x, locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + context.fillRect(locX, locY, locWidth, locHeight); } context.restore(); } else { @@ -209,10 +208,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { 0, locTextureCoord.width, locTextureCoord.height, - (t.tx + locDrawingRect.x) * scaleX, - (-t.ty + locDrawingRect.y) * scaleY, - locDrawingRect.width * scaleX, - locDrawingRect.height * scaleY); + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); } else { context.drawImage( image, @@ -220,10 +219,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, - (t.tx + locDrawingRect.x) * scaleX, - (-t.ty + locDrawingRect.y) * scaleY, - locDrawingRect.width * scaleX, - locDrawingRect.height * scaleY); + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); } } } else if (!node._texture && locTextureCoord.validRect && node._displayedColor) { @@ -231,7 +230,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.globalAlpha = (node._displayedOpacity / 255); curColor = node._displayedColor; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; - context.fillRect(t.tx * scaleX + locDrawingRect.x, -t.ty * scaleY + locDrawingRect.y, locDrawingRect.width, locDrawingRect.height); + context.fillRect(t.tx * scaleX + locX, -t.ty * scaleY + locY, locWidth, locHeight); } if (node._blendFuncStr != "source") @@ -242,17 +241,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.RectRenderCmdCanvas = function (node) { this._node = node; - - this._drawingRect = { - x: 0, - y: 0, - get width(){ - return node.width; - }, - get height(){ - return node.height; - } - }; }; cc.RectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { @@ -261,7 +249,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { t = node._transformWorld, curColor = node._displayedColor, opacity = node._displayedOpacity / 255, - locRect = this._drawingRect; + locWidth = node._contentSize.width, + locHeight = node._contentSize.height; context.save(); if (node._blendFuncStr != "source") @@ -270,7 +259,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," + (0 | curColor.b) + "," + opacity + ")"; - context.fillRect(locRect.x, locRect.y, locRect.width * scaleX, -locRect.height * scaleY); + context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); context.restore(); cc.g_NumberOfDraws++; @@ -278,13 +267,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.GradientRectRenderCmdCanvas = function (node) { this._node = node; - - this._drawingRect = { - x: 0, - y: 0, - get width(){ return node.width; }, - get height(){ return node.height; } - }; this._startPoint = cc.p(0, 0); this._endPoint = cc.p(0, 0); }; @@ -301,7 +283,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); var opacity = node._displayedOpacity / 255, - locRect = this._drawingRect; + locWidth = node._contentSize.width, + locHeight = node._contentSize.height; //TODO need cache gradient object var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); var locStartColor = node._displayedColor, @@ -311,7 +294,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + Math.round(locEndColor.b) + "," + (locEndColor.a!=null?(opacity * (locEndColor.a / 255)).toFixed(4):255) + ")"); context.fillStyle = gradient; - context.fillRect(locRect.x, locRect.y, locRect.width * scaleX, -locRect.height * scaleY); + context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); context.restore(); cc.g_NumberOfDraws++; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 2e5fb80192..28e2bb02f9 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1439,9 +1439,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._offsetPosition.x = relativeOffset.x + (_t._contentSize.width - _t._rect.width) / 2; _t._offsetPosition.y = relativeOffset.y + (_t._contentSize.height - _t._rect.height) / 2; - _t._rendererCmd._drawingRect.x = _t._offsetPosition.x; - _t._rendererCmd._drawingRect.y = _t._offsetPosition.y - _t._rect.height; - // rendering using batch node if (_t._batchNode) { // update dirty, don't update _recursiveDirty From c823cf6a20465121e38330bac0f1e1bc0f46a7d0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Oct 2014 11:14:53 +0800 Subject: [PATCH 0746/1564] Issue #5933: remove modification of error --- extensions/ccui/base-classes/UIWidget.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index ea96a97699..a8ecd23ff9 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -985,9 +985,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } cc.Node.prototype.setPosition.call(this, pos, posY); - //TODO CHECK HERE, WEBGL DOSEN'T UPDATE ELEMENT - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - cc.renderer.childrenOrderDirty = true; }, setPositionX: function (x) { From 850989628acf68ab2469dde0ca500aa9d12b3b3e Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 10 Oct 2014 11:23:18 +0800 Subject: [PATCH 0747/1564] Fixed #5956: Refactor cc.pool for JSB --- extensions/ccpool/CCPool.js | 55 +++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 5dafdf2a8a..660c4dbd41 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -46,8 +46,17 @@ cc.pool = /** @lends cc.pool# */{ _pool: {}, + _releaseCB: function () { + this.release(); + }, + + _autoRelease: function (obj) { + var running = obj._running === undefined ? false : !obj._running; + cc.director.getScheduler().scheduleCallbackForTarget(obj, this._releaseCB, 0, 0, 0, running) + }, + /** - * Put the cc.Node object in pool + * Put the obj in pool * @param obj */ putInPool: function (obj) { @@ -61,26 +70,30 @@ cc.pool = /** @lends cc.pool# */{ if (!this._pool[pid]) { this._pool[pid] = []; } - if(obj.unuse) - obj.unuse(); //define by user. use to initialize the state of objects. - obj.retain && obj.retain();//use for jsb + // JSB retain to avoid being auto released + obj.retain && obj.retain(); + // User implementation for disable the object + obj.unuse && obj.unuse(); this._pool[pid].push(obj); } }, /** - * Check if this kind of object has already in pool + * Check if this kind of obj has already in pool * @param objClass * @returns {boolean} if this kind of obj is already in pool return true,else return false; */ hasObject: function (objClass) { var pid = objClass.prototype.__pid; var list = this._pool[pid]; - return (list && list.length > 0); + if (!list || list.length == 0) { + return false; + } + return true; }, /** - * Remove the object if you want to delete it; + * Remove the obj if you want to delete it; * @param obj */ removeObject: function (obj) { @@ -90,7 +103,8 @@ cc.pool = /** @lends cc.pool# */{ if (list) { for (var i = 0; i < list.length; i++) { if (obj === list[i]) { - obj.release(); //use for jsb + // JSB release to avoid memory leak + obj.release && obj.release(); list.splice(i, 1); } } @@ -99,7 +113,7 @@ cc.pool = /** @lends cc.pool# */{ }, /** - * Get the object from pool + * Get the obj from pool * @param args * @returns {*} call the reuse function an return the obj */ @@ -107,25 +121,26 @@ cc.pool = /** @lends cc.pool# */{ if (this.hasObject(objClass)) { var pid = objClass.prototype.__pid; var list = this._pool[pid]; - var args = Array.prototype.slice.call(arguments, 1); + var args = Array.prototype.slice.call(arguments); + args.shift(); var obj = list.pop(); - obj.release && obj.release();//use for jsb - if(obj.reuse) - obj.reuse.apply(obj, args); //define by user. + // User implementation for re-enable the object + obj.reuse && obj.reuse.apply(obj, args); + // JSB release to avoid memory leak + cc.sys.isNative && obj.release && this._autoRelease(obj); return obj; } }, /** - * remove all object in pool and reset the pool + * remove all objs in pool and reset the pool */ drainAllPools: function () { - var locPool = this._pool; - for (var selKey in locPool) { - for (var j = 0; j < locPool[selKey].length; j++) { - var obj = locPool[selKey][j]; - if(obj && obj.release) - obj.release() + for (var i in this._pool) { + for (var j = 0; j < this._pool[i].length; j++) { + var obj = this._pool[i][j]; + // JSB release to avoid memory leak + obj.release && obj.release(); } } this._pool = {}; From 9821fccf8ef4d340753faf3ea168e67e85fe9112 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 10 Oct 2014 11:23:50 +0800 Subject: [PATCH 0748/1564] Fixed #5956: Activate cc.pool for all kind of object --- extensions/ccpool/CCPool.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 660c4dbd41..4121439db4 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -60,22 +60,20 @@ cc.pool = /** @lends cc.pool# */{ * @param obj */ putInPool: function (obj) { - if (obj instanceof cc.Node) { - var pid = obj.constructor.prototype.__pid; - if (!pid) { - var desc = { writable: true, enumerable: false, configurable: true }; - desc.value = ClassManager.getNewID(); - Object.defineProperty(obj.constructor.prototype, '__pid', desc); - } - if (!this._pool[pid]) { - this._pool[pid] = []; - } - // JSB retain to avoid being auto released - obj.retain && obj.retain(); - // User implementation for disable the object - obj.unuse && obj.unuse(); - this._pool[pid].push(obj); + var pid = obj.constructor.prototype.__pid; + if (!pid) { + var desc = { writable: true, enumerable: false, configurable: true }; + desc.value = ClassManager.getNewID(); + Object.defineProperty(obj.constructor.prototype, '__pid', desc); + } + if (!this._pool[pid]) { + this._pool[pid] = []; } + // JSB retain to avoid being auto released + obj.retain && obj.retain(); + // User implementation for disable the object + obj.unuse && obj.unuse(); + this._pool[pid].push(obj); }, /** From e1714284399bb20ce612a1298154b283e6b23e1a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Oct 2014 11:46:49 +0800 Subject: [PATCH 0749/1564] Issue #5933: Delete the redundant judgments --- cocos2d/core/renderer/RendererCanvas.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index aeb78072a0..e2e4ae1c9a 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -141,12 +141,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locHeight = node._rect.height, image, curColor; + + var blendChange = (node._blendFuncStr !== "source"); + if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (node._blendFuncStr != "source") + if (blendChange) context.globalCompositeOperation = node._blendFuncStr; if (node._flippedX) @@ -154,7 +157,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (node._flippedY) context.scale(1, -1); - if (node._texture && locTextureCoord.validRect) { + if (node._texture) { if (node._texture._isLoaded) { context.globalAlpha = (node._displayedOpacity / 255); image = node._texture._htmlElementObj; @@ -185,19 +188,19 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } - } else if (!node._texture && locTextureCoord.validRect) { + } else if (!node._texture) { curColor = node._color; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; context.fillRect(locX, locY, locWidth, locHeight); } context.restore(); } else { - if (node._blendFuncStr != "source") { + if (blendChange) { context.save(); context.globalCompositeOperation = node._blendFuncStr; } - if (node._texture && locTextureCoord.validRect) { + if (node._texture) { if (node._texture._isLoaded) { context.globalAlpha = (node._displayedOpacity / 255); @@ -225,7 +228,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locHeight * scaleY); } } - } else if (!node._texture && locTextureCoord.validRect && node._displayedColor) { + } else if (!node._texture && node._displayedColor) { context.globalAlpha = (node._displayedOpacity / 255); curColor = node._displayedColor; @@ -233,7 +236,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.fillRect(t.tx * scaleX + locX, -t.ty * scaleY + locY, locWidth, locHeight); } - if (node._blendFuncStr != "source") + if (blendChange) context.restore(); } cc.g_NumberOfDraws++; From adf41e46dc46dd611c51830a2a5e8a1f78adbb0e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Oct 2014 16:07:20 +0800 Subject: [PATCH 0750/1564] Issue #5933: Arrangement 1. Remove excess visit 2. Remove RendererTextureCmdCanvas --- cocos2d/core/renderer/RendererCanvas.js | 61 ----------------------- cocos2d/render-texture/CCRenderTexture.js | 10 +--- 2 files changed, 2 insertions(+), 69 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index e2e4ae1c9a..3985263055 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -476,46 +476,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.g_NumberOfDraws++; }; - // the canvas implement of renderCommand for cc.RenderTexture - cc.RenderTextureRenderCmdCanvas = function (node) { - this._node = node; - - //CCRenderTexture _initWithWidthAndHeightForCanvas - this._cacheCanvas = null; - this._cacheContext = null; - }; - - cc.RenderTextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - // auto draw flag - var context = ctx || cc._renderContext, - node = this._node; - var locNode = this._node, cacheCanvas = this._cacheCanvas, cacheCtx = this._cacheContext; - if (node.autoDraw) { - locNode.begin(); - - if (node._clearFlags) { - cacheCtx.save(); - cacheCtx.fillStyle = this._clearColorStr; - cacheCtx.clearRect(0, 0, cacheCanvas.width, -cacheCanvas.height); - cacheCtx.fillRect(0, 0, cacheCanvas.width, -cacheCanvas.height); - cacheCtx.restore(); - } - - //! make sure all children are drawn - locNode.sortAllChildren(); - var locChildren = locNode._children; - var childrenLen = locChildren.length; - var selfSprite = this.sprite; - for (var i = 0; i < childrenLen; i++) { - var getChild = locChildren[i]; - if (getChild != selfSprite) - getChild.visit(); - } - locNode.end(); - } - cc.g_NumberOfDraws++; - }; - cc.DrawNodeRenderCmdCanvas = function (node) { this._node = node; this._buffer = null; @@ -683,7 +643,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { var node = this._node; - var i, children = node._children, locChild; var locCache = cc.ClippingNode._getSharedCache(); var context = ctx || cc._renderContext; if (node._clipElemType) { @@ -696,26 +655,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.drawImage(locCache, 0, 0); context.restore(); } else { - // so if it has ClippingNode as a child, the child must uses composition stencil. - node._cangodhelpme(true); - var len = children.length; - if (len > 0) { - node.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - locChild = children[i]; - if (locChild._localZOrder < 0) - locChild.visit(context); - else - break; - } - node.draw(context); - for (; i < len; i++) { - children[i].visit(context); - } - } else - node.draw(context); - node._cangodhelpme(false); context.restore(); } }; diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 9d13cdb68b..196e1e194b 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -158,11 +158,9 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ _initRendererCmd: function(){ //TODO need merge in some code - if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._rendererCmd = new cc.RenderTextureRenderCmdCanvas(this); - else{ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) this._rendererCmd = new cc.RenderTextureRenderCmdWebGL(this); - } + }, _ctorForWebGL: function (width, height, format, depthStencilFormat) { @@ -246,10 +244,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ this.autoDraw = false; // add sprite for backward compatibility this.addChild(locSprite); - var locCmd = this._rendererCmd; - locCmd._sprite = this.sprite; - locCmd._cacheCanvas = this._cacheCanvas; - locCmd._cacheContext = this._cacheContext; return true; }, From f23e3309a936ece16926ce9942962bef3b44de32 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Fri, 10 Oct 2014 18:25:52 +0800 Subject: [PATCH 0751/1564] fix the bug that FPS will be doubled after swich browser tabs --- CCBoot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 55203c2bfe..fc46068337 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -2008,6 +2008,8 @@ cc.game = /** @lends cc.game# */{ callback = function () { if (!self._paused) { director.mainLoop(); + if(self._intervalId) + window.cancelAnimationFrame(self._intervalId); self._intervalId = window.requestAnimFrame(callback); } }; From 99f387979e42ba8e4ecf1b497e32c9b101302507 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Oct 2014 18:26:06 +0800 Subject: [PATCH 0752/1564] Issue #5933: Fixed armature setDisplay position error --- extensions/cocostudio/armature/display/CCDecorativeDisplay.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js index 3a3b3116b6..fa54cefc34 100644 --- a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +++ b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js @@ -55,6 +55,10 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ * @param {cc.Node} display */ setDisplay:function (display) { + if(display._parent){ + display._parent.removeChild(display); + delete display._parent; + } this._display = display; }, From 5e63f16e078340d115b4485e6cd37de71266b84e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Oct 2014 19:59:17 +0800 Subject: [PATCH 0753/1564] Issue #5933: scale9sprite to update cache --- extensions/ccui/base-classes/UIScale9Sprite.js | 7 +++++++ extensions/gui/control-extension/CCScale9Sprite.js | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 4cd4225b54..3fe8b84492 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -511,6 +511,13 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ } }, + _transformForRenderer: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + this._cacheScale9Sprite(); + this.transform(); + } + }, + /** * Initializes a ccui.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @returns {boolean} diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 08cc7ff535..01dc1b8204 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -509,6 +509,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } }, + _transformForRenderer: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + this._cacheScale9Sprite(); + this.transform(); + } + }, + /** * Initializes a cc.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @returns {boolean} From a621655c98684ec0e71403d96716b378b0359035 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Oct 2014 20:20:04 +0800 Subject: [PATCH 0754/1564] Issue #5933: scale9sprite to update cache --- extensions/ccui/base-classes/UIScale9Sprite.js | 1 + extensions/gui/control-extension/CCScale9Sprite.js | 1 + 2 files changed, 2 insertions(+) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 3fe8b84492..c063660645 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -516,6 +516,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._cacheScale9Sprite(); this.transform(); } + cc.Node.prototype._transformForRenderer.call(this); }, /** diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 01dc1b8204..db9a897f5d 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -514,6 +514,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._cacheScale9Sprite(); this.transform(); } + cc.Node.prototype._transformForRenderer.call(this); }, /** From 14b64cf5197a10084050d5f1b52753bc58c76e6a Mon Sep 17 00:00:00 2001 From: joshuastray Date: Sat, 11 Oct 2014 11:18:29 +0800 Subject: [PATCH 0755/1564] fix the bug of scrollview not transformed correctly --- extensions/ccui/layouts/UILayout.js | 6 ++++++ extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 33eb8794eb..71b406501b 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1805,6 +1805,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.setClippingType(layout._clippingType); this._loopFocus = layout._loopFocus; this.__passFocusToChild = layout.__passFocusToChild; + }, + + _transformForRenderer: function(parentMatrix){ + cc.Node.prototype._transformForRenderer.call(this, parentMatrix); + if(this._clippingStencil) + this._clippingStencil._transformForRenderer(this._stackMatrix); } }); ccui.Layout._init_once = null; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index c0eb838d19..8ce12c2149 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1721,6 +1721,12 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ addNode: function (node, zOrder, tag) { this._innerContainer.addNode(node, zOrder, tag); + }, + + _transformForRenderer: function(parentMatrix){ + ccui.Layout.prototype._transformForRenderer.call(this, parentMatrix); + if(this._innerContainer) + this._innerContainer._transformForRenderer(this._stackMatrix); } }); From 3207ce99a22c1dfc98b79867a34802a4e273b042 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 11 Oct 2014 13:36:18 +0800 Subject: [PATCH 0756/1564] Fixed #5941: correct some mistakes of cc.NodeGrid, CCActionGrid3D, CCActionTiledGrid and CCTransition --- cocos2d/actions3d/CCActionGrid3D.js | 2 +- cocos2d/actions3d/CCActionTiledGrid.js | 1 + cocos2d/core/base-nodes/BaseNodesWebGL.js | 2 +- cocos2d/effects/CCGrid.js | 24 ++++------ cocos2d/node-grid/CCNodeGrid.js | 37 ++++++--------- cocos2d/transitions/CCTransition.js | 51 +++++++++++++++------ cocos2d/transitions/CCTransitionPageTurn.js | 24 ++++++++-- 7 files changed, 84 insertions(+), 57 deletions(-) diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index 1332fd0e1f..d795c69b40 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -398,7 +398,7 @@ cc.FlipY3D.create = cc.flipY3D; * Upside down.
    * Reference the test cases (Effects Test) * @class - * @extends cc.FlipX3D + * @extends cc.Grid3DAction * @param {Number} duration * @param {cc.Size} gridSize * @param {cc.Point} position diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index 41be41b231..ff9b42e6be 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -1251,6 +1251,7 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ this.setTile(locPos, coords); } + cc.renderer.childrenOrderDirty = true; }, /** diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index bc3ac65d78..27e5b7f9ee 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -150,7 +150,7 @@ cc._tmp.WebGLCCNode = function () { cc.kmMat4Translation(translation, -apx, -apy, 0); cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); } else { - this._camera.locate(); + this._camera._locateForRenderer(stackMatrix); } } diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index f93dfd40a0..ed7e82f877 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -138,7 +138,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ }, /** - * get wheter or not the texture is flipped + * get whether or not the texture is flipped * @return {Boolean} */ isTextureFlipped:function () { @@ -146,7 +146,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ }, /** - * set wheter or not the texture is flipped + * set whether or not the texture is flipped * @param {Boolean} flipped */ setTextureFlipped:function (flipped) { @@ -210,9 +210,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ // save projection this._directorProjection = cc.director.getProjection(); - // 2d projection - // [director setProjection:kCCDirectorProjection2D]; - this.set2DProjection(); + //this.set2DProjection(); //TODO why? this._grabber.beforeRender(this._texture); }, @@ -220,9 +218,9 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ this._grabber.afterRender(this._texture); // restore projection - cc.director.setProjection(this._directorProjection); + //cc.director.setProjection(this._directorProjection); - if (target.getCamera().isDirty()) { + if (target && target.getCamera().isDirty()) { var offset = target.getAnchorPointInPoints(); // @@ -234,10 +232,6 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ } cc.glBindTexture2D(this._texture); - - // restore projection for default FBO .fixed bug #543 #544 - //TODO: CCDirector::sharedDirector().setProjection(CCDirector::sharedDirector().getProjection()); - //TODO: CCDirector::sharedDirector().applyOrientation(); this.blit(); }, @@ -362,11 +356,12 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ this._dirty = true; }, - blit:function () { + blit:function (target) { var n = this._gridSize.width * this._gridSize.height; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS); this._shaderProgram.use(); this._shaderProgram.setUniformsForBuiltins(); + //this._shaderProgram._setUniformsForBuiltinsForRenderer(target); var gl = cc._renderContext, locDirty = this._dirty; // @@ -590,11 +585,12 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ this._dirty = true; }, - blit:function () { + blit:function (target) { var n = this._gridSize.width * this._gridSize.height; this._shaderProgram.use(); this._shaderProgram.setUniformsForBuiltins(); + //this._shaderProgram._setUniformsForBuiltinsForRenderer(target); // // Attributes @@ -720,7 +716,7 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ /** * create one TiledGrid3D object - * @deprecated since v3.0, plese use new cc.TiledGrid3D(gridSize, texture, flipped) instead + * @deprecated since v3.0, please use new cc.TiledGrid3D(gridSize, texture, flipped) instead * @param {cc.Size} gridSize * @param {cc.Texture2D} [texture=] * @param {Boolean} [flipped=] diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index 58d33c2408..1d9b39dd37 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -40,7 +40,6 @@ cc.NodeGrid = cc.Node.extend({ ctor: function(){ cc.Node.prototype.ctor.call(this); - if(cc._renderType === cc._RENDER_TYPE_WEBGL){ this._gridBeginCommand = new cc.CustomRenderCmdWebGL(this, this.onGridBeginDraw); this._gridEndCommand = new cc.CustomRenderCmdWebGL(this, this.onGridEndDraw); @@ -68,25 +67,7 @@ cc.NodeGrid = cc.Node.extend({ * @param {cc.Node} target */ setTarget: function (target) { - //var self = this; - //self._target && self.removeChild(self._target); this._target = target; - //self.addChild(self._target); - }, - - /**

    "add" logic MUST only be in this method

    - * - *

    If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.

    - * @function - * @param {cc.Node} child A child node - * @param {Number} [zOrder=] Z order for drawing priority. Please refer to setZOrder(int) - * @param {Number} [tag=] A integer to identify the node easily. Please refer to setTag(int) - */ - addChild: function (child, zOrder, tag) { - cc.Node.prototype.addChild.call(this, child, zOrder, tag); - - if (child && !this._target) - this._target = child; }, onGridBeginDraw: function(){ @@ -109,6 +90,7 @@ cc.NodeGrid = cc.Node.extend({ // quick return if not visible if (!self._visible) return; + var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; if(isWebGL){ var currentStack = cc.current_stack; @@ -120,10 +102,17 @@ cc.NodeGrid = cc.Node.extend({ self.transform(); if(isWebGL){ + var beforeProjectionType = cc.director.PROJECTION_DEFAULT; - if (isWebGL && locGrid && locGrid._active){ + if (locGrid && locGrid._active){ + //var backMatrix = new cc.kmMat4(); + //cc.kmMat4Assign(backMatrix, this._stackMatrix); + beforeProjectionType = cc.director.getProjection(); - locGrid.set2DProjection(); + //locGrid.set2DProjection(); + + //reset this._stackMatrix to current_stack.top + //cc.kmMat4Assign(currentStack.top, backMatrix); } if(this._gridBeginCommand) cc.renderer.pushRenderCommand(this._gridBeginCommand); @@ -143,8 +132,10 @@ cc.NodeGrid = cc.Node.extend({ } } - if(isWebGL && locGrid && locGrid._active){ - cc.director.setProjection(beforeProjectionType); + if(isWebGL){ + if(locGrid && locGrid._active){ + //cc.director.setProjection(beforeProjectionType); + } if(this._gridEndCommand) cc.renderer.pushRenderCommand(this._gridEndCommand); currentStack.top = currentStack.stack.pop(); diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 258f40dfb3..7ecee6852f 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -1056,14 +1056,14 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF outAngleZ = 0; } - inA = cc.Sequence.create( - cc.DelayTime.create(this._duration / 2), cc.Show.create(), - cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0), - cc.CallFunc.create(this.finish, this) + inA = cc.sequence( + cc.delayTime(this._duration / 2), cc.show(), + cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0), + cc.callFunc(this.finish, this) ); - outA = cc.Sequence.create( - cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0), - cc.Hide.create(), cc.DelayTime.create(this._duration / 2) + outA = cc.sequence( + cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0), + cc.hide(), cc.delayTime(this._duration / 2) ); this._inScene.runAction(inA); @@ -1598,6 +1598,13 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross cc.TransitionScene.prototype.onExit.call(this); }, + /** + * stuff gets drawn here + */ + visit:function () { + cc.Node.prototype.visit.call(this); + }, + /** * overide draw */ @@ -1629,7 +1636,7 @@ cc.TransitionCrossFade.create = function (t, scene) { * var trans = new cc.TransitionTurnOffTiles(time,scene); */ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTurnOffTiles# */{ - + _gridProxy: null, /** * Constructor of TransitionCrossFade * @param {Number} t time in seconds @@ -1637,6 +1644,7 @@ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTu */ ctor:function (t, scene) { cc.TransitionScene.prototype.ctor.call(this); + this._gridProxy = new cc.NodeGrid(); scene && this.initWithDuration(t, scene); }, @@ -1649,13 +1657,21 @@ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTu */ onEnter:function () { cc.TransitionScene.prototype.onEnter.call(this); + this._gridProxy.setTarget(this._outScene); + this._gridProxy.onEnter(); + var winSize = cc.director.getWinSize(); var aspect = winSize.width / winSize.height; var x = 0 | (12 * aspect); var y = 12; var toff = cc.turnOffTiles(this._duration, cc.size(x, y)); var action = this.easeActionWithAction(toff); - this._outScene.runAction(cc.sequence(action, cc.callFunc(this.finish, this), cc.stopGrid())); + this._gridProxy.runAction(cc.sequence(action, cc.callFunc(this.finish, this), cc.stopGrid())); + }, + + visit: function(){ + this._inScene.visit(); + this._gridProxy.visit(); }, /** @@ -1731,7 +1747,6 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit }, visit: function(){ - cc.TransitionScene.prototype.visit.call(this); this._gridProxy.visit(); }, @@ -1815,7 +1830,7 @@ cc.TransitionSplitRows.create = function (t, scene) { * var trans = new cc.TransitionFadeTR(time,scene); */ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */{ - + _gridProxy: null, /** * Constructor of TransitionFadeTR * @param {Number} t time in seconds @@ -1823,6 +1838,7 @@ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */ ctor:function (t, scene) { cc.TransitionScene.prototype.ctor.call(this); + this._gridProxy = new cc.NodeGrid(); scene && this.initWithDuration(t, scene); }, _sceneOrder:function () { @@ -1835,18 +1851,25 @@ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# onEnter:function () { cc.TransitionScene.prototype.onEnter.call(this); + this._gridProxy.setTarget(this._outScene); + this._gridProxy.onEnter(); + var winSize = cc.director.getWinSize(); var aspect = winSize.width / winSize.height; var x = 0 | (12 * aspect); var y = 12; var action = this.actionWithSize(cc.size(x, y)); - this._outScene.runAction( - cc.Sequence.create(this.easeActionWithAction(action), cc.CallFunc.create(this.finish, this), - cc.StopGrid.create()) + this._gridProxy.runAction( + cc.sequence(this.easeActionWithAction(action), cc.callFunc(this.finish, this), cc.stopGrid()) ); }, + visit: function(){ + this._inScene.visit(); + this._gridProxy.visit(); + }, + /** * @param {cc.ActionInterval} action * @return {cc.ActionInterval} diff --git a/cocos2d/transitions/CCTransitionPageTurn.js b/cocos2d/transitions/CCTransitionPageTurn.js index b6f1800118..e3e8ac38ce 100644 --- a/cocos2d/transitions/CCTransitionPageTurn.js +++ b/cocos2d/transitions/CCTransitionPageTurn.js @@ -49,6 +49,7 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu */ ctor:function (t, scene, backwards) { cc.TransitionScene.prototype.ctor.call(this); + this._gridProxy = new cc.NodeGrid(); this.initWithDuration(t, scene, backwards); }, @@ -56,6 +57,7 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu * @type Boolean */ _back:true, + _gridProxy: null, _className:"TransitionPageTurn", /** @@ -103,19 +105,33 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu y = 16; } - var action = this.actionWithSize(cc.size(x, y)); + var action = this.actionWithSize(cc.size(x, y)), gridProxy = this._gridProxy; if (!this._back) { - this._outScene.runAction( cc.sequence(action,cc.CallFunc.create(this.finish, this),cc.StopGrid.create())); + gridProxy.setTarget(this._outScene); + gridProxy.onEnter(); + gridProxy.runAction( cc.sequence(action,cc.callFunc(this.finish, this),cc.stopGrid())); } else { + gridProxy.setTarget(this._inScene); + gridProxy.onEnter(); // to prevent initial flicker this._inScene.visible = false; - this._inScene.runAction( - cc.sequence(cc.show(),action, cc.callFunc(this.finish, this), cc.stopGrid()) + gridProxy.runAction( + cc.sequence(action, cc.callFunc(this.finish, this), cc.stopGrid()) ); + this._inScene.runAction(cc.show()); } }, + visit: function(){ + //cc.TransitionScene.prototype.visit.call(this); + if(this._back) + this._outScene.visit(); + else + this._inScene.visit(); + this._gridProxy.visit(); + }, + _sceneOrder:function () { this._isInSceneOnTop = this._back; } From 36f5c7c6efc75c85c7c11bd3a732eaacd2e7b7d9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 11 Oct 2014 14:12:25 +0800 Subject: [PATCH 0757/1564] Feature #5950: Polish Facebook Web SDK --- external/pluginx/platform/facebook.js | 327 ++++++++++++-------------- 1 file changed, 148 insertions(+), 179 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index cdf8417b4e..70ee0b6deb 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -23,86 +23,116 @@ ****************************************************************************/ /** - * Facebook APIs
    + * Facebook SDK for Web Platform
    * FacebookAgent... * * @property {String} name - plugin name * @property {String} version - API version - * @property {Object} userInfo - store user data - * @property {Object} HttpMethod - store http method static param - * @property {Number} CodeSucceed - success code */ plugin.extend('facebook', { name: "", version: "", - userInfo: null, + _userInfo: null, + _isLoggedIn: false, + /** + * HTTP methods constants + * @constant + * @type {Object} + */ HttpMethod: { 'GET': 'get', 'POST': 'post', 'DELETE': 'delete' }, + /** + * Succeed code returned in callbacks + * @constant + * @type {Number} + */ CODE_SUCCEED: 0, + + /** + * App event names constants + * @constant + * @type {Object} + */ AppEvent: { - 'ACTIVATED_APP': "fb_mobile_activate_app", - 'COMPLETED_REGISTRATION': "fb_mobile_complete_registration", - 'VIEWED_CONTENT': "fb_mobile_content_view", - 'SEARCHED': "fb_mobile_search", - 'RATED': "fb_mobile_rate", - 'COMPLETED_TUTORIAL': "fb_mobile_tutorial_completion", - 'ADDED_TO_CART': "fb_mobile_add_to_cart", - 'ADDED_TO_WISHLIST': "fb_mobile_add_to_wishlist", - 'INITIATED_CHECKOUT': "fb_mobile_initiated_checkout", - 'ADDED_PAYMENT_INFO': "fb_mobile_add_payment_info", - 'PURCHASED': "fb_mobile_purchase", - 'ACHIEVED_LEVEL': "fb_mobile_level_achieved", - 'UNLOCKED_ACHIEVEMENT': "fb_mobile_achievement_unlocked", - 'SPENT_CREDITS': "fb_mobile_spent_credits" + 'ACTIVATED_APP': FB.AppEvents.EventNames.ACTIVATED_APP, + 'COMPLETED_REGISTRATION': FB.AppEvents.EventNames.COMPLETED_REGISTRATION, + 'VIEWED_CONTENT': FB.AppEvents.EventNames.VIEWED_CONTENT, + 'SEARCHED': FB.AppEvents.EventNames.SEARCHED, + 'RATED': FB.AppEvents.EventNames.RATED, + 'COMPLETED_TUTORIAL': FB.AppEvents.EventNames.COMPLETED_TUTORIAL, + 'ADDED_TO_CART': FB.AppEvents.EventNames.ADDED_TO_CART, + 'ADDED_TO_WISHLIST': FB.AppEvents.EventNames.ADDED_TO_WISHLIST, + 'INITIATED_CHECKOUT': FB.AppEvents.EventNames.INITIATED_CHECKOUT, + 'ADDED_PAYMENT_INFO': FB.AppEvents.EventNames.ADDED_PAYMENT_INFO, + 'PURCHASED': FB.AppEvents.EventNames.PURCHASED, + 'ACHIEVED_LEVEL': FB.AppEvents.EventNames.ACHIEVED_LEVEL, + 'UNLOCKED_ACHIEVEMENT': FB.AppEvents.EventNames.UNLOCKED_ACHIEVEMENT, + 'SPENT_CREDITS': FB.AppEvents.EventNames.SPENT_CREDITS }, + /** + * App event parameter names constants + * @constant + * @type {Object} + */ AppEventParam: { - 'CURRENCY': "fb_currency", - 'REGISTRATION_METHOD': "fb_registration_method", - 'CONTENT_TYPE': "fb_content_type", - 'CONTENT_ID': "fb_content_id", - 'SEARCH_STRING': "fb_search_string", - 'SUCCESS': "fb_success", - 'MAX_RATING_VALUE': "fb_max_rating_value", - 'PAYMENT_INFO_AVAILABLE': "fb_payment_info_available", - 'NUM_ITEMS': "fb_num_items", - 'DESCRIPTION': "fb_description" + 'CURRENCY': FB.AppEvents.ParameterNames.CURRENCY, + 'REGISTRATION_METHOD': FB.AppEvents.ParameterNames.REGISTRATION_METHOD, + 'CONTENT_TYPE': FB.AppEvents.ParameterNames.CONTENT_TYPE, + 'CONTENT_ID': FB.AppEvents.ParameterNames.CONTENT_ID, + 'SEARCH_STRING': FB.AppEvents.ParameterNames.SEARCH_STRING, + 'SUCCESS': FB.AppEvents.ParameterNames.SUCCESS, + 'MAX_RATING_VALUE': FB.AppEvents.ParameterNames.MAX_RATING_VALUE, + 'PAYMENT_INFO_AVAILABLE': FB.AppEvents.ParameterNames.PAYMENT_INFO_AVAILABLE, + 'NUM_ITEMS': FB.AppEvents.ParameterNames.NUM_ITEMS, + 'LEVEL': FB.AppEvents.ParameterNames.LEVEL, + 'DESCRIPTION': FB.AppEvents.ParameterNames.DESCRIPTION }, + + /** + * App event parameter values constants + * @constant + * @type {Object} + */ AppEventParamValue: { 'VALUE_YES': "1", 'VALUE_NO': "0" }, - /** - * Initialize Facebook sdk - * @param {Object} config - */ + + _checkLoginStatus: function() { + var self = this; + FB.getLoginStatus(function (response) { + if (response && response.status === 'connected') { + //login + self._isLoggedIn = true; + //save user info + self._userInfo = response['authResponse']; + } else { + // Reset cached status + self._isLoggedIn = false; + self._userInfo = {}; + } + }); + }, + ctor: function (config) { this.name = "facebook"; this.version = "1.0"; - this.userInfo = {}; + this._userInfo = {}; + this._isLoggedIn = false; if (!FB) { return; } - var self = this; //This configuration will be read from the project.json. FB.init(config); - FB.getLoginStatus(function (response) { - if (response && response.status === 'connected') { - //login - self._isLogined = true; - //save user info - self.userInfo = response.authResponse; - } else { - self._isLogined = false; - } - }); + this._checkLoginStatus(); plugin.FacebookAgent = this; }, @@ -137,7 +167,7 @@ plugin.extend('facebook', { FB.login(function (response) { if (response['authResponse']) { //save user info - self.userInfo = response['authResponse']; + self._userInfo = response['authResponse']; var permissList = response['authResponse']['grantedScopes'].split(","); typeof callback === 'function' && callback(0, { accessToken: response['authResponse']['accessToken'], @@ -155,34 +185,14 @@ plugin.extend('facebook', { }, /** * Checking login status - * @param {Function} callback + * @return {Bool} Whether user is logged in * @example * //example * plugin.FacebookAgent.isLoggedIn(type, msg); */ - isLoggedIn: function (callback) { - var self = this; - FB.getLoginStatus(function (response) { - if (response) { - if (response['status'] === 'connected') { - //login - save user info - self.userInfo = response['authResponse']; - typeof callback === 'function' && callback(0, { - isLoggedIn: true, - accessToken: response['authResponse']['accessToken'] - }); - } else { - typeof callback === 'function' && callback(0, { - isLoggedIn: false, - accessToken: "" - }); - } - } else { - typeof callback === 'function' && callback(1, { - error_message: 'Unknown' - }); - } - }); + isLoggedIn: function () { + //this._checkLoginStatus(); + return this._isLoggedIn; }, /** @@ -197,7 +207,8 @@ plugin.extend('facebook', { FB.logout(function (response) { if (response['authResponse']) { // user is now logged out - self.userInfo = {}; + self._isLoggedIn = false; + self._userInfo = {}; typeof callback === 'function' && callback(0, {"isLoggedIn": false}); } else { typeof callback === 'function' && callback(response['error_code'] || 1, { @@ -216,14 +227,14 @@ plugin.extend('facebook', { * //example * plugin.FacebookAgent.requestPermissions(["manage_pages"], callback); */ - requestPermissions: function (permissions, callback) { + _requestPermissions: function (permissions, callback) { var permissionsStr = permissions.join(','); var self = this; FB.login(function (response) { if (response['authResponse']) { var permissList = response['authResponse']['grantedScopes'].split(","); //save user info - self.userInfo = response['authResponse']; + self._userInfo = response['authResponse']; typeof callback === 'function' && callback(0, { permissions: permissList }); @@ -240,45 +251,27 @@ plugin.extend('facebook', { /** * Acquiring AccessToken - * @param {Function} callback + * @return {String} * @example * //example - * plugin.FacebookAgent.requestPermissions(callback); + * var accessToken = plugin.FacebookAgent.getAccessToken(); */ - requestAccessToken: function (callback) { - if (typeof callback !== 'function') { - return; - } - - if (this.userInfo.accessToken) { - callback(0, { - accessToken: this.userInfo['accessToken'] - }); - } else { - var self = this; - FB.getLoginStatus(function (response) { - if (response && response['status'] === 'connected') { - //login - save user info - self.userInfo = response['authResponse']; - callback(0, { - accessToken: response['authResponse']['accessToken'] - - }); - } else { - callback(response['error_code'] || 1, { - error_message: response['error_message'] || "Unknown" - }); - } - }); - } + getAccessToken: function () { + return this._userInfo ? this._userInfo['accessToken'] : null; }, /** - * Share something - * @param info - * @param callback + * Acquiring User ID + * @return {String} + * @example + * //example + * var userID = plugin.FacebookAgent.getUserID(); */ - share: function (info, callback) { + getUserID: function () { + return this._userInfo ? this._userInfo['userID'] : null; + }, + + _share: function (info, callback) { FB.ui({ method: 'share', name: info['title'], @@ -307,12 +300,21 @@ plugin.extend('facebook', { }, /** - * Various pop + * Request a web dialog for Facebook sharing * @param info * @param callback */ - webDialog: function (info, callback) { + dialog: function (info, callback) { if (!info) { + typeof callback === 'function' && callback(1, { + error_message: "No info parameter provided" + }); + return; + } + if (!this.canPresentDialog(info)) { + typeof callback === 'function' && callback(1, { + error_message: "The requested dialog: " + info['dialog'] + "can not be presented on Web" + }); return; } if (info['dialog'] === 'share_link') { @@ -342,13 +344,12 @@ plugin.extend('facebook', { info['description'] = info['text'] || info['description']; delete info['text']; - delete info['description']; - if (info['method'] == 'share_open_graph' && info['url']) { + if (info['method'] == 'share_open_graph') { if (info['url']) { var obj = {}; - if (info["preview_property"]) - obj[info["preview_property"]] = info["url"]; + if (info["preview_property_name"]) + obj[info["preview_property_name"]] = info["url"]; else obj["object"] = info["url"]; @@ -360,18 +361,8 @@ plugin.extend('facebook', { } info['action_properties'] = JSON.stringify(obj); - } else { - return; } } - - if ( - info['method'] != 'share_open_graph' && - info['method'] != 'share_link' - ) { - cc.log('web is not supported what this it method'); - return; - } } FB.ui(info, @@ -391,11 +382,22 @@ plugin.extend('facebook', { } }); }, - canPresentDialog: function (map) { - return false; + + /** + * Check whether the share request can be achieved + * @param info + */ + canPresentDialog: function (info) { + if (info && info['dialog'] && ( + info['dialog'] === 'share_link' || + info['dialog'] === 'share_open_graph' || + info['dialog'] === 'message_link')) + return true; + else + return false; }, /** - * FB.api package + * FB.api * @param {String} path * @param {Number} httpmethod * @param {Object} params @@ -417,11 +419,7 @@ plugin.extend('facebook', { }); }, - /** - * Get permission list - * @param callback - */ - getPermissionList: function (callback) { + _getPermissionList: function (callback) { FB.api("/me/permissions", function (response) { if (response['data']) { var permissionList = []; @@ -471,17 +469,19 @@ plugin.extend('facebook', { }, /** - * Various pop - * @param info - * @param callback + * Send an app requests to friends + * @param {Object} info + * @param {Function} callback */ appRequest: function (info, callback) { if (!info) { + typeof callback === 'function' && callback(1, { + error_message: "No info parameter provided" + }); return; } info['method'] = "apprequests"; - delete info['dialog']; info['name'] = info['site'] || info['name']; delete info['site']; @@ -500,39 +500,7 @@ plugin.extend('facebook', { info['description'] = info['text'] || info['description']; delete info['text']; - delete info['description']; - - if (info['method'] == 'share_open_graph' && info['url']) { - if (info['url']) { - var obj = {}; - if (info["preview_property"]) - obj[info["preview_property"]] = info["url"]; - else - obj["object"] = info["url"]; - - for (var p in info) { - if (p != "method" && p != "action_type" && p != "action_properties") { - info[p] && (obj[p] = info[p]); - delete info[p]; - } - } - info['action_properties'] = JSON.stringify(obj); - } else { - return; - } - } else { - //if (!info['href']) { - // return; - //} - } - - if ( - info['method'] != 'apprequests' - ) { - cc.log('web is not supported what this it method'); - return; - } FB.ui(info, function (response) { if (response) { @@ -550,19 +518,12 @@ plugin.extend('facebook', { } }); }, + /** - * get userID - * @returns {String} userid - */ - getUserID: function () { - return FB.getUserID(); - }, - /** - * logEvent for web - * @param eventName - * @param valueToSum - * @param parameters - * @constructor + * Log an event + * @param {String} eventName + * @param {Number} valueToSum + * @param {Object} parameters */ logEvent: function (eventName, valueToSum, parameters) { if (eventName == undefined) return; @@ -576,13 +537,21 @@ plugin.extend('facebook', { FB.AppEvents.logEvent(eventName, valueToSum, parameters); } }, + /** * Activate App */ activateApp: function () { FB.AppEvents.activateApp(); }, - logPurchase:function(mount,currency,param){ - FB.AppEvents.logPurchase(mount,currency,param); + + /** + * Log a purchase + * @param {Number} amount Amount of the purchase + * @param {String} currency The currency + * @param {Object} param Supplemental parameters + */ + logPurchase:function(amount, currency, param){ + FB.AppEvents.logPurchase(amount, currency, param); } }); From 4afefc9866f109b94259fb5a0f67547b21c6320e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 14:21:13 +0800 Subject: [PATCH 0758/1564] Issue #5933: Multiple calls to fit, data update error(EGLView) --- cocos2d/core/platform/CCEGLView.js | 65 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 57739017d1..35b90e7724 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -513,68 +513,67 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ */ setDesignResolutionSize: function (width, height, resolutionPolicy) { // Defensive code - if (isNaN(width) || width == 0 || isNaN(height) || height == 0) { + if (!width || !height) { cc.log(cc._LogInfos.EGLView_setDesignResolutionSize); return; } var _t = this; - var previousPolicy = _t._resolutionPolicy; - _t.setResolutionPolicy(resolutionPolicy); + var director = cc.director; + + if(resolutionPolicy !== _t._resolutionPolicy){ + _t.setResolutionPolicy(resolutionPolicy); + } var policy = _t._resolutionPolicy; - if (policy) + if (policy){ policy.preApply(_t); - else { + } else { cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2); return; } - // Reinit frame size - var frameW = _t._frameSize.width, frameH = _t._frameSize.height; if (cc.sys.isMobile) _t._setViewPortMeta(_t._frameSize.width, _t._frameSize.height); + _t._initFrameSize(); - // No change - if (previousPolicy == _t._resolutionPolicy - && width == _t._originalDesignResolutionSize.width && height == _t._originalDesignResolutionSize.height - && frameW == _t._frameSize.width && frameH == _t._frameSize.height) - return; - _t._designResolutionSize = cc.size(width, height); - _t._originalDesignResolutionSize = cc.size(width, height); + var dSize = _t._designResolutionSize, + oSize = _t._originalDesignResolutionSize; + if ( dSize.width !== width || dSize.height !== height ){ + // reset director's member variables to fit visible rect + director._winSizeInPoints.width = oSize.width = dSize.width = width; + director._winSizeInPoints.height = oSize.height = dSize.height = height; + + policy.postApply(_t); + cc.winSize.width = director._winSizeInPoints.width; + cc.winSize.height = director._winSizeInPoints.height; + } - var result = policy.apply(_t, _t._designResolutionSize); + var result = policy.apply(_t, dSize); if (result.scale && result.scale.length == 2) { _t._scaleX = result.scale[0]; _t._scaleY = result.scale[1]; + + _t._originalScaleX = _t._scaleX; + _t._originalScaleY = _t._scaleY; + } + + if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + // reset director's member variables to fit visible rect + director._createStatsLabel(); + director.setGLDefaultValues(); } + if (result.viewport) { var vp = _t._viewPortRect = result.viewport, visible = _t._visibleRect; visible.width = cc._canvas.width / _t._scaleX; visible.height = cc._canvas.height / _t._scaleY; visible.x = -vp.x / _t._scaleX; visible.y = -vp.y / _t._scaleY; + cc.visibleRect && cc.visibleRect.init(_t._visibleRect); } - // reset director's member variables to fit visible rect - var director = cc.director; - director._winSizeInPoints.width = _t._designResolutionSize.width; - director._winSizeInPoints.height = _t._designResolutionSize.height; - - policy.postApply(_t); - cc.winSize.width = director._winSizeInPoints.width; - cc.winSize.height = director._winSizeInPoints.height; - - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - // reset director's member variables to fit visible rect - director._createStatsLabel(); - director.setGLDefaultValues(); - } - - _t._originalScaleX = _t._scaleX; - _t._originalScaleY = _t._scaleY; // For editbox if (cc.DOM) cc.DOM._resetEGLViewDiv(); - cc.visibleRect && cc.visibleRect.init(_t._visibleRect); }, /** From 7ecf29afc86a56b32284eff5617f936c1f22a084 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 14:35:30 +0800 Subject: [PATCH 0759/1564] Issue #5933: Multiple calls to fit, data update error(EGLView) --- cocos2d/core/platform/CCEGLView.js | 60 ++++++++++++++---------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 35b90e7724..12ca70a1c5 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -513,67 +513,63 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ */ setDesignResolutionSize: function (width, height, resolutionPolicy) { // Defensive code - if (!width || !height) { + if (isNaN(width) || width == 0 || isNaN(height) || height == 0) { cc.log(cc._LogInfos.EGLView_setDesignResolutionSize); return; } var _t = this; - var director = cc.director; - - if(resolutionPolicy !== _t._resolutionPolicy){ - _t.setResolutionPolicy(resolutionPolicy); - } + var frameW = _t._frameSize.width, frameH = _t._frameSize.height; + var previousPolicy = _t._resolutionPolicy; + _t.setResolutionPolicy(resolutionPolicy); var policy = _t._resolutionPolicy; - if (policy){ + if (policy) policy.preApply(_t); - } else { + else { cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2); return; } + // Reinit frame size if (cc.sys.isMobile) _t._setViewPortMeta(_t._frameSize.width, _t._frameSize.height); - _t._initFrameSize(); - var dSize = _t._designResolutionSize, - oSize = _t._originalDesignResolutionSize; - if ( dSize.width !== width || dSize.height !== height ){ - // reset director's member variables to fit visible rect - director._winSizeInPoints.width = oSize.width = dSize.width = width; - director._winSizeInPoints.height = oSize.height = dSize.height = height; + _t._designResolutionSize = cc.size(width, height); + _t._originalDesignResolutionSize = cc.size(width, height); - policy.postApply(_t); - cc.winSize.width = director._winSizeInPoints.width; - cc.winSize.height = director._winSizeInPoints.height; - } - - var result = policy.apply(_t, dSize); + var result = policy.apply(_t, _t._designResolutionSize); if (result.scale && result.scale.length == 2) { _t._scaleX = result.scale[0]; _t._scaleY = result.scale[1]; - - _t._originalScaleX = _t._scaleX; - _t._originalScaleY = _t._scaleY; } - - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - // reset director's member variables to fit visible rect - director._createStatsLabel(); - director.setGLDefaultValues(); - } - if (result.viewport) { var vp = _t._viewPortRect = result.viewport, visible = _t._visibleRect; visible.width = cc._canvas.width / _t._scaleX; visible.height = cc._canvas.height / _t._scaleY; visible.x = -vp.x / _t._scaleX; visible.y = -vp.y / _t._scaleY; - cc.visibleRect && cc.visibleRect.init(_t._visibleRect); } + // reset director's member variables to fit visible rect + var director = cc.director; + director._winSizeInPoints.width = _t._designResolutionSize.width; + director._winSizeInPoints.height = _t._designResolutionSize.height; + + policy.postApply(_t); + cc.winSize.width = director._winSizeInPoints.width; + cc.winSize.height = director._winSizeInPoints.height; + + if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + // reset director's member variables to fit visible rect + director._createStatsLabel(); + director.setGLDefaultValues(); + } + + _t._originalScaleX = _t._scaleX; + _t._originalScaleY = _t._scaleY; // For editbox if (cc.DOM) cc.DOM._resetEGLViewDiv(); + cc.visibleRect && cc.visibleRect.init(_t._visibleRect); }, /** From 1b418a7c3a88f4e4ad88d1864c1b3b555c45b0a8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 14:38:23 +0800 Subject: [PATCH 0760/1564] Issue #5933: Multiple calls to fit, data update error(EGLView) --- cocos2d/core/platform/CCEGLView.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 12ca70a1c5..0afcf5a92f 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -518,8 +518,6 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ return; } var _t = this; - var frameW = _t._frameSize.width, frameH = _t._frameSize.height; - var previousPolicy = _t._resolutionPolicy; _t.setResolutionPolicy(resolutionPolicy); var policy = _t._resolutionPolicy; if (policy) From 6a071467e6e90faadf168a7ab7d8b1858ca9704d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 11 Oct 2014 14:54:18 +0800 Subject: [PATCH 0761/1564] Fixed #5941: fixed a bug of some transitions that its orientation is incorrect --- cocos2d/transitions/CCTransition.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 7ecee6852f..5dee53db25 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -949,7 +949,8 @@ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, @@ -1030,7 +1031,8 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_UP_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_UP_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1108,7 +1110,8 @@ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.Trans */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1187,7 +1190,8 @@ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.Transit */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1272,7 +1276,8 @@ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.Transit */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_UP_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_UP_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1355,7 +1360,8 @@ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.T */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, /** From e622a43079bdc281380835b5d123ae9e67257b62 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 11 Oct 2014 15:13:10 +0800 Subject: [PATCH 0762/1564] fixed a bug of some transitions that its orientation is incorrect --- cocos2d/transitions/CCTransition.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 2c60f5fc45..f6be1526c0 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -948,7 +948,8 @@ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, @@ -1029,7 +1030,8 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_UP_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_UP_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1107,7 +1109,8 @@ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.Trans */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1186,7 +1189,8 @@ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.Transit */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1271,7 +1275,8 @@ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.Transit */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_UP_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_UP_OVER; scene && this.initWithDuration(t, scene, o); }, /** @@ -1354,7 +1359,8 @@ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.T */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; + if(o == null) + o = cc.TRANSITION_ORIENTATION_RIGHT_OVER; scene && this.initWithDuration(t, scene, o); }, /** From 8c54d945e7da29ad7d1decd3db6523274c4849a8 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 11 Oct 2014 15:24:29 +0800 Subject: [PATCH 0763/1564] Feature #5950: Polish Facebook Web SDK --- external/pluginx/platform/facebook.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 70ee0b6deb..ad5d8382a8 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -167,6 +167,7 @@ plugin.extend('facebook', { FB.login(function (response) { if (response['authResponse']) { //save user info + self._isLoggedIn = true; self._userInfo = response['authResponse']; var permissList = response['authResponse']['grantedScopes'].split(","); typeof callback === 'function' && callback(0, { @@ -174,6 +175,8 @@ plugin.extend('facebook', { permissions: permissList }); } else { + self._isLoggedIn = false; + self._userInfo = {}; typeof callback === 'function' && callback(response['error_code'] || 1, { error_message: "unknown" }); @@ -234,11 +237,14 @@ plugin.extend('facebook', { if (response['authResponse']) { var permissList = response['authResponse']['grantedScopes'].split(","); //save user info + self._isLoggedIn = true; self._userInfo = response['authResponse']; typeof callback === 'function' && callback(0, { permissions: permissList }); } else { + self._isLoggedIn = false; + self._userInfo = {}; typeof callback === 'function' && callback(response['error_code'] || 1, { error_message: response['error_message'] || "Unknown" }); @@ -313,7 +319,7 @@ plugin.extend('facebook', { } if (!this.canPresentDialog(info)) { typeof callback === 'function' && callback(1, { - error_message: "The requested dialog: " + info['dialog'] + "can not be presented on Web" + error_message: "The requested dialog: " + info['dialog'] + " can not be presented on Web" }); return; } @@ -323,6 +329,11 @@ plugin.extend('facebook', { info['href'] = info['link']; } } else { + // Compatible with feed_dialog + if (info['dialog'] == 'feed_dialog') { + info['dialog'] = 'share'; + } + info['method'] = info['dialog']; delete info['dialog']; @@ -390,6 +401,7 @@ plugin.extend('facebook', { canPresentDialog: function (info) { if (info && info['dialog'] && ( info['dialog'] === 'share_link' || + info['dialog'] === 'feed_dialog' || info['dialog'] === 'share_open_graph' || info['dialog'] === 'message_link')) return true; From 311e0d09a9d2a3db9d837dba2a9483bfb33249c0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 11 Oct 2014 15:26:16 +0800 Subject: [PATCH 0764/1564] Fixed #5941: merge develop branch to renderer branch. --- cocos2d/transitions/CCTransition.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 89dd74ffa1..08f7663257 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -1031,8 +1031,6 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF */ ctor:function (t, scene, o) { cc.TransitionSceneOriented.prototype.ctor.call(this); - if(o == null) - o = cc.TRANSITION_ORIENTATION_UP_OVER; if(o == null) o = cc.TRANSITION_ORIENTATION_UP_OVER; scene && this.initWithDuration(t, scene, o); From d0d3d4cd9385dd5358add9f3f9e8d7671b2c7663 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 17:03:04 +0800 Subject: [PATCH 0765/1564] Issue #5933: remove cc.p and cc.rect of SkeletonRenderCmdCanvas --- cocos2d/core/renderer/RendererCanvas.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 3985263055..af1d3e0522 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -798,7 +798,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { bone = locSkeleton.bones[i]; var x = bone.data.length * bone.m00 + bone.worldX; var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + drawingUtil.drawLine( + {x:bone.worldX, y:bone.worldY}, + {x:x, y:y}); } // Bone origins. @@ -807,7 +809,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { for (i = 0, n = locSkeleton.bones.length; i < n; i++) { bone = locSkeleton.bones[i]; - drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + drawingUtil.drawPoint({x:bone.worldX, y:bone.worldY}); if (i === 0) drawingUtil.setDrawColor(0, 255, 0, 255); } From 4e1e097390fc2882f3ea7ab83c2b53dcc86fa3ed Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 11 Oct 2014 17:06:47 +0800 Subject: [PATCH 0766/1564] Issue #5968: remove a condition from TextureRenderCmd --- cocos2d/core/renderer/RendererCanvas.js | 2 +- cocos2d/core/sprites/CCSprite.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 3985263055..a15aaf3d23 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -131,7 +131,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var context = ctx || cc._renderContext, locTextureCoord = self._textureCoord; - if (!locTextureCoord.validRect || !node._visible) + if (!locTextureCoord.validRect) return; //draw nothing var t = node._transformWorld, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 28e2bb02f9..69c8da28c0 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -321,7 +321,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // Shared data // // texture - _rect:null, //Retangle of cc.Texture2D + _rect:null, //Rectangle of cc.Texture2D _rectRotated:false, //Whether the texture is rotated // Offset Position (used by Zwoptex) From c680afeb4ca0c3904db262ce02c9f6b40bca7e84 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 11 Oct 2014 17:34:02 +0800 Subject: [PATCH 0767/1564] Fixed #5969: Remove arrivalOrder reset codes --- cocos2d/core/base-nodes/BaseNodesWebGL.js | 2 -- cocos2d/core/base-nodes/CCNode.js | 1 - cocos2d/core/layers/CCLayer.js | 2 -- cocos2d/core/sprites/CCSpriteBatchNode.js | 1 - cocos2d/render-texture/CCRenderTexture.js | 4 ---- extensions/ccui/base-classes/CCProtectedNode.js | 2 -- extensions/cocostudio/armature/CCArmature.js | 6 ------ extensions/cocostudio/armature/display/CCBatchNode.js | 2 -- 8 files changed, 20 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index ff723ece29..baaf280bfe 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -104,8 +104,6 @@ cc._tmp.WebGLCCNode = function () { cc.renderer.pushRenderCommand(this._rendererCmd); } - _t.arrivalOrder = 0; - //optimize performance for javascript currentStack.top = currentStack.stack.pop(); }; diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 9df687d51d..782e691a8f 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2623,7 +2623,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(this._rendererCmd) cc.renderer.pushRenderCommand(this._rendererCmd); } - _t.arrivalOrder = 0; }; _p._transformForRenderer = function () { diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 18916a5ccc..e4aa948bb1 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -177,7 +177,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //the bakeSprite is drawing locBakeSprite.visit(context); - _t.arrivalOrder = 0; context.restore(); }; @@ -496,7 +495,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //the bakeSprite is drawing locBakeSprite.visit(context); - _t.arrivalOrder = 0; context.restore(); }; diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index e7dc41b556..75cb18cb9d 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -888,7 +888,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //optimize performance for javascript currentStack.top = currentStack.stack.pop(); - this.arrivalOrder = 0; }, /** diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 9d13cdb68b..54ea6dabac 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -634,8 +634,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ ctx = ctx || cc._renderContext; this.transform(ctx); this.sprite.visit(ctx); // draw the RenderTexture - - this.arrivalOrder = 0; }, _visitForWebGL:function (ctx) { @@ -665,8 +663,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ locGrid.afterDraw(this);*/ cc.kmGLPopMatrix(); - - this.arrivalOrder = 0; }, /** diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index be410e09d3..0f4a58e0ba 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -278,7 +278,6 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locProtectedChildren[j] && locProtectedChildren[j].visit(context); this._cacheDirty = false; - _t.arrivalOrder = 0; // context.restore(); }, @@ -330,7 +329,6 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locProtectedChildren[j] && locProtectedChildren[j].visit(); } - _t.arrivalOrder = 0; if (locGrid && locGrid._active) locGrid.afterDraw(_t); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index b3d3173f01..60ed1ffccf 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -475,9 +475,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if(this._rendererEndCmd) cc.renderer.pushRenderCommand(this._rendererEndCmd); - // reset for next frame this._cacheDirty = false; - this.arrivalOrder = 0; context.restore(); }, @@ -506,9 +504,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ _endRendererCmdForCanvas: function(ctx){ var context = ctx || cc._renderContext; - // reset for next frame this._cacheDirty = false; - this.arrivalOrder = 0; context.restore(); }, @@ -530,8 +526,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ //this.draw(context); cc.renderer.pushRenderCommand(this._rendererCmd); - // reset for next frame - this.arrivalOrder = 0; currentStack.top = currentStack.stack.pop(); }, diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index 6f1b8d6d88..f28941f7d8 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -76,8 +76,6 @@ ccs.BatchNode = cc.Node.extend(/** @lends ccs.BatchNode# */{ this.sortAllChildren(); this.draw(renderer, this._modelViewTransform, dirty); - // reset for next frame - this.arrivalOrder = 0; if (this.grid && this.grid.isActive()) this.grid.afterDraw(this); From 3629c2403f915b50b7c4246477b4e39e0de97a8e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 11 Oct 2014 17:40:44 +0800 Subject: [PATCH 0768/1564] Fixed #5941: Correct MontionStreak to MotionStreak --- cocos2d/core/renderer/RendererWebGL.js | 4 ++-- cocos2d/motion-streak/CCMotionStreak.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index aaaa516c14..d37e35ad52 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -201,11 +201,11 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ _t._render(); }; - cc.MontionStreakCmdWebGL = function(node){ + cc.MotionStreakCmdWebGL = function(node){ this._node = node; }; - cc.MontionStreakCmdWebGL.prototype.rendering = function(ctx){ + cc.MotionStreakCmdWebGL.prototype.rendering = function(ctx){ var _t = this._node; if (_t._nuPoints <= 1) return; diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index a99cec9751..a0df3d6392 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -118,7 +118,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ }, _initRendererCmd:function(){ - this._rendererCmd = new cc.MontionStreakCmdWebGL(this); + this._rendererCmd = new cc.MotionStreakCmdWebGL(this); }, /** From 2710df9348cee14786ae848cc3aa4ab01195bfd8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 18:40:43 +0800 Subject: [PATCH 0769/1564] Issue #5933: Fixed pageView update error --- extensions/ccui/layouts/UILayout.js | 10 +++++++--- .../ccui/uiwidgets/scroll-widget/UIScrollView.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 71b406501b..95c9b35f87 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1808,9 +1808,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _transformForRenderer: function(parentMatrix){ - cc.Node.prototype._transformForRenderer.call(this, parentMatrix); - if(this._clippingStencil) - this._clippingStencil._transformForRenderer(this._stackMatrix); + if(cc._renderType === cc._RENDER_TYPE_WEBGL){ + cc.Node.prototype._transformForRenderer.call(this, parentMatrix); + if(this._clippingStencil) + this._clippingStencil._transformForRenderer(this._stackMatrix); + }else{ + ccui.ProtectedNode.prototype._transformForRenderer.call(this); + } } }); ccui.Layout._init_once = null; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 8ce12c2149..f9849d3680 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1725,7 +1725,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _transformForRenderer: function(parentMatrix){ ccui.Layout.prototype._transformForRenderer.call(this, parentMatrix); - if(this._innerContainer) + if(this._innerContainer && cc._renderType === cc._RENDER_TYPE_WEBGL) this._innerContainer._transformForRenderer(this._stackMatrix); } }); From 3beaf1477d12304b919ce4c60d34e563ca220b9a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 18:45:20 +0800 Subject: [PATCH 0770/1564] Issue #5933: Fixed scale9sprite _cacheScale9Sprite error --- extensions/ccui/base-classes/UIScale9Sprite.js | 2 +- extensions/gui/control-extension/CCScale9Sprite.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index c063660645..93e8f01e6c 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -208,7 +208,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, _cacheScale9Sprite: function(){ - if(!this._scale9Image && !this._scale9Dirty) + if(!this._scale9Image || !this._scale9Dirty) return; var size = this._contentSize, locCanvas = this._cacheCanvas; var contentSizeChanged = false; diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index db9a897f5d..30d6726932 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -206,7 +206,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, _cacheScale9Sprite: function(){ - if(!this._scale9Image && !this._scale9Dirty) + if(!this._scale9Image || !this._scale9Dirty) return; var size = this._contentSize, locCanvas = this._cacheCanvas; var contentSizeChanged = false; From a1a3baf4c27fea88b3c760f543ac34af38f915e2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 18:47:55 +0800 Subject: [PATCH 0771/1564] Issue #5933: Fixed scale9sprite _cacheScale9Sprite error --- extensions/ccui/base-classes/UIScale9Sprite.js | 2 +- extensions/gui/control-extension/CCScale9Sprite.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 93e8f01e6c..b5e929e285 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -208,7 +208,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, _cacheScale9Sprite: function(){ - if(!this._scale9Image || !this._scale9Dirty) + if(!this._scale9Image) return; var size = this._contentSize, locCanvas = this._cacheCanvas; var contentSizeChanged = false; diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 30d6726932..003ff3ea0b 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -206,7 +206,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, _cacheScale9Sprite: function(){ - if(!this._scale9Image || !this._scale9Dirty) + if(!this._scale9Image) return; var size = this._contentSize, locCanvas = this._cacheCanvas; var contentSizeChanged = false; From 355f5daafb85aa7047e86b0171dc95ab4d217d22 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 19:36:53 +0800 Subject: [PATCH 0772/1564] Issue #5933: Fixed pageView update error(webgl) --- extensions/ccui/layouts/UILayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 95c9b35f87..92ca7533e9 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1809,7 +1809,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _transformForRenderer: function(parentMatrix){ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - cc.Node.prototype._transformForRenderer.call(this, parentMatrix); + ccui.Widget.prototype._transformForRenderer.call(this, parentMatrix); if(this._clippingStencil) this._clippingStencil._transformForRenderer(this._stackMatrix); }else{ From cba4b8c7201eacd425fb63449bed1bf170c65ae0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 11 Oct 2014 20:58:17 +0800 Subject: [PATCH 0773/1564] Issue #5941: fixed a bug of cc.ClippingNode --- cocos2d/clipping-nodes/CCClippingNode.js | 4 ++-- cocos2d/core/renderer/RendererWebGL.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 684b24394a..79c4a6f432 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -333,7 +333,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); gl.stencilOp(!this.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP); - /*if (this.alphaThreshold < 1) { //TODO desktop + if (this.alphaThreshold < 1) { //TODO desktop // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST); @@ -344,7 +344,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // we need to recursively apply this shader to all the nodes in the stencil node // XXX: we should have a way to apply shader to all nodes without having to do this cc.setProgram(this._stencil, program); - }*/ + } }, _drawFullScreenQuadClearStencil: function () { diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index d37e35ad52..53635e24e3 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -630,11 +630,11 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ node.draw(ctx); break; default: - node.visit(ctx); + node.visit(ctx); //TODO need fix soon break; } } else if(selBone instanceof cc.Node) { - selBone.setShaderProgram(_t._shaderProgram); + selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon selBone.visit(ctx); // CC_NODE_DRAW_SETUP(); } From 3bccd34ec3cea3c57e31682ecca4f2df2a840ad5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 11 Oct 2014 21:56:04 +0800 Subject: [PATCH 0774/1564] Issue #5933: Fixed atlasNode setColor --- cocos2d/core/base-nodes/CCAtlasNode.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index f7bad055ea..8bf984c4fe 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -308,7 +308,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ temp.g = temp.g * locDisplayedOpacity / 255; temp.b = temp.b * locDisplayedOpacity / 255; } - cc.Node.prototype.setColor.call(this, color3); +// cc.Node.prototype.setColor.call(this, color3); this._changeTextureColor(); }, @@ -321,9 +321,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ var locElement = locTexture.getHtmlElementObj(); var textureRect = cc.rect(0, 0, element.width, element.height); if (locElement instanceof HTMLCanvasElement) - cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); + cc.generateTintImageWithMultiply(element, this._colorUnmodified, textureRect, locElement); else { - locElement = cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect); + locElement = cc.generateTintImageWithMultiply(element, this._colorUnmodified, textureRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); @@ -399,6 +399,11 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ _setTextureForCanvas: function (texture) { this._textureForCanvas = texture; + var children = this._children, + len = this._children.length; + for(var i=0; i Date: Sat, 11 Oct 2014 21:59:40 +0800 Subject: [PATCH 0775/1564] Issue #5933: remove cc.p and cc.rect of SkeletonRenderCmdCanvas --- cocos2d/core/base-nodes/CCAtlasNode.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 8bf984c4fe..e293697d21 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -399,11 +399,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ _setTextureForCanvas: function (texture) { this._textureForCanvas = texture; - var children = this._children, - len = this._children.length; - for(var i=0; i Date: Mon, 13 Oct 2014 10:26:23 +0800 Subject: [PATCH 0776/1564] Issue #5933: labelatlas opacity --- cocos2d/labels/CCLabelAtlas.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 9ec20983b7..61d3a764ba 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -241,7 +241,6 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ fontChar.initWithTexture(texture, rect); // restore to default in case they were modified fontChar.visible = true; - fontChar.opacity = this._displayedOpacity; } } fontChar.setPosition(i * locItemWidth + locItemWidth / 2, locItemHeight / 2); @@ -370,17 +369,6 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ */ setOpacity: null, - _setOpacityForCanvas: function (opacity) { - if (this._displayedOpacity !== opacity) { - cc.AtlasNode.prototype.setOpacity.call(this, opacity); - var locChildren = this._children; - for (var i = 0, len = locChildren.length; i < len; i++) { - if (locChildren[i]) - locChildren[i].opacity = opacity; - } - } - }, - _setOpacityForWebGL: function (opacity) { if (this._opacity !== opacity) cc.AtlasNode.prototype.setOpacity.call(this, opacity); From b92115bebf70ecefd206f290ef5a44423dc56313 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 13 Oct 2014 10:55:36 +0800 Subject: [PATCH 0777/1564] Update the AUTHORS.txt --- AUTHORS.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index c4643197f3..06412f8a6d 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -192,6 +192,8 @@ Ninja Lau @mutoo A typo bug in UILayout fix cc.eventManager bug fix ccs.Bone bug fix ccs.ActionFrame bug fix + ccui.Widget bug fix + ccui.LoadingBar bug fix Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode @@ -203,6 +205,15 @@ Michael Yin @layerssss cc.game refactored Yang Yuchen @yycdef cc.sys bug fix +K @kiwigrc cc.ParticleSystem bug fix + +Claudio Freitas @claudiofreitas ccui.TextField typo fix. + +nopakos @nopakos cc.Texture2D bug fix + +Robert Rouhani @Robmaister cc.TMXMapInfo bug fix + cc.TMXLayer bug fix + Retired Core Developers: Shengxiang Chen (Nero Chan) Xingsen Ma From 24a294a41fd41f6bd1a2d2682277e5e73499262f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 13 Oct 2014 11:01:13 +0800 Subject: [PATCH 0778/1564] Update the AUTHORS.txt Update the AUTHORS.txt for v3.1 beta --- AUTHORS.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index c4643197f3..06412f8a6d 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -192,6 +192,8 @@ Ninja Lau @mutoo A typo bug in UILayout fix cc.eventManager bug fix ccs.Bone bug fix ccs.ActionFrame bug fix + ccui.Widget bug fix + ccui.LoadingBar bug fix Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode @@ -203,6 +205,15 @@ Michael Yin @layerssss cc.game refactored Yang Yuchen @yycdef cc.sys bug fix +K @kiwigrc cc.ParticleSystem bug fix + +Claudio Freitas @claudiofreitas ccui.TextField typo fix. + +nopakos @nopakos cc.Texture2D bug fix + +Robert Rouhani @Robmaister cc.TMXMapInfo bug fix + cc.TMXLayer bug fix + Retired Core Developers: Shengxiang Chen (Nero Chan) Xingsen Ma From 0b82a712f47d2bf0f4defe1ea3200fdca4ce252e Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 13 Oct 2014 15:16:25 +0800 Subject: [PATCH 0779/1564] Update Docs and Engine Version --- CCBoot.js | 6 +++--- CHANGELOG.txt | 26 ++++++++++++++++++++++++++ cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 4 ++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 69cbe397e9..0f4715aa9f 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -244,7 +244,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ self._isErr = true; if(self._onEnd) self._onEnd.call(self._onEndTarget, err); - return + return; } var arr = Array.prototype.slice.call(arguments, 1); @@ -252,7 +252,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ if(self.finishedSize == self.size) { if(self._onEnd) self._onEnd.call(self._onEndTarget, null, self._results); - return + return; } self._handleItem(); }.bind(item), self); @@ -419,7 +419,7 @@ cc.path = /** @lends cc.path# */{ if(idx !== -1) return fileName.substring(0,idx); } - return fileName + return fileName; }, /** diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c1cd6f7650..a07e3fb1df 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,31 @@ ChangeLog: +Cocos2d-JS v3.1 beta @ Oct.13, 2014 + +* Refactoration of the web engine with new renderer on the architecture level, optimization is under going. +* Released Facebook SDK for Cocos2d-JS beta2, its API have been significantly improved and stablized. +* Upgraded MoonWarriors sample with new set of graphical assets. +* Automatically enabled WebGL on iOS 8 safari. +* Upgraded chipmunk.js to the newest version. +* Supported setting color of shadow for `cc.LabelTTF`. +* Added `getTitleRenderer` function to ccui.Button. +* Supported Coco Studio timeline animation. +* Set the default value of LabelAtlas's `cascadeOpacityEnabled` and `cascadeColorEnabled` to true. +* Added a listener of texture to `cc.Sprite#setTexture` when the texture hasn't loaded. +* Activated `cc.pool` for all kind of objects. +* Added query test for chipmunk and added necessary JavaScript bindings. + +* Bugs fix: + 1. Fixed a bug of `cc.ComponentContainer` that a 'if' statement behavior is incorrect. + 2. Fixed a bug of `cc.Scale9Sprite` that the behavior of Canvas and WebGL is different. + 3. Fixed a bug of `cc.EventListener` that its pause state should set to true. + 4. Fixed a bug of `cc.ParticleSystem` that it should apply canvas scaling on canvas rendering mode. + 5. Fixed a bug of CCBoot.js that `cc.loader` should add a condition to check whether `crossOrign` property is undefined on IE9 and IE10. + 6. Fixed a bug of `ccui.Widget` that its `setPosition` function's behavior is incorrect. + 7. Fixed a bug of `ccui.LoadingBar` that its `barRenderer` should add to protected children array. + 8. Fixed a bug of `cc.Texture2D` that its `TEXTURE_MAG_FILTER` should set to LINEAR. + 9. Fixed a bug of `cc.TMXMapInfo` that its doesn't parse `rotation` property. + Cocos2d-JS-v3.0 Final @ Sep.10, 2014 * Facebook SDK Beta2: Added `appRequest` API. diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index aed123d15c..ac4632f767 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 Final"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.1 Beta"; /** *

    diff --git a/tools/build.xml b/tools/build.xml index f80dce9688..55bf2d10c8 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.1-beta-min.js"> @@ -246,7 +246,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.1-beta-core-min.js"> From cc1ccc5f50b71e3445682dce9c83a762351a7288 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 14 Oct 2014 09:55:47 +0800 Subject: [PATCH 0780/1564] Fixed some typo. --- cocos2d/core/base-nodes/CCNode.js | 5 ++--- cocos2d/core/labelttf/CCLabelTTF.js | 6 +++--- cocos2d/core/sprites/CCSprite.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 349e453088..0984d43e57 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2539,9 +2539,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Set whether color should be changed with the opacity value, - * useless in cc.Node, but this function is overrided in some class to have such behavior. + * useless in cc.Node, but this function is override in some class to have such behavior. * @function - * @param {Boolean} value + * @param {Boolean} opacityValue */ setOpacityModifyRGB: function (opacityValue) { }, @@ -2574,7 +2574,6 @@ cc.Node.create = function () { cc.Node._StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7}; if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - //redefine cc.Node var _p = cc.Node.prototype; _p.ctor = function () { diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 4b61dc5c36..0fa34cc039 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -102,7 +102,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _className: "LabelTTF", /** - * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, you should pass the correct arguments in constructor to initialize the label. + * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, + * you should pass the correct arguments in constructor to initialize the label. * @param {String} label string * @param {String} fontName * @param {Number} fontSize @@ -179,8 +180,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (fontName && fontName instanceof cc.FontDefinition) { this.initWithStringAndTextDefinition(text, fontName); - } - else { + } else { cc.LabelTTF.prototype.initWithString.call(this, text, fontName, fontSize, dimensions, hAlignment, vAlignment); } }, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 69c8da28c0..e01438000f 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1450,7 +1450,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _t = this; //cc.assert(_t._batchNode, "updateTransform is only valid when cc.Sprite is being rendered using an cc.SpriteBatchNode"); - // recaculate matrix only if it is dirty + // re-calculate matrix only if it is dirty if (_t.dirty) { // If it is not visible, or one of its ancestors is not visible, then do nothing: var locParent = _t._parent; From 9a954d6398abb6c878d94c1cf30caf9a35724c62 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 14 Oct 2014 10:40:27 +0800 Subject: [PATCH 0781/1564] Issue #5933: The combined code (studio 10.14) --- .../ccui/base-classes/UIScale9Sprite.js | 3 + extensions/ccui/base-classes/UIWidget.js | 68 ++++++++++++++++--- extensions/ccui/layouts/UILayout.js | 7 +- extensions/ccui/uiwidgets/UIButton.js | 59 +++++++++++++--- extensions/ccui/uiwidgets/UICheckBox.js | 28 ++++++-- extensions/ccui/uiwidgets/UILoadingBar.js | 6 +- extensions/ccui/uiwidgets/UIRichText.js | 2 +- extensions/ccui/uiwidgets/UISlider.js | 5 +- .../uiwidgets/scroll-widget/UIPageView.js | 68 ++++++++++++++++--- .../uiwidgets/scroll-widget/UIScrollView.js | 20 ++++-- .../cocostudio/action/CCActionObject.js | 6 +- extensions/cocostudio/armature/CCArmature.js | 4 ++ extensions/cocostudio/armature/CCBone.js | 4 +- extensions/cocostudio/reader/GUIReader.js | 2 +- extensions/cocostudio/reader/SceneReader.js | 12 ++++ .../TextFieldReader/TextFieldReader.js | 2 +- 16 files changed, 247 insertions(+), 49 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index b5e929e285..494bae87ca 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -48,6 +48,9 @@ * @property {Number} insetRight - The right inset of the 9-slice sprite * @property {Number} insetBottom - The bottom inset of the 9-slice sprite */ + +//todo checking here. Maybe need synchronous. + ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _spriteRect: null, _capInsetsInternal: null, diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index a8ecd23ff9..047af717a7 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -77,7 +77,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _sizePercent: null, _positionType: null, _positionPercent: null, - _reorderWidgetChildDirty: false, _hit: false, _nodes: null, _touchListener: null, @@ -89,6 +88,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _touchEventCallback: null, + _propagateTouchEvents: true, + /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @function @@ -186,6 +187,31 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return parentWidget._isAncestorsEnabled(); }, + setPropagateTouchEvents: function(isPropagate){ + this._propagateTouchEvents = isPropagate; + }, + + isPropagateTouchEvents: function(){ + return this._propagateTouchEvents; + }, + + setSwallowTouches: function(swallow){ + if (this._touchListener) + { + this._touchListener.setSwallowTouches(swallow); + } + }, + + isSwallowTouches: function(){ + if (this._touchListener) + { + //todo + return true; + //return this._touchListener.isSwallowTouches(); + } + return false; + }, + _getAncensterWidget: function(node){ if (null == node) return null; @@ -755,6 +781,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _onPressStateChangedToDisabled: function () { }, + _updateChildrenDisplayedRGBA: function(){ + this.setColor(this.getColor()); + this.setOpacity(this.getOpacity()); + }, + /** * A call back function when widget lost of focus. */ @@ -789,13 +820,27 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return false; } this.setHighlighted(true); - var widgetParent = this.getWidgetParent(); - if (widgetParent) - widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_BEGAN, this, touch); + + /* + * Propagate touch events to its parents + */ + if (this._propagateTouchEvents) + { + this.propagateTouchEvent(ccui.Widget.TOUCH_BEGAN, this, touch); + } + this._pushDownEvent(); return true; }, + propagateTouchEvent: function(event, sender, touch){ + var widgetParent = this.getWidgetParent(); + if (widgetParent) + { + widgetParent.interceptTouchEvent(event, sender, touch); + } + }, + /** *

    * The callback of touch moved event.
    @@ -877,6 +922,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchEventCallback(this, ccui.Widget.TOUCH_ENDED); if (this._touchEventListener && this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED); + + if (this._clickEventListener) { + this._clickEventListener(this); + } }, _cancelUpEvent: function () { @@ -904,6 +953,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, + addClickEventListener: function(callback){ + this._clickEventListener = callback; + }, + /** * Checks a point if is in widget's space * @param {cc.Point} pt @@ -1309,8 +1362,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchEventCallback = widget._touchEventCallback; this._touchEventListener = widget._touchEventListener; this._touchEventSelector = widget._touchEventSelector; + this._clickEventListener = widget._clickEventListener; this._focused = widget._focused; this._focusEnabled = widget._focusEnabled; + this._propagateTouchEvents = widget._propagateTouchEvents; for (var key in widget._layoutParameterDictionary) { var parameter = widget._layoutParameterDictionary[key]; @@ -1517,11 +1572,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }else layout = layout._parent; } - }, - - _updateChildrenDisplayedRGBA: function(){ - this.setColor(this.getColor()); - this.setOpacity(this.getOpacity()); } }); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 92ca7533e9..723fed32ad 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -86,6 +86,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _loopFocus: false, //whether enable loop focus or not __passFocusToChild: false, //on default, it will pass the focus to the next nearest widget _isFocusPassing:false, //when finding the next focused widget, use this variable to pass focus between layout & widget + _isInterceptTouch: false, //add renderer for webgl _beforeVisitCmdStencil: null, @@ -1727,8 +1728,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return true; else return this._isWidgetAncestorSupportLoopFocus(parent, direction); - } else + } else{ cc.assert(0, "invalid layout type"); + return false; + } } else return this._isWidgetAncestorSupportLoopFocus(parent, direction); }, @@ -1792,6 +1795,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _copySpecialProperties: function (layout) { if(!(layout instanceof ccui.Layout)) return; + ccui.Widget.prototype._copySpecialProperties.call(this, layout); this.setBackGroundImageScale9Enabled(layout._backGroundScale9Enabled); this.setBackGroundImage(layout._backGroundImageFileName, layout._bgImageTexType); this.setBackGroundImageCapInsets(layout._backGroundImageCapInsets); @@ -1805,6 +1809,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this.setClippingType(layout._clippingType); this._loopFocus = layout._loopFocus; this.__passFocusToChild = layout.__passFocusToChild; + this._isInterceptTouch = layout._isInterceptTouch; }, _transformForRenderer: function(parentMatrix){ diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index f89eb5a233..6809634a56 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -67,6 +67,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _pressedTextureScaleXInSize: 1, _pressedTextureScaleYInSize: 1, + _zoomScale: 0.1, + _normalTextureLoaded: false, _pressedTextureLoaded: false, _disabledTextureLoaded: false, @@ -209,6 +211,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @returns {cc.Size} */ getVirtualRendererSize: function(){ + var titleSize = this._titleRenderer.getContentSize(); + if (!this._normalTextureLoaded && this._titleRenderer.getString().length > 0) { + return titleSize; + } return cc.size(this._normalTextureSize); }, @@ -526,13 +532,22 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var zoomAction = cc.scaleTo(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); this._buttonNormalRenderer.runAction(zoomAction); this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); + + this._titleRenderer.stopAllActions(); + this._titleRenderer.runAction(zoomAction.clone()); } } else { - if (this._scale9Enabled) - this._updateTexturesRGBA(); + if (this._scale9Enabled){ + //todo checking here. old -> this._updateTexturesRGBA(); + this._buttonNormalRenderer.setColor(cc.color.WHITE); + } else { this._buttonNormalRenderer.stopAllActions(); this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + + this._titleRenderer.stopAllActions(); + this._titleRenderer.setScaleX(this._normalTextureScaleXInSize); + this._titleRenderer.setScaleY(this._normalTextureScaleYInSize); } } }, @@ -549,6 +564,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var zoomAction = cc.scaleTo(0.05, this._pressedTextureScaleXInSize + 0.1,this._pressedTextureScaleYInSize + 0.1); this._buttonClickedRenderer.runAction(zoomAction); locNormalRenderer.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1); + + this._titleRenderer.stopAllActions(); + //we must call zoomAction->clone here + this._titleRenderer.runAction(zoomAction.clone()); } } else { locNormalRenderer.setVisible(true); @@ -559,6 +578,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ else { locNormalRenderer.stopAllActions(); locNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); + + this._titleRenderer.stopAllActions(); + this._titleRenderer.setScaleX(this._normalTextureScaleXInSize + this._zoomScale); + this._titleRenderer.setScaleY(this._normalTextureScaleYInSize + this._zoomScale); } } }, @@ -738,21 +761,17 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.pressedActionEnabled = enabled; }, - /** - * Get the title renderer. - * title ttf object. - * @returns {cc.LabelTTF} - */ - getTitleRenderer: function(){ - return this._titleRenderer; - }, - /** * Sets title text to ccui.Button * @param {String} text */ setTitleText: function (text) { this._titleRenderer.setString(text); + if (this._ignoreSize) + { + var s = this.getVirtualRendererSize(); + this.setContentSize(s); + } }, /** @@ -798,6 +817,14 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return this._titleRenderer.getFontSize(); }, + setZoomScale: function(scale){ + this._zoomScale = scale; + }, + + getZoomScale: function(){ + return this._zoomScale; + }, + /** * Sets title fontName to ccui.Button. * @param {String} fontName @@ -807,6 +834,15 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._fontName = fontName; }, + /** + * Get the title renderer. + * title ttf object. + * @returns {cc.LabelTTF} + */ + getTitleRenderer: function(){ + return this._titleRenderer; + }, + /** * Gets title fontName of ccui.Button. * @returns {String} @@ -849,6 +885,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.setTitleFontSize(uiButton.getTitleFontSize()); this.setTitleColor(uiButton.getTitleColor()); this.setPressedActionEnabled(uiButton.pressedActionEnabled); + this.setZoomScale(uiButton._zoomScale); } }); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 8ddfb696cf..2d050fdc15 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -95,7 +95,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ init: function (backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType) { if (ccui.Widget.prototype.init.call(this)) { this._isSelected = true; - this.setSelectedState(false); + this.setSelected(false); if(backGround === undefined) this.loadTextures(backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType); return true; @@ -394,22 +394,36 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ } }, + /** + * @deprecated since v3.1, please use setSelected. + */ + setSelectedState: function(selected){ + this.setSelected(selected); + }, + /** * Sets the selected state to ccui.CheckBox * @param {Boolean} selected */ - setSelectedState: function (selected) { + setSelected: function (selected) { if (selected == this._isSelected) return; this._isSelected = selected; this._frontCrossRenderer.setVisible(this._isSelected); }, + /** + * @deprecated since v3.1, please use isSelected. + */ + getSelectedState: function(){ + this.isSelected(); + }, + /** * Returns the selected state of ccui.CheckBox. * @returns {boolean} */ - getSelectedState: function () { + isSelected: function () { return this._isSelected; }, @@ -434,10 +448,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _releaseUpEvent: function(){ ccui.Widget.prototype._releaseUpEvent.call(this); if (this._isSelected){ - this.setSelectedState(false); + this.setSelected(false); this._unSelectedEvent(); } else { - this.setSelectedState(true); + this.setSelected(true); this._selectedEvent(); } }, @@ -614,7 +628,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this.loadTextureFrontCross(uiCheckBox._frontCrossFileName, uiCheckBox._frontCrossTexType); this.loadTextureBackGroundDisabled(uiCheckBox._backGroundDisabledFileName, uiCheckBox._backGroundDisabledTexType); this.loadTextureFrontCrossDisabled(uiCheckBox._frontCrossDisabledFileName, uiCheckBox._frontCrossDisabledTexType); - this.setSelectedState(uiCheckBox._isSelected); + this.setSelected(uiCheckBox._isSelected); this._checkBoxEventListener = uiCheckBox._checkBoxEventListener; this._checkBoxEventSelector = uiCheckBox._checkBoxEventSelector; } @@ -649,7 +663,7 @@ var _p = ccui.CheckBox.prototype; // Extended properties /** @expose */ _p.selected; -cc.defineGetterSetter(_p, "selected", _p.getSelectedState, _p.setSelectedState); +cc.defineGetterSetter(_p, "selected", _p.isSelected, _p.setSelected); _p = null; diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 180ba553df..9f991808d7 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -85,13 +85,15 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: this._barRenderer.setAnchorPoint(0.0, 0.5); - this._barRenderer.setPosition(-this._totalLength * 0.5, 0.0); + //todo check here old -> this._barRenderer.setPosition(-this._totalLength * 0.5, 0.0); + this._barRenderer.setPosition(0, 0); if (!this._scale9Enabled) this._barRenderer.setFlippedX(false); break; case ccui.LoadingBar.TYPE_RIGHT: this._barRenderer.setAnchorPoint(1.0, 0.5); - this._barRenderer.setPosition(this._totalLength * 0.5, 0.0); + //todo check here old -> this._barRenderer.setPosition(this._totalLength * 0.5, 0.0); + this._barRenderer.setPosition(0, 0); if (!this._scale9Enabled) this._barRenderer.setFlippedX(true); break; diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 5b171a090c..91c3b2f3f6 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -408,7 +408,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ for (j = 0; j < row.length; j++) { l = row[j]; l.setAnchorPoint(cc.p(0, 0)); - l.setPosition(cc.p(nextPosX, 0)); + l.setPosition(nextPosX, 0); locRenderersContainer.addChild(l, 1, j); var iSize = l.getContentSize(); newContentSizeWidth += iSize.width; diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 55aad96b10..ed19abaf20 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -99,6 +99,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._slidBallRenderer.addChild(this._slidBallNormalRenderer); this._slidBallRenderer.addChild(this._slidBallPressedRenderer); this._slidBallRenderer.addChild(this._slidBallDisabledRenderer); + this._slidBallRenderer.setCascadeColorEnabled(true); + this._slidBallRenderer.setCascadeOpacityEnabled(true); + this.addProtectedChild(this._slidBallRenderer, ccui.Slider.BALL_RENDERER_ZORDER, -1); }, @@ -439,7 +442,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._percent = percent; var res = percent / 100.0; var dis = this._barLength * res; - this._slidBallRenderer.setPosition(cc.p(dis, this._contentSize.height / 2)); + this._slidBallRenderer.setPosition(dis, this._contentSize.height / 2); if (this._scale9Enabled) this._progressBarRenderer.setPreferredSize(cc.size(dis, this._progressBarTextureSize.height)); else { diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 8cd56c715e..3b5fd485dd 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -54,6 +54,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _pageViewEventListener: null, _pageViewEventSelector: null, _className:"PageView", + _customScrollThreshold: 0, + _usingCustomScrollThreshold: false, /** * Allocates and initializes a UIPageView. @@ -332,11 +334,12 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {cc.Event} event */ onTouchMoved: function (touch, event) { - this._handleMoveLogic(touch); - var widgetParent = this.getWidgetParent(); - if (widgetParent) - widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); - this._moveEvent(); + + ccui.Layout.prototype.onTouchMoved(touch, event); + if (!this._isInterceptTouch) + { + this._handleMoveLogic(touch); + } }, /** @@ -347,7 +350,11 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ */ onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this._handleReleaseLogic(touch); + if (!this._isInterceptTouch) + { + this._handleReleaseLogic(touch); + } + this._isInterceptTouch = false; }, /** @@ -357,7 +364,11 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ */ onTouchCancelled: function (touch, event) { ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); - this._handleReleaseLogic(touch); + if (!this._isInterceptTouch) + { + this.handleReleaseLogic(touch); + } + this._isInterceptTouch = false; }, _doLayout: function(){ @@ -422,6 +433,37 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._scrollPages(offset); }, + /** + * Set CustomScrollThreshold + * @param threshold + */ + setCustomScrollThreshold: function(threshold){ + cc.assert(threshold>0, "Invalid threshold!"); + this._customScrollThreshold = threshold; + this.setUsingCustomScrollThreshold(true); + }, + + /** + * Gets the _customScrollThreshold. + */ + getCustomScrollThreshold: function(){ + return this._customScrollThreshold; + }, + + /** + * Set the UsingCustomScrollThreshold + */ + setUsingCustomScrollThreshold: function(flag){ + this._usingCustomScrollThreshold = flag; + }, + + /** + * Gets the UsingCustomScrollThreshold + */ + isUsingCustomScrollThreshold: function(){ + return this._usingCustomScrollThreshold; + }, + _handleReleaseLogic: function (touchPoint) { if (this._pages.length <= 0) return; @@ -431,7 +473,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var pageCount = this._pages.length; var curPageLocation = curPagePos.x; var pageWidth = this.getSize().width; - var boundary = pageWidth / 2.0; + if (!this._usingCustomScrollThreshold) { + this._customScrollThreshold = pageWidth / 2.0; + } + var boundary = this._customScrollThreshold; if (curPageLocation <= -boundary) { if (this._curPageIdx >= pageCount - 1) this._scrollPages(-curPageLocation); @@ -459,6 +504,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ case ccui.Widget.TOUCH_BEGAN: this._touchBeganPosition.x = touchPoint.x; this._touchBeganPosition.y = touchPoint.y; + this._isInterceptTouch = true; break; case ccui.Widget.TOUCH_MOVED: this._touchMovePosition.x = touchPoint.x; @@ -475,6 +521,10 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; this._handleReleaseLogic(touch); + if (sender.isSwallowTouches()) + { + this._isInterceptTouch = false; + } break; } }, @@ -559,6 +609,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ ccui.Layout.prototype._copySpecialProperties.call(this, pageView); this._pageViewEventListener = pageView._pageViewEventListener; this._pageViewEventSelector = pageView._pageViewEventSelector; + this._usingCustomScrollThreshold = pageView._usingCustomScrollThreshold; + this._customScrollThreshold = pageView._customScrollThreshold; } }); /** diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index f9849d3680..bbad9c2193 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1375,8 +1375,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ onTouchBegan: function (touch, event) { var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event); - if (this._hit) - this._handlePressLogic(touch); + if(!this._isInterceptTouch){ + if (this._hit) + this._handlePressLogic(touch); + } return pass; }, @@ -1387,7 +1389,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ onTouchMoved: function (touch, event) { ccui.Layout.prototype.onTouchMoved.call(this, touch, event); - this._handleMoveLogic(touch); + if(!this._isInterceptTouch) + this._handleMoveLogic(touch); }, /** @@ -1397,7 +1400,9 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); - this._handleReleaseLogic(touch); + if(!this._isInterceptTouch) + this._handleReleaseLogic(touch); + this._isInterceptTouch = false; }, /** @@ -1407,6 +1412,9 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ */ onTouchCancelled: function (touch, event) { ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); + if (!this._isInterceptTouch) + this.handleReleaseLogic(touch); + this._isInterceptTouch = false; }, /** @@ -1437,6 +1445,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var touchPoint = touch.getLocation(); switch (event) { case ccui.Widget.TOUCH_BEGAN: + this._isInterceptTouch = true; this._touchBeganPosition.x = touchPoint.x; this._touchBeganPosition.y = touchPoint.y; this._handlePressLogic(touch); @@ -1455,6 +1464,9 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; this._handleReleaseLogic(touch); + if (sender.isSwallowTouches()){ + this._isInterceptTouch = false; + } break; } }, diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js index e33973093d..15e0c200d4 100644 --- a/extensions/cocostudio/action/CCActionObject.js +++ b/extensions/cocostudio/action/CCActionObject.js @@ -210,6 +210,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ */ pause: function () { this._pause = true; + this._playing = false; }, /** @@ -221,6 +222,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ locActionNodeList[i].stopAction(); this._scheduler.unscheduleCallbackForTarget(this, this.simulationActionUpdate); this._pause = false; + this._playing = false; }, /** @@ -252,8 +254,10 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ this._callback.execute(); if (this._loop) this.play(); - else + else{ + this._playing = false; this._scheduler.unschedule(this.simulationActionUpdate, this); + } } } }); \ No newline at end of file diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 60ed1ffccf..230b447723 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -339,6 +339,10 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ return this._realAnchorPointInPoints; }, + getOffsetPoints: function(){ + return {x: this._offsetPoint.x, y: this._offsetPoint.y}; + }, + /** * Sets animation to this Armature * @param {ccs.ArmatureAnimation} animation diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 8a4d1d78a5..c95c964577 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -177,8 +177,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ locWorldInfo.y = locTweenData.y + this._position.y; locWorldInfo.scaleX = locTweenData.scaleX * this._scaleX; locWorldInfo.scaleY = locTweenData.scaleY * this._scaleY; - locWorldInfo.skewX = locTweenData.skewX + this._skewX + this._rotationX; - locWorldInfo.skewY = locTweenData.skewY + this._skewY - this._rotationY; + locWorldInfo.skewX = locTweenData.skewX + this._skewX + cc.degreesToRadians(this._rotationX); + locWorldInfo.skewY = locTweenData.skewY + this._skewY - cc.degreesToRadians(this._rotationY); if(this._parentBone) this._applyParentTransform(this._parentBone); diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index d7fb4dd382..2661c71ce4 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -588,7 +588,7 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend(/** @lends cc checkBox.loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp, backGroundDisabledFileName_tp, frontCrossDisabledFileName_tp); } - checkBox.setSelectedState(options["selectedState"] || false); + checkBox.setSelected(options["selectedState"] || false); this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 06dd286342..f35aed11a7 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -254,6 +254,15 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ this.createObject(subDict, gb); subDict = null; } + + var canvasSizeDict = inputFiles["CanvasSize"]; + if (canvasSizeDict) + { + var width = canvasSizeDict["_width"]; + var height = canvasSizeDict["_height"]; + gb.setContentSize(cc.size(width, height)); + } + return gb; } @@ -318,6 +327,9 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ var fRotationZ = (cc.isUndefined(dict["rotation"]))?0:dict["rotation"]; node.setRotation(fRotationZ); + + var sName = dict["name"] || ""; + node.setName(sName); }, /** diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index a152e23ce5..9ec1481ffd 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -50,7 +50,7 @@ ccs.TextFieldReader = /** @lends ccs.TextFieldReader# */{ var ph = options["placeHolder"]; if(ph) textField.setPlaceHolder(ph); - textField.setString(options["text"]); + textField.setString(options["text"] || "Text Field"); var fs = options["fontSize1"]; if(fs) textField.setFontSize(fs); From e5727b24218b02ec2b519bbf3c24d3e2450c7bb2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 14 Oct 2014 10:51:58 +0800 Subject: [PATCH 0782/1564] Issue #5933: Fixed a bug that pageview --- extensions/ccui/layouts/UILayout.js | 1 - extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 723fed32ad..bca09016e3 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1795,7 +1795,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _copySpecialProperties: function (layout) { if(!(layout instanceof ccui.Layout)) return; - ccui.Widget.prototype._copySpecialProperties.call(this, layout); this.setBackGroundImageScale9Enabled(layout._backGroundScale9Enabled); this.setBackGroundImage(layout._backGroundImageFileName, layout._bgImageTexType); this.setBackGroundImageCapInsets(layout._backGroundImageCapInsets); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 3b5fd485dd..dd3bd2c4e6 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -335,7 +335,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ */ onTouchMoved: function (touch, event) { - ccui.Layout.prototype.onTouchMoved(touch, event); + ccui.Layout.prototype.onTouchMoved.call(this, touch, event); if (!this._isInterceptTouch) { this._handleMoveLogic(touch); From 47641bf4ad25d539b9538fdfb11fedb4c624a728 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 14 Oct 2014 10:58:07 +0800 Subject: [PATCH 0783/1564] Issue #5933: remove studio namespace --- .../reader/timeline/ActionTimelineCache.js | 514 +++++++++--------- 1 file changed, 256 insertions(+), 258 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index 6dc5da71d9..b0fdc4b3c7 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -22,324 +22,322 @@ THE SOFTWARE. ****************************************************************************/ -(function(studio){ - var tlparam = { - FrameType_VisibleFrame : "VisibleFrame", - FrameType_PositionFrame : "PositionFrame", - FrameType_ScaleFrame : "ScaleFrame", - FrameType_RotationFrame : "RotationFrame", - FrameType_SkewFrame : "SkewFrame", - FrameType_RotationSkewFrame : "RotationSkewFrame", - FrameType_AnchorFrame : "AnchorFrame", - FrameType_InnerActionFrame : "InnerActionFrame", - FrameType_ColorFrame : "ColorFrame", - FrameType_TextureFrame : "TextureFrame", - FrameType_EventFrame : "EventFrame", - FrameType_ZOrderFrame : "ZOrderFrame", - - ACTION : "action", - DURATION : "duration", - TIMELINES : "timelines", - FRAME_TYPE : "frameType", - FRAMES : "frames", - FRAME_INDEX : "frameIndex", - TWEEN : "tween", - TIME_SPEED : "speed", - ACTION_TAG : "actionTag", - INNER_ACTION : "innerActionType", - START_FRAME : "startFrame", - - X : "x", - Y : "y", - ROTATION : "rotation", - ALPHA : "alpha", - RED : "red", - GREEN : "green", - BLUE : "blue", - Value : "value" - }; +var ActionTimelineCacheStatic = { + FrameType_VisibleFrame : "VisibleFrame", + FrameType_PositionFrame : "PositionFrame", + FrameType_ScaleFrame : "ScaleFrame", + FrameType_RotationFrame : "RotationFrame", + FrameType_SkewFrame : "SkewFrame", + FrameType_RotationSkewFrame : "RotationSkewFrame", + FrameType_AnchorFrame : "AnchorFrame", + FrameType_InnerActionFrame : "InnerActionFrame", + FrameType_ColorFrame : "ColorFrame", + FrameType_TextureFrame : "TextureFrame", + FrameType_EventFrame : "EventFrame", + FrameType_ZOrderFrame : "ZOrderFrame", + + ACTION : "action", + DURATION : "duration", + TIMELINES : "timelines", + FRAME_TYPE : "frameType", + FRAMES : "frames", + FRAME_INDEX : "frameIndex", + TWEEN : "tween", + TIME_SPEED : "speed", + ACTION_TAG : "actionTag", + INNER_ACTION : "innerActionType", + START_FRAME : "startFrame", + + X : "x", + Y : "y", + ROTATION : "rotation", + ALPHA : "alpha", + RED : "red", + GREEN : "green", + BLUE : "blue", + Value : "value" +}; + +/** + * action timeline cache + * @name ccs.ActionTimelineCache + * @namespace + */ +ccs.ActionTimelineCache = { + + _FrameCreateFunc: null, + _Pair: null, + _funcs: null, + _animationActions: null, /** - * action timeline cache - * @name ccs.ActionTimelineCache - * @namespace + * The initialization part object */ - studio.ActionTimelineCache = { - - _FrameCreateFunc: null, - _Pair: null, - _funcs: null, - _animationActions: null, - - /** - * The initialization part object - */ - init: function(){ - - this._animationActions = {}; - this._funcs = {}; - this._funcs["VisibleFrame"] = this._loadVisibleFrame; - this._funcs["PositionFrame"] = this._loadPositionFrame; - this._funcs["ScaleFrame"] = this._loadScaleFrame; - this._funcs["RotationFrame"] = this._loadRotationFrame; - this._funcs["SkewFrame"] = this._loadSkewFrame; - this._funcs["RotationSkewFrame"] = this._loadRotationSkewFrame; - this._funcs["AnchorFrame"] = this._loadAnchorPointFrame; - this._funcs["InnerActionFrame"] = this._loadInnerActionFrame; - this._funcs["ColorFrame"] = this._loadColorFrame; - this._funcs["TextureFrame"] = this._loadTextureFrame; - this._funcs["EventFrame"] = this._loadEventFrame; - this._funcs["ZOrderFrame"] = this._loadZOrderFrame; - }, - - /** - * remove Action - * @param {string} fileName - */ - removeAction: function(fileName){ - if (this._animationActions[fileName]) { - delete this._animationActions[fileName]; - } - }, - - /** - * Create new action - * @param {string} fileName - * @returns {*} - */ - createAction: function(fileName){ - - var action = this._animationActions[fileName]; - if (action == null) { - action = this.loadAnimationActionWithFile(fileName); - } - return action.clone(); - }, - - /** - * load Animation Action With File - * @param {string} fileName - * @returns {*} - */ - loadAnimationActionWithFile: function(fileName){ - // Read content from file - //TODO Whether you need a complete path splicing? - var contentStr = cc.loader.getRes(fileName); - return this.loadAnimationActionWithContent(fileName, contentStr); - - }, - - /** - * Load animation action with content. - * @param {string} fileName - * @param {Object} content - * @returns {*} - */ - loadAnimationActionWithContent: function(fileName, content){ - // if already exists an action with filename, then return this action - var action = this._animationActions[fileName]; - if(action) - return action; - - var json = content[tlparam.ACTION]; - - action = new studio.ActionTimeline(); - - action.setDuration(json[tlparam.DURATION]); - action.setTimeSpeed(json[tlparam.TIME_SPEED] || 1); - - var timelineLength = json[tlparam.TIMELINES].length; - for (var i = 0; i Date: Tue, 14 Oct 2014 15:09:53 +0800 Subject: [PATCH 0784/1564] Issue #5968: refactor load event of texture, sprite frame and sprite etc --- CCBoot.js | 1 - cocos2d/core/event-manager/CCEventManager.js | 89 ++++++++++++++++++- cocos2d/core/sprites/CCSprite.js | 37 +++----- cocos2d/core/sprites/CCSpriteFrame.js | 24 ++--- cocos2d/core/sprites/SpritesWebGL.js | 12 +-- cocos2d/core/textures/CCTexture2D.js | 37 +++----- cocos2d/core/textures/TexturesWebGL.js | 70 +++------------ cocos2d/labels/CCLabelAtlas.js | 23 ++--- cocos2d/labels/CCLabelBMFont.js | 27 ++---- cocos2d/menus/CCMenuItem.js | 4 +- cocos2d/particle/CCParticleSystem.js | 2 +- .../ccui/base-classes/UIScale9Sprite.js | 32 +++---- extensions/ccui/uiwidgets/UIButton.js | 9 +- extensions/ccui/uiwidgets/UICheckBox.js | 15 ++-- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- extensions/ccui/uiwidgets/UISlider.js | 12 ++- extensions/ccui/uiwidgets/UITextBMFont.js | 2 +- .../gui/control-extension/CCScale9Sprite.js | 32 +++---- 19 files changed, 193 insertions(+), 239 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 69cbe397e9..30bd37f3b4 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -758,7 +758,6 @@ cc.loader = /** @lends cc.loader# */{ }else{ typeof cb == "function" && cb("load image failed"); } - }; cc._addEventListener(img, "load", lcb); diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 89957f64da..39ac6a8069 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -922,4 +922,91 @@ cc.eventManager = /** @lends cc.eventManager# */{ ev.setUserData(optionalUserData); this.dispatchEvent(ev); } -}; \ No newline at end of file +}; + +// The event helper +cc.EventHelper = function(){}; + +cc.EventHelper.prototype = { + constructor: cc.EventHelper, + + apply: function ( object ) { + object.addEventListener = cc.EventHelper.prototype.addEventListener; + object.hasEventListener = cc.EventHelper.prototype.hasEventListener; + object.removeEventListener = cc.EventHelper.prototype.removeEventListener; + object.dispatchEvent = cc.EventHelper.prototype.dispatchEvent; + }, + + addEventListener: function ( type, listener, target ) { + if ( this._listeners === undefined ) + this._listeners = {}; + + var listeners = this._listeners; + if ( listeners[ type ] === undefined ) + listeners[ type ] = []; + + if ( this.hasEventListener(listener, target)) + listeners[ type ].push( {callback:listener, eventTarget: target} ); + }, + + hasEventListener: function ( type, listener, target ) { + if ( this._listeners === undefined ) + return false; + + var listeners = this._listeners; + if ( listeners[ type ] !== undefined ) { + for(var i = 0, len = listeners.length; i < len ; i++){ + var selListener = listeners[i]; + if(selListener.callback == listener && selListener.eventTarget == target) + return true; + } + } + return false; + }, + + removeEventListener: function( type, target){ + if ( this._listeners === undefined ) + return; + + var listeners = this._listeners; + var listenerArray = listeners[ type ]; + + if ( listenerArray !== undefined ) { + for(var i = 0; i < listenerArray.length ; ){ + var selListener = listenerArray[i]; + if(selListener.eventTarget == target) + listenerArray.splice( i, 1 ); + else + i++ + } + } + }, + + dispatchEvent: function ( event, clearAfterDispatch ) { + if ( this._listeners === undefined ) + return; + + if(clearAfterDispatch == null) + clearAfterDispatch = true; + var listeners = this._listeners; + var listenerArray = listeners[ event.type ]; + + if ( listenerArray !== undefined ) { + event.target = this; + var array = []; + var length = listenerArray.length; + + for ( var i = 0; i < length; i ++ ) { + array[ i ] = listenerArray[ i ]; + } + + for ( i = 0; i < length; i ++ ) { + array[ i ].callback.call( array[i].eventTarget, this ); + } + + if(clearAfterDispatch) + listenerArray.length = 0; + } + } +}; + diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index e01438000f..bee7711cc7 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -335,7 +335,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _flippedY:false, //Whether the sprite is flipped vertically or not. _textureLoaded:false, - _loadedEventListeners: null, _newTextureWhenChangeColor: null, //hack property for LabelBMFont _className:"Sprite", @@ -354,22 +353,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * Add a event listener for texture loaded event. * @param {Function} callback * @param {Object} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener:function(callback, target){ - if(!this._loadedEventListeners) - this._loadedEventListeners = []; - this._loadedEventListeners.push({eventCallback:callback, eventTarget:target}); - }, - - _callLoadedEventCallbacks:function(){ - if(!this._loadedEventListeners) - return; - var locListeners = this._loadedEventListeners; - for(var i = 0, len = locListeners.length; i < len; i++){ - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.addEventListener("load", callback, target); }, /** @@ -473,7 +460,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if(!spriteFrame.textureLoaded()){ //add event listener this._textureLoaded = false; - spriteFrame.addLoadedEventListener(this._spriteFrameLoadedCallback, this); + spriteFrame.addEventListener("load", this._spriteFrameLoadedCallback, this); } var rotated = cc._renderType === cc._RENDER_TYPE_CANVAS ? false : spriteFrame._rotated; @@ -1227,7 +1214,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) _t._changeTextureColor(); - _t._callLoadedEventCallbacks(); + _t.dispatchEvent("load"); }; _p.setOpacityModifyRGB = function (modify) { @@ -1358,8 +1345,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._rect.height = rect.height; } if(_t.texture) - _t.texture.removeLoadedEventListener(_t); - texture.addLoadedEventListener(_t._textureLoadedCallback, _t); + _t.texture.removeEventListener("load", _t); + texture.addEventListener("load", _t._textureLoadedCallback, _t); _t.texture = texture; return true; } @@ -1413,7 +1400,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" _t.batchNode = _t._batchNode; - _t._callLoadedEventCallbacks(); + _t.dispatchEvent("load"); }; _p.setTextureRect = function (rect, rotated, untrimmedSize) { @@ -1534,13 +1521,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var locTextureLoaded = newFrame.textureLoaded(); if (!locTextureLoaded) { _t._textureLoaded = false; - newFrame.addLoadedEventListener(function (sender) { + newFrame.addEventListener("load", function (sender) { _t._textureLoaded = true; var locNewTexture = sender.getTexture(); if (locNewTexture != _t._texture) _t.texture = locNewTexture; _t.setTextureRect(sender.getRect(), sender.isRotated(), sender.getOriginalSize()); - _t._callLoadedEventCallbacks(); + _t.dispatchEvent("load"); }, _t); } // update texture before updating texture rect @@ -1594,7 +1581,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t.setTextureRect(cc.rect(0,0, size.width, size.height)); //If image isn't loaded. Listen for the load event. if(!texture._isLoaded){ - texture.addLoadedEventListener(function(){ + texture.addEventListener("load", function(){ var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); }, this); @@ -1638,13 +1625,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - delete _p; + _p = null; } else { cc.assert(cc.isFunction(cc._tmp.WebGLSprite), cc._LogInfos.MissingFile, "SpritesWebGL.js"); cc._tmp.WebGLSprite(); delete cc._tmp.WebGLSprite; } +cc.EventHelper.prototype.apply(cc.Sprite.prototype); + cc.assert(cc.isFunction(cc._tmp.PrototypeSprite), cc._LogInfos.MissingFile, "SpritesPropertyDefine.js"); cc._tmp.PrototypeSprite(); delete cc._tmp.PrototypeSprite; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 9c5250bbfe..f485cfba57 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -62,7 +62,6 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ _texture:null, _textureFilename:"", _textureLoaded:false, - _eventListeners:null, ctor:function (filename, rect, rotated, offset, originalSize) { this._offset = cc.p(0, 0); @@ -94,22 +93,10 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * Add a event listener for texture loaded event. * @param {Function} callback * @param {Object} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener:function(callback, target){ - if (this._eventListeners == null){ - this._eventListeners = []; - } - this._eventListeners.push({eventCallback:callback, eventTarget:target}); - }, - - _callLoadedEventCallbacks:function(){ - var locListeners = this._eventListeners; - if (!locListeners) return; - for(var i = 0, len = locListeners.length; i < len; i++){ - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.addEventListener("load", callback, target); }, /** @@ -254,7 +241,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this._textureLoaded = locLoaded; this._texture = texture; if(!locLoaded){ - texture.addLoadedEventListener(function(sender){ + texture.addEventListener("load", function(sender){ this._textureLoaded = true; if(this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS){ var tempElement = sender.getHtmlElementObj(); @@ -278,7 +265,8 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this._originalSize.width = w; this._originalSize.height = h; } - this._callLoadedEventCallbacks(); + //dispatch 'load' event of cc.SpriteFrame + this.dispatchEvent("load"); }, this); } } @@ -389,6 +377,8 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ } }); +cc.EventHelper.prototype.apply(cc.SpriteFrame.prototype); + /** *

    * Create a cc.SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
    diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 80f574256b..4eff01f610 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -30,7 +30,7 @@ cc._tmp.WebGLSprite = function () { _p._spriteFrameLoadedCallback = function(spriteFrame){ this.setNodeDirty(true); this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); }; _p.setOpacityModifyRGB = function (modify) { @@ -169,7 +169,7 @@ cc._tmp.WebGLSprite = function () { locRect.width = rect.width; locRect.height = rect.height; } - texture.addLoadedEventListener(_t._textureLoadedCallback, _t); + texture.addEventListener("load", _t._textureLoadedCallback, _t); return true; } @@ -225,7 +225,7 @@ cc._tmp.WebGLSprite = function () { // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" _t.batchNode = _t._batchNode; _t._quadDirty = true; - _t._callLoadedEventCallbacks(); + _t.dispatchEvent("load"); }; _p.setTextureRect = function (rect, rotated, untrimmedSize) { @@ -416,14 +416,14 @@ cc._tmp.WebGLSprite = function () { var locTextureLoaded = newFrame.textureLoaded(); if (!locTextureLoaded) { _t._textureLoaded = false; - newFrame.addLoadedEventListener(function (sender) { + newFrame.addEventListener("load", function (sender) { _t._textureLoaded = true; var locNewTexture = sender.getTexture(); if (locNewTexture != _t._texture) _t.texture = locNewTexture; _t.setTextureRect(sender.getRect(), sender.isRotated(), sender.getOriginalSize()); - _t._callLoadedEventCallbacks(); + _t.dispatchEvent("load"); }, _t); } // update texture before updating texture rect @@ -480,7 +480,7 @@ cc._tmp.WebGLSprite = function () { _t.setTextureRect(cc.rect(0,0, size.width, size.height)); //If image isn't loaded. Listen for the load event. if(!texture._isLoaded){ - texture.addLoadedEventListener(function(){ + texture.addEventListener("load", function(){ var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); }, this); diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index b094af561f..236280cd81 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -124,7 +124,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _contentSize: null, _isLoaded: false, _htmlElementObj: null, - _loadedEventListeners: null, url: null, @@ -204,7 +203,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * handle loaded texture */ handleLoadedTexture: function () { - var self = this + var self = this; if (self._isLoaded) return; if (!self._htmlElementObj) { var img = cc.loader.getRes(self.url); @@ -217,7 +216,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { self._contentSize.width = locElement.width; self._contentSize.height = locElement.height; - self._callLoadedEventCallbacks(); + //dispatch load event to listener. + self.dispatchEvent("load"); }, /** @@ -368,38 +368,19 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * add listener for loaded event * @param {Function} callback * @param {cc.Node} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener: function (callback, target) { - if (!this._loadedEventListeners) - this._loadedEventListeners = []; - this._loadedEventListeners.push({eventCallback: callback, eventTarget: target}); + this.addEventListener("load", callback, target); }, /** - * remove listner for loaded event + * remove listener from listeners by target * @param {cc.Node} target + * @deprecated since 3.1, please use addEventListener instead */ removeLoadedEventListener: function (target) { - if (!this._loadedEventListeners) - return; - var locListeners = this._loadedEventListeners; - for (var i = 0; i < locListeners.length; i++) { - var selCallback = locListeners[i]; - if (selCallback.eventTarget == target) { - locListeners.splice(i, 1); - } - } - }, - - _callLoadedEventCallbacks: function () { - if (!this._loadedEventListeners) - return; - var locListeners = this._loadedEventListeners; - for (var i = 0, len = locListeners.length; i < len; i++) { - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.removeEventListener("load", target); } }); @@ -409,6 +390,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { delete cc._tmp.WebGLTexture2D; } +cc.EventHelper.prototype.apply(cc.Texture2D.prototype); + cc.assert(cc.isFunction(cc._tmp.PrototypeTexture2D), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js"); cc._tmp.PrototypeTexture2D(); delete cc._tmp.PrototypeTexture2D; \ No newline at end of file diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 60493c82f9..abd6b53ee7 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -69,7 +69,6 @@ cc._tmp.WebGLTexture2D = function () { _webTextureObj: null, url: null, - _loadedEventListeners: null, /** * constructor of cc.Texture2D @@ -446,15 +445,15 @@ cc._tmp.WebGLTexture2D = function () { handleLoadedTexture: function () { var self = this; // Not sure about this ! Some texture need to be updated even after loaded - if (!cc._rendererInitialized) return; + if (!cc._rendererInitialized) + return; if (!self._htmlElementObj) { var img = cc.loader.getRes(self.url); if (!img) return; self.initWithElement(img); } - if (!self._htmlElementObj.width || !self._htmlElementObj.height) { + if (!self._htmlElementObj.width || !self._htmlElementObj.height) return; - } self._isLoaded = true; //upload image to buffer var gl = cc._renderContext; @@ -486,7 +485,8 @@ cc._tmp.WebGLTexture2D = function () { self._hasPremultipliedAlpha = false; self._hasMipmaps = false; - this._callLoadedEventCallbacks(); + //dispatch load event to listener. + self.dispatchEvent("load"); }, /** @@ -573,9 +573,6 @@ cc._tmp.WebGLTexture2D = function () { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texParams.magFilter); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParams.wrapS); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParams.wrapT); - - //TODO - //VolatileTexture::setTexParameters(_t, texParams); }, /** @@ -592,11 +589,6 @@ cc._tmp.WebGLTexture2D = function () { else gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - //TODO - /*#if CC_ENABLE_CACHE_TEXTURE_DATA - ccTexParams texParams = {m_bHasMipmaps?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR,GL_LINEAR,GL_NONE,GL_NONE}; - VolatileTexture::setTexParameters(this, &texParams); - #endif*/ }, /** @@ -613,12 +605,6 @@ cc._tmp.WebGLTexture2D = function () { else gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - - //TODO - /*#if CC_ENABLE_CACHE_TEXTURE_DATA - ccTexParams texParams = {m_bHasMipmaps?GL_NEAREST_MIPMAP_NEAREST:GL_NEAREST,GL_NEAREST,GL_NONE,GL_NONE}; - VolatileTexture::setTexParameters(this, &texParams); - #endif*/ }, /** @@ -759,51 +745,28 @@ cc._tmp.WebGLTexture2D = function () { }, /** - * add listener of loaded event + * add listener for loaded event * @param {Function} callback * @param {cc.Node} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener: function (callback, target) { - if (!this._loadedEventListeners) - this._loadedEventListeners = []; - this._loadedEventListeners.push({eventCallback: callback, eventTarget: target}); + this.addEventListener("load", callback, target); }, /** - * return listener of loaded event + * remove listener from listeners by target * @param {cc.Node} target + * @deprecated since 3.1, please use addEventListener instead */ removeLoadedEventListener: function (target) { - if (!this._loadedEventListeners) - return; - var locListeners = this._loadedEventListeners; - for (var i = 0; i < locListeners.length; i++) { - var selCallback = locListeners[i]; - if (selCallback.eventTarget == target) { - locListeners.splice(i, 1); - } - } - }, - - _callLoadedEventCallbacks: function () { - if (!this._loadedEventListeners) - return; - var locListeners = this._loadedEventListeners; - for (var i = 0, len = locListeners.length; i < len; i++) { - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.removeEventListener("load", target); } }); - }; - cc._tmp.WebGLTextureAtlas = function () { - var _p = cc.TextureAtlas.prototype; - _p._setupVBO = function () { var _t = this; var gl = cc._renderContext; @@ -828,7 +791,6 @@ cc._tmp.WebGLTextureAtlas = function () { //cc.checkGLErrorDebug(); }; - /** *

    Draws n quads from an index (offset).
    * n + start can't be greater than the capacity of the atlas

    @@ -873,10 +835,9 @@ cc._tmp.WebGLTextureAtlas = function () { cc.g_NumberOfDraws++; //cc.checkGLErrorDebug(); }; - }; -cc._tmp.WebGLTextureCache = function () { +cc._tmp.WebGLTextureCache = function () { var _p = cc.textureCache; _p.handleLoadedTexture = function (url) { @@ -908,8 +869,6 @@ cc._tmp.WebGLTextureCache = function () { * cc.textureCache.addImage("hello.png"); */ _p.addImage = function (url, cb, target) { - - cc.assert(url, cc._LogInfos.Texture2D_addImage_2); var locTexs = this._textures; @@ -943,6 +902,5 @@ cc._tmp.WebGLTextureCache = function () { tex.url = url; return tex; }; - - delete _p; -} + _p = null; +}; diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 61d3a764ba..a6f186319a 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -53,7 +53,6 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ _mapStartChar: null, _textureLoaded: false, - _loadedEventListeners: null, _className: "LabelAtlas", /** @@ -91,23 +90,10 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ * Add texture loaded event listener. * @param {Function} callback * @param {cc.Node} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener: function (callback, target) { - if (!this._loadedEventListeners) - this._loadedEventListeners = []; - this._loadedEventListeners.push({eventCallback: callback, eventTarget: target}); - }, - - _callLoadedEventCallbacks: function () { - if (!this._loadedEventListeners) - return; - this._textureLoaded = true; - var locListeners = this._loadedEventListeners; - for (var i = 0, len = locListeners.length; i < len; i++) { - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.addEventListener("load", callback, target); }, /** @@ -154,10 +140,10 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ var locLoaded = texture.isLoaded(); this._textureLoaded = locLoaded; if (!locLoaded) { - texture.addLoadedEventListener(function (sender) { + texture.addEventListener("load", function (sender) { this.initWithTexture(texture, width, height, label.length); this.string = label; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); }, this); } if (this.initWithTexture(texture, width, height, label.length)) { @@ -376,6 +362,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ }); var _p = cc.LabelAtlas.prototype; +cc.EventHelper.prototype.apply(_p); if (cc._renderType === cc._RENDER_TYPE_WEBGL) { _p.updateAtlasValues = _p._updateAtlasValuesForWebGL; _p.setString = _p._setStringForWebGL; diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index c200741499..8b5ece7f91 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -121,7 +121,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ _cascadeOpacityEnabled: true, _textureLoaded: false, - _loadedEventListeners: null, _className: "LabelBMFont", _setString: function (newString, needUpdateLabel) { @@ -179,22 +178,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ * Will execute the callback in the loaded. * @param {Function} callback * @param {Object} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener: function (callback, target) { - if (!this._loadedEventListeners) - this._loadedEventListeners = []; - this._loadedEventListeners.push({eventCallback: callback, eventTarget: target}); - }, - - _callLoadedEventCallbacks: function () { - if (!this._loadedEventListeners) - return; - var locListeners = this._loadedEventListeners; - for (var i = 0, len = locListeners.length; i < len; i++) { - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.addEventListener("load", callback, target); }, /** @@ -452,13 +439,13 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var locIsLoaded = texture.isLoaded(); self._textureLoaded = locIsLoaded; if (!locIsLoaded) { - texture.addLoadedEventListener(function (sender) { + texture.addEventListener("load", function (sender) { var self1 = this; self1._textureLoaded = true; //reset the LabelBMFont self1.initWithTexture(sender, self1._initialString.length); self1.setString(self1._initialString, true); - self1._callLoadedEventCallbacks(); + self1.dispatchEvent("load"); }, self); } } else { @@ -959,14 +946,15 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (cc._renderType === cc._RENDER_TYPE_CANVAS) self._originalTexture = self.texture; if (!locIsLoaded) { - texture.addLoadedEventListener(function (sender) { + texture.addEventListener("load", function (sender) { var self1 = this; self1._textureLoaded = true; self1.texture = sender; self1.createFontChars(); self1._changeTextureColor(); self1.updateLabel(); - self1._callLoadedEventCallbacks(); + + self1.dispatchEvent("load"); }, self); } else { self.createFontChars(); @@ -1071,6 +1059,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ }); var _p = cc.LabelBMFont.prototype; +cc.EventHelper.prototype.apply(_p); if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (!cc.sys._supportCanvasNewBlendModes) { diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 6f3b31bb7e..698f46b8cb 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -797,7 +797,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ this._updateImagesVisibility(); if (normalImage.textureLoaded && !normalImage.textureLoaded()) { - normalImage.addLoadedEventListener(function (sender) { + normalImage.addEventListener("load", function (sender) { this.width = sender.width; this.height = sender.height; }, this); @@ -883,7 +883,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ this.height = locNormalImage.height; if (locNormalImage.textureLoaded && !locNormalImage.textureLoaded()) { - locNormalImage.addLoadedEventListener(function (sender) { + locNormalImage.addEventListener("load", function (sender) { this.width = sender.width; this.height = sender.height; this.cascadeColor = true; diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 80b5b65aba..6ce1edf970 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1301,7 +1301,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ this.setTextureWithRect(texture, cc.rect(0, 0, texture.width, texture.height)); } else { this._textureLoaded = false; - texture.addLoadedEventListener(function(sender){ + texture.addEventListener("load", function(sender){ this._textureLoaded = true; this.setTextureWithRect(sender, cc.rect(0, 0, sender.width, sender.height)); }, this); diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index b5e929e285..10843b5bd0 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -86,7 +86,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _spritesGenerated: false, _spriteFrameRotated: false, _textureLoaded:false, - _loadedEventListeners: null, _className:"Scale9Sprite", /** @@ -101,19 +100,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * add texture loaded event listener * @param {Function} callback * @param {Object} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener:function(callback, target){ - this._loadedEventListeners.push({eventCallback:callback, eventTarget:target}); - }, - - _callLoadedEventCallbacks:function(){ - this._textureLoaded = true; - var locListeners = this._loadedEventListeners; - for(var i = 0, len = locListeners.length; i < len; i++){ - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.addEventListener("load", callback, target); }, _updateCapInset: function () { @@ -250,7 +240,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._originalSize = cc.size(0, 0); this._preferredSize = cc.size(0, 0); this._capInsets = cc.rect(0, 0, 0, 0); - this._loadedEventListeners = []; //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ @@ -583,7 +572,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ var locLoaded = texture.isLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - texture.addLoadedEventListener(function(sender){ + texture.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); @@ -591,7 +580,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); }, this); } @@ -616,14 +605,14 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ var locLoaded = spriteFrame.textureLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - spriteFrame.addLoadedEventListener(function(sender){ + spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); },this); } var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); @@ -720,9 +709,9 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ var locLoaded = tmpTexture.isLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - tmpTexture.addLoadedEventListener(function(sender){ + tmpTexture.addEventListener("load", function(sender){ this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); },this); return true; } @@ -1016,14 +1005,14 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ var locLoaded = spriteFrame.textureLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - spriteFrame.addLoadedEventListener(function(sender){ + spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); },this); } this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0)); @@ -1037,6 +1026,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }); var _p = ccui.Scale9Sprite.prototype; +cc.EventHelper.prototype.apply(_p); // Extended properties /** @expose */ diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index f89eb5a233..25cb9faaa1 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -239,8 +239,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var self = this; if(!this._buttonNormalRenderer.texture || !this._buttonNormalRenderer.texture.isLoaded()){ - this._buttonNormalRenderer.addLoadedEventListener(function(){ - + this._buttonNormalRenderer.addEventListener("load", function(){ self._findLayout(); self._normalTextureSize = self._buttonNormalRenderer.getContentSize(); @@ -310,8 +309,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var self = this; if(!this._buttonClickedRenderer.texture || !this._buttonClickedRenderer.texture.isLoaded()){ - this._buttonClickedRenderer.addLoadedEventListener(function(){ - + this._buttonClickedRenderer.addEventListener("load", function(){ self._findLayout(); self._pressedTextureSize = self._buttonClickedRenderer.getContentSize(); @@ -377,8 +375,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var self = this; if(!this._buttonDisableRenderer.texture || !this._buttonDisableRenderer.texture.isLoaded()){ - this._buttonDisableRenderer.addLoadedEventListener(function() { - + this._buttonDisableRenderer.addEventListener("load", function() { self._findLayout(); self._disabledTextureSize = self._buttonDisableRenderer.getContentSize(); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 8ddfb696cf..51bbb98275 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -150,8 +150,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!bgBoxRenderer.texture || !bgBoxRenderer.texture.isLoaded()){ - bgBoxRenderer.addLoadedEventListener(function(){ - + bgBoxRenderer.addEventListener("load", function(){ self._findLayout(); self._updateFlippedX(); @@ -177,7 +176,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ if (!bgBoxRenderer.textureLoaded()) { this._backGroundBoxRenderer.setContentSize(this._customSize); - bgBoxRenderer.addLoadedEventListener(function () { + bgBoxRenderer.addEventListener("load", function () { this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); }, this); } @@ -205,8 +204,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._backGroundSelectedBoxRenderer.texture || !this._backGroundSelectedBoxRenderer.texture.isLoaded()){ - this._backGroundSelectedBoxRenderer.addLoadedEventListener(function(){ - + this._backGroundSelectedBoxRenderer.addEventListener("load", function(){ self._findLayout(); self._updateFlippedX(); @@ -251,7 +249,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._frontCrossRenderer.texture || !this._frontCrossRenderer.texture.isLoaded()){ - this._frontCrossRenderer.addLoadedEventListener(function(){ + this._frontCrossRenderer.addEventListener("load", function(){ self._findLayout(); self._updateFlippedX(); @@ -295,7 +293,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._backGroundBoxDisabledRenderer.texture || !this._backGroundBoxDisabledRenderer.texture.isLoaded()){ - this._backGroundBoxDisabledRenderer.addLoadedEventListener(function(){ + this._backGroundBoxDisabledRenderer.addEventListener("load", function(){ self._findLayout(); self._updateFlippedX(); @@ -339,8 +337,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._frontCrossDisabledRenderer.texture || !this._frontCrossDisabledRenderer.texture.isLoaded()){ - this._frontCrossDisabledRenderer.addLoadedEventListener(function(){ - + this._frontCrossDisabledRenderer.addEventListener("load", function(){ self._findLayout(); self._updateFlippedX(); diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index e71d8afced..744018f4dd 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -117,7 +117,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ } if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ - imageRenderer.addLoadedEventListener(function(){ + imageRenderer.addEventListener("load", function(){ self._findLayout(); self._imageTextureSize = imageRenderer.getContentSize(); diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 180ba553df..0d36144657 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -122,7 +122,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ var self = this; if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ - barRenderer.addLoadedEventListener(function(){ + barRenderer.addEventListener("load", function(){ self._findLayout(); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 55aad96b10..9ee361d6d8 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -118,7 +118,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ - barRenderer.addLoadedEventListener(function(){ + barRenderer.addEventListener("load", function(){ self._findLayout(); self._updateChildrenDisplayedRGBA(); @@ -163,7 +163,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!progressBarRenderer.texture || !progressBarRenderer.texture.isLoaded()){ - progressBarRenderer.addLoadedEventListener(function(){ + progressBarRenderer.addEventListener("load", function(){ self._findLayout(); self._updateChildrenDisplayedRGBA(); @@ -335,7 +335,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallNormalRenderer.texture || !this._slidBallNormalRenderer.texture.isLoaded()){ - this._slidBallNormalRenderer.addLoadedEventListener(function(){ + this._slidBallNormalRenderer.addEventListener("load", function(){ self._updateChildrenDisplayedRGBA(); }); } @@ -370,8 +370,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallPressedRenderer.texture || !this._slidBallPressedRenderer.texture.isLoaded()){ - this._slidBallPressedRenderer.addLoadedEventListener(function(){ - + this._slidBallPressedRenderer.addEventListener("load", function(){ self._updateChildrenDisplayedRGBA(); }); } @@ -406,8 +405,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallDisabledRenderer.texture || !this._slidBallDisabledRenderer.texture.isLoaded()){ - this._slidBallDisabledRenderer.addLoadedEventListener(function(){ - + this._slidBallDisabledRenderer.addEventListener("load", function(){ self._updateChildrenDisplayedRGBA(); }); } diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index ca16daea0c..7ea3065aa4 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -77,7 +77,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo var locRenderer = _self._labelBMFontRenderer; if(!locRenderer._textureLoaded){ - locRenderer.addLoadedEventListener(function(){ + locRenderer.addEventListener("load", function(){ _self.updateSizeAndPosition(); }); } diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 003ff3ea0b..f8d94003b7 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -84,7 +84,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ _spritesGenerated: false, _spriteFrameRotated: false, _textureLoaded:false, - _loadedEventListeners: null, _className:"Scale9Sprite", /** @@ -99,19 +98,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * add texture loaded event listener * @param {Function} callback * @param {Object} target + * @deprecated since 3.1, please use addEventListener instead */ addLoadedEventListener:function(callback, target){ - this._loadedEventListeners.push({eventCallback:callback, eventTarget:target}); - }, - - _callLoadedEventCallbacks:function(){ - this._textureLoaded = true; - var locListeners = this._loadedEventListeners; - for(var i = 0, len = locListeners.length; i < len; i++){ - var selCallback = locListeners[i]; - selCallback.eventCallback.call(selCallback.eventTarget, this); - } - locListeners.length = 0; + this.addEventListener("load", callback, target); }, _updateCapInset: function () { @@ -248,7 +238,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._originalSize = cc.size(0, 0); this._preferredSize = cc.size(0, 0); this._capInsets = cc.rect(0, 0, 0, 0); - this._loadedEventListeners = []; //cache if(cc._renderType === cc._RENDER_TYPE_CANVAS){ @@ -581,7 +570,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var locLoaded = texture.isLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - texture.addLoadedEventListener(function(sender){ + texture.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); @@ -589,7 +578,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); }, this); } @@ -614,14 +603,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var locLoaded = spriteFrame.textureLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - spriteFrame.addLoadedEventListener(function(sender){ + spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); },this); } var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); @@ -718,9 +707,9 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var locLoaded = tmpTexture.isLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - tmpTexture.addLoadedEventListener(function(sender){ + tmpTexture.addEventListener("load", function(sender){ this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); },this); return true; } @@ -1014,14 +1003,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var locLoaded = spriteFrame.textureLoaded(); this._textureLoaded = locLoaded; if(!locLoaded){ - spriteFrame.addLoadedEventListener(function(sender){ + spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; - this._callLoadedEventCallbacks(); + this.dispatchEvent("load"); },this); } this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0)); @@ -1035,6 +1024,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }); var _p = cc.Scale9Sprite.prototype; +cc.EventHelper.prototype.apply(_p); // Extended properties /** @expose */ From a65a644fcce8d566543e027bd8961b7d9036bcfa Mon Sep 17 00:00:00 2001 From: joshuastray Date: Tue, 14 Oct 2014 17:37:00 +0800 Subject: [PATCH 0785/1564] remove the useless _handleScissor which broke scissor clip --- extensions/ccui/layouts/UILayout.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 71b406501b..22917a2a99 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -55,7 +55,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _clippingRectDirty: true, _clippingType: null, _clippingStencil: null, - _handleScissor: false, _scissorRectDirty: false, _clippingRect: null, _clippingParent: null, @@ -1223,16 +1222,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _onBeforeVisitScissor: function(ctx){ var clippingRect = this._getClippingRect(); var gl = ctx || cc._renderContext; - if (this._handleScissor) { - gl.enable(gl.SCISSOR_TEST); - } + gl.enable(gl.SCISSOR_TEST); + cc.view.setScissorInPoints(clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height); }, _onAfterVisitScissor: function(ctx){ - if (this._handleScissor) { - gl.disable(gl.SCISSOR_TEST); - } + gl.disable(gl.SCISSOR_TEST); }, _updateBackGroundImageOpacity: function(){ From 4df5d7a0f20afc9db69f67af05461e923029d6bf Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 15 Oct 2014 14:16:19 +0800 Subject: [PATCH 0786/1564] issue #5849 : Return listener's reference for cc.eventManager.addListener() --- cocos2d/core/event-manager/CCEventManager.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 39ac6a8069..1f3d2dbf24 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -646,6 +646,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ * A lower priority will be called before the ones that have a higher value. 0 priority is forbidden for fixed priority since it's used for scene graph based priority. * The listener must be a cc.EventListener object when adding a fixed priority listener, because we can't remove a fixed priority listener without the listener handler, * except calls removeAllListeners(). + * @return {cc.EventListener} Return the listener. Needed in order to remove the event from the dispatcher. */ addListener: function (listener, nodeOrPriority) { cc.assert(listener && nodeOrPriority, cc._LogInfos.eventManager_addListener_2); @@ -679,6 +680,8 @@ cc.eventManager = /** @lends cc.eventManager# */{ listener._setRegistered(true); this._addListener(listener); } + + return listener; }, /** From 3617d437850eb6682bd85dd0dcdf547fb1a8c820 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Wed, 15 Oct 2014 14:20:09 +0800 Subject: [PATCH 0787/1564] issue #5979: add cocostudio file in build.xml --- tools/build.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/build.xml b/tools/build.xml index f80dce9688..2208ca2c2a 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.1-min.js"> @@ -235,6 +235,12 @@ + + + + + + @@ -246,7 +252,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.1-core-min.js"> From 725d3a226cf48d68d962436291cbab6e28ebf3e6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 15 Oct 2014 14:29:58 +0800 Subject: [PATCH 0788/1564] Fixed a bug of cc.view that it throws an error when html page doesn't add viewport meta --- cocos2d/core/platform/CCEGLView.js | 21 +++++---------------- cocos2d/labels/CCLabelBMFont.js | 2 -- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index d08bd03f02..1d93ba4aaf 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -229,7 +229,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ this.setDesignResolutionSize(designWidth, designHeight, this._resolutionPolicy); }, - _setViewPortMeta: function (width, height) { + _setViewPortMeta: function () { if (this._isAdjustViewPort) { var vp = document.getElementById("cocosMetaElement"); if(vp){ @@ -258,28 +258,17 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ content = currentVP ? currentVP.content : ""; for (var key in viewportMetas) { var pattern = new RegExp(key); - if (!pattern.test(content)) { content += "," + key + "=" + viewportMetas[key]; } } - if(!elems && content != ""){ + if(content != "") content = content.substr(1); - } - /* - if(width<=320){ - width = 321; - } - if(height) - content ="height="+height+","+content; - if(width) - content ="width="+width+","+content; - */ vp.content = content; // For adopting certain android devices which don't support second viewport - currentVP.content = content; - + if(currentVP) + currentVP.content = content; document.head.appendChild(vp); } }, @@ -532,7 +521,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ // Reinit frame size if (cc.sys.isMobile) - _t._setViewPortMeta(_t._frameSize.width, _t._frameSize.height); + _t._setViewPortMeta(); _t._initFrameSize(); _t._designResolutionSize = cc.size(width, height); _t._originalDesignResolutionSize = cc.size(width, height); diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 8b5ece7f91..0ca99ccc5d 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -201,7 +201,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } }, - //TODO /** * tint this label * @param {cc.Color} color @@ -920,7 +919,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this.updateLabel(); }, - //TODO /** * set fnt file path.
    * Change the fnt file path. From c0893c72ce8beb70690c8643b0951f2bd7f070a8 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Wed, 15 Oct 2014 14:55:20 +0800 Subject: [PATCH 0789/1564] issue #5979: add cocostudio file in jsdoc_toolkit/build.xml --- tools/jsdoc_toolkit/build.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/jsdoc_toolkit/build.xml b/tools/jsdoc_toolkit/build.xml index 5d84b167bd..e037685c34 100644 --- a/tools/jsdoc_toolkit/build.xml +++ b/tools/jsdoc_toolkit/build.xml @@ -193,8 +193,14 @@ + + + + + +
    From 79748cc858913b6412acf08883fd9ba0a0242bab Mon Sep 17 00:00:00 2001 From: Park Hyun Chen Date: Wed, 15 Oct 2014 16:39:58 +0900 Subject: [PATCH 0790/1564] Update UITextBMFont.js --- extensions/ccui/uiwidgets/UITextBMFont.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index ca16daea0c..141cca2c5b 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -191,7 +191,7 @@ var _p = ccui.TextBMFont.prototype; // Extended properties /** @expose */ _p.string; -cc.defineGetterSetter(_p, "string", _p.getString, _p.setStringValue); +cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); _p = null; @@ -213,4 +213,4 @@ ccui.TextBMFont.create = function (text, filename) { * @constant * @type {number} */ -ccui.TextBMFont.RENDERER_ZORDER = -1; \ No newline at end of file +ccui.TextBMFont.RENDERER_ZORDER = -1; From 565c6e72bd902980260cfc0b67b0fa0a2d7c0963 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 15 Oct 2014 16:59:16 +0800 Subject: [PATCH 0791/1564] move CC_Texture0 to be compatible with jsb --- cocos2d/shaders/CCGLProgram.js | 1 + cocos2d/shaders/CCShaders.js | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index cce2a218bd..9a035b94cc 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -92,6 +92,7 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ + "uniform vec4 CC_SinTime; \n" + "uniform vec4 CC_CosTime; \n" + "uniform vec4 CC_Random01; \n" + + "uniform sampler2D CC_Texture0; \n" + "//CC INCLUDES END \n" + source; this._glContext.shaderSource(shader, source); diff --git a/cocos2d/shaders/CCShaders.js b/cocos2d/shaders/CCShaders.js index a706a9ffe7..437ce589aa 100644 --- a/cocos2d/shaders/CCShaders.js +++ b/cocos2d/shaders/CCShaders.js @@ -125,7 +125,6 @@ cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT = cc.SHADER_POSITION_TEXTURE_FRAG = "precision lowp float; \n" + "varying vec2 v_texCoord; \n" - + "uniform sampler2D CC_Texture0; \n" + "void main() \n" + "{ \n" + " gl_FragColor = texture2D(CC_Texture0, v_texCoord); \n" @@ -155,7 +154,6 @@ cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG = "precision lowp float; \n" + "uniform vec4 u_color; \n" + "varying vec2 v_texCoord; \n" - + "uniform sampler2D CC_Texture0; \n" + "void main() \n" + "{ \n" + " gl_FragColor = texture2D(CC_Texture0, v_texCoord) * u_color; \n" @@ -185,7 +183,6 @@ cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG = "precision lowp float; \n" + "varying vec4 v_fragmentColor; \n" + "varying vec2 v_texCoord; \n" - + "uniform sampler2D CC_Texture0; \n" + "void main() \n" + "{ \n" + " gl_FragColor = vec4( v_fragmentColor.rgb, \n" // RGB from uniform @@ -220,7 +217,6 @@ cc.SHADER_POSITION_TEXTURE_COLOR_FRAG = "precision lowp float;\n" + "varying vec4 v_fragmentColor; \n" + "varying vec2 v_texCoord; \n" - + "uniform sampler2D CC_Texture0; \n" + "void main() \n" + "{ \n" + " gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n" @@ -253,7 +249,6 @@ cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG = "precision lowp float; \n" + "varying vec4 v_fragmentColor; \n" + "varying vec2 v_texCoord; \n" - + "uniform sampler2D CC_Texture0; \n" + "uniform float CC_alpha_value; \n" + "void main() \n" + "{ \n" From c9c45f434db8a512baa8028b8fa4a99b4fdf7b8e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 15 Oct 2014 21:28:32 +0800 Subject: [PATCH 0792/1564] Issue #5968: refactor canvas renderer for performance. --- cocos2d/core/renderer/RendererCanvas.js | 190 +++++++++++++----------- 1 file changed, 105 insertions(+), 85 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 2133cdd471..9ff4e53d93 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -30,6 +30,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _isCacheToCanvasOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds _cacheToCanvasCmds: [], // an array saves the renderer commands need for cache to other canvas + //contextSession: { globalAlpha:1 }, /** * drawing all renderer command to context (default is cc._renderContext) @@ -112,7 +113,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.TextureRenderCmdCanvas = function (node) { this._node = node; - this._textureCoord = { renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. @@ -131,9 +131,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var context = ctx || cc._renderContext, locTextureCoord = self._textureCoord; - if (!locTextureCoord.validRect) + if (!locTextureCoord.validRect && node._displayedOpacity === 0) return; //draw nothing + if(node._texture && !node._texture._isLoaded) //set texture but the texture isn't loaded. + return; + var t = node._transformWorld, locX = node._offsetPosition.x, locY = -node._offsetPosition.y - node._rect.height, @@ -142,13 +145,17 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { image, curColor; - var blendChange = (node._blendFuncStr !== "source"); + var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255); + /*if(cc.renderer.contextSession.globalAlpha !== alpha){ + cc.renderer.contextSession.globalAlpha = context.globalAlpha = alpha; //TODO + }*/ if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); + + context.globalAlpha = alpha; //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (blendChange) context.globalCompositeOperation = node._blendFuncStr; @@ -158,37 +165,33 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.scale(1, -1); if (node._texture) { - if (node._texture._isLoaded) { - context.globalAlpha = (node._displayedOpacity / 255); - image = node._texture._htmlElementObj; - - if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, + image = node._texture._htmlElementObj; + + //TODO should move '* scaleX/scaleY' to transforming + if (node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY - ); - } else { - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY - ); - } - + ); } - - } else if (!node._texture) { + } else { curColor = node._color; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; context.fillRect(locX, locY, locWidth, locHeight); @@ -200,41 +203,35 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.globalCompositeOperation = node._blendFuncStr; } + context.globalAlpha = alpha; if (node._texture) { - if (node._texture._isLoaded) { - - context.globalAlpha = (node._displayedOpacity / 255); - image = node._texture.getHtmlElementObj(); - if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, + image = node._texture.getHtmlElementObj(); + if (node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, (t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, locWidth * scaleX, locHeight * scaleY); - } else { - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, + } else { + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, (t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, locWidth * scaleX, locHeight * scaleY); - } } - } else if (!node._texture && node._displayedColor) { - - context.globalAlpha = (node._displayedOpacity / 255); + } else { curColor = node._displayedColor; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; context.fillRect(t.tx * scaleX + locX, -t.ty * scaleY + locY, locWidth, locHeight); - } if (blendChange) context.restore(); @@ -255,16 +252,27 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locWidth = node._contentSize.width, locHeight = node._contentSize.height; - context.save(); - if (node._blendFuncStr != "source") + if (opacity === 0) + return; + + var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); //TODO + var needRestore = (node._blendFuncStr !== "source") || needTransform; + + if (needRestore) { + context.save(); context.globalCompositeOperation = node._blendFuncStr; - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } + context.globalAlpha = opacity; context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," - + (0 | curColor.b) + "," + opacity + ")"; - context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); - - context.restore(); + + (0 | curColor.b) + ", 1)"; + if (needTransform) { + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); + } else { + context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); + } + if (needRestore) + context.restore(); cc.g_NumberOfDraws++; }; @@ -278,28 +286,40 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var context = ctx || cc._renderContext, self = this, node = self._node, + opacity = node._displayedOpacity / 255, t = node._transformWorld; - context.save(); - if (node._blendFuncStr != "source") - context.globalCompositeOperation = node._blendFuncStr; - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - var opacity = node._displayedOpacity / 255, - locWidth = node._contentSize.width, + if(opacity === 0) + return; + + var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); + var needRestore = (node._blendFuncStr !== "source") || needTransform; + if(needRestore){ + context.save(); + context.globalCompositeOperation = node._blendFuncStr; + } + context.globalAlpha = opacity; + var locWidth = node._contentSize.width, locHeight = node._contentSize.height; - //TODO need cache gradient object - var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); + + var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); //TODO need cached var locStartColor = node._displayedColor, locEndColor = node._endColor; gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," - + Math.round(locStartColor.b) + "," + (opacity * (locStartColor.a / 255)).toFixed(4) + ")"); + + Math.round(locStartColor.b) + "," + (locStartColor.a / 255).toFixed(4) + ")"); gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," - + Math.round(locEndColor.b) + "," + (locEndColor.a!=null?(opacity * (locEndColor.a / 255)).toFixed(4):255) + ")"); + + Math.round(locEndColor.b) + "," + (locEndColor.a != null ? (locEndColor.a / 255).toFixed(4) : 255) + ")"); context.fillStyle = gradient; - context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); - context.restore(); + if(needTransform){ + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); + } else { + context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); + } + + if(needRestore) + context.restore(); cc.g_NumberOfDraws++; }; @@ -312,6 +332,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { node = this._node, t = node._transformWorld, pointRect = node._pointRect; + context.save(); //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); @@ -320,7 +341,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { else context.globalCompositeOperation = 'source-over'; - var i, particle, lpx; + var i, particle, lpx, alpha; var particleCount = this._node.particleCount, particles = this._node._particles; if (cc.ParticleSystem.SHAPE_MODE == cc.ParticleSystem.TEXTURE_MODE) { // Delay drawing until the texture is fully loaded by the browser @@ -339,7 +360,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { particle = particles[i]; lpx = (0 | (particle.size * 0.5)); - context.globalAlpha = particle.color.a / 255; + alpha = particle.color.a / 255; + if(alpha === 0) continue; + context.globalAlpha = alpha; context.save(); context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); @@ -375,7 +398,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { for (i = 0; i < particleCount; i++) { particle = particles[i]; lpx = (0 | (particle.size * 0.5)); - context.globalAlpha = particle.color.a / 255; + alpha = particle.color.a / 255; + if(alpha === 0) continue; + context.globalAlpha = alpha; context.save(); context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); @@ -412,8 +437,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { node = this._node, locSprite = this._sprite; - var locTextureCoord = locSprite._rendererCmd._textureCoord; - if (!locSprite._texture || !locTextureCoord.validRect) + var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) return; var t = node._transformWorld; @@ -422,8 +447,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (locSprite._blendFuncStr != "source") context.globalCompositeOperation = locSprite._blendFuncStr; - - context.globalAlpha = locSprite._displayedOpacity / 255; + context.globalAlpha = alpha; var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; @@ -471,7 +495,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locDrawSizeCanvas.height ); - context.restore(); cc.g_NumberOfDraws++; }; @@ -487,9 +510,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var context = ctx || cc._renderContext, _t = this; if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) context.globalCompositeOperation = 'lighter'; - - for (var i = 0; i < _t._buffer.length; i++) { - var element = _t._buffer[i]; + var locBuffer = _t._buffer; + for (var i = 0, len = locBuffer.length; i < len; i++) { + var element = locBuffer[i]; switch (element.type) { case cc.DrawNode.TYPE_DOT: _t._drawDot(context, element, scaleX, scaleY); @@ -641,7 +664,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; var locCache = cc.ClippingNode._getSharedCache(); var context = ctx || cc._renderContext; @@ -685,8 +707,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //--- TMXLayer's render command --- cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { this._node = tmxLayer; - - this._transform = tmxLayer._transformWorld; this._childrenRenderCmds = []; }; @@ -709,7 +729,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locCacheContext.save(); locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); //reset the cache context - var t = cc.affineTransformInvert(this._transform); + var t = cc.affineTransformInvert(locNode._transformWorld); locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); for (var i = 0, len = locCacheCmds.length; i < len; i++) { @@ -729,7 +749,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var node = this._node; //context.globalAlpha = this._opacity / 255; var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); - var locCacheCanvas = node._cacheCanvas, t = this._transform; + var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; //direct draw image by canvas drawImage if (locCacheCanvas) { context.save(); From 8f23cf090f09b23a21c2cac1bd0bbbf2debe8798 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 15 Oct 2014 21:38:00 +0800 Subject: [PATCH 0793/1564] Issue #5983: translation C++ code --- CCBoot.js | 18 + cocos2d/core/platform/CCLoaders.js | 9 +- extensions/ccui/base-classes/UIWidget.js | 190 +- extensions/ccui/layouts/UILayout.js | 4 +- extensions/ccui/layouts/UILayoutComponent.js | 324 +++ extensions/ccui/system/UIHelper.js | 3 + extensions/ccui/uiwidgets/UIButton.js | 102 +- extensions/ccui/uiwidgets/UICheckBox.js | 3 + extensions/ccui/uiwidgets/UILoadingBar.js | 16 +- extensions/ccui/uiwidgets/UISlider.js | 10 +- extensions/ccui/uiwidgets/UIText.js | 1 + .../uiwidgets/scroll-widget/UIScrollView.js | 4 + extensions/cocostudio/reader/CSParseBinary.js | 599 +++++ extensions/cocostudio/reader/GUIReader.js | 244 ++ .../reader/timeline/ActionTimelineCache.js | 859 ++++++- .../cocostudio/reader/timeline/CSLoader.js | 2132 +++++++++++++++++ .../widgetreader/ButtonReader/ButtonReader.js | 460 +++- .../CheckBoxReader/CheckBoxReader.js | 359 ++- .../ImageViewReader/ImageViewReader.js | 200 +- .../LabelAtlasReader/LabelAtlasReader.js | 130 + .../LabelBMFontReader/LabelBMFontReader.js | 122 + .../widgetreader/LabelReader/LabelReader.js | 232 ++ .../widgetreader/LayoutReader/LayoutReader.js | 470 +++- .../ListViewReader/ListViewReader.js | 522 ++++ .../LoadingBarReader/LoadingBarReader.js | 177 +- .../PageViewReader/PageViewReader.js | 420 ++++ .../ScrollViewReader/ScrollViewReader.js | 477 ++++ .../widgetreader/SliderReader/SliderReader.js | 419 +++- .../TextFieldReader/TextFieldReader.js | 231 ++ .../reader/widgetreader/WidgetReader.js | 397 +++ external/protobuf/ByteBuffer.min.js | 85 + external/protobuf/Long.min.js | 21 + external/protobuf/ProtoBuf.min.js | 102 + moduleConfig.json | 8 +- 34 files changed, 9241 insertions(+), 109 deletions(-) create mode 100644 extensions/ccui/layouts/UILayoutComponent.js create mode 100644 extensions/cocostudio/reader/CSParseBinary.js create mode 100644 extensions/cocostudio/reader/timeline/CSLoader.js create mode 100644 external/protobuf/ByteBuffer.min.js create mode 100644 external/protobuf/Long.min.js create mode 100644 external/protobuf/ProtoBuf.min.js diff --git a/CCBoot.js b/CCBoot.js index 69cbe397e9..aab33a8ec1 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -703,6 +703,24 @@ cc.loader = /** @lends cc.loader# */{ } }, + loadCsb: function(url, cb){ + var xhr = new XMLHttpRequest(), + errInfo = "load " + url + " failed!"; + xhr.open("GET", url, true); + xhr.responseType = "arraybuffer"; + + xhr.onload = function () { + var arrayBuffer = xhr.response; // Note: not oReq.responseText + if (arrayBuffer) { + window.msg = arrayBuffer; + } + if(xhr.readyState == 4) + xhr.status == 200 ? cb(null, xhr.response) : cb(errInfo); + }; + + xhr.send(null); + }, + /** * Load a single resource as json. * @param {string} url diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index a941b39bbe..d051a80b42 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -125,4 +125,11 @@ cc._binaryLoader = { load : function(realUrl, url, res, cb){ cc.loader.loadBinary(realUrl, cb); } -}; \ No newline at end of file +}; + +cc._csbLoader = { + load: function(realUrl, url, res, cb){ + cc.loader.loadCsb(realUrl, cb); + } +}; +cc.loader.register(["csb"], cc._csbLoader); \ No newline at end of file diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 047af717a7..89b06f0e8b 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -89,6 +89,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _touchEventCallback: null, _propagateTouchEvents: true, + _unifySize: false, /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. @@ -139,6 +140,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ onEnter: function () { this.updateSizeAndPosition(); cc.ProtectedNode.prototype.onEnter.call(this); + //todo dolayout +// if (this._positionType == PositionType.PERCENT +// || this._sizeType == SizeType.PERCENT) { +// if (this._parent) { +// ccui.Helper.doLayout(this._parent); +// } +// } }, /** @@ -150,6 +158,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ cc.ProtectedNode.prototype.onExit.call(this); }, + getOrCreateLayoutComponent: function(){ + var layoutComponent = this.getComponent(__LAYOUT_COMPONENT_NAME); + if (null == layoutComponent){ + var component = ccui.LayoutComponent.create(); + this.addComponent(component); + layoutComponent = component; + } + return layoutComponent; + }, + /** * Calls _adaptRenderers(its subClass will override it) before calls its parent's visit. * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx @@ -174,6 +192,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _updateContentSizeWithTextureSize: function(size){ + if (this._unifySize) + { + this.setContentSize(size); + return; + } this.setContentSize(this._ignoreSize ? size : this._customSize); }, @@ -278,15 +301,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._customSize.width = locWidth; this._customSize.height = locHeight; - - if (this._ignoreSize) + if (this._unifySize){ + //unify Size logic + }else if (this._ignoreSize){ this._contentSize = this.getVirtualRendererSize(); - - if (this._running) { - var widgetParent = this.getWidgetParent(); - var pSize = widgetParent ? widgetParent.getContentSize() : this._parent.getContentSize(); - this._sizePercent.x = (pSize.width > 0.0) ? locWidth / pSize.width : 0.0; - this._sizePercent.y = (pSize.height > 0.0) ? locHeight / pSize.height : 0.0; } this._onSizeChanged(); }, @@ -323,26 +341,36 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Point} percent that is widget's percent size, width and height value from 0 to 1. */ setSizePercent: function (percent) { - this._sizePercent.x = percent.x; - this._sizePercent.y = percent.y; - var width = this._customSize.width, height = this._customSize.height; - if (this._running) { - var widgetParent = this.getWidgetParent(); - if (widgetParent) { - width = widgetParent.width * percent.x; - height = widgetParent.height * percent.y; - } else { - width = this._parent.width * percent.x; - height = this._parent.height * percent.y; - } - } - if (this._ignoreSize) - this.setContentSize(this.getVirtualRendererSize()); - else - this.setContentSize(width, height); - this._customSize.width = width; - this._customSize.height = height; + var component = this.getOrCreateLayoutComponent(); + component.setUsingPercentContentSize(true); + component.setPercentContentSize(percent); + +// if (null != this._parent) +// { +// ccui.Helper.prototype.doLayout.call(this, this._parent); +// } + +// this._sizePercent.x = percent.x; +// this._sizePercent.y = percent.y; +// var width = this._customSize.width, height = this._customSize.height; +// if (this._running) { +// var widgetParent = this.getWidgetParent(); +// if (widgetParent) { +// width = widgetParent.width * percent.x; +// height = widgetParent.height * percent.y; +// } else { +// width = this._parent.width * percent.x; +// height = this._parent.height * percent.y; +// } +// } +// if (this._ignoreSize) +// this.setContentSize(this.getVirtualRendererSize()); +// else +// this.setContentSize(width, height); +// +// this._customSize.width = width; +// this._customSize.height = height; }, _setWidthPercent: function (percent) { @@ -437,6 +465,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setSizeType: function (type) { this._sizeType = type; + var component = this.getOrCreateLayoutComponent(); + + if (this._sizeType == ccui.Widget.prototype.SizeType.PERCENT) + { + component.setUsingPercentContentSize(true); + } + else + { + component.setUsingPercentContentSize(false); + } }, /** @@ -452,7 +490,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} ignore true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ ignoreContentAdaptWithSize: function (ignore) { - if(this._ignoreSize == ignore) + if (this._unifySize){ + this.setContentSize(this._customSize); + return; + }else if(this._ignoreSize == ignore) return; this._ignoreSize = ignore; @@ -489,7 +530,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Point} */ getSizePercent: function () { - return cc.p(this._sizePercent); + var component = this.getOrCreateLayoutComponent(); + return component.getPercentContentSize(); }, _getWidthPercent: function () { return this._sizePercent.x; @@ -525,12 +567,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * call back function called when size changed. */ _onSizeChanged: function () { - var locChildren = this.getChildren(); - for (var i = 0, len = locChildren.length; i < len; i++) { - var child = locChildren[i]; - if(child instanceof ccui.Widget) - child.updateSizeAndPosition(); - } + ccui.Helper.prototype.doLayout.call(this, this); +// var locChildren = this.getChildren(); +// for (var i = 0, len = locChildren.length; i < len; i++) { +// var child = locChildren[i]; +// if(child instanceof ccui.Widget) +// child.updateSizeAndPosition(); +// } }, /** @@ -1018,26 +1061,27 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Number} [posY] */ setPosition: function (pos, posY) { - if (this._running) { - var widgetParent = this.getWidgetParent(); - if (widgetParent) { - var pSize = widgetParent.getContentSize(); - if (pSize.width <= 0 || pSize.height <= 0) { - this._positionPercent.x = 0; - this._positionPercent.y = 0; - } else { - if (posY == undefined) { - this._positionPercent.x = pos.x / pSize.width; - this._positionPercent.y = pos.y / pSize.height; - } else { - this._positionPercent.x = pos / pSize.width; - this._positionPercent.y = posY / pSize.height; - } - } - } - } +// if (this._running) { +// var widgetParent = this.getWidgetParent(); +// if (widgetParent) { +// var pSize = widgetParent.getContentSize(); +// if (pSize.width <= 0 || pSize.height <= 0) { +// this._positionPercent.x = 0; +// this._positionPercent.y = 0; +// } else { +// if (posY == undefined) { +// this._positionPercent.x = pos.x / pSize.width; +// this._positionPercent.y = pos.y / pSize.height; +// } else { +// this._positionPercent.x = pos / pSize.width; +// this._positionPercent.y = posY / pSize.height; +// } +// } +// } +// } cc.Node.prototype.setPosition.call(this, pos, posY); + this._positionType = PositionType.ABSOLUTE; }, setPositionX: function (x) { @@ -1074,14 +1118,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Point} percent */ setPositionPercent: function (percent) { - this._positionPercent = percent; - if (this._running) { - var widgetParent = this.getWidgetParent(); - if (widgetParent) { - var parentSize = widgetParent.getSize(); - this.setPosition(parentSize.width * this._positionPercent.x, parentSize.height * this._positionPercent.y); - } - } + this.setNormalizedPosition(percent); + this._positionType = PositionType.PERCENT; +// this._positionPercent = percent; +// if (this._running) { +// var widgetParent = this.getWidgetParent(); +// 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; @@ -1105,7 +1151,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Point} The percent (x,y) of the widget in OpenGL coordinates */ getPositionPercent: function () { - return cc.p(this._positionPercent); + return cc.p(this.getNormalizedPosition()); }, _getXPercent: function () { @@ -1121,6 +1167,18 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setPositionType: function (type) { this._positionType = type; + if (type == ccui.Widget.prototype.PositionType.ABSOLUTE) + { + var oldPosition = this.getPosition(); + this.setPosition(this.getPosition() + cc.p(10,0)); + this.setPosition(oldPosition); + } + else + { + var oldNormalizedPosition = this.getNormalizedPosition(); + this.setNormalizedPosition(oldNormalizedPosition + cc.p(0.2,0.1)); + this.setNormalizedPosition(oldNormalizedPosition); + } }, /** @@ -1572,6 +1630,14 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }else layout = layout._parent; } + }, + + isUnifySizeEnabled: function(){ + return this._unifySize; + }, + + setUnifySizeEnabled: function(enable){ + this._unifySize = enable; } }); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index bca09016e3..aef62e54ea 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -772,8 +772,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (!fileName) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; - if (this._backGroundImage == null) + if (this._backGroundImage == null){ this._addBackGroundImage(); + this._backGroundImage.setScale9Enabled(this._backGroundScale9Enabled); + } this._backGroundImageFileName = fileName; this._bgImageTexType = texType; var locBackgroundImage = this._backGroundImage; diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js new file mode 100644 index 0000000000..15d7966347 --- /dev/null +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -0,0 +1,324 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +var LayoutComponent_ReferencePoint = { + BOTTOM_LEFT: 0, + TOP_LEFT: 1, + BOTTOM_RIGHT: 2, + TOP_RIGHT: 3 +}; +var LayoutComponent_PositionType = { + Position: 0, + RelativePosition: 1, + PreRelativePosition: 2, + PreRelativePositionEnable: 3 +}; +var LayoutComponent_SizeType = { + Size: 0, + PreSize: 1, + PreSizeEnable: 2 +}; + +ccui.LayoutComponent = cc.Component.extend({ + + _percentContentSize: null, + _usingPercentContentSize: false, + + _referencePoint: LayoutComponent_ReferencePoint.BOTTOM_LEFT, + _relativePosition: null, + _percentPosition: null, + _usingPercentPosition: false, + _actived: true, + + + init: function(){ + var ret = true; + do + { + if (!cc.Component.prototype.init.call(this)) + { + ret = false; + break; + } + + //put layout component initalized code here + + } while (0); + return ret; + }, + + isUsingPercentPosition: function(){ + return this._usingPercentPosition; + }, + setUsingPercentPosition: function(flag){ + this._usingPercentPosition = flag; + this.RefreshLayoutPosition(LayoutComponent_PositionType.PreRelativePositionEnable, cc.p(0,0)); + }, + + getPercentPosition: function(){ + return this._percentPosition; + }, + setPercentPosition: function(percent){ + this.RefreshLayoutPosition(LayoutComponent_PositionType.PreRelativePosition, percent); + }, + + getRelativePosition: function(){ + return this._relativePosition; + }, + setRelativePosition: function(position){ + this.RefreshLayoutPosition(LayoutComponent_PositionType.RelativePosition, position); + }, + + setReferencePoint: function(point){ + this._referencePoint = point; + this.RefreshLayoutPosition(LayoutComponent_PositionType.RelativePosition, this._relativePosition) + }, + getReferencePoint: function(){ + return this._referencePoint; + }, + + getOwnerPosition: function(){ + return this.getOwner().getPosition(); + }, + setOwnerPosition: function(point){ + this.RefreshLayoutPosition(LayoutComponent_PositionType.Position, point); + }, + + RefreshLayoutPosition: function(pType, point){ + var parentNode = this.getOwner().getParent(); + var basePoint = point; + if (parentNode != null && this._actived) + { + var parentSize = parentNode.getContentSize(); + + if ( pType == LayoutComponent_PositionType.PreRelativePosition) + { + this._percentPosition = point; + basePoint = cc.p(_percentPosition.x*parentSize.width,_percentPosition.y*parentSize.height); + } + else if(pType == LayoutComponent_PositionType.PreRelativePositionEnable) + { + if (this._usingPercentPosition) + { + if (parentSize.width != 0) + { + _percentPosition.x = _relativePosition.x/parentSize.width; + } + else + { + _percentPosition.x = 0; + _relativePosition.x = 0; + } + + if (parentSize.height != 0) + { + _percentPosition.y = _relativePosition.y/parentSize.height; + } + else + { + _percentPosition.y = 0; + _relativePosition.y = 0; + } + } + basePoint = _relativePosition; + } + + var inversePoint = basePoint; + switch (this._referencePoint) + { + case LayoutComponent_ReferencePoint.TOP_LEFT: + inversePoint.y = parentSize.height - inversePoint.y; + break; + case LayoutComponent_ReferencePoint.BOTTOM_RIGHT: + inversePoint.x = parentSize.width - inversePoint.x; + break; + case LayoutComponent_ReferencePoint.TOP_RIGHT: + inversePoint.x = parentSize.width - inversePoint.x; + inversePoint.y = parentSize.height - inversePoint.y; + break; + default: + break; + } + + switch (pType) + { + case LayoutComponent_PositionType.Position: + this.getOwner().setPosition(basePoint); + this._relativePosition = inversePoint; + if (parentSize.width != 0 && parentSize.height != 0) + { + this._percentPosition = cc.p(this._relativePosition.x/parentSize.width,this._relativePosition.y/parentSize.height); + } + else + { + this._percentPosition = cc.p(0,0); + } + break; + case LayoutComponent_PositionType.RelativePosition: + this.getOwner().setPosition(inversePoint); + this._relativePosition = basePoint; + if (parentSize.width != 0 && parentSize.height != 0) + { + this._percentPosition = cc.p(this._relativePosition.x/parentSize.width,this._relativePosition.y/parentSize.height); + } + else + { + this._percentPosition = cc.p(0,0); + } + break; + case LayoutComponent_PositionType.PreRelativePosition: + this.getOwner().setPosition(inversePoint); + this._relativePosition = basePoint; + break; + case LayoutComponent_PositionType.PreRelativePositionEnable: + this.getOwner().setPosition(inversePoint); + this._relativePosition = basePoint; + break; + default: + break; + } + } + else + { + switch (pType) + { + case LayoutComponent_PositionType.Position: + this.getOwner().setPosition(basePoint); + if (this._referencePoint == LayoutComponent_ReferencePoint.BOTTOM_LEFT) + { + this._relativePosition = basePoint; + } + break; + case LayoutComponent_PositionType.RelativePosition: + this._relativePosition = basePoint; + break; + case LayoutComponent_PositionType.PreRelativePosition: + this._percentPosition = basePoint; + break; + default: + break; + } + } + }, + + getOwnerContentSize: function(){ + return this.getOwner().getContentSize(); + }, + setOwnerContentSize: function(percent){ + this.RefreshLayoutSize(LayoutComponent_SizeType.Size, percent); + }, + + getPercentContentSize: function(){ + return this._percentContentSize; + }, + setPercentContentSize: function(percent){ + this.RefreshLayoutSize(LayoutComponent_SizeType.PreSize, percent); + }, + + isUsingPercentContentSize: function(){ + return this._usingPercentContentSize; + }, + setUsingPercentContentSize: function(flag){ + this._usingPercentContentSize = flag; + this.RefreshLayoutSize(LayoutComponent_SizeType.PreSizeEnable, cc.p(0,0)); + }, + + RefreshLayoutSize: function(sType, size){ + var parentNode = this.getOwner().getParent(); + if (parentNode != null && this._actived) + { + var parentSize = parentNode.getContentSize(); + + switch (sType) + { + case LayoutComponent_SizeType.Size: + if (parentSize.width != 0 && parentSize.height != 0) + { + this._percentContentSize = cc.p(size.x/parentSize.width,size.y/parentSize.height); + } + else + { + this._percentContentSize = cc.p(0,0); + } + this.getOwner().setContentSize(cc.size(size.x,size.y)); + break; + case LayoutComponent_SizeType.PreSize: + cc.p_percentContentSize = size; + if (this._usingPercentContentSize) + { + this.getOwner().setContentSize(cc.size(size.x*parentSize.width,size.y*parentSize.height)); + } + break; + case LayoutComponent_SizeType.PreSizeEnable: + if (this._usingPercentContentSize) + { + var baseSize = this.getOwner().getContentSize(); + if (parentSize.width != 0) + { + this._percentContentSize.x = baseSize.width/parentSize.width; + } + else + { + this._percentContentSize.x = 0; + baseSize.width = 0; + } + + if (parentSize.height != 0) + { + this._percentContentSize.y = baseSize.height/parentSize.height; + } + else + { + this._percentContentSize.y = 0; + baseSize.height = 0; + } + + this.getOwner().setContentSize(baseSize); + } + break; + default: + break; + } + } + else + { + switch (sType) + { + case LayoutComponent_SizeType.Size: + this.getOwner().setContentSize(cc.size(size.x,size.y)); + break; + case LayoutComponent_SizeType.PreSize: + this._percentContentSize = size; + break; + default: + break; + } + } + }, + SetActiveEnable: function(enable){ + this._actived = enable; + } + +}); \ No newline at end of file diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 91cd9bd90f..73a5109681 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -23,6 +23,9 @@ THE SOFTWARE. ****************************************************************************/ +//todo maybe need change here + + /** * ccui.helper is the singleton object which is the Helper object contains some functions for seek widget * @class diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 6809634a56..8a9de8c394 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -200,6 +200,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @override */ ignoreContentAdaptWithSize: function (ignore) { + if(this._unifySize){ + if(this._scale9Enabled){ + ccui.ProtectedNode.prototype.setContentSize.call(this, this._customSize); + }else{ + var s = this.getVirtualRendererSize(); + ccui.ProtectedNode.prototype.setContentSize.call(this, s); + } + this.onSizeChanged(); + return; + } if (!this._scale9Enabled || (this._scale9Enabled && !ignore)) { ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, ignore); this._prevIgnoreSize = ignore; @@ -452,14 +462,32 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ setCapInsetsNormalRenderer: function (capInsets) { if(!capInsets) return; + var x = capInsets.origin.x; + var y = capInsets.origin.y; + var width = capInsets.size.width; + var height = capInsets.size.height; + + if (this._normalTextureSize.width < width) + { + x = 0; + width = 0; + } + if (this._normalTextureSize.height < height) + { + y = 0; + height = 0; + } + var rect = cc.rect(x, y, width, height); + var locInsets = this._capInsetsNormal; - locInsets.x = capInsets.x; - locInsets.y = capInsets.y; - locInsets.width = capInsets.width; - locInsets.height = capInsets.height; + locInsets.x = x; + locInsets.y = y; + locInsets.width = width; + locInsets.height = height; + if (!this._scale9Enabled) return; - this._buttonNormalRenderer.setCapInsets(capInsets); + this._buttonNormalRenderer.setCapInsets(rect); }, /** @@ -477,14 +505,32 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ setCapInsetsPressedRenderer: function (capInsets) { if(!capInsets) return; + + var x = capInsets.origin.x; + var y = capInsets.origin.y; + var width = capInsets.size.width; + var height = capInsets.size.height; + + if (this._normalTextureSize.width < width) + { + x = 0; + width = 0; + } + if (this._normalTextureSize.height < height) + { + y = 0; + height = 0; + } + var rect = cc.rect(x, y, width, height); + var locInsets = this._capInsetsPressed; - locInsets.x = capInsets.x; - locInsets.y = capInsets.y; - locInsets.width = capInsets.width; - locInsets.height = capInsets.height; + locInsets.x = x; + locInsets.y = y; + locInsets.width = width; + locInsets.height = height; if (!this._scale9Enabled) return; - this._buttonClickedRenderer.setCapInsets(capInsets); + this._buttonClickedRenderer.setCapInsets(rect); }, /** @@ -502,15 +548,33 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ setCapInsetsDisabledRenderer: function (capInsets) { if(!capInsets) return; + + var x = capInsets.origin.x; + var y = capInsets.origin.y; + var width = capInsets.size.width; + var height = capInsets.size.height; + + if (this._normalTextureSize.width < width) + { + x = 0; + width = 0; + } + if (this._normalTextureSize.height < height) + { + y = 0; + height = 0; + } + var rect = cc.rect(x, y, width, height); + var locInsets = this._capInsetsDisabled; - locInsets.x = capInsets.x; - locInsets.y = capInsets.y; - locInsets.width = capInsets.width; - locInsets.height = capInsets.height; + locInsets.x = x; + locInsets.y = y; + locInsets.width = width; + locInsets.height = height; if (!this._scale9Enabled) return; - this._buttonDisableRenderer.setCapInsets(capInsets); + this._buttonDisableRenderer.setCapInsets(rect); }, /** @@ -659,7 +723,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, _normalTextureScaleChangedWithSize: function () { - if (this._ignoreSize) { + if(this._unifySize){ + this._buttonNormalRenderer.setPreferredSize(this._contentSize); + }else if (this._ignoreSize) { if (!this._scale9Enabled) { this._buttonNormalRenderer.setScale(1.0); this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1; @@ -713,7 +779,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, _disabledTextureScaleChangedWithSize: function () { - if (this._ignoreSize) { + if(this._unifySize){ + this._buttonNormalRenderer.setPreferredSize(this._contentSize); + }else if (this._ignoreSize) { if (!this._scale9Enabled) this._buttonDisableRenderer.setScale(1.0); } else { diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 2d050fdc15..443e5c8b17 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -375,6 +375,9 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundSelectedBoxRenderer.setVisible(false); this._backGroundBoxDisabledRenderer.setVisible(false); this._frontCrossDisabledRenderer.setVisible(false); + if (this._isSelected){ + this._frontCrossRenderer.setVisible(true); + } }, _onPressStateChangedToPressed: function () { diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 9f991808d7..6868b65ed9 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -85,15 +85,13 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: this._barRenderer.setAnchorPoint(0.0, 0.5); - //todo check here old -> this._barRenderer.setPosition(-this._totalLength * 0.5, 0.0); - this._barRenderer.setPosition(0, 0); + this._barRenderer.setPosition(0, this._contentSize.height*0.5); if (!this._scale9Enabled) this._barRenderer.setFlippedX(false); break; case ccui.LoadingBar.TYPE_RIGHT: this._barRenderer.setAnchorPoint(1.0, 0.5); - //todo check here old -> this._barRenderer.setPosition(this._totalLength * 0.5, 0.0); - this._barRenderer.setPosition(0, 0); + this._barRenderer.setPosition(this._totalLength,this._contentSize.height*0.5); if (!this._scale9Enabled) this._barRenderer.setFlippedX(true); break; @@ -136,12 +134,12 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ case ccui.LoadingBar.TYPE_LEFT: barRenderer.setAnchorPoint(0.0,0.5); if (!self._scale9Enabled) - barRenderer.setFlippedX(false); + barRenderer.getSprite().setFlippedX(false); break; case ccui.LoadingBar.TYPE_RIGHT: barRenderer.setAnchorPoint(1.0,0.5); if (!self._scale9Enabled) - barRenderer.setFlippedX(true); + barRenderer.getSprite().setFlippedX(true); break; } self._updateChildrenDisplayedRGBA(); @@ -342,7 +340,11 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _barRendererScaleChangedWithSize: function () { var locBarRender = this._barRenderer, locContentSize = this._contentSize; - if (this._ignoreSize) { + if(this._unifySize){ + //_barRenderer->setPreferredSize(_contentSize); + this._totalLength = this._contentSize.width; + this.setPercent(this._percent); + }else if (this._ignoreSize) { if (!this._scale9Enabled) { this._totalLength = this._barRendererTextureSize.width; locBarRender.setScale(1.0); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index ed19abaf20..2080735dcc 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -579,7 +579,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _barRendererScaleChangedWithSize: function () { - if (this._ignoreSize) { + if(this._unifySize){ + this._barLength = this._contentSize.width; + this._barRenderer.setPreferredSize(this._contentSize); + }else if (this._ignoreSize) { this._barRenderer.setScale(1.0); this._barLength = this._contentSize.width; } @@ -605,7 +608,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _progressBarRendererScaleChangedWithSize: function () { - if (this._ignoreSize) { + if(this._unifySize){ + this._barLength = this._contentSize.width; + this._barRenderer.setPreferredSize(this._contentSize); + }else if (this._ignoreSize) { if (!this._scale9Enabled) { var ptextureSize = this._progressBarTextureSize; var pscaleX = this._contentSize.width / ptextureSize.width; diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 36142e8fd8..8d5a49629e 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -337,6 +337,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ _labelScaleChangedWithSize: function () { var locContentSize = this._contentSize; if (this._ignoreSize) { + this._labelRenderer.setDimensions(0,0); this._labelRenderer.setScale(1.0); this._normalScaleValueX = this._normalScaleValueY = 1; } else { diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index bbad9c2193..b2919ed555 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -142,6 +142,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _initRenderer: function () { ccui.Layout.prototype._initRenderer.call(this); this._innerContainer = ccui.Layout.create(); + this._innerContainer.setColor(cc.color(255,255,255)); + this._innerContainer.setOpacity(255); + this._innerContainer.setCascadeColorEnabled(true); + this._innerContainer.setCascadeOpacityEnabled(true); this.addProtectedChild(this._innerContainer, 1, 1); }, diff --git a/extensions/cocostudio/reader/CSParseBinary.js b/extensions/cocostudio/reader/CSParseBinary.js new file mode 100644 index 0000000000..5b7f829e82 --- /dev/null +++ b/extensions/cocostudio/reader/CSParseBinary.js @@ -0,0 +1,599 @@ +var CSParseBinary = "\n\ +package protocolbuffers;\n\ +\n\ +option optimize_for = LITE_RUNTIME; \n\ +\n\ +message CSParseBinary\n\ +{\n\ + optional string version = 1; \n\ + optional string cocos2dVersion = 2;\n\ + optional string editorType = 3;\n\ + optional float dataScale = 4;\n\ + optional int32 designHeight = 5;\n\ + optional int32 designWidth = 6; \n\ + repeated string textures = 7;\n\ + repeated string texturesPng = 8;\n\ + optional NodeTree nodeTree = 9;\n\ + optional NodeAction action = 10;\n\ +}\n\ +\n\ +\n\ +// nodeTree\n\ +message NodeTree\n\ +{\n\ + optional string classname = 1;\n\ + optional string name = 2;\n\ +\n\ + repeated NodeTree children = 3;\n\ +\n\ + optional WidgetOptions widgetOptions = 4;\n\ + optional ButtonOptions buttonOptions = 5;\n\ + optional CheckBoxOptions checkBoxOptions = 6;\n\ + optional ImageViewOptions imageViewOptions = 7;\n\ + \n\ + optional TextAtlasOptions textAtlasOptions = 8;\n\ + optional TextBMFontOptions textBMFontOptions = 9;\n\ + optional TextOptions textOptions = 10;\n\ + optional LoadingBarOptions loadingBarOptions = 11;\n\ + optional SliderOptions sliderOptions = 12;\n\ + optional TextFieldOptions textFieldOptions = 13;\n\ + optional ScrollViewOptions scrollViewOptions = 14;\n\ + optional PageViewOptions pageViewOptions = 15;\n\ + optional ListViewOptions listViewOptions = 16;\n\ + optional PanelOptions PanelOptions = 17;\n\ +\n\ + optional SpriteOptions spriteOptions = 18;\n\ + optional TMXTiledMapOptions tmxTiledMapOptions = 19;\n\ + optional ParticleSystemOptions particleSystemOptions = 20;\n\ + optional ProjectNodeOptions projectNodeOptions = 21;\n\ +}\n\ +\n\ +\n\ +// WidgetOptions\n\ +message WidgetOptions\n\ +{\n\ + optional float x = 1;\n\ + optional float y = 2;\n\ + optional float scaleX = 3;\n\ + optional float scaleY = 4;\n\ + optional float rotation = 5;\n\ + optional bool flipX = 6;\n\ + optional bool flipY = 7;\n\ + optional int32 colorB = 8;\n\ + optional int32 colorG = 9;\n\ + optional int32 colorR = 10;\n\ + optional int32 opacity = 11;\n\ + optional bool touchAble = 12;\n\ + optional bool visible = 13;\n\ + optional int32 zorder = 14;\n\ + optional string classType = 15;\n\ + optional float width = 16;\n\ + optional float height = 17;\n\ + optional int32 positionType = 18;\n\ + optional float positionPercentX = 19;\n\ + optional float positionPercentY = 20;\n\ + optional int32 sizeType = 21;\n\ + optional float sizePercentX = 22;\n\ + optional float sizePercentY = 23;\n\ + optional bool useMergedTexture = 24;\n\ + optional int32 actionTag = 25;\n\ + optional int32 tag = 26;\n\ + optional float anchorPointX = 27;\n\ + optional float anchorPointY = 28;\n\ + optional bool ignoreSize = 29;\n\ + optional float rotationSkewX = 30;\n\ + optional float rotationSkewY = 31;\n\ + optional LayoutParameter layoutParameter = 32;\n\ + optional string customProperty = 33;\n\ + optional string frameEvent = 34; \n\ + optional string name = 35;\n\ + optional int32 Alpha = 37;\n\ + repeated ComponentOptions componentOptions = 36;\n\ +}\n\ +\n\ +// LayoutParameter\n\ +message LayoutParameter\n\ +{\n\ + optional int32 type = 1;\n\ + optional int32 gravity = 2;\n\ + optional string relativeName = 3;\n\ + optional string relativeToName = 4;\n\ + optional int32 align = 5;\n\ + optional int32 marginLeft = 6;\n\ + optional int32 marginTop = 7;\n\ + optional int32 marginRight = 8;\n\ + optional int32 marginDown = 9;\n\ + optional int32 layoutEageType = 10;\n\ + optional int32 layoutNormalHorizontal = 11;\n\ + optional int32 layoutNormalVertical = 12;\n\ + optional int32 layoutParentHorizontal = 13;\n\ + optional int32 layoutParentVertical = 14;\n\ +}\n\ +\n\ +// ButtonOptions\n\ +message ButtonOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string normal = 3;\n\ + optional string pressed = 4;\n\ + optional string disabled = 5;\n\ + optional ResourceData normalData = 6;\n\ + optional ResourceData pressedData = 7;\n\ + optional ResourceData disabledData = 8;\n\ + optional string text = 9;\n\ + optional string fontName = 10;\n\ + optional int32 fontSize = 11;\n\ + optional int32 textColorR = 12;\n\ + optional int32 textColorG = 13;\n\ + optional int32 textColorB = 14;\n\ + optional float capInsetsX = 15;\n\ + optional float capInsetsY = 16;\n\ + optional float capInsetsWidth = 17;\n\ + optional float capInsetsHeight = 18;\n\ + optional float scale9Width = 19;\n\ + optional float scale9Height = 20;\n\ + optional bool scale9Enable = 21; \n\ + optional bool displaystate = 22;\n\ + optional ResourceData fontResource = 23;\n\ +}\n\ +\n\ +message ResourceData\n\ +{\n\ + optional string path = 1;\n\ + optional string plistFile = 2;\n\ + optional int32 resourceType = 3;\n\ +}\n\ +\n\ +// CheckBoxOptions\n\ +message CheckBoxOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string backGroundBox = 3;\n\ + optional string backGroundBoxSelected = 4;\n\ + optional string backGroundBoxDisabled = 5;\n\ + optional string frontCross = 6;\n\ + optional string frontCrossDisabled = 7;\n\ + optional ResourceData backGroundBoxData = 8;\n\ + optional ResourceData backGroundBoxSelectedData = 9;\n\ + optional ResourceData frontCrossData = 10;\n\ + optional ResourceData backGroundBoxDisabledData = 11;\n\ + optional ResourceData frontCrossDisabledData = 12;\n\ + optional bool selectedState = 13;\n\ + optional bool displaystate = 14;\n\ +}\n\ +\n\ +// ImageOptions\n\ +message ImageViewOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string fileName = 3;\n\ + optional ResourceData fileNameData = 4;\n\ + optional float capInsetsX = 5;\n\ + optional float capInsetsY = 6;\n\ + optional float capInsetsHeight = 7;\n\ + optional float capInsetsWidth = 8;\n\ + optional float scale9Width = 9;\n\ + optional float scale9Height = 10;\n\ + optional bool scale9Enable = 11;\n\ + optional bool flippedX = 12;\n\ + optional bool flippedY = 13;\n\ +}\n\ +\n\ +// TextAtlasOptions\n\ +message TextAtlasOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string stringValue = 3;\n\ + optional string charMapFile = 4;\n\ + optional ResourceData charMapFileData = 5;\n\ + optional string startCharMap = 6;\n\ + optional int32 itemWidth = 7;\n\ + optional int32 itemHeight = 8;\n\ +}\n\ +\n\ +// TextBMFontOptions\n\ +message TextBMFontOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string text = 3;\n\ + optional ResourceData fileNameData = 4;\n\ +}\n\ +\n\ +// TextOptions\n\ +message TextOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string fontName = 3;\n\ + optional ResourceData fontFile = 4;\n\ + optional int32 fontSize = 5;\n\ + optional string text = 6;\n\ + optional float areaWidth = 7;\n\ + optional float areaHeight = 8;\n\ + optional int32 hAlignment = 9;\n\ + optional int32 vAlignment = 10;\n\ + optional bool touchScaleEnable = 11;\n\ + optional ResourceData fontResource = 12;\n\ + optional bool IsCustomSize = 13;\n\ +}\n\ +\n\ +// LoadingBarOptions\n\ +message LoadingBarOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string texture = 3;\n\ + optional ResourceData textureData = 4;\n\ + optional int32 percent = 5;\n\ + optional int32 direction = 6;\n\ + optional float capInsetsX = 7;\n\ + optional float capInsetsY = 8;\n\ + optional float capInsetsWidth = 9;\n\ + optional float capInsetsHeight = 10;\n\ + optional bool scale9Enable = 11;\n\ + optional float scale9Width = 12;\n\ + optional float scale9Height = 13;\n\ +}\n\ +\n\ +// ListViewOptions\n\ +message ListViewOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string backGroundImage = 3;\n\ + optional ResourceData backGroundImageData = 4;\n\ + optional int32 bgColorR = 5;\n\ + optional int32 bgColorG = 6;\n\ + optional int32 bgColorB = 7;\n\ + optional int32 bgStartColorR = 8;\n\ + optional int32 bgStartColorG = 9;\n\ + optional int32 bgStartColorB = 10;\n\ + optional int32 bgEndColorR = 11;\n\ + optional int32 bgEndColorG = 12;\n\ + optional int32 bgEndColorB = 13;\n\ + optional int32 colorType = 14;\n\ + optional int32 bgColorOpacity = 15;\n\ + optional float vectorX = 16;\n\ + optional float vectorY = 17;\n\ + optional float capInsetsX = 18;\n\ + optional float capInsetsY = 19;\n\ + optional float capInsetsWidth = 20;\n\ + optional float capInsetsHeight = 21;\n\ + optional bool backGroundScale9Enable = 22;\n\ + optional float innerWidth = 23;\n\ + optional float innerHeight = 24;\n\ + optional bool clipAble = 25;\n\ + optional bool bounceEnable = 26;\n\ + optional int32 direction = 27;\n\ + optional int32 gravity = 28;\n\ + optional int32 itemMargin = 29;\n\ + optional float scale9Width = 30;\n\ + optional float scale9Height = 31;\n\ +}\n\ +\n\ +// PageViewOptions\n\ +message PageViewOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string backGroundImage = 3;\n\ + optional ResourceData backGroundImageData = 4;\n\ + optional bool clipAble = 5;\n\ + optional int32 bgColorR = 6;\n\ + optional int32 bgColorG = 7;\n\ + optional int32 bgColorB = 8;\n\ + optional int32 bgStartColorR = 9;\n\ + optional int32 bgStartColorG = 10;\n\ + optional int32 bgStartColorB = 11;\n\ + optional int32 bgEndColorR = 12;\n\ + optional int32 bgEndColorG = 13;\n\ + optional int32 bgEndColorB = 14;\n\ + optional int32 colorType = 15;\n\ + optional int32 bgColorOpacity = 16;\n\ + optional float vectorX = 17;\n\ + optional float vectorY = 18;\n\ + optional float capInsetsX = 19;\n\ + optional float capInsetsY = 20;\n\ + optional float capInsetsWidth = 21;\n\ + optional float capInsetsHeight = 22;\n\ + optional bool backGroundScale9Enable = 23;\n\ + optional float scale9Width = 24;\n\ + optional float scale9Height = 25;\n\ +}\n\ +\n\ +// PanelOptions\n\ +message PanelOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string backGroundImage = 3;\n\ + optional ResourceData backGroundImageData = 4;\n\ + optional bool clipAble = 5;\n\ + optional int32 bgColorR = 6;\n\ + optional int32 bgColorG = 7;\n\ + optional int32 bgColorB = 8;\n\ + optional int32 bgStartColorR = 9;\n\ + optional int32 bgStartColorG = 10;\n\ + optional int32 bgStartColorB = 11;\n\ + optional int32 bgEndColorR = 12;\n\ + optional int32 bgEndColorG = 13;\n\ + optional int32 bgEndColorB = 14;\n\ + optional int32 colorType = 15;\n\ + optional int32 bgColorOpacity = 16;\n\ + optional float vectorX = 17;\n\ + optional float vectorY = 18;\n\ + optional float capInsetsX = 19;\n\ + optional float capInsetsY = 20;\n\ + optional float capInsetsWidth = 21;\n\ + optional float capInsetsHeight = 22;\n\ + optional bool backGroundScale9Enable = 23;\n\ + optional int32 layoutType = 24;\n\ + optional bool adaptScreen = 25;\n\ + optional float scale9Width = 26;\n\ + optional float scale9Height = 27;\n\ +}\n\ +\n\ +// ScrollViewOptions\n\ +message ScrollViewOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string backGroundImage = 3;\n\ + optional ResourceData backGroundImageData = 4;\n\ + optional int32 bgColorR = 5;\n\ + optional int32 bgColorG = 6;\n\ + optional int32 bgColorB = 7;\n\ + optional int32 bgStartColorR = 8;\n\ + optional int32 bgStartColorG = 9;\n\ + optional int32 bgStartColorB = 10;\n\ + optional int32 bgEndColorR = 11;\n\ + optional int32 bgEndColorG = 12;\n\ + optional int32 bgEndColorB = 13;\n\ + optional int32 colorType = 14;\n\ + optional int32 bgColorOpacity = 15;\n\ + optional float vectorX = 16;\n\ + optional float vectorY = 17;\n\ + optional float capInsetsX = 18;\n\ + optional float capInsetsY = 19;\n\ + optional float capInsetsWidth = 20;\n\ + optional float capInsetsHeight = 21;\n\ + optional bool backGroundScale9Enable = 22;\n\ + optional float innerWidth = 23;\n\ + optional float innerHeight = 24;\n\ + optional int32 direction = 25;\n\ + optional bool clipAble = 26;\n\ + optional bool bounceEnable = 27;\n\ + optional int32 layoutType = 28;\n\ + optional float scale9Width = 29;\n\ + optional float scale9Height = 30;\n\ +}\n\ +\n\ +// SliderOptions\n\ +message SliderOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string barFileName = 3;\n\ + optional string ballNormal = 4;\n\ + optional string ballPressed = 5;\n\ + optional string ballDisabled = 6;\n\ + optional ResourceData barFileNameData = 7;\n\ + optional ResourceData ballNormalData = 8;\n\ + optional ResourceData ballPressedData = 9;\n\ + optional ResourceData ballDisabledData = 10;\n\ + optional ResourceData progressBarData = 11;\n\ + optional int32 percent = 12;\n\ + optional float capInsetsX = 13;\n\ + optional float capInsetsY = 14;\n\ + optional float capInsetsWidth = 15;\n\ + optional float capInsetsHeight = 16;\n\ + optional float barCapInsetsX = 17;\n\ + optional float barCapInsetsY = 18;\n\ + optional float barCapInsetsWidth = 19;\n\ + optional float barCapInsetsHeight = 20;\n\ + optional float progressBarCapInsetsX = 21;\n\ + optional float progressBarCapInsetsY = 22;\n\ + optional float progressBarCapInsetsWidth = 23;\n\ + optional float progressBarCapInsetsHeight = 24;\n\ + optional float scale9Width = 25;\n\ + optional float scale9Height = 26;\n\ + optional bool scale9Enable = 27;\n\ + optional float slidBallAnchorPointX = 28;\n\ + optional float slidBallAnchorPointY = 29;\n\ + optional float length = 30;\n\ + optional bool displaystate = 31;\n\ +}\n\ +\n\ +// SpriteOptions\n\ +message SpriteOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional bool touchAble = 3;\n\ + optional int32 positionType = 4;\n\ + optional float positionPercentX = 5;\n\ + optional float positionPercentY = 6;\n\ + optional int32 sizeType = 7;\n\ + optional float sizePercentX = 8;\n\ + optional float sizePercentY = 9;\n\ + optional bool useMergedTexture = 10;\n\ + optional bool ignoreSize = 11;\n\ + optional LayoutParameter layoutParameter = 12;\n\ + optional string customProperty = 13;\n\ + optional string fileName = 14;\n\ + optional bool flippedX = 15;\n\ + optional bool flippedY = 16;\n\ + \n\ + optional ResourceData fileNameData = 17;\n\ +}\n\ +\n\ +// TextFieldOptions\n\ +message TextFieldOptions\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string fontName = 3;\n\ + optional ResourceData fontFile = 4;\n\ + optional int32 fontSize = 5;\n\ + optional string text = 6;\n\ + optional string placeHolder = 7;\n\ + optional bool passwordEnable = 8;\n\ + optional string passwordStyleText = 9;\n\ + optional bool maxLengthEnable = 10;\n\ + optional int32 maxLength = 11;\n\ + optional float areaWidth = 12;\n\ + optional float areaHeight = 13;\n\ + optional float anchorPointX = 15;\n\ + optional float anchorPointY = 16;\n\ + optional ResourceData fontResource = 14;\n\ + optional bool IsCustomSize = 17;\n\ +}\n\ +\n\ +// TMXTiledMapOptions\n\ +message TMXTiledMapOptions\n\ +{\n\ + optional string tmxFile = 1;\n\ + optional string tmxString = 2;\n\ + optional string resourcePath = 3;\n\ +\n\ + optional ResourceData fileNameData = 4;\n\ +}\n\ +\n\ +// ParticleSystemOptions\n\ +message ParticleSystemOptions\n\ +{\n\ + optional string plistFile = 1;\n\ + optional int32 totalParticles = 2; \n\ +\n\ + optional ResourceData fileNameData = 3;\n\ +}\n\ +\n\ +// ProjectNodeOptions\n\ +message ProjectNodeOptions\n\ +{\n\ + optional string fileName = 1;\n\ +}\n\ +\n\ +// ComponentOptions\n\ +message ComponentOptions\n\ +{\n\ + optional string type = 1;\n\ +\n\ + optional ComAudioOptions comAudioOptions = 2;\n\ +}\n\ +\n\ +// ComAudioOptions\n\ +message ComAudioOptions\n\ +{\n\ + optional string name = 1;\n\ + optional bool enabled = 2;\n\ + optional bool loop = 3;\n\ + optional int32 volume = 4;\n\ + optional ResourceData fileNameData = 5;\n\ +}\n\ +\n\ +\n\ +// action\n\ +message NodeAction\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional int32 duration = 3;\n\ + optional float speed = 4;\n\ +\n\ + repeated TimeLine timelines = 5;\n\ +}\n\ +\n\ +// Timeline\n\ +message TimeLine\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional string frameType = 3;\n\ + optional int32 actionTag = 4;\n\ + repeated Frame frames = 5;\n\ +}\n\ +\n\ +//Frames\n\ +message Frame\n\ +{\n\ + optional TimeLineBoolFrame visibleFrame = 5;\n\ + optional TimeLineIntFrame zOrderFrame = 6;\n\ + optional TimeLinePointFrame rotationSkewFrame = 7;\n\ + optional TimeLineStringFrame eventFrame = 8;\n\ + optional TimeLinePointFrame anchorPointFrame = 9;\n\ + optional TimeLinePointFrame positionFrame = 10;\n\ + optional TimeLinePointFrame scaleFrame = 11;\n\ + optional TimeLineColorFrame colorFrame = 12;\n\ + optional TimeLineTextureFrame textureFrame = 13;\n\ +}\n\ +\n\ +//VisibleFrame\n\ +message TimeLineBoolFrame\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional int32 frameIndex = 3;\n\ + optional bool tween = 4;\n\ + optional bool value = 5;\n\ +}\n\ +\n\ +//ZOrderFrame RotationFrame\n\ +message TimeLineIntFrame\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional int32 frameIndex = 3;\n\ + optional bool tween = 4;\n\ + optional int32 value = 5;\n\ +}\n\ +\n\ +//EventFrame\n\ +message TimeLineStringFrame\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional int32 frameIndex = 3;\n\ + optional bool tween = 4;\n\ + optional string value = 5;\n\ +}\n\ +\n\ +//AnchorPointFrame PositionFrame ScaleFrame\n\ +message TimeLinePointFrame\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional int32 frameIndex = 3;\n\ + optional bool tween = 4;\n\ + optional float x = 5;\n\ + optional float y = 6;\n\ +}\n\ +\n\ +//ColorFrame\n\ +message TimeLineColorFrame\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional int32 frameIndex = 3;\n\ + optional bool tween = 4;\n\ + optional int32 alpha = 5;\n\ + optional int32 red = 6;\n\ + optional int32 green = 7;\n\ + optional int32 blue = 8;\n\ +}\n\ +\n\ +//TextureFrame\n\ +message TimeLineTextureFrame\n\ +{\n\ + optional string name = 1;\n\ + optional string classname = 2;\n\ + optional int32 frameIndex = 3;\n\ + optional bool tween = 4;\n\ + optional string filePath = 5;\n\ + optional string plistFile = 6;\n\ +}"; \ No newline at end of file diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 2661c71ce4..9a9fbeb7f1 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -22,6 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +var PBP; +if(CSParseBinary && dcodeIO && dcodeIO.ProtoBuf){ + PBP = dcodeIO.ProtoBuf.loadProto(CSParseBinary).build().protocolbuffers; +}else{ + PBP = null; +} (function(){ var factoryCreate = ccs.objectFactory; @@ -211,7 +217,245 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ */ getParseCallBackMap: function(){ return this._mapParseSelector; + }, + + widgetFromProtocolBuffers: function(url){ + + + var classname = nodetree.classname(); + cc.log("classname = %s", classname); + + var widget = this.createGUI(classname); + var readerName = this.getWidgetReaderClassName(classname); + + var reader = this.createWidgetReaderProtocol(readerName); + + if (reader) + { + // widget parse with widget reader + this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); + } + else + { + // + // 1st., custom widget parse properties of parent widget with parent widget reader + readerName = this.getWidgetReaderClassName(widget); + reader = this.createWidgetReaderProtocol(readerName); + if (reader && widget) + { + this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); + + // 2nd., custom widget parse with custom reader + var widgetOptions = nodetree.widgetoptions(); + var customProperty = widgetOptions.customproperty(); + var customJsonDict; + customJsonDict.Parse(customProperty); + if (customJsonDict.HasParseError()) + { + cc.log("GetParseError %s\n", customJsonDict.GetParseError()); + } + this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); + } + else + { + cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); + } + // + } + + var size = nodetree.children_size(); + cc.log("widget children size = %d", size); + for (var i = 0; i < size; ++i) + { + var subNodeTree = nodetree.children(i); + var child = this.widgetFromProtocolBuffers(subNodeTree); + cc.log("widget child = %p", child); + if (child) + { + var pageView = widget; + if (pageView instanceof ccui.PageView) + { + pageView.addPage(child); + } + else + { + var listView = widget; + if (listView instanceof ccui.ListView) + { + listView.pushBackCustomItem(child); + } + else + { + widget.addChild(child); + } + } + } + } + + cc.log("widget = %p", widget); + + return widget; + }, + + setPropsForAllWidgetFromProtocolBuffers: function(reader, widget, nodetree){ + reader.setPropsFromProtocolBuffers(widget, nodetree); + }, + + widgetFromXML: function(objectData, classType){ + var classname = classType.substr(0, classType.find("ObjectData")); + cc.log("classname = %s", classname); + + var widget = this.createGUI(classname); + var readerName = this.getWidgetReaderClassName(classname); + + var reader = this.createWidgetReaderProtocol(readerName); + + if (reader) + { + // widget parse with widget reader + this.setPropsForAllWidgetFromXML(reader, widget, objectData); + } + else + { + // + // 1st., custom widget parse properties of parent widget with parent widget reader + readerName = this.getWidgetReaderClassName(widget); + reader = this.createWidgetReaderProtocol(readerName); + if (reader && widget) + { + this.setPropsForAllWidgetFromXML(reader, widget, objectData); + + // 2nd., custom widget parse with custom reader + // const protocolbuffers::WidgetOptions& widgetOptions = nodetree.widgetoptions(); + // const char* customProperty = widgetOptions.customproperty().c_str(); + var customProperty = ""; + var customJsonDict; + customJsonDict.Parse(customProperty); + if (customJsonDict.HasParseError()) + { + cc.log("GetParseError %s\n", customJsonDict.GetParseError()); + } + this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); + } + else + { + cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); + } + // + } + + + + + + // children + var containChildrenElement = false; + objectData = objectData.FirstChildElement(); + + while (objectData) + { + cc.log("objectData name = %s", objectData.Name()); + + if ("Children" !== objectData.Name()) + { + containChildrenElement = true; + break; + } + + objectData = objectData.NextSiblingElement(); + } + + if (containChildrenElement) + { + objectData = objectData.FirstChildElement(); + cc.log("objectData name = %s", objectData.Name()); + + while (objectData) + { + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ctype") + { + var child = this.widgetFromXML(objectData, value); + cc.log("child = %p", child); + if (child) + { + var pageView = widget; + var listView = widget; + if (pageView instanceof ccui.PageView) + { + var layout = child; + if (layout instanceof ccui.Layout) + { + pageView.addPage(layout); + } + } + else if (listView) + { + var widgetChild = child; + if (widgetChild instanceof ccui.Widget) + { + listView.pushBackCustomItem(widgetChild); + } + } + else + { + widget.addChild(child); + } + } + + break; + } + + attribute = attribute.Next(); + } + + // Node* child = nodeFromXML(objectData, value); + // CCLOG("child = %p", child); + // if (child) + // { + // PageView* pageView = dynamic_cast(node); + // ListView* listView = dynamic_cast(node); + // if (pageView) + // { + // Layout* layout = dynamic_cast(child); + // if (layout) + // { + // pageView.addPage(layout); + // } + // } + // else if (listView) + // { + // Widget* widget = dynamic_cast(child); + // if (widget) + // { + // listView.pushBackCustomItem(widget); + // } + // } + // else + // { + // node.addChild(child); + // } + // } + + objectData = objectData.NextSiblingElement(); + } + } + // + + cc.log("widget = %p", widget); + + return widget; + }, + + setPropsForAllWidgetFromXML: function(reader, widget, objectData){ + reader.setPropsFromXML(widget, objectData); } + }; /** diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index b0fdc4b3c7..aeb3900b11 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -101,12 +101,33 @@ ccs.ActionTimelineCache = { } }, + /** + * Create new action + * @param {string} filename + * @returns {*} + */ + createAction: function(filename){ + + var path = filename; + var pos = path.lastIndexOf('.'); + var suffix = path.substr(pos + 1, path.length); + cc.log("suffix = %s", suffix); + + var cache = ccs.ActionTimelineCache; + if (suffix == "csb"){ + return cache.createActionFromProtocolBuffers(filename); + }else if (suffix == "json" || suffix == "ExportJson"){ + return cache.createActionFormJson(filename); + } + return null; + }, + /** * Create new action * @param {string} fileName * @returns {*} */ - createAction: function(fileName){ + createActionFormJson: function(fileName){ var action = this._animationActions[fileName]; if (action == null) { @@ -163,6 +184,58 @@ ccs.ActionTimelineCache = { }, + createActionFromProtocolBuffers: function(fileName){ + var action = this._animationActions[fileName]; + if(action == null){ + action = this.loadAnimationActionWithFileFromProtocolBuffers(fileName); + } + return action.clone(); + }, + + loadAnimationActionWithFileFromProtocolBuffers: function(fileName){ + // if already exists an action with filename, then return this action + var action = this._animationActions[fileName]; + if(action){ + return action; + } + // int pos = path.find_last_of('/') + // _protocolBuffersPath = path.substr(0, pos + 1); + +// var fullPath = FileUtils.getInstance().fullPathForFilename(fileName); +// var content = FileUtils.getInstance().getDataFromFile(fullPath); +// var gpbwp;//todo protobuf reader +// // protocolbuffers.GUIProtocolBuffersProtobuf gpbwp; +// if (!gpbwp.ParseFromArray(content.getBytes(), content.getSize())){ +// return null; +// } + var binary = cc.loader.getRes(fileName); + var buffer = PBP.CSParseBinary.decode(binary); + + var actionProtobuf = buffer.action; + action = new ccs.ActionTimeline(); + action.setDuration(actionProtobuf.duration); + action.setTimeSpeed(actionProtobuf.speed!==null?actionProtobuf.speed:1); + + var timelineLength = actionProtobuf.timelines.length; + for(var i=0;i(node); + + if(filePath != nullptr && strcmp(filePath, "") != 0) + { + var path = filePath; + + SpriteFrame* spriteFrame = SpriteFrameCache.getInstance().getSpriteFrameByName(path); + if(!spriteFrame) + { + path = _protocolBuffersPath + path; + sprite.setTexture(path); + } + else + { + sprite.setSpriteFrame(spriteFrame); + } + } + else + { + cc.log("filePath is empty. Create a sprite with no texture"); + } + */ + + this.setPropsForNodeFromProtocolBuffers(sprite, nodeOptions); + + var alpha = nodeOptions.Alpha !==null ? nodeOptions.Alpha : 255; + var red = nodeOptions.colorR!==null ? nodeOptions.colorR : 255; + var green = nodeOptions.colorG!==null ? nodeOptions.colorG : 255; + var blue = nodeOptions.colorB!==null ? nodeOptions.colorB : 255; + + if (alpha != 255) + { + sprite.setOpacity(alpha); + } + if (red != 255 || green != 255 || blue != 255) + { + sprite.setColor(cc.color(red, green, blue)); + } + + var flipX = spriteOptions.flippedX; + var flipY = spriteOptions.flippedY; + + if(flipX) + sprite.setFlippedX(flipX); + if(flipY) + sprite.setFlippedY(flipY); + }, + createParticleFromProtocolBuffers: function(particleSystemOptions, nodeOptions){ + var node = null; + + var options = particleSystemOptions; + + /* + const std.string& filePath = options.plistfile(); + var num = options.totalparticles(); + */ + + var fileNameData = options.fileNameData; + var resourceType = fileNameData.resourceType; + switch (resourceType) + { + case 0: + { + + var path = this._protocolBuffersPath + fileNameData.path; + if (path != "") + { + node = cc.ParticleSystemQuad.create(path); + } + break; + } + + default: + break; + } + + if (node) + { + this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); + } + + return node; + }, + createTMXTiledMapFromProtocolBuffers: function(tmxTiledMapOptions, nodeOptions){ + var node = null; + var options = tmxTiledMapOptions; + + var fileNameData = options.fileNameData; + var resourceType = fileNameData.resourceType; + switch (resourceType) + { + case 0: + { + var path = this._protocolBuffersPath + fileNameData.path; + var tmxFile = path; + + if (tmxFile && "" != tmxFile) + { + node = cc.TMXTiledMap.create(tmxFile); + } + break; + } + + default: + break; + } + + if (node) + { + this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); + } + + return node; + }, + setPropsForProjectNodeFromProtocolBuffers: function(node, projectNodeOptions, nodeOptions){ + var options = projectNodeOptions; + this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); + }, + setPropsForSimpleAudioFromProtocolBuffers: function(node, nodeOptions){ + this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); + }, + + createComponentFromProtocolBuffers: function(componentOptions){ + var component = null; + + var componentType = componentOptions.type; + + if (componentType == "ComAudio") + { + component = ccs.ComAudio.create(); + var options = componentOptions.comAudioOptions; + this.setPropsForComAudioFromProtocolBuffers(component, options); + } + + return component; + }, + setPropsForComponentFromProtocolBuffers: function(component, componentOptions){ + var componentType = componentOptions.type; + + if (componentType == "ComAudio") + { + component = ccs.ComAudio.create(); + var options = componentOptions.comAudioOptions; + this.setPropsForComAudioFromProtocolBuffers(component, options); + } + }, + setPropsForComAudioFromProtocolBuffers: function(component, comAudioOptions){ + var options = comAudioOptions; + var audio = component; + + var fileNameData = options.fileNameData; + var resourceType = fileNameData.resourceType; + switch (resourceType) + { + case 0: + { + var path = this._protocolBuffersPath + fileNameData.path; + audio.setFile(path); + break; + } + + default: + break; + } + + var loop = options.loop; + audio.setLoop(loop); + + audio.setName(options.name); + audio.setLoop(options.loop); + }, + + setPropsForNodeFromXML: function(node, nodeObjectData){ + node.setCascadeColorEnabled(true); + node.setCascadeOpacityEnabled(true); + + node.setScale(0.0, 0.0); + + var name = nodeObjectData.Name(); + cc.log("entity name = %s", name); + + // attributes + var attribute = nodeObjectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Name") + { + node.setName(value); + } + else if (name == "ActionTag") + { + //atoi(value) + node.setUserObject(ccs.ActionTimelineData.create(value)); + } + else if (name == "RotationSkewX") + { + node.setRotationSkewX(atof(value)); + } + else if (name == "RotationSkewY") + { + node.setRotationSkewY(atof(value)); + } + else if (name == "Rotation") + { + // node.setRotation(atoi(value)); + } + else if (name == "ZOrder") + { + node.setZOrder(atoi(value)); + } + else if (name == "Visible") + { + node.setVisible((value == "True") ? true : false); + } + else if (name == "VisibleForFrame") + { + // node.setVisible((value == "True") ? true : false); + } + else if (name == "Alpha") + { + node.setOpacity(atoi(value)); + } + else if (name == "Tag") + { + node.setTag(atoi(value)); + } + + attribute = attribute.Next(); + } + + var child = nodeObjectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + if (name == "Children") + { + break; + } + else if (name == "Position") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + node.setPositionX(atof(value)); + } + else if (name == "Y") + { + node.setPositionY(atof(value)); + } + + attribute = attribute.Next(); + } + } + else if (name == "Scale") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + node.setScaleX(atof(value)); + } + else if (name == "ScaleY") + { + node.setScaleY(atof(value)); + } + + attribute = attribute.Next(); + } + } + else if (name == "AnchorPoint") + { + var attribute = child.FirstAttribute(); + + var anchorX = 0.0; + var anchorY = 0.0; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + anchorX = atof(value); + } + else if (name == "ScaleY") + { + anchorY = atof(value); + } + + attribute = attribute.Next(); + } + + node.setAnchorPoint(Vec2(anchorX, anchorY)); + } + else if (name == "CColor") + { + var attribute = child.FirstAttribute(); + var opacity = 255, red = 255, green = 255, blue = 255; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "A") + { + opacity = atoi(value); + } + else if (name == "R") + { + red = atoi(value); + } + else if (name == "G") + { + green = atoi(value); + } + else if (name == "B") + { + blue = atoi(value); + } + + attribute = attribute.Next(); + } + + node.setOpacity(opacity); + node.setColor(cc.color(red, green, blue)); + } + else if (name == "Size") + { + var attribute = child.FirstAttribute(); + var width = 0, height = 0; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value); + } + else if (name == "Y") + { + height = atof(value); + } + + attribute = attribute.Next(); + } + + node.setContentSize(cc.size(width, height)); + } + + child = child.NextSiblingElement(); + } + }, + setPropsForSingleNodeFromXML: function(node, nodeObjectData){ + this.setPropsForNodeFromXML(node, nodeObjectData); + }, + setPropsForSpriteFromXML: function(node, spriteObjectData){ + this.setPropsForNodeFromXML(node, spriteObjectData); + + var sprite = node; + var opacity = 255; + + // attributes + var attribute = this.spriteObjectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Alpha") + { + opacity = atoi(value.c_str()); + } + else if (name == "FlipX") + { + sprite.setFlippedX((value == "True") ? true : false); + } + else if (name == "FlipY") + { + sprite.setFlippedY((value == "True") ? true : false); + } + + attribute = attribute.Next(); + } + + + // FileData + var child = spriteObjectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "FileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + if (path != "") + { + sprite.setTexture(this._xmlPath + path); + } + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(this._xmlPath + plistFile); + if (path != "") + { + sprite.setSpriteFrame(path); + } + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + sprite.setOpacity(opacity); + }, + createParticleFromXML: function(particleObjectData){ + var node = null; + + // child elements + var child = particleObjectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "FileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + if (path != "") + { + node = cc.ParticleSystemQuad.create(this._xmlPath + path); + } + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + if (node) + { + this.setPropsForNodeFromXML(node, particleObjectData); + } + + return node; + }, + createTMXTiledMapFromXML: function(tmxTiledMapObjectData){ + var node = null; + + // child elements + var child = tmxTiledMapObjectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "FileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + var tmxFile_str = this._xmlPath + path; + var tmxFile = tmxFile_str; + + if (tmxFile && "" != tmxFile) + { + node = cc.TMXTiledMap.create(tmxFile); + } + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + + if (node) + { + this.setPropsForNodeFromXML(node, tmxTiledMapObjectData); + } + + return node; + }, + setPropsForProjectNodeFromXML: function(node, projectNodeObjectData){ + this.setPropsForNodeFromXML(node, projectNodeObjectData); + }, + setPropsForSimpleAudioFromXML: function(node, simpleAudioObjectData){ + this.setPropsForNodeFromXML(node, simpleAudioObjectData); + }, + + createComponentFromXML: function(componentObjectData, componentType){ + var component = null; + + if (componentType == "ComAudio") + { + component = ccs.ComAudio.create(); + this.setPropsForComAudioFromXML(component, componentObjectData); + } + + return component; + }, + setPropsForComponentFromXML: function(component, componentObjectData){}, + setPropsForComAudioFromXML: function(component, comAudioObjectData){ + var audio = component; + + audio.setEnabled(true); + + var attribute = comAudioObjectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Loop") + { + audio.setLoop((value == "True") ? true : false); + } + else if (name == "Name") + { + audio.setName(value); + } + + attribute = attribute.Next(); + } + + // FileData + var child = comAudioObjectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "FileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + audio.setFile((this._xmlPath + path)); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + }, + + isWidget: function(type){ + return (type == CSLoaderStatic.ClassName_Panel + || type == CSLoaderStatic.ClassName_Button + || type == CSLoaderStatic.ClassName_CheckBox + || type == CSLoaderStatic.ClassName_ImageView + || type == CSLoaderStatic.ClassName_TextAtlas + || type == CSLoaderStatic.ClassName_LabelAtlas + || type == CSLoaderStatic.ClassName_LabelBMFont + || type == CSLoaderStatic.ClassName_TextBMFont + || type == CSLoaderStatic.ClassName_Text + || type == CSLoaderStatic.ClassName_LoadingBar + || type == CSLoaderStatic.ClassName_TextField + || type == CSLoaderStatic.ClassName_Slider + || type == CSLoaderStatic.ClassName_Layout + || type == CSLoaderStatic.ClassName_ScrollView + || type == CSLoaderStatic.ClassName_ListView + || type == CSLoaderStatic.ClassName_PageView + || type == CSLoaderStatic.ClassName_Widget + || type == CSLoaderStatic.ClassName_Label); + + }, + isCustomWidget: function(type){ + var widget = ccs.objectFactory.createObject(type); + if (widget) + { + return true; + } + + return false; + }, + + getGUIClassName: function(name){ + var convertedClassName = name; + if (name == "Panel") + { + convertedClassName = "Layout"; + } + else if (name == "TextArea") + { + convertedClassName = "Text"; + } + else if (name == "TextButton") + { + convertedClassName = "Button"; + } + else if (name == "Label") + { + convertedClassName = "Text"; + } + else if (name == "LabelAtlas") + { + convertedClassName = "TextAtlas"; + } + else if (name == "LabelBMFont") + { + convertedClassName = "TextBMFont"; + } + + + return convertedClassName; + }, + getWidgetReaderClassName: function(widget){ + var readerName; + + // 1st., custom widget parse properties of parent widget with parent widget reader + if (widget instanceof ccui.Button) + { + readerName = "ButtonReader"; + } + else if (widget instanceof ccui.CheckBox) + { + readerName = "CheckBoxReader"; + } + else if (widget instanceof ccui.ImageView) + { + readerName = "ImageViewReader"; + } + else if (widget instanceof ccui.TextAtlas) + { + readerName = "TextAtlasReader"; + } + else if (widget instanceof ccui.TextBMFont) + { + readerName = "TextBMFontReader"; + } + else if (widget instanceof ccui.Text) + { + readerName = "TextReader"; + } + else if (widget instanceof ccui.LoadingBar) + { + readerName = "LoadingBarReader"; + } + else if (widget instanceof ccui.Slider) + { + readerName = "SliderReader"; + } + else if (widget instanceof ccui.TextField) + { + readerName = "TextFieldReader"; + } + else if (widget instanceof ccui.ListView) + { + readerName = "ListViewReader"; + } + else if (widget instanceof ccui.PageView) + { + readerName = "PageViewReader"; + } + else if (widget instanceof ccui.ScrollView) + { + readerName = "ScrollViewReader"; + } + + else if (widget instanceof ccui.Layout) + { + readerName = "LayoutReader"; + } + else if (widget instanceof ccui.Widget) + { + readerName = "WidgetReader"; + } + + return readerName; + } + + /* + typedef std.function NodeCreateFunc; + typedef std.pair Pair; + + std.unordered_map _funcs; + + typedef std.function ComponentCreateFunc; + typedef std.pair ComponentPair; + + std.unordered_map _componentFuncs; + */ + + + +}; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index 7cbfcc7bc8..4f13b51548 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -62,7 +62,7 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ break; case 1: var normalFileName = normalDic["path"]; - button.loadTextureNormal(normalFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + button.loadTextureNormal(normalFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -79,7 +79,7 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ break; case 1: var pressedFileName = pressedDic["path"]; - button.loadTexturePressed(pressedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + button.loadTexturePressed(pressedFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -96,7 +96,7 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ break; case 1: var disabledFileName = disabledDic["path"]; - button.loadTextureDisabled(disabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + button.loadTextureDisabled(disabledFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -132,5 +132,459 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ if (fn) button.setTitleFontName(options["fontName"]); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var button = widget; + var options = nodeTree.buttonoptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + var scale9Enable = options.scale9enable(); + button.setScale9Enabled(scale9Enable); + + + var normalDic = options.normaldata(); + var normalType = normalDic.resourcetype(); + if (normalType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + normalDic.plistfile()); + } + var normalTexturePath = this.getResourcePath(normalDic.path(), normalType); + button.loadTextureNormal(normalTexturePath, normalType); + + + var pressedDic = options.presseddata(); + var pressedType = pressedDic.resourcetype(); + if (pressedType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + pressedDic.plistfile()); + } + var pressedTexturePath = this.getResourcePath(pressedDic.path(), pressedType); + button.loadTexturePressed(pressedTexturePath, pressedType); + + + var disabledDic = options.disableddata(); + var disabledType = disabledDic.resourcetype(); + if (disabledType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + disabledDic.plistfile()); + } + var disabledTexturePath = this.getResourcePath(disabledDic.path(), disabledType); + button.loadTextureDisabled(disabledTexturePath, disabledType); + + if (scale9Enable) + { + button.setUnifySizeEnabled(false); + button.ignoreContentAdaptWithSize(false); + + var cx = options.capinsetsx(); + var cy = options.capinsetsy(); + var cw = options.capinsetswidth(); + var ch = options.capinsetsheight(); + + button.setCapInsets(Rect(cx, cy, cw, ch)); + var sw = options.has_scale9width(); + var sh = options.has_scale9height(); + if (sw && sh) + { + var swf = options.scale9width(); + var shf = options.scale9height(); + button.setContentSize(cc.size(swf, shf)); + } + } + var tt = options.has_text(); + if (tt) + { + var text = options.text(); + if (text) + { + button.setTitleText(text); + } + } + + + var cri = options.has_textcolorr() ? options.textcolorr() : 255; + var cgi = options.has_textcolorg() ? options.textcolorg() : 255; + var cbi = options.has_textcolorb() ? options.textcolorb() : 255; + button.setTitleColor(cc.color(cri,cgi,cbi)); + + + var fontSize = options.has_fontsize() ? options.fontsize() : 14; + button.setTitleFontSize(fontSize); + + var displaystate = true; + if(options.has_displaystate()) + { + displaystate = options.displaystate(); + } + button.setBright(displaystate); + + var fontName = options.has_fontname() ? options.fontname() : "微软雅黑"; + button.setTitleFontName(fontName); + + if (options.has_fontresource()) + { + var resourceData = options.fontresource(); + button.setTitleFontName(protocolBuffersPath + resourceData.path()); + } + + var widgetOption = nodeTree.widgetoptions(); + button.setColor(cc.color(widgetOption.colorr(), widgetOption.colorg(), widgetOption.colorb())); + button.setOpacity(widgetOption.has_alpha() ? widgetOption.alpha() : 255); + + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var button = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var scale9Enabled = false; + var cx = 0, cy = 0, cw = 0, ch = 0; + var swf = 0, shf = 0; + var text = ""; + var fontName = "微软雅黑"; + var fontSize = 0; + var title_color_red = 255, title_color_green = 255, title_color_blue = 255; + var cri = 255, cgi = 255, cbi = 255; + var opacity = 255; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Scale9Enable") + { + if (value == "True") + { + scale9Enabled = true; + } + } + else if (name == "Scale9OriginX") + { + cx = atof(value()); + } + else if (name == "Scale9OriginY") + { + cy = atof(value()); + } + else if (name == "Scale9Width") + { + cw = atof(value()); + } + else if (name == "Scale9Height") + { + ch = atof(value()); + } + else if (name == "ButtonText") + { + text = value; + } + else if (name == "FontSize") + { + fontSize = atoi(value); + } + else if (name == "FontName") + { + fontName = value; + } + else if (name == "Alpha") + { + opacity = atoi(value()); + } + else if (name == "DisplayState") + { + button.setBright((value == "True") ? true : false); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "Size" && scale9Enabled) + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + swf = atof(value()); + } + else if (name == "Y") + { + shf = atof(value()); + } + + attribute = attribute.Next(); + } + } + else if (name == "CColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + cri = atoi(value()); + } + else if (name == "G") + { + cgi = atoi(value()); + } + else if (name == "B") + { + cbi = atoi(value()); + } + + attribute = attribute.Next(); + } + } + else if (name == "TextColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + title_color_red = atoi(value()); + } + else if (name == "G") + { + title_color_green = atoi(value()); + } + else if (name == "B") + { + title_color_blue = atoi(value()); + } + + attribute = attribute.Next(); + } + } + else if (name == "DisabledFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + button.loadTextureDisabled(xmlPath + path, Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + SpriteFrameCache.getInstance().addSpriteFramesWithFile(xmlPath + plistFile); + button.loadTextureDisabled(path, Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "PressedFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + button.loadTexturePressed(xmlPath + path, Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + button.loadTexturePressed(path, Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "NormalFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + button.loadTextureNormal(xmlPath + path, Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + button.loadTextureNormal(path, Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "FontResource") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + fontName = xmlPath + path; + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + button.setScale9Enabled(scale9Enabled); + + + if (scale9Enabled) + { + button.setUnifySizeEnabled(false); + button.ignoreContentAdaptWithSize(false); + + button.setCapInsets(cc.rect(cx, cy, cw, ch)); + button.setContentSize(cc.size(swf, shf)); + } + + button.setTitleText(text); + button.setTitleColor(cc.color(title_color_red, title_color_green, title_color_blue)); + button.setTitleFontSize(fontSize); + button.setTitleFontName(fontName); + + button.setColor(cc.color(cri,cgi,cbi)); + button.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index da88420db1..93127446a6 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -90,5 +90,362 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ checkBox.setSelectedState(options["selectedState"]); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - } + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var checkBox = widget; + var options = nodeTree.checkboxoptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + //load background image + var backGroundDic = options.backgroundboxdata(); + var backGroundType = backGroundDic.resourcetype(); + if (backGroundType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + backGroundDic.plistfile()); + } + var backGroundTexturePath = this.getResourcePath(backGroundDic.path(), backGroundType); + checkBox.loadTextureBackGround(backGroundTexturePath, backGroundType); + + //load background selected image + var backGroundSelectedDic = options.backgroundboxselecteddata(); + var backGroundSelectedType = backGroundSelectedDic.resourcetype(); + if (backGroundSelectedType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + backGroundSelectedDic.plistfile()); + } + var backGroundSelectedTexturePath = this.getResourcePath(backGroundSelectedDic.path(), backGroundSelectedType); + checkBox.loadTextureBackGroundSelected(backGroundSelectedTexturePath, backGroundSelectedType); + + //load frontCross image + var frontCrossDic = options.frontcrossdata(); + var frontCrossType = frontCrossDic.resourcetype(); + if (frontCrossType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + frontCrossDic.plistfile()); + } + var frontCrossFileName = this.getResourcePath(frontCrossDic.path(), frontCrossType); + checkBox.loadTextureFrontCross(frontCrossFileName, frontCrossType); + + //load backGroundBoxDisabledData + var backGroundDisabledDic = options.backgroundboxdisableddata(); + var backGroundDisabledType = backGroundDisabledDic.resourcetype(); + if (backGroundDisabledType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + backGroundDisabledDic.plistfile()); + } + var backGroundDisabledFileName = this.getResourcePath(backGroundDisabledDic.path(), backGroundDisabledType); + checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, backGroundDisabledType); + + ///load frontCrossDisabledData + var frontCrossDisabledDic = options.frontcrossdisableddata(); + var frontCrossDisabledType = frontCrossDisabledDic.resourcetype(); + if (frontCrossDisabledType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + frontCrossDisabledDic.plistfile()); + } + var frontCrossDisabledFileName = this.getResourcePath(frontCrossDisabledDic.path(), frontCrossDisabledType); + checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); + + checkBox.setSelectedState(options.selectedstate()); + + var displaystate = true; + if(options.has_displaystate()) + { + displaystate = options.displaystate(); + } + checkBox.setBright(displaystate); + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.setPropsFromXML.call(this, widget, objectData); + + var checkBox = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var opacity = 255; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "CheckedState") + { + checkBox.setSelectedState((value == "True") ? true : false); + } + else if (name == "DisplayState") + { + checkBox.setBright((value == "True") ? true : false); + } + else if (name == "Alpha") + { + opacity = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "NormalBackFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = this.getResourceType(value); + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + checkBox.loadTextureBackGround(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + checkBox.loadTextureBackGround(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "PressedBackFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = this.getResourceType(value); + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + checkBox.loadTextureBackGroundSelected(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + checkBox.loadTextureBackGroundSelected(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "NodeNormalFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = this.getResourceType(value); + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + checkBox.loadTextureFrontCross(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + checkBox.loadTextureFrontCross(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "DisableBackFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = this.getResourceType(value); + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + checkBox.loadTextureBackGroundDisabled(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + checkBox.loadTextureBackGroundDisabled(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "NodeDisableFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = this.getResourceType(value); + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + checkBox.loadTextureFrontCrossDisabled(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + checkBox.loadTextureFrontCrossDisabled(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + checkBox.setOpacity(opacity); + }, + + getResourceType: function(key) + { + if(key == "Normal" || key == "Default" || key == "MarkedSubImage") + { + return 0; + } + + return 1; + } + }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 6e27db35a9..e2ed8b30a4 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -63,7 +63,7 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ break; case 1: var imageFileName = imageFileNameDic["path"]; - imageView.loadTexture(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + imageView.loadTexture(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -97,5 +97,203 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var options = nodeTree.imageviewoptions(); + var imageView = widget; + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + var imageFileNameDic = options.filenamedata(); + var imageFileNameType = imageFileNameDic.resourcetype(); + if (imageFileNameType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + } + var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + imageView.loadTexture(imageFileName, imageFileNameType); + + + var scale9EnableExist = options.has_scale9enable(); + var scale9Enable = false; + if (scale9EnableExist) + { + scale9Enable = options.scale9enable(); + } + imageView.setScale9Enabled(scale9Enable); + + + if (scale9Enable) + { + imageView.setUnifySizeEnabled(false); + imageView.ignoreContentAdaptWithSize(false); + + var swf = options.has_scale9width() ? options.scale9width() : 80; + var shf = options.has_scale9height() ? options.scale9height() : 80; + imageView.setContentSize(Size(swf, shf)); + + + var cx = options.capinsetsx(); + var cy = options.capinsetsy(); + var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1.0; + var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1.0; + + imageView.setCapInsets(Rect(cx, cy, cw, ch)); + + } + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var flipX = options.flippedx(); + var flipY = options.flippedy(); + + if(flipX != false) + imageView.setFlippedX(flipX); + if(flipY != false) + imageView.setFlippedY(flipY); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var imageView = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var scale9Enabled = false; + var cx = 0, cy = 0, cw = 0, ch = 0; + var swf = 0, shf = 0; + + var opacity = 255; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Scale9Enable") + { + if (value == "True") + { + scale9Enabled = true; + } + } + else if (name == "Scale9OriginX") + { + cx = atof(value); + } + else if (name == "Scale9OriginY") + { + cy = atof(value); + } + else if (name == "Scale9Width") + { + cw = atof(value); + } + else if (name == "Scale9Height") + { + ch = atof(value); + } + else if (name == "Alpha") + { + opacity = atoi(value); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "Size" && scale9Enabled) + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + swf = atof(value); + } + else if (name == "Y") + { + shf = atof(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "FileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + imageView.loadTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + imageView.loadTexture(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + imageView.setScale9Enabled(scale9Enabled); + + if (scale9Enabled) + { + imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); + imageView.setContentSize(cc.size(swf, shf)); + } + + imageView.setOpacity(opacity); } + }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 05127cb8d6..31c6bb6525 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -73,5 +73,135 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var jsonPath = ccs.uiReader.getFilePath(); + + var labelAtlas = widget; + var options = nodeTree.textatlasoptions(); + // var sv = DICTOOL.checkObjectExist_json(options, P_StringValue); + // var cmf = DICTOOL.checkObjectExist_json(options, P_CharMapFile); + // var iw = DICTOOL.checkObjectExist_json(options, P_ItemWidth); + // var ih = DICTOOL.checkObjectExist_json(options, P_ItemHeight); + // var scm = DICTOOL.checkObjectExist_json(options, P_StartCharMap); + + var cmftDic = options.charmapfiledata(); + var cmfType = cmftDic.resourcetype(); + switch (cmfType) + { + case 0: + { + var tp_c = jsonPath; + var cmfPath = cmftDic.path().c_str(); + var cmf_tp = tp_c.append(cmfPath).c_str(); + var stringValue = options.has_stringvalue() ? options.stringvalue() : "12345678"; + var itemWidth = options.has_itemwidth() ? options.itemwidth() : 24; + var itemHeight = options.has_itemheight() ? options.itemheight() : 32; + labelAtlas.setProperty(stringValue, + cmf_tp, + itemWidth, + itemHeight, + options.startcharmap().c_str()); + break; + } + case 1: + cc.log("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var labelAtlas = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var stringValue = "", startChar = ""; + var itemWidth = 0, itemHeight = 0; + var resourceType = 0; + var path = "", plistFile = ""; + + var opacity = 255; + + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "LabelText") + { + stringValue = value; + } + else if (name == "CharWidth") + { + itemWidth = atoi(value.c_str()); + } + else if (name == "CharHeight") + { + itemHeight = atoi(value.c_str()); + } + else if (name == "StartChar") + { + startChar = value; + } + else if (name == "Alpha") + { + opacity = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "LabelAtlasFileImage_CNB") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + } + + child = child.NextSiblingElement(); + } + + labelAtlas.setProperty(stringValue, xmlPath + path, itemWidth, itemHeight, startChar); + + labelAtlas.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index 99d60664de..ef5a0aff3c 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -69,5 +69,127 @@ ccs.LabelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ var text = options["text"]; labelBMFont.setString(text); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var jsonPath = ccs.uiReader.getFilePath(); + + var labelBMFont = widget; + var options = nodeTree.textbmfontoptions(); + + + var cmftDic = options.filenamedata(); + var cmfType = cmftDic.resourcetype(); + switch (cmfType) + { + case 0: + { + var tp_c = jsonPath; + var cmfPath = cmftDic.path().c_str(); + var cmf_tp = tp_c.append(cmfPath).c_str(); + labelBMFont.setFntFile(cmf_tp); + break; + } + case 1: + cc.log("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + + var text = (options.has_text()) ? options.text().c_str() : "Text Label"; + labelBMFont.setString(text); + + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML: function(widget, nodeTree){ + WidgetReader.setPropsFromXML(widget, objectData); + + var labelBMFont = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var text = ""; + + var opacity = 255; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "LabelText") + { + text = value; + } + else if (name == "Alpha") + { + opacity = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "LabelBMFontFile_CNB") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + labelBMFont.setFntFile(xmlPath + path); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + labelBMFont.setString(text); + + labelBMFont.setOpacity(opacity); + } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index 96fc34750c..0ef6efee2e 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -79,5 +79,237 @@ ccs.LabelReader = /** @lends ccs.LabelReader# */{ label.setTextVerticalAlignment(options["vAlignment"]); } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + var label = widget; + var options = nodeTree.textoptions(); + + var IsCustomSize = options.iscustomsize(); + label.ignoreContentAdaptWithSize(!IsCustomSize); + + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + label.setUnifySizeEnabled(false); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + var touchScaleChangeAble = options.touchscaleenable(); + label.setTouchScaleChangeEnabled(touchScaleChangeAble); + var text = options.has_text() ? options.text().c_str() : "Text Label"; + label.setString(text); + + var fontSize = options.has_fontsize() ? options.fontsize() : 20; + label.setFontSize(fontSize); + + var fontName = options.has_fontname() ? options.fontname() : "微软雅黑"; + + var fontFilePath = protocolBuffersPath.append(fontName); + if (FileUtils.getInstance().isFileExist(fontFilePath)) + { + label.setFontName(fontFilePath); + } + else{ + label.setFontName(fontName); + } + + var aw = options.has_areawidth(); + var ah = options.has_areaheight(); + if (aw && ah) + { + var size = Size(options.areawidth(), options.areaheight()); + label.setTextAreaSize(size); + } + var ha = options.has_halignment(); + if (ha) + { + label.setTextHorizontalAlignment(options.halignment()); + } + var va = options.has_valignment(); + if (va) + { + label.setTextVerticalAlignment(options.valignment()); + } + + if (options.has_fontresource()) + { + var resourceData = options.fontresource(); + label.setFontName(protocolBuffersPath + resourceData.path()); + } + + + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var label = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var areaWidth = 0, areaHeight = 0; + var halignment = 0, valignment = 0; + + var opacity = 255; + + label.setUnifySizeEnabled(false); + + label.setFontName("微软雅黑"); + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "TouchScaleChangeAble") + { + label.setTouchScaleChangeEnabled((value == "True") ? true : false); + } + else if (name == "LabelText") + { + label.setString(value); + } + else if (name == "FontSize") + { + label.setFontSize(atoi(value.c_str())); + } + else if (name == "FontName") + { + label.setFontName(value); + } + else if (name == "AreaWidth") + { + areaWidth = atoi(value.c_str()); + } + else if (name == "AreaHeight") + { + areaHeight = atoi(value.c_str()); + } + else if (name == "HorizontalAlignmentType") + { + if (value == "HT_Left") + { + halignment = 0; + } + else if (value == "HT_Center") + { + halignment = 1; + } + else if (value == "HT_Right") + { + halignment = 2; + } + } + else if (name == "VerticalAlignmentType") + { + if (value == "VT_Top") + { + valignment = 0; + } + else if (value == "VT_Center") + { + valignment = 1; + } + else if (value == "VT_Bottom") + { + valignment = 2; + } + } + else if (name == "Alpha") + { + opacity = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "Size") + { + var attribute = child.FirstAttribute(); + var width = 0, height = 0; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value.c_str()); + } + else if (name == "Y") + { + height = atof(value.c_str()); + } + + attribute = attribute.Next(); + } + + label.ignoreContentAdaptWithSize(false); + label.setContentSize(cc.size(width, height)); + } + else if (name == "FontResource") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + label.setFontName(xmlPath + path); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + if (areaWidth != 0 || areaHeight != 0) + { + label.setTextAreaSize(cc.size(areaWidth, areaHeight)); + } + + label.setTextHorizontalAlignment(halignment); + label.setTextVerticalAlignment(valignment); + + label.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index d83ded8bd5..8e5c9d5c1b 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -84,7 +84,7 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ var co = options["bgColorOpacity"]; var colorType = options["colorType"]; - panel.setBackGroundColorType(colorType/*ui::LayoutBackGroundColorType(colorType)*/); + panel.setBackGroundColorType(colorType/*ui.LayoutBackGroundColorType(colorType)*/); panel.setBackGroundColor(cc.color(scr, scg, scb), cc.color(ecr, ecg, ecb)); panel.setBackGroundColor(cc.color(cr, cg, cb)); panel.setBackGroundColorOpacity(co); @@ -108,7 +108,7 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ case 1: { var imageFileName = imageFileNameDic["path"]; - panel.setBackGroundImage(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + panel.setBackGroundImage(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; } default: @@ -126,5 +126,471 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ } panel.setLayoutType(options["layoutType"]); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var panel = widget; + var options = nodeTree.paneloptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + panel.setClippingEnabled(options.clipable()); + + var backGroundScale9Enable = options.backgroundscale9enable(); + panel.setBackGroundImageScale9Enabled(backGroundScale9Enable); + + + var cr; + var cg; + var cb; + var scr; + var scg; + var scb; + var ecr; + var ecg; + var ecb; + + if (widget instanceof ccui.PageView) + { + cr = options.has_bgcolorr() ? options.bgcolorr() : 150; + cg = options.has_bgcolorg() ? options.bgcolorg() : 150; + cb = options.has_bgcolorb() ? options.bgcolorb() : 150; + + scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; + scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; + scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + + ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; + ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; + ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + } + else if(widget instanceof ccui.ListView) + { + cr = options.has_bgcolorr() ? options.bgcolorr() : 150; + cg = options.has_bgcolorg() ? options.bgcolorg() : 150; + cb = options.has_bgcolorb() ? options.bgcolorb() : 255; + + scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; + scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; + scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + + ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 150; + ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; + ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 255; + } + else if(widget instanceof ccui.ScrollView) + { + cr = options.has_bgcolorr() ? options.bgcolorr() : 255; + cg = options.has_bgcolorg() ? options.bgcolorg() : 150; + cb = options.has_bgcolorb() ? options.bgcolorb() : 100; + + scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; + scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; + scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + + ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; + ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; + ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + } + else + { + cr = options.has_bgcolorr() ? options.bgcolorr() : 150; + cg = options.has_bgcolorg() ? options.bgcolorg() : 200; + cb = options.has_bgcolorb() ? options.bgcolorb() : 255; + + scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; + scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; + scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + + ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 150; + ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 200; + ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 255; + } + + var bgcv1 = 0; + var bgcv2 = -0.5; + if(options.has_vectorx()) + { + bgcv1 = options.vectorx(); + } + if(options.has_vectory()) + { + bgcv2 = options.vectory(); + } + panel.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); + + var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + + var colorType = options.has_colortype() ? options.colortype() : 1; + panel.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + + panel.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); + panel.setBackGroundColor(cc.color(cr, cg, cb)); + panel.setBackGroundColorOpacity(co); + + + var imageFileNameDic = options.backgroundimagedata(); + var imageFileNameType = imageFileNameDic.resourcetype(); + if (imageFileNameType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + } + var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + panel.setBackGroundImage(imageFileName, imageFileNameType); + + + if (backGroundScale9Enable) + { + var cx = options.capinsetsx(); + var cy = options.capinsetsy(); + var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; + var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + + var sw = options.has_scale9width(); + var sh = options.has_scale9height(); + if (sw && sh) + { + var swf = options.scale9width(); + var shf = options.scale9height(); + panel.setContentSize(cc.size(swf, shf)); + } + } + + panel.setLayoutType(options.layouttype()); + + var widgetOptions = nodeTree.widgetoptions(); + + var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; + var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; + var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + panel.setColor(cc.color(red, green, blue)); + + var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + panel.setOpacity(opacity); + +// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; +// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; +// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; +// panel.setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb)); +// +// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; +// panel.setBackGroundImageOpacity(bgimgopacity); + + + // other commonly protperties + this.setAnchorPointForWidget(widget, nodeTree); + + var flipX = widgetOptions.flipx(); + var flipY = widgetOptions.flipy(); + widget.setFlippedX(flipX); + widget.setFlippedY(flipY); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var panel = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var scale9Enabled = false; + var width = 0, height = 0; + var cx = 0, cy = 0, cw = 0, ch = 0; + + var colorType = ccui.Layout.BackGroundColorType.NONE; + var color_opacity = 255, bgimg_opacity = 255, opacity = 255; + var red = 255, green = 255, blue = 255; + var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; + var singleRed = 255, singleGreen = 255, singleBlue = 255; + var start_red = 255, start_green = 255, start_blue = 255; + var end_red = 255, end_green = 255, end_blue = 255; + var vector_color_x = 0, vector_color_y = -0.5; + + var resourceType = 0; + var path = "", plistFile = ""; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ClipAble") + { + panel.setClippingEnabled((value == "True") ? true : false); + } + else if (name == "ComboBoxIndex") + { + colorType = atoi(value); + } + else if (name == "BackColorAlpha") + { + color_opacity = atoi(value); + } + else if (name == "Alpha") + { + opacity = atoi(value); + bgimg_opacity = atoi(value); + } + else if (name == "Scale9Enable") + { + scale9Enabled = (value == "True") ? true : false; + } + else if (name == "Scale9OriginX") + { + cx = atof(value); + } + else if (name == "Scale9OriginY") + { + cy = atof(value); + } + else if (name == "Scale9Width") + { + cw = atof(value); + } + else if (name == "Scale9Height") + { + ch = atof(value); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "Size") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value); + } + else if (name == "Y") + { + height = atof(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "CColor") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + red = atoi(value); + bgimg_red = atoi(value); + } + else if (name == "G") + { + green = atoi(value); + bgimg_green = atoi(value); + } + else if (name == "B") + { + blue = atoi(value); + bgimg_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "SingleColor") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + singleRed = atoi(value); + } + else if (name == "G") + { + singleGreen = atoi(value); + } + else if (name == "B") + { + singleBlue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "EndColor") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + end_red = atoi(value); + } + else if (name == "G") + { + end_green = atoi(value); + } + else if (name == "B") + { + end_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "FirstColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + start_red = atoi(value); + } + else if (name == "G") + { + start_green = atoi(value); + } + else if (name == "B") + { + start_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "ColorVector") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + vector_color_x = atof(value); + } + else if (name == "ScaleY") + { + vector_color_y = atof(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "FileData") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + } + + child = child.NextSiblingElement(); + } + + panel.setBackGroundColorType(colorType); + switch (colorType) + { + case Layout.BackGroundColorType.SOLID: + panel.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); + break; + + case Layout.BackGroundColorType.GRADIENT: + panel.setBackGroundColor(cc.color(start_red, start_green, start_blue), + cc.color(end_red, end_green, end_blue)); + panel.setBackGroundColorVector(cc.p(vector_color_x, vector_color_y)); + break; + + default: + break; + } + + panel.setColor(cc.color(red, green, blue)); + panel.setOpacity(opacity); + + panel.setBackGroundColorOpacity(color_opacity); + + switch (resourceType) + { + case 0: + { + panel.setBackGroundImage(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + panel.setBackGroundImage(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + + if (path != "") + { + if (scale9Enabled) + { + panel.setBackGroundImageScale9Enabled(scale9Enabled); + panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + panel.setContentSize(cc.size(width, height)); + } + } + +// panel.setBackGroundImageColor(Color3B(bgimg_red, bgimg_green, bgimg_blue)); +// panel.setBackGroundImageOpacity(bgimg_opacity); + } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index 919ec9d3b9..6aea22691f 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -56,5 +56,527 @@ ccs.ListViewReader = /** @lends ccs.ListViewReader# */{ var itemMargin = options["itemMargin"]; listView.setItemsMargin(itemMargin); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var listView = widget; + var options = nodeTree.listviewoptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + listView.setClippingEnabled(options.clipable()); + + var backGroundScale9Enable = options.backgroundscale9enable(); + listView.setBackGroundImageScale9Enabled(backGroundScale9Enable); + + + var cr; + var cg; + var cb; + var scr; + var scg; + var scb; + var ecr; + var ecg; + var ecb; + + + + cr = options.has_bgcolorr() ? options.bgcolorr() : 150; + cg = options.has_bgcolorg() ? options.bgcolorg() : 150; + cb = options.has_bgcolorb() ? options.bgcolorb() : 255; + + scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; + scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; + scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + + ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 150; + ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; + ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 255; + + var bgcv1 = options.vectorx(); + var bgcv2 = options.has_vectory() ? options.vectory() : -0.5; + listView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); + + var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + + var colorType = options.has_colortype() ? options.colortype() : 1; + listView.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + + listView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); + listView.setBackGroundColor(cc.color(cr, cg, cb)); + listView.setBackGroundColorOpacity(co); + + + var imageFileNameDic = options.backgroundimagedata(); + var imageFileNameType = imageFileNameDic.resourcetype(); + if (imageFileNameType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + } + var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + listView.setBackGroundImage(imageFileName, imageFileNameType); + + + if (backGroundScale9Enable) + { + var cx = options.capinsetsx(); + var cy = options.capinsetsy(); + var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; + var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + listView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + + var sw = options.has_scale9width(); + var sh = options.has_scale9height(); + if (sw && sh) + { + var swf = options.scale9width(); + var shf = options.scale9height(); + listView.setContentSize(cc.size(swf, shf)); + } + } + + var widgetOptions = nodeTree.widgetoptions(); + + var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; + var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; + var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + listView.setColor(cc.color(red, green, blue)); + + var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + listView.setOpacity(opacity); + +// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; +// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; +// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; +// listView.setBackGroundImageColor(cc.color(bgimgcr, bgimgcg, bgimgcb)); +// +// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; +// listView.setBackGroundImageOpacity(bgimgopacity); + + + + + + var innerWidth = options.has_innerwidth() ? options.innerwidth() : 200; + var innerHeight = options.has_innerheight() ? options.innerheight() : 200; + listView.setInnerContainerSize(Size(innerWidth, innerHeight)); + listView.setBounceEnabled(options.bounceenable()); + + var direction = options.has_direction() ? options.direction() : 2; + listView.setDirection(direction); + + var gravityValue = options.has_gravity() ? options.gravity() : 3; + var gravity = gravityValue; + listView.setGravity(gravity); + + var itemMargin = options.itemmargin(); + listView.setItemsMargin(itemMargin); + + + // other commonly protperties + this.setAnchorPointForWidget(widget, nodeTree); + + var flipX = widgetOptions.flipx(); + var flipY = widgetOptions.flipy(); + widget.setFlippedX(flipX); + widget.setFlippedY(flipY); + }, + + setPropsFromXML: function(){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var listView = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var scale9Enabled = false; + var width = 0, height = 0; + var cx = 0, cy = 0, cw = 0, ch = 0; + + var colorType = Layout.BackGroundColorType.NONE; + var color_opacity = 255, bgimg_opacity = 255, opacity = 255; + var red = 255, green = 255, blue = 255; + var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; + var singleRed = 255, singleGreen = 255, singleBlue = 255; + var start_red = 255, start_green = 255, start_blue = 255; + var end_red = 255, end_green = 255, end_blue = 255; + var vector_color_x = 0.0, vector_color_y = -0.5; + + var resourceType = 0; + var path = "", plistFile = ""; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ClipAble") + { + listView.setClippingEnabled((value == "True") ? true : false); + } + else if (name == "ComboBoxIndex") + { + colorType = atoi(value); + } + else if (name == "BackColorAlpha") + { + color_opacity = atoi(value); + } + else if (name == "Alpha") + { + opacity = atoi(value); + bgimg_opacity = atoi(value); + } + else if (name == "Scale9Enable") + { + scale9Enabled = (value == "True") ? true : false; + } + else if (name == "Scale9OriginX") + { + cx = atof(value); + } + else if (name == "Scale9OriginY") + { + cy = atof(value); + } + else if (name == "Scale9Width") + { + cw = atof(value); + } + else if (name == "Scale9Height") + { + ch = atof(value); + } + else if (name == "DirectionType") + { + if (value == "Vertical") + { + listView.setDirection(ccui.ScrollView.Direction.VERTICAL); + + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "HorizontalType") + { + if (value == "HORIZONTAL_LEFT") + { + listView.setGravity(ListView.Gravity.LEFT); + } + else if (value == "HORIZONTAL_RIGHT") + { + listView.setGravity(ListView.Gravity.RIGHT); + } + else if (value == "HORIZONTAL_CENTER") + { + listView.setGravity(ListView.Gravity.CENTER_HORIZONTAL); + } + } + + attribute = attribute.Next(); + } + } + else if (value == "Horizontal") + { + listView.setDirection(ScrollView.Direction.HORIZONTAL); + + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "VerticalType") + { + if (value == "VERTICAL_TOP") + { + listView.setGravity(ListView.Gravity.TOP); + } + else if (value == "VERTICAL_BOTTOM") + { + listView.setGravity(ListView.Gravity.BOTTOM); + } + else if (value == "VERTICAL_CENTER") + { + listView.setGravity(ListView.Gravity.CENTER_VERTICAL); + } + } + + attribute = attribute.Next(); + } + } + } + else if (name == "IsBounceEnabled") + { + listView.setBounceEnabled((value == "True") ? true : false); + } + else if (name == "ItemMargin") + { + listView.setItemsMargin(atoi(value)); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "InnerNodeSize") + { + var attribute = child.FirstAttribute(); + var width = 0, height = 0; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Width") + { + width = atof(value); + } + else if (name == "Height") + { + height = atof(value); + } + + attribute = attribute.Next(); + } + + listView.setInnerContainerSize(Size(width, height)); + } + else if (name == "Size") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value); + } + else if (name == "Y") + { + height = atof(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "CColor") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + red = atoi(value); + bgimg_red = atoi(value); + } + else if (name == "G") + { + green = atoi(value); + bgimg_green = atoi(value); + } + else if (name == "B") + { + blue = atoi(value); + bgimg_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "SingleColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + singleRed = atoi(value); + } + else if (name == "G") + { + singleGreen = atoi(value); + } + else if (name == "B") + { + singleBlue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "EndColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + end_red = atoi(value); + } + else if (name == "G") + { + end_green = atoi(value); + } + else if (name == "B") + { + end_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "FirstColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + start_red = atoi(value); + } + else if (name == "G") + { + start_green = atoi(value); + } + else if (name == "B") + { + start_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "ColorVector") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + vector_color_x = atof(value); + } + else if (name == "ScaleY") + { + vector_color_y = atof(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "FileData") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + } + + child = child.NextSiblingElement(); + } + + listView.setColor(cc.color(red, green, blue)); + listView.setOpacity(opacity); + + listView.setBackGroundColorType(colorType); + switch (colorType) + { + case Layout.BackGroundColorType.SOLID: + listView.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); + break; + + case Layout.BackGroundColorType.GRADIENT: + listView.setBackGroundColor(cc.color(start_red, start_green, start_blue), + cc.color(end_red, end_green, end_blue)); + listView.setBackGroundColorVector(Vec2(vector_color_x, vector_color_y)); + break; + + default: + break; + } + + listView.setBackGroundColorOpacity(color_opacity); + + switch (resourceType) + { + case 0: + { + listView.setBackGroundImage(xmlPath + path, Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + SpriteFrameCache.getInstance().addSpriteFramesWithFile(xmlPath + plistFile); + listView.setBackGroundImage(path, Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + + if (path != "") + { + if (scale9Enabled) + { + listView.setBackGroundImageScale9Enabled(scale9Enabled); + listView.setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); + listView.setContentSize(Size(width, height)); + } + } + +// listView.setBackGroundImageColor(cc.color(bgimg_red, bgimg_green, bgimg_blue)); +// listView.setBackGroundImageOpacity(bgimg_opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index 0adcf7acb2..80ec4051cd 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -65,7 +65,7 @@ ccs.LoadingBarReader = /** @lends ccs.LoadingBarReader# */{ break; case 1: var imageFileName = imageFileNameDic["path"]; - loadingBar.loadTexture(imageFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + loadingBar.loadTexture(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -87,9 +87,182 @@ ccs.LoadingBarReader = /** @lends ccs.LoadingBarReader# */{ loadingBar.setSize(cc.size(width, height)); } - loadingBar.setDirection(options["direction"]/*ui::LoadingBarType(options["direction"])*/); + loadingBar.setDirection(options["direction"]/*ui.LoadingBarType(options["direction"])*/); loadingBar.setPercent(options["percent"]); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var loadingBar = widget; + var options = nodeTree.loadingbaroptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + var imageFileNameDic = options.texturedata(); + var imageFileNameType = imageFileNameDic.resourcetype(); + if (imageFileNameType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + } + var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + loadingBar.loadTexture(imageFileName, imageFileNameType); + + + /* gui mark add load bar scale9 parse */ + var scale9Enable = options.scale9enable(); + loadingBar.setScale9Enabled(scale9Enable); + + + var cx = options.capinsetsx(); + var cy = options.capinsetsy(); + var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; + var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + + if (scale9Enable) { + loadingBar.setCapInsets(cc.rect(cx, cy, cw, ch)); + + } + + var widgetOptions = nodeTree.widgetoptions(); + var width = widgetOptions.width(); + var height = widgetOptions.height(); + loadingBar.setContentSize(cc.size(width, height)); + + /**/ + + loadingBar.setDirection(LoadingBar.Direction(options.direction())); + var percent = options.has_percent() ? options.percent() : 100; + loadingBar.setPercent(percent); + + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML: function(){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var loadingBar = widget; + + var xmlPath = ccs.GUIReader.getFilePath(); + + var scale9Enabled = false; + var cx = 0, cy = 0, cw = 0, ch = 0; + var swf = 0, shf = 0; + var direction = 0; + + var percent = 0; + + var opacity = 255; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ProgressType") + { + direction = (value == "Left_To_Right") ? 0 : 1; + } + else if (name == "ProgressInfo") + { + percent = atoi(value()); + } + else if (name == "Scale9Enable") + { + if (value == "True") + { + scale9Enabled = true; + } + } + else if (name == "Scale9OriginX") + { + cx = atof(value()); + } + else if (name == "Scale9OriginY") + { + cy = atof(value()); + } + else if (name == "Scale9Width") + { + cw = atof(value()); + } + else if (name == "Scale9Height") + { + ch = atof(value()); + } + else if (name == "Alpha") + { + opacity = atoi(value()); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "ImageFileData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + loadingBar.loadTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + loadingBar.loadTexture(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + loadingBar.setDirection(direction); + loadingBar.setPercent(percent); + + loadingBar.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index 429d076ff5..e198685526 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -45,5 +45,425 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ */ setPropsFromJsonDictionary: function(widget, options){ ccs.LayoutReader.setPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + + var pageView = widget; + var options = nodeTree.pageviewoptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + cc.log("options.clipable() = %d", options.clipable()); + pageView.setClippingEnabled(options.clipable()); + + var backGroundScale9Enable = options.backgroundscale9enable(); + pageView.setBackGroundImageScale9Enabled(backGroundScale9Enable); + + + var cr; + var cg; + var cb; + var scr; + var scg; + var scb; + var ecr; + var ecg; + var ecb; + + cr = options.has_bgcolorr() ? options.bgcolorr() : 150; + cg = options.has_bgcolorg() ? options.bgcolorg() : 150; + cb = options.has_bgcolorb() ? options.bgcolorb() : 150; + + scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; + scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; + scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + + ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; + ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; + ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + + var bgcv1 = 0; + var bgcv2 = -0.5; + if(options.has_vectorx()) + { + bgcv1 = options.vectorx(); + } + if(options.has_vectory()) + { + bgcv2 = options.vectory(); + } + pageView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); + + var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + + var colorType = options.has_colortype() ? options.colortype() : 1; + pageView.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + + pageView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); + pageView.setBackGroundColor(cc.color(cr, cg, cb)); + pageView.setBackGroundColorOpacity(co); + + + var imageFileNameDic = options.backgroundimagedata(); + var imageFileNameType = imageFileNameDic.resourcetype(); + if (imageFileNameType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + } + var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + pageView.setBackGroundImage(imageFileName, imageFileNameType); + + + if (backGroundScale9Enable) + { + var cx = options.capinsetsx(); + var cy = options.capinsetsy(); + var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; + var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + pageView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + var sw = options.has_scale9width(); + var sh = options.has_scale9height(); + if (sw && sh) + { + var swf = options.scale9width(); + var shf = options.scale9height(); + pageView.setContentSize(cc.size(swf, shf)); + } + } + + var widgetOptions = nodeTree.widgetoptions(); + + var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; + var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; + var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + pageView.setColor(cc.color(red, green, blue)); + + var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + pageView.setOpacity(opacity); + +// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; +// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; +// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; +// pageView.setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb)); +// +// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; +// pageView.setBackGroundImageOpacity(bgimgopacity); + + + // other commonly protperties + this.setAnchorPointForWidget(widget, nodeTree); + + var flipX = widgetOptions.flipx(); + var flipY = widgetOptions.flipy(); + widget.setFlippedX(flipX); + widget.setFlippedY(flipY); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var pageView = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var scale9Enabled = false; + var width = 0, height = 0; + var cx = 0, cy = 0, cw = 0, ch = 0; + + var colorType = ccui.Layout.BackGroundColorType.NONE; + var color_opacity = 255, bgimg_opacity = 255, opacity = 255; + var red = 255, green = 255, blue = 255; + var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; + var singleRed = 255, singleGreen = 255, singleBlue = 255; + var start_red = 255, start_green = 255, start_blue = 255; + var end_red = 255, end_green = 255, end_blue = 255; + var vector_color_x = 0, vector_color_y = -0.5; + + var resourceType = 0; + var path = "", plistFile = ""; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ClipAble") + { + pageView.setClippingEnabled((value == "True") ? true : false); + } + else if (name == "ComboBoxIndex") + { + colorType = atoi(value); + } + else if (name == "BackColorAlpha") + { + color_opacity = atoi(value); + } + else if (name == "Alpha") + { + opacity = atoi(value); + bgimg_opacity = atoi(value); + } + else if (name == "Scale9Enable") + { + scale9Enabled = (value == "True") ? true : false; + } + else if (name == "Scale9OriginX") + { + cx = atof(value); + } + else if (name == "Scale9OriginY") + { + cy = atof(value); + } + else if (name == "Scale9Width") + { + cw = atof(value); + } + else if (name == "Scale9Height") + { + ch = atof(value); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "Size") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value); + } + else if (name == "Y") + { + height = atof(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "CColor") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + red = atoi(value); + bgimg_red = atoi(value); + } + else if (name == "G") + { + green = atoi(value); + bgimg_green = atoi(value); + } + else if (name == "B") + { + blue = atoi(value); + bgimg_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "SingleColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + singleRed = atoi(value); + } + else if (name == "G") + { + singleGreen = atoi(value); + } + else if (name == "B") + { + singleBlue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "EndColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + end_red = atoi(value); + } + else if (name == "G") + { + end_green = atoi(value); + } + else if (name == "B") + { + end_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "FirstColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + start_red = atoi(value); + } + else if (name == "G") + { + start_green = atoi(value); + } + else if (name == "B") + { + start_blue = atoi(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "ColorVector") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + vector_color_x = atof(value); + } + else if (name == "ScaleY") + { + vector_color_y = atof(value); + } + + attribute = attribute.Next(); + } + } + else if (name == "FileData") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + } + + child = child.NextSiblingElement(); + } + + pageView.setColor(cc.color(red, green, blue)); + pageView.setOpacity(opacity); + + pageView.setBackGroundColorType(colorType); + switch (colorType) + { + case Layout.BackGroundColorType.SOLID: + pageView.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); + break; + + case Layout.BackGroundColorType.GRADIENT: + pageView.setBackGroundColor(cc.color(start_red, start_green, start_blue), + cc.color(end_red, end_green, end_blue)); + pageView.setBackGroundColorVector(cc.p(vector_color_x, vector_color_y)); + break; + + default: + break; + } + + pageView.setBackGroundColorOpacity(color_opacity); + + switch (resourceType) + { + case 0: + { + pageView.setBackGroundImage(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + pageView.setBackGroundImage(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + + if (path != "") + { + if (scale9Enabled) + { + pageView.setBackGroundImageScale9Enabled(scale9Enabled); + pageView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + pageView.setContentSize(cc.size(width, height)); + } + } + +// pageView.setBackGroundImageColor(Color3B(bgimg_red, bgimg_green, bgimg_blue)); +// pageView.setBackGroundImageOpacity(bgimg_opacity); + } + + }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index c91315a8e0..3ed20b84f0 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -56,5 +56,482 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ scrollView.setBounceEnabled(options["bounceEnable"]); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + + var scrollView = widget; + var options = nodeTree.scrollviewoptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + scrollView.setClippingEnabled(options.clipable()); + + var backGroundScale9Enable = options.backgroundscale9enable(); + scrollView.setBackGroundImageScale9Enabled(backGroundScale9Enable); + + + var cr; + var cg; + var cb; + var scr; + var scg; + var scb; + var ecr; + var ecg; + var ecb; + + + + cr = options.has_bgcolorr() ? options.bgcolorr() : 255; + cg = options.has_bgcolorg() ? options.bgcolorg() : 150; + cb = options.has_bgcolorb() ? options.bgcolorb() : 100; + + scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; + scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; + scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + + ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; + ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; + ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + + var bgcv1 = 0; + var bgcv2 = -0.5; + if(options.has_vectorx()) + { + bgcv1 = options.vectorx(); + } + if(options.has_vectory()) + { + bgcv2 = options.vectory(); + } + scrollView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); + + var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + + var colorType = options.has_colortype() ? options.colortype() : 1; + scrollView.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + + scrollView.setBackGroundColor(cc.color(scr, scg, scb),Color3B(ecr, ecg, ecb)); + scrollView.setBackGroundColor(cc.color(cr, cg, cb)); + scrollView.setBackGroundColorOpacity(co); + + + var imageFileNameDic = options.backgroundimagedata(); + var imageFileNameType = imageFileNameDic.resourcetype(); + if (imageFileNameType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + } + var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + scrollView.setBackGroundImage(imageFileName, imageFileNameType); + + + if (backGroundScale9Enable) + { + var cx = options.capinsetsx(); + var cy = options.capinsetsy(); + var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; + var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + scrollView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + var sw = options.has_scale9width(); + var sh = options.has_scale9height(); + if (sw && sh) + { + var swf = options.scale9width(); + var shf = options.scale9height(); + scrollView.setContentSize(cc.size(swf, shf)); + } + } + + scrollView.setLayoutType(options.layouttype()); + + var widgetOptions = nodeTree.widgetoptions(); + + var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; + var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; + var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + scrollView.setColor(cc.color(red, green, blue)); + + var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + scrollView.setOpacity(opacity); + +// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; +// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; +// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; +// scrollView.setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb)); +// +// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; +// scrollView.setBackGroundImageOpacity(bgimgopacity); + + + + + var innerWidth = options.has_innerwidth() ? options.innerwidth() : 200; + var innerHeight = options.has_innerheight() ? options.innerheight() : 200; + scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + var direction = options.has_direction() ? options.direction() : 1; + scrollView.setDirection(direction); + scrollView.setBounceEnabled(options.bounceenable()); + + + // other commonly protperties + this.setAnchorPointForWidget(widget, nodeTree); + + var flipX = widgetOptions.flipx(); + var flipY = widgetOptions.flipy(); + widget.setFlippedX(flipX); + widget.setFlippedY(flipY); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var scrollView = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var scale9Enabled = false; + var width = 0, height = 0; + var cx = 0, cy = 0, cw = 0, ch = 0.0; + + var colorType = ccui.Layout.BackGroundColorType.NONE; + var color_opacity = 255, bgimg_opacity = 255, opacity = 255; + var red = 255, green = 255, blue = 255; + var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; + var singleRed = 255, singleGreen = 255, singleBlue = 255; + var start_red = 255, start_green = 255, start_blue = 255; + var end_red = 255, end_green = 255, end_blue = 255; + var vector_color_x = 0, vector_color_y = -0; + + var direction = 1; + + var resourceType = 0; + var path = "", plistFile = ""; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ClipAble") + { + scrollView.setClippingEnabled((value == "True") ? true : false); + } + else if (name == "ComboBoxIndex") + { + colorType = atoi(value.c_str()); + } + else if (name == "BackColorAlpha") + { + color_opacity = atoi(value.c_str()); + } + else if (name == "Alpha") + { + opacity = atoi(value.c_str()); + bgimg_opacity = atoi(value.c_str()); + } + else if (name == "Scale9Enable") + { + scale9Enabled = (value == "True") ? true : false; + } + else if (name == "Scale9OriginX") + { + cx = atof(value.c_str()); + } + else if (name == "Scale9OriginY") + { + cy = atof(value.c_str()); + } + else if (name == "Scale9Width") + { + cw = atof(value.c_str()); + } + else if (name == "Scale9Height") + { + ch = atof(value.c_str()); + } + else if (name == "ScrollDirectionType") + { + if (value == "Vertical") + { + direction = 1; + } + else if (value == "Horizontal") + { + direction = 2; + } + else if (value == "Vertical_Horizontal") + { + direction = 3; + } + } + else if (name == "IsBounceEnabled") + { + scrollView.setBounceEnabled((value == "True") ? true : false); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "InnerNodeSize") + { + var attribute = child.FirstAttribute(); + var width = 0, height = 0; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Width") + { + width = atof(value.c_str()); + } + else if (name == "Height") + { + height = atof(value.c_str()); + } + + attribute = attribute.Next(); + } + + ccui.scrollView.prototype.setInnerContainerSize.call(this, cc.size(width, height)); + } + else if (name == "Size") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value.c_str()); + } + else if (name == "Y") + { + height = atof(value.c_str()); + } + + attribute = attribute.Next(); + } + } + else if (name == "CColor") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + red = atoi(value.c_str()); + bgimg_red = atoi(value.c_str()); + } + else if (name == "G") + { + green = atoi(value.c_str()); + bgimg_green = atoi(value.c_str()); + } + else if (name == "B") + { + blue = atoi(value.c_str()); + bgimg_blue = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + } + else if (name == "SingleColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + singleRed = atoi(value.c_str()); + } + else if (name == "G") + { + singleGreen = atoi(value.c_str()); + } + else if (name == "B") + { + singleBlue = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + } + else if (name == "EndColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + end_red = atoi(value.c_str()); + } + else if (name == "G") + { + end_green = atoi(value.c_str()); + } + else if (name == "B") + { + end_blue = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + } + else if (name == "FirstColor") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "R") + { + start_red = atoi(value.c_str()); + } + else if (name == "G") + { + start_green = atoi(value.c_str()); + } + else if (name == "B") + { + start_blue = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + } + else if (name == "ColorVector") + { + var attribute = child.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + vector_color_x = atof(value.c_str()); + } + else if (name == "ScaleY") + { + vector_color_y = atof(value.c_str()); + } + + attribute = attribute.Next(); + } + } + else if (name == "FileData") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + } + + child = child.NextSiblingElement(); + } + + scrollView.setColor(cc.color(red, green, blue)); + scrollView.setOpacity(opacity); + + scrollView.setBackGroundColorType(colorType); + switch (colorType) + { + case Layout.BackGroundColorType.SOLID: + scrollView.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); + break; + + case Layout.BackGroundColorType.GRADIENT: + scrollView.setBackGroundColor(cc.color(start_red, start_green, start_blue), + cc.color(end_red, end_green, end_blue)); + scrollView.setBackGroundColorVector(cc.p(vector_color_x, vector_color_y)); + break; + + default: + break; + } + + scrollView.setBackGroundColorOpacity(color_opacity); + + switch (resourceType) + { + case 0: + { + scrollView.setBackGroundImage(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + scrollView.setBackGroundImage(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + + if (path != "") + { + if (scale9Enabled) + { + scrollView.setBackGroundImageScale9Enabled(scale9Enabled); + scrollView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + scrollView.setContentSize(cc.size(width, height)); + } + } + + scrollView.setDirection(direction); + +// scrollView.setBackGroundImageColor(Color3B(bgimg_red, bgimg_green, bgimg_blue)); +// scrollView.setBackGroundImageOpacity(bgimg_opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index f2f3a66ea3..e86de5cfff 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -71,7 +71,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadBarTexture(imageFileName_tp); break; case 1: - slider.loadBarTexture(imageFileName, 1 /*ui::UI_TEX_TYPE_PLIST*/); + slider.loadBarTexture(imageFileName, 1 /*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -87,7 +87,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadBarTexture(imageFileName_tp); break; case 1: - slider.loadBarTexture(imageFileName, 1 /*ui::UI_TEX_TYPE_PLIST*/); + slider.loadBarTexture(imageFileName, 1 /*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -104,7 +104,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadSlidBallTextureNormal(normalFileName_tp); break; case 1: - slider.loadSlidBallTextureNormal(normalFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + slider.loadSlidBallTextureNormal(normalFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -125,7 +125,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadSlidBallTexturePressed(pressedFileName_tp); break; case 1: - slider.loadSlidBallTexturePressed(pressedFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + slider.loadSlidBallTexturePressed(pressedFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -141,7 +141,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadSlidBallTextureDisabled(disabledFileName_tp); break; case 1: - slider.loadSlidBallTextureDisabled(disabledFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + slider.loadSlidBallTextureDisabled(disabledFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; @@ -157,12 +157,419 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadProgressBarTexture(imageProgressFileName_tp); break; case 1: - slider.loadProgressBarTexture(imageProgressFileName, 1/*ui::UI_TEX_TYPE_PLIST*/); + slider.loadProgressBarTexture(imageProgressFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); break; default: break; } ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + + var slider = widget; + var options = nodeTree.slideroptions(); + + var protocolBuffersPath = ccs.uiReader.getFilePath(); + + var barTextureScale9Enable = options.scale9enable(); + slider.setScale9Enabled(barTextureScale9Enable); + + slider.setPercent(options.percent()); + + + // var bt = DICTOOL.checkObjectExist_json(options, P_BarFileName); + var barLength = options.has_length() ? options.length() : 290; + + var imageFileNameDic = options.barfilenamedata(); + var imageFileNameType = imageFileNameDic.resourcetype(); + if (imageFileNameType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + } + var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + slider.loadBarTexture(imageFileName, imageFileNameType); + + + + if (barTextureScale9Enable) + { + slider.setContentSize(cc.size(barLength, slider.getContentSize().height)); + } + + //loading normal slider ball texture + var normalDic = options.ballnormaldata(); + var normalType = normalDic.resourcetype(); + if (normalType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + normalDic.plistfile()); + } + imageFileName = this.getResourcePath(normalDic.path(), normalType); + slider.loadSlidBallTextureNormal(imageFileName, normalType); + + + //loading slider ball press texture + var pressedDic = options.ballpresseddata(); + var pressedType = pressedDic.resourcetype(); + if (pressedType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + pressedDic.plistfile()); + } + var pressedFileName = this.getResourcePath(pressedDic.path(), pressedType); + slider.loadSlidBallTexturePressed(pressedFileName, pressedType); + + //loading silder ball disable texture + var disabledDic = options.balldisableddata(); + var disabledType = disabledDic.resourcetype(); + if (disabledType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + disabledDic.plistfile()); + } + var disabledFileName = this.getResourcePath(disabledDic.path(), disabledType); + slider.loadSlidBallTextureDisabled(disabledFileName, disabledType); + + //load slider progress texture + var progressBarDic = options.progressbardata(); + var progressBarType = progressBarDic.resourcetype(); + if (progressBarType == 1) + { + cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + progressBarDic.plistfile()); + } + var progressBarFileName = this.getResourcePath(progressBarDic.path(), progressBarType); + slider.loadProgressBarTexture(progressBarFileName, progressBarType); + + var displaystate = true; + if(options.has_displaystate()) + { + displaystate = options.displaystate(); + } + slider.setBright(displaystate); + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML:function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var slider = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var scale9Enabled = false; + var cx = 0, cy = 0, cw = 0, ch = 0; + var swf = 0, shf = 0; + + var percent = 0; + + var opacity = 255; + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Scale9Enable") + { + if (value == "True") + { + scale9Enabled = true; + } + } + else if (name == "Scale9OriginX") + { + cx = atof(value.c_str()); + } + else if (name == "Scale9OriginY") + { + cy = atof(value.c_str()); + } + else if (name == "Scale9Width") + { + cw = atof(value.c_str()); + } + else if (name == "Scale9Height") + { + ch = atof(value.c_str()); + } + else if (name == "Length") + { + + } + else if (name == "PercentInfo") + { + percent = atoi(value.c_str()); + } + else if (name == "DisplayState") + { + slider.setBright((value == "True") ? true : false); + if (value == "False") + { + slider.setTouchEnabled(false); + } + } + else if (name == "Alpha") + { + opacity = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "BackGroundData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + slider.loadBarTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + slider.loadBarTexture(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "BallNormalData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + slider.loadSlidBallTextureNormal(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + slider.loadSlidBallTextureNormal(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "BallPressedData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + slider.loadSlidBallTexturePressed(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + slider.loadSlidBallTexturePressed(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "BallDisabledData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + slider.loadSlidBallTextureDisabled(xmlPath + path, Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + slider.loadSlidBallTextureDisabled(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + else if (name == "ProgressBarData") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + slider.loadProgressBarTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + break; + } + + case 1: + { + cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); + slider.loadProgressBarTexture(path, ccui.Widget.TextureResType.PLIST); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + slider.setScale9Enabled(scale9Enabled); + + if (scale9Enabled) + { + slider.setCapInsets(cc.rect(cx, cy, cw, ch)); + slider.setContentSize(cc.size(swf, shf)); + } + + slider.setPercent(percent); + + slider.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index 9ec1481ffd..35e2129867 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -93,5 +93,236 @@ ccs.TextFieldReader = /** @lends ccs.TextFieldReader# */{ textField.setTextVerticalAlignment(va); ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + var textField = widget; + var options = nodeTree.textfieldoptions(); + + var protocolBuffersPath = GUIReader.getInstance().getFilePath(); + + var IsCustomSize = options.iscustomsize(); + widget.ignoreContentAdaptWithSize(!IsCustomSize); + + if (IsCustomSize) + { + var widgetOptions = nodeTree.widgetoptions(); + textField.setContentSize(cc.size(widgetOptions.width(), widgetOptions.height())); + } + + ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.prototype.setAnchorPointForWidget.call(this, widget, nodeTree); + + textField.setUnifySizeEnabled(false); + + var ph = options.has_placeholder(); + if (ph) + { + var placeholder = options.has_placeholder() ? options.placeholder() : "inputs words here"; + textField.setPlaceHolder(placeholder); + } + var text = options.has_text() ? options.text() : "Text Field"; + textField.setText(text); + + var fontSize = options.has_fontsize() ? options.fontsize() : 20; + textField.setFontSize(fontSize); + + + var fontName = options.has_fontname() ? options.fontname() : "微软雅黑"; + textField.setFontName(fontName); + + // var tsw = options.has_touchsizewidth(); + // var tsh = options.has_touchsizeheight(); + // if (tsw && tsh) + // { + // textField.setTouchSize(Size(options.touchsizewidth(), options.touchsizeheight())); + // } + + // var dw = DICTOOL.getFloatValue_json(options, "width"); + // var dh = DICTOOL.getFloatValue_json(options, "height"); + // if (dw > 0.0f || dh > 0.0f) + // { + // //textField.setSize(Size(dw, dh)); + // } + var maxLengthEnable = options.maxlengthenable(); + textField.setMaxLengthEnabled(maxLengthEnable); + + if (maxLengthEnable) + { + var maxLength = options.has_maxlength() ? options.maxlength() : 10; + textField.setMaxLength(maxLength); + } + var passwordEnable = options.passwordenable(); + textField.setPasswordEnabled(passwordEnable); + if (passwordEnable) + { + var passwordStyleText = options.has_passwordstyletext() ? options.passwordstyletext() : "*"; + textField.setPasswordStyleText(passwordStyleText.c_str()); + } + + if (options.has_fontresource()) + { + var resourceData = options.fontresource(); + textField.setFontName(protocolBuffersPath + resourceData.path()); + } + + // other commonly protperties + ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + }, + + setPropsFromXML: function(widget, objectData){ + ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + + var textField = widget; + + var xmlPath = ccs.uiReader.getFilePath(); + + var isCustomSize = false; + var width = 0, height = 0; + + var opacity = 255; + + textField.setUnifySizeEnabled(false); + + textField.setFontName("微软雅黑"); + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "PlaceHolderText") + { + textField.setPlaceHolder(value); + } + else if (name == "LabelText") + { + textField.setText(value); + } + else if (name == "FontSize") + { + textField.setFontSize(atoi(value.c_str())); + } + else if (name == "FontName") + { + textField.setFontName(value); + } + else if (name == "MaxLengthEnable") + { + textField.setMaxLengthEnabled((value == "True") ? true : false); + } + else if (name == "MaxLengthText") + { + textField.setMaxLength(atoi(value.c_str())); + } + else if (name == "PasswordEnable") + { + textField.setPasswordEnabled((value == "True") ? true : false); + } + else if (name == "PasswordStyleText") + { + textField.setPasswordStyleText(value.c_str()); + } + else if (name == "IsCustomSize") + { + isCustomSize = ((value == "True") ? true : false); +// if (value == "Custom") +// { +// var areaWidth = 0.0f; +// objectData.QueryFloatAttribute("Width", &areaWidth); +// +// var areaHeight = 0.0f; +// objectData.QueryFloatAttribute("Height", &areaHeight); +// +// textField.setTextAreaSize(Size(areaWidth, areaHeight)); +// } + } + else if (name == "Alpha") + { + opacity = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + + // child elements + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + + if (name == "Size") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value.c_str()); + } + else if (name == "Y") + { + height = atof(value.c_str()); + } + + attribute = attribute.Next(); + } + } + else if (name == "FontResource") + { + var attribute = child.FirstAttribute(); + var resourceType = 0; + var path = "", plistFile = ""; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; + } + else if (name == "Plist") + { + plistFile = value; + } + + attribute = attribute.Next(); + } + + switch (resourceType) + { + case 0: + { + textField.setFontName(xmlPath + path); + break; + } + + default: + break; + } + } + + child = child.NextSiblingElement(); + } + + if (isCustomSize) + { + textField.ignoreContentAdaptWithSize(!isCustomSize); + textField.setContentSize(Size(width, height)); + } + + textField.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 94aa8fbbd5..2e54844281 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -180,5 +180,402 @@ ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ cc.assert(0, "invalid TextureResType!!!"); } return imageFileName_tp; + }, + + setPropsFromProtocolBuffers: function(widget, nodeTree){ + var options = nodeTree.widgetoptions(); + + widget.setCascadeColorEnabled(true); + widget.setCascadeOpacityEnabled(true); + + widget.setUnifySizeEnabled(true); + + var ignoreSizeExsit = options.has_ignoresize(); + if (ignoreSizeExsit) + { + widget.ignoreContentAdaptWithSize(options.ignoresize()); + } + + widget.setSizeType(options.sizetype()); + widget.setPositionType(options.positiontype()); + + widget.setSizePercent(cc.p(options.sizepercentx(), options.sizepercenty())); + widget.setPositionPercent(cc.p(options.positionpercentx(), options.positionpercenty())); + + var w = options.width(); + var h = options.height(); + widget.setContentSize(cc.size(w, h)); + + widget.setTag(options.tag()); + widget.setActionTag(options.actiontag()); + widget.setTouchEnabled(options.touchable()); + var name = options.name().c_str(); + var widgetName = name ? name : "default"; + widget.setName(widgetName); + + var x = options.x(); + var y = options.y(); + widget.setPosition(cc.p(x, y)); + + if(options.has_alpha()) + { + widget.setOpacity(options.alpha()); + } + + widget.setScaleX(options.has_scalex() ? options.scalex() : 1.0); + + + widget.setScaleY(options.has_scaley() ? options.scaley() : 1.0); + + +// widget.setRotation(options.has_rotation() ? options.rotation() : 0.0); + + widget.setRotationSkewX(options.has_rotationskewx() ? options.rotationskewx() : 0.0); + + widget.setRotationSkewY(options.has_rotationskewy() ? options.rotationskewy() : 0.0); + + var vb = options.has_visible(); + if (vb) + { + widget.setVisible(options.visible()); + } + + var z = options.zorder(); + widget.setLocalZOrder(z); + + + var layout = options.has_layoutparameter(); + if (layout) + { + + var layoutParameterDic = options.layoutparameter();; + var paramType = layoutParameterDic.type(); + + var parameter = null; + switch (paramType) + { + case 0: + break; + case 1: + { + parameter = LinearLayoutParameter.create(); + var gravity = layoutParameterDic.gravity(); + parameter.setGravity(gravity); + break; + } + case 2: + { + parameter = RelativeLayoutParameter.create(); + var rParameter = parameter; + var relativeName = layoutParameterDic.relativename().c_str(); + rParameter.setRelativeName(relativeName); + var relativeToName = layoutParameterDic.relativetoname().c_str(); + rParameter.setRelativeToWidgetName(relativeToName); + var align = layoutParameterDic.align(); + rParameter.setAlign(align); + break; + } + default: + break; + } + if (parameter) + { + var mgl = layoutParameterDic.marginleft(); + var mgt = layoutParameterDic.margintop(); + var mgr = layoutParameterDic.marginright(); + var mgb = layoutParameterDic.margindown(); + parameter.setMargin(Margin(mgl, mgt, mgr, mgb)); + widget.setLayoutParameter(parameter); + } + } + }, + + setColorPropsFromProtocolBuffers: function(widget, nodeTree){ + var options = nodeTree.widgetoptions(); + + + var isColorRExists = options.has_colorr(); + var isColorGExists = options.has_colorg(); + var isColorBExists = options.has_colorb(); + + var colorR = options.colorr(); + var colorG = options.colorg(); + var colorB = options.colorb(); + + if (isColorRExists && isColorGExists && isColorBExists) + { + widget.setColor(cc.color(colorR, colorG, colorB)); + } + + this.setAnchorPointForWidget(widget, nodeTree); + + var flipX = options.flipx(); + var flipY = options.flipy(); + widget.setFlippedX(flipX); + widget.setFlippedY(flipY); + }, + + setPropsFromXML: function(widget, objectData){ + widget.setTouchEnabled(false); + + widget.setCascadeColorEnabled(true); + widget.setCascadeOpacityEnabled(true); + + widget.setUnifySizeEnabled(true); + + widget.setScale(0, 0); + + // attributes + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "Name") + { + var widgetName = value.c_str() ? value.c_str() :"default"; + widget.setName(widgetName); + } + else if (name == "ActionTag") + { + var actionTag = atoi(value.c_str()); + widget.setUserObject(timeline.ActionTimelineData.create(actionTag)); + } + else if (name == "RotationSkewX") + { + widget.setRotationSkewX(atof(value.c_str())); + } + else if (name == "RotationSkewY") + { + widget.setRotationSkewY(atof(value.c_str())); + } + else if (name == "Rotation") + { +// widget.setRotation(atoi(value.c_str())); + } + else if (name == "ZOrder") + { + widget.setLocalZOrder(atoi(value.c_str())); + } + else if (name == "Visible") + { + widget.setVisible((value == "True") ? true : false); + } + else if (name == "VisibleForFrame") + { +// widget.setVisible((value == "True") ? true : false); + } + else if (name == "Alpha") + { + widget.setOpacity(atoi(value.c_str())); + } + else if (name == "Tag") + { + widget.setTag(atoi(value.c_str())); + } + else if (name == "FlipX") + { + widget.setFlippedX((value == "True") ? true : false); + } + else if (name == "FlipY") + { + widget.setFlippedY((value == "True") ? true : false); + } + else if (name == "TouchEnable") + { + widget.setTouchEnabled((value == "True") ? true : false); + } + else if (name == "ControlSizeType") + { + widget.ignoreContentAdaptWithSize((value == "Auto") ? true : false); + } + + attribute = attribute.Next(); + } + + var child = objectData.FirstChildElement(); + while (child) + { + var name = child.Name(); + if (name == "Children") + { + break; + } + else if (name == "Position") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + widget.setPositionX(atof(value.c_str())); + } + else if (name == "Y") + { + widget.setPositionY(atof(value.c_str())); + } + + attribute = attribute.Next(); + } + } + else if (name == "Scale") + { + var attribute = child.FirstAttribute(); + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + widget.setScaleX(atof(value.c_str())); + } + else if (name == "ScaleY") + { + widget.setScaleY(atof(value.c_str())); + } + + attribute = attribute.Next(); + } + } + else if (name == "AnchorPoint") + { + var attribute = child.FirstAttribute(); + var anchor_x = 0, anchor_y = 0; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ScaleX") + { + anchor_x = atof(value.c_str()); + } + else if (name == "ScaleY") + { + anchor_y = atof(value.c_str()); + } + + attribute = attribute.Next(); + } + + widget.setAnchorPoint(cc.p(anchor_x, anchor_y)); + } + else if (name == "CColor") + { + var attribute = child.FirstAttribute(); + var red = 255, green = 255, blue = 255; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "A") + { + widget.setOpacity(atoi(value.c_str())); + } + else if (name == "R") + { + red = atoi(value.c_str()); + } + else if (name == "G") + { + green = atoi(value.c_str()); + } + else if (name == "B") + { + blue = atoi(value.c_str()); + } + + attribute = attribute.Next(); + } + + widget.setColor(Color3B(red, green, blue)); + } + else if (name == "Size") + { + var attribute = child.FirstAttribute(); + var width = 0, height = 0; + + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "X") + { + width = atof(value.c_str()); + } + else if (name == "Y") + { + height = atof(value.c_str()); + } + + attribute = attribute.Next(); + } + + widget.setContentSize(cc.size(width, height)); + } + + child = child.NextSiblingElement(); + } + }, + + setAnchorPointForWidget: function(widget, nodeTree){ + var options = nodeTree.widgetoptions(); + + var isAnchorPointXExists = options.has_anchorpointx(); + var anchorPointXInFile; + if (isAnchorPointXExists) + { + anchorPointXInFile = options.anchorpointx(); + } + else + { + anchorPointXInFile = widget.getAnchorPoint().x; + } + + var isAnchorPointYExists = options.has_anchorpointy(); + var anchorPointYInFile; + if (isAnchorPointYExists) + { + anchorPointYInFile = options.anchorpointy(); + } + else + { + anchorPointYInFile = widget.getAnchorPoint().y; + } + + if (isAnchorPointXExists || isAnchorPointYExists) + { + widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); + } + }, + + getResourcePath: function(path, texType){ + var filePath = ccs.uiReader.getFilePath(); + var imageFileName = path; + var imageFileName_tp; + if (null != imageFileName && 0 != "" != imageFileName) + { + if (texType == ccui.Widget.TextureResType.LOCAL) { + imageFileName_tp = filePath + imageFileName; + } + else if(texType == ccui.Widget.TextureResType.PLIST){ + imageFileName_tp = imageFileName; + } + else{ + cc.assert(0, "invalid TextureResType!!!"); + } + } + return imageFileName_tp; } }; \ No newline at end of file diff --git a/external/protobuf/ByteBuffer.min.js b/external/protobuf/ByteBuffer.min.js new file mode 100644 index 0000000000..fcb130c588 --- /dev/null +++ b/external/protobuf/ByteBuffer.min.js @@ -0,0 +1,85 @@ +/* +ByteBuffer.js (c) 2013-2014 Daniel Wirtz +This version of ByteBuffer.js uses an ArrayBuffer (AB) as its backing buffer and is compatible with modern browsers. +Released under the Apache License, Version 2.0 +see: https://github.com/dcodeIO/ByteBuffer.js for details +*/ +(function(s){function u(k){function g(a,b,c){"undefined"===typeof a&&(a=g.DEFAULT_CAPACITY);"undefined"===typeof b&&(b=g.DEFAULT_ENDIAN);"undefined"===typeof c&&(c=g.DEFAULT_NOASSERT);if(!c){a|=0;if(0>a)throw RangeError("Illegal capacity");b=!!b;c=!!c}this.buffer=0===a?s:new ArrayBuffer(a);this.view=0===a?null:new DataView(this.buffer);this.offset=0;this.markedOffset=-1;this.limit=a;this.littleEndian="undefined"!==typeof b?!!b:!1;this.noAssert=!!c}function m(a){var b=0;return function(){return b< +a.length?a.charCodeAt(b++):null}}function t(){var a=[],b=[];return function(){if(0===arguments.length)return b.join("")+u.apply(String,a);1024=e||(d.set((new Uint8Array(c.buffer)).subarray(c.offset,c.limit),b.offset),b.offset+=e);b.limit=b.offset;b.offset=0;return b};g.isByteBuffer=function(a){return!0===(a&&a instanceof +g)};g.type=function(){return ArrayBuffer};g.wrap=function(a,b,c,d){"string"!==typeof b&&(d=c,c=b,b=void 0);if("string"===typeof a)switch("undefined"===typeof b&&(b="utf8"),b){case "base64":return g.fromBase64(a,c);case "hex":return g.fromHex(a,c);case "binary":return g.fromBinary(a,c);case "utf8":return g.fromUTF8(a,c);case "debug":return g.fromDebug(a,c);default:throw Error("Unsupported encoding: "+b);}if(null===a||"object"!==typeof a)throw TypeError("Illegal buffer");if(g.isByteBuffer(a))return b= +e.clone.call(a),b.markedOffset=-1,b;if(a instanceof Uint8Array)b=new g(0,c,d),0>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*= +2)>b?d:b);this.view.setInt8(b-1,a);c&&(this.offset+=1);return this};e.writeByte=e.writeInt8;e.readInt8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view.getInt8(a);b&&(this.offset+=1);return a};e.readByte=e.readInt8;e.writeUint8=function(a,b){var c= +"undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setUint8(b-1,a);c&&(this.offset+=1);return this};e.readUint8= +function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view.getUint8(a);b&&(this.offset+=1);return a};e.writeInt16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+ +a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setInt16(b-2,a,this.littleEndian);c&&(this.offset+=2);return this};e.writeShort=e.writeInt16;e.readInt16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== +typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}a=this.view.getInt16(a,this.littleEndian);b&&(this.offset+=2);return a};e.readShort=e.readInt16;e.writeUint16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b|| +0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setUint16(b-2,a,this.littleEndian);c&&(this.offset+=2);return this};e.readUint16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)"); +a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}a=this.view.getUint16(a,this.littleEndian);b&&(this.offset+=2);return a};e.writeInt32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ +b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setInt32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};e.writeInt=e.writeInt32;e.readInt32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength); +}a=this.view.getInt32(a,this.littleEndian);b&&(this.offset+=4);return a};e.readInt=e.readInt32;e.writeUint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+= +4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setUint32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};e.readUint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=this.view.getUint32(a,this.littleEndian);b&&(this.offset+= +4);return a};k&&(e.writeInt64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a&&(a=k.fromNumber(a));b+= +8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;this.littleEndian?(this.view.setInt32(b,a.low,!0),this.view.setInt32(b+4,a.high,!0)):(this.view.setInt32(b,a.high,!1),this.view.setInt32(b+4,a.low,!1));c&&(this.offset+=8);return this},e.writeLong=e.writeInt64,e.readInt64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ +a+" (+8) <= "+this.buffer.byteLength);}a=this.littleEndian?new k(this.view.getInt32(a,!0),this.view.getInt32(a+4,!0),!1):new k(this.view.getInt32(a+4,!1),this.view.getInt32(a,!1),!1);b&&(this.offset+=8);return a},e.readLong=e.readInt64,e.writeUint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+ +b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a&&(a=k.fromNumber(a));b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;this.littleEndian?(this.view.setInt32(b,a.low,!0),this.view.setInt32(b+4,a.high,!0)):(this.view.setInt32(b,a.high,!1),this.view.setInt32(b+4,a.low,!1));c&&(this.offset+=8);return this},e.readUint64=function(a){var b="undefined"===typeof a;b&&(a= +this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=this.littleEndian?new k(this.view.getInt32(a,!0),this.view.getInt32(a+4,!0),!0):new k(this.view.getInt32(a+4,!1),this.view.getInt32(a,!1),!0);b&&(this.offset+=8);return a});e.writeFloat32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!== +typeof a)throw TypeError("Illegal value: "+a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setFloat32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};e.writeFloat=e.writeFloat32;e.readFloat32=function(a){var b="undefined"===typeof a; +b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=this.view.getFloat32(a,this.littleEndian);b&&(this.offset+=4);return a};e.readFloat=e.readFloat32;e.writeFloat64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a)throw TypeError("Illegal value: "+ +a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setFloat64(b-8,a,this.littleEndian);c&&(this.offset+=8);return this};e.writeDouble=e.writeFloat64;e.readFloat64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== +typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=this.view.getFloat64(a,this.littleEndian);b&&(this.offset+=8);return a};e.readDouble=e.readFloat64;g.MAX_VARINT32_BYTES=5;g.calculateVarint32=function(a){a>>>=0;return 128>a?1:16384>a?2:2097152>a?3:268435456>a?4:5};g.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0};g.zigZagDecode32=function(a){return a>>> +1^-(a&1)|0};e.writeVarint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=g.calculateVarint32(a);b+=d;var f=this.buffer.byteLength;b>f&&this.resize((f*=2)> +b?f:b);b-=d;this.view.setUint8(b,d=a|128);a>>>=0;128<=a?(d=a>>7|128,this.view.setUint8(b+1,d),16384<=a?(d=a>>14|128,this.view.setUint8(b+2,d),2097152<=a?(d=a>>21|128,this.view.setUint8(b+3,d),268435456<=a?(this.view.setUint8(b+4,a>>28&15),d=5):(this.view.setUint8(b+3,d&127),d=4)):(this.view.setUint8(b+2,d&127),d=3)):(this.view.setUint8(b+1,d&127),d=2)):(this.view.setUint8(b,d&127),d=1);return c?(this.offset+=d,this):d};e.writeVarint32ZigZag=function(a,b){return this.writeVarint32(g.zigZagEncode32(a), +b)};e.readVarint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=0,d=0,f;do{f=a+c;if(!this.noAssert&&f>this.limit)throw a=Error("Truncated"),a.truncated=!0,a;f=this.view.getUint8(f);5>c&&(d|=(f&127)<<7*c>>>0);++c}while(128===(f&128));d|=0;return b?(this.offset+= +c,d):{value:d,length:c}};e.readVarint32ZigZag=function(a){a=this.readVarint32(a);"object"===typeof a?a.value=g.zigZagDecode32(a.value):a=g.zigZagDecode32(a);return a};k&&(g.MAX_VARINT64_BYTES=10,g.calculateVarint64=function(a){"number"===typeof a&&(a=k.fromNumber(a));var b=a.toInt()>>>0,c=a.shiftRightUnsigned(28).toInt()>>>0;a=a.shiftRightUnsigned(56).toInt()>>>0;return 0==a?0==c?16384>b?128>b?1:2:2097152>b?3:4:16384>c?128>c?5:6:2097152>c?7:8:128>a?9:10},g.zigZagEncode64=function(a){"number"===typeof a? +a=k.fromNumber(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},g.zigZagDecode64=function(a){"number"===typeof a?a=k.fromNumber(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftRightUnsigned(1).xor(a.and(k.ONE).toSigned().negate()).toSigned()},e.writeVarint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+ +" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a,!1):!1!==a.unsigned&&(a=a.toSigned());var d=g.calculateVarint64(a),f=a.toInt()>>>0,n=a.shiftRightUnsigned(28).toInt()>>>0,e=a.shiftRightUnsigned(56).toInt()>>>0;b+=d;var r=this.buffer.byteLength;b>r&&this.resize((r*=2)>b?r: +b);b-=d;switch(d){case 10:this.view.setUint8(b+9,e>>>7&1);case 9:this.view.setUint8(b+8,9!==d?e|128:e&127);case 8:this.view.setUint8(b+7,8!==d?n>>>21|128:n>>>21&127);case 7:this.view.setUint8(b+6,7!==d?n>>>14|128:n>>>14&127);case 6:this.view.setUint8(b+5,6!==d?n>>>7|128:n>>>7&127);case 5:this.view.setUint8(b+4,5!==d?n|128:n&127);case 4:this.view.setUint8(b+3,4!==d?f>>>21|128:f>>>21&127);case 3:this.view.setUint8(b+2,3!==d?f>>>14|128:f>>>14&127);case 2:this.view.setUint8(b+1,2!==d?f>>>7|128:f>>>7& +127);case 1:this.view.setUint8(b,1!==d?f|128:f&127)}return c?(this.offset+=d,this):d},e.writeVarint64ZigZag=function(a,b){return this.writeVarint64(g.zigZagEncode64(a),b)},e.readVarint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d=0,f=0,e=0,h=0, +h=this.view.getUint8(a++),d=h&127;if(h&128&&(h=this.view.getUint8(a++),d|=(h&127)<<7,h&128&&(h=this.view.getUint8(a++),d|=(h&127)<<14,h&128&&(h=this.view.getUint8(a++),d|=(h&127)<<21,h&128&&(h=this.view.getUint8(a++),f=h&127,h&128&&(h=this.view.getUint8(a++),f|=(h&127)<<7,h&128&&(h=this.view.getUint8(a++),f|=(h&127)<<14,h&128&&(h=this.view.getUint8(a++),f|=(h&127)<<21,h&128&&(h=this.view.getUint8(a++),e=h&127,h&128&&(h=this.view.getUint8(a++),e|=(h&127)<<7,h&128))))))))))throw Error("Buffer overrun"); +d=k.fromBits(d|f<<28,f>>>4|e<<24,!1);return b?(this.offset=a,d):{value:d,length:a-c}},e.readVarint64ZigZag=function(a){(a=this.readVarint64(a))&&a.value instanceof k?a.value=g.zigZagDecode64(a.value):a=g.zigZagDecode64(a);return a});e.writeCString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);var d,f=a.length;if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");for(d=0;d>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}d=b;f=l.a(m(a))[1];b+=f+1;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=f+1;l.c(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));this.view.setUint8(b++,0);return c?(this.offset=b-d,this):f};e.readCString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== +typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d,f=-1;l.b(function(){if(0===f)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return 0===(f=this.view.getUint8(a++))?null:f}.bind(this),d=t(),!0);return b?(this.offset=a,d()):{string:d(),length:a-c}};e.writeIString=function(a,b){var c="undefined"=== +typeof b;c&&(b=this.offset);if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f;f=l.a(m(a),this.noAssert)[1];b+=4+f;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=4+f;this.view.setUint32(b,f,this.littleEndian);b+=4;l.c(m(a),function(a){this.view.setUint8(b++, +a)}.bind(this));if(b!==d+4+f)throw RangeError("Illegal range: Truncated data, "+b+" == "+(b+4+f));return c?(this.offset=b,this):b-d};e.readIString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=0,d=a,c=this.view.getUint32(a,this.littleEndian);a+=4;var f= +a+c;l.b(function(){return a>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d, +f=b;d=l.a(m(a))[1];b+=d;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=d;l.c(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));return c?(this.offset=b,this):b-f};e.writeString=e.writeUTF8String;g.calculateUTF8Chars=function(a){return l.a(m(a))[0]};g.calculateUTF8Bytes=function(a){return l.a(m(a))[1]};e.readUTF8String=function(a,b,c){"number"===typeof b&&(c=b,b=void 0);var d="undefined"===typeof c;d&&(c=this.offset);"undefined"===typeof b&&(b=g.METRICS_CHARS);if(!this.noAssert){if("number"!== +typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}var f=0,e=c,h;if(b===g.METRICS_CHARS){h=t();l.g(function(){return f>>=0;if(0>c||c+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+"+a+") <= "+this.buffer.byteLength);}var r=c+a;l.b(function(){return c>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d= +b,f,e;f=l.a(m(a),this.noAssert)[1];e=g.calculateVarint32(f);b+=e+f;var h=this.buffer.byteLength;b>h&&this.resize((h*=2)>b?h:b);b-=e+f;b+=this.writeVarint32(f,b);l.c(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));if(b!==d+f+e)throw RangeError("Illegal range: Truncated data, "+b+" == "+(b+f+e));return c?(this.offset=b,this):b-d};e.readVString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)"); +a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=this.readVarint32(a),d=a;a+=c.length;var c=c.value,f=a+c,c=t();l.b(function(){return a>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof g||(a=g.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;c+=b;var f=this.buffer.byteLength;c>f&&this.resize((f*=2)>c?f:c);(new Uint8Array(this.buffer,c-b)).set((new Uint8Array(a.buffer)).subarray(a.offset,a.limit));a.offset+=b;d&&(this.offset+=b);return this};e.appendTo=function(a,b){a.append(this, +b);return this};e.assert=function(a){this.noAssert=!a;return this};e.capacity=function(){return this.buffer.byteLength};e.clear=function(){this.offset=0;this.limit=this.buffer.byteLength;this.markedOffset=-1;return this};e.clone=function(a){var b=new g(0,this.littleEndian,this.noAssert);a?(a=new ArrayBuffer(this.buffer.byteLength),(new Uint8Array(a)).set(this.buffer),b.buffer=a,b.view=new DataView(a)):(b.buffer=this.buffer,b.view=this.view);b.offset=this.offset;b.markedOffset=this.markedOffset;b.limit= +this.limit;return b};e.compact=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(0===a&&b===this.buffer.byteLength)return this;var c=b-a;if(0=== +c)return this.buffer=s,this.view=null,0<=this.markedOffset&&(this.markedOffset-=a),this.limit=this.offset=0,this;var d=new ArrayBuffer(c);(new Uint8Array(d)).set((new Uint8Array(this.buffer)).subarray(a,b));this.buffer=d;this.view=new DataView(d);0<=this.markedOffset&&(this.markedOffset-=a);this.offset=0;this.limit=c;return this};e.copy=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer"); +a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return new g(0,this.littleEndian,this.noAssert);var c=b-a,d=new g(c,this.littleEndian,this.noAssert);d.offset=0;d.limit=c;0<=d.markedOffset&&(d.markedOffset-=a);this.copyTo(d,0,a,b);return d};e.copyTo=function(a,b,c,d){var f,e;if(!this.noAssert&&!g.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer"); +b=(e="undefined"===typeof b)?a.offset:b|0;c=(f="undefined"===typeof c)?this.offset:c|0;d="undefined"===typeof d?this.limit:d|0;if(0>b||b>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+b+" <= "+a.buffer.byteLength);if(0>c||d>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+c+" <= "+this.buffer.byteLength);var h=d-c;if(0===h)return a;a.ensureCapacity(b+h);(new Uint8Array(a.buffer)).set((new Uint8Array(this.buffer)).subarray(c,d),b);f&&(this.offset+=h);e&&(a.offset+= +h);return this};e.ensureCapacity=function(a){var b=this.buffer.byteLength;return ba?b:a):this};e.fill=function(a,b,c){var d="undefined"===typeof b;d&&(b=this.offset);"string"===typeof a&&0>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal end: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(b>=c)return this;for(;b>>=0;if(0>a||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength);}this.markedOffset=a;return this};e.order=function(a){if(!this.noAssert&&"boolean"!==typeof a)throw TypeError("Illegal littleEndian: Not a boolean");this.littleEndian=!!a;return this};e.LE=function(a){this.littleEndian="undefined"!==typeof a?!!a:!0;return this};e.BE=function(a){this.littleEndian="undefined"!==typeof a?!a:!1;return this};e.prepend=function(a, +b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var d="undefined"===typeof c;d&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof g||(a=g.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;var f=b-c,e;if(0a)throw RangeError("Illegal capacity: 0 <= "+a);}this.buffer.byteLength>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return this;Array.prototype.reverse.call((new Uint8Array(this.buffer)).subarray(a, +b));this.view=new DataView(this.buffer);return this};e.skip=function(a){if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var b=this.offset+a;if(!this.noAssert&&(0>b||b>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);this.offset=b;return this};e.slice=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!== +typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c=this.clone();c.offset=a;c.limit=b;return c};e.toBuffer=function(a){var b=this.offset,c=this.limit;if(b>c)var d=b,b=c,c=d;if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: Not an integer"); +b>>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal limit: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(!a&&0===b&&c===this.buffer.byteLength)return this.buffer;if(b===c)return s;a=new ArrayBuffer(c-b);(new Uint8Array(a)).set((new Uint8Array(this.buffer)).subarray(b,c),0);return a};e.toArrayBuffer=e.toBuffer;e.toString=function(a,b,c){if("undefined"===typeof a)return"ByteBufferAB(offset="+ +this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";"number"===typeof a&&(c=b=a="utf8");switch(a){case "utf8":return this.toUTF8(b,c);case "base64":return this.toBase64(b,c);case "hex":return this.toHex(b,c);case "binary":return this.toBinary(b,c);case "debug":return this.toDebug();case "columns":return this.m();default:throw Error("Unsupported encoding: "+a);}};var v=function(){for(var a={},b=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82, +83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],c=[],d=0,f=b.length;d>2&63]),f=(d&3)<<4,null!==(d=a())?(f|=d>>4&15,c(b[(f|d>>4&15)&63]),f=(d&15)<<2,null!==(d=a())?(c(b[(f|d>>6&3)&63]),c(b[d&63])):(c(b[f&63]),c(61))):(c(b[f&63]),c(61),c(61))};a.h=function(a,b){function d(a){throw Error("Illegal character code: "+a);}for(var f, +e,g;null!==(f=a());)if(e=c[f],"undefined"===typeof e&&d(f),null!==(f=a())&&(g=c[f],"undefined"===typeof g&&d(f),b(e<<2>>>0|(g&48)>>4),null!==(f=a()))){e=c[f];if("undefined"===typeof e)if(61===f)break;else d(f);b((g&15)<<4>>>0|(e&60)>>2);if(null!==(f=a())){g=c[f];if("undefined"===typeof g)if(61===f)break;else d(f);b((e&3)<<6>>>0|g)}}};a.test=function(a){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(a)};return a}();e.toBase64=function(a,b){"undefined"===typeof a&&(a= +this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c;v.i(function(){return a>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return"";for(var c=[],d=[];ad?f+("0"+d.toString(16).toUpperCase()):f+d.toString(16).toUpperCase(),a&&(e+=32d?String.fromCharCode(d):"."));++b;if(a&&0f.length;)f+=" ";g+=f+e+"\n";f=e=""}f=b=== +this.offset&&b===this.limit?f+(b===this.markedOffset?"!":"|"):b===this.offset?f+(b===this.markedOffset?"[":"<"):b===this.limit?f+(b===this.markedOffset?"]":">"):f+(b===this.markedOffset?"'":a||0!==b&&b!==c?" ":"")}if(a&&" "!==f){for(;51>f.length;)f+=" ";g+=f+e+"\n"}return a?g:f};g.fromDebug=function(a,b,c){var d=a.length;b=new g((d+1)/3|0,b,c);for(var f=0,e=0,h,k=!1,l=!1,m=!1,q=!1,p=!1;f":if(!c){if(q){p=!0;break}q=!0}b.limit=e;k=!1;break;case "'":if(!c){if(m){p=!0;break}m=!0}b.markedOffset=e;k=!1;break;case " ":k=!1;break;default:if(!c&&k){p=!0;break}h=parseInt(h+a.charAt(f++), +16);if(!c&&(isNaN(h)||0>h||255>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}for(var c=Array(b-a),d;ad?c.push("0",d.toString(16)):c.push(d.toString(16));return c.join("")};g.fromHex=function(a,b,c){if(!c){if("string"!==typeof a)throw TypeError("Illegal str: Not a string"); +if(0!==a.length%2)throw TypeError("Illegal str: Length not a multiple of 2");}var d=a.length;b=new g(d/2|0,b);for(var f,e=0,h=0;ef||255d?c(d&127):(2048>d?c(d>>6&31|192):(65536>d? +c(d>>12&15|224):(c(d>>18&7|240),c(d>>12&63|128)),c(d>>6&63|128)),c(d&63|128)),d=null},g:function(a,c){function d(a){a=a.slice(0,a.indexOf(null));var b=Error(a.toString());b.name="TruncatedError";b.bytes=a;throw b;}for(var e,g,h,k;null!==(e=a());)if(0===(e&128))c(e);else if(192===(e&224))null===(g=a())&&d([e,g]),c((e&31)<<6|g&63);else if(224===(e&240))null!==(g=a())&&null!==(h=a())||d([e,g,h]),c((e&15)<<12|(g&63)<<6|h&63);else if(240===(e&248))null!==(g=a())&&null!==(h=a())&&null!==(k=a())||d([e,g, +h,k]),c((e&7)<<18|(g&63)<<12|(h&63)<<6|k&63);else throw RangeError("Illegal starting byte: "+e);},d:function(a,c){for(var d,e=null;null!==(d=null!==e?e:a());)55296<=d&&57343>=d&&null!==(e=a())&&56320<=e&&57343>=e?(c(1024*(d-55296)+e-56320+65536),e=null):c(d);null!==e&&c(e)},e:function(a,c){var d=null;"number"===typeof a&&(d=a,a=function(){return null});for(;null!==d||null!==(d=a());)65535>=d?c(d):(d-=65536,c((d>>10)+55296),c(d%1024+56320)),d=null},c:function(b,c){a.d(b,function(b){a.j(b,c)})},b:function(b, +c){a.g(b,function(b){a.e(b,c)})},f:function(a){return 128>a?1:2048>a?2:65536>a?3:4},l:function(b){for(var c,d=0;null!==(c=b());)d+=a.f(c);return d},a:function(b){var c=0,d=0;a.d(b,function(b){++c;d+=a.f(b)});return[c,d]}};return a}();e.toUTF8=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer"); +b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c;try{l.b(function(){return a + Released under the Apache License, Version 2.0 + see: https://github.com/dcodeIO/Long.js for details + */ +(function(q){function b(a,b,d){this.low=a|0;this.high=b|0;this.unsigned=!!d}b.isLong=function(a){return!0===(a&&a instanceof b)};var r={},s={};b.fromInt=function(a,c){var d;if(c){a>>>=0;if(0<=a&&256>a&&(d=s[a]))return d;d=new b(a,0>(a|0)?-1:0,!0);0<=a&&256>a&&(s[a]=d)}else{a|=0;if(-128<=a&&128>a&&(d=r[a]))return d;d=new b(a,0>a?-1:0,!1);-128<=a&&128>a&&(r[a]=d)}return d};b.fromNumber=function(a,c){c=!!c;return isNaN(a)||!isFinite(a)?b.ZERO:!c&&a<=-t?b.MIN_VALUE:!c&&a+1>=t?b.MAX_VALUE:c&&a>=u?b.MAX_UNSIGNED_VALUE: +0>a?b.fromNumber(-a,c).negate():new b(a%l|0,a/l|0,c)};b.fromBits=function(a,c,d){return new b(a,c,d)};b.fromString=function(a,c,d){if(0===a.length)throw Error("number format error: empty string");if("NaN"===a||"Infinity"===a||"+Infinity"===a||"-Infinity"===a)return b.ZERO;"number"===typeof c&&(d=c,c=!1);d=d||10;if(2>d||36k?(k=b.fromNumber(Math.pow(d,k)),f=f.multiply(k).add(b.fromNumber(m))):(f=f.multiply(e),f=f.add(b.fromNumber(m)))}f.unsigned=c;return f};b.fromValue=function(a){return"number"===typeof a?b.fromNumber(a):"string"===typeof a?b.fromString(a):b.isLong(a)?a:new b(a.low,a.high,a.unsigned)};var l=4294967296,u=l*l,t=u/2,v=b.fromInt(16777216);b.ZERO=b.fromInt(0); +b.UZERO=b.fromInt(0,!0);b.ONE=b.fromInt(1);b.UONE=b.fromInt(1,!0);b.NEG_ONE=b.fromInt(-1);b.MAX_VALUE=b.fromBits(-1,2147483647,!1);b.MAX_UNSIGNED_VALUE=b.fromBits(-1,-1,!0);b.MIN_VALUE=b.fromBits(0,-2147483648,!1);b.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)};b.prototype.toString=function(a){a=a||10;if(2>a||36>>0).toString(a);c=f;if(c.isZero())return g+e;for(;6>g.length;)g="0"+g;e=""+g+e}};b.prototype.getHighBits=function(){return this.high};b.prototype.getHighBitsUnsigned=function(){return this.high>>> +0};b.prototype.getLowBits=function(){return this.low};b.prototype.getLowBitsUnsigned=function(){return this.low>>>0};b.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(b.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var a=0!=this.high?this.high:this.low,c=31;0this.high};b.prototype.isPositive=function(){return this.unsigned|| +0<=this.high};b.prototype.isOdd=function(){return 1===(this.low&1)};b.prototype.equals=function(a){b.isLong(a)||(a=b.fromValue(a));return this.unsigned!==a.unsigned&&this.high>>>31!==a.high>>>31?!1:this.high===a.high&&this.low===a.low};b.prototype.notEquals=function(a){b.isLong(a)||(a=b.fromValue(a));return!this.equals(a)};b.prototype.lessThan=function(a){b.isLong(a)||(a=b.fromValue(a));return 0>this.compare(a)};b.prototype.lessThanOrEqual=function(a){b.isLong(a)||(a=b.fromValue(a));return 0>=this.compare(a)}; +b.prototype.greaterThan=function(a){b.isLong(a)||(a=b.fromValue(a));return 0>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.subtract(a).isNegative()?-1:1};b.prototype.negate=function(){return!this.unsigned&&this.equals(b.MIN_VALUE)?b.MIN_VALUE: +this.not().add(b.ONE)};b.prototype.add=function(a){b.isLong(a)||(a=b.fromValue(a));var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=a.high>>>16,g=a.high&65535,k=a.low>>>16,m;m=0+((this.low&65535)+(a.low&65535));a=0+(m>>>16);a+=e+k;e=0+(a>>>16);e+=d+g;d=0+(e>>>16);d=d+(c+f)&65535;return b.fromBits((a&65535)<<16|m&65535,d<<16|e&65535,this.unsigned)};b.prototype.subtract=function(a){b.isLong(a)||(a=b.fromValue(a));return this.add(a.negate())};b.prototype.multiply=function(a){if(this.isZero())return b.ZERO; +b.isLong(a)||(a=b.fromValue(a));if(a.isZero())return b.ZERO;if(this.equals(b.MIN_VALUE))return a.isOdd()?b.MIN_VALUE:b.ZERO;if(a.equals(b.MIN_VALUE))return this.isOdd()?b.MIN_VALUE:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().multiply(a.negate()):this.negate().multiply(a).negate();if(a.isNegative())return this.multiply(a.negate()).negate();if(this.lessThan(v)&&a.lessThan(v))return b.fromNumber(this.toNumber()*a.toNumber(),this.unsigned);var c=this.high>>>16,d=this.high&65535,e= +this.low>>>16,f=this.low&65535,g=a.high>>>16,k=a.high&65535,m=a.low>>>16;a=a.low&65535;var p,h,n,l;l=0+f*a;n=0+(l>>>16);n+=e*a;h=0+(n>>>16);n=(n&65535)+f*m;h+=n>>>16;n&=65535;h+=d*a;p=0+(h>>>16);h=(h&65535)+e*m;p+=h>>>16;h&=65535;h+=f*k;p+=h>>>16;h&=65535;p=p+(c*a+d*m+e*k+f*g)&65535;return b.fromBits(n<<16|l&65535,p<<16|h,this.unsigned)};b.prototype.div=function(a){b.isLong(a)||(a=b.fromValue(a));if(a.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?b.UZERO:b.ZERO;var c, +d,e;if(this.equals(b.MIN_VALUE)){if(a.equals(b.ONE)||a.equals(b.NEG_ONE))return b.MIN_VALUE;if(a.equals(b.MIN_VALUE))return b.ONE;c=this.shiftRight(1).div(a).shiftLeft(1);if(c.equals(b.ZERO))return a.isNegative()?b.ONE:b.NEG_ONE;d=this.subtract(a.multiply(c));return e=c.add(d.div(a))}if(a.equals(b.MIN_VALUE))return this.unsigned?b.UZERO:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().div(a.negate()):this.negate().div(a).negate();if(a.isNegative())return this.div(a.negate()).negate(); +e=b.ZERO;for(d=this;d.greaterThanOrEqual(a);){c=Math.max(1,Math.floor(d.toNumber()/a.toNumber()));for(var f=Math.ceil(Math.log(c)/Math.LN2),f=48>=f?1:Math.pow(2,f-48),g=b.fromNumber(c),k=g.multiply(a);k.isNegative()||k.greaterThan(d);)c-=f,g=b.fromNumber(c,this.unsigned),k=g.multiply(a);g.isZero()&&(g=b.ONE);e=e.add(g);d=d.subtract(k)}return e};b.prototype.modulo=function(a){b.isLong(a)||(a=b.fromValue(a));return this.subtract(this.div(a).multiply(a))};b.prototype.not=function(){return b.fromBits(~this.low, +~this.high,this.unsigned)};b.prototype.and=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low&a.low,this.high&a.high,this.unsigned)};b.prototype.or=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low|a.low,this.high|a.high,this.unsigned)};b.prototype.xor=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low^a.low,this.high^a.high,this.unsigned)};b.prototype.shiftLeft=function(a){b.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?b.fromBits(this.low<< +a,this.high<>>32-a,this.unsigned):b.fromBits(0,this.low<a?b.fromBits(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):b.fromBits(this.high>>a-32,0<=this.high?0:-1,this.unsigned)};b.prototype.shiftRightUnsigned=function(a){b.isLong(a)&&(a=a.toInt());a&=63;if(0===a)return this;var c=this.high;return 32>a?b.fromBits(this.low>>>a|c<<32-a,c>>>a,this.unsigned):32===a?b.fromBits(c, +0,this.unsigned):b.fromBits(c>>>a-32,0,this.unsigned)};b.prototype.toSigned=function(){return this.unsigned?new b(this.low,this.high,!1):this};b.prototype.toUnsigned=function(){return this.unsigned?this:new b(this.low,this.high,!0)};"undefined"!==typeof module&&module.exports?module.exports=b:"function"===typeof define&&define.amd?define(function(){return b}):(q.dcodeIO=q.dcodeIO||{}).Long=b})(this);})(); diff --git a/external/protobuf/ProtoBuf.min.js b/external/protobuf/ProtoBuf.min.js new file mode 100644 index 0000000000..6db98fc7b5 --- /dev/null +++ b/external/protobuf/ProtoBuf.min.js @@ -0,0 +1,102 @@ +/* + ProtoBuf.js (c) 2013 Daniel Wirtz + Released under the Apache License, Version 2.0 + see: https://github.com/dcodeIO/ProtoBuf.js for details +*/ +(function(s){function u(m){var g={VERSION:"3.7.0",WIRE_TYPES:{}};g.WIRE_TYPES.VARINT=0;g.WIRE_TYPES.BITS64=1;g.WIRE_TYPES.LDELIM=2;g.WIRE_TYPES.STARTGROUP=3;g.WIRE_TYPES.ENDGROUP=4;g.WIRE_TYPES.BITS32=5;g.PACKABLE_WIRE_TYPES=[g.WIRE_TYPES.VARINT,g.WIRE_TYPES.BITS64,g.WIRE_TYPES.BITS32];g.TYPES={int32:{name:"int32",wireType:g.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:g.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:g.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:g.WIRE_TYPES.VARINT},uint64:{name:"uint64", +wireType:g.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:g.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:g.WIRE_TYPES.VARINT},"double":{name:"double",wireType:g.WIRE_TYPES.BITS64},string:{name:"string",wireType:g.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:g.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:g.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:g.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:g.WIRE_TYPES.BITS64},sfixed64:{name:"sfixed64",wireType:g.WIRE_TYPES.BITS64}, +"float":{name:"float",wireType:g.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:g.WIRE_TYPES.VARINT},message:{name:"message",wireType:g.WIRE_TYPES.LDELIM},group:{name:"group",wireType:g.WIRE_TYPES.STARTGROUP}};g.ID_MIN=1;g.ID_MAX=536870911;g.ByteBuffer=m;g.Long=m.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(e){function d(){}if(1=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var f,a;do{for(f=!1;d.WHITESPACE.test(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++, +this.index==this.source.length)return null;this.index++;this.line++;f=!0}else if("*"===this.source.charAt(this.index)){for(a="";"*/"!==a+(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;this.index++;f=!0}else throw Error("Unterminated comment at line "+this.line+": /"+this.source.charAt(this.index));}while(f);if(this.index===this.source.length)return null;f=this.index;d.DELIM.lastIndex=0;if(d.DELIM.test(this.source.charAt(f)))++f; +else for(++f;fa?"-":"")+f);};b._parseString=function(){var f="",a;do{this.tn.next();f+=this.tn.next();a=this.tn.next();if(a!==this.tn.stringEndsWith)throw Error("Illegal end of string at line "+this.tn.line+": "+a);a=this.tn.peek()}while(a===d.STRINGOPEN||a===d.STRINGOPEN_SQ); +return f};b._parseId=function(f,a){var c=-1,b=1;"-"==f.charAt(0)&&(b=-1,f=f.substring(1));if(d.NUMBER_DEC.test(f))c=parseInt(f);else if(d.NUMBER_HEX.test(f))c=parseInt(f.substring(2),16);else if(d.NUMBER_OCT.test(f))c=parseInt(f.substring(1),8);else throw Error("Illegal id at line "+this.tn.line+": "+(0>b?"-":"")+f);c=b*c|0;if(!a&&0>c)throw Error("Illegal id at line "+this.tn.line+": "+(0>b?"-":"")+f);return c};b._parsePackage=function(f){f=this.tn.next();if(!d.TYPEREF.test(f))throw Error("Illegal package name at line "+ +this.tn.line+": "+f);var a=f;f=this.tn.next();if(f!=d.END)throw Error("Illegal end of package at line "+this.tn.line+": "+f);return a};b._parseImport=function(f){f=this.tn.peek();"public"===f&&(this.tn.next(),f=this.tn.peek());if(f!==d.STRINGOPEN&&f!==d.STRINGOPEN_SQ)throw Error("Illegal start of import at line "+this.tn.line+": "+f);var a=this._parseString();f=this.tn.next();if(f!==d.END)throw Error("Illegal end of import at line "+this.tn.line+": "+f);return a};b._parseOption=function(f,a){a=this.tn.next(); +var c=!1;a==d.COPTOPEN&&(c=!0,a=this.tn.next());if(!d.TYPEREF.test(a)&&!/google\.protobuf\./.test(a))throw Error("Illegal option name in message "+f.name+" at line "+this.tn.line+": "+a);var b=a;a=this.tn.next();if(c){if(a!==d.COPTCLOSE)throw Error("Illegal end in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);b="("+b+")";a=this.tn.next();d.FQTYPEREF.test(a)&&(b+=a,a=this.tn.next())}if(a!==d.EQUAL)throw Error("Illegal operator in message "+f.name+", option "+b+" at line "+this.tn.line+ +": "+a);a=this.tn.peek();if(a===d.STRINGOPEN||a===d.STRINGOPEN_SQ)c=this._parseString();else if(this.tn.next(),d.NUMBER.test(a))c=this._parseNumber(a,!0);else if(d.BOOL.test(a))c="true"===a;else if(d.TYPEREF.test(a))c=a;else throw Error("Illegal option value in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!==d.END)throw Error("Illegal end of option in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);f.options[b]=c};b._parseIgnoredStatement=function(f, +a){var c;do{c=this.tn.next();if(null===c)throw Error("Unexpected EOF in "+f.name+", "+a+" at line "+this.tn.line);if(c===d.END)break}while(1)};b._parseService=function(f,a){a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal service name at line "+this.tn.line+": "+a);var c=a,b={name:c,rpc:{},options:{}};a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of service "+c+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),"option"===a)this._parseOption(b,a);else if("rpc"===a)this._parseServiceRPC(b, +a);else if(a!==d.CLOSE)throw Error("Illegal type of service "+c+" at line "+this.tn.line+": "+a);while(a!==d.CLOSE);f.services.push(b)};b._parseServiceRPC=function(f,a){var c=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal method name in service "+f.name+" at line "+this.tn.line+": "+a);var b=a,e={request:null,response:null,options:{}};a=this.tn.next();if(a!==d.COPTOPEN)throw Error("Illegal start of request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next(); +if(!d.TYPEREF.test(a))throw Error("Illegal request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);e.request=a;a=this.tn.next();if(a!=d.COPTCLOSE)throw Error("Illegal end of request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if("returns"!==a.toLowerCase())throw Error("Illegal delimiter in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!=d.COPTOPEN)throw Error("Illegal start of response type in service "+f.name+"#"+ +b+" at line "+this.tn.line+": "+a);a=this.tn.next();e.response=a;a=this.tn.next();if(a!==d.COPTCLOSE)throw Error("Illegal end of response type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a===d.OPEN){do if(a=this.tn.next(),"option"===a)this._parseOption(e,a);else if(a!==d.CLOSE)throw Error("Illegal start of option inservice "+f.name+"#"+b+" at line "+this.tn.line+": "+a);while(a!==d.CLOSE);this.tn.peek()===d.END&&this.tn.next()}else if(a!==d.END)throw Error("Illegal delimiter in service "+ +f.name+"#"+b+" at line "+this.tn.line+": "+a);"undefined"===typeof f[c]&&(f[c]={});f[c][b]=e};b._parseMessage=function(f,a,c){var b={},e="group"===c;c=this.tn.next();if(!d.NAME.test(c))throw Error("Illegal "+(e?"group":"message")+" name"+(f?" in message "+f.name:"")+" at line "+this.tn.line+": "+c);b.name=c;if(e){c=this.tn.next();if(c!==d.EQUAL)throw Error("Illegal id assignment after group "+b.name+" at line "+this.tn.line+": "+c);c=this.tn.next();try{a.id=this._parseId(c)}catch(g){throw Error("Illegal field id value for group "+ +b.name+"#"+a.name+" at line "+this.tn.line+": "+c);}b.isGroup=!0}b.fields=[];b.enums=[];b.messages=[];b.options={};b.oneofs={};c=this.tn.next();c===d.OPTOPEN&&a&&(this._parseFieldOptions(b,a,c),c=this.tn.next());if(c!==d.OPEN)throw Error("Illegal start of "+(e?"group":"message")+" "+b.name+" at line "+this.tn.line+": "+c);do if(c=this.tn.next(),c===d.CLOSE){c=this.tn.peek();c===d.END&&this.tn.next();break}else if(d.RULE.test(c))this._parseMessageField(b,c);else if("oneof"===c)this._parseMessageOneOf(b, +c);else if("enum"===c)this._parseEnum(b,c);else if("message"===c)this._parseMessage(b,null,c);else if("option"===c)this._parseOption(b,c);else if("extensions"===c)b.extensions=this._parseExtensions(b,c);else if("extend"===c)this._parseExtend(b,c);else throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+c);while(1);f.messages.push(b);return b};b._parseMessageField=function(b,a){var c={},e=null;c.rule=a;c.options={};a=this.tn.next();if("group"===a){e=this._parseMessage(b,c, +a);if(!/^[A-Z]/.test(e.name))throw Error("Group names must start with a capital letter");c.type=e.name;c.name=e.name.toLowerCase();a=this.tn.peek();a===d.END&&this.tn.next()}else{if(!d.TYPE.test(a)&&!d.TYPEREF.test(a))throw Error("Illegal field type in message "+b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal field name in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal token in field "+ +b.name+"#"+c.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a)}catch(g){throw Error("Illegal field id in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();a===d.OPTOPEN&&(this._parseFieldOptions(b,c,a),a=this.tn.next());if(a!==d.END)throw Error("Illegal delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}b.fields.push(c);return c};b._parseMessageOneOf=function(b,a){a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal oneof name in message "+ +b.name+" at line "+this.tn.line+": "+a);var c=a,e,g=[];a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of oneof "+c+" at line "+this.tn.line+": "+a);for(;this.tn.peek()!==d.CLOSE;)e=this._parseMessageField(b,"optional"),e.oneof=c,g.push(e.id);this.tn.next();b.oneofs[c]=g};b._parseFieldOptions=function(b,a,c){var e=!0;do{c=this.tn.next();if(c===d.OPTCLOSE)break;else if(c===d.OPTEND){if(e)throw Error("Illegal start of options in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c); +c=this.tn.next()}this._parseFieldOption(b,a,c);e=!1}while(1)};b._parseFieldOption=function(b,a,c){var e=!1;c===d.COPTOPEN&&(c=this.tn.next(),e=!0);if(!d.TYPEREF.test(c))throw Error("Illegal field option in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);var g=c;c=this.tn.next();if(e){if(c!==d.COPTCLOSE)throw Error("Illegal delimiter in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);g="("+g+")";c=this.tn.next();d.FQTYPEREF.test(c)&&(g+=c,c=this.tn.next())}if(c!==d.EQUAL)throw Error("Illegal token in "+ +b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.peek();if(c===d.STRINGOPEN||c===d.STRINGOPEN_SQ)b=this._parseString();else if(d.NUMBER.test(c,!0))b=this._parseNumber(this.tn.next(),!0);else if(d.BOOL.test(c))b="true"===this.tn.next().toLowerCase();else if(d.TYPEREF.test(c))b=this.tn.next();else throw Error("Illegal value in message "+b.name+"#"+a.name+", option "+g+" at line "+this.tn.line+": "+c);a.options[g]=b};b._parseEnum=function(b,a){var c={};a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal enum name in message "+ +b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of enum "+c.name+" at line "+this.tn.line+": "+a);c.values=[];c.options={};do{a=this.tn.next();if(a===d.CLOSE){a=this.tn.peek();a===d.END&&this.tn.next();break}if("option"==a)this._parseOption(c,a);else{if(!d.NAME.test(a))throw Error("Illegal name in enum "+c.name+" at line "+this.tn.line+": "+a);this._parseEnumValue(c,a)}}while(1);b.enums.push(c)};b._parseEnumValue=function(b,a){var c={};c.name= +a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal token in enum "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a,!0)}catch(e){throw Error("Illegal id in enum "+b.name+" at line "+this.tn.line+": "+a);}b.values.push(c);a=this.tn.next();a===d.OPTOPEN&&(this._parseFieldOptions(b,{options:{}},a),a=this.tn.next());if(a!==d.END)throw Error("Illegal delimiter in enum "+b.name+" at line "+this.tn.line+": "+a);};b._parseExtensions=function(b,a){var c=[];a=this.tn.next(); +"min"===a?c.push(e.ID_MIN):"max"===a?c.push(e.ID_MAX):c.push(this._parseNumber(a));a=this.tn.next();if("to"!==a)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();"min"===a?c.push(e.ID_MIN):"max"===a?c.push(e.ID_MAX):c.push(this._parseNumber(a));a=this.tn.next();if(a!==d.END)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);return c};b._parseExtend=function(b,a){a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("Illegal message name at line "+ +this.tn.line+": "+a);var c={};c.ref=a;c.fields=[];a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of extend "+c.name+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),a===d.CLOSE){a=this.tn.peek();a==d.END&&this.tn.next();break}else if(d.RULE.test(a))this._parseMessageField(c,a);else throw Error("Illegal token in extend "+c.name+" at line "+this.tn.line+": "+a);while(1);b.messages.push(c);return c};b.toString=function(){return"Parser"};g.Parser=n;return g}(g,g.Lang);g.Reflect=function(e){function d(a, +b){var c=b.readVarint32(),f=c&7,c=c>>3;switch(f){case e.WIRE_TYPES.VARINT:do c=b.readUint8();while(128===(c&128));break;case e.WIRE_TYPES.BITS64:b.offset+=8;break;case e.WIRE_TYPES.LDELIM:c=b.readVarint32();b.offset+=c;break;case e.WIRE_TYPES.STARTGROUP:d(c,b);break;case e.WIRE_TYPES.ENDGROUP:if(c===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+c+" ("+a+" expected)");case e.WIRE_TYPES.BITS32:b.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+f);}return!0} +function g(a,b){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new e.Long(a.low,a.high,"undefined"===typeof b?a.unsigned:b);if("string"===typeof a)return e.Long.fromString(a,b||!1,10);if("number"===typeof a)return e.Long.fromNumber(a,b||!1);throw Error("not convertible to Long");}var k={},n=function(a,b,c){this.builder=a;this.parent=b;this.name=c},b=n.prototype;b.fqn=function(){var a=this.name,b=this;do{b=b.parent;if(null== +b)break;a=b.name+"."+a}while(1);return a};b.toString=function(a){return(a?this.className+" ":"")+this.fqn()};b.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};k.T=n;var f=function(a,b,c,e){n.call(this,a,b,c);this.className="Namespace";this.children=[];this.options=e||{}},b=f.prototype=Object.create(n.prototype);b.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var b=[],c=0,e=this.children.length;ca.remaining())return null;var l=a.offset,e=a.readVarint32();if(a.remaining()>3;if(p===e.WIRE_TYPES.ENDGROUP){if(k!==c)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(c?c+" expected":"not a group")+")");break}if(h=this._fieldsById[k])h.repeated&&!h.options.packed?g[h.name].push(h.decode(p,a)):(g[h.name]=h.decode(p,a),h.oneof&&(null!== +this[h.oneof.name]&&(this[this[h.oneof.name]]=null),g[h.oneof.name]=h.name));else switch(p){case e.WIRE_TYPES.VARINT:a.readVarint32();break;case e.WIRE_TYPES.BITS32:a.offset+=4;break;case e.WIRE_TYPES.BITS64:a.offset+=8;break;case e.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case e.WIRE_TYPES.STARTGROUP:for(;d(k,a););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+p);}}a=0;for(b=this._fields.length;aa?a>>>0:a;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return g(a,!1)}catch(f){c(typeof a,f.message)}else c(typeof a,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return g(a,!0)}catch(h){c(typeof a,h.message)}else c(typeof a,"requires Long.js");case e.TYPES.bool:return"boolean"!==typeof a&&c(typeof a,"not a boolean"),a;case e.TYPES["float"]:case e.TYPES["double"]:return"number"!==typeof a&&c(typeof a, +"not a number"),a;case e.TYPES.string:return"string"===typeof a||a&&a instanceof String||c(typeof a,"not a string"),""+a;case e.TYPES.bytes:return a&&a instanceof m?a:m.wrap(a);case e.TYPES["enum"]:var k=this.resolvedType.getChildren(p.Value);for(d=0;da?b.writeVarint64(a):b.writeVarint32(a);break;case e.TYPES.uint32:b.writeVarint32(a);break;case e.TYPES.sint32:b.writeVarint32ZigZag(a);break;case e.TYPES.fixed32:b.writeUint32(a);break;case e.TYPES.sfixed32:b.writeInt32(a);break;case e.TYPES.int64:case e.TYPES.uint64:b.writeVarint64(a);break;case e.TYPES.sint64:b.writeVarint64ZigZag(a);break;case e.TYPES.fixed64:b.writeUint64(a);break;case e.TYPES.sfixed64:b.writeInt64(a); +break;case e.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case e.TYPES["enum"]:b.writeVarint32(a);break;case e.TYPES["float"]:b.writeFloat32(a);break;case e.TYPES["double"]:b.writeFloat64(a);break;case e.TYPES.string:b.writeVString(a);break;case e.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");var c=a.offset;b.writeVarint32(a.remaining());b.append(a);a.offset=c; +break;case e.TYPES.message:c=(new m).LE();this.resolvedType.encode(a,c);b.writeVarint32(c.offset);b.append(c.flip());break;case e.TYPES.group:this.resolvedType.encode(a,b);b.writeVarint32(this.id<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");}return b};c.calculate=function(a){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+ +": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var c,d;if(this.options.packed&&0<=e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=m.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM);for(c=d=0;ca?m.calculateVarint64(a):m.calculateVarint32(a);case e.TYPES.uint32:return m.calculateVarint32(a);case e.TYPES.sint32:return m.calculateVarint32(m.zigZagEncode32(a));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES["float"]:return 4;case e.TYPES.int64:case e.TYPES.uint64:return m.calculateVarint64(a);case e.TYPES.sint64:return m.calculateVarint64(m.zigZagEncode64(a)); +case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES["enum"]:return m.calculateVarint32(a);case e.TYPES["double"]:return 8;case e.TYPES.string:return a=m.calculateUTF8Bytes(a),m.calculateVarint32(a)+a;case e.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");return m.calculateVarint32(a.remaining())+a.remaining();case e.TYPES.message:return a=this.resolvedType.calculate(a),m.calculateVarint32(a)+ +a;case e.TYPES.group:return a=this.resolvedType.calculate(a),a+m.calculateVarint32(this.id<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};c.decode=function(a,b,c){if(a!=this.type.wireType&&(c||a!=e.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==e.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&& +!c){a=b.readVarint32();a=b.offset+a;for(c=[];b.offset>>0;case e.TYPES.sint32:return b.readVarint32ZigZag()|0;case e.TYPES.fixed32:return b.readUint32()>>>0;case e.TYPES.sfixed32:return b.readInt32()|0;case e.TYPES.int64:return b.readVarint64();case e.TYPES.uint64:return b.readVarint64().toUnsigned();case e.TYPES.sint64:return b.readVarint64ZigZag(); +case e.TYPES.fixed64:return b.readUint64();case e.TYPES.sfixed64:return b.readInt64();case e.TYPES.bool:return!!b.readVarint32();case e.TYPES["enum"]:return b.readVarint32();case e.TYPES["float"]:return b.readFloat();case e.TYPES["double"]:return b.readDouble();case e.TYPES.string:return b.readVString();case e.TYPES.bytes:a=b.readVarint32();if(b.remaining()e.ID_MAX&&(c.extensions[1]=e.ID_MAX));this.ptr.addChild(c);0c.extensions[1])throw Error("Illegal extended field id in message "+c.name+": "+a.fields[h].id+" ("+c.extensions.join(" to ")+ +" expected)");n=a.fields[h].name;this.options.convertFieldsToCamelCase&&(n=g.Message.Field._toCamelCase(a.fields[h].name));p=new g.Message.ExtensionField(this,c,a.fields[h].rule,a.fields[h].type,this.ptr.fqn()+"."+n,a.fields[h].id,a.fields[h].options);n=new g.Extension(this,this.ptr,a.fields[h].name,p);p.extension=n;this.ptr.addChild(n);c.addChild(p)}else{if(!/\.?google\.protobuf\./.test(a.ref))throw Error("Extended message "+a.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(a)); +}else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};n["import"]=function(b,d){if("string"===typeof d){e.Util.IS_NODE&&(d=require("path").resolve(d));if(!0===this.files[d])return this.reset(),this;this.files[d]=!0}if(b.imports&&0 Date: Thu, 16 Oct 2014 10:41:39 +0800 Subject: [PATCH 0794/1564] Issue #5986: Fixed TableView and EGLView issue --- cocos2d/core/platform/CCEGLView.js | 12 ++---------- extensions/gui/scrollview/CCTableView.js | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index d08bd03f02..315039da58 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -267,18 +267,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ content = content.substr(1); } - /* - if(width<=320){ - width = 321; - } - if(height) - content ="height="+height+","+content; - if(width) - content ="width="+width+","+content; - */ vp.content = content; // For adopting certain android devices which don't support second viewport - currentVP.content = content; + if (currentVP) + currentVP.content = content; document.head.appendChild(vp); } diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js index 45c510ab9e..f3347aa498 100644 --- a/extensions/gui/scrollview/CCTableView.js +++ b/extensions/gui/scrollview/CCTableView.js @@ -714,5 +714,5 @@ _p = null; * @return {cc.TableView} table view */ cc.TableView.create = function (dataSource, size, container) { - return cc.TableView(dataSource, size, container); + return new cc.TableView(dataSource, size, container); }; From 668b522bc395dea15b39978a7ef81e46c5449122 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 16 Oct 2014 10:45:15 +0800 Subject: [PATCH 0795/1564] Issue #5968: fixed a bug of cc.DrawNode and eventHelper --- cocos2d/core/event-manager/CCEventManager.js | 5 +- cocos2d/core/renderer/RendererCanvas.js | 53 ++++++++------------ cocos2d/core/renderer/RendererWebGL.js | 2 +- 3 files changed, 23 insertions(+), 37 deletions(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 1f3d2dbf24..be7b68f5bd 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -948,7 +948,7 @@ cc.EventHelper.prototype = { if ( listeners[ type ] === undefined ) listeners[ type ] = []; - if ( this.hasEventListener(listener, target)) + if ( !this.hasEventListener(type, listener, target)) listeners[ type ].push( {callback:listener, eventTarget: target} ); }, @@ -992,10 +992,9 @@ cc.EventHelper.prototype = { if(clearAfterDispatch == null) clearAfterDispatch = true; var listeners = this._listeners; - var listenerArray = listeners[ event.type ]; + var listenerArray = listeners[ event]; if ( listenerArray !== undefined ) { - event.target = this; var array = []; var length = listenerArray.length; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 9ff4e53d93..0f3c1d9054 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -433,9 +433,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - node = this._node, - locSprite = this._sprite; + var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) @@ -507,7 +505,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.DrawNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, _t = this; + var context = ctx || cc._renderContext, _t = this, node = _t._node; + var alpha = node._displayedOpacity/255; + if(alpha === 0) + return; + context.globalAlpha = alpha; + + var t = node._transformWorld; + context.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) context.globalCompositeOperation = 'lighter'; var locBuffer = _t._buffer; @@ -525,6 +531,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { break; } } + context.restore(); }; cc.DrawNodeRenderCmdCanvas.prototype._drawDot = function (ctx, element, scaleX, scaleY) { @@ -539,10 +546,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.DrawNodeRenderCmdCanvas.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { var locColor = element.lineColor; - var locFrom = element.verts[0]; - var locTo = element.verts[1]; - var locLineWidth = element.lineWidth; - var locLineCap = element.lineCap; + var locFrom = element.verts[0], locTo = element.verts[1]; + var locLineWidth = element.lineWidth, locLineCap = element.lineCap; ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; ctx.lineWidth = locLineWidth * scaleX; @@ -554,38 +559,23 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.DrawNodeRenderCmdCanvas.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { - var _node = this._node; - var locVertices = element.verts; - var locLineCap = element.lineCap; - var locFillColor = element.fillColor; - var locLineWidth = element.lineWidth; - var locLineColor = element.lineColor; - var locIsClosePolygon = element.isClosePolygon; - var locIsFill = element.isFill; - var locIsStroke = element.isStroke; + var locVertices = element.verts, locLineCap = element.lineCap; + var locFillColor = element.fillColor, locLineWidth = element.lineWidth; + var locLineColor = element.lineColor, locIsClosePolygon = element.isClosePolygon; + var locIsFill = element.isFill, locIsStroke = element.isStroke; if (locVertices == null) return; var firstPoint = locVertices[0]; - ctx.lineCap = locLineCap; - - if (locFillColor) { + if (locFillColor) ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; - } - - if (locLineWidth) { + if (locLineWidth) ctx.lineWidth = locLineWidth * scaleX; - } - if (locLineColor) { + if (locLineColor) ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; - } - var t = _node._transformWorld; - - ctx.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); ctx.beginPath(); ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); @@ -594,12 +584,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (locIsClosePolygon) ctx.closePath(); - if (locIsFill) ctx.fill(); if (locIsStroke) ctx.stroke(); - ctx.restore(); }; cc.ClippingNodeSaveRenderCmdCanvas = function (node) { @@ -681,7 +669,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - //CHIPMUNK cc.PhysicsDebugNodeRenderCmdCanvas = function (node) { this._node = node; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 53635e24e3..db4d938ef3 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -115,7 +115,7 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ cc.TextureRenderCmdWebGL.prototype.rendering = function(ctx){ var _t = this._node; - if (!_t._textureLoaded) + if (!_t._textureLoaded || _t._displayedOpacity === 0) return; var gl = ctx || cc._renderContext, locTexture = _t._texture; From 0b82aa720fb481737950a4b2c2091547a6bd2ed2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 16 Oct 2014 13:19:13 +0800 Subject: [PATCH 0796/1564] Issue #5982: Refactor constructors in cocostudio extension --- extensions/cocostudio/armature/CCArmature.js | 9 +--- extensions/cocostudio/armature/CCBone.js | 21 ++++---- .../armature/animation/CCArmatureAnimation.js | 21 ++++---- .../cocostudio/armature/animation/CCTween.js | 22 ++++---- .../armature/display/CCBatchNode.js | 13 +++-- .../armature/display/CCDecorativeDisplay.js | 14 ++--- .../armature/display/CCDisplayManager.js | 15 +++--- .../cocostudio/armature/display/CCSkin.js | 54 ++++++++----------- .../armature/physics/CCColliderDetector.js | 12 +++-- extensions/cocostudio/trigger/TriggerObj.js | 10 ++-- 10 files changed, 81 insertions(+), 110 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 60ed1ffccf..341f5d7daf 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -770,13 +770,8 @@ _p = null; * @param {String} [name] Bone name * @param {ccs.Bone} [parentBone] the parent bone * @return {ccs.Armature} - * @example - * // example - * var armature = ccs.Armature.create(); + * @deprecated since v3.1, please use new construction instead */ ccs.Armature.create = function (name, parentBone) { - var armature = new ccs.Armature(); - if (armature.init(name, parentBone)) - return armature; - return null; + return new ccs.Armature(name, parentBone); }; diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 8a4d1d78a5..37627437f7 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -28,6 +28,11 @@ * @class * @extends ccs.Node * + * @param {String} [name] The name of the bone + * @example + * + * var bone = new ccs.Bone("head"); + * * @property {ccs.BoneData} boneData - The bone data * @property {ccs.Armature} armature - The armature * @property {ccs.Bone} parentBone - The parent bone @@ -60,10 +65,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ _dataVersion: 0, _className: "Bone", - /** - * Construction of ccs.Bone. - */ - ctor: function () { + ctor: function (name) { cc.Node.prototype.ctor.call(this); this._tweenData = null; this._parentBone = null; @@ -82,6 +84,8 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._armatureParentBone = null; this._dataVersion = 0; + + ccs.Bone.prototype.init.call(this, name); }, /** @@ -679,13 +683,8 @@ _p = null; /** * Allocates and initializes a bone. * @return {ccs.Bone} - * @example - * // example - * var bone = ccs.Bone.create(); + * @deprecated since v3.1, please use new construction instead */ ccs.Bone.create = function (name) { - var bone = new ccs.Bone(); - if (bone && bone.init(name)) - return bone; - return null; + return new ccs.Bone(name); }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 566e24b24b..1f16082011 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -100,6 +100,8 @@ ccs.FrameEvent = function () { * @class * @extends ccs.ProcessBase * + * @param {ccs.Armature} [armature] The armature + * * @property {ccs.AnimationData} animationData - Animation data * @property {Object} userObject - User custom object * @property {Boolean} ignoreFrameEvent - Indicate whether the frame event is ignored @@ -130,16 +132,16 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# _movementEventListener: null, _frameEventListener: null, - /** - * The Construction of ccs.ArmatureAnimation - */ - ctor: function () { + ctor: function (armature) { ccs.ProcessBase.prototype.ctor.call(this); this._tweenList = []; this._movementList = []; this._frameEventQueue = []; this._movementEventQueue = []; + this._armature = null; + + armature && ccs.ArmatureAnimation.prototype.init.call(this, armature); }, /** @@ -661,13 +663,8 @@ _p = null; /** * Allocates and initializes a ArmatureAnimation. * @return {ccs.ArmatureAnimation} - * @example - * // example - * var animation = ccs.ArmatureAnimation.create(); + * @deprecated since v3.1, please use new construction instead */ -ccs.ArmatureAnimation.create = function (armature) { //TODO it will be deprecated in v3.1 - var animation = new ccs.ArmatureAnimation(); - if (animation && animation.init(armature)) - return animation; - return null; +ccs.ArmatureAnimation.create = function (armature) { + return new ccs.ArmatureAnimation(armature); }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index fb86b5ffd2..0f39c54a35 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -28,6 +28,8 @@ * @class * @extends ccs.ProcessBase * + * @param {ccs.Bone} The bone to be animated + * * @property {ccs.ArmatureAnimation} animation - The animation */ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ @@ -45,12 +47,11 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ _animation:null, _passLastFrame:false, - /** - * Construction of ccs.Tween. - */ - ctor:function () { + ctor:function (bone) { ccs.ProcessBase.prototype.ctor.call(this); this._frameTweenEasing = ccs.TweenType.linear; + + ccs.Tween.prototype.init.call(this, bone); }, /** @@ -66,7 +67,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._tweenData = this._bone.getTweenData(); this._tweenData.displayIndex = -1; - this._animation = this._bone.getArmature() != null ? + this._animation = this._bone != null && this._bone.getArmature() != null ? this._bone.getArmature().getAnimation() : null; return true; @@ -440,13 +441,8 @@ _p = null; * Allocates and initializes a ArmatureAnimation. * @param {ccs.Bone} bone * @return {ccs.Tween} - * @example - * // example - * var animation = ccs.ArmatureAnimation.create(); + * @deprecated since v3.1, please use new construction instead */ -ccs.Tween.create = function (bone) { //TODO it will be deprecated in v3.1 - var tween = new ccs.Tween(); - if (tween && tween.init(bone)) - return tween; - return null; +ccs.Tween.create = function (bone) { + return new ccs.Tween(bone); }; diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index f28941f7d8..75e6e25031 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -34,6 +34,8 @@ ccs.BatchNode = cc.Node.extend(/** @lends ccs.BatchNode# */{ ctor:function () { this._atlas = null; + + ccs.BatchNode.prototype.init.call(this); }, init:function () { @@ -102,10 +104,11 @@ ccs.BatchNode = cc.Node.extend(/** @lends ccs.BatchNode# */{ } }); +/** + * + * @returns {BatchNode} + * @deprecated since v3.1, please use new construction instead + */ ccs.BatchNode.create = function () { - var batchNode = new ccs.BatchNode(); - if (batchNode && batchNode.init()) { - return batchNode; - } - return null; + return new ccs.BatchNode(); }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js index fa54cefc34..f7a7c3d4bf 100644 --- a/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +++ b/extensions/cocostudio/armature/display/CCDecorativeDisplay.js @@ -33,13 +33,12 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ _colliderDetector: null, _displayData: null, - /** - * Construction of ccs.DecorativeDisplay - */ ctor:function () { this._display = null; this._colliderDetector = null; this._displayData = null; + + //ccs.DecorativeDisplay.prototype.init.call(this); }, /** @@ -112,13 +111,8 @@ ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ /** * Allocates and initializes a decorative display. * @return {ccs.DecorativeDisplay} - * @example - * // example - * var display = ccs.DecorativeDisplay.create(); + * @deprecated since v3.1, please use new construction instead */ ccs.DecorativeDisplay.create = function () { - var decorativeDisplay = new ccs.DecorativeDisplay(); - if (decorativeDisplay && decorativeDisplay.init()) - return decorativeDisplay; - return null; + return new ccs.DecorativeDisplay(); }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index edbed8e513..f1b3446ae0 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -27,6 +27,8 @@ * The display manager for CocoStudio Armature bone. * @Class ccs.DisplayManager * @extend cc.Class + * + * @param {ccs.Bone} bone The bone for the display manager */ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ _decoDisplayList:null, @@ -38,10 +40,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ _visible:true, _displayType: null, - /** - * Construction of ccs.DisplayManager. - */ - ctor:function () { + ctor:function (bone) { this._decoDisplayList = []; this._currentDecoDisplay = null; this._displayRenderNode = null; @@ -50,6 +49,8 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ this._bone = null; this._visible = true; this._displayType = ccs.DISPLAY_TYPE_MAX; + + bone && ccs.DisplayManager.prototype.init.call(this, bone); }, /** @@ -457,10 +458,8 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ * Allocates and initializes a display manager with ccs.Bone. * @param {ccs.Bone} bone * @returns {ccs.DisplayManager} + * @deprecated since v3.1, please use new construction instead */ ccs.DisplayManager.create = function (bone) { - var displayManager = new ccs.DisplayManager(); - if (displayManager && displayManager.init(bone)) - return displayManager; - return null; + return new ccs.DisplayManager(bone); }; \ No newline at end of file diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index c804c3b08b..7345dda301 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -28,6 +28,9 @@ * @class * @extends ccs.Sprite * + * @param {String} [fileName] + * @param {cc.Rect} [rect] + * * @property {Object} skinData - The data of the skin * @property {ccs.Bone} bone - The bone of the skin * @property {String} displayName - <@readonly> The displayed name of skin @@ -41,16 +44,23 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ _armature: null, _className: "Skin", - /** - * Construction of ccs.Skin. - */ - ctor: function () { + ctor: function (fileName, rect) { cc.Sprite.prototype.ctor.call(this); this._skinData = null; this.bone = null; this._displayName = ""; this._skinTransform = cc.affineTransformIdentity(); this._armature = null; + + if (fileName == null || fileName == "") { + ccs.Skin.prototype.init.call(this); + } else { + if(fileName[0] == "#"){ + ccs.Skin.prototype.initWithSpriteFrameName.call(this, fileName.substr(1)); + } else { + ccs.Skin.prototype.initWithFile.call(this, fileName, rect); + } + } }, /** @@ -76,10 +86,12 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ /** * Initializes with texture file name. * @param {String} fileName + * @param {cc.Rect} rect * @returns {Boolean} */ - initWithFile: function (fileName) { - var ret = cc.Sprite.prototype.initWithFile.call(this, fileName); + initWithFile: function (fileName, rect) { + var ret = rect ? cc.Sprite.prototype.initWithFile.call(this, fileName, rect) + : cc.Sprite.prototype.initWithFile.call(this, fileName); this._displayName = fileName; return ret; }, @@ -260,40 +272,18 @@ _p = null; * @param {String} [fileName] fileName or sprite frame name * @param {cc.Rect} [rect] * @returns {ccs.Skin} - * @example - * // example - * var skin = ccs.Skin.create("res/test.png",cc.rect(0,0,50,50)); - * var skin = ccs.Skin.create("#test.png"); //=> ccs.Skin.createWithSpriteFrameName("test.png"); + * @deprecated since v3.1, please use new construction instead */ ccs.Skin.create = function (fileName, rect) { - var argnum = arguments.length; - var skin = new ccs.Skin(); - if (argnum === 0 || fileName == null || fileName == "") { - if (skin.init()) - return skin; - } else { - if(fileName[0] == "#"){ - if (skin && skin.initWithSpriteFrameName(fileName)) - return skin; - }else{ - if (skin && skin.initWithFile(fileName, rect)) - return skin; - } - } - return null; + return new ccs.Skin(fileName, rect); }; /** * allocates and initializes a skin. * @param {String} spriteFrameName * @returns {ccs.Skin} - * @example - * // example - * var skin = ccs.Skin.createWithSpriteFrameName("test.png"); + * @deprecated since v3.1, please use new construction instead */ ccs.Skin.createWithSpriteFrameName = function (spriteFrameName) { - var skin = new ccs.Skin(); - if (skin && skin.initWithSpriteFrameName(spriteFrameName)) - return skin; - return null; + return new ccs.Skin(spriteFrameName); }; diff --git a/extensions/cocostudio/armature/physics/CCColliderDetector.js b/extensions/cocostudio/armature/physics/CCColliderDetector.js index 04b7e72b37..092671afa1 100644 --- a/extensions/cocostudio/armature/physics/CCColliderDetector.js +++ b/extensions/cocostudio/armature/physics/CCColliderDetector.js @@ -154,6 +154,8 @@ ccs.ColliderBody = ccs.Class.extend(/** @lends ccs.ColliderBody# */{ * @class * @extends ccs.Class * + * @param {ccs.Bone} [bone] + * * @property {ccs.ColliderFilter} colliderFilter - The collider filter of the collider detector * @property {Boolean} active - Indicate whether the collider detector is active * @property {Object} body - The collider body @@ -165,12 +167,15 @@ ccs.ColliderDetector = ccs.Class.extend(/** @lends ccs.ColliderDetector# */{ _active: false, _filter: null, helpPoint: cc.p(0, 0), - ctor: function () { + + ctor: function (bone) { this._colliderBodyList = []; this._bone = null; this._body = null; this._active = false; this._filter = null; + + ccs.ColliderDetector.prototype.init.call(this, bone); }, init: function (bone) { this._colliderBodyList.length = 0; @@ -388,8 +393,5 @@ cc.defineGetterSetter(_p, "body", _p.getBody, _p.setBody); _p = null; ccs.ColliderDetector.create = function (bone) { - var colliderDetector = new ccs.ColliderDetector(); - if (colliderDetector && colliderDetector.init(bone)) - return colliderDetector; - return null; + return new ccs.ColliderDetector(bone); }; \ No newline at end of file diff --git a/extensions/cocostudio/trigger/TriggerObj.js b/extensions/cocostudio/trigger/TriggerObj.js index 3a3290c703..5d4e36af4b 100644 --- a/extensions/cocostudio/trigger/TriggerObj.js +++ b/extensions/cocostudio/trigger/TriggerObj.js @@ -117,12 +117,11 @@ ccs.TriggerObj = ccs.Class.extend(/** @lends ccs.TriggerObj# */{ _enable: true, _vInt: null, - /** - * Construction of trigger object. - */ ctor: function () { this._id = 0; this._enable = true; + + ccs.TriggerObj.prototype.init.call(this); }, /** @@ -260,8 +259,5 @@ ccs.TriggerObj = ccs.Class.extend(/** @lends ccs.TriggerObj# */{ }); ccs.TriggerObj.create = function () { - var ret = new ccs.TriggerObj(); - if (ret.init()) - return ret; - return null; + return new ccs.TriggerObj(); }; \ No newline at end of file From e9be26d1dc9fb4640ccf6341182c96ad07f8e293 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 16 Oct 2014 14:46:38 +0800 Subject: [PATCH 0797/1564] Closed #5987: added normalized position to cc.Node --- cocos2d/core/base-nodes/CCNode.js | 54 ++++++++++++++++++++++++++++-- cocos2d/physics/CCPhysicsSprite.js | 8 +++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 0984d43e57..98c73805fc 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -138,6 +138,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _scaleX: 1.0, _scaleY: 1.0, _position: null, + + _normalizedPosition:null, + _usingNormalizedPosition: false, + _normalizedPositionDirty: false, + _skewX: 0.0, _skewY: 0.0, // children (lazy allocs), @@ -152,7 +157,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true _ignoreAnchorPointForPosition: false, tag: cc.NODE_TAG_INVALID, - // userData is always inited as nil + // userData is always initialized as nil userData: null, userObject: null, _transformDirty: true, @@ -192,7 +197,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _realColor: null, _cascadeColorEnabled: false, _cascadeOpacityEnabled: false, - _usingNormalizedPosition: false, _hashOfName: 0, _curLevel: -1, //for new renderer @@ -205,6 +209,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _t._anchorPointInPoints = cc.p(0, 0); _t._contentSize = cc.size(0, 0); _t._position = cc.p(0, 0); + _t._normalizedPosition = cc.p(0,0); _t._children = []; _t._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; _t._transformWorld = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; @@ -675,6 +680,29 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ locPosition.y = yValue; } this.setNodeDirty(); + this._usingNormalizedPosition = false; + }, + + /** + *

    + * Sets the position (x,y) using values between 0 and 1.
    + * The positions in pixels is calculated like the following:
    + * _position = _normalizedPosition * parent.getContentSize() + *

    + * @param {cc.Point|Number} posOrX + * @param {Number} [y] + */ + setNormalizedPosition: function(posOrX, y){ + var locPosition = this._normalizedPosition; + if (y === undefined) { + locPosition.x = posOrX.x; + locPosition.y = posOrX.y; + } else { + locPosition.x = posOrX; + locPosition.y = y; + } + this.setNodeDirty(); + this._normalizedPositionDirty = this._usingNormalizedPosition = true; }, /** @@ -686,6 +714,14 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return cc.p(this._position); }, + /** + * returns the normalized position + * @returns {cc.Point} + */ + getNormalizedPosition: function(){ + return cc.p(this._normalizedPosition); + }, + /** *

    Returns the x axis position of the node in cocos2d coordinates.

    * @function @@ -2259,6 +2295,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _getNodeToParentTransformForWebGL: function () { var _t = this; + if(_t._usingNormalizedPosition && _t._parent){ //TODO need refactor + var conSize = _t._parent._contentSize; + _t._position.x = _t._normalizedPosition.x * conSize.width; + _t._position.y = _t._normalizedPosition.y * conSize.height; + _t._normalizedPositionDirty = false; + } if (_t._transformDirty) { // Translate values var x = _t._position.x; @@ -2663,7 +2705,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.transform = function (ctx) { // transform for canvas - var t = this.nodeToParentTransform(), + var t = this.getNodeToParentTransform(), worldT = this._transformWorld; //get the world transform if(this._parent){ @@ -2691,6 +2733,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.getNodeToParentTransform = function () { var _t = this; + if(_t._usingNormalizedPosition && _t._parent){ //TODO need refactor + var conSize = _t._parent._contentSize; + _t._position.x = _t._normalizedPosition.x * conSize.width; + _t._position.y = _t._normalizedPosition.y * conSize.height; + _t._normalizedPositionDirty = false; + } if (_t._transformDirty) { var t = _t._transform;// quick reference diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index a79399fd73..602d5b6f1c 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -401,6 +401,14 @@ * @return {cc.AffineTransform} */ getNodeToParentTransform:function () { + var _t = this; + if(_t._usingNormalizedPosition && _t._parent){ //TODO need refactor + var conSize = _t._parent._contentSize; + _t._position.x = _t._normalizedPosition.x * conSize.width; + _t._position.y = _t._normalizedPosition.y * conSize.height; + _t._normalizedPositionDirty = false; + } + if(cc._renderType === cc._RENDER_TYPE_CANVAS) return this._nodeToParentTransformForCanvas(); From ae23adc7a3da980895180548f4c547d020588288 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 16 Oct 2014 15:31:55 +0800 Subject: [PATCH 0798/1564] Issue #5982: Remove all create functions --- cocos2d/actions/CCAction.js | 4 +- cocos2d/actions/CCActionInstant.js | 4 +- cocos2d/core/CCDirector.js | 6 +- cocos2d/core/CCDirectorWebGL.js | 6 +- cocos2d/core/base-nodes/CCNode.js | 6 +- cocos2d/core/scenes/CCLoaderScene.js | 4 +- cocos2d/core/scenes/CCScene.js | 5 -- cocos2d/core/sprites/CCAnimation.js | 4 +- cocos2d/core/sprites/CCAnimationCache.js | 2 +- cocos2d/core/sprites/CCSprite.js | 14 +-- cocos2d/core/sprites/CCSpriteFrameCache.js | 2 +- cocos2d/core/textures/CCTextureAtlas.js | 8 -- cocos2d/labels/CCLabelAtlas.js | 7 -- cocos2d/labels/CCLabelBMFont.js | 9 -- cocos2d/menus/CCMenu.js | 4 - cocos2d/menus/CCMenuItem.js | 87 +++++-------------- cocos2d/particle/CCParticleBatchNode.js | 9 -- cocos2d/particle/CCParticleExamples.js | 33 ------- cocos2d/physics/CCPhysicsSprite.js | 23 +---- .../progress-timer/CCActionProgressTimer.js | 6 -- cocos2d/progress-timer/CCProgressTimer.js | 3 - cocos2d/render-texture/CCRenderTexture.js | 7 +- cocos2d/text-input/CCTextFieldTTF.js | 6 -- cocos2d/tilemap/CCTMXTiledMap.js | 17 +--- cocos2d/tilemap/CCTMXXMLParser.js | 14 +-- cocos2d/transitions/CCTransition.js | 74 +--------------- cocos2d/transitions/CCTransitionPageTurn.js | 2 - cocos2d/transitions/CCTransitionProgress.js | 24 ++--- extensions/ccb-reader/CCBAnimationManager.js | 52 +++++------ extensions/ccb-reader/CCBReader.js | 10 +-- extensions/ccb-reader/CCControlLoader.js | 6 +- extensions/ccb-reader/CCNodeLoader.js | 4 +- extensions/ccb-reader/CCSpriteLoader.js | 18 ++-- .../ccui/base-classes/UIScale9Sprite.js | 6 +- extensions/ccui/base-classes/UIWidget.js | 7 +- extensions/ccui/layouts/UILayout.js | 15 ++-- extensions/ccui/layouts/UILayoutParameter.js | 14 +-- extensions/ccui/uiwidgets/UIButton.js | 17 ++-- extensions/ccui/uiwidgets/UICheckBox.js | 14 +-- extensions/ccui/uiwidgets/UIImageView.js | 9 +- extensions/ccui/uiwidgets/UILoadingBar.js | 9 +- extensions/ccui/uiwidgets/UIRichText.js | 6 +- extensions/ccui/uiwidgets/UISlider.js | 19 ++-- extensions/ccui/uiwidgets/UIText.js | 5 +- extensions/ccui/uiwidgets/UITextAtlas.js | 5 +- extensions/ccui/uiwidgets/UITextBMFont.js | 3 - extensions/ccui/uiwidgets/UITextField.js | 5 +- .../uiwidgets/scroll-widget/UIListView.js | 9 +- .../uiwidgets/scroll-widget/UIPageView.js | 7 +- .../uiwidgets/scroll-widget/UIScrollView.js | 7 +- extensions/cocostudio/armature/CCArmature.js | 8 +- .../armature/display/CCDisplayFactory.js | 10 +-- .../armature/display/CCDisplayManager.js | 4 +- .../utils/CCSpriteFrameCacheHelper.js | 2 +- extensions/cocostudio/reader/GUIReader.js | 32 +++---- extensions/cocostudio/reader/SceneReader.js | 14 +-- extensions/cocostudio/trigger/TriggerMng.js | 2 +- .../gui/control-extension/CCControlButton.js | 14 +-- .../CCControlColourPicker.js | 6 +- .../CCControlPotentiometer.js | 6 +- .../gui/control-extension/CCControlSlider.js | 6 +- .../gui/control-extension/CCControlStepper.js | 4 +- .../gui/control-extension/CCControlSwitch.js | 4 +- .../gui/control-extension/CCControlUtils.js | 2 +- .../gui/control-extension/CCScale9Sprite.js | 6 +- extensions/gui/scrollview/CCScrollView.js | 10 +-- extensions/spine/CCSkeleton.js | 4 +- extensions/spine/CCSkeletonAnimation.js | 2 +- 68 files changed, 234 insertions(+), 539 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 2b154b0cf2..5f0ce14e0a 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -665,12 +665,12 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ * @example * // example * // creates the action with a set boundary - * var sprite = cc.Sprite.create("spriteFileName"); + * var sprite = new cc.Sprite("spriteFileName"); * var followAction = cc.follow(sprite, cc.rect(0, 0, s.width * 2 - 100, s.height)); * this.runAction(followAction); * * // creates the action with no boundary set - * var sprite = cc.Sprite.create("spriteFileName"); + * var sprite = new cc.Sprite("spriteFileName"); * var followAction = cc.follow(sprite); * this.runAction(followAction); */ diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js index 45aab879b0..84e2252fb5 100644 --- a/cocos2d/actions/CCActionInstant.js +++ b/cocos2d/actions/CCActionInstant.js @@ -525,8 +525,8 @@ cc.FlipY.create = cc.flipY; * @param {cc.Point|Number} pos * @param {Number} [y] * @example - * var placeAction = new cc.Place.create(cc.p(200, 200)); - * var placeAction = new cc.Place.create(200, 200); + * var placeAction = new cc.Place(cc.p(200, 200)); + * var placeAction = new cc.Place(200, 200); */ cc.Place = cc.ActionInstant.extend(/** @lends cc.Place# */{ _x: 0, diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index c1f098318b..ffbf5b7c76 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -983,9 +983,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { else fontSize = 0 | (_t._winSizeInPoints.width / 320 * 24); - _t._FPSLabel = cc.LabelTTF.create("000.0", "Arial", fontSize); - _t._SPFLabel = cc.LabelTTF.create("0.000", "Arial", fontSize); - _t._drawsLabel = cc.LabelTTF.create("0000", "Arial", fontSize); + _t._FPSLabel = new cc.LabelTTF("000.0", "Arial", fontSize); + _t._SPFLabel = new cc.LabelTTF("0.000", "Arial", fontSize); + _t._drawsLabel = new cc.LabelTTF("0000", "Arial", fontSize); var locStatsPosition = cc.DIRECTOR_STATS_POSITION; _t._drawsLabel.setPosition(_t._drawsLabel.width / 2 + locStatsPosition.x, _t._drawsLabel.height * 5 / 2 + locStatsPosition.y); diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 64c1407ef8..4566f92dc4 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -219,9 +219,9 @@ cc._tmp.DirectorWebGL = function () { else fontSize = 0 | (_t._winSizeInPoints.width / 320 * 24); - _t._FPSLabel = cc.LabelTTF.create("000.0", "Arial", fontSize); - _t._SPFLabel = cc.LabelTTF.create("0.000", "Arial", fontSize); - _t._drawsLabel = cc.LabelTTF.create("0000", "Arial", fontSize); + _t._FPSLabel = new cc.LabelTTF("000.0", "Arial", fontSize); + _t._SPFLabel = new cc.LabelTTF("0.000", "Arial", fontSize); + _t._drawsLabel = new cc.LabelTTF("0000", "Arial", fontSize); var locStatsPosition = cc.DIRECTOR_STATS_POSITION; _t._drawsLabel.setPosition(_t._drawsLabel.width / 2 + locStatsPosition.x, _t._drawsLabel.height * 5 / 2 + locStatsPosition.y); diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 349e453088..40dafbfa03 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1786,12 +1786,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {cc.AffineTransform} additionalTransform The additional transform * @example * // create a batchNode - * var batch= cc.SpriteBatchNode.create("Icon-114.png"); + * var batch = new cc.SpriteBatchNode("Icon-114.png"); * this.addChild(batch); * * // create two sprites, spriteA will be added to batchNode, they are using different textures. - * var spriteA = cc.Sprite.create(batch->getTexture()); - * var spriteB = cc.Sprite.create("Icon-72.png"); + * var spriteA = new cc.Sprite(batch->getTexture()); + * var spriteB = new cc.Sprite("Icon-72.png"); * * batch.addChild(spriteA); * diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index 05cdab09d6..2781c7c4d1 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -63,7 +63,7 @@ cc.LoaderScene = cc.Scene.extend({ lblHeight = -logoHeight / 2 - 10; } //loading percent - var label = self._label = cc.LabelTTF.create("Loading... 0%", "Arial", fontSize); + var label = self._label = new cc.LabelTTF("Loading... 0%", "Arial", fontSize); label.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, lblHeight))); label.setColor(cc.color(180, 180, 180)); bgLayer.addChild(this._label, 10); @@ -75,7 +75,7 @@ cc.LoaderScene = cc.Scene.extend({ var texture2d = self._texture2d = new cc.Texture2D(); texture2d.initWithElement(img); texture2d.handleLoadedTexture(); - var logo = self._logo = cc.Sprite.create(texture2d); + var logo = self._logo = new cc.Sprite(texture2d); logo.setScale(cc.contentScaleFactor()); logo.x = centerPos.x; logo.y = centerPos.y; diff --git a/cocos2d/core/scenes/CCScene.js b/cocos2d/core/scenes/CCScene.js index 31ff8520d6..a54a179dcd 100644 --- a/cocos2d/core/scenes/CCScene.js +++ b/cocos2d/core/scenes/CCScene.js @@ -56,11 +56,6 @@ cc.Scene = cc.Node.extend(/** @lends cc.Scene# */{ * creates a scene * @deprecated since v3.0,please use new cc.Scene() instead. * @return {cc.Scene} - * @example - * // Example - * var aScene = cc.Scene.create(); - * //OR - * var aScene = new cc.Scene(); */ cc.Scene.create = function () { return new cc.Scene(); diff --git a/cocos2d/core/sprites/CCAnimation.js b/cocos2d/core/sprites/CCAnimation.js index f72661c26b..1c653a0bea 100644 --- a/cocos2d/core/sprites/CCAnimation.js +++ b/cocos2d/core/sprites/CCAnimation.js @@ -259,7 +259,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ var rect = cc.rect(0, 0, 0, 0); rect.width = texture.width; rect.height = texture.height; - var frame = cc.SpriteFrame.create(texture, rect); + var frame = new cc.SpriteFrame(texture, rect); this.addSpriteFrame(frame); }, @@ -269,7 +269,7 @@ cc.Animation = cc.Class.extend(/** @lends cc.Animation# */{ * @param {cc.Rect} rect */ addSpriteFrameWithTexture:function (texture, rect) { - var pFrame = cc.SpriteFrame.create(texture, rect); + var pFrame = new cc.SpriteFrame(texture, rect); this.addSpriteFrame(pFrame); }, diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 3788a3bda8..23adb0a203 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -159,7 +159,7 @@ cc.animationCache = /** @lends cc.animationCache# */{ } else if (frames.length != frameNames.length) { cc.log(cc._LogInfos.animationCache__parseVersion1_4, key); } - animation = cc.Animation.create(frames, delay, 1); + animation = new cc.Animation(frames, delay, 1); cc.animationCache.addAnimation(animation, key); } }, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 28e2bb02f9..356fb65e47 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1026,11 +1026,11 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @return {cc.SpriteFrame} */ displayFrame: function () { - return cc.SpriteFrame.create(this._texture, - cc.rectPointsToPixels(this._rect), - this._rectRotated, - cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), - cc.sizePointsToPixels(this._contentSize)); + return new cc.SpriteFrame(this._texture, + cc.rectPointsToPixels(this._rect), + this._rectRotated, + cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), + cc.sizePointsToPixels(this._contentSize)); }, /** @@ -1038,8 +1038,8 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @function * @param {cc.SpriteBatchNode|null} spriteBatchNode * @example - * var batch = cc.SpriteBatchNode.create("Images/grossini_dance_atlas.png", 15); - * var sprite = cc.Sprite.create(batch.texture, cc.rect(0, 0, 57, 57)); + * var batch = new cc.SpriteBatchNode("Images/grossini_dance_atlas.png", 15); + * var sprite = new cc.Sprite(batch.texture, cc.rect(0, 0, 57, 57)); * batch.addChild(sprite); * layer.addChild(batch); */ diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index c0d2e3b7ee..a8dff3fe6f 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -175,7 +175,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ var frame = frames[key]; var spriteFrame = spriteFrames[key]; if (!spriteFrame) { - spriteFrame = cc.SpriteFrame.create(texture, frame.rect, frame.rotated, frame.offset, frame.size); + spriteFrame = new cc.SpriteFrame(texture, frame.rect, frame.rotated, frame.offset, frame.size); var aliases = frame.aliases; if(aliases){//set aliases for(var i = 0, li = aliases.length; i < li; i++){ diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index 6555014ff5..c08c610078 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -631,14 +631,6 @@ cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads); * @param {String|cc.Texture2D} fileName * @param {Number} capacity * @return {cc.TextureAtlas|Null} - * @example - * 1. - * //creates a TextureAtlas with filename - * var textureAtlas = cc.TextureAtlas.create("res/hello.png", 3); - * 2. - * //creates a TextureAtlas with texture - * var texture = cc.textureCache.addImage("hello.png"); - * var textureAtlas = cc.TextureAtlas.create(texture, 3); */ cc.TextureAtlas.create = function (fileName, capacity) { return new cc.TextureAtlas(fileName, capacity); diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 61d3a764ba..13fca34926 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -410,13 +410,6 @@ cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); * @param {Number} [itemHeight=0] * @param {Number} [startCharMap=""] * @return {cc.LabelAtlas} returns the LabelAtlas object on success - * @example - * //Example - * //creates the cc.LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas - * var myLabel = cc.LabelAtlas.create('Text to display', 'CharMapfile.png', 12, 20, ' ') - * - * //creates the cc.LabelAtlas with a string, a fnt file - * var myLabel = cc.LabelAtlas.create('Text to display', 'CharMapFile.plist‘); */ cc.LabelAtlas.create = function (strText, charMapFile, itemWidth, itemHeight, startCharMap) { return new cc.LabelAtlas(strText, charMapFile, itemWidth, itemHeight, startCharMap); diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index c200741499..5972992eb1 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -1133,15 +1133,6 @@ cc.defineGetterSetter(_p, "textAlign", _p._getAlignment, _p.setAlignment); * @param {Number} [alignment=cc.TEXT_ALIGNMENT_LEFT] * @param {cc.Point} [imageOffset=cc.p(0,0)] * @return {cc.LabelBMFont|Null} - * @example - * // Example 01 - * var label1 = cc.LabelBMFont.create("Test case", "test.fnt"); - * - * // Example 02 - * var label2 = cc.LabelBMFont.create("test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT); - * - * // Example 03 - * var label3 = cc.LabelBMFont.create("This is a \n test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT, cc.p(0,0)); */ cc.LabelBMFont.create = function (str, fntFile, width, alignment, imageOffset) { return new cc.LabelBMFont(str, fntFile, width, alignment, imageOffset); diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 89ca402fb3..579a9e717a 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -574,10 +574,6 @@ _p.enabled; * @deprecated since v3.0, please use new cc.Menu(menuitem1, menuitem2, menuitem3) to create a new menu * @param {...cc.MenuItem|null} menuItems * @return {cc.Menu} - * @example - * // Example - * //there is no limit on how many menu item you can pass in - * var myMenu = cc.Menu.create(menuitem1, menuitem2, menuitem3); */ cc.Menu.create = function (menuItems) { var argc = arguments.length; diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 6f3b31bb7e..7d0753f6d9 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -401,7 +401,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ else this._originalScale = this.scale; - var zoomAction = cc.ScaleTo.create(0.1, this._originalScale * 1.2); + var zoomAction = cc.scaleTo(0.1, this._originalScale * 1.2); zoomAction.setTag(cc.ZOOM_ACTION_TAG); this.runAction(zoomAction); } @@ -414,7 +414,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ if (this._enabled) { cc.MenuItem.prototype.unselected.call(this); this.stopActionByTag(cc.ZOOM_ACTION_TAG); - var zoomAction = cc.ScaleTo.create(0.1, this._originalScale); + var zoomAction = cc.scaleTo(0.1, this._originalScale); zoomAction.setTag(cc.ZOOM_ACTION_TAG); this.runAction(zoomAction); } @@ -475,7 +475,7 @@ cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# ctor: function (value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) { var label; if (value && value.length > 0) { - label = cc.LabelAtlas.create(value, charMapFile, itemWidth, itemHeight, startCharMap); + label = new cc.LabelAtlas(value, charMapFile, itemWidth, itemHeight, startCharMap); } cc.MenuItemLabel.prototype.ctor.call(this, label, callback, target); @@ -516,12 +516,6 @@ cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# * @param {function|String|Null} [callback=null] * @param {cc.Node|Null} [target=] * @return {cc.MenuItemAtlasFont} - * @example - * // Example - * var item = cc.MenuItemAtlasFont.create('text to display', 'font.fnt', 12, 32, ' ') - * - * //OR - * var item = cc.MenuItemAtlasFont.create('text to display', 'font.fnt', 12, 32, ' ', game.run, game) */ cc.MenuItemAtlasFont.create = function (value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) { return new cc.MenuItemAtlasFont(value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target); @@ -579,7 +573,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ this._fontName = cc._globalFontName; this._fontSize = cc._globalFontSize; - var label = cc.LabelTTF.create(value, this._fontName, this._fontSize); + var label = new cc.LabelTTF(value, this._fontName, this._fontSize); if (this.initWithLabel(label, callback, target)) { // do something ? } @@ -621,7 +615,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ }, _recreateLabel: function () { - var label = cc.LabelTTF.create(this._label.string, this._fontName, this._fontSize); + var label = new cc.LabelTTF(this._label.string, this._fontName, this._fontSize); this.setLabel(label); } }); @@ -675,23 +669,11 @@ cc.MenuItemFont.fontName = function () { /** * create a menu item from string - * @deprecated + * @deprecated since v3.0, please use new construction instead * @param {String} value the text to display * @param {String|function|Null} callback the callback to run, either in function name or pass in the actual function * @param {cc.Node|Null} target the target to run callback * @return {cc.MenuItemFont} - * @example - * // Example - * var item = cc.MenuItemFont.create("Game start", 'start', Game) - * //creates a menu item from string "Game start", and when clicked, it will run Game.start() - * - * var item = cc.MenuItemFont.create("Game start", game.start, Game)//same as above - * - * var item = cc.MenuItemFont.create("i do nothing")//create a text menu item that does nothing - * - * //you can set font size and name before or after - * cc.MenuItemFont.setFontName('my Fancy Font'); - * cc.MenuItemFont.setFontSize(62); */ cc.MenuItemFont.create = function (value, callback, target) { return new cc.MenuItemFont(value, callback, target); @@ -758,9 +740,9 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ } else if (four !== undefined && cc.isFunction(three)) { target = four; callback = three; - disabledImage = cc.Sprite.create(selectedSprite); + disabledImage = new cc.Sprite(selectedSprite); } else if (three === undefined) { - disabledImage = cc.Sprite.create(selectedSprite); + disabledImage = new cc.Sprite(selectedSprite); } this.initWithNormalSprite(normalSprite, selectedSprite, disabledImage, callback, target); } @@ -1033,18 +1015,6 @@ cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledIm * @param {String|function|cc.Node|Null} four callback function name in string or actual function, OR target Node * @param {String|function|Null} five callback function name in string or actual function * @return {cc.MenuItemSprite} - * @example - * // Example - * var item = cc.MenuItemSprite.create(normalImage)//create a menu item from a sprite with no functionality - * - * var item = cc.MenuItemSprite.create(normalImage, selectedImage)//create a menu Item, nothing will happen when clicked - * - * var item = cc.MenuItemSprite.create(normalImage, SelectedImage, disabledImage)//same above, but with disabled state image - * - * var item = cc.MenuItemSprite.create(normalImage, SelectedImage, 'callback', targetNode)//create a menu item, when clicked runs targetNode.callback() - * - * var item = cc.MenuItemSprite.create(normalImage, SelectedImage, disabledImage, targetNode.callback, targetNode) - * //same as above, but with disabled image, and passing in callback function */ cc.MenuItemSprite.create = function (normalSprite, selectedSprite, three, four, five) { return new cc.MenuItemSprite(normalSprite, selectedSprite, three, four, five || undefined); @@ -1089,9 +1059,9 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ cc.MenuItemSprite.prototype.ctor.call(this); } else { - normalSprite = cc.Sprite.create(normalImage); + normalSprite = new cc.Sprite(normalImage); selectedImage && - (selectedSprite = cc.Sprite.create(selectedImage)); + (selectedSprite = new cc.Sprite(selectedImage)); if (four === undefined) { callback = three; } @@ -1100,7 +1070,7 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ target = four; } else if (five) { - disabledSprite = cc.Sprite.create(three); + disabledSprite = new cc.Sprite(three); callback = four; target = five; } @@ -1113,7 +1083,7 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ * @param {cc.SpriteFrame} frame */ setNormalSpriteFrame: function (frame) { - this.setNormalImage(cc.Sprite.create(frame)); + this.setNormalImage(new cc.Sprite(frame)); }, /** @@ -1121,7 +1091,7 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ * @param {cc.SpriteFrame} frame */ setSelectedSpriteFrame: function (frame) { - this.setSelectedImage(cc.Sprite.create(frame)); + this.setSelectedImage(new cc.Sprite(frame)); }, /** @@ -1129,7 +1099,7 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ * @param {cc.SpriteFrame} frame */ setDisabledSpriteFrame: function (frame) { - this.setDisabledImage(cc.Sprite.create(frame)); + this.setDisabledImage(new cc.Sprite(frame)); }, /** @@ -1147,13 +1117,13 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ var disabledSprite = null; if (normalImage) { - normalSprite = cc.Sprite.create(normalImage); + normalSprite = new cc.Sprite(normalImage); } if (selectedImage) { - selectedSprite = cc.Sprite.create(selectedImage); + selectedSprite = new cc.Sprite(selectedImage); } if (disabledImage) { - disabledSprite = cc.Sprite.create(disabledImage); + disabledSprite = new cc.Sprite(disabledImage); } return this.initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, callback, target); } @@ -1168,13 +1138,6 @@ cc.MenuItemImage = cc.MenuItemSprite.extend(/** @lends cc.MenuItemImage# */{ * @param {String|function|Null} [four] callback function, either name in string or pass the whole function OR the target * @param {cc.Node|String|function|Null} [five] cc.Node target to run callback when clicked * @return {cc.MenuItemImage} - * @example - * // Example - * //create a dom menu item with normal and selected state, when clicked it will run the run function from gameScene object - * var item = cc.MenuItemImage.create('normal.png', 'selected.png', 'run', gameScene) - * - * //same as above, but pass in the actual function and disabled image - * var item = cc.MenuItemImage.create('normal.png', 'selected.png', 'disabled.png', gameScene.run, gameScene) */ cc.MenuItemImage.create = function (normalImage, selectedImage, three, four, five) { return new cc.MenuItemImage(normalImage, selectedImage, three, four, five); @@ -1193,12 +1156,12 @@ cc.MenuItemImage.create = function (normalImage, selectedImage, three, four, fiv *@example * // Example * //create a toggle item with 2 menu items (which you can then toggle between them later) - * var toggler = new cc.MenuItemToggle( cc.MenuItemFont.create("On"), cc.MenuItemFont.create("Off"), this.callback, this) + * var toggler = new cc.MenuItemToggle( new cc.MenuItemFont("On"), new cc.MenuItemFont("Off"), this.callback, this) * //Note: the first param is the target, the second is the callback function, afterwards, you can pass in any number of menuitems * * //if you pass only 1 variable, then it must be a cc.MenuItem - * var notYetToggler = new cc.MenuItemToggle(cc.MenuItemFont.create("On"));//it is useless right now, until you add more stuff to it - * notYetToggler.addSubItem(cc.MenuItemFont.create("Off")); + * var notYetToggler = new cc.MenuItemToggle(cc.MenuItemFont("On"));//it is useless right now, until you add more stuff to it + * notYetToggler.addSubItem(new cc.MenuItemFont("Off")); * //this is useful for constructing a toggler without a callback function (you wish to control the behavior from somewhere else) */ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ @@ -1441,16 +1404,6 @@ cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIn * @deprecated since v3.0 please use new cc.MenuItemToggle(params) instead * @return {cc.MenuItemToggle} * @example - * // Example - * - * //create a toggle item with 2 menu items (which you can then toggle between them later) - * var toggler = cc.MenuItemToggle.create( cc.MenuItemFont.create("On"), cc.MenuItemFont.create("Off"), this.callback, this) - * //Note: the first param is the target, the second is the callback function, afterwards, you can pass in any number of menuitems - * - * //if you pass only 1 variable, then it must be a cc.MenuItem - * var notYetToggler = cc.MenuItemToggle.create(cc.MenuItemFont.create("On"));//it is useless right now, until you add more stuff to it - * notYetToggler.addSubItem(cc.MenuItemFont.create("Off")); - * //this is useful for constructing a toggler without a callback function (you wish to control the behavior from somewhere else) */ cc.MenuItemToggle.create = function (/*Multiple arguments follow*/) { if ((arguments.length > 0) && (arguments[arguments.length - 1] == null)) diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 2ca29b5da5..4009bdb491 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -577,15 +577,6 @@ cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); * @param {String|cc.Texture2D} fileImage * @param {Number} capacity * @return {cc.ParticleBatchNode} - * @example - * 1. - * //Create a cc.ParticleBatchNode with image path and capacity - * var particleBatchNode = cc.ParticleBatchNode.create("res/grossini_dance.png",30); - * - * 2. - * //Create a cc.ParticleBatchNode with a texture and capacity - * var texture = cc.TextureCache.getInstance().addImage("res/grossini_dance.png"); - * var particleBatchNode = cc.ParticleBatchNode.create(texture, 30); */ cc.ParticleBatchNode.create = function (fileImage, capacity) { return new cc.ParticleBatchNode(fileImage, capacity); diff --git a/cocos2d/particle/CCParticleExamples.js b/cocos2d/particle/CCParticleExamples.js index 7b1e90ef1a..1202482f85 100644 --- a/cocos2d/particle/CCParticleExamples.js +++ b/cocos2d/particle/CCParticleExamples.js @@ -107,9 +107,6 @@ cc.ParticleFire = cc.ParticleSystem.extend(/** @lends cc.ParticleFire# */{ * Create a fire particle system * @deprecated since v3.0 please use new cc.ParticleFire() instead * @return {cc.ParticleFire} - * - * @example - * var emitter = cc.ParticleFire.create(); */ cc.ParticleFire.create = function () { return new cc.ParticleFire(); @@ -195,9 +192,6 @@ cc.ParticleFireworks = cc.ParticleSystem.extend(/** @lends cc.ParticleFireworks# * Create a fireworks particle system * @deprecated since v3.0 please use new cc.ParticleFireworks() instead. * @return {cc.ParticleFireworks} - * - * @example - * var emitter = cc.ParticleFireworks.create(); */ cc.ParticleFireworks.create = function () { return new cc.ParticleFireworks(); @@ -285,9 +279,6 @@ cc.ParticleSun = cc.ParticleSystem.extend(/** @lends cc.ParticleSun# */{ * Create a sun particle system * @deprecated since v3.0 please use new cc.ParticleSun() instead. * @return {cc.ParticleSun} - * - * @example - * var emitter = cc.ParticleSun.create(); */ cc.ParticleSun.create = function () { return new cc.ParticleSun(); @@ -378,9 +369,6 @@ cc.ParticleGalaxy = cc.ParticleSystem.extend(/** @lends cc.ParticleGalaxy# */{ * Create a galaxy particle system * @deprecated since v3.0 please use new cc.OarticleGalaxy() instead. * @return {cc.ParticleGalaxy} - * - * @example - * var emitter = cc.ParticleGalaxy.create(); */ cc.ParticleGalaxy.create = function () { return new cc.ParticleGalaxy(); @@ -471,9 +459,6 @@ cc.ParticleFlower = cc.ParticleSystem.extend(/** @lends cc.ParticleFlower# */{ * Create a flower particle system * @deprecated since v3.0 please use new cc.ParticleFlower() instead. * @return {cc.ParticleFlower} - * - * @example - * var emitter = cc.ParticleFlower.create(); */ cc.ParticleFlower.create = function () { return new cc.ParticleFlower(); @@ -565,9 +550,6 @@ cc.ParticleMeteor = cc.ParticleSystem.extend(/** @lends cc.ParticleMeteor# */{ * Create a meteor particle system * @deprecated since v3.0 please use new cc.ParticleMeteor() instead. * @return {cc.ParticleMeteor} - * - * @example - * var emitter = cc.ParticleMeteor.create(); */ cc.ParticleMeteor.create = function () { return new cc.ParticleMeteor(); @@ -659,9 +641,6 @@ cc.ParticleSpiral = cc.ParticleSystem.extend(/** @lends cc.ParticleSpiral# */{ * Create a spiral particle system * @deprecated since v3.0 please use new cc.ParticleSpiral() instead. * @return {cc.ParticleSpiral} - * - * @example - * var emitter = cc.ParticleSpiral.create(); */ cc.ParticleSpiral.create = function () { return new cc.ParticleSpiral(); @@ -751,9 +730,6 @@ cc.ParticleExplosion = cc.ParticleSystem.extend(/** @lends cc.ParticleExplosion# * Create an explosion particle system * @deprecated since v3.0 please use new cc.ParticleExplosion() instead. * @return {cc.ParticleExplosion} - * - * @example - * var emitter = cc.ParticleExplosion.create(); */ cc.ParticleExplosion.create = function () { return new cc.ParticleExplosion(); @@ -841,9 +817,6 @@ cc.ParticleSmoke = cc.ParticleSystem.extend(/** @lends cc.ParticleSmoke# */{ * Create a smoke particle system * @deprecated since v3.0 please use new cc.ParticleSmoke() instead. * @return {cc.ParticleSmoke} - * - * @example - * var emitter = cc.ParticleFireworks.create(); */ cc.ParticleSmoke.create = function () { return new cc.ParticleSmoke(); @@ -935,9 +908,6 @@ cc.ParticleSnow = cc.ParticleSystem.extend(/** @lends cc.ParticleSnow# */{ * Create a snow particle system * @deprecated since v3.0 please use new cc.ParticleSnow() instead. * @return {cc.ParticleSnow} - * - * @example - * var emitter = cc.ParticleSnow.create(); */ cc.ParticleSnow.create = function () { return new cc.ParticleSnow(); @@ -1030,9 +1000,6 @@ cc.ParticleRain = cc.ParticleSystem.extend(/** @lends cc.ParticleRain# */{ * Create a rain particle system * @deprecated since v3.0 please use cc.ParticleRain() instead. * @return {cc.ParticleRain} - * - * @example - * var emitter = cc.ParticleRain.create(); */ cc.ParticleRain.create = function () { return new cc.ParticleRain(); diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index a79399fd73..e6617182e8 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -49,7 +49,7 @@ * @example * * 1.Create a sprite with image path and rect - * var physicsSprite1 = cc.PhysicsSprite.create("res/HelloHTML5World.png"); + * var physicsSprite1 = new cc.PhysicsSprite("res/HelloHTML5World.png"); * var physicsSprite2 = new cc.PhysicsSprite("res/HelloHTML5World.png",cc.rect(0,0,480,320)); * * 2.Create a sprite with a sprite frame name. Must add "#" before fame name. @@ -220,7 +220,7 @@ * @example * * 1.Create a sprite with image path and rect - * var physicsSprite1 = cc.PhysicsSprite.create("res/HelloHTML5World.png"); + * var physicsSprite1 = new cc.PhysicsSprite("res/HelloHTML5World.png"); * var physicsSprite2 = new cc.PhysicsSprite("res/HelloHTML5World.png",cc.rect(0,0,480,320)); * * 2.Create a sprite with a sprite frame name. Must add "#" before frame name. @@ -512,25 +512,6 @@ * @param {String|cc.Texture2D|cc.SpriteFrame} fileName * @param {cc.Rect} rect * @return {cc.PhysicsSprite} - * @example - * - * 1.Create a sprite with image path and rect - * var physicsSprite1 = cc.PhysicsSprite.create("res/HelloHTML5World.png"); - * var physicsSprite2 = cc.PhysicsSprite.create("res/HelloHTML5World.png",cc.rect(0,0,480,320)); - * - * 2.Create a sprite with a sprite frame name. Must add "#" before fame name. - * var physicsSprite = cc.PhysicsSprite.create('#grossini_dance_01.png'); - * - * 3.Create a sprite with a sprite frame - * var spriteFrame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); - * var physicsSprite = cc.PhysicsSprite.create(spriteFrame); - * - * 4.Creates a sprite with an exsiting texture contained in a CCTexture2D object - * After creation, the rect will be the size of the texture, and the offset will be (0,0). - * var texture = cc.textureCache.addImage("HelloHTML5World.png"); - * var physicsSprite1 = cc.PhysicsSprite.create(texture); - * var physicsSprite2 = cc.PhysicsSprite.create(texture, cc.rect(0,0,480,320)); - * */ cc.PhysicsSprite.create = function (fileName, rect) { return new cc.PhysicsSprite(fileName, rect); diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index db5198b5d2..18f6500e7b 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -127,9 +127,6 @@ cc.progressTo = function (duration, percent) { * @param {Number} duration duration in seconds * @param {Number} percent * @return {cc.ProgressTo} - * @example - * //example - * var progress = cc.ProgressTo.create(duration,percent); */ cc.ProgressTo.create = cc.progressTo; @@ -231,8 +228,5 @@ cc.progressFromTo = function (duration, fromPercentage, toPercentage) { * @param {Number} fromPercentage * @param {Number} toPercentage * @return {cc.ProgressFromTo} - * @example - * //example - * var progress = cc.ProgressFromTo.create(duration, fromPercentage, toPercentage); */ cc.ProgressFromTo.create = cc.progressFromTo; diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 835264ecb9..f980defc22 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -873,9 +873,6 @@ cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDire * @deprecated since v3.0,please use new cc.ProgressTimer(sprite) instead. * @param {cc.Sprite} sprite * @return {cc.ProgressTimer} - * @example - * // Example - * var progress = cc.ProgressTimer.create('progress.png') */ cc.ProgressTimer.create = function (sprite) { return new cc.ProgressTimer(sprite); diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index a460a3e8f8..15e38ff0fe 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -238,7 +238,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ var texture = new cc.Texture2D(); texture.initWithElement(locCacheCanvas); texture.handleLoadedTexture(); - var locSprite = this.sprite = cc.Sprite.create(texture); + var locSprite = this.sprite = new cc.Sprite(texture); locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); // Disabled by default. this.autoDraw = false; @@ -321,7 +321,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ locTexture.setAliasTexParameters(); - this.sprite = cc.Sprite.create(locTexture); + this.sprite = new cc.Sprite(locTexture); var locSprite = this.sprite; locSprite.scaleY = -1; locSprite.setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); @@ -935,9 +935,6 @@ cc.defineGetterSetter(_p, "clearColorVal", _p.getClearColor, _p.setClearColor); * @param {cc.IMAGE_FORMAT_JPEG|cc.IMAGE_FORMAT_PNG|cc.IMAGE_FORMAT_RAWDATA} format * @param {Number} depthStencilFormat * @return {cc.RenderTexture} - * @example - * // Example - * var rt = cc.RenderTexture.create() */ cc.RenderTexture.create = function (width, height, format, depthStencilFormat) { return new cc.RenderTexture(width, height, format, depthStencilFormat); diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index 43d28e237c..e9649f5ad7 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -462,12 +462,6 @@ cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder); * @param {String} fontName * @param {Number} fontSize * @return {cc.TextFieldTTF|Null} - * @example - * //example - * // When five parameters - * var textField = cc.TextFieldTTF.create("", cc.size(100,50), cc.TEXT_ALIGNMENT_LEFT,"Arial", 32); - * // When three parameters - * var textField = cc.TextFieldTTF.create("", "Arial", 32); */ cc.TextFieldTTF.create = function (placeholder, dimensions, alignment, fontName, fontSize) { return new cc.TextFieldTTF(placeholder, dimensions, alignment, fontName, fontSize); diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index 3863aa96f2..2344cdb9fc 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -273,7 +273,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ throw "cc.TMXTiledMap.initWithTMXFile(): tmxFile should be non-null or non-empty string."; this.width = 0; this.height = 0; - var mapInfo = cc.TMXMapInfo.create(tmxFile); + var mapInfo = new cc.TMXMapInfo(tmxFile); if (!mapInfo) return false; @@ -294,7 +294,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ this.width = 0; this.height = 0; - var mapInfo = cc.TMXMapInfo.create(tmxString, resourcePath); + var mapInfo = new cc.TMXMapInfo(tmxString, resourcePath); var locTilesets = mapInfo.getTilesets(); if(!locTilesets || locTilesets.length === 0) cc.log("cc.TMXTiledMap.initWithXML(): Map not found. Please check the filename."); @@ -411,7 +411,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ _parseLayer:function (layerInfo, mapInfo) { var tileset = this._tilesetForLayer(layerInfo, mapInfo); - var layer = cc.TMXLayer.create(tileset, layerInfo, mapInfo); + var layer = new cc.TMXLayer(tileset, layerInfo, mapInfo); // tell the layerinfo to release the ownership of the tiles map. layerInfo.ownTiles = false; layer.setupTiles(); @@ -473,17 +473,6 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); * @param {String} tmxFile tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @return {cc.TMXTiledMap|undefined} - * @example - * //example - * 1. - * //create a TMXTiledMap with file name - * var tmxTiledMap = cc.TMXTiledMap.create("res/orthogonal-test1.tmx"); - * 2. - * //create a TMXTiledMap with content string and resource path - * var resources = "res/TileMaps"; - * var filePath = "res/TileMaps/orthogonal-test1.tmx"; - * var xmlStr = cc.loader.getRes(filePath); - * var tmxTiledMap = cc.TMXTiledMap.create(xmlStr, resources); */ cc.TMXTiledMap.create = function (tmxFile,resourcePath) { return new cc.TMXTiledMap(tmxFile,resourcePath); diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index 613a59d185..bae661de31 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -246,13 +246,13 @@ cc.TMXTilesetInfo = cc.Class.extend(/** @lends cc.TMXTilesetInfo# */{ * @example * 1. * //create a TMXMapInfo with file name - * var tmxMapInfo = cc.TMXMapInfo.create("res/orthogonal-test1.tmx"); + * var tmxMapInfo = new cc.TMXMapInfo("res/orthogonal-test1.tmx"); * 2. * //create a TMXMapInfo with content string and resource path * var resources = "res/TileMaps"; * var filePath = "res/TileMaps/orthogonal-test1.tmx"; * var xmlStr = cc.loader.getRes(filePath); - * var tmxMapInfo = cc.TMXMapInfo.create(xmlStr, resources); + * var tmxMapInfo = new cc.TMXMapInfo(xmlStr, resources); */ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ properties:null, @@ -919,16 +919,6 @@ cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight); * @param {String} tmxFile fileName or content string * @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required. * @return {cc.TMXMapInfo} - * @example - * 1. - * //create a TMXMapInfo with file name - * var tmxMapInfo = cc.TMXMapInfo.create("res/orthogonal-test1.tmx"); - * 2. - * //create a TMXMapInfo with content string and resource path - * var resources = "res/TileMaps"; - * var filePath = "res/TileMaps/orthogonal-test1.tmx"; - * var xmlStr = cc.loader.getRes(filePath); - * var tmxMapInfo = cc.TMXMapInfo.create(xmlStr, resources); */ cc.TMXMapInfo.create = function (tmxFile, resourcePath) { return new cc.TMXMapInfo(tmxFile, resourcePath); diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 08f7663257..07a5bd7e8e 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -191,7 +191,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ this._inScene = scene; this._outScene = cc.director.getRunningScene(); if (!this._outScene) { - this._outScene = cc.Scene.create(); + this._outScene = new cc.Scene(); this._outScene.init(); } @@ -300,9 +300,6 @@ cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionS * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation * @return {cc.TransitionSceneOriented} - * @example - * // Example - * var goHorizontal = cc.TransitionSceneOriented.create(0.5, thisScene, cc.TRANSITION_ORIENTATION_LEFT_OVER) */ cc.TransitionSceneOriented.create = function (t, scene, orientation) { return new cc.TransitionSceneOriented(t, scene, orientation); @@ -365,8 +362,6 @@ cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZo * @param {Number} t time in seconds * @param {cc.Scene} scene the scene to work with * @return {cc.TransitionRotoZoom} - * @example - * var RotoZoomTrans = cc.TransitionRotoZoom.create(2, nextScene); */ cc.TransitionRotoZoom.create = function (t, scene) { return new cc.TransitionRotoZoom(t, scene); @@ -494,8 +489,6 @@ cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInL} - * @example - * var MoveInLeft = cc.TransitionMoveInL.create(1, nextScene) */ cc.TransitionMoveInL.create = function (t, scene) { return new cc.TransitionMoveInL(t, scene); @@ -534,8 +527,6 @@ cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInR} - * @example - * var MoveInRight = cc.TransitionMoveInR.create(1, nextScene) */ cc.TransitionMoveInR.create = function (t, scene) { return new cc.TransitionMoveInR(t, scene); @@ -574,8 +565,6 @@ cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInT} - * @example - * var MoveInTop = cc.TransitionMoveInT.create(1, nextScene) */ cc.TransitionMoveInT.create = function (t, scene) { return new cc.TransitionMoveInT(t, scene); @@ -615,8 +604,6 @@ cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveI * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionMoveInB} - * @example - * var MoveinB = cc.TransitionMoveInB.create(1, nextScene) */ cc.TransitionMoveInB.create = function (t, scene) { return new cc.TransitionMoveInB(t, scene); @@ -700,8 +687,6 @@ cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideI * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInL} - * @example - * var myTransition = cc.TransitionSlideInL.create(1.5, nextScene) */ cc.TransitionSlideInL.create = function (t, scene) { return new cc.TransitionSlideInL(t, scene); @@ -750,8 +735,6 @@ cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInR} - * @example - * var myTransition = cc.TransitionSlideInR.create(1.5, nextScene) */ cc.TransitionSlideInR.create = function (t, scene) { return new cc.TransitionSlideInR(t, scene); @@ -802,8 +785,6 @@ cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInB} - * @example - * var myTransition = cc.TransitionSlideInB.create(1.5, nextScene) */ cc.TransitionSlideInB.create = function (t, scene) { return new cc.TransitionSlideInB(t, scene); @@ -854,8 +835,6 @@ cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSli * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSlideInT} - * @example - * var myTransition = cc.TransitionSlideInT.create(1.5, nextScene) */ cc.TransitionSlideInT.create = function (t, scene) { return new cc.TransitionSlideInT(t, scene); @@ -921,8 +900,6 @@ cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShri * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionShrinkGrow} - * @example - * var myTransition = cc.TransitionShrinkGrow.create(1.5, nextScene) */ cc.TransitionShrinkGrow.create = function (t, scene) { return new cc.TransitionShrinkGrow(t, scene); @@ -1001,10 +978,6 @@ cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionFlipX} - * @example - * var myTransition = cc.TransitionFlipX.create(1.5, nextScene) //default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * //OR - * var myTransition = cc.TransitionFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_UP_OVER) */ cc.TransitionFlipX.create = function (t, scene, o) { return new cc.TransitionFlipX(t, scene, o); @@ -1081,10 +1054,6 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionFlipY} - * @example - * var myTransition = cc.TransitionFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER - * //OR - * var myTransition = cc.TransitionFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_RIGHT_OVER) */ cc.TransitionFlipY.create = function (t, scene, o) { return new cc.TransitionFlipY(t, scene, o); @@ -1160,10 +1129,6 @@ cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.Trans * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionFlipAngular} - * @example - * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * //or - * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionFlipAngular.create = function (t, scene, o) { return new cc.TransitionFlipAngular(t, scene, o); @@ -1246,10 +1211,6 @@ cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.Transit * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionZoomFlipX} - * @example - * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * //OR - * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionZoomFlipX.create = function (t, scene, o) { return new cc.TransitionZoomFlipX(t, scene, o); @@ -1330,10 +1291,6 @@ cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.Transit * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionZoomFlipY} - * @example - * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER - * //OR - * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionZoomFlipY.create = function (t, scene, o) { return new cc.TransitionZoomFlipY(t, scene, o); @@ -1413,10 +1370,6 @@ cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.T * @param {cc.Scene} scene * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o * @return {cc.TransitionZoomFlipAngular} - * @example - * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER - * //OR - * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) */ cc.TransitionZoomFlipAngular.create = function (t, scene, o) { return new cc.TransitionZoomFlipAngular(t, scene, o); @@ -1503,8 +1456,6 @@ cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ * @param {cc.Scene} scene * @param {cc.Color} color * @return {cc.TransitionFade} - * @example - * var myTransition = cc.TransitionFade.create(1.5, nextScene, cc.color(255,0,0))//fade to red */ cc.TransitionFade.create = function (t, scene, color) { return new cc.TransitionFade(t, scene, color); @@ -1539,10 +1490,10 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross // in which we are going to add our rendertextures var color = cc.color(0, 0, 0, 0); var winSize = cc.director.getWinSize(); - var layer = cc.LayerColor.create(color); + var layer = new cc.LayerColor(color); // create the first render texture for inScene - var inTexture = cc.RenderTexture.create(winSize.width, winSize.height); + var inTexture = new cc.RenderTexture(winSize.width, winSize.height); if (null == inTexture) return; @@ -1562,7 +1513,7 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross inTexture.end(); // create the second render texture for outScene - var outTexture = cc.RenderTexture.create(winSize.width, winSize.height); + var outTexture = new cc.RenderTexture(winSize.width, winSize.height); outTexture.setPosition(winSize.width / 2, winSize.height / 2); outTexture.sprite.anchorX = outTexture.anchorX = 0.5; outTexture.sprite.anchorY = outTexture.anchorY = 0.5; @@ -1625,8 +1576,6 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionCrossFade} - * @example - * var myTransition = cc.TransitionCrossFade.create(1.5, nextScene) */ cc.TransitionCrossFade.create = function (t, scene) { return new cc.TransitionCrossFade(t, scene); @@ -1695,8 +1644,6 @@ cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTu * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionTurnOffTiles} - * @example - * var myTransition = cc.TransitionTurnOffTiles.create(1.5, nextScene) */ cc.TransitionTurnOffTiles.create = function (t, scene) { return new cc.TransitionTurnOffTiles(t, scene); @@ -1778,8 +1725,6 @@ cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplit * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSplitCols} - * @example - * var myTransition = cc.TransitionSplitCols.create(1.5, nextScene) */ cc.TransitionSplitCols.create = function (t, scene) { return new cc.TransitionSplitCols(t, scene); @@ -1819,8 +1764,6 @@ cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionS * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionSplitRows} - * @example - * var myTransition = cc.TransitionSplitRows.create(1.5, nextScene) */ cc.TransitionSplitRows.create = function (t, scene) { return new cc.TransitionSplitRows(t, scene); @@ -1899,8 +1842,6 @@ cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeTR} - * @example - * var myTransition = cc.TransitionFadeTR.create(1.5, nextScene) */ cc.TransitionFadeTR.create = function (t, scene) { return new cc.TransitionFadeTR(t, scene); @@ -1941,9 +1882,6 @@ cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeBL} - * @example - * // Example - * var myTransition = cc.TransitionFadeBL.create(1.5, nextScene) */ cc.TransitionFadeBL.create = function (t, scene) { return new cc.TransitionFadeBL(t, scene); @@ -1986,8 +1924,6 @@ cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeUp} - * @example - * var myTransition = cc.TransitionFadeUp.create(1.5, nextScene) */ cc.TransitionFadeUp.create = function (t, scene) { return new cc.TransitionFadeUp(t, scene); @@ -2029,8 +1965,6 @@ cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeD * @param {Number} t time in seconds * @param {cc.Scene} scene * @return {cc.TransitionFadeDown} - * @example - * var myTransition = cc.TransitionFadeDown.create(1.5, nextScene) */ cc.TransitionFadeDown.create = function (t, scene) { return new cc.TransitionFadeDown(t, scene); diff --git a/cocos2d/transitions/CCTransitionPageTurn.js b/cocos2d/transitions/CCTransitionPageTurn.js index e3e8ac38ce..6b71fd848b 100644 --- a/cocos2d/transitions/CCTransitionPageTurn.js +++ b/cocos2d/transitions/CCTransitionPageTurn.js @@ -146,8 +146,6 @@ cc.TransitionPageTurn = cc.TransitionScene.extend(/** @lends cc.TransitionPageTu * @param {cc.Scene} scene * @param {Boolean} backwards * @return {cc.TransitionPageTurn} - * @example - * var myTransition = cc.TransitionPageTurn.create(1.5, nextScene, true)//true means backwards */ cc.TransitionPageTurn.create = function (t, scene, backwards) { return new cc.TransitionPageTurn(t, scene, backwards); diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index 8ab4f3216a..ab128091c8 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -77,7 +77,7 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre var winSize = cc.director.getWinSize(); // create the second render texture for outScene - var texture = cc.RenderTexture.create(winSize.width, winSize.height); + var texture = new cc.RenderTexture(winSize.width, winSize.height); texture.sprite.anchorX = 0.5; texture.sprite.anchorY = 0.5; this._setAttrs(texture, winSize.width / 2, winSize.height / 2); @@ -139,8 +139,6 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgress} - * @example - * var trans = cc.TransitionProgress.create(time,scene); */ cc.TransitionProgress.create = function (t, scene) { return new cc.TransitionProgress(t, scene); @@ -170,7 +168,7 @@ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.Tran _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); - var pNode = cc.ProgressTimer.create(texture.sprite); + var pNode = new cc.ProgressTimer(texture.sprite); // but it is flipped upside down so we flip the sprite if (cc._renderType === cc._RENDER_TYPE_WEBGL) @@ -193,7 +191,7 @@ cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend(/** @lends cc.Tran * @param {cc.Scene} scene * @return {cc.TransitionProgressRadialCCW} * @example - * var trans = cc.TransitionProgressRadialCCW.create(time,scene); + * var trans = new cc.TransitionProgressRadialCCW(time,scene); */ cc.TransitionProgressRadialCCW.create = function (t, scene) { return new cc.TransitionProgressRadialCCW(t, scene); @@ -222,7 +220,7 @@ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.Trans _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); - var pNode = cc.ProgressTimer.create(texture.sprite); + var pNode = new cc.ProgressTimer(texture.sprite); // but it is flipped upside down so we flip the sprite if (cc._renderType === cc._RENDER_TYPE_WEBGL) @@ -244,8 +242,6 @@ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.Trans * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressRadialCW} - * @example - * var trans = cc.TransitionProgressRadialCW.create(time,scene); */ cc.TransitionProgressRadialCW.create = function (t, scene) { var tempScene = new cc.TransitionProgressRadialCW(); @@ -278,7 +274,7 @@ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.Tra _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); - var pNode = cc.ProgressTimer.create(texture.sprite); + var pNode = new cc.ProgressTimer(texture.sprite); // but it is flipped upside down so we flip the sprite if (cc._renderType === cc._RENDER_TYPE_WEBGL) @@ -301,8 +297,6 @@ cc.TransitionProgressHorizontal = cc.TransitionProgress.extend(/** @lends cc.Tra * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressHorizontal} - * @example - * var trans = cc.TransitionProgressHorizontal.create(time,scene); */ cc.TransitionProgressHorizontal.create = function (t, scene) { return new cc.TransitionProgressHorizontal(t, scene); @@ -331,7 +325,7 @@ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.Trans _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); - var pNode = cc.ProgressTimer.create(texture.sprite); + var pNode = new cc.ProgressTimer(texture.sprite); // but it is flipped upside down so we flip the sprite if (cc._renderType === cc._RENDER_TYPE_WEBGL) @@ -354,8 +348,6 @@ cc.TransitionProgressVertical = cc.TransitionProgress.extend(/** @lends cc.Trans * @param {Number} t time * @param {cc.Scene} scene * @return {cc.TransitionProgressVertical} - * @example - * var trans = cc.TransitionProgressVertical.create(time,scene); */ cc.TransitionProgressVertical.create = function (t, scene) { return new cc.TransitionProgressVertical(t, scene); @@ -380,7 +372,7 @@ cc.TransitionProgressInOut = cc.TransitionProgress.extend(/** @lends cc.Transiti _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); - var pNode = cc.ProgressTimer.create(texture.sprite); + var pNode = new cc.ProgressTimer(texture.sprite); // but it is flipped upside down so we flip the sprite if (cc._renderType === cc._RENDER_TYPE_WEBGL) @@ -436,7 +428,7 @@ cc.TransitionProgressOutIn = cc.TransitionProgress.extend(/** @lends cc.Transiti _progressTimerNodeWithRenderTexture:function (texture) { var size = cc.director.getWinSize(); - var pNode = cc.ProgressTimer.create(texture.sprite); + var pNode = new cc.ProgressTimer(texture.sprite); // but it is flipped upside down so we flip the sprite if (cc._renderType === cc._RENDER_TYPE_WEBGL) diff --git a/extensions/ccb-reader/CCBAnimationManager.js b/extensions/ccb-reader/CCBAnimationManager.js index ec41be26ca..0b8e9cdfbc 100644 --- a/extensions/ccb-reader/CCBAnimationManager.js +++ b/extensions/ccb-reader/CCBAnimationManager.js @@ -231,7 +231,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ var timeSinceLastKeyframe = keyframe.getTime() - lastKeyframeTime; lastKeyframeTime = keyframe.getTime(); if(timeSinceLastKeyframe > 0) { - actions.push(cc.DelayTime.create(timeSinceLastKeyframe)); + actions.push(cc.delayTime(timeSinceLastKeyframe)); } var keyVal = keyframe.getValue(); @@ -262,7 +262,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ if(selCallFunc == 0) cc.log("Skipping selector '" + selectorName + "' since no CCBSelectorResolver is present."); else - actions.push(cc.CallFunc.create(selCallFunc,target)); + actions.push(cc.callFunc(selCallFunc,target)); } else { cc.log("Unexpected empty selector."); } @@ -272,7 +272,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ if(actions.length < 1) return null; - return cc.Sequence.create(actions); + return cc.sequence(actions); }, getActionForSoundChannel:function(channel) { var lastKeyframeTime = 0; @@ -286,7 +286,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ var timeSinceLastKeyframe = keyframe.getTime() - lastKeyframeTime; lastKeyframeTime = keyframe.getTime(); if(timeSinceLastKeyframe > 0) { - actions.push(cc.DelayTime.create(timeSinceLastKeyframe)); + actions.push(cc.delayTime(timeSinceLastKeyframe)); } var keyVal = keyframe.getValue(); @@ -298,7 +298,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ if(actions.length < 1) return null; - return cc.Sequence.create(actions); + return cc.sequence(actions); }, runAnimationsForSequenceNamed:function(name){ @@ -444,19 +444,19 @@ cc.BuilderAnimationManager = cc.Class.extend({ } else if (propName === "rotationY") { return cc.BuilderRotateYTo.create(duration, keyframe1.getValue()); } else if (propName === "opacity") { - return cc.FadeTo.create(duration, keyframe1.getValue()); + return cc.fadeTo(duration, keyframe1.getValue()); } else if (propName === "color") { var selColor = keyframe1.getValue().getColor(); - return cc.TintTo.create(duration, selColor.r, selColor.g, selColor.b); + return cc.tintTo(duration, selColor.r, selColor.g, selColor.b); } else if (propName === "visible") { var isVisible = keyframe1.getValue(); if (isVisible) { - return cc.Sequence.create(cc.DelayTime.create(duration), cc.Show.create()); + return cc.sequence(cc.delayTime(duration), cc.show()); } else { - return cc.Sequence.create(cc.DelayTime.create(duration), cc.Hide.create()); + return cc.sequence(cc.delayTime(duration), cc.hide()); } } else if (propName === "displayFrame") { - return cc.Sequence.create(cc.DelayTime.create(duration), cc.BuilderSetSpriteFrame.create(keyframe1.getValue())); + return cc.sequence(cc.delayTime(duration), cc.BuilderSetSpriteFrame.create(keyframe1.getValue())); } else if(propName === "position"){ getArr = this._getBaseValue(node,propName); type = getArr[2]; @@ -470,7 +470,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ var absPos = cc._getAbsolutePosition(x,y, type,containerSize,propName); - return cc.MoveTo.create(duration,absPos); + return cc.moveTo(duration,absPos); } else if( propName === "scale"){ getArr = this._getBaseValue(node,propName); type = getArr[2]; @@ -487,13 +487,13 @@ cc.BuilderAnimationManager = cc.Class.extend({ y *= resolutionScale; } - return cc.ScaleTo.create(duration,x,y); + return cc.scaleTo(duration,x,y); } else if( propName === "skew") { //get relative position getValueArr = keyframe1.getValue(); x = getValueArr[0]; y = getValueArr[1]; - return cc.SkewTo.create(duration,x,y); + return cc.skewTo(duration,x,y); } else { cc.log("BuilderReader: Failed to create animation for property: " + propName); } @@ -584,29 +584,29 @@ cc.BuilderAnimationManager = cc.Class.extend({ if (easingType === CCB_KEYFRAME_EASING_LINEAR || easingType === CCB_KEYFRAME_EASING_INSTANT ) { return action; } else if (easingType === CCB_KEYFRAME_EASING_CUBIC_IN) { - return cc.EaseIn.create(action, easingOpt); + return action.easing(cc.easeIn(easingOpt)); } else if (easingType === CCB_KEYFRAME_EASING_CUBIC_OUT) { - return cc.EaseOut.create(action, easingOpt); + return action.easing(cc.easeOut(easingOpt)); } else if (easingType === CCB_KEYFRAME_EASING_CUBIC_INOUT) { - return cc.EaseInOut.create(action, easingOpt); + return action.easing(cc.easeInOut(easingOpt)); } else if (easingType === CCB_KEYFRAME_EASING_BACK_IN) { - return cc.EaseBackIn.create(action); + return action.easing(cc.easeBackIn()); } else if (easingType === CCB_KEYFRAME_EASING_BACK_OUT) { - return cc.EaseBackOut.create(action); + return action.easing(cc.easeBackOut()); } else if (easingType === CCB_KEYFRAME_EASING_BACK_INOUT) { - return cc.EaseBackInOut.create(action); + return action.easing(cc.easeBackInOut()); } else if (easingType === CCB_KEYFRAME_EASING_BOUNCE_IN) { - return cc.EaseBounceIn.create(action); + return action.easing(cc.easeBounceIn()); } else if (easingType === CCB_KEYFRAME_EASING_BOUNCE_OUT) { - return cc.EaseBounceOut.create(action); + return action.easing(cc.easeBounceOut()); } else if (easingType === CCB_KEYFRAME_EASING_BOUNCE_INOUT) { - return cc.EaseBounceInOut.create(action); + return action.easing(cc.easeBounceInOut()); } else if (easingType === CCB_KEYFRAME_EASING_ELASTIC_IN) { - return cc.EaseElasticIn.create(action, easingOpt); + return action.easing(cc.easeElasticIn(easingOpt)); } else if (easingType === CCB_KEYFRAME_EASING_ELASTIC_OUT) { - return cc.EaseElasticOut.create(action, easingOpt); + return action.easing(cc.easeElasticOut(easingOpt)); } else if (easingType === CCB_KEYFRAME_EASING_ELASTIC_INOUT) { - return cc.EaseElasticInOut.create(action, easingOpt); + return action.easing(cc.easeElasticInOut(easingOpt)); } else { cc.log("BuilderReader: Unkown easing type " + easingType); return action; @@ -625,7 +625,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ var timeFirst = keyframeFirst.getTime() + tweenDuration; if (timeFirst > 0) { - actions.push(cc.DelayTime.create(timeFirst)); + actions.push(cc.delayTime(timeFirst)); } for (var i = 0; i < numKeyframes - 1; ++i) { diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index 3b1105b028..98d8512233 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -305,7 +305,7 @@ cc.BuilderReader = cc.Class.extend({ createSceneWithNodeGraphFromFile:function (ccbFileName, owner, parentSize, animationManager) { var node = this.readNodeGraphFromFile(ccbFileName, owner, parentSize, animationManager); - var scene = cc.Scene.create(); + var scene = new cc.Scene(); scene.addChild(node); return scene; }, @@ -691,7 +691,7 @@ cc.BuilderReader = cc.Class.extend({ var texture = cc.textureCache.addImage(spriteFile); var locContentSize = texture.getContentSize(); var bounds = cc.rect(0, 0, locContentSize.width, locContentSize.height); - value = cc.SpriteFrame.create(texture, bounds); + value = new cc.SpriteFrame(texture, bounds); } else { spriteSheet = this._ccbRootPath + spriteSheet; var frameCache = cc.spriteFrameCache; @@ -967,7 +967,7 @@ cc.BuilderReader.loadAsScene = function (ccbFilePath, owner, parentSize, ccbRoot var getNode = cc.BuilderReader.load(ccbFilePath, owner, parentSize, ccbRootPath); - var scene = cc.Scene.create(); + var scene = new cc.Scene(); scene.addChild(getNode); return scene; }; @@ -1073,9 +1073,9 @@ cc.BuilderReader.load = function (ccbFilePath, owner, parentSize, ccbRootPath) { var kfCallbackName = callbackSplit[1]; if (callbackType == 1){ // Document callback - animationManager.setCallFunc(cc.CallFunc.create(controller[kfCallbackName], controller), keyframeCallbacks[j]); + animationManager.setCallFunc(cc.callFunc(controller[kfCallbackName], controller), keyframeCallbacks[j]); } else if (callbackType == 2 && owner) {// Owner callback - animationManager.setCallFunc(cc.CallFunc.create(owner[kfCallbackName], owner), keyframeCallbacks[j]); + animationManager.setCallFunc(cc.callFunc(owner[kfCallbackName], owner), keyframeCallbacks[j]); } } } diff --git a/extensions/ccb-reader/CCControlLoader.js b/extensions/ccb-reader/CCControlLoader.js index c739e2cc14..7e0bf1e499 100644 --- a/extensions/ccb-reader/CCControlLoader.js +++ b/extensions/ccb-reader/CCControlLoader.js @@ -89,7 +89,7 @@ var PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED = "backgroundSpriteFrame|3"; cc.ControlButtonLoader = cc.ControlLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.ControlButton.create(); + return new cc.ControlButton(); }, onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) { @@ -188,7 +188,7 @@ var PROPERTY_SCALE = "scale"; cc.ScrollViewLoader = cc.NodeLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.ScrollView.create(); + return new cc.ScrollView(); }, onHandlePropTypeSize:function(node,parent,propertyName,size,ccbReader){ @@ -248,7 +248,7 @@ var PROPERTY_INSETBOTTOM = "insetBottom"; cc.Scale9SpriteLoader = cc.NodeLoader.extend({ _createCCNode:function(parent,ccbReader){ - var sprite = cc.Scale9Sprite.create(); + var sprite = new cc.Scale9Sprite(); sprite.setAnchorPoint(0, 0); diff --git a/extensions/ccb-reader/CCNodeLoader.js b/extensions/ccb-reader/CCNodeLoader.js index 99ffa33290..b00c01b377 100644 --- a/extensions/ccb-reader/CCNodeLoader.js +++ b/extensions/ccb-reader/CCNodeLoader.js @@ -332,7 +332,7 @@ cc.NodeLoader = cc.Class.extend({ }, _createCCNode:function (parent, ccbReader) { - return cc.Node.create(); + return new cc.Node(); }, parsePropTypePosition:function (node, parent, ccbReader, propertyName) { @@ -484,7 +484,7 @@ cc.NodeLoader = cc.Class.extend({ var locContentSize = texture.getContentSize(); var bounds = cc.rect(0, 0, locContentSize.width, locContentSize.height); - spriteFrame = cc.SpriteFrame.create(texture, bounds); + spriteFrame = new cc.SpriteFrame(texture, bounds); } else { var frameCache = cc.spriteFrameCache; spriteSheet = ccbReader.getCCBRootPath() + spriteSheet; diff --git a/extensions/ccb-reader/CCSpriteLoader.js b/extensions/ccb-reader/CCSpriteLoader.js index 604a6324ed..b1ba28e7ac 100644 --- a/extensions/ccb-reader/CCSpriteLoader.js +++ b/extensions/ccb-reader/CCSpriteLoader.js @@ -32,7 +32,7 @@ var PROPERTY_BLENDFUNC = "blendFunc"; cc.SpriteLoader = cc.NodeLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.Sprite.create(); + return new cc.Sprite(); }, onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) { @@ -94,7 +94,7 @@ var PROPERTY_IS_KEYBOARD_ENABLED = "isKeyboardEnabled"; cc.LayerLoader = cc.NodeLoader.extend({ _createCCNode:function (parent, ccbReader) { - var layer=cc.Layer.create(); + var layer = new cc.Layer(); layer.setContentSize(0,0); @@ -128,7 +128,7 @@ cc.LayerLoader.loader = function () { cc.LayerColorLoader = cc.LayerLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.LayerColor.create(); + return new cc.LayerColor(); }, onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) { @@ -166,7 +166,7 @@ var PROPERTY_VECTOR = "vector"; cc.LayerGradientLoader = cc.LayerLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.LayerGradient.create(); + return new cc.LayerGradient(); }, onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) { if (propertyName === PROPERTY_STARTCOLOR) { @@ -210,7 +210,7 @@ cc.LayerGradientLoader.loader = function () { cc.MenuLoader = cc.LayerLoader.extend({ _createCCNode:function (parent, ccbReader) { - var menu = cc.Menu.create(); + var menu = new cc.Menu(); menu.setContentSize(0,0); @@ -254,7 +254,7 @@ var PROPERTY_DISABLEDDISPLAYFRAME = "disabledSpriteFrame"; cc.MenuItemImageLoader = cc.MenuItemLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.MenuItemImage.create(); + return new cc.MenuItemImage(); }, onHandlePropTypeSpriteFrame:function (node, parent, propertyName, spriteFrame, ccbReader) { @@ -289,7 +289,7 @@ var PROPERTY_DIMENSIONS = "dimensions"; cc.LabelTTFLoader = cc.NodeLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.LabelTTF.create(); + return new cc.LabelTTF(); }, onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) { if (propertyName === PROPERTY_COLOR) { @@ -361,7 +361,7 @@ var PROPERTY_FNTFILE = "fntFile"; cc.LabelBMFontLoader = cc.NodeLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.LabelBMFont.create(); + return new cc.LabelBMFont(); }, onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) { @@ -429,7 +429,7 @@ var PROPERTY_ROTATEPERSECOND = "rotatePerSecond"; cc.ParticleSystemLoader = cc.NodeLoader.extend({ _createCCNode:function (parent, ccbReader) { - return cc.ParticleSystem.create(); + return new cc.ParticleSystem(); }, onHandlePropTypeIntegerLabeled:function (node, parent, propertyName, integerLabeled, ccbReader) { diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index b5e929e285..056dedd5b1 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -595,7 +595,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, this); } - return this.initWithBatchNode(cc.SpriteBatchNode.create(file, 9), rect, false, capInsets); + return this.initWithBatchNode(new cc.SpriteBatchNode(file, 9), rect, false, capInsets); }, /** @@ -626,7 +626,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._callLoadedEventCallbacks(); },this); } - var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); + var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9); // the texture is rotated on Canvas render mode, so isRotated always is false. return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets); }, @@ -1011,7 +1011,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * @param {cc.SpriteFrame} spriteFrame */ setSpriteFrame: function (spriteFrame) { - var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); + var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9); // the texture is rotated on Canvas render mode, so isRotated always is false. var locLoaded = spriteFrame.textureLoaded(); this._textureLoaded = locLoaded; diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index a8ecd23ff9..2c839565e3 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -26,7 +26,7 @@ /** * The base class for ccui controls and layout * @sample - * var uiWidget = ccui.Widget.create(); + * var uiWidget = new ccui.Widget(); * this.addChild(uiWidget); * @class * @extends ccui.ProtectedNode @@ -1254,7 +1254,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _createCloneInstance: function () { - return ccui.Widget.create(); + return new ccui.Widget(); }, _copyClonedWidgetChildren: function (model) { @@ -1580,9 +1580,6 @@ _p = null; * allocates and initializes a UIWidget. * @deprecated * @return {ccui.Widget} - * @example - * // example - * var uiWidget = ccui.Widget.create(); */ ccui.Widget.create = function () { return new ccui.Widget(); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 92ca7533e9..55d4cb37ad 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -608,7 +608,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ switch (this._clippingType) { case ccui.Layout.CLIPPING_STENCIL: if (able){ - this._clippingStencil = cc.DrawNode.create(); + this._clippingStencil = new cc.DrawNode(); if(cc._renderType === cc._RENDER_TYPE_CANVAS) this._clippingStencil._rendererCmd.rendering = this.__stencilDraw.bind(this); if (this._running) @@ -844,12 +844,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Layout.LINEAR_VERTICAL: var layoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.LINEAR); if (!layoutParameter) - locChild.setLayoutParameter(ccui.LinearLayoutParameter.create()); + locChild.setLayoutParameter(new ccui.LinearLayoutParameter()); break; case ccui.Layout.RELATIVE: var layoutParameter = locChild.getLayoutParameter(ccui.LayoutParameter.RELATIVE); if (!layoutParameter) - locChild.setLayoutParameter(ccui.RelativeLayoutParameter.create()); + locChild.setLayoutParameter(new ccui.RelativeLayoutParameter()); break; default: break; @@ -858,10 +858,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _addBackGroundImage: function () { if (this._backGroundScale9Enabled) { - this._backGroundImage = ccui.Scale9Sprite.create(); + this._backGroundImage = new ccui.Scale9Sprite(); this._backGroundImage.setPreferredSize(this._contentSize); } else - this._backGroundImage = cc.Sprite.create(); + this._backGroundImage = new cc.Sprite(); this.addProtectedChild(this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1); this._backGroundImage.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); }, @@ -1782,7 +1782,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _createCloneInstance: function () { - return ccui.Layout.create(); + return new ccui.Layout(); }, _copyClonedWidgetChildren: function (model) { @@ -1853,9 +1853,6 @@ _p = null; * allocates and initializes a UILayout. * @deprecated since v3.0, please use new ccui.Layout() instead. * @return {ccui.Layout} - * @example - * // example - * var uiLayout = ccui.Layout.create(); */ ccui.Layout.create = function () { return new ccui.Layout(); diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 0babd3ccf8..96b6e812ab 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -177,9 +177,6 @@ ccui.LayoutParameter = ccui.Class.extend(/** @lends ccui.LayoutParameter# */{ * allocates and initializes a LayoutParameter. * @constructs * @return {ccui.LayoutParameter} - * @example - * // example - * var uiLayoutParameter = ccui.LayoutParameter.create(); */ ccui.LayoutParameter.create = function () { return new ccui.LayoutParameter(); @@ -240,7 +237,7 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL }, _createCloneInstance: function () { - return ccui.LinearLayoutParameter.create(); + return new ccui.LinearLayoutParameter(); }, _copyProperties: function (model) { @@ -254,9 +251,7 @@ ccui.LinearLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.LinearL * allocates and initializes a LinearLayoutParameter. * @constructs * @return {ccui.LinearLayoutParameter} - * @example - * // example - * var uiLinearLayoutParameter = ccui.LinearLayoutParameter.create(); + * @deprecated since v3.0, please use new construction instead */ ccui.LinearLayoutParameter.create = function () { return new ccui.LinearLayoutParameter(); @@ -380,7 +375,7 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat }, _createCloneInstance:function(){ - return ccui.RelativeLayoutParameter.create(); + return new ccui.RelativeLayoutParameter(); }, _copyProperties:function(model){ @@ -398,9 +393,6 @@ ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend(/** @lends ccui.Relat * @function * @deprecated since v3.0, please use new ccui.RelativeLayoutParameter() instead. * @return {ccui.RelativeLayoutParameter} - * @example - * // example - * var uiRelativeLayoutParameter = ccui.RelativeLayoutParameter.create(); */ ccui.RelativeLayoutParameter.create = function () { return new ccui.RelativeLayoutParameter(); diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index f89eb5a233..213e929cb0 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -124,9 +124,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, _initRenderer: function () { - this._buttonNormalRenderer = cc.Sprite.create(); - this._buttonClickedRenderer = cc.Sprite.create(); - this._buttonDisableRenderer = cc.Sprite.create(); + this._buttonNormalRenderer = new cc.Sprite(); + this._buttonClickedRenderer = new cc.Sprite(); + this._buttonDisableRenderer = new cc.Sprite(); this._titleRenderer = new cc.LabelTTF(""); this._titleRenderer.setAnchorPoint(0.5, 0.5); @@ -156,9 +156,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer = new ccui.Scale9Sprite(); this._buttonDisableRenderer = new ccui.Scale9Sprite(); } else { - this._buttonNormalRenderer = cc.Sprite.create(); - this._buttonClickedRenderer = cc.Sprite.create(); - this._buttonDisableRenderer = cc.Sprite.create(); + this._buttonNormalRenderer = new cc.Sprite(); + this._buttonClickedRenderer = new cc.Sprite(); + this._buttonDisableRenderer = new cc.Sprite(); } this._buttonClickedRenderer.setVisible(false); @@ -832,7 +832,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, _createCloneInstance: function () { - return ccui.Button.create(); + return new ccui.Button(); }, _copySpecialProperties: function (uiButton) { @@ -881,9 +881,6 @@ _p = null; * @param {string} [disableImage] disabled state texture name * @param {string} [texType] * @return {ccui.Button} - * @example - * // example - * var uiButton = ccui.Button.create(); */ ccui.Button.create = function (normalImage, selectedImage, disableImage, texType) { return new ccui.Button(normalImage, selectedImage, disableImage, texType); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 8ddfb696cf..989c44294a 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -104,11 +104,11 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, _initRenderer: function () { - this._backGroundBoxRenderer = cc.Sprite.create(); - this._backGroundSelectedBoxRenderer = cc.Sprite.create(); - this._frontCrossRenderer = cc.Sprite.create(); - this._backGroundBoxDisabledRenderer = cc.Sprite.create(); - this._frontCrossDisabledRenderer = cc.Sprite.create(); + this._backGroundBoxRenderer = new cc.Sprite(); + this._backGroundSelectedBoxRenderer = new cc.Sprite(); + this._frontCrossRenderer = new cc.Sprite(); + this._backGroundBoxDisabledRenderer = new cc.Sprite(); + this._frontCrossDisabledRenderer = new cc.Sprite(); this.addProtectedChild(this._backGroundBoxRenderer, ccui.CheckBox.BOX_RENDERER_ZORDER, -1); this.addProtectedChild(this._backGroundSelectedBoxRenderer, ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER, -1); @@ -604,7 +604,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ }, _createCloneInstance: function () { - return ccui.CheckBox.create(); + return new ccui.CheckBox(); }, _copySpecialProperties: function (uiCheckBox) { @@ -665,7 +665,7 @@ _p = null; * @return {ccui.CheckBox} * @example * // example - * var uiCheckBox = ccui.CheckBox.create(); + * var uiCheckBox = new ccui.CheckBox(); */ ccui.CheckBox.create = function (backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled, texType) { return new ccui.CheckBox(backGround, backGroundSeleted,cross,backGroundDisabled,frontCrossDisabled,texType); diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index e71d8afced..27e2965ea7 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -74,7 +74,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, _initRenderer: function () { - this._imageRenderer = cc.Sprite.create(); + this._imageRenderer = new cc.Sprite(); this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); }, @@ -178,7 +178,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if (this._scale9Enabled) { this._imageRenderer = new ccui.Scale9Sprite(); } else { - this._imageRenderer = cc.Sprite.create(); + this._imageRenderer = new cc.Sprite(); } this.loadTexture(this._textureFile, this._imageTexType); this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); @@ -296,7 +296,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, _createCloneInstance:function(){ - return ccui.ImageView.create(); + return new ccui.ImageView(); }, _copySpecialProperties: function (imageView) { @@ -316,9 +316,6 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {string} imageFileName * @param {Number} texType * @return {ccui.ImageView} - * @example - * // example - * var uiImageView = ccui.ImageView.create(); */ ccui.ImageView.create = function (imageFileName, texType) { return new ccui.ImageView(imageFileName, texType); diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 180ba553df..e34fee6132 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -68,7 +68,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, _initRenderer: function () { - this._barRenderer = cc.Sprite.create(); + this._barRenderer = new cc.Sprite(); this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); this._barRenderer.setAnchorPoint(0.0, 0.5); }, @@ -202,7 +202,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._scale9Enabled = enabled; this.removeProtectedChild(this._barRenderer); - this._barRenderer = this._scale9Enabled ? new ccui.Scale9Sprite() : cc.Sprite.create(); + this._barRenderer = this._scale9Enabled ? new ccui.Scale9Sprite() : new cc.Sprite(); this.loadTexture(this._textureFile, this._renderBarTexType); this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); @@ -387,7 +387,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, _createCloneInstance: function () { - return ccui.LoadingBar.create(); + return new ccui.LoadingBar(); }, _copySpecialProperties: function (loadingBar) { @@ -420,9 +420,6 @@ _p = null; * @param {string} textureName * @param {Number} percentage * @return {ccui.LoadingBar} - * @example - * // example - * var uiLoadingBar = ccui.LoadingBar.create(); */ ccui.LoadingBar.create = function (textureName, percentage) { return new ccui.LoadingBar(textureName, percentage); diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 5b171a090c..26ea99f9d7 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -310,7 +310,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ elementRenderer = new cc.LabelTTF(element._text, element._fontName, element._fontSize); break; case ccui.RichElement.IMAGE: - elementRenderer = cc.Sprite.create(element._filePath); + elementRenderer = new cc.Sprite(element._filePath); break; case ccui.RichElement.CUSTOM: elementRenderer = element._customNode; @@ -374,7 +374,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ }, _handleImageRenderer: function (filePath, color, opacity) { - var imageRenderer = cc.Sprite.create(filePath); + var imageRenderer = new cc.Sprite(filePath); this._handleCustomRenderer(imageRenderer); }, @@ -553,8 +553,6 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * create a rich text * @deprecated since v3.0, please use new ccui.RichText() instead. * @returns {RichText} - * @example - * var uiRichText = ccui.RichTex.create(); */ ccui.RichText.create = function(){ return new ccui.RichText(); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 55aad96b10..824bde057d 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -85,15 +85,15 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _initRenderer: function () { - this._barRenderer = cc.Sprite.create(); - this._progressBarRenderer = cc.Sprite.create(); + this._barRenderer = new cc.Sprite(); + this._progressBarRenderer = new cc.Sprite(); this._progressBarRenderer.setAnchorPoint(0.0, 0.5); this.addProtectedChild(this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1); this.addProtectedChild(this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1); - this._slidBallNormalRenderer = cc.Sprite.create(); - this._slidBallPressedRenderer = cc.Sprite.create(); + this._slidBallNormalRenderer = new cc.Sprite(); + this._slidBallPressedRenderer = new cc.Sprite(); this._slidBallPressedRenderer.setVisible(false); - this._slidBallDisabledRenderer = cc.Sprite.create(); + this._slidBallDisabledRenderer = new cc.Sprite(); this._slidBallDisabledRenderer.setVisible(false); this._slidBallRenderer = new cc.Node(); this._slidBallRenderer.addChild(this._slidBallNormalRenderer); @@ -211,8 +211,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRenderer = new ccui.Scale9Sprite(); this._progressBarRenderer = new ccui.Scale9Sprite(); } else { - this._barRenderer = cc.Sprite.create(); - this._progressBarRenderer = cc.Sprite.create(); + this._barRenderer = new cc.Sprite(); + this._progressBarRenderer = new cc.Sprite(); } this.loadBarTexture(this._textureFile, this._barTexType); this.loadProgressBarTexture(this._progressBarTextureFile, this._progressBarTexType); @@ -659,7 +659,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _createCloneInstance: function () { - return ccui.Slider.create(); + return new ccui.Slider(); }, _copySpecialProperties: function (slider) { @@ -690,9 +690,6 @@ _p = null; * allocates and initializes a UISlider. * @deprecated since v3.0, please use new ccui.Slider() instead. * @return {ccui.Slider} - * @example - * // example - * var uiSlider = ccui.Slider.create(); */ ccui.Slider.create = function () { return new ccui.Slider(); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 36142e8fd8..5885460637 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -401,7 +401,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ }, _createCloneInstance: function () { - return ccui.Text.create(); + return new ccui.Text(); }, _copySpecialProperties: function (uiLabel) { @@ -480,9 +480,6 @@ _p = null; * allocates and initializes a UILabel. * @deprecated since v3.0, please use new ccui.Text() instead. * @return {ccui.Text} - * @example - * // example - * var uiLabel = ccui.Text.create(); */ ccui.Label = ccui.Text.create = function (textContent, fontName, fontSize) { return new ccui.Text(textContent, fontName, fontSize); diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 9284c8e483..356838fd05 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -197,7 +197,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ }, _createCloneInstance: function () { - return ccui.TextAtlas.create(); + return new ccui.TextAtlas(); } }); @@ -214,9 +214,6 @@ _p = null; * allocates and initializes a UILabelAtlas. * @deprecated since v3.0, please use new ccui.TextAtlas() instead. * @return {ccui.TextAtlas} - * @example - * // example - * var uiLabelAtlas = ccui.TextAtlas.create(); */ ccui.TextAtlas.create = function (stringValue, charMapFile, itemWidth, itemHeight, startCharMap) { return new ccui.TextAtlas(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index ca16daea0c..2ea91c83b5 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -199,9 +199,6 @@ _p = null; * allocates and initializes a UILabelBMFont. * @deprecated since v3.0, please use new ccui.TextBMFont() instead. * @return {ccui.TextBMFont} - * @example - * // example - * var uiLabelBMFont = ccui.TextBMFont.create(); */ ccui.TextBMFont.create = function (text, filename) { return new ccui.TextBMFont(text, filename); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index d8554f93a3..3dd3f96eb4 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -753,7 +753,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, _createCloneInstance: function () { - return ccui.TextField.create(); + return new ccui.TextField(); }, _copySpecialProperties: function (textField) { @@ -821,9 +821,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {String} fontName * @param {Number} fontSize * @returns {ccui.TextField} - * @example - * // example - * var uiTextField = ccui.TextField.create(); */ ccui.TextField.create = function(placeholder, fontName, fontSize){ return new ccui.TextField(placeholder, fontName, fontSize); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index d484c8ac89..100116df96 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -120,7 +120,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ case ccui.ScrollView.DIR_VERTICAL: llp = item.getLayoutParameter(); if (!llp) { - var defaultLp = ccui.LinearLayoutParameter.create(); + var defaultLp = new ccui.LinearLayoutParameter(); switch (this._gravity) { case ccui.ListView.GRAVITY_LEFT: defaultLp.setGravity(ccui.LinearLayoutParameter.LEFT); @@ -162,7 +162,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ case ccui.ScrollView.DIR_HORIZONTAL: llp = item.getLayoutParameter(); if (!llp) { - var defaultLp = ccui.LinearLayoutParameter.create(); + var defaultLp = new ccui.LinearLayoutParameter(); switch (this._gravity) { case ccui.ListView.GRAVITY_TOP: defaultLp.setGravity(ccui.LinearLayoutParameter.TOP); @@ -517,7 +517,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, _createCloneInstance: function () { - return ccui.ListView.create(); + return new ccui.ListView(); }, _copyClonedWidgetChildren: function (model) { @@ -544,9 +544,6 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ /** * allocates and initializes a UIListView. * @deprecated since v3.0, please use new ccui.ListView() instead. - * @example - * // example - * var uiPageView = ccui.ListView.create(); */ ccui.ListView.create = function () { return new ccui.ListView(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 8cd56c715e..274c24661f 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -125,7 +125,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, _createPage: function () { - var newPage = ccui.Layout.create(); + var newPage = new ccui.Layout(); newPage.setContentSize(this.getContentSize()); return newPage; }, @@ -544,7 +544,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, _createCloneInstance: function () { - return ccui.PageView.create(); + return new ccui.PageView(); }, _copyClonedWidgetChildren: function (model) { @@ -565,9 +565,6 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * allocates and initializes a UIPageView. * @deprecated since v3.0, please use new ccui.PageView() instead. * @return {ccui.PageView} - * @example - * // example - * var uiPageView = ccui.PageView.create(); */ ccui.PageView.create = function () { return new ccui.PageView(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index f9849d3680..49c3553b48 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -141,7 +141,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ _initRenderer: function () { ccui.Layout.prototype._initRenderer.call(this); - this._innerContainer = ccui.Layout.create(); + this._innerContainer = new ccui.Layout(); this.addProtectedChild(this._innerContainer, 1, 1); }, @@ -1648,7 +1648,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, _createCloneInstance: function(){ - return ccui.ScrollView.create(); + return new ccui.ScrollView(); }, _copyClonedWidgetChildren: function (model) { @@ -1746,9 +1746,6 @@ _p = null; * allocates and initializes a UIScrollView. * @deprecated since v3.0, please use new ccui.ScrollView() instead. * @return {ccui.ScrollView} - * @example - * // example - * var uiScrollView = ccui.ScrollView.create(); */ ccui.ScrollView.create = function () { return new ccui.ScrollView(); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 341f5d7daf..e6e26ef521 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -142,10 +142,10 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.updateOffsetPoint(); } else { this._name = "new_armature"; - this.armatureData = ccs.ArmatureData.create(); + this.armatureData = new ccs.ArmatureData(); this.armatureData.name = this._name; - animationData = ccs.AnimationData.create(); + animationData = new ccs.AnimationData(); animationData.name = this._name; armatureDataManager.addArmatureData(this._name, this.armatureData); @@ -177,10 +177,10 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var bone = null; if (parentName) { this.createBone(parentName); - bone = ccs.Bone.create(boneName); + bone = new ccs.Bone(boneName); this.addBone(bone, parentName); } else { - bone = ccs.Bone.create(boneName); + bone = new ccs.Bone(boneName); this.addBone(bone, ""); } diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index 9595845ad9..093f3f07d9 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -122,9 +122,9 @@ ccs.displayFactory = { textureName = textureName.substring(0, startPos); //! create display if (textureName == "") - skin = ccs.Skin.create(); + skin = new ccs.Skin(); else - skin = ccs.Skin.createWithSpriteFrameName(textureName + ".png"); + skin = new ccs.Skin("#" + textureName + ".png"); decoDisplay.setDisplay(skin); @@ -160,7 +160,7 @@ ccs.displayFactory = { if (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) { if (textureData && textureData.contourDataList.length > 0) { //! create ContourSprite - var colliderDetector = ccs.ColliderDetector.create(bone); + var colliderDetector = new ccs.ColliderDetector(bone); colliderDetector.addContourDataList(textureData.contourDataList); decoDisplay.setColliderDetector(colliderDetector); } @@ -177,7 +177,7 @@ ccs.displayFactory = { createArmatureDisplay: function (bone, decoDisplay) { var displayData = decoDisplay.getDisplayData(); - var armature = ccs.Armature.create(displayData.displayName, bone); + var armature = new ccs.Armature(displayData.displayName, bone); decoDisplay.setDisplay(armature); }, @@ -197,7 +197,7 @@ ccs.displayFactory = { createParticleDisplay: function (bone, decoDisplay) { var displayData = decoDisplay.getDisplayData(); - var system = cc.ParticleSystem.create(displayData.displayName); + var system = new cc.ParticleSystem(displayData.displayName); system.removeFromParent(); system.cleanup(); diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index f1b3446ae0..54eea74489 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -78,7 +78,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ if( (index >= 0) && (index < locDisplayList.length) ) decoDisplay = locDisplayList[index]; else{ - decoDisplay = ccs.DecorativeDisplay.create(); + decoDisplay = new ccs.DecorativeDisplay(); locDisplayList.push(decoDisplay); } @@ -362,7 +362,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ var displayList = boneData.displayDataList, decoList = this._decoDisplayList, locBone = this._bone; for (var i = 0; i < displayList.length; i++) { var displayData = displayList[i]; - var decoDisplay = ccs.DecorativeDisplay.create(); + var decoDisplay = new ccs.DecorativeDisplay(); decoDisplay.setDisplayData(displayData); ccs.displayFactory.createDisplay(locBone, decoDisplay); decoList.push(decoDisplay); diff --git a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js index c0cda88ac6..a0496e96a7 100644 --- a/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +++ b/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js @@ -52,7 +52,7 @@ ccs.spriteFrameCacheHelper = /** @lends ccs.spriteFrameCacheHelper# */ { var textureName = texture.getName(); var atlas = this._textureAtlasDic[textureName]; if (atlas == null) { - atlas = cc.TextureAtlas.create(texture, 20); + atlas = new cc.TextureAtlas(texture, 20); this._textureAtlasDic[textureName] = atlas; } return atlas; diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index d7fb4dd382..c576a88b48 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -373,46 +373,46 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend(/** @lends cc var classname = data["classname"]; var uiOptions = data["options"]; if (classname == "Button") { - widget = ccui.Button.create(); + widget = new ccui.Button(); this.setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname == "CheckBox") { - widget = ccui.CheckBox.create(); + widget = new ccui.CheckBox(); this.setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); } else if (classname == "Label") { - widget = ccui.Text.create(); + widget = new ccui.Text(); this.setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname == "LabelAtlas") { - widget = ccui.TextAtlas.create(); + widget = new ccui.TextAtlas(); this.setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); } else if (classname == "LoadingBar") { - widget = ccui.LoadingBar.create(); + widget = new ccui.LoadingBar(); this.setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); } else if (classname == "ScrollView") { - widget = ccui.ScrollView.create(); + widget = new ccui.ScrollView(); this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } else if (classname == "TextArea") { - widget = ccui.Text.create(); + widget = new ccui.Text(); this.setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname == "TextButton") { - widget = ccui.Button.create(); + widget = new ccui.Button(); this.setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname == "TextField") { - widget = ccui.TextField.create(); + widget = new ccui.TextField(); this.setPropsForTextFieldFromJsonDictionary(widget, uiOptions); } else if (classname == "ImageView") { - widget = ccui.ImageView.create(); + widget = new ccui.ImageView(); this.setPropsForImageViewFromJsonDictionary(widget, uiOptions); } else if (classname == "Panel") { - widget = ccui.Layout.create(); + widget = new ccui.Layout(); this.setPropsForLayoutFromJsonDictionary(widget, uiOptions); } else if (classname == "Slider") { - widget = ccui.Slider.create(); + widget = new ccui.Slider(); this.setPropsForSliderFromJsonDictionary(widget, uiOptions); } else if (classname == "LabelBMFont") { - widget = ccui.TextBMFont.create(); + widget = new ccui.TextBMFont(); this.setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); } else if (classname == "DragPanel") { - widget = ccui.ScrollView.create(); + widget = new ccui.ScrollView(); this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } var children = data["children"]; @@ -1178,12 +1178,12 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc case 0: break; case 1: - parameter = ccui.LinearLayoutParameter.create(); + parameter = new ccui.LinearLayoutParameter(); var gravity = layoutParameterDic["gravity"]; parameter.setGravity(gravity); break; case 2: - parameter = ccui.RelativeLayoutParameter.create(); + parameter = new ccui.RelativeLayoutParameter(); var relativeName = layoutParameterDic["relativeName"]; parameter.setRelativeName(relativeName); var relativeToName = layoutParameterDic["relativeToName"]; diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 06dd286342..81d43c8045 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -63,10 +63,10 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ if (className == "CCNode") { var gb = null; if (!parenet) { - gb = cc.Node.create(); + gb = new cc.Node(); } else { - gb = cc.Node.create(); + gb = new cc.Node(); parenet.addChild(gb); } @@ -102,7 +102,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ if (resType == 0) { if (pathExtname != ".png") continue; - sprite = cc.Sprite.create(path); + sprite = new cc.Sprite(path); } else if (resType == 1) { if (pathExtname != ".plist") continue; @@ -110,7 +110,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ plistFile = cc.path.join(this._baseBath, plistFile); var pngFile = cc.path.changeExtname(plistFile, ".png"); cc.spriteFrameCache.addSpriteFrames(plistFile, pngFile); - sprite = cc.Sprite.create("#" + fileData["path"]); + sprite = new cc.Sprite("#" + fileData["path"]); } else { continue; @@ -128,7 +128,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ var tmx = null; if (resType == 0) { if (pathExtname != ".tmx") continue; - tmx = cc.TMXTiledMap.create(path); + tmx = new cc.TMXTiledMap(path); } else { continue; @@ -146,7 +146,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ var particle = null; if (resType == 0) { - particle = cc.ParticleSystem.create(path); + particle = new cc.ParticleSystem(path); } else { cc.log("unknown resourcetype on CCParticleSystemQuad!"); @@ -173,7 +173,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ ccs.armatureDataManager.addArmatureFileInfo(path); - var armature = ccs.Armature.create(name); + var armature = new ccs.Armature(name); var render = ccs.ComRender.create(armature, "CCArmature"); if (comName != null) { render.setName(comName); diff --git a/extensions/cocostudio/trigger/TriggerMng.js b/extensions/cocostudio/trigger/TriggerMng.js index 0603491486..f647e7ce6f 100644 --- a/extensions/cocostudio/trigger/TriggerMng.js +++ b/extensions/cocostudio/trigger/TriggerMng.js @@ -40,7 +40,7 @@ ccs.triggerManager = /** @lends ccs.triggerManager# */{ parse: function (triggers) { for (var i = 0; i < triggers.length; ++i) { var subDict = triggers[i]; - var triggerObj = ccs.TriggerObj.create(); + var triggerObj = new ccs.TriggerObj(); triggerObj.serialize(subDict); var events = triggerObj.getEvents(); for (var j = 0; j < events.length; j++) { diff --git a/extensions/gui/control-extension/CCControlButton.js b/extensions/gui/control-extension/CCControlButton.js index 7d2773e1d1..448f3ea1f7 100644 --- a/extensions/gui/control-extension/CCControlButton.js +++ b/extensions/gui/control-extension/CCControlButton.js @@ -84,7 +84,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ }, init: function () { - return this.initWithLabelAndBackgroundSprite(cc.LabelTTF.create("", "Arial", 12), cc.Scale9Sprite.create()); + return this.initWithLabelAndBackgroundSprite(new cc.LabelTTF("", "Arial", 12), new cc.Scale9Sprite()); }, needsLayout: function () { @@ -231,12 +231,12 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ }, initWithTitleAndFontNameAndFontSize: function (title, fontName, fontSize) { - var label = cc.LabelTTF.create(title, fontName, fontSize); - return this.initWithLabelAndBackgroundSprite(label, cc.Scale9Sprite.create()); + var label = new cc.LabelTTF(title, fontName, fontSize); + return this.initWithLabelAndBackgroundSprite(label, new cc.Scale9Sprite()); }, initWithBackgroundSprite: function (sprite) { - var label = cc.LabelTTF.create("", "Arial", 30);// + var label = new cc.LabelTTF("", "Arial", 30);// return this.initWithLabelAndBackgroundSprite(label, sprite); }, @@ -380,7 +380,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ this.needsLayout(); if (this.zoomOnTouchDown) { var scaleValue = (this.isHighlighted() && this.isEnabled() && !this.isSelected()) ? 1.1 : 1.0; - var zoomAction = cc.ScaleTo.create(0.05, scaleValue); + var zoomAction = cc.scaleTo(0.05, scaleValue); zoomAction.setTag(cc.CONTROL_ZOOM_ACTION_TAG); this.runAction(zoomAction); } @@ -544,7 +544,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ var title = this.getTitleForState(state); if (!title) title = ""; - this.setTitleLabelForState(cc.LabelTTF.create(title, fntFile, 12), state); + this.setTitleLabelForState(new cc.LabelTTF(title, fntFile, 12), state); }, /** @@ -594,7 +594,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ var title = this.getTitleForState(state); if (!title) title = ""; - this.setTitleLabelForState(cc.LabelBMFont.create(title, fntFile), state); + this.setTitleLabelForState(new cc.LabelBMFont(title, fntFile), state); }, getTitleBMFontForState: function (state) { diff --git a/extensions/gui/control-extension/CCControlColourPicker.js b/extensions/gui/control-extension/CCControlColourPicker.js index 7b5b357532..4e7a49f039 100644 --- a/extensions/gui/control-extension/CCControlColourPicker.js +++ b/extensions/gui/control-extension/CCControlColourPicker.js @@ -96,7 +96,7 @@ cc.ControlColourPicker = cc.Control.extend(/** @lends cc.ControlColourPicker# */ cc.spriteFrameCache.addSpriteFrames(res.CCControlColourPickerSpriteSheet_plist); // Create the sprite batch node - var spriteSheet = cc.SpriteBatchNode.create(res.CCControlColourPickerSpriteSheet_png); + var spriteSheet = new cc.SpriteBatchNode(res.CCControlColourPickerSpriteSheet_png); this.addChild(spriteSheet); /*// MIPMAP @@ -119,8 +119,8 @@ cc.ControlColourPicker = cc.Control.extend(/** @lends cc.ControlColourPicker# */ var hueShift = 8; var colourShift = 28; - this._huePicker = cc.ControlHuePicker.create(spriteSheet, cc.p(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); - this._colourPicker = cc.ControlSaturationBrightnessPicker.create(spriteSheet, cc.p(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); + this._huePicker = new cc.ControlHuePicker(spriteSheet, cc.p(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); + this._colourPicker = new cc.ControlSaturationBrightnessPicker(spriteSheet, cc.p(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); // Setup events this._huePicker.addTargetWithActionForControlEvents(this, this.hueSliderValueChanged, cc.CONTROL_EVENT_VALUECHANGED); diff --git a/extensions/gui/control-extension/CCControlPotentiometer.js b/extensions/gui/control-extension/CCControlPotentiometer.js index 686fa3d7d2..3fb2d8bba1 100644 --- a/extensions/gui/control-extension/CCControlPotentiometer.js +++ b/extensions/gui/control-extension/CCControlPotentiometer.js @@ -58,13 +58,13 @@ cc.ControlPotentiometer = cc.Control.extend(/** @lends cc.ControlPotentiometer# cc.Control.prototype.ctor.call(this); if (thumbFile != undefined) { // Prepare track for potentiometer - var backgroundSprite = cc.Sprite.create(backgroundFile); + var backgroundSprite = new cc.Sprite(backgroundFile); // Prepare thumb for potentiometer - var thumbSprite = cc.Sprite.create(thumbFile); + var thumbSprite = new cc.Sprite(thumbFile); // Prepare progress for potentiometer - var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); + var progressTimer = new cc.ProgressTimer(new cc.Sprite(progressFile)); this.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite); } }, diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index 87fcf73b60..f2221a7ebe 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -65,13 +65,13 @@ cc.ControlSlider = cc.Control.extend(/** @lends cc.ControlSlider# */{ cc.Control.prototype.ctor.call(this); if (thumbFile != undefined) { // Prepare background for slider - bgSprite = cc.Sprite.create(bgFile); + bgSprite = new cc.Sprite(bgFile); // Prepare progress for slider - progressSprite = cc.Sprite.create(progressFile); + progressSprite = new cc.Sprite(progressFile); // Prepare thumb (menuItem) for slider - thumbSprite = cc.Sprite.create(thumbFile); + thumbSprite = new cc.Sprite(thumbFile); this.initWithSprites(bgSprite, progressSprite, thumbSprite); } diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js index ae5599f5b7..f9757cc3b2 100644 --- a/extensions/gui/control-extension/CCControlStepper.js +++ b/extensions/gui/control-extension/CCControlStepper.js @@ -115,7 +115,7 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{ this._minusSprite.setPosition(minusSprite.getContentSize().width / 2, minusSprite.getContentSize().height / 2); this.addChild(this._minusSprite); - this.setMinusLabel(cc.LabelTTF.create("-", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER)); + this.setMinusLabel(new cc.LabelTTF("-", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER)); this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_DISABLED); this._minusLabel.setPosition(this._minusSprite.getContentSize().width / 2, this._minusSprite.getContentSize().height / 2); this._minusSprite.addChild(this._minusLabel); @@ -126,7 +126,7 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{ minusSprite.getContentSize().height / 2); this.addChild(this._plusSprite); - this.setPlusLabel(cc.LabelTTF.create("+", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER)); + this.setPlusLabel(new cc.LabelTTF("+", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER)); this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED); this._plusLabel.setPosition(this._plusSprite.getContentSize().width / 2, this._plusSprite.getContentSize().height / 2); this._plusSprite.addChild(this._plusLabel); diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js index 359bb69402..240af15017 100644 --- a/extensions/gui/control-extension/CCControlSwitch.js +++ b/extensions/gui/control-extension/CCControlSwitch.js @@ -77,7 +77,7 @@ cc.ControlSwitch = cc.Control.extend(/** @lends cc.ControlSwitch# */{ this._on = isOn; var xPosition = (this._on) ? this._switchSprite.getOnPosition() : this._switchSprite.getOffPosition(); if(animated){ - this._switchSprite.runAction(cc.ActionTween.create(0.2, "sliderXPosition", this._switchSprite.getSliderXPosition(),xPosition)); + this._switchSprite.runAction(new cc.ActionTween(0.2, "sliderXPosition", this._switchSprite.getSliderXPosition(),xPosition)); }else{ this._switchSprite.setSliderXPosition(xPosition); } @@ -233,7 +233,7 @@ cc.ControlSwitchSprite = cc.Sprite.extend({ this._stencil.setPosition(0, 0); // Init clipper for mask - this._clipper = cc.ClippingNode.create(); + this._clipper = new cc.ClippingNode(); this._clipper.setAnchorPoint(0.5, 0.5); this._clipper.setPosition(maskSize.width / 2, maskSize.height / 2); this._clipper.setStencil(this._stencil); diff --git a/extensions/gui/control-extension/CCControlUtils.js b/extensions/gui/control-extension/CCControlUtils.js index f2701c261a..5e803bd56a 100644 --- a/extensions/gui/control-extension/CCControlUtils.js +++ b/extensions/gui/control-extension/CCControlUtils.js @@ -54,7 +54,7 @@ cc.HSV = function(h,s,v){ cc.ControlUtils = {}; cc.ControlUtils.addSpriteToTargetWithPosAndAnchor = function(spriteName,target,pos,anchor){ - var sprite =cc.Sprite.create("#" + spriteName); + var sprite = new cc.Sprite("#" + spriteName); if (!sprite) return null; diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 003ff3ea0b..b237b1aa44 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -593,7 +593,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ }, this); } - return this.initWithBatchNode(cc.SpriteBatchNode.create(file, 9), rect, false, capInsets); + return this.initWithBatchNode(new cc.SpriteBatchNode(file, 9), rect, false, capInsets); }, /** @@ -624,7 +624,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._callLoadedEventCallbacks(); },this); } - var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); + var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9); // the texture is rotated on Canvas render mode, so isRotated always is false. return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets); }, @@ -1009,7 +1009,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ * @param {cc.SpriteFrame} spriteFrame */ setSpriteFrame: function (spriteFrame) { - var batchNode = cc.SpriteBatchNode.create(spriteFrame.getTexture(), 9); + var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9); // the texture is rotated on Canvas render mode, so isRotated always is false. var locLoaded = spriteFrame.textureLoaded(); this._textureLoaded = locLoaded; diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 8fce99d165..28c396c7f9 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -170,7 +170,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._container = container; if (!this._container) { - this._container = cc.Layer.create(); + this._container = new cc.Layer(); this._container.ignoreAnchorPointForPosition(false); this._container.setAnchorPoint(pZero); } @@ -235,9 +235,9 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ * @param {Number} dt animation duration */ setContentOffsetInDuration:function (offset, dt) { - var scroll = cc.MoveTo.create(dt, offset); - var expire = cc.CallFunc.create(this._stoppedAnimatedScroll, this); - this._container.runAction(cc.Sequence.create(scroll, expire)); + var scroll = cc.moveTo(dt, offset); + var expire = cc.callFunc(this._stoppedAnimatedScroll, this); + this._container.runAction(cc.sequence(scroll, expire)); this.schedule(this._performedAnimatedScroll); }, @@ -290,7 +290,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ if (dt > 0) { var locScale = this._container.getScale(); if (locScale != s) { - var scaleAction = cc.ActionTween.create(dt, "zoomScale", locScale, s); + var scaleAction = cc.actionTween(dt, "zoomScale", locScale, s); this.runAction(scaleAction); } } else { diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index c847deea23..fd2ee9a37d 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -305,7 +305,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ continue; rendererObject = attachment.rendererObject; rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); - var sprite = cc.Sprite.create(rendererObject.page._texture, rect, rendererObject.rotate); + var sprite = new cc.Sprite(rendererObject.page._texture, rect, rendererObject.rotate); this.addChild(sprite,-1); slot.currentSprite = sprite; } @@ -367,7 +367,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ if(!selSprite){ var rendererObject = attachment.rendererObject; var rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); - var sprite = cc.Sprite.create(rendererObject.page._texture, rect, rendererObject.rotate); + var sprite = new cc.Sprite(rendererObject.page._texture, rect, rendererObject.rotate); this.addChild(sprite,-1); slot.currentSprite = sprite; } diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index 54ce02582c..c71948ea80 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -29,7 +29,7 @@ */ sp._atlasPage_createTexture_webGL = function (self, path) { var texture = cc.textureCache.addImage(path); - self.rendererObject = cc.TextureAtlas.create(texture, 128); + self.rendererObject = new cc.TextureAtlas(texture, 128); self.width = texture.getPixelsWide(); self.height = texture.getPixelsHigh(); }; From 9a69511934d37df3aced8f02030906df2675ca81 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 16 Oct 2014 16:02:03 +0800 Subject: [PATCH 0799/1564] Issue #5983: The analysis of parameters --- extensions/ccui/base-classes/UIWidget.js | 97 ++++++++++++------------ extensions/ccui/layouts/UILayout.js | 2 +- extensions/ccui/uiwidgets/UIButton.js | 32 ++++---- 3 files changed, 68 insertions(+), 63 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 89b06f0e8b..3d4c304ac1 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +var __LAYOUT_COMPONENT_NAME = "__ui_layout"; + /** * The base class for ccui controls and layout * @sample @@ -161,7 +163,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ getOrCreateLayoutComponent: function(){ var layoutComponent = this.getComponent(__LAYOUT_COMPONENT_NAME); if (null == layoutComponent){ - var component = ccui.LayoutComponent.create(); + var component = new ccui.LayoutComponent(); this.addComponent(component); layoutComponent = component; } @@ -342,35 +344,35 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setSizePercent: function (percent) { - var component = this.getOrCreateLayoutComponent(); - component.setUsingPercentContentSize(true); - component.setPercentContentSize(percent); +// var component = this.getOrCreateLayoutComponent(); +// component.setUsingPercentContentSize(true); +// component.setPercentContentSize(percent); // if (null != this._parent) // { // ccui.Helper.prototype.doLayout.call(this, this._parent); // } -// this._sizePercent.x = percent.x; -// this._sizePercent.y = percent.y; -// var width = this._customSize.width, height = this._customSize.height; -// if (this._running) { -// var widgetParent = this.getWidgetParent(); -// if (widgetParent) { -// width = widgetParent.width * percent.x; -// height = widgetParent.height * percent.y; -// } else { -// width = this._parent.width * percent.x; -// height = this._parent.height * percent.y; -// } -// } -// if (this._ignoreSize) -// this.setContentSize(this.getVirtualRendererSize()); -// else -// this.setContentSize(width, height); -// -// this._customSize.width = width; -// this._customSize.height = height; + this._sizePercent.x = percent.x; + this._sizePercent.y = percent.y; + var width = this._customSize.width, height = this._customSize.height; + if (this._running) { + var widgetParent = this.getWidgetParent(); + if (widgetParent) { + width = widgetParent.width * percent.x; + height = widgetParent.height * percent.y; + } else { + width = this._parent.width * percent.x; + height = this._parent.height * percent.y; + } + } + if (this._ignoreSize) + this.setContentSize(this.getVirtualRendererSize()); + else + this.setContentSize(width, height); + + this._customSize.width = width; + this._customSize.height = height; }, _setWidthPercent: function (percent) { @@ -467,7 +469,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._sizeType = type; var component = this.getOrCreateLayoutComponent(); - if (this._sizeType == ccui.Widget.prototype.SizeType.PERCENT) + if (this._sizeType == ccui.Widget.SIZE_PERCENT) { component.setUsingPercentContentSize(true); } @@ -567,13 +569,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * call back function called when size changed. */ _onSizeChanged: function () { - ccui.Helper.prototype.doLayout.call(this, this); -// var locChildren = this.getChildren(); -// for (var i = 0, len = locChildren.length; i < len; i++) { -// var child = locChildren[i]; -// if(child instanceof ccui.Widget) -// child.updateSizeAndPosition(); -// } +// ccui.Helper.prototype.doLayout.call(this, this); + var locChildren = this.getChildren(); + for (var i = 0, len = locChildren.length; i < len; i++) { + var child = locChildren[i]; + if(child instanceof ccui.Widget) + child.updateSizeAndPosition(); + } }, /** @@ -1081,7 +1083,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ // } cc.Node.prototype.setPosition.call(this, pos, posY); - this._positionType = PositionType.ABSOLUTE; + this._positionType = ccui.Widget.POSITION_ABSOLUTE; }, setPositionX: function (x) { @@ -1118,16 +1120,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Point} percent */ setPositionPercent: function (percent) { - this.setNormalizedPosition(percent); - this._positionType = PositionType.PERCENT; -// this._positionPercent = percent; -// if (this._running) { -// var widgetParent = this.getWidgetParent(); -// if (widgetParent) { -// var parentSize = widgetParent.getSize(); -// this.setPosition(parentSize.width * this._positionPercent.x, parentSize.height * this._positionPercent.y); -// } -// } +// this.setNormalizedPosition(percent); +// this._positionType = PositionType.PERCENT; + this._positionPercent = percent; + if (this._running) { + var widgetParent = this.getWidgetParent(); + 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; @@ -1167,7 +1169,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setPositionType: function (type) { this._positionType = type; - if (type == ccui.Widget.prototype.PositionType.ABSOLUTE) + if (type == ccui.Widget.POSITION_ABSOLUTE) { var oldPosition = this.getPosition(); this.setPosition(this.getPosition() + cc.p(10,0)); @@ -1175,9 +1177,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } else { - var oldNormalizedPosition = this.getNormalizedPosition(); - this.setNormalizedPosition(oldNormalizedPosition + cc.p(0.2,0.1)); - this.setNormalizedPosition(oldNormalizedPosition); + //todo check here +// var oldNormalizedPosition = cc._position;//this.getNormalizedPosition(); +// this.setNormalizedPosition(oldNormalizedPosition + cc.p(0.2,0.1)); +// this.setNormalizedPosition(oldNormalizedPosition); } }, diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index aef62e54ea..3a9e055463 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -774,7 +774,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; if (this._backGroundImage == null){ this._addBackGroundImage(); - this._backGroundImage.setScale9Enabled(this._backGroundScale9Enabled); + this.setBackGroundImageScale9Enabled(this._backGroundScale9Enabled); } this._backGroundImageFileName = fileName; this._bgImageTexType = texType; diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 8a9de8c394..17ab2a9b8c 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -207,7 +207,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var s = this.getVirtualRendererSize(); ccui.ProtectedNode.prototype.setContentSize.call(this, s); } - this.onSizeChanged(); + this._onSizeChanged(); return; } if (!this._scale9Enabled || (this._scale9Enabled && !ignore)) { @@ -462,10 +462,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ setCapInsetsNormalRenderer: function (capInsets) { if(!capInsets) return; - var x = capInsets.origin.x; - var y = capInsets.origin.y; - var width = capInsets.size.width; - var height = capInsets.size.height; + var x = capInsets.x; + var y = capInsets.y; + var width = capInsets.width; + var height = capInsets.height; if (this._normalTextureSize.width < width) { @@ -506,10 +506,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if(!capInsets) return; - var x = capInsets.origin.x; - var y = capInsets.origin.y; - var width = capInsets.size.width; - var height = capInsets.size.height; + var x = capInsets.x; + var y = capInsets.y; + var width = capInsets.width; + var height = capInsets.height; if (this._normalTextureSize.width < width) { @@ -549,10 +549,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if(!capInsets) return; - var x = capInsets.origin.x; - var y = capInsets.origin.y; - var width = capInsets.size.width; - var height = capInsets.size.height; + var x = capInsets.x; + var y = capInsets.y; + var width = capInsets.width; + var height = capInsets.height; if (this._normalTextureSize.width < width) { @@ -724,7 +724,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _normalTextureScaleChangedWithSize: function () { if(this._unifySize){ - this._buttonNormalRenderer.setPreferredSize(this._contentSize); + if (this._scale9Enabled) + this._buttonNormalRenderer.setPreferredSize(this._contentSize); }else if (this._ignoreSize) { if (!this._scale9Enabled) { this._buttonNormalRenderer.setScale(1.0); @@ -780,7 +781,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _disabledTextureScaleChangedWithSize: function () { if(this._unifySize){ - this._buttonNormalRenderer.setPreferredSize(this._contentSize); + if (this._scale9Enabled) + this._buttonNormalRenderer.setPreferredSize(this._contentSize); }else if (this._ignoreSize) { if (!this._scale9Enabled) this._buttonDisableRenderer.setScale(1.0); From 9ca032af675e66d472d3b0bc561d00325a07b328 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 16 Oct 2014 16:02:28 +0800 Subject: [PATCH 0800/1564] Issue #5983: The analysis of parameters --- .../components/CCComponentContainer.js | 3 + extensions/cocostudio/reader/GUIReader.js | 489 +++++++++--------- .../widgetreader/ButtonReader/ButtonReader.js | 102 ++-- .../CheckBoxReader/CheckBoxReader.js | 72 +-- .../ImageViewReader/ImageViewReader.js | 42 +- .../LabelAtlasReader/LabelAtlasReader.js | 24 +- .../LabelBMFontReader/LabelBMFontReader.js | 40 +- .../widgetreader/LabelReader/LabelReader.js | 60 ++- .../widgetreader/LayoutReader/LayoutReader.js | 164 +++--- .../ListViewReader/ListViewReader.js | 92 ++-- .../LoadingBarReader/LoadingBarReader.js | 36 +- .../PageViewReader/PageViewReader.js | 80 ++- .../ScrollViewReader/ScrollViewReader.js | 94 ++-- .../widgetreader/SliderReader/SliderReader.js | 76 +-- .../TextFieldReader/TextFieldReader.js | 42 +- .../reader/widgetreader/WidgetReader.js | 112 ++-- moduleConfig.json | 1 + 17 files changed, 777 insertions(+), 752 deletions(-) diff --git a/extensions/cocostudio/components/CCComponentContainer.js b/extensions/cocostudio/components/CCComponentContainer.js index c1cc46ba09..1d54c6bc2d 100644 --- a/extensions/cocostudio/components/CCComponentContainer.js +++ b/extensions/cocostudio/components/CCComponentContainer.js @@ -50,6 +50,9 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ if(!name) throw "cc.ComponentContainer.getComponent(): name should be non-null"; name = name.trim(); + if(!this._components){ + this._components = {}; + } return this._components[name]; }, diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 9a9fbeb7f1..e30da833c2 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -219,243 +219,22 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ return this._mapParseSelector; }, + /** + * Load ui form protocolBuffers + * @param url + */ widgetFromProtocolBuffers: function(url){ - - - var classname = nodetree.classname(); - cc.log("classname = %s", classname); - - var widget = this.createGUI(classname); - var readerName = this.getWidgetReaderClassName(classname); - - var reader = this.createWidgetReaderProtocol(readerName); - - if (reader) - { - // widget parse with widget reader - this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); - } - else - { - // - // 1st., custom widget parse properties of parent widget with parent widget reader - readerName = this.getWidgetReaderClassName(widget); - reader = this.createWidgetReaderProtocol(readerName); - if (reader && widget) - { - this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); - - // 2nd., custom widget parse with custom reader - var widgetOptions = nodetree.widgetoptions(); - var customProperty = widgetOptions.customproperty(); - var customJsonDict; - customJsonDict.Parse(customProperty); - if (customJsonDict.HasParseError()) - { - cc.log("GetParseError %s\n", customJsonDict.GetParseError()); - } - this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); - } - else - { - cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); - } - // - } - - var size = nodetree.children_size(); - cc.log("widget children size = %d", size); - for (var i = 0; i < size; ++i) - { - var subNodeTree = nodetree.children(i); - var child = this.widgetFromProtocolBuffers(subNodeTree); - cc.log("widget child = %p", child); - if (child) - { - var pageView = widget; - if (pageView instanceof ccui.PageView) - { - pageView.addPage(child); - } - else - { - var listView = widget; - if (listView instanceof ccui.ListView) - { - listView.pushBackCustomItem(child); - } - else - { - widget.addChild(child); - } - } - } - } - - cc.log("widget = %p", widget); - - return widget; - }, - - setPropsForAllWidgetFromProtocolBuffers: function(reader, widget, nodetree){ - reader.setPropsFromProtocolBuffers(widget, nodetree); - }, - - widgetFromXML: function(objectData, classType){ - var classname = classType.substr(0, classType.find("ObjectData")); - cc.log("classname = %s", classname); - - var widget = this.createGUI(classname); - var readerName = this.getWidgetReaderClassName(classname); - - var reader = this.createWidgetReaderProtocol(readerName); - - if (reader) - { - // widget parse with widget reader - this.setPropsForAllWidgetFromXML(reader, widget, objectData); - } - else - { - // - // 1st., custom widget parse properties of parent widget with parent widget reader - readerName = this.getWidgetReaderClassName(widget); - reader = this.createWidgetReaderProtocol(readerName); - if (reader && widget) - { - this.setPropsForAllWidgetFromXML(reader, widget, objectData); - - // 2nd., custom widget parse with custom reader - // const protocolbuffers::WidgetOptions& widgetOptions = nodetree.widgetoptions(); - // const char* customProperty = widgetOptions.customproperty().c_str(); - var customProperty = ""; - var customJsonDict; - customJsonDict.Parse(customProperty); - if (customJsonDict.HasParseError()) - { - cc.log("GetParseError %s\n", customJsonDict.GetParseError()); - } - this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); - } - else - { - cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); - } - // - } - - - - - - // children - var containChildrenElement = false; - objectData = objectData.FirstChildElement(); - - while (objectData) - { - cc.log("objectData name = %s", objectData.Name()); - - if ("Children" !== objectData.Name()) - { - containChildrenElement = true; - break; - } - - objectData = objectData.NextSiblingElement(); - } - - if (containChildrenElement) - { - objectData = objectData.FirstChildElement(); - cc.log("objectData name = %s", objectData.Name()); - - while (objectData) - { - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ctype") - { - var child = this.widgetFromXML(objectData, value); - cc.log("child = %p", child); - if (child) - { - var pageView = widget; - var listView = widget; - if (pageView instanceof ccui.PageView) - { - var layout = child; - if (layout instanceof ccui.Layout) - { - pageView.addPage(layout); - } - } - else if (listView) - { - var widgetChild = child; - if (widgetChild instanceof ccui.Widget) - { - listView.pushBackCustomItem(widgetChild); - } - } - else - { - widget.addChild(child); - } - } - - break; - } - - attribute = attribute.Next(); - } - - // Node* child = nodeFromXML(objectData, value); - // CCLOG("child = %p", child); - // if (child) - // { - // PageView* pageView = dynamic_cast(node); - // ListView* listView = dynamic_cast(node); - // if (pageView) - // { - // Layout* layout = dynamic_cast(child); - // if (layout) - // { - // pageView.addPage(layout); - // } - // } - // else if (listView) - // { - // Widget* widget = dynamic_cast(child); - // if (widget) - // { - // listView.pushBackCustomItem(widget); - // } - // } - // else - // { - // node.addChild(child); - // } - // } - - objectData = objectData.NextSiblingElement(); - } - } - // - - cc.log("widget = %p", widget); - - return widget; - }, - - setPropsForAllWidgetFromXML: function(reader, widget, objectData){ - reader.setPropsFromXML(widget, objectData); + var buf = cc.loader.getRes(url); + if(!buf){ + cc.log("File not found: " + url); + return; + } + var jsonPath = url.substr(0, url.lastIndexOf('/') + 1); + ccs.uiReader.setFilePath(jsonPath); + var pReader = new ccs.WidgetPropertiesReader0300(); + var buffer = PBP.CSParseBinary.decode(buf); + return pReader.widgetFromProtocolBuffers(buffer.nodeTree); } - }; /** @@ -501,6 +280,8 @@ ccs.WidgetPropertiesReader = ccs.Class.extend(/** @lends ccs.WidgetPropertiesRea convertedClassName = "TextAtlas"; else if (name == "LabelBMFont") convertedClassName = "TextBMFont"; + else if (name == "Node") + convertedClassName = "Layout"; return convertedClassName; }, @@ -2179,5 +1960,243 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc labelBMFont.setString(text); this.setColorPropsForWidgetFromJsonDictionary(widget, options); + }, + + widgetFromProtocolBuffers: function(nodetree){ + + + var classname = nodetree.classname; + cc.log("classname = %s", classname); + + var widget = this._createGUI(classname); + var readerName = this._getWidgetReaderClassName(classname); + + var reader = this._createWidgetReaderProtocol(readerName); + + if (reader) + { + // widget parse with widget reader + this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); + } + else + { + // + // 1st., custom widget parse properties of parent widget with parent widget reader + readerName = this._getWidgetReaderClassName(widget); + reader = this._createWidgetReaderProtocol(readerName); + if (reader && widget) + { + this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); + + // 2nd., custom widget parse with custom reader + var widgetOptions = nodetree.widgetOptions; + var customJsonDict = widgetOptions.componentOptions; +// var customJsonDict; +// customJsonDict.Parse(customProperty); +// if (customJsonDict.HasParseError()) +// { +// cc.log("GetParseError %s\n", customJsonDict.GetParseError()); +// } + this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); + } + else + { + cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); + } + // + } + + var size = nodetree.children.length; + cc.log("widget children size = %d", size); + for (var i = 0; i < size; ++i) + { + var subNodeTree = nodetree.children[i]; + var child = this.widgetFromProtocolBuffers(subNodeTree); + cc.log("widget child = %p", child); + if (child) + { + var pageView = widget; + if (pageView instanceof ccui.PageView) + { + pageView.addPage(child); + } + else + { + var listView = widget; + if (listView instanceof ccui.ListView) + { + listView.pushBackCustomItem(child); + } + else + { + widget.addChild(child); + } + } + } + } + + cc.log("widget = %p", widget); + + return widget; + }, + + setPropsForAllWidgetFromProtocolBuffers: function(reader, widget, nodetree){ + reader.setPropsFromProtocolBuffers(widget, nodetree); + }, + + widgetFromXML: function(objectData, classType){ + var classname = classType.substr(0, classType.find("ObjectData")); + cc.log("classname = %s", classname); + + var widget = this.createGUI(classname); + var readerName = this.getWidgetReaderClassName(classname); + + var reader = this.createWidgetReaderProtocol(readerName); + + if (reader) + { + // widget parse with widget reader + this.setPropsForAllWidgetFromXML(reader, widget, objectData); + } + else + { + // + // 1st., custom widget parse properties of parent widget with parent widget reader + readerName = this.getWidgetReaderClassName(widget); + reader = this.createWidgetReaderProtocol(readerName); + if (reader && widget) + { + this.setPropsForAllWidgetFromXML(reader, widget, objectData); + + // 2nd., custom widget parse with custom reader + // const protocolbuffers::WidgetOptions& widgetOptions = nodetree.widgetoptions(); + // const char* customProperty = widgetOptions.customproperty().c_str(); + var customProperty = ""; + var customJsonDict; + customJsonDict.Parse(customProperty); + if (customJsonDict.HasParseError()) + { + cc.log("GetParseError %s\n", customJsonDict.GetParseError()); + } + this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); + } + else + { + cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); + } + // + } + + + + + + // children + var containChildrenElement = false; + objectData = objectData.FirstChildElement(); + + while (objectData) + { + cc.log("objectData name = %s", objectData.Name()); + + if ("Children" !== objectData.Name()) + { + containChildrenElement = true; + break; + } + + objectData = objectData.NextSiblingElement(); + } + + if (containChildrenElement) + { + objectData = objectData.FirstChildElement(); + cc.log("objectData name = %s", objectData.Name()); + + while (objectData) + { + var attribute = objectData.FirstAttribute(); + while (attribute) + { + var name = attribute.Name(); + var value = attribute.Value(); + + if (name == "ctype") + { + var child = this.widgetFromXML(objectData, value); + cc.log("child = %p", child); + if (child) + { + var pageView = widget; + var listView = widget; + if (pageView instanceof ccui.PageView) + { + var layout = child; + if (layout instanceof ccui.Layout) + { + pageView.addPage(layout); + } + } + else if (listView) + { + var widgetChild = child; + if (widgetChild instanceof ccui.Widget) + { + listView.pushBackCustomItem(widgetChild); + } + } + else + { + widget.addChild(child); + } + } + + break; + } + + attribute = attribute.Next(); + } + + // Node* child = nodeFromXML(objectData, value); + // CCLOG("child = %p", child); + // if (child) + // { + // PageView* pageView = dynamic_cast(node); + // ListView* listView = dynamic_cast(node); + // if (pageView) + // { + // Layout* layout = dynamic_cast(child); + // if (layout) + // { + // pageView.addPage(layout); + // } + // } + // else if (listView) + // { + // Widget* widget = dynamic_cast(child); + // if (widget) + // { + // listView.pushBackCustomItem(widget); + // } + // } + // else + // { + // node.addChild(child); + // } + // } + + objectData = objectData.NextSiblingElement(); + } + } + // + + cc.log("widget = %p", widget); + + return widget; + }, + + setPropsForAllWidgetFromXML: function(reader, widget, objectData){ + reader.setPropsFromXML(widget, objectData); } + }); diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index 4f13b51548..ea7f5a3875 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -120,9 +120,9 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ var cr = options["textColorR"]; var cg = options["textColorG"]; var cb = options["textColorB"]; - var cri = cr?options["textColorR"]:255; - var cgi = cg?options["textColorG"]:255; - var cbi = cb?options["textColorB"]:255; + var cri = cr!==null?options["textColorR"]:255; + var cgi = cg!==null?options["textColorG"]:255; + var cbi = cb!==null?options["textColorB"]:255; button.setTitleColor(cc.color(cri,cgi,cbi)); var fs = options["fontSize"]; @@ -135,44 +135,44 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var button = widget; - var options = nodeTree.buttonoptions(); + var options = nodeTree.buttonOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); - var scale9Enable = options.scale9enable(); + var scale9Enable = options.scale9Enable; button.setScale9Enabled(scale9Enable); - var normalDic = options.normaldata(); - var normalType = normalDic.resourcetype(); + var normalDic = options.normalData; + var normalType = normalDic.resourceType; if (normalType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + normalDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + normalDic.plistFile); } - var normalTexturePath = this.getResourcePath(normalDic.path(), normalType); + var normalTexturePath = ccs.WidgetReader.getResourcePath(normalDic.path, normalType); button.loadTextureNormal(normalTexturePath, normalType); - var pressedDic = options.presseddata(); - var pressedType = pressedDic.resourcetype(); + var pressedDic = options.pressedData; + var pressedType = pressedDic.resourceType; if (pressedType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + pressedDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + pressedDic.plistFile); } - var pressedTexturePath = this.getResourcePath(pressedDic.path(), pressedType); + var pressedTexturePath = ccs.WidgetReader.getResourcePath(pressedDic.path, pressedType); button.loadTexturePressed(pressedTexturePath, pressedType); - var disabledDic = options.disableddata(); - var disabledType = disabledDic.resourcetype(); + var disabledDic = options.disabledData; + var disabledType = disabledDic.resourceType; if (disabledType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + disabledDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + disabledDic.plistFile); } - var disabledTexturePath = this.getResourcePath(disabledDic.path(), disabledType); + var disabledTexturePath = ccs.WidgetReader.getResourcePath(disabledDic.path, disabledType); button.loadTextureDisabled(disabledTexturePath, disabledType); if (scale9Enable) @@ -180,64 +180,58 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ button.setUnifySizeEnabled(false); button.ignoreContentAdaptWithSize(false); - var cx = options.capinsetsx(); - var cy = options.capinsetsy(); - var cw = options.capinsetswidth(); - var ch = options.capinsetsheight(); + var cx = options.capInsetsX; + var cy = options.capInsetsY; + var cw = options.capInsetsWidth; + var ch = options.capInsetsHeight; - button.setCapInsets(Rect(cx, cy, cw, ch)); - var sw = options.has_scale9width(); - var sh = options.has_scale9height(); + button.setCapInsets(cc.rect(cx, cy, cw, ch)); + var sw = options.scale9Width; + var sh = options.scale9Height; if (sw && sh) { - var swf = options.scale9width(); - var shf = options.scale9height(); - button.setContentSize(cc.size(swf, shf)); + button.setContentSize(cc.size(sw, sh)); } } - var tt = options.has_text(); + var tt = options.text; if (tt) { - var text = options.text(); - if (text) - { - button.setTitleText(text); - } + button.setTitleText(tt); } - var cri = options.has_textcolorr() ? options.textcolorr() : 255; - var cgi = options.has_textcolorg() ? options.textcolorg() : 255; - var cbi = options.has_textcolorb() ? options.textcolorb() : 255; + var cri = options.textColorR!==null ? options.textColorR : 255; + var cgi = options.textColorG!==null ? options.textColorG : 255; + var cbi = options.textColorB!==null ? options.textColorB : 255; button.setTitleColor(cc.color(cri,cgi,cbi)); - var fontSize = options.has_fontsize() ? options.fontsize() : 14; + var fontSize = options.fontSize!==null ? options.fontSize : 14; button.setTitleFontSize(fontSize); var displaystate = true; - if(options.has_displaystate()) + if(options.displaystate!==null) { - displaystate = options.displaystate(); + displaystate = options.displaystate; } button.setBright(displaystate); - var fontName = options.has_fontname() ? options.fontname() : "微软雅黑"; + var fontName = options.fontName!==null ? options.fontName : "微软雅黑"; button.setTitleFontName(fontName); - if (options.has_fontresource()) + if (options.fontResource) { - var resourceData = options.fontresource(); - button.setTitleFontName(protocolBuffersPath + resourceData.path()); + var resourceData = options.fontResource; + button.setTitleFontName(protocolBuffersPath + resourceData.path); } - var widgetOption = nodeTree.widgetoptions(); - button.setColor(cc.color(widgetOption.colorr(), widgetOption.colorg(), widgetOption.colorb())); - button.setOpacity(widgetOption.has_alpha() ? widgetOption.alpha() : 255); + var widgetOption = nodeTree.widgetOptions; + button.setColor(cc.color(widgetOption.colorR, widgetOption.colorG, widgetOption.colorB)); + button.setOpacity(widgetOption.Alpha!==null ? widgetOption.Alpha : 255); // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML: function(widget, objectData){ @@ -417,14 +411,14 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ { case 0: { - button.loadTextureDisabled(xmlPath + path, Widget.TextureResType.LOCAL); + button.loadTextureDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { SpriteFrameCache.getInstance().addSpriteFramesWithFile(xmlPath + plistFile); - button.loadTextureDisabled(path, Widget.TextureResType.PLIST); + button.loadTextureDisabled(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -463,14 +457,14 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ { case 0: { - button.loadTexturePressed(xmlPath + path, Widget.TextureResType.LOCAL); + button.loadTexturePressed(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - button.loadTexturePressed(path, Widget.TextureResType.PLIST); + button.loadTexturePressed(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -509,14 +503,14 @@ ccs.ButtonReader = /** @lends ccs.ButtonReader# */{ { case 0: { - button.loadTextureNormal(xmlPath + path, Widget.TextureResType.LOCAL); + button.loadTextureNormal(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - button.loadTextureNormal(path, Widget.TextureResType.PLIST); + button.loadTextureNormal(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index 93127446a6..343814faae 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -93,74 +93,74 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var checkBox = widget; - var options = nodeTree.checkboxoptions(); + var options = nodeTree.checkboxOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); //load background image - var backGroundDic = options.backgroundboxdata(); - var backGroundType = backGroundDic.resourcetype(); + var backGroundDic = options.backGroundBoxData; + var backGroundType = backGroundDic.resourceType; if (backGroundType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + backGroundDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + backGroundDic.plistFile); } - var backGroundTexturePath = this.getResourcePath(backGroundDic.path(), backGroundType); + var backGroundTexturePath = ccs.WidgetReader.getResourcePath(backGroundDic.path, backGroundType); checkBox.loadTextureBackGround(backGroundTexturePath, backGroundType); //load background selected image - var backGroundSelectedDic = options.backgroundboxselecteddata(); - var backGroundSelectedType = backGroundSelectedDic.resourcetype(); + var backGroundSelectedDic = options.backGroundBoxSelectedData; + var backGroundSelectedType = backGroundSelectedDic.resourceType; if (backGroundSelectedType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + backGroundSelectedDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + backGroundSelectedDic.plistFile); } - var backGroundSelectedTexturePath = this.getResourcePath(backGroundSelectedDic.path(), backGroundSelectedType); + var backGroundSelectedTexturePath = ccs.WidgetReader.getResourcePath(backGroundSelectedDic.path, backGroundSelectedType); checkBox.loadTextureBackGroundSelected(backGroundSelectedTexturePath, backGroundSelectedType); //load frontCross image - var frontCrossDic = options.frontcrossdata(); - var frontCrossType = frontCrossDic.resourcetype(); + var frontCrossDic = options.frontCrossData; + var frontCrossType = frontCrossDic.resourceType; if (frontCrossType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + frontCrossDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + frontCrossDic.plistFile); } - var frontCrossFileName = this.getResourcePath(frontCrossDic.path(), frontCrossType); + var frontCrossFileName = ccs.WidgetReader.getResourcePath(frontCrossDic.path, frontCrossType); checkBox.loadTextureFrontCross(frontCrossFileName, frontCrossType); //load backGroundBoxDisabledData - var backGroundDisabledDic = options.backgroundboxdisableddata(); - var backGroundDisabledType = backGroundDisabledDic.resourcetype(); + var backGroundDisabledDic = options.backGroundBoxDisabledData; + var backGroundDisabledType = backGroundDisabledDic.resourceType; if (backGroundDisabledType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + backGroundDisabledDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + backGroundDisabledDic.plistFile); } - var backGroundDisabledFileName = this.getResourcePath(backGroundDisabledDic.path(), backGroundDisabledType); + var backGroundDisabledFileName = ccs.WidgetReader.getResourcePath(backGroundDisabledDic.path, backGroundDisabledType); checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, backGroundDisabledType); ///load frontCrossDisabledData - var frontCrossDisabledDic = options.frontcrossdisableddata(); - var frontCrossDisabledType = frontCrossDisabledDic.resourcetype(); + var frontCrossDisabledDic = options.frontCrossDisabledData; + var frontCrossDisabledType = frontCrossDisabledDic.resourceType; if (frontCrossDisabledType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + frontCrossDisabledDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + frontCrossDisabledDic.plistFile); } - var frontCrossDisabledFileName = this.getResourcePath(frontCrossDisabledDic.path(), frontCrossDisabledType); + var frontCrossDisabledFileName = ccs.WidgetReader.getResourcePath(frontCrossDisabledDic.path, frontCrossDisabledType); checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); - checkBox.setSelectedState(options.selectedstate()); + checkBox.setSelectedState(options.selectedState); var displaystate = true; - if(options.has_displaystate()) + if(options.displaystate!==null) { - displaystate = options.displaystate(); + displaystate = options.displaystate; } checkBox.setBright(displaystate); // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML: function(widget, objectData){ @@ -232,14 +232,14 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ { case 0: { - checkBox.loadTextureBackGround(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + checkBox.loadTextureBackGround(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - checkBox.loadTextureBackGround(path, ccui.Widget.TextureResType.PLIST); + checkBox.loadTextureBackGround(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -278,14 +278,14 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ { case 0: { - checkBox.loadTextureBackGroundSelected(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + checkBox.loadTextureBackGroundSelected(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - checkBox.loadTextureBackGroundSelected(path, ccui.Widget.TextureResType.PLIST); + checkBox.loadTextureBackGroundSelected(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -324,14 +324,14 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ { case 0: { - checkBox.loadTextureFrontCross(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + checkBox.loadTextureFrontCross(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - checkBox.loadTextureFrontCross(path, ccui.Widget.TextureResType.PLIST); + checkBox.loadTextureFrontCross(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -370,14 +370,14 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ { case 0: { - checkBox.loadTextureBackGroundDisabled(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + checkBox.loadTextureBackGroundDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - checkBox.loadTextureBackGroundDisabled(path, ccui.Widget.TextureResType.PLIST); + checkBox.loadTextureBackGroundDisabled(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -416,14 +416,14 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ { case 0: { - checkBox.loadTextureFrontCrossDisabled(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + checkBox.loadTextureFrontCrossDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - checkBox.loadTextureFrontCrossDisabled(path, ccui.Widget.TextureResType.PLIST); + checkBox.loadTextureFrontCrossDisabled(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index e2ed8b30a4..298277b945 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -100,28 +100,28 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - var options = nodeTree.imageviewoptions(); + var options = nodeTree.imageviewOptions; var imageView = widget; var protocolBuffersPath = ccs.uiReader.getFilePath(); - var imageFileNameDic = options.filenamedata(); - var imageFileNameType = imageFileNameDic.resourcetype(); + var imageFileNameDic = options.fileNameData; + var imageFileNameType = imageFileNameDic.resourceType; if (imageFileNameType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } - var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path(), imageFileNameType); imageView.loadTexture(imageFileName, imageFileNameType); - var scale9EnableExist = options.has_scale9enable(); + var scale9EnableExist = options.scale9enAble!==null; var scale9Enable = false; if (scale9EnableExist) { - scale9Enable = options.scale9enable(); + scale9Enable = options.scale9enAble; } imageView.setScale9Enabled(scale9Enable); @@ -131,25 +131,25 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ imageView.setUnifySizeEnabled(false); imageView.ignoreContentAdaptWithSize(false); - var swf = options.has_scale9width() ? options.scale9width() : 80; - var shf = options.has_scale9height() ? options.scale9height() : 80; - imageView.setContentSize(Size(swf, shf)); + var swf = options.scale9width!==null ? options.scale9Width : 80; + var shf = options.scale9height!==null ? options.scale9Height : 80; + imageView.setContentSize(cc.size(swf, shf)); - var cx = options.capinsetsx(); - var cy = options.capinsetsy(); - var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1.0; - var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1.0; + var cx = options.capInsetsX; + var cy = options.capInsetsY; + var cw = options.capInsetsWidth!==null ? options.capInsetsWidth : 1.0; + var ch = options.capInsetsHeight!==null ? options.capInsetsHeight : 1.0; - imageView.setCapInsets(Rect(cx, cy, cw, ch)); + imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); } // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - var flipX = options.flippedx(); - var flipY = options.flippedy(); + var flipX = options.flippedX; + var flipY = options.flippedY; if(flipX != false) imageView.setFlippedX(flipX); @@ -266,14 +266,14 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ { case 0: { - imageView.loadTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + imageView.loadTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - imageView.loadTexture(path, ccui.Widget.TextureResType.PLIST); + imageView.loadTexture(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 31c6bb6525..8f3c3e7cbc 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -76,35 +76,35 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var jsonPath = ccs.uiReader.getFilePath(); var labelAtlas = widget; - var options = nodeTree.textatlasoptions(); + var options = nodeTree.textatlasOptions; // var sv = DICTOOL.checkObjectExist_json(options, P_StringValue); // var cmf = DICTOOL.checkObjectExist_json(options, P_CharMapFile); // var iw = DICTOOL.checkObjectExist_json(options, P_ItemWidth); // var ih = DICTOOL.checkObjectExist_json(options, P_ItemHeight); // var scm = DICTOOL.checkObjectExist_json(options, P_StartCharMap); - var cmftDic = options.charmapfiledata(); - var cmfType = cmftDic.resourcetype(); + var cmftDic = options.charmapFileData; + var cmfType = cmftDic.resourceType; switch (cmfType) { case 0: { var tp_c = jsonPath; - var cmfPath = cmftDic.path().c_str(); - var cmf_tp = tp_c.append(cmfPath).c_str(); - var stringValue = options.has_stringvalue() ? options.stringvalue() : "12345678"; - var itemWidth = options.has_itemwidth() ? options.itemwidth() : 24; - var itemHeight = options.has_itemheight() ? options.itemheight() : 32; + var cmfPath = cmftDic.path; + var cmf_tp = tp_c.append(cmfPath); + var stringValue = options.stringValue!==null ? options.stringValue : "12345678"; + var itemWidth = options.itemWidth!==null ? options.itemWidth : 24; + var itemHeight = options.has_itemheight ? options.itemHeight : 32; labelAtlas.setProperty(stringValue, cmf_tp, itemWidth, itemHeight, - options.startcharmap().c_str()); + options.startCharmap); break; } case 1: @@ -116,11 +116,11 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML: function(widget, objectData){ - ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + ccs.WidgetReader.setPropsFromXML.call(this, widget, objectData); var labelAtlas = widget; diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index ef5a0aff3c..4bb7a5dcae 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -77,30 +77,32 @@ ccs.LabelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ var jsonPath = ccs.uiReader.getFilePath(); var labelBMFont = widget; - var options = nodeTree.textbmfontoptions(); + var options = nodeTree.textBMFontOptions; - var cmftDic = options.filenamedata(); - var cmfType = cmftDic.resourcetype(); - switch (cmfType) - { - case 0: + if(options){ + var cmftDic = options.fileNameData; + var cmfType = cmftDic.resourceType; + switch (cmfType) { - var tp_c = jsonPath; - var cmfPath = cmftDic.path().c_str(); - var cmf_tp = tp_c.append(cmfPath).c_str(); - labelBMFont.setFntFile(cmf_tp); - break; + case 0: + { + var tp_c = jsonPath; + var cmfPath = cmftDic.path(); + var cmf_tp = tp_c.append(cmfPath); + labelBMFont.setFntFile(cmf_tp); + break; + } + case 1: + cc.log("Wrong res type of LabelAtlas!"); + break; + default: + break; } - case 1: - cc.log("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - var text = (options.has_text()) ? options.text().c_str() : "Text Label"; - labelBMFont.setString(text); + var text = options.text!==null ? options.text : "Text Label"; + labelBMFont.setString(text); + } // other commonly protperties diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index 0ef6efee2e..d48625b795 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -83,68 +83,66 @@ ccs.LabelReader = /** @lends ccs.LabelReader# */{ setPropsFromProtocolBuffers: function(widget, nodeTree){ var label = widget; - var options = nodeTree.textoptions(); + var options = nodeTree.textOptions; - var IsCustomSize = options.iscustomsize(); + var IsCustomSize = options.IsCustomSize; label.ignoreContentAdaptWithSize(!IsCustomSize); - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); label.setUnifySizeEnabled(false); var protocolBuffersPath = ccs.uiReader.getFilePath(); - var touchScaleChangeAble = options.touchscaleenable(); + var touchScaleChangeAble = options.touchScaleEnable; label.setTouchScaleChangeEnabled(touchScaleChangeAble); - var text = options.has_text() ? options.text().c_str() : "Text Label"; + var text = options.text!==null ? options.text : "Text Label"; label.setString(text); - var fontSize = options.has_fontsize() ? options.fontsize() : 20; + var fontSize = options.fontSize!==null ? options.fontSize : 20; label.setFontSize(fontSize); - var fontName = options.has_fontname() ? options.fontname() : "微软雅黑"; - - var fontFilePath = protocolBuffersPath.append(fontName); - if (FileUtils.getInstance().isFileExist(fontFilePath)) - { - label.setFontName(fontFilePath); - } - else{ - label.setFontName(fontName); - } - - var aw = options.has_areawidth(); - var ah = options.has_areaheight(); + var fontName = options.fontName!==null ? options.fontName : "微软雅黑"; + label.setFontName(fontName); +// var fontFilePath = protocolBuffersPath.append(fontName); +// if (FileUtils.getInstance().isFileExist(fontFilePath)) +// { +// label.setFontName(fontFilePath); +// } +// else{ +// label.setFontName(fontName); +// } + + var aw = options.areaWidth; + var ah = options.areaHeight; if (aw && ah) { - var size = Size(options.areawidth(), options.areaheight()); + var size = cc.size(aw, ah); label.setTextAreaSize(size); } - var ha = options.has_halignment(); + var ha = options.hAlignment; if (ha) { - label.setTextHorizontalAlignment(options.halignment()); + label.setTextHorizontalAlignment(ha); } - var va = options.has_valignment(); + var va = options.vAlignment; if (va) { - label.setTextVerticalAlignment(options.valignment()); + label.setTextVerticalAlignment(va); } - if (options.has_fontresource()) + if (options.fontResource) { - var resourceData = options.fontresource(); - label.setFontName(protocolBuffersPath + resourceData.path()); + var resourceData = options.fontResource; + label.setFontName(protocolBuffersPath + resourceData.path); } - - // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML: function(widget, objectData){ - ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + ccs.WidgetReader.setPropsFromXML.call(this, widget, objectData); var label = widget; diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 8e5c9d5c1b..f2409d8679 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -129,16 +129,16 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var panel = widget; - var options = nodeTree.paneloptions(); + var options = nodeTree.PanelOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); - panel.setClippingEnabled(options.clipable()); + panel.setClippingEnabled(options.clipAble); - var backGroundScale9Enable = options.backgroundscale9enable(); + var backGroundScale9Enable = options.backGroundScale9Enable; panel.setBackGroundImageScale9Enabled(backGroundScale9Enable); @@ -154,121 +154,133 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ if (widget instanceof ccui.PageView) { - cr = options.has_bgcolorr() ? options.bgcolorr() : 150; - cg = options.has_bgcolorg() ? options.bgcolorg() : 150; - cb = options.has_bgcolorb() ? options.bgcolorb() : 150; + cr = 150; + cg = 150; + cb = 150; - scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; - scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; - scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + scr = 255; + scg = 255; + scb = 255; - ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; - ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; - ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + ecr = 255; + ecg = 150; + ecb = 100; } else if(widget instanceof ccui.ListView) { - cr = options.has_bgcolorr() ? options.bgcolorr() : 150; - cg = options.has_bgcolorg() ? options.bgcolorg() : 150; - cb = options.has_bgcolorb() ? options.bgcolorb() : 255; + cr = 150; + cg = 150; + cb = 255; - scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; - scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; - scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + scr = 255; + scg = 255; + scb = 255; - ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 150; - ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; - ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 255; + ecr = 150; + ecg = 150; + ecb = 255; } else if(widget instanceof ccui.ScrollView) { - cr = options.has_bgcolorr() ? options.bgcolorr() : 255; - cg = options.has_bgcolorg() ? options.bgcolorg() : 150; - cb = options.has_bgcolorb() ? options.bgcolorb() : 100; + cr = 255; + cg = 150; + cb = 100; - scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; - scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; - scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + scr = 255; + scg = 255; + scb = 255; - ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; - ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; - ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + ecr = 255; + ecg = 150; + ecb = 100; } else { - cr = options.has_bgcolorr() ? options.bgcolorr() : 150; - cg = options.has_bgcolorg() ? options.bgcolorg() : 200; - cb = options.has_bgcolorb() ? options.bgcolorb() : 255; + cr = 150; + cg = 200; + cb = 255; - scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; - scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; - scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + scr = 255; + scg = 255; + scb = 255; - ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 150; - ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 200; - ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 255; + ecr = 150; + ecg = 200; + ecb = 255; } + cr = options.bgColorR!==null ? options.bgColorR : cr; + cg = options.bgColorG!==null ? options.bgColorG : cg; + cb = options.bgColorB!==null ? options.bgColorB : cb; + + scr = options.bgStartColorR!==null ? options.bgStartColorR : scr; + scg = options.bgStartColorG!==null ? options.bgStartColorG : scg; + scb = options.bgStartColorB!==null ? options.bgStartColorB : scb; + + ecr = options.bgEndColorR!==null ? options.bgEndColorR : ecr; + ecg = options.bgEndColorG!==null ? options.bgEndColorG : ecg; + ecb = options.bgEndColorB!==null ? options.bgEndColorB : ecb; + var bgcv1 = 0; var bgcv2 = -0.5; - if(options.has_vectorx()) + if(options.vectorX!==null) { - bgcv1 = options.vectorx(); + bgcv1 = options.vectorX; } - if(options.has_vectory()) + if(options.vectorY) { - bgcv2 = options.vectory(); + bgcv2 = options.vectorY; } panel.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + var co = options.bgColorOpacity!==null ? options.bgColorOpacity : 100; - var colorType = options.has_colortype() ? options.colortype() : 1; - panel.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + var colorType = options.colorType!==null ? options.colorType : 1; + panel.setBackGroundColorType(colorType); panel.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); panel.setBackGroundColor(cc.color(cr, cg, cb)); panel.setBackGroundColorOpacity(co); - var imageFileNameDic = options.backgroundimagedata(); - var imageFileNameType = imageFileNameDic.resourcetype(); - if (imageFileNameType == 1) - { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); - } - var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); - panel.setBackGroundImage(imageFileName, imageFileNameType); + var imageFileNameDic = options.backGroundImageData; + if(imageFileNameDic){ + var imageFileNameType = imageFileNameDic.resourceType; + if (imageFileNameType == 1) + { + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); + } + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); + panel.setBackGroundImage(imageFileName, imageFileNameType); + } if (backGroundScale9Enable) { - var cx = options.capinsetsx(); - var cy = options.capinsetsy(); - var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; - var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + var cx = options.capInsetsX; + var cy = options.capInsetsY; + var cw = options.capInsetsWidth!==null ? options.capInsetsWidth : 1; + var ch = options.capInsetsHeight!==null ? options.capInsetsHeight : 1; panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - var sw = options.has_scale9width(); - var sh = options.has_scale9height(); + var sw = options.scale9Width; + var sh = options.scale9Height; if (sw && sh) { - var swf = options.scale9width(); - var shf = options.scale9height(); - panel.setContentSize(cc.size(swf, shf)); + panel.setContentSize(cc.size(sw, sh)); } } - panel.setLayoutType(options.layouttype()); + panel.setLayoutType(options.layoutType); - var widgetOptions = nodeTree.widgetoptions(); + var widgetOptions = nodeTree.widgetOptions; - var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; - var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; - var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + var red = widgetOptions.colorR!==null ? widgetOptions.colorR : 255; + var green = widgetOptions.colorG!==null ? widgetOptions.colorG : 255; + var blue = widgetOptions.colorB!==null ? widgetOptions.colorB : 255; panel.setColor(cc.color(red, green, blue)); - var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + var opacity = widgetOptions.Alpha!==null ? widgetOptions.alpha : 255; panel.setOpacity(opacity); // var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; @@ -281,16 +293,16 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ // other commonly protperties - this.setAnchorPointForWidget(widget, nodeTree); + ccs.WidgetReader._setAnchorPointForWidget(widget, nodeTree); - var flipX = widgetOptions.flipx(); - var flipY = widgetOptions.flipy(); + var flipX = widgetOptions.flipX; + var flipY = widgetOptions.flipY; widget.setFlippedX(flipX); widget.setFlippedY(flipY); }, setPropsFromXML: function(widget, objectData){ - ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + ccs.WidgetReader.setPropsFromXML.call(this, widget, objectData); var panel = widget; @@ -564,14 +576,14 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ { case 0: { - panel.setBackGroundImage(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + panel.setBackGroundImage(xmlPath + path, ccui.Widget.PLIST_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - panel.setBackGroundImage(path, ccui.Widget.TextureResType.PLIST); + panel.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index 6aea22691f..48325ddcad 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -62,13 +62,13 @@ ccs.ListViewReader = /** @lends ccs.ListViewReader# */{ ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var listView = widget; - var options = nodeTree.listviewoptions(); + var options = nodeTree.listviewOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); - listView.setClippingEnabled(options.clipable()); + listView.setClippingEnabled(options.clipAble); - var backGroundScale9Enable = options.backgroundscale9enable(); + var backGroundScale9Enable = options.backGroundScale9enAble; listView.setBackGroundImageScale9Enabled(backGroundScale9Enable); @@ -84,68 +84,68 @@ ccs.ListViewReader = /** @lends ccs.ListViewReader# */{ - cr = options.has_bgcolorr() ? options.bgcolorr() : 150; - cg = options.has_bgcolorg() ? options.bgcolorg() : 150; - cb = options.has_bgcolorb() ? options.bgcolorb() : 255; + cr = options.bgColorR!==null ? options.bgColorR : 150; + cg = options.bgColorG!==null ? options.bgColorG : 150; + cb = options.bgColorB!==null ? options.bgColorB : 255; - scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; - scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; - scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + scr = options.bgStartColorR!==null ? options.bgStartColorR : 255; + scg = options.bgStartColorG!==null ? options.bgStartColorG : 255; + scb = options.bgStartColorB!==null ? options.bgStartColorB : 255; - ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 150; - ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; - ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 255; + ecr = options.bgEndColorR!==null ? options.bgEndColorR : 150; + ecg = options.bgEndColorG!==null ? options.bgEndColorG : 150; + ecb = options.bgEndColorB!==null ? options.bgEndColorB : 255; - var bgcv1 = options.vectorx(); - var bgcv2 = options.has_vectory() ? options.vectory() : -0.5; + var bgcv1 = options.vectorX; + var bgcv2 = options.vectorY!==null ? options.vectorY : -0.5; listView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + var co = options.bgColorOpacity!==null ? options.bgColorOpacity : 100; - var colorType = options.has_colortype() ? options.colortype() : 1; - listView.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + var colorType = options.colorType!==null ? options.colorType : 1; + listView.setBackGroundColorType(colorType); listView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); listView.setBackGroundColor(cc.color(cr, cg, cb)); listView.setBackGroundColorOpacity(co); - var imageFileNameDic = options.backgroundimagedata(); - var imageFileNameType = imageFileNameDic.resourcetype(); + var imageFileNameDic = options.backGroundImageData; + var imageFileNameType = imageFileNameDic.resourceType; if (imageFileNameType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } - var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); listView.setBackGroundImage(imageFileName, imageFileNameType); if (backGroundScale9Enable) { - var cx = options.capinsetsx(); - var cy = options.capinsetsy(); - var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; - var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + var cx = options.capInsetsX; + var cy = options.capInsetsY; + var cw = options.capInsetsWidth!==null ? options.capInsetsWidth : 1; + var ch = options.capInsetsHeight!==null ? options.capInsetsHeight : 1; listView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - var sw = options.has_scale9width(); - var sh = options.has_scale9height(); + var sw = options.scale9width; + var sh = options.scale9height; if (sw && sh) { - var swf = options.scale9width(); - var shf = options.scale9height(); + var swf = options.scale9width; + var shf = options.scale9height; listView.setContentSize(cc.size(swf, shf)); } } - var widgetOptions = nodeTree.widgetoptions(); + var widgetOptions = nodeTree.widgetOptions; - var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; - var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; - var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + var red = widgetOptions.colorR!==null ? widgetOptions.colorR : 255; + var green = widgetOptions.colorG!==null ? widgetOptions.colorG : 255; + var blue = widgetOptions.colorB!==null ? widgetOptions.colorB : 255; listView.setColor(cc.color(red, green, blue)); - var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + var opacity = widgetOptions.Alpha!=null ? widgetOptions.Alpha : 255; listView.setOpacity(opacity); // var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; @@ -160,27 +160,27 @@ ccs.ListViewReader = /** @lends ccs.ListViewReader# */{ - var innerWidth = options.has_innerwidth() ? options.innerwidth() : 200; - var innerHeight = options.has_innerheight() ? options.innerheight() : 200; - listView.setInnerContainerSize(Size(innerWidth, innerHeight)); - listView.setBounceEnabled(options.bounceenable()); + var innerWidth = options.innerWidth!==null ? options.innerWidth : 200; + var innerHeight = options.innerHeight!==null ? options.innerHeight : 200; + listView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + listView.setBounceEnabled(options.bounceEnable); - var direction = options.has_direction() ? options.direction() : 2; + var direction = options.direction!=null ? options.direction : 2; listView.setDirection(direction); - var gravityValue = options.has_gravity() ? options.gravity() : 3; + var gravityValue = options.gravity!==null ? options.gravity : 3; var gravity = gravityValue; listView.setGravity(gravity); - var itemMargin = options.itemmargin(); + var itemMargin = options.itemMargin; listView.setItemsMargin(itemMargin); // other commonly protperties - this.setAnchorPointForWidget(widget, nodeTree); + ccs.WidgetReader.setAnchorPointForWidget(widget, nodeTree); - var flipX = widgetOptions.flipx(); - var flipY = widgetOptions.flipy(); + var flipX = widgetOptions.flipX; + var flipY = widgetOptions.flipY; widget.setFlippedX(flipX); widget.setFlippedY(flipY); }, @@ -551,14 +551,14 @@ ccs.ListViewReader = /** @lends ccs.ListViewReader# */{ { case 0: { - listView.setBackGroundImage(xmlPath + path, Widget.TextureResType.LOCAL); + listView.setBackGroundImage(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { SpriteFrameCache.getInstance().addSpriteFramesWithFile(xmlPath + plistFile); - listView.setBackGroundImage(path, Widget.TextureResType.PLIST); + listView.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index 80ec4051cd..7ce65c1d58 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -94,47 +94,47 @@ ccs.LoadingBarReader = /** @lends ccs.LoadingBarReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var loadingBar = widget; - var options = nodeTree.loadingbaroptions(); + var options = nodeTree.loadingbarOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); - var imageFileNameDic = options.texturedata(); - var imageFileNameType = imageFileNameDic.resourcetype(); + var imageFileNameDic = options.textureData; + var imageFileNameType = imageFileNameDic.resourceType; if (imageFileNameType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } - var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); loadingBar.loadTexture(imageFileName, imageFileNameType); /* gui mark add load bar scale9 parse */ - var scale9Enable = options.scale9enable(); + var scale9Enable = options.scale9Enable; loadingBar.setScale9Enabled(scale9Enable); - var cx = options.capinsetsx(); - var cy = options.capinsetsy(); - var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; - var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + var cx = options.capinsetsX; + var cy = options.capinsetsY; + var cw = options.capinsetsWidth!=null ? options.capinsetsWidth : 1; + var ch = options.capinsetsHeight!=null ? options.capinsetsHeight : 1; if (scale9Enable) { loadingBar.setCapInsets(cc.rect(cx, cy, cw, ch)); } - var widgetOptions = nodeTree.widgetoptions(); - var width = widgetOptions.width(); - var height = widgetOptions.height(); + var widgetOptions = nodeTree.widgetOptions; + var width = widgetOptions.width; + var height = widgetOptions.height; loadingBar.setContentSize(cc.size(width, height)); /**/ - loadingBar.setDirection(LoadingBar.Direction(options.direction())); - var percent = options.has_percent() ? options.percent() : 100; + loadingBar.setDirection(options.direction); + var percent = options.percent!==null ? options.percent : 100; loadingBar.setPercent(percent); @@ -241,14 +241,14 @@ ccs.LoadingBarReader = /** @lends ccs.LoadingBarReader# */{ { case 0: { - loadingBar.loadTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + loadingBar.loadTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - loadingBar.loadTexture(path, ccui.Widget.TextureResType.PLIST); + loadingBar.loadTexture(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index e198685526..b0e987c17e 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -52,14 +52,14 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ var pageView = widget; - var options = nodeTree.pageviewoptions(); + var options = nodeTree.pageviewOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); - cc.log("options.clipable() = %d", options.clipable()); - pageView.setClippingEnabled(options.clipable()); + cc.log("options.clipable() = %d", options.clipAble); + pageView.setClippingEnabled(options.clipAble); - var backGroundScale9Enable = options.backgroundscale9enable(); + var backGroundScale9Enable = options.backGroundScale9Enable; pageView.setBackGroundImageScale9Enabled(backGroundScale9Enable); @@ -73,45 +73,45 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ var ecg; var ecb; - cr = options.has_bgcolorr() ? options.bgcolorr() : 150; - cg = options.has_bgcolorg() ? options.bgcolorg() : 150; - cb = options.has_bgcolorb() ? options.bgcolorb() : 150; + cr = options.bgColorR!==null ? options.bgColorR : 150; + cg = options.bgColorG!==null ? options.bgColorG : 150; + cb = options.bgColorB!==null ? options.bgColorB : 150; - scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; - scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; - scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + scr = options.bgStartColorR!==null ? options.bgStartColorR : 255; + scg = options.bgStartColorG!==null ? options.bgStartColorG : 255; + scb = options.bgStartColorB!==null ? options.bgStartColorB : 255; - ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; - ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; - ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + ecr = options.bgEndColorR!==null ? options.bgEndColorR : 255; + ecg = options.bgEndColorG!==null ? options.bgEndColorG : 150; + ecb = options.bgEndColorB!==null ? options.bgEndColorB : 100; var bgcv1 = 0; var bgcv2 = -0.5; - if(options.has_vectorx()) + if(options.vectorX!==null) { - bgcv1 = options.vectorx(); + bgcv1 = options.vectorX; } - if(options.has_vectory()) + if(options.vectorY!==null) { - bgcv2 = options.vectory(); + bgcv2 = options.vectorY; } pageView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + var co = options.bgColorOpacity!==null ? options.bgColorOpacity : 100; - var colorType = options.has_colortype() ? options.colortype() : 1; - pageView.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + var colorType = options.colorType!==null ? options.colorType : 1; + pageView.setBackGroundColorType(colorType); pageView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); pageView.setBackGroundColor(cc.color(cr, cg, cb)); pageView.setBackGroundColorOpacity(co); - var imageFileNameDic = options.backgroundimagedata(); - var imageFileNameType = imageFileNameDic.resourcetype(); + var imageFileNameDic = options.backGroundImageData; + var imageFileNameType = imageFileNameDic.resourceType; if (imageFileNameType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); pageView.setBackGroundImage(imageFileName, imageFileNameType); @@ -119,29 +119,27 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ if (backGroundScale9Enable) { - var cx = options.capinsetsx(); - var cy = options.capinsetsy(); - var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; - var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + var cx = options.capInsetsX; + var cy = options.capInsetsY; + var cw = options.capInsetsWidth!==null ? options.capInsetsWidth : 1; + var ch = options.capInsetsHeight!==null ? options.capInsetsHeight : 1; pageView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - var sw = options.has_scale9width(); - var sh = options.has_scale9height(); + var sw = options.scale9Width; + var sh = options.scale9Height; if (sw && sh) { - var swf = options.scale9width(); - var shf = options.scale9height(); - pageView.setContentSize(cc.size(swf, shf)); + pageView.setContentSize(cc.size(sw, sh)); } } var widgetOptions = nodeTree.widgetoptions(); - var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; - var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; - var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + var red = widgetOptions.colorR!==null ? widgetOptions.colorR : 255; + var green = widgetOptions.colorG!==null ? widgetOptions.colorG : 255; + var blue = widgetOptions.colorB!==null ? widgetOptions.colorB : 255; pageView.setColor(cc.color(red, green, blue)); - var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + var opacity = widgetOptions.Alpha!==null ? widgetOptions.Alpha : 255; pageView.setOpacity(opacity); // var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; @@ -154,10 +152,10 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ // other commonly protperties - this.setAnchorPointForWidget(widget, nodeTree); + ccs.WidgetReader.setAnchorPointForWidget(widget, nodeTree); - var flipX = widgetOptions.flipx(); - var flipY = widgetOptions.flipy(); + var flipX = widgetOptions.flipX; + var flipY = widgetOptions.flipY; widget.setFlippedX(flipX); widget.setFlippedY(flipY); }, @@ -435,14 +433,14 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ { case 0: { - pageView.setBackGroundImage(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + pageView.setBackGroundImage(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - pageView.setBackGroundImage(path, ccui.Widget.TextureResType.PLIST); + pageView.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index 3ed20b84f0..bfb966c194 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -63,13 +63,13 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ var scrollView = widget; - var options = nodeTree.scrollviewoptions(); + var options = nodeTree.scrollviewOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); - scrollView.setClippingEnabled(options.clipable()); + scrollView.setClippingEnabled(options.clipAble); - var backGroundScale9Enable = options.backgroundscale9enable(); + var backGroundScale9Enable = options.backGroundScale9Enable; scrollView.setBackGroundImageScale9Enabled(backGroundScale9Enable); @@ -85,77 +85,75 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ - cr = options.has_bgcolorr() ? options.bgcolorr() : 255; - cg = options.has_bgcolorg() ? options.bgcolorg() : 150; - cb = options.has_bgcolorb() ? options.bgcolorb() : 100; + cr = options.bgColorR!==null ? options.bgColorR : 255; + cg = options.bgColorG!==null ? options.bgColorG : 150; + cb = options.bgColorB!==null ? options.bgColorB : 100; - scr = options.has_bgstartcolorr() ? options.bgstartcolorr() : 255; - scg = options.has_bgstartcolorg() ? options.bgstartcolorg() : 255; - scb = options.has_bgstartcolorb() ? options.bgstartcolorb() : 255; + scr = options.bgStartColorR!==null ? options.bgStartColorR : 255; + scg = options.bgStartColorG!==null ? options.bgStartColorG : 255; + scb = options.bgStartColorB!==null ? options.bgStartColorB : 255; - ecr = options.has_bgendcolorr() ? options.bgendcolorr() : 255; - ecg = options.has_bgendcolorg() ? options.bgendcolorg() : 150; - ecb = options.has_bgendcolorb() ? options.bgendcolorb() : 100; + ecr = options.bgEndColorR!==null ? options.bgEndColorR : 255; + ecg = options.bgEndColorG!==null ? options.bgEndColorG : 150; + ecb = options.bgEndColorB!==null ? options.bgEndColorB : 100; var bgcv1 = 0; var bgcv2 = -0.5; - if(options.has_vectorx()) + if(options.vectorX) { - bgcv1 = options.vectorx(); + bgcv1 = options.vectorX; } - if(options.has_vectory()) + if(options.vectorY!==null) { - bgcv2 = options.vectory(); + bgcv2 = options.vectorY; } scrollView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - var co = options.has_bgcoloropacity() ? options.bgcoloropacity() : 100; + var co = options.bgColorOpacity!==null ? options.bgColorOpacity : 100; - var colorType = options.has_colortype() ? options.colortype() : 1; - scrollView.setBackGroundColorType(Layout.BackGroundColorType(colorType)); + var colorType = options.colorType ? options.colorType : 1; + scrollView.setBackGroundColorType(colorType); - scrollView.setBackGroundColor(cc.color(scr, scg, scb),Color3B(ecr, ecg, ecb)); + scrollView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); scrollView.setBackGroundColor(cc.color(cr, cg, cb)); scrollView.setBackGroundColorOpacity(co); - var imageFileNameDic = options.backgroundimagedata(); - var imageFileNameType = imageFileNameDic.resourcetype(); + var imageFileNameDic = options.backGroundImageData; + var imageFileNameType = imageFileNameDic.resourceType; if (imageFileNameType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } - var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); scrollView.setBackGroundImage(imageFileName, imageFileNameType); if (backGroundScale9Enable) { - var cx = options.capinsetsx(); - var cy = options.capinsetsy(); - var cw = options.has_capinsetswidth() ? options.capinsetswidth() : 1; - var ch = options.has_capinsetsheight() ? options.capinsetsheight() : 1; + var cx = options.capInsetsX; + var cy = options.capInsetsY; + var cw = options.capInsetsWidth!==null ? options.capInsetsWidth : 1; + var ch = options.capInsetsHeight!==null ? options.capInsetsHeight : 1; scrollView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - var sw = options.has_scale9width(); - var sh = options.has_scale9height(); + var sw = options.scale9Width; + var sh = options.scale9Height; if (sw && sh) { - var swf = options.scale9width(); - var shf = options.scale9height(); - scrollView.setContentSize(cc.size(swf, shf)); + scrollView.setContentSize(cc.size(sw, sh)); } } - scrollView.setLayoutType(options.layouttype()); + scrollView.setLayoutType(options.layoutType); - var widgetOptions = nodeTree.widgetoptions(); + var widgetOptions = nodeTree.widgetOptions; - var red = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; - var green = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; - var blue = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; + var red = widgetOptions.colorR!==null ? widgetOptions.colorR : 255; + var green = widgetOptions.colorG ? widgetOptions.colorG : 255; + var blue = widgetOptions.colorB ? widgetOptions.colorB : 255; scrollView.setColor(cc.color(red, green, blue)); - var opacity = widgetOptions.has_alpha() ? widgetOptions.alpha() : 255; + var opacity = widgetOptions.Alpha!==null ? widgetOptions.Alpha : 255; scrollView.setOpacity(opacity); // var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; @@ -169,19 +167,19 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ - var innerWidth = options.has_innerwidth() ? options.innerwidth() : 200; - var innerHeight = options.has_innerheight() ? options.innerheight() : 200; + var innerWidth = options.innerWidth!==null ? options.innerWidth : 200; + var innerHeight = options.innerHeight!==null ? options.innerHeight : 200; scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); - var direction = options.has_direction() ? options.direction() : 1; + var direction = options.direction!==null ? options.direction : 1; scrollView.setDirection(direction); - scrollView.setBounceEnabled(options.bounceenable()); + scrollView.setBounceEnabled(options.bounceenAble); // other commonly protperties - this.setAnchorPointForWidget(widget, nodeTree); + ccs.WidgetReader.setAnchorPointForWidget(widget, nodeTree); - var flipX = widgetOptions.flipx(); - var flipY = widgetOptions.flipy(); + var flipX = widgetOptions.flipX; + var flipY = widgetOptions.flipY; widget.setFlippedX(flipX); widget.setFlippedY(flipY); }, @@ -504,14 +502,14 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ { case 0: { - scrollView.setBackGroundImage(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + scrollView.setBackGroundImage(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - scrollView.setBackGroundImage(path, ccui.Widget.TextureResType.PLIST); + scrollView.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index e86de5cfff..1c3fc5b7dc 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -167,29 +167,29 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var slider = widget; - var options = nodeTree.slideroptions(); + var options = nodeTree.sliderOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); - var barTextureScale9Enable = options.scale9enable(); + var barTextureScale9Enable = options.scale9Enable; slider.setScale9Enabled(barTextureScale9Enable); - slider.setPercent(options.percent()); + slider.setPercent(options.percent); // var bt = DICTOOL.checkObjectExist_json(options, P_BarFileName); - var barLength = options.has_length() ? options.length() : 290; + var barLength = options.length!==null ? options.length : 290; - var imageFileNameDic = options.barfilenamedata(); - var imageFileNameType = imageFileNameDic.resourcetype(); + var imageFileNameDic = options.barFileNameData; + var imageFileNameType = imageFileNameDic.resourceType; if (imageFileNameType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + imageFileNameDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } - var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path(), imageFileNameType); slider.loadBarTexture(imageFileName, imageFileNameType); @@ -200,50 +200,50 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ } //loading normal slider ball texture - var normalDic = options.ballnormaldata(); - var normalType = normalDic.resourcetype(); + var normalDic = options.ballnormalData; + var normalType = normalDic.resourceType; if (normalType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + normalDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + normalDic.plistFile); } - imageFileName = this.getResourcePath(normalDic.path(), normalType); + imageFileName = ccs.WidgetReader.getResourcePath(normalDic.path, normalType); slider.loadSlidBallTextureNormal(imageFileName, normalType); //loading slider ball press texture - var pressedDic = options.ballpresseddata(); - var pressedType = pressedDic.resourcetype(); + var pressedDic = options.ballpressedData; + var pressedType = pressedDic.resourceType; if (pressedType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + pressedDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + pressedDic.plistFile); } - var pressedFileName = this.getResourcePath(pressedDic.path(), pressedType); + var pressedFileName = ccs.WidgetReader.getResourcePath(pressedDic.path, pressedType); slider.loadSlidBallTexturePressed(pressedFileName, pressedType); //loading silder ball disable texture - var disabledDic = options.balldisableddata(); - var disabledType = disabledDic.resourcetype(); + var disabledDic = options.balldisabledData; + var disabledType = disabledDic.resourceType; if (disabledType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + disabledDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + disabledDic.plistFile); } - var disabledFileName = this.getResourcePath(disabledDic.path(), disabledType); + var disabledFileName = ccs.WidgetReader.getResourcePath(disabledDic.path, disabledType); slider.loadSlidBallTextureDisabled(disabledFileName, disabledType); //load slider progress texture - var progressBarDic = options.progressbardata(); - var progressBarType = progressBarDic.resourcetype(); + var progressBarDic = options.progressbarData; + var progressBarType = progressBarDic.resourceType; if (progressBarType == 1) { - cc.SpriteFrameCache.addSpriteFramesWithFile(protocolBuffersPath + progressBarDic.plistfile()); + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + progressBarDic.plistFile); } - var progressBarFileName = this.getResourcePath(progressBarDic.path(), progressBarType); + var progressBarFileName = ccs.WidgetReader.getResourcePath(progressBarDic.path, progressBarType); slider.loadProgressBarTexture(progressBarFileName, progressBarType); var displaystate = true; - if(options.has_displaystate()) + if(options.displaystate!==null) { - displaystate = options.displaystate(); + displaystate = options.displaystate; } slider.setBright(displaystate); @@ -357,14 +357,14 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ { case 0: { - slider.loadBarTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + slider.loadBarTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - slider.loadBarTexture(path, ccui.Widget.TextureResType.PLIST); + slider.loadBarTexture(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -403,14 +403,14 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ { case 0: { - slider.loadSlidBallTextureNormal(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + slider.loadSlidBallTextureNormal(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - slider.loadSlidBallTextureNormal(path, ccui.Widget.TextureResType.PLIST); + slider.loadSlidBallTextureNormal(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -449,14 +449,14 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ { case 0: { - slider.loadSlidBallTexturePressed(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + slider.loadSlidBallTexturePressed(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - slider.loadSlidBallTexturePressed(path, ccui.Widget.TextureResType.PLIST); + slider.loadSlidBallTexturePressed(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -495,14 +495,14 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ { case 0: { - slider.loadSlidBallTextureDisabled(xmlPath + path, Widget.TextureResType.LOCAL); + slider.loadSlidBallTextureDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - slider.loadSlidBallTextureDisabled(path, ccui.Widget.TextureResType.PLIST); + slider.loadSlidBallTextureDisabled(path, ccui.Widget.PLIST_TEXTURE); break; } @@ -541,14 +541,14 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ { case 0: { - slider.loadProgressBarTexture(xmlPath + path, ccui.Widget.TextureResType.LOCAL); + slider.loadProgressBarTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); break; } case 1: { - cc.SpriteFrameCache.addSpriteFramesWithFile(xmlPath + plistFile); - slider.loadProgressBarTexture(path, ccui.Widget.TextureResType.PLIST); + cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); + slider.loadProgressBarTexture(path, ccui.Widget.PLIST_TEXTURE); break; } diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index 35e2129867..ed153e8e22 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -97,38 +97,38 @@ ccs.TextFieldReader = /** @lends ccs.TextFieldReader# */{ setPropsFromProtocolBuffers: function(widget, nodeTree){ var textField = widget; - var options = nodeTree.textfieldoptions(); + var options = nodeTree.textfieldOptions; - var protocolBuffersPath = GUIReader.getInstance().getFilePath(); + var protocolBuffersPath = ccs.uiReader.getFilePath(); - var IsCustomSize = options.iscustomsize(); + var IsCustomSize = options.isCustomSize; widget.ignoreContentAdaptWithSize(!IsCustomSize); if (IsCustomSize) { - var widgetOptions = nodeTree.widgetoptions(); - textField.setContentSize(cc.size(widgetOptions.width(), widgetOptions.height())); + var widgetOptions = nodeTree.widgetOptions; + textField.setContentSize(cc.size(widgetOptions.width, widgetOptions.height)); } - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - ccs.WidgetReader.prototype.setAnchorPointForWidget.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setAnchorPointForWidget.call(this, widget, nodeTree); textField.setUnifySizeEnabled(false); - var ph = options.has_placeholder(); - if (ph) + var ph = options.placeholder; + if (ph!==null) { - var placeholder = options.has_placeholder() ? options.placeholder() : "inputs words here"; + var placeholder = options.placeholder!==null ? options.placeholder : "inputs words here"; textField.setPlaceHolder(placeholder); } - var text = options.has_text() ? options.text() : "Text Field"; + var text = options.text!==null ? options.text : "Text Field"; textField.setText(text); - var fontSize = options.has_fontsize() ? options.fontsize() : 20; + var fontSize = options.fontSize ? options.fontSize : 20; textField.setFontSize(fontSize); - var fontName = options.has_fontname() ? options.fontname() : "微软雅黑"; + var fontName = options.fontName!==null ? options.fontName : "微软雅黑"; textField.setFontName(fontName); // var tsw = options.has_touchsizewidth(); @@ -144,30 +144,30 @@ ccs.TextFieldReader = /** @lends ccs.TextFieldReader# */{ // { // //textField.setSize(Size(dw, dh)); // } - var maxLengthEnable = options.maxlengthenable(); + var maxLengthEnable = options.maxlengthEnable; textField.setMaxLengthEnabled(maxLengthEnable); if (maxLengthEnable) { - var maxLength = options.has_maxlength() ? options.maxlength() : 10; + var maxLength = options.maxLength!==null ? options.maxLength : 10; textField.setMaxLength(maxLength); } - var passwordEnable = options.passwordenable(); + var passwordEnable = options.passwordEnable; textField.setPasswordEnabled(passwordEnable); if (passwordEnable) { - var passwordStyleText = options.has_passwordstyletext() ? options.passwordstyletext() : "*"; - textField.setPasswordStyleText(passwordStyleText.c_str()); + var passwordStyleText = options.passwordStyleText!==null ? options.passwordStyleText : "*"; + textField.setPasswordStyleText(passwordStyleText); } - if (options.has_fontresource()) + if (options.fontResource!==null) { - var resourceData = options.fontresource(); + var resourceData = options.fontresource; textField.setFontName(protocolBuffersPath + resourceData.path()); } // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML: function(widget, objectData){ diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 2e54844281..dd75872e06 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -183,73 +183,73 @@ ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - var options = nodeTree.widgetoptions(); + var options = nodeTree.widgetOptions; widget.setCascadeColorEnabled(true); widget.setCascadeOpacityEnabled(true); widget.setUnifySizeEnabled(true); - var ignoreSizeExsit = options.has_ignoresize(); + var ignoreSizeExsit = options.ignoreSize; if (ignoreSizeExsit) { - widget.ignoreContentAdaptWithSize(options.ignoresize()); + widget.ignoreContentAdaptWithSize(options.ignoreSize); } - widget.setSizeType(options.sizetype()); - widget.setPositionType(options.positiontype()); + widget.setSizeType(options.sizeType); + widget.setPositionType(options.positionType); - widget.setSizePercent(cc.p(options.sizepercentx(), options.sizepercenty())); - widget.setPositionPercent(cc.p(options.positionpercentx(), options.positionpercenty())); + widget.setSizePercent(cc.p(options.sizePercentX, options.sizePercentY)); + widget.setPositionPercent(cc.p(options.positionPercentX, options.positionPercentY)); - var w = options.width(); - var h = options.height(); + var w = options.width; + var h = options.height; widget.setContentSize(cc.size(w, h)); - widget.setTag(options.tag()); - widget.setActionTag(options.actiontag()); - widget.setTouchEnabled(options.touchable()); - var name = options.name().c_str(); + widget.setTag(options.tag); + widget.setActionTag(options.actionTag); + widget.setTouchEnabled(options.touchAble); + var name = options.name; var widgetName = name ? name : "default"; widget.setName(widgetName); - var x = options.x(); - var y = options.y(); + var x = options.x; + var y = options.y; widget.setPosition(cc.p(x, y)); - if(options.has_alpha()) + if(options.Alpha) { - widget.setOpacity(options.alpha()); + widget.setOpacity(options.Alpha); } - widget.setScaleX(options.has_scalex() ? options.scalex() : 1.0); + widget.setScaleX(options.scaleX!==null ? options.scaleX : 1); - widget.setScaleY(options.has_scaley() ? options.scaley() : 1.0); + widget.setScaleY(options.scaleY!==null ? options.scaleY : 1); -// widget.setRotation(options.has_rotation() ? options.rotation() : 0.0); +// widget.setRotation(options.has_rotation ? options.rotation : 0.0); - widget.setRotationSkewX(options.has_rotationskewx() ? options.rotationskewx() : 0.0); + widget.setRotationX(options.rotationSkewX!==null ? options.rotationSkewX : 0.0); - widget.setRotationSkewY(options.has_rotationskewy() ? options.rotationskewy() : 0.0); + widget.setRotationY(options.rotationSkewY!==null ? options.rotationSkewY : 0.0); - var vb = options.has_visible(); + var vb = options.visible; if (vb) { - widget.setVisible(options.visible()); + widget.setVisible(options.visible); } - var z = options.zorder(); + var z = options.zorder; widget.setLocalZOrder(z); - var layout = options.has_layoutparameter(); + var layout = options.layoutParameter; if (layout) { - var layoutParameterDic = options.layoutparameter();; - var paramType = layoutParameterDic.type(); + var layoutParameterDic = options.layoutParameter; + var paramType = layoutParameterDic.type; var parameter = null; switch (paramType) @@ -258,20 +258,20 @@ ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ break; case 1: { - parameter = LinearLayoutParameter.create(); - var gravity = layoutParameterDic.gravity(); + parameter = ccui.LinearLayoutParameter.create(); + var gravity = layoutParameterDic.gravity; parameter.setGravity(gravity); break; } case 2: { - parameter = RelativeLayoutParameter.create(); + parameter = ccui.RelativeLayoutParameter.create(); var rParameter = parameter; - var relativeName = layoutParameterDic.relativename().c_str(); + var relativeName = layoutParameterDic.relativeName; rParameter.setRelativeName(relativeName); - var relativeToName = layoutParameterDic.relativetoname().c_str(); + var relativeToName = layoutParameterDic.relativeToName; rParameter.setRelativeToWidgetName(relativeToName); - var align = layoutParameterDic.align(); + var align = layoutParameterDic.align; rParameter.setAlign(align); break; } @@ -280,37 +280,37 @@ ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ } if (parameter) { - var mgl = layoutParameterDic.marginleft(); - var mgt = layoutParameterDic.margintop(); - var mgr = layoutParameterDic.marginright(); - var mgb = layoutParameterDic.margindown(); - parameter.setMargin(Margin(mgl, mgt, mgr, mgb)); + var mgl = layoutParameterDic.marginLeft; + var mgt = layoutParameterDic.marginTop; + var mgr = layoutParameterDic.marginRight; + var mgb = layoutParameterDic.marginDown; + parameter.setMargin(new ccui.Margin(mgl, mgt, mgr, mgb)); widget.setLayoutParameter(parameter); } } }, setColorPropsFromProtocolBuffers: function(widget, nodeTree){ - var options = nodeTree.widgetoptions(); + var options = nodeTree.widgetOptions; - var isColorRExists = options.has_colorr(); - var isColorGExists = options.has_colorg(); - var isColorBExists = options.has_colorb(); + var isColorRExists = options.colorR!==null; + var isColorGExists = options.colorG!==null; + var isColorBExists = options.colorB!==null; - var colorR = options.colorr(); - var colorG = options.colorg(); - var colorB = options.colorb(); + var colorR = options.colorR; + var colorG = options.colorG; + var colorB = options.colorB; if (isColorRExists && isColorGExists && isColorBExists) { widget.setColor(cc.color(colorR, colorG, colorB)); } - this.setAnchorPointForWidget(widget, nodeTree); + ccs.WidgetReader.setAnchorPointForWidget(widget, nodeTree); - var flipX = options.flipx(); - var flipY = options.flipy(); + var flipX = options.flipX; + var flipY = options.flipY; widget.setFlippedX(flipX); widget.setFlippedY(flipY); }, @@ -530,24 +530,24 @@ ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ }, setAnchorPointForWidget: function(widget, nodeTree){ - var options = nodeTree.widgetoptions(); + var options = nodeTree.widgetOptions; - var isAnchorPointXExists = options.has_anchorpointx(); + var isAnchorPointXExists = options.anchorPointX; var anchorPointXInFile; if (isAnchorPointXExists) { - anchorPointXInFile = options.anchorpointx(); + anchorPointXInFile = options.anchorPointX; } else { anchorPointXInFile = widget.getAnchorPoint().x; } - var isAnchorPointYExists = options.has_anchorpointy(); + var isAnchorPointYExists = options.anchorPointY; var anchorPointYInFile; if (isAnchorPointYExists) { - anchorPointYInFile = options.anchorpointy(); + anchorPointYInFile = options.anchorPointY; } else { @@ -566,10 +566,10 @@ ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ var imageFileName_tp; if (null != imageFileName && 0 != "" != imageFileName) { - if (texType == ccui.Widget.TextureResType.LOCAL) { + if (texType == ccui.Widget.LOCAL_TEXTURE) { imageFileName_tp = filePath + imageFileName; } - else if(texType == ccui.Widget.TextureResType.PLIST){ + else if(texType == ccui.Widget.PLIST_TEXTURE){ imageFileName_tp = imageFileName; } else{ diff --git a/moduleConfig.json b/moduleConfig.json index 3f1d63e808..a282f82838 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -298,6 +298,7 @@ "extensions/cocostudio/components/CCComponent.js", "extensions/cocostudio/components/CCComponentContainer.js", + "extensions/ccui/layouts/UILayoutComponent.js", "extensions/cocostudio/CocoStudio.js", "extensions/cocostudio/armature/utils/CCArmatureDefine.js", From 565123fc79900e8045af54a098eb4804d49e905e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 16 Oct 2014 16:37:41 +0800 Subject: [PATCH 0801/1564] Issue #5983: The analysis of parameters --- .../reader/widgetreader/CheckBoxReader/CheckBoxReader.js | 2 +- .../widgetreader/ImageViewReader/ImageViewReader.js | 4 ++-- .../widgetreader/LabelAtlasReader/LabelAtlasReader.js | 8 ++++---- .../widgetreader/LabelBMFontReader/LabelBMFontReader.js | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index 343814faae..11c227d893 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -96,7 +96,7 @@ ccs.CheckBoxReader = /** @lends ccs.CheckBoxReader# */{ ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var checkBox = widget; - var options = nodeTree.checkboxOptions; + var options = nodeTree.checkBoxOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 298277b945..6f71991b71 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -102,7 +102,7 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ setPropsFromProtocolBuffers: function(widget, nodeTree){ ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - var options = nodeTree.imageviewOptions; + var options = nodeTree.imageViewOptions; var imageView = widget; var protocolBuffersPath = ccs.uiReader.getFilePath(); @@ -113,7 +113,7 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ { cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } - var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path(), imageFileNameType); + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); imageView.loadTexture(imageFileName, imageFileNameType); diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 8f3c3e7cbc..4de9803497 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -81,14 +81,14 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ var jsonPath = ccs.uiReader.getFilePath(); var labelAtlas = widget; - var options = nodeTree.textatlasOptions; + var options = nodeTree.textAtlasOptions; // var sv = DICTOOL.checkObjectExist_json(options, P_StringValue); // var cmf = DICTOOL.checkObjectExist_json(options, P_CharMapFile); // var iw = DICTOOL.checkObjectExist_json(options, P_ItemWidth); // var ih = DICTOOL.checkObjectExist_json(options, P_ItemHeight); // var scm = DICTOOL.checkObjectExist_json(options, P_StartCharMap); - var cmftDic = options.charmapFileData; + var cmftDic = options.charMapFileData; var cmfType = cmftDic.resourceType; switch (cmfType) { @@ -96,7 +96,7 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ { var tp_c = jsonPath; var cmfPath = cmftDic.path; - var cmf_tp = tp_c.append(cmfPath); + var cmf_tp = tp_c += cmfPath; var stringValue = options.stringValue!==null ? options.stringValue : "12345678"; var itemWidth = options.itemWidth!==null ? options.itemWidth : 24; var itemHeight = options.has_itemheight ? options.itemHeight : 32; @@ -104,7 +104,7 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ cmf_tp, itemWidth, itemHeight, - options.startCharmap); + options.startCharMap); break; } case 1: diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index 4bb7a5dcae..017558e7e0 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -72,7 +72,7 @@ ccs.LabelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var jsonPath = ccs.uiReader.getFilePath(); @@ -88,8 +88,8 @@ ccs.LabelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ case 0: { var tp_c = jsonPath; - var cmfPath = cmftDic.path(); - var cmf_tp = tp_c.append(cmfPath); + var cmfPath = cmftDic.path; + var cmf_tp = tp_c + cmfPath; labelBMFont.setFntFile(cmf_tp); break; } @@ -106,7 +106,7 @@ ccs.LabelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML: function(widget, nodeTree){ From 044031541cbfa9cebff01c24ef100b031b77c9e8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 16 Oct 2014 19:53:27 +0800 Subject: [PATCH 0802/1564] Issue #5968: fixed a bug of cc.Layer that its bake function doesn't work --- cocos2d/core/base-nodes/CCNode.js | 3 +- cocos2d/core/layers/CCLayer.js | 128 +++++++++++++++++------------- 2 files changed, 77 insertions(+), 54 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 98c73805fc..9bd15bf072 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -162,7 +162,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ userObject: null, _transformDirty: true, _inverseDirty: true, - _cacheDirty: true, + _cacheDirty: false, // Cached parent serves to construct the cached parent chain _cachedParent: null, _transformGLDirty: null, @@ -2665,6 +2665,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(this._rendererCmd) cc.renderer.pushRenderCommand(this._rendererCmd); } + this._cacheDirty = false; }; _p._transformForRenderer = function () { diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index d6c30e42c7..746d24e575 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -32,6 +32,7 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ _isBaked: false, _bakeSprite: null, + _bakeRenderCmd: null, _className: "Layer", /** @@ -74,6 +75,8 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ */ unbake: null, + _bakeRendering: null, + /** * Determines if the layer is baked. * @function @@ -101,21 +104,27 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var p = cc.Layer.prototype; p.bake = function(){ if (!this._isBaked) { + cc.renderer.childrenOrderDirty = true; //limit: 1. its children's blendfunc are invalid. this._isBaked = this._cacheDirty = true; + if(!this._bakeRenderCmd && this._bakeRendering) + this._bakeRenderCmd = new cc.CustomRenderCmdCanvas(this, this._bakeRendering); this._cachedParent = this; var children = this._children; for(var i = 0, len = children.length; i < len; i++) children[i]._setCachedParent(this); - if (!this._bakeSprite) + if (!this._bakeSprite){ this._bakeSprite = new cc.BakeSprite(); + this._bakeSprite._parent = this; + } } }; p.unbake = function(){ if (this._isBaked) { + cc.renderer.childrenOrderDirty = true; this._isBaked = false; this._cacheDirty = true; @@ -132,26 +141,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { child._setCachedParent(this); }; - p.visit = function(ctx){ - if(!this._isBaked){ - cc.Node.prototype.visit.call(this, ctx); - return; - } - - var context = ctx || cc._renderContext, i; - var _t = this; - var children = _t._children; - var len = children.length; - // quick return if not visible - if (!_t._visible || len === 0) - return; - - var locBakeSprite = this._bakeSprite; - - context.save(); - _t.transform(context); - + p._bakeRendering = function(){ if(this._cacheDirty){ + var _t = this; + var children = _t._children, locBakeSprite = this._bakeSprite; //compute the bounding box of the bake layer. var boundingBox = this._getBoundingBoxForBake(); boundingBox.width = 0 | boundingBox.width; @@ -160,24 +153,47 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); + // invert + var t = cc.affineTransformInvert(this._transformWorld); + var scaleX = cc.view.getScaleX(), scaleY = cc.view.getScaleY(); + bakeContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + //reset the bake sprite's position var anchor = locBakeSprite.getAnchorPointInPoints(); locBakeSprite.setPosition(anchor.x + boundingBox.x, anchor.y + boundingBox.y); //visit for canvas _t.sortAllChildren(); - cc.view._setScaleXYForRenderTexture(); - for (i = 0; i < len; i++) { + cc.renderer._isCacheToCanvasOn = true; + for (var i = 0, len = children.length; i < len; i++) { children[i].visit(bakeContext); } - cc.view._resetScale(); + cc.renderer._renderingToCacheCanvas(bakeContext); this._cacheDirty = false; } + }; - //the bakeSprite is drawing - locBakeSprite.visit(context); + p.visit = function(ctx){ + if(!this._isBaked){ + cc.Node.prototype.visit.call(this, ctx); + return; + } + + var context = ctx || cc._renderContext; + var _t = this; + var children = _t._children; + var len = children.length; + // quick return if not visible + if (!_t._visible || len === 0) + return; - context.restore(); + _t.transform(context); + + if(_t._bakeRenderCmd) + cc.renderer.pushRenderCommand(_t._bakeRenderCmd); + + //the bakeSprite is drawing + this._bakeSprite.visit(context); }; p._getBoundingBoxForBake = function () { @@ -426,27 +442,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.g_NumberOfDraws++; }; - //for bake - _p.visit = function(ctx){ - if(!this._isBaked){ - cc.Node.prototype.visit.call(this, ctx); - return; - } - - var context = ctx || cc._renderContext, i; - var _t = this; - var children = _t._children; - var len = children.length; - // quick return if not visible - if (!_t._visible) - return; - - var locBakeSprite = this._bakeSprite; - - context.save(); - _t.transform(context); - + _p._bakeRendering = function(){ if(this._cacheDirty){ + var _t = this; + var locBakeSprite = _t._bakeSprite, children = this._children; + var len = children.length, i; + //compute the bounding box of the bake layer. var boundingBox = this._getBoundingBoxForBake(); boundingBox.width = 0 | boundingBox.width; @@ -464,9 +465,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); } + // invert + var t = cc.affineTransformInvert(this._transformWorld); + var scaleX = cc.view.getScaleX(), scaleY = cc.view.getScaleY(); + bakeContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); var child; - cc.view._setScaleXYForRenderTexture(); + cc.renderer._isCacheToCanvasOn = true; //visit for canvas if (len > 0) { _t.sortAllChildren(); @@ -484,16 +489,33 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { children[i].visit(bakeContext); } } else - if(_t._rendererCmd) - cc.renderer.pushRenderCommand(_t._rendererCmd); - cc.view._resetScale(); + if(_t._rendererCmd) + cc.renderer.pushRenderCommand(_t._rendererCmd); + cc.renderer._renderingToCacheCanvas(bakeContext); this._cacheDirty = false; } + }; - //the bakeSprite is drawing - locBakeSprite.visit(context); + //for bake + _p.visit = function(ctx){ + if(!this._isBaked){ + cc.Node.prototype.visit.call(this, ctx); + return; + } - context.restore(); + var context = ctx || cc._renderContext; + var _t = this; + // quick return if not visible + if (!_t._visible) + return; + + _t.transform(context); + + if(_t._bakeRenderCmd) + cc.renderer.pushRenderCommand(_t._bakeRenderCmd); + + //the bakeSprite is drawing + this._bakeSprite.visit(context); }; _p._getBoundingBoxForBake = function () { From e0047f284b1ba65d1f77ef7fcff75f3958ff182f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 16 Oct 2014 20:01:40 +0800 Subject: [PATCH 0803/1564] Issue #5983: The analysis of parameters --- extensions/ccui/uiwidgets/UILoadingBar.js | 4 +-- extensions/ccui/uiwidgets/UISlider.js | 12 +++------ .../ImageViewReader/ImageViewReader.js | 4 +-- .../LabelAtlasReader/LabelAtlasReader.js | 2 +- .../LabelBMFontReader/LabelBMFontReader.js | 2 +- .../widgetreader/LabelReader/LabelReader.js | 2 +- .../widgetreader/LayoutReader/LayoutReader.js | 2 +- .../LoadingBarReader/LoadingBarReader.js | 4 +-- .../PageViewReader/PageViewReader.js | 25 +++++++++++-------- .../ScrollViewReader/ScrollViewReader.js | 23 +++++++++-------- .../widgetreader/SliderReader/SliderReader.js | 18 ++++++------- .../TextFieldReader/TextFieldReader.js | 2 +- .../reader/widgetreader/WidgetReader.js | 2 +- 13 files changed, 49 insertions(+), 53 deletions(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 6868b65ed9..01997d1d3e 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -134,12 +134,12 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ case ccui.LoadingBar.TYPE_LEFT: barRenderer.setAnchorPoint(0.0,0.5); if (!self._scale9Enabled) - barRenderer.getSprite().setFlippedX(false); + barRenderer/*.getSprite()*/.setFlippedX(false); break; case ccui.LoadingBar.TYPE_RIGHT: barRenderer.setAnchorPoint(1.0,0.5); if (!self._scale9Enabled) - barRenderer.getSprite().setFlippedX(true); + barRenderer/*.getSprite()*/.setFlippedX(true); break; } self._updateChildrenDisplayedRGBA(); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 2080735dcc..270f33628c 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -147,7 +147,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRendererAdaptDirty = true; this._progressBarRendererDirty = true; - this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); + this._updateContentSizeWithTextureSize(this.getContentSize()); }, /** @@ -579,10 +579,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _barRendererScaleChangedWithSize: function () { - if(this._unifySize){ - this._barLength = this._contentSize.width; - this._barRenderer.setPreferredSize(this._contentSize); - }else if (this._ignoreSize) { + if (this._ignoreSize) { this._barRenderer.setScale(1.0); this._barLength = this._contentSize.width; } @@ -608,10 +605,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _progressBarRendererScaleChangedWithSize: function () { - if(this._unifySize){ - this._barLength = this._contentSize.width; - this._barRenderer.setPreferredSize(this._contentSize); - }else if (this._ignoreSize) { + if (this._ignoreSize) { if (!this._scale9Enabled) { var ptextureSize = this._progressBarTextureSize; var pscaleX = this._contentSize.width / ptextureSize.width; diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 6f71991b71..de77968d75 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -117,11 +117,11 @@ ccs.ImageViewReader = /** @lends ccs.ImageViewReader# */{ imageView.loadTexture(imageFileName, imageFileNameType); - var scale9EnableExist = options.scale9enAble!==null; + var scale9EnableExist = options.scale9Enable!==null; var scale9Enable = false; if (scale9EnableExist) { - scale9Enable = options.scale9enAble; + scale9Enable = options.scale9Enable; } imageView.setScale9Enabled(scale9Enable); diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 4de9803497..8930bed5b9 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -159,7 +159,7 @@ ccs.LabelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ } else if (name == "Alpha") { - opacity = atoi(value.c_str()); + opacity = atoi(value); } attribute = attribute.Next(); diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index 017558e7e0..ec091e86e2 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -133,7 +133,7 @@ ccs.LabelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ } else if (name == "Alpha") { - opacity = atoi(value.c_str()); + opacity = atoi(value); } attribute = attribute.Next(); diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index d48625b795..c8c4aab4b9 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -220,7 +220,7 @@ ccs.LabelReader = /** @lends ccs.LabelReader# */{ } else if (name == "Alpha") { - opacity = atoi(value.c_str()); + opacity = atoi(value); } attribute = attribute.Next(); diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index f2409d8679..3ad01e7bcd 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -280,7 +280,7 @@ ccs.LayoutReader = /** @lends ccs.LayoutReader# */{ var blue = widgetOptions.colorB!==null ? widgetOptions.colorB : 255; panel.setColor(cc.color(red, green, blue)); - var opacity = widgetOptions.Alpha!==null ? widgetOptions.alpha : 255; + var opacity = widgetOptions.Alpha!==null ? widgetOptions.Alpha : 255; panel.setOpacity(opacity); // var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index 7ce65c1d58..1daed05590 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -97,7 +97,7 @@ ccs.LoadingBarReader = /** @lends ccs.LoadingBarReader# */{ ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var loadingBar = widget; - var options = nodeTree.loadingbarOptions; + var options = nodeTree.loadingBarOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); @@ -139,7 +139,7 @@ ccs.LoadingBarReader = /** @lends ccs.LoadingBarReader# */{ // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML: function(){ diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index b0e987c17e..a9263dd81a 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -48,11 +48,11 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var pageView = widget; - var options = nodeTree.pageviewOptions; + var options = nodeTree.pageViewOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); @@ -108,13 +108,16 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ var imageFileNameDic = options.backGroundImageData; - var imageFileNameType = imageFileNameDic.resourceType; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); - } - var imageFileName = this.getResourcePath(imageFileNameDic.path(), imageFileNameType); - pageView.setBackGroundImage(imageFileName, imageFileNameType); + if(imageFileNameDic){ + + var imageFileNameType = imageFileNameDic.resourceType; + if (imageFileNameType == 1) + { + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); + } + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); + pageView.setBackGroundImage(imageFileName, imageFileNameType); + } if (backGroundScale9Enable) @@ -132,7 +135,7 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ } } - var widgetOptions = nodeTree.widgetoptions(); + var widgetOptions = nodeTree.widgetOptions; var red = widgetOptions.colorR!==null ? widgetOptions.colorR : 255; var green = widgetOptions.colorG!==null ? widgetOptions.colorG : 255; @@ -161,7 +164,7 @@ ccs.PageViewReader = /** @lends ccs.PageViewReader# */{ }, setPropsFromXML: function(widget, objectData){ - ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + ccs.WidgetReader.setPropsFromXML.call(this, widget, objectData); var pageView = widget; diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index bfb966c194..13aac42a38 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -59,11 +59,11 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.WidgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var scrollView = widget; - var options = nodeTree.scrollviewOptions; + var options = nodeTree.scrollViewOptions; var protocolBuffersPath = ccs.uiReader.getFilePath(); @@ -120,14 +120,15 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ var imageFileNameDic = options.backGroundImageData; - var imageFileNameType = imageFileNameDic.resourceType; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); - } - var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); - scrollView.setBackGroundImage(imageFileName, imageFileNameType); - + if(imageFileNameDic){ + var imageFileNameType = imageFileNameDic.resourceType; + if (imageFileNameType == 1) + { + cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); + } + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); + scrollView.setBackGroundImage(imageFileName, imageFileNameType); + } if (backGroundScale9Enable) { @@ -185,7 +186,7 @@ ccs.ScrollViewReader = /** @lends ccs.ScrollViewReader# */{ }, setPropsFromXML: function(widget, objectData){ - ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + ccs.WidgetReader.setPropsFromXML.call(this, widget, objectData); var scrollView = widget; diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index 1c3fc5b7dc..6da498c1b5 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -174,7 +174,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ var protocolBuffersPath = ccs.uiReader.getFilePath(); - var barTextureScale9Enable = options.scale9Enable; + var barTextureScale9Enable = !!options.scale9Enable; slider.setScale9Enabled(barTextureScale9Enable); slider.setPercent(options.percent); @@ -189,18 +189,16 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ { cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic.plistFile); } - var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path(), imageFileNameType); + var imageFileName = ccs.WidgetReader.getResourcePath(imageFileNameDic.path, imageFileNameType); slider.loadBarTexture(imageFileName, imageFileNameType); - - if (barTextureScale9Enable) { slider.setContentSize(cc.size(barLength, slider.getContentSize().height)); } //loading normal slider ball texture - var normalDic = options.ballnormalData; + var normalDic = options.ballNormalData; var normalType = normalDic.resourceType; if (normalType == 1) { @@ -211,7 +209,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ //loading slider ball press texture - var pressedDic = options.ballpressedData; + var pressedDic = options.ballPressedData; var pressedType = pressedDic.resourceType; if (pressedType == 1) { @@ -221,7 +219,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadSlidBallTexturePressed(pressedFileName, pressedType); //loading silder ball disable texture - var disabledDic = options.balldisabledData; + var disabledDic = options.ballDisabledData; var disabledType = disabledDic.resourceType; if (disabledType == 1) { @@ -231,7 +229,7 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.loadSlidBallTextureDisabled(disabledFileName, disabledType); //load slider progress texture - var progressBarDic = options.progressbarData; + var progressBarDic = options.progressBarData; var progressBarType = progressBarDic.resourceType; if (progressBarType == 1) { @@ -248,11 +246,11 @@ ccs.SliderReader = /** @lends ccs.SliderReader# */{ slider.setBright(displaystate); // other commonly protperties - ccs.WidgetReader.prototype.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.WidgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, setPropsFromXML:function(widget, objectData){ - ccs.WidgetReader.prototype.setPropsFromXML.call(this, widget, objectData); + ccs.WidgetReader.setPropsFromXML.call(this, widget, objectData); var slider = widget; diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index ed153e8e22..099ade2331 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -241,7 +241,7 @@ ccs.TextFieldReader = /** @lends ccs.TextFieldReader# */{ } else if (name == "Alpha") { - opacity = atoi(value.c_str()); + opacity = atoi(value); } attribute = attribute.Next(); diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index dd75872e06..cf2e3bf97a 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -368,7 +368,7 @@ ccs.WidgetReader = /** @lends ccs.WidgetReader# */{ } else if (name == "Alpha") { - widget.setOpacity(atoi(value.c_str())); + widget.setOpacity(atoi(value)); } else if (name == "Tag") { From 763898bf6d75727e61b6bb66e1b3d4ac8d3a8b91 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 16 Oct 2014 20:30:57 +0800 Subject: [PATCH 0804/1564] Issue #5983: Slider width error (scale9Sprite) --- extensions/ccui/uiwidgets/UISlider.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 270f33628c..833a78897b 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -147,7 +147,14 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRendererAdaptDirty = true; this._progressBarRendererDirty = true; - this._updateContentSizeWithTextureSize(this.getContentSize()); + this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); + }, + + setContentSize: function(a, b){ + ccui.Widget.prototype.setContentSize.call(this,a , b); + if(this._scale9Enabled){ + this._barRenderer.setContentSize(a, b); + } }, /** From 85f02c6780444f91f85ca93e1703cd5447581cdd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 16 Oct 2014 21:22:18 +0800 Subject: [PATCH 0805/1564] Issue #5983: Modification of a single example naming --- extensions/cocostudio/reader/GUIReader.js | 28 +- .../reader/timeline/ActionTimelineCache.js | 92 +-- .../cocostudio/reader/timeline/NodeReader.js | 771 +++++++++--------- .../widgetreader/ButtonReader/ButtonReader.js | 22 +- .../CheckBoxReader/CheckBoxReader.js | 34 +- .../ImageViewReader/ImageViewReader.js | 16 +- .../LabelAtlasReader/LabelAtlasReader.js | 14 +- .../LabelBMFontReader/LabelBMFontReader.js | 14 +- .../widgetreader/LabelReader/LabelReader.js | 14 +- .../widgetreader/LayoutReader/LayoutReader.js | 16 +- .../ListViewReader/ListViewReader.js | 14 +- .../LoadingBarReader/LoadingBarReader.js | 16 +- .../PageViewReader/PageViewReader.js | 14 +- .../ScrollViewReader/ScrollViewReader.js | 16 +- .../widgetreader/SliderReader/SliderReader.js | 24 +- .../TextFieldReader/TextFieldReader.js | 16 +- .../reader/widgetreader/WidgetReader.js | 10 +- 17 files changed, 564 insertions(+), 567 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index e30da833c2..f03c509b23 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -32,20 +32,20 @@ if(CSParseBinary && dcodeIO && dcodeIO.ProtoBuf){ (function(){ var factoryCreate = ccs.objectFactory; - factoryCreate.registerType({_className:"ButtonReader", _fun: ccs.ButtonReader}); - factoryCreate.registerType({_className: "CheckBoxReader", _fun: ccs.CheckBoxReader}); - factoryCreate.registerType({_className: "SliderReader", _fun: ccs.SliderReader}); - factoryCreate.registerType({_className: "ImageViewReader", _fun: ccs.ImageViewReader}); - factoryCreate.registerType({_className: "LoadingBarReader", _fun: ccs.LoadingBarReader}); - factoryCreate.registerType({_className: "TextAtlasReader", _fun: ccs.LabelAtlasReader}); - factoryCreate.registerType({_className: "TextReader", _fun: ccs.LabelReader}); - factoryCreate.registerType({_className: "TextBMFontReader", _fun: ccs.LabelBMFontReader}); - factoryCreate.registerType({_className: "TextFieldReader", _fun: ccs.TextFieldReader}); - factoryCreate.registerType({_className: "LayoutReader", _fun: ccs.LayoutReader}); - factoryCreate.registerType({_className: "PageViewReader", _fun: ccs.PageViewReader}); - factoryCreate.registerType({_className: "ScrollViewReader", _fun: ccs.ScrollViewReader}); - factoryCreate.registerType({_className: "ListViewReader", _fun: ccs.ListViewReader}); - factoryCreate.registerType({_className: "WidgetReader", _fun: ccs.WidgetReader}); + factoryCreate.registerType({_className:"ButtonReader", _fun: ccs.buttonReader}); + factoryCreate.registerType({_className: "CheckBoxReader", _fun: ccs.checkBoxReader}); + factoryCreate.registerType({_className: "SliderReader", _fun: ccs.sliderReader}); + factoryCreate.registerType({_className: "ImageViewReader", _fun: ccs.imageViewReader}); + factoryCreate.registerType({_className: "LoadingBarReader", _fun: ccs.loadingBarReader}); + factoryCreate.registerType({_className: "TextAtlasReader", _fun: ccs.labelAtlasReader}); + factoryCreate.registerType({_className: "TextReader", _fun: ccs.labelReader}); + factoryCreate.registerType({_className: "TextBMFontReader", _fun: ccs.labelBMFontReader}); + factoryCreate.registerType({_className: "TextFieldReader", _fun: ccs.textFieldReader}); + factoryCreate.registerType({_className: "LayoutReader", _fun: ccs.layoutReader}); + factoryCreate.registerType({_className: "PageViewReader", _fun: ccs.pageViewReader}); + factoryCreate.registerType({_className: "ScrollViewReader", _fun: ccs.scrollViewReader}); + factoryCreate.registerType({_className: "ListViewReader", _fun: ccs.listViewReader}); + factoryCreate.registerType({_className: "WidgetReader", _fun: ccs.widgetReader}); factoryCreate.registerType({_className: "Button", _fun: ccui.Button}); factoryCreate.registerType({_className: "CheckBox", _fun: ccui.CheckBox}); diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index aeb3900b11..79d9165869 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -var ActionTimelineCacheStatic = { +var actionTimelineCacheStatic = { FrameType_VisibleFrame : "VisibleFrame", FrameType_PositionFrame : "PositionFrame", FrameType_ScaleFrame : "ScaleFrame", @@ -63,7 +63,7 @@ var ActionTimelineCacheStatic = { * @name ccs.ActionTimelineCache * @namespace */ -ccs.ActionTimelineCache = { +ccs.actionTimelineCache = { _FrameCreateFunc: null, _Pair: null, @@ -113,7 +113,7 @@ ccs.ActionTimelineCache = { var suffix = path.substr(pos + 1, path.length); cc.log("suffix = %s", suffix); - var cache = ccs.ActionTimelineCache; + var cache = ccs.actionTimelineCache; if (suffix == "csb"){ return cache.createActionFromProtocolBuffers(filename); }else if (suffix == "json" || suffix == "ExportJson"){ @@ -161,17 +161,17 @@ ccs.ActionTimelineCache = { if(action) return action; - var json = content[ActionTimelineCacheStatic.ACTION]; + var json = content[actionTimelineCacheStatic.ACTION]; action = new ccs.ActionTimeline(); - action.setDuration(json[ActionTimelineCacheStatic.DURATION]); - action.setTimeSpeed(json[ActionTimelineCacheStatic.TIME_SPEED] || 1); + action.setDuration(json[actionTimelineCacheStatic.DURATION]); + action.setTimeSpeed(json[actionTimelineCacheStatic.TIME_SPEED] || 1); - var timelineLength = json[ActionTimelineCacheStatic.TIMELINES].length; + var timelineLength = json[actionTimelineCacheStatic.TIMELINES].length; for (var i = 0; igetStringFromFile(fileName); - var json = cc.loader.getRes(fileName); + return this.loadNodeWithFile(filename); + }, - var node = this.loadNodeWithContent(json); + /** + * load file + * @param {string} fileName + * @returns {cc.Node} + */ + loadNodeWithFile: function(fileName){ + // Read content from file + //std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName); + var json = cc.loader.getRes(fileName); - // Load animation data from file - studio.ActionTimelineCache.loadAnimationActionWithContent(fileName, json); + var node = this.loadNodeWithContent(json); - return node; + // Load animation data from file + ccs.actionTimelineCache.loadAnimationActionWithContent(fileName, json); - }, + return node; - /** - * load node with data. - * @param {Object} json - * @returns {cc.Node} - */ - loadNodeWithContent: function(json){ - // decode plist - var length = json[timeline.TEXTURES].length; + }, - for(var i=0; i Date: Thu, 16 Oct 2014 21:40:52 +0800 Subject: [PATCH 0806/1564] Issue #5983: remove create function --- .../cocostudio/components/CCComAttribute.js | 6 +- .../cocostudio/components/CCComAudio.js | 6 +- .../cocostudio/components/CCComController.js | 6 +- .../cocostudio/components/CCComRender.js | 6 +- extensions/cocostudio/reader/GUIReader.js | 24 +- extensions/cocostudio/reader/SceneReader.js | 30 +- .../reader/timeline/ActionTimeline.js | 772 +++++++++--------- .../reader/timeline/ActionTimelineCache.js | 2 +- .../cocostudio/reader/timeline/CSLoader.js | 46 +- .../reader/widgetreader/WidgetReader.js | 16 +- 10 files changed, 451 insertions(+), 463 deletions(-) diff --git a/extensions/cocostudio/components/CCComAttribute.js b/extensions/cocostudio/components/CCComAttribute.js index 3fd8f13a67..0575b9334d 100644 --- a/extensions/cocostudio/components/CCComAttribute.js +++ b/extensions/cocostudio/components/CCComAttribute.js @@ -40,6 +40,7 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ this._jsonDict = {}; this._filePath = ""; this._name = "CCComAttribute"; + ccs.ComAttribute.prototype.init.call(this); }, /** @@ -205,8 +206,5 @@ ccs.ComAttribute = ccs.Component.extend(/** @lends ccs.ComAttribute# */{ * var com = ccs.ComAttribute.create(); */ ccs.ComAttribute.create = function () { - var com = new ccs.ComAttribute(); - if (com && com.init()) - return com; - return null; + return new ccs.ComAttribute(); }; \ No newline at end of file diff --git a/extensions/cocostudio/components/CCComAudio.js b/extensions/cocostudio/components/CCComAudio.js index 6b99f6ae95..0b15af0b9a 100644 --- a/extensions/cocostudio/components/CCComAudio.js +++ b/extensions/cocostudio/components/CCComAudio.js @@ -38,6 +38,7 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ ctor: function () { cc.Component.prototype.ctor.call(this); this._name = "Audio"; + ccs.ComAudio.prototype.init.call(this); }, /** @@ -280,8 +281,5 @@ ccs.ComAudio = ccs.Component.extend(/** @lends ccs.ComAudio# */{ * var com = ccs.ComAudio.create(); */ ccs.ComAudio.create = function () { - var com = new ccs.ComAudio(); - if (com && com.init()) - return com; - return null; + return new ccs.ComAudio(); }; \ No newline at end of file diff --git a/extensions/cocostudio/components/CCComController.js b/extensions/cocostudio/components/CCComController.js index 77ff94f6a2..e9bb63d719 100644 --- a/extensions/cocostudio/components/CCComController.js +++ b/extensions/cocostudio/components/CCComController.js @@ -35,6 +35,7 @@ ccs.ComController = ccs.Component.extend(/** @lends ccs.ComController# */{ ctor: function () { cc.Component.prototype.ctor.call(this); this._name = "ComController"; + ccs.ComController.prototype.init.call(this); }, /** @@ -71,8 +72,5 @@ ccs.ComController = ccs.Component.extend(/** @lends ccs.ComController# */{ * var com = ccs.ComController.create(); */ ccs.ComController.create = function () { - var com = new ccs.ComController(); - if (com && com.init()) - return com; - return null; + return new ccs.ComController(); }; \ No newline at end of file diff --git a/extensions/cocostudio/components/CCComRender.js b/extensions/cocostudio/components/CCComRender.js index 29a292c4c8..960e096a11 100644 --- a/extensions/cocostudio/components/CCComRender.js +++ b/extensions/cocostudio/components/CCComRender.js @@ -40,6 +40,7 @@ ccs.ComRender = ccs.Component.extend(/** @lends ccs.ComRender# */{ this._render = node; this._name = comName; this.isRenderer = true; + ccs.ComRender.prototype.init.call(this); }, /** @@ -86,8 +87,5 @@ ccs.ComRender = ccs.Component.extend(/** @lends ccs.ComRender# */{ * var com = ccs.ComRender.create(); */ ccs.ComRender.create = function (node, comName) { - var com = new ccs.ComRender(node, comName); - if (com && com.init()) - return com; - return null; + return new ccs.ComRender(node, comName); }; diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index f03c509b23..f8318ee986 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -404,40 +404,40 @@ ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend(/** @lends cc widget = ccui.CheckBox.create(); this.setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); } else if (classname == "Label") { - widget = ccui.Text.create(); + widget = new ccui.Text(); this.setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname == "LabelAtlas") { - widget = ccui.TextAtlas.create(); + widget = new ccui.TextAtlas(); this.setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); } else if (classname == "LoadingBar") { - widget = ccui.LoadingBar.create(); + widget = new ccui.LoadingBar(); this.setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); } else if (classname == "ScrollView") { - widget = ccui.ScrollView.create(); + widget = new ccui.ScrollView(); this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } else if (classname == "TextArea") { - widget = ccui.Text.create(); + widget = new ccui.Text(); this.setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname == "TextButton") { - widget = ccui.Button.create(); + widget = new ccui.Button(); this.setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname == "TextField") { - widget = ccui.TextField.create(); + widget = new ccui.TextField(); this.setPropsForTextFieldFromJsonDictionary(widget, uiOptions); } else if (classname == "ImageView") { - widget = ccui.ImageView.create(); + widget = new ccui.ImageView(); this.setPropsForImageViewFromJsonDictionary(widget, uiOptions); } else if (classname == "Panel") { - widget = ccui.Layout.create(); + widget = new ccui.Layout(); this.setPropsForLayoutFromJsonDictionary(widget, uiOptions); } else if (classname == "Slider") { - widget = ccui.Slider.create(); + widget = new ccui.Slider(); this.setPropsForSliderFromJsonDictionary(widget, uiOptions); } else if (classname == "LabelBMFont") { - widget = ccui.TextBMFont.create(); + widget = new ccui.TextBMFont(); this.setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); } else if (classname == "DragPanel") { - widget = ccui.ScrollView.create(); + widget = new ccui.ScrollView(); this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } var children = data["children"]; diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index f35aed11a7..4899800e4f 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -63,10 +63,10 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ if (className == "CCNode") { var gb = null; if (!parenet) { - gb = cc.Node.create(); + gb = new cc.Node(); } else { - gb = cc.Node.create(); + gb = new cc.Node(); parenet.addChild(gb); } @@ -102,7 +102,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ if (resType == 0) { if (pathExtname != ".png") continue; - sprite = cc.Sprite.create(path); + sprite = new cc.Sprite(path); } else if (resType == 1) { if (pathExtname != ".plist") continue; @@ -110,13 +110,13 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ plistFile = cc.path.join(this._baseBath, plistFile); var pngFile = cc.path.changeExtname(plistFile, ".png"); cc.spriteFrameCache.addSpriteFrames(plistFile, pngFile); - sprite = cc.Sprite.create("#" + fileData["path"]); + sprite = new cc.Sprite("#" + fileData["path"]); } else { continue; } - var render = ccs.ComRender.create(sprite, "CCSprite"); + var render = new ccs.ComRender(sprite, "CCSprite"); if (comName != null) { render.setName(comName); } @@ -128,13 +128,13 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ var tmx = null; if (resType == 0) { if (pathExtname != ".tmx") continue; - tmx = cc.TMXTiledMap.create(path); + tmx = new cc.TMXTiledMap(path); } else { continue; } - var render = ccs.ComRender.create(tmx, "CCTMXTiledMap"); + var render = new ccs.ComRender(tmx, "CCTMXTiledMap"); if (comName != null) { render.setName(comName); } @@ -146,7 +146,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ var particle = null; if (resType == 0) { - particle = cc.ParticleSystem.create(path); + particle = new cc.ParticleSystem(path); } else { cc.log("unknown resourcetype on CCParticleSystemQuad!"); @@ -154,7 +154,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ } particle.setPosition(0, 0); - var render = ccs.ComRender.create(particle, "CCParticleSystemQuad"); + var render = new ccs.ComRender(particle, "CCParticleSystemQuad"); if (comName != null) { render.setName(comName); } @@ -173,8 +173,8 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ ccs.armatureDataManager.addArmatureFileInfo(path); - var armature = ccs.Armature.create(name); - var render = ccs.ComRender.create(armature, "CCArmature"); + var armature = new ccs.Armature(name); + var render = new ccs.ComRender(armature, "CCArmature"); if (comName != null) { render.setName(comName); } @@ -191,7 +191,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ else if (className == "CCComAudio") { var audio = null; if (resType == 0) { - audio = ccs.ComAudio.create(); + audio = new ccs.ComAudio(); } else { continue; @@ -206,7 +206,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ else if (className == "CCComAttribute") { var attribute = null; if (resType == 0) { - attribute = ccs.ComAttribute.create(); + attribute = new ccs.ComAttribute(); if (path != "") attribute.parse(path); } else { @@ -223,7 +223,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ if(!pathExtname) continue; if(resType!=0) continue; - var audio = ccs.ComAudio.create(); + var audio = new ccs.ComAudio(); audio.preloadBackgroundMusic(path); audio.setFile(path); var bLoop = Boolean(subDict["loop"] || 0); @@ -237,7 +237,7 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ } else if (className == "GUIComponent") { var widget = ccs.uiReader.widgetFromJsonFile(path); - var render = ccs.ComRender.create(widget, "GUIComponent"); + var render = new ccs.ComRender(widget, "GUIComponent"); if (comName != null) { render.setName(comName); } diff --git a/extensions/cocostudio/reader/timeline/ActionTimeline.js b/extensions/cocostudio/reader/timeline/ActionTimeline.js index 4c692c7a80..95f478aa8f 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimeline.js +++ b/extensions/cocostudio/reader/timeline/ActionTimeline.js @@ -23,430 +23,426 @@ ****************************************************************************/ -(function(studio){ +/** + * ActionTimelineData + * @name ccs.ActionTimelineData + * @extend ccs.Class + * @class + * + */ +ccs.ActionTimelineData = ccs.Class.extend({ + + _actionTag: 0, + + ctor: function(actionTag){ + this._init(actionTag); + }, + + _init: function(actionTag){ + this._actionTag = actionTag; + return true; + }, + + /** + * Set the action tag. + * @param {number} actionTag + */ + setActionTag: function(actionTag){ + this._actionTag = actionTag; + }, + /** - * ActionTimelineData - * @name ccs.ActionTimelineData - * @extend ccs.Class - * @class - * + * Gets the action tag. */ - studio.ActionTimelineData = studio.Class.extend({ - - _actionTag: 0, - - ctor: function(actionTag){ - this._init(actionTag); - }, - - _init: function(actionTag){ - this._actionTag = actionTag; - return true; - }, - - /** - * Set the action tag. - * @param {number} actionTag - */ - setActionTag: function(actionTag){ - this._actionTag = actionTag; - }, - - /** - * Gets the action tag. - */ - getActionTag: function(){ - return this._actionTag; + getActionTag: function(){ + return this._actionTag; + } + +}); + +/** + * Create new ActionTimelineData. + * + * @deprecated v3.0, please use new ccs.ActionTimelineData() instead. + * + * @name ccs.ActionTimelineData.create + * @function + * @param actionTag + * @returns {ccs.ActionTimelineData} + */ +ccs.ActionTimelineData.create = function(actionTag){ + return new ccs.ActionTimelineData(actionTag); +}; + + +/** + * ActionTimeline + * @class + * @extend cc.Action + * + * @property gotoFrameAndPlay + * @property gotoFrameAndPause + */ +ccs.ActionTimeline = cc.Action.extend({ + + _timelineMap: null, + _timelineList: null, + _duration: 0, + _time: null, + _timeSpeed: 1, + _frameInternal: 1/60, + _playing: false, + _currentFrame: 0, + _startFrame: 0, + _endFrame: 0, + _loop: null, + _frameEventListener: null, + + ctor: function(){ + cc.Action.prototype.ctor.call(this); + this._timelineMap = {}; + this._timelineList = []; + this.init(); + }, + + _gotoFrame: function(frameIndex){ + var size = this._timelineList.length; + for(var i = 0; i < size; i++) + { + this._timelineList[i]._gotoFrame(frameIndex); } + }, - }); + _stepToFrame: function(frameIndex){ + var size = this._timelineList.length; + for(var i = 0; i < size; i++){ + this._timelineList[i]._stepToFrame(frameIndex); + } + }, + + //emit frame event, call it when enter a frame + _emitFrameEvent: function(frame){ + if(this._frameEventListener){ + this._frameEventListener(frame); + } + }, + + init: function(){ + return true; + }, /** - * Create new ActionTimelineData. - * - * @deprecated v3.0, please use new ccs.ActionTimelineData() instead. - * - * @name ccs.ActionTimelineData.create - * @function - * @param actionTag - * @returns {ccs.ActionTimelineData} + * Goto the specified frame index, and start playing from this index. + * @param startIndex The animation will play from this index. + * @param [endIndex=] The animation will end at this index. + * @param [currentFrameIndex=] set current frame index. + * @param [loop=] Whether or not the animation need loop. */ - studio.ActionTimelineData.create = function(actionTag){ - var ret = new studio.ActionTimelineData(); - ret._init(actionTag); - return ret; - }; + gotoFrameAndPlay: function(startIndex, endIndex, currentFrameIndex, loop){ + //Consolidation parameters + var i = 0, + argLen = arguments.length; + var num = [], + bool; + for(i; i= this._startFrame && frameIndex >= this._endFrame){ + this._currentFrame = frameIndex; this._time = this._currentFrame * this._frameInternal; + }else{ + cc.log("frame index is not between start frame and end frame"); + } - this.resume(); - this._gotoFrame(this._currentFrame); - }, - - /** - * Goto the specified frame index, and pause at this index. - * @param startIndex The animation will pause at this index. - */ - gotoFrameAndPause: function(startIndex){ - this._startFrame = this._currentFrame = startIndex; - this._time = this._currentFrame * this._frameInternal; - - this.pause(); - this._gotoFrame(this._currentFrame); - }, - - /** - * Pause the animation. - */ - pause: function(){ - this._playing = false; - }, - - /** - * Resume the animation. - */ - resume: function(){ - this._playing = true; - }, - - /** - * Whether or not Action is playing. - */ - isPlaying: function(){ - return this._playing; - }, - - /** - * Set the animation speed, this will speed up or slow down the speed. - * @param {number} speed - */ - setTimeSpeed: function(speed){ - this._timeSpeed = speed; - }, - - /** - * Get current animation speed. - * @returns {number} - */ - getTimeSpeed: function(){ - return this._timeSpeed; - }, - - /** - * duration of the whole action - * @param {number} duration - */ - setDuration: function(duration){ - this._duration = duration; - }, - - /** - * Get current animation duration. - * @returns {number} - */ - getDuration: function(){ - return this._duration; - }, - - /** - * Start frame index of this action - * @returns {number} - */ - getStartFrame: function(){ - return this._startFrame; - }, - - /** - * End frame of this action. - * When action play to this frame, if action is not loop, then it will stop, - * or it will play from start frame again. - * @returns {number} - */ - getEndFrame: function(){ - return this._endFrame; - }, - - /** - * Set current frame index, this will cause action plays to this frame. - */ - setCurrentFrame: function(frameIndex){ - if (frameIndex >= this._startFrame && frameIndex >= this._endFrame){ - this._currentFrame = frameIndex; - this._time = this._currentFrame * this._frameInternal; - }else{ - cc.log("frame index is not between start frame and end frame"); - } + }, - }, - - /** - * Get current frame. - * @returns {number} - */ - getCurrentFrame: function(){ - return this._currentFrame; - }, - - /** - * add Timeline to ActionTimeline - * @param {ccs.Timeline} timeline - */ - addTimeline: function(timeline){ - var tag = timeline.getActionTag(); - if (!this._timelineMap[tag]) { - this._timelineMap[tag] = []; - } + /** + * Get current frame. + * @returns {number} + */ + getCurrentFrame: function(){ + return this._currentFrame; + }, + + /** + * add Timeline to ActionTimeline + * @param {ccs.Timeline} timeline + */ + addTimeline: function(timeline){ + var tag = timeline.getActionTag(); + if (!this._timelineMap[tag]) { + this._timelineMap[tag] = []; + } - if (!this._timelineMap[tag].some(function(item){ + if (!this._timelineMap[tag].some(function(item){ + if(item === timeline) + return true; + })) { + this._timelineList.push(timeline); + this._timelineMap[tag].push(timeline); + timeline.setActionTimeline(this); + } + + }, + + /** + * remove Timeline to ActionTimeline + * @param {ccs.Timeline} timeline + */ + removeTimeline: function(timeline){ + var tag = timeline.getActionTag(); + if (this._timelineMap[tag]) { + if(this._timelineMap[tag].some(function(item){ if(item === timeline) return true; })) { - this._timelineList.push(timeline); - this._timelineMap[tag].push(timeline); - timeline.setActionTimeline(this); - } - - }, - - /** - * remove Timeline to ActionTimeline - * @param {ccs.Timeline} timeline - */ - removeTimeline: function(timeline){ - var tag = timeline.getActionTag(); - if (this._timelineMap[tag]) { - if(this._timelineMap[tag].some(function(item){ - if(item === timeline) - return true; - })) { - cc.arrayRemoveObject(this._timelineMap[tag], timeline); - cc.arrayRemoveObject(this._timelineList, timeline); - timeline.setActionTimeline(null); - } - } - }, - - /** - * Gets the timeline list - * @returns {array | null} - */ - getTimelines: function(){ - return this._timelineList; - }, - - /** - * Set the Frame event - * @param {function} listener - */ - setFrameEventCallFunc: function(listener){ - this._frameEventListener = listener; - }, - - /** - * remove event - */ - clearFrameEventCallFunc: function(){ - this._frameEventListener = null; - }, - - /** - * Clone this timeline - * @returns {ccs.ActionTimeline} - */ - clone: function(){ - var newAction = new studio.ActionTimeline(); - newAction.setDuration(this._duration); - newAction.setTimeSpeed(this._timeSpeed); - - for (var a in this._timelineMap){ - var timelines = this._timelineMap[a]; - for(var b in timelines) - { - var timeline = timelines[b]; - var newTimeline = timeline.clone(); - newAction.addTimeline(newTimeline); - } + cc.arrayRemoveObject(this._timelineMap[tag], timeline); + cc.arrayRemoveObject(this._timelineList, timeline); + timeline.setActionTimeline(null); } + } + }, - return newAction; + /** + * Gets the timeline list + * @returns {array | null} + */ + getTimelines: function(){ + return this._timelineList; + }, - }, + /** + * Set the Frame event + * @param {function} listener + */ + setFrameEventCallFunc: function(listener){ + this._frameEventListener = listener; + }, - /** - * Reverse is not defined; - * @returns {null} - */ - reverse: function(){ - return null; - }, + /** + * remove event + */ + clearFrameEventCallFunc: function(){ + this._frameEventListener = null; + }, - /** - * Stepping of this time line. - * @param {number} delta - */ - step: function(delta){ - if (!this._playing || this._timelineMap.length == 0 || this._duration == 0) + /** + * Clone this timeline + * @returns {ccs.ActionTimeline} + */ + clone: function(){ + var newAction = new ccs.ActionTimeline(); + newAction.setDuration(this._duration); + newAction.setTimeSpeed(this._timeSpeed); + + for (var a in this._timelineMap){ + var timelines = this._timelineMap[a]; + for(var b in timelines) { - return; + var timeline = timelines[b]; + var newTimeline = timeline.clone(); + newAction.addTimeline(newTimeline); } + } - this._time += delta * this._timeSpeed; - this._currentFrame = this._time / this._frameInternal; + return newAction; - this._stepToFrame(this._currentFrame); + }, - if(this._time > this._endFrame * this._frameInternal){ - this._playing = this._loop; - if(!this._playing) - this._time = this._endFrame * this._frameInternal; - else - this.gotoFrameAndPlay(this._startFrame, this._endFrame, this._loop); - } + /** + * Reverse is not defined; + * @returns {null} + */ + reverse: function(){ + return null; + }, - }, + /** + * Stepping of this time line. + * @param {number} delta + */ + step: function(delta){ + if (!this._playing || this._timelineMap.length == 0 || this._duration == 0) + { + return; + } - _foreachNodeDescendant: function(parent, callback){ - callback(parent); + this._time += delta * this._timeSpeed; + this._currentFrame = this._time / this._frameInternal; - var children = parent.getChildren(); - for (var i=0; i this._endFrame * this._frameInternal){ + this._playing = this._loop; + if(!this._playing) + this._time = this._endFrame * this._frameInternal; + else + this.gotoFrameAndPlay(this._startFrame, this._endFrame, this._loop); + } - this._foreachNodeDescendant(target, callback); - }, + }, - /** - * Whether or not complete - * @returns {boolean} - */ - isDone: function(){ - return false; + _foreachNodeDescendant: function(parent, callback){ + callback(parent); + + var children = parent.getChildren(); + for (var i=0; i Date: Fri, 17 Oct 2014 14:06:09 +0800 Subject: [PATCH 0807/1564] Issue #5968: refactor cc.LayerGradient for performance --- cocos2d/core/layers/CCLayer.js | 14 ++++++++------ cocos2d/core/renderer/RendererCanvas.js | 18 +++++++----------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 746d24e575..5fe3396d1a 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -585,7 +585,6 @@ delete cc._tmp.PrototypeLayerColor; * @property {Number} compresseInterpolation - Indicate whether or not the interpolation will be compressed */ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ - _startColor: null, _endColor: null, _startOpacity: 255, _endOpacity: 255, @@ -603,7 +602,6 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ var _t = this; cc.LayerColor.prototype.ctor.call(_t); - _t._startColor = cc.color(0, 0, 0, 255); _t._endColor = cc.color(0, 0, 0, 255); _t._alongVector = cc.p(0, -1); _t._startOpacity = 255; @@ -629,10 +627,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ var _t = this; // Initializes the CCLayer with a gradient between start and end in the direction of v. - var locStartColor = _t._startColor, locEndColor = _t._endColor; - locStartColor.r = start.r; - locStartColor.g = start.g; - locStartColor.b = start.b; + var locEndColor = _t._endColor; _t._startOpacity = start.a; locEndColor.r = end.r; @@ -807,6 +802,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locCmd._startPoint.y = tHeight * locAlongVector.y - tHeight; locCmd._endPoint.x = tWidth * locAlongVector.x + tWidth; locCmd._endPoint.y = tHeight * (-locAlongVector.y) - tHeight; + + var locStartColor = this._displayedColor, locEndColor = this._endColor, opacity = this._displayedOpacity / 255; + var startOpacity = this._startOpacity, endOpacity = this._endOpacity; + locCmd._startStopStr = "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," + + Math.round(locStartColor.b) + "," + startOpacity.toFixed(4) + ")"; + locCmd._endStopStr = "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + + Math.round(locEndColor.b) + "," + endOpacity.toFixed(4) + ")"; }; //cc.LayerGradient define end _p = null; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 0f3c1d9054..97c9c6df0e 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -280,6 +280,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._node = node; this._startPoint = cc.p(0, 0); this._endPoint = cc.p(0, 0); + this._startStopStr = null; + this._endStopStr = null; }; cc.GradientRectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { @@ -299,24 +301,18 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.globalCompositeOperation = node._blendFuncStr; } context.globalAlpha = opacity; - var locWidth = node._contentSize.width, - locHeight = node._contentSize.height; + var locWidth = node._contentSize.width, locHeight = node._contentSize.height; - var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); //TODO need cached - var locStartColor = node._displayedColor, - locEndColor = node._endColor; - gradient.addColorStop(0, "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," - + Math.round(locStartColor.b) + "," + (locStartColor.a / 255).toFixed(4) + ")"); - gradient.addColorStop(1, "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," - + Math.round(locEndColor.b) + "," + (locEndColor.a != null ? (locEndColor.a / 255).toFixed(4) : 255) + ")"); + var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); + gradient.addColorStop(0, this._startStopStr); + gradient.addColorStop(1, this._endStopStr); context.fillStyle = gradient; if(needTransform){ context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); - } else { + } else context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); - } if(needRestore) context.restore(); From 6dcadef3492b91b5491b30aefceec04cf729ebfb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 17 Oct 2014 14:11:56 +0800 Subject: [PATCH 0808/1564] Issue #5983: The analysis of parameters --- .../cocostudio/reader/timeline/NodeReader.js | 466 ------------------ .../widgetreader/ButtonReader/ButtonReader.js | 104 ++-- .../CheckBoxReader/CheckBoxReader.js | 70 +-- .../ImageViewReader/ImageViewReader.js | 44 +- .../LabelAtlasReader/LabelAtlasReader.js | 22 +- .../LabelBMFontReader/LabelBMFontReader.js | 14 +- .../widgetreader/LabelReader/LabelReader.js | 38 +- .../widgetreader/LayoutReader/LayoutReader.js | 134 ++--- .../ListViewReader/ListViewReader.js | 182 ++++--- .../LoadingBarReader/LoadingBarReader.js | 48 +- .../PageViewReader/PageViewReader.js | 134 ++--- .../ScrollViewReader/ScrollViewReader.js | 146 +++--- .../widgetreader/SliderReader/SliderReader.js | 72 +-- .../TextFieldReader/TextFieldReader.js | 48 +- .../reader/widgetreader/WidgetReader.js | 124 ++--- moduleConfig.json | 1 - 16 files changed, 588 insertions(+), 1059 deletions(-) delete mode 100644 extensions/cocostudio/reader/timeline/NodeReader.js diff --git a/extensions/cocostudio/reader/timeline/NodeReader.js b/extensions/cocostudio/reader/timeline/NodeReader.js deleted file mode 100644 index 6d9090d6ca..0000000000 --- a/extensions/cocostudio/reader/timeline/NodeReader.js +++ /dev/null @@ -1,466 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -var timeline = { - ClassName_Node: "Node", - ClassName_SubGraph: "SubGraph", - ClassName_Sprite: "Sprite", - ClassName_Particle: "Particle", - - ClassName_Panel: "Panel", - ClassName_Button: "Button", - ClassName_CheckBox: "CheckBox", - ClassName_ImageView: "ImageView", - ClassName_TextAtlas: "TextAtlas", - ClassName_LabelAtlas: "LabelAtlas", - ClassName_LabelBMFont: "LabelBMFont", - ClassName_TextBMFont: "TextBMFont", - ClassName_Text: "Text", - ClassName_LoadingBar: "LoadingBar", - ClassName_TextField: "TextField", - ClassName_Slider: "Slider", - ClassName_Layout: "Layout", - ClassName_ScrollView: "ScrollView", - ClassName_ListView: "ListView", - ClassName_PageView: "PageView", - ClassName_Widget: "Widget", - ClassName_Label: "Label", - - - NODE: "nodeTree", - CHILDREN: "children", - CLASSNAME: "classname", - FILE_PATH: "fileName", - PLIST_FILE: "plistFile", - TAG: "tag", - ACTION_TAG: "actionTag", - - OPTIONS: "options", - - WIDTH: "width", - HEIGHT: "height", - X: "x", - Y: "y", - SCALE_X: "scaleX", - SCALE_Y: "scaleY", - SKEW_X: "skewX", - SKEW_Y: "skewY", - ROTATION: "rotation", - ROTATION_SKEW_X: "rotationSkewX", - ROTATION_SKEW_Y: "rotationSkewY", - ANCHOR_X: "anchorPointX", - ANCHOR_Y: "anchorPointY", - ALPHA: "opacity", - RED: "colorR", - GREEN: "colorG", - BLUE: "colorB", - ZORDER: "ZOrder", - PARTICLE_NUM: "particleNum", - FLIPX: "flipX", - FLIPY: "flipY", - VISIBLE: "visible", - - TEXTURES: "textures", - TEXTURES_PNG: "texturesPng" -}; - -/** - * Node Reader - * @name ccs.nodeReader - * @namespace - */ -ccs.nodeReader = { - - _funcs: null, - _recordJsonPath: true, - _jsonPath: "", - _sharedNodeReader: null, - - init: function(){ - this._funcs = {}; - - this._funcs[timeline.ClassName_Node] = ccs.nodeReader._loadSimpleNode.bind(this); - this._funcs[timeline.ClassName_SubGraph] = ccs.nodeReader._loadSubGraph.bind(this); - this._funcs[timeline.ClassName_Sprite] = ccs.nodeReader._loadSprite.bind(this); - this._funcs[timeline.ClassName_Particle] = ccs.nodeReader._loadParticle.bind(this); - this._funcs[timeline.ClassName_LabelAtlas] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_LabelBMFont] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_Panel] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_Button] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_CheckBox] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_ImageView] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_TextAtlas] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_TextBMFont] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_Text] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_LoadingBar] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_TextField] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_Slider] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_Layout] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_ScrollView] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_ListView] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_PageView] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_Widget] = ccs.nodeReader._loadWidget.bind(this); - this._funcs[timeline.ClassName_Label] = ccs.nodeReader._loadWidget.bind(this); - - }, - - /** - * Create node with file - * @param {string} filename - * @returns {cc.Node} - */ - createNode: function(filename){ - if(this._recordJsonPath){ - var jsonPath = filename.substr(0, filename.lastIndexOf('/') + 1); - ccs.uiReader.setFilePath(jsonPath); - - this._jsonPath = jsonPath; - }else{ - ccs.uiReader.setFilePath(""); - this._jsonPath = ""; - } - - return this.loadNodeWithFile(filename); - }, - - /** - * load file - * @param {string} fileName - * @returns {cc.Node} - */ - loadNodeWithFile: function(fileName){ - // Read content from file - //std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName); - var json = cc.loader.getRes(fileName); - - var node = this.loadNodeWithContent(json); - - // Load animation data from file - ccs.actionTimelineCache.loadAnimationActionWithContent(fileName, json); - - return node; - - }, - - /** - * load node with data. - * @param {Object} json - * @returns {cc.Node} - */ - loadNodeWithContent: function(json){ - // decode plist - var length = json[timeline.TEXTURES].length; - - for(var i=0; i Date: Fri, 17 Oct 2014 15:12:48 +0800 Subject: [PATCH 0809/1564] Issue #5983: Fixed a bug that CSLoader --- .../reader/timeline/ActionTimelineCache.js | 2 +- .../cocostudio/reader/timeline/CSLoader.js | 313 ++++++++---------- 2 files changed, 143 insertions(+), 172 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index 8dd2c68793..a2cf43c3f8 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -127,7 +127,7 @@ ccs.actionTimelineCache = { * @param {string} fileName * @returns {*} */ - createActionFormJson: function(fileName){ + createActionFromJson: function(fileName){ var action = this._animationActions[fileName]; if (action == null) { diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index 1be932e8e6..8e37a2b77d 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -157,6 +157,10 @@ ccs.CSLoader = { else if (suffix == "json" || suffix == "ExportJson") { return load.createNodeFromJson(filename); + }else if(suffix == "xml"){ + + cc.log("Does not support"); + return null; } return null; @@ -167,7 +171,7 @@ ccs.CSLoader = { var suffix = path.substr(pos + 1, path.length); cc.log("suffix = %s", suffix); - var cache = ccs.ActionTimelineCache; + var cache = ccs.actionTimelineCache; if (suffix == "csb") { @@ -196,42 +200,38 @@ ccs.CSLoader = { return this.loadNodeWithFile(filename); }, - loadNodeWithFile: function(filename){ + loadNodeWithFile: function(fileName){ // Read content from file - var contentStr = FileUtils.getInstance().getStringFromFile(fileName); + var contentStr = cc.loader.getRes(fileName); var node = this.loadNodeWithContent(contentStr); // Load animation data from file - ccs.ActionTimelineCache.getInstance().loadAnimationActionWithContent(fileName, contentStr); + ccs.actionTimelineCache.loadAnimationActionWithContent(fileName, contentStr); return node; }, - loadNodeWithContent: function(filename){ - var doc; - doc.Parse(content); - if (doc.HasParseError()) - { - cc.log("GetParseError %s\n", doc.GetParseError()); - } + loadNodeWithContent: function(data){ // cocos2dx version mono editor is based on - this._monoCocos2dxVersion = doc[CSLoaderStatic.MONO_COCOS2D_VERSION] || ""; + this._monoCocos2dxVersion = data[CSLoaderStatic.MONO_COCOS2D_VERSION] || data["version"]; // decode plist - var length = doc[CSLoaderStatic.TEXTURES]; + var texture = data[CSLoaderStatic.TEXTURES]; + var texturePng = data[CSLoaderStatic.TEXTURES_PNG]; + var length = texture.length; for(var i=0; i _componentFuncs; */ - - -}; \ No newline at end of file +}; +ccs.CSLoader.init(); \ No newline at end of file From 1053a0ffabcebce3621226d2e628607d06533277 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 17 Oct 2014 15:26:39 +0800 Subject: [PATCH 0810/1564] Issue #5983: Fixed a bug that param error --- cocos2d/core/renderer/RendererCanvas.js | 2 +- extensions/cocostudio/reader/SceneReader.js | 5 +---- extensions/cocostudio/reader/timeline/ActionTimelineCache.js | 2 +- tools/build.xml | 3 ++- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 97c9c6df0e..39e338c8c8 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -192,7 +192,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { ); } } else { - curColor = node._color; + curColor = node._displayedColor; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; context.fillRect(locX, locY, locWidth, locHeight); } diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js index 0a8d7d1bce..f085421994 100644 --- a/extensions/cocostudio/reader/SceneReader.js +++ b/extensions/cocostudio/reader/SceneReader.js @@ -174,11 +174,8 @@ ccs.sceneReader = /** @lends ccs.sceneReader# */{ ccs.armatureDataManager.addArmatureFileInfo(path); var armature = new ccs.Armature(name); -<<<<<<< HEAD + var render = new ccs.ComRender(armature, "CCArmature"); -======= - var render = ccs.ComRender.create(armature, "CCArmature"); ->>>>>>> 4e56aff207179a8182b25bc8178889149c384bce if (comName != null) { render.setName(comName); } diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index a2cf43c3f8..c417172117 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -117,7 +117,7 @@ ccs.actionTimelineCache = { if (suffix == "csb"){ return cache.createActionFromProtocolBuffers(filename); }else if (suffix == "json" || suffix == "ExportJson"){ - return cache.createActionFormJson(filename); + return cache.createActionFromJson(filename); } return null; }, diff --git a/tools/build.xml b/tools/build.xml index 7378e706e8..7f0f2cd081 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -234,11 +234,12 @@ + - + From 62f7f3a86d83cfc6d21023f09bfe72a463458291 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 17 Oct 2014 16:00:16 +0800 Subject: [PATCH 0811/1564] Issue #5933: Fixed a bug that ccs.bone create --- extensions/cocostudio/armature/CCBone.js | 6 ++---- extensions/cocostudio/armature/animation/CCTween.js | 2 +- extensions/cocostudio/armature/display/CCBatchNode.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 0bf73cd5d8..6a476a3b62 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -99,11 +99,9 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ this._name = name; this._tweenData = new ccs.FrameData(); - this._tween = new ccs.Tween(); - this._tween.init(this); + this._tween = new ccs.Tween(this); - this._displayManager = new ccs.DisplayManager(); - this._displayManager.init(this); + this._displayManager = new ccs.DisplayManager(this); this._worldInfo = new ccs.BaseData(); this._boneData = new ccs.BaseData(); diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 0f39c54a35..2139e7f46c 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -67,7 +67,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._tweenData = this._bone.getTweenData(); this._tweenData.displayIndex = -1; - this._animation = this._bone != null && this._bone.getArmature() != null ? + this._animation = (this._bone != null && this._bone.getArmature() != null) ? this._bone.getArmature().getAnimation() : null; return true; diff --git a/extensions/cocostudio/armature/display/CCBatchNode.js b/extensions/cocostudio/armature/display/CCBatchNode.js index 75e6e25031..f20c238850 100644 --- a/extensions/cocostudio/armature/display/CCBatchNode.js +++ b/extensions/cocostudio/armature/display/CCBatchNode.js @@ -106,7 +106,7 @@ ccs.BatchNode = cc.Node.extend(/** @lends ccs.BatchNode# */{ /** * - * @returns {BatchNode} + * @returns {ccs.BatchNode} * @deprecated since v3.1, please use new construction instead */ ccs.BatchNode.create = function () { From df8162fe56d67346cd440213642a18e5bdc6e327 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 17 Oct 2014 16:52:13 +0800 Subject: [PATCH 0812/1564] Issue #5983: Fixed a bug that layout error --- .../reader/widgetreader/LayoutReader/LayoutReader.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 361ac7d734..4e591a250d 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -257,11 +257,11 @@ ccs.layoutReader = /** @lends ccs.LayoutReader# */{ if (backGroundScale9Enable) { - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]!==null ? options["capInsetsWidth"] : 1; - var ch = options["capInsetsHeight"]!==null ? options["capInsetsHeight"] : 1; - panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + //var cx = options["capInsetsX"] || 0; + //var cy = options["capInsetsY"] || 0; + //var cw = options["capInsetsWidth"]!==null ? options["capInsetsWidth"] : 1; + //var ch = options["capInsetsHeight"]!==null ? options["capInsetsHeight"] : 1; + //panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); var sw = options["scale9Width"]; var sh = options["scale9Height"]; From 553c1aadc02400d4e75d5007cc3d9169f5f307c1 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Fri, 17 Oct 2014 17:09:52 +0800 Subject: [PATCH 0813/1564] Feature #5950 change Facebook dialog API --- external/pluginx/platform/facebook.js | 60 ++++++++++++++------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index ad5d8382a8..e5e513a7ca 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -323,14 +323,14 @@ plugin.extend('facebook', { }); return; } - if (info['dialog'] === 'share_link') { + if (info['dialog'] === 'shareLink') { if (info['link']) { info['method'] = 'share'; info['href'] = info['link']; } } else { // Compatible with feed_dialog - if (info['dialog'] == 'feed_dialog') { + if (info['dialog'] == 'feedDialog') { info['dialog'] = 'share'; } @@ -356,7 +356,8 @@ plugin.extend('facebook', { info['description'] = info['text'] || info['description']; delete info['text']; - if (info['method'] == 'share_open_graph') { + if (info['method'] == 'shareOpenGraph') { + info['method'] = "share_open_graph" if (info['url']) { var obj = {}; if (info["preview_property_name"]) @@ -400,10 +401,10 @@ plugin.extend('facebook', { */ canPresentDialog: function (info) { if (info && info['dialog'] && ( - info['dialog'] === 'share_link' || - info['dialog'] === 'feed_dialog' || - info['dialog'] === 'share_open_graph' || - info['dialog'] === 'message_link')) + info['dialog'] === 'shareLink' || + info['dialog'] === 'feedDialog' || + info['dialog'] === 'shareOpenGraph' || + info['dialog'] === 'messageLink')) return true; else return false; @@ -455,29 +456,30 @@ plugin.extend('facebook', { destroyInstance: function () { }, - - /** - * Payment request - * @param {Object} info - * @param {Function} callback - */ - pay: function (info, callback) { - /* - * Reference document - * https://developers.facebook.com/docs/payments/reference/paydialog + canvas:{ + /** + * Payment request + * @param {Object} info + * @param {Function} callback */ - info['method'] = 'pay'; - info['action'] = 'purchaseitem'; - - FB.ui(info, function (response) { - if (response['error_code']) { - callback(response['error_code'] || 1, { - error_message: response['error_message'] || 'Unknown' - }); - } else { - callback(0, response); - } - }) + pay: function (info, callback) { + /* + * Reference document + * https://developers.facebook.com/docs/payments/reference/paydialog + */ + info['method'] = 'pay'; + info['action'] = 'purchaseitem'; + + FB.ui(info, function (response) { + if (response['error_code']) { + callback(response['error_code'] || 1, { + error_message: response['error_message'] || 'Unknown' + }); + } else { + callback(0, response); + } + }) + } }, /** From a0c71bcdf361209455ca884c058d567c53f2acc7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 17 Oct 2014 17:26:44 +0800 Subject: [PATCH 0814/1564] Issue #5983: Remove cc.log and analysis of parameters --- extensions/cocostudio/reader/GUIReader.js | 18 +-- .../reader/timeline/ActionTimelineCache.js | 151 +++++++++--------- .../cocostudio/reader/timeline/CSLoader.js | 36 ++--- .../PageViewReader/PageViewReader.js | 2 +- 4 files changed, 103 insertions(+), 104 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 54f01aefcb..b09fc4a1d2 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -1966,7 +1966,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc var classname = nodetree.classname; - cc.log("classname = %s", classname); + //cc.log("classname = %s", classname); var widget = this._createGUI(classname); var readerName = this._getWidgetReaderClassName(classname); @@ -2007,12 +2007,12 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc } var size = nodetree.children.length; - cc.log("widget children size = %d", size); + //cc.log("widget children size = %d", size); for (var i = 0; i < size; ++i) { var subNodeTree = nodetree.children[i]; var child = this.widgetFromProtocolBuffers(subNodeTree); - cc.log("widget child = %p", child); + //cc.log("widget child = %p", child); if (child) { var pageView = widget; @@ -2035,7 +2035,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc } } - cc.log("widget = %p", widget); + //cc.log("widget = %p", widget); return widget; }, @@ -2046,7 +2046,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc widgetFromXML: function(objectData, classType){ var classname = classType.substr(0, classType.find("ObjectData")); - cc.log("classname = %s", classname); + //cc.log("classname = %s", classname); var widget = this.createGUI(classname); var readerName = this.getWidgetReaderClassName(classname); @@ -2097,7 +2097,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc while (objectData) { - cc.log("objectData name = %s", objectData.Name()); + //cc.log("objectData name = %s", objectData.Name()); if ("Children" !== objectData.Name()) { @@ -2111,7 +2111,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc if (containChildrenElement) { objectData = objectData.FirstChildElement(); - cc.log("objectData name = %s", objectData.Name()); + //cc.log("objectData name = %s", objectData.Name()); while (objectData) { @@ -2124,7 +2124,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc if (name == "ctype") { var child = this.widgetFromXML(objectData, value); - cc.log("child = %p", child); + //cc.log("child = %p", child); if (child) { var pageView = widget; @@ -2190,7 +2190,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc } // - cc.log("widget = %p", widget); + //cc.log("widget = %p", widget); return widget; }, diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index c417172117..0f527591a9 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -111,13 +111,15 @@ ccs.actionTimelineCache = { var path = filename; var pos = path.lastIndexOf('.'); var suffix = path.substr(pos + 1, path.length); - cc.log("suffix = %s", suffix); + //cc.log("suffix = %s", suffix); var cache = ccs.actionTimelineCache; if (suffix == "csb"){ return cache.createActionFromProtocolBuffers(filename); }else if (suffix == "json" || suffix == "ExportJson"){ return cache.createActionFromJson(filename); + }else if(suffix == "xml") { + cc.log("Does not support"); } return null; }, @@ -211,18 +213,18 @@ ccs.actionTimelineCache = { var binary = cc.loader.getRes(fileName); var buffer = PBP.CSParseBinary.decode(binary); - var actionProtobuf = buffer.action; + var actionProtobuf = buffer["action"]; action = new ccs.ActionTimeline(); - action.setDuration(actionProtobuf.duration); - action.setTimeSpeed(actionProtobuf.speed!==null?actionProtobuf.speed:1); + action.setDuration(actionProtobuf["duration"]); + action.setTimeSpeed(actionProtobuf["speed"]!==null?actionProtobuf["speed"]:1); - var timelineLength = actionProtobuf.timelines.length; + var timelineLength = actionProtobuf["timelines"].length; for(var i=0;i Date: Sat, 18 Oct 2014 10:06:35 +0800 Subject: [PATCH 0815/1564] Issue #5983: Fixed a bug that Node for widgetReader --- extensions/cocostudio/reader/GUIReader.js | 2 +- .../cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index b09fc4a1d2..220e298962 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -1982,7 +1982,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc { // // 1st., custom widget parse properties of parent widget with parent widget reader - readerName = this._getWidgetReaderClassName(widget); + readerName = this._getWidgetReaderClassNameFromWidget(widget); reader = this._createWidgetReaderProtocol(readerName); if (reader && widget) { diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 4e591a250d..3aa2dfc629 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -133,6 +133,8 @@ ccs.layoutReader = /** @lends ccs.LayoutReader# */{ var panel = widget; var options = nodeTree["PanelOptions"]; + if(!options) + return; var protocolBuffersPath = ccs.uiReader.getFilePath(); From e988cd8fc2de4a83a307d9695da0e3252688fdeb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 10:23:45 +0800 Subject: [PATCH 0816/1564] Issue #5983: Fixed a bug that Slider init error --- extensions/ccui/base-classes/UIWidget.js | 71 +++++++++++++----------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 81b7b53e83..2a96d9a287 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -194,11 +194,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _updateContentSizeWithTextureSize: function(size){ - if (this._unifySize) - { - this.setContentSize(size); - return; - } +// if (this._unifySize) +// { +// this.setContentSize(size); +// return; +// } this.setContentSize(this._ignoreSize ? size : this._customSize); }, @@ -303,11 +303,18 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._customSize.width = locWidth; this._customSize.height = locHeight; - if (this._unifySize){ - //unify Size logic - }else if (this._ignoreSize){ +// if (this._unifySize){ +// //unify Size logic +// }else + if (this._ignoreSize){ this._contentSize = this.getVirtualRendererSize(); } + if (this._running) { + var widgetParent = this.getWidgetParent(); + var pSize = widgetParent ? widgetParent.getContentSize() : this._parent.getContentSize(); + this._sizePercent.x = (pSize.width > 0.0) ? locWidth / pSize.width : 0.0; + this._sizePercent.y = (pSize.height > 0.0) ? locHeight / pSize.height : 0.0; + } this._onSizeChanged(); }, @@ -467,16 +474,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setSizeType: function (type) { this._sizeType = type; - var component = this.getOrCreateLayoutComponent(); - - if (this._sizeType == ccui.Widget.SIZE_PERCENT) - { - component.setUsingPercentContentSize(true); - } - else - { - component.setUsingPercentContentSize(false); - } +// var component = this.getOrCreateLayoutComponent(); +// +// if (this._sizeType == ccui.Widget.SIZE_PERCENT) +// { +// component.setUsingPercentContentSize(true); +// } +// else +// { +// component.setUsingPercentContentSize(false); +// } }, /** @@ -492,10 +499,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} ignore true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ ignoreContentAdaptWithSize: function (ignore) { - if (this._unifySize){ - this.setContentSize(this._customSize); - return; - }else if(this._ignoreSize == ignore) +// if (this._unifySize){ +// this.setContentSize(this._customSize); +// return; +// }else + if(this._ignoreSize == ignore) return; this._ignoreSize = ignore; @@ -1169,19 +1177,20 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setPositionType: function (type) { this._positionType = type; - if (type == ccui.Widget.POSITION_ABSOLUTE) - { - var oldPosition = this.getPosition(); - this.setPosition(this.getPosition() + cc.p(10,0)); - this.setPosition(oldPosition); - } - else - { + this.setNodeDirty(); +// if (type == ccui.Widget.POSITION_ABSOLUTE) +// { +// var oldPosition = this.getPosition(); +// this.setPosition(this.getPosition() + cc.p(10,0)); +// this.setPosition(oldPosition); +// } +// else +// { //todo check here // var oldNormalizedPosition = cc._position;//this.getNormalizedPosition(); // this.setNormalizedPosition(oldNormalizedPosition + cc.p(0.2,0.1)); // this.setNormalizedPosition(oldNormalizedPosition); - } +// } }, /** From be36be96ac5e04f398ee7806e2ad16dd4eae712c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 10:39:47 +0800 Subject: [PATCH 0817/1564] Issue #5983: Remove XML parse --- .../cocostudio/reader/timeline/CSLoader.js | 852 +----------------- .../widgetreader/ButtonReader/ButtonReader.js | 348 ------- .../CheckBoxReader/CheckBoxReader.js | 278 +----- .../ImageViewReader/ImageViewReader.js | 140 --- .../LabelAtlasReader/LabelAtlasReader.js | 91 -- .../LabelBMFontReader/LabelBMFontReader.js | 86 -- .../widgetreader/LabelReader/LabelReader.js | 178 ---- .../widgetreader/LayoutReader/LayoutReader.js | 305 ------- .../ListViewReader/ListViewReader.js | 397 +------- .../LoadingBarReader/LoadingBarReader.js | 124 --- .../PageViewReader/PageViewReader.js | 304 ------- .../ScrollViewReader/ScrollViewReader.js | 349 ------- .../widgetreader/SliderReader/SliderReader.js | 322 ------- .../TextFieldReader/TextFieldReader.js | 156 ---- .../reader/widgetreader/WidgetReader.js | 224 +---- 15 files changed, 8 insertions(+), 4146 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index fb46bf5327..dac3f58164 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -106,8 +106,6 @@ ccs.CSLoader = { _jsonPath: "", _recordProtocolBuffersPath: true, _protocolBuffersPath: "", - _recordXMLPath: "", - _xmlPath: "", _monoCocos2dxVersion: "", init: function(){ @@ -157,10 +155,6 @@ ccs.CSLoader = { else if (suffix == "json" || suffix == "ExportJson") { return load.createNodeFromJson(filename); - }else if(suffix == "xml"){ - - cc.log("Does not support"); - return null; } return null; @@ -503,335 +497,6 @@ ccs.CSLoader = { return this._protocolBuffersPath; }, - createNodeFromXML: function(filename){ - if(this._recordXMLPath) - { - var xmlPath = filename.substr(0, filename.lastIndexOf('/') + 1); - //cc.log("xmlPath = %s", xmlPath); - ccs.uiReader.setFilePath(xmlPath); - - this._xmlPath = xmlPath; - } - else - { - ccs.uiReader.setFilePath(""); - this._xmlPath = ""; - } - - return this.nodeFromXMLFile(filename); - - }, - nodeFromXMLFile: function(filename){ - var node = null; - - - var content = cc.loader.getRes(filename); - ////////////parse////////// - - - var element = rootElement.FirstChildElement(); - - var createEnabled = false; - var rootType = ""; - - while (element) - { - //cc.log("entity name = %s", element.Name()); - - if ("Content" != element.Name()) - { - var attribute = element.FirstAttribute(); - - if (!attribute) - { - createEnabled = true; - rootType = "NodeObjectData"; - } - // - - // - // while (attribute) - // { - // var name = attribute.Name(); - // var value = attribute.Value(); - // cc.log("attribute name = %s, value = %s", name, value); - // if (name == "") - // { - // serializeEnabled = true; - // rootType = (strcmp("", value) == 0) ? "Node" : value; - // } - // - // if (serializeEnabled) - // { - // break; - // } - // - // attribute = attribute.Next(); - // } - // - } - - if (createEnabled) - { - break; - } - - var child = element.FirstChildElement(); - if (child) - { - element = child; - } - else - { - element = element.NextSiblingElement(); - } - } - - - // create - if (createEnabled) - { - var protobuf;//protobuf reader - - var child = element.FirstChildElement(); - - while (child) - { - var name = child.Name(); - - if (name == "ObjectData") // nodeTree - { - var objectData = child; - node = this.nodeFromXML(objectData, rootType); - } - - child = child.NextSiblingElement(); - } - } - - return node; - }, - nodeFromXML: function(objectData, classType){ - var node = null; - - var classname = classType.substr(0, classType.indexOf("ObjectData")); - //cc.log("classname = %s", classname); - - if (classname == "Node") - { - node = new cc.Node(); - this.setPropsForNodeFromXML(node, objectData); - } - else if (classname == "SingleNode") - { - node = new cc.Node(); - this.setPropsForSingleNodeFromXML(node, objectData); - } - else if (classname == "Sprite") - { - node = new cc.Sprite(); - this.setPropsForSpriteFromXML(node, objectData); - } - else if (classname == "GameMap") - { - node = this.createTMXTiledMapFromXML(objectData); - } - else if (classname == "Particle") - { - node = this.createParticleFromXML(objectData); - } - else if (classname == "ProjectNode") - { - // FileData - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "FileData") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - node = this.createNodeFromXML(this._xmlPath + value); - this.setPropsForProjectNodeFromXML(node, objectData); - - var action = ccs.actionTimelineCache.createActionFromXML(this._xmlPath + value); - if(action) - { - node.runAction(action); - action.gotoFrameAndPlay(0); - } - - break; - } - - attribute = attribute.Next(); - } - - break; - } - - child = child.NextSiblingElement(); - } - } - else if (classname == "SimpleAudio") - { - // process as component options - node = new ccs.Node(); - this.setPropsForSimpleAudioFromXML(node, objectData); - - var component = this.createComponentFromXML(objectData, "ComAudio"); - - if (component) - { - node.addComponent(component); - } - } - else if (this.isWidget(classname)) - { - var guiClassName = this.getGUIClassName(classname); - var readerName = guiClassName; - readerName.append("Reader"); - - var widget = cc.objectFactory.createObject(guiClassName); - - var reader = ccs.objectFactory.createObject(readerName); - reader.setPropsFromXML(widget, objectData); - - node = widget; - } - - - // children - var containChildrenElement = false; - objectData = objectData.FirstChildElement(); - - while (objectData) - { - //cc.log("objectData name = %s", objectData.Name()); - - if ("Children" != objectData.Name()) - { - containChildrenElement = true; - break; - } - - objectData = objectData.NextSiblingElement(); - } - - if (containChildrenElement) - { - objectData = objectData.FirstChildElement(); - //cc.log("element name = %s", objectData.Name()); - - while (objectData) - { - var attribute = objectData.FirstAttribute(); - var bHasType = false; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ctype") - { - bHasType = true; - var child = this.nodeFromXML(objectData, value); - //cc.log("child = %p", child); - if (child) - { - var pageView = node; - var listView = node; - if (pageView instanceof ccui.PageView) - { - var layout = child; - if (layout instanceof ccui.Layout) - { - pageView.addPage(layout); - } - } - else if (listView instanceof ccui.ListView) - { - var widget = child; - if (widget instanceof ccui.Widget) - { - listView.pushBackCustomItem(widget); - } - } - else - { - node.addChild(child); - } - } - - break; - } - - attribute = attribute.Next(); - } - - if (!bHasType) - { - var child = this.nodeFromXML(objectData, "NodeObjectData"); - //cc.log("child = %p", child); - if (child) - { - var pageView = node; - var listView = node; - if (pageView instanceof ccui.PageView) - { - var layout = child; - if (layout instanceof ccui.Layout) - { - pageView.addPage(layout); - } - } - else if (listView instanceof ccui.ListView) - { - var widget = child; - if (widget instanceof ccui.Widget) - { - listView.pushBackCustomItem(widget); - } - } - else - { - node.addChild(child); - } - } - } - - objectData = objectData.NextSiblingElement(); - } - } - // - - return node; - }, - - setRecordXMLPath: function(record){ - this._recordXMLPath =- record; - }, - isRecordXMLPath: function(){ - return this._recordXMLPath; - }, - - setXMLPath: function(xmlPath){ - this._xmlPath = xmlPath; - }, - getXMLPath: function(){ - return this._xmlPath; - }, - - //protected loadNode: function(json){ var node = null; @@ -1082,7 +747,7 @@ ccs.CSLoader = { else if ((tmxString && "" != tmxString) && (resourcePath && "" != resourcePath)) { - tmx = cc.TMXTiledMap.createWithXML(tmxString, resourcePath); + tmx = new cc.TMXTiledMap(tmxString, resourcePath); } return tmx; @@ -1446,521 +1111,6 @@ ccs.CSLoader = { audio.setLoop(options["loop"]); }, - setPropsForNodeFromXML: function(node, nodeObjectData){ - node.setCascadeColorEnabled(true); - node.setCascadeOpacityEnabled(true); - - node.setScale(0.0, 0.0); - - var name = nodeObjectData.Name(); - //cc.log("entity name = %s", name); - - // attributes - var attribute = nodeObjectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Name") - { - node.setName(value); - } - else if (name == "ActionTag") - { - //atoi(value) - node.setUserObject(new ccs.ActionTimelineData(value)); - } - else if (name == "RotationSkewX") - { - node.setRotationX(value); - } - else if (name == "RotationSkewY") - { - node.setRotationY(value); - } - else if (name == "Rotation") - { - // node.setRotation(atoi(value)); - } - else if (name == "ZOrder") - { - node.setZOrder(value); - } - else if (name == "Visible") - { - node.setVisible((value == "True") ? true : false); - } - else if (name == "VisibleForFrame") - { - // node.setVisible((value == "True") ? true : false); - } - else if (name == "Alpha") - { - node.setOpacity(value); - } - else if (name == "Tag") - { - node.setTag(value); - } - - attribute = attribute.Next(); - } - - var child = nodeObjectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - if (name == "Children") - { - break; - } - else if (name == "Position") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - node.setPositionX(value); - } - else if (name == "Y") - { - node.setPositionY(value); - } - - attribute = attribute.Next(); - } - } - else if (name == "Scale") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - node.setScaleX(value); - } - else if (name == "ScaleY") - { - node.setScaleY(value); - } - - attribute = attribute.Next(); - } - } - else if (name == "AnchorPoint") - { - var attribute = child.FirstAttribute(); - - var anchorX = 0.0; - var anchorY = 0.0; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - anchorX = value; - } - else if (name == "ScaleY") - { - anchorY = value; - } - - attribute = attribute.Next(); - } - - node.setAnchorPoint(cc.p(anchorX, anchorY)); - } - else if (name == "CColor") - { - var attribute = child.FirstAttribute(); - var opacity = 255, red = 255, green = 255, blue = 255; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "A") - { - opacity = value; - } - else if (name == "R") - { - red = value; - } - else if (name == "G") - { - green = value; - } - else if (name == "B") - { - blue = value; - } - - attribute = attribute.Next(); - } - - node.setOpacity(opacity); - node.setColor(cc.color(red, green, blue)); - } - else if (name == "Size") - { - var attribute = child.FirstAttribute(); - var width = 0, height = 0; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - - node.setContentSize(cc.size(width, height)); - } - - child = child.NextSiblingElement(); - } - }, - setPropsForSingleNodeFromXML: function(node, nodeObjectData){ - this.setPropsForNodeFromXML(node, nodeObjectData); - }, - setPropsForSpriteFromXML: function(node, spriteObjectData){ - this.setPropsForNodeFromXML(node, spriteObjectData); - - var sprite = node; - var opacity = 255; - - // attributes - var attribute = this.spriteObjectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Alpha") - { - opacity = value; - } - else if (name == "FlipX") - { - sprite.setFlippedX((value == "True") ? true : false); - } - else if (name == "FlipY") - { - sprite.setFlippedY((value == "True") ? true : false); - } - - attribute = attribute.Next(); - } - - - // FileData - var child = spriteObjectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "FileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - if (path != "") - { - sprite.setTexture(this._xmlPath + path); - } - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(this._xmlPath + plistFile); - if (path != "") - { - sprite.setSpriteFrame(path); - } - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - sprite.setOpacity(opacity); - }, - createParticleFromXML: function(particleObjectData){ - var node = null; - - // child elements - var child = particleObjectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "FileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - if (path != "") - { - node = new cc.ParticleSystemQuad(this._xmlPath + path); - } - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - if (node) - { - this.setPropsForNodeFromXML(node, particleObjectData); - } - - return node; - }, - createTMXTiledMapFromXML: function(tmxTiledMapObjectData){ - var node = null; - - // child elements - var child = tmxTiledMapObjectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "FileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - var tmxFile_str = this._xmlPath + path; - var tmxFile = tmxFile_str; - - if (tmxFile && "" != tmxFile) - { - node = new cc.TMXTiledMap(tmxFile); - } - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - - if (node) - { - this.setPropsForNodeFromXML(node, tmxTiledMapObjectData); - } - - return node; - }, - setPropsForProjectNodeFromXML: function(node, projectNodeObjectData){ - this.setPropsForNodeFromXML(node, projectNodeObjectData); - }, - setPropsForSimpleAudioFromXML: function(node, simpleAudioObjectData){ - this.setPropsForNodeFromXML(node, simpleAudioObjectData); - }, - - createComponentFromXML: function(componentObjectData, componentType){ - var component = null; - - if (componentType == "ComAudio") - { - component = new ccs.ComAudio(); - this.setPropsForComAudioFromXML(component, componentObjectData); - } - - return component; - }, - setPropsForComponentFromXML: function(component, componentObjectData){}, - setPropsForComAudioFromXML: function(component, comAudioObjectData){ - var audio = component; - - audio.setEnabled(true); - - var attribute = comAudioObjectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Loop") - { - audio.setLoop((value == "True") ? true : false); - } - else if (name == "Name") - { - audio.setName(value); - } - - attribute = attribute.Next(); - } - - // FileData - var child = comAudioObjectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "FileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - audio.setFile((this._xmlPath + path)); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - }, - isWidget: function(type){ return (type == CSLoaderStatic.ClassName_Panel || type == CSLoaderStatic.ClassName_Button diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index e301a2187a..a6b759633e 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -232,353 +232,5 @@ ccs.buttonReader = /** @lends ccs.buttonReader# */{ // other commonly protperties ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var button = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var scale9Enabled = false; - var cx = 0, cy = 0, cw = 0, ch = 0; - var swf = 0, shf = 0; - var text = ""; - var fontName = "微软雅黑"; - var fontSize = 0; - var title_color_red = 255, title_color_green = 255, title_color_blue = 255; - var cri = 255, cgi = 255, cbi = 255; - var opacity = 255; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Scale9Enable") - { - if (value == "True") - { - scale9Enabled = true; - } - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - else if (name == "ButtonText") - { - text = value; - } - else if (name == "FontSize") - { - fontSize = value; - } - else if (name == "FontName") - { - fontName = value; - } - else if (name == "Alpha") - { - opacity = value; - } - else if (name == "DisplayState") - { - button.setBright((value == "True") ? true : false); - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "Size" && scale9Enabled) - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - swf = value; - } - else if (name == "Y") - { - shf = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "CColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - cri = value; - } - else if (name == "G") - { - cgi = value; - } - else if (name == "B") - { - cbi = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "TextColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - title_color_red = value; - } - else if (name == "G") - { - title_color_green = value; - } - else if (name == "B") - { - title_color_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "DisabledFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - button.loadTextureDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - button.loadTextureDisabled(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "PressedFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - button.loadTexturePressed(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - button.loadTexturePressed(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "NormalFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - button.loadTextureNormal(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - button.loadTextureNormal(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "FontResource") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - fontName = xmlPath + path; - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - button.setScale9Enabled(scale9Enabled); - - - if (scale9Enabled) - { - button.setUnifySizeEnabled(false); - button.ignoreContentAdaptWithSize(false); - - button.setCapInsets(cc.rect(cx, cy, cw, ch)); - button.setContentSize(cc.size(swf, shf)); - } - - button.setTitleText(text); - button.setTitleColor(cc.color(title_color_red, title_color_green, title_color_blue)); - button.setTitleFontSize(fontSize); - button.setTitleFontName(fontName); - - button.setColor(cc.color(cri,cgi,cbi)); - button.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index 5ef5481913..65f6ad3c14 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -163,283 +163,7 @@ ccs.checkBoxReader = /** @lends ccs.CheckBoxReader# */{ ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); }, - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var checkBox = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var opacity = 255; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "CheckedState") - { - checkBox.setSelectedState((value == "True") ? true : false); - } - else if (name == "DisplayState") - { - checkBox.setBright((value == "True") ? true : false); - } - else if (name == "Alpha") - { - opacity = atoi(value); - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "NormalBackFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = ccs.widgetReader.getResourceType(value); - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - checkBox.loadTextureBackGround(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - checkBox.loadTextureBackGround(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "PressedBackFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = ccs.widgetReader.getResourceType(value); - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - checkBox.loadTextureBackGroundSelected(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - checkBox.loadTextureBackGroundSelected(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "NodeNormalFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = ccs.widgetReader.getResourceType(value); - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - checkBox.loadTextureFrontCross(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - checkBox.loadTextureFrontCross(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "DisableBackFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = ccs.widgetReader.getResourceType(value); - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - checkBox.loadTextureBackGroundDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - checkBox.loadTextureBackGroundDisabled(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "NodeDisableFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = ccs.widgetReader.getResourceType(value); - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - checkBox.loadTextureFrontCrossDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - checkBox.loadTextureFrontCrossDisabled(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - checkBox.setOpacity(opacity); - }, - - getResourceType: function(key) - { + getResourceType: function(key){ if(key == "Normal" || key == "Default" || key == "MarkedSubImage") { return 0; diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 1e80a7d307..1fe74f603e 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -155,145 +155,5 @@ ccs.imageViewReader = /** @lends ccs.ImageViewReader# */{ imageView.setFlippedX(flipX); if(flipY != false) imageView.setFlippedY(flipY); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var imageView = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var scale9Enabled = false; - var cx = 0, cy = 0, cw = 0, ch = 0; - var swf = 0, shf = 0; - - var opacity = 255; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Scale9Enable") - { - if (value == "True") - { - scale9Enabled = true; - } - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - else if (name == "Alpha") - { - opacity = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "Size" && scale9Enabled) - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - swf = value; - } - else if (name == "Y") - { - shf = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - imageView.loadTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - imageView.loadTexture(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - imageView.setScale9Enabled(scale9Enabled); - - if (scale9Enabled) - { - imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); - imageView.setContentSize(cc.size(swf, shf)); - } - - imageView.setOpacity(opacity); } - }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 4004af68af..7aad436424 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -82,11 +82,6 @@ ccs.labelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ var labelAtlas = widget; var options = nodeTree["textAtlasOptions"]; - // var sv = DICTOOL.checkObjectExist_json(options, P_StringValue); - // var cmf = DICTOOL.checkObjectExist_json(options, P_CharMapFile); - // var iw = DICTOOL.checkObjectExist_json(options, P_ItemWidth); - // var ih = DICTOOL.checkObjectExist_json(options, P_ItemHeight); - // var scm = DICTOOL.checkObjectExist_json(options, P_StartCharMap); var cmftDic = options["charMapFileData"]; var cmfType = cmftDic["resourceType"]; @@ -117,91 +112,5 @@ ccs.labelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ // other commonly protperties ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var labelAtlas = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var stringValue = "", startChar = ""; - var itemWidth = 0, itemHeight = 0; - var resourceType = 0; - var path = "", plistFile = ""; - - var opacity = 255; - - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "LabelText") - { - stringValue = value; - } - else if (name == "CharWidth") - { - itemWidth = value; - } - else if (name == "CharHeight") - { - itemHeight = value; - } - else if (name == "StartChar") - { - startChar = value; - } - else if (name == "Alpha") - { - opacity = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "LabelAtlasFileImage_CNB") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - } - - child = child.NextSiblingElement(); - } - - labelAtlas.setProperty(stringValue, xmlPath + path, itemWidth, itemHeight, startChar); - - labelAtlas.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index 615890faf0..33234df611 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -107,91 +107,5 @@ ccs.labelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ // other commonly protperties ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - - setPropsFromXML: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromXML(widget, objectData); - - var labelBMFont = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var text = ""; - - var opacity = 255; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "LabelText") - { - text = value; - } - else if (name == "Alpha") - { - opacity = value; - } - - attribute = attribute.Next(); - } - - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "LabelBMFontFile_CNB") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - labelBMFont.setFntFile(xmlPath + path); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - labelBMFont.setString(text); - - labelBMFont.setOpacity(opacity); - } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index 8202abb581..f83c49bbd8 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -104,14 +104,6 @@ ccs.labelReader = /** @lends ccs.LabelReader# */{ var fontName = options["fontName"]!==null ? options["fontName"] : "微软雅黑"; label.setFontName(fontName); -// var fontFilePath = protocolBuffersPath.append(fontName); -// if (FileUtils.getInstance().isFileExist(fontFilePath)) -// { -// label.setFontName(fontFilePath); -// } -// else{ -// label.setFontName(fontName); -// } var aw = options["areaWidth"]; var ah = options["areaHeight"]; @@ -139,175 +131,5 @@ ccs.labelReader = /** @lends ccs.LabelReader# */{ // other commonly protperties ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var label = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var areaWidth = 0, areaHeight = 0; - var halignment = 0, valignment = 0; - - var opacity = 255; - - label.setUnifySizeEnabled(false); - - label.setFontName("微软雅黑"); - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "TouchScaleChangeAble") - { - label.setTouchScaleChangeEnabled((value == "True") ? true : false); - } - else if (name == "LabelText") - { - label.setString(value); - } - else if (name == "FontSize") - { - label.setFontSize(value); - } - else if (name == "FontName") - { - label.setFontName(value); - } - else if (name == "AreaWidth") - { - areaWidth = value; - } - else if (name == "AreaHeight") - { - areaHeight = value; - } - else if (name == "HorizontalAlignmentType") - { - if (value == "HT_Left") - { - halignment = 0; - } - else if (value == "HT_Center") - { - halignment = 1; - } - else if (value == "HT_Right") - { - halignment = 2; - } - } - else if (name == "VerticalAlignmentType") - { - if (value == "VT_Top") - { - valignment = 0; - } - else if (value == "VT_Center") - { - valignment = 1; - } - else if (value == "VT_Bottom") - { - valignment = 2; - } - } - else if (name == "Alpha") - { - opacity = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "Size") - { - var attribute = child.FirstAttribute(); - var width = 0, height = 0; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - - label.ignoreContentAdaptWithSize(false); - label.setContentSize(cc.size(width, height)); - } - else if (name == "FontResource") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - label.setFontName(xmlPath + path); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - if (areaWidth != 0 || areaHeight != 0) - { - label.setTextAreaSize(cc.size(areaWidth, areaHeight)); - } - - label.setTextHorizontalAlignment(halignment); - label.setTextVerticalAlignment(valignment); - - label.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 3aa2dfc629..a377a879b7 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -301,310 +301,5 @@ ccs.layoutReader = /** @lends ccs.LayoutReader# */{ var flipY = widgetOptions["flipY"]; widget.setFlippedX(flipX); widget.setFlippedY(flipY); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var panel = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var scale9Enabled = false; - var width = 0, height = 0; - var cx = 0, cy = 0, cw = 0, ch = 0; - - var colorType = ccui.Layout.BG_COLOR_NONE; - var color_opacity = 255, bgimg_opacity = 255, opacity = 255; - var red = 255, green = 255, blue = 255; - var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; - var singleRed = 255, singleGreen = 255, singleBlue = 255; - var start_red = 255, start_green = 255, start_blue = 255; - var end_red = 255, end_green = 255, end_blue = 255; - var vector_color_x = 0, vector_color_y = -0.5; - - var resourceType = 0; - var path = "", plistFile = ""; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ClipAble") - { - panel.setClippingEnabled((value == "True") ? true : false); - } - else if (name == "ComboBoxIndex") - { - colorType = value; - } - else if (name == "BackColorAlpha") - { - color_opacity = value; - } - else if (name == "Alpha") - { - opacity = value; - bgimg_opacity = value; - } - else if (name == "Scale9Enable") - { - scale9Enabled = (value == "True") ? true : false; - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "Size") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "CColor") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - red = value; - bgimg_red = value; - } - else if (name == "G") - { - green = value; - bgimg_green = value; - } - else if (name == "B") - { - blue = value; - bgimg_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "SingleColor") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - singleRed = value; - } - else if (name == "G") - { - singleGreen = value; - } - else if (name == "B") - { - singleBlue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "EndColor") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - end_red = value; - } - else if (name == "G") - { - end_green = value; - } - else if (name == "B") - { - end_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FirstColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - start_red = value; - } - else if (name == "G") - { - start_green = value; - } - else if (name == "B") - { - start_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "ColorVector") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - vector_color_x = value; - } - else if (name == "ScaleY") - { - vector_color_y = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FileData") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - } - - child = child.NextSiblingElement(); - } - - panel.setBackGroundColorType(colorType); - switch (colorType) - { - case ccui.Layout.BG_COLOR_SOLID: - panel.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); - break; - - case ccui.Layout.BG_COLOR_GRADIENT: - panel.setBackGroundColor(cc.color(start_red, start_green, start_blue), - cc.color(end_red, end_green, end_blue)); - panel.setBackGroundColorVector(cc.p(vector_color_x, vector_color_y)); - break; - - default: - break; - } - - panel.setColor(cc.color(red, green, blue)); - panel.setOpacity(opacity); - - panel.setBackGroundColorOpacity(color_opacity); - - switch (resourceType) - { - case 0: - { - panel.setBackGroundImage(xmlPath + path, ccui.Widget.PLIST_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - panel.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - - if (path != "") - { - if (scale9Enabled) - { - panel.setBackGroundImageScale9Enabled(scale9Enabled); - panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - panel.setContentSize(cc.size(width, height)); - } - } - -// panel.setBackGroundImageColor(Color3B(bgimg_red, bgimg_green, bgimg_blue)); -// panel.setBackGroundImageOpacity(bgimg_opacity); - } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index 62a5a4c32a..0723ae2616 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -59,7 +59,7 @@ ccs.listViewReader = /** @lends ccs.ListViewReader# */{ }, setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.prototype.setPropsFromProtocolBuffers.call(this, widget, nodeTree); + ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); var listView = widget; var options = nodeTree["listviewOptions"]; @@ -179,400 +179,5 @@ ccs.listViewReader = /** @lends ccs.ListViewReader# */{ var flipY = widgetOptions["flipY"]; widget.setFlippedX(flipX); widget.setFlippedY(flipY); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var listView = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var scale9Enabled = false; - var width = 0, height = 0; - var cx = 0, cy = 0, cw = 0, ch = 0; - - var colorType = ccui.Layout.BG_COLOR_NONE; - var color_opacity = 255, bgimg_opacity = 255, opacity = 255; - var red = 255, green = 255, blue = 255; - var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; - var singleRed = 255, singleGreen = 255, singleBlue = 255; - var start_red = 255, start_green = 255, start_blue = 255; - var end_red = 255, end_green = 255, end_blue = 255; - var vector_color_x = 0.0, vector_color_y = -0.5; - - var resourceType = 0; - var path = "", plistFile = ""; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ClipAble") - { - listView.setClippingEnabled((value == "True") ? true : false); - } - else if (name == "ComboBoxIndex") - { - colorType = value; - } - else if (name == "BackColorAlpha") - { - color_opacity = value; - } - else if (name == "Alpha") - { - opacity = value; - bgimg_opacity = value; - } - else if (name == "Scale9Enable") - { - scale9Enabled = (value == "True") ? true : false; - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - else if (name == "DirectionType") - { - if (value == "Vertical") - { - listView.setDirection(ccui.ScrollView.DIR_VERTICAL); - - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "HorizontalType") - { - if (value == "HORIZONTAL_LEFT") - { - listView.setGravity(ccui.ListView.GRAVITY_LEFT); - } - else if (value == "HORIZONTAL_RIGHT") - { - listView.setGravity(ccui.ListView.GRAVITY_RIGHT); - } - else if (value == "HORIZONTAL_CENTER") - { - listView.setGravity(ccui.ListView.GRAVITY_CENTER_HORIZONTAL); - } - } - - attribute = attribute.Next(); - } - } - else if (value == "Horizontal") - { - listView.setDirection(ccui.ScrollView.DIR_HORIZONTAL); - - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "VerticalType") - { - if (value == "VERTICAL_TOP") - { - listView.setGravity(ccui.ListView.GRAVITY_TOP); - } - else if (value == "VERTICAL_BOTTOM") - { - listView.setGravity(ccui.ListView.GRAVITY_BOTTOM); - } - else if (value == "VERTICAL_CENTER") - { - listView.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL); - } - } - - attribute = attribute.Next(); - } - } - } - else if (name == "IsBounceEnabled") - { - listView.setBounceEnabled((value == "True") ? true : false); - } - else if (name == "ItemMargin") - { - listView.setItemsMargin(value); - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "InnerNodeSize") - { - var attribute = child.FirstAttribute(); - var width = 0, height = 0; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Width") - { - width = value; - } - else if (name == "Height") - { - height = value; - } - - attribute = attribute.Next(); - } - - ccui.listView.prototype.setInnerContainerSize(cc.size(width, height)); - } - else if (name == "Size") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "CColor") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - red = value; - bgimg_red = value; - } - else if (name == "G") - { - green = value; - bgimg_green = value; - } - else if (name == "B") - { - blue = value; - bgimg_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "SingleColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - singleRed = value; - } - else if (name == "G") - { - singleGreen = value; - } - else if (name == "B") - { - singleBlue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "EndColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - end_red = value; - } - else if (name == "G") - { - end_green = value; - } - else if (name == "B") - { - end_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FirstColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - start_red = value; - } - else if (name == "G") - { - start_green = value; - } - else if (name == "B") - { - start_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "ColorVector") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - vector_color_x = value; - } - else if (name == "ScaleY") - { - vector_color_y = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FileData") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - } - - child = child.NextSiblingElement(); - } - - listView.setColor(cc.color(red, green, blue)); - listView.setOpacity(opacity); - - listView.setBackGroundColorType(colorType); - switch (colorType) - { - case ccui.Layout.BG_COLOR_SOLID: - listView.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); - break; - - case ccui.Layout.BG_COLOR_GRADIENT: - listView.setBackGroundColor(cc.color(start_red, start_green, start_blue), - cc.color(end_red, end_green, end_blue)); - listView.setBackGroundColorVector(cc.p(vector_color_x, vector_color_y)); - break; - - default: - break; - } - - listView.setBackGroundColorOpacity(color_opacity); - - switch (resourceType) - { - case 0: - { - listView.setBackGroundImage(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - listView.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - - if (path != "") - { - if (scale9Enabled) - { - listView.setBackGroundImageScale9Enabled(scale9Enabled); - listView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - listView.setContentSize(cc.size(width, height)); - } - } - -// listView.setBackGroundImageColor(cc.color(bgimg_red, bgimg_green, bgimg_blue)); -// listView.setBackGroundImageOpacity(bgimg_opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index 270418defa..59ac7cb23b 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -140,129 +140,5 @@ ccs.loadingBarReader = /** @lends ccs.LoadingBarReader# */{ // other commonly protperties ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var loadingBar = widget; - - var xmlPath = ccs.GUIReader.getFilePath(); - - var scale9Enabled = false; - var cx = 0, cy = 0, cw = 0, ch = 0; - var swf = 0, shf = 0; - var direction = 0; - - var percent = 0; - - var opacity = 255; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ProgressType") - { - direction = (value == "Left_To_Right") ? 0 : 1; - } - else if (name == "ProgressInfo") - { - percent = value; - } - else if (name == "Scale9Enable") - { - if (value == "True") - { - scale9Enabled = true; - } - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - else if (name == "Alpha") - { - opacity = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "ImageFileData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - loadingBar.loadTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - loadingBar.loadTexture(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - loadingBar.setDirection(direction); - loadingBar.setPercent(percent); - - loadingBar.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index 5a4efa2ddb..c0246bca0a 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -161,310 +161,6 @@ ccs.pageViewReader = /** @lends ccs.PageViewReader# */{ var flipY = widgetOptions["flipY"]; widget.setFlippedX(flipX); widget.setFlippedY(flipY); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var pageView = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var scale9Enabled = false; - var width = 0, height = 0; - var cx = 0, cy = 0, cw = 0, ch = 0; - - var colorType = ccui.Layout.BG_COLOR_NONE ; - var color_opacity = 255, bgimg_opacity = 255, opacity = 255; - var red = 255, green = 255, blue = 255; - var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; - var singleRed = 255, singleGreen = 255, singleBlue = 255; - var start_red = 255, start_green = 255, start_blue = 255; - var end_red = 255, end_green = 255, end_blue = 255; - var vector_color_x = 0, vector_color_y = -0.5; - - var resourceType = 0; - var path = "", plistFile = ""; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ClipAble") - { - pageView.setClippingEnabled((value == "True") ? true : false); - } - else if (name == "ComboBoxIndex") - { - colorType = value; - } - else if (name == "BackColorAlpha") - { - color_opacity = value; - } - else if (name == "Alpha") - { - opacity = value; - bgimg_opacity = value; - } - else if (name == "Scale9Enable") - { - scale9Enabled = (value == "True") ? true : false; - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "Size") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "CColor") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - red = value; - bgimg_red = value; - } - else if (name == "G") - { - green = value; - bgimg_green = value; - } - else if (name == "B") - { - blue = value; - bgimg_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "SingleColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - singleRed = value; - } - else if (name == "G") - { - singleGreen = value; - } - else if (name == "B") - { - singleBlue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "EndColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - end_red = value; - } - else if (name == "G") - { - end_green = value; - } - else if (name == "B") - { - end_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FirstColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - start_red = value; - } - else if (name == "G") - { - start_green = value; - } - else if (name == "B") - { - start_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "ColorVector") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - vector_color_x = value; - } - else if (name == "ScaleY") - { - vector_color_y = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FileData") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - } - - child = child.NextSiblingElement(); - } - - pageView.setColor(cc.color(red, green, blue)); - pageView.setOpacity(opacity); - - pageView.setBackGroundColorType(colorType); - switch (colorType) - { - case ccui.Layout.BG_COLOR_SOLID: - pageView.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); - break; - - case ccui.Layout.BG_COLOR_GRADIENT: - pageView.setBackGroundColor(cc.color(start_red, start_green, start_blue), - cc.color(end_red, end_green, end_blue)); - pageView.setBackGroundColorVector(cc.p(vector_color_x, vector_color_y)); - break; - - default: - break; - } - - pageView.setBackGroundColorOpacity(color_opacity); - - switch (resourceType) - { - case 0: - { - pageView.setBackGroundImage(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - pageView.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - - if (path != "") - { - if (scale9Enabled) - { - pageView.setBackGroundImageScale9Enabled(scale9Enabled); - pageView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - pageView.setContentSize(cc.size(width, height)); - } - } - -// pageView.setBackGroundImageColor(Color3B(bgimg_red, bgimg_green, bgimg_blue)); -// pageView.setBackGroundImageOpacity(bgimg_opacity); - } - }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index cd1f9b5e28..6c653d35c5 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -183,354 +183,5 @@ ccs.scrollViewReader = /** @lends ccs.ScrollViewReader# */{ var flipY = widgetOptions["flipY"]; widget.setFlippedX(flipX); widget.setFlippedY(flipY); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var scrollView = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var scale9Enabled = false; - var width = 0, height = 0; - var cx = 0, cy = 0, cw = 0, ch = 0.0; - - var colorType = ccui.Layout.BG_COLOR_NONE; - var color_opacity = 255, bgimg_opacity = 255, opacity = 255; - var red = 255, green = 255, blue = 255; - var bgimg_red = 255, bgimg_green = 255, bgimg_blue = 255; - var singleRed = 255, singleGreen = 255, singleBlue = 255; - var start_red = 255, start_green = 255, start_blue = 255; - var end_red = 255, end_green = 255, end_blue = 255; - var vector_color_x = 0, vector_color_y = -0; - - var direction = 1; - - var resourceType = 0; - var path = "", plistFile = ""; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ClipAble") - { - scrollView.setClippingEnabled((value == "True") ? true : false); - } - else if (name == "ComboBoxIndex") - { - colorType = value; - } - else if (name == "BackColorAlpha") - { - color_opacity = value; - } - else if (name == "Alpha") - { - opacity = value; - bgimg_opacity = value; - } - else if (name == "Scale9Enable") - { - scale9Enabled = (value == "True") ? true : false; - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - else if (name == "ScrollDirectionType") - { - if (value == "Vertical") - { - direction = 1; - } - else if (value == "Horizontal") - { - direction = 2; - } - else if (value == "Vertical_Horizontal") - { - direction = 3; - } - } - else if (name == "IsBounceEnabled") - { - scrollView.setBounceEnabled((value == "True") ? true : false); - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "InnerNodeSize") - { - var attribute = child.FirstAttribute(); - var width = 0, height = 0; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Width") - { - width = value; - } - else if (name == "Height") - { - height = value; - } - - attribute = attribute.Next(); - } - - ccui.scrollView.prototype.setInnerContainerSize.call(this, cc.size(width, height)); - } - else if (name == "Size") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "CColor") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - red = value; - bgimg_red = value; - } - else if (name == "G") - { - green = value; - bgimg_green = value; - } - else if (name == "B") - { - blue = value; - bgimg_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "SingleColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - singleRed = value; - } - else if (name == "G") - { - singleGreen = value; - } - else if (name == "B") - { - singleBlue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "EndColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - end_red = value; - } - else if (name == "G") - { - end_green = value; - } - else if (name == "B") - { - end_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FirstColor") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "R") - { - start_red = value; - } - else if (name == "G") - { - start_green = value; - } - else if (name == "B") - { - start_blue = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "ColorVector") - { - var attribute = child.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - vector_color_x = value; - } - else if (name == "ScaleY") - { - vector_color_y = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FileData") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - } - - child = child.NextSiblingElement(); - } - - scrollView.setColor(cc.color(red, green, blue)); - scrollView.setOpacity(opacity); - - scrollView.setBackGroundColorType(colorType); - switch (colorType) - { - case ccui.Layout.BG_COLOR_SOLID: - scrollView.setBackGroundColor(cc.color(singleRed, singleGreen, singleBlue)); - break; - - case ccui.Layout.BG_COLOR_GRADIENT: - scrollView.setBackGroundColor(cc.color(start_red, start_green, start_blue), - cc.color(end_red, end_green, end_blue)); - scrollView.setBackGroundColorVector(cc.p(vector_color_x, vector_color_y)); - break; - - default: - break; - } - - scrollView.setBackGroundColorOpacity(color_opacity); - - switch (resourceType) - { - case 0: - { - scrollView.setBackGroundImage(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - scrollView.setBackGroundImage(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - - if (path != "") - { - if (scale9Enabled) - { - scrollView.setBackGroundImageScale9Enabled(scale9Enabled); - scrollView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - scrollView.setContentSize(cc.size(width, height)); - } - } - - scrollView.setDirection(direction); - -// scrollView.setBackGroundImageColor(Color3B(bgimg_red, bgimg_green, bgimg_blue)); -// scrollView.setBackGroundImageOpacity(bgimg_opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index 1ff24cd619..3a2d755b5f 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -247,327 +247,5 @@ ccs.sliderReader = /** @lends ccs.SliderReader# */{ // other commonly protperties ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - - setPropsFromXML:function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var slider = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var scale9Enabled = false; - var cx = 0, cy = 0, cw = 0, ch = 0; - var swf = 0, shf = 0; - - var percent = 0; - - var opacity = 255; - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Scale9Enable") - { - if (value == "True") - { - scale9Enabled = true; - } - } - else if (name == "Scale9OriginX") - { - cx = value; - } - else if (name == "Scale9OriginY") - { - cy = value; - } - else if (name == "Scale9Width") - { - cw = value; - } - else if (name == "Scale9Height") - { - ch = value; - } - else if (name == "Length") - { - - } - else if (name == "PercentInfo") - { - percent = value; - } - else if (name == "DisplayState") - { - slider.setBright((value == "True") ? true : false); - if (value == "False") - { - slider.setTouchEnabled(false); - } - } - else if (name == "Alpha") - { - opacity = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "BackGroundData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - slider.loadBarTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - slider.loadBarTexture(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "BallNormalData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - slider.loadSlidBallTextureNormal(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - slider.loadSlidBallTextureNormal(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "BallPressedData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - slider.loadSlidBallTexturePressed(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - slider.loadSlidBallTexturePressed(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "BallDisabledData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - slider.loadSlidBallTextureDisabled(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - slider.loadSlidBallTextureDisabled(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - else if (name == "ProgressBarData") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - slider.loadProgressBarTexture(xmlPath + path, ccui.Widget.LOCAL_TEXTURE); - break; - } - - case 1: - { - cc.spriteFrameCache.addSpriteFrames(xmlPath + plistFile); - slider.loadProgressBarTexture(path, ccui.Widget.PLIST_TEXTURE); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - slider.setScale9Enabled(scale9Enabled); - - if (scale9Enabled) - { - slider.setCapInsets(cc.rect(cx, cy, cw, ch)); - slider.setContentSize(cc.size(swf, shf)); - } - - slider.setPercent(percent); - - slider.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index c4ab75a924..b9f8c7a1e3 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -168,161 +168,5 @@ ccs.textFieldReader = /** @lends ccs.TextFieldReader# */{ // other commonly protperties ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - - setPropsFromXML: function(widget, objectData){ - ccs.widgetReader.setPropsFromXML.call(this, widget, objectData); - - var textField = widget; - - var xmlPath = ccs.uiReader.getFilePath(); - - var isCustomSize = false; - var width = 0, height = 0; - - var opacity = 255; - - textField.setUnifySizeEnabled(false); - - textField.setFontName("微软雅黑"); - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "PlaceHolderText") - { - textField.setPlaceHolder(value); - } - else if (name == "LabelText") - { - textField.setText(value); - } - else if (name == "FontSize") - { - textField.setFontSize(value); - } - else if (name == "FontName") - { - textField.setFontName(value); - } - else if (name == "MaxLengthEnable") - { - textField.setMaxLengthEnabled((value == "True") ? true : false); - } - else if (name == "MaxLengthText") - { - textField.setMaxLength(value); - } - else if (name == "PasswordEnable") - { - textField.setPasswordEnabled((value == "True") ? true : false); - } - else if (name == "PasswordStyleText") - { - textField.setPasswordStyleText(value); - } - else if (name == "IsCustomSize") - { - isCustomSize = ((value == "True") ? true : false); -// if (value == "Custom") -// { -// var areaWidth = 0.0f; -// objectData.QueryFloatAttribute("Width", &areaWidth); -// -// var areaHeight = 0.0f; -// objectData.QueryFloatAttribute("Height", &areaHeight); -// -// textField.setTextAreaSize(Size(areaWidth, areaHeight)); -// } - } - else if (name == "Alpha") - { - opacity = value; - } - - attribute = attribute.Next(); - } - - // child elements - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - - if (name == "Size") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - } - else if (name == "FontResource") - { - var attribute = child.FirstAttribute(); - var resourceType = 0; - var path = "", plistFile = ""; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Path") - { - path = value; - } - else if (name == "Type") - { - resourceType = (value == "Normal" || value == "Default" || value == "MarkedSubImage") ? 0 : 1; - } - else if (name == "Plist") - { - plistFile = value; - } - - attribute = attribute.Next(); - } - - switch (resourceType) - { - case 0: - { - textField.setFontName(xmlPath + path); - break; - } - - default: - break; - } - } - - child = child.NextSiblingElement(); - } - - if (isCustomSize) - { - textField.ignoreContentAdaptWithSize(!isCustomSize); - textField.setContentSize(cc.size(width, height)); - } - - textField.setOpacity(opacity); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 36744840ca..1231a29488 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -315,239 +315,25 @@ ccs.widgetReader = /** @lends ccs.widgetReader# */{ widget.setFlippedY(flipY); }, - setPropsFromXML: function(widget, objectData){ - widget.setTouchEnabled(false); - - widget.setCascadeColorEnabled(true); - widget.setCascadeOpacityEnabled(true); - - widget.setUnifySizeEnabled(true); - - widget.setScale(0, 0); - - // attributes - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "Name") - { - var widgetName = value ? value :"default"; - widget.setName(widgetName); - } - else if (name == "ActionTag") - { - var actionTag = atoi(value); - widget.setUserObject(new ccs.Timeline.ActionTimelineData(actionTag)); - } - else if (name == "RotationSkewX") - { - widget.setRotationSkewX(value); - } - else if (name == "RotationSkewY") - { - widget.setRotationSkewY(value); - } - else if (name == "Rotation") - { -// widget.setRotation(atoi(value)); - } - else if (name == "ZOrder") - { - widget.setLocalZOrder(value); - } - else if (name == "Visible") - { - widget.setVisible((value == "True") ? true : false); - } - else if (name == "VisibleForFrame") - { -// widget.setVisible((value == "True") ? true : false); - } - else if (name == "Alpha") - { - widget.setOpacity(value); - } - else if (name == "Tag") - { - widget.setTag(value); - } - else if (name == "FlipX") - { - widget.setFlippedX((value == "True") ? true : false); - } - else if (name == "FlipY") - { - widget.setFlippedY((value == "True") ? true : false); - } - else if (name == "TouchEnable") - { - widget.setTouchEnabled((value == "True") ? true : false); - } - else if (name == "ControlSizeType") - { - widget.ignoreContentAdaptWithSize((value == "Auto") ? true : false); - } - - attribute = attribute.Next(); - } - - var child = objectData.FirstChildElement(); - while (child) - { - var name = child.Name(); - if (name == "Children") - { - break; - } - else if (name == "Position") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - widget.setPositionX(value); - } - else if (name == "Y") - { - widget.setPositionY(value); - } - - attribute = attribute.Next(); - } - } - else if (name == "Scale") - { - var attribute = child.FirstAttribute(); - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - widget.setScaleX(value); - } - else if (name == "ScaleY") - { - widget.setScaleY(value); - } - - attribute = attribute.Next(); - } - } - else if (name == "AnchorPoint") - { - var attribute = child.FirstAttribute(); - var anchor_x = 0, anchor_y = 0; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ScaleX") - { - anchor_x = value; - } - else if (name == "ScaleY") - { - anchor_y = value; - } - - attribute = attribute.Next(); - } - - widget.setAnchorPoint(cc.p(anchor_x, anchor_y)); - } - else if (name == "CColor") - { - var attribute = child.FirstAttribute(); - var red = 255, green = 255, blue = 255; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "A") - { - widget.setOpacity(atoi(value)); - } - else if (name == "R") - { - red = value; - } - else if (name == "G") - { - green = value; - } - else if (name == "B") - { - blue = value; - } - - attribute = attribute.Next(); - } - - widget.setColor(cc.color(red, green, blue)); - } - else if (name == "Size") - { - var attribute = child.FirstAttribute(); - var width = 0, height = 0; - - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "X") - { - width = value; - } - else if (name == "Y") - { - height = value; - } - - attribute = attribute.Next(); - } - - widget.setContentSize(cc.size(width, height)); - } - - child = child.NextSiblingElement(); - } - }, - setAnchorPointForWidget: function(widget, nodeTree){ - var options = nodeTree.widgetOptions; + var options = nodeTree["widgetOptions"]; - var isAnchorPointXExists = options.anchorPointX; + var isAnchorPointXExists = options["anchorPointX"]; var anchorPointXInFile; if (isAnchorPointXExists) { - anchorPointXInFile = options.anchorPointX; + anchorPointXInFile = options["anchorPointX"]; } else { anchorPointXInFile = widget.getAnchorPoint().x; } - var isAnchorPointYExists = options.anchorPointY; + var isAnchorPointYExists = options["anchorPointY"]; var anchorPointYInFile; if (isAnchorPointYExists) { - anchorPointYInFile = options.anchorPointY; + anchorPointYInFile = options["anchorPointY"]; } else { From bdfb6be6cb6ef2cf84bf226a9c390d2760c7ca08 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 10:46:09 +0800 Subject: [PATCH 0818/1564] Issue #5983: fixed error --- extensions/ccui/base-classes/UIWidget.js | 89 ++++---------------- extensions/ccui/layouts/UILayoutComponent.js | 20 ++--- 2 files changed, 28 insertions(+), 81 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 2a96d9a287..3a94b3fb02 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -142,13 +142,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ onEnter: function () { this.updateSizeAndPosition(); cc.ProtectedNode.prototype.onEnter.call(this); - //todo dolayout -// if (this._positionType == PositionType.PERCENT -// || this._sizeType == SizeType.PERCENT) { -// if (this._parent) { -// ccui.Helper.doLayout(this._parent); -// } -// } }, /** @@ -194,11 +187,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _updateContentSizeWithTextureSize: function(size){ -// if (this._unifySize) -// { -// this.setContentSize(size); -// return; -// } this.setContentSize(this._ignoreSize ? size : this._customSize); }, @@ -303,9 +291,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._customSize.width = locWidth; this._customSize.height = locHeight; -// if (this._unifySize){ -// //unify Size logic -// }else if (this._ignoreSize){ this._contentSize = this.getVirtualRendererSize(); } @@ -351,15 +336,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setSizePercent: function (percent) { -// var component = this.getOrCreateLayoutComponent(); -// component.setUsingPercentContentSize(true); -// component.setPercentContentSize(percent); - -// if (null != this._parent) -// { -// ccui.Helper.prototype.doLayout.call(this, this._parent); -// } - this._sizePercent.x = percent.x; this._sizePercent.y = percent.y; var width = this._customSize.width, height = this._customSize.height; @@ -474,16 +450,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setSizeType: function (type) { this._sizeType = type; -// var component = this.getOrCreateLayoutComponent(); -// -// if (this._sizeType == ccui.Widget.SIZE_PERCENT) -// { -// component.setUsingPercentContentSize(true); -// } -// else -// { -// component.setUsingPercentContentSize(false); -// } }, /** @@ -499,10 +465,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} ignore true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ ignoreContentAdaptWithSize: function (ignore) { -// if (this._unifySize){ -// this.setContentSize(this._customSize); -// return; -// }else if(this._ignoreSize == ignore) return; @@ -1071,24 +1033,24 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Number} [posY] */ setPosition: function (pos, posY) { -// if (this._running) { -// var widgetParent = this.getWidgetParent(); -// if (widgetParent) { -// var pSize = widgetParent.getContentSize(); -// if (pSize.width <= 0 || pSize.height <= 0) { -// this._positionPercent.x = 0; -// this._positionPercent.y = 0; -// } else { -// if (posY == undefined) { -// this._positionPercent.x = pos.x / pSize.width; -// this._positionPercent.y = pos.y / pSize.height; -// } else { -// this._positionPercent.x = pos / pSize.width; -// this._positionPercent.y = posY / pSize.height; -// } -// } -// } -// } + if (this._running) { + var widgetParent = this.getWidgetParent(); + if (widgetParent) { + var pSize = widgetParent.getContentSize(); + if (pSize.width <= 0 || pSize.height <= 0) { + this._positionPercent.x = 0; + this._positionPercent.y = 0; + } else { + if (posY == undefined) { + this._positionPercent.x = pos.x / pSize.width; + this._positionPercent.y = pos.y / pSize.height; + } else { + this._positionPercent.x = pos / pSize.width; + this._positionPercent.y = posY / pSize.height; + } + } + } + } cc.Node.prototype.setPosition.call(this, pos, posY); this._positionType = ccui.Widget.POSITION_ABSOLUTE; @@ -1128,8 +1090,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Point} percent */ setPositionPercent: function (percent) { -// this.setNormalizedPosition(percent); -// this._positionType = PositionType.PERCENT; this._positionPercent = percent; if (this._running) { var widgetParent = this.getWidgetParent(); @@ -1178,19 +1138,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ setPositionType: function (type) { this._positionType = type; this.setNodeDirty(); -// if (type == ccui.Widget.POSITION_ABSOLUTE) -// { -// var oldPosition = this.getPosition(); -// this.setPosition(this.getPosition() + cc.p(10,0)); -// this.setPosition(oldPosition); -// } -// else -// { - //todo check here -// var oldNormalizedPosition = cc._position;//this.getNormalizedPosition(); -// this.setNormalizedPosition(oldNormalizedPosition + cc.p(0.2,0.1)); -// this.setNormalizedPosition(oldNormalizedPosition); -// } }, /** diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index 15d7966347..1d175ae510 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -116,7 +116,7 @@ ccui.LayoutComponent = cc.Component.extend({ if ( pType == LayoutComponent_PositionType.PreRelativePosition) { this._percentPosition = point; - basePoint = cc.p(_percentPosition.x*parentSize.width,_percentPosition.y*parentSize.height); + basePoint = cc.p(this._percentPosition.x * parentSize.width, this._percentPosition.y * parentSize.height); } else if(pType == LayoutComponent_PositionType.PreRelativePositionEnable) { @@ -124,25 +124,25 @@ ccui.LayoutComponent = cc.Component.extend({ { if (parentSize.width != 0) { - _percentPosition.x = _relativePosition.x/parentSize.width; + this._percentPosition.x = this._relativePosition.x / parentSize.width; } else { - _percentPosition.x = 0; - _relativePosition.x = 0; + this._percentPosition.x = 0; + this._relativePosition.x = 0; } if (parentSize.height != 0) { - _percentPosition.y = _relativePosition.y/parentSize.height; + this._percentPosition.y = this._relativePosition.y / parentSize.height; } else { - _percentPosition.y = 0; - _relativePosition.y = 0; + this._percentPosition.y = 0; + this._relativePosition.y = 0; } } - basePoint = _relativePosition; + basePoint = this._relativePosition; } var inversePoint = basePoint; @@ -169,7 +169,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._relativePosition = inversePoint; if (parentSize.width != 0 && parentSize.height != 0) { - this._percentPosition = cc.p(this._relativePosition.x/parentSize.width,this._relativePosition.y/parentSize.height); + this._percentPosition = cc.p(this._relativePosition.x / parentSize.width, this._relativePosition.y / parentSize.height); } else { @@ -181,7 +181,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._relativePosition = basePoint; if (parentSize.width != 0 && parentSize.height != 0) { - this._percentPosition = cc.p(this._relativePosition.x/parentSize.width,this._relativePosition.y/parentSize.height); + this._percentPosition = cc.p(this._relativePosition.x / parentSize.width, this._relativePosition.y / parentSize.height); } else { From 4d2fb1cf378717add5a27f8c305ae9b558c2707a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 11:41:36 +0800 Subject: [PATCH 0819/1564] Issue #5983: __LAYOUT_COMPONENT_NAME -> ccs.__LAYOUT_COMPONENT_NAME --- extensions/ccui/base-classes/UIWidget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 3a94b3fb02..5590a119fe 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ -var __LAYOUT_COMPONENT_NAME = "__ui_layout"; +ccs.__LAYOUT_COMPONENT_NAME = "__ui_layout"; /** * The base class for ccui controls and layout @@ -154,7 +154,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, getOrCreateLayoutComponent: function(){ - var layoutComponent = this.getComponent(__LAYOUT_COMPONENT_NAME); + var layoutComponent = this.getComponent(ccs.__LAYOUT_COMPONENT_NAME); if (null == layoutComponent){ var component = new ccui.LayoutComponent(); this.addComponent(component); From f617c968b0b7d313daf78bde7fd8a34608ab8aeb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 11:44:42 +0800 Subject: [PATCH 0820/1564] Issue #5983: Modify the error message --- CCBoot.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 0159b5e88c..5484d8827f 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -704,8 +704,7 @@ cc.loader = /** @lends cc.loader# */{ }, loadCsb: function(url, cb){ - var xhr = new XMLHttpRequest(), - errInfo = "load " + url + " failed!"; + var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; @@ -715,7 +714,7 @@ cc.loader = /** @lends cc.loader# */{ window.msg = arrayBuffer; } if(xhr.readyState == 4) - xhr.status == 200 ? cb(null, xhr.response) : cb(errInfo); + xhr.status == 200 ? cb(null, xhr.response) : cb("load " + url + " failed!"); }; xhr.send(null); From c6541de2afbe2759806b29f87f94c261b88d00cb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 11:47:03 +0800 Subject: [PATCH 0821/1564] Issue #5983: ccs -> ccui --- extensions/ccui/base-classes/UIWidget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 5590a119fe..4edac18fbe 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ -ccs.__LAYOUT_COMPONENT_NAME = "__ui_layout"; +ccui.__LAYOUT_COMPONENT_NAME = "__ui_layout"; /** * The base class for ccui controls and layout @@ -154,7 +154,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, getOrCreateLayoutComponent: function(){ - var layoutComponent = this.getComponent(ccs.__LAYOUT_COMPONENT_NAME); + var layoutComponent = this.getComponent(ccui.__LAYOUT_COMPONENT_NAME); if (null == layoutComponent){ var component = new ccui.LayoutComponent(); this.addComponent(component); From 0ad9f6de19765f866074488accb832cdb68644a0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 11:51:30 +0800 Subject: [PATCH 0822/1564] Issue #5983: Modify param to ccui --- extensions/ccui/layouts/UILayoutComponent.js | 60 ++++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index 1d175ae510..b22d7b1a0e 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -23,19 +23,19 @@ THE SOFTWARE. ****************************************************************************/ -var LayoutComponent_ReferencePoint = { +ccui.LayoutComponent_ReferencePoint = { BOTTOM_LEFT: 0, TOP_LEFT: 1, BOTTOM_RIGHT: 2, TOP_RIGHT: 3 }; -var LayoutComponent_PositionType = { +ccui.LayoutComponent_PositionType = { Position: 0, RelativePosition: 1, PreRelativePosition: 2, PreRelativePositionEnable: 3 }; -var LayoutComponent_SizeType = { +ccui.LayoutComponent_SizeType = { Size: 0, PreSize: 1, PreSizeEnable: 2 @@ -46,7 +46,7 @@ ccui.LayoutComponent = cc.Component.extend({ _percentContentSize: null, _usingPercentContentSize: false, - _referencePoint: LayoutComponent_ReferencePoint.BOTTOM_LEFT, + _referencePoint: ccui.LayoutComponent_ReferencePoint.BOTTOM_LEFT, _relativePosition: null, _percentPosition: null, _usingPercentPosition: false, @@ -74,26 +74,26 @@ ccui.LayoutComponent = cc.Component.extend({ }, setUsingPercentPosition: function(flag){ this._usingPercentPosition = flag; - this.RefreshLayoutPosition(LayoutComponent_PositionType.PreRelativePositionEnable, cc.p(0,0)); + this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.PreRelativePositionEnable, cc.p(0,0)); }, getPercentPosition: function(){ return this._percentPosition; }, setPercentPosition: function(percent){ - this.RefreshLayoutPosition(LayoutComponent_PositionType.PreRelativePosition, percent); + this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.PreRelativePosition, percent); }, getRelativePosition: function(){ return this._relativePosition; }, setRelativePosition: function(position){ - this.RefreshLayoutPosition(LayoutComponent_PositionType.RelativePosition, position); + this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.RelativePosition, position); }, setReferencePoint: function(point){ this._referencePoint = point; - this.RefreshLayoutPosition(LayoutComponent_PositionType.RelativePosition, this._relativePosition) + this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.RelativePosition, this._relativePosition) }, getReferencePoint: function(){ return this._referencePoint; @@ -103,7 +103,7 @@ ccui.LayoutComponent = cc.Component.extend({ return this.getOwner().getPosition(); }, setOwnerPosition: function(point){ - this.RefreshLayoutPosition(LayoutComponent_PositionType.Position, point); + this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.Position, point); }, RefreshLayoutPosition: function(pType, point){ @@ -113,12 +113,12 @@ ccui.LayoutComponent = cc.Component.extend({ { var parentSize = parentNode.getContentSize(); - if ( pType == LayoutComponent_PositionType.PreRelativePosition) + if ( pType == ccui.LayoutComponent_PositionType.PreRelativePosition) { this._percentPosition = point; basePoint = cc.p(this._percentPosition.x * parentSize.width, this._percentPosition.y * parentSize.height); } - else if(pType == LayoutComponent_PositionType.PreRelativePositionEnable) + else if(pType == ccui.LayoutComponent_PositionType.PreRelativePositionEnable) { if (this._usingPercentPosition) { @@ -148,13 +148,13 @@ ccui.LayoutComponent = cc.Component.extend({ var inversePoint = basePoint; switch (this._referencePoint) { - case LayoutComponent_ReferencePoint.TOP_LEFT: + case ccui.LayoutComponent_ReferencePoint.TOP_LEFT: inversePoint.y = parentSize.height - inversePoint.y; break; - case LayoutComponent_ReferencePoint.BOTTOM_RIGHT: + case ccui.LayoutComponent_ReferencePoint.BOTTOM_RIGHT: inversePoint.x = parentSize.width - inversePoint.x; break; - case LayoutComponent_ReferencePoint.TOP_RIGHT: + case ccui.LayoutComponent_ReferencePoint.TOP_RIGHT: inversePoint.x = parentSize.width - inversePoint.x; inversePoint.y = parentSize.height - inversePoint.y; break; @@ -164,7 +164,7 @@ ccui.LayoutComponent = cc.Component.extend({ switch (pType) { - case LayoutComponent_PositionType.Position: + case ccui.LayoutComponent_PositionType.Position: this.getOwner().setPosition(basePoint); this._relativePosition = inversePoint; if (parentSize.width != 0 && parentSize.height != 0) @@ -176,7 +176,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._percentPosition = cc.p(0,0); } break; - case LayoutComponent_PositionType.RelativePosition: + case ccui.LayoutComponent_PositionType.RelativePosition: this.getOwner().setPosition(inversePoint); this._relativePosition = basePoint; if (parentSize.width != 0 && parentSize.height != 0) @@ -188,11 +188,11 @@ ccui.LayoutComponent = cc.Component.extend({ this._percentPosition = cc.p(0,0); } break; - case LayoutComponent_PositionType.PreRelativePosition: + case ccui.LayoutComponent_PositionType.PreRelativePosition: this.getOwner().setPosition(inversePoint); this._relativePosition = basePoint; break; - case LayoutComponent_PositionType.PreRelativePositionEnable: + case ccui.LayoutComponent_PositionType.PreRelativePositionEnable: this.getOwner().setPosition(inversePoint); this._relativePosition = basePoint; break; @@ -204,17 +204,17 @@ ccui.LayoutComponent = cc.Component.extend({ { switch (pType) { - case LayoutComponent_PositionType.Position: + case ccui.LayoutComponent_PositionType.Position: this.getOwner().setPosition(basePoint); - if (this._referencePoint == LayoutComponent_ReferencePoint.BOTTOM_LEFT) + if (this._referencePoint == ccui.LayoutComponent_ReferencePoint.BOTTOM_LEFT) { this._relativePosition = basePoint; } break; - case LayoutComponent_PositionType.RelativePosition: + case ccui.LayoutComponent_PositionType.RelativePosition: this._relativePosition = basePoint; break; - case LayoutComponent_PositionType.PreRelativePosition: + case ccui.LayoutComponent_PositionType.PreRelativePosition: this._percentPosition = basePoint; break; default: @@ -227,14 +227,14 @@ ccui.LayoutComponent = cc.Component.extend({ return this.getOwner().getContentSize(); }, setOwnerContentSize: function(percent){ - this.RefreshLayoutSize(LayoutComponent_SizeType.Size, percent); + this.RefreshLayoutSize(ccui.LayoutComponent_SizeType.Size, percent); }, getPercentContentSize: function(){ return this._percentContentSize; }, setPercentContentSize: function(percent){ - this.RefreshLayoutSize(LayoutComponent_SizeType.PreSize, percent); + this.RefreshLayoutSize(ccui.LayoutComponent_SizeType.PreSize, percent); }, isUsingPercentContentSize: function(){ @@ -242,7 +242,7 @@ ccui.LayoutComponent = cc.Component.extend({ }, setUsingPercentContentSize: function(flag){ this._usingPercentContentSize = flag; - this.RefreshLayoutSize(LayoutComponent_SizeType.PreSizeEnable, cc.p(0,0)); + this.RefreshLayoutSize(ccui.LayoutComponent_SizeType.PreSizeEnable, cc.p(0,0)); }, RefreshLayoutSize: function(sType, size){ @@ -253,7 +253,7 @@ ccui.LayoutComponent = cc.Component.extend({ switch (sType) { - case LayoutComponent_SizeType.Size: + case ccui.LayoutComponent_SizeType.Size: if (parentSize.width != 0 && parentSize.height != 0) { this._percentContentSize = cc.p(size.x/parentSize.width,size.y/parentSize.height); @@ -264,14 +264,14 @@ ccui.LayoutComponent = cc.Component.extend({ } this.getOwner().setContentSize(cc.size(size.x,size.y)); break; - case LayoutComponent_SizeType.PreSize: + case ccui.LayoutComponent_SizeType.PreSize: cc.p_percentContentSize = size; if (this._usingPercentContentSize) { this.getOwner().setContentSize(cc.size(size.x*parentSize.width,size.y*parentSize.height)); } break; - case LayoutComponent_SizeType.PreSizeEnable: + case ccui.LayoutComponent_SizeType.PreSizeEnable: if (this._usingPercentContentSize) { var baseSize = this.getOwner().getContentSize(); @@ -306,10 +306,10 @@ ccui.LayoutComponent = cc.Component.extend({ { switch (sType) { - case LayoutComponent_SizeType.Size: + case ccui.LayoutComponent_SizeType.Size: this.getOwner().setContentSize(cc.size(size.x,size.y)); break; - case LayoutComponent_SizeType.PreSize: + case ccui.LayoutComponent_SizeType.PreSize: this._percentContentSize = size; break; default: From 4009c65fc19afc0dbd01f4a1a9aea215ecd8f474 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 11:57:25 +0800 Subject: [PATCH 0823/1564] Issue #5983: Remove UISlider setContentSize --- extensions/ccui/uiwidgets/UISlider.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 734e36a316..0b7756a1a6 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -150,13 +150,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); }, - setContentSize: function(a, b){ - ccui.Widget.prototype.setContentSize.call(this,a , b); - if(this._scale9Enabled){ - this._barRenderer.setContentSize(a, b); - } - }, - /** * Loads dark state texture for slider progress bar. * @param {String} fileName From 76d54355f3edb667042aa3ea59ac5c2c7f68c89f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 18 Oct 2014 12:11:19 +0800 Subject: [PATCH 0824/1564] Issue #5983: remove getInstance --- .../reader/timeline/ActionTimelineCache.js | 84 ++++---- .../cocostudio/reader/timeline/CSLoader.js | 192 +++++++++--------- .../widgetreader/ButtonReader/ButtonReader.js | 8 - .../CheckBoxReader/CheckBoxReader.js | 8 - .../ImageViewReader/ImageViewReader.js | 8 - .../LabelAtlasReader/LabelAtlasReader.js | 8 - .../LabelBMFontReader/LabelBMFontReader.js | 8 - .../widgetreader/LabelReader/LabelReader.js | 8 - .../widgetreader/LayoutReader/LayoutReader.js | 8 - .../ListViewReader/ListViewReader.js | 8 - .../LoadingBarReader/LoadingBarReader.js | 8 - .../PageViewReader/PageViewReader.js | 8 - .../ScrollViewReader/ScrollViewReader.js | 8 - .../widgetreader/SliderReader/SliderReader.js | 8 - .../TextFieldReader/TextFieldReader.js | 8 - .../reader/widgetreader/WidgetReader.js | 8 - 16 files changed, 138 insertions(+), 250 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index 0f527591a9..5ece9e17cd 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -var actionTimelineCacheStatic = { +ccui.actionTimelineCacheStatic = { FrameType_VisibleFrame : "VisibleFrame", FrameType_PositionFrame : "PositionFrame", FrameType_ScaleFrame : "ScaleFrame", @@ -163,17 +163,17 @@ ccs.actionTimelineCache = { if(action) return action; - var json = content[actionTimelineCacheStatic.ACTION]; + var json = content[ccui.actionTimelineCacheStatic.ACTION]; action = new ccs.ActionTimeline(); - action.setDuration(json[actionTimelineCacheStatic.DURATION]); - action.setTimeSpeed(json[actionTimelineCacheStatic.TIME_SPEED] || 1); + action.setDuration(json[ccui.actionTimelineCacheStatic.DURATION]); + action.setTimeSpeed(json[ccui.actionTimelineCacheStatic.TIME_SPEED] || 1); - var timelineLength = json[actionTimelineCacheStatic.TIMELINES].length; + var timelineLength = json[ccui.actionTimelineCacheStatic.TIMELINES].length; for (var i = 0; i Date: Sat, 18 Oct 2014 16:22:51 +0800 Subject: [PATCH 0825/1564] rename CSLoader to csLoader --- .../reader/timeline/ActionTimelineCache.js | 2 +- .../cocostudio/reader/timeline/CSLoader.js | 56 +++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index 5ece9e17cd..2b89ffaea8 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -382,7 +382,7 @@ ccs.actionTimelineCache = { var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); if(spriteFrame == null) { - var jsonPath = ccs.CSLoader.getJsonPath(); + var jsonPath = ccs.csLoader.getJsonPath(); path = jsonPath + texture; } diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index 12003b7ecb..ff7e0cd4cd 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -100,7 +100,7 @@ ccui.CSLoaderStatic = { MONO_COCOS2D_VERSION : "cocos2dVersion" }; -ccs.CSLoader = { +ccs.csLoader = { _recordJsonPath: true, _jsonPath: "", @@ -112,31 +112,31 @@ ccs.CSLoader = { this._funcs = {}; this._componentFuncs = {}; - this._funcs[ccui.CSLoaderStatic.ClassName_Node] = ccs.CSLoader.loadSimpleNode.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_SubGraph] = ccs.CSLoader.loadSubGraph.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Sprite] = ccs.CSLoader.loadSprite.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Particle] = ccs.CSLoader.loadParticle.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_TMXTiledMap] = ccs.CSLoader.loadTMXTiledMap.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_LabelAtlas] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_LabelBMFont] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Panel] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Button] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_CheckBox] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_ImageView] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_TextAtlas] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_TextBMFont] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Text] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_LoadingBar] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_TextField] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Slider] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Layout] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_ScrollView] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_ListView] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_PageView] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Widget] = ccs.CSLoader.loadWidget.bind(this); - this._funcs[ccui.CSLoaderStatic.ClassName_Label] = ccs.CSLoader.loadWidget.bind(this); - - this._componentFuncs[ccui.CSLoaderStatic.ClassName_ComAudio] = ccs.CSLoader.loadComAudio.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Node] = ccs.csLoader.loadSimpleNode.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_SubGraph] = ccs.csLoader.loadSubGraph.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Sprite] = ccs.csLoader.loadSprite.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Particle] = ccs.csLoader.loadParticle.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_TMXTiledMap] = ccs.csLoader.loadTMXTiledMap.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_LabelAtlas] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_LabelBMFont] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Panel] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Button] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_CheckBox] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_ImageView] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_TextAtlas] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_TextBMFont] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Text] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_LoadingBar] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_TextField] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Slider] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Layout] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_ScrollView] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_ListView] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_PageView] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Widget] = ccs.csLoader.loadWidget.bind(this); + this._funcs[ccui.CSLoaderStatic.ClassName_Label] = ccs.csLoader.loadWidget.bind(this); + + this._componentFuncs[ccui.CSLoaderStatic.ClassName_ComAudio] = ccs.csLoader.loadComAudio.bind(this); }, @@ -146,7 +146,7 @@ ccs.CSLoader = { var suffix = path.substr(pos + 1, path.length); //cc.log("suffix = %s", suffix); - var load = ccs.CSLoader; + var load = ccs.csLoader; if (suffix == "csb") { @@ -1250,4 +1250,4 @@ ccs.CSLoader = { */ }; -ccs.CSLoader.init(); \ No newline at end of file +ccs.csLoader.init(); \ No newline at end of file From 1ee46fbcb3c863f7d14d5ba2b0b8a00b7adc2980 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 18 Oct 2014 17:07:50 +0800 Subject: [PATCH 0826/1564] Fixed #5990: Improve Facebook SDK --- external/pluginx/platform/facebook.js | 156 ++++++++++++-------------- 1 file changed, 71 insertions(+), 85 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index e5e513a7ca..6e243375f3 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -178,7 +178,7 @@ plugin.extend('facebook', { self._isLoggedIn = false; self._userInfo = {}; typeof callback === 'function' && callback(response['error_code'] || 1, { - error_message: "unknown" + error_message: response['error_message'] || "Unknown error" }); } }, { @@ -215,7 +215,7 @@ plugin.extend('facebook', { typeof callback === 'function' && callback(0, {"isLoggedIn": false}); } else { typeof callback === 'function' && callback(response['error_code'] || 1, { - error_message: response['error_message'] || "Unknown" + error_message: response['error_message'] || "Unknown error" }); } }); @@ -246,7 +246,7 @@ plugin.extend('facebook', { self._isLoggedIn = false; self._userInfo = {}; typeof callback === 'function' && callback(response['error_code'] || 1, { - error_message: response['error_message'] || "Unknown" + error_message: response['error_message'] || "Unknown error" }); } }, { @@ -294,12 +294,12 @@ plugin.extend('facebook', { post_id: response['post_id'] }); else - typeof callback === 'function' && callback(response.error_code || 1, { - error_message: "Unknown" + typeof callback === 'function' && callback(response['error_code'] || 1, { + error_message: response['error_message'] || "Unknown error" }); } else { typeof callback === 'function' && callback(1, { - error_message: "Unknown" + error_message: "Unknown error" }); } }); @@ -323,73 +323,76 @@ plugin.extend('facebook', { }); return; } - if (info['dialog'] === 'shareLink') { - if (info['link']) { - info['method'] = 'share'; - info['href'] = info['link']; - } - } else { - // Compatible with feed_dialog - if (info['dialog'] == 'feedDialog') { - info['dialog'] = 'share'; - } - - info['method'] = info['dialog']; - delete info['dialog']; - info['name'] = info['site'] || info['name']; - delete info['site']; - - info['href'] = info['siteUrl'] || info['link']; - delete info['siteUrl']; - delete info['link']; - - info['image'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; - delete info['imageUrl']; - delete info['imagePath']; - delete info['photo']; + // Preprocess properties + info['name'] = info['name'] || info['site']; + delete info['site']; + info['href'] = info['href'] || info['link'] || info['siteUrl']; + delete info['siteUrl']; + delete info['link']; - info['caption'] = info['title'] || info['caption']; - delete info['title']; + info['picture'] = info['picture'] || info['image'] || info['photo'] || info['imageUrl'] || info['imagePath']; + delete info['imageUrl']; + delete info['imagePath']; + delete info['photo']; + delete info['image']; - info['description'] = info['text'] || info['description']; - delete info['text']; + info['caption'] = info['title'] || info['caption']; + delete info['title']; - if (info['method'] == 'shareOpenGraph') { - info['method'] = "share_open_graph" - if (info['url']) { - var obj = {}; - if (info["preview_property_name"]) - obj[info["preview_property_name"]] = info["url"]; - else - obj["object"] = info["url"]; + info['description'] = info['text'] || info['description']; + delete info['text']; - for (var p in info) { - if (p != "method" && p != "action_type" && p != "action_properties") { - info[p] && (obj[p] = info[p]); - delete info[p]; - } + var method = info['dialog']; + delete info['dialog']; + + if (method === 'shareLink' || method == 'feedDialog') { + info['method'] = 'share'; + } else if (method == 'messageLink') { + info['method'] = 'send'; + info['link'] = info['href']; + } else if (method == 'shareOpenGraph') { + info['method'] = 'share_open_graph'; + + if (info['url']) { + var obj = {}; + if (info["preview_property_name"]) + obj[info["preview_property_name"]] = info["url"]; + else + obj["object"] = info["url"]; + + for (var p in info) { + if (p != "method" && p != "action_type" && p != "action_properties") { + info[p] && (obj[p] = info[p]); + delete info[p]; } - - info['action_properties'] = JSON.stringify(obj); } + + info['action_properties'] = JSON.stringify(obj); } } FB.ui(info, function (response) { - if (response) { - if (response['post_id']) - typeof callback === 'function' && callback(0, { + if (response && typeof callback === 'function') { + if (response['post_id'] || response['success']) { + callback(0, { didComplete: true, - post_id: response['post_id'] + post_id: response['post_id'] || "" }); - else - typeof callback === 'function' && callback(0, response); - } else { - typeof callback === 'function' && callback(1, { - error_message: "Unknow error" + } + else { + if (response['error_code']) { + callback(response['error_code'], { + error_message : response['error_message'] || 'Unknown error' + }); + } + else callback(0, response); + } + } else if (response == undefined && typeof callback === 'function') { + callback(1, { + error_message: "Unknown error" }); } }); @@ -424,7 +427,7 @@ plugin.extend('facebook', { FB.api(path, httpmethod, params, function (response) { if (response.error) { typeof callback === 'function' && callback(response['error']['code'], { - error_message: response['error']['message'] || 'Unknown' + error_message: response['error']['message'] || 'Unknown error' }) } else { typeof callback === 'function' && callback(0, response); @@ -448,7 +451,7 @@ plugin.extend('facebook', { if (!response['error']) response['error'] = {}; typeof callback == 'function' && callback(response['error']['code'] || 1, { - error_message: response['error']['message'] || 'Unknown' + error_message: response['error']['message'] || 'Unknown error' }); } }) @@ -473,7 +476,7 @@ plugin.extend('facebook', { FB.ui(info, function (response) { if (response['error_code']) { callback(response['error_code'] || 1, { - error_message: response['error_message'] || 'Unknown' + error_message: response['error_message'] || response['error_msg'] || 'Unknown error' }); } else { callback(0, response); @@ -497,37 +500,20 @@ plugin.extend('facebook', { info['method'] = "apprequests"; - info['name'] = info['site'] || info['name']; - delete info['site']; - - info['href'] = info['siteUrl'] || info['link']; - delete info['siteUrl']; - delete info['link']; - - info['image'] = info['imageUrl'] || info['imagePath'] || info['photo'] || info['picture'] || info['image']; - delete info['imageUrl']; - delete info['imagePath']; - delete info['photo']; - - info['caption'] = info['title'] || info['caption']; - delete info['title']; - - info['description'] = info['text'] || info['description']; - delete info['text']; - FB.ui(info, function (response) { if (response) { - if (response['post_id']) - typeof callback === 'function' && callback(0, { - didComplete: true, - post_id: response['post_id'] + if (response['error_code']) { + typeof callback === 'function' && callback(response['error_code'], { + error_message : response['error_message'] || 'Unknown error' }); - else + } + else { typeof callback === 'function' && callback(0, response); + } } else { typeof callback === 'function' && callback(1, { - error_message: "Unknow error" + error_message: "Unknown error" }); } }); From 6a1365b507a7a20cbe2aec44ba7265b62f07745f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 20 Oct 2014 11:53:44 +0800 Subject: [PATCH 0827/1564] Fixed #5991: Do not reset progression on ProgressTo start --- cocos2d/progress-timer/CCActionProgressTimer.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cocos2d/progress-timer/CCActionProgressTimer.js b/cocos2d/progress-timer/CCActionProgressTimer.js index 18f6500e7b..026af89750 100644 --- a/cocos2d/progress-timer/CCActionProgressTimer.js +++ b/cocos2d/progress-timer/CCActionProgressTimer.js @@ -89,11 +89,6 @@ cc.ProgressTo = cc.ActionInterval.extend(/** @lends cc.ProgressTo# */{ startWithTarget:function (target) { cc.ActionInterval.prototype.startWithTarget.call(this, target); this._from = target.percentage; - - // XXX: Is this correct ? - // Adding it to support CCRepeat - if (this._from == 100) - this._from = 0; }, /** From 23c8cb039509b3dc78d219efbf7726148fcb40c4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 14:15:42 +0800 Subject: [PATCH 0828/1564] checking create --- cocos2d/actions/CCActionInterval.js | 2 ++ cocos2d/core/event-manager/CCEventListener.js | 1 + cocos2d/core/event-manager/CCEventManager.js | 2 +- cocos2d/menus/CCMenu.js | 1 + cocos2d/menus/CCMenuItem.js | 2 +- extensions/cocostudio/armature/display/CCSkin.js | 2 +- 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 1d83b50f7d..5fd9213b5d 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -491,6 +491,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ * * // create sequence with array * var seq = cc.sequence(actArray); + * todo: It should be use new */ cc.sequence = function (/*Multiple Arguments*/tempArray) { var paramArray = (tempArray instanceof Array) ? tempArray : arguments; @@ -975,6 +976,7 @@ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{ * @example * // example * var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720)); + * todo:It should be the direct use new */ cc.spawn = function (/*Multiple Arguments*/tempArray) { var paramArray = (tempArray instanceof Array) ? tempArray : arguments; diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 8bf14c0b2c..2df66a3458 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -432,6 +432,7 @@ cc._EventListenerTouchAllAtOnce.create = function(){ * @static * @param {object} argObj a json object * @returns {cc.EventListener} + * todo: It should be the direct use new * @example * cc.EventListener.create({ * event: cc.EventListener.TOUCH_ONE_BY_ONE, diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index be7b68f5bd..13b5d7e0a1 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -691,7 +691,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ * @return {cc.EventListener} the generated event. Needed in order to remove the event from the dispatcher */ addCustomListener: function (eventName, callback) { - var listener = cc._EventListenerCustom.create(eventName, callback); + var listener = new cc._EventListenerCustom(eventName, callback); this.addListener(listener, 1); return listener; }, diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 579a9e717a..40923e3043 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -573,6 +573,7 @@ _p.enabled; * create a new menu * @deprecated since v3.0, please use new cc.Menu(menuitem1, menuitem2, menuitem3) to create a new menu * @param {...cc.MenuItem|null} menuItems + * todo: need to use new * @return {cc.Menu} */ cc.Menu.create = function (menuItems) { diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index afd89c430e..d810ad4745 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -549,7 +549,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ if (value && value.length > 0) { this._fontName = cc._globalFontName; this._fontSize = cc._globalFontSize; - label = cc.LabelTTF.create(value, this._fontName, this._fontSize); + label = new cc.LabelTTF(value, this._fontName, this._fontSize); } else { this._fontSize = 0; diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 7345dda301..eee89ac400 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -285,5 +285,5 @@ ccs.Skin.create = function (fileName, rect) { * @deprecated since v3.1, please use new construction instead */ ccs.Skin.createWithSpriteFrameName = function (spriteFrameName) { - return new ccs.Skin(spriteFrameName); + return new ccs.Skin("#" + spriteFrameName); }; From 7ff928c12f25d2df5144f01e27ed50791cae11ce Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 14:28:19 +0800 Subject: [PATCH 0829/1564] Issue #5983: merge -x #8851 --- extensions/cocostudio/reader/timeline/ActionTimelineCache.js | 2 +- extensions/cocostudio/reader/timeline/CSLoader.js | 2 +- .../cocostudio/reader/widgetreader/SliderReader/SliderReader.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index 2b89ffaea8..cd00f0a89c 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -29,7 +29,7 @@ ccui.actionTimelineCacheStatic = { FrameType_RotationFrame : "RotationFrame", FrameType_SkewFrame : "SkewFrame", FrameType_RotationSkewFrame : "RotationSkewFrame", - FrameType_AnchorFrame : "AnchorFrame", + FrameType_AnchorFrame : "AnchorPointFrame", FrameType_InnerActionFrame : "InnerActionFrame", FrameType_ColorFrame : "ColorFrame", FrameType_TextureFrame : "TextureFrame", diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index ff7e0cd4cd..492872e20f 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -104,7 +104,7 @@ ccs.csLoader = { _recordJsonPath: true, _jsonPath: "", - _recordProtocolBuffersPath: true, + _recordProtocolBuffersPath: false, _protocolBuffersPath: "", _monoCocos2dxVersion: "", diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index a77a6f30f9..a8ce1e61d3 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -167,6 +167,8 @@ ccs.sliderReader = /** @lends ccs.SliderReader# */{ var protocolBuffersPath = ccs.uiReader.getFilePath(); var barTextureScale9Enable = !!options["scale9Enable"]; + if(barTextureScale9Enable) + slider.setUnifySizeEnabled(false); slider.setScale9Enabled(barTextureScale9Enable); slider.setPercent(options["percent"]); From ba044214316898aeeca0303eec463ebf35c92b12 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Mon, 20 Oct 2014 10:22:28 +0300 Subject: [PATCH 0830/1564] fixed Scale9Sprite cached canvas size --- .../gui/control-extension/CCScale9Sprite.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 22c09a8a12..fe08b976a5 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -198,12 +198,17 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ _cacheScale9Sprite: function(){ if(!this._scale9Image) return; - var size = this._contentSize, locCanvas = this._cacheCanvas; + + var locScaleFactor = cc.contentScaleFactor(); + var size = this._contentSize; + var sizeInPixels = cc.size(size.width * locScaleFactor, size.height * locScaleFactor); + + var locCanvas = this._cacheCanvas; var contentSizeChanged = false; - if(locCanvas.width != size.width || locCanvas.height != size.height){ - locCanvas.width = size.width; - locCanvas.height = size.height; - this._cacheContext.translate(0, size.height); + if(locCanvas.width != sizeInPixels.width || locCanvas.height != sizeInPixels.height){ + locCanvas.width = sizeInPixels.width; + locCanvas.height = sizeInPixels.height; + this._cacheContext.translate(0, sizeInPixels.height); contentSizeChanged = true; } @@ -212,7 +217,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._scale9Image.visit(); //draw to cache canvas - this._cacheContext.clearRect(0, 0, size.width, -size.height); + this._cacheContext.clearRect(0, 0, sizeInPixels.width, -sizeInPixels.height); cc.renderer._renderingToCacheCanvas(this._cacheContext); if(contentSizeChanged) From 051eae433aedd83cfe2f97ce0b06bc8b0a9650f3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 15:50:53 +0800 Subject: [PATCH 0831/1564] Issue #5983: merge -x #8804 --- extensions/cocostudio/reader/GUIReader.js | 17 ------------- .../reader/timeline/ActionTimelineCache.js | 14 +---------- .../cocostudio/reader/timeline/CSLoader.js | 17 +++---------- .../widgetreader/ButtonReader/ButtonReader.js | 14 +++-------- .../CheckBoxReader/CheckBoxReader.js | 24 +++++------------- .../ImageViewReader/ImageViewReader.js | 5 +--- .../widgetreader/LayoutReader/LayoutReader.js | 5 +--- .../ListViewReader/ListViewReader.js | 5 +--- .../LoadingBarReader/LoadingBarReader.js | 5 +--- .../PageViewReader/PageViewReader.js | 5 +--- .../ScrollViewReader/ScrollViewReader.js | 5 +--- .../widgetreader/SliderReader/SliderReader.js | 25 ++++--------------- .../TextFieldReader/TextFieldReader.js | 2 +- 13 files changed, 25 insertions(+), 118 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 220e298962..80268f553d 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -217,23 +217,6 @@ ccs.uiReader = /** @lends ccs.uiReader# */{ */ getParseCallBackMap: function(){ return this._mapParseSelector; - }, - - /** - * Load ui form protocolBuffers - * @param url - */ - widgetFromProtocolBuffers: function(url){ - var buf = cc.loader.getRes(url); - if(!buf){ - cc.log("File not found: " + url); - return; - } - var jsonPath = url.substr(0, url.lastIndexOf('/') + 1); - ccs.uiReader.setFilePath(jsonPath); - var pReader = new ccs.WidgetPropertiesReader0300(); - var buffer = PBP.CSParseBinary.decode(buf); - return pReader.widgetFromProtocolBuffers(buffer.nodeTree); } }; diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index cd00f0a89c..201844f525 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -200,16 +200,7 @@ ccs.actionTimelineCache = { if(action){ return action; } - // int pos = path.find_last_of('/') - // _protocolBuffersPath = path.substr(0, pos + 1); - -// var fullPath = FileUtils.getInstance().fullPathForFilename(fileName); -// var content = FileUtils.getInstance().getDataFromFile(fullPath); -// var gpbwp;//todo protobuf reader -// // protocolbuffers.GUIProtocolBuffersProtobuf gpbwp; -// if (!gpbwp.ParseFromArray(content.getBytes(), content.getSize())){ -// return null; -// } + var binary = cc.loader.getRes(fileName); var buffer = PBP.CSParseBinary.decode(binary); @@ -762,9 +753,6 @@ ccs.actionTimelineCache = { action.addTimeline(timeline); } - // protocolbuffers.TimeLine* timeLine = nodeAction.add_timelines(); - // convertTimelineProtocolBuffers(timeLine, timelineElement); - timelineElement = timelineElement.NextSiblingElement(); } diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index 492872e20f..3d5ba7cf7d 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -261,10 +261,6 @@ ccs.csLoader = { return this.nodeFromProtocolBuffersFile(filename); }, nodeFromProtocolBuffersFile: function(fileName){ - var path = fileName; - var pos = path.lastIndexOf('/'); - // _protocolBuffersPath = path.substr(0, pos + 1); - var binary = cc.loader.getRes(fileName); var buffer = PBP.CSParseBinary.decode(binary); @@ -300,7 +296,7 @@ ccs.csLoader = { nodeFromProtocolBuffers: function(nodetree){ var node = null; - var classname = nodetree.classname; + var classname = nodetree["classname"]; //cc.log("classname = %s", classname); var curOptions; @@ -407,14 +403,8 @@ ccs.csLoader = { widgetPropertiesReader.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); // 2nd., custom widget parse with custom reader - var widgetOptions = nodetree.widgetOptions; - var customJsonDict = widgetOptions.customProperty; -// var customJsonDict; -// customJsonDict.ParsecustomProperty; -// if (customJsonDict.HasParseError()) -// { -// cc.log("GetParseError %s\n", customJsonDict.GetParseError()); -// } + var widgetOptions = nodetree["widgetOptions"]; + var customJsonDict = widgetOptions["customProperty"]; widgetPropertiesReader.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); } @@ -1054,7 +1044,6 @@ ccs.csLoader = { return node; }, setPropsForProjectNodeFromProtocolBuffers: function(node, projectNodeOptions, nodeOptions){ - var options = projectNodeOptions; this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); }, setPropsForSimpleAudioFromProtocolBuffers: function(node, nodeOptions){ diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index 64d5ae01bc..2c6ba38d40 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -140,10 +140,7 @@ ccs.buttonReader = /** @lends ccs.buttonReader# */{ var normalDic = options["normalData"]; var normalType = normalDic["resourceType"]; - if (normalType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + normalDic["plistFile"]); - } + var normalTexturePath = ccs.widgetReader.getResourcePath(normalDic["path"], normalType); button.loadTextureNormal(normalTexturePath, normalType); @@ -151,19 +148,14 @@ ccs.buttonReader = /** @lends ccs.buttonReader# */{ var pressedDic = options["pressedData"]; var pressedType = pressedDic["resourceType"]; if (pressedType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + pressedDic["plistFile"]); - } + var pressedTexturePath = ccs.widgetReader.getResourcePath(pressedDic["path"], pressedType); button.loadTexturePressed(pressedTexturePath, pressedType); var disabledDic = options["disabledData"]; var disabledType = disabledDic["resourceType"]; - if (disabledType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + disabledDic["plistFile"]); - } + var disabledTexturePath = ccs.widgetReader.getResourcePath(disabledDic["path"], disabledType); button.loadTextureDisabled(disabledTexturePath, disabledType); diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index 78fd5a6bc1..2a3c3f1514 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -79,7 +79,7 @@ ccs.checkBoxReader = /** @lends ccs.CheckBoxReader# */{ checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); if (options["selectedState"]) - checkBox.setSelectedState(options["selectedState"]); + checkBox.setSelected(options["selectedState"]); ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); }, @@ -105,44 +105,32 @@ ccs.checkBoxReader = /** @lends ccs.CheckBoxReader# */{ //load background selected image var backGroundSelectedDic = options["backGroundBoxSelectedData"]; var backGroundSelectedType = backGroundSelectedDic["resourceType"]; - if (backGroundSelectedType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + backGroundSelectedDic["plistFile"]); - } + var backGroundSelectedTexturePath = ccs.widgetReader.getResourcePath(backGroundSelectedDic["path"], backGroundSelectedType); checkBox.loadTextureBackGroundSelected(backGroundSelectedTexturePath, backGroundSelectedType); //load frontCross image var frontCrossDic = options["frontCrossData"]; var frontCrossType = frontCrossDic["resourceType"]; - if (frontCrossType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + frontCrossDic["plistFile"]); - } + var frontCrossFileName = ccs.widgetReader.getResourcePath(frontCrossDic["path"], frontCrossType); checkBox.loadTextureFrontCross(frontCrossFileName, frontCrossType); //load backGroundBoxDisabledData var backGroundDisabledDic = options["backGroundBoxDisabledData"]; var backGroundDisabledType = backGroundDisabledDic["resourceType"]; - if (backGroundDisabledType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + backGroundDisabledDic["plistFile"]); - } + var backGroundDisabledFileName = ccs.widgetReader.getResourcePath(backGroundDisabledDic["path"], backGroundDisabledType); checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, backGroundDisabledType); ///load frontCrossDisabledData var frontCrossDisabledDic = options["frontCrossDisabledData"]; var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; - if (frontCrossDisabledType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + frontCrossDisabledDic["plistFile"]); - } + var frontCrossDisabledFileName = ccs.widgetReader.getResourcePath(frontCrossDisabledDic["path"], frontCrossDisabledType); checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); - checkBox.setSelectedState(options["selectedState"]); + checkBox.setSelected(options["selectedState"]); var displaystate = true; if(options["displaystate"]!==null) diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index 69d125b5b7..b5ad95923b 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -101,10 +101,7 @@ ccs.imageViewReader = /** @lends ccs.ImageViewReader# */{ var imageFileNameDic = options["fileNameData"]; var imageFileNameType = imageFileNameDic["resourceType"]; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic["plistFile"]); - } + var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); imageView.loadTexture(imageFileName, imageFileNameType); diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 3830f258cd..df02f1fc25 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -240,10 +240,7 @@ ccs.layoutReader = /** @lends ccs.LayoutReader# */{ var imageFileNameDic = options["backGroundImageData"]; if(imageFileNameDic){ var imageFileNameType = imageFileNameDic["resourceType"]; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic["plistFile"]); - } + var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); panel.setBackGroundImage(imageFileName, imageFileNameType); } diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index 677ca18f38..8a621fde19 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -104,10 +104,7 @@ ccs.listViewReader = /** @lends ccs.ListViewReader# */{ var imageFileNameDic = options["backGroundImageData"]; var imageFileNameType = imageFileNameDic["resourceType"]; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic["plistFile"]); - } + var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); listView.setBackGroundImage(imageFileName, imageFileNameType); diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index eff6f7d06c..b1165eed70 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -95,10 +95,7 @@ ccs.loadingBarReader = /** @lends ccs.LoadingBarReader# */{ var imageFileNameDic = options["textureData"]; var imageFileNameType = imageFileNameDic["resourceType"]; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic["plistFile"]); - } + var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); loadingBar.loadTexture(imageFileName, imageFileNameType); diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index 0647e25b4f..fba8ac2fa1 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -103,10 +103,7 @@ ccs.pageViewReader = /** @lends ccs.PageViewReader# */{ if(imageFileNameDic){ var imageFileNameType = imageFileNameDic["resourceType"]; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic["plistFile"]); - } + var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); pageView.setBackGroundImage(imageFileName, imageFileNameType); } diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index d60d464006..63972823c8 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -114,10 +114,7 @@ ccs.scrollViewReader = /** @lends ccs.ScrollViewReader# */{ var imageFileNameDic = options["backGroundImageData"]; if(imageFileNameDic){ var imageFileNameType = imageFileNameDic["resourceType"]; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic["plistFile"]); - } + var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); scrollView.setBackGroundImage(imageFileName, imageFileNameType); } diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index a8ce1e61d3..e322c99444 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -179,10 +179,7 @@ ccs.sliderReader = /** @lends ccs.SliderReader# */{ var imageFileNameDic = options["barFileNameData"]; var imageFileNameType = imageFileNameDic["resourceType"]; - if (imageFileNameType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + imageFileNameDic["plistFile"]); - } + var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); slider.loadBarTexture(imageFileName, imageFileNameType); @@ -194,10 +191,7 @@ ccs.sliderReader = /** @lends ccs.SliderReader# */{ //loading normal slider ball texture var normalDic = options["ballNormalData"]; var normalType = normalDic["resourceType"]; - if (normalType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + normalDic["plistFile"]); - } + imageFileName = ccs.widgetReader.getResourcePath(normalDic["path"], normalType); slider.loadSlidBallTextureNormal(imageFileName, normalType); @@ -205,30 +199,21 @@ ccs.sliderReader = /** @lends ccs.SliderReader# */{ //loading slider ball press texture var pressedDic = options["ballPressedData"]; var pressedType = pressedDic["resourceType"]; - if (pressedType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + pressedDic["plistFile"]); - } + var pressedFileName = ccs.widgetReader.getResourcePath(pressedDic["path"], pressedType); slider.loadSlidBallTexturePressed(pressedFileName, pressedType); //loading silder ball disable texture var disabledDic = options["ballDisabledData"]; var disabledType = disabledDic["resourceType"]; - if (disabledType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + disabledDic["plistFile"]); - } + var disabledFileName = ccs.widgetReader.getResourcePath(disabledDic["path"], disabledType); slider.loadSlidBallTextureDisabled(disabledFileName, disabledType); //load slider progress texture var progressBarDic = options["progressBarData"]; var progressBarType = progressBarDic["resourceType"]; - if (progressBarType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + progressBarDic["plistFile"]); - } + var progressBarFileName = ccs.widgetReader.getResourcePath(progressBarDic["path"], progressBarType); slider.loadProgressBarTexture(progressBarFileName, progressBarType); diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index edc9f5786a..fd94cabdcd 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -114,7 +114,7 @@ ccs.textFieldReader = /** @lends ccs.TextFieldReader# */{ textField.setPlaceHolder(placeholder); } var text = options["text"]!==null ? options["text"] : "Text Field"; - textField.setText(text); + textField.setString(text); var fontSize = options["fontSize"] ? options["fontSize"] : 20; textField.setFontSize(fontSize); From f1869528d3802f8c0c63cba4044ff327e3532378 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 16:16:43 +0800 Subject: [PATCH 0832/1564] Issue #5983: fixed bug that loader error --- .../cocostudio/reader/timeline/CSLoader.js | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index 3d5ba7cf7d..9753a8418f 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -300,7 +300,7 @@ ccs.csLoader = { //cc.log("classname = %s", classname); var curOptions; - + if (classname == "Node") { node = new ccs.Node(); @@ -376,9 +376,9 @@ ccs.csLoader = { { var guiClassName = this.getGUIClassName(classname); var readerName = guiClassName; - readerName.append("Reader"); + readerName += "Reader"; - var widget = cc.objectFactory.createObject(guiClassName); + var widget = ccs.objectFactory.createObject(guiClassName); var reader = ccs.objectFactory.createObject(readerName); reader.setPropsFromProtocolBuffers(widget, nodetree); @@ -386,7 +386,7 @@ ccs.csLoader = { var widgetOptions = nodetree["widgetOptions"]; var actionTag = widgetOptions["actionTag"]; widget.setUserObject(new ccs.ActionTimelineData(actionTag)); - + node = widget; } else if (this.isCustomWidget(classname)) @@ -420,18 +420,20 @@ ccs.csLoader = { node = widget; } - - // component - var componentSize = curOptions["componentOptions"].length; - for (var i = 0; i < componentSize; ++i) - { - - var componentOptions = curOptions["componentOptions"][i]; - var component = this.createComponentFromProtocolBuffers(componentOptions); - - if (component) + + if(curOptions){ + // component + var componentSize = curOptions["componentOptions"].length; + for (var i = 0; i < componentSize; ++i) { - node.addComponent(component); + + var componentOptions = curOptions["componentOptions"][i]; + var component = this.createComponentFromProtocolBuffers(componentOptions); + + if (component) + { + node.addComponent(component); + } } } @@ -757,7 +759,7 @@ ccs.csLoader = { if (this.isWidget(classname)) { var readerName = this.getGUIClassName(classname); - readerName.append("Reader"); + readerName += "Reader"; var guiClassName = this.getGUIClassName(classname); widget = ccs.objectFactory.createObject(guiClassName); From ed437ca75696ab0ea4fed8324cf4f3f22477daf3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 17:00:04 +0800 Subject: [PATCH 0833/1564] Issue #5983: fixed bug that draw none --- cocos2d/core/renderer/RendererCanvas.js | 107 +++++++++++++----------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 39e338c8c8..749c180c9b 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -169,27 +169,29 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //TODO should move '* scaleX/scaleY' to transforming if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); } else { - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); } } else { curColor = node._displayedColor; @@ -207,26 +209,28 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (node._texture) { image = node._texture.getHtmlElementObj(); if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); } else { - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); } } else { curColor = node._displayedColor; @@ -479,15 +483,16 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //draw sprite var image = locSprite._texture.getHtmlElementObj(); - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); + if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); context.restore(); cc.g_NumberOfDraws++; @@ -740,8 +745,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); var locCanvasHeight = locCacheCanvas.height * scaleY; - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + + if(locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); context.restore(); } From cc75822eb4e83c20ecf585254a14867918c296ca Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 17:08:37 +0800 Subject: [PATCH 0834/1564] Issue #5983: fixed bug that draw none --- cocos2d/core/renderer/RendererCanvas.js | 113 ++++++++++++------------ 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 749c180c9b..9725950581 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -131,6 +131,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var context = ctx || cc._renderContext, locTextureCoord = self._textureCoord; + if(locTextureCoord.width === 0 || locTextureCoord.height === 0) + return; if (!locTextureCoord.validRect && node._displayedOpacity === 0) return; //draw nothing @@ -169,29 +171,27 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //TODO should move '* scaleX/scaleY' to transforming if (node._colorized) { - if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); } else { - if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); } } else { curColor = node._displayedColor; @@ -209,28 +209,26 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (node._texture) { image = node._texture.getHtmlElementObj(); if (node._colorized) { - if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); } else { - if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); } } else { curColor = node._displayedColor; @@ -436,6 +434,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + + if(locTextureCoord.width === 0 || locTextureCoord.height === 0) + return; if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) return; @@ -483,16 +484,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //draw sprite var image = locSprite._texture.getHtmlElementObj(); - if(locTextureCoord.width !== 0 && locTextureCoord.height !== 0) - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); context.restore(); cc.g_NumberOfDraws++; @@ -739,16 +739,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; //direct draw image by canvas drawImage - if (locCacheCanvas) { + if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { context.save(); //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); var locCanvasHeight = locCacheCanvas.height * scaleY; - if(locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); context.restore(); } From 78ce2a481f0650afe3562ab77e7807cefe2828ce Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 17:13:35 +0800 Subject: [PATCH 0835/1564] Issue #5983: fixed bug that draw none --- cocos2d/core/renderer/RendererCanvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 9725950581..9f2e829249 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -131,7 +131,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var context = ctx || cc._renderContext, locTextureCoord = self._textureCoord; - if(locTextureCoord.width === 0 || locTextureCoord.height === 0) + if(node._texture && (locTextureCoord.width === 0 || locTextureCoord.height === 0)) return; if (!locTextureCoord.validRect && node._displayedOpacity === 0) return; //draw nothing From 79edcaa80c69c3b44d139549ab352c4c0799cdf8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 20 Oct 2014 17:24:10 +0800 Subject: [PATCH 0836/1564] Fixed a bug of cc.Director that its position is incorrect when calling setProjection --- cocos2d/core/CCDirectorWebGL.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 4566f92dc4..e7ac27e17e 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -92,6 +92,7 @@ cc._tmp.DirectorWebGL = function () { _t._projection = projection; cc.eventManager.dispatchEvent(_t._eventProjectionChanged); cc.setProjectionMatrixDirty(); + cc.renderer.childrenOrderDirty = true; }; _p.setDepthTest = function (on) { From 6d4e93ff5db23ae001efdcd80714aa3aa631ef7a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Oct 2014 20:29:46 +0800 Subject: [PATCH 0837/1564] Issue #5983: fixed bug that uibutton readerer error --- .../cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index 2c6ba38d40..f877aa8dd9 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -147,7 +147,6 @@ ccs.buttonReader = /** @lends ccs.buttonReader# */{ var pressedDic = options["pressedData"]; var pressedType = pressedDic["resourceType"]; - if (pressedType == 1) var pressedTexturePath = ccs.widgetReader.getResourcePath(pressedDic["path"], pressedType); button.loadTexturePressed(pressedTexturePath, pressedType); From 06f7e8d9491de594c008635c26d9da1173e37708 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 20 Oct 2014 21:00:52 +0800 Subject: [PATCH 0838/1564] Fixed a bug of TextureRenderCmdCanvas --- cocos2d/core/renderer/RendererCanvas.js | 21 +++++++++++++-------- cocos2d/labels/CCLabelBMFont.js | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 9f2e829249..17e9071887 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -144,8 +144,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locY = -node._offsetPosition.y - node._rect.height, locWidth = node._rect.width, locHeight = node._rect.height, - image, - curColor; + image, curColor, contentSize; var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255); /*if(cc.renderer.contextSession.globalAlpha !== alpha){ @@ -194,9 +193,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { ); } } else { - curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; - context.fillRect(locX, locY, locWidth, locHeight); + contentSize = node._contentSize; + if(contentSize.width !== 0 && contentSize.height !== 0) { + curColor = node._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; + context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + } } context.restore(); } else { @@ -231,9 +233,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locHeight * scaleY); } } else { - curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; - context.fillRect(t.tx * scaleX + locX, -t.ty * scaleY + locY, locWidth, locHeight); + contentSize = node._contentSize; + if(contentSize.width !== 0 && contentSize.height !== 0) { + curColor = node._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; + context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + } } if (blendChange) context.restore(); diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 0498597c2d..a3b7617502 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -543,7 +543,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ //var hasSprite = true; if (!fontChar) { fontChar = new cc.Sprite(); - if ((key === 32) && (locContextType === cc._RENDER_TYPE_CANVAS)) rect = cc.rect(0, 0, 0, 0); + if ((key === 32) && (locContextType === cc._RENDER_TYPE_CANVAS)) + rect = cc.rect(0, 0, 0, 0); fontChar.initWithTexture(locTexture, rect, false); fontChar._newTextureWhenChangeColor = true; self.addChild(fontChar, 0, i); From c9490a246cf2f9ac29b31ecd0cc6281460fb2fa1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 21 Oct 2014 10:10:28 +0800 Subject: [PATCH 0839/1564] Fixed a bug of Scale9Sprite that its setPreferredSize works incorrect. --- extensions/ccui/base-classes/UIScale9Sprite.js | 6 ++---- extensions/gui/control-extension/CCScale9Sprite.js | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index a36f4a97aa..26c22169bf 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -290,16 +290,14 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ return this._preferredSize.height; }, setPreferredSize: function (preferredSize) { + this.setContentSize(preferredSize); + this._preferredSize = preferredSize; if (this._positionsAreDirty) { this._updatePositions(); this._positionsAreDirty = false; this._scale9Dirty = true; } - - - this.setContentSize(preferredSize); - this._preferredSize = preferredSize; }, _setPreferredWidth: function (value) { this._setWidth(value); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index fe08b976a5..be6b132990 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -290,16 +290,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ return this._preferredSize.height; }, setPreferredSize: function (preferredSize) { + this.setContentSize(preferredSize); + this._preferredSize = preferredSize; if (this._positionsAreDirty) { this._updatePositions(); this._positionsAreDirty = false; this._scale9Dirty = true; } - - - this.setContentSize(preferredSize); - this._preferredSize = preferredSize; }, _setPreferredWidth: function (value) { this._setWidth(value); From e01e4d18b3ec0f7e628aaa6321f2bb7ee38309c0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Oct 2014 11:07:48 +0800 Subject: [PATCH 0840/1564] Issue #5983: anchorPoint default value change to 0,0 --- extensions/cocostudio/reader/widgetreader/WidgetReader.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index b68fefcfca..5d9a82732a 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -179,6 +179,7 @@ ccs.widgetReader = /** @lends ccs.widgetReader# */{ widget.setCascadeColorEnabled(true); widget.setCascadeOpacityEnabled(true); + widget.setAnchorPoint(cc.p(0, 0)); widget.setUnifySizeEnabled(true); @@ -216,12 +217,8 @@ ccs.widgetReader = /** @lends ccs.widgetReader# */{ widget.setScaleX(options["scaleX"]!==null ? options["scaleX"] : 1); - widget.setScaleY(options["scaleY"]!==null ? options["scaleY"] : 1); - -// widget.setRotation(options.has_rotation ? options.rotation : 0.0); - widget.setRotationX(options["rotationSkewX"]!==null ? options["rotationSkewX"] : 0.0); widget.setRotationY(options["rotationSkewY"]!==null ? options["rotationSkewY"] : 0.0); From 047bdb3f4d41251ea15d25d74f30192a09a92def Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Oct 2014 16:54:33 +0800 Subject: [PATCH 0841/1564] Issue #5983: Modifying the test code for Advanced compression --- extensions/cocostudio/reader/GUIReader.js | 4 +- .../reader/timeline/ActionTimelineCache.js | 2 +- .../cocostudio/reader/timeline/CSLoader.js | 6 +-- external/pluginx/Plugin.js | 42 +++++++++++++++++++ tools/build.xml | 15 +++++-- 5 files changed, 60 insertions(+), 9 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index 80268f553d..ae816c8628 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ var PBP; -if(CSParseBinary && dcodeIO && dcodeIO.ProtoBuf){ - PBP = dcodeIO.ProtoBuf.loadProto(CSParseBinary).build().protocolbuffers; +if(CSParseBinary && window["dcodeIO"] && window["dcodeIO"]["ProtoBuf"]){ + PBP = dcodeIO["ProtoBuf"]["loadProto"](CSParseBinary)["build"]()["protocolbuffers"]; }else{ PBP = null; } diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index 201844f525..a8a20ad582 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -202,7 +202,7 @@ ccs.actionTimelineCache = { } var binary = cc.loader.getRes(fileName); - var buffer = PBP.CSParseBinary.decode(binary); + var buffer = PBP["CSParseBinary"]["decode"](binary); var actionProtobuf = buffer["action"]; action = new ccs.ActionTimeline(); diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index 9753a8418f..dc44f61142 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -263,14 +263,14 @@ ccs.csLoader = { nodeFromProtocolBuffersFile: function(fileName){ var binary = cc.loader.getRes(fileName); - var buffer = PBP.CSParseBinary.decode(binary); + var buffer = PBP["CSParseBinary"]["decode"](binary); // decode plist - var textureSize = buffer.textures.length; + var textureSize = buffer["textures"].length; //cc.log("textureSize = %d", textureSize); for (var i = 0; i < textureSize; ++i) { - var plist = buffer.textures[i]; + var plist = buffer["textures"][i]; //cc.log("plist = %s", plist); var png = buffer["texturesPng"][i]; //cc.log("png = %s", png); diff --git a/external/pluginx/Plugin.js b/external/pluginx/Plugin.js index 4693cb3ce0..1a2aaced03 100644 --- a/external/pluginx/Plugin.js +++ b/external/pluginx/Plugin.js @@ -43,6 +43,7 @@ /** * @returns {PluginManager} + * @expose */ getInstance: function(){ return this; @@ -50,6 +51,7 @@ /** * @param {String} pluginName + * @expose */ loadPlugin: function(pluginName){ @@ -58,6 +60,7 @@ /** * * @param pluginName + * @expose */ unloadPlugin: function(pluginName){ @@ -71,22 +74,26 @@ /** * @param {Boolean} debug + * @expose */ setDebugMode: function(debug){}, /** * @param {String} appKey + * @expose */ startSession: function(appKey){}, /** * @param {Boolean} Capture + * @expose */ setCaptureUncaughtException: function(Capture){}, /** * @param {String} funName * @param {All} Params + * @expose */ callFuncWithParam: function(funName){ if(typeof this[funName] === 'function'){ @@ -99,6 +106,7 @@ /** * @param {String} funName * @param {All} Params + * @expose */ callStringFuncWithParam: function(funName){ this.callFuncWithParam.apply(arguments); @@ -106,6 +114,7 @@ /** * @returns {String} + * @expose */ getPluginName: function(){ return this._name; @@ -113,12 +122,14 @@ /** * @returns {String} + * @expose */ getPluginVersion: function(){ return this._version; } }; + /** @expose */ PluginAssembly.extend = function(name, porp){ var p, prototype = {}; for(p in PluginAssembly.prototype){ @@ -158,55 +169,86 @@ return tmpValue }; + /** @expose */ Param.ParamType = { + /** @expose */ TypeInt:1, + /** @expose */ TypeFloat:2, + /** @expose */ TypeBool:3, + /** @expose */ TypeString:4, + /** @expose */ TypeStringMap:5 }; + /** @expose */ Param.AdsResultCode = { + /** @expose */ AdsReceived:0, + /** @expose */ FullScreenViewShown:1, + /** @expose */ FullScreenViewDismissed:2, + /** @expose */ PointsSpendSucceed:3, + /** @expose */ PointsSpendFailed:4, + /** @expose */ NetworkError:5, + /** @expose */ UnknownError:6 }; + /** @expose */ Param.PayResultCode = { + /** @expose */ PaySuccess:0, + /** @expose */ PayFail:1, + /** @expose */ PayCancel:2, + /** @expose */ PayTimeOut:3 }; + /** @expose */ Param.ShareResultCode = { + /** @expose */ ShareSuccess:0, + /** @expose */ ShareFail:1, + /** @expose */ ShareCancel:2, + /** @expose */ ShareTimeOut:3 }; + /** @expose */ var PluginList = {}; + /** @expose */ var Plugin = { + /** @expose */ extend: function(name, extend){ PluginList[name] = new (PluginAssembly.extend(name, extend)); typeof PluginList[name].ctor === "function" && PluginList[name].ctor(config[name]); }, + /** @expose */ PluginList: PluginList, + /** @expose */ PluginParam: Param, + /** @expose */ PluginManager: new PluginManager() }; + /** @expose */ window.plugin = Plugin; })(); \ No newline at end of file diff --git a/tools/build.xml b/tools/build.xml index 7f0f2cd081..727191fdbf 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.1-min.js"> @@ -39,6 +39,10 @@ + + + + @@ -185,7 +189,9 @@ + + @@ -234,7 +240,6 @@ - @@ -253,7 +258,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.1-core-min.js"> @@ -280,6 +285,10 @@ + + + + From 9db340cf4467264fdfa77bc47b24d0be3eaf284a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Oct 2014 16:58:18 +0800 Subject: [PATCH 0842/1564] Issue #5983: Modifying the test code for Advanced compression --- tools/genBuildXml.js | 10 ++++++++-- tools/publish.js | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/genBuildXml.js b/tools/genBuildXml.js index 87d8f00bb0..30da208caa 100644 --- a/tools/genBuildXml.js +++ b/tools/genBuildXml.js @@ -57,11 +57,16 @@ module.exports = function(projectDir, projectJson, buildOpt){ if(arr) ccJsList = ccJsList.concat(arr); } + var externalList = []; function getFileArrStr(jsList){ var str = ""; for(var i = 0, li = jsList.length; i < li; i++){ - str += ' ' - if(i < li - 1) str += '\r\n'; + if(/^external/.test(jsList[i]) && !/Plugin/.test(jsList[i])){ + externalList.push(jsList[i]); + }else{ + str += ' '; + if(i < li - 1) str += '\r\n'; + } } return str; } @@ -80,4 +85,5 @@ module.exports = function(projectDir, projectJson, buildOpt){ buildContent = buildContent.replace(/%userJsList%/gi, getFileArrStr(userJsList)); fs.writeFileSync(path.join(realPublishDir, "build.xml"), buildContent); + return externalList; }; diff --git a/tools/publish.js b/tools/publish.js index a0802aefa9..4b28867133 100644 --- a/tools/publish.js +++ b/tools/publish.js @@ -21,7 +21,7 @@ var buildOpt = { if(!fs.existsSync(realPublishDir)) core4cc.mkdirSyncRecursive(realPublishDir); -require("./genBuildXml")(projectDir, projectJson, buildOpt); +var externalList = require("./genBuildXml")(projectDir, projectJson, buildOpt); var outputJsPath = path.join(realPublishDir, buildOpt.outputFileName); if(fs.existsSync(outputJsPath)) fs.unlinkSync(outputJsPath); @@ -52,8 +52,21 @@ exec("cd " + realPublishDir + " && ant", function(err, data, info){ core4cc.copyFiles(path.join(projectDir, "res"), publishResDir); var indexContent = fs.readFileSync(path.join(projectDir, "index.html")).toString(); - indexContent = indexContent.replace(/<\/script>/g, ""); + var externalScript = ""; + externalList.forEach(function(external){ + externalScript += "\n"; + }); + indexContent = indexContent.replace(/<\/script>/g, externalScript); indexContent = indexContent.replace(/"main\.js"\s*/, '"' + buildOpt.outputFileName + '"'); + + externalScript = ""; + [ + "external/pluginx/platform/facebook_sdk.js", + "external/pluginx/platform/facebook.js" + ].forEach(function(external){ + externalScript += "\n"; + }); + indexContent += externalScript; fs.writeFileSync(path.join(realPublishDir, "index.html"), indexContent); console.log("Finished!") }); \ No newline at end of file From ee229bba8b8df8d7acb92430b0056efc10760eda Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Oct 2014 18:27:48 +0800 Subject: [PATCH 0843/1564] Issue #5983: Modifying the csLoader initNode --- .../cocostudio/reader/timeline/CSLoader.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index dc44f61142..ff1c00aa20 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -586,27 +586,27 @@ ccs.csLoader = { }, initNode: function(node, json){ - var width = json[ccui.CSLoaderStatic.WIDTH] || 0; - var height = json[ccui.CSLoaderStatic.HEIGHT] || 0; - var x = json[ccui.CSLoaderStatic.X] || 0; - var y = json[ccui.CSLoaderStatic.Y] || 0; - var scalex = json[ccui.CSLoaderStatic.SCALE_X] || 1; - var scaley = json[ccui.CSLoaderStatic.SCALE_Y] || 1; - var rotation = json[ccui.CSLoaderStatic.ROTATION] || 0; - var rotationSkewX = json[ccui.CSLoaderStatic.ROTATION_SKEW_X] || 0; - var rotationSkewY = json[ccui.CSLoaderStatic.ROTATION_SKEW_Y] || 0; - var skewx = json[ccui.CSLoaderStatic.SKEW_X] || 0; - var skewy = json[ccui.CSLoaderStatic.SKEW_Y] || 0; - var anchorx = json[ccui.CSLoaderStatic.ANCHOR_X] || 0.5; - var anchory = json[ccui.CSLoaderStatic.ANCHOR_Y] || 0.5; - var alpha = json[ccui.CSLoaderStatic.ALPHA] || 255; - var red = json[ccui.CSLoaderStatic.RED] || 255; - var green = json[ccui.CSLoaderStatic.GREEN] || 255; - var blue = json[ccui.CSLoaderStatic.BLUE] || 255; - var zorder = json[ccui.CSLoaderStatic.ZORDER] || 0; - var tag = json[ccui.CSLoaderStatic.TAG] || 0; - var actionTag = json[ccui.CSLoaderStatic.ACTION_TAG] || 0; - var visible = json[ccui.CSLoaderStatic.VISIBLE] || true; + var width = json[ccui.CSLoaderStatic.WIDTH] !=null ? json[ccui.CSLoaderStatic.WIDTH] : 0; + var height = json[ccui.CSLoaderStatic.HEIGHT] !=null ? json[ccui.CSLoaderStatic.HEIGHT] : 0; + var x = json[ccui.CSLoaderStatic.X] !=null ? json[ccui.CSLoaderStatic.X] : 0; + var y = json[ccui.CSLoaderStatic.Y] !=null ? json[ccui.CSLoaderStatic.Y] : 0; + var scalex = json[ccui.CSLoaderStatic.SCALE_X] !=null ? json[ccui.CSLoaderStatic.SCALE_X] : 1; + var scaley = json[ccui.CSLoaderStatic.SCALE_Y] !=null ? json[ccui.CSLoaderStatic.SCALE_Y] : 1; + var rotation = json[ccui.CSLoaderStatic.ROTATION] !=null ? json[ccui.CSLoaderStatic.ROTATION] : 0; + var rotationSkewX = json[ccui.CSLoaderStatic.ROTATION_SKEW_X]!=null ? json[ccui.CSLoaderStatic.ROTATION_SKEW_X] : 0; + var rotationSkewY = json[ccui.CSLoaderStatic.ROTATION_SKEW_Y]!=null ? json[ccui.CSLoaderStatic.ROTATION_SKEW_Y] : 0; + var skewx = json[ccui.CSLoaderStatic.SKEW_X] !=null ? json[ccui.CSLoaderStatic.SKEW_X] : 0; + var skewy = json[ccui.CSLoaderStatic.SKEW_Y] !=null ? json[ccui.CSLoaderStatic.SKEW_Y] : 0; + var anchorx = json[ccui.CSLoaderStatic.ANCHOR_X] !=null ? json[ccui.CSLoaderStatic.ANCHOR_X] : 0.5; + var anchory = json[ccui.CSLoaderStatic.ANCHOR_Y] !=null ? json[ccui.CSLoaderStatic.ANCHOR_Y] : 0.5; + var alpha = json[ccui.CSLoaderStatic.ALPHA] !=null ? json[ccui.CSLoaderStatic.ALPHA] : 255; + var red = json[ccui.CSLoaderStatic.RED] !=null ? json[ccui.CSLoaderStatic.RED] : 255; + var green = json[ccui.CSLoaderStatic.GREEN] !=null ? json[ccui.CSLoaderStatic.GREEN] : 255; + var blue = json[ccui.CSLoaderStatic.BLUE] !=null ? json[ccui.CSLoaderStatic.BLUE] : 255; + var zorder = json[ccui.CSLoaderStatic.ZORDER] !=null ? json[ccui.CSLoaderStatic.ZORDER] : 0; + var tag = json[ccui.CSLoaderStatic.TAG] !=null ? json[ccui.CSLoaderStatic.TAG] : 0; + var actionTag = json[ccui.CSLoaderStatic.ACTION_TAG] !=null ? json[ccui.CSLoaderStatic.ACTION_TAG] : 0; + var visible = json[ccui.CSLoaderStatic.VISIBLE] !=null ? json[ccui.CSLoaderStatic.VISIBLE] : true; if(x != 0 || y != 0) node.setPosition(cc.p(x, y)); From 88a7b757f4562e0f54494902fd36d5dea876d9e2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 21 Oct 2014 18:33:42 +0800 Subject: [PATCH 0844/1564] Issue #5993: Fix frame size initialization issue for cc.view The frame size won't get updated while changing orientation --- cocos2d/core/platform/CCEGLView.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index d4ebcd517b..6de11ebccd 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -205,20 +205,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _initFrameSize: function () { var locFrameSize = this._frameSize; - //To get the most likely for the actual display resolution data - var sWidth = Math.min(window.screen.availWidth, window.screen.width) * window.devicePixelRatio; - var sHeight = Math.min(window.screen.availHeight, window.screen.height) * window.devicePixelRatio; - //Calibration of the actual resolution may be smaller - if(cc.sys.isMobile && this._frame.clientWidth >= sWidth * 0.8){ - locFrameSize.width = sWidth / window.devicePixelRatio; - }else{ - locFrameSize.width = this._frame.clientWidth; - } - if(cc.sys.isMobile && this._frame.clientHeight >= sHeight * 0.8){ - locFrameSize.height = sHeight / window.devicePixelRatio; - }else{ - locFrameSize.height = this._frame.clientHeight; - } + locFrameSize.width = this._frame.clientWidth; + locFrameSize.height = this._frame.clientHeight; }, // hack From 3802d7aa327e21190a8eec96fe58487cc03193ac Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 21 Oct 2014 20:40:34 +0800 Subject: [PATCH 0845/1564] Update engine version --- cocos2d/core/platform/CCConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index ac4632f767..d9c4aefd81 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.1 Beta"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.1"; /** *

    From 45f71b6136b7101dfcdec9f3b1d1710749b1680c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 21 Oct 2014 21:54:58 +0800 Subject: [PATCH 0846/1564] Fixed a bug of cc.LabelAtlas that its 'color' property doesn't work. --- cocos2d/labels/CCLabelAtlas.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 867cc2d5be..8ee45fac95 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -376,6 +376,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { // Override properties cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); +cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); // Extended properties /** @expose */ From 816df98f62b6ff6f69328ab5e65e9bcaa633f82c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 21 Oct 2014 22:08:02 +0800 Subject: [PATCH 0847/1564] Fixed a bug of Sprite that it draws incorrect without texture. --- cocos2d/core/renderer/RendererCanvas.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 17e9071887..bbc50a2376 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -196,7 +196,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { contentSize = node._contentSize; if(contentSize.width !== 0 && contentSize.height !== 0) { curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + (node._displayedOpacity/255).toFixed(4) + ")"; context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } @@ -236,8 +236,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { contentSize = node._contentSize; if(contentSize.width !== 0 && contentSize.height !== 0) { curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + node._displayedOpacity + ")"; - context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + (node._displayedOpacity/255).toFixed(4) + ")"; + context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } if (blendChange) From dc5fd47dee59a9721afd67c29beed42c94c600f1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 22 Oct 2014 10:03:07 +0800 Subject: [PATCH 0848/1564] Fixed a bug of cc.TMXLayer that its position is incorrect when its layerOrientation is TMX_ORIENTATION_HEX --- cocos2d/core/renderer/RendererCanvas.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index bbc50a2376..faa81658f6 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -736,11 +736,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; cc.TMXLayerRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - this._renderingChildToCache(scaleX, scaleY); + var node = this._node; + var alpha = node._displayedOpacity/255; + if(alpha <= 0) + return; + this._renderingChildToCache(scaleX, scaleY); var context = ctx || cc._renderContext; - var node = this._node; - //context.globalAlpha = this._opacity / 255; + context.globalAlpha = alpha; var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; //direct draw image by canvas drawImage @@ -751,9 +754,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var locCanvasHeight = locCacheCanvas.height * scaleY; - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); - + if(node.layerOrientation === cc.TMX_ORIENTATION_HEX){ + var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); + } else { + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + } context.restore(); } cc.g_NumberOfDraws++; From 15ddd15f44076e5878f382c4c2c32582eafbbbc0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 22 Oct 2014 11:25:50 +0800 Subject: [PATCH 0849/1564] Update the authors and fixed a bug of cc.Node's addChild --- AUTHORS.txt | 2 ++ cocos2d/core/base-nodes/CCNode.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 06412f8a6d..208e7edf3e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -174,6 +174,7 @@ musikov @musikov cc.ClippingNode bug fix Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode JumpTo bug with wrong _delta position bug fix cc.ProgressTimer bug fix + cc.Scale9Sprite bug fix Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix @@ -183,6 +184,7 @@ Xiaodong Liu @tianxing113 cc.Spawn.create bug fix ccui.LoadingBar.setPercent crash bug fix Park Hyun Chen @sincntx Touch anywhere of screen to finish input when using cc.EditBox + ccui.TextBMFont bug fix Ninja Lau @mutoo A typo bug in UILayout fix One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index a2afcbb75d..99eb0bf553 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1296,7 +1296,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ addChild: function (child, localZOrder, tag) { var child = child; var localZOrder = localZOrder === undefined ? child._localZOrder : localZOrder; - var tag, name, setTag = false; + var name, setTag = false; if(cc.isUndefined(tag)){ tag = undefined; name = child._name; From 3d8d7d3918b72207d9bc4daa188212e7ba76642a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 22 Oct 2014 11:33:30 +0800 Subject: [PATCH 0850/1564] Fixed a bug of cc.Node's addChild --- cocos2d/core/base-nodes/CCNode.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 99eb0bf553..279591f16e 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1294,8 +1294,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} [tag=] A integer to identify the node easily. Please refer to setTag(int) */ addChild: function (child, localZOrder, tag) { - var child = child; - var localZOrder = localZOrder === undefined ? child._localZOrder : localZOrder; + localZOrder = localZOrder === undefined ? child._localZOrder : localZOrder; var name, setTag = false; if(cc.isUndefined(tag)){ tag = undefined; From 4e2785c6bedf649473b61f9eccd96c49067aa430 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 22 Oct 2014 13:49:30 +0800 Subject: [PATCH 0851/1564] fix the arguments bug --- extensions/ccui/base-classes/CCProtectedNode.js | 2 +- extensions/ccui/layouts/UIHBox.js | 2 +- extensions/ccui/layouts/UILayoutParameter.js | 2 +- extensions/ccui/layouts/UIVBox.js | 2 +- extensions/ccui/uiwidgets/UIButton.js | 2 +- extensions/ccui/uiwidgets/UICheckBox.js | 2 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UIRichText.js | 4 ++-- extensions/ccui/uiwidgets/UIText.js | 2 +- extensions/ccui/uiwidgets/UITextAtlas.js | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index b88d21c904..a342ebc0ef 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -43,7 +43,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ */ ctor: function(){ cc.Node.prototype.ctor.call(this); - this._protectedChildren = []; + this._protectedChildren = []; }, /** diff --git a/extensions/ccui/layouts/UIHBox.js b/extensions/ccui/layouts/UIHBox.js index ce5a7bb7b7..1a0c65d36c 100644 --- a/extensions/ccui/layouts/UIHBox.js +++ b/extensions/ccui/layouts/UIHBox.js @@ -35,7 +35,7 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ * @param {cc.Size} [size] */ ctor: function(size){ - if(size) + if(size !== undefined) this.initWithSize(size); else this.init(); diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index 96b6e812ab..c90d34de86 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -46,7 +46,7 @@ ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ * @param {Number} [bottom] */ ctor: function (margin, top, right, bottom) { - if (margin && top === undefined) { + if (margin !== undefined && top === undefined) { this.left = margin.left; this.top = margin.top; this.right = margin.right; diff --git a/extensions/ccui/layouts/UIVBox.js b/extensions/ccui/layouts/UIVBox.js index 53b88b6f58..15c4871f71 100644 --- a/extensions/ccui/layouts/UIVBox.js +++ b/extensions/ccui/layouts/UIVBox.js @@ -35,7 +35,7 @@ ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ * @param {cc.Size} size */ ctor: function(size){ - if(size) + if(size !== undefined) this.initWithSize(size); else this.init(); diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 8a162869d2..b001f0d173 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -104,7 +104,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); - texType && this.init(normalImage, selectedImage, disableImage, texType); + texType !== undefined && this.init(normalImage, selectedImage, disableImage, texType); }, /** diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 56296eebb9..441a5e66f1 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -78,7 +78,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); - texType && this.init(backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType); + texType !== undefined && this.init(backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType); }, /** diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 88c8901369..d1f3c005e5 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -53,7 +53,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._imageTextureSize = cc.size(this._capInsets.width, this._capInsets.height); ccui.Widget.prototype.ctor.call(this); - texType && this.init(imageFileName, texType); + texType !== undefined && this.init(imageFileName, texType); }, /** diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 324bd53e21..7927dbb4b8 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -146,7 +146,7 @@ ccui.RichElementImage = ccui.RichElement.extend(/** @lends ccui.RichElementImage this._textureRect = cc.rect(0, 0, 0, 0); this._textureType = 0; - filePath && this.init(tag, color, opacity, filePath); + filePath !== undefined && this.init(tag, color, opacity, filePath); }, /** @@ -196,7 +196,7 @@ ccui.RichElementCustomNode = ccui.RichElement.extend(/** @lends ccui.RichElement this._type = ccui.RichElement.CUSTOM; this._customNode = null; - customNode && this.init(tag, color, opacity, customNode); + customNode !== undefined && this.init(tag, color, opacity, customNode); }, /** diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 0210d11f60..8e8f1c13bb 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -70,7 +70,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this._textAreaSize = cc.size(0, 0); ccui.Widget.prototype.ctor.call(this); - fontSize && this.init(textContent, fontName, fontSize); + fontSize !== undefined && this.init(textContent, fontName, fontSize); }, diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index 356838fd05..f60254614b 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -54,7 +54,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ */ ctor: function (stringValue, charMapFile, itemWidth, itemHeight, startCharMap) { ccui.Widget.prototype.ctor.call(this); - startCharMap && this.setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); + startCharMap !== undefined && this.setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); }, _initRenderer: function () { From 4c85e519dc32ee5a93aa074ccec8ba0937940c7b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 22 Oct 2014 14:13:19 +0800 Subject: [PATCH 0852/1564] Strengthening the judgement --- extensions/cocostudio/reader/timeline/ActionTimeline.js | 2 +- .../reader/widgetreader/LabelReader/LabelReader.js | 2 +- .../reader/widgetreader/LayoutReader/LayoutReader.js | 2 +- .../reader/widgetreader/ListViewReader/ListViewReader.js | 6 ++---- .../reader/widgetreader/PageViewReader/PageViewReader.js | 2 +- .../widgetreader/ScrollViewReader/ScrollViewReader.js | 8 ++++---- .../widgetreader/TextFieldReader/TextFieldReader.js | 4 ++-- extensions/cocostudio/reader/widgetreader/WidgetReader.js | 4 ++-- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/ActionTimeline.js b/extensions/cocostudio/reader/timeline/ActionTimeline.js index 95f478aa8f..7bf9b7aed8 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimeline.js +++ b/extensions/cocostudio/reader/timeline/ActionTimeline.js @@ -154,7 +154,7 @@ ccs.ActionTimeline = cc.Action.extend({ startIndex = num[0]; endIndex = num[1] || this._duration; currentFrameIndex = num[2] || startIndex; - loop = bool || true; + loop = bool!=null ? bool : true; this._startFrame = startIndex; this._endFrame = endIndex; diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index de26cffd52..c76e358cef 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -99,7 +99,7 @@ ccs.labelReader = /** @lends ccs.LabelReader# */{ var aw = options["areaWidth"]; var ah = options["areaHeight"]; - if (aw && ah) + if (aw !== null && ah !== null) { var size = cc.size(aw, ah); label.setTextAreaSize(size); diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index df02f1fc25..8fae198f00 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -256,7 +256,7 @@ ccs.layoutReader = /** @lends ccs.LayoutReader# */{ var sw = options["scale9Width"]; var sh = options["scale9Height"]; - if (sw && sh) + if (sw!=null && sh !==null) { panel.setContentSize(cc.size(sw, sh)); } diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index 8a621fde19..593acda427 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -119,11 +119,9 @@ ccs.listViewReader = /** @lends ccs.ListViewReader# */{ var sw = options["scale9width"]; var sh = options["scale9height"]; - if (sw && sh) + if (sw!=null && sh!=null) { - var swf = options["scale9width"]; - var shf = options["scale9height"]; - listView.setContentSize(cc.size(swf, shf)); + listView.setContentSize(cc.size(sw, sh)); } } diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index fba8ac2fa1..48b9357fd0 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -118,7 +118,7 @@ ccs.pageViewReader = /** @lends ccs.PageViewReader# */{ pageView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); var sw = options["scale9Width"]; var sh = options["scale9Height"]; - if (sw && sh) + if (sw!=null && sh!=null) { pageView.setContentSize(cc.size(sw, sh)); } diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index 63972823c8..7c6f10a963 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -39,11 +39,11 @@ ccs.scrollViewReader = /** @lends ccs.ScrollViewReader# */{ ccs.layoutReader.setPropsFromJsonDictionary.call(this, widget, options); var scrollView = widget; - var innerWidth = options["innerWidth"] || 200; - var innerHeight = options["innerHeight"] || 200; + var innerWidth = options["innerWidth"]!=null ? options["innerWidth"] : 200; + var innerHeight = options["innerHeight"]!=null ? options["innerHeight"] : 200; scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); - var direction = options["direction"] || 1; + var direction = options["direction"]!=null ? options["direction"] : 1; scrollView.setDirection(direction); scrollView.setBounceEnabled(options["bounceEnable"]); @@ -128,7 +128,7 @@ ccs.scrollViewReader = /** @lends ccs.ScrollViewReader# */{ scrollView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); var sw = options["scale9Width"]; var sh = options["scale9Height"]; - if (sw && sh) + if (sw!=null && sh!=null) { scrollView.setContentSize(cc.size(sw, sh)); } diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index fd94cabdcd..2918496e74 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -51,7 +51,7 @@ ccs.textFieldReader = /** @lends ccs.TextFieldReader# */{ textField.setFontName(fn); var tsw = options["touchSizeWidth"]; var tsh = options["touchSizeHeight"]; - if(tsw && tsh) + if(tsw!=null && tsh!=null) textField.setTouchSize(tsw, tsh); var dw = options["width"]; @@ -73,7 +73,7 @@ ccs.textFieldReader = /** @lends ccs.TextFieldReader# */{ var aw = options["areaWidth"]; var ah = options["areaHeight"]; - if(aw && ah){ + if(aw!=null && ah!=null){ var size = cc.size(aw, ah); textField.setTextAreaSize(size); } diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index 5d9a82732a..f91746fd73 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -70,10 +70,10 @@ ccs.widgetReader = /** @lends ccs.widgetReader# */{ var y = options["y"]; widget.setPosition(x, y); - var sx = options["scaleX"] || 1; + var sx = options["scaleX"]!=null ? options["scaleX"] : 1; widget.setScaleX(sx); - var sy = options["scaleY"] || 1; + var sy = options["scaleY"]!=null ? options["scaleY"] : 1; widget.setScaleY(sy); var rt = options["rotation"] || 0; From e8b8a7816732b1bb10c8ec835a7249a9deef2b53 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 22 Oct 2014 15:28:26 +0800 Subject: [PATCH 0853/1564] Fixed a bug of renderer that its cache functions doesn't work when a renderTexture has an other renderTexture --- cocos2d/core/layers/CCLayer.js | 8 ++-- cocos2d/core/renderer/RendererCanvas.js | 37 ++++++++++++++--- cocos2d/core/renderer/RendererWebGL.js | 40 ++++++++++++++----- cocos2d/render-texture/CCRenderTexture.js | 8 ++-- cocos2d/tilemap/CCTMXLayer.js | 9 +++-- .../ccui/base-classes/UIScale9Sprite.js | 4 +- .../gui/control-extension/CCScale9Sprite.js | 4 +- 7 files changed, 79 insertions(+), 31 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 5fe3396d1a..792ee445d9 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -164,11 +164,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //visit for canvas _t.sortAllChildren(); - cc.renderer._isCacheToCanvasOn = true; + cc.renderer._turnToCacheMode(this.__instanceId); for (var i = 0, len = children.length; i < len; i++) { children[i].visit(bakeContext); } - cc.renderer._renderingToCacheCanvas(bakeContext); + cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); this._cacheDirty = false; } }; @@ -471,7 +471,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { bakeContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); var child; - cc.renderer._isCacheToCanvasOn = true; + cc.renderer._turnToCacheMode(this.__instanceId); //visit for canvas if (len > 0) { _t.sortAllChildren(); @@ -491,7 +491,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } else if(_t._rendererCmd) cc.renderer.pushRenderCommand(_t._rendererCmd); - cc.renderer._renderingToCacheCanvas(bakeContext); + cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); this._cacheDirty = false; } }; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index faa81658f6..b48d316c65 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -29,8 +29,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _renderCmds: [], //save renderer commands _isCacheToCanvasOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds - _cacheToCanvasCmds: [], // an array saves the renderer commands need for cache to other canvas + _cacheToCanvasCmds: {}, // an array saves the renderer commands need for cache to other canvas //contextSession: { globalAlpha:1 }, + _cacheInstanceIds:[], + _currentID: 0, /** * drawing all renderer command to context (default is cc._renderContext) @@ -51,16 +53,37 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { /** * drawing all renderer command to cache canvas' context * @param {CanvasRenderingContext2D} ctx + * @param {Number} [instanceID] */ - _renderingToCacheCanvas: function (ctx) { - var locCmds = this._cacheToCanvasCmds, i, len; + _renderingToCacheCanvas: function (ctx, instanceID) { if (!ctx) cc.log("The context of RenderTexture is invalid."); + + instanceID = instanceID || this._currentID; + var locCmds = this._cacheToCanvasCmds[instanceID], i, len; for (i = 0, len = locCmds.length; i < len; i++) { locCmds[i].rendering(ctx, 1, 1); } - locCmds.length = 0; + var locIDs = this._cacheInstanceIds; + delete this._cacheToCanvasCmds[instanceID]; + cc.arrayRemoveObject(locIDs, instanceID); + + if (locIDs.length === 0) + this._isCacheToCanvasOn = false; + else + this._currentID = locIDs[locIDs.length - 1]; + }, + + _turnToCacheMode: function(renderTextureID){ + this._isCacheToCanvasOn = true; + renderTextureID = renderTextureID || 0; + this._cacheToCanvasCmds[renderTextureID] = []; + this._cacheInstanceIds.push(renderTextureID); + this._currentID = renderTextureID; + }, + + _turnToNormalMode: function(){ this._isCacheToCanvasOn = false; }, @@ -101,8 +124,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { pushRenderCommand: function (cmd) { if (this._isCacheToCanvasOn) { - if (this._cacheToCanvasCmds.indexOf(cmd) === -1) - this._cacheToCanvasCmds.push(cmd); + var currentId = this._currentID, locCmdBuffer = this._cacheToCanvasCmds; + var cmdList = locCmdBuffer[currentId]; + if (cmdList.indexOf(cmd) === -1) + cmdList.push(cmd); } else { if (this._renderCmds.indexOf(cmd) === -1) this._renderCmds.push(cmd); diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index db4d938ef3..49499c5ce8 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -29,7 +29,9 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ _renderCmds: [], //save renderer commands _isCacheToBufferOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds - _cacheToBufferCmds: [], // an array saves the renderer commands need for cache to other canvas + _cacheToBufferCmds: {}, // an array saves the renderer commands need for cache to other canvas + _cacheInstanceIds:[], + _currentID: 0, /** * drawing all renderer command to context (default is cc._renderContext) @@ -45,19 +47,37 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ } }, + _turnToCacheMode: function(renderTextureID){ + this._isCacheToBufferOn = true; + renderTextureID = renderTextureID || 0; + this._cacheToBufferCmds[renderTextureID] = []; + this._cacheInstanceIds.push(renderTextureID); + this._currentID = renderTextureID; + }, + + _turnToNormalMode: function(){ + this._isCacheToBufferOn = false; + }, + /** * drawing all renderer command to cache canvas' context - * @param {CanvasRenderingContext2D} ctx + * @param {Number} [renderTextureId] */ - _renderingToBuffer: function (ctx) { - var locCmds = this._cacheToBufferCmds, i, len; - ctx = ctx || cc._renderContext; + _renderingToBuffer: function (renderTextureId) { + renderTextureId = renderTextureId || this._currentID; + var locCmds = this._cacheToBufferCmds[renderTextureId], i, len; + var ctx = cc._renderContext, locIDs = this._cacheInstanceIds; for (i = 0, len = locCmds.length; i < len; i++) { locCmds[i].rendering(ctx); } - locCmds.length = 0; - this._isCacheToBufferOn = false; + delete this._cacheToBufferCmds[renderTextureId]; + cc.arrayRemoveObject(locIDs, renderTextureId); + + if (locIDs.length === 0) + this._isCacheToBufferOn = false; + else + this._currentID = locIDs[locIDs.length - 1]; }, //reset renderer's flag @@ -98,8 +118,10 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ pushRenderCommand: function (cmd) { if (this._isCacheToBufferOn) { - if (this._cacheToBufferCmds.indexOf(cmd) === -1) - this._cacheToBufferCmds.push(cmd); + var currentId = this._currentID, locCmdBuffer = this._cacheToBufferCmds; + var cmdList = locCmdBuffer[currentId]; + if (cmdList.indexOf(cmd) === -1) + cmdList.push(cmd); } else { if (this._renderCmds.indexOf(cmd) === -1) this._renderCmds.push(cmd); diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 15e38ff0fe..4697a56e6e 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -348,7 +348,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ //cc._renderContext = this._cacheContext; //cc.view._setScaleXYForRenderTexture(); - cc.renderer._isCacheToCanvasOn = true; + cc.renderer._turnToCacheMode(this.__instanceId); /*// Save the current matrix cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); @@ -358,7 +358,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, _beginForWebGL: function () { - cc.renderer._isCacheToBufferOn = true; + cc.renderer._turnToCacheMode(this.__instanceId); // Save the current matrix cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); @@ -495,7 +495,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ //cc._renderContext = cc._mainRenderContextBackup; //cc.view._resetScale(); - cc.renderer._renderingToCacheCanvas(this._cacheContext); + cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId); //TODO /*//restore viewport @@ -507,7 +507,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ }, _endForWebGL: function () { - cc.renderer._renderingToBuffer(); + cc.renderer._renderingToBuffer(this.__instanceId); var gl = cc._renderContext; var director = cc.director; diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 59d5ad40c2..75bcb27712 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -208,9 +208,10 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this.transform(); if (this._cacheDirty) { - var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view; + var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view, + instanceID = this.__instanceId, renderer = cc.renderer; //begin cache - cc.renderer._isCacheToCanvasOn = true; + renderer._turnToCacheMode(instanceID); this.sortAllChildren(); for (i = 0, len = locChildren.length; i < len; i++) { @@ -221,7 +222,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ } //copy cached render cmd array to TMXLayer renderer - this._rendererCmd._copyRendererCmds(cc.renderer._cacheToCanvasCmds); + this._rendererCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); locCacheContext.save(); locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); @@ -229,7 +230,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); //draw to cache canvas - cc.renderer._renderingToCacheCanvas(locCacheContext); + renderer._renderingToCacheCanvas(locCacheContext, instanceID); locCacheContext.restore(); this._cacheDirty = false; } diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 26c22169bf..32aede1ac6 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -213,12 +213,12 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ } //begin cache - cc.renderer._isCacheToCanvasOn = true; + cc.renderer._turnToCacheMode(this.__instanceId); this._scale9Image.visit(); //draw to cache canvas this._cacheContext.clearRect(0, 0, size.width, -size.height); - cc.renderer._renderingToCacheCanvas(this._cacheContext); + cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId); if(contentSizeChanged) this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index be6b132990..ea8a307cb2 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -213,12 +213,12 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } //begin cache - cc.renderer._isCacheToCanvasOn = true; + cc.renderer._turnToCacheMode(this.__instanceId); this._scale9Image.visit(); //draw to cache canvas this._cacheContext.clearRect(0, 0, sizeInPixels.width, -sizeInPixels.height); - cc.renderer._renderingToCacheCanvas(this._cacheContext); + cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId); if(contentSizeChanged) this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); From 60ca0a1e31e63a1f56b98659fb801d9b81c28305 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 22 Oct 2014 15:54:18 +0800 Subject: [PATCH 0854/1564] [3.1 release] Add change log --- CHANGELOG.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a07e3fb1df..2f5809f9dc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,36 @@ ChangeLog: +Cocos2d-JS-v3.1 @ Oct.22, 2014 + +* Released Facebook Integration for Cocos2d-JS v1.0, all APIs have been significantly polished and stabilized. Improved test cases for Facebook with more features demonstrated. +* Upgraded Cocos2d-x to v3.3 rc0 +* Supported Cocos Studio v2.0 including Timeline animation support and proto buffers format support for both web engine and JSB engine. +* Refactored load event of texture, sprite frame and sprite for better maintainability. +* Refactored `cc.rendererCanvas` for improving performance. +* Moved the `CC_Texture0` definition of fragment shader to cc.GLProgram to ensure compatibility with JSB. +* Added normalized position functions to cc.Node. +* Refactored the constructor of Cocos Studio's classes and deprecated all create functions. +* Refactored Cocos Studio reader for better maintainability. +* Improved Facebook SDK. +* Modified `cc.ProgressTo`'s behavior, its progression didn't reset to zero when the progression is 100. +* Changed `ccui.Widget`'s default anchor point to (0, 0) in widget reader. +* Removed all deprecated create function usage in engine and in the test cases. + +* Bug fixes: + 1. Fixed an issue of `cc.UILayout` that its scissor mode didn't work. + 2. Fixed an issue of `ccui.TextBMFont` that its 'string' property setting was incorrect. + 3. Fixed an issue of `cc.DrawNode` that its element's position was incorrect in Canvas mode. + 4. Fixed an issue of `cc.Layer` that its bake function didn't work in new renderer. + 5. Fixed an issue of `cc.Scale9Sprite` that its cached canvas size was incorrect. + 6. Fixed an issue of `cc.Director` that its position was incorrect when calling `setProjection` in new renderer. + 7. Fixed an issue of `cc.view` that the reinitialization logic of frame size was incorrect. + 8. Fixed incorrect usage of `cc.progressTo` in progress action test. + 9. Fixed an issue of CocosNodeTest for the new renderer. + 10. Fixed minor issues in test cases. + +* Known Issues: + 1. `jsb.AssetsManager` doesn't work on windows due to a bug in libcurl + Cocos2d-JS v3.1 beta @ Oct.13, 2014 * Refactoration of the web engine with new renderer on the architecture level, optimization is under going. From 7f1f232db563e51819cfd8502f97110f55eb15da Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 22 Oct 2014 18:02:30 +0800 Subject: [PATCH 0855/1564] Fixed a bug of cc.Sprite that its flipped function is incorrect in Canvas --- cocos2d/core/base-nodes/CCNode.js | 6 ++---- cocos2d/core/renderer/RendererCanvas.js | 8 ++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 279591f16e..a78d1562b8 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2796,10 +2796,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } // adjust anchorPoint - if(!this._flippedX) //TODO modify for new renderer - t.tx += Cos * -appX * sx + -Sin * appY * sy; - if(!this._flippedY) - t.ty -= Sin * -appX * sx + Cos * appY * sy; + t.tx += Cos * -appX * sx + -Sin * appY * sy; + t.ty -= Sin * -appX * sx + Cos * appY * sy; // if ignore anchorPoint if (_t._ignoreAnchorPointForPosition) { diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index b48d316c65..793f3f4afc 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -185,10 +185,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (blendChange) context.globalCompositeOperation = node._blendFuncStr; - if (node._flippedX) + if (node._flippedX){ + locX = -locX - locWidth; context.scale(-1, 1); - if (node._flippedY) + } + if (node._flippedY){ + locY = node._offsetPosition.y; context.scale(1, -1); + } if (node._texture) { image = node._texture._htmlElementObj; From b617cd2c7c7d75fc2cca302841eb5481520acf44 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Thu, 23 Oct 2014 10:10:05 +0800 Subject: [PATCH 0856/1564] Feature #5995 change login default permission --- external/pluginx/platform/facebook.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/pluginx/platform/facebook.js b/external/pluginx/platform/facebook.js index 6e243375f3..190115951a 100644 --- a/external/pluginx/platform/facebook.js +++ b/external/pluginx/platform/facebook.js @@ -158,10 +158,10 @@ plugin.extend('facebook', { permissions = []; } if (permissions.every(function (item) { - if (item != 'publish_actions') + if (item != 'public_profile') return true; })) { - permissions.push("publish_actions"); + permissions.push("public_profile"); } var permissionsStr = permissions.join(','); FB.login(function (response) { From 512fbccdc16267672b6e2b35c09c2b6a5983ae72 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 24 Oct 2014 15:33:29 +0800 Subject: [PATCH 0857/1564] Correct a mistake of cc.Sprite that its rendering is incorrect without texture --- cocos2d/core/base-nodes/CCNode.js | 12 ++++++------ cocos2d/core/renderer/RendererCanvas.js | 12 ++++++------ cocos2d/core/sprites/CCSprite.js | 1 - cocos2d/core/sprites/SpritesWebGL.js | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index a78d1562b8..e19eb14ad9 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1345,7 +1345,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * If the cleanup parameter is not passed, it will force a cleanup.
    * If the node orphan, then nothing happens. * @function - * @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise. + * @param {Boolean} [cleanup=true] true if all actions and callbacks on this node should be removed, false otherwise. * @see cc.Node#removeFromParentAndCleanup */ removeFromParent: function (cleanup) { @@ -1360,7 +1360,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Removes this node itself from its parent node.
    * If the node orphan, then nothing happens. * @deprecated since v3.0, please use removeFromParent() instead - * @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise. + * @param {Boolean} [cleanup=true] true if all actions and callbacks on this node should be removed, false otherwise. */ removeFromParentAndCleanup: function (cleanup) { cc.log(cc._LogInfos.Node_removeFromParentAndCleanup); @@ -1374,7 +1374,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * to override this method

    * @function * @param {cc.Node} child The child node which will be removed. - * @param {Boolean|null} [cleanup=null] true if all running actions and callbacks on the child node will be cleanup, false otherwise. + * @param {Boolean} [cleanup=true] true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ removeChild: function (child, cleanup) { // explicit nil handling @@ -1395,7 +1395,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * If the cleanup parameter is not passed, it will force a cleanup.
    * @function * @param {Number} tag An integer number that identifies a child node - * @param {Boolean} cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + * @param {Boolean} [cleanup=true] true if all running actions and callbacks on the child node will be cleanup, false otherwise. * @see cc.Node#removeChildByTag */ removeChildByTag: function (tag, cleanup) { @@ -1411,7 +1411,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. - * @param {Boolean | null } cleanup + * @param {Boolean} [cleanup=true] */ removeAllChildrenWithCleanup: function (cleanup) { //cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup); //TODO It should be discuss in v3.0 @@ -1422,7 +1422,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
    * If the cleanup parameter is not passed, it will force a cleanup.
    * @function - * @param {Boolean | null } cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + * @param {Boolean} [cleanup=true] true if all running actions on all children nodes should be cleanup, false otherwise. */ removeAllChildren: function (cleanup) { // not using detachChild improves speed here diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 793f3f4afc..e5e9582d25 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -173,8 +173,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255); /*if(cc.renderer.contextSession.globalAlpha !== alpha){ - cc.renderer.contextSession.globalAlpha = context.globalAlpha = alpha; //TODO - }*/ + cc.renderer.contextSession.globalAlpha = context.globalAlpha = alpha; //TODO + }*/ if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); @@ -223,9 +223,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } } else { contentSize = node._contentSize; - if(contentSize.width !== 0 && contentSize.height !== 0) { + if(locTextureCoord.validRect) { curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + (node._displayedOpacity/255).toFixed(4) + ")"; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } @@ -263,9 +263,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } } else { contentSize = node._contentSize; - if(contentSize.width !== 0 && contentSize.height !== 0) { + if(locTextureCoord.validRect) { curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + "," + (node._displayedOpacity/255).toFixed(4) + ")"; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 5037609966..623f640634 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1269,7 +1269,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.Node.prototype.init.call(_t); _t.dirty = _t._recursiveDirty = false; - _t._opacityModifyRGB = true; _t._blendFunc.src = cc.BLEND_SRC; _t._blendFunc.dst = cc.BLEND_DST; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 4eff01f610..ff613fcb51 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -85,7 +85,6 @@ cc._tmp.WebGLSprite = function () { cc.Node.prototype.init.call(_t); _t.dirty = _t._recursiveDirty = false; - _t._opacityModifyRGB = true; _t._blendFunc.src = cc.BLEND_SRC; _t._blendFunc.dst = cc.BLEND_DST; From bf5d1d0902b772cbdd39e6e2af75c1218783ebce Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 24 Oct 2014 17:25:48 +0800 Subject: [PATCH 0858/1564] Fixed #2408: Fixed a bug of cc.ClippineNode --- cocos2d/clipping-nodes/CCClippingNode.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 79c4a6f432..8e4cd69043 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -511,12 +511,11 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ var context = ctx || cc._renderContext; var t = this._node._transformWorld; context.save(); + context.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); + context.beginPath(); for (var i = 0; i < stencil._buffer.length; i++) { - var element = stencil._buffer[i]; - var vertices = element.verts; - - context.transform(t.a, t.b, t.c, t.d, t.tx, -t.ty); + var vertices = stencil._buffer[i].verts; //cc.assert(cc.vertexListIsClockwise(vertices), // "Only clockwise polygons should be used as stencil"); From bb498d01c3116bd4fcbcb8a24416403a65882188 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Oct 2014 14:49:40 +0800 Subject: [PATCH 0859/1564] Closed #2401: Read out the textfield for the first time --- .../reader/widgetreader/TextFieldReader/TextFieldReader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index 2918496e74..bffd30737e 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -42,7 +42,7 @@ ccs.textFieldReader = /** @lends ccs.TextFieldReader# */{ var ph = options["placeHolder"]; if(ph) textField.setPlaceHolder(ph); - textField.setString(options["text"] || "Text Field"); + textField.setString(options["text"]||""); var fs = options["fontSize1"]; if(fs) textField.setFontSize(fs); @@ -73,7 +73,7 @@ ccs.textFieldReader = /** @lends ccs.TextFieldReader# */{ var aw = options["areaWidth"]; var ah = options["areaHeight"]; - if(aw!=null && ah!=null){ + if(aw && ah){ var size = cc.size(aw, ah); textField.setTextAreaSize(size); } From 8af4fd92b821285082cfbcbb8be8aa5acb31b96c Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Mon, 27 Oct 2014 22:14:34 +0200 Subject: [PATCH 0860/1564] Add getSprite() method for compatible with cocos2d-x Cocos2d-x's CCScale9Sprite is have getSprite() method for getting scale9Image field but cocos2d-html5 is not. Need to be fixed for compatibility. --- extensions/gui/control-extension/CCScale9Sprite.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index ea8a307cb2..10cb95c5cc 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -278,6 +278,9 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ getOriginalSize: function () { return cc.size(this._originalSize); }, + getSprite: function () { + return this._scale9Image; + }, //if the preferredSize component is given as -1, it is ignored getPreferredSize: function () { From 8775252a63991351f6044e1e061b94b8438724f4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 28 Oct 2014 10:07:02 +0800 Subject: [PATCH 0861/1564] Closed #2413: NO_BORDER is error --- cocos2d/core/CCDirectorWebGL.js | 8 +++++++- cocos2d/core/platform/CCEGLView.js | 12 +++++++----- cocos2d/core/platform/CCVisibleRect.js | 16 ++++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index e7ac27e17e..e1e4b02041 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -57,7 +57,13 @@ cc._tmp.DirectorWebGL = function () { cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); var orthoMatrix = new cc.kmMat4(); - cc.kmMat4OrthographicProjection(orthoMatrix, 0, size.width, 0, size.height, -1024, 1024); + cc.kmMat4OrthographicProjection( + orthoMatrix, + -ox, + size.width - ox, + -oy, + size.height - oy, + -1024, 1024); cc.kmGLMultMatrix(orthoMatrix); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLLoadIdentity(); diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 6de11ebccd..ef8cefd757 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -524,8 +524,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ var vp = _t._viewPortRect = result.viewport, visible = _t._visibleRect; visible.width = cc._canvas.width / _t._scaleX; visible.height = cc._canvas.height / _t._scaleY; - visible.x = -vp.x / _t._scaleX; - visible.y = -vp.y / _t._scaleY; + visible.x = -vp.x/2 / _t._scaleX; + visible.y = -vp.y/2 / _t._scaleY; } // reset director's member variables to fit visible rect @@ -969,11 +969,13 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ apply: function (view, designedResolution) { var containerW = cc._canvas.width, containerH = cc._canvas.height, designW = designedResolution.width, designH = designedResolution.height, - scaleX = containerW / designW, scaleY = containerH / designH, scale; + scaleX = containerW / designW, scaleY = containerH / designH, scale, + contentW, contentH; - scaleX < scaleY ? ( scale = scaleY ): ( scale = scaleX ); + scaleX < scaleY ? (scale = scaleY, contentW = designW * scale, contentH = containerH) + : (scale = scaleX, contentW = containerW, contentH = designH * scale); - return this._buildResult(containerW, containerH, containerW, containerH, scale, scale); + return this._buildResult(containerW, containerH, contentW, contentH, scale, scale); } }); diff --git a/cocos2d/core/platform/CCVisibleRect.js b/cocos2d/core/platform/CCVisibleRect.js index a2f6f01634..8b1a8dfdda 100644 --- a/cocos2d/core/platform/CCVisibleRect.js +++ b/cocos2d/core/platform/CCVisibleRect.js @@ -61,12 +61,16 @@ cc.visibleRect = { * @param {cc.Rect} visibleRect */ init:function(visibleRect){ - var w = this.width = visibleRect.width; - var h = this.height = visibleRect.height; - var l = visibleRect.x, - b = visibleRect.y, - t = b + h, - r = l + w; + var view = cc.EGLView; + var scaleX = view.getScaleX ? view.getScaleX() : 1; + var scaleY = view.getScaleY ? view.getScaleY() : 1; + + var w = this.width = visibleRect.width / scaleX; + var h = this.height = visibleRect.height / scaleY; + var l = visibleRect.x / scaleX, + b = visibleRect.y / scaleY, + t = (b + h) / scaleY, + r = (l + w) / scaleX; //top this.topLeft.x = l; From 9fb269092c5ef3f73111c3f439784ca2b7f9fb21 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 28 Oct 2014 10:08:47 +0800 Subject: [PATCH 0862/1564] Add getSprite() method for compatible with cocos2d-x --- extensions/ccui/base-classes/UIScale9Sprite.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 32aede1ac6..12d80dbbd0 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -274,6 +274,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ } }, + getSprite: function () { + return this._scale9Image; + }, + /** Original sprite's size. */ getOriginalSize: function () { return cc.size(this._originalSize); From 26cafe614d7898d2c709e08f3e2a099feb6389fe Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 28 Oct 2014 17:43:31 +0800 Subject: [PATCH 0863/1564] remove create --- template/src/myApp.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/src/myApp.js b/template/src/myApp.js index a1cd0c1e63..9136df3117 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -15,7 +15,7 @@ var MyLayer = cc.Layer.extend({ var size = cc.director.getWinSize(); // add a "close" icon to exit the progress. it's an autorelease object - var closeItem = cc.MenuItemImage.create( + var closeItem = new cc.MenuItemImage( s_CloseNormal, s_CloseSelected, function () { @@ -39,7 +39,7 @@ var MyLayer = cc.Layer.extend({ this.addChild(this.helloLabel, 5); // add "Helloworld" splash screen" - this.sprite = cc.Sprite.create(s_HelloWorld); + this.sprite = new cc.Sprite(s_HelloWorld); this.sprite.setAnchorPoint(0.5, 0.5); this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height/this.sprite.getContentSize().height); From a84d3ea05c0462767bc12538e53e90d377cee58a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 28 Oct 2014 17:56:32 +0800 Subject: [PATCH 0864/1564] Issue #2416: replace some deprecated APIs to new APIs --- cocos2d/core/base-nodes/BaseNodesPropertyDefine.js | 9 --------- cocos2d/core/base-nodes/BaseNodesWebGL.js | 4 ++-- cocos2d/core/base-nodes/CCNode.js | 6 +----- cocos2d/core/layers/CCLayer.js | 4 ++-- cocos2d/core/sprites/CCSprite.js | 4 ++-- cocos2d/core/sprites/SpritesWebGL.js | 4 ++-- cocos2d/node-grid/CCNodeGrid.js | 3 +-- extensions/ccui/base-classes/CCProtectedNode.js | 5 ++--- extensions/ccui/layouts/UILayout.js | 2 +- .../cocostudio/armature/display/CCDisplayFactory.js | 4 ++-- extensions/cocostudio/armature/display/CCSkin.js | 10 +--------- extensions/editbox/CCEditBox.js | 4 ++-- 12 files changed, 18 insertions(+), 41 deletions(-) diff --git a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js index 4bf8e9d429..2b2639cd89 100644 --- a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +++ b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js @@ -31,21 +31,12 @@ cc._tmp.PrototypeCCNode = function () { cc.defineGetterSetter(_p, "x", _p.getPositionX, _p.setPositionX); cc.defineGetterSetter(_p, "y", _p.getPositionY, _p.setPositionY); /** @expose */ - //_p.pos; - //cc.defineGetterSetter(_p, "pos", _p.getPosition, _p.setPosition); - /** @expose */ _p.width; cc.defineGetterSetter(_p, "width", _p._getWidth, _p._setWidth); /** @expose */ _p.height; cc.defineGetterSetter(_p, "height", _p._getHeight, _p._setHeight); /** @expose */ - //_p.size; - //cc.defineGetterSetter(_p, "size", _p.getContentSize, _p.setContentSize); - /** @expose */ - //_p.anchor; - //cc.defineGetterSetter(_p, "anchor", _p._getAnchor, _p._setAnchor); - /** @expose */ _p.anchorX; cc.defineGetterSetter(_p, "anchorX", _p._getAnchorX, _p._setAnchorX); /** @expose */ diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index cfc292eeeb..85cf9a0171 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -113,7 +113,7 @@ cc._tmp.WebGLCCNode = function () { parentMatrix = pMatrix || (this._parent ? this._parent._stackMatrix : cc.current_stack.top); // Convert 3x3 into 4x4 matrix - var trans = this.nodeToParentTransform(); + var trans = this.getNodeToParentTransform(); var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; @@ -168,7 +168,7 @@ cc._tmp.WebGLCCNode = function () { var t4x4 = _t._transform4x4, topMat4 = cc.current_stack.top; // Convert 3x3 into 4x4 matrix - var trans = _t.nodeToParentTransform(); + var trans = _t.getNodeToParentTransform(); var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index e19eb14ad9..7cb01e05c3 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1460,7 +1460,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ } // If you don't do cleanup, the child's actions will not get removed and the - // its scheduledSelectors_ dict will not get released! if (doCleanup) child.cleanup(); @@ -1614,7 +1613,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Action} An Action pointer */ runAction: function (action) { - cc.assert(action, cc._LogInfos.Node_runAction); this.actionManager.addAction(action, this, !this._running); @@ -1726,7 +1724,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ interval = interval || 0; cc.assert(callback_fn, cc._LogInfos.Node_schedule); - cc.assert(interval >= 0, cc._LogInfos.Node_schedule_2); repeat = (repeat == null) ? cc.REPEAT_FOREVER : repeat; @@ -1753,7 +1750,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {function} callback_fn A function wrapped as a selector */ unschedule: function (callback_fn) { - // explicit nil handling if (!callback_fn) return; @@ -2668,7 +2664,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; _p._transformForRenderer = function () { - var t = this.nodeToParentTransform(), worldT = this._transformWorld; + var t = this.getNodeToParentTransform(), worldT = this._transformWorld; if(this._parent){ var pt = this._parent._transformWorld; //worldT = cc.AffineTransformConcat(t, pt); diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 792ee445d9..01ad907de2 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -521,8 +521,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p._getBoundingBoxForBake = function () { //default size var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var trans = this.nodeToWorldTransform(); - rect = cc.rectApplyAffineTransform(rect, this.nodeToWorldTransform()); + var trans = this.getNodeToWorldTransform(); + rect = cc.rectApplyAffineTransform(rect, this.getNodeToWorldTransform()); //query child's BoundingBox if (!this._children || this._children.length === 0) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 623f640634..d38185e839 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1446,10 +1446,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._shouldBeHidden = false; if (!locParent || locParent == _t._batchNode) { - _t._transformToBatch = _t.nodeToParentTransform(); + _t._transformToBatch = _t.getNodeToParentTransform(); } else { //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); - _t._transformToBatch = cc.affineTransformConcat(_t.nodeToParentTransform(), locParent._transformToBatch); + _t._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); } } _t._recursiveDirty = false; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index ff613fcb51..30dec824ad 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -283,10 +283,10 @@ cc._tmp.WebGLSprite = function () { _t._shouldBeHidden = false; if (!locParent || locParent == _t._batchNode) { - _t._transformToBatch = _t.nodeToParentTransform(); + _t._transformToBatch = _t.getNodeToParentTransform(); } else { //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); - _t._transformToBatch = cc.affineTransformConcat(_t.nodeToParentTransform(), locParent._transformToBatch); + _t._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); } // diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index 1d9b39dd37..a2ef261158 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -147,8 +147,7 @@ cc.NodeGrid = cc.Node.extend({ var t4x4 = this._transform4x4, topMat4 = cc.current_stack.top; // Convert 3x3 into 4x4 matrix - //cc.CGAffineToGL(this.nodeToParentTransform(), this._transform4x4.mat); - var trans = this.nodeToParentTransform(); + var trans = this.getNodeToParentTransform(); var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index a342ebc0ef..9dc13d731a 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -482,10 +482,9 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForCanvas; cc.ProtectedNode.prototype._transformForRenderer = function () { - var t = this.nodeToParentTransform(), worldT = this._transformWorld; + var t = this.getNodeToParentTransform(), worldT = this._transformWorld; if(this._parent){ var pt = this._parent._transformWorld; - //worldT = cc.AffineTransformConcat(t, pt); worldT.a = t.a * pt.a + t.b * pt.c; //a worldT.b = t.a * pt.b + t.b * pt.d; //b worldT.c = t.c * pt.a + t.d * pt.c; //c @@ -524,7 +523,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { parentMatrix = this._parent ? this._parent._stackMatrix : cc.current_stack.top; // Convert 3x3 into 4x4 matrix - var trans = this.nodeToParentTransform(); + var trans = this.getNodeToParentTransform(); var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index c94a181473..884a3d7ade 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -666,7 +666,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _getClippingRect: function () { if (this._clippingRectDirty) { var worldPos = this.convertToWorldSpace(cc.p(0, 0)); - var t = this.nodeToWorldTransform(); + var t = this.getNodeToWorldTransform(); var scissorWidth = this._contentSize.width * t.a; var scissorHeight = this._contentSize.height * t.d; var parentClippingRect; diff --git a/extensions/cocostudio/armature/display/CCDisplayFactory.js b/extensions/cocostudio/armature/display/CCDisplayFactory.js index 093f3f07d9..92b9cd3d97 100644 --- a/extensions/cocostudio/armature/display/CCDisplayFactory.js +++ b/extensions/cocostudio/armature/display/CCDisplayFactory.js @@ -87,7 +87,7 @@ ccs.displayFactory = { var detector = decoDisplay.getColliderDetector(); if (detector) { var node = decoDisplay.getDisplay(); - var displayTransform = node.nodeToParentTransform(); + var displayTransform = node.getNodeToParentTransform(); var helpTransform = this._helpTransform; helpTransform.a = displayTransform.a; helpTransform.b = displayTransform.b; @@ -98,7 +98,7 @@ ccs.displayFactory = { var anchorPoint = cc.pointApplyAffineTransform(node.getAnchorPointInPoints(), helpTransform); helpTransform.tx = anchorPoint.x; helpTransform.ty = anchorPoint.y; - var t = cc.affineTransformConcat(helpTransform, bone.getArmature().nodeToParentTransform()); + var t = cc.affineTransformConcat(helpTransform, bone.getArmature().getNodeToParentTransform()); detector.updateTransform(t); } } diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index eee89ac400..f2356b3fc3 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -197,13 +197,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ (_v_).z = (_z_); }, - RENDER_IN_SUBPIXEL: function(__ARGS__){ - if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) - return Math.ceil(__ARGS__); - else - return __ARGS__; - }, - /** * Returns skin's world transform. * @returns {cc.AffineTransform} @@ -217,7 +210,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); displayTransform.tx = this._anchorPointInPoints.x; displayTransform.ty = this._anchorPointInPoints.y; - return cc.affineTransformConcat( displayTransform,this.bone.getArmature().nodeToWorldTransform()); + return cc.affineTransformConcat( displayTransform,this.bone.getArmature().getNodeToWorldTransform()); }, /** @@ -252,7 +245,6 @@ if (cc._renderType == cc._RENDER_TYPE_WEBGL) { }else{ //ccs.Skin.prototype.getNodeToParentTransform = cc.Node.prototype._getNodeToParentTransformForWebGL; } -//ccs.Skin.prototype.nodeToParentTransform = cc.Node.prototype._getNodeToParentTransformForWebGL; var _p = ccs.Skin.prototype; diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index eae0db612b..6a15a12dc4 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -685,12 +685,12 @@ _p = null; * get the rect of a node in world coordinate frame * @function * @param {cc.Node} node - * @return {cc.rect} + * @return {cc.Rect} */ cc.EditBox.getRect = function (node) { var contentSize = node.getContentSize(); var rect = cc.rect(0, 0, contentSize.width, contentSize.height); - return cc.rectApplyAffineTransform(rect, node.nodeToWorldTransform()); + return cc.rectApplyAffineTransform(rect, node.getNodeToWorldTransform()); }; /** From 134caf5f8a56c684d361a196f9fee4931e06a748 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 29 Oct 2014 17:23:14 +0800 Subject: [PATCH 0865/1564] Close #2419: ccui error --- extensions/ccui/uiwidgets/UICheckBox.js | 2 +- extensions/ccui/uiwidgets/UIImageView.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 441a5e66f1..4a571a5185 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -416,7 +416,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @deprecated since v3.1, please use isSelected. */ getSelectedState: function(){ - this.isSelected(); + return this.isSelected(); }, /** diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index d1f3c005e5..dba1462977 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -78,6 +78,10 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); }, + setRotation: function(rotate){ + this._imageRenderer.setRotation(rotate); + }, + /** * Loads textures for button. * @param {String} fileName @@ -127,6 +131,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ self._updateChildrenDisplayedRGBA(); self._updateContentSizeWithTextureSize(self._imageTextureSize); + if(self._scale9Enabled) + self.setCapInsets(self._capInsets); self._imageRendererAdaptDirty = true; }); } From cc3e15c3d5ecf34b8c159625f38fed455b4d9807 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 30 Oct 2014 10:26:00 +0800 Subject: [PATCH 0866/1564] Issue #2416: rename cc.Node's _StateCallbackType to _stateCallbackType --- cocos2d/clipping-nodes/CCClippingNode.js | 8 ++++---- cocos2d/core/base-nodes/CCNode.js | 22 +++++++++------------- cocos2d/core/renderer/RendererWebGL.js | 2 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 6 +++--- cocos2d/core/sprites/SpritesWebGL.js | 2 +- extensions/editbox/CCdomNode.js | 2 +- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 8e4cd69043..94cce745d4 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -34,7 +34,7 @@ cc.stencilBits = -1; /** *

    * cc.ClippingNode is a subclass of cc.Node.
    - * It draws its content (childs) clipped using a stencil.
    + * It draws its content (children) clipped using a stencil.
    * The stencil is an other cc.Node that will not be drawn.
    * The clipping is done using the alpha part of the stencil (adjusted with an alphaThreshold). *

    @@ -210,7 +210,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ if (cc.ClippingNode._layer + 1 == cc.stencilBits) { cc.ClippingNode._visit_once = true; if (cc.ClippingNode._visit_once) { - cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its childs."); + cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its children."); cc.ClippingNode._visit_once = false; } // draw everything, as if there where no stencil @@ -232,7 +232,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); - // draw (according to the stencil test func) this node and its childs + // draw (according to the stencil test func) this node and its children var locChildren = this._children; if (locChildren && locChildren.length > 0) { var childLen = locChildren.length; @@ -366,7 +366,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ var gl = ctx || cc._renderContext; // restore alpha test state //if (this.alphaThreshold < 1) { - // XXX: we need to find a way to restore the shaders of the stencil node and its childs + // XXX: we need to find a way to restore the shaders of the stencil node and its children //} // restore the depth test state diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 7cb01e05c3..24bcdb1aab 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -247,7 +247,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return; var i, len = array.length, node; - var nodeCallbackType = cc.Node._StateCallbackType; + var nodeCallbackType = cc.Node._stateCallbackType; switch (callbackType) { case nodeCallbackType.onEnter: for (i = 0; i < len; i++) { @@ -1241,7 +1241,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ cc.eventManager.removeListeners(this); // timers - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.cleanup); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.cleanup); }, // composition: GET @@ -1560,7 +1560,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ onEnter: function () { this._isTransitionFinished = false; this._running = true;//should be running before resumeSchedule - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnter); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnter); this.resume(); }, @@ -1574,7 +1574,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ onEnterTransitionDidFinish: function () { this._isTransitionFinished = true; - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnterTransitionDidFinish); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnterTransitionDidFinish); }, /** @@ -1584,7 +1584,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function */ onExitTransitionDidStart: function () { - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExitTransitionDidStart); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExitTransitionDidStart); }, /** @@ -1599,7 +1599,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ onExit: function () { this._running = false; this.pause(); - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExit); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExit); this.removeAllComponents(); }, @@ -2020,7 +2020,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ updateTransform: function () { // Recursively iterate over children - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.updateTransform); }, /** @@ -2213,7 +2213,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * It should be set in initialize phase. *

    * @function - * @param {cc.GLProgram} newShaderProgram The shader program which fetchs from CCShaderCache. + * @param {cc.GLProgram} newShaderProgram The shader program which fetches from CCShaderCache. * @example * node.setGLProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); */ @@ -2501,10 +2501,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ else parentColor = cc.color.WHITE; this.updateDisplayedColor(parentColor); - - /*if (color.a !== undefined && !color.a_undefined) { //setColor doesn't support changing opacity, please use setOpacity - this.setOpacity(color.a); - }*/ }, /** @@ -2608,7 +2604,7 @@ cc.Node.create = function () { return new cc.Node(); }; -cc.Node._StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7}; +cc.Node._stateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7}; if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //redefine cc.Node diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 49499c5ce8..4e44cfd642 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -424,7 +424,7 @@ if(cc._renderType === cc._RENDER_TYPE_WEBGL){ //cc.nodeDrawSetup(this); node._shaderProgram.use(); node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); - node._arrayMakeObjectsPerformSelector(node._children, cc.Node._StateCallbackType.updateTransform); + node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); node.textureAtlas.drawQuads(); diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 75cb18cb9d..ed16367b9b 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -1004,7 +1004,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //sorted now check all children if (locChildren.length > 0) { //first sort all children recursively based on zOrder - this._arrayMakeObjectsPerformSelector(locChildren, cc.Node._StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(locChildren, cc.Node._stateCallbackType.sortAllChildren); } this._reorderChildDirty = false; } @@ -1033,7 +1033,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //sorted now check all children if (childrenArr.length > 0) { //first sort all children recursively based on zOrder - this._arrayMakeObjectsPerformSelector(childrenArr, cc.Node._StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(childrenArr, cc.Node._stateCallbackType.sortAllChildren); var index = 0; //fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact) @@ -1059,7 +1059,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //cc.nodeDrawSetup(this); this._shaderProgram.use(); this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.updateTransform); cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); this.textureAtlas.drawQuads(); diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 30dec824ad..070c354171 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -341,7 +341,7 @@ cc._tmp.WebGLSprite = function () { // recursively iterate over children if (_t._hasChildren) - _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._StateCallbackType.updateTransform); + _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); if (cc.SPRITE_DEBUG_DRAW) { // draw bounding box diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index 2fb5bd47af..13c07b36e7 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -391,7 +391,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ this.unscheduleAllCallbacks(); // timers - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.cleanup); + this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.cleanup); if (this.dom) { this.dom.remove(); } From 92ea102c7f24a4d32a4c9b7b4e9215a906f6fdfc Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 30 Oct 2014 10:39:08 +0800 Subject: [PATCH 0867/1564] Fixed LabelTTF#_updateString bug --- cocos2d/core/labelttf/CCLabelTTF.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 0fa34cc039..bf187b20de 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -596,6 +596,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ } }, _updateString: function () { + if ((!this._string || this._string === "") && this._string !== this._originalText) + cc.renderer.childrenOrderDirty = true; + this._string = this._originalText; }, From 0155c1ed41edd8ee44289f53477abdeef6fc83e6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 30 Oct 2014 14:50:15 +0800 Subject: [PATCH 0868/1564] Repair labelTTF circulation problems --- cocos2d/core/labelttf/CCLabelTTF.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 0fa34cc039..3591ed2fa5 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -844,6 +844,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ } fuzzyLen -= pushNum; + if(fuzzyLen === 0){ + fuzzyLen = 1; + sLine = sLine.substr(1); + } var sText = text.substr(0, fuzzyLen); From 78db8f4749b217ebf8584625f838f5692003e93b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 30 Oct 2014 17:22:05 +0800 Subject: [PATCH 0869/1564] Fixed #2421: Fill sprite with repeating texture in Canvas mode --- cocos2d/core/base-nodes/CCNode.js | 15 ++-- cocos2d/core/platform/CCMacro.js | 29 +++++++ cocos2d/core/renderer/RendererCanvas.js | 102 +++++++++++++----------- cocos2d/core/textures/CCTexture2D.js | 25 +++++- 4 files changed, 114 insertions(+), 57 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 24bcdb1aab..acaaaf9f0f 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2668,16 +2668,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { worldT.b = t.a * pt.b + t.b * pt.d; //b worldT.c = t.c * pt.a + t.d * pt.c; //c worldT.d = t.c * pt.b + t.d * pt.d; //d - if(!this._skewX || this._skewY){ - var plt = this._parent._transform; - var xOffset = -(plt.b + plt.c) * t.ty ; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty - }else{ - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty - } + var plt = this._parent._transform; + var xOffset = -(plt.b + plt.c) * t.ty; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty } else { worldT.a = t.a; worldT.b = t.b; diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index adb7e453f4..2f94ced6cf 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -348,6 +348,7 @@ cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function (point) { return p; }; +//some gl constant variable /** * @constant * @type Number @@ -426,6 +427,34 @@ cc.ONE_MINUS_CONSTANT_ALPHA = 0x8004; */ cc.ONE_MINUS_CONSTANT_COLOR = 0x8002; +/** + * the constant variable equals gl.LINEAR for texture + * @constant + * @type Number + */ +cc.LINEAR = 0x2601; + +/** + * the constant variable equals gl.REPEAT for texture + * @constant + * @type Number + */ +cc.REPEAT = 0x2901; + +/** + * the constant variable equals gl.CLAMP_TO_EDGE for texture + * @constant + * @type Number + */ +cc.CLAMP_TO_EDGE = 0x812f; + +/** + * the constant variable equals gl.MIRRORED_REPEAT for texture + * @constant + * @type Number + */ +cc.MIRRORED_REPEAT = 0x8370; + /** * Check webgl error.Error will be shown in console if exists. * @function diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index e5e9582d25..65062121e8 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -172,9 +172,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { image, curColor, contentSize; var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255); - /*if(cc.renderer.contextSession.globalAlpha !== alpha){ - cc.renderer.contextSession.globalAlpha = context.globalAlpha = alpha; //TODO - }*/ if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); @@ -197,29 +194,36 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (node._texture) { image = node._texture._htmlElementObj; - //TODO should move '* scaleX/scaleY' to transforming - if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + if(node._texture._pattern != ""){ + context.save(); + context.fillStyle = context.createPattern(image, node._texture._pattern); + context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + context.restore(); } else { - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + //TODO should move '* scaleX/scaleY' to transforming + if (node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } } } else { contentSize = node._contentSize; @@ -239,27 +243,35 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.globalAlpha = alpha; if (node._texture) { image = node._texture.getHtmlElementObj(); - if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + if(node._texture._pattern != ""){ + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillStyle = context.createPattern(image, node._texture._pattern); + context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + context.restore(); } else { - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + if (node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); + } else { + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); + } } } else { contentSize = node._contentSize; diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 236280cd81..dbdc03ee4d 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -127,10 +127,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { url: null, + _pattern: null, + ctor: function () { this._contentSize = cc.size(0, 0); this._isLoaded = false; this._htmlElementObj = null; + this._pattern = ""; }, /** @@ -338,8 +341,26 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return false; }, - setTexParameters: function (texParams) { - //support only in WebGl rendering mode + setTexParameters: function (texParams, magFilter, wrapS, wrapT) { + if(magFilter !== undefined) + texParams = {minFilter: texParams, magFilter: magFilter, wrapS: wrapS, wrapT: wrapT}; + + if(texParams.wrapS === cc.REPEAT && texParams.wrapT === cc.REPEAT){ + this._pattern = "repeat"; + return; + } + + if(texParams.wrapS === cc.REPEAT ){ + this._pattern = "repeat-x"; + return; + } + + if(texParams.wrapT === cc.REPEAT){ + this._pattern = "repeat-y"; + return; + } + + this._pattern = ""; }, setAntiAliasTexParameters: function () { From 15c55846a0a99202a46aa34c261dfd602f3b1a21 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 31 Oct 2014 09:53:20 +0800 Subject: [PATCH 0870/1564] Fixed #1078: Fixed the problem with particle texture in canvas mode. --- cocos2d/core/renderer/RendererCanvas.js | 4 ++-- cocos2d/core/sprites/CCSprite.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 65062121e8..420a87ed49 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -387,7 +387,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var i, particle, lpx, alpha; var particleCount = this._node.particleCount, particles = this._node._particles; - if (cc.ParticleSystem.SHAPE_MODE == cc.ParticleSystem.TEXTURE_MODE) { + if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { // Delay drawing until the texture is fully loaded by the browser if (!node._texture || !node._texture._isLoaded) { context.restore(); @@ -448,7 +448,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.save(); context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - if (cc.ParticleSystem.BALL_SHAPE == cc.ParticleSystem.STAR_SHAPE) { + if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { if (particle.rotation) context.rotate(cc.degreesToRadians(particle.rotation)); drawTool.drawStar(context, lpx, particle.color); diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index d38185e839..f534ee38a2 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -228,7 +228,7 @@ cc.cutRotateImageToCanvas = function (texture, rect) { cc._getCompositeOperationByBlendFunc = function(blendFunc){ if(!blendFunc) - return "source"; + return "source-over"; else{ if(( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) return "lighter"; @@ -237,7 +237,7 @@ cc._getCompositeOperationByBlendFunc = function(blendFunc){ else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) return "destination-out"; else - return "source"; + return "source-over"; } }; From 3ae9c05e86da3599edb466a97d29e0b1704773d1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 4 Nov 2014 10:53:39 +0800 Subject: [PATCH 0871/1564] Closed #2429: Fixed a bug of cc.Layer's bake function. --- cocos2d/core/layers/CCLayer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 01ad907de2..6714559731 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -146,17 +146,16 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _t = this; var children = _t._children, locBakeSprite = this._bakeSprite; //compute the bounding box of the bake layer. + this._transformForRenderer(); var boundingBox = this._getBoundingBoxForBake(); - boundingBox.width = 0 | boundingBox.width; - boundingBox.height = 0 | boundingBox.height; + boundingBox.width = Math.ceil(boundingBox.width); + boundingBox.height = Math.ceil(boundingBox.height); var bakeContext = locBakeSprite.getCacheContext(); locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); - // invert var t = cc.affineTransformInvert(this._transformWorld); - var scaleX = cc.view.getScaleX(), scaleY = cc.view.getScaleY(); - bakeContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + bakeContext.transform(t.a, t.c, t.b, t.d, t.tx , -t.ty ); //reset the bake sprite's position var anchor = locBakeSprite.getAnchorPointInPoints(); @@ -169,6 +168,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { children[i].visit(bakeContext); } cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); + locBakeSprite.transform(); //because bake sprite's position was changed at rendering. this._cacheDirty = false; } }; @@ -230,7 +230,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
    * All features from CCLayer are valid, plus the following new features:
    * - opacity
    - * - RGB colors

    + * - RGB colors

    * @class * @extends cc.Layer * @@ -467,8 +467,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } // invert var t = cc.affineTransformInvert(this._transformWorld); - var scaleX = cc.view.getScaleX(), scaleY = cc.view.getScaleY(); - bakeContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + bakeContext.transform(t.a, t.c, t.b, t.d, t.tx, -t.ty); var child; cc.renderer._turnToCacheMode(this.__instanceId); @@ -492,6 +491,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(_t._rendererCmd) cc.renderer.pushRenderCommand(_t._rendererCmd); cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); + locBakeSprite.transform(); this._cacheDirty = false; } }; From d24b8a9cfd83c820e9b0f2d0a664e5026c2f8c6c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 4 Nov 2014 11:20:58 +0800 Subject: [PATCH 0872/1564] Closed #2429: math.ceil to 0| (x + 0.5) --- cocos2d/core/layers/CCLayer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 6714559731..eec85eb5a4 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -148,8 +148,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //compute the bounding box of the bake layer. this._transformForRenderer(); var boundingBox = this._getBoundingBoxForBake(); - boundingBox.width = Math.ceil(boundingBox.width); - boundingBox.height = Math.ceil(boundingBox.height); + boundingBox.width = 0|(boundingBox.width+0.5); + boundingBox.height = 0|(boundingBox.height+0.5); var bakeContext = locBakeSprite.getCacheContext(); locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); From 17624dc5debea478f02cb018d8f956e022bf9c25 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 4 Nov 2014 12:49:08 +0800 Subject: [PATCH 0873/1564] Fixed #2433: Fix ArmatureAnimation's setMovementEventCallFunc and setFrameEventCallFunc --- .../cocostudio/armature/animation/CCArmatureAnimation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 1f16082011..42ea8b5d9d 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -527,7 +527,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# */ setMovementEventCallFunc: function (callFunc, target) { if(arguments.length == 1){ - this._frameEventListener = target; + this._frameEventListener = callFunc; }else if(arguments.length == 2){ this._movementEventTarget = target; this._movementEventCallFunc = callFunc; @@ -541,7 +541,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# */ setFrameEventCallFunc: function (callFunc, target) { if(arguments.length == 1){ - this._frameEventListener = target; + this._frameEventListener = callFunc; }else if(arguments.length == 2){ this._frameEventTarget = target; this._frameEventCallFunc = callFunc; From 4d0c0e806c46e3e44753c2a236d69b10d5b4dac0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 4 Nov 2014 16:38:37 +0800 Subject: [PATCH 0874/1564] Issue #2416: added CCNodeRenderCmd.js to engine --- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 49 ++++++++++++++++++++++ cocos2d/core/layers/CCLayer.js | 2 +- cocos2d/core/renderer/RendererCanvas.js | 8 ++-- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/physics/CCPhysicsSprite.js | 2 +- moduleConfig.json | 1 + 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 cocos2d/core/base-nodes/CCNodeRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js new file mode 100644 index 0000000000..39f49d46ad --- /dev/null +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -0,0 +1,49 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +//The cc.Node's render command for Canvas +cc.NodeCanvasRenderCmd = function(){ + this._needDraw = false; + this._anchorPointInPoints = new cc.Point(0,0); + this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._transformWorld = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + +}; + +cc.NodeCanvasRenderCmd.prototype = { + constructor: cc.NodeCanvasRenderCmd + +}; + +//register to renderer + +//The cc.Node's render command for WebGL +cc.NodeWebGLRenderCmd = function(){ + this._needDraw = false; +}; + +cc.NodeWebGLRenderCmd.prototype = { + constructor: cc.NodeCanvasRenderCmd + +}; \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index eec85eb5a4..2ab1259ae3 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -308,7 +308,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ this._updateColor(); }, - _blendFuncStr: "source", + _blendFuncStr: "source-over", /** * Constructor of cc.LayerColor diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 420a87ed49..b2ebe5f0e8 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -171,7 +171,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locHeight = node._rect.height, image, curColor, contentSize; - var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255); + var blendChange = (node._blendFuncStr !== "source-over"), alpha = (node._displayedOpacity / 255); if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); @@ -304,7 +304,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); //TODO - var needRestore = (node._blendFuncStr !== "source") || needTransform; + var needRestore = (node._blendFuncStr !== "source-over") || needTransform; if (needRestore) { context.save(); @@ -343,7 +343,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); - var needRestore = (node._blendFuncStr !== "source") || needTransform; + var needRestore = (node._blendFuncStr !== "source-over") || needTransform; if(needRestore){ context.save(); context.globalCompositeOperation = node._blendFuncStr; @@ -490,7 +490,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (locSprite._blendFuncStr != "source") + if (locSprite._blendFuncStr != "source-over") context.globalCompositeOperation = locSprite._blendFuncStr; context.globalAlpha = alpha; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index f534ee38a2..2b8b63e057 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -800,7 +800,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _quadWebBuffer: null, _quadDirty: false, _colorized: false, - _blendFuncStr: "source", + _blendFuncStr: "source-over", _originalTexture: null, _drawSize_Canvas: null, diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 34051a4496..38719d9b09 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -369,7 +369,7 @@ * @return {Number} */ getRotation:function () { - return this._ignoreBodyRotation ? cc.radiansToDegrees(this._rotationRadiansX) : -cc.radiansToDegrees(this._body.a); + return this._ignoreBodyRotation ? this._rotationX : -cc.radiansToDegrees(this._body.a); }, /** diff --git a/moduleConfig.json b/moduleConfig.json index 875c2a8f24..d5ead965ce 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -76,6 +76,7 @@ "cocos2d/core/base-nodes/BaseNodesWebGL.js", "cocos2d/core/base-nodes/BaseNodesPropertyDefine.js", "cocos2d/core/base-nodes/CCNode.js", + "cocos2d/core/base-nodes/CCNodeRenderCmd.js", "cocos2d/core/base-nodes/CCAtlasNode.js", "cocos2d/core/textures/TexturesWebGL.js", From 2b1144ca3fa7ce2cb41f2714f1dc0df12fc745b5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 4 Nov 2014 16:42:34 +0800 Subject: [PATCH 0875/1564] Fixed a bug of new renderer that its blend func is incorrect in Canvas Mode --- cocos2d/core/layers/CCLayer.js | 2 +- cocos2d/core/renderer/RendererCanvas.js | 8 ++++---- cocos2d/core/sprites/CCSprite.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index eec85eb5a4..2ab1259ae3 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -308,7 +308,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ this._updateColor(); }, - _blendFuncStr: "source", + _blendFuncStr: "source-over", /** * Constructor of cc.LayerColor diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 420a87ed49..b2ebe5f0e8 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -171,7 +171,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locHeight = node._rect.height, image, curColor, contentSize; - var blendChange = (node._blendFuncStr !== "source"), alpha = (node._displayedOpacity / 255); + var blendChange = (node._blendFuncStr !== "source-over"), alpha = (node._displayedOpacity / 255); if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); @@ -304,7 +304,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); //TODO - var needRestore = (node._blendFuncStr !== "source") || needTransform; + var needRestore = (node._blendFuncStr !== "source-over") || needTransform; if (needRestore) { context.save(); @@ -343,7 +343,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return; var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); - var needRestore = (node._blendFuncStr !== "source") || needTransform; + var needRestore = (node._blendFuncStr !== "source-over") || needTransform; if(needRestore){ context.save(); context.globalCompositeOperation = node._blendFuncStr; @@ -490,7 +490,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (locSprite._blendFuncStr != "source") + if (locSprite._blendFuncStr != "source-over") context.globalCompositeOperation = locSprite._blendFuncStr; context.globalAlpha = alpha; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index f534ee38a2..2b8b63e057 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -800,7 +800,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _quadWebBuffer: null, _quadDirty: false, _colorized: false, - _blendFuncStr: "source", + _blendFuncStr: "source-over", _originalTexture: null, _drawSize_Canvas: null, From 81795731189ffe4373436126f575ce8b635a8540 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 4 Nov 2014 18:27:20 +0800 Subject: [PATCH 0876/1564] Fixed loader error (filename is not function) --- extensions/cocostudio/reader/timeline/CSLoader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index ff1c00aa20..3df9d650ea 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -331,7 +331,7 @@ ccs.csLoader = { var nodeOptions = nodetree["widgetOptions"]; var options = nodetree["projectNodeOptions"]; - var filePath = options.filename(); + var filePath = options["filename"]; //cc.log("filePath = %s", filePath); if(filePath != "") { From 82c9801c348b26574f39dbed006917412921bc9d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 5 Nov 2014 09:44:05 +0800 Subject: [PATCH 0877/1564] Fixed #2436: correct a mistake of cc.ClippingNode --- cocos2d/clipping-nodes/CCClippingNode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 94cce745d4..289bc15183 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -128,6 +128,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ this._stencil = stencil; this.alphaThreshold = 1; this.inverted = false; + return true; }, /** From b1a84beb7620c233598acbf43afe8fb71e6ede88 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 5 Nov 2014 10:55:58 +0800 Subject: [PATCH 0878/1564] Issue #2417: Unified management of browser data --- cocos2d/core/platform/CCEGLView.js | 119 ++++++++++++++++--------- cocos2d/core/platform/CCVisibleRect.js | 15 ++-- cocos2d/core/scenes/CCLoaderScene.js | 1 - 3 files changed, 85 insertions(+), 50 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index ef8cefd757..33d85f1a36 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -35,6 +35,42 @@ cc.DENSITYDPI_HIGH = "high-dpi"; cc.DENSITYDPI_MEDIUM = "medium-dpi"; cc.DENSITYDPI_LOW = "low-dpi"; +cc.__BrowserGetter = { + init: function(){ + this.html = document.getElementsByTagName("html")[0]; + }, + avaWidth: function(frame){ + if(!frame || frame === this.html) + return window.innerWidth; + else + return frame.clientWidth; + }, + avaHeight: function(frame){ + if(!frame || frame === this.html) + return window.innerHeight; + else + return frame.clientHeight; + }, + meta: { + "width": "device-width", + "user-scalable": "no" + } +}; + +switch(cc.sys.browserType){ + case cc.sys.BROWSER_TYPE_CHROME: + cc.__BrowserGetter.avaWidth = function(frame){ + return frame.clientWidth; + }; + cc.__BrowserGetter.avaHeight = function(frame){ + return frame.clientHeight; + }; + cc.__BrowserGetter.__defineGetter__("target-densitydpi", function(){ + return cc.view._targetDensityDPI; + }); + break; +} + /** * cc.view is the singleton object which represents the game window.
    * It's main task include:
    @@ -205,8 +241,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _initFrameSize: function () { var locFrameSize = this._frameSize; - locFrameSize.width = this._frame.clientWidth; - locFrameSize.height = this._frame.clientHeight; + locFrameSize.width = cc.__BrowserGetter.avaWidth(this._frame); + locFrameSize.height = cc.__BrowserGetter.avaHeight(this._frame); }, // hack @@ -234,14 +270,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ vp.name = "viewport"; vp.content = ""; - // For avoiding Android Firefox issue, to remove once firefox fixes its issue. - if (cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX) { - viewportMetas = {"width": "device-width", "initial-scale": "1.0"}; - }else{ - viewportMetas = {"width": "device-width", "user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}; - } - if(cc.sys.isMobile) - viewportMetas["target-densitydpi"] = this._targetDensityDPI; + viewportMetas = cc.__BrowserGetter.meta; content = currentVP ? currentVP.content : ""; for (var key in viewportMetas) { @@ -250,7 +279,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ content += "," + key + "=" + viewportMetas[key]; } } - if(content != "") + if(/^,/.test(content)) content = content.substr(1); vp.content = content; @@ -494,46 +523,56 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ */ setDesignResolutionSize: function (width, height, resolutionPolicy) { // Defensive code - if (isNaN(width) || width == 0 || isNaN(height) || height == 0) { + if( !(width > 0 || height > 0) ){ cc.log(cc._LogInfos.EGLView_setDesignResolutionSize); return; } - var _t = this; - _t.setResolutionPolicy(resolutionPolicy); - var policy = _t._resolutionPolicy; - if (policy) - policy.preApply(_t); - else { + + this.setResolutionPolicy(resolutionPolicy); + var policy = this._resolutionPolicy; + if (!policy){ cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2); return; } + policy.preApply(this); // Reinit frame size - if (cc.sys.isMobile) - _t._setViewPortMeta(); - _t._initFrameSize(); - _t._designResolutionSize = cc.size(width, height); - _t._originalDesignResolutionSize = cc.size(width, height); + if(cc.sys.isMobile) + this._setViewPortMeta(); + + this._initFrameSize(); + + this._originalDesignResolutionSize.width = this._designResolutionSize.width = width; + this._originalDesignResolutionSize.height = this._designResolutionSize.height = height; + + var result = policy.apply(this, this._designResolutionSize); - var result = policy.apply(_t, _t._designResolutionSize); - if (result.scale && result.scale.length == 2) { - _t._scaleX = result.scale[0]; - _t._scaleY = result.scale[1]; + if(result.scale && result.scale.length == 2){ + this._scaleX = result.scale[0]; + this._scaleY = result.scale[1]; } - if (result.viewport) { - var vp = _t._viewPortRect = result.viewport, visible = _t._visibleRect; - visible.width = cc._canvas.width / _t._scaleX; - visible.height = cc._canvas.height / _t._scaleY; - visible.x = -vp.x/2 / _t._scaleX; - visible.y = -vp.y/2 / _t._scaleY; + + if(result.viewport){ + var vp = this._viewPortRect, + vb = this._visibleRect, + rv = result.viewport; + + vp.x = rv.x; + vp.y = rv.y; + vp.width = rv.width; + vp.height = rv.height; + + vb.x = -vp.x / this._scaleX; + vb.y = -vp.y / this._scaleY; + vb.width = cc._canvas.width / this._scaleX; + vb.height = cc._canvas.height / this._scaleY; } // reset director's member variables to fit visible rect var director = cc.director; - director._winSizeInPoints.width = _t._designResolutionSize.width; - director._winSizeInPoints.height = _t._designResolutionSize.height; - - policy.postApply(_t); + director._winSizeInPoints.width = this._designResolutionSize.width; + director._winSizeInPoints.height = this._designResolutionSize.height; + policy.postApply(this); cc.winSize.width = director._winSizeInPoints.width; cc.winSize.height = director._winSizeInPoints.height; @@ -543,12 +582,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ director.setGLDefaultValues(); } - _t._originalScaleX = _t._scaleX; - _t._originalScaleY = _t._scaleY; + this._originalScaleX = this._scaleX; + this._originalScaleY = this._scaleY; // For editbox if (cc.DOM) cc.DOM._resetEGLViewDiv(); - cc.visibleRect && cc.visibleRect.init(_t._visibleRect); + cc.visibleRect && cc.visibleRect.init(this._visibleRect); }, /** diff --git a/cocos2d/core/platform/CCVisibleRect.js b/cocos2d/core/platform/CCVisibleRect.js index 8b1a8dfdda..c6545e9f72 100644 --- a/cocos2d/core/platform/CCVisibleRect.js +++ b/cocos2d/core/platform/CCVisibleRect.js @@ -61,16 +61,13 @@ cc.visibleRect = { * @param {cc.Rect} visibleRect */ init:function(visibleRect){ - var view = cc.EGLView; - var scaleX = view.getScaleX ? view.getScaleX() : 1; - var scaleY = view.getScaleY ? view.getScaleY() : 1; - var w = this.width = visibleRect.width / scaleX; - var h = this.height = visibleRect.height / scaleY; - var l = visibleRect.x / scaleX, - b = visibleRect.y / scaleY, - t = (b + h) / scaleY, - r = (l + w) / scaleX; + var w = this.width = visibleRect.width; + var h = this.height = visibleRect.height; + var l = visibleRect.x, + b = visibleRect.y, + t = b + h, + r = l + w; //top this.topLeft.x = l; diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index 2781c7c4d1..51417498c3 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -47,7 +47,6 @@ cc.LoaderScene = cc.Scene.extend({ // bg var bgLayer = self._bgLayer = new cc.LayerColor(cc.color(32, 32, 32, 255)); - bgLayer.setPosition(cc.visibleRect.bottomLeft); self.addChild(bgLayer, 0); //image move to CCSceneFile.js From 0fc26803e3c0989abbe79284df22f6f9ce057138 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 5 Nov 2014 16:36:25 +0800 Subject: [PATCH 0879/1564] Issue #2416: Added CCLayerRenderCmd.js, CCParticleSystemRenderCmd.js, CCSpriteRenderCmd.js to engine. --- cocos2d/core/base-nodes/CCNode.js | 34 +- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 21 +- cocos2d/core/layers/CCLayer.js | 21 +- cocos2d/core/layers/CCLayerRenderCmd.js | 164 +++ cocos2d/core/layers/CCLayerWebGL.js | 6 - cocos2d/core/renderer/RendererCanvas.js | 1312 +++++++---------- cocos2d/core/renderer/RendererWebGL.js | 1082 +++++++------- cocos2d/core/sprites/CCSprite.js | 9 +- cocos2d/core/sprites/CCSpriteRenderCmd.js | 234 +++ cocos2d/core/sprites/SpritesWebGL.js | 4 - cocos2d/particle/CCParticleSystem.js | 6 +- cocos2d/particle/CCParticleSystemRenderCmd.js | 154 ++ extensions/editbox/CCdomNode.js | 5 - moduleConfig.json | 3 + 14 files changed, 1610 insertions(+), 1445 deletions(-) create mode 100644 cocos2d/core/layers/CCLayerRenderCmd.js create mode 100644 cocos2d/core/sprites/CCSpriteRenderCmd.js create mode 100644 cocos2d/particle/CCParticleSystemRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index acaaaf9f0f..ef2fcba8d5 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -185,8 +185,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _componentContainer: null, _isTransitionFinished: false, - _rotationRadiansX: 0, - _rotationRadiansY: 0, _className: "Node", _showNode: false, _name: "", /// 0; - }, - - _sortNodeByLevelAsc: function (n1, n2) { - return n1._curLevel - n2._curLevel; - }, - - pushDirtyNode: function (node) { - //if (this._transformNodePool.indexOf(node) === -1) - this._transformNodePool.push(node); - }, - - clearRenderCommands: function () { - this._renderCmds.length = 0; - }, - - pushRenderCommand: function (cmd) { - if (this._isCacheToCanvasOn) { - var currentId = this._currentID, locCmdBuffer = this._cacheToCanvasCmds; - var cmdList = locCmdBuffer[currentId]; - if (cmdList.indexOf(cmd) === -1) - cmdList.push(cmd); - } else { - if (this._renderCmds.indexOf(cmd) === -1) - this._renderCmds.push(cmd); - } + else + this._currentID = locIDs[locIDs.length - 1]; + }, + + _turnToCacheMode: function (renderTextureID) { + this._isCacheToCanvasOn = true; + renderTextureID = renderTextureID || 0; + this._cacheToCanvasCmds[renderTextureID] = []; + this._cacheInstanceIds.push(renderTextureID); + this._currentID = renderTextureID; + }, + + _turnToNormalMode: function () { + this._isCacheToCanvasOn = false; + }, + + resetFlag: function () { + this.childrenOrderDirty = false; + this._transformNodePool.length = 0; + }, + + transform: function () { + var locPool = this._transformNodePool; + //sort the pool + locPool.sort(this._sortNodeByLevelAsc); + + //transform node + for (var i = 0, len = locPool.length; i < len; i++) { + if (locPool[i]._renderCmdDiry) //TODO need modify name for LabelTTF + locPool[i]._transformForRenderer(); } - }; - cc.renderer = cc.rendererCanvas; + locPool.length = 0; + }, - cc.TextureRenderCmdCanvas = function (node) { - this._node = node; - this._textureCoord = { - renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. - renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. - x: 0, //the x of texture coordinate for node. - y: 0, //the y of texture coordinate for node. - width: 0, - height: 0, - validRect: false - }; - }; - - cc.TextureRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var self = this, - node = self._node; - - var context = ctx || cc._renderContext, - locTextureCoord = self._textureCoord; - - if(node._texture && (locTextureCoord.width === 0 || locTextureCoord.height === 0)) - return; - if (!locTextureCoord.validRect && node._displayedOpacity === 0) - return; //draw nothing + transformDirty: function () { + return this._transformNodePool.length > 0; + }, - if(node._texture && !node._texture._isLoaded) //set texture but the texture isn't loaded. - return; + _sortNodeByLevelAsc: function (n1, n2) { + return n1._curLevel - n2._curLevel; + }, - var t = node._transformWorld, - locX = node._offsetPosition.x, - locY = -node._offsetPosition.y - node._rect.height, - locWidth = node._rect.width, - locHeight = node._rect.height, - image, curColor, contentSize; + pushDirtyNode: function (node) { + //if (this._transformNodePool.indexOf(node) === -1) + this._transformNodePool.push(node); + }, - var blendChange = (node._blendFuncStr !== "source-over"), alpha = (node._displayedOpacity / 255); + clearRenderCommands: function () { + this._renderCmds.length = 0; + }, - if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { - context.save(); - - context.globalAlpha = alpha; - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (blendChange) - context.globalCompositeOperation = node._blendFuncStr; - - if (node._flippedX){ - locX = -locX - locWidth; - context.scale(-1, 1); - } - if (node._flippedY){ - locY = node._offsetPosition.y; - context.scale(1, -1); - } - - if (node._texture) { - image = node._texture._htmlElementObj; - - if(node._texture._pattern != ""){ - context.save(); - context.fillStyle = context.createPattern(image, node._texture._pattern); - context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); - context.restore(); - } else { - //TODO should move '* scaleX/scaleY' to transforming - if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); - } else { - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); - } - } - } else { - contentSize = node._contentSize; - if(locTextureCoord.validRect) { - curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; - context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); - } - } - context.restore(); - } else { - if (blendChange) { - context.save(); - context.globalCompositeOperation = node._blendFuncStr; - } - - context.globalAlpha = alpha; - if (node._texture) { - image = node._texture.getHtmlElementObj(); - if(node._texture._pattern != ""){ - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.fillStyle = context.createPattern(image, node._texture._pattern); - context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); - context.restore(); - } else { - if (node._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); - } else { - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); - } - } - } else { - contentSize = node._contentSize; - if(locTextureCoord.validRect) { - curColor = node._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; - context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); - } - } - if (blendChange) - context.restore(); - } - cc.g_NumberOfDraws++; - }; - - cc.RectRenderCmdCanvas = function (node) { - this._node = node; - }; - - cc.RectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - node = this._node, - t = node._transformWorld, - curColor = node._displayedColor, - opacity = node._displayedOpacity / 255, - locWidth = node._contentSize.width, - locHeight = node._contentSize.height; - - if (opacity === 0) + pushRenderCommand: function (cmd) { + if(!cmd._needDraw) return; - - var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); //TODO - var needRestore = (node._blendFuncStr !== "source-over") || needTransform; - - if (needRestore) { - context.save(); - context.globalCompositeOperation = node._blendFuncStr; - } - context.globalAlpha = opacity; - context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," - + (0 | curColor.b) + ", 1)"; - if (needTransform) { - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); + if (this._isCacheToCanvasOn) { + var currentId = this._currentID, locCmdBuffer = this._cacheToCanvasCmds; + var cmdList = locCmdBuffer[currentId]; + if (cmdList.indexOf(cmd) === -1) + cmdList.push(cmd); } else { - context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); + if (this._renderCmds.indexOf(cmd) === -1) + this._renderCmds.push(cmd); } - if (needRestore) - context.restore(); - cc.g_NumberOfDraws++; - }; - - cc.GradientRectRenderCmdCanvas = function (node) { - this._node = node; - this._startPoint = cc.p(0, 0); - this._endPoint = cc.p(0, 0); - this._startStopStr = null; - this._endStopStr = null; - }; - - cc.GradientRectRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - self = this, - node = self._node, - opacity = node._displayedOpacity / 255, - t = node._transformWorld; - - if(opacity === 0) - return; + } +}; +if (cc._renderType === cc._RENDER_TYPE_CANVAS) + cc.renderer = cc.rendererCanvas; - var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); - var needRestore = (node._blendFuncStr !== "source-over") || needTransform; - if(needRestore){ - context.save(); - context.globalCompositeOperation = node._blendFuncStr; +// the canvas implement of renderCommand for cc.ProgressTimer +cc.ProgressRenderCmdCanvas = function (node) { + this._PI180 = Math.PI / 180; + + this._node = node; + this._sprite = null; + this._type = cc.ProgressTimer.TYPE_RADIAL; + this._barRect = cc.rect(0, 0, 0, 0); + this._origin = cc.p(0, 0); + this._radius = 0; + this._startAngle = 270; + this._endAngle = 270; + this._counterClockWise = false; +}; + +cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; + + var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + + if (locTextureCoord.width === 0 || locTextureCoord.height === 0) + return; + if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) + return; + + var t = node._transformWorld; + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (locSprite._blendFuncStr != "source-over") + context.globalCompositeOperation = locSprite._blendFuncStr; + context.globalAlpha = alpha; + + var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; + var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; + locDrawSizeCanvas.width = locRect.width * scaleX; + locDrawSizeCanvas.height = locRect.height * scaleY; + + if (locSprite._flippedX) { + flipXOffset = -locOffsetPosition.x - locRect.width; + context.scale(-1, 1); + } + if (locSprite._flippedY) { + flipYOffset = locOffsetPosition.y; + context.scale(1, -1); + } + + flipXOffset *= scaleX; + flipYOffset *= scaleY; + + //clip + if (this._type == cc.ProgressTimer.TYPE_BAR) { + var locBarRect = this._barRect; + context.beginPath(); + context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); + context.clip(); + context.closePath(); + } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { + var locOriginX = this._origin.x * scaleX; + var locOriginY = this._origin.y * scaleY; + context.beginPath(); + context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); + context.lineTo(locOriginX, locOriginY); + context.clip(); + context.closePath(); + } + + //draw sprite + var image = locSprite._texture.getHtmlElementObj(); + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); + + context.restore(); + cc.g_NumberOfDraws++; +}; + +cc.DrawNodeRenderCmdCanvas = function (node) { + this._node = node; + this._buffer = null; + this._drawColor = null; + this._blendFunc = null; +}; + +cc.DrawNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, _t = this, node = _t._node; + var alpha = node._displayedOpacity / 255; + if (alpha === 0) + return; + context.globalAlpha = alpha; + + var t = node._transformWorld; + context.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) + context.globalCompositeOperation = 'lighter'; + var locBuffer = _t._buffer; + for (var i = 0, len = locBuffer.length; i < len; i++) { + var element = locBuffer[i]; + switch (element.type) { + case cc.DrawNode.TYPE_DOT: + _t._drawDot(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_SEGMENT: + _t._drawSegment(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_POLY: + _t._drawPoly(context, element, scaleX, scaleY); + break; } - context.globalAlpha = opacity; - var locWidth = node._contentSize.width, locHeight = node._contentSize.height; - - var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); - gradient.addColorStop(0, this._startStopStr); - gradient.addColorStop(1, this._endStopStr); - context.fillStyle = gradient; + } + context.restore(); +}; + +cc.DrawNodeRenderCmdCanvas.prototype._drawDot = function (ctx, element, scaleX, scaleY) { + var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; + + ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.beginPath(); + ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); + ctx.closePath(); + ctx.fill(); +}; + +cc.DrawNodeRenderCmdCanvas.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { + var locColor = element.lineColor; + var locFrom = element.verts[0], locTo = element.verts[1]; + var locLineWidth = element.lineWidth, locLineCap = element.lineCap; + + ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.lineWidth = locLineWidth * scaleX; + ctx.beginPath(); + ctx.lineCap = locLineCap; + ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); + ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); + ctx.stroke(); +}; + +cc.DrawNodeRenderCmdCanvas.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { + var locVertices = element.verts, locLineCap = element.lineCap; + var locFillColor = element.fillColor, locLineWidth = element.lineWidth; + var locLineColor = element.lineColor, locIsClosePolygon = element.isClosePolygon; + var locIsFill = element.isFill, locIsStroke = element.isStroke; + if (locVertices == null) + return; + + var firstPoint = locVertices[0]; + ctx.lineCap = locLineCap; + if (locFillColor) + ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," + + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; + if (locLineWidth) + ctx.lineWidth = locLineWidth * scaleX; + if (locLineColor) + ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," + + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; - if(needTransform){ - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); - } else - context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); + ctx.beginPath(); + ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); + for (var i = 1, len = locVertices.length; i < len; i++) + ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); - if(needRestore) - context.restore(); - cc.g_NumberOfDraws++; - }; + if (locIsClosePolygon) + ctx.closePath(); + if (locIsFill) + ctx.fill(); + if (locIsStroke) + ctx.stroke(); +}; - cc.ParticleRenderCmdCanvas = function (node) { - this._node = node; - }; +cc.ClippingNodeSaveRenderCmdCanvas = function (node) { + this._node = node; +}; - cc.ParticleRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - node = this._node, - t = node._transformWorld, - pointRect = node._pointRect; +cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var context = ctx || cc._renderContext; + if (node._clipElemType) { + var locCache = cc.ClippingNode._getSharedCache(); + var canvas = context.canvas; + locCache.width = canvas.width; + locCache.height = canvas.height; + var locCacheCtx = locCache.getContext("2d"); + locCacheCtx.drawImage(canvas, 0, 0); context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (node.isBlendAdditive()) - context.globalCompositeOperation = 'lighter'; - else - context.globalCompositeOperation = 'source-over'; - - var i, particle, lpx, alpha; - var particleCount = this._node.particleCount, particles = this._node._particles; - if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { - // Delay drawing until the texture is fully loaded by the browser - if (!node._texture || !node._texture._isLoaded) { - context.restore(); - return; - } - var element = node._texture.getHtmlElementObj(); - if (!element.width || !element.height) { - context.restore(); - return; - } - - var textureCache = cc.textureCache, drawElement = element; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); - - alpha = particle.color.a / 255; - if(alpha === 0) continue; - context.globalAlpha = alpha; - - context.save(); - context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); - - var size = Math.floor(particle.size / 4) * 4; - var w = pointRect.width; - var h = pointRect.height; - - context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); - - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - - if (particle.isChangeColor) { - var cacheTextureForColor = textureCache.getTextureColors(element); - if (cacheTextureForColor) { - // Create another cache for the tinted version - // This speeds up things by a fair bit - if (!cacheTextureForColor.tintCache) { - cacheTextureForColor.tintCache = cc.newElement('canvas'); - cacheTextureForColor.tintCache.width = element.width; - cacheTextureForColor.tintCache.height = element.height; - } - cc.generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); - drawElement = cacheTextureForColor.tintCache; - } - } - context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); - context.restore(); - } - } else { - var drawTool = cc._drawingUtil; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); - alpha = particle.color.a / 255; - if(alpha === 0) continue; - context.globalAlpha = alpha; - - context.save(); - context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - drawTool.drawStar(context, lpx, particle.color); - } else - drawTool.drawColorBall(context, lpx, particle.color); - context.restore(); - } - } - context.restore(); - cc.g_NumberOfDraws++; - }; - - // the canvas implement of renderCommand for cc.ProgressTimer - cc.ProgressRenderCmdCanvas = function (node) { - this._PI180 = Math.PI / 180; - - this._node = node; - this._sprite = null; - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._barRect = cc.rect(0, 0, 0, 0); - this._origin = cc.p(0, 0); - this._radius = 0; - this._startAngle = 270; - this._endAngle = 270; - this._counterClockWise = false; - }; - - cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; - - var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; - - if(locTextureCoord.width === 0 || locTextureCoord.height === 0) - return; - if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) - return; - + } else { + node.transform(); var t = node._transformWorld; context.save(); + context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } +}; - if (locSprite._blendFuncStr != "source-over") - context.globalCompositeOperation = locSprite._blendFuncStr; - context.globalAlpha = alpha; - - var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; - var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; - locDrawSizeCanvas.width = locRect.width * scaleX; - locDrawSizeCanvas.height = locRect.height * scaleY; - - if (locSprite._flippedX) { - flipXOffset = -locOffsetPosition.x - locRect.width; - context.scale(-1, 1); - } - if (locSprite._flippedY) { - flipYOffset = locOffsetPosition.y; - context.scale(1, -1); - } - - flipXOffset *= scaleX; - flipYOffset *= scaleY; - - //clip - if (this._type == cc.ProgressTimer.TYPE_BAR) { - var locBarRect = this._barRect; - context.beginPath(); - context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); - context.clip(); - context.closePath(); - } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { - var locOriginX = this._origin.x * scaleX; - var locOriginY = this._origin.y * scaleY; - context.beginPath(); - context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); - context.lineTo(locOriginX, locOriginY); - context.clip(); - context.closePath(); - } - - //draw sprite - var image = locSprite._texture.getHtmlElementObj(); - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); +cc.ClippingNodeClipRenderCmdCanvas = function (node) { + this._node = node; +}; - context.restore(); - cc.g_NumberOfDraws++; - }; - - cc.DrawNodeRenderCmdCanvas = function (node) { - this._node = node; - this._buffer = null; - this._drawColor = null; - this._blendFunc = null; - }; - - cc.DrawNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, _t = this, node = _t._node; - var alpha = node._displayedOpacity/255; - if(alpha === 0) - return; - context.globalAlpha = alpha; +cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var context = ctx || cc._renderContext; + if (node._clipElemType) { + context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; var t = node._transformWorld; - context.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) - context.globalCompositeOperation = 'lighter'; - var locBuffer = _t._buffer; - for (var i = 0, len = locBuffer.length; i < len; i++) { - var element = locBuffer[i]; - switch (element.type) { - case cc.DrawNode.TYPE_DOT: - _t._drawDot(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_SEGMENT: - _t._drawSegment(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_POLY: - _t._drawPoly(context, element, scaleX, scaleY); - break; - } - } + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } else { context.restore(); - }; - - cc.DrawNodeRenderCmdCanvas.prototype._drawDot = function (ctx, element, scaleX, scaleY) { - var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; - - ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.beginPath(); - ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); - ctx.closePath(); - ctx.fill(); - }; - - cc.DrawNodeRenderCmdCanvas.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { - var locColor = element.lineColor; - var locFrom = element.verts[0], locTo = element.verts[1]; - var locLineWidth = element.lineWidth, locLineCap = element.lineCap; - - ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.lineWidth = locLineWidth * scaleX; - ctx.beginPath(); - ctx.lineCap = locLineCap; - ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); - ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); - ctx.stroke(); - }; - - cc.DrawNodeRenderCmdCanvas.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { - var locVertices = element.verts, locLineCap = element.lineCap; - var locFillColor = element.fillColor, locLineWidth = element.lineWidth; - var locLineColor = element.lineColor, locIsClosePolygon = element.isClosePolygon; - var locIsFill = element.isFill, locIsStroke = element.isStroke; - if (locVertices == null) - return; - - var firstPoint = locVertices[0]; - ctx.lineCap = locLineCap; - if (locFillColor) - ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," - + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; - if (locLineWidth) - ctx.lineWidth = locLineWidth * scaleX; - if (locLineColor) - ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," - + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; - - ctx.beginPath(); - ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); - for (var i = 1, len = locVertices.length; i < len; i++) - ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); - - if (locIsClosePolygon) - ctx.closePath(); - if (locIsFill) - ctx.fill(); - if (locIsStroke) - ctx.stroke(); - }; - - cc.ClippingNodeSaveRenderCmdCanvas = function (node) { - this._node = node; - }; - - cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var context = ctx || cc._renderContext; - - if (node._clipElemType) { - var locCache = cc.ClippingNode._getSharedCache(); + if (node.inverted) { var canvas = context.canvas; - locCache.width = canvas.width; - locCache.height = canvas.height; - var locCacheCtx = locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - context.save(); - } else { - node.transform(); - var t = node._transformWorld; - context.save(); context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } - }; - cc.ClippingNodeClipRenderCmdCanvas = function (node) { - this._node = node; - }; + context.setTransform(1, 0, 0, 1, 0, 0); - cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var context = ctx || cc._renderContext; + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); - if (node._clipElemType) { - context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; - var t = node._transformWorld; - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } else { context.restore(); - if (node.inverted) { - var canvas = context.canvas; - context.save(); - - context.setTransform(1, 0, 0, 1, 0, 0); - - context.moveTo(0, 0); - context.lineTo(0, canvas.height); - context.lineTo(canvas.width, canvas.height); - context.lineTo(canvas.width, 0); - context.lineTo(0, 0); - - context.restore(); - } - context.clip(); } - }; - - cc.ClippingNodeRestoreRenderCmdCanvas = function (node) { - this._node = node; - }; - - cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var locCache = cc.ClippingNode._getSharedCache(); - var context = ctx || cc._renderContext; - if (node._clipElemType) { - context.restore(); + context.clip(); + } +}; + +cc.ClippingNodeRestoreRenderCmdCanvas = function (node) { + this._node = node; +}; + +cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var locCache = cc.ClippingNode._getSharedCache(); + var context = ctx || cc._renderContext; + if (node._clipElemType) { + context.restore(); - // Redraw the cached canvas, so that the cliped area shows the background etc. - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalCompositeOperation = "destination-over"; - context.drawImage(locCache, 0, 0); - context.restore(); - } else { - context.restore(); + // Redraw the cached canvas, so that the cliped area shows the background etc. + context.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.globalCompositeOperation = "destination-over"; + context.drawImage(locCache, 0, 0); + context.restore(); + } else { + context.restore(); + } +}; + +//CHIPMUNK +cc.PhysicsDebugNodeRenderCmdCanvas = function (node) { + this._node = node; + this._buffer = node._buffer; +}; + +cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var _node = this._node; + + if (!_node._space) + return; + + _node._space.eachShape(cc.DrawShape.bind(_node)); + _node._space.eachConstraint(cc.DrawConstraint.bind(_node)); + cc.DrawNodeRenderCmdCanvas.prototype.rendering.call(this, ctx, scaleX, scaleY); + _node.clear(); +}; + +cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; +cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; +cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; + +//--- TMXLayer's render command --- +cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { + this._node = tmxLayer; + this._childrenRenderCmds = []; +}; + +cc.TMXLayerRenderCmdCanvas.prototype._copyRendererCmds = function (rendererCmds) { + if (!rendererCmds) + return; + + var locCacheCmds = this._childrenRenderCmds; + locCacheCmds.length = 0; + for (var i = 0, len = rendererCmds.length; i < len; i++) { + locCacheCmds[i] = rendererCmds[i]; + } +}; + +cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function (scaleX, scaleY) { + var locNode = this._node; + if (locNode._cacheDirty) { + var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; + + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + //reset the cache context + var t = cc.affineTransformInvert(locNode._transformWorld); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + for (var i = 0, len = locCacheCmds.length; i < len; i++) { + locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); + if (locCacheCmds[i]._node) + locCacheCmds[i]._node._cacheDirty = false; } - }; - - //CHIPMUNK - cc.PhysicsDebugNodeRenderCmdCanvas = function (node) { - this._node = node; - this._buffer = node._buffer; - }; - - cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var _node = this._node; - - if (!_node._space) - return; - - _node._space.eachShape(cc.DrawShape.bind(_node)); - _node._space.eachConstraint(cc.DrawConstraint.bind(_node)); - cc.DrawNodeRenderCmdCanvas.prototype.rendering.call(this, ctx, scaleX, scaleY); - _node.clear(); - }; - - cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; - cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; - cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; - - //--- TMXLayer's render command --- - cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { - this._node = tmxLayer; - this._childrenRenderCmds = []; - }; + locCacheContext.restore(); + locNode._cacheDirty = false; + } +}; + +cc.TMXLayerRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var alpha = node._displayedOpacity / 255; + if (alpha <= 0) + return; + + this._renderingChildToCache(scaleX, scaleY); + var context = ctx || cc._renderContext; + context.globalAlpha = alpha; + var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); + var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; + //direct draw image by canvas drawImage + if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - cc.TMXLayerRenderCmdCanvas.prototype._copyRendererCmds = function (rendererCmds) { - if (!rendererCmds) - return; + var locCanvasHeight = locCacheCanvas.height * scaleY; - var locCacheCmds = this._childrenRenderCmds; - locCacheCmds.length = 0; - for (var i = 0, len = rendererCmds.length; i < len; i++) { - locCacheCmds[i] = rendererCmds[i]; + if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) { + var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); + } else { + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); } - }; - - cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function (scaleX, scaleY) { - var locNode = this._node; - if (locNode._cacheDirty) { - var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; - - locCacheContext.save(); - locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - //reset the cache context - var t = cc.affineTransformInvert(locNode._transformWorld); - locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - for (var i = 0, len = locCacheCmds.length; i < len; i++) { - locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); - if (locCacheCmds[i]._node) - locCacheCmds[i]._node._cacheDirty = false; - } - locCacheContext.restore(); - locNode._cacheDirty = false; + context.restore(); + } + cc.g_NumberOfDraws++; +}; + +cc.CustomRenderCmdCanvas = function (node, func) { + this._node = node; + this._callback = func; +}; + +cc.CustomRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + if (!this._callback) + return; + this._callback.call(this._node, ctx, scaleX, scaleY); +}; + +cc.SkeletonRenderCmdCanvas = function (node) { + this._node = node; +}; + +cc.SkeletonRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + ctx = ctx || cc._renderContext; + + if (!node._debugSlots && !node._debugBones) { + return; + } + var t = node._transformWorld; + ctx.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + var locSkeleton = node._skeleton; + var attachment, slot, i, n, drawingUtil = cc._drawingUtil; + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + var points = []; + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); + drawingUtil.drawPoly(points, 4, true); } - }; - - cc.TMXLayerRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var alpha = node._displayedOpacity/255; - if(alpha <= 0) - return; - - this._renderingChildToCache(scaleX, scaleY); - var context = ctx || cc._renderContext; - context.globalAlpha = alpha; - var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); - var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; - //direct draw image by canvas drawImage - if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { - context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - var locCanvasHeight = locCacheCanvas.height * scaleY; - - if(node.layerOrientation === cc.TMX_ORIENTATION_HEX){ - var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); - } else { - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); - } - context.restore(); + } + + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine( + {x: bone.worldX, y: bone.worldY}, + {x: x, y: y}); } - cc.g_NumberOfDraws++; - }; - - cc.CustomRenderCmdCanvas = function(node, func){ - this._node = node; - this._callback = func; - }; - - cc.CustomRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - if(!this._callback) - return; - this._callback.call(this._node, ctx, scaleX, scaleY); - }; - - cc.SkeletonRenderCmdCanvas = function(node){ - this._node = node; - }; - cc.SkeletonRenderCmdCanvas.prototype.rendering = function(ctx, scaleX, scaleY){ - var node = this._node; - ctx = ctx || cc._renderContext; - - if(!node._debugSlots && !node._debugBones){ - return; - } - var t = node._transformWorld; - ctx.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - var locSkeleton = node._skeleton; - var attachment,slot, i, n, drawingUtil = cc._drawingUtil; - if (node._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); - - var points = []; - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); - drawingUtil.drawPoly(points, 4, true); - } - } + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - if (node._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine( - {x:bone.worldX, y:bone.worldY}, - {x:x, y:y}); - } - - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint({x:bone.worldX, y:bone.worldY}); - if (i === 0) - drawingUtil.setDrawColor(0, 255, 0, 255); - } + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint({x: bone.worldX, y: bone.worldY}); + if (i === 0) + drawingUtil.setDrawColor(0, 255, 0, 255); } - ctx.restore(); - }; -} + } + ctx.restore(); +}; +//} diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 4e44cfd642..eac835ab6e 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -22,646 +22,572 @@ THE SOFTWARE. ****************************************************************************/ -if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - cc.rendererWebGL = { - childrenOrderDirty: true, - _transformNodePool: [], //save nodes transform dirty - _renderCmds: [], //save renderer commands - - _isCacheToBufferOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds - _cacheToBufferCmds: {}, // an array saves the renderer commands need for cache to other canvas - _cacheInstanceIds:[], - _currentID: 0, - - /** - * drawing all renderer command to context (default is cc._renderContext) - * @param {WebGLRenderingContext} [ctx=cc._renderContext] - */ - rendering: function (ctx) { - var locCmds = this._renderCmds, - i, - len; - var context = ctx || cc._renderContext; - for (i = 0, len = locCmds.length; i < len; i++) { - locCmds[i].rendering(context); - } - }, - - _turnToCacheMode: function(renderTextureID){ - this._isCacheToBufferOn = true; - renderTextureID = renderTextureID || 0; - this._cacheToBufferCmds[renderTextureID] = []; - this._cacheInstanceIds.push(renderTextureID); - this._currentID = renderTextureID; - }, +cc.rendererWebGL = { + childrenOrderDirty: true, + _transformNodePool: [], //save nodes transform dirty + _renderCmds: [], //save renderer commands + + _isCacheToBufferOn: false, //a switch that whether cache the rendererCmd to cacheToCanvasCmds + _cacheToBufferCmds: {}, // an array saves the renderer commands need for cache to other canvas + _cacheInstanceIds: [], + _currentID: 0, + + getRenderCmd: function (renderableObject) { + //TODO Add renderCmd pool here + return renderableObject._createRenderCmd(); + }, + + /** + * drawing all renderer command to context (default is cc._renderContext) + * @param {WebGLRenderingContext} [ctx=cc._renderContext] + */ + rendering: function (ctx) { + var locCmds = this._renderCmds, + i, + len; + var context = ctx || cc._renderContext; + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(context); + } + }, + + _turnToCacheMode: function (renderTextureID) { + this._isCacheToBufferOn = true; + renderTextureID = renderTextureID || 0; + this._cacheToBufferCmds[renderTextureID] = []; + this._cacheInstanceIds.push(renderTextureID); + this._currentID = renderTextureID; + }, + + _turnToNormalMode: function () { + this._isCacheToBufferOn = false; + }, + + /** + * drawing all renderer command to cache canvas' context + * @param {Number} [renderTextureId] + */ + _renderingToBuffer: function (renderTextureId) { + renderTextureId = renderTextureId || this._currentID; + var locCmds = this._cacheToBufferCmds[renderTextureId], i, len; + var ctx = cc._renderContext, locIDs = this._cacheInstanceIds; + for (i = 0, len = locCmds.length; i < len; i++) { + locCmds[i].rendering(ctx); + } + locCmds.length = 0; + delete this._cacheToBufferCmds[renderTextureId]; + cc.arrayRemoveObject(locIDs, renderTextureId); - _turnToNormalMode: function(){ + if (locIDs.length === 0) this._isCacheToBufferOn = false; - }, - - /** - * drawing all renderer command to cache canvas' context - * @param {Number} [renderTextureId] - */ - _renderingToBuffer: function (renderTextureId) { - renderTextureId = renderTextureId || this._currentID; - var locCmds = this._cacheToBufferCmds[renderTextureId], i, len; - var ctx = cc._renderContext, locIDs = this._cacheInstanceIds; - for (i = 0, len = locCmds.length; i < len; i++) { - locCmds[i].rendering(ctx); - } - locCmds.length = 0; - delete this._cacheToBufferCmds[renderTextureId]; - cc.arrayRemoveObject(locIDs, renderTextureId); - - if (locIDs.length === 0) - this._isCacheToBufferOn = false; - else - this._currentID = locIDs[locIDs.length - 1]; - }, - - //reset renderer's flag - resetFlag: function () { - this.childrenOrderDirty = false; - this._transformNodePool.length = 0; - }, - - //update the transform data - transform: function () { - var locPool = this._transformNodePool; - //sort the pool - locPool.sort(this._sortNodeByLevelAsc); - //transform node - for (var i = 0, len = locPool.length; i < len; i++) { - if (locPool[i]._renderCmdDiry) - locPool[i]._transformForRenderer(); - } - locPool.length = 0; - }, - - transformDirty: function () { - return this._transformNodePool.length > 0; - }, - - _sortNodeByLevelAsc: function (n1, n2) { - return n1._curLevel - n2._curLevel; - }, - - pushDirtyNode: function (node) { - //if (this._transformNodePool.indexOf(node) === -1) - this._transformNodePool.push(node); - }, - - clearRenderCommands: function () { - this._renderCmds.length = 0; - }, - - pushRenderCommand: function (cmd) { - if (this._isCacheToBufferOn) { - var currentId = this._currentID, locCmdBuffer = this._cacheToBufferCmds; - var cmdList = locCmdBuffer[currentId]; - if (cmdList.indexOf(cmd) === -1) - cmdList.push(cmd); - } else { - if (this._renderCmds.indexOf(cmd) === -1) - this._renderCmds.push(cmd); - } + else + this._currentID = locIDs[locIDs.length - 1]; + }, + + //reset renderer's flag + resetFlag: function () { + this.childrenOrderDirty = false; + this._transformNodePool.length = 0; + }, + + //update the transform data + transform: function () { + var locPool = this._transformNodePool; + //sort the pool + locPool.sort(this._sortNodeByLevelAsc); + //transform node + for (var i = 0, len = locPool.length; i < len; i++) { + if (locPool[i]._renderCmdDiry) + locPool[i]._transformForRenderer(); } - }; - cc.renderer = cc.rendererWebGL; - - //sprite renderer command - cc.TextureRenderCmdWebGL = function(node){ - this._node = node; - }; - - cc.TextureRenderCmdWebGL.prototype.rendering = function(ctx){ - var _t = this._node; - if (!_t._textureLoaded || _t._displayedOpacity === 0) - return; + locPool.length = 0; + }, - var gl = ctx || cc._renderContext, locTexture = _t._texture; - //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); + transformDirty: function () { + return this._transformNodePool.length > 0; + }, - if (locTexture) { - if (locTexture._isLoaded) { - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + _sortNodeByLevelAsc: function (n1, n2) { + return n1._curLevel - n2._curLevel; + }, - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - //optimize performance for javascript - cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + pushDirtyNode: function (node) { + //if (this._transformNodePool.indexOf(node) === -1) + this._transformNodePool.push(node); + }, - gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (_t._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.DYNAMIC_DRAW); - _t._quadDirty = false; - } - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS + clearRenderCommands: function () { + this._renderCmds.length = 0; + }, - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - } + pushRenderCommand: function (cmd) { + if(!cmd._needDraw) + return; + if (this._isCacheToBufferOn) { + var currentId = this._currentID, locCmdBuffer = this._cacheToBufferCmds; + var cmdList = locCmdBuffer[currentId]; + if (cmdList.indexOf(cmd) === -1) + cmdList.push(cmd); } else { - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - cc.glBindTexture2D(null); - - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - - gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (_t._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.STATIC_DRAW); - _t._quadDirty = false; - } - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + if (this._renderCmds.indexOf(cmd) === -1) + this._renderCmds.push(cmd); } - cc.g_NumberOfDraws++; - }; - - //LayerColor render command - cc.RectRenderCmdWebGL = function(node){ - this._node = node; - }; - - cc.RectRenderCmdWebGL.prototype.rendering = function(ctx){ - var context = ctx || cc._renderContext; - var node = this._node; - - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - - // - // Attributes - // - context.bindBuffer(context.ARRAY_BUFFER, node._verticesFloat32Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); - - context.bindBuffer(context.ARRAY_BUFFER, node._colorsUint8Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); - - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - context.drawArrays(context.TRIANGLE_STRIP, 0, 4); - }; - - cc.DrawNodeRenderCmdWebGL = function (node) { - this._node = node; - }; + } +}; +if (cc._renderType === cc._RENDER_TYPE_WEBGL) + cc.renderer = cc.rendererWebGL; - cc.DrawNodeRenderCmdWebGL.prototype.rendering = function(ctx){ - var _t = this._node; - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); +cc.DrawNodeRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.DrawNodeRenderCmdWebGL.prototype.rendering = function (ctx) { + var _t = this._node; + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + _t._render(); +}; + +cc.MotionStreakCmdWebGL = function (node) { + this._node = node; +}; + +cc.MotionStreakCmdWebGL.prototype.rendering = function (ctx) { + var _t = this._node; + if (_t._nuPoints <= 1) + return; + + if (_t.texture && _t.texture.isLoaded()) { + ctx = ctx || cc._renderContext; _t._shaderProgram.use(); _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - _t._render(); - }; - - cc.MotionStreakCmdWebGL = function(node){ - this._node = node; - }; - - cc.MotionStreakCmdWebGL.prototype.rendering = function(ctx){ - var _t = this._node; - if (_t._nuPoints <= 1) - return; - - if(_t.texture && _t.texture.isLoaded()){ - ctx = ctx || cc._renderContext; - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - - cc.glBindTexture2D(_t.texture); - - //position - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._verticesBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._vertices, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); - - //texcoords - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._texCoordsBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._texCoords, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); - - //colors - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._colorPointerBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._colorPointer, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); - - ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, _t._nuPoints * 2); - cc.g_NumberOfDraws ++; - } - }; - - cc.ProgressRenderCmdWebGL = function (node) { - this._node = node; - }; + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - cc.ProgressRenderCmdWebGL.prototype.rendering = function(ctx){ - var _t = this._node; - var context = ctx || cc._renderContext; - if (!_t._vertexData || !_t._sprite) - return; + cc.glBindTexture2D(_t.texture); - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + //position + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._verticesBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._vertices, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); - var blendFunc = _t._sprite.getBlendFunc(); - cc.glBlendFunc(blendFunc.src, blendFunc.dst); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + //texcoords + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._texCoordsBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._texCoords, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); - cc.glBindTexture2D(_t._sprite.texture); + //colors + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._colorPointerBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._colorPointer, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); - context.bindBuffer(context.ARRAY_BUFFER, _t._vertexWebGLBuffer); - if(_t._vertexDataDirty){ - context.bufferData(context.ARRAY_BUFFER, _t._vertexArrayBuffer, context.DYNAMIC_DRAW); - _t._vertexDataDirty = false; + ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, _t._nuPoints * 2); + cc.g_NumberOfDraws++; + } +}; + +cc.ProgressRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.ProgressRenderCmdWebGL.prototype.rendering = function (ctx) { + var _t = this._node; + var context = ctx || cc._renderContext; + if (!_t._vertexData || !_t._sprite) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + var blendFunc = _t._sprite.getBlendFunc(); + cc.glBlendFunc(blendFunc.src, blendFunc.dst); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + cc.glBindTexture2D(_t._sprite.texture); + + context.bindBuffer(context.ARRAY_BUFFER, _t._vertexWebGLBuffer); + if (_t._vertexDataDirty) { + context.bufferData(context.ARRAY_BUFFER, _t._vertexArrayBuffer, context.DYNAMIC_DRAW); + _t._vertexDataDirty = false; + } + var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); + 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 (_t._type === cc.ProgressTimer.TYPE_RADIAL) + context.drawArrays(context.TRIANGLE_FAN, 0, _t._vertexDataCount); + else if (_t._type == cc.ProgressTimer.TYPE_BAR) { + if (!_t._reverseDirection) + context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount); + else { + context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount / 2); + context.drawArrays(context.TRIANGLE_STRIP, 4, _t._vertexDataCount / 2); + // 2 draw calls + cc.g_NumberOfDraws++; } - var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); - 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 (_t._type === cc.ProgressTimer.TYPE_RADIAL) - context.drawArrays(context.TRIANGLE_FAN, 0, _t._vertexDataCount); - else if (_t._type == cc.ProgressTimer.TYPE_BAR) { - if (!_t._reverseDirection) - context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount); - else { - context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount / 2); - context.drawArrays(context.TRIANGLE_STRIP, 4, _t._vertexDataCount / 2); - // 2 draw calls - cc.g_NumberOfDraws++; + } + cc.g_NumberOfDraws++; +}; + +cc.ParticleRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.ParticleRenderCmdWebGL.prototype.rendering = function (ctx) { + var _t = this._node; + if (!_t._texture) + return; + + var gl = ctx || cc._renderContext; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); + + cc.glBindTexture2D(_t._texture); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + + //cc.assert(this._particleIdx == this.particleCount, "Abnormal error in particle quad"); + + // + // Using VBO without VAO + // + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); + gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); +}; + +cc.ParticleBatchNodeRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.ParticleBatchNodeRenderCmdWebGL.prototype.rendering = function (ctx) { + var _t = this._node; + if (_t.textureAtlas.totalQuads == 0) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + _t.textureAtlas.drawQuads(); +}; + +//RenderTexture render command +cc.RenderTextureRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.RenderTextureRenderCmdWebGL.prototype.rendering = function (ctx) { + var gl = ctx || cc._renderContext; + var node = this._node; + if (node.autoDraw) { + node.begin(); + + var locClearFlags = node.clearFlags; + if (locClearFlags) { + var oldClearColor = [0.0, 0.0, 0.0, 0.0]; + var oldDepthClearValue = 0.0; + var oldStencilClearValue = 0; + + // backup and set + if (locClearFlags & gl.COLOR_BUFFER_BIT) { + oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); + gl.clearColor(node._clearColor.r / 255, node._clearColor.g / 255, node._clearColor.b / 255, node._clearColor.a / 255); } - } - cc.g_NumberOfDraws++; - }; - - cc.ParticleRenderCmdWebGL = function(node){ - this._node = node; - }; - - cc.ParticleRenderCmdWebGL.prototype.rendering = function(ctx){ - var _t = this._node; - if(!_t._texture) - return; - - var gl = ctx || cc._renderContext; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); - - cc.glBindTexture2D(_t._texture); - cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); - - //cc.assert(this._particleIdx == this.particleCount, "Abnormal error in particle quad"); - - // - // Using VBO without VAO - // - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); - gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); - }; - cc.ParticleBatchNodeRenderCmdWebGL = function(node){ - this._node = node; - }; - - cc.ParticleBatchNodeRenderCmdWebGL.prototype.rendering = function(ctx){ - var _t = this._node; - if (_t.textureAtlas.totalQuads == 0) - return; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); - _t.textureAtlas.drawQuads(); - }; - - //RenderTexture render command - cc.RenderTextureRenderCmdWebGL = function(node){ - this._node = node; - }; - - cc.RenderTextureRenderCmdWebGL.prototype.rendering = function(ctx){ - var gl = ctx || cc._renderContext; - var node = this._node; - if (node.autoDraw) { - node.begin(); - - var locClearFlags = node.clearFlags; - if (locClearFlags) { - var oldClearColor = [0.0, 0.0, 0.0, 0.0]; - var oldDepthClearValue = 0.0; - var oldStencilClearValue = 0; - - // backup and set - if (locClearFlags & gl.COLOR_BUFFER_BIT) { - oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); - gl.clearColor(node._clearColor.r/255, node._clearColor.g/255, node._clearColor.b/255, node._clearColor.a/255); - } - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) { - oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - gl.clearDepth(node.clearDepthVal); - } - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) { - oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); - gl.clearStencil(node.clearStencilVal); - } - - // clear - gl.clear(locClearFlags); - - // restore - if (locClearFlags & gl.COLOR_BUFFER_BIT) - gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) - gl.clearDepth(oldDepthClearValue); - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) - gl.clearStencil(oldStencilClearValue); + if (locClearFlags & gl.DEPTH_BUFFER_BIT) { + oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + gl.clearDepth(node.clearDepthVal); } - //! make sure all children are drawn - node.sortAllChildren(); - var locChildren = node._children; - for (var i = 0; i < locChildren.length; i++) { - var getChild = locChildren[i]; - if (getChild != node.sprite) - getChild.visit(); + if (locClearFlags & gl.STENCIL_BUFFER_BIT) { + oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); + gl.clearStencil(node.clearStencilVal); } - node.end(); - } - }; - - cc.SpriteBatchNodeRenderCmdWebGL = function(node){ - this._node = node; - }; - cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering = function(ctx){ - var node = this._node; - if (node.textureAtlas.totalQuads === 0) - return; - - //cc.nodeDrawSetup(this); - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); - node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - - node.textureAtlas.drawQuads(); - }; - - cc.AtlasNodeRenderCmdWebGL = function(node){ - this._node = node; - }; + // clear + gl.clear(locClearFlags); - cc.AtlasNodeRenderCmdWebGL.prototype.rendering = function(ctx){ - var context = ctx || cc._renderContext, node = this._node; + // restore + if (locClearFlags & gl.COLOR_BUFFER_BIT) + gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + if (locClearFlags & gl.DEPTH_BUFFER_BIT) + gl.clearDepth(oldDepthClearValue); - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - if(node._uniformColor && node._colorF32Array){ - context.uniform4fv(node._uniformColor, node._colorF32Array); - node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); + if (locClearFlags & gl.STENCIL_BUFFER_BIT) + gl.clearStencil(oldStencilClearValue); } - }; - - cc.CustomRenderCmdWebGL = function(node, func){ - this._node = node; - this._callback = func; - }; - - cc.CustomRenderCmdWebGL.prototype.rendering = function(ctx){ - if(!this._callback) - return; - this._callback.call(this._node, ctx); - }; - - cc.TMXLayerRenderCmdWebGL = function(node){ - this._node = node; - }; - cc.TMXLayerRenderCmdWebGL.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; - - cc.PhysicsDebugNodeRenderCmdWebGL = function(node){ - this._node = node; - }; - - cc.PhysicsDebugNodeRenderCmdWebGL.prototype.rendering = function(ctx){ - var node = this._node; - if (!node._space) - return; - - node._space.eachShape(cc.DrawShape.bind(node)); - node._space.eachConstraint(cc.DrawConstraint.bind(node)); - cc.DrawNode.prototype.draw.call(node); - node.clear(); - }; - - cc.SkeletonRenderCmdWebGL = function(node){ - this._node = node; - }; - - cc.SkeletonRenderCmdWebGL.prototype.rendering = function(ctx){ - var node = this._node; - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); -// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - var color = node.getColor(), locSkeleton = node._skeleton; - locSkeleton.r = color.r / 255; - locSkeleton.g = color.g / 255; - locSkeleton.b = color.b / 255; - locSkeleton.a = node.getOpacity() / 255; - if (node._premultipliedAlpha) { - locSkeleton.r *= locSkeleton.a; - locSkeleton.g *= locSkeleton.a; - locSkeleton.b *= locSkeleton.a; + //! make sure all children are drawn + node.sortAllChildren(); + var locChildren = node._children; + for (var i = 0; i < locChildren.length; i++) { + var getChild = locChildren[i]; + if (getChild != node.sprite) + getChild.visit(); } - - var additive,textureAtlas,attachment,slot, i, n, - quad = new cc.V3F_C4B_T2F_Quad(); - var locBlendFunc = node._blendFunc; - - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - var regionTextureAtlas = node.getTextureAtlas(attachment); - - if (slot.data.additiveBlending != additive) { - if (textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - additive = !additive; - cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); - } else if (regionTextureAtlas != textureAtlas && textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - textureAtlas = regionTextureAtlas; - - var quadCount = textureAtlas.getTotalQuads(); - if (textureAtlas.getCapacity() == quadCount) { + node.end(); + } +}; + +cc.SpriteBatchNodeRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering = function (ctx) { + var node = this._node; + if (node.textureAtlas.totalQuads === 0) + return; + + //cc.nodeDrawSetup(this); + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + + node.textureAtlas.drawQuads(); +}; + +cc.AtlasNodeRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.AtlasNodeRenderCmdWebGL.prototype.rendering = function (ctx) { + var context = ctx || cc._renderContext, node = this._node; + + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + if (node._uniformColor && node._colorF32Array) { + context.uniform4fv(node._uniformColor, node._colorF32Array); + node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); + } +}; + +cc.CustomRenderCmdWebGL = function (node, func) { + this._node = node; + this._callback = func; +}; + +cc.CustomRenderCmdWebGL.prototype.rendering = function (ctx) { + if (!this._callback) + return; + this._callback.call(this._node, ctx); +}; + +cc.TMXLayerRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.TMXLayerRenderCmdWebGL.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; + +cc.PhysicsDebugNodeRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.PhysicsDebugNodeRenderCmdWebGL.prototype.rendering = function (ctx) { + var node = this._node; + if (!node._space) + return; + + node._space.eachShape(cc.DrawShape.bind(node)); + node._space.eachConstraint(cc.DrawConstraint.bind(node)); + cc.DrawNode.prototype.draw.call(node); + node.clear(); +}; + +cc.SkeletonRenderCmdWebGL = function (node) { + this._node = node; +}; + +cc.SkeletonRenderCmdWebGL.prototype.rendering = function (ctx) { + var node = this._node; + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); +// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); + var color = node.getColor(), locSkeleton = node._skeleton; + locSkeleton.r = color.r / 255; + locSkeleton.g = color.g / 255; + locSkeleton.b = color.b / 255; + locSkeleton.a = node.getOpacity() / 255; + if (node._premultipliedAlpha) { + locSkeleton.r *= locSkeleton.a; + locSkeleton.g *= locSkeleton.a; + locSkeleton.b *= locSkeleton.a; + } + + var additive, textureAtlas, attachment, slot, i, n, + quad = new cc.V3F_C4B_T2F_Quad(); + var locBlendFunc = node._blendFunc; + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + var regionTextureAtlas = node.getTextureAtlas(attachment); + + if (slot.data.additiveBlending != additive) { + if (textureAtlas) { textureAtlas.drawQuads(); textureAtlas.removeAllQuads(); - if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) - return; } - - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); - textureAtlas.updateQuad(quad, quadCount); + additive = !additive; + cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); + } else if (regionTextureAtlas != textureAtlas && textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); } + textureAtlas = regionTextureAtlas; - if (textureAtlas) { + var quadCount = textureAtlas.getTotalQuads(); + if (textureAtlas.getCapacity() == quadCount) { textureAtlas.drawQuads(); textureAtlas.removeAllQuads(); + if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) + return; } - if(node._debugBones || node._debugSlots){ + sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + textureAtlas.updateQuad(quad, quadCount); + } - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - //cc.kmGLPushMatrixWitMat4(node._stackMatrix); - cc.current_stack.stack.push(cc.current_stack.top); - cc.current_stack.top = node._stackMatrix; + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } - var drawingUtil = cc._drawingUtil; + if (node._debugBones || node._debugSlots) { - if (node._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + //cc.kmGLPushMatrixWitMat4(node._stackMatrix); + cc.current_stack.stack.push(cc.current_stack.top); + cc.current_stack.top = node._stackMatrix; - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - quad = new cc.V3F_C4B_T2F_Quad(); - sp._regionAttachment_updateQuad(attachment, slot, quad); + var drawingUtil = cc._drawingUtil; - var points = []; - points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); - points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); - points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); - points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); - drawingUtil.drawPoly(points, 4, true); - } + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + quad = new cc.V3F_C4B_T2F_Quad(); + sp._regionAttachment_updateQuad(attachment, slot, quad); + + var points = []; + points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); + points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); + points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); + points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); + + drawingUtil.drawPoly(points, 4, true); } + } - if (node._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); - } + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + } - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); - if (i == 0) { - drawingUtil.setDrawColor(0, 255, 0, 255); - } + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + if (i == 0) { + drawingUtil.setDrawColor(0, 255, 0, 255); } } - - cc.kmGLPopMatrix(); } - }; - cc.ArmatureRenderCmdWebGL = function(node){ - this._node = node; - }; + cc.kmGLPopMatrix(); + } +}; - cc.ArmatureRenderCmdWebGL.prototype.rendering = function(ctx){ - var _t = this._node; +cc.ArmatureRenderCmdWebGL = function (node) { + this._node = node; +}; - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadMatrix(_t._stackMatrix); +cc.ArmatureRenderCmdWebGL.prototype.rendering = function (ctx) { + var _t = this._node; - //TODO REMOVE THIS FUNCTION - if (_t._parentBone == null && _t._batchNode == null) { - // CC_NODE_DRAW_SETUP(); - } + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadMatrix(_t._stackMatrix); - var locChildren = _t._children; - var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; - for (var i = 0, len = locChildren.length; i< len; i++) { - var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); + //TODO REMOVE THIS FUNCTION + if (_t._parentBone == null && _t._batchNode == null) { + // CC_NODE_DRAW_SETUP(); + } - if (null == node) - continue; + var locChildren = _t._children; + var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + for (var i = 0, len = locChildren.length; i < len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; - node.setShaderProgram(_t._shaderProgram); - - switch (selBone.getDisplayRenderNodeType()) { - case ccs.DISPLAY_TYPE_SPRITE: - if(node instanceof ccs.Skin){ - node.updateTransform(); - - var func = selBone.getBlendFunc(); - if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) - node.setBlendFunc(selBone.getBlendFunc()); - else { - if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) - && !node.getTexture().hasPremultipliedAlpha()) - node.setBlendFunc(alphaNonPremultipled); - else - node.setBlendFunc(_t._blendFunc); - } - node.draw(ctx); + node.setShaderProgram(_t._shaderProgram); + + switch (selBone.getDisplayRenderNodeType()) { + case ccs.DISPLAY_TYPE_SPRITE: + if (node instanceof ccs.Skin) { + node.updateTransform(); + + var func = selBone.getBlendFunc(); + if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + node.setBlendFunc(selBone.getBlendFunc()); + else { + if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) + && !node.getTexture().hasPremultipliedAlpha()) + node.setBlendFunc(alphaNonPremultipled); + else + node.setBlendFunc(_t._blendFunc); } - break; - case ccs.DISPLAY_TYPE_ARMATURE: node.draw(ctx); - break; - default: - node.visit(ctx); //TODO need fix soon - break; - } - } else if(selBone instanceof cc.Node) { - selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon - selBone.visit(ctx); - // CC_NODE_DRAW_SETUP(); + } + break; + case ccs.DISPLAY_TYPE_ARMATURE: + node.draw(ctx); + break; + default: + node.visit(ctx); //TODO need fix soon + break; } + } else if (selBone instanceof cc.Node) { + selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon + selBone.visit(ctx); + // CC_NODE_DRAW_SETUP(); } + } - cc.kmGLPopMatrix(); - }; -} + cc.kmGLPopMatrix(); +}; +//} diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 2b8b63e057..144b7f2eb9 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1159,6 +1159,13 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ locQuad.tr.texCoords.v = top; } this._quadDirty = true; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.Sprite.CanvasRenderCmd(this); + else + return new cc.Sprite.WebGLRenderCmd(this); } }); @@ -1246,7 +1253,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }; _p._initRendererCmd = function(){ - this._rendererCmd = new cc.TextureRenderCmdCanvas(this); + this._rendererCmd = cc.renderer.getRenderCmd(this); }; _p.setBlendFunc = function (src, dst) { diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js new file mode 100644 index 0000000000..ee7edac25d --- /dev/null +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -0,0 +1,234 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.Sprite.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + this._textureCoord = { + renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. + renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. + x: 0, //the x of texture coordinate for node. + y: 0, //the y of texture coordinate for node. + width: 0, + height: 0, + validRect: false + }; +}; + +cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + +cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var self = this, + node = self._node; + + var context = ctx || cc._renderContext, + locTextureCoord = self._textureCoord; + + if (node._texture && (locTextureCoord.width === 0 || locTextureCoord.height === 0)) + return; + if (!locTextureCoord.validRect && node._displayedOpacity === 0) + return; //draw nothing + + if (node._texture && !node._texture._isLoaded) //set texture but the texture isn't loaded. + return; + + var t = node._transformWorld, + locX = node._offsetPosition.x, + locY = -node._offsetPosition.y - node._rect.height, + locWidth = node._rect.width, + locHeight = node._rect.height, + image, curColor, contentSize; + + var blendChange = (node._blendFuncStr !== "source-over"), alpha = (node._displayedOpacity / 255); + + if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { + context.save(); + + context.globalAlpha = alpha; + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if (blendChange) + context.globalCompositeOperation = node._blendFuncStr; + + if (node._flippedX) { + locX = -locX - locWidth; + context.scale(-1, 1); + } + if (node._flippedY) { + locY = node._offsetPosition.y; + context.scale(1, -1); + } + + if (node._texture) { + image = node._texture._htmlElementObj; + + if (node._texture._pattern != "") { + context.save(); + context.fillStyle = context.createPattern(image, node._texture._pattern); + context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + context.restore(); + } else { + if (node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } + } + } else { + contentSize = node._contentSize; + if (locTextureCoord.validRect) { + curColor = node._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; + context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + } + } + context.restore(); + } else { + if (blendChange) { + context.save(); + context.globalCompositeOperation = node._blendFuncStr; + } + + context.globalAlpha = alpha; + if (node._texture) { + image = node._texture.getHtmlElementObj(); + if (node._texture._pattern != "") { + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillStyle = context.createPattern(image, node._texture._pattern); + context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + context.restore(); + } else { + if (node._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); + } else { + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); + } + } + } else { + contentSize = node._contentSize; + if (locTextureCoord.validRect) { + curColor = node._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; + context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + } + } + if (blendChange) + context.restore(); + } + cc.g_NumberOfDraws++; +}; + +//Sprite's WebGL render command +cc.Sprite.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd); + +cc.Sprite.WebGLRenderCmd.prototype.rendering = function (ctx) { + var _t = this._node; + if (!_t._textureLoaded || _t._displayedOpacity === 0) + return; + + var gl = ctx || cc._renderContext, locTexture = _t._texture; + //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); + + if (locTexture) { + if (locTexture._isLoaded) { + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + //optimize performance for javascript + cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); + if (_t._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.DYNAMIC_DRAW); + _t._quadDirty = false; + } + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + } else { + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + cc.glBindTexture2D(null); + + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); + if (_t._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.STATIC_DRAW); + _t._quadDirty = false; + } + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + cc.g_NumberOfDraws++; +}; \ No newline at end of file diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index 070c354171..b3757e2e65 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -63,10 +63,6 @@ cc._tmp.WebGLSprite = function () { self._softInit(fileName, rect, rotated); }; - _p._initRendererCmd = function(){ - this._rendererCmd = new cc.TextureRenderCmdWebGL(this); - }; - _p.setBlendFunc = function (src, dst) { var locBlendFunc = this._blendFunc; if (dst === undefined) { diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 6ce1edf970..17a5728988 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -373,11 +373,11 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } }, - _initRendererCmd: function(){ + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._rendererCmd = new cc.ParticleRenderCmdCanvas(this); + return new cc.ParticleSystem.CanvasRenderCmd(this); else - this._rendererCmd = new cc.ParticleRenderCmdWebGL(this); + return new cc.ParticleSystem.WebGLRenderCmd(this); }, /** diff --git a/cocos2d/particle/CCParticleSystemRenderCmd.js b/cocos2d/particle/CCParticleSystemRenderCmd.js new file mode 100644 index 0000000000..96aebb7679 --- /dev/null +++ b/cocos2d/particle/CCParticleSystemRenderCmd.js @@ -0,0 +1,154 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +// ParticleSystem's canvas render command +cc.ParticleSystem.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; +}; +cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + +cc.ParticleSystem.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, + node = this._node, + t = node._transformWorld, + pointRect = node._pointRect; + + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if (node.isBlendAdditive()) + context.globalCompositeOperation = 'lighter'; + else + context.globalCompositeOperation = 'source-over'; + + var i, particle, lpx, alpha; + var particleCount = this._node.particleCount, particles = this._node._particles; + if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { + // Delay drawing until the texture is fully loaded by the browser + if (!node._texture || !node._texture._isLoaded) { + context.restore(); + return; + } + var element = node._texture.getHtmlElementObj(); + if (!element.width || !element.height) { + context.restore(); + return; + } + + var textureCache = cc.textureCache, drawElement = element; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + + alpha = particle.color.a / 255; + if (alpha === 0) continue; + context.globalAlpha = alpha; + + context.save(); + context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); + + var size = Math.floor(particle.size / 4) * 4; + var w = pointRect.width; + var h = pointRect.height; + + context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); + + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + + if (particle.isChangeColor) { + var cacheTextureForColor = textureCache.getTextureColors(element); + if (cacheTextureForColor) { + // Create another cache for the tinted version + // This speeds up things by a fair bit + if (!cacheTextureForColor.tintCache) { + cacheTextureForColor.tintCache = cc.newElement('canvas'); + cacheTextureForColor.tintCache.width = element.width; + cacheTextureForColor.tintCache.height = element.height; + } + cc.generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); + drawElement = cacheTextureForColor.tintCache; + } + } + context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); + context.restore(); + } + } else { + var drawTool = cc._drawingUtil; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + alpha = particle.color.a / 255; + if (alpha === 0) continue; + context.globalAlpha = alpha; + + context.save(); + context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); + if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + drawTool.drawStar(context, lpx, particle.color); + } else + drawTool.drawColorBall(context, lpx, particle.color); + context.restore(); + } + } + context.restore(); + cc.g_NumberOfDraws++; +}; + +//ParticleSystem's WebGL render command +cc.ParticleSystem.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; +}; +cc.ParticleSystem.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + +cc.ParticleSystem.WebGLRenderCmd.prototype.rendering = function (ctx) { + var _t = this._node; + if (!_t._texture) + return; + + var gl = ctx || cc._renderContext; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); + + cc.glBindTexture2D(_t._texture); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + + // + // Using VBO without VAO + // + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); + gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); +}; diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index 13c07b36e7..dccdcc16a8 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -285,13 +285,8 @@ cc.DOM.methods = /** @lends cc.DOM# */{ setRotation:function (newRotation) { if (this._rotation == newRotation) return; - //save dirty region when before change - //this._addDirtyRegionToDirector(this.getBoundingBoxToWorld()); this._rotationX = this._rotationY = newRotation; - this._rotationRadiansX = this._rotationX * (Math.PI / 180); - this._rotationRadiansY = this._rotationY * (Math.PI / 180); - this.setNodeDirty(); this.dom.rotate(newRotation); }, diff --git a/moduleConfig.json b/moduleConfig.json index d5ead965ce..11cb8372a2 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -91,10 +91,12 @@ "cocos2d/core/layers/CCLayerWebGL.js", "cocos2d/core/layers/CCLayerPropertyDefine.js", "cocos2d/core/layers/CCLayer.js", + "cocos2d/core/layers/CCLayerRenderCmd.js", "cocos2d/core/sprites/SpritesWebGL.js", "cocos2d/core/sprites/SpritesPropertyDefine.js", "cocos2d/core/sprites/CCSprite.js", + "cocos2d/core/sprites/CCSpriteRenderCmd.js", "cocos2d/core/sprites/CCSpriteBatchNode.js", "cocos2d/core/sprites/CCBakeSprite.js", "cocos2d/core/sprites/CCAnimation.js", @@ -172,6 +174,7 @@ "cocos2d/particle/CCPNGReader.js", "cocos2d/particle/CCTIFFReader.js", "cocos2d/particle/CCParticleSystem.js", + "cocos2d/particle/CCParticleSystemRenderCmd.js", "cocos2d/particle/CCParticleExamples.js", "cocos2d/particle/CCParticleBatchNode.js" ], From f0bc589ce634eb7c9ab2a24bf65598a46f8877b8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 5 Nov 2014 17:27:30 +0800 Subject: [PATCH 0880/1564] Issue #2416: Add drawNode RenderCmd --- cocos2d/core/renderer/RendererCanvas.js | 98 +-------------- cocos2d/core/renderer/RendererWebGL.js | 11 -- cocos2d/core/sprites/CCSpriteRenderCmd.js | 1 + cocos2d/shape-nodes/CCDrawNode.js | 18 +-- cocos2d/shape-nodes/CCDrawNodeRenderCmd.js | 136 +++++++++++++++++++++ moduleConfig.json | 3 +- 6 files changed, 151 insertions(+), 116 deletions(-) create mode 100644 cocos2d/shape-nodes/CCDrawNodeRenderCmd.js diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index bb3cc7adbb..4ad605ff30 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -226,98 +226,6 @@ cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) cc.g_NumberOfDraws++; }; -cc.DrawNodeRenderCmdCanvas = function (node) { - this._node = node; - this._buffer = null; - this._drawColor = null; - this._blendFunc = null; -}; - -cc.DrawNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, _t = this, node = _t._node; - var alpha = node._displayedOpacity / 255; - if (alpha === 0) - return; - context.globalAlpha = alpha; - - var t = node._transformWorld; - context.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) - context.globalCompositeOperation = 'lighter'; - var locBuffer = _t._buffer; - for (var i = 0, len = locBuffer.length; i < len; i++) { - var element = locBuffer[i]; - switch (element.type) { - case cc.DrawNode.TYPE_DOT: - _t._drawDot(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_SEGMENT: - _t._drawSegment(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_POLY: - _t._drawPoly(context, element, scaleX, scaleY); - break; - } - } - context.restore(); -}; - -cc.DrawNodeRenderCmdCanvas.prototype._drawDot = function (ctx, element, scaleX, scaleY) { - var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; - - ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.beginPath(); - ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); - ctx.closePath(); - ctx.fill(); -}; - -cc.DrawNodeRenderCmdCanvas.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { - var locColor = element.lineColor; - var locFrom = element.verts[0], locTo = element.verts[1]; - var locLineWidth = element.lineWidth, locLineCap = element.lineCap; - - ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.lineWidth = locLineWidth * scaleX; - ctx.beginPath(); - ctx.lineCap = locLineCap; - ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); - ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); - ctx.stroke(); -}; - -cc.DrawNodeRenderCmdCanvas.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { - var locVertices = element.verts, locLineCap = element.lineCap; - var locFillColor = element.fillColor, locLineWidth = element.lineWidth; - var locLineColor = element.lineColor, locIsClosePolygon = element.isClosePolygon; - var locIsFill = element.isFill, locIsStroke = element.isStroke; - if (locVertices == null) - return; - - var firstPoint = locVertices[0]; - ctx.lineCap = locLineCap; - if (locFillColor) - ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," - + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; - if (locLineWidth) - ctx.lineWidth = locLineWidth * scaleX; - if (locLineColor) - ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," - + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; - - ctx.beginPath(); - ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); - for (var i = 1, len = locVertices.length; i < len; i++) - ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); - - if (locIsClosePolygon) - ctx.closePath(); - if (locIsFill) - ctx.fill(); - if (locIsStroke) - ctx.stroke(); -}; cc.ClippingNodeSaveRenderCmdCanvas = function (node) { this._node = node; @@ -416,9 +324,9 @@ cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, _node.clear(); }; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; -cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; +//cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; +//cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; +//cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; //--- TMXLayer's render command --- cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index eac835ab6e..9e5a2de01c 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -137,17 +137,6 @@ cc.rendererWebGL = { if (cc._renderType === cc._RENDER_TYPE_WEBGL) cc.renderer = cc.rendererWebGL; -cc.DrawNodeRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.DrawNodeRenderCmdWebGL.prototype.rendering = function (ctx) { - var _t = this._node; - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - _t._render(); -}; cc.MotionStreakCmdWebGL = function (node) { this._node = node; diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index ee7edac25d..c4f9908906 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -37,6 +37,7 @@ cc.Sprite.CanvasRenderCmd = function(renderableObject){ }; cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.Sprite.CanvasRenderCmd.prototype.constructor = cc.Sprite.CanvasRenderCmd; cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { var self = this, diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 17d2f22ef3..0aa7411bde 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -110,10 +110,6 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ this.init(); }, - _initRendererCmd: function(){ - this._rendererCmd = new cc.DrawNodeRenderCmdCanvas(this); - }, - // ----common function start ---- /** * Gets the blend func @@ -574,6 +570,10 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ */ clear: function () { this._buffer.length = 0; + }, + + _createRenderCmd: function(){ + return new cc.DrawNode.CanvasRenderCmd(this); } }); @@ -617,10 +617,6 @@ cc.DrawNodeWebGL = cc.Node.extend({ this.init(); }, - - _initRendererCmd: function(){ - this._rendererCmd = new cc.DrawNodeRenderCmdWebGL(this); - }, init:function () { if (cc.Node.prototype.init.call(this)) { @@ -1011,7 +1007,11 @@ cc.DrawNodeWebGL = cc.Node.extend({ clear:function () { this._buffer.length = 0; this._dirty = true; - } + }, + + _createRenderCmd: function(){ + return new cc.DrawNode.WebGLRenderCmd(this); +} }); cc.DrawNode = cc._renderType == cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas; diff --git a/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js new file mode 100644 index 0000000000..d1c9c468eb --- /dev/null +++ b/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js @@ -0,0 +1,136 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.DrawNode.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + this._buffer = null; + this._drawColor = null; + this._blendFunc = null; +}; + +cc.DrawNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.DrawNode.CanvasRenderCmd.prototype.constructor = cc.DrawNode.CanvasRenderCmd; + +cc.DrawNode.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, _t = this, node = _t._node; + var alpha = node._displayedOpacity / 255; + if (alpha === 0) + return; + context.globalAlpha = alpha; + + var t = node._transformWorld; + context.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) + context.globalCompositeOperation = 'lighter'; + var locBuffer = _t._buffer; + for (var i = 0, len = locBuffer.length; i < len; i++) { + var element = locBuffer[i]; + switch (element.type) { + case cc.DrawNode.TYPE_DOT: + _t._drawDot(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_SEGMENT: + _t._drawSegment(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_POLY: + _t._drawPoly(context, element, scaleX, scaleY); + break; + } + } + context.restore(); +}; + +cc.DrawNode.CanvasRenderCmd.prototype._drawDot = function (ctx, element, scaleX, scaleY) { + var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; + + ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.beginPath(); + ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); + ctx.closePath(); + ctx.fill(); +}; + +cc.DrawNode.CanvasRenderCmd.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { + var locColor = element.lineColor; + var locFrom = element.verts[0], locTo = element.verts[1]; + var locLineWidth = element.lineWidth, locLineCap = element.lineCap; + + ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.lineWidth = locLineWidth * scaleX; + ctx.beginPath(); + ctx.lineCap = locLineCap; + ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); + ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); + ctx.stroke(); +}; + +cc.DrawNode.CanvasRenderCmd.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { + var locVertices = element.verts, locLineCap = element.lineCap; + var locFillColor = element.fillColor, locLineWidth = element.lineWidth; + var locLineColor = element.lineColor, locIsClosePolygon = element.isClosePolygon; + var locIsFill = element.isFill, locIsStroke = element.isStroke; + if (locVertices == null) + return; + + var firstPoint = locVertices[0]; + ctx.lineCap = locLineCap; + if (locFillColor) + ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," + + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; + if (locLineWidth) + ctx.lineWidth = locLineWidth * scaleX; + if (locLineColor) + ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," + + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; + + ctx.beginPath(); + ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); + for (var i = 1, len = locVertices.length; i < len; i++) + ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); + + if (locIsClosePolygon) + ctx.closePath(); + if (locIsFill) + ctx.fill(); + if (locIsStroke) + ctx.stroke(); +}; + +cc.DrawNode.WebGLRenderCmd = function (renderableObject) { + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.DrawNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.DrawNode.WebGLRenderCmd.prototype.constructor = cc.DrawNode.WebGLRenderCmd; + +cc.DrawNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var _t = this._node; + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + _t._render(); +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 11cb8372a2..a4f7c0ce2b 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -206,7 +206,8 @@ "shape-nodes" : [ "core", - "cocos2d/shape-nodes/CCDrawNode.js" + "cocos2d/shape-nodes/CCDrawNode.js", + "cocos2d/shape-nodes/CCDrawNodeRenderCmd.js" ], "text-input" : [ "core", From f745a8bd70c6ec3fad98e6eb2407a898ef3c718b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 10:54:05 +0800 Subject: [PATCH 0881/1564] Fixed console.log.apply is not function (ie9) --- CCDebugger.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CCDebugger.js b/CCDebugger.js index 54be22d7c3..455d8301c0 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -312,8 +312,11 @@ cc._initDebugSetting = function (mode) { } } else { //log to console - if(!console) //console is null when user doesn't open dev tool on IE9 + if(!console){//console is null when user doesn't open dev tool on IE9 return; + }else if(!console.log.apply){ + return; + } cc.error = function(){ return console.error.apply(console, arguments); From 45908d0e2ef3bf0ee4eaed9e6e1ca17872f11a12 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 11:10:28 +0800 Subject: [PATCH 0882/1564] Fixed console.log.apply is not function (ie9) --- CCDebugger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCDebugger.js b/CCDebugger.js index 455d8301c0..199301df15 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -310,7 +310,7 @@ cc._initDebugSetting = function (mode) { locLog(cc.formatStr.apply(cc, arguments)); }; } - } else { + } else if(console && console.log.apply){ //log to console if(!console){//console is null when user doesn't open dev tool on IE9 return; From fa2dd4ecf4eafe2dbfe17e0a998e7a67ba275781 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 11:11:46 +0800 Subject: [PATCH 0883/1564] Fixed console.log.apply is not function (ie9) --- CCDebugger.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CCDebugger.js b/CCDebugger.js index 199301df15..b1ae21924a 100644 --- a/CCDebugger.js +++ b/CCDebugger.js @@ -310,13 +310,8 @@ cc._initDebugSetting = function (mode) { locLog(cc.formatStr.apply(cc, arguments)); }; } - } else if(console && console.log.apply){ + } else if(console && console.log.apply){//console is null when user doesn't open dev tool on IE9 //log to console - if(!console){//console is null when user doesn't open dev tool on IE9 - return; - }else if(!console.log.apply){ - return; - } cc.error = function(){ return console.error.apply(console, arguments); From e348f3bf6a8bbdf92885ed0bb9fb9dce591fd652 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 11:26:04 +0800 Subject: [PATCH 0884/1564] Issue #2416: Add ProgressTimer RenderCmd --- cocos2d/progress-timer/CCProgressTimer.js | 7 + .../CCProgressTimerRenderCmd.js | 156 ++++++++++++++++++ moduleConfig.json | 3 +- 3 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 cocos2d/progress-timer/CCProgressTimerRenderCmd.js diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index f980defc22..7f1ae047d4 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -823,6 +823,13 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ else if(locType === cc.ProgressTimer.TYPE_BAR) this._updateBar(); this._vertexDataDirty = true; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.ProgressTimer.CanvasRenderCmd(this); + else + return new cc.ProgressTimer.WebGLRenderCmd(this); } }); diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js new file mode 100644 index 0000000000..459cf36ee7 --- /dev/null +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -0,0 +1,156 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.ProgressTimer.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + + this._PI180 = Math.PI / 180; + this._sprite = null; + this._type = cc.ProgressTimer.TYPE_RADIAL; + this._barRect = cc.rect(0, 0, 0, 0); + this._origin = cc.p(0, 0); + this._radius = 0; + this._startAngle = 270; + this._endAngle = 270; + this._counterClockWise = false; +}; + +cc.ProgressTimer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.ProgressTimer.CanvasRenderCmd.prototype.constructor = cc.ProgressTimer.CanvasRenderCmd; + +cc.ProgressTimer.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; + + var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + + if (locTextureCoord.width === 0 || locTextureCoord.height === 0) + return; + if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) + return; + + var t = node._transformWorld; + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (locSprite._blendFuncStr != "source-over") + context.globalCompositeOperation = locSprite._blendFuncStr; + context.globalAlpha = alpha; + + var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; + var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; + locDrawSizeCanvas.width = locRect.width * scaleX; + locDrawSizeCanvas.height = locRect.height * scaleY; + + if (locSprite._flippedX) { + flipXOffset = -locOffsetPosition.x - locRect.width; + context.scale(-1, 1); + } + if (locSprite._flippedY) { + flipYOffset = locOffsetPosition.y; + context.scale(1, -1); + } + + flipXOffset *= scaleX; + flipYOffset *= scaleY; + + //clip + if (this._type == cc.ProgressTimer.TYPE_BAR) { + var locBarRect = this._barRect; + context.beginPath(); + context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); + context.clip(); + context.closePath(); + } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { + var locOriginX = this._origin.x * scaleX; + var locOriginY = this._origin.y * scaleY; + context.beginPath(); + context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); + context.lineTo(locOriginX, locOriginY); + context.clip(); + context.closePath(); + } + + //draw sprite + var image = locSprite._texture.getHtmlElementObj(); + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); + + context.restore(); + cc.g_NumberOfDraws++; +}; + + +cc.ProgressTimer.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); +}; + +cc.ProgressTimer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.ProgressTimer.WebGLRenderCmd.prototype.constructor = cc.ProgressTimer.WebGLRenderCmd; + +cc.ProgressTimer.WebGLRenderCmd.prototype.rendering = function (ctx) { + var _t = this._node; + var context = ctx || cc._renderContext; + if (!_t._vertexData || !_t._sprite) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + var blendFunc = _t._sprite.getBlendFunc(); + cc.glBlendFunc(blendFunc.src, blendFunc.dst); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + cc.glBindTexture2D(_t._sprite.texture); + + context.bindBuffer(context.ARRAY_BUFFER, _t._vertexWebGLBuffer); + if (_t._vertexDataDirty) { + context.bufferData(context.ARRAY_BUFFER, _t._vertexArrayBuffer, context.DYNAMIC_DRAW); + _t._vertexDataDirty = false; + } + var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); + 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 (_t._type === cc.ProgressTimer.TYPE_RADIAL) + context.drawArrays(context.TRIANGLE_FAN, 0, _t._vertexDataCount); + else if (_t._type == cc.ProgressTimer.TYPE_BAR) { + if (!_t._reverseDirection) + context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount); + else { + context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount / 2); + context.drawArrays(context.TRIANGLE_STRIP, 4, _t._vertexDataCount / 2); + // 2 draw calls + cc.g_NumberOfDraws++; + } + } + cc.g_NumberOfDraws++; +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index a4f7c0ce2b..6aa8d0cdfa 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -188,7 +188,8 @@ "core", "actions", "cocos2d/progress-timer/CCProgressTimer.js", - "cocos2d/progress-timer/CCActionProgressTimer.js" + "cocos2d/progress-timer/CCActionProgressTimer.js", + "cocos2d/progress-timer/CCProgressTimerRenderCmd.js" ], "render-texture" : [ "core", From 9abff8766dff2bdfce7a21578d0dc1eda266247e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 11:26:19 +0800 Subject: [PATCH 0885/1564] Issue #2416: Add ProgressTimer RenderCmd --- cocos2d/core/renderer/RendererCanvas.js | 84 ------------------------- cocos2d/core/renderer/RendererWebGL.js | 44 ------------- 2 files changed, 128 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 4ad605ff30..d8c466b029 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -143,90 +143,6 @@ cc.rendererCanvas = { if (cc._renderType === cc._RENDER_TYPE_CANVAS) cc.renderer = cc.rendererCanvas; -// the canvas implement of renderCommand for cc.ProgressTimer -cc.ProgressRenderCmdCanvas = function (node) { - this._PI180 = Math.PI / 180; - - this._node = node; - this._sprite = null; - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._barRect = cc.rect(0, 0, 0, 0); - this._origin = cc.p(0, 0); - this._radius = 0; - this._startAngle = 270; - this._endAngle = 270; - this._counterClockWise = false; -}; - -cc.ProgressRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; - - var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; - - if (locTextureCoord.width === 0 || locTextureCoord.height === 0) - return; - if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) - return; - - var t = node._transformWorld; - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - if (locSprite._blendFuncStr != "source-over") - context.globalCompositeOperation = locSprite._blendFuncStr; - context.globalAlpha = alpha; - - var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; - var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; - locDrawSizeCanvas.width = locRect.width * scaleX; - locDrawSizeCanvas.height = locRect.height * scaleY; - - if (locSprite._flippedX) { - flipXOffset = -locOffsetPosition.x - locRect.width; - context.scale(-1, 1); - } - if (locSprite._flippedY) { - flipYOffset = locOffsetPosition.y; - context.scale(1, -1); - } - - flipXOffset *= scaleX; - flipYOffset *= scaleY; - - //clip - if (this._type == cc.ProgressTimer.TYPE_BAR) { - var locBarRect = this._barRect; - context.beginPath(); - context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); - context.clip(); - context.closePath(); - } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { - var locOriginX = this._origin.x * scaleX; - var locOriginY = this._origin.y * scaleY; - context.beginPath(); - context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); - context.lineTo(locOriginX, locOriginY); - context.clip(); - context.closePath(); - } - - //draw sprite - var image = locSprite._texture.getHtmlElementObj(); - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); - - context.restore(); - cc.g_NumberOfDraws++; -}; - - cc.ClippingNodeSaveRenderCmdCanvas = function (node) { this._node = node; }; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 9e5a2de01c..0d146dfd81 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -176,50 +176,6 @@ cc.MotionStreakCmdWebGL.prototype.rendering = function (ctx) { } }; -cc.ProgressRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.ProgressRenderCmdWebGL.prototype.rendering = function (ctx) { - var _t = this._node; - var context = ctx || cc._renderContext; - if (!_t._vertexData || !_t._sprite) - return; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - - var blendFunc = _t._sprite.getBlendFunc(); - cc.glBlendFunc(blendFunc.src, blendFunc.dst); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - cc.glBindTexture2D(_t._sprite.texture); - - context.bindBuffer(context.ARRAY_BUFFER, _t._vertexWebGLBuffer); - if (_t._vertexDataDirty) { - context.bufferData(context.ARRAY_BUFFER, _t._vertexArrayBuffer, context.DYNAMIC_DRAW); - _t._vertexDataDirty = false; - } - var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); - 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 (_t._type === cc.ProgressTimer.TYPE_RADIAL) - context.drawArrays(context.TRIANGLE_FAN, 0, _t._vertexDataCount); - else if (_t._type == cc.ProgressTimer.TYPE_BAR) { - if (!_t._reverseDirection) - context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount); - else { - context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount / 2); - context.drawArrays(context.TRIANGLE_STRIP, 4, _t._vertexDataCount / 2); - // 2 draw calls - cc.g_NumberOfDraws++; - } - } - cc.g_NumberOfDraws++; -}; - cc.ParticleRenderCmdWebGL = function (node) { this._node = node; }; From 55d33a42ae6e663c82144dffdabbd723d64cd2d7 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 6 Nov 2014 11:26:41 +0800 Subject: [PATCH 0886/1564] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=A4=9A=E5=A4=84?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=90=8C=E4=B8=80=E8=B5=84=E6=BA=90=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E9=87=8D=E5=A4=8DaddSpriteFrames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如果在一个csb文件里 使用一个plist文件多次 会导致 buffer["textures"].length过大 导致重复cc.spriteFrameCache.addSpriteFrames(); --- extensions/cocostudio/reader/timeline/CSLoader.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index 3df9d650ea..615f5fb1b0 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -268,6 +268,7 @@ ccs.csLoader = { // decode plist var textureSize = buffer["textures"].length; //cc.log("textureSize = %d", textureSize); + var frameCaches = {}; for (var i = 0; i < textureSize; ++i) { var plist = buffer["textures"][i]; @@ -276,7 +277,10 @@ ccs.csLoader = { //cc.log("png = %s", png); plist = this._protocolBuffersPath + plist; png = this._protocolBuffersPath + png; - cc.spriteFrameCache.addSpriteFrames(plist, png); + frameCaches[plist] = png; + } + for(var plist in frameCaches){ + cc.spriteFrameCache.addSpriteFrames(plist,frameCaches[plist]); } var fileDesignWidth = buffer["designWidth"]; var fileDesignHeight = buffer["designHeight"]; @@ -1241,4 +1245,4 @@ ccs.csLoader = { */ }; -ccs.csLoader.init(); \ No newline at end of file +ccs.csLoader.init(); From d53f694529fd69a95642e49668beea151eba60a0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 11:48:03 +0800 Subject: [PATCH 0887/1564] Issue #2416: Add ClippingNode RenderCmd --- cocos2d/clipping-nodes/CCClippingNode.js | 24 ++-- .../clipping-nodes/CCClippingNodeRenderCmd.js | 129 ++++++++++++++++++ cocos2d/core/renderer/RendererCanvas.js | 79 ----------- cocos2d/core/renderer/RendererWebGL.js | 11 -- cocos2d/progress-timer/CCProgressTimer.js | 2 +- .../CCProgressTimerRenderCmd.js | 1 + moduleConfig.json | 3 +- 7 files changed, 145 insertions(+), 104 deletions(-) create mode 100644 cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 289bc15183..083d10ae76 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -87,18 +87,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ cc.ClippingNode.prototype.init.call(this, stencil); }, - _initRendererCmd: function(){ - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererSaveCmd = new cc.ClippingNodeSaveRenderCmdCanvas(this); - this._rendererClipCmd = new cc.ClippingNodeClipRenderCmdCanvas(this); - this._rendererRestoreCmd = new cc.ClippingNodeRestoreRenderCmdCanvas(this); - }else{ - this._beforeVisitCmd = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisit); - this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDrawStencil); - this._afterVisitCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterVisit); - } - }, - /** * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. * @function @@ -581,6 +569,18 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ cc.Node.prototype._transformForRenderer.call(this, parentMatrix); if(this._stencil) this._stencil._transformForRenderer(this._stackMatrix); + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + this._rendererSaveCmd = new cc.ClippingNode.CanvasSaveRenderCmd(this); + this._rendererClipCmd = new cc.ClippingNode.CanvasClipRenderCmd(this); + this._rendererRestoreCmd = new cc.ClippingNode.CanvasRestoreRenderCmd(this); + }else{ + this._beforeVisitCmd = new cc.ClippingNode.WebGLRenderCmd(this, this._onBeforeVisit); + this._afterDrawStencilCmd = new cc.ClippingNode.WebGLRenderCmd(this, this._onAfterDrawStencil); + this._afterVisitCmd = new cc.ClippingNode.WebGLRenderCmd(this, this._onAfterVisit); + } } }); diff --git a/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js new file mode 100644 index 0000000000..524bd73e82 --- /dev/null +++ b/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js @@ -0,0 +1,129 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.ClippingNode.CanvasSaveRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.ClippingNode.CanvasSaveRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var context = ctx || cc._renderContext; + + if (node._clipElemType) { + var locCache = cc.ClippingNode._getSharedCache(); + var canvas = context.canvas; + locCache.width = canvas.width; + locCache.height = canvas.height; + var locCacheCtx = locCache.getContext("2d"); + locCacheCtx.drawImage(canvas, 0, 0); + context.save(); + } else { + node.transform(); + var t = node._transformWorld; + context.save(); + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } +}; + +cc.ClippingNode.CanvasSaveRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.ClippingNode.CanvasSaveRenderCmd.prototype.constructor = cc.ClippingNode.CanvasSaveRenderCmd; + +cc.ClippingNode.CanvasClipRenderCmd = function (renderableObject) { + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.ClippingNode.CanvasClipRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var context = ctx || cc._renderContext; + + if (node._clipElemType) { + context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; + var t = node._transformWorld; + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } else { + context.restore(); + if (node.inverted) { + var canvas = context.canvas; + context.save(); + + context.setTransform(1, 0, 0, 1, 0, 0); + + context.moveTo(0, 0); + context.lineTo(0, canvas.height); + context.lineTo(canvas.width, canvas.height); + context.lineTo(canvas.width, 0); + context.lineTo(0, 0); + + context.restore(); + } + context.clip(); + } +}; + +cc.ClippingNode.CanvasClipRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.ClippingNode.CanvasClipRenderCmd.prototype.constructor = cc.ClippingNode.CanvasClipRenderCmd; + +cc.ClippingNode.CanvasRestoreRenderCmd = function (renderableObject) { + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.ClippingNode.CanvasRestoreRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var locCache = cc.ClippingNode._getSharedCache(); + var context = ctx || cc._renderContext; + if (node._clipElemType) { + context.restore(); + + // Redraw the cached canvas, so that the cliped area shows the background etc. + context.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.globalCompositeOperation = "destination-over"; + context.drawImage(locCache, 0, 0); + context.restore(); + } else { + context.restore(); + } +}; + +cc.ClippingNode.CanvasRestoreRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.ClippingNode.CanvasRestoreRenderCmd.prototype.constructor = cc.ClippingNode.CanvasRestoreRenderCmd; + +cc.ClippingNode.WebGLRenderCmd = function(renderableObject, callback){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + this._callback = callback; +}; + +cc.ClippingNode.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.ClippingNode.WebGLRenderCmd.prototype.constructor = cc.ClippingNode.WebGLRenderCmd; + +cc.ClippingNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + if (!this._callback) + return; + this._callback.call(this._node, ctx); +}; \ No newline at end of file diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index d8c466b029..5b6fc01987 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -143,85 +143,6 @@ cc.rendererCanvas = { if (cc._renderType === cc._RENDER_TYPE_CANVAS) cc.renderer = cc.rendererCanvas; -cc.ClippingNodeSaveRenderCmdCanvas = function (node) { - this._node = node; -}; - -cc.ClippingNodeSaveRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var context = ctx || cc._renderContext; - - if (node._clipElemType) { - var locCache = cc.ClippingNode._getSharedCache(); - var canvas = context.canvas; - locCache.width = canvas.width; - locCache.height = canvas.height; - var locCacheCtx = locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - context.save(); - } else { - node.transform(); - var t = node._transformWorld; - context.save(); - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } -}; - -cc.ClippingNodeClipRenderCmdCanvas = function (node) { - this._node = node; -}; - -cc.ClippingNodeClipRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var context = ctx || cc._renderContext; - - if (node._clipElemType) { - context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; - var t = node._transformWorld; - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } else { - context.restore(); - if (node.inverted) { - var canvas = context.canvas; - context.save(); - - context.setTransform(1, 0, 0, 1, 0, 0); - - context.moveTo(0, 0); - context.lineTo(0, canvas.height); - context.lineTo(canvas.width, canvas.height); - context.lineTo(canvas.width, 0); - context.lineTo(0, 0); - - context.restore(); - } - context.clip(); - } -}; - -cc.ClippingNodeRestoreRenderCmdCanvas = function (node) { - this._node = node; -}; - -cc.ClippingNodeRestoreRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var locCache = cc.ClippingNode._getSharedCache(); - var context = ctx || cc._renderContext; - if (node._clipElemType) { - context.restore(); - - // Redraw the cached canvas, so that the cliped area shows the background etc. - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalCompositeOperation = "destination-over"; - context.drawImage(locCache, 0, 0); - context.restore(); - } else { - context.restore(); - } -}; - //CHIPMUNK cc.PhysicsDebugNodeRenderCmdCanvas = function (node) { this._node = node; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 0d146dfd81..8cf791ea89 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -318,17 +318,6 @@ cc.AtlasNodeRenderCmdWebGL.prototype.rendering = function (ctx) { } }; -cc.CustomRenderCmdWebGL = function (node, func) { - this._node = node; - this._callback = func; -}; - -cc.CustomRenderCmdWebGL.prototype.rendering = function (ctx) { - if (!this._callback) - return; - this._callback.call(this._node, ctx); -}; - cc.TMXLayerRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 7f1ae047d4..4d0344cdc8 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -187,7 +187,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._reverseDirection = false; this._sprite = null; - this._rendererCmd = new cc.ProgressRenderCmdCanvas(this); + this._rendererCmd = this._createRenderCmd(); sprite && this._initWithSpriteForCanvas(sprite); }, diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js index 459cf36ee7..9137a47ca4 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -24,6 +24,7 @@ cc.ProgressTimer.CanvasRenderCmd = function(renderableObject){ cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; this._PI180 = Math.PI / 180; this._sprite = null; diff --git a/moduleConfig.json b/moduleConfig.json index 6aa8d0cdfa..dd80c29687 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -27,7 +27,8 @@ "clipping-nodes" : [ "core", "shape-nodes", - "cocos2d/clipping-nodes/CCClippingNode.js" + "cocos2d/clipping-nodes/CCClippingNode.js", + "cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js" ], "compression" : [ "core", From 390c66cbc4bc2e332712af76b01eb8f27f5c9945 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 14:54:18 +0800 Subject: [PATCH 0888/1564] Fixed a bug that sprite update color terminated unexpectedly --- cocos2d/core/sprites/CCSprite.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 5037609966..b7a9bcc69f 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1492,10 +1492,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateDisplayedColor = function (parentColor) { var _t = this; cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); - var oColor = _t._oldDisplayColor; - var nColor = _t._displayedColor; - if (oColor.r === nColor.r && oColor.g === nColor.g && oColor.b === nColor.b) - return; _t._changeTextureColor(); _t._setNodeDirtyForCache(); From 2a3aa3dfae5b051cbe1fae9bc6a0e71da69f1870 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 15:40:12 +0800 Subject: [PATCH 0889/1564] Issue #2416: Add PhysicsDebug RenderCmd --- cocos2d/core/renderer/RendererCanvas.js | 22 ------- cocos2d/core/renderer/RendererWebGL.js | 15 ----- cocos2d/physics/CCPhysicsDebugNode.js | 13 ++-- .../physics/CCPhysicsDebugNodeRenderCmd.js | 63 +++++++++++++++++++ cocos2d/physics/CCPhysicsSprite.js | 12 +--- cocos2d/physics/CCPhysicsSpriteRenderCmd.js | 50 +++++++++++++++ cocos2d/progress-timer/CCProgressTimer.js | 2 - moduleConfig.json | 4 +- 8 files changed, 125 insertions(+), 56 deletions(-) create mode 100644 cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js create mode 100644 cocos2d/physics/CCPhysicsSpriteRenderCmd.js diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 5b6fc01987..9ea6c70147 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -143,28 +143,6 @@ cc.rendererCanvas = { if (cc._renderType === cc._RENDER_TYPE_CANVAS) cc.renderer = cc.rendererCanvas; -//CHIPMUNK -cc.PhysicsDebugNodeRenderCmdCanvas = function (node) { - this._node = node; - this._buffer = node._buffer; -}; - -cc.PhysicsDebugNodeRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var _node = this._node; - - if (!_node._space) - return; - - _node._space.eachShape(cc.DrawShape.bind(_node)); - _node._space.eachConstraint(cc.DrawConstraint.bind(_node)); - cc.DrawNodeRenderCmdCanvas.prototype.rendering.call(this, ctx, scaleX, scaleY); - _node.clear(); -}; - -//cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawDot = cc.DrawNodeRenderCmdCanvas.prototype._drawDot; -//cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawSegment = cc.DrawNodeRenderCmdCanvas.prototype._drawSegment; -//cc.PhysicsDebugNodeRenderCmdCanvas.prototype._drawPoly = cc.DrawNodeRenderCmdCanvas.prototype._drawPoly; - //--- TMXLayer's render command --- cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { this._node = tmxLayer; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 8cf791ea89..7748f4c493 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -324,21 +324,6 @@ cc.TMXLayerRenderCmdWebGL = function (node) { cc.TMXLayerRenderCmdWebGL.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; -cc.PhysicsDebugNodeRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.PhysicsDebugNodeRenderCmdWebGL.prototype.rendering = function (ctx) { - var node = this._node; - if (!node._space) - return; - - node._space.eachShape(cc.DrawShape.bind(node)); - node._space.eachConstraint(cc.DrawConstraint.bind(node)); - cc.DrawNode.prototype.draw.call(node); - node.clear(); -}; - cc.SkeletonRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/cocos2d/physics/CCPhysicsDebugNode.js b/cocos2d/physics/CCPhysicsDebugNode.js index 0ce8fd171f..17bfe544a4 100644 --- a/cocos2d/physics/CCPhysicsDebugNode.js +++ b/cocos2d/physics/CCPhysicsDebugNode.js @@ -163,12 +163,6 @@ cc.PhysicsDebugNode = cc.DrawNode.extend({ this._space = space; }, - _initRendererCmd:function(){ - if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._rendererCmd = new cc.PhysicsDebugNodeRenderCmdCanvas(this); - else - this._rendererCmd = new cc.PhysicsDebugNodeRenderCmdWebGL(this); - }, /** * get space * @returns {cp.Space} @@ -197,6 +191,13 @@ cc.PhysicsDebugNode = cc.DrawNode.extend({ this._space.eachConstraint(cc.DrawConstraint.bind(this)); cc.DrawNode.prototype.draw.call(this); this.clear(); + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.PhysicsDebugNode.CanvasRenderCmd(this); + else + return new cc.PhysicsDebugNode.WebGLRenderCmd(this); } }); diff --git a/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js b/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js new file mode 100644 index 0000000000..18ff6ca1e6 --- /dev/null +++ b/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js @@ -0,0 +1,63 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.PhysicsDebugNode.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._buffer = renderableObject._buffer; + this._needDraw = true; +}; + +cc.PhysicsDebugNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.PhysicsDebugNode.CanvasRenderCmd.prototype.constructor = cc.PhysicsDebugNode.CanvasRenderCmd; + +cc.PhysicsDebugNode.CanvasRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ + var node = this._node; + if (!node._space) + return; + node._space.eachShape(cc.DrawShape.bind(node)); + node._space.eachConstraint(cc.DrawConstraint.bind(node)); + cc.DrawNode.CanvasRenderCmd.prototype.rendering.call(this, ctx, scaleX, scaleY); + node.clear(); +}; + +cc.PhysicsDebugNode.CanvasRenderCmd.prototype._drawDot = cc.DrawNode.CanvasRenderCmd.prototype._drawDot; +cc.PhysicsDebugNode.CanvasRenderCmd.prototype._drawSegment = cc.DrawNode.CanvasRenderCmd.prototype._drawSegment; +cc.PhysicsDebugNode.CanvasRenderCmd.prototype._drawPoly = cc.DrawNode.CanvasRenderCmd.prototype._drawPoly; + + +cc.PhysicsDebugNode.WebGLRenderCmd = function (renderableObject) { + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var node = this._node; + if (!node._space) + return; + + node._space.eachShape(cc.DrawShape.bind(node)); + node._space.eachConstraint(cc.DrawConstraint.bind(node)); + cc.DrawNode.prototype.draw.call(node); + node.clear(); +}; \ No newline at end of file diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 38719d9b09..d97b4e79bc 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -263,17 +263,9 @@ } if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._transformCmd = new cc.CustomRenderCmdCanvas(this, function(){ - if (this.transform) { - this.transform(); - } - }); + this._transformCmd = new cc.PhysicsSprite.CanvasRenderCmd(this); else - this._transformCmd = new cc.CustomRenderCmdWebGL(this, function(){ - if(this._transformForRenderer){ - this._transformForRenderer(); - } - }); + this._transformCmd = new cc.PhysicsSprite.WebGLRenderCmd(this); cc.renderer.pushRenderCommand(this._transformCmd); }, diff --git a/cocos2d/physics/CCPhysicsSpriteRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteRenderCmd.js new file mode 100644 index 0000000000..6945c7d861 --- /dev/null +++ b/cocos2d/physics/CCPhysicsSpriteRenderCmd.js @@ -0,0 +1,50 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.PhysicsSprite.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.PhysicsSprite.CanvasRenderCmd.prototype.constructor = cc.PhysicsSprite.CanvasRenderCmd; + +cc.PhysicsSprite.CanvasRenderCmd.prototype.rendering = function(){ + if (this._node.transform) + this._node.transform(); +}; + +cc.PhysicsSprite.WebGLRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.PhysicsSprite.WebGLRenderCmd.prototype.constructor = cc.PhysicsSprite.WebGLRenderCmd; + +cc.PhysicsSprite.WebGLRenderCmd.prototype.rendering = function(){ + if(this._node._transformForRenderer) + this._node._transformForRenderer(); +}; + diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 4d0344cdc8..596e1113eb 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -187,7 +187,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._reverseDirection = false; this._sprite = null; - this._rendererCmd = this._createRenderCmd(); sprite && this._initWithSpriteForCanvas(sprite); }, @@ -206,7 +205,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._vertexData = null; this._vertexArrayBuffer = null; this._vertexDataDirty = false; - this._rendererCmd = new cc.ProgressRenderCmdWebGL(this); sprite && this._initWithSpriteForWebGL(sprite); }, diff --git a/moduleConfig.json b/moduleConfig.json index dd80c29687..efa0c29506 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -183,7 +183,9 @@ "core", "shape-nodes", "cocos2d/physics/CCPhysicsSprite.js", - "cocos2d/physics/CCPhysicsDebugNode.js" + "cocos2d/physics/CCPhysicsDebugNode.js", + "cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js", + "cocos2d/physics/CCPhysicsSpriteRenderCmd.js" ], "progress-timer" : [ "core", "actions", From 70afd564b5001dd9b454e7a51a8c10c0bba2ddc6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 16:06:06 +0800 Subject: [PATCH 0890/1564] Issue #2416: Add TMXLayer RenderCmd --- cocos2d/core/renderer/RendererCanvas.js | 70 ---------------- cocos2d/tilemap/CCTMXLayer.js | 4 +- cocos2d/tilemap/CCTMXLayerRenderCmd.js | 103 ++++++++++++++++++++++++ moduleConfig.json | 3 +- 4 files changed, 107 insertions(+), 73 deletions(-) create mode 100644 cocos2d/tilemap/CCTMXLayerRenderCmd.js diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 9ea6c70147..a983bd112d 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -143,76 +143,6 @@ cc.rendererCanvas = { if (cc._renderType === cc._RENDER_TYPE_CANVAS) cc.renderer = cc.rendererCanvas; -//--- TMXLayer's render command --- -cc.TMXLayerRenderCmdCanvas = function (tmxLayer) { - this._node = tmxLayer; - this._childrenRenderCmds = []; -}; - -cc.TMXLayerRenderCmdCanvas.prototype._copyRendererCmds = function (rendererCmds) { - if (!rendererCmds) - return; - - var locCacheCmds = this._childrenRenderCmds; - locCacheCmds.length = 0; - for (var i = 0, len = rendererCmds.length; i < len; i++) { - locCacheCmds[i] = rendererCmds[i]; - } -}; - -cc.TMXLayerRenderCmdCanvas.prototype._renderingChildToCache = function (scaleX, scaleY) { - var locNode = this._node; - if (locNode._cacheDirty) { - var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; - - locCacheContext.save(); - locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - //reset the cache context - var t = cc.affineTransformInvert(locNode._transformWorld); - locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - for (var i = 0, len = locCacheCmds.length; i < len; i++) { - locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); - if (locCacheCmds[i]._node) - locCacheCmds[i]._node._cacheDirty = false; - } - locCacheContext.restore(); - locNode._cacheDirty = false; - } -}; - -cc.TMXLayerRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var alpha = node._displayedOpacity / 255; - if (alpha <= 0) - return; - - this._renderingChildToCache(scaleX, scaleY); - var context = ctx || cc._renderContext; - context.globalAlpha = alpha; - var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); - var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; - //direct draw image by canvas drawImage - if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { - context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - var locCanvasHeight = locCacheCanvas.height * scaleY; - - if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) { - var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); - } else { - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); - } - context.restore(); - } - cc.g_NumberOfDraws++; -}; - cc.CustomRenderCmdCanvas = function (node, func) { this._node = node; this._callback = func; diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 75bcb27712..0e8b3a57ce 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -119,9 +119,9 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ _initRendererCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._rendererCmd = new cc.TMXLayerRenderCmdCanvas(this); + this._rendererCmd = new cc.TMXLayer.CanvasRenderCmd(this); else - this._rendererCmd = new cc.TMXLayerRenderCmdWebGL(this); + this._rendererCmd = new cc.TMXLayer.WebGLRenderCmd(this); }, /** diff --git a/cocos2d/tilemap/CCTMXLayerRenderCmd.js b/cocos2d/tilemap/CCTMXLayerRenderCmd.js new file mode 100644 index 0000000000..8fc5b16dcf --- /dev/null +++ b/cocos2d/tilemap/CCTMXLayerRenderCmd.js @@ -0,0 +1,103 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.TMXLayer.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._childrenRenderCmds = []; + this._needDraw = true; +}; + +cc.TMXLayer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.TMXLayer.CanvasRenderCmd.prototype.constructor = cc.TMXLayer.CanvasRenderCmd; + +cc.TMXLayer.CanvasRenderCmd.prototype._copyRendererCmds = function (rendererCmds) { + if (!rendererCmds) + return; + + var locCacheCmds = this._childrenRenderCmds; + locCacheCmds.length = 0; + for (var i = 0, len = rendererCmds.length; i < len; i++) { + locCacheCmds[i] = rendererCmds[i]; + } +}; + +cc.TMXLayer.CanvasRenderCmd.prototype._renderingChildToCache = function (scaleX, scaleY) { + var locNode = this._node; + if (locNode._cacheDirty) { + var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; + + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + //reset the cache context + var t = cc.affineTransformInvert(locNode._transformWorld); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + for (var i = 0, len = locCacheCmds.length; i < len; i++) { + locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); + if (locCacheCmds[i]._node) + locCacheCmds[i]._node._cacheDirty = false; + } + locCacheContext.restore(); + locNode._cacheDirty = false; + } +}; + +cc.TMXLayer.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var alpha = node._displayedOpacity / 255; + if (alpha <= 0) + return; + + this._renderingChildToCache(scaleX, scaleY); + var context = ctx || cc._renderContext; + context.globalAlpha = alpha; + var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); + var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; + //direct draw image by canvas drawImage + if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + var locCanvasHeight = locCacheCanvas.height * scaleY; + + if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) { + var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); + } else { + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + } + context.restore(); + } + cc.g_NumberOfDraws++; +}; + +cc.TMXLayer.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index efa0c29506..a956b8e545 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -226,7 +226,8 @@ "cocos2d/tilemap/CCTMXTiledMap.js", "cocos2d/tilemap/CCTMXXMLParser.js", "cocos2d/tilemap/CCTMXObjectGroup.js", - "cocos2d/tilemap/CCTMXLayer.js" + "cocos2d/tilemap/CCTMXLayer.js", + "cocos2d/tilemap/CCTMXLayerRenderCmd.js" ], "transitions" : [ "core", "actions", "render-texture", "progress-timer", From 55f80bea99dc5be49d25fff335eaad2e27ab0363 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 16:26:03 +0800 Subject: [PATCH 0891/1564] Issue #2416: Add Skeleton RenderCmd --- cocos2d/core/renderer/RendererCanvas.js | 64 +----- cocos2d/core/renderer/RendererWebGL.js | 129 ------------ extensions/spine/CCSkeleton.js | 6 +- extensions/spine/CCSkeletonRenderCmd.js.js | 217 +++++++++++++++++++++ moduleConfig.json | 3 +- 5 files changed, 223 insertions(+), 196 deletions(-) create mode 100644 extensions/spine/CCSkeletonRenderCmd.js.js diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index a983bd112d..1aabe8ebf1 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -152,66 +152,4 @@ cc.CustomRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { if (!this._callback) return; this._callback.call(this._node, ctx, scaleX, scaleY); -}; - -cc.SkeletonRenderCmdCanvas = function (node) { - this._node = node; -}; - -cc.SkeletonRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - ctx = ctx || cc._renderContext; - - if (!node._debugSlots && !node._debugBones) { - return; - } - var t = node._transformWorld; - ctx.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - var locSkeleton = node._skeleton; - var attachment, slot, i, n, drawingUtil = cc._drawingUtil; - if (node._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); - - var points = []; - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); - drawingUtil.drawPoly(points, 4, true); - } - } - - if (node._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine( - {x: bone.worldX, y: bone.worldY}, - {x: x, y: y}); - } - - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint({x: bone.worldX, y: bone.worldY}); - if (i === 0) - drawingUtil.setDrawColor(0, 255, 0, 255); - } - } - ctx.restore(); -}; -//} +}; \ No newline at end of file diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 7748f4c493..f22fc71533 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -318,135 +318,6 @@ cc.AtlasNodeRenderCmdWebGL.prototype.rendering = function (ctx) { } }; -cc.TMXLayerRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.TMXLayerRenderCmdWebGL.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; - -cc.SkeletonRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.SkeletonRenderCmdWebGL.prototype.rendering = function (ctx) { - var node = this._node; - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); -// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - var color = node.getColor(), locSkeleton = node._skeleton; - locSkeleton.r = color.r / 255; - locSkeleton.g = color.g / 255; - locSkeleton.b = color.b / 255; - locSkeleton.a = node.getOpacity() / 255; - if (node._premultipliedAlpha) { - locSkeleton.r *= locSkeleton.a; - locSkeleton.g *= locSkeleton.a; - locSkeleton.b *= locSkeleton.a; - } - - var additive, textureAtlas, attachment, slot, i, n, - quad = new cc.V3F_C4B_T2F_Quad(); - var locBlendFunc = node._blendFunc; - - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - var regionTextureAtlas = node.getTextureAtlas(attachment); - - if (slot.data.additiveBlending != additive) { - if (textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - additive = !additive; - cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); - } else if (regionTextureAtlas != textureAtlas && textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - textureAtlas = regionTextureAtlas; - - var quadCount = textureAtlas.getTotalQuads(); - if (textureAtlas.getCapacity() == quadCount) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) - return; - } - - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); - textureAtlas.updateQuad(quad, quadCount); - } - - if (textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - - if (node._debugBones || node._debugSlots) { - - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - //cc.kmGLPushMatrixWitMat4(node._stackMatrix); - cc.current_stack.stack.push(cc.current_stack.top); - cc.current_stack.top = node._stackMatrix; - - var drawingUtil = cc._drawingUtil; - - if (node._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); - - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - quad = new cc.V3F_C4B_T2F_Quad(); - sp._regionAttachment_updateQuad(attachment, slot, quad); - - var points = []; - points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); - points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); - points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); - points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); - - drawingUtil.drawPoly(points, 4, true); - } - } - - if (node._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); - } - - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); - if (i == 0) { - drawingUtil.setDrawColor(0, 255, 0, 255); - } - } - } - - cc.kmGLPopMatrix(); - } -}; - cc.ArmatureRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index fd2ee9a37d..875c5054ef 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -93,10 +93,10 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ }, _initRendererCmd:function () { - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._rendererCmd = new cc.SkeletonRenderCmdWebGL(this); + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + this._rendererCmd = new sp.Skeleton.CanvasRenderCmd(this); else - this._rendererCmd = new cc.SkeletonRenderCmdCanvas(this); + this._rendererCmd = new sp.Skeleton.WebGLRenderCmd(this); }, /** diff --git a/extensions/spine/CCSkeletonRenderCmd.js.js b/extensions/spine/CCSkeletonRenderCmd.js.js new file mode 100644 index 0000000000..9a29747bc1 --- /dev/null +++ b/extensions/spine/CCSkeletonRenderCmd.js.js @@ -0,0 +1,217 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +sp.Skeleton.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +sp.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +sp.Skeleton.CanvasRenderCmd.prototype.constructor = sp.Skeleton.CanvasRenderCmd; + +sp.Skeleton.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + ctx = ctx || cc._renderContext; + + if (!node._debugSlots && !node._debugBones) { + return; + } + var t = node._transformWorld; + ctx.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + var locSkeleton = node._skeleton; + var attachment, slot, i, n, drawingUtil = cc._drawingUtil; + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + var points = []; + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); + drawingUtil.drawPoly(points, 4, true); + } + } + + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine( + {x: bone.worldX, y: bone.worldY}, + {x: x, y: y}); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint({x: bone.worldX, y: bone.worldY}); + if (i === 0) + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + ctx.restore(); +}; + + + +sp.Skeleton.WebGLRenderCmd = function (renderableObject) { + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +sp.Skeleton.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +sp.Skeleton.WebGLRenderCmd.prototype.constructor = sp.Skeleton.WebGLRenderCmd; + +sp.Skeleton.WebGLRenderCmd.prototype.rendering = function (ctx) { + var node = this._node; + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); +// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); + var color = node.getColor(), locSkeleton = node._skeleton; + locSkeleton.r = color.r / 255; + locSkeleton.g = color.g / 255; + locSkeleton.b = color.b / 255; + locSkeleton.a = node.getOpacity() / 255; + if (node._premultipliedAlpha) { + locSkeleton.r *= locSkeleton.a; + locSkeleton.g *= locSkeleton.a; + locSkeleton.b *= locSkeleton.a; + } + + var additive, textureAtlas, attachment, slot, i, n, + quad = new cc.V3F_C4B_T2F_Quad(); + var locBlendFunc = node._blendFunc; + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + var regionTextureAtlas = node.getTextureAtlas(attachment); + + if (slot.data.additiveBlending != additive) { + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + additive = !additive; + cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); + } else if (regionTextureAtlas != textureAtlas && textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + textureAtlas = regionTextureAtlas; + + var quadCount = textureAtlas.getTotalQuads(); + if (textureAtlas.getCapacity() == quadCount) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) + return; + } + + sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + textureAtlas.updateQuad(quad, quadCount); + } + + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + + if (node._debugBones || node._debugSlots) { + + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + //cc.kmGLPushMatrixWitMat4(node._stackMatrix); + cc.current_stack.stack.push(cc.current_stack.top); + cc.current_stack.top = node._stackMatrix; + + var drawingUtil = cc._drawingUtil; + + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + quad = new cc.V3F_C4B_T2F_Quad(); + sp._regionAttachment_updateQuad(attachment, slot, quad); + + var points = []; + points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); + points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); + points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); + points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); + + drawingUtil.drawPoly(points, 4, true); + } + } + + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + if (i == 0) { + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + } + + cc.kmGLPopMatrix(); + } +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index a956b8e545..a35707260a 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -407,7 +407,8 @@ "extensions/spine/Spine.js", "extensions/spine/CCSkeleton.js", - "extensions/spine/CCSkeletonAnimation.js" + "extensions/spine/CCSkeletonAnimation.js", + "extensions/spine/CCSkeletonRenderCmd.js.js" ], "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "spine", "ccpool"], From 53c34e7e7a05ceac69459027d66eadcfa6b0478f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 16:34:00 +0800 Subject: [PATCH 0892/1564] Issue #2416: Add MotionStreak RenderCmd --- cocos2d/core/renderer/RendererWebGL.js | 39 ---------- cocos2d/motion-streak/CCMotionStreak.js | 4 +- .../motion-streak/CCMotionStreakRenderCmd.js | 74 +++++++++++++++++++ moduleConfig.json | 3 +- 4 files changed, 77 insertions(+), 43 deletions(-) create mode 100644 cocos2d/motion-streak/CCMotionStreakRenderCmd.js diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index f22fc71533..71c07d88ac 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -137,45 +137,6 @@ cc.rendererWebGL = { if (cc._renderType === cc._RENDER_TYPE_WEBGL) cc.renderer = cc.rendererWebGL; - -cc.MotionStreakCmdWebGL = function (node) { - this._node = node; -}; - -cc.MotionStreakCmdWebGL.prototype.rendering = function (ctx) { - var _t = this._node; - if (_t._nuPoints <= 1) - return; - - if (_t.texture && _t.texture.isLoaded()) { - ctx = ctx || cc._renderContext; - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - - cc.glBindTexture2D(_t.texture); - - //position - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._verticesBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._vertices, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); - - //texcoords - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._texCoordsBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._texCoords, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); - - //colors - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._colorPointerBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._colorPointer, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); - - ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, _t._nuPoints * 2); - cc.g_NumberOfDraws++; - } -}; - cc.ParticleRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index a0df3d6392..38f698c35b 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -115,10 +115,8 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ if(texture !== undefined) this.initWithFade(fade, minSeg, stroke, color, texture); - }, - _initRendererCmd:function(){ - this._rendererCmd = new cc.MotionStreakCmdWebGL(this); + this._rendererCmd = new cc.MotionStreak.WebGLRenderCmd(this); }, /** diff --git a/cocos2d/motion-streak/CCMotionStreakRenderCmd.js b/cocos2d/motion-streak/CCMotionStreakRenderCmd.js new file mode 100644 index 0000000000..45733eb83b --- /dev/null +++ b/cocos2d/motion-streak/CCMotionStreakRenderCmd.js @@ -0,0 +1,74 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.MotionStreak.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + this._textureCoord = { + renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. + renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. + x: 0, //the x of texture coordinate for node. + y: 0, //the y of texture coordinate for node. + width: 0, + height: 0, + validRect: false + }; +}; + +cc.MotionStreak.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.MotionStreak.WebGLRenderCmd.prototype.constructor = cc.Sprite.WebGLRenderCmd; + +cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(ctx){ + var _t = this._node; + if (_t._nuPoints <= 1) + return; + + if (_t.texture && _t.texture.isLoaded()) { + ctx = ctx || cc._renderContext; + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + + cc.glBindTexture2D(_t.texture); + + //position + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._verticesBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._vertices, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); + + //texcoords + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._texCoordsBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._texCoords, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); + + //colors + ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._colorPointerBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, _t._colorPointer, ctx.DYNAMIC_DRAW); + ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); + + ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, _t._nuPoints * 2); + cc.g_NumberOfDraws++; + } +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index a35707260a..0563d7d25c 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -157,7 +157,8 @@ "motion-streak" : [ "core", "shaders", "kazmath", "labels", - "cocos2d/motion-streak/CCMotionStreak.js" + "cocos2d/motion-streak/CCMotionStreak.js", + "cocos2d/motion-streak/CCMotionStreakRenderCmd.js" ], "node-grid" : [ "core", From a71bd8ed3bc492a83c366ef8070bf868f3c10580 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 16:42:19 +0800 Subject: [PATCH 0893/1564] Issue #2416: Add ParticleBatchNode RenderCmd --- cocos2d/core/renderer/RendererWebGL.js | 15 ------- cocos2d/particle/CCParticleBatchNode.js | 7 +--- .../particle/CCParticleBatchNodeRenderCmd.js | 42 +++++++++++++++++++ moduleConfig.json | 3 +- 4 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 cocos2d/particle/CCParticleBatchNodeRenderCmd.js diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 71c07d88ac..1ec5ba3f1f 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -170,21 +170,6 @@ cc.ParticleRenderCmdWebGL.prototype.rendering = function (ctx) { gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; -cc.ParticleBatchNodeRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.ParticleBatchNodeRenderCmdWebGL.prototype.rendering = function (ctx) { - var _t = this._node; - if (_t.textureAtlas.totalQuads == 0) - return; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); - _t.textureAtlas.drawQuads(); -}; - //RenderTexture render command cc.RenderTextureRenderCmdWebGL = function (node) { this._node = node; diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 4009bdb491..b6e9a4b549 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -101,6 +101,8 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ } else if (fileImage instanceof cc.Texture2D) { this.initWithTexture(fileImage, capacity); } + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this._rendererCmd = new cc.ParticleBatchNode.WebGLRenderCmd(this); }, /** @@ -555,11 +557,6 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ */ setTextureAtlas:function (textureAtlas) { this.textureAtlas = textureAtlas; - }, - - _initRendererCmd:function(){ - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._rendererCmd = new cc.ParticleBatchNodeRenderCmdWebGL(this); } }); diff --git a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js new file mode 100644 index 0000000000..7b40bd0d52 --- /dev/null +++ b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js @@ -0,0 +1,42 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.ParticleBatchNode.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.ParticleBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.ParticleBatchNode.WebGLRenderCmd.prototype.constructor = cc.ParticleBatchNode.WebGLRenderCmd; + +cc.ParticleBatchNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var _t = this._node; + if (_t.textureAtlas.totalQuads == 0) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + _t.textureAtlas.drawQuads(); +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 0563d7d25c..4141738a12 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -178,7 +178,8 @@ "cocos2d/particle/CCParticleSystem.js", "cocos2d/particle/CCParticleSystemRenderCmd.js", "cocos2d/particle/CCParticleExamples.js", - "cocos2d/particle/CCParticleBatchNode.js" + "cocos2d/particle/CCParticleBatchNode.js", + "cocos2d/particle/CCParticleBatchNodeRenderCmd.js" ], "physics" : [ "core", "shape-nodes", From 2905deb322cc55c3cde91f9749044aa36d452d48 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 16:47:14 +0800 Subject: [PATCH 0894/1564] Issue #2416: Add RenderTexture RenderCmd --- cocos2d/core/renderer/RendererWebGL.js | 59 ------------- cocos2d/render-texture/CCRenderTexture.js | 10 +-- .../CCRenderTextureRenderCmd.js | 85 +++++++++++++++++++ moduleConfig.json | 3 +- 4 files changed, 90 insertions(+), 67 deletions(-) create mode 100644 cocos2d/render-texture/CCRenderTextureRenderCmd.js diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 1ec5ba3f1f..ac36f3742f 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -170,65 +170,6 @@ cc.ParticleRenderCmdWebGL.prototype.rendering = function (ctx) { gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; -//RenderTexture render command -cc.RenderTextureRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.RenderTextureRenderCmdWebGL.prototype.rendering = function (ctx) { - var gl = ctx || cc._renderContext; - var node = this._node; - if (node.autoDraw) { - node.begin(); - - var locClearFlags = node.clearFlags; - if (locClearFlags) { - var oldClearColor = [0.0, 0.0, 0.0, 0.0]; - var oldDepthClearValue = 0.0; - var oldStencilClearValue = 0; - - // backup and set - if (locClearFlags & gl.COLOR_BUFFER_BIT) { - oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); - gl.clearColor(node._clearColor.r / 255, node._clearColor.g / 255, node._clearColor.b / 255, node._clearColor.a / 255); - } - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) { - oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - gl.clearDepth(node.clearDepthVal); - } - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) { - oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); - gl.clearStencil(node.clearStencilVal); - } - - // clear - gl.clear(locClearFlags); - - // restore - if (locClearFlags & gl.COLOR_BUFFER_BIT) - gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) - gl.clearDepth(oldDepthClearValue); - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) - gl.clearStencil(oldStencilClearValue); - } - - //! make sure all children are drawn - node.sortAllChildren(); - var locChildren = node._children; - for (var i = 0; i < locChildren.length; i++) { - var getChild = locChildren[i]; - if (getChild != node.sprite) - getChild.visit(); - } - node.end(); - } -}; - cc.SpriteBatchNodeRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 4697a56e6e..64237f7cc0 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -156,13 +156,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ } }, - _initRendererCmd: function(){ - //TODO need merge in some code - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._rendererCmd = new cc.RenderTextureRenderCmdWebGL(this); - - }, - _ctorForWebGL: function (width, height, format, depthStencilFormat) { cc.Node.prototype.ctor.call(this); this._cascadeColorEnabled = true; @@ -174,6 +167,9 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ depthStencilFormat = depthStencilFormat || 0; this.initWithWidthAndHeight(width, height, format, depthStencilFormat); } + + //TODO need merge in some code + this._rendererCmd = new cc.RenderTexture.WebGLRenderCmd(this); }, /** diff --git a/cocos2d/render-texture/CCRenderTextureRenderCmd.js b/cocos2d/render-texture/CCRenderTextureRenderCmd.js new file mode 100644 index 0000000000..5675763933 --- /dev/null +++ b/cocos2d/render-texture/CCRenderTextureRenderCmd.js @@ -0,0 +1,85 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.RenderTexture.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.RenderTexture.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.RenderTexture.WebGLRenderCmd.prototype.constructor = cc.RenderTexture.WebGLRenderCmd; + +cc.RenderTexture.WebGLRenderCmd.prototype.rendering = function (ctx) { + var gl = ctx || cc._renderContext; + var node = this._node; + if (node.autoDraw) { + node.begin(); + + var locClearFlags = node.clearFlags; + if (locClearFlags) { + var oldClearColor = [0.0, 0.0, 0.0, 0.0]; + var oldDepthClearValue = 0.0; + var oldStencilClearValue = 0; + + // backup and set + if (locClearFlags & gl.COLOR_BUFFER_BIT) { + oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); + gl.clearColor(node._clearColor.r / 255, node._clearColor.g / 255, node._clearColor.b / 255, node._clearColor.a / 255); + } + + if (locClearFlags & gl.DEPTH_BUFFER_BIT) { + oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + gl.clearDepth(node.clearDepthVal); + } + + if (locClearFlags & gl.STENCIL_BUFFER_BIT) { + oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); + gl.clearStencil(node.clearStencilVal); + } + + // clear + gl.clear(locClearFlags); + + // restore + if (locClearFlags & gl.COLOR_BUFFER_BIT) + gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); + + if (locClearFlags & gl.DEPTH_BUFFER_BIT) + gl.clearDepth(oldDepthClearValue); + + if (locClearFlags & gl.STENCIL_BUFFER_BIT) + gl.clearStencil(oldStencilClearValue); + } + + //! make sure all children are drawn + node.sortAllChildren(); + var locChildren = node._children; + for (var i = 0; i < locChildren.length; i++) { + var getChild = locChildren[i]; + if (getChild != node.sprite) + getChild.visit(); + } + node.end(); + } +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 4141738a12..647f13238b 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -199,7 +199,8 @@ "render-texture" : [ "core", - "cocos2d/render-texture/CCRenderTexture.js" + "cocos2d/render-texture/CCRenderTexture.js", + "cocos2d/render-texture/CCRenderTextureRenderCmd.js" ], "shaders" : [ "core", "kazmath", From 936cbea1554c685e600e32ac2059bd30f44b6d7d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 16:51:29 +0800 Subject: [PATCH 0895/1564] Issue #2416: Add SpriteBatchNode RenderCmd --- cocos2d/core/renderer/RendererWebGL.js | 18 -------- cocos2d/core/sprites/CCSpriteBatchNode.js | 5 +-- .../sprites/CCSpriteBatchNodeRenderCmd.js | 45 +++++++++++++++++++ cocos2d/tilemap/CCTMXLayerRenderCmd.js | 2 +- moduleConfig.json | 1 + 5 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index ac36f3742f..c24a1a3380 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -170,24 +170,6 @@ cc.ParticleRenderCmdWebGL.prototype.rendering = function (ctx) { gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; -cc.SpriteBatchNodeRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering = function (ctx) { - var node = this._node; - if (node.textureAtlas.totalQuads === 0) - return; - - //cc.nodeDrawSetup(this); - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); - node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - - node.textureAtlas.drawQuads(); -}; - cc.AtlasNodeRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index ed16367b9b..c34bd0cef7 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -412,11 +412,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ } else if (fileImage instanceof cc.Texture2D) texture2D = fileImage; texture2D && this.initWithTexture(texture2D, capacity); - }, - _initRendererCmd: function(){ - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._rendererCmd = new cc.SpriteBatchNodeRenderCmdWebGL(this); + this._rendererCmd = new cc.SpriteBatchNode.WebGLRenderCmd(this); }, /** diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js new file mode 100644 index 0000000000..de6376cf5a --- /dev/null +++ b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js @@ -0,0 +1,45 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.SpriteBatchNode.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.SpriteBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.SpriteBatchNode.WebGLRenderCmd.prototype.constructor = cc.SpriteBatchNode.WebGLRenderCmd; + +cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var node = this._node; + if (node.textureAtlas.totalQuads === 0) + return; + + //cc.nodeDrawSetup(this); + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + + node.textureAtlas.drawQuads(); +}; \ No newline at end of file diff --git a/cocos2d/tilemap/CCTMXLayerRenderCmd.js b/cocos2d/tilemap/CCTMXLayerRenderCmd.js index 8fc5b16dcf..9c555d9ec6 100644 --- a/cocos2d/tilemap/CCTMXLayerRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerRenderCmd.js @@ -100,4 +100,4 @@ cc.TMXLayer.WebGLRenderCmd = function(renderableObject){ this._needDraw = true; }; -cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNodeRenderCmdWebGL.prototype.rendering; \ No newline at end of file +cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 647f13238b..733eda44c4 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -99,6 +99,7 @@ "cocos2d/core/sprites/CCSprite.js", "cocos2d/core/sprites/CCSpriteRenderCmd.js", "cocos2d/core/sprites/CCSpriteBatchNode.js", + "cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js", "cocos2d/core/sprites/CCBakeSprite.js", "cocos2d/core/sprites/CCAnimation.js", "cocos2d/core/sprites/CCAnimationCache.js", From da2308793a28fc36df3d8da4b95b0128e3c4900e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 16:54:33 +0800 Subject: [PATCH 0896/1564] Issue #2416: Add AtlasNode RenderCmd --- cocos2d/core/base-nodes/CCAtlasNode.js | 4 +- .../core/base-nodes/CCAtlasNodeRenderCmd.js | 44 +++++++++++++++++++ cocos2d/core/renderer/RendererWebGL.js | 17 ------- moduleConfig.json | 1 + 4 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index e293697d21..944ee9778f 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -84,11 +84,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ this._ignoreContentScaleFactor = false; itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender); - }, - _initRendererCmd: function () { if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._rendererCmd = new cc.AtlasNodeRenderCmdWebGL(this); + this._rendererCmd = new cc.AtlasNode.WebGLRenderCmd(this); }, /** diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js new file mode 100644 index 0000000000..38b7ea0875 --- /dev/null +++ b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js @@ -0,0 +1,44 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +cc.AtlasNode.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.AtlasNode.WebGLRenderCmd.prototype.constructor = cc.AtlasNode.WebGLRenderCmd; + +cc.AtlasNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var context = ctx || cc._renderContext, node = this._node; + + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + if (node._uniformColor && node._colorF32Array) { + context.uniform4fv(node._uniformColor, node._colorF32Array); + node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); + } +}; \ No newline at end of file diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index c24a1a3380..a68f578909 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -170,23 +170,6 @@ cc.ParticleRenderCmdWebGL.prototype.rendering = function (ctx) { gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; -cc.AtlasNodeRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.AtlasNodeRenderCmdWebGL.prototype.rendering = function (ctx) { - var context = ctx || cc._renderContext, node = this._node; - - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); - - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - if (node._uniformColor && node._colorF32Array) { - context.uniform4fv(node._uniformColor, node._colorF32Array); - node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); - } -}; - cc.ArmatureRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/moduleConfig.json b/moduleConfig.json index 733eda44c4..0b4b228c14 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -147,6 +147,7 @@ "core", "cocos2d/labels/CCLabelAtlas.js", + "cocos2d/labels/CCAtlasNodeRenderCmd.js", "cocos2d/labels/CCLabelBMFont.js" ], "menus" : [ From 69d0228fadc0abbda4d897a5221c8cce845374db Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 17:10:58 +0800 Subject: [PATCH 0897/1564] Issue #2416: Add Armature RenderCmd --- cocos2d/core/renderer/RendererWebGL.js | 64 --------- extensions/cocostudio/armature/CCArmature.js | 35 +---- .../armature/CCArmatureRenderCmd.js | 133 ++++++++++++++++++ moduleConfig.json | 3 +- 4 files changed, 138 insertions(+), 97 deletions(-) create mode 100644 extensions/cocostudio/armature/CCArmatureRenderCmd.js diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index a68f578909..8244dc8f55 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -169,67 +169,3 @@ cc.ParticleRenderCmdWebGL.prototype.rendering = function (ctx) { gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; - -cc.ArmatureRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.ArmatureRenderCmdWebGL.prototype.rendering = function (ctx) { - var _t = this._node; - - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadMatrix(_t._stackMatrix); - - //TODO REMOVE THIS FUNCTION - if (_t._parentBone == null && _t._batchNode == null) { - // CC_NODE_DRAW_SETUP(); - } - - var locChildren = _t._children; - var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; - for (var i = 0, len = locChildren.length; i < len; i++) { - var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); - - if (null == node) - continue; - - node.setShaderProgram(_t._shaderProgram); - - switch (selBone.getDisplayRenderNodeType()) { - case ccs.DISPLAY_TYPE_SPRITE: - if (node instanceof ccs.Skin) { - node.updateTransform(); - - var func = selBone.getBlendFunc(); - if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) - node.setBlendFunc(selBone.getBlendFunc()); - else { - if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) - && !node.getTexture().hasPremultipliedAlpha()) - node.setBlendFunc(alphaNonPremultipled); - else - node.setBlendFunc(_t._blendFunc); - } - node.draw(ctx); - } - break; - case ccs.DISPLAY_TYPE_ARMATURE: - node.draw(ctx); - break; - default: - node.visit(ctx); //TODO need fix soon - break; - } - } else if (selBone instanceof cc.Node) { - selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon - selBone.visit(ctx); - // CC_NODE_DRAW_SETUP(); - } - } - - cc.kmGLPopMatrix(); -}; -//} diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 0dfadb77da..2a2e36c550 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -75,10 +75,10 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ _initRendererCmd:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererStartCmd = new cc.CustomRenderCmdCanvas(this, this._startRendererCmdForCanvas); - this._rendererEndCmd = new cc.CustomRenderCmdCanvas(this, this._endRendererCmdForCanvas); + this._rendererStartCmd = new ccs.Armature.CanvasRenderCmd(this); + this._rendererEndCmd = new ccs.Armature.CanvasRestoreRenderCmd(this); }else{ - this._rendererCmd = new cc.ArmatureRenderCmdWebGL(this); + this._rendererCmd = new ccs.Armature.WebGLRenderCmd(this); } }, @@ -484,35 +484,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ context.restore(); }, - _startRendererCmdForCanvas: function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext; - context.save(); - this.transform(context); - var t = this._transformWorld; - ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); - - var locChildren = this._children; - for (var i = 0, len = locChildren.length; i< len; i++) { - var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); - - if (null == node) - continue; - - node._transformForRenderer(); - } - } - }, - - _endRendererCmdForCanvas: function(ctx){ - var context = ctx || cc._renderContext; - - this._cacheDirty = false; - - context.restore(); - }, - _visitForWebGL: function(){ // quick return if not visible. children won't be drawn. if (!this._visible) diff --git a/extensions/cocostudio/armature/CCArmatureRenderCmd.js b/extensions/cocostudio/armature/CCArmatureRenderCmd.js new file mode 100644 index 0000000000..94fa2cf8d5 --- /dev/null +++ b/extensions/cocostudio/armature/CCArmatureRenderCmd.js @@ -0,0 +1,133 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +ccs.Armature.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +ccs.Armature.CanvasRenderCmd.prototype.constructor = ccs.Armature.CanvasRenderCmd; + +ccs.Armature.CanvasRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + context.save(); + this.transform(context); + var t = this._transformWorld; + ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); + + var locChildren = this._children; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + node._transformForRenderer(); + } + } +}; + +ccs.Armature.CanvasRestoreRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +ccs.Armature.CanvasRestoreRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +ccs.Armature.CanvasRestoreRenderCmd.prototype.constructor = ccs.Armature.CanvasRestoreRenderCmd; + +ccs.Armature.CanvasRestoreRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + this._cacheDirty = false; + context.restore(); +}; + +ccs.Armature.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; +}; + +ccs.Armature.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +ccs.Armature.WebGLRenderCmd.prototype.constructor = ccs.Armature.WebGLRenderCmd; + +ccs.Armature.WebGLRenderCmd.prototype.rendering = function (ctx) { + var _t = this._node; + + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadMatrix(_t._stackMatrix); + + //TODO REMOVE THIS FUNCTION + if (_t._parentBone == null && _t._batchNode == null) { + // CC_NODE_DRAW_SETUP(); + } + + var locChildren = _t._children; + var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + for (var i = 0, len = locChildren.length; i < len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + node.setShaderProgram(_t._shaderProgram); + + switch (selBone.getDisplayRenderNodeType()) { + case ccs.DISPLAY_TYPE_SPRITE: + if (node instanceof ccs.Skin) { + node.updateTransform(); + + var func = selBone.getBlendFunc(); + if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + node.setBlendFunc(selBone.getBlendFunc()); + else { + if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) + && !node.getTexture().hasPremultipliedAlpha()) + node.setBlendFunc(alphaNonPremultipled); + else + node.setBlendFunc(_t._blendFunc); + } + node.draw(ctx); + } + break; + case ccs.DISPLAY_TYPE_ARMATURE: + node.draw(ctx); + break; + default: + node.visit(ctx); //TODO need fix soon + break; + } + } else if (selBone instanceof cc.Node) { + selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon + selBone.visit(ctx); + // CC_NODE_DRAW_SETUP(); + } + } + + cc.kmGLPopMatrix(); +}; \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 0b4b228c14..0e6eebd26e 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -79,6 +79,7 @@ "cocos2d/core/base-nodes/CCNode.js", "cocos2d/core/base-nodes/CCNodeRenderCmd.js", "cocos2d/core/base-nodes/CCAtlasNode.js", + "cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js", "cocos2d/core/textures/TexturesWebGL.js", "cocos2d/core/textures/TexturesPropertyDefine.js", @@ -147,7 +148,6 @@ "core", "cocos2d/labels/CCLabelAtlas.js", - "cocos2d/labels/CCAtlasNodeRenderCmd.js", "cocos2d/labels/CCLabelBMFont.js" ], "menus" : [ @@ -333,6 +333,7 @@ "extensions/cocostudio/armature/animation/CCTween.js", "extensions/cocostudio/armature/physics/CCColliderDetector.js", "extensions/cocostudio/armature/CCArmature.js", + "extensions/cocostudio/armature/CCArmatureRenderCmd.js", "extensions/cocostudio/armature/CCBone.js", "extensions/cocostudio/action/CCActionFrame.js", From a82dc31ea1fd34ba7b8fc115ee73ef787094273a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 17:29:30 +0800 Subject: [PATCH 0898/1564] Issue #2416: Fixed armature transform error --- cocos2d/core/renderer/RendererWebGL.js | 11 +++++++++++ extensions/cocostudio/armature/CCArmature.js | 3 --- .../cocostudio/armature/CCArmatureRenderCmd.js | 16 ++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 8244dc8f55..5d796b158a 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -137,6 +137,17 @@ cc.rendererWebGL = { if (cc._renderType === cc._RENDER_TYPE_WEBGL) cc.renderer = cc.rendererWebGL; +cc.CustomRenderCmdWebGL = function (node, func) { + this._node = node; + this._callback = func; +}; + +cc.CustomRenderCmdWebGL.prototype.rendering = function (ctx) { + if (!this._callback) + return; + this._callback.call(this._node, ctx); +}; + cc.ParticleRenderCmdWebGL = function (node) { this._node = node; }; diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 2a2e36c550..5afca50eea 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -71,9 +71,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = true; this._realAnchorPointInPoints = cc.p(0, 0); name && ccs.Armature.prototype.init.call(this, name, parentBone); - }, - - _initRendererCmd:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS){ this._rendererStartCmd = new ccs.Armature.CanvasRenderCmd(this); this._rendererEndCmd = new ccs.Armature.CanvasRestoreRenderCmd(this); diff --git a/extensions/cocostudio/armature/CCArmatureRenderCmd.js b/extensions/cocostudio/armature/CCArmatureRenderCmd.js index 94fa2cf8d5..b6162d292d 100644 --- a/extensions/cocostudio/armature/CCArmatureRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureRenderCmd.js @@ -32,21 +32,22 @@ ccs.Armature.CanvasRenderCmd.prototype.constructor = ccs.Armature.CanvasRenderCm ccs.Armature.CanvasRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ var context = ctx || cc._renderContext; + var node = this._node; context.save(); - this.transform(context); - var t = this._transformWorld; + node.transform(context); + var t = node._transformWorld; ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); - var locChildren = this._children; + var locChildren = node._children; for (var i = 0, len = locChildren.length; i< len; i++) { var selBone = locChildren[i]; if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); + var rn = selBone.getDisplayRenderNode(); - if (null == node) + if (null == rn) continue; - node._transformForRenderer(); + rn._transformForRenderer(); } } }; @@ -60,9 +61,8 @@ ccs.Armature.CanvasRestoreRenderCmd.prototype = Object.create(cc.Node.CanvasRend ccs.Armature.CanvasRestoreRenderCmd.prototype.constructor = ccs.Armature.CanvasRestoreRenderCmd; ccs.Armature.CanvasRestoreRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext; this._cacheDirty = false; - context.restore(); + ctx.restore(); }; ccs.Armature.WebGLRenderCmd = function(renderableObject){ From 129cc7e0aa1286726ee6f3377562f2cf9f71da58 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 6 Nov 2014 17:40:46 +0800 Subject: [PATCH 0899/1564] Issue #2416: Move bakelayer code --- cocos2d/core/layers/CCLayer.js | 35 ++-------------------- cocos2d/core/layers/CCLayerRenderCmd.js | 39 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index c92e1cc669..dad4a78cae 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -108,7 +108,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //limit: 1. its children's blendfunc are invalid. this._isBaked = this._cacheDirty = true; if(!this._bakeRenderCmd && this._bakeRendering) - this._bakeRenderCmd = new cc.CustomRenderCmdCanvas(this, this._bakeRendering); + this._bakeRenderCmd = new cc.Layer.CanvasBakeRenderCmd(this); + //this._bakeRenderCmd = new cc.CustomRenderCmdCanvas(this, this._bakeRendering); this._cachedParent = this; var children = this._children; @@ -141,38 +142,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { child._setCachedParent(this); }; - p._bakeRendering = function(){ - if(this._cacheDirty){ - var _t = this; - var children = _t._children, locBakeSprite = this._bakeSprite; - //compute the bounding box of the bake layer. - this._transformForRenderer(); - var boundingBox = this._getBoundingBoxForBake(); - boundingBox.width = 0|(boundingBox.width+0.5); - boundingBox.height = 0|(boundingBox.height+0.5); - var bakeContext = locBakeSprite.getCacheContext(); - locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); - bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); - // invert - var t = cc.affineTransformInvert(this._transformWorld); - bakeContext.transform(t.a, t.c, t.b, t.d, t.tx , -t.ty ); - - //reset the bake sprite's position - var anchor = locBakeSprite.getAnchorPointInPoints(); - locBakeSprite.setPosition(anchor.x + boundingBox.x, anchor.y + boundingBox.y); - - //visit for canvas - _t.sortAllChildren(); - cc.renderer._turnToCacheMode(this.__instanceId); - for (var i = 0, len = children.length; i < len; i++) { - children[i].visit(bakeContext); - } - cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); - locBakeSprite.transform(); //because bake sprite's position was changed at rendering. - this._cacheDirty = false; - } - }; - p.visit = function(ctx){ if(!this._isBaked){ cc.Node.prototype.visit.call(this, ctx); diff --git a/cocos2d/core/layers/CCLayerRenderCmd.js b/cocos2d/core/layers/CCLayerRenderCmd.js index 83b81b2dd0..cab68e763b 100644 --- a/cocos2d/core/layers/CCLayerRenderCmd.js +++ b/cocos2d/core/layers/CCLayerRenderCmd.js @@ -29,6 +29,45 @@ cc.Layer.CanvasRenderCmd = function(renderable){ cc.Layer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.Layer.CanvasBakeRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; +}; + +cc.Layer.CanvasBakeRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + +cc.Layer.CanvasBakeRenderCmd.prototype.rendering = function(){ + if(this._cacheDirty){ + var _t = this; + var children = _t._children, locBakeSprite = this._bakeSprite; + //compute the bounding box of the bake layer. + this._transformForRenderer(); + var boundingBox = this._getBoundingBoxForBake(); + boundingBox.width = 0|(boundingBox.width+0.5); + boundingBox.height = 0|(boundingBox.height+0.5); + var bakeContext = locBakeSprite.getCacheContext(); + locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); + bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); + // invert + var t = cc.affineTransformInvert(this._transformWorld); + bakeContext.transform(t.a, t.c, t.b, t.d, t.tx , -t.ty ); + + //reset the bake sprite's position + var anchor = locBakeSprite.getAnchorPointInPoints(); + locBakeSprite.setPosition(anchor.x + boundingBox.x, anchor.y + boundingBox.y); + + //visit for canvas + _t.sortAllChildren(); + cc.renderer._turnToCacheMode(this.__instanceId); + for (var i = 0, len = children.length; i < len; i++) { + children[i].visit(bakeContext); + } + cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); + locBakeSprite.transform(); //because bake sprite's position was changed at rendering. + this._cacheDirty = false; + } +}; + //Layer's WebGL render command cc.Layer.WebGLRenderCmd = function(renderable){ cc.Node.WebGLRenderCmd.call(this, renderable); From 70752dd3babffe0d0c09034d5ecfacab66a965e5 Mon Sep 17 00:00:00 2001 From: SijieWang Date: Fri, 7 Nov 2014 10:54:51 +0800 Subject: [PATCH 0900/1564] Revert "Fixed a bug that sprite update color terminated unexpectedly" --- cocos2d/core/sprites/CCSprite.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 98f245214a..2b8b63e057 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1491,6 +1491,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateDisplayedColor = function (parentColor) { var _t = this; cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); + var oColor = _t._oldDisplayColor; + var nColor = _t._displayedColor; + if (oColor.r === nColor.r && oColor.g === nColor.g && oColor.b === nColor.b) + return; _t._changeTextureColor(); _t._setNodeDirtyForCache(); From ccd1f75385c8a88c8b8427b69d3f6f8f49d9fcd0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 7 Nov 2014 11:11:53 +0800 Subject: [PATCH 0901/1564] Issue #2024: LabelTTF add setLineHeight --- cocos2d/core/labelttf/CCLabelTTF.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 4af86b7f6f..31b8d25fbc 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -101,6 +101,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _lineWidths: null, _className: "LabelTTF", + _lineHeight: 0, + /** * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, * you should pass the correct arguments in constructor to initialize the label. @@ -215,6 +217,14 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._setColorsString(); }, + getLineHiehgt: function(){ + return this._lineHeight || this._fontClientHeight; + }, + + setLineHeight: function(lineHeight){ + this._lineHeight = lineHeight; + }, + /** * Returns the text of the label * @return {String} @@ -752,6 +762,11 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ context.textAlign = cc.LabelTTF._textAlign[locHAlignment]; var locContentWidth = this._contentSize.width - locStrokeShadowOffsetX; + + //lineHiehgt + var lineHeight = this.getLineHiehgt(); + var transformTop = (lineHeight - this._fontClientHeight) / 2; + if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) xOffset += locContentWidth; else if (locHAlignment === cc.TEXT_ALIGNMENT_CENTER) @@ -761,13 +776,13 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._isMultiLine) { var locStrLen = this._strings.length; if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) - yOffset = locFontHeight + locContentSizeHeight - locFontHeight * locStrLen; + yOffset = lineHeight - transformTop * 2 + locContentSizeHeight - lineHeight * locStrLen; else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_CENTER) - yOffset = locFontHeight / 2 + (locContentSizeHeight - locFontHeight * locStrLen) / 2; + yOffset = (lineHeight - transformTop * 2) / 2 + (locContentSizeHeight - lineHeight * locStrLen) / 2; for (var i = 0; i < locStrLen; i++) { var line = this._strings[i]; - var tmpOffsetY = -locContentSizeHeight + (locFontHeight * i) + yOffset; + var tmpOffsetY = -locContentSizeHeight + (lineHeight * i + transformTop) + yOffset; if (locStrokeEnabled) context.strokeText(line, xOffset, tmpOffsetY); context.fillText(line, xOffset, tmpOffsetY); @@ -923,9 +938,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ } else { if (this._dimensions.height === 0) { if (this._isMultiLine) - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((this.getLineHiehgt() * this._strings.length) + locStrokeShadowOffsetY)); else - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this._fontClientHeight + locStrokeShadowOffsetY)); + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this.getLineHiehgt() + locStrokeShadowOffsetY)); } else { //dimension is already set, contentSize must be same as dimension locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this._dimensions.height + locStrokeShadowOffsetY)); From 8dc18280b1d0124befb0557b50fc317259b2ac7f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 10 Nov 2014 15:02:41 +0800 Subject: [PATCH 0902/1564] =?UTF-8?q?Issue=20#2417:=20Add=20miPhone?= =?UTF-8?q?=E2=80=98s=20browser=20and=20uc=20adaptation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos2d/core/platform/CCEGLView.js | 31 +++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 33d85f1a36..8def766fee 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -58,16 +58,34 @@ cc.__BrowserGetter = { }; switch(cc.sys.browserType){ + case cc.sys.BROWSER_TYPE_SAFARI: + cc.__BrowserGetter.meta["minimal-ui"] = "true"; + break; case cc.sys.BROWSER_TYPE_CHROME: + cc.__BrowserGetter.__defineGetter__("target-densitydpi", function(){ + return cc.view._targetDensityDPI; + }); + case cc.sys.BROWSER_TYPE_UC: cc.__BrowserGetter.avaWidth = function(frame){ - return frame.clientWidth; + return frame.clientWidth; }; cc.__BrowserGetter.avaHeight = function(frame){ - return frame.clientHeight; + return frame.clientHeight; + }; + break; + case cc.sys.BROWSER_TYPE_MIUI: + cc.__BrowserGetter.init = function(view){ + if(view.__resizeWithBrowserSize) return; + var resize = function(){ + view.setDesignResolutionSize( + view._designResolutionSize.width, + view._designResolutionSize.height, + view._resolutionPolicy + ); + window.removeEventListener("resize", resize, false); + }; + window.addEventListener("resize", resize, false); }; - cc.__BrowserGetter.__defineGetter__("target-densitydpi", function(){ - return cc.view._targetDensityDPI; - }); break; } @@ -138,6 +156,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ */ ctor: function () { var _t = this, d = document, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy; + + cc.__BrowserGetter.init(this); + _t._frame = (cc.container.parentNode === d.body) ? d.documentElement : cc.container.parentNode; _t._frameSize = cc.size(0, 0); _t._initFrameSize(); From cb6840a0c8c65412979937170025f925ec6a304c Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Tue, 11 Nov 2014 11:34:05 +0800 Subject: [PATCH 0903/1564] add dumpAudioInfo and touchEvent for mobile. --- cocos2d/audio/CCAudio.js | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 3038d2cbb7..a8c2bd0d92 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -346,6 +346,10 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ self._soundSupported = cc._audioLoader._supportedAudioTypes.length > 0; if (self._effectPauseCb) self._effectPauseCb = self._effectPauseCb.bind(self); + + if(cc.sys.isMobile){ + self._addTouchStartEvent(); + } }, /** @@ -769,6 +773,45 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ self._resumeAudio(playings[i]); } playings.length = 0; + }, + /** + * show music and effect info + */ + dumpAudioInfo: function () { + var self = this; + cc.log("--------------------------------------"); + if(self._currMusic){ + cc.log("Current music: "); + self._printAudioInfo(this._currMusic); + } + if(self._effects){ + cc.log("Current effect: "); + for(var key in self._effects){ + self._printAudioInfo(self._effects[key]); + } + } + cc.log("--------------------------------------"); + }, + _printAudioInfo: function (audio) { + cc.log(" url:" + audio.src); + cc.log(" played:" + (audio.played).toString()); + cc.log(" paused:" + audio.paused); + cc.log(" ended:" + audio.ended); + cc.log(" loop:" + audio.loop); + cc.log(" volume:" + audio.volume); + cc.log("------------------------------"); + }, + /** + * add touch event + * @private + */ + _addTouchStartEvent: function () { + var self = this; + cc._addEventListener(document.getElementById(cc.game.config[cc.game.CONFIG_KEY.id]),"touchstart", function (event) { + if(self._currMusic && (self._currMusic._sourceNode["playbackState"] == 1 || self._currMusic.played == null)){ + self._playMusic(self._currMusic); + } + },false); } }); From 66590d2391529b527cff9c8f72f019216b850111 Mon Sep 17 00:00:00 2001 From: wuzhiming Date: Tue, 11 Nov 2014 11:43:21 +0800 Subject: [PATCH 0904/1564] add dumpAudioInfo and touchEvent for mobile. --- cocos2d/audio/CCAudio.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index a8c2bd0d92..a581870262 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -346,7 +346,6 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ self._soundSupported = cc._audioLoader._supportedAudioTypes.length > 0; if (self._effectPauseCb) self._effectPauseCb = self._effectPauseCb.bind(self); - if(cc.sys.isMobile){ self._addTouchStartEvent(); } From 6c6a97743519d93831508fa6484f64ba5aa66918 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 11 Nov 2014 13:18:06 +0800 Subject: [PATCH 0905/1564] Fix incorrect check in ccui.CheckBox init --- extensions/ccui/uiwidgets/UICheckBox.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 4a571a5185..ab04b6827c 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -96,8 +96,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ if (ccui.Widget.prototype.init.call(this)) { this._isSelected = true; this.setSelected(false); - if(backGround === undefined) - this.loadTextures(backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType); + this.loadTextures(backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType); return true; } return false; From 3381b69064aaf8c786d9c32fac50ee5d69644c22 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 11 Nov 2014 16:28:35 +0800 Subject: [PATCH 0906/1564] Fixed filename is undefined of csLoader --- extensions/cocostudio/reader/timeline/CSLoader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/reader/timeline/CSLoader.js b/extensions/cocostudio/reader/timeline/CSLoader.js index 615f5fb1b0..92d2e5c6dd 100644 --- a/extensions/cocostudio/reader/timeline/CSLoader.js +++ b/extensions/cocostudio/reader/timeline/CSLoader.js @@ -335,7 +335,7 @@ ccs.csLoader = { var nodeOptions = nodetree["widgetOptions"]; var options = nodetree["projectNodeOptions"]; - var filePath = options["filename"]; + var filePath = options["fileName"]; //cc.log("filePath = %s", filePath); if(filePath != "") { From 8ff404873657443cc8abd45e2b989d588e86d139 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 12 Nov 2014 16:59:29 +0800 Subject: [PATCH 0907/1564] Fixed cc.Node._StateCallbackType is undefined --- cocos2d/core/sprites/CCSprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 2b8b63e057..e49092a777 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -546,7 +546,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ } if (this._batchNode) { - this._arrayMakeObjectsPerformSelector(_children, cc.Node._StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(_children, cc.Node._stateCallbackType.sortAllChildren); } //don't need to check children recursively, that's done in visit of each child From b282162ceb28e960d0934cdf34d982e1a1ac6172 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 12 Nov 2014 17:07:15 +0800 Subject: [PATCH 0908/1564] Fixed cc.Node._StateCallbackType is undefined --- cocos2d/core/sprites/CCSprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index e49092a777..9822be03ea 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1458,7 +1458,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { // recursively iterate over children if (_t._hasChildren) - _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._StateCallbackType.updateTransform); + _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); }; _p.addChild = function (child, localZOrder, tag) { From 765e890ddcb3e4c4b1cac3185c025b7c47069fb8 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 13 Nov 2014 18:06:43 +0800 Subject: [PATCH 0909/1564] issue #1108: add two method cleanScript and restart --- CCBoot.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 5484d8827f..073cd58ea0 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1673,6 +1673,17 @@ cc._initSys = function (config, CONFIG_KEY) { // N/A in cocos2d-html5 }; + /** + * cleanScript the singal JS file + * @memberof cc.sys + * @name cleanScript + * @param {String} jsfile + * @function + */ + sys.cleanScript = function (jsfile) { + // N/A in cocos2d-html5 + }; + /** * Dump system informations * @memberof cc.sys @@ -2034,6 +2045,13 @@ cc.game = /** @lends cc.game# */{ self._paused = false; }, + /** + * Run game. + */ + restart: function () { + window.location.href = window.location.href; + }, + /** * Run game. */ From 5e82385de1b2830bb35c24df4b5cdde516dfce3f Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Fri, 14 Nov 2014 10:12:36 +0800 Subject: [PATCH 0910/1564] Revert "issue #1108: add two method cleanScript and restart" This reverts commit 765e890ddcb3e4c4b1cac3185c025b7c47069fb8. --- CCBoot.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 073cd58ea0..5484d8827f 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1673,17 +1673,6 @@ cc._initSys = function (config, CONFIG_KEY) { // N/A in cocos2d-html5 }; - /** - * cleanScript the singal JS file - * @memberof cc.sys - * @name cleanScript - * @param {String} jsfile - * @function - */ - sys.cleanScript = function (jsfile) { - // N/A in cocos2d-html5 - }; - /** * Dump system informations * @memberof cc.sys @@ -2045,13 +2034,6 @@ cc.game = /** @lends cc.game# */{ self._paused = false; }, - /** - * Run game. - */ - restart: function () { - window.location.href = window.location.href; - }, - /** * Run game. */ From 32a8bcf4200b74817957e71b74f0837f866ac758 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Fri, 14 Nov 2014 11:25:47 +0200 Subject: [PATCH 0911/1564] fixed Scale9Sprite size on canvas renderer with contentScaleFactor != 1; fixed RenderTexture size on canvas renderer with contentScaleFactor != 1; fixed colorized progress timer rendering on canvas; --- cocos2d/core/renderer/RendererCanvas.js | 38 +++++++++++++------ cocos2d/render-texture/CCRenderTexture.js | 3 +- .../ccui/base-classes/UIScale9Sprite.js | 19 ++++++---- .../gui/control-extension/CCScale9Sprite.js | 2 +- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index b2ebe5f0e8..18651f14bc 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -54,15 +54,19 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * drawing all renderer command to cache canvas' context * @param {CanvasRenderingContext2D} ctx * @param {Number} [instanceID] + * @param {Number} [scaleX] + * @param {Number} [scaleY] */ - _renderingToCacheCanvas: function (ctx, instanceID) { + _renderingToCacheCanvas: function (ctx, instanceID, scaleX, scaleY) { if (!ctx) cc.log("The context of RenderTexture is invalid."); + scaleX = cc.isUndefined(scaleX) ? 1 : scaleX; + scaleY = cc.isUndefined(scaleY) ? 1 : scaleY; instanceID = instanceID || this._currentID; var locCmds = this._cacheToCanvasCmds[instanceID], i, len; for (i = 0, len = locCmds.length; i < len; i++) { - locCmds[i].rendering(ctx, 1, 1); + locCmds[i].rendering(ctx, scaleX, scaleY); } locCmds.length = 0; var locIDs = this._cacheInstanceIds; @@ -530,15 +534,27 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //draw sprite var image = locSprite._texture.getHtmlElementObj(); - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); + if (locSprite._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); + } context.restore(); cc.g_NumberOfDraws++; diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 4697a56e6e..ca104811ca 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -495,7 +495,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ //cc._renderContext = cc._mainRenderContextBackup; //cc.view._resetScale(); - cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId); + var scale = cc.contentScaleFactor(); + cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId, scale, scale); //TODO /*//restore viewport diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 12d80dbbd0..2f18ce8724 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -203,12 +203,17 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _cacheScale9Sprite: function(){ if(!this._scale9Image) return; - var size = this._contentSize, locCanvas = this._cacheCanvas; + + var locScaleFactor = cc.contentScaleFactor(); + var size = this._contentSize; + var sizeInPixels = cc.size(size.width * locScaleFactor, size.height * locScaleFactor); + + var locCanvas = this._cacheCanvas; var contentSizeChanged = false; - if(locCanvas.width != size.width || locCanvas.height != size.height){ - locCanvas.width = size.width; - locCanvas.height = size.height; - this._cacheContext.translate(0, size.height); + if(locCanvas.width != sizeInPixels.width || locCanvas.height != sizeInPixels.height){ + locCanvas.width = sizeInPixels.width; + locCanvas.height = sizeInPixels.height; + this._cacheContext.translate(0, sizeInPixels.height); contentSizeChanged = true; } @@ -217,8 +222,8 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._scale9Image.visit(); //draw to cache canvas - this._cacheContext.clearRect(0, 0, size.width, -size.height); - cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId); + this._cacheContext.clearRect(0, 0, sizeInPixels.width, -sizeInPixels.height); + cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId, locScaleFactor, locScaleFactor); if(contentSizeChanged) this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 10cb95c5cc..3360ccf095 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -218,7 +218,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ //draw to cache canvas this._cacheContext.clearRect(0, 0, sizeInPixels.width, -sizeInPixels.height); - cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId); + cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId, locScaleFactor, locScaleFactor); if(contentSizeChanged) this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); From 2c483b5435b30391ea82d034b5689c51d6cc52d0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 15 Nov 2014 15:05:37 +0800 Subject: [PATCH 0912/1564] Issue #2416: refactor cc.Node and cc.Sprite's renderer for performance. --- cocos2d/clipping-nodes/CCClippingNode.js | 18 +- cocos2d/core/CCDirector.js | 2 +- cocos2d/core/base-nodes/BaseNodesWebGL.js | 69 -- cocos2d/core/base-nodes/CCAtlasNode.js | 10 +- cocos2d/core/base-nodes/CCNode.js | 594 +++--------------- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 525 +++++++++++++++- cocos2d/core/labelttf/CCLabelTTF.js | 2 +- cocos2d/core/labelttf/CCLabelTTFRenderCmd.js | 25 + cocos2d/core/layers/CCLayer.js | 102 +-- cocos2d/core/layers/CCLayerRenderCmd.js | 74 ++- cocos2d/core/renderer/RendererCanvas.js | 6 +- cocos2d/core/renderer/RendererWebGL.js | 33 - cocos2d/core/sprites/CCSprite.js | 505 ++------------- cocos2d/core/sprites/CCSpriteBatchNode.js | 6 +- cocos2d/core/sprites/CCSpriteFrame.js | 2 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 2 +- cocos2d/core/sprites/CCSpriteRenderCmd.js | 408 +++++++++++- cocos2d/core/sprites/SpritesWebGL.js | 86 +-- cocos2d/core/textures/CCTextureCache.js | 2 +- cocos2d/labels/CCLabelBMFont.js | 13 +- cocos2d/motion-streak/CCMotionStreak.js | 2 +- cocos2d/particle/CCParticleBatchNode.js | 6 +- cocos2d/particle/CCParticleSystem.js | 12 +- cocos2d/particle/CCParticleSystemRenderCmd.js | 2 +- cocos2d/progress-timer/CCProgressTimer.js | 6 +- .../CCProgressTimerRenderCmd.js | 2 +- cocos2d/render-texture/CCRenderTexture.js | 6 +- cocos2d/shape-nodes/CCDrawNode.js | 2 +- cocos2d/tilemap/CCTMXLayer.js | 10 +- .../ccui/base-classes/CCProtectedNode.js | 8 +- extensions/ccui/layouts/UILayout.js | 6 +- extensions/cocostudio/armature/CCArmature.js | 4 +- .../cocostudio/armature/display/CCSkin.js | 2 - extensions/gui/scrollview/CCScrollView.js | 16 +- extensions/spine/CCSkeleton.js | 4 +- moduleConfig.json | 1 + template/project.json | 2 +- 37 files changed, 1213 insertions(+), 1362 deletions(-) create mode 100644 cocos2d/core/labelttf/CCLabelTTFRenderCmd.js diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 083d10ae76..c6ab026462 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -233,8 +233,8 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ else break; } - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); // draw children zOrder >= 0 for (; i < childLen; i++) { if (locChildren[i]) { @@ -242,8 +242,8 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ } } } else{ - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); } cc.renderer.pushRenderCommand(this._afterVisitCmd); @@ -436,14 +436,14 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ else break; } - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); for (; i < len; i++) { children[i].visit(context); } } else - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); this._cangodhelpme(false); } @@ -494,7 +494,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ // For shape stencil, rewrite the draw of stencil ,only init the clip path and draw nothing. //else if (stencil instanceof cc.DrawNode) { - stencil._rendererCmd.rendering = function (ctx, scaleX, scaleY) { + stencil._renderCmd.rendering = function (ctx, scaleX, scaleY) { scaleX = scaleX || cc.view.getScaleX(); scaleY = scaleY ||cc.view.getScaleY(); var context = ctx || cc._renderContext; diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index ffbf5b7c76..2a4ad8338d 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -237,7 +237,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ if (this._runningScene) { if (renderer.childrenOrderDirty === true) { cc.renderer.clearRenderCommands(); - this._runningScene._curLevel = 0; //level start from 0; + this._runningScene._renderCmd._curLevel = 0; //level start from 0; this._runningScene.visit(); renderer.resetFlag(); } else if (renderer.transformDirty() === true) diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js index 85cf9a0171..2db195d9d3 100644 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ b/cocos2d/core/base-nodes/BaseNodesWebGL.js @@ -33,25 +33,6 @@ cc._tmp.WebGLCCNode = function () { */ var _p = cc.Node.prototype; - _p._transform4x4 = null; - _p._stackMatrix = null; - _p._glServerState = null; - _p._camera = null; - - _p.ctor = function () { - var _t = this; - _t._initNode(); - - //WebGL - var mat4 = new cc.kmMat4(); - mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0; - mat4.mat[10] = mat4.mat[15] = 1.0; - _t._transform4x4 = mat4; - _t._glServerState = 0; - _t._stackMatrix = new cc.kmMat4(); - this._initRendererCmd(); - }; - _p.setNodeDirty = function () { var _t = this; if(_t._transformDirty === false){ @@ -61,53 +42,6 @@ cc._tmp.WebGLCCNode = function () { } }; - _p.visit = function () { - var _t = this; - // quick return if not visible - if (!_t._visible) - return; - - if( _t._parent) - _t._curLevel = _t._parent._curLevel + 1; - - var context = cc._renderContext, i, currentStack = cc.current_stack; - - //optimize performance for javascript - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(_t._stackMatrix, currentStack.top); - currentStack.top = _t._stackMatrix; - - //_t.toRenderer(); - _t.transform(); - - var locChildren = _t._children; - if (locChildren && locChildren.length > 0) { - var childLen = locChildren.length; - _t.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < childLen; i++) { - if (locChildren[i] && locChildren[i]._localZOrder < 0) - locChildren[i].visit(); - else - break; - } - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); - // draw children zOrder >= 0 - for (; i < childLen; i++) { - if (locChildren[i]) { - locChildren[i].visit(); - } - } - } else{ - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); - } - - //optimize performance for javascript - currentStack.top = currentStack.stack.pop(); - }; - _p._transformForRenderer = function (pMatrix) { var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, parentMatrix = pMatrix || (this._parent ? this._parent._stackMatrix : cc.current_stack.top); @@ -158,7 +92,6 @@ cc._tmp.WebGLCCNode = function () { var i, len, locChildren = this._children; for(i = 0, len = locChildren.length; i< len; i++){ locChildren[i]._transformForRenderer(stackMatrix); - //locChildren[i]._transformForRenderer(); } }; @@ -200,6 +133,4 @@ cc._tmp.WebGLCCNode = function () { } } }; - - _p.getNodeToParentTransform = _p._getNodeToParentTransformForWebGL; }; diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 944ee9778f..e21235f17a 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -86,7 +86,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender); if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._rendererCmd = new cc.AtlasNode.WebGLRenderCmd(this); + this._renderCmd = new cc.AtlasNode.WebGLRenderCmd(this); }, /** @@ -319,9 +319,9 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ var locElement = locTexture.getHtmlElementObj(); var textureRect = cc.rect(0, 0, element.width, element.height); if (locElement instanceof HTMLCanvasElement) - cc.generateTintImageWithMultiply(element, this._colorUnmodified, textureRect, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect, locElement); else { - locElement = cc.generateTintImageWithMultiply(element, this._colorUnmodified, textureRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); @@ -470,9 +470,9 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { if (cacheTextureForColor) { var textureRect = cc.rect(0, 0, element.width, element.height); if (locElement instanceof HTMLCanvasElement) - cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect, locElement); else { - locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index ef2fcba8d5..b151fe1b37 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -150,25 +150,16 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // lazy alloc, _visible: true, _anchorPoint: null, - _anchorPointInPoints: null, _contentSize: null, _running: false, _parent: null, + // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true _ignoreAnchorPointForPosition: false, tag: cc.NODE_TAG_INVALID, // userData is always initialized as nil userData: null, userObject: null, - _transformDirty: true, - _inverseDirty: true, - _cacheDirty: false, - // Cached parent serves to construct the cached parent chain - _cachedParent: null, - _transformGLDirty: null, - _transform: null, //local transform - _transformWorld: null, //world transform - _inverse: null, //since 2.0 api _reorderChildDirty: false, @@ -179,7 +170,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _scheduler: null, _eventDispatcher: null, - _initializedNode: false, _additionalTransformDirty: false, _additionalTransform: null, _componentContainer: null, @@ -189,22 +179,25 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _showNode: false, _name: "", ///Properties configuration function
    * All properties in attrs will be set to the node,
    @@ -350,7 +334,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setSkewX: function (newSkewX) { this._skewX = newSkewX; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -380,7 +364,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setSkewY: function (newSkewY) { this._skewY = newSkewY; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -529,7 +513,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setRotation: function (newRotation) { this._rotationX = this._rotationY = newRotation; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -554,7 +538,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setRotationX: function (rotationX) { this._rotationX = rotationX; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -579,7 +563,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setRotationY: function (rotationY) { this._rotationY = rotationY; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -603,7 +587,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ setScale: function (scale, scaleY) { this._scaleX = scale; this._scaleY = (scaleY || scaleY === 0) ? scaleY : scale; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -618,14 +602,14 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** *

    * Changes the scale factor on X axis of this node
    - * The deafult value is 1.0 if you haven't changed it before + * The default value is 1.0 if you haven't changed it before *

    * @function * @param {Number} newScaleX The scale factor on X axis. */ setScaleX: function (newScaleX) { this._scaleX = newScaleX; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -647,7 +631,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setScaleY: function (newScaleY) { this._scaleY = newScaleY; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -673,8 +657,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ locPosition.x = newPosOrxValue; locPosition.y = yValue; } - this.setNodeDirty(); this._usingNormalizedPosition = false; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -695,8 +679,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ locPosition.x = posOrX; locPosition.y = y; } - this.setNodeDirty(); this._normalizedPositionDirty = this._usingNormalizedPosition = true; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -732,7 +716,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setPositionX: function (x) { this._position.x = x; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -751,7 +735,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setPositionY: function (y) { this._position.y = y; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -798,7 +782,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ setVisible: function (visible) { if(this._visible != visible){ this._visible = visible; - if(visible) this.setNodeDirty(); + if(visible) + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.visibleDirty); cc.renderer.childrenOrderDirty = true; } }, @@ -844,35 +829,16 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ locAnchorPoint.x = point; locAnchorPoint.y = y; } - var locAPP = this._anchorPointInPoints, locSize = this._contentSize; - locAPP.x = locSize.width * locAnchorPoint.x; - locAPP.y = locSize.height * locAnchorPoint.y; - this.setNodeDirty(); + this._renderCmd._updateAnchorPointInPoint(); }, - _getAnchor: function () { - return this._anchorPoint; - }, - _setAnchor: function (p) { - var x = p.x, y = p.y; - if (this._anchorPoint.x !== x) { - this._anchorPoint.x = x; - this._anchorPointInPoints.x = this._contentSize.width * x; - } - if (this._anchorPoint.y !== y) { - this._anchorPoint.y = y; - this._anchorPointInPoints.y = this._contentSize.height * y; - } - this.setNodeDirty(); - }, _getAnchorX: function () { return this._anchorPoint.x; }, _setAnchorX: function (x) { if (this._anchorPoint.x === x) return; this._anchorPoint.x = x; - this._anchorPointInPoints.x = this._contentSize.width * x; - this.setNodeDirty(); + this._renderCmd._updateAnchorPointInPoint(); }, _getAnchorY: function () { return this._anchorPoint.y; @@ -880,8 +846,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _setAnchorY: function (y) { if (this._anchorPoint.y === y) return; this._anchorPoint.y = y; - this._anchorPointInPoints.y = this._contentSize.height * y; - this.setNodeDirty(); + this._renderCmd._updateAnchorPointInPoint(); }, /** @@ -892,7 +857,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} The anchor point in absolute pixels. */ getAnchorPointInPoints: function () { - return cc.p(this._anchorPointInPoints); + return this._renderCmd.getAnchorPointInPoints(); }, _getWidth: function () { @@ -900,16 +865,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, _setWidth: function (width) { this._contentSize.width = width; - this._anchorPointInPoints.x = width * this._anchorPoint.x; - this.setNodeDirty(); + this._renderCmd._updateAnchorPointInPoint(); }, _getHeight: function () { return this._contentSize.height; }, _setHeight: function (height) { this._contentSize.height = height; - this._anchorPointInPoints.y = height * this._anchorPoint.y; - this.setNodeDirty(); }, /** @@ -947,10 +909,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ locContentSize.width = size; locContentSize.height = height; } - var locAPP = this._anchorPointInPoints, locAnchorPoint = this._anchorPoint; - locAPP.x = locContentSize.width * locAnchorPoint.x; - locAPP.y = locContentSize.height * locAnchorPoint.y; - this.setNodeDirty(); + this._renderCmd._updateAnchorPointInPoint(); }, /** @@ -1006,7 +965,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ ignoreAnchorPointForPosition: function (newValue) { if (newValue != this._ignoreAnchorPointForPosition) { this._ignoreAnchorPointForPosition = newValue; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); } }, @@ -1114,9 +1073,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {object} newValue A user cocos2d object */ setUserObject: function (newValue) { - if (this.userObject != newValue) { + if (this.userObject != newValue) this.userObject = newValue; - } }, @@ -1152,9 +1110,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.ActionManager} A CCActionManager object. */ getActionManager: function () { - if (!this._actionManager) { + if (!this._actionManager) this._actionManager = cc.director.getActionManager(); - } return this._actionManager; }, @@ -1179,9 +1136,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Scheduler} A CCScheduler object. */ getScheduler: function () { - if (!this._scheduler) { + if (!this._scheduler) this._scheduler = cc.director.getScheduler(); - } return this._scheduler; }, @@ -1260,7 +1216,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ /** * Returns a child from the container given its name * @function - * @param {Number} name An identifier to find the child node. + * @param {String} name A name to find the child node. * @return {cc.Node} a CCNode object whose name equals to the input parameter */ getChildByName: function(name){ @@ -1326,11 +1282,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if (this._isTransitionFinished) child.onEnterTransitionDidFinish(); } - if (this._cascadeColorEnabled) - this._enableCascadeColor(); + child._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); if (this._cascadeOpacityEnabled) - this._enableCascadeOpacity(); + child._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); }, // composition: REMOVE @@ -1380,7 +1335,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if (this._children.indexOf(child) > -1) this._detachChild(child, cleanup); - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.visibleDirty); cc.renderer.childrenOrderDirty = true; }, @@ -1408,7 +1363,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Boolean} [cleanup=true] */ removeAllChildrenWithCleanup: function (cleanup) { - //cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup); //TODO It should be discuss in v3.0 this.removeAllChildren(cleanup); }, @@ -1459,8 +1413,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // set parent nil at the end child.parent = null; - child._cachedParent = null; - + child._renderCmd.detachFromParent(); cc.arrayRemoveObject(this._children, child); }, @@ -1482,7 +1435,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ child.arrivalOrder = cc.s_globalOrderOfArrival; cc.s_globalOrderOfArrival++; child._setLocalZOrder(zOrder); - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.orderDirty); }, /** @@ -1853,7 +1806,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setAdditionalTransform: function (additionalTransform) { this._additionalTransform = additionalTransform; - this._transformDirty = true; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); this._additionalTransformDirty = true; }, @@ -1864,11 +1817,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.AffineTransform} */ getParentToNodeTransform: function () { - if (this._inverseDirty) { - this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()); - this._inverseDirty = false; - } - return this._inverse; + this._renderCmd.getParentToNodeTransform(); }, /** @@ -1885,6 +1834,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.AffineTransform} */ getNodeToWorldTransform: function () { + //TODO renderCmd has a WorldTransform var t = this.getNodeToParentTransform(); for (var p = this._parent; p != null; p = p.parent) t = cc.affineTransformConcat(t, p.getNodeToParentTransform()); @@ -1945,7 +1895,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.Point} */ convertToNodeSpaceAR: function (worldPoint) { - return cc.pSub(this.convertToNodeSpace(worldPoint), this._anchorPointInPoints); + return cc.pSub(this.convertToNodeSpace(worldPoint), this._renderCmd.getAnchorPointInPoints()); }, /** @@ -1957,7 +1907,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ convertToWorldSpaceAR: function (nodePoint) { nodePoint = nodePoint || cc.p(0,0); - var pt = cc.pAdd(nodePoint, this._anchorPointInPoints); + var pt = cc.pAdd(nodePoint, this._renderCmd.getAnchorPointInPoints()); return this.convertToWorldSpace(pt); }, @@ -1974,19 +1924,17 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ convertTouchToNodeSpace: function (touch) { var point = touch.getLocation(); //TODO This point needn't convert to GL in HTML5 - //point = cc.director.convertToGL(point); return this.convertToNodeSpace(point); }, /** - * converts a cc.Touch (world coordinates) into a local coordiante. This method is AR (Anchor Relative). + * converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). * @function * @param {cc.Touch} touch The touch object * @return {cc.Point} */ convertTouchToNodeSpaceAR: function (touch) { - var point = touch.getLocation(); - point = cc.director.convertToGL(point); + var point = cc.director.convertToGL(touch.getLocation()); return this.convertToNodeSpaceAR(point); }, @@ -2092,25 +2040,23 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ grid: null, - /** - * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. - * @function - */ - ctor: null, - /** * Recursive method that visit its children and draw them * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx */ - visit: null, + visit: function(){ + this._renderCmd.visit(); + }, /** * Performs view-matrix transformation based on position, scale, rotation and other attributes. * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx Render context */ - transform: null, + transform: function(){ + this._renderCmd.transform(); + }, /** *

    Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
    @@ -2129,26 +2075,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function * @return {cc.AffineTransform} The affine transform object */ - getNodeToParentTransform: null, - - _setNodeDirtyForCache: function () { - if (this._cacheDirty === false) { - this._cacheDirty = true; - - var cachedP = this._cachedParent; - //var cachedP = this._parent; - cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); - } - }, - - _setCachedParent: function(cachedParent){ - if(this._cachedParent == cachedParent) - return; - - this._cachedParent = cachedParent; - var children = this._children; - for(var i = 0, len = children.length; i < len; i++) - children[i]._setCachedParent(cachedParent); + getNodeToParentTransform: function(){ + this._renderCmd.getNodeToParentTransform(); }, /** @@ -2162,9 +2090,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * camera.setCenter(0, 0, 0); */ getCamera: function () { - if (!this._camera) { + if (!this._camera) this._camera = new cc.Camera(); - } return this._camera; }, @@ -2222,7 +2149,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @deprecated since v3.0, no need anymore */ getGLServerState: function () { - return this._glServerState; + return 0; }, /** @@ -2232,7 +2159,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @deprecated since v3.0, no need anymore */ setGLServerState: function (state) { - this._glServerState = state; }, /** @@ -2243,7 +2169,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ getBoundingBoxToWorld: function () { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); var trans = this.getNodeToWorldTransform(); - rect = cc.rectApplyAffineTransform(rect, this.getNodeToWorldTransform()); + rect = cc.rectApplyAffineTransform(rect, trans); //query child's BoundingBox if (!this._children) @@ -2282,83 +2208,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return rect; }, - _getNodeToParentTransformForWebGL: function () { - var _t = this; - if(_t._usingNormalizedPosition && _t._parent){ //TODO need refactor - var conSize = _t._parent._contentSize; - _t._position.x = _t._normalizedPosition.x * conSize.width; - _t._position.y = _t._normalizedPosition.y * conSize.height; - _t._normalizedPositionDirty = false; - } - if (_t._transformDirty) { - // Translate values - var x = _t._position.x, y = _t._position.y; - var apx = _t._anchorPointInPoints.x, napx = -apx; - var apy = _t._anchorPointInPoints.y, napy = -apy; - var scx = _t._scaleX, scy = _t._scaleY; - var rotationRadiansX = _t._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - var rotationRadiansY = _t._rotationY * 0.017453292519943295; - - if (_t._ignoreAnchorPointForPosition) { - x += apx; - y += apy; - } - - // Rotation values - // Change rotation code to handle X and Y - // If we skew with the exact same value for both x and y then we're simply just rotating - var cx = 1, sx = 0, cy = 1, sy = 0; - if (_t._rotationX !== 0 || _t._rotationY !== 0) { - cx = Math.cos(-rotationRadiansX); - sx = Math.sin(-rotationRadiansX); - cy = Math.cos(-rotationRadiansY); - sy = Math.sin(-rotationRadiansY); - } - var needsSkewMatrix = ( _t._skewX || _t._skewY ); - - // optimization: - // inline anchor point calculation if skew is not needed - // Adjusted transform calculation for rotational skew - if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { - x += cy * napx * scx + -sx * napy * scy; - y += sy * napx * scx + cx * napy * scy; - } - - // Build Transform Matrix - // Adjusted transform calculation for rotational skew - var t = _t._transform; - t.a = cy * scx; - t.b = sy * scx; - t.c = -sx * scy; - t.d = cx * scy; - t.tx = x; - t.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(_t._skewY)), - c: Math.tan(cc.degreesToRadians(_t._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t); - - // adjust anchor point - if (apx !== 0 || apy !== 0) - t = cc.affineTransformTranslate(t, napx, napy); - } - - if (_t._additionalTransformDirty) { - t = cc.affineTransformConcat(t, _t._additionalTransform); - _t._additionalTransformDirty = false; - } - _t._transform = t; - _t._transformDirty = false; - } - return _t._transform; - }, - - _updateColor: function(){ - //TODO - }, - /** * Returns the opacity of Node * @function @@ -2375,7 +2224,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @returns {number} displayed opacity */ getDisplayedOpacity: function () { - return this._displayedOpacity; + return this._renderCmd.getDisplayedOpacity(); }, /** @@ -2384,14 +2233,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} opacity */ setOpacity: function (opacity) { - this._displayedOpacity = this._realOpacity = opacity; - - var parentOpacity = 255, locParent = this._parent; - if (locParent && locParent.cascadeOpacity) - parentOpacity = locParent.getDisplayedOpacity(); - this.updateDisplayedOpacity(parentOpacity); - - this._displayedColor.a = this._realColor.a = opacity; + this._realOpacity = opacity; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); }, /** @@ -2400,17 +2243,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} parentOpacity */ updateDisplayedOpacity: function (parentOpacity) { - this._displayedOpacity = this._realOpacity * parentOpacity / 255.0; - if(this._rendererCmd && this._rendererCmd._opacity !== undefined) - this._rendererCmd._opacity = this._displayedOpacity / 255; - if (this._cascadeOpacityEnabled) { - var selChildren = this._children; - for (var i = 0; i < selChildren.length; i++) { - var item = selChildren[i]; - if (item) - item.updateDisplayedOpacity(this._displayedOpacity); - } - } + //TODO this API shouldn't be public. + this._renderCmd._updateDisplayOpacity(parentOpacity); }, /** @@ -2430,30 +2264,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ setCascadeOpacityEnabled: function (cascadeOpacityEnabled) { if (this._cascadeOpacityEnabled === cascadeOpacityEnabled) return; - this._cascadeOpacityEnabled = cascadeOpacityEnabled; - if (cascadeOpacityEnabled) - this._enableCascadeOpacity(); - else - this._disableCascadeOpacity(); - }, - - _enableCascadeOpacity: function () { - var parentOpacity = 255, locParent = this._parent; - if (locParent && locParent.cascadeOpacity) - parentOpacity = locParent.getDisplayedOpacity(); - this.updateDisplayedOpacity(parentOpacity); - }, - - _disableCascadeOpacity: function () { - this._displayedOpacity = this._realOpacity; - - var selChildren = this._children; - for (var i = 0; i < selChildren.length; i++) { - var item = selChildren[i]; - if (item) - item.updateDisplayedOpacity(255); - } + this._renderCmd.setCascadeOpacityEnabledDirty(); }, /** @@ -2473,8 +2285,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @returns {cc.Color} */ getDisplayedColor: function () { - var tmpColor = this._displayedColor; - return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); + return this._renderCmd.getDisplayedColor(); }, /** @@ -2485,17 +2296,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {cc.Color} color The new color given */ setColor: function (color) { - var locDisplayedColor = this._displayedColor, locRealColor = this._realColor; - locDisplayedColor.r = locRealColor.r = color.r; - locDisplayedColor.g = locRealColor.g = color.g; - locDisplayedColor.b = locRealColor.b = color.b; - - var parentColor, locParent = this._parent; - if (locParent && locParent.cascadeColor) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - this.updateDisplayedColor(parentColor); + var locRealColor = this._realColor; + locRealColor.r = color.r; + locRealColor.g = color.g; + locRealColor.b = color.b; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); }, /** @@ -2504,19 +2309,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {cc.Color} parentColor */ updateDisplayedColor: function (parentColor) { - var locDispColor = this._displayedColor, locRealColor = this._realColor; - locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); - locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); - locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - - if (this._cascadeColorEnabled) { - var selChildren = this._children; - for (var i = 0; i < selChildren.length; i++) { - var item = selChildren[i]; - if (item) - item.updateDisplayedColor(locDispColor); - } - } + //TODO this API shouldn't be public. + this._renderCmd._updateDisplayColor(parentColor); }, /** @@ -2536,33 +2330,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if (this._cascadeColorEnabled === cascadeColorEnabled) return; this._cascadeColorEnabled = cascadeColorEnabled; - if (this._cascadeColorEnabled) - this._enableCascadeColor(); - else - this._disableCascadeColor(); - }, - - _enableCascadeColor: function () { - var parentColor , locParent = this._parent; - if (locParent && locParent.cascadeColor) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - this.updateDisplayedColor(parentColor); - }, - - _disableCascadeColor: function () { - var locDisplayedColor = this._displayedColor, locRealColor = this._realColor; - locDisplayedColor.r = locRealColor.r; - locDisplayedColor.g = locRealColor.g; - locDisplayedColor.b = locRealColor.b; - - var selChildren = this._children, whiteColor = cc.color.WHITE; - for (var i = 0; i < selChildren.length; i++) { - var item = selChildren[i]; - if (item) - item.updateDisplayedColor(whiteColor); - } + this._renderCmd.setCascadeColorEnabledDirty(); }, /** @@ -2584,11 +2352,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, _initRendererCmd: function(){ - this._rendererCmd = cc.renderer.getRenderCmd(this); + this._renderCmd = cc.renderer.getRenderCmd(this); }, - _transformForRenderer: null, - _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.Node.CanvasRenderCmd(this); @@ -2609,210 +2375,6 @@ cc.Node.create = function () { cc.Node._stateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7}; -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - //redefine cc.Node - var _p = cc.Node.prototype; - _p.ctor = function () { - this._initNode(); - this._initRendererCmd(); - }; - - _p.setNodeDirty = function () { - var _t = this; - if(_t._transformDirty === false){ - _t._setNodeDirtyForCache(); - _t._renderCmdDiry = _t._transformDirty = _t._inverseDirty = true; - cc.renderer.pushDirtyNode(this); - } - }; - - _p.visit = function (ctx) { - var _t = this; - // quick return if not visible - if (!_t._visible) - return; - - if( _t._parent) - _t._curLevel = _t._parent._curLevel + 1; - - //visit for canvas - var i, children = _t._children, child; - _t.transform(); - var len = children.length; - if (len > 0) { - _t.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - child = children[i]; - if (child._localZOrder < 0) - child.visit(); - else - break; - } - //_t.draw(context); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); - for (; i < len; i++) { - children[i].visit(); - } - } else{ - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); - } - this._cacheDirty = false; - }; - - _p._transformForRenderer = function () { - var t = this.getNodeToParentTransform(), worldT = this._transformWorld; - if(this._parent){ - var pt = this._parent._transformWorld; - //worldT = cc.AffineTransformConcat(t, pt); - worldT.a = t.a * pt.a + t.b * pt.c; //a - worldT.b = t.a * pt.b + t.b * pt.d; //b - worldT.c = t.c * pt.a + t.d * pt.c; //c - worldT.d = t.c * pt.b + t.d * pt.d; //d - var plt = this._parent._transform; - var xOffset = -(plt.b + plt.c) * t.ty; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty - } else { - worldT.a = t.a; - worldT.b = t.b; - worldT.c = t.c; - worldT.d = t.d; - worldT.tx = t.tx; - worldT.ty = t.ty; - } - this._renderCmdDiry = false; - if(!this._children || this._children.length === 0) - return; - var i, len, locChildren = this._children; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._transformForRenderer(); - } - }; - - _p.transform = function (ctx) { - // transform for canvas - var t = this.getNodeToParentTransform(), - worldT = this._transformWorld; //get the world transform - - if(this._parent){ - var pt = this._parent._transformWorld; - // cc.AffineTransformConcat is incorrect at get world transform - worldT.a = t.a * pt.a + t.b * pt.c; //a - worldT.b = t.a * pt.b + t.b * pt.d; //b - worldT.c = t.c * pt.a + t.d * pt.c; //c - worldT.d = t.c * pt.b + t.d * pt.d; //d - - var plt = this._parent._transform; - var xOffset = -(plt.b + plt.c) * t.ty; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty - } else { - worldT.a = t.a; - worldT.b = t.b; - worldT.c = t.c; - worldT.d = t.d; - worldT.tx = t.tx; - worldT.ty = t.ty; - } - }; - - _p.getNodeToParentTransform = function () { - var _t = this; - if(_t._usingNormalizedPosition && _t._parent){ //TODO need refactor - var conSize = _t._parent._contentSize; - _t._position.x = _t._normalizedPosition.x * conSize.width; - _t._position.y = _t._normalizedPosition.y * conSize.height; - _t._normalizedPositionDirty = false; - } - if (_t._transformDirty) { - var t = _t._transform;// quick reference - - // base position - t.tx = _t._position.x; - t.ty = _t._position.y; - - // rotation Cos and Sin - var Cos = 1, Sin = 0; - var rotationRadiansX = _t._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - if (_t._rotationX) { - Cos = Math.cos(rotationRadiansX); - Sin = Math.sin(rotationRadiansX); - } - - // base abcd - t.a = t.d = Cos; - t.b = -Sin; - t.c = Sin; - - var lScaleX = _t._scaleX, lScaleY = _t._scaleY; - var appX = _t._anchorPointInPoints.x, appY = _t._anchorPointInPoints.y; - - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - - // skew - if (_t._skewX || _t._skewY) { - // offset the anchorpoint - var skx = Math.tan(-_t._skewX * Math.PI / 180); - var sky = Math.tan(-_t._skewY * Math.PI / 180); - if(skx === Infinity){ - skx = 99999999; - } - if(sky === Infinity){ - sky = 99999999; - } - var xx = appY * skx * sx; - var yy = appX * sky * sy; - t.a = Cos + -Sin * sky; - t.b = Cos * skx + -Sin; - t.c = Sin + Cos * sky; - t.d = Sin * skx + Cos; - t.tx += Cos * xx + -Sin * yy; - t.ty += Sin * xx + Cos * yy; - } - - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.c *= sx; - t.b *= sy; - t.d *= sy; - } - - // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * appY * sy; - t.ty -= Sin * -appX * sx + Cos * appY * sy; - - // if ignore anchorPoint - if (_t._ignoreAnchorPointForPosition) { - t.tx += appX; - t.ty += appY; - } - - if (_t._additionalTransformDirty) { - _t._transform = cc.affineTransformConcat(t, _t._additionalTransform); - _t._additionalTransformDirty = false; - } - - _t._transformDirty = false; - } - return _t._transform; - }; - - _p = null; - -} else { - cc.assert(cc.isFunction(cc._tmp.WebGLCCNode), cc._LogInfos.MissingFile, "BaseNodesWebGL.js"); - cc._tmp.WebGLCCNode(); - delete cc._tmp.WebGLCCNode; -} cc.assert(cc.isFunction(cc._tmp.PrototypeCCNode), cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js"); cc._tmp.PrototypeCCNode(); delete cc._tmp.PrototypeCCNode; \ No newline at end of file diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index 0e67cd3858..3d299a9b02 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -22,27 +22,522 @@ THE SOFTWARE. ****************************************************************************/ -//The cc.Node's render command for Canvas -cc.Node.CanvasRenderCmd = function(renderableObject){ - this._node = renderableObject; +cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty:16, orderDirty:32}; + +//-------------------------Base ------------------------- +cc.Node.RenderCmd = function(renderable){ + this._dirtyFlag = 0; + + this._node = renderable; this._needDraw = false; this._anchorPointInPoints = new cc.Point(0,0); + this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._transformWorld = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._worldTransform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._inverse = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + + this._displayedOpacity = 255; + this._displayedColor = cc.color(255, 255, 255, 255); + this._cascadeColorEnabledDirty = false; + this._cascadeOpacityEnabledDirty = false; + + this._curLevel = -1; }; -cc.Node.CanvasRenderCmd.prototype = { - constructor: cc.Node.CanvasRenderCmd +cc.Node.RenderCmd.prototype = { + constructor: cc.Node.RenderCmd, + + getAnchorPointInPoints: function(){ + return cc.p(this._anchorPointInPoints); + }, + + getDisplayedColor: function(){ + var tmpColor = this._displayedColor; + return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); + }, + + getDisplayedOpacity: function(){ + return this._displayedOpacity; + }, + + setCascadeColorEnabledDirty: function(){ + this._cascadeColorEnabledDirty = true; + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); + }, + + setCascadeOpacityEnabledDirty:function(){ + this._cascadeOpacityEnabledDirty = true; + this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); + }, + + getParentToNodeTransform: function(){ + if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) + this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()); + return this._inverse; + }, + + detachFromParent: function(){ + + }, + + _updateAnchorPointInPoint: function() { + var locAPP = this._anchorPointInPoints, locSize = this._node._contentSize, locAnchorPoint = this._node._anchorPoint; + locAPP.x = locSize.width * locAnchorPoint.x; + locAPP.y = locSize.height * locAnchorPoint.y; + this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); + }, + + setDirtyFlag: function(dirtyFlag){ + if (this._dirtyFlag === 0 && dirtyFlag !== 0) + cc.renderer.pushDirtyNode(this); + this._dirtyFlag = this._dirtyFlag | dirtyFlag; + }, + + getParentRenderCmd: function(){ + if(this._node && this._node._parent && this._node._parent._renderCmd) + return this._node._parent._renderCmd; + return null; + } +}; +//-----------------------Canvas --------------------------- +//The cc.Node's render command for Canvas +cc.Node.CanvasRenderCmd = function(renderable){ + cc.Node.RenderCmd.call(this, renderable); + this._cachedParent = null; + this._cacheDirty = false; }; -//The cc.Node's render command for WebGL -cc.Node.WebGLRenderCmd = function(renderableObject){ - this._node = renderableObject; - this._needDraw = false; - this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._transformWorld = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; +cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); +cc.Node.CanvasRenderCmd.prototype.constructor = cc.Node.CanvasRenderCmd; + +cc.Node.CanvasRenderCmd.prototype.transform = function(parentCmd, recursive){ + // transform for canvas + var t = this.getNodeToParentTransform(), + worldT = this._worldTransform; //get the world transform + + if(parentCmd){ + var pt = parentCmd._worldTransform; + // cc.AffineTransformConcat is incorrect at get world transform + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d + + var plt = parentCmd._transform; + var xOffset = -(plt.b + plt.c) * t.ty; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + } else { + worldT.a = t.a; + worldT.b = t.b; + worldT.c = t.c; + worldT.d = t.d; + worldT.tx = t.tx; + worldT.ty = t.ty; + } + this._renderCmdDiry = false; + if(recursive){ + var locChildren = this._node._children; + if(!locChildren|| locChildren.length === 0) + return; + var i, len; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i].transform(this, recursive); + } + } }; -cc.Node.WebGLRenderCmd.prototype = { - constructor: cc.Node.WebGLRenderCmd -}; \ No newline at end of file +cc.Node.CanvasRenderCmd.prototype.getNodeToParentTransform = function(){ + var node = this._node; + if(node._usingNormalizedPosition && node._parent){ //TODO need refactor + var conSize = node._parent._contentSize; + node._position.x = node._normalizedPosition.x * conSize.width; + node._position.y = node._normalizedPosition.y * conSize.height; + node._normalizedPositionDirty = false; + } + if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { + var t = this._transform;// quick reference + + // base position + t.tx = node._position.x; + t.ty = node._position.y; + + // rotation Cos and Sin + var Cos = 1, Sin = 0; + if (node._rotationX) { + var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance + Cos = Math.cos(rotationRadiansX); + Sin = Math.sin(rotationRadiansX); + } + + // base abcd + t.a = t.d = Cos; + t.b = -Sin; + t.c = Sin; + + var lScaleX = node._scaleX, lScaleY = node._scaleY; + var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; + + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + + // skew + if (node._skewX || node._skewY) { + // offset the anchorpoint + var skx = Math.tan(-node._skewX * Math.PI / 180); //TODO + var sky = Math.tan(-node._skewY * Math.PI / 180); + if(skx === Infinity) + skx = 99999999; + if(sky === Infinity) + sky = 99999999; + var xx = appY * skx * sx; + var yy = appX * sky * sy; + t.a = Cos + -Sin * sky; + t.b = Cos * skx + -Sin; + t.c = Sin + Cos * sky; + t.d = Sin * skx + Cos; + t.tx += Cos * xx + -Sin * yy; + t.ty += Sin * xx + Cos * yy; + } + + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + t.a *= sx; + t.c *= sx; + t.b *= sy; + t.d *= sy; + } + + // adjust anchorPoint + t.tx += Cos * -appX * sx + -Sin * appY * sy; + t.ty -= Sin * -appX * sx + Cos * appY * sy; + + // if ignore anchorPoint + if (node._ignoreAnchorPointForPosition) { + t.tx += appX; + t.ty += appY; + } + + if (node._additionalTransformDirty) { + this._transform = cc.affineTransformConcat(t, node._additionalTransform); + node._additionalTransformDirty = false; + } + this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; + } + return this._transform; +}; + +cc.Node.CanvasRenderCmd.prototype.visit = function(parentCmd){ + var _t = this, node = this._node; + // quick return if not visible + if (!node._visible) + return; + + parentCmd = parentCmd || this.getParentRenderCmd(); + if( parentCmd) + this._curLevel = parentCmd._curLevel + 1; + + //visit for canvas + var i, children = node._children, child; + _t.transform(parentCmd); + var len = children.length; + if (len > 0) { + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + child = children[i]; + if (child._localZOrder < 0) + child.visit(this); + else + break; + } + cc.renderer.pushRenderCommand(this); + for (; i < len; i++) + children[i].visit(); + } else{ + cc.renderer.pushRenderCommand(this); + } +}; + +cc.Node.CanvasRenderCmd.prototype.updateStatus = function(){ + if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ + //update the transform + this.transform(null, true); + } + + if(this._dirtyFlag & cc.Node._dirtyFlags.colorDirty){ + //update the color + this._updateDisplayColor() + } + + if(this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty){ + //update the opacity + this._updateDisplayOpacity(); + } +}; + +cc.Node.CanvasRenderCmd.prototype._updateDisplayColor = function(parentColor){ + this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.colorDirty; + + var locDispColor = this._displayedColor, locRealColor = this._realColor, node = this._node; + var i, len, selChildren, item; + if(this._cascadeColorEnabledDirty && !node._cascadeColorEnabled){ + locDispColor.r = locRealColor.r; + locDispColor.g = locRealColor.g; + locDispColor.b = locRealColor.b; + var whiteColor = new cc.Color(255,255,255,255); + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(whiteColor); + } + } else { + if(parentColor === undefined){ + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + if (node._cascadeColorEnabled) { + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(locDispColor); + } + } + } + this._cascadeColorEnabledDirty = false; +}; + +cc.Node.CanvasRenderCmd.prototype._updateDisplayOpacity = function(parentOpacity){ + this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.opacityDirty; + + var node = this._node; + var i, len, selChildren, item; + if(this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled){ + this._displayedOpacity = node._realOpacity; + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(255); + } + } else { + if(parentOpacity === undefined){ + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + if (this._cascadeOpacityEnabled) { + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + } + } + } + this._cascadeOpacityEnabledDirty = false; +}; + +cc.Node.CanvasRenderCmd.prototype.setDirtyFlag = function(dirtyFlag){ + if (this._dirtyFlag === 0 && dirtyFlag !== 0) + cc.renderer.pushDirtyNode(this); + this._dirtyFlag = this._dirtyFlag | dirtyFlag; + this._setCacheDirty(); +}; + +cc.Node.CanvasRenderCmd.prototype._setCacheDirty = function(){ + if (this._cacheDirty === false) { + this._cacheDirty = true; + var cachedP = this._cachedParent; + cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); + } +}; + +cc.Node.CanvasRenderCmd.prototype._setCachedParent = function(cachedParent){ + if(this._cachedParent == cachedParent) + return; + + this._cachedParent = cachedParent; + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._renderCmd._setCachedParent(cachedParent); +}; + +cc.Node.CanvasRenderCmd.prototype.detachFromParent = function(){ + this._cachedParent = null; + var selChildren = this._node._children, item; + for(var i = 0, len = selChildren.length; i < len; i++){ + item = selChildren[i]; + if(item && item._renderCmd) + item._renderCmd.detachFromParent(); + } +}; + +//util functions +cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function(blendFunc){ + if(!blendFunc) + return "source-over"; + else{ + if(( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) + return "lighter"; + else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) + return "destination-in"; + else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) + return "destination-out"; + else + return "source-over"; + } +}; + +// ------------------------------ The cc.Node's render command for WebGL ---------------------------------- +cc.Node.WebGLRenderCmd = function(renderable){ + cc.Node.RenderCmd.call(this, renderable); + + var mat4 = new cc.kmMat4(); + mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0; + mat4.mat[10] = mat4.mat[15] = 1.0; + this._transform4x4 = mat4; + this._stackMatrix = new cc.kmMat4(); + + this._camera = null; +}; + +cc.Node.WebGLRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); +cc.Node.WebGLRenderCmd.prototype.constructor = cc.Node.WebGLRenderCmd; + +cc.Node.WebGLRenderCmd.prototype.getNodeToParentTransform = function(){ + var node = this._node; + if(node._usingNormalizedPosition && node._parent){ //TODO need refactor + var conSize = node._parent._contentSize; + node._position.x = node._normalizedPosition.x * conSize.width; + node._position.y = node._normalizedPosition.y * conSize.height; + node._normalizedPositionDirty = false; + } + if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { + // Translate values + var x = node._position.x, y = node._position.y; + var apx = node._anchorPointInPoints.x, napx = -apx; + var apy = node._anchorPointInPoints.y, napy = -apy; + var scx = node._scaleX, scy = node._scaleY; + var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance + var rotationRadiansY = node._rotationY * 0.017453292519943295; + + if (node._ignoreAnchorPointForPosition) { + x += apx; + y += apy; + } + + // Rotation values + // Change rotation code to handle X and Y + // If we skew with the exact same value for both x and y then we're simply just rotating + var cx = 1, sx = 0, cy = 1, sy = 0; + if (node._rotationX !== 0 || node._rotationY !== 0) { + cx = Math.cos(-rotationRadiansX); + sx = Math.sin(-rotationRadiansX); + cy = Math.cos(-rotationRadiansY); + sy = Math.sin(-rotationRadiansY); + } + var needsSkewMatrix = ( node._skewX || node._skewY ); + + // optimization: + // inline anchor point calculation if skew is not needed + // Adjusted transform calculation for rotational skew + if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { + x += cy * napx * scx + -sx * napy * scy; + y += sy * napx * scx + cx * napy * scy; + } + + // Build Transform Matrix + // Adjusted transform calculation for rotational skew + var t = this._transform; + t.a = cy * scx; + t.b = sy * scx; + t.c = -sx * scy; + t.d = cx * scy; + t.tx = x; + t.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(node._skewY)), + c: Math.tan(cc.degreesToRadians(node._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t); + + // adjust anchor point + if (apx !== 0 || apy !== 0) + t = cc.affineTransformTranslate(t, napx, napy); + } + + if (node._additionalTransformDirty) { + t = cc.affineTransformConcat(t, this._additionalTransform); + node._additionalTransformDirty = false; + } + this._transform = t; + this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; + } + return this._transform; +}; + +//TODO +cc.Node.WebGLRenderCmd.prototype.visit = function(){ + var _t = this, node = this._node; + // quick return if not visible + if (!_t._visible) + return; + + if( node._parent && node._parent._renderCmd) + this._curLevel = node._parent._renderCmd._curLevel + 1; + + var i, currentStack = cc.current_stack; + + //optimize performance for javascript + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(_t._stackMatrix, currentStack.top); + currentStack.top = _t._stackMatrix; + + _t.transform(); + + var locChildren = _t._children; + if (locChildren && locChildren.length > 0) { + var childLen = locChildren.length; + _t.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < childLen; i++) { + if (locChildren[i] && locChildren[i]._localZOrder < 0) + locChildren[i].visit(); + else + break; + } + if(this._needDraw) + cc.renderer.pushRenderCommand(this); + // draw children zOrder >= 0 + for (; i < childLen; i++) { + if (locChildren[i]) + locChildren[i].visit(); + } + } else{ + if(this._needDraw) + cc.renderer.pushRenderCommand(this); + } + + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); +}; + +//TODO +cc.Node.WebGLRenderCmd.prototype.transform = function() { + +}; diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 4af86b7f6f..7656098134 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -1163,7 +1163,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this.setContentSize(untrimmedSize); this.setVertexRect(rect); - var locTextureCoordRect = this._rendererCmd._textureCoord; + var locTextureCoordRect = this._renderCmd._textureCoord; locTextureCoordRect.x = rect.x; locTextureCoordRect.y = rect.y; locTextureCoordRect.renderX = rect.x; diff --git a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js new file mode 100644 index 0000000000..9c6d608885 --- /dev/null +++ b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js @@ -0,0 +1,25 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + + diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index dad4a78cae..7a48fca0e4 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -30,9 +30,6 @@ * @extends cc.Node */ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ - _isBaked: false, - _bakeSprite: null, - _bakeRenderCmd: null, _className: "Layer", /** @@ -65,7 +62,9 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ * @function * @see cc.Layer#unbake */ - bake: null, + bake: function(){ + this._renderCmd.bake(); + }, /** * Cancel the layer to cache all of children to a bake sprite.
    @@ -73,9 +72,9 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ * @function * @see cc.Layer#bake */ - unbake: null, - - _bakeRendering: null, + unbake: function(){ + this._renderCmd.unbake(); + }, /** * Determines if the layer is baked. @@ -102,69 +101,12 @@ cc.Layer.create = function () { if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var p = cc.Layer.prototype; - p.bake = function(){ - if (!this._isBaked) { - cc.renderer.childrenOrderDirty = true; - //limit: 1. its children's blendfunc are invalid. - this._isBaked = this._cacheDirty = true; - if(!this._bakeRenderCmd && this._bakeRendering) - this._bakeRenderCmd = new cc.Layer.CanvasBakeRenderCmd(this); - //this._bakeRenderCmd = new cc.CustomRenderCmdCanvas(this, this._bakeRendering); - - this._cachedParent = this; - var children = this._children; - for(var i = 0, len = children.length; i < len; i++) - children[i]._setCachedParent(this); - - if (!this._bakeSprite){ - this._bakeSprite = new cc.BakeSprite(); - this._bakeSprite._parent = this; - } - } - }; - - p.unbake = function(){ - if (this._isBaked) { - cc.renderer.childrenOrderDirty = true; - this._isBaked = false; - this._cacheDirty = true; - - this._cachedParent = null; - var children = this._children; - for(var i = 0, len = children.length; i < len; i++) - children[i]._setCachedParent(null); - } - }; - p.addChild = function(child, localZOrder, tag){ cc.Node.prototype.addChild.call(this, child, localZOrder, tag); if(child._parent == this && this._isBaked) child._setCachedParent(this); }; - p.visit = function(ctx){ - if(!this._isBaked){ - cc.Node.prototype.visit.call(this, ctx); - return; - } - - var context = ctx || cc._renderContext; - var _t = this; - var children = _t._children; - var len = children.length; - // quick return if not visible - if (!_t._visible || len === 0) - return; - - _t.transform(context); - - if(_t._bakeRenderCmd) - cc.renderer.pushRenderCommand(_t._bakeRenderCmd); - - //the bakeSprite is drawing - this._bakeSprite.visit(context); - }; - p._getBoundingBoxForBake = function () { var rect = null; @@ -211,7 +153,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * // Example * //Create a yellow color layer as background * var yellowBackground = new cc.LayerColor(cc.color(255,255,0,255)); - * //If you didnt pass in width and height, it defaults to the same size as the canvas + * //If you didn't pass in width and height, it defaults to the same size as the canvas * * //create a yellow box, 200 by 200 in size * var yellowBox = new cc.LayerColor(cc.color(255,255,0,255), 200, 200); @@ -304,17 +246,11 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ width = width === undefined ? winSize.width : width; height = height === undefined ? winSize.height : height; - var locDisplayedColor = this._displayedColor; - locDisplayedColor.r = color.r; - locDisplayedColor.g = color.g; - locDisplayedColor.b = color.b; - var locRealColor = this._realColor; locRealColor.r = color.r; locRealColor.g = color.g; locRealColor.b = color.b; - this._displayedOpacity = color.a; this._realOpacity = color.a; var proto = cc.LayerColor.prototype; @@ -338,7 +274,7 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ locBlendFunc.dst = dst; } if (cc._renderType === cc._RENDER_TYPE_CANVAS) - _t._blendFuncStr = cc._getCompositeOperationByBlendFunc(locBlendFunc); + _t._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(locBlendFunc); }, _setWidth: null, @@ -395,7 +331,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { cc.Node.prototype._setHeight.call(this, height); }; _p._updateColor = function () { - var locCmd = this._rendererCmd; + var locCmd = this._renderCmd; if(!locCmd || !locCmd._color) return; var locColor = this._displayedColor; @@ -405,16 +341,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locCmd._color.a = this._displayedOpacity / 255; }; - _p.draw = function (ctx) { - var context = ctx || cc._renderContext, _t = this; - var locEGLViewer = cc.view, locDisplayedColor = _t._displayedColor; - - context.fillStyle = "rgba(" + (0 | locDisplayedColor.r) + "," + (0 | locDisplayedColor.g) + "," - + (0 | locDisplayedColor.b) + "," + _t._displayedOpacity / 255 + ")"; - context.fillRect(0, 0, _t.width * locEGLViewer.getScaleX(), -_t.height * locEGLViewer.getScaleY()); - cc.g_NumberOfDraws++; - }; - _p._bakeRendering = function(){ if(this._cacheDirty){ var _t = this; @@ -455,14 +381,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { else break; } - if(_t._rendererCmd) - cc.renderer.pushRenderCommand(_t._rendererCmd); + if(_t._renderCmd) + cc.renderer.pushRenderCommand(_t._renderCmd); for (; i < len; i++) { children[i].visit(bakeContext); } } else - if(_t._rendererCmd) - cc.renderer.pushRenderCommand(_t._rendererCmd); + if(_t._renderCmd) + cc.renderer.pushRenderCommand(_t._renderCmd); cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); locBakeSprite.transform(); this._cacheDirty = false; @@ -773,7 +699,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _t = this; var locAlongVector = _t._alongVector, tWidth = _t.width * 0.5, tHeight = _t.height * 0.5; - var locCmd = this._rendererCmd; + var locCmd = this._renderCmd; locCmd._startPoint.x = tWidth * (-locAlongVector.x) + tWidth; locCmd._startPoint.y = tHeight * locAlongVector.y - tHeight; locCmd._endPoint.x = tWidth * locAlongVector.x + tWidth; diff --git a/cocos2d/core/layers/CCLayerRenderCmd.js b/cocos2d/core/layers/CCLayerRenderCmd.js index cab68e763b..d7f8a50fce 100644 --- a/cocos2d/core/layers/CCLayerRenderCmd.js +++ b/cocos2d/core/layers/CCLayerRenderCmd.js @@ -25,18 +25,50 @@ //Layer's canvas render command cc.Layer.CanvasRenderCmd = function(renderable){ cc.Node.CanvasRenderCmd.call(this, renderable); + this._isBaked = false; + this._bakeSprite = null; }; cc.Layer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.Layer.CanvasRenderCmd.prototype.constructor = cc.Layer.CanvasRenderCmd; + +cc.Layer.CanvasRenderCmd.prototype.bake = function(){ + if (!this._isBaked) { + this._needDraw = true; + cc.renderer.childrenOrderDirty = true; + //limit: 1. its children's blendfunc are invalid. + this._isBaked = this._cacheDirty = true; + + this._cachedParent = this; + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._setCachedParent(this); + + if (!this._bakeSprite){ + this._bakeSprite = new cc.BakeSprite(); + this._bakeSprite._parent = this; + } + } +}; -cc.Layer.CanvasBakeRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; +cc.Layer.CanvasRenderCmd.prototype.unbake = function(){ + if (this._isBaked) { + cc.renderer.childrenOrderDirty = true; + this._isBaked = false; + this._cacheDirty = true; + + this._cachedParent = null; + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._setCachedParent(null); + } }; -cc.Layer.CanvasBakeRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); +cc.Layer.CanvasRenderCmd.prototype.isBaked = function(){ + return this._isBaked; +}; -cc.Layer.CanvasBakeRenderCmd.prototype.rendering = function(){ +cc.Layer.CanvasRenderCmd.prototype.rendering = function(){ if(this._cacheDirty){ var _t = this; var children = _t._children, locBakeSprite = this._bakeSprite; @@ -68,12 +100,44 @@ cc.Layer.CanvasBakeRenderCmd.prototype.rendering = function(){ } }; +cc.Layer.CanvasRenderCmd.prototype.visit = function(parentCmd){ + if(!this._isBaked){ + cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); + return; + } + + var context = ctx || cc._renderContext; + var _t = this; + var children = _t._children; + var len = children.length; + // quick return if not visible + if (!_t._visible || len === 0) + return; + + _t.transform(context); + + if(_t._needDraw) + cc.renderer.pushRenderCommand(this); + + //the bakeSprite is drawing + this._bakeSprite.visit(context); +}; + //Layer's WebGL render command cc.Layer.WebGLRenderCmd = function(renderable){ cc.Node.WebGLRenderCmd.call(this, renderable); }; cc.Layer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); +cc.Layer.WebGLRenderCmd.prototype.constructor = cc.Layer.WebGLRenderCmd; + +cc.Layer.WebGLRenderCmd.prototype.bake = function(){}; + +cc.Layer.WebGLRenderCmd.prototype.unbake = function(){}; + +cc.Layer.WebGLRenderCmd.prototype.unbake = function(){ + return false; +}; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 1aabe8ebf1..f68e22a965 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -103,8 +103,8 @@ cc.rendererCanvas = { //transform node for (var i = 0, len = locPool.length; i < len; i++) { - if (locPool[i]._renderCmdDiry) //TODO need modify name for LabelTTF - locPool[i]._transformForRenderer(); + if (locPool[i]._dirtyFlag !== 0) + locPool[i].updateStatus(); } locPool.length = 0; }, @@ -118,7 +118,6 @@ cc.rendererCanvas = { }, pushDirtyNode: function (node) { - //if (this._transformNodePool.indexOf(node) === -1) this._transformNodePool.push(node); }, @@ -140,6 +139,7 @@ cc.rendererCanvas = { } } }; + if (cc._renderType === cc._RENDER_TYPE_CANVAS) cc.renderer = cc.rendererCanvas; diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 5d796b158a..d5bd1d5f71 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -147,36 +147,3 @@ cc.CustomRenderCmdWebGL.prototype.rendering = function (ctx) { return; this._callback.call(this._node, ctx); }; - -cc.ParticleRenderCmdWebGL = function (node) { - this._node = node; -}; - -cc.ParticleRenderCmdWebGL.prototype.rendering = function (ctx) { - var _t = this._node; - if (!_t._texture) - return; - - var gl = ctx || cc._renderContext; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); - - cc.glBindTexture2D(_t._texture); - cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); - - //cc.assert(this._particleIdx == this.particleCount, "Abnormal error in particle quad"); - - // - // Using VBO without VAO - // - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); - gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); -}; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 144b7f2eb9..571fb601f5 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -24,223 +24,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * Tint a texture using the "multiply" operation - * @param {HTMLImageElement} image - * @param {cc.Color} color - * @param {cc.Rect} [rect] - * @param {HTMLCanvasElement} renderCanvas - * @returns {HTMLCanvasElement} - */ -cc.generateTintImageWithMultiply = function(image, color, rect, renderCanvas){ - renderCanvas = renderCanvas || cc.newElement("canvas"); - - rect = rect || cc.rect(0,0, image.width, image.height); - - var context = renderCanvas.getContext( "2d" ); - if(renderCanvas.width != rect.width || renderCanvas.height != rect.height){ - renderCanvas.width = rect.width; - renderCanvas.height = rect.height; - }else{ - context.globalCompositeOperation = "source-over"; - } - - context.fillStyle = "rgb(" + (0|color.r) + "," + (0|color.g) + "," + (0|color.b) + ")"; - context.fillRect(0, 0, rect.width, rect.height); - context.globalCompositeOperation = "multiply"; - context.drawImage(image, - rect.x, - rect.y, - rect.width, - rect.height, - 0, - 0, - rect.width, - rect.height); - context.globalCompositeOperation = "destination-atop"; - context.drawImage(image, - rect.x, - rect.y, - rect.width, - rect.height, - 0, - 0, - rect.width, - rect.height); - return renderCanvas; -}; - -/** - * Generate tinted texture with lighter. - * lighter: The source and destination colors are added to each other, resulting in brighter colors, - * moving towards color values of 1 (maximum brightness for that color). - * @function - * @param {HTMLImageElement} texture - * @param {Array} tintedImgCache - * @param {cc.Color} color - * @param {cc.Rect} rect - * @param {HTMLCanvasElement} [renderCanvas] - * @return {HTMLCanvasElement} - */ -cc.generateTintImage = function (texture, tintedImgCache, color, rect, renderCanvas) { - if (!rect) - rect = cc.rect(0, 0, texture.width, texture.height); - - var r = color.r / 255; - var g = color.g / 255; - var b = color.b / 255; - var w = Math.min(rect.width, tintedImgCache[0].width); - var h = Math.min(rect.height, tintedImgCache[0].height); - var buff = renderCanvas; - var ctx; - - // Create a new buffer if required - if (!buff) { - buff = cc.newElement("canvas"); - buff.width = w; - buff.height = h; - ctx = buff.getContext("2d"); - } else { - ctx = buff.getContext("2d"); - ctx.clearRect(0, 0, w, h); - } - - ctx.save(); - ctx.globalCompositeOperation = 'lighter'; - - // Make sure to keep the renderCanvas alpha in mind in case of overdraw - var a = ctx.globalAlpha; - if (r > 0) { - ctx.globalAlpha = r * a; - ctx.drawImage(tintedImgCache[0], rect.x, rect.y, w, h, 0, 0, w, h); - } - if (g > 0) { - ctx.globalAlpha = g * a; - ctx.drawImage(tintedImgCache[1], rect.x, rect.y, w, h, 0, 0, w, h); - } - if (b > 0) { - ctx.globalAlpha = b * a; - ctx.drawImage(tintedImgCache[2], rect.x, rect.y, w, h, 0, 0, w, h); - } - - if (r + g + b < 1) { - ctx.globalAlpha = a; - ctx.drawImage(tintedImgCache[3], rect.x, rect.y, w, h, 0, 0, w, h); - } - - ctx.restore(); - return buff; -}; - -/** - * Generates texture's cache for texture tint - * @function - * @param {HTMLImageElement} texture - * @return {Array} - */ -cc.generateTextureCacheForColor = function (texture) { - if (texture.channelCache) { - return texture.channelCache; - } - - var textureCache = [ - cc.newElement("canvas"), - cc.newElement("canvas"), - cc.newElement("canvas"), - cc.newElement("canvas") - ]; - - function renderToCache() { - var ref = cc.generateTextureCacheForColor; - - var w = texture.width; - var h = texture.height; - - textureCache[0].width = w; - textureCache[0].height = h; - textureCache[1].width = w; - textureCache[1].height = h; - textureCache[2].width = w; - textureCache[2].height = h; - textureCache[3].width = w; - textureCache[3].height = h; - - ref.canvas.width = w; - ref.canvas.height = h; - - var ctx = ref.canvas.getContext("2d"); - ctx.drawImage(texture, 0, 0); - - ref.tempCanvas.width = w; - ref.tempCanvas.height = h; - - var pixels = ctx.getImageData(0, 0, w, h).data; - - for (var rgbI = 0; rgbI < 4; rgbI++) { - var cacheCtx = textureCache[rgbI].getContext('2d'); - cacheCtx.getImageData(0, 0, w, h).data; - ref.tempCtx.drawImage(texture, 0, 0); - - var to = ref.tempCtx.getImageData(0, 0, w, h); - var toData = to.data; - - for (var i = 0; i < pixels.length; i += 4) { - toData[i ] = (rgbI === 0) ? pixels[i ] : 0; - toData[i + 1] = (rgbI === 1) ? pixels[i + 1] : 0; - toData[i + 2] = (rgbI === 2) ? pixels[i + 2] : 0; - toData[i + 3] = pixels[i + 3]; - } - cacheCtx.putImageData(to, 0, 0); - } - texture.onload = null; - } - - try { - renderToCache(); - } catch (e) { - texture.onload = renderToCache; - } - - texture.channelCache = textureCache; - return textureCache; -}; - -cc.generateTextureCacheForColor.canvas = cc.newElement('canvas'); -cc.generateTextureCacheForColor.tempCanvas = cc.newElement('canvas'); -cc.generateTextureCacheForColor.tempCtx = cc.generateTextureCacheForColor.tempCanvas.getContext('2d'); - -cc.cutRotateImageToCanvas = function (texture, rect) { - if (!texture) - return null; - - if (!rect) - return texture; - - var nCanvas = cc.newElement("canvas"); - nCanvas.width = rect.width; - nCanvas.height = rect.height; - var ctx = nCanvas.getContext("2d"); - ctx.translate(nCanvas.width / 2, nCanvas.height / 2); - ctx.rotate(-1.5707963267948966); - ctx.drawImage(texture, rect.x, rect.y, rect.height, rect.width, -rect.height / 2, -rect.width / 2, rect.height, rect.width); - return nCanvas; -}; - -cc._getCompositeOperationByBlendFunc = function(blendFunc){ - if(!blendFunc) - return "source-over"; - else{ - if(( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) - return "lighter"; - else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) - return "destination-in"; - else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) - return "destination-out"; - else - return "source-over"; - } -}; - /** *

    cc.Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
    * @@ -335,11 +118,26 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _flippedY:false, //Whether the sprite is flipped vertically or not. _textureLoaded:false, - _newTextureWhenChangeColor: null, //hack property for LabelBMFont _className:"Sprite", //Only for texture update judgment - _oldDisplayColor: cc.color.WHITE, + _oldDisplayColor: cc.color.WHITE, //TODO move to Canvas render + + _originalTexture: null, //TODO move to Canvas render cmd + _drawSize_Canvas: null, + + ctor: function (fileName, rect, rotated) { + var self = this; + cc.Node.prototype.ctor.call(self); + self._shouldBeHidden = false; + self._offsetPosition = cc.p(0, 0); + self._unflippedOffsetPositionFromCenter = cc.p(0, 0); + self._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; + self._rect = cc.rect(0, 0, 0, 0); + + self._textureLoaded = true; + self._softInit(fileName, rect, rotated); + }, /** * Returns whether the texture have been loaded @@ -448,19 +246,18 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, /** - * Initializes a sprite with an SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite.
    + * Initializes a sprite with a SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite.
    * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself, * @param {cc.SpriteFrame} spriteFrame A CCSpriteFrame object. It should includes a valid texture and a rect * @return {Boolean} true if the sprite is initialized properly, false otherwise. */ initWithSpriteFrame:function (spriteFrame) { - cc.assert(spriteFrame, cc._LogInfos.Sprite_initWithSpriteFrame); if(!spriteFrame.textureLoaded()){ //add event listener this._textureLoaded = false; - spriteFrame.addEventListener("load", this._spriteFrameLoadedCallback, this); + spriteFrame.addEventListener("load", this._renderCmd._spriteFrameLoadedCallback, this); } var rotated = cc._renderType === cc._RENDER_TYPE_CANVAS ? false : spriteFrame._rotated; @@ -470,14 +267,12 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ return ret; }, - _spriteFrameLoadedCallback:null, - /** * Initializes a sprite with a sprite frame name.
    * A cc.SpriteFrame will be fetched from the cc.SpriteFrameCache by name.
    * If the cc.SpriteFrame doesn't exist it will raise an exception.
    * Please pass parameters to the constructor to initialize the sprite, do not call this function yourself. - * @param {String} spriteFrameName A key string that can fected a volid cc.SpriteFrame from cc.SpriteFrameCache + * @param {String} spriteFrameName A key string that can fected a valid cc.SpriteFrame from cc.SpriteFrameCache * @return {Boolean} true if the sprite is initialized properly, false otherwise. * @example * var sprite = new cc.Sprite(); @@ -546,7 +341,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ } if (this._batchNode) { - this._arrayMakeObjectsPerformSelector(_children, cc.Node._StateCallbackType.sortAllChildren); + this._arrayMakeObjectsPerformSelector(_children, cc.Node._stateCallbackType.sortAllChildren); } //don't need to check children recursively, that's done in visit of each child @@ -796,16 +591,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ return this._texture; }, - _quad: null, // vertex coords, texture coords and color info - _quadWebBuffer: null, - _quadDirty: false, - _colorized: false, - _blendFuncStr: "source-over", - _originalTexture: null, - _drawSize_Canvas: null, - - ctor: null, - _softInit: function (fileName, rect, rotated) { if (fileName === undefined) cc.Sprite.prototype.init.call(this); @@ -838,10 +623,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ /** * Returns the quad (tex coords, vertex coords and color) information. - * @return {cc.V3F_C4B_T2F_Quad} + * @return {cc.V3F_C4B_T2F_Quad|null} Returns a cc.V3F_C4B_T2F_Quad object when render mode is WebGL, returns null when render mode is Canvas. */ getQuad:function () { - return this._quad; + return this._renderCmd.getQuad(); }, /** @@ -850,7 +635,17 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param {Number|cc.BlendFunc} src * @param {Number} dst */ - setBlendFunc: null, + setBlendFunc: function (src, dst) { + var locBlendFunc = this._blendFunc; + if (dst === undefined) { + locBlendFunc.src = src.src; + locBlendFunc.dst = src.dst; + } else { + locBlendFunc.src = src; + locBlendFunc.dst = dst; + } + this._renderCmd.updateBlendFunc(locBlendFunc); + }, /** * Initializes an empty sprite with nothing init.
    @@ -929,39 +724,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ */ addChild: null, - /** - * Update sprite's color - */ - updateColor:function () { - var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; - var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; - // special opacity for premultiplied textures - if (this._opacityModifyRGB) { - color4.r *= locDisplayedOpacity / 255.0; - color4.g *= locDisplayedOpacity / 255.0; - color4.b *= locDisplayedOpacity / 255.0; - } - var locQuad = this._quad; - locQuad.bl.colors = color4; - locQuad.br.colors = color4; - locQuad.tl.colors = color4; - locQuad.tr.colors = color4; - - // renders using Sprite Manager - if (this._batchNode) { - if (this.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { - this.textureAtlas.updateQuad(locQuad, this.atlasIndex) - } else { - // no need to set it recursively - // update dirty_, don't update recursiveDirty_ - this.dirty = true; - } - } - // self render - // do nothing - this._quadDirty = true; - }, - /** * Sets opacity of the sprite * @function @@ -1059,108 +821,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ } }, - _changeTextureColor: function () { - var locElement, locTexture = this._texture, locRect = this._rendererCmd._textureCoord; //this.getTextureRect(); - if (locTexture && locRect.validRect && this._originalTexture) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; - - this._colorized = true; - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor - && this._originalTexture._htmlElementObj != locElement) - cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); - else { - locElement = cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.texture = locTexture; - } - } - }, - - _setTextureCoords:function (rect) { - rect = cc.rectPointsToPixels(rect); - - var tex = this._batchNode ? this.textureAtlas.texture : this._texture; - if (!tex) - return; - - var atlasWidth = tex.pixelsWidth; - var atlasHeight = tex.pixelsHeight; - - var left, right, top, bottom, tempSwap, locQuad = this._quad; - if (this._rectRotated) { - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.height * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); - } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.height) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.width) / atlasHeight; - }// CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - - if (this._flippedX) { - tempSwap = top; - top = bottom; - bottom = tempSwap; - } - - if (this._flippedY) { - tempSwap = left; - left = right; - right = tempSwap; - } - - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = top; - locQuad.br.texCoords.u = left; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = right; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = bottom; - } else { - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.width * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); - } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.width) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.height) / atlasHeight; - } // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - - if (this._flippedX) { - tempSwap = left; - left = right; - right = tempSwap; - } - - if (this._flippedY) { - tempSwap = top; - top = bottom; - bottom = tempSwap; - } - - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = bottom; - locQuad.br.texCoords.u = right; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = left; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = top; - } - this._quadDirty = true; - }, - _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.Sprite.CanvasRenderCmd(this); @@ -1213,17 +873,6 @@ cc.Sprite.INDEX_NOT_INITIALIZED = -1; if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _p = cc.Sprite.prototype; - _p._spriteFrameLoadedCallback = function(spriteFrame){ - var _t = this; - _t.setNodeDirty(true); - _t.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - var curColor = _t.color; - if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) - _t._changeTextureColor(); - - _t.dispatchEvent("load"); - }; - _p.setOpacityModifyRGB = function (modify) { if (this._opacityModifyRGB !== modify) { this._opacityModifyRGB = modify; @@ -1236,39 +885,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._setNodeDirtyForCache(); }; - _p.ctor = function (fileName, rect, rotated) { - var self = this; - cc.Node.prototype.ctor.call(self); - self._shouldBeHidden = false; - self._offsetPosition = cc.p(0, 0); - self._unflippedOffsetPositionFromCenter = cc.p(0, 0); - self._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; - self._rect = cc.rect(0, 0, 0, 0); - - self._newTextureWhenChangeColor = false; - self._textureLoaded = true; - self._drawSize_Canvas = cc.size(0, 0); - - self._softInit(fileName, rect, rotated); - }; - - _p._initRendererCmd = function(){ - this._rendererCmd = cc.renderer.getRenderCmd(this); - }; - - _p.setBlendFunc = function (src, dst) { - var _t = this, locBlendFunc = this._blendFunc; - if (dst === undefined) { - locBlendFunc.src = src.src; - locBlendFunc.dst = src.dst; - } else { - locBlendFunc.src = src; - locBlendFunc.dst = dst; - } - if (cc._renderType === cc._RENDER_TYPE_CANVAS) - _t._blendFuncStr = cc._getCompositeOperationByBlendFunc(locBlendFunc); - }; - _p.init = function () { var _t = this; if (arguments.length > 0) @@ -1280,7 +896,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._blendFunc.src = cc.BLEND_SRC; _t._blendFunc.dst = cc.BLEND_DST; - // update texture (calls _updateBlendFunc) _t.texture = null; _t._textureLoaded = true; _t._flippedX = _t._flippedY = false; @@ -1308,12 +923,11 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (rotated && texture.isLoaded()) { var tempElement = texture.getHtmlElementObj(); - tempElement = cc.cutRotateImageToCanvas(tempElement, rect); + tempElement = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, rect); var tempTexture = new cc.Texture2D(); tempTexture.initWithElement(tempElement); tempTexture.handleLoadedTexture(); texture = tempTexture; - _t._rect = cc.rect(0, 0, rect.width, rect.height); } @@ -1416,7 +1030,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t.setVertexRect(rect); - var locTextureRect = _t._rendererCmd._textureCoord, + var locTextureRect = _t._renderCmd._textureCoord, scaleFactor = cc.contentScaleFactor(); locTextureRect.renderX = locTextureRect.x = 0 | (rect.x * scaleFactor); locTextureRect.renderY = locTextureRect.y = 0 | (rect.y * scaleFactor); @@ -1465,7 +1079,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { // recursively iterate over children if (_t._hasChildren) - _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._StateCallbackType.updateTransform); + _t._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); }; _p.addChild = function (child, localZOrder, tag) { @@ -1486,15 +1100,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._setNodeDirtyForCache(); }; - _p.setColor = function (color3) { - var _t = this; - var curColor = _t.color; - this._oldDisplayColor = curColor; - if ((curColor.r === color3.r) && (curColor.g === color3.g) && (curColor.b === color3.b)) - return; - cc.Node.prototype.setColor.call(_t, color3); - }; - _p.updateDisplayedColor = function (parentColor) { var _t = this; cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); @@ -1541,12 +1146,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t.texture = pNewTexture; if (_t._rectRotated) - _t._originalTexture = pNewTexture; + _t._originalTexture = pNewTexture; //TODO _t.setTextureRect(newFrame.getRect(), _t._rectRotated, newFrame.getOriginalSize()); - _t._colorized = false; - _t._rendererCmd._textureCoord.renderX = _t._rendererCmd._textureCoord.x; - _t._rendererCmd._textureCoord.renderY = _t._rendererCmd._textureCoord.y; + + _t._renderCmd._colorized = false; + _t._renderCmd._textureCoord.renderX = _t._renderCmd._textureCoord.x; + _t._renderCmd._textureCoord.renderY = _t._renderCmd._textureCoord.y; if (locTextureLoaded) { var curColor = _t.color; if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) @@ -1554,7 +1160,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - _p.isFrameDisplayed = function (frame) { + _p.isFrameDisplayed = function (frame) { //TODO there maybe has a bug if (frame.getTexture() != this._texture) return false; return cc.rectEqualToRect(frame.getRect(), this._rect); @@ -1606,31 +1212,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - if(!cc.sys._supportCanvasNewBlendModes) - _p._changeTextureColor = function () { - var locElement, locTexture = this._texture, locRect = this._rendererCmd._textureCoord; //this.getTextureRect(); - if (locTexture && locRect.validRect && this._originalTexture) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; - - var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); - if (cacheTextureForColor) { - this._colorized = true; - //generate color texture cache - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); - else { - locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.texture = locTexture; - } - } - } - }; - _p = null; } else { cc.assert(cc.isFunction(cc._tmp.WebGLSprite), cc._LogInfos.MissingFile, "SpritesWebGL.js"); diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index c34bd0cef7..7b1e5b026b 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -413,7 +413,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ texture2D = fileImage; texture2D && this.initWithTexture(texture2D, capacity); - this._rendererCmd = new cc.SpriteBatchNode.WebGLRenderCmd(this); + this._renderCmd = new cc.SpriteBatchNode.WebGLRenderCmd(this); }, /** @@ -877,8 +877,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ this.sortAllChildren(); this.transform(gl); //this.draw(gl); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); /* if (locGrid && locGrid.isActive()) locGrid.afterDraw(this);*/ diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index f485cfba57..56ca499e7c 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -245,7 +245,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ this._textureLoaded = true; if(this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS){ var tempElement = sender.getHtmlElementObj(); - tempElement = cc.cutRotateImageToCanvas(tempElement, this.getRect()); + tempElement = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, this.getRect()); var tempTexture = new cc.Texture2D(); tempTexture.initWithElement(tempElement); tempTexture.handleLoadedTexture(); diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index a8dff3fe6f..b65f265cda 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -192,7 +192,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ var locTexture = spriteFrame.getTexture(); if (locTexture.isLoaded()) { var tempElement = spriteFrame.getTexture().getHtmlElementObj(); - tempElement = cc.cutRotateImageToCanvas(tempElement, spriteFrame.getRectInPixels()); + tempElement = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, spriteFrame.getRectInPixels()); var tempTexture = new cc.Texture2D(); tempTexture.initWithElement(tempElement); tempTexture.handleLoadedTexture(); diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index c4f9908906..ba09e0d1e6 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -22,8 +22,8 @@ THE SOFTWARE. ****************************************************************************/ -cc.Sprite.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); +cc.Sprite.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); this._needDraw = true; this._textureCoord = { renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. @@ -34,11 +34,20 @@ cc.Sprite.CanvasRenderCmd = function(renderableObject){ height: 0, validRect: false }; + this._blendFuncStr = "source-over"; + this._colorized = false; + + this._originalTexture = null; + this._drawSizeCanvas = null; }; cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); cc.Sprite.CanvasRenderCmd.prototype.constructor = cc.Sprite.CanvasRenderCmd; +cc.Sprite.CanvasRenderCmd.prototype.updateBlendFunc = function(blendFunc){ + this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(blendFunc); +}; + cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { var self = this, node = self._node; @@ -176,17 +185,376 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { cc.g_NumberOfDraws++; }; +cc.Sprite.CanvasRenderCmd.prototype._changeTextureColor = function(){ + if(!cc.sys._supportCanvasNewBlendModes){ + var locElement, locTexture = this._texture, locRect = this._renderCmd._textureCoord; + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + + if(!cc.sys._supportCanvasNewBlendModes) { + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); + if (cacheTextureForColor) { + this._colorized = true; + //generate color texture cache + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.texture = locTexture; + } + } + } else { + this._colorized = true; + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor + && this._originalTexture._htmlElementObj != locElement) + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.texture = locTexture; + } + } + } + } +}; + +cc.Sprite.CanvasRenderCmd.prototype.getQuad = function(){ + //throw an error. + return null; +}; + +cc.Sprite.CanvasRenderCmd.prototype._spriteFrameLoadedCallback = function(spriteFrame){ + var _t = this; + _t.setNodeDirty(true); + _t.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); + + var curColor = _t.getColor(); + if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) + _t._changeTextureColor(); + + _t.dispatchEvent("load"); +}; + +//TODO need refactor these functions +//utils for tint +// Tint a texture using the "multiply" operation +cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply = function(image, color, rect, renderCanvas){ + renderCanvas = renderCanvas || cc.newElement("canvas"); + rect = rect || cc.rect(0,0, image.width, image.height); + var context = renderCanvas.getContext( "2d" ); + if(renderCanvas.width != rect.width || renderCanvas.height != rect.height){ + renderCanvas.width = rect.width; + renderCanvas.height = rect.height; + }else{ + context.globalCompositeOperation = "source-over"; + } + + context.fillStyle = "rgb(" + (0|color.r) + "," + (0|color.g) + "," + (0|color.b) + ")"; + context.fillRect(0, 0, rect.width, rect.height); + context.globalCompositeOperation = "multiply"; + context.drawImage(image, + rect.x, + rect.y, + rect.width, + rect.height, + 0, + 0, + rect.width, + rect.height); + context.globalCompositeOperation = "destination-atop"; + context.drawImage(image, + rect.x, + rect.y, + rect.width, + rect.height, + 0, + 0, + rect.width, + rect.height); + return renderCanvas; +}; + +//Generate tinted texture with lighter. +cc.Sprite.CanvasRenderCmd._generateTintImage = function (texture, tintedImgCache, color, rect, renderCanvas) { + if (!rect) + rect = cc.rect(0, 0, texture.width, texture.height); + + var r = color.r / 255, g = color.g / 255, b = color.b / 255; + var w = Math.min(rect.width, tintedImgCache[0].width); + var h = Math.min(rect.height, tintedImgCache[0].height); + var buff = renderCanvas, ctx; + // Create a new buffer if required + if (!buff) { + buff = cc.newElement("canvas"); + buff.width = w; + buff.height = h; + ctx = buff.getContext("2d"); + } else { + ctx = buff.getContext("2d"); + ctx.clearRect(0, 0, w, h); + } + + ctx.save(); + ctx.globalCompositeOperation = 'lighter'; + // Make sure to keep the renderCanvas alpha in mind in case of overdraw + var a = ctx.globalAlpha; + if (r > 0) { + ctx.globalAlpha = r * a; + ctx.drawImage(tintedImgCache[0], rect.x, rect.y, w, h, 0, 0, w, h); + } + if (g > 0) { + ctx.globalAlpha = g * a; + ctx.drawImage(tintedImgCache[1], rect.x, rect.y, w, h, 0, 0, w, h); + } + if (b > 0) { + ctx.globalAlpha = b * a; + ctx.drawImage(tintedImgCache[2], rect.x, rect.y, w, h, 0, 0, w, h); + } + if (r + g + b < 1) { + ctx.globalAlpha = a; + ctx.drawImage(tintedImgCache[3], rect.x, rect.y, w, h, 0, 0, w, h); + } + ctx.restore(); + return buff; +}; + +cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor = function (texture) { + if (texture.channelCache) { + return texture.channelCache; + } + + var textureCache = [ + cc.newElement("canvas"), + cc.newElement("canvas"), + cc.newElement("canvas"), + cc.newElement("canvas") + ]; + + function renderToCache() { + var ref = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor; + + var w = texture.width; + var h = texture.height; + + textureCache[0].width = w; + textureCache[0].height = h; + textureCache[1].width = w; + textureCache[1].height = h; + textureCache[2].width = w; + textureCache[2].height = h; + textureCache[3].width = w; + textureCache[3].height = h; + + ref.canvas.width = w; + ref.canvas.height = h; + + var ctx = ref.canvas.getContext("2d"); + ctx.drawImage(texture, 0, 0); + + ref.tempCanvas.width = w; + ref.tempCanvas.height = h; + + var pixels = ctx.getImageData(0, 0, w, h).data; + + for (var rgbI = 0; rgbI < 4; rgbI++) { + var cacheCtx = textureCache[rgbI].getContext('2d'); + cacheCtx.getImageData(0, 0, w, h).data; + ref.tempCtx.drawImage(texture, 0, 0); + + var to = ref.tempCtx.getImageData(0, 0, w, h); + var toData = to.data; + + for (var i = 0; i < pixels.length; i += 4) { + toData[i ] = (rgbI === 0) ? pixels[i ] : 0; + toData[i + 1] = (rgbI === 1) ? pixels[i + 1] : 0; + toData[i + 2] = (rgbI === 2) ? pixels[i + 2] : 0; + toData[i + 3] = pixels[i + 3]; + } + cacheCtx.putImageData(to, 0, 0); + } + texture.onload = null; + } + + try { + renderToCache(); + } catch (e) { + texture.onload = renderToCache; + } + + texture.channelCache = textureCache; + return textureCache; +}; + +cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.canvas = cc.newElement('canvas'); +cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas = cc.newElement('canvas'); +cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCtx = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas.getContext('2d'); + +cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas = function (texture, rect) { + if (!texture) + return null; + + if (!rect) + return texture; + + var nCanvas = cc.newElement("canvas"); + nCanvas.width = rect.width; + nCanvas.height = rect.height; + var ctx = nCanvas.getContext("2d"); + ctx.translate(nCanvas.width / 2, nCanvas.height / 2); + ctx.rotate(-1.5707963267948966); + ctx.drawImage(texture, rect.x, rect.y, rect.height, rect.width, -rect.height / 2, -rect.width / 2, rect.height, rect.width); + return nCanvas; +}; + +//++++++++++++++++++++++++++++++WebGL+++++++++++++++++++++++++++++++++++++++++++ //Sprite's WebGL render command -cc.Sprite.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); +cc.Sprite.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); this._needDraw = true; + + this._quad = new cc.V3F_C4B_T2F_Quad(); + this._quadWebBuffer = cc._renderContext.createBuffer(); + this._quadDirty = true; }; cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd); +cc.Sprite.WebGLRenderCmd.prototype.updateBlendFunc = function(blendFunc){ + //do nothing +}; + +cc.Sprite.WebGLRenderCmd.prototype.getQuad = function(){ + return this. _quad; +}; + +cc.Sprite.WebGLRenderCmd.prototype.getQuad._spriteFrameLoadedCallback = function(spriteFrame){ + this.setNodeDirty(true); + this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); + this.dispatchEvent("load"); +}; + +cc.Sprite.WebGLRenderCmd.prototype._setTextureCoords = function (rect) { + rect = cc.rectPointsToPixels(rect); + var node = this._node; + + var tex = node._batchNode ? node.textureAtlas.texture : node._texture; + if (!tex) + return; + + var atlasWidth = tex.pixelsWidth; + var atlasHeight = tex.pixelsHeight; + + var left, right, top, bottom, tempSwap, locQuad = this._quad; + if (node._rectRotated) { + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.height * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.height) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.width) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + if (node._flippedY) { + tempSwap = left; + left = right; + right = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = top; + locQuad.br.texCoords.u = left; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = right; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = bottom; + } else { + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.width * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.width) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.height) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = left; + left = right; + right = tempSwap; + } + + if (node._flippedY) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = bottom; + locQuad.br.texCoords.u = right; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = left; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = top; + } + this._quadDirty = true; +}; + +cc.Sprite.WebGLRenderCmd.prototype._updateColor = function () { + var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; + var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; + // special opacity for premultiplied textures + if (this._opacityModifyRGB) { + color4.r *= locDisplayedOpacity / 255.0; + color4.g *= locDisplayedOpacity / 255.0; + color4.b *= locDisplayedOpacity / 255.0; + } + var locQuad = this._quad, node = this._node; + locQuad.bl.colors = color4; + locQuad.br.colors = color4; + locQuad.tl.colors = color4; + locQuad.tr.colors = color4; + + // renders using Sprite Manager + if (node._batchNode) { + if (node.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { + node.textureAtlas.updateQuad(locQuad, node.atlasIndex) + } else { + // no need to set it recursively + // update dirty_, don't update recursiveDirty_ + node.dirty = true; + } + } + // self render + // do nothing + this._quadDirty = true; +}; + cc.Sprite.WebGLRenderCmd.prototype.rendering = function (ctx) { var _t = this._node; - if (!_t._textureLoaded || _t._displayedOpacity === 0) + if (!_t._textureLoaded || this._displayedOpacity === 0) return; var gl = ctx || cc._renderContext, locTexture = _t._texture; @@ -195,7 +563,7 @@ cc.Sprite.WebGLRenderCmd.prototype.rendering = function (ctx) { if (locTexture) { if (locTexture._isLoaded) { _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); //optimize performance for javascript @@ -203,9 +571,9 @@ cc.Sprite.WebGLRenderCmd.prototype.rendering = function (ctx) { cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (_t._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.DYNAMIC_DRAW); - _t._quadDirty = false; + if (this._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); + this._quadDirty = false; } gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR @@ -232,4 +600,26 @@ cc.Sprite.WebGLRenderCmd.prototype.rendering = function (ctx) { gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); } cc.g_NumberOfDraws++; + + if (cc.SPRITE_DEBUG_DRAW === 0 && !_t._showNode) + return; + + if (cc.SPRITE_DEBUG_DRAW === 1 || _t._showNode) { + // draw bounding box + var locQuad = _t._quad; + var verticesG1 = [ + cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), + cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), + cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), + cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) + ]; + cc._drawingUtil.drawPoly(verticesG1, 4, true); + } else if (cc.SPRITE_DEBUG_DRAW === 2) { + // draw texture box + var drawRectG2 = _t.getTextureRect(); + var offsetPixG2 = _t.getOffsetPosition(); + var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), + cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; + cc._drawingUtil.drawPoly(verticesG2, 4, true); + } // CC_SPRITE_DEBUG_DRAW }; \ No newline at end of file diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index b3757e2e65..aaecafbffc 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -63,17 +63,6 @@ cc._tmp.WebGLSprite = function () { self._softInit(fileName, rect, rotated); }; - _p.setBlendFunc = function (src, dst) { - var locBlendFunc = this._blendFunc; - if (dst === undefined) { - locBlendFunc.src = src.src; - locBlendFunc.dst = src.dst; - } else { - locBlendFunc.src = src; - locBlendFunc.dst = dst; - } - }; - _p.init = function () { var _t = this; if (arguments.length > 0) @@ -502,77 +491,4 @@ cc._tmp.WebGLSprite = function () { _t._updateBlendFunc(); } }; - - _p.draw = function () { - var _t = this; - if (!_t._textureLoaded) - return; - - var gl = cc._renderContext, locTexture = _t._texture; - //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); - - if (locTexture) { - if (locTexture._isLoaded) { - _t._shaderProgram.use(); - _t._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); - - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - //optimize performance for javascript - cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (_t._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.DYNAMIC_DRAW); - _t._quadDirty = false; - } - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS - - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - } - } else { - _t._shaderProgram.use(); - _t._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); - - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - cc.glBindTexture2D(null); - - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - - gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (_t._quadDirty) { - cc._renderContext.bufferData(cc._renderContext.ARRAY_BUFFER, _t._quad.arrayBuffer, cc._renderContext.STATIC_DRAW); - _t._quadDirty = false; - } - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - } - cc.g_NumberOfDraws++; - if (cc.SPRITE_DEBUG_DRAW === 0 && !_t._showNode) - return; - - if (cc.SPRITE_DEBUG_DRAW === 1 || _t._showNode) { - // draw bounding box - var locQuad = _t._quad; - var verticesG1 = [ - cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), - cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), - cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), - cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) - ]; - cc._drawingUtil.drawPoly(verticesG1, 4, true); - } else if (cc.SPRITE_DEBUG_DRAW === 2) { - // draw texture box - var drawRectG2 = _t.getTextureRect(); - var offsetPixG2 = _t.getOffsetPosition(); - var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), - cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; - cc._drawingUtil.drawPoly(verticesG2, 4, true); - } // CC_SPRITE_DEBUG_DRAW - }; - - delete _p; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index a8290816c7..53f2053b45 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -150,7 +150,7 @@ cc.textureCache = /** @lends cc.textureCache# */{ } if (!this._textureColorsCache[key]) - this._textureColorsCache[key] = cc.generateTextureCacheForColor(texture); + this._textureColorsCache[key] = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor(texture); return this._textureColorsCache[key]; }, diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index a3b7617502..cf16bfd34b 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -373,10 +373,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var locElement = locTexture.getHtmlElementObj(); var textureRect = cc.rect(0, 0, element.width, element.height); if (locElement instanceof HTMLCanvasElement && !this._rectRotated){ - cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); this.setTexture(locTexture); } else { - locElement = cc.generateTintImageWithMultiply(element, this._displayedColor, textureRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._displayedColor, textureRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); @@ -981,11 +981,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this.updateLabel(); }, - _setAnchor: function (p) { - cc.Node.prototype._setAnchor.call(this, p); - this.updateLabel(); - }, - _setAnchorX: function (x) { cc.Node.prototype._setAnchorX.call(this, x); this.updateLabel(); @@ -1073,10 +1068,10 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); if (cacheTextureForColor) { if (locElement instanceof HTMLCanvasElement && !this._rectRotated) { - cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); this.setTexture(locTexture); } else { - locElement = cc.generateTintImage(locElement, cacheTextureForColor, this._displayedColor); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 38f698c35b..cffafc8c80 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -116,7 +116,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ if(texture !== undefined) this.initWithFade(fade, minSeg, stroke, color, texture); - this._rendererCmd = new cc.MotionStreak.WebGLRenderCmd(this); + this._renderCmd = new cc.MotionStreak.WebGLRenderCmd(this); }, /** diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index b6e9a4b549..8e34607d46 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -102,7 +102,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ this.initWithTexture(fileImage, capacity); } if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._rendererCmd = new cc.ParticleBatchNode.WebGLRenderCmd(this); + this._renderCmd = new cc.ParticleBatchNode.WebGLRenderCmd(this); }, /** @@ -426,8 +426,8 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ this.transform(ctx); //this.draw(ctx); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); cc.kmGLPopMatrix(); }, diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 17a5728988..a663d7ff95 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -551,8 +551,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ */ setDrawMode:function (drawMode) { this.drawMode = drawMode; - if(this._rendererCmd) - this._rendererCmd._drawMode = drawMode; + if(this._renderCmd) + this._renderCmd._drawMode = drawMode; }, /** @@ -569,8 +569,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ */ setShapeType:function (shapeType) { this.shapeType = shapeType; - if(this._rendererCmd) - this._rendererCmd._shapeType = shapeType; + if(this._renderCmd) + this._renderCmd._shapeType = shapeType; }, /** @@ -2480,7 +2480,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ element.tintCache.width = element.width; element.tintCache.height = element.height; } - return cc.generateTintImageWithMultiply(element, color, rect, element.tintCache); + return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, color, rect, element.tintCache); }, _drawForWebGL:function (ctx) { @@ -2620,7 +2620,7 @@ if(cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendMo cacheTextureForColor.tintCache.width = element.width; cacheTextureForColor.tintCache.height = element.height; } - cc.generateTintImage(element, cacheTextureForColor, color, rect, cacheTextureForColor.tintCache); + cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, color, rect, cacheTextureForColor.tintCache); return cacheTextureForColor.tintCache; } return null diff --git a/cocos2d/particle/CCParticleSystemRenderCmd.js b/cocos2d/particle/CCParticleSystemRenderCmd.js index 96aebb7679..449ad964e4 100644 --- a/cocos2d/particle/CCParticleSystemRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemRenderCmd.js @@ -88,7 +88,7 @@ cc.ParticleSystem.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, s cacheTextureForColor.tintCache.width = element.width; cacheTextureForColor.tintCache.height = element.height; } - cc.generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); + cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); drawElement = cacheTextureForColor.tintCache; } } diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 596e1113eb..a539e89db5 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -276,7 +276,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ _setSpriteForCanvas:function (sprite) { if (this._sprite != sprite) { this._sprite = sprite; - this._rendererCmd._sprite = sprite; + this._renderCmd._sprite = sprite; this.width = this._sprite.width; this.height = this._sprite.height; } @@ -307,7 +307,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ _setTypeForCanvas:function (type) { if (type !== this._type){ this._type = type; - this._rendererCmd._type = type; + this._renderCmd._type = type; } }, @@ -731,7 +731,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ var locSprite = this._sprite; var sw = locSprite.width, sh = locSprite.height; var locMidPoint = this._midPoint; - var locCmd = this._rendererCmd; + var locCmd = this._renderCmd; if (this._type == cc.ProgressTimer.TYPE_RADIAL) { locCmd._radius = Math.round(Math.sqrt(sw * sw + sh * sh)); diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js index 9137a47ca4..4bb4aa9892 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -43,7 +43,7 @@ cc.ProgressTimer.CanvasRenderCmd.prototype.constructor = cc.ProgressTimer.Canvas cc.ProgressTimer.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; - var locTextureCoord = locSprite._rendererCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + var locTextureCoord = locSprite._renderCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; if (locTextureCoord.width === 0 || locTextureCoord.height === 0) return; diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 64237f7cc0..c9f0511111 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -169,7 +169,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ } //TODO need merge in some code - this._rendererCmd = new cc.RenderTexture.WebGLRenderCmd(this); + this._renderCmd = new cc.RenderTexture.WebGLRenderCmd(this); }, /** @@ -645,8 +645,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ this.sprite.visit(); //this.draw(ctx); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); //TODO GridNode /* if (locGrid && locGrid.isActive()) diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 0aa7411bde..303aab6066 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -102,7 +102,7 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ */ ctor: function () { cc.Node.prototype.ctor.call(this); - var locCmd = this._rendererCmd; + var locCmd = this._renderCmd; locCmd._buffer = this._buffer = []; locCmd._drawColor = this._drawColor = cc.color(255, 255, 255, 255); locCmd._blendFunc = this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 0e8b3a57ce..1448c13d13 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -117,11 +117,11 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this.initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo); }, - _initRendererCmd: function(){ + _createRendererCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._rendererCmd = new cc.TMXLayer.CanvasRenderCmd(this); + return new cc.TMXLayer.CanvasRenderCmd(this); else - this._rendererCmd = new cc.TMXLayer.WebGLRenderCmd(this); + return new cc.TMXLayer.WebGLRenderCmd(this); }, /** @@ -222,7 +222,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ } //copy cached render cmd array to TMXLayer renderer - this._rendererCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); + this._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); locCacheContext.save(); locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); @@ -234,7 +234,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ locCacheContext.restore(); this._cacheDirty = false; } - cc.renderer.pushRenderCommand(this._rendererCmd); + cc.renderer.pushRenderCommand(this._renderCmd); }, //set the cache dirty flag for canvas diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 9dc13d731a..beebade536 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -269,8 +269,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } // _t.draw(context); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); for (; i < childLen; i++) children[i] && children[i].visit(context); @@ -318,8 +318,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ break; } // _t.draw(context); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); // draw children zOrder >= 0 for (; i < childLen; i++) { diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 884a3d7ade..3d76d1ae9d 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -447,8 +447,8 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ break; } //this.draw(); //draw self - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); for (; i < iLen; i++) locChildren[i].visit(); for (; j < jLen; j++) @@ -610,7 +610,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (able){ this._clippingStencil = new cc.DrawNode(); if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._clippingStencil._rendererCmd.rendering = this.__stencilDraw.bind(this); + this._clippingStencil._renderCmd.rendering = this.__stencilDraw.bind(this); if (this._running) this._clippingStencil.onEnter(); this._setStencilClippingSize(this._contentSize); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 5afca50eea..b6a49945a8 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -75,7 +75,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._rendererStartCmd = new ccs.Armature.CanvasRenderCmd(this); this._rendererEndCmd = new ccs.Armature.CanvasRestoreRenderCmd(this); }else{ - this._rendererCmd = new ccs.Armature.WebGLRenderCmd(this); + this._renderCmd = new ccs.Armature.WebGLRenderCmd(this); } }, @@ -496,7 +496,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.sortAllChildren(); //this.draw(context); - cc.renderer.pushRenderCommand(this._rendererCmd); + cc.renderer.pushRenderCommand(this._renderCmd); currentStack.top = currentStack.stack.pop(); }, diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index f2356b3fc3..effd7748fa 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -242,8 +242,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ }); if (cc._renderType == cc._RENDER_TYPE_WEBGL) { ccs.Skin.prototype.updateTransform = ccs.Skin.prototype._updateTransformForWebGL; -}else{ - //ccs.Skin.prototype.getNodeToParentTransform = cc.Node.prototype._getNodeToParentTransformForWebGL; } diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 28c396c7f9..31ab2b3413 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -636,16 +636,16 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ } // this.draw(context); // self draw - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); // draw children zOrder >= 0 for (; i < childrenLen; i++) locChildren[i].visit(context); } else{ // this.draw(context); // self draw - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); } // this._afterDraw(); @@ -676,16 +676,16 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ // this draw //this.draw(context); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); // draw children zOrder >= 0 for (; i < childrenLen; i++) locChildren[i].visit(); } else{ //this.draw(context); - if(this._rendererCmd) - cc.renderer.pushRenderCommand(this._rendererCmd); + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); } this._afterDraw(context); diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 875c5054ef..7afbd19f35 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -94,9 +94,9 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ _initRendererCmd:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._rendererCmd = new sp.Skeleton.CanvasRenderCmd(this); + this._renderCmd = new sp.Skeleton.CanvasRenderCmd(this); else - this._rendererCmd = new sp.Skeleton.WebGLRenderCmd(this); + this._renderCmd = new sp.Skeleton.WebGLRenderCmd(this); }, /** diff --git a/moduleConfig.json b/moduleConfig.json index 0e6eebd26e..fb4bf7f984 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -119,6 +119,7 @@ "cocos2d/core/labelttf/LabelTTFWebGL.js", "cocos2d/core/labelttf/LabelTTFPropertyDefine.js", "cocos2d/core/labelttf/CCLabelTTF.js", + "cocos2d/core/labelttf/CCLabelTTFRenderCmd.js", "cocos2d/core/CCActionManager.js" ], diff --git a/template/project.json b/template/project.json index 0c277b291a..cd45a5926f 100644 --- a/template/project.json +++ b/template/project.json @@ -3,7 +3,7 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 0, + "renderMode" : 1, "engineDir":"../", "modules" : ["cocos2d"], From 8ed792ce35293e852c328ea19e4adb655c482d53 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 17 Nov 2014 10:47:44 +0800 Subject: [PATCH 0913/1564] Issue #2416: refactor cc.Sprite's renderer --- cocos2d/core/sprites/CCSprite.js | 234 ++++++---------------- cocos2d/core/sprites/CCSpriteBatchNode.js | 1 - cocos2d/core/sprites/CCSpriteRenderCmd.js | 150 +++++++++++++- cocos2d/core/sprites/SpritesWebGL.js | 146 +------------- 4 files changed, 214 insertions(+), 317 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 571fb601f5..95267c5df8 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -120,11 +120,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _textureLoaded:false, _className:"Sprite", - //Only for texture update judgment - _oldDisplayColor: cc.color.WHITE, //TODO move to Canvas render - _originalTexture: null, //TODO move to Canvas render cmd - _drawSize_Canvas: null, ctor: function (fileName, rect, rotated) { var self = this; @@ -522,7 +518,12 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @function * @param {Boolean} modify */ - setOpacityModifyRGB:null, + setOpacityModifyRGB: function (modify) { + if (this._opacityModifyRGB !== modify) { + this._opacityModifyRGB = modify; + this._renderCmd._updateColor(); + } + }, /** * Returns whether opacity modify color or not. @@ -532,12 +533,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ return this._opacityModifyRGB; }, - /** - * Update the display opacity. - * @function - */ - updateDisplayedOpacity: null, - // Animation /** @@ -653,7 +648,36 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @function * @return {Boolean} */ - init:null, + init: function () { + var _t = this; + if (arguments.length > 0) + return _t.initWithFile(arguments[0], arguments[1]); + + cc.Node.prototype.init.call(_t); + _t.dirty = _t._recursiveDirty = false; + + _t._blendFunc.src = cc.BLEND_SRC; + _t._blendFunc.dst = cc.BLEND_DST; + + _t.texture = null; + _t._textureLoaded = true; + _t._flippedX = _t._flippedY = false; + + // default transform anchor: center + _t.anchorX = 0.5; + _t.anchorY = 0.5; + + // zwoptex default values + _t._offsetPosition.x = 0; + _t._offsetPosition.y = 0; + _t._hasChildren = false; + + this._renderCmd.init(); + // updated in "useSelfRender" + // Atlas: TexCoords + _t.setTextureRect(cc.rect(0, 0, 0, 0), false, cc.size(0, 0)); + return true; + }, /** *

    @@ -696,8 +720,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ */ initWithTexture: null, - _textureLoadedCallback: null, - /** * Updates the texture rect of the CCSprite in points. * @function @@ -724,20 +746,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ */ addChild: null, - /** - * Sets opacity of the sprite - * @function - * @param {Number} opacity - */ - setOpacity:null, - - /** - * Sets color of the sprite - * @function - * @param {cc.Color} color3 - */ - setColor: null, - /** * Updates the display color * @function @@ -768,7 +776,9 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param {cc.SpriteFrame} frame * @return {Boolean} */ - isFrameDisplayed: null, + isFrameDisplayed: function(frame){ + return this._renderCmd.isFrameDisplayed(frame); + }, /** * Returns the current displayed frame. @@ -800,25 +810,27 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @function * @param {cc.Texture2D|String} texture */ - setTexture: null, - - // Texture protocol - _updateBlendFunc:function () { - if(this._batchNode){ - cc.log(cc._LogInfos.Sprite__updateBlendFunc); + setTexture: function (texture) { + var _t = this; + if(texture && (cc.isString(texture))){ + texture = cc.textureCache.addImage(texture); + _t.setTexture(texture); + //TODO + var size = texture.getContentSize(); + _t.setTextureRect(cc.rect(0,0, size.width, size.height)); + //If image isn't loaded. Listen for the load event. + if(!texture._isLoaded){ + texture.addEventListener("load", function(){ + var size = texture.getContentSize(); + _t.setTextureRect(cc.rect(0,0, size.width, size.height)); + }, this); + } return; } + // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet + cc.assert(!texture || texture instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2); - // it's possible to have an untextured sprite - if (!this._texture || !this._texture.hasPremultipliedAlpha()) { - this._blendFunc.src = cc.SRC_ALPHA; - this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - this.opacityModifyRGB = false; - } else { - this._blendFunc.src = cc.BLEND_SRC; - this._blendFunc.dst = cc.BLEND_DST; - this.opacityModifyRGB = true; - } + this._renderCmd._setTexture(texture); }, _createRenderCmd: function(){ @@ -873,48 +885,6 @@ cc.Sprite.INDEX_NOT_INITIALIZED = -1; if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _p = cc.Sprite.prototype; - _p.setOpacityModifyRGB = function (modify) { - if (this._opacityModifyRGB !== modify) { - this._opacityModifyRGB = modify; - this.setNodeDirty(true); - } - }; - - _p.updateDisplayedOpacity = function (parentOpacity) { - cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); - this._setNodeDirtyForCache(); - }; - - _p.init = function () { - var _t = this; - if (arguments.length > 0) - return _t.initWithFile(arguments[0], arguments[1]); - - cc.Node.prototype.init.call(_t); - _t.dirty = _t._recursiveDirty = false; - - _t._blendFunc.src = cc.BLEND_SRC; - _t._blendFunc.dst = cc.BLEND_DST; - - _t.texture = null; - _t._textureLoaded = true; - _t._flippedX = _t._flippedY = false; - - // default transform anchor: center - _t.anchorX = 0.5; - _t.anchorY = 0.5; - - // zwoptex default values - _t._offsetPosition.x = 0; - _t._offsetPosition.y = 0; - _t._hasChildren = false; - - // updated in "useSelfRender" - // Atlas: TexCoords - _t.setTextureRect(cc.rect(0, 0, 0, 0), false, cc.size(0, 0)); - return true; - }; - _p.initWithTexture = function (texture, rect, rotated) { var _t = this; cc.assert(arguments.length != 0, cc._LogInfos.CCSpriteBatchNode_initWithTexture); @@ -945,8 +915,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _t._flippedX = _t._flippedY = false; // default transform anchor: center - _t.anchorX = 0.5; - _t.anchorY = 0.5; + _t.setAnchorPoint(0.5, 0.5); // zwoptex default values _t._offsetPosition.x = 0; @@ -966,14 +935,13 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } if(_t.texture) _t.texture.removeEventListener("load", _t); - texture.addEventListener("load", _t._textureLoadedCallback, _t); + texture.addEventListener("load", _t._renderCmd._textureLoadedCallback, _t); _t.texture = texture; return true; } - if (!rect) { + if (!rect) rect = cc.rect(0, 0, texture.width, texture.height); - } if(texture && texture.url) { var _x = rect.x + rect.width, _y = rect.y + rect.height; @@ -994,35 +962,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return true; }; - _p._textureLoadedCallback = function (sender) { - var _t = this; - if(_t._textureLoaded) - return; - - _t._textureLoaded = true; - var locRect = _t._rect; - if (!locRect) { - locRect = cc.rect(0, 0, sender.width, sender.height); - } else if (cc._rectEqualToZero(locRect)) { - locRect.width = sender.width; - locRect.height = sender.height; - } - _t._originalTexture = sender; - - _t.texture = sender; - _t.setTextureRect(locRect, _t._rectRotated); - - //set the texture's color after the it loaded - var locColor = this._displayedColor; - if(locColor.r != 255 || locColor.g != 255 || locColor.b != 255) - _t._changeTextureColor(); - - // by default use "Self Render". - // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - _t.batchNode = _t._batchNode; - _t.dispatchEvent("load"); - }; - _p.setTextureRect = function (rect, rotated, untrimmedSize) { var _t = this; _t._rectRotated = rotated || false; @@ -1055,7 +994,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.updateTransform = function () { var _t = this; - //cc.assert(_t._batchNode, "updateTransform is only valid when cc.Sprite is being rendered using an cc.SpriteBatchNode"); // re-calculate matrix only if it is dirty if (_t.dirty) { @@ -1095,23 +1033,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._hasChildren = true; }; - _p.setOpacity = function (opacity) { - cc.Node.prototype.setOpacity.call(this, opacity); - this._setNodeDirtyForCache(); - }; - - _p.updateDisplayedColor = function (parentColor) { - var _t = this; - cc.Node.prototype.updateDisplayedColor.call(_t, parentColor); - var oColor = _t._oldDisplayColor; - var nColor = _t._displayedColor; - if (oColor.r === nColor.r && oColor.g === nColor.g && oColor.b === nColor.b) - return; - - _t._changeTextureColor(); - _t._setNodeDirtyForCache(); - }; - _p.setSpriteFrame = function (newFrame) { var _t = this; if(cc.isString(newFrame)){ @@ -1160,12 +1081,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - _p.isFrameDisplayed = function (frame) { //TODO there maybe has a bug - if (frame.getTexture() != this._texture) - return false; - return cc.rectEqualToRect(frame.getRect(), this._rect); - }; - _p.setBatchNode = function (spriteBatchNode) { var _t = this; _t._batchNode = spriteBatchNode; // weak reference @@ -1183,35 +1098,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - _p.setTexture = function (texture) { - var _t = this; - if(texture && (cc.isString(texture))){ - texture = cc.textureCache.addImage(texture); - _t.setTexture(texture); - //TODO - var size = texture.getContentSize(); - _t.setTextureRect(cc.rect(0,0, size.width, size.height)); - //If image isn't loaded. Listen for the load event. - if(!texture._isLoaded){ - texture.addEventListener("load", function(){ - var size = texture.getContentSize(); - _t.setTextureRect(cc.rect(0,0, size.width, size.height)); - }, this); - } - return; - } - - // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet - cc.assert(!texture || texture instanceof cc.Texture2D, cc._LogInfos.CCSpriteBatchNode_setTexture); - - if (_t._texture != texture) { - if (texture && texture.getHtmlElementObj() instanceof HTMLImageElement) { - _t._originalTexture = texture; - } - _t._texture = texture; - } - }; - _p = null; } else { cc.assert(cc.isFunction(cc._tmp.WebGLSprite), cc._LogInfos.MissingFile, "SpritesWebGL.js"); diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 7b1e5b026b..9a6381cf75 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -526,7 +526,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, _insertQuadFromSpriteForWebGL: function (sprite, index) { - cc.assert(sprite, cc._LogInfos.Sprite_insertQuadFromSprite_2); if (!(sprite instanceof cc.Sprite)) { diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index ba09e0d1e6..2b78f1ddbc 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -44,6 +44,31 @@ cc.Sprite.CanvasRenderCmd = function(renderable){ cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); cc.Sprite.CanvasRenderCmd.prototype.constructor = cc.Sprite.CanvasRenderCmd; +cc.Sprite.CanvasRenderCmd.prototype.init = function(){ +}; + +cc.Sprite.CanvasRenderCmd.prototype._setTexture = function(texture){ + var node = this._node; + if (node._texture != texture) { + if (texture && texture.getHtmlElementObj() instanceof HTMLImageElement) { + this._originalTexture = texture; + } + node._texture = texture; + } +}; + +cc.Sprite.CanvasRenderCmd.prototype._updateColor = function(){ + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty); +}; + +cc.Sprite.CanvasRenderCmd.prototype.isFrameDisplayed = function(frame){ + //TODO there maybe has a bug + var node = this._node; + if (frame.getTexture() != node._texture) + return false; + return cc.rectEqualToRect(frame.getRect(), node._rect); +}; + cc.Sprite.CanvasRenderCmd.prototype.updateBlendFunc = function(blendFunc){ this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(blendFunc); }; @@ -226,15 +251,21 @@ cc.Sprite.CanvasRenderCmd.prototype._changeTextureColor = function(){ }; cc.Sprite.CanvasRenderCmd.prototype.getQuad = function(){ - //throw an error. + //throw an error. it doesn't support this function. return null; }; +cc.Sprite.CanvasRenderCmd.prototype._updateDisplayColor = function(parentColor){ + cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, parentColor); + this._changeTextureColor(); +}; + cc.Sprite.CanvasRenderCmd.prototype._spriteFrameLoadedCallback = function(spriteFrame){ var _t = this; _t.setNodeDirty(true); _t.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); + //TODO change var curColor = _t.getColor(); if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) _t._changeTextureColor(); @@ -242,6 +273,35 @@ cc.Sprite.CanvasRenderCmd.prototype._spriteFrameLoadedCallback = function(sprite _t.dispatchEvent("load"); }; +cc.Sprite.CanvasRenderCmd.prototype._textureLoadedCallback = function (sender) { + var _t = this; + if(_t._textureLoaded) + return; + + _t._textureLoaded = true; + var locRect = _t._rect, locRenderCmd = this._renderCmd; + if (!locRect) { + locRect = cc.rect(0, 0, sender.width, sender.height); + } else if (cc._rectEqualToZero(locRect)) { + locRect.width = sender.width; + locRect.height = sender.height; + } + locRenderCmd._originalTexture = sender; + + _t.texture = sender; + _t.setTextureRect(locRect, _t._rectRotated); + + //set the texture's color after the it loaded + var locColor = locRenderCmd._displayedColor; + if(locColor.r != 255 || locColor.g != 255 || locColor.b != 255) + _t._changeTextureColor(); + + // by default use "Self Render". + // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" + _t.setBatchNode(_t._batchNode); + _t.dispatchEvent("load"); +}; + //TODO need refactor these functions //utils for tint // Tint a texture using the "multiply" operation @@ -430,16 +490,55 @@ cc.Sprite.WebGLRenderCmd.prototype.updateBlendFunc = function(blendFunc){ //do nothing }; +cc.Sprite.WebGLRenderCmd.prototype.isFrameDisplayed = function(frame){ + var node = this._node; + return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() == node._texture.getName() + && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); +}; + +cc.Sprite.WebGLRenderCmd.prototype.init = function(){ + var tempColor = {r: 255, g: 255, b: 255, a: 255}, quad = this._quad; + quad.bl.colors = tempColor; + quad.br.colors = tempColor; + quad.tl.colors = tempColor; + quad.tr.colors = tempColor; + this._quadDirty = true; +}; + cc.Sprite.WebGLRenderCmd.prototype.getQuad = function(){ return this. _quad; }; -cc.Sprite.WebGLRenderCmd.prototype.getQuad._spriteFrameLoadedCallback = function(spriteFrame){ +cc.Sprite.WebGLRenderCmd.prototype._spriteFrameLoadedCallback = function(spriteFrame){ this.setNodeDirty(true); this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); this.dispatchEvent("load"); }; +cc.Sprite.WebGLRenderCmd.prototype._textureLoadedCallback = function (sender) { + var _t = this; + if(_t._textureLoaded) + return; + + _t._textureLoaded = true; + var locRect = _t._rect, renderCmd = this._renderCmd; + if (!locRect) { + locRect = cc.rect(0, 0, sender.width, sender.height); + } else if (cc._rectEqualToZero(locRect)) { + locRect.width = sender.width; + locRect.height = sender.height; + } + + _t.texture = sender; + _t.setTextureRect(locRect, _t._rectRotated); + + // by default use "Self Render". + // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" + _t.batchNode = _t._batchNode; + renderCmd._quadDirty = true; + _t.dispatchEvent("load"); +}; + cc.Sprite.WebGLRenderCmd.prototype._setTextureCoords = function (rect) { rect = cc.rectPointsToPixels(rect); var node = this._node; @@ -522,6 +621,16 @@ cc.Sprite.WebGLRenderCmd.prototype._setTextureCoords = function (rect) { this._quadDirty = true; }; +cc.Sprite.WebGLRenderCmd.prototype._updateDisplayColor = function(parentColor){ + cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); + this._updateColor(); +}; + +cc.Sprite.WebGLRenderCmd.prototype._updateDisplayOpacity = function(parentOpacity){ + cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); + this._updateColor(); +}; + cc.Sprite.WebGLRenderCmd.prototype._updateColor = function () { var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; @@ -552,6 +661,43 @@ cc.Sprite.WebGLRenderCmd.prototype._updateColor = function () { this._quadDirty = true; }; +cc.Sprite.WebGLRenderCmd.prototype._updateBlendFunc = function(){ + if(this._batchNode){ + cc.log(cc._LogInfos.Sprite__updateBlendFunc); + return; + } + + // it's possible to have an untextured sprite + if (!this._texture || !this._texture.hasPremultipliedAlpha()) { + this._blendFunc.src = cc.SRC_ALPHA; + this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + this.opacityModifyRGB = false; + } else { + this._blendFunc.src = cc.BLEND_SRC; + this._blendFunc.dst = cc.BLEND_DST; + this.opacityModifyRGB = true; + } +}; + +cc.Sprite.WebGLRenderCmd.prototype._setTexture = function(texture){ + var node = this._node; + // If batchnode, then texture id should be the same + if(node._batchNode && node._batchNode.texture != texture) { + cc.log(cc._LogInfos.Sprite_setTexture); + return; + } + + if (texture) + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + else + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); + + if (!node._batchNode && node._texture != texture) { + node._texture = texture; + this._updateBlendFunc(); + } +}; + cc.Sprite.WebGLRenderCmd.prototype.rendering = function (ctx) { var _t = this._node; if (!_t._textureLoaded || this._displayedOpacity === 0) diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index aaecafbffc..537cb9ba0c 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -27,82 +27,6 @@ cc._tmp.WebGLSprite = function () { var _p = cc.Sprite.prototype; - _p._spriteFrameLoadedCallback = function(spriteFrame){ - this.setNodeDirty(true); - this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - this.dispatchEvent("load"); - }; - - _p.setOpacityModifyRGB = function (modify) { - if (this._opacityModifyRGB !== modify) { - this._opacityModifyRGB = modify; - this.updateColor(); - } - }; - - _p.updateDisplayedOpacity = function (parentOpacity) { - cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); - this.updateColor(); - }; - - _p.ctor = function (fileName, rect, rotated) { - var self = this; - cc.Node.prototype.ctor.call(self); - self._shouldBeHidden = false; - self._offsetPosition = cc.p(0, 0); - self._unflippedOffsetPositionFromCenter = cc.p(0, 0); - self._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; - self._rect = cc.rect(0,0,0,0); - - self._quad = new cc.V3F_C4B_T2F_Quad(); - self._quadWebBuffer = cc._renderContext.createBuffer(); - self._quadDirty = true; - - self._textureLoaded = true; - - self._softInit(fileName, rect, rotated); - }; - - _p.init = function () { - var _t = this; - if (arguments.length > 0) - return _t.initWithFile(arguments[0], arguments[1]); - - cc.Node.prototype.init.call(_t); - _t.dirty = _t._recursiveDirty = false; - - _t._blendFunc.src = cc.BLEND_SRC; - _t._blendFunc.dst = cc.BLEND_DST; - - // update texture (calls _updateBlendFunc) - _t.texture = null; - _t._textureLoaded = true; - _t._flippedX = _t._flippedY = false; - - // default transform anchor: center - _t.anchorX = 0.5; - _t.anchorY = 0.5; - - // zwoptex default values - _t._offsetPosition.x = 0; - _t._offsetPosition.y = 0; - - _t._hasChildren = false; - - // Atlas: Color - var tempColor = {r: 255, g: 255, b: 255, a: 255}; - _t._quad.bl.colors = tempColor; - _t._quad.br.colors = tempColor; - _t._quad.tl.colors = tempColor; - _t._quad.tr.colors = tempColor; - _t._quadDirty = true; - - // updated in "useSelfRender" - // Atlas: TexCoords - _t.setTextureRect(cc.rect(0, 0, 0, 0), false, cc.size(0, 0)); - return true; - }; - _p.initWithTexture = function (texture, rect, rotated) { var _t = this; var argnum = arguments.length; @@ -125,8 +49,7 @@ cc._tmp.WebGLSprite = function () { _t._flippedX = _t._flippedY = false; // default transform anchor: center - _t.anchorX = 0.5; - _t.anchorY = 0.5; + _t.setAnchorPoint(0.5, 0.5); // zwoptex default values _t._offsetPosition.x = 0; @@ -140,6 +63,7 @@ cc._tmp.WebGLSprite = function () { locQuad.br.colors = tmpColor; locQuad.tl.colors = tmpColor; locQuad.tr.colors = tmpColor; + _t._quadDirty = true; var locTextureLoaded = texture.isLoaded(); _t._textureLoaded = locTextureLoaded; @@ -153,13 +77,12 @@ cc._tmp.WebGLSprite = function () { locRect.width = rect.width; locRect.height = rect.height; } - texture.addEventListener("load", _t._textureLoadedCallback, _t); + texture.addEventListener("load", _t._renderCmd._textureLoadedCallback, _t); return true; } - if (!rect) { + if (!rect) rect = cc.rect(0, 0, texture.width, texture.height); - } if(texture && texture.url) { var _x, _y; @@ -184,32 +107,8 @@ cc._tmp.WebGLSprite = function () { // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" _t.batchNode = null; - _t._quadDirty = true; - return true; - }; - _p._textureLoadedCallback = function (sender) { - var _t = this; - if(_t._textureLoaded) - return; - - _t._textureLoaded = true; - var locRect = _t._rect; - if (!locRect) { - locRect = cc.rect(0, 0, sender.width, sender.height); - } else if (cc._rectEqualToZero(locRect)) { - locRect.width = sender.width; - locRect.height = sender.height; - } - - _t.texture = sender; - _t.setTextureRect(locRect, _t._rectRotated); - - // by default use "Self Render". - // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - _t.batchNode = _t._batchNode; - _t._quadDirty = true; - _t.dispatchEvent("load"); + return true; }; _p.setTextureRect = function (rect, rotated, untrimmedSize) { @@ -225,7 +124,6 @@ cc._tmp.WebGLSprite = function () { relativeOffset.x = -relativeOffset.x; if (_t._flippedY) relativeOffset.y = -relativeOffset.y; - var locRect = _t._rect; _t._offsetPosition.x = relativeOffset.x + (_t._contentSize.width - locRect.width) / 2; _t._offsetPosition.y = relativeOffset.y + (_t._contentSize.height - locRect.height) / 2; @@ -255,9 +153,8 @@ cc._tmp.WebGLSprite = function () { _p.updateTransform = function () { var _t = this; - //cc.assert(_t._batchNode, "updateTransform is only valid when cc.Sprite is being rendered using an cc.SpriteBatchNode"); - // recaculate matrix only if it is dirty + // recalculate matrix only if it is dirty if (_t.dirty) { var locQuad = _t._quad, locParent = _t._parent; // If it is not visible, or one of its ancestors is not visible, then do nothing: @@ -369,16 +266,6 @@ cc._tmp.WebGLSprite = function () { _t._hasChildren = true; }; - _p.setOpacity = function (opacity) { - cc.Node.prototype.setOpacity.call(this, opacity); - this.updateColor(); - }; - - _p.setColor = function (color3) { - cc.Node.prototype.setColor.call(this, color3); - this.updateColor(); - }; - _p.updateDisplayedColor = function (parentColor) { cc.Node.prototype.updateDisplayedColor.call(this, parentColor); this.updateColor(); @@ -419,11 +306,6 @@ cc._tmp.WebGLSprite = function () { _t.setTextureRect(newFrame.getRect(), _t._rectRotated, newFrame.getOriginalSize()); }; - _p.isFrameDisplayed = function (frame) { - return (cc.rectEqualToRect(frame.getRect(), this._rect) && frame.getTexture().getName() == this._texture.getName() - && cc.pointEqualToPoint(frame.getOffset(), this._unflippedOffsetPositionFromCenter)); - }; - _p.setBatchNode = function (spriteBatchNode) { var _t = this; _t._batchNode = spriteBatchNode; // weak reference @@ -458,7 +340,6 @@ cc._tmp.WebGLSprite = function () { if(texture && (cc.isString(texture))){ texture = cc.textureCache.addImage(texture); _t.setTexture(texture); - //TODO var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); @@ -472,23 +353,8 @@ cc._tmp.WebGLSprite = function () { return; } // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet - cc.assert(!texture || (texture instanceof cc.Texture2D), cc._LogInfos.Sprite_setTexture_2); - // If batchnode, then texture id should be the same - if(_t._batchNode && _t._batchNode.texture != texture) { - cc.log(cc._LogInfos.Sprite_setTexture); - return; - } - if (texture) - _t.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - else - _t.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); - - if (!_t._batchNode && _t._texture != texture) { - _t._texture = texture; - _t._updateBlendFunc(); - } }; }; \ No newline at end of file From 00c76c4deeb7d65df4f5ec05c98f820af72dcb7b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 17 Nov 2014 17:34:59 +0800 Subject: [PATCH 0914/1564] Fix browser version wrong --- CCBoot.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 5484d8827f..0cbf9d6da3 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1512,7 +1512,7 @@ cc._initSys = function (config, CONFIG_KEY) { sys.language = currLanguage; var browserType = sys.BROWSER_TYPE_UNKNOWN; - var browserTypes = ua.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i) + var browserTypes = ua.match(/micromessenger|qqbrowser|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i) || ua.match(/chrome|safari/i); if (browserTypes && browserTypes.length > 0) { browserType = browserTypes[0].toLowerCase(); @@ -1521,6 +1521,7 @@ cc._initSys = function (config, CONFIG_KEY) { } else if (browserType === "safari" && (ua.match(/android.*applewebkit/))) browserType = sys.BROWSER_TYPE_ANDROID; else if (browserType == "trident") browserType = sys.BROWSER_TYPE_IE; + else if (browserType == "360 aphone") browserType = sys.BROWSER_TYPE_360; } /** * Indicate the running browser type @@ -1607,7 +1608,7 @@ cc._initSys = function (config, CONFIG_KEY) { // check if browser supports Web Audio // check Web Audio's context try { - sys._supportWebAudio = !!(new (win.AudioContext || win.webkitAudioContext || win.mozAudioContext)()); + sys._supportWebAudio = !!(win.AudioContext || win.webkitAudioContext || win.mozAudioContext); } catch (e) { sys._supportWebAudio = false; } From c434e767cbffa6bf8572bb6c9201fbe189d57277 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 17 Nov 2014 17:36:33 +0800 Subject: [PATCH 0915/1564] Issue #2457: Merge webAudio and DOM Audio, Reduce the audioEngine logic --- cocos2d/audio/CCAudio.js | 1766 ++++++++++++++++---------------------- 1 file changed, 760 insertions(+), 1006 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 3038d2cbb7..9ca6582d31 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -24,1151 +24,905 @@ THE SOFTWARE. ****************************************************************************/ -if (cc.sys._supportWebAudio) { - var _ctx = cc.webAudioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); - /** - * A class of Web Audio. - * @class - * @param src - * @extends cc.Class - */ - cc.WebAudio = cc.Class.extend({ - _events: null, - _buffer: null, - _sourceNode: null, - _volumeNode: null, +/** + * Audio support in the browser + * + * multichannel : Multiple audio while playing - If it doesn't, you can only play background music + * webAudio : Support for WebAudio - Support W3C WebAudio standards, all of the audio can be played + * auto : Supports auto-play audio - if Don‘t support it, On a touch detecting background music canvas, and then replay + * + * May be modifications for a few browser version + */ +(function(){ + + var DEBUG = false; + + var sys = cc.sys; + + var supportTable = { + "common" : {multichannel: true , webAudio: cc.sys._supportWebAudio , auto: true } + }; + + // ANDROID // + supportTable[sys.BROWSER_TYPE_ANDROID] = {multichannel: false, webAudio: false, auto: false}; + supportTable[sys.BROWSER_TYPE_CHROME] = {multichannel: true , webAudio: true , auto: false}; + supportTable[sys.BROWSER_TYPE_FIREFOX] = {multichannel: true , webAudio: true , auto: true }; + supportTable[sys.BROWSER_TYPE_BAIDU] = {multichannel: false, webAudio: false, auto: true }; + supportTable[sys.BROWSER_TYPE_UC] = {multichannel: true , webAudio: false, auto: true }; + supportTable[sys.BROWSER_TYPE_QQ] = {multichannel: false, webAudio: false, auto: true }; + supportTable[sys.BROWSER_TYPE_OUPENG] = {multichannel: false, webAudio: false, auto: false}; + supportTable[sys.BROWSER_TYPE_WECHAT] = {multichannel: false, webAudio: false, auto: false}; + supportTable[sys.BROWSER_TYPE_360] = {multichannel: false, webAudio: false, auto: true }; + supportTable[sys.BROWSER_TYPE_MIUI] = {multichannel: false, webAudio: false, auto: true }; + + // APPLE // + supportTable[sys.BROWSER_TYPE_SAFARI] = {multichannel: true , webAudio: true , auto: false}; + + /* Determine the browser version number */ + var version, tmp; + try{ + var ua = navigator.userAgent.toLowerCase(); + switch(sys.browserType){ + case sys.BROWSER_TYPE_IE: + tmp = ua.match(/(msie |rv:)([\d.]+)/); + break; + case sys.BROWSER_TYPE_FIREFOX: + tmp = ua.match(/(firefox\/|rv:)([\d.]+)/); + break; + case sys.BROWSER_TYPE_CHROME: + tmp = ua.match(/chrome\/([\d.]+)/); + break; + case sys.BROWSER_TYPE_BAIDU: + tmp = ua.match(/baidubrowser\/([\d.]+)/); + break; + case sys.BROWSER_TYPE_UC: + tmp = ua.match(/ucbrowser\/([\d.]+)/); + break; + case sys.BROWSER_TYPE_QQ: + tmp = ua.match(/qqbrowser\/([\d.]+)/); + break; + case sys.BROWSER_TYPE_OUPENG: + tmp = ua.match(/oupeng\/([\d.]+)/); + break; + case sys.BROWSER_TYPE_WECHAT: + tmp = ua.match(/micromessenger\/([\d.]+)/); + break; + case sys.BROWSER_TYPE_SAFARI: + tmp = ua.match(/safari\/([\d.]+)/); + break; + } + version = tmp ? tmp[1] : ""; + }catch(e){ + console.log(e); + } - src: null, - preload: null,//"none" or "metadata" or "auto" or "" (empty string) or empty TODO not used here - autoplay: null, //"autoplay" or "" (empty string) or empty - controls: null, //"controls" or "" (empty string) or empty TODO not used here - mediagroup: null, + /////////////////////////// + // Browser compatibility// + /////////////////////////// + if(version){ + switch(sys.browserType){ + case sys.BROWSER_TYPE_CHROME: + if(parseInt(version) < 30){ + supportTable[sys.BROWSER_TYPE_CHROME] = {multichannel: false , webAudio: true , auto: false}; + } + } + } - //The following IDL attributes and methods are exposed to dynamic scripts. - currentTime: 0, - startTime: 0, - duration: 0, // TODO not used here + if(cc.sys.isMobile){ + cc.__audioSuppor = supportTable[cc.sys.browserType] || supportTable["common"]; + }else{ + //Desktop support all + cc.__audioSuppor = supportTable["common"]; + } - _loop: null, //"loop" or "" (empty string) or empty - _volume: 1, + if(DEBUG){ + setTimeout(function(){ + cc.log("browse type: " + sys.browserType); + cc.log("browse version: " + version); + cc.log("multichannel: " + cc.__audioSuppor.multichannel); + cc.log("webAudio: " + cc.__audioSuppor.webAudio); + cc.log("auto: " + cc.__audioSuppor.auto); + }, 0); + } - _pauseTime: 0, - _paused: false, - _stopped: true, +})(); - _loadState: -1,//-1 : not loaded, 0 : waiting, 1 : loaded, -2 : load failed +/** + * Encapsulate DOM and webAudio + */ +cc.Audio = cc.Class.extend({ + //TODO Maybe loader shift in will be better + volume: 1, + loop: false, + _touch: false, + + _playing: false, + _AUDIO_TYPE: "AUDIO", + _pause: false, + _src: null, + + //Web Audio + _buffer: null, + _currentSource: null, + _startTime: null, + _currentTime: null, + _context: null, + _volume: null, + + //DOM Audio + _element: null, + + ctor: function(context, volume, url){ + context && (this._context = context); + volume && (this._volume = volume); + if(context && volume){ + this._AUDIO_TYPE = "WEBAUDIO"; + } + this.src = url; + }, - /** - * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. - * @param src - */ - ctor: function (src) { - var self = this; - self._events = {}; - self.src = src; + _setBufferCallback: null, + setBuffer: function(buffer){ + this._AUDIO_TYPE = "WEBAUDIO"; + this._buffer = buffer; + if(this._playing) + this.play(); - if (_ctx["createGain"]) - self._volumeNode = _ctx["createGain"](); - else - self._volumeNode = _ctx["createGainNode"](); + this._volume["gain"].value = this.volume; + this._setBufferCallback && this._setBufferCallback(buffer); + }, - self._onSuccess1 = self._onSuccess.bind(this); - self._onError1 = self._onError.bind(this); - }, + _setElementCallback: null, + setElement: function(element){ + this._AUDIO_TYPE = "AUDIO"; + this._element = element; + if(this._playing) + this.play(); - _play: function (offset) { - var self = this; - var sourceNode = self._sourceNode = _ctx["createBufferSource"](); - var volumeNode = self._volumeNode; - offset = offset || 0; - - sourceNode.buffer = self._buffer; - volumeNode["gain"].value = self._volume; - sourceNode["connect"](volumeNode); - volumeNode["connect"](_ctx["destination"]); - sourceNode.loop = self._loop; - sourceNode._stopped = false; - - if(!sourceNode["playbackState"]){ - sourceNode["onended"] = function(){ - this._stopped = true; - }; - } + element.volume = this.volume; + element.loop = this.loop; + this._setElementCallback && this._setElementCallback(element); + }, - self._paused = false; - self._stopped = false; - - /* - * Safari on iOS 6 only supports noteOn(), noteGrainOn(), and noteOff() now.(iOS 6.1.3) - * The latest version of chrome has supported start() and stop() - * start() & stop() are specified in the latest specification (written on 04/26/2013) - * Reference: https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html - * noteOn(), noteGrainOn(), and noteOff() are specified in Draft 13 version (03/13/2012) - * Reference: http://www.w3.org/2011/audio/drafts/2WD/Overview.html - */ - if (sourceNode.start) { - // starting from offset means resuming from where it paused last time - sourceNode.start(0, offset); - } else if (sourceNode["noteGrainOn"]) { - var duration = sourceNode.buffer.duration; - if (self.loop) { - /* - * On Safari on iOS 6, if loop == true, the passed in @param duration will be the duration from now on. - * In other words, the sound will keep playing the rest of the music all the time. - * On latest chrome desktop version, the passed in duration will only be the duration in this cycle. - * Now that latest chrome would have start() method, it is prepared for iOS here. - */ - sourceNode["noteGrainOn"](0, offset, duration); - } else { - sourceNode["noteGrainOn"](0, offset, duration - offset); - } - } else { - // if only noteOn() is supported, resuming sound will NOT work - sourceNode["noteOn"](0); - } - self._pauseTime = 0; - }, + play: function(offset, loop){ + this._playing = true; + this.loop = loop === undefined ? this.loop : (loop || false); + if(this._AUDIO_TYPE === "AUDIO"){ + this._playOfAudio(offset); + }else{ + this._playOfWebAudio(offset); + } + }, - _stop: function () { - var self = this, sourceNode = self._sourceNode; - if (self._stopped) - return; - if (sourceNode.stop) - sourceNode.stop(0); + getPlaying: function(){ + if(!this._playing){ + return this._playing; + } + if(this._AUDIO_TYPE === "AUDIO"){ + var audio = this._element; + if(!audio || this._pause){ + this._playing = false; + return false; + }else if(audio.ended){ + this._playing = false; + return false; + }else + return true; + }else{ + var sourceNode = this._currentSource; + if(!this._playing && !sourceNode) + return true; + if(sourceNode["playbackState"] == null) + return this._playing; else - sourceNode.noteOff(0); - self._stopped = true; - }, + return sourceNode["playbackState"] == 3; + } + }, - /** - * Play the audio. - */ - play: function () { - var self = this; - if (self._loadState == -1) { - self._loadState = 0; - return; - } else if (self._loadState != 1) + _playOfWebAudio: function(offset){ + var cs = this._currentSource; + if(!this._buffer){ + return; + } + if(!this._pause && cs){ + if(this._currentTime + this._context.currentTime - this._startTime < this._currentSource.buffer.duration < 0) return; - - var sourceNode = self._sourceNode; - if (!self._stopped && sourceNode && (sourceNode["playbackState"] == 2 || !sourceNode._stopped)) - return;//playing - - self.startTime = _ctx.currentTime; - this._play(0); - }, - - /** - * Pause the audio. - */ - pause: function () { - this._pauseTime = _ctx.currentTime; - this._paused = true; - this._stop(); - }, - - /** - * Resume the pause audio. + else + this._stopOfWebAudio(); + } + var audio = this._context["createBufferSource"](); + audio.buffer = this._buffer; + audio["connect"](this._volume); + audio.loop = this.loop; + this._startTime = this._context.currentTime; + this._currentTime = 0; + + /* + * Safari on iOS 6 only supports noteOn(), noteGrainOn(), and noteOff() now.(iOS 6.1.3) + * The latest version of chrome has supported start() and stop() + * start() & stop() are specified in the latest specification (written on 04/26/2013) + * Reference: https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html + * noteOn(), noteGrainOn(), and noteOff() are specified in Draft 13 version (03/13/2012) + * Reference: http://www.w3.org/2011/audio/drafts/2WD/Overview.html */ - resume: function () { - var self = this; - if (self._paused) { - var offset = self._buffer ? (self._pauseTime - self.startTime) % self._buffer.duration : 0; - this._play(offset); + if(audio.start){ + audio.start(0, offset || 0); + }else if(audio["noteGrainOn"]){ + var duration = audio.buffer.duration; + if (this.loop) { + /* + * On Safari on iOS 6, if loop == true, the passed in @param duration will be the duration from now on. + * In other words, the sound will keep playing the rest of the music all the time. + * On latest chrome desktop version, the passed in duration will only be the duration in this cycle. + * Now that latest chrome would have start() method, it is prepared for iOS here. + */ + audio["noteGrainOn"](0, offset, duration); + } else { + audio["noteGrainOn"](0, offset, duration - offset); } - }, - - /** - * Stop the play audio. - */ - stop: function () { - this._pauseTime = 0; - this._paused = false; - this._stop(); - }, - - /** - * Load this audio. - */ - load: function () { - var self = this; - if (self._loadState == 1) - return; - self._loadState = -1;//not loaded - - self.played = false; - self.ended = true; - var request = new XMLHttpRequest(); - request.open("GET", self.src, true); - request.responseType = "arraybuffer"; - - // Our asynchronous callback - request.onload = function () { - _ctx["decodeAudioData"](request.response, self._onSuccess1, self._onError1); - }; - request.send(); - }, - - /** - * Bind event to the audio element. - * @param {String} eventName - * @param {Function} event - */ - addEventListener: function (eventName, event) { - this._events[eventName] = event.bind(this); - }, - - /** - * Remove event of audio element. - * @param {String} eventName - */ - removeEventListener: function (eventName) { - delete this._events[eventName]; - }, - - /** - * Checking webaudio support. - * @returns {Boolean} - */ - canplay: function () { - return cc.sys._supportWebAudio; - }, - - _onSuccess: function (buffer) { - var self = this; - self._buffer = buffer; - - var success = self._events["success"], canplaythrough = self._events["canplaythrough"]; - if (success) - success(); - if (canplaythrough) - canplaythrough(); - if (self._loadState == 0 || self.autoplay == "autoplay" || self.autoplay == true) - self._play(); - self._loadState = 1;//loaded - }, - - _onError: function () { - var error = this._events["error"]; - if (error) - error(); - this._loadState = -2;//load failed - }, - - /** - * to copy object with deep copy. - * - * @return {cc.WebAudio} - */ - cloneNode: function () { - var self = this, obj = new cc.WebAudio(self.src); - obj.volume = self.volume; - obj._loadState = self._loadState; - obj._buffer = self._buffer; - if (obj._loadState == 0 || obj._loadState == -1) - obj.load(); - return obj; + }else { + // if only noteOn() is supported, resuming sound will NOT work + audio["noteOn"](0); } - - }); - var _p = cc.WebAudio.prototype; - /** @expose */ - _p.loop; - cc.defineGetterSetter(_p, "loop", function () { - return this._loop; - }, function (loop) { - this._loop = loop; - if (this._sourceNode) - this._sourceNode.loop = loop; - }); - /** @expose */ - _p.volume; - cc.defineGetterSetter(_p, "volume", function () { - return this._volume; - }, function (volume) { - this._volume = volume; - this._volumeNode["gain"].value = volume; - }); - /** @expose */ - _p.paused; - cc.defineGetterSetter(_p, "paused", function () { - return this._paused; - }); - /** @expose */ - _p.ended; - cc.defineGetterSetter(_p, "ended", function () { - var sourceNode = this._sourceNode; - if(this._paused) - return false; - if(this._stopped && !sourceNode) - return true; - if(sourceNode["playbackState"] == null) - return sourceNode._stopped; - else - return sourceNode["playbackState"] == 3; - }); - /** @expose */ - _p.played; - cc.defineGetterSetter(_p, "played", function () { - var sourceNode = this._sourceNode; - return sourceNode && (sourceNode["playbackState"] == 2 || !sourceNode._stopped); - }); -} - -/** - * cc.audioEngine is the singleton object, it provide simple audio APIs. - * @class - * @name cc.audioEngine - */ -cc.AudioEngine = cc.Class.extend(/** @lends cc.audioEngine# */{ - _soundSupported: false, // if sound is not enabled, this engine's init() will return false - - _currMusic: null, - _currMusicPath: null, - _musicPlayState: 0, //0 : stopped, 1 : paused, 2 : playing - - _audioID: 0, - _effects: {}, //effects cache - _audioPool: {}, //audio pool for effects - _effectsVolume: 1, // the volume applied to all effects - _maxAudioInstance: 5,//max count of audios that has same url - - _effectPauseCb: null, - - _playings: [],//only store when window is hidden - - /** - * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. - */ - ctor: function () { + this._currentSource = audio; var self = this; - self._soundSupported = cc._audioLoader._supportedAudioTypes.length > 0; - if (self._effectPauseCb) - self._effectPauseCb = self._effectPauseCb.bind(self); + audio["onended"] = function(){ + self._playing = false; + }; }, - /** - * Indicates whether any background music can be played or not. - * @returns {boolean} true if the background music is playing, otherwise false - */ - willPlayMusic: function () { - return false; + _recklessPlay: function(offset){ + if(!this._buffer) return; + var audio = this._context["createBufferSource"](); + audio.buffer = this._buffer; + audio["connect"](this._volume); + audio.loop = this.loop; + audio.start(0, offset || 0); }, - /** - * The volume of the effects max value is 1.0,the min value is 0.0 . - * @return {Number} - * @example - * //example - * var effectVolume = cc.audioEngine.getEffectsVolume(); - */ - getEffectsVolume: function () { - return this._effectsVolume; + _playOfAudio: function(){ + var audio = this._element; + if(audio){ + audio.loop = this.loop; + audio.play(); + } }, - //music begin - /** - * Play music. - * @param {String} url The path of the music file without filename extension. - * @param {Boolean} loop Whether the music loop or not. - * @example - * //example - * cc.audioEngine.playMusic(path, false); - */ - playMusic: function (url, loop) { - var self = this; - if (!self._soundSupported) - return; - - var audio = self._currMusic; - if (audio) - this._stopAudio(audio); - if(cc.sys.isMobile && cc.sys.os == cc.sys.OS_IOS){ - audio = self._getAudioByUrl(url); - self._currMusic = audio.cloneNode(); - self._currMusicPath = url; + stop: function(){ + this._playing = false; + if(this._AUDIO_TYPE === "AUDIO"){ + this._stopOfAudio(); }else{ - if (url != self._currMusicPath) { - audio = self._getAudioByUrl(url); - self._currMusic = audio; - self._currMusicPath = url; - } + this._stopOfWebAudio(); } - if (!self._currMusic) - return; - self._currMusic.loop = loop || false; - self._playMusic(self._currMusic); }, - _getAudioByUrl: function (url) { - var locLoader = cc.loader, audio = locLoader.getRes(url); - if (!audio) { - locLoader.load(url); - audio = locLoader.getRes(url); + _stopOfWebAudio: function(){ + var audio = this._currentSource; + if(audio){ + audio.stop(0); + this._currentSource = null; } - return audio; }, - _playMusic: function (audio) { - if (!audio.ended) { - if (audio.stop) {//cc.WebAudio - audio.stop(); - } else { - audio.pause(); - if (audio.readyState > 2) - audio.currentTime = 0; - } + _stopOfAudio: function(){ + var audio = this._element; + if(audio){ + audio.pause(); + if (audio.duration && audio.duration != Infinity) + audio.currentTime = audio.duration; } - this._musicPlayState = 2; - audio.play(); }, - /** - * Stop playing music. - * @param {Boolean} [releaseData] If release the music data or not.As default value is false. - * @example - * //example - * cc.audioEngine.stopMusic(); - */ - stopMusic: function (releaseData) { - if (this._musicPlayState > 0) { - var audio = this._currMusic; - if (!audio) return; - if (!this._stopAudio(audio)) - return; - if (releaseData) - cc.loader.release(this._currMusicPath); - this._currMusic = null; - this._currMusicPath = null; - this._musicPlayState = 0; + pause: function(){ + this._playing = false; + this._pause = true; + if(this._AUDIO_TYPE === "AUDIO"){ + this._pauseOfAudio(); + }else{ + this._pauseOfWebAudio(); } }, - _stopAudio: function (audio) { - if (audio && !audio.ended) { - if (audio.stop) {//cc.WebAudio - audio.stop(); - } else { - audio.pause(); - if (audio.readyState > 2 && audio.duration && audio.duration != Infinity) - audio.currentTime = audio.duration; - } - return true; + _pauseOfWebAudio: function(){ + this._currentTime += this._context.currentTime - this._startTime; + var audio = this._currentSource; + if(audio){ + audio.stop(0); } - return false; }, - /** - * Pause playing music. - * @example - * //example - * cc.audioEngine.pauseMusic(); - */ - pauseMusic: function () { - if (this._musicPlayState == 2) { - this._currMusic.pause(); - this._musicPlayState = 1; + _pauseOfAudio: function(){ + var audio = this._element; + if(audio){ + audio.pause(); } }, - /** - * Resume playing music. - * @example - * //example - * cc.audioEngine.resumeMusic(); - */ - resumeMusic: function () { - if (this._musicPlayState == 1) { - var audio = this._currMusic; - this._resumeAudio(audio); - this._musicPlayState = 2; + resume: function(){ + if(this._pause){ + if(this._AUDIO_TYPE === "AUDIO"){ + this._resumeOfAudio(); + }else{ + this._resumeOfWebAudio(); + } + this._pause = false; + this._playing = true; } }, - _resumeAudio: function (audio) { - if (audio && !audio.ended) { - if (audio.resume) - audio.resume();//cc.WebAudio - else - audio.play(); + _resumeOfWebAudio: function(){ + var audio = this._currentSource; + if(audio){ + this._startTime = this._context.currentTime; + var offset = this._currentTime % audio.buffer.duration; + this._playOfWebAudio(offset); } }, - /** - * Rewind playing music. - * @example - * //example - * cc.audioEngine.rewindMusic(); - */ - rewindMusic: function () { - if (this._currMusic) - this._playMusic(this._currMusic); - }, - - /** - * The volume of the music max value is 1.0,the min value is 0.0 . - * @return {Number} - * @example - * //example - * var volume = cc.audioEngine.getMusicVolume(); - */ - getMusicVolume: function () { - return this._musicPlayState == 0 ? 0 : this._currMusic.volume; + _resumeOfAudio: function(){ + var audio = this._element; + if(audio){ + audio.play(); + } }, - /** - * Set the volume of music. - * @param {Number} volume Volume must be in 0.0~1.0 . - * @example - * //example - * cc.audioEngine.setMusicVolume(0.5); - */ - setMusicVolume: function (volume) { - if (this._musicPlayState > 0) { - this._currMusic.volume = Math.min(Math.max(volume, 0), 1); + setVolume: function(volume){ + if(volume > 1) volume = 1; + if(volume < 0) volume = 0; + this.volume = volume; + if(this._AUDIO_TYPE === "AUDIO"){ + if(this._element){ + this._element.volume = volume; + } + }else{ + if(this._volume){ + this._volume["gain"].value = volume; + } } }, - /** - * Whether the music is playing. - * @return {Boolean} If is playing return true,or return false. - * @example - * //example - * if (cc.audioEngine.isMusicPlaying()) { - * cc.log("music is playing"); - * } - * else { - * cc.log("music is not playing"); - * } - */ - isMusicPlaying: function () { - return this._musicPlayState == 2 && this._currMusic && !this._currMusic.ended; - }, - //music end - - //effect begin - _getEffectList: function (url) { - var list = this._audioPool[url]; - if (!list) - list = this._audioPool[url] = []; - return list; + getVolume: function(){ + return this.volume; }, - _getEffect: function (url) { - var self = this, audio; - if (!self._soundSupported) return null; + cloneNode: function(){ + var audio, self; + if(this._AUDIO_TYPE === "AUDIO"){ + audio = new cc.Audio(); - var effList = this._getEffectList(url); - if(cc.sys.isMobile && cc.sys.os == cc.sys.OS_IOS){ - audio = this._getEffectAudio(effList, url); + var elem = document.createElement("audio"); + elem.src = this.src; + audio.setElement(elem); }else{ - for (var i = 0, li = effList.length; i < li; i++) { - var eff = effList[i]; - if (eff.ended) { - audio = eff; - if (audio.readyState > 2) - audio.currentTime = 0; - if (window.chrome) - audio.load(); - break; - } - } - if (!audio) { - audio = this._getEffectAudio(effList, url); - audio && effList.push(audio); + var volume = this._context["createGain"](); + volume["gain"].value = 1; + volume["connect"](this._context["destination"]); + audio = new cc.Audio(this._context, volume, this.src); + if(this._buffer){ + audio.setBuffer(this._buffer); + }else{ + self = this; + this._setBufferCallback = function(buffer){ + audio.setBuffer(buffer); + self._setBufferCallback = null; + }; } } + audio._AUDIO_TYPE = this._AUDIO_TYPE; return audio; - }, + } - _getEffectAudio: function(effList, url){ - var audio; - if (effList.length >= this._maxAudioInstance) { - cc.log("Error: " + url + " greater than " + this._maxAudioInstance); - return null; +}); + +(function(polyfill){ + + var SWA = polyfill.webAudio, + SWB = polyfill.multichannel, + SWC = polyfill.auto; + + var support = []; + + (function(){ + var audio = document.createElement("audio"); + if(audio.canPlayType) { + var ogg = audio.canPlayType('audio/ogg; codecs="vorbis"'); + if (ogg && ogg !== "") support.push(".ogg"); + var mp3 = audio.canPlayType("audio/mpeg"); + if (mp3 && mp3 !== "") support.push(".mp3"); + var wav = audio.canPlayType('audio/wav; codecs="1"'); + if (wav && wav !== "") support.push(".wav"); + var mp4 = audio.canPlayType("audio/mp4"); + if (mp4 && mp4 !== "") support.push(".mp4"); + var m4a = audio.canPlayType("audio/x-m4a"); + if (m4a && m4a !== "") support.push(".m4a"); } - audio = this._getAudioByUrl(url); - if (!audio) - return null; - audio = audio.cloneNode(true); - if (this._effectPauseCb) - cc._addEventListener(audio, "pause", this._effectPauseCb); - audio.volume = this._effectsVolume; - return audio; - }, + })(); - /** - * Play sound effect. - * @param {String} url The path of the sound effect with filename extension. - * @param {Boolean} loop Whether to loop the effect playing, default value is false - * @return {Number|null} the audio id - * @example - * //example - * var soundId = cc.audioEngine.playEffect(path); - */ - playEffect: function (url, loop) { - var audio = this._getEffect(url); - if (!audio) return null; - audio.loop = loop || false; - audio.play(); - var audioId = this._audioID++; - this._effects[audioId] = audio; - return audioId; - }, + if(SWA){ + var context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); + } - /** - * Set the volume of sound effects. - * @param {Number} volume Volume must be in 0.0~1.0 . - * @example - * //example - * cc.audioEngine.setEffectsVolume(0.5); - */ - setEffectsVolume: function (volume) { - volume = this._effectsVolume = Math.min(Math.max(volume, 0), 1); - var effects = this._effects; - for (var key in effects) { - effects[key].volume = volume; - } - }, + var loader = { - /** - * Pause playing sound effect. - * @param {Number} audioID The return value of function playEffect. - * @example - * //example - * cc.audioEngine.pauseEffect(audioID); - */ - pauseEffect: function (audioID) { - var audio = this._effects[audioID]; - if (audio && !audio.ended) { - audio.pause(); - } - }, + cache: {}, - /** - * Pause all playing sound effect. - * @example - * //example - * cc.audioEngine.pauseAllEffects(); - */ - pauseAllEffects: function () { - var effects = this._effects; - for (var key in effects) { - var eff = effects[key]; - if (!eff.ended) eff.pause(); - } - }, + load: function(realUrl, url, res, cb){ - /** - * Resume playing sound effect. - * @param {Number} effectId The return value of function playEffect. - * @audioID - * //example - * cc.audioEngine.resumeEffect(audioID); - */ - resumeEffect: function (effectId) { - this._resumeAudio(this._effects[effectId]) - }, + if(support.length === 0) + return cb("can not support audio!"); - /** - * Resume all playing sound effect - * @example - * //example - * cc.audioEngine.resumeAllEffects(); - */ - resumeAllEffects: function () { - var effects = this._effects; - for (var key in effects) { - this._resumeAudio(effects[key]); - } - }, + var i; - /** - * Stop playing sound effect. - * @param {Number} effectId The return value of function playEffect. - * @example - * //example - * cc.audioEngine.stopEffect(audioID); - */ - stopEffect: function (effectId) { - this._stopAudio(this._effects[effectId]); - delete this._effects[effectId]; - }, + var extname = cc.path.extname(realUrl); - /** - * Stop all playing sound effects. - * @example - * //example - * cc.audioEngine.stopAllEffects(); - */ - stopAllEffects: function () { - var effects = this._effects; - for (var key in effects) { - this._stopAudio(effects[key]); - delete effects[key]; - } - }, + var typeList = [extname]; + for(i=0; i if the background music is playing, otherwise false + */ + willPlayMusic: function(){return false;}, -if (!cc.sys._supportWebAudio && !cc.sys._supportMultipleAudio) { - cc.AudioEngineForSingle = cc.AudioEngine.extend({ - _waitingEffIds: [], - _pausedEffIds: [], - _currEffect: null, - _maxAudioInstance: 2, - _effectCache4Single: {},//{url:audio}, - _needToResumeMusic: false, - _expendTime4Music: 0, - - _isHiddenMode: false, - - _playMusic: function (audio) { - this._stopAllEffects(); - this._super(audio); + /** + * Play music. + * @param {String} url The path of the music file without filename extension. + * @param {Boolean} loop Whether the music loop or not. + * @example + * //example + * cc.audioEngine.playMusic(path, false); + */ + playMusic: function(url, loop){ + if(this._currMusic && this._currMusic._src !== url){ + this._currMusic.stop(); + } + var audio = loader.cache[url]; + if(!audio){ + cc.loader.load(url); + audio = loader.cache[url]; + } + audio.play(0, loop); + audio.setVolume(this._musicVolume); + this._currMusic = audio; }, - resumeMusic: function () { - var self = this; - if (self._musicPlayState == 1) { - self._stopAllEffects(); - self._needToResumeMusic = false; - self._expendTime4Music = 0; - self._super(); + /** + * Stop playing music. + * @param {Boolean} [releaseData] If release the music data or not.As default value is false. + * @example + * //example + * cc.audioEngine.stopMusic(); + */ + stopMusic: function(releaseData){ + var audio = this._currMusic; + if(audio){ + audio.stop(); + if (releaseData) + cc.loader.release(audio.src); } }, - playEffect: function (url, loop) { - var self = this, currEffect = self._currEffect; - var audio = loop ? self._getEffect(url) : self._getSingleEffect(url); - if (!audio) return null; - audio.loop = loop || false; - var audioId = self._audioID++; - self._effects[audioId] = audio; - - if (self.isMusicPlaying()) { - self.pauseMusic(); - self._needToResumeMusic = true; - } - if (currEffect) { - if (currEffect != audio) self._waitingEffIds.push(self._currEffectId); - self._waitingEffIds.push(audioId); - currEffect.pause(); - } else { - self._currEffect = audio; - self._currEffectId = audioId; + /** + * Pause playing music. + * @example + * //example + * cc.audioEngine.pauseMusic(); + */ + pauseMusic: function(){ + var audio = this._currMusic; + if(audio) + audio.pause(); + }, + + /** + * Resume playing music. + * @example + * //example + * cc.audioEngine.resumeMusic(); + */ + resumeMusic: function(){ + var audio = this._currMusic; + if(audio) + audio.resume(); + }, + + /** + * Rewind playing music. + * @example + * //example + * cc.audioEngine.rewindMusic(); + */ + rewindMusic: function(){ + var audio = this._currMusic; + if(audio){ + audio.stop(); audio.play(); } - return audioId; }, - pauseEffect: function (effectId) { - cc.log("pauseEffect not supported in single audio mode!"); + /** + * The volume of the music max value is 1.0,the min value is 0.0 . + * @return {Number} + * @example + * //example + * var volume = cc.audioEngine.getMusicVolume(); + */ + getMusicVolume: function(){ + return this._musicVolume; }, - pauseAllEffects: function () { - var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds, currEffect = self._currEffect; - if (!currEffect) return; - for (var i = 0, li = waitings.length; i < li; i++) { - pauseds.push(waitings[i]); + /** + * Set the volume of music. + * @param {Number} volume Volume must be in 0.0~1.0 . + * @example + * //example + * cc.audioEngine.setMusicVolume(0.5); + */ + setMusicVolume: function(volume){ + this._musicVolume = volume; + var audio = this._currMusic; + if(audio){ + audio.setVolume(volume); } - waitings.length = 0;//clear - pauseds.push(self._currEffectId); - currEffect.pause(); }, - resumeEffect: function (effectId) { - cc.log("resumeEffect not supported in single audio mode!"); + /** + * Whether the music is playing. + * @return {Boolean} If is playing return true,or return false. + * @example + * //example + * if (cc.audioEngine.isMusicPlaying()) { + * cc.log("music is playing"); + * } + * else { + * cc.log("music is not playing"); + * } + */ + isMusicPlaying: function(){ + var audio = this._currMusic; + if(audio){ + return audio.getPlaying(); + }else{ + return false; + } }, - resumeAllEffects: function () { - var self = this, waitings = self._waitingEffIds, pauseds = self._pausedEffIds; - - if (self.isMusicPlaying()) {//if music is playing, pause it first - self.pauseMusic(); - self._needToResumeMusic = true; + _audioPool: {}, + _maxAudioInstance: SWA ? 20 : 5, + _effectVolume: 1, + /** + * Play sound effect. + * @param {String} url The path of the sound effect with filename extension. + * @param {Boolean} loop Whether to loop the effect playing, default value is false + * @return {Number|null} the audio id + * @example + * //example + * var soundId = cc.audioEngine.playEffect(path); + */ + playEffect: function(url, loop){ + //If the browser just support playing single audio + if(!SWB){ + //Must be forced to shut down + //Because playing multichannel audio will be stuck in chrome 28 (android) + return; + }else if(SWA){ + var audio = loader.cache[url]; + if(!audio){ + cc.loader.load(url); + audio = loader.cache[url]; + } + return audio._recklessPlay(); } - for (var i = 0, li = pauseds.length; i < li; i++) {//move pauseds to waitings - waitings.push(pauseds[i]); + var effectList = this._audioPool[url]; + if(!effectList){ + effectList = this._audioPool[url] = []; } - pauseds.length = 0;//clear - if (!self._currEffect && waitings.length >= 0) {//is none currEff, resume the newest effect in waitings - var effId = waitings.pop(); - var eff = self._effects[effId]; - if (eff) { - self._currEffectId = effId; - self._currEffect = eff; - self._resumeAudio(eff); + + var i; + + for(i=0; i= 0) { - waitings.splice(index, 1); - } else { - index = pauseds.indexOf(effectId); - if (index >= 0) pauseds.splice(index, 1); + if(effectList[i]){ + effectList[i].setVolume(this._effectVolume); + effectList[i].play(0, loop); + }else if(i > this._maxAudioInstance){ + cc.log("Error: %s greater than %d", url, this._maxAudioInstance); + }else{ + var audio = loader.cache[url]; + if(!audio){ + cc.loader.load(url); + audio = loader.cache[url]; } + audio = audio.cloneNode(); + audio.setVolume(this._effectVolume); + audio.play(); + effectList.push(audio); } + console.log(effectList.length) + + return audio; }, - stopAllEffects: function () { - var self = this; - self._stopAllEffects(); - if (!self._currEffect && self._needToResumeMusic) {//need to resume music - self._resumeAudio(self._currMusic); - self._musicPlayState = 2; - self._needToResumeMusic = false; - self._expendTime4Music = 0; - } + /** + * Set the volume of sound effects. + * @param {Number} volume Volume must be in 0.0~1.0 . + * @example + * //example + * cc.audioEngine.setEffectsVolume(0.5); + */ + setEffectsVolume: function(volume){ + this._effectVolume = volume; }, - unloadEffect: function (url) { - var self = this, locLoader = cc.loader, locEffects = self._effects, effCache = self._effectCache4Single, - effectList = self._getEffectList(url), currEffect = self._currEffect; - locLoader.release(url);//release the resource in cc.loader first. - if (effectList.length == 0 && !effCache[url]) return; - var realUrl = effectList.length > 0 ? effectList[0].src : effCache[url].src; - delete self._audioPool[url]; - delete effCache[url]; - for (var key in locEffects) { - if (locEffects[key].src == realUrl) { - delete locEffects[key]; - } - } - if (currEffect && currEffect.src == realUrl) self._stopAudio(currEffect);//need to stop currEff + /** + * The volume of the effects max value is 1.0,the min value is 0.0 . + * @return {Number} + * @example + * //example + * var effectVolume = cc.audioEngine.getEffectsVolume(); + */ + getEffectsVolume: function(){ + return this._effectVolume; }, - //When `loop == false`, one url one audio. - _getSingleEffect: function (url) { - var self = this, audio = self._effectCache4Single[url], locLoader = cc.loader, - waitings = self._waitingEffIds, pauseds = self._pausedEffIds, effects = self._effects; - if (audio) { - if (audio.readyState > 2) - audio.currentTime = 0; //reset current time - } else { - audio = self._getAudioByUrl(url); - if (!audio) return null; - audio = audio.cloneNode(true); - if (self._effectPauseCb) - cc._addEventListener(audio, "pause", self._effectPauseCb); - audio.volume = self._effectsVolume; - self._effectCache4Single[url] = audio; - } - for (var i = 0, li = waitings.length; i < li;) {//reset waitings - if (effects[waitings[i]] == audio) { - waitings.splice(i, 1); - } else - i++; - } - for (var i = 0, li = pauseds.length; i < li;) {//reset pauseds - if (effects[pauseds[i]] == audio) { - pauseds.splice(i, 1); - } else - i++; - } - audio._isToPlay = true;//custom flag - return audio; + /** + * Pause playing sound effect. + * @param {Number} cc.Audio The return value of function playEffect. + * @example + * //example + * cc.audioEngine.pauseEffect(audioID); + */ + pauseEffect: function(audio){ + audio.pause(); }, - _stopAllEffects: function () { - var self = this, currEffect = self._currEffect, audioPool = self._audioPool, sglCache = self._effectCache4Single, - waitings = self._waitingEffIds, pauseds = self._pausedEffIds; - if (!currEffect && waitings.length == 0 && pauseds.length == 0) - return; - for (var key in sglCache) { - var eff = sglCache[key]; - if (eff.readyState > 2 && eff.duration && eff.duration != Infinity) - eff.currentTime = eff.duration; - } - waitings.length = 0; - pauseds.length = 0; - for (var key in audioPool) {//reset audios in pool to be ended - var list = audioPool[key]; - for (var i = 0, li = list.length; i < li; i++) { - var eff = list[i]; - eff.loop = false; - if (eff.readyState > 2 && eff.duration && eff.duration != Infinity) - eff.currentTime = eff.duration; + /** + * Pause all playing sound effect. + * @example + * //example + * cc.audioEngine.pauseAllEffects(); + */ + pauseAllEffects: function(){ + var ap = this._audioPool; + for(var p in ap){ + var list = ap[p]; + for(var i=0; i 2 && currMusic.duration && currMusic.duration != Infinity) {//calculate current time - var temp = currMusic.currentTime + self._expendTime4Music; - temp = temp - currMusic.duration * ((temp / currMusic.duration) | 0); - currMusic.currentTime = temp; + /** + * Resume playing sound effect. + * @param {Number} cc.Audio The return value of function playEffect. + * @audioID + * //example + * cc.audioEngine.resumeEffect(audioID); + */ + resumeEffect: function(audio){ + audio.resume(); + }, + + /** + * Resume all playing sound effect + * @example + * //example + * cc.audioEngine.resumeAllEffects(); + */ + resumeAllEffects: function(){ + var ap = this._audioPool; + for(var p in ap){ + var list = ap[p]; + for(var i=0; i 2 && eff.duration && eff.duration != Infinity) { - var temp = eff.currentTime + expendTime; - temp = temp - eff.duration * ((temp / eff.duration) | 0); - eff.currentTime = temp; - } - eff._isToPlay = false; - return eff; - } else { - if (eff.readyState > 2 && eff.duration && eff.duration != Infinity) - eff.currentTime = eff.duration; + /** + * Stop all playing sound effects. + * @example + * //example + * cc.audioEngine.stopAllEffects(); + */ + stopAllEffects: function(){ + var ap = this._audioPool; + for(var p in ap){ + var list = ap[p]; + for(var i=0; i 0) { - self._resumeAudio(playings[0]); - playings.length = 0; - } - } - }); -} - -cc._audioLoader = { - _supportedAudioTypes: null, - - // Get audio default path. - getBasePath: function () { - return cc.loader.audioPath; - }, + /** + * End music and effects. + */ + end: function(){ + this.stopMusic(); + this.stopAllEffects(); + }, - // pre-load the audio.
    - // note: If the preload audio type doesn't be supported on current platform, loader will use other audio format to try, but its key is still the origin audio format.
    - // for example: a.mp3 doesn't be supported on some browser, loader will load a.ogg, if a.ogg loads success, user still uses a.mp3 to play audio. - _load: function (realUrl, url, res, count, tryArr, audio, cb) { - var self = this, locLoader = cc.loader, path = cc.path; - var types = this._supportedAudioTypes; - var extname = ""; - if (types.length == 0) - return cb("can not support audio!"); - if (count == -1) { - extname = (path.extname(realUrl) || "").toLowerCase(); - if (!self.audioTypeSupported(extname)) { - extname = types[0]; - count = 0; + _pauseCache: [], + _pausePlaying: function(){ + if(this._currMusic.getPlaying()){ + this._currMusic.pause(); + this._pauseCache.push(this._currMusic); } - } else if (count < types.length) { - extname = types[count]; - } else { - return cb("can not found the resource of audio! Last match url is : " + realUrl); - } - if (tryArr.indexOf(extname) >= 0) - return self._load(realUrl, url, res, count + 1, tryArr, audio, cb); - realUrl = path.changeExtname(realUrl, extname); - tryArr.push(extname); - var delFlag = (count == types.length -1); - audio = self._loadAudio(realUrl, audio, function (err) { - if (err) - return self._load(realUrl, url, res, count + 1, tryArr, audio, cb);//can not found - cb(null, audio); - }, delFlag); - locLoader.cache[url] = audio; - }, - - //Check whether to support this type of file - audioTypeSupported: function (type) { - if (!type) return false; - return this._supportedAudioTypes.indexOf(type.toLowerCase()) >= 0; - }, - - _loadAudio: function (url, audio, cb, delFlag) { - var _Audio; - if (!cc.isObject(window["cc"]) && cc.sys.browserType == "firefox") - _Audio = Audio; //The WebAudio of FireFox doesn't work after google closure compiler compiled with advanced mode - else - _Audio = (location.origin == "file://") ? Audio : (cc.WebAudio || Audio); - if (arguments.length == 2) { - cb = audio; - audio = new _Audio(); - } else if ((arguments.length > 3 ) && !audio) { - audio = new _Audio(); - } - audio.src = url; - audio.preload = "auto"; - - var ua = navigator.userAgent; - if (/Mobile/.test(ua) && (/iPhone OS/.test(ua) || /iPad/.test(ua) || /Firefox/.test(ua)) || /MSIE/.test(ua)) { - audio.load(); - cb(null, audio); - } else { - var canplaythrough = "canplaythrough", error = "error"; - cc._addEventListener(audio, canplaythrough, function () { - cb(null, audio); - this.removeEventListener(canplaythrough, arguments.callee, false); - this.removeEventListener(error, arguments.callee, false); - }, false); - - var audioCB = function () { - audio.removeEventListener("emptied", audioCB); - audio.removeEventListener(error, audioCB); - cb("load " + url + " failed"); - if(delFlag){ - this.removeEventListener(canplaythrough, arguments.callee, false); - this.removeEventListener(error, arguments.callee, false); + var ap = this._audioPool; + for(var p in ap){ + var list = ap[p]; + for(var i=0; i tag is supported, go on - var _check = function (typeStr) { - var result = au.canPlayType(typeStr); - return result != "no" && result != ""; }; - if (_check('audio/ogg; codecs="vorbis"')) arr.push(".ogg"); - if (_check("audio/mpeg")) arr.push(".mp3"); - if (_check('audio/wav; codecs="1"')) arr.push(".wav"); - if (_check("audio/mp4")) arr.push(".mp4"); - if (_check("audio/x-m4a") || _check("audio/aac")) arr.push(".m4a"); + + setTimeout(function(){ + if(cc._canvas){ + cc._canvas.addEventListener("touchstart", reBGM, false); + } + }, 0); } - return arr; -}(); -cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader); + cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function () { + cc.audioEngine._pausePlaying(); + }); + cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function () { + cc.audioEngine._resumePlaying(); + }); -// Initialize Audio engine singleton -cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngineForSingle() : new cc.AudioEngine(); -cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function () { - cc.audioEngine._pausePlaying(); -}); -cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function () { - cc.audioEngine._resumePlaying(); -}); + +})(cc.__audioSuppor); \ No newline at end of file From 27c11a8068b6e99ecefa884bac5e9a95947792d7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 17 Nov 2014 17:54:10 +0800 Subject: [PATCH 0916/1564] Modify name --- cocos2d/core/platform/CCEGLView.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 8def766fee..f51b6d5941 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -39,13 +39,13 @@ cc.__BrowserGetter = { init: function(){ this.html = document.getElementsByTagName("html")[0]; }, - avaWidth: function(frame){ + availWidth: function(frame){ if(!frame || frame === this.html) return window.innerWidth; else return frame.clientWidth; }, - avaHeight: function(frame){ + availHeight: function(frame){ if(!frame || frame === this.html) return window.innerHeight; else @@ -66,10 +66,10 @@ switch(cc.sys.browserType){ return cc.view._targetDensityDPI; }); case cc.sys.BROWSER_TYPE_UC: - cc.__BrowserGetter.avaWidth = function(frame){ + cc.__BrowserGetter.availWidth = function(frame){ return frame.clientWidth; }; - cc.__BrowserGetter.avaHeight = function(frame){ + cc.__BrowserGetter.availHeight = function(frame){ return frame.clientHeight; }; break; @@ -262,8 +262,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _initFrameSize: function () { var locFrameSize = this._frameSize; - locFrameSize.width = cc.__BrowserGetter.avaWidth(this._frame); - locFrameSize.height = cc.__BrowserGetter.avaHeight(this._frame); + locFrameSize.width = cc.__BrowserGetter.availWidth(this._frame); + locFrameSize.height = cc.__BrowserGetter.availHeight(this._frame); }, // hack From 1d14248c2e342a402082c476dc902e64833d0800 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 18 Nov 2014 11:04:01 +0800 Subject: [PATCH 0917/1564] Issue 2416: Refactor cc.LabelTTF's renderer --- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 2 +- cocos2d/core/labelttf/CCLabelTTF.js | 6 +----- cocos2d/core/labelttf/CCLabelTTFRenderCmd.js | 11 ++++++++++- cocos2d/core/sprites/CCSpriteRenderCmd.js | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index 3d299a9b02..642151bb61 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty:16, orderDirty:32}; +cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty:16, orderDirty:32, textDirty:64}; //-------------------------Base ------------------------- cc.Node.RenderCmd = function(renderable){ diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 43e7d462e0..e491f89c79 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -73,6 +73,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _originalText: null, _isMultiLine: false, _fontStyleStr: null, //TODO move to render cmd + _fontClientHeight: 18, // font shadow _shadowEnabled: false, @@ -536,7 +537,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ var texDef = new cc.FontDefinition(); if (adjustForResolution) { - //texDef.fontSize = (cc._renderType === cc._RENDER_TYPE_CANVAS) ? this._fontSize : this._fontSize * cc.contentScaleFactor(); texDef.fontSize = this._fontSize; texDef.boundingWidth = cc.contentScaleFactor() * this._dimensions.width; texDef.boundingHeight = cc.contentScaleFactor() * this._dimensions.height; @@ -576,8 +576,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return texDef; }, - _fontClientHeight: 18, - /** * Changes the text content of the label * @warning Changing the string is as expensive as creating a new cc.LabelTTF. To obtain better performance use cc.LabelAtlas @@ -1008,7 +1006,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }); if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - var _p = cc.LabelTTF.prototype; _p.setColor = function (color3) { @@ -1052,7 +1049,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._setUpdateTextureDirty(); }; - //TODO: _p._updateDisplayedOpacityForCanvas _p.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity; _p.initWithStringAndTextDefinition = function (text, textDefinition) { diff --git a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js index d1224cc4ce..b311f2f243 100644 --- a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js @@ -22,6 +22,13 @@ THE SOFTWARE. ****************************************************************************/ +cc.LabelTTF.RenderCmd = function(){ + this._fontStyleStr = ""; + this._shadowColorStr = "rgba(128, 128, 128, 0.5)"; + this._strokeColorStr = ""; + this._fillColorStr = "rgba(255,255,255,1)"; +}; + cc.LabelTTF.CanvasRenderCmd = function(renderable){ cc.Sprite.CanvasRenderCmd.call(this, renderable); @@ -32,6 +39,7 @@ cc.LabelTTF.CanvasRenderCmd = function(renderable){ }; cc.LabelTTF.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); +cc.LabelTTF.CanvasRenderCmd.prototype.constructor = cc.LabelTTF.CanvasRenderCmd; // ----------------------------------- LabelTTF WebGL render cmd ---------------------------- @@ -40,5 +48,6 @@ cc.LabelTTF.WebGLRenderCmd = function(renderable){ }; -cc.LabelTFF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); +cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); +cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index 1d93b8e3d6..f31adbf628 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -570,6 +570,7 @@ cc.Sprite.WebGLRenderCmd = function(renderable){ }; cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd); +cc.Sprite.WebGLRenderCmd.prototype.constructor = cc.Sprite.WebGLRenderCmd; cc.Sprite.WebGLRenderCmd.prototype.updateBlendFunc = function(blendFunc){ //do nothing From 3f0cfcf0ca99db2c550e696bdd891593aa39c397 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 18 Nov 2014 11:51:30 +0800 Subject: [PATCH 0918/1564] Modify name --- cocos2d/audio/CCAudio.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 9ca6582d31..800a059995 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -109,19 +109,19 @@ } if(cc.sys.isMobile){ - cc.__audioSuppor = supportTable[cc.sys.browserType] || supportTable["common"]; + cc.__audioSupport = supportTable[cc.sys.browserType] || supportTable["common"]; }else{ //Desktop support all - cc.__audioSuppor = supportTable["common"]; + cc.__audioSupport = supportTable["common"]; } if(DEBUG){ setTimeout(function(){ cc.log("browse type: " + sys.browserType); cc.log("browse version: " + version); - cc.log("multichannel: " + cc.__audioSuppor.multichannel); - cc.log("webAudio: " + cc.__audioSuppor.webAudio); - cc.log("auto: " + cc.__audioSuppor.auto); + cc.log("multichannel: " + cc.__audioSupport.multichannel); + cc.log("webAudio: " + cc.__audioSupport.webAudio); + cc.log("auto: " + cc.__audioSupport.auto); }, 0); } @@ -925,4 +925,4 @@ cc.Audio = cc.Class.extend({ }); -})(cc.__audioSuppor); \ No newline at end of file +})(cc.__audioSupport); \ No newline at end of file From 1addae2794d96c7e945657d277ad78c34331bd94 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 18 Nov 2014 13:57:44 +0800 Subject: [PATCH 0919/1564] Fixed Play webAudio error --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 800a059995..0c3ed1b8e3 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -225,7 +225,7 @@ cc.Audio = cc.Class.extend({ return; } if(!this._pause && cs){ - if(this._currentTime + this._context.currentTime - this._startTime < this._currentSource.buffer.duration < 0) + if(this._currentTime + this._context.currentTime - this._startTime < this._currentSource.buffer.duration) return; else this._stopOfWebAudio(); From b420b188678f930f2f29ceed77387a5c5eb4f199 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 18 Nov 2014 17:09:20 +0800 Subject: [PATCH 0920/1564] Issue #2416: refactor cc.LabelTTF's renderer --- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 10 +- cocos2d/core/labelttf/CCLabelTTF.js | 344 ++----------------- cocos2d/core/labelttf/CCLabelTTFRenderCmd.js | 335 +++++++++++++++++- cocos2d/core/platform/CCClass.js | 5 + 4 files changed, 362 insertions(+), 332 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index 642151bb61..fdc92d2fce 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -263,11 +263,6 @@ cc.Node.CanvasRenderCmd.prototype.visit = function(parentCmd){ }; cc.Node.CanvasRenderCmd.prototype.updateStatus = function(){ - if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ - //update the transform - this.transform(null, true); - } - if(this._dirtyFlag & cc.Node._dirtyFlags.colorDirty){ //update the color this._updateDisplayColor() @@ -277,6 +272,11 @@ cc.Node.CanvasRenderCmd.prototype.updateStatus = function(){ //update the opacity this._updateDisplayOpacity(); } + + if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ + //update the transform + this.transform(null, true); + } }; cc.Node.CanvasRenderCmd.prototype._updateDisplayColor = function(parentColor){ diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 43415702ad..e9601e8e31 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -71,7 +71,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _fontSize: 0.0, _string: "", _originalText: null, - _isMultiLine: false, + _fontStyleStr: null, //TODO move to render cmd _fontClientHeight: 18, @@ -97,8 +97,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _strokeShadowOffsetY: 0, _needUpdateTexture: false, - _labelCanvas: null, - _labelContext: null, _lineWidths: null, _className: "LabelTTF", @@ -137,8 +135,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._fontStyleStr = this._fontSize + "px '" + fontName + "'"; this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, this._fontSize); this.string = strInfo; - this._setColorsString(); - this._updateTexture(); + this._renderCmd._setColorsString(); + this._renderCmd._updateTexture(); this._setUpdateTextureDirty(); return true; }, @@ -157,7 +155,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._opacityModifyRGB = false; this._fontStyleStr = ""; this._fontName = "Arial"; - this._isMultiLine = false; this._shadowEnabled = false; this._shadowOffset = cc.p(0, 0); @@ -178,7 +175,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._lineWidths = []; - this._setColorsString(); + this._renderCmd._setColorsString(); if (fontName && fontName instanceof cc.FontDefinition) { this.initWithStringAndTextDefinition(text, fontName); @@ -191,21 +188,12 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return this.initWithString(" ", this._fontName, this._fontSize); }, - _measureConfig: function () { - this._getLabelContext().font = this._fontStyleStr; - }, - _measure: function (text) { - return this._getLabelContext().measureText(text).width; - }, - description: function () { return ""; }, setColor: null, - _setColorsString: null, - updateDisplayedColor: null, setOpacity: null, @@ -214,7 +202,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ updateDisplayedOpacityForCanvas: function (parentOpacity) { cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); - this._setColorsString(); + this._renderCmd._setColorsString(); }, getLineHiehgt: function(){ @@ -333,7 +321,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowOpacity != shadowOpacity) { this._shadowOpacity = shadowOpacity; } - this._setColorsString(); + this._renderCmd._setColorsString(); if (this._shadowBlur != shadowBlur) this._shadowBlur = shadowBlur; @@ -341,7 +329,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, _enableShadow: function(shadowColor, offset, blurRadius){ - if(!this._shadowColor){ this._shadowColor = cc.color(255, 255, 255, 128); } @@ -407,7 +394,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (this._shadowOpacity != shadowOpacity) { this._shadowOpacity = shadowOpacity; - this._setColorsString(); + this._renderCmd._setColorsString(); this._setUpdateTextureDirty(); } }, @@ -449,7 +436,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ locStrokeColor.r = strokeColor.r; locStrokeColor.g = strokeColor.g; locStrokeColor.b = strokeColor.b; - this._setColorsString(); + this._renderCmd._setColorsString(); } if (this._strokeSize !== strokeSize) @@ -469,7 +456,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ locStrokeColor.r = strokeStyle.r; locStrokeColor.g = strokeStyle.g; locStrokeColor.b = strokeStyle.b; - this._setColorsString(); + this._renderCmd._setColorsString(); this._setUpdateTextureDirty(); } }, @@ -540,7 +527,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this.setFontFillColor(textDefinition.fillStyle); if (mustUpdateTexture) - this._updateTexture(); + this._renderCmd._updateTexture(); }, _prepareTextDefinition: function (adjustForResolution) { @@ -605,7 +592,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _updateString: function () { if ((!this._string || this._string === "") && this._string !== this._originalText) cc.renderer.childrenOrderDirty = true; - this._string = this._originalText; }, @@ -616,7 +602,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ setHorizontalAlignment: function (alignment) { if (alignment !== this._hAlignment) { this._hAlignment = alignment; - // Force update this._setUpdateTextureDirty(); } @@ -724,291 +709,33 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ } }, - _drawTTFInCanvas: function (context) { - if (!context) - return; - var locStrokeShadowOffsetX = this._strokeShadowOffsetX, locStrokeShadowOffsetY = this._strokeShadowOffsetY; - var locContentSizeHeight = this._contentSize.height - locStrokeShadowOffsetY, locVAlignment = this._vAlignment, locHAlignment = this._hAlignment, - locFontHeight = this._fontClientHeight, locStrokeSize = this._strokeSize; - - context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); - - //this is fillText for canvas - if (context.font != this._fontStyleStr) - context.font = this._fontStyleStr; - context.fillStyle = this._fillColorStr; - - var xOffset = 0, yOffset = 0; - //stroke style setup - var locStrokeEnabled = this._strokeEnabled; - if (locStrokeEnabled) { - context.lineWidth = locStrokeSize * 2; - context.strokeStyle = this._strokeColorStr; - } - - //shadow style setup - if (this._shadowEnabled) { - var locShadowOffset = this._shadowOffset; - context.shadowColor = this._shadowColorStr; - context.shadowOffsetX = locShadowOffset.x; - context.shadowOffsetY = -locShadowOffset.y; - context.shadowBlur = this._shadowBlur; - } - - context.textBaseline = cc.LabelTTF._textBaseline[locVAlignment]; - context.textAlign = cc.LabelTTF._textAlign[locHAlignment]; - - var locContentWidth = this._contentSize.width - locStrokeShadowOffsetX; - - //lineHiehgt - var lineHeight = this.getLineHiehgt(); - var transformTop = (lineHeight - this._fontClientHeight) / 2; - - if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) - xOffset += locContentWidth; - else if (locHAlignment === cc.TEXT_ALIGNMENT_CENTER) - xOffset += locContentWidth / 2; - else - xOffset += 0; - if (this._isMultiLine) { - var locStrLen = this._strings.length; - if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) - yOffset = lineHeight - transformTop * 2 + locContentSizeHeight - lineHeight * locStrLen; - else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_CENTER) - yOffset = (lineHeight - transformTop * 2) / 2 + (locContentSizeHeight - lineHeight * locStrLen) / 2; - - for (var i = 0; i < locStrLen; i++) { - var line = this._strings[i]; - var tmpOffsetY = -locContentSizeHeight + (lineHeight * i + transformTop) + yOffset; - if (locStrokeEnabled) - context.strokeText(line, xOffset, tmpOffsetY); - context.fillText(line, xOffset, tmpOffsetY); - } - } else { - if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) { - if (locStrokeEnabled) - context.strokeText(this._string, xOffset, yOffset); - context.fillText(this._string, xOffset, yOffset); - } else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_TOP) { - yOffset -= locContentSizeHeight; - if (locStrokeEnabled) - context.strokeText(this._string, xOffset, yOffset); - context.fillText(this._string, xOffset, yOffset); - } else { - yOffset -= locContentSizeHeight * 0.5; - if (locStrokeEnabled) - context.strokeText(this._string, xOffset, yOffset); - context.fillText(this._string, xOffset, yOffset); - } - } - }, - - _getLabelContext: function () { - if (this._labelContext) - return this._labelContext; - - if (!this._labelCanvas) { - var locCanvas = cc.newElement("canvas"); - var labelTexture = new cc.Texture2D(); - labelTexture.initWithElement(locCanvas); - this.texture = labelTexture; - this._labelCanvas = locCanvas; - } - this._labelContext = this._labelCanvas.getContext("2d"); - return this._labelContext; - }, - - _checkWarp: function(strArr, i, maxWidth){ - var text = strArr[i]; - var allWidth = this._measure(text); - if(allWidth > maxWidth && text.length > 1){ - - var fuzzyLen = text.length * ( maxWidth / allWidth ) | 0; - var tmpText = text.substr(fuzzyLen); - var width = allWidth - this._measure(tmpText); - var sLine; - var pushNum = 0; - - //Increased while cycle maximum ceiling. default 100 time - var checkWhile = 0; - - //Exceeded the size - while(width > maxWidth && checkWhile++ < 100){ - fuzzyLen *= maxWidth / width; - fuzzyLen = fuzzyLen | 0; - tmpText = text.substr(fuzzyLen); - width = allWidth - this._measure(tmpText); - } - - checkWhile = 0; - - //Find the truncation point - while(width < maxWidth && checkWhile++ < 100){ - - if(tmpText){ - var exec = cc.LabelTTF._wordRex.exec(tmpText); - pushNum = exec ? exec[0].length : 1; - sLine = tmpText; - } - - fuzzyLen = fuzzyLen + pushNum; - - tmpText = text.substr(fuzzyLen); - - width = allWidth - this._measure(tmpText); - } - - fuzzyLen -= pushNum; - if(fuzzyLen === 0){ - fuzzyLen = 1; - sLine = sLine.substr(1); - } - - var sText = text.substr(0, fuzzyLen); - - //symbol in the first - if(cc.LabelTTF.wrapInspection){ - if(cc.LabelTTF._symbolRex.test(sLine || tmpText)){ - var result = cc.LabelTTF._lastWordRex.exec(sText); - fuzzyLen -= result ? result[0].length : 0; - - sLine = text.substr(fuzzyLen); - sText = text.substr(0, fuzzyLen); - } - } - - //To judge whether a English words are truncated - if(cc.LabelTTF._firsrEnglish.test(sLine)){ - var result = cc.LabelTTF._lastEnglish.exec(sText); - if(result && sText !== result[0]){ - fuzzyLen -= result[0].length; - sLine = text.substr(fuzzyLen); - sText = text.substr(0, fuzzyLen); - } - } - - strArr[i] = sLine || tmpText; - strArr.splice(i, 0, sText); - } - }, - - _updateTTF: function () { - var locDimensionsWidth = this._dimensions.width, i, strLength; - var locLineWidth = this._lineWidths; - locLineWidth.length = 0; - - this._isMultiLine = false; - this._measureConfig(); - if (locDimensionsWidth !== 0) { - // Content processing - this._strings = this._string.split('\n'); - - for(i = 0; i < this._strings.length; i++){ - this._checkWarp(this._strings, i, locDimensionsWidth); - } - } else { - this._strings = this._string.split('\n'); - for (i = 0, strLength = this._strings.length; i < strLength; i++) { - locLineWidth.push(this._measure(this._strings[i])); - } - } - - if (this._strings.length > 0) - this._isMultiLine = true; - - var locSize, locStrokeShadowOffsetX = 0, locStrokeShadowOffsetY = 0; - if (this._strokeEnabled) - locStrokeShadowOffsetX = locStrokeShadowOffsetY = this._strokeSize * 2; - if (this._shadowEnabled) { - var locOffsetSize = this._shadowOffset; - locStrokeShadowOffsetX += Math.abs(locOffsetSize.x) * 2; - locStrokeShadowOffsetY += Math.abs(locOffsetSize.y) * 2; - } - - //get offset for stroke and shadow - if (locDimensionsWidth === 0) { - if (this._isMultiLine) - locSize = cc.size(0 | (Math.max.apply(Math, locLineWidth) + locStrokeShadowOffsetX), - 0 | ((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); - else - locSize = cc.size(0 | (this._measure(this._string) + locStrokeShadowOffsetX), 0 | (this._fontClientHeight + locStrokeShadowOffsetY)); - } else { - if (this._dimensions.height === 0) { - if (this._isMultiLine) - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((this.getLineHiehgt() * this._strings.length) + locStrokeShadowOffsetY)); - else - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this.getLineHiehgt() + locStrokeShadowOffsetY)); - } else { - //dimension is already set, contentSize must be same as dimension - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this._dimensions.height + locStrokeShadowOffsetY)); - } - } - this.setContentSize(locSize); - this._strokeShadowOffsetX = locStrokeShadowOffsetX; - this._strokeShadowOffsetY = locStrokeShadowOffsetY; - - // need computing _anchorPointInPoints - var locAP = this._anchorPoint; - this._anchorPointInPoints.x = (locStrokeShadowOffsetX * 0.5) + ((locSize.width - locStrokeShadowOffsetX) * locAP.x); - this._anchorPointInPoints.y = (locStrokeShadowOffsetY * 0.5) + ((locSize.height - locStrokeShadowOffsetY) * locAP.y); - }, - /** * Returns the actual content size of the label, the content size is the real size that the label occupied while dimension is the outer bounding box of the label. * @returns {cc.Size} The content size */ getContentSize: function () { if (this._needUpdateTexture) - this._updateTTF(); + this._renderCmd._updateTTF(); return cc.Sprite.prototype.getContentSize.call(this); }, _getWidth: function () { if (this._needUpdateTexture) - this._updateTTF(); + this._renderCmd._updateTTF(); return cc.Sprite.prototype._getWidth.call(this); }, _getHeight: function () { if (this._needUpdateTexture) - this._updateTTF(); + this._renderCmd._updateTTF(); return cc.Sprite.prototype._getHeight.call(this); }, - _updateTexture: function () { - var locContext = this._getLabelContext(), locLabelCanvas = this._labelCanvas; - var locContentSize = this._contentSize; - - if (this._string.length === 0) { - locLabelCanvas.width = 1; - locLabelCanvas.height = locContentSize.height || 1; - this._texture && this._texture.handleLoadedTexture(); - this.setTextureRect(cc.rect(0, 0, 1, locContentSize.height)); - return true; - } - - //set size for labelCanvas - locContext.font = this._fontStyleStr; - this._updateTTF(); - var width = locContentSize.width, height = locContentSize.height; - var flag = locLabelCanvas.width == width && locLabelCanvas.height == height; - locLabelCanvas.width = width; - locLabelCanvas.height = height; - if (flag) locContext.clearRect(0, 0, width, height); - - //draw text to labelCanvas - this._drawTTFInCanvas(locContext); - this._texture && this._texture.handleLoadedTexture(); - - this.setTextureRect(cc.rect(0, 0, width, height)); - return true; - }, - visit: function (ctx) { if (!this._string || this._string == "") return; if (this._needUpdateTexture) { this._needUpdateTexture = false; - this._updateTexture(); + this._renderCmd._updateTexture(); } var context = ctx || cc._renderContext; cc.Sprite.prototype.visit.call(this, context); @@ -1017,6 +744,13 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ setTextureRect: function (rect, rotated, untrimmedSize) { //set needConvert to false cc.Sprite.prototype.setTextureRect.call(this, rect, rotated, untrimmedSize, false); + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.LabelTTF.CanvasRenderCmd(this); + else + return new cc.LabelTTF.WebGLRenderCmd(this); } }); @@ -1025,47 +759,17 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _p.setColor = function (color3) { cc.Node.prototype.setColor.call(this, color3); - this._setColorsString(); + this._renderCmd._setColorsString(); }; _p._transformForRenderer = function(){ if (this._needUpdateTexture) { this._needUpdateTexture = false; - this._updateTexture(); + this._renderCmd._updateTexture(); } cc.Node.prototype._transformForRenderer.call(this); }; - _p._setColorsString = function () { - this._setUpdateTextureDirty(); - - var locDisplayColor = this._displayedColor, - locDisplayedOpacity = this._displayedOpacity, - locShadowColor = this._shadowColor || this._displayedColor; - var locStrokeColor = this._strokeColor, locFontFillColor = this._textFillColor; - - this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r * 0.5)) + "," + (0 | (locShadowColor.g * 0.5)) + "," + (0 | (locShadowColor.b * 0.5)) + "," + this._shadowOpacity + ")"; - this._fillColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locFontFillColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locFontFillColor.g)) + "," - + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; - this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," - + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; - }; - - _p.updateDisplayedColor = function (parentColor) { - cc.Node.prototype.updateDisplayedColor.call(this, parentColor); - this._setColorsString(); - }; - - _p.setOpacity = function (opacity) { - if (this._opacity === opacity) - return; - cc.Sprite.prototype.setOpacity.call(this, opacity); - this._setColorsString(); - this._setUpdateTextureDirty(); - }; - - _p.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity; - _p.initWithStringAndTextDefinition = function (text, textDefinition) { // prepare everything needed to render the label this._updateWithTextDefinition(textDefinition, false); @@ -1083,7 +787,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { locTextFillColor.g = tintColor.g; locTextFillColor.b = tintColor.b; - this._setColorsString(); + this._renderCmd._setColorsString(); this._setUpdateTextureDirty(); } }; diff --git a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js index b311f2f243..a623cd8b30 100644 --- a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js @@ -23,31 +23,352 @@ ****************************************************************************/ cc.LabelTTF.RenderCmd = function(){ + this._fontClientHeight = 18; this._fontStyleStr = ""; this._shadowColorStr = "rgba(128, 128, 128, 0.5)"; this._strokeColorStr = ""; this._fillColorStr = "rgba(255,255,255,1)"; + + this._labelCanvas = null; + this._labelContext = null; + this._lineWidths = []; + this._strings = []; + this._isMultiLine = false; +}; + +cc.LabelTTF.RenderCmd.prototype.constructor = cc.LabelTTF.RenderCmd; + +cc.LabelTTF.RenderCmd.prototype._getLabelContext = function () { + if (this._labelContext) + return this._labelContext; + + if (!this._labelCanvas) { + var locCanvas = cc.newElement("canvas"); + var labelTexture = new cc.Texture2D(); + labelTexture.initWithElement(locCanvas); + this.texture = labelTexture; + this._labelCanvas = locCanvas; + } + this._labelContext = this._labelCanvas.getContext("2d"); + return this._labelContext; +}; + +cc.LabelTTF.RenderCmd.prototype._updateTexture = function () { + var node = this._node; + var locContext = this._getLabelContext(), locLabelCanvas = this._labelCanvas; + var locContentSize = node._contentSize; + + if (node._string.length === 0) { + locLabelCanvas.width = 1; + locLabelCanvas.height = locContentSize.height || 1; + node._texture && node._texture.handleLoadedTexture(); + node.setTextureRect(cc.rect(0, 0, 1, locContentSize.height)); + return true; + } + + //set size for labelCanvas + locContext.font = node._fontStyleStr; + this._updateTTF(); + var width = locContentSize.width, height = locContentSize.height; + var flag = locLabelCanvas.width == width && locLabelCanvas.height == height; + locLabelCanvas.width = width; + locLabelCanvas.height = height; + if (flag) locContext.clearRect(0, 0, width, height); + + //draw text to labelCanvas + this._drawTTFInCanvas(locContext); + node._texture && node._texture.handleLoadedTexture(); + + node.setTextureRect(cc.rect(0, 0, width, height)); + return true; +}; + +cc.LabelTTF.RenderCmd.prototype._measureConfig = function(){ + this._getLabelContext().font = this._fontStyleStr; +}; + +cc.LabelTTF.RenderCmd.prototype._measure = function(text){ + return this._getLabelContext().measureText(text).width; +}; + +cc.LabelTTF.RenderCmd.prototype._updateTTF = function(){ + var node = this._node; + var locDimensionsWidth = node._dimensions.width, i, strLength; + var locLineWidth = this._lineWidths; + locLineWidth.length = 0; + + this._isMultiLine = false; + this._measureConfig(); + if (locDimensionsWidth !== 0) { + // Content processing + this._strings = node._string.split('\n'); + + for(i = 0; i < this._strings.length; i++){ + this._checkWarp(this._strings, i, locDimensionsWidth); + } + } else { + this._strings = node._string.split('\n'); + for (i = 0, strLength = this._strings.length; i < strLength; i++) { + locLineWidth.push(this._measure(this._strings[i])); + } + } + + if (this._strings.length > 0) + this._isMultiLine = true; + + var locSize, locStrokeShadowOffsetX = 0, locStrokeShadowOffsetY = 0; + if (node._strokeEnabled) + locStrokeShadowOffsetX = locStrokeShadowOffsetY = node._strokeSize * 2; + if (node._shadowEnabled) { + var locOffsetSize = node._shadowOffset; + locStrokeShadowOffsetX += Math.abs(locOffsetSize.x) * 2; + locStrokeShadowOffsetY += Math.abs(locOffsetSize.y) * 2; + } + + //get offset for stroke and shadow + if (locDimensionsWidth === 0) { + if (this._isMultiLine) + locSize = cc.size(0 | (Math.max.apply(Math, locLineWidth) + locStrokeShadowOffsetX), + 0 | ((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); + else + locSize = cc.size(0 | (this._measure(this._string) + locStrokeShadowOffsetX), 0 | (this._fontClientHeight + locStrokeShadowOffsetY)); + } else { + if (node._dimensions.height === 0) { + if (this._isMultiLine) + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((node.getLineHiehgt() * this._strings.length) + locStrokeShadowOffsetY)); + else + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node.getLineHiehgt() + locStrokeShadowOffsetY)); + } else { + //dimension is already set, contentSize must be same as dimension + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node._dimensions.height + locStrokeShadowOffsetY)); + } + } + node.setContentSize(locSize); + node._strokeShadowOffsetX = locStrokeShadowOffsetX; + node._strokeShadowOffsetY = locStrokeShadowOffsetY; + + // need computing _anchorPointInPoints + var locAP = node._anchorPoint; + this._anchorPointInPoints.x = (locStrokeShadowOffsetX * 0.5) + ((locSize.width - locStrokeShadowOffsetX) * locAP.x); + this._anchorPointInPoints.y = (locStrokeShadowOffsetY * 0.5) + ((locSize.height - locStrokeShadowOffsetY) * locAP.y); +}; + +cc.LabelTTF.RenderCmd.prototype._drawTTFInCanvas = function (context) { + if (!context) + return; + var node = this._node; + var locStrokeShadowOffsetX = node._strokeShadowOffsetX, locStrokeShadowOffsetY = node._strokeShadowOffsetY; + var locContentSizeHeight = node._contentSize.height - locStrokeShadowOffsetY, locVAlignment = node._vAlignment, locHAlignment = node._hAlignment, + locFontHeight = this._fontClientHeight, locStrokeSize = node._strokeSize; + + context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); + + //this is fillText for canvas + if (context.font != this._fontStyleStr) + context.font = this._fontStyleStr; + context.fillStyle = this._fillColorStr; + + var xOffset = 0, yOffset = 0; + //stroke style setup + var locStrokeEnabled = node._strokeEnabled; + if (locStrokeEnabled) { + context.lineWidth = locStrokeSize * 2; + context.strokeStyle = this._strokeColorStr; + } + + //shadow style setup + if (node._shadowEnabled) { + var locShadowOffset = node._shadowOffset; + context.shadowColor = this._shadowColorStr; + context.shadowOffsetX = locShadowOffset.x; + context.shadowOffsetY = -locShadowOffset.y; + context.shadowBlur = node._shadowBlur; + } + + context.textBaseline = cc.LabelTTF._textBaseline[locVAlignment]; + context.textAlign = cc.LabelTTF._textAlign[locHAlignment]; + + var locContentWidth = node._contentSize.width - locStrokeShadowOffsetX; + + //lineHiehgt + var lineHeight = node.getLineHiehgt(); + var transformTop = (lineHeight - this._fontClientHeight) / 2; + + if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) + xOffset += locContentWidth; + else if (locHAlignment === cc.TEXT_ALIGNMENT_CENTER) + xOffset += locContentWidth / 2; + else + xOffset += 0; + if (this._isMultiLine) { + var locStrLen = this._strings.length; + if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) + yOffset = lineHeight - transformTop * 2 + locContentSizeHeight - lineHeight * locStrLen; + else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_CENTER) + yOffset = (lineHeight - transformTop * 2) / 2 + (locContentSizeHeight - lineHeight * locStrLen) / 2; + + for (var i = 0; i < locStrLen; i++) { + var line = this._strings[i]; + var tmpOffsetY = -locContentSizeHeight + (lineHeight * i + transformTop) + yOffset; + if (locStrokeEnabled) + context.strokeText(line, xOffset, tmpOffsetY); + context.fillText(line, xOffset, tmpOffsetY); + } + } else { + if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) { + if (locStrokeEnabled) + context.strokeText(this._string, xOffset, yOffset); + context.fillText(this._string, xOffset, yOffset); + } else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_TOP) { + yOffset -= locContentSizeHeight; + if (locStrokeEnabled) + context.strokeText(this._string, xOffset, yOffset); + context.fillText(this._string, xOffset, yOffset); + } else { + yOffset -= locContentSizeHeight * 0.5; + if (locStrokeEnabled) + context.strokeText(this._string, xOffset, yOffset); + context.fillText(this._string, xOffset, yOffset); + } + } +}; + +cc.LabelTTF.RenderCmd.prototype._checkWarp = function(strArr, i, maxWidth){ + var text = strArr[i]; + var allWidth = this._measure(text); + if(allWidth > maxWidth && text.length > 1){ + + var fuzzyLen = text.length * ( maxWidth / allWidth ) | 0; + var tmpText = text.substr(fuzzyLen); + var width = allWidth - this._measure(tmpText); + var sLine; + var pushNum = 0; + + //Increased while cycle maximum ceiling. default 100 time + var checkWhile = 0; + + //Exceeded the size + while(width > maxWidth && checkWhile++ < 100){ + fuzzyLen *= maxWidth / width; + fuzzyLen = fuzzyLen | 0; + tmpText = text.substr(fuzzyLen); + width = allWidth - this._measure(tmpText); + } + + checkWhile = 0; + + //Find the truncation point + while(width < maxWidth && checkWhile++ < 100){ + if(tmpText){ + var exec = cc.LabelTTF._wordRex.exec(tmpText); + pushNum = exec ? exec[0].length : 1; + sLine = tmpText; + } + + fuzzyLen = fuzzyLen + pushNum; + + tmpText = text.substr(fuzzyLen); + + width = allWidth - this._measure(tmpText); + } + + fuzzyLen -= pushNum; + if(fuzzyLen === 0){ + fuzzyLen = 1; + sLine = sLine.substr(1); + } + + var sText = text.substr(0, fuzzyLen), result; + + //symbol in the first + if(cc.LabelTTF.wrapInspection){ + if(cc.LabelTTF._symbolRex.test(sLine || tmpText)){ + result = cc.LabelTTF._lastWordRex.exec(sText); + fuzzyLen -= result ? result[0].length : 0; + + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); + } + } + + //To judge whether a English words are truncated + if(cc.LabelTTF._firsrEnglish.test(sLine)){ + result = cc.LabelTTF._lastEnglish.exec(sText); + if(result && sText !== result[0]){ + fuzzyLen -= result[0].length; + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); + } + } + + strArr[i] = sLine || tmpText; + strArr.splice(i, 0, sText); + } }; +// ---------------------------------- LabelTTF Canvas render cmd -------------------------- cc.LabelTTF.CanvasRenderCmd = function(renderable){ cc.Sprite.CanvasRenderCmd.call(this, renderable); - - this._fontStyleStr = ""; - this._shadowColorStr = "rgba(128, 128, 128, 0.5)"; - this._strokeColorStr = ""; - this._fillColorStr = "rgba(255,255,255,1)"; + cc.LabelTTF.RenderCmd.call(this); }; cc.LabelTTF.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); cc.LabelTTF.CanvasRenderCmd.prototype.constructor = cc.LabelTTF.CanvasRenderCmd; +cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.CanvasRenderCmd.prototype); + +cc.LabelTTF.CanvasRenderCmd.prototype._updateDisplayedOpacity = function(parentOpacity){ + cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedOpacity.call(this, parentOpacity); + this._setColorsString(); +}; + +cc.LabelTTF.CanvasRenderCmd.prototype._updateDisplayedColor = function(parentColor){ + cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedColor.call(this, parentColor); + this._setColorsString(); +}; + +cc.LabelTTF.CanvasRenderCmd.prototype._setColorsString = function(){ + this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); + + var locDisplayColor = this._displayedColor, node = this._node, + locDisplayedOpacity = this._displayedOpacity, + locShadowColor = node._shadowColor || this._displayedColor; + var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; + + this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r * 0.5)) + "," + (0 | (locShadowColor.g * 0.5)) + "," + (0 | (locShadowColor.b * 0.5)) + "," + node._shadowOpacity + ")"; + this._fillColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locFontFillColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locFontFillColor.g)) + "," + + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; + this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," + + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; +}; + +cc.LabelTTF.CanvasRenderCmd.prototype.updateStatus = function(){ + if(this._dirtyFlag & cc.Node._dirtyFlags.colorDirty){ + //update the color + this._updateDisplayColor() + } + + if(this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty){ + //update the opacity + this._updateDisplayOpacity(); + } + + if(this._dirtyFlag & cc.Node._dirtyFlags.textDirty){ + //update texture for labelTTF + } + + if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ + //update the transform + this.transform(null, true); + } +}; // ----------------------------------- LabelTTF WebGL render cmd ---------------------------- cc.LabelTTF.WebGLRenderCmd = function(renderable){ cc.Sprite.WebGLRenderCmd.call(this, renderable); - + cc.LabelTTF.RenderCmd.call(this); }; cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; - +cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 01b6643042..cf187cad09 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -326,3 +326,8 @@ cc.clone = function (obj) { return newObj; }; +cc.inject = function(srcPrototype, destPrototype){ + for(var key in srcPrototype) + destPrototype[key] = srcPrototype[key]; +}; + From f70f7835c9483f22d677202b18251d5d4de57d42 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 18 Nov 2014 17:44:20 +0800 Subject: [PATCH 0921/1564] Layer renderCmd --- cocos2d/core/layers/CCLayer.js | 284 ++----- cocos2d/core/layers/CCLayerPropertyDefine.js | 52 -- cocos2d/core/layers/CCLayerRenderCmd.js | 803 +++++++++++++------ cocos2d/core/layers/CCLayerWebGL.js | 190 ----- cocos2d/core/sprites/CCSpriteRenderCmd.js | 4 +- moduleConfig.json | 2 - 6 files changed, 647 insertions(+), 688 deletions(-) delete mode 100644 cocos2d/core/layers/CCLayerPropertyDefine.js delete mode 100644 cocos2d/core/layers/CCLayerWebGL.js diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 7a48fca0e4..cee1243f39 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -86,7 +86,24 @@ cc.Layer = cc.Node.extend(/** @lends cc.Layer# */{ return this._isBaked; }, - visit: null + /** + * @function + */ + visit: function(){ + this._renderCmd.visit(); + }, + + addChild: function(child, localZOrder, tag){ + cc.Node.prototype.addChild.call(this, child, localZOrder, tag); + this._renderCmd._bakeForAddChild(child); + }, + + _createRenderCmd: function(){ + if (cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.Layer.CanvasRenderCmd(this); + else + return new cc.Layer.WebGLRenderCmd(this); + } }); /** @@ -99,43 +116,6 @@ cc.Layer.create = function () { return new cc.Layer(); }; -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - var p = cc.Layer.prototype; - p.addChild = function(child, localZOrder, tag){ - cc.Node.prototype.addChild.call(this, child, localZOrder, tag); - if(child._parent == this && this._isBaked) - child._setCachedParent(this); - }; - - p._getBoundingBoxForBake = function () { - var rect = null; - - //query child's BoundingBox - if (!this._children || this._children.length === 0) - return cc.rect(0, 0, 10, 10); - - var locChildren = this._children; - for (var i = 0; i < locChildren.length; i++) { - var child = locChildren[i]; - if (child && child._visible) { - if(rect){ - var childRect = child._getBoundingBoxToCurrentNode(); - if (childRect) - rect = cc.rectUnion(rect, childRect); - }else{ - rect = child._getBoundingBoxToCurrentNode(); - } - } - } - return rect; - }; - p = null; -}else{ - cc.assert(cc.isFunction(cc._tmp.LayerDefineForWebGL), cc._LogInfos.MissingFile, "CCLayerWebGL.js"); - cc._tmp.LayerDefineForWebGL(); - delete cc._tmp.LayerDefineForWebGL; -} - /** *

    * CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
    @@ -228,7 +208,11 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ * @param {Number} [width=] * @param {Number} [height=] */ - ctor: null, + ctor: function(color, width, height){ + cc.Layer.prototype.ctor.call(this); + this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); + cc.LayerColor.prototype.init.call(this, color, width, height); + }, /** * Initialization of the layer, please do not call this function by yourself, you should pass the parameters to constructor to initialize a layer @@ -277,11 +261,19 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ _t._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(locBlendFunc); }, - _setWidth: null, + _setWidth: function(width){ + this._renderCmd._updateSquareVerticesWidth(width); + cc.Node.prototype._setWidth.call(this, width); + }, - _setHeight: null, + _setHeight: function(height){ + this._renderCmd._updateSquareVerticesHeight(height); + cc.Node.prototype._setHeight.call(this, height); + }, - _updateColor: null, + _updateColor: function(){ + this._renderCmd._updateColor(); + }, updateDisplayedColor: function (parentColor) { cc.Layer.prototype.updateDisplayedColor.call(this, parentColor); @@ -300,7 +292,14 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ return new cc.LayerColor.WebGLRenderCmd(this); }, - draw: null + draw: function(){ + this._renderCmd.draw(); + }, + + setContentSize: function(size, height){ + this._renderCmd._updataSquareVertices(); + cc.Layer.prototype.setContentSize.call(this, size, height); + } }); /** @@ -316,139 +315,12 @@ cc.LayerColor.create = function (color, width, height) { return new cc.LayerColor(color, width, height); }; -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - //cc.LayerColor define start - var _p = cc.LayerColor.prototype; - _p.ctor = function (color, width, height) { - cc.Layer.prototype.ctor.call(this); - this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); - cc.LayerColor.prototype.init.call(this, color, width, height); - }; - _p._setWidth = function(width){ - cc.Node.prototype._setWidth.call(this, width); - }; - _p._setHeight = function(height){ - cc.Node.prototype._setHeight.call(this, height); - }; - _p._updateColor = function () { - var locCmd = this._renderCmd; - if(!locCmd || !locCmd._color) - return; - var locColor = this._displayedColor; - locCmd._color.r = locColor.r; - locCmd._color.g = locColor.g; - locCmd._color.b = locColor.b; - locCmd._color.a = this._displayedOpacity / 255; - }; - - _p._bakeRendering = function(){ - if(this._cacheDirty){ - var _t = this; - var locBakeSprite = _t._bakeSprite, children = this._children; - var len = children.length, i; - - //compute the bounding box of the bake layer. - var boundingBox = this._getBoundingBoxForBake(); - boundingBox.width = 0 | boundingBox.width; - boundingBox.height = 0 | boundingBox.height; - var bakeContext = locBakeSprite.getCacheContext(); - locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); - var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = this._position; - if(this._ignoreAnchorPointForPosition){ - bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); - //reset the bake sprite's position - locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); - } else { - var selfAnchor = this.getAnchorPointInPoints(); - var selfPos = {x: locPos.x - selfAnchor.x, y: locPos.y - selfAnchor.y}; - bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); - locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); - } - // invert - var t = cc.affineTransformInvert(this._transformWorld); - bakeContext.transform(t.a, t.c, t.b, t.d, t.tx, -t.ty); - - var child; - cc.renderer._turnToCacheMode(this.__instanceId); - //visit for canvas - if (len > 0) { - _t.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - child = children[i]; - if (child._localZOrder < 0) - child.visit(bakeContext); - else - break; - } - if(_t._renderCmd) - cc.renderer.pushRenderCommand(_t._renderCmd); - for (; i < len; i++) { - children[i].visit(bakeContext); - } - } else - if(_t._renderCmd) - cc.renderer.pushRenderCommand(_t._renderCmd); - cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); - locBakeSprite.transform(); - this._cacheDirty = false; - } - }; - - //for bake - _p.visit = function(ctx){ - if(!this._isBaked){ - cc.Node.prototype.visit.call(this, ctx); - return; - } - - var context = ctx || cc._renderContext; - var _t = this; - // quick return if not visible - if (!_t._visible) - return; - - _t.transform(context); - - if(_t._bakeRenderCmd) - cc.renderer.pushRenderCommand(_t._bakeRenderCmd); - - //the bakeSprite is drawing - this._bakeSprite.visit(context); - }; - - _p._getBoundingBoxForBake = function () { - //default size - var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var trans = this.getNodeToWorldTransform(); - rect = cc.rectApplyAffineTransform(rect, this.getNodeToWorldTransform()); - - //query child's BoundingBox - if (!this._children || this._children.length === 0) - return rect; - - var locChildren = this._children; - for (var i = 0; i < locChildren.length; i++) { - var child = locChildren[i]; - if (child && child._visible) { - var childRect = child._getBoundingBoxToCurrentNode(trans); - rect = cc.rectUnion(rect, childRect); - } - } - return rect; - }; - - //cc.LayerColor define end - _p = null; -} else { - cc.assert(cc.isFunction(cc._tmp.WebGLLayerColor), cc._LogInfos.MissingFile, "CCLayerWebGL.js"); - cc._tmp.WebGLLayerColor(); - delete cc._tmp.WebGLLayerColor; -} - -cc.assert(cc.isFunction(cc._tmp.PrototypeLayerColor), cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); -cc._tmp.PrototypeLayerColor(); -delete cc._tmp.PrototypeLayerColor; +//LayerColor - Getter Setter +(function(){ + var proto = cc.LayerColor.prototype; + cc.defineGetterSetter(proto, "width", proto._getWidth, proto._setWidth); + cc.defineGetterSetter(proto, "height", proto._getHeight, proto._setHeight); +})(); /** *

    @@ -674,9 +546,13 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ return new cc.LayerGradient.WebGLRenderCmd(this); }, - _draw: null, + _draw: function(){ + cc.LayerColor.prototype.draw.call(this); + }, - _updateColor: null + _updateColor: function(){ + this._renderCmd._updateColor(); + } }); /** @@ -691,38 +567,26 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ cc.LayerGradient.create = function (start, end, v) { return new cc.LayerGradient(start, end, v); }; - -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - //cc.LayerGradient define start - var _p = cc.LayerGradient.prototype; - _p._updateColor = function () { - var _t = this; - var locAlongVector = _t._alongVector, tWidth = _t.width * 0.5, tHeight = _t.height * 0.5; - - var locCmd = this._renderCmd; - locCmd._startPoint.x = tWidth * (-locAlongVector.x) + tWidth; - locCmd._startPoint.y = tHeight * locAlongVector.y - tHeight; - locCmd._endPoint.x = tWidth * locAlongVector.x + tWidth; - locCmd._endPoint.y = tHeight * (-locAlongVector.y) - tHeight; - - var locStartColor = this._displayedColor, locEndColor = this._endColor, opacity = this._displayedOpacity / 255; - var startOpacity = this._startOpacity, endOpacity = this._endOpacity; - locCmd._startStopStr = "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," - + Math.round(locStartColor.b) + "," + startOpacity.toFixed(4) + ")"; - locCmd._endStopStr = "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," - + Math.round(locEndColor.b) + "," + endOpacity.toFixed(4) + ")"; - }; - //cc.LayerGradient define end - _p = null; -} else { - cc.assert(cc.isFunction(cc._tmp.WebGLLayerGradient), cc._LogInfos.MissingFile, "CCLayerWebGL.js"); - cc._tmp.WebGLLayerGradient(); - delete cc._tmp.WebGLLayerGradient; -} - -cc.assert(cc.isFunction(cc._tmp.PrototypeLayerGradient), cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js"); -cc._tmp.PrototypeLayerGradient(); -delete cc._tmp.PrototypeLayerGradient; +//LayerGradient - Getter Setter +(function(){ + var proto = cc.LayerGradient.prototype; + // Extended properties + /** @expose */ + proto.startColor; + cc.defineGetterSetter(proto, "startColor", proto.getStartColor, proto.setStartColor); + /** @expose */ + proto.endColor; + cc.defineGetterSetter(proto, "endColor", proto.getEndColor, proto.setEndColor); + /** @expose */ + proto.startOpacity; + cc.defineGetterSetter(proto, "startOpacity", proto.getStartOpacity, proto.setStartOpacity); + /** @expose */ + proto.endOpacity; + cc.defineGetterSetter(proto, "endOpacity", proto.getEndOpacity, proto.setEndOpacity); + /** @expose */ + proto.vector; + cc.defineGetterSetter(proto, "vector", proto.getVector, proto.setVector); +})(); /** * CCMultipleLayer is a CCLayer with the ability to multiplex it's children.
    diff --git a/cocos2d/core/layers/CCLayerPropertyDefine.js b/cocos2d/core/layers/CCLayerPropertyDefine.js deleted file mode 100644 index 0600fa1dd6..0000000000 --- a/cocos2d/core/layers/CCLayerPropertyDefine.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -cc._tmp.PrototypeLayerColor = function () { - var _p = cc.LayerColor.prototype; - // Override properties - cc.defineGetterSetter(_p, "width", _p._getWidth, _p._setWidth); - cc.defineGetterSetter(_p, "height", _p._getHeight, _p._setHeight); -}; - -cc._tmp.PrototypeLayerGradient = function () { - var _p = cc.LayerGradient.prototype; - // Extended properties - /** @expose */ - _p.startColor; - cc.defineGetterSetter(_p, "startColor", _p.getStartColor, _p.setStartColor); - /** @expose */ - _p.endColor; - cc.defineGetterSetter(_p, "endColor", _p.getEndColor, _p.setEndColor); - /** @expose */ - _p.startOpacity; - cc.defineGetterSetter(_p, "startOpacity", _p.getStartOpacity, _p.setStartOpacity); - /** @expose */ - _p.endOpacity; - cc.defineGetterSetter(_p, "endOpacity", _p.getEndOpacity, _p.setEndOpacity); - /** @expose */ - _p.vector; - cc.defineGetterSetter(_p, "vector", _p.getVector, _p.setVector); -}; \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayerRenderCmd.js b/cocos2d/core/layers/CCLayerRenderCmd.js index d7f8a50fce..fbae2245d0 100644 --- a/cocos2d/core/layers/CCLayerRenderCmd.js +++ b/cocos2d/core/layers/CCLayerRenderCmd.js @@ -22,246 +22,585 @@ THE SOFTWARE. ****************************************************************************/ -//Layer's canvas render command -cc.Layer.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - this._isBaked = false; - this._bakeSprite = null; -}; - -cc.Layer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.Layer.CanvasRenderCmd.prototype.constructor = cc.Layer.CanvasRenderCmd; - -cc.Layer.CanvasRenderCmd.prototype.bake = function(){ - if (!this._isBaked) { +//-----------------------// +// 1. cc.Layer // +// 2. cc.LayerColor // +// 3. cc.LayerGradient // +//-----------------------// + +/** + * cc.Layer's rendering objects of Canvas + */ +(function(){ + + //Layer's canvas render command + cc.Layer.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._isBaked = false; + this._bakeSprite = null; + }; + + var proto = cc.Layer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.Layer.CanvasRenderCmd; + + proto.bake = function(){ + if (!this._isBaked) { + this._needDraw = true; + cc.renderer.childrenOrderDirty = true; + //limit: 1. its children's blendfunc are invalid. + this._isBaked = this._cacheDirty = true; + + this._cachedParent = this; + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._setCachedParent(this); + + if (!this._bakeSprite){ + this._bakeSprite = new cc.BakeSprite(); + this._bakeSprite._parent = this; + } + } + }; + + proto.unbake = function(){ + if (this._isBaked) { + cc.renderer.childrenOrderDirty = true; + this._isBaked = false; + this._cacheDirty = true; + + this._cachedParent = null; + var children = this._children; + for(var i = 0, len = children.length; i < len; i++) + children[i]._setCachedParent(null); + } + }; + + proto.isBaked = function(){ + return this._isBaked; + }; + + proto.rendering = function(){ + if(this._cacheDirty){ + var _t = this; + var children = _t._children, locBakeSprite = this._bakeSprite; + //compute the bounding box of the bake layer. + this._transformForRenderer(); + var boundingBox = this._renderCmd._getBoundingBoxForBake(); + boundingBox.width = 0|(boundingBox.width+0.5); + boundingBox.height = 0|(boundingBox.height+0.5); + var bakeContext = locBakeSprite.getCacheContext(); + locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); + bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); + // invert + var t = cc.affineTransformInvert(this._transformWorld); + bakeContext.transform(t.a, t.c, t.b, t.d, t.tx , -t.ty ); + + //reset the bake sprite's position + var anchor = locBakeSprite.getAnchorPointInPoints(); + locBakeSprite.setPosition(anchor.x + boundingBox.x, anchor.y + boundingBox.y); + + //visit for canvas + _t.sortAllChildren(); + cc.renderer._turnToCacheMode(this.__instanceId); + for (var i = 0, len = children.length; i < len; i++) { + children[i].visit(bakeContext); + } + cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); + locBakeSprite.transform(); //because bake sprite's position was changed at rendering. + this._cacheDirty = false; + } + }; + + proto.visit = function(parentCmd){ + if(!this._isBaked){ + cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); + return; + } + + var context = ctx || cc._renderContext; + var _t = this; + var children = _t._children; + var len = children.length; + // quick return if not visible + if (!_t._visible || len === 0) + return; + + _t.transform(context); + + if(_t._needDraw) + cc.renderer.pushRenderCommand(this); + + //the bakeSprite is drawing + this._bakeSprite.visit(context); + }; + + proto._bakeForAddChild = function(child){ + if(child._parent == this && this._isBaked) + child._setCachedParent(this); + }; + + proto._getBoundingBoxForBake = function(){ + var rect = null; + + //query child's BoundingBox + if (!this._children || this._children.length === 0) + return cc.rect(0, 0, 10, 10); + + var locChildren = this._children; + for (var i = 0; i < locChildren.length; i++) { + var child = locChildren[i]; + if (child && child._visible) { + if(rect){ + var childRect = child._getBoundingBoxToCurrentNode(); + if (childRect) + rect = cc.rectUnion(rect, childRect); + }else{ + rect = child._getBoundingBoxToCurrentNode(); + } + } + } + return rect; + }; + +})(); + +/** + * cc.LayerColor's rendering objects of Canvas + */ +(function(){ + + //LayerColor's canvas render command + cc.LayerColor.CanvasRenderCmd = function(renderable){ + cc.Layer.CanvasRenderCmd.call(this, renderable); this._needDraw = true; - cc.renderer.childrenOrderDirty = true; - //limit: 1. its children's blendfunc are invalid. - this._isBaked = this._cacheDirty = true; - - this._cachedParent = this; - var children = this._children; - for(var i = 0, len = children.length; i < len; i++) - children[i]._setCachedParent(this); - - if (!this._bakeSprite){ - this._bakeSprite = new cc.BakeSprite(); - this._bakeSprite._parent = this; + }; + var proto = cc.LayerColor.CanvasRenderCmd.prototype = Object.create(cc.Layer.CanvasRenderCmd.prototype); + proto.constructor = cc.LayerColor.CanvasRenderCmd; + + proto.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, + node = this._node, + t = this._worldTransform, + curColor = this._displayedColor, + opacity = this._displayedOpacity / 255, + locWidth = node._contentSize.width, + locHeight = node._contentSize.height; + + if (opacity === 0) + return; + + var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); + var needRestore = (node._blendFuncStr !== "source-over") || needTransform; + + if (needRestore) { + context.save(); + context.globalCompositeOperation = node._blendFuncStr; + } + context.globalAlpha = opacity; + context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," + + (0 | curColor.b) + ", 1)"; + if (needTransform) { + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); + } else { + context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); + } + if (needRestore) + context.restore(); + cc.g_NumberOfDraws++; + }; + + proto._updataSquareVertices = + proto._updateSquareVerticesWidth = + proto._updateSquareVerticesHeight = function(){}; + + proto._updateColor = function(){ + var locCmd = this._renderCmd; + if(!locCmd || !locCmd._color) + return; + var locColor = this._displayedColor; + locCmd._color.r = locColor.r; + locCmd._color.g = locColor.g; + locCmd._color.b = locColor.b; + locCmd._color.a = this._displayedOpacity / 255; + }; + + proto._bakeRendering = function(){ + if(this._cacheDirty){ + var _t = this; + var locBakeSprite = _t._bakeSprite, children = this._children; + var len = children.length, i; + + //compute the bounding box of the bake layer. + var boundingBox = this._renderCmd._getBoundingBoxForBake(); + boundingBox.width = 0 | boundingBox.width; + boundingBox.height = 0 | boundingBox.height; + var bakeContext = locBakeSprite.getCacheContext(); + locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); + var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = this._position; + if(this._ignoreAnchorPointForPosition){ + bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); + //reset the bake sprite's position + locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); + } else { + var selfAnchor = this.getAnchorPointInPoints(); + var selfPos = {x: locPos.x - selfAnchor.x, y: locPos.y - selfAnchor.y}; + bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); + locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); + } + // invert + var t = cc.affineTransformInvert(this._transformWorld); + bakeContext.transform(t.a, t.c, t.b, t.d, t.tx, -t.ty); + + var child; + cc.renderer._turnToCacheMode(this.__instanceId); + //visit for canvas + if (len > 0) { + _t.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + child = children[i]; + if (child._localZOrder < 0) + child.visit(bakeContext); + else + break; + } + if(_t._renderCmd) + cc.renderer.pushRenderCommand(_t._renderCmd); + for (; i < len; i++) { + children[i].visit(bakeContext); + } + } else + if(_t._renderCmd) + cc.renderer.pushRenderCommand(_t._renderCmd); + cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); + locBakeSprite.transform(); + this._cacheDirty = false; } - } -}; + }; -cc.Layer.CanvasRenderCmd.prototype.unbake = function(){ - if (this._isBaked) { - cc.renderer.childrenOrderDirty = true; - this._isBaked = false; - this._cacheDirty = true; + proto.visit = function(ctx){ + var context = ctx || cc._renderContext; + if(!this._isBaked){ + cc.Node.CanvasRenderCmd.prototype.visit.call(this); + return; + } - this._cachedParent = null; - var children = this._children; - for(var i = 0, len = children.length; i < len; i++) - children[i]._setCachedParent(null); - } -}; + var _t = this; + // quick return if not visible + if (!_t._visible) + return; + + _t.transform(context); + + if(_t._bakeRenderCmd) + cc.renderer.pushRenderCommand(_t._bakeRenderCmd); + + //the bakeSprite is drawing + this._bakeSprite.visit(context); + }; + + proto._getBoundingBoxForBake = function(){ + //default size + var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); + var trans = this.getNodeToWorldTransform(); + rect = cc.rectApplyAffineTransform(rect, this.getNodeToWorldTransform()); + + //query child's BoundingBox + if (!this._children || this._children.length === 0) + return rect; + + var locChildren = this._children; + for (var i = 0; i < locChildren.length; i++) { + var child = locChildren[i]; + if (child && child._visible) { + var childRect = child._getBoundingBoxToCurrentNode(trans); + rect = cc.rectUnion(rect, childRect); + } + } + return rect; + }; + + proto.draw = function(){}; + +})(); -cc.Layer.CanvasRenderCmd.prototype.isBaked = function(){ - return this._isBaked; -}; +/** + * cc.LayerGradient's rendering objects of Canvas + */ +(function(){ -cc.Layer.CanvasRenderCmd.prototype.rendering = function(){ - if(this._cacheDirty){ + cc.LayerGradient.CanvasRenderCmd = function(renderable){ + cc.LayerColor.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; + this._startPoint = cc.p(0, 0); + this._endPoint = cc.p(0, 0); + this._startStopStr = null; + this._endStopStr = null; + }; + var proto = cc.LayerGradient.CanvasRenderCmd.prototype = Object.create(cc.LayerColor.CanvasRenderCmd.prototype); + proto.constructor = cc.LayerGradient.CanvasRenderCmd; + + proto.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, + self = this, + node = self._node, + opacity = node._displayedOpacity / 255, + t = node._transformWorld; + + if (opacity === 0) + return; + + var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); + var needRestore = (node._blendFuncStr !== "source-over") || needTransform; + if (needRestore) { + context.save(); + context.globalCompositeOperation = node._blendFuncStr; + } + context.globalAlpha = opacity; + var locWidth = node._contentSize.width, locHeight = node._contentSize.height; + + var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); + gradient.addColorStop(0, this._startStopStr); + gradient.addColorStop(1, this._endStopStr); + context.fillStyle = gradient; + + if (needTransform) { + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); + } else + context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); + + if (needRestore) + context.restore(); + cc.g_NumberOfDraws++; + }; + + proto._updateColor = function(){ var _t = this; - var children = _t._children, locBakeSprite = this._bakeSprite; - //compute the bounding box of the bake layer. - this._transformForRenderer(); - var boundingBox = this._getBoundingBoxForBake(); - boundingBox.width = 0|(boundingBox.width+0.5); - boundingBox.height = 0|(boundingBox.height+0.5); - var bakeContext = locBakeSprite.getCacheContext(); - locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); - bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); - // invert - var t = cc.affineTransformInvert(this._transformWorld); - bakeContext.transform(t.a, t.c, t.b, t.d, t.tx , -t.ty ); - - //reset the bake sprite's position - var anchor = locBakeSprite.getAnchorPointInPoints(); - locBakeSprite.setPosition(anchor.x + boundingBox.x, anchor.y + boundingBox.y); - - //visit for canvas - _t.sortAllChildren(); - cc.renderer._turnToCacheMode(this.__instanceId); - for (var i = 0, len = children.length; i < len; i++) { - children[i].visit(bakeContext); + var locAlongVector = _t._alongVector, tWidth = _t.width * 0.5, tHeight = _t.height * 0.5; + + var locCmd = this._renderCmd; + locCmd._startPoint.x = tWidth * (-locAlongVector.x) + tWidth; + locCmd._startPoint.y = tHeight * locAlongVector.y - tHeight; + locCmd._endPoint.x = tWidth * locAlongVector.x + tWidth; + locCmd._endPoint.y = tHeight * (-locAlongVector.y) - tHeight; + + var locStartColor = this._displayedColor, locEndColor = this._endColor, opacity = this._displayedOpacity / 255; + var startOpacity = this._startOpacity, endOpacity = this._endOpacity; + locCmd._startStopStr = "rgba(" + Math.round(locStartColor.r) + "," + Math.round(locStartColor.g) + "," + + Math.round(locStartColor.b) + "," + startOpacity.toFixed(4) + ")"; + locCmd._endStopStr = "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + + Math.round(locEndColor.b) + "," + endOpacity.toFixed(4) + ")"; + }; + +})(); + + +/** + * cc.Layer's rendering objects of WebGL + */ +(function(){ + cc.Layer.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + }; + + var proto = cc.Layer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.Layer.WebGLRenderCmd; + + proto.bake = function(){}; + + proto.unbake = function(){}; + + proto.unbake = function(){ + return false; + }; + + proto.visit = cc.Node.prototype.visit; + + proto._bakeForAddChild = function(){}; +})(); + +/** + * cc.LayerColor's rendering objects of WebGL + */ +(function(){ + + cc.LayerColor.WebGLRenderCmd = function(renderable){ + cc.Layer.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + + // + var _t = this; + _t._squareVerticesAB = new ArrayBuffer(32); + _t._squareColorsAB = new ArrayBuffer(16); + + var locSquareVerticesAB = _t._squareVerticesAB, locSquareColorsAB = _t._squareColorsAB; + var locVertex2FLen = cc.Vertex2F.BYTES_PER_ELEMENT, locColorLen = cc.Color.BYTES_PER_ELEMENT; + _t._squareVertices = [new cc.Vertex2F(0, 0, locSquareVerticesAB, 0), + new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen), + new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 2), + new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 3)]; + _t._squareColors = [cc.color(0, 0, 0, 255, locSquareColorsAB, 0), + cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen), + cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 2), + cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 3)]; + _t._verticesFloat32Buffer = cc._renderContext.createBuffer(); + _t._colorsUint8Buffer = cc._renderContext.createBuffer(); + }; + var proto = cc.LayerColor.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype); + proto.constructor = cc.LayerColor.WebGLRenderCmd; + + cc.LayerColor.WebGLRenderCmd.prototype.rendering = function (ctx) { + var context = ctx || cc._renderContext; + var node = this._node; + + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + + // + // Attributes + // + context.bindBuffer(context.ARRAY_BUFFER, node._verticesFloat32Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); + + context.bindBuffer(context.ARRAY_BUFFER, node._colorsUint8Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); + + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + context.drawArrays(context.TRIANGLE_STRIP, 0, 4); + }; + + proto._updataSquareVertices = function(size, height){ + var locSquareVertices = this._squareVertices; + if (height === undefined) { + locSquareVertices[1].x = size.width; + locSquareVertices[2].y = size.height; + locSquareVertices[3].x = size.width; + locSquareVertices[3].y = size.height; + } else { + locSquareVertices[1].x = size; + locSquareVertices[2].y = height; + locSquareVertices[3].x = size; + locSquareVertices[3].y = height; } - cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); - locBakeSprite.transform(); //because bake sprite's position was changed at rendering. - this._cacheDirty = false; - } -}; - -cc.Layer.CanvasRenderCmd.prototype.visit = function(parentCmd){ - if(!this._isBaked){ - cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); - return; - } - - var context = ctx || cc._renderContext; - var _t = this; - var children = _t._children; - var len = children.length; - // quick return if not visible - if (!_t._visible || len === 0) - return; - - _t.transform(context); - - if(_t._needDraw) - cc.renderer.pushRenderCommand(this); - - //the bakeSprite is drawing - this._bakeSprite.visit(context); -}; - -//Layer's WebGL render command -cc.Layer.WebGLRenderCmd = function(renderable){ - cc.Node.WebGLRenderCmd.call(this, renderable); -}; - -cc.Layer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.Layer.WebGLRenderCmd.prototype.constructor = cc.Layer.WebGLRenderCmd; - -cc.Layer.WebGLRenderCmd.prototype.bake = function(){}; - -cc.Layer.WebGLRenderCmd.prototype.unbake = function(){}; - -cc.Layer.WebGLRenderCmd.prototype.unbake = function(){ - return false; -}; - -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//LayerColor's canvas render command -cc.LayerColor.CanvasRenderCmd = function(renderable){ - cc.Layer.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; -}; -cc.LayerColor.CanvasRenderCmd.prototype = Object.create(cc.Layer.CanvasRenderCmd.prototype); - -cc.LayerColor.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - node = this._node, - t = node._transformWorld, - curColor = node._displayedColor, - opacity = node._displayedOpacity / 255, - locWidth = node._contentSize.width, - locHeight = node._contentSize.height; - - if (opacity === 0) - return; - - var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); - var needRestore = (node._blendFuncStr !== "source-over") || needTransform; - - if (needRestore) { - context.save(); - context.globalCompositeOperation = node._blendFuncStr; - } - context.globalAlpha = opacity; - context.fillStyle = "rgba(" + (0 | curColor.r) + "," + (0 | curColor.g) + "," - + (0 | curColor.b) + ", 1)"; - if (needTransform) { - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); - } else { - context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); - } - if (needRestore) - context.restore(); - cc.g_NumberOfDraws++; -}; - -//LayerColor's WebGL render command -cc.LayerColor.WebGLRenderCmd = function(renderable){ - cc.Layer.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; -}; -cc.LayerColor.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype); - -cc.LayerColor.WebGLRenderCmd.prototype.rendering = function (ctx) { - var context = ctx || cc._renderContext; - var node = this._node; - - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - - // - // Attributes - // - context.bindBuffer(context.ARRAY_BUFFER, node._verticesFloat32Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); - - context.bindBuffer(context.ARRAY_BUFFER, node._colorsUint8Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); - - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - context.drawArrays(context.TRIANGLE_STRIP, 0, 4); -}; - -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -//LayerGradient's Canvas render command -cc.LayerGradient.CanvasRenderCmd = function(renderable){ - cc.LayerColor.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; - this._startPoint = cc.p(0, 0); - this._endPoint = cc.p(0, 0); - this._startStopStr = null; - this._endStopStr = null; -}; -cc.LayerGradient.CanvasRenderCmd.prototype = Object.create(cc.LayerColor.CanvasRenderCmd.prototype); - -cc.LayerGradient.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - self = this, - node = self._node, - opacity = node._displayedOpacity / 255, - t = node._transformWorld; - - if (opacity === 0) - return; - - var needTransform = (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1); - var needRestore = (node._blendFuncStr !== "source-over") || needTransform; - if (needRestore) { - context.save(); - context.globalCompositeOperation = node._blendFuncStr; - } - context.globalAlpha = opacity; - var locWidth = node._contentSize.width, locHeight = node._contentSize.height; - - var gradient = context.createLinearGradient(self._startPoint.x, self._startPoint.y, self._endPoint.x, self._endPoint.y); - gradient.addColorStop(0, this._startStopStr); - gradient.addColorStop(1, this._endStopStr); - context.fillStyle = gradient; - - if (needTransform) { - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.fillRect(0, 0, locWidth * scaleX, -locHeight * scaleY); - } else - context.fillRect(t.tx * scaleX, -t.ty * scaleY, locWidth * scaleX, -locHeight * scaleY); - - if (needRestore) - context.restore(); - cc.g_NumberOfDraws++; -}; - -//LayerColor's WebGL render command -cc.LayerGradient.WebGLRenderCmd = function(renderable){ - cc.LayerColor.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; -}; -cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype); + this._bindLayerVerticesBufferData(); + }; + + proto._updateSquareVerticesWidth = function(width){ + var locSquareVertices = this._squareVertices; + locSquareVertices[1].x = width; + locSquareVertices[3].x = width; + this._bindLayerVerticesBufferData(); + }; + + proto._updateSquareVerticesHeight = function(height){ + var locSquareVertices = this._squareVertices; + locSquareVertices[2].y = height; + locSquareVertices[3].y = height; + this._bindLayerVerticesBufferData(); + }; + + proto._updateColor = function(){ + var locDisplayedColor = this._displayedColor; + var locDisplayedOpacity = this._displayedOpacity, locSquareColors = this._squareColors; + for (var i = 0; i < 4; i++) { + locSquareColors[i].r = locDisplayedColor.r; + locSquareColors[i].g = locDisplayedColor.g; + locSquareColors[i].b = locDisplayedColor.b; + locSquareColors[i].a = locDisplayedOpacity; + } + this._bindLayerColorsBufferData(); + }; + + proto.draw = function(){ + var context = ctx || cc._renderContext; + + cc.nodeDrawSetup(this); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + + // + // Attributes + // + context.bindBuffer(context.ARRAY_BUFFER, this._verticesFloat32Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); + + context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); + + cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); + context.drawArrays(context.TRIANGLE_STRIP, 0, 4); + }; + + proto._bindLayerVerticesBufferData = function(){ + var glContext = cc._renderContext; + glContext.bindBuffer(glContext.ARRAY_BUFFER, this._verticesFloat32Buffer); + glContext.bufferData(glContext.ARRAY_BUFFER, this._squareVerticesAB, glContext.STATIC_DRAW); + }; + + proto._bindLayerColorsBufferData = function(){ + var glContext = cc._renderContext; + glContext.bindBuffer(glContext.ARRAY_BUFFER, this._colorsUint8Buffer); + glContext.bufferData(glContext.ARRAY_BUFFER, this._squareColorsAB, glContext.STATIC_DRAW); + }; + +})(); + +/** + * cc.LayerGradient's rendering objects of WebGL + */ +(function(){ + cc.LayerGradient.WebGLRenderCmd = function(renderable){ + cc.LayerColor.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + }; + var proto = cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype); + proto.constructor = cc.LayerGradient.WebGLRenderCmd; + proto._updateColor = function(){ + var _t = this; + var locAlongVector = _t._alongVector; + var h = cc.pLength(locAlongVector); + if (h === 0) + return; + var c = Math.sqrt(2.0), u = cc.p(locAlongVector.x / h, locAlongVector.y / h); + + // Compressed Interpolation mode + if (_t._compressedInterpolation) { + var h2 = 1 / ( Math.abs(u.x) + Math.abs(u.y) ); + u = cc.pMult(u, h2 * c); + } + var opacityf = _t._displayedOpacity / 255.0; + var locDisplayedColor = _t._displayedColor, locEndColor = _t._endColor; + var S = { r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: _t._startOpacity * opacityf}; + var E = {r: locEndColor.r, g: locEndColor.g, b: locEndColor.b, a: _t._endOpacity * opacityf}; + + // (-1, -1) + var locSquareColors = _t._squareColors; + var locSquareColor0 = locSquareColors[0], locSquareColor1 = locSquareColors[1], locSquareColor2 = locSquareColors[2], locSquareColor3 = locSquareColors[3]; + locSquareColor0.r = ((E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0 * c)))); + locSquareColor0.g = ((E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0 * c)))); + locSquareColor0.b = ((E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0 * c)))); + locSquareColor0.a = ((E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0 * c)))); + // (1, -1) + locSquareColor1.r = ((E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0 * c)))); + locSquareColor1.g = ((E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0 * c)))); + locSquareColor1.b = ((E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0 * c)))); + locSquareColor1.a = ((E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0 * c)))); + // (-1, 1) + locSquareColor2.r = ((E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0 * c)))); + locSquareColor2.g = ((E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0 * c)))); + locSquareColor2.b = ((E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0 * c)))); + locSquareColor2.a = ((E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0 * c)))); + // (1, 1) + locSquareColor3.r = ((E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0 * c)))); + locSquareColor3.g = ((E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0 * c)))); + locSquareColor3.b = ((E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0 * c)))); + locSquareColor3.a = ((E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0 * c)))); + + _t._bindLayerColorsBufferData(); + }; +})(); \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayerWebGL.js b/cocos2d/core/layers/CCLayerWebGL.js deleted file mode 100644 index 525ce26521..0000000000 --- a/cocos2d/core/layers/CCLayerWebGL.js +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -cc._tmp.LayerDefineForWebGL = function(){ - var _p = cc.Layer.prototype; - //Layer doesn't support bake function in WebGL - _p.bake = function(){}; - _p.unbake = function(){}; - _p.visit = cc.Node.prototype.visit; -}; - -cc._tmp.WebGLLayerColor = function () { - //cc.LayerColor define start - var _p = cc.LayerColor.prototype; - _p._squareVertices = null; - _p._squareColors = null; - _p._verticesFloat32Buffer = null; - _p._colorsUint8Buffer = null; - _p._squareVerticesAB = null; - _p._squareColorsAB = null; - _p.ctor = function (color, width, height) { - var _t = this; - _t._squareVerticesAB = new ArrayBuffer(32); - _t._squareColorsAB = new ArrayBuffer(16); - - var locSquareVerticesAB = _t._squareVerticesAB, locSquareColorsAB = _t._squareColorsAB; - var locVertex2FLen = cc.Vertex2F.BYTES_PER_ELEMENT, locColorLen = cc.Color.BYTES_PER_ELEMENT; - _t._squareVertices = [new cc.Vertex2F(0, 0, locSquareVerticesAB, 0), - new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen), - new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 2), - new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 3)]; - _t._squareColors = [cc.color(0, 0, 0, 255, locSquareColorsAB, 0), - cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen), - cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 2), - cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 3)]; - _t._verticesFloat32Buffer = cc._renderContext.createBuffer(); - _t._colorsUint8Buffer = cc._renderContext.createBuffer(); - - cc.Layer.prototype.ctor.call(_t); - _t._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); - - cc.LayerColor.prototype.init.call(_t, color, width, height); - }; - _p.setContentSize = function (size, height) { - var locSquareVertices = this._squareVertices; - if (height === undefined) { - locSquareVertices[1].x = size.width; - locSquareVertices[2].y = size.height; - locSquareVertices[3].x = size.width; - locSquareVertices[3].y = size.height; - } else { - locSquareVertices[1].x = size; - locSquareVertices[2].y = height; - locSquareVertices[3].x = size; - locSquareVertices[3].y = height; - } - this._bindLayerVerticesBufferData(); - cc.Layer.prototype.setContentSize.call(this, size, height); - }; - _p._setWidth = function (width) { - var locSquareVertices = this._squareVertices; - locSquareVertices[1].x = width; - locSquareVertices[3].x = width; - this._bindLayerVerticesBufferData(); - cc.Layer.prototype._setWidth.call(this, width); - }; - _p._setHeight = function (height) { - var locSquareVertices = this._squareVertices; - locSquareVertices[2].y = height; - locSquareVertices[3].y = height; - this._bindLayerVerticesBufferData(); - cc.Layer.prototype._setHeight.call(this, height); - }; - _p._updateColor = function () { - var locDisplayedColor = this._displayedColor; - var locDisplayedOpacity = this._displayedOpacity, locSquareColors = this._squareColors; - for (var i = 0; i < 4; i++) { - locSquareColors[i].r = locDisplayedColor.r; - locSquareColors[i].g = locDisplayedColor.g; - locSquareColors[i].b = locDisplayedColor.b; - locSquareColors[i].a = locDisplayedOpacity; - } - this._bindLayerColorsBufferData(); - }; - _p.draw = function (ctx) { - var context = ctx || cc._renderContext; - - cc.nodeDrawSetup(this); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - - // - // Attributes - // - context.bindBuffer(context.ARRAY_BUFFER, this._verticesFloat32Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); - - context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); - - cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - context.drawArrays(context.TRIANGLE_STRIP, 0, 4); - }; - _p._bindLayerVerticesBufferData = function () { - var glContext = cc._renderContext; - glContext.bindBuffer(glContext.ARRAY_BUFFER, this._verticesFloat32Buffer); - glContext.bufferData(glContext.ARRAY_BUFFER, this._squareVerticesAB, glContext.STATIC_DRAW); - }; - - _p._bindLayerColorsBufferData = function () { - var glContext = cc._renderContext; - glContext.bindBuffer(glContext.ARRAY_BUFFER, this._colorsUint8Buffer); - glContext.bufferData(glContext.ARRAY_BUFFER, this._squareColorsAB, glContext.STATIC_DRAW); - }; - //cc.LayerColor define end -}; - -cc._tmp.WebGLLayerGradient = function () { - //cc.LayerGradient define start - var _p = cc.LayerGradient.prototype; - _p.draw = cc.LayerColor.prototype.draw; - _p._updateColor = function () { - var _t = this; - var locAlongVector = _t._alongVector; - var h = cc.pLength(locAlongVector); - if (h === 0) - return; - - var c = Math.sqrt(2.0), u = cc.p(locAlongVector.x / h, locAlongVector.y / h); - - // Compressed Interpolation mode - if (_t._compressedInterpolation) { - var h2 = 1 / ( Math.abs(u.x) + Math.abs(u.y) ); - u = cc.pMult(u, h2 * c); - } - - var opacityf = _t._displayedOpacity / 255.0; - var locDisplayedColor = _t._displayedColor, locEndColor = _t._endColor; - var S = { r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: _t._startOpacity * opacityf}; - var E = {r: locEndColor.r, g: locEndColor.g, b: locEndColor.b, a: _t._endOpacity * opacityf}; - - // (-1, -1) - var locSquareColors = _t._squareColors; - var locSquareColor0 = locSquareColors[0], locSquareColor1 = locSquareColors[1], locSquareColor2 = locSquareColors[2], locSquareColor3 = locSquareColors[3]; - locSquareColor0.r = ((E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.g = ((E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.b = ((E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.a = ((E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0 * c)))); - // (1, -1) - locSquareColor1.r = ((E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.g = ((E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.b = ((E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.a = ((E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0 * c)))); - // (-1, 1) - locSquareColor2.r = ((E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.g = ((E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.b = ((E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.a = ((E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0 * c)))); - // (1, 1) - locSquareColor3.r = ((E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.g = ((E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.b = ((E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.a = ((E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0 * c)))); - - _t._bindLayerColorsBufferData(); - }; - //cc.LayerGradient define end -}; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index f31adbf628..8411226534 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -182,7 +182,7 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { } else { contentSize = node._contentSize; if (locTextureCoord.validRect) { - curColor = node._displayedColor; + curColor = this._displayedColor; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } @@ -230,7 +230,7 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { } else { contentSize = node._contentSize; if (locTextureCoord.validRect) { - curColor = node._displayedColor; + curColor = this._displayedColor; context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } diff --git a/moduleConfig.json b/moduleConfig.json index aab615b00f..b1a04756ed 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -90,8 +90,6 @@ "cocos2d/core/scenes/CCScene.js", "cocos2d/core/scenes/CCLoaderScene.js", - "cocos2d/core/layers/CCLayerWebGL.js", - "cocos2d/core/layers/CCLayerPropertyDefine.js", "cocos2d/core/layers/CCLayer.js", "cocos2d/core/layers/CCLayerRenderCmd.js", From 56c826f7ea811c3b2189e3a9c401d0b5d5f901e3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 18 Nov 2014 18:05:39 +0800 Subject: [PATCH 0922/1564] Issue #2416: refactor LabelTTF's renderer --- cocos2d/core/labelttf/CCLabelTTF.js | 28 +++++++------------- cocos2d/core/labelttf/CCLabelTTFRenderCmd.js | 8 ++++++ cocos2d/core/labelttf/LabelTTFWebGL.js | 27 ------------------- 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index e9601e8e31..c3a070ac30 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -488,7 +488,16 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ * @function * @param {cc.Color} fillColor The fill color of the label */ - setFontFillColor: null, + setFontFillColor: function (fillColor) { + var locTextFillColor = this._textFillColor; + if (locTextFillColor.r != fillColor.r || locTextFillColor.g != fillColor.g || locTextFillColor.b != fillColor.b) { + locTextFillColor.r = fillColor.r; + locTextFillColor.g = fillColor.g; + locTextFillColor.b = fillColor.b; + this._setColorsString(); + this._needUpdateTexture = true; + } + }, _getFillStyle: function () { return this._textFillColor; @@ -757,11 +766,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var _p = cc.LabelTTF.prototype; - _p.setColor = function (color3) { - cc.Node.prototype.setColor.call(this, color3); - this._renderCmd._setColorsString(); - }; - _p._transformForRenderer = function(){ if (this._needUpdateTexture) { this._needUpdateTexture = false; @@ -780,18 +784,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return true; }; - _p.setFontFillColor = function (tintColor) { - var locTextFillColor = this._textFillColor; - if (locTextFillColor.r != tintColor.r || locTextFillColor.g != tintColor.g || locTextFillColor.b != tintColor.b) { - locTextFillColor.r = tintColor.r; - locTextFillColor.g = tintColor.g; - locTextFillColor.b = tintColor.b; - - this._renderCmd._setColorsString(); - this._setUpdateTextureDirty(); - } - }; - _p = null; } else { cc.assert(cc.isFunction(cc._tmp.WebGLLabelTTF), cc._LogInfos.MissingFile, "LabelTTFWebGL.js"); diff --git a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js index a623cd8b30..143c730f91 100644 --- a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js @@ -372,3 +372,11 @@ cc.LabelTTF.WebGLRenderCmd = function(renderable){ cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit + +cc.LabelTTF.WebGLRenderCmd.prototype._setColorsString = function(){ + this._needUpdateTexture = true; + var locStrokeColor = this._strokeColor, locFontFillColor = this._textFillColor; + this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; + this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; + this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; +}; \ No newline at end of file diff --git a/cocos2d/core/labelttf/LabelTTFWebGL.js b/cocos2d/core/labelttf/LabelTTFWebGL.js index 99cefb31f3..b206d83d5f 100644 --- a/cocos2d/core/labelttf/LabelTTFWebGL.js +++ b/cocos2d/core/labelttf/LabelTTFWebGL.js @@ -27,8 +27,6 @@ cc._tmp.WebGLLabelTTF = function () { var _p = cc.LabelTTF.prototype; - _p.setColor = cc.Sprite.prototype.setColor; - _p._transformForRenderer = function(){ if (this._needUpdateTexture) { this._needUpdateTexture = false; @@ -37,20 +35,6 @@ cc._tmp.WebGLLabelTTF = function () { cc.Node.prototype._transformForRenderer.call(this); }; - _p._setColorsString = function () { - this._needUpdateTexture = true; - var locStrokeColor = this._strokeColor, locFontFillColor = this._textFillColor; - this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; - this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; - this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; - }; - - _p.updateDisplayedColor = cc.Sprite.prototype.updateDisplayedColor; - - _p.setOpacity = cc.Sprite.prototype.setOpacity; - - _p.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity; - _p.initWithStringAndTextDefinition = function (text, textDefinition) { if (!cc.Sprite.prototype.init.call(this)) return false; @@ -66,15 +50,4 @@ cc._tmp.WebGLLabelTTF = function () { return true; }; - - _p.setFontFillColor = function (tintColor) { - var locTextFillColor = this._textFillColor; - if (locTextFillColor.r != tintColor.r || locTextFillColor.g != tintColor.g || locTextFillColor.b != tintColor.b) { - locTextFillColor.r = tintColor.r; - locTextFillColor.g = tintColor.g; - locTextFillColor.b = tintColor.b; - this._setColorsString(); - this._needUpdateTexture = true; - } - }; }; \ No newline at end of file From 18cc15cb4073d8ec72e113a5b4555bda30a1f209 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 19 Nov 2014 09:54:22 +0800 Subject: [PATCH 0923/1564] Fixed Pause All audio without background music error --- cocos2d/audio/CCAudio.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 0c3ed1b8e3..ec3b37f592 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -134,12 +134,12 @@ cc.Audio = cc.Class.extend({ //TODO Maybe loader shift in will be better volume: 1, loop: false, + src: null, _touch: false, _playing: false, _AUDIO_TYPE: "AUDIO", _pause: false, - _src: null, //Web Audio _buffer: null, @@ -557,8 +557,9 @@ cc.Audio = cc.Class.extend({ * cc.audioEngine.playMusic(path, false); */ playMusic: function(url, loop){ - if(this._currMusic && this._currMusic._src !== url){ - this._currMusic.stop(); + var bgMusic = this._currMusic; + if(bgMusic && bgMusic.src !== url){ + bgMusic.stop(); } var audio = loader.cache[url]; if(!audio){ @@ -866,9 +867,10 @@ cc.Audio = cc.Class.extend({ _pauseCache: [], _pausePlaying: function(){ - if(this._currMusic.getPlaying()){ - this._currMusic.pause(); - this._pauseCache.push(this._currMusic); + var bgMusic = this._currMusic; + if(bgMusic && bgMusic.getPlaying()){ + bgMusic.pause(); + this._pauseCache.push(bgMusic); } var ap = this._audioPool; for(var p in ap){ From 0bb599e1c8790277e42fa9775d3b6083340164a6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 19 Nov 2014 10:50:57 +0800 Subject: [PATCH 0924/1564] Issue #2416: Correct some mistakes for cc.LabelTTF --- cocos2d/core/base-nodes/CCNode.js | 2 +- cocos2d/core/labelttf/CCLabelTTF.js | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b151fe1b37..88c7a84ac1 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2076,7 +2076,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.AffineTransform} The affine transform object */ getNodeToParentTransform: function(){ - this._renderCmd.getNodeToParentTransform(); + return this._renderCmd.getNodeToParentTransform(); }, /** diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index c3a070ac30..e3d510ca69 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -143,7 +143,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _setUpdateTextureDirty: function(){ this._renderCmdDiry = this._needUpdateTexture = true; - cc.renderer.pushDirtyNode(this); + cc.renderer.pushDirtyNode(this._renderCmd); }, ctor: function (text, fontName, fontSize, dimensions, hAlignment, vAlignment) { @@ -192,19 +192,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return ""; }, - setColor: null, - - updateDisplayedColor: null, - - setOpacity: null, - - updateDisplayedOpacity: null, - - updateDisplayedOpacityForCanvas: function (parentOpacity) { - cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); - this._renderCmd._setColorsString(); - }, - getLineHiehgt: function(){ return this._lineHeight || this._fontClientHeight; }, @@ -739,7 +726,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return cc.Sprite.prototype._getHeight.call(this); }, - visit: function (ctx) { + /*visit: function (ctx) { if (!this._string || this._string == "") return; if (this._needUpdateTexture) { @@ -748,7 +735,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ } var context = ctx || cc._renderContext; cc.Sprite.prototype.visit.call(this, context); - }, + },*/ setTextureRect: function (rect, rotated, untrimmedSize) { //set needConvert to false From 5eceaba665750b14033c9c33ec7ef30e2d35092b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 19 Nov 2014 11:43:47 +0800 Subject: [PATCH 0925/1564] Fix layer set Color --- cocos2d/core/layers/CCLayer.js | 15 ++++++++++++--- cocos2d/core/layers/CCLayerRenderCmd.js | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index cee1243f39..90ac2e7e9c 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -192,11 +192,13 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ setColor: function (color) { cc.Layer.prototype.setColor.call(this, color); this._updateColor(); + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); }, setOpacity: function (opacity) { cc.Layer.prototype.setOpacity.call(this, opacity); this._updateColor(); + this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); }, _blendFuncStr: "source-over", @@ -272,17 +274,24 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ }, _updateColor: function(){ - this._renderCmd._updateColor(); + var renderCmd = this._renderCmd, + relColor = this._realColor, + disColor = renderCmd._displayedColor; + disColor.r = relColor.r; + disColor.g = relColor.g; + disColor.b = relColor.b; + disColor.a = relColor.a; + renderCmd._updateColor(); }, updateDisplayedColor: function (parentColor) { cc.Layer.prototype.updateDisplayedColor.call(this, parentColor); - this._updateColor(); + this._renderCmd._updateColor(); }, updateDisplayedOpacity: function (parentOpacity) { cc.Layer.prototype.updateDisplayedOpacity.call(this, parentOpacity); - this._updateColor(); + this._renderCmd._updateColor(); }, _createRenderCmd: function(){ diff --git a/cocos2d/core/layers/CCLayerRenderCmd.js b/cocos2d/core/layers/CCLayerRenderCmd.js index fbae2245d0..51c453440c 100644 --- a/cocos2d/core/layers/CCLayerRenderCmd.js +++ b/cocos2d/core/layers/CCLayerRenderCmd.js @@ -512,6 +512,7 @@ locSquareColors[i].a = locDisplayedOpacity; } this._bindLayerColorsBufferData(); + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); }; proto.draw = function(){ From 7be4c97f60c256c1bb8ab92aacb7e8c6eb6d3dff Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 19 Nov 2014 13:57:42 +0800 Subject: [PATCH 0926/1564] ParticleSystem renderCmd --- cocos2d/particle/CCParticleSystem.js | 386 +---------- cocos2d/particle/CCParticleSystemRenderCmd.js | 652 ++++++++++++++---- 2 files changed, 559 insertions(+), 479 deletions(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index a663d7ff95..6623f0642c 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -281,18 +281,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ autoRemoveOnFinish: false, emitterMode: 0, - // quads to be rendered - _quads:null, - // indices - _indices:null, - - //_VAOname:0, - //0: vertex 1: indices - _buffersVBO:null, - _pointRect:null, - _textureLoaded: null, - _quadsArrayBuffer:null, /** *

    return the string found by key in dict.
    @@ -354,16 +343,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ this.positionType = cc.ParticleSystem.TYPE_FREE; this.autoRemoveOnFinish = false; - this._buffersVBO = [0, 0]; - this._quads = []; - this._indices = []; - this._pointRect = cc.rect(0, 0, 0, 0); this._textureLoaded = true; - if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - this._quadsArrayBuffer = null; - } - if (!plistFile || cc.isNumber(plistFile)) { var ton = plistFile || 100; this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); @@ -384,7 +365,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * initializes the indices for the vertices */ initIndices:function () { - var locIndices = this._indices; + var locIndices = this._renderCmd._indices; for (var i = 0, len = this._totalParticles; i < len; ++i) { var i6 = i * 6; var i4 = i * 4; @@ -405,73 +386,9 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {cc.Rect} pointRect */ initTexCoordsWithRect:function (pointRect) { - var scaleFactor = cc.contentScaleFactor(); - // convert to pixels coords - var rect = cc.rect( - pointRect.x * scaleFactor, - pointRect.y * scaleFactor, - pointRect.width * scaleFactor, - pointRect.height * scaleFactor); - - var wide = pointRect.width; - var high = pointRect.height; - - if (this._texture) { - wide = this._texture.pixelsWidth; - high = this._texture.pixelsHeight; - } - - if(cc._renderType === cc._RENDER_TYPE_CANVAS) - return; - - var left, bottom, right, top; - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (rect.x * 2 + 1) / (wide * 2); - bottom = (rect.y * 2 + 1) / (high * 2); - right = left + (rect.width * 2 - 2) / (wide * 2); - top = bottom + (rect.height * 2 - 2) / (high * 2); - } else { - left = rect.x / wide; - bottom = rect.y / high; - right = left + rect.width / wide; - top = bottom + rect.height / high; - } - // Important. Texture in cocos2d are inverted, so the Y component should be inverted - var temp = top; - top = bottom; - bottom = temp; + this._renderCmd.initTexCoordsWithRect(pointRect); - var quads; - var start = 0, end = 0; - if (this._batchNode) { - quads = this._batchNode.textureAtlas.quads; - start = this.atlasIndex; - end = this.atlasIndex + this._totalParticles; - } else { - quads = this._quads; - start = 0; - end = this._totalParticles; - } - - for (var i = start; i < end; i++) { - if (!quads[i]) - quads[i] = cc.V3F_C4B_T2F_QuadZero(); - - // bottom-left vertex: - var selQuad = quads[i]; - selQuad.bl.texCoords.u = left; - selQuad.bl.texCoords.v = bottom; - // bottom-right vertex: - selQuad.br.texCoords.u = right; - selQuad.br.texCoords.v = bottom; - // top-left vertex: - selQuad.tl.texCoords.u = left; - selQuad.tl.texCoords.v = top; - // top-right vertex: - selQuad.tr.texCoords.u = right; - selQuad.tr.texCoords.v = top; - } }, /** @@ -510,7 +427,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } else if (!oldBatch) { // OLD: was it self render cleanup ? // copy current state to batch - this._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._quads, this.atlasIndex); + this._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._renderCmd._quads, this.atlasIndex); //delete buffer cc._renderContext.deleteBuffer(this._buffersVBO[1]); //where is re-bindBuffer code? @@ -1235,53 +1152,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {Number} tp totalParticles */ setTotalParticles:function (tp) { - //cc.assert(tp <= this._allocatedParticles, "Particle: resizing particle array only supported for quads"); - if (cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._totalParticles = (tp < 200) ? tp : 200; - return; - } - - // If we are setting the total numer of particles to a number higher - // than what is allocated, we need to allocate new arrays - if (tp > this._allocatedParticles) { - var quadSize = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; - // Allocate new memory - this._indices = new Uint16Array(tp * 6); - var locQuadsArrayBuffer = new ArrayBuffer(tp * quadSize); - //TODO need fix - // Assign pointers - var locParticles = this._particles; - locParticles.length = 0; - var locQuads = this._quads; - locQuads.length = 0; - for (var j = 0; j < tp; j++) { - locParticles[j] = new cc.Particle(); - locQuads[j] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, locQuadsArrayBuffer, j * quadSize); - } - this._allocatedParticles = tp; - this._totalParticles = tp; - - // Init particles - if (this._batchNode) { - for (var i = 0; i < tp; i++) - locParticles[i].atlasIndex = i; - } - - this._quadsArrayBuffer = locQuadsArrayBuffer; - - this.initIndices(); - //if (cc.TEXTURE_ATLAS_USE_VAO) - // this._setupVBOandVAO(); - //else - this._setupVBO(); - - //set the texture coord - if(this._texture){ - this.initTexCoordsWithRect(cc.rect(0, 0, this._texture.width, this._texture.height)); - } - } else - this._totalParticles = tp; - this.resetSystem(); + this._renderCmd.setTotalParticles(); }, /** @@ -1377,18 +1248,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ locBlendFunc.src = cc.SRC_ALPHA; locBlendFunc.dst = cc.ONE; } else { - if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - if (this._texture && !this._texture.hasPremultipliedAlpha()) { - locBlendFunc.src = cc.SRC_ALPHA; - locBlendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - } else { - locBlendFunc.src = cc.BLEND_SRC; - locBlendFunc.dst = cc.BLEND_DST; - } - } else { - locBlendFunc.src = cc.BLEND_SRC; - locBlendFunc.dst = cc.BLEND_DST; - } + this._renderCmd._setBlendAdditive(); } }, @@ -1709,19 +1569,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // udpate after action in run! this.scheduleUpdateWithPriority(1); - if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - // allocating data space - if (!this._allocMemory()) - return false; - - this.initIndices(); - //if (cc.TEXTURE_ATLAS_USE_VAO) - // this._setupVBOandVAO(); - //else - this._setupVBO(); - - this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - } + this._renderCmd._initWithTotalParticles(); return true; }, @@ -1742,17 +1590,9 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ addParticle: function () { if (this.isFull()) return false; - var particle, particles = this._particles; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - if (this.particleCount < particles.length) { - particle = particles[this.particleCount]; - } else { - particle = new cc.Particle(); - particles.push(particle); - } - } else { - particle = particles[this.particleCount]; - } + + var particle = this._renderCmd.addParticle(); + this.initParticle(particle); ++this.particleCount; return true; @@ -1774,36 +1614,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ particle.pos.y = this._sourcePosition.y + this._posVar.y * locRandomMinus11(); // Color - var start, end; - var locStartColor = this._startColor, locStartColorVar = this._startColorVar; - var locEndColor = this._endColor, locEndColorVar = this._endColorVar; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - start = cc.color( - cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255), - cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255), - cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255), - cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255) - ); - end = cc.color( - cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255), - cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255), - cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255), - cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255) - ); - } else { - start = { - r: cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255), - g: cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255), - b: cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255), - a: cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255) - }; - end = { - r: cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255), - g: cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255), - b: cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255), - a: cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255) - }; - } + + var color = this._renderCmd.initParticle(); + var start = color.start, + end = color.end; particle.color = start; var locParticleDeltaColor = particle.deltaColor, locParticleTimeToLive = particle.timeToLive; @@ -1917,7 +1731,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ quad = batchQuads[this.atlasIndex + particle.atlasIndex]; this._batchNode.textureAtlas.dirty = true; } else - quad = this._quads[this._particleIdx]; + quad = this._renderCmd._quads[this._particleIdx]; var r, g, b, a; if (this._opacityModifyRGB) { @@ -2019,8 +1833,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { var gl = cc._renderContext; - gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]); - gl.bufferData(gl.ARRAY_BUFFER, this._quadsArrayBuffer, gl.DYNAMIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this._renderCmd._buffersVBO[0]); + gl.bufferData(gl.ARRAY_BUFFER, this._renderCmd._quadsArrayBuffer, gl.DYNAMIC_DRAW); // Option 2: Data // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * particleCount, quads_, GL_DYNAMIC_DRAW); @@ -2133,13 +1947,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } // color - if (!this._dontTint || cc._renderType === cc._RENDER_TYPE_WEBGL) { - selParticle.color.r += selParticle.deltaColor.r * dt; - selParticle.color.g += selParticle.deltaColor.g * dt; - selParticle.color.b += selParticle.deltaColor.b * dt; - selParticle.color.a += selParticle.deltaColor.a * dt; - selParticle.isChangeColor = true; - } + this._renderCmd._updateDeltaColor(selParticle, dt); // size selParticle.size += (selParticle.deltaSize * dt); @@ -2395,7 +2203,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } } - this._pointRect = rect; + this._renderCmd._pointRect = rect; this.initTexCoordsWithRect(rect); }, @@ -2408,107 +2216,13 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ if(!this._textureLoaded || this._batchNode) // draw should not be called when added to a particleBatchNode return; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) - this._drawForCanvas(ctx); - else - this._drawForWebGL(ctx); + this._renderCmd.draw(); cc.g_NumberOfDraws++; }, - _drawForCanvas:function (ctx) { - var context = ctx || cc._renderContext; - context.save(); - if (this.isBlendAdditive()) - context.globalCompositeOperation = 'lighter'; - else - context.globalCompositeOperation = 'source-over'; - - var element = this._texture.getHtmlElementObj(); - var locScaleX = cc.view.getScaleX(), locScaleY = cc.view.getScaleY(); - - for (var i = 0; i < this.particleCount; i++) { - var particle = this._particles[i]; - var lpx = (0 | (particle.size * 0.5)); - - if (this.drawMode == cc.ParticleSystem.TEXTURE_MODE) { - // Delay drawing until the texture is fully loaded by the browser - if (!element.width || !element.height) - continue; - - context.save(); - context.globalAlpha = particle.color.a / 255; - context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); - - var size = Math.floor(particle.size / 4) * 4; - var w = this._pointRect.width; - var h = this._pointRect.height; - - context.scale( - Math.max(size * locScaleX / w, 0.000001), - Math.max(size * locScaleY / h, 0.000001) - ); - - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - context.translate(-(0 | (w / 2)), -(0 | (h / 2))); - var drawElement = particle.isChangeColor ? this._changeTextureColor(element, particle.color, this._pointRect) : element; - if(drawElement) - context.drawImage(drawElement, 0, 0); - context.restore(); - } else { - context.save(); - context.globalAlpha = particle.color.a / 255; - - context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - - if (this.shapeType == cc.ParticleSystem.STAR_SHAPE) { - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - cc._drawingUtil.drawStar(context, lpx, particle.color); - } else - cc._drawingUtil.drawColorBall(context, lpx, particle.color); - context.restore(); - } - } - context.restore(); - }, - _changeTextureColor: function(element, color, rect){ - if (!element.tintCache) { - element.tintCache = document.createElement('canvas'); - element.tintCache.width = element.width; - element.tintCache.height = element.height; - } - return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, color, rect, element.tintCache); - }, - - _drawForWebGL:function (ctx) { - if(!this._texture) - return; - - var gl = ctx || cc._renderContext; - - this._shaderProgram.use(); - this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); - - cc.glBindTexture2D(this._texture); - cc.glBlendFuncForParticle(this._blendFunc.src, this._blendFunc.dst); - - //cc.assert(this._particleIdx == this.particleCount, "Abnormal error in particle quad"); - - // - // Using VBO without VAO - // - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); - gl.drawElements(gl.TRIANGLES, this._particleIdx * 6, gl.UNSIGNED_SHORT, 0); + this._renderCmd._changeTextureColor(element, color, rect); }, /** @@ -2537,7 +2251,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ glGenBuffers(2, this._buffersVBO[0]); glBindBuffer(GL_ARRAY_BUFFER, this._buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(this._quads[0]) * this._totalParticles, this._quads, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(this._renderCmd._quads[0]) * this._totalParticles, this._renderCmd._quads, GL_DYNAMIC_DRAW); // vertices glEnableVertexAttribArray(kCCVertexAttrib_Position); @@ -2562,70 +2276,16 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ }, _setupVBO:function () { - if (cc._renderType == cc._RENDER_TYPE_CANVAS) - return; - - var gl = cc._renderContext; - - //gl.deleteBuffer(this._buffersVBO[0]); - this._buffersVBO[0] = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]); - gl.bufferData(gl.ARRAY_BUFFER, this._quadsArrayBuffer, gl.DYNAMIC_DRAW); - - this._buffersVBO[1] = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._indices, gl.STATIC_DRAW); - - //cc.checkGLErrorDebug(); + this._renderCmd._setupVBO(); }, _allocMemory:function () { - if (cc._renderType === cc._RENDER_TYPE_CANVAS) - return true; - - //cc.assert((!this._quads && !this._indices), "Memory already allocated"); - if(this._batchNode){ - cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"); - return false; - } - - var quadSize = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; - var totalParticles = this._totalParticles; - var locQuads = this._quads; - locQuads.length = 0; - this._indices = new Uint16Array(totalParticles * 6); - var locQuadsArrayBuffer = new ArrayBuffer(quadSize * totalParticles); - - for (var i = 0; i < totalParticles; i++) - locQuads[i] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, locQuadsArrayBuffer, i * quadSize); - if (!locQuads || !this._indices) { - cc.log("cocos2d: Particle system: not enough memory"); - return false; - } - this._quadsArrayBuffer = locQuadsArrayBuffer; - return true; + this._renderCmd._allocMemory(); } }); var _p = cc.ParticleSystem.prototype; -if(cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes) - _p._changeTextureColor = function (element, color, rect) { - var cacheTextureForColor = cc.textureCache.getTextureColors(element); - if (cacheTextureForColor) { - // Create another cache for the tinted version - // This speeds up things by a fair bit - if (!cacheTextureForColor.tintCache) { - cacheTextureForColor.tintCache = document.createElement('canvas'); - cacheTextureForColor.tintCache.width = element.width; - cacheTextureForColor.tintCache.height = element.height; - } - cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, color, rect, cacheTextureForColor.tintCache); - return cacheTextureForColor.tintCache; - } - return null - }; - // Extended properties /** @expose */ _p.opacityModifyRGB; diff --git a/cocos2d/particle/CCParticleSystemRenderCmd.js b/cocos2d/particle/CCParticleSystemRenderCmd.js index 449ad964e4..4a050e74e5 100644 --- a/cocos2d/particle/CCParticleSystemRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemRenderCmd.js @@ -22,133 +22,553 @@ THE SOFTWARE. ****************************************************************************/ -// ParticleSystem's canvas render command -cc.ParticleSystem.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; -}; -cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - -cc.ParticleSystem.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - node = this._node, - t = node._transformWorld, - pointRect = node._pointRect; - - context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (node.isBlendAdditive()) - context.globalCompositeOperation = 'lighter'; - else - context.globalCompositeOperation = 'source-over'; - - var i, particle, lpx, alpha; - var particleCount = this._node.particleCount, particles = this._node._particles; - if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { - // Delay drawing until the texture is fully loaded by the browser - if (!node._texture || !node._texture._isLoaded) { - context.restore(); - return; - } - var element = node._texture.getHtmlElementObj(); - if (!element.width || !element.height) { - context.restore(); - return; - } +/** + * ParticleSystem's canvas render command + */ +(function(){ + cc.ParticleSystem.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; - var textureCache = cc.textureCache, drawElement = element; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); + this._buffersVBO = [0, 0]; + this._quads = []; + this._indices = []; + this._pointRect = cc.rect(0, 0, 0, 0); + }; + var proto = cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ParticleSystem.CanvasRenderCmd; - alpha = particle.color.a / 255; - if (alpha === 0) continue; - context.globalAlpha = alpha; + proto.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, + node = this._node, + t = node._transformWorld, + pointRect = this._pointRect; - context.save(); - context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if (node.isBlendAdditive()) + context.globalCompositeOperation = 'lighter'; + else + context.globalCompositeOperation = 'source-over'; - var size = Math.floor(particle.size / 4) * 4; - var w = pointRect.width; - var h = pointRect.height; + var i, particle, lpx, alpha; + var particleCount = this._node.particleCount, particles = this._node._particles; + if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { + // Delay drawing until the texture is fully loaded by the browser + if (!node._texture || !node._texture._isLoaded) { + context.restore(); + return; + } + var element = node._texture.getHtmlElementObj(); + if (!element.width || !element.height) { + context.restore(); + return; + } - context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); + var textureCache = cc.textureCache, drawElement = element; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); + alpha = particle.color.a / 255; + if (alpha === 0) continue; + context.globalAlpha = alpha; + + context.save(); + context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); + + var size = Math.floor(particle.size / 4) * 4; + var w = pointRect.width; + var h = pointRect.height; + + context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); + + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); - if (particle.isChangeColor) { - var cacheTextureForColor = textureCache.getTextureColors(element); - if (cacheTextureForColor) { - // Create another cache for the tinted version - // This speeds up things by a fair bit - if (!cacheTextureForColor.tintCache) { - cacheTextureForColor.tintCache = cc.newElement('canvas'); - cacheTextureForColor.tintCache.width = element.width; - cacheTextureForColor.tintCache.height = element.height; + if (particle.isChangeColor) { + var cacheTextureForColor = textureCache.getTextureColors(element); + if (cacheTextureForColor) { + // Create another cache for the tinted version + // This speeds up things by a fair bit + if (!cacheTextureForColor.tintCache) { + cacheTextureForColor.tintCache = cc.newElement('canvas'); + cacheTextureForColor.tintCache.width = element.width; + cacheTextureForColor.tintCache.height = element.height; + } + cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); + drawElement = cacheTextureForColor.tintCache; } - cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); - drawElement = cacheTextureForColor.tintCache; } + context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); + context.restore(); } - context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); - context.restore(); + } else { + var drawTool = cc._drawingUtil; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + alpha = particle.color.a / 255; + if (alpha === 0) continue; + context.globalAlpha = alpha; + + context.save(); + context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); + if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + drawTool.drawStar(context, lpx, particle.color); + } else + drawTool.drawColorBall(context, lpx, particle.color); + context.restore(); + } + } + context.restore(); + cc.g_NumberOfDraws++; + }; + + if(!cc.sys._supportCanvasNewBlendModes){ + proto._changeTextureColor = function(element, color, rect){ + var cacheTextureForColor = cc.textureCache.getTextureColors(element); + if (cacheTextureForColor) { + // Create another cache for the tinted version + // This speeds up things by a fair bit + if (!cacheTextureForColor.tintCache) { + cacheTextureForColor.tintCache = document.createElement('canvas'); + cacheTextureForColor.tintCache.width = element.width; + cacheTextureForColor.tintCache.height = element.height; + } + cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, color, rect, cacheTextureForColor.tintCache); + return cacheTextureForColor.tintCache; + } + return null + } + }else{ + proto._changeTextureColor = function(element, color, rect){ + if (!element.tintCache) { + element.tintCache = document.createElement('canvas'); + element.tintCache.width = element.width; + element.tintCache.height = element.height; + } + return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, color, rect, element.tintCache); + } + } + + proto.initTexCoordsWithRect = function(){}; + + proto.setTotalParticles = function(){ + //cc.assert(tp <= this._allocatedParticles, "Particle: resizing particle array only supported for quads"); + this._node._totalParticles = (tp < 200) ? tp : 200; + }; + + proto.addParticle = function(){ + var node = this._node, + particles = node._particles, + particle; + if (node.particleCount < particles.length) { + particle = particles[node.particleCount]; + } else { + particle = new cc.Particle(); + particles.push(particle); } - } else { - var drawTool = cc._drawingUtil; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); - alpha = particle.color.a / 255; - if (alpha === 0) continue; - context.globalAlpha = alpha; - - context.save(); - context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { + return particle; + }; + + proto.initParticle = function(){ + var node = this._node; + var locRandomMinus11 = cc.randomMinus1To1; + // Color + var start, end; + var locStartColor = node._startColor, locStartColorVar = node._startColorVar; + var locEndColor = node._endColor, locEndColorVar = node._endColorVar; + start = cc.color( + cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255), + cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255), + cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255), + cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255) + ); + end = cc.color( + cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255), + cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255), + cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255), + cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255) + ); + return {start: start, end: end}; + }; + + proto.draw = function(ctx){ + var node = this; + var context = ctx || cc._renderContext; + context.save(); + if (node.isBlendAdditive()) + context.globalCompositeOperation = 'lighter'; + else + context.globalCompositeOperation = 'source-over'; + + var element = node._texture.getHtmlElementObj(); + var locScaleX = cc.view.getScaleX(), locScaleY = cc.view.getScaleY(); + + for (var i = 0; i < node.particleCount; i++) { + var particle = node._particles[i]; + var lpx = (0 | (particle.size * 0.5)); + + if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { + // Delay drawing until the texture is fully loaded by the browser + if (!element.width || !element.height) + continue; + + context.save(); + context.globalAlpha = particle.color.a / 255; + context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); + + var size = Math.floor(particle.size / 4) * 4; + var w = this._pointRect.width; + var h = this._pointRect.height; + + context.scale( + Math.max(size * locScaleX / w, 0.000001), + Math.max(size * locScaleY / h, 0.000001) + ); + if (particle.rotation) context.rotate(cc.degreesToRadians(particle.rotation)); - drawTool.drawStar(context, lpx, particle.color); - } else - drawTool.drawColorBall(context, lpx, particle.color); - context.restore(); + context.translate(-(0 | (w / 2)), -(0 | (h / 2))); + var drawElement = particle.isChangeColor ? node._changeTextureColor(element, particle.color, this._pointRect) : element; + if(drawElement) + context.drawImage(drawElement, 0, 0); + context.restore(); + } else { + context.save(); + context.globalAlpha = particle.color.a / 255; + + context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); + + if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + cc._drawingUtil.drawStar(context, lpx, particle.color); + } else + cc._drawingUtil.drawColorBall(context, lpx, particle.color); + context.restore(); + } } - } - context.restore(); - cc.g_NumberOfDraws++; -}; - -//ParticleSystem's WebGL render command -cc.ParticleSystem.WebGLRenderCmd = function(renderable){ - cc.Node.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; -}; -cc.ParticleSystem.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); - -cc.ParticleSystem.WebGLRenderCmd.prototype.rendering = function (ctx) { - var _t = this._node; - if (!_t._texture) - return; - - var gl = ctx || cc._renderContext; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); - - cc.glBindTexture2D(_t._texture); - cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); - - // - // Using VBO without VAO - // - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); - gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); -}; + context.restore(); + }; + + proto._setupVBO = function(){}; + proto._allocMemory = function(){ + return true; + }; + + proto._setBlendAdditive = function(){ + var locBlendFunc = this._node._blendFunc; + locBlendFunc.src = cc.BLEND_SRC; + locBlendFunc.dst = cc.BLEND_DST; + }; + + proto._initWithTotalParticles = + proto._updateDeltaColor = function(){}; +})(); + +/** + * ParticleSystem's WebGL render command + */ +(function(){ + + cc.ParticleSystem.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + + this._buffersVBO = [0, 0]; + this._quads = []; + this._indices = []; + this._pointRect = cc.rect(0, 0, 0, 0); + this._quadsArrayBuffer = null; + }; + var proto = cc.ParticleSystem.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.ParticleSystem.CanvasRenderCmd; + + proto.rendering = function (ctx) { + var _t = this._node; + if (!_t._texture) + return; + + var gl = ctx || cc._renderContext; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); + + cc.glBindTexture2D(_t._texture); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + + // + // Using VBO without VAO + // + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); + gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); + }; + + proto._changeTextureColor = function(element, color, rect){ + if (!element.tintCache) { + element.tintCache = document.createElement('canvas'); + element.tintCache.width = element.width; + element.tintCache.height = element.height; + } + return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, color, rect, element.tintCache); + }; + + proto.initTexCoordsWithRect = function(pointRect){ + var node = this; + var texture = node.texture; + var scaleFactor = cc.contentScaleFactor(); + // convert to pixels coords + var rect = cc.rect( + pointRect.x * scaleFactor, + pointRect.y * scaleFactor, + pointRect.width * scaleFactor, + pointRect.height * scaleFactor); + + var wide = pointRect.width; + var high = pointRect.height; + + if (texture) { + wide = texture.pixelsWidth; + high = texture.pixelsHeight; + } + + var left, bottom, right, top; + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (rect.x * 2 + 1) / (wide * 2); + bottom = (rect.y * 2 + 1) / (high * 2); + right = left + (rect.width * 2 - 2) / (wide * 2); + top = bottom + (rect.height * 2 - 2) / (high * 2); + } else { + left = rect.x / wide; + bottom = rect.y / high; + right = left + rect.width / wide; + top = bottom + rect.height / high; + } + + // Important. Texture in cocos2d are inverted, so the Y component should be inverted + var temp = top; + top = bottom; + bottom = temp; + + var quads; + var start = 0, end = 0; + if (node._batchNode) { + quads = node._batchNode.textureAtlas.quads; + start = node.atlasIndex; + end = node.atlasIndex + node._totalParticles; + } else { + quads = this._quads; + start = 0; + end = node._totalParticles; + } + + for (var i = start; i < end; i++) { + if (!quads[i]) + quads[i] = cc.V3F_C4B_T2F_QuadZero(); + + // bottom-left vertex: + var selQuad = quads[i]; + selQuad.bl.texCoords.u = left; + selQuad.bl.texCoords.v = bottom; + // bottom-right vertex: + selQuad.br.texCoords.u = right; + selQuad.br.texCoords.v = bottom; + // top-left vertex: + selQuad.tl.texCoords.u = left; + selQuad.tl.texCoords.v = top; + // top-right vertex: + selQuad.tr.texCoords.u = right; + selQuad.tr.texCoords.v = top; + } + }; + + proto.setTotalParticles = function(){ + var node = this._node; + // If we are setting the total numer of particles to a number higher + // than what is allocated, we need to allocate new arrays + if (tp > node._allocatedParticles) { + var quadSize = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; + // Allocate new memory + this._indices = new Uint16Array(tp * 6); + var locQuadsArrayBuffer = new ArrayBuffer(tp * quadSize); + //TODO need fix + // Assign pointers + var locParticles = node._particles; + locParticles.length = 0; + var locQuads = this._quads; + locQuads.length = 0; + for (var j = 0; j < tp; j++) { + locParticles[j] = new cc.Particle(); + locQuads[j] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, locQuadsArrayBuffer, j * quadSize); + } + node._allocatedParticles = tp; + node._totalParticles = tp; + + // Init particles + if (node._batchNode) { + for (var i = 0; i < tp; i++) + locParticles[i].atlasIndex = i; + } + + this._quadsArrayBuffer = locQuadsArrayBuffer; + + node.initIndices(); + //if (cc.TEXTURE_ATLAS_USE_VAO) + // node._setupVBOandVAO(); + //else + this._setupVBO(); + + //set the texture coord + if(node._texture){ + node.initTexCoordsWithRect(cc.rect(0, 0, node._texture.width, node._texture.height)); + } + } else + node._totalParticles = tp; + node.resetSystem(); + }; + + proto.addParticle = function(){ + var node = this._node, + particles = node._particles; + return particles[node.particleCount]; + }; + + proto.initParticle = function(){ + var node = this._node; + var locRandomMinus11 = cc.randomMinus1To1; + // Color + var start, end; + var locStartColor = node._startColor, locStartColorVar = node._startColorVar; + var locEndColor = node._endColor, locEndColorVar = node._endColorVar; + start = { + r: cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255), + g: cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255), + b: cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255), + a: cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255) + }; + end = { + r: cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255), + g: cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255), + b: cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255), + a: cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255) + }; + return {start: start, end: end}; + }; + + proto.draw = function(ctx){ + if(!this._texture) + return; + var node = this._node; + var gl = ctx || cc._renderContext; + node._shaderProgram.use(); + node._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); + + cc.glBindTexture2D(node._texture); + cc.glBlendFuncForParticle(node._blendFunc.src, node._blendFunc.dst); + + //cc.assert(node._particleIdx == node.particleCount, "Abnormal error in particle quad"); + + // + // Using VBO without VAO + // + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, node._buffersVBO[0]); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, node._buffersVBO[1]); + gl.drawElements(gl.TRIANGLES, node._particleIdx * 6, gl.UNSIGNED_SHORT, 0); + }; + + proto._setupVBO = function(){ + var node = this; + var gl = cc._renderContext; + + //gl.deleteBuffer(this._buffersVBO[0]); + this._buffersVBO[0] = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, node._buffersVBO[0]); + gl.bufferData(gl.ARRAY_BUFFER, this._quadsArrayBuffer, gl.DYNAMIC_DRAW); + + this._buffersVBO[1] = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, node._buffersVBO[1]); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._indices, gl.STATIC_DRAW); + + //cc.checkGLErrorDebug(); + }; + + proto._allocMemory = function(){ + var node = this; + //cc.assert((!this._quads && !this._indices), "Memory already allocated"); + if(node._batchNode){ + cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"); + return false; + } + + var quadSize = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; + var totalParticles = node._totalParticles; + var locQuads = this._quads; + locQuads.length = 0; + this._indices = new Uint16Array(totalParticles * 6); + var locQuadsArrayBuffer = new ArrayBuffer(quadSize * totalParticles); + + for (var i = 0; i < totalParticles; i++) + locQuads[i] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, locQuadsArrayBuffer, i * quadSize); + if (!locQuads || !this._indices) { + cc.log("cocos2d: Particle system: not enough memory"); + return false; + } + this._quadsArrayBuffer = locQuadsArrayBuffer; + return true; + }; + + proto._setBlendAdditive = function(){ + var locBlendFunc = this._node._blendFunc; + if (this._texture && !this._texture.hasPremultipliedAlpha()) { + locBlendFunc.src = cc.SRC_ALPHA; + locBlendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + } else { + locBlendFunc.src = cc.BLEND_SRC; + locBlendFunc.dst = cc.BLEND_DST; + } + }; + + proto._initWithTotalParticles = function(){ + var node = this; + // allocating data space + if (!node._allocMemory()) + return false; + + node.initIndices(); + //if (cc.TEXTURE_ATLAS_USE_VAO) + // this._setupVBOandVAO(); + //else + node._setupVBO(); + + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + }; + + proto._updateDeltaColor = function(selParticle, dt){ + if (!this._node._dontTint) { + selParticle.color.r += selParticle.deltaColor.r * dt; + selParticle.color.g += selParticle.deltaColor.g * dt; + selParticle.color.b += selParticle.deltaColor.b * dt; + selParticle.color.a += selParticle.deltaColor.a * dt; + selParticle.isChangeColor = true; + } + }; + +})(); \ No newline at end of file From 6578cb14ea573e9eea658ef3cb9f8f6f6a684280 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 19 Nov 2014 15:03:42 +0800 Subject: [PATCH 0927/1564] ParticleBatchNode renderCmd --- cocos2d/particle/CCParticleBatchNode.js | 43 +------- .../particle/CCParticleBatchNodeRenderCmd.js | 101 ++++++++++++++---- 2 files changed, 88 insertions(+), 56 deletions(-) diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 8e34607d46..16ccd1910a 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -103,6 +103,8 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ } if(cc._renderType === cc._RENDER_TYPE_WEBGL) this._renderCmd = new cc.ParticleBatchNode.WebGLRenderCmd(this); + else + this._renderCmd = new cc.ParticleBatchNode.CanvasRenderCmd(this); }, /** @@ -118,8 +120,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ // no lazy alloc in this node this._children.length = 0; - if (cc._renderType === cc._RENDER_TYPE_WEBGL) - this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + this._renderCmd._initWithTexture(); return true; }, @@ -337,18 +338,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ draw:function (ctx) { - //cc.PROFILER_STOP("CCParticleBatchNode - draw"); - if (cc._renderType === cc._RENDER_TYPE_CANVAS) - return; - - if (this.textureAtlas.totalQuads == 0) - return; - - cc.nodeDrawSetup(this); - cc.glBlendFuncForParticle(this._blendFunc.src, this._blendFunc.dst); - this.textureAtlas.drawQuads(); - - //cc.PROFILER_STOP("CCParticleBatchNode - draw"); + this._renderCmd.draw(); }, /** @@ -406,30 +396,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx */ visit:function (ctx) { - if (cc._renderType === cc._RENDER_TYPE_CANVAS) - return; - - // CAREFUL: - // This visit is almost identical to cc.Node#visit - // with the exception that it doesn't call visit on it's children - // - // The alternative is to have a void cc.Sprite#visit, but - // although this is less mantainable, is faster - // - if (!this._visible) - return; - - var currentStack = cc.current_stack; - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); - currentStack.top = this._stackMatrix; - - this.transform(ctx); - //this.draw(ctx); - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - - cc.kmGLPopMatrix(); + this._renderCmd.visit(); }, _updateAllAtlasIndexes:function () { diff --git a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js index 7b40bd0d52..8d03078bd5 100644 --- a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js +++ b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js @@ -22,21 +22,86 @@ THE SOFTWARE. ****************************************************************************/ -cc.ParticleBatchNode.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -cc.ParticleBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.ParticleBatchNode.WebGLRenderCmd.prototype.constructor = cc.ParticleBatchNode.WebGLRenderCmd; - -cc.ParticleBatchNode.WebGLRenderCmd.prototype.rendering = function (ctx) { - var _t = this._node; - if (_t.textureAtlas.totalQuads == 0) - return; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); - _t.textureAtlas.drawQuads(); -}; \ No newline at end of file +/** + * cc.Layer's rendering objects of Canvas + */ +(function(){ + cc.ParticleBatchNode.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.ParticleBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ParticleBatchNode.CanvasRenderCmd; + + proto.rendering = + proto._initWithTexture = + proto.draw = + proto.visit = function(){}; +})(); + +/** + * cc.Layer's rendering objects of WebGL + */ +(function(){ + + cc.ParticleBatchNode.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.ParticleBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.ParticleBatchNode.WebGLRenderCmd; + + proto.rendering = function (ctx) { + var _t = this._node; + if (_t.textureAtlas.totalQuads == 0) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + _t.textureAtlas.drawQuads(); + }; + + proto._initWithTexture = function(){ + this._node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + }; + + proto.draw = function(){ + var ndoe = this._node; + //cc.PROFILER_STOP("CCParticleBatchNode - draw"); + if (ndoe.textureAtlas.totalQuads == 0) + return; + + cc.nodeDrawSetup(ndoe); + cc.glBlendFuncForParticle(ndoe._blendFunc.src, ndoe._blendFunc.dst); + ndoe.textureAtlas.drawQuads(); + + //cc.PROFILER_STOP("CCParticleBatchNode - draw"); + }; + + proto.visit = function(){ + var node = this._node; + // CAREFUL: + // This visit is almost identical to cc.Node#visit + // with the exception that it doesn't call visit on it's children + // + // The alternative is to have a void cc.Sprite#visit, but + // although this is less mantainable, is faster + // + if (!node._visible) + return; + + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(node._stackMatrix, currentStack.top); + currentStack.top = node._stackMatrix; + + node.transform(ctx); + //this.draw(ctx); + cc.renderer.pushRenderCommand(this); + + cc.kmGLPopMatrix(); + }; +})(); \ No newline at end of file From c472bf44b24fcd4e31ba9a58399effe05c44de17 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 19 Nov 2014 15:13:01 +0800 Subject: [PATCH 0928/1564] PhysicsDebugNode renderCmd --- .../particle/CCParticleBatchNodeRenderCmd.js | 4 +- .../physics/CCPhysicsDebugNodeRenderCmd.js | 88 +++++++++++-------- cocos2d/physics/CCPhysicsSprite.js | 32 +------ cocos2d/physics/CCPhysicsSpriteRenderCmd.js | 85 +++++++++++++----- 4 files changed, 117 insertions(+), 92 deletions(-) diff --git a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js index 8d03078bd5..3dd112eb74 100644 --- a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js +++ b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js @@ -23,7 +23,7 @@ ****************************************************************************/ /** - * cc.Layer's rendering objects of Canvas + * cc.ParticleBatchNode's rendering objects of Canvas */ (function(){ cc.ParticleBatchNode.CanvasRenderCmd = function(renderableObject){ @@ -41,7 +41,7 @@ })(); /** - * cc.Layer's rendering objects of WebGL + * cc.ParticleBatchNode's rendering objects of WebGL */ (function(){ diff --git a/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js b/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js index 18ff6ca1e6..adc0b8cfca 100644 --- a/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js +++ b/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js @@ -22,42 +22,52 @@ THE SOFTWARE. ****************************************************************************/ -cc.PhysicsDebugNode.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._buffer = renderableObject._buffer; - this._needDraw = true; -}; - -cc.PhysicsDebugNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.PhysicsDebugNode.CanvasRenderCmd.prototype.constructor = cc.PhysicsDebugNode.CanvasRenderCmd; - -cc.PhysicsDebugNode.CanvasRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ - var node = this._node; - if (!node._space) - return; - node._space.eachShape(cc.DrawShape.bind(node)); - node._space.eachConstraint(cc.DrawConstraint.bind(node)); - cc.DrawNode.CanvasRenderCmd.prototype.rendering.call(this, ctx, scaleX, scaleY); - node.clear(); -}; - -cc.PhysicsDebugNode.CanvasRenderCmd.prototype._drawDot = cc.DrawNode.CanvasRenderCmd.prototype._drawDot; -cc.PhysicsDebugNode.CanvasRenderCmd.prototype._drawSegment = cc.DrawNode.CanvasRenderCmd.prototype._drawSegment; -cc.PhysicsDebugNode.CanvasRenderCmd.prototype._drawPoly = cc.DrawNode.CanvasRenderCmd.prototype._drawPoly; - - -cc.PhysicsDebugNode.WebGLRenderCmd = function (renderableObject) { - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function (ctx) { - var node = this._node; - if (!node._space) - return; - - node._space.eachShape(cc.DrawShape.bind(node)); - node._space.eachConstraint(cc.DrawConstraint.bind(node)); - cc.DrawNode.prototype.draw.call(node); - node.clear(); -}; \ No newline at end of file +/** + * cc.PhysicsDebugNode's rendering objects of Canvas + */ +(function(){ + cc.PhysicsDebugNode.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._buffer = renderableObject._buffer; + this._needDraw = true; + }; + + var proto = cc.PhysicsDebugNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.PhysicsDebugNode.CanvasRenderCmd; + + proto.rendering = function(ctx, scaleX, scaleY){ + var node = this._node; + if (!node._space) + return; + node._space.eachShape(cc.DrawShape.bind(node)); + node._space.eachConstraint(cc.DrawConstraint.bind(node)); + cc.DrawNode.CanvasRenderCmd.prototype.rendering.call(this, ctx, scaleX, scaleY); + node.clear(); + }; + + proto._drawDot = cc.DrawNode.CanvasRenderCmd.prototype._drawDot; + proto._drawSegment = cc.DrawNode.CanvasRenderCmd.prototype._drawSegment; + proto._drawPoly = cc.DrawNode.CanvasRenderCmd.prototype._drawPoly; + +})(); + +/** + * cc.PhysicsDebugNode's rendering objects of WebGL + */ +(function(){ + cc.PhysicsDebugNode.WebGLRenderCmd = function (renderableObject) { + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var node = this._node; + if (!node._space) + return; + + node._space.eachShape(cc.DrawShape.bind(node)); + node._space.eachConstraint(cc.DrawConstraint.bind(node)); + cc.DrawNode.prototype.draw.call(node); + node.clear(); + }; +})(); \ No newline at end of file diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index d97b4e79bc..67c48fdc5a 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -401,37 +401,7 @@ _t._normalizedPositionDirty = false; } - if(cc._renderType === cc._RENDER_TYPE_CANVAS) - return this._nodeToParentTransformForCanvas(); - - var locBody = this._body, locAnchorPIP = this._anchorPointInPoints, locScaleX = this._scaleX, locScaleY = this._scaleY; - var x = locBody.p.x; - var y = locBody.p.y; - - if (this._ignoreAnchorPointForPosition) { - x += locAnchorPIP.x; - y += locAnchorPIP.y; - } - - // Make matrix - var radians = locBody.a; - var c = Math.cos(radians); - var s = Math.sin(radians); - - // Although scale is not used by physics engines, it is calculated just in case - // the sprite is animated (scaled up/down) using actions. - // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990 - if (!cc._rectEqualToZero(locAnchorPIP)) { - x += c * -locAnchorPIP.x * locScaleX + -s * -locAnchorPIP.y * locScaleY; - y += s * -locAnchorPIP.x * locScaleX + c * -locAnchorPIP.y * locScaleY; - } - - // Rot, Translate Matrix - this._transform = cc.affineTransformMake(c * locScaleX, s * locScaleX, - -s * locScaleY, c * locScaleY, - x, y); - - return this._transform; + return this._renderCmd._getNodeToParentTransform(); }, _nodeToParentTransformForCanvas: function () { diff --git a/cocos2d/physics/CCPhysicsSpriteRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteRenderCmd.js index 6945c7d861..0672409f8f 100644 --- a/cocos2d/physics/CCPhysicsSpriteRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteRenderCmd.js @@ -22,29 +22,74 @@ THE SOFTWARE. ****************************************************************************/ -cc.PhysicsSprite.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; +/** + * cc.PhysicsSprite's rendering objects of Canvas + */ +(function(){ + cc.PhysicsSprite.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; -cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.PhysicsSprite.CanvasRenderCmd.prototype.constructor = cc.PhysicsSprite.CanvasRenderCmd; + var proto = cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.PhysicsSprite.CanvasRenderCmd; -cc.PhysicsSprite.CanvasRenderCmd.prototype.rendering = function(){ - if (this._node.transform) - this._node.transform(); -}; + proto.rendering = function(){ + if (this._node.transform) + this._node.transform(); + }; -cc.PhysicsSprite.WebGLRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; + proto._getNodeToParentTransform = function(){ + return this._node._nodeToParentTransformForCanvas(); + }; +})(); -cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.PhysicsSprite.WebGLRenderCmd.prototype.constructor = cc.PhysicsSprite.WebGLRenderCmd; +/** + * cc.PhysicsSprite's rendering objects of WebGL + */ +(function(){ + cc.PhysicsSprite.WebGLRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; -cc.PhysicsSprite.WebGLRenderCmd.prototype.rendering = function(){ - if(this._node._transformForRenderer) - this._node._transformForRenderer(); -}; + var proto = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.PhysicsSprite.WebGLRenderCmd; + proto.rendering = function(){ + if(this._node._transformForRenderer) + this._node._transformForRenderer(); + }; + + proto._getNodeToParentTransform = function(){ + var locBody = this._body, locAnchorPIP = this._anchorPointInPoints, locScaleX = this._scaleX, locScaleY = this._scaleY; + var x = locBody.p.x; + var y = locBody.p.y; + + if (this._ignoreAnchorPointForPosition) { + x += locAnchorPIP.x; + y += locAnchorPIP.y; + } + + // Make matrix + var radians = locBody.a; + var c = Math.cos(radians); + var s = Math.sin(radians); + + // Although scale is not used by physics engines, it is calculated just in case + // the sprite is animated (scaled up/down) using actions. + // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990 + if (!cc._rectEqualToZero(locAnchorPIP)) { + x += c * -locAnchorPIP.x * locScaleX + -s * -locAnchorPIP.y * locScaleY; + y += s * -locAnchorPIP.x * locScaleX + c * -locAnchorPIP.y * locScaleY; + } + + // Rot, Translate Matrix + this._transform = cc.affineTransformMake(c * locScaleX, s * locScaleX, + -s * locScaleY, c * locScaleY, + x, y); + + return this._transform; + }; + +})(); \ No newline at end of file From 1e7682ce6d2955aaba781654e4cc7bfabac92b10 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 19 Nov 2014 15:18:56 +0800 Subject: [PATCH 0929/1564] Issue #2416: correct some mistakes for renderer --- cocos2d/core/base-nodes/CCNode.js | 4 +- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 19 ++++- cocos2d/core/labelttf/CCLabelTTF.js | 88 +++++--------------- cocos2d/core/labelttf/CCLabelTTFRenderCmd.js | 50 ++++++----- cocos2d/core/labelttf/LabelTTFWebGL.js | 53 ------------ cocos2d/core/sprites/CCSpriteRenderCmd.js | 14 ++-- moduleConfig.json | 1 - tools/build.xml | 1 - 8 files changed, 80 insertions(+), 150 deletions(-) delete mode 100644 cocos2d/core/labelttf/LabelTTFWebGL.js diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 88c7a84ac1..f13bfc94da 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2123,7 +2123,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @return {cc.GLProgram} The shader program currently used for this node */ getShaderProgram: function () { - return this._shaderProgram; + return this._renderCmd.getShaderProgram(); }, /** @@ -2139,7 +2139,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * node.setGLProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); */ setShaderProgram: function (newShaderProgram) { - this._shaderProgram = newShaderProgram; + this._renderCmd.setShaderProgram(newShaderProgram); }, /** diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index fdc92d2fce..4c0ad9c531 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -319,7 +319,7 @@ cc.Node.CanvasRenderCmd.prototype._updateDisplayColor = function(parentColor){ }; cc.Node.CanvasRenderCmd.prototype._updateDisplayOpacity = function(parentOpacity){ - this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.opacityDirty; + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; var node = this._node; var i, len, selChildren, item; @@ -386,6 +386,14 @@ cc.Node.CanvasRenderCmd.prototype.detachFromParent = function(){ } }; +cc.Node.CanvasRenderCmd.prototype.setShaderProgram = function(shaderProgram){ + //do nothing. +}; + +cc.Node.CanvasRenderCmd.prototype.getShaderProgram = function(){ + //do nothing. +}; + //util functions cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function(blendFunc){ if(!blendFunc) @@ -411,6 +419,7 @@ cc.Node.WebGLRenderCmd = function(renderable){ mat4.mat[10] = mat4.mat[15] = 1.0; this._transform4x4 = mat4; this._stackMatrix = new cc.kmMat4(); + this._shaderProgram = null; this._camera = null; }; @@ -541,3 +550,11 @@ cc.Node.WebGLRenderCmd.prototype.visit = function(){ cc.Node.WebGLRenderCmd.prototype.transform = function() { }; + +cc.Node.WebGLRenderCmd.prototype.setShaderProgram = function(shaderProgram){ + this._shaderProgram = shaderProgram; +}; + +cc.Node.WebGLRenderCmd.prototype.getShaderProgram = function(){ + return this._shaderProgram; +}; diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index e3d510ca69..3d8c9b77bb 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -141,8 +141,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return true; }, - _setUpdateTextureDirty: function(){ + _setUpdateTextureDirty: function () { this._renderCmdDiry = this._needUpdateTexture = true; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.textDirty); cc.renderer.pushDirtyNode(this._renderCmd); }, @@ -192,11 +193,11 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return ""; }, - getLineHiehgt: function(){ + getLineHiehgt: function () { return this._lineHeight || this._fontClientHeight; }, - setLineHeight: function(lineHeight){ + setLineHeight: function (lineHeight) { this._lineHeight = lineHeight; }, @@ -255,7 +256,15 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ * @param {cc.FontDefinition} textDefinition * @return {Boolean} */ - initWithStringAndTextDefinition: null, + initWithStringAndTextDefinition: function (text, textDefinition) { + // shader program + this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM)); + // prepare everything needed to render the label + this._updateWithTextDefinition(textDefinition, false); + // set the string + this.string = text; + return true; + }, /** * Sets the text definition used by this label @@ -287,14 +296,14 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ * labelttf.enableShadow(shadowColor, offset, blurRadius); */ enableShadow: function (a, b, c, d) { - if(a.r != null && a.g != null && a.b != null && a.a != null){ + if (a.r != null && a.g != null && a.b != null && a.a != null) { this._enableShadow(a, b, c); - }else{ + } else { this._enableShadowNoneColor(a, b, c, d) } }, - _enableShadowNoneColor: function(shadowOffsetX, shadowOffsetY, shadowOpacity, shadowBlur){ + _enableShadowNoneColor: function (shadowOffsetX, shadowOffsetY, shadowOpacity, shadowBlur) { shadowOpacity = shadowOpacity || 0.5; if (false === this._shadowEnabled) this._shadowEnabled = true; @@ -315,8 +324,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._setUpdateTextureDirty(); }, - _enableShadow: function(shadowColor, offset, blurRadius){ - if(!this._shadowColor){ + _enableShadow: function (shadowColor, offset, blurRadius) { + if (!this._shadowColor) { this._shadowColor = cc.color(255, 255, 255, 128); } this._shadowColor.r = shadowColor.r; @@ -623,10 +632,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ */ setDimensions: function (dim, height) { var width; - if(height === undefined){ + if (height === undefined) { width = dim.width; height = dim.height; - }else + } else width = dim; if (width != this._dimensions.width || height != this._dimensions.height) { @@ -726,76 +735,23 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return cc.Sprite.prototype._getHeight.call(this); }, - /*visit: function (ctx) { - if (!this._string || this._string == "") - return; - if (this._needUpdateTexture) { - this._needUpdateTexture = false; - this._renderCmd._updateTexture(); - } - var context = ctx || cc._renderContext; - cc.Sprite.prototype.visit.call(this, context); - },*/ - setTextureRect: function (rect, rotated, untrimmedSize) { //set needConvert to false cc.Sprite.prototype.setTextureRect.call(this, rect, rotated, untrimmedSize, false); }, - _createRenderCmd: function(){ - if(cc._renderType === cc._RENDER_TYPE_CANVAS) + _createRenderCmd: function () { + if (cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.LabelTTF.CanvasRenderCmd(this); else return new cc.LabelTTF.WebGLRenderCmd(this); } }); -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - var _p = cc.LabelTTF.prototype; - - _p._transformForRenderer = function(){ - if (this._needUpdateTexture) { - this._needUpdateTexture = false; - this._renderCmd._updateTexture(); - } - cc.Node.prototype._transformForRenderer.call(this); - }; - - _p.initWithStringAndTextDefinition = function (text, textDefinition) { - // prepare everything needed to render the label - this._updateWithTextDefinition(textDefinition, false); - - // set the string - this.string = text; - - return true; - }; - - _p = null; -} else { - cc.assert(cc.isFunction(cc._tmp.WebGLLabelTTF), cc._LogInfos.MissingFile, "LabelTTFWebGL.js"); - cc._tmp.WebGLLabelTTF(); - delete cc._tmp.WebGLLabelTTF; -} - cc.assert(cc.isFunction(cc._tmp.PrototypeLabelTTF), cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js"); cc._tmp.PrototypeLabelTTF(); delete cc._tmp.PrototypeLabelTTF; -cc.LabelTTF._textAlign = ["left", "center", "right"]; -cc.LabelTTF._textBaseline = ["top", "middle", "bottom"]; - -//check the first character -cc.LabelTTF.wrapInspection = true; - -//Support: English French German -//Other as Oriental Language -cc.LabelTTF._wordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)/; -cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>、‘“》?。,!]/; -cc.LabelTTF._lastWordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)$/; -cc.LabelTTF._lastEnglish = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/; -cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; - // Only support style in this format: "18px Verdana" or "18px 'Helvetica Neue'" cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/; diff --git a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js index 143c730f91..9a5cfd9a70 100644 --- a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js @@ -22,6 +22,20 @@ THE SOFTWARE. ****************************************************************************/ +cc.LabelTTF._textAlign = ["left", "center", "right"]; +cc.LabelTTF._textBaseline = ["top", "middle", "bottom"]; + +//check the first character +cc.LabelTTF.wrapInspection = true; + +//Support: English French German +//Other as Oriental Language +cc.LabelTTF._wordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)/; +cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>、‘“》?。,!]/; +cc.LabelTTF._lastWordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)$/; +cc.LabelTTF._lastEnglish = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/; +cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; + cc.LabelTTF.RenderCmd = function(){ this._fontClientHeight = 18; this._fontStyleStr = ""; @@ -42,11 +56,12 @@ cc.LabelTTF.RenderCmd.prototype._getLabelContext = function () { if (this._labelContext) return this._labelContext; + var node = this._node; if (!this._labelCanvas) { var locCanvas = cc.newElement("canvas"); var labelTexture = new cc.Texture2D(); labelTexture.initWithElement(locCanvas); - this.texture = labelTexture; + node.setTexture(labelTexture); this._labelCanvas = locCanvas; } this._labelContext = this._labelCanvas.getContext("2d"); @@ -80,6 +95,7 @@ cc.LabelTTF.RenderCmd.prototype._updateTexture = function () { node._texture && node._texture.handleLoadedTexture(); node.setTextureRect(cc.rect(0, 0, width, height)); + this._dirtyFlag ^= cc.Node._dirtyFlags.textDirty; return true; }; @@ -129,9 +145,9 @@ cc.LabelTTF.RenderCmd.prototype._updateTTF = function(){ if (locDimensionsWidth === 0) { if (this._isMultiLine) locSize = cc.size(0 | (Math.max.apply(Math, locLineWidth) + locStrokeShadowOffsetX), - 0 | ((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); + 0 | ((node._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); else - locSize = cc.size(0 | (this._measure(this._string) + locStrokeShadowOffsetX), 0 | (this._fontClientHeight + locStrokeShadowOffsetY)); + locSize = cc.size(0 | (this._measure(node._string) + locStrokeShadowOffsetX), 0 | (node._fontClientHeight + locStrokeShadowOffsetY)); } else { if (node._dimensions.height === 0) { if (this._isMultiLine) @@ -159,27 +175,27 @@ cc.LabelTTF.RenderCmd.prototype._drawTTFInCanvas = function (context) { var node = this._node; var locStrokeShadowOffsetX = node._strokeShadowOffsetX, locStrokeShadowOffsetY = node._strokeShadowOffsetY; var locContentSizeHeight = node._contentSize.height - locStrokeShadowOffsetY, locVAlignment = node._vAlignment, locHAlignment = node._hAlignment, - locFontHeight = this._fontClientHeight, locStrokeSize = node._strokeSize; + locFontHeight = node._fontClientHeight, locStrokeSize = node._strokeSize; context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); //this is fillText for canvas - if (context.font != this._fontStyleStr) - context.font = this._fontStyleStr; - context.fillStyle = this._fillColorStr; + if (context.font != node._fontStyleStr) + context.font = node._fontStyleStr; + context.fillStyle = node._fillColorStr; var xOffset = 0, yOffset = 0; //stroke style setup var locStrokeEnabled = node._strokeEnabled; if (locStrokeEnabled) { context.lineWidth = locStrokeSize * 2; - context.strokeStyle = this._strokeColorStr; + context.strokeStyle = node._strokeColorStr; } //shadow style setup if (node._shadowEnabled) { var locShadowOffset = node._shadowOffset; - context.shadowColor = this._shadowColorStr; + context.shadowColor = node._shadowColorStr; context.shadowOffsetX = locShadowOffset.x; context.shadowOffsetY = -locShadowOffset.y; context.shadowBlur = node._shadowBlur; @@ -192,7 +208,7 @@ cc.LabelTTF.RenderCmd.prototype._drawTTFInCanvas = function (context) { //lineHiehgt var lineHeight = node.getLineHiehgt(); - var transformTop = (lineHeight - this._fontClientHeight) / 2; + var transformTop = (lineHeight - node._fontClientHeight) / 2; if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) xOffset += locContentWidth; @@ -216,20 +232,15 @@ cc.LabelTTF.RenderCmd.prototype._drawTTFInCanvas = function (context) { } } else { if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) { - if (locStrokeEnabled) - context.strokeText(this._string, xOffset, yOffset); - context.fillText(this._string, xOffset, yOffset); + //do nothing } else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_TOP) { yOffset -= locContentSizeHeight; - if (locStrokeEnabled) - context.strokeText(this._string, xOffset, yOffset); - context.fillText(this._string, xOffset, yOffset); } else { yOffset -= locContentSizeHeight * 0.5; - if (locStrokeEnabled) - context.strokeText(this._string, xOffset, yOffset); - context.fillText(this._string, xOffset, yOffset); } + if (locStrokeEnabled) + context.strokeText(node._string, xOffset, yOffset); + context.fillText(node._string, xOffset, yOffset); } }; @@ -354,6 +365,7 @@ cc.LabelTTF.CanvasRenderCmd.prototype.updateStatus = function(){ if(this._dirtyFlag & cc.Node._dirtyFlags.textDirty){ //update texture for labelTTF + this._updateTexture(); } if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ diff --git a/cocos2d/core/labelttf/LabelTTFWebGL.js b/cocos2d/core/labelttf/LabelTTFWebGL.js deleted file mode 100644 index b206d83d5f..0000000000 --- a/cocos2d/core/labelttf/LabelTTFWebGL.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -cc._tmp.WebGLLabelTTF = function () { - var _p = cc.LabelTTF.prototype; - - _p._transformForRenderer = function(){ - if (this._needUpdateTexture) { - this._needUpdateTexture = false; - this._updateTexture(); - } - cc.Node.prototype._transformForRenderer.call(this); - }; - - _p.initWithStringAndTextDefinition = function (text, textDefinition) { - if (!cc.Sprite.prototype.init.call(this)) - return false; - - // shader program - this.shaderProgram = cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM); - - // prepare everything needed to render the label - this._updateWithTextDefinition(textDefinition, false); - - // set the string - this.string = text; - - return true; - }; -}; \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index 8411226534..7fc3c442de 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -113,20 +113,20 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { if (node._texture && (locTextureCoord.width === 0 || locTextureCoord.height === 0)) return; - if (!locTextureCoord.validRect && node._displayedOpacity === 0) + if (!locTextureCoord.validRect && this._displayedOpacity === 0) return; //draw nothing if (node._texture && !node._texture._isLoaded) //set texture but the texture isn't loaded. return; - var t = node._transformWorld, + var t = this._worldTransform, locX = node._offsetPosition.x, locY = -node._offsetPosition.y - node._rect.height, locWidth = node._rect.width, locHeight = node._rect.height, image, curColor, contentSize; - var blendChange = (node._blendFuncStr !== "source-over"), alpha = (node._displayedOpacity / 255); + var blendChange = (this._blendFuncStr !== "source-over"), alpha = (this._displayedOpacity / 255); if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); @@ -135,7 +135,7 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { //transform context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); if (blendChange) - context.globalCompositeOperation = node._blendFuncStr; + context.globalCompositeOperation = this._blendFuncStr; if (node._flippedX) { locX = -locX - locWidth; @@ -155,7 +155,7 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); context.restore(); } else { - if (node._colorized) { + if (this._colorized) { context.drawImage(image, 0, 0, @@ -191,7 +191,7 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { } else { if (blendChange) { context.save(); - context.globalCompositeOperation = node._blendFuncStr; + context.globalCompositeOperation = this._blendFuncStr; } context.globalAlpha = alpha; @@ -204,7 +204,7 @@ cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); context.restore(); } else { - if (node._colorized) { + if (this._colorized) { context.drawImage(image, 0, 0, diff --git a/moduleConfig.json b/moduleConfig.json index b1a04756ed..fa8a620cdd 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -113,7 +113,6 @@ "cocos2d/core/CCDrawingPrimitivesCanvas.js", "cocos2d/core/CCDrawingPrimitivesWebGL.js", - "cocos2d/core/labelttf/LabelTTFWebGL.js", "cocos2d/core/labelttf/LabelTTFPropertyDefine.js", "cocos2d/core/labelttf/CCLabelTTF.js", "cocos2d/core/labelttf/CCLabelTTFRenderCmd.js", diff --git a/tools/build.xml b/tools/build.xml index 289b07cac5..e4f7597a1e 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -72,7 +72,6 @@ - From 0f1bf6c7137e944da4f9eb875b25e6cc297c803b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 19 Nov 2014 15:55:30 +0800 Subject: [PATCH 0930/1564] Fixed name error --- cocos2d/core/labelttf/CCLabelTTF.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 31b8d25fbc..7fc4511674 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -217,7 +217,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._setColorsString(); }, - getLineHiehgt: function(){ + getLineHeight: function(){ return this._lineHeight || this._fontClientHeight; }, @@ -764,7 +764,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ var locContentWidth = this._contentSize.width - locStrokeShadowOffsetX; //lineHiehgt - var lineHeight = this.getLineHiehgt(); + var lineHeight = this.getLineHeight(); var transformTop = (lineHeight - this._fontClientHeight) / 2; if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) @@ -938,9 +938,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ } else { if (this._dimensions.height === 0) { if (this._isMultiLine) - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((this.getLineHiehgt() * this._strings.length) + locStrokeShadowOffsetY)); + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((this.getLineHeight() * this._strings.length) + locStrokeShadowOffsetY)); else - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this.getLineHiehgt() + locStrokeShadowOffsetY)); + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this.getLineHeight() + locStrokeShadowOffsetY)); } else { //dimension is already set, contentSize must be same as dimension locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (this._dimensions.height + locStrokeShadowOffsetY)); From a52414ec6f420a28b22f861a835899326940987e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 20 Nov 2014 11:04:54 +0800 Subject: [PATCH 0931/1564] Progress Timer renderCmd --- cocos2d/progress-timer/CCProgressTimer.js | 463 +----------- .../CCProgressTimerRenderCmd.js | 700 ++++++++++++++---- 2 files changed, 586 insertions(+), 577 deletions(-) diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index a539e89db5..0755faad4a 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -164,34 +164,15 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ return cc.p(0,0); }, - _vertexDataCount:0, - _vertexData:null, - _vertexArrayBuffer:null, - _vertexWebGLBuffer:null, - _vertexDataDirty:false, - /** * constructor of cc.cc.ProgressTimer * @function * @param {cc.Sprite} sprite */ - ctor: null, - - _ctorForCanvas: function (sprite) { + ctor: function(){ cc.Node.prototype.ctor.call(this); - - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._percentage = 0.0; - this._midPoint = cc.p(0, 0); - this._barChangeRate = cc.p(0, 0); - this._reverseDirection = false; - - this._sprite = null; - sprite && this._initWithSpriteForCanvas(sprite); - }, - - _ctorForWebGL: function (sprite) { cc.Node.prototype.ctor.call(this); + this._type = cc.ProgressTimer.TYPE_RADIAL; this._percentage = 0.0; this._midPoint = cc.p(0, 0); @@ -199,14 +180,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._reverseDirection = false; this._sprite = null; + this.sprite && this._renderCmd.initWithSprite(this.sprite); - this._vertexWebGLBuffer = cc._renderContext.createBuffer(); - this._vertexDataCount = 0; - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataDirty = false; - - sprite && this._initWithSpriteForWebGL(sprite); }, /** @@ -248,22 +223,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @function * @param {Boolean} reverse */ - setReverseProgress:null, - - _setReverseProgressForCanvas:function (reverse) { - if (this._reverseDirection !== reverse) - this._reverseDirection = reverse; - }, - - _setReverseProgressForWebGL:function (reverse) { - if (this._reverseDirection !== reverse) { - this._reverseDirection = reverse; - - // release all previous information - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; - } + setReverseProgress: function(reverse){ + this._renderCmd.setReverseProgress(reverse); }, /** @@ -271,30 +232,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @function * @param {cc.Sprite} sprite */ - setSprite:null, - - _setSpriteForCanvas:function (sprite) { - if (this._sprite != sprite) { - this._sprite = sprite; - this._renderCmd._sprite = sprite; - this.width = this._sprite.width; - this.height = this._sprite.height; - } - }, - - _setSpriteForWebGL:function (sprite) { - if (sprite && this._sprite != sprite) { - this._sprite = sprite; - this.width = sprite.width; - this.height = sprite.height; - - // Everytime we set a new sprite, we free the current vertex data - if (this._vertexData) { - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; - } - } + setSprite: function(sprite){ + this._renderCmd.setSprite(sprite); }, /** @@ -302,25 +241,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @function * @param {cc.ProgressTimer.TYPE_RADIAL|cc.ProgressTimer.TYPE_BAR} type */ - setType:null, - - _setTypeForCanvas:function (type) { - if (type !== this._type){ - this._type = type; - this._renderCmd._type = type; - } - }, - - _setTypeForWebGL:function (type) { - if (type !== this._type) { - // release all previous information - if (this._vertexData) { - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; - } - this._type = type; - } + setType: function(type){ + this._renderCmd.setType(type); }, /** @@ -328,21 +250,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @function * @param {Boolean} reverse */ - setReverseDirection: null, - - _setReverseDirectionForCanvas: function (reverse) { - if (this._reverseDirection !== reverse) - this._reverseDirection = reverse; - }, - - _setReverseDirectionForWebGL: function (reverse) { - if (this._reverseDirection !== reverse) { - this._reverseDirection = reverse; - //release all previous information - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; - } + setReverseDirection: function(reverse){ + this._renderCmd.setReverseDirection(reverse); }, /** @@ -384,39 +293,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {cc.Sprite} sprite * @return {Boolean} */ - initWithSprite:null, - - _initWithSpriteForCanvas:function (sprite) { - this.percentage = 0; - this.anchorX = 0.5; - this.anchorY = 0.5; - - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._reverseDirection = false; - this.midPoint = cc.p(0.5, 0.5); - this.barChangeRate = cc.p(1, 1); - this.sprite = sprite; - - return true; - }, - - _initWithSpriteForWebGL:function (sprite) { - this.percentage = 0; - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; - this.anchorX = 0.5; - this.anchorY = 0.5; - - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._reverseDirection = false; - this.midPoint = cc.p(0.5, 0.5); - this.barChangeRate = cc.p(1, 1); - this.sprite = sprite; - - //shader program - this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - return true; + initWithSprite: function(sprite){ + this._renderCmd.initWithSprite(sprite); }, /** @@ -424,44 +302,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @function * @param {CanvasRenderingContext2D} ctx */ - draw:null, - - _drawForWebGL:function (ctx) { - var context = ctx || cc._renderContext; - if (!this._vertexData || !this._sprite) - return; - - cc.nodeDrawSetup(this); - - var blendFunc = this._sprite.getBlendFunc(); - cc.glBlendFunc(blendFunc.src, blendFunc.dst); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - cc.glBindTexture2D(this._sprite.texture); - - context.bindBuffer(context.ARRAY_BUFFER, this._vertexWebGLBuffer); - if(this._vertexDataDirty){ - context.bufferData(context.ARRAY_BUFFER, this._vertexArrayBuffer, context.DYNAMIC_DRAW); - this._vertexDataDirty = false; - } - var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); - 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.ProgressTimer.TYPE_RADIAL) - context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount); - else if (this._type == cc.ProgressTimer.TYPE_BAR) { - if (!this._reverseDirection) - context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount); - else { - context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount / 2); - context.drawArrays(context.TRIANGLE_STRIP, 4, this._vertexDataCount / 2); - // 2 draw calls - cc.g_NumberOfDraws++; - } - } - cc.g_NumberOfDraws++; + draw: function(ctx){ + this._renderCmd.draw(ctx); }, /** @@ -552,30 +394,30 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ // The size of the vertex data is the index from the hitpoint // the 3 is for the m_tMidpoint, 12 o'clock point and hitpoint position. var sameIndexCount = true; - if (this._vertexDataCount != index + 3) { + if (this._renderCmd._vertexDataCount != index + 3) { sameIndexCount = false; - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; + this._renderCmd._vertexData = null; + this._renderCmd._vertexArrayBuffer = null; + this._renderCmd._vertexDataCount = 0; } - if (!this._vertexData) { - this._vertexDataCount = index + 3; - var locCount = this._vertexDataCount, vertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - this._vertexArrayBuffer = new ArrayBuffer(locCount * vertexDataLen); + if (!this._renderCmd._vertexData) { + this._renderCmd._vertexDataCount = index + 3; + var locCount = this._renderCmd._vertexDataCount, vertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; + this._renderCmd._vertexArrayBuffer = new ArrayBuffer(locCount * vertexDataLen); var locData = []; for (i = 0; i < locCount; i++) - locData[i] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, i * vertexDataLen); + locData[i] = new cc.V2F_C4B_T2F(null, null, null, this._renderCmd._vertexArrayBuffer, i * vertexDataLen); - this._vertexData = locData; - if(!this._vertexData){ + this._renderCmd._vertexData = locData; + if(!this._renderCmd._vertexData){ cc.log( "cc.ProgressTimer._updateRadial() : Not enough memory"); return; } } this._updateColor(); - var locVertexData = this._vertexData; + var locVertexData = this._renderCmd._vertexData; if (!sameIndexCount) { // First we populate the array with the m_tMidpoint, then all // vertices/texcoords/colors of the 12 'o clock start and edges and the hitpoint @@ -593,234 +435,12 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ } // hitpoint will go last - locVertexData[this._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(hit); - locVertexData[this._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(hit); - }, - - /** - *

    - * Update does the work of mapping the texture onto the triangles for the bar
    - * It now doesn't occur the cost of free/alloc data every update cycle.
    - * It also only changes the percentage point but no other points if they have not been modified.
    - *
    - * It now deals with flipped texture. If you run into this problem, just use the
    - * sprite property and enable the methods flipX, flipY.
    - *

    - * @private - */ - _updateBar:function () { - if (!this._sprite) - return; - - var i; - var alpha = this._percentage / 100.0; - var locBarChangeRate = this._barChangeRate; - var alphaOffset = cc.pMult(cc.p((1.0 - locBarChangeRate.x) + alpha * locBarChangeRate.x, - (1.0 - locBarChangeRate.y) + alpha * locBarChangeRate.y), 0.5); - var min = cc.pSub(this._midPoint, alphaOffset); - var max = cc.pAdd(this._midPoint, alphaOffset); - - if (min.x < 0) { - max.x += -min.x; - min.x = 0; - } - - if (max.x > 1) { - min.x -= max.x - 1; - max.x = 1; - } - - if (min.y < 0) { - max.y += -min.y; - min.y = 0; - } - - if (max.y > 1) { - min.y -= max.y - 1; - max.y = 1; - } - - var locVertexData; - if (!this._reverseDirection) { - if (!this._vertexData) { - this._vertexDataCount = 4; - var vertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT, locCount = 4; - this._vertexArrayBuffer = new ArrayBuffer(locCount * vertexDataLen); - this._vertexData = []; - for (i = 0; i < locCount; i++) - this._vertexData[i] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, i * vertexDataLen); - } - - locVertexData = this._vertexData; - // TOPLEFT - locVertexData[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); - locVertexData[0].vertices = this._vertexFromAlphaPoint(cc.p(min.x, max.y)); - - // BOTLEFT - locVertexData[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); - locVertexData[1].vertices = this._vertexFromAlphaPoint(cc.p(min.x, min.y)); - - // TOPRIGHT - locVertexData[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); - locVertexData[2].vertices = this._vertexFromAlphaPoint(cc.p(max.x, max.y)); - - // BOTRIGHT - locVertexData[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); - locVertexData[3].vertices = this._vertexFromAlphaPoint(cc.p(max.x, min.y)); - } else { - if (!this._vertexData) { - this._vertexDataCount = 8; - var rVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT, rLocCount = 8; - this._vertexArrayBuffer = new ArrayBuffer(rLocCount * rVertexDataLen); - var rTempData = []; - for (i = 0; i < rLocCount; i++) - rTempData[i] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, i * rVertexDataLen); - // TOPLEFT 1 - rTempData[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 1)); - rTempData[0].vertices = this._vertexFromAlphaPoint(cc.p(0, 1)); - - // BOTLEFT 1 - rTempData[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 0)); - rTempData[1].vertices = this._vertexFromAlphaPoint(cc.p(0, 0)); - - // TOPRIGHT 2 - rTempData[6].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 1)); - rTempData[6].vertices = this._vertexFromAlphaPoint(cc.p(1, 1)); - - // BOTRIGHT 2 - rTempData[7].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 0)); - rTempData[7].vertices = this._vertexFromAlphaPoint(cc.p(1, 0)); - - this._vertexData = rTempData; - } - - locVertexData = this._vertexData; - // TOPRIGHT 1 - locVertexData[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); - locVertexData[2].vertices = this._vertexFromAlphaPoint(cc.p(min.x, max.y)); - - // BOTRIGHT 1 - locVertexData[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); - locVertexData[3].vertices = this._vertexFromAlphaPoint(cc.p(min.x, min.y)); - - // TOPLEFT 2 - locVertexData[4].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); - locVertexData[4].vertices = this._vertexFromAlphaPoint(cc.p(max.x, max.y)); - - // BOTLEFT 2 - locVertexData[5].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); - locVertexData[5].vertices = this._vertexFromAlphaPoint(cc.p(max.x, min.y)); - } - this._updateColor(); + locVertexData[this._renderCmd._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(hit); + locVertexData[this._renderCmd._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(hit); }, - _updateColor:function () { - if (!this._sprite || !this._vertexData) - return; - - var sc = this._sprite.quad.tl.colors; - var locVertexData = this._vertexData; - for (var i = 0, len = this._vertexDataCount; i < len; ++i) - locVertexData[i].colors = sc; - this._vertexDataDirty = true; - }, - - _updateProgress:null, - - _updateProgressForCanvas:function () { - var locSprite = this._sprite; - var sw = locSprite.width, sh = locSprite.height; - var locMidPoint = this._midPoint; - var locCmd = this._renderCmd; - - if (this._type == cc.ProgressTimer.TYPE_RADIAL) { - locCmd._radius = Math.round(Math.sqrt(sw * sw + sh * sh)); - var locStartAngle, locEndAngle, locCounterClockWise = false, locOrigin = locCmd._origin; - locOrigin.x = sw * locMidPoint.x; - locOrigin.y = -sh * locMidPoint.y; - - if (this._reverseDirection) { - locEndAngle = 270; - locStartAngle = 270 - 3.6 * this._percentage; - } else { - locStartAngle = -90; - locEndAngle = -90 + 3.6 * this._percentage; - } - - if (locSprite._flippedX) { - locOrigin.x -= sw * (this._midPoint.x * 2); - locStartAngle= -locStartAngle; - locEndAngle= -locEndAngle; - locStartAngle -= 180; - locEndAngle -= 180; - locCounterClockWise = !locCounterClockWise; - } - if (locSprite._flippedY) { - locOrigin.y+=sh*(this._midPoint.y*2); - locCounterClockWise = !locCounterClockWise; - locStartAngle= -locStartAngle; - locEndAngle= -locEndAngle; - } - - locCmd._startAngle = locStartAngle; - locCmd._endAngle = locEndAngle; - locCmd._counterClockWise = locCounterClockWise; - } else { - var locBarChangeRate = this._barChangeRate; - var percentageF = this._percentage / 100; - var locBarRect = locCmd._barRect; - - var drawedSize = cc.size((sw * (1 - locBarChangeRate.x)), (sh * (1 - locBarChangeRate.y))); - var drawingSize = cc.size((sw - drawedSize.width) * percentageF, (sh - drawedSize.height) * percentageF); - var currentDrawSize = cc.size(drawedSize.width + drawingSize.width, drawedSize.height + drawingSize.height); - - var startPoint = cc.p(sw * locMidPoint.x, sh * locMidPoint.y); - - var needToLeft = startPoint.x - currentDrawSize.width / 2; - if ((locMidPoint.x > 0.5) && (currentDrawSize.width / 2 >= sw - startPoint.x)) { - needToLeft = sw - currentDrawSize.width; - } - - var needToTop = startPoint.y - currentDrawSize.height / 2; - if ((locMidPoint.y > 0.5) && (currentDrawSize.height / 2 >= sh - startPoint.y)) { - needToTop = sh - currentDrawSize.height; - } - - //left pos - locBarRect.x = 0; - var flipXNeed = 1; - if (locSprite._flippedX) { - locBarRect.x -= currentDrawSize.width; - flipXNeed = -1; - } - - if (needToLeft > 0) - locBarRect.x += needToLeft * flipXNeed; - - //right pos - locBarRect.y = 0; - var flipYNeed = 1; - if (locSprite._flippedY) { - locBarRect.y += currentDrawSize.height; - flipYNeed = -1; - } - - if (needToTop > 0) - locBarRect.y -= needToTop * flipYNeed; - - //clip width and clip height - locBarRect.width = currentDrawSize.width; - locBarRect.height = -currentDrawSize.height; - } - }, - - _updateProgressForWebGL:function () { - var locType = this._type; - if(locType === cc.ProgressTimer.TYPE_RADIAL) - this._updateRadial(); - else if(locType === cc.ProgressTimer.TYPE_BAR) - this._updateBar(); - this._vertexDataDirty = true; + _updateProgress: function(){ + this._renderCmd._updateProgress(); }, _createRenderCmd: function(){ @@ -831,27 +451,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ } }); -var _p = cc.ProgressTimer.prototype; -if(cc._renderType == cc._RENDER_TYPE_WEBGL){ - _p.ctor = _p._ctorForWebGL; - _p.setReverseProgress = _p._setReverseProgressForWebGL; - _p.setSprite = _p._setSpriteForWebGL; - _p.setType = _p._setTypeForWebGL; - _p.setReverseDirection = _p._setReverseDirectionForWebGL; - _p.initWithSprite = _p._initWithSpriteForWebGL; - _p.draw = _p._drawForWebGL; - _p._updateProgress = _p._updateProgressForWebGL; -} else { - _p.ctor = _p._ctorForCanvas; - _p.setReverseProgress = _p._setReverseProgressForCanvas; - _p.setSprite = _p._setSpriteForCanvas; - _p.setType = _p._setTypeForCanvas; - _p.setReverseDirection = _p._setReverseDirectionForCanvas; - _p.initWithSprite = _p._initWithSpriteForCanvas; - _p.draw = _p._drawForCanvas; - _p._updateProgress = cc.ProgressTimer.prototype._updateProgressForCanvas; -} - // Extended properties /** @expose */ _p.midPoint; diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js index 5623d3ec67..4a19ff5e91 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -22,148 +22,558 @@ THE SOFTWARE. ****************************************************************************/ -cc.ProgressTimer.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; - - this._PI180 = Math.PI / 180; - this._sprite = null; - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._barRect = cc.rect(0, 0, 0, 0); - this._origin = cc.p(0, 0); - this._radius = 0; - this._startAngle = 270; - this._endAngle = 270; - this._counterClockWise = false; -}; - -cc.ProgressTimer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.ProgressTimer.CanvasRenderCmd.prototype.constructor = cc.ProgressTimer.CanvasRenderCmd; - -cc.ProgressTimer.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, node = this._node, locSprite = this._sprite; - - var locTextureCoord = locSprite._renderCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; - - if (locTextureCoord.width === 0 || locTextureCoord.height === 0) - return; - if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) - return; - - var t = node._transformWorld; - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - if (locSprite._blendFuncStr != "source-over") - context.globalCompositeOperation = locSprite._blendFuncStr; - context.globalAlpha = alpha; - - var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; - var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; - locDrawSizeCanvas.width = locRect.width * scaleX; - locDrawSizeCanvas.height = locRect.height * scaleY; - - if (locSprite._flippedX) { - flipXOffset = -locOffsetPosition.x - locRect.width; - context.scale(-1, 1); - } - if (locSprite._flippedY) { - flipYOffset = locOffsetPosition.y; - context.scale(1, -1); - } - - flipXOffset *= scaleX; - flipYOffset *= scaleY; - - //clip - if (this._type == cc.ProgressTimer.TYPE_BAR) { - var locBarRect = this._barRect; - context.beginPath(); - context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); - context.clip(); - context.closePath(); - } else if (this._type == cc.ProgressTimer.TYPE_RADIAL) { - var locOriginX = this._origin.x * scaleX; - var locOriginY = this._origin.y * scaleY; - context.beginPath(); - context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); - context.lineTo(locOriginX, locOriginY); - context.clip(); - context.closePath(); - } - - //draw sprite - var image = locSprite._texture.getHtmlElementObj(); - if (locSprite._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); - } else { - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height - ); - } - - context.restore(); - cc.g_NumberOfDraws++; -}; - - -cc.ProgressTimer.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); -}; - -cc.ProgressTimer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.ProgressTimer.WebGLRenderCmd.prototype.constructor = cc.ProgressTimer.WebGLRenderCmd; - -cc.ProgressTimer.WebGLRenderCmd.prototype.rendering = function (ctx) { - var _t = this._node; - var context = ctx || cc._renderContext; - if (!_t._vertexData || !_t._sprite) - return; - - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - - var blendFunc = _t._sprite.getBlendFunc(); - cc.glBlendFunc(blendFunc.src, blendFunc.dst); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - cc.glBindTexture2D(_t._sprite.texture); - - context.bindBuffer(context.ARRAY_BUFFER, _t._vertexWebGLBuffer); - if (_t._vertexDataDirty) { - context.bufferData(context.ARRAY_BUFFER, _t._vertexArrayBuffer, context.DYNAMIC_DRAW); - _t._vertexDataDirty = false; - } - var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); - 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 (_t._type === cc.ProgressTimer.TYPE_RADIAL) - context.drawArrays(context.TRIANGLE_FAN, 0, _t._vertexDataCount); - else if (_t._type == cc.ProgressTimer.TYPE_BAR) { - if (!_t._reverseDirection) - context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount); - else { - context.drawArrays(context.TRIANGLE_STRIP, 0, _t._vertexDataCount / 2); - context.drawArrays(context.TRIANGLE_STRIP, 4, _t._vertexDataCount / 2); - // 2 draw calls - cc.g_NumberOfDraws++; - } - } - cc.g_NumberOfDraws++; -}; \ No newline at end of file +/** + * cc.ProgressTimer's rendering objects of Canvas + */ +(function(){ + + cc.ProgressTimer.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + + this._PI180 = Math.PI / 180; + this._barRect = cc.rect(0, 0, 0, 0); + this._origin = cc.p(0, 0); + this._radius = 0; + this._startAngle = 270; + this._endAngle = 270; + this._counterClockWise = false; + }; + + var proto = cc.ProgressTimer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ProgressTimer.CanvasRenderCmd; + + proto.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, node = this._node, locSprite = node._sprite; + + var locTextureCoord = locSprite._renderCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + + if (locTextureCoord.width === 0 || locTextureCoord.height === 0) + return; + if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) + return; + + var t = node._transformWorld; + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (locSprite._blendFuncStr != "source-over") + context.globalCompositeOperation = locSprite._blendFuncStr; + context.globalAlpha = alpha; + + var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; + var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; + locDrawSizeCanvas.width = locRect.width * scaleX; + locDrawSizeCanvas.height = locRect.height * scaleY; + + if (locSprite._flippedX) { + flipXOffset = -locOffsetPosition.x - locRect.width; + context.scale(-1, 1); + } + if (locSprite._flippedY) { + flipYOffset = locOffsetPosition.y; + context.scale(1, -1); + } + + flipXOffset *= scaleX; + flipYOffset *= scaleY; + + //clip + if (node._type == cc.ProgressTimer.TYPE_BAR) { + var locBarRect = this._barRect; + context.beginPath(); + context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); + context.clip(); + context.closePath(); + } else if (node._type == cc.ProgressTimer.TYPE_RADIAL) { + var locOriginX = this._origin.x * scaleX; + var locOriginY = this._origin.y * scaleY; + context.beginPath(); + context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); + context.lineTo(locOriginX, locOriginY); + context.clip(); + context.closePath(); + } + + //draw sprite + var image = locSprite._texture.getHtmlElementObj(); + if (locSprite._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + flipXOffset, flipYOffset, + locDrawSizeCanvas.width, + locDrawSizeCanvas.height + ); + } + + context.restore(); + cc.g_NumberOfDraws++; + }; + + proto.setReverseProgress = function(reverse){ + var node = this._node; + if (node._reverseDirection !== reverse) + node._reverseDirection = reverse; + }; + + proto.setSprite = function(sprite){ + var node = this._node; + if (node._sprite != sprite) { + node._sprite = sprite; + node.width = node._sprite.width; + node.height = node._sprite.height; + } + }; + + proto.setType = function(type){ + var node = this._node; + if (type !== node._type){ + node._type = type; + node._renderCmd._type = type; + } + }; + + proto.setReverseDirection = function(reverse){ + var node = this._node; + if (node._reverseDirection !== reverse) + node._reverseDirection = reverse; + }; + + proto.initWithSprite = function(sprite){ + var node = this._node; + node.percentage = 0; + node.anchorX = 0.5; + node.anchorY = 0.5; + + node._type = cc.ProgressTimer.TYPE_RADIAL; + node._reverseDirection = false; + node.midPoint = cc.p(0.5, 0.5); + node.barChangeRate = cc.p(1, 1); + node.sprite = sprite; + + return true; + }; + + proto.draw = function(){}; + + proto._updateProgress = function(){ + var node = this._node; + var locSprite = node._sprite; + var sw = locSprite.width, sh = locSprite.height; + var locMidPoint = node._midPoint; + var locCmd = this; + + if (node._type == cc.ProgressTimer.TYPE_RADIAL) { + locCmd._radius = Math.round(Math.sqrt(sw * sw + sh * sh)); + var locStartAngle, locEndAngle, locCounterClockWise = false, locOrigin = locCmd._origin; + locOrigin.x = sw * locMidPoint.x; + locOrigin.y = -sh * locMidPoint.y; + + if (node._reverseDirection) { + locEndAngle = 270; + locStartAngle = 270 - 3.6 * node._percentage; + } else { + locStartAngle = -90; + locEndAngle = -90 + 3.6 * node._percentage; + } + + if (locSprite._flippedX) { + locOrigin.x -= sw * (node._midPoint.x * 2); + locStartAngle= -locStartAngle; + locEndAngle= -locEndAngle; + locStartAngle -= 180; + locEndAngle -= 180; + locCounterClockWise = !locCounterClockWise; + } + if (locSprite._flippedY) { + locOrigin.y+=sh*(node._midPoint.y*2); + locCounterClockWise = !locCounterClockWise; + locStartAngle= -locStartAngle; + locEndAngle= -locEndAngle; + } + + locCmd._startAngle = locStartAngle; + locCmd._endAngle = locEndAngle; + locCmd._counterClockWise = locCounterClockWise; + } else { + var locBarChangeRate = node._barChangeRate; + var percentageF = node._percentage / 100; + var locBarRect = locCmd._barRect; + + var drawedSize = cc.size((sw * (1 - locBarChangeRate.x)), (sh * (1 - locBarChangeRate.y))); + var drawingSize = cc.size((sw - drawedSize.width) * percentageF, (sh - drawedSize.height) * percentageF); + var currentDrawSize = cc.size(drawedSize.width + drawingSize.width, drawedSize.height + drawingSize.height); + + var startPoint = cc.p(sw * locMidPoint.x, sh * locMidPoint.y); + + var needToLeft = startPoint.x - currentDrawSize.width / 2; + if ((locMidPoint.x > 0.5) && (currentDrawSize.width / 2 >= sw - startPoint.x)) { + needToLeft = sw - currentDrawSize.width; + } + + var needToTop = startPoint.y - currentDrawSize.height / 2; + if ((locMidPoint.y > 0.5) && (currentDrawSize.height / 2 >= sh - startPoint.y)) { + needToTop = sh - currentDrawSize.height; + } + + //left pos + locBarRect.x = 0; + var flipXNeed = 1; + if (locSprite._flippedX) { + locBarRect.x -= currentDrawSize.width; + flipXNeed = -1; + } + + if (needToLeft > 0) + locBarRect.x += needToLeft * flipXNeed; + + //right pos + locBarRect.y = 0; + var flipYNeed = 1; + if (locSprite._flippedY) { + locBarRect.y += currentDrawSize.height; + flipYNeed = -1; + } + + if (needToTop > 0) + locBarRect.y -= needToTop * flipYNeed; + + //clip width and clip height + locBarRect.width = currentDrawSize.width; + locBarRect.height = -currentDrawSize.height; + } + }; +})(); + + +/** + * cc.ProgressTimer's rendering objects of WebGL + */ +(function(){ + cc.ProgressTimer.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + + this._PI180 = Math.PI / 180; + this._type = cc.ProgressTimer.TYPE_RADIAL; + this._barRect = cc.rect(0, 0, 0, 0); + this._origin = cc.p(0, 0); + this._radius = 0; + this._startAngle = 270; + this._endAngle = 270; + this._counterClockWise = false; + + this._vertexWebGLBuffer = cc._renderContext.createBuffer(); + this._vertexDataCount = 0; + this._vertexData = null; + this._vertexArrayBuffer = null; + this._vertexDataDirty = false; + }; + + var proto = cc.ProgressTimer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.ProgressTimer.WebGLRenderCmd; + + proto.rendering = function (ctx) { + var _t = this._node; + var context = ctx || cc._renderContext; + if (!this._vertexData || !_t._sprite) + return; + + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + var blendFunc = _t._sprite.getBlendFunc(); + cc.glBlendFunc(blendFunc.src, blendFunc.dst); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + cc.glBindTexture2D(_t._sprite.texture); + + context.bindBuffer(context.ARRAY_BUFFER, this._vertexWebGLBuffer); + if (this._vertexDataDirty) { + context.bufferData(context.ARRAY_BUFFER, this._vertexArrayBuffer, context.DYNAMIC_DRAW); + this._vertexDataDirty = false; + } + var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); + 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.ProgressTimer.TYPE_RADIAL) + context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount); + else if (this._type == cc.ProgressTimer.TYPE_BAR) { + if (!_t._reverseDirection) + context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount); + else { + context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount / 2); + context.drawArrays(context.TRIANGLE_STRIP, 4, this._vertexDataCount / 2); + // 2 draw calls + cc.g_NumberOfDraws++; + } + } + cc.g_NumberOfDraws++; + }; + + proto.setReverseProgress = function(reverse){ + var node = this._node; + if (node._reverseDirection !== reverse) { + node._reverseDirection = reverse; + + // release all previous information + this._vertexData = null; + this._vertexArrayBuffer = null; + this._vertexDataCount = 0; + } + }; + + proto.setSprite = function(sprite){ + var node = this._node; + if (sprite && node._sprite != sprite) { + node._sprite = sprite; + node.width = sprite.width; + node.height = sprite.height; + + // Everytime we set a new sprite, we free the current vertex data + if (this._vertexData) { + this._vertexData = null; + this._vertexArrayBuffer = null; + this._vertexDataCount = 0; + } + } + }; + + proto.setType = function(type){ + var node = this._node; + if (type !== this._type) { + // release all previous information + if (this._vertexData) { + this._vertexData = null; + node._vertexArrayBuffer = null; + this._vertexDataCount = 0; + } + node._type = type; + } + }; + + proto.setReverseDirection = function(reverse){ + var node = this._node; + if (node._reverseDirection !== reverse) { + node._reverseDirection = reverse; + //release all previous information + this._vertexData = null; + this._vertexArrayBuffer = null; + this._vertexDataCount = 0; + } + }; + + proto.initWithSprite = function(sprite){ + var node = this._node; + node.percentage = 0; + this._vertexData = null; + this._vertexArrayBuffer = null; + this._vertexDataCount = 0; + node.anchorX = 0.5; + node.anchorY = 0.5; + + node._type = cc.ProgressTimer.TYPE_RADIAL; + node._reverseDirection = false; + node.midPoint = cc.p(0.5, 0.5); + node.barChangeRate = cc.p(1, 1); + node.sprite = sprite; + + //shader program + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + return true; + }; + + proto.draw = function(ctx){ + var node = this._node; + var context = ctx || cc._renderContext; + if (!this._vertexData || !node._sprite) + return; + + cc.nodeDrawSetup(node); + + var blendFunc = node._sprite.getBlendFunc(); + cc.glBlendFunc(blendFunc.src, blendFunc.dst); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + cc.glBindTexture2D(node._sprite.texture); + + context.bindBuffer(context.ARRAY_BUFFER, this._vertexWebGLBuffer); + if(this._vertexDataDirty){ + context.bufferData(context.ARRAY_BUFFER, this._vertexArrayBuffer, context.DYNAMIC_DRAW); + this._vertexDataDirty = false; + } + var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); + 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 (node._type === cc.ProgressTimer.TYPE_RADIAL) + context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount); + else if (node._type == cc.ProgressTimer.TYPE_BAR) { + if (!node._reverseDirection) + context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount); + else { + context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount / 2); + context.drawArrays(context.TRIANGLE_STRIP, 4, this._vertexDataCount / 2); + // 2 draw calls + cc.g_NumberOfDraws++; + } + } + cc.g_NumberOfDraws++; + }; + + proto._updateProgress = function(){ + var node = this._node; + var locType = node._type; + if(locType === cc.ProgressTimer.TYPE_RADIAL) + node._updateRadial(); + else if(locType === cc.ProgressTimer.TYPE_BAR) + node._updateBar(); + this._vertexDataDirty = true; + }; + + /** + *

    + * Update does the work of mapping the texture onto the triangles for the bar
    + * It now doesn't occur the cost of free/alloc data every update cycle.
    + * It also only changes the percentage point but no other points if they have not been modified.
    + *
    + * It now deals with flipped texture. If you run into this problem, just use the
    + * sprite property and enable the methods flipX, flipY.
    + *

    + * @private + */ + proto._updateBar = function(){ + var node = this._node; + if (!node._sprite) + return; + + var i; + var alpha = node._percentage / 100.0; + var locBarChangeRate = node._barChangeRate; + var alphaOffset = cc.pMult(cc.p((1.0 - locBarChangeRate.x) + alpha * locBarChangeRate.x, + (1.0 - locBarChangeRate.y) + alpha * locBarChangeRate.y), 0.5); + var min = cc.pSub(node._midPoint, alphaOffset); + var max = cc.pAdd(node._midPoint, alphaOffset); + + if (min.x < 0) { + max.x += -min.x; + min.x = 0; + } + + if (max.x > 1) { + min.x -= max.x - 1; + max.x = 1; + } + + if (min.y < 0) { + max.y += -min.y; + min.y = 0; + } + + if (max.y > 1) { + min.y -= max.y - 1; + max.y = 1; + } + + var locVertexData; + if (!this._reverseDirection) { + if (!this._vertexData) { + this._vertexDataCount = 4; + var vertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT, locCount = 4; + this._vertexArrayBuffer = new ArrayBuffer(locCount * vertexDataLen); + this._vertexData = []; + for (i = 0; i < locCount; i++) + this._vertexData[i] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, i * vertexDataLen); + } + + locVertexData = this._vertexData; + // TOPLEFT + locVertexData[0].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); + locVertexData[0].vertices = node._vertexFromAlphaPoint(cc.p(min.x, max.y)); + + // BOTLEFT + locVertexData[1].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); + locVertexData[1].vertices = node._vertexFromAlphaPoint(cc.p(min.x, min.y)); + + // TOPRIGHT + locVertexData[2].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); + locVertexData[2].vertices = node._vertexFromAlphaPoint(cc.p(max.x, max.y)); + + // BOTRIGHT + locVertexData[3].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); + locVertexData[3].vertices = node._vertexFromAlphaPoint(cc.p(max.x, min.y)); + } else { + if (!this._vertexData) { + this._vertexDataCount = 8; + var rVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT, rLocCount = 8; + this._vertexArrayBuffer = new ArrayBuffer(rLocCount * rVertexDataLen); + var rTempData = []; + for (i = 0; i < rLocCount; i++) + rTempData[i] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, i * rVertexDataLen); + // TOPLEFT 1 + rTempData[0].texCoords = node._textureCoordFromAlphaPoint(cc.p(0, 1)); + rTempData[0].vertices = node._vertexFromAlphaPoint(cc.p(0, 1)); + + // BOTLEFT 1 + rTempData[1].texCoords = node._textureCoordFromAlphaPoint(cc.p(0, 0)); + rTempData[1].vertices = node._vertexFromAlphaPoint(cc.p(0, 0)); + + // TOPRIGHT 2 + rTempData[6].texCoords = node._textureCoordFromAlphaPoint(cc.p(1, 1)); + rTempData[6].vertices = node._vertexFromAlphaPoint(cc.p(1, 1)); + + // BOTRIGHT 2 + rTempData[7].texCoords = node._textureCoordFromAlphaPoint(cc.p(1, 0)); + rTempData[7].vertices = node._vertexFromAlphaPoint(cc.p(1, 0)); + + this._vertexData = rTempData; + } + + locVertexData = this._vertexData; + // TOPRIGHT 1 + locVertexData[2].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); + locVertexData[2].vertices = node._vertexFromAlphaPoint(cc.p(min.x, max.y)); + + // BOTRIGHT 1 + locVertexData[3].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); + locVertexData[3].vertices = node._vertexFromAlphaPoint(cc.p(min.x, min.y)); + + // TOPLEFT 2 + locVertexData[4].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); + locVertexData[4].vertices = node._vertexFromAlphaPoint(cc.p(max.x, max.y)); + + // BOTLEFT 2 + locVertexData[5].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); + locVertexData[5].vertices = node._vertexFromAlphaPoint(cc.p(max.x, min.y)); + } + this._updateColor(); + }; + + proto._updateColor = function(){ + var node = this._node; + if (!node._sprite || !this._vertexData) + return; + + var sc = node._sprite.quad.tl.colors; + var locVertexData = this._vertexData; + for (var i = 0, len = this._vertexDataCount; i < len; ++i) + locVertexData[i].colors = sc; + this._vertexDataDirty = true; + }; +})(); \ No newline at end of file From 54a6ec74172e4f65a0f4e8b71f606ad6f1405427 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 20 Nov 2014 14:42:30 +0800 Subject: [PATCH 0932/1564] AtlasNode renderCmd, LabelAtlas renderCmd --- cocos2d/core/base-nodes/CCAtlasNode.js | 225 ++------------- .../core/base-nodes/CCAtlasNodeRenderCmd.js | 259 ++++++++++++++++-- cocos2d/labels/CCLabelAtlas.js | 182 +----------- cocos2d/labels/CCLabelAtlasRenderCmd.js | 206 ++++++++++++++ 4 files changed, 476 insertions(+), 396 deletions(-) create mode 100644 cocos2d/labels/CCLabelAtlasRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index e21235f17a..5973d19a1a 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -87,6 +87,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ if(cc._renderType === cc._RENDER_TYPE_WEBGL) this._renderCmd = new cc.AtlasNode.WebGLRenderCmd(this); + else + this._renderCmd = new cc.AtlasNode.CanvasRenderCmd(this); }, /** @@ -220,53 +222,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @param {Number} itemsToRender The quantity of tiles to be rendered * @return {Boolean} */ - initWithTexture: null, - - _initWithTextureForCanvas: function (texture, tileWidth, tileHeight, itemsToRender) { - this._itemWidth = tileWidth; - this._itemHeight = tileHeight; - - this._opacityModifyRGB = true; - this._originalTexture = texture; - if (!this._originalTexture) { - cc.log(cc._LogInfos.AtlasNode__initWithTexture); - return false; - } - this._textureForCanvas = this._originalTexture; - this._calculateMaxItems(); - - this.quadsToDraw = itemsToRender; - return true; - }, - - _initWithTextureForWebGL: function (texture, tileWidth, tileHeight, itemsToRender) { - this._itemWidth = tileWidth; - this._itemHeight = tileHeight; - this._colorUnmodified = cc.color.WHITE; - this._opacityModifyRGB = true; - - this._blendFunc.src = cc.BLEND_SRC; - this._blendFunc.dst = cc.BLEND_DST; - - var locRealColor = this._realColor; - this._colorF32Array = new Float32Array([locRealColor.r / 255.0, locRealColor.g / 255.0, locRealColor.b / 255.0, this._realOpacity / 255.0]); - this.textureAtlas = new cc.TextureAtlas(); - this.textureAtlas.initWithTexture(texture, itemsToRender); - - if (!this.textureAtlas) { - cc.log(cc._LogInfos.AtlasNode__initWithTexture); - return false; - } - - this._updateBlendFunc(); - this._updateOpacityModifyRGB(); - this._calculateMaxItems(); - this.quadsToDraw = itemsToRender; - - //shader stuff - this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); - this._uniformColor = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), "u_color"); - return true; + initWithTexture: function(texture, tileWidth, tileHeight, itemsToRender){ + this._renderCmd.initWithTexture(texture, tileWidth, tileHeight, itemsToRender); }, /** @@ -274,16 +231,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @function * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ - draw: null, - - _drawForWebGL: function (ctx) { - var context = ctx || cc._renderContext; - cc.nodeDrawSetup(this); - cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - if(this._uniformColor && this._colorF32Array){ - context.uniform4fv(this._uniformColor, this._colorF32Array); - this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0); - } + draw: function(ctx){ + this._renderCmd.draw(ctx); }, /** @@ -291,58 +240,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @function * @param {cc.Color} color Color object created with cc.color(r, g, b). */ - setColor: null, - - _setColorForCanvas: function (color3) { - var locRealColor = this._realColor; - if ((locRealColor.r == color3.r) && (locRealColor.g == color3.g) && (locRealColor.b == color3.b)) - return; - var temp = cc.color(color3.r, color3.g, color3.b); - this._colorUnmodified = color3; - - if (this._opacityModifyRGB) { - var locDisplayedOpacity = this._displayedOpacity; - temp.r = temp.r * locDisplayedOpacity / 255; - temp.g = temp.g * locDisplayedOpacity / 255; - temp.b = temp.b * locDisplayedOpacity / 255; - } -// cc.Node.prototype.setColor.call(this, color3); - this._changeTextureColor(); - }, - - _changeTextureColor: function(){ - var locTexture = this.getTexture(); - if (locTexture && this._originalTexture) { - var element = this._originalTexture.getHtmlElementObj(); - if(!element) - return; - var locElement = locTexture.getHtmlElementObj(); - var textureRect = cc.rect(0, 0, element.width, element.height); - if (locElement instanceof HTMLCanvasElement) - cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect, locElement); - else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.setTexture(locTexture); - } - } - }, - - _setColorForWebGL: function (color3) { - var temp = cc.color(color3.r, color3.g, color3.b); - this._colorUnmodified = color3; - var locDisplayedOpacity = this._displayedOpacity; - if (this._opacityModifyRGB) { - temp.r = temp.r * locDisplayedOpacity / 255; - temp.g = temp.g * locDisplayedOpacity / 255; - temp.b = temp.b * locDisplayedOpacity / 255; - } - cc.Node.prototype.setColor.call(this, color3); - var locDisplayedColor = this._displayedColor; - this._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, - locDisplayedColor.b / 255.0, locDisplayedOpacity / 255.0]); + setColor: function(color){ + this._renderCmd.setColor(color); }, /** @@ -351,26 +250,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @param {Number} opacity The opacity value */ setOpacity: function (opacity) { - }, - - _setOpacityForCanvas: function (opacity) { - cc.Node.prototype.setOpacity.call(this, opacity); - // special opacity for premultiplied textures - if (this._opacityModifyRGB) { - this.color = this._colorUnmodified; - } - }, - - _setOpacityForWebGL: function (opacity) { - cc.Node.prototype.setOpacity.call(this, opacity); - // special opacity for premultiplied textures - if (this._opacityModifyRGB) { - this.color = this._colorUnmodified; - } else { - var locDisplayedColor = this._displayedColor; - this._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, - locDisplayedColor.b / 255.0, this._displayedOpacity / 255.0]); - } + this._renderCmd.setOpacity(opacity); }, /** @@ -378,14 +258,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @function * @return {cc.Texture2D} */ - getTexture: null, - - _getTextureForCanvas: function () { - return this._textureForCanvas; - }, - - _getTextureForWebGL: function () { - return this.textureAtlas.texture; + getTexture: function(){ + this._renderCmd.getTexture(); }, /** @@ -393,36 +267,12 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @function * @param {cc.Texture2D} texture The new texture */ - setTexture: null, - - _setTextureForCanvas: function (texture) { - this._textureForCanvas = texture; - }, - - _setTextureForWebGL: function (texture) { - this.textureAtlas.texture = texture; - this._updateBlendFunc(); - this._updateOpacityModifyRGB(); - }, - - _calculateMaxItems: null, - - _calculateMaxItemsForCanvas: function () { - var selTexture = this.texture; - var size = selTexture.getContentSize(); - - this._itemsPerColumn = 0 | (size.height / this._itemHeight); - this._itemsPerRow = 0 | (size.width / this._itemWidth); + setTexture: function(texture){ + this._renderCmd.setTexture(texture); }, - _calculateMaxItemsForWebGL: function () { - var selTexture = this.texture; - var size = selTexture.getContentSize(); - if (this._ignoreContentScaleFactor) - size = selTexture.getContentSizeInPixels(); - - this._itemsPerColumn = 0 | (size.height / this._itemHeight); - this._itemsPerRow = 0 | (size.width / this._itemWidth); + _calculateMaxItems: function(){ + this._renderCmd._calculateMaxItems(); }, _updateBlendFunc: function () { @@ -441,48 +291,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ } }); -var _p = cc.AtlasNode.prototype; -if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - _p.initWithTexture = _p._initWithTextureForWebGL; - _p.draw = _p._drawForWebGL; - _p.setColor = _p._setColorForWebGL; - _p.setOpacity = _p._setOpacityForWebGL; - _p.getTexture = _p._getTextureForWebGL; - _p.setTexture = _p._setTextureForWebGL; - _p._calculateMaxItems = _p._calculateMaxItemsForWebGL; -} else { - _p.initWithTexture = _p._initWithTextureForCanvas; - _p.draw = cc.Node.prototype.draw; - _p.setColor = _p._setColorForCanvas; - _p.setOpacity = _p._setOpacityForCanvas; - _p.getTexture = _p._getTextureForCanvas; - _p.setTexture = _p._setTextureForCanvas; - _p._calculateMaxItems = _p._calculateMaxItemsForCanvas; - if(!cc.sys._supportCanvasNewBlendModes) - _p._changeTextureColor = function(){ - var locElement, locTexture = this.getTexture(); - if (locTexture && this._originalTexture) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; - var element = this._originalTexture.getHtmlElementObj(); - var cacheTextureForColor = cc.textureCache.getTextureColors(element); - if (cacheTextureForColor) { - var textureRect = cc.rect(0, 0, element.width, element.height); - if (locElement instanceof HTMLCanvasElement) - cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect, locElement); - else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.setTexture(locTexture); - } - } - } - }; -} - // Override properties cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); @@ -510,5 +318,4 @@ _p.quadsToDraw; */ cc.AtlasNode.create = function (tile, tileWidth, tileHeight, itemsToRender) { return new cc.AtlasNode(tile, tileWidth, tileHeight, itemsToRender); -}; - +}; \ No newline at end of file diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js index 38b7ea0875..14f23b863a 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js @@ -22,23 +22,242 @@ THE SOFTWARE. ****************************************************************************/ -cc.AtlasNode.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.AtlasNode.WebGLRenderCmd.prototype.constructor = cc.AtlasNode.WebGLRenderCmd; - -cc.AtlasNode.WebGLRenderCmd.prototype.rendering = function (ctx) { - var context = ctx || cc._renderContext, node = this._node; - - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); - - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - if (node._uniformColor && node._colorF32Array) { - context.uniform4fv(node._uniformColor, node._colorF32Array); - node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); - } -}; \ No newline at end of file +/** + * cc.AtlasNode's rendering objects of Canvas + */ +(function(){ + cc.AtlasNode.CanvasRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.AtlasNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.AtlasNode.CanvasRenderCmd; + + proto.initWithTexture = function(texture, tileWidth, tileHeight, itemsToRender){ + var node = this._node; + node._itemWidth = tileWidth; + node._itemHeight = tileHeight; + + node._opacityModifyRGB = true; + node._originalTexture = texture; + if (!node._originalTexture) { + cc.log(cc._LogInfos.AtlasNode__initWithTexture); + return false; + } + node._textureForCanvas = node._originalTexture; + node._calculateMaxItems(); + + node.quadsToDraw = itemsToRender; + return true; + }; + + proto.draw = cc.Node.prototype.draw; + + proto.setColor = function(color3){ + var node = this; + var locRealColor = node._realColor; + if ((locRealColor.r == color3.r) && (locRealColor.g == color3.g) && (locRealColor.b == color3.b)) + return; + var temp = cc.color(color3.r, color3.g, color3.b); + this._colorUnmodified = color3; + + if (node._opacityModifyRGB) { + var locDisplayedOpacity = node._displayedOpacity; + temp.r = temp.r * locDisplayedOpacity / 255; + temp.g = temp.g * locDisplayedOpacity / 255; + temp.b = temp.b * locDisplayedOpacity / 255; + } +// cc.Node.prototype.setColor.call(this, color3); + this._changeTextureColor(); + }; + + if(cc.sys._supportCanvasNewBlendModes) + proto._changeTextureColor = function(){ + var node = this._node; + var locTexture = node.getTexture(); + if (locTexture && node._originalTexture) { + var element = node._originalTexture.getHtmlElementObj(); + if(!element) + return; + var locElement = locTexture.getHtmlElementObj(); + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement) + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, node._colorUnmodified, textureRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, node._colorUnmodified, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.setTexture(locTexture); + } + } + }; + else + proto._changeTextureColor = function(){ + var node = this._node; + var locElement, locTexture = node.getTexture(); + if (locTexture && node._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + var element = node._originalTexture.getHtmlElementObj(); + var cacheTextureForColor = cc.textureCache.getTextureColors(element); + if (cacheTextureForColor) { + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement) + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, node._displayedColor, textureRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, node._displayedColor, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.setTexture(locTexture); + } + } + } + }; + + proto.setOpacity = function(opacity){ + var node = this._node; + cc.Node.prototype.setOpacity.call(node, opacity); + // special opacity for premultiplied textures + if (node._opacityModifyRGB) { + node.color = node._colorUnmodified; + } + }; + + proto.getTexture = function(){ + return this._node._textureForCanvas; + }; + + proto.setTexture = function (texture) { + this._node._textureForCanvas = texture; + }; + + proto._calculateMaxItems = function(){ + var node = this._node; + var selTexture = node.texture; + var size = selTexture.getContentSize(); + + node._itemsPerColumn = 0 | (size.height / node._itemHeight); + node._itemsPerRow = 0 | (size.width / node._itemWidth); + }; +})(); + +/** + * cc.AtlasNode's rendering objects of Canvas + */ +(function(){ + cc.AtlasNode.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.AtlasNode.WebGLRenderCmd; + + proto.rendering = function (ctx) { + var context = ctx || cc._renderContext, node = this._node; + + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + if (node._uniformColor && node._colorF32Array) { + context.uniform4fv(node._uniformColor, node._colorF32Array); + node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); + } + }; + + proto.initWithTexture = function(texture, tileWidth, tileHeight, itemsToRender){ + var node = this._node; + node._itemWidth = tileWidth; + node._itemHeight = tileHeight; + node._colorUnmodified = cc.color.WHITE; + node._opacityModifyRGB = true; + + node._blendFunc.src = cc.BLEND_SRC; + node._blendFunc.dst = cc.BLEND_DST; + + var locRealColor = node._realColor; + node._colorF32Array = new Float32Array([locRealColor.r / 255.0, locRealColor.g / 255.0, locRealColor.b / 255.0, node._realOpacity / 255.0]); + node.textureAtlas = new cc.TextureAtlas(); + node.textureAtlas.initWithTexture(texture, itemsToRender); + + if (!node.textureAtlas) { + cc.log(cc._LogInfos.AtlasNode__initWithTexture); + return false; + } + + node._updateBlendFunc(); + node._updateOpacityModifyRGB(); + node._calculateMaxItems(); + node.quadsToDraw = itemsToRender; + + //shader stuff + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); + node._uniformColor = cc._renderContext.getUniformLocation(node.shaderProgram.getProgram(), "u_color"); + return true; + }; + + proto.draw = function(ctx){ + var context = ctx || cc._renderContext; + cc.nodeDrawSetup(this); + cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); + if(this._uniformColor && this._colorF32Array){ + context.uniform4fv(this._uniformColor, this._colorF32Array); + this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0); + } + }; + + proto.setColor = function(color3){ + var temp = cc.color(color3.r, color3.g, color3.b); + this._colorUnmodified = color3; + var locDisplayedOpacity = this._displayedOpacity; + if (this._opacityModifyRGB) { + temp.r = temp.r * locDisplayedOpacity / 255; + temp.g = temp.g * locDisplayedOpacity / 255; + temp.b = temp.b * locDisplayedOpacity / 255; + } + cc.Node.prototype.setColor.call(this, color3); + var locDisplayedColor = this._displayedColor; + this._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, + locDisplayedColor.b / 255.0, locDisplayedOpacity / 255.0]); + }; + + proto.setOpacity = function(opacity){ + var node = this._node; + cc.Node.prototype.setOpacity.call(node, opacity); + // special opacity for premultiplied textures + if (node._opacityModifyRGB) { + node.color = node._colorUnmodified; + } else { + var locDisplayedColor = node._displayedColor; + node._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, + locDisplayedColor.b / 255.0, node._displayedOpacity / 255.0]); + } + }; + + proto.getTexture = function(){ + return this._node.textureAtlas.texture; + }; + + proto.setTexture = function(texture){ + var node = this._node; + node.textureAtlas.texture = texture; + node._updateBlendFunc(); + node._updateOpacityModifyRGB(); + }; + + proto._calculateMaxItems = function(){ + var node = this._node; + var selTexture = node.texture; + var size = selTexture.getContentSize(); + if (node._ignoreContentScaleFactor) + size = selTexture.getContentSizeInPixels(); + + node._itemsPerColumn = 0 | (size.height / node._itemHeight); + node._itemsPerRow = 0 | (size.width / node._itemWidth); + }; +})(); \ No newline at end of file diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 8ee45fac95..24cf5c94b1 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -75,6 +75,12 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ this._cascadeOpacityEnabled = true; this._cascadeColorEnabled = true; + + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this._renderCmd = new cc.LabelAtlas.WebGLRenderCmd(this); + else + this._renderCmd = new cc.LabelAtlas.CanvasRenderCmd(this); + charMapFile && cc.LabelAtlas.prototype.initWithString.call(this, strText, charMapFile, itemWidth, itemHeight, startCharMap); }, @@ -184,127 +190,17 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ } }, - _addChildForCanvas: function(child, zOrder, tag){ - child._lateChild = true; - cc.Node.prototype.addChild.call(this, child, zOrder, tag); + addChild: function(child, localZOrder, tag){ + this._renderCmd._addChild(child); + cc.Node.prototype.addChild.call(this, child, localZOrder, tag); }, /** * Atlas generation * @function */ - updateAtlasValues: null, - - _updateAtlasValuesForCanvas: function () { - var locString = this._string || ""; - var n = locString.length; - var texture = this.texture; - var locItemWidth = this._itemWidth , locItemHeight = this._itemHeight; //needn't multiply cc.contentScaleFactor(), because sprite's draw will do this - - for (var i = 0; i < n; i++) { - var a = locString.charCodeAt(i) - this._mapStartChar.charCodeAt(0); - var row = parseInt(a % this._itemsPerRow, 10); - var col = parseInt(a / this._itemsPerRow, 10); - - var rect = cc.rect(row * locItemWidth, col * locItemHeight, locItemWidth, locItemHeight); - var c = locString.charCodeAt(i); - var fontChar = this.getChildByTag(i); - if (!fontChar) { - fontChar = new cc.Sprite(); - if (c == 32) { - fontChar.init(); - fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); - } else - fontChar.initWithTexture(texture, rect); - - cc.Node.prototype.addChild.call(this, fontChar, 0, i); - } else { - if (c == 32) { - fontChar.init(); - fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); - } else { - // reusing fonts - fontChar.initWithTexture(texture, rect); - // restore to default in case they were modified - fontChar.visible = true; - } - } - fontChar.setPosition(i * locItemWidth + locItemWidth / 2, locItemHeight / 2); - } - }, - - _updateAtlasValuesForWebGL: function () { - var locString = this._string; - var n = locString.length; - var locTextureAtlas = this.textureAtlas; - - var texture = locTextureAtlas.texture; - var textureWide = texture.pixelsWidth; - var textureHigh = texture.pixelsHeight; - var itemWidthInPixels = this._itemWidth; - var itemHeightInPixels = this._itemHeight; - if (!this._ignoreContentScaleFactor) { - itemWidthInPixels = this._itemWidth * cc.contentScaleFactor(); - itemHeightInPixels = this._itemHeight * cc.contentScaleFactor(); - } - if (n > locTextureAtlas.getCapacity()) - cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length"); - var quads = locTextureAtlas.quads; - var locDisplayedColor = this._displayedColor; - var curColor = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: this._displayedOpacity}; - var locItemWidth = this._itemWidth; - for (var i = 0; i < n; i++) { - var a = locString.charCodeAt(i) - this._mapStartChar.charCodeAt(0); - var row = a % this._itemsPerRow; - var col = 0 | (a / this._itemsPerRow); - - var left, right, top, bottom; - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - // Issue #938. Don't use texStepX & texStepY - left = (2 * row * itemWidthInPixels + 1) / (2 * textureWide); - right = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide); - top = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh); - bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh); - } else { - left = row * itemWidthInPixels / textureWide; - right = left + itemWidthInPixels / textureWide; - top = col * itemHeightInPixels / textureHigh; - bottom = top + itemHeightInPixels / textureHigh; - } - var quad = quads[i]; - var locQuadTL = quad.tl, locQuadTR = quad.tr, locQuadBL = quad.bl, locQuadBR = quad.br; - locQuadTL.texCoords.u = left; - locQuadTL.texCoords.v = top; - locQuadTR.texCoords.u = right; - locQuadTR.texCoords.v = top; - locQuadBL.texCoords.u = left; - locQuadBL.texCoords.v = bottom; - locQuadBR.texCoords.u = right; - locQuadBR.texCoords.v = bottom; - - locQuadBL.vertices.x = (i * locItemWidth); - locQuadBL.vertices.y = 0; - locQuadBL.vertices.z = 0.0; - locQuadBR.vertices.x = (i * locItemWidth + locItemWidth); - locQuadBR.vertices.y = 0; - locQuadBR.vertices.z = 0.0; - locQuadTL.vertices.x = i * locItemWidth; - locQuadTL.vertices.y = this._itemHeight; - locQuadTL.vertices.z = 0.0; - locQuadTR.vertices.x = i * locItemWidth + locItemWidth; - locQuadTR.vertices.y = this._itemHeight; - locQuadTR.vertices.z = 0.0; - locQuadTL.colors = curColor; - locQuadTR.colors = curColor; - locQuadBL.colors = curColor; - locQuadBR.colors = curColor; - } - if (n > 0) { - locTextureAtlas.dirty = true; - var totalQuads = locTextureAtlas.totalQuads; - if (n > totalQuads) - locTextureAtlas.increaseTotalQuadsWith(n - totalQuads); - } + updateAtlasValues: function(){ + this._renderCmd.updateAtlasValues(); }, /** @@ -312,40 +208,8 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ * @function * @param {String} label */ - setString: null, - - _setStringForCanvas: function (label) { - label = String(label); - var len = label.length; - this._string = label; - this.width = len * this._itemWidth; - this.height = this._itemHeight; - if (this._children) { - var locChildren = this._children; - len = locChildren.length; - for (var i = 0; i < len; i++) { - var node = locChildren[i]; - if (node && !node._lateChild) - node.visible = false; - } - } - - this.updateAtlasValues(); - this.quadsToDraw = len; - }, - - _setStringForWebGL: function (label) { - label = String(label); - var len = label.length; - if (len > this.textureAtlas.totalQuads) - this.textureAtlas.resizeCapacity(len); - - this._string = label; - this.width = len * this._itemWidth; - this.height = this._itemHeight; - - this.updateAtlasValues(); - this.quadsToDraw = len; + setString: function(label){ + this._renderCmd.setString(label); }, /** @@ -353,27 +217,11 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ * @function * @param {Number} opacity */ - setOpacity: null, - - _setOpacityForWebGL: function (opacity) { - if (this._opacity !== opacity) - cc.AtlasNode.prototype.setOpacity.call(this, opacity); + setOpacity: function(opacity){ + this._renderCmd.setOpacity(opacity); } }); -var _p = cc.LabelAtlas.prototype; -cc.EventHelper.prototype.apply(_p); -if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - _p.updateAtlasValues = _p._updateAtlasValuesForWebGL; - _p.setString = _p._setStringForWebGL; - _p.setOpacity = _p._setOpacityForWebGL; -} else { - _p.updateAtlasValues = _p._updateAtlasValuesForCanvas; - _p.setString = _p._setStringForCanvas; - _p.setOpacity = _p._setOpacityForCanvas; - _p.addChild = _p._addChildForCanvas; -} - // Override properties cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); diff --git a/cocos2d/labels/CCLabelAtlasRenderCmd.js b/cocos2d/labels/CCLabelAtlasRenderCmd.js new file mode 100644 index 0000000000..79dd9e6add --- /dev/null +++ b/cocos2d/labels/CCLabelAtlasRenderCmd.js @@ -0,0 +1,206 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + + cc.LabelAtlas.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); + proto.constructor = cc.LabelAtlas.CanvasRenderCmd; + + proto.updateAtlasValues = function(){ + var node = this._node; + var locString = node._string || ""; + var n = locString.length; + var texture = node.texture; + var locItemWidth = node._itemWidth , locItemHeight = node._itemHeight; //needn't multiply cc.contentScaleFactor(), because sprite's draw will do this + + for (var i = 0; i < n; i++) { + var a = locString.charCodeAt(i) - node._mapStartChar.charCodeAt(0); + var row = parseInt(a % node._itemsPerRow, 10); + var col = parseInt(a / node._itemsPerRow, 10); + + var rect = cc.rect(row * locItemWidth, col * locItemHeight, locItemWidth, locItemHeight); + var c = locString.charCodeAt(i); + var fontChar = node.getChildByTag(i); + if (!fontChar) { + fontChar = new cc.Sprite(); + if (c == 32) { + fontChar.init(); + fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); + } else + fontChar.initWithTexture(texture, rect); + + cc.Node.prototype.addChild.call(node, fontChar, 0, i); + } else { + if (c == 32) { + fontChar.init(); + fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); + } else { + // reusing fonts + fontChar.initWithTexture(texture, rect); + // restore to default in case they were modified + fontChar.visible = true; + } + } + fontChar.setPosition(i * locItemWidth + locItemWidth / 2, locItemHeight / 2); + } + }; + + proto.setString = function(label){ + var node = this._node; + label = String(label); + var len = label.length; + this._string = label; + this.width = len * node._itemWidth; + this.height = node._itemHeight; + if (this._children) { + var locChildren = node._children; + len = locChildren.length; + for (var i = 0; i < len; i++) { + var child = locChildren[i]; + if (child && !child._lateChild) + child.visible = false; + } + } + + this.updateAtlasValues(); + this.quadsToDraw = len; + }; + + proto._addChild = function(){ + child._lateChild = true; + }; +})(); + +(function(){ + + cc.LabelAtlas.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype); + proto.constructor = cc.LabelAtlas.WebGLRenderCmd; + + proto.updateAtlasValues = function(){ + var node = this._node; + var locString = node._string; + var n = locString.length; + var locTextureAtlas = node.textureAtlas; + + var texture = locTextureAtlas.texture; + var textureWide = texture.pixelsWidth; + var textureHigh = texture.pixelsHeight; + var itemWidthInPixels = node._itemWidth; + var itemHeightInPixels = node._itemHeight; + if (!node._ignoreContentScaleFactor) { + itemWidthInPixels = node._itemWidth * cc.contentScaleFactor(); + itemHeightInPixels = node._itemHeight * cc.contentScaleFactor(); + } + if (n > locTextureAtlas.getCapacity()) + cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length"); + var quads = locTextureAtlas.quads; + var locDisplayedColor = node._displayedColor; + var curColor = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: node._displayedOpacity}; + var locItemWidth = node._itemWidth; + for (var i = 0; i < n; i++) { + var a = locString.charCodeAt(i) - node._mapStartChar.charCodeAt(0); + var row = a % node._itemsPerRow; + var col = 0 | (a / node._itemsPerRow); + + var left, right, top, bottom; + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + // Issue #938. Don't use texStepX & texStepY + left = (2 * row * itemWidthInPixels + 1) / (2 * textureWide); + right = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide); + top = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh); + bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh); + } else { + left = row * itemWidthInPixels / textureWide; + right = left + itemWidthInPixels / textureWide; + top = col * itemHeightInPixels / textureHigh; + bottom = top + itemHeightInPixels / textureHigh; + } + var quad = quads[i]; + var locQuadTL = quad.tl, locQuadTR = quad.tr, locQuadBL = quad.bl, locQuadBR = quad.br; + locQuadTL.texCoords.u = left; + locQuadTL.texCoords.v = top; + locQuadTR.texCoords.u = right; + locQuadTR.texCoords.v = top; + locQuadBL.texCoords.u = left; + locQuadBL.texCoords.v = bottom; + locQuadBR.texCoords.u = right; + locQuadBR.texCoords.v = bottom; + + locQuadBL.vertices.x = (i * locItemWidth); + locQuadBL.vertices.y = 0; + locQuadBL.vertices.z = 0.0; + locQuadBR.vertices.x = (i * locItemWidth + locItemWidth); + locQuadBR.vertices.y = 0; + locQuadBR.vertices.z = 0.0; + locQuadTL.vertices.x = i * locItemWidth; + locQuadTL.vertices.y = node._itemHeight; + locQuadTL.vertices.z = 0.0; + locQuadTR.vertices.x = i * locItemWidth + locItemWidth; + locQuadTR.vertices.y = node._itemHeight; + locQuadTR.vertices.z = 0.0; + locQuadTL.colors = curColor; + locQuadTR.colors = curColor; + locQuadBL.colors = curColor; + locQuadBR.colors = curColor; + } + if (n > 0) { + locTextureAtlas.dirty = true; + var totalQuads = locTextureAtlas.totalQuads; + if (n > totalQuads) + locTextureAtlas.increaseTotalQuadsWith(n - totalQuads); + } + }; + + proto.setString = function(label){ + var node = this._node; + label = String(label); + var len = label.length; + if (len > node.textureAtlas.totalQuads) + node.textureAtlas.resizeCapacity(len); + + node._string = label; + node.width = len * node._itemWidth; + node.height = node._itemHeight; + + node.updateAtlasValues(); + node.quadsToDraw = len; + }; + + proto.setOpacity = function(){ + if (this._opacity !== opacity) + cc.AtlasNode.prototype.setOpacity.call(this, opacity); + }; + + proto._addChild = function(){}; +})(); \ No newline at end of file From e12c351df387d3afe28ed7ce08cac5d83cad2102 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 20 Nov 2014 18:00:07 +0800 Subject: [PATCH 0933/1564] RenderTexture renderCmd --- cocos2d/render-texture/CCRenderTexture.js | 543 ++---------------- .../CCRenderTextureRenderCmd.js | 489 +++++++++++++++- 2 files changed, 505 insertions(+), 527 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 603711d27f..a0332fe612 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -90,16 +90,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ clearDepthVal:0, autoDraw:false, - // - // the off-screen canvas for rendering and storing the texture - // @type HTMLCanvasElement - // - _cacheCanvas:null, - /** - * stores a reference to the canvas context object - * @type CanvasRenderingContext2D - */ - _cacheContext:null, _fBO:0, _depthRenderBuffer:0, @@ -110,10 +100,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ _pixelFormat:cc.Texture2D.PIXEL_FORMAT_RGBA8888, - _clearColor:null, clearStencilVal:0, - _clearColorStr:null, _className:"RenderTexture", //for WebGL @@ -135,68 +123,34 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * var rt = new cc.RenderTexture(width, height, format, depthStencilFormat) * @function */ - ctor: null, - - _ctorForCanvas: function (width, height, format, depthStencilFormat) { + ctor: function(width, height, format, depthStencilFormat){ cc.Node.prototype.ctor.call(this); this._cascadeColorEnabled = true; this._cascadeOpacityEnabled = true; - this._clearColor = cc.color(255, 255, 255, 255); - this._clearColorStr = "rgba(255,255,255,1)"; - - this._cacheCanvas = cc.newElement('canvas'); - this._cacheContext = this._cacheCanvas.getContext('2d'); - this.anchorX = 0; - this.anchorY = 0; - if(width !== undefined && height !== undefined){ + if(width !== undefined && height !== undefined) { format = format || cc.Texture2D.PIXEL_FORMAT_RGBA8888; depthStencilFormat = depthStencilFormat || 0; this.initWithWidthAndHeight(width, height, format, depthStencilFormat); } + this.anchorX = 0; + this.anchorY = 0; }, - _ctorForWebGL: function (width, height, format, depthStencilFormat) { - cc.Node.prototype.ctor.call(this); - this._cascadeColorEnabled = true; - this._cascadeOpacityEnabled = true; - this._clearColor = cc.color(0, 0, 0, 0); - - if(width !== undefined && height !== undefined){ - format = format || cc.Texture2D.PIXEL_FORMAT_RGBA8888; - depthStencilFormat = depthStencilFormat || 0; - this.initWithWidthAndHeight(width, height, format, depthStencilFormat); - } - - //TODO need merge in some code - this._renderCmd = new cc.RenderTexture.WebGLRenderCmd(this); + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.RenderTexture.CanvasRenderCmd(this); + else + return new cc.RenderTexture.WebGLRenderCmd(this); }, /** * Clear RenderTexture. * @function */ - cleanup:null, - - _cleanupForCanvas:function () { + cleanup: function(){ cc.Node.prototype.onExit.call(this); - this._cacheContext = null; - this._cacheCanvas = null; - }, - - _cleanupForWebGL: function () { - cc.Node.prototype.onExit.call(this); - - //this.sprite = null; - this._textureCopy = null; - - var gl = cc._renderContext; - gl.deleteFramebuffer(this._fBO); - if (this._depthRenderBuffer) - gl.deleteRenderbuffer(this._depthRenderBuffer); - this._uITextureImage = null; - //if (this._texture) - // this._texture.releaseTexture(); + this._renderCmd.cleanup(); }, /** @@ -224,181 +178,18 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @param {Number} [depthStencilFormat] * @return {Boolean} */ - initWithWidthAndHeight: null, - - _initWithWidthAndHeightForCanvas: function (width, height, format, depthStencilFormat) { - var locCacheCanvas = this._cacheCanvas, locScaleFactor = cc.contentScaleFactor(); - locCacheCanvas.width = 0 | (width * locScaleFactor); - locCacheCanvas.height = 0 | (height * locScaleFactor); - this._cacheContext.translate(0, locCacheCanvas.height); - var texture = new cc.Texture2D(); - texture.initWithElement(locCacheCanvas); - texture.handleLoadedTexture(); - var locSprite = this.sprite = new cc.Sprite(texture); - locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); - // Disabled by default. - this.autoDraw = false; - // add sprite for backward compatibility - this.addChild(locSprite); - return true; - }, - - _initWithWidthAndHeightForWebGL: function (width, height, format, depthStencilFormat) { - if(format == cc.Texture2D.PIXEL_FORMAT_A8) - cc.log( "cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;"); - - var gl = cc._renderContext, locScaleFactor = cc.contentScaleFactor(); - - width = 0 | (width * locScaleFactor); - height = 0 | (height * locScaleFactor); - - this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); - - // textures must be power of two squared - var powW , powH; - - if (cc.configuration.supportsNPOT()) { - powW = width; - powH = height; - } else { - powW = cc.NextPOT(width); - powH = cc.NextPOT(height); - } - - //void *data = malloc(powW * powH * 4); - var dataLen = powW * powH * 4; - var data = new Uint8Array(dataLen); - //memset(data, 0, (int)(powW * powH * 4)); - for (var i = 0; i < powW * powH * 4; i++) - data[i] = 0; - - this._pixelFormat = format; - - this._texture = new cc.Texture2D(); - if (!this._texture) - return false; - - var locTexture = this._texture; - locTexture.initWithData(data, this._pixelFormat, powW, powH, cc.size(width, height)); - //free( data ); - - var oldRBO = gl.getParameter(gl.RENDERBUFFER_BINDING); - - if (cc.configuration.checkForGLExtension("GL_QCOM")) { - this._textureCopy = new cc.Texture2D(); - if (!this._textureCopy) - return false; - this._textureCopy.initWithData(data, this._pixelFormat, powW, powH, cc.size(width, height)); - } - - // generate FBO - this._fBO = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO); - - // associate texture with FBO - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, locTexture._webTextureObj, 0); - - if (depthStencilFormat != 0) { - //create and attach depth buffer - this._depthRenderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, depthStencilFormat, powW, powH); - if(depthStencilFormat == gl.DEPTH_STENCIL) - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); - else if(depthStencilFormat == gl.STENCIL_INDEX || depthStencilFormat == gl.STENCIL_INDEX8) - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); - else if(depthStencilFormat == gl.DEPTH_COMPONENT16) - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); - } - - // check if it worked (probably worth doing :) ) - if(gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) - cc.log("Could not attach texture to the framebuffer"); - - locTexture.setAliasTexParameters(); - - this.sprite = new cc.Sprite(locTexture); - var locSprite = this.sprite; - locSprite.scaleY = -1; - locSprite.setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - - gl.bindRenderbuffer(gl.RENDERBUFFER, oldRBO); - gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO); - - // Disabled by default. - this.autoDraw = false; - - // add sprite for backward compatibility - this.addChild(locSprite); - return true; + initWithWidthAndHeight: function(width, height, format, depthStencilFormat){ + return this._renderCmd.initWithWidthAndHeight(width, height, format, depthStencilFormat); }, /** * starts grabbing * @function */ - begin: null, - - _beginForCanvas: function () { - //old code - //cc._renderContext = this._cacheContext; - //cc.view._setScaleXYForRenderTexture(); - + begin: function(){ cc.renderer._turnToCacheMode(this.__instanceId); - - /*// Save the current matrix - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPushMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix();*/ + this._renderCmd.begin(); }, - - _beginForWebGL: function () { - cc.renderer._turnToCacheMode(this.__instanceId); - - // Save the current matrix - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPushMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - - var director = cc.director; - director.setProjection(director.getProjection()); - - var texSize = this._texture.getContentSizeInPixels(); - - // Calculate the adjustment ratios based on the old and new projections - var size = cc.director.getWinSizeInPixels(); - var widthRatio = size.width / texSize.width; - var heightRatio = size.height / texSize.height; - - var gl = cc._renderContext; - - // Adjust the orthographic projection and viewport - gl.viewport(0, 0, texSize.width, texSize.height); - - var orthoMatrix = new cc.kmMat4(); - cc.kmMat4OrthographicProjection(orthoMatrix, -1.0 / widthRatio, 1.0 / widthRatio, - -1.0 / heightRatio, 1.0 / heightRatio, -1, 1); - cc.kmGLMultMatrix(orthoMatrix); - - this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); - gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO);//Will direct drawing to the frame buffer created above - - /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. - * The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. - * Create a temporary texture to overcome this. At the end of CCRenderTexture::begin(), switch the attached texture to the second one, call glClear, - * and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers. - */ - if (cc.configuration.checkForGLExtension("GL_QCOM")) { - // -- bind a temporary texture so we can clear the render buffer without losing our texture - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._textureCopy._webTextureObj, 0); - //cc.checkGLErrorDebug(); - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._texture._webTextureObj, 0); - } - }, - /** * starts rendering to the texture while clearing the texture first.
    * This is more efficient then calling -clear first and then -begin @@ -417,117 +208,17 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ this._beginWithClear(r , g , b , a , depthValue, stencilValue, (gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)); }, - _beginWithClear: null, - - _beginWithClearForCanvas: function (r, g, b, a, depthValue, stencilValue, flags) { + _beginWithClear: function(r, g, b, a, depthValue, stencilValue, flags){ this.begin(); - - r = r || 0; - g = g || 0; - b = b || 0; - a = isNaN(a) ? 1 : a; - - //var context = cc._renderContext; - var context = this._cacheContext; - var locCanvas = this._cacheCanvas; - context.save(); - context.fillStyle = "rgba(" + (0 | r) + "," + (0 | g) + "," + (0 | b) + "," + a / 255 + ")"; - context.clearRect(0, 0, locCanvas.width, -locCanvas.height); - context.fillRect(0, 0, locCanvas.width, -locCanvas.height); - context.restore(); - }, - - _beginWithClearForWebGL: function (r, g, b, a, depthValue, stencilValue, flags) { - r = r / 255; - g = g / 255; - b = b / 255; - a = a / 255; - - this.begin(); - - var gl = cc._renderContext; - - // save clear color - var clearColor = [0.0, 0.0, 0.0, 0.0]; - var depthClearValue = 0.0; - var stencilClearValue = 0; - - if (flags & gl.COLOR_BUFFER_BIT) { - clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); - gl.clearColor(r, g, b, a); - } - - if (flags & gl.DEPTH_BUFFER_BIT) { - depthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - gl.clearDepth(depthValue); - } - - if (flags & gl.STENCIL_BUFFER_BIT) { - stencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); - gl.clearStencil(stencilValue); - } - - gl.clear(flags); - - // restore - if (flags & gl.COLOR_BUFFER_BIT) - gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); - - if (flags & gl.DEPTH_BUFFER_BIT) - gl.clearDepth(depthClearValue); - - if (flags & gl.STENCIL_BUFFER_BIT) - gl.clearStencil(stencilClearValue); + this._renderCmd._beginWithClear(r, g, b, a, depthValue, stencilValue, flags); }, /** * ends grabbing * @function */ - end: null, - - _endForCanvas: function () { - //old code - //cc._renderContext = cc._mainRenderContextBackup; - //cc.view._resetScale(); - - var scale = cc.contentScaleFactor(); - cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId, scale, scale); - - //TODO - /*//restore viewport - director.setViewport(); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix();*/ - }, - - _endForWebGL: function () { - cc.renderer._renderingToBuffer(this.__instanceId); - - var gl = cc._renderContext; - var director = cc.director; - gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO); - - //restore viewport - director.setViewport(); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix(); - - /* var size = director.getWinSizeInPixels(); - - // restore viewport - gl.viewport(0, 0, size.width * cc.contentScaleFactor(), size.height * cc.contentScaleFactor()); - - // special viewport for 3d projection + retina display - if (director.getProjection() == cc.Director.PROJECTION_3D && cc.contentScaleFactor() != 1) { - gl.viewport((-size.width / 2), (-size.height / 2), (size.width * cc.contentScaleFactor()), (size.height * cc.contentScaleFactor())); - } - - director.setProjection(director.getProjection());*/ + end: function(){ + this._renderCmd.end(); }, /** @@ -550,14 +241,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @param {number} width * @param {number} height */ - clearRect:null, - - _clearRectForCanvas:function(x, y, width, height){ - this._cacheContext.clearRect(x, y, width, -height); - }, - - _clearRectForWebGL:function(x, y, width, height){ - //TODO need to implement + clearRect: function(x, y, width, height){ + this._renderCmd.clearRect(x, y, width, height); }, /** @@ -565,25 +250,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @function * @param {Number} depthValue */ - clearDepth:null, - - _clearDepthForCanvas:function (depthValue) { - cc.log("clearDepth isn't supported on Cocos2d-Html5"); - }, - - _clearDepthForWebGL:function (depthValue) { - this.begin(); - - var gl = cc._renderContext; - //! save old depth value - var depthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - - gl.clearDepth(depthValue); - gl.clear(gl.DEPTH_BUFFER_BIT); - - // restore clear color - gl.clearDepth(depthClearValue); - this.end(); + clearDepth: function(depthValue){ + this._renderCmd.clearDepth(depthValue); }, /** @@ -614,46 +282,13 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx */ - visit:null, - - _visitForCanvas:function (ctx) { - // override visit. - // Don't call visit on its children - if (!this._visible) - return; + visit: function(){ - ctx = ctx || cc._renderContext; - this.transform(ctx); - this.sprite.visit(ctx); // draw the RenderTexture - }, - - _visitForWebGL:function (ctx) { // override visit. // Don't call visit on its children if (!this._visible) return; - - cc.kmGLPushMatrix(); - -/* var locGrid = this.grid; - if (locGrid && locGrid.isActive()) { - locGrid.beforeDraw(); - this.transformAncestors(); - }*/ - - this.transform(ctx); - //this.toRenderer(); - - this.sprite.visit(); - //this.draw(ctx); - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - - //TODO GridNode -/* if (locGrid && locGrid.isActive()) - locGrid.afterDraw(this);*/ - - cc.kmGLPopMatrix(); + this._renderCmd.visit(); }, /** @@ -661,87 +296,11 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @function * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context */ - draw:null, - - _drawForCanvas: function (ctx) { + draw: function(ctx){ ctx = ctx || cc._renderContext; if (this.autoDraw) { this.begin(); - - if (this.clearFlags) { - var locCanvas = this._cacheCanvas; - ctx.save(); - ctx.fillStyle = this._clearColorStr; - ctx.clearRect(0, 0, locCanvas.width, -locCanvas.height); - ctx.fillRect(0, 0, locCanvas.width, -locCanvas.height); - ctx.restore(); - } - - //! make sure all children are drawn - this.sortAllChildren(); - var locChildren = this._children; - var childrenLen = locChildren.length; - var selfSprite = this.sprite; - for (var i = 0; i < childrenLen; i++) { - var getChild = locChildren[i]; - if (getChild != selfSprite) - getChild.visit(); - } - this.end(); - } - }, - - _drawForWebGL: function (ctx) { - var gl = cc._renderContext; - if (this.autoDraw) { - this.begin(); - - var locClearFlags = this.clearFlags; - if (locClearFlags) { - var oldClearColor = [0.0, 0.0, 0.0, 0.0]; - var oldDepthClearValue = 0.0; - var oldStencilClearValue = 0; - - // backup and set - if (locClearFlags & gl.COLOR_BUFFER_BIT) { - oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); - gl.clearColor(this._clearColor.r/255, this._clearColor.g/255, this._clearColor.b/255, this._clearColor.a/255); - } - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) { - oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - gl.clearDepth(this.clearDepthVal); - } - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) { - oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); - gl.clearStencil(this.clearStencilVal); - } - - // clear - gl.clear(locClearFlags); - - // restore - if (locClearFlags & gl.COLOR_BUFFER_BIT) - gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) - gl.clearDepth(oldDepthClearValue); - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) - gl.clearStencil(oldStencilClearValue); - } - - //! make sure all children are drawn - this.sortAllChildren(); - var locChildren = this._children; - for (var i = 0; i < locChildren.length; i++) { - var getChild = locChildren[i]; - if (getChild != this.sprite) - getChild.visit(); - } - - this.end(); + this._renderCmd.draw(ctx); } }, @@ -809,7 +368,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @return {cc.Color} */ getClearColor:function () { - return this._clearColor; + return this._renderCmd._clearColor; }, /** @@ -817,24 +376,18 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @function * @param {cc.Color} clearColor The clear color */ - setClearColor:null, + setClearColor: function(clearColor){ + var cmd = this._renderCmd; - _setClearColorForCanvas:function (clearColor) { - var locClearColor = this._clearColor; + var locClearColor = cmd._clearColor; locClearColor.r = clearColor.r; locClearColor.g = clearColor.g; locClearColor.b = clearColor.b; locClearColor.a = clearColor.a; - this._clearColorStr = "rgba(" + (0 | clearColor.r) + "," + (0 | clearColor.g) + "," + (0 | clearColor.b) + "," + clearColor.a / 255 + ")"; - }, + //Only canvas!! + cmd._clearColorStr = "rgba(" + (0 | clearColor.r) + "," + (0 | clearColor.g) + "," + (0 | clearColor.b) + "," + clearColor.a / 255 + ")"; - _setClearColorForWebGL:function (clearColor) { - var locClearColor = this._clearColor; - locClearColor.r = clearColor.r; - locClearColor.g = clearColor.g; - locClearColor.b = clearColor.b; - locClearColor.a = clearColor.a; }, /** @@ -888,36 +441,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ } }); -var _p = cc.RenderTexture.prototype; - -if(cc._renderType == cc._RENDER_TYPE_WEBGL){ - _p.ctor = _p._ctorForWebGL; - _p.cleanup = _p._cleanupForWebGL; - _p.initWithWidthAndHeight = _p._initWithWidthAndHeightForWebGL; - _p.begin = _p._beginForWebGL; - _p._beginWithClear = _p._beginWithClearForWebGL; - _p.end = _p._endForWebGL; - _p.clearRect = _p._clearRectForWebGL; - _p.clearDepth = _p._clearDepthForWebGL; - _p.clearStencil = _p._clearStencilForWebGL; - _p.visit = _p._visitForWebGL; - _p.draw = _p._drawForWebGL; - _p.setClearColor = _p._setClearColorForWebGL; -} else { - _p.ctor = _p._ctorForCanvas; - _p.cleanup = _p._cleanupForCanvas; - _p.initWithWidthAndHeight = _p._initWithWidthAndHeightForCanvas; - _p.begin = _p._beginForCanvas; - _p._beginWithClear = _p._beginWithClearForCanvas; - _p.end = _p._endForCanvas; - _p.clearRect = _p._clearRectForCanvas; - _p.clearDepth = _p._clearDepthForCanvas; - _p.clearStencil = _p._clearStencilForCanvas; - _p.visit = _p._visitForCanvas; - _p.draw = _p._drawForCanvas; - _p.setClearColor = _p._setClearColorForCanvas; -} - // Extended /** @expose */ _p.clearColorVal; diff --git a/cocos2d/render-texture/CCRenderTextureRenderCmd.js b/cocos2d/render-texture/CCRenderTextureRenderCmd.js index 5675763933..e559ad0305 100644 --- a/cocos2d/render-texture/CCRenderTextureRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureRenderCmd.js @@ -22,20 +22,473 @@ THE SOFTWARE. ****************************************************************************/ -cc.RenderTexture.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -cc.RenderTexture.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.RenderTexture.WebGLRenderCmd.prototype.constructor = cc.RenderTexture.WebGLRenderCmd; - -cc.RenderTexture.WebGLRenderCmd.prototype.rendering = function (ctx) { - var gl = ctx || cc._renderContext; - var node = this._node; - if (node.autoDraw) { +(function(){ + + cc.RenderTexture.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + + this._clearColor = cc.color(255, 255, 255, 255); + this._clearColorStr = "rgba(255,255,255,1)"; + + // + // the off-screen canvas for rendering and storing the texture + // @type HTMLCanvasElement + // + this._cacheCanvas = cc.newElement('canvas'); + /** + * stores a reference to the canvas context object + * @type CanvasRenderingContext2D + */ + this._cacheContext = this._cacheCanvas.getContext('2d'); + }; + + var proto = cc.RenderTexture.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.RenderTexture.CanvasRenderCmd; + + proto.cleanup = function(){ + var node = this._node; + this._cacheContext = null; + this._cacheCanvas = null; + }; + + proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ + var node = this._node; + var locCacheCanvas = this._cacheCanvas, locScaleFactor = cc.contentScaleFactor(); + locCacheCanvas.width = 0 | (width * locScaleFactor); + locCacheCanvas.height = 0 | (height * locScaleFactor); + this._cacheContext.translate(0, locCacheCanvas.height); + var texture = new cc.Texture2D(); + texture.initWithElement(locCacheCanvas); + texture.handleLoadedTexture(); + var locSprite = node.sprite = new cc.Sprite(texture); + locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); + // Disabled by default. + node.autoDraw = false; + // add sprite for backward compatibility + node.addChild(locSprite); + return true; + }; + + proto.begin = function(){}; + + proto._beginWithClear = function(r, g, b, a, depthValue, stencilValue, flags){ + var node = this._node; node.begin(); + r = r || 0; + g = g || 0; + b = b || 0; + a = isNaN(a) ? 1 : a; + + //var context = cc._renderContext; + var context = this._cacheContext; + var locCanvas = this._cacheCanvas; + context.save(); + context.fillStyle = "rgba(" + (0 | r) + "," + (0 | g) + "," + (0 | b) + "," + a / 255 + ")"; + context.clearRect(0, 0, locCanvas.width, -locCanvas.height); + context.fillRect(0, 0, locCanvas.width, -locCanvas.height); + context.restore(); + }; + + proto.end = function(){ + + var node = this._node; + + //old code + //cc._renderContext = cc._mainRenderContextBackup; + //cc.view._resetScale(); + + var scale = cc.contentScaleFactor(); + cc.renderer._renderingToCacheCanvas(this._cacheContext, node.__instanceId, scale, scale); + + //TODO + /*//restore viewport + director.setViewport(); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix();*/ + }; + + proto.clearRect = function(x, y, width, height){ + this._cacheContext.clearRect(x, y, width, -height); + }; + + proto.clearDepth = function(depthValue){ + cc.log("clearDepth isn't supported on Cocos2d-Html5"); + }; + + proto.visit = function(ctx){ + var node = this._node; + ctx = ctx || cc._renderContext; + node.transform(ctx); + node.sprite.visit(ctx); + }; + + proto.draw = function(){ + var node = this._node; + if (node.clearFlags) { + var locCanvas = this._cacheCanvas; + ctx.save(); + ctx.fillStyle = this._clearColorStr; + ctx.clearRect(0, 0, locCanvas.width, -locCanvas.height); + ctx.fillRect(0, 0, locCanvas.width, -locCanvas.height); + ctx.restore(); + } + + //! make sure all children are drawn + node.sortAllChildren(); + var locChildren = node._children; + var childrenLen = locChildren.length; + var selfSprite = node.sprite; + for (var i = 0; i < childrenLen; i++) { + var getChild = locChildren[i]; + if (getChild != selfSprite) + getChild.visit(); + } + node.end(); + }; + +})(); + + +(function(){ + + cc.RenderTexture.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + + this._clearColor = cc.color(0, 0, 0, 0); + }; + + var proto = cc.RenderTexture.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.RenderTexture.WebGLRenderCmd; + + proto.rendering = function (ctx) { + var gl = ctx || cc._renderContext; + var node = this._node; + if (node.autoDraw) { + node.begin(); + + var locClearFlags = node.clearFlags; + if (locClearFlags) { + var oldClearColor = [0.0, 0.0, 0.0, 0.0]; + var oldDepthClearValue = 0.0; + var oldStencilClearValue = 0; + + // backup and set + if (locClearFlags & gl.COLOR_BUFFER_BIT) { + oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); + gl.clearColor(this._clearColor.r / 255, this._clearColor.g / 255, this._clearColor.b / 255, this._clearColor.a / 255); + } + + if (locClearFlags & gl.DEPTH_BUFFER_BIT) { + oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + gl.clearDepth(node.clearDepthVal); + } + + if (locClearFlags & gl.STENCIL_BUFFER_BIT) { + oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); + gl.clearStencil(node.clearStencilVal); + } + + // clear + gl.clear(locClearFlags); + + // restore + if (locClearFlags & gl.COLOR_BUFFER_BIT) + gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); + + if (locClearFlags & gl.DEPTH_BUFFER_BIT) + gl.clearDepth(oldDepthClearValue); + + if (locClearFlags & gl.STENCIL_BUFFER_BIT) + gl.clearStencil(oldStencilClearValue); + } + + //! make sure all children are drawn + node.sortAllChildren(); + var locChildren = node._children; + for (var i = 0; i < locChildren.length; i++) { + var getChild = locChildren[i]; + if (getChild != node.sprite) + getChild.visit(); + } + node.end(); + } + }; + + proto.cleanup = function(){ + var node = this._node; + //node.sprite = null; + node._textureCopy = null; + + var gl = cc._renderContext; + gl.deleteFramebuffer(node._fBO); + if (node._depthRenderBuffer) + gl.deleteRenderbuffer(node._depthRenderBuffer); + node._uITextureImage = null; + //if (node._texture) + // node._texture.releaseTexture(); + }; + + proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ + var node = this._node; + if(format == cc.Texture2D.PIXEL_FORMAT_A8) + cc.log( "cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;"); + + var gl = cc._renderContext, locScaleFactor = cc.contentScaleFactor(); + + width = 0 | (width * locScaleFactor); + height = 0 | (height * locScaleFactor); + + node._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); + + // textures must be power of two squared + var powW , powH; + + if (cc.configuration.supportsNPOT()) { + powW = width; + powH = height; + } else { + powW = cc.NextPOT(width); + powH = cc.NextPOT(height); + } + + //void *data = malloc(powW * powH * 4); + var dataLen = powW * powH * 4; + var data = new Uint8Array(dataLen); + //memset(data, 0, (int)(powW * powH * 4)); + for (var i = 0; i < powW * powH * 4; i++) + data[i] = 0; + + this._pixelFormat = format; + + this._texture = new cc.Texture2D(); + if (!node._texture) + return false; + + var locTexture = node._texture; + locTexture.initWithData(data, node._pixelFormat, powW, powH, cc.size(width, height)); + //free( data ); + + var oldRBO = gl.getParameter(gl.RENDERBUFFER_BINDING); + + if (cc.configuration.checkForGLExtension("GL_QCOM")) { + node._textureCopy = new cc.Texture2D(); + if (!node._textureCopy) + return false; + this._textureCopy.initWithData(data, node._pixelFormat, powW, powH, cc.size(width, height)); + } + + // generate FBO + node._fBO = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, node._fBO); + + // associate texture with FBO + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, locTexture._webTextureObj, 0); + + if (depthStencilFormat != 0) { + //create and attach depth buffer + node._depthRenderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, node._depthRenderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, depthStencilFormat, powW, powH); + if(depthStencilFormat == gl.DEPTH_STENCIL) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, node._depthRenderBuffer); + else if(depthStencilFormat == gl.STENCIL_INDEX || depthStencilFormat == gl.STENCIL_INDEX8) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, node._depthRenderBuffer); + else if(depthStencilFormat == gl.DEPTH_COMPONENT16) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, node._depthRenderBuffer); + } + + // check if it worked (probably worth doing :) ) + if(gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) + cc.log("Could not attach texture to the framebuffer"); + + locTexture.setAliasTexParameters(); + + node.sprite = new cc.Sprite(locTexture); + var locSprite = node.sprite; + locSprite.scaleY = -1; + locSprite.setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + + gl.bindRenderbuffer(gl.RENDERBUFFER, oldRBO); + gl.bindFramebuffer(gl.FRAMEBUFFER, node._oldFBO); + + // Disabled by default. + node.autoDraw = false; + + // add sprite for backward compatibility + node.addChild(locSprite); + return true; + }; + + proto.begin = function(){ + var node = this; + // Save the current matrix + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPushMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + + var director = cc.director; + director.setProjection(director.getProjection()); + + var texSize = node._texture.getContentSizeInPixels(); + + // Calculate the adjustment ratios based on the old and new projections + var size = cc.director.getWinSizeInPixels(); + var widthRatio = size.width / texSize.width; + var heightRatio = size.height / texSize.height; + + var gl = cc._renderContext; + + // Adjust the orthographic projection and viewport + gl.viewport(0, 0, texSize.width, texSize.height); + + var orthoMatrix = new cc.kmMat4(); + cc.kmMat4OrthographicProjection(orthoMatrix, -1.0 / widthRatio, 1.0 / widthRatio, + -1.0 / heightRatio, 1.0 / heightRatio, -1, 1); + cc.kmGLMultMatrix(orthoMatrix); + + node._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); + gl.bindFramebuffer(gl.FRAMEBUFFER, node._fBO);//Will direct drawing to the frame buffer created above + + /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. + * The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. + * Create a temporary texture to overcome this. At the end of CCRenderTexture::begin(), switch the attached texture to the second one, call glClear, + * and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers. + */ + if (cc.configuration.checkForGLExtension("GL_QCOM")) { + // -- bind a temporary texture so we can clear the render buffer without losing our texture + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, node._textureCopy._webTextureObj, 0); + //cc.checkGLErrorDebug(); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, node._texture._webTextureObj, 0); + } + }; + + proto._beginWithClear = function(r, g, b, a, depthValue, stencilValue, flags){ + var node = this._node; + r = r / 255; + g = g / 255; + b = b / 255; + a = a / 255; + + node.begin(); + + var gl = cc._renderContext; + + // save clear color + var clearColor = [0.0, 0.0, 0.0, 0.0]; + var depthClearValue = 0.0; + var stencilClearValue = 0; + + if (flags & gl.COLOR_BUFFER_BIT) { + clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); + gl.clearColor(r, g, b, a); + } + + if (flags & gl.DEPTH_BUFFER_BIT) { + depthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + gl.clearDepth(depthValue); + } + + if (flags & gl.STENCIL_BUFFER_BIT) { + stencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); + gl.clearStencil(stencilValue); + } + + gl.clear(flags); + + // restore + if (flags & gl.COLOR_BUFFER_BIT) + gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + + if (flags & gl.DEPTH_BUFFER_BIT) + gl.clearDepth(depthClearValue); + + if (flags & gl.STENCIL_BUFFER_BIT) + gl.clearStencil(stencilClearValue); + }; + + proto.end = function(){ + var node = this.node + cc.renderer._renderingToBuffer(node.__instanceId); + + var gl = cc._renderContext; + var director = cc.director; + gl.bindFramebuffer(gl.FRAMEBUFFER, node._oldFBO); + + //restore viewport + director.setViewport(); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix(); + + /* var size = director.getWinSizeInPixels(); + + // restore viewport + gl.viewport(0, 0, size.width * cc.contentScaleFactor(), size.height * cc.contentScaleFactor()); + + // special viewport for 3d projection + retina display + if (director.getProjection() == cc.Director.PROJECTION_3D && cc.contentScaleFactor() != 1) { + gl.viewport((-size.width / 2), (-size.height / 2), (size.width * cc.contentScaleFactor()), (size.height * cc.contentScaleFactor())); + } + + director.setProjection(director.getProjection());*/ + }; + + proto.clearRect = function(x, y, width, height){ + //TODO need to implement + }; + + proto.clearDepth = function(depthValue){ + var node = this._node; + node.begin(); + + var gl = cc._renderContext; + //! save old depth value + var depthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + + gl.clearDepth(depthValue); + gl.clear(gl.DEPTH_BUFFER_BIT); + + // restore clear color + gl.clearDepth(depthClearValue); + node.end(); + }; + + proto.visit = function(ctx){ + var node = this._node; + cc.kmGLPushMatrix(); + + /* var locGrid = this.grid; + if (locGrid && locGrid.isActive()) { + locGrid.beforeDraw(); + this.transformAncestors(); + }*/ + + node.transform(ctx); + //this.toRenderer(); + + node.sprite.visit(); + //this.draw(ctx); + + cc.renderer.pushRenderCommand(this); + + //TODO GridNode + /* if (locGrid && locGrid.isActive()) + locGrid.afterDraw(this);*/ + + cc.kmGLPopMatrix(); + }; + + proto.draw = function(ctx){ + var node = this._node; + var gl = cc._renderContext; var locClearFlags = node.clearFlags; if (locClearFlags) { var oldClearColor = [0.0, 0.0, 0.0, 0.0]; @@ -45,7 +498,7 @@ cc.RenderTexture.WebGLRenderCmd.prototype.rendering = function (ctx) { // backup and set if (locClearFlags & gl.COLOR_BUFFER_BIT) { oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); - gl.clearColor(node._clearColor.r / 255, node._clearColor.g / 255, node._clearColor.b / 255, node._clearColor.a / 255); + gl.clearColor(this._clearColor.r/255, this._clearColor.g/255, this._clearColor.b/255, this._clearColor.a/255); } if (locClearFlags & gl.DEPTH_BUFFER_BIT) { @@ -73,13 +526,15 @@ cc.RenderTexture.WebGLRenderCmd.prototype.rendering = function (ctx) { } //! make sure all children are drawn - node.sortAllChildren(); + this.sortAllChildren(); var locChildren = node._children; for (var i = 0; i < locChildren.length; i++) { var getChild = locChildren[i]; if (getChild != node.sprite) getChild.visit(); } - node.end(); - } -}; \ No newline at end of file + + this.end(); + }; + +})(); \ No newline at end of file From 22333a7e8e2ec2bf96136fe49784082f7eb6772c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 20 Nov 2014 19:30:34 +0800 Subject: [PATCH 0934/1564] Fixed atlasnode --- cocos2d/core/base-nodes/CCAtlasNode.js | 11 ++++++++--- cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js | 2 +- moduleConfig.json | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 5973d19a1a..2c3ad77f0a 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -85,10 +85,13 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender); - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._renderCmd = new cc.AtlasNode.WebGLRenderCmd(this); - else + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) this._renderCmd = new cc.AtlasNode.CanvasRenderCmd(this); + else + this._renderCmd = new cc.AtlasNode.WebGLRenderCmd(this); }, /** @@ -291,6 +294,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ } }); + +var _p = cc.AtlasNode.prototype; // Override properties cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js index 14f23b863a..beb137c34e 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js @@ -146,7 +146,7 @@ })(); /** - * cc.AtlasNode's rendering objects of Canvas + * cc.AtlasNode's rendering objects of WebGL */ (function(){ cc.AtlasNode.WebGLRenderCmd = function(renderableObject){ diff --git a/moduleConfig.json b/moduleConfig.json index fa8a620cdd..5726f29dde 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -145,6 +145,7 @@ "core", "cocos2d/labels/CCLabelAtlas.js", + "cocos2d/labels/CCLabelAtlasRenderCmd.js", "cocos2d/labels/CCLabelBMFont.js" ], "menus" : [ From 574be51d8a1973fb86f65fd2d77612304efb7831 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 20 Nov 2014 19:37:30 +0800 Subject: [PATCH 0935/1564] Fixed atlasnode --- cocos2d/core/base-nodes/CCAtlasNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 2c3ad77f0a..fb3dc8770f 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -262,7 +262,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @return {cc.Texture2D} */ getTexture: function(){ - this._renderCmd.getTexture(); + return this._renderCmd.getTexture(); }, /** From 853f40bbf03d73f26c1f8c5ef7897d640d398f03 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 20 Nov 2014 20:56:06 +0800 Subject: [PATCH 0936/1564] CCTMXLayer renderCmd --- cocos2d/tilemap/CCTMXLayer.js | 158 +------------ cocos2d/tilemap/CCTMXLayerRenderCmd.js | 307 +++++++++++++++++++------ 2 files changed, 242 insertions(+), 223 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 1448c13d13..e6bc3f1f75 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -78,7 +78,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ //used for retina display _contentScaleFactor: null, - _cacheCanvas:null, _cacheContext:null, _cacheTexture:null, _className:"TMXLayer", @@ -97,27 +96,13 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this._layerSize = cc.size(0, 0); this._mapTileSize = cc.size(0, 0); - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - var locCanvas = cc._canvas; - var tmpCanvas = cc.newElement('canvas'); - tmpCanvas.width = locCanvas.width; - tmpCanvas.height = locCanvas.height; - this._cacheCanvas = tmpCanvas; - this._cacheContext = this._cacheCanvas.getContext('2d'); - var tempTexture = new cc.Texture2D(); - tempTexture.initWithElement(tmpCanvas); - tempTexture.handleLoadedTexture(); - this._cacheTexture = tempTexture; - this.width = locCanvas.width; - this.height = locCanvas.height; - // This class uses cache, so its default cachedParent should be himself - this._cachedParent = this; - } if(mapInfo !== undefined) this.initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo); + + this._renderCmd._initContentSize(); }, - _createRendererCmd: function(){ + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.TMXLayer.CanvasRenderCmd(this); else @@ -131,49 +116,8 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * @param {Number} [height] The untransformed size's height of the TMXLayer. */ setContentSize:function (size, height) { - var locContentSize = this._contentSize; cc.Node.prototype.setContentSize.call(this, size, height); - - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - var locCanvas = this._cacheCanvas; - var scaleFactor = cc.contentScaleFactor(); - locCanvas.width = 0 | (locContentSize.width * 1.5 * scaleFactor); - locCanvas.height = 0 | (locContentSize.height * 1.5 * scaleFactor); - - if(this.layerOrientation === cc.TMX_ORIENTATION_HEX) - this._cacheContext.translate(0, locCanvas.height - (this._mapTileSize.height * 0.5)); //translate for hexagonal - else - this._cacheContext.translate(0, locCanvas.height); - var locTexContentSize = this._cacheTexture._contentSize; - locTexContentSize.width = locCanvas.width; - locTexContentSize.height = locCanvas.height; - - // Init sub caches if needed - var totalPixel = locCanvas.width * locCanvas.height; - if(totalPixel > this._maxCachePixel) { - if(!this._subCacheCanvas) this._subCacheCanvas = []; - if(!this._subCacheContext) this._subCacheContext = []; - - this._subCacheCount = Math.ceil( totalPixel / this._maxCachePixel ); - var locSubCacheCanvas = this._subCacheCanvas, i; - for(i = 0; i < this._subCacheCount; i++) { - if(!locSubCacheCanvas[i]) { - locSubCacheCanvas[i] = document.createElement('canvas'); - this._subCacheContext[i] = locSubCacheCanvas[i].getContext('2d'); - } - var tmpCanvas = locSubCacheCanvas[i]; - tmpCanvas.width = this._subCacheWidth = Math.round( locCanvas.width / this._subCacheCount ); - tmpCanvas.height = locCanvas.height; - } - // Clear wasted cache to release memory - for(i = this._subCacheCount; i < locSubCacheCanvas.length; i++) { - tmpCanvas.width = 0; - tmpCanvas.height = 0; - } - } - // Otherwise use count as a flag to disable sub caches - else this._subCacheCount = 0; - } + this._renderCmd.setContentSize(size, height); }, /** @@ -181,10 +125,8 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * @function * @return {cc.Texture2D} */ - getTexture: null, - - _getTextureForCanvas:function () { - return this._cacheTexture; + getTexture: function(){ + this._renderCmd.getTexture(); }, /** @@ -193,48 +135,8 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * @override * @param {CanvasRenderingContext2D} ctx */ - visit: null, - - _visitForCanvas: function (ctx) { - //TODO it will implement dynamic compute child cutting automation. - var i, len, locChildren = this._children; - // quick return if not visible - if (!this._visible || !locChildren || locChildren.length === 0) - return; - - if( this._parent) - this._curLevel = this._parent._curLevel + 1; - - this.transform(); - - if (this._cacheDirty) { - var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view, - instanceID = this.__instanceId, renderer = cc.renderer; - //begin cache - renderer._turnToCacheMode(instanceID); - - this.sortAllChildren(); - for (i = 0, len = locChildren.length; i < len; i++) { - if (locChildren[i]){ - locChildren[i].visit(); - locChildren[i]._cacheDirty = false; - } - } - - //copy cached render cmd array to TMXLayer renderer - this._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); - - locCacheContext.save(); - locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - var t = cc.affineTransformInvert(this._transformWorld); - locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); - - //draw to cache canvas - renderer._renderingToCacheCanvas(locCacheContext, instanceID); - locCacheContext.restore(); - this._cacheDirty = false; - } - cc.renderer.pushRenderCommand(this._renderCmd); + visit: function(ctx){ + this._renderCmd.visit(); }, //set the cache dirty flag for canvas @@ -250,38 +152,8 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * @function * @param {CanvasRenderingContext2D} ctx */ - draw:null, - - _drawForCanvas:function (ctx) { - var context = ctx || cc._renderContext; - //context.globalAlpha = this._opacity / 255; - var posX = 0 | ( -this._anchorPointInPoints.x), posY = 0 | ( -this._anchorPointInPoints.y); - var eglViewer = cc.view; - var locCacheCanvas = this._cacheCanvas; - //direct draw image by canvas drawImage - if (locCacheCanvas) { - var locSubCacheCount = this._subCacheCount, locCanvasHeight = locCacheCanvas.height * eglViewer._scaleY; - var halfTileSize = this._mapTileSize.height * 0.5 * eglViewer._scaleY; - if(locSubCacheCount > 0) { - var locSubCacheCanvasArr = this._subCacheCanvas; - for(var i = 0; i < locSubCacheCount; i++){ - var selSubCanvas = locSubCacheCanvasArr[i]; - if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) - context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * this._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight) + halfTileSize, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); - else - context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * this._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); - } - } else{ - if (this.layerOrientation === cc.TMX_ORIENTATION_HEX) - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); - else - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); - } - } + draw: function(ctx){ + this._renderCmd.draw(ctx); }, /** @@ -1080,16 +952,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ var _p = cc.TMXLayer.prototype; -if(cc._renderType == cc._RENDER_TYPE_WEBGL){ - _p.draw = cc.SpriteBatchNode.prototype.draw; - _p.visit = cc.SpriteBatchNode.prototype.visit; - _p.getTexture = cc.SpriteBatchNode.prototype.getTexture; -}else{ - _p.draw = _p._drawForCanvas; - _p.visit = _p._visitForCanvas; - _p.getTexture = _p._getTextureForCanvas; -} - /** @expose */ cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); diff --git a/cocos2d/tilemap/CCTMXLayerRenderCmd.js b/cocos2d/tilemap/CCTMXLayerRenderCmd.js index 9c555d9ec6..3eb0be964d 100644 --- a/cocos2d/tilemap/CCTMXLayerRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerRenderCmd.js @@ -22,82 +22,239 @@ THE SOFTWARE. ****************************************************************************/ -cc.TMXLayer.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._childrenRenderCmds = []; - this._needDraw = true; -}; - -cc.TMXLayer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.TMXLayer.CanvasRenderCmd.prototype.constructor = cc.TMXLayer.CanvasRenderCmd; - -cc.TMXLayer.CanvasRenderCmd.prototype._copyRendererCmds = function (rendererCmds) { - if (!rendererCmds) - return; - - var locCacheCmds = this._childrenRenderCmds; - locCacheCmds.length = 0; - for (var i = 0, len = rendererCmds.length; i < len; i++) { - locCacheCmds[i] = rendererCmds[i]; - } -}; - -cc.TMXLayer.CanvasRenderCmd.prototype._renderingChildToCache = function (scaleX, scaleY) { - var locNode = this._node; - if (locNode._cacheDirty) { - var locCacheCmds = this._childrenRenderCmds, locCacheContext = locNode._cacheContext, locCanvas = locNode._cacheCanvas; - - locCacheContext.save(); - locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - //reset the cache context - var t = cc.affineTransformInvert(locNode._transformWorld); - locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - for (var i = 0, len = locCacheCmds.length; i < len; i++) { - locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); - if (locCacheCmds[i]._node) - locCacheCmds[i]._node._cacheDirty = false; +(function(){ + cc.TMXLayer.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._childrenRenderCmds = []; + this._needDraw = true; + + var locCanvas = cc._canvas; + var tmpCanvas = cc.newElement('canvas'); + tmpCanvas.width = locCanvas.width; + tmpCanvas.height = locCanvas.height; + this._cacheCanvas = tmpCanvas; + this._cacheContext = this._cacheCanvas.getContext('2d'); + var tempTexture = new cc.Texture2D(); + tempTexture.initWithElement(tmpCanvas); + tempTexture.handleLoadedTexture(); + this._cacheTexture = tempTexture; + // This class uses cache, so its default cachedParent should be himself + this._cachedParent = this; + }; + + var proto = cc.TMXLayer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.TMXLayer.CanvasRenderCmd; + + proto._copyRendererCmds = function (rendererCmds) { + if (!rendererCmds) + return; + + var locCacheCmds = this._childrenRenderCmds; + locCacheCmds.length = 0; + for (var i = 0, len = rendererCmds.length; i < len; i++) { + locCacheCmds[i] = rendererCmds[i]; + } + }; + + proto._renderingChildToCache = function (scaleX, scaleY) { + var locNode = this._node; + if (locNode._cacheDirty) { + var locCacheCmds = this._childrenRenderCmds, locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas; + + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + //reset the cache context + var t = cc.affineTransformInvert(locNode._transformWorld); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + for (var i = 0, len = locCacheCmds.length; i < len; i++) { + locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); + if (locCacheCmds[i]._node) + locCacheCmds[i]._node._cacheDirty = false; + } + locCacheContext.restore(); + locNode._cacheDirty = false; + } + }; + + proto.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + var alpha = node._displayedOpacity / 255; + if (alpha <= 0) + return; + + this._renderingChildToCache(scaleX, scaleY); + var context = ctx || cc._renderContext; + context.globalAlpha = alpha; + var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); + var locCacheCanvas = this._cacheCanvas, t = node._transformWorld; + //direct draw image by canvas drawImage + if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + var locCanvasHeight = locCacheCanvas.height * scaleY; + + if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) { + var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); + } else { + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + } + context.restore(); } - locCacheContext.restore(); - locNode._cacheDirty = false; - } -}; - -cc.TMXLayer.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var alpha = node._displayedOpacity / 255; - if (alpha <= 0) - return; - - this._renderingChildToCache(scaleX, scaleY); - var context = ctx || cc._renderContext; - context.globalAlpha = alpha; - var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); - var locCacheCanvas = node._cacheCanvas, t = node._transformWorld; - //direct draw image by canvas drawImage - if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { - context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - var locCanvasHeight = locCacheCanvas.height * scaleY; - - if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) { - var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); - } else { - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + cc.g_NumberOfDraws++; + }; + + proto.setContentSize = function(size, height){ + var node = this._node; + var locContentSize = node._contentSize; + var locCanvas = this._cacheCanvas; + var scaleFactor = cc.contentScaleFactor(); + locCanvas.width = 0 | (locContentSize.width * 1.5 * scaleFactor); + locCanvas.height = 0 | (locContentSize.height * 1.5 * scaleFactor); + + if(node.layerOrientation === cc.TMX_ORIENTATION_HEX) + this._cacheContext.translate(0, locCanvas.height - (node._mapTileSize.height * 0.5)); //translate for hexagonal + else + this._cacheContext.translate(0, locCanvas.height); + var locTexContentSize = this._cacheTexture._contentSize; + locTexContentSize.width = locCanvas.width; + locTexContentSize.height = locCanvas.height; + + // Init sub caches if needed + var totalPixel = locCanvas.width * locCanvas.height; + if(totalPixel > node._maxCachePixel) { + if(!node._subCacheCanvas) node._subCacheCanvas = []; + if(!node._subCacheContext) node._subCacheContext = []; + + node._subCacheCount = Math.ceil( totalPixel / node._maxCachePixel ); + var locSubCacheCanvas = node._subCacheCanvas, i; + for(i = 0; i < node._subCacheCount; i++) { + if(!locSubCacheCanvas[i]) { + locSubCacheCanvas[i] = document.createElement('canvas'); + node._subCacheContext[i] = locSubCacheCanvas[i].getContext('2d'); + } + var tmpCanvas = locSubCacheCanvas[i]; + tmpCanvas.width = node._subCacheWidth = Math.round( locCanvas.width / node._subCacheCount ); + tmpCanvas.height = locCanvas.height; + } + // Clear wasted cache to release memory + for(i = node._subCacheCount; i < locSubCacheCanvas.length; i++) { + tmpCanvas.width = 0; + tmpCanvas.height = 0; + } } - context.restore(); - } - cc.g_NumberOfDraws++; -}; + // Otherwise use count as a flag to disable sub caches + else node._subCacheCount = 0; + }; + + proto.getTexture = function(){ + return this._cacheTexture; + }; + + proto.visit = function(ctx){ + var node = this._node; + //TODO it will implement dynamic compute child cutting automation. + var i, len, locChildren = node._children; + // quick return if not visible + if (!node._visible || !locChildren || locChildren.length === 0) + return; + + if( node._parent) + node._curLevel = node._parent._curLevel + 1; + + node.transform(); + + if (node._cacheDirty) { + var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view, + instanceID = node.__instanceId, renderer = cc.renderer; + //begin cache + renderer._turnToCacheMode(instanceID); + + node.sortAllChildren(); + for (i = 0, len = locChildren.length; i < len; i++) { + if (locChildren[i]){ + locChildren[i].visit(); + locChildren[i]._cacheDirty = false; + } + } + + //copy cached render cmd array to TMXLayer renderer + node._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); + + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + var t = cc.affineTransformInvert(node._transformWorld); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); + + //draw to cache canvas + renderer._renderingToCacheCanvas(locCacheContext, instanceID); + locCacheContext.restore(); + node._cacheDirty = false; + } + cc.renderer.pushRenderCommand(node._renderCmd); + }; + + proto.draw = function(ctx){ + var node = this._node; + var context = ctx || cc._renderContext; + //context.globalAlpha = node._opacity / 255; + var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); + var eglViewer = cc.view; + var locCacheCanvas = this._cacheCanvas; + //direct draw image by canvas drawImage + if (locCacheCanvas) { + var locSubCacheCount = node._subCacheCount, locCanvasHeight = locCacheCanvas.height * eglViewer._scaleY; + var halfTileSize = node._mapTileSize.height * 0.5 * eglViewer._scaleY; + if(locSubCacheCount > 0) { + var locSubCacheCanvasArr = node._subCacheCanvas; + for(var i = 0; i < locSubCacheCount; i++){ + var selSubCanvas = locSubCacheCanvasArr[i]; + if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) + context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, + posX + i * node._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight) + halfTileSize, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); + else + context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, + posX + i * node._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); + } + } else{ + if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); + else + context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, + posX, -(posY + locCanvasHeight), locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); + } + } + }; + + proto._initContentSize = function(){ + var locCanvas = cc._canvas; + this._node.width = locCanvas.width; + this._node.height = locCanvas.height; + }; +})(); + +(function(){ + cc.TMXLayer.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering; + proto.constructor = cc.TMXLayer.WebGLRenderCmd; + + proto.setContentSize = function(){}; + + proto.getTexture = cc.SpriteBatchNode.prototype.getTexture; + + proto.visit = cc.SpriteBatchNode.prototype.visit; -cc.TMXLayer.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; + proto.draw = cc.SpriteBatchNode.prototype.draw; -cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering; \ No newline at end of file + proto._initContentSize = function(){}; +})(); From b8cfc26b51c211da8fde7aba154cd7714713d559 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 20 Nov 2014 21:03:41 +0800 Subject: [PATCH 0937/1564] Issue #2416: Change function name --- cocos2d/tilemap/CCTMXLayer.js | 2 +- cocos2d/tilemap/CCTMXLayerRenderCmd.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index e6bc3f1f75..7285ea74cd 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -117,7 +117,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ */ setContentSize:function (size, height) { cc.Node.prototype.setContentSize.call(this, size, height); - this._renderCmd.setContentSize(size, height); + this._renderCmd._updateCacheContext(size, height); }, /** diff --git a/cocos2d/tilemap/CCTMXLayerRenderCmd.js b/cocos2d/tilemap/CCTMXLayerRenderCmd.js index 3eb0be964d..3257b221f6 100644 --- a/cocos2d/tilemap/CCTMXLayerRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerRenderCmd.js @@ -109,11 +109,11 @@ cc.g_NumberOfDraws++; }; - proto.setContentSize = function(size, height){ - var node = this._node; - var locContentSize = node._contentSize; - var locCanvas = this._cacheCanvas; - var scaleFactor = cc.contentScaleFactor(); + proto._updateCacheContext = function(size, height){ + var node = this._node, + locContentSize = node._contentSize, + locCanvas = this._cacheCanvas, + scaleFactor = cc.contentScaleFactor(); locCanvas.width = 0 | (locContentSize.width * 1.5 * scaleFactor); locCanvas.height = 0 | (locContentSize.height * 1.5 * scaleFactor); @@ -248,7 +248,7 @@ var proto = cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering; proto.constructor = cc.TMXLayer.WebGLRenderCmd; - proto.setContentSize = function(){}; + proto._updateCacheContext = function(){}; proto.getTexture = cc.SpriteBatchNode.prototype.getTexture; From 8446a69e8f4730195f32b39010f5347bb6b130f5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 20 Nov 2014 21:33:40 +0800 Subject: [PATCH 0938/1564] Issue #2416: Refactor cc.SpriteBatchNode's renderer --- cocos2d/core/sprites/CCSpriteBatchNode.js | 500 ++---------------- .../sprites/CCSpriteBatchNodeRenderCmd.js | 213 +++++++- cocos2d/core/sprites/CCSpriteRenderCmd.js | 2 +- 3 files changed, 244 insertions(+), 471 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 2035fec9ee..5419176f1d 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -24,11 +24,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * @constant - * @type Number - */ -cc.DEFAULT_SPRITE_BATCH_CAPACITY = 29; /** *

    @@ -71,6 +66,23 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ _textureForCanvas: null, _originalTexture: null, + ctor: function (fileImage, capacity) { + cc.Node.prototype.ctor.call(this); + this._descendants = []; + this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); + + var texture2D; + capacity = capacity || cc.SpriteBatchNode.DEFAULT_CAPACITY; + if (cc.isString(fileImage)) { + texture2D = cc.textureCache.getTextureForKey(fileImage); + if (!texture2D) + texture2D = cc.textureCache.addImage(fileImage); + }else if (fileImage instanceof cc.Texture2D) + texture2D = fileImage; + + texture2D && this.initWithTexture(texture2D, capacity); + }, + /** *

    * This is the opposite of "addQuadFromSprite.
    @@ -82,7 +94,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @return {cc.SpriteBatchNode} */ addSpriteWithoutQuad: function (child, z, aTag) { - cc.assert(child, cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2); if (!(child instanceof cc.Sprite)) { @@ -136,7 +147,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @return {Array} */ getDescendants: function () { - return this._descendants; + return this._descendants; }, /** @@ -188,7 +199,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ // this is likely computationally expensive var locCapacity = this.textureAtlas.capacity; var quantity = Math.floor((locCapacity + 1) * 4 / 3); - cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, locCapacity, quantity); if (!this.textureAtlas.resizeCapacity(quantity)) { @@ -258,7 +268,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ */ lowestAtlasIndexInChild: function (sprite) { var children = sprite.children; - if (!children || children.length == 0) return sprite.atlasIndex; else @@ -332,7 +341,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @return {cc.BlendFunc} */ getBlendFunc: function () { - return this._blendFunc; + return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst); }, /** @@ -342,14 +351,11 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {Number} zOrder */ reorderChild: function (child, zOrder) { - cc.assert(child, cc._LogInfos.SpriteBatchNode_reorderChild_2); - if (this._children.indexOf(child) === -1) { cc.log(cc._LogInfos.SpriteBatchNode_reorderChild); return; } - if (zOrder === child.zIndex) return; @@ -377,21 +383,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ cc.Node.prototype.removeChild.call(this, child, cleanup); }, - ctor: function (fileImage, capacity) { - cc.Node.prototype.ctor.call(this); - - var texture2D; - capacity = capacity || cc.DEFAULT_SPRITE_BATCH_CAPACITY; - if (cc.isString(fileImage)) { - texture2D = cc.textureCache.getTextureForKey(fileImage); - if (!texture2D) - texture2D = cc.textureCache.addImage(fileImage); - }else if (fileImage instanceof cc.Texture2D) - texture2D = fileImage; - - texture2D && this.initWithTexture(texture2D, capacity); - }, - /** *

    * Updates a quad at a certain index into the texture atlas. The CCSprite won't be added into the children array.
    @@ -402,70 +393,24 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {cc.Sprite} sprite * @param {Number} index */ - updateQuadFromSprite: null, - - _updateQuadFromSpriteForCanvas: function (sprite, index) { - + updateQuadFromSprite: function (sprite, index) { cc.assert(sprite, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2); - - if (!(sprite instanceof cc.Sprite)) { - cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite); - return; - } - - // - // update the quad directly. Don't add the sprite to the scene graph - // - sprite.batchNode = this; - sprite.atlasIndex = index; - - sprite.dirty = true; - // UpdateTransform updates the textureAtlas quad - sprite.updateTransform(); - }, - - _updateQuadFromSpriteForWebGL: function (sprite, index) { - - cc.assert(sprite, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite); - if (!(sprite instanceof cc.Sprite)) { cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite); return; } - - // make needed room - var locCapacity = this.textureAtlas.capacity; - while (index >= locCapacity || locCapacity == this.textureAtlas.totalQuads) { - this.increaseAtlasCapacity(); - } + this._renderCmd.checkAtlasCapacity(); // // update the quad directly. Don't add the sprite to the scene graph // sprite.batchNode = this; sprite.atlasIndex = index; - sprite.dirty = true; // UpdateTransform updates the textureAtlas quad sprite.updateTransform(); }, - _swap: function (oldIndex, newIndex) { - var locDescendants = this._descendants; - var locTextureAtlas = this.textureAtlas; - var quads = locTextureAtlas.quads; - var tempItem = locDescendants[oldIndex]; - var tempIteQuad = cc.V3F_C4B_T2F_QuadCopy(quads[oldIndex]); - - //update the index of other swapped item - locDescendants[newIndex].atlasIndex = oldIndex; - locDescendants[oldIndex] = locDescendants[newIndex]; - - locTextureAtlas.updateQuad(quads[newIndex], oldIndex); - locDescendants[newIndex] = tempItem; - locTextureAtlas.updateQuad(tempIteQuad, newIndex); - }, - /** *

    * Inserts a quad at a certain index into the texture atlas. The cc.Sprite won't be added into the children array.
    @@ -476,16 +421,13 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {cc.Sprite} sprite * @param {Number} index */ - insertQuadFromSprite: null, - - _insertQuadFromSpriteForCanvas: function (sprite, index) { - + insertQuadFromSprite: function (sprite, index) { cc.assert(sprite, cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2); - if (!(sprite instanceof cc.Sprite)) { cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite); return; } + this._renderCmd.checkAtlasCapacity(); // // update the quad directly. Don't add the sprite to the scene graph @@ -501,88 +443,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ this._children.splice(index, 0, sprite); }, - _insertQuadFromSpriteForWebGL: function (sprite, index) { - cc.assert(sprite, cc._LogInfos.Sprite_insertQuadFromSprite_2); - - if (!(sprite instanceof cc.Sprite)) { - cc.log(cc._LogInfos.Sprite_insertQuadFromSprite); - return; - } - - // make needed room - var locTextureAtlas = this.textureAtlas; - while (index >= locTextureAtlas.capacity || locTextureAtlas.capacity === locTextureAtlas.totalQuads) - this.increaseAtlasCapacity(); - - // - // update the quad directly. Don't add the sprite to the scene graph - // - sprite.batchNode = this; - sprite.atlasIndex = index; - locTextureAtlas.insertQuad(sprite.quad, index); - - // XXX: updateTransform will update the textureAtlas too, using updateQuad. - // XXX: so, it should be AFTER the insertQuad - sprite.dirty = true; - sprite.updateTransform(); - }, - - _updateAtlasIndex: function (sprite, curIndex) { - var count = 0; - var pArray = sprite.children; - if (pArray) - count = pArray.length; - - var oldIndex = 0; - if (count === 0) { - oldIndex = sprite.atlasIndex; - sprite.atlasIndex = curIndex; - sprite.arrivalOrder = 0; - if (oldIndex != curIndex) - this._swap(oldIndex, curIndex); - curIndex++; - } else { - var needNewIndex = true; - if (pArray[0].zIndex >= 0) { - //all children are in front of the parent - oldIndex = sprite.atlasIndex; - sprite.atlasIndex = curIndex; - sprite.arrivalOrder = 0; - if (oldIndex != curIndex) - this._swap(oldIndex, curIndex); - curIndex++; - needNewIndex = false; - } - for (var i = 0; i < pArray.length; i++) { - var child = pArray[i]; - if (needNewIndex && child.zIndex >= 0) { - oldIndex = sprite.atlasIndex; - sprite.atlasIndex = curIndex; - sprite.arrivalOrder = 0; - if (oldIndex != curIndex) { - this._swap(oldIndex, curIndex); - } - curIndex++; - needNewIndex = false; - } - curIndex = this._updateAtlasIndex(child, curIndex); - } - - if (needNewIndex) { - //all children have a zOrder < 0) - oldIndex = sprite.atlasIndex; - sprite.atlasIndex = curIndex; - sprite.arrivalOrder = 0; - if (oldIndex != curIndex) { - this._swap(oldIndex, curIndex); - } - curIndex++; - } - } - - return curIndex; - }, - _updateBlendFunc: function () { if (!this.textureAtlas.texture.hasPremultipliedAlpha()) { this._blendFunc.src = cc.SRC_ALPHA; @@ -601,28 +461,12 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {Number} [capacity] * @return {Boolean} */ - initWithTexture: null, - - _initWithTextureForCanvas: function (tex, capacity) { - this._children = []; - this._descendants = []; - - this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); - this._originalTexture = tex; - this._textureForCanvas = tex; - return true; - }, - - _initWithTextureForWebGL: function (tex, capacity) { - this._children = []; - this._descendants = []; + initWithTexture: function (tex, capacity) { + this._children.length = 0; + this._descendants.length = 0; - this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST); - capacity = capacity || cc.DEFAULT_SPRITE_BATCH_CAPACITY; - this.textureAtlas = new cc.TextureAtlas(); - this.textureAtlas.initWithTexture(tex, capacity); - this._updateBlendFunc(); - this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + capacity = capacity || cc.SpriteBatchNode.DEFAULT_CAPACITY; + this._renderCmd.initWithTexture(tex, capacity); return true; }, @@ -632,6 +476,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {Number} index The insert index */ insertChild: function (sprite, index) { + //TODO WebGL only ? sprite.batchNode = this; sprite.atlasIndex = index; sprite.dirty = true; @@ -668,23 +513,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @function * @param {cc.Sprite} sprite */ - appendChild: null, - - _appendChildForCanvas: function (sprite) { - this._reorderChildDirty = true; - sprite.batchNode = this; - sprite.dirty = true; - - this._descendants.push(sprite); - sprite.atlasIndex = this._descendants.length - 1; - - // add children recursively - var children = sprite.children; - for (var i = 0, l = children.length || 0; i < l; i++) - this.appendChild(children[i]); - }, - - _appendChildForWebGL: function (sprite) { + appendChild: function (sprite) { this._reorderChildDirty = true; sprite.batchNode = this; sprite.dirty = true; @@ -692,11 +521,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ this._descendants.push(sprite); var index = this._descendants.length - 1; sprite.atlasIndex = index; - - var locTextureAtlas = this.textureAtlas; - if (locTextureAtlas.totalQuads == locTextureAtlas.capacity) - this.increaseAtlasCapacity(); - locTextureAtlas.insertQuad(sprite.quad, index); + this._renderCmd.insertQuad(sprite, index); // add children recursively var children = sprite.children; @@ -709,45 +534,17 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @function * @param {cc.Sprite} sprite */ - removeSpriteFromAtlas: null, - - _removeSpriteFromAtlasForCanvas: function (sprite) { - // Cleanup sprite. It might be reused (issue #569) - sprite.batchNode = null; - var locDescendants = this._descendants; - var index = locDescendants.indexOf(sprite); - if (index != -1) { - locDescendants.splice(index, 1) - - // update all sprites beyond this one - var len = locDescendants.length; - for (; index < len; ++index) { - var s = locDescendants[index]; - s.atlasIndex--; - } - } - - // remove children recursively - var children = sprite.children; - if (children) { - for (var i = 0, l = children.length || 0; i < l; i++) - children[i] && this.removeSpriteFromAtlas(children[i]); - } - }, - - _removeSpriteFromAtlasForWebGL: function (sprite) { - this.textureAtlas.removeQuadAtIndex(sprite.atlasIndex); // remove from TextureAtlas + removeSpriteFromAtlas: function (sprite) { + this._renderCmd.removeQuadAtIndex(sprite.atlasIndex); // Cleanup sprite. It might be reused (issue #569) sprite.batchNode = null; - var locDescendants = this._descendants; var index = locDescendants.indexOf(sprite); if (index != -1) { locDescendants.splice(index, 1); // update all sprites beyond this one - var len = locDescendants.length; for (; index < len; ++index) { var s = locDescendants[index]; @@ -766,16 +563,10 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ /** * Returns texture of the sprite batch node * @function - * @return {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} + * @return {cc.Texture2D} */ - getTexture: null, - - _getTextureForCanvas: function () { - return this._textureForCanvas; - }, - - _getTextureForWebGL: function () { - return this.textureAtlas.texture; + getTexture: function () { + return this._renderCmd.getTexture(); }, /** @@ -783,82 +574,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @function * @param {cc.Texture2D} texture */ - setTexture: null, - - _setTextureForCanvas: function (texture) { - this._textureForCanvas = texture; - var locChildren = this._children; - for (var i = 0; i < locChildren.length; i++) - locChildren[i].texture = texture; - }, - - _setTextureForWebGL: function (texture) { - this.textureAtlas.texture = texture; - this._updateBlendFunc(); - }, - - /** - * Don't call visit on its children ( override visit of cc.Node ) - * @function - * @override - * @param {CanvasRenderingContext2D} ctx - */ - visit: null, - - _visitForCanvas: function (ctx) { - var context = ctx || cc._renderContext; - // quick return if not visible - if (!this._visible) - return; - - context.save(); - this.transform(ctx); - var i, locChildren = this._children; - if (locChildren) { - this.sortAllChildren(); - for (i = 0; i < locChildren.length; i++) { - if (locChildren[i]) - locChildren[i].visit(context); - } - } - context.restore(); - }, - - _visitForWebGL: function (ctx) { - var gl = ctx || cc._renderContext; - - // CAREFUL: - // This visit is almost identical to CocosNode#visit - // with the exception that it doesn't call visit on it's children - // - // The alternative is to have a void CCSprite#visit, but - // although this is less mantainable, is faster - // - if (!this._visible) - return; - - var currentStack = cc.current_stack; - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); - currentStack.top = this._stackMatrix; - -/* var locGrid = this.grid; - if (locGrid && locGrid.isActive()) { - locGrid.beforeDraw(); - this.transformAncestors(); - }*/ - - this.sortAllChildren(); - this.transform(gl); - //this.draw(gl); - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - -/* if (locGrid && locGrid.isActive()) - locGrid.afterDraw(this);*/ - - //optimize performance for javascript - currentStack.top = currentStack.stack.pop(); + setTexture: function(texture){ + this._renderCmd.setTexture(texture); }, /** @@ -869,39 +586,20 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {Number} [zOrder] * @param {Number} [tag] */ - addChild: null, - - _addChildForCanvas: function (child, zOrder, tag) { - cc.assert(child != null, cc._LogInfos.CCSpriteBatchNode_addChild_3); - - if (!(child instanceof cc.Sprite)) { - cc.log(cc._LogInfos.CCSpriteBatchNode_addChild); - return; - } - - zOrder = (zOrder == null) ? child.zIndex : zOrder; - tag = (tag == null) ? child.tag : tag; - - cc.Node.prototype.addChild.call(this, child, zOrder, tag); - this.appendChild(child); - this.setNodeDirty(); - }, - - _addChildForWebGL: function (child, zOrder, tag) { + addChild: function (child, zOrder, tag) { cc.assert(child != null, cc._LogInfos.CCSpriteBatchNode_addChild_3); if (!(child instanceof cc.Sprite)) { cc.log(cc._LogInfos.Sprite_addChild_4); return; } - if (child.texture != this.textureAtlas.texture) { // check cc.Sprite is using the same texture id + if (child.texture != this._renderCmd.getTexture()) { cc.log(cc._LogInfos.Sprite_addChild_5); return; } zOrder = (zOrder == null) ? child.zIndex : zOrder; tag = (tag == null) ? child.tag : tag; - cc.Node.prototype.addChild.call(this, child, zOrder, tag); this.appendChild(child); this.setNodeDirty(); @@ -913,24 +611,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @function * @param {Boolean} cleanup */ - removeAllChildren: null, - - _removeAllChildrenForCanvas: function (cleanup) { - // Invalidate atlas index. issue #569 - // useSelfRender should be performed on all descendants. issue #1216 - var locDescendants = this._descendants; - if (locDescendants && locDescendants.length > 0) { - for (var i = 0, len = locDescendants.length; i < len; i++) { - if (locDescendants[i]) - locDescendants[i].batchNode = null; - } - } - - cc.Node.prototype.removeAllChildren.call(this, cleanup); - this._descendants.length = 0; - }, - - _removeAllChildrenForWebGL: function (cleanup) { + removeAllChildren: function (cleanup) { // Invalidate atlas index. issue #569 // useSelfRender should be performed on all descendants. issue #1216 var locDescendants = this._descendants; @@ -942,45 +623,13 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ } cc.Node.prototype.removeAllChildren.call(this, cleanup); this._descendants.length = 0; - this.textureAtlas.removeAllQuads(); + this._renderCmd.removeAllQuads(); }, /** * Sort all children nodes (override draw of cc.Node) */ - sortAllChildren: null, - - //TODO need refactor - _sortAllChildrenForCanvas: function () { - if (this._reorderChildDirty) { - var i, j = 0, locChildren = this._children; - var length = locChildren.length, tempChild; - //insertion sort - for (i = 1; i < length; i++) { - var tempItem = locChildren[i]; - j = i - 1; - tempChild = locChildren[j]; - - //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller - while (j >= 0 && ( tempItem._localZOrder < tempChild._localZOrder || - ( tempItem._localZOrder == tempChild._localZOrder && tempItem.arrivalOrder < tempChild.arrivalOrder ))) { - locChildren[j + 1] = tempChild; - j = j - 1; - tempChild = locChildren[j]; - } - locChildren[j + 1] = tempItem; - } - - //sorted now check all children - if (locChildren.length > 0) { - //first sort all children recursively based on zOrder - this._arrayMakeObjectsPerformSelector(locChildren, cc.Node._stateCallbackType.sortAllChildren); - } - this._reorderChildDirty = false; - } - }, - - _sortAllChildrenForWebGL: function () { + sortAllChildren: function () { if (this._reorderChildDirty) { var childrenArr = this._children; var i, j = 0, length = childrenArr.length, tempChild; @@ -1005,69 +654,16 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //first sort all children recursively based on zOrder this._arrayMakeObjectsPerformSelector(childrenArr, cc.Node._stateCallbackType.sortAllChildren); - var index = 0; - //fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact) - // and at the same time reorder descedants and the quads to the right index - for (i = 0; i < childrenArr.length; i++) - index = this._updateAtlasIndex(childrenArr[i], index); + this._renderCmd.updateChildrenAtlasIndex(childrenArr); + } this._reorderChildDirty = false; } - }, - - /** - * Draw the sprite batch node (override draw of cc.Node) - * @function - */ - draw: null, - - _drawForWebGL: function () { - // Optimization: Fast Dispatch - if (this.textureAtlas.totalQuads === 0) - return; - - //cc.nodeDrawSetup(this); - this._shaderProgram.use(); - this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); - this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.updateTransform); - cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - - this.textureAtlas.drawQuads(); } }); var _p = cc.SpriteBatchNode.prototype; -if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - _p.ctor = _p._ctorForWebGL; - _p.updateQuadFromSprite = _p._updateQuadFromSpriteForWebGL; - _p.insertQuadFromSprite = _p._insertQuadFromSpriteForWebGL; - _p.initWithTexture = _p._initWithTextureForWebGL; - _p.appendChild = _p._appendChildForWebGL; - _p.removeSpriteFromAtlas = _p._removeSpriteFromAtlasForWebGL; - _p.getTexture = _p._getTextureForWebGL; - _p.setTexture = _p._setTextureForWebGL; - _p.visit = _p._visitForWebGL; - _p.addChild = _p._addChildForWebGL; - _p.removeAllChildren = _p._removeAllChildrenForWebGL; - _p.sortAllChildren = _p._sortAllChildrenForWebGL; - _p.draw = _p._drawForWebGL; -} else { - _p.ctor = _p._ctorForCanvas; - _p.updateQuadFromSprite = _p._updateQuadFromSpriteForCanvas; - _p.insertQuadFromSprite = _p._insertQuadFromSpriteForCanvas; - _p.initWithTexture = _p._initWithTextureForCanvas; - _p.appendChild = _p._appendChildForCanvas; - _p.removeSpriteFromAtlas = _p._removeSpriteFromAtlasForCanvas; - _p.getTexture = _p._getTextureForCanvas; - _p.setTexture = _p._setTextureForCanvas; - _p.visit = _p._visitForCanvas; - _p.removeAllChildren = _p._removeAllChildrenForCanvas; - _p.addChild = _p._addChildForCanvas; - _p.sortAllChildren = _p._sortAllChildrenForCanvas; - _p.draw = cc.Node.prototype.draw; -} - // Override properties cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); @@ -1077,6 +673,12 @@ _p.descendants; cc.defineGetterSetter(_p, "descendants", _p.getDescendants); +/** + * @constant + * @type Number + */ +cc.SpriteBatchNode.DEFAULT_CAPACITY = 29; + /** *

    * creates a cc.SpriteBatchNodeCanvas with a file image (.png, .jpg etc) with a default capacity of 29 children.
    diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js index d521edb65a..1cf36dd473 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js @@ -22,30 +22,201 @@ THE SOFTWARE. ****************************************************************************/ -cc.SpriteBatchNode.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); +(function(){ + //SpriteBatchNode's canvas render command + cc.SpriteBatchNode.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); - this._texture = null; -}; + this._texture = null; + this._originalTexture = null; + }; -cc.SpriteBatchNode.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; + var proto = cc.SpriteBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.SpriteBatchNode.CanvasRenderCmd; -cc.SpriteBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.SpriteBatchNode.WebGLRenderCmd.prototype.constructor = cc.SpriteBatchNode.WebGLRenderCmd; + proto.checkAtlasCapacity = function(){}; -cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering = function () { - var node = this._node; - if (node.textureAtlas.totalQuads === 0) - return; + proto.initWithTexture = function(texture, capacity){ + this._originalTexture = texture; + this._textureForCanvas = texture; + }; - //cc.nodeDrawSetup(this); - this._shaderProgram.use(); - this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + proto.insertQuad = function(){}; - node.textureAtlas.drawQuads(); -}; \ No newline at end of file + proto.removeQuadAtIndex = function(){}; + + proto.removeAllQuads = function(){}; + + proto.getTexture = function(){ + return this._texture; + }; + + proto.setTexture = function(texture){ + this._textureForCanvas = texture; + var locChildren = this._node._children; + for (var i = 0; i < locChildren.length; i++) + locChildren[i].setTexture(texture); + }; + + proto.updateChildrenAtlasIndex = function(){ } +})(); + +(function(){ + //SpriteBatchNode's WebGL render command + cc.SpriteBatchNode.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + + this._textureAtlas = null; + }; + + var proto = cc.SpriteBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.SpriteBatchNode.WebGLRenderCmd; + + proto.rendering = function () { + var node = this._node; + if (this._textureAtlas.totalQuads === 0) + return; + + //cc.nodeDrawSetup(this); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + + this._textureAtlas.drawQuads(); + }; + + proto.checkAtlasCapacity = function(index){ + // make needed room + var locCapacity = this._textureAtlas.capacity; + while (index >= locCapacity || locCapacity == this._textureAtlas.totalQuads) { + this.increaseAtlasCapacity(); + } + }; + + proto.increaseAtlasCapacity = function(){ + // if we're going beyond the current TextureAtlas's capacity, + // all the previously initialized sprites will need to redo their texture coords + // this is likely computationally expensive + var locCapacity = this._textureAtlas.capacity; + var quantity = Math.floor((locCapacity + 1) * 4 / 3); + + cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, locCapacity, quantity); + + if (!this._textureAtlas.resizeCapacity(quantity)) { + // serious problems + cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2); + } + }; + + proto.initWithTexture = function(texture, capacity){ + this._textureAtlas = new cc.TextureAtlas(); + this._textureAtlas.initWithTexture(texture, capacity); + this._node._updateBlendFunc(); + this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + }; + + proto.insertQuad = function(sprite, index){ + var locTextureAtlas = this._textureAtlas; + if (locTextureAtlas.totalQuads >= locTextureAtlas.capacity) + this.increaseAtlasCapacity(); + locTextureAtlas.insertQuad(sprite.quad, index); + }; + + proto.removeQuadAtIndex = function(index){ + this._textureAtlas.removeQuadAtIndex(index); // remove from TextureAtlas + }; + + proto.getTexture = function(){ + return this._textureAtlas.texture; + }; + + proto.setTexture = function(texture){ + this._textureAtlas.setTexture(texture); + this._updateBlendFunc(); + }; + + proto.removeAllQuads = function(){ + this._textureAtlas.removeAllQuads(); + }; + + proto._swap = function (oldIndex, newIndex) { + var locDescendants = this._node._descendants; + var locTextureAtlas = this._textureAtlas; + var quads = locTextureAtlas.quads; + var tempItem = locDescendants[oldIndex]; + var tempIteQuad = cc.V3F_C4B_T2F_QuadCopy(quads[oldIndex]); + + //update the index of other swapped item + locDescendants[newIndex].atlasIndex = oldIndex; + locDescendants[oldIndex] = locDescendants[newIndex]; + + locTextureAtlas.updateQuad(quads[newIndex], oldIndex); + locDescendants[newIndex] = tempItem; + locTextureAtlas.updateQuad(tempIteQuad, newIndex); + }; + + proto._updateAtlasIndex = function (sprite, curIndex) { + var count = 0; + var pArray = sprite.children; + if (pArray) + count = pArray.length; + + var oldIndex = 0; + if (count === 0) { + oldIndex = sprite.atlasIndex; + sprite.atlasIndex = curIndex; + sprite.arrivalOrder = 0; + if (oldIndex != curIndex) + this._swap(oldIndex, curIndex); + curIndex++; + } else { + var needNewIndex = true; + if (pArray[0].zIndex >= 0) { + //all children are in front of the parent + oldIndex = sprite.atlasIndex; + sprite.atlasIndex = curIndex; + sprite.arrivalOrder = 0; + if (oldIndex != curIndex) + this._swap(oldIndex, curIndex); + curIndex++; + needNewIndex = false; + } + for (var i = 0; i < pArray.length; i++) { + var child = pArray[i]; + if (needNewIndex && child.zIndex >= 0) { + oldIndex = sprite.atlasIndex; + sprite.atlasIndex = curIndex; + sprite.arrivalOrder = 0; + if (oldIndex != curIndex) { + this._swap(oldIndex, curIndex); + } + curIndex++; + needNewIndex = false; + } + curIndex = this._updateAtlasIndex(child, curIndex); + } + + if (needNewIndex) { + //all children have a zOrder < 0) + oldIndex = sprite.atlasIndex; + sprite.atlasIndex = curIndex; + sprite.arrivalOrder = 0; + if (oldIndex != curIndex) { + this._swap(oldIndex, curIndex); + } + curIndex++; + } + } + return curIndex; + }; + + proto.updateChildrenAtlasIndex = function(children){ + var index = 0; + //fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact) + // and at the same time reorder descedants and the quads to the right index + for (var i = 0; i < children.length; i++) + index = this._updateAtlasIndex(children[i], index); + } +})(); diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index 7fc3c442de..bd5bb396e7 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -569,7 +569,7 @@ cc.Sprite.WebGLRenderCmd = function(renderable){ this._quadDirty = true; }; -cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd); +cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); cc.Sprite.WebGLRenderCmd.prototype.constructor = cc.Sprite.WebGLRenderCmd; cc.Sprite.WebGLRenderCmd.prototype.updateBlendFunc = function(blendFunc){ From affe8e125904a02f175535ad69a0d5808cfb3f08 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 20 Nov 2014 21:47:18 +0800 Subject: [PATCH 0939/1564] Issue #2416: refactor cc.SpriteBatchNode's renderer --- cocos2d/core/sprites/CCSpriteBatchNode.js | 32 +++---------------- .../sprites/CCSpriteBatchNodeRenderCmd.js | 31 +++++++++++++++--- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 5419176f1d..33005ad0a2 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -56,16 +56,11 @@ * @property {Array} descendants - <@readonly> Descendants of sprite batch node */ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ - textureAtlas: null, - _blendFunc: null, // all descendants: chlidren, gran children, etc... _descendants: null, _className: "SpriteBatchNode", - _textureForCanvas: null, - _originalTexture: null, - ctor: function (fileImage, capacity) { cc.Node.prototype.ctor.call(this); this._descendants = []; @@ -129,7 +124,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @return {cc.TextureAtlas} */ getTextureAtlas: function () { - return this.textureAtlas; + return this._renderCmd.getTexture(); }, /** @@ -137,9 +132,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {cc.TextureAtlas} textureAtlas */ setTextureAtlas: function (textureAtlas) { - if (textureAtlas != this.textureAtlas) { - this.textureAtlas = textureAtlas; - } + this._renderCmd.setTexture(textureAtlas); }, /** @@ -194,17 +187,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * Increase Atlas Capacity */ increaseAtlasCapacity: function () { - // if we're going beyond the current TextureAtlas's capacity, - // all the previously initialized sprites will need to redo their texture coords - // this is likely computationally expensive - var locCapacity = this.textureAtlas.capacity; - var quantity = Math.floor((locCapacity + 1) * 4 / 3); - cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, locCapacity, quantity); - - if (!this.textureAtlas.resizeCapacity(quantity)) { - // serious problems - cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2); - } + this._renderCmd.increaseAtlasCapacity(); }, /** @@ -443,13 +426,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ this._children.splice(index, 0, sprite); }, - _updateBlendFunc: function () { - if (!this.textureAtlas.texture.hasPremultipliedAlpha()) { - this._blendFunc.src = cc.SRC_ALPHA; - this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - } - }, - /** *

    * Initializes a cc.SpriteBatchNode with a texture2d and capacity of children.
    @@ -481,7 +457,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ sprite.atlasIndex = index; sprite.dirty = true; - var locTextureAtlas = this.textureAtlas; + var locTextureAtlas = this.getTextureAtlas(); if (locTextureAtlas.totalQuads >= locTextureAtlas.capacity) this.increaseAtlasCapacity(); diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js index 1cf36dd473..a48402ae83 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js @@ -43,6 +43,8 @@ proto.insertQuad = function(){}; + proto.increaseAtlasCapacity = function(){}; + proto.removeQuadAtIndex = function(){}; proto.removeAllQuads = function(){}; @@ -58,7 +60,11 @@ locChildren[i].setTexture(texture); }; - proto.updateChildrenAtlasIndex = function(){ } + proto.updateChildrenAtlasIndex = function(){ }; + + proto.getTextureAtlas = function(){}; + + proto.setTextureAtlas = function(textureAtlas){}; })(); (function(){ @@ -113,8 +119,8 @@ proto.initWithTexture = function(texture, capacity){ this._textureAtlas = new cc.TextureAtlas(); this._textureAtlas.initWithTexture(texture, capacity); - this._node._updateBlendFunc(); - this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + this._updateBlendFunc(); + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; proto.insertQuad = function(sprite, index){ @@ -218,5 +224,22 @@ // and at the same time reorder descedants and the quads to the right index for (var i = 0; i < children.length; i++) index = this._updateAtlasIndex(children[i], index); - } + }; + + proto._updateBlendFunc = function () { + if (!this._textureAtlas.texture.hasPremultipliedAlpha()) { + this._blendFunc.src = cc.SRC_ALPHA; + this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + } + }; + + proto.getTextureAtlas = function(){ + return this._textureAtlas; + }; + + proto.setTextureAtlas = function(textureAtlas){ + if (textureAtlas != this._textureAtlas) { + this._textureAtlas = textureAtlas; + } + }; })(); From bda28bdbefdef5713188c12356e8f880988291be Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 21 Nov 2014 17:31:19 +0800 Subject: [PATCH 0940/1564] Issue #2416: refactor cc.ClippingNode's renderer --- cocos2d/clipping-nodes/CCClippingNode.js | 457 +--------------- .../clipping-nodes/CCClippingNodeRenderCmd.js | 491 ++++++++++++++---- cocos2d/core/base-nodes/CCNode.js | 6 +- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 18 +- cocos2d/core/layers/CCLayerRenderCmd.js | 22 +- cocos2d/core/renderer/RendererCanvas.js | 13 +- cocos2d/core/renderer/RendererWebGL.js | 11 - cocos2d/core/sprites/CCSpriteBatchNode.js | 11 +- cocos2d/core/textures/CCTextureAtlas.js | 4 +- cocos2d/node-grid/CCNodeGrid.js | 4 +- cocos2d/particle/CCParticleSystemRenderCmd.js | 2 +- cocos2d/physics/CCPhysicsSpriteRenderCmd.js | 3 +- .../CCProgressTimerRenderCmd.js | 2 +- cocos2d/shape-nodes/CCDrawNodeRenderCmd.js | 2 +- cocos2d/tilemap/CCTMXLayerRenderCmd.js | 8 +- .../ccui/base-classes/CCProtectedNode.js | 2 +- extensions/ccui/layouts/UILayout.js | 22 +- .../cocostudio/armature/display/CCSkin.js | 4 +- extensions/gui/scrollview/CCScrollView.js | 14 +- extensions/spine/CCSkeletonRenderCmd.js.js | 2 +- 20 files changed, 496 insertions(+), 602 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index c6ab026462..7d73097c3f 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -50,41 +50,20 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ alphaThreshold: 0, inverted: false, - _rendererSaveCmd: null, - _rendererClipCmd: null, - _rendererRestoreCmd: null, - - _beforeVisitCmd: null, - _afterDrawStencilCmd: null, - _afterVisitCmd: null, - _stencil: null, - _godhelpme: false, - _clipElemType: null, - - _currentStencilFunc: null, - _currentStencilRef: null, - _currentStencilValueMask: null, - _currentStencilFail: null, - _currentStencilPassDepthFail: null, - _currentStencilPassDepthPass:null, - _currentStencilWriteMask:null, - _currentStencilEnabled:null, - _currentDepthWriteMask: null, - _mask_layer_le: null, - + _className: "ClippingNode", /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @param {cc.Node} [stencil=null] */ ctor: function (stencil) { + stencil = stencil || null; cc.Node.prototype.ctor.call(this); - this._stencil = null; - this.alphaThreshold = 0; + this._stencil = stencil; + this.alphaThreshold = 1; this.inverted = false; - stencil = stencil || null; - cc.ClippingNode.prototype.init.call(this, stencil); + this._renderCmd.initStencilBits(); }, /** @@ -92,30 +71,11 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ * @function * @param {cc.Node} [stencil=null] */ - init: null, - - _className: "ClippingNode", - - _initForWebGL: function (stencil) { - this._stencil = stencil; - - this.alphaThreshold = 1; - this.inverted = false; - // get (only once) the number of bits of the stencil buffer - cc.ClippingNode._init_once = true; - if (cc.ClippingNode._init_once) { - cc.stencilBits = cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS); - if (cc.stencilBits <= 0) - cc.log("Stencil buffer is not enabled."); - cc.ClippingNode._init_once = false; - } - return true; - }, - - _initForCanvas: function (stencil) { + init: function (stencil) { this._stencil = stencil; this.alphaThreshold = 1; this.inverted = false; + this._renderCmd.initStencilBits(); return true; }, @@ -173,351 +133,6 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ cc.Node.prototype.onExit.call(this); }, - /** - * Recursive method that visit its children and draw them - * @function - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx - */ - visit: null, - - _visitForWebGL: function (ctx) { - var gl = ctx || cc._renderContext; - - // if stencil buffer disabled - if (cc.stencilBits < 1) { - // draw everything, as if there where no stencil - cc.Node.prototype.visit.call(this, ctx); - return; - } - - if (!this._stencil || !this._stencil.visible) { - if (this.inverted) - cc.Node.prototype.visit.call(this, ctx); // draw everything - return; - } - - if (cc.ClippingNode._layer + 1 == cc.stencilBits) { - cc.ClippingNode._visit_once = true; - if (cc.ClippingNode._visit_once) { - cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its children."); - cc.ClippingNode._visit_once = false; - } - // draw everything, as if there where no stencil - cc.Node.prototype.visit.call(this, ctx); - return; - } - - cc.renderer.pushRenderCommand(this._beforeVisitCmd); - - //optimize performance for javascript - var currentStack = cc.current_stack; - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); - currentStack.top = this._stackMatrix; - - this.transform(); - //this._stencil._stackMatrix = this._stackMatrix; - this._stencil.visit(); - - cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); - - // draw (according to the stencil test func) this node and its children - var locChildren = this._children; - if (locChildren && locChildren.length > 0) { - var childLen = locChildren.length; - this.sortAllChildren(); - // draw children zOrder < 0 - for (var i = 0; i < childLen; i++) { - if (locChildren[i] && locChildren[i]._localZOrder < 0) - locChildren[i].visit(); - else - break; - } - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - // draw children zOrder >= 0 - for (; i < childLen; i++) { - if (locChildren[i]) { - locChildren[i].visit(); - } - } - } else{ - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - } - - cc.renderer.pushRenderCommand(this._afterVisitCmd); - - //optimize performance for javascript - currentStack.top = currentStack.stack.pop(); - }, - - _onBeforeVisit: function(ctx){ - var gl = ctx || cc._renderContext; - /////////////////////////////////// - // INIT - - // increment the current layer - cc.ClippingNode._layer++; - - // mask of the current layer (ie: for layer 3: 00000100) - var mask_layer = 0x1 << cc.ClippingNode._layer; - // mask of all layers less than the current (ie: for layer 3: 00000011) - var mask_layer_l = mask_layer - 1; - // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) - //var mask_layer_le = mask_layer | mask_layer_l; - this._mask_layer_le = mask_layer | mask_layer_l; - // manually save the stencil state - this._currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); - this._currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); - this._currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); - this._currentStencilRef = gl.getParameter(gl.STENCIL_REF); - this._currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); - this._currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); - this._currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); - this._currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); - - // enable stencil use - gl.enable(gl.STENCIL_TEST); - // check for OpenGL error while enabling stencil test - //cc.checkGLErrorDebug(); - - // all bits on the stencil buffer are readonly, except the current layer bit, - // this means that operation like glClear or glStencilOp will be masked with this value - gl.stencilMask(mask_layer); - - // manually save the depth test state - //GLboolean currentDepthTestEnabled = GL_TRUE; - //currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); - //var currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); - this._currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); - // disable depth test while drawing the stencil - //glDisable(GL_DEPTH_TEST); - // disable update to the depth buffer while drawing the stencil, - // as the stencil is not meant to be rendered in the real scene, - // it should never prevent something else to be drawn, - // only disabling depth buffer update should do - gl.depthMask(false); - - /////////////////////////////////// - // CLEAR STENCIL BUFFER - - // manually clear the stencil buffer by drawing a fullscreen rectangle on it - // setup the stencil test func like this: - // for each pixel in the fullscreen rectangle - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 0 in the stencil buffer - // if in inverted mode: set the current layer value to 1 in the stencil buffer - gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(!this.inverted ? gl.ZERO : gl.REPLACE, gl.KEEP, gl.KEEP); - - this._drawFullScreenQuadClearStencil(); - - // DRAW CLIPPING STENCIL - // setup the stencil test func like this: - // for each pixel in the stencil node - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 1 in the stencil buffer - // if in inverted mode: set the current layer value to 0 in the stencil buffer - gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(!this.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP); - - if (this.alphaThreshold < 1) { //TODO desktop - // since glAlphaTest do not exists in OES, use a shader that writes - // pixel only if greater than an alpha threshold - var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST); - var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S); - // set our alphaThreshold - cc.glUseProgram(program.getProgram()); - program.setUniformLocationWith1f(alphaValueLocation, this.alphaThreshold); - // we need to recursively apply this shader to all the nodes in the stencil node - // XXX: we should have a way to apply shader to all nodes without having to do this - cc.setProgram(this._stencil, program); - } - }, - - _drawFullScreenQuadClearStencil: function () { - // draw a fullscreen solid rectangle to clear the stencil buffer - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255)); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix(); - }, - - _onAfterDrawStencil: function(ctx){ - var gl = ctx || cc._renderContext; - // restore alpha test state - //if (this.alphaThreshold < 1) { - // XXX: we need to find a way to restore the shaders of the stencil node and its children - //} - - // restore the depth test state - gl.depthMask(this._currentDepthWriteMask); - - /////////////////////////////////// - // DRAW CONTENT - - // setup the stencil test func like this: - // for each pixel of this node and its childs - // if all layers less than or equals to the current are set to 1 in the stencil buffer - // draw the pixel and keep the current layer in the stencil buffer - // else - // do not draw the pixel but keep the current layer in the stencil buffer - gl.stencilFunc(gl.EQUAL, this._mask_layer_le, this._mask_layer_le); - gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); - }, - - _onAfterVisit: function(ctx){ - var gl = ctx || cc._renderContext; - /////////////////////////////////// - // CLEANUP - - // manually restore the stencil state - gl.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask); - gl.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass); - gl.stencilMask(this._currentStencilWriteMask); - if (!this._currentStencilEnabled) - gl.disable(gl.STENCIL_TEST); - - // we are done using this layer, decrement - cc.ClippingNode._layer--; - }, - - _visitForCanvas: function (ctx) { - // Composition mode, costy but support texture stencil - this._clipElemType = (this._cangodhelpme() || this._stencil instanceof cc.Sprite); - - var context = ctx || cc._renderContext; - var i, children = this._children, locChild; - - if (!this._stencil || !this._stencil.visible) { - if (this.inverted) - cc.Node.prototype.visit.call(this, ctx); // draw everything - return; - } - - if(this._rendererSaveCmd) - cc.renderer.pushRenderCommand(this._rendererSaveCmd); - - if(this._clipElemType){ - - // Draw everything first using node visit function - cc.Node.prototype.visit.call(this, context); - }else{ - this._stencil.visit(context); - } - - if(this._rendererClipCmd) - cc.renderer.pushRenderCommand(this._rendererClipCmd); - - this.transform(); - - if(this._clipElemType){ - this._stencil.visit(); - }else{ - // Clip mode doesn't support recusive stencil, so once we used a clip stencil, - // so if it has ClippingNode as a child, the child must uses composition stencil. - this._cangodhelpme(true); - var len = children.length; - if (len > 0) { - this.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - locChild = children[i]; - if (locChild._localZOrder < 0) - locChild.visit(context); - else - break; - } - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - for (; i < len; i++) { - children[i].visit(context); - } - } else - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - this._cangodhelpme(false); - - } - - if(this._rendererRestoreCmd) - cc.renderer.pushRenderCommand(this._rendererRestoreCmd); - }, - - /** - * The cc.Node to use as a stencil to do the clipping.
    - * The stencil node will be retained. This default to nil. - * @return {cc.Node} - */ - getStencil: function () { - return this._stencil; - }, - - /** - * Set stencil. - * @function - * @param {cc.Node} stencil - */ - setStencil: null, - - _setStencilForWebGL: function (stencil) { - if(this._stencil == stencil) - return; - if(this._stencil) - this._stencil._parent = null; - this._stencil = stencil; - if(this._stencil) - this._stencil._parent = this; - }, - - _setStencilForCanvas: function (stencil) { - this._stencil = stencil; - if(stencil._buffer){ - for(var i=0; i * The alpha threshold.
    @@ -559,59 +174,41 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ this.inverted = inverted; }, - _cangodhelpme: function (godhelpme) { - if (godhelpme === true || godhelpme === false) - cc.ClippingNode.prototype._godhelpme = godhelpme; - return cc.ClippingNode.prototype._godhelpme; + /** + * The cc.Node to use as a stencil to do the clipping.
    + * The stencil node will be retained. This default to nil. + * @return {cc.Node} + */ + getStencil: function () { + return this._stencil; }, - _transformForRenderer: function(parentMatrix){ - cc.Node.prototype._transformForRenderer.call(this, parentMatrix); - if(this._stencil) - this._stencil._transformForRenderer(this._stackMatrix); + /** + * Set stencil. + * @function + * @param {cc.Node} stencil + */ + setStencil: function (stencil) { + if(this._stencil == stencil) + return; + this._renderCmd.setStencil(stencil); }, _createRenderCmd: function(){ - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererSaveCmd = new cc.ClippingNode.CanvasSaveRenderCmd(this); - this._rendererClipCmd = new cc.ClippingNode.CanvasClipRenderCmd(this); - this._rendererRestoreCmd = new cc.ClippingNode.CanvasRestoreRenderCmd(this); - }else{ - this._beforeVisitCmd = new cc.ClippingNode.WebGLRenderCmd(this, this._onBeforeVisit); - this._afterDrawStencilCmd = new cc.ClippingNode.WebGLRenderCmd(this, this._onAfterDrawStencil); - this._afterVisitCmd = new cc.ClippingNode.WebGLRenderCmd(this, this._onAfterVisit); - } + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.ClippingNode.CanvasRenderCmd(this); + else + return new cc.ClippingNode.WebGLRenderCmd(this); } }); var _p = cc.ClippingNode.prototype; -if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - //WebGL - _p.init = _p._initForWebGL; - _p.visit = _p._visitForWebGL; - _p.setStencil = _p._setStencilForWebGL; -} else { - _p.init = _p._initForCanvas; - _p.visit = _p._visitForCanvas; - _p.setStencil = _p._setStencilForCanvas; -} - // Extended properties cc.defineGetterSetter(_p, "stencil", _p.getStencil, _p.setStencil); /** @expose */ _p.stencil; - -cc.ClippingNode._init_once = null; -cc.ClippingNode._visit_once = null; -cc.ClippingNode._layer = -1; -cc.ClippingNode._sharedCache = null; - -cc.ClippingNode._getSharedCache = function () { - return (cc.ClippingNode._sharedCache) || (cc.ClippingNode._sharedCache = document.createElement("canvas")); -}; - /** * Creates and initializes a clipping node with an other node as its stencil.
    * The stencil node will be retained. diff --git a/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js index 524bd73e82..446e5cc1f6 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js @@ -22,108 +22,411 @@ THE SOFTWARE. ****************************************************************************/ -cc.ClippingNode.CanvasSaveRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -cc.ClippingNode.CanvasSaveRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var context = ctx || cc._renderContext; - - if (node._clipElemType) { - var locCache = cc.ClippingNode._getSharedCache(); - var canvas = context.canvas; - locCache.width = canvas.width; - locCache.height = canvas.height; - var locCacheCtx = locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - context.save(); - } else { - node.transform(); - var t = node._transformWorld; - context.save(); - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } -}; - -cc.ClippingNode.CanvasSaveRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.ClippingNode.CanvasSaveRenderCmd.prototype.constructor = cc.ClippingNode.CanvasSaveRenderCmd; - -cc.ClippingNode.CanvasClipRenderCmd = function (renderableObject) { - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -cc.ClippingNode.CanvasClipRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - var context = ctx || cc._renderContext; - - if (node._clipElemType) { - context.globalCompositeOperation = node.inverted ? "destination-out" : "destination-in"; - var t = node._transformWorld; - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } else { - context.restore(); - if (node.inverted) { +//-------------------------- ClippingNode's canvas render cmd -------------------------------- +(function(){ + cc.ClippingNode.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; + this._godhelpme = false; + this._clipElemType = null; + + this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._saveCmdCallback); + this._rendererClipCmd = new cc.CustomRenderCmd(this, this._clipCmdCallback); + this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._restoreCmdCallback); + }; + var proto = cc.ClippingNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ClippingNode.CanvasRenderCmd; + + proto.initStencilBits = function(){}; + + proto.setStencil = function(stencil){ + if(stencil == null) + return; + + this._node._stencil = stencil; + // For texture stencil, use the sprite itself + //if (stencil instanceof cc.Sprite) { + // return; + //} + // For shape stencil, rewrite the draw of stencil ,only init the clip path and draw nothing. + //else + if (stencil instanceof cc.DrawNode) { + if(stencil._buffer){ + for(var i=0; i 0) { + this.sortAllChildren(); + for (i = 0; i < len; i++) + children[i]._renderCmd.visit(this); + } + this._cangodhelpme(false); + } -cc.ClippingNode.CanvasRestoreRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.ClippingNode.CanvasRestoreRenderCmd.prototype.constructor = cc.ClippingNode.CanvasRestoreRenderCmd; + cc.renderer.pushRenderCommand(this._rendererRestoreCmd); + }; -cc.ClippingNode.WebGLRenderCmd = function(renderableObject, callback){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; - this._callback = callback; -}; + cc.ClippingNode.CanvasRenderCmd._sharedCache = null; + cc.ClippingNode.CanvasRenderCmd._getSharedCache = function () { + return (cc.ClippingNode.CanvasRenderCmd._sharedCache) || (cc.ClippingNode.CanvasRenderCmd._sharedCache = document.createElement("canvas")); + }; +})(); -cc.ClippingNode.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.ClippingNode.WebGLRenderCmd.prototype.constructor = cc.ClippingNode.WebGLRenderCmd; +// ------------------------------- ClippingNode's WebGL render cmd ------------------------------ +(function(){ + cc.ClippingNode.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = false; -cc.ClippingNode.WebGLRenderCmd.prototype.rendering = function (ctx) { - if (!this._callback) - return; - this._callback.call(this._node, ctx); -}; \ No newline at end of file + this._beforeVisitCmd = new cc.CustomRenderCmd(this, this._onBeforeVisit); + this._afterDrawStencilCmd = new cc.CustomRenderCmd(this, this._onAfterDrawStencil); + this._afterVisitCmd = new cc.CustomRenderCmd(this, this._onAfterVisit); + + this._currentStencilFunc = null; + this._currentStencilRef = null; + this._currentStencilValueMask = null; + this._currentStencilFail = null; + this._currentStencilPassDepthFail = null; + this._currentStencilPassDepthPass = null; + this._currentStencilWriteMask = null; + this._currentStencilEnabled = null; + this._currentDepthWriteMask = null; + this._mask_layer_le = null; + }; + + var proto = cc.ClippingNode.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ClippingNode.WebGLRenderCmd; + + cc.ClippingNode.WebGLRenderCmd._init_once = null; + cc.ClippingNode.WebGLRenderCmd._visit_once = null; + cc.ClippingNode.WebGLRenderCmd._layer = -1; + + proto.initStencilBits = function(){ + // get (only once) the number of bits of the stencil buffer + cc.ClippingNode.WebGLRenderCmd._init_once = true; + if (cc.ClippingNode.WebGLRenderCmd._init_once) { + cc.stencilBits = cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS); + if (cc.stencilBits <= 0) + cc.log("Stencil buffer is not enabled."); + cc.ClippingNode.WebGLRenderCmd._init_once = false; + } + }; + + proto.transform = function(parentCmd, recursive){ + cc.Node.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); + if(this._stencil) + this._stencil._renderCmd.transform(parentCmd, recursive); + }; + + proto.visit = function(parentCmd){ + var _t = this, node = this._node; + // quick return if not visible + if (!_t._visible) + return; + + if( node._parent && node._parent._renderCmd) + this._curLevel = node._parent._renderCmd._curLevel + 1; + + // if stencil buffer disabled + if (cc.stencilBits < 1) { + // draw everything, as if there where no stencil + cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); + return; + } + + if (!this._stencil || !this._stencil.visible) { + if (this.inverted) + cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); // draw everything + return; + } + + if (cc.ClippingNode.WebGLRenderCmd._layer + 1 == cc.stencilBits) { + cc.ClippingNode.WebGLRenderCmd._visit_once = true; + if (cc.ClippingNode.WebGLRenderCmd._visit_once) { + cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its children."); + cc.ClippingNode.WebGLRenderCmd._visit_once = false; + } + // draw everything, as if there where no stencil + cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); + return; + } + + cc.renderer.pushRenderCommand(this._beforeVisitCmd); + + //optimize performance for javascript + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; + + this._syncStatus(parentCmd); + //this._stencil._stackMatrix = this._stackMatrix; + this._stencil.visit(parentCmd); + + cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); + + // draw (according to the stencil test func) this node and its children + var locChildren = this._children; + if (locChildren && locChildren.length > 0) { + var childLen = locChildren.length; + this.sortAllChildren(); + // draw children zOrder < 0 + for (var i = 0; i < childLen; i++) { + if (locChildren[i] && locChildren[i]._localZOrder < 0) + locChildren[i].visit(); + else + break; + } + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); + // draw children zOrder >= 0 + for (; i < childLen; i++) { + if (locChildren[i]) { + locChildren[i].visit(); + } + } + } else{ + if(this._renderCmd) + cc.renderer.pushRenderCommand(this._renderCmd); + } + + cc.renderer.pushRenderCommand(this._afterVisitCmd); + + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); + }; + + proto.setStencil = function(stencil){ + var node = this._node; + if(node._stencil) + node._stencil._parent = null; + node._stencil = stencil; + if(node._stencil) + node._stencil._parent = this; + }; + + proto._drawFullScreenQuadClearStencil = function () { + // draw a fullscreen solid rectangle to clear the stencil buffer + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255)); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix(); + }; + + proto._onBeforeVisit = function(ctx){ + var gl = ctx || cc._renderContext; + cc.ClippingNode.WebGLRenderCmd._layer++; + + // mask of the current layer (ie: for layer 3: 00000100) + var mask_layer = 0x1 << cc.ClippingNode.WebGLRenderCmd._layer; + // mask of all layers less than the current (ie: for layer 3: 00000011) + var mask_layer_l = mask_layer - 1; + // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) + //var mask_layer_le = mask_layer | mask_layer_l; + this._mask_layer_le = mask_layer | mask_layer_l; + // manually save the stencil state + this._currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); + this._currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); + this._currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); + this._currentStencilRef = gl.getParameter(gl.STENCIL_REF); + this._currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); + this._currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); + this._currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); + this._currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); + + // enable stencil use + gl.enable(gl.STENCIL_TEST); + gl.stencilMask(mask_layer); + this._currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); + + gl.depthMask(false); + + gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); + gl.stencilOp(!this.inverted ? gl.ZERO : gl.REPLACE, gl.KEEP, gl.KEEP); + + this._drawFullScreenQuadClearStencil(); + + gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); + gl.stencilOp(!this.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP); + + if (this.alphaThreshold < 1) { //TODO desktop + var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST); + var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S); + // set our alphaThreshold + cc.glUseProgram(program.getProgram()); + program.setUniformLocationWith1f(alphaValueLocation, this.alphaThreshold); + cc.setProgram(this._stencil, program); + } + }; + + proto._onAfterDrawStencil = function(ctx){ + var gl = ctx || cc._renderContext; + gl.depthMask(this._currentDepthWriteMask); + + gl.stencilFunc(gl.EQUAL, this._mask_layer_le, this._mask_layer_le); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + }; + + proto._onAfterVisit = function(ctx){ + var gl = ctx || cc._renderContext; + + gl.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask); + gl.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass); + gl.stencilMask(this._currentStencilWriteMask); + if (!this._currentStencilEnabled) + gl.disable(gl.STENCIL_TEST); + + // we are done using this layer, decrement + cc.ClippingNode.WebGLRenderCmd._layer--; + } +})(); diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index f13bfc94da..b8aaad8431 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -202,8 +202,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _t._position = cc.p(0, 0); _t._normalizedPosition = cc.p(0,0); _t._children = []; - _t._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - _t._transformWorld = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; var director = cc.director; _t._actionManager = director.getActionManager(); @@ -2054,8 +2052,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx Render context */ - transform: function(){ - this._renderCmd.transform(); + transform: function(parentCmd, recursive){ + this._renderCmd.transform(parentCmd, recursive); }, /** diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index 2178ddfc59..79546983da 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -22,6 +22,20 @@ THE SOFTWARE. ****************************************************************************/ +//---------------------- Customer render cmd -------------------- +cc.CustomRenderCmd = function (target, func) { + this._needDraw = true; + this._target = target; + this._callback = func; +}; + +cc.CustomRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + if (!this._callback) + return; + this._callback.call(this._target, ctx, scaleX, scaleY); +}; + + cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty:16, orderDirty:32, textDirty:64}; //-------------------------Base ------------------------- @@ -250,13 +264,13 @@ cc.Node.CanvasRenderCmd.prototype.visit = function(parentCmd){ for (i = 0; i < len; i++) { child = children[i]; if (child._localZOrder < 0) - child.visit(this); + child._renderCmd.visit(this); else break; } cc.renderer.pushRenderCommand(this); for (; i < len; i++) - children[i].visit(); + children[i]._renderCmd.visit(this); } else{ cc.renderer.pushRenderCommand(this); } diff --git a/cocos2d/core/layers/CCLayerRenderCmd.js b/cocos2d/core/layers/CCLayerRenderCmd.js index b2d26d5020..2f6f919f22 100644 --- a/cocos2d/core/layers/CCLayerRenderCmd.js +++ b/cocos2d/core/layers/CCLayerRenderCmd.js @@ -50,7 +50,7 @@ this._isBaked = this._cacheDirty = true; this._cachedParent = this; - var children = this._children; + var children = this._node._children; for(var i = 0, len = children.length; i < len; i++) children[i]._setCachedParent(this); @@ -68,7 +68,7 @@ this._cacheDirty = true; this._cachedParent = null; - var children = this._children; + var children = this._node._children; for(var i = 0, len = children.length; i < len; i++) children[i]._setCachedParent(null); } @@ -80,8 +80,8 @@ proto.rendering = function(){ if(this._cacheDirty){ - var _t = this; - var children = _t._children, locBakeSprite = this._bakeSprite; + var _t = this, node = this._node; + var children = node._children, locBakeSprite = this._bakeSprite; //compute the bounding box of the bake layer. this._transformForRenderer(); var boundingBox = this._renderCmd._getBoundingBoxForBake(); @@ -91,7 +91,7 @@ locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); bakeContext.translate(0 - boundingBox.x, boundingBox.height + boundingBox.y); // invert - var t = cc.affineTransformInvert(this._transformWorld); + var t = cc.affineTransformInvert(this._worldTransform); bakeContext.transform(t.a, t.c, t.b, t.d, t.tx , -t.ty ); //reset the bake sprite's position @@ -117,8 +117,8 @@ } var context = ctx || cc._renderContext; - var _t = this; - var children = _t._children; + var _t = this, node = this._node; + var children = node._children; var len = children.length; // quick return if not visible if (!_t._visible || len === 0) @@ -139,13 +139,13 @@ }; proto._getBoundingBoxForBake = function(){ - var rect = null; + var rect = null, node = this._node; //query child's BoundingBox - if (!this._children || this._children.length === 0) + if (!node._children || node._children.length === 0) return cc.rect(0, 0, 10, 10); - var locChildren = this._children; + var locChildren = node._children; for (var i = 0; i < locChildren.length; i++) { var child = locChildren[i]; if (child && child._visible) { @@ -240,7 +240,7 @@ locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); } // invert - var t = cc.affineTransformInvert(this._transformWorld); + var t = cc.affineTransformInvert(this._worldTransform); bakeContext.transform(t.a, t.c, t.b, t.d, t.tx, -t.ty); var child; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 617063c51d..58c5d26d78 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -144,15 +144,4 @@ cc.rendererCanvas = { }; if (cc._renderType === cc._RENDER_TYPE_CANVAS) - cc.renderer = cc.rendererCanvas; - -cc.CustomRenderCmdCanvas = function (node, func) { - this._node = node; - this._callback = func; -}; - -cc.CustomRenderCmdCanvas.prototype.rendering = function (ctx, scaleX, scaleY) { - if (!this._callback) - return; - this._callback.call(this._node, ctx, scaleX, scaleY); -}; \ No newline at end of file + cc.renderer = cc.rendererCanvas; \ No newline at end of file diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index d5bd1d5f71..531a54b4a2 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -136,14 +136,3 @@ cc.rendererWebGL = { }; if (cc._renderType === cc._RENDER_TYPE_WEBGL) cc.renderer = cc.rendererWebGL; - -cc.CustomRenderCmdWebGL = function (node, func) { - this._node = node; - this._callback = func; -}; - -cc.CustomRenderCmdWebGL.prototype.rendering = function (ctx) { - if (!this._callback) - return; - this._callback.call(this._node, ctx); -}; diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 33005ad0a2..d976afa3b4 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -344,7 +344,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //set the z-order and sort later cc.Node.prototype.reorderChild.call(this, child, zOrder); - this.setNodeDirty(); + //this.setNodeDirty(); }, /** @@ -578,7 +578,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ tag = (tag == null) ? child.tag : tag; cc.Node.prototype.addChild.call(this, child, zOrder, tag); this.appendChild(child); - this.setNodeDirty(); + //this.setNodeDirty(); }, /** @@ -635,6 +635,13 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ } this._reorderChildDirty = false; } + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.SpriteBatchNode.CanvasRenderCmd(this); + else + return new cc.SpriteBatchNode.WebGLRenderCmd(this); } }); diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index c08c610078..4bda9fb0d2 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -42,7 +42,7 @@ * @property {Number} totalQuads - <@readonly> Quantity of quads that are going to be drawn. * @property {Array} quads - <@readonly> Quads that are going to be rendered */ -cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ +cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ //WebGL only dirty: false, texture: null, @@ -141,8 +141,8 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ * @param {Array} quads */ setQuads: function (quads) { - this._quads = quads; //TODO need re-binding + this._quads = quads; }, _copyQuadsToTextureAtlas: function (quads, index) { diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index a2ef261158..b7fb046c79 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -41,8 +41,8 @@ cc.NodeGrid = cc.Node.extend({ ctor: function(){ cc.Node.prototype.ctor.call(this); if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - this._gridBeginCommand = new cc.CustomRenderCmdWebGL(this, this.onGridBeginDraw); - this._gridEndCommand = new cc.CustomRenderCmdWebGL(this, this.onGridEndDraw); + this._gridBeginCommand = new cc.CustomRenderCmd(this, this.onGridBeginDraw); + this._gridEndCommand = new cc.CustomRenderCmd(this, this.onGridEndDraw); } }, diff --git a/cocos2d/particle/CCParticleSystemRenderCmd.js b/cocos2d/particle/CCParticleSystemRenderCmd.js index 4a050e74e5..d6bc98733c 100644 --- a/cocos2d/particle/CCParticleSystemRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemRenderCmd.js @@ -41,7 +41,7 @@ proto.rendering = function (ctx, scaleX, scaleY) { var context = ctx || cc._renderContext, node = this._node, - t = node._transformWorld, + t = this._worldTransform, pointRect = this._pointRect; context.save(); diff --git a/cocos2d/physics/CCPhysicsSpriteRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteRenderCmd.js index 0672409f8f..8f5fc6a060 100644 --- a/cocos2d/physics/CCPhysicsSpriteRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteRenderCmd.js @@ -86,8 +86,7 @@ // Rot, Translate Matrix this._transform = cc.affineTransformMake(c * locScaleX, s * locScaleX, - -s * locScaleY, c * locScaleY, - x, y); + -s * locScaleY, c * locScaleY, x, y); return this._transform; }; diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js index 4a19ff5e91..fa7193f047 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -53,7 +53,7 @@ if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) return; - var t = node._transformWorld; + var t = this._worldTransform; context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); diff --git a/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js index d1c9c468eb..57f7ef895b 100644 --- a/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js +++ b/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js @@ -40,7 +40,7 @@ cc.DrawNode.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) return; context.globalAlpha = alpha; - var t = node._transformWorld; + var t = this._worldTransform; context.save(); ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) diff --git a/cocos2d/tilemap/CCTMXLayerRenderCmd.js b/cocos2d/tilemap/CCTMXLayerRenderCmd.js index 3257b221f6..bfb77282a7 100644 --- a/cocos2d/tilemap/CCTMXLayerRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerRenderCmd.js @@ -64,7 +64,7 @@ locCacheContext.save(); locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); //reset the cache context - var t = cc.affineTransformInvert(locNode._transformWorld); + var t = cc.affineTransformInvert(this._worldTransform); locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); for (var i = 0, len = locCacheCmds.length; i < len; i++) { @@ -86,8 +86,8 @@ this._renderingChildToCache(scaleX, scaleY); var context = ctx || cc._renderContext; context.globalAlpha = alpha; - var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); - var locCacheCanvas = this._cacheCanvas, t = node._transformWorld; + var posX = 0 | ( -this._anchorPointInPoints.x), posY = 0 | ( -this._anchorPointInPoints.y); + var locCacheCanvas = this._cacheCanvas, t = this._worldTransform; //direct draw image by canvas drawImage if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { context.save(); @@ -188,7 +188,7 @@ locCacheContext.save(); locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - var t = cc.affineTransformInvert(node._transformWorld); + var t = cc.affineTransformInvert(this._worldTransform); locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); //draw to cache canvas diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index beebade536..48c1a64d1d 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -479,7 +479,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } }); -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { +if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //TODO refactoring cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForCanvas; cc.ProtectedNode.prototype._transformForRenderer = function () { var t = this.getNodeToParentTransform(), worldT = this._transformWorld; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 3d76d1ae9d..a51df19da3 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -123,17 +123,17 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._backGroundImageColor = cc.color(255, 255, 255, 255); if(cc._renderType == cc._RENDER_TYPE_CANVAS){ - this._rendererSaveCmd = new cc.CustomRenderCmdCanvas(this, this._onRenderSaveCmd); - this._rendererSaveCmdSprite = new cc.CustomRenderCmdCanvas(this, this._onRenderSaveSpriteCmd); - this._rendererClipCmd = new cc.CustomRenderCmdCanvas(this, this._onRenderClipCmd); - this._rendererRestoreCmd = new cc.CustomRenderCmdCanvas(this, this._onRenderRestoreCmd); + this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._onRenderSaveCmd); + this._rendererSaveCmdSprite = new cc.CustomRenderCmd(this, this._onRenderSaveSpriteCmd); + this._rendererClipCmd = new cc.CustomRenderCmd(this, this._onRenderClipCmd); + this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._onRenderRestoreCmd); }else{ - this._beforeVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitStencil); - this._afterDrawStencilCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDrawStencil); - this._afterVisitCmdStencil = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitStencil); - this._beforeVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onBeforeVisitScissor); - this._afterVisitCmdScissor = new cc.CustomRenderCmdWebGL(this, this._onAfterVisitScissor); + this._beforeVisitCmdStencil = new cc.CustomRenderCmd(this, this._onBeforeVisitStencil); + this._afterDrawStencilCmd = new cc.CustomRenderCmd(this, this._onAfterDrawStencil); + this._afterVisitCmdStencil = new cc.CustomRenderCmd(this, this._onAfterVisitStencil); + this._beforeVisitCmdScissor = new cc.CustomRenderCmd(this, this._onBeforeVisitScissor); + this._afterVisitCmdScissor = new cc.CustomRenderCmd(this, this._onAfterVisitScissor); } }, @@ -459,7 +459,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ //optimize performance for javascript currentStack.top = currentStack.stack.pop(); }, - + //TODO _stencilClippingVisitForCanvas: function (ctx) { if (!this._clippingStencil || !this._clippingStencil.isVisible()) { return; @@ -561,7 +561,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }else{} }, _onRenderClipCmd: function(ctx){ - var context = ctx || cc._renderContext; if (this._clipElemType) { @@ -572,7 +571,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } }, _onRenderRestoreCmd: function(ctx){ - var context = ctx || cc._renderContext; if (this._clipElemType) { diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index effd7748fa..51ff3df692 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -130,7 +130,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ /** * Updates armature skin's transform with skin transform and bone's transform. */ - updateArmatureTransform: function () { + updateArmatureTransform: function () { //TODO refactor this._transform = cc.affineTransformConcat( this._skinTransform, this.bone.getNodeToArmatureTransform() @@ -205,7 +205,7 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return cc.affineTransformConcat(this._transform,this.bone.getArmature().getNodeToWorldTransform()); }, - getNodeToWorldTransformAR: function(){ + getNodeToWorldTransformAR: function(){ //TODO refactoring var displayTransform = this._transform; this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); displayTransform.tx = this._anchorPointInPoints.x; diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 31ab2b3413..3b6e96af08 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -124,17 +124,17 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._tmpViewRect = new cc.Rect(0,0,0,0); if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this.startCmd = new cc.CustomRenderCmdCanvas(this, function(ctx, scaleX, scaleY){ - ctx = ctx || cc.context; + this.startCmd = new cc.CustomRenderCmd(this, function(ctx, scaleX, scaleY){ + ctx = ctx || cc._renderContext; ctx.save(); ctx.save(); this.transform(); - var t = this._transformWorld; + var t = this._worldTransform; ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); cc.ScrollView.prototype._beforeDraw.call(this); }); - this.endCmd = new cc.CustomRenderCmdCanvas(this, function(ctx){ - ctx = ctx || cc.context; + this.endCmd = new cc.CustomRenderCmd(this, function(ctx){ + ctx = ctx || cc._renderContext; cc.ScrollView.prototype._afterDraw.call(this); ctx.restore(); }); @@ -149,8 +149,8 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ _initRendererCmd:function () { if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - this._beforeDrawCmd = new cc.CustomRenderCmdWebGL(this, this._onBeforeDraw); - this._afterDrawCmd = new cc.CustomRenderCmdWebGL(this, this._onAfterDraw); + this._beforeDrawCmd = new cc.CustomRenderCmd(this, this._onBeforeDraw); + this._afterDrawCmd = new cc.CustomRenderCmd(this, this._onAfterDraw); } }, diff --git a/extensions/spine/CCSkeletonRenderCmd.js.js b/extensions/spine/CCSkeletonRenderCmd.js.js index 9a29747bc1..b98f10e119 100644 --- a/extensions/spine/CCSkeletonRenderCmd.js.js +++ b/extensions/spine/CCSkeletonRenderCmd.js.js @@ -37,7 +37,7 @@ sp.Skeleton.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) if (!node._debugSlots && !node._debugBones) { return; } - var t = node._transformWorld; + var t = this._worldTransform; ctx.save(); ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); var locSkeleton = node._skeleton; From b4dcfc8ba11ae9bf61b5fbe04cc386ca3480018b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 22 Nov 2014 09:45:01 +0800 Subject: [PATCH 0941/1564] Fix a bug about LabelAtlas variable does not exist --- cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js | 2 +- cocos2d/labels/CCLabelAtlas.js | 11 +++++++---- cocos2d/labels/CCLabelAtlasRenderCmd.js | 7 +++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js index beb137c34e..badc476eb7 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js @@ -55,7 +55,7 @@ proto.draw = cc.Node.prototype.draw; proto.setColor = function(color3){ - var node = this; + var node = this._node; var locRealColor = node._realColor; if ((locRealColor.r == color3.r) && (locRealColor.g == color3.g) && (locRealColor.b == color3.b)) return; diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 24cf5c94b1..bc9f3905af 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -76,12 +76,15 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ this._cascadeColorEnabled = true; + charMapFile && cc.LabelAtlas.prototype.initWithString.call(this, strText, charMapFile, itemWidth, itemHeight, startCharMap); + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._renderCmd = new cc.LabelAtlas.WebGLRenderCmd(this); + return new cc.LabelAtlas.WebGLRenderCmd(this); else - this._renderCmd = new cc.LabelAtlas.CanvasRenderCmd(this); - - charMapFile && cc.LabelAtlas.prototype.initWithString.call(this, strText, charMapFile, itemWidth, itemHeight, startCharMap); + return new cc.LabelAtlas.CanvasRenderCmd(this); }, /** diff --git a/cocos2d/labels/CCLabelAtlasRenderCmd.js b/cocos2d/labels/CCLabelAtlasRenderCmd.js index 79dd9e6add..bf39ffbc24 100644 --- a/cocos2d/labels/CCLabelAtlasRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasRenderCmd.js @@ -32,6 +32,12 @@ var proto = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); proto.constructor = cc.LabelAtlas.CanvasRenderCmd; + proto.rendering = function(){ + var node = this._node; + node.draw(); + node._textureForCanvas._renderCmd + }; + proto.updateAtlasValues = function(){ var node = this._node; var locString = node._string || ""; @@ -106,6 +112,7 @@ var proto = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype); proto.constructor = cc.LabelAtlas.WebGLRenderCmd; + proto.rendering = function(){}; proto.updateAtlasValues = function(){ var node = this._node; From 748f0dd374f3c2b41b954c3805a010339799c786 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 22 Nov 2014 10:32:06 +0800 Subject: [PATCH 0942/1564] Fix a bug about LabelAtlas variable does not exist --- cocos2d/core/base-nodes/CCAtlasNode.js | 7 ++---- .../core/base-nodes/CCAtlasNodeRenderCmd.js | 23 +++++++++++-------- cocos2d/labels/CCLabelAtlasRenderCmd.js | 15 ++++++------ 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index fb3dc8770f..8db30a943e 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -60,8 +60,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ //! height of each char _itemHeight: 0, - _colorUnmodified: null, - // protocol variables _opacityModifyRGB: false, _blendFunc: null, @@ -79,7 +77,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ */ ctor: function (tile, tileWidth, tileHeight, itemsToRender) { cc.Node.prototype.ctor.call(this); - this._colorUnmodified = cc.color.WHITE; this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; this._ignoreContentScaleFactor = false; @@ -110,7 +107,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ */ getColor: function () { if (this._opacityModifyRGB) - return this._colorUnmodified; + return this._renderCmd._colorUnmodified; return cc.Node.prototype.getColor.call(this); }, @@ -226,7 +223,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ * @return {Boolean} */ initWithTexture: function(texture, tileWidth, tileHeight, itemsToRender){ - this._renderCmd.initWithTexture(texture, tileWidth, tileHeight, itemsToRender); + return this._renderCmd.initWithTexture(texture, tileWidth, tileHeight, itemsToRender); }, /** diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js index badc476eb7..489bd5f6a2 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js @@ -29,6 +29,8 @@ cc.AtlasNode.CanvasRenderCmd = function(renderableObject){ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; + this._colorUnmodified = cc.color.WHITE; + }; var proto = cc.AtlasNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); @@ -63,12 +65,12 @@ this._colorUnmodified = color3; if (node._opacityModifyRGB) { - var locDisplayedOpacity = node._displayedOpacity; + var locDisplayedOpacity = this._displayedOpacity; temp.r = temp.r * locDisplayedOpacity / 255; temp.g = temp.g * locDisplayedOpacity / 255; temp.b = temp.b * locDisplayedOpacity / 255; } -// cc.Node.prototype.setColor.call(this, color3); +// cc.Node.prototype.setColor.call(node, color3); this._changeTextureColor(); }; @@ -83,9 +85,9 @@ var locElement = locTexture.getHtmlElementObj(); var textureRect = cc.rect(0, 0, element.width, element.height); if (locElement instanceof HTMLCanvasElement) - cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, node._colorUnmodified, textureRect, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect, locElement); else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, node._colorUnmodified, textureRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); @@ -106,9 +108,9 @@ if (cacheTextureForColor) { var textureRect = cc.rect(0, 0, element.width, element.height); if (locElement instanceof HTMLCanvasElement) - cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, node._displayedColor, textureRect, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect, locElement); else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, node._displayedColor, textureRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); @@ -123,7 +125,7 @@ cc.Node.prototype.setOpacity.call(node, opacity); // special opacity for premultiplied textures if (node._opacityModifyRGB) { - node.color = node._colorUnmodified; + node.color = this._colorUnmodified; } }; @@ -152,6 +154,7 @@ cc.AtlasNode.WebGLRenderCmd = function(renderableObject){ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; + this._colorUnmodified = cc.color.WHITE; }; var proto = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); @@ -174,7 +177,7 @@ var node = this._node; node._itemWidth = tileWidth; node._itemHeight = tileHeight; - node._colorUnmodified = cc.color.WHITE; + this._colorUnmodified = cc.color.WHITE; node._opacityModifyRGB = true; node._blendFunc.src = cc.BLEND_SRC; @@ -231,9 +234,9 @@ cc.Node.prototype.setOpacity.call(node, opacity); // special opacity for premultiplied textures if (node._opacityModifyRGB) { - node.color = node._colorUnmodified; + node.color = this._colorUnmodified; } else { - var locDisplayedColor = node._displayedColor; + var locDisplayedColor = this._displayedColor; node._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, locDisplayedColor.b / 255.0, node._displayedOpacity / 255.0]); } diff --git a/cocos2d/labels/CCLabelAtlasRenderCmd.js b/cocos2d/labels/CCLabelAtlasRenderCmd.js index bf39ffbc24..b329031694 100644 --- a/cocos2d/labels/CCLabelAtlasRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasRenderCmd.js @@ -25,8 +25,8 @@ (function(){ cc.LabelAtlas.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; + cc.AtlasNode.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = false; }; var proto = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); @@ -35,7 +35,6 @@ proto.rendering = function(){ var node = this._node; node.draw(); - node._textureForCanvas._renderCmd }; proto.updateAtlasValues = function(){ @@ -81,10 +80,10 @@ var node = this._node; label = String(label); var len = label.length; - this._string = label; + node._string = label; this.width = len * node._itemWidth; this.height = node._itemHeight; - if (this._children) { + if (node._children) { var locChildren = node._children; len = locChildren.length; for (var i = 0; i < len; i++) { @@ -106,8 +105,8 @@ (function(){ cc.LabelAtlas.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; + cc.AtlasNode.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = false; }; var proto = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype); @@ -132,7 +131,7 @@ if (n > locTextureAtlas.getCapacity()) cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length"); var quads = locTextureAtlas.quads; - var locDisplayedColor = node._displayedColor; + var locDisplayedColor = this._displayedColor; var curColor = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: node._displayedOpacity}; var locItemWidth = node._itemWidth; for (var i = 0; i < n; i++) { From dcc5391ce2a4b34df4c24092a241adf1362ada1c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 22 Nov 2014 14:25:50 +0800 Subject: [PATCH 0943/1564] Issue #2416: refactor Engine's renderer --- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 882 ++++---- cocos2d/core/labelttf/CCLabelTTFRenderCmd.js | 79 +- cocos2d/core/sprites/CCSprite.js | 24 +- .../sprites/CCSpriteBatchNodeRenderCmd.js | 2 +- cocos2d/core/sprites/CCSpriteRenderCmd.js | 1810 +++++++++-------- template/project.json | 2 +- 6 files changed, 1406 insertions(+), 1393 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index 79546983da..3667c99ef4 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -27,12 +27,12 @@ cc.CustomRenderCmd = function (target, func) { this._needDraw = true; this._target = target; this._callback = func; -}; -cc.CustomRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - if (!this._callback) - return; - this._callback.call(this._target, ctx, scaleX, scaleY); + this.rendering = function (ctx, scaleX, scaleY) { + if (!this._callback) + return; + this._callback.call(this._target, ctx, scaleX, scaleY); + } }; @@ -112,248 +112,212 @@ cc.Node.RenderCmd.prototype = { return null; } }; + //-----------------------Canvas --------------------------- -//The cc.Node's render command for Canvas -cc.Node.CanvasRenderCmd = function(renderable){ - cc.Node.RenderCmd.call(this, renderable); - this._cachedParent = null; - this._cacheDirty = false; -}; -cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); -cc.Node.CanvasRenderCmd.prototype.constructor = cc.Node.CanvasRenderCmd; - -cc.Node.CanvasRenderCmd.prototype.transform = function(parentCmd, recursive){ - // transform for canvas - var t = this.getNodeToParentTransform(), - worldT = this._worldTransform; //get the world transform - - if(parentCmd){ - var pt = parentCmd._worldTransform; - // cc.AffineTransformConcat is incorrect at get world transform - worldT.a = t.a * pt.a + t.b * pt.c; //a - worldT.b = t.a * pt.b + t.b * pt.d; //b - worldT.c = t.c * pt.a + t.d * pt.c; //c - worldT.d = t.c * pt.b + t.d * pt.d; //d - - var plt = parentCmd._transform; - var xOffset = -(plt.b + plt.c) * t.ty; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty - } else { - worldT.a = t.a; - worldT.b = t.b; - worldT.c = t.c; - worldT.d = t.d; - worldT.tx = t.tx; - worldT.ty = t.ty; - } - this._renderCmdDiry = false; - if(recursive){ - var locChildren = this._node._children; - if(!locChildren|| locChildren.length === 0) - return; - var i, len; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._renderCmd.transform(this, recursive); +(function() { +//The cc.Node's render command for Canvas + cc.Node.CanvasRenderCmd = function (renderable) { + cc.Node.RenderCmd.call(this, renderable); + this._cachedParent = null; + this._cacheDirty = false; + }; + + var proto = cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); + proto.constructor = cc.Node.CanvasRenderCmd; + + proto.transform = function (parentCmd, recursive) { + // transform for canvas + var t = this.getNodeToParentTransform(), + worldT = this._worldTransform; //get the world transform + + if (parentCmd) { + var pt = parentCmd._worldTransform; + // cc.AffineTransformConcat is incorrect at get world transform + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d + + var plt = parentCmd._transform; + var xOffset = -(plt.b + plt.c) * t.ty; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + } else { + worldT.a = t.a; + worldT.b = t.b; + worldT.c = t.c; + worldT.d = t.d; + worldT.tx = t.tx; + worldT.ty = t.ty; } - } -}; + this._renderCmdDiry = false; + if (recursive) { + var locChildren = this._node._children; + if (!locChildren || locChildren.length === 0) + return; + var i, len; + for (i = 0, len = locChildren.length; i < len; i++) { + locChildren[i]._renderCmd.transform(this, recursive); + } + } + }; + + proto.getNodeToParentTransform = function () { + var node = this._node, normalizeDirty = false; + if (node._usingNormalizedPosition && node._parent) { //TODO need refactor + var conSize = node._parent._contentSize; + node._position.x = node._normalizedPosition.x * conSize.width; + node._position.y = node._normalizedPosition.y * conSize.height; + node._normalizedPositionDirty = false; + normalizeDirty = true; + } + if (normalizeDirty || (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty)) { + var t = this._transform;// quick reference + + // base position + t.tx = node._position.x; + t.ty = node._position.y; + + // rotation Cos and Sin + var Cos = 1, Sin = 0; + if (node._rotationX) { + var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance + Cos = Math.cos(rotationRadiansX); + Sin = Math.sin(rotationRadiansX); + } -cc.Node.CanvasRenderCmd.prototype.getNodeToParentTransform = function(){ - var node = this._node, normalizeDirty = false; - if(node._usingNormalizedPosition && node._parent){ //TODO need refactor - var conSize = node._parent._contentSize; - node._position.x = node._normalizedPosition.x * conSize.width; - node._position.y = node._normalizedPosition.y * conSize.height; - node._normalizedPositionDirty = false; - normalizeDirty = true; - } - if (normalizeDirty || (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty)) { - var t = this._transform;// quick reference + // base abcd + t.a = t.d = Cos; + t.b = -Sin; + t.c = Sin; + + var lScaleX = node._scaleX, lScaleY = node._scaleY; + var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; + + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + + // skew + if (node._skewX || node._skewY) { + // offset the anchorpoint + var skx = Math.tan(-node._skewX * Math.PI / 180); //TODO + var sky = Math.tan(-node._skewY * Math.PI / 180); + if (skx === Infinity) + skx = 99999999; + if (sky === Infinity) + sky = 99999999; + var xx = appY * skx * sx; + var yy = appX * sky * sy; + t.a = Cos + -Sin * sky; + t.b = Cos * skx + -Sin; + t.c = Sin + Cos * sky; + t.d = Sin * skx + Cos; + t.tx += Cos * xx + -Sin * yy; + t.ty += Sin * xx + Cos * yy; + } - // base position - t.tx = node._position.x; - t.ty = node._position.y; + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + t.a *= sx; + t.c *= sx; + t.b *= sy; + t.d *= sy; + } - // rotation Cos and Sin - var Cos = 1, Sin = 0; - if (node._rotationX) { - var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - Cos = Math.cos(rotationRadiansX); - Sin = Math.sin(rotationRadiansX); - } + // adjust anchorPoint + t.tx += Cos * -appX * sx + -Sin * appY * sy; + t.ty -= Sin * -appX * sx + Cos * appY * sy; - // base abcd - t.a = t.d = Cos; - t.b = -Sin; - t.c = Sin; - - var lScaleX = node._scaleX, lScaleY = node._scaleY; - var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; - - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - - // skew - if (node._skewX || node._skewY) { - // offset the anchorpoint - var skx = Math.tan(-node._skewX * Math.PI / 180); //TODO - var sky = Math.tan(-node._skewY * Math.PI / 180); - if(skx === Infinity) - skx = 99999999; - if(sky === Infinity) - sky = 99999999; - var xx = appY * skx * sx; - var yy = appX * sky * sy; - t.a = Cos + -Sin * sky; - t.b = Cos * skx + -Sin; - t.c = Sin + Cos * sky; - t.d = Sin * skx + Cos; - t.tx += Cos * xx + -Sin * yy; - t.ty += Sin * xx + Cos * yy; - } + // if ignore anchorPoint + if (node._ignoreAnchorPointForPosition) { + t.tx += appX; + t.ty += appY; + } - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.c *= sx; - t.b *= sy; - t.d *= sy; + if (node._additionalTransformDirty) { + this._transform = cc.affineTransformConcat(t, node._additionalTransform); + node._additionalTransformDirty = false; + } + this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; } + return this._transform; + }; - // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * appY * sy; - t.ty -= Sin * -appX * sx + Cos * appY * sy; + proto.visit = function (parentCmd) { + var _t = this, node = this._node; + // quick return if not visible + if (!node._visible) + return; - // if ignore anchorPoint - if (node._ignoreAnchorPointForPosition) { - t.tx += appX; - t.ty += appY; + parentCmd = parentCmd || this.getParentRenderCmd(); + if (parentCmd) + this._curLevel = parentCmd._curLevel + 1; + + //visit for canvas + var i, children = node._children, child; + _t._syncStatus(parentCmd); + var len = children.length; + if (len > 0) { + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + child = children[i]; + if (child._localZOrder < 0) + child._renderCmd.visit(this); + else + break; + } + cc.renderer.pushRenderCommand(this); + for (; i < len; i++) + children[i]._renderCmd.visit(this); + } else { + cc.renderer.pushRenderCommand(this); } + }; - if (node._additionalTransformDirty) { - this._transform = cc.affineTransformConcat(t, node._additionalTransform); - node._additionalTransformDirty = false; + proto.updateStatus = function () { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._updateDisplayColor() } - this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; - } - return this._transform; -}; -cc.Node.CanvasRenderCmd.prototype.visit = function(parentCmd){ - var _t = this, node = this._node; - // quick return if not visible - if (!node._visible) - return; - - parentCmd = parentCmd || this.getParentRenderCmd(); - if( parentCmd) - this._curLevel = parentCmd._curLevel + 1; - - //visit for canvas - var i, children = node._children, child; - _t._syncStatus(parentCmd); - var len = children.length; - if (len > 0) { - node.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - child = children[i]; - if (child._localZOrder < 0) - child._renderCmd.visit(this); - else - break; + if (locFlag & flags.opacityDirty) { + //update the opacity + this._updateDisplayOpacity(); } - cc.renderer.pushRenderCommand(this); - for (; i < len; i++) - children[i]._renderCmd.visit(this); - } else{ - cc.renderer.pushRenderCommand(this); - } -}; - -cc.Node.CanvasRenderCmd.prototype.updateStatus = function(){ - if(this._dirtyFlag & cc.Node._dirtyFlags.colorDirty){ - //update the color - this._updateDisplayColor() - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty){ - //update the opacity - this._updateDisplayOpacity(); - } - if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ - //update the transform - this.transform(this.getParentRenderCmd(), true); - } -}; - -cc.Node.CanvasRenderCmd.prototype._syncStatus = function(parentCmd){ - if(this._dirtyFlag & cc.Node._dirtyFlags.colorDirty){ - //update the color - this._syncDisplayColor() - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty){ - //update the opacity - this._syncDisplayOpacity(); - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ - //update the transform - this.transform(parentCmd); - } -}; + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(this.getParentRenderCmd(), true); + } + }; -cc.Node.CanvasRenderCmd.prototype._syncDisplayColor = function(parentColor){ - var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; - if(parentColor === undefined){ - var locParent = node._parent; - if (locParent && locParent._cascadeColorEnabled) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - } - locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); - locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); - locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; -}; + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._syncDisplayColor() + } -cc.Node.CanvasRenderCmd.prototype._syncDisplayOpacity = function(parentOpacity){ - var node = this._node; - if(parentOpacity === undefined){ - var locParent = node._parent; - parentOpacity = 255; - if (locParent && locParent._cascadeOpacityEnabled) - parentOpacity = locParent.getDisplayedOpacity(); - } - this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; -}; + if (locFlag & flags.opacityDirty) { + //update the opacity + this._syncDisplayOpacity(); + } -cc.Node.CanvasRenderCmd.prototype._updateDisplayColor = function(parentColor){ - var node = this._node; - var locDispColor = this._displayedColor, locRealColor = node._realColor; - var i, len, selChildren, item; - if(this._cascadeColorEnabledDirty && !node._cascadeColorEnabled){ - locDispColor.r = locRealColor.r; - locDispColor.g = locRealColor.g; - locDispColor.b = locRealColor.b; - var whiteColor = new cc.Color(255,255,255,255); - selChildren = node._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayColor(whiteColor); + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); } - } else { - if(parentColor === undefined){ + }; + + proto._syncDisplayColor = function (parentColor) { + var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; + if (parentColor === undefined) { var locParent = node._parent; if (locParent && locParent._cascadeColorEnabled) parentColor = locParent.getDisplayedColor(); @@ -363,255 +327,295 @@ cc.Node.CanvasRenderCmd.prototype._updateDisplayColor = function(parentColor){ locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - if (node._cascadeColorEnabled) { - selChildren = node._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayColor(locDispColor); - } - } - } - this._cascadeColorEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; -}; + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + }; -cc.Node.CanvasRenderCmd.prototype._updateDisplayOpacity = function(parentOpacity){ - var node = this._node; - var i, len, selChildren, item; - if(this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled){ - this._displayedOpacity = node._realOpacity; - selChildren = this._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayOpacity(255); - } - } else { - if(parentOpacity === undefined){ + proto._syncDisplayOpacity = function (parentOpacity) { + var node = this._node; + if (parentOpacity === undefined) { var locParent = node._parent; parentOpacity = 255; if (locParent && locParent._cascadeOpacityEnabled) parentOpacity = locParent.getDisplayedOpacity(); } this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - if (this._cascadeOpacityEnabled) { + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + }; + + proto._updateDisplayColor = function (parentColor) { + var node = this._node; + var locDispColor = this._displayedColor, locRealColor = node._realColor; + var i, len, selChildren, item; + if (this._cascadeColorEnabledDirty && !node._cascadeColorEnabled) { + locDispColor.r = locRealColor.r; + locDispColor.g = locRealColor.g; + locDispColor.b = locRealColor.b; + var whiteColor = new cc.Color(255, 255, 255, 255); + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(whiteColor); + } + } else { + if (parentColor === undefined) { + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + if (node._cascadeColorEnabled) { + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(locDispColor); + } + } + } + this._cascadeColorEnabledDirty = false; + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + }; + + proto._updateDisplayOpacity = function (parentOpacity) { + var node = this._node; + var i, len, selChildren, item; + if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { + this._displayedOpacity = node._realOpacity; selChildren = this._children; for (i = 0, len = selChildren.length; i < len; i++) { item = selChildren[i]; if (item && item._renderCmd) - item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + item._renderCmd._updateDisplayOpacity(255); + } + } else { + if (parentOpacity === undefined) { + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + if (this._cascadeOpacityEnabled) { + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + } } } - } - this._cascadeOpacityEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; -}; - -cc.Node.CanvasRenderCmd.prototype.setDirtyFlag = function(dirtyFlag){ - if (this._dirtyFlag === 0 && dirtyFlag !== 0) - cc.renderer.pushDirtyNode(this); - this._dirtyFlag = this._dirtyFlag | dirtyFlag; - this._setCacheDirty(); -}; + this._cascadeOpacityEnabledDirty = false; + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + }; -cc.Node.CanvasRenderCmd.prototype._setCacheDirty = function(){ - if (this._cacheDirty === false) { - this._cacheDirty = true; - var cachedP = this._cachedParent; - cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); - } -}; + proto.setDirtyFlag = function (dirtyFlag) { + if (this._dirtyFlag === 0 && dirtyFlag !== 0) + cc.renderer.pushDirtyNode(this); + this._dirtyFlag = this._dirtyFlag | dirtyFlag; + this._setCacheDirty(); + }; + + proto._setCacheDirty = function () { + if (this._cacheDirty === false) { + this._cacheDirty = true; + var cachedP = this._cachedParent; + cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); + } + }; -cc.Node.CanvasRenderCmd.prototype._setCachedParent = function(cachedParent){ - if(this._cachedParent == cachedParent) - return; + proto._setCachedParent = function (cachedParent) { + if (this._cachedParent == cachedParent) + return; - this._cachedParent = cachedParent; - var children = this._children; - for(var i = 0, len = children.length; i < len; i++) - children[i]._renderCmd._setCachedParent(cachedParent); -}; + this._cachedParent = cachedParent; + var children = this._children; + for (var i = 0, len = children.length; i < len; i++) + children[i]._renderCmd._setCachedParent(cachedParent); + }; -cc.Node.CanvasRenderCmd.prototype.detachFromParent = function(){ - this._cachedParent = null; - var selChildren = this._node._children, item; - for(var i = 0, len = selChildren.length; i < len; i++){ - item = selChildren[i]; - if(item && item._renderCmd) - item._renderCmd.detachFromParent(); - } -}; + proto.detachFromParent = function () { + this._cachedParent = null; + var selChildren = this._node._children, item; + for (var i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd.detachFromParent(); + } + }; -cc.Node.CanvasRenderCmd.prototype.setShaderProgram = function(shaderProgram){ - //do nothing. -}; + proto.setShaderProgram = function (shaderProgram) { + //do nothing. + }; -cc.Node.CanvasRenderCmd.prototype.getShaderProgram = function(){ - //do nothing. -}; + proto.getShaderProgram = function () { + return null; + }; //util functions -cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function(blendFunc){ - if(!blendFunc) - return "source-over"; - else{ - if(( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) - return "lighter"; - else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) - return "destination-in"; - else if(blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) - return "destination-out"; - else + cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function (blendFunc) { + if (!blendFunc) return "source-over"; - } -}; + else { + if (( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) + return "lighter"; + else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) + return "destination-in"; + else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) + return "destination-out"; + else + return "source-over"; + } + }; +})(); // ------------------------------ The cc.Node's render command for WebGL ---------------------------------- -cc.Node.WebGLRenderCmd = function(renderable){ - cc.Node.RenderCmd.call(this, renderable); - - var mat4 = new cc.kmMat4(); - mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0; - mat4.mat[10] = mat4.mat[15] = 1.0; - this._transform4x4 = mat4; - this._stackMatrix = new cc.kmMat4(); - this._shaderProgram = null; +(function() { + cc.Node.WebGLRenderCmd = function (renderable) { + cc.Node.RenderCmd.call(this, renderable); + + var mat4 = new cc.kmMat4(); + mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0; + mat4.mat[10] = mat4.mat[15] = 1.0; + this._transform4x4 = mat4; + this._stackMatrix = new cc.kmMat4(); + this._shaderProgram = null; + + this._camera = null; + }; + + var proto = cc.Node.WebGLRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); + proto.constructor = cc.Node.WebGLRenderCmd; + + proto.getNodeToParentTransform = function () { + var node = this._node; + if (node._usingNormalizedPosition && node._parent) { //TODO need refactor + var conSize = node._parent._contentSize; + node._position.x = node._normalizedPosition.x * conSize.width; + node._position.y = node._normalizedPosition.y * conSize.height; + node._normalizedPositionDirty = false; + } + if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + // Translate values + var x = node._position.x, y = node._position.y; + var apx = this._anchorPointInPoints.x, napx = -apx; + var apy = this._anchorPointInPoints.y, napy = -apy; + var scx = node._scaleX, scy = node._scaleY; + var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance + var rotationRadiansY = node._rotationY * 0.017453292519943295; - this._camera = null; -}; + if (node._ignoreAnchorPointForPosition) { + x += apx; + y += apy; + } -cc.Node.WebGLRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); -cc.Node.WebGLRenderCmd.prototype.constructor = cc.Node.WebGLRenderCmd; + // Rotation values + // Change rotation code to handle X and Y + // If we skew with the exact same value for both x and y then we're simply just rotating + var cx = 1, sx = 0, cy = 1, sy = 0; + if (node._rotationX !== 0 || node._rotationY !== 0) { + cx = Math.cos(-rotationRadiansX); + sx = Math.sin(-rotationRadiansX); + cy = Math.cos(-rotationRadiansY); + sy = Math.sin(-rotationRadiansY); + } + var needsSkewMatrix = ( node._skewX || node._skewY ); + + // optimization: + // inline anchor point calculation if skew is not needed + // Adjusted transform calculation for rotational skew + if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { + x += cy * napx * scx + -sx * napy * scy; + y += sy * napx * scx + cx * napy * scy; + } -cc.Node.WebGLRenderCmd.prototype.getNodeToParentTransform = function(){ - var node = this._node; - if(node._usingNormalizedPosition && node._parent){ //TODO need refactor - var conSize = node._parent._contentSize; - node._position.x = node._normalizedPosition.x * conSize.width; - node._position.y = node._normalizedPosition.y * conSize.height; - node._normalizedPositionDirty = false; - } - if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { - // Translate values - var x = node._position.x, y = node._position.y; - var apx = node._anchorPointInPoints.x, napx = -apx; - var apy = node._anchorPointInPoints.y, napy = -apy; - var scx = node._scaleX, scy = node._scaleY; - var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - var rotationRadiansY = node._rotationY * 0.017453292519943295; - - if (node._ignoreAnchorPointForPosition) { - x += apx; - y += apy; - } + // Build Transform Matrix + // Adjusted transform calculation for rotational skew + var t = this._transform; + t.a = cy * scx; + t.b = sy * scx; + t.c = -sx * scy; + t.d = cx * scy; + t.tx = x; + t.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(node._skewY)), + c: Math.tan(cc.degreesToRadians(node._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t); + + // adjust anchor point + if (apx !== 0 || apy !== 0) + t = cc.affineTransformTranslate(t, napx, napy); + } - // Rotation values - // Change rotation code to handle X and Y - // If we skew with the exact same value for both x and y then we're simply just rotating - var cx = 1, sx = 0, cy = 1, sy = 0; - if (node._rotationX !== 0 || node._rotationY !== 0) { - cx = Math.cos(-rotationRadiansX); - sx = Math.sin(-rotationRadiansX); - cy = Math.cos(-rotationRadiansY); - sy = Math.sin(-rotationRadiansY); - } - var needsSkewMatrix = ( node._skewX || node._skewY ); - - // optimization: - // inline anchor point calculation if skew is not needed - // Adjusted transform calculation for rotational skew - if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { - x += cy * napx * scx + -sx * napy * scy; - y += sy * napx * scx + cx * napy * scy; + if (node._additionalTransformDirty) { + t = cc.affineTransformConcat(t, this._additionalTransform); + node._additionalTransformDirty = false; + } + this._transform = t; } + return this._transform; + }; - // Build Transform Matrix - // Adjusted transform calculation for rotational skew - var t = this._transform; - t.a = cy * scx; - t.b = sy * scx; - t.c = -sx * scy; - t.d = cx * scy; - t.tx = x; - t.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(node._skewY)), - c: Math.tan(cc.degreesToRadians(node._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t); - - // adjust anchor point - if (apx !== 0 || apy !== 0) - t = cc.affineTransformTranslate(t, napx, napy); - } +//TODO + proto.visit = function (parentCmd) { + var _t = this, node = this._node; + // quick return if not visible + if (!_t._visible) + return; - if (node._additionalTransformDirty) { - t = cc.affineTransformConcat(t, this._additionalTransform); - node._additionalTransformDirty = false; - } - this._transform = t; - this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; - } - return this._transform; -}; + if (node._parent && node._parent._renderCmd) + this._curLevel = node._parent._renderCmd._curLevel + 1; + + var i, currentStack = cc.current_stack; + + //optimize performance for javascript + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(_t._stackMatrix, currentStack.top); + currentStack.top = _t._stackMatrix; + + _t._syncStatus(parentCmd); + var locChildren = _t._children; + if (locChildren && locChildren.length > 0) { + var childLen = locChildren.length; + _t.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < childLen; i++) { + if (locChildren[i] && locChildren[i]._localZOrder < 0) + locChildren[i]._renderCmd.visit(this); + else + break; + } -//TODO -cc.Node.WebGLRenderCmd.prototype.visit = function(){ - var _t = this, node = this._node; - // quick return if not visible - if (!_t._visible) - return; - - if( node._parent && node._parent._renderCmd) - this._curLevel = node._parent._renderCmd._curLevel + 1; - - var i, currentStack = cc.current_stack; - - //optimize performance for javascript - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(_t._stackMatrix, currentStack.top); - currentStack.top = _t._stackMatrix; - - _t.transform(); - - var locChildren = _t._children; - if (locChildren && locChildren.length > 0) { - var childLen = locChildren.length; - _t.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < childLen; i++) { - if (locChildren[i] && locChildren[i]._localZOrder < 0) - locChildren[i].visit(); - else - break; - } - if(this._needDraw) cc.renderer.pushRenderCommand(this); - // draw children zOrder >= 0 - for (; i < childLen; i++) { - if (locChildren[i]) - locChildren[i].visit(); - } - } else{ - if(this._needDraw) + // draw children zOrder >= 0 + for (; i < childLen; i++) { + if (locChildren[i]) + locChildren[i]._renderCmd.visit(this); + } + } else cc.renderer.pushRenderCommand(this); - } - //optimize performance for javascript - currentStack.top = currentStack.stack.pop(); -}; + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); + }; -//TODO -cc.Node.WebGLRenderCmd.prototype.transform = function() { + proto.transform = function () { -}; + }; -cc.Node.WebGLRenderCmd.prototype.setShaderProgram = function(shaderProgram){ - this._shaderProgram = shaderProgram; -}; + proto.setShaderProgram = function (shaderProgram) { + this._shaderProgram = shaderProgram; + }; -cc.Node.WebGLRenderCmd.prototype.getShaderProgram = function(){ - return this._shaderProgram; -}; + proto.getShaderProgram = function () { + return this._shaderProgram; + }; +})(); diff --git a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js index b5bf4f3de1..132bb1c78f 100644 --- a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js @@ -52,6 +52,52 @@ cc.LabelTTF.RenderCmd = function(){ cc.LabelTTF.RenderCmd.prototype.constructor = cc.LabelTTF.RenderCmd; +cc.LabelTTF.RenderCmd.prototype.updateStatus = function(){ + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if(locFlag & flags.colorDirty){ + //update the color + this._updateDisplayColor() + } + + if(locFlag & flags.opacityDirty){ + //update the opacity + this._updateDisplayOpacity(); + } + + if(locFlag & flags.textDirty){ + //update texture for labelTTF + this._updateTexture(); + } + + if(locFlag & flags.transformDirty){ + //update the transform + this.transform(null, true); + } +}; + +cc.LabelTTF.RenderCmd.prototype._syncStatus = function(parentCmd){ + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if(locFlag & flags.colorDirty){ + //update the color + this._syncDisplayColor() + } + + if(locFlag & flags.opacityDirty){ + //update the opacity + this._syncDisplayOpacity(); + } + + if(locFlag & flags.textDirty){ + //update texture for labelTTF + this._updateTexture(); + } + + if(locFlag & flags.transformDirty){ + //update the transform + this.transform(parentCmd); + } +}; + cc.LabelTTF.RenderCmd.prototype._getLabelContext = function () { if (this._labelContext) return this._labelContext; @@ -82,6 +128,7 @@ cc.LabelTTF.RenderCmd.prototype._getFontClientHeight = function(){ }; cc.LabelTTF.RenderCmd.prototype._updateTexture = function () { + this._dirtyFlag ^= cc.Node._dirtyFlags.textDirty; var node = this._node; var locContext = this._getLabelContext(), locLabelCanvas = this._labelCanvas; var locContentSize = node._contentSize; @@ -108,7 +155,6 @@ cc.LabelTTF.RenderCmd.prototype._updateTexture = function () { node._texture && node._texture.handleLoadedTexture(); node.setTextureRect(cc.rect(0, 0, width, height)); - this._dirtyFlag ^= cc.Node._dirtyFlags.textDirty; return true; }; @@ -337,8 +383,8 @@ cc.LabelTTF.CanvasRenderCmd = function(renderable){ }; cc.LabelTTF.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); -cc.LabelTTF.CanvasRenderCmd.prototype.constructor = cc.LabelTTF.CanvasRenderCmd; cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.CanvasRenderCmd.prototype); +cc.LabelTTF.CanvasRenderCmd.prototype.constructor = cc.LabelTTF.CanvasRenderCmd; cc.LabelTTF.CanvasRenderCmd.prototype._updateDisplayedOpacity = function(parentOpacity){ cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedOpacity.call(this, parentOpacity); @@ -365,28 +411,6 @@ cc.LabelTTF.CanvasRenderCmd.prototype._setColorsString = function(){ + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; }; -cc.LabelTTF.CanvasRenderCmd.prototype.updateStatus = function(){ - if(this._dirtyFlag & cc.Node._dirtyFlags.colorDirty){ - //update the color - this._updateDisplayColor() - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty){ - //update the opacity - this._updateDisplayOpacity(); - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.textDirty){ - //update texture for labelTTF - this._updateTexture(); - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ - //update the transform - this.transform(null, true); - } -}; - // ----------------------------------- LabelTTF WebGL render cmd ---------------------------- cc.LabelTTF.WebGLRenderCmd = function(renderable){ @@ -395,12 +419,13 @@ cc.LabelTTF.WebGLRenderCmd = function(renderable){ }; cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); -cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit +cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; cc.LabelTTF.WebGLRenderCmd.prototype._setColorsString = function(){ - this._needUpdateTexture = true; - var locStrokeColor = this._strokeColor, locFontFillColor = this._textFillColor; + this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); + var node = this._node; + var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index dfd391cc9d..945c49892d 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -426,24 +426,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ } }, - /** - * Make the node dirty - * @param {Boolean} norecursive When true children will not be set dirty recursively, by default, they will be. - * @override - */ - setNodeDirty: function(norecursive) { - cc.Node.prototype.setNodeDirty.call(this); - // Lazy set dirty - if (!norecursive && this._batchNode && !this._recursiveDirty) { - if (this._hasChildren) - this.setDirtyRecursively(true); - else { - this._recursiveDirty = true; - this.dirty = true; - } - } - }, - /** * Sets whether ignore anchor point for positioning * @param {Boolean} relative @@ -465,7 +447,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if (this._flippedX != flippedX) { this._flippedX = flippedX; this.setTextureRect(this._rect, this._rectRotated, this._contentSize); - this.setNodeDirty(true); + //TODO } }, @@ -477,7 +459,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if (this._flippedY != flippedY) { this._flippedY = flippedY; this.setTextureRect(this._rect, this._rectRotated, this._contentSize); - this.setNodeDirty(true); + //TODO } }, @@ -859,7 +841,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ cc.assert(newFrame, cc._LogInfos.Sprite_setSpriteFrame) } - _t.setNodeDirty(true); + //TODO set dirty flag var frameOffset = newFrame.getOffset(); _t._unflippedOffsetPositionFromCenter.x = frameOffset.x; diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js index a48402ae83..bcf2ec444c 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js @@ -54,7 +54,7 @@ }; proto.setTexture = function(texture){ - this._textureForCanvas = texture; + this._texture = texture; var locChildren = this._node._children; for (var i = 0; i < locChildren.length; i++) locChildren[i].setTexture(texture); diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index bd5bb396e7..638136667d 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -22,981 +22,983 @@ THE SOFTWARE. ****************************************************************************/ -cc.Sprite.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; - this._textureCoord = { - renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. - renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. - x: 0, //the x of texture coordinate for node. - y: 0, //the y of texture coordinate for node. - width: 0, - height: 0, - validRect: false - }; - this._blendFuncStr = "source-over"; - this._colorized = false; - - this._originalTexture = null; - this._drawSizeCanvas = null; -}; - -cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.Sprite.CanvasRenderCmd.prototype.constructor = cc.Sprite.CanvasRenderCmd; - -cc.Sprite.CanvasRenderCmd.prototype._init = function(){}; - -cc.Sprite.CanvasRenderCmd.prototype._resetForBatchNode = function(){}; - -cc.Sprite.CanvasRenderCmd.prototype._setTexture = function(texture){ - var node = this._node; - if (node._texture != texture) { - if (texture && texture.getHtmlElementObj() instanceof HTMLImageElement) { - this._originalTexture = texture; - } - node._texture = texture; - } -}; - -cc.Sprite.CanvasRenderCmd.prototype._updateColor = function(){ - this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty); -}; - -cc.Sprite.CanvasRenderCmd.prototype.isFrameDisplayed = function(frame){ - //TODO there maybe has a bug - var node = this._node; - if (frame.getTexture() != node._texture) - return false; - return cc.rectEqualToRect(frame.getRect(), node._rect); -}; - -cc.Sprite.CanvasRenderCmd.prototype.updateBlendFunc = function(blendFunc){ - this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(blendFunc); -}; - -cc.Sprite.CanvasRenderCmd.prototype._setBatchNodeForAddChild = function(child){ - return true; -}; - -cc.Sprite.CanvasRenderCmd.prototype._handleTextureForRotatedTexture = function(texture, rect, rotated){ - if (rotated && texture.isLoaded()) { - var tempElement = texture.getHtmlElementObj(); - tempElement = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, rect); - var tempTexture = new cc.Texture2D(); - tempTexture.initWithElement(tempElement); - tempTexture.handleLoadedTexture(); - texture = tempTexture; - this._node._rect = cc.rect(0, 0, rect.width, rect.height); - } - return texture; -}; - -cc.Sprite.CanvasRenderCmd.prototype._checkTextureBoundary = function(texture, rect, rotated){ - if(texture && texture.url) { - var _x = rect.x + rect.width, _y = rect.y + rect.height; - if(_x > texture.width){ - cc.error(cc._LogInfos.RectWidth, texture.url); - } - if(_y > texture.height){ - cc.error(cc._LogInfos.RectHeight, texture.url); +(function() { + cc.Sprite.CanvasRenderCmd = function (renderable) { + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; + this._textureCoord = { + renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. + renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. + x: 0, //the x of texture coordinate for node. + y: 0, //the y of texture coordinate for node. + width: 0, + height: 0, + validRect: false + }; + this._blendFuncStr = "source-over"; + this._colorized = false; + + this._originalTexture = null; + }; + + var proto = cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.Sprite.CanvasRenderCmd; + + proto._init = function () {}; + + proto._resetForBatchNode = function () {}; + + proto._setTexture = function (texture) { + var node = this._node; + if (node._texture != texture) { + if (texture && texture.getHtmlElementObj() instanceof HTMLImageElement) { + this._originalTexture = texture; + } + node._texture = texture; } - } - this._node._originalTexture = texture; -}; - -cc.Sprite.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var self = this, - node = self._node; - - var context = ctx || cc._renderContext, - locTextureCoord = self._textureCoord; - - if (node._texture && (locTextureCoord.width === 0 || locTextureCoord.height === 0)) - return; - if (!locTextureCoord.validRect && this._displayedOpacity === 0) - return; //draw nothing - - if (node._texture && !node._texture._isLoaded) //set texture but the texture isn't loaded. - return; - - var t = this._worldTransform, - locX = node._offsetPosition.x, - locY = -node._offsetPosition.y - node._rect.height, - locWidth = node._rect.width, - locHeight = node._rect.height, - image, curColor, contentSize; - - var blendChange = (this._blendFuncStr !== "source-over"), alpha = (this._displayedOpacity / 255); - - if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { - context.save(); - - context.globalAlpha = alpha; - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (blendChange) - context.globalCompositeOperation = this._blendFuncStr; - - if (node._flippedX) { - locX = -locX - locWidth; - context.scale(-1, 1); + }; + + proto._updateColor = function () { + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty); + }; + + proto.isFrameDisplayed = function (frame) { + //TODO there maybe has a bug + var node = this._node; + if (frame.getTexture() != node._texture) + return false; + return cc.rectEqualToRect(frame.getRect(), node._rect); + }; + + proto.updateBlendFunc = function (blendFunc) { + this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(blendFunc); + }; + + proto._setBatchNodeForAddChild = function (child) { + return true; + }; + + proto._handleTextureForRotatedTexture = function (texture, rect, rotated) { + if (rotated && texture.isLoaded()) { + var tempElement = texture.getHtmlElementObj(); + tempElement = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, rect); + var tempTexture = new cc.Texture2D(); + tempTexture.initWithElement(tempElement); + tempTexture.handleLoadedTexture(); + texture = tempTexture; + this._node._rect = cc.rect(0, 0, rect.width, rect.height); } - if (node._flippedY) { - locY = node._offsetPosition.y; - context.scale(1, -1); + return texture; + }; + + proto._checkTextureBoundary = function (texture, rect, rotated) { + if (texture && texture.url) { + var _x = rect.x + rect.width, _y = rect.y + rect.height; + if (_x > texture.width) { + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if (_y > texture.height) { + cc.error(cc._LogInfos.RectHeight, texture.url); + } } + this._node._originalTexture = texture; + }; - if (node._texture) { - image = node._texture._htmlElementObj; + proto.rendering = function (ctx, scaleX, scaleY) { + var self = this, + node = self._node; - if (node._texture._pattern != "") { - context.save(); - context.fillStyle = context.createPattern(image, node._texture._pattern); - context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); - context.restore(); - } else { - if (this._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + var context = ctx || cc._renderContext, + locTextureCoord = self._textureCoord; + + if (node._texture && (locTextureCoord.width === 0 || locTextureCoord.height === 0)) + return; + if (!locTextureCoord.validRect && this._displayedOpacity === 0) + return; //draw nothing + + if (node._texture && !node._texture._isLoaded) //set texture but the texture isn't loaded. + return; + + var t = this._worldTransform, + locX = node._offsetPosition.x, + locY = -node._offsetPosition.y - node._rect.height, + locWidth = node._rect.width, + locHeight = node._rect.height, + image, curColor, contentSize; + + var blendChange = (this._blendFuncStr !== "source-over"), alpha = (this._displayedOpacity / 255); + + if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { + context.save(); + + context.globalAlpha = alpha; + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if (blendChange) + context.globalCompositeOperation = this._blendFuncStr; + + if (node._flippedX) { + locX = -locX - locWidth; + context.scale(-1, 1); + } + if (node._flippedY) { + locY = node._offsetPosition.y; + context.scale(1, -1); + } + + if (node._texture) { + image = node._texture._htmlElementObj; + + if (node._texture._pattern != "") { + context.save(); + context.fillStyle = context.createPattern(image, node._texture._pattern); + context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + context.restore(); } else { - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); + if (this._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } + } + } else { + contentSize = node._contentSize; + if (locTextureCoord.validRect) { + curColor = this._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; + context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } + context.restore(); } else { - contentSize = node._contentSize; - if (locTextureCoord.validRect) { - curColor = this._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; - context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + if (blendChange) { + context.save(); + context.globalCompositeOperation = this._blendFuncStr; } - } - context.restore(); - } else { - if (blendChange) { - context.save(); - context.globalCompositeOperation = this._blendFuncStr; - } - context.globalAlpha = alpha; - if (node._texture) { - image = node._texture.getHtmlElementObj(); - if (node._texture._pattern != "") { - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - context.fillStyle = context.createPattern(image, node._texture._pattern); - context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); - context.restore(); - } else { - if (this._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + context.globalAlpha = alpha; + if (node._texture) { + image = node._texture.getHtmlElementObj(); + if (node._texture._pattern != "") { + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + context.fillStyle = context.createPattern(image, node._texture._pattern); + context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + context.restore(); } else { - context.drawImage( - image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - (t.tx + locX) * scaleX, - (-t.ty + locY) * scaleY, - locWidth * scaleX, - locHeight * scaleY); + if (this._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); + } else { + context.drawImage( + image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + (t.tx + locX) * scaleX, + (-t.ty + locY) * scaleY, + locWidth * scaleX, + locHeight * scaleY); + } + } + } else { + contentSize = node._contentSize; + if (locTextureCoord.validRect) { + curColor = this._displayedColor; + context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; + context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } - } else { - contentSize = node._contentSize; - if (locTextureCoord.validRect) { - curColor = this._displayedColor; - context.fillStyle = "rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"; - context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); - } + if (blendChange) + context.restore(); } - if (blendChange) - context.restore(); - } - cc.g_NumberOfDraws++; -}; - -cc.Sprite.CanvasRenderCmd.prototype._changeTextureColor = function(){ - if(!cc.sys._supportCanvasNewBlendModes){ - var locElement, locTexture = this._texture, locRect = this._renderCmd._textureCoord; - if (locTexture && locRect.validRect && this._originalTexture) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; - - if(!cc.sys._supportCanvasNewBlendModes) { - var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); - if (cacheTextureForColor) { + cc.g_NumberOfDraws++; + }; + + proto._changeTextureColor = function () { + if (!cc.sys._supportCanvasNewBlendModes) { + var locElement, locTexture = this._texture, locRect = this._renderCmd._textureCoord; + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + + if (!cc.sys._supportCanvasNewBlendModes) { + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); + if (cacheTextureForColor) { + this._colorized = true; + //generate color texture cache + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + this.texture = locTexture; + } + } + } else { this._colorized = true; - //generate color texture cache - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor + && this._originalTexture._htmlElementObj != locElement) + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); this.texture = locTexture; } } + } + } + }; + + proto.getQuad = function () { + //throw an error. it doesn't support this function. + return null; + }; + + proto._updateForSetSpriteFrame = function (pNewTexture, textureLoaded) { + var node = this._node; + if (node._rectRotated) + node._originalTexture = pNewTexture; //TODO + this._colorized = false; + this._textureCoord.renderX = this._textureCoord.x; + this._textureCoord.renderY = this._textureCoord.y; + if (textureLoaded) { + var curColor = node.getColor(); + if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) + this._changeTextureColor(); + } + }; + + proto.updateTransform = function () { + var _t = this, node = this._node; + + // re-calculate matrix only if it is dirty + if (node.dirty) { + // If it is not visible, or one of its ancestors is not visible, then do nothing: + var locParent = node._parent; + if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { + node._shouldBeHidden = true; } else { - this._colorized = true; - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor - && this._originalTexture._htmlElementObj != locElement) - cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); - else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.texture = locTexture; + node._shouldBeHidden = false; + + if (!locParent || locParent == node._batchNode) { + node._transformToBatch = _t.getNodeToParentTransform(); + } else { + //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); + node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); } } + node._recursiveDirty = false; + node.dirty = false; } - } -}; - -cc.Sprite.CanvasRenderCmd.prototype.getQuad = function(){ - //throw an error. it doesn't support this function. - return null; -}; - -cc.Sprite.CanvasRenderCmd.prototype._updateForSetSpriteFrame = function(pNewTexture, textureLoaded){ - var node = this._node; - if (node._rectRotated) - node._originalTexture = pNewTexture; //TODO - this._colorized = false; - this._textureCoord.renderX = this._textureCoord.x; - this._textureCoord.renderY = this._textureCoord.y; - if (textureLoaded) { - var curColor = node.getColor(); + + // recursively iterate over children + if (node._hasChildren) + node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); + }; + + proto._updateDisplayColor = function (parentColor) { + cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, parentColor); + this._changeTextureColor(); + }; + + proto._spriteFrameLoadedCallback = function (spriteFrame) { + var _t = this; + _t.setNodeDirty(true); + _t.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); + + //TODO change + var curColor = _t.getColor(); if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) - this._changeTextureColor(); - } -}; - -cc.Sprite.CanvasRenderCmd.prototype.updateTransform = function(){ - var _t = this, node = this._node; - - // re-calculate matrix only if it is dirty - if (node.dirty) { - // If it is not visible, or one of its ancestors is not visible, then do nothing: - var locParent = node._parent; - if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { - node._shouldBeHidden = true; + _t._changeTextureColor(); + + _t.dispatchEvent("load"); + }; + + proto._textureLoadedCallback = function (sender) { + var _t = this; + if (_t._textureLoaded) + return; + + _t._textureLoaded = true; + var locRect = _t._rect, locRenderCmd = this._renderCmd; + if (!locRect) { + locRect = cc.rect(0, 0, sender.width, sender.height); + } else if (cc._rectEqualToZero(locRect)) { + locRect.width = sender.width; + locRect.height = sender.height; + } + locRenderCmd._originalTexture = sender; + + _t.texture = sender; + _t.setTextureRect(locRect, _t._rectRotated); + + //set the texture's color after the it loaded + var locColor = locRenderCmd._displayedColor; + if (locColor.r != 255 || locColor.g != 255 || locColor.b != 255) + _t._changeTextureColor(); + + // by default use "Self Render". + // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" + _t.setBatchNode(_t._batchNode); + _t.dispatchEvent("load"); + }; + + proto._setTextureCoords = function (rect, needConvert) { + if (needConvert === undefined) + needConvert = true; + var locTextureRect = this._textureCoord, + scaleFactor = needConvert ? cc.contentScaleFactor() : 1; + locTextureRect.renderX = locTextureRect.x = 0 | (rect.x * scaleFactor); + locTextureRect.renderY = locTextureRect.y = 0 | (rect.y * scaleFactor); + locTextureRect.width = 0 | (rect.width * scaleFactor); + locTextureRect.height = 0 | (rect.height * scaleFactor); + locTextureRect.validRect = !(locTextureRect.width === 0 || locTextureRect.height === 0 || locTextureRect.x < 0 || locTextureRect.y < 0); + }; + + //TODO need refactor these functions + //utils for tint + // Tint a texture using the "multiply" operation + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply = function (image, color, rect, renderCanvas) { + renderCanvas = renderCanvas || cc.newElement("canvas"); + rect = rect || cc.rect(0, 0, image.width, image.height); + var context = renderCanvas.getContext("2d"); + if (renderCanvas.width != rect.width || renderCanvas.height != rect.height) { + renderCanvas.width = rect.width; + renderCanvas.height = rect.height; } else { - node._shouldBeHidden = false; + context.globalCompositeOperation = "source-over"; + } - if (!locParent || locParent == node._batchNode) { - node._transformToBatch = _t.getNodeToParentTransform(); - } else { - //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); - node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); - } + context.fillStyle = "rgb(" + (0 | color.r) + "," + (0 | color.g) + "," + (0 | color.b) + ")"; + context.fillRect(0, 0, rect.width, rect.height); + context.globalCompositeOperation = "multiply"; + context.drawImage(image, + rect.x, + rect.y, + rect.width, + rect.height, + 0, + 0, + rect.width, + rect.height); + context.globalCompositeOperation = "destination-atop"; + context.drawImage(image, + rect.x, + rect.y, + rect.width, + rect.height, + 0, + 0, + rect.width, + rect.height); + return renderCanvas; + }; + + //Generate tinted texture with lighter. + cc.Sprite.CanvasRenderCmd._generateTintImage = function (texture, tintedImgCache, color, rect, renderCanvas) { + if (!rect) + rect = cc.rect(0, 0, texture.width, texture.height); + + var r = color.r / 255, g = color.g / 255, b = color.b / 255; + var w = Math.min(rect.width, tintedImgCache[0].width); + var h = Math.min(rect.height, tintedImgCache[0].height); + var buff = renderCanvas, ctx; + // Create a new buffer if required + if (!buff) { + buff = cc.newElement("canvas"); + buff.width = w; + buff.height = h; + ctx = buff.getContext("2d"); + } else { + ctx = buff.getContext("2d"); + ctx.clearRect(0, 0, w, h); } - node._recursiveDirty = false; - node.dirty = false; - } - - // recursively iterate over children - if (node._hasChildren) - node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); -}; - -cc.Sprite.CanvasRenderCmd.prototype._updateDisplayColor = function(parentColor){ - cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._changeTextureColor(); -}; - -cc.Sprite.CanvasRenderCmd.prototype._spriteFrameLoadedCallback = function(spriteFrame){ - var _t = this; - _t.setNodeDirty(true); - _t.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - - //TODO change - var curColor = _t.getColor(); - if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) - _t._changeTextureColor(); - - _t.dispatchEvent("load"); -}; - -cc.Sprite.CanvasRenderCmd.prototype._textureLoadedCallback = function (sender) { - var _t = this; - if(_t._textureLoaded) - return; - - _t._textureLoaded = true; - var locRect = _t._rect, locRenderCmd = this._renderCmd; - if (!locRect) { - locRect = cc.rect(0, 0, sender.width, sender.height); - } else if (cc._rectEqualToZero(locRect)) { - locRect.width = sender.width; - locRect.height = sender.height; - } - locRenderCmd._originalTexture = sender; - - _t.texture = sender; - _t.setTextureRect(locRect, _t._rectRotated); - - //set the texture's color after the it loaded - var locColor = locRenderCmd._displayedColor; - if(locColor.r != 255 || locColor.g != 255 || locColor.b != 255) - _t._changeTextureColor(); - - // by default use "Self Render". - // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - _t.setBatchNode(_t._batchNode); - _t.dispatchEvent("load"); -}; - -cc.Sprite.CanvasRenderCmd.prototype._setTextureCoords = function(rect, needConvert){ - if(needConvert === undefined) - needConvert = true; - var locTextureRect = this._textureCoord, - scaleFactor = needConvert ? cc.contentScaleFactor() : 1; - locTextureRect.renderX = locTextureRect.x = 0 | (rect.x * scaleFactor); - locTextureRect.renderY = locTextureRect.y = 0 | (rect.y * scaleFactor); - locTextureRect.width = 0 | (rect.width * scaleFactor); - locTextureRect.height = 0 | (rect.height * scaleFactor); - locTextureRect.validRect = !(locTextureRect.width === 0 || locTextureRect.height === 0 || locTextureRect.x < 0 || locTextureRect.y < 0); -}; - -//TODO need refactor these functions -//utils for tint -// Tint a texture using the "multiply" operation -cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply = function(image, color, rect, renderCanvas){ - renderCanvas = renderCanvas || cc.newElement("canvas"); - rect = rect || cc.rect(0,0, image.width, image.height); - var context = renderCanvas.getContext( "2d" ); - if(renderCanvas.width != rect.width || renderCanvas.height != rect.height){ - renderCanvas.width = rect.width; - renderCanvas.height = rect.height; - }else{ - context.globalCompositeOperation = "source-over"; - } - - context.fillStyle = "rgb(" + (0|color.r) + "," + (0|color.g) + "," + (0|color.b) + ")"; - context.fillRect(0, 0, rect.width, rect.height); - context.globalCompositeOperation = "multiply"; - context.drawImage(image, - rect.x, - rect.y, - rect.width, - rect.height, - 0, - 0, - rect.width, - rect.height); - context.globalCompositeOperation = "destination-atop"; - context.drawImage(image, - rect.x, - rect.y, - rect.width, - rect.height, - 0, - 0, - rect.width, - rect.height); - return renderCanvas; -}; - -//Generate tinted texture with lighter. -cc.Sprite.CanvasRenderCmd._generateTintImage = function (texture, tintedImgCache, color, rect, renderCanvas) { - if (!rect) - rect = cc.rect(0, 0, texture.width, texture.height); - - var r = color.r / 255, g = color.g / 255, b = color.b / 255; - var w = Math.min(rect.width, tintedImgCache[0].width); - var h = Math.min(rect.height, tintedImgCache[0].height); - var buff = renderCanvas, ctx; - // Create a new buffer if required - if (!buff) { - buff = cc.newElement("canvas"); - buff.width = w; - buff.height = h; - ctx = buff.getContext("2d"); - } else { - ctx = buff.getContext("2d"); - ctx.clearRect(0, 0, w, h); - } - - ctx.save(); - ctx.globalCompositeOperation = 'lighter'; - // Make sure to keep the renderCanvas alpha in mind in case of overdraw - var a = ctx.globalAlpha; - if (r > 0) { - ctx.globalAlpha = r * a; - ctx.drawImage(tintedImgCache[0], rect.x, rect.y, w, h, 0, 0, w, h); - } - if (g > 0) { - ctx.globalAlpha = g * a; - ctx.drawImage(tintedImgCache[1], rect.x, rect.y, w, h, 0, 0, w, h); - } - if (b > 0) { - ctx.globalAlpha = b * a; - ctx.drawImage(tintedImgCache[2], rect.x, rect.y, w, h, 0, 0, w, h); - } - if (r + g + b < 1) { - ctx.globalAlpha = a; - ctx.drawImage(tintedImgCache[3], rect.x, rect.y, w, h, 0, 0, w, h); - } - ctx.restore(); - return buff; -}; - -cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor = function (texture) { - if (texture.channelCache) { - return texture.channelCache; - } - - var textureCache = [ - cc.newElement("canvas"), - cc.newElement("canvas"), - cc.newElement("canvas"), - cc.newElement("canvas") - ]; - - function renderToCache() { - var ref = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor; - - var w = texture.width; - var h = texture.height; - - textureCache[0].width = w; - textureCache[0].height = h; - textureCache[1].width = w; - textureCache[1].height = h; - textureCache[2].width = w; - textureCache[2].height = h; - textureCache[3].width = w; - textureCache[3].height = h; - - ref.canvas.width = w; - ref.canvas.height = h; - - var ctx = ref.canvas.getContext("2d"); - ctx.drawImage(texture, 0, 0); - - ref.tempCanvas.width = w; - ref.tempCanvas.height = h; - - var pixels = ctx.getImageData(0, 0, w, h).data; - - for (var rgbI = 0; rgbI < 4; rgbI++) { - var cacheCtx = textureCache[rgbI].getContext('2d'); - cacheCtx.getImageData(0, 0, w, h).data; - ref.tempCtx.drawImage(texture, 0, 0); - - var to = ref.tempCtx.getImageData(0, 0, w, h); - var toData = to.data; - - for (var i = 0; i < pixels.length; i += 4) { - toData[i ] = (rgbI === 0) ? pixels[i ] : 0; - toData[i + 1] = (rgbI === 1) ? pixels[i + 1] : 0; - toData[i + 2] = (rgbI === 2) ? pixels[i + 2] : 0; - toData[i + 3] = pixels[i + 3]; - } - cacheCtx.putImageData(to, 0, 0); + + ctx.save(); + ctx.globalCompositeOperation = 'lighter'; + // Make sure to keep the renderCanvas alpha in mind in case of overdraw + var a = ctx.globalAlpha; + if (r > 0) { + ctx.globalAlpha = r * a; + ctx.drawImage(tintedImgCache[0], rect.x, rect.y, w, h, 0, 0, w, h); + } + if (g > 0) { + ctx.globalAlpha = g * a; + ctx.drawImage(tintedImgCache[1], rect.x, rect.y, w, h, 0, 0, w, h); } - texture.onload = null; - } + if (b > 0) { + ctx.globalAlpha = b * a; + ctx.drawImage(tintedImgCache[2], rect.x, rect.y, w, h, 0, 0, w, h); + } + if (r + g + b < 1) { + ctx.globalAlpha = a; + ctx.drawImage(tintedImgCache[3], rect.x, rect.y, w, h, 0, 0, w, h); + } + ctx.restore(); + return buff; + }; - try { - renderToCache(); - } catch (e) { - texture.onload = renderToCache; - } + cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor = function (texture) { + if (texture.channelCache) { + return texture.channelCache; + } - texture.channelCache = textureCache; - return textureCache; -}; + var textureCache = [ + cc.newElement("canvas"), + cc.newElement("canvas"), + cc.newElement("canvas"), + cc.newElement("canvas") + ]; -cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.canvas = cc.newElement('canvas'); -cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas = cc.newElement('canvas'); -cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCtx = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas.getContext('2d'); + function renderToCache() { + var ref = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor; -cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas = function (texture, rect) { - if (!texture) - return null; + var w = texture.width; + var h = texture.height; - if (!rect) - return texture; + textureCache[0].width = w; + textureCache[0].height = h; + textureCache[1].width = w; + textureCache[1].height = h; + textureCache[2].width = w; + textureCache[2].height = h; + textureCache[3].width = w; + textureCache[3].height = h; + + ref.canvas.width = w; + ref.canvas.height = h; + + var ctx = ref.canvas.getContext("2d"); + ctx.drawImage(texture, 0, 0); + + ref.tempCanvas.width = w; + ref.tempCanvas.height = h; + + var pixels = ctx.getImageData(0, 0, w, h).data; + + for (var rgbI = 0; rgbI < 4; rgbI++) { + var cacheCtx = textureCache[rgbI].getContext('2d'); + cacheCtx.getImageData(0, 0, w, h).data; + ref.tempCtx.drawImage(texture, 0, 0); + + var to = ref.tempCtx.getImageData(0, 0, w, h); + var toData = to.data; + + for (var i = 0; i < pixels.length; i += 4) { + toData[i ] = (rgbI === 0) ? pixels[i ] : 0; + toData[i + 1] = (rgbI === 1) ? pixels[i + 1] : 0; + toData[i + 2] = (rgbI === 2) ? pixels[i + 2] : 0; + toData[i + 3] = pixels[i + 3]; + } + cacheCtx.putImageData(to, 0, 0); + } + texture.onload = null; + } + + try { + renderToCache(); + } catch (e) { + texture.onload = renderToCache; + } - var nCanvas = cc.newElement("canvas"); - nCanvas.width = rect.width; - nCanvas.height = rect.height; - var ctx = nCanvas.getContext("2d"); - ctx.translate(nCanvas.width / 2, nCanvas.height / 2); - ctx.rotate(-1.5707963267948966); - ctx.drawImage(texture, rect.x, rect.y, rect.height, rect.width, -rect.height / 2, -rect.width / 2, rect.height, rect.width); - return nCanvas; -}; + texture.channelCache = textureCache; + return textureCache; + }; + + cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.canvas = cc.newElement('canvas'); + cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas = cc.newElement('canvas'); + cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCtx = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas.getContext('2d'); + + cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas = function (texture, rect) { + if (!texture) + return null; + + if (!rect) + return texture; + + var nCanvas = cc.newElement("canvas"); + nCanvas.width = rect.width; + nCanvas.height = rect.height; + var ctx = nCanvas.getContext("2d"); + ctx.translate(nCanvas.width / 2, nCanvas.height / 2); + ctx.rotate(-1.5707963267948966); + ctx.drawImage(texture, rect.x, rect.y, rect.height, rect.width, -rect.height / 2, -rect.width / 2, rect.height, rect.width); + return nCanvas; + }; +})(); //++++++++++++++++++++++++++++++WebGL+++++++++++++++++++++++++++++++++++++++++++ //Sprite's WebGL render command -cc.Sprite.WebGLRenderCmd = function(renderable){ - cc.Node.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; - - this._quad = new cc.V3F_C4B_T2F_Quad(); - this._quadWebBuffer = cc._renderContext.createBuffer(); - this._quadDirty = true; -}; - -cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.Sprite.WebGLRenderCmd.prototype.constructor = cc.Sprite.WebGLRenderCmd; - -cc.Sprite.WebGLRenderCmd.prototype.updateBlendFunc = function(blendFunc){ - //do nothing -}; - -cc.Sprite.WebGLRenderCmd.prototype._setBatchNodeForAddChild = function(child){ - var node = this._node; - if (node._batchNode) { - if(!(child instanceof cc.Sprite)){ - cc.log(cc._LogInfos.Sprite_addChild); - return false; +(function() { + cc.Sprite.WebGLRenderCmd = function (renderable) { + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + + this._quad = new cc.V3F_C4B_T2F_Quad(); + this._quadWebBuffer = cc._renderContext.createBuffer(); + this._quadDirty = true; + }; + + var proto = cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.Sprite.WebGLRenderCmd; + + proto.updateBlendFunc = function (blendFunc) {}; + + proto._setBatchNodeForAddChild = function (child) { + var node = this._node; + if (node._batchNode) { + if (!(child instanceof cc.Sprite)) { + cc.log(cc._LogInfos.Sprite_addChild); + return false; + } + if (child.texture._webTextureObj !== node.textureAtlas.texture._webTextureObj) + cc.log(cc._LogInfos.Sprite_addChild_2); + + //put it in descendants array of batch node + node._batchNode.appendChild(child); + if (!node._reorderChildDirty) + node._setReorderChildDirtyRecursively(); } - if(child.texture._webTextureObj !== node.textureAtlas.texture._webTextureObj) - cc.log(cc._LogInfos.Sprite_addChild_2); - - //put it in descendants array of batch node - node._batchNode.appendChild(child); - if (!node._reorderChildDirty) - node._setReorderChildDirtyRecursively(); - } - return true; -}; - -cc.Sprite.WebGLRenderCmd.prototype._handleTextureForRotatedTexture = function(){ - //do nothing. -}; - -cc.Sprite.WebGLRenderCmd.prototype.isFrameDisplayed = function(frame){ - var node = this._node; - return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() == node._texture.getName() - && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); -}; - -cc.Sprite.WebGLRenderCmd.prototype._init = function(){ - var tempColor = {r: 255, g: 255, b: 255, a: 255}, quad = this._quad; - quad.bl.colors = tempColor; - quad.br.colors = tempColor; - quad.tl.colors = tempColor; - quad.tr.colors = tempColor; - this._quadDirty = true; -}; - -cc.Sprite.WebGLRenderCmd.prototype._resetForBatchNode = function(){ - var node = this._node; - var x1 = node._offsetPosition.x; - var y1 = node._offsetPosition.y; - var x2 = x1 + node._rect.width; - var y2 = y1 + node._rect.height; - var locQuad = this._quad; - locQuad.bl.vertices = {x:x1, y:y1, z:0}; - locQuad.br.vertices = {x:x2, y:y1, z:0}; - locQuad.tl.vertices = {x:x1, y:y2, z:0}; - locQuad.tr.vertices = {x:x2, y:y2, z:0}; - this._quadDirty = true; -}; - -cc.Sprite.WebGLRenderCmd.prototype.getQuad = function(){ - return this._quad; -}; - -cc.Sprite.WebGLRenderCmd.prototype._updateForSetSpriteFrame = function(){}; - -cc.Sprite.WebGLRenderCmd.prototype._spriteFrameLoadedCallback = function(spriteFrame){ - this.setNodeDirty(true); - this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - this.dispatchEvent("load"); -}; - -cc.Sprite.WebGLRenderCmd.prototype._textureLoadedCallback = function (sender) { - var node = this._node; - if(node._textureLoaded) - return; - - node._textureLoaded = true; - var locRect = node._rect; - if (!locRect) { - locRect = cc.rect(0, 0, sender.width, sender.height); - } else if (cc._rectEqualToZero(locRect)) { - locRect.width = sender.width; - locRect.height = sender.height; - } - - node.texture = sender; - node.setTextureRect(locRect, node._rectRotated); - - // by default use "Self Render". - // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - node.setBatchNode(node._batchNode); - this._quadDirty = true; - node.dispatchEvent("load"); -}; - -cc.Sprite.WebGLRenderCmd.prototype._setTextureCoords = function (rect, needConvert) { - if(needConvert === undefined) - needConvert = true; - if(needConvert) - rect = cc.rectPointsToPixels(rect); - var node = this._node; - - var tex = node._batchNode ? node.textureAtlas.texture : node._texture; - if (!tex) - return; - - var atlasWidth = tex.pixelsWidth; - var atlasHeight = tex.pixelsHeight; - - var left, right, top, bottom, tempSwap, locQuad = this._quad; - if (node._rectRotated) { - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.height * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); + return true; + }; + + proto._handleTextureForRotatedTexture = function (texture) { + return texture; + }; + + proto.isFrameDisplayed = function (frame) { + var node = this._node; + return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() == node._texture.getName() + && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); + }; + + proto._init = function () { + var tempColor = {r: 255, g: 255, b: 255, a: 255}, quad = this._quad; + quad.bl.colors = tempColor; + quad.br.colors = tempColor; + quad.tl.colors = tempColor; + quad.tr.colors = tempColor; + this._quadDirty = true; + }; + + proto._resetForBatchNode = function () { + var node = this._node; + var x1 = node._offsetPosition.x; + var y1 = node._offsetPosition.y; + var x2 = x1 + node._rect.width; + var y2 = y1 + node._rect.height; + var locQuad = this._quad; + locQuad.bl.vertices = {x: x1, y: y1, z: 0}; + locQuad.br.vertices = {x: x2, y: y1, z: 0}; + locQuad.tl.vertices = {x: x1, y: y2, z: 0}; + locQuad.tr.vertices = {x: x2, y: y2, z: 0}; + this._quadDirty = true; + }; + + proto.getQuad = function () { + return this._quad; + }; + + proto._updateForSetSpriteFrame = function () {}; + + proto._spriteFrameLoadedCallback = function (spriteFrame) { + this.setNodeDirty(true); + this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); + this.dispatchEvent("load"); + }; + + proto._textureLoadedCallback = function (sender) { + var node = this._node; + if (node._textureLoaded) + return; + + node._textureLoaded = true; + var locRect = node._rect; + if (!locRect) { + locRect = cc.rect(0, 0, sender.width, sender.height); + } else if (cc._rectEqualToZero(locRect)) { + locRect.width = sender.width; + locRect.height = sender.height; + } + + node.texture = sender; + node.setTextureRect(locRect, node._rectRotated); + + // by default use "Self Render". + // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" + node.setBatchNode(node._batchNode); + this._quadDirty = true; + node.dispatchEvent("load"); + }; + + proto._setTextureCoords = function (rect, needConvert) { + if (needConvert === undefined) + needConvert = true; + if (needConvert) + rect = cc.rectPointsToPixels(rect); + var node = this._node; + + var tex = node._batchNode ? node.textureAtlas.texture : node._texture; + if (!tex) + return; + + var atlasWidth = tex.pixelsWidth; + var atlasHeight = tex.pixelsHeight; + + var left, right, top, bottom, tempSwap, locQuad = this._quad; + if (node._rectRotated) { + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.height * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.height) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.width) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + if (node._flippedY) { + tempSwap = left; + left = right; + right = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = top; + locQuad.br.texCoords.u = left; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = right; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = bottom; } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.height) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.width) / atlasHeight; + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.width * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.width) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.height) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = left; + left = right; + right = tempSwap; + } + + if (node._flippedY) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = bottom; + locQuad.br.texCoords.u = right; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = left; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = top; } + this._quadDirty = true; + }; + + proto._updateDisplayColor = function (parentColor) { + cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); + this._updateColor(); + }; + + proto._updateDisplayOpacity = function (parentOpacity) { + cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); + this._updateColor(); + }; - if (node._flippedX) { - tempSwap = top; - top = bottom; - bottom = tempSwap; + proto._updateColor = function () { + var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; + var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; + // special opacity for premultiplied textures + if (this._opacityModifyRGB) { + color4.r *= locDisplayedOpacity / 255.0; + color4.g *= locDisplayedOpacity / 255.0; + color4.b *= locDisplayedOpacity / 255.0; + } + var locQuad = this._quad, node = this._node; + locQuad.bl.colors = color4; + locQuad.br.colors = color4; + locQuad.tl.colors = color4; + locQuad.tr.colors = color4; + + // renders using Sprite Manager + if (node._batchNode) { + if (node.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { + node.textureAtlas.updateQuad(locQuad, node.atlasIndex) + } else { + // no need to set it recursively + // update dirty_, don't update recursiveDirty_ + node.dirty = true; + } } + // self render + // do nothing + this._quadDirty = true; + }; - if (node._flippedY) { - tempSwap = left; - left = right; - right = tempSwap; + proto._updateBlendFunc = function () { + if (this._batchNode) { + cc.log(cc._LogInfos.Sprite__updateBlendFunc); + return; } - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = top; - locQuad.br.texCoords.u = left; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = right; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = bottom; - } else { - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.width * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); + // it's possible to have an untextured sprite + var node = this._node; + if (!node._texture || !node._texture.hasPremultipliedAlpha()) { + node._blendFunc.src = cc.SRC_ALPHA; + node._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + node.opacityModifyRGB = false; } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.width) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.height) / atlasHeight; + node._blendFunc.src = cc.BLEND_SRC; + node._blendFunc.dst = cc.BLEND_DST; + node.opacityModifyRGB = true; } + }; - if (node._flippedX) { - tempSwap = left; - left = right; - right = tempSwap; + proto._setTexture = function (texture) { + var node = this._node; + // If batchnode, then texture id should be the same + if (node._batchNode && node._batchNode.texture != texture) { + cc.log(cc._LogInfos.Sprite_setTexture); + return; } - if (node._flippedY) { - tempSwap = top; - top = bottom; - bottom = tempSwap; - } + if (texture) + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + else + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = bottom; - locQuad.br.texCoords.u = right; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = left; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = top; - } - this._quadDirty = true; -}; - -cc.Sprite.WebGLRenderCmd.prototype._updateDisplayColor = function(parentColor){ - cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._updateColor(); -}; - -cc.Sprite.WebGLRenderCmd.prototype._updateDisplayOpacity = function(parentOpacity){ - cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); - this._updateColor(); -}; - -cc.Sprite.WebGLRenderCmd.prototype._updateColor = function () { - var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; - var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; - // special opacity for premultiplied textures - if (this._opacityModifyRGB) { - color4.r *= locDisplayedOpacity / 255.0; - color4.g *= locDisplayedOpacity / 255.0; - color4.b *= locDisplayedOpacity / 255.0; - } - var locQuad = this._quad, node = this._node; - locQuad.bl.colors = color4; - locQuad.br.colors = color4; - locQuad.tl.colors = color4; - locQuad.tr.colors = color4; - - // renders using Sprite Manager - if (node._batchNode) { - if (node.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { - node.textureAtlas.updateQuad(locQuad, node.atlasIndex) - } else { - // no need to set it recursively - // update dirty_, don't update recursiveDirty_ - node.dirty = true; + if (!node._batchNode && node._texture != texture) { + node._texture = texture; + this._updateBlendFunc(); } - } - // self render - // do nothing - this._quadDirty = true; -}; - -cc.Sprite.WebGLRenderCmd.prototype._updateBlendFunc = function(){ - if(this._batchNode){ - cc.log(cc._LogInfos.Sprite__updateBlendFunc); - return; - } - - // it's possible to have an untextured sprite - if (!this._texture || !this._texture.hasPremultipliedAlpha()) { - this._blendFunc.src = cc.SRC_ALPHA; - this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - this.opacityModifyRGB = false; - } else { - this._blendFunc.src = cc.BLEND_SRC; - this._blendFunc.dst = cc.BLEND_DST; - this.opacityModifyRGB = true; - } -}; - -cc.Sprite.WebGLRenderCmd.prototype._setTexture = function(texture){ - var node = this._node; - // If batchnode, then texture id should be the same - if(node._batchNode && node._batchNode.texture != texture) { - cc.log(cc._LogInfos.Sprite_setTexture); - return; - } - - if (texture) - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - else - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); - - if (!node._batchNode && node._texture != texture) { - node._texture = texture; - this._updateBlendFunc(); - } -}; - -cc.Sprite.WebGLRenderCmd.prototype.updateTransform = function () { - var _t = this, node = this._node; - - // recalculate matrix only if it is dirty - if (node.dirty) { - var locQuad = _t._quad, locParent = node._parent; - // If it is not visible, or one of its ancestors is not visible, then do nothing: - if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { - locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; - node._shouldBeHidden = true; - } else { - node._shouldBeHidden = false; + }; - if (!locParent || locParent == node._batchNode) { - node._transformToBatch = _t.getNodeToParentTransform(); + proto.updateTransform = function () { + var _t = this, node = this._node; + + // recalculate matrix only if it is dirty + if (node.dirty) { + var locQuad = _t._quad, locParent = node._parent; + // If it is not visible, or one of its ancestors is not visible, then do nothing: + if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { + locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; + node._shouldBeHidden = true; } else { - //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); - node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); - } + node._shouldBeHidden = false; - // - // calculate the Quad based on the Affine Matrix - // - var locTransformToBatch = node._transformToBatch; - var rect = node._rect; - var x1 = node._offsetPosition.x; - var y1 = node._offsetPosition.y; - - var x2 = x1 + rect.width; - var y2 = y1 + rect.height; - var x = locTransformToBatch.tx; - var y = locTransformToBatch.ty; - - var cr = locTransformToBatch.a; - var sr = locTransformToBatch.b; - var cr2 = locTransformToBatch.d; - var sr2 = -locTransformToBatch.c; - var ax = x1 * cr - y1 * sr2 + x; - var ay = x1 * sr + y1 * cr2 + y; - - var bx = x2 * cr - y1 * sr2 + x; - var by = x2 * sr + y1 * cr2 + y; - - var cx = x2 * cr - y2 * sr2 + x; - var cy = x2 * sr + y2 * cr2 + y; - - var dx = x1 * cr - y2 * sr2 + x; - var dy = x1 * sr + y2 * cr2 + y; - - var locVertexZ = _t._vertexZ; - if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - ax = 0 | ax; - ay = 0 | ay; - bx = 0 | bx; - by = 0 | by; - cx = 0 | cx; - cy = 0 | cy; - dx = 0 | dx; - dy = 0 | dy; + if (!locParent || locParent == node._batchNode) { + node._transformToBatch = _t.getNodeToParentTransform(); + } else { + //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); + node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); + } + + // + // calculate the Quad based on the Affine Matrix + // + var locTransformToBatch = node._transformToBatch; + var rect = node._rect; + var x1 = node._offsetPosition.x; + var y1 = node._offsetPosition.y; + + var x2 = x1 + rect.width; + var y2 = y1 + rect.height; + var x = locTransformToBatch.tx; + var y = locTransformToBatch.ty; + + var cr = locTransformToBatch.a; + var sr = locTransformToBatch.b; + var cr2 = locTransformToBatch.d; + var sr2 = -locTransformToBatch.c; + var ax = x1 * cr - y1 * sr2 + x; + var ay = x1 * sr + y1 * cr2 + y; + + var bx = x2 * cr - y1 * sr2 + x; + var by = x2 * sr + y1 * cr2 + y; + + var cx = x2 * cr - y2 * sr2 + x; + var cy = x2 * sr + y2 * cr2 + y; + + var dx = x1 * cr - y2 * sr2 + x; + var dy = x1 * sr + y2 * cr2 + y; + + var locVertexZ = _t._vertexZ; + if (!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + ax = 0 | ax; + ay = 0 | ay; + bx = 0 | bx; + by = 0 | by; + cx = 0 | cx; + cy = 0 | cy; + dx = 0 | dx; + dy = 0 | dy; + } + locQuad.bl.vertices = {x: ax, y: ay, z: locVertexZ}; + locQuad.br.vertices = {x: bx, y: by, z: locVertexZ}; + locQuad.tl.vertices = {x: dx, y: dy, z: locVertexZ}; + locQuad.tr.vertices = {x: cx, y: cy, z: locVertexZ}; } - locQuad.bl.vertices = {x: ax, y: ay, z: locVertexZ}; - locQuad.br.vertices = {x: bx, y: by, z: locVertexZ}; - locQuad.tl.vertices = {x: dx, y: dy, z: locVertexZ}; - locQuad.tr.vertices = {x: cx, y: cy, z: locVertexZ}; + node.textureAtlas.updateQuad(locQuad, _t.atlasIndex); + node._recursiveDirty = false; + node.dirty = false; } - node.textureAtlas.updateQuad(locQuad, _t.atlasIndex); - node._recursiveDirty = false; - node.dirty = false; - } - - // recursively iterate over children - if (node._hasChildren) - node._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); - - if (cc.SPRITE_DEBUG_DRAW) { - // draw bounding box - var vertices = [ - cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), - cc.p(_t._quad.br.vertices.x, _t._quad.br.vertices.y), - cc.p(_t._quad.tr.vertices.x, _t._quad.tr.vertices.y), - cc.p(_t._quad.tl.vertices.x, _t._quad.tl.vertices.y) - ]; - cc._drawingUtil.drawPoly(vertices, 4, true); - } -}; - -cc.Sprite.WebGLRenderCmd.prototype._checkTextureBoundary = function(texture, rect, rotated){ - if(texture && texture.url) { - var _x, _y; - if(rotated){ - _x = rect.x + rect.height; - _y = rect.y + rect.width; - }else{ - _x = rect.x + rect.width; - _y = rect.y + rect.height; - } - if(_x > texture.width){ - cc.error(cc._LogInfos.RectWidth, texture.url); + + // recursively iterate over children + if (node._hasChildren) + node._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); + + if (cc.SPRITE_DEBUG_DRAW) { + // draw bounding box + var vertices = [ + cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), + cc.p(_t._quad.br.vertices.x, _t._quad.br.vertices.y), + cc.p(_t._quad.tr.vertices.x, _t._quad.tr.vertices.y), + cc.p(_t._quad.tl.vertices.x, _t._quad.tl.vertices.y) + ]; + cc._drawingUtil.drawPoly(vertices, 4, true); } - if(_y > texture.height){ - cc.error(cc._LogInfos.RectHeight, texture.url); + }; + + proto._checkTextureBoundary = function (texture, rect, rotated) { + if (texture && texture.url) { + var _x, _y; + if (rotated) { + _x = rect.x + rect.height; + _y = rect.y + rect.width; + } else { + _x = rect.x + rect.width; + _y = rect.y + rect.height; + } + if (_x > texture.width) { + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if (_y > texture.height) { + cc.error(cc._LogInfos.RectHeight, texture.url); + } } - } -}; + }; -cc.Sprite.WebGLRenderCmd.prototype.rendering = function (ctx) { - var _t = this._node; - if (!_t._textureLoaded || this._displayedOpacity === 0) - return; + proto.rendering = function (ctx) { + var _t = this._node; + if (!_t._textureLoaded || this._displayedOpacity === 0) + return; - var gl = ctx || cc._renderContext, locTexture = _t._texture; - //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); + var gl = ctx || cc._renderContext, locTexture = _t._texture; + //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); - if (locTexture) { - if (locTexture._isLoaded) { + if (locTexture) { + if (locTexture._isLoaded) { + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + //optimize performance for javascript + cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); + if (this._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); + this._quadDirty = false; + } + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + } else { _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - //optimize performance for javascript - cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + cc.glBindTexture2D(null); + + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (this._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); - this._quadDirty = false; + if (_t._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.STATIC_DRAW); + _t._quadDirty = false; } - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); } - } else { - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - cc.glBindTexture2D(null); - - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - - gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (_t._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.STATIC_DRAW); - _t._quadDirty = false; - } - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - } - cc.g_NumberOfDraws++; - - if (cc.SPRITE_DEBUG_DRAW === 0 && !_t._showNode) - return; - - if (cc.SPRITE_DEBUG_DRAW === 1 || _t._showNode) { - // draw bounding box - var locQuad = _t._quad; - var verticesG1 = [ - cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), - cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), - cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), - cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) - ]; - cc._drawingUtil.drawPoly(verticesG1, 4, true); - } else if (cc.SPRITE_DEBUG_DRAW === 2) { - // draw texture box - var drawRectG2 = _t.getTextureRect(); - var offsetPixG2 = _t.getOffsetPosition(); - var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), - cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; - cc._drawingUtil.drawPoly(verticesG2, 4, true); - } // CC_SPRITE_DEBUG_DRAW -}; \ No newline at end of file + cc.g_NumberOfDraws++; + + if (cc.SPRITE_DEBUG_DRAW === 0 && !_t._showNode) + return; + + if (cc.SPRITE_DEBUG_DRAW === 1 || _t._showNode) { + // draw bounding box + var locQuad = _t._quad; + var verticesG1 = [ + cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), + cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), + cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), + cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) + ]; + cc._drawingUtil.drawPoly(verticesG1, 4, true); + } else if (cc.SPRITE_DEBUG_DRAW === 2) { + // draw texture box + var drawRectG2 = _t.getTextureRect(); + var offsetPixG2 = _t.getOffsetPosition(); + var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), + cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; + cc._drawingUtil.drawPoly(verticesG2, 4, true); + } // CC_SPRITE_DEBUG_DRAW + }; +})(); \ No newline at end of file diff --git a/template/project.json b/template/project.json index cd45a5926f..0c277b291a 100644 --- a/template/project.json +++ b/template/project.json @@ -3,7 +3,7 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 1, + "renderMode" : 0, "engineDir":"../", "modules" : ["cocos2d"], From 774dd1806f7a0bbf08e2d35eb737345f847fd8f3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 22 Nov 2014 15:50:09 +0800 Subject: [PATCH 0944/1564] LabelBMFont renderCmd --- cocos2d/labels/CCLabelBMFont.js | 144 +++------------- cocos2d/labels/CCLabelBMFontRenderCmd.js | 203 +++++++++++++++++++++++ moduleConfig.json | 3 +- 3 files changed, 230 insertions(+), 120 deletions(-) create mode 100644 cocos2d/labels/CCLabelBMFontRenderCmd.js diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index cf16bfd34b..c6142c8c03 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -145,6 +145,13 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } }, + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + return new cc.LabelBMFont.WebGLRenderCmd(this); + else + return new cc.LabelBMFont.CanvasRenderCmd(this); + }, + /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    * creates a bitmap font atlas with an initial string and the FNT file. @@ -286,16 +293,11 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ * @param parentOpacity */ updateDisplayedOpacity: function (parentOpacity) { + var cmd = this._renderCmd; this._displayedOpacity = this._realOpacity * parentOpacity / 255.0; var locChildren = this._children; for (var i = 0; i < locChildren.length; i++) { - var locChild = locChildren[i]; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - locChild.updateDisplayedOpacity(this._displayedOpacity); - } else { - cc.Node.prototype.updateDisplayedOpacity.call(locChild, this._displayedOpacity); - locChild.setNodeDirty(); - } + cmd._updateChildrenDisplayedOpacity(locChildren[i]); } this._changeTextureColor(); }, @@ -342,6 +344,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ * @returns {cc.Color} */ updateDisplayedColor: function (parentColor) { + var cmd = this._renderCmd; var locDispColor = this._displayedColor; var locRealColor = this._realColor; locDispColor.r = locRealColor.r * parentColor.r / 255.0; @@ -350,39 +353,13 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var locChildren = this._children; for (var i = 0; i < locChildren.length; i++) { - var locChild = locChildren[i]; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - locChild.updateDisplayedColor(this._displayedColor); - } else { - cc.Node.prototype.updateDisplayedColor.call(locChild, this._displayedColor); - locChild.setNodeDirty(); - } + cmd._updateChildrenDisplayedColor(locChildren[i]); } this._changeTextureColor(); }, _changeTextureColor: function () { - if (cc._renderType == cc._RENDER_TYPE_WEBGL) - return; - - var locTexture = this.getTexture(); - if (locTexture && locTexture.getContentSize().width>0) { - var element = this._originalTexture.getHtmlElementObj(); - if(!element) - return; - var locElement = locTexture.getHtmlElementObj(); - var textureRect = cc.rect(0, 0, element.width, element.height); - if (locElement instanceof HTMLCanvasElement && !this._rectRotated){ - cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); - this.setTexture(locTexture); - } else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._displayedColor, textureRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.setTexture(locTexture); - } - } + this._renderCmd._changeTextureColor(); }, /** @@ -419,6 +396,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ */ initWithString: function (str, fntFile, width, alignment, imageOffset) { var self = this, theString = str || ""; + var cmd = this._renderCmd; if (self._config) cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported"); @@ -459,8 +437,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ self._imageOffset = imageOffset || cc.p(0, 0); self._width = (width == null) ? -1 : width; - self._displayedOpacity = self._realOpacity = 255; - self._displayedColor = cc.color(255, 255, 255, 255); + cmd._displayedOpacity = self._realOpacity = 255; + cmd._displayedColor = cc.color(255, 255, 255, 255); self._realColor = cc.color(255, 255, 255, 255); self._cascadeOpacityEnabled = true; self._cascadeColorEnabled = true; @@ -470,14 +448,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ self.setAnchorPoint(0.5, 0.5); - if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - var locTexture = self.textureAtlas.texture; - self._opacityModifyRGB = locTexture.hasPremultipliedAlpha(); + this._renderCmd._initBatchTexture(); - var reusedChar = self._reusedChar = new cc.Sprite(); - reusedChar.initWithTexture(locTexture, cc.rect(0, 0, 0, 0), false); - reusedChar.batchNode = self; - } self.setString(theString, true); return true; } @@ -489,8 +461,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ */ createFontChars: function () { var self = this; - var locContextType = cc._renderType; - var locTexture = (locContextType === cc._RENDER_TYPE_CANVAS) ? self.texture : self.textureAtlas.texture; + var cmd = this._renderCmd; + var locTexture = cmd._texture || self.textureAtlas.texture; var nextFontPositionX = 0; @@ -540,35 +512,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ rect.y += self._imageOffset.y; var fontChar = self.getChildByTag(i); - //var hasSprite = true; - if (!fontChar) { - fontChar = new cc.Sprite(); - if ((key === 32) && (locContextType === cc._RENDER_TYPE_CANVAS)) - rect = cc.rect(0, 0, 0, 0); - fontChar.initWithTexture(locTexture, rect, false); - fontChar._newTextureWhenChangeColor = true; - self.addChild(fontChar, 0, i); - } else { - if ((key === 32) && (locContextType === cc._RENDER_TYPE_CANVAS)) { - fontChar.setTextureRect(rect, false, cc.size(0, 0)); - } else { - // updating previous sprite - fontChar.setTextureRect(rect, false); - // restore to default in case they were modified - fontChar.visible = true; - } - } - // Apply label properties - fontChar.opacityModifyRGB = self._opacityModifyRGB; - // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - fontChar.updateDisplayedColor(self._displayedColor); - fontChar.updateDisplayedOpacity(self._displayedOpacity); - } else { - cc.Node.prototype.updateDisplayedColor.call(fontChar, self._displayedColor); - cc.Node.prototype.updateDisplayedOpacity.call(fontChar, self._displayedOpacity); - fontChar.setNodeDirty(); - } + + fontChar = this._renderCmd._updateTexture(fontChar, locTexture, rect); var yOffset = locCfg.commonHeight - fontDef.yOffset; var fontPos = cc.p(nextFontPositionX + fontDef.xOffset + fontDef.rect.width * 0.5 + kerningAmount, @@ -942,8 +887,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var locIsLoaded = texture.isLoaded(); self._textureLoaded = locIsLoaded; self.texture = texture; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) - self._originalTexture = self.texture; + this._renderCmd._updateFntFileTexture(); if (!locIsLoaded) { texture.addEventListener("load", function (sender) { var self1 = this; @@ -969,6 +913,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ return this._fntFile; }, + setTexture: function(texture){ + this._renderCmd.setTexture(texture); + }, + /** * Set the AnchorPoint of the labelBMFont.
    * In order to change the location of label. @@ -1055,48 +1003,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var _p = cc.LabelBMFont.prototype; cc.EventHelper.prototype.apply(_p); -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - if (!cc.sys._supportCanvasNewBlendModes) { - _p._changeTextureColor = function () { - if (cc._renderType == cc._RENDER_TYPE_WEBGL) - return; - var locElement, locTexture = this.getTexture(); - if (locTexture && locTexture.getContentSize().width > 0) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; - var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); - if (cacheTextureForColor) { - if (locElement instanceof HTMLCanvasElement && !this._rectRotated) { - cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); - this.setTexture(locTexture); - } else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.setTexture(locTexture); - } - } - } - }; - } - _p.setTexture = function (texture) { - var locChildren = this._children; - var locDisplayedColor = this._displayedColor; - for (var i = 0; i < locChildren.length; i++) { - var selChild = locChildren[i]; - var childDColor = selChild._displayedColor; - if (this._textureForCanvas != selChild._texture && (childDColor.r !== locDisplayedColor.r || - childDColor.g !== locDisplayedColor.g || childDColor.b !== locDisplayedColor.b)) - continue; - selChild.texture = texture; - } - this._textureForCanvas = texture; - }; -} - - /** @expose */ _p.string; cc.defineGetterSetter(_p, "string", _p.getString, _p._setStringForSetter); diff --git a/cocos2d/labels/CCLabelBMFontRenderCmd.js b/cocos2d/labels/CCLabelBMFontRenderCmd.js new file mode 100644 index 0000000000..fac450205f --- /dev/null +++ b/cocos2d/labels/CCLabelBMFontRenderCmd.js @@ -0,0 +1,203 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + Use any of these editors to generate BMFonts: + http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) + http://www.n4te.com/hiero/hiero.jnlp (Free, Java) + http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) + http://www.angelcode.com/products/bmfont/ (Free, Windows only) + ****************************************************************************/ + +(function(){ + cc.LabelBMFont.CanvasRenderCmd = function(renderableObject){ + cc.SpriteBatchNode.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = false; + }; + + var proto = cc.LabelBMFont.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype); + proto.constructor = cc.LabelBMFont.CanvasRenderCmd; + + proto._updateTexture = function(fontChar, locTexture, rect){ + var node = this._node; + //var hasSprite = true; + if (!fontChar) { + fontChar = new cc.Sprite(); + + fontChar.initWithTexture(locTexture, rect, false); + fontChar._newTextureWhenChangeColor = true; + node.addChild(fontChar, 0, i); + } else { + fontChar.setTextureRect(rect, false, cc.size(0, 0)); + } + + // Apply label properties + fontChar.opacityModifyRGB = node._opacityModifyRGB; + // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on + cc.Node.prototype.updateDisplayedColor.call(fontChar, this._displayedColor); + cc.Node.prototype.updateDisplayedOpacity.call(fontChar, this._displayedOpacity); + + return fontChar; + }; + + proto._updateFntFileTexture = function(){ + var node = this._node; + node._originalTexture = node.texture; + }; + + proto.setTexture = function (texture) { + var node = this._node; + var locChildren = node._children; + var locDisplayedColor = node._displayedColor; + for (var i = 0; i < locChildren.length; i++) { + var selChild = locChildren[i]; + var cm = selChild._renderCmd; + var childDColor = cm._displayedColor; + if (this._texture != cm._texture && (childDColor.r !== locDisplayedColor.r || + childDColor.g !== locDisplayedColor.g || childDColor.b !== locDisplayedColor.b)) + continue; + selChild.texture = texture; + } + this._texture = texture; + }; + + if(cc.sys._supportCanvasNewBlendModes) + proto._changeTextureColor = function(){ + var node = this._node; + var locTexture = node.getTexture(); + if (locTexture && locTexture.getContentSize().width>0) { + var element = this._originalTexture.getHtmlElementObj(); + if(!element) + return; + var locElement = locTexture.getHtmlElementObj(); + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement && !node._rectRotated){ + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._displayedColor, textureRect, locElement); + node.setTexture(locTexture); + } else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._displayedColor, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.setTexture(locTexture); + } + } + }; + else + proto._changeTextureColor = function () { + var node = this._node; + var locElement, locTexture = node.getTexture(); + if (locTexture && locTexture.getContentSize().width > 0) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); + if (cacheTextureForColor) { + if (locElement instanceof HTMLCanvasElement && !this._rectRotated) { + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, null, locElement); + this.setTexture(locTexture); + } else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.setTexture(locTexture); + } + } + } + }; + + proto._updateChildrenDisplayedOpacity = function(locChild){ + cc.Node.prototype.updateDisplayedOpacity.call(locChild, this._displayedOpacity); + + }; + + proto._updateChildrenDisplayedColor = function(locChild){ + cc.Node.prototype.updateDisplayedColor.call(locChild, this._displayedColor); + }; + + proto._initBatchTexture = function(){}; + +})(); + + +(function(){ + cc.LabelBMFont.WebGLRenderCmd = function(renderableObject){ + cc.SpriteBatchNode.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = false; + }; + + var proto = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); + proto.constructor = cc.LabelBMFont.WebGLRenderCmd; + + proto._updateTexture = function(fontChar, locTexture, rect){ + var node = this._node; + //var hasSprite = true; + if (!fontChar) { + fontChar = new cc.Sprite(); + fontChar.initWithTexture(locTexture, rect, false); + fontChar._newTextureWhenChangeColor = true; + self.addChild(fontChar, 0, i); + } else { + // updating previous sprite + fontChar.setTextureRect(rect, false); + // restore to default in case they were modified + fontChar.visible = true; + } + + + // Apply label properties + fontChar.opacityModifyRGB = node._opacityModifyRGB; + // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on + fontChar.updateDisplayedColor(this._displayedColor); + fontChar.updateDisplayedOpacity(this._displayedOpacity); + + return fontChar; + }; + + proto._updateFntFileTexture = function(){}; + + proto.setTexture = cc.SpriteBatchNode.prototype.setTexture; + + proto._changeTextureColor = function(){}; + + proto._updateChildrenDisplayedOpacity = function(locChild){ + locChild.updateDisplayedOpacity(this._displayedOpacity); + }; + + proto._updateChildrenDisplayedOpacity = function(locChild){ + locChild.updateDisplayedColor(this._displayedColor); + }; + + proto._initBatchTexture = function(){ + var node = this._node; + var locTexture = node.textureAtlas.texture; + node._opacityModifyRGB = locTexture.hasPremultipliedAlpha(); + + var reusedChar = node._reusedChar = new cc.Sprite(); + reusedChar.initWithTexture(locTexture, cc.rect(0, 0, 0, 0), false); + reusedChar.batchNode = node; + }; + +})(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 5726f29dde..ca99c494db 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -146,7 +146,8 @@ "cocos2d/labels/CCLabelAtlas.js", "cocos2d/labels/CCLabelAtlasRenderCmd.js", - "cocos2d/labels/CCLabelBMFont.js" + "cocos2d/labels/CCLabelBMFont.js", + "cocos2d/labels/CCLabelBMFontRenderCmd.js" ], "menus" : [ "core", "actions", From 0f6f4ed22d7e68ae3551bccbb857dc2bd730ea9a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 22 Nov 2014 16:07:53 +0800 Subject: [PATCH 0945/1564] Issue 2416: Let template running on WebGL --- cocos2d/core/base-nodes/BaseNodesWebGL.js | 136 ------------------ cocos2d/core/base-nodes/CCNodeRenderCmd.js | 123 +++++++++++++++- cocos2d/core/layers/CCLayerRenderCmd.js | 35 +++-- .../sprites/CCSpriteBatchNodeRenderCmd.js | 2 +- cocos2d/core/sprites/CCSpriteRenderCmd.js | 17 ++- moduleConfig.json | 1 - tools/build.xml | 1 - 7 files changed, 153 insertions(+), 162 deletions(-) delete mode 100644 cocos2d/core/base-nodes/BaseNodesWebGL.js diff --git a/cocos2d/core/base-nodes/BaseNodesWebGL.js b/cocos2d/core/base-nodes/BaseNodesWebGL.js deleted file mode 100644 index 2db195d9d3..0000000000 --- a/cocos2d/core/base-nodes/BaseNodesWebGL.js +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -cc._tmp.WebGLCCNode = function () { - - /** - * CCNode - * @type {Object|Function|cc.Node|*} - * @private - */ - var _p = cc.Node.prototype; - - _p.setNodeDirty = function () { - var _t = this; - if(_t._transformDirty === false){ - _t._setNodeDirtyForCache(); - _t._renderCmdDiry = _t._transformDirty = _t._inverseDirty = true; - cc.renderer.pushDirtyNode(this); - } - }; - - _p._transformForRenderer = function (pMatrix) { - var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, - parentMatrix = pMatrix || (this._parent ? this._parent._stackMatrix : cc.current_stack.top); - - // Convert 3x3 into 4x4 matrix - var trans = this.getNodeToParentTransform(); - var t4x4Mat = t4x4.mat; - t4x4Mat[0] = trans.a; - t4x4Mat[4] = trans.c; - t4x4Mat[12] = trans.tx; - t4x4Mat[1] = trans.b; - t4x4Mat[5] = trans.d; - t4x4Mat[13] = trans.ty; - - // Update Z vertex manually - t4x4Mat[14] = this._vertexZ; - - //optimize performance for Javascript - cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); - - // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if (this._camera != null && !(this.grid != null && this.grid.isActive())) { - var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; - var translate = (apx !== 0.0 || apy !== 0.0); - if (translate){ - if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - apx = 0 | apx; - apy = 0 | apy; - } - //cc.kmGLTranslatef(apx, apy, 0); - var translation = new cc.kmMat4(); - cc.kmMat4Translation(translation, apx, apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); - - this._camera._locateForRenderer(stackMatrix); - - //cc.kmGLTranslatef(-apx, -apy, 0); - cc.kmMat4Translation(translation, -apx, -apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); - } else { - this._camera._locateForRenderer(stackMatrix); - } - } - - this._renderCmdDiry = false; - if(!this._children || this._children.length === 0) - return; - var i, len, locChildren = this._children; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._transformForRenderer(stackMatrix); - } - }; - - _p.transform = function () { - var _t = this; - //optimize performance for javascript - var t4x4 = _t._transform4x4, topMat4 = cc.current_stack.top; - - // Convert 3x3 into 4x4 matrix - var trans = _t.getNodeToParentTransform(); - var t4x4Mat = t4x4.mat; - t4x4Mat[0] = trans.a; - t4x4Mat[4] = trans.c; - t4x4Mat[12] = trans.tx; - t4x4Mat[1] = trans.b; - t4x4Mat[5] = trans.d; - t4x4Mat[13] = trans.ty; - - // Update Z vertex manually - t4x4Mat[14] = _t._vertexZ; - - //optimize performance for Javascript - cc.kmMat4Multiply(topMat4, topMat4, t4x4); - - // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if (_t._camera != null && !(_t.grid != null && _t.grid.isActive())) { - var apx = _t._anchorPointInPoints.x, apy = _t._anchorPointInPoints.y; - var translate = (apx !== 0.0 || apy !== 0.0); - if (translate){ - if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - apx = 0 | apx; - apy = 0 | apy; - } - cc.kmGLTranslatef(apx, apy, 0); - _t._camera.locate(); - cc.kmGLTranslatef(-apx, -apy, 0); - } else { - _t._camera.locate(); - } - } - }; -}; diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index 3667c99ef4..28080d24e1 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -110,6 +110,33 @@ cc.Node.RenderCmd.prototype = { if(this._node && this._node._parent && this._node._parent._renderCmd) return this._node._parent._renderCmd; return null; + }, + + _syncDisplayColor : function (parentColor) { + var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; + if (parentColor === undefined) { + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + }, + + _syncDisplayOpacity : function (parentOpacity) { + var node = this._node; + if (parentOpacity === undefined) { + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; } }; @@ -564,11 +591,46 @@ cc.Node.RenderCmd.prototype = { return this._transform; }; -//TODO + proto.updateStatus = function () { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._updateDisplayColor() + } + + if (locFlag & flags.opacityDirty) { + //update the opacity + this._updateDisplayOpacity(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(this.getParentRenderCmd(), true); + } + }; + + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._syncDisplayColor() + } + + if (locFlag & flags.opacityDirty) { + //update the opacity + this._syncDisplayOpacity(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } + }; + proto.visit = function (parentCmd) { var _t = this, node = this._node; // quick return if not visible - if (!_t._visible) + if (!node._visible) return; if (node._parent && node._parent._renderCmd) @@ -582,10 +644,10 @@ cc.Node.RenderCmd.prototype = { currentStack.top = _t._stackMatrix; _t._syncStatus(parentCmd); - var locChildren = _t._children; + var locChildren = node._children; if (locChildren && locChildren.length > 0) { var childLen = locChildren.length; - _t.sortAllChildren(); + node.sortAllChildren(); // draw children zOrder < 0 for (i = 0; i < childLen; i++) { if (locChildren[i] && locChildren[i]._localZOrder < 0) @@ -607,8 +669,57 @@ cc.Node.RenderCmd.prototype = { currentStack.top = currentStack.stack.pop(); }; - proto.transform = function () { - + proto.transform = function (parentCmd, recursive) { + var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, node = this._node; + parentCmd = parentCmd || this.getParentRenderCmd(); + var parentMatrix = (parentCmd ? parentCmd._stackMatrix : cc.current_stack.top); + + // Convert 3x3 into 4x4 matrix + var trans = this.getNodeToParentTransform(); + var t4x4Mat = t4x4.mat; + t4x4Mat[0] = trans.a; + t4x4Mat[4] = trans.c; + t4x4Mat[12] = trans.tx; + t4x4Mat[1] = trans.b; + t4x4Mat[5] = trans.d; + t4x4Mat[13] = trans.ty; + + // Update Z vertex manually + t4x4Mat[14] = node._vertexZ; + + //optimize performance for Javascript + cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); + + // XXX: Expensive calls. Camera should be integrated into the cached affine matrix + if (node._camera != null && !(node.grid != null && node.grid.isActive())) { + var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; + var translate = (apx !== 0.0 || apy !== 0.0); + if (translate){ + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + apx = 0 | apx; + apy = 0 | apy; + } + //cc.kmGLTranslatef(apx, apy, 0); + var translation = new cc.kmMat4(); + cc.kmMat4Translation(translation, apx, apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + + node._camera._locateForRenderer(stackMatrix); + + //cc.kmGLTranslatef(-apx, -apy, 0); + cc.kmMat4Translation(translation, -apx, -apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + } else { + node._camera._locateForRenderer(stackMatrix); + } + } + this._renderCmdDiry = false; + if(!recursive || !node._children || node._children.length === 0) + return; + var i, len, locChildren = node._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(this, recursive); + } }; proto.setShaderProgram = function (shaderProgram) { diff --git a/cocos2d/core/layers/CCLayerRenderCmd.js b/cocos2d/core/layers/CCLayerRenderCmd.js index 2f6f919f22..54b6f5f78b 100644 --- a/cocos2d/core/layers/CCLayerRenderCmd.js +++ b/cocos2d/core/layers/CCLayerRenderCmd.js @@ -539,9 +539,29 @@ this._bindLayerVerticesBufferData(); }; + proto._updateDisplayColor = function(parentColor){ + cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); + this._updateColor(); + }; + + proto._updateDisplayOpacity= function(parentOpacity){ + cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); + this._updateColor(); + }; + + proto._syncDisplayColor = function(parentColor){ + cc.Node.WebGLRenderCmd.prototype._syncDisplayColor.call(this, parentColor); + this._updateColor(); + }; + + proto._syncDisplayOpacity = function(parentOpacity){ + cc.Node.WebGLRenderCmd.prototype._syncDisplayOpacity.call(this, parentOpacity); + this._updateColor(); + }; + proto._updateColor = function(){ - var locDisplayedColor = this._displayedColor; - var locDisplayedOpacity = this._displayedOpacity, locSquareColors = this._squareColors; + var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity, + locSquareColors = this._squareColors; for (var i = 0; i < 4; i++) { locSquareColors[i].r = locDisplayedColor.r; locSquareColors[i].g = locDisplayedColor.g; @@ -564,8 +584,7 @@ glContext.bufferData(glContext.ARRAY_BUFFER, this._squareColorsAB, glContext.STATIC_DRAW); }; - proto.updateBlendFunc = function(blendFunc){ - }; + proto.updateBlendFunc = function(blendFunc){}; })(); /** @@ -580,8 +599,8 @@ proto.constructor = cc.LayerGradient.WebGLRenderCmd; proto._updateColor = function(){ - var _t = this; - var locAlongVector = _t._alongVector; + var _t = this, node = this._node; + var locAlongVector = node._alongVector; var h = cc.pLength(locAlongVector); if (h === 0) return; @@ -589,12 +608,12 @@ var c = Math.sqrt(2.0), u = cc.p(locAlongVector.x / h, locAlongVector.y / h); // Compressed Interpolation mode - if (_t._compressedInterpolation) { + if (node._compressedInterpolation) { var h2 = 1 / ( Math.abs(u.x) + Math.abs(u.y) ); u = cc.pMult(u, h2 * c); } - var opacityf = _t._displayedOpacity / 255.0, node = this._node; + var opacityf = _t._displayedOpacity / 255.0; var locDisplayedColor = _t._displayedColor, locEndColor = node._endColor; var S = { r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: node._startOpacity * opacityf}; var E = {r: locEndColor.r, g: locEndColor.g, b: locEndColor.b, a: node._endOpacity * opacityf}; diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js index bcf2ec444c..93f6040e2f 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js @@ -38,7 +38,7 @@ proto.initWithTexture = function(texture, capacity){ this._originalTexture = texture; - this._textureForCanvas = texture; + this._texture = texture; }; proto.insertQuad = function(){}; diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index 638136667d..223b2931d6 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -634,7 +634,6 @@ proto._updateForSetSpriteFrame = function () {}; proto._spriteFrameLoadedCallback = function (spriteFrame) { - this.setNodeDirty(true); this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); this.dispatchEvent("load"); }; @@ -941,15 +940,15 @@ if (locTexture) { if (locTexture._isLoaded) { - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); //optimize performance for javascript cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); if (this._quadDirty) { gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); this._quadDirty = false; @@ -960,7 +959,7 @@ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); } } else { - _t._shaderProgram.use(); + this._shaderProgram.use(); _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); @@ -968,10 +967,10 @@ cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadWebBuffer); - if (_t._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, _t._quad.arrayBuffer, gl.STATIC_DRAW); - _t._quadDirty = false; + gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); + if (this._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.STATIC_DRAW); + this._quadDirty = false; } gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); diff --git a/moduleConfig.json b/moduleConfig.json index 5726f29dde..339f6140d8 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -74,7 +74,6 @@ "cocos2d/core/renderer/RendererCanvas.js", "cocos2d/core/renderer/RendererWebGL.js", - "cocos2d/core/base-nodes/BaseNodesWebGL.js", "cocos2d/core/base-nodes/BaseNodesPropertyDefine.js", "cocos2d/core/base-nodes/CCNode.js", "cocos2d/core/base-nodes/CCNodeRenderCmd.js", diff --git a/tools/build.xml b/tools/build.xml index e4f7597a1e..fd39a423f2 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -37,7 +37,6 @@ - From 933b387185a23b9697d43e25353c03439f54071c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 24 Nov 2014 09:28:51 +0800 Subject: [PATCH 0946/1564] Issue #2416: refactoring cc.AtlasNode and cc.LabelAtlas --- cocos2d/core/base-nodes/CCAtlasNode.js | 27 +----- .../core/base-nodes/CCAtlasNodeRenderCmd.js | 95 ++++++++++--------- cocos2d/labels/CCLabelAtlas.js | 28 ++---- cocos2d/labels/CCLabelAtlasRenderCmd.js | 47 ++++----- cocos2d/progress-timer/CCProgressTimer.js | 10 -- .../CCProgressTimerRenderCmd.js | 3 - 6 files changed, 79 insertions(+), 131 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 8db30a943e..290822e728 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -68,6 +68,8 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ _ignoreContentScaleFactor: false, _className: "AtlasNode", + _textureForCanvas: null, + /** *

    Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.

    * @param {String} tile @@ -79,9 +81,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ cc.Node.prototype.ctor.call(this); this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; this._ignoreContentScaleFactor = false; - itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender); - }, _createRenderCmd: function(){ @@ -120,7 +120,7 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ setOpacityModifyRGB: function (value) { var oldColor = this.color; this._opacityModifyRGB = value; - this.color = oldColor; + this.setColor(oldColor); }, /** @@ -191,12 +191,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ this.quadsToDraw = quadsToDraw; }, - _textureForCanvas: null, - _originalTexture: null, - - _uniformColor: null, - _colorF32Array: null, - /** * Initializes an cc.AtlasNode object with an atlas texture file name, the width, the height of each tile and the quantity of tiles to render * @function @@ -271,21 +265,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ this._renderCmd.setTexture(texture); }, - _calculateMaxItems: function(){ - this._renderCmd._calculateMaxItems(); - }, - - _updateBlendFunc: function () { - if (!this.textureAtlas.texture.hasPremultipliedAlpha()) { - this._blendFunc.src = cc.SRC_ALPHA; - this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - } - }, - - _updateOpacityModifyRGB: function () { - this._opacityModifyRGB = this.textureAtlas.texture.hasPremultipliedAlpha(); - }, - _setIgnoreContentScaleFactor: function (ignoreContentScaleFactor) { this._ignoreContentScaleFactor = ignoreContentScaleFactor; } diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js index 489bd5f6a2..50baa6681e 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js @@ -27,10 +27,11 @@ */ (function(){ cc.AtlasNode.CanvasRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = false; this._colorUnmodified = cc.color.WHITE; - + this._originalTexture = null; + this._texture = null; }; var proto = cc.AtlasNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); @@ -42,35 +43,24 @@ node._itemHeight = tileHeight; node._opacityModifyRGB = true; - node._originalTexture = texture; - if (!node._originalTexture) { + this._originalTexture = texture; + if (!this._originalTexture) { cc.log(cc._LogInfos.AtlasNode__initWithTexture); return false; } - node._textureForCanvas = node._originalTexture; - node._calculateMaxItems(); + this._texture = this._originalTexture; + this._calculateMaxItems(); node.quadsToDraw = itemsToRender; return true; }; - proto.draw = cc.Node.prototype.draw; - proto.setColor = function(color3){ var node = this._node; var locRealColor = node._realColor; if ((locRealColor.r == color3.r) && (locRealColor.g == color3.g) && (locRealColor.b == color3.b)) return; - var temp = cc.color(color3.r, color3.g, color3.b); this._colorUnmodified = color3; - - if (node._opacityModifyRGB) { - var locDisplayedOpacity = this._displayedOpacity; - temp.r = temp.r * locDisplayedOpacity / 255; - temp.g = temp.g * locDisplayedOpacity / 255; - temp.b = temp.b * locDisplayedOpacity / 255; - } -// cc.Node.prototype.setColor.call(node, color3); this._changeTextureColor(); }; @@ -78,8 +68,8 @@ proto._changeTextureColor = function(){ var node = this._node; var locTexture = node.getTexture(); - if (locTexture && node._originalTexture) { - var element = node._originalTexture.getHtmlElementObj(); + if (locTexture && this._originalTexture) { + var element = this._originalTexture.getHtmlElementObj(); if(!element) return; var locElement = locTexture.getHtmlElementObj(); @@ -99,11 +89,11 @@ proto._changeTextureColor = function(){ var node = this._node; var locElement, locTexture = node.getTexture(); - if (locTexture && node._originalTexture) { + if (locTexture && this._originalTexture) { locElement = locTexture.getHtmlElementObj(); if (!locElement) return; - var element = node._originalTexture.getHtmlElementObj(); + var element = this._originalTexture.getHtmlElementObj(); var cacheTextureForColor = cc.textureCache.getTextureColors(element); if (cacheTextureForColor) { var textureRect = cc.rect(0, 0, element.width, element.height); @@ -130,16 +120,16 @@ }; proto.getTexture = function(){ - return this._node._textureForCanvas; + return this._texture; }; proto.setTexture = function (texture) { - this._node._textureForCanvas = texture; + this._texture = texture; }; proto._calculateMaxItems = function(){ var node = this._node; - var selTexture = node.texture; + var selTexture = this._texture; var size = selTexture.getContentSize(); node._itemsPerColumn = 0 | (size.height / node._itemHeight); @@ -154,22 +144,38 @@ cc.AtlasNode.WebGLRenderCmd = function(renderableObject){ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; + this._textureAtlas = null; this._colorUnmodified = cc.color.WHITE; + this._colorF32Array = null; + this._uniformColor = null; }; var proto = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.AtlasNode.WebGLRenderCmd; + + proto._updateBlendFunc = function () { + var node = this._node; + if (!this._textureAtlas.texture.hasPremultipliedAlpha()) { + node._blendFunc.src = cc.SRC_ALPHA; + node._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + } + }; + + proto._updateOpacityModifyRGB = function () { + this._node._opacityModifyRGB = this._textureAtlas.texture.hasPremultipliedAlpha(); + }; + proto.rendering = function (ctx) { var context = ctx || cc._renderContext, node = this._node; - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - if (node._uniformColor && node._colorF32Array) { - context.uniform4fv(node._uniformColor, node._colorF32Array); - node.textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); + if (this._uniformColor && this._colorF32Array) { + context.uniform4fv(this._uniformColor, this._colorF32Array); + this._textureAtlas.drawNumberOfQuads(node.quadsToDraw, 0); } }; @@ -184,23 +190,23 @@ node._blendFunc.dst = cc.BLEND_DST; var locRealColor = node._realColor; - node._colorF32Array = new Float32Array([locRealColor.r / 255.0, locRealColor.g / 255.0, locRealColor.b / 255.0, node._realOpacity / 255.0]); - node.textureAtlas = new cc.TextureAtlas(); - node.textureAtlas.initWithTexture(texture, itemsToRender); + this._colorF32Array = new Float32Array([locRealColor.r / 255.0, locRealColor.g / 255.0, locRealColor.b / 255.0, node._realOpacity / 255.0]); + this._textureAtlas = new cc.TextureAtlas(); + this._textureAtlas.initWithTexture(texture, itemsToRender); - if (!node.textureAtlas) { + if (!this._textureAtlas) { cc.log(cc._LogInfos.AtlasNode__initWithTexture); return false; } - node._updateBlendFunc(); - node._updateOpacityModifyRGB(); - node._calculateMaxItems(); + this._updateBlendFunc(); + this._updateOpacityModifyRGB(); + this._calculateMaxItems(); node.quadsToDraw = itemsToRender; //shader stuff - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); - node._uniformColor = cc._renderContext.getUniformLocation(node.shaderProgram.getProgram(), "u_color"); + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); + this._uniformColor = cc._renderContext.getUniformLocation(node.shaderProgram.getProgram(), "u_color"); return true; }; @@ -243,19 +249,18 @@ }; proto.getTexture = function(){ - return this._node.textureAtlas.texture; + return this._textureAtlas.texture; }; proto.setTexture = function(texture){ - var node = this._node; - node.textureAtlas.texture = texture; - node._updateBlendFunc(); - node._updateOpacityModifyRGB(); + this._textureAtlas.texture = texture; + this._updateBlendFunc(); + this._updateOpacityModifyRGB(); }; proto._calculateMaxItems = function(){ var node = this._node; - var selTexture = node.texture; + var selTexture = this._texture; var size = selTexture.getContentSize(); if (node._ignoreContentScaleFactor) size = selTexture.getContentSizeInPixels(); diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index bc9f3905af..ff93a99112 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -44,9 +44,7 @@ * var myLabel = new cc.LabelAtlas('Text to display', 'CharMapFile.plist‘); */ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ - //property String is Getter and Setter - // string to render _string: null, // the first char in the charmap @@ -74,13 +72,10 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ this._cascadeOpacityEnabled = true; this._cascadeColorEnabled = true; - - charMapFile && cc.LabelAtlas.prototype.initWithString.call(this, strText, charMapFile, itemWidth, itemHeight, startCharMap); }, _createRenderCmd: function(){ - if(cc._renderType === cc._RENDER_TYPE_WEBGL) return new cc.LabelAtlas.WebGLRenderCmd(this); else @@ -180,19 +175,6 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ return this._string; }, - /** - * draw the label - */ - draw: function (ctx) { - cc.AtlasNode.prototype.draw.call(this, ctx); - if (cc.LABELATLAS_DEBUG_DRAW) { - var s = this.size; - var vertices = [cc.p(0, 0), cc.p(s.width, 0), - cc.p(s.width, s.height), cc.p(0, s.height)]; - cc._drawingUtil.drawPoly(vertices, 4, true); - } - }, - addChild: function(child, localZOrder, tag){ this._renderCmd._addChild(child); cc.Node.prototype.addChild.call(this, child, localZOrder, tag); @@ -212,7 +194,17 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ * @param {String} label */ setString: function(label){ + var node = this._node; + label = String(label); + var len = label.length; + node._string = label; + this.width = len * node._itemWidth; + this.height = node._itemHeight; + this._renderCmd.setString(label); + + this.updateAtlasValues(); + this.quadsToDraw = len; }, /** diff --git a/cocos2d/labels/CCLabelAtlasRenderCmd.js b/cocos2d/labels/CCLabelAtlasRenderCmd.js index b329031694..c0aaed9f7d 100644 --- a/cocos2d/labels/CCLabelAtlasRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasRenderCmd.js @@ -23,7 +23,6 @@ ****************************************************************************/ (function(){ - cc.LabelAtlas.CanvasRenderCmd = function(renderableObject){ cc.AtlasNode.CanvasRenderCmd.call(this, renderableObject); this._needDraw = false; @@ -32,16 +31,11 @@ var proto = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); proto.constructor = cc.LabelAtlas.CanvasRenderCmd; - proto.rendering = function(){ - var node = this._node; - node.draw(); - }; - proto.updateAtlasValues = function(){ var node = this._node; var locString = node._string || ""; var n = locString.length; - var texture = node.texture; + var texture = this._texture; var locItemWidth = node._itemWidth , locItemHeight = node._itemHeight; //needn't multiply cc.contentScaleFactor(), because sprite's draw will do this for (var i = 0; i < n; i++) { @@ -78,23 +72,15 @@ proto.setString = function(label){ var node = this._node; - label = String(label); - var len = label.length; - node._string = label; - this.width = len * node._itemWidth; - this.height = node._itemHeight; if (node._children) { var locChildren = node._children; - len = locChildren.length; + var len = locChildren.length; for (var i = 0; i < len; i++) { var child = locChildren[i]; if (child && !child._lateChild) child.visible = false; } } - - this.updateAtlasValues(); - this.quadsToDraw = len; }; proto._addChild = function(){ @@ -103,15 +89,23 @@ })(); (function(){ - - cc.LabelAtlas.WebGLRenderCmd = function(renderableObject){ - cc.AtlasNode.WebGLRenderCmd.call(this, renderableObject); + cc.LabelAtlas.WebGLRenderCmd = function(renderable){ + cc.AtlasNode.WebGLRenderCmd.call(this, renderable); this._needDraw = false; }; var proto = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype); proto.constructor = cc.LabelAtlas.WebGLRenderCmd; - proto.rendering = function(){}; + + proto.rendering = function(){ + cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, ctx); + if (cc.LABELATLAS_DEBUG_DRAW) { + var s = this.size; + var vertices = [cc.p(0, 0), cc.p(s.width, 0), + cc.p(s.width, s.height), cc.p(0, s.height)]; + cc._drawingUtil.drawPoly(vertices, 4, true); + } + }; proto.updateAtlasValues = function(){ var node = this._node; @@ -189,21 +183,12 @@ }; proto.setString = function(label){ - var node = this._node; - label = String(label); - var len = label.length; + var len = label.length, node = this._node; if (len > node.textureAtlas.totalQuads) node.textureAtlas.resizeCapacity(len); - - node._string = label; - node.width = len * node._itemWidth; - node.height = node._itemHeight; - - node.updateAtlasValues(); - node.quadsToDraw = len; }; - proto.setOpacity = function(){ + proto.setOpacity = function(opacity){ if (this._opacity !== opacity) cc.AtlasNode.prototype.setOpacity.call(this, opacity); }; diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 0755faad4a..dd06b870e7 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -181,7 +181,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._sprite = null; this.sprite && this._renderCmd.initWithSprite(this.sprite); - }, /** @@ -297,15 +296,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._renderCmd.initWithSprite(sprite); }, - /** - * Stuff gets drawn here - * @function - * @param {CanvasRenderingContext2D} ctx - */ - draw: function(ctx){ - this._renderCmd.draw(ctx); - }, - /** *

    * Update does the work of mapping the texture onto the triangles
    diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js index fa7193f047..660723e3ad 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -26,7 +26,6 @@ * cc.ProgressTimer's rendering objects of Canvas */ (function(){ - cc.ProgressTimer.CanvasRenderCmd = function(renderableObject){ cc.Node.CanvasRenderCmd.call(this, renderableObject); this._needDraw = true; @@ -167,8 +166,6 @@ return true; }; - proto.draw = function(){}; - proto._updateProgress = function(){ var node = this._node; var locSprite = node._sprite; From af1a6e267dd0c5bf889605cac31c3a5571c18c37 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 24 Nov 2014 10:29:55 +0800 Subject: [PATCH 0947/1564] Issue #2416: Fixed a bug that LabelBMFont does not display --- cocos2d/labels/CCLabelBMFont.js | 2 +- cocos2d/labels/CCLabelBMFontRenderCmd.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index c6142c8c03..7495a300a9 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -513,7 +513,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var fontChar = self.getChildByTag(i); - fontChar = this._renderCmd._updateTexture(fontChar, locTexture, rect); + fontChar = this._renderCmd._updateTexture(fontChar, locTexture, rect, i, key); var yOffset = locCfg.commonHeight - fontDef.yOffset; var fontPos = cc.p(nextFontPositionX + fontDef.xOffset + fontDef.rect.width * 0.5 + kerningAmount, diff --git a/cocos2d/labels/CCLabelBMFontRenderCmd.js b/cocos2d/labels/CCLabelBMFontRenderCmd.js index fac450205f..587823228f 100644 --- a/cocos2d/labels/CCLabelBMFontRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontRenderCmd.js @@ -39,7 +39,7 @@ var proto = cc.LabelBMFont.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype); proto.constructor = cc.LabelBMFont.CanvasRenderCmd; - proto._updateTexture = function(fontChar, locTexture, rect){ + proto._updateTexture = function(fontChar, locTexture, rect, i, key){ var node = this._node; //var hasSprite = true; if (!fontChar) { @@ -49,7 +49,14 @@ fontChar._newTextureWhenChangeColor = true; node.addChild(fontChar, 0, i); } else { - fontChar.setTextureRect(rect, false, cc.size(0, 0)); + if (key === 32) { + fontChar.setTextureRect(rect, false, cc.size(0, 0)); + } else { + // updating previous sprite + fontChar.setTextureRect(rect, false); + // restore to default in case they were modified + fontChar.visible = true; + } } // Apply label properties @@ -151,14 +158,14 @@ var proto = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); proto.constructor = cc.LabelBMFont.WebGLRenderCmd; - proto._updateTexture = function(fontChar, locTexture, rect){ + proto._updateTexture = function(fontChar, locTexture, rect, i){ var node = this._node; //var hasSprite = true; if (!fontChar) { fontChar = new cc.Sprite(); fontChar.initWithTexture(locTexture, rect, false); fontChar._newTextureWhenChangeColor = true; - self.addChild(fontChar, 0, i); + node.addChild(fontChar, 0, i); } else { // updating previous sprite fontChar.setTextureRect(rect, false); From c666dc422bfbc32d451a9845b85549442fe6289d Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Mon, 24 Nov 2014 16:43:14 +0800 Subject: [PATCH 0948/1564] issue #1108: comment out the function of restart --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index f2b4700870..65e63c47b5 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -2050,7 +2050,7 @@ cc.game = /** @lends cc.game# */{ * Run game. */ restart: function () { - window.location.href = window.location.href; + //window.location.href = window.location.href; }, /** From 767203ff2666a60585025bd3cd39c0cc0ad718a6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 24 Nov 2014 18:14:52 +0800 Subject: [PATCH 0949/1564] Issue #2416: refactor cc.ParticleSystem and cc.ProgressTimer --- .../core/base-nodes/CCAtlasNodeRenderCmd.js | 2 +- cocos2d/core/support/CCPointExtension.js | 2 +- cocos2d/labels/CCLabelAtlas.js | 7 +- cocos2d/particle/CCParticleBatchNode.js | 40 +- .../particle/CCParticleBatchNodeRenderCmd.js | 49 +-- cocos2d/particle/CCParticleSystem.js | 369 +++------------- cocos2d/particle/CCParticleSystemRenderCmd.js | 407 ++++++++++-------- cocos2d/progress-timer/CCProgressTimer.js | 246 ++--------- .../CCProgressTimerRenderCmd.js | 386 ++++++++++------- 9 files changed, 584 insertions(+), 924 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js index 50baa6681e..341ce7febb 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js @@ -260,7 +260,7 @@ proto._calculateMaxItems = function(){ var node = this._node; - var selTexture = this._texture; + var selTexture = this._textureAtlas.texture; var size = selTexture.getContentSize(); if (node._ignoreContentScaleFactor) size = selTexture.getContentSizeInPixels(); diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/support/CCPointExtension.js index fb3442fa05..3ec17e3d2e 100644 --- a/cocos2d/core/support/CCPointExtension.js +++ b/cocos2d/core/support/CCPointExtension.js @@ -487,7 +487,7 @@ cc.pMultIn = function(point, floatVar) { /** * subtracts one point from another (inplace) * @param {cc.Point} v1 - * @param {cc.Point{ v2 + * @param {cc.Point} v2 */ cc.pSubIn = function(v1, v2) { v1.x -= v2.x; diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index ff93a99112..b0f273cd06 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -194,13 +194,10 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ * @param {String} label */ setString: function(label){ - var node = this._node; label = String(label); var len = label.length; - node._string = label; - this.width = len * node._itemWidth; - this.height = node._itemHeight; - + this._string = label; + this.setContentSize(len * this._itemWidth, this._itemHeight); this._renderCmd.setString(label); this.updateAtlasValues(); diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 16ccd1910a..69809898d1 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -72,8 +72,6 @@ cc.PARTICLE_DEFAULT_CAPACITY = 500; */ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ textureAtlas:null, - - TextureProtocol:true, //the blend function used for drawing the quads _blendFunc:null, _className:"ParticleBatchNode", @@ -101,10 +99,13 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ } else if (fileImage instanceof cc.Texture2D) { this.initWithTexture(fileImage, capacity); } - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this._renderCmd = new cc.ParticleBatchNode.WebGLRenderCmd(this); + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.ParticleBatchNode.CanvasRenderCmd(this); else - this._renderCmd = new cc.ParticleBatchNode.CanvasRenderCmd(this); + return new cc.ParticleBatchNode.WebGLRenderCmd(this); }, /** @@ -142,7 +143,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ * @return {Boolean} */ init:function (fileImage, capacity) { - var tex = cc.TextureCache.getInstance().addImage(fileImage); + var tex = cc.textureCache.addImage(fileImage); return this.initWithTexture(tex, capacity); }, @@ -332,18 +333,9 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ this.textureAtlas._setDirty(true); }, - /** - * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function - * @function - * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context - */ - draw:function (ctx) { - this._renderCmd.draw(); - }, - /** * returns the used texture - * @return {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} + * @return {cc.Texture2D} */ getTexture:function () { return this.textureAtlas.texture; @@ -351,7 +343,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ /** * sets a new texture. it will be retained - * @param {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture + * @param {cc.Texture2D} texture */ setTexture:function (texture) { this.textureAtlas.texture = texture; @@ -377,7 +369,6 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ this._blendFunc.src = src; this._blendFunc.src = dst; } - }, /** @@ -385,18 +376,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ * @return {cc.BlendFunc} */ getBlendFunc:function () { - return {src:this._blendFunc.src, dst:this._blendFunc.dst}; - }, - - // override visit. - // Don't call visit on it's children - /** - * Recursive method that visit its children and draw them - * @function - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx - */ - visit:function (ctx) { - this._renderCmd.visit(); + return new cc.BlendFunc(this._blendFunc.src, this._blendFunc.dst); }, _updateAllAtlasIndexes:function () { diff --git a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js index 3dd112eb74..f006972ccd 100644 --- a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js +++ b/cocos2d/particle/CCParticleBatchNodeRenderCmd.js @@ -22,31 +22,27 @@ THE SOFTWARE. ****************************************************************************/ -/** - * cc.ParticleBatchNode's rendering objects of Canvas - */ (function(){ - cc.ParticleBatchNode.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; + /** + * cc.ParticleBatchNode's rendering objects of Canvas + */ + cc.ParticleBatchNode.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = false; }; var proto = cc.ParticleBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); proto.constructor = cc.ParticleBatchNode.CanvasRenderCmd; - proto.rendering = - proto._initWithTexture = - proto.draw = - proto.visit = function(){}; + proto._initWithTexture = function(){}; })(); -/** - * cc.ParticleBatchNode's rendering objects of WebGL - */ (function(){ - - cc.ParticleBatchNode.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); + /** + * cc.ParticleBatchNode's rendering objects of WebGL + */ + cc.ParticleBatchNode.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); this._needDraw = true; }; @@ -58,27 +54,14 @@ if (_t.textureAtlas.totalQuads == 0) return; - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); _t.textureAtlas.drawQuads(); }; proto._initWithTexture = function(){ - this._node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - }; - - proto.draw = function(){ - var ndoe = this._node; - //cc.PROFILER_STOP("CCParticleBatchNode - draw"); - if (ndoe.textureAtlas.totalQuads == 0) - return; - - cc.nodeDrawSetup(ndoe); - cc.glBlendFuncForParticle(ndoe._blendFunc.src, ndoe._blendFunc.dst); - ndoe.textureAtlas.drawQuads(); - - //cc.PROFILER_STOP("CCParticleBatchNode - draw"); + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; proto.visit = function(){ @@ -98,7 +81,7 @@ cc.kmMat4Assign(node._stackMatrix, currentStack.top); currentStack.top = node._stackMatrix; - node.transform(ctx); + node._syncStatus(ctx); //this.draw(ctx); cc.renderer.pushRenderCommand(this); diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 6623f0642c..81bfc0975f 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -211,11 +211,11 @@ cc.Particle.TemporaryPoints = [ * emitter.startSpin = 0; */ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ + _className:"ParticleSystem", //***********variables************* _plistFile: "", //! time elapsed since the start of the system (in seconds) _elapsed: 0, - _dontTint: false, // Different modes @@ -223,7 +223,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ modeA: null, //! Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode) modeB: null, - _className:"ParticleSystem", //private POINTZERO for ParticleSystem _pointZeroForParticle: cc.p(0, 0), @@ -246,11 +245,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ _transformSystemDirty: false, _allocatedParticles: 0, - //drawMode - drawMode: null, - - //shape type - shapeType: null, _isActive: false, particleCount: 0, duration: 0, @@ -318,8 +312,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ this._transformSystemDirty = false; this._allocatedParticles = 0; - this.drawMode = cc.ParticleSystem.SHAPE_MODE; - this.shapeType = cc.ParticleSystem.BALL_SHAPE; this._isActive = false; this.particleCount = 0; this.duration = 0; @@ -362,21 +354,12 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ }, /** - * initializes the indices for the vertices + * This is a hack function for performance, it's only available on Canvas mode.
    + * It's very expensive to change color on Canvas mode, so if set it to true, particle system will ignore the changing color operation. + * @param {boolean} ignore */ - initIndices:function () { - var locIndices = this._renderCmd._indices; - for (var i = 0, len = this._totalParticles; i < len; ++i) { - var i6 = i * 6; - var i4 = i * 4; - locIndices[i6 + 0] = i4 + 0; - locIndices[i6 + 1] = i4 + 1; - locIndices[i6 + 2] = i4 + 2; - - locIndices[i6 + 5] = i4 + 1; - locIndices[i6 + 4] = i4 + 2; - locIndices[i6 + 3] = i4 + 3; - } + ignoreColor: function(ignore){ + this._dontTint = ignore; }, /** @@ -386,9 +369,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {cc.Rect} pointRect */ initTexCoordsWithRect:function (pointRect) { - this._renderCmd.initTexCoordsWithRect(pointRect); - }, /** @@ -404,38 +385,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {cc.ParticleBatchNode} batchNode */ setBatchNode:function (batchNode) { - if (this._batchNode != batchNode) { - var oldBatch = this._batchNode; - - this._batchNode = batchNode; //weak reference - - if (batchNode) { - var locParticles = this._particles; - for (var i = 0; i < this._totalParticles; i++) - locParticles[i].atlasIndex = i; - } - - // NEW: is self render ? - if (!batchNode) { - this._allocMemory(); - this.initIndices(); - this.setTexture(oldBatch.getTexture()); - //if (cc.TEXTURE_ATLAS_USE_VAO) - // this._setupVBOandVAO(); - //else - this._setupVBO(); - } else if (!oldBatch) { - // OLD: was it self render cleanup ? - // copy current state to batch - this._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._renderCmd._quads, this.atlasIndex); - - //delete buffer - cc._renderContext.deleteBuffer(this._buffersVBO[1]); //where is re-bindBuffer code? - - //if (cc.TEXTURE_ATLAS_USE_VAO) - // glDeleteVertexArrays(1, this._VAOname); - } - } + this._renderCmd.setBatchNode(batchNode); }, /** @@ -455,39 +405,35 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ }, /** - * Return DrawMode of ParticleSystem + * Return DrawMode of ParticleSystem (Canvas Mode only) * @return {Number} */ getDrawMode:function () { - return this.drawMode; + return this._renderCmd.getDrawMode(); }, /** - * DrawMode of ParticleSystem setter + * DrawMode of ParticleSystem setter (Canvas Mode only) * @param {Number} drawMode */ setDrawMode:function (drawMode) { - this.drawMode = drawMode; - if(this._renderCmd) - this._renderCmd._drawMode = drawMode; + this._renderCmd.setDrawMode(drawMode); }, /** - * Return ShapeType of ParticleSystem + * Return ShapeType of ParticleSystem (Canvas Mode only) * @return {Number} */ getShapeType:function () { - return this.shapeType; + return this._renderCmd.getShapeType(); }, /** - * ShapeType of ParticleSystem setter + * ShapeType of ParticleSystem setter (Canvas Mode only) * @param {Number} shapeType */ setShapeType:function (shapeType) { - this.shapeType = shapeType; - if(this._renderCmd) - this._renderCmd._shapeType = shapeType; + this._renderCmd.setShapeType(shapeType); }, /** @@ -535,7 +481,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @return {cc.Point | Object} */ getSourcePosition:function () { - return {x:this._sourcePosition.x, y:this._sourcePosition.y}; + return {x: this._sourcePosition.x, y: this._sourcePosition.y}; }, /** @@ -1152,7 +1098,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {Number} tp totalParticles */ setTotalParticles:function (tp) { - this._renderCmd.setTotalParticles(); + this._renderCmd.setTotalParticles(tp); }, /** @@ -1168,6 +1114,9 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {cc.Texture2D } texture */ setTexture:function (texture) { + if(!texture) + return; + if(texture.isLoaded()){ this.setTextureWithRect(texture, cc.rect(0, 0, texture.width, texture.height)); } else { @@ -1568,9 +1517,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // udpate after action in run! this.scheduleUpdateWithPriority(1); - - this._renderCmd._initWithTotalParticles(); - + this._renderCmd._initWithTotalParticles(numberOfParticles); return true; }, @@ -1592,7 +1539,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ return false; var particle = this._renderCmd.addParticle(); - this.initParticle(particle); ++this.particleCount; return true; @@ -1614,10 +1560,21 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ particle.pos.y = this._sourcePosition.y + this._posVar.y * locRandomMinus11(); // Color - - var color = this._renderCmd.initParticle(); - var start = color.start, - end = color.end; + var start, end; + var locStartColor = this._startColor, locStartColorVar = this._startColorVar; + var locEndColor = this._endColor, locEndColorVar = this._endColorVar; + start = { + r: cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255), + g: cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255), + b: cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255), + a: cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255) + }; + end = { + r: cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255), + g: cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255), + b: cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255), + a: cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255) + }; particle.color = start; var locParticleDeltaColor = particle.deltaColor, locParticleTimeToLive = particle.timeToLive; @@ -1725,128 +1682,14 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {cc.Point} newPosition */ updateQuadWithParticle:function (particle, newPosition) { - var quad = null; - if (this._batchNode) { - var batchQuads = this._batchNode.textureAtlas.quads; - quad = batchQuads[this.atlasIndex + particle.atlasIndex]; - this._batchNode.textureAtlas.dirty = true; - } else - quad = this._renderCmd._quads[this._particleIdx]; - - var r, g, b, a; - if (this._opacityModifyRGB) { - r = 0 | (particle.color.r * particle.color.a/255); - g = 0 | (particle.color.g * particle.color.a/255); - b = 0 | (particle.color.b * particle.color.a/255); - } else { - r = 0 | (particle.color.r ); - g = 0 | (particle.color.g ); - b = 0 | (particle.color.b ); - } - a = 0 | (particle.color.a ); - - var locColors = quad.bl.colors; - locColors.r = r; - locColors.g = g; - locColors.b = b; - locColors.a = a; - - locColors = quad.br.colors; - locColors.r = r; - locColors.g = g; - locColors.b = b; - locColors.a = a; - - locColors = quad.tl.colors; - locColors.r = r; - locColors.g = g; - locColors.b = b; - locColors.a = a; - - locColors = quad.tr.colors; - locColors.r = r; - locColors.g = g; - locColors.b = b; - locColors.a = a; - - // vertices - var size_2 = particle.size / 2; - if (particle.rotation) { - var x1 = -size_2; - var y1 = -size_2; - - var x2 = size_2; - var y2 = size_2; - var x = newPosition.x; - var y = newPosition.y; - - var rad = -cc.degreesToRadians(particle.rotation); - var cr = Math.cos(rad); - var sr = Math.sin(rad); - var ax = x1 * cr - y1 * sr + x; - var ay = x1 * sr + y1 * cr + y; - var bx = x2 * cr - y1 * sr + x; - var by = x2 * sr + y1 * cr + y; - var cx = x2 * cr - y2 * sr + x; - var cy = x2 * sr + y2 * cr + y; - var dx = x1 * cr - y2 * sr + x; - var dy = x1 * sr + y2 * cr + y; - - // bottom-left - quad.bl.vertices.x = ax; - quad.bl.vertices.y = ay; - - // bottom-right vertex: - quad.br.vertices.x = bx; - quad.br.vertices.y = by; - - // top-left vertex: - quad.tl.vertices.x = dx; - quad.tl.vertices.y = dy; - - // top-right vertex: - quad.tr.vertices.x = cx; - quad.tr.vertices.y = cy; - } else { - // bottom-left vertex: - quad.bl.vertices.x = newPosition.x - size_2; - quad.bl.vertices.y = newPosition.y - size_2; - - // bottom-right vertex: - quad.br.vertices.x = newPosition.x + size_2; - quad.br.vertices.y = newPosition.y - size_2; - - // top-left vertex: - quad.tl.vertices.x = newPosition.x - size_2; - quad.tl.vertices.y = newPosition.y + size_2; - - // top-right vertex: - quad.tr.vertices.x = newPosition.x + size_2; - quad.tr.vertices.y = newPosition.y + size_2; - } + this._renderCmd.updateQuadWithParticle(particle, newPosition); }, /** * should be overridden by subclasses */ postStep:function () { - if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - var gl = cc._renderContext; - - gl.bindBuffer(gl.ARRAY_BUFFER, this._renderCmd._buffersVBO[0]); - gl.bufferData(gl.ARRAY_BUFFER, this._renderCmd._quadsArrayBuffer, gl.DYNAMIC_DRAW); - - // Option 2: Data - // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * particleCount, quads_, GL_DYNAMIC_DRAW); - - // Option 3: Orphaning + glMapBuffer - // glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_uTotalParticles, NULL, GL_STREAM_DRAW); - // void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - // memcpy(buf, m_pQuads, sizeof(m_pQuads[0])*m_uTotalParticles); - // glUnmapBuffer(GL_ARRAY_BUFFER); - - //cc.checkGLErrorDebug(); - } + this._renderCmd.postStep(); }, /** @@ -1881,7 +1724,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } if (this._visible) { - // Used to reduce memory allocation / creation within the loop var tpa = cc.Particle.TemporaryPoints[1], tpb = cc.Particle.TemporaryPoints[2], @@ -1961,14 +1803,12 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // var newPos = tpa; if (this.positionType == cc.ParticleSystem.TYPE_FREE || this.positionType == cc.ParticleSystem.TYPE_RELATIVE) { - var diff = tpb; cc.pIn(diff, currentPosition); cc.pSubIn(diff, selParticle.startPos); cc.pIn(newPos, selParticle.pos); cc.pSubIn(newPos, diff); - } else { cc.pIn(newPos, selParticle.pos); } @@ -1979,16 +1819,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ newPos.x += this._position.x; newPos.y += this._position.y; } - - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - // IMPORTANT: newPos may not be used as a reference here! (as it is just the temporary tpa point) - // the implementation of updateQuadWithParticle must use - // the x and y values directly - this.updateQuadWithParticle(selParticle, newPos); - } else { - cc.pIn(selParticle.drawPos, newPos); - } - //updateParticleImp(self, updateParticleSel, p, newPos); + this._renderCmd.updateParticlePosition(selParticle, newPos); // update particle counter ++this._particleIdx; @@ -2003,7 +1834,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ if (this._batchNode) { //disable the switched particle this._batchNode.disableParticle(this.atlasIndex + currentIndex); - //switch indexes locParticles[this.particleCount - 1].atlasIndex = currentIndex; } @@ -2172,15 +2002,18 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ *

    * @param {cc.SpriteFrame} spriteFrame */ - setDisplayFrame:function (spriteFrame) { + setDisplayFrame: function (spriteFrame) { + if (!spriteFrame) + return; + var locOffset = spriteFrame.getOffsetInPixels(); - if(locOffset.x != 0 || locOffset.y != 0) + if (locOffset.x != 0 || locOffset.y != 0) cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets"); // update texture before updating texture rect - if (cc._renderType === cc._RENDER_TYPE_WEBGL) - if (!this._texture || spriteFrame.getTexture()._webTextureObj != this._texture._webTextureObj) - this.setTexture(spriteFrame.getTexture()); + var texture = spriteFrame.getTexture(), locTexture = this._texture; + if (locTexture != texture) + this.setTexture(texture); }, /** @@ -2188,99 +2021,21 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * @param {cc.Texture2D} texture * @param {cc.Rect} rect */ - setTextureWithRect:function (texture, rect) { + setTextureWithRect: function (texture, rect) { var locTexture = this._texture; - if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - // Only update the texture if is different from the current one - if ((!locTexture || texture._webTextureObj != locTexture._webTextureObj) && (locTexture != texture)) { - this._texture = texture; - this._updateBlendFunc(); - } - } else { - if ((!locTexture || texture != locTexture) && (locTexture != texture)) { - this._texture = texture; - this._updateBlendFunc(); - } + if (locTexture != texture) { + this._texture = texture; + this._updateBlendFunc(); } - - this._renderCmd._pointRect = rect; this.initTexCoordsWithRect(rect); }, /** - * draw particle - * @param {CanvasRenderingContext2D} ctx CanvasContext - * @override - */ - draw:function (ctx) { - if(!this._textureLoaded || this._batchNode) // draw should not be called when added to a particleBatchNode - return; - - this._renderCmd.draw(); - - cc.g_NumberOfDraws++; - }, - - _changeTextureColor: function(element, color, rect){ - this._renderCmd._changeTextureColor(element, color, rect); - }, - - /** - * listen the event that coming to foreground on Android + * listen the event that coming to foreground on Android (An empty function for native) * @param {cc.Class} obj */ listenBackToForeground:function (obj) { - if (cc.TEXTURE_ATLAS_USE_VAO) - this._setupVBOandVAO(); - else - this._setupVBO(); - }, - - _setupVBOandVAO:function () { - //Not support on WebGL - /*if (cc._renderType == cc._RENDER_TYPE_CANVAS) { - return; - }*/ - - //NOT SUPPORTED - /*glGenVertexArrays(1, this._VAOname); - glBindVertexArray(this._VAOname); - - var kQuadSize = sizeof(m_pQuads[0].bl); - - glGenBuffers(2, this._buffersVBO[0]); - - glBindBuffer(GL_ARRAY_BUFFER, this._buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(this._renderCmd._quads[0]) * this._totalParticles, this._renderCmd._quads, GL_DYNAMIC_DRAW); - - // vertices - glEnableVertexAttribArray(kCCVertexAttrib_Position); - glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, offsetof(ccV3F_C4B_T2F, vertices)); - - // colors - glEnableVertexAttribArray(kCCVertexAttrib_Color); - glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, offsetof(ccV3F_C4B_T2F, colors)); - - // tex coords - glEnableVertexAttribArray(kCCVertexAttrib_TexCoords); - glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, offsetof(ccV3F_C4B_T2F, texCoords)); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(m_pIndices[0]) * m_uTotalParticles * 6, m_pIndices, GL_STATIC_DRAW); - - glBindVertexArray(0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - CHECK_GL_ERROR_DEBUG();*/ - }, - - _setupVBO:function () { - this._renderCmd._setupVBO(); - }, - - _allocMemory:function () { - this._renderCmd._allocMemory(); + //do nothing } }); @@ -2294,6 +2049,12 @@ cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpaci _p.batchNode; cc.defineGetterSetter(_p, "batchNode", _p.getBatchNode, _p.setBatchNode); /** @expose */ +_p.drawMode; +cc.defineGetterSetter(_p, "drawMode", _p.getDrawMode, _p.setDrawMode); +/** @expose */ +_p.shapeType; +cc.defineGetterSetter(_p, "shapeType", _p.getShapeType, _p.setShapeType); +/** @expose */ _p.active; cc.defineGetterSetter(_p, "active", _p.isActive); /** @expose */ @@ -2426,12 +2187,12 @@ cc.ParticleSystem.ModeA = function (gravity, speed, speedVar, tangentialAccel, t * Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode) * @Class * @Construct - * @param {Number} startRadius The starting radius of the particles. - * @param {Number} startRadiusVar The starting radius variance of the particles. - * @param {Number} endRadius The ending radius of the particles. - * @param {Number} endRadiusVar The ending radius variance of the particles. - * @param {Number} rotatePerSecond Number of degress to rotate a particle around the source pos per second. - * @param {Number} rotatePerSecondVar Variance in degrees for rotatePerSecond. + * @param {Number} [startRadius=0] The starting radius of the particles. + * @param {Number} [startRadiusVar=0] The starting radius variance of the particles. + * @param {Number} [endRadius=0] The ending radius of the particles. + * @param {Number} [endRadiusVar=0] The ending radius variance of the particles. + * @param {Number} [rotatePerSecond=0] Number of degrees to rotate a particle around the source pos per second. + * @param {Number} [rotatePerSecondVar=0] Variance in degrees for rotatePerSecond. */ cc.ParticleSystem.ModeB = function (startRadius, startRadiusVar, endRadius, endRadiusVar, rotatePerSecond, rotatePerSecondVar) { /** The starting radius of the particles. Only available in 'Radius' mode. */ diff --git a/cocos2d/particle/CCParticleSystemRenderCmd.js b/cocos2d/particle/CCParticleSystemRenderCmd.js index d6bc98733c..0ff76ca287 100644 --- a/cocos2d/particle/CCParticleSystemRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemRenderCmd.js @@ -30,14 +30,44 @@ cc.Node.CanvasRenderCmd.call(this, renderable); this._needDraw = true; - this._buffersVBO = [0, 0]; - this._quads = []; - this._indices = []; + this._drawMode = cc.ParticleSystem.SHAPE_MODE; + this._shapeType = cc.ParticleSystem.BALL_SHAPE; + this._pointRect = cc.rect(0, 0, 0, 0); }; var proto = cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); proto.constructor = cc.ParticleSystem.CanvasRenderCmd; + proto.getDrawMode = function(){ + return this._drawMode; + }; + + proto.setDrawMode = function(drawMode){ + this._drawMode = drawMode; + }; + + proto.getShapeType = function(){ + return this._shapeType; + }; + + proto.setShapeType = function(shapeType){ + this._shapeType = shapeType; + }; + + proto.setBatchNode = function(batchNode){ + if (this._batchNode != batchNode) { + this._node._batchNode = batchNode; + } + }; + + proto.updateQuadWithParticle = function (particle, newPosition) { + //do nothing + }; + + proto.updateParticlePosition = function(particle, position){ + cc.pIn(particle.drawPos, position); + }; + proto.rendering = function (ctx, scaleX, scaleY) { var context = ctx || cc._renderContext, node = this._node, @@ -66,7 +96,7 @@ return; } - var textureCache = cc.textureCache, drawElement = element; + var drawElement = element; for (i = 0; i < particleCount; i++) { particle = particles[i]; lpx = (0 | (particle.size * 0.5)); @@ -87,20 +117,7 @@ if (particle.rotation) context.rotate(cc.degreesToRadians(particle.rotation)); - if (particle.isChangeColor) { - var cacheTextureForColor = textureCache.getTextureColors(element); - if (cacheTextureForColor) { - // Create another cache for the tinted version - // This speeds up things by a fair bit - if (!cacheTextureForColor.tintCache) { - cacheTextureForColor.tintCache = cc.newElement('canvas'); - cacheTextureForColor.tintCache.width = element.width; - cacheTextureForColor.tintCache.height = element.height; - } - cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, particle.color, this._pointRect, cacheTextureForColor.tintCache); - drawElement = cacheTextureForColor.tintCache; - } - } + drawElement = particle.isChangeColor ? this._changeTextureColor(element, particle.color, this._pointRect) : element; context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); context.restore(); } @@ -155,7 +172,9 @@ } } - proto.initTexCoordsWithRect = function(){}; + proto.initTexCoordsWithRect = function(pointRect){ + this._pointRect = pointRect; + }; proto.setTotalParticles = function(){ //cc.assert(tp <= this._allocatedParticles, "Particle: resizing particle array only supported for quads"); @@ -175,107 +194,35 @@ return particle; }; - proto.initParticle = function(){ - var node = this._node; - var locRandomMinus11 = cc.randomMinus1To1; - // Color - var start, end; - var locStartColor = node._startColor, locStartColorVar = node._startColorVar; - var locEndColor = node._endColor, locEndColorVar = node._endColorVar; - start = cc.color( - cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255), - cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255), - cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255), - cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255) - ); - end = cc.color( - cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255), - cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255), - cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255), - cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255) - ); - return {start: start, end: end}; - }; - - proto.draw = function(ctx){ - var node = this; - var context = ctx || cc._renderContext; - context.save(); - if (node.isBlendAdditive()) - context.globalCompositeOperation = 'lighter'; - else - context.globalCompositeOperation = 'source-over'; - - var element = node._texture.getHtmlElementObj(); - var locScaleX = cc.view.getScaleX(), locScaleY = cc.view.getScaleY(); - - for (var i = 0; i < node.particleCount; i++) { - var particle = node._particles[i]; - var lpx = (0 | (particle.size * 0.5)); - - if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { - // Delay drawing until the texture is fully loaded by the browser - if (!element.width || !element.height) - continue; - - context.save(); - context.globalAlpha = particle.color.a / 255; - context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); - - var size = Math.floor(particle.size / 4) * 4; - var w = this._pointRect.width; - var h = this._pointRect.height; - - context.scale( - Math.max(size * locScaleX / w, 0.000001), - Math.max(size * locScaleY / h, 0.000001) - ); - - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - context.translate(-(0 | (w / 2)), -(0 | (h / 2))); - var drawElement = particle.isChangeColor ? node._changeTextureColor(element, particle.color, this._pointRect) : element; - if(drawElement) - context.drawImage(drawElement, 0, 0); - context.restore(); - } else { - context.save(); - context.globalAlpha = particle.color.a / 255; - - context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - - if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - cc._drawingUtil.drawStar(context, lpx, particle.color); - } else - cc._drawingUtil.drawColorBall(context, lpx, particle.color); - context.restore(); - } - } - context.restore(); - }; - proto._setupVBO = function(){}; proto._allocMemory = function(){ return true; }; + proto.postStep = function(){}; + proto._setBlendAdditive = function(){ var locBlendFunc = this._node._blendFunc; locBlendFunc.src = cc.BLEND_SRC; locBlendFunc.dst = cc.BLEND_DST; }; - proto._initWithTotalParticles = - proto._updateDeltaColor = function(){}; + proto._initWithTotalParticles = function(totalParticles){}; + proto._updateDeltaColor = function(selParticle, dt){ + if (!this._dontTint) { + selParticle.color.r += selParticle.deltaColor.r * dt; + selParticle.color.g += selParticle.deltaColor.g * dt; + selParticle.color.b += selParticle.deltaColor.b * dt; + selParticle.color.a += selParticle.deltaColor.a * dt; + selParticle.isChangeColor = true; + } + }; })(); -/** - * ParticleSystem's WebGL render command - */ (function(){ - + /** + * ParticleSystem's WebGL render command + */ cc.ParticleSystem.WebGLRenderCmd = function(renderable){ cc.Node.WebGLRenderCmd.call(this, renderable); this._needDraw = true; @@ -283,12 +230,153 @@ this._buffersVBO = [0, 0]; this._quads = []; this._indices = []; - this._pointRect = cc.rect(0, 0, 0, 0); this._quadsArrayBuffer = null; }; var proto = cc.ParticleSystem.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.ParticleSystem.CanvasRenderCmd; + proto.getDrawMode = function(){}; + proto.setDrawMode = function(drawMode){}; + proto.getShapeType = function(){}; + proto.setShapeType = function(shapeType){}; + + proto.setBatchNode = function(batchNode){ + var node = this._node; + if (node._batchNode != batchNode) { + var oldBatch = node._batchNode; + node._batchNode = batchNode; //weak reference + + if (batchNode) { + var locParticles = node._particles; + for (var i = 0; i < node._totalParticles; i++) + locParticles[i].atlasIndex = i; + } + + // NEW: is self render ? + if (!batchNode) { + this._allocMemory(); + this.initIndices(node._totalParticles); + node.setTexture(oldBatch.getTexture()); + this._setupVBO(); + + } else if (!oldBatch) { + // OLD: was it self render cleanup ? + // copy current state to batch + node._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._quads, node.atlasIndex); + + //delete buffer + cc._renderContext.deleteBuffer(this._buffersVBO[1]); //where is re-bindBuffer code? + } + } + }; + + proto.initIndices = function (totalParticles) { + var locIndices = this._indices; + for (var i = 0, len = totalParticles; i < len; ++i) { + var i6 = i * 6; + var i4 = i * 4; + locIndices[i6 + 0] = i4 + 0; + locIndices[i6 + 1] = i4 + 1; + locIndices[i6 + 2] = i4 + 2; + + locIndices[i6 + 5] = i4 + 1; + locIndices[i6 + 4] = i4 + 2; + locIndices[i6 + 3] = i4 + 3; + } + }; + + proto.isDifferentTexture = function(texture1, texture2){ + if(texture1 == texture2) + return true; + }; + + proto.updateParticlePosition = function(particle, position){ + // IMPORTANT: newPos may not be used as a reference here! (as it is just the temporary tpa point) + // the implementation of updateQuadWithParticle must use + // the x and y values directly + this.updateQuadWithParticle(particle, position); + }; + + proto.updateQuadWithParticle = function (particle, newPosition) { + var quad = null, node = this._node; + if (node._batchNode) { + var batchQuads = node._batchNode.textureAtlas.quads; + quad = batchQuads[this.atlasIndex + particle.atlasIndex]; + node._batchNode.textureAtlas.dirty = true; + } else + quad = this._quads[this._particleIdx]; + + var r, g, b, a; + if (node._opacityModifyRGB) { + r = 0 | (particle.color.r * particle.color.a/255); + g = 0 | (particle.color.g * particle.color.a/255); + b = 0 | (particle.color.b * particle.color.a/255); + } else { + r = 0 | (particle.color.r ); + g = 0 | (particle.color.g ); + b = 0 | (particle.color.b ); + } + a = 0 | (particle.color.a ); + + var blColors = quad.bl.colors, brColors = quad.br.colors, tlColors = quad.tl.colors, trColors = quad.tr.colors; + blColors.r = brColors.r = tlColors.r = trColors.r = r; + blColors.g = brColors.g = tlColors.g = trColors.g = g; + blColors.b = brColors.b = tlColors.b = trColors.b = b; + blColors.a = brColors.a = tlColors.a = trColors.a = a; + + // vertices + var size_2 = particle.size / 2; + if (particle.rotation) { + var x1 = -size_2, y1 = -size_2; + + var x2 = size_2, y2 = size_2; + var x = newPosition.x, y = newPosition.y; + + var rad = -cc.degreesToRadians(particle.rotation); + var cr = Math.cos(rad), sr = Math.sin(rad); + var ax = x1 * cr - y1 * sr + x; + var ay = x1 * sr + y1 * cr + y; + var bx = x2 * cr - y1 * sr + x; + var by = x2 * sr + y1 * cr + y; + var cx = x2 * cr - y2 * sr + x; + var cy = x2 * sr + y2 * cr + y; + var dx = x1 * cr - y2 * sr + x; + var dy = x1 * sr + y2 * cr + y; + + // bottom-left + quad.bl.vertices.x = ax; + quad.bl.vertices.y = ay; + + // bottom-right vertex: + quad.br.vertices.x = bx; + quad.br.vertices.y = by; + + // top-left vertex: + quad.tl.vertices.x = dx; + quad.tl.vertices.y = dy; + + // top-right vertex: + quad.tr.vertices.x = cx; + quad.tr.vertices.y = cy; + } else { + // bottom-left vertex: + quad.bl.vertices.x = newPosition.x - size_2; + quad.bl.vertices.y = newPosition.y - size_2; + + // bottom-right vertex: + quad.br.vertices.x = newPosition.x + size_2; + quad.br.vertices.y = newPosition.y - size_2; + + // top-left vertex: + quad.tl.vertices.x = newPosition.x - size_2; + quad.tl.vertices.y = newPosition.y + size_2; + + // top-right vertex: + quad.tr.vertices.x = newPosition.x + size_2; + quad.tr.vertices.y = newPosition.y + size_2; + } + }; + proto.rendering = function (ctx) { var _t = this._node; if (!_t._texture) @@ -316,15 +404,6 @@ gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; - proto._changeTextureColor = function(element, color, rect){ - if (!element.tintCache) { - element.tintCache = document.createElement('canvas'); - element.tintCache.width = element.width; - element.tintCache.height = element.height; - } - return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, color, rect, element.tintCache); - }; - proto.initTexCoordsWithRect = function(pointRect){ var node = this; var texture = node.texture; @@ -394,7 +473,7 @@ } }; - proto.setTotalParticles = function(){ + proto.setTotalParticles = function(tp){ var node = this._node; // If we are setting the total numer of particles to a number higher // than what is allocated, we need to allocate new arrays @@ -423,11 +502,7 @@ } this._quadsArrayBuffer = locQuadsArrayBuffer; - - node.initIndices(); - //if (cc.TEXTURE_ATLAS_USE_VAO) - // node._setupVBOandVAO(); - //else + this.initIndices(tp); this._setupVBO(); //set the texture coord @@ -445,66 +520,17 @@ return particles[node.particleCount]; }; - proto.initParticle = function(){ - var node = this._node; - var locRandomMinus11 = cc.randomMinus1To1; - // Color - var start, end; - var locStartColor = node._startColor, locStartColorVar = node._startColorVar; - var locEndColor = node._endColor, locEndColorVar = node._endColorVar; - start = { - r: cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255), - g: cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255), - b: cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255), - a: cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255) - }; - end = { - r: cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255), - g: cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255), - b: cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255), - a: cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255) - }; - return {start: start, end: end}; - }; - - proto.draw = function(ctx){ - if(!this._texture) - return; - var node = this._node; - var gl = ctx || cc._renderContext; - node._shaderProgram.use(); - node._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); - - cc.glBindTexture2D(node._texture); - cc.glBlendFuncForParticle(node._blendFunc.src, node._blendFunc.dst); - - //cc.assert(node._particleIdx == node.particleCount, "Abnormal error in particle quad"); - - // - // Using VBO without VAO - // - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, node._buffersVBO[0]); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, node._buffersVBO[1]); - gl.drawElements(gl.TRIANGLES, node._particleIdx * 6, gl.UNSIGNED_SHORT, 0); - }; - proto._setupVBO = function(){ var node = this; var gl = cc._renderContext; //gl.deleteBuffer(this._buffersVBO[0]); this._buffersVBO[0] = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, node._buffersVBO[0]); + gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]); gl.bufferData(gl.ARRAY_BUFFER, this._quadsArrayBuffer, gl.DYNAMIC_DRAW); this._buffersVBO[1] = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, node._buffersVBO[1]); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._indices, gl.STATIC_DRAW); //cc.checkGLErrorDebug(); @@ -535,6 +561,12 @@ return true; }; + proto.postStep = function(){ + var gl = cc._renderContext; + gl.bindBuffer(gl.ARRAY_BUFFER, this._buffersVBO[0]); + gl.bufferData(gl.ARRAY_BUFFER, this._quadsArrayBuffer, gl.DYNAMIC_DRAW); + }; + proto._setBlendAdditive = function(){ var locBlendFunc = this._node._blendFunc; if (this._texture && !this._texture.hasPremultipliedAlpha()) { @@ -546,29 +578,22 @@ } }; - proto._initWithTotalParticles = function(){ - var node = this; + proto._initWithTotalParticles = function(totalParticles){ // allocating data space - if (!node._allocMemory()) + if (!this._allocMemory()) return false; - node.initIndices(); - //if (cc.TEXTURE_ATLAS_USE_VAO) - // this._setupVBOandVAO(); - //else - node._setupVBO(); + this.initIndices(totalParticles); + this._setupVBO(); - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; - proto._updateDeltaColor = function(selParticle, dt){ - if (!this._node._dontTint) { - selParticle.color.r += selParticle.deltaColor.r * dt; - selParticle.color.g += selParticle.deltaColor.g * dt; - selParticle.color.b += selParticle.deltaColor.b * dt; - selParticle.color.a += selParticle.deltaColor.a * dt; - selParticle.isChangeColor = true; - } + proto._updateDeltaColor = function (selParticle, dt) { + selParticle.color.r += selParticle.deltaColor.r * dt; + selParticle.color.g += selParticle.deltaColor.g * dt; + selParticle.color.b += selParticle.deltaColor.b * dt; + selParticle.color.a += selParticle.deltaColor.a * dt; + selParticle.isChangeColor = true; }; - })(); \ No newline at end of file diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index dd06b870e7..91a76369ab 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -57,6 +57,24 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ _reverseDirection:false, _className:"ProgressTimer", + /** + * constructor of cc.cc.ProgressTimer + * @function + * @param {cc.Sprite} sprite + */ + ctor: function(sprite){ + cc.Node.prototype.ctor.call(this); + + this._type = cc.ProgressTimer.TYPE_RADIAL; + this._percentage = 0.0; + this._midPoint = cc.p(0, 0); + this._barChangeRate = cc.p(0, 0); + this._reverseDirection = false; + this._sprite = null; + + sprite && this.initWithSprite(sprite); + }, + /** * Midpoint is used to modify the progress start position. * If you're using radials type then the midpoint changes the center point @@ -153,36 +171,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ return this._reverseDirection; }, - _boundaryTexCoord:function (index) { - 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 - return cc.p((locProTextCoords >> ((index << 1) + 1)) & 1, (locProTextCoords >> (index << 1)) & 1); - } - return cc.p(0,0); - }, - - /** - * constructor of cc.cc.ProgressTimer - * @function - * @param {cc.Sprite} sprite - */ - ctor: function(){ - cc.Node.prototype.ctor.call(this); - cc.Node.prototype.ctor.call(this); - - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._percentage = 0.0; - this._midPoint = cc.p(0, 0); - this._barChangeRate = cc.p(0, 0); - this._reverseDirection = false; - - this._sprite = null; - this.sprite && this._renderCmd.initWithSprite(this.sprite); - }, - /** * set color of sprite * @param {cc.Color} color @@ -223,7 +211,10 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {Boolean} reverse */ setReverseProgress: function(reverse){ - this._renderCmd.setReverseProgress(reverse); + if (this._reverseDirection !== reverse){ + this._reverseDirection = reverse; + this._renderCmd.releaseData(); + } }, /** @@ -232,7 +223,14 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {cc.Sprite} sprite */ setSprite: function(sprite){ - this._renderCmd.setSprite(sprite); + if (this._sprite != sprite) { + this._sprite = sprite; + if(sprite) + this.setContentSize(sprite.width,sprite.height); + else + this.setContentSize(0,0); + this._renderCmd.releaseData(); + } }, /** @@ -241,7 +239,11 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {cc.ProgressTimer.TYPE_RADIAL|cc.ProgressTimer.TYPE_BAR} type */ setType: function(type){ - this._renderCmd.setType(type); + var node = this._node; + if (type !== this._type){ + node._type = type; + this._renderCmd.releaseData(); + } }, /** @@ -250,40 +252,10 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {Boolean} reverse */ setReverseDirection: function(reverse){ - this._renderCmd.setReverseDirection(reverse); - }, - - /** - * @param {cc.Point} alpha - * @return {cc.Vertex2F | Object} the vertex position from the texture coordinate - * @private - */ - _textureCoordFromAlphaPoint:function (alpha) { - var locSprite = this._sprite; - if (!locSprite) { - return {u:0, v:0}; //new cc.Tex2F(0, 0); - } - var quad = locSprite.quad; - var min = cc.p(quad.bl.texCoords.u, quad.bl.texCoords.v); - var max = cc.p(quad.tr.texCoords.u, quad.tr.texCoords.v); - - // Fix bug #1303 so that progress timer handles sprite frame texture rotation - if (locSprite.textureRectRotated) { - var temp = alpha.x; - alpha.x = alpha.y; - alpha.y = temp; + if (this._reverseDirection !== reverse){ + this._reverseDirection = reverse; + this._renderCmd.releaseData(); } - return {u: min.x * (1 - alpha.x) + max.x * alpha.x, v: min.y * (1 - alpha.y) + max.y * alpha.y}; - }, - - _vertexFromAlphaPoint:function (alpha) { - if (!this._sprite) { - return {x: 0, y: 0}; - } - var quad = this._sprite.quad; - var min = cc.p(quad.bl.vertices.x, quad.bl.vertices.y); - var max = cc.p(quad.tr.vertices.x, quad.tr.vertices.y); - return {x: min.x * (1 - alpha.x) + max.x * alpha.x, y: min.y * (1 - alpha.y) + max.y * alpha.y}; }, /** @@ -293,140 +265,16 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @return {Boolean} */ initWithSprite: function(sprite){ - this._renderCmd.initWithSprite(sprite); - }, - - /** - *

    - * Update does the work of mapping the texture onto the triangles
    - * It now doesn't occur the cost of free/alloc data every update cycle.
    - * It also only changes the percentage point but no other points if they have not been modified.
    - *
    - * It now deals with flipped texture. If you run into this problem, just use the
    - * sprite property and enable the methods flipX, flipY.
    - *

    - * @private - */ - _updateRadial:function () { - if (!this._sprite) - return; - - var i, locMidPoint = this._midPoint; - var alpha = this._percentage / 100; - var angle = 2 * (cc.PI) * ( this._reverseDirection ? alpha : 1.0 - alpha); - - // We find the vector to do a hit detection based on the percentage - // We know the first vector is the one @ 12 o'clock (top,mid) so we rotate - // from that by the progress angle around the m_tMidpoint pivot - var topMid = cc.p(locMidPoint.x, 1); - var percentagePt = cc.pRotateByAngle(topMid, locMidPoint, angle); - - var index = 0; - var hit; - - if (alpha == 0) { - // More efficient since we don't always need to check intersection - // If the alpha is zero then the hit point is top mid and the index is 0. - hit = topMid; - index = 0; - } else if (alpha == 1) { - // More efficient since we don't always need to check intersection - // If the alpha is one then the hit point is top mid and the index is 4. - hit = topMid; - index = 4; - } else { - // We run a for loop checking the edges of the texture to find the - // intersection point - // We loop through five points since the top is split in half - - var min_t = cc.FLT_MAX; - var locProTextCoordsCount = cc.ProgressTimer.TEXTURE_COORDS_COUNT; - for (i = 0; i <= locProTextCoordsCount; ++i) { - var pIndex = (i + (locProTextCoordsCount - 1)) % locProTextCoordsCount; - - var edgePtA = this._boundaryTexCoord(i % locProTextCoordsCount); - var edgePtB = this._boundaryTexCoord(pIndex); - - // Remember that the top edge is split in half for the 12 o'clock position - // Let's deal with that here by finding the correct endpoints - if (i == 0) - edgePtB = cc.pLerp(edgePtA, edgePtB, 1 - locMidPoint.x); - else if (i == 4) - edgePtA = cc.pLerp(edgePtA, edgePtB, 1 - locMidPoint.x); - - // retPoint are returned by ccpLineIntersect - var retPoint = cc.p(0, 0); - if (cc.pLineIntersect(edgePtA, edgePtB, locMidPoint, percentagePt, retPoint)) { - // Since our hit test is on rays we have to deal with the top edge - // being in split in half so we have to test as a segment - if ((i == 0 || i == 4)) { - // s represents the point between edgePtA--edgePtB - if (!(0 <= retPoint.x && retPoint.x <= 1)) - continue; - } - // As long as our t isn't negative we are at least finding a - // correct hitpoint from m_tMidpoint to percentagePt. - if (retPoint.y >= 0) { - // Because the percentage line and all the texture edges are - // rays we should only account for the shortest intersection - if (retPoint.y < min_t) { - min_t = retPoint.y; - index = i; - } - } - } - } - - // Now that we have the minimum magnitude we can use that to find our intersection - hit = cc.pAdd(locMidPoint, cc.pMult(cc.pSub(percentagePt, locMidPoint), min_t)); - } - - // The size of the vertex data is the index from the hitpoint - // the 3 is for the m_tMidpoint, 12 o'clock point and hitpoint position. - var sameIndexCount = true; - if (this._renderCmd._vertexDataCount != index + 3) { - sameIndexCount = false; - this._renderCmd._vertexData = null; - this._renderCmd._vertexArrayBuffer = null; - this._renderCmd._vertexDataCount = 0; - } + this.percentage = 0; + this.setAnchorPoint(0.5,0.5); - if (!this._renderCmd._vertexData) { - this._renderCmd._vertexDataCount = index + 3; - var locCount = this._renderCmd._vertexDataCount, vertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - this._renderCmd._vertexArrayBuffer = new ArrayBuffer(locCount * vertexDataLen); - var locData = []; - for (i = 0; i < locCount; i++) - locData[i] = new cc.V2F_C4B_T2F(null, null, null, this._renderCmd._vertexArrayBuffer, i * vertexDataLen); - - this._renderCmd._vertexData = locData; - if(!this._renderCmd._vertexData){ - cc.log( "cc.ProgressTimer._updateRadial() : Not enough memory"); - return; - } - } - this._updateColor(); - - var locVertexData = this._renderCmd._vertexData; - if (!sameIndexCount) { - // First we populate the array with the m_tMidpoint, then all - // vertices/texcoords/colors of the 12 'o clock start and edges and the hitpoint - locVertexData[0].texCoords = this._textureCoordFromAlphaPoint(locMidPoint); - locVertexData[0].vertices = this._vertexFromAlphaPoint(locMidPoint); - - locVertexData[1].texCoords = this._textureCoordFromAlphaPoint(topMid); - locVertexData[1].vertices = this._vertexFromAlphaPoint(topMid); - - for (i = 0; i < index; i++) { - var alphaPoint = this._boundaryTexCoord(i); - locVertexData[i + 2].texCoords = this._textureCoordFromAlphaPoint(alphaPoint); - locVertexData[i + 2].vertices = this._vertexFromAlphaPoint(alphaPoint); - } - } - - // hitpoint will go last - locVertexData[this._renderCmd._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(hit); - locVertexData[this._renderCmd._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(hit); + this._type = cc.ProgressTimer.TYPE_RADIAL; + this._reverseDirection = false; + this.midPoint = cc.p(0.5, 0.5); + this.barChangeRate = cc.p(1, 1); + this.sprite = sprite; + this._renderCmd.initCmd(); + return true; }, _updateProgress: function(){ diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js index 660723e3ad..e81038d26b 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -122,60 +122,19 @@ cc.g_NumberOfDraws++; }; - proto.setReverseProgress = function(reverse){ - var node = this._node; - if (node._reverseDirection !== reverse) - node._reverseDirection = reverse; - }; - - proto.setSprite = function(sprite){ - var node = this._node; - if (node._sprite != sprite) { - node._sprite = sprite; - node.width = node._sprite.width; - node.height = node._sprite.height; - } - }; - - proto.setType = function(type){ - var node = this._node; - if (type !== node._type){ - node._type = type; - node._renderCmd._type = type; - } - }; - - proto.setReverseDirection = function(reverse){ - var node = this._node; - if (node._reverseDirection !== reverse) - node._reverseDirection = reverse; - }; - - proto.initWithSprite = function(sprite){ - var node = this._node; - node.percentage = 0; - node.anchorX = 0.5; - node.anchorY = 0.5; + proto.releaseData = function(){}; - node._type = cc.ProgressTimer.TYPE_RADIAL; - node._reverseDirection = false; - node.midPoint = cc.p(0.5, 0.5); - node.barChangeRate = cc.p(1, 1); - node.sprite = sprite; - - return true; - }; + proto.initCmd = function(){ }; proto._updateProgress = function(){ var node = this._node; var locSprite = node._sprite; var sw = locSprite.width, sh = locSprite.height; var locMidPoint = node._midPoint; - var locCmd = this; if (node._type == cc.ProgressTimer.TYPE_RADIAL) { - locCmd._radius = Math.round(Math.sqrt(sw * sw + sh * sh)); - var locStartAngle, locEndAngle, locCounterClockWise = false, locOrigin = locCmd._origin; + this._radius = Math.round(Math.sqrt(sw * sw + sh * sh)); + var locStartAngle, locEndAngle, locCounterClockWise = false, locOrigin = this._origin; locOrigin.x = sw * locMidPoint.x; locOrigin.y = -sh * locMidPoint.y; @@ -202,29 +161,27 @@ locEndAngle= -locEndAngle; } - locCmd._startAngle = locStartAngle; - locCmd._endAngle = locEndAngle; - locCmd._counterClockWise = locCounterClockWise; + this._startAngle = locStartAngle; + this._endAngle = locEndAngle; + this._counterClockWise = locCounterClockWise; } else { var locBarChangeRate = node._barChangeRate; var percentageF = node._percentage / 100; - var locBarRect = locCmd._barRect; + var locBarRect = this._barRect; - var drawedSize = cc.size((sw * (1 - locBarChangeRate.x)), (sh * (1 - locBarChangeRate.y))); - var drawingSize = cc.size((sw - drawedSize.width) * percentageF, (sh - drawedSize.height) * percentageF); - var currentDrawSize = cc.size(drawedSize.width + drawingSize.width, drawedSize.height + drawingSize.height); + var drewSize = cc.size((sw * (1 - locBarChangeRate.x)), (sh * (1 - locBarChangeRate.y))); + var drawingSize = cc.size((sw - drewSize.width) * percentageF, (sh - drewSize.height) * percentageF); + var currentDrawSize = cc.size(drewSize.width + drawingSize.width, drewSize.height + drawingSize.height); var startPoint = cc.p(sw * locMidPoint.x, sh * locMidPoint.y); var needToLeft = startPoint.x - currentDrawSize.width / 2; - if ((locMidPoint.x > 0.5) && (currentDrawSize.width / 2 >= sw - startPoint.x)) { + if ((locMidPoint.x > 0.5) && (currentDrawSize.width / 2 >= sw - startPoint.x)) needToLeft = sw - currentDrawSize.width; - } var needToTop = startPoint.y - currentDrawSize.height / 2; - if ((locMidPoint.y > 0.5) && (currentDrawSize.height / 2 >= sh - startPoint.y)) { + if ((locMidPoint.y > 0.5) && (currentDrawSize.height / 2 >= sh - startPoint.y)) needToTop = sh - currentDrawSize.height; - } //left pos locBarRect.x = 0; @@ -264,15 +221,6 @@ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; - this._PI180 = Math.PI / 180; - this._type = cc.ProgressTimer.TYPE_RADIAL; - this._barRect = cc.rect(0, 0, 0, 0); - this._origin = cc.p(0, 0); - this._radius = 0; - this._startAngle = 270; - this._endAngle = 270; - this._counterClockWise = false; - this._vertexWebGLBuffer = cc._renderContext.createBuffer(); this._vertexDataCount = 0; this._vertexData = null; @@ -284,19 +232,19 @@ proto.constructor = cc.ProgressTimer.WebGLRenderCmd; proto.rendering = function (ctx) { - var _t = this._node; + var node = this._node; var context = ctx || cc._renderContext; - if (!this._vertexData || !_t._sprite) + if (!this._vertexData || !node._sprite) return; - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - var blendFunc = _t._sprite.getBlendFunc(); + var blendFunc = node._sprite._blendFunc; cc.glBlendFunc(blendFunc.src, blendFunc.dst); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - cc.glBindTexture2D(_t._sprite.texture); + cc.glBindTexture2D(node._sprite.texture); context.bindBuffer(context.ARRAY_BUFFER, this._vertexWebGLBuffer); if (this._vertexDataDirty) { @@ -308,10 +256,10 @@ 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.ProgressTimer.TYPE_RADIAL) + if (node._type === cc.ProgressTimer.TYPE_RADIAL) context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount); - else if (this._type == cc.ProgressTimer.TYPE_BAR) { - if (!_t._reverseDirection) + else if (node._type == cc.ProgressTimer.TYPE_BAR) { + if (!node._reverseDirection) context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount); else { context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount / 2); @@ -323,51 +271,8 @@ cc.g_NumberOfDraws++; }; - proto.setReverseProgress = function(reverse){ - var node = this._node; - if (node._reverseDirection !== reverse) { - node._reverseDirection = reverse; - - // release all previous information - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; - } - }; - - proto.setSprite = function(sprite){ - var node = this._node; - if (sprite && node._sprite != sprite) { - node._sprite = sprite; - node.width = sprite.width; - node.height = sprite.height; - - // Everytime we set a new sprite, we free the current vertex data - if (this._vertexData) { - this._vertexData = null; - this._vertexArrayBuffer = null; - this._vertexDataCount = 0; - } - } - }; - - proto.setType = function(type){ - var node = this._node; - if (type !== this._type) { - // release all previous information - if (this._vertexData) { - this._vertexData = null; - node._vertexArrayBuffer = null; - this._vertexDataCount = 0; - } - node._type = type; - } - }; - - proto.setReverseDirection = function(reverse){ - var node = this._node; - if (node._reverseDirection !== reverse) { - node._reverseDirection = reverse; + proto.releaseData = function(){ + if (this._vertexData) { //release all previous information this._vertexData = null; this._vertexArrayBuffer = null; @@ -375,24 +280,13 @@ } }; - proto.initWithSprite = function(sprite){ - var node = this._node; - node.percentage = 0; + proto.initCmd = function(){ this._vertexData = null; this._vertexArrayBuffer = null; this._vertexDataCount = 0; - node.anchorX = 0.5; - node.anchorY = 0.5; - - node._type = cc.ProgressTimer.TYPE_RADIAL; - node._reverseDirection = false; - node.midPoint = cc.p(0.5, 0.5); - node.barChangeRate = cc.p(1, 1); - node.sprite = sprite; //shader program - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - return true; + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; proto.draw = function(ctx){ @@ -460,13 +354,11 @@ if (!node._sprite) return; - var i; - var alpha = node._percentage / 100.0; + var i, alpha = node._percentage / 100.0; var locBarChangeRate = node._barChangeRate; var alphaOffset = cc.pMult(cc.p((1.0 - locBarChangeRate.x) + alpha * locBarChangeRate.x, (1.0 - locBarChangeRate.y) + alpha * locBarChangeRate.y), 0.5); - var min = cc.pSub(node._midPoint, alphaOffset); - var max = cc.pAdd(node._midPoint, alphaOffset); + var min = cc.pSub(node._midPoint, alphaOffset), max = cc.pAdd(node._midPoint, alphaOffset); if (min.x < 0) { max.x += -min.x; @@ -501,20 +393,20 @@ locVertexData = this._vertexData; // TOPLEFT - locVertexData[0].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); - locVertexData[0].vertices = node._vertexFromAlphaPoint(cc.p(min.x, max.y)); + locVertexData[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); + locVertexData[0].vertices = this._vertexFromAlphaPoint(cc.p(min.x, max.y)); // BOTLEFT - locVertexData[1].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); - locVertexData[1].vertices = node._vertexFromAlphaPoint(cc.p(min.x, min.y)); + locVertexData[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); + locVertexData[1].vertices = this._vertexFromAlphaPoint(cc.p(min.x, min.y)); // TOPRIGHT - locVertexData[2].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); - locVertexData[2].vertices = node._vertexFromAlphaPoint(cc.p(max.x, max.y)); + locVertexData[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); + locVertexData[2].vertices = this._vertexFromAlphaPoint(cc.p(max.x, max.y)); // BOTRIGHT - locVertexData[3].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); - locVertexData[3].vertices = node._vertexFromAlphaPoint(cc.p(max.x, min.y)); + locVertexData[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); + locVertexData[3].vertices = this._vertexFromAlphaPoint(cc.p(max.x, min.y)); } else { if (!this._vertexData) { this._vertexDataCount = 8; @@ -524,44 +416,218 @@ for (i = 0; i < rLocCount; i++) rTempData[i] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, i * rVertexDataLen); // TOPLEFT 1 - rTempData[0].texCoords = node._textureCoordFromAlphaPoint(cc.p(0, 1)); - rTempData[0].vertices = node._vertexFromAlphaPoint(cc.p(0, 1)); + rTempData[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 1)); + rTempData[0].vertices = this._vertexFromAlphaPoint(cc.p(0, 1)); // BOTLEFT 1 - rTempData[1].texCoords = node._textureCoordFromAlphaPoint(cc.p(0, 0)); - rTempData[1].vertices = node._vertexFromAlphaPoint(cc.p(0, 0)); + rTempData[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 0)); + rTempData[1].vertices = this._vertexFromAlphaPoint(cc.p(0, 0)); // TOPRIGHT 2 - rTempData[6].texCoords = node._textureCoordFromAlphaPoint(cc.p(1, 1)); - rTempData[6].vertices = node._vertexFromAlphaPoint(cc.p(1, 1)); + rTempData[6].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 1)); + rTempData[6].vertices = this._vertexFromAlphaPoint(cc.p(1, 1)); // BOTRIGHT 2 - rTempData[7].texCoords = node._textureCoordFromAlphaPoint(cc.p(1, 0)); - rTempData[7].vertices = node._vertexFromAlphaPoint(cc.p(1, 0)); + rTempData[7].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 0)); + rTempData[7].vertices = this._vertexFromAlphaPoint(cc.p(1, 0)); this._vertexData = rTempData; } locVertexData = this._vertexData; // TOPRIGHT 1 - locVertexData[2].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); - locVertexData[2].vertices = node._vertexFromAlphaPoint(cc.p(min.x, max.y)); + locVertexData[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, max.y)); + locVertexData[2].vertices = this._vertexFromAlphaPoint(cc.p(min.x, max.y)); // BOTRIGHT 1 - locVertexData[3].texCoords = node._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); - locVertexData[3].vertices = node._vertexFromAlphaPoint(cc.p(min.x, min.y)); + locVertexData[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(min.x, min.y)); + locVertexData[3].vertices = this._vertexFromAlphaPoint(cc.p(min.x, min.y)); // TOPLEFT 2 - locVertexData[4].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); - locVertexData[4].vertices = node._vertexFromAlphaPoint(cc.p(max.x, max.y)); + locVertexData[4].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, max.y)); + locVertexData[4].vertices = this._vertexFromAlphaPoint(cc.p(max.x, max.y)); // BOTLEFT 2 - locVertexData[5].texCoords = node._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); - locVertexData[5].vertices = node._vertexFromAlphaPoint(cc.p(max.x, min.y)); + locVertexData[5].texCoords = this._textureCoordFromAlphaPoint(cc.p(max.x, min.y)); + locVertexData[5].vertices = this._vertexFromAlphaPoint(cc.p(max.x, min.y)); } this._updateColor(); }; + /** + *

    + * Update does the work of mapping the texture onto the triangles
    + * It now doesn't occur the cost of free/alloc data every update cycle.
    + * It also only changes the percentage point but no other points if they have not been modified.
    + *
    + * It now deals with flipped texture. If you run into this problem, just use the
    + * sprite property and enable the methods flipX, flipY.
    + *

    + * @private + */ + proto._updateRadial = function () { + var node = this._node; + if (!node._sprite) + return; + + var i, locMidPoint = node._midPoint; + var alpha = node._percentage / 100; + var angle = 2 * (cc.PI) * ( node._reverseDirection ? alpha : 1.0 - alpha); + + // We find the vector to do a hit detection based on the percentage + // We know the first vector is the one @ 12 o'clock (top,mid) so we rotate + // from that by the progress angle around the m_tMidpoint pivot + var topMid = cc.p(locMidPoint.x, 1); + var percentagePt = cc.pRotateByAngle(topMid, locMidPoint, angle); + + var index = 0; + var hit; + + if (alpha == 0) { + // More efficient since we don't always need to check intersection + // If the alpha is zero then the hit point is top mid and the index is 0. + hit = topMid; + index = 0; + } else if (alpha == 1) { + // More efficient since we don't always need to check intersection + // If the alpha is one then the hit point is top mid and the index is 4. + hit = topMid; + index = 4; + } else { + // We run a for loop checking the edges of the texture to find the + // intersection point + // We loop through five points since the top is split in half + + var min_t = cc.FLT_MAX; + var locProTextCoordsCount = cc.ProgressTimer.TEXTURE_COORDS_COUNT; + for (i = 0; i <= locProTextCoordsCount; ++i) { + var pIndex = (i + (locProTextCoordsCount - 1)) % locProTextCoordsCount; + + var edgePtA = this._boundaryTexCoord(i % locProTextCoordsCount); + var edgePtB = this._boundaryTexCoord(pIndex); + + // Remember that the top edge is split in half for the 12 o'clock position + // Let's deal with that here by finding the correct endpoints + if (i == 0) + edgePtB = cc.pLerp(edgePtA, edgePtB, 1 - locMidPoint.x); + else if (i == 4) + edgePtA = cc.pLerp(edgePtA, edgePtB, 1 - locMidPoint.x); + + // retPoint are returned by ccpLineIntersect + var retPoint = cc.p(0, 0); + if (cc.pLineIntersect(edgePtA, edgePtB, locMidPoint, percentagePt, retPoint)) { + // Since our hit test is on rays we have to deal with the top edge + // being in split in half so we have to test as a segment + if ((i == 0 || i == 4)) { + // s represents the point between edgePtA--edgePtB + if (!(0 <= retPoint.x && retPoint.x <= 1)) + continue; + } + // As long as our t isn't negative we are at least finding a + // correct hitpoint from m_tMidpoint to percentagePt. + if (retPoint.y >= 0) { + // Because the percentage line and all the texture edges are + // rays we should only account for the shortest intersection + if (retPoint.y < min_t) { + min_t = retPoint.y; + index = i; + } + } + } + } + + // Now that we have the minimum magnitude we can use that to find our intersection + hit = cc.pAdd(locMidPoint, cc.pMult(cc.pSub(percentagePt, locMidPoint), min_t)); + } + + // The size of the vertex data is the index from the hitpoint + // the 3 is for the m_tMidpoint, 12 o'clock point and hitpoint position. + var sameIndexCount = true; + if (this._vertexDataCount != index + 3) { + sameIndexCount = false; + this._vertexData = null; + this._vertexArrayBuffer = null; + this._vertexDataCount = 0; + } + + if (!this._vertexData) { + this._vertexDataCount = index + 3; + var locCount = this._vertexDataCount, vertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; + this._vertexArrayBuffer = new ArrayBuffer(locCount * vertexDataLen); + var locData = []; + for (i = 0; i < locCount; i++) + locData[i] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, i * vertexDataLen); + + this._vertexData = locData; + if(!this._vertexData){ + cc.log( "cc.ProgressTimer._updateRadial() : Not enough memory"); + return; + } + } + this._updateColor(); + + var locVertexData = this._vertexData; + if (!sameIndexCount) { + // First we populate the array with the m_tMidpoint, then all + // vertices/texcoords/colors of the 12 'o clock start and edges and the hitpoint + locVertexData[0].texCoords = this._textureCoordFromAlphaPoint(locMidPoint); + locVertexData[0].vertices = this._vertexFromAlphaPoint(locMidPoint); + + locVertexData[1].texCoords = this._textureCoordFromAlphaPoint(topMid); + locVertexData[1].vertices = this._vertexFromAlphaPoint(topMid); + + for (i = 0; i < index; i++) { + var alphaPoint = this._boundaryTexCoord(i); + locVertexData[i + 2].texCoords = this._textureCoordFromAlphaPoint(alphaPoint); + locVertexData[i + 2].vertices = this._vertexFromAlphaPoint(alphaPoint); + } + } + + // hitpoint will go last + locVertexData[this._renderCmd._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(hit); + locVertexData[this._renderCmd._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(hit); + }; + + proto._boundaryTexCoord = function (index) { + if (index < cc.ProgressTimer.TEXTURE_COORDS_COUNT) { + var locProTextCoords = cc.ProgressTimer.TEXTURE_COORDS; + if (this._node._reverseDirection) + return cc.p((locProTextCoords >> (7 - (index << 1))) & 1, (locProTextCoords >> (7 - ((index << 1) + 1))) & 1); + else + return cc.p((locProTextCoords >> ((index << 1) + 1)) & 1, (locProTextCoords >> (index << 1)) & 1); + } + return cc.p(0,0); + }; + + proto._textureCoordFromAlphaPoint = function (alpha) { + var locSprite = this._node._sprite; + if (!locSprite) { + return {u:0, v:0}; //new cc.Tex2F(0, 0); + } + var quad = locSprite.quad; + var min = cc.p(quad.bl.texCoords.u, quad.bl.texCoords.v); + var max = cc.p(quad.tr.texCoords.u, quad.tr.texCoords.v); + + // Fix bug #1303 so that progress timer handles sprite frame texture rotation + if (locSprite.textureRectRotated) { + var temp = alpha.x; + alpha.x = alpha.y; + alpha.y = temp; + } + return {u: min.x * (1 - alpha.x) + max.x * alpha.x, v: min.y * (1 - alpha.y) + max.y * alpha.y}; + }; + + proto._vertexFromAlphaPoint = function (alpha) { + var locSprite = this._node._sprite; + if (!locSprite) { + return {x: 0, y: 0}; + } + var quad = locSprite.quad; + var min = cc.p(quad.bl.vertices.x, quad.bl.vertices.y); + var max = cc.p(quad.tr.vertices.x, quad.tr.vertices.y); + return {x: min.x * (1 - alpha.x) + max.x * alpha.x, y: min.y * (1 - alpha.y) + max.y * alpha.y}; + }; + proto._updateColor = function(){ var node = this._node; if (!node._sprite || !this._vertexData) From b7ea5844763ce1f748eb916e6bda6316aeb82cb3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 24 Nov 2014 20:03:06 +0800 Subject: [PATCH 0950/1564] Fixed a bug that audio is undefined --- cocos2d/audio/CCAudio.js | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index ec3b37f592..425c6a514a 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -271,15 +271,6 @@ cc.Audio = cc.Class.extend({ }; }, - _recklessPlay: function(offset){ - if(!this._buffer) return; - var audio = this._context["createBufferSource"](); - audio.buffer = this._buffer; - audio["connect"](this._volume); - audio.loop = this.loop; - audio.start(0, offset || 0); - }, - _playOfAudio: function(){ var audio = this._element; if(audio){ @@ -673,7 +664,7 @@ cc.Audio = cc.Class.extend({ }, _audioPool: {}, - _maxAudioInstance: SWA ? 20 : 5, + _maxAudioInstance: 5, _effectVolume: 1, /** * Play sound effect. @@ -689,14 +680,7 @@ cc.Audio = cc.Class.extend({ if(!SWB){ //Must be forced to shut down //Because playing multichannel audio will be stuck in chrome 28 (android) - return; - }else if(SWA){ - var audio = loader.cache[url]; - if(!audio){ - cc.loader.load(url); - audio = loader.cache[url]; - } - return audio._recklessPlay(); + return null; } var effectList = this._audioPool[url]; @@ -713,9 +697,10 @@ cc.Audio = cc.Class.extend({ } if(effectList[i]){ - effectList[i].setVolume(this._effectVolume); - effectList[i].play(0, loop); - }else if(i > this._maxAudioInstance){ + audio = effectList[i]; + audio.setVolume(this._effectVolume); + audio.play(0, loop); + }else if(SWA && i > this._maxAudioInstance){ cc.log("Error: %s greater than %d", url, this._maxAudioInstance); }else{ var audio = loader.cache[url]; @@ -728,7 +713,6 @@ cc.Audio = cc.Class.extend({ audio.play(); effectList.push(audio); } - console.log(effectList.length) return audio; }, @@ -763,7 +747,9 @@ cc.Audio = cc.Class.extend({ * cc.audioEngine.pauseEffect(audioID); */ pauseEffect: function(audio){ - audio.pause(); + if(audio){ + audio.pause(); + } }, /** @@ -792,7 +778,8 @@ cc.Audio = cc.Class.extend({ * cc.audioEngine.resumeEffect(audioID); */ resumeEffect: function(audio){ - audio.resume(); + if(audio) + audio.resume(); }, /** @@ -819,7 +806,8 @@ cc.Audio = cc.Class.extend({ * cc.audioEngine.stopEffect(audioID); */ stopEffect: function(audio){ - audio.stop(); + if(audio) + audio.stop(); }, /** From f0b8d44ba8e3454a897466801225d0527625e517 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 24 Nov 2014 20:44:55 +0800 Subject: [PATCH 0951/1564] Armature renderCmd --- cocos2d/core/base-nodes/CCNodeRenderCmd.js | 4 +- extensions/cocostudio/armature/CCArmature.js | 113 ++----- .../armature/CCArmatureRenderCmd.js | 286 +++++++++++------- 3 files changed, 211 insertions(+), 192 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeRenderCmd.js index 28080d24e1..4f92d46e64 100644 --- a/cocos2d/core/base-nodes/CCNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeRenderCmd.js @@ -441,9 +441,7 @@ cc.Node.RenderCmd.prototype = { }; proto.setDirtyFlag = function (dirtyFlag) { - if (this._dirtyFlag === 0 && dirtyFlag !== 0) - cc.renderer.pushDirtyNode(this); - this._dirtyFlag = this._dirtyFlag | dirtyFlag; + cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); this._setCacheDirty(); }; diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index b6a49945a8..fb2c1b21d6 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -71,12 +71,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = true; this._realAnchorPointInPoints = cc.p(0, 0); name && ccs.Armature.prototype.init.call(this, name, parentBone); - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._rendererStartCmd = new ccs.Armature.CanvasRenderCmd(this); - this._rendererEndCmd = new ccs.Armature.CanvasRestoreRenderCmd(this); - }else{ - this._renderCmd = new ccs.Armature.WebGLRenderCmd(this); - } }, /** @@ -150,8 +144,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.animation.setAnimationData(animationData); } - if (cc._renderType === cc._RENDER_TYPE_WEBGL) - this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + + this._renderCmd.initShaderCache(); this.setCascadeOpacityEnabled(true); this.setCascadeColorEnabled(true); @@ -289,6 +283,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * @param {Number} [y] y of point */ setAnchorPoint: function(point, y){ + var cmd = this._renderCmd; var ax, ay; if(y !== undefined){ ax = point; @@ -302,29 +297,33 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var contentSize = this._contentSize ; locAnchorPoint.x = ax; locAnchorPoint.y = ay; - this._anchorPointInPoints.x = contentSize.width * locAnchorPoint.x - this._offsetPoint.x; - this._anchorPointInPoints.y = contentSize.height * locAnchorPoint.y - this._offsetPoint.y; + cmd._anchorPointInPoints.x = contentSize.width * locAnchorPoint.x - this._offsetPoint.x; + cmd._anchorPointInPoints.y = contentSize.height * locAnchorPoint.y - this._offsetPoint.y; this._realAnchorPointInPoints.x = contentSize.width * locAnchorPoint.x; this._realAnchorPointInPoints.y = contentSize.height * locAnchorPoint.y; - this.setNodeDirty(); + cmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); } }, _setAnchorX: function (x) { + var cmd = this._renderCmd, + anchorPointInPoint = cmd._anchorPointInPoints; if (this._anchorPoint.x === x) return; this._anchorPoint.x = x; - this._anchorPointInPoints.x = this._contentSize.width * x - this._offsetPoint.x; + anchorPointInPoint.x = this._contentSize.width * x - this._offsetPoint.x; this._realAnchorPointInPoints.x = this._contentSize.width * x; - this.setNodeDirty(); + cmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, _setAnchorY: function (y) { + var cmd = this._renderCmd, + anchorPointInPoint = cmd._anchorPointInPoints; if (this._anchorPoint.y === y) return; this._anchorPoint.y = y; - this._anchorPointInPoints.y = this._contentSize.height * y - this._offsetPoint.y; + anchorPointInPoint.y = this._contentSize.height * y - this._offsetPoint.y; this._realAnchorPointInPoints.y = this._contentSize.height * y; - this.setNodeDirty(); + cmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -398,30 +397,12 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ if (null == node) continue; - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - node.setShaderProgram(this._shaderProgram); + this._renderCmd.setShaderProgram(node); switch (selBone.getDisplayRenderNodeType()) { case ccs.DISPLAY_TYPE_SPRITE: - if(node instanceof ccs.Skin){ - if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - node.updateTransform(); - - var func = selBone.getBlendFunc(); - if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) - node.setBlendFunc(selBone.getBlendFunc()); - else { - if ((this._blendFunc.src == alphaPremultiplied.src && this._blendFunc.dst == alphaPremultiplied.dst) - && !node.getTexture().hasPremultipliedAlpha()) - node.setBlendFunc(alphaNonPremultipled); - else - node.setBlendFunc(this._blendFunc); - } - node.draw(ctx); - } else{ - node.visit(ctx); - } - } + if(node instanceof ccs.Skin) + this._renderCmd.updateChildPosition(ctx, node, selBone, alphaPremultiplied, alphaNonPremultipled); break; case ccs.DISPLAY_TYPE_ARMATURE: node.draw(ctx); @@ -431,8 +412,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ break; } } else if(selBone instanceof cc.Node) { - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - selBone.setShaderProgram(this._shaderProgram); + this._renderCmd.setShaderProgram(selBone); selBone.visit(ctx); // CC_NODE_DRAW_SETUP(); } @@ -457,48 +437,8 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.unscheduleUpdate(); }, - visit: null, - - _visitForCanvas: function(ctx){ - var context = ctx || cc._renderContext; - // quick return if not visible. children won't be drawn. - if (!this._visible) - return; - - context.save(); - this.transform(context); - - this.sortAllChildren(); - - if(this._rendererStartCmd) - cc.renderer.pushRenderCommand(this._rendererStartCmd); - this.draw(ctx); - if(this._rendererEndCmd) - cc.renderer.pushRenderCommand(this._rendererEndCmd); - - this._cacheDirty = false; - - context.restore(); - }, - - _visitForWebGL: function(){ - // quick return if not visible. children won't be drawn. - if (!this._visible) - return; - - var context = cc._renderContext, currentStack = cc.current_stack; - - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); - currentStack.top = this._stackMatrix; - - this.transform(); - - this.sortAllChildren(); - //this.draw(context); - cc.renderer.pushRenderCommand(this._renderCmd); - - currentStack.top = currentStack.stack.pop(); + visit: function(){ + this._renderCmd.visit(); }, /** @@ -714,15 +654,16 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ node._transformForRenderer(); } } + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new ccs.Armature.CanvasRenderCmd(this); + else + return new ccs.Armature.WebGLRenderCmd(this); } }); -if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForWebGL; -} else { - ccs.Armature.prototype.visit = ccs.Armature.prototype._visitForCanvas; -} - var _p = ccs.Armature.prototype; /** @expose */ diff --git a/extensions/cocostudio/armature/CCArmatureRenderCmd.js b/extensions/cocostudio/armature/CCArmatureRenderCmd.js index b6162d292d..8f753ddfa7 100644 --- a/extensions/cocostudio/armature/CCArmatureRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureRenderCmd.js @@ -22,112 +22,192 @@ THE SOFTWARE. ****************************************************************************/ -ccs.Armature.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -ccs.Armature.CanvasRenderCmd.prototype.constructor = ccs.Armature.CanvasRenderCmd; - -ccs.Armature.CanvasRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext; - var node = this._node; - context.save(); - node.transform(context); - var t = node._transformWorld; - ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); - - var locChildren = node._children; - for (var i = 0, len = locChildren.length; i< len; i++) { - var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { - var rn = selBone.getDisplayRenderNode(); - - if (null == rn) - continue; - - rn._transformForRenderer(); +(function(){ + + ccs.Armature.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = false; + + this._startRenderCmd = new cc.CustomRenderCmd(this, this._startCmdCallback); + this._RestoreRenderCmd = new cc.CustomRenderCmd(this, this._RestoreCmdCallback); + }; + + var proto = ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = ccs.Armature.CanvasRenderCmd; + + proto.rendering = function(ctx, scaleX, scaleY){ + }; + + proto._startCmdCallback = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + var node = this._node; + context.save(); + node.transform(); + var t = this._worldTransform; + ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); + + var locChildren = node._children; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var rn = selBone.getDisplayRenderNode(); + + if (null == rn) + continue; + +// rn._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); + } + } + }; + + proto._RestoreCmdCallback = function(ctx, scaleX, scaleY){ + this._cacheDirty = false; + ctx.restore(); + }; + + proto.initShaderCache = function(){}; + proto.setShaderProgram = function(){}; + proto.updateChildPosition = function(ctx, dis){ + dis.visit(ctx); + }; + + proto.visit = function(){ + var node = this._node; + var context = cc._renderContext; + // quick return if not visible. children won't be drawn. + if (!node._visible) + return; + + context.save(); +// this.transform(); + + node.sortAllChildren(); + + cc.renderer.pushRenderCommand(this); + cc.renderer.pushRenderCommand(this._startRenderCmd); + node.draw(ctx); + cc.renderer.pushRenderCommand(this._RestoreRenderCmd); + + this._cacheDirty = false; + + context.restore(); + }; +})(); + +(function(){ + + ccs.Armature.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = ccs.Armature.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = ccs.Armature.WebGLRenderCmd; + + proto.rendering = function (ctx) { + var _t = this._node; + + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadMatrix(_t._stackMatrix); + + //TODO REMOVE THIS FUNCTION + if (_t._parentBone == null && _t._batchNode == null) { + // CC_NODE_DRAW_SETUP(); } - } -}; - -ccs.Armature.CanvasRestoreRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -ccs.Armature.CanvasRestoreRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -ccs.Armature.CanvasRestoreRenderCmd.prototype.constructor = ccs.Armature.CanvasRestoreRenderCmd; - -ccs.Armature.CanvasRestoreRenderCmd.prototype.rendering = function(ctx, scaleX, scaleY){ - this._cacheDirty = false; - ctx.restore(); -}; - -ccs.Armature.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -ccs.Armature.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -ccs.Armature.WebGLRenderCmd.prototype.constructor = ccs.Armature.WebGLRenderCmd; - -ccs.Armature.WebGLRenderCmd.prototype.rendering = function (ctx) { - var _t = this._node; - - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadMatrix(_t._stackMatrix); - - //TODO REMOVE THIS FUNCTION - if (_t._parentBone == null && _t._batchNode == null) { - // CC_NODE_DRAW_SETUP(); - } - - var locChildren = _t._children; - var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; - for (var i = 0, len = locChildren.length; i < len; i++) { - var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); - - if (null == node) - continue; - - node.setShaderProgram(_t._shaderProgram); - - switch (selBone.getDisplayRenderNodeType()) { - case ccs.DISPLAY_TYPE_SPRITE: - if (node instanceof ccs.Skin) { - node.updateTransform(); - - var func = selBone.getBlendFunc(); - if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) - node.setBlendFunc(selBone.getBlendFunc()); - else { - if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) - && !node.getTexture().hasPremultipliedAlpha()) - node.setBlendFunc(alphaNonPremultipled); - else - node.setBlendFunc(_t._blendFunc); + + var locChildren = _t._children; + var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + for (var i = 0, len = locChildren.length; i < len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + node.setShaderProgram(_t._shaderProgram); + + switch (selBone.getDisplayRenderNodeType()) { + case ccs.DISPLAY_TYPE_SPRITE: + if (node instanceof ccs.Skin) { + node.updateTransform(); + + var func = selBone.getBlendFunc(); + if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + node.setBlendFunc(selBone.getBlendFunc()); + else { + if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) + && !node.getTexture().hasPremultipliedAlpha()) + node.setBlendFunc(alphaNonPremultipled); + else + node.setBlendFunc(_t._blendFunc); + } + node.draw(ctx); } + break; + case ccs.DISPLAY_TYPE_ARMATURE: node.draw(ctx); - } - break; - case ccs.DISPLAY_TYPE_ARMATURE: - node.draw(ctx); - break; - default: - node.visit(ctx); //TODO need fix soon - break; + break; + default: + node.visit(ctx); //TODO need fix soon + break; + } + } else if (selBone instanceof cc.Node) { + selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon + selBone.visit(ctx); + // CC_NODE_DRAW_SETUP(); } - } else if (selBone instanceof cc.Node) { - selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon - selBone.visit(ctx); - // CC_NODE_DRAW_SETUP(); } - } - cc.kmGLPopMatrix(); -}; \ No newline at end of file + cc.kmGLPopMatrix(); + }; + + proto.initShaderCache = function(){ + var node = this._node; + node.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + }; + + proto.setShaderProgram = function(child){ + var node = this._node; + child.setShaderProgram(node._shaderProgram); + }; + + proto.updateChildPosition = function(ctx, dis, selBone, alphaPremultiplied, alphaNonPremultipled){ + var node = this._node; + dis.updateTransform(); + + var func = selBone.getBlendFunc(); + if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + dis.setBlendFunc(selBone.getBlendFunc()); + else { + if ((node._blendFunc.src == alphaPremultiplied.src && node_blendFunc.dst == alphaPremultiplied.dst) + && !dis.getTexture().hasPremultipliedAlpha()) + dis.setBlendFunc(alphaNonPremultipled); + else + dis.setBlendFunc(node._blendFunc); + } + dis.draw(ctx); + }; + + proto.visit = function(){ + var node = this._node; + // quick return if not visible. children won't be drawn. + if (!node._visible) + return; + + var /*context = cc._renderContext, */currentStack = cc.current_stack; + + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(node._stackMatrix, currentStack.top); + currentStack.top = node._stackMatrix; + + node.transform(); + + node.sortAllChildren(); + //this.draw(context); + cc.renderer.pushRenderCommand(this); + + currentStack.top = currentStack.stack.pop(); + }; +})(); \ No newline at end of file From 18262486225b183f9d1ddd9c02b0b867ca5fe441 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 24 Nov 2014 20:45:31 +0800 Subject: [PATCH 0952/1564] Issue 2416: modify CCSpriteRenderCmd.js for setColor --- cocos2d/core/sprites/CCSpriteRenderCmd.js | 64 ++++++++++++----------- cocos2d/tilemap/CCTMXLayer.js | 2 - cocos2d/tilemap/CCTMXLayerRenderCmd.js | 6 --- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteRenderCmd.js index 223b2931d6..418c023062 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteRenderCmd.js @@ -62,8 +62,7 @@ this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty); }; - proto.isFrameDisplayed = function (frame) { - //TODO there maybe has a bug + proto.isFrameDisplayed = function (frame) { //TODO there maybe has a bug var node = this._node; if (frame.getTexture() != node._texture) return false; @@ -242,41 +241,40 @@ }; proto._changeTextureColor = function () { - if (!cc.sys._supportCanvasNewBlendModes) { - var locElement, locTexture = this._texture, locRect = this._renderCmd._textureCoord; - if (locTexture && locRect.validRect && this._originalTexture) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; - - if (!cc.sys._supportCanvasNewBlendModes) { - var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); - if (cacheTextureForColor) { - this._colorized = true; - //generate color texture cache - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); - else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - this.texture = locTexture; - } - } - } else { + var node = this._node; + var locElement, locTexture = node._texture, locRect = this._textureCoord; + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + + if (!cc.sys._supportCanvasNewBlendModes) { + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); + if (cacheTextureForColor) { this._colorized = true; - if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor - && this._originalTexture._htmlElementObj != locElement) - cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); + //generate color texture cache + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); - this.texture = locTexture; + node.texture = locTexture; } } + } else { + this._colorized = true; + if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor + && this._originalTexture._htmlElementObj != locElement) + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.texture = locTexture; + } } } }; @@ -333,9 +331,13 @@ this._changeTextureColor(); }; + proto._syncDisplayColor = function(parentColor){ + cc.Node.CanvasRenderCmd.prototype._syncDisplayColor.call(this, parentColor); + this._changeTextureColor(); + }; + proto._spriteFrameLoadedCallback = function (spriteFrame) { var _t = this; - _t.setNodeDirty(true); _t.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); //TODO change diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 7285ea74cd..e556edbca8 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -78,8 +78,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ //used for retina display _contentScaleFactor: null, - _cacheContext:null, - _cacheTexture:null, _className:"TMXLayer", /** diff --git a/cocos2d/tilemap/CCTMXLayerRenderCmd.js b/cocos2d/tilemap/CCTMXLayerRenderCmd.js index bfb77282a7..e2f6f69ca5 100644 --- a/cocos2d/tilemap/CCTMXLayerRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerRenderCmd.js @@ -250,11 +250,5 @@ proto._updateCacheContext = function(){}; - proto.getTexture = cc.SpriteBatchNode.prototype.getTexture; - - proto.visit = cc.SpriteBatchNode.prototype.visit; - - proto.draw = cc.SpriteBatchNode.prototype.draw; - proto._initContentSize = function(){}; })(); From be40f4fd728b7b1a8c518688fce6076f8eba290b Mon Sep 17 00:00:00 2001 From: Park Hyun Chen Date: Mon, 24 Nov 2014 22:57:11 +0900 Subject: [PATCH 0953/1564] Fixed a bug that playEffect's loop doesn't work --- cocos2d/audio/CCAudio.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 425c6a514a..a0bf2f8a71 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -710,6 +710,7 @@ cc.Audio = cc.Class.extend({ } audio = audio.cloneNode(); audio.setVolume(this._effectVolume); + audio.loop = loop || false; audio.play(); effectList.push(audio); } @@ -915,4 +916,4 @@ cc.Audio = cc.Class.extend({ }); -})(cc.__audioSupport); \ No newline at end of file +})(cc.__audioSupport); From ffcc7a50e14eb07b158be91362e99812755ff857 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 10:07:42 +0800 Subject: [PATCH 0954/1564] Split module --- .../CCClippingNodeCanvasRenderCmd.js | 216 ++++++++ ...Cmd.js => CCClippingNodeWebGLRenderCmd.js} | 193 ------- .../base-nodes/CCAtlasNodeCanvasRenderCmd.js | 138 +++++ ...derCmd.js => CCAtlasNodeWebGLRenderCmd.js} | 115 ---- ...eRenderCmd.js => CCNodeCanvasRenderCmd.js} | 0 .../core/base-nodes/CCNodeWebGLRenderCmd.js | 499 ++++++++++++++++++ ...derCmd.js => CCLabelTTFCanvasRenderCmd.js} | 20 - .../core/labelttf/CCLabelTTFWebGLRenderCmd.js | 43 ++ ...RenderCmd.js => CCLayerCanvasRenderCmd.js} | 204 ------- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 233 ++++++++ .../CCSpriteBatchNodeCanvasRenderCmd.js | 68 +++ ....js => CCSpriteBatchNodeWebGLRenderCmd.js} | 45 -- ...enderCmd.js => CCSpriteCanvasRenderCmd.js} | 443 ---------------- .../core/sprites/CCSpriteWebGLRenderCmd.js | 465 ++++++++++++++++ cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js | 89 ++++ ...erCmd.js => CCLabelAtlasWebGLRenderCmd.js} | 66 --- ...Cmd.js => CCLabelBMFontCanvasRenderCmd.js} | 61 --- cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js | 91 ++++ ...Cmd.js => CCMotionStreakWebGLRenderCmd.js} | 0 .../CCParticleBatchNodeCanvasRenderCmd.js | 38 ++ ...s => CCParticleBatchNodeWebGLRenderCmd.js} | 15 - .../CCParticleSystemCanvasRenderCmd.js | 220 ++++++++ ...d.js => CCParticleSystemWebGLRenderCmd.js} | 197 ------- ...s => CCPhysicsDebugNodeCanvasRenderCmd.js} | 21 - .../CCPhysicsDebugNodeWebGLRenderCmd.js | 44 ++ ...d.js => CCPhysicsSpriteCanvasRenderCmd.js} | 0 .../physics/CCPhysicsSpriteWebGLRenderCmd.js | 94 ++++ .../CCRenderTextureCanvasRenderCmd.js | 153 ++++++ ...md.js => CCRenderTextureWebGLRenderCmd.js} | 131 ----- .../shape-nodes/CCDrawNodeCanvasRenderCmd.js | 124 +++++ cocos2d/shape-nodes/CCDrawNodeRenderCmd.js | 136 ----- .../shape-nodes/CCDrawNodeWebGlRenderCmd.js | 42 ++ ...derCmd.js => CCTMXLayerCanvasRenderCmd.js} | 16 +- cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js | 37 ++ .../armature/CCArmatureCanvasRenderCmd.js | 95 ++++ ...nderCmd.js => CCArmatureWebGLRenderCmd.js} | 72 --- moduleConfig.json | 53 +- 37 files changed, 2725 insertions(+), 1752 deletions(-) create mode 100644 cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js rename cocos2d/clipping-nodes/{CCClippingNodeRenderCmd.js => CCClippingNodeWebGLRenderCmd.js} (58%) create mode 100644 cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js rename cocos2d/core/base-nodes/{CCAtlasNodeRenderCmd.js => CCAtlasNodeWebGLRenderCmd.js} (57%) rename cocos2d/core/base-nodes/{CCNodeRenderCmd.js => CCNodeCanvasRenderCmd.js} (100%) create mode 100644 cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js rename cocos2d/core/labelttf/{CCLabelTTFRenderCmd.js => CCLabelTTFCanvasRenderCmd.js} (93%) create mode 100644 cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js rename cocos2d/core/layers/{CCLayerRenderCmd.js => CCLayerCanvasRenderCmd.js} (65%) create mode 100644 cocos2d/core/layers/CCLayerWebGLRenderCmd.js create mode 100644 cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js rename cocos2d/core/sprites/{CCSpriteBatchNodeRenderCmd.js => CCSpriteBatchNodeWebGLRenderCmd.js} (85%) rename cocos2d/core/sprites/{CCSpriteRenderCmd.js => CCSpriteCanvasRenderCmd.js} (57%) create mode 100644 cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js create mode 100644 cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js rename cocos2d/labels/{CCLabelAtlasRenderCmd.js => CCLabelAtlasWebGLRenderCmd.js} (69%) rename cocos2d/labels/{CCLabelBMFontRenderCmd.js => CCLabelBMFontCanvasRenderCmd.js} (76%) create mode 100644 cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js rename cocos2d/motion-streak/{CCMotionStreakRenderCmd.js => CCMotionStreakWebGLRenderCmd.js} (100%) create mode 100644 cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js rename cocos2d/particle/{CCParticleBatchNodeRenderCmd.js => CCParticleBatchNodeWebGLRenderCmd.js} (86%) create mode 100644 cocos2d/particle/CCParticleSystemCanvasRenderCmd.js rename cocos2d/particle/{CCParticleSystemRenderCmd.js => CCParticleSystemWebGLRenderCmd.js} (67%) rename cocos2d/physics/{CCPhysicsDebugNodeRenderCmd.js => CCPhysicsDebugNodeCanvasRenderCmd.js} (79%) create mode 100644 cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js rename cocos2d/physics/{CCPhysicsSpriteRenderCmd.js => CCPhysicsSpriteCanvasRenderCmd.js} (100%) create mode 100644 cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js create mode 100644 cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js rename cocos2d/render-texture/{CCRenderTextureRenderCmd.js => CCRenderTextureWebGLRenderCmd.js} (78%) create mode 100644 cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js delete mode 100644 cocos2d/shape-nodes/CCDrawNodeRenderCmd.js create mode 100644 cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js rename cocos2d/tilemap/{CCTMXLayerRenderCmd.js => CCTMXLayerCanvasRenderCmd.js} (96%) create mode 100644 cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js create mode 100644 extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js rename extensions/cocostudio/armature/{CCArmatureRenderCmd.js => CCArmatureWebGLRenderCmd.js} (72%) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js new file mode 100644 index 0000000000..17240bace6 --- /dev/null +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -0,0 +1,216 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +//-------------------------- ClippingNode's canvas render cmd -------------------------------- +(function(){ + cc.ClippingNode.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; + this._godhelpme = false; + this._clipElemType = null; + + this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._saveCmdCallback); + this._rendererClipCmd = new cc.CustomRenderCmd(this, this._clipCmdCallback); + this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._restoreCmdCallback); + }; + var proto = cc.ClippingNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ClippingNode.CanvasRenderCmd; + + proto.initStencilBits = function(){}; + + proto.setStencil = function(stencil){ + if(stencil == null) + return; + + this._node._stencil = stencil; + // For texture stencil, use the sprite itself + //if (stencil instanceof cc.Sprite) { + // return; + //} + // For shape stencil, rewrite the draw of stencil ,only init the clip path and draw nothing. + //else + if (stencil instanceof cc.DrawNode) { + if(stencil._buffer){ + for(var i=0; i 0) { + this.sortAllChildren(); + for (i = 0; i < len; i++) + children[i]._renderCmd.visit(this); + } + this._cangodhelpme(false); + } + + cc.renderer.pushRenderCommand(this._rendererRestoreCmd); + }; + + cc.ClippingNode.CanvasRenderCmd._sharedCache = null; + cc.ClippingNode.CanvasRenderCmd._getSharedCache = function () { + return (cc.ClippingNode.CanvasRenderCmd._sharedCache) || (cc.ClippingNode.CanvasRenderCmd._sharedCache = document.createElement("canvas")); + }; +})(); \ No newline at end of file diff --git a/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js similarity index 58% rename from cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js rename to cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js index 446e5cc1f6..ea58b64440 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js @@ -22,199 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -//-------------------------- ClippingNode's canvas render cmd -------------------------------- -(function(){ - cc.ClippingNode.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; - this._godhelpme = false; - this._clipElemType = null; - - this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._saveCmdCallback); - this._rendererClipCmd = new cc.CustomRenderCmd(this, this._clipCmdCallback); - this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._restoreCmdCallback); - }; - var proto = cc.ClippingNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.ClippingNode.CanvasRenderCmd; - - proto.initStencilBits = function(){}; - - proto.setStencil = function(stencil){ - if(stencil == null) - return; - - this._node._stencil = stencil; - // For texture stencil, use the sprite itself - //if (stencil instanceof cc.Sprite) { - // return; - //} - // For shape stencil, rewrite the draw of stencil ,only init the clip path and draw nothing. - //else - if (stencil instanceof cc.DrawNode) { - if(stencil._buffer){ - for(var i=0; i 0) { - this.sortAllChildren(); - for (i = 0; i < len; i++) - children[i]._renderCmd.visit(this); - } - this._cangodhelpme(false); - } - - cc.renderer.pushRenderCommand(this._rendererRestoreCmd); - }; - - cc.ClippingNode.CanvasRenderCmd._sharedCache = null; - cc.ClippingNode.CanvasRenderCmd._getSharedCache = function () { - return (cc.ClippingNode.CanvasRenderCmd._sharedCache) || (cc.ClippingNode.CanvasRenderCmd._sharedCache = document.createElement("canvas")); - }; -})(); - // ------------------------------- ClippingNode's WebGL render cmd ------------------------------ (function(){ cc.ClippingNode.WebGLRenderCmd = function(renderable){ diff --git a/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js new file mode 100644 index 0000000000..ea85928db8 --- /dev/null +++ b/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js @@ -0,0 +1,138 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * cc.AtlasNode's rendering objects of Canvas + */ +(function(){ + cc.AtlasNode.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = false; + this._colorUnmodified = cc.color.WHITE; + this._originalTexture = null; + this._texture = null; + }; + + var proto = cc.AtlasNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.AtlasNode.CanvasRenderCmd; + + proto.initWithTexture = function(texture, tileWidth, tileHeight, itemsToRender){ + var node = this._node; + node._itemWidth = tileWidth; + node._itemHeight = tileHeight; + + node._opacityModifyRGB = true; + this._originalTexture = texture; + if (!this._originalTexture) { + cc.log(cc._LogInfos.AtlasNode__initWithTexture); + return false; + } + this._texture = this._originalTexture; + this._calculateMaxItems(); + + node.quadsToDraw = itemsToRender; + return true; + }; + + proto.setColor = function(color3){ + var node = this._node; + var locRealColor = node._realColor; + if ((locRealColor.r == color3.r) && (locRealColor.g == color3.g) && (locRealColor.b == color3.b)) + return; + this._colorUnmodified = color3; + this._changeTextureColor(); + }; + + if(cc.sys._supportCanvasNewBlendModes) + proto._changeTextureColor = function(){ + var node = this._node; + var locTexture = node.getTexture(); + if (locTexture && this._originalTexture) { + var element = this._originalTexture.getHtmlElementObj(); + if(!element) + return; + var locElement = locTexture.getHtmlElementObj(); + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement) + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.setTexture(locTexture); + } + } + }; + else + proto._changeTextureColor = function(){ + var node = this._node; + var locElement, locTexture = node.getTexture(); + if (locTexture && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + var element = this._originalTexture.getHtmlElementObj(); + var cacheTextureForColor = cc.textureCache.getTextureColors(element); + if (cacheTextureForColor) { + var textureRect = cc.rect(0, 0, element.width, element.height); + if (locElement instanceof HTMLCanvasElement) + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect, locElement); + else { + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.setTexture(locTexture); + } + } + } + }; + + proto.setOpacity = function(opacity){ + var node = this._node; + cc.Node.prototype.setOpacity.call(node, opacity); + // special opacity for premultiplied textures + if (node._opacityModifyRGB) { + node.color = this._colorUnmodified; + } + }; + + proto.getTexture = function(){ + return this._texture; + }; + + proto.setTexture = function (texture) { + this._texture = texture; + }; + + proto._calculateMaxItems = function(){ + var node = this._node; + var selTexture = this._texture; + var size = selTexture.getContentSize(); + + node._itemsPerColumn = 0 | (size.height / node._itemHeight); + node._itemsPerRow = 0 | (size.width / node._itemWidth); + }; +})(); diff --git a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js similarity index 57% rename from cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js rename to cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js index 341ce7febb..8ccb0009dc 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js @@ -22,121 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * cc.AtlasNode's rendering objects of Canvas - */ -(function(){ - cc.AtlasNode.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = false; - this._colorUnmodified = cc.color.WHITE; - this._originalTexture = null; - this._texture = null; - }; - - var proto = cc.AtlasNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.AtlasNode.CanvasRenderCmd; - - proto.initWithTexture = function(texture, tileWidth, tileHeight, itemsToRender){ - var node = this._node; - node._itemWidth = tileWidth; - node._itemHeight = tileHeight; - - node._opacityModifyRGB = true; - this._originalTexture = texture; - if (!this._originalTexture) { - cc.log(cc._LogInfos.AtlasNode__initWithTexture); - return false; - } - this._texture = this._originalTexture; - this._calculateMaxItems(); - - node.quadsToDraw = itemsToRender; - return true; - }; - - proto.setColor = function(color3){ - var node = this._node; - var locRealColor = node._realColor; - if ((locRealColor.r == color3.r) && (locRealColor.g == color3.g) && (locRealColor.b == color3.b)) - return; - this._colorUnmodified = color3; - this._changeTextureColor(); - }; - - if(cc.sys._supportCanvasNewBlendModes) - proto._changeTextureColor = function(){ - var node = this._node; - var locTexture = node.getTexture(); - if (locTexture && this._originalTexture) { - var element = this._originalTexture.getHtmlElementObj(); - if(!element) - return; - var locElement = locTexture.getHtmlElementObj(); - var textureRect = cc.rect(0, 0, element.width, element.height); - if (locElement instanceof HTMLCanvasElement) - cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect, locElement); - else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, this._colorUnmodified, textureRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - node.setTexture(locTexture); - } - } - }; - else - proto._changeTextureColor = function(){ - var node = this._node; - var locElement, locTexture = node.getTexture(); - if (locTexture && this._originalTexture) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; - var element = this._originalTexture.getHtmlElementObj(); - var cacheTextureForColor = cc.textureCache.getTextureColors(element); - if (cacheTextureForColor) { - var textureRect = cc.rect(0, 0, element.width, element.height); - if (locElement instanceof HTMLCanvasElement) - cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect, locElement); - else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, textureRect); - locTexture = new cc.Texture2D(); - locTexture.initWithElement(locElement); - locTexture.handleLoadedTexture(); - node.setTexture(locTexture); - } - } - } - }; - - proto.setOpacity = function(opacity){ - var node = this._node; - cc.Node.prototype.setOpacity.call(node, opacity); - // special opacity for premultiplied textures - if (node._opacityModifyRGB) { - node.color = this._colorUnmodified; - } - }; - - proto.getTexture = function(){ - return this._texture; - }; - - proto.setTexture = function (texture) { - this._texture = texture; - }; - - proto._calculateMaxItems = function(){ - var node = this._node; - var selTexture = this._texture; - var size = selTexture.getContentSize(); - - node._itemsPerColumn = 0 | (size.height / node._itemHeight); - node._itemsPerRow = 0 | (size.width / node._itemWidth); - }; -})(); - /** * cc.AtlasNode's rendering objects of WebGL */ diff --git a/cocos2d/core/base-nodes/CCNodeRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js similarity index 100% rename from cocos2d/core/base-nodes/CCNodeRenderCmd.js rename to cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js new file mode 100644 index 0000000000..4186419b4d --- /dev/null +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -0,0 +1,499 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +//---------------------- Customer render cmd -------------------- +cc.CustomRenderCmd = function (target, func) { + this._needDraw = true; + this._target = target; + this._callback = func; + + this.rendering = function (ctx, scaleX, scaleY) { + if (!this._callback) + return; + this._callback.call(this._target, ctx, scaleX, scaleY); + } +}; + + +cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty:16, orderDirty:32, textDirty:64}; + +//-------------------------Base ------------------------- +cc.Node.RenderCmd = function(renderable){ + this._dirtyFlag = 0; + + this._node = renderable; + this._needDraw = false; + this._anchorPointInPoints = new cc.Point(0,0); + + this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._worldTransform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + this._inverse = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; + + this._displayedOpacity = 255; + this._displayedColor = cc.color(255, 255, 255, 255); + this._cascadeColorEnabledDirty = false; + this._cascadeOpacityEnabledDirty = false; + + this._curLevel = -1; +}; + +cc.Node.RenderCmd.prototype = { + constructor: cc.Node.RenderCmd, + + getAnchorPointInPoints: function(){ + return cc.p(this._anchorPointInPoints); + }, + + getDisplayedColor: function(){ + var tmpColor = this._displayedColor; + return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); + }, + + getDisplayedOpacity: function(){ + return this._displayedOpacity; + }, + + setCascadeColorEnabledDirty: function(){ + this._cascadeColorEnabledDirty = true; + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); + }, + + setCascadeOpacityEnabledDirty:function(){ + this._cascadeOpacityEnabledDirty = true; + this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); + }, + + getParentToNodeTransform: function(){ + if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) + this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()); + return this._inverse; + }, + + detachFromParent: function(){ + }, + + _updateAnchorPointInPoint: function() { + var locAPP = this._anchorPointInPoints, locSize = this._node._contentSize, locAnchorPoint = this._node._anchorPoint; + locAPP.x = locSize.width * locAnchorPoint.x; + locAPP.y = locSize.height * locAnchorPoint.y; + this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); + }, + + setDirtyFlag: function(dirtyFlag){ + if (this._dirtyFlag === 0 && dirtyFlag !== 0) + cc.renderer.pushDirtyNode(this); + this._dirtyFlag = this._dirtyFlag | dirtyFlag; + }, + + getParentRenderCmd: function(){ + if(this._node && this._node._parent && this._node._parent._renderCmd) + return this._node._parent._renderCmd; + return null; + }, + + _syncDisplayColor : function (parentColor) { + var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; + if (parentColor === undefined) { + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + }, + + _syncDisplayOpacity : function (parentOpacity) { + var node = this._node; + if (parentOpacity === undefined) { + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + } +}; + +//-----------------------Canvas --------------------------- + +(function() { +//The cc.Node's render command for Canvas + cc.Node.CanvasRenderCmd = function (renderable) { + cc.Node.RenderCmd.call(this, renderable); + this._cachedParent = null; + this._cacheDirty = false; + }; + + var proto = cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); + proto.constructor = cc.Node.CanvasRenderCmd; + + proto.transform = function (parentCmd, recursive) { + // transform for canvas + var t = this.getNodeToParentTransform(), + worldT = this._worldTransform; //get the world transform + + if (parentCmd) { + var pt = parentCmd._worldTransform; + // cc.AffineTransformConcat is incorrect at get world transform + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d + + var plt = parentCmd._transform; + var xOffset = -(plt.b + plt.c) * t.ty; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + } else { + worldT.a = t.a; + worldT.b = t.b; + worldT.c = t.c; + worldT.d = t.d; + worldT.tx = t.tx; + worldT.ty = t.ty; + } + this._renderCmdDiry = false; + if (recursive) { + var locChildren = this._node._children; + if (!locChildren || locChildren.length === 0) + return; + var i, len; + for (i = 0, len = locChildren.length; i < len; i++) { + locChildren[i]._renderCmd.transform(this, recursive); + } + } + }; + + proto.getNodeToParentTransform = function () { + var node = this._node, normalizeDirty = false; + if (node._usingNormalizedPosition && node._parent) { //TODO need refactor + var conSize = node._parent._contentSize; + node._position.x = node._normalizedPosition.x * conSize.width; + node._position.y = node._normalizedPosition.y * conSize.height; + node._normalizedPositionDirty = false; + normalizeDirty = true; + } + if (normalizeDirty || (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty)) { + var t = this._transform;// quick reference + + // base position + t.tx = node._position.x; + t.ty = node._position.y; + + // rotation Cos and Sin + var Cos = 1, Sin = 0; + if (node._rotationX) { + var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance + Cos = Math.cos(rotationRadiansX); + Sin = Math.sin(rotationRadiansX); + } + + // base abcd + t.a = t.d = Cos; + t.b = -Sin; + t.c = Sin; + + var lScaleX = node._scaleX, lScaleY = node._scaleY; + var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; + + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + + // skew + if (node._skewX || node._skewY) { + // offset the anchorpoint + var skx = Math.tan(-node._skewX * Math.PI / 180); //TODO + var sky = Math.tan(-node._skewY * Math.PI / 180); + if (skx === Infinity) + skx = 99999999; + if (sky === Infinity) + sky = 99999999; + var xx = appY * skx * sx; + var yy = appX * sky * sy; + t.a = Cos + -Sin * sky; + t.b = Cos * skx + -Sin; + t.c = Sin + Cos * sky; + t.d = Sin * skx + Cos; + t.tx += Cos * xx + -Sin * yy; + t.ty += Sin * xx + Cos * yy; + } + + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + t.a *= sx; + t.c *= sx; + t.b *= sy; + t.d *= sy; + } + + // adjust anchorPoint + t.tx += Cos * -appX * sx + -Sin * appY * sy; + t.ty -= Sin * -appX * sx + Cos * appY * sy; + + // if ignore anchorPoint + if (node._ignoreAnchorPointForPosition) { + t.tx += appX; + t.ty += appY; + } + + if (node._additionalTransformDirty) { + this._transform = cc.affineTransformConcat(t, node._additionalTransform); + node._additionalTransformDirty = false; + } + this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; + } + return this._transform; + }; + + proto.visit = function (parentCmd) { + var _t = this, node = this._node; + // quick return if not visible + if (!node._visible) + return; + + parentCmd = parentCmd || this.getParentRenderCmd(); + if (parentCmd) + this._curLevel = parentCmd._curLevel + 1; + + //visit for canvas + var i, children = node._children, child; + _t._syncStatus(parentCmd); + var len = children.length; + if (len > 0) { + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < len; i++) { + child = children[i]; + if (child._localZOrder < 0) + child._renderCmd.visit(this); + else + break; + } + cc.renderer.pushRenderCommand(this); + for (; i < len; i++) + children[i]._renderCmd.visit(this); + } else { + cc.renderer.pushRenderCommand(this); + } + }; + + proto.updateStatus = function () { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._updateDisplayColor() + } + + if (locFlag & flags.opacityDirty) { + //update the opacity + this._updateDisplayOpacity(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(this.getParentRenderCmd(), true); + } + }; + + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._syncDisplayColor() + } + + if (locFlag & flags.opacityDirty) { + //update the opacity + this._syncDisplayOpacity(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } + }; + + proto._syncDisplayColor = function (parentColor) { + var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; + if (parentColor === undefined) { + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + }; + + proto._syncDisplayOpacity = function (parentOpacity) { + var node = this._node; + if (parentOpacity === undefined) { + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + }; + + proto._updateDisplayColor = function (parentColor) { + var node = this._node; + var locDispColor = this._displayedColor, locRealColor = node._realColor; + var i, len, selChildren, item; + if (this._cascadeColorEnabledDirty && !node._cascadeColorEnabled) { + locDispColor.r = locRealColor.r; + locDispColor.g = locRealColor.g; + locDispColor.b = locRealColor.b; + var whiteColor = new cc.Color(255, 255, 255, 255); + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(whiteColor); + } + } else { + if (parentColor === undefined) { + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + if (node._cascadeColorEnabled) { + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(locDispColor); + } + } + } + this._cascadeColorEnabledDirty = false; + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + }; + + proto._updateDisplayOpacity = function (parentOpacity) { + var node = this._node; + var i, len, selChildren, item; + if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { + this._displayedOpacity = node._realOpacity; + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(255); + } + } else { + if (parentOpacity === undefined) { + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + if (this._cascadeOpacityEnabled) { + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + } + } + } + this._cascadeOpacityEnabledDirty = false; + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + }; + + proto.setDirtyFlag = function (dirtyFlag) { + cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); + this._setCacheDirty(); + }; + + proto._setCacheDirty = function () { + if (this._cacheDirty === false) { + this._cacheDirty = true; + var cachedP = this._cachedParent; + cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); + } + }; + + proto._setCachedParent = function (cachedParent) { + if (this._cachedParent == cachedParent) + return; + + this._cachedParent = cachedParent; + var children = this._children; + for (var i = 0, len = children.length; i < len; i++) + children[i]._renderCmd._setCachedParent(cachedParent); + }; + + proto.detachFromParent = function () { + this._cachedParent = null; + var selChildren = this._node._children, item; + for (var i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd.detachFromParent(); + } + }; + + proto.setShaderProgram = function (shaderProgram) { + //do nothing. + }; + + proto.getShaderProgram = function () { + return null; + }; + +//util functions + cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function (blendFunc) { + if (!blendFunc) + return "source-over"; + else { + if (( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) + return "lighter"; + else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) + return "destination-in"; + else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) + return "destination-out"; + else + return "source-over"; + } + }; +})(); \ No newline at end of file diff --git a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js similarity index 93% rename from cocos2d/core/labelttf/CCLabelTTFRenderCmd.js rename to cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 132bb1c78f..5c62697124 100644 --- a/cocos2d/core/labelttf/CCLabelTTFRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -409,24 +409,4 @@ cc.LabelTTF.CanvasRenderCmd.prototype._setColorsString = function(){ + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; -}; - -// ----------------------------------- LabelTTF WebGL render cmd ---------------------------- - -cc.LabelTTF.WebGLRenderCmd = function(renderable){ - cc.Sprite.WebGLRenderCmd.call(this, renderable); - cc.LabelTTF.RenderCmd.call(this); -}; - -cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); -cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit -cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; - -cc.LabelTTF.WebGLRenderCmd.prototype._setColorsString = function(){ - this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); - var node = this._node; - var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; - this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; - this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; - this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; }; \ No newline at end of file diff --git a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js new file mode 100644 index 0000000000..82828686d9 --- /dev/null +++ b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +// ----------------------------------- LabelTTF WebGL render cmd ---------------------------- + +cc.LabelTTF.WebGLRenderCmd = function(renderable){ + cc.Sprite.WebGLRenderCmd.call(this, renderable); + cc.LabelTTF.RenderCmd.call(this); +}; + +cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); +cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit +cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; + +cc.LabelTTF.WebGLRenderCmd.prototype._setColorsString = function(){ + this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); + var node = this._node; + var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; + this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; + this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; + this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; +}; \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayerRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js similarity index 65% rename from cocos2d/core/layers/CCLayerRenderCmd.js rename to cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 54b6f5f78b..62e9202f66 100644 --- a/cocos2d/core/layers/CCLayerRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -439,208 +439,4 @@ this._endStopStr = "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + Math.round(locEndColor.b) + "," + endOpacity.toFixed(4) + ")"; }; -})(); - -/** - * cc.Layer's rendering objects of WebGL - */ -(function(){ - cc.Layer.WebGLRenderCmd = function(renderable){ - cc.Node.WebGLRenderCmd.call(this, renderable); - }; - - var proto = cc.Layer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); - proto.constructor = cc.Layer.WebGLRenderCmd; - - proto.bake = function(){}; - - proto.unbake = function(){}; - - proto._bakeForAddChild = function(){}; -})(); - -/** - * cc.LayerColor's rendering objects of WebGL - */ -(function(){ - cc.LayerColor.WebGLRenderCmd = function(renderable){ - cc.Layer.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; - - // - var _t = this; - _t._squareVerticesAB = new ArrayBuffer(32); - _t._squareColorsAB = new ArrayBuffer(16); - - var locSquareVerticesAB = _t._squareVerticesAB, locSquareColorsAB = _t._squareColorsAB; - var locVertex2FLen = cc.Vertex2F.BYTES_PER_ELEMENT, locColorLen = cc.Color.BYTES_PER_ELEMENT; - _t._squareVertices = [new cc.Vertex2F(0, 0, locSquareVerticesAB, 0), - new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen), - new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 2), - new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 3)]; - _t._squareColors = [cc.color(0, 0, 0, 255, locSquareColorsAB, 0), - cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen), - cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 2), - cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 3)]; - _t._verticesFloat32Buffer = cc._renderContext.createBuffer(); - _t._colorsUint8Buffer = cc._renderContext.createBuffer(); - }; - var proto = cc.LayerColor.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype); - proto.constructor = cc.LayerColor.WebGLRenderCmd; - - cc.LayerColor.WebGLRenderCmd.prototype.rendering = function (ctx) { - var context = ctx || cc._renderContext; - var node = this._node; - - this._shaderProgram.use(); - this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - - // - // Attributes - // - context.bindBuffer(context.ARRAY_BUFFER, this._verticesFloat32Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); - - context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); - context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); - - context.drawArrays(context.TRIANGLE_STRIP, 0, 4); - }; - - proto._updateSquareVertices = function(size, height){ - var locSquareVertices = this._squareVertices; - if (height === undefined) { - locSquareVertices[1].x = size.width; - locSquareVertices[2].y = size.height; - locSquareVertices[3].x = size.width; - locSquareVertices[3].y = size.height; - } else { - locSquareVertices[1].x = size; - locSquareVertices[2].y = height; - locSquareVertices[3].x = size; - locSquareVertices[3].y = height; - } - this._bindLayerVerticesBufferData(); - }; - - proto._updateSquareVerticesWidth = function(width){ - var locSquareVertices = this._squareVertices; - locSquareVertices[1].x = width; - locSquareVertices[3].x = width; - this._bindLayerVerticesBufferData(); - }; - - proto._updateSquareVerticesHeight = function(height){ - var locSquareVertices = this._squareVertices; - locSquareVertices[2].y = height; - locSquareVertices[3].y = height; - this._bindLayerVerticesBufferData(); - }; - - proto._updateDisplayColor = function(parentColor){ - cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._updateColor(); - }; - - proto._updateDisplayOpacity= function(parentOpacity){ - cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); - this._updateColor(); - }; - - proto._syncDisplayColor = function(parentColor){ - cc.Node.WebGLRenderCmd.prototype._syncDisplayColor.call(this, parentColor); - this._updateColor(); - }; - - proto._syncDisplayOpacity = function(parentOpacity){ - cc.Node.WebGLRenderCmd.prototype._syncDisplayOpacity.call(this, parentOpacity); - this._updateColor(); - }; - - proto._updateColor = function(){ - var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity, - locSquareColors = this._squareColors; - for (var i = 0; i < 4; i++) { - locSquareColors[i].r = locDisplayedColor.r; - locSquareColors[i].g = locDisplayedColor.g; - locSquareColors[i].b = locDisplayedColor.b; - locSquareColors[i].a = locDisplayedOpacity; - } - this._bindLayerColorsBufferData(); - this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); - }; - - proto._bindLayerVerticesBufferData = function(){ - var glContext = cc._renderContext; - glContext.bindBuffer(glContext.ARRAY_BUFFER, this._verticesFloat32Buffer); - glContext.bufferData(glContext.ARRAY_BUFFER, this._squareVerticesAB, glContext.STATIC_DRAW); - }; - - proto._bindLayerColorsBufferData = function(){ - var glContext = cc._renderContext; - glContext.bindBuffer(glContext.ARRAY_BUFFER, this._colorsUint8Buffer); - glContext.bufferData(glContext.ARRAY_BUFFER, this._squareColorsAB, glContext.STATIC_DRAW); - }; - - proto.updateBlendFunc = function(blendFunc){}; -})(); - -/** - * cc.LayerGradient's rendering objects of WebGL - */ -(function(){ - cc.LayerGradient.WebGLRenderCmd = function(renderable){ - cc.LayerColor.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; - }; - var proto = cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype); - proto.constructor = cc.LayerGradient.WebGLRenderCmd; - - proto._updateColor = function(){ - var _t = this, node = this._node; - var locAlongVector = node._alongVector; - var h = cc.pLength(locAlongVector); - if (h === 0) - return; - - var c = Math.sqrt(2.0), u = cc.p(locAlongVector.x / h, locAlongVector.y / h); - - // Compressed Interpolation mode - if (node._compressedInterpolation) { - var h2 = 1 / ( Math.abs(u.x) + Math.abs(u.y) ); - u = cc.pMult(u, h2 * c); - } - - var opacityf = _t._displayedOpacity / 255.0; - var locDisplayedColor = _t._displayedColor, locEndColor = node._endColor; - var S = { r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: node._startOpacity * opacityf}; - var E = {r: locEndColor.r, g: locEndColor.g, b: locEndColor.b, a: node._endOpacity * opacityf}; - - // (-1, -1) - var locSquareColors = _t._squareColors; - var locSquareColor0 = locSquareColors[0], locSquareColor1 = locSquareColors[1], locSquareColor2 = locSquareColors[2], locSquareColor3 = locSquareColors[3]; - locSquareColor0.r = ((E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.g = ((E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.b = ((E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.a = ((E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0 * c)))); - // (1, -1) - locSquareColor1.r = ((E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.g = ((E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.b = ((E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.a = ((E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0 * c)))); - // (-1, 1) - locSquareColor2.r = ((E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.g = ((E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.b = ((E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.a = ((E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0 * c)))); - // (1, 1) - locSquareColor3.r = ((E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.g = ((E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.b = ((E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.a = ((E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0 * c)))); - - _t._bindLayerColorsBufferData(); - }; })(); \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js new file mode 100644 index 0000000000..5659162ad8 --- /dev/null +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -0,0 +1,233 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +//-----------------------// +// 1. cc.Layer // +// 2. cc.LayerColor // +// 3. cc.LayerGradient // +//-----------------------// + +/** + * cc.Layer's rendering objects of WebGL + */ +(function(){ + cc.Layer.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + }; + + var proto = cc.Layer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.Layer.WebGLRenderCmd; + + proto.bake = function(){}; + + proto.unbake = function(){}; + + proto._bakeForAddChild = function(){}; +})(); + +/** + * cc.LayerColor's rendering objects of WebGL + */ +(function(){ + cc.LayerColor.WebGLRenderCmd = function(renderable){ + cc.Layer.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + + // + var _t = this; + _t._squareVerticesAB = new ArrayBuffer(32); + _t._squareColorsAB = new ArrayBuffer(16); + + var locSquareVerticesAB = _t._squareVerticesAB, locSquareColorsAB = _t._squareColorsAB; + var locVertex2FLen = cc.Vertex2F.BYTES_PER_ELEMENT, locColorLen = cc.Color.BYTES_PER_ELEMENT; + _t._squareVertices = [new cc.Vertex2F(0, 0, locSquareVerticesAB, 0), + new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen), + new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 2), + new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * 3)]; + _t._squareColors = [cc.color(0, 0, 0, 255, locSquareColorsAB, 0), + cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen), + cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 2), + cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * 3)]; + _t._verticesFloat32Buffer = cc._renderContext.createBuffer(); + _t._colorsUint8Buffer = cc._renderContext.createBuffer(); + }; + var proto = cc.LayerColor.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype); + proto.constructor = cc.LayerColor.WebGLRenderCmd; + + cc.LayerColor.WebGLRenderCmd.prototype.rendering = function (ctx) { + var context = ctx || cc._renderContext; + var node = this._node; + + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + + // + // Attributes + // + context.bindBuffer(context.ARRAY_BUFFER, this._verticesFloat32Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); + + context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); + + context.drawArrays(context.TRIANGLE_STRIP, 0, 4); + }; + + proto._updateSquareVertices = function(size, height){ + var locSquareVertices = this._squareVertices; + if (height === undefined) { + locSquareVertices[1].x = size.width; + locSquareVertices[2].y = size.height; + locSquareVertices[3].x = size.width; + locSquareVertices[3].y = size.height; + } else { + locSquareVertices[1].x = size; + locSquareVertices[2].y = height; + locSquareVertices[3].x = size; + locSquareVertices[3].y = height; + } + this._bindLayerVerticesBufferData(); + }; + + proto._updateSquareVerticesWidth = function(width){ + var locSquareVertices = this._squareVertices; + locSquareVertices[1].x = width; + locSquareVertices[3].x = width; + this._bindLayerVerticesBufferData(); + }; + + proto._updateSquareVerticesHeight = function(height){ + var locSquareVertices = this._squareVertices; + locSquareVertices[2].y = height; + locSquareVertices[3].y = height; + this._bindLayerVerticesBufferData(); + }; + + proto._updateDisplayColor = function(parentColor){ + cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); + this._updateColor(); + }; + + proto._updateDisplayOpacity= function(parentOpacity){ + cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); + this._updateColor(); + }; + + proto._syncDisplayColor = function(parentColor){ + cc.Node.WebGLRenderCmd.prototype._syncDisplayColor.call(this, parentColor); + this._updateColor(); + }; + + proto._syncDisplayOpacity = function(parentOpacity){ + cc.Node.WebGLRenderCmd.prototype._syncDisplayOpacity.call(this, parentOpacity); + this._updateColor(); + }; + + proto._updateColor = function(){ + var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity, + locSquareColors = this._squareColors; + for (var i = 0; i < 4; i++) { + locSquareColors[i].r = locDisplayedColor.r; + locSquareColors[i].g = locDisplayedColor.g; + locSquareColors[i].b = locDisplayedColor.b; + locSquareColors[i].a = locDisplayedOpacity; + } + this._bindLayerColorsBufferData(); + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); + }; + + proto._bindLayerVerticesBufferData = function(){ + var glContext = cc._renderContext; + glContext.bindBuffer(glContext.ARRAY_BUFFER, this._verticesFloat32Buffer); + glContext.bufferData(glContext.ARRAY_BUFFER, this._squareVerticesAB, glContext.STATIC_DRAW); + }; + + proto._bindLayerColorsBufferData = function(){ + var glContext = cc._renderContext; + glContext.bindBuffer(glContext.ARRAY_BUFFER, this._colorsUint8Buffer); + glContext.bufferData(glContext.ARRAY_BUFFER, this._squareColorsAB, glContext.STATIC_DRAW); + }; + + proto.updateBlendFunc = function(blendFunc){}; +})(); + +/** + * cc.LayerGradient's rendering objects of WebGL + */ +(function(){ + cc.LayerGradient.WebGLRenderCmd = function(renderable){ + cc.LayerColor.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + }; + var proto = cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype); + proto.constructor = cc.LayerGradient.WebGLRenderCmd; + + proto._updateColor = function(){ + var _t = this, node = this._node; + var locAlongVector = node._alongVector; + var h = cc.pLength(locAlongVector); + if (h === 0) + return; + + var c = Math.sqrt(2.0), u = cc.p(locAlongVector.x / h, locAlongVector.y / h); + + // Compressed Interpolation mode + if (node._compressedInterpolation) { + var h2 = 1 / ( Math.abs(u.x) + Math.abs(u.y) ); + u = cc.pMult(u, h2 * c); + } + + var opacityf = _t._displayedOpacity / 255.0; + var locDisplayedColor = _t._displayedColor, locEndColor = node._endColor; + var S = { r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: node._startOpacity * opacityf}; + var E = {r: locEndColor.r, g: locEndColor.g, b: locEndColor.b, a: node._endOpacity * opacityf}; + + // (-1, -1) + var locSquareColors = _t._squareColors; + var locSquareColor0 = locSquareColors[0], locSquareColor1 = locSquareColors[1], locSquareColor2 = locSquareColors[2], locSquareColor3 = locSquareColors[3]; + locSquareColor0.r = ((E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0 * c)))); + locSquareColor0.g = ((E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0 * c)))); + locSquareColor0.b = ((E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0 * c)))); + locSquareColor0.a = ((E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0 * c)))); + // (1, -1) + locSquareColor1.r = ((E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0 * c)))); + locSquareColor1.g = ((E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0 * c)))); + locSquareColor1.b = ((E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0 * c)))); + locSquareColor1.a = ((E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0 * c)))); + // (-1, 1) + locSquareColor2.r = ((E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0 * c)))); + locSquareColor2.g = ((E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0 * c)))); + locSquareColor2.b = ((E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0 * c)))); + locSquareColor2.a = ((E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0 * c)))); + // (1, 1) + locSquareColor3.r = ((E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0 * c)))); + locSquareColor3.g = ((E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0 * c)))); + locSquareColor3.b = ((E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0 * c)))); + locSquareColor3.a = ((E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0 * c)))); + + _t._bindLayerColorsBufferData(); + }; +})(); \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js new file mode 100644 index 0000000000..26edfddf25 --- /dev/null +++ b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js @@ -0,0 +1,68 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + //SpriteBatchNode's canvas render command + cc.SpriteBatchNode.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + + this._texture = null; + this._originalTexture = null; + }; + + var proto = cc.SpriteBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.SpriteBatchNode.CanvasRenderCmd; + + proto.checkAtlasCapacity = function(){}; + + proto.initWithTexture = function(texture, capacity){ + this._originalTexture = texture; + this._texture = texture; + }; + + proto.insertQuad = function(){}; + + proto.increaseAtlasCapacity = function(){}; + + proto.removeQuadAtIndex = function(){}; + + proto.removeAllQuads = function(){}; + + proto.getTexture = function(){ + return this._texture; + }; + + proto.setTexture = function(texture){ + this._texture = texture; + var locChildren = this._node._children; + for (var i = 0; i < locChildren.length; i++) + locChildren[i].setTexture(texture); + }; + + proto.updateChildrenAtlasIndex = function(){ }; + + proto.getTextureAtlas = function(){}; + + proto.setTextureAtlas = function(textureAtlas){}; +})(); \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js similarity index 85% rename from cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js rename to cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 93f6040e2f..caea22eecd 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -22,51 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -(function(){ - //SpriteBatchNode's canvas render command - cc.SpriteBatchNode.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - - this._texture = null; - this._originalTexture = null; - }; - - var proto = cc.SpriteBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.SpriteBatchNode.CanvasRenderCmd; - - proto.checkAtlasCapacity = function(){}; - - proto.initWithTexture = function(texture, capacity){ - this._originalTexture = texture; - this._texture = texture; - }; - - proto.insertQuad = function(){}; - - proto.increaseAtlasCapacity = function(){}; - - proto.removeQuadAtIndex = function(){}; - - proto.removeAllQuads = function(){}; - - proto.getTexture = function(){ - return this._texture; - }; - - proto.setTexture = function(texture){ - this._texture = texture; - var locChildren = this._node._children; - for (var i = 0; i < locChildren.length; i++) - locChildren[i].setTexture(texture); - }; - - proto.updateChildrenAtlasIndex = function(){ }; - - proto.getTextureAtlas = function(){}; - - proto.setTextureAtlas = function(textureAtlas){}; -})(); - (function(){ //SpriteBatchNode's WebGL render command cc.SpriteBatchNode.WebGLRenderCmd = function(renderable){ diff --git a/cocos2d/core/sprites/CCSpriteRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js similarity index 57% rename from cocos2d/core/sprites/CCSpriteRenderCmd.js rename to cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 418c023062..f47762937b 100644 --- a/cocos2d/core/sprites/CCSpriteRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -560,446 +560,3 @@ return nCanvas; }; })(); - -//++++++++++++++++++++++++++++++WebGL+++++++++++++++++++++++++++++++++++++++++++ -//Sprite's WebGL render command -(function() { - cc.Sprite.WebGLRenderCmd = function (renderable) { - cc.Node.WebGLRenderCmd.call(this, renderable); - this._needDraw = true; - - this._quad = new cc.V3F_C4B_T2F_Quad(); - this._quadWebBuffer = cc._renderContext.createBuffer(); - this._quadDirty = true; - }; - - var proto = cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); - proto.constructor = cc.Sprite.WebGLRenderCmd; - - proto.updateBlendFunc = function (blendFunc) {}; - - proto._setBatchNodeForAddChild = function (child) { - var node = this._node; - if (node._batchNode) { - if (!(child instanceof cc.Sprite)) { - cc.log(cc._LogInfos.Sprite_addChild); - return false; - } - if (child.texture._webTextureObj !== node.textureAtlas.texture._webTextureObj) - cc.log(cc._LogInfos.Sprite_addChild_2); - - //put it in descendants array of batch node - node._batchNode.appendChild(child); - if (!node._reorderChildDirty) - node._setReorderChildDirtyRecursively(); - } - return true; - }; - - proto._handleTextureForRotatedTexture = function (texture) { - return texture; - }; - - proto.isFrameDisplayed = function (frame) { - var node = this._node; - return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() == node._texture.getName() - && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); - }; - - proto._init = function () { - var tempColor = {r: 255, g: 255, b: 255, a: 255}, quad = this._quad; - quad.bl.colors = tempColor; - quad.br.colors = tempColor; - quad.tl.colors = tempColor; - quad.tr.colors = tempColor; - this._quadDirty = true; - }; - - proto._resetForBatchNode = function () { - var node = this._node; - var x1 = node._offsetPosition.x; - var y1 = node._offsetPosition.y; - var x2 = x1 + node._rect.width; - var y2 = y1 + node._rect.height; - var locQuad = this._quad; - locQuad.bl.vertices = {x: x1, y: y1, z: 0}; - locQuad.br.vertices = {x: x2, y: y1, z: 0}; - locQuad.tl.vertices = {x: x1, y: y2, z: 0}; - locQuad.tr.vertices = {x: x2, y: y2, z: 0}; - this._quadDirty = true; - }; - - proto.getQuad = function () { - return this._quad; - }; - - proto._updateForSetSpriteFrame = function () {}; - - proto._spriteFrameLoadedCallback = function (spriteFrame) { - this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - this.dispatchEvent("load"); - }; - - proto._textureLoadedCallback = function (sender) { - var node = this._node; - if (node._textureLoaded) - return; - - node._textureLoaded = true; - var locRect = node._rect; - if (!locRect) { - locRect = cc.rect(0, 0, sender.width, sender.height); - } else if (cc._rectEqualToZero(locRect)) { - locRect.width = sender.width; - locRect.height = sender.height; - } - - node.texture = sender; - node.setTextureRect(locRect, node._rectRotated); - - // by default use "Self Render". - // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - node.setBatchNode(node._batchNode); - this._quadDirty = true; - node.dispatchEvent("load"); - }; - - proto._setTextureCoords = function (rect, needConvert) { - if (needConvert === undefined) - needConvert = true; - if (needConvert) - rect = cc.rectPointsToPixels(rect); - var node = this._node; - - var tex = node._batchNode ? node.textureAtlas.texture : node._texture; - if (!tex) - return; - - var atlasWidth = tex.pixelsWidth; - var atlasHeight = tex.pixelsHeight; - - var left, right, top, bottom, tempSwap, locQuad = this._quad; - if (node._rectRotated) { - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.height * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); - } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.height) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.width) / atlasHeight; - } - - if (node._flippedX) { - tempSwap = top; - top = bottom; - bottom = tempSwap; - } - - if (node._flippedY) { - tempSwap = left; - left = right; - right = tempSwap; - } - - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = top; - locQuad.br.texCoords.u = left; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = right; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = bottom; - } else { - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * rect.x + 1) / (2 * atlasWidth); - right = left + (rect.width * 2 - 2) / (2 * atlasWidth); - top = (2 * rect.y + 1) / (2 * atlasHeight); - bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); - } else { - left = rect.x / atlasWidth; - right = (rect.x + rect.width) / atlasWidth; - top = rect.y / atlasHeight; - bottom = (rect.y + rect.height) / atlasHeight; - } - - if (node._flippedX) { - tempSwap = left; - left = right; - right = tempSwap; - } - - if (node._flippedY) { - tempSwap = top; - top = bottom; - bottom = tempSwap; - } - - locQuad.bl.texCoords.u = left; - locQuad.bl.texCoords.v = bottom; - locQuad.br.texCoords.u = right; - locQuad.br.texCoords.v = bottom; - locQuad.tl.texCoords.u = left; - locQuad.tl.texCoords.v = top; - locQuad.tr.texCoords.u = right; - locQuad.tr.texCoords.v = top; - } - this._quadDirty = true; - }; - - proto._updateDisplayColor = function (parentColor) { - cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._updateColor(); - }; - - proto._updateDisplayOpacity = function (parentOpacity) { - cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); - this._updateColor(); - }; - - proto._updateColor = function () { - var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; - var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; - // special opacity for premultiplied textures - if (this._opacityModifyRGB) { - color4.r *= locDisplayedOpacity / 255.0; - color4.g *= locDisplayedOpacity / 255.0; - color4.b *= locDisplayedOpacity / 255.0; - } - var locQuad = this._quad, node = this._node; - locQuad.bl.colors = color4; - locQuad.br.colors = color4; - locQuad.tl.colors = color4; - locQuad.tr.colors = color4; - - // renders using Sprite Manager - if (node._batchNode) { - if (node.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { - node.textureAtlas.updateQuad(locQuad, node.atlasIndex) - } else { - // no need to set it recursively - // update dirty_, don't update recursiveDirty_ - node.dirty = true; - } - } - // self render - // do nothing - this._quadDirty = true; - }; - - proto._updateBlendFunc = function () { - if (this._batchNode) { - cc.log(cc._LogInfos.Sprite__updateBlendFunc); - return; - } - - // it's possible to have an untextured sprite - var node = this._node; - if (!node._texture || !node._texture.hasPremultipliedAlpha()) { - node._blendFunc.src = cc.SRC_ALPHA; - node._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - node.opacityModifyRGB = false; - } else { - node._blendFunc.src = cc.BLEND_SRC; - node._blendFunc.dst = cc.BLEND_DST; - node.opacityModifyRGB = true; - } - }; - - proto._setTexture = function (texture) { - var node = this._node; - // If batchnode, then texture id should be the same - if (node._batchNode && node._batchNode.texture != texture) { - cc.log(cc._LogInfos.Sprite_setTexture); - return; - } - - if (texture) - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - else - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); - - if (!node._batchNode && node._texture != texture) { - node._texture = texture; - this._updateBlendFunc(); - } - }; - - proto.updateTransform = function () { - var _t = this, node = this._node; - - // recalculate matrix only if it is dirty - if (node.dirty) { - var locQuad = _t._quad, locParent = node._parent; - // If it is not visible, or one of its ancestors is not visible, then do nothing: - if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { - locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; - node._shouldBeHidden = true; - } else { - node._shouldBeHidden = false; - - if (!locParent || locParent == node._batchNode) { - node._transformToBatch = _t.getNodeToParentTransform(); - } else { - //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); - node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); - } - - // - // calculate the Quad based on the Affine Matrix - // - var locTransformToBatch = node._transformToBatch; - var rect = node._rect; - var x1 = node._offsetPosition.x; - var y1 = node._offsetPosition.y; - - var x2 = x1 + rect.width; - var y2 = y1 + rect.height; - var x = locTransformToBatch.tx; - var y = locTransformToBatch.ty; - - var cr = locTransformToBatch.a; - var sr = locTransformToBatch.b; - var cr2 = locTransformToBatch.d; - var sr2 = -locTransformToBatch.c; - var ax = x1 * cr - y1 * sr2 + x; - var ay = x1 * sr + y1 * cr2 + y; - - var bx = x2 * cr - y1 * sr2 + x; - var by = x2 * sr + y1 * cr2 + y; - - var cx = x2 * cr - y2 * sr2 + x; - var cy = x2 * sr + y2 * cr2 + y; - - var dx = x1 * cr - y2 * sr2 + x; - var dy = x1 * sr + y2 * cr2 + y; - - var locVertexZ = _t._vertexZ; - if (!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - ax = 0 | ax; - ay = 0 | ay; - bx = 0 | bx; - by = 0 | by; - cx = 0 | cx; - cy = 0 | cy; - dx = 0 | dx; - dy = 0 | dy; - } - locQuad.bl.vertices = {x: ax, y: ay, z: locVertexZ}; - locQuad.br.vertices = {x: bx, y: by, z: locVertexZ}; - locQuad.tl.vertices = {x: dx, y: dy, z: locVertexZ}; - locQuad.tr.vertices = {x: cx, y: cy, z: locVertexZ}; - } - node.textureAtlas.updateQuad(locQuad, _t.atlasIndex); - node._recursiveDirty = false; - node.dirty = false; - } - - // recursively iterate over children - if (node._hasChildren) - node._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); - - if (cc.SPRITE_DEBUG_DRAW) { - // draw bounding box - var vertices = [ - cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), - cc.p(_t._quad.br.vertices.x, _t._quad.br.vertices.y), - cc.p(_t._quad.tr.vertices.x, _t._quad.tr.vertices.y), - cc.p(_t._quad.tl.vertices.x, _t._quad.tl.vertices.y) - ]; - cc._drawingUtil.drawPoly(vertices, 4, true); - } - }; - - proto._checkTextureBoundary = function (texture, rect, rotated) { - if (texture && texture.url) { - var _x, _y; - if (rotated) { - _x = rect.x + rect.height; - _y = rect.y + rect.width; - } else { - _x = rect.x + rect.width; - _y = rect.y + rect.height; - } - if (_x > texture.width) { - cc.error(cc._LogInfos.RectWidth, texture.url); - } - if (_y > texture.height) { - cc.error(cc._LogInfos.RectHeight, texture.url); - } - } - }; - - proto.rendering = function (ctx) { - var _t = this._node; - if (!_t._textureLoaded || this._displayedOpacity === 0) - return; - - var gl = ctx || cc._renderContext, locTexture = _t._texture; - //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); - - if (locTexture) { - if (locTexture._isLoaded) { - this._shaderProgram.use(); - this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - //optimize performance for javascript - cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); - if (this._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); - this._quadDirty = false; - } - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION - gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR - gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - } - } else { - this._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - cc.glBindTexture2D(null); - - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); - - gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); - if (this._quadDirty) { - gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.STATIC_DRAW); - this._quadDirty = false; - } - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - } - cc.g_NumberOfDraws++; - - if (cc.SPRITE_DEBUG_DRAW === 0 && !_t._showNode) - return; - - if (cc.SPRITE_DEBUG_DRAW === 1 || _t._showNode) { - // draw bounding box - var locQuad = _t._quad; - var verticesG1 = [ - cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), - cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), - cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), - cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) - ]; - cc._drawingUtil.drawPoly(verticesG1, 4, true); - } else if (cc.SPRITE_DEBUG_DRAW === 2) { - // draw texture box - var drawRectG2 = _t.getTextureRect(); - var offsetPixG2 = _t.getOffsetPosition(); - var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), - cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; - cc._drawingUtil.drawPoly(verticesG2, 4, true); - } // CC_SPRITE_DEBUG_DRAW - }; -})(); \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js new file mode 100644 index 0000000000..6a924e4ad1 --- /dev/null +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -0,0 +1,465 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +//Sprite's WebGL render command +(function() { + cc.Sprite.WebGLRenderCmd = function (renderable) { + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = true; + + this._quad = new cc.V3F_C4B_T2F_Quad(); + this._quadWebBuffer = cc._renderContext.createBuffer(); + this._quadDirty = true; + }; + + var proto = cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.Sprite.WebGLRenderCmd; + + proto.updateBlendFunc = function (blendFunc) {}; + + proto._setBatchNodeForAddChild = function (child) { + var node = this._node; + if (node._batchNode) { + if (!(child instanceof cc.Sprite)) { + cc.log(cc._LogInfos.Sprite_addChild); + return false; + } + if (child.texture._webTextureObj !== node.textureAtlas.texture._webTextureObj) + cc.log(cc._LogInfos.Sprite_addChild_2); + + //put it in descendants array of batch node + node._batchNode.appendChild(child); + if (!node._reorderChildDirty) + node._setReorderChildDirtyRecursively(); + } + return true; + }; + + proto._handleTextureForRotatedTexture = function (texture) { + return texture; + }; + + proto.isFrameDisplayed = function (frame) { + var node = this._node; + return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() == node._texture.getName() + && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); + }; + + proto._init = function () { + var tempColor = {r: 255, g: 255, b: 255, a: 255}, quad = this._quad; + quad.bl.colors = tempColor; + quad.br.colors = tempColor; + quad.tl.colors = tempColor; + quad.tr.colors = tempColor; + this._quadDirty = true; + }; + + proto._resetForBatchNode = function () { + var node = this._node; + var x1 = node._offsetPosition.x; + var y1 = node._offsetPosition.y; + var x2 = x1 + node._rect.width; + var y2 = y1 + node._rect.height; + var locQuad = this._quad; + locQuad.bl.vertices = {x: x1, y: y1, z: 0}; + locQuad.br.vertices = {x: x2, y: y1, z: 0}; + locQuad.tl.vertices = {x: x1, y: y2, z: 0}; + locQuad.tr.vertices = {x: x2, y: y2, z: 0}; + this._quadDirty = true; + }; + + proto.getQuad = function () { + return this._quad; + }; + + proto._updateForSetSpriteFrame = function () {}; + + proto._spriteFrameLoadedCallback = function (spriteFrame) { + this.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); + this.dispatchEvent("load"); + }; + + proto._textureLoadedCallback = function (sender) { + var node = this._node; + if (node._textureLoaded) + return; + + node._textureLoaded = true; + var locRect = node._rect; + if (!locRect) { + locRect = cc.rect(0, 0, sender.width, sender.height); + } else if (cc._rectEqualToZero(locRect)) { + locRect.width = sender.width; + locRect.height = sender.height; + } + + node.texture = sender; + node.setTextureRect(locRect, node._rectRotated); + + // by default use "Self Render". + // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" + node.setBatchNode(node._batchNode); + this._quadDirty = true; + node.dispatchEvent("load"); + }; + + proto._setTextureCoords = function (rect, needConvert) { + if (needConvert === undefined) + needConvert = true; + if (needConvert) + rect = cc.rectPointsToPixels(rect); + var node = this._node; + + var tex = node._batchNode ? node.textureAtlas.texture : node._texture; + if (!tex) + return; + + var atlasWidth = tex.pixelsWidth; + var atlasHeight = tex.pixelsHeight; + + var left, right, top, bottom, tempSwap, locQuad = this._quad; + if (node._rectRotated) { + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.height * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.width * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.height) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.width) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + if (node._flippedY) { + tempSwap = left; + left = right; + right = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = top; + locQuad.br.texCoords.u = left; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = right; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = bottom; + } else { + if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { + left = (2 * rect.x + 1) / (2 * atlasWidth); + right = left + (rect.width * 2 - 2) / (2 * atlasWidth); + top = (2 * rect.y + 1) / (2 * atlasHeight); + bottom = top + (rect.height * 2 - 2) / (2 * atlasHeight); + } else { + left = rect.x / atlasWidth; + right = (rect.x + rect.width) / atlasWidth; + top = rect.y / atlasHeight; + bottom = (rect.y + rect.height) / atlasHeight; + } + + if (node._flippedX) { + tempSwap = left; + left = right; + right = tempSwap; + } + + if (node._flippedY) { + tempSwap = top; + top = bottom; + bottom = tempSwap; + } + + locQuad.bl.texCoords.u = left; + locQuad.bl.texCoords.v = bottom; + locQuad.br.texCoords.u = right; + locQuad.br.texCoords.v = bottom; + locQuad.tl.texCoords.u = left; + locQuad.tl.texCoords.v = top; + locQuad.tr.texCoords.u = right; + locQuad.tr.texCoords.v = top; + } + this._quadDirty = true; + }; + + proto._updateDisplayColor = function (parentColor) { + cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); + this._updateColor(); + }; + + proto._updateDisplayOpacity = function (parentOpacity) { + cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); + this._updateColor(); + }; + + proto._updateColor = function () { + var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; + var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; + // special opacity for premultiplied textures + if (this._opacityModifyRGB) { + color4.r *= locDisplayedOpacity / 255.0; + color4.g *= locDisplayedOpacity / 255.0; + color4.b *= locDisplayedOpacity / 255.0; + } + var locQuad = this._quad, node = this._node; + locQuad.bl.colors = color4; + locQuad.br.colors = color4; + locQuad.tl.colors = color4; + locQuad.tr.colors = color4; + + // renders using Sprite Manager + if (node._batchNode) { + if (node.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { + node.textureAtlas.updateQuad(locQuad, node.atlasIndex) + } else { + // no need to set it recursively + // update dirty_, don't update recursiveDirty_ + node.dirty = true; + } + } + // self render + // do nothing + this._quadDirty = true; + }; + + proto._updateBlendFunc = function () { + if (this._batchNode) { + cc.log(cc._LogInfos.Sprite__updateBlendFunc); + return; + } + + // it's possible to have an untextured sprite + var node = this._node; + if (!node._texture || !node._texture.hasPremultipliedAlpha()) { + node._blendFunc.src = cc.SRC_ALPHA; + node._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + node.opacityModifyRGB = false; + } else { + node._blendFunc.src = cc.BLEND_SRC; + node._blendFunc.dst = cc.BLEND_DST; + node.opacityModifyRGB = true; + } + }; + + proto._setTexture = function (texture) { + var node = this._node; + // If batchnode, then texture id should be the same + if (node._batchNode && node._batchNode.texture != texture) { + cc.log(cc._LogInfos.Sprite_setTexture); + return; + } + + if (texture) + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + else + node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); + + if (!node._batchNode && node._texture != texture) { + node._texture = texture; + this._updateBlendFunc(); + } + }; + + proto.updateTransform = function () { + var _t = this, node = this._node; + + // recalculate matrix only if it is dirty + if (node.dirty) { + var locQuad = _t._quad, locParent = node._parent; + // If it is not visible, or one of its ancestors is not visible, then do nothing: + if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { + locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; + node._shouldBeHidden = true; + } else { + node._shouldBeHidden = false; + + if (!locParent || locParent == node._batchNode) { + node._transformToBatch = _t.getNodeToParentTransform(); + } else { + //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); + node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); + } + + // + // calculate the Quad based on the Affine Matrix + // + var locTransformToBatch = node._transformToBatch; + var rect = node._rect; + var x1 = node._offsetPosition.x; + var y1 = node._offsetPosition.y; + + var x2 = x1 + rect.width; + var y2 = y1 + rect.height; + var x = locTransformToBatch.tx; + var y = locTransformToBatch.ty; + + var cr = locTransformToBatch.a; + var sr = locTransformToBatch.b; + var cr2 = locTransformToBatch.d; + var sr2 = -locTransformToBatch.c; + var ax = x1 * cr - y1 * sr2 + x; + var ay = x1 * sr + y1 * cr2 + y; + + var bx = x2 * cr - y1 * sr2 + x; + var by = x2 * sr + y1 * cr2 + y; + + var cx = x2 * cr - y2 * sr2 + x; + var cy = x2 * sr + y2 * cr2 + y; + + var dx = x1 * cr - y2 * sr2 + x; + var dy = x1 * sr + y2 * cr2 + y; + + var locVertexZ = _t._vertexZ; + if (!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + ax = 0 | ax; + ay = 0 | ay; + bx = 0 | bx; + by = 0 | by; + cx = 0 | cx; + cy = 0 | cy; + dx = 0 | dx; + dy = 0 | dy; + } + locQuad.bl.vertices = {x: ax, y: ay, z: locVertexZ}; + locQuad.br.vertices = {x: bx, y: by, z: locVertexZ}; + locQuad.tl.vertices = {x: dx, y: dy, z: locVertexZ}; + locQuad.tr.vertices = {x: cx, y: cy, z: locVertexZ}; + } + node.textureAtlas.updateQuad(locQuad, _t.atlasIndex); + node._recursiveDirty = false; + node.dirty = false; + } + + // recursively iterate over children + if (node._hasChildren) + node._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); + + if (cc.SPRITE_DEBUG_DRAW) { + // draw bounding box + var vertices = [ + cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), + cc.p(_t._quad.br.vertices.x, _t._quad.br.vertices.y), + cc.p(_t._quad.tr.vertices.x, _t._quad.tr.vertices.y), + cc.p(_t._quad.tl.vertices.x, _t._quad.tl.vertices.y) + ]; + cc._drawingUtil.drawPoly(vertices, 4, true); + } + }; + + proto._checkTextureBoundary = function (texture, rect, rotated) { + if (texture && texture.url) { + var _x, _y; + if (rotated) { + _x = rect.x + rect.height; + _y = rect.y + rect.width; + } else { + _x = rect.x + rect.width; + _y = rect.y + rect.height; + } + if (_x > texture.width) { + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if (_y > texture.height) { + cc.error(cc._LogInfos.RectHeight, texture.url); + } + } + }; + + proto.rendering = function (ctx) { + var _t = this._node; + if (!_t._textureLoaded || this._displayedOpacity === 0) + return; + + var gl = ctx || cc._renderContext, locTexture = _t._texture; + //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); + + if (locTexture) { + if (locTexture._isLoaded) { + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + //optimize performance for javascript + cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); + if (this._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); + this._quadDirty = false; + } + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + } else { + this._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + cc.glBindTexture2D(null); + + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + + gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); + if (this._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.STATIC_DRAW); + this._quadDirty = false; + } + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + cc.g_NumberOfDraws++; + + if (cc.SPRITE_DEBUG_DRAW === 0 && !_t._showNode) + return; + + if (cc.SPRITE_DEBUG_DRAW === 1 || _t._showNode) { + // draw bounding box + var locQuad = _t._quad; + var verticesG1 = [ + cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), + cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), + cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), + cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) + ]; + cc._drawingUtil.drawPoly(verticesG1, 4, true); + } else if (cc.SPRITE_DEBUG_DRAW === 2) { + // draw texture box + var drawRectG2 = _t.getTextureRect(); + var offsetPixG2 = _t.getOffsetPosition(); + var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), + cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; + cc._drawingUtil.drawPoly(verticesG2, 4, true); + } // CC_SPRITE_DEBUG_DRAW + }; +})(); \ No newline at end of file diff --git a/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js new file mode 100644 index 0000000000..02c6ef7c57 --- /dev/null +++ b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js @@ -0,0 +1,89 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + cc.LabelAtlas.CanvasRenderCmd = function(renderableObject){ + cc.AtlasNode.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = false; + }; + + var proto = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); + proto.constructor = cc.LabelAtlas.CanvasRenderCmd; + + proto.updateAtlasValues = function(){ + var node = this._node; + var locString = node._string || ""; + var n = locString.length; + var texture = this._texture; + var locItemWidth = node._itemWidth , locItemHeight = node._itemHeight; //needn't multiply cc.contentScaleFactor(), because sprite's draw will do this + + for (var i = 0; i < n; i++) { + var a = locString.charCodeAt(i) - node._mapStartChar.charCodeAt(0); + var row = parseInt(a % node._itemsPerRow, 10); + var col = parseInt(a / node._itemsPerRow, 10); + + var rect = cc.rect(row * locItemWidth, col * locItemHeight, locItemWidth, locItemHeight); + var c = locString.charCodeAt(i); + var fontChar = node.getChildByTag(i); + if (!fontChar) { + fontChar = new cc.Sprite(); + if (c == 32) { + fontChar.init(); + fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); + } else + fontChar.initWithTexture(texture, rect); + + cc.Node.prototype.addChild.call(node, fontChar, 0, i); + } else { + if (c == 32) { + fontChar.init(); + fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); + } else { + // reusing fonts + fontChar.initWithTexture(texture, rect); + // restore to default in case they were modified + fontChar.visible = true; + } + } + fontChar.setPosition(i * locItemWidth + locItemWidth / 2, locItemHeight / 2); + } + }; + + proto.setString = function(label){ + var node = this._node; + if (node._children) { + var locChildren = node._children; + var len = locChildren.length; + for (var i = 0; i < len; i++) { + var child = locChildren[i]; + if (child && !child._lateChild) + child.visible = false; + } + } + }; + + proto._addChild = function(){ + child._lateChild = true; + }; +})(); \ No newline at end of file diff --git a/cocos2d/labels/CCLabelAtlasRenderCmd.js b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js similarity index 69% rename from cocos2d/labels/CCLabelAtlasRenderCmd.js rename to cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js index c0aaed9f7d..d41b6724d5 100644 --- a/cocos2d/labels/CCLabelAtlasRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js @@ -22,72 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -(function(){ - cc.LabelAtlas.CanvasRenderCmd = function(renderableObject){ - cc.AtlasNode.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = false; - }; - - var proto = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); - proto.constructor = cc.LabelAtlas.CanvasRenderCmd; - - proto.updateAtlasValues = function(){ - var node = this._node; - var locString = node._string || ""; - var n = locString.length; - var texture = this._texture; - var locItemWidth = node._itemWidth , locItemHeight = node._itemHeight; //needn't multiply cc.contentScaleFactor(), because sprite's draw will do this - - for (var i = 0; i < n; i++) { - var a = locString.charCodeAt(i) - node._mapStartChar.charCodeAt(0); - var row = parseInt(a % node._itemsPerRow, 10); - var col = parseInt(a / node._itemsPerRow, 10); - - var rect = cc.rect(row * locItemWidth, col * locItemHeight, locItemWidth, locItemHeight); - var c = locString.charCodeAt(i); - var fontChar = node.getChildByTag(i); - if (!fontChar) { - fontChar = new cc.Sprite(); - if (c == 32) { - fontChar.init(); - fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); - } else - fontChar.initWithTexture(texture, rect); - - cc.Node.prototype.addChild.call(node, fontChar, 0, i); - } else { - if (c == 32) { - fontChar.init(); - fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); - } else { - // reusing fonts - fontChar.initWithTexture(texture, rect); - // restore to default in case they were modified - fontChar.visible = true; - } - } - fontChar.setPosition(i * locItemWidth + locItemWidth / 2, locItemHeight / 2); - } - }; - - proto.setString = function(label){ - var node = this._node; - if (node._children) { - var locChildren = node._children; - var len = locChildren.length; - for (var i = 0; i < len; i++) { - var child = locChildren[i]; - if (child && !child._lateChild) - child.visible = false; - } - } - }; - - proto._addChild = function(){ - child._lateChild = true; - }; -})(); - (function(){ cc.LabelAtlas.WebGLRenderCmd = function(renderable){ cc.AtlasNode.WebGLRenderCmd.call(this, renderable); diff --git a/cocos2d/labels/CCLabelBMFontRenderCmd.js b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js similarity index 76% rename from cocos2d/labels/CCLabelBMFontRenderCmd.js rename to cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js index 587823228f..a69f485627 100644 --- a/cocos2d/labels/CCLabelBMFontRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js @@ -146,65 +146,4 @@ proto._initBatchTexture = function(){}; -})(); - - -(function(){ - cc.LabelBMFont.WebGLRenderCmd = function(renderableObject){ - cc.SpriteBatchNode.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = false; - }; - - var proto = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); - proto.constructor = cc.LabelBMFont.WebGLRenderCmd; - - proto._updateTexture = function(fontChar, locTexture, rect, i){ - var node = this._node; - //var hasSprite = true; - if (!fontChar) { - fontChar = new cc.Sprite(); - fontChar.initWithTexture(locTexture, rect, false); - fontChar._newTextureWhenChangeColor = true; - node.addChild(fontChar, 0, i); - } else { - // updating previous sprite - fontChar.setTextureRect(rect, false); - // restore to default in case they were modified - fontChar.visible = true; - } - - - // Apply label properties - fontChar.opacityModifyRGB = node._opacityModifyRGB; - // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on - fontChar.updateDisplayedColor(this._displayedColor); - fontChar.updateDisplayedOpacity(this._displayedOpacity); - - return fontChar; - }; - - proto._updateFntFileTexture = function(){}; - - proto.setTexture = cc.SpriteBatchNode.prototype.setTexture; - - proto._changeTextureColor = function(){}; - - proto._updateChildrenDisplayedOpacity = function(locChild){ - locChild.updateDisplayedOpacity(this._displayedOpacity); - }; - - proto._updateChildrenDisplayedOpacity = function(locChild){ - locChild.updateDisplayedColor(this._displayedColor); - }; - - proto._initBatchTexture = function(){ - var node = this._node; - var locTexture = node.textureAtlas.texture; - node._opacityModifyRGB = locTexture.hasPremultipliedAlpha(); - - var reusedChar = node._reusedChar = new cc.Sprite(); - reusedChar.initWithTexture(locTexture, cc.rect(0, 0, 0, 0), false); - reusedChar.batchNode = node; - }; - })(); \ No newline at end of file diff --git a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js new file mode 100644 index 0000000000..7889b2074d --- /dev/null +++ b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js @@ -0,0 +1,91 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + Use any of these editors to generate BMFonts: + http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) + http://www.n4te.com/hiero/hiero.jnlp (Free, Java) + http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) + http://www.angelcode.com/products/bmfont/ (Free, Windows only) + ****************************************************************************/ + +(function(){ + cc.LabelBMFont.WebGLRenderCmd = function(renderableObject){ + cc.SpriteBatchNode.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = false; + }; + + var proto = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); + proto.constructor = cc.LabelBMFont.WebGLRenderCmd; + + proto._updateTexture = function(fontChar, locTexture, rect, i){ + var node = this._node; + //var hasSprite = true; + if (!fontChar) { + fontChar = new cc.Sprite(); + fontChar.initWithTexture(locTexture, rect, false); + fontChar._newTextureWhenChangeColor = true; + node.addChild(fontChar, 0, i); + } else { + // updating previous sprite + fontChar.setTextureRect(rect, false); + // restore to default in case they were modified + fontChar.visible = true; + } + + + // Apply label properties + fontChar.opacityModifyRGB = node._opacityModifyRGB; + // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on + fontChar.updateDisplayedColor(this._displayedColor); + fontChar.updateDisplayedOpacity(this._displayedOpacity); + + return fontChar; + }; + + proto._updateFntFileTexture = function(){}; + + proto.setTexture = cc.SpriteBatchNode.prototype.setTexture; + + proto._changeTextureColor = function(){}; + + proto._updateChildrenDisplayedOpacity = function(locChild){ + locChild.updateDisplayedOpacity(this._displayedOpacity); + }; + + proto._updateChildrenDisplayedOpacity = function(locChild){ + locChild.updateDisplayedColor(this._displayedColor); + }; + + proto._initBatchTexture = function(){ + var node = this._node; + var locTexture = node.textureAtlas.texture; + node._opacityModifyRGB = locTexture.hasPremultipliedAlpha(); + + var reusedChar = node._reusedChar = new cc.Sprite(); + reusedChar.initWithTexture(locTexture, cc.rect(0, 0, 0, 0), false); + reusedChar.batchNode = node; + }; + +})(); \ No newline at end of file diff --git a/cocos2d/motion-streak/CCMotionStreakRenderCmd.js b/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js similarity index 100% rename from cocos2d/motion-streak/CCMotionStreakRenderCmd.js rename to cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js diff --git a/cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js new file mode 100644 index 0000000000..36da185ecb --- /dev/null +++ b/cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js @@ -0,0 +1,38 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + /** + * cc.ParticleBatchNode's rendering objects of Canvas + */ + cc.ParticleBatchNode.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = false; + }; + + var proto = cc.ParticleBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ParticleBatchNode.CanvasRenderCmd; + + proto._initWithTexture = function(){}; +})(); diff --git a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js similarity index 86% rename from cocos2d/particle/CCParticleBatchNodeRenderCmd.js rename to cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js index f006972ccd..cf62122794 100644 --- a/cocos2d/particle/CCParticleBatchNodeRenderCmd.js +++ b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js @@ -22,21 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -(function(){ - /** - * cc.ParticleBatchNode's rendering objects of Canvas - */ - cc.ParticleBatchNode.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - this._needDraw = false; - }; - - var proto = cc.ParticleBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.ParticleBatchNode.CanvasRenderCmd; - - proto._initWithTexture = function(){}; -})(); - (function(){ /** * cc.ParticleBatchNode's rendering objects of WebGL diff --git a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js new file mode 100644 index 0000000000..e114232ee2 --- /dev/null +++ b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js @@ -0,0 +1,220 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * ParticleSystem's canvas render command + */ +(function(){ + cc.ParticleSystem.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; + + this._drawMode = cc.ParticleSystem.SHAPE_MODE; + this._shapeType = cc.ParticleSystem.BALL_SHAPE; + + this._pointRect = cc.rect(0, 0, 0, 0); + }; + var proto = cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ParticleSystem.CanvasRenderCmd; + + proto.getDrawMode = function(){ + return this._drawMode; + }; + + proto.setDrawMode = function(drawMode){ + this._drawMode = drawMode; + }; + + proto.getShapeType = function(){ + return this._shapeType; + }; + + proto.setShapeType = function(shapeType){ + this._shapeType = shapeType; + }; + + proto.setBatchNode = function(batchNode){ + if (this._batchNode != batchNode) { + this._node._batchNode = batchNode; + } + }; + + proto.updateQuadWithParticle = function (particle, newPosition) { + //do nothing + }; + + proto.updateParticlePosition = function(particle, position){ + cc.pIn(particle.drawPos, position); + }; + + proto.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, + node = this._node, + t = this._worldTransform, + pointRect = this._pointRect; + + context.save(); + //transform + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if (node.isBlendAdditive()) + context.globalCompositeOperation = 'lighter'; + else + context.globalCompositeOperation = 'source-over'; + + var i, particle, lpx, alpha; + var particleCount = this._node.particleCount, particles = this._node._particles; + if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { + // Delay drawing until the texture is fully loaded by the browser + if (!node._texture || !node._texture._isLoaded) { + context.restore(); + return; + } + var element = node._texture.getHtmlElementObj(); + if (!element.width || !element.height) { + context.restore(); + return; + } + + var drawElement = element; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + + alpha = particle.color.a / 255; + if (alpha === 0) continue; + context.globalAlpha = alpha; + + context.save(); + context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); + + var size = Math.floor(particle.size / 4) * 4; + var w = pointRect.width; + var h = pointRect.height; + + context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); + + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + + drawElement = particle.isChangeColor ? this._changeTextureColor(element, particle.color, this._pointRect) : element; + context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); + context.restore(); + } + } else { + var drawTool = cc._drawingUtil; + for (i = 0; i < particleCount; i++) { + particle = particles[i]; + lpx = (0 | (particle.size * 0.5)); + alpha = particle.color.a / 255; + if (alpha === 0) continue; + context.globalAlpha = alpha; + + context.save(); + context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); + if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (particle.rotation) + context.rotate(cc.degreesToRadians(particle.rotation)); + drawTool.drawStar(context, lpx, particle.color); + } else + drawTool.drawColorBall(context, lpx, particle.color); + context.restore(); + } + } + context.restore(); + cc.g_NumberOfDraws++; + }; + + if(!cc.sys._supportCanvasNewBlendModes){ + proto._changeTextureColor = function(element, color, rect){ + var cacheTextureForColor = cc.textureCache.getTextureColors(element); + if (cacheTextureForColor) { + // Create another cache for the tinted version + // This speeds up things by a fair bit + if (!cacheTextureForColor.tintCache) { + cacheTextureForColor.tintCache = document.createElement('canvas'); + cacheTextureForColor.tintCache.width = element.width; + cacheTextureForColor.tintCache.height = element.height; + } + cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, color, rect, cacheTextureForColor.tintCache); + return cacheTextureForColor.tintCache; + } + return null + } + }else{ + proto._changeTextureColor = function(element, color, rect){ + if (!element.tintCache) { + element.tintCache = document.createElement('canvas'); + element.tintCache.width = element.width; + element.tintCache.height = element.height; + } + return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, color, rect, element.tintCache); + } + } + + proto.initTexCoordsWithRect = function(pointRect){ + this._pointRect = pointRect; + }; + + proto.setTotalParticles = function(){ + //cc.assert(tp <= this._allocatedParticles, "Particle: resizing particle array only supported for quads"); + this._node._totalParticles = (tp < 200) ? tp : 200; + }; + + proto.addParticle = function(){ + var node = this._node, + particles = node._particles, + particle; + if (node.particleCount < particles.length) { + particle = particles[node.particleCount]; + } else { + particle = new cc.Particle(); + particles.push(particle); + } + return particle; + }; + + proto._setupVBO = function(){}; + proto._allocMemory = function(){ + return true; + }; + + proto.postStep = function(){}; + + proto._setBlendAdditive = function(){ + var locBlendFunc = this._node._blendFunc; + locBlendFunc.src = cc.BLEND_SRC; + locBlendFunc.dst = cc.BLEND_DST; + }; + + proto._initWithTotalParticles = function(totalParticles){}; + proto._updateDeltaColor = function(selParticle, dt){ + if (!this._dontTint) { + selParticle.color.r += selParticle.deltaColor.r * dt; + selParticle.color.g += selParticle.deltaColor.g * dt; + selParticle.color.b += selParticle.deltaColor.b * dt; + selParticle.color.a += selParticle.deltaColor.a * dt; + selParticle.isChangeColor = true; + } + }; +})(); diff --git a/cocos2d/particle/CCParticleSystemRenderCmd.js b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js similarity index 67% rename from cocos2d/particle/CCParticleSystemRenderCmd.js rename to cocos2d/particle/CCParticleSystemWebGLRenderCmd.js index 0ff76ca287..d5bc45f10c 100644 --- a/cocos2d/particle/CCParticleSystemRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js @@ -22,203 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * ParticleSystem's canvas render command - */ -(function(){ - cc.ParticleSystem.CanvasRenderCmd = function(renderable){ - cc.Node.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; - - this._drawMode = cc.ParticleSystem.SHAPE_MODE; - this._shapeType = cc.ParticleSystem.BALL_SHAPE; - - this._pointRect = cc.rect(0, 0, 0, 0); - }; - var proto = cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.ParticleSystem.CanvasRenderCmd; - - proto.getDrawMode = function(){ - return this._drawMode; - }; - - proto.setDrawMode = function(drawMode){ - this._drawMode = drawMode; - }; - - proto.getShapeType = function(){ - return this._shapeType; - }; - - proto.setShapeType = function(shapeType){ - this._shapeType = shapeType; - }; - - proto.setBatchNode = function(batchNode){ - if (this._batchNode != batchNode) { - this._node._batchNode = batchNode; - } - }; - - proto.updateQuadWithParticle = function (particle, newPosition) { - //do nothing - }; - - proto.updateParticlePosition = function(particle, position){ - cc.pIn(particle.drawPos, position); - }; - - proto.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, - node = this._node, - t = this._worldTransform, - pointRect = this._pointRect; - - context.save(); - //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (node.isBlendAdditive()) - context.globalCompositeOperation = 'lighter'; - else - context.globalCompositeOperation = 'source-over'; - - var i, particle, lpx, alpha; - var particleCount = this._node.particleCount, particles = this._node._particles; - if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { - // Delay drawing until the texture is fully loaded by the browser - if (!node._texture || !node._texture._isLoaded) { - context.restore(); - return; - } - var element = node._texture.getHtmlElementObj(); - if (!element.width || !element.height) { - context.restore(); - return; - } - - var drawElement = element; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); - - alpha = particle.color.a / 255; - if (alpha === 0) continue; - context.globalAlpha = alpha; - - context.save(); - context.translate((0 | particle.drawPos.x), -(0 | particle.drawPos.y)); - - var size = Math.floor(particle.size / 4) * 4; - var w = pointRect.width; - var h = pointRect.height; - - context.scale(Math.max((1 / w) * size, 0.000001), Math.max((1 / h) * size, 0.000001)); - - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - - drawElement = particle.isChangeColor ? this._changeTextureColor(element, particle.color, this._pointRect) : element; - context.drawImage(drawElement, -(0 | (w / 2)), -(0 | (h / 2))); - context.restore(); - } - } else { - var drawTool = cc._drawingUtil; - for (i = 0; i < particleCount; i++) { - particle = particles[i]; - lpx = (0 | (particle.size * 0.5)); - alpha = particle.color.a / 255; - if (alpha === 0) continue; - context.globalAlpha = alpha; - - context.save(); - context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { - if (particle.rotation) - context.rotate(cc.degreesToRadians(particle.rotation)); - drawTool.drawStar(context, lpx, particle.color); - } else - drawTool.drawColorBall(context, lpx, particle.color); - context.restore(); - } - } - context.restore(); - cc.g_NumberOfDraws++; - }; - - if(!cc.sys._supportCanvasNewBlendModes){ - proto._changeTextureColor = function(element, color, rect){ - var cacheTextureForColor = cc.textureCache.getTextureColors(element); - if (cacheTextureForColor) { - // Create another cache for the tinted version - // This speeds up things by a fair bit - if (!cacheTextureForColor.tintCache) { - cacheTextureForColor.tintCache = document.createElement('canvas'); - cacheTextureForColor.tintCache.width = element.width; - cacheTextureForColor.tintCache.height = element.height; - } - cc.Sprite.CanvasRenderCmd._generateTintImage(element, cacheTextureForColor, color, rect, cacheTextureForColor.tintCache); - return cacheTextureForColor.tintCache; - } - return null - } - }else{ - proto._changeTextureColor = function(element, color, rect){ - if (!element.tintCache) { - element.tintCache = document.createElement('canvas'); - element.tintCache.width = element.width; - element.tintCache.height = element.height; - } - return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(element, color, rect, element.tintCache); - } - } - - proto.initTexCoordsWithRect = function(pointRect){ - this._pointRect = pointRect; - }; - - proto.setTotalParticles = function(){ - //cc.assert(tp <= this._allocatedParticles, "Particle: resizing particle array only supported for quads"); - this._node._totalParticles = (tp < 200) ? tp : 200; - }; - - proto.addParticle = function(){ - var node = this._node, - particles = node._particles, - particle; - if (node.particleCount < particles.length) { - particle = particles[node.particleCount]; - } else { - particle = new cc.Particle(); - particles.push(particle); - } - return particle; - }; - - proto._setupVBO = function(){}; - proto._allocMemory = function(){ - return true; - }; - - proto.postStep = function(){}; - - proto._setBlendAdditive = function(){ - var locBlendFunc = this._node._blendFunc; - locBlendFunc.src = cc.BLEND_SRC; - locBlendFunc.dst = cc.BLEND_DST; - }; - - proto._initWithTotalParticles = function(totalParticles){}; - proto._updateDeltaColor = function(selParticle, dt){ - if (!this._dontTint) { - selParticle.color.r += selParticle.deltaColor.r * dt; - selParticle.color.g += selParticle.deltaColor.g * dt; - selParticle.color.b += selParticle.deltaColor.b * dt; - selParticle.color.a += selParticle.deltaColor.a * dt; - selParticle.isChangeColor = true; - } - }; -})(); - (function(){ /** * ParticleSystem's WebGL render command diff --git a/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js b/cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js similarity index 79% rename from cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js rename to cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js index adc0b8cfca..be1f6f14ba 100644 --- a/cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js +++ b/cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js @@ -50,24 +50,3 @@ proto._drawPoly = cc.DrawNode.CanvasRenderCmd.prototype._drawPoly; })(); - -/** - * cc.PhysicsDebugNode's rendering objects of WebGL - */ -(function(){ - cc.PhysicsDebugNode.WebGLRenderCmd = function (renderableObject) { - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; - }; - - cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function (ctx) { - var node = this._node; - if (!node._space) - return; - - node._space.eachShape(cc.DrawShape.bind(node)); - node._space.eachConstraint(cc.DrawConstraint.bind(node)); - cc.DrawNode.prototype.draw.call(node); - node.clear(); - }; -})(); \ No newline at end of file diff --git a/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js new file mode 100644 index 0000000000..2161e3337c --- /dev/null +++ b/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js @@ -0,0 +1,44 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * cc.PhysicsDebugNode's rendering objects of WebGL + */ +(function(){ + cc.PhysicsDebugNode.WebGLRenderCmd = function (renderableObject) { + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var node = this._node; + if (!node._space) + return; + + node._space.eachShape(cc.DrawShape.bind(node)); + node._space.eachConstraint(cc.DrawConstraint.bind(node)); + cc.DrawNode.prototype.draw.call(node); + node.clear(); + }; +})(); \ No newline at end of file diff --git a/cocos2d/physics/CCPhysicsSpriteRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js similarity index 100% rename from cocos2d/physics/CCPhysicsSpriteRenderCmd.js rename to cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js diff --git a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js new file mode 100644 index 0000000000..8f5fc6a060 --- /dev/null +++ b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js @@ -0,0 +1,94 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * cc.PhysicsSprite's rendering objects of Canvas + */ +(function(){ + cc.PhysicsSprite.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.PhysicsSprite.CanvasRenderCmd; + + proto.rendering = function(){ + if (this._node.transform) + this._node.transform(); + }; + + proto._getNodeToParentTransform = function(){ + return this._node._nodeToParentTransformForCanvas(); + }; +})(); + +/** + * cc.PhysicsSprite's rendering objects of WebGL + */ +(function(){ + cc.PhysicsSprite.WebGLRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.PhysicsSprite.WebGLRenderCmd; + + proto.rendering = function(){ + if(this._node._transformForRenderer) + this._node._transformForRenderer(); + }; + + proto._getNodeToParentTransform = function(){ + var locBody = this._body, locAnchorPIP = this._anchorPointInPoints, locScaleX = this._scaleX, locScaleY = this._scaleY; + var x = locBody.p.x; + var y = locBody.p.y; + + if (this._ignoreAnchorPointForPosition) { + x += locAnchorPIP.x; + y += locAnchorPIP.y; + } + + // Make matrix + var radians = locBody.a; + var c = Math.cos(radians); + var s = Math.sin(radians); + + // Although scale is not used by physics engines, it is calculated just in case + // the sprite is animated (scaled up/down) using actions. + // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990 + if (!cc._rectEqualToZero(locAnchorPIP)) { + x += c * -locAnchorPIP.x * locScaleX + -s * -locAnchorPIP.y * locScaleY; + y += s * -locAnchorPIP.x * locScaleX + c * -locAnchorPIP.y * locScaleY; + } + + // Rot, Translate Matrix + this._transform = cc.affineTransformMake(c * locScaleX, s * locScaleX, + -s * locScaleY, c * locScaleY, x, y); + + return this._transform; + }; + +})(); \ No newline at end of file diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js new file mode 100644 index 0000000000..abea97d466 --- /dev/null +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -0,0 +1,153 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + + cc.RenderTexture.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + + this._clearColor = cc.color(255, 255, 255, 255); + this._clearColorStr = "rgba(255,255,255,1)"; + + // + // the off-screen canvas for rendering and storing the texture + // @type HTMLCanvasElement + // + this._cacheCanvas = cc.newElement('canvas'); + /** + * stores a reference to the canvas context object + * @type CanvasRenderingContext2D + */ + this._cacheContext = this._cacheCanvas.getContext('2d'); + }; + + var proto = cc.RenderTexture.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.RenderTexture.CanvasRenderCmd; + + proto.cleanup = function(){ + var node = this._node; + this._cacheContext = null; + this._cacheCanvas = null; + }; + + proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ + var node = this._node; + var locCacheCanvas = this._cacheCanvas, locScaleFactor = cc.contentScaleFactor(); + locCacheCanvas.width = 0 | (width * locScaleFactor); + locCacheCanvas.height = 0 | (height * locScaleFactor); + this._cacheContext.translate(0, locCacheCanvas.height); + var texture = new cc.Texture2D(); + texture.initWithElement(locCacheCanvas); + texture.handleLoadedTexture(); + var locSprite = node.sprite = new cc.Sprite(texture); + locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); + // Disabled by default. + node.autoDraw = false; + // add sprite for backward compatibility + node.addChild(locSprite); + return true; + }; + + proto.begin = function(){}; + + proto._beginWithClear = function(r, g, b, a, depthValue, stencilValue, flags){ + var node = this._node; + node.begin(); + + r = r || 0; + g = g || 0; + b = b || 0; + a = isNaN(a) ? 1 : a; + + //var context = cc._renderContext; + var context = this._cacheContext; + var locCanvas = this._cacheCanvas; + context.save(); + context.fillStyle = "rgba(" + (0 | r) + "," + (0 | g) + "," + (0 | b) + "," + a / 255 + ")"; + context.clearRect(0, 0, locCanvas.width, -locCanvas.height); + context.fillRect(0, 0, locCanvas.width, -locCanvas.height); + context.restore(); + }; + + proto.end = function(){ + + var node = this._node; + + //old code + //cc._renderContext = cc._mainRenderContextBackup; + //cc.view._resetScale(); + + var scale = cc.contentScaleFactor(); + cc.renderer._renderingToCacheCanvas(this._cacheContext, node.__instanceId, scale, scale); + + //TODO + /*//restore viewport + director.setViewport(); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix();*/ + }; + + proto.clearRect = function(x, y, width, height){ + this._cacheContext.clearRect(x, y, width, -height); + }; + + proto.clearDepth = function(depthValue){ + cc.log("clearDepth isn't supported on Cocos2d-Html5"); + }; + + proto.visit = function(ctx){ + var node = this._node; + ctx = ctx || cc._renderContext; + node.transform(ctx); + node.sprite.visit(ctx); + }; + + proto.draw = function(){ + var node = this._node; + if (node.clearFlags) { + var locCanvas = this._cacheCanvas; + ctx.save(); + ctx.fillStyle = this._clearColorStr; + ctx.clearRect(0, 0, locCanvas.width, -locCanvas.height); + ctx.fillRect(0, 0, locCanvas.width, -locCanvas.height); + ctx.restore(); + } + + //! make sure all children are drawn + node.sortAllChildren(); + var locChildren = node._children; + var childrenLen = locChildren.length; + var selfSprite = node.sprite; + for (var i = 0; i < childrenLen; i++) { + var getChild = locChildren[i]; + if (getChild != selfSprite) + getChild.visit(); + } + node.end(); + }; + +})(); \ No newline at end of file diff --git a/cocos2d/render-texture/CCRenderTextureRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js similarity index 78% rename from cocos2d/render-texture/CCRenderTextureRenderCmd.js rename to cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index e559ad0305..5b2ed37d6a 100644 --- a/cocos2d/render-texture/CCRenderTextureRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -22,137 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -(function(){ - - cc.RenderTexture.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; - - this._clearColor = cc.color(255, 255, 255, 255); - this._clearColorStr = "rgba(255,255,255,1)"; - - // - // the off-screen canvas for rendering and storing the texture - // @type HTMLCanvasElement - // - this._cacheCanvas = cc.newElement('canvas'); - /** - * stores a reference to the canvas context object - * @type CanvasRenderingContext2D - */ - this._cacheContext = this._cacheCanvas.getContext('2d'); - }; - - var proto = cc.RenderTexture.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.RenderTexture.CanvasRenderCmd; - - proto.cleanup = function(){ - var node = this._node; - this._cacheContext = null; - this._cacheCanvas = null; - }; - - proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ - var node = this._node; - var locCacheCanvas = this._cacheCanvas, locScaleFactor = cc.contentScaleFactor(); - locCacheCanvas.width = 0 | (width * locScaleFactor); - locCacheCanvas.height = 0 | (height * locScaleFactor); - this._cacheContext.translate(0, locCacheCanvas.height); - var texture = new cc.Texture2D(); - texture.initWithElement(locCacheCanvas); - texture.handleLoadedTexture(); - var locSprite = node.sprite = new cc.Sprite(texture); - locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); - // Disabled by default. - node.autoDraw = false; - // add sprite for backward compatibility - node.addChild(locSprite); - return true; - }; - - proto.begin = function(){}; - - proto._beginWithClear = function(r, g, b, a, depthValue, stencilValue, flags){ - var node = this._node; - node.begin(); - - r = r || 0; - g = g || 0; - b = b || 0; - a = isNaN(a) ? 1 : a; - - //var context = cc._renderContext; - var context = this._cacheContext; - var locCanvas = this._cacheCanvas; - context.save(); - context.fillStyle = "rgba(" + (0 | r) + "," + (0 | g) + "," + (0 | b) + "," + a / 255 + ")"; - context.clearRect(0, 0, locCanvas.width, -locCanvas.height); - context.fillRect(0, 0, locCanvas.width, -locCanvas.height); - context.restore(); - }; - - proto.end = function(){ - - var node = this._node; - - //old code - //cc._renderContext = cc._mainRenderContextBackup; - //cc.view._resetScale(); - - var scale = cc.contentScaleFactor(); - cc.renderer._renderingToCacheCanvas(this._cacheContext, node.__instanceId, scale, scale); - - //TODO - /*//restore viewport - director.setViewport(); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix();*/ - }; - - proto.clearRect = function(x, y, width, height){ - this._cacheContext.clearRect(x, y, width, -height); - }; - - proto.clearDepth = function(depthValue){ - cc.log("clearDepth isn't supported on Cocos2d-Html5"); - }; - - proto.visit = function(ctx){ - var node = this._node; - ctx = ctx || cc._renderContext; - node.transform(ctx); - node.sprite.visit(ctx); - }; - - proto.draw = function(){ - var node = this._node; - if (node.clearFlags) { - var locCanvas = this._cacheCanvas; - ctx.save(); - ctx.fillStyle = this._clearColorStr; - ctx.clearRect(0, 0, locCanvas.width, -locCanvas.height); - ctx.fillRect(0, 0, locCanvas.width, -locCanvas.height); - ctx.restore(); - } - - //! make sure all children are drawn - node.sortAllChildren(); - var locChildren = node._children; - var childrenLen = locChildren.length; - var selfSprite = node.sprite; - for (var i = 0; i < childrenLen; i++) { - var getChild = locChildren[i]; - if (getChild != selfSprite) - getChild.visit(); - } - node.end(); - }; - -})(); - - (function(){ cc.RenderTexture.WebGLRenderCmd = function(renderableObject){ diff --git a/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js new file mode 100644 index 0000000000..dff4455953 --- /dev/null +++ b/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js @@ -0,0 +1,124 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + + cc.DrawNode.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + this._buffer = null; + this._drawColor = null; + this._blendFunc = null; + }; + + cc.DrawNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + cc.DrawNode.CanvasRenderCmd.prototype.constructor = cc.DrawNode.CanvasRenderCmd; + + cc.DrawNode.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, _t = this, node = _t._node; + var alpha = node._displayedOpacity / 255; + if (alpha === 0) + return; + context.globalAlpha = alpha; + + var t = this._worldTransform; + context.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) + context.globalCompositeOperation = 'lighter'; + var locBuffer = _t._buffer; + for (var i = 0, len = locBuffer.length; i < len; i++) { + var element = locBuffer[i]; + switch (element.type) { + case cc.DrawNode.TYPE_DOT: + _t._drawDot(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_SEGMENT: + _t._drawSegment(context, element, scaleX, scaleY); + break; + case cc.DrawNode.TYPE_POLY: + _t._drawPoly(context, element, scaleX, scaleY); + break; + } + } + context.restore(); + }; + + cc.DrawNode.CanvasRenderCmd.prototype._drawDot = function (ctx, element, scaleX, scaleY) { + var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; + + ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.beginPath(); + ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); + ctx.closePath(); + ctx.fill(); + }; + + cc.DrawNode.CanvasRenderCmd.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { + var locColor = element.lineColor; + var locFrom = element.verts[0], locTo = element.verts[1]; + var locLineWidth = element.lineWidth, locLineCap = element.lineCap; + + ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; + ctx.lineWidth = locLineWidth * scaleX; + ctx.beginPath(); + ctx.lineCap = locLineCap; + ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); + ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); + ctx.stroke(); + }; + + cc.DrawNode.CanvasRenderCmd.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { + var locVertices = element.verts, locLineCap = element.lineCap; + var locFillColor = element.fillColor, locLineWidth = element.lineWidth; + var locLineColor = element.lineColor, locIsClosePolygon = element.isClosePolygon; + var locIsFill = element.isFill, locIsStroke = element.isStroke; + if (locVertices == null) + return; + + var firstPoint = locVertices[0]; + ctx.lineCap = locLineCap; + if (locFillColor) + ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," + + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; + if (locLineWidth) + ctx.lineWidth = locLineWidth * scaleX; + if (locLineColor) + ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," + + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; + + ctx.beginPath(); + ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); + for (var i = 1, len = locVertices.length; i < len; i++) + ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); + + if (locIsClosePolygon) + ctx.closePath(); + if (locIsFill) + ctx.fill(); + if (locIsStroke) + ctx.stroke(); + }; + +})(); \ No newline at end of file diff --git a/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js deleted file mode 100644 index 57f7ef895b..0000000000 --- a/cocos2d/shape-nodes/CCDrawNodeRenderCmd.js +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -cc.DrawNode.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; - this._buffer = null; - this._drawColor = null; - this._blendFunc = null; -}; - -cc.DrawNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -cc.DrawNode.CanvasRenderCmd.prototype.constructor = cc.DrawNode.CanvasRenderCmd; - -cc.DrawNode.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, _t = this, node = _t._node; - var alpha = node._displayedOpacity / 255; - if (alpha === 0) - return; - context.globalAlpha = alpha; - - var t = this._worldTransform; - context.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if ((_t._blendFunc && (_t._blendFunc.src == cc.SRC_ALPHA) && (_t._blendFunc.dst == cc.ONE))) - context.globalCompositeOperation = 'lighter'; - var locBuffer = _t._buffer; - for (var i = 0, len = locBuffer.length; i < len; i++) { - var element = locBuffer[i]; - switch (element.type) { - case cc.DrawNode.TYPE_DOT: - _t._drawDot(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_SEGMENT: - _t._drawSegment(context, element, scaleX, scaleY); - break; - case cc.DrawNode.TYPE_POLY: - _t._drawPoly(context, element, scaleX, scaleY); - break; - } - } - context.restore(); -}; - -cc.DrawNode.CanvasRenderCmd.prototype._drawDot = function (ctx, element, scaleX, scaleY) { - var locColor = element.fillColor, locPos = element.verts[0], locRadius = element.lineWidth; - - ctx.fillStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.beginPath(); - ctx.arc(locPos.x * scaleX, -locPos.y * scaleY, locRadius * scaleX, 0, Math.PI * 2, false); - ctx.closePath(); - ctx.fill(); -}; - -cc.DrawNode.CanvasRenderCmd.prototype._drawSegment = function (ctx, element, scaleX, scaleY) { - var locColor = element.lineColor; - var locFrom = element.verts[0], locTo = element.verts[1]; - var locLineWidth = element.lineWidth, locLineCap = element.lineCap; - - ctx.strokeStyle = "rgba(" + (0 | locColor.r) + "," + (0 | locColor.g) + "," + (0 | locColor.b) + "," + locColor.a / 255 + ")"; - ctx.lineWidth = locLineWidth * scaleX; - ctx.beginPath(); - ctx.lineCap = locLineCap; - ctx.moveTo(locFrom.x * scaleX, -locFrom.y * scaleY); - ctx.lineTo(locTo.x * scaleX, -locTo.y * scaleY); - ctx.stroke(); -}; - -cc.DrawNode.CanvasRenderCmd.prototype._drawPoly = function (ctx, element, scaleX, scaleY) { - var locVertices = element.verts, locLineCap = element.lineCap; - var locFillColor = element.fillColor, locLineWidth = element.lineWidth; - var locLineColor = element.lineColor, locIsClosePolygon = element.isClosePolygon; - var locIsFill = element.isFill, locIsStroke = element.isStroke; - if (locVertices == null) - return; - - var firstPoint = locVertices[0]; - ctx.lineCap = locLineCap; - if (locFillColor) - ctx.fillStyle = "rgba(" + (0 | locFillColor.r) + "," + (0 | locFillColor.g) + "," - + (0 | locFillColor.b) + "," + locFillColor.a / 255 + ")"; - if (locLineWidth) - ctx.lineWidth = locLineWidth * scaleX; - if (locLineColor) - ctx.strokeStyle = "rgba(" + (0 | locLineColor.r) + "," + (0 | locLineColor.g) + "," - + (0 | locLineColor.b) + "," + locLineColor.a / 255 + ")"; - - ctx.beginPath(); - ctx.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); - for (var i = 1, len = locVertices.length; i < len; i++) - ctx.lineTo(locVertices[i].x * scaleX, -locVertices[i].y * scaleY); - - if (locIsClosePolygon) - ctx.closePath(); - if (locIsFill) - ctx.fill(); - if (locIsStroke) - ctx.stroke(); -}; - -cc.DrawNode.WebGLRenderCmd = function (renderableObject) { - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -cc.DrawNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -cc.DrawNode.WebGLRenderCmd.prototype.constructor = cc.DrawNode.WebGLRenderCmd; - -cc.DrawNode.WebGLRenderCmd.prototype.rendering = function (ctx) { - var _t = this._node; - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - _t._render(); -}; \ No newline at end of file diff --git a/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js new file mode 100644 index 0000000000..d869eab6ff --- /dev/null +++ b/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js @@ -0,0 +1,42 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + + cc.DrawNode.WebGLRenderCmd = function (renderableObject) { + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + cc.DrawNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + cc.DrawNode.WebGLRenderCmd.prototype.constructor = cc.DrawNode.WebGLRenderCmd; + + cc.DrawNode.WebGLRenderCmd.prototype.rendering = function (ctx) { + var _t = this._node; + cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + _t._shaderProgram.use(); + _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + _t._render(); + }; +})(); \ No newline at end of file diff --git a/cocos2d/tilemap/CCTMXLayerRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js similarity index 96% rename from cocos2d/tilemap/CCTMXLayerRenderCmd.js rename to cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index e2f6f69ca5..c8b54fbac3 100644 --- a/cocos2d/tilemap/CCTMXLayerRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -237,18 +237,4 @@ this._node.width = locCanvas.width; this._node.height = locCanvas.height; }; -})(); - -(function(){ - cc.TMXLayer.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; - }; - - var proto = cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering; - proto.constructor = cc.TMXLayer.WebGLRenderCmd; - - proto._updateCacheContext = function(){}; - - proto._initContentSize = function(){}; -})(); +})(); \ No newline at end of file diff --git a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js new file mode 100644 index 0000000000..0dadf059e4 --- /dev/null +++ b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + cc.TMXLayer.WebGLRenderCmd = function(renderableObject){ + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering; + proto.constructor = cc.TMXLayer.WebGLRenderCmd; + + proto._updateCacheContext = function(){}; + + proto._initContentSize = function(){}; +})(); diff --git a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js new file mode 100644 index 0000000000..fde75b81fe --- /dev/null +++ b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js @@ -0,0 +1,95 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + + ccs.Armature.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = false; + + this._startRenderCmd = new cc.CustomRenderCmd(this, this._startCmdCallback); + this._RestoreRenderCmd = new cc.CustomRenderCmd(this, this._RestoreCmdCallback); + }; + + var proto = ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = ccs.Armature.CanvasRenderCmd; + + proto.rendering = function(ctx, scaleX, scaleY){ + }; + + proto._startCmdCallback = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + var node = this._node; + context.save(); + node.transform(); + var t = this._worldTransform; + ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); + + var locChildren = node._children; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var rn = selBone.getDisplayRenderNode(); + + if (null == rn) + continue; + +// rn._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); + } + } + }; + + proto._RestoreCmdCallback = function(ctx, scaleX, scaleY){ + this._cacheDirty = false; + ctx.restore(); + }; + + proto.initShaderCache = function(){}; + proto.setShaderProgram = function(){}; + proto.updateChildPosition = function(ctx, dis){ + dis.visit(ctx); + }; + + proto.visit = function(){ + var node = this._node; + var context = cc._renderContext; + // quick return if not visible. children won't be drawn. + if (!node._visible) + return; + + context.save(); +// this.transform(); + + node.sortAllChildren(); + + cc.renderer.pushRenderCommand(this); + cc.renderer.pushRenderCommand(this._startRenderCmd); + node.draw(ctx); + cc.renderer.pushRenderCommand(this._RestoreRenderCmd); + + this._cacheDirty = false; + + context.restore(); + }; +})(); \ No newline at end of file diff --git a/extensions/cocostudio/armature/CCArmatureRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js similarity index 72% rename from extensions/cocostudio/armature/CCArmatureRenderCmd.js rename to extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index 8f753ddfa7..9cf378cbf2 100644 --- a/extensions/cocostudio/armature/CCArmatureRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -22,78 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -(function(){ - - ccs.Armature.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = false; - - this._startRenderCmd = new cc.CustomRenderCmd(this, this._startCmdCallback); - this._RestoreRenderCmd = new cc.CustomRenderCmd(this, this._RestoreCmdCallback); - }; - - var proto = ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = ccs.Armature.CanvasRenderCmd; - - proto.rendering = function(ctx, scaleX, scaleY){ - }; - - proto._startCmdCallback = function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext; - var node = this._node; - context.save(); - node.transform(); - var t = this._worldTransform; - ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); - - var locChildren = node._children; - for (var i = 0, len = locChildren.length; i< len; i++) { - var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { - var rn = selBone.getDisplayRenderNode(); - - if (null == rn) - continue; - -// rn._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); - } - } - }; - - proto._RestoreCmdCallback = function(ctx, scaleX, scaleY){ - this._cacheDirty = false; - ctx.restore(); - }; - - proto.initShaderCache = function(){}; - proto.setShaderProgram = function(){}; - proto.updateChildPosition = function(ctx, dis){ - dis.visit(ctx); - }; - - proto.visit = function(){ - var node = this._node; - var context = cc._renderContext; - // quick return if not visible. children won't be drawn. - if (!node._visible) - return; - - context.save(); -// this.transform(); - - node.sortAllChildren(); - - cc.renderer.pushRenderCommand(this); - cc.renderer.pushRenderCommand(this._startRenderCmd); - node.draw(ctx); - cc.renderer.pushRenderCommand(this._RestoreRenderCmd); - - this._cacheDirty = false; - - context.restore(); - }; -})(); - (function(){ ccs.Armature.WebGLRenderCmd = function(renderableObject){ diff --git a/moduleConfig.json b/moduleConfig.json index 6b57f65e0c..2d6283ef6c 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -28,7 +28,8 @@ "core", "shape-nodes", "cocos2d/clipping-nodes/CCClippingNode.js", - "cocos2d/clipping-nodes/CCClippingNodeRenderCmd.js" + "cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js", + "cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js" ], "compression" : [ "core", @@ -76,9 +77,11 @@ "cocos2d/core/base-nodes/BaseNodesPropertyDefine.js", "cocos2d/core/base-nodes/CCNode.js", - "cocos2d/core/base-nodes/CCNodeRenderCmd.js", + "cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js", + "cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js", "cocos2d/core/base-nodes/CCAtlasNode.js", - "cocos2d/core/base-nodes/CCAtlasNodeRenderCmd.js", + "cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js", + "cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js", "cocos2d/core/textures/TexturesWebGL.js", "cocos2d/core/textures/TexturesPropertyDefine.js", @@ -90,13 +93,16 @@ "cocos2d/core/scenes/CCLoaderScene.js", "cocos2d/core/layers/CCLayer.js", - "cocos2d/core/layers/CCLayerRenderCmd.js", + "cocos2d/core/layers/CCLayerCanvasRenderCmd.js", + "cocos2d/core/layers/CCLayerWebGLRenderCmd.js", "cocos2d/core/sprites/SpritesPropertyDefine.js", "cocos2d/core/sprites/CCSprite.js", - "cocos2d/core/sprites/CCSpriteRenderCmd.js", + "cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js", + "cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js", "cocos2d/core/sprites/CCSpriteBatchNode.js", - "cocos2d/core/sprites/CCSpriteBatchNodeRenderCmd.js", + "cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js", + "cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js", "cocos2d/core/sprites/CCBakeSprite.js", "cocos2d/core/sprites/CCAnimation.js", "cocos2d/core/sprites/CCAnimationCache.js", @@ -114,7 +120,8 @@ "cocos2d/core/labelttf/LabelTTFPropertyDefine.js", "cocos2d/core/labelttf/CCLabelTTF.js", - "cocos2d/core/labelttf/CCLabelTTFRenderCmd.js", + "cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js", + "cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js", "cocos2d/core/CCActionManager.js" ], @@ -144,9 +151,11 @@ "core", "cocos2d/labels/CCLabelAtlas.js", - "cocos2d/labels/CCLabelAtlasRenderCmd.js", + "cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js", + "cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js", "cocos2d/labels/CCLabelBMFont.js", - "cocos2d/labels/CCLabelBMFontRenderCmd.js" + "cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js", + "cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js" ], "menus" : [ "core", "actions", @@ -158,7 +167,7 @@ "core", "shaders", "kazmath", "labels", "cocos2d/motion-streak/CCMotionStreak.js", - "cocos2d/motion-streak/CCMotionStreakRenderCmd.js" + "cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js" ], "node-grid" : [ "core", @@ -176,18 +185,22 @@ "cocos2d/particle/CCPNGReader.js", "cocos2d/particle/CCTIFFReader.js", "cocos2d/particle/CCParticleSystem.js", - "cocos2d/particle/CCParticleSystemRenderCmd.js", + "cocos2d/particle/CCParticleSystemCanvasRenderCmd.js", + "cocos2d/particle/CCParticleSystemWebGLRenderCmd.js", "cocos2d/particle/CCParticleExamples.js", "cocos2d/particle/CCParticleBatchNode.js", - "cocos2d/particle/CCParticleBatchNodeRenderCmd.js" + "cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js", + "cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js" ], "physics" : [ "core", "shape-nodes", "cocos2d/physics/CCPhysicsSprite.js", "cocos2d/physics/CCPhysicsDebugNode.js", - "cocos2d/physics/CCPhysicsDebugNodeRenderCmd.js", - "cocos2d/physics/CCPhysicsSpriteRenderCmd.js" + "cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js", + "cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js", + "cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js", + "cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js" ], "progress-timer" : [ "core", "actions", @@ -200,7 +213,8 @@ "core", "cocos2d/render-texture/CCRenderTexture.js", - "cocos2d/render-texture/CCRenderTextureRenderCmd.js" + "cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js", + "cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js" ], "shaders" : [ "core", "kazmath", @@ -214,7 +228,8 @@ "core", "cocos2d/shape-nodes/CCDrawNode.js", - "cocos2d/shape-nodes/CCDrawNodeRenderCmd.js" + "cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js", + "cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js" ], "text-input" : [ "core", @@ -230,7 +245,8 @@ "cocos2d/tilemap/CCTMXXMLParser.js", "cocos2d/tilemap/CCTMXObjectGroup.js", "cocos2d/tilemap/CCTMXLayer.js", - "cocos2d/tilemap/CCTMXLayerRenderCmd.js" + "cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js", + "cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js" ], "transitions" : [ "core", "actions", "render-texture", "progress-timer", @@ -331,7 +347,8 @@ "extensions/cocostudio/armature/animation/CCTween.js", "extensions/cocostudio/armature/physics/CCColliderDetector.js", "extensions/cocostudio/armature/CCArmature.js", - "extensions/cocostudio/armature/CCArmatureRenderCmd.js", + "extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js", + "extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js", "extensions/cocostudio/armature/CCBone.js", "extensions/cocostudio/action/CCActionFrame.js", From eb22d1867caf1faa96862d48a43412630a546e91 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 10:19:54 +0800 Subject: [PATCH 0955/1564] Issue #2416: Delete superfluous code after split module --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 233 +----------------- .../physics/CCPhysicsSpriteCanvasRenderCmd.js | 49 ---- 2 files changed, 1 insertion(+), 281 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 4f92d46e64..4186419b4d 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -496,235 +496,4 @@ cc.Node.RenderCmd.prototype = { return "source-over"; } }; -})(); - -// ------------------------------ The cc.Node's render command for WebGL ---------------------------------- -(function() { - cc.Node.WebGLRenderCmd = function (renderable) { - cc.Node.RenderCmd.call(this, renderable); - - var mat4 = new cc.kmMat4(); - mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0; - mat4.mat[10] = mat4.mat[15] = 1.0; - this._transform4x4 = mat4; - this._stackMatrix = new cc.kmMat4(); - this._shaderProgram = null; - - this._camera = null; - }; - - var proto = cc.Node.WebGLRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); - proto.constructor = cc.Node.WebGLRenderCmd; - - proto.getNodeToParentTransform = function () { - var node = this._node; - if (node._usingNormalizedPosition && node._parent) { //TODO need refactor - var conSize = node._parent._contentSize; - node._position.x = node._normalizedPosition.x * conSize.width; - node._position.y = node._normalizedPosition.y * conSize.height; - node._normalizedPositionDirty = false; - } - if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; - // Translate values - var x = node._position.x, y = node._position.y; - var apx = this._anchorPointInPoints.x, napx = -apx; - var apy = this._anchorPointInPoints.y, napy = -apy; - var scx = node._scaleX, scy = node._scaleY; - var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - var rotationRadiansY = node._rotationY * 0.017453292519943295; - - if (node._ignoreAnchorPointForPosition) { - x += apx; - y += apy; - } - - // Rotation values - // Change rotation code to handle X and Y - // If we skew with the exact same value for both x and y then we're simply just rotating - var cx = 1, sx = 0, cy = 1, sy = 0; - if (node._rotationX !== 0 || node._rotationY !== 0) { - cx = Math.cos(-rotationRadiansX); - sx = Math.sin(-rotationRadiansX); - cy = Math.cos(-rotationRadiansY); - sy = Math.sin(-rotationRadiansY); - } - var needsSkewMatrix = ( node._skewX || node._skewY ); - - // optimization: - // inline anchor point calculation if skew is not needed - // Adjusted transform calculation for rotational skew - if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { - x += cy * napx * scx + -sx * napy * scy; - y += sy * napx * scx + cx * napy * scy; - } - - // Build Transform Matrix - // Adjusted transform calculation for rotational skew - var t = this._transform; - t.a = cy * scx; - t.b = sy * scx; - t.c = -sx * scy; - t.d = cx * scy; - t.tx = x; - t.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(node._skewY)), - c: Math.tan(cc.degreesToRadians(node._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t); - - // adjust anchor point - if (apx !== 0 || apy !== 0) - t = cc.affineTransformTranslate(t, napx, napy); - } - - if (node._additionalTransformDirty) { - t = cc.affineTransformConcat(t, this._additionalTransform); - node._additionalTransformDirty = false; - } - this._transform = t; - } - return this._transform; - }; - - proto.updateStatus = function () { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color - this._updateDisplayColor() - } - - if (locFlag & flags.opacityDirty) { - //update the opacity - this._updateDisplayOpacity(); - } - - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(this.getParentRenderCmd(), true); - } - }; - - proto._syncStatus = function (parentCmd) { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color - this._syncDisplayColor() - } - - if (locFlag & flags.opacityDirty) { - //update the opacity - this._syncDisplayOpacity(); - } - - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(parentCmd); - } - }; - - proto.visit = function (parentCmd) { - var _t = this, node = this._node; - // quick return if not visible - if (!node._visible) - return; - - if (node._parent && node._parent._renderCmd) - this._curLevel = node._parent._renderCmd._curLevel + 1; - - var i, currentStack = cc.current_stack; - - //optimize performance for javascript - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(_t._stackMatrix, currentStack.top); - currentStack.top = _t._stackMatrix; - - _t._syncStatus(parentCmd); - var locChildren = node._children; - if (locChildren && locChildren.length > 0) { - var childLen = locChildren.length; - node.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < childLen; i++) { - if (locChildren[i] && locChildren[i]._localZOrder < 0) - locChildren[i]._renderCmd.visit(this); - else - break; - } - - cc.renderer.pushRenderCommand(this); - // draw children zOrder >= 0 - for (; i < childLen; i++) { - if (locChildren[i]) - locChildren[i]._renderCmd.visit(this); - } - } else - cc.renderer.pushRenderCommand(this); - - //optimize performance for javascript - currentStack.top = currentStack.stack.pop(); - }; - - proto.transform = function (parentCmd, recursive) { - var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, node = this._node; - parentCmd = parentCmd || this.getParentRenderCmd(); - var parentMatrix = (parentCmd ? parentCmd._stackMatrix : cc.current_stack.top); - - // Convert 3x3 into 4x4 matrix - var trans = this.getNodeToParentTransform(); - var t4x4Mat = t4x4.mat; - t4x4Mat[0] = trans.a; - t4x4Mat[4] = trans.c; - t4x4Mat[12] = trans.tx; - t4x4Mat[1] = trans.b; - t4x4Mat[5] = trans.d; - t4x4Mat[13] = trans.ty; - - // Update Z vertex manually - t4x4Mat[14] = node._vertexZ; - - //optimize performance for Javascript - cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); - - // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if (node._camera != null && !(node.grid != null && node.grid.isActive())) { - var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; - var translate = (apx !== 0.0 || apy !== 0.0); - if (translate){ - if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - apx = 0 | apx; - apy = 0 | apy; - } - //cc.kmGLTranslatef(apx, apy, 0); - var translation = new cc.kmMat4(); - cc.kmMat4Translation(translation, apx, apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); - - node._camera._locateForRenderer(stackMatrix); - - //cc.kmGLTranslatef(-apx, -apy, 0); - cc.kmMat4Translation(translation, -apx, -apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); - } else { - node._camera._locateForRenderer(stackMatrix); - } - } - this._renderCmdDiry = false; - if(!recursive || !node._children || node._children.length === 0) - return; - var i, len, locChildren = node._children; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._renderCmd.transform(this, recursive); - } - }; - - proto.setShaderProgram = function (shaderProgram) { - this._shaderProgram = shaderProgram; - }; - - proto.getShaderProgram = function () { - return this._shaderProgram; - }; -})(); +})(); \ No newline at end of file diff --git a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js index 8f5fc6a060..c1d06cf684 100644 --- a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js @@ -42,53 +42,4 @@ proto._getNodeToParentTransform = function(){ return this._node._nodeToParentTransformForCanvas(); }; -})(); - -/** - * cc.PhysicsSprite's rendering objects of WebGL - */ -(function(){ - cc.PhysicsSprite.WebGLRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; - }; - - var proto = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.PhysicsSprite.WebGLRenderCmd; - - proto.rendering = function(){ - if(this._node._transformForRenderer) - this._node._transformForRenderer(); - }; - - proto._getNodeToParentTransform = function(){ - var locBody = this._body, locAnchorPIP = this._anchorPointInPoints, locScaleX = this._scaleX, locScaleY = this._scaleY; - var x = locBody.p.x; - var y = locBody.p.y; - - if (this._ignoreAnchorPointForPosition) { - x += locAnchorPIP.x; - y += locAnchorPIP.y; - } - - // Make matrix - var radians = locBody.a; - var c = Math.cos(radians); - var s = Math.sin(radians); - - // Although scale is not used by physics engines, it is calculated just in case - // the sprite is animated (scaled up/down) using actions. - // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990 - if (!cc._rectEqualToZero(locAnchorPIP)) { - x += c * -locAnchorPIP.x * locScaleX + -s * -locAnchorPIP.y * locScaleY; - y += s * -locAnchorPIP.x * locScaleX + c * -locAnchorPIP.y * locScaleY; - } - - // Rot, Translate Matrix - this._transform = cc.affineTransformMake(c * locScaleX, s * locScaleX, - -s * locScaleY, c * locScaleY, x, y); - - return this._transform; - }; - })(); \ No newline at end of file From ca1354c4513e0c6f8e47ba628427339a875730d6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 10:23:50 +0800 Subject: [PATCH 0956/1564] Issue #2416: Delete superfluous code after split module --- .../physics/CCPhysicsSpriteWebGLRenderCmd.js | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js index 8f5fc6a060..4334e2963d 100644 --- a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js @@ -22,28 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * cc.PhysicsSprite's rendering objects of Canvas - */ -(function(){ - cc.PhysicsSprite.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; - }; - - var proto = cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.PhysicsSprite.CanvasRenderCmd; - - proto.rendering = function(){ - if (this._node.transform) - this._node.transform(); - }; - - proto._getNodeToParentTransform = function(){ - return this._node._nodeToParentTransformForCanvas(); - }; -})(); - /** * cc.PhysicsSprite's rendering objects of WebGL */ From 9b6f7f798b8ac21920716bbc1c7da0a069a6f91d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 25 Nov 2014 10:32:04 +0800 Subject: [PATCH 0957/1564] Issue #2416: correct a mistake of cc.ProgressTimer --- cocos2d/progress-timer/CCProgressTimer.js | 11 +++--- .../CCProgressTimerRenderCmd.js | 34 ++++++++++--------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 91a76369ab..663211e246 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -177,7 +177,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ */ setColor:function (color) { this._sprite.color = color; - this._updateColor(); + this._renderCmd._updateColor(); }, /** @@ -186,7 +186,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ */ setOpacity:function (opacity) { this._sprite.opacity = opacity; - this._updateColor(); + this._renderCmd._updateColor(); }, /** @@ -239,9 +239,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {cc.ProgressTimer.TYPE_RADIAL|cc.ProgressTimer.TYPE_BAR} type */ setType: function(type){ - var node = this._node; if (type !== this._type){ - node._type = type; + this._type = type; this._renderCmd.releaseData(); } }, @@ -272,7 +271,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._reverseDirection = false; this.midPoint = cc.p(0.5, 0.5); this.barChangeRate = cc.p(1, 1); - this.sprite = sprite; + this._sprite = sprite; this._renderCmd.initCmd(); return true; }, @@ -290,6 +289,8 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ }); // Extended properties +var _p = cc.ProgressTimer.prototype; + /** @expose */ _p.midPoint; cc.defineGetterSetter(_p, "midPoint", _p.getMidpoint, _p.setMidpoint); diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js index e81038d26b..c07acc9975 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerRenderCmd.js @@ -60,23 +60,21 @@ context.globalCompositeOperation = locSprite._blendFuncStr; context.globalAlpha = alpha; - var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition, locDrawSizeCanvas = locSprite._drawSize_Canvas; - var flipXOffset = 0 | (locOffsetPosition.x), flipYOffset = -locOffsetPosition.y - locRect.height; - locDrawSizeCanvas.width = locRect.width * scaleX; - locDrawSizeCanvas.height = locRect.height * scaleY; + var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition; + var locX = locOffsetPosition.x, + locY = -locOffsetPosition.y - locRect.height, + locWidth = locRect.width, + locHeight = locRect.height; if (locSprite._flippedX) { - flipXOffset = -locOffsetPosition.x - locRect.width; + locX = -locX - locWidth; context.scale(-1, 1); } if (locSprite._flippedY) { - flipYOffset = locOffsetPosition.y; + locY = locOffsetPosition.y; context.scale(1, -1); } - flipXOffset *= scaleX; - flipYOffset *= scaleY; - //clip if (node._type == cc.ProgressTimer.TYPE_BAR) { var locBarRect = this._barRect; @@ -102,9 +100,10 @@ 0, locTextureCoord.width, locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY ); } else { context.drawImage(image, @@ -112,9 +111,10 @@ locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, - flipXOffset, flipYOffset, - locDrawSizeCanvas.width, - locDrawSizeCanvas.height + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY ); } @@ -124,7 +124,7 @@ proto.releaseData = function(){}; - proto.initCmd = function(){ }; + proto.initCmd = function(){}; proto._updateProgress = function(){ var node = this._node; @@ -210,6 +210,8 @@ locBarRect.height = -currentDrawSize.height; } }; + + proto._updateColor = function(){}; })(); From c03bce29d7a3c237935343fc3b3842cb9f462e7c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 10:57:36 +0800 Subject: [PATCH 0958/1564] Issue #2416: Delete superfluous code after split module --- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 542 +++++------------- 1 file changed, 148 insertions(+), 394 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 4186419b4d..d3a56f175f 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -21,291 +21,97 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -//---------------------- Customer render cmd -------------------- -cc.CustomRenderCmd = function (target, func) { - this._needDraw = true; - this._target = target; - this._callback = func; - - this.rendering = function (ctx, scaleX, scaleY) { - if (!this._callback) - return; - this._callback.call(this._target, ctx, scaleX, scaleY); - } -}; - - -cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty:16, orderDirty:32, textDirty:64}; - -//-------------------------Base ------------------------- -cc.Node.RenderCmd = function(renderable){ - this._dirtyFlag = 0; - - this._node = renderable; - this._needDraw = false; - this._anchorPointInPoints = new cc.Point(0,0); - - this._transform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._worldTransform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._inverse = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - - this._displayedOpacity = 255; - this._displayedColor = cc.color(255, 255, 255, 255); - this._cascadeColorEnabledDirty = false; - this._cascadeOpacityEnabledDirty = false; - - this._curLevel = -1; -}; - -cc.Node.RenderCmd.prototype = { - constructor: cc.Node.RenderCmd, - - getAnchorPointInPoints: function(){ - return cc.p(this._anchorPointInPoints); - }, - - getDisplayedColor: function(){ - var tmpColor = this._displayedColor; - return cc.color(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a); - }, - - getDisplayedOpacity: function(){ - return this._displayedOpacity; - }, - - setCascadeColorEnabledDirty: function(){ - this._cascadeColorEnabledDirty = true; - this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); - }, - - setCascadeOpacityEnabledDirty:function(){ - this._cascadeOpacityEnabledDirty = true; - this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); - }, - - getParentToNodeTransform: function(){ - if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) - this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()); - return this._inverse; - }, - - detachFromParent: function(){ - }, - - _updateAnchorPointInPoint: function() { - var locAPP = this._anchorPointInPoints, locSize = this._node._contentSize, locAnchorPoint = this._node._anchorPoint; - locAPP.x = locSize.width * locAnchorPoint.x; - locAPP.y = locSize.height * locAnchorPoint.y; - this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); - }, - - setDirtyFlag: function(dirtyFlag){ - if (this._dirtyFlag === 0 && dirtyFlag !== 0) - cc.renderer.pushDirtyNode(this); - this._dirtyFlag = this._dirtyFlag | dirtyFlag; - }, - - getParentRenderCmd: function(){ - if(this._node && this._node._parent && this._node._parent._renderCmd) - return this._node._parent._renderCmd; - return null; - }, - - _syncDisplayColor : function (parentColor) { - var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; - if (parentColor === undefined) { - var locParent = node._parent; - if (locParent && locParent._cascadeColorEnabled) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - } - locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); - locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); - locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; - }, - - _syncDisplayOpacity : function (parentOpacity) { - var node = this._node; - if (parentOpacity === undefined) { - var locParent = node._parent; - parentOpacity = 255; - if (locParent && locParent._cascadeOpacityEnabled) - parentOpacity = locParent.getDisplayedOpacity(); - } - this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; - } -}; - -//-----------------------Canvas --------------------------- - +// ------------------------------ The cc.Node's render command for WebGL ---------------------------------- (function() { -//The cc.Node's render command for Canvas - cc.Node.CanvasRenderCmd = function (renderable) { + cc.Node.WebGLRenderCmd = function (renderable) { cc.Node.RenderCmd.call(this, renderable); - this._cachedParent = null; - this._cacheDirty = false; - }; - var proto = cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); - proto.constructor = cc.Node.CanvasRenderCmd; + var mat4 = new cc.kmMat4(); + mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0; + mat4.mat[10] = mat4.mat[15] = 1.0; + this._transform4x4 = mat4; + this._stackMatrix = new cc.kmMat4(); + this._shaderProgram = null; - proto.transform = function (parentCmd, recursive) { - // transform for canvas - var t = this.getNodeToParentTransform(), - worldT = this._worldTransform; //get the world transform - - if (parentCmd) { - var pt = parentCmd._worldTransform; - // cc.AffineTransformConcat is incorrect at get world transform - worldT.a = t.a * pt.a + t.b * pt.c; //a - worldT.b = t.a * pt.b + t.b * pt.d; //b - worldT.c = t.c * pt.a + t.d * pt.c; //c - worldT.d = t.c * pt.b + t.d * pt.d; //d - - var plt = parentCmd._transform; - var xOffset = -(plt.b + plt.c) * t.ty; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty - } else { - worldT.a = t.a; - worldT.b = t.b; - worldT.c = t.c; - worldT.d = t.d; - worldT.tx = t.tx; - worldT.ty = t.ty; - } - this._renderCmdDiry = false; - if (recursive) { - var locChildren = this._node._children; - if (!locChildren || locChildren.length === 0) - return; - var i, len; - for (i = 0, len = locChildren.length; i < len; i++) { - locChildren[i]._renderCmd.transform(this, recursive); - } - } + this._camera = null; }; + var proto = cc.Node.WebGLRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); + proto.constructor = cc.Node.WebGLRenderCmd; + proto.getNodeToParentTransform = function () { - var node = this._node, normalizeDirty = false; + var node = this._node; if (node._usingNormalizedPosition && node._parent) { //TODO need refactor var conSize = node._parent._contentSize; node._position.x = node._normalizedPosition.x * conSize.width; node._position.y = node._normalizedPosition.y * conSize.height; node._normalizedPositionDirty = false; - normalizeDirty = true; } - if (normalizeDirty || (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty)) { - var t = this._transform;// quick reference - - // base position - t.tx = node._position.x; - t.ty = node._position.y; - - // rotation Cos and Sin - var Cos = 1, Sin = 0; - if (node._rotationX) { - var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - Cos = Math.cos(rotationRadiansX); - Sin = Math.sin(rotationRadiansX); - } + if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + // Translate values + var x = node._position.x, y = node._position.y; + var apx = this._anchorPointInPoints.x, napx = -apx; + var apy = this._anchorPointInPoints.y, napy = -apy; + var scx = node._scaleX, scy = node._scaleY; + var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance + var rotationRadiansY = node._rotationY * 0.017453292519943295; - // base abcd - t.a = t.d = Cos; - t.b = -Sin; - t.c = Sin; - - var lScaleX = node._scaleX, lScaleY = node._scaleY; - var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; - - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - - // skew - if (node._skewX || node._skewY) { - // offset the anchorpoint - var skx = Math.tan(-node._skewX * Math.PI / 180); //TODO - var sky = Math.tan(-node._skewY * Math.PI / 180); - if (skx === Infinity) - skx = 99999999; - if (sky === Infinity) - sky = 99999999; - var xx = appY * skx * sx; - var yy = appX * sky * sy; - t.a = Cos + -Sin * sky; - t.b = Cos * skx + -Sin; - t.c = Sin + Cos * sky; - t.d = Sin * skx + Cos; - t.tx += Cos * xx + -Sin * yy; - t.ty += Sin * xx + Cos * yy; + if (node._ignoreAnchorPointForPosition) { + x += apx; + y += apy; } - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.c *= sx; - t.b *= sy; - t.d *= sy; + // Rotation values + // Change rotation code to handle X and Y + // If we skew with the exact same value for both x and y then we're simply just rotating + var cx = 1, sx = 0, cy = 1, sy = 0; + if (node._rotationX !== 0 || node._rotationY !== 0) { + cx = Math.cos(-rotationRadiansX); + sx = Math.sin(-rotationRadiansX); + cy = Math.cos(-rotationRadiansY); + sy = Math.sin(-rotationRadiansY); + } + var needsSkewMatrix = ( node._skewX || node._skewY ); + + // optimization: + // inline anchor point calculation if skew is not needed + // Adjusted transform calculation for rotational skew + if (!needsSkewMatrix && (apx !== 0 || apy !== 0)) { + x += cy * napx * scx + -sx * napy * scy; + y += sy * napx * scx + cx * napy * scy; } - // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * appY * sy; - t.ty -= Sin * -appX * sx + Cos * appY * sy; - - // if ignore anchorPoint - if (node._ignoreAnchorPointForPosition) { - t.tx += appX; - t.ty += appY; + // Build Transform Matrix + // Adjusted transform calculation for rotational skew + var t = this._transform; + t.a = cy * scx; + t.b = sy * scx; + t.c = -sx * scy; + t.d = cx * scy; + t.tx = x; + t.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(node._skewY)), + c: Math.tan(cc.degreesToRadians(node._skewX)), d: 1.0, tx: 0.0, ty: 0.0}, t); + + // adjust anchor point + if (apx !== 0 || apy !== 0) + t = cc.affineTransformTranslate(t, napx, napy); } if (node._additionalTransformDirty) { - this._transform = cc.affineTransformConcat(t, node._additionalTransform); + t = cc.affineTransformConcat(t, this._additionalTransform); node._additionalTransformDirty = false; } - this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; + this._transform = t; } return this._transform; }; - proto.visit = function (parentCmd) { - var _t = this, node = this._node; - // quick return if not visible - if (!node._visible) - return; - - parentCmd = parentCmd || this.getParentRenderCmd(); - if (parentCmd) - this._curLevel = parentCmd._curLevel + 1; - - //visit for canvas - var i, children = node._children, child; - _t._syncStatus(parentCmd); - var len = children.length; - if (len > 0) { - node.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < len; i++) { - child = children[i]; - if (child._localZOrder < 0) - child._renderCmd.visit(this); - else - break; - } - cc.renderer.pushRenderCommand(this); - for (; i < len; i++) - children[i]._renderCmd.visit(this); - } else { - cc.renderer.pushRenderCommand(this); - } - }; - proto.updateStatus = function () { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; if (locFlag & flags.colorDirty) { @@ -342,158 +148,106 @@ cc.Node.RenderCmd.prototype = { } }; - proto._syncDisplayColor = function (parentColor) { - var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; - if (parentColor === undefined) { - var locParent = node._parent; - if (locParent && locParent._cascadeColorEnabled) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - } - locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); - locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); - locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; - }; + proto.visit = function (parentCmd) { + var _t = this, node = this._node; + // quick return if not visible + if (!node._visible) + return; - proto._syncDisplayOpacity = function (parentOpacity) { - var node = this._node; - if (parentOpacity === undefined) { - var locParent = node._parent; - parentOpacity = 255; - if (locParent && locParent._cascadeOpacityEnabled) - parentOpacity = locParent.getDisplayedOpacity(); - } - this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; - }; + if (node._parent && node._parent._renderCmd) + this._curLevel = node._parent._renderCmd._curLevel + 1; - proto._updateDisplayColor = function (parentColor) { - var node = this._node; - var locDispColor = this._displayedColor, locRealColor = node._realColor; - var i, len, selChildren, item; - if (this._cascadeColorEnabledDirty && !node._cascadeColorEnabled) { - locDispColor.r = locRealColor.r; - locDispColor.g = locRealColor.g; - locDispColor.b = locRealColor.b; - var whiteColor = new cc.Color(255, 255, 255, 255); - selChildren = node._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayColor(whiteColor); - } - } else { - if (parentColor === undefined) { - var locParent = node._parent; - if (locParent && locParent._cascadeColorEnabled) - parentColor = locParent.getDisplayedColor(); + var i, currentStack = cc.current_stack; + + //optimize performance for javascript + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(_t._stackMatrix, currentStack.top); + currentStack.top = _t._stackMatrix; + + _t._syncStatus(parentCmd); + var locChildren = node._children; + if (locChildren && locChildren.length > 0) { + var childLen = locChildren.length; + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < childLen; i++) { + if (locChildren[i] && locChildren[i]._localZOrder < 0) + locChildren[i]._renderCmd.visit(this); else - parentColor = cc.color.WHITE; - } - locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); - locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); - locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - if (node._cascadeColorEnabled) { - selChildren = node._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayColor(locDispColor); - } + break; } - } - this._cascadeColorEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; - }; - proto._updateDisplayOpacity = function (parentOpacity) { - var node = this._node; - var i, len, selChildren, item; - if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { - this._displayedOpacity = node._realOpacity; - selChildren = this._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayOpacity(255); - } - } else { - if (parentOpacity === undefined) { - var locParent = node._parent; - parentOpacity = 255; - if (locParent && locParent._cascadeOpacityEnabled) - parentOpacity = locParent.getDisplayedOpacity(); - } - this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - if (this._cascadeOpacityEnabled) { - selChildren = this._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayOpacity(this._displayedOpacity); - } + cc.renderer.pushRenderCommand(this); + // draw children zOrder >= 0 + for (; i < childLen; i++) { + if (locChildren[i]) + locChildren[i]._renderCmd.visit(this); } - } - this._cascadeOpacityEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; - }; + } else + cc.renderer.pushRenderCommand(this); - proto.setDirtyFlag = function (dirtyFlag) { - cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); - this._setCacheDirty(); + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); }; - proto._setCacheDirty = function () { - if (this._cacheDirty === false) { - this._cacheDirty = true; - var cachedP = this._cachedParent; - cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); + proto.transform = function (parentCmd, recursive) { + var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, node = this._node; + parentCmd = parentCmd || this.getParentRenderCmd(); + var parentMatrix = (parentCmd ? parentCmd._stackMatrix : cc.current_stack.top); + + // Convert 3x3 into 4x4 matrix + var trans = this.getNodeToParentTransform(); + var t4x4Mat = t4x4.mat; + t4x4Mat[0] = trans.a; + t4x4Mat[4] = trans.c; + t4x4Mat[12] = trans.tx; + t4x4Mat[1] = trans.b; + t4x4Mat[5] = trans.d; + t4x4Mat[13] = trans.ty; + + // Update Z vertex manually + t4x4Mat[14] = node._vertexZ; + + //optimize performance for Javascript + cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); + + // XXX: Expensive calls. Camera should be integrated into the cached affine matrix + if (node._camera != null && !(node.grid != null && node.grid.isActive())) { + var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; + var translate = (apx !== 0.0 || apy !== 0.0); + if (translate){ + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + apx = 0 | apx; + apy = 0 | apy; + } + //cc.kmGLTranslatef(apx, apy, 0); + var translation = new cc.kmMat4(); + cc.kmMat4Translation(translation, apx, apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + + node._camera._locateForRenderer(stackMatrix); + + //cc.kmGLTranslatef(-apx, -apy, 0); + cc.kmMat4Translation(translation, -apx, -apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + } else { + node._camera._locateForRenderer(stackMatrix); + } } - }; - - proto._setCachedParent = function (cachedParent) { - if (this._cachedParent == cachedParent) + this._renderCmdDiry = false; + if(!recursive || !node._children || node._children.length === 0) return; - - this._cachedParent = cachedParent; - var children = this._children; - for (var i = 0, len = children.length; i < len; i++) - children[i]._renderCmd._setCachedParent(cachedParent); - }; - - proto.detachFromParent = function () { - this._cachedParent = null; - var selChildren = this._node._children, item; - for (var i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd.detachFromParent(); + var i, len, locChildren = node._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(this, recursive); } }; proto.setShaderProgram = function (shaderProgram) { - //do nothing. + this._shaderProgram = shaderProgram; }; proto.getShaderProgram = function () { - return null; - }; - -//util functions - cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function (blendFunc) { - if (!blendFunc) - return "source-over"; - else { - if (( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) - return "lighter"; - else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) - return "destination-in"; - else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) - return "destination-out"; - else - return "source-over"; - } + return this._shaderProgram; }; -})(); \ No newline at end of file +})(); From 1c07114f5b5b6f1bf9a9ef40652d26849af454f0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 11:05:12 +0800 Subject: [PATCH 0959/1564] Issue #2416: Delete superfluous code after split module --- .../CCProgressTimerCanvasRenderCmd.js | 215 ++++++++++++++++++ ...md.js => CCProgressTimerWebGLRenderCmd.js} | 193 ---------------- moduleConfig.json | 3 +- 3 files changed, 217 insertions(+), 194 deletions(-) create mode 100644 cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js rename cocos2d/progress-timer/{CCProgressTimerRenderCmd.js => CCProgressTimerWebGLRenderCmd.js} (74%) diff --git a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js new file mode 100644 index 0000000000..a1beee74ac --- /dev/null +++ b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js @@ -0,0 +1,215 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * cc.ProgressTimer's rendering objects of Canvas + */ +(function(){ + cc.ProgressTimer.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + + this._PI180 = Math.PI / 180; + this._barRect = cc.rect(0, 0, 0, 0); + this._origin = cc.p(0, 0); + this._radius = 0; + this._startAngle = 270; + this._endAngle = 270; + this._counterClockWise = false; + }; + + var proto = cc.ProgressTimer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ProgressTimer.CanvasRenderCmd; + + proto.rendering = function (ctx, scaleX, scaleY) { + var context = ctx || cc._renderContext, node = this._node, locSprite = node._sprite; + + var locTextureCoord = locSprite._renderCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + + if (locTextureCoord.width === 0 || locTextureCoord.height === 0) + return; + if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) + return; + + var t = this._worldTransform; + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + + if (locSprite._blendFuncStr != "source-over") + context.globalCompositeOperation = locSprite._blendFuncStr; + context.globalAlpha = alpha; + + var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition; + var locX = locOffsetPosition.x, + locY = -locOffsetPosition.y - locRect.height, + locWidth = locRect.width, + locHeight = locRect.height; + + if (locSprite._flippedX) { + locX = -locX - locWidth; + context.scale(-1, 1); + } + if (locSprite._flippedY) { + locY = locOffsetPosition.y; + context.scale(1, -1); + } + + //clip + if (node._type == cc.ProgressTimer.TYPE_BAR) { + var locBarRect = this._barRect; + context.beginPath(); + context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); + context.clip(); + context.closePath(); + } else if (node._type == cc.ProgressTimer.TYPE_RADIAL) { + var locOriginX = this._origin.x * scaleX; + var locOriginY = this._origin.y * scaleY; + context.beginPath(); + context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); + context.lineTo(locOriginX, locOriginY); + context.clip(); + context.closePath(); + } + + //draw sprite + var image = locSprite._texture.getHtmlElementObj(); + if (locSprite._colorized) { + context.drawImage(image, + 0, + 0, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } else { + context.drawImage(image, + locTextureCoord.renderX, + locTextureCoord.renderY, + locTextureCoord.width, + locTextureCoord.height, + locX * scaleX, + locY * scaleY, + locWidth * scaleX, + locHeight * scaleY + ); + } + + context.restore(); + cc.g_NumberOfDraws++; + }; + + proto.releaseData = function(){}; + + proto.initCmd = function(){}; + + proto._updateProgress = function(){ + var node = this._node; + var locSprite = node._sprite; + var sw = locSprite.width, sh = locSprite.height; + var locMidPoint = node._midPoint; + + if (node._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; + locOrigin.y = -sh * locMidPoint.y; + + if (node._reverseDirection) { + locEndAngle = 270; + locStartAngle = 270 - 3.6 * node._percentage; + } else { + locStartAngle = -90; + locEndAngle = -90 + 3.6 * node._percentage; + } + + if (locSprite._flippedX) { + locOrigin.x -= sw * (node._midPoint.x * 2); + locStartAngle= -locStartAngle; + locEndAngle= -locEndAngle; + locStartAngle -= 180; + locEndAngle -= 180; + locCounterClockWise = !locCounterClockWise; + } + if (locSprite._flippedY) { + locOrigin.y+=sh*(node._midPoint.y*2); + locCounterClockWise = !locCounterClockWise; + locStartAngle= -locStartAngle; + locEndAngle= -locEndAngle; + } + + this._startAngle = locStartAngle; + this._endAngle = locEndAngle; + this._counterClockWise = locCounterClockWise; + } else { + var locBarChangeRate = node._barChangeRate; + var percentageF = node._percentage / 100; + var locBarRect = this._barRect; + + var drewSize = cc.size((sw * (1 - locBarChangeRate.x)), (sh * (1 - locBarChangeRate.y))); + var drawingSize = cc.size((sw - drewSize.width) * percentageF, (sh - drewSize.height) * percentageF); + var currentDrawSize = cc.size(drewSize.width + drawingSize.width, drewSize.height + drawingSize.height); + + var startPoint = cc.p(sw * locMidPoint.x, sh * locMidPoint.y); + + var needToLeft = startPoint.x - currentDrawSize.width / 2; + if ((locMidPoint.x > 0.5) && (currentDrawSize.width / 2 >= sw - startPoint.x)) + needToLeft = sw - currentDrawSize.width; + + var needToTop = startPoint.y - currentDrawSize.height / 2; + if ((locMidPoint.y > 0.5) && (currentDrawSize.height / 2 >= sh - startPoint.y)) + needToTop = sh - currentDrawSize.height; + + //left pos + locBarRect.x = 0; + var flipXNeed = 1; + if (locSprite._flippedX) { + locBarRect.x -= currentDrawSize.width; + flipXNeed = -1; + } + + if (needToLeft > 0) + locBarRect.x += needToLeft * flipXNeed; + + //right pos + locBarRect.y = 0; + var flipYNeed = 1; + if (locSprite._flippedY) { + locBarRect.y += currentDrawSize.height; + flipYNeed = -1; + } + + if (needToTop > 0) + locBarRect.y -= needToTop * flipYNeed; + + //clip width and clip height + locBarRect.width = currentDrawSize.width; + locBarRect.height = -currentDrawSize.height; + } + }; + + proto._updateColor = function(){}; +})(); \ No newline at end of file diff --git a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js similarity index 74% rename from cocos2d/progress-timer/CCProgressTimerRenderCmd.js rename to cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index c07acc9975..34254d92c1 100644 --- a/cocos2d/progress-timer/CCProgressTimerRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -22,199 +22,6 @@ THE SOFTWARE. ****************************************************************************/ -/** - * cc.ProgressTimer's rendering objects of Canvas - */ -(function(){ - cc.ProgressTimer.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; - - this._PI180 = Math.PI / 180; - this._barRect = cc.rect(0, 0, 0, 0); - this._origin = cc.p(0, 0); - this._radius = 0; - this._startAngle = 270; - this._endAngle = 270; - this._counterClockWise = false; - }; - - var proto = cc.ProgressTimer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); - proto.constructor = cc.ProgressTimer.CanvasRenderCmd; - - proto.rendering = function (ctx, scaleX, scaleY) { - var context = ctx || cc._renderContext, node = this._node, locSprite = node._sprite; - - var locTextureCoord = locSprite._renderCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; - - if (locTextureCoord.width === 0 || locTextureCoord.height === 0) - return; - if (!locSprite._texture || !locTextureCoord.validRect || alpha === 0) - return; - - var t = this._worldTransform; - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - if (locSprite._blendFuncStr != "source-over") - context.globalCompositeOperation = locSprite._blendFuncStr; - context.globalAlpha = alpha; - - var locRect = locSprite._rect, locOffsetPosition = locSprite._offsetPosition; - var locX = locOffsetPosition.x, - locY = -locOffsetPosition.y - locRect.height, - locWidth = locRect.width, - locHeight = locRect.height; - - if (locSprite._flippedX) { - locX = -locX - locWidth; - context.scale(-1, 1); - } - if (locSprite._flippedY) { - locY = locOffsetPosition.y; - context.scale(1, -1); - } - - //clip - if (node._type == cc.ProgressTimer.TYPE_BAR) { - var locBarRect = this._barRect; - context.beginPath(); - context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); - context.clip(); - context.closePath(); - } else if (node._type == cc.ProgressTimer.TYPE_RADIAL) { - var locOriginX = this._origin.x * scaleX; - var locOriginY = this._origin.y * scaleY; - context.beginPath(); - context.arc(locOriginX, locOriginY, this._radius * scaleY, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise); - context.lineTo(locOriginX, locOriginY); - context.clip(); - context.closePath(); - } - - //draw sprite - var image = locSprite._texture.getHtmlElementObj(); - if (locSprite._colorized) { - context.drawImage(image, - 0, - 0, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); - } else { - context.drawImage(image, - locTextureCoord.renderX, - locTextureCoord.renderY, - locTextureCoord.width, - locTextureCoord.height, - locX * scaleX, - locY * scaleY, - locWidth * scaleX, - locHeight * scaleY - ); - } - - context.restore(); - cc.g_NumberOfDraws++; - }; - - proto.releaseData = function(){}; - - proto.initCmd = function(){}; - - proto._updateProgress = function(){ - var node = this._node; - var locSprite = node._sprite; - var sw = locSprite.width, sh = locSprite.height; - var locMidPoint = node._midPoint; - - if (node._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; - locOrigin.y = -sh * locMidPoint.y; - - if (node._reverseDirection) { - locEndAngle = 270; - locStartAngle = 270 - 3.6 * node._percentage; - } else { - locStartAngle = -90; - locEndAngle = -90 + 3.6 * node._percentage; - } - - if (locSprite._flippedX) { - locOrigin.x -= sw * (node._midPoint.x * 2); - locStartAngle= -locStartAngle; - locEndAngle= -locEndAngle; - locStartAngle -= 180; - locEndAngle -= 180; - locCounterClockWise = !locCounterClockWise; - } - if (locSprite._flippedY) { - locOrigin.y+=sh*(node._midPoint.y*2); - locCounterClockWise = !locCounterClockWise; - locStartAngle= -locStartAngle; - locEndAngle= -locEndAngle; - } - - this._startAngle = locStartAngle; - this._endAngle = locEndAngle; - this._counterClockWise = locCounterClockWise; - } else { - var locBarChangeRate = node._barChangeRate; - var percentageF = node._percentage / 100; - var locBarRect = this._barRect; - - var drewSize = cc.size((sw * (1 - locBarChangeRate.x)), (sh * (1 - locBarChangeRate.y))); - var drawingSize = cc.size((sw - drewSize.width) * percentageF, (sh - drewSize.height) * percentageF); - var currentDrawSize = cc.size(drewSize.width + drawingSize.width, drewSize.height + drawingSize.height); - - var startPoint = cc.p(sw * locMidPoint.x, sh * locMidPoint.y); - - var needToLeft = startPoint.x - currentDrawSize.width / 2; - if ((locMidPoint.x > 0.5) && (currentDrawSize.width / 2 >= sw - startPoint.x)) - needToLeft = sw - currentDrawSize.width; - - var needToTop = startPoint.y - currentDrawSize.height / 2; - if ((locMidPoint.y > 0.5) && (currentDrawSize.height / 2 >= sh - startPoint.y)) - needToTop = sh - currentDrawSize.height; - - //left pos - locBarRect.x = 0; - var flipXNeed = 1; - if (locSprite._flippedX) { - locBarRect.x -= currentDrawSize.width; - flipXNeed = -1; - } - - if (needToLeft > 0) - locBarRect.x += needToLeft * flipXNeed; - - //right pos - locBarRect.y = 0; - var flipYNeed = 1; - if (locSprite._flippedY) { - locBarRect.y += currentDrawSize.height; - flipYNeed = -1; - } - - if (needToTop > 0) - locBarRect.y -= needToTop * flipYNeed; - - //clip width and clip height - locBarRect.width = currentDrawSize.width; - locBarRect.height = -currentDrawSize.height; - } - }; - - proto._updateColor = function(){}; -})(); - - /** * cc.ProgressTimer's rendering objects of WebGL */ diff --git a/moduleConfig.json b/moduleConfig.json index 2d6283ef6c..3e010669be 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -207,7 +207,8 @@ "cocos2d/progress-timer/CCProgressTimer.js", "cocos2d/progress-timer/CCActionProgressTimer.js", - "cocos2d/progress-timer/CCProgressTimerRenderCmd.js" + "cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js", + "cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js" ], "render-texture" : [ "core", From f5bb4a0ee721c786f08b116c56e57085de1a947b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 25 Nov 2014 11:25:39 +0800 Subject: [PATCH 0960/1564] Issue #2416: refactor cc.RenderTexture --- cocos2d/render-texture/CCRenderTexture.js | 41 +------------------ .../CCRenderTextureCanvasRenderCmd.js | 13 +----- .../CCRenderTextureWebGLRenderCmd.js | 40 +++++++++--------- 3 files changed, 24 insertions(+), 70 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index a0332fe612..ba84c383b0 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -90,10 +90,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ clearDepthVal:0, autoDraw:false, - - _fBO:0, - _depthRenderBuffer:0, - _oldFBO:0, _texture:null, _textureCopy:null, _uITextureImage:null, @@ -101,6 +97,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ _pixelFormat:cc.Texture2D.PIXEL_FORMAT_RGBA8888, clearStencilVal:0, + _clearColor:null, _className:"RenderTexture", @@ -133,8 +130,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ depthStencilFormat = depthStencilFormat || 0; this.initWithWidthAndHeight(width, height, format, depthStencilFormat); } - this.anchorX = 0; - this.anchorY = 0; + this.setAnchorPoint(0,0); }, _createRenderCmd: function(){ @@ -277,33 +273,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ gl.clearStencil(stencilClearValue); }, - /** - * Recursive method that visit its children and draw them - * @function - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx - */ - visit: function(){ - - // override visit. - // Don't call visit on its children - if (!this._visible) - return; - this._renderCmd.visit(); - }, - - /** - * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function - * @function - * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context - */ - draw: function(ctx){ - ctx = ctx || cc._renderContext; - if (this.autoDraw) { - this.begin(); - this._renderCmd.draw(ctx); - } - }, - /** * creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete. * @return {*} @@ -313,12 +282,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ return null; }, - _memcpy:function (destArr, destIndex, srcArr, srcIndex, size) { - for (var i = 0; i < size; i++) { - destArr[destIndex + i] = srcArr[srcIndex + i]; - } - }, - /** * saves the texture into a file using JPEG format. The file will be saved in the Documents folder. * Returns YES if the operation is successful. diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js index abea97d466..a1cf4eb277 100644 --- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -36,10 +36,6 @@ // @type HTMLCanvasElement // this._cacheCanvas = cc.newElement('canvas'); - /** - * stores a reference to the canvas context object - * @type CanvasRenderingContext2D - */ this._cacheContext = this._cacheCanvas.getContext('2d'); }; @@ -47,7 +43,6 @@ proto.constructor = cc.RenderTexture.CanvasRenderCmd; proto.cleanup = function(){ - var node = this._node; this._cacheContext = null; this._cacheCanvas = null; }; @@ -92,7 +87,6 @@ }; proto.end = function(){ - var node = this._node; //old code @@ -103,12 +97,7 @@ cc.renderer._renderingToCacheCanvas(this._cacheContext, node.__instanceId, scale, scale); //TODO - /*//restore viewport - director.setViewport(); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix();*/ + //restore viewport }; proto.clearRect = function(x, y, width, height){ diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index 5b2ed37d6a..6c1f2f8708 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -29,6 +29,9 @@ this._needDraw = true; this._clearColor = cc.color(0, 0, 0, 0); + this._fBO = null; + this._oldFBO = null; + this._depthRenderBuffer = null; }; var proto = cc.RenderTexture.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); @@ -94,9 +97,9 @@ node._textureCopy = null; var gl = cc._renderContext; - gl.deleteFramebuffer(node._fBO); - if (node._depthRenderBuffer) - gl.deleteRenderbuffer(node._depthRenderBuffer); + gl.deleteFramebuffer(this._fBO); + if (this._depthRenderBuffer) + gl.deleteRenderbuffer(this._depthRenderBuffer); node._uITextureImage = null; //if (node._texture) // node._texture.releaseTexture(); @@ -112,7 +115,7 @@ width = 0 | (width * locScaleFactor); height = 0 | (height * locScaleFactor); - node._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); + this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); // textures must be power of two squared var powW , powH; @@ -152,23 +155,23 @@ } // generate FBO - node._fBO = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, node._fBO); + this._fBO = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO); // associate texture with FBO gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, locTexture._webTextureObj, 0); if (depthStencilFormat != 0) { //create and attach depth buffer - node._depthRenderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, node._depthRenderBuffer); + this._depthRenderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderBuffer); gl.renderbufferStorage(gl.RENDERBUFFER, depthStencilFormat, powW, powH); - if(depthStencilFormat == gl.DEPTH_STENCIL) - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, node._depthRenderBuffer); - else if(depthStencilFormat == gl.STENCIL_INDEX || depthStencilFormat == gl.STENCIL_INDEX8) - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, node._depthRenderBuffer); - else if(depthStencilFormat == gl.DEPTH_COMPONENT16) - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, node._depthRenderBuffer); + if(depthStencilFormat === gl.DEPTH_STENCIL) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); + else if(depthStencilFormat === gl.STENCIL_INDEX || depthStencilFormat === gl.STENCIL_INDEX8) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); + else if(depthStencilFormat === gl.DEPTH_COMPONENT16) + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderBuffer); } // check if it worked (probably worth doing :) ) @@ -183,7 +186,7 @@ locSprite.setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); gl.bindRenderbuffer(gl.RENDERBUFFER, oldRBO); - gl.bindFramebuffer(gl.FRAMEBUFFER, node._oldFBO); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO); // Disabled by default. node.autoDraw = false; @@ -221,8 +224,8 @@ -1.0 / heightRatio, 1.0 / heightRatio, -1, 1); cc.kmGLMultMatrix(orthoMatrix); - node._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); - gl.bindFramebuffer(gl.FRAMEBUFFER, node._fBO);//Will direct drawing to the frame buffer created above + this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO);//Will direct drawing to the frame buffer created above /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. * The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. @@ -288,7 +291,7 @@ var gl = cc._renderContext; var director = cc.director; - gl.bindFramebuffer(gl.FRAMEBUFFER, node._oldFBO); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._oldFBO); //restore viewport director.setViewport(); @@ -405,5 +408,4 @@ this.end(); }; - })(); \ No newline at end of file From 5ec9e2d88aa35c4723f4e4d9c4ccd1b5a2f9c79c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 14:07:06 +0800 Subject: [PATCH 0961/1564] Issue #2416: Skeleton renderCmd --- extensions/spine/CCSkeleton.js | 27 +-- extensions/spine/CCSkeletonCanvasRenderCmd.js | 139 +++++++++++ extensions/spine/CCSkeletonRenderCmd.js.js | 217 ------------------ extensions/spine/CCSkeletonWebGLRenderCmd.js | 156 +++++++++++++ moduleConfig.json | 3 +- 5 files changed, 304 insertions(+), 238 deletions(-) create mode 100644 extensions/spine/CCSkeletonCanvasRenderCmd.js delete mode 100644 extensions/spine/CCSkeletonRenderCmd.js.js create mode 100644 extensions/spine/CCSkeletonWebGLRenderCmd.js diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 7afbd19f35..cf286c907a 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -92,11 +92,11 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ this.initWithArgs(skeletonDataFile, atlasFile, scale); }, - _initRendererCmd:function () { + _createRenderCmd:function () { if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._renderCmd = new sp.Skeleton.CanvasRenderCmd(this); + return new sp.Skeleton.CanvasRenderCmd(this); else - this._renderCmd = new sp.Skeleton.WebGLRenderCmd(this); + return new sp.Skeleton.WebGLRenderCmd(this); }, /** @@ -107,8 +107,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ this.setOpacityModifyRGB(true); this._blendFunc.src = cc.ONE; this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; - if (cc._renderType === cc._RENDER_TYPE_WEBGL) - this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + this._renderCmd.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); this.scheduleUpdate(); }, @@ -296,20 +295,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ this._rootBone = this._skeleton.getRootBone(); this._ownsSkeletonData = ownsSkeletonData; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - var locSkeleton = this._skeleton, rendererObject, rect; - for (var i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { - var slot = locSkeleton.drawOrder[i]; - var attachment = slot.attachment; - if (!(attachment instanceof spine.RegionAttachment)) - continue; - rendererObject = attachment.rendererObject; - rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); - var sprite = new cc.Sprite(rendererObject.page._texture, rect, rendererObject.rotate); - this.addChild(sprite,-1); - slot.currentSprite = sprite; - } - } + this._renderCmd._createChildFormSkeletonData(); }, /** @@ -352,6 +338,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ update: function (dt) { this._skeleton.update(dt); + this._renderCmd._updateChild(); if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var locSkeleton = this._skeleton; locSkeleton.updateWorldTransform(); @@ -377,7 +364,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ var bone = slot.bone; selSprite.setPosition(bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01, - bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); + bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); selSprite.setScale(bone.worldScaleX, bone.worldScaleY); selSprite.setRotation(- (slot.bone.worldRotation + attachment.rotation)); } diff --git a/extensions/spine/CCSkeletonCanvasRenderCmd.js b/extensions/spine/CCSkeletonCanvasRenderCmd.js new file mode 100644 index 0000000000..e35d6c21ad --- /dev/null +++ b/extensions/spine/CCSkeletonCanvasRenderCmd.js @@ -0,0 +1,139 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + sp.Skeleton.CanvasRenderCmd = function(renderableObject){ + cc.Node.CanvasRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = sp.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = sp.Skeleton.CanvasRenderCmd; + + proto.rendering = function (ctx, scaleX, scaleY) { + var node = this._node; + ctx = ctx || cc._renderContext; + + if (!node._debugSlots && !node._debugBones) { + return; + } + var t = this._worldTransform; + ctx.save(); + ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + var locSkeleton = node._skeleton; + var attachment, slot, i, n, drawingUtil = cc._drawingUtil; + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + var points = []; + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); + drawingUtil.drawPoly(points, 4, true); + } + } + + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine( + {x: bone.worldX, y: bone.worldY}, + {x: x, y: y}); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint({x: bone.worldX, y: bone.worldY}); + if (i === 0) + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + ctx.restore(); + }; + + proto._createChildFormSkeletonData = function(){ + var node = this._node; + var locSkeleton = node._skeleton, rendererObject, rect; + for (var i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { + var slot = locSkeleton.drawOrder[i]; + var attachment = slot.attachment; + if (!(attachment instanceof spine.RegionAttachment)) + continue; + rendererObject = attachment.rendererObject; + rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); + var sprite = new cc.Sprite(rendererObject.page._texture, rect, rendererObject.rotate); + node.addChild(sprite,-1); + slot.currentSprite = sprite; + } + }; + + proto._updateChild = function(){ + var node = this._node; + var locSkeleton = node._skeleton; + locSkeleton.updateWorldTransform(); + var drawOrder = node._skeleton.drawOrder; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var attachment = slot.attachment, selSprite = slot.currentSprite; + if (!(attachment instanceof spine.RegionAttachment)) { + if(selSprite) + selSprite.setVisible(false); + continue; + } + if(!selSprite){ + var rendererObject = attachment.rendererObject; + var rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); + var sprite = new cc.Sprite(rendererObject.page._texture, rect, rendererObject.rotate); + node.addChild(sprite,-1); + slot.currentSprite = sprite; + } + selSprite.setVisible(true); + //update color and blendFunc + selSprite.setBlendFunc(cc.BLEND_SRC, slot.data.additiveBlending ? cc.ONE : cc.BLEND_DST); + + var bone = slot.bone; + selSprite.setPosition(bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01, + bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); + selSprite.setScale(bone.worldScaleX, bone.worldScaleY); + selSprite.setRotation(- (slot.bone.worldRotation + attachment.rotation)); + } + }; + +})(); \ No newline at end of file diff --git a/extensions/spine/CCSkeletonRenderCmd.js.js b/extensions/spine/CCSkeletonRenderCmd.js.js deleted file mode 100644 index b98f10e119..0000000000 --- a/extensions/spine/CCSkeletonRenderCmd.js.js +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -sp.Skeleton.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -sp.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); -sp.Skeleton.CanvasRenderCmd.prototype.constructor = sp.Skeleton.CanvasRenderCmd; - -sp.Skeleton.CanvasRenderCmd.prototype.rendering = function (ctx, scaleX, scaleY) { - var node = this._node; - ctx = ctx || cc._renderContext; - - if (!node._debugSlots && !node._debugBones) { - return; - } - var t = this._worldTransform; - ctx.save(); - ctx.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - var locSkeleton = node._skeleton; - var attachment, slot, i, n, drawingUtil = cc._drawingUtil; - if (node._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); - - var points = []; - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); - drawingUtil.drawPoly(points, 4, true); - } - } - - if (node._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine( - {x: bone.worldX, y: bone.worldY}, - {x: x, y: y}); - } - - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint({x: bone.worldX, y: bone.worldY}); - if (i === 0) - drawingUtil.setDrawColor(0, 255, 0, 255); - } - } - ctx.restore(); -}; - - - -sp.Skeleton.WebGLRenderCmd = function (renderableObject) { - cc.Node.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = true; -}; - -sp.Skeleton.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); -sp.Skeleton.WebGLRenderCmd.prototype.constructor = sp.Skeleton.WebGLRenderCmd; - -sp.Skeleton.WebGLRenderCmd.prototype.rendering = function (ctx) { - var node = this._node; - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); -// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - var color = node.getColor(), locSkeleton = node._skeleton; - locSkeleton.r = color.r / 255; - locSkeleton.g = color.g / 255; - locSkeleton.b = color.b / 255; - locSkeleton.a = node.getOpacity() / 255; - if (node._premultipliedAlpha) { - locSkeleton.r *= locSkeleton.a; - locSkeleton.g *= locSkeleton.a; - locSkeleton.b *= locSkeleton.a; - } - - var additive, textureAtlas, attachment, slot, i, n, - quad = new cc.V3F_C4B_T2F_Quad(); - var locBlendFunc = node._blendFunc; - - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - var regionTextureAtlas = node.getTextureAtlas(attachment); - - if (slot.data.additiveBlending != additive) { - if (textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - additive = !additive; - cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); - } else if (regionTextureAtlas != textureAtlas && textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - textureAtlas = regionTextureAtlas; - - var quadCount = textureAtlas.getTotalQuads(); - if (textureAtlas.getCapacity() == quadCount) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) - return; - } - - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); - textureAtlas.updateQuad(quad, quadCount); - } - - if (textureAtlas) { - textureAtlas.drawQuads(); - textureAtlas.removeAllQuads(); - } - - if (node._debugBones || node._debugSlots) { - - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - //cc.kmGLPushMatrixWitMat4(node._stackMatrix); - cc.current_stack.stack.push(cc.current_stack.top); - cc.current_stack.top = node._stackMatrix; - - var drawingUtil = cc._drawingUtil; - - if (node._debugSlots) { - // Slots. - drawingUtil.setDrawColor(0, 0, 255, 255); - drawingUtil.setLineWidth(1); - - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) - continue; - attachment = slot.attachment; - quad = new cc.V3F_C4B_T2F_Quad(); - sp._regionAttachment_updateQuad(attachment, slot, quad); - - var points = []; - points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); - points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); - points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); - points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); - - drawingUtil.drawPoly(points, 4, true); - } - } - - if (node._debugBones) { - // Bone lengths. - var bone; - drawingUtil.setLineWidth(2); - drawingUtil.setDrawColor(255, 0, 0, 255); - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - var x = bone.data.length * bone.m00 + bone.worldX; - var y = bone.data.length * bone.m10 + bone.worldY; - drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); - } - - // Bone origins. - drawingUtil.setPointSize(4); - drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. - - for (i = 0, n = locSkeleton.bones.length; i < n; i++) { - bone = locSkeleton.bones[i]; - drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); - if (i == 0) { - drawingUtil.setDrawColor(0, 255, 0, 255); - } - } - } - - cc.kmGLPopMatrix(); - } -}; \ No newline at end of file diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js new file mode 100644 index 0000000000..d9a6baabfa --- /dev/null +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -0,0 +1,156 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + sp.Skeleton.WebGLRenderCmd = function (renderableObject) { + cc.Node.WebGLRenderCmd.call(this, renderableObject); + this._needDraw = true; + }; + + var proto = sp.Skeleton.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = sp.Skeleton.WebGLRenderCmd; + + proto.rendering = function (ctx) { + var node = this._node; + node._shaderProgram.use(); + node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); +// cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); + var color = node.getColor(), locSkeleton = node._skeleton; + locSkeleton.r = color.r / 255; + locSkeleton.g = color.g / 255; + locSkeleton.b = color.b / 255; + locSkeleton.a = node.getOpacity() / 255; + if (node._premultipliedAlpha) { + locSkeleton.r *= locSkeleton.a; + locSkeleton.g *= locSkeleton.a; + locSkeleton.b *= locSkeleton.a; + } + + var additive, textureAtlas, attachment, slot, i, n, + quad = new cc.V3F_C4B_T2F_Quad(); + var locBlendFunc = node._blendFunc; + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + var regionTextureAtlas = node.getTextureAtlas(attachment); + + if (slot.data.additiveBlending != additive) { + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + additive = !additive; + cc.glBlendFunc(locBlendFunc.src, additive ? cc.ONE : locBlendFunc.dst); + } else if (regionTextureAtlas != textureAtlas && textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + textureAtlas = regionTextureAtlas; + + var quadCount = textureAtlas.getTotalQuads(); + if (textureAtlas.getCapacity() == quadCount) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + if (!textureAtlas.resizeCapacity(textureAtlas.getCapacity() * 2)) + return; + } + + sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + textureAtlas.updateQuad(quad, quadCount); + } + + if (textureAtlas) { + textureAtlas.drawQuads(); + textureAtlas.removeAllQuads(); + } + + if (node._debugBones || node._debugSlots) { + + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + //cc.kmGLPushMatrixWitMat4(node._stackMatrix); + cc.current_stack.stack.push(cc.current_stack.top); + cc.current_stack.top = node._stackMatrix; + + var drawingUtil = cc._drawingUtil; + + if (node._debugSlots) { + // Slots. + drawingUtil.setDrawColor(0, 0, 255, 255); + drawingUtil.setLineWidth(1); + + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + continue; + attachment = slot.attachment; + quad = new cc.V3F_C4B_T2F_Quad(); + sp._regionAttachment_updateQuad(attachment, slot, quad); + + var points = []; + points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); + points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); + points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); + points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); + + drawingUtil.drawPoly(points, 4, true); + } + } + + if (node._debugBones) { + // Bone lengths. + var bone; + drawingUtil.setLineWidth(2); + drawingUtil.setDrawColor(255, 0, 0, 255); + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + var x = bone.data.length * bone.m00 + bone.worldX; + var y = bone.data.length * bone.m10 + bone.worldY; + drawingUtil.drawLine(cc.p(bone.worldX, bone.worldY), cc.p(x, y)); + } + + // Bone origins. + drawingUtil.setPointSize(4); + drawingUtil.setDrawColor(0, 0, 255, 255); // Root bone is blue. + + for (i = 0, n = locSkeleton.bones.length; i < n; i++) { + bone = locSkeleton.bones[i]; + drawingUtil.drawPoint(cc.p(bone.worldX, bone.worldY)); + if (i == 0) { + drawingUtil.setDrawColor(0, 255, 0, 255); + } + } + } + + cc.kmGLPopMatrix(); + } + }; + + proto._createChildFormSkeletonData = function(){}; + + proto._updateChild = function(){}; +})(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 3e010669be..6314d739f9 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -430,7 +430,8 @@ "extensions/spine/Spine.js", "extensions/spine/CCSkeleton.js", "extensions/spine/CCSkeletonAnimation.js", - "extensions/spine/CCSkeletonRenderCmd.js.js" + "extensions/spine/CCSkeletonCanvasRenderCmd.js", + "extensions/spine/CCSkeletonWebGLRenderCmd.js" ], "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "spine", "ccpool"], From c2da2d0462808ded84c8c562257252941f0dbf9f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 20:58:52 +0800 Subject: [PATCH 0962/1564] Fixed a bug that atlasNode change [color | opacity] error --- .../base-nodes/CCAtlasNodeCanvasRenderCmd.js | 6 +++--- cocos2d/core/base-nodes/CCNode.js | 6 +++--- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 21 +++++++++++++++++-- cocos2d/labels/CCLabelAtlas.js | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js index ea85928db8..e236ae82fb 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js @@ -114,9 +114,9 @@ var node = this._node; cc.Node.prototype.setOpacity.call(node, opacity); // special opacity for premultiplied textures - if (node._opacityModifyRGB) { - node.color = this._colorUnmodified; - } + //if (node._opacityModifyRGB) { + // node.color = this._colorUnmodified; + //} }; proto.getTexture = function(){ diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b8aaad8431..f404b60cce 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -780,8 +780,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ setVisible: function (visible) { if(this._visible != visible){ this._visible = visible; - if(visible) - this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.visibleDirty); + //if(visible) + // this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.visibleDirty); cc.renderer.childrenOrderDirty = true; } }, @@ -1333,7 +1333,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if (this._children.indexOf(child) > -1) this._detachChild(child, cleanup); - this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.visibleDirty); + //this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.visibleDirty); cc.renderer.childrenOrderDirty = true; }, diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 4186419b4d..855309b999 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -304,6 +304,7 @@ cc.Node.RenderCmd.prototype = { } else { cc.renderer.pushRenderCommand(this); } + _t._dirtyFlag = 0; }; proto.updateStatus = function () { @@ -325,7 +326,23 @@ cc.Node.RenderCmd.prototype = { }; proto._syncStatus = function (parentCmd) { + // In the visit logic does not restore the _dirtyFlag + // Because child elements need parent's _dirtyFlag to change himself var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var parentNode = parentCmd ? parentCmd._node : null; + + // There is a possibility: + // The parent element changed color, child element not change + // This will cause the parent element changed color, + // but while the child element does not enter the circulation + // Here will be reset state in last, + // in order to let the child elements to obtain the parent state + if(parentNode && parentNode._cascadeColorEnabled && (parentCmd._dirtyFlag & flags.colorDirty)) + locFlag |= flags.colorDirty; + + if(parentNode && parentNode._cascadeOpacityEnabled && (parentCmd._dirtyFlag & flags.opacityDirty)) + locFlag |= flags.opacityDirty; + if (locFlag & flags.colorDirty) { //update the color this._syncDisplayColor() @@ -354,7 +371,7 @@ cc.Node.RenderCmd.prototype = { locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + //this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; }; proto._syncDisplayOpacity = function (parentOpacity) { @@ -366,7 +383,7 @@ cc.Node.RenderCmd.prototype = { parentOpacity = locParent.getDisplayedOpacity(); } this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + //this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; }; proto._updateDisplayColor = function (parentColor) { diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index b0f273cd06..fdfc8ad7bd 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -71,7 +71,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ cc.AtlasNode.prototype.ctor.call(this); this._cascadeOpacityEnabled = true; - this._cascadeColorEnabled = true; + this._cascadeColorEnabled = false; charMapFile && cc.LabelAtlas.prototype.initWithString.call(this, strText, charMapFile, itemWidth, itemHeight, startCharMap); }, From 2ada7cde88ee0d597134c660c73d3b2d2eb8026e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 25 Nov 2014 21:01:46 +0800 Subject: [PATCH 0963/1564] Issue #2416: Change the notes --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 855309b999..383740640e 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -333,10 +333,10 @@ cc.Node.RenderCmd.prototype = { // There is a possibility: // The parent element changed color, child element not change - // This will cause the parent element changed color, - // but while the child element does not enter the circulation - // Here will be reset state in last, - // in order to let the child elements to obtain the parent state + // This will cause the parent element changed color + // But while the child element does not enter the circulation + // Here will be reset state in last + // In order the child elements get the parent state if(parentNode && parentNode._cascadeColorEnabled && (parentCmd._dirtyFlag & flags.colorDirty)) locFlag |= flags.colorDirty; From 29e49439ece629b5883d170879486b13111b44ee Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 09:54:55 +0800 Subject: [PATCH 0964/1564] Issue #2416: Fixed labelAtlas literal transparency and text initialization --- cocos2d/labels/CCLabelAtlas.js | 3 +-- cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js | 6 ++++++ cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index fdfc8ad7bd..02dd82537b 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -70,8 +70,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ ctor: function (strText, charMapFile, itemWidth, itemHeight, startCharMap) { cc.AtlasNode.prototype.ctor.call(this); - this._cascadeOpacityEnabled = true; - this._cascadeColorEnabled = false; + this._renderCmd.setCascade(); charMapFile && cc.LabelAtlas.prototype.initWithString.call(this, strText, charMapFile, itemWidth, itemHeight, startCharMap); }, diff --git a/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js index 02c6ef7c57..035554b205 100644 --- a/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js @@ -31,6 +31,12 @@ var proto = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype); proto.constructor = cc.LabelAtlas.CanvasRenderCmd; + proto.setCascade = function(){ + var node = this._node; + node._cascadeOpacityEnabled = false; + node._cascadeColorEnabled = false; + }; + proto.updateAtlasValues = function(){ var node = this._node; var locString = node._string || ""; diff --git a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js index d41b6724d5..f4feba9596 100644 --- a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js @@ -31,6 +31,12 @@ var proto = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype); proto.constructor = cc.LabelAtlas.WebGLRenderCmd; + proto.setCascade = function(){ + var node = this._node; + node._cascadeOpacityEnabled = true; + node._cascadeColorEnabled = true; + }; + proto.rendering = function(){ cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, ctx); if (cc.LABELATLAS_DEBUG_DRAW) { From f19ffecb2a4af5ea859ede454f3e967e434adfc1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 09:58:51 +0800 Subject: [PATCH 0965/1564] Issue #2416: Repair of getter setter, remove the test code --- cocos2d/labels/CCLabelAtlas.js | 19 +++++++++++-------- cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 02dd82537b..d1e07ab6ad 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -213,14 +213,17 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ } }); -// Override properties -cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); -cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); - -// Extended properties -/** @expose */ -_p.string; -cc.defineGetterSetter(_p, "string", _p.getString, _p.setString); +(function(){ + var proto = cc.LabelAtlas.prototype; + // Override properties + cc.defineGetterSetter(proto, "opacity", proto.getOpacity, proto.setOpacity); + cc.defineGetterSetter(proto, "color", proto.getColor, proto.setColor); + + // Extended properties + /** @expose */ + proto.string; + cc.defineGetterSetter(proto, "string", proto.getString, proto.setString); +})(); /** *

    diff --git a/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js index 035554b205..fed5c47dbd 100644 --- a/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js @@ -33,7 +33,7 @@ proto.setCascade = function(){ var node = this._node; - node._cascadeOpacityEnabled = false; + node._cascadeOpacityEnabled = true; node._cascadeColorEnabled = false; }; From 91a8c1e0712260545172d783435929bbca4a2d51 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 26 Nov 2014 10:56:47 +0800 Subject: [PATCH 0966/1564] Issue #2416: correct some mistakes of cc.RenderTexture and cc.Layer --- cocos2d/core/CCDirectorWebGL.js | 2 +- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 6 +- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 1 - cocos2d/core/labelttf/CCLabelTTF.js | 2 +- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 78 +++++++------ cocos2d/core/renderer/RendererCanvas.js | 3 +- cocos2d/core/renderer/RendererWebGL.js | 3 +- cocos2d/progress-timer/CCProgressTimer.js | 2 +- cocos2d/render-texture/CCRenderTexture.js | 110 +++++++----------- .../CCRenderTextureCanvasRenderCmd.js | 26 ++--- .../CCRenderTextureWebGLRenderCmd.js | 86 ++++---------- cocos2d/tilemap/CCTMXLayer.js | 1 - .../ccui/base-classes/CCProtectedNode.js | 2 - 13 files changed, 120 insertions(+), 202 deletions(-) diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index e1e4b02041..b9996d58f6 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -324,4 +324,4 @@ cc._tmp.DirectorWebGL = function () { // set other opengl default values cc._renderContext.clearColor(0.0, 0.0, 0.0, 1.0); }; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 4186419b4d..8dc05d2b4d 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -90,8 +90,7 @@ cc.Node.RenderCmd.prototype = { return this._inverse; }, - detachFromParent: function(){ - }, + detachFromParent: function(){}, _updateAnchorPointInPoint: function() { var locAPP = this._anchorPointInPoints, locSize = this._node._contentSize, locAnchorPoint = this._node._anchorPoint; @@ -179,7 +178,6 @@ cc.Node.RenderCmd.prototype = { worldT.tx = t.tx; worldT.ty = t.ty; } - this._renderCmdDiry = false; if (recursive) { var locChildren = this._node._children; if (!locChildren || locChildren.length === 0) @@ -458,7 +456,7 @@ cc.Node.RenderCmd.prototype = { return; this._cachedParent = cachedParent; - var children = this._children; + var children = this._node._children; for (var i = 0, len = children.length; i < len; i++) children[i]._renderCmd._setCachedParent(cachedParent); }; diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index d3a56f175f..0a546ee7dc 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -234,7 +234,6 @@ node._camera._locateForRenderer(stackMatrix); } } - this._renderCmdDiry = false; if(!recursive || !node._children || node._children.length === 0) return; var i, len, locChildren = node._children; diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index c0e14c3a6a..5757c8cb9f 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -135,7 +135,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, _setUpdateTextureDirty: function () { - this._renderCmdDiry = this._needUpdateTexture = true; + this._needUpdateTexture = true; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.textDirty); cc.renderer.pushDirtyNode(this._renderCmd); }, diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 62e9202f66..8aaaf325bc 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -52,7 +52,7 @@ this._cachedParent = this; var children = this._node._children; for(var i = 0, len = children.length; i < len; i++) - children[i]._setCachedParent(this); + children[i]._renderCmd._setCachedParent(this); if (!this._bakeSprite){ this._bakeSprite = new cc.BakeSprite(); @@ -64,13 +64,14 @@ proto.unbake = function(){ if (this._isBaked) { cc.renderer.childrenOrderDirty = true; + this._needDraw = false; this._isBaked = false; this._cacheDirty = true; this._cachedParent = null; var children = this._node._children; for(var i = 0, len = children.length; i < len; i++) - children[i]._setCachedParent(null); + children[i]._renderCmd._setCachedParent(null); } }; @@ -80,11 +81,11 @@ proto.rendering = function(){ if(this._cacheDirty){ - var _t = this, node = this._node; + var node = this._node; var children = node._children, locBakeSprite = this._bakeSprite; //compute the bounding box of the bake layer. - this._transformForRenderer(); - var boundingBox = this._renderCmd._getBoundingBoxForBake(); + this.transform(this.getParentRenderCmd(), true); + var boundingBox = this._getBoundingBoxForBake(); boundingBox.width = 0|(boundingBox.width+0.5); boundingBox.height = 0|(boundingBox.height+0.5); var bakeContext = locBakeSprite.getCacheContext(); @@ -99,7 +100,7 @@ locBakeSprite.setPosition(anchor.x + boundingBox.x, anchor.y + boundingBox.y); //visit for canvas - _t.sortAllChildren(); + node.sortAllChildren(); cc.renderer._turnToCacheMode(this.__instanceId); for (var i = 0, len = children.length; i < len; i++) { children[i].visit(bakeContext); @@ -116,21 +117,19 @@ return; } - var context = ctx || cc._renderContext; var _t = this, node = this._node; var children = node._children; var len = children.length; // quick return if not visible - if (!_t._visible || len === 0) + if (!node._visible || len === 0) return; _t._syncStatus(parentCmd); - if(_t._needDraw) - cc.renderer.pushRenderCommand(this); + cc.renderer.pushRenderCommand(this); //the bakeSprite is drawing - this._bakeSprite.visit(context); + this._bakeSprite.visit(this); }; proto._bakeForAddChild = function(child){ @@ -171,10 +170,16 @@ cc.Layer.CanvasRenderCmd.call(this, renderable); this._needDraw = true; this._blendFuncStr = "source-over"; + this._bakeRenderCmd = new cc.CustomRenderCmd(this, this._bakeRendering); }; var proto = cc.LayerColor.CanvasRenderCmd.prototype = Object.create(cc.Layer.CanvasRenderCmd.prototype); proto.constructor = cc.LayerColor.CanvasRenderCmd; + proto.unbake = function(){ + cc.Layer.CanvasRenderCmd.prototype.unbake.call(this); + this._needDraw = true; + }; + proto.rendering = function (ctx, scaleX, scaleY) { var context = ctx || cc._renderContext, node = this._node, @@ -218,18 +223,20 @@ proto._bakeRendering = function(){ if(this._cacheDirty){ - var _t = this; - var locBakeSprite = _t._bakeSprite, children = this._children; + var node = this._node; + var locBakeSprite = this._bakeSprite, children = node._children; var len = children.length, i; //compute the bounding box of the bake layer. - var boundingBox = this._renderCmd._getBoundingBoxForBake(); + this.transform(this.getParentRenderCmd(), true); + //compute the bounding box of the bake layer. + var boundingBox = this._getBoundingBoxForBake(); boundingBox.width = 0 | boundingBox.width; boundingBox.height = 0 | boundingBox.height; var bakeContext = locBakeSprite.getCacheContext(); locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); - var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = this._position; - if(this._ignoreAnchorPointForPosition){ + var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = node._position; + if(node._ignoreAnchorPointForPosition){ bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); //reset the bake sprite's position locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); @@ -247,61 +254,58 @@ cc.renderer._turnToCacheMode(this.__instanceId); //visit for canvas if (len > 0) { - _t.sortAllChildren(); + node.sortAllChildren(); // draw children zOrder < 0 for (i = 0; i < len; i++) { child = children[i]; if (child._localZOrder < 0) - child.visit(bakeContext); + child._renderCmd.visit(bakeContext); else break; } - if(_t._renderCmd) - cc.renderer.pushRenderCommand(_t._renderCmd); + cc.renderer.pushRenderCommand(this); for (; i < len; i++) { - children[i].visit(bakeContext); + children[i]._renderCmd.visit(bakeContext); } } else - if(_t._renderCmd) - cc.renderer.pushRenderCommand(_t._renderCmd); + cc.renderer.pushRenderCommand(this); cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); - locBakeSprite.transform(); + locBakeSprite.transform(this); this._cacheDirty = false; } }; - proto.visit = function(ctx){ - var context = ctx || cc._renderContext; + proto.visit = function(parentCmd){ if(!this._isBaked){ cc.Node.CanvasRenderCmd.prototype.visit.call(this); return; } - var _t = this; + var node = this._node; // quick return if not visible - if (!_t._visible) + if (!node._visible) return; - _t.transform(context); + this._syncStatus(parentCmd); - if(_t._bakeRenderCmd) - cc.renderer.pushRenderCommand(_t._bakeRenderCmd); + cc.renderer.pushRenderCommand(this._bakeRenderCmd); //the bakeSprite is drawing - this._bakeSprite.visit(context); + this._bakeSprite.visit(this); }; proto._getBoundingBoxForBake = function(){ + var node = this._node; //default size - var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var trans = this.getNodeToWorldTransform(); - rect = cc.rectApplyAffineTransform(rect, this.getNodeToWorldTransform()); + var rect = cc.rect(0, 0, node._contentSize.width, node._contentSize.height); + var trans = node.getNodeToWorldTransform(); + rect = cc.rectApplyAffineTransform(rect, node.getNodeToWorldTransform()); //query child's BoundingBox - if (!this._children || this._children.length === 0) + if (!node._children || node._children.length === 0) return rect; - var locChildren = this._children; + var locChildren = node._children; for (var i = 0; i < locChildren.length; i++) { var child = locChildren[i]; if (child && child._visible) { diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index 58c5d26d78..050122df7c 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -86,7 +86,8 @@ cc.rendererCanvas = { this._isCacheToCanvasOn = true; renderTextureID = renderTextureID || 0; this._cacheToCanvasCmds[renderTextureID] = []; - this._cacheInstanceIds.push(renderTextureID); + if(this._cacheInstanceIds.indexOf(renderTextureID) === -1) + this._cacheInstanceIds.push(renderTextureID); this._currentID = renderTextureID; }, diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 531a54b4a2..3d8c8579e9 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -97,8 +97,7 @@ cc.rendererWebGL = { locPool.sort(this._sortNodeByLevelAsc); //transform node for (var i = 0, len = locPool.length; i < len; i++) { - if (locPool[i]._renderCmdDiry) - locPool[i]._transformForRenderer(); + locPool[i].transform(); } locPool.length = 0; }, diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 663211e246..defb85ef0a 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -271,7 +271,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ this._reverseDirection = false; this.midPoint = cc.p(0.5, 0.5); this.barChangeRate = cc.p(1, 1); - this._sprite = sprite; + this.setSprite(sprite); this._renderCmd.initCmd(); return true; }, diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index ba84c383b0..5154e58239 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -91,9 +91,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ autoDraw:false, _texture:null, - _textureCopy:null, - _uITextureImage:null, - _pixelFormat:cc.Texture2D.PIXEL_FORMAT_RGBA8888, clearStencilVal:0, @@ -101,13 +98,6 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ _className:"RenderTexture", - //for WebGL - _beginWithClearCommand: null, - _clearDepthCommand: null, - _clearCommand: null, - _beginCommand: null, - _endCommand: null, - /** * creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid * Constructor of cc.RenderTexture for Canvas @@ -255,58 +245,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @function * @param {Number} stencilValue */ - clearStencil:null, - - _clearStencilForCanvas:function (stencilValue) { - cc.log("clearDepth isn't supported on Cocos2d-Html5"); - }, - - _clearStencilForWebGL:function (stencilValue) { - var gl = cc._renderContext; - // save old stencil value - var stencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); - - gl.clearStencil(stencilValue); - gl.clear(gl.STENCIL_BUFFER_BIT); - - // restore clear color - gl.clearStencil(stencilClearValue); - }, - - /** - * creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete. - * @return {*} - */ - newCCImage:function(flipImage){ - cc.log("saveToFile isn't supported on cocos2d-html5"); - return null; - }, - - /** - * saves the texture into a file using JPEG format. The file will be saved in the Documents folder. - * Returns YES if the operation is successful. - * (doesn't support in HTML5) - * @param {Number} filePath - * @param {Number} format - */ - saveToFile:function (filePath, format) { - cc.log("saveToFile isn't supported on Cocos2d-Html5"); - }, - - /** - * Listen "come to background" message, and save render texture. It only has effect on Android. - * @param {cc.Class} obj - */ - listenToBackground:function (obj) { - cc.log("listenToBackground isn't supported on Cocos2d-Html5"); - }, - - /** - * Listen "come to foreground" message and restore the frame buffer object. It only has effect on Android. - * @param {cc.Class} obj - */ - listenToForeground:function (obj) { - cc.log("listenToForeground isn't supported on Cocos2d-Html5"); + clearStencil: function(stencilValue) { + this._renderCmd.clearStencil(stencilValue); }, /** @@ -331,7 +271,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @return {cc.Color} */ getClearColor:function () { - return this._renderCmd._clearColor; + return this._clearColor; }, /** @@ -340,17 +280,12 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ * @param {cc.Color} clearColor The clear color */ setClearColor: function(clearColor){ - var cmd = this._renderCmd; - - var locClearColor = cmd._clearColor; + var locClearColor = this._clearColor; locClearColor.r = clearColor.r; locClearColor.g = clearColor.g; locClearColor.b = clearColor.b; locClearColor.a = clearColor.a; - - //Only canvas!! - cmd._clearColorStr = "rgba(" + (0 | clearColor.r) + "," + (0 | clearColor.g) + "," + (0 | clearColor.b) + "," + clearColor.a / 255 + ")"; - + this._renderCmd.updateClearColor(clearColor); }, /** @@ -401,7 +336,40 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ */ setAutoDraw:function (autoDraw) { this.autoDraw = autoDraw; - } + }, + + //---- some stub functions for jsb + /** + * saves the texture into a file using JPEG format. The file will be saved in the Documents folder. + * Returns YES if the operation is successful. + * (doesn't support in HTML5) + * @param {Number} filePath + * @param {Number} format + */ + saveToFile:function (filePath, format) { + cc.log("saveToFile isn't supported on Cocos2d-Html5"); + }, + + /** + * creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete. + * @return {*} + */ + newCCImage:function(flipImage){ + cc.log("saveToFile isn't supported on cocos2d-html5"); + return null; + }, + + /** + * Listen "come to background" message, and save render texture. It only has effect on Android. + * @param {cc.Class} obj + */ + listenToBackground:function (obj) { }, + + /** + * Listen "come to foreground" message and restore the frame buffer object. It only has effect on Android. + * @param {cc.Class} obj + */ + listenToForeground:function (obj) { } }); // Extended diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js index a1cf4eb277..761b3639b7 100644 --- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -23,18 +23,11 @@ ****************************************************************************/ (function(){ - cc.RenderTexture.CanvasRenderCmd = function(renderableObject){ cc.Node.CanvasRenderCmd.call(this, renderableObject); this._needDraw = true; - - this._clearColor = cc.color(255, 255, 255, 255); this._clearColorStr = "rgba(255,255,255,1)"; - // - // the off-screen canvas for rendering and storing the texture - // @type HTMLCanvasElement - // this._cacheCanvas = cc.newElement('canvas'); this._cacheContext = this._cacheCanvas.getContext('2d'); }; @@ -47,15 +40,23 @@ this._cacheCanvas = null; }; + proto.clearStencil = function (stencilValue) { }; + + proto.updateClearColor = function(clearColor){ + this._clearColorStr = "rgba(" + (0 | clearColor.r) + "," + (0 | clearColor.g) + "," + (0 | clearColor.b) + "," + clearColor.a / 255 + ")"; + }; + proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ var node = this._node; var locCacheCanvas = this._cacheCanvas, locScaleFactor = cc.contentScaleFactor(); locCacheCanvas.width = 0 | (width * locScaleFactor); locCacheCanvas.height = 0 | (height * locScaleFactor); this._cacheContext.translate(0, locCacheCanvas.height); + var texture = new cc.Texture2D(); texture.initWithElement(locCacheCanvas); texture.handleLoadedTexture(); + var locSprite = node.sprite = new cc.Sprite(texture); locSprite.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); // Disabled by default. @@ -68,9 +69,6 @@ proto.begin = function(){}; proto._beginWithClear = function(r, g, b, a, depthValue, stencilValue, flags){ - var node = this._node; - node.begin(); - r = r || 0; g = g || 0; b = b || 0; @@ -96,7 +94,6 @@ var scale = cc.contentScaleFactor(); cc.renderer._renderingToCacheCanvas(this._cacheContext, node.__instanceId, scale, scale); - //TODO //restore viewport }; @@ -108,11 +105,10 @@ cc.log("clearDepth isn't supported on Cocos2d-Html5"); }; - proto.visit = function(ctx){ + proto.visit = function(parentCmd){ var node = this._node; - ctx = ctx || cc._renderContext; - node.transform(ctx); - node.sprite.visit(ctx); + this._syncStatus(parentCmd); + node.sprite.visit(parentCmd); }; proto.draw = function(){ diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index 6c1f2f8708..4e952ac969 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -23,7 +23,6 @@ ****************************************************************************/ (function(){ - cc.RenderTexture.WebGLRenderCmd = function(renderableObject){ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; @@ -31,6 +30,7 @@ this._clearColor = cc.color(0, 0, 0, 0); this._fBO = null; this._oldFBO = null; + this._textureCopy = null; this._depthRenderBuffer = null; }; @@ -85,26 +85,37 @@ for (var i = 0; i < locChildren.length; i++) { var getChild = locChildren[i]; if (getChild != node.sprite) - getChild.visit(); + getChild._renderCmd.visit(this); } node.end(); } }; + proto.clearStencil = function(stencilValue) { + var gl = cc._renderContext; + // save old stencil value + var stencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); + + gl.clearStencil(stencilValue); + gl.clear(gl.STENCIL_BUFFER_BIT); + + // restore clear color + gl.clearStencil(stencilClearValue); + }; + proto.cleanup = function(){ var node = this._node; //node.sprite = null; - node._textureCopy = null; + this._textureCopy = null; var gl = cc._renderContext; gl.deleteFramebuffer(this._fBO); if (this._depthRenderBuffer) gl.deleteRenderbuffer(this._depthRenderBuffer); - node._uITextureImage = null; - //if (node._texture) - // node._texture.releaseTexture(); }; + proto.updateClearColor = function(clearColor){}; + proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ var node = this._node; if(format == cc.Texture2D.PIXEL_FORMAT_A8) @@ -148,8 +159,8 @@ var oldRBO = gl.getParameter(gl.RENDERBUFFER_BINDING); if (cc.configuration.checkForGLExtension("GL_QCOM")) { - node._textureCopy = new cc.Texture2D(); - if (!node._textureCopy) + this._textureCopy = new cc.Texture2D(); + if (!this._textureCopy) return false; this._textureCopy.initWithData(data, node._pixelFormat, powW, powH, cc.size(width, height)); } @@ -180,8 +191,7 @@ locTexture.setAliasTexParameters(); - node.sprite = new cc.Sprite(locTexture); - var locSprite = node.sprite; + var locSprite = node.sprite = new cc.Sprite(locTexture); locSprite.scaleY = -1; locSprite.setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); @@ -234,7 +244,7 @@ */ if (cc.configuration.checkForGLExtension("GL_QCOM")) { // -- bind a temporary texture so we can clear the render buffer without losing our texture - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, node._textureCopy._webTextureObj, 0); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._textureCopy._webTextureObj, 0); //cc.checkGLErrorDebug(); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, node._texture._webTextureObj, 0); @@ -242,14 +252,11 @@ }; proto._beginWithClear = function(r, g, b, a, depthValue, stencilValue, flags){ - var node = this._node; r = r / 255; g = g / 255; b = b / 255; a = a / 255; - node.begin(); - var gl = cc._renderContext; // save clear color @@ -357,55 +364,4 @@ cc.kmGLPopMatrix(); }; - - proto.draw = function(ctx){ - var node = this._node; - var gl = cc._renderContext; - var locClearFlags = node.clearFlags; - if (locClearFlags) { - var oldClearColor = [0.0, 0.0, 0.0, 0.0]; - var oldDepthClearValue = 0.0; - var oldStencilClearValue = 0; - - // backup and set - if (locClearFlags & gl.COLOR_BUFFER_BIT) { - oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); - gl.clearColor(this._clearColor.r/255, this._clearColor.g/255, this._clearColor.b/255, this._clearColor.a/255); - } - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) { - oldDepthClearValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - gl.clearDepth(node.clearDepthVal); - } - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) { - oldStencilClearValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE); - gl.clearStencil(node.clearStencilVal); - } - - // clear - gl.clear(locClearFlags); - - // restore - if (locClearFlags & gl.COLOR_BUFFER_BIT) - gl.clearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); - - if (locClearFlags & gl.DEPTH_BUFFER_BIT) - gl.clearDepth(oldDepthClearValue); - - if (locClearFlags & gl.STENCIL_BUFFER_BIT) - gl.clearStencil(oldStencilClearValue); - } - - //! make sure all children are drawn - this.sortAllChildren(); - var locChildren = node._children; - for (var i = 0; i < locChildren.length; i++) { - var getChild = locChildren[i]; - if (getChild != node.sprite) - getChild.visit(); - } - - this.end(); - }; })(); \ No newline at end of file diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index e556edbca8..e88aaf03ec 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -142,7 +142,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this._cacheDirty = true; if(cc.renderer._transformNodePool.indexOf(this) === -1) cc.renderer.pushDirtyNode(this); - this._renderCmdDiry = true; }, /** diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 48c1a64d1d..fdebe42614 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -507,7 +507,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //TODO refactoring worldT.tx = t.tx; worldT.ty = t.ty; } - this._renderCmdDiry = false; var i, len, locChildren = this._children; for(i = 0, len = locChildren.length; i< len; i++){ locChildren[i]._transformForRenderer(); @@ -538,7 +537,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //TODO refactoring //optimize performance for Javascript cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); - this._renderCmdDiry = false; var i, len, locChildren = this._children; for(i = 0, len = locChildren.length; i< len; i++){ locChildren[i]._transformForRenderer(); From 6dea9acd487534927647d044f177f796e82bda5f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 12:43:39 +0800 Subject: [PATCH 0967/1564] Issue #2416: Fixed LabelBMFont --- cocos2d/labels/CCLabelAtlas.js | 4 +- cocos2d/labels/CCLabelBMFont.js | 67 +++++++++++-------- .../labels/CCLabelBMFontCanvasRenderCmd.js | 41 +++++------- cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js | 28 +++----- 4 files changed, 67 insertions(+), 73 deletions(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index d1e07ab6ad..746210379a 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -163,7 +163,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ */ setColor: function (color3) { cc.AtlasNode.prototype.setColor.call(this, color3); - this.updateAtlasValues(); + this._renderCmd.updateAtlasValues(); }, /** @@ -199,7 +199,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ this.setContentSize(len * this._itemWidth, this._itemHeight); this._renderCmd.setString(label); - this.updateAtlasValues(); + this._renderCmd.updateAtlasValues(); this.quadsToDraw = len; }, diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 7495a300a9..d02d55ab55 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -294,12 +294,12 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ */ updateDisplayedOpacity: function (parentOpacity) { var cmd = this._renderCmd; - this._displayedOpacity = this._realOpacity * parentOpacity / 255.0; - var locChildren = this._children; - for (var i = 0; i < locChildren.length; i++) { - cmd._updateChildrenDisplayedOpacity(locChildren[i]); - } - this._changeTextureColor(); + cmd._displayedOpacity = this._realOpacity * parentOpacity / 255.0; +// var locChildren = this._children; +// for (var i = 0; i < locChildren.length; i++) { +// cmd._updateChildrenDisplayedOpacity(locChildren[i]); +// } +// this._changeTextureColor(); }, /** @@ -345,17 +345,17 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ */ updateDisplayedColor: function (parentColor) { var cmd = this._renderCmd; - var locDispColor = this._displayedColor; + var locDispColor = cmd._displayedColor; var locRealColor = this._realColor; locDispColor.r = locRealColor.r * parentColor.r / 255.0; locDispColor.g = locRealColor.g * parentColor.g / 255.0; locDispColor.b = locRealColor.b * parentColor.b / 255.0; - var locChildren = this._children; - for (var i = 0; i < locChildren.length; i++) { - cmd._updateChildrenDisplayedColor(locChildren[i]); - } - this._changeTextureColor(); +// var locChildren = this._children; +// for (var i = 0; i < locChildren.length; i++) { +// cmd._updateChildrenDisplayedColor(locChildren[i]); +// } +// this._changeTextureColor(); }, _changeTextureColor: function () { @@ -440,8 +440,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ cmd._displayedOpacity = self._realOpacity = 255; cmd._displayedColor = cc.color(255, 255, 255, 255); self._realColor = cc.color(255, 255, 255, 255); - self._cascadeOpacityEnabled = true; - self._cascadeColorEnabled = true; + this._cascadeColorEnabled = true; + this._cascadeOpacityEnabled = true; self._contentSize.width = 0; self._contentSize.height = 0; @@ -513,7 +513,18 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var fontChar = self.getChildByTag(i); - fontChar = this._renderCmd._updateTexture(fontChar, locTexture, rect, i, key); + if(!fontChar){ + fontChar = new cc.Sprite(); + fontChar.initWithTexture(locTexture, rect, false); + fontChar._newTextureWhenChangeColor = true; + this.addChild(fontChar, 0, i); + }else{ + this._renderCmd._updateCharTexture(fontChar, rect, key); + } + + // Apply label properties + fontChar.opacityModifyRGB = this._opacityModifyRGB; + this._renderCmd._updateCharColorAndOpacity(fontChar); var yOffset = locCfg.commonHeight - fontDef.yOffset; var fontPos = cc.p(nextFontPositionX + fontDef.xOffset + fontDef.rect.width * 0.5 + kerningAmount, @@ -1000,18 +1011,20 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } }); -var _p = cc.LabelBMFont.prototype; -cc.EventHelper.prototype.apply(_p); - -/** @expose */ -_p.string; -cc.defineGetterSetter(_p, "string", _p.getString, _p._setStringForSetter); -/** @expose */ -_p.boundingWidth; -cc.defineGetterSetter(_p, "boundingWidth", _p._getBoundingWidth, _p.setBoundingWidth); -/** @expose */ -_p.textAlign; -cc.defineGetterSetter(_p, "textAlign", _p._getAlignment, _p.setAlignment); +(function(){ + var p = cc.LabelBMFont.prototype; + cc.EventHelper.prototype.apply(p); + + /** @expose */ + p.string; + cc.defineGetterSetter(p, "string", p.getString, p._setStringForSetter); + /** @expose */ + p.boundingWidth; + cc.defineGetterSetter(p, "boundingWidth", p._getBoundingWidth, p.setBoundingWidth); + /** @expose */ + p.textAlign; + cc.defineGetterSetter(p, "textAlign", p._getAlignment, p.setAlignment); +})(); /** * creates a bitmap font atlas with an initial string and the FNT file diff --git a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js index a69f485627..d091f21175 100644 --- a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js @@ -33,39 +33,33 @@ (function(){ cc.LabelBMFont.CanvasRenderCmd = function(renderableObject){ cc.SpriteBatchNode.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = false; + this._needDraw = true; }; var proto = cc.LabelBMFont.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype); proto.constructor = cc.LabelBMFont.CanvasRenderCmd; - proto._updateTexture = function(fontChar, locTexture, rect, i, key){ - var node = this._node; - //var hasSprite = true; - if (!fontChar) { - fontChar = new cc.Sprite(); + proto.rendering = function(){ + void 0; + }; - fontChar.initWithTexture(locTexture, rect, false); - fontChar._newTextureWhenChangeColor = true; - node.addChild(fontChar, 0, i); + proto._updateCharTexture = function(fontChar, rect, key){ + if (key === 32) { + fontChar.setTextureRect(rect, false, cc.size(0, 0)); } else { - if (key === 32) { - fontChar.setTextureRect(rect, false, cc.size(0, 0)); - } else { - // updating previous sprite - fontChar.setTextureRect(rect, false); - // restore to default in case they were modified - fontChar.visible = true; - } + // updating previous sprite + fontChar.setTextureRect(rect, false); + // restore to default in case they were modified + fontChar.visible = true; } + }; - // Apply label properties - fontChar.opacityModifyRGB = node._opacityModifyRGB; + proto._updateCharColorAndOpacity = function(fontChar){ // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on - cc.Node.prototype.updateDisplayedColor.call(fontChar, this._displayedColor); - cc.Node.prototype.updateDisplayedOpacity.call(fontChar, this._displayedOpacity); - - return fontChar; +// cc.Node.prototype.updateDisplayedColor.call(fontChar, this._displayedColor); +// cc.Node.prototype.updateDisplayedOpacity.call(fontChar, this._displayedOpacity); + fontChar.updateDisplayedColor(this._displayedColor); + fontChar.updateDisplayedOpacity(this._displayedOpacity); }; proto._updateFntFileTexture = function(){ @@ -137,7 +131,6 @@ proto._updateChildrenDisplayedOpacity = function(locChild){ cc.Node.prototype.updateDisplayedOpacity.call(locChild, this._displayedOpacity); - }; proto._updateChildrenDisplayedColor = function(locChild){ diff --git a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js index 7889b2074d..e8032f17a2 100644 --- a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js @@ -39,29 +39,17 @@ var proto = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); proto.constructor = cc.LabelBMFont.WebGLRenderCmd; - proto._updateTexture = function(fontChar, locTexture, rect, i){ - var node = this._node; - //var hasSprite = true; - if (!fontChar) { - fontChar = new cc.Sprite(); - fontChar.initWithTexture(locTexture, rect, false); - fontChar._newTextureWhenChangeColor = true; - node.addChild(fontChar, 0, i); - } else { - // updating previous sprite - fontChar.setTextureRect(rect, false); - // restore to default in case they were modified - fontChar.visible = true; - } - - - // Apply label properties - fontChar.opacityModifyRGB = node._opacityModifyRGB; + proto._updateCharTexture = function(fontChar, rect, key){ + // updating previous sprite + fontChar.setTextureRect(rect, false); + // restore to default in case they were modified + fontChar.visible = true; + }; + + proto._updateCharColorAndOpacity = function(fontChar){ // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on fontChar.updateDisplayedColor(this._displayedColor); fontChar.updateDisplayedOpacity(this._displayedOpacity); - - return fontChar; }; proto._updateFntFileTexture = function(){}; From 8c361276c6c6cbd542d99891662755e8e5800c42 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 26 Nov 2014 13:35:55 +0800 Subject: [PATCH 0968/1564] Issue #2416: correct some mistakes of cc.ProgressTimer on WebGL --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 2 +- cocos2d/core/renderer/RendererWebGL.js | 2 +- cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js | 12 ++--- .../CCProgressTimerWebGLRenderCmd.js | 47 ++----------------- .../CCRenderTextureWebGLRenderCmd.js | 7 ++- 5 files changed, 15 insertions(+), 55 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 8a17098c81..3c40f4a5c2 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -102,7 +102,7 @@ cc.Node.RenderCmd.prototype = { setDirtyFlag: function(dirtyFlag){ if (this._dirtyFlag === 0 && dirtyFlag !== 0) cc.renderer.pushDirtyNode(this); - this._dirtyFlag = this._dirtyFlag | dirtyFlag; + this._dirtyFlag |= dirtyFlag; }, getParentRenderCmd: function(){ diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js index 3d8c8579e9..e9c9284857 100644 --- a/cocos2d/core/renderer/RendererWebGL.js +++ b/cocos2d/core/renderer/RendererWebGL.js @@ -97,7 +97,7 @@ cc.rendererWebGL = { locPool.sort(this._sortNodeByLevelAsc); //transform node for (var i = 0, len = locPool.length; i < len; i++) { - locPool[i].transform(); + locPool[i].updateStatus(); } locPool.length = 0; }, diff --git a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js index f4feba9596..b5976d366a 100644 --- a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js @@ -25,7 +25,7 @@ (function(){ cc.LabelAtlas.WebGLRenderCmd = function(renderable){ cc.AtlasNode.WebGLRenderCmd.call(this, renderable); - this._needDraw = false; + this._needDraw = true; }; var proto = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype); @@ -40,7 +40,7 @@ proto.rendering = function(){ cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, ctx); if (cc.LABELATLAS_DEBUG_DRAW) { - var s = this.size; + var s = this._node.getContentSize(); var vertices = [cc.p(0, 0), cc.p(s.width, 0), cc.p(s.width, s.height), cc.p(0, s.height)]; cc._drawingUtil.drawPoly(vertices, 4, true); @@ -51,7 +51,7 @@ var node = this._node; var locString = node._string; var n = locString.length; - var locTextureAtlas = node.textureAtlas; + var locTextureAtlas = this._textureAtlas; var texture = locTextureAtlas.texture; var textureWide = texture.pixelsWidth; @@ -123,9 +123,9 @@ }; proto.setString = function(label){ - var len = label.length, node = this._node; - if (len > node.textureAtlas.totalQuads) - node.textureAtlas.resizeCapacity(len); + var len = label.length; + if (len > this._textureAtlas.totalQuads) + this._textureAtlas.resizeCapacity(len); }; proto.setOpacity = function(opacity){ diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index 34254d92c1..de746543d0 100644 --- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -98,52 +98,13 @@ this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; - proto.draw = function(ctx){ - var node = this._node; - var context = ctx || cc._renderContext; - if (!this._vertexData || !node._sprite) - return; - - cc.nodeDrawSetup(node); - - var blendFunc = node._sprite.getBlendFunc(); - cc.glBlendFunc(blendFunc.src, blendFunc.dst); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - cc.glBindTexture2D(node._sprite.texture); - - context.bindBuffer(context.ARRAY_BUFFER, this._vertexWebGLBuffer); - if(this._vertexDataDirty){ - context.bufferData(context.ARRAY_BUFFER, this._vertexArrayBuffer, context.DYNAMIC_DRAW); - this._vertexDataDirty = false; - } - var locVertexDataLen = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT; - context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, locVertexDataLen, 0); - 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 (node._type === cc.ProgressTimer.TYPE_RADIAL) - context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount); - else if (node._type == cc.ProgressTimer.TYPE_BAR) { - if (!node._reverseDirection) - context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount); - else { - context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount / 2); - context.drawArrays(context.TRIANGLE_STRIP, 4, this._vertexDataCount / 2); - // 2 draw calls - cc.g_NumberOfDraws++; - } - } - cc.g_NumberOfDraws++; - }; - proto._updateProgress = function(){ var node = this._node; var locType = node._type; if(locType === cc.ProgressTimer.TYPE_RADIAL) - node._updateRadial(); + this._updateRadial(); else if(locType === cc.ProgressTimer.TYPE_BAR) - node._updateBar(); + this._updateBar(); this._vertexDataDirty = true; }; @@ -393,8 +354,8 @@ } // hitpoint will go last - locVertexData[this._renderCmd._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(hit); - locVertexData[this._renderCmd._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(hit); + locVertexData[this._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(hit); + locVertexData[this._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(hit); }; proto._boundaryTexCoord = function (index) { diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index 4e952ac969..d1ca194d9f 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -148,11 +148,10 @@ this._pixelFormat = format; - this._texture = new cc.Texture2D(); + var locTexture = node._texture = new cc.Texture2D(); if (!node._texture) return false; - var locTexture = node._texture; locTexture.initWithData(data, node._pixelFormat, powW, powH, cc.size(width, height)); //free( data ); @@ -207,7 +206,7 @@ }; proto.begin = function(){ - var node = this; + var node = this._node; // Save the current matrix cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLPushMatrix(); @@ -293,7 +292,7 @@ }; proto.end = function(){ - var node = this.node + var node = this._node; cc.renderer._renderingToBuffer(node.__instanceId); var gl = cc._renderContext; From 80fee0b168626668acbb7f9ca5707a6c2cbdb226 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 13:39:03 +0800 Subject: [PATCH 0969/1564] Issue #2416: Function is undefined of LabelTTF --- cocos2d/core/labelttf/CCLabelTTF.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index c0e14c3a6a..d754460325 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -478,7 +478,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ locTextFillColor.r = fillColor.r; locTextFillColor.g = fillColor.g; locTextFillColor.b = fillColor.b; - this._setColorsString(); + this._renderCmd._setColorsString(); this._needUpdateTexture = true; } }, From d6b91ccaa867f06bac8dd8852e41ae3d1772e6a5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 14:41:39 +0800 Subject: [PATCH 0970/1564] Issue #2416: PhysicsSprite CanvasRender --- cocos2d/physics/CCPhysicsSprite.js | 68 +++---------------- .../physics/CCPhysicsSpriteCanvasRenderCmd.js | 61 +++++++++++++++-- .../physics/CCPhysicsSpriteWebGLRenderCmd.js | 16 +++-- 3 files changed, 77 insertions(+), 68 deletions(-) diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 67c48fdc5a..20f8e74d99 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -262,15 +262,11 @@ } } - if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._transformCmd = new cc.PhysicsSprite.CanvasRenderCmd(this); - else - this._transformCmd = new cc.PhysicsSprite.WebGLRenderCmd(this); - cc.renderer.pushRenderCommand(this._transformCmd); + cc.renderer.pushRenderCommand(this._renderCmd); }, visit: function(){ - cc.renderer.pushRenderCommand(this._transformCmd); + cc.renderer.pushRenderCommand(this._renderCmd); cc.Sprite.prototype.visit.call(this); }, @@ -393,58 +389,7 @@ * @return {cc.AffineTransform} */ getNodeToParentTransform:function () { - var _t = this; - if(_t._usingNormalizedPosition && _t._parent){ //TODO need refactor - var conSize = _t._parent._contentSize; - _t._position.x = _t._normalizedPosition.x * conSize.width; - _t._position.y = _t._normalizedPosition.y * conSize.height; - _t._normalizedPositionDirty = false; - } - - return this._renderCmd._getNodeToParentTransform(); - }, - - _nodeToParentTransformForCanvas: function () { - if (this.dirty) { - var t = this._transform;// quick reference - // base position - var locBody = this._body, locScaleX = this._scaleX, locScaleY = this._scaleY, locAnchorPIP = this._anchorPointInPoints; - t.tx = locBody.p.x; - t.ty = locBody.p.y; - - // rotation Cos and Sin - var radians = -locBody.a; - var Cos = 1, Sin = 0; - if (radians) { - Cos = Math.cos(radians); - Sin = Math.sin(radians); - } - - // base abcd - t.a = t.d = Cos; - t.b = -Sin; - t.c = Sin; - - // scale - if (locScaleX !== 1 || locScaleY !== 1) { - t.a *= locScaleX; - t.c *= locScaleX; - t.b *= locScaleY; - t.d *= locScaleY; - } - - // adjust anchorPoint - t.tx += Cos * -locAnchorPIP.x * locScaleX + -Sin * locAnchorPIP.y * locScaleY; - t.ty -= Sin * -locAnchorPIP.x * locScaleX + Cos * locAnchorPIP.y * locScaleY; - - // if ignore anchorPoint - if (this._ignoreAnchorPointForPosition) { - t.tx += locAnchorPIP.x; - t.ty += locAnchorPIP.y; - } - this._transformDirty = false; - } - return this._transform; + return this._renderCmd.getNodeToParentTransform(); }, /** @@ -462,6 +407,13 @@ */ setIgnoreBodyRotation: function(b) { this._ignoreBodyRotation = b; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.PhysicsSprite.CanvasRenderCmd(this); + else + return new cc.PhysicsSprite.WebGLRenderCmd(this); } }; cc.PhysicsSprite = cc.Sprite.extend(chipmunkAPI); diff --git a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js index c1d06cf684..f8a589c455 100644 --- a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js @@ -27,19 +27,70 @@ */ (function(){ cc.PhysicsSprite.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); + cc.Sprite.CanvasRenderCmd.call(this, renderableObject); this._needDraw = true; }; - var proto = cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + var proto = cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); proto.constructor = cc.PhysicsSprite.CanvasRenderCmd; - proto.rendering = function(){ + proto.rendering = function(ctx, scaleX, scaleY){ + // This is a special class + // Sprite can not obtain sign + // So here must to calculate of each frame if (this._node.transform) this._node.transform(); + cc.Sprite.CanvasRenderCmd.prototype.rendering.call(this, ctx, scaleX, scaleY); }; - proto._getNodeToParentTransform = function(){ - return this._node._nodeToParentTransformForCanvas(); + proto.getNodeToParentTransform = function(){ + var node = this._node; + if(node._usingNormalizedPosition && node._parent){ //TODO need refactor + var conSize = node._parent._contentSize; + node._position.x = node._normalizedPosition.x * conSize.width; + node._position.y = node._normalizedPosition.y * conSize.height; + node._normalizedPositionDirty = false; + } + + + var t = this._transform;// quick reference + // base position + var locBody = node._body, locScaleX = node._scaleX, locScaleY = node._scaleY, locAnchorPIP = this._anchorPointInPoints; + t.tx = locBody.p.x; + t.ty = locBody.p.y; + + // rotation Cos and Sin + var radians = -locBody.a; + var Cos = 1, Sin = 0; + if (radians) { + Cos = Math.cos(radians); + Sin = Math.sin(radians); + } + + // base abcd + t.a = t.d = Cos; + t.b = -Sin; + t.c = Sin; + + // scale + if (locScaleX !== 1 || locScaleY !== 1) { + t.a *= locScaleX; + t.c *= locScaleX; + t.b *= locScaleY; + t.d *= locScaleY; + } + + // adjust anchorPoint + t.tx += Cos * -locAnchorPIP.x * locScaleX + -Sin * locAnchorPIP.y * locScaleY; + t.ty -= Sin * -locAnchorPIP.x * locScaleX + Cos * locAnchorPIP.y * locScaleY; + + // if ignore anchorPoint + if (this._ignoreAnchorPointForPosition) { + t.tx += locAnchorPIP.x; + t.ty += locAnchorPIP.y; + } + + return this._transform; }; + })(); \ No newline at end of file diff --git a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js index 4334e2963d..2d1065c884 100644 --- a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js @@ -27,20 +27,26 @@ */ (function(){ cc.PhysicsSprite.WebGLRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); + cc.Sprite.CanvasRenderCmd.call(this, renderableObject); this._needDraw = true; }; - var proto = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + var proto = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); proto.constructor = cc.PhysicsSprite.WebGLRenderCmd; - proto.rendering = function(){ + proto.rendering = function(ctx, scaleX, scaleY){ + // This is a special class + // Sprite can not obtain sign + // So here must to calculate of each frame + // TODO _transformForRenderer has been deleted. if(this._node._transformForRenderer) this._node._transformForRenderer(); + cc.Sprite.CanvasRenderCmd.prototype.rendering.call(this, ctx, scaleX, scaleY); }; - proto._getNodeToParentTransform = function(){ - var locBody = this._body, locAnchorPIP = this._anchorPointInPoints, locScaleX = this._scaleX, locScaleY = this._scaleY; + proto.getNodeToParentTransform = function(){ + var node = this._node; + var locBody = node._body, locAnchorPIP = this._anchorPointInPoints, locScaleX = node._scaleX, locScaleY = node._scaleY; var x = locBody.p.x; var y = locBody.p.y; From a37a672959fcbc88b121fd10bfbd45f283321ed7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 15:08:53 +0800 Subject: [PATCH 0971/1564] Issue #2416: ClippingNode CanvasRender --- .../CCClippingNodeCanvasRenderCmd.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js index 17240bace6..72d6537147 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -26,7 +26,7 @@ (function(){ cc.ClippingNode.CanvasRenderCmd = function(renderable){ cc.Node.CanvasRenderCmd.call(this, renderable); - this._needDraw = true; + this._needDraw = false; this._godhelpme = false; this._clipElemType = null; @@ -86,7 +86,7 @@ var context = ctx || cc._renderContext; if (this._clipElemType) { - var locCache = cc.ClippingNode._getSharedCache(); + var locCache = cc.ClippingNode.CanvasRenderCmd._getSharedCache(); var canvas = context.canvas; locCache.width = canvas.width; locCache.height = canvas.height; @@ -160,6 +160,7 @@ }; proto.visit = function(parentCmd){ + cc.renderer.pushRenderCommand(this); var node = this._node; // quick return if not visible if (!node._visible) @@ -170,10 +171,10 @@ this._curLevel = parentCmd._curLevel + 1; // Composition mode, costy but support texture stencil - this._clipElemType = (this._cangodhelpme() || this._stencil instanceof cc.Sprite); + this._clipElemType = (this._cangodhelpme() || node._stencil instanceof cc.Sprite); var i, children = node._children; - if (!this._stencil || !this._stencil.visible) { + if (!node._stencil || !node._stencil.visible) { if (this.inverted) cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); // draw everything return; @@ -184,7 +185,7 @@ // Draw everything first using node visit function cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); }else{ - this._stencil.visit(this); + node._stencil.visit(this); } cc.renderer.pushRenderCommand(this._rendererClipCmd); @@ -192,14 +193,14 @@ this._syncStatus(parentCmd); if(this._clipElemType){ - this._stencil.visit(this); + node._stencil.visit(this); }else{ // Clip mode doesn't support recusive stencil, so once we used a clip stencil, // so if it has ClippingNode as a child, the child must uses composition stencil. this._cangodhelpme(true); var len = children.length; if (len > 0) { - this.sortAllChildren(); + node.sortAllChildren(); for (i = 0; i < len; i++) children[i]._renderCmd.visit(this); } From ad40c8c4f71258e30d4bfcdefa1b57d34f4cfa41 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 26 Nov 2014 16:02:38 +0800 Subject: [PATCH 0972/1564] Issue #2416: correct a mistake of cc.Node.WebGLRenderCmd --- cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js | 1 - cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 2 +- cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js index 8ccb0009dc..092f0951fb 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js @@ -38,7 +38,6 @@ var proto = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.AtlasNode.WebGLRenderCmd; - proto._updateBlendFunc = function () { var node = this._node; if (!this._textureAtlas.texture.hasPremultipliedAlpha()) { diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 3c40f4a5c2..c1f217b4f6 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -267,7 +267,7 @@ cc.Node.RenderCmd.prototype = { this._transform = cc.affineTransformConcat(t, node._additionalTransform); node._additionalTransformDirty = false; } - this._dirtyFlag = this._dirtyFlag ^ cc.Node._dirtyFlags.transformDirty; + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; } return this._transform; }; diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 0a546ee7dc..335cc35186 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -154,6 +154,7 @@ if (!node._visible) return; + parentCmd = parentCmd || this.getParentRenderCmd(); if (node._parent && node._parent._renderCmd) this._curLevel = node._parent._renderCmd._curLevel + 1; @@ -161,10 +162,10 @@ //optimize performance for javascript currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(_t._stackMatrix, currentStack.top); + //cc.kmMat4Assign(_t._stackMatrix, currentStack.top); + _t._syncStatus(parentCmd); currentStack.top = _t._stackMatrix; - _t._syncStatus(parentCmd); var locChildren = node._children; if (locChildren && locChildren.length > 0) { var childLen = locChildren.length; From 668e547f4d752ba3988f6ad6d904c9e14a723cfd Mon Sep 17 00:00:00 2001 From: wang hao Date: Wed, 26 Nov 2014 16:31:38 +0800 Subject: [PATCH 0973/1564] fixed bug dispatchevet failure in chrome --- cocos2d/core/platform/CCInputManager.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 3e4ebb8bea..b02184bf4a 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -416,8 +416,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); if (!cc.rectContainsPoint(new cc.Rect(pos.left, pos.top, pos.width, pos.height), location)){ - if(!supportTouches) - selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); + // if(!supportTouches) + selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.UP); mouseEvent.setButton(event.button); @@ -432,8 +432,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); - if(!supportTouches) - selfPointer.handleTouchesBegin([selfPointer.getTouchByXY(location.x, location.y, pos)]); + // if(!supportTouches) + selfPointer.handleTouchesBegin([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.DOWN); mouseEvent.setButton(event.button); @@ -450,8 +450,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); - if(!supportTouches) - selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); + // if(!supportTouches) + selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.UP); mouseEvent.setButton(event.button); @@ -468,8 +468,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); - if(!supportTouches) - selfPointer.handleTouchesMove([selfPointer.getTouchByXY(location.x, location.y, pos)]); + // if(!supportTouches) + selfPointer.handleTouchesMove([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.MOVE); if(selfPointer._mousePressed) From 471a9000435d6b2d1b88a4a864e5cf5120113dc6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 17:23:04 +0800 Subject: [PATCH 0974/1564] Issue #2416: CCProtectedNode RenderCmd --- .../ccui/base-classes/CCProtectedNode.js | 178 +----------------- .../CCProtectedNodeCanvasRenderCmd.js | 114 +++++++++++ .../CCProtectedNodeWebGLRenderCmd.js | 119 ++++++++++++ extensions/ccui/base-classes/UIWidget.js | 2 +- moduleConfig.json | 2 + 5 files changed, 245 insertions(+), 170 deletions(-) create mode 100644 extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js create mode 100644 extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index fdebe42614..5f398cd899 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -233,107 +233,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx context of renderer */ - visit: null, - - _visitForCanvas: function(ctx){ - var _t = this; - // quick return if not visible - if (!_t._visible) - return; - - //visit for canvas - var context = ctx || cc._renderContext, i, j; - var children = _t._children, child; - var locChildren = _t._children, locProtectedChildren = this._protectedChildren; - var childLen = locChildren.length, pLen = locProtectedChildren.length; -// context.save(); - _t.transform(context); - - _t.sortAllChildren(); - _t.sortAllProtectedChildren(); - - // draw children zOrder < 0 - for (i = 0; i < childLen; i++) { - child = children[i]; - if (child._localZOrder < 0) - child.visit(context); - else - break; - } - for (j = 0; j < pLen; j++) { - child = locProtectedChildren[j]; - if (child._localZOrder < 0) - child.visit(context); - else - break; - } - -// _t.draw(context); - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - - for (; i < childLen; i++) - children[i] && children[i].visit(context); - for (; j < pLen; j++) - locProtectedChildren[j] && locProtectedChildren[j].visit(context); - - this._cacheDirty = false; -// context.restore(); - }, - - _visitForWebGL: function(){ - var _t = this; - // quick return if not visible - if (!_t._visible) - return; - var context = cc._renderContext, i, currentStack = cc.current_stack, j; - - //optimize performance for javascript - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(_t._stackMatrix, currentStack.top); - currentStack.top = _t._stackMatrix; - - var locGrid = _t.grid; - if (locGrid && locGrid._active) - locGrid.beforeDraw(); - - _t.transform(); - - var locChildren = _t._children, locProtectedChildren = this._protectedChildren; - var childLen = locChildren.length, pLen = locProtectedChildren.length; - _t.sortAllChildren(); - _t.sortAllProtectedChildren(); - - // draw children zOrder < 0 - for (i = 0; i < childLen; i++) { - if (locChildren[i] && locChildren[i]._localZOrder < 0) - locChildren[i].visit(); - else - break; - } - for(j = 0; j < pLen; j++){ - if (locProtectedChildren[j] && locProtectedChildren[j]._localZOrder < 0) - locProtectedChildren[j].visit(); - else - break; - } -// _t.draw(context); - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - - // draw children zOrder >= 0 - for (; i < childLen; i++) { - locChildren[i] && locChildren[i].visit(); - } - for (; j < pLen; j++) { - locProtectedChildren[j] && locProtectedChildren[j].visit(); - } - - if (locGrid && locGrid._active) - locGrid.afterDraw(_t); - - //optimize performance for javascript - currentStack.top = currentStack.stack.pop(); + visit: function(){ + this._renderCmd.visit(); }, /** @@ -476,77 +377,16 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren = this._protectedChildren; for(i =0, len = locChildren.length; i < len; i++) locChildren[i].setColor(white); + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.ProtectedNode.CanvasRenderCmd(this); + else + return new cc.ProtectedNode.WebGLRenderCmd(this); } }); -if (cc._renderType === cc._RENDER_TYPE_CANVAS) { //TODO refactoring - cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForCanvas; - cc.ProtectedNode.prototype._transformForRenderer = function () { - var t = this.getNodeToParentTransform(), worldT = this._transformWorld; - if(this._parent){ - var pt = this._parent._transformWorld; - worldT.a = t.a * pt.a + t.b * pt.c; //a - worldT.b = t.a * pt.b + t.b * pt.d; //b - worldT.c = t.c * pt.a + t.d * pt.c; //c - worldT.d = t.c * pt.b + t.d * pt.d; //d - if(this._skewX || this._skewY){ - var plt = this._parent._transform; - var xOffset = -(plt.b + plt.c) * t.ty ; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty - }else{ - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty - } - } else { - worldT.a = t.a; - worldT.b = t.b; - worldT.c = t.c; - worldT.d = t.d; - worldT.tx = t.tx; - worldT.ty = t.ty; - } - var i, len, locChildren = this._children; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._transformForRenderer(); - } - locChildren = this._protectedChildren; - for( i = 0, len = locChildren.length; i< len; i++) - locChildren[i]._transformForRenderer(); - }; -}else{ - cc.ProtectedNode.prototype.visit = cc.ProtectedNode.prototype._visitForWebGL; - cc.ProtectedNode.prototype._transformForRenderer = function () { - var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, - parentMatrix = this._parent ? this._parent._stackMatrix : cc.current_stack.top; - - // Convert 3x3 into 4x4 matrix - var trans = this.getNodeToParentTransform(); - var t4x4Mat = t4x4.mat; - t4x4Mat[0] = trans.a; - t4x4Mat[4] = trans.c; - t4x4Mat[12] = trans.tx; - t4x4Mat[1] = trans.b; - t4x4Mat[5] = trans.d; - t4x4Mat[13] = trans.ty; - - // Update Z vertex manually - t4x4Mat[14] = this._vertexZ; - - //optimize performance for Javascript - cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); - - var i, len, locChildren = this._children; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._transformForRenderer(); - } - locChildren = this._protectedChildren; - for( i = 0, len = locChildren.length; i< len; i++) - locChildren[i]._transformForRenderer(); - }; -} - /** * create a cc.ProtectedNode object; * @deprecated since v3.0, please use new cc.ProtectedNode() instead. diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js new file mode 100644 index 0000000000..28f6ece5a3 --- /dev/null +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -0,0 +1,114 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + cc.ProtectedNode.CanvasRenderCmd = function (renderable) { + cc.Node.CanvasRenderCmd.call(this, renderable); + this._cachedParent = null; + this._cacheDirty = false; + }; + + var proto = cc.ProtectedNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ProtectedNode.CanvasRenderCmd; + + proto.visit = function(){ + var node = this._node; + // quick return if not visible + if (!node._visible) + return; + + //visit for canvas + var context = ctx || cc._renderContext, i, j; + var children = node._children, child; + var locChildren = node._children, locProtectedChildren = node._protectedChildren; + var childLen = locChildren.length, pLen = locProtectedChildren.length; + + node.transform(node._parent && node._parent._renderCmd); + + node.sortAllChildren(); + node.sortAllProtectedChildren(); + + // draw children zOrder < 0 + for (i = 0; i < childLen; i++) { + child = children[i]; + if (child._localZOrder < 0) + child._renderCmd.visit(this); + else + break; + } + for (j = 0; j < pLen; j++) { + child = locProtectedChildren[j]; + if (child._localZOrder < 0) + child._renderCmd.visit(this); + else + break; + } + + cc.renderer.pushRenderCommand(this); + + for (; i < childLen; i++) + children[i] && children[i].visit(this); + for (; j < pLen; j++) + locProtectedChildren[j] && locProtectedChildren[j].visit(this); + + this._cacheDirty = false; + }; + + proto.transform = function(parentCmd, recursive){ + var node = this._node; + var t = node.getNodeToParentTransform(), worldT = this._worldTransform; + if(parentCmd){ + var pt = parentCmd._worldTransform; + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d + if(node._skewX || node._skewY){ + var plt = parentCmd._transform; + var xOffset = -(plt.b + plt.c) * t.ty ; + var yOffset = -(plt.b + plt.c) * t.tx; + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + }else{ + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty + } + } else { + worldT.a = t.a; + worldT.b = t.b; + worldT.c = t.c; + worldT.d = t.d; + worldT.tx = t.tx; + worldT.ty = t.ty; + } + var i, len, locChildren = node._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(this); + } + locChildren = node._protectedChildren; + for( i = 0, len = locChildren.length; i< len; i++) + locChildren[i]._renderCmd.transform(this); + } + +})(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js new file mode 100644 index 0000000000..92f3f1bd67 --- /dev/null +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -0,0 +1,119 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + + cc.ProtectedNode.WebGLRenderCmd = function (renderable) { + cc.Node.WebGLRenderCmd.call(this, renderable); + this._cachedParent = null; + this._cacheDirty = false; + }; + + var proto = cc.ProtectedNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.ProtectedNode.WebGLRenderCmd; + + proto.visit = function(){ + var node = this._node; + // quick return if not visible + if (!node._visible) + return; + var context = cc._renderContext, i, currentStack = cc.current_stack, j; + + //optimize performance for javascript + currentStack.stack.push(currentStack.top); + cc.kmMat4Assign(this._stackMatrix, currentStack.top); + currentStack.top = this._stackMatrix; + + var locGrid = node.grid; + if (locGrid && locGrid._active) + locGrid.beforeDraw(); + + node.transform(node._parent && node._parent._renderCmd); + + var locChildren = node._children, locProtectedChildren = node._protectedChildren; + var childLen = locChildren.length, pLen = locProtectedChildren.length; + node.sortAllChildren(); + node.sortAllProtectedChildren(); + + // draw children zOrder < 0 + for (i = 0; i < childLen; i++) { + if (locChildren[i] && locChildren[i]._localZOrder < 0) + locChildren[i].visit(); + else + break; + } + for(j = 0; j < pLen; j++){ + if (locProtectedChildren[j] && locProtectedChildren[j]._localZOrder < 0) + locProtectedChildren[j].visit(); + else + break; + } + + cc.renderer.pushRenderCommand(this); + + // draw children zOrder >= 0 + for (; i < childLen; i++) { + locChildren[i] && locChildren[i].visit(); + } + for (; j < pLen; j++) { + locProtectedChildren[j] && locProtectedChildren[j].visit(); + } + + if (locGrid && locGrid._active) + locGrid.afterDraw(node); + + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); + }; + + proto.transform = function(parentCmd){ + var node = this._node; + var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, + parentMatrix = parentCmd ? parentCmd._stackMatrix : cc.current_stack.top; + + // Convert 3x3 into 4x4 matrix + var trans = node.getNodeToParentTransform(); + var t4x4Mat = t4x4.mat; + t4x4Mat[0] = trans.a; + t4x4Mat[4] = trans.c; + t4x4Mat[12] = trans.tx; + t4x4Mat[1] = trans.b; + t4x4Mat[5] = trans.d; + t4x4Mat[13] = trans.ty; + + // Update Z vertex manually + t4x4Mat[14] = this._vertexZ; + + //optimize performance for Javascript + cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); + + var i, len, locChildren = node._children; + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(); + } + locChildren = node._protectedChildren; + for( i = 0, len = locChildren.length; i< len; i++) + locChildren[i]._renderCmd.transform(); + }; +})(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 4edac18fbe..87cef6420d 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1137,7 +1137,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setPositionType: function (type) { this._positionType = type; - this.setNodeDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** diff --git a/moduleConfig.json b/moduleConfig.json index 6314d739f9..55f098e1db 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -294,6 +294,8 @@ "ccui" : [ "core", "actions", "labels", "text-input","clipping-nodes", "extensions/ccui/base-classes/CCProtectedNode.js", + "extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js", + "extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js", "extensions/ccui/system/CocosGUI.js", "extensions/ccui/base-classes/UIWidget.js", "extensions/ccui/base-classes/UIScale9Sprite.js", From cc09501cf233800e74b565f04abebd376c88cb45 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 26 Nov 2014 20:41:21 +0800 Subject: [PATCH 0975/1564] Issue #2416: CCUI support --- cocos2d/text-input/CCTextFieldTTF.js | 2 +- extensions/ccui/base-classes/CCProtectedNode.js | 2 +- .../ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js | 8 ++++++-- extensions/ccui/layouts/UILayout.js | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index e9649f5ad7..a27bea0d3e 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -245,7 +245,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this.setColor(this._colorText); } if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._updateTexture(); + this._renderCmd._updateTexture(); this._charCount = this._inputText.length; }, diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 5f398cd899..2bc449d450 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -234,7 +234,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx context of renderer */ visit: function(){ - this._renderCmd.visit(); + this._renderCmd._visit(); }, /** diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 28f6ece5a3..ec7015f76a 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -33,6 +33,10 @@ proto.constructor = cc.ProtectedNode.CanvasRenderCmd; proto.visit = function(){ + this._node.visit(); + }; + + proto._visit = function(){ var node = this._node; // quick return if not visible if (!node._visible) @@ -68,9 +72,9 @@ cc.renderer.pushRenderCommand(this); for (; i < childLen; i++) - children[i] && children[i].visit(this); + children[i] && children[i]._renderCmd.visit(this); for (; j < pLen; j++) - locProtectedChildren[j] && locProtectedChildren[j].visit(this); + locProtectedChildren[j] && locProtectedChildren[j]._renderCmd.visit(this); this._cacheDirty = false; }; diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index a51df19da3..eb97f08223 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -544,7 +544,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ context.save(); }else{ this.transform(); - var t = this._transformWorld; + var t = this._renderCmd._worldTransform; context.save(); context.save(); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); From 37fdcc36f3b1aead224f85f4c27daff2398dc890 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 26 Nov 2014 20:55:57 +0800 Subject: [PATCH 0976/1564] Issue #2415: correct some mistakes of cc.Layer and cc.Node --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 180 ++--- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 30 +- .../labelttf/CCLabelTTFCanvasRenderCmd.js | 701 +++++++++--------- .../core/labelttf/CCLabelTTFWebGLRenderCmd.js | 37 +- cocos2d/core/layers/CCLayer.js | 4 +- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 48 +- .../core/sprites/CCSpriteWebGLRenderCmd.js | 41 +- cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js | 2 +- cocos2d/shape-nodes/CCDrawNode.js | 11 +- .../shape-nodes/CCDrawNodeWebGlRenderCmd.js | 10 +- 10 files changed, 543 insertions(+), 521 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index c1f217b4f6..16c64ddeca 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -111,6 +111,77 @@ cc.Node.RenderCmd.prototype = { return null; }, + _updateDisplayColor: function (parentColor) { + var node = this._node; + var locDispColor = this._displayedColor, locRealColor = node._realColor; + var i, len, selChildren, item; + if (this._cascadeColorEnabledDirty && !node._cascadeColorEnabled) { + locDispColor.r = locRealColor.r; + locDispColor.g = locRealColor.g; + locDispColor.b = locRealColor.b; + var whiteColor = new cc.Color(255, 255, 255, 255); + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(whiteColor); + } + } else { + if (parentColor === undefined) { + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + if (node._cascadeColorEnabled) { + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(locDispColor); + } + } + } + this._cascadeColorEnabledDirty = false; + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + }, + + _updateDisplayOpacity: function (parentOpacity) { + var node = this._node; + var i, len, selChildren, item; + if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { + this._displayedOpacity = node._realOpacity; + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(255); + } + } else { + if (parentOpacity === undefined) { + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + if (this._cascadeOpacityEnabled) { + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + } + } + } + this._cascadeOpacityEnabledDirty = false; + this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + }, + _syncDisplayColor : function (parentColor) { var node = this._node, locDispColor = this._displayedColor, locRealColor = node._realColor; if (parentColor === undefined) { @@ -136,6 +207,24 @@ cc.Node.RenderCmd.prototype = { } this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + }, + + updateStatus: function () { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._updateDisplayColor() + } + + if (locFlag & flags.opacityDirty) { + //update the opacity + this._updateDisplayOpacity(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(this.getParentRenderCmd(), true); + } } }; @@ -305,24 +394,6 @@ cc.Node.RenderCmd.prototype = { _t._dirtyFlag = 0; }; - proto.updateStatus = function () { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color - this._updateDisplayColor() - } - - if (locFlag & flags.opacityDirty) { - //update the opacity - this._updateDisplayOpacity(); - } - - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(this.getParentRenderCmd(), true); - } - }; - proto._syncStatus = function (parentCmd) { // In the visit logic does not restore the _dirtyFlag // Because child elements need parent's _dirtyFlag to change himself @@ -384,77 +455,6 @@ cc.Node.RenderCmd.prototype = { //this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; }; - proto._updateDisplayColor = function (parentColor) { - var node = this._node; - var locDispColor = this._displayedColor, locRealColor = node._realColor; - var i, len, selChildren, item; - if (this._cascadeColorEnabledDirty && !node._cascadeColorEnabled) { - locDispColor.r = locRealColor.r; - locDispColor.g = locRealColor.g; - locDispColor.b = locRealColor.b; - var whiteColor = new cc.Color(255, 255, 255, 255); - selChildren = node._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayColor(whiteColor); - } - } else { - if (parentColor === undefined) { - var locParent = node._parent; - if (locParent && locParent._cascadeColorEnabled) - parentColor = locParent.getDisplayedColor(); - else - parentColor = cc.color.WHITE; - } - locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); - locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); - locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - if (node._cascadeColorEnabled) { - selChildren = node._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayColor(locDispColor); - } - } - } - this._cascadeColorEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; - }; - - proto._updateDisplayOpacity = function (parentOpacity) { - var node = this._node; - var i, len, selChildren, item; - if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { - this._displayedOpacity = node._realOpacity; - selChildren = this._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayOpacity(255); - } - } else { - if (parentOpacity === undefined) { - var locParent = node._parent; - parentOpacity = 255; - if (locParent && locParent._cascadeOpacityEnabled) - parentOpacity = locParent.getDisplayedOpacity(); - } - this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - if (this._cascadeOpacityEnabled) { - selChildren = this._children; - for (i = 0, len = selChildren.length; i < len; i++) { - item = selChildren[i]; - if (item && item._renderCmd) - item._renderCmd._updateDisplayOpacity(this._displayedOpacity); - } - } - } - this._cascadeOpacityEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; - }; - proto.setDirtyFlag = function (dirtyFlag) { cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); this._setCacheDirty(); @@ -496,7 +496,7 @@ cc.Node.RenderCmd.prototype = { return null; }; -//util functions + //util functions cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function (blendFunc) { if (!blendFunc) return "source-over"; diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 335cc35186..797a7b386c 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -112,40 +112,16 @@ return this._transform; }; - proto.updateStatus = function () { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color - this._updateDisplayColor() - } - - if (locFlag & flags.opacityDirty) { - //update the opacity - this._updateDisplayOpacity(); - } - - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(this.getParentRenderCmd(), true); - } - }; - proto._syncStatus = function (parentCmd) { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color + if (locFlag & flags.colorDirty) this._syncDisplayColor() - } - if (locFlag & flags.opacityDirty) { - //update the opacity + if (locFlag & flags.opacityDirty) this._syncDisplayOpacity(); - } - if (locFlag & flags.transformDirty) { - //update the transform + if (locFlag & flags.transformDirty) this.transform(parentCmd); - } }; proto.visit = function (parentCmd) { diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 5c62697124..11b4a02fde 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -36,377 +36,382 @@ cc.LabelTTF._lastWordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)$ cc.LabelTTF._lastEnglish = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/; cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; -cc.LabelTTF.RenderCmd = function(){ - this._fontClientHeight = 18; - this._fontStyleStr = ""; - this._shadowColorStr = "rgba(128, 128, 128, 0.5)"; - this._strokeColorStr = ""; - this._fillColorStr = "rgba(255,255,255,1)"; - - this._labelCanvas = null; - this._labelContext = null; - this._lineWidths = []; - this._strings = []; - this._isMultiLine = false; -}; - -cc.LabelTTF.RenderCmd.prototype.constructor = cc.LabelTTF.RenderCmd; - -cc.LabelTTF.RenderCmd.prototype.updateStatus = function(){ - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if(locFlag & flags.colorDirty){ - //update the color - this._updateDisplayColor() - } - - if(locFlag & flags.opacityDirty){ - //update the opacity - this._updateDisplayOpacity(); - } - - if(locFlag & flags.textDirty){ - //update texture for labelTTF - this._updateTexture(); - } - - if(locFlag & flags.transformDirty){ - //update the transform - this.transform(null, true); - } -}; - -cc.LabelTTF.RenderCmd.prototype._syncStatus = function(parentCmd){ - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if(locFlag & flags.colorDirty){ - //update the color - this._syncDisplayColor() - } - - if(locFlag & flags.opacityDirty){ - //update the opacity - this._syncDisplayOpacity(); - } - - if(locFlag & flags.textDirty){ - //update texture for labelTTF - this._updateTexture(); - } - - if(locFlag & flags.transformDirty){ - //update the transform - this.transform(parentCmd); - } -}; - -cc.LabelTTF.RenderCmd.prototype._getLabelContext = function () { - if (this._labelContext) +(function() { + cc.LabelTTF.RenderCmd = function () { + this._fontClientHeight = 18; + this._fontStyleStr = ""; + this._shadowColorStr = "rgba(128, 128, 128, 0.5)"; + this._strokeColorStr = ""; + this._fillColorStr = "rgba(255,255,255,1)"; + + this._labelCanvas = null; + this._labelContext = null; + this._lineWidths = []; + this._strings = []; + this._isMultiLine = false; + }; + var proto = cc.LabelTTF.RenderCmd.prototype; + + proto.constructor = cc.LabelTTF.RenderCmd; + proto.updateStatus = function () { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._updateDisplayColor() + } + + if (locFlag & flags.opacityDirty) { + //update the opacity + this._updateDisplayOpacity(); + } + + if (locFlag & flags.textDirty) { + //update texture for labelTTF + this._updateTexture(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(null, true); + } + }; + + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + if (locFlag & flags.colorDirty) { + //update the color + this._syncDisplayColor() + } + + if (locFlag & flags.opacityDirty) { + //update the opacity + this._syncDisplayOpacity(); + } + + if (locFlag & flags.textDirty) { + //update texture for labelTTF + this._updateTexture(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } + }; + + proto._getLabelContext = function () { + if (this._labelContext) + return this._labelContext; + + var node = this._node; + if (!this._labelCanvas) { + var locCanvas = cc.newElement("canvas"); + var labelTexture = new cc.Texture2D(); + labelTexture.initWithElement(locCanvas); + node.setTexture(labelTexture); + this._labelCanvas = locCanvas; + } + this._labelContext = this._labelCanvas.getContext("2d"); return this._labelContext; + }; + + proto._setFontStyle = function (fontName, fontSize) { + this._fontStyleStr = fontSize + "px '" + fontName + "'"; + this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, fontSize); + }; + + proto._getFontStyle = function () { + return this._fontStyleStr; + }; + + proto._getFontClientHeight = function () { + return this._fontClientHeight; + }; + + proto._updateTexture = function () { + this._dirtyFlag ^= cc.Node._dirtyFlags.textDirty; + var node = this._node; + var locContext = this._getLabelContext(), locLabelCanvas = this._labelCanvas; + var locContentSize = node._contentSize; + + if (node._string.length === 0) { + locLabelCanvas.width = 1; + locLabelCanvas.height = locContentSize.height || 1; + node._texture && node._texture.handleLoadedTexture(); + node.setTextureRect(cc.rect(0, 0, 1, locContentSize.height)); + return true; + } - var node = this._node; - if (!this._labelCanvas) { - var locCanvas = cc.newElement("canvas"); - var labelTexture = new cc.Texture2D(); - labelTexture.initWithElement(locCanvas); - node.setTexture(labelTexture); - this._labelCanvas = locCanvas; - } - this._labelContext = this._labelCanvas.getContext("2d"); - return this._labelContext; -}; - -cc.LabelTTF.RenderCmd.prototype._setFontStyle = function(fontName, fontSize){ - this._fontStyleStr = fontSize + "px '" + fontName + "'"; - this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, fontSize); -}; - -cc.LabelTTF.RenderCmd.prototype._getFontStyle = function () { - return this._fontStyleStr; -}; - -cc.LabelTTF.RenderCmd.prototype._getFontClientHeight = function(){ - return this._fontClientHeight; -}; - -cc.LabelTTF.RenderCmd.prototype._updateTexture = function () { - this._dirtyFlag ^= cc.Node._dirtyFlags.textDirty; - var node = this._node; - var locContext = this._getLabelContext(), locLabelCanvas = this._labelCanvas; - var locContentSize = node._contentSize; - - if (node._string.length === 0) { - locLabelCanvas.width = 1; - locLabelCanvas.height = locContentSize.height || 1; + //set size for labelCanvas + locContext.font = this._fontStyleStr; + this._updateTTF(); + var width = locContentSize.width, height = locContentSize.height; + var flag = locLabelCanvas.width == width && locLabelCanvas.height == height; + locLabelCanvas.width = width; + locLabelCanvas.height = height; + if (flag) locContext.clearRect(0, 0, width, height); + + //draw text to labelCanvas + this._drawTTFInCanvas(locContext); node._texture && node._texture.handleLoadedTexture(); - node.setTextureRect(cc.rect(0, 0, 1, locContentSize.height)); + + node.setTextureRect(cc.rect(0, 0, width, height)); return true; - } - - //set size for labelCanvas - locContext.font = this._fontStyleStr; - this._updateTTF(); - var width = locContentSize.width, height = locContentSize.height; - var flag = locLabelCanvas.width == width && locLabelCanvas.height == height; - locLabelCanvas.width = width; - locLabelCanvas.height = height; - if (flag) locContext.clearRect(0, 0, width, height); - - //draw text to labelCanvas - this._drawTTFInCanvas(locContext); - node._texture && node._texture.handleLoadedTexture(); - - node.setTextureRect(cc.rect(0, 0, width, height)); - return true; -}; - -cc.LabelTTF.RenderCmd.prototype._measureConfig = function(){ - this._getLabelContext().font = this._fontStyleStr; -}; - -cc.LabelTTF.RenderCmd.prototype._measure = function(text){ - return this._getLabelContext().measureText(text).width; -}; - -cc.LabelTTF.RenderCmd.prototype._updateTTF = function(){ - var node = this._node; - var locDimensionsWidth = node._dimensions.width, i, strLength; - var locLineWidth = this._lineWidths; - locLineWidth.length = 0; - - this._isMultiLine = false; - this._measureConfig(); - if (locDimensionsWidth !== 0) { - // Content processing - this._strings = node._string.split('\n'); - - for(i = 0; i < this._strings.length; i++){ - this._checkWarp(this._strings, i, locDimensionsWidth); + }; + + proto._measureConfig = function () { + this._getLabelContext().font = this._fontStyleStr; + }; + + proto._measure = function (text) { + return this._getLabelContext().measureText(text).width; + }; + + proto._updateTTF = function () { + var node = this._node; + var locDimensionsWidth = node._dimensions.width, i, strLength; + var locLineWidth = this._lineWidths; + locLineWidth.length = 0; + + this._isMultiLine = false; + this._measureConfig(); + if (locDimensionsWidth !== 0) { + // Content processing + this._strings = node._string.split('\n'); + + for (i = 0; i < this._strings.length; i++) { + this._checkWarp(this._strings, i, locDimensionsWidth); + } + } else { + this._strings = node._string.split('\n'); + for (i = 0, strLength = this._strings.length; i < strLength; i++) { + locLineWidth.push(this._measure(this._strings[i])); + } } - } else { - this._strings = node._string.split('\n'); - for (i = 0, strLength = this._strings.length; i < strLength; i++) { - locLineWidth.push(this._measure(this._strings[i])); + + if (this._strings.length > 0) + this._isMultiLine = true; + + var locSize, locStrokeShadowOffsetX = 0, locStrokeShadowOffsetY = 0; + if (node._strokeEnabled) + locStrokeShadowOffsetX = locStrokeShadowOffsetY = node._strokeSize * 2; + if (node._shadowEnabled) { + var locOffsetSize = node._shadowOffset; + locStrokeShadowOffsetX += Math.abs(locOffsetSize.x) * 2; + locStrokeShadowOffsetY += Math.abs(locOffsetSize.y) * 2; } - } - - if (this._strings.length > 0) - this._isMultiLine = true; - - var locSize, locStrokeShadowOffsetX = 0, locStrokeShadowOffsetY = 0; - if (node._strokeEnabled) - locStrokeShadowOffsetX = locStrokeShadowOffsetY = node._strokeSize * 2; - if (node._shadowEnabled) { - var locOffsetSize = node._shadowOffset; - locStrokeShadowOffsetX += Math.abs(locOffsetSize.x) * 2; - locStrokeShadowOffsetY += Math.abs(locOffsetSize.y) * 2; - } - - //get offset for stroke and shadow - if (locDimensionsWidth === 0) { - if (this._isMultiLine) - locSize = cc.size(0 | (Math.max.apply(Math, locLineWidth) + locStrokeShadowOffsetX), - 0 | ((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); - else - locSize = cc.size(0 | (this._measure(node._string) + locStrokeShadowOffsetX), 0 | (this._fontClientHeight + locStrokeShadowOffsetY)); - } else { - if (node._dimensions.height === 0) { + + //get offset for stroke and shadow + if (locDimensionsWidth === 0) { if (this._isMultiLine) - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((node.getLineHeight() * this._strings.length) + locStrokeShadowOffsetY)); + locSize = cc.size(0 | (Math.max.apply(Math, locLineWidth) + locStrokeShadowOffsetX), + 0 | ((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); else - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node.getLineHeight() + locStrokeShadowOffsetY)); + locSize = cc.size(0 | (this._measure(node._string) + locStrokeShadowOffsetX), 0 | (this._fontClientHeight + locStrokeShadowOffsetY)); } else { - //dimension is already set, contentSize must be same as dimension - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node._dimensions.height + locStrokeShadowOffsetY)); - } - } - node.setContentSize(locSize); - node._strokeShadowOffsetX = locStrokeShadowOffsetX; - node._strokeShadowOffsetY = locStrokeShadowOffsetY; - - // need computing _anchorPointInPoints - var locAP = node._anchorPoint; - this._anchorPointInPoints.x = (locStrokeShadowOffsetX * 0.5) + ((locSize.width - locStrokeShadowOffsetX) * locAP.x); - this._anchorPointInPoints.y = (locStrokeShadowOffsetY * 0.5) + ((locSize.height - locStrokeShadowOffsetY) * locAP.y); -}; - -cc.LabelTTF.RenderCmd.prototype._drawTTFInCanvas = function (context) { - if (!context) - return; - var node = this._node; - var locStrokeShadowOffsetX = node._strokeShadowOffsetX, locStrokeShadowOffsetY = node._strokeShadowOffsetY; - var locContentSizeHeight = node._contentSize.height - locStrokeShadowOffsetY, locVAlignment = node._vAlignment, - locHAlignment = node._hAlignment, locStrokeSize = node._strokeSize; - - context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); - - //this is fillText for canvas - if (context.font != this._fontStyleStr) - context.font = this._fontStyleStr; - context.fillStyle = this._fillColorStr; - - var xOffset = 0, yOffset = 0; - //stroke style setup - var locStrokeEnabled = node._strokeEnabled; - if (locStrokeEnabled) { - context.lineWidth = locStrokeSize * 2; - context.strokeStyle = this._strokeColorStr; - } - - //shadow style setup - if (node._shadowEnabled) { - var locShadowOffset = node._shadowOffset; - context.shadowColor = this._shadowColorStr; - context.shadowOffsetX = locShadowOffset.x; - context.shadowOffsetY = -locShadowOffset.y; - context.shadowBlur = node._shadowBlur; - } - - context.textBaseline = cc.LabelTTF._textBaseline[locVAlignment]; - context.textAlign = cc.LabelTTF._textAlign[locHAlignment]; - - var locContentWidth = node._contentSize.width - locStrokeShadowOffsetX; - - //lineHeight - var lineHeight = node.getLineHeight(); - var transformTop = (lineHeight - this._fontClientHeight) / 2; - - if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) - xOffset += locContentWidth; - else if (locHAlignment === cc.TEXT_ALIGNMENT_CENTER) - xOffset += locContentWidth / 2; - else - xOffset += 0; - if (this._isMultiLine) { - var locStrLen = this._strings.length; - if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) - yOffset = lineHeight - transformTop * 2 + locContentSizeHeight - lineHeight * locStrLen; - else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_CENTER) - yOffset = (lineHeight - transformTop * 2) / 2 + (locContentSizeHeight - lineHeight * locStrLen) / 2; - - for (var i = 0; i < locStrLen; i++) { - var line = this._strings[i]; - var tmpOffsetY = -locContentSizeHeight + (lineHeight * i + transformTop) + yOffset; - if (locStrokeEnabled) - context.strokeText(line, xOffset, tmpOffsetY); - context.fillText(line, xOffset, tmpOffsetY); + if (node._dimensions.height === 0) { + if (this._isMultiLine) + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((node.getLineHeight() * this._strings.length) + locStrokeShadowOffsetY)); + else + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node.getLineHeight() + locStrokeShadowOffsetY)); + } else { + //dimension is already set, contentSize must be same as dimension + locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node._dimensions.height + locStrokeShadowOffsetY)); + } } - } else { - if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) { - //do nothing - } else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_TOP) { - yOffset -= locContentSizeHeight; - } else { - yOffset -= locContentSizeHeight * 0.5; + node.setContentSize(locSize); + node._strokeShadowOffsetX = locStrokeShadowOffsetX; + node._strokeShadowOffsetY = locStrokeShadowOffsetY; + + // need computing _anchorPointInPoints + var locAP = node._anchorPoint; + this._anchorPointInPoints.x = (locStrokeShadowOffsetX * 0.5) + ((locSize.width - locStrokeShadowOffsetX) * locAP.x); + this._anchorPointInPoints.y = (locStrokeShadowOffsetY * 0.5) + ((locSize.height - locStrokeShadowOffsetY) * locAP.y); + }; + + proto._drawTTFInCanvas = function (context) { + if (!context) + return; + var node = this._node; + var locStrokeShadowOffsetX = node._strokeShadowOffsetX, locStrokeShadowOffsetY = node._strokeShadowOffsetY; + var locContentSizeHeight = node._contentSize.height - locStrokeShadowOffsetY, locVAlignment = node._vAlignment, + locHAlignment = node._hAlignment, locStrokeSize = node._strokeSize; + + context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); + + //this is fillText for canvas + if (context.font != this._fontStyleStr) + context.font = this._fontStyleStr; + context.fillStyle = this._fillColorStr; + + var xOffset = 0, yOffset = 0; + //stroke style setup + var locStrokeEnabled = node._strokeEnabled; + if (locStrokeEnabled) { + context.lineWidth = locStrokeSize * 2; + context.strokeStyle = this._strokeColorStr; } - if (locStrokeEnabled) - context.strokeText(node._string, xOffset, yOffset); - context.fillText(node._string, xOffset, yOffset); - } -}; - -cc.LabelTTF.RenderCmd.prototype._checkWarp = function(strArr, i, maxWidth){ - var text = strArr[i]; - var allWidth = this._measure(text); - if(allWidth > maxWidth && text.length > 1){ - - var fuzzyLen = text.length * ( maxWidth / allWidth ) | 0; - var tmpText = text.substr(fuzzyLen); - var width = allWidth - this._measure(tmpText); - var sLine; - var pushNum = 0; - - //Increased while cycle maximum ceiling. default 100 time - var checkWhile = 0; - - //Exceeded the size - while(width > maxWidth && checkWhile++ < 100){ - fuzzyLen *= maxWidth / width; - fuzzyLen = fuzzyLen | 0; - tmpText = text.substr(fuzzyLen); - width = allWidth - this._measure(tmpText); + + //shadow style setup + if (node._shadowEnabled) { + var locShadowOffset = node._shadowOffset; + context.shadowColor = this._shadowColorStr; + context.shadowOffsetX = locShadowOffset.x; + context.shadowOffsetY = -locShadowOffset.y; + context.shadowBlur = node._shadowBlur; } - checkWhile = 0; + context.textBaseline = cc.LabelTTF._textBaseline[locVAlignment]; + context.textAlign = cc.LabelTTF._textAlign[locHAlignment]; - //Find the truncation point - while(width < maxWidth && checkWhile++ < 100){ - if(tmpText){ - var exec = cc.LabelTTF._wordRex.exec(tmpText); - pushNum = exec ? exec[0].length : 1; - sLine = tmpText; + var locContentWidth = node._contentSize.width - locStrokeShadowOffsetX; + + //lineHeight + var lineHeight = node.getLineHeight(); + var transformTop = (lineHeight - this._fontClientHeight) / 2; + + if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) + xOffset += locContentWidth; + else if (locHAlignment === cc.TEXT_ALIGNMENT_CENTER) + xOffset += locContentWidth / 2; + else + xOffset += 0; + if (this._isMultiLine) { + var locStrLen = this._strings.length; + if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) + yOffset = lineHeight - transformTop * 2 + locContentSizeHeight - lineHeight * locStrLen; + else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_CENTER) + yOffset = (lineHeight - transformTop * 2) / 2 + (locContentSizeHeight - lineHeight * locStrLen) / 2; + + for (var i = 0; i < locStrLen; i++) { + var line = this._strings[i]; + var tmpOffsetY = -locContentSizeHeight + (lineHeight * i + transformTop) + yOffset; + if (locStrokeEnabled) + context.strokeText(line, xOffset, tmpOffsetY); + context.fillText(line, xOffset, tmpOffsetY); + } + } else { + if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) { + //do nothing + } else if (locVAlignment === cc.VERTICAL_TEXT_ALIGNMENT_TOP) { + yOffset -= locContentSizeHeight; + } else { + yOffset -= locContentSizeHeight * 0.5; + } + if (locStrokeEnabled) + context.strokeText(node._string, xOffset, yOffset); + context.fillText(node._string, xOffset, yOffset); + } + }; + + proto._checkWarp = function (strArr, i, maxWidth) { + var text = strArr[i]; + var allWidth = this._measure(text); + if (allWidth > maxWidth && text.length > 1) { + + var fuzzyLen = text.length * ( maxWidth / allWidth ) | 0; + var tmpText = text.substr(fuzzyLen); + var width = allWidth - this._measure(tmpText); + var sLine; + var pushNum = 0; + + //Increased while cycle maximum ceiling. default 100 time + var checkWhile = 0; + + //Exceeded the size + while (width > maxWidth && checkWhile++ < 100) { + fuzzyLen *= maxWidth / width; + fuzzyLen = fuzzyLen | 0; + tmpText = text.substr(fuzzyLen); + width = allWidth - this._measure(tmpText); } - fuzzyLen = fuzzyLen + pushNum; + checkWhile = 0; - tmpText = text.substr(fuzzyLen); + //Find the truncation point + while (width < maxWidth && checkWhile++ < 100) { + if (tmpText) { + var exec = cc.LabelTTF._wordRex.exec(tmpText); + pushNum = exec ? exec[0].length : 1; + sLine = tmpText; + } - width = allWidth - this._measure(tmpText); - } + fuzzyLen = fuzzyLen + pushNum; - fuzzyLen -= pushNum; - if(fuzzyLen === 0){ - fuzzyLen = 1; - sLine = sLine.substr(1); - } + tmpText = text.substr(fuzzyLen); - var sText = text.substr(0, fuzzyLen), result; + width = allWidth - this._measure(tmpText); + } - //symbol in the first - if(cc.LabelTTF.wrapInspection){ - if(cc.LabelTTF._symbolRex.test(sLine || tmpText)){ - result = cc.LabelTTF._lastWordRex.exec(sText); - fuzzyLen -= result ? result[0].length : 0; + fuzzyLen -= pushNum; + if (fuzzyLen === 0) { + fuzzyLen = 1; + sLine = sLine.substr(1); + } - sLine = text.substr(fuzzyLen); - sText = text.substr(0, fuzzyLen); + var sText = text.substr(0, fuzzyLen), result; + + //symbol in the first + if (cc.LabelTTF.wrapInspection) { + if (cc.LabelTTF._symbolRex.test(sLine || tmpText)) { + result = cc.LabelTTF._lastWordRex.exec(sText); + fuzzyLen -= result ? result[0].length : 0; + + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); + } } - } - //To judge whether a English words are truncated - if(cc.LabelTTF._firsrEnglish.test(sLine)){ - result = cc.LabelTTF._lastEnglish.exec(sText); - if(result && sText !== result[0]){ - fuzzyLen -= result[0].length; - sLine = text.substr(fuzzyLen); - sText = text.substr(0, fuzzyLen); + //To judge whether a English words are truncated + if (cc.LabelTTF._firsrEnglish.test(sLine)) { + result = cc.LabelTTF._lastEnglish.exec(sText); + if (result && sText !== result[0]) { + fuzzyLen -= result[0].length; + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); + } } - } - strArr[i] = sLine || tmpText; - strArr.splice(i, 0, sText); - } -}; - -// ---------------------------------- LabelTTF Canvas render cmd -------------------------- -cc.LabelTTF.CanvasRenderCmd = function(renderable){ - cc.Sprite.CanvasRenderCmd.call(this, renderable); - cc.LabelTTF.RenderCmd.call(this); -}; - -cc.LabelTTF.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); -cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.CanvasRenderCmd.prototype); -cc.LabelTTF.CanvasRenderCmd.prototype.constructor = cc.LabelTTF.CanvasRenderCmd; - -cc.LabelTTF.CanvasRenderCmd.prototype._updateDisplayedOpacity = function(parentOpacity){ - cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedOpacity.call(this, parentOpacity); - this._setColorsString(); -}; - -cc.LabelTTF.CanvasRenderCmd.prototype._updateDisplayedColor = function(parentColor){ - cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedColor.call(this, parentColor); - this._setColorsString(); -}; - -cc.LabelTTF.CanvasRenderCmd.prototype._setColorsString = function(){ - this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); - - var locDisplayColor = this._displayedColor, node = this._node, - locDisplayedOpacity = this._displayedOpacity, - locShadowColor = node._shadowColor || this._displayedColor; - var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; - - this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r * 0.5)) + "," + (0 | (locShadowColor.g * 0.5)) + "," + (0 | (locShadowColor.b * 0.5)) + "," + node._shadowOpacity + ")"; - this._fillColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locFontFillColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locFontFillColor.g)) + "," - + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; - this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," - + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; -}; \ No newline at end of file + strArr[i] = sLine || tmpText; + strArr.splice(i, 0, sText); + } + }; +})(); + +(function(){ + cc.LabelTTF.CanvasRenderCmd = function (renderable) { + cc.Sprite.CanvasRenderCmd.call(this, renderable); + cc.LabelTTF.RenderCmd.call(this); + }; + + cc.LabelTTF.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); + cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.CanvasRenderCmd.prototype); + + var proto = cc.LabelTTF.CanvasRenderCmd.prototype; + proto.constructor = cc.LabelTTF.CanvasRenderCmd; + + proto._updateDisplayedOpacity = function (parentOpacity) { + cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedOpacity.call(this, parentOpacity); + this._setColorsString(); + }; + + proto._updateDisplayedColor = function (parentColor) { + cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedColor.call(this, parentColor); + this._setColorsString(); + }; + + proto._setColorsString = function () { + this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); + + var locDisplayColor = this._displayedColor, node = this._node, + locDisplayedOpacity = this._displayedOpacity, + locShadowColor = node._shadowColor || this._displayedColor; + var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; + + this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r * 0.5)) + "," + (0 | (locShadowColor.g * 0.5)) + "," + (0 | (locShadowColor.b * 0.5)) + "," + node._shadowOpacity + ")"; + this._fillColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locFontFillColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locFontFillColor.g)) + "," + + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; + this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," + + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; + }; +})(); \ No newline at end of file diff --git a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js index 82828686d9..9f47f7cb9f 100644 --- a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js @@ -23,21 +23,22 @@ ****************************************************************************/ // ----------------------------------- LabelTTF WebGL render cmd ---------------------------- - -cc.LabelTTF.WebGLRenderCmd = function(renderable){ - cc.Sprite.WebGLRenderCmd.call(this, renderable); - cc.LabelTTF.RenderCmd.call(this); -}; - -cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); -cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit -cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; - -cc.LabelTTF.WebGLRenderCmd.prototype._setColorsString = function(){ - this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); - var node = this._node; - var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; - this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; - this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; - this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; -}; \ No newline at end of file +(function() { + cc.LabelTTF.WebGLRenderCmd = function (renderable) { + cc.Sprite.WebGLRenderCmd.call(this, renderable); + cc.LabelTTF.RenderCmd.call(this); + }; + + cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); + cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit + cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; + + cc.LabelTTF.WebGLRenderCmd.prototype._setColorsString = function () { + this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); + var node = this._node; + var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; + this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; + this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; + this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; + }; +})(); \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 64e48972b1..96ae76fe73 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -240,13 +240,13 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{ }, _setWidth: function(width){ - this._renderCmd._updateSquareVerticesWidth(width); cc.Node.prototype._setWidth.call(this, width); + this._renderCmd._updateSquareVerticesWidth(width); }, _setHeight: function(height){ - this._renderCmd._updateSquareVerticesHeight(height); cc.Node.prototype._setHeight.call(this, height); + this._renderCmd._updateSquareVerticesHeight(height); }, setContentSize: function(size, height){ diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index 5659162ad8..1418c2eaa1 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -126,24 +126,43 @@ this._bindLayerVerticesBufferData(); }; - proto._updateDisplayColor = function(parentColor){ - cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._updateColor(); - }; + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; - proto._updateDisplayOpacity= function(parentOpacity){ - cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); - this._updateColor(); - }; + if (colorDirty) + this._syncDisplayColor(); + + if (opacityDirty) + this._syncDisplayOpacity(); - proto._syncDisplayColor = function(parentColor){ - cc.Node.WebGLRenderCmd.prototype._syncDisplayColor.call(this, parentColor); - this._updateColor(); + if(colorDirty || opacityDirty) + this._updateColor(); + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } }; - proto._syncDisplayOpacity = function(parentOpacity){ - cc.Node.WebGLRenderCmd.prototype._syncDisplayOpacity.call(this, parentOpacity); - this._updateColor(); + proto.updateStatus = function(){ + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if(colorDirty) + this._updateDisplayColor(); + + if(opacityDirty) + this._updateDisplayOpacity(); + + if(colorDirty || opacityDirty) + this._updateColor(); + + if(this._dirtyFlag & flags.transformDirty){ + //update the transform + this.transform(null, true); + } }; proto._updateColor = function(){ @@ -156,7 +175,6 @@ locSquareColors[i].a = locDisplayedOpacity; } this._bindLayerColorsBufferData(); - this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); }; proto._bindLayerVerticesBufferData = function(){ diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 6a924e4ad1..736c8c6b4b 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -209,14 +209,43 @@ this._quadDirty = true; }; - proto._updateDisplayColor = function (parentColor) { - cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._updateColor(); + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + + if (colorDirty) + this._syncDisplayColor(); + + if (opacityDirty) + this._syncDisplayOpacity(); + + if(colorDirty || opacityDirty) + this._updateColor(); + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } }; - proto._updateDisplayOpacity = function (parentOpacity) { - cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); - this._updateColor(); + proto.updateStatus = function(){ + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if(colorDirty) + this._updateDisplayColor(); + + if(opacityDirty) + this._updateDisplayOpacity(); + + if(colorDirty || opacityDirty) + this._updateColor(); + + if(this._dirtyFlag & flags.transformDirty){ + //update the transform + this.transform(null, true); + } }; proto._updateColor = function () { diff --git a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js index b5976d366a..315d542ceb 100644 --- a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js @@ -37,7 +37,7 @@ node._cascadeColorEnabled = true; }; - proto.rendering = function(){ + proto.rendering = function(ctx){ cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, ctx); if (cc.LABELATLAS_DEBUG_DRAW) { var s = this._node.getContentSize(); diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 303aab6066..a2dddea4aa 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -800,13 +800,6 @@ cc.DrawNodeWebGL = cc.Node.extend({ } }, - draw:function () { - cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - this._shaderProgram.use(); - this._shaderProgram.setUniformsForBuiltins(); - this._render(); - }, - drawDot:function (pos, radius, color) { color = color || this.getDrawColor(); if (color.a == null) @@ -1009,9 +1002,9 @@ cc.DrawNodeWebGL = cc.Node.extend({ this._dirty = true; }, - _createRenderCmd: function(){ + _createRenderCmd: function () { return new cc.DrawNode.WebGLRenderCmd(this); -} + } }); cc.DrawNode = cc._renderType == cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas; diff --git a/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js index d869eab6ff..8daaf6af72 100644 --- a/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js +++ b/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js @@ -33,10 +33,10 @@ cc.DrawNode.WebGLRenderCmd.prototype.constructor = cc.DrawNode.WebGLRenderCmd; cc.DrawNode.WebGLRenderCmd.prototype.rendering = function (ctx) { - var _t = this._node; - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); - _t._render(); + var node = this._node; + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + node._render(); }; })(); \ No newline at end of file From 2084cd22d39ebd0da15e54300c9773baf9e070e5 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 27 Nov 2014 10:28:39 +0800 Subject: [PATCH 0977/1564] fix typo of file name --- .../{CCDrawNodeWebGlRenderCmd.js => CCDrawNodeWebGLRenderCmd.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cocos2d/shape-nodes/{CCDrawNodeWebGlRenderCmd.js => CCDrawNodeWebGLRenderCmd.js} (100%) diff --git a/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js similarity index 100% rename from cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js rename to cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js From 2023c80a531f50eff4c892731c67d1a4d7709972 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 27 Nov 2014 10:40:49 +0800 Subject: [PATCH 0978/1564] Fix typo of Director in comments --- cocos2d/core/CCDirector.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 2a4ad8338d..bb572bc8dd 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -581,7 +581,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ /** * Sets an OpenGL projection.
    - * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. * @function * @param {Number} projection */ @@ -589,14 +589,14 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ /** * Update the view port.
    - * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. * @function */ setViewport: null, /** * Get the CCEGLView, where everything is rendered.
    - * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. * @function * @return {cc.view} */ @@ -604,7 +604,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ /** * Sets an OpenGL projection.
    - * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. * @function * @return {Number} */ @@ -612,7 +612,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ /** * Enables/disables OpenGL alpha blending.
    - * Implementation can be found in CCDiretorCanvas.js/CCDiretorWebGL.js. + * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js. * @function * @param {Boolean} on */ From ffb48e913add35152e0783e73886ede91be5e1c5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 27 Nov 2014 11:31:39 +0800 Subject: [PATCH 0979/1564] Issue #2416: correct some mistakes of cc.ClippingNode --- .../CCClippingNodeWebGLRenderCmd.js | 52 +++++++------------ cocos2d/core/base-nodes/CCNode.js | 4 +- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 5 +- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 4 ++ .../core/sprites/CCSpriteCanvasRenderCmd.js | 2 +- .../core/sprites/CCSpriteWebGLRenderCmd.js | 18 +++---- 6 files changed, 39 insertions(+), 46 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js index ea58b64440..1aa5ce5ab9 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js @@ -63,15 +63,16 @@ }; proto.transform = function(parentCmd, recursive){ + var node = this._node; cc.Node.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); - if(this._stencil) - this._stencil._renderCmd.transform(parentCmd, recursive); + if(node._stencil) + node._stencil._renderCmd.transform(this, recursive); }; proto.visit = function(parentCmd){ - var _t = this, node = this._node; + var node = this._node; // quick return if not visible - if (!_t._visible) + if (!node._visible) return; if( node._parent && node._parent._renderCmd) @@ -84,8 +85,8 @@ return; } - if (!this._stencil || !this._stencil.visible) { - if (this.inverted) + if (!node._stencil || !node._stencil.visible) { + if (node.inverted) cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); // draw everything return; } @@ -106,38 +107,23 @@ //optimize performance for javascript var currentStack = cc.current_stack; currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); + this._syncStatus(parentCmd); currentStack.top = this._stackMatrix; - this._syncStatus(parentCmd); //this._stencil._stackMatrix = this._stackMatrix; - this._stencil.visit(parentCmd); + node._stencil._renderCmd.visit(this); cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); // draw (according to the stencil test func) this node and its children - var locChildren = this._children; + var locChildren = node._children; if (locChildren && locChildren.length > 0) { var childLen = locChildren.length; - this.sortAllChildren(); + node.sortAllChildren(); // draw children zOrder < 0 for (var i = 0; i < childLen; i++) { - if (locChildren[i] && locChildren[i]._localZOrder < 0) - locChildren[i].visit(); - else - break; - } - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - // draw children zOrder >= 0 - for (; i < childLen; i++) { - if (locChildren[i]) { - locChildren[i].visit(); - } + locChildren[i]._renderCmd.visit(this); } - } else{ - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); } cc.renderer.pushRenderCommand(this._afterVisitCmd); @@ -152,7 +138,7 @@ node._stencil._parent = null; node._stencil = stencil; if(node._stencil) - node._stencil._parent = this; + node._stencil._parent = node; }; proto._drawFullScreenQuadClearStencil = function () { @@ -171,7 +157,7 @@ }; proto._onBeforeVisit = function(ctx){ - var gl = ctx || cc._renderContext; + var gl = ctx || cc._renderContext, node = this._node; cc.ClippingNode.WebGLRenderCmd._layer++; // mask of the current layer (ie: for layer 3: 00000100) @@ -199,20 +185,20 @@ gl.depthMask(false); gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(!this.inverted ? gl.ZERO : gl.REPLACE, gl.KEEP, gl.KEEP); + gl.stencilOp(!node.inverted ? gl.ZERO : gl.REPLACE, gl.KEEP, gl.KEEP); this._drawFullScreenQuadClearStencil(); gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(!this.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP); + gl.stencilOp(!node.inverted ? gl.REPLACE : gl.ZERO, gl.KEEP, gl.KEEP); - if (this.alphaThreshold < 1) { //TODO desktop + if (node.alphaThreshold < 1) { //TODO desktop var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST); var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S); // set our alphaThreshold cc.glUseProgram(program.getProgram()); - program.setUniformLocationWith1f(alphaValueLocation, this.alphaThreshold); - cc.setProgram(this._stencil, program); + program.setUniformLocationWith1f(alphaValueLocation, node.alphaThreshold); + cc.setProgram(node._stencil, program); } }; diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index f404b60cce..8cb4c5bc9e 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2043,8 +2043,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx */ - visit: function(){ - this._renderCmd.visit(); + visit: function(parentCmd){ + this._renderCmd.visit(parentCmd); }, /** diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 16c64ddeca..640c95e0e9 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -40,7 +40,7 @@ cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacit //-------------------------Base ------------------------- cc.Node.RenderCmd = function(renderable){ - this._dirtyFlag = 0; + this._dirtyFlag = 1; //need update the transform at first. this._node = renderable; this._needDraw = false; @@ -412,6 +412,9 @@ cc.Node.RenderCmd.prototype = { if(parentNode && parentNode._cascadeOpacityEnabled && (parentCmd._dirtyFlag & flags.opacityDirty)) locFlag |= flags.opacityDirty; + if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) + locFlag |= flags.transformDirty; + if (locFlag & flags.colorDirty) { //update the color this._syncDisplayColor() diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 797a7b386c..5582d8520d 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -114,6 +114,10 @@ proto._syncStatus = function (parentCmd) { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + + if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) + locFlag |= flags.transformDirty; + if (locFlag & flags.colorDirty) this._syncDisplayColor() diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index f47762937b..77f6c56d91 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -369,7 +369,7 @@ //set the texture's color after the it loaded var locColor = locRenderCmd._displayedColor; if (locColor.r != 255 || locColor.g != 255 || locColor.b != 255) - _t._changeTextureColor(); + locRenderCmd._changeTextureColor(); // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 736c8c6b4b..1b36b7be6d 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -101,12 +101,12 @@ }; proto._textureLoadedCallback = function (sender) { - var node = this._node; - if (node._textureLoaded) + var renderCmd = this._renderCmd; + if (this._textureLoaded) return; - node._textureLoaded = true; - var locRect = node._rect; + this._textureLoaded = true; + var locRect = this._rect; if (!locRect) { locRect = cc.rect(0, 0, sender.width, sender.height); } else if (cc._rectEqualToZero(locRect)) { @@ -114,14 +114,14 @@ locRect.height = sender.height; } - node.texture = sender; - node.setTextureRect(locRect, node._rectRotated); + this.texture = sender; + this.setTextureRect(locRect, this._rectRotated); // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - node.setBatchNode(node._batchNode); - this._quadDirty = true; - node.dispatchEvent("load"); + this.setBatchNode(this._batchNode); + renderCmd._quadDirty = true; + this.dispatchEvent("load"); }; proto._setTextureCoords = function (rect, needConvert) { From 2cc540df5fc6b2d3cea87d7617c8fd624968d24f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 27 Nov 2014 14:48:12 +0800 Subject: [PATCH 0980/1564] Issue #2416: correct some mistakes of AtlasNode, Sprite, SpriteBatchNode --- cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js | 10 ---------- cocos2d/core/sprites/CCSprite.js | 8 ++++---- cocos2d/core/sprites/CCSpriteBatchNode.js | 4 ++-- .../core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js | 5 +++-- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 4 ++-- cocos2d/core/textures/TexturesWebGL.js | 7 +++---- cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js | 3 +++ cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js | 1 - 8 files changed, 17 insertions(+), 25 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js index 092f0951fb..e9bfde7295 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js @@ -94,16 +94,6 @@ return true; }; - proto.draw = function(ctx){ - var context = ctx || cc._renderContext; - cc.nodeDrawSetup(this); - cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - if(this._uniformColor && this._colorF32Array){ - context.uniform4fv(this._uniformColor, this._colorF32Array); - this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0); - } - }; - proto.setColor = function(color3){ var temp = cc.color(color3.r, color3.g, color3.b); this._colorUnmodified = color3; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 945c49892d..aba56cf0be 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -72,8 +72,8 @@ * var sprite2 = new cc.Sprite(texture, cc.rect(0,0,480,320)); * * @property {Boolean} dirty - Indicates whether the sprite needs to be updated. - * @property {Boolean} flippedX - Indicates whether or not the spirte is flipped on x axis. - * @property {Boolean} flippedY - Indicates whether or not the spirte is flipped on y axis. + * @property {Boolean} flippedX - Indicates whether or not the sprite is flipped on x axis. + * @property {Boolean} flippedY - Indicates whether or not the sprite is flipped on y axis. * @property {Number} offsetX - <@readonly> The offset position on x axis of the sprite in texture. Calculated automatically by editors like Zwoptex. * @property {Number} offsetY - <@readonly> The offset position on x axis of the sprite in texture. Calculated automatically by editors like Zwoptex. * @property {Number} atlasIndex - The index used on the TextureAtlas. @@ -285,7 +285,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param {cc.SpriteBatchNode} batchNode */ useBatchNode:function (batchNode) { - this.textureAtlas = batchNode.textureAtlas; // weak ref + this.textureAtlas = batchNode.getTextureAtlas(); // weak ref this._batchNode = batchNode; }, @@ -929,7 +929,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ } else { // using batch _t._transformToBatch = cc.affineTransformIdentity(); - _t.textureAtlas = _t._batchNode.textureAtlas; // weak ref + _t.textureAtlas = _t._batchNode.getTextureAtlas(); // weak ref } }, diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index d976afa3b4..bd9dc70ca3 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -124,7 +124,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @return {cc.TextureAtlas} */ getTextureAtlas: function () { - return this._renderCmd.getTexture(); + return this._renderCmd.getTextureAtlas(); }, /** @@ -132,7 +132,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ * @param {cc.TextureAtlas} textureAtlas */ setTextureAtlas: function (textureAtlas) { - this._renderCmd.setTexture(textureAtlas); + this._renderCmd.getTextureAtlas(textureAtlas); }, /** diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index caea22eecd..509f247baa 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -183,8 +183,9 @@ proto._updateBlendFunc = function () { if (!this._textureAtlas.texture.hasPremultipliedAlpha()) { - this._blendFunc.src = cc.SRC_ALPHA; - this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; + var blendFunc = this._node._blendFunc; + blendFunc.src = cc.SRC_ALPHA; + blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; } }; diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 1b36b7be6d..64483fda73 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -365,7 +365,7 @@ var dx = x1 * cr - y2 * sr2 + x; var dy = x1 * sr + y2 * cr2 + y; - var locVertexZ = _t._vertexZ; + var locVertexZ = node._vertexZ; if (!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { ax = 0 | ax; ay = 0 | ay; @@ -381,7 +381,7 @@ locQuad.tl.vertices = {x: dx, y: dy, z: locVertexZ}; locQuad.tr.vertices = {x: cx, y: cy, z: locVertexZ}; } - node.textureAtlas.updateQuad(locQuad, _t.atlasIndex); + node.textureAtlas.updateQuad(locQuad, node.atlasIndex); node._recursiveDirty = false; node.dirty = false; } diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index abd6b53ee7..a273578faa 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -815,16 +815,15 @@ cc._tmp.WebGLTextureAtlas = function () { cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadsWebBuffer); - if (_t.dirty) + if (_t.dirty){ gl.bufferData(gl.ARRAY_BUFFER, _t._quadsArrayBuffer, gl.DYNAMIC_DRAW); + _t.dirty = false; + } gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords - if (_t.dirty) - _t.dirty = false; - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]); if (cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP) diff --git a/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js index 2161e3337c..30da1fe854 100644 --- a/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js @@ -31,6 +31,9 @@ this._needDraw = true; }; + cc.PhysicsDebugNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + cc.PhysicsDebugNode.WebGLRenderCmd.prototype.constructor = cc.PhysicsDebugNode.WebGLRenderCmd; + cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function (ctx) { var node = this._node; if (!node._space) diff --git a/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js index 8daaf6af72..2c393c6cdb 100644 --- a/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js +++ b/cocos2d/shape-nodes/CCDrawNodeWebGlRenderCmd.js @@ -23,7 +23,6 @@ ****************************************************************************/ (function(){ - cc.DrawNode.WebGLRenderCmd = function (renderableObject) { cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; From c914fe22614db5888641f31cdcfa8836521709ad Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 27 Nov 2014 15:40:33 +0800 Subject: [PATCH 0981/1564] Issue #2416: CCUI support --- .../ccui/base-classes/CCProtectedNode.js | 2 + .../CCProtectedNodeCanvasRenderCmd.js | 9 ++- .../CCProtectedNodeWebGLRenderCmd.js | 4 +- .../ccui/base-classes/UIScale9Sprite.js | 35 +++-------- .../UIScale9SpriteCanvasRenderCmd.js | 63 +++++++++++++++++++ .../UIScale9SpriteWebGLRenderCmd.js | 48 ++++++++++++++ extensions/ccui/base-classes/UIWidget.js | 1 - extensions/ccui/layouts/UILayout.js | 27 +++++--- extensions/ccui/uiwidgets/UIButton.js | 5 +- extensions/ccui/uiwidgets/UIText.js | 8 +-- extensions/ccui/uiwidgets/UITextField.js | 8 +-- moduleConfig.json | 2 + 12 files changed, 155 insertions(+), 57 deletions(-) create mode 100644 extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js create mode 100644 extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 2bc449d450..beff22b6fe 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -237,6 +237,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ this._renderCmd._visit(); }, + _changePosition: function(){}, + /** * Stops itself and its children and protected children's all running actions and schedulers * @override diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index ec7015f76a..ef87519717 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -57,14 +57,14 @@ for (i = 0; i < childLen; i++) { child = children[i]; if (child._localZOrder < 0) - child._renderCmd.visit(this); + child.visit(this); else break; } for (j = 0; j < pLen; j++) { child = locProtectedChildren[j]; if (child._localZOrder < 0) - child._renderCmd.visit(this); + child.visit(this); else break; } @@ -81,6 +81,10 @@ proto.transform = function(parentCmd, recursive){ var node = this._node; + + if(node._changePosition) + node._changePosition(); + var t = node.getNodeToParentTransform(), worldT = this._worldTransform; if(parentCmd){ var pt = parentCmd._worldTransform; @@ -113,6 +117,7 @@ locChildren = node._protectedChildren; for( i = 0, len = locChildren.length; i< len; i++) locChildren[i]._renderCmd.transform(this); + } })(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index 92f3f1bd67..025d6f79d1 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -110,10 +110,10 @@ var i, len, locChildren = node._children; for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._renderCmd.transform(); + locChildren[i]._renderCmd.transform(this); } locChildren = node._protectedChildren; for( i = 0, len = locChildren.length; i< len; i++) - locChildren[i]._renderCmd.transform(); + locChildren[i]._renderCmd.transform(this); }; })(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 2f18ce8724..b0997f6670 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -490,34 +490,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._positionsAreDirty = true; }, - visit: function (ctx) { - if(!this._visible){ - return; - } - - if (this._positionsAreDirty) { - this._updatePositions(); - this._positionsAreDirty = false; - this._scale9Dirty = true; - } - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._scale9Dirty = false; - this._cacheScale9Sprite(); - - cc.Node.prototype.visit.call(this, ctx); - }else{ - cc.Node.prototype.visit.call(this, ctx); - } - }, - - _transformForRenderer: function(){ - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._cacheScale9Sprite(); - this.transform(); - } - cc.Node.prototype._transformForRenderer.call(this); - }, - /** * Initializes a ccui.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @returns {boolean} @@ -1032,6 +1004,13 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._insetTop = 0; this._insetRight = 0; this._insetBottom = 0; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new ccui.Scale9Sprite.CanvasRenderCmd(this); + else + return new ccui.Scale9Sprite.WebGLRenderCmd(this); } }); diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js new file mode 100644 index 0000000000..74779c49a3 --- /dev/null +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -0,0 +1,63 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function() { + ccui.Scale9Sprite.CanvasRenderCmd = function (renderable) { + cc.Node.CanvasRenderCmd.call(this, renderable); + this._cachedParent = null; + this._cacheDirty = false; + }; + + var proto = ccui.Scale9Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = ccui.Scale9Sprite.CanvasRenderCmd; + + proto.visit = function(){ + var node = this._node; + if(!node._visible){ + return; + } + + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; + } + node._scale9Dirty = false; + node._cacheScale9Sprite(); + + cc.Node.CanvasRenderCmd.prototype.visit.call(this, ctx); + }; + + proto.transform = function(parentCmd){ + var node = this._node; + node._cacheScale9Sprite(); + cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); + + var children = node._children; + for(var i=0; i Date: Thu, 27 Nov 2014 17:32:09 +0800 Subject: [PATCH 0982/1564] Fix PhysicsDebugNode on webgl --- cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js index 30da1fe854..38ddf9f630 100644 --- a/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js @@ -41,7 +41,13 @@ node._space.eachShape(cc.DrawShape.bind(node)); node._space.eachConstraint(cc.DrawConstraint.bind(node)); - cc.DrawNode.prototype.draw.call(node); + + //cc.DrawNode.prototype.draw.call(node); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + node._render(); + node.clear(); }; })(); \ No newline at end of file From 2f69a6b58c79cfb1a8f3950cbd64695c2f17120e Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 27 Nov 2014 18:07:44 +0800 Subject: [PATCH 0983/1564] Fix PhysicsSprite on webgl --- .../physics/CCPhysicsSpriteWebGLRenderCmd.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js index 2d1065c884..c45b80f8f6 100644 --- a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js @@ -27,21 +27,25 @@ */ (function(){ cc.PhysicsSprite.WebGLRenderCmd = function(renderableObject){ - cc.Sprite.CanvasRenderCmd.call(this, renderableObject); + cc.Sprite.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; }; - var proto = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); + var proto = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); proto.constructor = cc.PhysicsSprite.WebGLRenderCmd; - proto.rendering = function(ctx, scaleX, scaleY){ + proto.rendering = function(ctx){ // This is a special class // Sprite can not obtain sign // So here must to calculate of each frame - // TODO _transformForRenderer has been deleted. - if(this._node._transformForRenderer) - this._node._transformForRenderer(); - cc.Sprite.CanvasRenderCmd.prototype.rendering.call(this, ctx, scaleX, scaleY); + + var node = this._node; + node._syncPosition(); + if(!node._ignoreBodyRotation) + node._syncRotation(); + this.transform(this.getParentRenderCmd()); + + cc.Sprite.WebGLRenderCmd.prototype.rendering.call(this, ctx); }; proto.getNodeToParentTransform = function(){ From c101cda0d6f9ff51f53c66c083026fe1f19b853e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 27 Nov 2014 19:41:38 +0800 Subject: [PATCH 0984/1564] Issue #2416: CCScale9Sprite --- cocos2d/core/base-nodes/CCNode.js | 1 + .../gui/control-extension/CCScale9Sprite.js | 35 +++-------- .../CCScale9SpriteCanvasRenderCmd.js | 63 +++++++++++++++++++ .../CCScale9SpriteWebGLRenderCmd.js | 48 ++++++++++++++ moduleConfig.json | 2 + 5 files changed, 121 insertions(+), 28 deletions(-) create mode 100644 extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js create mode 100644 extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 8cb4c5bc9e..c3db23aed7 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -870,6 +870,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, _setHeight: function (height) { this._contentSize.height = height; + this._renderCmd._updateAnchorPointInPoint(); }, /** diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 3360ccf095..6fbfcc9eba 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -484,34 +484,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._positionsAreDirty = true; }, - visit: function (ctx) { - if(!this._visible){ - return; - } - - if (this._positionsAreDirty) { - this._updatePositions(); - this._positionsAreDirty = false; - this._scale9Dirty = true; - } - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._scale9Dirty = false; - this._cacheScale9Sprite(); - - cc.Node.prototype.visit.call(this, ctx); - }else{ - cc.Node.prototype.visit.call(this, ctx); - } - }, - - _transformForRenderer: function(){ - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this._cacheScale9Sprite(); - this.transform(); - } - cc.Node.prototype._transformForRenderer.call(this); - }, - /** * Initializes a cc.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @returns {boolean} @@ -1026,6 +998,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._insetTop = 0; this._insetRight = 0; this._insetBottom = 0; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.Scale9Sprite.CanvasRenderCmd(this); + else + return new cc.Scale9Sprite.WebGLRenderCmd(this); } }); diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js new file mode 100644 index 0000000000..2d794fc111 --- /dev/null +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -0,0 +1,63 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function() { + cc.Scale9Sprite.CanvasRenderCmd = function (renderable) { + cc.Node.CanvasRenderCmd.call(this, renderable); + this._cachedParent = null; + this._cacheDirty = false; + }; + + var proto = cc.Scale9Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.Scale9Sprite.CanvasRenderCmd; + + proto.visit = function(){ + var node = this._node; + if(!node._visible){ + return; + } + + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; + } + node._scale9Dirty = false; + node._cacheScale9Sprite(); + + cc.Node.CanvasRenderCmd.prototype.visit.call(this, ctx); + }; + + proto.transform = function(parentCmd){ + var node = this._node; + node._cacheScale9Sprite(); + cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); + + var children = node._children; + for(var i=0; i Date: Fri, 28 Nov 2014 11:29:16 +0800 Subject: [PATCH 0985/1564] Issue #2416: correct the mistake updating status in SpriteBatchNode --- cocos2d/core/base-nodes/CCNode.js | 4 +-- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 1 - cocos2d/core/sprites/CCSprite.js | 18 +---------- .../CCSpriteBatchNodeWebGLRenderCmd.js | 26 +++++++++++++++- .../core/sprites/CCSpriteCanvasRenderCmd.js | 29 +++++++++-------- .../core/sprites/CCSpriteWebGLRenderCmd.js | 31 ++++++++++++++++--- cocos2d/particle/CCParticleSystem.js | 1 - .../CCParticleSystemWebGLRenderCmd.js | 20 ++++++------ template/src/myApp.js | 9 ++++-- 9 files changed, 85 insertions(+), 54 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 8cb4c5bc9e..3e38fb65f7 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -778,10 +778,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Boolean} visible Pass true to make the node visible, false to hide the node. */ setVisible: function (visible) { - if(this._visible != visible){ + if(this._visible !== visible){ this._visible = visible; //if(visible) - // this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.visibleDirty); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); cc.renderer.childrenOrderDirty = true; } }, diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 5582d8520d..d33d0c0924 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -142,7 +142,6 @@ //optimize performance for javascript currentStack.stack.push(currentStack.top); - //cc.kmMat4Assign(_t._stackMatrix, currentStack.top); _t._syncStatus(parentCmd); currentStack.top = _t._stackMatrix; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index aba56cf0be..d88eefb017 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -387,7 +387,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ */ setVisible:function (visible) { cc.Node.prototype.setVisible.call(this, visible); - this.setDirtyRecursively(true); + this._renderCmd.setDirtyRecursively(true); }, /** @@ -410,22 +410,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // cc.Node property overloads // - /** - * Sets recursively the dirty flag. - * Used only when parent is cc.SpriteBatchNode - * @param {Boolean} value - */ - setDirtyRecursively:function (value) { - this._recursiveDirty = value; - this.dirty = value; - // recursively set dirty - var locChildren = this._children, child, l = locChildren ? locChildren.length : 0; - for (var i = 0; i < l; i++) { - child = locChildren[i]; - (child instanceof cc.Sprite) && child.setDirtyRecursively(true); - } - }, - /** * Sets whether ignore anchor point for positioning * @param {Boolean} relative diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 509f247baa..53f621af11 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -39,7 +39,6 @@ if (this._textureAtlas.totalQuads === 0) return; - //cc.nodeDrawSetup(this); this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); @@ -48,6 +47,31 @@ this._textureAtlas.drawQuads(); }; + proto.visit = function(parentCmd){ + var _t = this, node = this._node; + // quick return if not visible + if (!node._visible) + return; + + parentCmd = parentCmd || this.getParentRenderCmd(); + if (node._parent && node._parent._renderCmd) + this._curLevel = node._parent._renderCmd._curLevel + 1; + + var currentStack = cc.current_stack; + + //optimize performance for javascript + currentStack.stack.push(currentStack.top); + _t._syncStatus(parentCmd); + currentStack.top = _t._stackMatrix; + + node.sortAllChildren(); + + cc.renderer.pushRenderCommand(this); + + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); + }; + proto.checkAtlasCapacity = function(index){ // make needed room var locCapacity = this._textureAtlas.capacity; diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 77f6c56d91..ff166c2a1a 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -37,6 +37,7 @@ }; this._blendFuncStr = "source-over"; this._colorized = false; + this._needSetBlend = false; this._originalTexture = null; }; @@ -46,6 +47,8 @@ proto._init = function () {}; + proto.setDirtyRecursively = function (value) {}; + proto._resetForBatchNode = function () {}; proto._setTexture = function (texture) { @@ -71,6 +74,7 @@ proto.updateBlendFunc = function (blendFunc) { this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(blendFunc); + this._needSetBlend = (this._blendFuncStr !== "source-over"); }; proto._setBatchNodeForAddChild = function (child) { @@ -108,14 +112,10 @@ node = self._node; var context = ctx || cc._renderContext, - locTextureCoord = self._textureCoord; - - if (node._texture && (locTextureCoord.width === 0 || locTextureCoord.height === 0)) - return; - if (!locTextureCoord.validRect && this._displayedOpacity === 0) - return; //draw nothing + locTextureCoord = self._textureCoord, alpha = (this._displayedOpacity / 255); - if (node._texture && !node._texture._isLoaded) //set texture but the texture isn't loaded. + if ((node._texture && ((locTextureCoord.width === 0 || locTextureCoord.height === 0) //set texture but the texture isn't loaded. + || !node._texture._isLoaded)) || alpha === 0) return; var t = this._worldTransform, @@ -125,15 +125,15 @@ locHeight = node._rect.height, image, curColor, contentSize; - var blendChange = (this._blendFuncStr !== "source-over"), alpha = (this._displayedOpacity / 255); + if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1 || node._flippedX || node._flippedY) { context.save(); - context.globalAlpha = alpha; + context.globalAlpha = alpha; //cache //transform - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - if (blendChange) + context.setTransform(t.a, t.c, t.b, t.d, t.tx * scaleX, (cc.view._visibleRect.height-t.ty) * scaleY); + if (this._needSetBlend) context.globalCompositeOperation = this._blendFuncStr; if (node._flippedX) { @@ -147,7 +147,6 @@ if (node._texture) { image = node._texture._htmlElementObj; - if (node._texture._pattern != "") { context.save(); context.fillStyle = context.createPattern(image, node._texture._pattern); @@ -188,7 +187,7 @@ } context.restore(); } else { - if (blendChange) { + if (this._needSetBlend) { context.save(); context.globalCompositeOperation = this._blendFuncStr; } @@ -234,7 +233,7 @@ context.fillRect((t.tx + locX) * scaleX, (-t.ty + locY) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } - if (blendChange) + if (this._needSetBlend) context.restore(); } cc.g_NumberOfDraws++; @@ -298,7 +297,7 @@ } }; - proto.updateTransform = function () { + proto.updateTransform = function () { //TODO need delete, because Canvas needn't var _t = this, node = this._node; // re-calculate matrix only if it is dirty diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 64483fda73..be303d477a 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -31,6 +31,8 @@ this._quad = new cc.V3F_C4B_T2F_Quad(); this._quadWebBuffer = cc._renderContext.createBuffer(); this._quadDirty = true; + this._dirty = false; + this._recursiveDirty = false; }; var proto = cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); @@ -38,6 +40,22 @@ proto.updateBlendFunc = function (blendFunc) {}; + proto.setDirtyFlag = function(dirtyFlag){ + cc.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); + this._dirty = true; + }; + + proto.setDirtyRecursively = function (value) { + this._recursiveDirty = value; + this._dirty = value; + // recursively set dirty + var locChildren = this._node._children, child, l = locChildren ? locChildren.length : 0; + for (var i = 0; i < l; i++) { + child = locChildren[i]; + (child instanceof cc.Sprite) && child.setDirtyRecursively(value); + } + }; + proto._setBatchNodeForAddChild = function (child) { var node = this._node; if (node._batchNode) { @@ -270,7 +288,7 @@ } else { // no need to set it recursively // update dirty_, don't update recursiveDirty_ - node.dirty = true; + this._dirty = true; } } // self render @@ -316,11 +334,11 @@ } }; - proto.updateTransform = function () { + proto.updateTransform = function () { //called only at batching. var _t = this, node = this._node; // recalculate matrix only if it is dirty - if (node.dirty) { + if (this._dirty) { var locQuad = _t._quad, locParent = node._parent; // If it is not visible, or one of its ancestors is not visible, then do nothing: if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { @@ -328,11 +346,14 @@ node._shouldBeHidden = true; } else { node._shouldBeHidden = false; + if(this._dirtyFlag !== 0){ //because changing color and opacity uses dirty flag at visit, but visit doesn't call at batching. + this.updateStatus(); + this._dirtyFlag = 0; + } if (!locParent || locParent == node._batchNode) { node._transformToBatch = _t.getNodeToParentTransform(); } else { - //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); } @@ -383,7 +404,7 @@ } node.textureAtlas.updateQuad(locQuad, node.atlasIndex); node._recursiveDirty = false; - node.dirty = false; + this._dirty = false; } // recursively iterate over children diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 81bfc0975f..f270679a0a 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1776,7 +1776,6 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ cc.pIn(tmp, selParticle.modeA.dir); cc.pMultIn(tmp, dt); cc.pAddIn(selParticle.pos, tmp); - } else { // Mode B: radius movement var selModeB = selParticle.modeB; diff --git a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js index d5bc45f10c..db201767bb 100644 --- a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js @@ -104,10 +104,10 @@ var quad = null, node = this._node; if (node._batchNode) { var batchQuads = node._batchNode.textureAtlas.quads; - quad = batchQuads[this.atlasIndex + particle.atlasIndex]; + quad = batchQuads[node.atlasIndex + particle.atlasIndex]; node._batchNode.textureAtlas.dirty = true; } else - quad = this._quads[this._particleIdx]; + quad = this._quads[node._particleIdx]; var r, g, b, a; if (node._opacityModifyRGB) { @@ -181,17 +181,17 @@ }; proto.rendering = function (ctx) { - var _t = this._node; - if (!_t._texture) + var node = this._node; + if (!node._texture) return; var gl = ctx || cc._renderContext; - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix);//setUniformForModelViewAndProjectionMatrixWithMat4(); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); //setUniformForModelViewAndProjectionMatrixWithMat4(); - cc.glBindTexture2D(_t._texture); - cc.glBlendFuncForParticle(_t._blendFunc.src, _t._blendFunc.dst); + cc.glBindTexture2D(node._texture); + cc.glBlendFuncForParticle(node._blendFunc.src, node._blendFunc.dst); // // Using VBO without VAO @@ -204,7 +204,7 @@ gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]); - gl.drawElements(gl.TRIANGLES, _t._particleIdx * 6, gl.UNSIGNED_SHORT, 0); + gl.drawElements(gl.TRIANGLES, node._particleIdx * 6, gl.UNSIGNED_SHORT, 0); }; proto.initTexCoordsWithRect = function(pointRect){ @@ -340,7 +340,7 @@ }; proto._allocMemory = function(){ - var node = this; + var node = this._node; //cc.assert((!this._quads && !this._indices), "Memory already allocated"); if(node._batchNode){ cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"); diff --git a/template/src/myApp.js b/template/src/myApp.js index 9136df3117..aa06d2f5e6 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -38,12 +38,17 @@ var MyLayer = cc.Layer.extend({ // add the label as a child to this layer this.addChild(this.helloLabel, 5); + var batchNode = new cc.SpriteBatchNode(s_HelloWorld, 5); + this.addChild(batchNode, 1); + // add "Helloworld" splash screen" this.sprite = new cc.Sprite(s_HelloWorld); this.sprite.setAnchorPoint(0.5, 0.5); + this.sprite.setColor(cc.color.RED); this.sprite.setPosition(size.width / 2, size.height / 2); - this.sprite.setScale(size.height/this.sprite.getContentSize().height); - this.addChild(this.sprite, 0); + this.sprite.setScale(size.height / this.sprite.getContentSize().height); + batchNode.addChild(this.sprite, 0); + window.sprite = this.sprite; } }); From fd2ebad2add580c8f725dfa8fd38cfde55210cb5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 28 Nov 2014 12:01:24 +0800 Subject: [PATCH 0986/1564] Issue #2416: update the dirty flag --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 4 ++-- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 640c95e0e9..b9c538aa9c 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -35,8 +35,8 @@ cc.CustomRenderCmd = function (target, func) { } }; - -cc.Node._dirtyFlags = {transformDirty: 1, visibleDirty: 2, colorDirty: 4, opacityDirty: 8, cacheDirty:16, orderDirty:32, textDirty:64}; +cc.Node._dirtyFlags = {transformDirty: 1 << 0, visibleDirty: 1 << 1, colorDirty: 1 << 2, opacityDirty: 1 << 3, cacheDirty: 1 << 4, + orderDirty: 1 << 5, textDirty: 1 << 6, all: (1 << 7) - 1}; //-------------------------Base ------------------------- cc.Node.RenderCmd = function(renderable){ diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index be303d477a..a968353696 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -68,6 +68,7 @@ //put it in descendants array of batch node node._batchNode.appendChild(child); + child._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); if (!node._reorderChildDirty) node._setReorderChildDirtyRecursively(); } From ab6accaf3f2bbcaba7aa73378e8ea9c8806754f0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 28 Nov 2014 14:21:36 +0800 Subject: [PATCH 0987/1564] Issue #2416: TileMap (unfinished) --- cocos2d/core/sprites/CCSpriteBatchNode.js | 2 +- cocos2d/tilemap/CCTMXLayer.js | 22 +--- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 104 +++++++++++-------- cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js | 14 ++- 4 files changed, 81 insertions(+), 61 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index bd9dc70ca3..1e1f0e324e 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -422,7 +422,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ // XXX: so, it should be AFTER the insertQuad sprite.dirty = true; sprite.updateTransform(); - sprite._setCachedParent(this); + sprite._renderCmd._setCachedParent(this); this._children.splice(index, 0, sprite); }, diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index e88aaf03ec..a98beed227 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -133,15 +133,14 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * @override * @param {CanvasRenderingContext2D} ctx */ - visit: function(ctx){ + visit: function(){ this._renderCmd.visit(); }, //set the cache dirty flag for canvas _setNodeDirtyForCache: function () { - this._cacheDirty = true; - if(cc.renderer._transformNodePool.indexOf(this) === -1) - cc.renderer.pushDirtyNode(this); + this._renderCmd._cacheDirty = true; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, /** @@ -599,18 +598,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ */ setupTiles:function () { // Optimization: quick hack that sets the image size on the tileset - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - this.tileset.imageSize = this._originalTexture.getContentSizeInPixels(); - } else { - this.tileset.imageSize = this.textureAtlas.texture.getContentSizeInPixels(); - - // By default all the tiles are aliased - // pros: - // - easier to render - // cons: - // - difficult to scale / rotate / etc. - this.textureAtlas.texture.setAliasTexParameters(); - } + this._renderCmd.initImageSize(); // Parse cocos2d properties this._parseInternalProperties(); @@ -889,7 +877,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ } } else { this._reusedTile = new cc.Sprite(); - this._reusedTile.initWithTexture(this._textureForCanvas, rect, false); + this._reusedTile.initWithTexture(this._renderCmd._texture, rect, false); this._reusedTile.batchNode = this; this._reusedTile.parent = this; this._reusedTile._cachedParent = this; diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index c8b54fbac3..bba2dfeb87 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -24,7 +24,7 @@ (function(){ cc.TMXLayer.CanvasRenderCmd = function(renderableObject){ - cc.Node.CanvasRenderCmd.call(this, renderableObject); + cc.SpriteBatchNode.CanvasRenderCmd.call(this, renderableObject); this._childrenRenderCmds = []; this._needDraw = true; @@ -40,9 +40,10 @@ this._cacheTexture = tempTexture; // This class uses cache, so its default cachedParent should be himself this._cachedParent = this; + this._cacheDirty = false; }; - var proto = cc.TMXLayer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + var proto = cc.TMXLayer.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype); proto.constructor = cc.TMXLayer.CanvasRenderCmd; proto._copyRendererCmds = function (rendererCmds) { @@ -57,29 +58,43 @@ }; proto._renderingChildToCache = function (scaleX, scaleY) { - var locNode = this._node; - if (locNode._cacheDirty) { - var locCacheCmds = this._childrenRenderCmds, locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas; - - locCacheContext.save(); - locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - //reset the cache context - var t = cc.affineTransformInvert(this._worldTransform); - locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - - for (var i = 0, len = locCacheCmds.length; i < len; i++) { - locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); - if (locCacheCmds[i]._node) - locCacheCmds[i]._node._cacheDirty = false; + if (this._cacheDirty) { +// var locCacheCmds = this._childrenRenderCmds, locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas; +// +// locCacheContext.save(); +// locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); +// //reset the cache context +// var t = cc.affineTransformInvert(this._worldTransform); +// locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); +// +// for (var i = 0, len = locCacheCmds.length; i < len; i++) { +// locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); +// if (locCacheCmds[i]) +// locCacheCmds[i]._cacheDirty = false; +// } +// locCacheContext.restore(); +// this._cacheDirty = false; + + var renderer = cc.renderer; + var node = this._node; + var instanceID = node.__instanceId; + var locChildren = node._children; + node.sortAllChildren(); + for (var i = 0, len = locChildren.length; i < len; i++) { + if (locChildren[i]){ + locChildren[i].visit(); + } } - locCacheContext.restore(); - locNode._cacheDirty = false; + + //copy cached render cmd array to TMXLayer renderer + node._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); + this._cacheDirty = false; } }; proto.rendering = function (ctx, scaleX, scaleY) { var node = this._node; - var alpha = node._displayedOpacity / 255; + var alpha = this._displayedOpacity / 255; if (alpha <= 0) return; @@ -156,7 +171,7 @@ return this._cacheTexture; }; - proto.visit = function(ctx){ + proto.visit = function(parentCmd){ var node = this._node; //TODO it will implement dynamic compute child cutting automation. var i, len, locChildren = node._children; @@ -167,35 +182,35 @@ if( node._parent) node._curLevel = node._parent._curLevel + 1; - node.transform(); + node.transform(node._parent && node._parent._renderCmd); - if (node._cacheDirty) { - var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view, - instanceID = node.__instanceId, renderer = cc.renderer; +// if (this._cacheDirty) { +// var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view, +// instanceID = node.__instanceId, renderer = cc.renderer; //begin cache - renderer._turnToCacheMode(instanceID); - - node.sortAllChildren(); - for (i = 0, len = locChildren.length; i < len; i++) { - if (locChildren[i]){ - locChildren[i].visit(); - locChildren[i]._cacheDirty = false; - } - } +// renderer._turnToCacheMode(instanceID); +// +// node.sortAllChildren(); +// for (i = 0, len = locChildren.length; i < len; i++) { +// if (locChildren[i]){ +// locChildren[i].visit(this); +// } +// } //copy cached render cmd array to TMXLayer renderer - node._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); +// node._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); - locCacheContext.save(); - locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); - var t = cc.affineTransformInvert(this._worldTransform); - locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); +// locCacheContext.save(); +// locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); +// var t = cc.affineTransformInvert(this._worldTransform); +// locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); //draw to cache canvas - renderer._renderingToCacheCanvas(locCacheContext, instanceID); - locCacheContext.restore(); - node._cacheDirty = false; - } +// renderer._renderingToCacheCanvas(locCacheContext, instanceID); +// locCacheContext.restore(); +// this._cacheDirty = false +// } + proto._renderingChildToCache(); cc.renderer.pushRenderCommand(node._renderCmd); }; @@ -237,4 +252,9 @@ this._node.width = locCanvas.width; this._node.height = locCanvas.height; }; + + proto.initImageSize = function(){ + var node = this._node; + node.tileset.imageSize = this._originalTexture.getContentSizeInPixels(); + } })(); \ No newline at end of file diff --git a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js index 0dadf059e4..94e49a5c12 100644 --- a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js @@ -24,7 +24,7 @@ (function(){ cc.TMXLayer.WebGLRenderCmd = function(renderableObject){ - cc.Node.WebGLRenderCmd.call(this, renderableObject); + cc.SpriteBatchNode.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; }; @@ -34,4 +34,16 @@ proto._updateCacheContext = function(){}; proto._initContentSize = function(){}; + + proto.initImageSize = function(){ + var node = this._node; + node.tileset.imageSize = this.textureAtlas.texture.getContentSizeInPixels(); + + // By default all the tiles are aliased + // pros: + // - easier to render + // cons: + // - difficult to scale / rotate / etc. + node.textureAtlas.texture.setAliasTexParameters(); + } })(); From 3f5b78c78cf2a79915b73db338477bdd402835a1 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 28 Nov 2014 14:27:10 +0800 Subject: [PATCH 0988/1564] Issue #2416: correct some mistakes of cc.SpriteBatchNode --- cocos2d/core/base-nodes/CCNode.js | 4 ++++ cocos2d/core/sprites/CCSpriteBatchNode.js | 4 +--- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 3 +-- template/src/myApp.js | 7 +------ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 0560462f31..8fa0a709fb 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1422,6 +1422,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ child._setLocalZOrder(z); }, + setNodeDirty: function(){ + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); + }, + /** Reorders a child according to a new z value.
    * The child MUST be already added. * @function diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index bd9dc70ca3..cb99445127 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -422,7 +422,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ // XXX: so, it should be AFTER the insertQuad sprite.dirty = true; sprite.updateTransform(); - sprite._setCachedParent(this); + //sprite._setCachedParent(this); this._children.splice(index, 0, sprite); }, @@ -629,9 +629,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ if (childrenArr.length > 0) { //first sort all children recursively based on zOrder this._arrayMakeObjectsPerformSelector(childrenArr, cc.Node._stateCallbackType.sortAllChildren); - this._renderCmd.updateChildrenAtlasIndex(childrenArr); - } this._reorderChildDirty = false; } diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index a968353696..1e0aaf0b3f 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -68,7 +68,6 @@ //put it in descendants array of batch node node._batchNode.appendChild(child); - child._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); if (!node._reorderChildDirty) node._setReorderChildDirtyRecursively(); } @@ -410,7 +409,7 @@ // recursively iterate over children if (node._hasChildren) - node._arrayMakeObjectsPerformSelector(_t._children, cc.Node._stateCallbackType.updateTransform); + node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); if (cc.SPRITE_DEBUG_DRAW) { // draw bounding box diff --git a/template/src/myApp.js b/template/src/myApp.js index aa06d2f5e6..f91b7c40af 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -38,17 +38,12 @@ var MyLayer = cc.Layer.extend({ // add the label as a child to this layer this.addChild(this.helloLabel, 5); - var batchNode = new cc.SpriteBatchNode(s_HelloWorld, 5); - this.addChild(batchNode, 1); - // add "Helloworld" splash screen" this.sprite = new cc.Sprite(s_HelloWorld); this.sprite.setAnchorPoint(0.5, 0.5); - this.sprite.setColor(cc.color.RED); this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); - batchNode.addChild(this.sprite, 0); - window.sprite = this.sprite; + this.addChild(this.sprite, 0); } }); From d99c6f94c92878d720f5d38c239a549f06c2b550 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 28 Nov 2014 15:10:04 +0800 Subject: [PATCH 0989/1564] Issue #2416: LabelTTF set color invalid --- cocos2d/core/labelttf/CCLabelTTF.js | 8 ++++++++ .../core/labelttf/CCLabelTTFCanvasRenderCmd.js | 16 +++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index c1e207b83a..a7b395d7e7 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -134,6 +134,14 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return true; }, + setColor: function(a, b, c, d){ + if(this._string === "MotionStreak Test"){ + void 0; + } + cc.Sprite.prototype.setColor.call(this, a, b, c, d); + this._renderCmd._setColorsString(); + }, + _setUpdateTextureDirty: function () { this._needUpdateTexture = true; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.textDirty); diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 11b4a02fde..effb02595d 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -54,6 +54,9 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; proto.constructor = cc.LabelTTF.RenderCmd; proto.updateStatus = function () { + if(this._node._string === "MotionStreak Test"){ + void 0; + } var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; if (locFlag & flags.colorDirty) { //update the color @@ -80,7 +83,8 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; if (locFlag & flags.colorDirty) { //update the color - this._syncDisplayColor() + this._syncDisplayColor(); + this._setColorsString(); } if (locFlag & flags.opacityDirty) { @@ -390,16 +394,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var proto = cc.LabelTTF.CanvasRenderCmd.prototype; proto.constructor = cc.LabelTTF.CanvasRenderCmd; - proto._updateDisplayedOpacity = function (parentOpacity) { - cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedOpacity.call(this, parentOpacity); - this._setColorsString(); - }; - - proto._updateDisplayedColor = function (parentColor) { - cc.Sprite.CanvasRenderCmd.prototype._updateDisplayedColor.call(this, parentColor); - this._setColorsString(); - }; - proto._setColorsString = function () { this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); From 43be3022911ea181322a18d4f2c0f4e70c65a937 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 28 Nov 2014 15:40:48 +0800 Subject: [PATCH 0990/1564] Issue #2416: Repair UILayout visit introduction parameters error --- extensions/ccui/layouts/UILayout.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 02298987a2..be2dfeb433 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -485,10 +485,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if(this._rendererSaveCmdSprite) cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite); - this._clippingStencil.visit(); + this._clippingStencil.visit(this._renderCmd); }else{ - this._clippingStencil.visit(context); + this._clippingStencil.visit(this._renderCmd); } if(this._rendererClipCmd) @@ -508,22 +508,22 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ for (i = 0; i < iLen; i++) { locChild = children[i]; if (locChild && locChild._localZOrder < 0) - locChild.visit(context); + locChild.visit(this._renderCmd); else break; } for (j = 0; j < jLen; j++) { locChild = locProtectChildren[j]; if (locChild && locChild._localZOrder < 0) - locChild.visit(context); + locChild.visit(this._renderCmd); else break; } //this.draw(context); for (; i < iLen; i++) - children[i].visit(context); + children[i].visit(this._renderCmd); for (; j < jLen; j++) - locProtectChildren[j].visit(context); + locProtectChildren[j].visit(this._renderCmd); if(this._rendererRestoreCmd) cc.renderer.pushRenderCommand(this._rendererRestoreCmd); From cb49edc6f1dfa54a8757cc0405c69ccff5937421 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 28 Nov 2014 17:49:08 +0800 Subject: [PATCH 0991/1564] Issue #2416: Repair UI setColor error --- .../ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js | 3 +-- extensions/ccui/uiwidgets/UIButton.js | 5 +++++ extensions/ccui/uiwidgets/UIText.js | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index ef87519717..b7c7783017 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -118,6 +118,5 @@ for( i = 0, len = locChildren.length; i< len; i++) locChildren[i]._renderCmd.transform(this); - } - + }; })(); \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 0512976a8f..e264f4245a 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -954,6 +954,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.setTitleColor(uiButton.getTitleColor()); this.setPressedActionEnabled(uiButton.pressedActionEnabled); this.setZoomScale(uiButton._zoomScale); + }, + + setColor: function(color){ + cc.ProtectedNode.prototype.setColor.call(this, color); + this._updateTexturesRGBA(); } }); diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 21323b0fae..fffd19f90a 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -437,6 +437,11 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ _changePosition: function(){ this._adaptRenderers(); //this._labelRenderer.transform(this._renderCmd); + }, + + setColor: function(color){ + cc.ProtectedNode.prototype.setColor.call(this, color); + this._labelRenderer.setColor(color); } }); From 0e32526fc7755465844340da97a24bd38f528cdb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 28 Nov 2014 18:11:35 +0800 Subject: [PATCH 0992/1564] Issue #2416: Remove test code --- cocos2d/core/labelttf/CCLabelTTF.js | 7 ++----- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index a7b395d7e7..30bc0eaac2 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -134,11 +134,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return true; }, - setColor: function(a, b, c, d){ - if(this._string === "MotionStreak Test"){ - void 0; - } - cc.Sprite.prototype.setColor.call(this, a, b, c, d); + setColor: function(color){ + cc.Sprite.prototype.setColor.call(this, color); this._renderCmd._setColorsString(); }, diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index effb02595d..dfc789a0cd 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -54,9 +54,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; proto.constructor = cc.LabelTTF.RenderCmd; proto.updateStatus = function () { - if(this._node._string === "MotionStreak Test"){ - void 0; - } var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; if (locFlag & flags.colorDirty) { //update the color From b004cbf5931ed8ec1937c30fbb5d25b6e3546045 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 29 Nov 2014 10:45:19 +0800 Subject: [PATCH 0993/1564] Issue #2416: modify cc.Node's updateStatus and syncStatus --- cocos2d/core/base-nodes/CCAtlasNode.js | 9 --- .../base-nodes/CCAtlasNodeWebGLRenderCmd.js | 19 +++-- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 19 ++--- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 20 ++++-- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 32 --------- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 39 ----------- cocos2d/core/sprites/CCSprite.js | 6 +- .../core/sprites/CCSpriteWebGLRenderCmd.js | 70 +++++-------------- cocos2d/labels/CCLabelAtlas.js | 9 --- cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js | 5 -- 10 files changed, 54 insertions(+), 174 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 290822e728..45a8b99e3a 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -220,15 +220,6 @@ cc.AtlasNode = cc.Node.extend(/** @lends cc.AtlasNode# */{ return this._renderCmd.initWithTexture(texture, tileWidth, tileHeight, itemsToRender); }, - /** - * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function - * @function - * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context - */ - draw: function(ctx){ - this._renderCmd.draw(ctx); - }, - /** * Set node's color * @function diff --git a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js index e9bfde7295..4e6a863ac6 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js @@ -95,18 +95,15 @@ }; proto.setColor = function(color3){ - var temp = cc.color(color3.r, color3.g, color3.b); + var temp = cc.color(color3.r, color3.g, color3.b), node = this._node; this._colorUnmodified = color3; var locDisplayedOpacity = this._displayedOpacity; - if (this._opacityModifyRGB) { + if (node._opacityModifyRGB) { temp.r = temp.r * locDisplayedOpacity / 255; temp.g = temp.g * locDisplayedOpacity / 255; temp.b = temp.b * locDisplayedOpacity / 255; } - cc.Node.prototype.setColor.call(this, color3); - var locDisplayedColor = this._displayedColor; - this._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, - locDisplayedColor.b / 255.0, locDisplayedOpacity / 255.0]); + cc.Node.prototype.setColor.call(node, temp); }; proto.setOpacity = function(opacity){ @@ -115,13 +112,15 @@ // special opacity for premultiplied textures if (node._opacityModifyRGB) { node.color = this._colorUnmodified; - } else { - var locDisplayedColor = this._displayedColor; - node._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, - locDisplayedColor.b / 255.0, node._displayedOpacity / 255.0]); } }; + proto._updateColor = function(){ + var locDisplayedColor = this._displayedColor; + this._colorF32Array = new Float32Array([locDisplayedColor.r / 255.0, locDisplayedColor.g / 255.0, + locDisplayedColor.b / 255.0, this._displayedOpacity / 255.0]); + }; + proto.getTexture = function(){ return this._textureAtlas.texture; }; diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index b9c538aa9c..80105a0521 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -209,19 +209,22 @@ cc.Node.RenderCmd.prototype = { this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; }, + _updateColor: function(){}, + updateStatus: function () { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color - this._updateDisplayColor() - } + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if(colorDirty) + this._updateDisplayColor(); - if (locFlag & flags.opacityDirty) { - //update the opacity + if(opacityDirty) this._updateDisplayOpacity(); - } - if (locFlag & flags.transformDirty) { + if(colorDirty || opacityDirty) + this._updateColor(); + + if(this._dirtyFlag & flags.transformDirty){ //update the transform this.transform(this.getParentRenderCmd(), true); } diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index d33d0c0924..e0f1afb557 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -114,20 +114,26 @@ proto._syncStatus = function (parentCmd) { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; - if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) - locFlag |= flags.transformDirty; + if (colorDirty) + this._syncDisplayColor(); - if (locFlag & flags.colorDirty) - this._syncDisplayColor() - - if (locFlag & flags.opacityDirty) + if (opacityDirty) this._syncDisplayOpacity(); - if (locFlag & flags.transformDirty) + if(colorDirty || opacityDirty) + this._updateColor(); + + if (locFlag & flags.transformDirty) { + //update the transform this.transform(parentCmd); + } }; + proto._updateColor = function(){}; + proto.visit = function (parentCmd) { var _t = this, node = this._node; // quick return if not visible diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 8aaaf325bc..7976e6203a 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -394,38 +394,6 @@ this._updateColor(); }; - proto._updateDisplayColor = function(parentColor){ - cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._updateColor(); - }; - - proto._updateDisplayOpacity = function(parentOpacity){ - cc.Node.CanvasRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity); - this._updateColor(); - }; - - proto._syncStatus = function(parentCmd){ - var colorDirty = this._dirtyFlag & cc.Node._dirtyFlags.colorDirty, - opacityDirty = this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty; - if(colorDirty){ - //update the color - this._syncDisplayColor() - } - - if(opacityDirty){ - //update the opacity - this._syncDisplayOpacity(); - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ - //update the transform - this.transform(parentCmd); - } - - if(colorDirty || opacityDirty) - this._updateColor(); - }; - proto._updateColor = function(){ var node = this._node; var contentSize = node._contentSize; diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index 1418c2eaa1..fb073f65e2 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -126,45 +126,6 @@ this._bindLayerVerticesBufferData(); }; - proto._syncStatus = function (parentCmd) { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - var colorDirty = locFlag & flags.colorDirty, - opacityDirty = locFlag & flags.opacityDirty; - - if (colorDirty) - this._syncDisplayColor(); - - if (opacityDirty) - this._syncDisplayOpacity(); - - if(colorDirty || opacityDirty) - this._updateColor(); - - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(parentCmd); - } - }; - - proto.updateStatus = function(){ - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - var colorDirty = locFlag & flags.colorDirty, - opacityDirty = locFlag & flags.opacityDirty; - if(colorDirty) - this._updateDisplayColor(); - - if(opacityDirty) - this._updateDisplayOpacity(); - - if(colorDirty || opacityDirty) - this._updateColor(); - - if(this._dirtyFlag & flags.transformDirty){ - //update the transform - this.transform(null, true); - } - }; - proto._updateColor = function(){ var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity, locSquareColors = this._squareColors; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index d88eefb017..4e2c47ba29 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -431,7 +431,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if (this._flippedX != flippedX) { this._flippedX = flippedX; this.setTextureRect(this._rect, this._rectRotated, this._contentSize); - //TODO + this.setNodeDirty(true); } }, @@ -443,7 +443,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if (this._flippedY != flippedY) { this._flippedY = flippedY; this.setTextureRect(this._rect, this._rectRotated, this._contentSize); - //TODO + this.setNodeDirty(true); } }, @@ -825,7 +825,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ cc.assert(newFrame, cc._LogInfos.Sprite_setSpriteFrame) } - //TODO set dirty flag + this.setNodeDirty(true) var frameOffset = newFrame.getOffset(); _t._unflippedOffsetPositionFromCenter.x = frameOffset.x; diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 1e0aaf0b3f..f9a523a9b0 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -52,7 +52,7 @@ var locChildren = this._node._children, child, l = locChildren ? locChildren.length : 0; for (var i = 0; i < l; i++) { child = locChildren[i]; - (child instanceof cc.Sprite) && child.setDirtyRecursively(value); + (child instanceof cc.Sprite) && child._renderCmd.setDirtyRecursively(value); } }; @@ -227,55 +227,21 @@ this._quadDirty = true; }; - proto._syncStatus = function (parentCmd) { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - var colorDirty = locFlag & flags.colorDirty, - opacityDirty = locFlag & flags.opacityDirty; - - if (colorDirty) - this._syncDisplayColor(); - - if (opacityDirty) - this._syncDisplayOpacity(); - - if(colorDirty || opacityDirty) - this._updateColor(); - - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(parentCmd); - } - }; - - proto.updateStatus = function(){ - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - var colorDirty = locFlag & flags.colorDirty, - opacityDirty = locFlag & flags.opacityDirty; - if(colorDirty) - this._updateDisplayColor(); - - if(opacityDirty) - this._updateDisplayOpacity(); - - if(colorDirty || opacityDirty) - this._updateColor(); - - if(this._dirtyFlag & flags.transformDirty){ - //update the transform - this.transform(null, true); - } + proto.transform = function(parentCmd, recursive){ + cc.Node.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); + this._dirty = true; //use for batching }; proto._updateColor = function () { - var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity; + var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity, node = this._node; var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; // special opacity for premultiplied textures - if (this._opacityModifyRGB) { + if (node._opacityModifyRGB) { color4.r *= locDisplayedOpacity / 255.0; color4.g *= locDisplayedOpacity / 255.0; color4.b *= locDisplayedOpacity / 255.0; } - var locQuad = this._quad, node = this._node; + var locQuad = this._quad; locQuad.bl.colors = color4; locQuad.br.colors = color4; locQuad.tl.colors = color4; @@ -443,11 +409,11 @@ }; proto.rendering = function (ctx) { - var _t = this._node; - if (!_t._textureLoaded || this._displayedOpacity === 0) + var node = this._node; + if (!node._textureLoaded || this._displayedOpacity === 0) return; - var gl = ctx || cc._renderContext, locTexture = _t._texture; + var gl = ctx || cc._renderContext, locTexture = node._texture; //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); if (locTexture) { @@ -455,7 +421,7 @@ this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); //optimize performance for javascript cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); @@ -472,9 +438,9 @@ } } else { this._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); cc.glBindTexture2D(null); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); @@ -490,12 +456,12 @@ } cc.g_NumberOfDraws++; - if (cc.SPRITE_DEBUG_DRAW === 0 && !_t._showNode) + if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode) return; - if (cc.SPRITE_DEBUG_DRAW === 1 || _t._showNode) { + if (cc.SPRITE_DEBUG_DRAW === 1 || node._showNode) { // draw bounding box - var locQuad = _t._quad; + var locQuad = node._quad; var verticesG1 = [ cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), @@ -505,8 +471,8 @@ cc._drawingUtil.drawPoly(verticesG1, 4, true); } else if (cc.SPRITE_DEBUG_DRAW === 2) { // draw texture box - var drawRectG2 = _t.getTextureRect(); - var offsetPixG2 = _t.getOffsetPosition(); + var drawRectG2 = node.getTextureRect(); + var offsetPixG2 = node.getOffsetPosition(); var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; cc._drawingUtil.drawPoly(verticesG2, 4, true); diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 746210379a..9864ace3a7 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -201,15 +201,6 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ this._renderCmd.updateAtlasValues(); this.quadsToDraw = len; - }, - - /** - * set the opacity - * @function - * @param {Number} opacity - */ - setOpacity: function(opacity){ - this._renderCmd.setOpacity(opacity); } }); diff --git a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js index 315d542ceb..ef548032e3 100644 --- a/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js @@ -128,10 +128,5 @@ this._textureAtlas.resizeCapacity(len); }; - proto.setOpacity = function(opacity){ - if (this._opacity !== opacity) - cc.AtlasNode.prototype.setOpacity.call(this, opacity); - }; - proto._addChild = function(){}; })(); \ No newline at end of file From e7d9f14152e1134d5f703dc32bddcc8fe3ddd41b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 29 Nov 2014 14:20:33 +0800 Subject: [PATCH 0994/1564] Issue #2416: correct a mistake of cc.SpriteBatchNode and LabelBMFont --- cocos2d/core/sprites/CCSpriteBatchNode.js | 1 + cocos2d/labels/CCLabelBMFont.js | 202 ++---------------- cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js | 17 +- template/src/myApp.js | 9 +- 4 files changed, 37 insertions(+), 192 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 0a1a245e17..496e115eb8 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -648,6 +648,7 @@ var _p = cc.SpriteBatchNode.prototype; // Override properties cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); +cc.defineGetterSetter(_p, "textureAtlas", _p.getTextureAtlas, _p.setTextureAtlas); // Extended properties /** @expose */ diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index d02d55ab55..7f0e9ecdeb 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -86,11 +86,9 @@ cc.LABEL_AUTOMATIC_WIDTH = -1; * var label3 = new cc.LabelBMFont("This is a \n test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT, cc.p(0,0)); */ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ - //property string is Getter and Setter. //property textAlign is Getter and Setter. //property boundingWidth is Getter and Setter. - _opacityModifyRGB: false, _string: "", @@ -112,17 +110,16 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ _reusedChar: null, - //texture RGBA - _displayedOpacity: 255, - _realOpacity: 255, - _displayedColor: null, - _realColor: null, - _cascadeColorEnabled: true, - _cascadeOpacityEnabled: true, - _textureLoaded: false, _className: "LabelBMFont", + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + return new cc.LabelBMFont.WebGLRenderCmd(this); + else + return new cc.LabelBMFont.CanvasRenderCmd(this); + }, + _setString: function (newString, needUpdateLabel) { if (!needUpdateLabel) { this._string = newString; @@ -139,19 +136,11 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } if (this._textureLoaded) { this.createFontChars(); - if (needUpdateLabel) this.updateLabel(); } }, - _createRenderCmd: function(){ - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - return new cc.LabelBMFont.WebGLRenderCmd(this); - else - return new cc.LabelBMFont.CanvasRenderCmd(this); - }, - /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
    * creates a bitmap font atlas with an initial string and the FNT file. @@ -162,13 +151,11 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ * @param {cc.Point} [imageOffset=cc.p(0,0)] */ ctor: function (str, fntFile, width, alignment, imageOffset) { - var self = this; - cc.SpriteBatchNode.prototype.ctor.call(self); - self._imageOffset = cc.p(0, 0); - self._displayedColor = cc.color(255, 255, 255, 255); - self._realColor = cc.color(255, 255, 255, 255); - self._reusedChar = []; - + cc.SpriteBatchNode.prototype.ctor.call(this); + this._imageOffset = cc.p(0, 0); + this._reusedChar = []; + this._cascadeColorEnabled = true; + this._cascadeOpacityEnabled = true; this.initWithString(str, fntFile, width, alignment, imageOffset); }, @@ -191,46 +178,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this.addEventListener("load", callback, target); }, - /** - * Draw this font. - * @param {CanvasRenderingContext2D} ctx - */ - draw: function (ctx) { - cc.SpriteBatchNode.prototype.draw.call(this, ctx); - - //LabelBMFont - Debug draw - if (cc.LABELBMFONT_DEBUG_DRAW) { - var size = this.getContentSize(); - var pos = cc.p(0 | ( -this._anchorPointInPoints.x), 0 | ( -this._anchorPointInPoints.y)); - var vertices = [cc.p(pos.x, pos.y), cc.p(pos.x + size.width, pos.y), cc.p(pos.x + size.width, pos.y + size.height), cc.p(pos.x, pos.y + size.height)]; - cc._drawingUtil.setDrawColor(0, 255, 0, 255); - cc._drawingUtil.drawPoly(vertices, 4, true); - } - }, - - /** - * tint this label - * @param {cc.Color} color - */ - setColor: function (color) { - var locDisplayed = this._displayedColor, locRealColor = this._realColor; - if ((locRealColor.r == color.r) && (locRealColor.g == color.g) && (locRealColor.b == color.b) && (locRealColor.a == color.a)) - return; - locDisplayed.r = locRealColor.r = color.r; - locDisplayed.g = locRealColor.g = color.g; - locDisplayed.b = locRealColor.b = color.b; - - if (this._textureLoaded) { - if (this._cascadeColorEnabled) { - var parentColor = cc.color.WHITE; - var locParent = this._parent; - if (locParent && locParent.cascadeColor) - parentColor = locParent.getDisplayedColor(); - this.updateDisplayedColor(parentColor); - } - } - }, - /** * Conforms to cc.RGBAProtocol protocol. * @return {Boolean} @@ -255,129 +202,10 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } }, - /** - * Gets the real opacity. - * @returns {number} - */ - getOpacity: function () { - return this._realOpacity; - }, - - /** - * Gets the display opacity. - * @returns {number} - */ - getDisplayedOpacity: function () { - return this._displayedOpacity; - }, - - /** - * Override synthesized setOpacity to recurse items - * @param {Number} opacity - */ - setOpacity: function (opacity) { - this._displayedOpacity = this._realOpacity = opacity; - if (this._cascadeOpacityEnabled) { - var parentOpacity = 255; - var locParent = this._parent; - if (locParent && locParent.cascadeOpacity) - parentOpacity = locParent.getDisplayedOpacity(); - this.updateDisplayedOpacity(parentOpacity); - } - - this._displayedColor.a = this._realColor.a = opacity; - }, - - /** - * Override synthesized update pacity to recurse items - * @param parentOpacity - */ - updateDisplayedOpacity: function (parentOpacity) { - var cmd = this._renderCmd; - cmd._displayedOpacity = this._realOpacity * parentOpacity / 255.0; -// var locChildren = this._children; -// for (var i = 0; i < locChildren.length; i++) { -// cmd._updateChildrenDisplayedOpacity(locChildren[i]); -// } -// this._changeTextureColor(); - }, - - /** - * Checking cascade opacity enabled - * @returns {boolean} - */ - isCascadeOpacityEnabled: function () { - return false; - }, - - /** - * Set cascade opacity enabled - * @param {Boolean} cascadeOpacityEnabled - */ - setCascadeOpacityEnabled: function (cascadeOpacityEnabled) { - this._cascadeOpacityEnabled = cascadeOpacityEnabled; - }, - - /** - * Gets the real color.
    - * Create a new cc.Color clone in this real color. - * @returns {cc.Color} - */ - getColor: function () { - var locRealColor = this._realColor; - return cc.color(locRealColor.r, locRealColor.g, locRealColor.b, locRealColor.a); - }, - - /** - * Gets the display color.
    - * Create a new cc.Color clone in this display color. - * @returns {cc.Color} - */ - getDisplayedColor: function () { - var dc = this._displayedColor; - return cc.color(dc.r, dc.g, dc.b, dc.a); - }, - - /** - * Update the display color.
    - * Only update this label display color. - * @returns {cc.Color} - */ - updateDisplayedColor: function (parentColor) { - var cmd = this._renderCmd; - var locDispColor = cmd._displayedColor; - var locRealColor = this._realColor; - locDispColor.r = locRealColor.r * parentColor.r / 255.0; - locDispColor.g = locRealColor.g * parentColor.g / 255.0; - locDispColor.b = locRealColor.b * parentColor.b / 255.0; - -// var locChildren = this._children; -// for (var i = 0; i < locChildren.length; i++) { -// cmd._updateChildrenDisplayedColor(locChildren[i]); -// } -// this._changeTextureColor(); - }, - _changeTextureColor: function () { this._renderCmd._changeTextureColor(); }, - /** - * Checking cascade color enabled - * @returns {boolean} - */ - isCascadeColorEnabled: function () { - return false; - }, - - /** - * Override synthesized setOpacity to recurse items - * @param {Boolean} cascadeColorEnabled - */ - setCascadeColorEnabled: function (cascadeColorEnabled) { - this._cascadeColorEnabled = cascadeColorEnabled; - }, - /** * Initialization of the node, please do not call this function by yourself, you should pass the parameters to constructor to initialize it
. */ @@ -401,7 +229,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ if (self._config) cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported"); - var texture; if (fntFile) { var newConf = cc.loader.getRes(fntFile); @@ -437,11 +264,8 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ self._imageOffset = imageOffset || cc.p(0, 0); self._width = (width == null) ? -1 : width; - cmd._displayedOpacity = self._realOpacity = 255; - cmd._displayedColor = cc.color(255, 255, 255, 255); + self._realOpacity = 255; self._realColor = cc.color(255, 255, 255, 255); - this._cascadeColorEnabled = true; - this._cascadeOpacityEnabled = true; self._contentSize.width = 0; self._contentSize.height = 0; diff --git a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js index e8032f17a2..57fe3e5ecf 100644 --- a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js @@ -33,7 +33,7 @@ (function(){ cc.LabelBMFont.WebGLRenderCmd = function(renderableObject){ cc.SpriteBatchNode.WebGLRenderCmd.call(this, renderableObject); - this._needDraw = false; + this._needDraw = true; }; var proto = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); @@ -62,7 +62,7 @@ locChild.updateDisplayedOpacity(this._displayedOpacity); }; - proto._updateChildrenDisplayedOpacity = function(locChild){ + proto._updateChildrenDisplayedColor = function(locChild){ locChild.updateDisplayedColor(this._displayedColor); }; @@ -76,4 +76,17 @@ reusedChar.batchNode = node; }; + proto.rendering = function(ctx){ + cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering.call(this, ctx); + + var node = this._node; + //LabelBMFont - Debug draw + if (cc.LABELBMFONT_DEBUG_DRAW) { + var size = node.getContentSize(); + var pos = cc.p(0 | ( -this._anchorPointInPoints.x), 0 | ( -this._anchorPointInPoints.y)); + var vertices = [cc.p(pos.x, pos.y), cc.p(pos.x + size.width, pos.y), cc.p(pos.x + size.width, pos.y + size.height), cc.p(pos.x, pos.y + size.height)]; + cc._drawingUtil.setDrawColor(0, 255, 0, 255); + cc._drawingUtil.drawPoly(vertices, 4, true); + } + }; })(); \ No newline at end of file diff --git a/template/src/myApp.js b/template/src/myApp.js index f91b7c40af..99d38b1b1b 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -38,12 +38,19 @@ var MyLayer = cc.Layer.extend({ // add the label as a child to this layer this.addChild(this.helloLabel, 5); + var batchNode = new cc.SpriteBatchNode(s_HelloWorld); + this.addChild(batchNode,0); + // add "Helloworld" splash screen" this.sprite = new cc.Sprite(s_HelloWorld); this.sprite.setAnchorPoint(0.5, 0.5); this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); - this.addChild(this.sprite, 0); + //this.addChild(this.sprite, 0); + batchNode.addChild(this.sprite, 0); + batchNode.setColor(cc.color.RED); + batchNode.setCascadeColorEnabled(true); + window.batchNode = batchNode; } }); From 72efc572357fe758d7b2e14cad8e0f4a672d6c8d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 29 Nov 2014 14:44:24 +0800 Subject: [PATCH 0995/1564] Issue #2416: Repair Node status update error --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 19 ++++--- .../gui/control-extension/CCScale9Sprite.js | 48 ------------------ .../CCScale9SpriteCanvasRenderCmd.js | 50 ++++++++++++++++++- 3 files changed, 60 insertions(+), 57 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 80105a0521..8031503b23 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -418,20 +418,25 @@ cc.Node.RenderCmd.prototype = { if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) locFlag |= flags.transformDirty; - if (locFlag & flags.colorDirty) { + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty, + transformDirty = locFlag & flags.transformDirty; + + if (colorDirty) //update the color - this._syncDisplayColor() - } + this._syncDisplayColor(); - if (locFlag & flags.opacityDirty) { + if (opacityDirty) //update the opacity this._syncDisplayOpacity(); - } - if (locFlag & flags.transformDirty) { + if(colorDirty) + this._updateColor(); + + if (transformDirty) //update the transform this.transform(parentCmd); - } + }; proto._syncDisplayColor = function (parentColor) { diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 6fbfcc9eba..10f9875903 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -64,7 +64,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ //cache in canvas on Canvas mode _cacheSprite: null, - _cacheCanvas: null, _cacheContext: null, _cacheTexture: null, _scale9Dirty: true, @@ -195,38 +194,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ locCenter.setPosition(leftWidth, bottomHeight); }, - _cacheScale9Sprite: function(){ - if(!this._scale9Image) - return; - - var locScaleFactor = cc.contentScaleFactor(); - var size = this._contentSize; - var sizeInPixels = cc.size(size.width * locScaleFactor, size.height * locScaleFactor); - - var locCanvas = this._cacheCanvas; - var contentSizeChanged = false; - if(locCanvas.width != sizeInPixels.width || locCanvas.height != sizeInPixels.height){ - locCanvas.width = sizeInPixels.width; - locCanvas.height = sizeInPixels.height; - this._cacheContext.translate(0, sizeInPixels.height); - contentSizeChanged = true; - } - - //begin cache - cc.renderer._turnToCacheMode(this.__instanceId); - this._scale9Image.visit(); - - //draw to cache canvas - this._cacheContext.clearRect(0, 0, sizeInPixels.width, -sizeInPixels.height); - cc.renderer._renderingToCacheCanvas(this._cacheContext, this.__instanceId, locScaleFactor, locScaleFactor); - - if(contentSizeChanged) - this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); - - if(!this._cacheSprite.getParent()) - this.addChild(this._cacheSprite, -1); - }, - /** * Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @function @@ -244,21 +211,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._preferredSize = cc.size(0, 0); this._capInsets = cc.rect(0, 0, 0, 0); - //cache - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - - var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); - locCacheCanvas.width = 1; - locCacheCanvas.height = 1; - this._cacheContext = locCacheCanvas.getContext("2d"); - var locTexture = this._cacheTexture = new cc.Texture2D(); - locTexture.initWithElement(locCacheCanvas); - locTexture.handleLoadedTexture(); - this._cacheSprite = new cc.Sprite(locTexture); - this._cacheSprite.setAnchorPoint(0,0); - this.addChild(this._cacheSprite); - } - if(file != undefined){ if(file instanceof cc.SpriteFrame) this.initWithSpriteFrame(file, rect); diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js index 2d794fc111..75573a0454 100644 --- a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -27,6 +27,18 @@ cc.Node.CanvasRenderCmd.call(this, renderable); this._cachedParent = null; this._cacheDirty = false; + + var node = this._node; + var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); + locCacheCanvas.width = 1; + locCacheCanvas.height = 1; + this._cacheContext = locCacheCanvas.getContext("2d"); + var locTexture = this._cacheTexture = new cc.Texture2D(); + locTexture.initWithElement(locCacheCanvas); + locTexture.handleLoadedTexture(); + this._cacheSprite = new cc.Sprite(locTexture); + this._cacheSprite.setAnchorPoint(0,0); + node.addChild(this._cacheSprite); }; var proto = cc.Scale9Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); @@ -44,14 +56,14 @@ node._scale9Dirty = true; } node._scale9Dirty = false; - node._cacheScale9Sprite(); + this._cacheScale9Sprite(); cc.Node.CanvasRenderCmd.prototype.visit.call(this, ctx); }; proto.transform = function(parentCmd){ var node = this._node; - node._cacheScale9Sprite(); + this._cacheScale9Sprite(); cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); var children = node._children; @@ -60,4 +72,38 @@ } }; + proto._cacheScale9Sprite = function(){ + var node = this._node; + if(!node._scale9Image) + return; + + var locScaleFactor = cc.contentScaleFactor(); + var size = node._contentSize; + var sizeInPixels = cc.size(size.width * locScaleFactor, size.height * locScaleFactor); + + var locCanvas = this._cacheCanvas; + + var contentSizeChanged = false; + if(locCanvas.width != sizeInPixels.width || locCanvas.height != sizeInPixels.height){ + locCanvas.width = sizeInPixels.width; + locCanvas.height = sizeInPixels.height; + this._cacheContext.translate(0, sizeInPixels.height); + contentSizeChanged = true; + } + + //begin cache + cc.renderer._turnToCacheMode(node.__instanceId); + node._scale9Image.visit(); + + //draw to cache canvas + this._cacheContext.clearRect(0, 0, sizeInPixels.width, -sizeInPixels.height); + cc.renderer._renderingToCacheCanvas(this._cacheContext, node.__instanceId, locScaleFactor, locScaleFactor); + + if(contentSizeChanged) + this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); + + if(!this._cacheSprite.getParent()) + node.addChild(this._cacheSprite, -1); + }; + })(); \ No newline at end of file From a9bdca901fc1ca5b47058c76beaf1b373bd1833b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 29 Nov 2014 16:04:18 +0800 Subject: [PATCH 0996/1564] Issue #2416: correct LabelBMFont's mistake --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 12 ++++++++---- .../core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js | 7 +++++-- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 2 +- cocos2d/labels/CCLabelBMFont.js | 1 - cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js | 8 -------- cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js | 7 ------- template/src/myApp.js | 10 ++-------- 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 80105a0521..85649209ee 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -141,8 +141,10 @@ cc.Node.RenderCmd.prototype = { selChildren = node._children; for (i = 0, len = selChildren.length; i < len; i++) { item = selChildren[i]; - if (item && item._renderCmd) + if (item && item._renderCmd){ item._renderCmd._updateDisplayColor(locDispColor); + item._renderCmd._updateColor(); + } } } } @@ -169,12 +171,14 @@ cc.Node.RenderCmd.prototype = { parentOpacity = locParent.getDisplayedOpacity(); } this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - if (this._cascadeOpacityEnabled) { - selChildren = this._children; + if (node._cascadeOpacityEnabled) { + selChildren = node._children; for (i = 0, len = selChildren.length; i < len; i++) { item = selChildren[i]; - if (item && item._renderCmd) + if (item && item._renderCmd){ item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + item._renderCmd._updateColor(); + } } } } diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 53f621af11..7e12138597 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -47,13 +47,16 @@ this._textureAtlas.drawQuads(); }; + proto.updateStatus = function(){ + cc.Node.WebGLRenderCmd.prototype.updateStatus.call(this); + }; + proto.visit = function(parentCmd){ var _t = this, node = this._node; // quick return if not visible if (!node._visible) return; - parentCmd = parentCmd || this.getParentRenderCmd(); if (node._parent && node._parent._renderCmd) this._curLevel = node._parent._renderCmd._curLevel + 1; @@ -61,7 +64,7 @@ //optimize performance for javascript currentStack.stack.push(currentStack.top); - _t._syncStatus(parentCmd); + _t.updateStatus(); //because batchNode doesn't visit its children. currentStack.top = _t._stackMatrix; node.sortAllChildren(); diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index f9a523a9b0..302ae66476 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -461,7 +461,7 @@ if (cc.SPRITE_DEBUG_DRAW === 1 || node._showNode) { // draw bounding box - var locQuad = node._quad; + var locQuad = this._quad; var verticesG1 = [ cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 7f0e9ecdeb..ea4bbe45dd 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -348,7 +348,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ // Apply label properties fontChar.opacityModifyRGB = this._opacityModifyRGB; - this._renderCmd._updateCharColorAndOpacity(fontChar); var yOffset = locCfg.commonHeight - fontDef.yOffset; var fontPos = cc.p(nextFontPositionX + fontDef.xOffset + fontDef.rect.width * 0.5 + kerningAmount, diff --git a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js index d091f21175..68b035fe8f 100644 --- a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js @@ -54,14 +54,6 @@ } }; - proto._updateCharColorAndOpacity = function(fontChar){ - // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on -// cc.Node.prototype.updateDisplayedColor.call(fontChar, this._displayedColor); -// cc.Node.prototype.updateDisplayedOpacity.call(fontChar, this._displayedOpacity); - fontChar.updateDisplayedColor(this._displayedColor); - fontChar.updateDisplayedOpacity(this._displayedOpacity); - }; - proto._updateFntFileTexture = function(){ var node = this._node; node._originalTexture = node.texture; diff --git a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js index 57fe3e5ecf..87461ec8da 100644 --- a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js @@ -46,16 +46,9 @@ fontChar.visible = true; }; - proto._updateCharColorAndOpacity = function(fontChar){ - // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on - fontChar.updateDisplayedColor(this._displayedColor); - fontChar.updateDisplayedOpacity(this._displayedOpacity); - }; proto._updateFntFileTexture = function(){}; - proto.setTexture = cc.SpriteBatchNode.prototype.setTexture; - proto._changeTextureColor = function(){}; proto._updateChildrenDisplayedOpacity = function(locChild){ diff --git a/template/src/myApp.js b/template/src/myApp.js index 99d38b1b1b..a706995ea1 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -38,19 +38,13 @@ var MyLayer = cc.Layer.extend({ // add the label as a child to this layer this.addChild(this.helloLabel, 5); - var batchNode = new cc.SpriteBatchNode(s_HelloWorld); - this.addChild(batchNode,0); - // add "Helloworld" splash screen" this.sprite = new cc.Sprite(s_HelloWorld); this.sprite.setAnchorPoint(0.5, 0.5); this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); - //this.addChild(this.sprite, 0); - batchNode.addChild(this.sprite, 0); - batchNode.setColor(cc.color.RED); - batchNode.setCascadeColorEnabled(true); - window.batchNode = batchNode; + this.addChild(this.sprite, 0); + } }); From 679d3b594aa5f9825b23ff1af534ce1564ac0a5f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 29 Nov 2014 17:57:10 +0800 Subject: [PATCH 0997/1564] Issue #2416: Repair _cachedParent error --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 2 ++ cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 2 -- cocos2d/core/sprites/CCSpriteBatchNode.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 8031503b23..8601170c0c 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -469,6 +469,8 @@ cc.Node.RenderCmd.prototype = { proto.setDirtyFlag = function (dirtyFlag) { cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); this._setCacheDirty(); + if(this._cachedParent) + this._cachedParent.setDirtyFlag(dirtyFlag); }; proto._setCacheDirty = function () { diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 7976e6203a..ff140a8ce7 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -49,7 +49,6 @@ //limit: 1. its children's blendfunc are invalid. this._isBaked = this._cacheDirty = true; - this._cachedParent = this; var children = this._node._children; for(var i = 0, len = children.length; i < len; i++) children[i]._renderCmd._setCachedParent(this); @@ -68,7 +67,6 @@ this._isBaked = false; this._cacheDirty = true; - this._cachedParent = null; var children = this._node._children; for(var i = 0, len = children.length; i < len; i++) children[i]._renderCmd._setCachedParent(null); diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 0a1a245e17..bd9d367e62 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -423,7 +423,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ sprite.dirty = true; sprite.updateTransform(); - sprite._renderCmd._setCachedParent(this); + sprite._renderCmd._setCachedParent(this._renderCmd); this._children.splice(index, 0, sprite); }, From a7e85aedc596e8dfc1a4042d2fb60e82a8c6d7ab Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 1 Dec 2014 09:32:18 +0800 Subject: [PATCH 0998/1564] Issue #2416: correct some mistakes of cc.Scale9Sprite and cc.ParallaxNode --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 4 +- cocos2d/core/labelttf/CCLabelTTF.js | 10 +- .../labelttf/CCLabelTTFCanvasRenderCmd.js | 53 +++++----- .../core/labelttf/CCLabelTTFWebGLRenderCmd.js | 3 +- cocos2d/core/layers/CCLayer.js | 12 +-- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 74 +++++++++----- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 2 + cocos2d/core/sprites/CCSpriteBatchNode.js | 4 +- .../CCSpriteBatchNodeWebGLRenderCmd.js | 4 +- .../core/sprites/CCSpriteWebGLRenderCmd.js | 10 +- cocos2d/labels/CCLabelBMFont.js | 1 - cocos2d/parallax/CCParallaxNode.js | 30 ++---- cocos2d/parallax/CCParallaxNodeRenderCmd.js | 69 +++++++++++++ cocos2d/progress-timer/CCProgressTimer.js | 4 +- cocos2d/tilemap/CCTMXLayer.js | 21 +--- cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js | 6 +- .../gui/control-extension/CCScale9Sprite.js | 99 ++++--------------- .../CCScale9SpriteCanvasRenderCmd.js | 10 ++ .../CCScale9SpriteWebGLRenderCmd.js | 38 +++++-- moduleConfig.json | 3 +- template/src/myApp.js | 3 +- 21 files changed, 239 insertions(+), 221 deletions(-) create mode 100644 cocos2d/parallax/CCParallaxNodeRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index b82976b9a5..1c40a15d1d 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -36,7 +36,7 @@ cc.CustomRenderCmd = function (target, func) { }; cc.Node._dirtyFlags = {transformDirty: 1 << 0, visibleDirty: 1 << 1, colorDirty: 1 << 2, opacityDirty: 1 << 3, cacheDirty: 1 << 4, - orderDirty: 1 << 5, textDirty: 1 << 6, all: (1 << 7) - 1}; + orderDirty: 1 << 5, textDirty: 1 << 6, gradientDirty:1 << 7, all: (1 << 8) - 1}; //-------------------------Base ------------------------- cc.Node.RenderCmd = function(renderable){ @@ -228,7 +228,7 @@ cc.Node.RenderCmd.prototype = { if(colorDirty || opacityDirty) this._updateColor(); - if(this._dirtyFlag & flags.transformDirty){ + if(locFlag & flags.transformDirty){ //update the transform this.transform(this.getParentRenderCmd(), true); } diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 30bc0eaac2..58206a8e55 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -134,15 +134,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return true; }, - setColor: function(color){ - cc.Sprite.prototype.setColor.call(this, color); - this._renderCmd._setColorsString(); - }, - _setUpdateTextureDirty: function () { this._needUpdateTexture = true; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.textDirty); - cc.renderer.pushDirtyNode(this._renderCmd); }, ctor: function (text, fontName, fontSize, dimensions, hAlignment, vAlignment) { @@ -250,8 +244,6 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ * @return {Boolean} */ initWithStringAndTextDefinition: function (text, textDefinition) { - // shader program - this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM)); //TODO // prepare everything needed to render the label this._updateWithTextDefinition(textDefinition, false); // set the string @@ -525,6 +517,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (mustUpdateTexture) this._renderCmd._updateTexture(); + var flags = cc.Node._dirtyFlags; + this._renderCmd.setDirtyFlag(flags.colorDirty|flags.opacityDirty|flags.textDirty); }, _prepareTextDefinition: function (adjustForResolution) { diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index dfc789a0cd..495c388523 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -55,49 +55,43 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; proto.constructor = cc.LabelTTF.RenderCmd; proto.updateStatus = function () { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color - this._updateDisplayColor() - } + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; - if (locFlag & flags.opacityDirty) { - //update the opacity + if (colorDirty) + this._updateDisplayColor(); + if (opacityDirty) this._updateDisplayOpacity(); - } - if (locFlag & flags.textDirty) { - //update texture for labelTTF + if(colorDirty || opacityDirty){ + this._setColorsString(); + this._updateColor(); + this._updateTexture(); + }else if(locFlag & flags.textDirty) this._updateTexture(); - } - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(null, true); - } + if (locFlag & flags.transformDirty) + this.transform(this.getParentRenderCmd(), true); }; proto._syncStatus = function (parentCmd) { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - if (locFlag & flags.colorDirty) { - //update the color + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if (colorDirty) this._syncDisplayColor(); - this._setColorsString(); - } - - if (locFlag & flags.opacityDirty) { - //update the opacity + if (opacityDirty) this._syncDisplayOpacity(); - } - if (locFlag & flags.textDirty) { - //update texture for labelTTF + if(colorDirty || opacityDirty){ + this._setColorsString(); + this._updateColor(); + this._updateTexture(); + }else if(locFlag & flags.textDirty) this._updateTexture(); - } - if (locFlag & flags.transformDirty) { - //update the transform + if (locFlag & flags.transformDirty) //update the transform this.transform(parentCmd); - } }; proto._getLabelContext = function () { @@ -338,9 +332,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; } fuzzyLen = fuzzyLen + pushNum; - tmpText = text.substr(fuzzyLen); - width = allWidth - this._measure(tmpText); } @@ -393,7 +385,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; proto._setColorsString = function () { this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); - var locDisplayColor = this._displayedColor, node = this._node, locDisplayedOpacity = this._displayedOpacity, locShadowColor = node._shadowColor || this._displayedColor; diff --git a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js index 9f47f7cb9f..14b3cb5dd2 100644 --- a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js @@ -27,6 +27,7 @@ cc.LabelTTF.WebGLRenderCmd = function (renderable) { cc.Sprite.WebGLRenderCmd.call(this, renderable); cc.LabelTTF.RenderCmd.call(this); + this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM)); }; cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); @@ -37,7 +38,7 @@ this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); var node = this._node; var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; - this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")"; + this._shadowColorStr = "rgba(128,128,128," + node._shadowOpacity + ")"; this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; }; diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 96ae76fe73..297217e3b6 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -365,7 +365,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ _t._compressedInterpolation = true; cc.LayerColor.prototype.init.call(_t, cc.color(start.r, start.g, start.b, 255)); - this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty|cc.Node._dirtyFlags.gradientDirty); return true; }, @@ -376,16 +376,16 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ */ setContentSize: function (size, height) { cc.LayerColor.prototype.setContentSize.call(this, size, height); - this._renderCmd.setGradientDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty); }, _setWidth: function (width) { cc.LayerColor.prototype._setWidth.call(this, width); - this._renderCmd.setGradientDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty); }, _setHeight: function (height) { cc.LayerColor.prototype._setHeight.call(this, height); - this._renderCmd.setGradientDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty); }, /** @@ -470,7 +470,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ setVector: function (Var) { this._alongVector.x = Var.x; this._alongVector.y = Var.y; - this._renderCmd.setGradientDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty); }, /** @@ -495,7 +495,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ */ setCompressedInterpolation: function (compress) { this._compressedInterpolation = compress; - this._renderCmd.setGradientDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty); }, _createRenderCmd: function(){ diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 7976e6203a..b3157c2eb1 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -317,6 +317,51 @@ }; })(); +(function () { + cc.LayerGradient.RenderCmd = { + updateStatus: function () { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if (colorDirty) + this._updateDisplayColor() + + if (opacityDirty) + this._updateDisplayOpacity(); + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(null, true); + } + + if (colorDirty || opacityDirty || (locFlag & flags.gradientDirty)){ + this._updateColor(); + } + }, + + _syncStatus: function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + + if (colorDirty) + this._syncDisplayColor(); + + if (opacityDirty) + this._syncDisplayOpacity(); + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } + + if (colorDirty || opacityDirty || (locFlag & flags.gradientDirty)){ + this._updateColor(); + } + } + }; +})(); + /** * cc.LayerGradient's rendering objects of Canvas */ @@ -328,15 +373,11 @@ this._endPoint = cc.p(0, 0); this._startStopStr = null; this._endStopStr = null; - this._gradientDirty = false; }; var proto = cc.LayerGradient.CanvasRenderCmd.prototype = Object.create(cc.LayerColor.CanvasRenderCmd.prototype); + cc.inject(cc.LayerGradient.RenderCmd, proto); proto.constructor = cc.LayerGradient.CanvasRenderCmd; - proto.setGradientDirty = function(){ - this._gradientDirty = true; - }; - proto.rendering = function (ctx, scaleX, scaleY) { var context = ctx || cc._renderContext, self = this, @@ -372,32 +413,11 @@ cc.g_NumberOfDraws++; }; - proto.updateStatus = function(){ - var colorDirty = this._dirtyFlag & cc.Node._dirtyFlags.colorDirty, - opacityDirty = this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty; - if(colorDirty){ - //update the color - this._updateDisplayColor() - } - - if(opacityDirty){ - //update the opacity - this._updateDisplayOpacity(); - } - - if(this._dirtyFlag & cc.Node._dirtyFlags.transformDirty){ - //update the transform - this.transform(null, true); - } - - if(colorDirty || opacityDirty || this._gradientDirty) - this._updateColor(); - }; - proto._updateColor = function(){ var node = this._node; var contentSize = node._contentSize; var locAlongVector = node._alongVector, tWidth = contentSize.width * 0.5, tHeight = contentSize.height * 0.5; + this._dirtyFlag ^= cc.Node._dirtyFlags.gradientDirty; this._startPoint.x = tWidth * (-locAlongVector.x) + tWidth; this._startPoint.y = tHeight * locAlongVector.y - tHeight; diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index fb073f65e2..a0b1b0ca61 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -162,9 +162,11 @@ this._needDraw = true; }; var proto = cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype); + cc.inject(cc.LayerGradient.RenderCmd, proto); proto.constructor = cc.LayerGradient.WebGLRenderCmd; proto._updateColor = function(){ + this._dirtyFlag ^= cc.Node._dirtyFlags.gradientDirty; var _t = this, node = this._node; var locAlongVector = node._alongVector; var h = cc.pLength(locAlongVector); diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 496e115eb8..949542a7ea 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -410,7 +410,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite); return; } - this._renderCmd.checkAtlasCapacity(); + this._renderCmd.checkAtlasCapacity(index); // // update the quad directly. Don't add the sprite to the scene graph @@ -423,7 +423,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ sprite.dirty = true; sprite.updateTransform(); - sprite._renderCmd._setCachedParent(this); + //sprite._renderCmd._setCachedParent(this); //TODO need move to renderCmd this._children.splice(index, 0, sprite); }, diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 7e12138597..be9d2b418c 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -77,8 +77,8 @@ proto.checkAtlasCapacity = function(index){ // make needed room - var locCapacity = this._textureAtlas.capacity; - while (index >= locCapacity || locCapacity == this._textureAtlas.totalQuads) { + var locAtlas = this._textureAtlas; + while (index >= locAtlas.capacity || locAtlas.capacity == locAtlas.totalQuads) { this.increaseAtlasCapacity(); } }; diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 302ae66476..e6fc156856 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -377,7 +377,8 @@ if (node._hasChildren) node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); - if (cc.SPRITE_DEBUG_DRAW) { + //TODO + /*if (cc.SPRITE_DEBUG_DRAW) { // draw bounding box var vertices = [ cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), @@ -386,7 +387,7 @@ cc.p(_t._quad.tl.vertices.x, _t._quad.tl.vertices.y) ]; cc._drawingUtil.drawPoly(vertices, 4, true); - } + }*/ }; proto._checkTextureBoundary = function (texture, rect, rotated) { @@ -456,7 +457,8 @@ } cc.g_NumberOfDraws++; - if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode) + //TODO + /*if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode) return; if (cc.SPRITE_DEBUG_DRAW === 1 || node._showNode) { @@ -476,6 +478,6 @@ var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; cc._drawingUtil.drawPoly(verticesG2, 4, true); - } // CC_SPRITE_DEBUG_DRAW + } */// CC_SPRITE_DEBUG_DRAW }; })(); \ No newline at end of file diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index ea4bbe45dd..071852c8b7 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -364,7 +364,6 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ //If the last character processed has an xAdvance which is less that the width of the characters image, then we need // to adjust the width of the string to take this into account, or the character will overlap the end of the bounding box - //TODO sync to -x if(fontDef && fontDef.xAdvance < fontDef.rect.width) tmpSize.width = longestLine - fontDef.xAdvance + fontDef.rect.width; else diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index 48fbb51616..c7716ea99f 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -207,22 +207,18 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ cc.Node.prototype.removeAllChildren.call(this, cleanup); }, - /** - * Recursive method that visit its children and draw them - */ - visit:function () { + _updateParallaxPosition: function(){ var pos = this._absolutePosition(); if (!cc.pointEqualToPoint(pos, this._lastPosition)) { var locParallaxArray = this.parallaxArray; for (var i = 0, len = locParallaxArray.length; i < len; i++) { var point = locParallaxArray[i]; - var child = point.getChild(); - child.setPosition(-pos.x + pos.x * point.getRatio().x + point.getOffset().x, - -pos.y + pos.y * point.getRatio().y + point.getOffset().y); + var child = point.getChild(); + child.setPosition(-pos.x + pos.x * point.getRatio().x + point.getOffset().x, + -pos.y + pos.y * point.getRatio().y + point.getOffset().y); } this._lastPosition = pos; } - cc.Node.prototype.visit.call(this); }, _absolutePosition:function () { @@ -235,19 +231,11 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ return ret; }, - _transformForRenderer:function () { - var pos = this._absolutePosition(); - if (!cc.pointEqualToPoint(pos, this._lastPosition)) { - var locParallaxArray = this.parallaxArray; - for (var i = 0, len = locParallaxArray.length; i < len; i++) { - var point = locParallaxArray[i]; - var child = point.getChild(); - child.setPosition(-pos.x + pos.x * point.getRatio().x + point.getOffset().x, - -pos.y + pos.y * point.getRatio().y + point.getOffset().y); - } - this._lastPosition = pos; - } - cc.Node.prototype._transformForRenderer.call(this); + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new cc.ParallaxNode.CanvasRenderCmd(this); + else + return new cc.ParallaxNode.WebGLRenderCmd(this); } }); diff --git a/cocos2d/parallax/CCParallaxNodeRenderCmd.js b/cocos2d/parallax/CCParallaxNodeRenderCmd.js new file mode 100644 index 0000000000..690a7849f6 --- /dev/null +++ b/cocos2d/parallax/CCParallaxNodeRenderCmd.js @@ -0,0 +1,69 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +//TODO find a way to simple these code. + +(function(){ + cc.ParallaxNode.CanvasRenderCmd = function(renderable){ + cc.Node.CanvasRenderCmd.call(this, renderable); + this._needDraw = false; + }; + + var proto = cc.ParallaxNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + proto.constructor = cc.ParallaxNode.CanvasRenderCmd; + + proto.updateStatus = function(){ + this._node._updateParallaxPosition(); + cc.Node.CanvasRenderCmd.prototype.updateStatus.call(this); + }; + + proto._syncStatus = function(parentCmd){ + this._node._updateParallaxPosition(); + cc.Node.CanvasRenderCmd.prototype._syncStatus.call(this, parentCmd); + } +})(); + +(function(){ + if(cc._renderType !== cc._RENDER_TYPE_WEBGL) + return; + + cc.ParallaxNode.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = false; + }; + + var proto = cc.ParallaxNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.ParallaxNode.WebGLRenderCmd; + + proto.updateStatus = function(){ + this._node._updateParallaxPosition(); + cc.Node.WebGLRenderCmd.prototype.updateStatus.call(this); + }; + + proto._syncStatus = function(parentCmd){ + this._node._updateParallaxPosition(); + cc.Node.WebGLRenderCmd.prototype._syncStatus.call(this, parentCmd); + } +})(); + diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index defb85ef0a..51abcf23b5 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -177,7 +177,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ */ setColor:function (color) { this._sprite.color = color; - this._renderCmd._updateColor(); + //this._renderCmd._updateColor(); }, /** @@ -186,7 +186,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ */ setOpacity:function (opacity) { this._sprite.opacity = opacity; - this._renderCmd._updateColor(); + //this._renderCmd._updateColor(); }, /** diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index a98beed227..bf03f6fe63 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -124,17 +124,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * @return {cc.Texture2D} */ getTexture: function(){ - this._renderCmd.getTexture(); - }, - - /** - * don't call visit on it's children ( override visit of cc.Node ) - * @function - * @override - * @param {CanvasRenderingContext2D} ctx - */ - visit: function(){ - this._renderCmd.visit(); + return this._renderCmd.getTexture(); }, //set the cache dirty flag for canvas @@ -143,15 +133,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, - /** - * draw cc.SpriteBatchNode (override draw of cc.Node) - * @function - * @param {CanvasRenderingContext2D} ctx - */ - draw: function(ctx){ - this._renderCmd.draw(ctx); - }, - /** * Gets layer size. * @return {cc.Size} diff --git a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js index 94e49a5c12..f65bf670e7 100644 --- a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js @@ -28,7 +28,7 @@ this._needDraw = true; }; - var proto = cc.TMXLayer.WebGLRenderCmd.prototype.rendering = cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering; + var proto = cc.TMXLayer.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype); proto.constructor = cc.TMXLayer.WebGLRenderCmd; proto._updateCacheContext = function(){}; @@ -37,13 +37,13 @@ proto.initImageSize = function(){ var node = this._node; - node.tileset.imageSize = this.textureAtlas.texture.getContentSizeInPixels(); + node.tileset.imageSize = this._textureAtlas.texture.getContentSizeInPixels(); // By default all the tiles are aliased // pros: // - easier to render // cons: // - difficult to scale / rotate / etc. - node.textureAtlas.texture.setAliasTexParameters(); + this._textureAtlas.texture.setAliasTexParameters(); } })(); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 10f9875903..bc486b3b85 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -62,18 +62,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ _bottom: null, _bottomRight: null, - //cache in canvas on Canvas mode - _cacheSprite: null, - _cacheContext: null, - _cacheTexture: null, _scale9Dirty: true, _opacityModifyRGB: false, _originalSize: null, _preferredSize: null, - _opacity: 0, - _color: null, + _capInsets: null, _insetLeft: 0, _insetTop: 0, @@ -136,32 +131,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var sizableWidth = size.width - locTopLeftContentSize.width - locTopRight.getContentSize().width; var sizableHeight = size.height - locTopLeftContentSize.height - locBottomRight.getContentSize().height; - var horizontalScale = sizableWidth / locCenterContentSize.width; - var verticalScale = sizableHeight / locCenterContentSize.height; + var scaleResult = this._renderCmd._computeSpriteScale(sizableWidth, sizableHeight, locCenterContentSize.width, locCenterContentSize.height); - var rescaledWidth = locCenterContentSize.width * horizontalScale; - var rescaledHeight = locCenterContentSize.height * verticalScale; + locCenter.setScaleX(scaleResult.horizontalScale); + locCenter.setScaleY(scaleResult.verticalScale); var leftWidth = locBottomLeftContentSize.width; var bottomHeight = locBottomLeftContentSize.height; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - //browser is in canvas mode, need to manually control rounding to prevent overlapping pixels - var roundedRescaledWidth = Math.round(rescaledWidth); - if (rescaledWidth != roundedRescaledWidth) { - rescaledWidth = roundedRescaledWidth; - horizontalScale = rescaledWidth / locCenterContentSize.width; - } - var roundedRescaledHeight = Math.round(rescaledHeight); - if (rescaledHeight != roundedRescaledHeight) { - rescaledHeight = roundedRescaledHeight; - verticalScale = rescaledHeight / locCenterContentSize.height; - } - } - - locCenter.setScaleX(horizontalScale); - locCenter.setScaleY(verticalScale); - var locLeft = this._left, locRight = this._right, locTop = this._top, locBottom = this._bottom; var tempAP = cc.p(0, 0); locBottomLeft.setAnchorPoint(tempAP); @@ -176,19 +153,19 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Position corners locBottomLeft.setPosition(0, 0); - locBottomRight.setPosition(leftWidth + rescaledWidth, 0); - locTopLeft.setPosition(0, bottomHeight + rescaledHeight); - locTopRight.setPosition(leftWidth + rescaledWidth, bottomHeight + rescaledHeight); + locBottomRight.setPosition(leftWidth + scaleResult.rescaledWidth, 0); + locTopLeft.setPosition(0, bottomHeight + scaleResult.rescaledHeight); + locTopRight.setPosition(leftWidth + scaleResult.rescaledWidth, bottomHeight + scaleResult.rescaledHeight); // Scale and position borders locLeft.setPosition(0, bottomHeight); - locLeft.setScaleY(verticalScale); - locRight.setPosition(leftWidth + rescaledWidth, bottomHeight); - locRight.setScaleY(verticalScale); + locLeft.setScaleY(scaleResult.verticalScale); + locRight.setPosition(leftWidth + scaleResult.rescaledWidth, bottomHeight); + locRight.setScaleY(scaleResult.verticalScale); locBottom.setPosition(leftWidth, 0); - locBottom.setScaleX(horizontalScale); - locTop.setPosition(leftWidth, bottomHeight + rescaledHeight); - locTop.setScaleX(horizontalScale); + locBottom.setScaleX(scaleResult.horizontalScale); + locTop.setPosition(leftWidth, bottomHeight + scaleResult.rescaledHeight); + locTop.setScaleX(scaleResult.horizontalScale); // Position centre locCenter.setPosition(leftWidth, bottomHeight); @@ -277,20 +254,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._scale9Dirty = true; }, - updateDisplayedOpacity: function(parentOpacity){ - if(!this._scale9Image) - return; - - cc.Node.prototype.updateDisplayedOpacity.call(this, parentOpacity); - var scaleChildren = this._scale9Image.getChildren(); - for (var i = 0; i < scaleChildren.length; i++) { - var selChild = scaleChildren[i]; - if (selChild) - selChild.updateDisplayedOpacity(parentOpacity); - } - this._scale9Dirty = true; - }, - /** Color: conforms to CCRGBAProtocol protocol */ setColor: function (color) { if(!this._scale9Image) @@ -306,33 +269,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._scale9Dirty = true; }, - updateDisplayedColor: function(parentColor){ - if(!this._scale9Image) - return; - - cc.Node.prototype.updateDisplayedColor.call(this, parentColor); - var scaleChildren = this._scale9Image.getChildren(); - for (var i = 0; i < scaleChildren.length; i++) { - var selChild = scaleChildren[i]; - if (selChild){ - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - cc.Node.prototype.updateDisplayedColor.call(selChild, parentColor); - if( - parentColor.r !== 255 || - parentColor.g !== 255 || - parentColor.b !== 255 - ){ - selChild._changeTextureColor(); - selChild._setNodeDirtyForCache(); - } - }else{ - selChild.updateDisplayedColor(parentColor); - } - } - } - this._scale9Dirty = true; - }, - getCapInsets: function () { return cc.rect(this._capInsets); }, @@ -664,7 +600,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } // Set the given rect's size as original size - this._spriteRect = rect; + //this._spriteRect = rect; var locSpriteRect = this._spriteRect; locSpriteRect.x = rect.x; locSpriteRect.y = rect.y; @@ -911,8 +847,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } this.setContentSize(rect.width, rect.height); - if(cc._renderType === cc._RENDER_TYPE_WEBGL) - this.addChild(locScale9Image); + this._renderCmd.addBatchNodeToChildren(locScale9Image); if (this._spritesGenerated) { // Restore color and opacity @@ -1002,7 +937,7 @@ cc.Scale9Sprite.create = function (file, rect, capInsets) { * @deprecated * @param spriteFrame * @param capInsets - * @returns {Scale9Sprite} + * @returns {cc.Scale9Sprite} */ cc.Scale9Sprite.createWithSpriteFrame = function (spriteFrame, capInsets) { return new cc.Scale9Sprite(spriteFrame, capInsets); @@ -1012,7 +947,7 @@ cc.Scale9Sprite.createWithSpriteFrame = function (spriteFrame, capInsets) { * @deprecated * @param spriteFrameName * @param capInsets - * @returns {Scale9Sprite} + * @returns {cc.Scale9Sprite} */ cc.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName, capInsets) { return new cc.Scale9Sprite(spriteFrameName, capInsets); diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js index 75573a0454..909bcc79f7 100644 --- a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -44,6 +44,16 @@ var proto = cc.Scale9Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); proto.constructor = cc.Scale9Sprite.CanvasRenderCmd; + proto.addBatchNodeToChildren = function(batchNode){ + //needn't add to children on canvas mode. + }; + + proto._computeSpriteScale = function(sizableWidth, sizableHeight, centerWidth, centerHeight){ + var horizontalScale = sizableWidth / centerWidth, verticalScale = sizableHeight / centerHeight; + return {horizontalScale: horizontalScale, verticalScale: verticalScale, + rescaledWidth: centerWidth * horizontalScale, rescaledHeight: centerHeight * verticalScale} + }; + proto.visit = function(){ var node = this._node; if(!node._visible){ diff --git a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js index 83df2c24ed..cc5c708da8 100644 --- a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js @@ -32,17 +32,41 @@ var proto = cc.Scale9Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.Scale9Sprite.WebGLRenderCmd; - proto.visit = function(){ - if(!this._visible){ + proto.addBatchNodeToChildren = function(batchNode){ + this._node.addChild(batchNode); + }; + + proto._computeSpriteScale = function (sizableWidth, sizableHeight, centerWidth, centerHeight) { + var horizontalScale = sizableWidth / centerWidth, verticalScale = sizableHeight / centerHeight; + var rescaledWidth = centerWidth * horizontalScale, rescaledHeight = centerHeight * verticalScale; + + var roundedRescaledWidth = Math.round(rescaledWidth); + if (rescaledWidth !== roundedRescaledWidth) { + rescaledWidth = roundedRescaledWidth; + horizontalScale = rescaledWidth / centerWidth; + } + var roundedRescaledHeight = Math.round(rescaledHeight); + if (rescaledHeight !== roundedRescaledHeight) { + rescaledHeight = roundedRescaledHeight; + verticalScale = rescaledHeight / centerHeight; + } + + return {horizontalScale: horizontalScale, verticalScale: verticalScale, + rescaledWidth: rescaledWidth, rescaledHeight: rescaledHeight} + }; + + proto.visit = function(parentCmd){ + var node = this._node; + if(!node._visible){ return; } - if (this._positionsAreDirty) { - this._updatePositions(); - this._positionsAreDirty = false; - this._scale9Dirty = true; + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; } - cc.Node.prototype.visit.call(this, ctx); + cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); }; })(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 446db60478..1c18718c23 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -177,7 +177,8 @@ "parallax" : [ "core", - "cocos2d/parallax/CCParallaxNode.js" + "cocos2d/parallax/CCParallaxNode.js", + "cocos2d/parallax/CCParallaxNodeRenderCmd.js" ], "particle" : [ "core", "compression", diff --git a/template/src/myApp.js b/template/src/myApp.js index a706995ea1..329288ce1f 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,7 +44,8 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); - + this.helloLabel.setColor(cc.color.RED); + window.label = this.helloLabel; } }); From 953380cf97f916de1520cb42eba28648f7c1c62c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 11:00:03 +0800 Subject: [PATCH 0999/1564] Issue #2416: Repair BMFont texture update error for canvas --- cocos2d/labels/CCLabelBMFont.js | 1 + cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js | 8 ++++++++ cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js | 2 ++ 3 files changed, 11 insertions(+) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 071852c8b7..2d7335122e 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -348,6 +348,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ // Apply label properties fontChar.opacityModifyRGB = this._opacityModifyRGB; + this._renderCmd._updateCharColorAndOpacity(fontChar); var yOffset = locCfg.commonHeight - fontDef.yOffset; var fontPos = cc.p(nextFontPositionX + fontDef.xOffset + fontDef.rect.width * 0.5 + kerningAmount, diff --git a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js index 68b035fe8f..4920171d6a 100644 --- a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js @@ -54,6 +54,14 @@ } }; + proto._updateCharColorAndOpacity = function(fontChar){ + // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on + fontChar._displayedColor = this._displayedColor; + fontChar._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); + fontChar._displayedOpacity = this._displayedOpacity; + fontChar._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); + }; + proto._updateFntFileTexture = function(){ var node = this._node; node._originalTexture = node.texture; diff --git a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js index 87461ec8da..8d0aee5e13 100644 --- a/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js @@ -82,4 +82,6 @@ cc._drawingUtil.drawPoly(vertices, 4, true); } }; + + proto._updateCharColorAndOpacity = function(){}; })(); \ No newline at end of file From 54c94ec9571d4aa30153f10f96c1b1970f7cb529 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 13:33:17 +0800 Subject: [PATCH 1000/1564] Issue #2416: Repair ClippingNode transform error for canvas --- cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js index 72d6537147..931f44cf6a 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -162,6 +162,7 @@ proto.visit = function(parentCmd){ cc.renderer.pushRenderCommand(this); var node = this._node; + var transformRenderCmd = (node._stencil instanceof cc.Sprite) ? this : null; // quick return if not visible if (!node._visible) return; @@ -185,7 +186,7 @@ // Draw everything first using node visit function cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); }else{ - node._stencil.visit(this); + node._stencil.visit(transformRenderCmd); } cc.renderer.pushRenderCommand(this._rendererClipCmd); @@ -193,7 +194,7 @@ this._syncStatus(parentCmd); if(this._clipElemType){ - node._stencil.visit(this); + node._stencil.visit(transformRenderCmd); }else{ // Clip mode doesn't support recusive stencil, so once we used a clip stencil, // so if it has ClippingNode as a child, the child must uses composition stencil. From e23a456106e67638c234eb5e97c6adb92ddd3e36 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 14:10:22 +0800 Subject: [PATCH 1001/1564] Issue #2416: Repair ClippingNode transform error for canvas --- cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index ff166c2a1a..711c86dae3 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -132,7 +132,7 @@ context.globalAlpha = alpha; //cache //transform - context.setTransform(t.a, t.c, t.b, t.d, t.tx * scaleX, (cc.view._visibleRect.height-t.ty) * scaleY); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); if (this._needSetBlend) context.globalCompositeOperation = this._blendFuncStr; From 94b476d70226db50ebca03de113831bf2cb6619a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 1 Dec 2014 15:25:56 +0800 Subject: [PATCH 1002/1564] Issue #2416: refactor cc.MotionStreak and correct a mistake of cc.ParticleSystem --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 3 +- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 2 +- cocos2d/motion-streak/CCMotionStreak.js | 80 +++---------------- .../CCMotionStreakWebGLRenderCmd.js | 38 ++++----- .../CCParticleBatchNodeWebGLRenderCmd.js | 6 +- .../CCParticleSystemWebGLRenderCmd.js | 4 +- cocos2d/progress-timer/CCProgressTimer.js | 9 +-- .../CCProgressTimerCanvasRenderCmd.js | 63 ++++++++++++++- .../CCProgressTimerWebGLRenderCmd.js | 64 +++++++++++++++ extensions/spine/CCSkeletonWebGLRenderCmd.js | 4 +- 10 files changed, 166 insertions(+), 107 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 1c40a15d1d..723efe0c26 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -149,7 +149,7 @@ cc.Node.RenderCmd.prototype = { } } this._cascadeColorEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; }, _updateDisplayOpacity: function (parentOpacity) { @@ -253,6 +253,7 @@ cc.Node.RenderCmd.prototype = { var t = this.getNodeToParentTransform(), worldT = this._worldTransform; //get the world transform + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; if (parentCmd) { var pt = parentCmd._worldTransform; // cc.AffineTransformConcat is incorrect at get world transform diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index e0f1afb557..8ae17abb66 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -48,7 +48,6 @@ node._normalizedPositionDirty = false; } if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) { - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; // Translate values var x = node._position.x, y = node._position.y; var apx = this._anchorPointInPoints.x, napx = -apx; @@ -183,6 +182,7 @@ // Convert 3x3 into 4x4 matrix var trans = this.getNodeToParentTransform(); + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index cffafc8c80..e62727be07 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -85,7 +85,6 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ cc.Node.prototype.ctor.call(this); this._positionR = cc.p(0, 0); this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); - this._vertexWebGLBuffer = cc._renderContext.createBuffer(); this.fastMode = false; this.startingPositionInitialized = false; @@ -115,8 +114,6 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ if(texture !== undefined) this.initWithFade(fade, minSeg, stroke, color, texture); - - this._renderCmd = new cc.MotionStreak.WebGLRenderCmd(this); }, /** @@ -193,25 +190,6 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ return false; }, - /** - *

    - * callback that is called every time the node leaves the 'stage'.
    - * If the node leaves the 'stage' with a transition, this callback is called when the transition finishes.
    - * During onExit you can't access a sibling node.
    - * If you override onExit, you shall call its parent's onExit with this._super(). - *

    - * @function - */ - onExit:function(){ - cc.Node.prototype.onExit.call(this); - if(this._verticesBuffer) - cc._renderContext.deleteBuffer(this._verticesBuffer); - if(this._texCoordsBuffer) - cc._renderContext.deleteBuffer(this._texCoordsBuffer); - if(this._colorPointerBuffer) - cc._renderContext.deleteBuffer(this._colorPointerBuffer); - }, - /** * Checking fast mode. * @returns {boolean} @@ -267,13 +245,14 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this.startingPositionInitialized = false; this.fastMode = true; - this._minSeg = (minSeg == -1.0) ? (stroke / 5.0) : minSeg; + this._minSeg = (minSeg === -1.0) ? (stroke / 5.0) : minSeg; this._minSeg *= this._minSeg; this._stroke = stroke; this._fadeDelta = 1.0 / fade; var locMaxPoints = (0 | (fade * 60)) + 2; + this._maxPoints = locMaxPoints; this._nuPoints = 0; this._pointState = new Float32Array(locMaxPoints); this._pointVertexes = new Float32Array(locMaxPoints * 2); @@ -281,9 +260,6 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this._vertices = new Float32Array(locMaxPoints * 4); this._texCoords = new Float32Array(locMaxPoints * 4); this._colorPointer = new Uint8Array(locMaxPoints * 8); - this._maxPoints = locMaxPoints; - - var gl = cc._renderContext; this._verticesBuffer = gl.createBuffer(); this._texCoordsBuffer = gl.createBuffer(); @@ -293,9 +269,6 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this._blendFunc.src = gl.SRC_ALPHA; this._blendFunc.dst = gl.ONE_MINUS_SRC_ALPHA; - // shader program - this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); - this.texture = texture; this.color = color; this.scheduleUpdate(); @@ -387,43 +360,6 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this.startingPositionInitialized = true; }, - /** - * Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function - * @function - * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context - */ - draw:function (ctx) { - if (this._nuPoints <= 1) - return; - - if(this.texture && this.texture.isLoaded()){ - ctx = ctx || cc._renderContext; - cc.nodeDrawSetup(this); - cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); - - cc.glBindTexture2D(this.texture); - - //position - ctx.bindBuffer(ctx.ARRAY_BUFFER, this._verticesBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, this._vertices, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); - - //texcoords - ctx.bindBuffer(ctx.ARRAY_BUFFER, this._texCoordsBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, this._texCoords, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); - - //colors - ctx.bindBuffer(ctx.ARRAY_BUFFER, this._colorPointerBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, this._colorPointer, ctx.DYNAMIC_DRAW); - ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); - - ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, this._nuPoints * 2); - cc.g_NumberOfDraws ++; - } - }, - /** *

    schedules the "update" method.
    * It will use the order number 0. This method will be called every frame.
    @@ -435,6 +371,9 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ if (!this.startingPositionInitialized) return; + //TODO update the color (need move to render cmd) + this._renderCmd._updateDisplayColor(); + delta *= this._fadeDelta; var newIdx, newIdx2, i, i2; @@ -507,7 +446,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ // Color assignment var offset = locNuPoints * 8; - var locDisplayedColor = this._displayedColor; + var locDisplayedColor = this.getDisplayedColor(); locColorPointer[offset] = locDisplayedColor.r; locColorPointer[offset + 1] = locDisplayedColor.g; locColorPointer[offset + 2] = locDisplayedColor.b; @@ -549,6 +488,13 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ } this._nuPoints = locNuPoints; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + return new cc.MotionStreak.WebGLRenderCmd(this); + else + return null; //MotionStreak doesn't support Canvas mode } }); diff --git a/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js b/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js index 45733eb83b..45ab07cafd 100644 --- a/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js +++ b/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js @@ -25,50 +25,42 @@ cc.MotionStreak.WebGLRenderCmd = function(renderableObject){ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; - this._textureCoord = { - renderX: 0, //the x of texture coordinate for render, when texture tinted, its value doesn't equal x. - renderY: 0, //the y of texture coordinate for render, when texture tinted, its value doesn't equal y. - x: 0, //the x of texture coordinate for node. - y: 0, //the y of texture coordinate for node. - width: 0, - height: 0, - validRect: false - }; + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; cc.MotionStreak.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); cc.MotionStreak.WebGLRenderCmd.prototype.constructor = cc.Sprite.WebGLRenderCmd; cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(ctx){ - var _t = this._node; - if (_t._nuPoints <= 1) + var node = this._node; + if (node._nuPoints <= 1) return; - if (_t.texture && _t.texture.isLoaded()) { + if (node.texture && node.texture.isLoaded()) { ctx = ctx || cc._renderContext; - _t._shaderProgram.use(); - _t._shaderProgram._setUniformForMVPMatrixWithMat4(_t._stackMatrix); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - cc.glBlendFunc(_t._blendFunc.src, _t._blendFunc.dst); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); - cc.glBindTexture2D(_t.texture); + cc.glBindTexture2D(node.texture); //position - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._verticesBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._vertices, ctx.DYNAMIC_DRAW); + ctx.bindBuffer(ctx.ARRAY_BUFFER, node._verticesBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, node._vertices, ctx.DYNAMIC_DRAW); ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, ctx.FLOAT, false, 0, 0); //texcoords - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._texCoordsBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._texCoords, ctx.DYNAMIC_DRAW); + ctx.bindBuffer(ctx.ARRAY_BUFFER, node._texCoordsBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, node._texCoords, ctx.DYNAMIC_DRAW); ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, ctx.FLOAT, false, 0, 0); //colors - ctx.bindBuffer(ctx.ARRAY_BUFFER, _t._colorPointerBuffer); - ctx.bufferData(ctx.ARRAY_BUFFER, _t._colorPointer, ctx.DYNAMIC_DRAW); + ctx.bindBuffer(ctx.ARRAY_BUFFER, node._colorPointerBuffer); + ctx.bufferData(ctx.ARRAY_BUFFER, node._colorPointer, ctx.DYNAMIC_DRAW); ctx.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, ctx.UNSIGNED_BYTE, true, 0, 0); - ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, _t._nuPoints * 2); + ctx.drawArrays(ctx.TRIANGLE_STRIP, 0, node._nuPoints * 2); cc.g_NumberOfDraws++; } }; \ No newline at end of file diff --git a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js index cf62122794..6b694f0ffe 100644 --- a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js @@ -63,10 +63,8 @@ var currentStack = cc.current_stack; currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(node._stackMatrix, currentStack.top); - currentStack.top = node._stackMatrix; - - node._syncStatus(ctx); + this._syncStatus(ctx); + currentStack.top = this._stackMatrix; //this.draw(ctx); cc.renderer.pushRenderCommand(this); diff --git a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js index db201767bb..1065d1f229 100644 --- a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js @@ -208,7 +208,7 @@ }; proto.initTexCoordsWithRect = function(pointRect){ - var node = this; + var node = this._node; var texture = node.texture; var scaleFactor = cc.contentScaleFactor(); // convert to pixels coords @@ -310,7 +310,7 @@ //set the texture coord if(node._texture){ - node.initTexCoordsWithRect(cc.rect(0, 0, node._texture.width, node._texture.height)); + this.initTexCoordsWithRect(cc.rect(0, 0, node._texture.width, node._texture.height)); } } else node._totalParticles = tp; diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index 51abcf23b5..b5b9fff6f3 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -147,7 +147,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ setPercentage:function (percentage) { if (this._percentage != percentage) { this._percentage = cc.clampf(percentage, 0, 100); - this._updateProgress(); + this._renderCmd._updateProgress(); } }, /** @@ -177,7 +177,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ */ setColor:function (color) { this._sprite.color = color; - //this._renderCmd._updateColor(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); }, /** @@ -187,6 +187,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ setOpacity:function (opacity) { this._sprite.opacity = opacity; //this._renderCmd._updateColor(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); }, /** @@ -276,10 +277,6 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ return true; }, - _updateProgress: function(){ - this._renderCmd._updateProgress(); - }, - _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.ProgressTimer.CanvasRenderCmd(this); diff --git a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js index a1beee74ac..bc79382509 100644 --- a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js @@ -45,7 +45,7 @@ proto.rendering = function (ctx, scaleX, scaleY) { var context = ctx || cc._renderContext, node = this._node, locSprite = node._sprite; - var locTextureCoord = locSprite._renderCmd._textureCoord, alpha = locSprite._displayedOpacity / 255; + var locTextureCoord = locSprite._renderCmd._textureCoord, alpha = locSprite._renderCmd._displayedOpacity / 255; if (locTextureCoord.width === 0 || locTextureCoord.height === 0) return; @@ -212,4 +212,65 @@ }; proto._updateColor = function(){}; + + proto._syncStatus = function (parentCmd) { + var node = this._node; + if(!node._sprite) + return; + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var spriteCmd = node._sprite._renderCmd; + var spriteFlag = spriteCmd._dirtyFlag; + + var colorDirty = spriteFlag & flags.colorDirty, + opacityDirty = spriteFlag & flags.opacityDirty; + + if (colorDirty){ + spriteCmd._syncDisplayColor(); + } + + if (opacityDirty){ + spriteCmd._syncDisplayOpacity(); + } + +/* if(colorDirty || opacityDirty){ + spriteCmd._updateColor(); + this._updateColor(); + }*/ + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } + }; + + proto.updateStatus = function () { + var node = this._node; + if(!node._sprite) + return; + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var spriteCmd = node._sprite._renderCmd; + var spriteFlag = spriteCmd._dirtyFlag; + + var colorDirty = spriteFlag & flags.colorDirty, + opacityDirty = spriteFlag & flags.opacityDirty; + + if(colorDirty){ + spriteCmd._updateDisplayColor(); + } + + if(opacityDirty){ + spriteCmd._updateDisplayOpacity(); + } + +/* if(colorDirty || opacityDirty){ + spriteCmd._updateColor(); + this._updateColor(); + }*/ + + if(locFlag & flags.transformDirty){ + //update the transform + this.transform(this.getParentRenderCmd(), true); + } + this._dirtyFlag = 0; + }; })(); \ No newline at end of file diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index de746543d0..e0de1baa52 100644 --- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -80,6 +80,70 @@ cc.g_NumberOfDraws++; }; + proto._syncStatus = function (parentCmd) { + var node = this._node; + if(!node._sprite) + return; + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var spriteCmd = node._sprite._renderCmd; + var spriteFlag = spriteCmd._dirtyFlag; + + var colorDirty = spriteFlag & flags.colorDirty, + opacityDirty = spriteFlag & flags.opacityDirty; + + if (colorDirty){ + spriteCmd._syncDisplayColor(); + this._dirtyFlag ^= flags.colorDirty; + } + + if (opacityDirty){ + spriteCmd._syncDisplayOpacity(); + this._dirtyFlag ^= flags.opacityDirty; + } + + if(colorDirty || opacityDirty){ + spriteCmd._updateColor(); + this._updateColor(); + } + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } + }; + + proto.updateStatus = function () { + var node = this._node; + if(!node._sprite) + return; + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var spriteCmd = node._sprite._renderCmd; + var spriteFlag = spriteCmd._dirtyFlag; + + var colorDirty = spriteFlag & flags.colorDirty, + opacityDirty = spriteFlag & flags.opacityDirty; + + if(colorDirty){ + spriteCmd._updateDisplayColor(); + this._dirtyFlag ^= flags.colorDirty; + } + + if(opacityDirty){ + spriteCmd._updateDisplayOpacity(); + this._dirtyFlag ^= flags.opacityDirty; + } + + if(colorDirty || opacityDirty){ + spriteCmd._updateColor(); + this._updateColor(); + } + + if(locFlag & flags.transformDirty){ + //update the transform + this.transform(this.getParentRenderCmd(), true); + } + }; + proto.releaseData = function(){ if (this._vertexData) { //release all previous information diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index d9a6baabfa..c39376a0e8 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -33,8 +33,8 @@ proto.rendering = function (ctx) { var node = this._node; - node._shaderProgram.use(); - node._shaderProgram._setUniformForMVPMatrixWithMat4(node._stackMatrix); + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); // cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); var color = node.getColor(), locSkeleton = node._skeleton; locSkeleton.r = color.r / 255; From 0d420e322437ddd8f6ba66aab7800e6b88d4b8b4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 15:36:17 +0800 Subject: [PATCH 1003/1564] Issue #2416: Parameter is missing --- cocos2d/particle/CCParticleSystemCanvasRenderCmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js index e114232ee2..837d595670 100644 --- a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js @@ -176,7 +176,7 @@ this._pointRect = pointRect; }; - proto.setTotalParticles = function(){ + proto.setTotalParticles = function(tp){ //cc.assert(tp <= this._allocatedParticles, "Particle: resizing particle array only supported for quads"); this._node._totalParticles = (tp < 200) ? tp : 200; }; From 8cf8b76c8feabeecd027698c0b384dd5eb8727e4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 16:38:02 +0800 Subject: [PATCH 1004/1564] Issue #2416: Repair the transform mark erro --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 98f7d7795a..2e02546cb7 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -253,7 +253,6 @@ cc.Node.RenderCmd.prototype = { var t = this.getNodeToParentTransform(), worldT = this._worldTransform; //get the world transform - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; if (parentCmd) { var pt = parentCmd._worldTransform; // cc.AffineTransformConcat is incorrect at get world transform @@ -438,9 +437,11 @@ cc.Node.RenderCmd.prototype = { if(colorDirty) this._updateColor(); - if (transformDirty) + if (transformDirty){ //update the transform this.transform(parentCmd); + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + } }; From 9eaa76935f7b18ed1902dc9c41d8db82b0319012 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 1 Dec 2014 17:23:32 +0800 Subject: [PATCH 1005/1564] Issue #2416: refactor cc.NodeGrid's renderer --- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 6 +- cocos2d/node-grid/CCNodeGrid.js | 96 ++----------------- cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js | 96 +++++++++++++++++++ moduleConfig.json | 3 +- 4 files changed, 110 insertions(+), 91 deletions(-) create mode 100644 cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 8ae17abb66..91c62b5f71 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -134,7 +134,7 @@ proto._updateColor = function(){}; proto.visit = function (parentCmd) { - var _t = this, node = this._node; + var node = this._node; // quick return if not visible if (!node._visible) return; @@ -147,8 +147,8 @@ //optimize performance for javascript currentStack.stack.push(currentStack.top); - _t._syncStatus(parentCmd); - currentStack.top = _t._stackMatrix; + this._syncStatus(parentCmd); + currentStack.top = this._stackMatrix; var locChildren = node._children; if (locChildren && locChildren.length > 0) { diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index b7fb046c79..c5bc3b28ba 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -26,7 +26,8 @@ /** *

    NodeGrid class is a class serves as a decorator of cc.Node,
    - * Grid node can run grid actions over all its children

    + * Grid node can run grid actions over all its children (WebGL only) + *

    * @type {Class} * * @property {cc.GridBase} grid - Grid object that is used when applying effects @@ -35,16 +36,6 @@ cc.NodeGrid = cc.Node.extend({ grid: null, _target: null, - _gridBeginCommand:null, - _gridEndCommand:null, - - ctor: function(){ - cc.Node.prototype.ctor.call(this); - if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - this._gridBeginCommand = new cc.CustomRenderCmd(this, this.onGridBeginDraw); - this._gridEndCommand = new cc.CustomRenderCmd(this, this.onGridEndDraw); - } - }, /** * Gets the grid object. @@ -70,78 +61,6 @@ cc.NodeGrid = cc.Node.extend({ this._target = target; }, - onGridBeginDraw: function(){ - var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; - if (isWebGL && locGrid && locGrid._active) - locGrid.beforeDraw(); - }, - - onGridEndDraw: function(){ - var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; - if (isWebGL && locGrid && locGrid._active) - locGrid.afterDraw(this._target); - }, - - /** - * Recursive method that visit its children and draw them - */ - visit: function () { - var self = this; - // quick return if not visible - if (!self._visible) - return; - - var isWebGL = cc._renderType == cc._RENDER_TYPE_WEBGL, locGrid = this.grid; - if(isWebGL){ - var currentStack = cc.current_stack; - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); - currentStack.top = this._stackMatrix; - } - - self.transform(); - - if(isWebGL){ - - var beforeProjectionType = cc.director.PROJECTION_DEFAULT; - if (locGrid && locGrid._active){ - //var backMatrix = new cc.kmMat4(); - //cc.kmMat4Assign(backMatrix, this._stackMatrix); - - beforeProjectionType = cc.director.getProjection(); - //locGrid.set2DProjection(); - - //reset this._stackMatrix to current_stack.top - //cc.kmMat4Assign(currentStack.top, backMatrix); - } - if(this._gridBeginCommand) - cc.renderer.pushRenderCommand(this._gridBeginCommand); - - if(this._target) - this._target.visit(); - } - - var locChildren = this._children; - if (locChildren && locChildren.length > 0) { - var childLen = locChildren.length; - this.sortAllChildren(); - // draw children - for (var i = 0; i < childLen; i++) { - var child = locChildren[i]; - child && child.visit(); - } - } - - if(isWebGL){ - if(locGrid && locGrid._active){ - //cc.director.setProjection(beforeProjectionType); - } - if(this._gridEndCommand) - cc.renderer.pushRenderCommand(this._gridEndCommand); - currentStack.top = currentStack.stack.pop(); - } - }, - _transformForWebGL: function () { //optimize performance for javascript var t4x4 = this._transform4x4, topMat4 = cc.current_stack.top; @@ -179,14 +98,17 @@ cc.NodeGrid = cc.Node.extend({ this._camera.locate(); } } + }, + + _createRenderCmd: function(){ + if (cc._renderType === cc._RENDER_TYPE_WEBGL) + return new cc.NodeGrid.WebGLRenderCmd(this); + else + return null; // cc.NodeGrid doesn't support Canvas mode. } }); var _p = cc.NodeGrid.prototype; -if (cc._renderType === cc._RENDER_TYPE_WEBGL) { - _p.transform = _p._transformForWebGL; - //The parent class method directly from canvas model -} // Extended property /** @expose */ _p.grid; diff --git a/cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js b/cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js new file mode 100644 index 0000000000..c0e5bc437b --- /dev/null +++ b/cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js @@ -0,0 +1,96 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + cc.NodeGrid.WebGLRenderCmd = function(renderable){ + cc.Node.WebGLRenderCmd.call(this, renderable); + this._needDraw = false; + this._gridBeginCommand = new cc.CustomRenderCmd(this, this.onGridBeginDraw); + this._gridEndCommand = new cc.CustomRenderCmd(this, this.onGridEndDraw); + }; + + var proto = cc.NodeGrid.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + proto.constructor = cc.NodeGrid.WebGLRenderCmd; + + proto.visit = function(parentCmd) { + var node = this._node; + // quick return if not visible + if (!node._visible) + return; + + parentCmd = parentCmd || this.getParentRenderCmd(); + if (node._parent && node._parent._renderCmd) + this._curLevel = node._parent._renderCmd._curLevel + 1; + + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + this._syncStatus(parentCmd); + currentStack.top = this._stackMatrix; + + /*var beforeProjectionType = cc.director.PROJECTION_DEFAULT; + if (locGrid && locGrid._active) { + //var backMatrix = new cc.kmMat4(); + //cc.kmMat4Assign(backMatrix, this._stackMatrix); + + beforeProjectionType = cc.director.getProjection(); + //locGrid.set2DProjection(); + + //reset this._stackMatrix to current_stack.top + //cc.kmMat4Assign(currentStack.top, backMatrix); + }*/ + cc.renderer.pushRenderCommand(this._gridBeginCommand); + + if (node._target) + node._target.visit(); + + var locChildren = node._children; + if (locChildren && locChildren.length > 0) { + var childLen = locChildren.length; + node.sortAllChildren(); + // draw children + for (var i = 0; i < childLen; i++) { + var child = locChildren[i]; + child && child.visit(); + } + } + + //if (locGrid && locGrid._active) { + //cc.director.setProjection(beforeProjectionType); + //} + cc.renderer.pushRenderCommand(this._gridEndCommand); + currentStack.top = currentStack.stack.pop(); + }; + + proto.onGridBeginDraw = function(){ + var locGrid = this._node.grid; + if (locGrid && locGrid._active) + locGrid.beforeDraw(); + }; + + proto.onGridEndDraw = function(){ + var locGrid = this._node.grid; + if (locGrid && locGrid._active) + locGrid.afterDraw(this._node); + }; +})(); diff --git a/moduleConfig.json b/moduleConfig.json index 1c18718c23..d981b2eadc 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -172,7 +172,8 @@ "node-grid" : [ "core", - "cocos2d/node-grid/CCNodeGrid.js" + "cocos2d/node-grid/CCNodeGrid.js", + "cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js" ], "parallax" : [ "core", From 7d927db637e6572b4557145cc78728e862c6e17f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 19:56:57 +0800 Subject: [PATCH 1006/1564] Issue #2416: CCScrollView renderCmd --- extensions/gui/scrollview/CCScrollView.js | 187 +----------------- .../scrollview/CCScrollViewCanvasRenderCmd.js | 102 ++++++++++ .../scrollview/CCScrollViewWebGLRenderCmd.js | 107 ++++++++++ moduleConfig.json | 2 + 4 files changed, 221 insertions(+), 177 deletions(-) create mode 100644 extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js create mode 100644 extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 3b6e96af08..854bf08953 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -102,9 +102,6 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ _touchListener: null, _className:"ScrollView", - _beforeDrawCmd:null, - _afterDrawCmd:null, - /** * @contructor * @param size @@ -123,23 +120,6 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._parentScissorRect = new cc.Rect(0,0,0,0); this._tmpViewRect = new cc.Rect(0,0,0,0); - if(cc._renderType === cc._RENDER_TYPE_CANVAS){ - this.startCmd = new cc.CustomRenderCmd(this, function(ctx, scaleX, scaleY){ - ctx = ctx || cc._renderContext; - ctx.save(); - ctx.save(); - this.transform(); - var t = this._worldTransform; - ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); - cc.ScrollView.prototype._beforeDraw.call(this); - }); - this.endCmd = new cc.CustomRenderCmd(this, function(ctx){ - ctx = ctx || cc._renderContext; - cc.ScrollView.prototype._afterDraw.call(this); - ctx.restore(); - }); - } - if(container != undefined) this.initWithViewSize(size, container); else @@ -147,13 +127,6 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ }, - _initRendererCmd:function () { - if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - this._beforeDrawCmd = new cc.CustomRenderCmd(this, this._onBeforeDraw); - this._afterDrawCmd = new cc.CustomRenderCmd(this, this._onAfterDraw); - } - }, - init:function () { return this.initWithViewSize(cc.size(200, 200), null); }, @@ -609,91 +582,12 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._clippingToBounds = clippingToBounds; }, - visit:function (ctx) { + visit:function (parentCmd) { // quick return if not visible if (!this.isVisible()) return; - var context = ctx || cc._renderContext; - var i, locChildren = this._children, selChild, childrenLen; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { -// context.save(); - this.transform(context); - if(this.startCmd) - cc.renderer.pushRenderCommand(this.startCmd); -// this._beforeDraw(context); - - if (locChildren && locChildren.length > 0) { - childrenLen = locChildren.length; - this.sortAllChildren(); - // draw children zOrder < 0 - for (i = 0; i < childrenLen; i++) { - selChild = locChildren[i]; - if (selChild && selChild._localZOrder < 0) - selChild.visit(context); - else - break; - } - -// this.draw(context); // self draw - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - - // draw children zOrder >= 0 - for (; i < childrenLen; i++) - locChildren[i].visit(context); - } else{ -// this.draw(context); // self draw - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - } - -// this._afterDraw(); - if(this.endCmd) - cc.renderer.pushRenderCommand(this.endCmd); - -// context.restore(); - } else { - cc.kmGLPushMatrix(); -// var locGrid = this.grid; -// if (locGrid && locGrid.isActive()) { -// locGrid.beforeDraw(); -// this.transformAncestors(); -// } - - this.transform(context); - this._beforeDraw(context); - if (locChildren && locChildren.length > 0) { - childrenLen = locChildren.length; - // draw children zOrder < 0 - for (i = 0; i < childrenLen; i++) { - selChild = locChildren[i]; - if (selChild && selChild._localZOrder < 0) - selChild.visit(); - else - break; - } - - // this draw - //this.draw(context); - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - - // draw children zOrder >= 0 - for (; i < childrenLen; i++) - locChildren[i].visit(); - } else{ - //this.draw(context); - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - } - - this._afterDraw(context); -// if (locGrid && locGrid.isActive()) -// locGrid.afterDraw(this); - - cc.kmGLPopMatrix(); - } + this._renderCmd.visit(parentCmd); }, addChild:function (child, zOrder, tag) { @@ -844,75 +738,6 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ } }, - /** - * clip this view so that outside of the visible bounds can be hidden. - */ - _beforeDraw:function (context) { - if (this._clippingToBounds) { - this._scissorRestored = false; - var locEGLViewer = cc.view; - - var scaleX = this.getScaleX(); - var scaleY = this.getScaleY(); - - var ctx = context || cc._renderContext; - if (cc._renderType === cc._RENDER_TYPE_CANVAS) { - var getWidth = (this._viewSize.width * scaleX) * locEGLViewer.getScaleX(); - var getHeight = (this._viewSize.height * scaleY) * locEGLViewer.getScaleY(); - var startX = 0; - var startY = 0; - - ctx.beginPath(); - ctx.rect(startX, startY, getWidth, -getHeight); - ctx.restore(); - ctx.clip(); - ctx.closePath(); - } else { - cc.renderer.pushRenderCommand(this._beforeDrawCmd); - } - } - }, - - _onBeforeDraw:function(){ - var EGLViewer = cc.view; - var frame = this._getViewRect(); - if(EGLViewer.isScissorEnabled()){ - this._scissorRestored = true; - this._parentScissorRect = EGLViewer.getScissorRect(); - //set the intersection of m_tParentScissorRect and frame as the new scissor rect - if (cc.rectIntersection(frame, this._parentScissorRect)) { - var locPSRect = this._parentScissorRect; - var x = Math.max(frame.x, locPSRect.x); - var y = Math.max(frame.y, locPSRect.y); - var xx = Math.min(frame.x + frame.width, locPSRect.x + locPSRect.width); - var yy = Math.min(frame.y + frame.height, locPSRect.y + locPSRect.height); - EGLViewer.setScissorInPoints(x, y, xx - x, yy - y); - } - }else{ - var ctx = cc._renderContext; - ctx.enable(ctx.SCISSOR_TEST); - //clip - EGLViewer.setScissorInPoints(frame.x, frame.y, frame.width, frame.height); - } - }, - /** - * retract what's done in beforeDraw so that there's no side effect to - * other nodes. - */ - _afterDraw:function (context) { - if (this._clippingToBounds && cc._renderType === cc._RENDER_TYPE_WEBGL) { - cc.renderer.pushRenderCommand(this._afterDrawCmd); - } - }, - _onAfterDraw:function(){ - if (this._scissorRestored) { //restore the parent's scissor rect - var rect = this._parentScissorRect; - cc.view.setScissorInPoints(rect.x, rect.y, rect.width, rect.height) - }else{ - var ctx = cc._renderContext; - ctx.disable(ctx.SCISSOR_TEST); - } - }, /** * Zoom handling */ @@ -949,6 +774,14 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ locViewRect.width = locViewSize.width * scaleX; locViewRect.height = locViewSize.height * scaleY; return locViewRect; + }, + + _createRenderCmd: function(){ + if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + return new cc.ScrollView.CanvasRenderCmd(this); + } else { + return new cc.ScrollView.WebGLRenderCmd(this); + } } }); diff --git a/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js b/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js new file mode 100644 index 0000000000..15ee434945 --- /dev/null +++ b/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js @@ -0,0 +1,102 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function() { + cc.ScrollView.CanvasRenderCmd = function(renderable){ + cc.Layer.CanvasRenderCmd.call(this, renderable); + this._needDraw = false; + + this.startCmd = new cc.CustomRenderCmd(this, this._startCmd); + this.endCmd = new cc.CustomRenderCmd(this, this._endCmd); + }; + + var proto = cc.ScrollView.CanvasRenderCmd.prototype = Object.create(cc.Layer.CanvasRenderCmd.prototype); + proto.constructor = cc.ScrollView.CanvasRenderCmd; + + proto._startCmd = function(ctx, scaleX, scaleY){ + ctx = ctx || cc._renderContext; + ctx.save(); + ctx.save(); + this.transform(); + var t = this._worldTransform; + ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); + + + if (this._clippingToBounds) { + this._scissorRestored = false; + + var locScaleX = this.getScaleX(); + var locScaleY = this.getScaleY(); + + ctx = ctx || cc._renderContext; + + var getWidth = (this._viewSize.width * locScaleX) * scaleX; + var getHeight = (this._viewSize.height * locScaleY) * scaleY; + var startX = 0; + var startY = 0; + + ctx.beginPath(); + ctx.rect(startX, startY, getWidth, -getHeight); + ctx.restore(); + ctx.clip(); + ctx.closePath(); + + } + }; + + proto._endCmd = function(ctx){ + ctx = ctx || cc._renderContext; + ctx.restore(); + }; + + proto.visit = function(parentCmd){ + var node = this._node; + var i, locChildren = node._children, selChild, childrenLen; + + this.transform(parentCmd); + + cc.renderer.pushRenderCommand(this.startCmd); + + if (locChildren && locChildren.length > 0) { + childrenLen = locChildren.length; + node.sortAllChildren(); + // draw children zOrder < 0 + for (i = 0; i < childrenLen; i++) { + selChild = locChildren[i]; + if (selChild && selChild._localZOrder < 0) + selChild._renderCmd.visit(); + else + break; + } + + // draw children zOrder >= 0 + for (; i < childrenLen; i++) + locChildren[i]._renderCmd.visit(); + } + + cc.renderer.pushRenderCommand(this.endCmd); + + }; + +})(); \ No newline at end of file diff --git a/extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js b/extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js new file mode 100644 index 0000000000..3dacba20f4 --- /dev/null +++ b/extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js @@ -0,0 +1,107 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function() { + cc.ScrollView.WebGLRenderCmd = function(renderable){ + cc.Layer.WebGLRenderCmd.call(this, renderable); + this._needDraw = false; + + this.startCmd = new cc.CustomRenderCmd(this, this._startCmd); + this.endCmd = new cc.CustomRenderCmd(this, this._endCmd); + }; + + var proto = cc.ScrollView.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype); + proto.constructor = cc.ScrollView.WebGLRenderCmd; + + proto._startCmd = function(){ + var node = this._node; + var EGLViewer = cc.view; + var frame = node._getViewRect(); + if(EGLViewer.isScissorEnabled()){ + node._scissorRestored = true; + node._parentScissorRect = EGLViewer.getScissorRect(); + //set the intersection of m_tParentScissorRect and frame as the new scissor rect + if (cc.rectIntersection(frame, node._parentScissorRect)) { + var locPSRect = node._parentScissorRect; + var x = Math.max(frame.x, locPSRect.x); + var y = Math.max(frame.y, locPSRect.y); + var xx = Math.min(frame.x + frame.width, locPSRect.x + locPSRect.width); + var yy = Math.min(frame.y + frame.height, locPSRect.y + locPSRect.height); + EGLViewer.setScissorInPoints(x, y, xx - x, yy - y); + } + }else{ + var ctx = cc._renderContext; + ctx.enable(ctx.SCISSOR_TEST); + //clip + EGLViewer.setScissorInPoints(frame.x, frame.y, frame.width, frame.height); + } + }; + + proto._endCmd = function(){ + var node = this._node; + if (node._scissorRestored) { //restore the parent's scissor rect + var rect = node._parentScissorRect; + cc.view.setScissorInPoints(rect.x, rect.y, rect.width, rect.height) + }else{ + var ctx = cc._renderContext; + ctx.disable(ctx.SCISSOR_TEST); + } + }; + + proto.visit = function(parendCmd){ + var node = this._node; + + var i, locChildren = node._children, selChild, childrenLen; + + cc.kmGLPushMatrix(); + + this.transform(parendCmd); + + if (node._clippingToBounds) { + cc.renderer.pushRenderCommand(this.startCmd); + } + + if (locChildren && locChildren.length > 0) { + childrenLen = locChildren.length; + // draw children zOrder < 0 + for (i = 0; i < childrenLen; i++) { + selChild = locChildren[i]; + if (selChild && selChild._localZOrder < 0) + selChild._renderCmd.visit(); + else + break; + } + + // draw children zOrder >= 0 + for (; i < childrenLen; i++) + locChildren[i]._renderCmd.visit(); + } + + if (node._clippingToBounds) { + cc.renderer.pushRenderCommand(this.endCmd); + } + + cc.kmGLPopMatrix(); + }; +})(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 1c18718c23..0d40a2c09f 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -417,6 +417,8 @@ "extensions/gui/control-extension/CCControlStepper.js", "extensions/gui/control-extension/CCControlPotentiometer.js", "extensions/gui/scrollview/CCScrollView.js", + "extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js", + "extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js", "extensions/gui/scrollview/CCSorting.js", "extensions/gui/scrollview/CCTableView.js" ], From 3219fd86c2c1c26cdbfd5201ccdf21c98882c8e5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 20:20:43 +0800 Subject: [PATCH 1007/1564] Issue #2416: Repair recycle call setDirtyFlag --- cocos2d/tilemap/CCTMXLayer.js | 2 +- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index bf03f6fe63..dac70221e9 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -861,7 +861,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this._reusedTile.initWithTexture(this._renderCmd._texture, rect, false); this._reusedTile.batchNode = this; this._reusedTile.parent = this; - this._reusedTile._cachedParent = this; + this._reusedTile._cachedParent = this._renderCmd; } return this._reusedTile; }, diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index bba2dfeb87..9f635694ab 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -39,7 +39,6 @@ tempTexture.handleLoadedTexture(); this._cacheTexture = tempTexture; // This class uses cache, so its default cachedParent should be himself - this._cachedParent = this; this._cacheDirty = false; }; From 06a4b5de83965018af0833a53a62e8b15985e773 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 1 Dec 2014 20:34:36 +0800 Subject: [PATCH 1008/1564] Issue #2416: Clipping texture must be update --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 1 - cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 2e02546cb7..99113dc614 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -440,7 +440,6 @@ cc.Node.RenderCmd.prototype = { if (transformDirty){ //update the transform this.transform(parentCmd); - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; } }; diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 8ae17abb66..30a926cf74 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -128,6 +128,7 @@ if (locFlag & flags.transformDirty) { //update the transform this.transform(parentCmd); + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; } }; From 38005228ba801fd6c010a57c09c982df76570675 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 1 Dec 2014 21:22:09 +0800 Subject: [PATCH 1009/1564] Issue #2416: Let effect advanced works. --- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 11 +++-- .../labelttf/CCLabelTTFCanvasRenderCmd.js | 40 +++++++++--------- .../core/labelttf/CCLabelTTFWebGLRenderCmd.js | 27 ++++++++++-- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 42 +++++++++---------- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 21 ++++++++++ cocos2d/effects/CCGrid.js | 26 ++++++++---- .../CCProgressTimerWebGLRenderCmd.js | 4 +- cocos2d/shaders/CCGLProgram.js | 7 +++- 8 files changed, 117 insertions(+), 61 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 91c62b5f71..338629934b 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -125,10 +125,10 @@ if(colorDirty || opacityDirty) this._updateColor(); - if (locFlag & flags.transformDirty) { + //if (locFlag & flags.transformDirty) { //need update the stackMatrix every calling visit, because when projection changed, need update all scene graph element. //update the transform - this.transform(parentCmd); - } + this.transform(parentCmd); + //} }; proto._updateColor = function(){}; @@ -182,7 +182,10 @@ // Convert 3x3 into 4x4 matrix var trans = this.getNodeToParentTransform(); - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + + if(cc.Node._dirtyFlags.transformDirty & this._dirtyFlag) + this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 495c388523..37908f7714 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -74,26 +74,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; this.transform(this.getParentRenderCmd(), true); }; - proto._syncStatus = function (parentCmd) { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - var colorDirty = locFlag & flags.colorDirty, - opacityDirty = locFlag & flags.opacityDirty; - if (colorDirty) - this._syncDisplayColor(); - if (opacityDirty) - this._syncDisplayOpacity(); - - if(colorDirty || opacityDirty){ - this._setColorsString(); - this._updateColor(); - this._updateTexture(); - }else if(locFlag & flags.textDirty) - this._updateTexture(); - - if (locFlag & flags.transformDirty) //update the transform - this.transform(parentCmd); - }; - proto._getLabelContext = function () { if (this._labelContext) return this._labelContext; @@ -383,6 +363,26 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var proto = cc.LabelTTF.CanvasRenderCmd.prototype; proto.constructor = cc.LabelTTF.CanvasRenderCmd; + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if (colorDirty) + this._syncDisplayColor(); + if (opacityDirty) + this._syncDisplayOpacity(); + + if(colorDirty || opacityDirty){ + this._setColorsString(); + this._updateColor(); + this._updateTexture(); + }else if(locFlag & flags.textDirty) + this._updateTexture(); + + if (locFlag & flags.transformDirty) //update the transform + this.transform(parentCmd); + }; + proto._setColorsString = function () { this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); var locDisplayColor = this._displayedColor, node = this._node, diff --git a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js index 14b3cb5dd2..0809f5cc66 100644 --- a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js @@ -30,11 +30,11 @@ this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM)); }; - cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); - cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.WebGLRenderCmd.prototype); //multi-inherit - cc.LabelTTF.WebGLRenderCmd.prototype.constructor = cc.LabelTTF.WebGLRenderCmd; + var proto = cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); + cc.inject(cc.LabelTTF.RenderCmd.prototype, proto); //multi-inherit + proto.constructor = cc.LabelTTF.WebGLRenderCmd; - cc.LabelTTF.WebGLRenderCmd.prototype._setColorsString = function () { + proto._setColorsString = function () { this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); var node = this._node; var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; @@ -42,4 +42,23 @@ this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; }; + + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if (colorDirty) + this._syncDisplayColor(); + if (opacityDirty) + this._syncDisplayOpacity(); + + if(colorDirty || opacityDirty){ + this._setColorsString(); + this._updateColor(); + this._updateTexture(); + }else if(locFlag & flags.textDirty) + this._updateTexture(); + + this.transform(parentCmd); + }; })(); \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index a3253c5a27..57b091205d 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -332,27 +332,6 @@ this.transform(null, true); } - if (colorDirty || opacityDirty || (locFlag & flags.gradientDirty)){ - this._updateColor(); - } - }, - - _syncStatus: function (parentCmd) { - var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; - var colorDirty = locFlag & flags.colorDirty, - opacityDirty = locFlag & flags.opacityDirty; - - if (colorDirty) - this._syncDisplayColor(); - - if (opacityDirty) - this._syncDisplayOpacity(); - - if (locFlag & flags.transformDirty) { - //update the transform - this.transform(parentCmd); - } - if (colorDirty || opacityDirty || (locFlag & flags.gradientDirty)){ this._updateColor(); } @@ -411,6 +390,27 @@ cc.g_NumberOfDraws++; }; + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + + if (colorDirty) + this._syncDisplayColor(); + + if (opacityDirty) + this._syncDisplayOpacity(); + + if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + } + + if (colorDirty || opacityDirty || (locFlag & flags.gradientDirty)){ + this._updateColor(); + } + }; + proto._updateColor = function(){ var node = this._node; var contentSize = node._contentSize; diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index a0b1b0ca61..e61dfa603c 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -165,6 +165,27 @@ cc.inject(cc.LayerGradient.RenderCmd, proto); proto.constructor = cc.LayerGradient.WebGLRenderCmd; + proto._syncStatus = function (parentCmd) { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + + if (colorDirty) + this._syncDisplayColor(); + + if (opacityDirty) + this._syncDisplayOpacity(); + + //if (locFlag & flags.transformDirty) { + //update the transform + this.transform(parentCmd); + //} + + if (colorDirty || opacityDirty || (locFlag & flags.gradientDirty)){ + this._updateColor(); + } + }; + proto._updateColor = function(){ this._dirtyFlag ^= cc.Node._dirtyFlags.gradientDirty; var _t = this, node = this._node; diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index ed7e82f877..04719e1df9 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -223,16 +223,26 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ if (target && target.getCamera().isDirty()) { var offset = target.getAnchorPointInPoints(); + //TODO hack + var stackMatrix = target._renderCmd._stackMatrix; // // XXX: Camera should be applied in the AnchorPoint // - cc.kmGLTranslatef(offset.x, offset.y, 0); - target.getCamera().locate(); - cc.kmGLTranslatef(-offset.x, -offset.y, 0); + //cc.kmGLTranslatef(offset.x, offset.y, 0); + var translation = new cc.kmMat4(); + cc.kmMat4Translation(translation, offset.x, offset.y, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + + //target.getCamera().locate(); + target._camera._locateForRenderer(stackMatrix); + + //cc.kmGLTranslatef(-offset.x, -offset.y, 0); + cc.kmMat4Translation(translation, -offset.x, -offset.y, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); } cc.glBindTexture2D(this._texture); - this.blit(); + this.blit(target); }, blit:function () { @@ -360,8 +370,8 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ var n = this._gridSize.width * this._gridSize.height; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS); this._shaderProgram.use(); - this._shaderProgram.setUniformsForBuiltins(); - //this._shaderProgram._setUniformsForBuiltinsForRenderer(target); + //this._shaderProgram.setUniformsForBuiltins(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(target._renderCmd._stackMatrix); var gl = cc._renderContext, locDirty = this._dirty; // @@ -589,8 +599,8 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ var n = this._gridSize.width * this._gridSize.height; this._shaderProgram.use(); - this._shaderProgram.setUniformsForBuiltins(); - //this._shaderProgram._setUniformsForBuiltinsForRenderer(target); + this._shaderProgram._setUniformForMVPMatrixWithMat4(target._renderCmd._stackMatrix); + //this._shaderProgram.setUniformsForBuiltins(); // // Attributes diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index e0de1baa52..9ce1b70ca6 100644 --- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -106,10 +106,10 @@ this._updateColor(); } - if (locFlag & flags.transformDirty) { + //if (locFlag & flags.transformDirty) { //update the transform this.transform(parentCmd); - } + //} }; proto.updateStatus = function () { diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 9a035b94cc..831b91fd7a 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -573,6 +573,9 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ }, _setUniformsForBuiltinsForRenderer: function (node) { + if(!node || !node._renderCmd) + return; + var matrixP = new cc.kmMat4(); //var matrixMV = new cc.kmMat4(); var matrixMVP = new cc.kmMat4(); @@ -580,10 +583,10 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, matrixP); //cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, node._stackMatrix); - cc.kmMat4Multiply(matrixMVP, matrixP, node._stackMatrix); + cc.kmMat4Multiply(matrixMVP, matrixP, node._renderCmd._stackMatrix); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], matrixP.mat, 1); - this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], node._stackMatrix.mat, 1); + this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], node._renderCmd._stackMatrix.mat, 1); this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], matrixMVP.mat, 1); if (this._usesTime) { From f888ac007e084fb676df4c1652e30022daceb777 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 2 Dec 2014 11:02:54 +0800 Subject: [PATCH 1010/1564] Issue #2416: Bit operation error --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 14 +++++++------- cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js | 4 ++-- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 2 +- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 2 +- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 2 +- .../CCProgressTimerWebGLRenderCmd.js | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 99113dc614..d7538fd6bb 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -149,7 +149,7 @@ cc.Node.RenderCmd.prototype = { } } this._cascadeColorEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.colorDirty ^ this._dirtyFlag; }, _updateDisplayOpacity: function (parentOpacity) { @@ -183,7 +183,7 @@ cc.Node.RenderCmd.prototype = { } } this._cascadeOpacityEnabledDirty = false; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty ^ this._dirtyFlag; }, _syncDisplayColor : function (parentColor) { @@ -198,7 +198,7 @@ cc.Node.RenderCmd.prototype = { locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.colorDirty ^ this._dirtyFlag; }, _syncDisplayOpacity : function (parentOpacity) { @@ -210,7 +210,7 @@ cc.Node.RenderCmd.prototype = { parentOpacity = locParent.getDisplayedOpacity(); } this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty ^ this._dirtyFlag; }, _updateColor: function(){}, @@ -363,7 +363,7 @@ cc.Node.RenderCmd.prototype = { this._transform = cc.affineTransformConcat(t, node._additionalTransform); node._additionalTransformDirty = false; } - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; } return this._transform; }; @@ -456,7 +456,7 @@ cc.Node.RenderCmd.prototype = { locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); - //this._dirtyFlag ^= cc.Node._dirtyFlags.colorDirty; + //this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.colorDirty ^ this._dirtyFlag; }; proto._syncDisplayOpacity = function (parentOpacity) { @@ -468,7 +468,7 @@ cc.Node.RenderCmd.prototype = { parentOpacity = locParent.getDisplayedOpacity(); } this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; - //this._dirtyFlag ^= cc.Node._dirtyFlags.opacityDirty; + //this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty ^ this._dirtyFlag; }; proto.setDirtyFlag = function (dirtyFlag) { diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 30a926cf74..428d9449a6 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -128,7 +128,7 @@ if (locFlag & flags.transformDirty) { //update the transform this.transform(parentCmd); - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; } }; @@ -183,7 +183,7 @@ // Convert 3x3 into 4x4 matrix var trans = this.getNodeToParentTransform(); - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 495c388523..0dd1821dd9 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -124,7 +124,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; }; proto._updateTexture = function () { - this._dirtyFlag ^= cc.Node._dirtyFlags.textDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.textDirty ^ this._dirtyFlag; var node = this._node; var locContext = this._getLabelContext(), locLabelCanvas = this._labelCanvas; var locContentSize = node._contentSize; diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index a3253c5a27..09257a9d54 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -415,7 +415,7 @@ var node = this._node; var contentSize = node._contentSize; var locAlongVector = node._alongVector, tWidth = contentSize.width * 0.5, tHeight = contentSize.height * 0.5; - this._dirtyFlag ^= cc.Node._dirtyFlags.gradientDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty ^ this._dirtyFlag; this._startPoint.x = tWidth * (-locAlongVector.x) + tWidth; this._startPoint.y = tHeight * locAlongVector.y - tHeight; diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index a0b1b0ca61..ba3b653c69 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -166,7 +166,7 @@ proto.constructor = cc.LayerGradient.WebGLRenderCmd; proto._updateColor = function(){ - this._dirtyFlag ^= cc.Node._dirtyFlags.gradientDirty; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty ^ this._dirtyFlag; var _t = this, node = this._node; var locAlongVector = node._alongVector; var h = cc.pLength(locAlongVector); diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index e0de1baa52..55fde24ad5 100644 --- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -93,12 +93,12 @@ if (colorDirty){ spriteCmd._syncDisplayColor(); - this._dirtyFlag ^= flags.colorDirty; + this._dirtyFlag = this._dirtyFlag & flags.colorDirty ^ this._dirtyFlag; } if (opacityDirty){ spriteCmd._syncDisplayOpacity(); - this._dirtyFlag ^= flags.opacityDirty; + this._dirtyFlag = this._dirtyFlag & flags.opacityDirty ^ this._dirtyFlag; } if(colorDirty || opacityDirty){ @@ -125,12 +125,12 @@ if(colorDirty){ spriteCmd._updateDisplayColor(); - this._dirtyFlag ^= flags.colorDirty; + this._dirtyFlag = this._dirtyFlag & flags.colorDirty ^ this._dirtyFlag; } if(opacityDirty){ spriteCmd._updateDisplayOpacity(); - this._dirtyFlag ^= flags.opacityDirty; + this._dirtyFlag = this._dirtyFlag & flags.opacityDirty ^ this._dirtyFlag; } if(colorDirty || opacityDirty){ From d4c5678afd6f1b740a0fd4fbdbab3fffcc0cb50b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 2 Dec 2014 11:05:06 +0800 Subject: [PATCH 1011/1564] Issue #2416: LabelTTF setting state error --- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 0dd1821dd9..9ccb069386 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -384,7 +384,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; proto.constructor = cc.LabelTTF.CanvasRenderCmd; proto._setColorsString = function () { - this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); var locDisplayColor = this._displayedColor, node = this._node, locDisplayedOpacity = this._displayedOpacity, locShadowColor = node._shadowColor || this._displayedColor; @@ -396,4 +395,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", " + locDisplayedOpacity / 255 + ")"; }; + + proto._updateColor = function(){}; })(); \ No newline at end of file From 526ec26faba6c47c94c70e05e8c788c55389f62c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 2 Dec 2014 14:31:42 +0800 Subject: [PATCH 1012/1564] Issue #2416: Particle transform error --- cocos2d/particle/CCParticleSystemCanvasRenderCmd.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js index 837d595670..5d13c19dc2 100644 --- a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js @@ -76,6 +76,9 @@ context.save(); //transform + var parent = node._parent; + var parentCmd = parent ? parent._renderCmd : null; + this.transform(parentCmd); context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); if (node.isBlendAdditive()) context.globalCompositeOperation = 'lighter'; From 216f931bd425fff635d27ea09b1d092aa4d9d1e5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 2 Dec 2014 14:50:09 +0800 Subject: [PATCH 1013/1564] Issue #2416: Repair the problem of ScrollView --- .../gui/scrollview/CCScrollViewCanvasRenderCmd.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js b/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js index 15ee434945..90e87f8083 100644 --- a/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js +++ b/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js @@ -35,6 +35,7 @@ proto.constructor = cc.ScrollView.CanvasRenderCmd; proto._startCmd = function(ctx, scaleX, scaleY){ + var node = this._node; ctx = ctx || cc._renderContext; ctx.save(); ctx.save(); @@ -43,16 +44,16 @@ ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); - if (this._clippingToBounds) { + if (this._node._clippingToBounds) { this._scissorRestored = false; - var locScaleX = this.getScaleX(); - var locScaleY = this.getScaleY(); + var locScaleX = node.getScaleX(); + var locScaleY = node.getScaleY(); ctx = ctx || cc._renderContext; - var getWidth = (this._viewSize.width * locScaleX) * scaleX; - var getHeight = (this._viewSize.height * locScaleY) * scaleY; + var getWidth = (node._viewSize.width * locScaleX) * scaleX; + var getHeight = (node._viewSize.height * locScaleY) * scaleY; var startX = 0; var startY = 0; From 12c822423de0828bf5c90fbbdb67a07fc84b1f8a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 2 Dec 2014 15:55:17 +0800 Subject: [PATCH 1014/1564] Issue #2416: Fixed a problem that position initialization error --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 3 ++- .../gui/control-extension/CCScale9SpriteCanvasRenderCmd.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index d7538fd6bb..e89123cd9c 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -231,6 +231,7 @@ cc.Node.RenderCmd.prototype = { if(locFlag & flags.transformDirty){ //update the transform this.transform(this.getParentRenderCmd(), true); + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; } } }; @@ -363,7 +364,6 @@ cc.Node.RenderCmd.prototype = { this._transform = cc.affineTransformConcat(t, node._additionalTransform); node._additionalTransformDirty = false; } - this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; } return this._transform; }; @@ -440,6 +440,7 @@ cc.Node.RenderCmd.prototype = { if (transformDirty){ //update the transform this.transform(parentCmd); + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; } }; diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js index 909bcc79f7..fb3e783f04 100644 --- a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -54,7 +54,7 @@ rescaledWidth: centerWidth * horizontalScale, rescaledHeight: centerHeight * verticalScale} }; - proto.visit = function(){ + proto.visit = function(parentCmd){ var node = this._node; if(!node._visible){ return; @@ -68,7 +68,7 @@ node._scale9Dirty = false; this._cacheScale9Sprite(); - cc.Node.CanvasRenderCmd.prototype.visit.call(this, ctx); + cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); }; proto.transform = function(parentCmd){ From bc4ad2dc84396665a26998ad93fe94ac67cc477c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 2 Dec 2014 16:21:18 +0800 Subject: [PATCH 1015/1564] Issue #2416: Correct PhysicsSprite's mistake. --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 2 - .../core/sprites/CCSpriteWebGLRenderCmd.js | 18 +-- cocos2d/physics/CCPhysicsSprite.js | 8 +- .../physics/CCPhysicsSpriteWebGLRenderCmd.js | 4 + extensions/cocostudio/armature/CCArmature.js | 108 +----------------- .../armature/CCArmatureCanvasRenderCmd.js | 65 ++++++++++- .../armature/CCArmatureWebGLRenderCmd.js | 55 +++++---- .../cocostudio/armature/display/CCSkin.js | 4 - extensions/spine/CCSkeletonWebGLRenderCmd.js | 2 +- 9 files changed, 105 insertions(+), 161 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 2e02546cb7..789700f189 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -363,7 +363,6 @@ cc.Node.RenderCmd.prototype = { this._transform = cc.affineTransformConcat(t, node._additionalTransform); node._additionalTransformDirty = false; } - this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; } return this._transform; }; @@ -442,7 +441,6 @@ cc.Node.RenderCmd.prototype = { this.transform(parentCmd); this._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; } - }; proto._syncDisplayColor = function (parentColor) { diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index e6fc156856..54d922b209 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -290,9 +290,9 @@ } if (texture) - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); else - node.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); if (!node._batchNode && node._texture != texture) { node._texture = texture; @@ -377,8 +377,7 @@ if (node._hasChildren) node._arrayMakeObjectsPerformSelector(node._children, cc.Node._stateCallbackType.updateTransform); - //TODO - /*if (cc.SPRITE_DEBUG_DRAW) { + /*if (cc.SPRITE_DEBUG_DRAW) { //TODO // draw bounding box var vertices = [ cc.p(_t._quad.bl.vertices.x, _t._quad.bl.vertices.y), @@ -457,10 +456,14 @@ } cc.g_NumberOfDraws++; - //TODO - /*if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode) + if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode) return; + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + //cc.kmGLPushMatrixWitMat4(node._stackMatrix); + cc.current_stack.stack.push(cc.current_stack.top); + cc.current_stack.top = this._stackMatrix; + if (cc.SPRITE_DEBUG_DRAW === 1 || node._showNode) { // draw bounding box var locQuad = this._quad; @@ -478,6 +481,7 @@ var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; cc._drawingUtil.drawPoly(verticesG2, 4, true); - } */// CC_SPRITE_DEBUG_DRAW + } // CC_SPRITE_DEBUG_DRAW + cc.current_stack.top = cc.current_stack.stack.pop(); }; })(); \ No newline at end of file diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 20f8e74d99..d415a281c5 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -373,16 +373,10 @@ } }, _syncRotation:function () { - if (this._rotationRadiansX != -this._body.a) { + if (this._rotationX != -cc.radiansToDegrees(this._body.a)) { cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegrees(this._body.a)); } }, - /** - * @deprecated since v3.0, please use getNodeToParentTransform instead - */ - nodeToParentTransform: function(){ - return this.getNodeToParentTransform(); - }, /** * get the affine transform matrix of node to parent coordinate frame diff --git a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js index c45b80f8f6..44847d998b 100644 --- a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js @@ -79,4 +79,8 @@ return this._transform; }; + proto.updateTransform = function(){ + this._dirty = this._node.isDirty(); + cc.Sprite.WebGLRenderCmd.prototype.updateTransform.call(this); + }; })(); \ No newline at end of file diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index fb2c1b21d6..e2d19f4cdb 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -52,7 +52,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ _body: null, _blendFunc: null, _className: "Armature", - _realAnchorPointInPoints: null, /** * Create a armature node. @@ -69,7 +68,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureIndexDic = {}; this._offsetPoint = cc.p(0, 0); this._armatureTransformDirty = true; - this._realAnchorPointInPoints = cc.p(0, 0); + this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; name && ccs.Armature.prototype.init.call(this, name, parentBone); }, @@ -90,7 +89,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._boneDic = {}; this._topBoneList.length = 0; - this._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; + this._name = name || ""; var armatureDataManager = ccs.armatureDataManager; @@ -276,65 +275,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.setAnchorPoint(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height); }, - /** - * Sets armature's anchor point, because it need to consider offset point, so here is the override function. - * @override - * @param {cc.Point|Number} point point or x of point - * @param {Number} [y] y of point - */ - setAnchorPoint: function(point, y){ - var cmd = this._renderCmd; - var ax, ay; - if(y !== undefined){ - ax = point; - ay = y; - }else{ - ax = point.x; - ay = point.y; - } - var locAnchorPoint = this._anchorPoint; - if(ax != locAnchorPoint.x || ay != locAnchorPoint.y){ - var contentSize = this._contentSize ; - locAnchorPoint.x = ax; - locAnchorPoint.y = ay; - cmd._anchorPointInPoints.x = contentSize.width * locAnchorPoint.x - this._offsetPoint.x; - cmd._anchorPointInPoints.y = contentSize.height * locAnchorPoint.y - this._offsetPoint.y; - - this._realAnchorPointInPoints.x = contentSize.width * locAnchorPoint.x; - this._realAnchorPointInPoints.y = contentSize.height * locAnchorPoint.y; - cmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); - } - }, - - _setAnchorX: function (x) { - var cmd = this._renderCmd, - anchorPointInPoint = cmd._anchorPointInPoints; - if (this._anchorPoint.x === x) return; - this._anchorPoint.x = x; - anchorPointInPoint.x = this._contentSize.width * x - this._offsetPoint.x; - this._realAnchorPointInPoints.x = this._contentSize.width * x; - cmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); - }, - - _setAnchorY: function (y) { - var cmd = this._renderCmd, - anchorPointInPoint = cmd._anchorPointInPoints; - if (this._anchorPoint.y === y) return; - this._anchorPoint.y = y; - anchorPointInPoint.y = this._contentSize.height * y - this._offsetPoint.y; - this._realAnchorPointInPoints.y = this._contentSize.height * y; - cmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); - }, - - /** - * Returns the anchor point in points of ccs.Armature. - * @override - * @returns {cc.Point} - */ - getAnchorPointInPoints: function(){ - return this._realAnchorPointInPoints; - }, - getOffsetPoints: function(){ return {x: this._offsetPoint.x, y: this._offsetPoint.y}; }, @@ -376,49 +316,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._armatureTransformDirty = false; }, - /** - * Draws armature's display render node. - * @override - * @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context - */ - draw: function(ctx){ - //TODO REMOVE THIS FUNCTION - if (this._parentBone == null && this._batchNode == null) { - // CC_NODE_DRAW_SETUP(); - } - - var locChildren = this._children; - var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; - for (var i = 0, len = locChildren.length; i< len; i++) { - var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); - - if (null == node) - continue; - - this._renderCmd.setShaderProgram(node); - - switch (selBone.getDisplayRenderNodeType()) { - case ccs.DISPLAY_TYPE_SPRITE: - if(node instanceof ccs.Skin) - this._renderCmd.updateChildPosition(ctx, node, selBone, alphaPremultiplied, alphaNonPremultipled); - break; - case ccs.DISPLAY_TYPE_ARMATURE: - node.draw(ctx); - break; - default: - node.visit(ctx); - break; - } - } else if(selBone instanceof cc.Node) { - this._renderCmd.setShaderProgram(selBone); - selBone.visit(ctx); - // CC_NODE_DRAW_SETUP(); - } - } - }, - /** * The callback when ccs.Armature enter stage. * @override @@ -540,7 +437,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ } }, - setBody: function (body) { if (this._body == body) return; diff --git a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js index fde75b81fe..44c225e687 100644 --- a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js @@ -23,21 +23,38 @@ ****************************************************************************/ (function(){ + ccs.Armature.RenderCmd = { + _updateAnchorPointInPoint: function(){ + var node = this._node; + var contentSize = node._contentSize, anchorPoint = node._anchorPoint, offsetPoint = node._offsetPoint; + this._anchorPointInPoints.x = contentSize.width * anchorPoint.x - offsetPoint.x; + this._anchorPointInPoints.y = contentSize.height * anchorPoint.y - offsetPoint.y; + + this._realAnchorPointInPoints.x = contentSize.width * anchorPoint.x; + this._realAnchorPointInPoints.y = contentSize.height * anchorPoint.y; + this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); + }, + + getAnchorPointInPoints: function(){ + return cc.p(this._realAnchorPointInPoints); + } + }; +})(); +(function(){ ccs.Armature.CanvasRenderCmd = function(renderableObject){ cc.Node.CanvasRenderCmd.call(this, renderableObject); - this._needDraw = false; + this._needDraw = true; + this._realAnchorPointInPoints = new cc.Point(0,0); this._startRenderCmd = new cc.CustomRenderCmd(this, this._startCmdCallback); this._RestoreRenderCmd = new cc.CustomRenderCmd(this, this._RestoreCmdCallback); }; var proto = ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + cc.inject(ccs.Armature.RenderCmd, proto); proto.constructor = ccs.Armature.CanvasRenderCmd; - proto.rendering = function(ctx, scaleX, scaleY){ - }; - proto._startCmdCallback = function(ctx, scaleX, scaleY){ var context = ctx || cc._renderContext; var node = this._node; @@ -71,6 +88,43 @@ dis.visit(ctx); }; + proto.rendering = function(ctx, scaleX, scaleY){ + if (this._parentBone == null && this._batchNode == null) { + // CC_NODE_DRAW_SETUP(); + } + + var locChildren = this._children; + var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var node = selBone.getDisplayRenderNode(); + + if (null == node) + continue; + + this._renderCmd.setShaderProgram(node); + + switch (selBone.getDisplayRenderNodeType()) { + case ccs.DISPLAY_TYPE_SPRITE: + if(node instanceof ccs.Skin) + this._renderCmd.updateChildPosition(ctx, node, selBone, alphaPremultiplied, alphaNonPremultipled); + break; + case ccs.DISPLAY_TYPE_ARMATURE: + node.draw(ctx); + break; + default: + node.visit(ctx); + break; + } + } else if(selBone instanceof cc.Node) { + this._renderCmd.setShaderProgram(selBone); + selBone.visit(ctx); + // CC_NODE_DRAW_SETUP(); + } + } + }; + proto.visit = function(){ var node = this._node; var context = cc._renderContext; @@ -83,9 +137,8 @@ node.sortAllChildren(); - cc.renderer.pushRenderCommand(this); cc.renderer.pushRenderCommand(this._startRenderCmd); - node.draw(ctx); + //node.draw(ctx); cc.renderer.pushRenderCommand(this._RestoreRenderCmd); this._cacheDirty = false; diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index 9cf378cbf2..e429aa9d22 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -27,62 +27,65 @@ ccs.Armature.WebGLRenderCmd = function(renderableObject){ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; + + this._realAnchorPointInPoints = new cc.Point(0,0); }; var proto = ccs.Armature.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + cc.inject(ccs.Armature.RenderCmd, proto); proto.constructor = ccs.Armature.WebGLRenderCmd; proto.rendering = function (ctx) { - var _t = this._node; + var node = this._node; cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLPushMatrix(); - cc.kmGLLoadMatrix(_t._stackMatrix); + cc.kmGLLoadMatrix(this._stackMatrix); //TODO REMOVE THIS FUNCTION - if (_t._parentBone == null && _t._batchNode == null) { + if (node._parentBone == null && node._batchNode == null) { // CC_NODE_DRAW_SETUP(); } - var locChildren = _t._children; + var locChildren = node._children; var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; for (var i = 0, len = locChildren.length; i < len; i++) { var selBone = locChildren[i]; if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); + var selNode = selBone.getDisplayRenderNode(); - if (null == node) + if (null == selNode) continue; - node.setShaderProgram(_t._shaderProgram); + selNode.setShaderProgram(this._shaderProgram); switch (selBone.getDisplayRenderNodeType()) { case ccs.DISPLAY_TYPE_SPRITE: - if (node instanceof ccs.Skin) { - node.updateTransform(); + if (selNode instanceof ccs.Skin) { + selNode.updateTransform(); var func = selBone.getBlendFunc(); if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) - node.setBlendFunc(selBone.getBlendFunc()); + selNode.setBlendFunc(selBone.getBlendFunc()); else { - if ((_t._blendFunc.src == alphaPremultiplied.src && _t._blendFunc.dst == alphaPremultiplied.dst) - && !node.getTexture().hasPremultipliedAlpha()) - node.setBlendFunc(alphaNonPremultipled); + if ((node._blendFunc.src == alphaPremultiplied.src && node._blendFunc.dst == alphaPremultiplied.dst) + && !selNode.getTexture().hasPremultipliedAlpha()) + selNode.setBlendFunc(alphaNonPremultipled); else - node.setBlendFunc(_t._blendFunc); + selNode.setBlendFunc(node._blendFunc); } - node.draw(ctx); + selNode.draw(ctx); } break; case ccs.DISPLAY_TYPE_ARMATURE: - node.draw(ctx); + selNode.draw(ctx); break; default: - node.visit(ctx); //TODO need fix soon + selNode.visit(ctx); //TODO need fix soon break; } } else if (selBone instanceof cc.Node) { - selBone.setShaderProgram(_t._shaderProgram); //TODO need fix soon + selBone.setShaderProgram(this._shaderProgram); //TODO need fix soon selBone.visit(ctx); // CC_NODE_DRAW_SETUP(); } @@ -92,13 +95,11 @@ }; proto.initShaderCache = function(){ - var node = this._node; - node.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; proto.setShaderProgram = function(child){ - var node = this._node; - child.setShaderProgram(node._shaderProgram); + child.setShaderProgram(this._shaderProgram); }; proto.updateChildPosition = function(ctx, dis, selBone, alphaPremultiplied, alphaNonPremultipled){ @@ -118,19 +119,17 @@ dis.draw(ctx); }; - proto.visit = function(){ + proto.visit = function(parentCmd){ var node = this._node; // quick return if not visible. children won't be drawn. if (!node._visible) return; - var /*context = cc._renderContext, */currentStack = cc.current_stack; + var currentStack = cc.current_stack; currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(node._stackMatrix, currentStack.top); - currentStack.top = node._stackMatrix; - - node.transform(); + this._syncStatus(parentCmd); + currentStack.top = this._stackMatrix; node.sortAllChildren(); //this.draw(context); diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 51ff3df692..44ef5aa4ca 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -240,10 +240,6 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ return this._displayName; } }); -if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - ccs.Skin.prototype.updateTransform = ccs.Skin.prototype._updateTransformForWebGL; -} - var _p = ccs.Skin.prototype; diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index c39376a0e8..13ee906508 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -93,7 +93,7 @@ cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); //cc.kmGLPushMatrixWitMat4(node._stackMatrix); cc.current_stack.stack.push(cc.current_stack.top); - cc.current_stack.top = node._stackMatrix; + cc.current_stack.top = this._stackMatrix; var drawingUtil = cc._drawingUtil; From ca21f31d10cba5127bdfaf9b14d5f805a5dff34e Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Tue, 2 Dec 2014 15:53:24 +0200 Subject: [PATCH 1016/1564] cc.ControlSwitchSprite now uses maskSprite's displayFrame instead of texture; --- extensions/gui/control-extension/CCControlSwitch.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/gui/control-extension/CCControlSwitch.js b/extensions/gui/control-extension/CCControlSwitch.js index 240af15017..1321dcb12c 100644 --- a/extensions/gui/control-extension/CCControlSwitch.js +++ b/extensions/gui/control-extension/CCControlSwitch.js @@ -215,7 +215,8 @@ cc.ControlSwitchSprite = cc.Sprite.extend({ }, initWithMaskSprite:function (maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel) { - if (cc.Sprite.prototype.initWithTexture.call(this, maskSprite.getTexture())) { + if (cc.Sprite.prototype.init.call(this)) { + this.setSpriteFrame(maskSprite.displayFrame()); // Sets the default values this._onPosition = 0; this._offPosition = -onSprite.getContentSize().width + thumbSprite.getContentSize().width / 2; @@ -307,8 +308,8 @@ cc.ControlSwitchSprite = cc.Sprite.extend({ }, updateTweenAction:function (value, key) { - cc.log("key = " + key + ", value = " + value); - this.setSliderXPosition(value); + if (key === "sliderXPosition") + this.setSliderXPosition(value); }, setOnPosition:function (onPosition) { From 975ea2e824d7357932464da604ba61a19f6bd1c9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 3 Dec 2014 10:35:26 +0800 Subject: [PATCH 1017/1564] Issue #2416: edit box --- extensions/editbox/CCdomNode.js | 12 ++++++++---- extensions/gui/control-extension/CCControlSlider.js | 7 ++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index dccdcc16a8..987efd26b7 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -137,6 +137,8 @@ cc.DOM.methods = /** @lends cc.DOM# */{ * @param {Number} [y] The anchor point.y of node. */ setAnchorPoint:function (point, y) { + var cmd = this._renderCmd; + var locAnchorPoint = this._anchorPoint; if (y === undefined) { locAnchorPoint.x = point.x; @@ -145,7 +147,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ locAnchorPoint.x = point; locAnchorPoint.y = y; } - var locAPP = this._anchorPointInPoints, locSize = this._contentSize; + var locAPP = cmd._anchorPointInPoints, locSize = this._contentSize; locAPP.x = locSize.width * locAnchorPoint.x; locAPP.y = locSize.height * locAnchorPoint.y; @@ -214,6 +216,8 @@ cc.DOM.methods = /** @lends cc.DOM# */{ * @param {Number} [height] The untransformed size's height of the node. */ setContentSize:function (size, height) { + var cmd = this._renderCmd; + var locContentSize = this._contentSize; if (height === undefined) { locContentSize.width = size.width; @@ -222,7 +226,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ locContentSize.width = size; locContentSize.height = height; } - var locAPP = this._anchorPointInPoints, locAnchorPoint = this._anchorPoint; + var locAPP = cmd._anchorPointInPoints, locAnchorPoint = this._anchorPoint; locAPP.x = locContentSize.width * locAnchorPoint.x; locAPP.y = locContentSize.height * locAnchorPoint.y; this.dom.width = locContentSize.width; @@ -536,11 +540,11 @@ cc.DOM.setTransform = function (x) { if (x.isSprite) { var tmp = x._children; x._children = []; - cc.Sprite.prototype.visit.call(x, x.ctx); + cc.Sprite.prototype.visit.call(x); x._children = tmp; } else { - cc.Sprite.prototype.visit.call(x, x.ctx); + cc.Sprite.prototype.visit.call(x); } } if (x.dom) { diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index f2221a7ebe..9fd8037471 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -65,13 +65,13 @@ cc.ControlSlider = cc.Control.extend(/** @lends cc.ControlSlider# */{ cc.Control.prototype.ctor.call(this); if (thumbFile != undefined) { // Prepare background for slider - bgSprite = new cc.Sprite(bgFile); + var bgSprite = new cc.Sprite(bgFile); // Prepare progress for slider - progressSprite = new cc.Sprite(progressFile); + var progressSprite = new cc.Sprite(progressFile); // Prepare thumb (menuItem) for slider - thumbSprite = new cc.Sprite(thumbFile); + var thumbSprite = new cc.Sprite(thumbFile); this.initWithSprites(bgSprite, progressSprite, thumbSprite); } @@ -258,6 +258,7 @@ cc.ControlSlider = cc.Control.extend(/** @lends cc.ControlSlider# */{ var textureRect = this._progressSprite.getTextureRect(); textureRect = cc.rect(textureRect.x, textureRect.y, this._thumbSprite.getPositionX(), textureRect.height); this._progressSprite.setTextureRect(textureRect, this._progressSprite.isTextureRectRotated()); + this._thumbSprite._renderCmd.transform(this._renderCmd); }, /** Returns the value for the given location. */ valueForLocation:function (location) { From d3c2ed30ffccfeff9ad0b22a9881d6a71e15819b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 3 Dec 2014 16:08:37 +0800 Subject: [PATCH 1018/1564] Issue #2416: Fixed some bug - sprite _dirtyFlag error | TTF _dirtyFlag error --- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 4 +++- cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js | 2 +- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 2 +- extensions/gui/control-extension/CCControlSlider.js | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 729863c2d2..a29d4fd0d6 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -70,8 +70,10 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; }else if(locFlag & flags.textDirty) this._updateTexture(); - if (locFlag & flags.transformDirty) + if (this._dirtyFlag & flags.transformDirty){ this.transform(this.getParentRenderCmd(), true); + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; + } }; proto._getLabelContext = function () { diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4e2c47ba29..a4d871d6b2 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -486,7 +486,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ setOpacityModifyRGB: function (modify) { if (this._opacityModifyRGB !== modify) { this._opacityModifyRGB = modify; - this._renderCmd._updateColor(); + this._renderCmd._setColorDirty(); } }, diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 711c86dae3..b48c6740ac 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -61,7 +61,7 @@ } }; - proto._updateColor = function () { + proto._setColorDirty = function () { this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty); }; diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index e6fc156856..6896faf92e 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -232,7 +232,7 @@ this._dirty = true; //use for batching }; - proto._updateColor = function () { + proto._setColorDirty = function () { var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity, node = this._node; var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; // special opacity for premultiplied textures diff --git a/extensions/gui/control-extension/CCControlSlider.js b/extensions/gui/control-extension/CCControlSlider.js index 9fd8037471..e4a757b3c8 100644 --- a/extensions/gui/control-extension/CCControlSlider.js +++ b/extensions/gui/control-extension/CCControlSlider.js @@ -209,7 +209,7 @@ cc.ControlSlider = cc.Control.extend(/** @lends cc.ControlSlider# */{ sliderBegan:function (location) { this.setSelected(true); - this.getThumbSprite().setColor(cc.color.GRAY); + this._thumbSprite.setColor(cc.color.GRAY); this.setValue(this.valueForLocation(location)); }, sliderMoved:function (location) { From 1797b5daf9bf31752a8388cefd48ce3143757d31 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 3 Dec 2014 16:31:52 +0800 Subject: [PATCH 1019/1564] Issue #2416: refactor Armature and let it works. --- cocos2d/core/sprites/CCSprite.js | 2 +- .../CCParticleSystemWebGLRenderCmd.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 21 +-- .../armature/CCArmatureCanvasRenderCmd.js | 44 +++--- .../armature/CCArmatureWebGLRenderCmd.js | 29 ++-- extensions/cocostudio/armature/CCBone.js | 2 +- .../cocostudio/armature/display/CCSkin.js | 84 ++-------- .../armature/display/CCSkinCanvasRenderCmd.js | 61 ++++++++ .../armature/display/CCSkinWebGLRenderCmd.js | 146 ++++++++++++++++++ moduleConfig.json | 2 + template/project.json | 2 +- template/src/myApp.js | 9 -- template/src/resource.js | 3 - 13 files changed, 275 insertions(+), 132 deletions(-) create mode 100644 extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js create mode 100644 extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 4e2c47ba29..164b2e986e 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -13,7 +13,7 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. + all copies or substantial portions of the Software. node THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, diff --git a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js index 1065d1f229..0bdd3462f3 100644 --- a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js @@ -188,7 +188,7 @@ var gl = ctx || cc._renderContext; this._shaderProgram.use(); - this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); //setUniformForModelViewAndProjectionMatrixWithMat4(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); //; cc.glBindTexture2D(node._texture); cc.glBlendFuncForParticle(node._blendFunc.src, node._blendFunc.dst); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index e2d19f4cdb..b54d52d238 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -334,10 +334,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.unscheduleUpdate(); }, - visit: function(){ - this._renderCmd.visit(); - }, - /** * This boundingBox will calculate all bones' boundingBox every time * @returns {cc.Rect} @@ -470,10 +466,17 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ /** * Sets the blendFunc to ccs.Armature - * @param {cc.BlendFunc} blendFunc + * @param {cc.BlendFunc|Number} blendFunc + * @param {Number} [dst] */ - setBlendFunc: function (blendFunc) { - this._blendFunc = blendFunc; + setBlendFunc: function (blendFunc, dst) { + if(dst === undefined){ + this._blendFunc.src = blendFunc.src; + this._blendFunc.dst = blendFunc.dst; + } else { + this._blendFunc.src = blendFunc; + this._blendFunc.dst = dst; + } }, /** @@ -481,7 +484,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ * @returns {cc.BlendFunc} */ getBlendFunc: function () { - return this._blendFunc; + return new cc.BlendFunc(this._blendFunc.src, this._blendFunc.dst); }, /** @@ -535,7 +538,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, _transformForRenderer: function(){ - ccs.Node.prototype._transformForRenderer.call(this); var locChildren = this._children; @@ -543,7 +545,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var selBone = locChildren[i]; if (selBone && selBone.getDisplayRenderNode) { var node = selBone.getDisplayRenderNode(); - if (null == node) continue; diff --git a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js index 44c225e687..c45422e487 100644 --- a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js @@ -72,7 +72,22 @@ if (null == rn) continue; -// rn._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); + rn._renderCmd.transform(); + } + } + }; + + proto.transform = function(parentCmd, recursive){ + ccs.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd, recursive); + + var node = this._node; + var locChildren = node._children; + for (var i = 0, len = locChildren.length; i< len; i++) { + var selBone = locChildren[i]; + if (selBone && selBone.getDisplayRenderNode) { + var selNode = selBone.getDisplayRenderNode(); + if (selNode) + selNode.transform(); } } }; @@ -89,38 +104,31 @@ }; proto.rendering = function(ctx, scaleX, scaleY){ - if (this._parentBone == null && this._batchNode == null) { - // CC_NODE_DRAW_SETUP(); - } - - var locChildren = this._children; + var node = this._node; + var locChildren = node._children; var alphaPremultiplied = cc.BlendFunc.ALPHA_PREMULTIPLIED, alphaNonPremultipled = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; for (var i = 0, len = locChildren.length; i< len; i++) { var selBone = locChildren[i]; if (selBone && selBone.getDisplayRenderNode) { - var node = selBone.getDisplayRenderNode(); + var selNode = selBone.getDisplayRenderNode(); - if (null == node) + if (null == selNode) continue; - this._renderCmd.setShaderProgram(node); - switch (selBone.getDisplayRenderNodeType()) { case ccs.DISPLAY_TYPE_SPRITE: - if(node instanceof ccs.Skin) - this._renderCmd.updateChildPosition(ctx, node, selBone, alphaPremultiplied, alphaNonPremultipled); + if(selNode instanceof ccs.Skin) + this.updateChildPosition(ctx, selNode, selBone, alphaPremultiplied, alphaNonPremultipled); break; case ccs.DISPLAY_TYPE_ARMATURE: - node.draw(ctx); + selNode._renderCmd.rendering(ctx); break; default: - node.visit(ctx); + selNode.visit(ctx); break; } } else if(selBone instanceof cc.Node) { - this._renderCmd.setShaderProgram(selBone); selBone.visit(ctx); - // CC_NODE_DRAW_SETUP(); } } }; @@ -133,12 +141,12 @@ return; context.save(); -// this.transform(); + this.transform(); node.sortAllChildren(); cc.renderer.pushRenderCommand(this._startRenderCmd); - //node.draw(ctx); + this.rendering(); cc.renderer.pushRenderCommand(this._RestoreRenderCmd); this._cacheDirty = false; diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index e429aa9d22..4bbe87b48a 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -35,16 +35,13 @@ cc.inject(ccs.Armature.RenderCmd, proto); proto.constructor = ccs.Armature.WebGLRenderCmd; - proto.rendering = function (ctx) { + proto.rendering = function (ctx, dontChangeMatrix) { var node = this._node; - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadMatrix(this._stackMatrix); - - //TODO REMOVE THIS FUNCTION - if (node._parentBone == null && node._batchNode == null) { - // CC_NODE_DRAW_SETUP(); + if(!dontChangeMatrix){ + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadMatrix(this._stackMatrix); } var locChildren = node._children; @@ -74,32 +71,32 @@ else selNode.setBlendFunc(node._blendFunc); } - selNode.draw(ctx); + selNode._renderCmd.rendering(ctx); } break; case ccs.DISPLAY_TYPE_ARMATURE: - selNode.draw(ctx); + selNode._renderCmd.rendering(ctx, true); break; default: - selNode.visit(ctx); //TODO need fix soon + selNode._renderCmd.transform(); + selNode._renderCmd.rendering(ctx); break; } } else if (selBone instanceof cc.Node) { selBone.setShaderProgram(this._shaderProgram); //TODO need fix soon selBone.visit(ctx); - // CC_NODE_DRAW_SETUP(); } } - - cc.kmGLPopMatrix(); + if(!dontChangeMatrix) + cc.kmGLPopMatrix(); }; proto.initShaderCache = function(){ this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); }; - proto.setShaderProgram = function(child){ - child.setShaderProgram(this._shaderProgram); + proto.setShaderProgram = function(shaderProgram){ + this._shaderProgram = shaderProgram; }; proto.updateChildPosition = function(ctx, dis, selBone, alphaPremultiplied, alphaNonPremultipled){ diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 6a476a3b62..fbcce440e5 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -567,7 +567,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @return {cc.BlendFunc} */ getBlendFunc: function () { - return this._blendFunc; + return new cc.BlendFunc(this._blendFunc.src, this._blendFunc.dst); }, /** diff --git a/extensions/cocostudio/armature/display/CCSkin.js b/extensions/cocostudio/armature/display/CCSkin.js index 44ef5aa4ca..6bba29b876 100644 --- a/extensions/cocostudio/armature/display/CCSkin.js +++ b/extensions/cocostudio/armature/display/CCSkin.js @@ -130,71 +130,8 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ /** * Updates armature skin's transform with skin transform and bone's transform. */ - updateArmatureTransform: function () { //TODO refactor - this._transform = cc.affineTransformConcat( - this._skinTransform, - this.bone.getNodeToArmatureTransform() - ); - }, - - _updateTransformForWebGL: function(){ - var locQuad = this._quad; - // If it is not visible, or one of its ancestors is not visible, then do nothing: - if( !this._visible) - locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y:0, z:0}; - else { - // - // calculate the Quad based on the Affine Matrix - // - var transform = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform(); - var size = this._rect; - - var x1 = this._offsetPosition.x, y1 = this._offsetPosition.y; - - var x2 = x1 + size.width, y2 = y1 + size.height; - var x = transform.tx, y = transform.ty; - - var cr = transform.a, sr = transform.b; - var cr2 = transform.d, sr2 = -transform.c; - var ax = x1 * cr - y1 * sr2 + x; - var ay = x1 * sr + y1 * cr2 + y; - - var bx = x2 * cr - y1 * sr2 + x; - var by = x2 * sr + y1 * cr2 + y; - - var cx = x2 * cr - y2 * sr2 + x; - var cy = x2 * sr + y2 * cr2 + y; - - var dx = x1 * cr - y2 * sr2 + x; - var dy = x1 * sr + y2 * cr2 + y; - - var locVertexZ = this._vertexZ; - if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { - ax = 0 | ax; - ay = 0 | ay; - bx = 0 | bx; - by = 0 | by; - cx = 0 | cx; - cy = 0 | cy; - dx = 0 | dx; - dy = 0 | dy; - } - this.SET_VERTEX3F(locQuad.bl.vertices,ax, ay,locVertexZ); - this.SET_VERTEX3F(locQuad.br.vertices,bx, by,locVertexZ); - this.SET_VERTEX3F(locQuad.tl.vertices,dx, dy,locVertexZ); - this.SET_VERTEX3F(locQuad.tr.vertices,cx, cy,locVertexZ); - } - - // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS - if (this._textureAtlas) - this._textureAtlas.updateQuad(locQuad, this._textureAtlas.getTotalQuads()); - this._quadDirty = true; - }, - - SET_VERTEX3F: function(_v_, _x_, _y_, _z_){ - (_v_).x = (_x_); - (_v_).y = (_y_); - (_v_).z = (_z_); + updateArmatureTransform: function () { + this._renderCmd.updateArmatureTransform(); }, /** @@ -202,15 +139,11 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ * @returns {cc.AffineTransform} */ getNodeToWorldTransform: function(){ - return cc.affineTransformConcat(this._transform,this.bone.getArmature().getNodeToWorldTransform()); + return this._renderCmd.getNodeToWorldTransform(); }, - getNodeToWorldTransformAR: function(){ //TODO refactoring - var displayTransform = this._transform; - this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); - displayTransform.tx = this._anchorPointInPoints.x; - displayTransform.ty = this._anchorPointInPoints.y; - return cc.affineTransformConcat( displayTransform,this.bone.getArmature().getNodeToWorldTransform()); + getNodeToWorldTransformAR: function(){ + return this._renderCmd.getNodeToWorldTransformAR(); }, /** @@ -238,6 +171,13 @@ ccs.Skin = ccs.Sprite.extend(/** @lends ccs.Skin# */{ */ getDisplayName: function () { return this._displayName; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new ccs.Skin.CanvasRenderCmd(this); + else + return new ccs.Skin.WebGLRenderCmd(this); } }); diff --git a/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js b/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js new file mode 100644 index 0000000000..056a6617ea --- /dev/null +++ b/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js @@ -0,0 +1,61 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + ccs.Skin.RenderCmd = { + updateArmatureTransform: function () { + var node = this._node; + this._transform = cc.affineTransformConcat( + node._skinTransform, + node.bone.getNodeToArmatureTransform() + ); + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; + }, + + getNodeToWorldTransform: function () { + var node = this._node; + return cc.affineTransformConcat(this._transform, node.bone.getArmature().getNodeToWorldTransform()); + }, + + getNodeToWorldTransformAR: function () { + var displayTransform = this._transform, node = this._node; + this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, displayTransform); + displayTransform.tx = this._anchorPointInPoints.x; + displayTransform.ty = this._anchorPointInPoints.y; + return cc.affineTransformConcat(displayTransform, node.bone.getArmature().getNodeToWorldTransform()); + } + }; + + ccs.Skin.CanvasRenderCmd = function(renderable){ + cc.Sprite.CanvasRenderCmd.call(this, renderable); + this._needDraw = true; + }; + + var proto = ccs.Skin.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); + cc.inject(ccs.Skin.RenderCmd, proto); + proto.constructor = ccs.Skin.CanvasRenderCmd; + + +})(); diff --git a/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js new file mode 100644 index 0000000000..deb0370c31 --- /dev/null +++ b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js @@ -0,0 +1,146 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + ccs.Skin.WebGLRenderCmd = function(renderable){ + cc.Sprite.WebGLRenderCmd.call(this, renderable); + }; + + var proto = ccs.Skin.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); + cc.inject(ccs.Skin.RenderCmd, proto); + proto.constructor = ccs.Skin.WebGLRenderCmd; + + proto.updateTransform = function(){ + var node = this._node; + var locQuad = this._quad; + // If it is not visible, or one of its ancestors is not visible, then do nothing: + if( !node._visible) + locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; + else { + // + // calculate the Quad based on the Affine Matrix + // + var transform = this.getNodeToParentTransform(); //this._transform; + var size = node._rect; + + var x1 = node._offsetPosition.x, y1 = node._offsetPosition.y; + + var x2 = x1 + size.width, y2 = y1 + size.height; + var x = transform.tx, y = transform.ty; + + var cr = transform.a, sr = transform.b; + var cr2 = transform.d, sr2 = -transform.c; + var ax = x1 * cr - y1 * sr2 + x; + var ay = x1 * sr + y1 * cr2 + y; + + var bx = x2 * cr - y1 * sr2 + x; + var by = x2 * sr + y1 * cr2 + y; + + var cx = x2 * cr - y2 * sr2 + x; + var cy = x2 * sr + y2 * cr2 + y; + + var dx = x1 * cr - y2 * sr2 + x; + var dy = x1 * sr + y2 * cr2 + y; + + var locVertexZ = node._vertexZ; + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + ax = 0 | ax; + ay = 0 | ay; + bx = 0 | bx; + by = 0 | by; + cx = 0 | cx; + cy = 0 | cy; + dx = 0 | dx; + dy = 0 | dy; + } + this.SET_VERTEX3F(locQuad.bl.vertices,ax, ay,locVertexZ); + this.SET_VERTEX3F(locQuad.br.vertices,bx, by,locVertexZ); + this.SET_VERTEX3F(locQuad.tl.vertices,dx, dy,locVertexZ); + this.SET_VERTEX3F(locQuad.tr.vertices,cx, cy,locVertexZ); + } + + // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS + if (node.textureAtlas) + node.textureAtlas.updateQuad(locQuad, node.textureAtlas.getTotalQuads()); + this._quadDirty = true; + }; + + proto.SET_VERTEX3F = function(_v_, _x_, _y_, _z_){ + (_v_).x = (_x_); + (_v_).y = (_y_); + (_v_).z = (_z_); + }; + + proto.rendering = function(ctx){ + var node = this._node; + if (!node._textureLoaded) + return; + + var gl = ctx || cc._renderContext, locTexture = node._texture; + if (locTexture && locTexture._isLoaded) { + this._shaderProgram.use(); + this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); + + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + //optimize performance for javascript + cc.glBindTexture2DN(0, locTexture); // = cc.glBindTexture2D(locTexture); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + gl.bindBuffer(gl.ARRAY_BUFFER, this._quadWebBuffer); + if (this._quadDirty) { + gl.bufferData(gl.ARRAY_BUFFER, this._quad.arrayBuffer, gl.DYNAMIC_DRAW); + this._quadDirty = false; + } + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0); //cc.VERTEX_ATTRIB_POSITION + gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 24, 12); //cc.VERTEX_ATTRIB_COLOR + gl.vertexAttribPointer(2, 2, gl.FLOAT, false, 24, 16); //cc.VERTEX_ATTRIB_TEX_COORDS + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + } + + cc.g_NumberOfDraws++; + if (cc.SPRITE_DEBUG_DRAW === 0 && !node._showNode) + return; + + if (cc.SPRITE_DEBUG_DRAW === 1 || node._showNode) { + // draw bounding box + var locQuad = this._quad; + var verticesG1 = [ + cc.p(locQuad.tl.vertices.x, locQuad.tl.vertices.y), + cc.p(locQuad.bl.vertices.x, locQuad.bl.vertices.y), + cc.p(locQuad.br.vertices.x, locQuad.br.vertices.y), + cc.p(locQuad.tr.vertices.x, locQuad.tr.vertices.y) + ]; + cc._drawingUtil.drawPoly(verticesG1, 4, true); + } else if (cc.SPRITE_DEBUG_DRAW === 2) { + // draw texture box + var drawRectG2 = node.getTextureRect(); + var offsetPixG2 = node.getOffsetPosition(); + var verticesG2 = [cc.p(offsetPixG2.x, offsetPixG2.y), cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y), + cc.p(offsetPixG2.x + drawRectG2.width, offsetPixG2.y + drawRectG2.height), cc.p(offsetPixG2.x, offsetPixG2.y + drawRectG2.height)]; + cc._drawingUtil.drawPoly(verticesG2, 4, true); + } // CC_SPRITE_DEBUG_DRAW + }; +})(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index a021ab42d2..06a7b28042 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -349,6 +349,8 @@ "extensions/cocostudio/armature/display/CCDisplayFactory.js", "extensions/cocostudio/armature/display/CCDisplayManager.js", "extensions/cocostudio/armature/display/CCSkin.js", + "extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js", + "extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js", "extensions/cocostudio/armature/animation/CCProcessBase.js", "extensions/cocostudio/armature/animation/CCArmatureAnimation.js", "extensions/cocostudio/armature/animation/CCTween.js", diff --git a/template/project.json b/template/project.json index ab517674a9..46a1467d42 100644 --- a/template/project.json +++ b/template/project.json @@ -3,7 +3,7 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 1, + "renderMode" : 0, "engineDir":"../", "modules" : ["cocos2d", "extensions"], diff --git a/template/src/myApp.js b/template/src/myApp.js index 75c4353bd2..f91b7c40af 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,15 +44,6 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); - - ccs.armatureDataManager.addArmatureFileInfo("cyborg.png", "cyborg.plist", "cyborg.xml"); - this.armature = ccs.Armature.create("cyborg"); - this.armature.getAnimation().playWithIndex(1); - this.armature.x = size.width / 2; - this.armature.y = size.height / 2; - this.armature.scale = 1.2; - this.armature.getAnimation().setSpeedScale(0.4); - this.addChild(this.armature); } }); diff --git a/template/src/resource.js b/template/src/resource.js index b368440129..94284083d1 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -6,9 +6,6 @@ var g_resources = [ //image s_HelloWorld, s_CloseNormal, - "cyborg.png", - "cyborg.plist", - "cyborg.xml", s_CloseSelected //plist From ad9982c664a74535b09c929af916a09708fc84b7 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 3 Dec 2014 16:37:31 +0800 Subject: [PATCH 1020/1564] cocos2d-js#1161: Fix MenuItemSprite's automatic init logic --- cocos2d/menus/CCMenuItem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index d810ad4745..ce44297a70 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -740,9 +740,9 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ } else if (four !== undefined && cc.isFunction(three)) { target = four; callback = three; - disabledImage = new cc.Sprite(selectedSprite); + disabledImage = new cc.Sprite(selectedSprite.getTexture(), selectedSprite.getTextureRect()); } else if (three === undefined) { - disabledImage = new cc.Sprite(selectedSprite); + disabledImage = new cc.Sprite(selectedSprite.getTexture(), selectedSprite.getTextureRect()); } this.initWithNormalSprite(normalSprite, selectedSprite, disabledImage, callback, target); } From 9b9eb427f693926c9e5f2ec0e02e94b6f3cc35f7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 3 Dec 2014 18:04:24 +0800 Subject: [PATCH 1021/1564] Issue #2416: undefined is not function --- cocos2d/core/base-nodes/CCAtlasNode.js | 1 + extensions/ccui/base-classes/CCProtectedNode.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js index 45a8b99e3a..c2b543931a 100644 --- a/cocos2d/core/base-nodes/CCAtlasNode.js +++ b/cocos2d/core/base-nodes/CCAtlasNode.js @@ -276,6 +276,7 @@ _p.textureAtlas; /** @expose */ _p.quadsToDraw; +cc.EventHelper.prototype.apply(_p); /** * Creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index beff22b6fe..3c474f203a 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -75,9 +75,9 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ child.onEnterTransitionDidFinish(); } if(this._cascadeColorEnabled) - this._enableCascadeColor(); + this._renderCmd.setCascadeColorEnabledDirty(); if (this._cascadeOpacityEnabled) - this._enableCascadeOpacity(); + this._renderCmd.setCascadeOpacityEnabledDirty(); }, /** From ec15593336de5c2238777d91e9f042d0796a8e69 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 3 Dec 2014 20:35:38 +0800 Subject: [PATCH 1022/1564] cocos2d-js#1163: Made menu items' texture update in bake layer --- cocos2d/menus/CCMenu.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 40923e3043..6249588aee 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -466,6 +466,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ if (target._selectedItem) { target._state = cc.MENU_STATE_TRACKING_TOUCH; target._selectedItem.selected(); + target._selectedItem.setNodeDirty(); return true; } return false; @@ -480,6 +481,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ if (target._selectedItem) { target._selectedItem.unselected(); target._selectedItem.activate(); + target._selectedItem.setNodeDirty(); } target._state = cc.MENU_STATE_WAITING; }, @@ -490,8 +492,10 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ cc.log("cc.Menu.onTouchCancelled(): invalid state"); return; } - if (this._selectedItem) + if (this._selectedItem) { target._selectedItem.unselected(); + target._selectedItem.setNodeDirty(); + } target._state = cc.MENU_STATE_WAITING; }, @@ -503,11 +507,15 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ } var currentItem = target._itemForTouch(touch); if (currentItem != target._selectedItem) { - if (target._selectedItem) + if (target._selectedItem) { target._selectedItem.unselected(); + target._selectedItem.setNodeDirty(); + } target._selectedItem = currentItem; - if (target._selectedItem) + if (target._selectedItem) { target._selectedItem.selected(); + target._selectedItem.setNodeDirty(); + } } }, From ad2481250de2abe73b9a7273b7fe4543a4920bfd Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Dec 2014 13:38:01 +0800 Subject: [PATCH 1023/1564] Issue #2416: Refactor Cocostudio's renderer --- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 2 +- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 7 +- cocos2d/shape-nodes/CCDrawNode.js | 2 +- .../ccui/base-classes/CCProtectedNode.js | 10 +- .../CCProtectedNodeCanvasRenderCmd.js | 95 ++++- .../CCProtectedNodeWebGLRenderCmd.js | 17 +- .../UIScale9SpriteWebGLRenderCmd.js | 15 +- extensions/ccui/base-classes/UIWidget.js | 3 +- extensions/ccui/layouts/UILayout.js | 382 +----------------- .../ccui/layouts/UILayoutCanvasRenderCmd.js | 195 +++++++++ .../ccui/layouts/UILayoutWebGLRenderCmd.js | 210 ++++++++++ .../armature/display/CCSkinCanvasRenderCmd.js | 1 - .../CCScale9SpriteWebGLRenderCmd.js | 1 - extensions/spine/CCSkeletonCanvasRenderCmd.js | 1 - moduleConfig.json | 2 + 15 files changed, 541 insertions(+), 402 deletions(-) create mode 100644 extensions/ccui/layouts/UILayoutCanvasRenderCmd.js create mode 100644 extensions/ccui/layouts/UILayoutWebGLRenderCmd.js diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 577e0cfb70..724fec088a 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -103,7 +103,7 @@ } if (node._additionalTransformDirty) { - t = cc.affineTransformConcat(t, this._additionalTransform); + t = cc.affineTransformConcat(t, node._additionalTransform); node._additionalTransformDirty = false; } this._transform = t; diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index f79dc454bc..e309c2a27f 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -101,7 +101,7 @@ node.sortAllChildren(); cc.renderer._turnToCacheMode(this.__instanceId); for (var i = 0, len = children.length; i < len; i++) { - children[i].visit(bakeContext); + children[i].visit(this); } cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); locBakeSprite.transform(); //because bake sprite's position was changed at rendering. @@ -123,7 +123,6 @@ return; _t._syncStatus(parentCmd); - cc.renderer.pushRenderCommand(this); //the bakeSprite is drawing @@ -257,13 +256,13 @@ for (i = 0; i < len; i++) { child = children[i]; if (child._localZOrder < 0) - child._renderCmd.visit(bakeContext); + child._renderCmd.visit(this); else break; } cc.renderer.pushRenderCommand(this); for (; i < len; i++) { - children[i]._renderCmd.visit(bakeContext); + children[i]._renderCmd.visit(this); } } else cc.renderer.pushRenderCommand(this); diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index a2dddea4aa..1cbccead7c 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -88,7 +88,7 @@ cc.__t = function (v) { * @name cc.DrawNode * @extends cc.Node */ -cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ +cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ //TODO need refactor _buffer: null, _blendFunc: null, _lineWidth: 1, diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index beff22b6fe..74f4024048 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -67,7 +67,6 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ child.setParent(this); child.setOrderOfArrival(cc.s_globalOrderOfArrival); - //TODO USE PHYSICS if(this._running){ child.onEnter(); // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter @@ -75,9 +74,9 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ child.onEnterTransitionDidFinish(); } if(this._cascadeColorEnabled) - this._enableCascadeColor(); + child._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); if (this._cascadeOpacityEnabled) - this._enableCascadeOpacity(); + child._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); }, /** @@ -111,7 +110,6 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ child.onExitTransitionDidStart(); child.onExit(); } - //TODO USE PHYSICS // If you don't do cleanup, the child's actions will not get removed and the // its scheduledSelectors_ dict will not get released! @@ -171,7 +169,6 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ child.onExit(); } - //TODO USE PHYSICS if (cleanup) child.cleanup(); // set parent nil at the end @@ -300,6 +297,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren[i].onExitTransitionDidStart(); }, + // todo ---- start need delete ----- /** * Updates itself and its protected children displayed opacity, if opacity cascade is enable, its children also update. * @param {Number} parentOpacity @@ -381,6 +379,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ locChildren[i].setColor(white); }, + //todo ---- end ------ + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.ProtectedNode.CanvasRenderCmd(this); diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index b7c7783017..b8d903c462 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -23,6 +23,99 @@ ****************************************************************************/ (function(){ + cc.ProtectedNode.RenderCmd = { + _updateDisplayColor: function (parentColor) { + var node = this._node; + var locDispColor = this._displayedColor, locRealColor = node._realColor; + var i, len, selChildren, item; + if (this._cascadeColorEnabledDirty && !node._cascadeColorEnabled) { + locDispColor.r = locRealColor.r; + locDispColor.g = locRealColor.g; + locDispColor.b = locRealColor.b; + var whiteColor = new cc.Color(255, 255, 255, 255); + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayColor(whiteColor); + } + } else { + if (parentColor === undefined) { + var locParent = node._parent; + if (locParent && locParent._cascadeColorEnabled) + parentColor = locParent.getDisplayedColor(); + else + parentColor = cc.color.WHITE; + } + locDispColor.r = 0 | (locRealColor.r * parentColor.r / 255.0); + locDispColor.g = 0 | (locRealColor.g * parentColor.g / 255.0); + locDispColor.b = 0 | (locRealColor.b * parentColor.b / 255.0); + if (node._cascadeColorEnabled) { + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd){ + item._renderCmd._updateDisplayColor(locDispColor); + item._renderCmd._updateColor(); + } + } + } + selChildren = node._protectedChildren; + for(i = 0, len = selChildren.length;i < len; i++){ + item = selChildren[i]; + if(item && item._renderCmd){ + item._renderCmd._updateDisplayColor(locDispColor); + item._renderCmd._updateColor(); + } + } + } + this._cascadeColorEnabledDirty = false; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.colorDirty ^ this._dirtyFlag; + }, + + _updateDisplayOpacity: function (parentOpacity) { + var node = this._node; + var i, len, selChildren, item; + if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { + this._displayedOpacity = node._realOpacity; + selChildren = this._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd) + item._renderCmd._updateDisplayOpacity(255); + } + } else { + if (parentOpacity === undefined) { + var locParent = node._parent; + parentOpacity = 255; + if (locParent && locParent._cascadeOpacityEnabled) + parentOpacity = locParent.getDisplayedOpacity(); + } + this._displayedOpacity = node._realOpacity * parentOpacity / 255.0; + if (node._cascadeOpacityEnabled) { + selChildren = node._children; + for (i = 0, len = selChildren.length; i < len; i++) { + item = selChildren[i]; + if (item && item._renderCmd){ + item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + item._renderCmd._updateColor(); + } + } + } + selChildren = node._protectedChildren; + for(i = 0, len = selChildren.length;i < len; i++){ + item = selChildren[i]; + if(item && item._renderCmd){ + item._renderCmd._updateDisplayOpacity(this._displayedOpacity); + item._renderCmd._updateColor(); + } + } + } + this._cascadeOpacityEnabledDirty = false; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty ^ this._dirtyFlag; + } + }; + cc.ProtectedNode.CanvasRenderCmd = function (renderable) { cc.Node.CanvasRenderCmd.call(this, renderable); this._cachedParent = null; @@ -30,6 +123,7 @@ }; var proto = cc.ProtectedNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + cc.inject(cc.ProtectedNode.RenderCmd, proto); proto.constructor = cc.ProtectedNode.CanvasRenderCmd; proto.visit = function(){ @@ -117,6 +211,5 @@ locChildren = node._protectedChildren; for( i = 0, len = locChildren.length; i< len; i++) locChildren[i]._renderCmd.transform(this); - }; })(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index 025d6f79d1..45a62251d7 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -23,7 +23,6 @@ ****************************************************************************/ (function(){ - cc.ProtectedNode.WebGLRenderCmd = function (renderable) { cc.Node.WebGLRenderCmd.call(this, renderable); this._cachedParent = null; @@ -31,9 +30,14 @@ }; var proto = cc.ProtectedNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); + cc.inject(cc.ProtectedNode.RenderCmd, proto); proto.constructor = cc.ProtectedNode.WebGLRenderCmd; proto.visit = function(){ + this._node.visit(); //todo refactor late + }; + + proto._visit = function(parentCmd){ var node = this._node; // quick return if not visible if (!node._visible) @@ -59,13 +63,13 @@ // draw children zOrder < 0 for (i = 0; i < childLen; i++) { if (locChildren[i] && locChildren[i]._localZOrder < 0) - locChildren[i].visit(); + locChildren[i].visit(this); else break; } for(j = 0; j < pLen; j++){ if (locProtectedChildren[j] && locProtectedChildren[j]._localZOrder < 0) - locProtectedChildren[j].visit(); + locProtectedChildren[j].visit(this); else break; } @@ -74,10 +78,10 @@ // draw children zOrder >= 0 for (; i < childLen; i++) { - locChildren[i] && locChildren[i].visit(); + locChildren[i] && locChildren[i].visit(this); } for (; j < pLen; j++) { - locProtectedChildren[j] && locProtectedChildren[j].visit(); + locProtectedChildren[j] && locProtectedChildren[j].visit(this); } if (locGrid && locGrid._active) @@ -103,7 +107,7 @@ t4x4Mat[13] = trans.ty; // Update Z vertex manually - t4x4Mat[14] = this._vertexZ; + t4x4Mat[14] = node._vertexZ; //optimize performance for Javascript cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); @@ -116,4 +120,5 @@ for( i = 0, len = locChildren.length; i< len; i++) locChildren[i]._renderCmd.transform(this); }; + })(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js index 2879618e01..aecd399a6e 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js @@ -32,17 +32,18 @@ var proto = ccui.Scale9Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = ccui.Scale9Sprite.WebGLRenderCmd; - proto.visit = function(){ - if(!this._visible){ + proto.visit = function(parentCmd){ + var node = this._node; + if(!node._visible){ return; } - if (this._positionsAreDirty) { - this._updatePositions(); - this._positionsAreDirty = false; - this._scale9Dirty = true; + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; } - cc.Node.prototype.visit.call(this, ctx); + cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); }; })(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index bd1d4675cf..d078172802 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -216,8 +216,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, isSwallowTouches: function(){ - if (this._touchListener) - { + if (this._touchListener){ //todo return true; //return this._touchListener.isSwallowTouches(); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index be2dfeb433..da3c4a270a 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -63,37 +63,13 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _finalPositionX: 0, _finalPositionY: 0, - //clipping - _currentStencilEnabled: 0, - _currentStencilWriteMask: 0, - _currentStencilFunc: 0, - _currentStencilRef:0, - _currentStencilValueMask:0, - _currentStencilFail:0, - _currentStencilPassDepthFail:0, - _currentStencilPassDepthPass:0, - _currentDepthWriteMask:0, - - _currentAlphaTestEnabled:0, - _currentAlphaTestFunc:0, - _currentAlphaTestRef:0, - _backGroundImageOpacity:0, - _mask_layer_le: 0, - _loopFocus: false, //whether enable loop focus or not __passFocusToChild: false, //on default, it will pass the focus to the next nearest widget _isFocusPassing:false, //when finding the next focused widget, use this variable to pass focus between layout & widget _isInterceptTouch: false, - //add renderer for webgl - _beforeVisitCmdStencil: null, - _afterDrawStencilCmd: null, - _afterVisitCmdStencil: null, - _beforeVisitCmdScissor: null, - _afterVisitCmdScissor: null, - _clipElemType: false, /** @@ -121,20 +97,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._clippingRect = cc.rect(0, 0, 0, 0); this._backGroundImageColor = cc.color(255, 255, 255, 255); - - if(cc._renderType == cc._RENDER_TYPE_CANVAS){ - this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._onRenderSaveCmd); - this._rendererSaveCmdSprite = new cc.CustomRenderCmd(this, this._onRenderSaveSpriteCmd); - this._rendererClipCmd = new cc.CustomRenderCmd(this, this._onRenderClipCmd); - this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._onRenderRestoreCmd); - - }else{ - this._beforeVisitCmdStencil = new cc.CustomRenderCmd(this, this._onBeforeVisitStencil); - this._afterDrawStencilCmd = new cc.CustomRenderCmd(this, this._onAfterDrawStencil); - this._afterVisitCmdStencil = new cc.CustomRenderCmd(this, this._onAfterVisitStencil); - this._beforeVisitCmdScissor = new cc.CustomRenderCmd(this, this._onBeforeVisitScissor); - this._afterVisitCmdScissor = new cc.CustomRenderCmd(this, this._onAfterVisitScissor); - } }, /** @@ -293,21 +255,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return false; }, - __stencilDraw: function(ctx){ //Only for Canvas - var locContext = ctx || cc._renderContext; - var stencil = this._clippingStencil; - var locEGL_ScaleX = cc.view.getScaleX(), locEGL_ScaleY = cc.view.getScaleY(); - for (var i = 0; i < stencil._buffer.length; i++) { - var element = stencil._buffer[i]; - var vertices = element.verts; - var firstPoint = vertices[0]; - locContext.beginPath(); - locContext.moveTo(firstPoint.x * locEGL_ScaleX, -firstPoint.y * locEGL_ScaleY); - for (var j = 1, len = vertices.length; j < len; j++) - locContext.lineTo(vertices[j].x * locEGL_ScaleX, -vertices[j].y * locEGL_ScaleY); - } - }, - /** * Adds a widget to the container. * @param {ccui.Widget} widget @@ -378,10 +325,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._clippingEnabled) { switch (this._clippingType) { case ccui.Layout.CLIPPING_STENCIL: - this._stencilClippingVisit(ctx); + this._renderCmd.stencilClippingVisit(ctx); break; case ccui.Layout.CLIPPING_SCISSOR: - this._scissorClippingVisit(ctx); + this._renderCmd.scissorClippingVisit(ctx); break; default: break; @@ -390,212 +337,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ ccui.Widget.prototype.visit.call(this, ctx); }, - _stencilClippingVisit: null, - - _stencilClippingVisitForWebGL: function (ctx) { - var gl = ctx || cc._renderContext; - - if (!this._clippingStencil || !this._clippingStencil.isVisible()) - return; - - // all the _stencilBits are in use? - if (ccui.Layout._layer + 1 == cc.stencilBits) { - // warn once - ccui.Layout._visit_once = true; - if (ccui.Layout._visit_once) { - cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its childs."); - ccui.Layout._visit_once = false; - } - // draw everything, as if there where no stencil - cc.Node.prototype.visit.call(this, ctx); - return; - } - - cc.renderer.pushRenderCommand(this._beforeVisitCmdStencil); - - //optimize performance for javascript - var currentStack = cc.current_stack; - currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); - currentStack.top = this._stackMatrix; - - this.transform(); - this._clippingStencil.visit(); - - cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); - - // draw (according to the stencil test func) this node and its childs - var i = 0; // used by _children - var j = 0; // used by _protectedChildren - - this.sortAllChildren(); - this.sortAllProtectedChildren(); - var locChildren = this._children, locProtectChildren = this._protectedChildren; - var iLen = locChildren.length, jLen = locProtectChildren.length, child; - for( ; i < iLen; i++ ){ - child = locChildren[i]; - if ( child && child.getLocalZOrder() < 0 ) - child.visit(); - else - break; - } - for( ; j < jLen; j++ ) { - child = locProtectChildren[j]; - if ( child && child.getLocalZOrder() < 0 ) - child.visit(); - else - break; - } - //this.draw(); //draw self - if(this._renderCmd) - cc.renderer.pushRenderCommand(this._renderCmd); - for (; i < iLen; i++) - locChildren[i].visit(); - for (; j < jLen; j++) - locProtectChildren[j].visit(); - - cc.renderer.pushRenderCommand(this._afterVisitCmdStencil); - - //optimize performance for javascript - currentStack.top = currentStack.stack.pop(); - }, - //TODO - _stencilClippingVisitForCanvas: function (ctx) { - if (!this._clippingStencil || !this._clippingStencil.isVisible()) { - return; - } - - var i, locChild; - if (this._stencil instanceof cc.Sprite) { - this._clipElemType = true; - }else{ - this._clipElemType = false; - } - - var context = ctx || cc._renderContext; - - this.transform(); - - if(this._rendererSaveCmd) - cc.renderer.pushRenderCommand(this._rendererSaveCmd); - - if (this._clipElemType) { - cc.ProtectedNode.prototype.visit.call(this, context); - - if(this._rendererSaveCmdSprite) - cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite); - - this._clippingStencil.visit(this._renderCmd); - - }else{ - this._clippingStencil.visit(this._renderCmd); - } - - if(this._rendererClipCmd) - cc.renderer.pushRenderCommand(this._rendererClipCmd); - - if (this._clipElemType) { - - }else{ - this.sortAllChildren(); - this.sortAllProtectedChildren(); - - var children = this._children; - var j, locProtectChildren = this._protectedChildren; - var iLen = children.length, jLen = locProtectChildren.length; - - // draw children zOrder < 0 - for (i = 0; i < iLen; i++) { - locChild = children[i]; - if (locChild && locChild._localZOrder < 0) - locChild.visit(this._renderCmd); - else - break; - } - for (j = 0; j < jLen; j++) { - locChild = locProtectChildren[j]; - if (locChild && locChild._localZOrder < 0) - locChild.visit(this._renderCmd); - else - break; - } - //this.draw(context); - for (; i < iLen; i++) - children[i].visit(this._renderCmd); - for (; j < jLen; j++) - locProtectChildren[j].visit(this._renderCmd); - - if(this._rendererRestoreCmd) - cc.renderer.pushRenderCommand(this._rendererRestoreCmd); - } - }, - - _onRenderSaveCmd: function(ctx, scaleX, scaleY){ - var context = ctx || cc._renderContext; - - if (this._clipElemType) { - var canvas = context.canvas; - this._locCache = ccui.Layout._getSharedCache(); - this._locCache.width = canvas.width; - this._locCache.height = canvas.height; - var locCacheCtx = this._locCache.getContext("2d"); - locCacheCtx.drawImage(canvas, 0, 0); - - context.save(); - }else{ - var parentCmd = this._parent ? this._parent._renderCmd : null; - this.transform(parentCmd); - var t = this._renderCmd._worldTransform; - context.save(); - context.save(); - context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - } - - }, - _onRenderSaveSpriteCmd: function(ctx){ - var context = ctx || cc._renderContext; - - if (this._clipElemType) { - context.globalCompositeOperation = "destination-in"; - - var parentCmd = this._parent ? this._parent._renderCmd : null; - this.transform(parentCmd); - }else{} - }, - _onRenderClipCmd: function(ctx){ - var context = ctx || cc._renderContext; - - if (this._clipElemType) { - - }else{ - context.restore(); - context.clip(); - } - }, - _onRenderRestoreCmd: function(ctx){ - var context = ctx || cc._renderContext; - - if (this._clipElemType) { - context.restore(); - - // Redraw the cached canvas, so that the cliped area shows the background etc. - context.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.globalCompositeOperation = "destination-over"; - context.drawImage(this._node._locCache, 0, 0); - context.restore(); - }else{ - context.restore(); - } - }, - - _scissorClippingVisit: null, - _scissorClippingVisitForWebGL: function (ctx) { - cc.renderer.pushRenderCommand(this._beforeVisitCmdScissor); - cc.ProtectedNode.prototype.visit.call(this); - cc.renderer.pushRenderCommand(this._afterVisitCmdScissor); - }, - /** * Changes if layout can clip it's content and locChild. * If you really need this, please enable it. But it would reduce the rendering efficiency. @@ -609,8 +350,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Layout.CLIPPING_STENCIL: if (able){ this._clippingStencil = new cc.DrawNode(); - if(cc._renderType === cc._RENDER_TYPE_CANVAS) - this._clippingStencil._renderCmd.rendering = this.__stencilDraw.bind(this); + this._renderCmd.rebindStencilRendering(this._clippingStencil); if (this._running) this._clippingStencil.onEnter(); this._setStencilClippingSize(this._contentSize); @@ -1151,89 +891,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return this.getChildren(); }, - //clipping - _onBeforeVisitStencil: function(ctx){ - var gl = ctx || cc._renderContext; - - ccui.Layout._layer++; - - var mask_layer = 0x1 << ccui.Layout._layer; - var mask_layer_l = mask_layer - 1; - this._mask_layer_le = mask_layer | mask_layer_l; - - // manually save the stencil state - this._currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); - this._currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); - this._currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); - this._currentStencilRef = gl.getParameter(gl.STENCIL_REF); - this._currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); - this._currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); - this._currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); - this._currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); - - gl.enable(gl.STENCIL_TEST); - - gl.stencilMask(mask_layer); - - this._currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); - - gl.depthMask(false); - - gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(gl.ZERO, gl.KEEP, gl.KEEP); - - // draw a fullscreen solid rectangle to clear the stencil buffer - this._drawFullScreenQuadClearStencil(); - - gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); - gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP); - }, - - _drawFullScreenQuadClearStencil:function(){ - // draw a fullscreen solid rectangle to clear the stencil buffer - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc._drawingUtil.drawSolidRect(cc.p(-1,-1), cc.p(1,1), cc.color(255, 255, 255, 255)); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix(); - }, - - _onAfterDrawStencil: function(ctx){ - var gl = ctx || cc._renderContext; - gl.depthMask(this._currentDepthWriteMask); - gl.stencilFunc(gl.EQUAL, this._mask_layer_le, this._mask_layer_le); - gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); - }, - - _onAfterVisitStencil: function(ctx){ - var gl = ctx || cc._renderContext; - // manually restore the stencil state - gl.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask); - gl.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass); - gl.stencilMask(this._currentStencilWriteMask); - if (!this._currentStencilEnabled) - gl.disable(gl.STENCIL_TEST); - ccui.Layout._layer--; - }, - - _onBeforeVisitScissor: function(ctx){ - var clippingRect = this._getClippingRect(); - var gl = ctx || cc._renderContext; - gl.enable(gl.SCISSOR_TEST); - - cc.view.setScissorInPoints(clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height); - }, - - _onAfterVisitScissor: function(ctx){ - gl.disable(gl.SCISSOR_TEST); - }, - _updateBackGroundImageOpacity: function(){ if (this._backGroundImage) this._backGroundImage.setOpacity(this._backGroundImageOpacity); @@ -1814,34 +1471,15 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ // this._backGroundImage.transform(this._renderCmd); // this._backGroundImage._renderCmd._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; } - } + }, -// _transformForRenderer: function(parentMatrix){ -// if(cc._renderType === cc._RENDER_TYPE_WEBGL){ -// ccui.Widget.prototype._transformForRenderer.call(this, parentMatrix); -// if(this._clippingStencil) -// this._clippingStencil._transformForRenderer(this._stackMatrix); -// }else{ -// ccui.ProtectedNode.prototype._transformForRenderer.call(this); -// } -// } + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + return new ccui.Layout.WebGLRenderCmd(this); + else + return new ccui.Layout.CanvasRenderCmd(this); + } }); -ccui.Layout._init_once = null; -ccui.Layout._visit_once = null; -ccui.Layout._layer = -1; -ccui.Layout._sharedCache = null; - -if (cc._renderType == cc._RENDER_TYPE_WEBGL) { - //WebGL - ccui.Layout.prototype._stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForWebGL; - ccui.Layout.prototype._scissorClippingVisit = ccui.Layout.prototype._scissorClippingVisitForWebGL; -} else { - ccui.Layout.prototype._stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; - ccui.Layout.prototype._scissorClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas; -} -ccui.Layout._getSharedCache = function () { - return (cc.ClippingNode._sharedCache) || (cc.ClippingNode._sharedCache = cc.newElement("canvas")); -}; var _p = ccui.Layout.prototype; diff --git a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js new file mode 100644 index 0000000000..0180bb556a --- /dev/null +++ b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js @@ -0,0 +1,195 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + ccui.Layout.CanvasRenderCmd = function(renderable){ + ccui.ProtectedNode.CanvasRenderCmd.call(this, renderable); + this._needDraw = false; + + this._locCache = null; + + this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._onRenderSaveCmd); + this._rendererSaveCmdSprite = new cc.CustomRenderCmd(this, this._onRenderSaveSpriteCmd); + this._rendererClipCmd = new cc.CustomRenderCmd(this, this._onRenderClipCmd); + this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._onRenderRestoreCmd); + }; + + var proto = ccui.Layout.CanvasRenderCmd.prototype = Object.create(ccui.ProtectedNode.WebGLRenderCmd.prototype); + proto.constructor = ccui.Layout.CanvasRenderCmd; + + proto._onRenderSaveCmd = function(ctx, scaleX, scaleY){ + var context = ctx || cc._renderContext; + + var node = this._node; + if (node._clipElemType) { + var canvas = context.canvas; + this._locCache = ccui.Layout.CanvasRenderCmd._getSharedCache(); + this._locCache.width = canvas.width; + this._locCache.height = canvas.height; + var locCacheCtx = this._locCache.getContext("2d"); + locCacheCtx.drawImage(canvas, 0, 0); + context.save(); + }else{ + var parentCmd = node._parent ? node._parent._renderCmd : null; + this.transform(parentCmd); + var t = this._worldTransform; + context.save(); + context.save(); + context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); + } + }; + + proto._onRenderSaveSpriteCmd = function(ctx){ + var context = ctx || cc._renderContext; + + var node = this._node; + if (node._clipElemType) { + context.globalCompositeOperation = "destination-in"; + + var parentCmd = node._parent ? node._parent._renderCmd : null; + this.transform(parentCmd); + }else{ + } + }; + + proto._onRenderClipCmd = function(ctx){ + var context = ctx || cc._renderContext; + + if (this._node._clipElemType) { + }else{ + context.restore(); + context.clip(); + } + }; + + proto._onRenderRestoreCmd = function(ctx){ + var context = ctx || cc._renderContext; + + var node = this._node; + if (node._clipElemType) { + context.restore(); + + // Redraw the cached canvas, so that the cliped area shows the background etc. + context.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.globalCompositeOperation = "destination-over"; + context.drawImage(this._locCache, 0, 0); + context.restore(); + }else{ + context.restore(); + } + }; + + proto.rebindStencilRendering = function(stencil){ + stencil._renderCmd.rendering = this.__stencilDraw; + }; + + proto.__stencilDraw = function(ctx,scaleX, scaleY){ //Only for Canvas + var locContext = ctx || cc._renderContext; + var buffer = this._buffer; + for (var i = 0, bufLen = buffer.length; i < bufLen; i++) { + var element = buffer[i], vertices = element.verts; + var firstPoint = vertices[0]; + locContext.beginPath(); + locContext.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); + for (var j = 1, len = vertices.length; j < len; j++) + locContext.lineTo(vertices[j].x * scaleX, -vertices[j].y * scaleY); + } + }; + + proto.stencilClippingVisit = proto.scissorClippingVisit = function(parentCmd){ + if (!this._clippingStencil || !this._clippingStencil.isVisible()) { + return; + } + + var i, locChild; + if (this._stencil instanceof cc.Sprite) { + this._clipElemType = true; + }else{ + this._clipElemType = false; + } + + var context = ctx || cc._renderContext; + + this.transform(); + + if(this._rendererSaveCmd) + cc.renderer.pushRenderCommand(this._rendererSaveCmd); + + if (this._clipElemType) { + cc.ProtectedNode.prototype.visit.call(this, context); + + if(this._rendererSaveCmdSprite) + cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite); + + this._clippingStencil.visit(this._renderCmd); + + }else{ + this._clippingStencil.visit(this._renderCmd); + } + + if(this._rendererClipCmd) + cc.renderer.pushRenderCommand(this._rendererClipCmd); + + if (this._clipElemType) { + + }else{ + this.sortAllChildren(); + this.sortAllProtectedChildren(); + + var children = this._children; + var j, locProtectChildren = this._protectedChildren; + var iLen = children.length, jLen = locProtectChildren.length; + + // draw children zOrder < 0 + for (i = 0; i < iLen; i++) { + locChild = children[i]; + if (locChild && locChild._localZOrder < 0) + locChild.visit(this._renderCmd); + else + break; + } + for (j = 0; j < jLen; j++) { + locChild = locProtectChildren[j]; + if (locChild && locChild._localZOrder < 0) + locChild.visit(this._renderCmd); + else + break; + } + //this.draw(context); + for (; i < iLen; i++) + children[i].visit(this._renderCmd); + for (; j < jLen; j++) + locProtectChildren[j].visit(this._renderCmd); + + if(this._rendererRestoreCmd) + cc.renderer.pushRenderCommand(this._rendererRestoreCmd); + } + }; + + ccui.Layout.CanvasRenderCmd._getSharedCache = function () { + return (cc.ClippingNode._sharedCache) || (cc.ClippingNode._sharedCache = cc.newElement("canvas")); + }; +})(); \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js new file mode 100644 index 0000000000..60867944d6 --- /dev/null +++ b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js @@ -0,0 +1,210 @@ +/**************************************************************************** + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(){ + ccui.Layout.WebGLRenderCmd = function(renderable){ + ccui.ProtectedNode.WebGLRenderCmd.call(this, renderable); + this._needDraw = false; + + this._currentStencilEnabled = 0; + this._currentStencilWriteMask = 0; + this._currentStencilFunc = 0; + this._currentStencilRef = 0; + this._currentStencilValueMask = 0; + this._currentStencilFail = 0; + this._currentStencilPassDepthFail = 0; + this._currentStencilPassDepthPass = 0; + this._currentDepthWriteMask = false; + + this._mask_layer_le = 0; + + this._beforeVisitCmdStencil = new cc.CustomRenderCmd(this, this._onBeforeVisitStencil); + this._afterDrawStencilCmd = new cc.CustomRenderCmd(this, this._onAfterDrawStencil); + this._afterVisitCmdStencil = new cc.CustomRenderCmd(this, this._onAfterVisitStencil); + this._beforeVisitCmdScissor = new cc.CustomRenderCmd(this, this._onBeforeVisitScissor); + this._afterVisitCmdScissor = new cc.CustomRenderCmd(this, this._onAfterVisitScissor); + }; + + var proto = ccui.Layout.WebGLRenderCmd.prototype = Object.create(ccui.ProtectedNode.WebGLRenderCmd.prototype); + proto.constructor = ccui.Layout.WebGLRenderCmd; + + proto._onBeforeVisitStencil = function(ctx){ + var gl = ctx || cc._renderContext; + + ccui.Layout.WebGLRenderCmd._layer++; + + var mask_layer = 0x1 << ccui.Layout.WebGLRenderCmd._layer; + var mask_layer_l = mask_layer - 1; + this._mask_layer_le = mask_layer | mask_layer_l; + + // manually save the stencil state + this._currentStencilEnabled = gl.isEnabled(gl.STENCIL_TEST); + this._currentStencilWriteMask = gl.getParameter(gl.STENCIL_WRITEMASK); + this._currentStencilFunc = gl.getParameter(gl.STENCIL_FUNC); + this._currentStencilRef = gl.getParameter(gl.STENCIL_REF); + this._currentStencilValueMask = gl.getParameter(gl.STENCIL_VALUE_MASK); + this._currentStencilFail = gl.getParameter(gl.STENCIL_FAIL); + this._currentStencilPassDepthFail = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); + this._currentStencilPassDepthPass = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); + + gl.enable(gl.STENCIL_TEST); + + gl.stencilMask(mask_layer); + + this._currentDepthWriteMask = gl.getParameter(gl.DEPTH_WRITEMASK); + + gl.depthMask(false); + + gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); + gl.stencilOp(gl.ZERO, gl.KEEP, gl.KEEP); + + // draw a fullscreen solid rectangle to clear the stencil buffer + this._drawFullScreenQuadClearStencil(); + + gl.stencilFunc(gl.NEVER, mask_layer, mask_layer); + gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP); + }; + + proto._onAfterDrawStencil = function(ctx){ + var gl = ctx || cc._renderContext; + gl.depthMask(this._currentDepthWriteMask); + gl.stencilFunc(gl.EQUAL, this._mask_layer_le, this._mask_layer_le); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + }; + + proto._onAfterVisitStencil = function(ctx){ + var gl = ctx || cc._renderContext; + // manually restore the stencil state + gl.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask); + gl.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass); + gl.stencilMask(this._currentStencilWriteMask); + if (!this._currentStencilEnabled) + gl.disable(gl.STENCIL_TEST); + ccui.Layout.WebGLRenderCmd._layer--; + }; + + proto._onBeforeVisitScissor = function(ctx){ + var clippingRect = this._getClippingRect(); + var gl = ctx || cc._renderContext; + gl.enable(gl.SCISSOR_TEST); + + cc.view.setScissorInPoints(clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height); + }; + + proto._onAfterVisitScissor = function(ctx){ + var gl = ctx || cc._renderContext; + gl.disable(gl.SCISSOR_TEST); + }; + + proto._drawFullScreenQuadClearStencil = function(){ + // draw a fullscreen solid rectangle to clear the stencil buffer + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadIdentity(); + cc._drawingUtil.drawSolidRect(cc.p(-1,-1), cc.p(1,1), cc.color(255, 255, 255, 255)); + cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + cc.kmGLPopMatrix(); + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPopMatrix(); + }; + + proto.rebindStencilRendering = function(stencil){}; + + proto.stencilClippingVisit = function (parentCmd) { + var node = this._node; + if (!node._clippingStencil || !node._clippingStencil.isVisible()) + return; + + // all the _stencilBits are in use? + if (ccui.Layout.WebGLRenderCmd._layer + 1 == cc.stencilBits) { + // warn once + ccui.Layout.WebGLRenderCmd._visit_once = true; + if (ccui.Layout.WebGLRenderCmd._visit_once) { + cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its childs."); + ccui.Layout.WebGLRenderCmd._visit_once = false; + } + // draw everything, as if there where no stencil + cc.Node.prototype.visit.call(this, parentCmd); + return; + } + + cc.renderer.pushRenderCommand(this._beforeVisitCmdStencil); + + //optimize performance for javascript + var currentStack = cc.current_stack; + currentStack.stack.push(currentStack.top); + this._syncStatus(parentCmd); + currentStack.top = this._stackMatrix; + + this._clippingStencil.visit(parentCmd); + + cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); + + // draw (according to the stencil test func) this node and its childs + var i = 0; // used by _children + var j = 0; // used by _protectedChildren + + node.sortAllChildren(); + node.sortAllProtectedChildren(); + var locChildren = node._children, locProtectChildren = node._protectedChildren; + var iLen = locChildren.length, jLen = locProtectChildren.length, child; + for( ; i < iLen; i++ ){ + child = locChildren[i]; + if ( child && child.getLocalZOrder() < 0 ) + child.visit(parentCmd); + else + break; + } + for( ; j < jLen; j++ ) { + child = locProtectChildren[j]; + if ( child && child.getLocalZOrder() < 0 ) + child.visit(parentCmd); + else + break; + } + + for (; i < iLen; i++) + locChildren[i].visit(parentCmd); + for (; j < jLen; j++) + locProtectChildren[j].visit(parentCmd); + + cc.renderer.pushRenderCommand(this._afterVisitCmdStencil); + + //optimize performance for javascript + currentStack.top = currentStack.stack.pop(); + }; + + proto.scissorClippingVisit = function(parentCmd){ + cc.renderer.pushRenderCommand(this._beforeVisitCmdScissor); + cc.ProtectedNode.prototype.visit.call(this, parentCmd); + cc.renderer.pushRenderCommand(this._afterVisitCmdScissor); + }; + + ccui.Layout.WebGLRenderCmd._layer = -1; + ccui.Layout.WebGLRenderCmd._visit_once = null; +})(); diff --git a/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js b/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js index 056a6617ea..043ef907be 100644 --- a/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js +++ b/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js @@ -57,5 +57,4 @@ cc.inject(ccs.Skin.RenderCmd, proto); proto.constructor = ccs.Skin.CanvasRenderCmd; - })(); diff --git a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js index cc5c708da8..047d00ccc3 100644 --- a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js @@ -68,5 +68,4 @@ } cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); }; - })(); \ No newline at end of file diff --git a/extensions/spine/CCSkeletonCanvasRenderCmd.js b/extensions/spine/CCSkeletonCanvasRenderCmd.js index e35d6c21ad..523087b811 100644 --- a/extensions/spine/CCSkeletonCanvasRenderCmd.js +++ b/extensions/spine/CCSkeletonCanvasRenderCmd.js @@ -135,5 +135,4 @@ selSprite.setRotation(- (slot.bone.worldRotation + attachment.rotation)); } }; - })(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 06a7b28042..a2065b2a63 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -304,6 +304,8 @@ "extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js", "extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js", "extensions/ccui/layouts/UILayout.js", + "extensions/ccui/layouts/UILayoutCanvasRenderCmd.js", + "extensions/ccui/layouts/UILayoutWebGLRenderCmd.js", "extensions/ccui/layouts/UILayoutParameter.js", "extensions/ccui/layouts/UILayoutManager.js", "extensions/ccui/layouts/UIHBox.js", From 132b94ab98711de62d2087729975ab84f6ef1308 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 4 Dec 2014 13:58:43 +0800 Subject: [PATCH 1024/1564] Issue #2416: Fixed a bug that sprite set color error --- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 0b18561c19..06311b611f 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -232,7 +232,9 @@ this._dirty = true; //use for batching }; - proto._setColorDirty = function () { + proto._setColorDirty = function () {}; + + proto._updateColor = function () { var locDisplayedColor = this._displayedColor, locDisplayedOpacity = this._displayedOpacity, node = this._node; var color4 = {r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: locDisplayedOpacity}; // special opacity for premultiplied textures From 1ac1d6bf2e0171edf9f40410fc6ab2483b39c6cc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 4 Dec 2014 14:18:25 +0800 Subject: [PATCH 1025/1564] cocos2d-js#1161: Avoid issue when user remove a menu item during the callback --- cocos2d/menus/CCMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 6249588aee..4bac0c3749 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -480,8 +480,8 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ } if (target._selectedItem) { target._selectedItem.unselected(); - target._selectedItem.activate(); target._selectedItem.setNodeDirty(); + target._selectedItem.activate(); } target._state = cc.MENU_STATE_WAITING; }, From 631ab9ccf18a41fc26251561696c30ab2b34c6e9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 4 Dec 2014 14:18:55 +0800 Subject: [PATCH 1026/1564] cocos2d-js#1165: Made Sequence taken account of the repeat _times attribute --- cocos2d/actions/CCActionInterval.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 5fd9213b5d..c7e8ed2a19 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -423,9 +423,10 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ * @param {Number} dt */ update:function (dt) { - dt = this._computeEaseTime(dt); 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, actionFound; + + dt = this._computeEaseTime(dt); if (dt < locSplit) { // action[0] new_t = (locSplit !== 0) ? dt / locSplit : 1; @@ -456,15 +457,17 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ } } + actionFound = locActions[found]; // Last action found and it is done. - if (locLast === found && locActions[found].isDone()) + if (locLast === found && actionFound.isDone()) return; // Last action found and it is done if (locLast !== found) - locActions[found].startWithTarget(this.target); + actionFound.startWithTarget(this.target); - locActions[found].update(new_t); + new_t = new_t * actionFound._times; + actionFound.update(new_t > 1 ? new_t % 1 : new_t); this._last = found; }, From c9ee5cc6c76a19a8d3c35f9e87c2f51fbce807e4 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Dec 2014 15:38:14 +0800 Subject: [PATCH 1027/1564] Issue #2416: correct a mistake of cc.ProtectedNode and ccui.Layout --- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 4 +- .../ccui/base-classes/CCProtectedNode.js | 4 +- .../CCProtectedNodeCanvasRenderCmd.js | 15 +++-- .../CCProtectedNodeWebGLRenderCmd.js | 53 +++++++++++++---- .../ccui/layouts/UILayoutCanvasRenderCmd.js | 57 +++++++------------ .../ccui/layouts/UILayoutWebGLRenderCmd.js | 14 ++--- .../uiwidgets/scroll-widget/UIPageView.js | 2 +- 7 files changed, 83 insertions(+), 66 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 724fec088a..7a42486e18 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -184,9 +184,7 @@ // Convert 3x3 into 4x4 matrix var trans = this.getNodeToParentTransform(); - - if(cc.Node._dirtyFlags.transformDirty & this._dirtyFlag) - this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index b14830e86b..3a24e7a044 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -230,8 +230,8 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ * @function * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx context of renderer */ - visit: function(){ - this._renderCmd._visit(); + visit: function(parentCmd){ + this._renderCmd._visit(parentCmd); }, _changePosition: function(){}, diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index b8d903c462..93ee74108c 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -137,7 +137,7 @@ return; //visit for canvas - var context = ctx || cc._renderContext, i, j; + var i, j; var children = node._children, child; var locChildren = node._children, locProtectedChildren = node._protectedChildren; var childLen = locChildren.length, pLen = locProtectedChildren.length; @@ -205,11 +205,16 @@ worldT.ty = t.ty; } var i, len, locChildren = node._children; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._renderCmd.transform(this); + if(recursive && locChildren && locChildren.length !== 0){ + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(this, recursive); + } } locChildren = node._protectedChildren; - for( i = 0, len = locChildren.length; i< len; i++) - locChildren[i]._renderCmd.transform(this); + if(recursive && locChildren && locChildren.length !== 0){ + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(this, recursive); + } + } }; })(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index 45a62251d7..e670e4e97f 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -33,8 +33,8 @@ cc.inject(cc.ProtectedNode.RenderCmd, proto); proto.constructor = cc.ProtectedNode.WebGLRenderCmd; - proto.visit = function(){ - this._node.visit(); //todo refactor late + proto.visit = function(parentCmd){ + this._node.visit(parentCmd); //todo refactor late }; proto._visit = function(parentCmd){ @@ -42,18 +42,18 @@ // quick return if not visible if (!node._visible) return; - var context = cc._renderContext, i, currentStack = cc.current_stack, j; + var i, j, currentStack = cc.current_stack; //optimize performance for javascript currentStack.stack.push(currentStack.top); - cc.kmMat4Assign(this._stackMatrix, currentStack.top); + this._syncStatus(parentCmd); currentStack.top = this._stackMatrix; var locGrid = node.grid; if (locGrid && locGrid._active) locGrid.beforeDraw(); - node.transform(node._parent && node._parent._renderCmd); + //node.transform(node._parent && node._parent._renderCmd); var locChildren = node._children, locProtectedChildren = node._protectedChildren; var childLen = locChildren.length, pLen = locProtectedChildren.length; @@ -91,13 +91,16 @@ currentStack.top = currentStack.stack.pop(); }; - proto.transform = function(parentCmd){ + proto.transform = function(parentCmd, recursive){ var node = this._node; var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, parentMatrix = parentCmd ? parentCmd._stackMatrix : cc.current_stack.top; // Convert 3x3 into 4x4 matrix var trans = node.getNodeToParentTransform(); + + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; + var t4x4Mat = t4x4.mat; t4x4Mat[0] = trans.a; t4x4Mat[4] = trans.c; @@ -112,13 +115,41 @@ //optimize performance for Javascript cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); + // XXX: Expensive calls. Camera should be integrated into the cached affine matrix + if (node._camera != null && !(node.grid != null && node.grid.isActive())) { + var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; + var translate = (apx !== 0.0 || apy !== 0.0); + if (translate){ + if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { + apx = 0 | apx; + apy = 0 | apy; + } + //cc.kmGLTranslatef(apx, apy, 0); + var translation = new cc.kmMat4(); + cc.kmMat4Translation(translation, apx, apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + + node._camera._locateForRenderer(stackMatrix); + + //cc.kmGLTranslatef(-apx, -apy, 0); + cc.kmMat4Translation(translation, -apx, -apy, 0); + cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + } else { + node._camera._locateForRenderer(stackMatrix); + } + } + var i, len, locChildren = node._children; - for(i = 0, len = locChildren.length; i< len; i++){ - locChildren[i]._renderCmd.transform(this); + if(recursive && locChildren && locChildren.length !== 0){ + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(this, recursive); + } } locChildren = node._protectedChildren; - for( i = 0, len = locChildren.length; i< len; i++) - locChildren[i]._renderCmd.transform(this); + if(recursive && locChildren && locChildren.length !== 0){ + for(i = 0, len = locChildren.length; i< len; i++){ + locChildren[i]._renderCmd.transform(this, recursive); + } + } }; - })(); \ No newline at end of file diff --git a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js index 0180bb556a..bc5bdfd865 100644 --- a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js @@ -36,7 +36,7 @@ this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._onRenderRestoreCmd); }; - var proto = ccui.Layout.CanvasRenderCmd.prototype = Object.create(ccui.ProtectedNode.WebGLRenderCmd.prototype); + var proto = ccui.Layout.CanvasRenderCmd.prototype = Object.create(ccui.ProtectedNode.CanvasRenderCmd.prototype); proto.constructor = ccui.Layout.CanvasRenderCmd; proto._onRenderSaveCmd = function(ctx, scaleX, scaleY){ @@ -120,72 +120,55 @@ }; proto.stencilClippingVisit = proto.scissorClippingVisit = function(parentCmd){ - if (!this._clippingStencil || !this._clippingStencil.isVisible()) { + var node = this._node; + if (!node._clippingStencil || !node._clippingStencil.isVisible()) return; - } var i, locChild; - if (this._stencil instanceof cc.Sprite) { - this._clipElemType = true; - }else{ - this._clipElemType = false; - } - - var context = ctx || cc._renderContext; + node._clipElemType = node._stencil instanceof cc.Sprite; this.transform(); - if(this._rendererSaveCmd) - cc.renderer.pushRenderCommand(this._rendererSaveCmd); - - if (this._clipElemType) { - cc.ProtectedNode.prototype.visit.call(this, context); + cc.renderer.pushRenderCommand(this._rendererSaveCmd); - if(this._rendererSaveCmdSprite) - cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite); - - this._clippingStencil.visit(this._renderCmd); - - }else{ - this._clippingStencil.visit(this._renderCmd); + if (node._clipElemType) { + cc.ProtectedNode.prototype.visit.call(node, parentCmd); + cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite); } + node._clippingStencil.visit(this); - if(this._rendererClipCmd) - cc.renderer.pushRenderCommand(this._rendererClipCmd); - - if (this._clipElemType) { + cc.renderer.pushRenderCommand(this._rendererClipCmd); - }else{ - this.sortAllChildren(); - this.sortAllProtectedChildren(); + if (!node._clipElemType) { + node.sortAllChildren(); + node.sortAllProtectedChildren(); - var children = this._children; - var j, locProtectChildren = this._protectedChildren; + var children = node._children; + var j, locProtectChildren = node._protectedChildren; var iLen = children.length, jLen = locProtectChildren.length; // draw children zOrder < 0 for (i = 0; i < iLen; i++) { locChild = children[i]; if (locChild && locChild._localZOrder < 0) - locChild.visit(this._renderCmd); + locChild.visit(this); else break; } for (j = 0; j < jLen; j++) { locChild = locProtectChildren[j]; if (locChild && locChild._localZOrder < 0) - locChild.visit(this._renderCmd); + locChild.visit(this); else break; } //this.draw(context); for (; i < iLen; i++) - children[i].visit(this._renderCmd); + children[i].visit(this); for (; j < jLen; j++) - locProtectChildren[j].visit(this._renderCmd); + locProtectChildren[j].visit(this); - if(this._rendererRestoreCmd) - cc.renderer.pushRenderCommand(this._rendererRestoreCmd); + cc.renderer.pushRenderCommand(this._rendererRestoreCmd); } }; diff --git a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js index 60867944d6..397c983ffd 100644 --- a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js @@ -149,7 +149,7 @@ ccui.Layout.WebGLRenderCmd._visit_once = false; } // draw everything, as if there where no stencil - cc.Node.prototype.visit.call(this, parentCmd); + cc.Node.prototype.visit.call(node, parentCmd); return; } @@ -161,7 +161,7 @@ this._syncStatus(parentCmd); currentStack.top = this._stackMatrix; - this._clippingStencil.visit(parentCmd); + node._clippingStencil.visit(this); cc.renderer.pushRenderCommand(this._afterDrawStencilCmd); @@ -176,22 +176,22 @@ for( ; i < iLen; i++ ){ child = locChildren[i]; if ( child && child.getLocalZOrder() < 0 ) - child.visit(parentCmd); + child.visit(this); else break; } for( ; j < jLen; j++ ) { child = locProtectChildren[j]; if ( child && child.getLocalZOrder() < 0 ) - child.visit(parentCmd); + child.visit(this); else break; } for (; i < iLen; i++) - locChildren[i].visit(parentCmd); + locChildren[i].visit(this); for (; j < jLen; j++) - locProtectChildren[j].visit(parentCmd); + locProtectChildren[j].visit(this); cc.renderer.pushRenderCommand(this._afterVisitCmdStencil); @@ -201,7 +201,7 @@ proto.scissorClippingVisit = function(parentCmd){ cc.renderer.pushRenderCommand(this._beforeVisitCmdScissor); - cc.ProtectedNode.prototype.visit.call(this, parentCmd); + cc.ProtectedNode.prototype.visit.call(this._node, parentCmd); cc.renderer.pushRenderCommand(this._afterVisitCmdScissor); }; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index a10e68f337..36e5676ba4 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -366,7 +366,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); if (!this._isInterceptTouch) { - this.handleReleaseLogic(touch); + this._handleReleaseLogic(touch); } this._isInterceptTouch = false; }, From 5d7f6cff4ea0938e813f679a06ca387535c7f8f0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 4 Dec 2014 16:39:05 +0800 Subject: [PATCH 1028/1564] Issue #2416: UIText position mistake for WebGL --- extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js | 3 +++ extensions/ccui/uiwidgets/UIText.js | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index e670e4e97f..9de3949971 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -99,6 +99,9 @@ // Convert 3x3 into 4x4 matrix var trans = node.getNodeToParentTransform(); + if(node._changePosition) + node._changePosition(); + this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; var t4x4Mat = t4x4.mat; diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index fffd19f90a..8e11a91d0b 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -436,7 +436,6 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ _changePosition: function(){ this._adaptRenderers(); - //this._labelRenderer.transform(this._renderCmd); }, setColor: function(color){ From 882b63b0964af91803eb4af51d44f8914e211ac6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 4 Dec 2014 17:35:26 +0800 Subject: [PATCH 1029/1564] Issue #2416: armature position mistake --- extensions/ccui/uiwidgets/UIRichText.js | 6 +++--- .../cocostudio/armature/CCArmatureCanvasRenderCmd.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 7927dbb4b8..bc4dc3b76e 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -466,12 +466,12 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ /** * Calls formatText before calls parent class' visit. * @override - * @param ctx + * @param parentCmd */ - visit: function (ctx) { + visit: function (parentCmd) { if (this._enabled) { this.formatText(); - ccui.Widget.prototype.visit.call(this, ctx); + ccui.Widget.prototype.visit.call(this, parentCmd); } }, diff --git a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js index c45422e487..3b5dabb383 100644 --- a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js @@ -59,7 +59,8 @@ var context = ctx || cc._renderContext; var node = this._node; context.save(); - node.transform(); + var parent = node._parent; + node.transform(parent ? parent._renderCmd : null); var t = this._worldTransform; ctx.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); @@ -133,7 +134,7 @@ } }; - proto.visit = function(){ + proto.visit = function(parentCmd){ var node = this._node; var context = cc._renderContext; // quick return if not visible. children won't be drawn. @@ -141,7 +142,7 @@ return; context.save(); - this.transform(); + this.transform(parentCmd); node.sortAllChildren(); From a6fcf76af90292b41e69aaf7c066022ceef08f03 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 4 Dec 2014 18:26:55 +0800 Subject: [PATCH 1030/1564] Issue #2416: UILayout display mistake --- .../ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js | 8 ++++---- extensions/ccui/layouts/UILayout.js | 7 ------- extensions/ccui/layouts/UILayoutCanvasRenderCmd.js | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 93ee74108c..3bbd8a60d0 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -126,11 +126,11 @@ cc.inject(cc.ProtectedNode.RenderCmd, proto); proto.constructor = cc.ProtectedNode.CanvasRenderCmd; - proto.visit = function(){ - this._node.visit(); + proto.visit = function(parentCmd){ + this._node.visit(parentCmd); }; - proto._visit = function(){ + proto._visit = function(parentCmd){ var node = this._node; // quick return if not visible if (!node._visible) @@ -142,7 +142,7 @@ var locChildren = node._children, locProtectedChildren = node._protectedChildren; var childLen = locChildren.length, pLen = locProtectedChildren.length; - node.transform(node._parent && node._parent._renderCmd); + this._syncStatus(parentCmd); node.sortAllChildren(); node.sortAllProtectedChildren(); diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index da3c4a270a..4bbe608ca2 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -1466,13 +1466,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._isInterceptTouch = layout._isInterceptTouch; }, - _changePosition: function(){ - if (this._backGroundImage){ -// this._backGroundImage.transform(this._renderCmd); -// this._backGroundImage._renderCmd._dirtyFlag ^= cc.Node._dirtyFlags.transformDirty; - } - }, - _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_WEBGL) return new ccui.Layout.WebGLRenderCmd(this); diff --git a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js index bc5bdfd865..f4edf335d4 100644 --- a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js @@ -127,7 +127,7 @@ var i, locChild; node._clipElemType = node._stencil instanceof cc.Sprite; - this.transform(); + this._syncStatus(parentCmd); cc.renderer.pushRenderCommand(this._rendererSaveCmd); From f8c15802108c4d9741fe710a00ce5da23cd979a2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Dec 2014 20:52:57 +0800 Subject: [PATCH 1031/1564] Issue #2416: correct a mistake of cc.SpriteBatchNode --- cocos2d/core/base-nodes/CCNode.js | 1 - cocos2d/core/sprites/CCSpriteBatchNode.js | 12 +++--------- .../core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js | 6 +++++- cocos2d/tilemap/CCTMXLayer.js | 3 +++ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 8fa0a709fb..2cb59b63e8 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1438,7 +1438,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ child.arrivalOrder = cc.s_globalOrderOfArrival; cc.s_globalOrderOfArrival++; child._setLocalZOrder(zOrder); - this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.orderDirty); }, /** diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index b3824ded16..fa11739604 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -410,7 +410,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite); return; } - this._renderCmd.checkAtlasCapacity(index); + this._renderCmd.insertQuad(sprite, index); // // update the quad directly. Don't add the sprite to the scene graph @@ -422,9 +422,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ // XXX: so, it should be AFTER the insertQuad sprite.dirty = true; sprite.updateTransform(); - - //sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd - this._children.splice(index, 0, sprite); }, /** @@ -458,11 +455,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ sprite.atlasIndex = index; sprite.dirty = true; - var locTextureAtlas = this.getTextureAtlas(); - if (locTextureAtlas.totalQuads >= locTextureAtlas.capacity) - this.increaseAtlasCapacity(); - - locTextureAtlas.insertQuad(sprite.quad, index); + this._renderCmd.insertQuad(sprite, index); this._descendants.splice(index, 0, sprite); // update indices @@ -497,6 +490,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ this._descendants.push(sprite); var index = this._descendants.length - 1; + sprite.atlasIndex = index; this._renderCmd.insertQuad(sprite, index); diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js index 26edfddf25..abf81520dd 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js @@ -41,7 +41,11 @@ this._texture = texture; }; - proto.insertQuad = function(){}; + proto.insertQuad = function(sprite, index){ + var node = this._node; + node._children.splice(index, 0, sprite); + //sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd + }; proto.increaseAtlasCapacity = function(){}; diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index dac70221e9..7c2a0fead0 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -455,6 +455,9 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ return; } + console.log("textureAtlas capacity:" + this.textureAtlas.capacity + " textureAtlas totalQuads:" + this.textureAtlas.totalQuads); + console.log("x:" + pos.x + " y:" + pos.y); + flags = flags || 0; this._setNodeDirtyForCache(); var currentFlags = this.getTileFlagsAt(pos); From 879e47388ac277be34c248fe12b8274b22441e8c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 4 Dec 2014 21:27:26 +0800 Subject: [PATCH 1032/1564] Issue #2416: remove the test codes --- cocos2d/tilemap/CCTMXLayer.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 7c2a0fead0..dac70221e9 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -455,9 +455,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ return; } - console.log("textureAtlas capacity:" + this.textureAtlas.capacity + " textureAtlas totalQuads:" + this.textureAtlas.totalQuads); - console.log("x:" + pos.x + " y:" + pos.y); - flags = flags || 0; this._setNodeDirtyForCache(); var currentFlags = this.getTileFlagsAt(pos); From b6807f971947b3f32e1f0cb99d76c6d3901c4735 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 4 Dec 2014 21:49:59 +0800 Subject: [PATCH 1033/1564] #1108: Add restartGame and cleanScript API for web --- CCBoot.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 65e63c47b5..2df1e30522 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1645,7 +1645,7 @@ cc._initSys = function (config, CONFIG_KEY) { capabilities["accelerometer"] = true; /** - * Forces the garbage collection + * Forces the garbage collection, only available in JSB * @memberof cc.sys * @name garbageCollect * @function @@ -1655,7 +1655,7 @@ cc._initSys = function (config, CONFIG_KEY) { }; /** - * Dumps rooted objects + * Dumps rooted objects, only available in JSB * @memberof cc.sys * @name dumpRoot * @function @@ -1665,7 +1665,7 @@ cc._initSys = function (config, CONFIG_KEY) { }; /** - * Restart the JS VM + * Restart the JS VM, only available in JSB * @memberof cc.sys * @name restartVM * @function @@ -1675,7 +1675,7 @@ cc._initSys = function (config, CONFIG_KEY) { }; /** - * cleanScript the singal JS file + * Clean a script in the JS VM, only available in JSB * @memberof cc.sys * @name cleanScript * @param {String} jsfile @@ -2047,10 +2047,14 @@ cc.game = /** @lends cc.game# */{ }, /** - * Run game. + * Restart game. */ restart: function () { - //window.location.href = window.location.href; + cc.director.popToSceneStackLevel(0); + // Clean up audio + cc.audioEngine.end(); + + cc.game.onStart(); }, /** From 04c04c0f08f23bf324bfc51b43bba72c970cf648 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 5 Dec 2014 16:20:38 +0800 Subject: [PATCH 1034/1564] Issue #2416: Sprite SetColor mistake --- .../core/sprites/CCSpriteCanvasRenderCmd.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index b48c6740ac..82813fd2cb 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -241,6 +241,18 @@ proto._changeTextureColor = function () { var node = this._node; + var displayedColor = this._displayedColor; + + if(this._colorized){ + if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255 && displayedColor.a === 255){ + this._colorized = false; + node.texture = this._originalTexture; + return; + } + }else + if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255 && displayedColor.a === 255) + return; + var locElement, locTexture = node._texture, locRect = this._textureCoord; if (locTexture && locRect.validRect && this._originalTexture) { locElement = locTexture.getHtmlElementObj(); @@ -253,9 +265,9 @@ this._colorized = true; //generate color texture cache if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor) - cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, displayedColor, locRect, locElement); else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, this._displayedColor, locRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImage(locElement, cacheTextureForColor, displayedColor, locRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); @@ -266,9 +278,9 @@ this._colorized = true; if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor && this._originalTexture._htmlElementObj != locElement) - cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect, locElement); + cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, displayedColor, locRect, locElement); else { - locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, locRect); + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, displayedColor, locRect); locTexture = new cc.Texture2D(); locTexture.initWithElement(locElement); locTexture.handleLoadedTexture(); From 29a83284f68e5d2dc2acf7d3429de69cc1e59826 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 5 Dec 2014 16:24:04 +0800 Subject: [PATCH 1035/1564] Issue #2416: correct a mistake of cc.Layer.CanvasRenderCmd --- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index e309c2a27f..c5f8944f25 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -55,7 +55,7 @@ if (!this._bakeSprite){ this._bakeSprite = new cc.BakeSprite(); - this._bakeSprite._parent = this; + this._bakeSprite._parent = this._node; } } }; @@ -130,8 +130,8 @@ }; proto._bakeForAddChild = function(child){ - if(child._parent == this && this._isBaked) - child._setCachedParent(this); + if(child._parent == this._node && this._isBaked) + child._renderCmd._setCachedParent(this); }; proto._getBoundingBoxForBake = function(){ @@ -288,6 +288,7 @@ cc.renderer.pushRenderCommand(this._bakeRenderCmd); //the bakeSprite is drawing + this._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); this._bakeSprite.visit(this); }; From 63a2c374051275a94ca17f9c11fd72f00cb903be Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 5 Dec 2014 16:55:29 +0800 Subject: [PATCH 1036/1564] Issue #2416: rename sprite _changeTextureColor --- .../core/sprites/CCSpriteCanvasRenderCmd.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 82813fd2cb..6a6ce49a41 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -239,18 +239,18 @@ cc.g_NumberOfDraws++; }; - proto._changeTextureColor = function () { + proto._updateColor = function () { var node = this._node; var displayedColor = this._displayedColor; if(this._colorized){ - if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255 && displayedColor.a === 255){ + if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255){ this._colorized = false; node.texture = this._originalTexture; return; } }else - if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255 && displayedColor.a === 255) + if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255) return; var locElement, locTexture = node._texture, locRect = this._textureCoord; @@ -305,7 +305,7 @@ if (textureLoaded) { var curColor = node.getColor(); if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) - this._changeTextureColor(); + this._updateColor(); } }; @@ -339,12 +339,7 @@ proto._updateDisplayColor = function (parentColor) { cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._changeTextureColor(); - }; - - proto._syncDisplayColor = function(parentColor){ - cc.Node.CanvasRenderCmd.prototype._syncDisplayColor.call(this, parentColor); - this._changeTextureColor(); + this._updateColor(); }; proto._spriteFrameLoadedCallback = function (spriteFrame) { @@ -354,7 +349,7 @@ //TODO change var curColor = _t.getColor(); if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) - _t._changeTextureColor(); + _t._updateColor(); _t.dispatchEvent("load"); }; @@ -380,7 +375,7 @@ //set the texture's color after the it loaded var locColor = locRenderCmd._displayedColor; if (locColor.r != 255 || locColor.g != 255 || locColor.b != 255) - locRenderCmd._changeTextureColor(); + locRenderCmd._updateColor(); // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" From a19dd93fafb6582a7da3d4ec5fef1e4aa270efc3 Mon Sep 17 00:00:00 2001 From: Hermanto Date: Sat, 6 Dec 2014 21:34:15 +0800 Subject: [PATCH 1037/1564] Remote Texture Loading Fix --- cocos2d/core/textures/CCTextureCache.js | 18 +++++++++++++++--- cocos2d/core/textures/TexturesWebGL.js | 24 +++++++++++++++++------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index a8290816c7..57bdb37f48 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -351,16 +351,28 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { tex.url = url; if (!cc.loader.getRes(url)) { if (cc.loader._checkIsImageURL(url)) { - cc.loader.load(url, function (err) { - cb && cb.call(target); + cc.loader.load(url, function (err, img) { + if (err) + return cb ? cb(err) : err; + + cc.loader.cache[url] = img; + cc.textureCache.handleLoadedTexture(url); + + var texResult = locTexs[url]; + + cb && cb.call(target,texResult); }); } else { cc.loader.loadImg(url, function (err, img) { if (err) return cb ? cb(err) : err; + cc.loader.cache[url] = img; cc.textureCache.handleLoadedTexture(url); - cb && cb.call(target, tex); + + var texResult = locTexs[url]; + + cb && cb.call(target, texResult); }); } } diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index abd6b53ee7..f5866f6631 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -881,11 +881,20 @@ cc._tmp.WebGLTextureCache = function () { cb && cb.call(target, tex); return tex; } - + + if (!cc.loader.getRes(url)) { if (cc.loader._checkIsImageURL(url)) { - cc.loader.load(url, function (err) { - cb && cb.call(target); + + //cc.log("loading image url"); + + cc.loader.load(url, function (err,img) { + cc.loader.cache[url] = img; + cc.textureCache.handleLoadedTexture(url); + + var texResult = locTexs[url]; + + cb && cb.call(target,texResult); }); } else { cc.loader.loadImg(url, function (err, img) { @@ -893,13 +902,14 @@ cc._tmp.WebGLTextureCache = function () { return cb ? cb(err) : err; cc.loader.cache[url] = img; cc.textureCache.handleLoadedTexture(url); - cb && cb.call(target, tex); + + var texResult = locTexs[url]; + + cb && cb.call(target, texResult); }); } } - - tex = locTexs[url] = new cc.Texture2D(); - tex.url = url; + return tex; }; _p = null; From ea75174e22c1ee0976689acc5546ab65cf92d2b1 Mon Sep 17 00:00:00 2001 From: Hermanto Date: Sat, 6 Dec 2014 21:38:50 +0800 Subject: [PATCH 1038/1564] Remove comment --- cocos2d/core/textures/TexturesWebGL.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index f5866f6631..4cb2ea2487 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -885,9 +885,6 @@ cc._tmp.WebGLTextureCache = function () { if (!cc.loader.getRes(url)) { if (cc.loader._checkIsImageURL(url)) { - - //cc.log("loading image url"); - cc.loader.load(url, function (err,img) { cc.loader.cache[url] = img; cc.textureCache.handleLoadedTexture(url); From 6732f9908084f649abf5b38391b4ca3cccc42456 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 8 Dec 2014 11:24:08 +0800 Subject: [PATCH 1039/1564] Issue #2416: Layout can't move caused by mark mistak --- extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js | 1 + extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js | 1 + extensions/ccui/layouts/UILayoutCanvasRenderCmd.js | 1 + extensions/ccui/layouts/UILayoutWebGLRenderCmd.js | 1 + 4 files changed, 4 insertions(+) diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 3bbd8a60d0..9e40b250ac 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -143,6 +143,7 @@ var childLen = locChildren.length, pLen = locProtectedChildren.length; this._syncStatus(parentCmd); + this._dirtyFlag = 0; node.sortAllChildren(); node.sortAllProtectedChildren(); diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index 9de3949971..f8ebebfe6f 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -47,6 +47,7 @@ //optimize performance for javascript currentStack.stack.push(currentStack.top); this._syncStatus(parentCmd); + this._dirtyFlag = 0; currentStack.top = this._stackMatrix; var locGrid = node.grid; diff --git a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js index f4edf335d4..237e4587cf 100644 --- a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js @@ -128,6 +128,7 @@ node._clipElemType = node._stencil instanceof cc.Sprite; this._syncStatus(parentCmd); + this._dirtyFlag = 0; cc.renderer.pushRenderCommand(this._rendererSaveCmd); diff --git a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js index 397c983ffd..afd574e134 100644 --- a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js @@ -159,6 +159,7 @@ var currentStack = cc.current_stack; currentStack.stack.push(currentStack.top); this._syncStatus(parentCmd); + this._dirtyFlag = 0; currentStack.top = this._stackMatrix; node._clippingStencil.visit(this); From 63cbf7dde6d07797fabb381e9cc25a42ad38fbc0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 8 Dec 2014 14:42:56 +0800 Subject: [PATCH 1040/1564] Issue #2416: The temporary repair of cc.follow --- cocos2d/actions/CCAction.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 5f0ce14e0a..3797077f71 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -625,6 +625,9 @@ cc.Follow = cc.Action.extend(/** @lends cc.Follow# */{ tempPosX = this._halfScreenSize.x - tempPosX; tempPosY = this._halfScreenSize.y - tempPosY; + //TODO Temporary treatment - The dirtyFlag symbol error + this.target._renderCmd._dirtyFlag = 0; + if (this._boundarySet) { // whole map fits inside a single screen, no need to modify the position - unless map boundaries are increased if (this._boundaryFullyCovered) From e89a5707099bb1009fe5758cdb9ef8ad07553cb3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 8 Dec 2014 16:46:46 +0800 Subject: [PATCH 1041/1564] Issue #2416: Fixed armature throw error --- cocos2d/node-grid/CCNodeGrid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index c5bc3b28ba..3c0e1d6f8a 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -104,7 +104,7 @@ cc.NodeGrid = cc.Node.extend({ if (cc._renderType === cc._RENDER_TYPE_WEBGL) return new cc.NodeGrid.WebGLRenderCmd(this); else - return null; // cc.NodeGrid doesn't support Canvas mode. + return new cc.Node.CanvasRenderCmd(this); // cc.NodeGrid doesn't support Canvas mode. } }); From 9252370e0a8d8dbc837a977e85d5706259798917 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 8 Dec 2014 17:22:05 +0800 Subject: [PATCH 1042/1564] Issue #2416: correct a mistake of cc.TMXLayer --- cocos2d/tilemap/CCTMXLayer.js | 2 - cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 164 +++++-------------- cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js | 2 - 3 files changed, 44 insertions(+), 124 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index dac70221e9..ad03e1bebc 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -96,8 +96,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ if(mapInfo !== undefined) this.initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo); - - this._renderCmd._initContentSize(); }, _createRenderCmd: function(){ diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index 9f635694ab..d9316b213e 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -23,10 +23,10 @@ ****************************************************************************/ (function(){ - cc.TMXLayer.CanvasRenderCmd = function(renderableObject){ - cc.SpriteBatchNode.CanvasRenderCmd.call(this, renderableObject); - this._childrenRenderCmds = []; + cc.TMXLayer.CanvasRenderCmd = function(renderable){ + cc.SpriteBatchNode.CanvasRenderCmd.call(this, renderable); this._needDraw = true; + this._childrenRenderCmds = []; var locCanvas = cc._canvas; var tmpCanvas = cc.newElement('canvas'); @@ -58,35 +58,19 @@ proto._renderingChildToCache = function (scaleX, scaleY) { if (this._cacheDirty) { -// var locCacheCmds = this._childrenRenderCmds, locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas; -// -// locCacheContext.save(); -// locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); -// //reset the cache context -// var t = cc.affineTransformInvert(this._worldTransform); -// locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); -// -// for (var i = 0, len = locCacheCmds.length; i < len; i++) { -// locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); -// if (locCacheCmds[i]) -// locCacheCmds[i]._cacheDirty = false; -// } -// locCacheContext.restore(); -// this._cacheDirty = false; + var locCacheCmds = this._childrenRenderCmds, locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas; - var renderer = cc.renderer; - var node = this._node; - var instanceID = node.__instanceId; - var locChildren = node._children; - node.sortAllChildren(); - for (var i = 0, len = locChildren.length; i < len; i++) { - if (locChildren[i]){ - locChildren[i].visit(); - } - } + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + //reset the cache context + var t = cc.affineTransformInvert(this._worldTransform); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -t.ty * scaleY); - //copy cached render cmd array to TMXLayer renderer - node._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); + for (var i = 0, len = locCacheCmds.length; i < len; i++) { + locCacheCmds[i].rendering(locCacheContext, scaleX, scaleY); + locCacheCmds[i]._cacheDirty = false; + } + locCacheContext.restore(); this._cacheDirty = false; } }; @@ -138,32 +122,6 @@ var locTexContentSize = this._cacheTexture._contentSize; locTexContentSize.width = locCanvas.width; locTexContentSize.height = locCanvas.height; - - // Init sub caches if needed - var totalPixel = locCanvas.width * locCanvas.height; - if(totalPixel > node._maxCachePixel) { - if(!node._subCacheCanvas) node._subCacheCanvas = []; - if(!node._subCacheContext) node._subCacheContext = []; - - node._subCacheCount = Math.ceil( totalPixel / node._maxCachePixel ); - var locSubCacheCanvas = node._subCacheCanvas, i; - for(i = 0; i < node._subCacheCount; i++) { - if(!locSubCacheCanvas[i]) { - locSubCacheCanvas[i] = document.createElement('canvas'); - node._subCacheContext[i] = locSubCacheCanvas[i].getContext('2d'); - } - var tmpCanvas = locSubCacheCanvas[i]; - tmpCanvas.width = node._subCacheWidth = Math.round( locCanvas.width / node._subCacheCount ); - tmpCanvas.height = locCanvas.height; - } - // Clear wasted cache to release memory - for(i = node._subCacheCount; i < locSubCacheCanvas.length; i++) { - tmpCanvas.width = 0; - tmpCanvas.height = 0; - } - } - // Otherwise use count as a flag to disable sub caches - else node._subCacheCount = 0; }; proto.getTexture = function(){ @@ -178,82 +136,48 @@ if (!node._visible || !locChildren || locChildren.length === 0) return; - if( node._parent) - node._curLevel = node._parent._curLevel + 1; + parentCmd = parentCmd || this.getParentRenderCmd(); + if (parentCmd) + this._curLevel = parentCmd._curLevel + 1; - node.transform(node._parent && node._parent._renderCmd); + //node.transform(node._parent && node._parent._renderCmd); + this._syncStatus(parentCmd); -// if (this._cacheDirty) { -// var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view, -// instanceID = node.__instanceId, renderer = cc.renderer; + if (this._cacheDirty) { + var locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas, locView = cc.view, + instanceID = node.__instanceId, renderer = cc.renderer; //begin cache -// renderer._turnToCacheMode(instanceID); -// -// node.sortAllChildren(); -// for (i = 0, len = locChildren.length; i < len; i++) { -// if (locChildren[i]){ -// locChildren[i].visit(this); -// } -// } + renderer._turnToCacheMode(instanceID); + + node.sortAllChildren(); + for (i = 0, len = locChildren.length; i < len; i++) { + if (locChildren[i]){ + var selCmd = locChildren[i]._renderCmd; + if(selCmd){ + selCmd.visit(this); + selCmd._cacheDirty = false; + } + } + } //copy cached render cmd array to TMXLayer renderer -// node._renderCmd._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); + this._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); -// locCacheContext.save(); -// locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); -// var t = cc.affineTransformInvert(this._worldTransform); -// locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); + locCacheContext.save(); + locCacheContext.clearRect(0, 0, locCanvas.width, -locCanvas.height); + var t = cc.affineTransformInvert(this._worldTransform); + locCacheContext.transform(t.a, t.c, t.b, t.d, t.tx * locView.getScaleX(), -t.ty * locView.getScaleY()); //draw to cache canvas -// renderer._renderingToCacheCanvas(locCacheContext, instanceID); -// locCacheContext.restore(); -// this._cacheDirty = false -// } - proto._renderingChildToCache(); - cc.renderer.pushRenderCommand(node._renderCmd); - }; - - proto.draw = function(ctx){ - var node = this._node; - var context = ctx || cc._renderContext; - //context.globalAlpha = node._opacity / 255; - var posX = 0 | ( -node._anchorPointInPoints.x), posY = 0 | ( -node._anchorPointInPoints.y); - var eglViewer = cc.view; - var locCacheCanvas = this._cacheCanvas; - //direct draw image by canvas drawImage - if (locCacheCanvas) { - var locSubCacheCount = node._subCacheCount, locCanvasHeight = locCacheCanvas.height * eglViewer._scaleY; - var halfTileSize = node._mapTileSize.height * 0.5 * eglViewer._scaleY; - if(locSubCacheCount > 0) { - var locSubCacheCanvasArr = node._subCacheCanvas; - for(var i = 0; i < locSubCacheCount; i++){ - var selSubCanvas = locSubCacheCanvasArr[i]; - if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) - context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * node._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight) + halfTileSize, selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); - else - context.drawImage(locSubCacheCanvasArr[i], 0, 0, selSubCanvas.width, selSubCanvas.height, - posX + i * node._subCacheWidth * eglViewer._scaleX, -(posY + locCanvasHeight), selSubCanvas.width * eglViewer._scaleX, locCanvasHeight); - } - } else{ - if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); - else - context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * eglViewer._scaleX, locCanvasHeight); - } + renderer._renderingToCacheCanvas(locCacheContext, instanceID); + locCacheContext.restore(); + this._cacheDirty = false } - }; - - proto._initContentSize = function(){ - var locCanvas = cc._canvas; - this._node.width = locCanvas.width; - this._node.height = locCanvas.height; + cc.renderer.pushRenderCommand(this); }; proto.initImageSize = function(){ var node = this._node; node.tileset.imageSize = this._originalTexture.getContentSizeInPixels(); - } + }; })(); \ No newline at end of file diff --git a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js index f65bf670e7..9c5b0f3a15 100644 --- a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js @@ -33,8 +33,6 @@ proto._updateCacheContext = function(){}; - proto._initContentSize = function(){}; - proto.initImageSize = function(){ var node = this._node; node.tileset.imageSize = this._textureAtlas.texture.getContentSizeInPixels(); From 11b02d92117b8ccd77bc21c1c876d055eee96394 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Dec 2014 10:29:45 +0800 Subject: [PATCH 1043/1564] Issue #2416: remove element error --- cocos2d/core/sprites/CCSpriteBatchNode.js | 1 + .../core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js | 12 +++++++----- .../core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index fa11739604..87233b5ee9 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -422,6 +422,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ // XXX: so, it should be AFTER the insertQuad sprite.dirty = true; sprite.updateTransform(); + this._renderCmd.cutting(sprite, index); }, /** diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js index abf81520dd..511ba996f8 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js @@ -41,11 +41,7 @@ this._texture = texture; }; - proto.insertQuad = function(sprite, index){ - var node = this._node; - node._children.splice(index, 0, sprite); - //sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd - }; + proto.insertQuad = function(sprite, index){}; proto.increaseAtlasCapacity = function(){}; @@ -69,4 +65,10 @@ proto.getTextureAtlas = function(){}; proto.setTextureAtlas = function(textureAtlas){}; + + proto.cutting = function(sprite, index){ + var node = this._node; + //sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd + node._children.splice(index, 0, sprite); + } })(); \ No newline at end of file diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index be9d2b418c..1739228981 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -225,4 +225,6 @@ this._textureAtlas = textureAtlas; } }; + + proto.cutting = function(){}; })(); From 05c7123ff81eb91ac6b8be0b1bf23b5db669bae1 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 9 Dec 2014 12:55:45 +0800 Subject: [PATCH 1044/1564] cocos2d/cocos2d-js#1171: Fixed cc.texutreCache's addImage logic --- CCBoot.js | 12 ++++++-- cocos2d/core/textures/CCTextureCache.js | 39 ++++++------------------- cocos2d/core/textures/TexturesWebGL.js | 39 +++++++++---------------- 3 files changed, 32 insertions(+), 58 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 2df1e30522..adcdf89c56 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -755,13 +755,21 @@ cc.loader = /** @lends cc.loader# */{ else if (option !== undefined) cb = option; - var img = new Image(); + var img = this.getRes(url); + if (img) { + cb && cb(null, img); + return img; + } + + img = new Image(); if (opt.isCrossOrigin && location.origin != "file://") img.crossOrigin = "Anonymous"; var lcb = function () { this.removeEventListener('load', lcb, false); this.removeEventListener('error', ecb, false); + + cc.loader.cache[url] = img; if (cb) cb(null, img); }; @@ -802,7 +810,7 @@ cc.loader = /** @lends cc.loader# */{ type = cc.path.extname(url); } - var obj = self.cache[url]; + var obj = self.getRes(url); if (obj) return cb(null, obj); var loader = null; diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 57bdb37f48..9dd8a2898c 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -349,36 +349,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { tex = locTexs[url] = new cc.Texture2D(); tex.url = url; - if (!cc.loader.getRes(url)) { - if (cc.loader._checkIsImageURL(url)) { - cc.loader.load(url, function (err, img) { - if (err) - return cb ? cb(err) : err; - - cc.loader.cache[url] = img; - cc.textureCache.handleLoadedTexture(url); - - var texResult = locTexs[url]; - - cb && cb.call(target,texResult); - }); - } else { - cc.loader.loadImg(url, function (err, img) { - if (err) - return cb ? cb(err) : err; - - cc.loader.cache[url] = img; - cc.textureCache.handleLoadedTexture(url); - - var texResult = locTexs[url]; - - cb && cb.call(target, texResult); - }); - } - } - else { - tex.handleLoadedTexture(); - } + var loadFunc = cc.loader._checkIsImageURL(url) ? cc.loader.load : cc.loader.loadImg; + loadFunc.call(cc.loader, url, function (err, img) { + if (err) + return cb && cb.call(target, err); + cc.textureCache.handleLoadedTexture(url); + + var texResult = locTexs[url]; + cb && cb.call(target, texResult); + }); return tex; }; diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 4cb2ea2487..09f6f71699 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -881,32 +881,19 @@ cc._tmp.WebGLTextureCache = function () { cb && cb.call(target, tex); return tex; } - - - if (!cc.loader.getRes(url)) { - if (cc.loader._checkIsImageURL(url)) { - cc.loader.load(url, function (err,img) { - cc.loader.cache[url] = img; - cc.textureCache.handleLoadedTexture(url); - - var texResult = locTexs[url]; - - cb && cb.call(target,texResult); - }); - } else { - cc.loader.loadImg(url, function (err, img) { - if (err) - return cb ? cb(err) : err; - cc.loader.cache[url] = img; - cc.textureCache.handleLoadedTexture(url); - - var texResult = locTexs[url]; - - cb && cb.call(target, texResult); - }); - } - } - + + tex = locTexs[url] = new cc.Texture2D(); + tex.url = url; + var loadFunc = cc.loader._checkIsImageURL(url) ? cc.loader.load : cc.loader.loadImg; + loadFunc.call(cc.loader, url, function (err, img) { + if (err) + return cb && cb.call(target, err); + cc.textureCache.handleLoadedTexture(url); + + var texResult = locTexs[url]; + cb && cb.call(target, texResult); + }); + return tex; }; _p = null; From 86b2ab116634de68ab009438c2cae49e5b0b1080 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 9 Dec 2014 14:30:09 +0800 Subject: [PATCH 1045/1564] cocos2d/cocos2d-js#1108: Fix audioEngine absent issue --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 2df1e30522..423b56b033 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -2052,7 +2052,7 @@ cc.game = /** @lends cc.game# */{ restart: function () { cc.director.popToSceneStackLevel(0); // Clean up audio - cc.audioEngine.end(); + cc.audioEngine && cc.audioEngine.end(); cc.game.onStart(); }, From 931bbe1dbcfbd55010981772a5878124ce7bcf2d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Dec 2014 14:33:48 +0800 Subject: [PATCH 1046/1564] Issue #2416: Flags missing 1. DirtyFlags was not removed after run _syncStatus 2. cacheDirty was not add on TileMap --- cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js | 2 ++ cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 2 ++ cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js | 1 + cocos2d/tilemap/CCTMXLayer.js | 9 ++------- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 6 ++++++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js index 931f44cf6a..0418b690fc 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -142,6 +142,7 @@ context.globalCompositeOperation = "destination-over"; context.drawImage(locCache, 0, 0); context.restore(); + this._dirtyFlag = 0; } else { context.restore(); } @@ -209,6 +210,7 @@ } cc.renderer.pushRenderCommand(this._rendererRestoreCmd); + this._dirtyFlag = 0; }; cc.ClippingNode.CanvasRenderCmd._sharedCache = null; diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index c5f8944f25..1fcc2c1b7c 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -127,6 +127,7 @@ //the bakeSprite is drawing this._bakeSprite.visit(this); + this._dirtyFlag = 0; }; proto._bakeForAddChild = function(child){ @@ -290,6 +291,7 @@ //the bakeSprite is drawing this._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); this._bakeSprite.visit(this); + this._dirtyFlag = 0; }; proto._getBoundingBoxForBake = function(){ diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js index 761b3639b7..b9414a807c 100644 --- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -109,6 +109,7 @@ var node = this._node; this._syncStatus(parentCmd); node.sprite.visit(parentCmd); + this._dirtyFlag = 0; }; proto.draw = function(){ diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index ad03e1bebc..816e0569bd 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -125,12 +125,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ return this._renderCmd.getTexture(); }, - //set the cache dirty flag for canvas - _setNodeDirtyForCache: function () { - this._renderCmd._cacheDirty = true; - this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); - }, - /** * Gets layer size. * @return {cc.Size} @@ -360,6 +354,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ tile.anchorX = 0; tile.anchorY = 0; tile.opacity = this._opacity; + tile._renderCmd._cachedParent = this._renderCmd; var indexForZ = this._atlasIndexForExistantZ(z); this.addSpriteWithoutQuad(tile, indexForZ, z); @@ -859,7 +854,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ this._reusedTile.initWithTexture(this._renderCmd._texture, rect, false); this._reusedTile.batchNode = this; this._reusedTile.parent = this; - this._reusedTile._cachedParent = this._renderCmd; + this._reusedTile._renderCmd._cachedParent = this._renderCmd; } return this._reusedTile; }, diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index d9316b213e..265fb19c78 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -56,6 +56,11 @@ } }; + //set the cache dirty flag for canvas + proto._setNodeDirtyForCache = function () { + this._cacheDirty = true; + }; + proto._renderingChildToCache = function (scaleX, scaleY) { if (this._cacheDirty) { var locCacheCmds = this._childrenRenderCmds, locCacheContext = this._cacheContext, locCanvas = this._cacheCanvas; @@ -174,6 +179,7 @@ this._cacheDirty = false } cc.renderer.pushRenderCommand(this); + this._dirtyFlag = 0; }; proto.initImageSize = function(){ From 81b04d698edc4422a4b23f32bf32098dda4d1c81 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Dec 2014 15:48:43 +0800 Subject: [PATCH 1047/1564] Issue #2416: RenderTexture position --- cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js index b9414a807c..68aef24050 100644 --- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -108,7 +108,7 @@ proto.visit = function(parentCmd){ var node = this._node; this._syncStatus(parentCmd); - node.sprite.visit(parentCmd); + node.sprite.visit(this); this._dirtyFlag = 0; }; @@ -131,7 +131,7 @@ for (var i = 0; i < childrenLen; i++) { var getChild = locChildren[i]; if (getChild != selfSprite) - getChild.visit(); + getChild.visit(this); } node.end(); }; From c8096c46577db5d178263edd120789d63f6d4448 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 9 Dec 2014 16:06:41 +0800 Subject: [PATCH 1048/1564] Fixed #2416: fixed a bug of cc.RenderTexture --- cocos2d/render-texture/CCRenderTexture.js | 2 ++ .../CCRenderTextureWebGLRenderCmd.js | 22 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 5154e58239..971b674682 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -114,6 +114,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ cc.Node.prototype.ctor.call(this); this._cascadeColorEnabled = true; this._cascadeOpacityEnabled = true; + this._clearColor = new cc.Color(0,0,0,255); if(width !== undefined && height !== undefined) { format = format || cc.Texture2D.PIXEL_FORMAT_RGBA8888; @@ -372,6 +373,7 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ listenToForeground:function (obj) { } }); +var _p = cc.RenderTexture.prototype; // Extended /** @expose */ _p.clearColorVal; diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index d1ca194d9f..55a700dc69 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -27,7 +27,6 @@ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; - this._clearColor = cc.color(0, 0, 0, 0); this._fBO = null; this._oldFBO = null; this._textureCopy = null; @@ -52,7 +51,7 @@ // backup and set if (locClearFlags & gl.COLOR_BUFFER_BIT) { oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); - gl.clearColor(this._clearColor.r / 255, this._clearColor.g / 255, this._clearColor.b / 255, this._clearColor.a / 255); + gl.clearColor(node._clearColor.r / 255, node._clearColor.g / 255, node._clearColor.b / 255, node._clearColor.a / 255); } if (locClearFlags & gl.DEPTH_BUFFER_BIT) { @@ -84,8 +83,9 @@ var locChildren = node._children; for (var i = 0; i < locChildren.length; i++) { var getChild = locChildren[i]; - if (getChild != node.sprite) - getChild._renderCmd.visit(this); + if (getChild != node.sprite){ + getChild._renderCmd.visit(node.sprite._renderCmd); //TODO it's very Strange + } } node.end(); } @@ -114,7 +114,7 @@ gl.deleteRenderbuffer(this._depthRenderBuffer); }; - proto.updateClearColor = function(clearColor){}; + proto.updateClearColor = function(clearColor){ }; proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ var node = this._node; @@ -339,23 +339,23 @@ node.end(); }; - proto.visit = function(ctx){ + proto.visit = function(parentCmd){ var node = this._node; + if (!node._visible) + return; cc.kmGLPushMatrix(); + //TODO using GridNode /* var locGrid = this.grid; if (locGrid && locGrid.isActive()) { locGrid.beforeDraw(); this.transformAncestors(); }*/ - node.transform(ctx); + this._syncStatus(parentCmd); //this.toRenderer(); - - node.sprite.visit(); - //this.draw(ctx); - cc.renderer.pushRenderCommand(this); + node.sprite.visit(this); //TODO GridNode /* if (locGrid && locGrid.isActive()) From 069d2dc7d3aefa02dbb2ad146c81330b345fb64d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Dec 2014 16:18:31 +0800 Subject: [PATCH 1049/1564] Issue #2416: Code separation --- cocos2d/tilemap/CCTMXLayer.js | 34 ++------------------ cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 10 ++++++ cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js | 22 ++++++++++++- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 816e0569bd..1c6c5b743d 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -354,7 +354,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ tile.anchorX = 0; tile.anchorY = 0; tile.opacity = this._opacity; - tile._renderCmd._cachedParent = this._renderCmd; var indexForZ = this._atlasIndexForExistantZ(z); this.addSpriteWithoutQuad(tile, indexForZ, z); @@ -691,7 +690,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ rect = cc.rectPixelsToPoints(rect); var z = 0 | (pos.x + pos.y * this._layerSize.width); - var tile = this._reusedTileWithRect(rect); + var tile = this._renderCmd._reusedTileWithRect(rect); this._setupTileSprite(tile, pos, gid); // optimization: @@ -712,7 +711,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ rect = cc.rectPixelsToPoints(rect); var z = 0 | (pos.x + pos.y * this._layerSize.width); - var tile = this._reusedTileWithRect(rect); + var tile = this._renderCmd._reusedTileWithRect(rect); this._setupTileSprite(tile, pos, gid); // get atlas index @@ -746,7 +745,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ rect.width / locScaleFactor, rect.height / locScaleFactor); var z = pos.x + pos.y * this._layerSize.width; - var tile = this._reusedTileWithRect(rect); + var tile = this._renderCmd._reusedTileWithRect(rect); this._setupTileSprite(tile, pos, gid); // get atlas index @@ -832,33 +831,6 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ } }, - _reusedTileWithRect:function (rect) { - if(cc._renderType === cc._RENDER_TYPE_WEBGL){ - if (!this._reusedTile) { - this._reusedTile = new cc.Sprite(); - this._reusedTile.initWithTexture(this.texture, rect, false); - this._reusedTile.batchNode = this; - } else { - // XXX HACK: Needed because if "batch node" is nil, - // then the Sprite'squad will be reset - this._reusedTile.batchNode = null; - - // Re-init the sprite - this._reusedTile.setTextureRect(rect, false); - - // restore the batch node - this._reusedTile.batchNode = this; - } - } else { - this._reusedTile = new cc.Sprite(); - this._reusedTile.initWithTexture(this._renderCmd._texture, rect, false); - this._reusedTile.batchNode = this; - this._reusedTile.parent = this; - this._reusedTile._renderCmd._cachedParent = this._renderCmd; - } - return this._reusedTile; - }, - _vertexZForPos:function (pos) { var ret = 0; var maxVal = 0; diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index 265fb19c78..fa2f2cf1de 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -186,4 +186,14 @@ var node = this._node; node.tileset.imageSize = this._originalTexture.getContentSizeInPixels(); }; + + proto._reusedTileWithRect = function(rect){ + var node = this._node; + node._reusedTile = new cc.Sprite(); + node._reusedTile.initWithTexture(node._renderCmd._texture, rect, false); + node._reusedTile.batchNode = node; + node._reusedTile.parent = node; + node._reusedTile._renderCmd._cachedParent = node._renderCmd; + return node._reusedTile; + }; })(); \ No newline at end of file diff --git a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js index 9c5b0f3a15..8c1906f640 100644 --- a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js @@ -43,5 +43,25 @@ // cons: // - difficult to scale / rotate / etc. this._textureAtlas.texture.setAliasTexParameters(); - } + }; + + proto._reusedTileWithRect = function(rect){ + var node = this._node; + if (!node._reusedTile) { + node._reusedTile = new cc.Sprite(); + node._reusedTile.initWithTexture(node.texture, rect, false); + node._reusedTile.batchNode = node; + } else { + // XXX HACK: Needed because if "batch node" is nil, + // then the Sprite'squad will be reset + node._reusedTile.batchNode = null; + + // Re-init the sprite + node._reusedTile.setTextureRect(rect, false); + + // restore the batch node + node._reusedTile.batchNode = node; + } + return node._reusedTile; + }; })(); From fcd675777bfe038205ab331b6eb2d0564fa1ad7a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 9 Dec 2014 16:19:48 +0800 Subject: [PATCH 1050/1564] Fixed #2416: add a condition to TMXLayer --- cocos2d/tilemap/CCTMXLayer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index 816e0569bd..664328a22b 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -354,7 +354,8 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ tile.anchorX = 0; tile.anchorY = 0; tile.opacity = this._opacity; - tile._renderCmd._cachedParent = this._renderCmd; + if(cc._renderType === cc._RENDER_TYPE_CANVAS) //todo need refactor + tile._renderCmd._cachedParent = this._renderCmd; var indexForZ = this._atlasIndexForExistantZ(z); this.addSpriteWithoutQuad(tile, indexForZ, z); From 0d088783bd27df41fa76cf4a8c630da1179804e9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 9 Dec 2014 21:30:31 +0800 Subject: [PATCH 1051/1564] Issue #2416: LabelTTF setString nothing transform --- cocos2d/core/labelttf/CCLabelTTF.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 58206a8e55..39874b8be6 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -578,6 +578,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ // Force update this._setUpdateTextureDirty(); + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); } }, _updateString: function () { From 97fd8813d18c7c468a335eeaaa48fa1d558d8ed9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Dec 2014 11:13:34 +0800 Subject: [PATCH 1052/1564] Issue #2416: Flag error --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 1 - cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 11 +++++++++++ cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 14 +++++++++++++- .../CCProgressTimerCanvasRenderCmd.js | 11 +++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index f21ed704a2..8a5810472f 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -440,7 +440,6 @@ cc.Node.RenderCmd.prototype = { if (transformDirty){ //update the transform this.transform(parentCmd); - this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.transformDirty ^ this._dirtyFlag; } }; diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index a29d4fd0d6..9cec2ea51f 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -367,6 +367,17 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; proto._syncStatus = function (parentCmd) { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var parentNode = parentCmd ? parentCmd._node : null; + + if(parentNode && parentNode._cascadeColorEnabled && (parentCmd._dirtyFlag & flags.colorDirty)) + locFlag |= flags.colorDirty; + + if(parentNode && parentNode._cascadeOpacityEnabled && (parentCmd._dirtyFlag & flags.opacityDirty)) + locFlag |= flags.opacityDirty; + + if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) + locFlag |= flags.transformDirty; + var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; if (colorDirty) diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 1fcc2c1b7c..3508e51324 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -324,7 +324,7 @@ var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; if (colorDirty) - this._updateDisplayColor() + this._updateDisplayColor(); if (opacityDirty) this._updateDisplayOpacity(); @@ -337,6 +337,7 @@ if (colorDirty || opacityDirty || (locFlag & flags.gradientDirty)){ this._updateColor(); } + this._dirtyFlag = 0; } }; })(); @@ -394,6 +395,17 @@ proto._syncStatus = function (parentCmd) { var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var parentNode = parentCmd ? parentCmd._node : null; + + if(parentNode && parentNode._cascadeColorEnabled && (parentCmd._dirtyFlag & flags.colorDirty)) + locFlag |= flags.colorDirty; + + if(parentNode && parentNode._cascadeOpacityEnabled && (parentCmd._dirtyFlag & flags.opacityDirty)) + locFlag |= flags.opacityDirty; + + if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) + locFlag |= flags.transformDirty; + var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; diff --git a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js index bc79382509..e6af6f657b 100644 --- a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js @@ -218,6 +218,17 @@ if(!node._sprite) return; var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var parentNode = parentCmd ? parentCmd._node : null; + + if(parentNode && parentNode._cascadeColorEnabled && (parentCmd._dirtyFlag & flags.colorDirty)) + locFlag |= flags.colorDirty; + + if(parentNode && parentNode._cascadeOpacityEnabled && (parentCmd._dirtyFlag & flags.opacityDirty)) + locFlag |= flags.opacityDirty; + + if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) + locFlag |= flags.transformDirty; + var spriteCmd = node._sprite._renderCmd; var spriteFlag = spriteCmd._dirtyFlag; From 32e6c5f4f56802a505978b4fed5585b4a930ca24 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Dec 2014 11:50:01 +0800 Subject: [PATCH 1053/1564] Issue #2416: Flag error --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 2 ++ cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 2 ++ cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 2 ++ cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js | 2 ++ 4 files changed, 8 insertions(+) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 8a5810472f..b1235d3b7c 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -426,6 +426,8 @@ cc.Node.RenderCmd.prototype = { opacityDirty = locFlag & flags.opacityDirty, transformDirty = locFlag & flags.transformDirty; + this._dirtyFlag = locFlag; + if (colorDirty) //update the color this._syncDisplayColor(); diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 9cec2ea51f..71a5e16cfe 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -378,6 +378,8 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) locFlag |= flags.transformDirty; + this._dirtyFlag = locFlag; + var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; if (colorDirty) diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 3508e51324..db8101a0e0 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -409,6 +409,8 @@ var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; + this._dirtyFlag = locFlag; + if (colorDirty) this._syncDisplayColor(); diff --git a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js index e6af6f657b..f2e2b34c7b 100644 --- a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js @@ -229,6 +229,8 @@ if(parentCmd && (parentCmd._dirtyFlag & flags.transformDirty)) locFlag |= flags.transformDirty; + this._dirtyFlag = locFlag; + var spriteCmd = node._sprite._renderCmd; var spriteFlag = spriteCmd._dirtyFlag; From 987d051813003af172cc02c441194ea250ee2168 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 10 Dec 2014 14:43:07 +0800 Subject: [PATCH 1054/1564] Fixed #2416: SpriteBatchNode needn't check texture when adding a child to it. --- cocos2d/core/sprites/CCSpriteBatchNode.js | 8 +------- .../core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js | 8 ++++++++ .../core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js | 12 ++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 87233b5ee9..9f72438920 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -561,14 +561,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ addChild: function (child, zOrder, tag) { cc.assert(child != null, cc._LogInfos.CCSpriteBatchNode_addChild_3); - if (!(child instanceof cc.Sprite)) { - cc.log(cc._LogInfos.Sprite_addChild_4); - return; - } - if (child.texture != this._renderCmd.getTexture()) { - cc.log(cc._LogInfos.Sprite_addChild_5); + if(!this._renderCmd.isValidChild(child)) return; - } zOrder = (zOrder == null) ? child.zIndex : zOrder; tag = (tag == null) ? child.tag : tag; diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js index 511ba996f8..5a2f0844f5 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js @@ -36,6 +36,14 @@ proto.checkAtlasCapacity = function(){}; + proto.isValidChild = function(child){ + if (!(child instanceof cc.Sprite)) { + cc.log(cc._LogInfos.Sprite_addChild_4); + return false; + } + return true; + }; + proto.initWithTexture = function(texture, capacity){ this._originalTexture = texture; this._texture = texture; diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 1739228981..431e4a4f9a 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -34,6 +34,18 @@ var proto = cc.SpriteBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.SpriteBatchNode.WebGLRenderCmd; + proto.isValidChild = function(child){ + if (!(child instanceof cc.Sprite)) { + cc.log(cc._LogInfos.Sprite_addChild_4); + return false; + } + if (child.texture != this.getTexture()) { + cc.log(cc._LogInfos.Sprite_addChild_5); + return false; + } + return true; + }; + proto.rendering = function () { var node = this._node; if (this._textureAtlas.totalQuads === 0) From 2fbf4322d9b81eaf40e029f176d7a668b1db997c Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 10 Dec 2014 15:22:22 +0800 Subject: [PATCH 1055/1564] Improve cc.loader.loadJson for better error notif --- CCBoot.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index b76c7cc08c..ad2fe3c4c2 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -727,10 +727,18 @@ cc.loader = /** @lends cc.loader# */{ */ loadJson: function (url, cb) { this.loadTxt(url, function (err, txt) { - try { - err ? cb(err) : cb(null, JSON.parse(txt)); - } catch (e) { - throw "load json [" + url + "] failed : " + e; + if (err) { + cb(err); + } + else { + try { + var result = JSON.parse(txt); + } + catch (e) { + throw "parse json [" + url + "] failed : " + e; + return; + } + cb(null, result); } }); }, From cd8d6f94c2c2483b74c39443dfcde37e7f4628c7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Dec 2014 17:25:46 +0800 Subject: [PATCH 1056/1564] Restore the event modification. Some browsers, mouse and touch will trigger --- cocos2d/core/platform/CCInputManager.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index b02184bf4a..3e4ebb8bea 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -416,8 +416,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); if (!cc.rectContainsPoint(new cc.Rect(pos.left, pos.top, pos.width, pos.height), location)){ - // if(!supportTouches) - selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); + if(!supportTouches) + selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.UP); mouseEvent.setButton(event.button); @@ -432,8 +432,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); - // if(!supportTouches) - selfPointer.handleTouchesBegin([selfPointer.getTouchByXY(location.x, location.y, pos)]); + if(!supportTouches) + selfPointer.handleTouchesBegin([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.DOWN); mouseEvent.setButton(event.button); @@ -450,8 +450,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); - // if(!supportTouches) - selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); + if(!supportTouches) + selfPointer.handleTouchesEnd([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.UP); mouseEvent.setButton(event.button); @@ -468,8 +468,8 @@ cc.inputManager = /** @lends cc.inputManager# */{ var pos = selfPointer.getHTMLElementPosition(element); var location = selfPointer.getPointByEvent(event, pos); - // if(!supportTouches) - selfPointer.handleTouchesMove([selfPointer.getTouchByXY(location.x, location.y, pos)]); + if(!supportTouches) + selfPointer.handleTouchesMove([selfPointer.getTouchByXY(location.x, location.y, pos)]); var mouseEvent = selfPointer.getMouseEvent(location,pos,cc.EventMouse.MOVE); if(selfPointer._mousePressed) From ff2c1f7471cbb3087da5714915e4e7f592bfa5c2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Dec 2014 17:45:11 +0800 Subject: [PATCH 1057/1564] Remove ProtoBuffer support --- extensions/cocostudio/reader/CSParseBinary.js | 599 ------------------ extensions/cocostudio/reader/GUIReader.js | 88 --- .../reader/timeline/ActionTimelineCache.js | 276 +------- .../cocostudio/reader/timeline/CSLoader.js | 525 +-------------- .../widgetreader/ButtonReader/ButtonReader.js | 91 --- .../CheckBoxReader/CheckBoxReader.js | 59 -- .../ImageViewReader/ImageViewReader.js | 55 -- .../LabelAtlasReader/LabelAtlasReader.js | 39 -- .../LabelBMFontReader/LabelBMFontReader.js | 38 -- .../widgetreader/LabelReader/LabelReader.js | 52 -- .../widgetreader/LayoutReader/LayoutReader.js | 172 ----- .../ListViewReader/ListViewReader.js | 118 ---- .../LoadingBarReader/LoadingBarReader.js | 46 -- .../PageViewReader/PageViewReader.js | 113 ---- .../ScrollViewReader/ScrollViewReader.js | 124 ---- .../widgetreader/SliderReader/SliderReader.js | 70 -- .../TextFieldReader/TextFieldReader.js | 75 --- .../reader/widgetreader/WidgetReader.js | 130 ---- external/protobuf/ByteBuffer.min.js | 85 --- external/protobuf/Long.min.js | 21 - external/protobuf/ProtoBuf.min.js | 102 --- moduleConfig.json | 5 - 22 files changed, 4 insertions(+), 2879 deletions(-) delete mode 100644 extensions/cocostudio/reader/CSParseBinary.js delete mode 100644 external/protobuf/ByteBuffer.min.js delete mode 100644 external/protobuf/Long.min.js delete mode 100644 external/protobuf/ProtoBuf.min.js diff --git a/extensions/cocostudio/reader/CSParseBinary.js b/extensions/cocostudio/reader/CSParseBinary.js deleted file mode 100644 index 5b7f829e82..0000000000 --- a/extensions/cocostudio/reader/CSParseBinary.js +++ /dev/null @@ -1,599 +0,0 @@ -var CSParseBinary = "\n\ -package protocolbuffers;\n\ -\n\ -option optimize_for = LITE_RUNTIME; \n\ -\n\ -message CSParseBinary\n\ -{\n\ - optional string version = 1; \n\ - optional string cocos2dVersion = 2;\n\ - optional string editorType = 3;\n\ - optional float dataScale = 4;\n\ - optional int32 designHeight = 5;\n\ - optional int32 designWidth = 6; \n\ - repeated string textures = 7;\n\ - repeated string texturesPng = 8;\n\ - optional NodeTree nodeTree = 9;\n\ - optional NodeAction action = 10;\n\ -}\n\ -\n\ -\n\ -// nodeTree\n\ -message NodeTree\n\ -{\n\ - optional string classname = 1;\n\ - optional string name = 2;\n\ -\n\ - repeated NodeTree children = 3;\n\ -\n\ - optional WidgetOptions widgetOptions = 4;\n\ - optional ButtonOptions buttonOptions = 5;\n\ - optional CheckBoxOptions checkBoxOptions = 6;\n\ - optional ImageViewOptions imageViewOptions = 7;\n\ - \n\ - optional TextAtlasOptions textAtlasOptions = 8;\n\ - optional TextBMFontOptions textBMFontOptions = 9;\n\ - optional TextOptions textOptions = 10;\n\ - optional LoadingBarOptions loadingBarOptions = 11;\n\ - optional SliderOptions sliderOptions = 12;\n\ - optional TextFieldOptions textFieldOptions = 13;\n\ - optional ScrollViewOptions scrollViewOptions = 14;\n\ - optional PageViewOptions pageViewOptions = 15;\n\ - optional ListViewOptions listViewOptions = 16;\n\ - optional PanelOptions PanelOptions = 17;\n\ -\n\ - optional SpriteOptions spriteOptions = 18;\n\ - optional TMXTiledMapOptions tmxTiledMapOptions = 19;\n\ - optional ParticleSystemOptions particleSystemOptions = 20;\n\ - optional ProjectNodeOptions projectNodeOptions = 21;\n\ -}\n\ -\n\ -\n\ -// WidgetOptions\n\ -message WidgetOptions\n\ -{\n\ - optional float x = 1;\n\ - optional float y = 2;\n\ - optional float scaleX = 3;\n\ - optional float scaleY = 4;\n\ - optional float rotation = 5;\n\ - optional bool flipX = 6;\n\ - optional bool flipY = 7;\n\ - optional int32 colorB = 8;\n\ - optional int32 colorG = 9;\n\ - optional int32 colorR = 10;\n\ - optional int32 opacity = 11;\n\ - optional bool touchAble = 12;\n\ - optional bool visible = 13;\n\ - optional int32 zorder = 14;\n\ - optional string classType = 15;\n\ - optional float width = 16;\n\ - optional float height = 17;\n\ - optional int32 positionType = 18;\n\ - optional float positionPercentX = 19;\n\ - optional float positionPercentY = 20;\n\ - optional int32 sizeType = 21;\n\ - optional float sizePercentX = 22;\n\ - optional float sizePercentY = 23;\n\ - optional bool useMergedTexture = 24;\n\ - optional int32 actionTag = 25;\n\ - optional int32 tag = 26;\n\ - optional float anchorPointX = 27;\n\ - optional float anchorPointY = 28;\n\ - optional bool ignoreSize = 29;\n\ - optional float rotationSkewX = 30;\n\ - optional float rotationSkewY = 31;\n\ - optional LayoutParameter layoutParameter = 32;\n\ - optional string customProperty = 33;\n\ - optional string frameEvent = 34; \n\ - optional string name = 35;\n\ - optional int32 Alpha = 37;\n\ - repeated ComponentOptions componentOptions = 36;\n\ -}\n\ -\n\ -// LayoutParameter\n\ -message LayoutParameter\n\ -{\n\ - optional int32 type = 1;\n\ - optional int32 gravity = 2;\n\ - optional string relativeName = 3;\n\ - optional string relativeToName = 4;\n\ - optional int32 align = 5;\n\ - optional int32 marginLeft = 6;\n\ - optional int32 marginTop = 7;\n\ - optional int32 marginRight = 8;\n\ - optional int32 marginDown = 9;\n\ - optional int32 layoutEageType = 10;\n\ - optional int32 layoutNormalHorizontal = 11;\n\ - optional int32 layoutNormalVertical = 12;\n\ - optional int32 layoutParentHorizontal = 13;\n\ - optional int32 layoutParentVertical = 14;\n\ -}\n\ -\n\ -// ButtonOptions\n\ -message ButtonOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string normal = 3;\n\ - optional string pressed = 4;\n\ - optional string disabled = 5;\n\ - optional ResourceData normalData = 6;\n\ - optional ResourceData pressedData = 7;\n\ - optional ResourceData disabledData = 8;\n\ - optional string text = 9;\n\ - optional string fontName = 10;\n\ - optional int32 fontSize = 11;\n\ - optional int32 textColorR = 12;\n\ - optional int32 textColorG = 13;\n\ - optional int32 textColorB = 14;\n\ - optional float capInsetsX = 15;\n\ - optional float capInsetsY = 16;\n\ - optional float capInsetsWidth = 17;\n\ - optional float capInsetsHeight = 18;\n\ - optional float scale9Width = 19;\n\ - optional float scale9Height = 20;\n\ - optional bool scale9Enable = 21; \n\ - optional bool displaystate = 22;\n\ - optional ResourceData fontResource = 23;\n\ -}\n\ -\n\ -message ResourceData\n\ -{\n\ - optional string path = 1;\n\ - optional string plistFile = 2;\n\ - optional int32 resourceType = 3;\n\ -}\n\ -\n\ -// CheckBoxOptions\n\ -message CheckBoxOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string backGroundBox = 3;\n\ - optional string backGroundBoxSelected = 4;\n\ - optional string backGroundBoxDisabled = 5;\n\ - optional string frontCross = 6;\n\ - optional string frontCrossDisabled = 7;\n\ - optional ResourceData backGroundBoxData = 8;\n\ - optional ResourceData backGroundBoxSelectedData = 9;\n\ - optional ResourceData frontCrossData = 10;\n\ - optional ResourceData backGroundBoxDisabledData = 11;\n\ - optional ResourceData frontCrossDisabledData = 12;\n\ - optional bool selectedState = 13;\n\ - optional bool displaystate = 14;\n\ -}\n\ -\n\ -// ImageOptions\n\ -message ImageViewOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string fileName = 3;\n\ - optional ResourceData fileNameData = 4;\n\ - optional float capInsetsX = 5;\n\ - optional float capInsetsY = 6;\n\ - optional float capInsetsHeight = 7;\n\ - optional float capInsetsWidth = 8;\n\ - optional float scale9Width = 9;\n\ - optional float scale9Height = 10;\n\ - optional bool scale9Enable = 11;\n\ - optional bool flippedX = 12;\n\ - optional bool flippedY = 13;\n\ -}\n\ -\n\ -// TextAtlasOptions\n\ -message TextAtlasOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string stringValue = 3;\n\ - optional string charMapFile = 4;\n\ - optional ResourceData charMapFileData = 5;\n\ - optional string startCharMap = 6;\n\ - optional int32 itemWidth = 7;\n\ - optional int32 itemHeight = 8;\n\ -}\n\ -\n\ -// TextBMFontOptions\n\ -message TextBMFontOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string text = 3;\n\ - optional ResourceData fileNameData = 4;\n\ -}\n\ -\n\ -// TextOptions\n\ -message TextOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string fontName = 3;\n\ - optional ResourceData fontFile = 4;\n\ - optional int32 fontSize = 5;\n\ - optional string text = 6;\n\ - optional float areaWidth = 7;\n\ - optional float areaHeight = 8;\n\ - optional int32 hAlignment = 9;\n\ - optional int32 vAlignment = 10;\n\ - optional bool touchScaleEnable = 11;\n\ - optional ResourceData fontResource = 12;\n\ - optional bool IsCustomSize = 13;\n\ -}\n\ -\n\ -// LoadingBarOptions\n\ -message LoadingBarOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string texture = 3;\n\ - optional ResourceData textureData = 4;\n\ - optional int32 percent = 5;\n\ - optional int32 direction = 6;\n\ - optional float capInsetsX = 7;\n\ - optional float capInsetsY = 8;\n\ - optional float capInsetsWidth = 9;\n\ - optional float capInsetsHeight = 10;\n\ - optional bool scale9Enable = 11;\n\ - optional float scale9Width = 12;\n\ - optional float scale9Height = 13;\n\ -}\n\ -\n\ -// ListViewOptions\n\ -message ListViewOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string backGroundImage = 3;\n\ - optional ResourceData backGroundImageData = 4;\n\ - optional int32 bgColorR = 5;\n\ - optional int32 bgColorG = 6;\n\ - optional int32 bgColorB = 7;\n\ - optional int32 bgStartColorR = 8;\n\ - optional int32 bgStartColorG = 9;\n\ - optional int32 bgStartColorB = 10;\n\ - optional int32 bgEndColorR = 11;\n\ - optional int32 bgEndColorG = 12;\n\ - optional int32 bgEndColorB = 13;\n\ - optional int32 colorType = 14;\n\ - optional int32 bgColorOpacity = 15;\n\ - optional float vectorX = 16;\n\ - optional float vectorY = 17;\n\ - optional float capInsetsX = 18;\n\ - optional float capInsetsY = 19;\n\ - optional float capInsetsWidth = 20;\n\ - optional float capInsetsHeight = 21;\n\ - optional bool backGroundScale9Enable = 22;\n\ - optional float innerWidth = 23;\n\ - optional float innerHeight = 24;\n\ - optional bool clipAble = 25;\n\ - optional bool bounceEnable = 26;\n\ - optional int32 direction = 27;\n\ - optional int32 gravity = 28;\n\ - optional int32 itemMargin = 29;\n\ - optional float scale9Width = 30;\n\ - optional float scale9Height = 31;\n\ -}\n\ -\n\ -// PageViewOptions\n\ -message PageViewOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string backGroundImage = 3;\n\ - optional ResourceData backGroundImageData = 4;\n\ - optional bool clipAble = 5;\n\ - optional int32 bgColorR = 6;\n\ - optional int32 bgColorG = 7;\n\ - optional int32 bgColorB = 8;\n\ - optional int32 bgStartColorR = 9;\n\ - optional int32 bgStartColorG = 10;\n\ - optional int32 bgStartColorB = 11;\n\ - optional int32 bgEndColorR = 12;\n\ - optional int32 bgEndColorG = 13;\n\ - optional int32 bgEndColorB = 14;\n\ - optional int32 colorType = 15;\n\ - optional int32 bgColorOpacity = 16;\n\ - optional float vectorX = 17;\n\ - optional float vectorY = 18;\n\ - optional float capInsetsX = 19;\n\ - optional float capInsetsY = 20;\n\ - optional float capInsetsWidth = 21;\n\ - optional float capInsetsHeight = 22;\n\ - optional bool backGroundScale9Enable = 23;\n\ - optional float scale9Width = 24;\n\ - optional float scale9Height = 25;\n\ -}\n\ -\n\ -// PanelOptions\n\ -message PanelOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string backGroundImage = 3;\n\ - optional ResourceData backGroundImageData = 4;\n\ - optional bool clipAble = 5;\n\ - optional int32 bgColorR = 6;\n\ - optional int32 bgColorG = 7;\n\ - optional int32 bgColorB = 8;\n\ - optional int32 bgStartColorR = 9;\n\ - optional int32 bgStartColorG = 10;\n\ - optional int32 bgStartColorB = 11;\n\ - optional int32 bgEndColorR = 12;\n\ - optional int32 bgEndColorG = 13;\n\ - optional int32 bgEndColorB = 14;\n\ - optional int32 colorType = 15;\n\ - optional int32 bgColorOpacity = 16;\n\ - optional float vectorX = 17;\n\ - optional float vectorY = 18;\n\ - optional float capInsetsX = 19;\n\ - optional float capInsetsY = 20;\n\ - optional float capInsetsWidth = 21;\n\ - optional float capInsetsHeight = 22;\n\ - optional bool backGroundScale9Enable = 23;\n\ - optional int32 layoutType = 24;\n\ - optional bool adaptScreen = 25;\n\ - optional float scale9Width = 26;\n\ - optional float scale9Height = 27;\n\ -}\n\ -\n\ -// ScrollViewOptions\n\ -message ScrollViewOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string backGroundImage = 3;\n\ - optional ResourceData backGroundImageData = 4;\n\ - optional int32 bgColorR = 5;\n\ - optional int32 bgColorG = 6;\n\ - optional int32 bgColorB = 7;\n\ - optional int32 bgStartColorR = 8;\n\ - optional int32 bgStartColorG = 9;\n\ - optional int32 bgStartColorB = 10;\n\ - optional int32 bgEndColorR = 11;\n\ - optional int32 bgEndColorG = 12;\n\ - optional int32 bgEndColorB = 13;\n\ - optional int32 colorType = 14;\n\ - optional int32 bgColorOpacity = 15;\n\ - optional float vectorX = 16;\n\ - optional float vectorY = 17;\n\ - optional float capInsetsX = 18;\n\ - optional float capInsetsY = 19;\n\ - optional float capInsetsWidth = 20;\n\ - optional float capInsetsHeight = 21;\n\ - optional bool backGroundScale9Enable = 22;\n\ - optional float innerWidth = 23;\n\ - optional float innerHeight = 24;\n\ - optional int32 direction = 25;\n\ - optional bool clipAble = 26;\n\ - optional bool bounceEnable = 27;\n\ - optional int32 layoutType = 28;\n\ - optional float scale9Width = 29;\n\ - optional float scale9Height = 30;\n\ -}\n\ -\n\ -// SliderOptions\n\ -message SliderOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string barFileName = 3;\n\ - optional string ballNormal = 4;\n\ - optional string ballPressed = 5;\n\ - optional string ballDisabled = 6;\n\ - optional ResourceData barFileNameData = 7;\n\ - optional ResourceData ballNormalData = 8;\n\ - optional ResourceData ballPressedData = 9;\n\ - optional ResourceData ballDisabledData = 10;\n\ - optional ResourceData progressBarData = 11;\n\ - optional int32 percent = 12;\n\ - optional float capInsetsX = 13;\n\ - optional float capInsetsY = 14;\n\ - optional float capInsetsWidth = 15;\n\ - optional float capInsetsHeight = 16;\n\ - optional float barCapInsetsX = 17;\n\ - optional float barCapInsetsY = 18;\n\ - optional float barCapInsetsWidth = 19;\n\ - optional float barCapInsetsHeight = 20;\n\ - optional float progressBarCapInsetsX = 21;\n\ - optional float progressBarCapInsetsY = 22;\n\ - optional float progressBarCapInsetsWidth = 23;\n\ - optional float progressBarCapInsetsHeight = 24;\n\ - optional float scale9Width = 25;\n\ - optional float scale9Height = 26;\n\ - optional bool scale9Enable = 27;\n\ - optional float slidBallAnchorPointX = 28;\n\ - optional float slidBallAnchorPointY = 29;\n\ - optional float length = 30;\n\ - optional bool displaystate = 31;\n\ -}\n\ -\n\ -// SpriteOptions\n\ -message SpriteOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional bool touchAble = 3;\n\ - optional int32 positionType = 4;\n\ - optional float positionPercentX = 5;\n\ - optional float positionPercentY = 6;\n\ - optional int32 sizeType = 7;\n\ - optional float sizePercentX = 8;\n\ - optional float sizePercentY = 9;\n\ - optional bool useMergedTexture = 10;\n\ - optional bool ignoreSize = 11;\n\ - optional LayoutParameter layoutParameter = 12;\n\ - optional string customProperty = 13;\n\ - optional string fileName = 14;\n\ - optional bool flippedX = 15;\n\ - optional bool flippedY = 16;\n\ - \n\ - optional ResourceData fileNameData = 17;\n\ -}\n\ -\n\ -// TextFieldOptions\n\ -message TextFieldOptions\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string fontName = 3;\n\ - optional ResourceData fontFile = 4;\n\ - optional int32 fontSize = 5;\n\ - optional string text = 6;\n\ - optional string placeHolder = 7;\n\ - optional bool passwordEnable = 8;\n\ - optional string passwordStyleText = 9;\n\ - optional bool maxLengthEnable = 10;\n\ - optional int32 maxLength = 11;\n\ - optional float areaWidth = 12;\n\ - optional float areaHeight = 13;\n\ - optional float anchorPointX = 15;\n\ - optional float anchorPointY = 16;\n\ - optional ResourceData fontResource = 14;\n\ - optional bool IsCustomSize = 17;\n\ -}\n\ -\n\ -// TMXTiledMapOptions\n\ -message TMXTiledMapOptions\n\ -{\n\ - optional string tmxFile = 1;\n\ - optional string tmxString = 2;\n\ - optional string resourcePath = 3;\n\ -\n\ - optional ResourceData fileNameData = 4;\n\ -}\n\ -\n\ -// ParticleSystemOptions\n\ -message ParticleSystemOptions\n\ -{\n\ - optional string plistFile = 1;\n\ - optional int32 totalParticles = 2; \n\ -\n\ - optional ResourceData fileNameData = 3;\n\ -}\n\ -\n\ -// ProjectNodeOptions\n\ -message ProjectNodeOptions\n\ -{\n\ - optional string fileName = 1;\n\ -}\n\ -\n\ -// ComponentOptions\n\ -message ComponentOptions\n\ -{\n\ - optional string type = 1;\n\ -\n\ - optional ComAudioOptions comAudioOptions = 2;\n\ -}\n\ -\n\ -// ComAudioOptions\n\ -message ComAudioOptions\n\ -{\n\ - optional string name = 1;\n\ - optional bool enabled = 2;\n\ - optional bool loop = 3;\n\ - optional int32 volume = 4;\n\ - optional ResourceData fileNameData = 5;\n\ -}\n\ -\n\ -\n\ -// action\n\ -message NodeAction\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional int32 duration = 3;\n\ - optional float speed = 4;\n\ -\n\ - repeated TimeLine timelines = 5;\n\ -}\n\ -\n\ -// Timeline\n\ -message TimeLine\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional string frameType = 3;\n\ - optional int32 actionTag = 4;\n\ - repeated Frame frames = 5;\n\ -}\n\ -\n\ -//Frames\n\ -message Frame\n\ -{\n\ - optional TimeLineBoolFrame visibleFrame = 5;\n\ - optional TimeLineIntFrame zOrderFrame = 6;\n\ - optional TimeLinePointFrame rotationSkewFrame = 7;\n\ - optional TimeLineStringFrame eventFrame = 8;\n\ - optional TimeLinePointFrame anchorPointFrame = 9;\n\ - optional TimeLinePointFrame positionFrame = 10;\n\ - optional TimeLinePointFrame scaleFrame = 11;\n\ - optional TimeLineColorFrame colorFrame = 12;\n\ - optional TimeLineTextureFrame textureFrame = 13;\n\ -}\n\ -\n\ -//VisibleFrame\n\ -message TimeLineBoolFrame\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional int32 frameIndex = 3;\n\ - optional bool tween = 4;\n\ - optional bool value = 5;\n\ -}\n\ -\n\ -//ZOrderFrame RotationFrame\n\ -message TimeLineIntFrame\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional int32 frameIndex = 3;\n\ - optional bool tween = 4;\n\ - optional int32 value = 5;\n\ -}\n\ -\n\ -//EventFrame\n\ -message TimeLineStringFrame\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional int32 frameIndex = 3;\n\ - optional bool tween = 4;\n\ - optional string value = 5;\n\ -}\n\ -\n\ -//AnchorPointFrame PositionFrame ScaleFrame\n\ -message TimeLinePointFrame\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional int32 frameIndex = 3;\n\ - optional bool tween = 4;\n\ - optional float x = 5;\n\ - optional float y = 6;\n\ -}\n\ -\n\ -//ColorFrame\n\ -message TimeLineColorFrame\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional int32 frameIndex = 3;\n\ - optional bool tween = 4;\n\ - optional int32 alpha = 5;\n\ - optional int32 red = 6;\n\ - optional int32 green = 7;\n\ - optional int32 blue = 8;\n\ -}\n\ -\n\ -//TextureFrame\n\ -message TimeLineTextureFrame\n\ -{\n\ - optional string name = 1;\n\ - optional string classname = 2;\n\ - optional int32 frameIndex = 3;\n\ - optional bool tween = 4;\n\ - optional string filePath = 5;\n\ - optional string plistFile = 6;\n\ -}"; \ No newline at end of file diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index ae816c8628..a5ecb04772 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -22,12 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -var PBP; -if(CSParseBinary && window["dcodeIO"] && window["dcodeIO"]["ProtoBuf"]){ - PBP = dcodeIO["ProtoBuf"]["loadProto"](CSParseBinary)["build"]()["protocolbuffers"]; -}else{ - PBP = null; -} (function(){ var factoryCreate = ccs.objectFactory; @@ -1945,88 +1939,6 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc this.setColorPropsForWidgetFromJsonDictionary(widget, options); }, - widgetFromProtocolBuffers: function(nodetree){ - - - var classname = nodetree.classname; - //cc.log("classname = %s", classname); - - var widget = this._createGUI(classname); - var readerName = this._getWidgetReaderClassName(classname); - - var reader = this._createWidgetReaderProtocol(readerName); - - if (reader) - { - // widget parse with widget reader - this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); - } - else - { - // - // 1st., custom widget parse properties of parent widget with parent widget reader - readerName = this._getWidgetReaderClassNameFromWidget(widget); - reader = this._createWidgetReaderProtocol(readerName); - if (reader && widget) - { - this.setPropsForAllWidgetFromProtocolBuffers(reader, widget, nodetree); - - // 2nd., custom widget parse with custom reader - var widgetOptions = nodetree.widgetOptions; - var customJsonDict = widgetOptions.componentOptions; -// var customJsonDict; -// customJsonDict.Parse(customProperty); -// if (customJsonDict.HasParseError()) -// { -// cc.log("GetParseError %s\n", customJsonDict.GetParseError()); -// } - this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); - } - else - { - cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); - } - // - } - - var size = nodetree.children.length; - //cc.log("widget children size = %d", size); - for (var i = 0; i < size; ++i) - { - var subNodeTree = nodetree.children[i]; - var child = this.widgetFromProtocolBuffers(subNodeTree); - //cc.log("widget child = %p", child); - if (child) - { - var pageView = widget; - if (pageView instanceof ccui.PageView) - { - pageView.addPage(child); - } - else - { - var listView = widget; - if (listView instanceof ccui.ListView) - { - listView.pushBackCustomItem(child); - } - else - { - widget.addChild(child); - } - } - } - } - - //cc.log("widget = %p", widget); - - return widget; - }, - - setPropsForAllWidgetFromProtocolBuffers: function(reader, widget, nodetree){ - reader.setPropsFromProtocolBuffers(widget, nodetree); - }, - widgetFromXML: function(objectData, classType){ var classname = classType.substr(0, classType.find("ObjectData")); //cc.log("classname = %s", classname); diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index a8a20ad582..95c4a5d07f 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -115,7 +115,7 @@ ccs.actionTimelineCache = { var cache = ccs.actionTimelineCache; if (suffix == "csb"){ - return cache.createActionFromProtocolBuffers(filename); + throw "Does not support protobuf"; }else if (suffix == "json" || suffix == "ExportJson"){ return cache.createActionFromJson(filename); }else if(suffix == "xml") { @@ -186,49 +186,6 @@ ccs.actionTimelineCache = { }, - createActionFromProtocolBuffers: function(fileName){ - var action = this._animationActions[fileName]; - if(action == null){ - action = this.loadAnimationActionWithFileFromProtocolBuffers(fileName); - } - return action.clone(); - }, - - loadAnimationActionWithFileFromProtocolBuffers: function(fileName){ - // if already exists an action with filename, then return this action - var action = this._animationActions[fileName]; - if(action){ - return action; - } - - var binary = cc.loader.getRes(fileName); - var buffer = PBP["CSParseBinary"]["decode"](binary); - - var actionProtobuf = buffer["action"]; - action = new ccs.ActionTimeline(); - action.setDuration(actionProtobuf["duration"]); - action.setTimeSpeed(actionProtobuf["speed"]!==null?actionProtobuf["speed"]:1); - - var timelineLength = actionProtobuf["timelines"].length; - for(var i=0;i(node); - - if(filePath != nullptr && strcmp(filePath, "") != 0) - { - var path = filePath; - - SpriteFrame* spriteFrame = SpriteFrameCache.getInstance().getSpriteFrameByName(path); - if(!spriteFrame) - { - path = _protocolBuffersPath + path; - sprite.setTexture(path); - } - else - { - sprite.setSpriteFrame(spriteFrame); - } - } - else - { - cc.log("filePath is empty. Create a sprite with no texture"); - } - */ - - this.setPropsForNodeFromProtocolBuffers(sprite, nodeOptions); - - var alpha = nodeOptions["Alpha"] !==null ? nodeOptions["Alpha"] : 255; - var red = nodeOptions["colorR"]!==null ? nodeOptions["colorR"] : 255; - var green = nodeOptions["colorG"]!==null ? nodeOptions["colorG"] : 255; - var blue = nodeOptions["colorB"]!==null ? nodeOptions["colorB"] : 255; - - if (alpha != 255) - { - sprite.setOpacity(alpha); - } - if (red != 255 || green != 255 || blue != 255) - { - sprite.setColor(cc.color(red, green, blue)); - } - - var flipX = spriteOptions["flippedX"]; - var flipY = spriteOptions["flippedY"]; - - if(flipX) - sprite.setFlippedX(flipX); - if(flipY) - sprite.setFlippedY(flipY); - }, - createParticleFromProtocolBuffers: function(particleSystemOptions, nodeOptions){ - var node = null; - - var options = particleSystemOptions; - - /* - const std.string& filePath = options.plistfile(); - var num = options.totalparticles(); - */ - - var fileNameData = options["fileNameData"]; - var resourceType = fileNameData["resourceType"]; - switch (resourceType) - { - case 0: - { - - var path = this._protocolBuffersPath + fileNameData["path"]; - if (path != "") - { - node = new cc.ParticleSystemQuad(path); - } - break; - } - - default: - break; - } - - if (node) - { - this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); - } - - return node; - }, - createTMXTiledMapFromProtocolBuffers: function(tmxTiledMapOptions, nodeOptions){ - var node = null; - var options = tmxTiledMapOptions; - - var fileNameData = options["fileNameData"]; - var resourceType = fileNameData["resourceType"]; - switch (resourceType) - { - case 0: - { - var path = this._protocolBuffersPath + fileNameData["path"]; - var tmxFile = path; - - if (tmxFile && "" != tmxFile) - { - node = new cc.TMXTiledMap(tmxFile); - } - break; - } - - default: - break; - } - - if (node) - { - this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); - } - - return node; - }, - setPropsForProjectNodeFromProtocolBuffers: function(node, projectNodeOptions, nodeOptions){ - this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); - }, - setPropsForSimpleAudioFromProtocolBuffers: function(node, nodeOptions){ - this.setPropsForNodeFromProtocolBuffers(node, nodeOptions); - }, - - createComponentFromProtocolBuffers: function(componentOptions){ - var component = null; - - var componentType = componentOptions["type"]; - - if (componentType == "ComAudio") - { - component = new ccs.ComAudio(); - var options = componentOptions["comAudioOptions"]; - this.setPropsForComAudioFromProtocolBuffers(component, options); - } - - return component; - }, - setPropsForComponentFromProtocolBuffers: function(component, componentOptions){ - var componentType = componentOptions.type; - - if (componentType == "ComAudio") - { - component = new ccs.ComAudio(); - var options = componentOptions["comAudioOptions"]; - this.setPropsForComAudioFromProtocolBuffers(component, options); - } - }, - setPropsForComAudioFromProtocolBuffers: function(component, comAudioOptions){ - var options = comAudioOptions; - var audio = component; - - var fileNameData = options["fileNameData"]; - var resourceType = fileNameData["resourceType"]; - switch (resourceType) - { - case 0: - { - var path = this._protocolBuffersPath + fileNameData["path"]; - audio.setFile(path); - break; - } - - default: - break; - } - - var loop = options["loop"]; - audio.setLoop(loop); - - audio.setName(options["name"]); - audio.setLoop(options["loop"]); - }, - isWidget: function(type){ return (type == ccui.CSLoaderStatic.ClassName_Panel || type == ccui.CSLoaderStatic.ClassName_Button @@ -1232,17 +725,5 @@ ccs.csLoader = { return readerName; } - /* - typedef std.function NodeCreateFunc; - typedef std.pair Pair; - - std.unordered_map _funcs; - - typedef std.function ComponentCreateFunc; - typedef std.pair ComponentPair; - - std.unordered_map _componentFuncs; - */ - }; ccs.csLoader.init(); diff --git a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js index f877aa8dd9..bf72159bd5 100644 --- a/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js +++ b/extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js @@ -124,96 +124,5 @@ ccs.buttonReader = /** @lends ccs.buttonReader# */{ if (fn) button.setTitleFontName(options["fontName"]); ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var button = widget; - var options = nodeTree["buttonOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - var scale9Enable = options["scale9Enable"]; - button.setScale9Enabled(scale9Enable); - - - var normalDic = options["normalData"]; - var normalType = normalDic["resourceType"]; - - var normalTexturePath = ccs.widgetReader.getResourcePath(normalDic["path"], normalType); - button.loadTextureNormal(normalTexturePath, normalType); - - - var pressedDic = options["pressedData"]; - var pressedType = pressedDic["resourceType"]; - - var pressedTexturePath = ccs.widgetReader.getResourcePath(pressedDic["path"], pressedType); - button.loadTexturePressed(pressedTexturePath, pressedType); - - - var disabledDic = options["disabledData"]; - var disabledType = disabledDic["resourceType"]; - - var disabledTexturePath = ccs.widgetReader.getResourcePath(disabledDic["path"], disabledType); - button.loadTextureDisabled(disabledTexturePath, disabledType); - - if (scale9Enable) - { - button.setUnifySizeEnabled(false); - button.ignoreContentAdaptWithSize(false); - - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]; - var ch = options["capInsetsHeight"]; - - button.setCapInsets(cc.rect(cx, cy, cw, ch)); - var sw = options["scale9Width"]; - var sh = options["scale9Height"]; - if (sw && sh) - { - button.setContentSize(cc.size(sw, sh)); - } - } - var tt = options["text"]; - if (tt) - { - button.setTitleText(tt); - } - - - var cri = options["textColorR"]!==null ? options["textColorR"] : 255; - var cgi = options["textColorG"]!==null ? options["textColorG"] : 255; - var cbi = options["textColorB"]!==null ? options["textColorB"] : 255; - button.setTitleColor(cc.color(cri,cgi,cbi)); - - - var fontSize = options["fontSize"]!==null ? options["fontSize"] : 14; - button.setTitleFontSize(fontSize); - - var displaystate = true; - if(options["displaystate"]!==null) - { - displaystate = options["displaystate"]; - } - button.setBright(displaystate); - - var fontName = options["fontName"]!==null ? options["fontName"] : "微软雅黑"; - button.setTitleFontName(fontName); - - if (options["fontResource"]) - { - var resourceData = options["fontResource"]; - button.setTitleFontName(protocolBuffersPath + resourceData["path"]); - } - - var widgetOption = nodeTree["widgetOptions"]; - button.setColor(cc.color(widgetOption["colorR"], widgetOption["colorG"], widgetOption["colorB"])); - button.setOpacity(widgetOption["Alpha"]!==null ? widgetOption["Alpha"] : 255); - - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js index 2a3c3f1514..1a4c4980dd 100644 --- a/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js +++ b/extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js @@ -84,65 +84,6 @@ ccs.checkBoxReader = /** @lends ccs.CheckBoxReader# */{ ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); }, - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var checkBox = widget; - var options = nodeTree["checkBoxOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - //load background image - var backGroundDic = options["backGroundBoxData"]; - var backGroundType = backGroundDic["resourceType"]; - if (backGroundType == 1) - { - cc.spriteFrameCache.addSpriteFrames(protocolBuffersPath + backGroundDic["plistFile"]); - } - var backGroundTexturePath = ccs.widgetReader.getResourcePath(backGroundDic["path"], backGroundType); - checkBox.loadTextureBackGround(backGroundTexturePath, backGroundType); - - //load background selected image - var backGroundSelectedDic = options["backGroundBoxSelectedData"]; - var backGroundSelectedType = backGroundSelectedDic["resourceType"]; - - var backGroundSelectedTexturePath = ccs.widgetReader.getResourcePath(backGroundSelectedDic["path"], backGroundSelectedType); - checkBox.loadTextureBackGroundSelected(backGroundSelectedTexturePath, backGroundSelectedType); - - //load frontCross image - var frontCrossDic = options["frontCrossData"]; - var frontCrossType = frontCrossDic["resourceType"]; - - var frontCrossFileName = ccs.widgetReader.getResourcePath(frontCrossDic["path"], frontCrossType); - checkBox.loadTextureFrontCross(frontCrossFileName, frontCrossType); - - //load backGroundBoxDisabledData - var backGroundDisabledDic = options["backGroundBoxDisabledData"]; - var backGroundDisabledType = backGroundDisabledDic["resourceType"]; - - var backGroundDisabledFileName = ccs.widgetReader.getResourcePath(backGroundDisabledDic["path"], backGroundDisabledType); - checkBox.loadTextureBackGroundDisabled(backGroundDisabledFileName, backGroundDisabledType); - - ///load frontCrossDisabledData - var frontCrossDisabledDic = options["frontCrossDisabledData"]; - var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; - - var frontCrossDisabledFileName = ccs.widgetReader.getResourcePath(frontCrossDisabledDic["path"], frontCrossDisabledType); - checkBox.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); - - checkBox.setSelected(options["selectedState"]); - - var displaystate = true; - if(options["displaystate"]!==null) - { - displaystate = options["displaystate"]; - } - checkBox.setBright(displaystate); - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - }, - getResourceType: function(key){ if(key == "Normal" || key == "Default" || key == "MarkedSubImage") { diff --git a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js index b5ad95923b..19c6cf8552 100644 --- a/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js @@ -89,60 +89,5 @@ ccs.imageViewReader = /** @lends ccs.ImageViewReader# */{ } ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var options = nodeTree["imageViewOptions"]; - var imageView = widget; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - var imageFileNameDic = options["fileNameData"]; - var imageFileNameType = imageFileNameDic["resourceType"]; - - var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); - imageView.loadTexture(imageFileName, imageFileNameType); - - - var scale9EnableExist = options["scale9Enable"]!==null; - var scale9Enable = false; - if (scale9EnableExist) - { - scale9Enable = options["scale9Enable"]; - } - imageView.setScale9Enabled(scale9Enable); - - - if (scale9Enable) - { - imageView.setUnifySizeEnabled(false); - imageView.ignoreContentAdaptWithSize(false); - - var swf = options["scale9width"]!==null ? options["scale9Width"] : 80; - var shf = options["scale9height"]!==null ? options["scale9Height"] : 80; - imageView.setContentSize(cc.size(swf, shf)); - - - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]!==null ? options["capInsetsWidth"] : 1.0; - var ch = options["capInsetsHeight"]!==null ? options["capInsetsHeight"] : 1.0; - - imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); - - } - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var flipX = options.flippedX; - var flipY = options.flippedY; - - if(flipX != false) - imageView.setFlippedX(flipX); - if(flipY != false) - imageView.setFlippedY(flipY); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js index 90680b515d..b4785b06a3 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js @@ -65,44 +65,5 @@ ccs.labelAtlasReader = /** @lends ccs.LabelAtlasReader# */{ } ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var jsonPath = ccs.uiReader.getFilePath(); - - var labelAtlas = widget; - var options = nodeTree["textAtlasOptions"]; - - var cmftDic = options["charMapFileData"]; - var cmfType = cmftDic["resourceType"]; - switch (cmfType) - { - case 0: - { - var tp_c = jsonPath; - var cmfPath = cmftDic["path"]; - var cmf_tp = tp_c += cmfPath; - var stringValue = options["stringValue"]!==null ? options["stringValue"] : "12345678"; - var itemWidth = options["itemWidth"]!==null ? options["itemWidth"] : 24; - var itemHeight = options["itemHeight"]!==null ? options["itemHeight"] : 32; - labelAtlas.setProperty(stringValue, - cmf_tp, - itemWidth, - itemHeight, - options["startCharMap"]); - break; - } - case 1: - cc.log("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js index fa388f1ff4..f0237b6af9 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js @@ -61,43 +61,5 @@ ccs.labelBMFontReader = /** @lends ccs.LabelBMFontReader# */{ var text = options["text"]; labelBMFont.setString(text); ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var jsonPath = ccs.uiReader.getFilePath(); - - var labelBMFont = widget; - var options = nodeTree["textBMFontOptions"]; - - - if(options){ - var cmftDic = options["fileNameData"]; - var cmfType = cmftDic["resourceType"]; - switch (cmfType) - { - case 0: - { - var tp_c = jsonPath; - var cmfPath = cmftDic["path"]; - var cmf_tp = tp_c + cmfPath; - labelBMFont.setFntFile(cmf_tp); - break; - } - case 1: - cc.log("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - - var text = options["text"]!==null ? options["text"] : "Text Label"; - labelBMFont.setString(text); - } - - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js index c76e358cef..934b7f1611 100644 --- a/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js +++ b/extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js @@ -71,57 +71,5 @@ ccs.labelReader = /** @lends ccs.LabelReader# */{ label.setTextVerticalAlignment(options["vAlignment"]); } ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - var label = widget; - var options = nodeTree["textOptions"]; - - var IsCustomSize = options["IsCustomSize"]; - label.ignoreContentAdaptWithSize(!IsCustomSize); - - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - label.setUnifySizeEnabled(false); - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - var touchScaleChangeAble = options["touchScaleEnable"]; - label.setTouchScaleChangeEnabled(touchScaleChangeAble); - var text = options["text"]!==null ? options["text"] : "Text Label"; - label.setString(text); - - var fontSize = options["fontSize"]!==null ? options["fontSize"] : 20; - label.setFontSize(fontSize); - - var fontName = options["fontName"]!==null ? options["fontName"] : "微软雅黑"; - label.setFontName(fontName); - - var aw = options["areaWidth"]; - var ah = options["areaHeight"]; - if (aw !== null && ah !== null) - { - var size = cc.size(aw, ah); - label.setTextAreaSize(size); - } - var ha = options["hAlignment"]; - if (ha) - { - label.setTextHorizontalAlignment(ha); - } - var va = options["vAlignment"]; - if (va) - { - label.setTextVerticalAlignment(va); - } - - if (options["fontResource"]) - { - var resourceData = options["fontResource"]; - label.setFontName(protocolBuffersPath + resourceData["path"]); - } - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js index 8fae198f00..3be52ed9be 100644 --- a/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js +++ b/extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js @@ -118,177 +118,5 @@ ccs.layoutReader = /** @lends ccs.LayoutReader# */{ } panel.setLayoutType(options["layoutType"]); ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var panel = widget; - var options = nodeTree["PanelOptions"]; - if(!options) - return; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - panel.setClippingEnabled(options["clipAble"]); - - var backGroundScale9Enable = options["backGroundScale9Enable"]; - panel.setBackGroundImageScale9Enabled(backGroundScale9Enable); - - - var cr; - var cg; - var cb; - var scr; - var scg; - var scb; - var ecr; - var ecg; - var ecb; - - if (widget instanceof ccui.PageView) - { - cr = 150; - cg = 150; - cb = 150; - - scr = 255; - scg = 255; - scb = 255; - - ecr = 255; - ecg = 150; - ecb = 100; - } - else if(widget instanceof ccui.ListView) - { - cr = 150; - cg = 150; - cb = 255; - - scr = 255; - scg = 255; - scb = 255; - - ecr = 150; - ecg = 150; - ecb = 255; - } - else if(widget instanceof ccui.ScrollView) - { - cr = 255; - cg = 150; - cb = 100; - - scr = 255; - scg = 255; - scb = 255; - - ecr = 255; - ecg = 150; - ecb = 100; - } - else - { - cr = 150; - cg = 200; - cb = 255; - - scr = 255; - scg = 255; - scb = 255; - - ecr = 150; - ecg = 200; - ecb = 255; - } - - cr = options["bgColorR"]!==null ? options["bgColorR"] : cr; - cg = options["bgColorG"]!==null ? options["bgColorG"] : cg; - cb = options["bgColorB"]!==null ? options["bgColorB"] : cb; - - scr = options["bgStartColorR"]!==null ? options["bgStartColorR"] : scr; - scg = options["bgStartColorG"]!==null ? options["bgStartColorG"] : scg; - scb = options["bgStartColorB"]!==null ? options["bgStartColorB"] : scb; - - ecr = options["bgEndColorR"]!==null ? options["bgEndColorR"] : ecr; - ecg = options["bgEndColorG"]!==null ? options["bgEndColorG"] : ecg; - ecb = options["bgEndColorB"]!==null ? options["bgEndColorB"] : ecb; - - var bgcv1 = 0; - var bgcv2 = -0.5; - if(options["vectorX"]!==null) - { - bgcv1 = options["vectorX"]; - } - if(options["vectorY"]) - { - bgcv2 = options["vectorY"]; - } - panel.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - - var co = options["bgColorOpacity"]!==null ? options["bgColorOpacity"] : 100; - - var colorType = options["colorType"]!==null ? options["colorType"] : 1; - panel.setBackGroundColorType(colorType); - - panel.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); - panel.setBackGroundColor(cc.color(cr, cg, cb)); - panel.setBackGroundColorOpacity(co); - - - var imageFileNameDic = options["backGroundImageData"]; - if(imageFileNameDic){ - var imageFileNameType = imageFileNameDic["resourceType"]; - - var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); - panel.setBackGroundImage(imageFileName, imageFileNameType); - } - - - if (backGroundScale9Enable) - { - //var cx = options["capInsetsX"] || 0; - //var cy = options["capInsetsY"] || 0; - //var cw = options["capInsetsWidth"]!==null ? options["capInsetsWidth"] : 1; - //var ch = options["capInsetsHeight"]!==null ? options["capInsetsHeight"] : 1; - //panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - - var sw = options["scale9Width"]; - var sh = options["scale9Height"]; - if (sw!=null && sh !==null) - { - panel.setContentSize(cc.size(sw, sh)); - } - } - - panel.setLayoutType(options["layoutType"]); - - var widgetOptions = nodeTree["widgetOptions"]; - - var red = widgetOptions["colorR"]!==null ? widgetOptions["colorR"] : 255; - var green = widgetOptions["colorG"]!==null ? widgetOptions["colorG"] : 255; - var blue = widgetOptions["colorB"]!==null ? widgetOptions["colorB"] : 255; - panel.setColor(cc.color(red, green, blue)); - - var opacity = widgetOptions["Alpha"]!==null ? widgetOptions["Alpha"] : 255; - panel.setOpacity(opacity); - -// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; -// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; -// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; -// panel.setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb)); -// -// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; -// panel.setBackGroundImageOpacity(bgimgopacity); - - - // other commonly protperties - ccs.widgetReader._setAnchorPointForWidget(widget, nodeTree); - - var flipX = widgetOptions["flipX"]; - var flipY = widgetOptions["flipY"]; - widget.setFlippedX(flipX); - widget.setFlippedY(flipY); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js index 593acda427..0a673274f9 100644 --- a/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js @@ -48,123 +48,5 @@ ccs.listViewReader = /** @lends ccs.ListViewReader# */{ var itemMargin = options["itemMargin"]; listView.setItemsMargin(itemMargin); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var listView = widget; - var options = nodeTree["listviewOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - listView.setClippingEnabled(options["clipAble"]); - - var backGroundScale9Enable = options["backGroundScale9enAble"]; - listView.setBackGroundImageScale9Enabled(backGroundScale9Enable); - - - var cr; - var cg; - var cb; - var scr; - var scg; - var scb; - var ecr; - var ecg; - var ecb; - - - - cr = options["bgColorR"]!==null ? options["bgColorR"] : 150; - cg = options["bgColorG"]!==null ? options["bgColorG"] : 150; - cb = options["bgColorB"]!==null ? options["bgColorB"] : 255; - - scr = options["bgStartColorR"]!==null ? options["bgStartColorR"] : 255; - scg = options["bgStartColorG"]!==null ? options["bgStartColorG"] : 255; - scb = options["bgStartColorB"]!==null ? options["bgStartColorB"] : 255; - - ecr = options["bgEndColorR"]!==null ? options["bgEndColorR"] : 150; - ecg = options["bgEndColorG"]!==null ? options["bgEndColorG"] : 150; - ecb = options["bgEndColorB"]!==null ? options["bgEndColorB"] : 255; - - var bgcv1 = options["vectorX"]; - var bgcv2 = options["ectorY"]!==null ? options["vectorY"] : -0.5; - listView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - - var co = options["bgColorOpacity"]!==null ? options["bgColorOpacity"] : 100; - - var colorType = options["colorType"]!==null ? options["colorType"] : 1; - listView.setBackGroundColorType(colorType); - - listView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); - listView.setBackGroundColor(cc.color(cr, cg, cb)); - listView.setBackGroundColorOpacity(co); - - - var imageFileNameDic = options["backGroundImageData"]; - var imageFileNameType = imageFileNameDic["resourceType"]; - - var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); - listView.setBackGroundImage(imageFileName, imageFileNameType); - - - if (backGroundScale9Enable) - { - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]!==null ? options["capInsetsWidth"] : 1; - var ch = options["capInsetsHeight"]!==null ? options["capInsetsHeight"] : 1; - listView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - - var sw = options["scale9width"]; - var sh = options["scale9height"]; - if (sw!=null && sh!=null) - { - listView.setContentSize(cc.size(sw, sh)); - } - } - - var widgetOptions = nodeTree["widgetOptions"]; - - var red = widgetOptions["colorR"]!==null ? widgetOptions["colorR"] : 255; - var green = widgetOptions["colorG"]!==null ? widgetOptions["colorG"] : 255; - var blue = widgetOptions["colorB"]!==null ? widgetOptions["colorB"] : 255; - listView.setColor(cc.color(red, green, blue)); - - var opacity = widgetOptions["Alpha"]!=null ? widgetOptions["Alpha"] : 255; - listView.setOpacity(opacity); - -// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; -// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; -// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; -// listView.setBackGroundImageColor(cc.color(bgimgcr, bgimgcg, bgimgcb)); -// -// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; -// listView.setBackGroundImageOpacity(bgimgopacity); - - var innerWidth = options["innerWidth"]!==null ? options["innerWidth"] : 200; - var innerHeight = options["innerHeight"]!==null ? options["innerHeight"] : 200; - listView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); - listView.setBounceEnabled(options["bounceEnable"]); - - var direction = options["direction"]!=null ? options["direction"] : 2; - listView.setDirection(direction); - - var gravityValue = options["gravity"]!==null ? options["gravity"] : 3; - var gravity = gravityValue; - listView.setGravity(gravity); - - var itemMargin = options["itemMargin"]; - listView.setItemsMargin(itemMargin); - - - // other commonly protperties - ccs.widgetReader.setAnchorPointForWidget(widget, nodeTree); - - var flipX = widgetOptions["flipX"]; - var flipY = widgetOptions["flipY"]; - widget.setFlippedX(flipX); - widget.setFlippedY(flipY); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js index b1165eed70..5b5ae5fa55 100644 --- a/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js +++ b/extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js @@ -83,51 +83,5 @@ ccs.loadingBarReader = /** @lends ccs.LoadingBarReader# */{ loadingBar.setPercent(options["percent"]); ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var loadingBar = widget; - var options = nodeTree["loadingBarOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - var imageFileNameDic = options["textureData"]; - var imageFileNameType = imageFileNameDic["resourceType"]; - - var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); - loadingBar.loadTexture(imageFileName, imageFileNameType); - - - /* gui mark add load bar scale9 parse */ - var scale9Enable = options["scale9Enable"]; - loadingBar.setScale9Enabled(scale9Enable); - - - var cx = options["capinsetsX"]; - var cy = options["capinsetsY"]; - var cw = options["capinsetsWidth"]!=null ? options["capinsetsWidth"] : 1; - var ch = options["capinsetsHeight"]!=null ? options["capinsetsHeight"] : 1; - - if (scale9Enable) { - loadingBar.setCapInsets(cc.rect(cx, cy, cw, ch)); - - } - - var widgetOptions = nodeTree["widgetOptions"]; - var width = widgetOptions["width"]; - var height = widgetOptions["height"]; - loadingBar.setContentSize(cc.size(width, height)); - - /**/ - - loadingBar.setDirection(options["direction"]); - var percent = options["percent"]!==null ? options["percent"] : 100; - loadingBar.setPercent(percent); - - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js index 48b9357fd0..36b8566cd1 100644 --- a/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js @@ -37,119 +37,6 @@ ccs.pageViewReader = /** @lends ccs.PageViewReader# */{ */ setPropsFromJsonDictionary: function(widget, options){ ccs.layoutReader.setPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - - var pageView = widget; - var options = nodeTree["pageViewOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - //cc.log("options.clipable() = %d", options["clipAble"]); - pageView.setClippingEnabled(options["clipAble"]); - - var backGroundScale9Enable = options["backGroundScale9Enable"]; - pageView.setBackGroundImageScale9Enabled(backGroundScale9Enable); - - - var cr; - var cg; - var cb; - var scr; - var scg; - var scb; - var ecr; - var ecg; - var ecb; - - cr = options["bgColorR"]!==null ? options["bgColorR"] : 150; - cg = options["bgColorG"]!==null ? options["bgColorG"] : 150; - cb = options["bgColorB"]!==null ? options["bgColorB"] : 150; - - scr = options["bgStartColorR"]!==null ? options["bgStartColorR"] : 255; - scg = options["bgStartColorG"]!==null ? options["bgStartColorG"] : 255; - scb = options["bgStartColorB"]!==null ? options["bgStartColorB"] : 255; - - ecr = options["bgEndColorR"]!==null ? options["bgEndColorR"] : 255; - ecg = options["bgEndColorG"]!==null ? options["bgEndColorG"] : 150; - ecb = options["bgEndColorB"]!==null ? options["bgEndColorB"] : 100; - - var bgcv1 = 0; - var bgcv2 = -0.5; - if(options["vectorX"]!==null) - { - bgcv1 = options["vectorX"]; - } - if(options["vectorY"]!==null) - { - bgcv2 = options["vectorY"]; - } - pageView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - - var co = options["bgColorOpacity"]!==null ? options["bgColorOpacity"] : 100; - - var colorType = options["colorType"]!==null ? options["colorType"] : 1; - pageView.setBackGroundColorType(colorType); - - pageView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); - pageView.setBackGroundColor(cc.color(cr, cg, cb)); - pageView.setBackGroundColorOpacity(co); - - - var imageFileNameDic = options["backGroundImageData"]; - if(imageFileNameDic){ - - var imageFileNameType = imageFileNameDic["resourceType"]; - - var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); - pageView.setBackGroundImage(imageFileName, imageFileNameType); - } - - - if (backGroundScale9Enable) - { - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]!==null ? options["capInsetsWidth"] : 1; - var ch = options["capInsetsHeight"]!==null ? options["capInsetsHeight"] : 1; - pageView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - var sw = options["scale9Width"]; - var sh = options["scale9Height"]; - if (sw!=null && sh!=null) - { - pageView.setContentSize(cc.size(sw, sh)); - } - } - - var widgetOptions = nodeTree["widgetOptions"]; - - var red = widgetOptions["colorR"]!==null ? widgetOptions["colorR"] : 255; - var green = widgetOptions["colorG"]!==null ? widgetOptions["colorG"] : 255; - var blue = widgetOptions["colorB"]!==null ? widgetOptions["colorB"] : 255; - pageView.setColor(cc.color(red, green, blue)); - - var opacity = widgetOptions["Alpha"]!==null ? widgetOptions["Alpha"] : 255; - pageView.setOpacity(opacity); - -// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; -// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; -// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; -// pageView.setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb)); -// -// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; -// pageView.setBackGroundImageOpacity(bgimgopacity); - - - // other commonly protperties - ccs.widgetReader.setAnchorPointForWidget(widget, nodeTree); - - var flipX = widgetOptions["flipX"]; - var flipY = widgetOptions["flipY"]; - widget.setFlippedX(flipX); - widget.setFlippedY(flipY); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js index 7c6f10a963..e1b15bb4ef 100644 --- a/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js +++ b/extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js @@ -48,129 +48,5 @@ ccs.scrollViewReader = /** @lends ccs.ScrollViewReader# */{ scrollView.setBounceEnabled(options["bounceEnable"]); ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - - var scrollView = widget; - var options = nodeTree["scrollViewOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - scrollView.setClippingEnabled(options["clipAble"]); - - var backGroundScale9Enable = options["backGroundScale9Enable"]; - scrollView.setBackGroundImageScale9Enabled(backGroundScale9Enable); - - - var cr; - var cg; - var cb; - var scr; - var scg; - var scb; - var ecr; - var ecg; - var ecb; - - - - cr = options["bgColorR"]!==null ? options["bgColorR"] : 255; - cg = options["bgColorG"]!==null ? options["bgColorG"] : 150; - cb = options["bgColorB"]!==null ? options["bgColorB"] : 100; - - scr = options["bgStartColorR"]!==null ? options["bgStartColorR"] : 255; - scg = options["bgStartColorG"]!==null ? options["bgStartColorG"] : 255; - scb = options["bgStartColorB"]!==null ? options["bgStartColorB"] : 255; - - ecr = options["bgEndColorR"]!==null ? options["bgEndColorR"] : 255; - ecg = options["bgEndColorG"]!==null ? options["bgEndColorG"] : 150; - ecb = options["bgEndColorB"]!==null ? options["bgEndColorB"] : 100; - - var bgcv1 = 0; - var bgcv2 = -0.5; - if(options["vectorX"]) - { - bgcv1 = options["vectorX"]; - } - if(options["vectorY"]!==null) - { - bgcv2 = options["vectorY"]; - } - scrollView.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - - var co = options["bgColorOpacity"]!==null ? options["bgColorOpacity"] : 100; - - var colorType = options["colorType"] ? options["colorType"] : 1; - scrollView.setBackGroundColorType(colorType); - - scrollView.setBackGroundColor(cc.color(scr, scg, scb),cc.color(ecr, ecg, ecb)); - scrollView.setBackGroundColor(cc.color(cr, cg, cb)); - scrollView.setBackGroundColorOpacity(co); - - - var imageFileNameDic = options["backGroundImageData"]; - if(imageFileNameDic){ - var imageFileNameType = imageFileNameDic["resourceType"]; - - var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); - scrollView.setBackGroundImage(imageFileName, imageFileNameType); - } - - if (backGroundScale9Enable) - { - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]!==null ? options["capInsetsWidth"] : 1; - var ch = options["capInsetsHeight"]!==null ? options["capInsetsHeight"] : 1; - scrollView.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - var sw = options["scale9Width"]; - var sh = options["scale9Height"]; - if (sw!=null && sh!=null) - { - scrollView.setContentSize(cc.size(sw, sh)); - } - } - - scrollView.setLayoutType(options["layoutType"]); - - var widgetOptions = nodeTree["widgetOptions"]; - - var red = widgetOptions["colorR"]!==null ? widgetOptions["colorR"] : 255; - var green = widgetOptions["colorG"] ? widgetOptions["colorG"] : 255; - var blue = widgetOptions["colorB"] ? widgetOptions["colorB"] : 255; - scrollView.setColor(cc.color(red, green, blue)); - - var opacity = widgetOptions["Alpha"]!==null ? widgetOptions["Alpha"] : 255; - scrollView.setOpacity(opacity); - -// var bgimgcr = widgetOptions.has_colorr() ? widgetOptions.colorr() : 255; -// var bgimgcg = widgetOptions.has_colorg() ? widgetOptions.colorg() : 255; -// var bgimgcb = widgetOptions.has_colorb() ? widgetOptions.colorb() : 255; -// scrollView.setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb)); -// -// var bgimgopacity = widgetOptions.has_opacity() ? widgetOptions.opacity() : 255; -// scrollView.setBackGroundImageOpacity(bgimgopacity); - - - - - var innerWidth = options["innerWidth"]!==null ? options["innerWidth"] : 200; - var innerHeight = options["innerHeight"]!==null ? options["innerHeight"] : 200; - scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); - var direction = options["direction"]!==null ? options["direction"] : 1; - scrollView.setDirection(direction); - scrollView.setBounceEnabled(options["bounceenAble"]); - - - // other commonly protperties - ccs.widgetReader.setAnchorPointForWidget(widget, nodeTree); - - var flipX = widgetOptions["flipX"]; - var flipY = widgetOptions["flipY"]; - widget.setFlippedX(flipX); - widget.setFlippedY(flipY); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js index e322c99444..8dcd93d82e 100644 --- a/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js +++ b/extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js @@ -156,75 +156,5 @@ ccs.sliderReader = /** @lends ccs.SliderReader# */{ } ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - - var slider = widget; - var options = nodeTree["sliderOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - var barTextureScale9Enable = !!options["scale9Enable"]; - if(barTextureScale9Enable) - slider.setUnifySizeEnabled(false); - slider.setScale9Enabled(barTextureScale9Enable); - - slider.setPercent(options["percent"]); - - - // var bt = DICTOOL.checkObjectExist_json(options, P_BarFileName); - var barLength = options["length"]!==null ? options["length"] : 290; - - var imageFileNameDic = options["barFileNameData"]; - var imageFileNameType = imageFileNameDic["resourceType"]; - - var imageFileName = ccs.widgetReader.getResourcePath(imageFileNameDic["path"], imageFileNameType); - slider.loadBarTexture(imageFileName, imageFileNameType); - - if (barTextureScale9Enable) - { - slider.setContentSize(cc.size(barLength, slider.getContentSize().height)); - } - - //loading normal slider ball texture - var normalDic = options["ballNormalData"]; - var normalType = normalDic["resourceType"]; - - imageFileName = ccs.widgetReader.getResourcePath(normalDic["path"], normalType); - slider.loadSlidBallTextureNormal(imageFileName, normalType); - - - //loading slider ball press texture - var pressedDic = options["ballPressedData"]; - var pressedType = pressedDic["resourceType"]; - - var pressedFileName = ccs.widgetReader.getResourcePath(pressedDic["path"], pressedType); - slider.loadSlidBallTexturePressed(pressedFileName, pressedType); - - //loading silder ball disable texture - var disabledDic = options["ballDisabledData"]; - var disabledType = disabledDic["resourceType"]; - - var disabledFileName = ccs.widgetReader.getResourcePath(disabledDic["path"], disabledType); - slider.loadSlidBallTextureDisabled(disabledFileName, disabledType); - - //load slider progress texture - var progressBarDic = options["progressBarData"]; - var progressBarType = progressBarDic["resourceType"]; - - var progressBarFileName = ccs.widgetReader.getResourcePath(progressBarDic["path"], progressBarType); - slider.loadProgressBarTexture(progressBarFileName, progressBarType); - - var displaystate = true; - if(options["displaystate"]!==null) - { - displaystate = options["displaystate"]; - } - slider.setBright(displaystate); - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js index bffd30737e..bb436b4c67 100644 --- a/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js +++ b/extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js @@ -85,80 +85,5 @@ ccs.textFieldReader = /** @lends ccs.TextFieldReader# */{ textField.setTextVerticalAlignment(va); ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - }, - - setPropsFromProtocolBuffers: function(widget, nodeTree){ - var textField = widget; - var options = nodeTree["textfieldOptions"]; - - var protocolBuffersPath = ccs.uiReader.getFilePath(); - - var IsCustomSize = options["isCustomSize"]; - widget.ignoreContentAdaptWithSize(!IsCustomSize); - - if (IsCustomSize) - { - var widgetOptions = nodeTree["widgetOptions"]; - textField.setContentSize(cc.size(widgetOptions["width"], widgetOptions["height"])); - } - - ccs.widgetReader.setPropsFromProtocolBuffers.call(this, widget, nodeTree); - ccs.widgetReader.setAnchorPointForWidget.call(this, widget, nodeTree); - - textField.setUnifySizeEnabled(false); - - var ph = options["placeholder"]; - if (ph!==null) - { - var placeholder = options["placeholder"]!==null ? options["placeholder"] : "inputs words here"; - textField.setPlaceHolder(placeholder); - } - var text = options["text"]!==null ? options["text"] : "Text Field"; - textField.setString(text); - - var fontSize = options["fontSize"] ? options["fontSize"] : 20; - textField.setFontSize(fontSize); - - - var fontName = options["fontName"]!==null ? options["fontName"] : "微软雅黑"; - textField.setFontName(fontName); - - // var tsw = options.has_touchsizewidth(); - // var tsh = options.has_touchsizeheight(); - // if (tsw && tsh) - // { - // textField.setTouchSize(Size(options.touchsizewidth(), options.touchsizeheight())); - // } - - // var dw = DICTOOL.getFloatValue_json(options, "width"); - // var dh = DICTOOL.getFloatValue_json(options, "height"); - // if (dw > 0.0f || dh > 0.0f) - // { - // //textField.setSize(Size(dw, dh)); - // } - var maxLengthEnable = options["maxlengthEnable"]; - textField.setMaxLengthEnabled(maxLengthEnable); - - if (maxLengthEnable) - { - var maxLength = options["maxLength"]!==null ? options["maxLength"] : 10; - textField.setMaxLength(maxLength); - } - var passwordEnable = options["passwordEnable"]; - textField.setPasswordEnabled(passwordEnable); - if (passwordEnable) - { - var passwordStyleText = options["passwordStyleText"]!==null ? options["passwordStyleText"] : "*"; - textField.setPasswordStyleText(passwordStyleText); - } - - if (options["fontResource"]!==null) - { - var resourceData = options["fontresource"]; - textField.setFontName(protocolBuffersPath + resourceData["path"]); - } - - // other commonly protperties - ccs.widgetReader.setColorPropsFromProtocolBuffers.call(this, widget, nodeTree); } }; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js index f91746fd73..dfe3eae17f 100644 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ b/extensions/cocostudio/reader/widgetreader/WidgetReader.js @@ -174,136 +174,6 @@ ccs.widgetReader = /** @lends ccs.widgetReader# */{ return imageFileName_tp; }, - setPropsFromProtocolBuffers: function(widget, nodeTree){ - var options = nodeTree["widgetOptions"]; - - widget.setCascadeColorEnabled(true); - widget.setCascadeOpacityEnabled(true); - widget.setAnchorPoint(cc.p(0, 0)); - - widget.setUnifySizeEnabled(true); - - var ignoreSizeExsit = options["ignoreSize"]; - if (ignoreSizeExsit) - { - widget.ignoreContentAdaptWithSize(options["ignoreSize"]); - } - - widget.setSizeType(options["sizeType"]); - widget.setPositionType(options["positionType"]); - - widget.setSizePercent(cc.p(options["sizePercentX"], options["sizePercentY"])); - widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"])); - - var w = options["width"]; - var h = options["height"]; - widget.setContentSize(cc.size(w, h)); - - widget.setTag(options["tag"]); - widget.setActionTag(options["actionTag"]); - widget.setTouchEnabled(options["touchAble"]); - var name = options.name; - var widgetName = name ? name : "default"; - widget.setName(widgetName); - - var x = options["x"]; - var y = options["y"]; - widget.setPosition(cc.p(x, y)); - - if(options["Alpha"]) - { - widget.setOpacity(options["Alpha"]); - } - - widget.setScaleX(options["scaleX"]!==null ? options["scaleX"] : 1); - - widget.setScaleY(options["scaleY"]!==null ? options["scaleY"] : 1); - - widget.setRotationX(options["rotationSkewX"]!==null ? options["rotationSkewX"] : 0.0); - - widget.setRotationY(options["rotationSkewY"]!==null ? options["rotationSkewY"] : 0.0); - - var vb = options["visible"]; - if (vb) - { - widget.setVisible(options["visible"]); - } - - var z = options["zorder"]; - widget.setLocalZOrder(z); - - - var layout = options["layoutParameter"]; - if (layout) - { - - var layoutParameterDic = options["layoutParameter"]; - var paramType = layoutParameterDic["type"]; - - var parameter = null; - switch (paramType) - { - case 0: - break; - case 1: - { - parameter = new ccui.LinearLayoutParameter(); - var gravity = layoutParameterDic["gravity"]; - parameter.setGravity(gravity); - break; - } - case 2: - { - parameter = new ccui.RelativeLayoutParameter(); - var rParameter = parameter; - var relativeName = layoutParameterDic["relativeName"]; - rParameter.setRelativeName(relativeName); - var relativeToName = layoutParameterDic["relativeToName"]; - rParameter.setRelativeToWidgetName(relativeToName); - var align = layoutParameterDic.align; - rParameter.setAlign(align); - break; - } - default: - break; - } - if (parameter) - { - var mgl = layoutParameterDic["marginLeft"]; - var mgt = layoutParameterDic["marginTop"]; - var mgr = layoutParameterDic["marginRight"]; - var mgb = layoutParameterDic["marginDown"]; - parameter.setMargin(new ccui.Margin(mgl, mgt, mgr, mgb)); - widget.setLayoutParameter(parameter); - } - } - }, - - setColorPropsFromProtocolBuffers: function(widget, nodeTree){ - var options = nodeTree["widgetOptions"]; - - - var isColorRExists = options["colorR"]!==null; - var isColorGExists = options["colorG"]!==null; - var isColorBExists = options["colorB"]!==null; - - var colorR = options["colorR"]; - var colorG = options["colorG"]; - var colorB = options["colorB"]; - - if (isColorRExists && isColorGExists && isColorBExists) - { - widget.setColor(cc.color(colorR, colorG, colorB)); - } - - ccs.widgetReader.setAnchorPointForWidget(widget, nodeTree); - - var flipX = options["flipX"]; - var flipY = options["flipY"]; - widget.setFlippedX(flipX); - widget.setFlippedY(flipY); - }, - setAnchorPointForWidget: function(widget, nodeTree){ var options = nodeTree["widgetOptions"]; diff --git a/external/protobuf/ByteBuffer.min.js b/external/protobuf/ByteBuffer.min.js deleted file mode 100644 index fcb130c588..0000000000 --- a/external/protobuf/ByteBuffer.min.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -ByteBuffer.js (c) 2013-2014 Daniel Wirtz -This version of ByteBuffer.js uses an ArrayBuffer (AB) as its backing buffer and is compatible with modern browsers. -Released under the Apache License, Version 2.0 -see: https://github.com/dcodeIO/ByteBuffer.js for details -*/ -(function(s){function u(k){function g(a,b,c){"undefined"===typeof a&&(a=g.DEFAULT_CAPACITY);"undefined"===typeof b&&(b=g.DEFAULT_ENDIAN);"undefined"===typeof c&&(c=g.DEFAULT_NOASSERT);if(!c){a|=0;if(0>a)throw RangeError("Illegal capacity");b=!!b;c=!!c}this.buffer=0===a?s:new ArrayBuffer(a);this.view=0===a?null:new DataView(this.buffer);this.offset=0;this.markedOffset=-1;this.limit=a;this.littleEndian="undefined"!==typeof b?!!b:!1;this.noAssert=!!c}function m(a){var b=0;return function(){return b< -a.length?a.charCodeAt(b++):null}}function t(){var a=[],b=[];return function(){if(0===arguments.length)return b.join("")+u.apply(String,a);1024=e||(d.set((new Uint8Array(c.buffer)).subarray(c.offset,c.limit),b.offset),b.offset+=e);b.limit=b.offset;b.offset=0;return b};g.isByteBuffer=function(a){return!0===(a&&a instanceof -g)};g.type=function(){return ArrayBuffer};g.wrap=function(a,b,c,d){"string"!==typeof b&&(d=c,c=b,b=void 0);if("string"===typeof a)switch("undefined"===typeof b&&(b="utf8"),b){case "base64":return g.fromBase64(a,c);case "hex":return g.fromHex(a,c);case "binary":return g.fromBinary(a,c);case "utf8":return g.fromUTF8(a,c);case "debug":return g.fromDebug(a,c);default:throw Error("Unsupported encoding: "+b);}if(null===a||"object"!==typeof a)throw TypeError("Illegal buffer");if(g.isByteBuffer(a))return b= -e.clone.call(a),b.markedOffset=-1,b;if(a instanceof Uint8Array)b=new g(0,c,d),0>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*= -2)>b?d:b);this.view.setInt8(b-1,a);c&&(this.offset+=1);return this};e.writeByte=e.writeInt8;e.readInt8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view.getInt8(a);b&&(this.offset+=1);return a};e.readByte=e.readInt8;e.writeUint8=function(a,b){var c= -"undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setUint8(b-1,a);c&&(this.offset+=1);return this};e.readUint8= -function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view.getUint8(a);b&&(this.offset+=1);return a};e.writeInt16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+ -a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setInt16(b-2,a,this.littleEndian);c&&(this.offset+=2);return this};e.writeShort=e.writeInt16;e.readInt16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== -typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}a=this.view.getInt16(a,this.littleEndian);b&&(this.offset+=2);return a};e.readShort=e.readInt16;e.writeUint16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b|| -0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setUint16(b-2,a,this.littleEndian);c&&(this.offset+=2);return this};e.readUint16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)"); -a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}a=this.view.getUint16(a,this.littleEndian);b&&(this.offset+=2);return a};e.writeInt32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ -b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setInt32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};e.writeInt=e.writeInt32;e.readInt32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength); -}a=this.view.getInt32(a,this.littleEndian);b&&(this.offset+=4);return a};e.readInt=e.readInt32;e.writeUint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+= -4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setUint32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};e.readUint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=this.view.getUint32(a,this.littleEndian);b&&(this.offset+= -4);return a};k&&(e.writeInt64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a&&(a=k.fromNumber(a));b+= -8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;this.littleEndian?(this.view.setInt32(b,a.low,!0),this.view.setInt32(b+4,a.high,!0)):(this.view.setInt32(b,a.high,!1),this.view.setInt32(b+4,a.low,!1));c&&(this.offset+=8);return this},e.writeLong=e.writeInt64,e.readInt64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+ -a+" (+8) <= "+this.buffer.byteLength);}a=this.littleEndian?new k(this.view.getInt32(a,!0),this.view.getInt32(a+4,!0),!1):new k(this.view.getInt32(a+4,!1),this.view.getInt32(a,!1),!1);b&&(this.offset+=8);return a},e.readLong=e.readInt64,e.writeUint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+ -b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a&&(a=k.fromNumber(a));b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;this.littleEndian?(this.view.setInt32(b,a.low,!0),this.view.setInt32(b+4,a.high,!0)):(this.view.setInt32(b,a.high,!1),this.view.setInt32(b+4,a.low,!1));c&&(this.offset+=8);return this},e.readUint64=function(a){var b="undefined"===typeof a;b&&(a= -this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=this.littleEndian?new k(this.view.getInt32(a,!0),this.view.getInt32(a+4,!0),!0):new k(this.view.getInt32(a+4,!1),this.view.getInt32(a,!1),!0);b&&(this.offset+=8);return a});e.writeFloat32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!== -typeof a)throw TypeError("Illegal value: "+a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setFloat32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};e.writeFloat=e.writeFloat32;e.readFloat32=function(a){var b="undefined"===typeof a; -b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=this.view.getFloat32(a,this.littleEndian);b&&(this.offset+=4);return a};e.readFloat=e.readFloat32;e.writeFloat64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a)throw TypeError("Illegal value: "+ -a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view.setFloat64(b-8,a,this.littleEndian);c&&(this.offset+=8);return this};e.writeDouble=e.writeFloat64;e.readFloat64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== -typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=this.view.getFloat64(a,this.littleEndian);b&&(this.offset+=8);return a};e.readDouble=e.readFloat64;g.MAX_VARINT32_BYTES=5;g.calculateVarint32=function(a){a>>>=0;return 128>a?1:16384>a?2:2097152>a?3:268435456>a?4:5};g.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0};g.zigZagDecode32=function(a){return a>>> -1^-(a&1)|0};e.writeVarint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=g.calculateVarint32(a);b+=d;var f=this.buffer.byteLength;b>f&&this.resize((f*=2)> -b?f:b);b-=d;this.view.setUint8(b,d=a|128);a>>>=0;128<=a?(d=a>>7|128,this.view.setUint8(b+1,d),16384<=a?(d=a>>14|128,this.view.setUint8(b+2,d),2097152<=a?(d=a>>21|128,this.view.setUint8(b+3,d),268435456<=a?(this.view.setUint8(b+4,a>>28&15),d=5):(this.view.setUint8(b+3,d&127),d=4)):(this.view.setUint8(b+2,d&127),d=3)):(this.view.setUint8(b+1,d&127),d=2)):(this.view.setUint8(b,d&127),d=1);return c?(this.offset+=d,this):d};e.writeVarint32ZigZag=function(a,b){return this.writeVarint32(g.zigZagEncode32(a), -b)};e.readVarint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=0,d=0,f;do{f=a+c;if(!this.noAssert&&f>this.limit)throw a=Error("Truncated"),a.truncated=!0,a;f=this.view.getUint8(f);5>c&&(d|=(f&127)<<7*c>>>0);++c}while(128===(f&128));d|=0;return b?(this.offset+= -c,d):{value:d,length:c}};e.readVarint32ZigZag=function(a){a=this.readVarint32(a);"object"===typeof a?a.value=g.zigZagDecode32(a.value):a=g.zigZagDecode32(a);return a};k&&(g.MAX_VARINT64_BYTES=10,g.calculateVarint64=function(a){"number"===typeof a&&(a=k.fromNumber(a));var b=a.toInt()>>>0,c=a.shiftRightUnsigned(28).toInt()>>>0;a=a.shiftRightUnsigned(56).toInt()>>>0;return 0==a?0==c?16384>b?128>b?1:2:2097152>b?3:4:16384>c?128>c?5:6:2097152>c?7:8:128>a?9:10},g.zigZagEncode64=function(a){"number"===typeof a? -a=k.fromNumber(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},g.zigZagDecode64=function(a){"number"===typeof a?a=k.fromNumber(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftRightUnsigned(1).xor(a.and(k.ONE).toSigned().negate()).toSigned()},e.writeVarint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+ -" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a,!1):!1!==a.unsigned&&(a=a.toSigned());var d=g.calculateVarint64(a),f=a.toInt()>>>0,n=a.shiftRightUnsigned(28).toInt()>>>0,e=a.shiftRightUnsigned(56).toInt()>>>0;b+=d;var r=this.buffer.byteLength;b>r&&this.resize((r*=2)>b?r: -b);b-=d;switch(d){case 10:this.view.setUint8(b+9,e>>>7&1);case 9:this.view.setUint8(b+8,9!==d?e|128:e&127);case 8:this.view.setUint8(b+7,8!==d?n>>>21|128:n>>>21&127);case 7:this.view.setUint8(b+6,7!==d?n>>>14|128:n>>>14&127);case 6:this.view.setUint8(b+5,6!==d?n>>>7|128:n>>>7&127);case 5:this.view.setUint8(b+4,5!==d?n|128:n&127);case 4:this.view.setUint8(b+3,4!==d?f>>>21|128:f>>>21&127);case 3:this.view.setUint8(b+2,3!==d?f>>>14|128:f>>>14&127);case 2:this.view.setUint8(b+1,2!==d?f>>>7|128:f>>>7& -127);case 1:this.view.setUint8(b,1!==d?f|128:f&127)}return c?(this.offset+=d,this):d},e.writeVarint64ZigZag=function(a,b){return this.writeVarint64(g.zigZagEncode64(a),b)},e.readVarint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d=0,f=0,e=0,h=0, -h=this.view.getUint8(a++),d=h&127;if(h&128&&(h=this.view.getUint8(a++),d|=(h&127)<<7,h&128&&(h=this.view.getUint8(a++),d|=(h&127)<<14,h&128&&(h=this.view.getUint8(a++),d|=(h&127)<<21,h&128&&(h=this.view.getUint8(a++),f=h&127,h&128&&(h=this.view.getUint8(a++),f|=(h&127)<<7,h&128&&(h=this.view.getUint8(a++),f|=(h&127)<<14,h&128&&(h=this.view.getUint8(a++),f|=(h&127)<<21,h&128&&(h=this.view.getUint8(a++),e=h&127,h&128&&(h=this.view.getUint8(a++),e|=(h&127)<<7,h&128))))))))))throw Error("Buffer overrun"); -d=k.fromBits(d|f<<28,f>>>4|e<<24,!1);return b?(this.offset=a,d):{value:d,length:a-c}},e.readVarint64ZigZag=function(a){(a=this.readVarint64(a))&&a.value instanceof k?a.value=g.zigZagDecode64(a.value):a=g.zigZagDecode64(a);return a});e.writeCString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);var d,f=a.length;if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");for(d=0;d>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}d=b;f=l.a(m(a))[1];b+=f+1;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=f+1;l.c(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));this.view.setUint8(b++,0);return c?(this.offset=b-d,this):f};e.readCString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!== -typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d,f=-1;l.b(function(){if(0===f)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);return 0===(f=this.view.getUint8(a++))?null:f}.bind(this),d=t(),!0);return b?(this.offset=a,d()):{string:d(),length:a-c}};e.writeIString=function(a,b){var c="undefined"=== -typeof b;c&&(b=this.offset);if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f;f=l.a(m(a),this.noAssert)[1];b+=4+f;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=4+f;this.view.setUint32(b,f,this.littleEndian);b+=4;l.c(m(a),function(a){this.view.setUint8(b++, -a)}.bind(this));if(b!==d+4+f)throw RangeError("Illegal range: Truncated data, "+b+" == "+(b+4+f));return c?(this.offset=b,this):b-d};e.readIString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=0,d=a,c=this.view.getUint32(a,this.littleEndian);a+=4;var f= -a+c;l.b(function(){return a>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d, -f=b;d=l.a(m(a))[1];b+=d;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=d;l.c(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));return c?(this.offset=b,this):b-f};e.writeString=e.writeUTF8String;g.calculateUTF8Chars=function(a){return l.a(m(a))[0]};g.calculateUTF8Bytes=function(a){return l.a(m(a))[1]};e.readUTF8String=function(a,b,c){"number"===typeof b&&(c=b,b=void 0);var d="undefined"===typeof c;d&&(c=this.offset);"undefined"===typeof b&&(b=g.METRICS_CHARS);if(!this.noAssert){if("number"!== -typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}var f=0,e=c,h;if(b===g.METRICS_CHARS){h=t();l.g(function(){return f>>=0;if(0>c||c+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+"+a+") <= "+this.buffer.byteLength);}var r=c+a;l.b(function(){return c>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d= -b,f,e;f=l.a(m(a),this.noAssert)[1];e=g.calculateVarint32(f);b+=e+f;var h=this.buffer.byteLength;b>h&&this.resize((h*=2)>b?h:b);b-=e+f;b+=this.writeVarint32(f,b);l.c(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));if(b!==d+f+e)throw RangeError("Illegal range: Truncated data, "+b+" == "+(b+f+e));return c?(this.offset=b,this):b-d};e.readVString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)"); -a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=this.readVarint32(a),d=a;a+=c.length;var c=c.value,f=a+c,c=t();l.b(function(){return a>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof g||(a=g.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;c+=b;var f=this.buffer.byteLength;c>f&&this.resize((f*=2)>c?f:c);(new Uint8Array(this.buffer,c-b)).set((new Uint8Array(a.buffer)).subarray(a.offset,a.limit));a.offset+=b;d&&(this.offset+=b);return this};e.appendTo=function(a,b){a.append(this, -b);return this};e.assert=function(a){this.noAssert=!a;return this};e.capacity=function(){return this.buffer.byteLength};e.clear=function(){this.offset=0;this.limit=this.buffer.byteLength;this.markedOffset=-1;return this};e.clone=function(a){var b=new g(0,this.littleEndian,this.noAssert);a?(a=new ArrayBuffer(this.buffer.byteLength),(new Uint8Array(a)).set(this.buffer),b.buffer=a,b.view=new DataView(a)):(b.buffer=this.buffer,b.view=this.view);b.offset=this.offset;b.markedOffset=this.markedOffset;b.limit= -this.limit;return b};e.compact=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(0===a&&b===this.buffer.byteLength)return this;var c=b-a;if(0=== -c)return this.buffer=s,this.view=null,0<=this.markedOffset&&(this.markedOffset-=a),this.limit=this.offset=0,this;var d=new ArrayBuffer(c);(new Uint8Array(d)).set((new Uint8Array(this.buffer)).subarray(a,b));this.buffer=d;this.view=new DataView(d);0<=this.markedOffset&&(this.markedOffset-=a);this.offset=0;this.limit=c;return this};e.copy=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer"); -a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return new g(0,this.littleEndian,this.noAssert);var c=b-a,d=new g(c,this.littleEndian,this.noAssert);d.offset=0;d.limit=c;0<=d.markedOffset&&(d.markedOffset-=a);this.copyTo(d,0,a,b);return d};e.copyTo=function(a,b,c,d){var f,e;if(!this.noAssert&&!g.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer"); -b=(e="undefined"===typeof b)?a.offset:b|0;c=(f="undefined"===typeof c)?this.offset:c|0;d="undefined"===typeof d?this.limit:d|0;if(0>b||b>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+b+" <= "+a.buffer.byteLength);if(0>c||d>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+c+" <= "+this.buffer.byteLength);var h=d-c;if(0===h)return a;a.ensureCapacity(b+h);(new Uint8Array(a.buffer)).set((new Uint8Array(this.buffer)).subarray(c,d),b);f&&(this.offset+=h);e&&(a.offset+= -h);return this};e.ensureCapacity=function(a){var b=this.buffer.byteLength;return ba?b:a):this};e.fill=function(a,b,c){var d="undefined"===typeof b;d&&(b=this.offset);"string"===typeof a&&0>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal end: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(b>=c)return this;for(;b>>=0;if(0>a||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength);}this.markedOffset=a;return this};e.order=function(a){if(!this.noAssert&&"boolean"!==typeof a)throw TypeError("Illegal littleEndian: Not a boolean");this.littleEndian=!!a;return this};e.LE=function(a){this.littleEndian="undefined"!==typeof a?!!a:!0;return this};e.BE=function(a){this.littleEndian="undefined"!==typeof a?!a:!1;return this};e.prepend=function(a, -b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var d="undefined"===typeof c;d&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof g||(a=g.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;var f=b-c,e;if(0a)throw RangeError("Illegal capacity: 0 <= "+a);}this.buffer.byteLength>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return this;Array.prototype.reverse.call((new Uint8Array(this.buffer)).subarray(a, -b));this.view=new DataView(this.buffer);return this};e.skip=function(a){if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var b=this.offset+a;if(!this.noAssert&&(0>b||b>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);this.offset=b;return this};e.slice=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!== -typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c=this.clone();c.offset=a;c.limit=b;return c};e.toBuffer=function(a){var b=this.offset,c=this.limit;if(b>c)var d=b,b=c,c=d;if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: Not an integer"); -b>>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal limit: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(!a&&0===b&&c===this.buffer.byteLength)return this.buffer;if(b===c)return s;a=new ArrayBuffer(c-b);(new Uint8Array(a)).set((new Uint8Array(this.buffer)).subarray(b,c),0);return a};e.toArrayBuffer=e.toBuffer;e.toString=function(a,b,c){if("undefined"===typeof a)return"ByteBufferAB(offset="+ -this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";"number"===typeof a&&(c=b=a="utf8");switch(a){case "utf8":return this.toUTF8(b,c);case "base64":return this.toBase64(b,c);case "hex":return this.toHex(b,c);case "binary":return this.toBinary(b,c);case "debug":return this.toDebug();case "columns":return this.m();default:throw Error("Unsupported encoding: "+a);}};var v=function(){for(var a={},b=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82, -83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],c=[],d=0,f=b.length;d>2&63]),f=(d&3)<<4,null!==(d=a())?(f|=d>>4&15,c(b[(f|d>>4&15)&63]),f=(d&15)<<2,null!==(d=a())?(c(b[(f|d>>6&3)&63]),c(b[d&63])):(c(b[f&63]),c(61))):(c(b[f&63]),c(61),c(61))};a.h=function(a,b){function d(a){throw Error("Illegal character code: "+a);}for(var f, -e,g;null!==(f=a());)if(e=c[f],"undefined"===typeof e&&d(f),null!==(f=a())&&(g=c[f],"undefined"===typeof g&&d(f),b(e<<2>>>0|(g&48)>>4),null!==(f=a()))){e=c[f];if("undefined"===typeof e)if(61===f)break;else d(f);b((g&15)<<4>>>0|(e&60)>>2);if(null!==(f=a())){g=c[f];if("undefined"===typeof g)if(61===f)break;else d(f);b((e&3)<<6>>>0|g)}}};a.test=function(a){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(a)};return a}();e.toBase64=function(a,b){"undefined"===typeof a&&(a= -this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c;v.i(function(){return a>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return"";for(var c=[],d=[];ad?f+("0"+d.toString(16).toUpperCase()):f+d.toString(16).toUpperCase(),a&&(e+=32d?String.fromCharCode(d):"."));++b;if(a&&0f.length;)f+=" ";g+=f+e+"\n";f=e=""}f=b=== -this.offset&&b===this.limit?f+(b===this.markedOffset?"!":"|"):b===this.offset?f+(b===this.markedOffset?"[":"<"):b===this.limit?f+(b===this.markedOffset?"]":">"):f+(b===this.markedOffset?"'":a||0!==b&&b!==c?" ":"")}if(a&&" "!==f){for(;51>f.length;)f+=" ";g+=f+e+"\n"}return a?g:f};g.fromDebug=function(a,b,c){var d=a.length;b=new g((d+1)/3|0,b,c);for(var f=0,e=0,h,k=!1,l=!1,m=!1,q=!1,p=!1;f":if(!c){if(q){p=!0;break}q=!0}b.limit=e;k=!1;break;case "'":if(!c){if(m){p=!0;break}m=!0}b.markedOffset=e;k=!1;break;case " ":k=!1;break;default:if(!c&&k){p=!0;break}h=parseInt(h+a.charAt(f++), -16);if(!c&&(isNaN(h)||0>h||255>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}for(var c=Array(b-a),d;ad?c.push("0",d.toString(16)):c.push(d.toString(16));return c.join("")};g.fromHex=function(a,b,c){if(!c){if("string"!==typeof a)throw TypeError("Illegal str: Not a string"); -if(0!==a.length%2)throw TypeError("Illegal str: Length not a multiple of 2");}var d=a.length;b=new g(d/2|0,b);for(var f,e=0,h=0;ef||255d?c(d&127):(2048>d?c(d>>6&31|192):(65536>d? -c(d>>12&15|224):(c(d>>18&7|240),c(d>>12&63|128)),c(d>>6&63|128)),c(d&63|128)),d=null},g:function(a,c){function d(a){a=a.slice(0,a.indexOf(null));var b=Error(a.toString());b.name="TruncatedError";b.bytes=a;throw b;}for(var e,g,h,k;null!==(e=a());)if(0===(e&128))c(e);else if(192===(e&224))null===(g=a())&&d([e,g]),c((e&31)<<6|g&63);else if(224===(e&240))null!==(g=a())&&null!==(h=a())||d([e,g,h]),c((e&15)<<12|(g&63)<<6|h&63);else if(240===(e&248))null!==(g=a())&&null!==(h=a())&&null!==(k=a())||d([e,g, -h,k]),c((e&7)<<18|(g&63)<<12|(h&63)<<6|k&63);else throw RangeError("Illegal starting byte: "+e);},d:function(a,c){for(var d,e=null;null!==(d=null!==e?e:a());)55296<=d&&57343>=d&&null!==(e=a())&&56320<=e&&57343>=e?(c(1024*(d-55296)+e-56320+65536),e=null):c(d);null!==e&&c(e)},e:function(a,c){var d=null;"number"===typeof a&&(d=a,a=function(){return null});for(;null!==d||null!==(d=a());)65535>=d?c(d):(d-=65536,c((d>>10)+55296),c(d%1024+56320)),d=null},c:function(b,c){a.d(b,function(b){a.j(b,c)})},b:function(b, -c){a.g(b,function(b){a.e(b,c)})},f:function(a){return 128>a?1:2048>a?2:65536>a?3:4},l:function(b){for(var c,d=0;null!==(c=b());)d+=a.f(c);return d},a:function(b){var c=0,d=0;a.d(b,function(b){++c;d+=a.f(b)});return[c,d]}};return a}();e.toUTF8=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer"); -b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c;try{l.b(function(){return a - Released under the Apache License, Version 2.0 - see: https://github.com/dcodeIO/Long.js for details - */ -(function(q){function b(a,b,d){this.low=a|0;this.high=b|0;this.unsigned=!!d}b.isLong=function(a){return!0===(a&&a instanceof b)};var r={},s={};b.fromInt=function(a,c){var d;if(c){a>>>=0;if(0<=a&&256>a&&(d=s[a]))return d;d=new b(a,0>(a|0)?-1:0,!0);0<=a&&256>a&&(s[a]=d)}else{a|=0;if(-128<=a&&128>a&&(d=r[a]))return d;d=new b(a,0>a?-1:0,!1);-128<=a&&128>a&&(r[a]=d)}return d};b.fromNumber=function(a,c){c=!!c;return isNaN(a)||!isFinite(a)?b.ZERO:!c&&a<=-t?b.MIN_VALUE:!c&&a+1>=t?b.MAX_VALUE:c&&a>=u?b.MAX_UNSIGNED_VALUE: -0>a?b.fromNumber(-a,c).negate():new b(a%l|0,a/l|0,c)};b.fromBits=function(a,c,d){return new b(a,c,d)};b.fromString=function(a,c,d){if(0===a.length)throw Error("number format error: empty string");if("NaN"===a||"Infinity"===a||"+Infinity"===a||"-Infinity"===a)return b.ZERO;"number"===typeof c&&(d=c,c=!1);d=d||10;if(2>d||36k?(k=b.fromNumber(Math.pow(d,k)),f=f.multiply(k).add(b.fromNumber(m))):(f=f.multiply(e),f=f.add(b.fromNumber(m)))}f.unsigned=c;return f};b.fromValue=function(a){return"number"===typeof a?b.fromNumber(a):"string"===typeof a?b.fromString(a):b.isLong(a)?a:new b(a.low,a.high,a.unsigned)};var l=4294967296,u=l*l,t=u/2,v=b.fromInt(16777216);b.ZERO=b.fromInt(0); -b.UZERO=b.fromInt(0,!0);b.ONE=b.fromInt(1);b.UONE=b.fromInt(1,!0);b.NEG_ONE=b.fromInt(-1);b.MAX_VALUE=b.fromBits(-1,2147483647,!1);b.MAX_UNSIGNED_VALUE=b.fromBits(-1,-1,!0);b.MIN_VALUE=b.fromBits(0,-2147483648,!1);b.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)};b.prototype.toString=function(a){a=a||10;if(2>a||36>>0).toString(a);c=f;if(c.isZero())return g+e;for(;6>g.length;)g="0"+g;e=""+g+e}};b.prototype.getHighBits=function(){return this.high};b.prototype.getHighBitsUnsigned=function(){return this.high>>> -0};b.prototype.getLowBits=function(){return this.low};b.prototype.getLowBitsUnsigned=function(){return this.low>>>0};b.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(b.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var a=0!=this.high?this.high:this.low,c=31;0this.high};b.prototype.isPositive=function(){return this.unsigned|| -0<=this.high};b.prototype.isOdd=function(){return 1===(this.low&1)};b.prototype.equals=function(a){b.isLong(a)||(a=b.fromValue(a));return this.unsigned!==a.unsigned&&this.high>>>31!==a.high>>>31?!1:this.high===a.high&&this.low===a.low};b.prototype.notEquals=function(a){b.isLong(a)||(a=b.fromValue(a));return!this.equals(a)};b.prototype.lessThan=function(a){b.isLong(a)||(a=b.fromValue(a));return 0>this.compare(a)};b.prototype.lessThanOrEqual=function(a){b.isLong(a)||(a=b.fromValue(a));return 0>=this.compare(a)}; -b.prototype.greaterThan=function(a){b.isLong(a)||(a=b.fromValue(a));return 0>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.subtract(a).isNegative()?-1:1};b.prototype.negate=function(){return!this.unsigned&&this.equals(b.MIN_VALUE)?b.MIN_VALUE: -this.not().add(b.ONE)};b.prototype.add=function(a){b.isLong(a)||(a=b.fromValue(a));var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=a.high>>>16,g=a.high&65535,k=a.low>>>16,m;m=0+((this.low&65535)+(a.low&65535));a=0+(m>>>16);a+=e+k;e=0+(a>>>16);e+=d+g;d=0+(e>>>16);d=d+(c+f)&65535;return b.fromBits((a&65535)<<16|m&65535,d<<16|e&65535,this.unsigned)};b.prototype.subtract=function(a){b.isLong(a)||(a=b.fromValue(a));return this.add(a.negate())};b.prototype.multiply=function(a){if(this.isZero())return b.ZERO; -b.isLong(a)||(a=b.fromValue(a));if(a.isZero())return b.ZERO;if(this.equals(b.MIN_VALUE))return a.isOdd()?b.MIN_VALUE:b.ZERO;if(a.equals(b.MIN_VALUE))return this.isOdd()?b.MIN_VALUE:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().multiply(a.negate()):this.negate().multiply(a).negate();if(a.isNegative())return this.multiply(a.negate()).negate();if(this.lessThan(v)&&a.lessThan(v))return b.fromNumber(this.toNumber()*a.toNumber(),this.unsigned);var c=this.high>>>16,d=this.high&65535,e= -this.low>>>16,f=this.low&65535,g=a.high>>>16,k=a.high&65535,m=a.low>>>16;a=a.low&65535;var p,h,n,l;l=0+f*a;n=0+(l>>>16);n+=e*a;h=0+(n>>>16);n=(n&65535)+f*m;h+=n>>>16;n&=65535;h+=d*a;p=0+(h>>>16);h=(h&65535)+e*m;p+=h>>>16;h&=65535;h+=f*k;p+=h>>>16;h&=65535;p=p+(c*a+d*m+e*k+f*g)&65535;return b.fromBits(n<<16|l&65535,p<<16|h,this.unsigned)};b.prototype.div=function(a){b.isLong(a)||(a=b.fromValue(a));if(a.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?b.UZERO:b.ZERO;var c, -d,e;if(this.equals(b.MIN_VALUE)){if(a.equals(b.ONE)||a.equals(b.NEG_ONE))return b.MIN_VALUE;if(a.equals(b.MIN_VALUE))return b.ONE;c=this.shiftRight(1).div(a).shiftLeft(1);if(c.equals(b.ZERO))return a.isNegative()?b.ONE:b.NEG_ONE;d=this.subtract(a.multiply(c));return e=c.add(d.div(a))}if(a.equals(b.MIN_VALUE))return this.unsigned?b.UZERO:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().div(a.negate()):this.negate().div(a).negate();if(a.isNegative())return this.div(a.negate()).negate(); -e=b.ZERO;for(d=this;d.greaterThanOrEqual(a);){c=Math.max(1,Math.floor(d.toNumber()/a.toNumber()));for(var f=Math.ceil(Math.log(c)/Math.LN2),f=48>=f?1:Math.pow(2,f-48),g=b.fromNumber(c),k=g.multiply(a);k.isNegative()||k.greaterThan(d);)c-=f,g=b.fromNumber(c,this.unsigned),k=g.multiply(a);g.isZero()&&(g=b.ONE);e=e.add(g);d=d.subtract(k)}return e};b.prototype.modulo=function(a){b.isLong(a)||(a=b.fromValue(a));return this.subtract(this.div(a).multiply(a))};b.prototype.not=function(){return b.fromBits(~this.low, -~this.high,this.unsigned)};b.prototype.and=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low&a.low,this.high&a.high,this.unsigned)};b.prototype.or=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low|a.low,this.high|a.high,this.unsigned)};b.prototype.xor=function(a){b.isLong(a)||(a=b.fromValue(a));return b.fromBits(this.low^a.low,this.high^a.high,this.unsigned)};b.prototype.shiftLeft=function(a){b.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?b.fromBits(this.low<< -a,this.high<>>32-a,this.unsigned):b.fromBits(0,this.low<a?b.fromBits(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):b.fromBits(this.high>>a-32,0<=this.high?0:-1,this.unsigned)};b.prototype.shiftRightUnsigned=function(a){b.isLong(a)&&(a=a.toInt());a&=63;if(0===a)return this;var c=this.high;return 32>a?b.fromBits(this.low>>>a|c<<32-a,c>>>a,this.unsigned):32===a?b.fromBits(c, -0,this.unsigned):b.fromBits(c>>>a-32,0,this.unsigned)};b.prototype.toSigned=function(){return this.unsigned?new b(this.low,this.high,!1):this};b.prototype.toUnsigned=function(){return this.unsigned?this:new b(this.low,this.high,!0)};"undefined"!==typeof module&&module.exports?module.exports=b:"function"===typeof define&&define.amd?define(function(){return b}):(q.dcodeIO=q.dcodeIO||{}).Long=b})(this);})(); diff --git a/external/protobuf/ProtoBuf.min.js b/external/protobuf/ProtoBuf.min.js deleted file mode 100644 index 6db98fc7b5..0000000000 --- a/external/protobuf/ProtoBuf.min.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - ProtoBuf.js (c) 2013 Daniel Wirtz - Released under the Apache License, Version 2.0 - see: https://github.com/dcodeIO/ProtoBuf.js for details -*/ -(function(s){function u(m){var g={VERSION:"3.7.0",WIRE_TYPES:{}};g.WIRE_TYPES.VARINT=0;g.WIRE_TYPES.BITS64=1;g.WIRE_TYPES.LDELIM=2;g.WIRE_TYPES.STARTGROUP=3;g.WIRE_TYPES.ENDGROUP=4;g.WIRE_TYPES.BITS32=5;g.PACKABLE_WIRE_TYPES=[g.WIRE_TYPES.VARINT,g.WIRE_TYPES.BITS64,g.WIRE_TYPES.BITS32];g.TYPES={int32:{name:"int32",wireType:g.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:g.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:g.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:g.WIRE_TYPES.VARINT},uint64:{name:"uint64", -wireType:g.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:g.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:g.WIRE_TYPES.VARINT},"double":{name:"double",wireType:g.WIRE_TYPES.BITS64},string:{name:"string",wireType:g.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:g.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:g.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:g.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:g.WIRE_TYPES.BITS64},sfixed64:{name:"sfixed64",wireType:g.WIRE_TYPES.BITS64}, -"float":{name:"float",wireType:g.WIRE_TYPES.BITS32},"enum":{name:"enum",wireType:g.WIRE_TYPES.VARINT},message:{name:"message",wireType:g.WIRE_TYPES.LDELIM},group:{name:"group",wireType:g.WIRE_TYPES.STARTGROUP}};g.ID_MIN=1;g.ID_MAX=536870911;g.ByteBuffer=m;g.Long=m.Long||null;g.convertFieldsToCamelCase=!1;g.populateAccessors=!0;g.Util=function(){Object.create||(Object.create=function(e){function d(){}if(1=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var f,a;do{for(f=!1;d.WHITESPACE.test(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++, -this.index==this.source.length)return null;this.index++;this.line++;f=!0}else if("*"===this.source.charAt(this.index)){for(a="";"*/"!==a+(a=this.source.charAt(this.index));)if(this.index++,"\n"===a&&this.line++,this.index===this.source.length)return null;this.index++;f=!0}else throw Error("Unterminated comment at line "+this.line+": /"+this.source.charAt(this.index));}while(f);if(this.index===this.source.length)return null;f=this.index;d.DELIM.lastIndex=0;if(d.DELIM.test(this.source.charAt(f)))++f; -else for(++f;fa?"-":"")+f);};b._parseString=function(){var f="",a;do{this.tn.next();f+=this.tn.next();a=this.tn.next();if(a!==this.tn.stringEndsWith)throw Error("Illegal end of string at line "+this.tn.line+": "+a);a=this.tn.peek()}while(a===d.STRINGOPEN||a===d.STRINGOPEN_SQ); -return f};b._parseId=function(f,a){var c=-1,b=1;"-"==f.charAt(0)&&(b=-1,f=f.substring(1));if(d.NUMBER_DEC.test(f))c=parseInt(f);else if(d.NUMBER_HEX.test(f))c=parseInt(f.substring(2),16);else if(d.NUMBER_OCT.test(f))c=parseInt(f.substring(1),8);else throw Error("Illegal id at line "+this.tn.line+": "+(0>b?"-":"")+f);c=b*c|0;if(!a&&0>c)throw Error("Illegal id at line "+this.tn.line+": "+(0>b?"-":"")+f);return c};b._parsePackage=function(f){f=this.tn.next();if(!d.TYPEREF.test(f))throw Error("Illegal package name at line "+ -this.tn.line+": "+f);var a=f;f=this.tn.next();if(f!=d.END)throw Error("Illegal end of package at line "+this.tn.line+": "+f);return a};b._parseImport=function(f){f=this.tn.peek();"public"===f&&(this.tn.next(),f=this.tn.peek());if(f!==d.STRINGOPEN&&f!==d.STRINGOPEN_SQ)throw Error("Illegal start of import at line "+this.tn.line+": "+f);var a=this._parseString();f=this.tn.next();if(f!==d.END)throw Error("Illegal end of import at line "+this.tn.line+": "+f);return a};b._parseOption=function(f,a){a=this.tn.next(); -var c=!1;a==d.COPTOPEN&&(c=!0,a=this.tn.next());if(!d.TYPEREF.test(a)&&!/google\.protobuf\./.test(a))throw Error("Illegal option name in message "+f.name+" at line "+this.tn.line+": "+a);var b=a;a=this.tn.next();if(c){if(a!==d.COPTCLOSE)throw Error("Illegal end in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);b="("+b+")";a=this.tn.next();d.FQTYPEREF.test(a)&&(b+=a,a=this.tn.next())}if(a!==d.EQUAL)throw Error("Illegal operator in message "+f.name+", option "+b+" at line "+this.tn.line+ -": "+a);a=this.tn.peek();if(a===d.STRINGOPEN||a===d.STRINGOPEN_SQ)c=this._parseString();else if(this.tn.next(),d.NUMBER.test(a))c=this._parseNumber(a,!0);else if(d.BOOL.test(a))c="true"===a;else if(d.TYPEREF.test(a))c=a;else throw Error("Illegal option value in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!==d.END)throw Error("Illegal end of option in message "+f.name+", option "+b+" at line "+this.tn.line+": "+a);f.options[b]=c};b._parseIgnoredStatement=function(f, -a){var c;do{c=this.tn.next();if(null===c)throw Error("Unexpected EOF in "+f.name+", "+a+" at line "+this.tn.line);if(c===d.END)break}while(1)};b._parseService=function(f,a){a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal service name at line "+this.tn.line+": "+a);var c=a,b={name:c,rpc:{},options:{}};a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of service "+c+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),"option"===a)this._parseOption(b,a);else if("rpc"===a)this._parseServiceRPC(b, -a);else if(a!==d.CLOSE)throw Error("Illegal type of service "+c+" at line "+this.tn.line+": "+a);while(a!==d.CLOSE);f.services.push(b)};b._parseServiceRPC=function(f,a){var c=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal method name in service "+f.name+" at line "+this.tn.line+": "+a);var b=a,e={request:null,response:null,options:{}};a=this.tn.next();if(a!==d.COPTOPEN)throw Error("Illegal start of request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next(); -if(!d.TYPEREF.test(a))throw Error("Illegal request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);e.request=a;a=this.tn.next();if(a!=d.COPTCLOSE)throw Error("Illegal end of request type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if("returns"!==a.toLowerCase())throw Error("Illegal delimiter in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a!=d.COPTOPEN)throw Error("Illegal start of response type in service "+f.name+"#"+ -b+" at line "+this.tn.line+": "+a);a=this.tn.next();e.response=a;a=this.tn.next();if(a!==d.COPTCLOSE)throw Error("Illegal end of response type in service "+f.name+"#"+b+" at line "+this.tn.line+": "+a);a=this.tn.next();if(a===d.OPEN){do if(a=this.tn.next(),"option"===a)this._parseOption(e,a);else if(a!==d.CLOSE)throw Error("Illegal start of option inservice "+f.name+"#"+b+" at line "+this.tn.line+": "+a);while(a!==d.CLOSE);this.tn.peek()===d.END&&this.tn.next()}else if(a!==d.END)throw Error("Illegal delimiter in service "+ -f.name+"#"+b+" at line "+this.tn.line+": "+a);"undefined"===typeof f[c]&&(f[c]={});f[c][b]=e};b._parseMessage=function(f,a,c){var b={},e="group"===c;c=this.tn.next();if(!d.NAME.test(c))throw Error("Illegal "+(e?"group":"message")+" name"+(f?" in message "+f.name:"")+" at line "+this.tn.line+": "+c);b.name=c;if(e){c=this.tn.next();if(c!==d.EQUAL)throw Error("Illegal id assignment after group "+b.name+" at line "+this.tn.line+": "+c);c=this.tn.next();try{a.id=this._parseId(c)}catch(g){throw Error("Illegal field id value for group "+ -b.name+"#"+a.name+" at line "+this.tn.line+": "+c);}b.isGroup=!0}b.fields=[];b.enums=[];b.messages=[];b.options={};b.oneofs={};c=this.tn.next();c===d.OPTOPEN&&a&&(this._parseFieldOptions(b,a,c),c=this.tn.next());if(c!==d.OPEN)throw Error("Illegal start of "+(e?"group":"message")+" "+b.name+" at line "+this.tn.line+": "+c);do if(c=this.tn.next(),c===d.CLOSE){c=this.tn.peek();c===d.END&&this.tn.next();break}else if(d.RULE.test(c))this._parseMessageField(b,c);else if("oneof"===c)this._parseMessageOneOf(b, -c);else if("enum"===c)this._parseEnum(b,c);else if("message"===c)this._parseMessage(b,null,c);else if("option"===c)this._parseOption(b,c);else if("extensions"===c)b.extensions=this._parseExtensions(b,c);else if("extend"===c)this._parseExtend(b,c);else throw Error("Illegal token in message "+b.name+" at line "+this.tn.line+": "+c);while(1);f.messages.push(b);return b};b._parseMessageField=function(b,a){var c={},e=null;c.rule=a;c.options={};a=this.tn.next();if("group"===a){e=this._parseMessage(b,c, -a);if(!/^[A-Z]/.test(e.name))throw Error("Group names must start with a capital letter");c.type=e.name;c.name=e.name.toLowerCase();a=this.tn.peek();a===d.END&&this.tn.next()}else{if(!d.TYPE.test(a)&&!d.TYPEREF.test(a))throw Error("Illegal field type in message "+b.name+" at line "+this.tn.line+": "+a);c.type=a;a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal field name in message "+b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal token in field "+ -b.name+"#"+c.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a)}catch(g){throw Error("Illegal field id in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}a=this.tn.next();a===d.OPTOPEN&&(this._parseFieldOptions(b,c,a),a=this.tn.next());if(a!==d.END)throw Error("Illegal delimiter in message "+b.name+"#"+c.name+" at line "+this.tn.line+": "+a);}b.fields.push(c);return c};b._parseMessageOneOf=function(b,a){a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal oneof name in message "+ -b.name+" at line "+this.tn.line+": "+a);var c=a,e,g=[];a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of oneof "+c+" at line "+this.tn.line+": "+a);for(;this.tn.peek()!==d.CLOSE;)e=this._parseMessageField(b,"optional"),e.oneof=c,g.push(e.id);this.tn.next();b.oneofs[c]=g};b._parseFieldOptions=function(b,a,c){var e=!0;do{c=this.tn.next();if(c===d.OPTCLOSE)break;else if(c===d.OPTEND){if(e)throw Error("Illegal start of options in message "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c); -c=this.tn.next()}this._parseFieldOption(b,a,c);e=!1}while(1)};b._parseFieldOption=function(b,a,c){var e=!1;c===d.COPTOPEN&&(c=this.tn.next(),e=!0);if(!d.TYPEREF.test(c))throw Error("Illegal field option in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);var g=c;c=this.tn.next();if(e){if(c!==d.COPTCLOSE)throw Error("Illegal delimiter in "+b.name+"#"+a.name+" at line "+this.tn.line+": "+c);g="("+g+")";c=this.tn.next();d.FQTYPEREF.test(c)&&(g+=c,c=this.tn.next())}if(c!==d.EQUAL)throw Error("Illegal token in "+ -b.name+"#"+a.name+" at line "+this.tn.line+": "+c);c=this.tn.peek();if(c===d.STRINGOPEN||c===d.STRINGOPEN_SQ)b=this._parseString();else if(d.NUMBER.test(c,!0))b=this._parseNumber(this.tn.next(),!0);else if(d.BOOL.test(c))b="true"===this.tn.next().toLowerCase();else if(d.TYPEREF.test(c))b=this.tn.next();else throw Error("Illegal value in message "+b.name+"#"+a.name+", option "+g+" at line "+this.tn.line+": "+c);a.options[g]=b};b._parseEnum=function(b,a){var c={};a=this.tn.next();if(!d.NAME.test(a))throw Error("Illegal enum name in message "+ -b.name+" at line "+this.tn.line+": "+a);c.name=a;a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of enum "+c.name+" at line "+this.tn.line+": "+a);c.values=[];c.options={};do{a=this.tn.next();if(a===d.CLOSE){a=this.tn.peek();a===d.END&&this.tn.next();break}if("option"==a)this._parseOption(c,a);else{if(!d.NAME.test(a))throw Error("Illegal name in enum "+c.name+" at line "+this.tn.line+": "+a);this._parseEnumValue(c,a)}}while(1);b.enums.push(c)};b._parseEnumValue=function(b,a){var c={};c.name= -a;a=this.tn.next();if(a!==d.EQUAL)throw Error("Illegal token in enum "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();try{c.id=this._parseId(a,!0)}catch(e){throw Error("Illegal id in enum "+b.name+" at line "+this.tn.line+": "+a);}b.values.push(c);a=this.tn.next();a===d.OPTOPEN&&(this._parseFieldOptions(b,{options:{}},a),a=this.tn.next());if(a!==d.END)throw Error("Illegal delimiter in enum "+b.name+" at line "+this.tn.line+": "+a);};b._parseExtensions=function(b,a){var c=[];a=this.tn.next(); -"min"===a?c.push(e.ID_MIN):"max"===a?c.push(e.ID_MAX):c.push(this._parseNumber(a));a=this.tn.next();if("to"!==a)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);a=this.tn.next();"min"===a?c.push(e.ID_MIN):"max"===a?c.push(e.ID_MAX):c.push(this._parseNumber(a));a=this.tn.next();if(a!==d.END)throw Error("Illegal extensions delimiter in message "+b.name+" at line "+this.tn.line+": "+a);return c};b._parseExtend=function(b,a){a=this.tn.next();if(!d.TYPEREF.test(a))throw Error("Illegal message name at line "+ -this.tn.line+": "+a);var c={};c.ref=a;c.fields=[];a=this.tn.next();if(a!==d.OPEN)throw Error("Illegal start of extend "+c.name+" at line "+this.tn.line+": "+a);do if(a=this.tn.next(),a===d.CLOSE){a=this.tn.peek();a==d.END&&this.tn.next();break}else if(d.RULE.test(a))this._parseMessageField(c,a);else throw Error("Illegal token in extend "+c.name+" at line "+this.tn.line+": "+a);while(1);b.messages.push(c);return c};b.toString=function(){return"Parser"};g.Parser=n;return g}(g,g.Lang);g.Reflect=function(e){function d(a, -b){var c=b.readVarint32(),f=c&7,c=c>>3;switch(f){case e.WIRE_TYPES.VARINT:do c=b.readUint8();while(128===(c&128));break;case e.WIRE_TYPES.BITS64:b.offset+=8;break;case e.WIRE_TYPES.LDELIM:c=b.readVarint32();b.offset+=c;break;case e.WIRE_TYPES.STARTGROUP:d(c,b);break;case e.WIRE_TYPES.ENDGROUP:if(c===a)return!1;throw Error("Illegal GROUPEND after unknown group: "+c+" ("+a+" expected)");case e.WIRE_TYPES.BITS32:b.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+a+": "+f);}return!0} -function g(a,b){if(a&&"number"===typeof a.low&&"number"===typeof a.high&&"boolean"===typeof a.unsigned&&a.low===a.low&&a.high===a.high)return new e.Long(a.low,a.high,"undefined"===typeof b?a.unsigned:b);if("string"===typeof a)return e.Long.fromString(a,b||!1,10);if("number"===typeof a)return e.Long.fromNumber(a,b||!1);throw Error("not convertible to Long");}var k={},n=function(a,b,c){this.builder=a;this.parent=b;this.name=c},b=n.prototype;b.fqn=function(){var a=this.name,b=this;do{b=b.parent;if(null== -b)break;a=b.name+"."+a}while(1);return a};b.toString=function(a){return(a?this.className+" ":"")+this.fqn()};b.build=function(){throw Error(this.toString(!0)+" cannot be built directly");};k.T=n;var f=function(a,b,c,e){n.call(this,a,b,c);this.className="Namespace";this.children=[];this.options=e||{}},b=f.prototype=Object.create(n.prototype);b.getChildren=function(a){a=a||null;if(null==a)return this.children.slice();for(var b=[],c=0,e=this.children.length;ca.remaining())return null;var l=a.offset,e=a.readVarint32();if(a.remaining()>3;if(p===e.WIRE_TYPES.ENDGROUP){if(k!==c)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+k+" ("+(c?c+" expected":"not a group")+")");break}if(h=this._fieldsById[k])h.repeated&&!h.options.packed?g[h.name].push(h.decode(p,a)):(g[h.name]=h.decode(p,a),h.oneof&&(null!== -this[h.oneof.name]&&(this[this[h.oneof.name]]=null),g[h.oneof.name]=h.name));else switch(p){case e.WIRE_TYPES.VARINT:a.readVarint32();break;case e.WIRE_TYPES.BITS32:a.offset+=4;break;case e.WIRE_TYPES.BITS64:a.offset+=8;break;case e.WIRE_TYPES.LDELIM:h=a.readVarint32();a.offset+=h;break;case e.WIRE_TYPES.STARTGROUP:for(;d(k,a););break;default:throw Error("Illegal wire type for unknown field "+k+" in "+this.toString(!0)+"#decode: "+p);}}a=0;for(b=this._fields.length;aa?a>>>0:a;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return g(a,!1)}catch(f){c(typeof a,f.message)}else c(typeof a,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return g(a,!0)}catch(h){c(typeof a,h.message)}else c(typeof a,"requires Long.js");case e.TYPES.bool:return"boolean"!==typeof a&&c(typeof a,"not a boolean"),a;case e.TYPES["float"]:case e.TYPES["double"]:return"number"!==typeof a&&c(typeof a, -"not a number"),a;case e.TYPES.string:return"string"===typeof a||a&&a instanceof String||c(typeof a,"not a string"),""+a;case e.TYPES.bytes:return a&&a instanceof m?a:m.wrap(a);case e.TYPES["enum"]:var k=this.resolvedType.getChildren(p.Value);for(d=0;da?b.writeVarint64(a):b.writeVarint32(a);break;case e.TYPES.uint32:b.writeVarint32(a);break;case e.TYPES.sint32:b.writeVarint32ZigZag(a);break;case e.TYPES.fixed32:b.writeUint32(a);break;case e.TYPES.sfixed32:b.writeInt32(a);break;case e.TYPES.int64:case e.TYPES.uint64:b.writeVarint64(a);break;case e.TYPES.sint64:b.writeVarint64ZigZag(a);break;case e.TYPES.fixed64:b.writeUint64(a);break;case e.TYPES.sfixed64:b.writeInt64(a); -break;case e.TYPES.bool:"string"===typeof a?b.writeVarint32("false"===a.toLowerCase()?0:!!a):b.writeVarint32(a?1:0);break;case e.TYPES["enum"]:b.writeVarint32(a);break;case e.TYPES["float"]:b.writeFloat32(a);break;case e.TYPES["double"]:b.writeFloat64(a);break;case e.TYPES.string:b.writeVString(a);break;case e.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");var c=a.offset;b.writeVarint32(a.remaining());b.append(a);a.offset=c; -break;case e.TYPES.message:c=(new m).LE();this.resolvedType.encode(a,c);b.writeVarint32(c.offset);b.append(c.flip());break;case e.TYPES.group:this.resolvedType.encode(a,b);b.writeVarint32(this.id<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");}return b};c.calculate=function(a){a=this.verifyValue(a);if(null===this.type||"object"!==typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+ -": "+this.type);if(null===a||this.repeated&&0==a.length)return 0;var b=0;try{if(this.repeated){var c,d;if(this.options.packed&&0<=e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){b+=m.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM);for(c=d=0;ca?m.calculateVarint64(a):m.calculateVarint32(a);case e.TYPES.uint32:return m.calculateVarint32(a);case e.TYPES.sint32:return m.calculateVarint32(m.zigZagEncode32(a));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES["float"]:return 4;case e.TYPES.int64:case e.TYPES.uint64:return m.calculateVarint64(a);case e.TYPES.sint64:return m.calculateVarint64(m.zigZagEncode64(a)); -case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES["enum"]:return m.calculateVarint32(a);case e.TYPES["double"]:return 8;case e.TYPES.string:return a=m.calculateUTF8Bytes(a),m.calculateVarint32(a)+a;case e.TYPES.bytes:if(0>a.remaining())throw Error("Illegal value for "+this.toString(!0)+": "+a.remaining()+" bytes remaining");return m.calculateVarint32(a.remaining())+a.remaining();case e.TYPES.message:return a=this.resolvedType.calculate(a),m.calculateVarint32(a)+ -a;case e.TYPES.group:return a=this.resolvedType.calculate(a),a+m.calculateVarint32(this.id<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+a+" (unknown type)");};c.decode=function(a,b,c){if(a!=this.type.wireType&&(c||a!=e.WIRE_TYPES.LDELIM||!this.repeated))throw Error("Illegal wire type for field "+this.toString(!0)+": "+a+" ("+this.type.wireType+" expected)");if(a==e.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&& -!c){a=b.readVarint32();a=b.offset+a;for(c=[];b.offset>>0;case e.TYPES.sint32:return b.readVarint32ZigZag()|0;case e.TYPES.fixed32:return b.readUint32()>>>0;case e.TYPES.sfixed32:return b.readInt32()|0;case e.TYPES.int64:return b.readVarint64();case e.TYPES.uint64:return b.readVarint64().toUnsigned();case e.TYPES.sint64:return b.readVarint64ZigZag(); -case e.TYPES.fixed64:return b.readUint64();case e.TYPES.sfixed64:return b.readInt64();case e.TYPES.bool:return!!b.readVarint32();case e.TYPES["enum"]:return b.readVarint32();case e.TYPES["float"]:return b.readFloat();case e.TYPES["double"]:return b.readDouble();case e.TYPES.string:return b.readVString();case e.TYPES.bytes:a=b.readVarint32();if(b.remaining()e.ID_MAX&&(c.extensions[1]=e.ID_MAX));this.ptr.addChild(c);0c.extensions[1])throw Error("Illegal extended field id in message "+c.name+": "+a.fields[h].id+" ("+c.extensions.join(" to ")+ -" expected)");n=a.fields[h].name;this.options.convertFieldsToCamelCase&&(n=g.Message.Field._toCamelCase(a.fields[h].name));p=new g.Message.ExtensionField(this,c,a.fields[h].rule,a.fields[h].type,this.ptr.fqn()+"."+n,a.fields[h].id,a.fields[h].options);n=new g.Extension(this,this.ptr,a.fields[h].name,p);p.extension=n;this.ptr.addChild(n);c.addChild(p)}else{if(!/\.?google\.protobuf\./.test(a.ref))throw Error("Extended message "+a.ref+" is not defined");}else throw Error("Not a valid definition: "+JSON.stringify(a)); -}else throw Error("Not a valid namespace: "+JSON.stringify(b));this.ptr=this.ptr.parent}this.resolved=!1;this.result=null;return this};n["import"]=function(b,d){if("string"===typeof d){e.Util.IS_NODE&&(d=require("path").resolve(d));if(!0===this.files[d])return this.reset(),this;this.files[d]=!0}if(b.imports&&0 Date: Wed, 10 Dec 2014 18:25:21 +0800 Subject: [PATCH 1058/1564] Fixed #2416: fixed a bug of cc.SpriteBatchNode on Canvas Mode --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 2 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index b1235d3b7c..36e0a6bb30 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -483,7 +483,7 @@ cc.Node.RenderCmd.prototype = { if (this._cacheDirty === false) { this._cacheDirty = true; var cachedP = this._cachedParent; - cachedP && cachedP != this && cachedP._setNodeDirtyForCache(); + cachedP && cachedP != this && cachedP._setNodeDirtyForCache && cachedP._setNodeDirtyForCache(); } }; diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 9f72438920..62d831f8ab 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -162,7 +162,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ }, _setNodeDirtyForCache: function () { - this._cacheDirty = true; + if(this._renderCmd && this._renderCmd._setNodeDirtyForCache) + this._renderCmd._setNodeDirtyForCache(); }, /** From adc5958682c3b8cd43ab7863835f238948c162c1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 10 Dec 2014 20:54:38 +0800 Subject: [PATCH 1059/1564] Fixed audio web audio error --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index a0bf2f8a71..8d07b6df1a 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -700,7 +700,7 @@ cc.Audio = cc.Class.extend({ audio = effectList[i]; audio.setVolume(this._effectVolume); audio.play(0, loop); - }else if(SWA && i > this._maxAudioInstance){ + }else if(!SWA && i > this._maxAudioInstance){ cc.log("Error: %s greater than %d", url, this._maxAudioInstance); }else{ var audio = loader.cache[url]; From cb3e06a1e020bbf56331793145532cec1f550b04 Mon Sep 17 00:00:00 2001 From: sxd1140 Date: Thu, 11 Dec 2014 01:48:42 +0800 Subject: [PATCH 1060/1564] add stopActionByName() --- extensions/cocostudio/action/CCActionManager.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index b990197870..88d2bbe626 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -81,6 +81,17 @@ ccs.actionManager = /** @lends ccs.actionManager# */{ if (action) action.play(fun); }, + + /** + * Stop an Action with a name. + * @param {String} jsonName + * @param {String} actionName + */ + stopActionByName: function (jsonName, actionName) { + var action = this.getActionByName(jsonName, actionName); + if (action) + action.stop(); + }, /** * Release all actions. @@ -95,4 +106,4 @@ ccs.actionManager = /** @lends ccs.actionManager# */{ clear: function() { this._actionDic = {}; } -}; \ No newline at end of file +}; From 61c353e3c5331ceabcc4a52ef9ffa19f75639dba Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 11 Dec 2014 11:30:58 +0800 Subject: [PATCH 1061/1564] Update the authors for V3.2 rc0 --- AUTHORS.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 208e7edf3e..537ad3deb9 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -169,12 +169,13 @@ Asano @LaercioAsano cc.Node bug fix Bruno Assarisse @bassarisse cc.LabelBMFont bug fix -musikov @musikov cc.ClippingNode bug fix +Mykyta Usikov @musikov cc.ClippingNode bug fix cc.fontLoader bug fix Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode JumpTo bug with wrong _delta position bug fix - cc.ProgressTimer bug fix - cc.Scale9Sprite bug fix + cc.ProgressTimer bugs fix + cc.Scale9Sprite bugs fix + cc.RenderTexture bug fix Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix @@ -216,6 +217,12 @@ nopakos @nopakos cc.Texture2D bug fix Robert Rouhani @Robmaister cc.TMXMapInfo bug fix cc.TMXLayer bug fix +Igor Mats @IgorMats cc.Scale9Sprite bug fix + +Tim @duhaibo0404 ccs.csLoader bug fix + +Hermanto @man2 cc.loader bug fix + Retired Core Developers: Shengxiang Chen (Nero Chan) Xingsen Ma From 52281b4852527f3bd221062a55fba10d7e823c0d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 11 Dec 2014 11:51:53 +0800 Subject: [PATCH 1062/1564] Update the build.xml, and create inspection tools --- cocos2d/core/platform/CCConfig.js | 2 +- cocos2d/tilemap/CCTileMapAtlas.js | 308 ------------------------------ tools/XmlCheck.js | 130 +++++++++++++ tools/build.xml | 69 ++++++- 4 files changed, 193 insertions(+), 316 deletions(-) delete mode 100644 cocos2d/tilemap/CCTileMapAtlas.js create mode 100644 tools/XmlCheck.js diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index d9c4aefd81..a2847ca9a3 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.1"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.2 RC0"; /** *

    diff --git a/cocos2d/tilemap/CCTileMapAtlas.js b/cocos2d/tilemap/CCTileMapAtlas.js deleted file mode 100644 index 40d4f562e1..0000000000 --- a/cocos2d/tilemap/CCTileMapAtlas.js +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -/** - *

    cc.TileMapAtlas is a subclass of cc.AtlasNode.

    - * - *

    It knows how to render a map based of tiles.
    - * The tiles must be in a .PNG format while the map must be a .TGA file.

    - * - *

    For more information regarding the format, please see this post:
    - * http://www.cocos2d-iphone.org/archives/27

    - * - *

    All features from cc.AtlasNode are valid in cc.TileMapAtlas

    - * - *

    IMPORTANT:
    - * This class is deprecated. It is maintained for compatibility reasons only.
    - * You SHOULD not use this class.
    - * Instead, use the newer TMX file format: cc.TMXTiledMap

    - * @class - * @extends cc.AtlasNode - * - * @property {cc.ImageTGA} tgaInfo - TGA Info - */ -cc.TileMapAtlas = cc.AtlasNode.extend(/** @lends cc.TileMapAtlas# */{ - tgaInfo:null, - - indices:null, - //numbers of tiles to render - _itemsToRender:0, - //x,y to altas dictionary - _posToAtlasIndex:null, - _className:"TileMapAtlas", - - /** - *

    Creates a cc.TileMap with a tile file (atlas) with a map file and the width and height of each tile in points.
    - * The tile file will be loaded using the TextureMgr.
    - * Constructor of cc.TileMapAtlas - *

    - * - * @param {String} tile - * @param {String} mapFile - * @param {Number} tileWidth - * @param {Number} tileHeight - * @example - * //example - * var tmpAtlas = new cc.TileMapAtlas("hello.png", "hello.tga", 16, 16); - */ - ctor:function(tile, mapFile, tileWidth, tileHeight){ - cc.AtlasNode.prototype.ctor.call(this); - if(tileHeight !== undefined) - this.initWithTileFile(tile, mapFile, tileWidth, tileHeight); - }, - - /** - * @return {cc.ImageTGA} - */ - getTGAInfo:function () { - return this.tgaInfo; - }, - - /** - * @param {cc.ImageTGA} Var - */ - setTGAInfo:function (Var) { - this.tgaInfo = Var; - }, - - /** - * Initializes a cc.TileMap with a tile file (atlas) with a map file and the width and height of each tile in points.
    - * The file will be loaded using the TextureMgr. - * @param {String} tile - * @param {String} mapFile - * @param {Number} tileWidth - * @param {Number} tileHeight - * @return {Boolean} - * @example - * //example - * var tmpAtlas = new cc.TileMapAtlas(); - * tmpAtlas.initWithTileFile("hello.png", "hello.tga", 16, 16); - */ - initWithTileFile:function (tile, mapFile, tileWidth, tileHeight) { - this._calculateItemsToRender(); - if (cc.AtlasNode.prototype.initWithTileFile.call(this, tile, tileWidth, tileHeight, this._itemsToRender)) { - this._color = cc.color.WHITE; - this._posToAtlasIndex = {}; - this._updateAtlasValues(); - this.width = this.tgaInfo.width * this._itemWidth; - this.height = this.tgaInfo.height * this._itemHeight; - return true; - } - return false; - }, - - /** - *

    Returns a tile from position x,y.
    - * For the moment only channel R is used.

    - * @param {cc.Point} position - * @return {cc.Color} - */ - getTileAt:function (position) { - if(!this.tgaInfo){ - cc.log("cc.TileMapAtlas.getTileAt(): tgaInfo must not be null"); - return null; - } - if(position.x >= this.tgaInfo.width || position.y >= this.tgaInfo.height) - throw "cc.TileMapAtlas.getTileAt(): Invalid position"; - - var colorPos = 0|(position.x * 3 + position.y * this.tgaInfo.width * 3); - var locTGAImageData = this.tgaInfo.imageData; - return cc.color(locTGAImageData[colorPos], locTGAImageData[colorPos + 1], locTGAImageData[colorPos + 2]); - }, - - /** - * Sets a tile at position x,y. - * For the moment only channel R is used - * @param {cc.Color} tile - * @param {cc.Point} position - */ - setTile:function (tile, position) { - if(!this.tgaInfo){ - cc.log("cc.TileMapAtlas.setTile(): tgaInfo must not be null"); - return; - } - if(!this._posToAtlasIndex){ - cc.log("cc.TileMapAtlas.setTile(): posToAtlasIndex must not be null"); - return; - } - if(position.x >= this.tgaInfo.width || position.y >= this.tgaInfo.height) - throw "cc.TileMapAtlas.setTile(): Invalid position"; - if(!tile || tile.r == 0) - throw "cc.TileMapAtlas.setTile(): tile should be non-null and tile.r should be non-nil"; - - var colorPos = 0 | (position.x * 3 + position.y * this.tgaInfo.width * 3); - if (this.tgaInfo.imageData[colorPos] == 0) - cc.log("cocos2d: Value.r must be non 0."); - else { - this.tgaInfo.imageData[colorPos] = tile.r; - this.tgaInfo.imageData[colorPos + 1] = tile.g; - this.tgaInfo.imageData[colorPos + 2] = tile.b; - - var num = this._posToAtlasIndex[position.x + "_" + position.y]; - this._updateAtlasValueAt(position, tile, num); - } - }, - - /** - * Dealloc the map from memory - */ - releaseMap:function () { - if (this.tgaInfo) { - cc.tgaDestroy(this.tgaInfo); - } - this.tgaInfo = null; - }, - - _calculateItemsToRender:function () { - if(!this.tgaInfo){ - cc.log("cc.TileMapAtlas._calculateItemsToRender(): tgaInfo must not be null"); - return; - } - - this._itemsToRender = 0; - var locWidth = this.tgaInfo.width, locHeight = this.tgaInfo.height, locImageData = this.tgaInfo.imageData; - for (var x = 0; x < locWidth; x++) { - for (var y = 0; y < locHeight; y++) { - if (locImageData[x * 3 + y * locWidth * 3]) - ++this._itemsToRender; - } - } - }, - - /** - * @param {cc.Point|cc.GridSize} pos - * @param {cc.Color} value - * @param {Number} index - * @private - */ - _updateAtlasValueAt:function (pos, value, index) { - var locTextureAtlas = this.textureAtlas; - if(index < 0 && index >= locTextureAtlas.getCapacity()) - throw "cc.TileMapAtlas._updateAtlasValueAt(): Invalid index"; - var quad = locTextureAtlas.quads[index]; - - var x = pos.x; - var y = pos.y; - var row = (value.r % this._itemsPerRow); - var col = (value.r / this._itemsPerRow); - - var tex = locTextureAtlas.texture, textureWide = tex.pixelsWidth, textureHigh = tex.pixelsHeight; - - var locItemWidth = this._itemWidth; - var locItemHeight = this._itemHeight; - var itemWidthInPixels = locItemWidth * cc.contentScaleFactor(); - var itemHeightInPixels = locItemHeight * cc.contentScaleFactor(); - - var left, right, top, bottom; - if (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL) { - left = (2 * row * itemWidthInPixels + 1) / (2 * textureWide); - right = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide); - top = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh); - bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh); - } else { - left = (row * itemWidthInPixels) / textureWide; - right = left + itemWidthInPixels / textureWide; - top = (col * itemHeightInPixels) / textureHigh; - bottom = top + itemHeightInPixels / textureHigh; - } - - quad.tl.texCoords.u = left; - quad.tl.texCoords.v = top; - quad.tr.texCoords.u = right; - quad.tr.texCoords.v = top; - quad.bl.texCoords.u = left; - quad.bl.texCoords.v = bottom; - quad.br.texCoords.u = right; - quad.br.texCoords.v = bottom; - - quad.bl.vertices.x = (x * locItemWidth); - quad.bl.vertices.y = (y * locItemHeight); - quad.bl.vertices.z = 0.0; - quad.br.vertices.x = (x * locItemWidth + locItemWidth); - quad.br.vertices.y = (y * locItemHeight); - quad.br.vertices.z = 0.0; - quad.tl.vertices.x = (x * locItemWidth); - quad.tl.vertices.y = (y * locItemHeight + locItemHeight); - quad.tl.vertices.z = 0.0; - quad.tr.vertices.x = (x * locItemWidth + locItemWidth); - quad.tr.vertices.y = (y * locItemHeight + locItemHeight); - quad.tr.vertices.z = 0.0; - - var locColor = this._displayedColor; - var color = {r: locColor.r, g: locColor.g, b: locColor.b, a: this._displayedOpacity}; - quad.tr.colors = color; - quad.tl.colors = color; - quad.br.colors = color; - quad.bl.colors = color; - - locTextureAtlas.dirty = true; - var totalQuads = locTextureAtlas.totalQuads; - if (index + 1 > totalQuads) - locTextureAtlas.increaseTotalQuadsWith(index + 1 - totalQuads); - }, - - _updateAtlasValues:function () { - if(!this.tgaInfo){ - cc.log("cc.TileMapAtlas._updateAtlasValues(): tgaInfo must not be null"); - return; - } - - var total = 0; - var locTGAInfo = this.tgaInfo; - var locTGAInfoWidth = locTGAInfo.width, locTGAInfoHeight = locTGAInfo.height, locItemsToRender = this._itemsToRender; - for (var x = 0; x < locTGAInfoWidth; x++) { - for (var y = 0; y < locTGAInfoHeight; y++) { - if (total < locItemsToRender) { - var colorPos = x * 3 + y * locTGAInfoWidth * 3; - var value = cc.color(locTGAInfo.imageData[colorPos], locTGAInfo.imageData[colorPos + 1], locTGAInfo.imageData[colorPos + 2]); - if (value.r != 0) { - this._updateAtlasValueAt(cc.p(x, y), value, total); - this._posToAtlasIndex[x + "_" + y] = total; - total++; - } - } - } - } - } -}); - -/** - *

    Creates a cc.TileMap with a tile file (atlas) with a map file and the width and height of each tile in points.
    - * The tile file will be loaded using the TextureMgr.

    - * @deprecated since v3.0 please use new cc.TileMapAtlas(tile, mapFile, tileWidth, tileHeight) instead. - * @param {String} tile - * @param {String} mapFile - * @param {Number} tileWidth - * @param {Number} tileHeight - * @return {cc.TileMapAtlas} - * @example - * //example - * var tmpAtlas = new cc.TileMapAtlas(); - * tmpAtlas.initWithTileFile("hello.png", "hello.tga", 16, 16); - */ -cc.TileMapAtlas.create = function (tile, mapFile, tileWidth, tileHeight) { - return new cc.TileMapAtlas(tile, mapFile, tileWidth, tileHeight); -}; diff --git a/tools/XmlCheck.js b/tools/XmlCheck.js new file mode 100644 index 0000000000..62f383d0a5 --- /dev/null +++ b/tools/XmlCheck.js @@ -0,0 +1,130 @@ +const fs = require("fs"); +const path = require("path"); +const modules = JSON.parse(fs.readFileSync("../moduleConfig.json")); + +var contains = [ + "../cocos2d", + "../extensions", + "../external", + "../Base64Images.js", + "../CCBoot.js", + "../CCDebugger.js" +]; +(function(){ + var i = 0; + function read(name){ + if(fs.existsSync(name)){ + var stat = fs.statSync(name); + if(stat.isDirectory()){ + contains.splice(i--, 1); + var fileList = fs.readdirSync(name); + for(var n=0; n((.|\r\n|\r|\n)*?)\<\/sources/g, function(a, b){ + a.replace(/file name\=\"(.*)\"\/\>/g, function(c, d){ + arr[index] && arr[index].push("../" + d); + }); + index++; + }); +})(); +console.log(" The number of files in the XML file : %s", xmlFile.length); + +console.log("\x1B[0m\x1B[33m"); +console.log(" warn : moduleConfig missing..."); +contains.forEach(function(a){ + if(!moduleFile.some(function(b){return b==a})) + console.log(" " + a); +}); + + +console.log("\x1B[0m\x1B[92m"); +console.log(" warn : engine dir missing..."); +moduleFile.forEach(function(a){ + if(!contains.some(function(b){return b==a})) + console.log(" " + a); +}); + + +console.log("\x1B[0m\x1B[96m"); +console.log(" warn : xml(all) file missing..."); +contains.forEach(function(a){ + if(!xmlFile.some(function(b){return b==a})) + console.log(" " + a); +}); + + +console.log("\x1B[0m\x1B[91m"); +console.log(" warn : xml(all) redundant files..."); +xmlFile.forEach(function(a){ + if(!contains.some(function(b){return b==a})) + console.log(" " + a); +}); + + +console.log("\x1B[0m\x1B[94m"); +console.log(" warn : xml(core) maybe missing files..."); +xmlFile2.forEach(function(a){ + var basename = path.basename(a); + basename = basename.substr(0, basename.indexOf(".")); + contains.forEach(function(b){ + if(b.indexOf(basename) > -1 && a != b){ + if( + b.indexOf("extensions") == -1 && + !xmlFile2.some(function(c){return b == c;}) + ) + console.log(" " + b); + } + }); +}); + + +console.log("\x1B[0m\x1B[35m"); +console.log(" warn : xml(core) redundant files..."); +xmlFile2.forEach(function(a){ + if(!contains.some(function(b){return b==a})) + console.log(" " + a); +}); +console.log("\x1B[0m"); \ No newline at end of file diff --git a/tools/build.xml b/tools/build.xml index fd39a423f2..0b37149aa6 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.2-RC0-min.js"> @@ -43,8 +43,14 @@ + + + + + + @@ -52,17 +58,21 @@ - - + + + + + + @@ -72,6 +82,8 @@ + + @@ -90,12 +102,24 @@ + + + + + + + + + + + + @@ -110,6 +134,8 @@ + + @@ -121,8 +147,12 @@ + + + + @@ -132,13 +162,18 @@ + + + + + @@ -148,6 +183,8 @@ + + @@ -166,7 +203,11 @@ + + + + @@ -186,7 +227,6 @@ - @@ -203,11 +243,15 @@ + + + + @@ -221,7 +265,7 @@ - + @@ -245,17 +289,25 @@ + + + + + + + + + debug="false" output="./../lib/cocos2d-js-v3.2-RC0-core-min.js"> @@ -279,6 +331,7 @@ + @@ -288,10 +341,11 @@ - + + @@ -300,6 +354,7 @@ + @@ -307,7 +307,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.2-core-min.js"> From 7be2e36eb01f117b89a200e1c8d8a00ee6afc18a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 29 Dec 2014 17:08:51 +0800 Subject: [PATCH 1124/1564] new studio loader --- extensions/cocostudio/reader/loader/load.js | 127 +++ .../loader/parsers/timelineParser-1.x.js | 256 ++++++ .../loader/parsers/timelineParser-2.x.js | 278 ++++++ .../reader/loader/parsers/uiParser-1.x.js | 800 ++++++++++++++++++ moduleConfig.json | 9 +- 5 files changed, 1469 insertions(+), 1 deletion(-) create mode 100644 extensions/cocostudio/reader/loader/load.js create mode 100644 extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js create mode 100644 extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js create mode 100644 extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js diff --git a/extensions/cocostudio/reader/loader/load.js b/extensions/cocostudio/reader/loader/load.js new file mode 100644 index 0000000000..fbfb126792 --- /dev/null +++ b/extensions/cocostudio/reader/loader/load.js @@ -0,0 +1,127 @@ +ccs.loadNode = (function(){ + + var load = function(file){ + + var json = cc.loader.getRes(file); + + if(!json) + return cc.log("%s is not exists", file); + var ext = extname(file).toLocaleLowerCase(); + if(ext !== "json" && ext !== "exportjson") + return cc.log("%s load error, must be json file", file); + + // Judging the parser (uiParse or timelineParse, Temporarily blank) + // The judgment condition is unknown + var parse; + if(json["widgetTree"]) + parse = parser["ccui"]; + else if(json["nodeTree"]) + parse = parser["timeline"]; + else if(json["Content"]) + parse = parser["timeline"]; + + if(!parse){ + cc.log("Can't find the parser : %s", file); + return new cc.Node(); + } + var version = json["version"] || json["Version"]; + var currentParser = getParser(parse, version); + if(!currentParser){ + cc.log("Can't find the parser : %s", file); + return new cc.Node(); + } + + return currentParser.parse(file, json) || new cc.Node(); + }; + + var parser = { + "ccui": {}, + "timeline": {} + }; + + load.registerParser = function(name, version, target){ + if(!name || !version || !target) + return cc.log("register parser error"); + if(!parser[name]) + parser[name] = {}; + parser[name][version] = target; + }; + + load.getParser = function(name, version){ + if(name && version) + return parser[name] ? parser[name][version] : undefined; + if(name) + return parser[name]; + return parser; + }; + + //Gets the file extension + var extname = function(fileName){ + var arr = fileName.match(extnameReg); + return ( arr && arr[1] ) ? arr[1] : null; + }; + var extnameReg = /\.([^\.]+)$/; + + + var parserReg = /([^\.](\.\*)?)*$/; + var getParser = function(parser, version){ + if(parser[version]) + return parser[version]; + else if(version === "*") + return null; + else + return getParser(parser, version.replace(parserReg, "*")); + }; + + return load; + +})(); + + +ccs._parser = cc.Class.extend({ + + ctor: function(){ + this.parsers = {}; + }, + + _dirnameReg: /\S*\//, + _dirname: function(path){ + var arr = path.match(this._dirnameReg); + return (arr && arr[0]) ? arr[0] : ""; + }, + + getClass: function(json){ + return json["classname"]; + }, + + getNodeJson: function(json){ + return json["widgetTree"]; + }, + + parse: function(file, json){ + var resourcePath = this._dirname(file); + this.pretreatment(json, resourcePath); + var node = this.parseNode(this.getNodeJson(json), resourcePath); + this.deferred(json, resourcePath, node, file); + return node; + }, + + pretreatment: function(json, resourcePath, file){}, + + deferred: function(json, resourcePath, node, file){}, + + parseNode: function(json, resourcePath){ + var parser = this.parsers[this.getClass(json)]; + var widget = null; + if(parser) + widget = parser.call(this, json, this.parseNode, resourcePath); + else + cc.log("Can't find the parser : %s", this.getClass(json)); + + return widget; + }, + + registerParser: function(widget, parse){ + this.parsers[widget] = parse; + } +}); diff --git a/extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js new file mode 100644 index 0000000000..7da3666f2a --- /dev/null +++ b/extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js @@ -0,0 +1,256 @@ +(function(load, baseParser){ + + var Parser = baseParser.extend({ + + getNodeJson: function(json){ + return json["nodeTree"]; + }, + + addSpriteFrame: function(textures, plists, resourcePath){ + if(!textures) return; + for (var i = 0; i < textures.length; i++) { + cc.spriteFrameCache.addSpriteFrames( + resourcePath + textures[i], + resourcePath + plists[i] + ); + } + }, + + pretreatment: function(json, resourcePath, file){ + this.addSpriteFrame(json["textures"], json["texturesPng"], resourcePath); + ccs.actionTimelineCache.loadAnimationActionWithContent(file, json); + } + + }); + var parser = new Parser(); + + parser.generalAttributes = function(node, options){ + var width = options[ccui.CSLoaderStatic.WIDTH] !=null ? options[ccui.CSLoaderStatic.WIDTH] : 0; + var height = options[ccui.CSLoaderStatic.HEIGHT] !=null ? options[ccui.CSLoaderStatic.HEIGHT] : 0; + var x = options[ccui.CSLoaderStatic.X] !=null ? options[ccui.CSLoaderStatic.X] : 0; + var y = options[ccui.CSLoaderStatic.Y] !=null ? options[ccui.CSLoaderStatic.Y] : 0; + var scalex = options[ccui.CSLoaderStatic.SCALE_X] !=null ? options[ccui.CSLoaderStatic.SCALE_X] : 1; + var scaley = options[ccui.CSLoaderStatic.SCALE_Y] !=null ? options[ccui.CSLoaderStatic.SCALE_Y] : 1; + var rotation = options[ccui.CSLoaderStatic.ROTATION] !=null ? options[ccui.CSLoaderStatic.ROTATION] : 0; + var rotationSkewX = options[ccui.CSLoaderStatic.ROTATION_SKEW_X]!=null ? options[ccui.CSLoaderStatic.ROTATION_SKEW_X] : 0; + var rotationSkewY = options[ccui.CSLoaderStatic.ROTATION_SKEW_Y]!=null ? options[ccui.CSLoaderStatic.ROTATION_SKEW_Y] : 0; + var skewx = options[ccui.CSLoaderStatic.SKEW_X] !=null ? options[ccui.CSLoaderStatic.SKEW_X] : 0; + var skewy = options[ccui.CSLoaderStatic.SKEW_Y] !=null ? options[ccui.CSLoaderStatic.SKEW_Y] : 0; + var anchorx = options[ccui.CSLoaderStatic.ANCHOR_X] !=null ? options[ccui.CSLoaderStatic.ANCHOR_X] : 0.5; + var anchory = options[ccui.CSLoaderStatic.ANCHOR_Y] !=null ? options[ccui.CSLoaderStatic.ANCHOR_Y] : 0.5; + var alpha = options[ccui.CSLoaderStatic.ALPHA] !=null ? options[ccui.CSLoaderStatic.ALPHA] : 255; + var red = options[ccui.CSLoaderStatic.RED] !=null ? options[ccui.CSLoaderStatic.RED] : 255; + var green = options[ccui.CSLoaderStatic.GREEN] !=null ? options[ccui.CSLoaderStatic.GREEN] : 255; + var blue = options[ccui.CSLoaderStatic.BLUE] !=null ? options[ccui.CSLoaderStatic.BLUE] : 255; + var zorder = options[ccui.CSLoaderStatic.ZORDER] !=null ? options[ccui.CSLoaderStatic.ZORDER] : 0; + var tag = options[ccui.CSLoaderStatic.TAG] !=null ? options[ccui.CSLoaderStatic.TAG] : 0; + var actionTag = options[ccui.CSLoaderStatic.ACTION_TAG] !=null ? options[ccui.CSLoaderStatic.ACTION_TAG] : 0; + var visible = options[ccui.CSLoaderStatic.VISIBLE] !=null ? options[ccui.CSLoaderStatic.VISIBLE] : true; + + if(x != 0 || y != 0) + node.setPosition(cc.p(x, y)); + if(scalex != 1) + node.setScaleX(scalex); + if(scaley != 1) + node.setScaleY(scaley); + if (rotation != 0) + node.setRotation(rotation); + if(rotationSkewX != 0) + node.setRotationX(rotationSkewX); + if(rotationSkewY != 0) + node.setRotationY(rotationSkewY); + if(skewx != 0) + node.setSkewX(skewx); + if(skewy != 0) + node.setSkewY(skewy); + if(anchorx != 0.5 || anchory != 0.5) + node.setAnchorPoint(cc.p(anchorx, anchory)); + if(width != 0 || height != 0) + node.setContentSize(cc.size(width, height)); + if(zorder != 0) + node.setLocalZOrder(zorder); + if(visible != true) + node.setVisible(visible); + + if(alpha != 255) + { + node.setOpacity(alpha); + } + if(red != 255 || green != 255 || blue != 255) + { + node.setColor(cc.color(red, green, blue)); + } + + + node.setTag(tag); + node.setUserObject(new ccs.ActionTimelineData(actionTag)); + }; + + parser.parseComponent = function(node, options){ + if(!options) return; + for (var i = 0; i < options.length; ++i){ + var dic = options[i]; + var component = this.loadComponent(dic); + if (component){ + node.addComponent(component); + } + } + }; + + parser.parseChild = function(parse, widget, options, resourcePath){ + var children = options["children"]; + for (var i = 0; i < children.length; i++) { + var child = this.parseNode(children[i], resourcePath); + if(child){ + if(widget instanceof ccui.PageView){ + if(child instanceof ccui.Layout) + widget.addPage(child); + } else { + if(widget instanceof ccui.ListView){ + if(child instanceof ccui.Widget) + widget.pushBackCustomItem(child); + } else { + if(!(widget instanceof ccui.Layout) && child instanceof ccui.Widget) { + if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { + var position = child.getPositionPercent(); + var anchor = widget.getAnchorPoint(); + child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); + } + var AnchorPointIn = widget.getAnchorPointInPoints(); + child.setPosition(cc.p(child.getPositionX() + AnchorPointIn.x, child.getPositionY() + AnchorPointIn.y)); + } + widget.addChild(child); + } + } + } + } + }; + + parser.initNode = function(options){ + var node = new cc.Node(); + this.generalAttributes(node, options); + return node; + }; + parser.initSubGraph = function(options){ + var filePath = options["fileName"]; + + var node; + if (filePath && "" != filePath){ + node = this.createNode(filePath); + }else{ + node = new ccs.Node(); + } + this.generalAttributes(node, options); + return node; + }; + parser.initSprite = function(options, resourcePath){ + var path = options["fileName"]; + var sprite; + if(path != null){ + var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); + if(!spriteFrame){ + path = resourcePath + path; + sprite = new ccs.Sprite(path); + }else{ + sprite = ccs.Sprite.createWithSpriteFrame(spriteFrame); + } + + if(!sprite){ + sprite = new cc.Sprite(); + cc.log("filePath is empty. Create a sprite with no texture"); + } + }else{ + sprite = new ccs.Sprite(); + } + this.generalAttributes(sprite, options); + var flipX = options["flipX"]; + var flipY = options["flipY"]; + + if(flipX != false) + sprite.setFlippedX(flipX); + if(flipY != false) + sprite.setFlippedY(flipY); + return sprite; + }; + parser.initParticle = function(options, resourcePath){ + var filePath = options["plistFile"]; + var num = options["tmxFile"]; + var particle = new cc.ParticleSystemQuad(filePath); + particle.setTotalParticles(num); + this.generalAttributes(particle, options); + return particle; + }; + parser.initTMXTiledMap = function(options, resourcePath){ + var tmxFile = options[ccui.CSLoaderStatic.TMX_FILE]; + var tmxString = options[ccui.CSLoaderStatic.TMX_STRING]; + //todo check path and resourcePath + var path = options[ccui.CSLoaderStatic.RESOURCE_PATH]; + + var tmx = null; + if (tmxFile && "" != tmxFile){ + tmx = new cc.TMXTiledMap(tmxFile); + }else if (tmxString && "" != tmxString && path && "" != path){ + tmx = new cc.TMXTiledMap(tmxString, path); + } + return tmx; + }; + var uiParser = load.getParser("ccui")["1.*"]; + parser.initWidget = function(options, resourcePath){ + var node = uiParser.parseNode.call(this, options, resourcePath); + if(node){ + var rotationSkewX = options["rotationSkewX"]; + var rotationSkewY = options["rotationSkewY"]; + var skewx = options["skewX"]; + var skewy = options["skewY"]; + if(rotationSkewX != 0) + node.setRotationX(rotationSkewX); + if(rotationSkewY != 0) + node.setRotationY(rotationSkewY); + if(skewx != 0) + node.setSkewX(skewx); + if(skewy != 0) + node.setSkewY(skewy); + + var actionTag = options[ccui.CSLoaderStatic.ACTION_TAG]; + node.setUserObject(new ccs.ActionTimelineData(actionTag)); + } + return node; + }; + + var register = [ + {name: "Node", handle: parser.initNode}, + {name: "SubGraph", handle: parser.initSubGraph}, + {name: "Sprite", handle: parser.initSprite}, + {name: "Particle", handle: parser.initParticle}, + {name: "TMXTiledMap", handle: parser.initTMXTiledMap}, + + {name: "Widget", handle: parser.initWidget}, + {name: "Panel", handle: parser.initWidget}, + {name: "Button", handle: parser.initWidget}, + {name: "CheckBox", handle: parser.initWidget}, + {name: "ImageView", handle: parser.initWidget}, + {name: "LabelAtlas", handle: parser.initWidget}, + {name: "LabelBMFont", handle: parser.initWidget}, + {name: "Label", handle: parser.initWidget}, + {name: "ListView", handle: parser.initWidget}, + {name: "LoadingBar", handle: parser.initWidget}, + {name: "PageView", handle: parser.initWidget}, + {name: "ScrollView", handle: parser.initWidget}, + {name: "Slider", handle: parser.initWidget}, + {name: "TextField", handle: parser.initWidget} + ]; + + register.forEach(function(item){ + parser.registerParser(item.name, function(options, parse, resourcePath){ + var node = item.handle.call(this, options["options"]); + this.parseComponent(node, options["components"]); + this.parseChild(parse, node, options, resourcePath); + return node; + }); + }); + + + load.registerParser("timeline", "1.*", parser); + + +})(ccs.loadNode, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js new file mode 100644 index 0000000000..38e2e38126 --- /dev/null +++ b/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js @@ -0,0 +1,278 @@ +(function(load, baseParser){ + + var Parser = baseParser.extend({ + + parse: function(file, json){ + var resourcePath = this._dirname(file); + this.pretreatment(json, resourcePath); + var node = this.parseNode(this.getNodeJson(json), resourcePath); + this.deferred(json, resourcePath, node, file); + return node; + }, + + getNodeJson: function(json){ + return json["Content"]["Content"]["ObjectData"]; + }, + + getClass: function(json){ + return json["ctype"]; + }, + + addSpriteFrame: function(textures, plists, resourcePath){ + if(!textures) return; + for (var i = 0; i < textures.length; i++) { + cc.spriteFrameCache.addSpriteFrames( + resourcePath + textures[i], + resourcePath + plists[i] + ); + } + }, + + pretreatment: function(json, resourcePath, file){ + this.addSpriteFrame(json["textures"], json["texturesPng"], resourcePath); + ccs.actionTimelineCache.loadAnimationActionWithContent(file, json); + } + + }); + var parser = new Parser(); + + + ////////// + // NODE // + ////////// + + parser.generalAttributes = function(node, json){ + if(json["Name"] != null) + node.setName(json["Name"]); + + var position = json["Position"]; + if(position != null && (position["X"] != null || position["Y"] != null)) + node.setPosition(cc.p(position["X"]||0, position["Y"]||0)); + + var scale = json["Scale"]; + if(scale != null){ + if(scale["ScaleX"] != null) + node.setScaleX(scale["ScaleX"]); + if(scale["ScaleY"] != null) + node.setScaleY(scale["ScaleY"]); + } + + var rotationSkewX = json["RotationSkewX"]; + if (rotationSkewX != null) + node.setRotationX(rotationSkewX); + //rotationSkewX + var rotationSkewY = json["RotationSkewY"]; + if (json["RotationSkewY"] != null) + node.setRotationY(rotationSkewY); + //rotationSkewY + + //todo check it + var anchor = json["AnchorPoint"]; + if(anchor && (anchor["ScaleX"] || anchor["ScaleY"])) + node.setAnchorPoint(cc.p(anchor["ScaleX"]||0.5, anchor["ScaleY"]||0.5)); + + if (json["ZOrder"] != null) + node.setLocalZOrder(json["ZOrder"]); + + var visible = json["VisibleForFrame"]; + if (visible != null) + node.setVisible(visible == "True"); + + + var contentSize = json["Size"]; + if(contentSize != null && (contentSize["X"] != null || contentSize["Y"] != null)) + node.setContentSize(cc.size(contentSize["X"]||0, contentSize["Y"]||0)); + + if (json["Alpha"] != null) + node.setOpacity(json["Alpha"]); + var color = json["CColor"]; + if(color != null && (color["R"] != null || color["G"] != null || color["B"] != null)) + node.setColor(cc.color(color["R"]||255, color["G"]||255, color["B"]||255)); + + if (json["Tag"] != null) + node.setTag(json["Tag"]); + + if (json["ActionTag"] != null) + node.setUserObject(new ccs.ActionTimelineData(json["ActionTag"])); + + node.setCascadeColorEnabled(true); + node.setCascadeOpacityEnabled(true); + }; + + parser.parseChild = function(node, children, resourcePath){ + if(!children) return; + for (var i = 0; i < children.length; i++) { + var child = this.parseNode(children[i], resourcePath); + if(child){ + if(node instanceof ccui.PageView){ + if(child instanceof ccui.Layout) + node.addPage(child); + } else { + if(node instanceof ccui.ListView){ + if(child instanceof ccui.Widget) + node.pushBackCustomItem(child); + } else { + if(!(node instanceof ccui.Layout) && child instanceof ccui.Widget) { + if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { + var position = child.getPositionPercent(); + var anchor = node.getAnchorPoint(); + child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); + } + var AnchorPointIn = node.getAnchorPointInPoints(); + child.setPosition(cc.p(child.getPositionX() + AnchorPointIn.x, child.getPositionY() + AnchorPointIn.y)); + } + node.addChild(child); + } + } + } + } + }; + + parser.initSingleNode = function(json){ + var node = new cc.Node(); + + this.generalAttributes(node, json); + + return node; + }; + + parser.initSprite = function(json){ + var node = new cc.Sprite(); + + this.generalAttributes(node, json); + + var fileData = json["FileData"]; + if(fileData){ + switch(fileData["Type"]){ + case 1: + var spriteFrame = cc.spriteFrameCache.getSpriteFrameByName(); + if(spriteFrame) + node.setSpriteFrame(spriteFrame); + break; + default: + if(fileData["Path"]) + node.setTexture(fileData["Path"]); + } + + } +// if (!fileExist) +// { +// auto label = Label::create(); +// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString()); +// sprite->addChild(label); +// } + + if(json["FlipX"]) + node.setFlippedX(true); + if(json["FlipY"]) + node.setFlippedY(true); + + return node; + }; + + parser.initParticle = function(json){ + var fileData = json["FileData"]; + var node; + if(fileData){ + node = new cc.ParticleSystemQuad(); + this.generalAttributes(node, json); + } + return node; + }; + + + //////////// + // WIDGET // + //////////// + + parser.widgetAttributes = function(widget, json){ + var name = json["Name"]; + if(name) + widget.setName(name); + + var actionTag = json["ActionTag"]; + if(actionTag){ + widget.setActionTag(actionTag); + widget.setUserObject(new ccs.ActionTimelineData(actionTag)); + } + + var rotationSkewX = json["RotationSkewX"]; + if(rotationSkewX) + widget.setRotationX(rotationSkewX); + + var rotationSkewY = json["RotationSkewY"]; + if(rotationSkewY) + widget.setRotationX(rotationSkewY); + + //var rotation = json["Rotation"]; + + var flipX = json["FlipX"]; + if(flipX) + widget.setFlippedX(true); + + var flipY = json["FlipY"]; + if(flipY) + widget.setFlippedY(true); + + var zOrder = json["zOrder"]; + if(zOrder != null) + widget.setLocalZOrder(zOrder); + + //var visible = json["Visible"]; + + var visible = json["VisibleForFrame"]; + if(visible != null) + widget.setVisible(visible); + + var alpha = json["Alpha"]; + if(alpha != null) + widget.setOpacity(alpha); + + var tag = json["Tag"]; + if(tag != null) + widget.setTag(tag); + + var touchEnabled = json["TouchEnabled"]; + if(touchEnabled != null) + widget.setTouchEnabled(touchEnabled); + + // -- var frameEvent = json["FrameEvent"]; + + var callBackType = json["CallBackType"]; + if(callBackType != nul) + widget.setCallbackType(callBackType); + + var callBackName = json["CallBackName"]; + if(callBackName) + widget.setCallbackName(callBackName); + }; + + parser.initPanel = function(json){ + var widget = new ccui.Layout(); + + + + + return node; + }; + + var register = [ + {name: "SingleNodeObjectData", handle: parser.initSingleNode}, + {name: "SpriteObjectData", handle: parser.initSprite}, + {name: "ParticleObjectData", handle: parser.initParticle}, + {name: "PanelObjectData", handle: parser.initPanel} + ]; + + register.forEach(function(item){ + parser.registerParser(item.name, function(options, parse, resourcePath){ + var node = item.handle.call(this, options); + this.parseChild(node, options["Children"], resourcePath); + return node; + }); + }); + + + load.registerParser("timeline", "2.*", parser); + + +})(ccs.loadNode, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js new file mode 100644 index 0000000000..20628505c2 --- /dev/null +++ b/extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js @@ -0,0 +1,800 @@ +(function(load, baseParser){ + + var Parser = baseParser.extend({ + + addSpriteFrame: function(textures, resourcePath){ + if(!textures) return; + for (var i = 0; i < textures.length; i++) { + cc.spriteFrameCache.addSpriteFrames(resourcePath + textures[i]); + } + }, + + pretreatment: function(json, resourcePath){ + this.addSpriteFrame(json["textures"], resourcePath); + }, + + deferred: function(json, resourcePath, node, file){ + if(node){ + ccs.actionManager.initWithDictionary(file, json["animation"], node); + node.setContentSize(cc.size(json["designWidth"], json["designHeight"])); + } + } + + }); + var parser = new Parser(); + + + parser.generalAttributes = function(widget, options){ + var ignoreSizeExsit = options["ignoreSize"]; + if(ignoreSizeExsit != null) + widget.ignoreContentAdaptWithSize(ignoreSizeExsit); + + widget.setSizeType(options["sizeType"]); + widget.setPositionType(options["positionType"]); + + widget.setSizePercent(cc.p(options["sizePercentX"], options["sizePercentY"])); + widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"])); + + /* adapt screen */ + var w = 0, h = 0; + var adaptScreen = options["adaptScreen"]; + if (adaptScreen) { + var screenSize = cc.director.getWinSize(); + w = screenSize.width; + h = screenSize.height; + } else { + w = options["width"]; + h = options["height"]; + } + widget.setContentSize(w, h); + + widget.setTag(options["tag"]); + widget.setActionTag(options["actiontag"]); + widget.setTouchEnabled(options["touchAble"]); + var name = options["name"]; + var widgetName = name ? name : "default"; + widget.setName(widgetName); + + var x = options["x"]; + var y = options["y"]; + widget.setPosition(x, y); + + var sx = options["scaleX"]!=null ? options["scaleX"] : 1; + widget.setScaleX(sx); + + var sy = options["scaleY"]!=null ? options["scaleY"] : 1; + widget.setScaleY(sy); + + var rt = options["rotation"] || 0; + widget.setRotation(rt); + + var vb = options["visible"] || false; + if(vb != null) + widget.setVisible(vb); + widget.setLocalZOrder(options["ZOrder"]); + + var layout = options["layoutParameter"]; + if(layout != null){ + var layoutParameterDic = options["layoutParameter"]; + var paramType = layoutParameterDic["type"]; + var parameter = null; + + switch(paramType){ + case 0: + break; + case 1: + parameter = new ccui.LinearLayoutParameter(); + var gravity = layoutParameterDic["gravity"]; + parameter.setGravity(gravity); + break; + case 2: + parameter = new ccui.RelativeLayoutParameter(); + var rParameter = parameter; + var relativeName = layoutParameterDic["relativeName"]; + rParameter.setRelativeName(relativeName); + var relativeToName = layoutParameterDic["relativeToName"]; + rParameter.setRelativeToWidgetName(relativeToName); + var align = layoutParameterDic["align"]; + rParameter.setAlign(align); + break; + default: + break; + } + if(parameter != null){ + var mgl = layoutParameterDic["marginLeft"]||0; + var mgt = layoutParameterDic["marginTop"]||0; + var mgr = layoutParameterDic["marginRight"]||0; + var mgb = layoutParameterDic["marginDown"]||0; + parameter.setMargin(mgl, mgt, mgr, mgb); + widget.setLayoutParameter(parameter); + } + } + }; + + parser.colorAttributes = function(widget, options){ + var op = options["opacity"]; + if(op != null) + widget.setOpacity(op); + var colorR = options["colorR"]; + var colorG = options["colorG"]; + var colorB = options["colorB"]; + widget.setColor(cc.color((colorR == null) ? 255 : colorR, (colorG == null) ? 255 : colorG, (colorB == null) ? 255 : colorB)); + + widget.setFlippedX(options["flipX"]); + widget.setFlippedY(options["flipY"]); + }; + + parser.anchorPointAttributes = function(widget, options){ + var isAnchorPointXExists = options["anchorPointX"]; + var anchorPointXInFile; + if (isAnchorPointXExists != null) + anchorPointXInFile = options["anchorPointX"]; + else + anchorPointXInFile = widget.getAnchorPoint().x; + + var isAnchorPointYExists = options["anchorPointY"]; + var anchorPointYInFile; + if (isAnchorPointYExists != null) + anchorPointYInFile = options["anchorPointY"]; + else + anchorPointYInFile = widget.getAnchorPoint().y; + + if (isAnchorPointXExists != null || isAnchorPointYExists != null) + widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); + }; + + parser.parseChild = function(parse, widget, options, resourcePath){ + var children = options["children"]; + for (var i = 0; i < children.length; i++) { + var child = this.parseNode(children[i], resourcePath); + if(child){ + if(widget instanceof ccui.PageView) + widget.addPage(child); + else { + if(widget instanceof ccui.ListView){ + widget.pushBackCustomItem(child); + } else { + if(!(widget instanceof ccui.Layout)) { + if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { + var position = child.getPositionPercent(); + var anchor = widget.getAnchorPoint(); + child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); + } + var AnchorPointIn = widget.getAnchorPointInPoints(); + child.setPosition(cc.p(child.getPositionX() + AnchorPointIn.x, child.getPositionY() + AnchorPointIn.y)); + } + widget.addChild(child); + } + } + } + } + }; + + /** + * Panel parser (UILayout) + */ + parser.LayoutAttributes = function(widget, options, resourcePath){ + var w = 0, h = 0; + var adaptScreen = options["adaptScreen"]; + if (adaptScreen){ + var screenSize = cc.director.getWinSize(); + w = screenSize.width; + h = screenSize.height; + }else{ + w = options["width"]; + h = options["height"]; + } + widget.setSize(cc.size(w, h)); + + widget.setClippingEnabled(options["clipAble"]); + + var backGroundScale9Enable = options["backGroundScale9Enable"]; + widget.setBackGroundImageScale9Enabled(backGroundScale9Enable); + var cr = options["bgColorR"]; + var cg = options["bgColorG"]; + var cb = options["bgColorB"]; + + var scr = options["bgStartColorR"]; + var scg = options["bgStartColorG"]; + var scb = options["bgStartColorB"]; + + var ecr = options["bgEndColorR"]; + var ecg = options["bgEndColorG"]; + var ecb = options["bgEndColorB"]; + + var bgcv1 = options["vectorX"]; + var bgcv2 = options["vectorY"]; + widget.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); + + var co = options["bgColorOpacity"]; + + var colorType = options["colorType"]; + widget.setBackGroundColorType(colorType/*ui.LayoutBackGroundColorType(colorType)*/); + widget.setBackGroundColor(cc.color(scr, scg, scb), cc.color(ecr, ecg, ecb)); + widget.setBackGroundColor(cc.color(cr, cg, cb)); + widget.setBackGroundColorOpacity(co); + + + var imageFileNameDic = options["backGroundImageData"]; + if(imageFileNameDic){ + var imageFileName, + imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType) + { + case 0: + { + var tp_b = resourcePath; + imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = (imageFileName && (imageFileName !== "")) ? + tp_b + imageFileName : + null; + widget.setBackGroundImage(imageFileName_tp); + break; + } + case 1: + { + imageFileName = imageFileNameDic["path"]; + widget.setBackGroundImage(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + } + default: + break; + } + } + + if (backGroundScale9Enable) + { + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + widget.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); + } + widget.setLayoutType(options["layoutType"]); + }; + /** + * Button parser (UIButton) + */ + parser.ButtonAttributes = function(widget, options, resourcePath){ + var button = widget; + var scale9Enable = options["scale9Enable"]; + button.setScale9Enabled(scale9Enable); + + var normalFileName, + normalDic = options["normalData"], + normalType = normalDic["resourceType"]; + switch (normalType) { + case 0: + var tp_n = resourcePath; + normalFileName = normalDic["path"]; + var normalFileName_tp = (normalFileName && normalFileName !== "") ? + tp_n + normalFileName : null; + button.loadTextureNormal(normalFileName_tp); + break; + case 1: + normalFileName = normalDic["path"]; + button.loadTextureNormal(normalFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + var pressedFileName, + pressedDic = options["pressedData"], + pressedType = pressedDic["resourceType"]; + switch (pressedType) { + case 0: + var tp_p = resourcePath; + pressedFileName = pressedDic["path"]; + var pressedFileName_tp = (pressedFileName && pressedFileName !== "") ? + tp_p + pressedFileName : null; + button.loadTexturePressed(pressedFileName_tp); + break; + case 1: + pressedFileName = pressedDic["path"]; + button.loadTexturePressed(pressedFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + var disabledFileName, + disabledDic = options["disabledData"], + disabledType = disabledDic["resourceType"]; + switch (disabledType){ + case 0: + var tp_d = resourcePath; + disabledFileName = disabledDic["path"]; + var disabledFileName_tp = (disabledFileName && disabledFileName !== "") ? + tp_d + disabledFileName : null; + button.loadTextureDisabled(disabledFileName_tp); + break; + case 1: + disabledFileName = disabledDic["path"]; + button.loadTextureDisabled(disabledFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + if (scale9Enable) { + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + + button.setCapInsets(cc.rect(cx, cy, cw, ch)); + var sw = options["scale9Width"]; + var sh = options["scale9Height"]; + if (sw != null && sh != null) + button.setSize(cc.size(sw, sh)); + } + var text = options["text"]; + if (text != null) + button.setTitleText(text); + + var cr = options["textColorR"]; + var cg = options["textColorG"]; + var cb = options["textColorB"]; + var cri = cr!==null?options["textColorR"]:255; + var cgi = cg!==null?options["textColorG"]:255; + var cbi = cb!==null?options["textColorB"]:255; + + button.setTitleColor(cc.color(cri,cgi,cbi)); + var fs = options["fontSize"]; + if (fs != null) + button.setTitleFontSize(options["fontSize"]); + var fn = options["fontName"]; + if (fn) + button.setTitleFontName(options["fontName"]); + }; + /** + * CheckBox parser (UICheckBox) + */ + parser.CheckBoxAttributes = function(widget, options, resourcePath){ + //load background image + var backGroundDic = options["backGroundBoxData"]; + var backGroundType = backGroundDic["resourceType"]; + var backGroundTexturePath = resourcePath + backGroundDic["path"]; + widget.loadTextureBackGround(backGroundTexturePath, backGroundType); + + //load background selected image + var backGroundSelectedDic = options["backGroundBoxSelectedData"]; + var backGroundSelectedType = backGroundSelectedDic["resourceType"]; + var backGroundSelectedTexturePath = resourcePath + backGroundSelectedDic["path"]; + if(!backGroundSelectedTexturePath){ + backGroundSelectedType = backGroundType; + backGroundSelectedTexturePath = backGroundTexturePath; + } + widget.loadTextureBackGroundSelected(backGroundSelectedTexturePath, backGroundSelectedType); + + //load frontCross image + var frontCrossDic = options["frontCrossData"]; + var frontCrossType = frontCrossDic["resourceType"]; + var frontCrossFileName = resourcePath + frontCrossDic["path"]; + widget.loadTextureFrontCross(frontCrossFileName, frontCrossType); + + //load backGroundBoxDisabledData + var backGroundDisabledDic = options["backGroundBoxDisabledData"]; + var backGroundDisabledType = backGroundDisabledDic["resourceType"]; + var backGroundDisabledFileName = resourcePath + backGroundDisabledDic["path"]; + if(!backGroundDisabledFileName){ + backGroundDisabledType = frontCrossType; + backGroundDisabledFileName = frontCrossFileName; + } + widget.loadTextureBackGroundDisabled(backGroundDisabledFileName, backGroundDisabledType); + + ///load frontCrossDisabledData + var frontCrossDisabledDic = options["frontCrossDisabledData"]; + var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; + var frontCrossDisabledFileName = resourcePath + frontCrossDisabledDic["path"]; + widget.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); + + if (options["selectedState"]) + widget.setSelected(options["selectedState"]); + }; + /** + * ImageView parser (UIImageView) + */ + parser.ImageViewAttributes = function(widget, options, resourcePath){ + var imageFileName, + imageFileNameDic = options["fileNameData"], + imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType){ + case 0: + var tp_i = resourcePath; + imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = null; + if (imageFileName && imageFileName !== "") { + imageFileName_tp = tp_i + imageFileName; + widget.loadTexture(imageFileName_tp); + } + break; + case 1: + imageFileName = imageFileNameDic["path"]; + widget.loadTexture(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + + var scale9EnableExist = options["scale9Enable"]; + var scale9Enable = false; + if (scale9EnableExist){ + scale9Enable = options["scale9Enable"]; + } + widget.setScale9Enabled(scale9Enable); + + if (scale9Enable){ + var sw = options["scale9Width"]; + var sh = options["scale9Height"]; + if (sw && sh) + { + var swf = options["scale9Width"]; + var shf = options["scale9Height"]; + widget.setSize(cc.size(swf, shf)); + } + + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + + widget.setCapInsets(cc.rect(cx, cy, cw, ch)); + + } + }; + /** + * TextAtlas parser (UITextAtlas) + */ + parser.TextAtlasAttributes = function(widget, options, resourcePath){ + var sv = options["stringValue"]; + var cmf = options["charMapFileData"]; // || options["charMapFile"]; + var iw = options["itemWidth"]; + var ih = options["itemHeight"]; + var scm = options["startCharMap"]; + if (sv != null && cmf && iw != null && ih != null && scm != null){ + var cmftDic = options["charMapFileData"]; + var cmfType = cmftDic["resourceType"]; + switch (cmfType){ + case 0: + var tp_c = resourcePath; + var cmfPath = cmftDic["path"]; + var cmf_tp = tp_c + cmfPath; + widget.setProperty(sv, cmf_tp, iw, ih, scm); + break; + case 1: + cc.log("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + } + }; + /** + * TextBMFont parser (UITextBMFont) + */ + parser.TextBMFontAttributes = function(widget, options, resourcePath){ + var cmftDic = options["fileNameData"]; + var cmfType = cmftDic["resourceType"]; + switch (cmfType) { + case 0: + var tp_c = resourcePath; + var cmfPath = cmftDic["path"]; + var cmf_tp = tp_c + cmfPath; + widget.setFntFile(cmf_tp); + break; + case 1: + cc.log("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + + var text = options["text"]; + widget.setString(text); + }; + /** + * Text parser (UIText) + */ + parser.TextAttributes = function(widget, options, resourcePath){ + var touchScaleChangeAble = options["touchScaleEnable"]; + widget.setTouchScaleChangeEnabled(touchScaleChangeAble); + var text = options["text"]; + widget.setString(text); + var fs = options["fontSize"]; + if (fs != null){ + widget.setFontSize(options["fontSize"]); + } + var fn = options["fontName"]; + if (fn != null){ + widget.setFontName(options["fontName"]); + } + var aw = options["areaWidth"]; + var ah = options["areaHeight"]; + if (aw != null && ah != null){ + var size = cc.size(options["areaWidth"], options["areaHeight"]); + widget.setTextAreaSize(size); + } + var ha = options["hAlignment"]; + if (ha != null){ + widget.setTextHorizontalAlignment(options["hAlignment"]); + } + var va = options["vAlignment"]; + if (va != null){ + widget.setTextVerticalAlignment(options["vAlignment"]); + } + }; + /** + * ListView parser (UIListView) + */ + parser.ListViewAttributes = function(widget, options, resoutcePath){ + parser.ScrollViewAttributes(widget, options,resoutcePath); + var direction = options["direction"]; + widget.setDirection(direction); + var gravity = options["gravity"]; + widget.setGravity(gravity); + var itemMargin = options["itemMargin"]; + widget.setItemsMargin(itemMargin); + }; + /** + * LoadingBar parser (UILoadingBar) + */ + parser.LoadingBarAttributes = function(widget, options, resoutcePath){ + var imageFileName, + imageFileNameDic = options["textureData"], + imageFileNameType = imageFileNameDic["resourceType"]; + switch (imageFileNameType){ + case 0: + var tp_i = resoutcePath; + imageFileName = imageFileNameDic["path"]; + var imageFileName_tp = null; + if (imageFileName && (imageFileName !== "")){ + imageFileName_tp = tp_i + imageFileName; + widget.loadTexture(imageFileName_tp); + } + break; + case 1: + imageFileName = imageFileNameDic["path"]; + widget.loadTexture(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + + var scale9Enable = options["scale9Enable"]; + widget.setScale9Enabled(scale9Enable); + + if (scale9Enable){ + var cx = options["capInsetsX"]; + var cy = options["capInsetsY"]; + var cw = options["capInsetsWidth"]; + var ch = options["capInsetsHeight"]; + + widget.setCapInsets(cc.rect(cx, cy, cw, ch)); + + var width = options["width"]; + var height = options["height"]; + widget.setSize(cc.size(width, height)); + } + + widget.setDirection(options["direction"]); + widget.setPercent(options["percent"]); + }; + /** + * PageView parser (UIPageView) + */ + parser.PageViewAttributes = parser.LayoutAttributes; + /** + * ScrollView parser (UIScrollView) + */ + parser.ScrollViewAttributes = function(widget, options, resoutcePath){ + parser.LayoutAttributes(widget, options,resoutcePath); + var innerWidth = options["innerWidth"]!=null ? options["innerWidth"] : 200; + var innerHeight = options["innerHeight"]!=null ? options["innerHeight"] : 200; + widget.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + + var direction = options["direction"]!=null ? options["direction"] : 1; + widget.setDirection(direction); + widget.setBounceEnabled(options["bounceEnable"]); + }; + /** + * Slider parser (UISlider) + */ + parser.SliderAttributes = function(widget, options, resoutcePath){ + + var slider = widget; + var tp = resoutcePath; + + var barTextureScale9Enable = options["scale9Enable"]; + slider.setScale9Enabled(barTextureScale9Enable); + var bt = options["barFileName"]; + var barLength = options["length"]; + + var imageFileNameDic = options["barFileNameData"]; + var imageFileType = imageFileNameDic["resourceType"]; + var imageFileName = imageFileNameDic["path"]; + var imageFileName_tp; + + if(bt != null){ + if(barTextureScale9Enable){ + switch(imageFileType){ + case 0: + imageFileName_tp = imageFileName ? + ( tp + imageFileName ) : + null; + slider.loadBarTexture(imageFileName_tp); + break; + case 1: + slider.loadBarTexture(imageFileName, 1 /*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + slider.setSize(cc.size(barLength, slider.getContentSize().height)); + } + }else{ + switch(imageFileType){ + case 0: + imageFileName_tp = imageFileName ? + tp + imageFileName : + null; + slider.loadBarTexture(imageFileName_tp); + break; + case 1: + slider.loadBarTexture(imageFileName, 1 /*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + } + var normalDic = options["ballNormalData"]; + var normalType = normalDic["resourceType"]; + var normalFileName = normalDic["path"]; + switch(normalType){ + case 0: + var normalFileName_tp = normalFileName ? + tp + normalFileName : + null; + slider.loadSlidBallTextureNormal(normalFileName_tp); + break; + case 1: + slider.loadSlidBallTextureNormal(normalFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + + var pressedDic = options["ballPressedData"]; + var pressedType = pressedDic["resourceType"]; + var pressedFileName = pressedDic["path"]; + if(pressedFileName === null){ + pressedType = normalType; + pressedFileName = normalFileName; + } + switch(pressedType){ + case 0: + var pressedFileName_tp = pressedFileName ? + tp + pressedFileName : + null; + slider.loadSlidBallTexturePressed(pressedFileName_tp); + break; + case 1: + slider.loadSlidBallTexturePressed(pressedFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + var disabledDic = options["ballDisabledData"]; + var disabledType = disabledDic["resourceType"]; + var disabledFileName = disabledDic["path"]; + switch(disabledType){ + case 0: + var disabledFileName_tp = disabledFileName ? + tp + disabledFileName : + null; + slider.loadSlidBallTextureDisabled(disabledFileName_tp); + break; + case 1: + slider.loadSlidBallTextureDisabled(disabledFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + var progressBarDic = options["progressBarData"]; + var progressBarType = progressBarDic["resourceType"]; + var imageProgressFileName = progressBarDic["path"]; + switch (progressBarType){ + case 0: + var imageProgressFileName_tp = imageProgressFileName ? + (tp + imageProgressFileName) : + null; + slider.loadProgressBarTexture(imageProgressFileName_tp); + break; + case 1: + slider.loadProgressBarTexture(imageProgressFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); + break; + default: + break; + } + }; + /** + * TextField parser (UITextField) + */ + parser.TextFieldAttributes = function(widget, options, resoutcePath){ + var ph = options["placeHolder"]; + if(ph) + widget.setPlaceHolder(ph); + widget.setString(options["text"]||""); + var fs = options["fontSize1"]; + if(fs) + widget.setFontSize(fs); + var fn = options["fontName"]; + if(fn) + widget.setFontName(fn); + var tsw = options["touchSizeWidth"]; + var tsh = options["touchSizeHeight"]; + if(tsw!=null && tsh!=null) + widget.setTouchSize(tsw, tsh); + + var dw = options["width"]; + var dh = options["height"]; + if(dw > 0 || dh > 0){ + //textField.setSize(cc.size(dw, dh)); + } + var maxLengthEnable = options["maxLengthEnable"]; + widget.setMaxLengthEnabled(maxLengthEnable); + + if(maxLengthEnable){ + var maxLength = options["maxLength"]; + widget.setMaxLength(maxLength); + } + var passwordEnable = options["passwordEnable"]; + widget.setPasswordEnabled(passwordEnable); + if(passwordEnable) + widget.setPasswordStyleText(options["passwordStyleText"]); + + var aw = options["areaWidth"]; + var ah = options["areaHeight"]; + if(aw && ah){ + var size = cc.size(aw, ah); + widget.setTextAreaSize(size); + } + var ha = options["hAlignment"]; + if(ha) + widget.setTextHorizontalAlignment(ha); + var va = options["vAlignment"]; + if(va) + widget.setTextVerticalAlignment(va); + }; + + var register = [ + {name: "Panel", object: ccui.Layout, handle: parser.LayoutAttributes}, + {name: "Button", object: ccui.Button, handle: parser.ButtonAttributes}, + {name: "CheckBox", object: ccui.CheckBox, handle: parser.CheckBoxAttributes}, + {name: "ImageView", object: ccui.ImageView, handle: parser.ImageViewAttributes}, + {name: "LabelAtlas", object: ccui.TextAtlas, handle: parser.TextAtlasAttributes}, + {name: "LabelBMFont", object: ccui.TextBMFont, handle: parser.TextBMFontAttributes}, + {name: "Label", object: ccui.Text, handle: parser.TextAttributes}, + {name: "ListView", object: ccui.ListView, handle: parser.ListViewAttributes}, + {name: "LoadingBar", object: ccui.LoadingBar, handle: parser.LoadingBarAttributes}, + {name: "PageView", object: ccui.PageView, handle: parser.PageViewAttributes}, + {name: "ScrollView", object: ccui.ScrollView, handle: parser.ScrollViewAttributes}, + {name: "Slider", object: ccui.Slider, handle: parser.SliderAttributes}, + {name: "TextField", object: ccui.TextField, handle: parser.TextFieldAttributes} + ]; + + register.forEach(function(item){ + parser.registerParser(item.name, function(options, parse, resourcePath){ + var widget = new item.object; + var uiOptions = options["options"]; + parser.generalAttributes(widget, uiOptions); + item.handle(widget, uiOptions, resourcePath); + parser.colorAttributes(widget, uiOptions); + parser.anchorPointAttributes(widget, uiOptions); + parser.parseChild.call(this, parse, widget, options, resourcePath); + return widget; + }); + }); + + load.registerParser("ccui", "1.*", parser); + + +})(ccs.loadNode, ccs._parser); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index b5da63757a..02530f0941 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -396,7 +396,14 @@ "extensions/cocostudio/reader/timeline/ActionTimelineCache.js", "extensions/cocostudio/reader/timeline/Frame.js", "extensions/cocostudio/reader/timeline/Timeline.js", - "extensions/cocostudio/reader/timeline/CSLoader.js" + "extensions/cocostudio/reader/timeline/CSLoader.js", + + "extensions/cocostudio/reader/loader/load.js", + "extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js", + "extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js", + "extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js" + + ], "gui" : [ "core", "clipping-nodes", "render-texture", "actions", "progress-timer", From b0a81068e17f396ae0574345d167f27ef62aafbf Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 29 Dec 2014 18:28:26 +0800 Subject: [PATCH 1125/1564] Fixed a bug of cc.Sprite that its setColor doesn't work on IE11 --- cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 7f84a3c9ff..d12d6b23a0 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -380,7 +380,7 @@ ctx = buff.getContext("2d"); ctx.clearRect(0, 0, w, h); } - + ctx.save(); ctx.globalCompositeOperation = 'lighter'; // Make sure to keep the renderCanvas alpha in mind in case of overdraw var a = ctx.globalAlpha; @@ -400,6 +400,7 @@ ctx.globalAlpha = a; ctx.drawImage(tintedImgCache[3], rect.x, rect.y, w, h, 0, 0, w, h); } + ctx.restore(); return buff; }; From 8c50f991af9fff6f4766ae31d97c64f00bbd5bc5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 30 Dec 2014 13:50:48 +0800 Subject: [PATCH 1126/1564] Fixed #2489: added a checking to addEventListener of Texture2D, Sprite etc, let them dispatch 'load' event in next frame when texture is loaded. --- cocos2d/core/event-manager/CCEventManager.js | 6 ++++++ cocos2d/core/sprites/CCSprite.js | 2 +- cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js | 2 +- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 2 +- cocos2d/core/textures/CCTexture2D.js | 13 +++++-------- cocos2d/core/textures/TexturesWebGL.js | 11 +++++------ cocos2d/particle/CCParticleSystemCanvasRenderCmd.js | 2 +- .../armature/display/CCSkinWebGLRenderCmd.js | 2 +- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index f0bf33a625..6fd0512f68 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -942,6 +942,12 @@ cc.EventHelper.prototype = { }, addEventListener: function ( type, listener, target ) { + //check 'type' status, if the status is ready, dispatch event next frame + if(type === "load" && this._textureLoaded){ //only load event checked. + setTimeout(listener.call(target), 0); + return; + } + if ( this._listeners === undefined ) this._listeners = {}; diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index cfe5038633..3a5202fa12 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -932,7 +932,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); //If image isn't loaded. Listen for the load event. - if(!texture._isLoaded){ + if(!texture._textureLoaded){ texture.addEventListener("load", function(){ var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index d12d6b23a0..7a8645a5d1 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -114,7 +114,7 @@ var node = this._node; var locTextureCoord = this._textureCoord, alpha = (this._displayedOpacity / 255); if ((node._texture && ((locTextureCoord.width === 0 || locTextureCoord.height === 0) //set texture but the texture isn't loaded. - || !node._texture._isLoaded)) || alpha === 0) + || !node._texture._textureLoaded)) || alpha === 0) return; var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 06311b611f..b590b6c74b 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -419,7 +419,7 @@ //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); if (locTexture) { - if (locTexture._isLoaded) { + if (locTexture._textureLoaded) { this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index dbdc03ee4d..82833cab4f 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -122,16 +122,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { */ cc.Texture2D = cc.Class.extend(/** @lends cc.Texture2D# */{ _contentSize: null, - _isLoaded: false, + _textureLoaded: false, _htmlElementObj: null, - url: null, - _pattern: null, ctor: function () { this._contentSize = cc.size(0, 0); - this._isLoaded = false; + this._textureLoaded = false; this._htmlElementObj = null; this._pattern = ""; }, @@ -199,7 +197,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { * @returns {boolean} */ isLoaded: function () { - return this._isLoaded; + return this._textureLoaded; }, /** @@ -207,14 +205,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { */ handleLoadedTexture: function () { var self = this; - if (self._isLoaded) return; + if (self._textureLoaded) return; if (!self._htmlElementObj) { var img = cc.loader.getRes(self.url); if (!img) return; self.initWithElement(img); } - self._isLoaded = true; + self._textureLoaded = true; var locElement = self._htmlElementObj; self._contentSize.width = locElement.width; self._contentSize.height = locElement.height; @@ -398,7 +396,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { /** * remove listener from listeners by target * @param {cc.Node} target - * @deprecated since 3.1, please use addEventListener instead */ removeLoadedEventListener: function (target) { this.removeEventListener("load", target); diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 567efa7998..4e0f41c5d9 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -64,7 +64,7 @@ cc._tmp.WebGLTexture2D = function () { shaderProgram: null, - _isLoaded: false, + _textureLoaded: false, _htmlElementObj: null, _webTextureObj: null, @@ -308,7 +308,7 @@ cc._tmp.WebGLTexture2D = function () { self._hasMipmaps = false; self.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE); - self._isLoaded = true; + self._textureLoaded = true; return true; }, @@ -406,7 +406,7 @@ cc._tmp.WebGLTexture2D = function () { cc.log(cc._LogInfos.Texture2D_initWithImage_2, imageWidth, imageHeight, maxTextureSize, maxTextureSize); return false; } - this._isLoaded = true; + this._textureLoaded = true; // always load premultiplied images return this._initPremultipliedATextureWithImage(uiImage, imageWidth, imageHeight); @@ -436,7 +436,7 @@ cc._tmp.WebGLTexture2D = function () { * @return {Boolean} */ isLoaded: function () { - return this._isLoaded; + return this._textureLoaded; }, /** @@ -454,7 +454,7 @@ cc._tmp.WebGLTexture2D = function () { } if (!self._htmlElementObj.width || !self._htmlElementObj.height) return; - self._isLoaded = true; + self._textureLoaded = true; //upload image to buffer var gl = cc._renderContext; @@ -757,7 +757,6 @@ cc._tmp.WebGLTexture2D = function () { /** * remove listener from listeners by target * @param {cc.Node} target - * @deprecated since 3.1, please use addEventListener instead */ removeLoadedEventListener: function (target) { this.removeEventListener("load", target); diff --git a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js index 6d71ac0ccc..7b316d3ed3 100644 --- a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js @@ -84,7 +84,7 @@ var particleCount = this._node.particleCount, particles = this._node._particles; if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { // Delay drawing until the texture is fully loaded by the browser - if (!node._texture || !node._texture._isLoaded) { + if (!node._texture || !node._texture._textureLoaded) { wrapper.restore(); return; } diff --git a/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js index deb0370c31..f541aa1058 100644 --- a/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js @@ -99,7 +99,7 @@ return; var gl = ctx || cc._renderContext, locTexture = node._texture; - if (locTexture && locTexture._isLoaded) { + if (locTexture && locTexture._textureLoaded) { this._shaderProgram.use(); this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(); From 1fd60f39f5838145a97f2d92319715c250dcd243 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 30 Dec 2014 18:31:20 +0800 Subject: [PATCH 1127/1564] update timelineParser-2.x.js --- extensions/cocostudio/reader/loader/load.js | 11 +- .../loader/parsers/timelineParser-2.x.js | 605 +++++++++++++++++- 2 files changed, 588 insertions(+), 28 deletions(-) diff --git a/extensions/cocostudio/reader/loader/load.js b/extensions/cocostudio/reader/loader/load.js index fbfb126792..9bcca3bea0 100644 --- a/extensions/cocostudio/reader/loader/load.js +++ b/extensions/cocostudio/reader/loader/load.js @@ -1,6 +1,12 @@ ccs.loadNode = (function(){ - var load = function(file){ + /** + * load file + * @param file + * @param type - ui|timeline|action + * @returns {*} + */ + var load = function(file, type){ var json = cc.loader.getRes(file); @@ -36,7 +42,8 @@ ccs.loadNode = (function(){ var parser = { "ccui": {}, - "timeline": {} + "timeline": {}, + "action": {} }; load.registerParser = function(name, version, target){ diff --git a/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js index 38e2e38126..e82139cd07 100644 --- a/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js @@ -1,5 +1,7 @@ (function(load, baseParser){ + var DEBUG = true; + var Parser = baseParser.extend({ parse: function(file, json){ @@ -128,6 +130,11 @@ } }; + /** + * SingleNode + * @param json + * @returns {cc.Node} + */ parser.initSingleNode = function(json){ var node = new cc.Node(); @@ -136,31 +143,19 @@ return node; }; - parser.initSprite = function(json){ + /** + * Sprite + * @param json + * @returns {cc.Sprite} + */ + parser.initSprite = function(json, resourcePath){ var node = new cc.Sprite(); this.generalAttributes(node, json); - var fileData = json["FileData"]; - if(fileData){ - switch(fileData["Type"]){ - case 1: - var spriteFrame = cc.spriteFrameCache.getSpriteFrameByName(); - if(spriteFrame) - node.setSpriteFrame(spriteFrame); - break; - default: - if(fileData["Path"]) - node.setTexture(fileData["Path"]); - } - - } -// if (!fileExist) -// { -// auto label = Label::create(); -// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString()); -// sprite->addChild(label); -// } + loadTexture(json["FileData"], resourcePath, function(path, type){ + node.setTexture(path); + }); if(json["FlipX"]) node.setFlippedX(true); @@ -170,6 +165,11 @@ return node; }; + /** + * Particle + * @param json + * @returns {*} + */ parser.initParticle = function(json){ var fileData = json["FileData"]; var node; @@ -239,34 +239,587 @@ // -- var frameEvent = json["FrameEvent"]; var callBackType = json["CallBackType"]; - if(callBackType != nul) + if(callBackType != null) widget.setCallbackType(callBackType); var callBackName = json["CallBackName"]; if(callBackName) widget.setCallbackName(callBackName); + + var position = json["Position"]; + if(position != null) + widget.setPosition(position["X"] || 0, position["Y"] || 0); + + var scale = json["Scale"]; + if(scale != null){ + widget.setScaleX(scale["ScaleX"] || 1); + widget.setScaleY(scale["ScaleY"] || 1); + } + + var anchorPoint = json["AnchorPoint"]; + if(anchorPoint != null) + widget.setAnchorPoint(anchorPoint["ScaleX"] || 0.5, anchorPoint["ScaleY"] || 0.5); + + var color = json["CColor"]; + if(color != null && color["R"] != null &&color["G"] != null &&color["B"] != null) + widget.setColor(color["R"], color["G"], color["B"]); +// +// var size = json["Size"]; +// if(size != null) +// widget.setContentSize(size["X"]||0, size["Y"]||0); + + if(widget instanceof ccui.Layout){ + //todo update UILayoutComponent.bindLayoutComponent + var positionXPercentEnabled = json["PositionPercentXEnable"]; + var positionYPercentEnabled = json["PositionPercentYEnable"]; + var sizeXPercentEnable = json["PercentWidthEnable"]; + var sizeYPercentEnable = json["PercentHeightEnable"]; + var stretchHorizontalEnabled = json["StretchWidthEnable"]; + var stretchVerticalEnabled = json["StretchHeightEnable"]; + var horizontalEdge = json["HorizontalEdge"]; + var verticalEdge = json["VerticalEdge"]; + var leftMargin = json["LeftMargin"]; + var rightMargin = json["RightMargin"]; + var topMargin = json["TopMargin"]; + var bottomMargin = json["BottomMargin"]; + //var prePosition = json["PrePosition"]; + //if(prePosition) + // prePosition["X"], prePosition["Y"] + + //var preSize = json["PreSize"]; + //if(preSize) + // preSize["X"], preSize["Y"] + } + }; - parser.initPanel = function(json){ + /** + * Layout + * @param json + * @param resourcePath + * @returns {ccui.Layout} + */ + parser.initPanel = function(json, resourcePath){ var widget = new ccui.Layout(); + this.widgetAttributes(widget, json); + + var clipEnabled = json["ClipAple"]; + if(clipEnabled != null) + widget.setClippingEnabled(clipEnabled); + + var colorType = json["ComboBoxIndex"]; + if(colorType != null) + widget.setBackGroundColorType(colorType); + + var bgColorOpacity = json["BackColorAlpha"]; + if(bgColorOpacity != null) + widget.setBackGroundColorOpacity(bgColorOpacity); + + var backGroundScale9Enabled = json["Scale9Enable"]; + if(backGroundScale9Enabled != null) + widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled); + + var scale9OriginX = json["Scale9OriginX"]; + var scale9OriginY = json["Scale9OriginY"]; + + var scale9Width = json["Scale9Width"]; + var scale9Height = json["Scale9Height"]; + + var bgStartColor = json["FirstColor"]; + var bgEndColor = json["EndColor"]; + if(bgStartColor != null && bgEndColor != null){ + bgStartColor["R"] == undefined && (bgStartColor["R"] = 255); + bgStartColor["G"] == undefined && (bgStartColor["G"] = 255); + bgStartColor["B"] == undefined && (bgStartColor["B"] = 255); + bgEndColor["R"] == undefined && (bgEndColor["R"] = 255); + bgEndColor["G"] == undefined && (bgEndColor["G"] = 255); + bgEndColor["B"] == undefined && (bgEndColor["B"] = 255); + widget.setBackGroundColor( + cc.color(bgStartColor["R"], bgStartColor["G"], bgStartColor["B"]), + cc.color(bgEndColor["R"], bgEndColor["G"], bgEndColor["B"]) + ); + } - return node; + var colorVector = json["ColorVector"]; + if(colorVector != null) + colorVector["ScaleX"]; + + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + + return widget; + }; + + /** + * Text + * @param json + * @param resourcePath + */ + parser.initText = function(json, resourcePath){ + + var widget = new ccui.Text(); + + this.widgetAttributes(widget, json); + + var touchScaleEnabled = json["TouchScaleChangeAble"]; + if(touchScaleEnabled != null) + widget.setTouchScaleChangeEnabled(touchScaleEnabled); + + var text = json["LabelText"]; + if(text != null) + widget.setString(text); + + var fontSize = json["FontSize"]; + if(fontSize != null) + widget.setFontSize(fontSize); + + var fontName = json["FontName"]; + if(fontName != null) + widget.setFontName(fontName); + + var areaWidth = json["AreaWidth"]; + var areaHeight = json["areaHeight"]; + if(areaWidth && areaHeight) + widget.setTextAreaSize(cc.size(areaWidth, areaHeight)); + + var h_alignment = json["HorizontalAlignmentType"]; + switch(h_alignment){ + case "HT_Right": + h_alignment = 2; break; + case "HT_Center": + h_alignment = 1; break; + case "HT_Left": + default: + h_alignment = 0; + } + widget.setTextHorizontalAlignment(h_alignment); + + var v_alignment = json["VerticalAlignmentType"]; + switch(v_alignment){ + case "VT_Bottom": + v_alignment = 2; break; + case "VT_Center": + v_alignment = 1; break; + case "VT_Top": + default: + v_alignment = 0; + } + widget.setTextVerticalAlignment(v_alignment); + + //todo check it + var isCustomSize = json["IsCustomSize"]; + widget.ignoreContentAdaptWithSize(!isCustomSize); + + var path, resoutceType, plistFile; + var fontResource = json["FontResource"]; + if(fontResource != null){ + path = fontResource["Path"]; + resoutceType = fontResource["Type"]; + plistFile = fontResource["Plist"]; + } + + widget.setUnifySizeEnabled(false); + + if(widget.isIgnoreContentAdaptWithSize()){ + var size = json["Size"]; + if(size != null) + widget.setContentSize(cc.size(size["X"]||0, size["Y"]||0)); + } + + return widget; + + }; + + /** + * Button + * @param json + * @param resourcePath + */ + parser.initButton = function(json, resourcePath){ + + var widget = new ccui.Button(); + + this.widgetAttributes(widget, json); + + var scale9Enabled = json["Scale9Enable"]; + if(scale9Enabled){ + widget.setScale9Enabled(scale9Enabled); + widget.setUnifySizeEnabled(false); + widget.ignoreContentAdaptWithSize(false); + + var capInsets = cc.rect( + json["Scale9OriginX"] || 0, + json["Scale9OriginY"] || 0, + json["Scale9Width"] || 0, + json["Scale9Height"] || 0 + ); + + widget.setCapInsets(capInsets); + + } + + var size = json["Size"]; + if(size != null){ + widget.setContentSize(size["X"] || 0, size["Y"] || 0); + } + + var text = json["ButtonText"]; + if(text != null) + widget.setTitleText(text); + + var fontSize = json["FontSize"]; + if(fontSize != null) + widget.setTitleFontSize(fontSize); + + var fontName = json["FontName"]; + if(fontName != null) + widget.setTitleFontName(fontName); + + var displaystate = json["DisplayState"]; + if(displaystate != null){ + widget.setBright(displaystate); + widget.setEnabled(displaystate); + } + + var textColor = json["TextColor"]; + if(textColor != null){ + textColor["R"] = textColor["R"] != null ? textColor["R"] : 255; + textColor["G"] = textColor["G"] != null ? textColor["G"] : 255; + textColor["B"] = textColor["B"] != null ? textColor["B"] : 255; + widget.setTitleColor(cc.color(textColor["R"], textColor["G"], textColor["B"])); + } + + var dataList = [ + {json: json["DisabledFileData"], handle: function(path, type){ + widget.loadTextureDisabled(path, type); + }}, + {json: json["PressedFileData"], handle: function(path, type){ + widget.loadTexturePressed(path, type); + }}, + {json: json["NormalFileData"], handle: function(path, type){ + widget.loadTextureNormal(path, type); + }} + ]; + + dataList.forEach(function(item){ + loadTexture(item.json, resourcePath, item.handle); + }); + + //var fontResourcePath, fontResourceResourceType, fontResourcePlistFile; + //var fontResource = json["FontResource"]; + //if(fontResource != null){ + // fontResourcePath = fontResource["Path"]; + // fontResourceResourceType = fontResource["Type"] == "Default" ? 0 : 1; + // fontResourcePlistFile = fontResource["Plist"]; + //} + + return widget; + + }; + + /** + * CheckBox + * @param json + * @param resourcePath + */ + parser.initCheckBox = function(json, resourcePath){ + + var widget = new ccui.CheckBox(); + + this.widgetAttributes(widget, json); + + var selectedState = json["CheckedState"]; + if(selectedState) + widget.setSelected(true); + + var displaystate = json["DisplayState"]; + if(displaystate){ + widget.setBright(displaystate); + widget.setEnabled(displaystate); + } + + var dataList = [ + {json: json["NormalBackFileData"], handle: function(path, type){ + widget.loadTextureBackGround(path, type); + }}, + {json: json["PressedBackFileData"], handle: function(path, type){ + widget.loadTextureBackGroundSelected(path, type); + }}, + {json: json["NodeNormalFileData"], handle: function(path, type){ + widget.loadTextureFrontCross(path, type); + }}, + {json: json["DisableBackFileData"], handle: function(path, type){ + widget.loadTextureBackGroundDisabled(path, type); + }}, + {json: json["NodeDisableFileData"], handle: function(path, type){ + widget.loadTextureFrontCrossDisabled(path, type); + }} + ]; + + dataList.forEach(function(item){ + loadTexture(item.json, resourcePath, item.handle); + }); + + return widget; + }; + + /** + * ScrollView + * @param json + * @param resourcePath + */ + parser.initScrollView = function(json, resourcePath){ + var widget = new ccui.ScrollView(); + + this.widgetAttributes(widget, json); + + var clipEnabled = json["ClipAble"]; + if(clipEnabled) + widget.setClippingEnabled(true); + + var colorType = json["ComboBoxIndex"]; + if(colorType != null) + widget.setBackGroundColorType(colorType); + + var bgColorOpacity = json["BackColorAlpha"]; + if(bgColorOpacity) + widget.setBackGroundColorOpacity(bgColorOpacity); + + var backGroundScale9Enabled = json["Scale9Enable"]; + if(backGroundScale9Enabled){ + widget.setBackGroundImageScale9Enabled(true); + } + + var scale9OriginX = json["Scale9OriginX"]; + var scale9OriginY = json["Scale9OriginY"]; + + var scale9Width = json["Scale9Width"]; + var scale9Height = json["Scale9Height"]; + + var scale9Size = json["Size"]; + if(scale9Size){ + scale9Size = cc.size(scale9Size["X"] || 0, scale9Size["Y"] || 0); + } + + + if(json["FirstColor"] && json["EndColor"]){ + var bgStartColor, bgEndColor; + bgStartColor = setColor(json["FirstColor"]); + bgEndColor = setColor(json["EndColor"]); + widget.setBackGroundColor(bgStartColor, bgEndColor); + }else{ + widget.setBackGroundColor(setColor(json["SingleColor"])); + } + + + var colorVector = json["ColorVector"]; + if(colorVector){ + widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"] || 1, colorVector["ScaleY"] || 1)); + } + + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + + var innerNodeSize = json["InnerNodeSize"]; + var innerSize = cc.size( + innerNodeSize["width"] || 0, + innerNodeSize["height"] || 0 + ); + widget.setInnerContainerSize(innerSize); + + var direction = 0; + if(json["ScrollDirectionType"] == "Vertical") direction = 1; + if(json["ScrollDirectionType"] == "Horizontal") direction = 2; + if(json["ScrollDirectionType"] == "Vertical_Horizontal") direction = 3; + widget.setDirection(direction); + + var bounceEnabled = json["IsBounceEnabled"]; + if(bounceEnabled) + widget.setBounceEnabled(bounceEnabled); + + return widget; + }; + + /** + * ImageView + * @param json + * @param resourcePath + */ + parser.initImageView = function(json, resourcePath){ + + var widget = new ccui.ImageView(); + + this.widgetAttributes(widget, json); + + var scale9Enabled = json["Scale9Enable"]; + if(scale9Enabled){ + widget.setScale9Enabled(true); + widget.setUnifySizeEnabled(false); + widget.ignoreContentAdaptWithSize(false); + + var scale9OriginX = json["Scale9OriginX"]; + var scale9OriginY = json["Scale9OriginY"]; + var scale9Width = json["Scale9Width"]; + var scale9Height = json["Scale9Height"]; + widget.setCapInsets(cc.rect( + scale9OriginX || 0, + scale9OriginY || 0, + scale9Width || 0, + scale9Height || 0 + )); + } + + + var scale9Size = json["Size"]; + if(scale9Size) + widget.setContentSize(cc.size(scale9Size["X"] || 0, scale9Size["Y"] || 0)); + + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.loadTexture(path, type); + }); + + return widget; + }; + + /** + * + * @param json + * @param resourcePath + * @returns {ccui.LoadingBar} + */ + parser.initLoadingBar = function(json, resourcePath){ + + var widget = new ccui.LoadingBar(); + + this.widgetAttributes(widget, json); + + var direction = json["ProgressType"] == "Left_To_Right" ? 0 : 1; + widget.setDirection(direction); + + var percent = json["ProgressInfo"] != null ? json["ProgressInfo"] : 0; + widget.setPercent(percent); + + loadTexture(json["ImageFileData"], resourcePath, function(path, type){ + widget.loadTexture(path, type); + }); + + return widget; + }; + /** + * + * @param json + * @param resourcePath + */ + parser.initSlider = function(json, resourcePath){ + + var widget = new ccui.Slider(); + + this.widgetAttributes(widget, json); + + var percent = json["PercentInfo"]; + if(percent != null) + widget.setPercent(percent); + + var displaystate = json["DisplayState"]; + if(displaystate != null){ + widget.setBright(displaystate); + widget.setEnabled(displaystate); + } + + loadTexture(json["BackGroundData"], resourcePath, function(path, type){ + widget.loadBarTexture(path, type); + }); + loadTexture(json["BallNormalData"], resourcePath, function(path, type){ + widget.loadSlidBallTextureNormal(path, type); + }); + loadTexture(json["BallPressedData"], resourcePath, function(path, type){ + widget.loadSlidBallTexturePressed(path, type); + }); + loadTexture(json["BallDisabledData"], resourcePath, function(path, type){ + widget.loadSlidBallTextureDisabled(path, type); + }); + loadTexture(json["ProgressBarData"], resourcePath, function(path, type){ + widget.loadProgressBarTexture(path, type); + }); + + + return widget; + }; + + /** + * + * @param json + * @param resourcePath + */ + parser.initPageView = function(json, resourcePath){ + + var widget = ccui.PageView(); + + this.widgetAttributes(widget, json); + + var percent = json["PercentInfo"]; + + var displaystate = json["DisplayState"]; + + return widget; + + }; + + var loadTexture = function(json, resourcePath, cb){ + if(json != null){ + var path = json["Path"]; + var type; + if(json["Type"] == "Default" || json["Type"] == "Normal") + type = 0; + else + type = 1; + var plist = json["Plist"]; + if(plist) + cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); + if(type !== 0) + cb(path, type); + else + cb(resourcePath + path, type); + } + }; + + var setColor = function(json){ + if(!json) return; + var r = json["R"] != null ? json["R"] : 255; + var g = json["G"] != null ? json["G"] : 255; + var b = json["B"] != null ? json["B"] : 255; + return cc.size(r, g, b); + }; + + + var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, {name: "SpriteObjectData", handle: parser.initSprite}, {name: "ParticleObjectData", handle: parser.initParticle}, - {name: "PanelObjectData", handle: parser.initPanel} + {name: "PanelObjectData", handle: parser.initPanel}, + {name: "TextObjectData", handle: parser.initText}, + {name: "ButtonObjectData", handle: parser.initButton}, + {name: "CheckBoxObjectData", handle: parser.initCheckBox}, + {name: "ScrollViewObjectData", handle: parser.initScrollView}, + {name: "ImageViewObjectData", handle: parser.initImageView}, + {name: "LoadingBarObjectData", handle: parser.initLoadingBar}, + {name: "SliderObjectData", handle: parser.initSlider}, + {name: "PageViewObjectData", handle: parser.initPageView} ]; register.forEach(function(item){ parser.registerParser(item.name, function(options, parse, resourcePath){ - var node = item.handle.call(this, options); + var node = item.handle.call(this, options, resourcePath); this.parseChild(node, options["Children"], resourcePath); + DEBUG && (node.__parserName = item.name); return node; }); }); From 795cd35eb476df5990638f893fdb2d9b822af9a0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 31 Dec 2014 10:11:03 +0800 Subject: [PATCH 1128/1564] Fixed #2560: fixed a bug of Armature that its position doesn't update in visit on WebGL mode --- .../armature/CCArmatureWebGLRenderCmd.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index bf2df6893f..f405d461e4 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -117,6 +117,23 @@ dis.rendering(ctx); }; + proto.updateStatus = function () { + var flags = cc.Node._dirtyFlags, locFlag = this._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if(colorDirty) + this._updateDisplayColor(); + + if(opacityDirty) + this._updateDisplayOpacity(); + + if(colorDirty || opacityDirty) + this._updateColor(); + + //update the transform every visit, needn't dirty flag, + this.transform(this.getParentRenderCmd(), true); + }; + proto.visit = function(parentCmd){ var node = this._node; // quick return if not visible. children won't be drawn. From 3795b23accdad2212300187458cc71eb8a8cd8b8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 31 Dec 2014 11:43:21 +0800 Subject: [PATCH 1129/1564] Issue #2563: add ListView and PageView --- .../loader/parsers/timelineParser-2.x.js | 150 ++++++++++++++++-- 1 file changed, 140 insertions(+), 10 deletions(-) diff --git a/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js index e82139cd07..da557de0b0 100644 --- a/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js @@ -174,7 +174,7 @@ var fileData = json["FileData"]; var node; if(fileData){ - node = new cc.ParticleSystemQuad(); + node = new cc.ParticleSystem(); this.generalAttributes(node, json); } return node; @@ -608,11 +608,11 @@ if(json["FirstColor"] && json["EndColor"]){ var bgStartColor, bgEndColor; - bgStartColor = setColor(json["FirstColor"]); - bgEndColor = setColor(json["EndColor"]); + bgStartColor = getColor(json["FirstColor"]); + bgEndColor = getColor(json["EndColor"]); widget.setBackGroundColor(bgStartColor, bgEndColor); }else{ - widget.setBackGroundColor(setColor(json["SingleColor"])); + widget.setBackGroundColor(getColor(json["SingleColor"])); } @@ -674,7 +674,6 @@ )); } - var scale9Size = json["Size"]; if(scale9Size) widget.setContentSize(cc.size(scale9Size["X"] || 0, scale9Size["Y"] || 0)); @@ -760,18 +759,148 @@ */ parser.initPageView = function(json, resourcePath){ - var widget = ccui.PageView(); + var widget = new ccui.PageView(); this.widgetAttributes(widget, json); - var percent = json["PercentInfo"]; + var clipEnabled = json["ClipAble"]; + if(clipEnabled) + widget.setClippingEnabled(true); - var displaystate = json["DisplayState"]; + var backGroundScale9Enabled = json["Scale9Enable"]; + if(backGroundScale9Enabled){ + widget.setBackGroundImageScale9Enabled(true); + + var scale9OriginX = json["Scale9OriginX"]; + var scale9OriginY = json["Scale9OriginY"]; + var scale9Width = json["Scale9Width"]; + var scale9Height = json["Scale9Height"]; + widget.setBackGroundImageCapInsets(cc.rect( + scale9OriginX || 0, + scale9OriginY || 0, + scale9Width || 0, + scale9Height || 0 + )); + } + + var colorType = json["ComboBoxIndex"]; + if(colorType != null) + widget.setBackGroundColorType(colorType); + + var bgColorOpacity = json["BackColorAlpha"]; + var bgColor = getColor(json["SingleColor"]); + var bgEndColor = getColor(json["EndColor"]); + var bgStartColor = getColor(json["FirstColor"]); + if(bgEndColor && bgStartColor) + widget.setBackGroundColor(bgStartColor, bgEndColor); + else + widget.setBackGroundColor(bgColor); + + var colorVector = json["ColorVector"]; + if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) + widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]); + widget.setBackGroundColorOpacity(bgColorOpacity); + + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + + var size = json["Size"]; + if(size != null) + widget.setContentSize(size["X"], size["Y"]); return widget; }; + parser.initListView = function(json, resourcePath){ + + var widget = new ccui.ListView(); + + var clipEnabled = json["ClipAble"]; + if(clipEnabled) + widget.setClippingEnabled(true); + + var colorType = json["ComboBoxIndex"]; + if(colorType != null) + widget.setBackGroundColorType(colorType); + + var bgColorOpacity = json["BackColorAlpha"]; + var backGroundScale9Enabled = json["Scale9Enable"]; + if(backGroundScale9Enabled){ + widget.setBackGroundImageScale9Enabled(true); + + var scale9OriginX = json["Scale9OriginX"]; + var scale9OriginY = json["Scale9OriginY"]; + var scale9Width = json["Scale9Width"]; + var scale9Height = json["Scale9Height"]; + widget.setBackGroundImageCapInsets(cc.rect( + scale9OriginX || 0, + scale9OriginY || 0, + scale9Width || 0, + scale9Height || 0 + )); + } + + var directionType = json["DirectionType"]; + var verticalType = json["VerticalType"]; + var horizontalType = json["HorizontalType"]; + if(!directionType){ + widget.setDirection(ccui.ListView.DIR_HORIZONTAL); + if(verticalType == "Align_Bottom") + widget.setGravity(ccui.ListView.GRAVITY_BOTTOM); + else if(verticalType == "Align_VerticalCenter") + widget.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL); + else + widget.setGravity(ccui.ListView.GRAVITY_TOP); + }else if(directionType == "Vertical"){ + widget.setDirection(ccui.ListView.DIR_VERTICAL); + if (horizontalType == "") + widget.setGravity(ccui.ListView.GRAVITY_LEFT); + else if (horizontalType == "Align_Right") + widget.setGravity(ccui.ListView.GRAVITY_RIGHT); + else if (horizontalType == "Align_HorizontalCenter") + widget.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL); + } + + + var bounceEnabled = json["IsBounceEnabled"]; + if(bounceEnabled) + widget.setBounceEnabled(true); + var itemMargin = json["ItemMargin"]; + if(itemMargin != null){ + widget.setItemsMargin(itemMargin); + } + + var innerSize = json["InnerNodeSize"]; + //Width + if(innerSize != null) + widget.setInnerContainerSize(cc.size(innerSize["Widget"]||0, innerSize["Height"]||0)); + + var bgColor = getColor(json["SingleColor"]); + var bgEndColor = getColor(json["EndColor"]); + var bgStartColor = getColor(json["FirstColor"]); + if(bgEndColor && bgStartColor) + widget.setBackGroundColor(bgStartColor, bgEndColor); + else + widget.setBackGroundColor(bgColor); + var colorVector = json["ColorVector"]; + if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) + widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]); + widget.setBackGroundColorOpacity(bgColorOpacity); + + + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + + var size = json["Size"]; + if(size != null) + widget.setContentSize(size["X"]||0, size["Y"]||0); + + return widget; + }; + var loadTexture = function(json, resourcePath, cb){ if(json != null){ var path = json["Path"]; @@ -790,7 +919,7 @@ } }; - var setColor = function(json){ + var getColor = function(json){ if(!json) return; var r = json["R"] != null ? json["R"] : 255; var g = json["G"] != null ? json["G"] : 255; @@ -812,7 +941,8 @@ {name: "ImageViewObjectData", handle: parser.initImageView}, {name: "LoadingBarObjectData", handle: parser.initLoadingBar}, {name: "SliderObjectData", handle: parser.initSlider}, - {name: "PageViewObjectData", handle: parser.initPageView} + {name: "PageViewObjectData", handle: parser.initPageView}, + {name: "ListViewObjectData", handle: parser.initListView} ]; register.forEach(function(item){ From c699dce722cf3e850645e17c0584cd30815bef64 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 31 Dec 2014 15:06:14 +0800 Subject: [PATCH 1130/1564] Fixed #1545: fixed a bug of cc.Sprite that its setTextureRect doesn't work when called setColor --- cocos2d/core/sprites/CCSprite.js | 2 +- .../core/sprites/CCSpriteCanvasRenderCmd.js | 94 +++++++++++-------- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 3a5202fa12..8c7f1abf23 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -825,7 +825,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ cc.assert(newFrame, cc._LogInfos.Sprite_setSpriteFrame) } - this.setNodeDirty(true) + this.setNodeDirty(true); var frameOffset = newFrame.getOffset(); _t._unflippedOffsetPositionFromCenter.x = frameOffset.x; diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 7a8645a5d1..ec0ecd09b8 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -100,12 +100,10 @@ proto._checkTextureBoundary = function (texture, rect, rotated) { if (texture && texture.url) { var _x = rect.x + rect.width, _y = rect.y + rect.height; - if (_x > texture.width) { + if (_x > texture.width) cc.error(cc._LogInfos.RectWidth, texture.url); - } - if (_y > texture.height) { + if (_y > texture.height) cc.error(cc._LogInfos.RectHeight, texture.url); - } } this._node._originalTexture = texture; }; @@ -165,28 +163,24 @@ cc.g_NumberOfDraws++; }; - proto._updateColor = function () { - //TODO need refactor - var node = this._node; - var displayedColor = this._displayedColor; + if(!cc.sys._supportCanvasNewBlendModes){ + proto._updateColor = function () { + var node = this._node, displayedColor = this._displayedColor; - if(this._colorized){ - if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255){ - this._colorized = false; - node.texture = this._originalTexture; + if (displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255){ + if(this._colorized){ + this._colorized = false; + node.texture = this._originalTexture; + } return; } - }else - if(displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255) - return; - var locElement, locTexture = node._texture, locRect = this._textureCoord; - if (locTexture && locRect.validRect && this._originalTexture) { - locElement = locTexture.getHtmlElementObj(); - if (!locElement) - return; + var locElement, locTexture = node._texture, locRect = this._textureCoord; + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; - if (!cc.sys._supportCanvasNewBlendModes) { var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); if (cacheTextureForColor) { this._colorized = true; @@ -201,7 +195,25 @@ node.texture = locTexture; } } - } else { + } + }; + } else { + proto._updateColor = function () { + var node = this._node, displayedColor = this._displayedColor; + if (displayedColor.r === 255 && displayedColor.g === 255 && displayedColor.b === 255) { + if (this._colorized) { + this._colorized = false; + node.texture = this._originalTexture; + } + return; + } + + var locElement, locTexture = node._texture, locRect = this._textureCoord; + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + this._colorized = true; if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor && this._originalTexture._htmlElementObj != locElement) @@ -214,8 +226,8 @@ node.texture = locTexture; } } - } - }; + }; + } proto.getQuad = function () { //throw an error. it doesn't support this function. @@ -270,24 +282,20 @@ }; proto._spriteFrameLoadedCallback = function (spriteFrame) { - var _t = this; - _t.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - - //TODO change - var curColor = _t.getColor(); - if (curColor.r !== 255 || curColor.g !== 255 || curColor.b !== 255) - _t._updateColor(); + var node = this; + node.setTextureRect(spriteFrame.getRect(), spriteFrame.isRotated(), spriteFrame.getOriginalSize()); - _t.dispatchEvent("load"); + node._renderCmd._updateColor(); + node.dispatchEvent("load"); }; proto._textureLoadedCallback = function (sender) { - var _t = this; - if (_t._textureLoaded) + var node = this; + if (node._textureLoaded) return; - _t._textureLoaded = true; - var locRect = _t._rect, locRenderCmd = this._renderCmd; + node._textureLoaded = true; + var locRect = node._rect, locRenderCmd = this._renderCmd; if (!locRect) { locRect = cc.rect(0, 0, sender.width, sender.height); } else if (cc._rectEqualToZero(locRect)) { @@ -296,8 +304,8 @@ } locRenderCmd._originalTexture = sender; - _t.texture = sender; - _t.setTextureRect(locRect, _t._rectRotated); + node.texture = sender; + node.setTextureRect(locRect, node._rectRotated); //set the texture's color after the it loaded var locColor = locRenderCmd._displayedColor; @@ -306,8 +314,8 @@ // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" - _t.setBatchNode(_t._batchNode); - _t.dispatchEvent("load"); + node.setBatchNode(node._batchNode); + node.dispatchEvent("load"); }; proto._setTextureCoords = function (rect, needConvert) { @@ -320,6 +328,12 @@ locTextureRect.width = 0 | (rect.width * scaleFactor); locTextureRect.height = 0 | (rect.height * scaleFactor); locTextureRect.validRect = !(locTextureRect.width === 0 || locTextureRect.height === 0 || locTextureRect.x < 0 || locTextureRect.y < 0); + + if(this._colorized){ + this._node._texture = this._originalTexture; + this._colorized = false; + this._updateColor(); + } }; //TODO need refactor these functions From 7449900bb735a55710587159f2c3a9d3c9e2c987 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 4 Jan 2015 10:09:07 +0800 Subject: [PATCH 1131/1564] Issue #2563: add action parser --- extensions/cocostudio/reader/loader/load.js | 18 +++++++----- .../reader/loader/parsers/action-2.x.js | 29 +++++++++++++++++++ moduleConfig.json | 1 + 3 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 extensions/cocostudio/reader/loader/parsers/action-2.x.js diff --git a/extensions/cocostudio/reader/loader/load.js b/extensions/cocostudio/reader/loader/load.js index 9bcca3bea0..47be300a21 100644 --- a/extensions/cocostudio/reader/loader/load.js +++ b/extensions/cocostudio/reader/loader/load.js @@ -3,7 +3,7 @@ ccs.loadNode = (function(){ /** * load file * @param file - * @param type - ui|timeline|action + * @param type - ccui|node|action * @returns {*} */ var load = function(file, type){ @@ -19,12 +19,16 @@ ccs.loadNode = (function(){ // Judging the parser (uiParse or timelineParse, Temporarily blank) // The judgment condition is unknown var parse; - if(json["widgetTree"]) - parse = parser["ccui"]; - else if(json["nodeTree"]) - parse = parser["timeline"]; - else if(json["Content"]) - parse = parser["timeline"]; + if(!type){ + if(json["widgetTree"]) + parse = parser["ccui"]; + else if(json["nodeTree"]) + parse = parser["timeline"]; + else if(json["Content"]) + parse = parser["timeline"]; + }else{ + parse = parser[type]; + } if(!parse){ cc.log("Can't find the parser : %s", file); diff --git a/extensions/cocostudio/reader/loader/parsers/action-2.x.js b/extensions/cocostudio/reader/loader/parsers/action-2.x.js new file mode 100644 index 0000000000..b9a77f41c8 --- /dev/null +++ b/extensions/cocostudio/reader/loader/parsers/action-2.x.js @@ -0,0 +1,29 @@ +(function(load, baseParser){ + + var Parser = baseParser.extend({ + + getNodeJson: function(json){ + return json["Content"]["Content"]["Animation"]; + }, + + parseNode: function(json, resourcePath, file){ + var self = this; + //The process of analysis + var timelines = json["Timelines"]; + timelines.forEach(function(timeline){ + var parser = self.parsers[timeline["FrameType"]]; + parser.call(self, timeline, resourcePath); + }); + return new cc.Action(); + } + + }); + var parser = new Parser(); + + parser.registerParser("RotationSkewFrame", function(options, resourcePath){ + + }); + + load.registerParser("action", "2.*", parser); + +})(ccs.loadNode, ccs._parser); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 02530f0941..cca3b2c9e9 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -400,6 +400,7 @@ "extensions/cocostudio/reader/loader/load.js", "extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js", + "extensions/cocostudio/reader/loader/parsers/action-2.x.js", "extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js", "extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js" From b1e42e1218d2b87b7e093bb48c8a340580beeeb3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sun, 4 Jan 2015 17:52:52 +0800 Subject: [PATCH 1132/1564] Fixed #2517: fixed a bug of cc.PhysicsSprite that its position is incorrect --- cocos2d/physics/CCPhysicsSprite.js | 2 +- cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js | 15 ++++++--------- cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js | 1 - external/chipmunk/chipmunk.js | 1 + 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index d415a281c5..913b8726e6 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -59,7 +59,7 @@ * var spriteFrame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); * var physicsSprite = new cc.PhysicsSprite(spriteFrame); * - * 4.Creates a sprite with an exsiting texture contained in a CCTexture2D object + * 4.Creates a sprite with an existing texture contained in a CCTexture2D object * After creation, the rect will be the size of the texture, and the offset will be (0,0). * var texture = cc.textureCache.addImage("HelloHTML5World.png"); * var physicsSprite1 = new cc.PhysicsSprite(texture); diff --git a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js index f8a589c455..cb67531c89 100644 --- a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js @@ -38,20 +38,17 @@ // This is a special class // Sprite can not obtain sign // So here must to calculate of each frame - if (this._node.transform) - this._node.transform(); + var node = this._node; + node._syncPosition(); + if(!node._ignoreBodyRotation) + node._syncRotation(); + this.transform(this.getParentRenderCmd()); + cc.Sprite.CanvasRenderCmd.prototype.rendering.call(this, ctx, scaleX, scaleY); }; proto.getNodeToParentTransform = function(){ var node = this._node; - if(node._usingNormalizedPosition && node._parent){ //TODO need refactor - var conSize = node._parent._contentSize; - node._position.x = node._normalizedPosition.x * conSize.width; - node._position.y = node._normalizedPosition.y * conSize.height; - node._normalizedPositionDirty = false; - } - var t = this._transform;// quick reference // base position diff --git a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js index 44847d998b..893c272953 100644 --- a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js @@ -38,7 +38,6 @@ // This is a special class // Sprite can not obtain sign // So here must to calculate of each frame - var node = this._node; node._syncPosition(); if(!node._ignoreBodyRotation) diff --git a/external/chipmunk/chipmunk.js b/external/chipmunk/chipmunk.js index 6f2fc2b459..0fb3aeaa68 100644 --- a/external/chipmunk/chipmunk.js +++ b/external/chipmunk/chipmunk.js @@ -1575,6 +1575,7 @@ var createStaticBody = function() return body; }; + cp.StaticBody = createStaticBody; if (typeof DEBUG !== 'undefined' && DEBUG) { var v_assert_nan = function(v, message){assert(v.x == v.x && v.y == v.y, message); }; From dae1062ee80c2f51a86d840b618e2f42470f2199 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 Jan 2015 14:44:33 +0800 Subject: [PATCH 1133/1564] Issue #2563: Fix reader bug and moving file --- .../cocostudio/{reader => }/loader/load.js | 16 +- .../{reader => }/loader/parsers/action-2.x.js | 2 +- .../loader/parsers/timelineParser-1.x.js | 2 +- .../loader/parsers/timelineParser-2.x.js | 296 +++++++++++++----- .../loader/parsers/uiParser-1.x.js | 2 +- moduleConfig.json | 10 +- 6 files changed, 230 insertions(+), 98 deletions(-) rename extensions/cocostudio/{reader => }/loader/load.js (89%) rename extensions/cocostudio/{reader => }/loader/parsers/action-2.x.js (96%) rename extensions/cocostudio/{reader => }/loader/parsers/timelineParser-1.x.js (99%) rename extensions/cocostudio/{reader => }/loader/parsers/timelineParser-2.x.js (79%) rename extensions/cocostudio/{reader => }/loader/parsers/uiParser-1.x.js (99%) diff --git a/extensions/cocostudio/reader/loader/load.js b/extensions/cocostudio/loader/load.js similarity index 89% rename from extensions/cocostudio/reader/loader/load.js rename to extensions/cocostudio/loader/load.js index 47be300a21..dbda4dffe7 100644 --- a/extensions/cocostudio/reader/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -1,4 +1,4 @@ -ccs.loadNode = (function(){ +ccs._load = (function(){ /** * load file @@ -24,7 +24,7 @@ ccs.loadNode = (function(){ parse = parser["ccui"]; else if(json["nodeTree"]) parse = parser["timeline"]; - else if(json["Content"]) + else if(json["Content"] && json["Content"]["Content"]) parse = parser["timeline"]; }else{ parse = parser[type]; @@ -41,7 +41,7 @@ ccs.loadNode = (function(){ return new cc.Node(); } - return currentParser.parse(file, json) || new cc.Node(); + return currentParser.parse(file, json) || null; }; var parser = { @@ -88,6 +88,16 @@ ccs.loadNode = (function(){ })(); +//cc.loader.register(["json", "ExportJson"], { +// load: function(realUrl, url, res, cb){ +// var cloader = cc.loader; +// if(cloader.cache[url]){ +// console.log(url) +// }else{ +// return cc.loader.loadJson(realUrl, cb); +// } +// } +//}); ccs._parser = cc.Class.extend({ diff --git a/extensions/cocostudio/reader/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js similarity index 96% rename from extensions/cocostudio/reader/loader/parsers/action-2.x.js rename to extensions/cocostudio/loader/parsers/action-2.x.js index b9a77f41c8..765cdfe171 100644 --- a/extensions/cocostudio/reader/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -26,4 +26,4 @@ load.registerParser("action", "2.*", parser); -})(ccs.loadNode, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js similarity index 99% rename from extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js rename to extensions/cocostudio/loader/parsers/timelineParser-1.x.js index 7da3666f2a..8cf3976b37 100644 --- a/extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -253,4 +253,4 @@ load.registerParser("timeline", "1.*", parser); -})(ccs.loadNode, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js similarity index 79% rename from extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js rename to extensions/cocostudio/loader/parsers/timelineParser-2.x.js index da557de0b0..9043c69c4b 100644 --- a/extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -6,7 +6,7 @@ parse: function(file, json){ var resourcePath = this._dirname(file); - this.pretreatment(json, resourcePath); + this.pretreatment(json, resourcePath, file); var node = this.parseNode(this.getNodeJson(json), resourcePath); this.deferred(json, resourcePath, node, file); return node; @@ -32,7 +32,7 @@ pretreatment: function(json, resourcePath, file){ this.addSpriteFrame(json["textures"], json["texturesPng"], resourcePath); - ccs.actionTimelineCache.loadAnimationActionWithContent(file, json); +// ccs.actionTimelineCache.loadAnimationActionWithContent(file, json); } }); @@ -62,16 +62,21 @@ var rotationSkewX = json["RotationSkewX"]; if (rotationSkewX != null) node.setRotationX(rotationSkewX); - //rotationSkewX + var rotationSkewY = json["RotationSkewY"]; if (json["RotationSkewY"] != null) node.setRotationY(rotationSkewY); - //rotationSkewY - //todo check it + var anchor = json["AnchorPoint"]; - if(anchor && (anchor["ScaleX"] || anchor["ScaleY"])) - node.setAnchorPoint(cc.p(anchor["ScaleX"]||0.5, anchor["ScaleY"]||0.5)); + if(anchor != null){ + if(anchor["ScaleX"] == null) + anchor["ScaleX"] = 0; + if(anchor["ScaleY"] == null) + anchor["ScaleY"] = 0; + if(anchor["ScaleX"] != 0.5 || anchor["ScaleY"] != 0.5) + node.setAnchorPoint(cc.p(anchor["ScaleX"], anchor["ScaleY"])); + } if (json["ZOrder"] != null) node.setLocalZOrder(json["ZOrder"]); @@ -87,9 +92,6 @@ if (json["Alpha"] != null) node.setOpacity(json["Alpha"]); - var color = json["CColor"]; - if(color != null && (color["R"] != null || color["G"] != null || color["B"] != null)) - node.setColor(cc.color(color["R"]||255, color["G"]||255, color["B"]||255)); if (json["Tag"] != null) node.setTag(json["Tag"]); @@ -151,10 +153,14 @@ parser.initSprite = function(json, resourcePath){ var node = new cc.Sprite(); - this.generalAttributes(node, json); - loadTexture(json["FileData"], resourcePath, function(path, type){ - node.setTexture(path); + if(type == 0) + node.setTexture(path); + else if(type == 1){ + var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); + node.setSpriteFrame(spriteFrame); + } + }); if(json["FlipX"]) @@ -162,21 +168,29 @@ if(json["FlipY"]) node.setFlippedY(true); + this.generalAttributes(node, json); + var color = json["CColor"]; + if(color != null) + node.setColor(getColor(color)); + return node; }; /** * Particle * @param json + * @param resourcePath * @returns {*} */ - parser.initParticle = function(json){ - var fileData = json["FileData"]; - var node; - if(fileData){ - node = new cc.ParticleSystem(); - this.generalAttributes(node, json); - } + parser.initParticle = function(json, resourcePath){ + var node, + self = this; + loadTexture(json["FileData"], resourcePath, function(path, type){ + if(!cc.loader.getRes(path)) + cc.log("%s need to pre load", path); + node = new cc.ParticleSystem(path); + self.generalAttributes(node, json); + }); return node; }; @@ -202,7 +216,7 @@ var rotationSkewY = json["RotationSkewY"]; if(rotationSkewY) - widget.setRotationX(rotationSkewY); + widget.setRotationY(rotationSkewY); //var rotation = json["Rotation"]; @@ -232,9 +246,9 @@ if(tag != null) widget.setTag(tag); - var touchEnabled = json["TouchEnabled"]; - if(touchEnabled != null) - widget.setTouchEnabled(touchEnabled); + var touchEnabled = json["TouchEnable"]; + if(touchEnabled) + widget.setTouchEnabled(true); // -- var frameEvent = json["FrameEvent"]; @@ -261,12 +275,12 @@ widget.setAnchorPoint(anchorPoint["ScaleX"] || 0.5, anchorPoint["ScaleY"] || 0.5); var color = json["CColor"]; - if(color != null && color["R"] != null &&color["G"] != null &&color["B"] != null) - widget.setColor(color["R"], color["G"], color["B"]); -// -// var size = json["Size"]; -// if(size != null) -// widget.setContentSize(size["X"]||0, size["Y"]||0); + if(color != null) + widget.setColor(getColor(color)); + + var size = json["Size"]; + if(size != null) + widget.setContentSize(size["X"]||0, size["Y"]||0); if(widget instanceof ccui.Layout){ //todo update UILayoutComponent.bindLayoutComponent @@ -329,20 +343,12 @@ var bgStartColor = json["FirstColor"]; var bgEndColor = json["EndColor"]; if(bgStartColor != null && bgEndColor != null){ - bgStartColor["R"] == undefined && (bgStartColor["R"] = 255); - bgStartColor["G"] == undefined && (bgStartColor["G"] = 255); - bgStartColor["B"] == undefined && (bgStartColor["B"] = 255); - bgEndColor["R"] == undefined && (bgEndColor["R"] = 255); - bgEndColor["G"] == undefined && (bgEndColor["G"] = 255); - bgEndColor["B"] == undefined && (bgEndColor["B"] = 255); widget.setBackGroundColor( - cc.color(bgStartColor["R"], bgStartColor["G"], bgStartColor["B"]), - cc.color(bgEndColor["R"], bgEndColor["G"], bgEndColor["B"]) + getColor(bgStartColor), + getColor(bgEndColor) ); } - - var colorVector = json["ColorVector"]; if(colorVector != null) colorVector["ScaleX"]; @@ -412,14 +418,19 @@ //todo check it var isCustomSize = json["IsCustomSize"]; - widget.ignoreContentAdaptWithSize(!isCustomSize); + if(isCustomSize != null) + widget.ignoreContentAdaptWithSize(!isCustomSize); - var path, resoutceType, plistFile; + //todo check it var fontResource = json["FontResource"]; if(fontResource != null){ - path = fontResource["Path"]; - resoutceType = fontResource["Type"]; - plistFile = fontResource["Plist"]; + var path = fontResource["Path"]; + //resoutceType = fontResource["Type"]; + if(path != null){ + fontName = path.match(/([^\/]+)\.ttf/); + fontName = fontName ? fontName[1] : ""; + widget.setFontName(fontName); + } } widget.setUnifySizeEnabled(false); @@ -486,27 +497,18 @@ } var textColor = json["TextColor"]; - if(textColor != null){ - textColor["R"] = textColor["R"] != null ? textColor["R"] : 255; - textColor["G"] = textColor["G"] != null ? textColor["G"] : 255; - textColor["B"] = textColor["B"] != null ? textColor["B"] : 255; - widget.setTitleColor(cc.color(textColor["R"], textColor["G"], textColor["B"])); - } + if(textColor != null) + widget.setTitleColor(getColor(textColor)); - var dataList = [ - {json: json["DisabledFileData"], handle: function(path, type){ - widget.loadTextureDisabled(path, type); - }}, - {json: json["PressedFileData"], handle: function(path, type){ - widget.loadTexturePressed(path, type); - }}, - {json: json["NormalFileData"], handle: function(path, type){ - widget.loadTextureNormal(path, type); - }} - ]; - dataList.forEach(function(item){ - loadTexture(item.json, resourcePath, item.handle); + loadTexture(json["NormalFileData"], resourcePath, function(path, type){ + widget.loadTextureNormal(path, type); + }); + loadTexture(json["PressedFileData"], resourcePath, function(path, type){ + widget.loadTexturePressed(path, type); + }); + loadTexture(json["DisabledFileData"], resourcePath, function(path, type){ + widget.loadTextureDisabled(path, type); }); //var fontResourcePath, fontResourceResourceType, fontResourcePlistFile; @@ -681,6 +683,9 @@ loadTexture(json["FileData"], resourcePath, function(path, type){ widget.loadTexture(path, type); }); + loadTexture(json["ImageFileData"], resourcePath, function(path, type){ + widget.loadTexture(path, type); + }); return widget; }; @@ -697,16 +702,17 @@ this.widgetAttributes(widget, json); - var direction = json["ProgressType"] == "Left_To_Right" ? 0 : 1; - widget.setDirection(direction); - - var percent = json["ProgressInfo"] != null ? json["ProgressInfo"] : 0; - widget.setPercent(percent); - loadTexture(json["ImageFileData"], resourcePath, function(path, type){ widget.loadTexture(path, type); }); + var direction = json["ProgressType"]; + widget.setDirection((direction != "Left_To_Right") | 0); + + var percent = json["ProgressInfo"]; + if(percent != null) + widget.setPercent(percent); + return widget; }; @@ -719,35 +725,46 @@ parser.initSlider = function(json, resourcePath){ var widget = new ccui.Slider(); + var loader = cc.loader, + cache = cc.spriteFrameCache; this.widgetAttributes(widget, json); - var percent = json["PercentInfo"]; - if(percent != null) - widget.setPercent(percent); - - var displaystate = json["DisplayState"]; - if(displaystate != null){ - widget.setBright(displaystate); - widget.setEnabled(displaystate); - } - loadTexture(json["BackGroundData"], resourcePath, function(path, type){ + if(type == 0 && !loader.getRes(path)) + cc.log("%s need to pre load", path); widget.loadBarTexture(path, type); }); loadTexture(json["BallNormalData"], resourcePath, function(path, type){ + if(type == 0 && !loader.getRes(path)) + cc.log("%s need to pre load", path); widget.loadSlidBallTextureNormal(path, type); }); loadTexture(json["BallPressedData"], resourcePath, function(path, type){ + if(type == 0 && !loader.getRes(path)) + cc.log("%s need to pre load", path); widget.loadSlidBallTexturePressed(path, type); }); loadTexture(json["BallDisabledData"], resourcePath, function(path, type){ + if(type == 0 && !loader.getRes(path)) + cc.log("%s need to pre load", path); widget.loadSlidBallTextureDisabled(path, type); }); loadTexture(json["ProgressBarData"], resourcePath, function(path, type){ + if(type == 0 && !loader.getRes(path)) + cc.log("%s need to pre load", path); widget.loadProgressBarTexture(path, type); }); + var percent = json["PercentInfo"]; + if(percent != null) + widget.setPercent(percent); + + var displaystate = json["DisplayState"]; + if(displaystate != null){ + widget.setBright(displaystate); + widget.setEnabled(displaystate); + } return widget; }; @@ -901,6 +918,103 @@ return widget; }; + parser.initTextAtlas = function(json, resourcePath){ + + var widget = new ccui.TextAtlas(); + + var stringValue = json["LabelText"]; + var itemWidth = json["CharWidth"]; + var itemHeight = json["CharHeight"]; + + var startCharMap = json["StartChar"]; + + loadTexture(json["LabelAtlasFileImage_CNB"], resourcePath, function(path, type){ + if(!cc.loader.getRes(path)) + cc.log("%s need to pre load", path); + if(type == 0){ + widget.setProperty(stringValue, path, itemWidth, itemHeight, startCharMap); + } + }); + this.widgetAttributes(widget, json); + + return widget; + }; + + parser.initTextBMFont = function(json, resourcePath){ + + var widget = new ccui.TextBMFont(); + this.widgetAttributes(widget, json); + + var text = json["LabelText"]; + widget.setString(text); + + loadTexture(json["LabelBMFontFile_CNB"], resourcePath, function(path, type){ + widget.setFntFile(path); + }); + return widget; + }; + + parser.initTextField = function(json, resourcePath){ + var widget = new ccui.TextField(); + + var passwordEnabled = json["PasswordEnable"]; + if(passwordEnabled){ + widget.setPasswordEnabled(true); + var passwordStyleText = json["PasswordStyleText"]; + if(passwordStyleText != null) + widget.setPasswordStyleText(passwordStyleText); + } + + var placeHolder = json["PlaceHolderText"]; + if(placeHolder != null) + widget.setPlaceHolder(placeHolder); + + var fontSize = json["FontSize"]; + if(fontSize != null) + widget.setFontSize(fontSize); + + var fontName = json["FontName"]; + if(fontName != null) + widget.setFontName(fontName); + + var maxLengthEnabled = json["MaxLengthEnable"]; + if(maxLengthEnabled){ + widget.setMaxLengthEnabled(true); + var maxLength = json["MaxLengthText"]; + if(maxLength != null) + widget.setMaxLength(maxLength); + } + + //var isCustomSize = json["IsCustomSize"]; + this.widgetAttributes(widget, json); + + var text = json["LabelText"]; + if(text != null) + widget.setString(text); + + loadTexture(json["FontResource"], resourcePath, function(path, type){ + widget.setFontName(path); + }); + + widget.setUnifySizeEnabled(false); + widget.ignoreContentAdaptWithSize(false); + + var color = json["CColor"]; + if(color != null) + widget.setTextColor(getColor(color)); + + if (!widget.isIgnoreContentAdaptWithSize()) + { + //widget.getVirtualRenderer().setLineBreakWithoutSpace(true); + var size = json["Size"]; + if(size) + widget.setContentSize(cc.size(size["X"] || 0, size["Y"] || 0)); + } + return widget; + + }; + + var loadedPlist = {}; var loadTexture = function(json, resourcePath, cb){ if(json != null){ var path = json["Path"]; @@ -910,8 +1024,15 @@ else type = 1; var plist = json["Plist"]; - if(plist) - cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); + if(plist){ + if(cc.loader.getRes(resourcePath + plist)){ + loadedPlist[resourcePath + plist] = true; + cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); + }else{ + if(!loadedPlist[resourcePath + plist]) + cc.log("%s need to pre load", resourcePath + plist); + } + } if(type !== 0) cb(path, type); else @@ -924,11 +1045,9 @@ var r = json["R"] != null ? json["R"] : 255; var g = json["G"] != null ? json["G"] : 255; var b = json["B"] != null ? json["B"] : 255; - return cc.size(r, g, b); + return cc.color(r, g, b); }; - - var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, {name: "SpriteObjectData", handle: parser.initSprite}, @@ -942,7 +1061,10 @@ {name: "LoadingBarObjectData", handle: parser.initLoadingBar}, {name: "SliderObjectData", handle: parser.initSlider}, {name: "PageViewObjectData", handle: parser.initPageView}, - {name: "ListViewObjectData", handle: parser.initListView} + {name: "ListViewObjectData", handle: parser.initListView}, + {name: "TextAtlasObjectData", handle: parser.initTextAtlas}, + {name: "TextBMFontObjectData", handle: parser.initTextBMFont}, + {name: "TextFieldObjectData", handle: parser.initTextField} ]; register.forEach(function(item){ @@ -958,4 +1080,4 @@ load.registerParser("timeline", "2.*", parser); -})(ccs.loadNode, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js similarity index 99% rename from extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js rename to extensions/cocostudio/loader/parsers/uiParser-1.x.js index 20628505c2..ef3a5b1e03 100644 --- a/extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -797,4 +797,4 @@ load.registerParser("ccui", "1.*", parser); -})(ccs.loadNode, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index cca3b2c9e9..2f3df9fca6 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -398,11 +398,11 @@ "extensions/cocostudio/reader/timeline/Timeline.js", "extensions/cocostudio/reader/timeline/CSLoader.js", - "extensions/cocostudio/reader/loader/load.js", - "extensions/cocostudio/reader/loader/parsers/uiParser-1.x.js", - "extensions/cocostudio/reader/loader/parsers/action-2.x.js", - "extensions/cocostudio/reader/loader/parsers/timelineParser-1.x.js", - "extensions/cocostudio/reader/loader/parsers/timelineParser-2.x.js" + "extensions/cocostudio/loader/load.js", + "extensions/cocostudio/loader/parsers/uiParser-1.x.js", + "extensions/cocostudio/loader/parsers/action-2.x.js", + "extensions/cocostudio/loader/parsers/timelineParser-1.x.js", + "extensions/cocostudio/loader/parsers/timelineParser-2.x.js" ], From ec65e22b8eb6cab2d0a7ee51903b9bdbce2efd00 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 Jan 2015 15:08:42 +0800 Subject: [PATCH 1134/1564] this._shaderProgram is not initialized --- cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js index 4e6a863ac6..1d358bc78c 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js @@ -52,7 +52,8 @@ proto.rendering = function (ctx) { var context = ctx || cc._renderContext, node = this._node; - + if(!this._shaderProgram) + return; this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); From e3570f752382031a3348c77ac6a6b137a05f8fc3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 Jan 2015 15:59:16 +0800 Subject: [PATCH 1135/1564] Issue #2563: add audio | project | armature --- .../loader/parsers/timelineParser-2.x.js | 58 ++++++++++++++++++- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 9043c69c4b..837e6b7dd1 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -104,7 +104,7 @@ }; parser.parseChild = function(node, children, resourcePath){ - if(!children) return; + if(!node || !children) return; for (var i = 0; i < children.length; i++) { var child = this.parseNode(children[i], resourcePath); if(child){ @@ -1014,6 +1014,54 @@ }; + parser.initSimpleAudio = function(json, resourcePath){ + + var loop = json["Loop"]; + var volume = json["Volume"]; + if(volume != null) + cc.audioEngine.setMusicVolume(volume); + //var name = json["Name"]; + var resPath = (cc.loader.resPath + "/").replace(/\/\/$/, "/"); + loadTexture(json["FileData"], resourcePath, function(path, type){ + cc.loader.load(path, function(){ + cc.audioEngine.playMusic(resPath + path, loop); + }); + }); + + }; + + parser.initGameMap = function(json, resourcePath){ + + var node = null; + + loadTexture(json["FileData"], resourcePath, function(path, type){ + if(type == 0) + node = new cc.TMXTiledMap(path); + }); + + return node; + }; + + parser.initProjectNode = function(json, resourcePath){ + return ccs._load(json); + }; + + parser.initArmature = function(json, resourcePath){ + + var node = new ccs.Armature(); + + var isLoop = json["isLoop"]; + + var isAutoPlay = json["IsAutoPlay"]; + + var currentAnimationName = json["CurrentAnimationName"]; + + loadTexture(json["FileData"], resourcePath, function(path, type){ + ccs.ArmatureDataManager.addArmatureFileInfo(path); + }); + node.init(); + }; + var loadedPlist = {}; var loadTexture = function(json, resourcePath, cb){ if(json != null){ @@ -1064,14 +1112,18 @@ {name: "ListViewObjectData", handle: parser.initListView}, {name: "TextAtlasObjectData", handle: parser.initTextAtlas}, {name: "TextBMFontObjectData", handle: parser.initTextBMFont}, - {name: "TextFieldObjectData", handle: parser.initTextField} + {name: "TextFieldObjectData", handle: parser.initTextField}, + {name: "SimpleAudioObjectData", handle: parser.initSimpleAudio}, + {name: "GameMapObjectData", handle: parser.initGameMap}, + {name: "ProjectNodeObjectData", handle: parser.initProjectNode}, + {name: "ArmatureNodeObjectData", handle: parser.initArmature} ]; register.forEach(function(item){ parser.registerParser(item.name, function(options, parse, resourcePath){ var node = item.handle.call(this, options, resourcePath); this.parseChild(node, options["Children"], resourcePath); - DEBUG && (node.__parserName = item.name); + DEBUG && node && (node.__parserName = item.name); return node; }); }); From 289944ba93e087d281a8958a7af5680bc0dc18cb Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 5 Jan 2015 16:23:04 +0800 Subject: [PATCH 1136/1564] Issue #1267: refactor ccui's visit --- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 5 +- .../ccui/base-classes/CCProtectedNode.js | 10 --- .../CCProtectedNodeCanvasRenderCmd.js | 53 +++++++--------- .../CCProtectedNodeWebGLRenderCmd.js | 29 --------- extensions/ccui/base-classes/UIWidget.js | 59 +++++++----------- .../ccui/base-classes/UIWidgetRenderCmd.js | 62 +++++++++++++++++++ extensions/ccui/layouts/UILayout.js | 10 +-- .../ccui/layouts/UILayoutCanvasRenderCmd.js | 24 ++++++- .../ccui/layouts/UILayoutWebGLRenderCmd.js | 22 +++++++ extensions/ccui/uiwidgets/UIRichText.js | 12 +--- moduleConfig.json | 1 + tools/build.xml | 1 + 12 files changed, 162 insertions(+), 126 deletions(-) create mode 100644 extensions/ccui/base-classes/UIWidgetRenderCmd.js diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index 418d308abf..a7f3c6a24b 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -125,14 +125,13 @@ return; } - var _t = this, node = this._node; - var children = node._children; + var node = this._node, children = node._children; var len = children.length; // quick return if not visible if (!node._visible || len === 0) return; - _t._syncStatus(parentCmd); + this._syncStatus(parentCmd); cc.renderer.pushRenderCommand(this); //the bakeSprite is drawing diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index 891c66c7d6..c9f8d9f812 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -224,16 +224,6 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ } }, - /** - * transforms and draws itself, and visit its children and protected children. - * @override - * @function - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx context of renderer - */ - visit: function(parentCmd){ - this._renderCmd._visit(parentCmd); - }, - _changePosition: function(){}, /** diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 4f2d0725f8..1a1a34f113 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -113,6 +113,28 @@ } } this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty ^ this._dirtyFlag; + }, + + _changeProtectedChild: function (child) { + var cmd = child._renderCmd, + dirty = cmd._dirtyFlag, + flags = cc.Node._dirtyFlags; + + if (this._dirtyFlag & flags.colorDirty) + dirty |= flags.colorDirty; + + if (this._dirtyFlag & flags.opacityDirty) + dirty |= flags.opacityDirty; + + var colorDirty = dirty & flags.colorDirty, + opacityDirty = dirty & flags.opacityDirty; + + if (colorDirty) + cmd._updateDisplayColor(this._displayedColor); + if (opacityDirty) + cmd._updateDisplayOpacity(this._displayedOpacity); + if (colorDirty || opacityDirty) + cmd._updateColor(); } }; @@ -127,10 +149,6 @@ proto.constructor = cc.ProtectedNode.CanvasRenderCmd; proto.visit = function(parentCmd){ - this._node.visit(parentCmd); - }; - - proto._visit = function(parentCmd){ var node = this._node; // quick return if not visible if (!node._visible) @@ -147,7 +165,6 @@ node.sortAllChildren(); node.sortAllProtectedChildren(); - var pChild; // draw children zOrder < 0 for (i = 0; i < childLen; i++) { @@ -182,28 +199,6 @@ this._cacheDirty = false; }; - proto._changeProtectedChild = function(child){ - var cmd = child._renderCmd, - dirty = cmd._dirtyFlag, - flags = cc.Node._dirtyFlags; - - if(this._dirtyFlag & flags.colorDirty) - dirty |= flags.colorDirty; - - if(this._dirtyFlag & flags.opacityDirty) - dirty |= flags.opacityDirty; - - var colorDirty = dirty & flags.colorDirty, - opacityDirty = dirty & flags.opacityDirty; - - if(colorDirty) - cmd._updateDisplayColor(this._displayedColor); - if(opacityDirty) - cmd._updateDisplayOpacity(this._displayedOpacity); - if(colorDirty || opacityDirty) - cmd._updateColor(); - }; - proto.transform = function(parentCmd, recursive){ var node = this._node; @@ -224,8 +219,8 @@ worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty }else{ - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty + worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx + worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty } } else { worldT.a = t.a; diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index 559f788cf5..b4581dbaaf 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -25,8 +25,6 @@ (function(){ cc.ProtectedNode.WebGLRenderCmd = function (renderable) { cc.Node.WebGLRenderCmd.call(this, renderable); - this._cachedParent = null; - this._cacheDirty = false; }; var proto = cc.ProtectedNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); @@ -34,10 +32,6 @@ proto.constructor = cc.ProtectedNode.WebGLRenderCmd; proto.visit = function(parentCmd){ - this._node.visit(parentCmd); //todo refactor late - }; - - proto._visit = function(parentCmd){ var node = this._node; // quick return if not visible if (!node._visible) @@ -60,7 +54,6 @@ node.sortAllChildren(); node.sortAllProtectedChildren(); - var pChild; // draw children zOrder < 0 for (i = 0; i < childLen; i++) { @@ -99,28 +92,6 @@ currentStack.top = currentStack.stack.pop(); }; - proto._changeProtectedChild = function(child){ - var cmd = child._renderCmd, - dirty = cmd._dirtyFlag, - flags = cc.Node._dirtyFlags; - - if(this._dirtyFlag & flags.colorDirty) - dirty |= flags.colorDirty; - - if(this._dirtyFlag & flags.opacityDirty) - dirty |= flags.opacityDirty; - - var colorDirty = dirty & flags.colorDirty, - opacityDirty = dirty & flags.opacityDirty; - - if(colorDirty) - cmd._updateDisplayColor(this._displayedColor); - if(opacityDirty) - cmd._updateDisplayOpacity(this._displayedOpacity); - if(colorDirty || opacityDirty) - cmd._updateColor(); - }; - proto.transform = function(parentCmd, recursive){ var node = this._node; var t4x4 = this._transform4x4, stackMatrix = this._stackMatrix, diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index d078172802..67dc978fbb 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -156,25 +156,12 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ getOrCreateLayoutComponent: function(){ var layoutComponent = this.getComponent(ccui.__LAYOUT_COMPONENT_NAME); if (null == layoutComponent){ - var component = new ccui.LayoutComponent(); + layoutComponent = new ccui.LayoutComponent(); this.addComponent(component); - layoutComponent = component; } return layoutComponent; }, - /** - * Calls _adaptRenderers(its subClass will override it) before calls its parent's visit. - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx - * @override - */ - visit: function (ctx) { - if (this._visible) { - this._adaptRenderers(); - cc.ProtectedNode.prototype.visit.call(this, ctx); - } - }, - /** * The direct parent when it's a widget also, otherwise equals null * @returns {ccui.Widget|null} @@ -273,8 +260,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * initializes renderer of widget. */ - _initRenderer: function () { - }, + _initRenderer: function () {}, /** * Sets _customSize of ccui.Widget, if ignoreSize is true, the content size is its renderer's contentSize, otherwise the content size is parameter. @@ -690,8 +676,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @note it doesn't implemented on Web * @param {Boolean} enable set true to enable dpad focus navigation, otherwise disable dpad focus navigation */ - enableDpadNavigation: function(enable){ - }, + enableDpadNavigation: function(enable){}, /** *

    @@ -785,14 +770,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, - _onPressStateChangedToNormal: function () { - }, + _onPressStateChangedToNormal: function () {}, - _onPressStateChangedToPressed: function () { - }, + _onPressStateChangedToPressed: function () {}, - _onPressStateChangedToDisabled: function () { - }, + _onPressStateChangedToDisabled: function () {}, _updateChildrenDisplayedRGBA: function(){ this.setColor(this.getColor()); @@ -802,8 +784,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /** * A call back function when widget lost of focus. */ - didNotSelectSelf: function () { - }, + didNotSelectSelf: function () {}, /** *

    @@ -848,8 +829,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ propagateTouchEvent: function(event, sender, touch){ var widgetParent = this.getWidgetParent(); - if (widgetParent) - { + if (widgetParent){ widgetParent.interceptTouchEvent(event, sender, touch); } }, @@ -1192,14 +1172,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return this._flippedY; }, - _updateFlippedX: function () { - }, + _updateFlippedX: function () {}, - _updateFlippedY: function () { - }, + _updateFlippedY: function () {}, - _adaptRenderers: function(){ - }, + _adaptRenderers: function(){}, /** * Determines if the widget is bright @@ -1334,8 +1311,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, - _copySpecialProperties: function (model) { - }, + _copySpecialProperties: function (model) {}, _copyProperties: function (widget) { this.setEnabled(widget.isEnabled()); @@ -1558,11 +1534,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} [cleanup] */ removeNodeByTag: function (tag, cleanup) { - var node = this.getNodeByTag(tag); + var node = this.getChildByTag(tag); if (!node) cc.log("cocos2d: removeNodeByTag(tag = %d): child not found!", tag); else - this.removeNode(node); + this.removeChild(node, cleanup); }, /** @@ -1595,6 +1571,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ setUnifySizeEnabled: function(enable){ this._unifySize = enable; + }, + + _createRenderCmd: function(){ + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + return new ccui.Widget.WebGLRenderCmd(this); + else + return new ccui.Widget.CanvasRenderCmd(this); } }); diff --git a/extensions/ccui/base-classes/UIWidgetRenderCmd.js b/extensions/ccui/base-classes/UIWidgetRenderCmd.js new file mode 100644 index 0000000000..b042a4c8b8 --- /dev/null +++ b/extensions/ccui/base-classes/UIWidgetRenderCmd.js @@ -0,0 +1,62 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +if (cc._renderType === cc._RENDER_TYPE_CANVAS) { + (function () { + ccui.Widget.CanvasRenderCmd = function (renderable) { + cc.ProtectedNode.CanvasRenderCmd.call(this, renderable); + this._needDraw = false; + }; + + var proto = ccui.Widget.CanvasRenderCmd.prototype = Object.create(cc.ProtectedNode.CanvasRenderCmd.prototype); + proto.constructor = ccui.Widget.CanvasRenderCmd; + + proto.visit = function (parentCmd) { + var node = this._node; + if (node._visible) { + node._adaptRenderers(); + cc.ProtectedNode.CanvasRenderCmd.prototype.visit.call(this, parentCmd); + } + }; + })(); +} else { + (function () { + ccui.Widget.WebGLRenderCmd = function (renderable) { + cc.ProtectedNode.WebGLRenderCmd.call(this, renderable); + this._needDraw = false; + }; + + var proto = ccui.Widget.WebGLRenderCmd.prototype = Object.create(cc.ProtectedNode.WebGLRenderCmd.prototype); + proto.constructor = ccui.Widget.WebGLRenderCmd; + + proto.visit = function (parentCmd) { + var node = this._node; + if (node._visible) { + node._adaptRenderers(); + cc.ProtectedNode.WebGLRenderCmd.prototype.visit.call(this, parentCmd); + } + }; + })(); +} + diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 86f35681fc..7bd7f771a0 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -312,9 +312,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * If clippingEnabled is true, it will clip/scissor area. *

    * @override - * @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx + * @param {cc.Node.RenderCmd} [parentCmd] */ - visit: function (ctx) { + visit: function (parentCmd) { if (!this._visible) return; this._adaptRenderers(); @@ -323,16 +323,16 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._clippingEnabled) { switch (this._clippingType) { case ccui.Layout.CLIPPING_STENCIL: - this._renderCmd.stencilClippingVisit(ctx); + this._renderCmd.stencilClippingVisit(parentCmd); break; case ccui.Layout.CLIPPING_SCISSOR: - this._renderCmd.scissorClippingVisit(ctx); + this._renderCmd.scissorClippingVisit(parentCmd); break; default: break; } } else - ccui.Widget.prototype.visit.call(this, ctx); + ccui.Widget.prototype.visit.call(this, parentCmd); }, /** diff --git a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js index bdacc19a75..d3861d2573 100644 --- a/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js @@ -39,6 +39,28 @@ var proto = ccui.Layout.CanvasRenderCmd.prototype = Object.create(ccui.ProtectedNode.CanvasRenderCmd.prototype); proto.constructor = ccui.Layout.CanvasRenderCmd; + proto.visit = function(parentCmd){ + var node = this._node; + if (!node._visible) + return; + node._adaptRenderers(); + node._doLayout(); + + if (node._clippingEnabled) { + switch (node._clippingType) { + case ccui.Layout.CLIPPING_STENCIL: + this.stencilClippingVisit(parentCmd); + break; + case ccui.Layout.CLIPPING_SCISSOR: + this.scissorClippingVisit(parentCmd); + break; + default: + break; + } + } else + ccui.Widget.CanvasRenderCmd.prototype.visit.call(this, parentCmd); + }; + proto._onRenderSaveCmd = function(ctx, scaleX, scaleY){ var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); if (this._clipElemType) { @@ -60,8 +82,6 @@ //var node = this._node; if (this._clipElemType) { wrapper.setCompositeOperation("destination-in"); - //var parentCmd = node._parent ? node._parent._renderCmd : null; - //this.transform(parentCmd); //todo: why? } }; diff --git a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js index f2de94d980..4ec484d55e 100644 --- a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js @@ -50,6 +50,28 @@ var proto = ccui.Layout.WebGLRenderCmd.prototype = Object.create(ccui.ProtectedNode.WebGLRenderCmd.prototype); proto.constructor = ccui.Layout.WebGLRenderCmd; + proto.visit = function(parentCmd){ + var node = this._node; + if (!node._visible) + return; + node._adaptRenderers(); + node._doLayout(); + + if (node._clippingEnabled) { + switch (node._clippingType) { + case ccui.Layout.CLIPPING_STENCIL: + this.stencilClippingVisit(parentCmd); + break; + case ccui.Layout.CLIPPING_SCISSOR: + this.scissorClippingVisit(parentCmd); + break; + default: + break; + } + } else + ccui.Widget.WebGLRenderCmd.prototype.visit.call(this, parentCmd); + }; + proto._onBeforeVisitStencil = function(ctx){ var gl = ctx || cc._renderContext; diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 9e7069151b..6b44784902 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -463,16 +463,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._elementRenders[this._elementRenders.length - 1].push(renderer); }, - /** - * Calls formatText before calls parent class' visit. - * @override - * @param parentCmd - */ - visit: function (parentCmd) { - if (this._enabled) { - this.formatText(); - ccui.Widget.prototype.visit.call(this, parentCmd); - } + _adaptRenderers: function(){ + this.formatText(); }, /** diff --git a/moduleConfig.json b/moduleConfig.json index b5da63757a..8d8cb65595 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -300,6 +300,7 @@ "extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js", "extensions/ccui/system/CocosGUI.js", "extensions/ccui/base-classes/UIWidget.js", + "extensions/ccui/base-classes/UIWidgetRenderCmd.js", "extensions/ccui/base-classes/UIScale9Sprite.js", "extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js", "extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js", diff --git a/tools/build.xml b/tools/build.xml index b89f21f929..0881ff6395 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -202,6 +202,7 @@ + From 9cd641f72ebaf7bc88257c4a3b12a7dfc53a98ad Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 Jan 2015 16:31:01 +0800 Subject: [PATCH 1137/1564] Fix webgl cc.Director is undefined (Compression mode) --- tools/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build.xml b/tools/build.xml index b89f21f929..e602c3e0e0 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -74,8 +74,8 @@ - + From 887bdb07f42ab1aebc60bbb822ad06e625f0292e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 5 Jan 2015 17:31:56 +0800 Subject: [PATCH 1138/1564] Issue #2563: Finishing the code --- .../loader/parsers/timelineParser-2.x.js | 214 +++++++++--------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 837e6b7dd1..507de25e2d 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1,6 +1,6 @@ (function(load, baseParser){ - var DEBUG = true; + var DEBUG = false; var Parser = baseParser.extend({ @@ -18,21 +18,6 @@ getClass: function(json){ return json["ctype"]; - }, - - addSpriteFrame: function(textures, plists, resourcePath){ - if(!textures) return; - for (var i = 0; i < textures.length; i++) { - cc.spriteFrameCache.addSpriteFrames( - resourcePath + textures[i], - resourcePath + plists[i] - ); - } - }, - - pretreatment: function(json, resourcePath, file){ - this.addSpriteFrame(json["textures"], json["texturesPng"], resourcePath); -// ccs.actionTimelineCache.loadAnimationActionWithContent(file, json); } }); @@ -85,10 +70,7 @@ if (visible != null) node.setVisible(visible == "True"); - - var contentSize = json["Size"]; - if(contentSize != null && (contentSize["X"] != null || contentSize["Y"] != null)) - node.setContentSize(cc.size(contentSize["X"]||0, contentSize["Y"]||0)); + setContentSize(node, json["Size"]); if (json["Alpha"] != null) node.setOpacity(json["Alpha"]); @@ -148,6 +130,7 @@ /** * Sprite * @param json + * @param resourcePath * @returns {cc.Sprite} */ parser.initSprite = function(json, resourcePath){ @@ -278,9 +261,7 @@ if(color != null) widget.setColor(getColor(color)); - var size = json["Size"]; - if(size != null) - widget.setContentSize(size["X"]||0, size["Y"]||0); + setContentSize(widget, json["Size"]); if(widget instanceof ccui.Layout){ //todo update UILayoutComponent.bindLayoutComponent @@ -342,12 +323,8 @@ var bgStartColor = json["FirstColor"]; var bgEndColor = json["EndColor"]; - if(bgStartColor != null && bgEndColor != null){ - widget.setBackGroundColor( - getColor(bgStartColor), - getColor(bgEndColor) - ); - } + if(bgStartColor != null && bgEndColor != null) + widget.setBackGroundColor( getColor(bgStartColor), getColor(bgEndColor) ); var colorVector = json["ColorVector"]; if(colorVector != null) @@ -435,11 +412,8 @@ widget.setUnifySizeEnabled(false); - if(widget.isIgnoreContentAdaptWithSize()){ - var size = json["Size"]; - if(size != null) - widget.setContentSize(cc.size(size["X"]||0, size["Y"]||0)); - } + if(widget.isIgnoreContentAdaptWithSize()) + setContentSize(widget, json["Size"]); return widget; @@ -473,10 +447,7 @@ } - var size = json["Size"]; - if(size != null){ - widget.setContentSize(size["X"] || 0, size["Y"] || 0); - } + setContentSize(widget, json["Size"]); var text = json["ButtonText"]; if(text != null) @@ -511,13 +482,14 @@ widget.loadTextureDisabled(path, type); }); - //var fontResourcePath, fontResourceResourceType, fontResourcePlistFile; - //var fontResource = json["FontResource"]; - //if(fontResource != null){ + var fontResourcePath, fontResourceResourceType, fontResourcePlistFile; + var fontResource = json["FontResource"]; + if(fontResource != null){ + console.log(fontResource["Path"]) // fontResourcePath = fontResource["Path"]; // fontResourceResourceType = fontResource["Type"] == "Default" ? 0 : 1; // fontResourcePlistFile = fontResource["Plist"]; - //} + } return widget; @@ -545,25 +517,17 @@ } var dataList = [ - {json: json["NormalBackFileData"], handle: function(path, type){ - widget.loadTextureBackGround(path, type); - }}, - {json: json["PressedBackFileData"], handle: function(path, type){ - widget.loadTextureBackGroundSelected(path, type); - }}, - {json: json["NodeNormalFileData"], handle: function(path, type){ - widget.loadTextureFrontCross(path, type); - }}, - {json: json["DisableBackFileData"], handle: function(path, type){ - widget.loadTextureBackGroundDisabled(path, type); - }}, - {json: json["NodeDisableFileData"], handle: function(path, type){ - widget.loadTextureFrontCrossDisabled(path, type); - }} + {name: "NormalBackFileData", handle: widget.loadTextureBackGround}, + {name: "PressedBackFileData", handle: widget.loadTextureBackGroundSelected}, + {name: "NodeNormalFileData", handle: widget.loadTextureFrontCross}, + {name: "DisableBackFileData", handle: widget.loadTextureBackGroundDisabled}, + {name: "NodeDisableFileData", handle: widget.loadTextureFrontCrossDisabled} ]; dataList.forEach(function(item){ - loadTexture(item.json, resourcePath, item.handle); + loadTexture(json[item.name], resourcePath, function(path, type){ + item.handle.call(widget, path, type); + }); }); return widget; @@ -602,11 +566,8 @@ var scale9Width = json["Scale9Width"]; var scale9Height = json["Scale9Height"]; - var scale9Size = json["Size"]; - if(scale9Size){ - scale9Size = cc.size(scale9Size["X"] || 0, scale9Size["Y"] || 0); - } - + //todo please check it + setContentSize(widget, json["Size"]); if(json["FirstColor"] && json["EndColor"]){ var bgStartColor, bgEndColor; @@ -676,9 +637,7 @@ )); } - var scale9Size = json["Size"]; - if(scale9Size) - widget.setContentSize(cc.size(scale9Size["X"] || 0, scale9Size["Y"] || 0)); + setContentSize(widget, json["Size"]); loadTexture(json["FileData"], resourcePath, function(path, type){ widget.loadTexture(path, type); @@ -691,7 +650,7 @@ }; /** - * + * LoadingBar * @param json * @param resourcePath * @returns {ccui.LoadingBar} @@ -718,42 +677,30 @@ }; /** - * + * Slider * @param json * @param resourcePath */ parser.initSlider = function(json, resourcePath){ var widget = new ccui.Slider(); - var loader = cc.loader, - cache = cc.spriteFrameCache; + var loader = cc.loader; this.widgetAttributes(widget, json); - loadTexture(json["BackGroundData"], resourcePath, function(path, type){ - if(type == 0 && !loader.getRes(path)) - cc.log("%s need to pre load", path); - widget.loadBarTexture(path, type); - }); - loadTexture(json["BallNormalData"], resourcePath, function(path, type){ - if(type == 0 && !loader.getRes(path)) - cc.log("%s need to pre load", path); - widget.loadSlidBallTextureNormal(path, type); - }); - loadTexture(json["BallPressedData"], resourcePath, function(path, type){ - if(type == 0 && !loader.getRes(path)) - cc.log("%s need to pre load", path); - widget.loadSlidBallTexturePressed(path, type); - }); - loadTexture(json["BallDisabledData"], resourcePath, function(path, type){ - if(type == 0 && !loader.getRes(path)) - cc.log("%s need to pre load", path); - widget.loadSlidBallTextureDisabled(path, type); - }); - loadTexture(json["ProgressBarData"], resourcePath, function(path, type){ - if(type == 0 && !loader.getRes(path)) - cc.log("%s need to pre load", path); - widget.loadProgressBarTexture(path, type); + var textureList = [ + {name: "BackGroundData", handle: widget.loadBarTexture}, + {name: "BallNormalData", handle: widget.loadSlidBallTextureNormal}, + {name: "BallPressedData", handle: widget.loadSlidBallTexturePressed}, + {name: "BallDisabledData", handle: widget.loadSlidBallTextureDisabled}, + {name: "ProgressBarData", handle: widget.loadProgressBarTexture} + ]; + textureList.forEach(function(item){ + loadTexture(json[item.name], resourcePath, function(path, type){ + if(type == 0 && !loader.getRes(path)) + cc.log("%s need to pre load", path); + item.handle.call(widget, path, type); + }); }); var percent = json["PercentInfo"]; @@ -770,7 +717,7 @@ }; /** - * + * PageView * @param json * @param resourcePath */ @@ -822,14 +769,18 @@ widget.setBackGroundImage(path, type); }); - var size = json["Size"]; - if(size != null) - widget.setContentSize(size["X"], size["Y"]); + setContentSize(widget, json["Size"]); return widget; }; + /** + * ListView + * @param json + * @param resourcePath + * @returns {ccui.ListView} + */ parser.initListView = function(json, resourcePath){ var widget = new ccui.ListView(); @@ -911,13 +862,17 @@ widget.setBackGroundImage(path, type); }); - var size = json["Size"]; - if(size != null) - widget.setContentSize(size["X"]||0, size["Y"]||0); + setContentSize(widget, json["Size"]); return widget; }; + /** + * TextAtlas + * @param json + * @param resourcePath + * @returns {ccui.TextAtlas} + */ parser.initTextAtlas = function(json, resourcePath){ var widget = new ccui.TextAtlas(); @@ -940,6 +895,12 @@ return widget; }; + /** + * TextBMFont + * @param json + * @param resourcePath + * @returns {ccui.TextBMFont} + */ parser.initTextBMFont = function(json, resourcePath){ var widget = new ccui.TextBMFont(); @@ -954,6 +915,12 @@ return widget; }; + /** + * TextField + * @param json + * @param resourcePath + * @returns {ccui.TextField} + */ parser.initTextField = function(json, resourcePath){ var widget = new ccui.TextField(); @@ -1004,16 +971,18 @@ widget.setTextColor(getColor(color)); if (!widget.isIgnoreContentAdaptWithSize()) - { + setContentSize(widget, json["Size"]); //widget.getVirtualRenderer().setLineBreakWithoutSpace(true); - var size = json["Size"]; - if(size) - widget.setContentSize(cc.size(size["X"] || 0, size["Y"] || 0)); - } + return widget; }; + /** + * SimpleAudio + * @param json + * @param resourcePath + */ parser.initSimpleAudio = function(json, resourcePath){ var loop = json["Loop"]; @@ -1030,6 +999,12 @@ }; + /** + * GameMap + * @param json + * @param resourcePath + * @returns {*} + */ parser.initGameMap = function(json, resourcePath){ var node = null; @@ -1042,10 +1017,28 @@ return node; }; + /** + * ProjectNode + * @param json + * @param resourcePath + * @returns {*} + */ parser.initProjectNode = function(json, resourcePath){ - return ccs._load(json); + var projectFile = json["FileData"]; + if(projectFile != null && projectFile["Path"]){ + var file = resourcePath + projectFile["Path"]; + if(cc.loader.getRes(file)) + return ccs._load(file); + else + cc.log("%s need to pre load", file); + } }; + /** + * Armature + * @param json + * @param resourcePath + */ parser.initArmature = function(json, resourcePath){ var node = new ccs.Armature(); @@ -1096,6 +1089,13 @@ return cc.color(r, g, b); }; + var setContentSize = function(node, size){ + var x = size["X"] || 0; + var y = size["Y"] || 0; + if(size) + node.setContentSize(cc.size(x, y)); + }; + var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, {name: "SpriteObjectData", handle: parser.initSprite}, From 7ecdcf4ae6f7fdab2f1fc3de7d7aa32206925e9a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 6 Jan 2015 10:45:59 +0800 Subject: [PATCH 1139/1564] Issue #1267: Migrating ccui.Scale9Sprite --- .../ccui/base-classes/UIScale9Sprite.js | 137 ++++++++++++++++-- 1 file changed, 127 insertions(+), 10 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 153df2fc14..027bdd9f83 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -68,10 +68,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _bottomRight: null, //cache in canvas on Canvas mode - _cacheSprite: null, - _cacheCanvas: null, - _cacheContext: null, - _cacheTexture: null, _scale9Dirty: true, _opacityModifyRGB: false, @@ -91,6 +87,21 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _textureLoaded:false, _className:"Scale9Sprite", + //v3.3 + _scale9Enabled: false, + _topLeftSize: null, + _centerSize: null, + _bottomRightSize: null, + _centerOffset: null, + + _offset: null, + + _protectedChildren: null, + _reorderProtectedChildDirty: false, + + _flippedX: false, + _flippedY: false, + /** * return texture is loaded * @returns {boolean} @@ -521,8 +532,8 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * to resize the sprite will all it's 9-slice goodness interact. * It respects the anchorPoint too. * - * @param spriteFrameName The sprite frame name. - * @param capInsets The values to use for the cap insets. + * @param {String} spriteFrameName The sprite frame name. + * @param {cc.Rect} capInsets The values to use for the cap insets. */ initWithSpriteFrameName: function (spriteFrameName, capInsets) { if(!spriteFrameName) @@ -539,11 +550,12 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, /** - * Creates and returns a new sprite object with the specified cap insets. - * You use this method to add cap insets to a sprite or to change the existing - * cap insets of a sprite. In both cases, you get back a new image and the + *

    + * Creates and returns a new sprite object with the specified cap insets.
    + * You use this method to add cap insets to a sprite or to change the existing
    + * cap insets of a sprite. In both cases, you get back a new image and the
    * original sprite remains untouched. - * + *

    * @param {cc.Rect} capInsets The values to use for the cap insets. */ resizableSpriteWithCapInsets: function (capInsets) { @@ -918,6 +930,111 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._insetBottom = 0; }, + //todo: v3.3 + updateWithSprite: function(sprite, rect, rotated, offset, orginalSize, capInsets){ + //virtual bool updateWithSprite(Sprite* sprite, const Rect& rect, bool rotated, const Rect& capInsets); + //virtual bool updateWithSprite(Sprite* sprite, const Rect& rect, bool rotated, const Vec2 &offset, const Size &originalSize, const Rect& capInsets); + }, + + //virtual void setAnchorPoint(const Vec2& anchorPoint) override; + + /** + * set the state of ccui.Scale9Sprite + * @param {Number} state + */ + setState: function(state){ + + }, + + cleanup: function(){}, + + onEnter: function(){}, + + onEnterTransitionDidFinish: function(){}, + + onExit: function(){}, + + onExitTransitionDidStart: function(){}, + + /** + * Sets whether the widget should be flipped horizontally or not. + * @param {Boolean} flippedX true if the widget should be flipped horizontally, false otherwise. + */ + setFlippedX: function(flippedX){}, + + /** + *

    + * Returns the flag which indicates whether the widget is flipped horizontally or not.
    + *
    + * It only flips the texture of the widget, and not the texture of the widget's children.
    + * Also, flipping the texture doesn't alter the anchorPoint.
    + * If you want to flip the anchorPoint too, and/or to flip the children too use:
    + * widget.setScaleX(sprite.getScaleX() * -1);
    + *

    + * @return true if the widget is flipped horizontally, false otherwise. + */ + isFlippedX: function(){}, + + /** + * Sets whether the widget should be flipped vertically or not. + * @param {Boolean} flippedY true if the widget should be flipped vertically, false otherwise. + */ + setFlippedY: function(flippedY){}, + + /** + *

    + * Return the flag which indicates whether the widget is flipped vertically or not.
    + *
    + * It only flips the texture of the widget, and not the texture of the widget's children.
    + * Also, flipping the texture doesn't alter the anchorPoint.
    + * If you want to flip the anchorPoint too, and/or to flip the children too use:
    + * widget.setScaleY(widget.getScaleY() * -1);
    + *

    + * @return true if the widget is flipped vertically, false otherwise. + */ + isFlippedY: function(){}, + + setScaleX: function(scaleX){}, + + setScaleY: function(scaleY){}, + + setScale: function(scaleX, scaleY){}, + + getScaleX: function(){}, + + getScaleY: function(){}, + + getScale: function(){}, + + _createSlicedSprites: function(){}, + + _cleanupSlicedSprites: function(){ + if (this._topLeft && this._topLeft.isRunning()) + this._topLeft.onExit(); + if (this._top && this._top.isRunning()) + this._top.onExit(); + if (this._topRight && this._topRight.isRunning()) + this._topRight.onExit(); + if (this._left && this._left.isRunning()) + this._left.onExit(); + if (this._centre && this._centre.isRunning()) + this._centre.onExit(); + if (this._right && this._right.isRunning()) + this._right.onExit(); + if (this._bottomLeft && this._bottomLeft.isRunning()) + this._bottomLeft.onExit(); + if (this._bottomRight && this._bottomRight.isRunning()) + this._bottomRight.onExit(); + if (this._bottom && this._bottom.isRunning()) + this._bottom.onExit(); + }, + + _adjustScale9ImagePosition: function(){}, + + _sortAllProtectedChildren: function(){}, + + _addProtectedChild: function(){}, + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new ccui.Scale9Sprite.CanvasRenderCmd(this); From 2ba32e5c94e97de2cfcc11b31b0f8c1303268fd7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 Jan 2015 14:21:18 +0800 Subject: [PATCH 1140/1564] Issue #2563: support timeline(action) 1.0.0.0 --- .../cocostudio/loader/parsers/action-1.x.js | 212 ++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 extensions/cocostudio/loader/parsers/action-1.x.js diff --git a/extensions/cocostudio/loader/parsers/action-1.x.js b/extensions/cocostudio/loader/parsers/action-1.x.js new file mode 100644 index 0000000000..135e83f4a5 --- /dev/null +++ b/extensions/cocostudio/loader/parsers/action-1.x.js @@ -0,0 +1,212 @@ +(function(load, baseParser){ + + var cache = {}; + + var Parser = baseParser.extend({ + + getNodeJson: function(json){ + return json["action"]; + }, + + parseNode: function(json, resourcePath, file){ + if(cache[file]) + return cache[file].clone(); + + var self = this, + action = new ccs.ActionTimeline(); + + action.setDuration(json["duration"]); + action.setTimeSpeed(json["speed"] || 1); + //The process of analysis + var timelines = json["timelines"]; + timelines.forEach(function(timeline){ + var parser = self.parsers[timeline["frameType"]]; + var frame; + if(parser) + frame = parser.call(self, timeline, resourcePath); + else + cc.log("parser is not exists : %s", timeline["frameType"]); + if(frame) + action.addTimeline(frame); + + if(timeline["frameType"] == "ColorFrame"){ + action.addTimeline( + self.parsers["AlphaFrame"].call(self, timeline, resourcePath) + ); + } + }); + + cache[file] = action; + + return action.clone(); + } + + }); + + var parser = new Parser(); + + var frameList = [ + { + name: "PositionFrame", + handle: function(options){ + var frame = new ccs.PositionFrame(); + var x = options["x"]; + var y = options["y"]; + frame.setPosition(cc.p(x,y)); + return frame; + } + }, + { + name: "VisibleFrame", + handle: function(options){ + var frame = new ccs.VisibleFrame(); + var visible = options["value"]; + frame.setVisible(visible); + return frame; + } + }, + { + name: "ScaleFrame", + handle: function(options){ + var frame = new ccs.ScaleFrame(); + var scalex = options["x"]; + var scaley = options["y"]; + frame.setScaleX(scalex); + frame.setScaleY(scaley); + return frame; + } + }, + { + name: "RotationFrame", + handle: function(options){ + var frame = new ccs.RotationFrame(); + var rotation = options["rotation"]; + frame.setRotation(rotation); + return frame; + } + }, + { + name: "SkewFrame", + handle: function(options){ + var frame = new ccs.SkewFrame(); + var skewx = options["x"]; + var skewy = options["y"]; + frame.setSkewX(skewx); + frame.setSkewY(skewy); + return frame; + } + }, + { + name: "RotationSkewFrame", + handle: function(options){ + var frame = new ccs.RotationSkewFrame(); + var skewx = options["x"]; + var skewy = options["y"]; + frame.setSkewX(skewx); + frame.setSkewY(skewy); + return frame; + } + }, + { + name: "AnchorFrame", + handle: function(options){ + var frame = new ccs.AnchorPointFrame(); + var anchorx = options["x"]; + var anchory = options["y"]; + frame.setAnchorPoint(cc.p(anchorx, anchory)); + return frame; + } + }, + { + name: "InnerActionFrame", + handle: function(options){ + var frame = new ccs.InnerActionFrame(); + var type = options["innerActionType"]; + var startFrame = options["startFrame"]; + frame.setInnerActionType(type); + frame.setStartFrameIndex(startFrame); + return frame; + } + }, + { + name: "ColorFrame", + handle: function(options){ + var frame = new ccs.ColorFrame(); + var red = options["red"]; + var green = options["green"]; + var blue = options["blue"]; + frame.setColor(cc.color(red, green, blue)); + var alphaFrame = new ccs.AlphaFrame(); + var alpha = options["alpha"]; + alphaFrame.setAlpha(alpha); + return frame; + } + }, + { + name: "AlphaFrame", + handle: function(options){ + var frame = new ccs.AlphaFrame(); + var alpha = options["alpha"]; + frame.setAlpha(alpha); + return frame; + } + }, + { + name: "TextureFrame", + handle: function(options){ + var frame = new ccs.TextureFrame(); + var texture = options["value"]; + if(texture != null) { + var path = texture; + var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); + if(spriteFrame == null){ + var jsonPath = ccs.csLoader.getJsonPath(); + path = jsonPath + texture; + } + frame.setTextureName(path); + } + return frame; + } + }, + { + name: "EventFrame", + handle: function(options){ + var frame = new ccs.EventFrame(); + var evnt = options["value"]; + if(evnt != null) + frame.setEvent(evnt); + return frame; + } + }, + { + name: "ZOrderFrame", + handle: function(options){ + var frame = new ccs.ZOrderFrame(); + var zorder = options["value"]; + frame.setZOrder(zorder); + return frame; + } + } + ]; + + frameList.forEach(function(item){ + parser.registerParser(item.name, function(options, resourcePath){ + var timeline = new ccs.Timeline(); + timeline.setActionTag(options["actionTag"]); + + var frames = options["frames"]; + if(frames && frames.length){ + frames.forEach(function(frameData){ + var frame = item.handle(frameData); + frame.setFrameIndex(frameData["frameIndex"]); + frame.setTween(frameData["tween"]); + timeline.addFrame(frame); + }); + } + return timeline; + }); + }); + + load.registerParser("action", "1.*", parser); + +})(ccs._load, ccs._parser); \ No newline at end of file From de3f38ae0aca3edd9ddc0a00802c4e84e19078d8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 Jan 2015 14:21:50 +0800 Subject: [PATCH 1141/1564] Issue #2563: Add ccs.AlphaFrame --- .../cocostudio/reader/timeline/Frame.js | 85 ++++++++++++------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/extensions/cocostudio/reader/timeline/Frame.js b/extensions/cocostudio/reader/timeline/Frame.js index 8fffc07af4..8b39c62ca6 100644 --- a/extensions/cocostudio/reader/timeline/Frame.js +++ b/extensions/cocostudio/reader/timeline/Frame.js @@ -239,8 +239,7 @@ ccs.TextureFrame = ccs.Frame.extend({ */ onEnter: function(nextFrame){ if(this._sprite){ - var spriteFrame = cc.spriteFrameCache.getSpriteFrame(this._textureName); - + var spriteFrame = cc.spriteFrameCache._spriteFrames[this._textureName]; if(spriteFrame != null) this._sprite.setSpriteFrame(spriteFrame); else @@ -952,22 +951,16 @@ ccs.ColorFrame = ccs.Frame.extend({ ctor: function(){ ccs.Frame.prototype.ctor.call(this); - - this._alpha = 255; - this.color = cc.color(255, 255, 255); + this._color = cc.color(255, 255, 255); }, /** * the execution of the callback - * @param {ccs.Frame} nextFrame + * @param {ccs.ColorFrame} nextFrame */ onEnter: function(nextFrame){ - this._node.setOpacity(this._alpha); this._node.setColor(this._color); - if(this._tween){ - this._betweenAlpha = nextFrame._alpha - this._alpha; - var color = nextFrame._color; this._betweenRed = color.r - this._color.r; this._betweenGreen = color.g - this._color.g; @@ -1001,30 +994,11 @@ ccs.ColorFrame = ccs.Frame.extend({ */ clone: function(){ var frame = new ccs.ColorFrame(); - frame.setAlpha(this._alpha); frame.setColor(this._color); - frame._cloneProperty(this); - return frame; }, - /** - * Set the alpha - * @param {Number} alpha - */ - setAlpha: function(alpha){ - this._alpha = alpha; - }, - - /** - * Gets the alpha - * @returns {Number} - */ - getAlpha: function(){ - return this._alpha; - }, - /** * Set the color * @param {cc.color} color @@ -1053,6 +1027,59 @@ ccs.ColorFrame.create = function(){ return new ccs.ColorFrame(); }; +/** + * Alpha frame + * @class + * @extend ccs.Frame + */ +ccs.AlphaFrame = ccs.Frame.extend({ + + _alpha: null, + _betweenAlpha: null, + + ctor: function(){ + ccs.Frame.prototype.ctor.call(this); + this._alpha = 255; + }, + + onEnter: function(nextFrame){ + this._node.setOpacity(this._alpha); + if(this._tween){ + this._betweenAlpha = nextFrame._alpha - this._alpha; + } + }, + + apply: function(percent){ + if (this._tween){ + var alpha = this._alpha + this._betweenAlpha * percent; + this._node.setOpacity(alpha); + } + }, + + /** + * Set the alpha + * @param {Number} alpha + */ + setAlpha: function(alpha){ + this._alpha = alpha; + }, + + /** + * Gets the alpha + * @returns {Number} + */ + getAlpha: function(){ + return this._alpha; + }, + + clone: function(){ + var frame = new ccs.AlphaFrame(); + frame.setAlpha(this._alpha); + frame._cloneProperty(this); + return frame; + } +}); + /** * Event frame * @class From 3e7f8197ffc487c89abf33a1a0f0f0f19b4c83ed Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 Jan 2015 14:23:12 +0800 Subject: [PATCH 1142/1564] Issue #2563: Add ccs.load function --- extensions/cocostudio/loader/load.js | 35 +++++++++++-------- .../reader/timeline/ActionTimelineCache.js | 2 +- moduleConfig.json | 1 + 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index dbda4dffe7..876772e69d 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -16,8 +16,6 @@ ccs._load = (function(){ if(ext !== "json" && ext !== "exportjson") return cc.log("%s load error, must be json file", file); - // Judging the parser (uiParse or timelineParse, Temporarily blank) - // The judgment condition is unknown var parse; if(!type){ if(json["widgetTree"]) @@ -88,17 +86,6 @@ ccs._load = (function(){ })(); -//cc.loader.register(["json", "ExportJson"], { -// load: function(realUrl, url, res, cb){ -// var cloader = cc.loader; -// if(cloader.cache[url]){ -// console.log(url) -// }else{ -// return cc.loader.loadJson(realUrl, cb); -// } -// } -//}); - ccs._parser = cc.Class.extend({ ctor: function(){ @@ -135,7 +122,7 @@ ccs._parser = cc.Class.extend({ var parser = this.parsers[this.getClass(json)]; var widget = null; if(parser) - widget = parser.call(this, json, this.parseNode, resourcePath); + widget = parser.call(this, json, resourcePath); else cc.log("Can't find the parser : %s", this.getClass(json)); @@ -146,3 +133,23 @@ ccs._parser = cc.Class.extend({ this.parsers[widget] = parse; } }); + +/** + * Analysis of studio JSON file + * The incoming file name, parse out the corresponding object + * Temporary support file list: + * ui 1.* + * node 1.* - 2.* + * action 1.* - 2.* + * @param {String} file + * @returns {{node: cc.Node, action: cc.Action}} + */ +ccs.load = function(file){ + var object = { + node: null, + action: null + }; + object.node = ccs._load(file); + object.action = ccs._load(file, "action"); + return object; +}; \ No newline at end of file diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js index 95c4a5d07f..76b5fa0ee0 100644 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js @@ -291,7 +291,7 @@ ccs.actionTimelineCache = { var anchorx = json[ccui.actionTimelineCacheStatic.X]; var anchory = json[ccui.actionTimelineCacheStatic.Y]; - frame.setAnchorPoint(Point(anchorx, anchory)); + frame.setAnchorPoint(cc.p(anchorx, anchory)); return frame; }, diff --git a/moduleConfig.json b/moduleConfig.json index 2f3df9fca6..af0f419530 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -400,6 +400,7 @@ "extensions/cocostudio/loader/load.js", "extensions/cocostudio/loader/parsers/uiParser-1.x.js", + "extensions/cocostudio/loader/parsers/action-1.x.js", "extensions/cocostudio/loader/parsers/action-2.x.js", "extensions/cocostudio/loader/parsers/timelineParser-1.x.js", "extensions/cocostudio/loader/parsers/timelineParser-2.x.js" From f69ff3151ed15a504c38e4eaafd3a473e171895d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 Jan 2015 14:23:33 +0800 Subject: [PATCH 1143/1564] Issue #2563: support timeline(action) 2.0.0.0 --- .../cocostudio/loader/parsers/action-2.x.js | 184 +++++++++++++++++- 1 file changed, 179 insertions(+), 5 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 765cdfe171..8c15026208 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -1,5 +1,7 @@ (function(load, baseParser){ + var cache = {}; + var Parser = baseParser.extend({ getNodeJson: function(json){ @@ -7,21 +9,193 @@ }, parseNode: function(json, resourcePath, file){ - var self = this; + if(cache[file]) + return cache[file].clone(); + + var self = this, + action = new ccs.ActionTimeline(); + + action.setDuration(json["Duration"]); + action.setTimeSpeed(json["Speed"] || 1); //The process of analysis var timelines = json["Timelines"]; timelines.forEach(function(timeline){ - var parser = self.parsers[timeline["FrameType"]]; - parser.call(self, timeline, resourcePath); + var parser = self.parsers[timeline["Property"]]; + var frame; + if(parser) + frame = parser.call(self, timeline, resourcePath); + else + cc.log("parser is not exists : %s", timeline["Property"]); + if(frame) + action.addTimeline(frame); }); - return new cc.Action(); + + cache[file] = action; + + return action.clone(); } }); var parser = new Parser(); - parser.registerParser("RotationSkewFrame", function(options, resourcePath){ + var frameList = [ + { + name: "Position", + handle: function(options){ + var frame = new ccs.PositionFrame(); + var x = options["X"]; + var y = options["Y"]; + frame.setPosition(cc.p(x,y)); + return frame; + } + }, + { + name: "VisibleForFrame", + handle: function(options){ + var frame = new ccs.VisibleFrame(); + var visible = options["Value"]; + frame.setVisible(visible); + return frame; + } + }, + { + name: "Scale", + handle: function(options){ + var frame = new ccs.ScaleFrame(); + var scalex = options["X"]; + var scaley = options["Y"]; + frame.setScaleX(scalex); + frame.setScaleY(scaley); + return frame; + } + }, + { + name: "Rotation", + handle: function(options){ + var frame = new ccs.RotationFrame(); + var rotation = options["Rotation"]; + frame.setRotation(rotation); + return frame; + } + }, + { + name: "Skew", + handle: function(options){ + var frame = new ccs.SkewFrame(); + var skewx = options["X"]; + var skewy = options["Y"]; + frame.setSkewX(skewx); + frame.setSkewY(skewy); + return frame; + } + }, + { + name: "RotationSkew", + handle: function(options){ + var frame = new ccs.RotationSkewFrame(); + var skewx = options["X"]; + var skewy = options["Y"]; + frame.setSkewX(skewx); + frame.setSkewY(skewy); + return frame; + } + }, + { + name: "Anchor", + handle: function(options){ + var frame = new ccs.AnchorPointFrame(); + var anchorx = options["X"]; + var anchory = options["Y"]; + frame.setAnchorPoint(cc.p(anchorx, anchory)); + return frame; + } + }, + { + name: "InnerAction", + handle: function(options){ + var frame = new ccs.InnerActionFrame(); + var type = options["InnerActionType"]; + var startFrame = options["StartFrame"]; + frame.setInnerActionType(type); + frame.setStartFrameIndex(startFrame); + return frame; + } + }, + { + name: "CColor", + handle: function(options){ + var frame = new ccs.ColorFrame(); + var color = options["Color"]; + if(!color) color = {}; + color["R"] = color["R"] || 255; + color["G"] = color["G"] || 255; + color["B"] = color["B"] || 255; + frame.setColor(cc.color(color["R"], color["G"], color["B"])); + return frame; + } + }, + { + name: "Alpha", + handle: function(options){ + var frame = new ccs.AlphaFrame(); + var alpha = options["Value"]; + frame.setAlpha(alpha); + return frame; + } + }, + { + name: "FileData", + handle: function(options, resourcePath){ + var frame = new ccs.TextureFrame(); + var texture = options["TextureFile"]; + if(texture != null) { + var path = texture["Path"]; + var spriteFrame = cc.spriteFrameCache._spriteFrames[path]; + if(spriteFrame == null){ + path = resourcePath + path; + } + frame.setTextureName(path); + } + return frame; + } + }, + { + name: "FrameEvent", + handle: function(options){ + var frame = new ccs.EventFrame(); + var evnt = options["Value"]; + if(evnt != null) + frame.setEvent(evnt); + return frame; + } + }, + { + name: "ZOrder", + handle: function(options){ + var frame = new ccs.ZOrderFrame(); + var zorder = options["Value"]; + frame.setZOrder(zorder); + return frame; + } + } + ]; + + frameList.forEach(function(item){ + parser.registerParser(item.name, function(options, resourcePath){ + var timeline = new ccs.Timeline(); + timeline.setActionTag(options["ActionTag"]); + var frames = options["Frames"]; + if(frames && frames.length){ + frames.forEach(function(frameData){ + var frame = item.handle(frameData, resourcePath); + frame.setFrameIndex(frameData["FrameIndex"]); + frame.setTween(frameData["Tween"]); + timeline.addFrame(frame); + }); + } + return timeline; + }); }); load.registerParser("action", "2.*", parser); From 5bb079f264c6ec3fd1397e380f4b233c25c37a0d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 Jan 2015 14:24:49 +0800 Subject: [PATCH 1144/1564] Issue #2563: repair some of the problem that is parser error --- .../loader/parsers/timelineParser-1.x.js | 29 +++++++++++++------ .../loader/parsers/timelineParser-2.x.js | 2 +- .../cocostudio/loader/parsers/uiParser-1.x.js | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js index 8cf3976b37..6c5de0792c 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -1,24 +1,31 @@ (function(load, baseParser){ + var loadedPlist = {}; + var Parser = baseParser.extend({ getNodeJson: function(json){ return json["nodeTree"]; }, - addSpriteFrame: function(textures, plists, resourcePath){ - if(!textures) return; - for (var i = 0; i < textures.length; i++) { + addSpriteFrame: function(plists, pngs, resourcePath){ + if(!plists || !pngs || plists.length != pngs.length) + return; + for (var i = 0; i < plists.length; i++) { + var plist = resourcePath + plists[i]; + if(!cc.loader.getRes(plist) && !loadedPlist[plist]) + cc.log("%s need to pre load", plist); + else + loadedPlist[plist] = true; cc.spriteFrameCache.addSpriteFrames( - resourcePath + textures[i], - resourcePath + plists[i] + plist, + resourcePath + pngs[i] ); } }, pretreatment: function(json, resourcePath, file){ this.addSpriteFrame(json["textures"], json["texturesPng"], resourcePath); - ccs.actionTimelineCache.loadAnimationActionWithContent(file, json); } }); @@ -196,7 +203,13 @@ }; var uiParser = load.getParser("ccui")["1.*"]; parser.initWidget = function(options, resourcePath){ - var node = uiParser.parseNode.call(this, options, resourcePath); + var type = options["classname"]; + + var parser = uiParser.parsers[type]; + if(!parser) + return cc.log("%s parser is not found", type); + + var node = parser.call(uiParser, options, resourcePath); if(node){ var rotationSkewX = options["rotationSkewX"]; var rotationSkewY = options["rotationSkewY"]; @@ -249,8 +262,6 @@ }); }); - load.registerParser("timeline", "1.*", parser); - })(ccs._load, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 507de25e2d..323e1ecd2a 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -485,7 +485,7 @@ var fontResourcePath, fontResourceResourceType, fontResourcePlistFile; var fontResource = json["FontResource"]; if(fontResource != null){ - console.log(fontResource["Path"]) + //console.log(fontResource["Path"]); // fontResourcePath = fontResource["Path"]; // fontResourceResourceType = fontResource["Type"] == "Default" ? 0 : 1; // fontResourcePlistFile = fontResource["Plist"]; diff --git a/extensions/cocostudio/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js index ef3a5b1e03..1e85e82354 100644 --- a/extensions/cocostudio/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -782,7 +782,7 @@ ]; register.forEach(function(item){ - parser.registerParser(item.name, function(options, parse, resourcePath){ + parser.registerParser(item.name, function(options, resourcePath){ var widget = new item.object; var uiOptions = options["options"]; parser.generalAttributes(widget, uiOptions); From 5355540289719b5c6f860783ea9aaf5424fca6eb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 Jan 2015 16:31:58 +0800 Subject: [PATCH 1145/1564] Need to set the design resolution --- extensions/cocostudio/reader/GUIReader.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js index a5ecb04772..ed96f8959b 100644 --- a/extensions/cocostudio/reader/GUIReader.js +++ b/extensions/cocostudio/reader/GUIReader.js @@ -1030,8 +1030,7 @@ ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends cc var widget = this.widgetFromJsonDictionary(widgetTree); var size = widget.getContentSize(); - if (size.width == 0 && size.height == 0) - widget.setSize(cc.size(fileDesignWidth, fileDesignHeight)); + widget.setSize(cc.size(fileDesignWidth, fileDesignHeight)); var actions = jsonDict["animation"]; ccs.actionManager.initWithDictionary(fileName, actions, widget); From 205ec78006dd9c13aa94c56a455a44785a6e8364 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 6 Jan 2015 16:35:50 +0800 Subject: [PATCH 1146/1564] Issue #2563: prevent accidental interruption --- extensions/cocostudio/loader/load.js | 10 +- .../cocostudio/loader/parsers/action-1.x.js | 2 + .../cocostudio/loader/parsers/action-2.x.js | 2 + .../loader/parsers/timelineParser-2.x.js | 2 +- .../cocostudio/loader/parsers/uiParser-1.x.js | 299 +++++------------- 5 files changed, 93 insertions(+), 222 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index 876772e69d..359f9b568b 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -110,7 +110,7 @@ ccs._parser = cc.Class.extend({ var resourcePath = this._dirname(file); this.pretreatment(json, resourcePath); var node = this.parseNode(this.getNodeJson(json), resourcePath); - this.deferred(json, resourcePath, node, file); + node && this.deferred(json, resourcePath, node, file); return node; }, @@ -149,7 +149,11 @@ ccs.load = function(file){ node: null, action: null }; - object.node = ccs._load(file); - object.action = ccs._load(file, "action"); + try{ + object.node = ccs._load(file); + object.action = ccs._load(file, "action"); + }catch(error){ + cc.log("ccs.load has encountered some problems"); + } return object; }; \ No newline at end of file diff --git a/extensions/cocostudio/loader/parsers/action-1.x.js b/extensions/cocostudio/loader/parsers/action-1.x.js index 135e83f4a5..8f05c137fd 100644 --- a/extensions/cocostudio/loader/parsers/action-1.x.js +++ b/extensions/cocostudio/loader/parsers/action-1.x.js @@ -9,6 +9,8 @@ }, parseNode: function(json, resourcePath, file){ + if(!json) + return null; if(cache[file]) return cache[file].clone(); diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 8c15026208..25d2f10d88 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -9,6 +9,8 @@ }, parseNode: function(json, resourcePath, file){ + if(!json) + return null; if(cache[file]) return cache[file].clone(); diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 323e1ecd2a..60b9e16103 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1120,7 +1120,7 @@ ]; register.forEach(function(item){ - parser.registerParser(item.name, function(options, parse, resourcePath){ + parser.registerParser(item.name, function(options, resourcePath){ var node = item.handle.call(this, options, resourcePath); this.parseChild(node, options["Children"], resourcePath); DEBUG && node && (node.__parserName = item.name); diff --git a/extensions/cocostudio/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js index 1e85e82354..83de06d419 100644 --- a/extensions/cocostudio/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -143,7 +143,7 @@ widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); }; - parser.parseChild = function(parse, widget, options, resourcePath){ + parser.parseChild = function(widget, options, resourcePath){ var children = options["children"]; for (var i = 0; i < children.length; i++) { var child = this.parseNode(children[i], resourcePath); @@ -170,6 +170,15 @@ } }; + var getPath = function(res, type, path, cb){ + if(path){ + if(type == 0) + cb(res + path, type); + else + cb(path, type); + } + }; + /** * Panel parser (UILayout) */ @@ -217,33 +226,12 @@ var imageFileNameDic = options["backGroundImageData"]; if(imageFileNameDic){ - var imageFileName, - imageFileNameType = imageFileNameDic["resourceType"]; - switch (imageFileNameType) - { - case 0: - { - var tp_b = resourcePath; - imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = (imageFileName && (imageFileName !== "")) ? - tp_b + imageFileName : - null; - widget.setBackGroundImage(imageFileName_tp); - break; - } - case 1: - { - imageFileName = imageFileNameDic["path"]; - widget.setBackGroundImage(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - } - default: - break; - } + getPath(resourcePath, imageFileNameDic["resourceType"], imageFileNameDic["path"], function(path, type){ + widget.setBackGroundImage(path, type); + }); } - if (backGroundScale9Enable) - { + if (backGroundScale9Enable){ var cx = options["capInsetsX"]; var cy = options["capInsetsY"]; var cw = options["capInsetsWidth"]; @@ -260,60 +248,18 @@ var scale9Enable = options["scale9Enable"]; button.setScale9Enabled(scale9Enable); - var normalFileName, - normalDic = options["normalData"], - normalType = normalDic["resourceType"]; - switch (normalType) { - case 0: - var tp_n = resourcePath; - normalFileName = normalDic["path"]; - var normalFileName_tp = (normalFileName && normalFileName !== "") ? - tp_n + normalFileName : null; - button.loadTextureNormal(normalFileName_tp); - break; - case 1: - normalFileName = normalDic["path"]; - button.loadTextureNormal(normalFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } - var pressedFileName, - pressedDic = options["pressedData"], - pressedType = pressedDic["resourceType"]; - switch (pressedType) { - case 0: - var tp_p = resourcePath; - pressedFileName = pressedDic["path"]; - var pressedFileName_tp = (pressedFileName && pressedFileName !== "") ? - tp_p + pressedFileName : null; - button.loadTexturePressed(pressedFileName_tp); - break; - case 1: - pressedFileName = pressedDic["path"]; - button.loadTexturePressed(pressedFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } - var disabledFileName, - disabledDic = options["disabledData"], - disabledType = disabledDic["resourceType"]; - switch (disabledType){ - case 0: - var tp_d = resourcePath; - disabledFileName = disabledDic["path"]; - var disabledFileName_tp = (disabledFileName && disabledFileName !== "") ? - tp_d + disabledFileName : null; - button.loadTextureDisabled(disabledFileName_tp); - break; - case 1: - disabledFileName = disabledDic["path"]; - button.loadTextureDisabled(disabledFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + var normalDic = options["normalData"]; + getPath(resourcePath, normalDic["resourceType"], normalDic["path"], function(path, type){ + button.loadTextureNormal(path, type); + }); + var pressedDic = options["pressedData"]; + getPath(resourcePath, pressedDic["resourceType"], pressedDic["path"], function(path, type){ + button.loadTexturePressed(path, type); + }); + var disabledDic = options["disabledData"]; + getPath(resourcePath, disabledDic["resourceType"], disabledDic["path"], function(path, type){ + button.loadTextureDisabled(path, type); + }); if (scale9Enable) { var cx = options["capInsetsX"]; var cy = options["capInsetsY"]; @@ -351,41 +297,41 @@ parser.CheckBoxAttributes = function(widget, options, resourcePath){ //load background image var backGroundDic = options["backGroundBoxData"]; - var backGroundType = backGroundDic["resourceType"]; - var backGroundTexturePath = resourcePath + backGroundDic["path"]; - widget.loadTextureBackGround(backGroundTexturePath, backGroundType); + getPath(resourcePath, backGroundDic["resourceType"], backGroundDic["path"], function(path, type){ + widget.loadTextureBackGround(path, type); + }); //load background selected image var backGroundSelectedDic = options["backGroundBoxSelectedData"]; - var backGroundSelectedType = backGroundSelectedDic["resourceType"]; - var backGroundSelectedTexturePath = resourcePath + backGroundSelectedDic["path"]; - if(!backGroundSelectedTexturePath){ - backGroundSelectedType = backGroundType; - backGroundSelectedTexturePath = backGroundTexturePath; - } - widget.loadTextureBackGroundSelected(backGroundSelectedTexturePath, backGroundSelectedType); + getPath( + resourcePath, + backGroundSelectedDic["resourceType"] || backGroundDic["resourceType"], + backGroundSelectedDic["path"] || backGroundDic["path"], + function(path, type){ + widget.loadTextureBackGroundSelected(path, type); + }); //load frontCross image var frontCrossDic = options["frontCrossData"]; - var frontCrossType = frontCrossDic["resourceType"]; - var frontCrossFileName = resourcePath + frontCrossDic["path"]; - widget.loadTextureFrontCross(frontCrossFileName, frontCrossType); + getPath(resourcePath, frontCrossDic["resourceType"], frontCrossDic["path"], function(path, type){ + widget.loadTextureFrontCross(path, type); + }); //load backGroundBoxDisabledData var backGroundDisabledDic = options["backGroundBoxDisabledData"]; - var backGroundDisabledType = backGroundDisabledDic["resourceType"]; - var backGroundDisabledFileName = resourcePath + backGroundDisabledDic["path"]; - if(!backGroundDisabledFileName){ - backGroundDisabledType = frontCrossType; - backGroundDisabledFileName = frontCrossFileName; - } - widget.loadTextureBackGroundDisabled(backGroundDisabledFileName, backGroundDisabledType); + getPath( + resourcePath, + backGroundDisabledDic["resourceType"] || frontCrossDic["resourceType"], + backGroundDisabledDic["path"] || frontCrossDic["path"], + function(path, type){ + widget.loadTextureBackGroundDisabled(path, type); + }); ///load frontCrossDisabledData var frontCrossDisabledDic = options["frontCrossDisabledData"]; - var frontCrossDisabledType = frontCrossDisabledDic["resourceType"]; - var frontCrossDisabledFileName = resourcePath + frontCrossDisabledDic["path"]; - widget.loadTextureFrontCrossDisabled(frontCrossDisabledFileName, frontCrossDisabledType); + getPath(resourcePath, frontCrossDisabledDic["resourceType"], frontCrossDisabledDic["path"], function(path, type){ + widget.loadTextureFrontCrossDisabled(path, type); + }); if (options["selectedState"]) widget.setSelected(options["selectedState"]); @@ -537,27 +483,11 @@ /** * LoadingBar parser (UILoadingBar) */ - parser.LoadingBarAttributes = function(widget, options, resoutcePath){ - var imageFileName, - imageFileNameDic = options["textureData"], - imageFileNameType = imageFileNameDic["resourceType"]; - switch (imageFileNameType){ - case 0: - var tp_i = resoutcePath; - imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = null; - if (imageFileName && (imageFileName !== "")){ - imageFileName_tp = tp_i + imageFileName; - widget.loadTexture(imageFileName_tp); - } - break; - case 1: - imageFileName = imageFileNameDic["path"]; - widget.loadTexture(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + parser.LoadingBarAttributes = function(widget, options, resourcePath){ + var imageFileNameDic = options["textureData"]; + getPath(resourcePath, imageFileNameDic["resourceType"], imageFileNameDic["path"], function(path, type){ + widget.loadTexture(path, type); + }); var scale9Enable = options["scale9Enable"]; widget.setScale9Enabled(scale9Enable); @@ -598,10 +528,9 @@ /** * Slider parser (UISlider) */ - parser.SliderAttributes = function(widget, options, resoutcePath){ + parser.SliderAttributes = function(widget, options, resourcePath){ var slider = widget; - var tp = resoutcePath; var barTextureScale9Enable = options["scale9Enable"]; slider.setScale9Enabled(barTextureScale9Enable); @@ -611,109 +540,43 @@ var imageFileNameDic = options["barFileNameData"]; var imageFileType = imageFileNameDic["resourceType"]; var imageFileName = imageFileNameDic["path"]; - var imageFileName_tp; if(bt != null){ if(barTextureScale9Enable){ - switch(imageFileType){ - case 0: - imageFileName_tp = imageFileName ? - ( tp + imageFileName ) : - null; - slider.loadBarTexture(imageFileName_tp); - break; - case 1: - slider.loadBarTexture(imageFileName, 1 /*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + getPath(resourcePath, imageFileType, imageFileName, function(path, type){ + slider.loadBarTexture(path, type); + }); slider.setSize(cc.size(barLength, slider.getContentSize().height)); } }else{ - switch(imageFileType){ - case 0: - imageFileName_tp = imageFileName ? - tp + imageFileName : - null; - slider.loadBarTexture(imageFileName_tp); - break; - case 1: - slider.loadBarTexture(imageFileName, 1 /*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + getPath(resourcePath, imageFileType, imageFileName, function(path, type){ + slider.loadBarTexture(path, type); + }); } + var normalDic = options["ballNormalData"]; - var normalType = normalDic["resourceType"]; - var normalFileName = normalDic["path"]; - switch(normalType){ - case 0: - var normalFileName_tp = normalFileName ? - tp + normalFileName : - null; - slider.loadSlidBallTextureNormal(normalFileName_tp); - break; - case 1: - slider.loadSlidBallTextureNormal(normalFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + getPath(resourcePath, normalDic["resourceType"], normalDic["path"], function(path, type){ + slider.loadSlidBallTextureNormal(path, type); + }); var pressedDic = options["ballPressedData"]; - var pressedType = pressedDic["resourceType"]; - var pressedFileName = pressedDic["path"]; - if(pressedFileName === null){ - pressedType = normalType; - pressedFileName = normalFileName; - } - switch(pressedType){ - case 0: - var pressedFileName_tp = pressedFileName ? - tp + pressedFileName : - null; - slider.loadSlidBallTexturePressed(pressedFileName_tp); - break; - case 1: - slider.loadSlidBallTexturePressed(pressedFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + getPath( + resourcePath, + pressedDic["resourceType"] || normalDic["resourceType"], + pressedDic["path"] || normalDic["path"], + function(path, type){ + slider.loadSlidBallTexturePressed(path, type); + }); + var disabledDic = options["ballDisabledData"]; - var disabledType = disabledDic["resourceType"]; - var disabledFileName = disabledDic["path"]; - switch(disabledType){ - case 0: - var disabledFileName_tp = disabledFileName ? - tp + disabledFileName : - null; - slider.loadSlidBallTextureDisabled(disabledFileName_tp); - break; - case 1: - slider.loadSlidBallTextureDisabled(disabledFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + getPath(resourcePath, disabledDic["resourceType"], disabledDic["path"], function(path, type){ + slider.loadSlidBallTextureDisabled(path, type); + }); + var progressBarDic = options["progressBarData"]; - var progressBarType = progressBarDic["resourceType"]; - var imageProgressFileName = progressBarDic["path"]; - switch (progressBarType){ - case 0: - var imageProgressFileName_tp = imageProgressFileName ? - (tp + imageProgressFileName) : - null; - slider.loadProgressBarTexture(imageProgressFileName_tp); - break; - case 1: - slider.loadProgressBarTexture(imageProgressFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + getPath(resourcePath, progressBarDic["resourceType"], progressBarDic["path"], function(path, type){ + slider.loadProgressBarTexture(path, type); + }); }; /** * TextField parser (UITextField) @@ -789,7 +652,7 @@ item.handle(widget, uiOptions, resourcePath); parser.colorAttributes(widget, uiOptions); parser.anchorPointAttributes(widget, uiOptions); - parser.parseChild.call(this, parse, widget, options, resourcePath); + parser.parseChild.call(this, widget, options, resourcePath); return widget; }); }); From 27644f938ee3704aa2d39ee3f6e017cc155ac256 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 14:16:29 +0800 Subject: [PATCH 1147/1564] Issue #2563: Timeline does not belong to reader --- extensions/cocostudio/{reader => }/timeline/ActionTimeline.js | 0 extensions/cocostudio/{reader => }/timeline/Frame.js | 0 extensions/cocostudio/{reader => }/timeline/Timeline.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename extensions/cocostudio/{reader => }/timeline/ActionTimeline.js (100%) rename extensions/cocostudio/{reader => }/timeline/Frame.js (100%) rename extensions/cocostudio/{reader => }/timeline/Timeline.js (100%) diff --git a/extensions/cocostudio/reader/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js similarity index 100% rename from extensions/cocostudio/reader/timeline/ActionTimeline.js rename to extensions/cocostudio/timeline/ActionTimeline.js diff --git a/extensions/cocostudio/reader/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js similarity index 100% rename from extensions/cocostudio/reader/timeline/Frame.js rename to extensions/cocostudio/timeline/Frame.js diff --git a/extensions/cocostudio/reader/timeline/Timeline.js b/extensions/cocostudio/timeline/Timeline.js similarity index 100% rename from extensions/cocostudio/reader/timeline/Timeline.js rename to extensions/cocostudio/timeline/Timeline.js From b44eefb1c63dd496b93adcbebc59fcfaab057099 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 14:18:14 +0800 Subject: [PATCH 1148/1564] Issue #2563: Add a scene analysis --- extensions/cocostudio/loader/load.js | 58 +++- .../cocostudio/loader/parsers/compatible.js | 243 +++++++++++++++++ .../cocostudio/loader/parsers/scene-1.x.js | 256 ++++++++++++++++++ 3 files changed, 556 insertions(+), 1 deletion(-) create mode 100644 extensions/cocostudio/loader/parsers/compatible.js create mode 100644 extensions/cocostudio/loader/parsers/scene-1.x.js diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index 359f9b568b..d1a09cbcb2 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + ccs._load = (function(){ /** @@ -24,6 +48,8 @@ ccs._load = (function(){ parse = parser["timeline"]; else if(json["Content"] && json["Content"]["Content"]) parse = parser["timeline"]; + else if(json["gameobjects"] && json["Triggers"]) + parse = parser["scene"]; }else{ parse = parser[type]; } @@ -45,7 +71,8 @@ ccs._load = (function(){ var parser = { "ccui": {}, "timeline": {}, - "action": {} + "action": {}, + "scene": {} }; load.registerParser = function(name, version, target){ @@ -156,4 +183,33 @@ ccs.load = function(file){ cc.log("ccs.load has encountered some problems"); } return object; +}; + +//Forward compatible interface + +ccs.actionTimelineCache = { + + + //@deprecated This function will be deprecated sooner or later please use ccs.load + /** + * Create Timeline Action + * @param file + * @returns {*} + */ + createAction: function(file){ + return ccs._load(file, "action"); + } +}; + +ccs.csLoader = { + + //@deprecated This function will be deprecated sooner or later please use ccs.load + /** + * Create Timeline Node + * @param file + * @returns {*} + */ + createNode: function(file){ + return ccs._load(file); + } }; \ No newline at end of file diff --git a/extensions/cocostudio/loader/parsers/compatible.js b/extensions/cocostudio/loader/parsers/compatible.js new file mode 100644 index 0000000000..4a91c56ab0 --- /dev/null +++ b/extensions/cocostudio/loader/parsers/compatible.js @@ -0,0 +1,243 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + + +/* + This file is for compatibility compatibility with older versions of GUIReader and SceneReader + */ + +(function(){ + + ccs.uiReader = { + + _fileDesignSizes: {}, + + //@deprecated This function will be deprecated sooner or later please use ccs.load + /** + * Create CCUI Node + * @param file + * @returns {*} + */ + widgetFromJsonFile: function(file){ + var json = cc.loader.getRes(file); + if(json) + this._fileDesignSizes[file] = cc.size(json["designWidth"]||0, json["designHeight"]||0); + return ccs._load(file, "ccui"); + }, + + //@deprecated This function will be deprecated sooner or later please use parser.registerParser + /** + * Register a custom Widget reader + * @param classType + * @param ins + * @param object + * @param callback + * @deprecated This function will be deprecated sooner or later please use parser.registerParser + */ + registerTypeAndCallBack: function(classType, ins, object, callback){ + var parser = ccs._load.getParser("ccui")["*"]; + var func = callback.bind(object); + parser.registerParser(classType, function(options, resourcePath){ + var widget = new ins(); + var uiOptions = options["options"]; + object.setPropsFromJsonDictionary && object.setPropsFromJsonDictionary(widget, uiOptions); + this.generalAttributes(widget, uiOptions); + var customProperty = uiOptions["customProperty"]; + if(customProperty) + customProperty = JSON.parse(customProperty); + else + customProperty = {}; + func(classType, widget, customProperty); + this.colorAttributes(widget, uiOptions); + this.anchorPointAttributes(widget, uiOptions); + this.parseChild.call(this, widget, options, resourcePath); + return widget; + }); + }, + + //@deprecated This function will be deprecated sooner or later + /** + * Gets the version number by version string. + * @param {String} version version string. + * @returns {Number} + */ + getVersionInteger: function(version){ + if(!version || typeof version != "string") return 0; + var arr = version.split("."); + if (arr.length != 4) + return 0; + var num = 0; + arr.forEach(function(n, i){ + num += n * Math.pow(10, 3 - i); + }); + return num; + }, + + //@deprecated This function will be deprecated sooner or later + /** + * stores the designSize of UI file. + * @param {String} fileName + * @param {cc.Size} size + */ + storeFileDesignSize: function (fileName, size) { + this._fileDesignSizes[fileName] = size; + }, + + //@deprecated This function will be deprecated sooner or later + /** + * Gets the design size by filename. + * @param {String} fileName + * @returns {cc.Size} + */ + getFileDesignSize: function (fileName) { + return this._fileDesignSizes[fileName]; + }, + + //@deprecated This function will be deprecated sooner or later + /** + * Returns the file path + * @returns {string} + */ + getFilePath: function(){ + return this._filePath; + }, + + //@deprecated This function will be deprecated sooner or later + setFilePath: function(path){ + this._filePath = path; + }, + + //@deprecated This function will be deprecated sooner or later + /** + * Returns the parsed object map. (analytic function) + * @returns {Object} + */ + getParseObjectMap: function(){ + return ccs._load.getParser("ccui")["*"]["parsers"]; + }, + + //@deprecated This function will be deprecated sooner or later + /** + * Returns the parsed callback map. (analytic function) + * @returns {*} + */ + getParseCallBackMap: function(){ + return ccs._load.getParser("ccui")["*"]["parsers"]; + }, + + //@deprecated This function will be deprecated sooner or later + clear: function(){} + }; + + var parser = ccs._load.getParser("ccui")["*"]; + ccs.imageViewReader = {setPropsFromJsonDictionary: parser.ImageViewAttributes}; + ccs.buttonReader = {setPropsFromJsonDictionary: parser.ButtonAttributes}; + ccs.checkBoxReader = {setPropsFromJsonDictionary: parser.CheckBoxAttributes}; + ccs.labelAtlasReader = {setPropsFromJsonDictionary: parser.TextAtlasAttributes}; + ccs.labelBMFontReader= {setPropsFromJsonDictionary: parser.TextBMFontAttributes}; + ccs.labelReader = {setPropsFromJsonDictionary: parser.TextAttributes}; + ccs.layoutReader = {setPropsFromJsonDictionary: parser.LayoutAttributes}; + ccs.listViewReader = {setPropsFromJsonDictionary: parser.ListViewAttributes}; + ccs.loadingBarReader = {setPropsFromJsonDictionary: parser.LoadingBarAttributes}; + ccs.pageViewReader = {setPropsFromJsonDictionary: parser.PageViewAttributes}; + ccs.scrollViewReader = {setPropsFromJsonDictionary: parser.ScrollViewAttributes}; + ccs.sliderReader = {setPropsFromJsonDictionary: parser.SliderAttributes}; + ccs.textFieldReader = {setPropsFromJsonDictionary: parser.TextFieldAttributes}; +})(); + +(function(){ + ccs.sceneReader = { + + _node: null, + + //@deprecated This function will be deprecated sooner or later please use ccs.load + /** + * Create Scene Node + * @param file + * @returns {*} + */ + createNodeWithSceneFile: function(file){ + var node = ccs._load(file, "scene"); + this._node = node; + return node; + }, + + /** + * Get a node by tag. + * @param {Number} tag + * @returns {cc.Node|null} + */ + getNodeByTag: function(tag){ + if (this._node == null) + return null; + if (this._node.getTag() == tag) + return this._node; + return this._nodeByTag(this._node, tag); + }, + + _nodeByTag: function (parent, tag) { + if (parent == null) + return null; + var retNode = null; + var children = parent.getChildren(); + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child && child.getTag() == tag) { + retNode = child; + break; + } else { + retNode = this._nodeByTag(child, tag); + if (retNode) + break; + } + } + return retNode; + }, + + //@deprecated This function will be deprecated sooner or later + /** + * Returns the version of ccs.SceneReader. + * @returns {string} + */ + version: function(){ + return "*"; + }, + + //@deprecated This function will be deprecated sooner or later + /** + * Sets the listener to reader. + * Cannot use + */ + setTarget: function(){}, + + //@deprecated This function will be deprecated sooner or later + /** + * Clear all triggers and stops all sounds. + */ + clear: function(){ + ccs.triggerManager.removeAll(); + cc.audioEngine.end(); + } + }; +})(); \ No newline at end of file diff --git a/extensions/cocostudio/loader/parsers/scene-1.x.js b/extensions/cocostudio/loader/parsers/scene-1.x.js new file mode 100644 index 0000000000..8e01342094 --- /dev/null +++ b/extensions/cocostudio/loader/parsers/scene-1.x.js @@ -0,0 +1,256 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +(function(load, baseParser){ + + var Parser = baseParser.extend({ + + getNodeJson: function(json){ + return json; + }, + + parseNode: function(json, resourcePath){ + var parser = this.parsers[this.getClass(json)]; + var node = null; + if(parser) + node = parser.call(this, json, resourcePath); + else + cc.log("Can't find the parser : %s", this.getClass(json)); + + return node; + }, + + setPropertyFromJsonDict: function(node, json){ + var x = (cc.isUndefined(json["x"]))?0:json["x"]; + var y = (cc.isUndefined(json["y"]))?0:json["y"]; + node.setPosition(x, y); + + var bVisible = Boolean((cc.isUndefined(json["visible"]))?1:json["visible"]); + node.setVisible(bVisible); + + var nTag = (cc.isUndefined(json["objecttag"]))?-1:json["objecttag"]; + node.setTag(nTag); + + var nZorder = (cc.isUndefined(json["zorder"]))?0:json["zorder"]; + node.setLocalZOrder(nZorder); + + var fScaleX = (cc.isUndefined(json["scalex"]))?1:json["scalex"]; + var fScaleY = (cc.isUndefined(json["scaley"]))?1:json["scaley"]; + node.setScaleX(fScaleX); + node.setScaleY(fScaleY); + + var fRotationZ = (cc.isUndefined(json["rotation"]))?0:json["rotation"]; + node.setRotation(fRotationZ); + + var sName = json["name"] || ""; + node.setName(sName); + } + + }); + + var parser = new Parser(); + + parser.parseChild = function(node, objects, resourcePath){ + for (var i = 0; i < objects.length; i++) { + var child, + options = objects[i]; + if(options) + child = this.parseNode(options, resourcePath); + if(child) + node.addChild(child); + } + }; + + var componentsParser = { + "CCSprite": function(node, component, resourcePath){ + var child = new cc.Sprite(); + loadTexture(component["fileData"], resourcePath, function(path, type){ + if(type == 0) + child.setTexture(path); + else if(type == 1){ + var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); + child.setSpriteFrame(spriteFrame); + } + }); + var render = new ccs.ComRender(child, "CCSprite"); + node.addComponent(render); + return render; + }, + "CCTMXTiledMap": function(node, component, resourcePath){ + var child = null; + loadTexture(component["fileData"], resourcePath, function(path, type){ + if(type == 0) + child = new cc.TMXTiledMap(path); + }); + var render = new ccs.ComRender(child, "CCTMXTiledMap"); + node.addComponent(render); + return render; + }, + "CCParticleSystemQuad": function(node, component, resourcePath){ + var child = null; + loadTexture(component["fileData"], resourcePath, function(path, type){ + if(type == 0) + child = new cc.ParticleSystem(path); + else + cc.log("unknown resourcetype on CCParticleSystemQuad!"); + child.setPosition(0, 0); + }); + var render = new ccs.ComRender(child, "CCParticleSystemQuad"); + node.addComponent(render); + return render; + }, + "CCArmature": function(node, component, resourcePath){ + var child = null; + loadTexture(component["fileData"], resourcePath, function(path, type){ + if(type == 0){ + var jsonDict = cc.loader.getRes(path); + if (!jsonDict) cc.log("Please load the resource [%s] first!", path); + var armature_data = jsonDict["armature_data"]; + var subData = armature_data[0]; + var name = subData["name"]; + ccs.armatureDataManager.addArmatureFileInfo(path); + child = new ccs.Armature(name); + } + }); + if(child){ + var render = new ccs.ComRender(child, "CCArmature"); + node.addComponent(render); + var actionName = component["selectedactionname"]; + if (actionName && child.getAnimation()) + child.getAnimation().play(actionName); + + return render; + } + + }, + "CCComAudio": function(node, component, resourcePath){ + var audio = null; + loadTexture(component["fileData"], resourcePath, function(path, type){ + if(type == 0){ + audio = new ccs.ComAudio(); + audio.preloadEffect(path); + var name = component["name"]; + if(name) + audio.setName(name); + node.addComponent(audio); + } + }); + }, + "CCComAttribute": function(node, component, resourcePath){ + var attribute = null; + loadTexture(component["fileData"], resourcePath, function(path, type){ + if(type == 0){ + attribute = new ccs.ComAttribute(); + if (path != "") + attribute.parse(path); + node.addComponent(attribute); + }else + cc.log("unknown resourcetype on CCComAttribute!"); + }); + return attribute; + }, + "CCBackgroundAudio": function(node, component, resourcePath){ + var audio = null; + loadTexture(component["fileData"], resourcePath, function(path, type){ + if(type == 0){ + audio = new ccs.ComAudio(); + audio.preloadBackgroundMusic(path); + audio.setFile(path);var bLoop = Boolean(component["loop"] || 0); + audio.setLoop(bLoop); + var name = component["name"]; + if(name) + audio.setName(name); + node.addComponent(audio); + audio.playBackgroundMusic(path, bLoop); + } + }); + }, + "GUIComponent": function(node, component, resourcePath){ + var widget = null; + loadTexture(component["fileData"], resourcePath, function(path, type){ + widget = ccs._load(path, "ccui"); + }); + var render = new ccs.ComRender(widget, "GUIComponent"); + node.addComponent(render); + return render; + }, + "CCScene": function(){} + }; + var loadedPlist = {}; + var loadTexture = function(json, resourcePath, cb){ + if(json != null){ + var path = json["path"]; + var type = json["resourceType"]; + var plist = json["plist"]; + if(!path) + return; + if(plist){ + if(cc.loader.getRes(resourcePath + plist)){ + loadedPlist[resourcePath + plist] = true; + cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); + }else{ + if(!loadedPlist[resourcePath + plist]) + cc.log("%s need to pre load", resourcePath + plist); + } + } + if(type !== 0) + cb(path, type); + else + cb(resourcePath + path, type); + } + }; + + parser.parseComponents = function(node, json, resourcePath){ + if(!node || !json) + return; + json.forEach(function(component){ + var parser = componentsParser[component["classname"]]; + var render = null; + if(parser) + render = parser(node, component, resourcePath); + else + cc.log("Can't find the component parser : %s", component["classname"]); + var name = component["name"]; + if(render && name){ + render.setName(name); + } + }); + }; + + parser.registerParser("CCNode", function(options, resourcePath){ + var node = new cc.Node(); + this.setPropertyFromJsonDict(node, options); + this.parseChild.call(this, node, options["gameobjects"], resourcePath); + this.parseComponents(node, options["components"], resourcePath); + var size = options["CanvasSize"]; + if (size) + node.setContentSize(cc.size(size["_width"], size["_height"])); + + return node; + }); + + load.registerParser("scene", "*", parser); + + +})(ccs._load, ccs._parser); \ No newline at end of file From 4a348c05f6565e02386b718f9736fd6c465dc003 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 14:19:04 +0800 Subject: [PATCH 1149/1564] Issue #2563: Check the file dependence, remove excess file --- .../cocostudio/loader/parsers/action-1.x.js | 26 ++++++- .../cocostudio/loader/parsers/action-2.x.js | 24 ++++++ .../loader/parsers/timelineParser-1.x.js | 76 ++++++++++++------- .../loader/parsers/timelineParser-2.x.js | 24 ++++++ .../cocostudio/loader/parsers/uiParser-1.x.js | 51 +++++++------ moduleConfig.json | 32 ++------ 6 files changed, 158 insertions(+), 75 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-1.x.js b/extensions/cocostudio/loader/parsers/action-1.x.js index 8f05c137fd..1b02ce6b2e 100644 --- a/extensions/cocostudio/loader/parsers/action-1.x.js +++ b/extensions/cocostudio/loader/parsers/action-1.x.js @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + (function(load, baseParser){ var cache = {}; @@ -209,6 +233,6 @@ }); }); - load.registerParser("action", "1.*", parser); + load.registerParser("action", "*", parser); })(ccs._load, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 25d2f10d88..41b52895b5 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + (function(load, baseParser){ var cache = {}; diff --git a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js index 6c5de0792c..aadd9323e9 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + (function(load, baseParser){ var loadedPlist = {}; @@ -32,27 +56,27 @@ var parser = new Parser(); parser.generalAttributes = function(node, options){ - var width = options[ccui.CSLoaderStatic.WIDTH] !=null ? options[ccui.CSLoaderStatic.WIDTH] : 0; - var height = options[ccui.CSLoaderStatic.HEIGHT] !=null ? options[ccui.CSLoaderStatic.HEIGHT] : 0; - var x = options[ccui.CSLoaderStatic.X] !=null ? options[ccui.CSLoaderStatic.X] : 0; - var y = options[ccui.CSLoaderStatic.Y] !=null ? options[ccui.CSLoaderStatic.Y] : 0; - var scalex = options[ccui.CSLoaderStatic.SCALE_X] !=null ? options[ccui.CSLoaderStatic.SCALE_X] : 1; - var scaley = options[ccui.CSLoaderStatic.SCALE_Y] !=null ? options[ccui.CSLoaderStatic.SCALE_Y] : 1; - var rotation = options[ccui.CSLoaderStatic.ROTATION] !=null ? options[ccui.CSLoaderStatic.ROTATION] : 0; - var rotationSkewX = options[ccui.CSLoaderStatic.ROTATION_SKEW_X]!=null ? options[ccui.CSLoaderStatic.ROTATION_SKEW_X] : 0; - var rotationSkewY = options[ccui.CSLoaderStatic.ROTATION_SKEW_Y]!=null ? options[ccui.CSLoaderStatic.ROTATION_SKEW_Y] : 0; - var skewx = options[ccui.CSLoaderStatic.SKEW_X] !=null ? options[ccui.CSLoaderStatic.SKEW_X] : 0; - var skewy = options[ccui.CSLoaderStatic.SKEW_Y] !=null ? options[ccui.CSLoaderStatic.SKEW_Y] : 0; - var anchorx = options[ccui.CSLoaderStatic.ANCHOR_X] !=null ? options[ccui.CSLoaderStatic.ANCHOR_X] : 0.5; - var anchory = options[ccui.CSLoaderStatic.ANCHOR_Y] !=null ? options[ccui.CSLoaderStatic.ANCHOR_Y] : 0.5; - var alpha = options[ccui.CSLoaderStatic.ALPHA] !=null ? options[ccui.CSLoaderStatic.ALPHA] : 255; - var red = options[ccui.CSLoaderStatic.RED] !=null ? options[ccui.CSLoaderStatic.RED] : 255; - var green = options[ccui.CSLoaderStatic.GREEN] !=null ? options[ccui.CSLoaderStatic.GREEN] : 255; - var blue = options[ccui.CSLoaderStatic.BLUE] !=null ? options[ccui.CSLoaderStatic.BLUE] : 255; - var zorder = options[ccui.CSLoaderStatic.ZORDER] !=null ? options[ccui.CSLoaderStatic.ZORDER] : 0; - var tag = options[ccui.CSLoaderStatic.TAG] !=null ? options[ccui.CSLoaderStatic.TAG] : 0; - var actionTag = options[ccui.CSLoaderStatic.ACTION_TAG] !=null ? options[ccui.CSLoaderStatic.ACTION_TAG] : 0; - var visible = options[ccui.CSLoaderStatic.VISIBLE] !=null ? options[ccui.CSLoaderStatic.VISIBLE] : true; + var width = options["width"] !=null ? options["width"] : 0; + var height = options["height"] !=null ? options["height"] : 0; + var x = options["x"] !=null ? options["x"] : 0; + var y = options["y"] !=null ? options["y"] : 0; + var scalex = options["scaleX"] !=null ? options["scaleX"] : 1; + var scaley = options["scaleY"] !=null ? options["scaleY"] : 1; + var rotation = options["rotation"] !=null ? options["rotation"] : 0; + var rotationSkewX = options["rotationSkewX"]!=null ? options["rotationSkewX"] : 0; + var rotationSkewY = options["rotationSkewY"]!=null ? options["rotationSkewY"] : 0; + var skewx = options["skewX"] !=null ? options["skewX"] : 0; + var skewy = options["skewY"] !=null ? options["skewY"] : 0; + var anchorx = options["anchorPointX"] !=null ? options["anchorPointX"] : 0.5; + var anchory = options["anchorPointY"] !=null ? options["anchorPointY"] : 0.5; + var alpha = options["opacity"] !=null ? options["opacity"] : 255; + var red = options["colorR"] !=null ? options["colorR"] : 255; + var green = options["colorG"] !=null ? options["colorG"] : 255; + var blue = options["colorB"] !=null ? options["colorB"] : 255; + var zorder = options["colorR"] !=null ? options["colorR"] : 0; + var tag = options["tag"] !=null ? options["tag"] : 0; + var actionTag = options["actionTag"] !=null ? options["actionTag"] : 0; + var visible = options["visible"] !=null ? options["visible"] : true; if(x != 0 || y != 0) node.setPosition(cc.p(x, y)); @@ -188,10 +212,10 @@ return particle; }; parser.initTMXTiledMap = function(options, resourcePath){ - var tmxFile = options[ccui.CSLoaderStatic.TMX_FILE]; - var tmxString = options[ccui.CSLoaderStatic.TMX_STRING]; + var tmxFile = options["tmxFile"]; + var tmxString = options["tmxString"]; //todo check path and resourcePath - var path = options[ccui.CSLoaderStatic.RESOURCE_PATH]; + var path = options["resourcePath"]; var tmx = null; if (tmxFile && "" != tmxFile){ @@ -224,7 +248,7 @@ if(skewy != 0) node.setSkewY(skewy); - var actionTag = options[ccui.CSLoaderStatic.ACTION_TAG]; + var actionTag = options["actionTag"]; node.setUserObject(new ccs.ActionTimelineData(actionTag)); } return node; @@ -262,6 +286,6 @@ }); }); - load.registerParser("timeline", "1.*", parser); + load.registerParser("timeline", "*", parser); })(ccs._load, ccs._parser); \ No newline at end of file diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 60b9e16103..d98a52a06b 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + (function(load, baseParser){ var DEBUG = false; diff --git a/extensions/cocostudio/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js index 83de06d419..a89b01cddc 100644 --- a/extensions/cocostudio/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + (function(load, baseParser){ var Parser = baseParser.extend({ @@ -340,26 +364,10 @@ * ImageView parser (UIImageView) */ parser.ImageViewAttributes = function(widget, options, resourcePath){ - var imageFileName, - imageFileNameDic = options["fileNameData"], - imageFileNameType = imageFileNameDic["resourceType"]; - switch (imageFileNameType){ - case 0: - var tp_i = resourcePath; - imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = null; - if (imageFileName && imageFileName !== "") { - imageFileName_tp = tp_i + imageFileName; - widget.loadTexture(imageFileName_tp); - } - break; - case 1: - imageFileName = imageFileNameDic["path"]; - widget.loadTexture(imageFileName, 1/*ui.UI_TEX_TYPE_PLIST*/); - break; - default: - break; - } + var imageFileNameDic = options["fileNameData"] + getPath(resourcePath, imageFileNameDic["resourceType"], imageFileNameDic["path"], function(path, type){ + widget.loadTexture(path, type); + }); var scale9EnableExist = options["scale9Enable"]; var scale9Enable = false; @@ -657,7 +665,6 @@ }); }); - load.registerParser("ccui", "1.*", parser); - + load.registerParser("ccui", "*", parser); })(ccs._load, ccs._parser); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index af0f419530..fa4cbaa52e 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -372,38 +372,18 @@ "extensions/cocostudio/trigger/TriggerMng.js", "extensions/cocostudio/trigger/TriggerObj.js", - - "extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js", - "extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js", - "extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js", - "extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js", - "extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js", - "extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js", - "extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js", - "extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js", - "extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js", - "extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js", - "extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js", - "extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js", - "extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js", - "extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js", - "extensions/cocostudio/reader/widgetreader/WidgetReader.js", - - "extensions/cocostudio/reader/GUIReader.js", - "extensions/cocostudio/reader/SceneReader.js", - - "extensions/cocostudio/reader/timeline/ActionTimeline.js", - "extensions/cocostudio/reader/timeline/ActionTimelineCache.js", - "extensions/cocostudio/reader/timeline/Frame.js", - "extensions/cocostudio/reader/timeline/Timeline.js", - "extensions/cocostudio/reader/timeline/CSLoader.js", + "extensions/cocostudio/timeline/ActionTimeline.js", + "extensions/cocostudio/timeline/Frame.js", + "extensions/cocostudio/timeline/Timeline.js", "extensions/cocostudio/loader/load.js", + "extensions/cocostudio/loader/parsers/scene-1.x.js", "extensions/cocostudio/loader/parsers/uiParser-1.x.js", "extensions/cocostudio/loader/parsers/action-1.x.js", "extensions/cocostudio/loader/parsers/action-2.x.js", "extensions/cocostudio/loader/parsers/timelineParser-1.x.js", - "extensions/cocostudio/loader/parsers/timelineParser-2.x.js" + "extensions/cocostudio/loader/parsers/timelineParser-2.x.js", + "extensions/cocostudio/loader/parsers/compatible.js" ], From dd1b0c0bc91e63bf28d8e4db8c2eb17c8f3dd421 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 14:22:43 +0800 Subject: [PATCH 1150/1564] Issue #2563: remove excess file(Is compatible with the old interface - compatible.js) --- extensions/cocostudio/reader/GUIReader.js | 2096 ----------------- extensions/cocostudio/reader/SceneReader.js | 366 --- .../reader/timeline/ActionTimelineCache.js | 909 ------- .../cocostudio/reader/timeline/CSLoader.js | 729 ------ .../widgetreader/ButtonReader/ButtonReader.js | 128 - .../CheckBoxReader/CheckBoxReader.js | 96 - .../ImageViewReader/ImageViewReader.js | 93 - .../LabelAtlasReader/LabelAtlasReader.js | 69 - .../LabelBMFontReader/LabelBMFontReader.js | 65 - .../widgetreader/LabelReader/LabelReader.js | 75 - .../widgetreader/LayoutReader/LayoutReader.js | 122 - .../ListViewReader/ListViewReader.js | 52 - .../LoadingBarReader/LoadingBarReader.js | 87 - .../PageViewReader/PageViewReader.js | 42 - .../ScrollViewReader/ScrollViewReader.js | 52 - .../widgetreader/SliderReader/SliderReader.js | 160 -- .../TextFieldReader/TextFieldReader.js | 89 - .../reader/widgetreader/WidgetReader.js | 226 -- .../widgetreader/WidgetReaderProtocol.js | 30 - 19 files changed, 5486 deletions(-) delete mode 100644 extensions/cocostudio/reader/GUIReader.js delete mode 100644 extensions/cocostudio/reader/SceneReader.js delete mode 100644 extensions/cocostudio/reader/timeline/ActionTimelineCache.js delete mode 100644 extensions/cocostudio/reader/timeline/CSLoader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/ButtonReader/ButtonReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/CheckBoxReader/CheckBoxReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/ImageViewReader/ImageViewReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/LabelAtlasReader/LabelAtlasReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/LabelBMFontReader/LabelBMFontReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/LabelReader/LabelReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/LayoutReader/LayoutReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/ListViewReader/ListViewReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/LoadingBarReader/LoadingBarReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/PageViewReader/PageViewReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/ScrollViewReader/ScrollViewReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/SliderReader/SliderReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/TextFieldReader/TextFieldReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/WidgetReader.js delete mode 100644 extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js diff --git a/extensions/cocostudio/reader/GUIReader.js b/extensions/cocostudio/reader/GUIReader.js deleted file mode 100644 index ed96f8959b..0000000000 --- a/extensions/cocostudio/reader/GUIReader.js +++ /dev/null @@ -1,2096 +0,0 @@ -/**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -(function(){ - var factoryCreate = ccs.objectFactory; - - factoryCreate.registerType({_className:"ButtonReader", _fun: ccs.buttonReader}); - factoryCreate.registerType({_className: "CheckBoxReader", _fun: ccs.checkBoxReader}); - factoryCreate.registerType({_className: "SliderReader", _fun: ccs.sliderReader}); - factoryCreate.registerType({_className: "ImageViewReader", _fun: ccs.imageViewReader}); - factoryCreate.registerType({_className: "LoadingBarReader", _fun: ccs.loadingBarReader}); - factoryCreate.registerType({_className: "TextAtlasReader", _fun: ccs.labelAtlasReader}); - factoryCreate.registerType({_className: "TextReader", _fun: ccs.labelReader}); - factoryCreate.registerType({_className: "TextBMFontReader", _fun: ccs.labelBMFontReader}); - factoryCreate.registerType({_className: "TextFieldReader", _fun: ccs.textFieldReader}); - factoryCreate.registerType({_className: "LayoutReader", _fun: ccs.layoutReader}); - factoryCreate.registerType({_className: "PageViewReader", _fun: ccs.pageViewReader}); - factoryCreate.registerType({_className: "ScrollViewReader", _fun: ccs.scrollViewReader}); - factoryCreate.registerType({_className: "ListViewReader", _fun: ccs.listViewReader}); - factoryCreate.registerType({_className: "WidgetReader", _fun: ccs.widgetReader}); - - factoryCreate.registerType({_className: "Button", _fun: ccui.Button}); - factoryCreate.registerType({_className: "CheckBox", _fun: ccui.CheckBox}); - factoryCreate.registerType({_className: "ImageView", _fun: ccui.ImageView}); - factoryCreate.registerType({_className: "Text", _fun: ccui.Text}); - factoryCreate.registerType({_className: "TextAtlas", _fun: ccui.TextAtlas}); - factoryCreate.registerType({_className: "TextBMFont", _fun: ccui.TextBMFont}); - factoryCreate.registerType({_className: "LoadingBar", _fun: ccui.LoadingBar}); - factoryCreate.registerType({_className: "Slider", _fun: ccui.Slider}); - factoryCreate.registerType({_className: "TextField", _fun: ccui.TextField}); - factoryCreate.registerType({_className: "Layout", _fun: ccui.Layout}); - factoryCreate.registerType({_className: "ListView", _fun: ccui.ListView}); - factoryCreate.registerType({_className: "PageView", _fun: ccui.PageView}); - factoryCreate.registerType({_className: "ScrollView", _fun: ccui.ScrollView}); - -})(); - -/** - * ccs.uiReader is a singleton object which is the reader for Cocos Studio ui. - * @class - * @name ccs.uiReader - */ -ccs.uiReader = /** @lends ccs.uiReader# */{ - _filePath: "", - _olderVersion: false, - _fileDesignSizes: {}, - _mapObject: {}, - _mapParseSelector: {}, - - /** - * Gets the version number by version string. - * @param {String} str version string. - * @returns {Number} - */ - getVersionInteger: function (str) { - if(!str) - return 0; - var strVersion = str; - var versionLength = strVersion.length; - if (versionLength < 7) { - return 0; - } - var pos = strVersion.indexOf("."); - var t = strVersion.substr(0, pos); - strVersion = strVersion.substr(pos + 1, versionLength - 1); - - pos = strVersion.indexOf("."); - var h = strVersion.substr(0, pos); - strVersion = strVersion.substr(pos + 1, versionLength - 1); - - pos = strVersion.indexOf("."); - var te = strVersion.substr(0, pos); - strVersion = strVersion.substr(pos + 1, versionLength - 1); - - pos = strVersion.indexOf("."); - var s = (pos == -1) ? strVersion : strVersion.substr(0, pos); - - var it = parseInt(t); - var ih = parseInt(h); - var ite = parseInt(te); - var is = parseInt(s); - - return (it * 1000 + ih * 100 + ite * 10 + is); - }, - - /** - * stores the designSize of UI file. - * @param {String} fileName - * @param {cc.Size} size - */ - storeFileDesignSize: function (fileName, size) { - this._fileDesignSizes[fileName] = size; - }, - - /** - * Gets the design size by filename. - * @param {String} fileName - * @returns {cc.Size} - */ - getFileDesignSize: function (fileName) { - return this._fileDesignSizes[fileName]; - }, - - /** - * Creates uiWidget from a json file that exported by cocostudio UI editor - * @param {String} fileName - * @returns {ccui.Widget} - */ - widgetFromJsonFile: function (fileName) { - var jsonDict = cc.loader.getRes(fileName); - if(!jsonDict) throw "Please load the resource first : " + fileName; - - var tempFilePath = cc.path.dirname(fileName); - this._filePath = tempFilePath == "" ? tempFilePath : tempFilePath + "/"; - - var fileVersion = jsonDict["version"]; - var pReader, widget; - var versionInteger = this.getVersionInteger(fileVersion); - if (fileVersion) { - if (versionInteger < 250) { - pReader = new ccs.WidgetPropertiesReader0250(); - widget = pReader.createWidget(jsonDict, this._filePath, fileName); - } else { - pReader = new ccs.WidgetPropertiesReader0300(); - widget = pReader.createWidget(jsonDict, this._filePath, fileName); - } - } else { - pReader = new ccs.WidgetPropertiesReader0250(); - widget = pReader.createWidget(jsonDict, this._filePath, fileName); - } - - if (!fileVersion || versionInteger < 250) { - this._olderVersion = true; - } - jsonDict = null; - return widget; - }, - - /** - * Resets the states and clear the file design sizes. - */ - clear: function () { - this._filePath = ""; - this._olderVersion = false; - this._fileDesignSizes = {}; - }, - - /** - * Registers class type and callback. - * @param {String} classType - * @param {ccs.objectFactory} ins - * @param {Object} object - * @param {function} callback - */ - registerTypeAndCallBack: function(classType, ins, object, callback){ - var factoryCreate = ccs.objectFactory; - var t = new ccs.TInfo(classType, ins); - factoryCreate.registerType(t); - - if(object) - this._mapObject[classType] = object; - if(callback) - this._mapParseSelector[classType] = callback; - }, - - /** - * Returns the file path - * @returns {string} - */ - getFilePath: function(){ - return this._filePath; - }, - - setFilePath: function(path){ - this._filePath = path; - }, - - /** - * Returns the parsed object map. - * @returns {Object} - */ - getParseObjectMap: function(){ - return this._mapObject; - }, - - /** - * Returns the parsed callback map. - * @returns {*} - */ - getParseCallBackMap: function(){ - return this._mapParseSelector; - } -}; - -/** - * The base class of widget properties reader. It parse the foundation properties of widget. - * @class - * @extends ccs.Class - */ -ccs.WidgetPropertiesReader = ccs.Class.extend(/** @lends ccs.WidgetPropertiesReader# */{ - _filePath: "", - - /** - * Create a widget object by json object. - * @param {Object} jsonDict - * @param {String} fullPath - * @param {String} fileName - */ - createWidget: function (jsonDict, fullPath, fileName) { - }, - - /** - * Parses the widget properties. - * @param {Object} data - */ - widgetFromJsonDictionary: function (data) { - }, - - _createGUI: function(className){ - var name = this._getGUIClassName(className); - return ccs.objectFactory.createObject(name); - }, - - _getGUIClassName: function(name){ - var convertedClassName = name; - if (name == "Panel") - convertedClassName = "Layout"; - else if (name == "TextArea") - convertedClassName = "Text"; - else if (name == "TextButton") - convertedClassName = "Button"; - else if (name == "Label") - convertedClassName = "Text"; - else if (name == "LabelAtlas") - convertedClassName = "TextAtlas"; - else if (name == "LabelBMFont") - convertedClassName = "TextBMFont"; - else if (name == "Node") - convertedClassName = "Layout"; - return convertedClassName; - }, - - _getWidgetReaderClassName: function(className){ - // create widget reader to parse properties of widget - var readerName = className; - if (readerName == "Panel") - readerName = "Layout"; - else if (readerName == "TextArea") - readerName = "Text"; - else if (readerName == "TextButton") - readerName = "Button"; - else if (readerName == "Label") - readerName = "Text"; - else if (readerName == "LabelAtlas") - readerName = "TextAtlas"; - else if (readerName == "LabelBMFont") - readerName = "TextBMFont"; - readerName += "Reader"; - return readerName; - }, - - _getWidgetReaderClassNameFromWidget: function(widget){ - var readerName = ""; - // 1st., custom widget parse properties of parent widget with parent widget reader - if (widget instanceof ccui.Button) - readerName = "ButtonReader"; - else if (widget instanceof ccui.CheckBox) - readerName = "CheckBoxReader"; - else if (widget instanceof ccui.ImageView) - readerName = "ImageViewReader"; - else if (widget instanceof ccui.TextAtlas) - readerName = "TextAtlasReader"; - else if (widget instanceof ccui.TextBMFont) - readerName = "TextBMFontReader"; - else if (widget instanceof ccui.Text) - readerName = "TextReader"; - else if (widget instanceof ccui.LoadingBar) - readerName = "LoadingBarReader"; - else if (widget instanceof ccui.Slider) - readerName = "SliderReader"; - else if (widget instanceof ccui.TextField) - readerName = "TextFieldReader"; - else if (widget instanceof ccui.ListView) - readerName = "ListViewReader"; - else if (widget instanceof ccui.PageView) - readerName = "PageViewReader"; - else if (widget instanceof ccui.ScrollView) - readerName = "ScrollViewReader"; - else if (widget instanceof ccui.Layout) - readerName = "LayoutReader"; - else if (widget instanceof ccui.Widget) - readerName = "WidgetReader"; - - return readerName; - }, - - _createWidgetReaderProtocol: function(className){ - return ccs.objectFactory.createObject(className); - } -}); - -/** - * The widget properties reader to parse Cocostudio exported file v0.3 -- v1.0 - * @class - * @extends ccs.WidgetPropertiesReader - */ -ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend(/** @lends ccs.WidgetPropertiesReader0250# */{ - /** - * Creates a widget by json object. - * @param {Object} jsonDict - * @param {string} fullPath - * @param {string} fileName - * @returns {*} - */ - createWidget: function (jsonDict, fullPath, fileName) { - this._filePath = fullPath == "" ? fullPath : cc.path.join(fullPath, "/"); - var textures = jsonDict["textures"]; - for (var i = 0; i < textures.length; i++) { - var file = textures[i]; - var tp = fullPath; - tp += file; - cc.spriteFrameCache.addSpriteFrames(tp); - } - var fileDesignWidth = jsonDict["designWidth"]; - var fileDesignHeight = jsonDict["designHeight"]; - if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { - cc.log("Read design size error!"); - var winSize = cc.director.getWinSize(); - ccs.uiReader.storeFileDesignSize(fileName, winSize); - } else - ccs.uiReader.storeFileDesignSize(fileName, cc.size(fileDesignWidth, fileDesignHeight)); - var widgetTree = jsonDict["widgetTree"]; - var widget = this.widgetFromJsonDictionary(widgetTree); - - var size = widget.getContentSize(); - if (size.width == 0 && size.height == 0) - widget.setSize(cc.size(fileDesignWidth, fileDesignHeight)); - - var actions = jsonDict["animation"]; - ccs.actionManager.initWithDictionary(fileName, actions, widget); - widgetTree = null; - actions = null; - return widget; - }, - - /** - * Creates a widget by json dictionary. - * @param {Object} data - * @returns {ccui.Widget} - */ - widgetFromJsonDictionary: function (data) { - var widget = null; - var classname = data["classname"]; - var uiOptions = data["options"]; - if (classname == "Button") { - widget = new ccui.Button(); - this.setPropsForButtonFromJsonDictionary(widget, uiOptions); - } else if (classname == "CheckBox") { - widget = new ccui.CheckBox(); - this.setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); - } else if (classname == "Label") { - widget = new ccui.Text(); - this.setPropsForLabelFromJsonDictionary(widget, uiOptions); - } else if (classname == "LabelAtlas") { - widget = new ccui.TextAtlas(); - this.setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); - } else if (classname == "LoadingBar") { - widget = new ccui.LoadingBar(); - this.setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); - } else if (classname == "ScrollView") { - widget = new ccui.ScrollView(); - this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); - } else if (classname == "TextArea") { - widget = new ccui.Text(); - this.setPropsForLabelFromJsonDictionary(widget, uiOptions); - } else if (classname == "TextButton") { - widget = new ccui.Button(); - this.setPropsForButtonFromJsonDictionary(widget, uiOptions); - } else if (classname == "TextField") { - widget = new ccui.TextField(); - this.setPropsForTextFieldFromJsonDictionary(widget, uiOptions); - } else if (classname == "ImageView") { - widget = new ccui.ImageView(); - this.setPropsForImageViewFromJsonDictionary(widget, uiOptions); - } else if (classname == "Panel") { - widget = new ccui.Layout(); - this.setPropsForLayoutFromJsonDictionary(widget, uiOptions); - } else if (classname == "Slider") { - widget = new ccui.Slider(); - this.setPropsForSliderFromJsonDictionary(widget, uiOptions); - } else if (classname == "LabelBMFont") { - widget = new ccui.TextBMFont(); - this.setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); - } else if (classname == "DragPanel") { - widget = new ccui.ScrollView(); - this.setPropsForScrollViewFromJsonDictionary(widget, uiOptions); - } - var children = data["children"]; - for (var i = 0; i < children.length; i++) { - var subData = children[i]; - var child = this.widgetFromJsonDictionary(subData); - if (child) - widget.addChild(child); - subData = null; - } - uiOptions = null; - return widget; - }, - - /** - * Sets widget's properties from json dictionary. - * @param {ccui.Widget} widget - * @param {Object} options the json dictionary. - */ - setPropsForWidgetFromJsonDictionary: function (widget, options) { - if (options["ignoreSize"] !== undefined) - widget.ignoreContentAdaptWithSize(options["ignoreSize"]); - - var w = options["width"]; - var h = options["height"]; - widget.setSize(cc.size(w, h)); - - widget.setTag(options["tag"]); - widget.setActionTag(options["actiontag"]); - widget.setTouchEnabled(options["touchAble"]); - var name = options["name"]; - var widgetName = name ? name : "default"; - widget.setName(widgetName); - var x = options["x"]; - var y = options["y"]; - widget.setPosition(cc.p(x, y)); - if (options["scaleX"] !== undefined) { - widget.setScaleX(options["scaleX"]); - } - if (options["scaleY"] !== undefined) { - widget.setScaleY(options["scaleY"]); - } - if (options["rotation"] !== undefined) { - widget.setRotation(options["rotation"]); - } - if (options["visible"] !== undefined) { - widget.setVisible(options["visible"]); - } - - var z = options["ZOrder"]; - widget.setLocalZOrder(z); - }, - - /** - * Sets all widgets' properties from json dictionary. - */ - setPropsForAllWidgetFromJsonDictionary: function(){}, - - /** - * Sets all custom widget's properties from json dictionary. - */ - setPropsForAllCustomWidgetFromJsonDictionary: function(){}, - - /** - * Sets widget's color, anchor point, flipped properties from json object. - * @param {ccui.Widget} widget - * @param {Object} options json object. - */ - setColorPropsForWidgetFromJsonDictionary: function (widget, options) { - if (options["opacity"] !== undefined) { - widget.setOpacity(options["opacity"]); - } - var colorR = options["colorR"] !== undefined ? options["colorR"] : 255; - var colorG = options["colorG"] !== undefined ? options["colorG"] : 255; - var colorB = options["colorB"] !== undefined ? options["colorB"] : 255; - widget.setColor(cc.color(colorR, colorG, colorB)); - var apx = options["anchorPointX"] !== undefined ? options["anchorPointX"] : ((widget.getWidgetType() == ccui.Widget.TYPE_WIDGET) ? 0.5 : 0); - var apy = options["anchorPointY"] !== undefined ? options["anchorPointY"] : ((widget.getWidgetType() == ccui.Widget.TYPE_WIDGET) ? 0.5 : 0); - widget.setAnchorPoint(apx, apy); - var flipX = options["flipX"]; - var flipY = options["flipY"]; - widget.setFlippedX(flipX); - widget.setFlippedY(flipY); - }, - - /** - * Sets ccui.Button's properties from json object. - * @param {ccui.Button} widget - * @param {Object} options - */ - setPropsForButtonFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var button = widget; - var scale9Enable = options["scale9Enable"]; - button.setScale9Enabled(scale9Enable); - - var normalFileName = options["normal"]; - var pressedFileName = options["pressed"]; - var disabledFileName = options["disabled"]; - - var normalFileName_tp = normalFileName ? this._filePath + normalFileName : null; - var pressedFileName_tp = pressedFileName ? this._filePath + pressedFileName : null; - var disabledFileName_tp = disabledFileName ? this._filePath + disabledFileName : null; - var useMergedTexture = options["useMergedTexture"]; - if (scale9Enable) { - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]; - var ch = options["capInsetsHeight"]; - - if (useMergedTexture) - button.loadTextures(normalFileName, pressedFileName, disabledFileName, ccui.Widget.PLIST_TEXTURE); - else - button.loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - //button.setCapInsets(cc.rect(cx, cy, cw, ch)); - if (options["scale9Width"] !== undefined && options["scale9Height"] !== undefined) { - var swf = options["scale9Width"]; - var shf = options["scale9Height"]; - button.setSize(cc.size(swf, shf)); - } - } else { - if (useMergedTexture) - button.loadTextures(normalFileName, pressedFileName, disabledFileName, ccui.Widget.PLIST_TEXTURE); - else - button.loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } - if (options["text"] !== undefined) { - var text = options["text"] || ""; - if (text) - button.setTitleText(text); - } - if (options["fontSize"] !== undefined) { - button.setTitleFontSize(options["fontSize"]); - } - if (options["fontName"] !== undefined) { - button.setTitleFontName(options["fontName"]); - } - var cr = options["textColorR"] !== undefined ? options["textColorR"] : 255; - var cg = options["textColorG"] !== undefined ? options["textColorG"] : 255; - var cb = options["textColorB"] !== undefined ? options["textColorB"] : 255; - var tc = cc.color(cr, cg, cb); - button.setTitleColor(tc); - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.CheckBox's properties from json object. - * @param {ccui.CheckBox} widget - * @param {Object} options - */ - setPropsForCheckBoxFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var checkBox = widget; - var backGroundFileName = options["backGroundBox"]; - var backGroundSelectedFileName = options["backGroundBoxSelected"]; - var frontCrossFileName = options["frontCross"]; - var backGroundDisabledFileName = options["backGroundBoxDisabled"]; - var frontCrossDisabledFileName = options["frontCrossDisabled"]; - - var locFilePath = this._filePath; - - var backGroundFileName_tp = backGroundFileName ? locFilePath + backGroundFileName : null; - var backGroundSelectedFileName_tp = backGroundSelectedFileName ? locFilePath + backGroundSelectedFileName : null; - var frontCrossFileName_tp = frontCrossFileName ? locFilePath + frontCrossFileName : null; - var backGroundDisabledFileName_tp = backGroundDisabledFileName ? locFilePath + backGroundDisabledFileName : null; - var frontCrossDisabledFileName_tp = frontCrossDisabledFileName ? locFilePath + frontCrossDisabledFileName : null; - var useMergedTexture = options["useMergedTexture"]; - - if (useMergedTexture) { - checkBox.loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName, backGroundDisabledFileName, frontCrossDisabledFileName, ccui.Widget.PLIST_TEXTURE); - } - else { - checkBox.loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp, backGroundDisabledFileName_tp, frontCrossDisabledFileName_tp); - } - - checkBox.setSelected(options["selectedState"] || false); - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.ImageView's properties from json object. - * @param {ccui.ImageView} widget - * @param {Object} options - */ - setPropsForImageViewFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - - var imageView = widget; - var imageFileName = options["fileName"]; - var scale9Enable = options["scale9Enable"] || false; - imageView.setScale9Enabled(scale9Enable); - - var tp_i = this._filePath; - var imageFileName_tp = null; - if (imageFileName) - imageFileName_tp = tp_i + imageFileName; - - var useMergedTexture = options["useMergedTexture"]; - if (scale9Enable) { - if (useMergedTexture) { - imageView.loadTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } - else { - imageView.loadTexture(imageFileName_tp); - } - - if (options["scale9Width"] !== undefined && options["scale9Height"] !== undefined) { - var swf = options["scale9Width"]; - var shf = options["scale9Height"]; - imageView.setSize(cc.size(swf, shf)); - } - - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]; - var ch = options["capInsetsHeight"]; - imageView.setCapInsets(cc.rect(cx, cy, cw, ch)); - - } - else { - if (useMergedTexture) { - imageView.loadTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } - else { - imageView.loadTexture(imageFileName_tp); - } - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.Text's properties from json object. - * @param {ccui.Text} widget - * @param {Object} options json dictionary - */ - setPropsForLabelFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var label = widget; - var touchScaleChangeAble = options["touchScaleEnable"]; - label.setTouchScaleChangeEnabled(touchScaleChangeAble); - var text = options["text"]; - label.setString(text); - if (options["fontSize"] !== undefined) { - label.setFontSize(options["fontSize"]); - } - if (options["fontName"] !== undefined) { - label.setFontName(options["fontName"]); - } - if (options["areaWidth"] !== undefined && options["areaHeight"] !== undefined) { - var size = cc.size(options["areaWidth"], options["areaHeight"]); - label.setTextAreaSize(size); - } - if (options["hAlignment"]) { - label.setTextHorizontalAlignment(options["hAlignment"]); - } - if (options["vAlignment"]) { - label.setTextVerticalAlignment(options["vAlignment"]); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.TextAtlas' properties from json object. - * @param {ccui.TextAtlas} widget - * @param {Object} options - */ - setPropsForLabelAtlasFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var labelAtlas = widget; - - var cmft = options["charMapFileData"], svValue = options["stringValue"], iwValue = options["itemWidth"]; - var ihValue = options["itemHeight"], scmValue = options["startCharMap"]; - var sv = (svValue !== undefined); - var cmf = (cmft !== undefined); - var iw = (iwValue !== undefined); - var ih = (ihValue !== undefined); - var scm = (scmValue !== undefined); - if (sv && cmf && iw && ih && scm && cmft) { - var cmf_tp = this._filePath + cmft; - labelAtlas.setProperty(svValue, cmf_tp, iwValue, ihValue, scmValue); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.Layout's properties from json object. - * @param {ccui.Layout} widget - * @param {Object} options - */ - setPropsForLayoutFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var containerWidget = widget; - if (!(containerWidget instanceof ccui.ScrollView) && !(containerWidget instanceof ccui.ListView)) { - containerWidget.setClippingEnabled(options["clipAble"]); - } - var panel = widget; - var backGroundScale9Enable = options["backGroundScale9Enable"]; - panel.setBackGroundImageScale9Enabled(backGroundScale9Enable); - var cr = options["bgColorR"]; - var cg = options["bgColorG"]; - var cb = options["bgColorB"]; - - var scr = options["bgStartColorR"]; - var scg = options["bgStartColorG"]; - var scb = options["bgStartColorB"]; - - var ecr = options["bgEndColorR"]; - var ecg = options["bgEndColorG"]; - var ecb = options["bgEndColorB"]; - - var bgcv1 = options["vectorX"]; - var bgcv2 = options["vectorY"]; - panel.setBackGroundColorVector(cc.p(bgcv1, bgcv2)); - - var co = options["bgColorOpacity"]; - - var colorType = options["colorType"]; - panel.setBackGroundColorType(colorType); - panel.setBackGroundColor(cc.color(scr, scg, scb), cc.color(ecr, ecg, ecb)); - panel.setBackGroundColor(cc.color(cr, cg, cb)); - panel.setBackGroundColorOpacity(co); - - var imageFileName = options["backGroundImage"]; - var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; - var useMergedTexture = options["useMergedTexture"]; - if (useMergedTexture) { - panel.setBackGroundImage(imageFileName, ccui.Widget.PLIST_TEXTURE); - } - else { - panel.setBackGroundImage(imageFileName_tp); - } - if (backGroundScale9Enable) { - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]; - var ch = options["capInsetsHeight"]; - panel.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.ScrollView's properties from json dictionary. - * @param {ccui.ScrollView} widget - * @param {Object} options json dictionary. - */ - setPropsForScrollViewFromJsonDictionary: function (widget, options) { - this.setPropsForLayoutFromJsonDictionary(widget, options); - var scrollView = widget; - var innerWidth = options["innerWidth"]; - var innerHeight = options["innerHeight"]; - scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); - var direction = options["direction"]; - scrollView.setDirection(direction); - scrollView.setBounceEnabled(options["bounceEnable"]); - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets the container's properties from json dictionary. - * @param {ccui.Widget} widget - * @param {Object} options json dictionary. - */ - setPropsForContainerWidgetFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var containerWidget = widget; - if (containerWidget instanceof ccui.ScrollView || - containerWidget instanceof ccui.ListView) { - containerWidget.setClippingEnabled(options["clipAble"]); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.Slider's properties from json dictionary. - * @param {ccui.Slider} widget - * @param {Object} options json dictionary. - */ - setPropsForSliderFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var slider = widget; - - var barTextureScale9Enable = options["barTextureScale9Enable"] || false; - slider.setScale9Enabled(barTextureScale9Enable); - var barLength = options["length"]; - var useMergedTexture = options["useMergedTexture"]; - var bt = (options["barFileName"] !== undefined); - if (bt) { - if (barTextureScale9Enable) { - var imageFileName = options["barFileName"]; - var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; - if (useMergedTexture) { - slider.loadBarTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } else { - slider.loadBarTexture(imageFileName_tp); - } - slider.setSize(cc.size(barLength, slider.getContentSize().height)); - } else { - var imageFileName = options["barFileName"]; - var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; - if (useMergedTexture) { - slider.loadBarTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } else { - slider.loadBarTexture(imageFileName_tp); - } - } - } - - var normalFileName = options["ballNormal"]; - var pressedFileName = options["ballPressed"]; - var disabledFileName = options["ballDisabled"]; - - var normalFileName_tp = normalFileName ? this._filePath + normalFileName : null; - var pressedFileName_tp = pressedFileName ? this._filePath + pressedFileName : null; - var disabledFileName_tp = disabledFileName ? this._filePath + disabledFileName : null; - if (useMergedTexture) { - slider.loadSlidBallTextures(normalFileName, pressedFileName, disabledFileName, ccui.Widget.PLIST_TEXTURE); - } else { - slider.loadSlidBallTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } - slider.setPercent(options["percent"]); - - var imageFileName = options["progressBarFileName"]; - var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; - if (useMergedTexture) { - slider.loadProgressBarTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } else { - slider.loadProgressBarTexture(imageFileName_tp); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.TextField's properties from json object. - * @param {ccui.TextField} widget - * @param {Object} options - */ - setPropsForTextAreaFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var textArea = widget; - textArea.setString(options["text"]); - if (options["fontSize"] !== undefined) { - textArea.setFontSize(options["fontSize"]); - } - var cr = options["colorR"]; - var cg = options["colorG"]; - var cb = options["colorB"]; - textArea.setColor(cc.color((cr == null) ? 255 : cr, (cg == null) ? 255 : cg, (cb == null) ? 255 : cb)); - textArea.setFontName(options["fontName"]); - if (options["areaWidth"] !== undefined && options["areaHeight"] !== undefined) { - var size = cc.size(options["areaWidth"], options["areaHeight"]); - textArea.setTextAreaSize(size); - } - if (options["hAlignment"]) { - textArea.setTextHorizontalAlignment(options["hAlignment"]); - } - if (options["vAlignment"]) { - textArea.setTextVerticalAlignment(options["vAlignment"]); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.Button's text properties from json dictionary. - * @param {ccui.Button} widget - * @param {Object} options - */ - setPropsForTextButtonFromJsonDictionary: function (widget, options) { - this.setPropsForButtonFromJsonDictionary(widget, options); - - var textButton = widget; - textButton.setTitleText(options["text"] || ""); - var cri = options["textColorR"] !== undefined ? options["textColorR"] : 255; - var cgi = options["textColorG"] !== undefined ? options["textColorG"] : 255; - var cbi = options["textColorB"] !== undefined ? options["textColorB"] : 255; - textButton.setTitleColor(cc.color(cri, cgi, cbi)); - if (options["fontSize"] !== undefined) - textButton.setTitleFontSize(options["fontSize"]); - if (options["fontName"] !== undefined) - textButton.setTitleFontName(options["fontName"]); - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.TextField's properties from json dictionary. - * @param {ccui.TextField} widget - * @param {Object} options json dictionary - */ - setPropsForTextFieldFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var textField = widget; - if (options["placeHolder"] !== undefined) { - textField.setPlaceHolder(options["placeHolder"]); - } - textField.setString(options["text"]); - if (options["fontSize"] !== undefined) { - textField.setFontSize(options["fontSize"]); - } - if (options["fontName"] !== undefined) { - textField.setFontName(options["fontName"]); - } - if (options["touchSizeWidth"] !== undefined && options["touchSizeHeight"] !== undefined) { - textField.setTouchSize(cc.size(options["touchSizeWidth"], options["touchSizeHeight"])); - } - - var dw = options["width"]; - var dh = options["height"]; - if (dw > 0.0 || dh > 0.0) { - //textField.setSize(CCSizeMake(dw, dh)); - } - var maxLengthEnable = options["maxLengthEnable"]; - textField.setMaxLengthEnabled(maxLengthEnable); - - if (maxLengthEnable) { - var maxLength = options["maxLength"]; - textField.setMaxLength(maxLength); - } - var passwordEnable = options["passwordEnable"]; - textField.setPasswordEnabled(passwordEnable); - if (passwordEnable) { - textField.setPasswordStyleText(options["passwordStyleText"]); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.LoadingBar's properties from json dictionary. - * @param {ccui.LoadingBar} widget - * @param {Object} options json dictionary - */ - setPropsForLoadingBarFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var loadingBar = widget; - var useMergedTexture = options["useMergedTexture"]; - var imageFileName = options["texture"]; - var imageFileName_tp = imageFileName ? this._filePath + imageFileName : null; - if (useMergedTexture) { - loadingBar.loadTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - } else { - loadingBar.loadTexture(imageFileName_tp); - } - loadingBar.setDirection(options["direction"]); - loadingBar.setPercent(options["percent"]); - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.ListView's properties from json dictionary. - * @param {ccui.ListView} widget - * @param {Object} options json dictionary - */ - setPropsForListViewFromJsonDictionary: function (widget, options) { - this.setPropsForLayoutFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.PageView's properties from json dictionary. - * @param {ccui.PageView} widget - * @param {Object} options json dictionary - */ - setPropsForPageViewFromJsonDictionary: function (widget, options) { - this.setPropsForLayoutFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.TextBMFont's properties from json dictionary. - * @param {ccui.TextBMFont} widget - * @param {Object} options json dictionary - */ - setPropsForLabelBMFontFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var labelBMFont = widget; - var cmft = options["fileName"]; - var cmf_tp = this._filePath + cmft; - labelBMFont.setFntFile(cmf_tp); - var text = options["text"]; - labelBMFont.setString(text); - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - } -}); - -/** - * The widget properties reader to parse Cocostudio exported file v1.0 higher. - * @class - * @extends ccs.WidgetPropertiesReader - */ -ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend(/** @lends ccs.WidgetPropertiesReader0300# */{ - /** - * Creates widget by json object. - * @param {Object} jsonDict json dictionary - * @param {String} fullPath - * @param {String} fileName - * @returns {ccui.Widget} - */ - createWidget: function (jsonDict, fullPath, fileName) { - this._filePath = fullPath == "" ? fullPath : cc.path.join(fullPath, "/"); - var textures = jsonDict["textures"]; - for (var i = 0; i < textures.length; i++) { - var file = textures[i]; - var tp = fullPath; - tp += file; - cc.spriteFrameCache.addSpriteFrames(tp); - } - var fileDesignWidth = jsonDict["designWidth"]; - var fileDesignHeight = jsonDict["designHeight"]; - if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { - cc.log("Read design size error!"); - var winSize = cc.director.getWinSize(); - ccs.uiReader.storeFileDesignSize(fileName, winSize); - } else - ccs.uiReader.storeFileDesignSize(fileName, cc.size(fileDesignWidth, fileDesignHeight)); - var widgetTree = jsonDict["widgetTree"]; - var widget = this.widgetFromJsonDictionary(widgetTree); - - var size = widget.getContentSize(); - widget.setSize(cc.size(fileDesignWidth, fileDesignHeight)); - - var actions = jsonDict["animation"]; - ccs.actionManager.initWithDictionary(fileName, actions, widget); - - widgetTree = null; - actions = null; - return widget; - }, - - /** - * Sets widget's foundation properties from json dictionary. - * @param {Object} reader widget reader - * @param {ccui.Widget} widget - * @param {Object} options json dictionary - */ - setPropsForAllWidgetFromJsonDictionary: function(reader, widget, options){ - if(reader && reader.setPropsFromJsonDictionary) - reader.setPropsFromJsonDictionary(widget, options); - }, - - /** - * Sets widget's custom properties from json dictionary - * @param {String} classType class type - * @param {ccui.Widget} widget - * @param {Object} customOptions - */ - setPropsForAllCustomWidgetFromJsonDictionary: function(classType, widget, customOptions){ - var guiReader = ccs.uiReader; - var object_map = guiReader.getParseObjectMap(); - var object = object_map[classType]; - - var selector_map = guiReader.getParseCallBackMap(); - var selector = selector_map[classType]; - - if (object && selector) - selector.call(object, classType, widget, customOptions); - }, - - /** - * Creates a widget from json dictionary. - * @param {Object} data json data - * @returns {ccui.Widget} - */ - widgetFromJsonDictionary: function (data) { - var classname = data["classname"]; - var uiOptions = data["options"]; - var widget = this._createGUI(classname); - - var readerName = this._getWidgetReaderClassName(classname); - var reader = this._createWidgetReaderProtocol(readerName); - - if (reader){ - // widget parse with widget reader - this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); - } else { - readerName = this._getWidgetReaderClassNameFromWidget(widget); - - reader = ccs.objectFactory.createObject(readerName); - - if (reader && widget) { - this.setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); - - // 2nd., custom widget parse with custom reader - var customProperty = uiOptions["customProperty"]; - var customJsonDict = JSON.parse(customProperty); - this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); - }else{ - cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); - } - - } - - var childrenItem = data["children"]; - for(var i=0; i 0.0 || dh > 0.0) { - //textField.setSize(CCSizeMake(dw, dh)); - } - var maxLengthEnable = options["maxLengthEnable"]; - textField.setMaxLengthEnabled(maxLengthEnable); - - if (maxLengthEnable) { - var maxLength = options["maxLength"]; - textField.setMaxLength(maxLength); - } - var passwordEnable = options["passwordEnable"]; - textField.setPasswordEnabled(passwordEnable); - if (passwordEnable) { - textField.setPasswordStyleText(options["passwordStyleText"]); - } - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.LoadingBar's properties from json dictionary. - * @param {ccui.LoadingBar} widget - * @param {Object} options json dictionary - */ - setPropsForLoadingBarFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - var loadingBar = widget; - - var imageFileNameDic = options["textureData"]; - var imageFileNameType = imageFileNameDic["resourceType"]; - switch (imageFileNameType) { - case 0: - var tp_i = this._filePath; - var imageFileName = imageFileNameDic["path"]; - var imageFileName_tp = null; - if (imageFileName) { - imageFileName_tp = tp_i + imageFileName; - loadingBar.loadTexture(imageFileName_tp); - } - break; - case 1: - var imageFileName = imageFileNameDic["path"]; - loadingBar.loadTexture(imageFileName, ccui.Widget.PLIST_TEXTURE); - break; - default: - break; - } - imageFileNameDic = null; - - var scale9Enable = options["scale9Enable"]; - loadingBar.setScale9Enabled(scale9Enable); - - if (scale9Enable) { - var cx = options["capInsetsX"]; - var cy = options["capInsetsY"]; - var cw = options["capInsetsWidth"]; - var ch = options["capInsetsHeight"]; - - loadingBar.setCapInsets(cc.rect(cx, cy, cw, ch)); - - var width = options["width"]; - var height = options["height"]; - loadingBar.setSize(cc.size(width, height)); - } - - loadingBar.setDirection(options["direction"]); - loadingBar.setPercent(options["percent"]); - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - - }, - - /** - * Sets ccui.ListView's properties from json dictionary. - * @param {ccui.ListView} widget - * @param {Object} options json dictionary - */ - setPropsForListViewFromJsonDictionary: function (widget, options) { - this.setPropsForLayoutFromJsonDictionary(widget, options); - var innerWidth = options["innerWidth"] || 0; - var innerHeight = options["innerHeight"] || 0; - widget.setInnerContainerSize(cc.size(innerWidth, innerHeight)); - widget.setDirection(options["direction"] || 0); - widget.setGravity(options["gravity"] || 0); - widget.setItemsMargin(options["itemMargin"] || 0); - }, - - /** - * Sets ccui.PageView's properties from json dictionary. - * @param {ccui.PageView} widget - * @param {Object} options json dictionary - */ - setPropsForPageViewFromJsonDictionary: function (widget, options) { - this.setPropsForLayoutFromJsonDictionary(widget, options); - }, - - /** - * Sets ccui.TextBMFont's properties from json dictionary. - * @param {ccui.TextBMFont} widget - * @param {Object} options json dictionary - */ - setPropsForLabelBMFontFromJsonDictionary: function (widget, options) { - this.setPropsForWidgetFromJsonDictionary(widget, options); - - var labelBMFont = widget; - - var cmftDic = options["fileNameData"]; - var cmfType = cmftDic["resourceType"]; - switch (cmfType) { - case 0: - var cmfPath = cmftDic["path"]; - var cmf_tp = this._filePath + cmfPath; - labelBMFont.setFntFile(cmf_tp); - break; - case 1: - cc.log("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - cmftDic = null; - - var text = options["text"]; - labelBMFont.setString(text); - - this.setColorPropsForWidgetFromJsonDictionary(widget, options); - }, - - widgetFromXML: function(objectData, classType){ - var classname = classType.substr(0, classType.find("ObjectData")); - //cc.log("classname = %s", classname); - - var widget = this.createGUI(classname); - var readerName = this.getWidgetReaderClassName(classname); - - var reader = this.createWidgetReaderProtocol(readerName); - - if (reader) - { - // widget parse with widget reader - this.setPropsForAllWidgetFromXML(reader, widget, objectData); - } - else - { - // - // 1st., custom widget parse properties of parent widget with parent widget reader - readerName = this.getWidgetReaderClassName(widget); - reader = this.createWidgetReaderProtocol(readerName); - if (reader && widget) - { - this.setPropsForAllWidgetFromXML(reader, widget, objectData); - - // 2nd., custom widget parse with custom reader - // const protocolbuffers::WidgetOptions& widgetOptions = nodetree.widgetoptions(); - // const char* customProperty = widgetOptions.customproperty().c_str(); - var customProperty = ""; - var customJsonDict; - customJsonDict.Parse(customProperty); - if (customJsonDict.HasParseError()) - { - cc.log("GetParseError %s\n", customJsonDict.GetParseError()); - } - this.setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); - } - else - { - cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."); - } - // - } - - - - - - // children - var containChildrenElement = false; - objectData = objectData.FirstChildElement(); - - while (objectData) - { - //cc.log("objectData name = %s", objectData.Name()); - - if ("Children" !== objectData.Name()) - { - containChildrenElement = true; - break; - } - - objectData = objectData.NextSiblingElement(); - } - - if (containChildrenElement) - { - objectData = objectData.FirstChildElement(); - //cc.log("objectData name = %s", objectData.Name()); - - while (objectData) - { - var attribute = objectData.FirstAttribute(); - while (attribute) - { - var name = attribute.Name(); - var value = attribute.Value(); - - if (name == "ctype") - { - var child = this.widgetFromXML(objectData, value); - //cc.log("child = %p", child); - if (child) - { - var pageView = widget; - var listView = widget; - if (pageView instanceof ccui.PageView) - { - var layout = child; - if (layout instanceof ccui.Layout) - { - pageView.addPage(layout); - } - } - else if (listView) - { - var widgetChild = child; - if (widgetChild instanceof ccui.Widget) - { - listView.pushBackCustomItem(widgetChild); - } - } - else - { - widget.addChild(child); - } - } - - break; - } - - attribute = attribute.Next(); - } - - // Node* child = nodeFromXML(objectData, value); - // CCLOG("child = %p", child); - // if (child) - // { - // PageView* pageView = dynamic_cast(node); - // ListView* listView = dynamic_cast(node); - // if (pageView) - // { - // Layout* layout = dynamic_cast(child); - // if (layout) - // { - // pageView.addPage(layout); - // } - // } - // else if (listView) - // { - // Widget* widget = dynamic_cast(child); - // if (widget) - // { - // listView.pushBackCustomItem(widget); - // } - // } - // else - // { - // node.addChild(child); - // } - // } - - objectData = objectData.NextSiblingElement(); - } - } - // - - //cc.log("widget = %p", widget); - - return widget; - }, - - setPropsForAllWidgetFromXML: function(reader, widget, objectData){ - reader.setPropsFromXML(widget, objectData); - } - -}); diff --git a/extensions/cocostudio/reader/SceneReader.js b/extensions/cocostudio/reader/SceneReader.js deleted file mode 100644 index f085421994..0000000000 --- a/extensions/cocostudio/reader/SceneReader.js +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -/** - * ccs.sceneReader is the reader for Cocos Studio scene editor. - * @class - * @name ccs.sceneReader - */ -ccs.sceneReader = /** @lends ccs.sceneReader# */{ - _baseBath:"", - _listener:null, - _selector:null, - _node: null, - - /** - * Creates a node with json file that exported by CocoStudio scene editor - * @param pszFileName - * @returns {cc.Node} - */ - createNodeWithSceneFile: function (pszFileName) { - this._node = null; - do{ - this._baseBath = cc.path.dirname(pszFileName); - var jsonDict = cc.loader.getRes(pszFileName); - if (!jsonDict) - throw "Please load the resource first : " + pszFileName; - this._node = this.createObject(jsonDict, null); - ccs.triggerManager.parse(jsonDict["Triggers"]||[]); - }while(0); - return this._node; - }, - - /** - * create UI object from data - * @param {Object} inputFiles - * @param {cc.Node} parenet - * @returns {cc.Node} - */ - createObject: function (inputFiles, parenet) { - var className = inputFiles["classname"]; - if (className == "CCNode") { - var gb = null; - if (!parenet) { - gb = new cc.Node(); - } - else { - gb = new cc.Node(); - parenet.addChild(gb); - } - - this.setPropertyFromJsonDict(gb, inputFiles); - - var components = inputFiles["components"]; - for (var i = 0; i < components.length; i++) { - var subDict = components[i]; - if (!subDict) { - break; - } - className = subDict["classname"]; - var comName = subDict["name"]; - - var fileData = subDict["fileData"]; - var path = "", plistFile = ""; - var resType = 0; - if (fileData != null) { - if(fileData["resourceType"] !== undefined){ - resType = fileData["resourceType"] - }else{ - resType =-1; - } - - path = cc.path.join(this._baseBath, fileData["path"]); - plistFile = fileData["plistFile"]; - } - - var pathExtname = cc.path.extname(path); - - if (className == "CCSprite") { - var sprite = null; - - if (resType == 0) { - if (pathExtname != ".png") continue; - sprite = new cc.Sprite(path); - } - else if (resType == 1) { - if (pathExtname != ".plist") continue; - - plistFile = cc.path.join(this._baseBath, plistFile); - var pngFile = cc.path.changeExtname(plistFile, ".png"); - cc.spriteFrameCache.addSpriteFrames(plistFile, pngFile); - sprite = new cc.Sprite("#" + fileData["path"]); - } - else { - continue; - } - - var render = new ccs.ComRender(sprite, "CCSprite"); - if (comName != null) { - render.setName(comName); - } - - gb.addComponent(render); - this._callSelector(sprite, subDict); - } - else if (className == "CCTMXTiledMap") { - var tmx = null; - if (resType == 0) { - if (pathExtname != ".tmx") continue; - tmx = new cc.TMXTiledMap(path); - } - else { - continue; - } - - var render = new ccs.ComRender(tmx, "CCTMXTiledMap"); - if (comName != null) { - render.setName(comName); - } - gb.addComponent(render); - this._callSelector(tmx, subDict); - } - else if (className == "CCParticleSystemQuad") { - if (pathExtname != ".plist") continue; - - var particle = null; - if (resType == 0) { - particle = new cc.ParticleSystem(path); - } - else { - cc.log("unknown resourcetype on CCParticleSystemQuad!"); - continue; - } - - particle.setPosition(0, 0); - var render = new ccs.ComRender(particle, "CCParticleSystemQuad"); - if (comName != null) { - render.setName(comName); - } - gb.addComponent(render); - this._callSelector(particle, subDict); - } - else if (className == "CCArmature") { - if (resType != 0) { - continue; - } - var jsonDict = cc.loader.getRes(path); - if (!jsonDict) cc.log("Please load the resource [%s] first!", path); - var armature_data = jsonDict["armature_data"]; - var subData = armature_data[0]; - var name = subData["name"]; - - ccs.armatureDataManager.addArmatureFileInfo(path); - - var armature = new ccs.Armature(name); - - var render = new ccs.ComRender(armature, "CCArmature"); - if (comName != null) { - render.setName(comName); - } - gb.addComponent(render); - - var actionName = subDict["selectedactionname"]; - if (actionName && armature.getAnimation()) { - armature.getAnimation().play(actionName); - } - jsonDict = null; - subData = null; - this._callSelector(armature, subDict); - } - else if (className == "CCComAudio") { - var audio = null; - if (resType == 0) { - audio = new ccs.ComAudio(); - } - else { - continue; - } - audio.preloadEffect(path); - if (comName) { - audio.setName(comName); - } - gb.addComponent(audio); - this._callSelector(audio, subDict); - } - else if (className == "CCComAttribute") { - var attribute = null; - if (resType == 0) { - attribute = new ccs.ComAttribute(); - if (path != "") attribute.parse(path); - } - else { - cc.log("unknown resourcetype on CCComAttribute!"); - continue; - } - if (comName) { - attribute.setName(comName); - } - gb.addComponent(attribute); - this._callSelector(attribute, subDict); - } - else if (className == "CCBackgroundAudio") { - if(!pathExtname) continue; - if(resType!=0) continue; - - var audio = new ccs.ComAudio(); - audio.preloadBackgroundMusic(path); - audio.setFile(path); - var bLoop = Boolean(subDict["loop"] || 0); - audio.setLoop(bLoop); - if (comName) { - audio.setName(comName); - } - gb.addComponent(audio); - audio.playBackgroundMusic(path, bLoop); - this._callSelector(audio, subDict); - } - else if (className == "GUIComponent") { - var widget = ccs.uiReader.widgetFromJsonFile(path); - var render = new ccs.ComRender(widget, "GUIComponent"); - if (comName != null) { - render.setName(comName); - } - gb.addComponent(render); - this._callSelector(audio, subDict); - } - subDict = null; - } - var gameobjects = inputFiles["gameobjects"]; - for (var i = 0; i < gameobjects.length; i++) { - var subDict = gameobjects[i]; - if (!subDict) - break; - this.createObject(subDict, gb); - subDict = null; - } - - var canvasSizeDict = inputFiles["CanvasSize"]; - if (canvasSizeDict) - { - var width = canvasSizeDict["_width"]; - var height = canvasSizeDict["_height"]; - gb.setContentSize(cc.size(width, height)); - } - - return gb; - } - - return null; - }, - - _nodeByTag: function (parent, tag) { - if (parent == null) - return null; - var retNode = null; - var children = parent.getChildren(); - for (var i = 0; i < children.length; i++) { - var child = children[i]; - if (child && child.getTag() == tag) { - retNode = child; - break; - } else { - retNode = this._nodeByTag(child, tag); - if (retNode) - break; - } - } - return retNode; - }, - - /** - * Get a node by tag. - * @param {Number} tag - * @returns {cc.Node|null} - */ - getNodeByTag: function (tag) { - if (this._node == null) - return null; - if (this._node.getTag() == tag) - return this._node; - return this._nodeByTag(this._node, tag); - }, - - /** - * Sets properties from json dictionary. - * @param {cc.Node} node - * @param {Object} dict - */ - setPropertyFromJsonDict: function (node, dict) { - var x = (cc.isUndefined(dict["x"]))?0:dict["x"]; - var y = (cc.isUndefined(dict["y"]))?0:dict["y"]; - node.setPosition(x, y); - - var bVisible = Boolean((cc.isUndefined(dict["visible"]))?1:dict["visible"]); - node.setVisible(bVisible); - - var nTag = (cc.isUndefined(dict["objecttag"]))?-1:dict["objecttag"]; - node.setTag(nTag); - - var nZorder = (cc.isUndefined(dict["zorder"]))?0:dict["zorder"]; - node.setLocalZOrder(nZorder); - - var fScaleX = (cc.isUndefined(dict["scalex"]))?1:dict["scalex"]; - var fScaleY = (cc.isUndefined(dict["scaley"]))?1:dict["scaley"]; - node.setScaleX(fScaleX); - node.setScaleY(fScaleY); - - var fRotationZ = (cc.isUndefined(dict["rotation"]))?0:dict["rotation"]; - node.setRotation(fRotationZ); - - var sName = dict["name"] || ""; - node.setName(sName); - }, - - /** - * Sets the listener to reader. - * @param {function} selector - * @param {Object} listener the target object. - */ - setTarget : function(selector,listener){ - this._listener = listener; - this._selector = selector; - }, - - _callSelector:function(obj,subDict){ - if(this._selector) - this._selector.call(this._listener,obj,subDict); - }, - - /** - * Returns the version of ccs.SceneReader. - * @returns {string} - */ - version: function () { - return "1.2.0.0"; - }, - - /** - * Clear all triggers and stops all sounds. - */ - clear: function () { - ccs.triggerManager.removeAll(); - cc.audioEngine.end(); - } -}; \ No newline at end of file diff --git a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js b/extensions/cocostudio/reader/timeline/ActionTimelineCache.js deleted file mode 100644 index 76b5fa0ee0..0000000000 --- a/extensions/cocostudio/reader/timeline/ActionTimelineCache.js +++ /dev/null @@ -1,909 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -ccui.actionTimelineCacheStatic = { - FrameType_VisibleFrame : "VisibleFrame", - FrameType_PositionFrame : "PositionFrame", - FrameType_ScaleFrame : "ScaleFrame", - FrameType_RotationFrame : "RotationFrame", - FrameType_SkewFrame : "SkewFrame", - FrameType_RotationSkewFrame : "RotationSkewFrame", - FrameType_AnchorFrame : "AnchorPointFrame", - FrameType_InnerActionFrame : "InnerActionFrame", - FrameType_ColorFrame : "ColorFrame", - FrameType_TextureFrame : "TextureFrame", - FrameType_EventFrame : "EventFrame", - FrameType_ZOrderFrame : "ZOrderFrame", - - ACTION : "action", - DURATION : "duration", - TIMELINES : "timelines", - FRAME_TYPE : "frameType", - FRAMES : "frames", - FRAME_INDEX : "frameIndex", - TWEEN : "tween", - TIME_SPEED : "speed", - ACTION_TAG : "actionTag", - INNER_ACTION : "innerActionType", - START_FRAME : "startFrame", - - X : "x", - Y : "y", - ROTATION : "rotation", - ALPHA : "alpha", - RED : "red", - GREEN : "green", - BLUE : "blue", - Value : "value" -}; - -/** - * action timeline cache - * @name ccs.ActionTimelineCache - * @namespace - */ -ccs.actionTimelineCache = { - - _FrameCreateFunc: null, - _Pair: null, - _funcs: null, - _animationActions: null, - - /** - * The initialization part object - */ - init: function(){ - - this._animationActions = {}; - this._funcs = {}; - this._funcs["VisibleFrame"] = this._loadVisibleFrame; - this._funcs["PositionFrame"] = this._loadPositionFrame; - this._funcs["ScaleFrame"] = this._loadScaleFrame; - this._funcs["RotationFrame"] = this._loadRotationFrame; - this._funcs["SkewFrame"] = this._loadSkewFrame; - this._funcs["RotationSkewFrame"] = this._loadRotationSkewFrame; - this._funcs["AnchorFrame"] = this._loadAnchorPointFrame; - this._funcs["InnerActionFrame"] = this._loadInnerActionFrame; - this._funcs["ColorFrame"] = this._loadColorFrame; - this._funcs["TextureFrame"] = this._loadTextureFrame; - this._funcs["EventFrame"] = this._loadEventFrame; - this._funcs["ZOrderFrame"] = this._loadZOrderFrame; - }, - - /** - * remove Action - * @param {string} fileName - */ - removeAction: function(fileName){ - if (this._animationActions[fileName]) { - delete this._animationActions[fileName]; - } - }, - - /** - * Create new action - * @param {string} filename - * @returns {*} - */ - createAction: function(filename){ - - var path = filename; - var pos = path.lastIndexOf('.'); - var suffix = path.substr(pos + 1, path.length); - //cc.log("suffix = %s", suffix); - - var cache = ccs.actionTimelineCache; - if (suffix == "csb"){ - throw "Does not support protobuf"; - }else if (suffix == "json" || suffix == "ExportJson"){ - return cache.createActionFromJson(filename); - }else if(suffix == "xml") { - cc.log("Does not support"); - } - return null; - }, - - /** - * Create new action - * @param {string} fileName - * @returns {*} - */ - createActionFromJson: function(fileName){ - - var action = this._animationActions[fileName]; - if (action == null) { - action = this.loadAnimationActionWithFile(fileName); - } - return action.clone(); - }, - - /** - * load Animation Action With File - * @param {string} fileName - * @returns {*} - */ - loadAnimationActionWithFile: function(fileName){ - // Read content from file - //TODO Whether you need a complete path splicing? - var contentStr = cc.loader.getRes(fileName); - return this.loadAnimationActionWithContent(fileName, contentStr); - - }, - - /** - * Load animation action with content. - * @param {string} fileName - * @param {Object} content - * @returns {*} - */ - loadAnimationActionWithContent: function(fileName, content){ - // if already exists an action with filename, then return this action - var action = this._animationActions[fileName]; - if(action) - return action; - - var json = content[ccui.actionTimelineCacheStatic.ACTION]; - - action = new ccs.ActionTimeline(); - - action.setDuration(json[ccui.actionTimelineCacheStatic.DURATION]); - action.setTimeSpeed(json[ccui.actionTimelineCacheStatic.TIME_SPEED] || 1); - - var timelineLength = json[ccui.actionTimelineCacheStatic.TIMELINES].length; - for (var i = 0; i 0 || dh > 0){ - //textField.setSize(cc.size(dw, dh)); - } - var maxLengthEnable = options["maxLengthEnable"]; - textField.setMaxLengthEnabled(maxLengthEnable); - - if(maxLengthEnable){ - var maxLength = options["maxLength"]; - textField.setMaxLength(maxLength); - } - var passwordEnable = options["passwordEnable"]; - textField.setPasswordEnabled(passwordEnable); - if(passwordEnable) - textField.setPasswordStyleText(options["passwordStyleText"]); - - var aw = options["areaWidth"]; - var ah = options["areaHeight"]; - if(aw && ah){ - var size = cc.size(aw, ah); - textField.setTextAreaSize(size); - } - var ha = options["hAlignment"]; - if(ha) - textField.setTextHorizontalAlignment(ha); - var va = options["vAlignment"]; - if(va) - textField.setTextVerticalAlignment(va); - - ccs.widgetReader.setColorPropsFromJsonDictionary.call(this, widget, options); - } -}; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReader.js b/extensions/cocostudio/reader/widgetreader/WidgetReader.js deleted file mode 100644 index dfe3eae17f..0000000000 --- a/extensions/cocostudio/reader/widgetreader/WidgetReader.js +++ /dev/null @@ -1,226 +0,0 @@ -/**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -/** - * The ccui.Widget's properties reader for GUIReader. - * @class - * @name ccs.widgetReader - **/ -ccs.widgetReader = /** @lends ccs.widgetReader# */{ - - /** - * Sets widget's properties from json dictionary - * @param {ccui.Widget} widget - * @param {object} options - */ - setPropsFromJsonDictionary: function(widget, options){ - var ignoreSizeExsit = options["ignoreSize"]; - if(ignoreSizeExsit != null) - widget.ignoreContentAdaptWithSize(ignoreSizeExsit); - - widget.setSizeType(options["sizeType"]); - widget.setPositionType(options["positionType"]); - - widget.setSizePercent(cc.p(options["sizePercentX"], options["sizePercentY"])); - widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"])); - - /* adapt screen */ - var w = 0, h = 0; - var adaptScreen = options["adaptScreen"]; - if (adaptScreen) { - var screenSize = cc.director.getWinSize(); - w = screenSize.width; - h = screenSize.height; - } else { - w = options["width"]; - h = options["height"]; - } - widget.setContentSize(w, h); - - widget.setTag(options["tag"]); - widget.setActionTag(options["actiontag"]); - widget.setTouchEnabled(options["touchAble"]); - var name = options["name"]; - var widgetName = name ? name : "default"; - widget.setName(widgetName); - - var x = options["x"]; - var y = options["y"]; - widget.setPosition(x, y); - - var sx = options["scaleX"]!=null ? options["scaleX"] : 1; - widget.setScaleX(sx); - - var sy = options["scaleY"]!=null ? options["scaleY"] : 1; - widget.setScaleY(sy); - - var rt = options["rotation"] || 0; - widget.setRotation(rt); - - var vb = options["visible"] || false; - if(vb != null) - widget.setVisible(vb); - widget.setLocalZOrder(options["ZOrder"]); - - var layout = options["layoutParameter"]; - if(layout != null){ - var layoutParameterDic = options["layoutParameter"]; - var paramType = layoutParameterDic["type"]; - var parameter = null; - - switch(paramType){ - case 0: - break; - case 1: - parameter = new ccui.LinearLayoutParameter(); - var gravity = layoutParameterDic["gravity"]; - parameter.setGravity(gravity); - break; - case 2: - parameter = new ccui.RelativeLayoutParameter(); - var rParameter = parameter; - var relativeName = layoutParameterDic["relativeName"]; - rParameter.setRelativeName(relativeName); - var relativeToName = layoutParameterDic["relativeToName"]; - rParameter.setRelativeToWidgetName(relativeToName); - var align = layoutParameterDic["align"]; - rParameter.setAlign(align); - break; - default: - break; - } - if(parameter != null){ - var mgl = layoutParameterDic["marginLeft"]||0; - var mgt = layoutParameterDic["marginTop"]||0; - var mgr = layoutParameterDic["marginRight"]||0; - var mgb = layoutParameterDic["marginDown"]||0; - parameter.setMargin(mgl, mgt, mgr, mgb); - widget.setLayoutParameter(parameter); - } - } - }, - - /** - * Sets widget's color, anchor point and flipped properties from json dictionary - * @param {ccui.Widget} widget - * @param {object} options - */ - setColorPropsFromJsonDictionary: function(widget, options){ - var op = options["opacity"]; - if(op != null) - widget.setOpacity(op); - var colorR = options["colorR"]; - var colorG = options["colorG"]; - var colorB = options["colorB"]; - widget.setColor(cc.color((colorR == null) ? 255 : colorR, (colorG == null) ? 255 : colorG, (colorB == null) ? 255 : colorB)); - - ccs.widgetReader._setAnchorPointForWidget(widget, options); - widget.setFlippedX(options["flipX"]); - widget.setFlippedY(options["flipY"]); - }, - - _setAnchorPointForWidget: function(widget, options){ - var isAnchorPointXExists = options["anchorPointX"]; - var anchorPointXInFile; - if (isAnchorPointXExists != null) - anchorPointXInFile = options["anchorPointX"]; - else - anchorPointXInFile = widget.getAnchorPoint().x; - - var isAnchorPointYExists = options["anchorPointY"]; - var anchorPointYInFile; - if (isAnchorPointYExists != null) - anchorPointYInFile = options["anchorPointY"]; - else - anchorPointYInFile = widget.getAnchorPoint().y; - - if (isAnchorPointXExists != null || isAnchorPointYExists != null) - widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); - }, - - _getResourcePath: function(dict, key, texType){ - var imageFileName = dict[key]; - var imageFileName_tp; - if (null != imageFileName) { - if (texType == 0) - imageFileName_tp = ccs.uiReader.getFilePath() + imageFileName; - else if(texType == 1) - imageFileName_tp = imageFileName; - else - cc.assert(0, "invalid TextureResType!!!"); - } - return imageFileName_tp; - }, - - setAnchorPointForWidget: function(widget, nodeTree){ - var options = nodeTree["widgetOptions"]; - - var isAnchorPointXExists = options["anchorPointX"]; - var anchorPointXInFile; - if (isAnchorPointXExists) - { - anchorPointXInFile = options["anchorPointX"]; - } - else - { - anchorPointXInFile = widget.getAnchorPoint().x; - } - - var isAnchorPointYExists = options["anchorPointY"]; - var anchorPointYInFile; - if (isAnchorPointYExists) - { - anchorPointYInFile = options["anchorPointY"]; - } - else - { - anchorPointYInFile = widget.getAnchorPoint().y; - } - - if (isAnchorPointXExists || isAnchorPointYExists) - { - widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile)); - } - }, - - getResourcePath: function(path, texType){ - var filePath = ccs.uiReader.getFilePath(); - var imageFileName = path; - var imageFileName_tp; - if (null != imageFileName && 0 != "" != imageFileName) - { - if (texType == ccui.Widget.LOCAL_TEXTURE) { - imageFileName_tp = filePath + imageFileName; - } - else if(texType == ccui.Widget.PLIST_TEXTURE){ - imageFileName_tp = imageFileName; - } - else{ - cc.assert(0, "invalid TextureResType!!!"); - } - } - return imageFileName_tp; - } -}; \ No newline at end of file diff --git a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js b/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js deleted file mode 100644 index 5c26a77bc6..0000000000 --- a/extensions/cocostudio/reader/widgetreader/WidgetReaderProtocol.js +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -ccs.WidgetReaderProtocol = ccs.Class.extend({ - setPropsFromJsonDictionary: function(widget, options){ - - } -}); \ No newline at end of file From 7d476c5f74b4d817f04f25787dc441f2162817ea Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 7 Jan 2015 14:38:54 +0800 Subject: [PATCH 1151/1564] Issue #1267: Migrating ccui.Scale9Sprite --- .../ccui/base-classes/UIScale9Sprite.js | 427 ++++++++++++++++-- 1 file changed, 390 insertions(+), 37 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 027bdd9f83..c128b670c5 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -102,6 +102,46 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _flippedX: false, _flippedY: false, + /** + * Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @function + * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame + * @param {cc.Rect} rect + * @param {cc.Rect} capInsets + * @returns {Scale9Sprite} + */ + ctor: function (file, rect, capInsets) { + cc.Node.prototype.ctor.call(this); + this._spriteRect = cc.rect(0, 0, 0, 0); + this._capInsetsInternal = cc.rect(0, 0, 0, 0); + + this._originalSize = cc.size(0, 0); + this._preferredSize = cc.size(0, 0); + this._capInsets = cc.rect(0, 0, 0, 0); + + this._topLeftSize = new cc.Size(0,0); + this._centerSize = new cc.Size(0,0); + this._bottomRightSize = new cc.Size(0,0); + this._centerOffset = new cc.Point(0,0); + + this._offset = new cc.Point(0,0); + this._protectedChildren = []; + + if(file != undefined){ + if(file instanceof cc.SpriteFrame) + this.initWithSpriteFrame(file, rect); + else{ + var frame = cc.spriteFrameCache.getSpriteFrame(file); + if(frame != null) + this.initWithSpriteFrame(frame, rect); + else + this.initWithFile(file, rect, capInsets); + } + }else{ + this.init(); + } + }, + /** * return texture is loaded * @returns {boolean} @@ -211,38 +251,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ locCenter.setPosition(leftWidth, bottomHeight); }, - /** - * Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. - * @function - * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame - * @param {cc.Rect} rect - * @param {cc.Rect} capInsets - * @returns {Scale9Sprite} - */ - ctor: function (file, rect, capInsets) { - cc.Node.prototype.ctor.call(this); - this._spriteRect = cc.rect(0, 0, 0, 0); - this._capInsetsInternal = cc.rect(0, 0, 0, 0); - - this._originalSize = cc.size(0, 0); - this._preferredSize = cc.size(0, 0); - this._capInsets = cc.rect(0, 0, 0, 0); - - if(file != undefined){ - if(file instanceof cc.SpriteFrame) - this.initWithSpriteFrame(file, rect); - else{ - var frame = cc.spriteFrameCache.getSpriteFrame(file); - if(frame != null) - this.initWithSpriteFrame(frame, rect); - else - this.initWithFile(file, rect, capInsets); - } - }else{ - this.init(); - } - }, - getSprite: function () { return this._scale9Image; }, @@ -418,7 +426,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * @returns {boolean} */ init: function () { - return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); + return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); //TODO }, /** @@ -429,7 +437,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * @param {cc.Rect} [capInsets] * @returns {boolean} */ - initWithBatchNode: function (batchNode, rect, rotated, capInsets) { + initWithBatchNode: function (batchNode, rect, rotated, capInsets) { //TODO if (capInsets === undefined) { capInsets = rotated; rotated = false; @@ -642,7 +650,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ } // Set the given rect's size as original size - this._spriteRect = rect; + //this._spriteRect = rect; var locSpriteRect = this._spriteRect; locSpriteRect.x = rect.x; locSpriteRect.y = rect.y; @@ -931,9 +939,98 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, //todo: v3.3 - updateWithSprite: function(sprite, rect, rotated, offset, orginalSize, capInsets){ + updateWithSprite: function(sprite, rect, rotated, offset, originalSize, capInsets){ //virtual bool updateWithSprite(Sprite* sprite, const Rect& rect, bool rotated, const Rect& capInsets); //virtual bool updateWithSprite(Sprite* sprite, const Rect& rect, bool rotated, const Vec2 &offset, const Size &originalSize, const Rect& capInsets); + if(originalSize === undefined){ + capInsets = offset; + offset = new cc.Point(0,0); + originalSize = new cc.Size(rect.width, rect.height); + } + + var opacity = this.getOpacity(); + var color = this.getColor(); + + // Release old sprites + this._cleanupSlicedSprites(); + this._protectedChildren.length = 0; + + if(this._scale9Image != sprite) + this._scale9Image = sprite; + if (!this._scale9Image) + return false; + +/* var tmpTexture = batchNode.getTexture(); + var locLoaded = tmpTexture.isLoaded(); + this._textureLoaded = locLoaded; + if(!locLoaded){ + tmpTexture.addEventListener("load", function(sender){ + this._positionsAreDirty = true; + this.dispatchEvent("load"); + },this); + return true; + }*/ + + var locScale9Image = this._scale9Image; + var spriteFrame = locScale9Image.getSpriteFrame(); + if (!spriteFrame) + return false; + + var locCapInsets = this._capInsets; + if(capInsets) { + locCapInsets.x = capInsets.x; + locCapInsets.y = capInsets.y; + locCapInsets.width = capInsets.width; + locCapInsets.height = capInsets.height; + } + this._spriteFrameRotated = rotated; + + // If there is no given rect + if (cc._rectEqualToZero(rect)) { + // Get the texture size as original + var textureSize = locScale9Image.getTexture().getContentSize(); + rect = cc.rect(0, 0, textureSize.width, textureSize.height); + } + if(originalSize.width === 0 && originalSize.height === 0){ + originalSize.width = rect.width; + originalSize.height = rect.height; + } + + // Set the given rect's size as original size + var locSpriteRect = this._spriteRect; + locSpriteRect.x = rect.x; + locSpriteRect.y = rect.y; + locSpriteRect.width = rect.width; + locSpriteRect.height = rect.height; + + this._offset.x = offset.x; + this._offset.y = offset.y; + + this._originalSize.width = originalSize.width; + this._originalSize.height = originalSize.height; + + this._preferredSize.width = originalSize.width; + this._preferredSize.height = originalSize.height; + + var locCapInsetsInternal = this._capInsetsInternal; + if(capInsets){ + locCapInsetsInternal.x = capInsets.x; + locCapInsetsInternal.y = capInsets.y; + locCapInsetsInternal.width = capInsets.width; + locCapInsetsInternal.height = capInsets.height; + } + + if (this._scale9Enabled) + this._createSlicedSprites(); + this.setContentSize(originalSize); + + if (this._spritesGenerated){ + // Restore color and opacity + this.setOpacity(opacity); + this.setColor(color); + } + this._spritesGenerated = true; + return true; }, //virtual void setAnchorPoint(const Vec2& anchorPoint) override; @@ -1006,7 +1103,263 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ getScale: function(){}, - _createSlicedSprites: function(){}, + _intersectRect:function(first, second){ + var ret = cc.rect(Math.max(first.x,second.x), Math.max(first.y,second.y), 0,0); + var rightRealPoint = Math.min(first.x + first.width, second.x + second.width); + var bottomRealPoint = Math.min(first.y + first.height, second.y + second.height); + ret.width = Math.max(rightRealPoint - ret.x, 0.0); + ret.height = Math.max(bottomRealPoint - ret.y, 0.0); + return ret; + }, + + _createSlicedSprites: function(){ + var w = this._originalSize.width; + var h = this._originalSize.height; + + var offsetPosition = new cc.Point( + Math.ceil(this._offset.x + (this._originalSize.width - this._spriteRect.size.width) / 2), + Math.ceil(this._offset.y + (this._originalSize.height - this._spriteRect.size.height) / 2)); + + var locCapInsetsInternal = this._capInsetsInternal; + // If there is no specified center region + if ( cc._rectEqualToZero(locCapInsetsInternal)){ + // cc.log("... cap insets not specified : using default cap insets ..."); + locCapInsetsInternal.x = w / 3; + locCapInsetsInternal.y = h / 3; + locCapInsetsInternal.width = w / 3; + locCapInsetsInternal.height = h / 3; + } + + var originalRect; + if(this._spriteFrameRotated) + originalRect = cc.rect(this._spriteRect.x - offsetPosition.y, this._spriteRect.y - offsetPosition.x, this._originalSize.width, this._originalSize.height); + else + originalRect = cc.rect(this._spriteRect.x - offsetPosition.x, this._spriteRect.y - offsetPosition.y, this._originalSize.width, this._originalSize.height); + + var left_w = locCapInsetsInternal.x; + var center_w = locCapInsetsInternal.width; + var right_w = locCapInsetsInternal.width - (left_w + center_w); + + var top_h = locCapInsetsInternal.y; + var center_h = locCapInsetsInternal.height; + var bottom_h = originalRect.height - (top_h + center_h); + + // calculate rects + // ... top row + var x = 0.0; + var y = 0.0; + + var pixelRect = cc.rect(offsetPosition.x, offsetPosition.y, this._spriteRect.width, this._spriteRect.height); + + // top left + var lefttopboundsorig = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, top_h + 0.5 | 0); + var lefttopbounds = lefttopboundsorig; + + // top center + x += left_w; + var centertopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, top_h + 0.5 | 0); + + // top right + x += center_w; + var righttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, top_h + 0.5 | 0); + + // ... center row + x = 0.0; + y = 0.0; + y += top_h; + + // center left + var leftcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, center_h + 0.5 | 0); + + // center center + x += left_w; + var centerboundsorig = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, center_h + 0.5 | 0); + var centerbounds = centerboundsorig; + + // center right + x += center_w; + var rightcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, center_h + 0.5 | 0); + + // ... bottom row + x = 0.0; + y = 0.0; + y += top_h; + y += center_h; + + // bottom left + var leftbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, bottom_h + 0.5 | 0); + + // bottom center + x += left_w; + var centerbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, bottom_h + 0.5 | 0); + + // bottom right + x += center_w; + var rightbottomboundsorig = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, bottom_h + 0.5 | 0); + var rightbottombounds = rightbottomboundsorig; + + if((locCapInsetsInternal.x + locCapInsetsInternal.width) <= this._originalSize.width + || (locCapInsetsInternal.y + locCapInsetsInternal.height) <= this._originalSize.height) { + //in general case it is error but for legacy support we will check it + lefttopbounds = this._intersectRect(lefttopbounds, pixelRect); + centertopbounds = this._intersectRect(centertopbounds, pixelRect); + righttopbounds = this._intersectRect(righttopbounds, pixelRect); + leftcenterbounds = this._intersectRect(leftcenterbounds, pixelRect); + centerbounds = this._intersectRect(centerbounds, pixelRect); + rightcenterbounds = this._intersectRect(rightcenterbounds, pixelRect); + leftbottombounds = this._intersectRect(leftbottombounds, pixelRect); + centerbottombounds = this._intersectRect(centerbottombounds, pixelRect); + rightbottombounds = this._intersectRect(rightbottombounds, pixelRect); + } else + cc.log("Scale9Sprite capInsetsInternal > originalSize"); //it is error but for legacy turn off clip system + + var rotatedlefttopboundsorig = lefttopboundsorig; + var rotatedcenterboundsorig = centerboundsorig; + var rotatedrightbottomboundsorig = rightbottomboundsorig; + + var rotatedcenterbounds = centerbounds; + var rotatedrightbottombounds = rightbottombounds; + var rotatedleftbottombounds = leftbottombounds; + var rotatedrighttopbounds = righttopbounds; + var rotatedlefttopbounds = lefttopbounds; + var rotatedrightcenterbounds = rightcenterbounds; + var rotatedleftcenterbounds = leftcenterbounds; + var rotatedcenterbottombounds = centerbottombounds; + var rotatedcentertopbounds = centertopbounds; + + var t = cc.affineTransformMakeIdentity(); + if (!this._spriteFrameRotated) { + //TODO + t = cc.affineTransformTranslate(t, originalRect.x, originalRect.y); + + rotatedlefttopboundsorig = RectApplyAffineTransform(rotatedlefttopboundsorig, t); + rotatedcenterboundsorig = RectApplyAffineTransform(rotatedcenterboundsorig, t); + rotatedrightbottomboundsorig = RectApplyAffineTransform(rotatedrightbottomboundsorig, t); + + rotatedcenterbounds = RectApplyAffineTransform(rotatedcenterbounds, t); + rotatedrightbottombounds = RectApplyAffineTransform(rotatedrightbottombounds, t); + rotatedleftbottombounds = RectApplyAffineTransform(rotatedleftbottombounds, t); + rotatedrighttopbounds = RectApplyAffineTransform(rotatedrighttopbounds, t); + rotatedlefttopbounds = RectApplyAffineTransform(rotatedlefttopbounds, t); + rotatedrightcenterbounds = RectApplyAffineTransform(rotatedrightcenterbounds, t); + rotatedleftcenterbounds = RectApplyAffineTransform(rotatedleftcenterbounds, t); + rotatedcenterbottombounds = RectApplyAffineTransform(rotatedcenterbottombounds, t); + rotatedcentertopbounds = RectApplyAffineTransform(rotatedcentertopbounds, t); + } else { + // set up transformation of coordinates + // to handle the case where the sprite is stored rotated + // in the spritesheet + // log("rotated"); + t = cc.affineTransformTranslate(t, originalRect.height+originalRect.x, originalRect.y); + t = cc.affineTransformRotate(t, 1.57079633); + + lefttopboundsorig = RectApplyAffineTransform(lefttopboundsorig, t); + centerboundsorig = RectApplyAffineTransform(centerboundsorig, t); + rightbottomboundsorig = RectApplyAffineTransform(rightbottomboundsorig, t); + + centerbounds = RectApplyAffineTransform(centerbounds, t); + rightbottombounds = RectApplyAffineTransform(rightbottombounds, t); + leftbottombounds = RectApplyAffineTransform(leftbottombounds, t); + righttopbounds = RectApplyAffineTransform(righttopbounds, t); + lefttopbounds = RectApplyAffineTransform(lefttopbounds, t); + rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t); + leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t); + centerbottombounds = RectApplyAffineTransform(centerbottombounds, t); + centertopbounds = RectApplyAffineTransform(centertopbounds, t); + + rotatedlefttopboundsorig.origin = lefttopboundsorig.origin; + rotatedcenterboundsorig.origin = centerboundsorig.origin; + rotatedrightbottomboundsorig.origin = rightbottomboundsorig.origin; + + rotatedcenterbounds.origin = centerbounds.origin; + rotatedrightbottombounds.origin = rightbottombounds.origin; + rotatedleftbottombounds.origin = leftbottombounds.origin; + rotatedrighttopbounds.origin = righttopbounds.origin; + rotatedlefttopbounds.origin = lefttopbounds.origin; + rotatedrightcenterbounds.origin = rightcenterbounds.origin; + rotatedleftcenterbounds.origin = leftcenterbounds.origin; + rotatedcenterbottombounds.origin = centerbottombounds.origin; + rotatedcentertopbounds.origin = centertopbounds.origin; + } + + this._topLeftSize.width = rotatedlefttopboundsorig.width; + this._topLeftSize.height = rotatedlefttopboundsorig.height; + this._centerSize.width = rotatedcenterboundsorig.width; + this._centerSize.height = rotatedcenterboundsorig.height; + this._bottomRightSize.width = rotatedrightbottomboundsorig.width; + this._bottomRightSize.height = rotatedrightbottomboundsorig.height; + + if(this._spriteFrameRotated){ + this._centerOffset.x = -(rotatedcenterboundsorig.y + rotatedcenterboundsorig.width/2)- (rotatedcenterbounds.y + rotatedcenterbounds.width/2); + this._centerOffset.y = (rotatedcenterbounds.x + rotatedcenterbounds.height/2) - (rotatedcenterboundsorig.x + rotatedcenterboundsorig.height/2); + } else { + this._centerOffset.x = (rotatedcenterbounds.x + rotatedcenterbounds.width/2) - (rotatedcenterboundsorig.x + rotatedcenterboundsorig.width/2); + this._centerOffset.y = (rotatedcenterboundsorig.y + rotatedcenterboundsorig.height/2)- (rotatedcenterbounds.y + rotatedcenterbounds.height/2); + } + + // Centre + if(rotatedcenterbounds.width > 0 && rotatedcenterbounds.height > 0 ) { + this._centre = new cc.Sprite(); + this._centre.initWithTexture(this._scale9Image.getTexture(), rotatedcenterbounds, this._spriteFrameRotated); + this.addProtectedChild(this._centre); + } + + // Top + if(rotatedcentertopbounds.width > 0 && rotatedcentertopbounds.height > 0 ) { + this._top = new cc.Sprite(); + this._top.initWithTexture(this._scale9Image.getTexture(), rotatedcentertopbounds, this._spriteFrameRotated); + this.addProtectedChild(this._top); + } + + // Bottom + if(rotatedcenterbottombounds.width > 0 && rotatedcenterbottombounds.height > 0 ) { + this._bottom = new cc.Sprite(); + this._bottom.initWithTexture(this._scale9Image.getTexture(), rotatedcenterbottombounds, this._spriteFrameRotated); + this.addProtectedChild(this._bottom); + } + + // Left + if(rotatedleftcenterbounds.width > 0 && rotatedleftcenterbounds.height > 0 ) { + this._left = new cc.Sprite(); + this._left.initWithTexture(this._scale9Image.getTexture(), rotatedleftcenterbounds, this._spriteFrameRotated); + this.addProtectedChild(this._left); + } + + // Right + if(rotatedrightcenterbounds.width > 0 && rotatedrightcenterbounds.height > 0 ) { + this._right = new cc.Sprite(); + this._right.initWithTexture(this._scale9Image.getTexture(), rotatedrightcenterbounds, this._spriteFrameRotated); + this.addProtectedChild(this._right); + } + + // Top left + if(rotatedlefttopbounds.width > 0 && rotatedlefttopbounds.height > 0 ) { + this._topLeft = new cc.Sprite(); + this._topLeft.initWithTexture(this._scale9Image.getTexture(), rotatedlefttopbounds, this._spriteFrameRotated); + this.addProtectedChild(this._topLeft); + } + + // Top right + if(rotatedrighttopbounds.width > 0 && rotatedrighttopbounds.height > 0 ) { + this._topRight = new cc.Sprite(); + this._topRight.initWithTexture(this._scale9Image.getTexture(), rotatedrighttopbounds, this._spriteFrameRotated); + this.addProtectedChild(this._topRight); + } + + // Bottom left + if(rotatedleftbottombounds.width > 0 && rotatedleftbottombounds.height > 0 ) { + this._bottomLeft = new cc.Sprite(); + this._bottomLeft.initWithTexture(this._scale9Image.getTexture(), rotatedleftbottombounds, this._spriteFrameRotated); + this.addProtectedChild(this._bottomLeft); + } + + // Bottom right + if(rotatedrightbottombounds.width > 0 && rotatedrightbottombounds.height > 0 ) { + this._bottomRight = new cc.Sprite(); + this._bottomRight.initWithTexture(this._scale9Image.getTexture(), rotatedrightbottombounds, this._spriteFrameRotated); + this.addProtectedChild(this._bottomRight); + } + }, _cleanupSlicedSprites: function(){ if (this._topLeft && this._topLeft.isRunning()) From 36bf522152f8c099943fa09084c6f1da088f45a9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 15:30:04 +0800 Subject: [PATCH 1152/1564] Issue #2563: add deprecated --- extensions/cocostudio/loader/parsers/compatible.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cocostudio/loader/parsers/compatible.js b/extensions/cocostudio/loader/parsers/compatible.js index 4a91c56ab0..02a6ea00fe 100644 --- a/extensions/cocostudio/loader/parsers/compatible.js +++ b/extensions/cocostudio/loader/parsers/compatible.js @@ -25,6 +25,7 @@ /* This file is for compatibility compatibility with older versions of GUIReader and SceneReader + todo: deprecated all */ (function(){ From f0c69dcade6a40bde6b993e5805697ae8b2f64f0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 7 Jan 2015 15:50:55 +0800 Subject: [PATCH 1153/1564] Fixed #1281: fixed a bug of ccs.Armature that ccs.Bone's setOpacity and setColor doesn't work. --- .../armature/CCArmatureCanvasRenderCmd.js | 16 ++++++++-- .../armature/CCArmatureWebGLRenderCmd.js | 17 +++++++++-- extensions/cocostudio/armature/CCBone.js | 30 ++++--------------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js index 0c6b363092..ce1dd9b250 100644 --- a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js @@ -70,14 +70,24 @@ ccs.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd, recursive); var locChildren = this._node._children; - window.allBones = locChildren; for (var i = 0, len = locChildren.length; i< len; i++) { var selBone = locChildren[i]; - if (selBone && selBone.getDisplayRenderNode) { var selNode = selBone.getDisplayRenderNode(); if (selNode && selNode._renderCmd){ - selNode._renderCmd.transform(null); //must be null, use transform in armature mode + var cmd = selNode._renderCmd; + cmd.transform(null); //must be null, use transform in armature mode + + //update displayNode's color and opacity, because skin didn't call visit() + var flags = cc.Node._dirtyFlags, locFlag = cmd._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if(colorDirty) + cmd._updateDisplayColor(); + if(opacityDirty) + cmd._updateDisplayOpacity(); + if(colorDirty || opacityDirty) + cmd._updateColor(); } } } diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index f405d461e4..d6991691cb 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -50,15 +50,13 @@ var selBone = locChildren[i]; if (selBone && selBone.getDisplayRenderNode) { var selNode = selBone.getDisplayRenderNode(); - if (null == selNode) continue; - selNode.setShaderProgram(this._shaderProgram); - switch (selBone.getDisplayRenderNodeType()) { case ccs.DISPLAY_TYPE_SPRITE: if (selNode instanceof ccs.Skin) { + this._updateColorAndOpacity(selNode._renderCmd); //because skin didn't call visit() selNode.updateTransform(); var func = selBone.getBlendFunc(); @@ -100,6 +98,19 @@ this._shaderProgram = shaderProgram; }; + proto._updateColorAndOpacity = function(skinRenderCmd){ + //update displayNode's color and opacity + var flags = cc.Node._dirtyFlags, locFlag = skinRenderCmd._dirtyFlag; + var colorDirty = locFlag & flags.colorDirty, + opacityDirty = locFlag & flags.opacityDirty; + if(colorDirty) + skinRenderCmd._updateDisplayColor(); + if(opacityDirty) + skinRenderCmd._updateDisplayOpacity(); + if(colorDirty || opacityDirty) + skinRenderCmd._updateColor(); + }; + proto.updateChildPosition = function(ctx, dis, selBone, alphaPremultiplied, alphaNonPremultipled){ var node = this._node; dis.updateTransform(); diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 84f5f78805..eb4bdff222 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -237,39 +237,19 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ } }, - /** - * Updates display color - * @override - * @param {cc.Color} color - */ - updateDisplayedColor: function (color) { - this._realColor = cc.color(255, 255, 255); - cc.Node.prototype.updateDisplayedColor.call(this, color); - this.updateColor(); - }, - - /** - * Updates display opacity - * @param {Number} opacity - */ - updateDisplayedOpacity: function (opacity) { - this._realOpacity = 255; - cc.Node.prototype.updateDisplayedOpacity.call(this, opacity); - this.updateColor(); - }, - /** * Updates display color */ updateColor: function () { var display = this._displayManager.getDisplayRenderNode(); if (display != null) { + var cmd = this._renderCmd; display.setColor( cc.color( - this._displayedColor.r * this._tweenData.r / 255, - this._displayedColor.g * this._tweenData.g / 255, - this._displayedColor.b * this._tweenData.b / 255)); - display.setOpacity(this._displayedOpacity * this._tweenData.a / 255); + cmd._displayedColor.r * this._tweenData.r / 255, + cmd._displayedColor.g * this._tweenData.g / 255, + cmd._displayedColor.b * this._tweenData.b / 255)); + display.setOpacity(cmd._displayedOpacity * this._tweenData.a / 255); } }, From fc7a104bb175d31ba794f6c802c71ad7d032bb4a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 7 Jan 2015 16:29:38 +0800 Subject: [PATCH 1154/1564] Fixed #1281: fixed a bug of ccs.Armature that ccs.Bone's setOpacity and setColor doesn't work --- .../cocostudio/armature/CCArmatureCanvasRenderCmd.js | 7 +++---- .../cocostudio/armature/CCArmatureWebGLRenderCmd.js | 9 +++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js index ce1dd9b250..ac491c13ba 100644 --- a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js @@ -79,15 +79,14 @@ cmd.transform(null); //must be null, use transform in armature mode //update displayNode's color and opacity, because skin didn't call visit() + var parentColor = selBone._renderCmd._displayedColor, parentOpacity = selBone._renderCmd._displayedOpacity; var flags = cc.Node._dirtyFlags, locFlag = cmd._dirtyFlag; var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; if(colorDirty) - cmd._updateDisplayColor(); + cmd._updateDisplayColor(parentColor); if(opacityDirty) - cmd._updateDisplayOpacity(); - if(colorDirty || opacityDirty) - cmd._updateColor(); + cmd._updateDisplayOpacity(parentOpacity); } } } diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index d6991691cb..42985ca1e0 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -56,7 +56,7 @@ switch (selBone.getDisplayRenderNodeType()) { case ccs.DISPLAY_TYPE_SPRITE: if (selNode instanceof ccs.Skin) { - this._updateColorAndOpacity(selNode._renderCmd); //because skin didn't call visit() + this._updateColorAndOpacity(selNode._renderCmd, selBone); //because skin didn't call visit() selNode.updateTransform(); var func = selBone.getBlendFunc(); @@ -98,15 +98,16 @@ this._shaderProgram = shaderProgram; }; - proto._updateColorAndOpacity = function(skinRenderCmd){ + proto._updateColorAndOpacity = function(skinRenderCmd, bone){ //update displayNode's color and opacity + var parentColor = bone._renderCmd._displayedColor, parentOpacity = bone._renderCmd._displayedOpacity; var flags = cc.Node._dirtyFlags, locFlag = skinRenderCmd._dirtyFlag; var colorDirty = locFlag & flags.colorDirty, opacityDirty = locFlag & flags.opacityDirty; if(colorDirty) - skinRenderCmd._updateDisplayColor(); + skinRenderCmd._updateDisplayColor(parentColor); if(opacityDirty) - skinRenderCmd._updateDisplayOpacity(); + skinRenderCmd._updateDisplayOpacity(parentOpacity); if(colorDirty || opacityDirty) skinRenderCmd._updateColor(); }; From a613e346f86b0a111aebe994a922785cd9b7aa51 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Wed, 7 Jan 2015 16:43:05 +0800 Subject: [PATCH 1155/1564] issue #1272: fix the bug , test case need to improve. --- cocos2d/labels/CCLabelBMFont.js | 232 +++++++++++++++----------------- 1 file changed, 112 insertions(+), 120 deletions(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 2d7335122e..03376e3605 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -432,143 +432,135 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ this.setString(label, true); }, - /** - * Update Label.
    - * Update this Label display string and more... - */ - updateLabel: function () { + // calc the text all with in a line + _getCharsWidth:function (startIndex, endIndex) { + if (endIndex <= 0) + { + return 0; + } + var curTextFirstSprite = this.getChildByTag(startIndex); + var curTextLastSprite = this.getChildByTag(startIndex + endIndex); + return this._getLetterPosXLeft(curTextLastSprite) - this._getLetterPosXLeft(curTextFirstSprite); + }, + + _checkWarp:function (strArr, i, maxWidth, initStringWrapNum) { var self = this; - self.string = self._initialString; + var text = strArr[i]; + var curLength = 0; + for (var strArrIndex = 0; strArrIndex < i; strArrIndex++) + { + curLength += strArr[strArrIndex].length; + } - // Step 1: Make multiline - if (self._width > 0) { - var stringLength = self._string.length; - var multiline_string = []; - var last_word = []; + curLength = curLength + i - initStringWrapNum; // add the wrap line num - var line = 1, i = 0, start_line = false, start_word = false, startOfLine = -1, startOfWord = -1, skip = 0; + var allWidth = self._getCharsWidth(curLength, strArr[i].length - 1); - var characterSprite; - for (var j = 0, lj = self._children.length; j < lj; j++) { - var justSkipped = 0; - while (!(characterSprite = self.getChildByTag(j + skip + justSkipped))) - justSkipped++; - skip += justSkipped; + if (allWidth > maxWidth && text.length > 1) { + var fuzzyLen = text.length * ( maxWidth / allWidth ) | 0; + var tmpText = text.substr(fuzzyLen); + var width = allWidth - this._getCharsWidth(curLength + fuzzyLen, tmpText.length - 1); + var sLine; + var pushNum = 0; - if (i >= stringLength) - break; + //Increased while cycle maximum ceiling. default 100 time + var checkWhile = 0; + + //Exceeded the size + while (width > maxWidth && checkWhile++ < 100) { + fuzzyLen *= maxWidth / width; + fuzzyLen = fuzzyLen | 0; + tmpText = text.substr(fuzzyLen); + width = allWidth - this._getCharsWidth(curLength + fuzzyLen, tmpText.length - 1); + } - var character = self._string[i]; - if (!start_word) { - startOfWord = self._getLetterPosXLeft(characterSprite); - start_word = true; + checkWhile = 0; + + //Find the truncation point + while (width < maxWidth && checkWhile++ < 100) { + if (tmpText) { + var exec = cc.LabelTTF._wordRex.exec(tmpText); + pushNum = exec ? exec[0].length : 1; + sLine = tmpText; } - if (!start_line) { - startOfLine = startOfWord; - start_line = true; + if (self._lineBreakWithoutSpaces) { + pushNum = 0; } + fuzzyLen = fuzzyLen + pushNum; + tmpText = text.substr(fuzzyLen); + width = allWidth - this._getCharsWidth(curLength + fuzzyLen, tmpText.length - 1); + } - // Newline. - if (character.charCodeAt(0) == 10) { - last_word.push('\n'); - multiline_string = multiline_string.concat(last_word); - last_word.length = 0; - start_word = false; - start_line = false; - startOfWord = -1; - startOfLine = -1; - //i+= justSkipped; - j--; - skip -= justSkipped; - line++; - - if (i >= stringLength) - break; - - character = self._string[i]; - if (!startOfWord) { - startOfWord = self._getLetterPosXLeft(characterSprite); - start_word = true; - } - if (!startOfLine) { - startOfLine = startOfWord; - start_line = true; + fuzzyLen -= pushNum; + if (fuzzyLen === 0) { + fuzzyLen = 1; + sLine = sLine.substr(1); + } + + var sText = text.substr(0, fuzzyLen), result; + + //symbol in the first + if (cc.LabelTTF.wrapInspection) { + if (cc.LabelTTF._symbolRex.test(sLine || tmpText)) { + result = cc.LabelTTF._lastWordRex.exec(sText); + pushNum = result ? result[0].length : 0; + if (self._lineBreakWithoutSpaces) { + pushNum = 0; } - i++; - continue; - } + fuzzyLen -= pushNum; - // Whitespace. - if (this._isspace_unicode(character)) { - last_word.push(character); - multiline_string = multiline_string.concat(last_word); - last_word.length = 0; - start_word = false; - startOfWord = -1; - i++; - continue; + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); } + } - // Out of bounds. - if (self._getLetterPosXRight(characterSprite) - startOfLine > self._width) { - if (!self._lineBreakWithoutSpaces) { - last_word.push(character); - - var found = multiline_string.lastIndexOf(" "); - if (found != -1) - this._utf8_trim_ws(multiline_string); - else - multiline_string = []; - - if (multiline_string.length > 0) - multiline_string.push('\n'); - - line++; - start_line = false; - startOfLine = -1; - i++; - } else { - this._utf8_trim_ws(last_word); - - last_word.push('\n'); - multiline_string = multiline_string.concat(last_word); - last_word.length = 0; - start_word = false; - start_line = false; - startOfWord = -1; - startOfLine = -1; - line++; - - if (i >= stringLength) - break; - - if (!startOfWord) { - startOfWord = self._getLetterPosXLeft(characterSprite); - start_word = true; - } - if (!startOfLine) { - startOfLine = startOfWord; - start_line = true; - } - j--; + //To judge whether a English words are truncated + if (cc.LabelTTF._firsrEnglish.test(sLine)) { + result = cc.LabelTTF._lastEnglish.exec(sText); + if (result && sText !== result[0]) { + pushNum = result[0].length; + if (self._lineBreakWithoutSpaces) { + pushNum = 0; } - } else { - // Character is normal. - last_word.push(character); - i++; + fuzzyLen -= pushNum; + sLine = text.substr(fuzzyLen); + sText = text.substr(0, fuzzyLen); } } + strArr[i] = sLine || tmpText; + strArr.splice(i, 0, sText); + } + }, - multiline_string = multiline_string.concat(last_word); - var len = multiline_string.length; - var str_new = ""; - - for (i = 0; i < len; ++i) - str_new += multiline_string[i]; - - str_new = str_new + String.fromCharCode(0); - //this.updateString(true); - self._setString(str_new, false) + /** + * Update Label.
    + * Update this Label display string and more... + */ + updateLabel: function () { + var self = this; + self.string = self._initialString; + // process string + // Step 1: Make multiline + if (self._width > 0) { + var stringArr = self.string.split('\n'); + var wrapString = ""; + var newWrapNum = 0; + var oldArrLength = 0; + for (i = 0; i < stringArr.length; i++) { + oldArrLength = stringArr.length; + this._checkWarp(stringArr, i, self._width, newWrapNum); + if (oldArrLength < stringArr.length) + { + newWrapNum++; + } + if (i > 0) + { + wrapString += "\n"; + } + wrapString += stringArr[i]; + } + wrapString = wrapString + String.fromCharCode(0); + self._setString(wrapString, false); } // Step 2: Make alignment From b1e52f911e0715637fea9a24be09f50745419fa2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 16:48:54 +0800 Subject: [PATCH 1156/1564] Issue #2563: modify condition to judgment the scene file --- extensions/cocostudio/loader/load.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index d1a09cbcb2..bf2bee9544 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -48,7 +48,7 @@ ccs._load = (function(){ parse = parser["timeline"]; else if(json["Content"] && json["Content"]["Content"]) parse = parser["timeline"]; - else if(json["gameobjects"] && json["Triggers"]) + else if(json["gameobjects"]) parse = parser["scene"]; }else{ parse = parser[type]; From f77c5c83b68cb0ea1707a12c725284bbc67161e6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 17:30:52 +0800 Subject: [PATCH 1157/1564] Fix atlas _shaderProgram is not init --- cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js index 1d358bc78c..d398f20eef 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js @@ -33,6 +33,10 @@ this._colorUnmodified = cc.color.WHITE; this._colorF32Array = null; this._uniformColor = null; + + //shader stuff + this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); + this._uniformColor = cc._renderContext.getUniformLocation(this._shaderProgram.getProgram(), "u_color"); }; var proto = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); @@ -52,8 +56,7 @@ proto.rendering = function (ctx) { var context = ctx || cc._renderContext, node = this._node; - if(!this._shaderProgram) - return; + this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); @@ -89,9 +92,6 @@ this._calculateMaxItems(); node.quadsToDraw = itemsToRender; - //shader stuff - this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR); - this._uniformColor = cc._renderContext.getUniformLocation(node.shaderProgram.getProgram(), "u_color"); return true; }; From 667819abcc12bfc498bea2b9ac1dc5e202cb3012 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 7 Jan 2015 17:37:08 +0800 Subject: [PATCH 1158/1564] Issue #2563: Modify access version number --- extensions/cocostudio/loader/parsers/timelineParser-1.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js index aadd9323e9..f4cbe3d9c3 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -225,7 +225,7 @@ } return tmx; }; - var uiParser = load.getParser("ccui")["1.*"]; + var uiParser = load.getParser("ccui")["*"]; parser.initWidget = function(options, resourcePath){ var type = options["classname"]; From e5e3d69d3564a3349be26ca54ae50e464343a024 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Wed, 7 Jan 2015 18:16:17 +0800 Subject: [PATCH 1159/1564] issue #1272: fix a render bug in canvas mode --- cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js index 4920171d6a..211932df4e 100644 --- a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js @@ -70,7 +70,7 @@ proto.setTexture = function (texture) { var node = this._node; var locChildren = node._children; - var locDisplayedColor = node._displayedColor; + var locDisplayedColor = this._displayedColor; for (var i = 0; i < locChildren.length; i++) { var selChild = locChildren[i]; var cm = selChild._renderCmd; From a3be2b52d9f4d0385067b1ccf805179235c028f9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 8 Jan 2015 11:51:14 +0800 Subject: [PATCH 1160/1564] Issue #2563: fix parse armature error --- extensions/cocostudio/loader/load.js | 1 + .../loader/parsers/timelineParser-2.x.js | 31 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index bf2bee9544..4d4dd8ca29 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -181,6 +181,7 @@ ccs.load = function(file){ object.action = ccs._load(file, "action"); }catch(error){ cc.log("ccs.load has encountered some problems"); + cc.log(error); } return object; }; diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index d98a52a06b..62d87ff1a1 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1058,6 +1058,15 @@ } }; + var getFileName = function(name){ + if(!name) return ""; + var arr = name.match(/([^\/]+)\.[^\/]+$/); + if(arr && arr[1]) + return arr[1]; + else + return ""; + }; + /** * Armature * @param json @@ -1067,16 +1076,32 @@ var node = new ccs.Armature(); - var isLoop = json["isLoop"]; + var isLoop = json["IsLoop"]; var isAutoPlay = json["IsAutoPlay"]; var currentAnimationName = json["CurrentAnimationName"]; loadTexture(json["FileData"], resourcePath, function(path, type){ - ccs.ArmatureDataManager.addArmatureFileInfo(path); + var plists, pngs; + var armJson = cc.loader.getRes(path); + if(!armJson) + cc.log("%s need to pre load", path); + else{ + plists = armJson["config_file_path"]; + pngs = armJson["config_png_path"]; + plists.forEach(function(plist, index){ + if(pngs[index]) + cc.spriteFrameCache.addSpriteFrame(plist, pngs[index]); + }); + } + ccs.armatureDataManager.addArmatureFileInfo(path); + node.init(getFileName(path)); + if(isAutoPlay) + node.getAnimation().play(currentAnimationName, -1, isLoop); + }); - node.init(); + return node; }; var loadedPlist = {}; From 3e5142f818b860c9a319a52191d92e78af55431f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 8 Jan 2015 14:21:24 +0800 Subject: [PATCH 1161/1564] Event callback error and Remove try/catch for ccs.load --- cocos2d/core/event-manager/CCEventManager.js | 4 +++- cocos2d/core/sprites/CCSprite.js | 2 -- extensions/cocostudio/loader/load.js | 11 ++++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 6fd0512f68..f827944f7c 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -944,7 +944,9 @@ cc.EventHelper.prototype = { addEventListener: function ( type, listener, target ) { //check 'type' status, if the status is ready, dispatch event next frame if(type === "load" && this._textureLoaded){ //only load event checked. - setTimeout(listener.call(target), 0); + setTimeout(function(){ + listener.call(target); + }, 0); return; } diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 8c7f1abf23..5237ab85bf 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -129,7 +129,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ self._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST}; self._rect = cc.rect(0, 0, 0, 0); - self._textureLoaded = true; self._softInit(fileName, rect, rotated); }, @@ -625,7 +624,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _t._blendFunc.dst = cc.BLEND_DST; _t.texture = null; - _t._textureLoaded = true; _t._flippedX = _t._flippedY = false; // default transform anchor: center diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index 4d4dd8ca29..a8dfc5c5fa 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -168,6 +168,7 @@ ccs._parser = cc.Class.extend({ * ui 1.* * node 1.* - 2.* * action 1.* - 2.* + * scene 0.* - 1.* * @param {String} file * @returns {{node: cc.Node, action: cc.Action}} */ @@ -176,13 +177,9 @@ ccs.load = function(file){ node: null, action: null }; - try{ - object.node = ccs._load(file); - object.action = ccs._load(file, "action"); - }catch(error){ - cc.log("ccs.load has encountered some problems"); - cc.log(error); - } + + object.node = ccs._load(file); + object.action = ccs._load(file, "action"); return object; }; From 912ed01752ece4a6bebda33fee595789af544bcc Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 8 Jan 2015 14:50:55 +0800 Subject: [PATCH 1162/1564] fixed #1284: It's need to add scale parm when calc word wrap --- cocos2d/labels/CCLabelBMFont.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 03376e3605..0b5169d090 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -548,7 +548,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var oldArrLength = 0; for (i = 0; i < stringArr.length; i++) { oldArrLength = stringArr.length; - this._checkWarp(stringArr, i, self._width, newWrapNum); + this._checkWarp(stringArr, i, self._width * this._scaleX, newWrapNum); if (oldArrLength < stringArr.length) { newWrapNum++; From 8cdfe00a2580de43433e7e30dccc7ae0c2494fa9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 8 Jan 2015 14:56:58 +0800 Subject: [PATCH 1163/1564] LabelTTF add _textureLoaded = true --- cocos2d/core/labelttf/CCLabelTTF.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 39874b8be6..e9847c0fe7 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -164,6 +164,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._lineWidths = []; this._renderCmd._setColorsString(); + this._textureLoaded = true; if (fontName && fontName instanceof cc.FontDefinition) { this.initWithStringAndTextDefinition(text, fontName); From 56cebd8cd123ad198097825398618ec24e922ee4 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 8 Jan 2015 15:49:59 +0800 Subject: [PATCH 1164/1564] Issue #1267: revert ccui.Scale9Sprite, because WebGL renderer doesn't support auto-batch --- cocos2d/core/support/CCPointExtension.js | 3 +- .../ccui/base-classes/UIScale9Sprite.js | 562 ++---------------- 2 files changed, 48 insertions(+), 517 deletions(-) diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/support/CCPointExtension.js index 3ec17e3d2e..db74da1001 100644 --- a/cocos2d/core/support/CCPointExtension.js +++ b/cocos2d/core/support/CCPointExtension.js @@ -204,7 +204,8 @@ cc.pDistance = function (v1, v2) { * @return {cc.Point} */ cc.pNormalize = function (v) { - return cc.pMult(v, 1.0 / cc.pLength(v)); + var n = cc.pLength(v); + return n === 0 ? cc.p(v) : cc.pMult(v, 1.0 / n); }; /** diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index c128b670c5..c49a2affcc 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -68,6 +68,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _bottomRight: null, //cache in canvas on Canvas mode + _cacheSprite: null, + _cacheCanvas: null, + _cacheContext: null, + _cacheTexture: null, _scale9Dirty: true, _opacityModifyRGB: false, @@ -87,61 +91,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _textureLoaded:false, _className:"Scale9Sprite", - //v3.3 - _scale9Enabled: false, - _topLeftSize: null, - _centerSize: null, - _bottomRightSize: null, - _centerOffset: null, - - _offset: null, - - _protectedChildren: null, - _reorderProtectedChildDirty: false, - - _flippedX: false, - _flippedY: false, - - /** - * Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. - * @function - * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame - * @param {cc.Rect} rect - * @param {cc.Rect} capInsets - * @returns {Scale9Sprite} - */ - ctor: function (file, rect, capInsets) { - cc.Node.prototype.ctor.call(this); - this._spriteRect = cc.rect(0, 0, 0, 0); - this._capInsetsInternal = cc.rect(0, 0, 0, 0); - - this._originalSize = cc.size(0, 0); - this._preferredSize = cc.size(0, 0); - this._capInsets = cc.rect(0, 0, 0, 0); - - this._topLeftSize = new cc.Size(0,0); - this._centerSize = new cc.Size(0,0); - this._bottomRightSize = new cc.Size(0,0); - this._centerOffset = new cc.Point(0,0); - - this._offset = new cc.Point(0,0); - this._protectedChildren = []; - - if(file != undefined){ - if(file instanceof cc.SpriteFrame) - this.initWithSpriteFrame(file, rect); - else{ - var frame = cc.spriteFrameCache.getSpriteFrame(file); - if(frame != null) - this.initWithSpriteFrame(frame, rect); - else - this.initWithFile(file, rect, capInsets); - } - }else{ - this.init(); - } - }, - /** * return texture is loaded * @returns {boolean} @@ -251,6 +200,38 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ locCenter.setPosition(leftWidth, bottomHeight); }, + /** + * Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. + * @function + * @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame + * @param {cc.Rect} rect + * @param {cc.Rect} capInsets + * @returns {Scale9Sprite} + */ + ctor: function (file, rect, capInsets) { + cc.Node.prototype.ctor.call(this); + this._spriteRect = cc.rect(0, 0, 0, 0); + this._capInsetsInternal = cc.rect(0, 0, 0, 0); + + this._originalSize = cc.size(0, 0); + this._preferredSize = cc.size(0, 0); + this._capInsets = cc.rect(0, 0, 0, 0); + + if(file != undefined){ + if(file instanceof cc.SpriteFrame) + this.initWithSpriteFrame(file, rect); + else{ + var frame = cc.spriteFrameCache.getSpriteFrame(file); + if(frame != null) + this.initWithSpriteFrame(frame, rect); + else + this.initWithFile(file, rect, capInsets); + } + }else{ + this.init(); + } + }, + getSprite: function () { return this._scale9Image; }, @@ -426,7 +407,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * @returns {boolean} */ init: function () { - return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); //TODO + return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0)); }, /** @@ -437,7 +418,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * @param {cc.Rect} [capInsets] * @returns {boolean} */ - initWithBatchNode: function (batchNode, rect, rotated, capInsets) { //TODO + initWithBatchNode: function (batchNode, rect, rotated, capInsets) { if (capInsets === undefined) { capInsets = rotated; rotated = false; @@ -540,8 +521,8 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ * to resize the sprite will all it's 9-slice goodness interact. * It respects the anchorPoint too. * - * @param {String} spriteFrameName The sprite frame name. - * @param {cc.Rect} capInsets The values to use for the cap insets. + * @param spriteFrameName The sprite frame name. + * @param capInsets The values to use for the cap insets. */ initWithSpriteFrameName: function (spriteFrameName, capInsets) { if(!spriteFrameName) @@ -558,12 +539,11 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, /** - *

    - * Creates and returns a new sprite object with the specified cap insets.
    - * You use this method to add cap insets to a sprite or to change the existing
    - * cap insets of a sprite. In both cases, you get back a new image and the
    + * Creates and returns a new sprite object with the specified cap insets. + * You use this method to add cap insets to a sprite or to change the existing + * cap insets of a sprite. In both cases, you get back a new image and the * original sprite remains untouched. - *

    + * * @param {cc.Rect} capInsets The values to use for the cap insets. */ resizableSpriteWithCapInsets: function (capInsets) { @@ -650,7 +630,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ } // Set the given rect's size as original size - //this._spriteRect = rect; + this._spriteRect = rect; var locSpriteRect = this._spriteRect; locSpriteRect.x = rect.x; locSpriteRect.y = rect.y; @@ -938,456 +918,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._insetBottom = 0; }, - //todo: v3.3 - updateWithSprite: function(sprite, rect, rotated, offset, originalSize, capInsets){ - //virtual bool updateWithSprite(Sprite* sprite, const Rect& rect, bool rotated, const Rect& capInsets); - //virtual bool updateWithSprite(Sprite* sprite, const Rect& rect, bool rotated, const Vec2 &offset, const Size &originalSize, const Rect& capInsets); - if(originalSize === undefined){ - capInsets = offset; - offset = new cc.Point(0,0); - originalSize = new cc.Size(rect.width, rect.height); - } - - var opacity = this.getOpacity(); - var color = this.getColor(); - - // Release old sprites - this._cleanupSlicedSprites(); - this._protectedChildren.length = 0; - - if(this._scale9Image != sprite) - this._scale9Image = sprite; - if (!this._scale9Image) - return false; - -/* var tmpTexture = batchNode.getTexture(); - var locLoaded = tmpTexture.isLoaded(); - this._textureLoaded = locLoaded; - if(!locLoaded){ - tmpTexture.addEventListener("load", function(sender){ - this._positionsAreDirty = true; - this.dispatchEvent("load"); - },this); - return true; - }*/ - - var locScale9Image = this._scale9Image; - var spriteFrame = locScale9Image.getSpriteFrame(); - if (!spriteFrame) - return false; - - var locCapInsets = this._capInsets; - if(capInsets) { - locCapInsets.x = capInsets.x; - locCapInsets.y = capInsets.y; - locCapInsets.width = capInsets.width; - locCapInsets.height = capInsets.height; - } - this._spriteFrameRotated = rotated; - - // If there is no given rect - if (cc._rectEqualToZero(rect)) { - // Get the texture size as original - var textureSize = locScale9Image.getTexture().getContentSize(); - rect = cc.rect(0, 0, textureSize.width, textureSize.height); - } - if(originalSize.width === 0 && originalSize.height === 0){ - originalSize.width = rect.width; - originalSize.height = rect.height; - } - - // Set the given rect's size as original size - var locSpriteRect = this._spriteRect; - locSpriteRect.x = rect.x; - locSpriteRect.y = rect.y; - locSpriteRect.width = rect.width; - locSpriteRect.height = rect.height; - - this._offset.x = offset.x; - this._offset.y = offset.y; - - this._originalSize.width = originalSize.width; - this._originalSize.height = originalSize.height; - - this._preferredSize.width = originalSize.width; - this._preferredSize.height = originalSize.height; - - var locCapInsetsInternal = this._capInsetsInternal; - if(capInsets){ - locCapInsetsInternal.x = capInsets.x; - locCapInsetsInternal.y = capInsets.y; - locCapInsetsInternal.width = capInsets.width; - locCapInsetsInternal.height = capInsets.height; - } - - if (this._scale9Enabled) - this._createSlicedSprites(); - this.setContentSize(originalSize); - - if (this._spritesGenerated){ - // Restore color and opacity - this.setOpacity(opacity); - this.setColor(color); - } - this._spritesGenerated = true; - return true; - }, - - //virtual void setAnchorPoint(const Vec2& anchorPoint) override; - - /** - * set the state of ccui.Scale9Sprite - * @param {Number} state - */ - setState: function(state){ - - }, - - cleanup: function(){}, - - onEnter: function(){}, - - onEnterTransitionDidFinish: function(){}, - - onExit: function(){}, - - onExitTransitionDidStart: function(){}, - - /** - * Sets whether the widget should be flipped horizontally or not. - * @param {Boolean} flippedX true if the widget should be flipped horizontally, false otherwise. - */ - setFlippedX: function(flippedX){}, - - /** - *

    - * Returns the flag which indicates whether the widget is flipped horizontally or not.
    - *
    - * It only flips the texture of the widget, and not the texture of the widget's children.
    - * Also, flipping the texture doesn't alter the anchorPoint.
    - * If you want to flip the anchorPoint too, and/or to flip the children too use:
    - * widget.setScaleX(sprite.getScaleX() * -1);
    - *

    - * @return true if the widget is flipped horizontally, false otherwise. - */ - isFlippedX: function(){}, - - /** - * Sets whether the widget should be flipped vertically or not. - * @param {Boolean} flippedY true if the widget should be flipped vertically, false otherwise. - */ - setFlippedY: function(flippedY){}, - - /** - *

    - * Return the flag which indicates whether the widget is flipped vertically or not.
    - *
    - * It only flips the texture of the widget, and not the texture of the widget's children.
    - * Also, flipping the texture doesn't alter the anchorPoint.
    - * If you want to flip the anchorPoint too, and/or to flip the children too use:
    - * widget.setScaleY(widget.getScaleY() * -1);
    - *

    - * @return true if the widget is flipped vertically, false otherwise. - */ - isFlippedY: function(){}, - - setScaleX: function(scaleX){}, - - setScaleY: function(scaleY){}, - - setScale: function(scaleX, scaleY){}, - - getScaleX: function(){}, - - getScaleY: function(){}, - - getScale: function(){}, - - _intersectRect:function(first, second){ - var ret = cc.rect(Math.max(first.x,second.x), Math.max(first.y,second.y), 0,0); - var rightRealPoint = Math.min(first.x + first.width, second.x + second.width); - var bottomRealPoint = Math.min(first.y + first.height, second.y + second.height); - ret.width = Math.max(rightRealPoint - ret.x, 0.0); - ret.height = Math.max(bottomRealPoint - ret.y, 0.0); - return ret; - }, - - _createSlicedSprites: function(){ - var w = this._originalSize.width; - var h = this._originalSize.height; - - var offsetPosition = new cc.Point( - Math.ceil(this._offset.x + (this._originalSize.width - this._spriteRect.size.width) / 2), - Math.ceil(this._offset.y + (this._originalSize.height - this._spriteRect.size.height) / 2)); - - var locCapInsetsInternal = this._capInsetsInternal; - // If there is no specified center region - if ( cc._rectEqualToZero(locCapInsetsInternal)){ - // cc.log("... cap insets not specified : using default cap insets ..."); - locCapInsetsInternal.x = w / 3; - locCapInsetsInternal.y = h / 3; - locCapInsetsInternal.width = w / 3; - locCapInsetsInternal.height = h / 3; - } - - var originalRect; - if(this._spriteFrameRotated) - originalRect = cc.rect(this._spriteRect.x - offsetPosition.y, this._spriteRect.y - offsetPosition.x, this._originalSize.width, this._originalSize.height); - else - originalRect = cc.rect(this._spriteRect.x - offsetPosition.x, this._spriteRect.y - offsetPosition.y, this._originalSize.width, this._originalSize.height); - - var left_w = locCapInsetsInternal.x; - var center_w = locCapInsetsInternal.width; - var right_w = locCapInsetsInternal.width - (left_w + center_w); - - var top_h = locCapInsetsInternal.y; - var center_h = locCapInsetsInternal.height; - var bottom_h = originalRect.height - (top_h + center_h); - - // calculate rects - // ... top row - var x = 0.0; - var y = 0.0; - - var pixelRect = cc.rect(offsetPosition.x, offsetPosition.y, this._spriteRect.width, this._spriteRect.height); - - // top left - var lefttopboundsorig = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, top_h + 0.5 | 0); - var lefttopbounds = lefttopboundsorig; - - // top center - x += left_w; - var centertopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, top_h + 0.5 | 0); - - // top right - x += center_w; - var righttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, top_h + 0.5 | 0); - - // ... center row - x = 0.0; - y = 0.0; - y += top_h; - - // center left - var leftcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, center_h + 0.5 | 0); - - // center center - x += left_w; - var centerboundsorig = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, center_h + 0.5 | 0); - var centerbounds = centerboundsorig; - - // center right - x += center_w; - var rightcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, center_h + 0.5 | 0); - - // ... bottom row - x = 0.0; - y = 0.0; - y += top_h; - y += center_h; - - // bottom left - var leftbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, bottom_h + 0.5 | 0); - - // bottom center - x += left_w; - var centerbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, bottom_h + 0.5 | 0); - - // bottom right - x += center_w; - var rightbottomboundsorig = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, bottom_h + 0.5 | 0); - var rightbottombounds = rightbottomboundsorig; - - if((locCapInsetsInternal.x + locCapInsetsInternal.width) <= this._originalSize.width - || (locCapInsetsInternal.y + locCapInsetsInternal.height) <= this._originalSize.height) { - //in general case it is error but for legacy support we will check it - lefttopbounds = this._intersectRect(lefttopbounds, pixelRect); - centertopbounds = this._intersectRect(centertopbounds, pixelRect); - righttopbounds = this._intersectRect(righttopbounds, pixelRect); - leftcenterbounds = this._intersectRect(leftcenterbounds, pixelRect); - centerbounds = this._intersectRect(centerbounds, pixelRect); - rightcenterbounds = this._intersectRect(rightcenterbounds, pixelRect); - leftbottombounds = this._intersectRect(leftbottombounds, pixelRect); - centerbottombounds = this._intersectRect(centerbottombounds, pixelRect); - rightbottombounds = this._intersectRect(rightbottombounds, pixelRect); - } else - cc.log("Scale9Sprite capInsetsInternal > originalSize"); //it is error but for legacy turn off clip system - - var rotatedlefttopboundsorig = lefttopboundsorig; - var rotatedcenterboundsorig = centerboundsorig; - var rotatedrightbottomboundsorig = rightbottomboundsorig; - - var rotatedcenterbounds = centerbounds; - var rotatedrightbottombounds = rightbottombounds; - var rotatedleftbottombounds = leftbottombounds; - var rotatedrighttopbounds = righttopbounds; - var rotatedlefttopbounds = lefttopbounds; - var rotatedrightcenterbounds = rightcenterbounds; - var rotatedleftcenterbounds = leftcenterbounds; - var rotatedcenterbottombounds = centerbottombounds; - var rotatedcentertopbounds = centertopbounds; - - var t = cc.affineTransformMakeIdentity(); - if (!this._spriteFrameRotated) { - //TODO - t = cc.affineTransformTranslate(t, originalRect.x, originalRect.y); - - rotatedlefttopboundsorig = RectApplyAffineTransform(rotatedlefttopboundsorig, t); - rotatedcenterboundsorig = RectApplyAffineTransform(rotatedcenterboundsorig, t); - rotatedrightbottomboundsorig = RectApplyAffineTransform(rotatedrightbottomboundsorig, t); - - rotatedcenterbounds = RectApplyAffineTransform(rotatedcenterbounds, t); - rotatedrightbottombounds = RectApplyAffineTransform(rotatedrightbottombounds, t); - rotatedleftbottombounds = RectApplyAffineTransform(rotatedleftbottombounds, t); - rotatedrighttopbounds = RectApplyAffineTransform(rotatedrighttopbounds, t); - rotatedlefttopbounds = RectApplyAffineTransform(rotatedlefttopbounds, t); - rotatedrightcenterbounds = RectApplyAffineTransform(rotatedrightcenterbounds, t); - rotatedleftcenterbounds = RectApplyAffineTransform(rotatedleftcenterbounds, t); - rotatedcenterbottombounds = RectApplyAffineTransform(rotatedcenterbottombounds, t); - rotatedcentertopbounds = RectApplyAffineTransform(rotatedcentertopbounds, t); - } else { - // set up transformation of coordinates - // to handle the case where the sprite is stored rotated - // in the spritesheet - // log("rotated"); - t = cc.affineTransformTranslate(t, originalRect.height+originalRect.x, originalRect.y); - t = cc.affineTransformRotate(t, 1.57079633); - - lefttopboundsorig = RectApplyAffineTransform(lefttopboundsorig, t); - centerboundsorig = RectApplyAffineTransform(centerboundsorig, t); - rightbottomboundsorig = RectApplyAffineTransform(rightbottomboundsorig, t); - - centerbounds = RectApplyAffineTransform(centerbounds, t); - rightbottombounds = RectApplyAffineTransform(rightbottombounds, t); - leftbottombounds = RectApplyAffineTransform(leftbottombounds, t); - righttopbounds = RectApplyAffineTransform(righttopbounds, t); - lefttopbounds = RectApplyAffineTransform(lefttopbounds, t); - rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t); - leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t); - centerbottombounds = RectApplyAffineTransform(centerbottombounds, t); - centertopbounds = RectApplyAffineTransform(centertopbounds, t); - - rotatedlefttopboundsorig.origin = lefttopboundsorig.origin; - rotatedcenterboundsorig.origin = centerboundsorig.origin; - rotatedrightbottomboundsorig.origin = rightbottomboundsorig.origin; - - rotatedcenterbounds.origin = centerbounds.origin; - rotatedrightbottombounds.origin = rightbottombounds.origin; - rotatedleftbottombounds.origin = leftbottombounds.origin; - rotatedrighttopbounds.origin = righttopbounds.origin; - rotatedlefttopbounds.origin = lefttopbounds.origin; - rotatedrightcenterbounds.origin = rightcenterbounds.origin; - rotatedleftcenterbounds.origin = leftcenterbounds.origin; - rotatedcenterbottombounds.origin = centerbottombounds.origin; - rotatedcentertopbounds.origin = centertopbounds.origin; - } - - this._topLeftSize.width = rotatedlefttopboundsorig.width; - this._topLeftSize.height = rotatedlefttopboundsorig.height; - this._centerSize.width = rotatedcenterboundsorig.width; - this._centerSize.height = rotatedcenterboundsorig.height; - this._bottomRightSize.width = rotatedrightbottomboundsorig.width; - this._bottomRightSize.height = rotatedrightbottomboundsorig.height; - - if(this._spriteFrameRotated){ - this._centerOffset.x = -(rotatedcenterboundsorig.y + rotatedcenterboundsorig.width/2)- (rotatedcenterbounds.y + rotatedcenterbounds.width/2); - this._centerOffset.y = (rotatedcenterbounds.x + rotatedcenterbounds.height/2) - (rotatedcenterboundsorig.x + rotatedcenterboundsorig.height/2); - } else { - this._centerOffset.x = (rotatedcenterbounds.x + rotatedcenterbounds.width/2) - (rotatedcenterboundsorig.x + rotatedcenterboundsorig.width/2); - this._centerOffset.y = (rotatedcenterboundsorig.y + rotatedcenterboundsorig.height/2)- (rotatedcenterbounds.y + rotatedcenterbounds.height/2); - } - - // Centre - if(rotatedcenterbounds.width > 0 && rotatedcenterbounds.height > 0 ) { - this._centre = new cc.Sprite(); - this._centre.initWithTexture(this._scale9Image.getTexture(), rotatedcenterbounds, this._spriteFrameRotated); - this.addProtectedChild(this._centre); - } - - // Top - if(rotatedcentertopbounds.width > 0 && rotatedcentertopbounds.height > 0 ) { - this._top = new cc.Sprite(); - this._top.initWithTexture(this._scale9Image.getTexture(), rotatedcentertopbounds, this._spriteFrameRotated); - this.addProtectedChild(this._top); - } - - // Bottom - if(rotatedcenterbottombounds.width > 0 && rotatedcenterbottombounds.height > 0 ) { - this._bottom = new cc.Sprite(); - this._bottom.initWithTexture(this._scale9Image.getTexture(), rotatedcenterbottombounds, this._spriteFrameRotated); - this.addProtectedChild(this._bottom); - } - - // Left - if(rotatedleftcenterbounds.width > 0 && rotatedleftcenterbounds.height > 0 ) { - this._left = new cc.Sprite(); - this._left.initWithTexture(this._scale9Image.getTexture(), rotatedleftcenterbounds, this._spriteFrameRotated); - this.addProtectedChild(this._left); - } - - // Right - if(rotatedrightcenterbounds.width > 0 && rotatedrightcenterbounds.height > 0 ) { - this._right = new cc.Sprite(); - this._right.initWithTexture(this._scale9Image.getTexture(), rotatedrightcenterbounds, this._spriteFrameRotated); - this.addProtectedChild(this._right); - } - - // Top left - if(rotatedlefttopbounds.width > 0 && rotatedlefttopbounds.height > 0 ) { - this._topLeft = new cc.Sprite(); - this._topLeft.initWithTexture(this._scale9Image.getTexture(), rotatedlefttopbounds, this._spriteFrameRotated); - this.addProtectedChild(this._topLeft); - } - - // Top right - if(rotatedrighttopbounds.width > 0 && rotatedrighttopbounds.height > 0 ) { - this._topRight = new cc.Sprite(); - this._topRight.initWithTexture(this._scale9Image.getTexture(), rotatedrighttopbounds, this._spriteFrameRotated); - this.addProtectedChild(this._topRight); - } - - // Bottom left - if(rotatedleftbottombounds.width > 0 && rotatedleftbottombounds.height > 0 ) { - this._bottomLeft = new cc.Sprite(); - this._bottomLeft.initWithTexture(this._scale9Image.getTexture(), rotatedleftbottombounds, this._spriteFrameRotated); - this.addProtectedChild(this._bottomLeft); - } - - // Bottom right - if(rotatedrightbottombounds.width > 0 && rotatedrightbottombounds.height > 0 ) { - this._bottomRight = new cc.Sprite(); - this._bottomRight.initWithTexture(this._scale9Image.getTexture(), rotatedrightbottombounds, this._spriteFrameRotated); - this.addProtectedChild(this._bottomRight); - } - }, - - _cleanupSlicedSprites: function(){ - if (this._topLeft && this._topLeft.isRunning()) - this._topLeft.onExit(); - if (this._top && this._top.isRunning()) - this._top.onExit(); - if (this._topRight && this._topRight.isRunning()) - this._topRight.onExit(); - if (this._left && this._left.isRunning()) - this._left.onExit(); - if (this._centre && this._centre.isRunning()) - this._centre.onExit(); - if (this._right && this._right.isRunning()) - this._right.onExit(); - if (this._bottomLeft && this._bottomLeft.isRunning()) - this._bottomLeft.onExit(); - if (this._bottomRight && this._bottomRight.isRunning()) - this._bottomRight.onExit(); - if (this._bottom && this._bottom.isRunning()) - this._bottom.onExit(); - }, - - _adjustScale9ImagePosition: function(){}, - - _sortAllProtectedChildren: function(){}, - - _addProtectedChild: function(){}, - _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new ccui.Scale9Sprite.CanvasRenderCmd(this); @@ -1466,4 +996,4 @@ ccui.Scale9Sprite.POSITIONS_RIGHT = 3; ccui.Scale9Sprite.POSITIONS_BOTTOM = 4; ccui.Scale9Sprite.POSITIONS_TOPRIGHT = 5; ccui.Scale9Sprite.POSITIONS_TOPLEFT = 6; -ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; +ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; \ No newline at end of file From b51e4d6eabf10fa76677cd6f7053694ba2e1e6e7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 8 Jan 2015 17:33:21 +0800 Subject: [PATCH 1165/1564] _textureLoaded errore when call setTexture --- cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js | 1 + cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 1 + cocos2d/core/textures/CCTexture2D.js | 2 +- cocos2d/core/textures/TexturesWebGL.js | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index ec0ecd09b8..45224e6adb 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -61,6 +61,7 @@ if (texture && texture.getHtmlElementObj() instanceof HTMLImageElement) { this._originalTexture = texture; } + node._textureLoaded = texture._textureLoaded; node._texture = texture; } }; diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index b590b6c74b..376d227e62 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -297,6 +297,7 @@ this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); if (!node._batchNode && node._texture != texture) { + node._textureLoaded = texture._textureLoaded; node._texture = texture; this._updateBlendFunc(); } diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 82833cab4f..074a6efc77 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -182,6 +182,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (!element) return; this._htmlElementObj = element; + this._textureLoaded = true; }, /** @@ -212,7 +213,6 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { self.initWithElement(img); } - self._textureLoaded = true; var locElement = self._htmlElementObj; self._contentSize.width = locElement.width; self._contentSize.height = locElement.height; diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 4e0f41c5d9..d26cbe5a57 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -421,6 +421,7 @@ cc._tmp.WebGLTexture2D = function () { return; this._webTextureObj = cc._renderContext.createTexture(); this._htmlElementObj = element; + this._textureLoaded = true; }, /** @@ -454,7 +455,7 @@ cc._tmp.WebGLTexture2D = function () { } if (!self._htmlElementObj.width || !self._htmlElementObj.height) return; - self._textureLoaded = true; + //upload image to buffer var gl = cc._renderContext; From 2b0e00f64061cc285c191ad8a389a69b2f8789a1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 8 Jan 2015 17:55:00 +0800 Subject: [PATCH 1166/1564] Create a sprite from the frame and not pre loaded, color cannot be modified --- cocos2d/core/sprites/CCSprite.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 5237ab85bf..2fcce96352 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -843,13 +843,15 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _t.texture = locNewTexture; _t.setTextureRect(sender.getRect(), sender.isRotated(), sender.getOriginalSize()); _t.dispatchEvent("load"); + _t.setColor(_t.color); }, _t); - } - // update texture before updating texture rect - if (pNewTexture != _t._texture) - _t.texture = pNewTexture; + }else{ + // update texture before updating texture rect + if (pNewTexture != _t._texture) + _t.texture = pNewTexture; - _t.setTextureRect(newFrame.getRect(), _t._rectRotated, newFrame.getOriginalSize()); + _t.setTextureRect(newFrame.getRect(), _t._rectRotated, newFrame.getOriginalSize()); + } this._renderCmd._updateForSetSpriteFrame(pNewTexture); }, From 71efef0ab5abbd53bc5fd0f8e208c1858ccada19 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 8 Jan 2015 18:29:54 +0800 Subject: [PATCH 1167/1564] Issue #1267: added flippedX/flippedY to ccui.Scale9Sprite --- .../core/sprites/CCSpriteCanvasRenderCmd.js | 2 +- .../ccui/base-classes/UIScale9Sprite.js | 103 ++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index ec0ecd09b8..f3b9178fef 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -278,7 +278,7 @@ proto._updateDisplayColor = function (parentColor) { cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, parentColor); - this._updateColor(); + //this._updateColor(); }; proto._spriteFrameLoadedCallback = function (spriteFrame) { diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index c49a2affcc..a3b8191a60 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -91,6 +91,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _textureLoaded:false, _className:"Scale9Sprite", + //v3.3 + _flippedX: false, + _flippedY: false, + /** * return texture is loaded * @returns {boolean} @@ -918,6 +922,105 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._insetBottom = 0; }, + //v3.3 + setState: function(state){ + // + }, + + //setScale9Enabled implement late + + /** + * Sets whether the widget should be flipped horizontally or not. + * @since v3.3 + * @param flippedX true if the widget should be flipped horizontally, false otherwise. + */ + setFlippedX: function(flippedX){ + var realScale = this.getScaleX(); + this._flippedX = flippedX; + this.setScaleX(realScale); + }, + + /** + *

    + * Returns the flag which indicates whether the widget is flipped horizontally or not.
    + *
    + * It only flips the texture of the widget, and not the texture of the widget's children.
    + * Also, flipping the texture doesn't alter the anchorPoint.
    + * If you want to flip the anchorPoint too, and/or to flip the children too use:
    + * widget->setScaleX(sprite->getScaleX() * -1);
    + *

    + * @since v3.3 + * @return {Boolean} true if the widget is flipped horizontally, false otherwise. + */ + isFlippedX: function(){ + return this._flippedX; + }, + + /** + * Sets whether the widget should be flipped vertically or not. + * @since v3.3 + * @param flippedY true if the widget should be flipped vertically, false otherwise. + */ + setFlippedY:function(flippedY){ + var realScale = this.getScaleY(); + this._flippedY = flippedY; + this.setScaleY(realScale); + }, + + /** + *

    + * Return the flag which indicates whether the widget is flipped vertically or not.
    + *
    + * It only flips the texture of the widget, and not the texture of the widget's children.
    + * Also, flipping the texture doesn't alter the anchorPoint.
    + * If you want to flip the anchorPoint too, and/or to flip the children too use:
    + * widget->setScaleY(widget->getScaleY() * -1);
    + *

    + * @since v3.3 + * @return {Boolean} true if the widget is flipped vertically, false otherwise. + */ + isFlippedY:function(){ + return this._flippedY; + }, + + setScaleX: function (scaleX) { + if (this._flippedX) + scaleX = scaleX * -1; + cc.Node.prototype.setScaleX.call(this, scaleX); + }, + + setScaleY: function (scaleY) { + if (this._flippedY) + scaleY = scaleY * -1; + cc.Node.prototype.setScaleY.call(this, scaleY); + }, + + setScale: function (scaleX, scaleY) { + if(scaleY === undefined) + scaleY = scaleX; + this.setScaleX(scaleX); + this.setScaleY(scaleY); + }, + + getScaleX: function () { + var originalScale = cc.Node.prototype.getScaleX.call(this); + if (this._flippedX) + originalScale = originalScale * -1.0; + return originalScale; + }, + + getScaleY: function () { + var originalScale = cc.Node.prototype.getScaleY.call(this); + if (this._flippedY) + originalScale = originalScale * -1.0; + return originalScale; + }, + + getScale: function () { + cc.log(this.getScaleX() == this.getScaleY(), "Scale9Sprite#scale. ScaleX != ScaleY. Don't know which one to return"); + return this.getScaleX(); + }, + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new ccui.Scale9Sprite.CanvasRenderCmd(this); From 780bb615f23a691d4a7e0263f9e2af2f0116b929 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 Jan 2015 10:46:22 +0800 Subject: [PATCH 1168/1564] Issue #2563: Fixed particle texture size error --- cocos2d/core/textures/CCTexture2D.js | 2 ++ extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 1 + 2 files changed, 3 insertions(+) diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 074a6efc77..1eee6d2f0c 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -182,6 +182,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (!element) return; this._htmlElementObj = element; + this._contentSize.width = element.width; + this._contentSize.height = element.height; this._textureLoaded = true; }, diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 62d87ff1a1..746e6da38b 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -197,6 +197,7 @@ cc.log("%s need to pre load", path); node = new cc.ParticleSystem(path); self.generalAttributes(node, json); + node.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); }); return node; }; From ea145250933c08162126667648b057cf194fb0ec Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 Jan 2015 10:50:20 +0800 Subject: [PATCH 1169/1564] Issue #2563: Fixed layoutType is undefined --- extensions/cocostudio/loader/parsers/uiParser-1.x.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js index a89b01cddc..6dfef4c8b6 100644 --- a/extensions/cocostudio/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -262,7 +262,9 @@ var ch = options["capInsetsHeight"]; widget.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); } - widget.setLayoutType(options["layoutType"]); + var layoutType = options["layoutType"]; + if(layoutType != null) + widget.setLayoutType(layoutType); }; /** * Button parser (UIButton) From 7874ec7df7f5e6ef6ccb849743fe3d83e63f3f1d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 Jan 2015 11:49:44 +0800 Subject: [PATCH 1170/1564] Fixed ActionManager currTarget.actions is null error --- cocos2d/core/CCActionManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index 06006dc795..18c2e3900d 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -339,7 +339,8 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ //this._currentTargetSalvaged = false; if (!locCurrTarget.paused) { // The 'actions' CCMutableArray may change while inside this loop. - for (locCurrTarget.actionIndex = 0; locCurrTarget.actionIndex < locCurrTarget.actions.length; + for (locCurrTarget.actionIndex = 0; + locCurrTarget.actionIndex < (locCurrTarget.actions ? locCurrTarget.actions.length : 0); locCurrTarget.actionIndex++) { locCurrTarget.currentAction = locCurrTarget.actions[locCurrTarget.actionIndex]; if (!locCurrTarget.currentAction) From b5e7b13736ed336dec107a11b1a33e67c4bf96b3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 Jan 2015 15:05:44 +0800 Subject: [PATCH 1171/1564] Fixed atlas setColor error when texture is not pre loaded --- cocos2d/labels/CCLabelAtlas.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 9864ace3a7..4e649f6881 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -146,6 +146,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ texture.addEventListener("load", function (sender) { this.initWithTexture(texture, width, height, label.length); this.string = label; + this.setColor(this._renderCmd._displayedColor); this.dispatchEvent("load"); }, this); } From 4950effafee9c3892c66637d7f42a794b5f9f38c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 9 Jan 2015 15:21:26 +0800 Subject: [PATCH 1172/1564] Fixed Sprite setTexture set _textureLoaded error --- cocos2d/core/sprites/CCSprite.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 2fcce96352..ac0733d9c7 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -936,7 +936,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ texture.addEventListener("load", function(){ var size = texture.getContentSize(); _t.setTextureRect(cc.rect(0,0, size.width, size.height)); + _t._textureLoaded = true; }, this); + }else{ + _t._textureLoaded = true; } return; } From 7931299a778e6bbd427d294a42e8b6b4577fdbd8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 9 Jan 2015 16:17:07 +0800 Subject: [PATCH 1173/1564] Issue #1267: implemented ccui.Scale9Sprite's setState --- cocos2d/core/textures/CCTexture2D.js | 38 ++++++++++++++++++ .../ccui/base-classes/UIScale9Sprite.js | 16 ++++---- .../UIScale9SpriteCanvasRenderCmd.js | 13 ++++++ .../UIScale9SpriteWebGLRenderCmd.js | 40 +++++++++++++++++-- 4 files changed, 97 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 82833cab4f..b6f919555b 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -399,9 +399,47 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { */ removeLoadedEventListener: function (target) { this.removeEventListener("load", target); + }, + + //hack for gray effect + _grayElementObj: null, + _backupElement: null, + _isGray: false, + _switchToGray: function(toGray){ + if(!this._textureLoaded || this._isGray == toGray) + return; + this._isGray = toGray; + if(this._isGray){ + this._backupElement = this._htmlElementObj; + if(!this._grayElementObj) + this._grayElementObj = cc.Texture2D._generateGrayTexture(this._htmlElementObj); + this._htmlElementObj = this._grayElementObj; + } else { + if(this._backupElement != null) + this._htmlElementObj = this._backupElement; + } } }); + cc.Texture2D._generateGrayTexture = function(texture, rect, renderCanvas){ + if (texture === null) + return null; + renderCanvas = renderCanvas || cc.newElement("canvas"); + rect = rect || cc.rect(0, 0, texture.width, texture.height); + renderCanvas.width = rect.width; + renderCanvas.height = rect.height; + + var context = renderCanvas.getContext("2d"); + context.drawImage(texture, rect.x, rect.y, rect.width, rect.height, 0, 0, rect.width, rect.height); + var imgData = context.getImageData(0, 0, rect.width, rect.height); + var data = imgData.data; + for (var i = 0, len = data.length; i < len; i += 4) { + data[i] = data[i + 1] = data[i + 2] = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]; + } + context.putImageData(imgData, 0, 0); + return renderCanvas; + }; + } else { cc.assert(cc.isFunction(cc._tmp.WebGLTexture2D), cc._LogInfos.MissingFile, "TexturesWebGL.js"); cc._tmp.WebGLTexture2D(); diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index a3b8191a60..a828908e64 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -67,11 +67,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ _bottom: null, _bottomRight: null, - //cache in canvas on Canvas mode - _cacheSprite: null, - _cacheCanvas: null, - _cacheContext: null, - _cacheTexture: null, _scale9Dirty: true, _opacityModifyRGB: false, @@ -923,8 +918,13 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, //v3.3 + /** + * Sets ccui.Scale9Sprite's state + * @since v3.3 + * @param {Number} state + */ setState: function(state){ - // + this._renderCmd.setState(state); }, //setScale9Enabled implement late @@ -1099,4 +1099,6 @@ ccui.Scale9Sprite.POSITIONS_RIGHT = 3; ccui.Scale9Sprite.POSITIONS_BOTTOM = 4; ccui.Scale9Sprite.POSITIONS_TOPRIGHT = 5; ccui.Scale9Sprite.POSITIONS_TOPLEFT = 6; -ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; \ No newline at end of file +ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; + +ccui.Scale9Sprite.state = {NORMAL: 0, GRAY: 1}; diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index 31b21de117..a324dab733 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -120,4 +120,17 @@ if(!this._cacheSprite.getParent()) node.addChild(this._cacheSprite, -1); }; + + proto.setState = function(state){ + var locScale9Image = this._node._scale9Image; + if(!locScale9Image) + return; + var selTexture = locScale9Image.getTexture(); + if(state === ccui.Scale9Sprite.state.NORMAL){ + selTexture._switchToGray(false); + } else if( state === ccui.Scale9Sprite.state.GRAY){ + selTexture._switchToGray(true); + } + this._cacheScale9Sprite(); + }; })(); \ No newline at end of file diff --git a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js index d26f118bd2..158eca0a47 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js @@ -34,9 +34,8 @@ proto.visit = function(parentCmd){ var node = this._node; - if(!node._visible){ + if(!node._visible) return; - } if (node._positionsAreDirty) { node._updatePositions(); @@ -60,7 +59,6 @@ } } } - }; proto._updateDisplayOpacity = function(parentColor){ @@ -77,7 +75,43 @@ } } } + }; + + proto.setState = function (state) { + var scale9Image = this._node._scale9Image; + if (state === ccui.Scale9Sprite.state.NORMAL) { + scale9Image.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + } else if (state === ccui.Scale9Sprite.state.GRAY) { + scale9Image.setShaderProgram(ccui.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram()); + } + }; + + ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = null; + ccui.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram = function(){ + var grayShader = ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram; + if(grayShader) + return grayShader; + + grayShader = new cc.GLProgram(); + grayShader.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, ccui.Scale9Sprite.WebGLRenderCmd._grayShaderFragment); + grayShader.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); + grayShader.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); + grayShader.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); + grayShader.link(); + grayShader.updateUniforms(); + ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = grayShader; + return grayShader; }; + ccui.Scale9Sprite.WebGLRenderCmd._grayShaderFragment = + "precision lowp float;\n" + + "varying vec4 v_fragmentColor; \n" + + "varying vec2 v_texCoord; \n" + + "void main() \n" + + "{ \n" + + " vec4 c = texture2D(CC_Texture0, v_texCoord); \n" + + " gl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b); \n" + +" gl_FragColor.w = c.w ; \n" + + "}"; })(); \ No newline at end of file From bbc07f03763704136c8fb7a18d66707e9733c6a4 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Sat, 10 Jan 2015 17:10:20 +0800 Subject: [PATCH 1174/1564] issue #2563: protect the data --- extensions/cocostudio/loader/load.js | 2 +- .../cocostudio/loader/parsers/uiParser-1.x.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index a8dfc5c5fa..e031a7dbff 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -136,7 +136,7 @@ ccs._parser = cc.Class.extend({ parse: function(file, json){ var resourcePath = this._dirname(file); this.pretreatment(json, resourcePath); - var node = this.parseNode(this.getNodeJson(json), resourcePath); + var node = this.parseNode(this.getNodeJson(json), resourcePath, file); node && this.deferred(json, resourcePath, node, file); return node; }, diff --git a/extensions/cocostudio/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js index a89b01cddc..41500f531f 100644 --- a/extensions/cocostudio/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -53,8 +53,15 @@ if(ignoreSizeExsit != null) widget.ignoreContentAdaptWithSize(ignoreSizeExsit); - widget.setSizeType(options["sizeType"]); - widget.setPositionType(options["positionType"]); + if (options["sizeType"]) + { + widget.setSizeType(options["sizeType"]); + } + + if (options["positionType"]) + { + widget.setPositionType(options["positionType"]); + } widget.setSizePercent(cc.p(options["sizePercentX"], options["sizePercentY"])); widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"])); @@ -262,7 +269,10 @@ var ch = options["capInsetsHeight"]; widget.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch)); } - widget.setLayoutType(options["layoutType"]); + if (options["layoutType"]) + { + widget.setLayoutType(options["layoutType"]); + } }; /** * Button parser (UIButton) From 064784be159294096a1e445fa90b7c3b8784f4bf Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 12 Jan 2015 10:16:08 +0800 Subject: [PATCH 1175/1564] Issue #1267: migrating UIWidget.js --- extensions/ccui/base-classes/UIWidget.js | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 67dc978fbb..bc32a1cd34 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -89,6 +89,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _highlight: false, _touchEventCallback: null, + _clickEventListener: null, _propagateTouchEvents: true, _unifySize: false, @@ -187,14 +188,29 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return parentWidget._isAncestorsEnabled(); }, + /** + * Allow widget touch events to propagate to its parents. Set false will disable propagation + * @since v3.2 + * @param {Boolean} isPropagate + */ setPropagateTouchEvents: function(isPropagate){ this._propagateTouchEvents = isPropagate; }, + /** + * Return whether the widget is propagate touch events to its parents or not + * @since v3.2 + * @returns {boolean} + */ isPropagateTouchEvents: function(){ return this._propagateTouchEvents; }, + /** + * Specify widget to swallow touches or not + * @since v3.2 + * @param {Boolean} swallow + */ setSwallowTouches: function(swallow){ if (this._touchListener) { @@ -202,6 +218,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, + /** + * Return whether the widget is swallowing touch or not + * @since v3.2 + * @returns {boolean} + */ isSwallowTouches: function(){ if (this._touchListener){ //todo @@ -1573,6 +1594,25 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._unifySize = enable; }, + //v3.3 + /** + * Set a event handler to the widget in order to use cocostudio editor and framework + * @since v3.3 + * @param {function} callback + */ + addCCSEventListener: function(callback){}, + + //override the scale functions. + setScaleX: function(scaleX){}, + setScaleY: function(scaleY){}, + setScale: function(scaleX, scaleY){}, + + getScaleX: function(){}, + getScaleY: function(){}, + getScale: function(){}, + + + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_WEBGL) return new ccui.Widget.WebGLRenderCmd(this); From c09f6eb2ff5ccd324890a9a6d466f4dcf75986d6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 12 Jan 2015 10:25:38 +0800 Subject: [PATCH 1176/1564] Fixed Cocos2d-js/#1292: Gets the wrong OS type to sys.os when OS is Linux --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index d2b733287d..f777148fc1 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1561,7 +1561,7 @@ cc._initSys = function (config, CONFIG_KEY) { if (nav.appVersion.indexOf("Win") != -1) osName = sys.OS_WINDOWS; else if (iOS) osName = sys.OS_IOS; else if (nav.appVersion.indexOf("Mac") != -1) osName = sys.OS_OSX; - else if (nav.appVersion.indexOf("X11") != -1) osName = sys.OS_UNIX; + else if (nav.appVersion.indexOf("X11") != -1 && nav.appVersion.indexOf("Linux") == -1) osName = sys.OS_UNIX; else if (isAndroid) osName = sys.OS_ANDROID; else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; From b140c2663a0e652e95677d7c5a956a0ce514641c Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Mon, 12 Jan 2015 11:18:55 +0800 Subject: [PATCH 1177/1564] issue #2563: keey the code same with the jsb code. --- extensions/cocostudio/loader/parsers/action-1.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/action-1.x.js b/extensions/cocostudio/loader/parsers/action-1.x.js index 1b02ce6b2e..c5c20446c4 100644 --- a/extensions/cocostudio/loader/parsers/action-1.x.js +++ b/extensions/cocostudio/loader/parsers/action-1.x.js @@ -63,7 +63,7 @@ }); cache[file] = action; - + cache[file].retain(); return action.clone(); } From 1ee6e7ad510b48154cbe81568dfe05b51cb7a3e2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 12 Jan 2015 13:51:00 +0800 Subject: [PATCH 1178/1564] Issue #1267: migrated ccui.Widget --- extensions/ccui/base-classes/UIWidget.js | 265 +++++++++++++++++++---- 1 file changed, 218 insertions(+), 47 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index bc32a1cd34..d7dc060958 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -94,6 +94,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _propagateTouchEvents: true, _unifySize: false, + _callbackName: null, + _callbackType: null, + _usingLayoutComponent: false, + /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @function @@ -141,7 +145,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @override */ onEnter: function () { - this.updateSizeAndPosition(); + if(!this._usingLayoutComponent) + this.updateSizeAndPosition(); cc.ProtectedNode.prototype.onEnter.call(this); }, @@ -154,11 +159,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ cc.ProtectedNode.prototype.onExit.call(this); }, - getOrCreateLayoutComponent: function(){ + _getOrCreateLayoutComponent: function(){ var layoutComponent = this.getComponent(ccui.__LAYOUT_COMPONENT_NAME); if (null == layoutComponent){ layoutComponent = new ccui.LayoutComponent(); - this.addComponent(component); + this.addComponent(layoutComponent); } return layoutComponent; }, @@ -175,6 +180,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ }, _updateContentSizeWithTextureSize: function(size){ + if(this._unifySize){ + this.setContentSize(size); + return; + } this.setContentSize(this._ignoreSize ? size : this._customSize); }, @@ -213,9 +222,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setSwallowTouches: function(swallow){ if (this._touchListener) - { this._touchListener.setSwallowTouches(swallow); - } }, /** @@ -225,9 +232,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ isSwallowTouches: function(){ if (this._touchListener){ - //todo - return true; - //return this._touchListener.isSwallowTouches(); + //return true; //todo need test + return this._touchListener.isSwallowTouches(); } return false; }, @@ -297,10 +303,12 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._customSize.width = locWidth; this._customSize.height = locHeight; - if (this._ignoreSize){ + if(this._unifySize){ + //unify size logic + } else if (this._ignoreSize){ this._contentSize = this.getVirtualRendererSize(); } - if (this._running) { + if (!this._usingLayoutComponent && this._running) { var widgetParent = this.getWidgetParent(); var pSize = widgetParent ? widgetParent.getContentSize() : this._parent.getContentSize(); this._sizePercent.x = (pSize.width > 0.0) ? locWidth / pSize.width : 0.0; @@ -312,10 +320,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _setWidth: function (w) { cc.Node.prototype._setWidth.call(this, w); this._customSize.width = w; - if(this._ignoreSize) + if(this._unifySize){ + //unify size logic + } else if (this._ignoreSize){ this._contentSize = this.getVirtualRendererSize(); + } - if (this._running) { + if (!this._usingLayoutComponent && this._running) { var widgetParent = this.getWidgetParent(); var locWidth = widgetParent ? widgetParent.width : this._parent.width; this._sizePercent.x = locWidth > 0 ? this._customSize.width / locWidth : 0; @@ -325,10 +336,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _setHeight: function (h) { cc.Node.prototype._setHeight.call(this, h); this._customSize.height = h; - if(this._ignoreSize) + if(this._unifySize){ + //unify size logic + } else if (this._ignoreSize){ this._contentSize = this.getVirtualRendererSize(); + } - if (this._running) { + if (!this._usingLayoutComponent && this._running) { var widgetParent = this.getWidgetParent(); var locH = widgetParent ? widgetParent.height : this._parent.height; this._sizePercent.y = locH > 0 ? this._customSize.height / locH : 0; @@ -341,6 +355,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Point} percent that is widget's percent size, width and height value from 0 to 1. */ setSizePercent: function (percent) { + if(this._usingLayoutComponent){ + var component = this._getOrCreateLayoutComponent(); + component.setUsingPercentContentSize(true); + component.setPercentContentSize(percent); + component.refreshLayout(); + return; + } this._sizePercent.x = percent.x; this._sizePercent.y = percent.y; @@ -456,6 +477,10 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setSizeType: function (type) { this._sizeType = type; + if (this._usingLayoutComponent) { + var component = this._getOrCreateLayoutComponent(); + component.setUsingPercentContentSize(this._sizeType == ccui.SIZE_PERCENT); + } }, /** @@ -471,12 +496,17 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} ignore true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ ignoreContentAdaptWithSize: function (ignore) { + if(this._unifySize){ + this.setContentSize(this._customSize); + return; + } + if(this._ignoreSize == ignore) return; this._ignoreSize = ignore; this.setContentSize( ignore ? this.getVirtualRendererSize() : this._customSize ); - this._onSizeChanged(); + //this._onSizeChanged(); }, /** @@ -508,8 +538,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Point} */ getSizePercent: function () { - var component = this.getOrCreateLayoutComponent(); - return component.getPercentContentSize(); + if(this._usingLayoutComponent){ + var component = this._getOrCreateLayoutComponent(); + this._sizePercent = component.getPercentContentSize(); + } + return this._sizePercent; }, _getWidthPercent: function () { return this._sizePercent.x; @@ -545,11 +578,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * call back function called when size changed. */ _onSizeChanged: function () { - var locChildren = this.getChildren(); - for (var i = 0, len = locChildren.length; i < len; i++) { - var child = locChildren[i]; - if(child instanceof ccui.Widget) - child.updateSizeAndPosition(); + if(!this._usingLayoutComponent){ + var locChildren = this.getChildren(); + for (var i = 0, len = locChildren.length; i < len; i++) { + var child = locChildren[i]; + if(child instanceof ccui.Widget) + child.updateSizeAndPosition(); + } } }, @@ -839,8 +874,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ /* * Propagate touch events to its parents */ - if (this._propagateTouchEvents) - { + if (this._propagateTouchEvents) { this.propagateTouchEvent(ccui.Widget.TOUCH_BEGAN, this, touch); } @@ -868,9 +902,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchMovePosition.x = touchPoint.x; this._touchMovePosition.y = touchPoint.y; this.setHighlighted(this.hitTest(touchPoint)); - var widgetParent = this.getWidgetParent(); - if (widgetParent) - widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); + /* + * Propagate touch events to its parents + */ + if (this._propagateTouchEvents) + this.propagateTouchEvent(ccui.Widget.TOUCH_MOVED, this, touch); this._moveEvent(); }, @@ -888,9 +924,12 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var touchPoint = touch.getLocation(); this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; - var widgetParent = this.getWidgetParent(); - if (widgetParent) - widgetParent.interceptTouchEvent(ccui.Widget.TOUCH_ENDED, this, touch); + /* + * Propagate touch events to its parents + */ + if (this._propagateTouchEvents) + this.propagateTouchEvent(ccui.Widget.TOUCH_ENDED, this, touch); + var highlight = this._highlight; this.setHighlighted(false); if (highlight) @@ -936,10 +975,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchEventCallback(this, ccui.Widget.TOUCH_ENDED); if (this._touchEventListener && this._touchEventSelector) this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED); - - if (this._clickEventListener) { + if (this._clickEventListener) this._clickEventListener(this); - } }, _cancelUpEvent: function () { @@ -1032,7 +1069,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Number} [posY] */ setPosition: function (pos, posY) { - if (this._running) { + if (!this._usingLayoutComponent && this._running) { var widgetParent = this.getWidgetParent(); if (widgetParent) { var pSize = widgetParent.getContentSize(); @@ -1089,6 +1126,14 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {cc.Point} percent */ setPositionPercent: function (percent) { + if (this._usingLayoutComponent) + { + var component = this._getOrCreateLayoutComponent(); + component.setPositionPercentX(percent.x); + component.setPositionPercentY(percent.y); + component.refreshLayout(); + return; + } this._positionPercent = percent; if (this._running) { var widgetParent = this.getWidgetParent(); @@ -1099,6 +1144,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, _setXPercent: function (percent) { + if (this._usingLayoutComponent) + { + var component = this._getOrCreateLayoutComponent(); + component.setPositionPercentX(percent.x); + component.refreshLayout(); + return; + } this._positionPercent.x = percent; if (this._running) { var widgetParent = this.getWidgetParent(); @@ -1107,6 +1159,13 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, _setYPercent: function (percent) { + if (this._usingLayoutComponent) + { + var component = this._getOrCreateLayoutComponent(); + component.setPositionPercentY(percent.x); + component.refreshLayout(); + return; + } this._positionPercent.y = percent; if (this._running) { var widgetParent = this.getWidgetParent(); @@ -1120,13 +1179,28 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @returns {cc.Point} The percent (x,y) of the widget in OpenGL coordinates */ getPositionPercent: function () { + if (this._usingLayoutComponent) { + var component = this._getOrCreateLayoutComponent(); + this._positionPercent.x = component.getPositionPercentX(); + this._positionPercent.y = component.getPositionPercentY(); + } return cc.p(this.getNormalizedPosition()); }, _getXPercent: function () { + if (this._usingLayoutComponent) { + var component = this._getOrCreateLayoutComponent(); + this._positionPercent.x = component.getPositionPercentX(); + this._positionPercent.y = component.getPositionPercentY(); + } return this._positionPercent.x; }, _getYPercent: function () { + if (this._usingLayoutComponent) { + var component = this._getOrCreateLayoutComponent(); + this._positionPercent.x = component.getPositionPercentX(); + this._positionPercent.y = component.getPositionPercentY(); + } return this._positionPercent.y; }, @@ -1136,6 +1210,16 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ */ setPositionType: function (type) { this._positionType = type; + if(this._usingLayoutComponent){ + var component = this._getOrCreateLayoutComponent(); + if (type == ccui.POSITION_ABSOLUTE){ + component.setPositionPercentXEnabled(false); + component.setPositionPercentYEnabled(false); + } else { + component.setPositionPercentXEnabled(true); + component.setPositionPercentYEnabled(true); + } + } this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); }, @@ -1152,8 +1236,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} flipX true if the widget should be flipped horizontally, false otherwise. */ setFlippedX: function (flipX) { + var realScale = this.getScaleX(); this._flippedX = flipX; - this._updateFlippedX(); + this.setScaleX(realScale); }, /** @@ -1175,8 +1260,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} flipY true if the widget should be flipped vertically, false otherwise. */ setFlippedY: function (flipY) { + var realScale = this.getScaleY(); this._flippedY = flipY; - this._updateFlippedY(); + this.setScaleY(realScale); }, /** @@ -1193,10 +1279,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return this._flippedY; }, - _updateFlippedX: function () {}, - - _updateFlippedY: function () {}, - _adaptRenderers: function(){}, /** @@ -1586,31 +1668,120 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ } }, + /** + * @since v3.2 + * @returns {boolean} true represent the widget use Unify Size, false represent the widget couldn't use Unify Size + */ isUnifySizeEnabled: function(){ return this._unifySize; }, + /** + * @since v3.2 + * @param {Boolean} enable enable Unify Size of a widget + */ setUnifySizeEnabled: function(enable){ this._unifySize = enable; }, //v3.3 + _ccEventCallback: null, /** * Set a event handler to the widget in order to use cocostudio editor and framework * @since v3.3 * @param {function} callback */ - addCCSEventListener: function(callback){}, + addCCSEventListener: function(callback){ + this._ccEventCallback = callback; + }, //override the scale functions. - setScaleX: function(scaleX){}, - setScaleY: function(scaleY){}, - setScale: function(scaleX, scaleY){}, + setScaleX: function(scaleX){ + if (this._flippedX) + scaleX = scaleX * -1; + cc.Node.prototype.setScaleX.call(this, scaleX); + }, + setScaleY: function(scaleY){ + if (this._flippedY) + scaleY = scaleY * -1; + cc.Node.prototype.setScaleY.call(this, scaleY); + }, + setScale: function(scaleX, scaleY){ + if(scaleY === undefined) + scaleY = scaleX; + this.setScaleX(scaleX); + this.setScaleY(scaleY); + }, + + getScaleX: function(){ + var originalScale = cc.Node.prototype.getScaleX.call(this); + if (this._flippedX) + originalScale = originalScale * -1.0; + return originalScale; + }, + getScaleY: function(){ + var originalScale = cc.Node.prototype.getScaleY.call(this); + if (this._flippedY) + originalScale = originalScale * -1.0; + return originalScale; + }, + getScale: function(){ + cc.log(this.getScaleX() == this.getScaleY(), "Widget#scale. ScaleX != ScaleY. Don't know which one to return"); + return this.getScaleX(); + }, + + /** + * Sets callback name to widget. + * @since v3.3 + * @param {String} callbackName + */ + setCallbackName: function(callbackName){ + this._callbackName = callbackName; + }, + + /** + * Gets callback name of widget + * @since v3.3 + * @returns {String|Null} + */ + getCallbackName: function(){ + return this._callbackName; + }, + + /** + * Sets callback type to widget + * @since v3.3 + * @param {String} callbackType + */ + setCallbackType: function(callbackType){ + this._callbackType = callbackType; + }, - getScaleX: function(){}, - getScaleY: function(){}, - getScale: function(){}, + /** + * Gets callback type of widget + * @since v3.3 + * @returns {String|null} + */ + getCallbackType: function(){ + return this._callbackType; + }, + + /** + * Whether enable layout component of a widget + * @since v3.3 + * @param {Boolean} enable enable layout Component of a widget + */ + setLayoutComponentEnabled: function(enable){ + this._usingLayoutComponent = enable; + }, + /** + * Returns whether enable layout component of a widget + * @return {Boolean} true represent the widget use Layout Component, false represent the widget couldn't use Layout Component. + */ + isLayoutComponentEnabled: function(){ + return this._usingLayoutComponent; + }, _createRenderCmd: function(){ From 1d1539709ae9a30bc8dccb630272902012961b6a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 14:11:02 +0800 Subject: [PATCH 1179/1564] update build.xml --- tools/build.xml | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/tools/build.xml b/tools/build.xml index e602c3e0e0..a703fea018 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -265,28 +265,17 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + From 8dd86729d79d52818abf4a0499b20cebff63aefa Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 15:10:58 +0800 Subject: [PATCH 1180/1564] Fixed the audio path is error and add LabelBMFont preload info --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 746e6da38b..a0e7307595 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -935,6 +935,8 @@ widget.setString(text); loadTexture(json["LabelBMFontFile_CNB"], resourcePath, function(path, type){ + if(!cc.loader.getRes(path)) + cc.log("%s need to pre load", path); widget.setFntFile(path); }); return widget; @@ -1015,7 +1017,10 @@ if(volume != null) cc.audioEngine.setMusicVolume(volume); //var name = json["Name"]; - var resPath = (cc.loader.resPath + "/").replace(/\/\/$/, "/"); + var resPath = ""; + if(cc.loader.resPath) + resPath = (cc.loader.resPath + "/").replace(/\/\/$/, "/"); + loadTexture(json["FileData"], resourcePath, function(path, type){ cc.loader.load(path, function(){ cc.audioEngine.playMusic(resPath + path, loop); From 33298c3a74166cff8d7b4b666057c73b91d2b33e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 16:44:36 +0800 Subject: [PATCH 1181/1564] Issue #1267: update UIButton.js --- extensions/ccui/uiwidgets/UIButton.js | 306 ++++++++++++++------------ 1 file changed, 166 insertions(+), 140 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index a440c02339..419e532f4f 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -126,6 +126,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, _initRenderer: function () { + //todo create Scale9Sprite this._buttonNormalRenderer = new cc.Sprite(); this._buttonClickedRenderer = new cc.Sprite(); this._buttonDisableRenderer = new cc.Sprite(); @@ -143,6 +144,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {Boolean} able true that using scale9 renderer, false otherwise. */ setScale9Enabled: function (able) { + //todo create Scale9Sprite if (this._scale9Enabled == able) return; @@ -201,13 +203,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ ignoreContentAdaptWithSize: function (ignore) { if(this._unifySize){ - if(this._scale9Enabled){ - ccui.ProtectedNode.prototype.setContentSize.call(this, this._customSize); - }else{ - var s = this.getVirtualRendererSize(); - ccui.ProtectedNode.prototype.setContentSize.call(this, s); - } - this._onSizeChanged(); + this._updateContentSize(); return; } if (!this._scale9Enabled || (this._scale9Enabled && !ignore)) { @@ -221,9 +217,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @returns {cc.Size} */ getVirtualRendererSize: function(){ + if (this._unifySize) + return this.getNormalSize(); + var titleSize = this._titleRenderer.getContentSize(); if (!this._normalTextureLoaded && this._titleRenderer.getString().length > 0) { - return titleSize; + return cc.size(titleSize); } return cc.size(this._normalTextureSize); }, @@ -272,41 +271,33 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }); } - if (this._scale9Enabled) { - var normalRendererScale9 = this._buttonNormalRenderer; - switch (this._normalTexType){ - case ccui.Widget.LOCAL_TEXTURE: - normalRendererScale9.initWithFile(normal); - break; - case ccui.Widget.PLIST_TEXTURE: - normalRendererScale9.initWithSpriteFrameName(normal); - break; - default: - break; - } - normalRendererScale9.setCapInsets(this._capInsetsNormal); - } else { - var normalRenderer = this._buttonNormalRenderer; - switch (this._normalTexType){ - case ccui.Widget.LOCAL_TEXTURE: - //SetTexture cannot load resource - normalRenderer.initWithFile(normal); - break; - case ccui.Widget.PLIST_TEXTURE: - //SetTexture cannot load resource - normalRenderer.initWithSpriteFrameName(normal); - break; - default: - break; - } + var normalRenderer = this._buttonNormalRenderer; + switch (this._normalTexType){ + case ccui.Widget.LOCAL_TEXTURE: + //SetTexture cannot load resource + normalRenderer.initWithFile(normal); + break; + case ccui.Widget.PLIST_TEXTURE: + //SetTexture cannot load resource + normalRenderer.initWithSpriteFrameName(normal); + break; + default: + break; } + if (this._unifySize) + if (this._scale9Enabled){ + normalRenderer.setCapInsets(this._capInsetsNormal); + this._updateContentSizeWithTextureSize(this.getNormalSize()); + } + else + this._updateContentSizeWithTextureSize(this._normalTextureSize); + this._normalTextureSize = this._buttonNormalRenderer.getContentSize(); this._updateFlippedX(); this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); - this._updateContentSizeWithTextureSize(this._normalTextureSize); this._normalTextureLoaded = true; this._normalTextureAdaptDirty = true; }, @@ -338,34 +329,23 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }); } - if (this._scale9Enabled) { - var clickedRendererScale9 = this._buttonClickedRenderer; - switch (this._pressedTexType) { - case ccui.Widget.LOCAL_TEXTURE: - clickedRendererScale9.initWithFile(selected); - break; - case ccui.Widget.PLIST_TEXTURE: - clickedRendererScale9.initWithSpriteFrameName(selected); - break; - default: - break; - } - clickedRendererScale9.setCapInsets(this._capInsetsPressed); - } else { - var clickedRenderer = this._buttonClickedRenderer; - switch (this._pressedTexType) { - case ccui.Widget.LOCAL_TEXTURE: - //SetTexture cannot load resource - clickedRenderer.initWithFile(selected); - break; - case ccui.Widget.PLIST_TEXTURE: - //SetTexture cannot load resource - clickedRenderer.initWithSpriteFrameName(selected); - break; - default: - break; - } + var clickedRenderer = this._buttonClickedRenderer; + switch (this._pressedTexType) { + case ccui.Widget.LOCAL_TEXTURE: + //SetTexture cannot load resource + clickedRenderer.initWithFile(selected); + break; + case ccui.Widget.PLIST_TEXTURE: + //SetTexture cannot load resource + clickedRenderer.initWithSpriteFrameName(selected); + break; + default: + break; } + + if (this._scale9Enabled) + clickedRenderer.setCapInsets(this._capInsetsPressed); + this._pressedTextureSize = this._buttonClickedRenderer.getContentSize(); this._updateFlippedX(); this._updateFlippedY(); @@ -404,34 +384,23 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }); } - if (this._scale9Enabled) { - var disabledScale9 = this._buttonDisableRenderer; - switch (this._disabledTexType) { - case ccui.Widget.LOCAL_TEXTURE: - disabledScale9.initWithFile(disabled); - break; - case ccui.Widget.PLIST_TEXTURE: - disabledScale9.initWithSpriteFrameName(disabled); - break; - default: - break; - } - disabledScale9.setCapInsets(this._capInsetsDisabled); - } else { - var disabledRenderer = this._buttonDisableRenderer; - switch (this._disabledTexType) { - case ccui.Widget.LOCAL_TEXTURE: - //SetTexture cannot load resource - disabledRenderer.initWithFile(disabled); - break; - case ccui.Widget.PLIST_TEXTURE: - //SetTexture cannot load resource - disabledRenderer.initWithSpriteFrameName(disabled); - break; - default: - break; - } + var disabledRenderer = this._buttonDisableRenderer; + switch (this._disabledTexType) { + case ccui.Widget.LOCAL_TEXTURE: + //SetTexture cannot load resource + disabledRenderer.initWithFile(disabled); + break; + case ccui.Widget.PLIST_TEXTURE: + //SetTexture cannot load resource + disabledRenderer.initWithSpriteFrameName(disabled); + break; + default: + break; } + + if (this._scale9Enabled) + disabledRenderer.setCapInsets(this._capInsetsDisabled); + this._disabledTextureSize = this._buttonDisableRenderer.getContentSize(); this._updateFlippedX(); this._updateFlippedY(); @@ -500,7 +469,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {cc.Rect} capInsets */ setCapInsetsPressedRenderer: function (capInsets) { - if(!capInsets) + if(!capInsets || !this._scale9Enabled) return; var x = capInsets.x; @@ -525,8 +494,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locInsets.y = y; locInsets.width = width; locInsets.height = height; - if (!this._scale9Enabled) - return; + this._buttonClickedRenderer.setCapInsets(rect); }, @@ -543,7 +511,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {cc.Rect} capInsets */ setCapInsetsDisabledRenderer: function (capInsets) { - if(!capInsets) + if(!capInsets || !this._scale9Enabled) return; var x = capInsets.x; @@ -569,8 +537,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locInsets.width = width; locInsets.height = height; - if (!this._scale9Enabled) - return; this._buttonDisableRenderer.setCapInsets(rect); }, @@ -586,6 +552,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonNormalRenderer.setVisible(true); this._buttonClickedRenderer.setVisible(false); this._buttonDisableRenderer.setVisible(false); + if (this._scale9Enabled) + this._buttonNormalRenderer.setState(0/*Scale9Sprite::State::NORMAL*/); if (this._pressedTextureLoaded) { if (this.pressedActionEnabled){ this._buttonNormalRenderer.stopAllActions(); @@ -595,18 +563,25 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); this._titleRenderer.stopAllActions(); - this._titleRenderer.runAction(zoomAction.clone()); + if (this._unifySize){ + var zoomTitleAction = cc.scaleTo(0.05/*ZOOM_ACTION_TIME_STEP*/, 1, 1); + this._titleRenderer.runAction(zoomTitleAction); + }else + this._titleRenderer.runAction(zoomAction.clone()); } } else { - if (this._scale9Enabled){ - //todo checking here. old -> this._updateTexturesRGBA(); + this._buttonNormalRenderer.stopAllActions(); + this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + + this._titleRenderer.stopAllActions(); + + if (this._scale9Enabled) this._buttonNormalRenderer.setColor(cc.color.WHITE); - } - else { - this._buttonNormalRenderer.stopAllActions(); - this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); - this._titleRenderer.stopAllActions(); + if(this._unifySize){ + this._titleRenderer.setScaleX(1); + this._titleRenderer.setScaleY(1); + }else{ this._titleRenderer.setScaleX(this._normalTextureScaleXInSize); this._titleRenderer.setScaleY(this._normalTextureScaleYInSize); } @@ -615,6 +590,9 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _onPressStateChangedToPressed: function () { var locNormalRenderer = this._buttonNormalRenderer; + if (this._scale9Enabled) + locNormalRenderer.setState(0/*Scale9Sprite::State::NORMAL*/); + if (this._pressedTextureLoaded) { locNormalRenderer.setVisible(false); this._buttonClickedRenderer.setVisible(true); @@ -627,34 +605,67 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locNormalRenderer.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1); this._titleRenderer.stopAllActions(); - //we must call zoomAction->clone here - this._titleRenderer.runAction(zoomAction.clone()); + if (this._unifySize){ + var zoomTitleAction = cc.scaleTo(0.05, 1 + this._zoomScale, 1 + this._zoomScale); + this._titleRenderer.runAction(zoomTitleAction); + } + else + this._titleRenderer.runAction(zoomAction.clone()); } } else { locNormalRenderer.setVisible(true); this._buttonClickedRenderer.setVisible(true); this._buttonDisableRenderer.setVisible(false); + locNormalRenderer.stopAllActions(); + locNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); + if (this._scale9Enabled) locNormalRenderer.setColor(cc.color.GRAY); - else { - locNormalRenderer.stopAllActions(); - locNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); - this._titleRenderer.stopAllActions(); + this._titleRenderer.stopAllActions(); + if (this._unifySize){ + this._titleRenderer.setScaleX(1 + this._zoomScale); + this._titleRenderer.setScaleY(1 + this._zoomScale); + }else{ this._titleRenderer.setScaleX(this._normalTextureScaleXInSize + this._zoomScale); this._titleRenderer.setScaleY(this._normalTextureScaleYInSize + this._zoomScale); } + } }, _onPressStateChangedToDisabled: function () { - this._buttonNormalRenderer.setVisible(false); + + //if disable resource is null + if (!this._disabledTextureLoaded){ + if (this._normalTextureLoaded && this._scale9Enabled) + this._buttonNormalRenderer.setState(1/*Scale9Sprite::State::GRAY*/); + }else{ + this._buttonNormalRenderer.setVisible(false); + this._buttonDisableRenderer.setVisible(true); + } + this._buttonClickedRenderer.setVisible(false); - this._buttonDisableRenderer.setVisible(true); this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); }, + _updateContentSize: function(){ + if (this._unifySize){ + if (this._scale9Enabled) + ccui.ProtectedNode.setContentSize(this._customSize); + else{ + var s = this.getNormalSize(); + ccui.ProtectedNode.setContentSize(s); + } + this._onSizeChanged(); + return; + } + + if (this._ignoreSize) + this.setContentSize(this.getVirtualRendererSize()); + }, + _updateFlippedX: function () { var flip = this._flippedX ? -1.0 : 1.0; this._titleRenderer.setScaleX(flip); @@ -720,22 +731,21 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ }, _normalTextureScaleChangedWithSize: function () { - if(this._unifySize){ - if (this._scale9Enabled) - this._buttonNormalRenderer.setPreferredSize(this._contentSize); - }else if (this._ignoreSize) { - if (!this._scale9Enabled) { - this._buttonNormalRenderer.setScale(1.0); + if(this._ignoreSize && !this._unifySize){ + if(!this._scale9Enabled){ + this._buttonNormalRenderer.setScale(1); this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1; } - } else { - if (this._scale9Enabled) { + }else{ + if (this._scale9Enabled){ this._buttonNormalRenderer.setPreferredSize(this._contentSize); this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1; - } else { + this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + }else{ var textureSize = this._normalTextureSize; - if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._buttonNormalRenderer.setScale(1.0); + if (textureSize.width <= 0 || textureSize.height <= 0) + { + this._buttonNormalRenderer.setScale(1); return; } var scaleX = this._contentSize.width / textureSize.width; @@ -746,23 +756,24 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._normalTextureScaleYInSize = scaleY; } } - this._buttonNormalRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); + this._buttonNormalRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, _pressedTextureScaleChangedWithSize: function () { - if (this._ignoreSize) { + if (this._ignoreSize && !this._unifySize) { if (!this._scale9Enabled) { - this._buttonClickedRenderer.setScale(1.0); + this._buttonClickedRenderer.setScale(1); this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1; } } else { if (this._scale9Enabled) { this._buttonClickedRenderer.setPreferredSize(this._contentSize); this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1; + this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); } else { var textureSize = this._pressedTextureSize; - if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._buttonClickedRenderer.setScale(1.0); + if (textureSize.width <= 0 || textureSize.height <= 0) { + this._buttonClickedRenderer.setScale(1); return; } var scaleX = this._contentSize.width / textureSize.width; @@ -773,23 +784,21 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._pressedTextureScaleYInSize = scaleY; } } - this._buttonClickedRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); + this._buttonClickedRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, _disabledTextureScaleChangedWithSize: function () { - if(this._unifySize){ - if (this._scale9Enabled) - this._buttonNormalRenderer.setPreferredSize(this._contentSize); - }else if (this._ignoreSize) { - if (!this._scale9Enabled) - this._buttonDisableRenderer.setScale(1.0); - } else { + if(this._ignoreSize && !this._unifySize){ if (this._scale9Enabled) + this._buttonDisableRenderer.setScale(1); + }else { + if (this._scale9Enabled){ + this._buttonDisableRenderer.setScale(1); this._buttonDisableRenderer.setPreferredSize(this._contentSize); - else { + }else{ var textureSize = this._disabledTextureSize; - if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { - this._buttonDisableRenderer.setScale(1.0); + if (textureSize.width <= 0 || textureSize.height <= 0) { + this._buttonDisableRenderer.setScale(1); return; } var scaleX = this._contentSize.width / textureSize.width; @@ -798,7 +807,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonDisableRenderer.setScaleY(scaleY); } } - this._buttonDisableRenderer.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); + this._buttonDisableRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, _adaptRenderers: function(){ @@ -833,6 +842,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {String} text */ setTitleText: function (text) { + if(text == this.getTitleText()) + return; this._titleRenderer.setString(text); if (this._ignoreSize){ var s = this.getVirtualRendererSize(); @@ -872,6 +883,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ setTitleFontSize: function (size) { this._titleRenderer.setFontSize(size); + this._fontSize = size; }, /** @@ -956,6 +968,20 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ setColor: function(color){ cc.ProtectedNode.prototype.setColor.call(this, color); this._updateTexturesRGBA(); + }, + + getNormalSize: function(){ + var titleSize; + if (this._titleRenderer != null) + titleSize = this._titleRenderer.getContentSize(); + + var imageSize; + if (this._buttonNormalRenderer != null) + imageSize = this._buttonNormalRenderer.getContentSize(); + var width = titleSize.width > imageSize.width ? titleSize.width : imageSize.width; + var height = titleSize.height > imageSize.height ? titleSize.height : imageSize.height; + + return cc.size(width,height); } }); From 97c40ad032264e737dc716c644ab936a4ef19e78 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 12 Jan 2015 16:51:06 +0800 Subject: [PATCH 1182/1564] Issue cocos2d/cocos2d-js/#1267: ccui.LayoutComponent has been migrated. --- extensions/ccui/layouts/UILayoutComponent.js | 668 +++++++++++++------ extensions/ccui/system/UIHelper.js | 16 +- 2 files changed, 466 insertions(+), 218 deletions(-) diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index b22d7b1a0e..14e40f5e86 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -41,284 +41,518 @@ ccui.LayoutComponent_SizeType = { PreSizeEnable: 2 }; +//refactor since v3.3 ccui.LayoutComponent = cc.Component.extend({ + _horizontalEdge: 0, + _verticalEdge: 0, - _percentContentSize: null, - _usingPercentContentSize: false, + _leftMargin: 0, + _rightMargin: 0, + _bottomMargin: 0, + _topMargin: 0, - _referencePoint: ccui.LayoutComponent_ReferencePoint.BOTTOM_LEFT, - _relativePosition: null, - _percentPosition: null, - _usingPercentPosition: false, - _actived: true, + _usingPositionPercentX: false, + _positionPercentX: 0, + _usingPositionPercentY: false, + _positionPercentY: 0, + + _usingStretchWidth: false, + _usingStretchHeight: false, + + _percentWidth: 0, + _usingPercentWidth: false, + _percentHeight: 0, + _usingPercentHeight: false, - init: function(){ + _actived: true, + ctor: function(){ + this._name = ccui.LayoutComponent.NAME; + }, + + init: function () { var ret = true; - do - { - if (!cc.Component.prototype.init.call(this)) - { - ret = false; - break; - } - //put layout component initalized code here + if (!cc.Component.prototype.init.call(this)) { + return false; + } + + //put layout component initalized code here - } while (0); return ret; }, - isUsingPercentPosition: function(){ - return this._usingPercentPosition; + getPercentContentSize: function(){ + return cc.p(this._percentWidth, this._percentHeight); }, - setUsingPercentPosition: function(flag){ - this._usingPercentPosition = flag; - this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.PreRelativePositionEnable, cc.p(0,0)); + setPercentContentSize: function(percent){ + this.setPercentWidth(percent.x); + this.setPercentHeight(percent.y); }, - getPercentPosition: function(){ - return this._percentPosition; + setUsingPercentContentSize: function(isUsed){ + this._usingPercentWidth = this._usingPercentHeight = isUsed; }, - setPercentPosition: function(percent){ - this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.PreRelativePosition, percent); + + //old + SetActiveEnable: function(enable){ + this._actived = enable; + }, + + //v3.3 + getUsingPercentContentSize: function(){ + return this._usingPercentWidth && this._usingPercentHeight; }, - getRelativePosition: function(){ - return this._relativePosition; + //position & margin + getAnchorPosition: function(){ + return this._owner.getAnchorPoint(); }, - setRelativePosition: function(position){ - this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.RelativePosition, position); + + setAnchorPosition: function(point, y){ + var oldRect = this._owner.getBoundingBox(); + this._owner.setAnchorPoint(point, y); + var newRect = this._owner.getBoundingBox(); + var offSetX = oldRect.x - newRect.x, offSetY = oldRect.y - newRect.y; + + var ownerPosition = this._owner.getPosition(); + ownerPosition.x += offSetX; + ownerPosition.y += offSetY; + this.setPosition(ownerPosition); + }, + + getPosition: function(){ + return this._owner.getPosition(); + }, + + setPosition: function(position, y){ + var parent = this._getOwnerParent(), x; + if (parent != null) { + if(y === undefined){ + x = position.x; + y = position.y; + }else + x = position; + var parentSize = parent.getContentSize(); + + if (parentSize.width != 0) + this._positionPercentX = x / parentSize.width; + else { + this._positionPercentX = 0; + if (this._usingPositionPercentX) + x = 0; + } + + if (parentSize.height != 0) + this._positionPercentY = y / parentSize.height; + else { + this._positionPercentY = 0; + if (this._usingPositionPercentY) + y = 0; + } + + this._owner.setPosition(x, y); + this._refreshHorizontalMargin(); + this._refreshVerticalMargin(); + } else + this._owner.setPosition(position, y); + }, + + isPositionPercentXEnabled: function(){ + return this._usingPositionPercentX; + }, + setPositionPercentXEnabled: function(isUsed){ + this._usingPositionPercentX = isUsed; + if (this._usingPositionPercentX) + this._horizontalEdge = ccui.LayoutComponent.horizontalEdge.NONE; + }, + + getPositionPercentX: function(){ + return this._positionPercentX; + }, + setPositionPercentX: function(percentMargin){ + this._positionPercentX = percentMargin; + + var parent = this._getOwnerParent(); + if (parent != null) { + this._owner.setPositionX(parent.width * this._positionPercentX); + this._refreshHorizontalMargin(); + } }, - setReferencePoint: function(point){ - this._referencePoint = point; - this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.RelativePosition, this._relativePosition) + isPositionPercentYEnabled: function(){ + return this._usingPositionPercentY; }, - getReferencePoint: function(){ - return this._referencePoint; + setPositionPercentYEnabled: function(isUsed){ + this._usingPositionPercentY = isUsed; + if (this._usingPositionPercentY) + this._verticalEdge = ccui.LayoutComponent.verticalEdge.NONE; }, - getOwnerPosition: function(){ - return this.getOwner().getPosition(); + getPositionPercentY: function(){ + return this._positionPercentY; }, - setOwnerPosition: function(point){ - this.RefreshLayoutPosition(ccui.LayoutComponent_PositionType.Position, point); + setPositionPercentY: function(percentMargin){ + this._positionPercentY = percentMargin; + + var parent = this._getOwnerParent(); + if (parent != null) { + this._owner.setPositionY(parent.height * this._positionPercentY); + this._refreshVerticalMargin(); + } }, - RefreshLayoutPosition: function(pType, point){ - var parentNode = this.getOwner().getParent(); - var basePoint = point; - if (parentNode != null && this._actived) - { - var parentSize = parentNode.getContentSize(); + getHorizontalEdge: function(){ + return this._horizontalEdge; + }, + setHorizontalEdge: function(hEdge){ + this._horizontalEdge = hEdge; + if (this._horizontalEdge != cc.LayoutComponent.horizontalEdge.NONE) + this._usingPositionPercentX = false; - if ( pType == ccui.LayoutComponent_PositionType.PreRelativePosition) - { - this._percentPosition = point; - basePoint = cc.p(this._percentPosition.x * parentSize.width, this._percentPosition.y * parentSize.height); + var parent = this._getOwnerParent(); + if (parent != null) { + var ownerPoint = this._owner.getPosition(); + var parentSize = parent.getContentSize(); + if (parentSize.width != 0) + this._positionPercentX = ownerPoint.x / parentSize.width; + else { + this._positionPercentX = 0; + ownerPoint.x = 0; + if (this._usingPositionPercentX) + this._owner.setPosition(ownerPoint); } - else if(pType == ccui.LayoutComponent_PositionType.PreRelativePositionEnable) - { - if (this._usingPercentPosition) - { - if (parentSize.width != 0) - { - this._percentPosition.x = this._relativePosition.x / parentSize.width; - } - else - { - this._percentPosition.x = 0; - this._relativePosition.x = 0; - } - - if (parentSize.height != 0) - { - this._percentPosition.y = this._relativePosition.y / parentSize.height; - } - else - { - this._percentPosition.y = 0; - this._relativePosition.y = 0; - } - } - basePoint = this._relativePosition; + this._refreshHorizontalMargin(); + } + }, + + getVerticalEdge: function(){ + return this._verticalEdge; + }, + setVerticalEdge: function(vEdge){ + this._verticalEdge = vEdge; + if (this._verticalEdge != ccui.LayoutComponent.verticalEdge.NONE) + this._usingPositionPercentY = false; + + var parent = this._getOwnerParent(); + if (parent != null) { + var ownerPoint = this._owner.getPosition(); + var parentSize = parent.getContentSize(); + if (parentSize.height != 0) + this._positionPercentY = ownerPoint.y / parentSize.height; + else { + this._positionPercentY = 0; + ownerPoint.y = 0; + if (this._usingPositionPercentY) + this._owner.setPosition(ownerPoint); } + this._refreshVerticalMargin(); + } + }, - var inversePoint = basePoint; - switch (this._referencePoint) - { - case ccui.LayoutComponent_ReferencePoint.TOP_LEFT: - inversePoint.y = parentSize.height - inversePoint.y; - break; - case ccui.LayoutComponent_ReferencePoint.BOTTOM_RIGHT: - inversePoint.x = parentSize.width - inversePoint.x; - break; - case ccui.LayoutComponent_ReferencePoint.TOP_RIGHT: - inversePoint.x = parentSize.width - inversePoint.x; - inversePoint.y = parentSize.height - inversePoint.y; - break; - default: - break; + getLeftMargin: function(){ + return this._leftMargin; + }, + setLeftMargin: function(margin){ + this._leftMargin = margin; + }, + + getRightMargin: function(){ + return this._rightMargin; + }, + setRightMargin: function(margin){ + this._rightMargin = margin; + }, + + getTopMargin: function(){ + return this._topMargin; + }, + setTopMargin: function(margin){ + this._topMargin = margin; + }, + + getBottomMargin: function(){ + return this._bottomMargin; + }, + setBottomMargin: function(margin){ + this._bottomMargin = margin; + }, + + //size & + getSize: function(){ + return this.getOwner().getContentSize(); + }, + setSize: function(size){ + var parent = this._getOwnerParent(); + if (parent != null) { + var ownerSize = size, parentSize = parent.getContentSize(); + + if (parentSize.width != 0) + this._percentWidth = ownerSize.width / parentSize.width; + else { + this._percentWidth = 0; + if (this._usingPercentWidth) + ownerSize.width = 0; } - switch (pType) - { - case ccui.LayoutComponent_PositionType.Position: - this.getOwner().setPosition(basePoint); - this._relativePosition = inversePoint; - if (parentSize.width != 0 && parentSize.height != 0) - { - this._percentPosition = cc.p(this._relativePosition.x / parentSize.width, this._relativePosition.y / parentSize.height); - } - else - { - this._percentPosition = cc.p(0,0); - } - break; - case ccui.LayoutComponent_PositionType.RelativePosition: - this.getOwner().setPosition(inversePoint); - this._relativePosition = basePoint; - if (parentSize.width != 0 && parentSize.height != 0) - { - this._percentPosition = cc.p(this._relativePosition.x / parentSize.width, this._relativePosition.y / parentSize.height); - } - else - { - this._percentPosition = cc.p(0,0); - } - break; - case ccui.LayoutComponent_PositionType.PreRelativePosition: - this.getOwner().setPosition(inversePoint); - this._relativePosition = basePoint; - break; - case ccui.LayoutComponent_PositionType.PreRelativePositionEnable: - this.getOwner().setPosition(inversePoint); - this._relativePosition = basePoint; - break; - default: - break; + if (parentSize.height != 0) + this._percentHeight = ownerSize.height / parentSize.height; + else { + this._percentHeight = 0; + if (this._usingPercentHeight) + ownerSize.height = 0; } + + this._owner.setContentSize(ownerSize); + + this._refreshHorizontalMargin(); + this._refreshVerticalMargin(); } else - { - switch (pType) - { - case ccui.LayoutComponent_PositionType.Position: - this.getOwner().setPosition(basePoint); - if (this._referencePoint == ccui.LayoutComponent_ReferencePoint.BOTTOM_LEFT) - { - this._relativePosition = basePoint; - } - break; - case ccui.LayoutComponent_PositionType.RelativePosition: - this._relativePosition = basePoint; - break; - case ccui.LayoutComponent_PositionType.PreRelativePosition: - this._percentPosition = basePoint; - break; - default: - break; + this._owner.setContentSize(size); + }, + + isPercentWidthEnabled: function(){ + return this._usingPercentWidth; + }, + setPercentWidthEnabled: function(isUsed){ + this._usingPercentWidth = isUsed; + if (this._usingPercentWidth) + this._usingStretchWidth = false; + }, + + getSizeWidth: function(){ + return this._owner.width; + }, + setSizeWidth: function(width){ + var ownerSize = this._owner.getContentSize(); + ownerSize.width = width; + + var parent = this._getOwnerParent(); + if (parent != null) { + var parentSize = parent.getContentSize(); + if (parentSize.width != 0) + this._percentWidth = ownerSize.width / parentSize.width; + else { + this._percentWidth = 0; + if (this._usingPercentWidth) + ownerSize.width = 0; } + this._owner.setContentSize(ownerSize); + this._refreshHorizontalMargin(); + } else + this._owner.setContentSize(ownerSize); + }, + + getPercentWidth: function(){ + return this._percentWidth; + }, + setPercentWidth: function(percentWidth){ + this._percentWidth = percentWidth; + + var parent = this._getOwnerParent(); + if (parent != null) { + var ownerSize = this._owner.getContentSize(); + ownerSize.width = parent.width * this._percentWidth; + this._owner.setContentSize(ownerSize); + this._refreshHorizontalMargin(); } }, - getOwnerContentSize: function(){ - return this.getOwner().getContentSize(); + isPercentHeightEnabled: function(){ + return this._usingPercentHeight; }, - setOwnerContentSize: function(percent){ - this.RefreshLayoutSize(ccui.LayoutComponent_SizeType.Size, percent); + setPercentHeightEnabled: function(isUsed){ + this._usingPercentHeight = isUsed; + if (this._usingPercentHeight) + this._usingStretchHeight = false; }, - getPercentContentSize: function(){ - return this._percentContentSize; + getSizeHeight: function(){ + return this._owner.height; }, - setPercentContentSize: function(percent){ - this.RefreshLayoutSize(ccui.LayoutComponent_SizeType.PreSize, percent); + setSizeHeight: function(height){ + var ownerSize = this._owner.getContentSize(); + ownerSize.height = height; + + var parent = this._getOwnerParent(); + if (parent != null) { + var parentSize = parent.getContentSize(); + if (parentSize.height != 0) + this._percentHeight = ownerSize.height / parentSize.height; + else { + this._percentHeight = 0; + if (this._usingPercentHeight) + ownerSize.height = 0; + } + this._owner.setContentSize(ownerSize); + this._refreshVerticalMargin(); + } + else + this._owner.setContentSize(ownerSize); }, - isUsingPercentContentSize: function(){ - return this._usingPercentContentSize; + getPercentHeight: function(){ + return this._percentHeight; }, - setUsingPercentContentSize: function(flag){ - this._usingPercentContentSize = flag; - this.RefreshLayoutSize(ccui.LayoutComponent_SizeType.PreSizeEnable, cc.p(0,0)); + setPercentHeight: function(percentHeight){ + this._percentHeight = percentHeight; + + var parent = this._getOwnerParent(); + if (parent != null) { + var ownerSize = this._owner.getContentSize(); + ownerSize.height = parent.height * this._percentHeight; + this._owner.setContentSize(ownerSize); + this._refreshVerticalMargin(); + } }, - RefreshLayoutSize: function(sType, size){ - var parentNode = this.getOwner().getParent(); - if (parentNode != null && this._actived) - { - var parentSize = parentNode.getContentSize(); + isStretchWidthEnabled: function(){ + return this._usingStretchWidth; + }, + setStretchWidthEnabled: function(isUsed){ + this._usingStretchWidth = isUsed; + if (this._usingStretchWidth) + this._usingPercentWidth = false; + }, - switch (sType) - { - case ccui.LayoutComponent_SizeType.Size: - if (parentSize.width != 0 && parentSize.height != 0) - { - this._percentContentSize = cc.p(size.x/parentSize.width,size.y/parentSize.height); - } - else - { - this._percentContentSize = cc.p(0,0); + isStretchHeightEnabled: function(){ + return this._usingStretchHeight; + }, + setStretchHeightEnabled: function(isUsed){ + this._usingStretchHeight = isUsed; + if (this._usingStretchHeight) + this._usingPercentHeight = false; + }, + + setActiveEnabled: function(enable){ + this._actived = enable; + }, + refreshLayout: function(){ + var parent = this._getOwnerParent(); + if (parent == null) + return; + + var parentSize = parent.getContentSize(); + var ownerAnchor = this._owner.getAnchorPoint(), ownerSize = this._owner.getContentSize(); + var ownerPosition = this._owner.getPosition(); + + switch (this._horizontalEdge) { + case ccui.LayoutComponent.horizontalEdge.NONE: + if (this._usingStretchWidth){ + ownerSize.width = parentSize.width * this._percentWidth; + ownerPosition.x = this._leftMargin + ownerAnchor.x * ownerSize.width; + } else { + if (this._usingPositionPercentX) + ownerPosition.x = parentSize.width * this._positionPercentX; + if (this._usingPercentWidth) + ownerSize.width = parentSize.width * this._percentWidth; } - this.getOwner().setContentSize(cc.size(size.x,size.y)); break; - case ccui.LayoutComponent_SizeType.PreSize: - cc.p_percentContentSize = size; - if (this._usingPercentContentSize) - { - this.getOwner().setContentSize(cc.size(size.x*parentSize.width,size.y*parentSize.height)); - } + case ccui.LayoutComponent.horizontalEdge.LEFT: + if (this._usingPercentWidth || this._usingStretchWidth) + ownerSize.width = parentSize.width * this._percentWidth; + ownerPosition.x = this._leftMargin + ownerAnchor.x * ownerSize.width; break; - case ccui.LayoutComponent_SizeType.PreSizeEnable: - if (this._usingPercentContentSize) - { - var baseSize = this.getOwner().getContentSize(); - if (parentSize.width != 0) - { - this._percentContentSize.x = baseSize.width/parentSize.width; - } - else - { - this._percentContentSize.x = 0; - baseSize.width = 0; - } - - if (parentSize.height != 0) - { - this._percentContentSize.y = baseSize.height/parentSize.height; - } - else - { - this._percentContentSize.y = 0; - baseSize.height = 0; - } - - this.getOwner().setContentSize(baseSize); - } + case ccui.LayoutComponent.horizontalEdge.RIGHT: + if (this._usingPercentWidth || this._usingStretchWidth) + ownerSize.width = parentSize.width * this._percentWidth; + ownerPosition.x = parentSize.width - (this._rightMargin + (1 - ownerAnchor.x) * ownerSize.width); + break; + case ccui.LayoutComponent.horizontalEdge.CENTER: + if (this._usingPercentWidth || this._usingStretchWidth){ + ownerSize.width = parentSize.width - this._leftMargin - this._rightMargin; + if (ownerSize.width < 0) + ownerSize.width = 0; + ownerPosition.x = this._leftMargin + ownerAnchor.x * ownerSize.width; + } else + ownerPosition.x = parentSize.width * this._positionPercentX; break; default: break; - } } - else - { - switch (sType) - { - case ccui.LayoutComponent_SizeType.Size: - this.getOwner().setContentSize(cc.size(size.x,size.y)); + + switch (this._verticalEdge) { + case ccui.LayoutComponent.verticalEdge.NONE: + if (this._usingStretchHeight){ + ownerSize.height = parentSize.height * this._percentHeight; + ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; + } else { + if (this._usingPositionPercentY) + ownerPosition.y = parentSize.height * this._positionPercentY; + if (this._usingPercentHeight) + ownerSize.height = parentSize.height * this._percentHeight; + } break; - case ccui.LayoutComponent_SizeType.PreSize: - this._percentContentSize = size; + case ccui.LayoutComponent.verticalEdge.BOTTOM: + if (this._usingPercentHeight || this._usingStretchHeight) + ownerSize.height = parentSize.height * this._percentHeight; + ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; + break; + case ccui.LayoutComponent.verticalEdge.TOP: + if (this._usingPercentHeight || this._usingStretchHeight) + ownerSize.height = parentSize.height * this._percentHeight; + ownerPosition.y = parentSize.height - (this._topMargin + (1 - ownerAnchor.y) * ownerSize.height); + break; + case ccui.LayoutComponent.verticalEdge.CENTER: + if (this._usingPercentHeight || this._usingStretchHeight) { + ownerSize.height = parentSize.height - this._topMargin - this._bottomMargin; + if (ownerSize.height < 0) + ownerSize.height = 0; + ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; + } else + ownerPosition.y = parentSize.height* this._positionPercentY; break; default: break; - } } + + this._owner.setPosition(ownerPosition); + this._owner.setContentSize(ownerSize); + + ccui.helper.doLayout(this._owner); }, - SetActiveEnable: function(enable){ - this._actived = enable; + + _getOwnerParent: function(){ + return this._owner ? this._owner.getParent() : null; + }, + _refreshHorizontalMargin: function(){ + var parent = this._getOwnerParent(); + if (parent == null) + return; + + var ownerPoint = this._owner.getPosition(), ownerAnchor = this._owner.getAnchorPoint(); + var ownerSize = this._owner.getContentSize(), parentSize = parent.getContentSize(); + + this._leftMargin = ownerPoint.x - ownerAnchor.x * ownerSize.width; + this._rightMargin = parentSize.width - (ownerPoint.x + (1 - ownerAnchor.x) * ownerSize.width); + }, + _refreshVerticalMargin: function(){ + var parent = this._getOwnerParent(); + if (parent == null) + return; + + var ownerPoint = this._owner.getPosition(), ownerAnchor = this._owner.getAnchorPoint(); + var ownerSize = this._owner.getContentSize(), parentSize = parent.getContentSize(); + + this._bottomMargin = ownerPoint.y - ownerAnchor.y * ownerSize.height; + this._topMargin = parentSize.height - (ownerPoint.y + (1 - ownerAnchor.y) * ownerSize.height); } +}); + +ccui.LayoutComponent.horizontalEdge = {NONE: 0, LEFT: 1, RIGHT: 2, CENTER: 3}; +ccui.LayoutComponent.verticalEdge = {NONE: 0, BOTTOM: 1, TOP: 2, CENTER: 3}; -}); \ No newline at end of file +ccui.LayoutComponent.NAME= "__ui_layout"; +ccui.LayoutComponent.bindLayoutComponent = function(node){ + var layout = node.getComponent(ccui.LayoutComponent.NAME); + if (layout != null) + return layout; + + layout = new ccui.LayoutComponent(); + if (layout && layout.init()){ + node.addComponent(layout); + return layout; + } + return null; +}; \ No newline at end of file diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 73a5109681..802c0f65df 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -117,5 +117,19 @@ ccui.helper = { return res; } return null; - } + } , + + _activeLayout: false, + doLayout: function(rootNode){ + if(!this._activeLayout) + return; + var children = rootNode.getChildren(), node; + for(var i = 0, len = children.length;i < len; i++) { + node = children[i]; + var com = node.getComponent(ccui.LayoutComponent.NAME); + var parent = node.getParent(); + if (null != com && null != parent && com.refreshLayout) + com.refreshLayout(); + } + } }; From 5b7fb171dad4ed8348c9bf4588782b5f2424a161 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 16:59:54 +0800 Subject: [PATCH 1183/1564] Issue #1267: update UICheckBox.js --- extensions/ccui/uiwidgets/UICheckBox.js | 80 +++++++++++++++---------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index ab04b6827c..12694cd4c2 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -55,6 +55,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _frontCrossDisabledFileName: "", _className: "CheckBox", + _zoomScale: 0.1, + _backgroundTextureScaleX: 0.1, + _backgroundTextureScaleY: 0.1, + _backGroundBoxRendererAdaptDirty:true, _backGroundSelectedBoxRendererAdaptDirty:true, _frontCrossRendererAdaptDirty: true, @@ -139,7 +143,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGround: function (backGround, texType) { - if (!backGround) + if (!backGround || (this._backGroundFileName == backGround && this._backGroundTexType == texType)) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; @@ -194,7 +198,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGroundSelected: function (backGroundSelected, texType) { - if (!backGroundSelected) + if (!backGroundSelected || (this._backGroundSelectedFileName == backGroundSelected && this._backGroundSelectedTexType == texType)) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; @@ -240,7 +244,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureFrontCross: function (cross, texType) { - if (!cross) + if (!cross || (this._frontCrossFileName == cross && this._frontCrossTexType == texType)) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossFileName = cross; @@ -284,7 +288,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGroundDisabled: function (backGroundDisabled, texType) { - if (!backGroundDisabled) + if (!backGroundDisabled || (this._backGroundDisabledFileName == backGroundDisabled && this._backGroundDisabledTexType == texType)) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundDisabledFileName = backGroundDisabled; @@ -328,7 +332,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureFrontCrossDisabled: function (frontCrossDisabled, texType) { - if (!frontCrossDisabled) + if (!frontCrossDisabled || (this._frontCrossDisabledFileName == frontCrossDisabled && this._frontCrossDisabledTexType == texType)) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossDisabledFileName = frontCrossDisabled; @@ -371,28 +375,50 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundSelectedBoxRenderer.setVisible(false); this._backGroundBoxDisabledRenderer.setVisible(false); this._frontCrossDisabledRenderer.setVisible(false); - if (this._isSelected){ + + this._backGroundBoxRenderer.setScale(this._backgroundTextureScaleX, this._backgroundTextureScaleY); + this._frontCrossRenderer.setScale(this._backgroundTextureScaleX, this._backgroundTextureScaleY); + + if (this._isSelected) this._frontCrossRenderer.setVisible(true); - } }, _onPressStateChangedToPressed: function () { - this._backGroundBoxRenderer.setVisible(false); - this._backGroundSelectedBoxRenderer.setVisible(true); - this._backGroundBoxDisabledRenderer.setVisible(false); - this._frontCrossDisabledRenderer.setVisible(false); + if (!this._backGroundSelectedFileName){ + this._backGroundBoxRenderer.setScale(this._backgroundTextureScaleX + this._zoomScale, this._backgroundTextureScaleY + this._zoomScale); + this._frontCrossRenderer.setScale(this._backgroundTextureScaleX + this._zoomScale, this._backgroundTextureScaleY + this._zoomScale); + }else{ + this._backGroundBoxRenderer.setVisible(false); + this._backGroundSelectedBoxRenderer.setVisible(true); + this._backGroundBoxDisabledRenderer.setVisible(false); + this._frontCrossDisabledRenderer.setVisible(false); + } }, _onPressStateChangedToDisabled: function () { - this._backGroundBoxRenderer.setVisible(false); + if (this._backGroundDisabledFileName && this._frontCrossDisabledFileName){ + this._backGroundBoxRenderer.setVisible(false); + this._backGroundBoxDisabledRenderer.setVisible(true); + } + this._backGroundSelectedBoxRenderer.setVisible(false); - this._backGroundBoxDisabledRenderer.setVisible(true); this._frontCrossRenderer.setVisible(false); + this._backGroundBoxRenderer.setScale(this._backgroundTextureScaleX, this._backgroundTextureScaleY); + this._frontCrossRenderer.setScale(this._backgroundTextureScaleX, this._backgroundTextureScaleY); + if (this._isSelected) { this._frontCrossDisabledRenderer.setVisible(true); } }, + setZoomScale: function(scale){ + this._zoomScale = scale; + }, + + getZoomScale: function(){ + return this._zoomScale; + }, + /** * @deprecated since v3.1, please use setSelected. */ @@ -483,22 +509,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ return this._backGroundBoxRenderer.getContentSize(); }, - _updateFlippedX: function () { - this._backGroundBoxRenderer.setFlippedX(this._flippedX); - this._backGroundSelectedBoxRenderer.setFlippedX(this._flippedX); - this._frontCrossRenderer.setFlippedX(this._flippedX); - this._backGroundBoxDisabledRenderer.setFlippedX(this._flippedX); - this._frontCrossDisabledRenderer.setFlippedX(this._flippedX); - }, - - _updateFlippedY: function () { - this._backGroundBoxRenderer.setFlippedY(this._flippedY); - this._backGroundSelectedBoxRenderer.setFlippedY(this._flippedY); - this._frontCrossRenderer.setFlippedY(this._flippedY); - this._backGroundBoxDisabledRenderer.setFlippedY(this._flippedY); - this._frontCrossDisabledRenderer.setFlippedY(this._flippedY); - }, - _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); this._backGroundBoxRendererAdaptDirty = true; @@ -519,16 +529,20 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ _backGroundTextureScaleChangedWithSize: function () { var locRenderer = this._backGroundBoxRenderer, locContentSize = this._contentSize; - if (this._ignoreSize) + if (this._ignoreSize){ locRenderer.setScale(1.0); - else{ + this._backgroundTextureScaleX = this._backgroundTextureScaleY = 1; + }else{ var textureSize = locRenderer.getContentSize(); if (textureSize.width <= 0.0 || textureSize.height <= 0.0){ locRenderer.setScale(1.0); + this._backgroundTextureScaleX = this._backgroundTextureScaleY = 1; return; } var scaleX = locContentSize.width / textureSize.width; var scaleY = locContentSize.height / textureSize.height; + this._backgroundTextureScaleX = scaleX; + this._backgroundTextureScaleY = scaleY; locRenderer.setScaleX(scaleX); locRenderer.setScaleY(scaleY); } @@ -630,6 +644,10 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this.setSelected(uiCheckBox._isSelected); this._checkBoxEventListener = uiCheckBox._checkBoxEventListener; this._checkBoxEventSelector = uiCheckBox._checkBoxEventSelector; + this._ccEventCallback = uiCheckBox._ccEventCallback; + this._zoomScale = uiCheckBox._zoomScale; + this._backgroundTextureScaleX = uiCheckBox._backgroundTextureScaleX; + this._backgroundTextureScaleY = uiCheckBox._backgroundTextureScaleY; } }, From f4433a4d4f6378e44af8f923f054f1950c3a3147 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 17:02:05 +0800 Subject: [PATCH 1184/1564] Issue #1267: remove _updateFlipped --- extensions/ccui/uiwidgets/UIButton.js | 40 ------------------------- extensions/ccui/uiwidgets/UICheckBox.js | 20 ------------- 2 files changed, 60 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 419e532f4f..8cd10b38c7 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -258,8 +258,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ self._findLayout(); self._normalTextureSize = self._buttonNormalRenderer.getContentSize(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._buttonNormalRenderer.setColor(self.getColor()); @@ -293,8 +291,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._updateContentSizeWithTextureSize(this._normalTextureSize); this._normalTextureSize = this._buttonNormalRenderer.getContentSize(); - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -320,8 +316,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ self._findLayout(); self._pressedTextureSize = self._buttonClickedRenderer.getContentSize(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._pressedTextureLoaded = true; @@ -347,8 +341,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ clickedRenderer.setCapInsets(this._capInsetsPressed); this._pressedTextureSize = this._buttonClickedRenderer.getContentSize(); - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -375,8 +367,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ self._findLayout(); self._disabledTextureSize = self._buttonDisableRenderer.getContentSize(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._disabledTextureLoaded = true; @@ -402,8 +392,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ disabledRenderer.setCapInsets(this._capInsetsDisabled); this._disabledTextureSize = this._buttonDisableRenderer.getContentSize(); - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -666,34 +654,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.setContentSize(this.getVirtualRendererSize()); }, - _updateFlippedX: function () { - var flip = this._flippedX ? -1.0 : 1.0; - this._titleRenderer.setScaleX(flip); - if (this._scale9Enabled) { - this._buttonNormalRenderer.setScaleX(flip); - this._buttonClickedRenderer.setScaleX(flip); - this._buttonDisableRenderer.setScaleX(flip); - } else { - this._buttonNormalRenderer.setFlippedX(this._flippedX); - this._buttonClickedRenderer.setFlippedX(this._flippedX); - this._buttonDisableRenderer.setFlippedX(this._flippedX); - } - }, - - _updateFlippedY: function () { - var flip = this._flippedY ? -1.0 : 1.0; - this._titleRenderer.setScaleY(flip); - if (this._scale9Enabled) { - this._buttonNormalRenderer.setScaleY(flip); - this._buttonClickedRenderer.setScaleY(flip); - this._buttonDisableRenderer.setScaleY(flip); - } else { - this._buttonNormalRenderer.setFlippedY(this._flippedY); - this._buttonClickedRenderer.setFlippedY(this._flippedY); - this._buttonDisableRenderer.setFlippedY(this._flippedY); - } - }, - _updateTexturesRGBA: function(){ this._buttonNormalRenderer.setColor(this.getColor()); this._buttonClickedRenderer.setColor(this.getColor()); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 12694cd4c2..9a027bc98e 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -156,8 +156,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ bgBoxRenderer.addEventListener("load", function(){ self._findLayout(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._updateContentSizeWithTextureSize(self._backGroundBoxRenderer.getContentSize()); self._backGroundBoxRendererAdaptDirty = true; @@ -183,8 +181,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); }, this); } - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -210,8 +206,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundSelectedBoxRenderer.addEventListener("load", function(){ self._findLayout(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._backGroundSelectedBoxRendererAdaptDirty = true; }); @@ -230,8 +224,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -255,8 +247,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossRenderer.addEventListener("load", function(){ self._findLayout(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._frontCrossRendererAdaptDirty = true; }); @@ -274,8 +264,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -299,8 +287,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundBoxDisabledRenderer.addEventListener("load", function(){ self._findLayout(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._backGroundBoxDisabledRendererAdaptDirty = true; }); @@ -318,8 +304,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -343,8 +327,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledRenderer.addEventListener("load", function(){ self._findLayout(); - self._updateFlippedX(); - self._updateFlippedY(); self._updateChildrenDisplayedRGBA(); self._frontCrossDisabledRendererAdaptDirty = true; }); @@ -362,8 +344,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ default: break; } - this._updateFlippedX(); - this._updateFlippedY(); this._updateChildrenDisplayedRGBA(); From 82f0cd69e005009af259c86d850a59c05ec87dd7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 17:23:51 +0800 Subject: [PATCH 1185/1564] Issue #1267: update UIImageView.js --- extensions/ccui/uiwidgets/UIImageView.js | 52 +++++++++--------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index dba1462977..a951d07ed0 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -74,6 +74,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ }, _initRenderer: function () { + //todo create Scale9Sprite and setScale9Enabled(false) this._imageRenderer = new cc.Sprite(); this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1); }, @@ -88,6 +89,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexture: function (fileName, texType) { + //todo use this code when _initRenderer use Scale9Sprite + //if (!fileName || (this._textureFile == fileName && this._imageTexType == texType)) { if (!fileName) { return; } @@ -97,6 +100,21 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._imageTexType = texType; var imageRenderer = self._imageRenderer; + if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ + imageRenderer.addEventListener("load", function(){ + self._findLayout(); + + self._imageTextureSize = imageRenderer.getContentSize(); + + self._updateChildrenDisplayedRGBA(); + + self._updateContentSizeWithTextureSize(self._imageTextureSize); + if(self._scale9Enabled) + self.setCapInsets(self._capInsets); + self._imageRendererAdaptDirty = true; + }); + } + switch (self._imageTexType) { case ccui.Widget.LOCAL_TEXTURE: if(self._scale9Enabled){ @@ -120,26 +138,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ break; } - if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ - imageRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._imageTextureSize = imageRenderer.getContentSize(); - self._updateFlippedX(); - self._updateFlippedY(); - - self._updateChildrenDisplayedRGBA(); - - self._updateContentSizeWithTextureSize(self._imageTextureSize); - if(self._scale9Enabled) - self.setCapInsets(self._capInsets); - self._imageRendererAdaptDirty = true; - }); - } - self._imageTextureSize = imageRenderer.getContentSize(); - self._updateFlippedX(); - self._updateFlippedY(); this._updateChildrenDisplayedRGBA(); @@ -156,25 +155,12 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._imageRenderer.setTextureRect(rect); }, - _updateFlippedX: function () { - if (this._scale9Enabled) - this._imageRenderer.setScaleX(this._flippedX ? -1 : 1); - else - this._imageRenderer.setFlippedX(this._flippedX); - }, - - _updateFlippedY: function () { - if (this._scale9Enabled) - this._imageRenderer.setScaleY(this._flippedY ? -1 : 1); - else - this._imageRenderer.setFlippedY(this._flippedY); - }, - /** * Sets if button is using scale9 renderer. * @param {Boolean} able */ setScale9Enabled: function (able) { + //todo setScale9Enabled if (this._scale9Enabled == able) return; From 0d7366355c9affe440c4cf8bc894f53971fbacb1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 17:38:57 +0800 Subject: [PATCH 1186/1564] Issue #1267: update UILoadingBar.js --- extensions/ccui/uiwidgets/UILoadingBar.js | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index bf7bc314f7..ed28c83720 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -68,6 +68,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ }, _initRenderer: function () { + //todo use Scale9Sprite this._barRenderer = new cc.Sprite(); this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1); this._barRenderer.setAnchorPoint(0.0, 0.5); @@ -84,13 +85,13 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._direction = dir; switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: - this._barRenderer.setAnchorPoint(0.0, 0.5); + this._barRenderer.setAnchorPoint(0, 0.5); this._barRenderer.setPosition(0, this._contentSize.height*0.5); if (!this._scale9Enabled) this._barRenderer.setFlippedX(false); break; case ccui.LoadingBar.TYPE_RIGHT: - this._barRenderer.setAnchorPoint(1.0, 0.5); + this._barRenderer.setAnchorPoint(1, 0.5); this._barRenderer.setPosition(this._totalLength,this._contentSize.height*0.5); if (!this._scale9Enabled) this._barRenderer.setFlippedX(true); @@ -151,20 +152,10 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ switch (this._renderBarTexType) { case ccui.Widget.LOCAL_TEXTURE: - if (this._scale9Enabled){ - barRenderer.initWithFile(texture); - barRenderer.setCapInsets(this._capInsets); - } else - //SetTexture cannot load resource - barRenderer.initWithFile(texture); + barRenderer.initWithFile(texture); break; case ccui.Widget.PLIST_TEXTURE: - if (this._scale9Enabled) { - barRenderer.initWithSpriteFrameName(texture); - barRenderer.setCapInsets(this._capInsets); - } else - //SetTexture cannot load resource - barRenderer.initWithSpriteFrameName(texture); + barRenderer.initWithSpriteFrameName(texture); break; default: break; @@ -176,16 +167,19 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ switch (this._direction) { case ccui.LoadingBar.TYPE_LEFT: - barRenderer.setAnchorPoint(0.0,0.5); + barRenderer.setAnchorPoint(0,0.5); if (!this._scale9Enabled) barRenderer.setFlippedX(false); break; case ccui.LoadingBar.TYPE_RIGHT: - barRenderer.setAnchorPoint(1.0,0.5); + barRenderer.setAnchorPoint(1,0.5); if (!this._scale9Enabled) barRenderer.setFlippedX(true); break; } + if (this._scale9Enabled) + barRenderer.setCapInsets(this._capInsets); + this._updateChildrenDisplayedRGBA(); this._barRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._barRendererTextureSize); @@ -197,6 +191,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ * @param {Boolean} enabled */ setScale9Enabled: function (enabled) { + //todo use setScale9Enabled if (this._scale9Enabled == enabled) return; this._scale9Enabled = enabled; @@ -254,7 +249,11 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ * @param {number} percent percent value from 1 to 100. */ setPercent: function (percent) { - if (percent < 0 || percent > 100) + if(percent > 100) + percent = 100; + if(percent < 0) + percent = 0; + if (percent == this._percent) return; this._percent = percent; if (this._totalLength <= 0) @@ -341,7 +340,6 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ _barRendererScaleChangedWithSize: function () { var locBarRender = this._barRenderer, locContentSize = this._contentSize; if(this._unifySize){ - //_barRenderer->setPreferredSize(_contentSize); this._totalLength = this._contentSize.width; this.setPercent(this._percent); }else if (this._ignoreSize) { From f768e9e26d86b4cac99eb6e6df168270e9cb8e2f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 12 Jan 2015 17:45:55 +0800 Subject: [PATCH 1187/1564] Issue cocos2d/cocos2d-js/#1267: ccui.Layout has been migrated. --- extensions/ccui/layouts/UILayout.js | 75 ++++------ extensions/ccui/layouts/UILayoutComponent.js | 140 +++++++++---------- 2 files changed, 101 insertions(+), 114 deletions(-) diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 7bd7f771a0..4a6273aeac 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -516,34 +516,19 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._backGroundImageFileName = fileName; this._bgImageTexType = texType; var locBackgroundImage = this._backGroundImage; - if (this._backGroundScale9Enabled) { - var bgiScale9 = locBackgroundImage; - switch (this._bgImageTexType) { - case ccui.Widget.LOCAL_TEXTURE: - bgiScale9.initWithFile(fileName); - break; - case ccui.Widget.PLIST_TEXTURE: - bgiScale9.initWithSpriteFrameName(fileName); - break; - default: - break; - } - bgiScale9.setPreferredSize(this._contentSize); - } else { - var sprite = locBackgroundImage; - switch (this._bgImageTexType){ - case ccui.Widget.LOCAL_TEXTURE: - //SetTexture cannot load resource - sprite.initWithFile(fileName); - break; - case ccui.Widget.PLIST_TEXTURE: - //SetTexture cannot load resource - sprite.initWithSpriteFrameName(fileName); - break; - default: - break; - } + switch (this._bgImageTexType) { + case ccui.Widget.LOCAL_TEXTURE: + locBackgroundImage.initWithFile(fileName); + break; + case ccui.Widget.PLIST_TEXTURE: + locBackgroundImage.initWithSpriteFrameName(fileName); + break; + default: + break; } + if (this._backGroundScale9Enabled) + locBackgroundImage.setPreferredSize(this._contentSize); + this._backGroundImageTextureSize = locBackgroundImage.getContentSize(); locBackgroundImage.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); this._updateBackGroundImageColor(); @@ -597,13 +582,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _addBackGroundImage: function () { + var contentSize = this._contentSize; if (this._backGroundScale9Enabled) { this._backGroundImage = new ccui.Scale9Sprite(); - this._backGroundImage.setPreferredSize(this._contentSize); + this._backGroundImage.setPreferredSize(contentSize); } else this._backGroundImage = new cc.Sprite(); this.addProtectedChild(this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1); - this._backGroundImage.setPosition(this._contentSize.width / 2.0, this._contentSize.height / 2.0); + this._backGroundImage.setPosition(contentSize.width * 0.5, contentSize.height * 0.5); }, /** @@ -863,7 +849,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, /** - * request do layout, it will do layout at visit calls + * request to refresh widget layout, it will do layout at visit calls */ requestDoLayout: function () { this._doLayoutDirty = true; @@ -1203,22 +1189,15 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } } else return this._getNextFocusedWidget(direction, nextWidget); - } else { - if (current instanceof ccui.Layout) - return current; - else - return this._focusedWidget; - } + } else + return (current instanceof ccui.Layout) ? current : this._focusedWidget; } else{ if (this._isLastWidgetInContainer(current, direction)){ if (this._isWidgetAncestorSupportLoopFocus(this, direction)) - return this.findNextFocusedWidget(direction, this); - if (current instanceof ccui.Layout) - return current; - else - return this._focusedWidget; + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); + return (current instanceof ccui.Layout) ? current : this._focusedWidget; } else - return this.findNextFocusedWidget(direction, this); + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); } } }, @@ -1265,10 +1244,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } else { if (this._isLastWidgetInContainer(current, direction)) { if (this._isWidgetAncestorSupportLoopFocus(this, direction)) - return this.findNextFocusedWidget(direction, this); + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); return (current instanceof ccui.Layout) ? current : this._focusedWidget; } else - return this.findNextFocusedWidget(direction, this); + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); } } }, @@ -1464,6 +1443,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ this._isInterceptTouch = layout._isInterceptTouch; }, + /** + * force refresh widget layout + */ + forceDoLayout: function(){ + this.requestDoLayout(); + this._doLayout(); + }, + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_WEBGL) return new ccui.Layout.WebGLRenderCmd(this); diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index 14e40f5e86..73fbdff28b 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -43,7 +43,7 @@ ccui.LayoutComponent_SizeType = { //refactor since v3.3 ccui.LayoutComponent = cc.Component.extend({ - _horizontalEdge: 0, + _horizontalEdge: 0, _verticalEdge: 0, _leftMargin: 0, @@ -66,7 +66,7 @@ ccui.LayoutComponent = cc.Component.extend({ _usingPercentHeight: false, _actived: true, - ctor: function(){ + ctor: function () { this._name = ccui.LayoutComponent.NAME; }, @@ -82,34 +82,34 @@ ccui.LayoutComponent = cc.Component.extend({ return ret; }, - getPercentContentSize: function(){ + getPercentContentSize: function () { return cc.p(this._percentWidth, this._percentHeight); }, - setPercentContentSize: function(percent){ + setPercentContentSize: function (percent) { this.setPercentWidth(percent.x); this.setPercentHeight(percent.y); }, - setUsingPercentContentSize: function(isUsed){ + setUsingPercentContentSize: function (isUsed) { this._usingPercentWidth = this._usingPercentHeight = isUsed; }, //old - SetActiveEnable: function(enable){ + SetActiveEnable: function (enable) { this._actived = enable; }, //v3.3 - getUsingPercentContentSize: function(){ + getUsingPercentContentSize: function () { return this._usingPercentWidth && this._usingPercentHeight; }, //position & margin - getAnchorPosition: function(){ + getAnchorPosition: function () { return this._owner.getAnchorPoint(); }, - setAnchorPosition: function(point, y){ + setAnchorPosition: function (point, y) { var oldRect = this._owner.getBoundingBox(); this._owner.setAnchorPoint(point, y); var newRect = this._owner.getBoundingBox(); @@ -121,17 +121,17 @@ ccui.LayoutComponent = cc.Component.extend({ this.setPosition(ownerPosition); }, - getPosition: function(){ + getPosition: function () { return this._owner.getPosition(); }, - setPosition: function(position, y){ + setPosition: function (position, y) { var parent = this._getOwnerParent(), x; if (parent != null) { - if(y === undefined){ + if (y === undefined) { x = position.x; y = position.y; - }else + } else x = position; var parentSize = parent.getContentSize(); @@ -158,19 +158,19 @@ ccui.LayoutComponent = cc.Component.extend({ this._owner.setPosition(position, y); }, - isPositionPercentXEnabled: function(){ + isPositionPercentXEnabled: function () { return this._usingPositionPercentX; }, - setPositionPercentXEnabled: function(isUsed){ + setPositionPercentXEnabled: function (isUsed) { this._usingPositionPercentX = isUsed; if (this._usingPositionPercentX) this._horizontalEdge = ccui.LayoutComponent.horizontalEdge.NONE; }, - getPositionPercentX: function(){ + getPositionPercentX: function () { return this._positionPercentX; }, - setPositionPercentX: function(percentMargin){ + setPositionPercentX: function (percentMargin) { this._positionPercentX = percentMargin; var parent = this._getOwnerParent(); @@ -180,19 +180,19 @@ ccui.LayoutComponent = cc.Component.extend({ } }, - isPositionPercentYEnabled: function(){ + isPositionPercentYEnabled: function () { return this._usingPositionPercentY; }, - setPositionPercentYEnabled: function(isUsed){ + setPositionPercentYEnabled: function (isUsed) { this._usingPositionPercentY = isUsed; if (this._usingPositionPercentY) this._verticalEdge = ccui.LayoutComponent.verticalEdge.NONE; }, - getPositionPercentY: function(){ + getPositionPercentY: function () { return this._positionPercentY; }, - setPositionPercentY: function(percentMargin){ + setPositionPercentY: function (percentMargin) { this._positionPercentY = percentMargin; var parent = this._getOwnerParent(); @@ -202,10 +202,10 @@ ccui.LayoutComponent = cc.Component.extend({ } }, - getHorizontalEdge: function(){ + getHorizontalEdge: function () { return this._horizontalEdge; }, - setHorizontalEdge: function(hEdge){ + setHorizontalEdge: function (hEdge) { this._horizontalEdge = hEdge; if (this._horizontalEdge != cc.LayoutComponent.horizontalEdge.NONE) this._usingPositionPercentX = false; @@ -226,10 +226,10 @@ ccui.LayoutComponent = cc.Component.extend({ } }, - getVerticalEdge: function(){ + getVerticalEdge: function () { return this._verticalEdge; }, - setVerticalEdge: function(vEdge){ + setVerticalEdge: function (vEdge) { this._verticalEdge = vEdge; if (this._verticalEdge != ccui.LayoutComponent.verticalEdge.NONE) this._usingPositionPercentY = false; @@ -250,45 +250,45 @@ ccui.LayoutComponent = cc.Component.extend({ } }, - getLeftMargin: function(){ + getLeftMargin: function () { return this._leftMargin; }, - setLeftMargin: function(margin){ + setLeftMargin: function (margin) { this._leftMargin = margin; }, - getRightMargin: function(){ + getRightMargin: function () { return this._rightMargin; }, - setRightMargin: function(margin){ + setRightMargin: function (margin) { this._rightMargin = margin; }, - getTopMargin: function(){ + getTopMargin: function () { return this._topMargin; }, - setTopMargin: function(margin){ + setTopMargin: function (margin) { this._topMargin = margin; }, - getBottomMargin: function(){ + getBottomMargin: function () { return this._bottomMargin; }, - setBottomMargin: function(margin){ + setBottomMargin: function (margin) { this._bottomMargin = margin; }, //size & - getSize: function(){ + getSize: function () { return this.getOwner().getContentSize(); }, - setSize: function(size){ + setSize: function (size) { var parent = this._getOwnerParent(); if (parent != null) { var ownerSize = size, parentSize = parent.getContentSize(); if (parentSize.width != 0) - this._percentWidth = ownerSize.width / parentSize.width; + this._percentWidth = ownerSize.width / parentSize.width; else { this._percentWidth = 0; if (this._usingPercentWidth) @@ -312,19 +312,19 @@ ccui.LayoutComponent = cc.Component.extend({ this._owner.setContentSize(size); }, - isPercentWidthEnabled: function(){ + isPercentWidthEnabled: function () { return this._usingPercentWidth; }, - setPercentWidthEnabled: function(isUsed){ + setPercentWidthEnabled: function (isUsed) { this._usingPercentWidth = isUsed; if (this._usingPercentWidth) this._usingStretchWidth = false; }, - getSizeWidth: function(){ + getSizeWidth: function () { return this._owner.width; }, - setSizeWidth: function(width){ + setSizeWidth: function (width) { var ownerSize = this._owner.getContentSize(); ownerSize.width = width; @@ -344,10 +344,10 @@ ccui.LayoutComponent = cc.Component.extend({ this._owner.setContentSize(ownerSize); }, - getPercentWidth: function(){ + getPercentWidth: function () { return this._percentWidth; }, - setPercentWidth: function(percentWidth){ + setPercentWidth: function (percentWidth) { this._percentWidth = percentWidth; var parent = this._getOwnerParent(); @@ -359,19 +359,19 @@ ccui.LayoutComponent = cc.Component.extend({ } }, - isPercentHeightEnabled: function(){ + isPercentHeightEnabled: function () { return this._usingPercentHeight; }, - setPercentHeightEnabled: function(isUsed){ + setPercentHeightEnabled: function (isUsed) { this._usingPercentHeight = isUsed; if (this._usingPercentHeight) this._usingStretchHeight = false; }, - getSizeHeight: function(){ + getSizeHeight: function () { return this._owner.height; }, - setSizeHeight: function(height){ + setSizeHeight: function (height) { var ownerSize = this._owner.getContentSize(); ownerSize.height = height; @@ -392,10 +392,10 @@ ccui.LayoutComponent = cc.Component.extend({ this._owner.setContentSize(ownerSize); }, - getPercentHeight: function(){ + getPercentHeight: function () { return this._percentHeight; }, - setPercentHeight: function(percentHeight){ + setPercentHeight: function (percentHeight) { this._percentHeight = percentHeight; var parent = this._getOwnerParent(); @@ -407,39 +407,39 @@ ccui.LayoutComponent = cc.Component.extend({ } }, - isStretchWidthEnabled: function(){ + isStretchWidthEnabled: function () { return this._usingStretchWidth; }, - setStretchWidthEnabled: function(isUsed){ + setStretchWidthEnabled: function (isUsed) { this._usingStretchWidth = isUsed; if (this._usingStretchWidth) this._usingPercentWidth = false; }, - isStretchHeightEnabled: function(){ + isStretchHeightEnabled: function () { return this._usingStretchHeight; }, - setStretchHeightEnabled: function(isUsed){ + setStretchHeightEnabled: function (isUsed) { this._usingStretchHeight = isUsed; if (this._usingStretchHeight) this._usingPercentHeight = false; }, - setActiveEnabled: function(enable){ + setActiveEnabled: function (enable) { this._actived = enable; }, - refreshLayout: function(){ + refreshLayout: function () { var parent = this._getOwnerParent(); if (parent == null) return; - var parentSize = parent.getContentSize(); - var ownerAnchor = this._owner.getAnchorPoint(), ownerSize = this._owner.getContentSize(); - var ownerPosition = this._owner.getPosition(); + var parentSize = parent.getContentSize(), locOwner = this._owner; + var ownerAnchor = locOwner.getAnchorPoint(), ownerSize = locOwner.getContentSize(); + var ownerPosition = locOwner.getPosition(); switch (this._horizontalEdge) { case ccui.LayoutComponent.horizontalEdge.NONE: - if (this._usingStretchWidth){ + if (this._usingStretchWidth) { ownerSize.width = parentSize.width * this._percentWidth; ownerPosition.x = this._leftMargin + ownerAnchor.x * ownerSize.width; } else { @@ -460,7 +460,7 @@ ccui.LayoutComponent = cc.Component.extend({ ownerPosition.x = parentSize.width - (this._rightMargin + (1 - ownerAnchor.x) * ownerSize.width); break; case ccui.LayoutComponent.horizontalEdge.CENTER: - if (this._usingPercentWidth || this._usingStretchWidth){ + if (this._usingPercentWidth || this._usingStretchWidth) { ownerSize.width = parentSize.width - this._leftMargin - this._rightMargin; if (ownerSize.width < 0) ownerSize.width = 0; @@ -474,7 +474,7 @@ ccui.LayoutComponent = cc.Component.extend({ switch (this._verticalEdge) { case ccui.LayoutComponent.verticalEdge.NONE: - if (this._usingStretchHeight){ + if (this._usingStretchHeight) { ownerSize.height = parentSize.height * this._percentHeight; ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; } else { @@ -501,22 +501,22 @@ ccui.LayoutComponent = cc.Component.extend({ ownerSize.height = 0; ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; } else - ownerPosition.y = parentSize.height* this._positionPercentY; + ownerPosition.y = parentSize.height * this._positionPercentY; break; default: break; } - this._owner.setPosition(ownerPosition); - this._owner.setContentSize(ownerSize); + locOwner.setPosition(ownerPosition); + locOwner.setContentSize(ownerSize); - ccui.helper.doLayout(this._owner); + ccui.helper.doLayout(locOwner); }, - _getOwnerParent: function(){ + _getOwnerParent: function () { return this._owner ? this._owner.getParent() : null; }, - _refreshHorizontalMargin: function(){ + _refreshHorizontalMargin: function () { var parent = this._getOwnerParent(); if (parent == null) return; @@ -527,7 +527,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._leftMargin = ownerPoint.x - ownerAnchor.x * ownerSize.width; this._rightMargin = parentSize.width - (ownerPoint.x + (1 - ownerAnchor.x) * ownerSize.width); }, - _refreshVerticalMargin: function(){ + _refreshVerticalMargin: function () { var parent = this._getOwnerParent(); if (parent == null) return; @@ -543,14 +543,14 @@ ccui.LayoutComponent = cc.Component.extend({ ccui.LayoutComponent.horizontalEdge = {NONE: 0, LEFT: 1, RIGHT: 2, CENTER: 3}; ccui.LayoutComponent.verticalEdge = {NONE: 0, BOTTOM: 1, TOP: 2, CENTER: 3}; -ccui.LayoutComponent.NAME= "__ui_layout"; -ccui.LayoutComponent.bindLayoutComponent = function(node){ +ccui.LayoutComponent.NAME = "__ui_layout"; +ccui.LayoutComponent.bindLayoutComponent = function (node) { var layout = node.getComponent(ccui.LayoutComponent.NAME); if (layout != null) return layout; layout = new ccui.LayoutComponent(); - if (layout && layout.init()){ + if (layout && layout.init()) { node.addComponent(layout); return layout; } From 1fdc125bfe7167b647980d1a262b99d0b9e8379a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 18:04:35 +0800 Subject: [PATCH 1188/1564] Issue #1267: update UISlider.js --- extensions/ccui/uiwidgets/UISlider.js | 56 ++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 0b7756a1a6..48f725ac91 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -60,6 +60,11 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _className: "Slider", _barRendererAdaptDirty: true, _progressBarRendererDirty: true, + _unifySize: false, + + _sliderBallNormalTextureScaleX: 1, + _sliderBallNormalTextureScaleY: 1, + _eventCallback: null, /** * allocates and initializes a UISlider. @@ -85,6 +90,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _initRenderer: function () { + //todo use Scale9Sprite this._barRenderer = new cc.Sprite(); this._progressBarRenderer = new cc.Sprite(); this._progressBarRenderer.setAnchorPoint(0.0, 0.5); @@ -202,6 +208,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * @param {Boolean} able */ setScale9Enabled: function (able) { + //todo use setScale9Enabled if (this._scale9Enabled == able) return; @@ -531,6 +538,13 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ else this._sliderEventSelector(this, ccui.Slider.EVENT_PERCENT_CHANGED); } + //todo check here + if (this._eventCallback){ + this._eventCallback(this, 0/*EventType::ON_PERCENTAGE_CHANGED*/); + } + if (this._ccEventCallback){ + this._ccEventCallback(this, 0/*static_cast(EventType::ON_PERCENTAGE_CHANGED)*/); + } }, /** @@ -577,11 +591,13 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _barRendererScaleChangedWithSize: function () { - if (this._ignoreSize) { + if (this._unifySize){ + this._barLength = this._contentSize.width; + this._barRenderer.setPreferredSize(this._contentSize); + }else if(this._ignoreSize) { this._barRenderer.setScale(1.0); this._barLength = this._contentSize.width; - } - else { + }else { this._barLength = this._contentSize.width; if (this._scale9Enabled) { this._barRenderer.setPreferredSize(this._contentSize); @@ -603,7 +619,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ }, _progressBarRendererScaleChangedWithSize: function () { - if (this._ignoreSize) { + if(this._unifySize){ + this._progressBarRenderer.setPreferredSize(this._contentSize); + }else if(this._ignoreSize) { if (!this._scale9Enabled) { var ptextureSize = this._progressBarTextureSize; var pscaleX = this._contentSize.width / ptextureSize.width; @@ -637,18 +655,35 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._slidBallNormalRenderer.setVisible(true); this._slidBallPressedRenderer.setVisible(false); this._slidBallDisabledRenderer.setVisible(false); + + this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX, this._sliderBallNormalTextureScaleY); }, _onPressStateChangedToPressed: function () { - this._slidBallNormalRenderer.setVisible(false); - this._slidBallPressedRenderer.setVisible(true); - this._slidBallDisabledRenderer.setVisible(false); + if (!this._slidBallPressedTextureFile){ + this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX + this._zoomScale, this._sliderBallNormalTextureScaleY + this._zoomScale); + }else{ + this._slidBallNormalRenderer.setVisible(false); + this._slidBallPressedRenderer.setVisible(true); + this._slidBallDisabledRenderer.setVisible(false); + } }, _onPressStateChangedToDisabled: function () { - this._slidBallNormalRenderer.setVisible(false); + if (this._slidBallDisabledTextureFile){ + this._slidBallNormalRenderer.setVisible(false); + this._slidBallDisabledRenderer.setVisible(true); + } + this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX, this._sliderBallNormalTextureScaleY); this._slidBallPressedRenderer.setVisible(false); - this._slidBallDisabledRenderer.setVisible(true); + }, + + setZoomScale: function(scale){ + this._zoomScale = scale; + }, + + getZoomScale: function(){ + return this._zoomScale; }, /** @@ -674,6 +709,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this.setPercent(slider.getPercent()); this._sliderEventListener = slider._sliderEventListener; this._sliderEventSelector = slider._sliderEventSelector; + this._zoomScale = slider._zoomScale; + this._eventCallback = slider._eventCallback; + this._ccEventCallback = slider._ccEventCallback; } }); From eab417d9d53a7357ad08e9f18a0128c82003ef29 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 12 Jan 2015 18:10:31 +0800 Subject: [PATCH 1189/1564] Issue #1267: update UIText.js --- extensions/ccui/uiwidgets/UIText.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 8e11a91d0b..70e4984049 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -114,6 +114,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {String} text */ setString: function (text) { + if(text == this._labelRenderer.getString()) + return; this._labelRenderer.setString(text); this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; @@ -210,6 +212,9 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ */ setTextAreaSize: function (size) { this._labelRenderer.setDimensions(size); + if (!this._ignoreSize){ + this._customSize = size; + } this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); this._labelRendererAdaptDirty = true; }, @@ -291,20 +296,6 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ _onPressStateChangedToDisabled: function () { }, - _updateFlippedX: function () { - if (this._flippedX) - this._labelRenderer.setScaleX(-1.0); - else - this._labelRenderer.setScaleX(1.0); - }, - - _updateFlippedY: function () { - if (this._flippedY) - this._labelRenderer.setScaleY(-1.0); - else - this._labelRenderer.setScaleY(1.0); - }, - _onSizeChanged: function () { ccui.Widget.prototype._onSizeChanged.call(this); this._labelRendererAdaptDirty = true; @@ -414,6 +405,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this.setTextAreaSize(uiLabel._textAreaSize); this.setTextHorizontalAlignment(uiLabel._labelRenderer.getHorizontalAlignment()); this.setTextVerticalAlignment(uiLabel._labelRenderer.getVerticalAlignment()); + this.setContentSize(uiLabel.getContentSize()); } }, @@ -442,6 +434,14 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ cc.ProtectedNode.prototype.setColor.call(this, color); this._labelRenderer.setColor(color); } + //todo label add setTextColor +// setTextColor: function(color){ +// this._labelRenderer.setTextColor(color); +// }, +// +// getTextColor: function(){ +// return this._labelRenderer.getTextColor(); +// } }); var _p = ccui.Text.prototype; From 6105e3dca6258d8fbcb7fc7daa33d03ba343ee5d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 12 Jan 2015 18:17:40 +0800 Subject: [PATCH 1190/1564] Issue cocos2d/cocos2d-js/#1267: ccui.helper has been migrated. --- extensions/ccui/layouts/UILayoutManager.js | 8 +++--- extensions/ccui/system/UIHelper.js | 31 +++++++++++++++++++++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index fcbfc98993..d24e8996ab 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -60,7 +60,7 @@ ccui.linearVerticalLayoutManager = /** @lends ccui.linearVerticalLayoutManager# var ap = child.getAnchorPoint(); var cs = child.getContentSize(); var finalPosX = ap.x * cs.width; - var finalPosY = topBoundary - ((1.0-ap.y) * cs.height); + var finalPosY = topBoundary - ((1.0 - ap.y) * cs.height); switch (childGravity){ case ccui.LinearLayoutParameter.NONE: case ccui.LinearLayoutParameter.LEFT: @@ -69,7 +69,7 @@ ccui.linearVerticalLayoutManager = /** @lends ccui.linearVerticalLayoutManager# finalPosX = layoutSize.width - ((1.0 - ap.x) * cs.width); break; case ccui.LinearLayoutParameter.CENTER_HORIZONTAL: - finalPosX = layoutSize.width / 2.0 - cs.width * (0.5-ap.x); + finalPosX = layoutSize.width / 2.0 - cs.width * (0.5 - ap.x); break; default: break; @@ -78,7 +78,7 @@ ccui.linearVerticalLayoutManager = /** @lends ccui.linearVerticalLayoutManager# finalPosX += mg.left; finalPosY -= mg.top; child.setPosition(finalPosX, finalPosY); - topBoundary = child.getPositionY() - child.getAnchorPoint().y * child.getContentSize().height - mg.bottom; + topBoundary = child.getPositionY() - ap.y * cs.height - mg.bottom; } } } @@ -102,7 +102,7 @@ ccui.linearHorizontalLayoutManager = /** @lends ccui.linearHorizontalLayoutManag if (layoutParameter){ var childGravity = layoutParameter.getGravity(); var ap = child.getAnchorPoint(); - var cs = child.getSize(); + var cs = child.getContentSize(); var finalPosX = leftBoundary + (ap.x * cs.width); var finalPosY = layoutSize.height - (1.0 - ap.y) * cs.height; switch (childGravity){ diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 802c0f65df..2c0263b35f 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -119,7 +119,11 @@ ccui.helper = { return null; } , - _activeLayout: false, + _activeLayout: true, + /** + * Refresh object and it's children layout state + * @param {cc.Node} rootNode + */ doLayout: function(rootNode){ if(!this._activeLayout) return; @@ -131,5 +135,30 @@ ccui.helper = { if (null != com && null != parent && com.refreshLayout) com.refreshLayout(); } + }, + + changeLayoutSystemActiveState: function(active){ + this._activeLayout = active; + }, + + /** + * restrict capInsetSize, when the capInsets' width is larger than the textureSize, it will restrict to 0,
    + * the height goes the same way as width. + * @param {cc.Rect} capInsets + * @param {cc.Size} textureSize + */ + restrictCapInsetRect: function (capInsets, textureSize) { + var x = capInsets.x, y = capInsets.y; + var width = capInsets.width, height = capInsets.height; + + if (textureSize.width < width) { + x = 0.0; + width = 0.0; + } + if (textureSize.height < height) { + y = 0.0; + height = 0.0; + } + return cc.rect(x, y, width, height); } }; From c9aac6cea831d9789aa1a2a8ec184afe5f9d1c41 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Tue, 13 Jan 2015 10:17:11 +0800 Subject: [PATCH 1191/1564] Issue #2563: fix the bug that trigger error in scene test --- extensions/cocostudio/loader/parsers/scene-1.x.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/cocostudio/loader/parsers/scene-1.x.js b/extensions/cocostudio/loader/parsers/scene-1.x.js index 8e01342094..96183b3606 100644 --- a/extensions/cocostudio/loader/parsers/scene-1.x.js +++ b/extensions/cocostudio/loader/parsers/scene-1.x.js @@ -41,6 +41,12 @@ return node; }, + deferred: function(json, resourcePath, node, file){ + ccs.triggerManager.parse(json["Triggers"]||[]); + if(ccs.sceneReader) + ccs.sceneReader._node = node; + }, + setPropertyFromJsonDict: function(node, json){ var x = (cc.isUndefined(json["x"]))?0:json["x"]; var y = (cc.isUndefined(json["y"]))?0:json["y"]; From 964e4107c9f1fbdb1bdddf32b08453e0dbf98669 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 10:51:13 +0800 Subject: [PATCH 1192/1564] Issue cocos2d/cocos2d-js/#1267: ccui.PageView and ccui.ScrollView have been migrated. --- .../uiwidgets/scroll-widget/UIPageView.js | 27 +++++------ .../uiwidgets/scroll-widget/UIScrollView.js | 45 ++++++++++++++----- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 36e5676ba4..cfedf69092 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -54,6 +54,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _pageViewEventListener: null, _pageViewEventSelector: null, _className:"PageView", + //v3.2 _customScrollThreshold: 0, _usingCustomScrollThreshold: false, @@ -334,12 +335,9 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {cc.Event} event */ onTouchMoved: function (touch, event) { - ccui.Layout.prototype.onTouchMoved.call(this, touch, event); if (!this._isInterceptTouch) - { this._handleMoveLogic(touch); - } }, /** @@ -351,9 +349,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ onTouchEnded: function (touch, event) { ccui.Layout.prototype.onTouchEnded.call(this, touch, event); if (!this._isInterceptTouch) - { this._handleReleaseLogic(touch); - } this._isInterceptTouch = false; }, @@ -365,9 +361,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ onTouchCancelled: function (touch, event) { ccui.Layout.prototype.onTouchCancelled.call(this, touch, event); if (!this._isInterceptTouch) - { this._handleReleaseLogic(touch); - } this._isInterceptTouch = false; }, @@ -434,7 +428,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Set CustomScrollThreshold + * Set custom scroll threshold to page view. If you don't specify the value, the pageView will scroll when half page view width reached. + * @since v3.2 * @param threshold */ setCustomScrollThreshold: function(threshold){ @@ -444,21 +439,23 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ }, /** - * Gets the _customScrollThreshold. + * Returns user defined scroll page threshold. + * @since v3.2 */ getCustomScrollThreshold: function(){ return this._customScrollThreshold; }, /** - * Set the UsingCustomScrollThreshold + * Set using user defined scroll page threshold or not. If you set it to false, then the default scroll threshold is pageView.width / 2. + * @since v3.2 */ setUsingCustomScrollThreshold: function(flag){ this._usingCustomScrollThreshold = flag; }, /** - * Gets the UsingCustomScrollThreshold + * Queries whether we are using user defined scroll page threshold or not */ isUsingCustomScrollThreshold: function(){ return this._usingCustomScrollThreshold; @@ -473,9 +470,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var pageCount = this._pages.length; var curPageLocation = curPagePos.x; var pageWidth = this.getSize().width; - if (!this._usingCustomScrollThreshold) { + if (!this._usingCustomScrollThreshold) this._customScrollThreshold = pageWidth / 2.0; - } var boundary = this._customScrollThreshold; if (curPageLocation <= -boundary) { if (this._curPageIdx >= pageCount - 1) @@ -522,9 +518,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ this._touchEndPosition.y = touchPoint.y; this._handleReleaseLogic(touch); if (sender.isSwallowTouches()) - { this._isInterceptTouch = false; - } break; } }, @@ -536,6 +530,8 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ else this._pageViewEventSelector(this, ccui.PageView.EVENT_TURNING); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.PageView.EVENT_TURNING); }, /** @@ -607,6 +603,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ _copySpecialProperties: function (pageView) { ccui.Layout.prototype._copySpecialProperties.call(this, pageView); + this._ccEventCallback = pageView._ccEventCallback; this._pageViewEventListener = pageView._pageViewEventListener; this._pageViewEventSelector = pageView._pageViewEventSelector; this._usingCustomScrollThreshold = pageView._usingCustomScrollThreshold; diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 92b6b72c07..4c1113aeab 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -701,7 +701,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ var icBottomPos, icLeftPos, icRightPos, icTopPos; var locContainer = this._innerContainer, locDestination = this._autoScrollDestination; switch (this.direction) { - case ccui.ScrollView.DIR_VERTICAL: // vertical + case ccui.ScrollView.DIR_VERTICAL: if (this._autoScrollDir.y > 0) { icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= locDestination.y) { @@ -716,7 +716,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ } } break; - case ccui.ScrollView.DIR_HORIZONTAL: // horizontal + case ccui.ScrollView.DIR_HORIZONTAL: if (this._autoScrollDir.x > 0) { icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= locDestination.x) { @@ -1321,19 +1321,20 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (!this._checkNeedBounce() && this.inertiaScrollEnabled) { if (this._slidTime <= 0.016) return; - var totalDis = 0; - var dir; + var totalDis = 0, dir; + var touchEndPositionInNodeSpace = this.convertToNodeSpace(this._touchEndPosition); + var touchBeganPositionInNodeSpace = this.convertToNodeSpace(this._touchBeganPosition); switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL : - totalDis = this._touchEndPosition.y - this._touchBeganPosition.y; + totalDis = touchEndPositionInNodeSpace.y - touchBeganPositionInNodeSpace.y; dir = (totalDis < 0) ? ccui.ScrollView.SCROLLDIR_DOWN : ccui.ScrollView.SCROLLDIR_UP; break; case ccui.ScrollView.DIR_HORIZONTAL: - totalDis = this._touchEndPosition.x - this._touchBeganPosition.x; + totalDis = touchEndPositionInNodeSpace.x - touchBeganPositionInNodeSpace.x; dir = totalDis < 0 ? ccui.ScrollView.SCROLLDIR_LEFT : ccui.ScrollView.SCROLLDIR_RIGHT; break; case ccui.ScrollView.DIR_BOTH : - var subVector = cc.pSub(this._touchEndPosition, this._touchBeganPosition); + var subVector = cc.pSub(touchEndPositionInNodeSpace, touchBeganPositionInNodeSpace); totalDis = cc.pLength(subVector); dir = cc.pNormalize(subVector); break; @@ -1352,7 +1353,9 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ }, _handleMoveLogic: function (touch) { - var delta = cc.pSub(touch.getLocation(), touch.getPreviousLocation()); + var touchPositionInNodeSpace = this.convertToNodeSpace(touch.getLocation()), + previousTouchPositionInNodeSpace = this.convertToNodeSpace(touch.getPreviousLocation()); + var delta = cc.pSub(touchPositionInNodeSpace, previousTouchPositionInNodeSpace); switch (this.direction) { case ccui.ScrollView.DIR_VERTICAL: // vertical this._scrollChildren(0.0, delta.y); @@ -1458,10 +1461,10 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ break; case ccui.Widget.TOUCH_MOVED: var offset = cc.pLength(cc.pSub(sender.getTouchBeganPosition(), touchPoint)); + this._touchMovePosition.x = touchPoint.x; + this._touchMovePosition.y = touchPoint.y; if (offset > this._childFocusCancelOffset) { sender.setHighlighted(false); - this._touchMovePosition.x = touchPoint.x; - this._touchMovePosition.y = touchPoint.y; this._handleMoveLogic(touch); } break; @@ -1470,9 +1473,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._touchEndPosition.x = touchPoint.x; this._touchEndPosition.y = touchPoint.y; this._handleReleaseLogic(touch); - if (sender.isSwallowTouches()){ + if (sender.isSwallowTouches()) this._isInterceptTouch = false; - } break; } }, @@ -1484,6 +1486,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_TOP); }, _scrollToBottomEvent: function () { @@ -1493,6 +1497,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM); }, _scrollToLeftEvent: function () { @@ -1502,6 +1508,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT); }, _scrollToRightEvent: function () { @@ -1511,6 +1519,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT); }, _scrollingEvent: function () { @@ -1520,6 +1530,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLLING); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLLING); }, _bounceTopEvent: function () { @@ -1529,6 +1541,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_TOP); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_TOP); }, _bounceBottomEvent: function () { @@ -1538,6 +1552,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM); }, _bounceLeftEvent: function () { @@ -1547,6 +1563,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_LEFT); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_LEFT); }, _bounceRightEvent: function () { @@ -1556,6 +1574,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ else this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); } + if(this._ccEventCallback) + this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT); }, /** @@ -1682,6 +1702,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this.setInertiaScrollEnabled(scrollView.inertiaScrollEnabled); this._scrollViewEventListener = scrollView._scrollViewEventListener; this._scrollViewEventSelector = scrollView._scrollViewEventSelector; + this._ccEventCallback = scrollView._ccEventCallback; } }, From 0e5e3b5068a07ed70216d00a9a0d7a2905f66271 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 11:09:45 +0800 Subject: [PATCH 1193/1564] Issue cocos2d/cocos2d-js/#1267: ccui.ListView has been migrated. --- extensions/ccui/uiwidgets/scroll-widget/UIListView.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 100116df96..9b2950218c 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -471,6 +471,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ else this._listViewEventSelector(this, eventEnum); } + if(this._ccEventCallback) + this._ccEventCallback(this, eventEnum); }, /** @@ -538,6 +540,15 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ this._listViewEventListener = listView._listViewEventListener; this._listViewEventSelector = listView._listViewEventSelector; } + }, + + //v3.3 + forceDoLayout: function(){ + if (this._refreshViewDirty) { + this.refreshView(); + this._refreshViewDirty = false; + } + this._innerContainer.forceDoLayout(); } }); From 49e059ec11242e0b004c57ac100152d67adca277 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 11:26:49 +0800 Subject: [PATCH 1194/1564] Issue #1267: ccui.TextAtlas and ccui.TextBMFont have been migrated. --- extensions/ccui/uiwidgets/UITextAtlas.js | 2 ++ extensions/ccui/uiwidgets/UITextBMFont.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index f60254614b..cb4ad707cc 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -95,6 +95,8 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ * @param {String} value */ setString: function (value) { + if(value == this._labelAtlasRenderer.getString()) + return; this._stringValue = value; this._labelAtlasRenderer.setString(value); this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()); diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 2354261b46..0175981964 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -98,6 +98,8 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo * @param {String} value */ setString: function (value) { + if(value == this._labelBMFontRenderer.getString()) + return; this._stringValue = value; if (!this._fntFileHasInit) return; From f37facc6b3297b93878c24bb62cdd96e3232f7d3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 Jan 2015 11:31:29 +0800 Subject: [PATCH 1195/1564] Fixed the guiReader parser 2.0 throw error --- extensions/cocostudio/loader/parsers/compatible.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/compatible.js b/extensions/cocostudio/loader/parsers/compatible.js index 02a6ea00fe..c77028b367 100644 --- a/extensions/cocostudio/loader/parsers/compatible.js +++ b/extensions/cocostudio/loader/parsers/compatible.js @@ -44,7 +44,13 @@ var json = cc.loader.getRes(file); if(json) this._fileDesignSizes[file] = cc.size(json["designWidth"]||0, json["designHeight"]||0); - return ccs._load(file, "ccui"); + try{ + return ccs._load(file, "ccui"); + }catch(err){ + cc.warn("Not supported file types, Please try use the ccs.load"); + cc.log(err); + return null; + } }, //@deprecated This function will be deprecated sooner or later please use parser.registerParser From 79e01ff27f6fdb4428b4c291a074df9b01390fb2 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 Jan 2015 11:39:58 +0800 Subject: [PATCH 1196/1564] Update UITextFiled.js --- extensions/ccui/uiwidgets/UITextField.js | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 987d67b4fc..b0718917c8 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -38,6 +38,8 @@ ccui._TextFieldRenderer = cc.TextFieldTTF.extend({ _deleteBackward: false, _className: "_TextFieldRenderer", _textFieldRendererAdaptDirty: true, + _ccEventCallback: null, + _eventCallback: null, ctor: function () { cc.TextFieldTTF.prototype.ctor.call(this); @@ -653,6 +655,9 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ else this._textFieldEventSelector(this, ccui.TextField.EVENT_ATTACH_WITH_IME); } + if (this._ccEventCallback){ + this._ccEventCallback(this, 0/*static_cast(EventType::ATTACH_WITH_IME)*/); + } }, _detachWithIMEEvent: function () { @@ -662,6 +667,12 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ else this._textFieldEventSelector(this, ccui.TextField.EVENT_DETACH_WITH_IME); } + if (this._eventCallback){ + this._eventCallback(this, 0/*EventType::DETACH_WITH_IME*/); + } + if (this._ccEventCallback){ + this._ccEventCallback(this, 0/*static_cast(EventType::DETACH_WITH_IME)*/); + } }, _insertTextEvent: function () { @@ -671,6 +682,12 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ else this._textFieldEventSelector(this, ccui.TextField.EVENT_INSERT_TEXT); } + if (this._eventCallback){ + this._eventCallback(this, 0/*EventType::INSERT_TEXT*/); + } + if (this._ccEventCallback){ + this._ccEventCallback(this, 0/*static_cast(EventType::INSERT_TEXT)*/); + } }, _deleteBackwardEvent: function () { @@ -680,6 +697,13 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ else this._textFieldEventSelector(this, ccui.TextField.EVENT_DELETE_BACKWARD); } + if (this._eventCallback){ + this._eventCallback(this, 0/*EventType::DELETE_BACKWARD*/); + } + if (this._ccEventCallback) + { + this._ccEventCallback(this, 0/*static_cast(EventType::DELETE_BACKWARD)*/); + } }, /** @@ -769,6 +793,10 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setDetachWithIME(textField.getDetachWithIME()); this.setInsertText(textField.getInsertText()); this.setDeleteBackward(textField.getDeleteBackward()); + this._eventCallback = textField._eventCallback; + this._ccEventCallback = textField._ccEventCallback; + this._textFieldEventListener = textField._textFieldEventListener; + this._textFieldEventSelector = textField._textFieldEventSelector; }, /** From 5fa5ffa070ed6d8ead0a8670573c96a52bb22976 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 11:48:57 +0800 Subject: [PATCH 1197/1564] Issue #1267: modified ccui.Button's codes --- extensions/ccui/uiwidgets/UIButton.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 8cd10b38c7..36eee19cee 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -220,9 +220,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this._unifySize) return this.getNormalSize(); - var titleSize = this._titleRenderer.getContentSize(); if (!this._normalTextureLoaded && this._titleRenderer.getString().length > 0) { - return cc.size(titleSize); + return this._titleRenderer.getContentSize(); } return cc.size(this._normalTextureSize); }, From 904db1b218ee8f566d8c003443915e6fad14ed54 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 Jan 2015 12:51:20 +0800 Subject: [PATCH 1198/1564] Fixed the guiReader parser 2.0 throw error --- extensions/cocostudio/loader/parsers/compatible.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/compatible.js b/extensions/cocostudio/loader/parsers/compatible.js index c77028b367..326a138597 100644 --- a/extensions/cocostudio/loader/parsers/compatible.js +++ b/extensions/cocostudio/loader/parsers/compatible.js @@ -44,13 +44,14 @@ var json = cc.loader.getRes(file); if(json) this._fileDesignSizes[file] = cc.size(json["designWidth"]||0, json["designHeight"]||0); - try{ - return ccs._load(file, "ccui"); - }catch(err){ + + var version = json["Version"]; + var versionNum = ccs.uiReader.getVersionInteger(version); + if(!version || versionNum >= 1700){ cc.warn("Not supported file types, Please try use the ccs.load"); - cc.log(err); return null; } + return ccs._load(file, "ccui"); }, //@deprecated This function will be deprecated sooner or later please use parser.registerParser From ccd0885a35f9dfb3e60f827a5e49f8686500d590 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 13:59:27 +0800 Subject: [PATCH 1199/1564] Fixed cocos2d/cocos2d-js/#1267: fixed a bug of ccui.Button --- extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js index 158eca0a47..aba5ca6b11 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js @@ -79,6 +79,8 @@ proto.setState = function (state) { var scale9Image = this._node._scale9Image; + if(scale9Image == null) + return; if (state === ccui.Scale9Sprite.state.NORMAL) { scale9Image.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); } else if (state === ccui.Scale9Sprite.state.GRAY) { From c1670ddf2f9b4dff15ecbcc2cd846dd2a54df57a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 14:39:44 +0800 Subject: [PATCH 1200/1564] Fixed cocos2d/cocos2d-js/#1267: fixed a bug of ccui.Button that its content size is incorrect. --- extensions/ccui/uiwidgets/UIButton.js | 58 +++++++++------------------ 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 36eee19cee..09f9c88b36 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -281,18 +281,17 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ default: break; } - if (this._unifySize) + + this._normalTextureSize = this._buttonNormalRenderer.getContentSize(); + this._updateChildrenDisplayedRGBA(); + if (this._unifySize){ if (this._scale9Enabled){ normalRenderer.setCapInsets(this._capInsetsNormal); this._updateContentSizeWithTextureSize(this.getNormalSize()); } - else + }else this._updateContentSizeWithTextureSize(this._normalTextureSize); - this._normalTextureSize = this._buttonNormalRenderer.getContentSize(); - - this._updateChildrenDisplayedRGBA(); - this._normalTextureLoaded = true; this._normalTextureAdaptDirty = true; }, @@ -340,7 +339,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ clickedRenderer.setCapInsets(this._capInsetsPressed); this._pressedTextureSize = this._buttonClickedRenderer.getContentSize(); - this._updateChildrenDisplayedRGBA(); this._pressedTextureLoaded = true; @@ -391,7 +389,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ disabledRenderer.setCapInsets(this._capInsetsDisabled); this._disabledTextureSize = this._buttonDisableRenderer.getContentSize(); - this._updateChildrenDisplayedRGBA(); this._disabledTextureLoaded = true; @@ -415,22 +412,17 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ setCapInsetsNormalRenderer: function (capInsets) { if(!capInsets) return; - var x = capInsets.x; - var y = capInsets.y; - var width = capInsets.width; - var height = capInsets.height; - if (this._normalTextureSize.width < width) - { + var x = capInsets.x, y = capInsets.y; + var width = capInsets.width, height = capInsets.height; + if (this._normalTextureSize.width < width){ x = 0; width = 0; } - if (this._normalTextureSize.height < height) - { + if (this._normalTextureSize.height < height){ y = 0; height = 0; } - var rect = cc.rect(x, y, width, height); var locInsets = this._capInsetsNormal; locInsets.x = x; @@ -440,7 +432,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (!this._scale9Enabled) return; - this._buttonNormalRenderer.setCapInsets(rect); + this._buttonNormalRenderer.setCapInsets(locInsets); }, /** @@ -459,22 +451,17 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if(!capInsets || !this._scale9Enabled) return; - var x = capInsets.x; - var y = capInsets.y; - var width = capInsets.width; - var height = capInsets.height; + var x = capInsets.x, y = capInsets.y; + var width = capInsets.width, height = capInsets.height; - if (this._normalTextureSize.width < width) - { + if (this._normalTextureSize.width < width) { x = 0; width = 0; } - if (this._normalTextureSize.height < height) - { + if (this._normalTextureSize.height < height) { y = 0; height = 0; } - var rect = cc.rect(x, y, width, height); var locInsets = this._capInsetsPressed; locInsets.x = x; @@ -482,7 +469,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locInsets.width = width; locInsets.height = height; - this._buttonClickedRenderer.setCapInsets(rect); + this._buttonClickedRenderer.setCapInsets(locInsets); }, /** @@ -501,22 +488,17 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if(!capInsets || !this._scale9Enabled) return; - var x = capInsets.x; - var y = capInsets.y; - var width = capInsets.width; - var height = capInsets.height; + var x = capInsets.x, y = capInsets.y; + var width = capInsets.width, height = capInsets.height; - if (this._normalTextureSize.width < width) - { + if (this._normalTextureSize.width < width) { x = 0; width = 0; } - if (this._normalTextureSize.height < height) - { + if (this._normalTextureSize.height < height) { y = 0; height = 0; } - var rect = cc.rect(x, y, width, height); var locInsets = this._capInsetsDisabled; locInsets.x = x; @@ -524,7 +506,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locInsets.width = width; locInsets.height = height; - this._buttonDisableRenderer.setCapInsets(rect); + this._buttonDisableRenderer.setCapInsets(locInsets); }, /** From b12022ba131f0023b3d4c71cf3e6d154708eab21 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 Jan 2015 15:03:32 +0800 Subject: [PATCH 1201/1564] update 2.0 layout parser --- .../loader/parsers/timelineParser-2.x.js | 84 ++++++++++++++----- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index a0e7307595..0e4f9d244e 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -289,26 +289,70 @@ setContentSize(widget, json["Size"]); if(widget instanceof ccui.Layout){ - //todo update UILayoutComponent.bindLayoutComponent - var positionXPercentEnabled = json["PositionPercentXEnable"]; - var positionYPercentEnabled = json["PositionPercentYEnable"]; - var sizeXPercentEnable = json["PercentWidthEnable"]; - var sizeYPercentEnable = json["PercentHeightEnable"]; - var stretchHorizontalEnabled = json["StretchWidthEnable"]; - var stretchVerticalEnabled = json["StretchHeightEnable"]; - var horizontalEdge = json["HorizontalEdge"]; - var verticalEdge = json["VerticalEdge"]; - var leftMargin = json["LeftMargin"]; - var rightMargin = json["RightMargin"]; - var topMargin = json["TopMargin"]; - var bottomMargin = json["BottomMargin"]; - //var prePosition = json["PrePosition"]; - //if(prePosition) - // prePosition["X"], prePosition["Y"] - - //var preSize = json["PreSize"]; - //if(preSize) - // preSize["X"], preSize["Y"] + var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); + + var positionXPercentEnabled = json["PositionPercentXEnable"] || false; + var positionYPercentEnabled = json["PositionPercentYEnable"] || false; + var positionXPercent = 0, + positionYPercent = 0, + PrePosition = json["PrePosition"]; + if(PrePosition != null){ + positionXPercent = PrePosition["X"] || 0; + positionYPercent = PrePosition["Y"] || 0; + } + var sizeXPercentEnable = json["PercentWidthEnable"] || false; + var sizeYPercentEnable = json["PercentHeightEnable"] || false; + var sizeXPercent = 0, + sizeYPercent = 0, + PreSize = json["PreSize"]; + if(PrePosition != null){ + sizeXPercent = PreSize["X"] || 0; + sizeYPercent = PreSize["Y"] || 0; + } + var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; + var stretchVerticalEnabled = json["StretchHeightEnable"] || false; + var horizontalEdge = json["HorizontalEdge"] = ccui.LayoutComponent.horizontalEdge.LEFT; + var verticalEdge = json["VerticalEdge"] = ccui.LayoutComponent.verticalEdge.TOP; + var leftMargin = json["LeftMargin"] || 0; + var rightMargin = json["RightMargin"] || 0; + var topMargin = json["TopMargin"] || 0; + var bottomMargin = json["BottomMargin"] || 0; + + layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); + layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); + layoutComponent.setPositionPercentX(positionXPercent); + layoutComponent.setPositionPercentY(positionYPercent); + layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); + layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); + layoutComponent.setPercentWidth(sizeXPercent); + layoutComponent.setPercentHeight(sizeYPercent); + layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); + layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); + + var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; + if (horizontalEdge == "LeftEdge"){ + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; + }else if (horizontalEdge == "RightEdge"){ + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; + }else if (horizontalEdge == "BothEdge"){ + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; + } + layoutComponent.setHorizontalEdge(horizontalEdgeType); + + var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; + if (verticalEdge == "TopEdge"){ + verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; + }else if (verticalEdge == "BottomEdge"){ + verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; + }else if (verticalEdge == "BothEdge"){ + verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; + } + layoutComponent.setVerticalEdge(verticalEdgeType); + + layoutComponent.setTopMargin(topMargin); + layoutComponent.setBottomMargin(bottomMargin); + layoutComponent.setLeftMargin(leftMargin); + layoutComponent.setRightMargin(rightMargin); } }; From 9ff1f27421a068d8eb24b01bca2660fa2a88abc2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 15:07:47 +0800 Subject: [PATCH 1202/1564] Fixed #1267: add 'isSwallowTouches' to cc._EventListenerTouchOneByOne --- cocos2d/core/event-manager/CCEventListener.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 2df66a3458..9cb338fed5 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -366,6 +366,10 @@ cc._EventListenerTouchOneByOne = cc.EventListener.extend({ this.swallowTouches = needSwallow; }, + isSwallowTouches: function(){ + return this.swallowTouches; + }, + clone: function () { var eventListener = new cc._EventListenerTouchOneByOne(); eventListener.onTouchBegan = this.onTouchBegan; From 36bb01f64c8485f784547aa0870682fa4ef67be5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 16:02:27 +0800 Subject: [PATCH 1203/1564] Fixed #1267: correct a jsDoc of ccui.Button --- extensions/ccui/uiwidgets/UIButton.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 09f9c88b36..4e3994c3c7 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -829,7 +829,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ /** * Returns title fontSize of ccui.Button. - * @returns {cc.Size} + * @returns {Number} */ getTitleFontSize: function () { return this._titleRenderer.getFontSize(); From 66dc7bbf7b19acff6fb309cfb778e273429e5a23 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 Jan 2015 16:46:21 +0800 Subject: [PATCH 1204/1564] Fixed the guiReader parser 2.0 throw error --- extensions/cocostudio/loader/parsers/compatible.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/compatible.js b/extensions/cocostudio/loader/parsers/compatible.js index 326a138597..0969d257d5 100644 --- a/extensions/cocostudio/loader/parsers/compatible.js +++ b/extensions/cocostudio/loader/parsers/compatible.js @@ -45,7 +45,7 @@ if(json) this._fileDesignSizes[file] = cc.size(json["designWidth"]||0, json["designHeight"]||0); - var version = json["Version"]; + var version = json["Version"] || json["version"]; var versionNum = ccs.uiReader.getVersionInteger(version); if(!version || versionNum >= 1700){ cc.warn("Not supported file types, Please try use the ccs.load"); From ae2d03de4003c1ce94c6d240b649416a55b53552 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 13 Jan 2015 17:02:31 +0800 Subject: [PATCH 1205/1564] Fixed #1267: refactor ccui.Button, ccui.Slider and ccui.TextField's eventCallback --- .../ccui/base-classes/UIScale9Sprite.js | 3 +- extensions/ccui/base-classes/UIWidget.js | 3 +- extensions/ccui/uiwidgets/UIButton.js | 21 +++++++---- extensions/ccui/uiwidgets/UISlider.js | 15 ++------ extensions/ccui/uiwidgets/UITextField.js | 37 ++++++------------- 5 files changed, 33 insertions(+), 46 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index a828908e64..e36ee5d569 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -1017,7 +1017,8 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ }, getScale: function () { - cc.log(this.getScaleX() == this.getScaleY(), "Scale9Sprite#scale. ScaleX != ScaleY. Don't know which one to return"); + if(this.getScaleX() !== this.getScaleY()) + cc.log("Scale9Sprite#scale. ScaleX != ScaleY. Don't know which one to return"); return this.getScaleX(); }, diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index d7dc060958..b753d792ee 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1726,7 +1726,8 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return originalScale; }, getScale: function(){ - cc.log(this.getScaleX() == this.getScaleY(), "Widget#scale. ScaleX != ScaleY. Don't know which one to return"); + if(this.getScaleX() == this.getScaleY()) + cc.log("Widget#scale. ScaleX != ScaleY. Don't know which one to return"); return this.getScaleX(); }, diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 4e3994c3c7..6dba636038 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -522,7 +522,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setVisible(false); this._buttonDisableRenderer.setVisible(false); if (this._scale9Enabled) - this._buttonNormalRenderer.setState(0/*Scale9Sprite::State::NORMAL*/); + this._buttonNormalRenderer.setState( ccui.Scale9Sprite.state.NORMAL); if (this._pressedTextureLoaded) { if (this.pressedActionEnabled){ this._buttonNormalRenderer.stopAllActions(); @@ -533,7 +533,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._titleRenderer.stopAllActions(); if (this._unifySize){ - var zoomTitleAction = cc.scaleTo(0.05/*ZOOM_ACTION_TIME_STEP*/, 1, 1); + var zoomTitleAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, 1, 1); this._titleRenderer.runAction(zoomTitleAction); }else this._titleRenderer.runAction(zoomAction.clone()); @@ -560,7 +560,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _onPressStateChangedToPressed: function () { var locNormalRenderer = this._buttonNormalRenderer; if (this._scale9Enabled) - locNormalRenderer.setState(0/*Scale9Sprite::State::NORMAL*/); + locNormalRenderer.setState(ccui.Scale9Sprite.state.NORMAL); if (this._pressedTextureLoaded) { locNormalRenderer.setVisible(false); @@ -962,30 +962,37 @@ ccui.Button.create = function (normalImage, selectedImage, disableImage, texType // Constants /** - * The normal renderer's zOrder value. + * The normal renderer's zOrder value of ccui.Button. * @constant * @type {number} */ ccui.Button.NORMAL_RENDERER_ZORDER = -2; /** - * The pressed renderer's zOrder value. + * The pressed renderer's zOrder value ccui.Button. * @constant * @type {number} */ ccui.Button.PRESSED_RENDERER_ZORDER = -2; /** - * The disabled renderer's zOrder value. + * The disabled renderer's zOrder value of ccui.Button. * @constant * @type {number} */ ccui.Button.DISABLED_RENDERER_ZORDER = -2; /** - * The title renderer's zOrder value. + * The title renderer's zOrder value of ccui.Button. * @constant * @type {number} */ ccui.Button.TITLE_RENDERER_ZORDER = -1; +/** + * the zoom action time step of ccui.Button + * @constant + * @type {number} + */ +ccui.Button.ZOOM_ACTION_TIME_STEP = 0.05; + /** * @ignore */ diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 48f725ac91..c2feccd6b6 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -64,7 +64,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _sliderBallNormalTextureScaleX: 1, _sliderBallNormalTextureScaleY: 1, - _eventCallback: null, /** * allocates and initializes a UISlider. @@ -527,7 +526,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * @param {Object} [target=] */ addEventListener: function(selector, target){ - this._sliderEventSelector = selector; + this._sliderEventSelector = selector; //when target is undefined, _sliderEventSelector = _eventCallback this._sliderEventListener = target; }, @@ -536,15 +535,10 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ if (this._sliderEventListener) this._sliderEventSelector.call(this._sliderEventListener, this, ccui.Slider.EVENT_PERCENT_CHANGED); else - this._sliderEventSelector(this, ccui.Slider.EVENT_PERCENT_CHANGED); - } - //todo check here - if (this._eventCallback){ - this._eventCallback(this, 0/*EventType::ON_PERCENTAGE_CHANGED*/); - } - if (this._ccEventCallback){ - this._ccEventCallback(this, 0/*static_cast(EventType::ON_PERCENTAGE_CHANGED)*/); + this._sliderEventSelector(this, ccui.Slider.EVENT_PERCENT_CHANGED); // _eventCallback } + if (this._ccEventCallback) + this._ccEventCallback(this, ccui.Slider.EVENT_PERCENT_CHANGED); }, /** @@ -710,7 +704,6 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._sliderEventListener = slider._sliderEventListener; this._sliderEventSelector = slider._sliderEventSelector; this._zoomScale = slider._zoomScale; - this._eventCallback = slider._eventCallback; this._ccEventCallback = slider._ccEventCallback; } diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index b0718917c8..056cc24d79 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -37,9 +37,6 @@ ccui._TextFieldRenderer = cc.TextFieldTTF.extend({ _insertText: false, _deleteBackward: false, _className: "_TextFieldRenderer", - _textFieldRendererAdaptDirty: true, - _ccEventCallback: null, - _eventCallback: null, ctor: function () { cc.TextFieldTTF.prototype.ctor.call(this); @@ -241,6 +238,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ _fontName: "", _fontSize: 12, + _ccEventCallback: null, + /** * allocates and initializes a UITextField. * Constructor of ccui.TextField. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. @@ -656,7 +655,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldEventSelector(this, ccui.TextField.EVENT_ATTACH_WITH_IME); } if (this._ccEventCallback){ - this._ccEventCallback(this, 0/*static_cast(EventType::ATTACH_WITH_IME)*/); + this._ccEventCallback(this, ccui.TextField.EVENT_ATTACH_WITH_IME); } }, @@ -667,12 +666,8 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ else this._textFieldEventSelector(this, ccui.TextField.EVENT_DETACH_WITH_IME); } - if (this._eventCallback){ - this._eventCallback(this, 0/*EventType::DETACH_WITH_IME*/); - } - if (this._ccEventCallback){ - this._ccEventCallback(this, 0/*static_cast(EventType::DETACH_WITH_IME)*/); - } + if (this._ccEventCallback) + this._ccEventCallback(this, ccui.TextField.EVENT_DETACH_WITH_IME); }, _insertTextEvent: function () { @@ -680,14 +675,10 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ if (this._textFieldEventListener) this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT); else - this._textFieldEventSelector(this, ccui.TextField.EVENT_INSERT_TEXT); - } - if (this._eventCallback){ - this._eventCallback(this, 0/*EventType::INSERT_TEXT*/); - } - if (this._ccEventCallback){ - this._ccEventCallback(this, 0/*static_cast(EventType::INSERT_TEXT)*/); + this._textFieldEventSelector(this, ccui.TextField.EVENT_INSERT_TEXT); //eventCallback } + if (this._ccEventCallback) + this._ccEventCallback(this, ccui.TextField.EVENT_INSERT_TEXT); }, _deleteBackwardEvent: function () { @@ -695,15 +686,10 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ if (this._textFieldEventListener) this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD); else - this._textFieldEventSelector(this, ccui.TextField.EVENT_DELETE_BACKWARD); - } - if (this._eventCallback){ - this._eventCallback(this, 0/*EventType::DELETE_BACKWARD*/); + this._textFieldEventSelector(this, ccui.TextField.EVENT_DELETE_BACKWARD); //eventCallback } if (this._ccEventCallback) - { - this._ccEventCallback(this, 0/*static_cast(EventType::DELETE_BACKWARD)*/); - } + this._ccEventCallback(this, ccui.TextField.EVENT_DELETE_BACKWARD); }, /** @@ -722,7 +708,7 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ * @param {Function} selector */ addEventListener: function(selector, target){ - this._textFieldEventSelector = selector; + this._textFieldEventSelector = selector; //when target is undefined, _textFieldEventSelector is ccEventCallback. this._textFieldEventListener = target; }, @@ -793,7 +779,6 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setDetachWithIME(textField.getDetachWithIME()); this.setInsertText(textField.getInsertText()); this.setDeleteBackward(textField.getDeleteBackward()); - this._eventCallback = textField._eventCallback; this._ccEventCallback = textField._ccEventCallback; this._textFieldEventListener = textField._textFieldEventListener; this._textFieldEventSelector = textField._textFieldEventSelector; From 7d6d895e6a14802ceac9956703d899cd0562206d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 13 Jan 2015 18:15:01 +0800 Subject: [PATCH 1206/1564] Modify the log text --- extensions/cocostudio/loader/parsers/scene-1.x.js | 2 +- .../loader/parsers/timelineParser-1.x.js | 2 +- .../loader/parsers/timelineParser-2.x.js | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/scene-1.x.js b/extensions/cocostudio/loader/parsers/scene-1.x.js index 96183b3606..616350c613 100644 --- a/extensions/cocostudio/loader/parsers/scene-1.x.js +++ b/extensions/cocostudio/loader/parsers/scene-1.x.js @@ -217,7 +217,7 @@ cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); }else{ if(!loadedPlist[resourcePath + plist]) - cc.log("%s need to pre load", resourcePath + plist); + cc.log("%s need to be pre loaded", resourcePath + plist); } } if(type !== 0) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js index f4cbe3d9c3..b157859934 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -38,7 +38,7 @@ for (var i = 0; i < plists.length; i++) { var plist = resourcePath + plists[i]; if(!cc.loader.getRes(plist) && !loadedPlist[plist]) - cc.log("%s need to pre load", plist); + cc.log("%s need to be pre loaded", plist); else loadedPlist[plist] = true; cc.spriteFrameCache.addSpriteFrames( diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 0e4f9d244e..434114428d 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -194,7 +194,7 @@ self = this; loadTexture(json["FileData"], resourcePath, function(path, type){ if(!cc.loader.getRes(path)) - cc.log("%s need to pre load", path); + cc.log("%s need to be pre loaded", path); node = new cc.ParticleSystem(path); self.generalAttributes(node, json); node.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); @@ -767,7 +767,7 @@ textureList.forEach(function(item){ loadTexture(json[item.name], resourcePath, function(path, type){ if(type == 0 && !loader.getRes(path)) - cc.log("%s need to pre load", path); + cc.log("%s need to be pre loaded", path); item.handle.call(widget, path, type); }); }); @@ -954,7 +954,7 @@ loadTexture(json["LabelAtlasFileImage_CNB"], resourcePath, function(path, type){ if(!cc.loader.getRes(path)) - cc.log("%s need to pre load", path); + cc.log("%s need to be pre loaded", path); if(type == 0){ widget.setProperty(stringValue, path, itemWidth, itemHeight, startCharMap); } @@ -980,7 +980,7 @@ loadTexture(json["LabelBMFontFile_CNB"], resourcePath, function(path, type){ if(!cc.loader.getRes(path)) - cc.log("%s need to pre load", path); + cc.log("%s need to be pre loaded", path); widget.setFntFile(path); }); return widget; @@ -1104,7 +1104,7 @@ if(cc.loader.getRes(file)) return ccs._load(file); else - cc.log("%s need to pre load", file); + cc.log("%s need to be pre loaded", file); } }; @@ -1136,7 +1136,7 @@ var plists, pngs; var armJson = cc.loader.getRes(path); if(!armJson) - cc.log("%s need to pre load", path); + cc.log("%s need to be pre loaded", path); else{ plists = armJson["config_file_path"]; pngs = armJson["config_png_path"]; @@ -1170,7 +1170,7 @@ cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); }else{ if(!loadedPlist[resourcePath + plist]) - cc.log("%s need to pre load", resourcePath + plist); + cc.log("%s need to be pre loaded", resourcePath + plist); } } if(type !== 0) From 09eb5ca8f04a6d095e3de56fd3c4dfb2006b07ed Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 14 Jan 2015 14:55:29 +0800 Subject: [PATCH 1207/1564] Fixed cocos2d/cocos2d-js/#1309: ccui.Widget can't touch when it reused. --- extensions/ccui/base-classes/UIWidget.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index b753d792ee..eb1df91975 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -145,6 +145,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @override */ onEnter: function () { + var locListener = this._touchListener; + if (locListener && !locListener._isRegistered() && this._touchEnabled) + cc.eventManager.addListener(locListener, this); if(!this._usingLayoutComponent) this.updateSizeAndPosition(); cc.ProtectedNode.prototype.onEnter.call(this); From 082ab2e9efa6ced5a522dbbe12542391086af7aa Mon Sep 17 00:00:00 2001 From: Joe Lafiosca Date: Wed, 14 Jan 2015 18:10:27 -0500 Subject: [PATCH 1208/1564] register loader for JavaScript (.js) files --- cocos2d/core/platform/CCLoaders.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index d051a80b42..44aefd9f00 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -37,6 +37,13 @@ cc._jsonLoader = { }; cc.loader.register(["json", "ExportJson"], cc._jsonLoader); +cc._jsLoader = { + load : function(realUrl, url, res, cb){ + cc.loader.loadJs(realUrl, cb); + } +}; +cc.loader.register(["js"], cc._jsLoader); + cc._imgLoader = { load : function(realUrl, url, res, cb){ cc.loader.cache[url] = cc.loader.loadImg(realUrl, function(err, img){ From 599302e361614da49d23b1e87ae689708101077e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 15 Jan 2015 13:42:21 +0800 Subject: [PATCH 1209/1564] Added Focus event, Focus event listener and added getSelectedItem function to cc.Menu --- cocos2d/core/event-manager/CCEvent.js | 16 +++++++- cocos2d/core/event-manager/CCEventListener.js | 37 ++++++++++++++++++- cocos2d/menus/CCMenuItem.js | 11 +++++- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/event-manager/CCEvent.js b/cocos2d/core/event-manager/CCEvent.js index 74ac15c845..f5d8624830 100644 --- a/cocos2d/core/event-manager/CCEvent.js +++ b/cocos2d/core/event-manager/CCEvent.js @@ -420,4 +420,18 @@ cc.EventTouch = cc.Event.extend(/** @lends cc.EventTouch# */{ */ cc.EventTouch.MAX_TOUCHES = 5; -cc.EventTouch.EventCode = {BEGAN: 0, MOVED: 1, ENDED: 2, CANCELLED: 3}; \ No newline at end of file +cc.EventTouch.EventCode = {BEGAN: 0, MOVED: 1, ENDED: 2, CANCELLED: 3}; + +/** + * Focus change event for UI widget + * @class + * @extends cc.Event + */ +cc.EventFocus = cc.Event.extend(/** @lends cc.EventTouch# */{ + _widgetGetFocus: null, + _widgetLoseFocus: null, + ctor: function(widgetLoseFocus, widgetGetFocus){ + this._widgetGetFocus = widgetGetFocus; + this._widgetLoseFocus = widgetLoseFocus; + } +}); \ No newline at end of file diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 9cb338fed5..96bee80700 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -269,6 +269,13 @@ cc.EventListener.ACCELERATION = 5; */ cc.EventListener.CUSTOM = 6; +/** + * The type code of Focus change event listener. + * @constant + * @type {number} + */ +cc.EventListener.FOCUS = 7; + cc._EventListenerCustom = cc.EventListener.extend({ _onCustomEvent: null, ctor: function (listenerId, callback) { @@ -470,11 +477,37 @@ cc.EventListener.create = function(argObj){ else if(listenerType === cc.EventListener.ACCELERATION){ listener = new cc._EventListenerAcceleration(argObj.callback); delete argObj.callback; - } + } else if(listenerType === cc.EventListener.FOCUS) + listener = new cc._EventListenerFocus(); for(var key in argObj) { listener[key] = argObj[key]; } return listener; -}; \ No newline at end of file +}; + +cc._EventListenerFocus = cc.EventListener.extend({ + clone: function(){ + var listener = new cc._EventListenerFocus(); + listener.onFocusChanged = this.onFocusChanged; + return listener; + }, + checkAvailable: function(){ + if(!this.onFocusChanged){ + cc.log("Invalid EventListenerFocus!"); + return false; + } + return true; + }, + onFocusChanged: null, + ctor: function(){ + var listener = function(event){ + if(this.onFocusChanged) + this.onFocusChanged(event._widgetLoseFocus, event._widgetGetFocus); + }; + cc.EventListener.prototype.ctor.call(this, cc.EventListener.FOCUS, cc._EventListenerFocus.LISTENER_ID, listener); + } +}); + +cc._EventListenerFocus.LISTENER_ID = ""; \ No newline at end of file diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 0d92724556..8225c03cc6 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -1369,12 +1369,21 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ }, /** - * returns the selected item + * returns the selected item (deprecated in -x, please use getSelectedItem instead.) * @return {cc.MenuItem} */ selectedItem: function () { return this.subItems[this._selectedIndex]; }, + + /** + * returns the selected item. + * @return {cc.MenuItem} + */ + getSelectedItem: function() { + return this.subItems[this._selectedIndex]; + }, + /** * *

    * Event callback that is invoked every time when cc.MenuItemToggle enters the 'stage'.
    From a98914a17344b48b19340fde7e48ea275b278aa0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 15 Jan 2015 13:45:40 +0800 Subject: [PATCH 1210/1564] HBox and VBox actor error --- extensions/ccui/layouts/UIHBox.js | 1 + extensions/ccui/layouts/UIVBox.js | 1 + 2 files changed, 2 insertions(+) diff --git a/extensions/ccui/layouts/UIHBox.js b/extensions/ccui/layouts/UIHBox.js index 1a0c65d36c..4e32002dd4 100644 --- a/extensions/ccui/layouts/UIHBox.js +++ b/extensions/ccui/layouts/UIHBox.js @@ -35,6 +35,7 @@ ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{ * @param {cc.Size} [size] */ ctor: function(size){ + ccui.Layout.prototype.ctor.call(this, size); if(size !== undefined) this.initWithSize(size); else diff --git a/extensions/ccui/layouts/UIVBox.js b/extensions/ccui/layouts/UIVBox.js index 15c4871f71..d816c729db 100644 --- a/extensions/ccui/layouts/UIVBox.js +++ b/extensions/ccui/layouts/UIVBox.js @@ -35,6 +35,7 @@ ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ * @param {cc.Size} size */ ctor: function(size){ + ccui.Layout.prototype.ctor.call(this, size); if(size !== undefined) this.initWithSize(size); else From e047e4dc1b2250294b35ad280288a46fe9d92f81 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 15 Jan 2015 13:46:30 +0800 Subject: [PATCH 1211/1564] UIWidget get positionPercent error --- extensions/ccui/base-classes/UIWidget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index eb1df91975..94adbca007 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -1187,7 +1187,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._positionPercent.x = component.getPositionPercentX(); this._positionPercent.y = component.getPositionPercentY(); } - return cc.p(this.getNormalizedPosition()); + return cc.p(this._positionPercent); }, _getXPercent: function () { From 4ce4ccc48431f309d26fc5ef5fbfb3f9e1287776 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 15 Jan 2015 13:47:11 +0800 Subject: [PATCH 1212/1564] Fixed CheckBox and ImageView ctor problem --- extensions/ccui/uiwidgets/UICheckBox.js | 4 ++-- extensions/ccui/uiwidgets/UIImageView.js | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 9a027bc98e..56639a17cf 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -81,8 +81,8 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ ctor: function (backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType) { ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); - - texType !== undefined && this.init(backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType); + texType = texType === undefined ? 0 : texType; + this.init(backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType); }, /** diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index a951d07ed0..9a743dff29 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -52,8 +52,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._capInsets = cc.rect(0,0,0,0); this._imageTextureSize = cc.size(this._capInsets.width, this._capInsets.height); ccui.Widget.prototype.ctor.call(this); - - texType !== undefined && this.init(imageFileName, texType); + texType = texType === undefined ? 0 : texType; + this.init(imageFileName, texType); }, /** @@ -298,6 +298,19 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this.loadTexture(imageView._textureFile, imageView._imageTexType); this.setCapInsets(imageView._capInsets); } + }, + /** + * Sets _customSize of ccui.Widget, if ignoreSize is true, the content size is its renderer's contentSize, otherwise the content size is parameter. + * and updates size percent by parent content size. At last, updates its children's size and position. + * @param {cc.Size|Number} contentSize content size or width of content size + * @param {Number} [height] + * @override + */ + setContentSize: function(contentSize, height){ + if(height) + contentSize = cc.size(contentSize, height); + ccui.Widget.prototype.setContentSize.call(this, contentSize); + this._imageRenderer.setContentSize(contentSize); } }); From 9e906f47aa29ee71202f5090b0ba266e4558e8e3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 15 Jan 2015 13:47:45 +0800 Subject: [PATCH 1213/1564] Scale9Sprite setContentSize error --- .../ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js | 5 +++++ .../ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js | 10 ++++++++++ .../control-extension/CCScale9SpriteCanvasRenderCmd.js | 5 +++++ .../control-extension/CCScale9SpriteWebGLRenderCmd.js | 10 ++++++++++ 4 files changed, 30 insertions(+) diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index a324dab733..e049c5abe6 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -62,6 +62,11 @@ proto.transform = function(parentCmd){ var node = this._node; + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; + } this._cacheScale9Sprite(); cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); diff --git a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js index aba5ca6b11..150c685f2d 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js @@ -45,6 +45,16 @@ cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); }; + proto.transform = function(){ + var node = this._node; + cc.Node.WebGLRenderCmd.prototype.transform.call(this); + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; + } + }; + proto._updateDisplayColor = function(parentColor){ cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this, parentColor); diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js index 8332b5cd80..ab2963b328 100644 --- a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -89,6 +89,11 @@ proto.transform = function(parentCmd){ var node = this._node; + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; + } this._cacheScale9Sprite(); cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); diff --git a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js index 047d00ccc3..6a5826dd12 100644 --- a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js @@ -68,4 +68,14 @@ } cc.Node.WebGLRenderCmd.prototype.visit.call(this, parentCmd); }; + + proto.transform = function(){ + var node = this._node; + cc.Node.WebGLRenderCmd.prototype.transform.call(this); + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; + } + }; })(); \ No newline at end of file From 296eab2f6501dabb52abc7a94c7a120659233310 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 15 Jan 2015 15:22:08 +0800 Subject: [PATCH 1214/1564] Added ccui._FocusNavigationController --- cocos2d/core/event-manager/CCEvent.js | 5 ++ extensions/ccui/base-classes/UIWidget.js | 104 ++++++++++++++++++----- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/cocos2d/core/event-manager/CCEvent.js b/cocos2d/core/event-manager/CCEvent.js index f5d8624830..91e4d23c5b 100644 --- a/cocos2d/core/event-manager/CCEvent.js +++ b/cocos2d/core/event-manager/CCEvent.js @@ -430,6 +430,11 @@ cc.EventTouch.EventCode = {BEGAN: 0, MOVED: 1, ENDED: 2, CANCELLED: 3}; cc.EventFocus = cc.Event.extend(/** @lends cc.EventTouch# */{ _widgetGetFocus: null, _widgetLoseFocus: null, + /** + * Constructor function. + * @param {ccui.Widget} widgetLoseFocus + * @param {ccui.Widget} widgetGetFocus + */ ctor: function(widgetLoseFocus, widgetGetFocus){ this._widgetGetFocus = widgetGetFocus; this._widgetLoseFocus = widgetLoseFocus; diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index eb1df91975..26602c6fce 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -23,6 +23,62 @@ THE SOFTWARE. ****************************************************************************/ +ccui._FocusNavigationController = cc.Class.extend({ + _keyboardListener: null, + _firstFocusedWidget: null, + _enableFocusNavigation: false, + _keyboardEventPriority: 1, + + enableFocusNavigation: function(flag){ + if (this._enableFocusNavigation == flag) + return; + + this._enableFocusNavigation = flag; + if (flag) + this._addKeyboardEventListener(); + else + this._removeKeyboardEventListener(); + }, + + _setFirstFocsuedWidget: function(widget){ + this._firstFocusedWidget = widget; + }, + + _onKeyPressed: function(keyCode, event){ + if (this._enableFocusNavigation && this._firstFocusedWidget) { + if (keyCode == cc.KEY.down) { + this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.DOWN, this._firstFocusedWidget); + } + if (keyCode == cc.KEY.up){ + this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.UP, this._firstFocusedWidget); + } + if (keyCode == cc.KEY.left) { + this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.LEFT, this._firstFocusedWidget); + } + if (keyCode == cc.KEY.right) { + this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.RIGHT, this._firstFocusedWidget); + } + } + }, + + _addKeyboardEventListener: function(){ + if (!this._keyboardListener) { + this._keyboardListener = cc.EventListener.create({ + event: cc.EventListener.FOCUS, + onKeyReleased: this._onKeyPressed.bind(this) + }); + cc.eventManager.addListener(this._keyboardListener, this._keyboardEventPriority); + } + }, + + _removeKeyboardEventListener: function(){ + if (this._keyboardListener) { + cc.eventManager.removeEventListener(this._keyboardListener); + this._keyboardListener = null; + } + } +}); + ccui.__LAYOUT_COMPONENT_NAME = "__ui_layout"; /** @@ -269,10 +325,14 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ _cleanupWidget: function(){ //clean up _touchListener this._eventDispatcher.removeEventListener(this._touchListener); + this._touchEnabled = false; + this._touchListener = null; //cleanup focused widget and focus navigation controller - if (ccui.Widget._focusedWidget == this) + if (ccui.Widget._focusedWidget == this){ ccui.Widget._focusedWidget = null; + ccui.Widget._focusNavigationController = null; + } }, /** @@ -664,8 +724,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ setFocused: function (focus) { this._focused = focus; //make sure there is only one focusedWidget - if (focus) + if (focus){ ccui.Widget._focusedWidget = this; + if(ccui.Widget._focusNavigationController) + ccui.Widget._focusNavigationController._setFirstFocsuedWidget(this); + } }, /** @@ -735,7 +798,22 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @note it doesn't implemented on Web * @param {Boolean} enable set true to enable dpad focus navigation, otherwise disable dpad focus navigation */ - enableDpadNavigation: function(enable){}, + enableDpadNavigation: function(enable){ + if (enable){ + if (null == ccui.Widget._focusNavigationController) { + ccui.Widget._focusNavigationController = new ccui._FocusNavigationController(); + if (this._focusedWidget) { + ccui.Widget._focusNavigationController._setFirstFocsuedWidget(ccui.Widget._focusedWidget); + } + } + ccui.Widget._focusNavigationController.enableFocusNavigation(true); + } else { + if(ccui.Widget._focusNavigationController){ + ccui.Widget._focusNavigationController.enableFocusNavigation(false); + ccui.Widget._focusNavigationController = null; + } + } + }, /** *

    @@ -1857,6 +1935,7 @@ ccui.Widget.create = function () { }; ccui.Widget._focusedWidget = null; //both layout & widget will be stored in this variable +ccui.Widget._focusNavigationController = null; /** * Gets the focused widget of current stage. @@ -1995,22 +2074,3 @@ ccui.Widget.POSITION_ABSOLUTE = 0; * @type {number} */ ccui.Widget.POSITION_PERCENT = 1; - -/** - * The widget focus event. - * @class - * @extends cc.Event - */ -cc.EventFocus = cc.Event.extend(/** @lends cc.EventFocus# */{ - _widgetGetFocus: null, - _widgetLoseFocus: null, - /** - * Constructor function. - * @param {ccui.Widget} widgetLoseFocus - * @param {ccui.Widget} widgetGetFocus - */ - ctor: function(widgetLoseFocus, widgetGetFocus){ - this._widgetGetFocus = widgetGetFocus; - this._widgetLoseFocus = widgetLoseFocus; - } -}); \ No newline at end of file From 39adb05cee55145229d415bd1f516747f81242d1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 15 Jan 2015 17:10:46 +0800 Subject: [PATCH 1215/1564] Fixed Widget position error (percent) --- .../UIScale9SpriteCanvasRenderCmd.js | 2 +- .../UIScale9SpriteWebGLRenderCmd.js | 4 +-- extensions/ccui/base-classes/UIWidget.js | 33 +++++-------------- .../ccui/base-classes/UIWidgetRenderCmd.js | 26 +++++++++++++++ 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index e049c5abe6..b6714b5573 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -62,13 +62,13 @@ proto.transform = function(parentCmd){ var node = this._node; + cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); if (node._positionsAreDirty) { node._updatePositions(); node._positionsAreDirty = false; node._scale9Dirty = true; } this._cacheScale9Sprite(); - cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); var children = node._children; for(var i=0; i Date: Thu, 15 Jan 2015 17:37:06 +0800 Subject: [PATCH 1216/1564] UIWidgetRenderCmd webgl error (Missing code) --- extensions/ccui/base-classes/UIWidgetRenderCmd.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/base-classes/UIWidgetRenderCmd.js b/extensions/ccui/base-classes/UIWidgetRenderCmd.js index 5fdff70c21..7e9c18ba8f 100644 --- a/extensions/ccui/base-classes/UIWidgetRenderCmd.js +++ b/extensions/ccui/base-classes/UIWidgetRenderCmd.js @@ -80,7 +80,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { var node = this._node; if (node._visible) { node._adaptRenderers(); - cc.ProtectedNode.CanvasRenderCmd.prototype.transform.call(this, parentCmd, recursive); + + var widgetParent = node.getWidgetParent(); + if (widgetParent) { + var parentSize = widgetParent.getSize(); + node._position.x = parentSize.width * node._positionPercent.x; + node._position.y = parentSize.height * node._positionPercent.y; + } + cc.ProtectedNode.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); } }; })(); From a64593d6bfafa9f9e96c61f6b37525f2dabb6fcc Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 15 Jan 2015 17:37:40 +0800 Subject: [PATCH 1217/1564] UIText add TextColor --- extensions/ccui/uiwidgets/UIText.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 70e4984049..84e7123a70 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -433,15 +433,15 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ setColor: function(color){ cc.ProtectedNode.prototype.setColor.call(this, color); this._labelRenderer.setColor(color); + }, + + setTextColor: function(color){ + this._labelRenderer.setFontFillColor(color); + }, + + getTextColor: function(){ + return this._labelRenderer._getFillStyle(); } - //todo label add setTextColor -// setTextColor: function(color){ -// this._labelRenderer.setTextColor(color); -// }, -// -// getTextColor: function(){ -// return this._labelRenderer.getTextColor(); -// } }); var _p = ccui.Text.prototype; From 9a5af6c0a91299b82ea2eef5264f3e7a01b28306 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 16 Jan 2015 10:31:14 +0800 Subject: [PATCH 1218/1564] Fixed some mistakes for UI focus feature. --- cocos2d/core/event-manager/CCEvent.js | 9 ++++++- cocos2d/core/event-manager/CCEventListener.js | 10 +++++-- cocos2d/core/event-manager/CCEventManager.js | 2 ++ extensions/ccui/base-classes/UIWidget.js | 10 +++---- extensions/ccui/layouts/UILayout.js | 27 +++++++++---------- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/cocos2d/core/event-manager/CCEvent.js b/cocos2d/core/event-manager/CCEvent.js index 91e4d23c5b..fa5c47f5a1 100644 --- a/cocos2d/core/event-manager/CCEvent.js +++ b/cocos2d/core/event-manager/CCEvent.js @@ -106,12 +106,18 @@ cc.Event.ACCELERATION = 2; * @type {number} */ cc.Event.MOUSE = 3; +/** + * The type code of UI focus event. + * @constant + * @type {number} + */ +cc.Event.FOCUS = 4; /** * The type code of Custom event. * @constant * @type {number} */ -cc.Event.CUSTOM = 4; +cc.Event.CUSTOM = 6; /** * The Custom event @@ -436,6 +442,7 @@ cc.EventFocus = cc.Event.extend(/** @lends cc.EventTouch# */{ * @param {ccui.Widget} widgetGetFocus */ ctor: function(widgetLoseFocus, widgetGetFocus){ + cc.Event.prototype.ctor.call(this, cc.Event.FOCUS); this._widgetGetFocus = widgetGetFocus; this._widgetLoseFocus = widgetLoseFocus; } diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 96bee80700..642d7d9e47 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -262,12 +262,18 @@ cc.EventListener.MOUSE = 4; * @type {number} */ cc.EventListener.ACCELERATION = 5; +/** + * The type code of focus event listener. + * @constant + * @type {number} + */ +cc.EventListener.ACCELERATION = 6; /** * The type code of custom event listener. * @constant * @type {number} */ -cc.EventListener.CUSTOM = 6; +cc.EventListener.CUSTOM = 8; /** * The type code of Focus change event listener. @@ -510,4 +516,4 @@ cc._EventListenerFocus = cc.EventListener.extend({ } }); -cc._EventListenerFocus.LISTENER_ID = ""; \ No newline at end of file +cc._EventListenerFocus.LISTENER_ID = "__cc_focus_event"; \ No newline at end of file diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index f827944f7c..f412e20b13 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -83,6 +83,8 @@ cc.__getListenerID = function (event) { return cc._EventListenerKeyboard.LISTENER_ID; if(getType === eventType.MOUSE) return cc._EventListenerMouse.LISTENER_ID; + if(getType === eventType.FOCUS) + return cc._EventListenerFocus.LISTENER_ID; if(getType === eventType.TOUCH){ // Touch listener is very special, it contains two kinds of listeners, EventListenerTouchOneByOne and EventListenerTouchAllAtOnce. // return UNKNOWN instead. diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index ec2c3422dd..c1ee916a4d 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -64,7 +64,7 @@ ccui._FocusNavigationController = cc.Class.extend({ _addKeyboardEventListener: function(){ if (!this._keyboardListener) { this._keyboardListener = cc.EventListener.create({ - event: cc.EventListener.FOCUS, + event: cc.EventListener.KEYBOARD, onKeyReleased: this._onKeyPressed.bind(this) }); cc.eventManager.addListener(this._keyboardListener, this._keyboardEventPriority); @@ -761,7 +761,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var isLayout = current instanceof ccui.Layout; if (this.isFocused() || isLayout) { var layout = this.getParent(); - if (null == layout){ + if (null == layout || !(layout instanceof ccui.Layout)){ //the outer layout's default behaviour is : loop focus if (isLayout) return current.findNextFocusedWidget(direction, current); @@ -802,7 +802,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (enable){ if (null == ccui.Widget._focusNavigationController) { ccui.Widget._focusNavigationController = new ccui._FocusNavigationController(); - if (this._focusedWidget) { + if (ccui.Widget._focusedWidget) { ccui.Widget._focusNavigationController._setFirstFocsuedWidget(ccui.Widget._focusedWidget); } } @@ -1999,13 +1999,13 @@ ccui.Widget.RIGHT = 1; * @constant * @type {number} */ -ccui.Widget.UP = 0; +ccui.Widget.UP = 2; /** * The down of Focus direction for ccui.Widget * @constant * @type {number} */ -ccui.Widget.DOWN = 1; +ccui.Widget.DOWN = 3; //texture resource type /** diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 4a6273aeac..08bb627824 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -66,7 +66,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ _backGroundImageOpacity:0, _loopFocus: false, //whether enable loop focus or not - __passFocusToChild: false, //on default, it will pass the focus to the next nearest widget + __passFocusToChild: true, //on default, it will pass the focus to the next nearest widget _isFocusPassing:false, //when finding the next focused widget, use this variable to pass focus between layout & widget _isInterceptTouch: false, @@ -162,7 +162,6 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (this._isFocusPassing || this.isFocused()) { var parent = this.getParent(); this._isFocusPassing = false; - if (this.__passFocusToChild) { var w = this._passFocusToChild(direction, current); if (w instanceof ccui.Layout && parent) { @@ -172,7 +171,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return w; } - if (null == parent) + if (null == parent || !(parent instanceof ccui.Layout)) return this; parent._isFocusPassing = true; return parent.findNextFocusedWidget(direction, this); @@ -189,10 +188,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Widget.UP: if (this._isLastWidgetInContainer(this, direction)){ if (this._isWidgetAncestorSupportLoopFocus(current, direction)) - return this.findNextFocusedWidget(direction, this); + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); return current; } else { - return this.findNextFocusedWidget(direction, this); + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); } break; default: @@ -205,11 +204,11 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ case ccui.Widget.RIGHT: if (this._isLastWidgetInContainer(this, direction)) { if (this._isWidgetAncestorSupportLoopFocus(current, direction)) - return this.findNextFocusedWidget(direction, this); + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); return current; } else - return this.findNextFocusedWidget(direction, this); + return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); break; case ccui.Widget.DOWN: return this._getNextFocusedWidget(direction, current); @@ -1094,7 +1093,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if(widget) return widget; } else{ - if (child instanceof cc.Widget) + if (child instanceof ccui.Widget) return child; } } @@ -1190,12 +1189,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } else return this._getNextFocusedWidget(direction, nextWidget); } else - return (current instanceof ccui.Layout) ? current : this._focusedWidget; + return (current instanceof ccui.Layout) ? current : ccui.Widget._focusedWidget; } else{ if (this._isLastWidgetInContainer(current, direction)){ if (this._isWidgetAncestorSupportLoopFocus(this, direction)) return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); - return (current instanceof ccui.Layout) ? current : this._focusedWidget; + return (current instanceof ccui.Layout) ? current : ccui.Widget._focusedWidget; } else return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); } @@ -1240,12 +1239,12 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ } else return this._getPreviousFocusedWidget(direction, nextWidget); } else - return (current instanceof ccui.Layout) ? current : this._focusedWidget; + return (current instanceof ccui.Layout) ? current : ccui.Widget._focusedWidget; } else { if (this._isLastWidgetInContainer(current, direction)) { if (this._isWidgetAncestorSupportLoopFocus(this, direction)) return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); - return (current instanceof ccui.Layout) ? current : this._focusedWidget; + return (current instanceof ccui.Layout) ? current : ccui.Widget._focusedWidget; } else return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, this); } @@ -1289,7 +1288,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ _isLastWidgetInContainer:function(widget, direction){ var parent = widget.getParent(); - if (parent instanceof ccui.Layout) + if (parent == null || !(parent instanceof ccui.Layout)) return true; var container = parent.getChildren(); @@ -1345,7 +1344,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ */ _isWidgetAncestorSupportLoopFocus: function(widget, direction){ var parent = widget.getParent(); - if (parent == null) + if (parent == null || !(parent instanceof ccui.Layout)) return false; if (parent.isLoopFocus()) { var layoutType = parent.getLayoutType(); From c5adc50c7f8c5d4d283f7c77ffe204d5dc40e89b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 16 Jan 2015 10:42:03 +0800 Subject: [PATCH 1219/1564] Modify the ui texture callback --- extensions/ccui/uiwidgets/UIButton.js | 28 +++---------------- extensions/ccui/uiwidgets/UICheckBox.js | 33 ++++------------------- extensions/ccui/uiwidgets/UIImageView.js | 11 +------- extensions/ccui/uiwidgets/UILoadingBar.js | 24 +---------------- extensions/ccui/uiwidgets/UISlider.js | 21 ++++----------- extensions/ccui/uiwidgets/UITextBMFont.js | 2 +- 6 files changed, 16 insertions(+), 103 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 6dba636038..2280b6eccd 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -254,17 +254,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var self = this; if(!this._buttonNormalRenderer.texture || !this._buttonNormalRenderer.texture.isLoaded()){ this._buttonNormalRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._normalTextureSize = self._buttonNormalRenderer.getContentSize(); - self._updateChildrenDisplayedRGBA(); - - self._buttonNormalRenderer.setColor(self.getColor()); - self._buttonNormalRenderer.setOpacity(self.getOpacity()); - - self._updateContentSizeWithTextureSize(self._normalTextureSize); - self._normalTextureLoaded = true; - self._normalTextureAdaptDirty = true; + self.loadTextureNormal(normal, texType); }); } @@ -311,13 +301,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var self = this; if(!this._buttonClickedRenderer.texture || !this._buttonClickedRenderer.texture.isLoaded()){ this._buttonClickedRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._pressedTextureSize = self._buttonClickedRenderer.getContentSize(); - self._updateChildrenDisplayedRGBA(); - - self._pressedTextureLoaded = true; - self._pressedTextureAdaptDirty = true; + self.loadTexturePressed(selected, texType); }); } @@ -361,13 +345,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var self = this; if(!this._buttonDisableRenderer.texture || !this._buttonDisableRenderer.texture.isLoaded()){ this._buttonDisableRenderer.addEventListener("load", function() { - self._findLayout(); - - self._disabledTextureSize = self._buttonDisableRenderer.getContentSize(); - self._updateChildrenDisplayedRGBA(); - - self._disabledTextureLoaded = true; - self._disabledTextureAdaptDirty = true; + self.loadTextureDisabled(disabled, texType); }); } diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 56639a17cf..9b5364ab7e 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -154,11 +154,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!bgBoxRenderer.texture || !bgBoxRenderer.texture.isLoaded()){ bgBoxRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._updateChildrenDisplayedRGBA(); - self._updateContentSizeWithTextureSize(self._backGroundBoxRenderer.getContentSize()); - self._backGroundBoxRendererAdaptDirty = true; + self.loadTextureBackGround(backGround, texType); }); } @@ -175,13 +171,6 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ break; } - if (!bgBoxRenderer.textureLoaded()) { - this._backGroundBoxRenderer.setContentSize(this._customSize); - bgBoxRenderer.addEventListener("load", function () { - this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); - }, this); - } - this._updateChildrenDisplayedRGBA(); this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); @@ -204,10 +193,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._backGroundSelectedBoxRenderer.texture || !this._backGroundSelectedBoxRenderer.texture.isLoaded()){ this._backGroundSelectedBoxRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._updateChildrenDisplayedRGBA(); - self._backGroundSelectedBoxRendererAdaptDirty = true; + self.loadTextureBackGroundSelected(backGroundSelected, texType); }); } @@ -245,10 +231,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._frontCrossRenderer.texture || !this._frontCrossRenderer.texture.isLoaded()){ this._frontCrossRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._updateChildrenDisplayedRGBA(); - self._frontCrossRendererAdaptDirty = true; + self.loadTextureFrontCross(cross, texType); }); } @@ -285,10 +268,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._backGroundBoxDisabledRenderer.texture || !this._backGroundBoxDisabledRenderer.texture.isLoaded()){ this._backGroundBoxDisabledRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._updateChildrenDisplayedRGBA(); - self._backGroundBoxDisabledRendererAdaptDirty = true; + self.loadTextureBackGroundDisabled(backGroundDisabled, texType); }); } @@ -325,10 +305,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var self = this; if(!this._frontCrossDisabledRenderer.texture || !this._frontCrossDisabledRenderer.texture.isLoaded()){ this._frontCrossDisabledRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._updateChildrenDisplayedRGBA(); - self._frontCrossDisabledRendererAdaptDirty = true; + self.loadTextureFrontCrossDisabled(frontCrossDisabled, texType); }); } diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 9a743dff29..0aa6e71b28 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -102,16 +102,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ imageRenderer.addEventListener("load", function(){ - self._findLayout(); - - self._imageTextureSize = imageRenderer.getContentSize(); - - self._updateChildrenDisplayedRGBA(); - - self._updateContentSizeWithTextureSize(self._imageTextureSize); - if(self._scale9Enabled) - self.setCapInsets(self._capInsets); - self._imageRendererAdaptDirty = true; + self.loadTexture(fileName, texType); }); } diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index ed28c83720..2d6467a9c5 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -124,29 +124,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ var self = this; if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ barRenderer.addEventListener("load", function(){ - - self._findLayout(); - - var bz = barRenderer.getContentSize(); - self._barRendererTextureSize.width = bz.width; - self._barRendererTextureSize.height = bz.height; - - switch (self._direction) { - case ccui.LoadingBar.TYPE_LEFT: - barRenderer.setAnchorPoint(0.0,0.5); - if (!self._scale9Enabled) - barRenderer/*.getSprite()*/.setFlippedX(false); - break; - case ccui.LoadingBar.TYPE_RIGHT: - barRenderer.setAnchorPoint(1.0,0.5); - if (!self._scale9Enabled) - barRenderer/*.getSprite()*/.setFlippedX(true); - break; - } - self._updateChildrenDisplayedRGBA(); - self._barRendererScaleChangedWithSize(); - self._updateContentSizeWithTextureSize(self._barRendererTextureSize); - self._barRendererAdaptDirty = true; + self.loadTexture(texture, texType); }); } diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index c2feccd6b6..292e53dea0 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -127,12 +127,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ barRenderer.addEventListener("load", function(){ - self._findLayout(); - self._updateChildrenDisplayedRGBA(); - - self._barRendererAdaptDirty = true; - self._progressBarRendererDirty = true; - self._updateContentSizeWithTextureSize(self._barRenderer.getContentSize()); + self.loadBarTexture(fileName, texType); }); } @@ -172,13 +167,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!progressBarRenderer.texture || !progressBarRenderer.texture.isLoaded()){ progressBarRenderer.addEventListener("load", function(){ - self._findLayout(); - self._updateChildrenDisplayedRGBA(); - - self._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5)); - var tz = self._progressBarRenderer.getContentSize(); - self._progressBarTextureSize = {width: tz.width, height: tz.height}; - self._progressBarRendererDirty = true; + self.loadProgressBarTexture(fileName, texType); }); } @@ -345,7 +334,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallNormalRenderer.texture || !this._slidBallNormalRenderer.texture.isLoaded()){ this._slidBallNormalRenderer.addEventListener("load", function(){ - self._updateChildrenDisplayedRGBA(); + self.loadSlidBallTextureNormal(normal, texType); }); } @@ -380,7 +369,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallPressedRenderer.texture || !this._slidBallPressedRenderer.texture.isLoaded()){ this._slidBallPressedRenderer.addEventListener("load", function(){ - self._updateChildrenDisplayedRGBA(); + self.loadSlidBallTexturePressed(pressed, texType); }); } @@ -415,7 +404,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallDisabledRenderer.texture || !this._slidBallDisabledRenderer.texture.isLoaded()){ this._slidBallDisabledRenderer.addEventListener("load", function(){ - self._updateChildrenDisplayedRGBA(); + self.loadSlidBallTextureDisabled(disabled, texType); }); } diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index 0175981964..e659906ebd 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -78,7 +78,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo var locRenderer = _self._labelBMFontRenderer; if(!locRenderer._textureLoaded){ locRenderer.addEventListener("load", function(){ - _self.updateSizeAndPosition(); + _self.setFntFile(fileName); }); } }, From 8f793826f962f2db9d13542eedf8096f5c5f4fba Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 16 Jan 2015 14:39:09 +0800 Subject: [PATCH 1220/1564] Fixed a bug of ccui.Widget that its percent position doesn't work --- extensions/ccui/base-classes/UIWidget.js | 44 +++++++++---------- .../ccui/base-classes/UIWidgetRenderCmd.js | 33 ++++++++------ 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index ab0fb1dd44..4a6d48d56b 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -793,28 +793,6 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return ccui.Widget._focusedWidget; }, - /** - * call this method with parameter true to enable the Android Dpad focus navigation feature - * @note it doesn't implemented on Web - * @param {Boolean} enable set true to enable dpad focus navigation, otherwise disable dpad focus navigation - */ - enableDpadNavigation: function(enable){ - if (enable){ - if (null == ccui.Widget._focusNavigationController) { - ccui.Widget._focusNavigationController = new ccui._FocusNavigationController(); - if (ccui.Widget._focusedWidget) { - ccui.Widget._focusNavigationController._setFirstFocsuedWidget(ccui.Widget._focusedWidget); - } - } - ccui.Widget._focusNavigationController.enableFocusNavigation(true); - } else { - if(ccui.Widget._focusNavigationController){ - ccui.Widget._focusNavigationController.enableFocusNavigation(false); - ccui.Widget._focusNavigationController = null; - } - } - }, - /** *

    * When a widget lose/get focus, this method will be called. Be Caution when you provide your own version,
    @@ -1920,6 +1898,28 @@ ccui.Widget.create = function () { ccui.Widget._focusedWidget = null; //both layout & widget will be stored in this variable ccui.Widget._focusNavigationController = null; +/** + * call this method with parameter true to enable the Android Dpad focus navigation feature + * @note it doesn't implemented on Web + * @param {Boolean} enable set true to enable dpad focus navigation, otherwise disable dpad focus navigation + */ +ccui.Widget.enableDpadNavigation = function(enable){ + if (enable){ + if (null == ccui.Widget._focusNavigationController) { + ccui.Widget._focusNavigationController = new ccui._FocusNavigationController(); + if (ccui.Widget._focusedWidget) { + ccui.Widget._focusNavigationController._setFirstFocsuedWidget(ccui.Widget._focusedWidget); + } + } + ccui.Widget._focusNavigationController.enableFocusNavigation(true); + } else { + if(ccui.Widget._focusNavigationController){ + ccui.Widget._focusNavigationController.enableFocusNavigation(false); + ccui.Widget._focusNavigationController = null; + } + } +}; + /** * Gets the focused widget of current stage. * @function diff --git a/extensions/ccui/base-classes/UIWidgetRenderCmd.js b/extensions/ccui/base-classes/UIWidgetRenderCmd.js index 7e9c18ba8f..3faca0b751 100644 --- a/extensions/ccui/base-classes/UIWidgetRenderCmd.js +++ b/extensions/ccui/base-classes/UIWidgetRenderCmd.js @@ -40,22 +40,23 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { } }; - proto.transform = function(parentCmd, recursive){ + proto.transform = function (parentCmd, recursive) { var node = this._node; if (node._visible) { node._adaptRenderers(); - - var widgetParent = node.getWidgetParent(); - if (widgetParent) { - var parentSize = widgetParent.getSize(); - node._position.x = parentSize.width * node._positionPercent.x; - node._position.y = parentSize.height * node._positionPercent.y; + if(!this._usingLayoutComponent){ + var widgetParent = node.getWidgetParent(); + if (widgetParent) { + var parentSize = widgetParent.getContentSize(); + if (parentSize.width !== 0 && parentSize.height !== 0) { + node._position.x = parentSize.width * node._positionPercent.x; + node._position.y = parentSize.height * node._positionPercent.y; + } + } } - cc.ProtectedNode.CanvasRenderCmd.prototype.transform.call(this, parentCmd, recursive); } - }; })(); } else { @@ -81,11 +82,15 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if (node._visible) { node._adaptRenderers(); - var widgetParent = node.getWidgetParent(); - if (widgetParent) { - var parentSize = widgetParent.getSize(); - node._position.x = parentSize.width * node._positionPercent.x; - node._position.y = parentSize.height * node._positionPercent.y; + if(!this._usingLayoutComponent) { + var widgetParent = node.getWidgetParent(); + if (widgetParent) { + var parentSize = widgetParent.getContentSize(); + if (parentSize.width !== 0 && parentSize.height !== 0) { + node._position.x = parentSize.width * node._positionPercent.x; + node._position.y = parentSize.height * node._positionPercent.y; + } + } } cc.ProtectedNode.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); } From c652b3e63b004e3571fd5a980d230f9788108d58 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 16 Jan 2015 16:00:25 +0800 Subject: [PATCH 1221/1564] Improve Cocos Studio Parser --- .../cocostudio/loader/parsers/action-2.x.js | 4 ++-- .../cocostudio/loader/parsers/scene-1.x.js | 4 ++-- .../loader/parsers/timelineParser-1.x.js | 4 ++-- .../loader/parsers/timelineParser-2.x.js | 18 +++++++++--------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 41b52895b5..07c907192d 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -57,7 +57,7 @@ }); cache[file] = action; - + cache[file].retain(); return action.clone(); } @@ -226,4 +226,4 @@ load.registerParser("action", "2.*", parser); -})(ccs._load, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); diff --git a/extensions/cocostudio/loader/parsers/scene-1.x.js b/extensions/cocostudio/loader/parsers/scene-1.x.js index 616350c613..aad9b5a73b 100644 --- a/extensions/cocostudio/loader/parsers/scene-1.x.js +++ b/extensions/cocostudio/loader/parsers/scene-1.x.js @@ -217,7 +217,7 @@ cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); }else{ if(!loadedPlist[resourcePath + plist]) - cc.log("%s need to be pre loaded", resourcePath + plist); + cc.log("%s need to be preloaded", resourcePath + plist); } } if(type !== 0) @@ -259,4 +259,4 @@ load.registerParser("scene", "*", parser); -})(ccs._load, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); diff --git a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js index b157859934..e5f6b8ef8e 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -38,7 +38,7 @@ for (var i = 0; i < plists.length; i++) { var plist = resourcePath + plists[i]; if(!cc.loader.getRes(plist) && !loadedPlist[plist]) - cc.log("%s need to be pre loaded", plist); + cc.log("%s need to be preloaded", plist); else loadedPlist[plist] = true; cc.spriteFrameCache.addSpriteFrames( @@ -288,4 +288,4 @@ load.registerParser("timeline", "*", parser); -})(ccs._load, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 434114428d..4164b7f852 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -194,10 +194,10 @@ self = this; loadTexture(json["FileData"], resourcePath, function(path, type){ if(!cc.loader.getRes(path)) - cc.log("%s need to be pre loaded", path); + cc.log("%s need to be preloaded", path); node = new cc.ParticleSystem(path); self.generalAttributes(node, json); - node.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); + !cc.sys.isNative && node.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); }); return node; }; @@ -767,7 +767,7 @@ textureList.forEach(function(item){ loadTexture(json[item.name], resourcePath, function(path, type){ if(type == 0 && !loader.getRes(path)) - cc.log("%s need to be pre loaded", path); + cc.log("%s need to be preloaded", path); item.handle.call(widget, path, type); }); }); @@ -954,7 +954,7 @@ loadTexture(json["LabelAtlasFileImage_CNB"], resourcePath, function(path, type){ if(!cc.loader.getRes(path)) - cc.log("%s need to be pre loaded", path); + cc.log("%s need to be preloaded", path); if(type == 0){ widget.setProperty(stringValue, path, itemWidth, itemHeight, startCharMap); } @@ -1104,7 +1104,7 @@ if(cc.loader.getRes(file)) return ccs._load(file); else - cc.log("%s need to be pre loaded", file); + cc.log("%s need to be preloaded", file); } }; @@ -1136,13 +1136,13 @@ var plists, pngs; var armJson = cc.loader.getRes(path); if(!armJson) - cc.log("%s need to be pre loaded", path); + cc.log("%s need to be preloaded", path); else{ plists = armJson["config_file_path"]; pngs = armJson["config_png_path"]; plists.forEach(function(plist, index){ if(pngs[index]) - cc.spriteFrameCache.addSpriteFrame(plist, pngs[index]); + cc.spriteFrameCache.addSpriteFrames(plist, pngs[index]); }); } ccs.armatureDataManager.addArmatureFileInfo(path); @@ -1170,7 +1170,7 @@ cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); }else{ if(!loadedPlist[resourcePath + plist]) - cc.log("%s need to be pre loaded", resourcePath + plist); + cc.log("%s need to be preloaded", resourcePath + plist); } } if(type !== 0) @@ -1231,4 +1231,4 @@ load.registerParser("timeline", "2.*", parser); -})(ccs._load, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); From a80dab2d6caa8d302b47e7ca0f58050e200c5419 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 16 Jan 2015 16:18:40 +0800 Subject: [PATCH 1222/1564] Fix private property usage --- cocos2d/core/sprites/CCSpriteFrameCache.js | 1 - extensions/cocostudio/loader/parsers/action-2.x.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index b65f265cda..79321e5327 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -330,7 +330,6 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ if(!frame) delete self._spriteFramesAliases[name]; } } - if (!frame) cc.log(cc._LogInfos.spriteFrameCache_getSpriteFrame, name); return frame; }, diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 07c907192d..25953fde53 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -176,7 +176,7 @@ var texture = options["TextureFile"]; if(texture != null) { var path = texture["Path"]; - var spriteFrame = cc.spriteFrameCache._spriteFrames[path]; + var spriteFrame = cc.spriteFrameCache.getSpriteFrames(path); if(spriteFrame == null){ path = resourcePath + path; } From 6e29c22a618e8050b7d0a0ae875e8102925d5d31 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 16 Jan 2015 16:23:17 +0800 Subject: [PATCH 1223/1564] Fixed UISlider bug --- extensions/ccui/uiwidgets/UISlider.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 292e53dea0..3d62508907 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -61,6 +61,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _barRendererAdaptDirty: true, _progressBarRendererDirty: true, _unifySize: false, + _zoomScale: 0.1, _sliderBallNormalTextureScaleX: 1, _sliderBallNormalTextureScaleY: 1, @@ -72,11 +73,16 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * // example * var uiSlider = new ccui.Slider(); */ - ctor: function () { + ctor: function (barTextureName, normalBallTextureName, resType) { this._progressBarTextureSize = cc.size(0, 0); this._capInsetsBarRenderer = cc.rect(0, 0, 0, 0); this._capInsetsProgressBarRenderer = cc.rect(0, 0, 0, 0); ccui.Widget.prototype.ctor.call(this); + + resType = resType == null ? 0 : resType; + this.setTouchEnabled(true); + barTextureName && this.loadBarTexture(barTextureName, resType); + normalBallTextureName && this.loadSlidBallTextures(normalBallTextureName, resType); }, /** @@ -712,8 +718,8 @@ _p = null; * @deprecated since v3.0, please use new ccui.Slider() instead. * @return {ccui.Slider} */ -ccui.Slider.create = function () { - return new ccui.Slider(); +ccui.Slider.create = function (barTextureName, normalBallTextureName, resType) { + return new ccui.Slider(barTextureName, normalBallTextureName, resType); }; // Constant From 8ac57078a7d400120c39702a70af2aecbcb2a31f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 16 Jan 2015 16:46:19 +0800 Subject: [PATCH 1224/1564] Fix typo --- extensions/cocostudio/loader/parsers/action-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 25953fde53..f57709f8ad 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -176,7 +176,7 @@ var texture = options["TextureFile"]; if(texture != null) { var path = texture["Path"]; - var spriteFrame = cc.spriteFrameCache.getSpriteFrames(path); + var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); if(spriteFrame == null){ path = resourcePath + path; } From ebb1b77d8f62a869f3ac8f8bc50b1fbbf2f95529 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 16 Jan 2015 17:32:27 +0800 Subject: [PATCH 1225/1564] add _findLayout function --- extensions/ccui/uiwidgets/UIButton.js | 3 +++ extensions/ccui/uiwidgets/UICheckBox.js | 5 +++++ extensions/ccui/uiwidgets/UIImageView.js | 2 ++ extensions/ccui/uiwidgets/UILoadingBar.js | 1 + extensions/ccui/uiwidgets/UISlider.js | 5 +++++ 5 files changed, 16 insertions(+) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 2280b6eccd..d762e528c2 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -284,6 +284,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._normalTextureLoaded = true; this._normalTextureAdaptDirty = true; + this._findLayout(); }, /** @@ -327,6 +328,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._pressedTextureLoaded = true; this._pressedTextureAdaptDirty = true; + this._findLayout(); }, /** @@ -371,6 +373,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._disabledTextureLoaded = true; this._disabledTextureAdaptDirty = true; + this._findLayout(); }, /** diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 9b5364ab7e..a1383533a9 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -175,6 +175,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); this._backGroundBoxRendererAdaptDirty = true; + this._findLayout(); }, /** @@ -214,6 +215,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateChildrenDisplayedRGBA(); this._backGroundSelectedBoxRendererAdaptDirty = true; + this._findLayout(); }, /** @@ -251,6 +253,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateChildrenDisplayedRGBA(); this._frontCrossRendererAdaptDirty = true; + this._findLayout(); }, /** @@ -288,6 +291,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateChildrenDisplayedRGBA(); this._backGroundBoxDisabledRendererAdaptDirty = true; + this._findLayout(); }, /** @@ -325,6 +329,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._updateChildrenDisplayedRGBA(); this._frontCrossDisabledRendererAdaptDirty = true; + this._findLayout(); }, _onPressStateChangedToNormal: function () { diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 0aa6e71b28..2cb7325868 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -135,6 +135,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ self._updateContentSizeWithTextureSize(self._imageTextureSize); self._imageRendererAdaptDirty = true; + self._findLayout(); + }, /** diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 2d6467a9c5..86bb631dbb 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -162,6 +162,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this._barRendererScaleChangedWithSize(); this._updateContentSizeWithTextureSize(this._barRendererTextureSize); this._barRendererAdaptDirty = true; + this._findLayout(); }, /** diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 3d62508907..b629b87196 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -154,6 +154,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barRendererAdaptDirty = true; this._progressBarRendererDirty = true; this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); + this._findLayout(); }, /** @@ -195,6 +196,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var tz = this._progressBarRenderer.getContentSize(); this._progressBarTextureSize = {width: tz.width, height: tz.height}; this._progressBarRendererDirty = true; + this._findLayout(); }, /** @@ -357,6 +359,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ break; } this._updateChildrenDisplayedRGBA(); + this._findLayout(); }, /** @@ -392,6 +395,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ break; } this._updateChildrenDisplayedRGBA(); + this._findLayout(); }, /** @@ -427,6 +431,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ break; } this._updateChildrenDisplayedRGBA(); + this._findLayout(); }, /** From e94c40d32b3bfd4f3ac66d462db28477d7a4fe6a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 19 Jan 2015 10:20:35 +0800 Subject: [PATCH 1226/1564] setContentSize doesn't changed texture for UIImageView --- extensions/ccui/layouts/UILayoutComponent.js | 2 +- extensions/ccui/uiwidgets/UIImageView.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index 73fbdff28b..19f3c2158a 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -207,7 +207,7 @@ ccui.LayoutComponent = cc.Component.extend({ }, setHorizontalEdge: function (hEdge) { this._horizontalEdge = hEdge; - if (this._horizontalEdge != cc.LayoutComponent.horizontalEdge.NONE) + if (this._horizontalEdge != ccui.LayoutComponent.horizontalEdge.NONE) this._usingPositionPercentX = false; var parent = this._getOwnerParent(); diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 2cb7325868..d99cb41dcd 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -303,7 +303,10 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if(height) contentSize = cc.size(contentSize, height); ccui.Widget.prototype.setContentSize.call(this, contentSize); - this._imageRenderer.setContentSize(contentSize); + var iContentSize = this._imageRenderer.getContentSize(); + this._imageRenderer.setScaleX(contentSize.width / iContentSize.width); + this._imageRenderer.setScaleY(contentSize.height / iContentSize.height); + } }); From 047b0d29fcd22143af9a9fa8473aef41c5f9697f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 19 Jan 2015 13:59:40 +0800 Subject: [PATCH 1227/1564] setContentSize doesn't changed texture for UIImageView --- extensions/ccui/uiwidgets/UIImageView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index d99cb41dcd..5997c70d24 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -300,7 +300,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ * @override */ setContentSize: function(contentSize, height){ - if(height) + if(height != null) contentSize = cc.size(contentSize, height); ccui.Widget.prototype.setContentSize.call(this, contentSize); var iContentSize = this._imageRenderer.getContentSize(); From 6e2b6e4266acee888940fa5f94bbd4f3148dd05b Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Mon, 19 Jan 2015 14:15:54 +0800 Subject: [PATCH 1228/1564] issue #1260:arranging the key code make it same with jsb key code --- cocos2d/core/platform/CCCommon.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index a15cca1ede..9eeac574b5 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -52,15 +52,25 @@ cc.associateWithNative = function (jsObj, superclass) { }, this); */ cc.KEY = { + none:0, + + // android + back:6, + menu:18, + backspace:8, tab:9, + enter:13, + shift:16, //should use shiftkey instead ctrl:17, //should use ctrlkey alt:18, //should use altkey pause:19, capslock:20, + escape:27, + space:32, pageup:33, pagedown:34, end:35, @@ -69,6 +79,8 @@ cc.KEY = { up:38, right:39, down:40, + select:41, + insert:45, Delete:46, 0:48, @@ -107,6 +119,7 @@ cc.KEY = { x:88, y:89, z:90, + num0:96, num1:97, num2:98, @@ -134,8 +147,10 @@ cc.KEY = { f10:121, f11:122, f12:123, + numlock:144, scrolllock:145, + semicolon:186, ',':186, equal:187, @@ -149,11 +164,10 @@ cc.KEY = { grave:192, '[':219, openbracket:219, + backslash:220, ']':221, closebracket:221, - backslash:220, - quote:222, - space:32 + quote:222 }; /** From 275761f003f6d08aff4d7b2031de64e630e36b38 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 19 Jan 2015 14:22:54 +0800 Subject: [PATCH 1229/1564] setContentSize doesn't changed texture for UIImageView --- extensions/ccui/uiwidgets/UIImageView.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 5997c70d24..b8b8ad9029 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -303,9 +303,11 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if(height != null) contentSize = cc.size(contentSize, height); ccui.Widget.prototype.setContentSize.call(this, contentSize); - var iContentSize = this._imageRenderer.getContentSize(); - this._imageRenderer.setScaleX(contentSize.width / iContentSize.width); - this._imageRenderer.setScaleY(contentSize.height / iContentSize.height); + if(!this._scale9Enabled){ + var iContentSize = this._imageRenderer.getContentSize(); + this._imageRenderer.setScaleX(contentSize.width / iContentSize.width); + this._imageRenderer.setScaleY(contentSize.height / iContentSize.height); + } } From 264fbbbce296c416017db1d021b66bcdab979e02 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 19 Jan 2015 14:23:37 +0800 Subject: [PATCH 1230/1564] Fixed some mistakes of ccui.Button --- cocos2d/core/base-nodes/CCNode.js | 4 ++ .../UIScale9SpriteCanvasRenderCmd.js | 13 ++--- extensions/ccui/uiwidgets/UIButton.js | 48 +++++++++++-------- extensions/ccui/uiwidgets/UISlider.js | 1 + 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index ec7988b01d..91b49f0d40 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -649,9 +649,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ setPosition: function (newPosOrxValue, yValue) { var locPosition = this._position; if (yValue === undefined) { + if(locPosition.x === newPosOrxValue.x && locPosition.y === newPosOrxValue.y) + return; locPosition.x = newPosOrxValue.x; locPosition.y = newPosOrxValue.y; } else { + if(locPosition.x === newPosOrxValue.x && locPosition.y === yValue) + return; locPosition.x = newPosOrxValue; locPosition.y = yValue; } diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index b6714b5573..535451aca2 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -27,6 +27,7 @@ cc.Node.CanvasRenderCmd.call(this, renderable); this._cachedParent = null; this._cacheDirty = false; + this._state = ccui.Scale9Sprite.state.NORMAL; var node = this._node; var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); @@ -115,9 +116,14 @@ node._scale9Image.visit(); //draw to cache canvas + var selTexture = node._scale9Image.getTexture(); + if(selTexture && this._state === ccui.Scale9Sprite.state.NORMAL) + selTexture._switchToGray(true); locContext.setTransform(1, 0, 0, 1, 0, 0); locContext.clearRect(0, 0, sizeInPixels.width, sizeInPixels.height); cc.renderer._renderingToCacheCanvas(wrapper, node.__instanceId, locScaleFactor, locScaleFactor); + if(selTexture && this._state === ccui.Scale9Sprite.state.NORMAL) + selTexture._switchToGray(false); if(contentSizeChanged) this._cacheSprite.setTextureRect(cc.rect(0,0, size.width, size.height)); @@ -130,12 +136,7 @@ var locScale9Image = this._node._scale9Image; if(!locScale9Image) return; - var selTexture = locScale9Image.getTexture(); - if(state === ccui.Scale9Sprite.state.NORMAL){ - selTexture._switchToGray(false); - } else if( state === ccui.Scale9Sprite.state.GRAY){ - selTexture._switchToGray(true); - } + this._state = state; this._cacheScale9Sprite(); }; })(); \ No newline at end of file diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 6dba636038..51ead262dd 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -103,8 +103,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._titleColor = cc.color.WHITE; ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); - - texType !== undefined && this.init(normalImage, selectedImage, disableImage, texType); + this.init(normalImage, selectedImage, disableImage, texType); }, /** @@ -218,7 +217,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ getVirtualRendererSize: function(){ if (this._unifySize) - return this.getNormalSize(); + return this._getNormalSize(); if (!this._normalTextureLoaded && this._titleRenderer.getString().length > 0) { return this._titleRenderer.getContentSize(); @@ -287,7 +286,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this._unifySize){ if (this._scale9Enabled){ normalRenderer.setCapInsets(this._capInsetsNormal); - this._updateContentSizeWithTextureSize(this.getNormalSize()); + this._updateContentSizeWithTextureSize(this._getNormalSize()); } }else this._updateContentSizeWithTextureSize(this._normalTextureSize); @@ -302,7 +301,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexturePressed: function (selected, texType) { - if (!selected) + if (!selected || (this._clickedFileName == selected && this._pressedTexType == texType)) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._clickedFileName = selected; @@ -527,7 +526,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this.pressedActionEnabled){ this._buttonNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); - var zoomAction = cc.scaleTo(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + var zoomAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); this._buttonNormalRenderer.runAction(zoomAction); this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); @@ -569,16 +568,16 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this.pressedActionEnabled) { locNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); - var zoomAction = cc.scaleTo(0.05, this._pressedTextureScaleXInSize + 0.1,this._pressedTextureScaleYInSize + 0.1); + var zoomAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, this._pressedTextureScaleXInSize + this._zoomScale, + this._pressedTextureScaleYInSize + this._zoomScale); this._buttonClickedRenderer.runAction(zoomAction); - locNormalRenderer.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1); + locNormalRenderer.setScale(this._pressedTextureScaleXInSize + this._zoomScale, this._pressedTextureScaleYInSize + this._zoomScale); this._titleRenderer.stopAllActions(); if (this._unifySize){ - var zoomTitleAction = cc.scaleTo(0.05, 1 + this._zoomScale, 1 + this._zoomScale); + var zoomTitleAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, 1 + this._zoomScale, 1 + this._zoomScale); this._titleRenderer.runAction(zoomTitleAction); - } - else + } else this._titleRenderer.runAction(zoomAction.clone()); } } else { @@ -586,10 +585,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._buttonClickedRenderer.setVisible(true); this._buttonDisableRenderer.setVisible(false); locNormalRenderer.stopAllActions(); - locNormalRenderer.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1); + locNormalRenderer.setScale(this._normalTextureScaleXInSize + this._zoomScale, this._normalTextureScaleYInSize + this._zoomScale); if (this._scale9Enabled) - locNormalRenderer.setColor(cc.color.GRAY); + locNormalRenderer.setState(ccui.Scale9Sprite.state.GRAY); this._titleRenderer.stopAllActions(); if (this._unifySize){ @@ -599,16 +598,14 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._titleRenderer.setScaleX(this._normalTextureScaleXInSize + this._zoomScale); this._titleRenderer.setScaleY(this._normalTextureScaleYInSize + this._zoomScale); } - } }, _onPressStateChangedToDisabled: function () { - //if disable resource is null if (!this._disabledTextureLoaded){ if (this._normalTextureLoaded && this._scale9Enabled) - this._buttonNormalRenderer.setState(1/*Scale9Sprite::State::GRAY*/); + this._buttonNormalRenderer.setState(ccui.Scale9Sprite.state.GRAY); }else{ this._buttonNormalRenderer.setVisible(false); this._buttonDisableRenderer.setVisible(true); @@ -624,7 +621,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this._scale9Enabled) ccui.ProtectedNode.setContentSize(this._customSize); else{ - var s = this.getNormalSize(); + var s = this._getNormalSize(); ccui.ProtectedNode.setContentSize(s); } this._onSizeChanged(); @@ -807,7 +804,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {cc.Color} color */ setTitleColor: function (color) { - this._titleRenderer.setColor(color); + this._titleRenderer.setFontFillColor(color); }, /** @@ -815,7 +812,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @returns {cc.Color} */ getTitleColor: function () { - return this._titleRenderer.getColor(); + return this._titleRenderer._getFillStyle(); }, /** @@ -835,10 +832,21 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return this._titleRenderer.getFontSize(); }, + /** + * When user pressed the button, the button will zoom to a scale. + * The final scale of the button equals (button original scale + _zoomScale) + * @since v3.2 + * @param scale + */ setZoomScale: function(scale){ this._zoomScale = scale; }, + /** + * Returns a zoom scale + * @since v3.2 + * @returns {number} + */ getZoomScale: function(){ return this._zoomScale; }, @@ -911,7 +919,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._updateTexturesRGBA(); }, - getNormalSize: function(){ + _getNormalSize: function(){ var titleSize; if (this._titleRenderer != null) titleSize = this._titleRenderer.getContentSize(); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index c2feccd6b6..e8fe47eef2 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -77,6 +77,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._capInsetsBarRenderer = cc.rect(0, 0, 0, 0); this._capInsetsProgressBarRenderer = cc.rect(0, 0, 0, 0); ccui.Widget.prototype.ctor.call(this); + this.setTouchEnabled(true); }, /** From bdc82fb8355fc881262e10cbf9930a80ea0b5bcd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 19 Jan 2015 14:26:04 +0800 Subject: [PATCH 1231/1564] setContentSize doesn't changed texture for UIImageView --- extensions/ccui/uiwidgets/UIImageView.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index b8b8ad9029..bfc4c85527 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -307,6 +307,8 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ var iContentSize = this._imageRenderer.getContentSize(); this._imageRenderer.setScaleX(contentSize.width / iContentSize.width); this._imageRenderer.setScaleY(contentSize.height / iContentSize.height); + }else{ + this._imageRenderer.setContentSize(contentSize); } } From f624250c07cd4d4d433ecc24981cd3433014f677 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 19 Jan 2015 16:05:10 +0800 Subject: [PATCH 1232/1564] Fixed a bug of ccui.Widget that its setFocusEnabled doesn't work --- extensions/ccui/base-classes/UIWidget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 4a6d48d56b..2554e18bce 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -744,7 +744,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Boolean} enable true represent the widget could accept focus, false represent the widget couldn't accept focus */ setFocusEnabled: function(enable){ - this._focused = enable; + this._focusEnabled = enable; }, /** From b110682c9395744ffe183899edef1965eddf0dcf Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Mon, 19 Jan 2015 16:35:00 +0800 Subject: [PATCH 1233/1564] issue #1260: fix quote and comma key code error --- cocos2d/core/platform/CCCommon.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index 9eeac574b5..8fdd7d3d84 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -151,11 +151,11 @@ cc.KEY = { numlock:144, scrolllock:145, + ';':186, semicolon:186, - ',':186, equal:187, '=':187, - ';':188, + ',':188, comma:188, dash:189, '.':190, From abc250d7e18b791e82a9e8a0c8c5f3714eece50a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 19 Jan 2015 16:37:46 +0800 Subject: [PATCH 1234/1564] Parameter adaptation (CheckBox) --- extensions/ccui/uiwidgets/UICheckBox.js | 30 ++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index a1383533a9..b86ee96ef0 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -81,6 +81,26 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ ctor: function (backGround, backGroundSelected,cross,backGroundDisabled,frontCrossDisabled,texType) { ccui.Widget.prototype.ctor.call(this); this.setTouchEnabled(true); + var strNum = 0; + for(var i=0; i Date: Mon, 19 Jan 2015 16:51:51 +0800 Subject: [PATCH 1235/1564] Fixed #2604: fixed a bug of cc.ActionInterval that its `_times` is conflict with cc.Blink --- cocos2d/actions/CCAction.js | 2 +- cocos2d/actions/CCActionInterval.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js index 3797077f71..1c3163e4bd 100644 --- a/cocos2d/actions/CCAction.js +++ b/cocos2d/actions/CCAction.js @@ -255,7 +255,7 @@ cc.FiniteTimeAction = cc.Action.extend(/** @lends cc.FiniteTimeAction# */{ * @return {Number} */ getDuration:function () { - return this._duration * (this._times || 1); + return this._duration * (this._timesForRepeat || 1); }, /** diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index c7e8ed2a19..fe0d0bc4c1 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -47,7 +47,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _elapsed:0, _firstTick:false, _easeList: null, - _times:1, + _timesForRepeat:1, _repeatForever: false, _repeatMethod: false,//Compatible with repeat class, Discard after can be deleted _speed: 1, @@ -59,7 +59,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ ctor:function (d) { this._speed = 1; - this._times = 1; + this._timesForRepeat = 1; this._repeatForever = false; this.MAX_VALUE = 2; this._repeatMethod = false;//Compatible with repeat class, Discard after can be deleted @@ -107,7 +107,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ _cloneDecoration: function(action){ action._repeatForever = this._repeatForever; action._speed = this._speed; - action._times = this._times; + action._timesForRepeat = this._timesForRepeat; action._easeList = this._easeList; action._speedMethod = this._speedMethod; action._repeatMethod = this._repeatMethod; @@ -180,9 +180,9 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ this.update(t > 0 ? t : 0); //Compatible with repeat class, Discard after can be deleted (this._repeatMethod) - if(this._repeatMethod && this._times > 1 && this.isDone()){ + if(this._repeatMethod && this._timesForRepeat > 1 && this.isDone()){ if(!this._repeatForever){ - this._times--; + this._timesForRepeat--; } //var diff = locInnerAction.getElapsed() - locInnerAction._duration; this.startWithTarget(this.target); @@ -286,7 +286,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ return this; } this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted - this._times *= times; + this._timesForRepeat *= times; return this; }, @@ -297,7 +297,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{ */ repeatForever: function(){ this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted - this._times = this.MAX_VALUE; + this._timesForRepeat = this.MAX_VALUE; this._repeatForever = true; return this; } @@ -466,7 +466,7 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{ if (locLast !== found) actionFound.startWithTarget(this.target); - new_t = new_t * actionFound._times; + new_t = new_t * actionFound._timesForRepeat; actionFound.update(new_t > 1 ? new_t % 1 : new_t); this._last = found; }, From 2ed0a73bacf82cc3fb11e9553708e288b9ee9604 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 20 Jan 2015 09:42:56 +0800 Subject: [PATCH 1236/1564] Modifying the texture loaded condition judgment --- .../ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js | 4 ++-- extensions/ccui/uiwidgets/UIButton.js | 6 +++--- extensions/ccui/uiwidgets/UICheckBox.js | 10 +++++----- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- extensions/ccui/uiwidgets/UISlider.js | 10 +++++----- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index 535451aca2..7c5abde255 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -117,12 +117,12 @@ //draw to cache canvas var selTexture = node._scale9Image.getTexture(); - if(selTexture && this._state === ccui.Scale9Sprite.state.NORMAL) + if(selTexture && this._state === ccui.Scale9Sprite.state.GRAY) selTexture._switchToGray(true); locContext.setTransform(1, 0, 0, 1, 0, 0); locContext.clearRect(0, 0, sizeInPixels.width, sizeInPixels.height); cc.renderer._renderingToCacheCanvas(wrapper, node.__instanceId, locScaleFactor, locScaleFactor); - if(selTexture && this._state === ccui.Scale9Sprite.state.NORMAL) + if(selTexture && this._state === ccui.Scale9Sprite.state.GRAY) selTexture._switchToGray(false); if(contentSizeChanged) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index f82996171e..4d4d0e2171 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -251,7 +251,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._normalTexType = texType; var self = this; - if(!this._buttonNormalRenderer.texture || !this._buttonNormalRenderer.texture.isLoaded()){ + if(!this._textureLoaded){ this._buttonNormalRenderer.addEventListener("load", function(){ self.loadTextureNormal(normal, texType); }); @@ -299,7 +299,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._pressedTexType = texType; var self = this; - if(!this._buttonClickedRenderer.texture || !this._buttonClickedRenderer.texture.isLoaded()){ + if(!this._textureLoaded){ this._buttonClickedRenderer.addEventListener("load", function(){ self.loadTexturePressed(selected, texType); }); @@ -344,7 +344,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._disabledTexType = texType; var self = this; - if(!this._buttonDisableRenderer.texture || !this._buttonDisableRenderer.texture.isLoaded()){ + if(!this._textureLoaded){ this._buttonDisableRenderer.addEventListener("load", function() { self.loadTextureDisabled(disabled, texType); }); diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index b86ee96ef0..e282fac36d 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -172,7 +172,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var bgBoxRenderer = this._backGroundBoxRenderer; var self = this; - if(!bgBoxRenderer.texture || !bgBoxRenderer.texture.isLoaded()){ + if(!bgBoxRenderer._textureLoaded){ bgBoxRenderer.addEventListener("load", function(){ self.loadTextureBackGround(backGround, texType); }); @@ -212,7 +212,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundSelectedTexType = texType; var self = this; - if(!this._backGroundSelectedBoxRenderer.texture || !this._backGroundSelectedBoxRenderer.texture.isLoaded()){ + if(!this._backGroundSelectedBoxRenderer._textureLoaded){ this._backGroundSelectedBoxRenderer.addEventListener("load", function(){ self.loadTextureBackGroundSelected(backGroundSelected, texType); }); @@ -251,7 +251,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossTexType = texType; var self = this; - if(!this._frontCrossRenderer.texture || !this._frontCrossRenderer.texture.isLoaded()){ + if(!this._frontCrossRenderer._textureLoaded){ this._frontCrossRenderer.addEventListener("load", function(){ self.loadTextureFrontCross(cross, texType); }); @@ -289,7 +289,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundDisabledTexType = texType; var self = this; - if(!this._backGroundBoxDisabledRenderer.texture || !this._backGroundBoxDisabledRenderer.texture.isLoaded()){ + if(!this._backGroundBoxDisabledRenderer._textureLoaded){ this._backGroundBoxDisabledRenderer.addEventListener("load", function(){ self.loadTextureBackGroundDisabled(backGroundDisabled, texType); }); @@ -327,7 +327,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledTexType = texType; var self = this; - if(!this._frontCrossDisabledRenderer.texture || !this._frontCrossDisabledRenderer.texture.isLoaded()){ + if(!this._frontCrossDisabledRenderer._textureLoaded){ this._frontCrossDisabledRenderer.addEventListener("load", function(){ self.loadTextureFrontCrossDisabled(frontCrossDisabled, texType); }); diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index bfc4c85527..9d33c6c678 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -100,7 +100,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ this._imageTexType = texType; var imageRenderer = self._imageRenderer; - if(!imageRenderer.texture || !imageRenderer.texture.isLoaded()){ + if(!imageRenderer._textureLoaded){ imageRenderer.addEventListener("load", function(){ self.loadTexture(fileName, texType); }); diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 86bb631dbb..68f4316c1f 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -122,7 +122,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ var barRenderer = this._barRenderer; var self = this; - if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ + if(!barRenderer._textureLoaded){ barRenderer.addEventListener("load", function(){ self.loadTexture(texture, texType); }); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index b629b87196..7c3b4f5f13 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -131,7 +131,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var barRenderer = this._barRenderer; var self = this; - if(!barRenderer.texture || !barRenderer.texture.isLoaded()){ + if(!barRenderer._textureLoaded){ barRenderer.addEventListener("load", function(){ self.loadBarTexture(fileName, texType); }); @@ -172,7 +172,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var progressBarRenderer = this._progressBarRenderer; var self = this; - if(!progressBarRenderer.texture || !progressBarRenderer.texture.isLoaded()){ + if(!progressBarRenderer._textureLoaded){ progressBarRenderer.addEventListener("load", function(){ self.loadProgressBarTexture(fileName, texType); }); @@ -340,7 +340,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballNTexType = texType; var self = this; - if(!this._slidBallNormalRenderer.texture || !this._slidBallNormalRenderer.texture.isLoaded()){ + if(!this._slidBallNormalRenderer._textureLoaded){ this._slidBallNormalRenderer.addEventListener("load", function(){ self.loadSlidBallTextureNormal(normal, texType); }); @@ -376,7 +376,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballPTexType = texType; var self = this; - if(!this._slidBallPressedRenderer.texture || !this._slidBallPressedRenderer.texture.isLoaded()){ + if(!this._slidBallPressedRenderer._textureLoaded){ this._slidBallPressedRenderer.addEventListener("load", function(){ self.loadSlidBallTexturePressed(pressed, texType); }); @@ -412,7 +412,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._ballDTexType = texType; var self = this; - if(!this._slidBallDisabledRenderer.texture || !this._slidBallDisabledRenderer.texture.isLoaded()){ + if(!this._slidBallDisabledRenderer._textureLoaded){ this._slidBallDisabledRenderer.addEventListener("load", function(){ self.loadSlidBallTextureDisabled(disabled, texType); }); From ff751aef86c2a4d50a5e523961fa1fa32d46b71f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 20 Jan 2015 11:20:17 +0800 Subject: [PATCH 1237/1564] Repair cannot click without pre load of CheckBox --- extensions/ccui/uiwidgets/UIButton.js | 19 ++++---- extensions/ccui/uiwidgets/UICheckBox.js | 63 +++++++++++++------------ 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 4d4d0e2171..7f54bdabed 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -251,13 +251,12 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._normalTexType = texType; var self = this; - if(!this._textureLoaded){ - this._buttonNormalRenderer.addEventListener("load", function(){ + var normalRenderer = this._buttonNormalRenderer; + if(!normalRenderer._textureLoaded){ + normalRenderer.addEventListener("load", function(){ self.loadTextureNormal(normal, texType); }); } - - var normalRenderer = this._buttonNormalRenderer; switch (this._normalTexType){ case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource @@ -299,13 +298,13 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._pressedTexType = texType; var self = this; - if(!this._textureLoaded){ - this._buttonClickedRenderer.addEventListener("load", function(){ + var clickedRenderer = this._buttonClickedRenderer; + if(!clickedRenderer._textureLoaded){ + clickedRenderer.addEventListener("load", function(){ self.loadTexturePressed(selected, texType); }); } - var clickedRenderer = this._buttonClickedRenderer; switch (this._pressedTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource @@ -344,13 +343,13 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this._disabledTexType = texType; var self = this; - if(!this._textureLoaded){ - this._buttonDisableRenderer.addEventListener("load", function() { + var disabledRenderer = this._buttonDisableRenderer; + if(!disabledRenderer._textureLoaded){ + disabledRenderer.addEventListener("load", function() { self.loadTextureDisabled(disabled, texType); }); } - var disabledRenderer = this._buttonDisableRenderer; switch (this._disabledTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index e282fac36d..d62fdccf00 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -169,13 +169,15 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundFileName = backGround; this._backGroundTexType = texType; - var bgBoxRenderer = this._backGroundBoxRenderer; - var self = this; + var bgBoxRenderer = this._backGroundBoxRenderer; if(!bgBoxRenderer._textureLoaded){ bgBoxRenderer.addEventListener("load", function(){ - self.loadTextureBackGround(backGround, texType); - }); + this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); + this.loadTextureBackGround(backGround, texType); + }, this); + }else{ + this._backGroundBoxRenderer.setContentSize(this._customSize); } switch (this._backGroundTexType) { @@ -211,21 +213,21 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundSelectedFileName = backGroundSelected; this._backGroundSelectedTexType = texType; - var self = this; - if(!this._backGroundSelectedBoxRenderer._textureLoaded){ - this._backGroundSelectedBoxRenderer.addEventListener("load", function(){ - self.loadTextureBackGroundSelected(backGroundSelected, texType); - }); + var backGroundSelectedBoxRenderer = this._backGroundSelectedBoxRenderer; + if(!backGroundSelectedBoxRenderer._textureLoaded){ + backGroundSelectedBoxRenderer.addEventListener("load", function(){ + this.loadTextureBackGroundSelected(backGroundSelected, texType); + }, this); } switch (this._backGroundSelectedTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource - this._backGroundSelectedBoxRenderer.initWithFile(backGroundSelected); + backGroundSelectedBoxRenderer.initWithFile(backGroundSelected); break; case ccui.Widget.PLIST_TEXTURE: //SetTexture cannot load resource - this._backGroundSelectedBoxRenderer.initWithSpriteFrameName(backGroundSelected); + backGroundSelectedBoxRenderer.initWithSpriteFrameName(backGroundSelected); break; default: break; @@ -251,20 +253,21 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossTexType = texType; var self = this; - if(!this._frontCrossRenderer._textureLoaded){ - this._frontCrossRenderer.addEventListener("load", function(){ - self.loadTextureFrontCross(cross, texType); - }); + var frontCrossRenderer = this._frontCrossRenderer; + if(!frontCrossRenderer._textureLoaded){ + frontCrossRenderer.addEventListener("load", function(){ + this.loadTextureFrontCross(cross, texType); + }, this); } switch (this._frontCrossTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource - this._frontCrossRenderer.initWithFile(cross); + frontCrossRenderer.initWithFile(cross); break; case ccui.Widget.PLIST_TEXTURE: //SetTexture cannot load resource - this._frontCrossRenderer.initWithSpriteFrameName(cross); + frontCrossRenderer.initWithSpriteFrameName(cross); break; default: break; @@ -289,20 +292,21 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._backGroundDisabledTexType = texType; var self = this; - if(!this._backGroundBoxDisabledRenderer._textureLoaded){ - this._backGroundBoxDisabledRenderer.addEventListener("load", function(){ - self.loadTextureBackGroundDisabled(backGroundDisabled, texType); - }); + var backGroundBoxDisabledRenderer = this._backGroundBoxDisabledRenderer; + if(!backGroundBoxDisabledRenderer._textureLoaded){ + backGroundBoxDisabledRenderer.addEventListener("load", function(){ + this.loadTextureBackGroundDisabled(backGroundDisabled, texType); + }, this); } switch (this._backGroundDisabledTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource - this._backGroundBoxDisabledRenderer.initWithFile(backGroundDisabled); + backGroundBoxDisabledRenderer.initWithFile(backGroundDisabled); break; case ccui.Widget.PLIST_TEXTURE: //SetTexture cannot load resource - this._backGroundBoxDisabledRenderer.initWithSpriteFrameName(backGroundDisabled); + backGroundBoxDisabledRenderer.initWithSpriteFrameName(backGroundDisabled); break; default: break; @@ -327,20 +331,21 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ this._frontCrossDisabledTexType = texType; var self = this; - if(!this._frontCrossDisabledRenderer._textureLoaded){ - this._frontCrossDisabledRenderer.addEventListener("load", function(){ - self.loadTextureFrontCrossDisabled(frontCrossDisabled, texType); - }); + var frontCrossDisabledRenderer = this._frontCrossDisabledRenderer; + if(!frontCrossDisabledRenderer._textureLoaded){ + frontCrossDisabledRenderer.addEventListener("load", function(){ + this.loadTextureFrontCrossDisabled(frontCrossDisabled, texType); + }, this); } switch (this._frontCrossDisabledTexType) { case ccui.Widget.LOCAL_TEXTURE: //SetTexture cannot load resource - this._frontCrossDisabledRenderer.initWithFile(frontCrossDisabled); + frontCrossDisabledRenderer.initWithFile(frontCrossDisabled); break; case ccui.Widget.PLIST_TEXTURE: //SetTexture cannot load resource - this._frontCrossDisabledRenderer.initWithSpriteFrameName(frontCrossDisabled); + frontCrossDisabledRenderer.initWithSpriteFrameName(frontCrossDisabled); break; default: break; From 9a3395870ade103bf9ae2ecfabc9aeea715dee7b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 20 Jan 2015 13:57:03 +0800 Subject: [PATCH 1238/1564] update CCScale9Sprite --- .../gui/control-extension/CCScale9Sprite.js | 169 ++++++++++++++++-- .../CCScale9SpriteCanvasRenderCmd.js | 64 +++---- .../CCScale9SpriteWebGLRenderCmd.js | 102 ++++++++--- 3 files changed, 259 insertions(+), 76 deletions(-) diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index bc486b3b85..1188d28d44 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -68,7 +68,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ _originalSize: null, _preferredSize: null, - + _opacity: 0, + _color: null, _capInsets: null, _insetLeft: 0, _insetTop: 0, @@ -80,6 +81,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ _textureLoaded:false, _className:"Scale9Sprite", + //v3.3 + _flippedX: false, + _flippedY: false, + /** * return texture is loaded * @returns {boolean} @@ -131,14 +136,32 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var sizableWidth = size.width - locTopLeftContentSize.width - locTopRight.getContentSize().width; var sizableHeight = size.height - locTopLeftContentSize.height - locBottomRight.getContentSize().height; - var scaleResult = this._renderCmd._computeSpriteScale(sizableWidth, sizableHeight, locCenterContentSize.width, locCenterContentSize.height); + var horizontalScale = sizableWidth / locCenterContentSize.width; + var verticalScale = sizableHeight / locCenterContentSize.height; - locCenter.setScaleX(scaleResult.horizontalScale); - locCenter.setScaleY(scaleResult.verticalScale); + var rescaledWidth = locCenterContentSize.width * horizontalScale; + var rescaledHeight = locCenterContentSize.height * verticalScale; var leftWidth = locBottomLeftContentSize.width; var bottomHeight = locBottomLeftContentSize.height; + if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + //browser is in canvas mode, need to manually control rounding to prevent overlapping pixels + var roundedRescaledWidth = Math.round(rescaledWidth); + if (rescaledWidth != roundedRescaledWidth) { + rescaledWidth = roundedRescaledWidth; + horizontalScale = rescaledWidth / locCenterContentSize.width; + } + var roundedRescaledHeight = Math.round(rescaledHeight); + if (rescaledHeight != roundedRescaledHeight) { + rescaledHeight = roundedRescaledHeight; + verticalScale = rescaledHeight / locCenterContentSize.height; + } + } + + locCenter.setScaleX(horizontalScale); + locCenter.setScaleY(verticalScale); + var locLeft = this._left, locRight = this._right, locTop = this._top, locBottom = this._bottom; var tempAP = cc.p(0, 0); locBottomLeft.setAnchorPoint(tempAP); @@ -153,19 +176,19 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Position corners locBottomLeft.setPosition(0, 0); - locBottomRight.setPosition(leftWidth + scaleResult.rescaledWidth, 0); - locTopLeft.setPosition(0, bottomHeight + scaleResult.rescaledHeight); - locTopRight.setPosition(leftWidth + scaleResult.rescaledWidth, bottomHeight + scaleResult.rescaledHeight); + locBottomRight.setPosition(leftWidth + rescaledWidth, 0); + locTopLeft.setPosition(0, bottomHeight + rescaledHeight); + locTopRight.setPosition(leftWidth + rescaledWidth, bottomHeight + rescaledHeight); // Scale and position borders locLeft.setPosition(0, bottomHeight); - locLeft.setScaleY(scaleResult.verticalScale); - locRight.setPosition(leftWidth + scaleResult.rescaledWidth, bottomHeight); - locRight.setScaleY(scaleResult.verticalScale); + locLeft.setScaleY(verticalScale); + locRight.setPosition(leftWidth + rescaledWidth, bottomHeight); + locRight.setScaleY(verticalScale); locBottom.setPosition(leftWidth, 0); - locBottom.setScaleX(scaleResult.horizontalScale); - locTop.setPosition(leftWidth, bottomHeight + scaleResult.rescaledHeight); - locTop.setScaleX(scaleResult.horizontalScale); + locBottom.setScaleX(horizontalScale); + locTop.setPosition(leftWidth, bottomHeight + rescaledHeight); + locTop.setScaleX(horizontalScale); // Position centre locCenter.setPosition(leftWidth, bottomHeight); @@ -203,13 +226,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } }, + getSprite: function () { + return this._scale9Image; + }, + /** Original sprite's size. */ getOriginalSize: function () { return cc.size(this._originalSize); }, - getSprite: function () { - return this._scale9Image; - }, //if the preferredSize component is given as -1, it is ignored getPreferredSize: function () { @@ -600,7 +624,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } // Set the given rect's size as original size - //this._spriteRect = rect; + this._spriteRect = rect; var locSpriteRect = this._spriteRect; locSpriteRect.x = rect.x; locSpriteRect.y = rect.y; @@ -847,7 +871,8 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } this.setContentSize(rect.width, rect.height); - this._renderCmd.addBatchNodeToChildren(locScale9Image); + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this.addChild(locScale9Image); if (this._spritesGenerated) { // Restore color and opacity @@ -887,6 +912,111 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._insetBottom = 0; }, + //v3.3 + /** + * Sets cc.Scale9Sprite's state + * @since v3.3 + * @param {Number} state + */ + setState: function(state){ + this._renderCmd.setState(state); + }, + + //setScale9Enabled implement late + + /** + * Sets whether the widget should be flipped horizontally or not. + * @since v3.3 + * @param flippedX true if the widget should be flipped horizontally, false otherwise. + */ + setFlippedX: function(flippedX){ + var realScale = this.getScaleX(); + this._flippedX = flippedX; + this.setScaleX(realScale); + }, + + /** + *

    + * Returns the flag which indicates whether the widget is flipped horizontally or not.
    + *
    + * It only flips the texture of the widget, and not the texture of the widget's children.
    + * Also, flipping the texture doesn't alter the anchorPoint.
    + * If you want to flip the anchorPoint too, and/or to flip the children too use:
    + * widget->setScaleX(sprite->getScaleX() * -1);
    + *

    + * @since v3.3 + * @return {Boolean} true if the widget is flipped horizontally, false otherwise. + */ + isFlippedX: function(){ + return this._flippedX; + }, + + /** + * Sets whether the widget should be flipped vertically or not. + * @since v3.3 + * @param flippedY true if the widget should be flipped vertically, false otherwise. + */ + setFlippedY:function(flippedY){ + var realScale = this.getScaleY(); + this._flippedY = flippedY; + this.setScaleY(realScale); + }, + + /** + *

    + * Return the flag which indicates whether the widget is flipped vertically or not.
    + *
    + * It only flips the texture of the widget, and not the texture of the widget's children.
    + * Also, flipping the texture doesn't alter the anchorPoint.
    + * If you want to flip the anchorPoint too, and/or to flip the children too use:
    + * widget->setScaleY(widget->getScaleY() * -1);
    + *

    + * @since v3.3 + * @return {Boolean} true if the widget is flipped vertically, false otherwise. + */ + isFlippedY:function(){ + return this._flippedY; + }, + + setScaleX: function (scaleX) { + if (this._flippedX) + scaleX = scaleX * -1; + cc.Node.prototype.setScaleX.call(this, scaleX); + }, + + setScaleY: function (scaleY) { + if (this._flippedY) + scaleY = scaleY * -1; + cc.Node.prototype.setScaleY.call(this, scaleY); + }, + + setScale: function (scaleX, scaleY) { + if(scaleY === undefined) + scaleY = scaleX; + this.setScaleX(scaleX); + this.setScaleY(scaleY); + }, + + getScaleX: function () { + var originalScale = cc.Node.prototype.getScaleX.call(this); + if (this._flippedX) + originalScale = originalScale * -1.0; + return originalScale; + }, + + getScaleY: function () { + var originalScale = cc.Node.prototype.getScaleY.call(this); + if (this._flippedY) + originalScale = originalScale * -1.0; + return originalScale; + }, + + getScale: function () { + if(this.getScaleX() !== this.getScaleY()) + cc.log("Scale9Sprite#scale. ScaleX != ScaleY. Don't know which one to return"); + return this.getScaleX(); + }, + _createRenderCmd: function(){ if(cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.Scale9Sprite.CanvasRenderCmd(this); @@ -964,3 +1094,6 @@ cc.Scale9Sprite.POSITIONS_BOTTOM = 4; cc.Scale9Sprite.POSITIONS_TOPRIGHT = 5; cc.Scale9Sprite.POSITIONS_TOPLEFT = 6; cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; + +cc.Scale9Sprite.state = {NORMAL: 0, GRAY: 1}; + diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js index ab2963b328..4d91c032d6 100644 --- a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -27,6 +27,7 @@ cc.Node.CanvasRenderCmd.call(this, renderable); this._cachedParent = null; this._cacheDirty = false; + this._state = cc.Scale9Sprite.state.NORMAL; var node = this._node; var locCacheCanvas = this._cacheCanvas = cc.newElement('canvas'); @@ -44,21 +45,10 @@ var proto = cc.Scale9Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); proto.constructor = cc.Scale9Sprite.CanvasRenderCmd; - proto.addBatchNodeToChildren = function(batchNode){ - //needn't add to children on canvas mode. - }; - - proto._computeSpriteScale = function(sizableWidth, sizableHeight, centerWidth, centerHeight){ - var horizontalScale = sizableWidth / centerWidth, verticalScale = sizableHeight / centerHeight; - return {horizontalScale: horizontalScale, verticalScale: verticalScale, - rescaledWidth: centerWidth * horizontalScale, rescaledHeight: centerHeight * verticalScale} - }; - proto.visit = function(parentCmd){ var node = this._node; - if(!node._visible){ + if(!node._visible) return; - } if (node._positionsAreDirty) { node._updatePositions(); @@ -71,6 +61,22 @@ cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); }; + proto.transform = function(parentCmd){ + var node = this._node; + cc.Node.CanvasRenderCmd.prototype.transform.call(this, parentCmd); + if (node._positionsAreDirty) { + node._updatePositions(); + node._positionsAreDirty = false; + node._scale9Dirty = true; + } + this._cacheScale9Sprite(); + + var children = node._children; + for(var i=0; i Date: Tue, 20 Jan 2015 14:02:59 +0800 Subject: [PATCH 1239/1564] Fixed a bug of ccui.TextField and cc.TextFieldTTF --- cocos2d/text-input/CCTextFieldTTF.js | 5 ++++- extensions/ccui/uiwidgets/UITextField.js | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index a27bea0d3e..2624093618 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -181,6 +181,8 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this.colorSpaceHolder.g = value.g; this.colorSpaceHolder.b = value.b; this.colorSpaceHolder.a = cc.isUndefined(value.a) ? 255 : value.a; + if(!this._inputText.length) + this.setColor(this.colorSpaceHolder); }, /** @@ -192,6 +194,8 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this._colorText.g = textColor.g; this._colorText.b = textColor.b; this._colorText.a = cc.isUndefined(textColor.a) ? 255 : textColor.a; + if(this._inputText.length) + this.setColor(this._colorText); }, /** @@ -451,7 +455,6 @@ cc.defineGetterSetter(_p, "charCount", _p.getCharCount); _p.placeHolder; cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder); - /** * Please use new TextFieldTTF instead.
    * Creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size. diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 056cc24d79..927585f959 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -488,6 +488,10 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ setTimeout(function(){ self._textFieldRenderer.attachWithIME(); }, 0); + }else{ + setTimeout(function(){ + self._textFieldRenderer.detachWithIME(); + }, 0); } return pass; }, From c9ba30b385a62fadedc66bf0861a05e23c5df743 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 20 Jan 2015 15:35:47 +0800 Subject: [PATCH 1240/1564] Fix an issue of RenderCmd's _updateDisplayOpacity function --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index c9bb546c1d..671d259538 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -157,7 +157,7 @@ cc.Node.RenderCmd.prototype = { var i, len, selChildren, item; if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { this._displayedOpacity = node._realOpacity; - selChildren = this._children; + selChildren = node._children; for (i = 0, len = selChildren.length; i < len; i++) { item = selChildren[i]; if (item && item._renderCmd) From 6a82ad42947014cc4d02186eb9bdff02540924ee Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 20 Jan 2015 17:14:27 +0800 Subject: [PATCH 1241/1564] Fix release texture issue in canvas mode --- cocos2d/core/textures/CCTexture2D.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index b5c95da37f..6d3f8a3e53 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -247,7 +247,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { }, releaseTexture: function () { - //support only in WebGl rendering mode + cc.loader.release(this.url); }, getName: function () { From c5b515c22a660a2f9c0a3a799f3abd5281d13115 Mon Sep 17 00:00:00 2001 From: Daisuke Hashimoto Date: Wed, 21 Jan 2015 13:12:42 +0900 Subject: [PATCH 1242/1564] fix ccs.actionManager bug _actionDic keys are just filename --- extensions/cocostudio/action/CCActionManager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index 88d2bbe626..903de51d8c 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -59,7 +59,10 @@ ccs.actionManager = /** @lends ccs.actionManager# */{ * @returns {ccs.ActionObject} */ getActionByName: function (jsonName, actionName) { - var actionList = this._actionDic[jsonName]; + var path = jsonName; + var pos = path.lastIndexOf("/"); + var fileName = path.substr(pos + 1, path.length); + var actionList = this._actionDic[fileName]; if (!actionList) return null; for (var i = 0; i < actionList.length; i++) { From fa17bca4b6733070eb62a4872c3ac9356baa9d67 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 Jan 2015 14:00:29 +0800 Subject: [PATCH 1243/1564] Repair some values doesn't update in setTexture --- cocos2d/core/sprites/CCSprite.js | 43 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index ac0733d9c7..c6d5d7a984 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -924,29 +924,42 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param {cc.Texture2D|String} texture */ setTexture: function (texture) { - var _t = this; - if(texture && (cc.isString(texture))){ + if(!texture) + return this._renderCmd._setTexture(null); + + if(cc.isString(texture)){ texture = cc.textureCache.addImage(texture); - _t.setTexture(texture); - //TODO - var size = texture.getContentSize(); - _t.setTextureRect(cc.rect(0,0, size.width, size.height)); - //If image isn't loaded. Listen for the load event. + if(!texture._textureLoaded){ texture.addEventListener("load", function(){ - var size = texture.getContentSize(); - _t.setTextureRect(cc.rect(0,0, size.width, size.height)); - _t._textureLoaded = true; + this._renderCmd._setTexture(texture); + this._changeRectWithTexture(texture.getContentSize()); + this.setColor(this._realColor); + this._textureLoaded = true; }, this); }else{ - _t._textureLoaded = true; + this._renderCmd._setTexture(texture); + this._changeRectWithTexture(texture.getContentSize()); + this.setColor(this._realColor); + this._textureLoaded = true; } - return; + }else{ + // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet + cc.assert(texture instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2); + this._changeRectWithTexture(texture.getContentSize()); + this._renderCmd._setTexture(texture); } - // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet - cc.assert(!texture || texture instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2); + }, - this._renderCmd._setTexture(texture); + _changeRectWithTexture: function(rect){ + if(!rect || (!rect.width && !rect.height)) return; + var textureRect = this.getTextureRect(); + if(textureRect.height || textureRect.width) return; + rect.x = rect.x || 0; + rect.y = rect.y || 0; + rect.width = rect.width || 0; + rect.height = rect.height || 0; + this.setTextureRect(rect); }, _createRenderCmd: function(){ From c089b748e4cb329ead7a5194d45170204715c906 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 21 Jan 2015 14:01:07 +0800 Subject: [PATCH 1244/1564] Allow set the texture to null --- .../core/sprites/CCSpriteCanvasRenderCmd.js | 9 ++++++--- .../core/sprites/CCSpriteWebGLRenderCmd.js | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 5828aeab12..05984018fd 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -58,10 +58,13 @@ proto._setTexture = function (texture) { var node = this._node; if (node._texture != texture) { - if (texture && texture.getHtmlElementObj() instanceof HTMLImageElement) { - this._originalTexture = texture; + if (texture) { + if(texture.getHtmlElementObj() instanceof HTMLImageElement) + this._originalTexture = texture; + node._textureLoaded = texture._textureLoaded; + }else{ + node._textureLoaded = false; } - node._textureLoaded = texture._textureLoaded; node._texture = texture; } }; diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 376d227e62..cd53080796 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -286,9 +286,17 @@ proto._setTexture = function (texture) { var node = this._node; // If batchnode, then texture id should be the same - if (node._batchNode && node._batchNode.texture != texture) { - cc.log(cc._LogInfos.Sprite_setTexture); - return; + if (node._batchNode) { + if(node._batchNode.texture != texture){ + cc.log(cc._LogInfos.Sprite_setTexture); + return; + } + }else{ + if(node._texture != texture){ + node._textureLoaded = texture ? texture._textureLoaded : false; + node._texture = texture; + this._updateBlendFunc(); + } } if (texture) @@ -296,11 +304,6 @@ else this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR); - if (!node._batchNode && node._texture != texture) { - node._textureLoaded = texture._textureLoaded; - node._texture = texture; - this._updateBlendFunc(); - } }; proto.updateTransform = function () { //called only at batching. From f027028e9f2d206c6b9cdfcfccfc9e49c466722e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 21 Jan 2015 15:34:39 +0800 Subject: [PATCH 1245/1564] Fixed a bug of cc.Sprite that it can't draw without texture on WebGL mode --- cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index cd53080796..56ac66f8b2 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -415,11 +415,11 @@ }; proto.rendering = function (ctx) { - var node = this._node; - if (!node._textureLoaded || this._displayedOpacity === 0) + var node = this._node, locTexture = node._texture; + if ((locTexture &&!locTexture._textureLoaded) || this._displayedOpacity === 0) return; - var gl = ctx || cc._renderContext, locTexture = node._texture; + var gl = ctx || cc._renderContext ; //cc.assert(!_t._batchNode, "If cc.Sprite is being rendered by cc.SpriteBatchNode, cc.Sprite#draw SHOULD NOT be called"); if (locTexture) { From f800da25061a9afb77fd469bb493a51d25b7d0ef Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Wed, 21 Jan 2015 17:57:18 +0800 Subject: [PATCH 1246/1564] issue #1260:sync jsb key code --- cocos2d/core/platform/CCCommon.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index 8fdd7d3d84..9edef5f478 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -167,7 +167,14 @@ cc.KEY = { backslash:220, ']':221, closebracket:221, - quote:222 + quote:222, + + // gamepad controll + dpadLeft:1000, + dpadRight:1001, + dpadUp:1003, + dpadDown:1004, + dpadCenter:1005 }; /** From d90147c472e739ee2669eed20650d328066bd3c1 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Wed, 21 Jan 2015 18:03:30 +0800 Subject: [PATCH 1247/1564] issue #1260:It's samme with cocos2d-x that modify the key code in UIWidget --- extensions/ccui/base-classes/UIWidget.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index 2554e18bce..d3cea43929 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -46,16 +46,16 @@ ccui._FocusNavigationController = cc.Class.extend({ _onKeyPressed: function(keyCode, event){ if (this._enableFocusNavigation && this._firstFocusedWidget) { - if (keyCode == cc.KEY.down) { + if (keyCode == cc.KEY.dpadDown) { this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.DOWN, this._firstFocusedWidget); } - if (keyCode == cc.KEY.up){ + if (keyCode == cc.KEY.dpadUp){ this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.UP, this._firstFocusedWidget); } - if (keyCode == cc.KEY.left) { + if (keyCode == cc.KEY.dpadLeft) { this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.LEFT, this._firstFocusedWidget); } - if (keyCode == cc.KEY.right) { + if (keyCode == cc.KEY.dpadRight) { this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.RIGHT, this._firstFocusedWidget); } } From 3a548048c5118491e24f26ab3f73cd7c4538f963 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 22 Jan 2015 09:57:56 +0800 Subject: [PATCH 1248/1564] Added a condition when texture is null in SpriteBatchNode --- cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index d01556387c..8c371d0635 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -134,7 +134,8 @@ proto.setTexture = function(texture){ this._textureAtlas.setTexture(texture); - this._updateBlendFunc(); + if(texture) + this._updateBlendFunc(); }; proto.removeAllQuads = function(){ From d13a5d747fb7b8bf9369a8e8bd2d58907fca67ad Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 Jan 2015 11:11:05 +0800 Subject: [PATCH 1249/1564] Audio - Baidu browser play music may be fail --- cocos2d/audio/CCAudio.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 96a480dd8b..fdd9559ba0 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -55,10 +55,12 @@ supportTable[sys.BROWSER_TYPE_WECHAT] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; supportTable[sys.BROWSER_TYPE_360] = {multichannel: false, webAudio: false, auto: true }; supportTable[sys.BROWSER_TYPE_MIUI] = {multichannel: false, webAudio: false, auto: true }; - supportTable[sys.BROWSER_TYPE_BAIDU] = {multichannel: false, webAudio: false, auto: true , emptied: true }; - supportTable[sys.BROWSER_TYPE_BAIDU_APP]= {multichannel: false, webAudio: false, auto: true , emptied: true }; supportTable[sys.BROWSER_TYPE_LIEBAO] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; supportTable[sys.BROWSER_TYPE_SOUGOU] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; + //"Baidu" browser can automatically play + //But because it may be play failed, so need to replay and auto + supportTable[sys.BROWSER_TYPE_BAIDU] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; + supportTable[sys.BROWSER_TYPE_BAIDU_APP]= {multichannel: false, webAudio: false, auto: false, replay: true , emptied: // APPLE // supportTable[sys.BROWSER_TYPE_SAFARI] = {multichannel: true , webAudio: true , auto: false, webAudioCallback: function(realUrl){ From ebe9c2870758a92ad6cc8ea814f46aaadba0ab2e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 Jan 2015 11:37:34 +0800 Subject: [PATCH 1250/1564] Audio - Baidu browser play music may be fail --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index fdd9559ba0..0500abad0c 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -60,7 +60,7 @@ //"Baidu" browser can automatically play //But because it may be play failed, so need to replay and auto supportTable[sys.BROWSER_TYPE_BAIDU] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; - supportTable[sys.BROWSER_TYPE_BAIDU_APP]= {multichannel: false, webAudio: false, auto: false, replay: true , emptied: + supportTable[sys.BROWSER_TYPE_BAIDU_APP]= {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; // APPLE // supportTable[sys.BROWSER_TYPE_SAFARI] = {multichannel: true , webAudio: true , auto: false, webAudioCallback: function(realUrl){ From b9aaa9305037f4b47381261e6c501a81f4737b12 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 Jan 2015 14:44:21 +0800 Subject: [PATCH 1251/1564] UILayout background error --- .../cocostudio/loader/parsers/timelineParser-2.x.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 4164b7f852..feb1306484 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -392,12 +392,19 @@ var bgStartColor = json["FirstColor"]; var bgEndColor = json["EndColor"]; - if(bgStartColor != null && bgEndColor != null) - widget.setBackGroundColor( getColor(bgStartColor), getColor(bgEndColor) ); + if(bgStartColor != null && bgEndColor != null){ + var startC = getColor(bgStartColor); + var endC; + if(bgEndColor["R"] == null && bgEndColor["G"] == null && bgEndColor["B"] == null) + endC = null; + else + endC = getColor(bgEndColor); + widget.setBackGroundColor( startC, endC ); + } var colorVector = json["ColorVector"]; if(colorVector != null) - colorVector["ScaleX"]; + widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); loadTexture(json["FileData"], resourcePath, function(path, type){ widget.setBackGroundImage(path, type); From 3e48b6ce8ac4524a3e0e21794b23cf4da57fabb6 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 22 Jan 2015 15:07:31 +0800 Subject: [PATCH 1252/1564] fix listview direction error, and modify the gravity default value --- extensions/ccui/uiwidgets/scroll-widget/UIListView.js | 2 +- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 9b2950218c..aacc0be62e 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -59,7 +59,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ ctor: function () { ccui.ScrollView.prototype.ctor.call(this); this._items = []; - this._gravity = ccui.ListView.GRAVITY_CENTER_HORIZONTAL; + this._gravity = ccui.ListView.GRAVITY_CENTER_VERTICAL; this.setTouchEnabled(true); this.init(); diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index feb1306484..cc2e3e7134 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -890,7 +890,7 @@ var verticalType = json["VerticalType"]; var horizontalType = json["HorizontalType"]; if(!directionType){ - widget.setDirection(ccui.ListView.DIR_HORIZONTAL); + widget.setDirection(ccui.ScrollView.DIR_HORIZONTAL); if(verticalType == "Align_Bottom") widget.setGravity(ccui.ListView.GRAVITY_BOTTOM); else if(verticalType == "Align_VerticalCenter") @@ -898,7 +898,7 @@ else widget.setGravity(ccui.ListView.GRAVITY_TOP); }else if(directionType == "Vertical"){ - widget.setDirection(ccui.ListView.DIR_VERTICAL); + widget.setDirection(ccui.ScrollView.DIR_VERTICAL); if (horizontalType == "") widget.setGravity(ccui.ListView.GRAVITY_LEFT); else if (horizontalType == "Align_Right") From f5310410a18bc6ff8a053abcd6bea6f31f9a7c3a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 Jan 2015 15:52:53 +0800 Subject: [PATCH 1253/1564] UIImageView setContentSize error --- .../loader/parsers/timelineParser-2.x.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index feb1306484..ccbb970b76 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -693,34 +693,34 @@ var widget = new ccui.ImageView(); - this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.loadTexture(path, type); + }); + loadTexture(json["ImageFileData"], resourcePath, function(path, type){ + widget.loadTexture(path, type); + }); var scale9Enabled = json["Scale9Enable"]; if(scale9Enabled){ widget.setScale9Enabled(true); widget.setUnifySizeEnabled(false); - widget.ignoreContentAdaptWithSize(false); var scale9OriginX = json["Scale9OriginX"]; var scale9OriginY = json["Scale9OriginY"]; var scale9Width = json["Scale9Width"]; var scale9Height = json["Scale9Height"]; widget.setCapInsets(cc.rect( - scale9OriginX || 0, - scale9OriginY || 0, - scale9Width || 0, - scale9Height || 0 + scale9OriginX || 0, + scale9OriginY || 0, + scale9Width || 0, + scale9Height || 0 )); - } + } else + setContentSize(widget, json["Size"]); - setContentSize(widget, json["Size"]); + widget.ignoreContentAdaptWithSize(false); - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.loadTexture(path, type); - }); - loadTexture(json["ImageFileData"], resourcePath, function(path, type){ - widget.loadTexture(path, type); - }); + this.widgetAttributes(widget, json); return widget; }; From d48cd7216efd61879bb3bd1407fc4664047ba749 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 22 Jan 2015 15:57:05 +0800 Subject: [PATCH 1254/1564] [3.3b] Update version --- cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index d9a9563c10..f960492f24 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.2"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3 Beta0"; /** *

    diff --git a/tools/build.xml b/tools/build.xml index a2638b99de..384d8eb2e4 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,8 +5,8 @@ classpath="./compiler/compiler.jar"/> - + debug="false" output="./../lib/cocos2d-js-v3.3-beta0-min.js"> + @@ -297,8 +297,8 @@ - + debug="false" output="./../lib/cocos2d-js-v3.3-beta0-core-min.js"> + From 28918c60b1f2fa663324b4ba507b7b621506bc3e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 Jan 2015 16:29:19 +0800 Subject: [PATCH 1255/1564] UIImageView setContentSize error --- .../cocostudio/loader/parsers/timelineParser-2.x.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 91b3227bb3..8a204c0645 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -208,6 +208,14 @@ //////////// parser.widgetAttributes = function(widget, json){ + widget.setCascadeColorEnabled(true); + widget.setCascadeOpacityEnabled(true); + + widget.setUnifySizeEnabled(false); + widget.setLayoutComponentEnabled(true); + widget.ignoreContentAdaptWithSize(false); + setContentSize(widget, json["Size"]); + var name = json["Name"]; if(name) widget.setName(name); @@ -286,8 +294,6 @@ if(color != null) widget.setColor(getColor(color)); - setContentSize(widget, json["Size"]); - if(widget instanceof ccui.Layout){ var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); @@ -704,6 +710,7 @@ if(scale9Enabled){ widget.setScale9Enabled(true); widget.setUnifySizeEnabled(false); + widget.ignoreContentAdaptWithSize(false); var scale9OriginX = json["Scale9OriginX"]; var scale9OriginY = json["Scale9OriginY"]; @@ -718,8 +725,6 @@ } else setContentSize(widget, json["Size"]); - widget.ignoreContentAdaptWithSize(false); - this.widgetAttributes(widget, json); return widget; From c16e73f1250c51d55b38308ccaecc307df32b938 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 22 Jan 2015 16:34:49 +0800 Subject: [PATCH 1256/1564] Fixed a bug of cc.EditBox that its position is incorrect on Canvas Mode and its string value is wrong when PlaceHolder is showing. --- .../labelttf/CCLabelTTFCanvasRenderCmd.js | 2 ++ extensions/editbox/CCEditBox.js | 24 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index dc5d9b6f99..a851398cfe 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -61,6 +61,8 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var node = this._node; if (!this._labelCanvas) { var locCanvas = cc.newElement("canvas"); + locCanvas.width = 1; + locCanvas.height = 1; var labelTexture = new cc.Texture2D(); labelTexture.initWithElement(locCanvas); node.setTexture(labelTexture); diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 6a15a12dc4..ef9beca447 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -280,6 +280,10 @@ cc.EditBox = cc.ControlButton.extend({ this.value = ""; this.style.fontSize = selfPointer._edFontSize + "px"; this.style.color = cc.colorToHex(selfPointer._textColor); + if (selfPointer._editBoxInputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD) + selfPointer._edTxt.type = "password"; + else + selfPointer._edTxt.type = "text"; } if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidBegin) selfPointer._delegate.editBoxEditingDidBegin(selfPointer); @@ -290,6 +294,7 @@ cc.EditBox = cc.ControlButton.extend({ this.value = selfPointer._placeholderText; this.style.fontSize = selfPointer._placeholderFontSize + "px"; this.style.color = cc.colorToHex(selfPointer._placeholderColor); + selfPointer._edTxt.type = "text"; } if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidEnd) selfPointer._delegate.editBoxEditingDidEnd(selfPointer); @@ -360,6 +365,10 @@ cc.EditBox = cc.ControlButton.extend({ if (this._edTxt.value != this._placeholderText) { this._edTxt.style.fontFamily = this._edFontName; this._edTxt.style.fontSize = this._edFontSize + "px"; + if (this._editBoxInputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD) + this._edTxt.type = "password"; + else + this._edTxt.type = "text"; } }, @@ -370,15 +379,7 @@ cc.EditBox = cc.ControlButton.extend({ */ setText: function (text) { cc.log("Please use the setString"); - if (text != null) { - if (text == "") { - this._edTxt.value = this._placeholderText; - this._edTxt.style.color = cc.colorToHex(this._placeholderColor); - } else { - this._edTxt.value = text; - this._edTxt.style.color = cc.colorToHex(this._textColor); - } - } + this.setString(text); }, /** @@ -487,6 +488,7 @@ cc.EditBox = cc.ControlButton.extend({ if (this._edTxt.value == this._placeholderText) { this._edTxt.style.fontFamily = this._placeholderFontName; this._edTxt.style.fontSize = this._placeholderFontSize + "px"; + this._edTxt.type = "text"; } }, @@ -508,7 +510,7 @@ cc.EditBox = cc.ControlButton.extend({ */ setInputFlag: function (inputFlag) { this._editBoxInputFlag = inputFlag; - if (inputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD) + if ((this._edTxt.value !== this._placeholderText) && (inputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD)) this._edTxt.type = "password"; else this._edTxt.type = "text"; @@ -529,6 +531,8 @@ cc.EditBox = cc.ControlButton.extend({ * @return {string} */ getString: function () { + if(this._edTxt.value === this._placeholderText) + return ""; return this._edTxt.value; }, From 246aa7c88999477c9ab954aa7587469736c763db Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 Jan 2015 16:42:31 +0800 Subject: [PATCH 1257/1564] UIImageView setContentSize error --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 8a204c0645..226a5348ab 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -212,7 +212,7 @@ widget.setCascadeOpacityEnabled(true); widget.setUnifySizeEnabled(false); - widget.setLayoutComponentEnabled(true); + //widget.setLayoutComponentEnabled(true); widget.ignoreContentAdaptWithSize(false); setContentSize(widget, json["Size"]); From 9f78916b7a5b5763718e769ee000d2b06d37a626 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 22 Jan 2015 16:45:50 +0800 Subject: [PATCH 1258/1564] Fixed a bug of cc.EditBox that its position is incorrect on Canvas Mode and its string value is wrong when PlaceHolder is showing. --- extensions/editbox/CCEditBox.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index ef9beca447..561e771d77 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -243,8 +243,7 @@ cc.EditBox = cc.ControlButton.extend({ this._placeholderColor = cc.color.GRAY; this.setContentSize(size); 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"); @@ -259,9 +258,7 @@ cc.EditBox = cc.ControlButton.extend({ tmpEdTxt.style.active = 0; tmpEdTxt.style.outline = "medium"; tmpEdTxt.style.padding = "0"; - var onCanvasClick = function() { - tmpEdTxt.blur(); - }; + var onCanvasClick = function() { tmpEdTxt.blur();}; // TODO the event listener will be remove when EditBox removes from parent. cc._addEventListener(tmpEdTxt, "input", function () { @@ -317,7 +314,6 @@ cc.EditBox = cc.ControlButton.extend({ if (this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg)) { if (press9SpriteBg) this.setBackgroundSpriteForState(press9SpriteBg, cc.CONTROL_STATE_HIGHLIGHTED); - if (disabled9SpriteBg) this.setBackgroundSpriteForState(disabled9SpriteBg, cc.CONTROL_STATE_DISABLED); } @@ -391,9 +387,14 @@ cc.EditBox = cc.ControlButton.extend({ if (text == "") { this._edTxt.value = this._placeholderText; this._edTxt.style.color = cc.colorToHex(this._placeholderColor); + this._edTxt.type = "text"; } else { this._edTxt.value = text; this._edTxt.style.color = cc.colorToHex(this._textColor); + if (this._editBoxInputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD) + this._edTxt.type = "password"; + else + this._edTxt.type = "text"; } } }, From b5b6c592948f5a996c0f50c1fc427fa7160cbec1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 22 Jan 2015 17:05:37 +0800 Subject: [PATCH 1259/1564] Parser anchor error --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 226a5348ab..362cd0358d 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -288,7 +288,7 @@ var anchorPoint = json["AnchorPoint"]; if(anchorPoint != null) - widget.setAnchorPoint(anchorPoint["ScaleX"] || 0.5, anchorPoint["ScaleY"] || 0.5); + widget.setAnchorPoint(anchorPoint["ScaleX"] || 0, anchorPoint["ScaleY"] || 0); var color = json["CColor"]; if(color != null) From bc08d06adf74973375474546749e63a546153fbe Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 22 Jan 2015 18:02:39 +0800 Subject: [PATCH 1260/1564] Fixed a bug of cc.loader that its loadImage doesn't work when image is crossOrigin --- CCBoot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index f777148fc1..c0b3919823 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -783,11 +783,13 @@ cc.loader = /** @lends cc.loader# */{ callback(null, img); }; + var self = this; var errorCallback = function () { this.removeEventListener('error', errorCallback, false); if(img.crossOrigin && img.crossOrigin.toLowerCase() == "anonymous"){ opt.isCrossOrigin = false; + self.release(url); cc.loader.loadImg(url, opt, callback); }else{ typeof callback == "function" && callback("load image failed"); From c86e008996182aa8a8bee25b1e9f10a9179a4cd8 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 22 Jan 2015 18:05:31 +0800 Subject: [PATCH 1261/1564] update function setBackgroundColor judgement, avoid the error in jsb --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 362cd0358d..fef266a3cc 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -402,10 +402,9 @@ var startC = getColor(bgStartColor); var endC; if(bgEndColor["R"] == null && bgEndColor["G"] == null && bgEndColor["B"] == null) - endC = null; + widget.setBackGroundColor( startC ); else - endC = getColor(bgEndColor); - widget.setBackGroundColor( startC, endC ); + widget.setBackGroundColor( startC, getColor(bgEndColor) ); } var colorVector = json["ColorVector"]; From 37f15170499e00be215058e43893fe3e08638b80 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 23 Jan 2015 11:52:12 +0800 Subject: [PATCH 1262/1564] Fixed a bug of ccui.TextField that its contentSize is incorrect in textFieldEvent --- extensions/ccui/uiwidgets/UITextField.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 927585f959..90deb83d4f 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -574,16 +574,18 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this.setDetachWithIME(false); } if (this.getInsertText()) { - this._insertTextEvent(); - this.setInsertText(false); this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()); + + this._insertTextEvent(); + this.setInsertText(false); } if (this.getDeleteBackward()) { - this._deleteBackwardEvent(); - this.setDeleteBackward(false); this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()); + + this._deleteBackwardEvent(); + this.setDeleteBackward(false); } }, From c9eaa7f852e63256615a637da463e78ebea20dce Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 23 Jan 2015 18:03:01 +0800 Subject: [PATCH 1263/1564] update build.xml --- tools/build.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build.xml b/tools/build.xml index a2638b99de..49f7f37950 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -270,6 +270,7 @@ + From 7c9ec7ac7938da49140421ad94a7d49fcb809fc2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 23 Jan 2015 18:51:36 +0800 Subject: [PATCH 1264/1564] Update the authors for v3.3 beta0 --- AUTHORS.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 2f5bbfe7d6..5777d39dcd 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -224,6 +224,15 @@ Tim @duhaibo0404 ccs.csLoader bug fix Hermanto @man2 cc.loader bug fix +Long Jiang @jianglong0156 cc.LabelBMFont bug fix + KeyCode bug fix + ccui.ListView bug fix + +Joe Lafiosca @lafiosca Added Javascript file loader + +galapagosit @galapagosit ccs.actionManager bug fix + + Retired Core Developers: Shengxiang Chen (Nero Chan) Xingsen Ma From 8b2cd11a7b603489a68596caa9136031b1c40fb0 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 24 Jan 2015 12:22:15 +0800 Subject: [PATCH 1265/1564] Update changelog for v3.3 beta --- CHANGELOG.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0c340d480b..c61ba3f643 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,36 @@ ChangeLog: +Cocos2d-JS v3.3 Beta @ Jan.24, 2015 + +* Added Cocos Studio v2.x parser and refactored 1.x parser. +* Upgraded new flow layout UI system in web engine. +* Refactored `load` events of texture2d, sprite and so on to be more intuitive. +* Added JavaScript file loader. +* Allowed set texture to null in `cc.Sprite`. +* Added full test cases for Cocos Studio v2.x parser and the new flow layout UI system. +* Upgraded MoonWarriors sample's UI and graphic design. + +* Bug fixes: + 1. Fixed a bug of Cocos2d UI, their focus event has been supported. + 2. Fixed a buf of `ccui.Widget` that its percent position doesn't work. + 3. Fixed a bug of `ccs.Armature` that its position doesn't update in visit on WebGL render mode. + 4. Fixed a bug of `cc.Sprite` that its `setTextureRect` function doesn't work when `setColor` invoked. + 5. Fixed a bug of `cc.PhysicsSprite` that its position is incorrect. + 6. Fixed a bug of `ccs.Bone` that its `setOpacity` and `setColor` doesn't work. + 7. Fixed a bug of `cc.LabelBMFont` that its word wrap doesn't work. + 8. Fixed a bug of `cc.sys` that it gets the incorrect OS type when system is Linux. + 9. Fixed a bug of `cc.audioEngine` that its loading path is incorrect. + 10. Fixed a bug of `ccui.Widget` that it can't touch when it's reused. + 11. Fixed a bug of UI system that the `setNormalizedPosition` doesn't work. + 12. Fixed a bug of `cc.ActionInterval` that its `_times` conflict with `cc.Blink`. + 13. Fixed release texture issue in canvas mode. + 14. Fixed a bug of `ccs.actionManager` that its `getActionByName` doesn't work. + 15. Fixed a bug of `cc.Sprite` that it can't draw without texture on WebGL mode. + 16. Fixed a bug of `cc.audioEngine` that it doesn't work on baidu browser. + 17. Fixed a bug of `cc.EditBox` that its position is incorrect on Canvas Mode and its string value is wrong when PlaceHolder is showing. + 18. Fixed a bug of `cc.loader` that its `loadImg` function doesn't work when image is accessed cross origin. + 19. Fixed a bug of `ccui.TextField` that its `contentSize` is incorrect in text field event. + Cocos2d-JS v3.2 @ Dec.29, 2014 * Replaced `transform` function with `setTransform` function under canvas render mode for better performance. From 9feb7f77be4546709be82fb1aeee29948412f9ec Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 25 Jan 2015 10:52:54 +0800 Subject: [PATCH 1266/1564] studio parser modify default value --- .../cocostudio/loader/parsers/action-2.x.js | 3 +- .../loader/parsers/timelineParser-2.x.js | 214 ++++++++---------- 2 files changed, 98 insertions(+), 119 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index f57709f8ad..e04dd83017 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -216,7 +216,8 @@ frames.forEach(function(frameData){ var frame = item.handle(frameData, resourcePath); frame.setFrameIndex(frameData["FrameIndex"]); - frame.setTween(frameData["Tween"]); + var tween = frameData["Tween"] != null ? frameData["Tween"] : true; + frame.setTween(tween); timeline.addFrame(frame); }); } diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index fef266a3cc..04ef310735 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -48,6 +48,13 @@ var parser = new Parser(); + var getParam = function(value, dValue){ + if(value === undefined) + return dValue; + else + return value; + }; + ////////// // NODE // ////////// @@ -90,20 +97,17 @@ if (json["ZOrder"] != null) node.setLocalZOrder(json["ZOrder"]); - var visible = json["VisibleForFrame"]; - if (visible != null) - node.setVisible(visible == "True"); + var visible = getParam(json["VisibleForFrame"], true); + node.setVisible(visible); setContentSize(node, json["Size"]); if (json["Alpha"] != null) node.setOpacity(json["Alpha"]); - if (json["Tag"] != null) - node.setTag(json["Tag"]); + node.setTag(json["Tag"] || 0); - if (json["ActionTag"] != null) - node.setUserObject(new ccs.ActionTimelineData(json["ActionTag"])); + node.setUserObject(new ccs.ActionTimelineData(json["ActionTag"] || 0)); node.setCascadeColorEnabled(true); node.setCascadeOpacityEnabled(true); @@ -220,11 +224,9 @@ if(name) widget.setName(name); - var actionTag = json["ActionTag"]; - if(actionTag){ - widget.setActionTag(actionTag); - widget.setUserObject(new ccs.ActionTimelineData(actionTag)); - } + var actionTag = json["ActionTag"] || 0; + widget.setActionTag(actionTag); + widget.setUserObject(new ccs.ActionTimelineData(actionTag)); var rotationSkewX = json["RotationSkewX"]; if(rotationSkewX) @@ -250,17 +252,14 @@ //var visible = json["Visible"]; - var visible = json["VisibleForFrame"]; - if(visible != null) - widget.setVisible(visible); + var visible = getParam(json["VisibleForFrame"], true); + widget.setVisible(visible); var alpha = json["Alpha"]; if(alpha != null) widget.setOpacity(alpha); - var tag = json["Tag"]; - if(tag != null) - widget.setTag(tag); + widget.setTag(json["Tag"] || 0); var touchEnabled = json["TouchEnable"]; if(touchEnabled) @@ -317,8 +316,8 @@ } var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; var stretchVerticalEnabled = json["StretchHeightEnable"] || false; - var horizontalEdge = json["HorizontalEdge"] = ccui.LayoutComponent.horizontalEdge.LEFT; - var verticalEdge = json["VerticalEdge"] = ccui.LayoutComponent.verticalEdge.TOP; + var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; + var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; var leftMargin = json["LeftMargin"] || 0; var rightMargin = json["RightMargin"] || 0; var topMargin = json["TopMargin"] || 0; @@ -378,29 +377,26 @@ if(clipEnabled != null) widget.setClippingEnabled(clipEnabled); - var colorType = json["ComboBoxIndex"]; - if(colorType != null) - widget.setBackGroundColorType(colorType); + var colorType = getParam(json["ComboBoxIndex"], 0); + widget.setBackGroundColorType(colorType); - var bgColorOpacity = json["BackColorAlpha"]; - if(bgColorOpacity != null) - widget.setBackGroundColorOpacity(bgColorOpacity); + var bgColorOpacity = getParam(json["BackColorAlpha"], 255); + widget.setBackGroundColorOpacity(bgColorOpacity); var backGroundScale9Enabled = json["Scale9Enable"]; if(backGroundScale9Enabled != null) widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled); - var scale9OriginX = json["Scale9OriginX"]; - var scale9OriginY = json["Scale9OriginY"]; + var scale9OriginX = json["Scale9OriginX"] || 0; + var scale9OriginY = json["Scale9OriginY"] || 0; - var scale9Width = json["Scale9Width"]; - var scale9Height = json["Scale9Height"]; + var scale9Width = json["Scale9Width"] || 0; + var scale9Height = json["Scale9Height"] || 0; var bgStartColor = json["FirstColor"]; var bgEndColor = json["EndColor"]; if(bgStartColor != null && bgEndColor != null){ var startC = getColor(bgStartColor); - var endC; if(bgEndColor["R"] == null && bgEndColor["G"] == null && bgEndColor["B"] == null) widget.setBackGroundColor( startC ); else @@ -450,7 +446,7 @@ if(areaWidth && areaHeight) widget.setTextAreaSize(cc.size(areaWidth, areaHeight)); - var h_alignment = json["HorizontalAlignmentType"]; + var h_alignment = json["HorizontalAlignmentType"] || "HT_Left"; switch(h_alignment){ case "HT_Right": h_alignment = 2; break; @@ -462,7 +458,7 @@ } widget.setTextHorizontalAlignment(h_alignment); - var v_alignment = json["VerticalAlignmentType"]; + var v_alignment = json["VerticalAlignmentType"] || "VT_Top"; switch(v_alignment){ case "VT_Bottom": v_alignment = 2; break; @@ -511,7 +507,7 @@ this.widgetAttributes(widget, json); - var scale9Enabled = json["Scale9Enable"]; + var scale9Enabled = getParam(json["Scale9Enable"], false); if(scale9Enabled){ widget.setScale9Enabled(scale9Enabled); widget.setUnifySizeEnabled(false); @@ -542,17 +538,14 @@ if(fontName != null) widget.setTitleFontName(fontName); - var displaystate = json["DisplayState"]; - if(displaystate != null){ - widget.setBright(displaystate); - widget.setEnabled(displaystate); - } + var displaystate = getParam(json["DisplayState"], true); + widget.setBright(displaystate); + widget.setEnabled(displaystate); var textColor = json["TextColor"]; if(textColor != null) widget.setTitleColor(getColor(textColor)); - loadTexture(json["NormalFileData"], resourcePath, function(path, type){ widget.loadTextureNormal(path, type); }); @@ -587,15 +580,12 @@ this.widgetAttributes(widget, json); - var selectedState = json["CheckedState"]; - if(selectedState) - widget.setSelected(true); + var selectedState = getParam(json["CheckedState"], false); + widget.setSelected(selectedState); - var displaystate = json["DisplayState"]; - if(displaystate){ - widget.setBright(displaystate); - widget.setEnabled(displaystate); - } + var displaystate = getParam(json["DisplayState"], true); + widget.setBright(displaystate); + widget.setEnabled(displaystate); var dataList = [ {name: "NormalBackFileData", handle: widget.loadTextureBackGround}, @@ -628,9 +618,8 @@ if(clipEnabled) widget.setClippingEnabled(true); - var colorType = json["ComboBoxIndex"]; - if(colorType != null) - widget.setBackGroundColorType(colorType); + var colorType = getParam(json["ComboBoxIndex"], 0); + widget.setBackGroundColorType(colorType); var bgColorOpacity = json["BackColorAlpha"]; if(bgColorOpacity) @@ -641,11 +630,11 @@ widget.setBackGroundImageScale9Enabled(true); } - var scale9OriginX = json["Scale9OriginX"]; - var scale9OriginY = json["Scale9OriginY"]; + var scale9OriginX = json["Scale9OriginX"] || 0; + var scale9OriginY = json["Scale9OriginY"] || 0; - var scale9Width = json["Scale9Width"]; - var scale9Height = json["Scale9Height"]; + var scale9Width = json["Scale9Width"] || 0; + var scale9Height = json["Scale9Height"] || 0; //todo please check it setContentSize(widget, json["Size"]); @@ -682,9 +671,8 @@ if(json["ScrollDirectionType"] == "Vertical_Horizontal") direction = 3; widget.setDirection(direction); - var bounceEnabled = json["IsBounceEnabled"]; - if(bounceEnabled) - widget.setBounceEnabled(bounceEnabled); + var bounceEnabled = getParam(json["IsBounceEnabled"], false); + widget.setBounceEnabled(bounceEnabled); return widget; }; @@ -711,15 +699,15 @@ widget.setUnifySizeEnabled(false); widget.ignoreContentAdaptWithSize(false); - var scale9OriginX = json["Scale9OriginX"]; - var scale9OriginY = json["Scale9OriginY"]; - var scale9Width = json["Scale9Width"]; - var scale9Height = json["Scale9Height"]; + var scale9OriginX = json["Scale9OriginX"] || 0; + var scale9OriginY = json["Scale9OriginY"] || 0; + var scale9Width = json["Scale9Width"] || 0; + var scale9Height = json["Scale9Height"] || 0; widget.setCapInsets(cc.rect( - scale9OriginX || 0, - scale9OriginY || 0, - scale9Width || 0, - scale9Height || 0 + scale9OriginX , + scale9OriginY, + scale9Width, + scale9Height )); } else setContentSize(widget, json["Size"]); @@ -748,7 +736,7 @@ var direction = json["ProgressType"]; widget.setDirection((direction != "Left_To_Right") | 0); - var percent = json["ProgressInfo"]; + var percent = getParam(json["ProgressInfo"], 80); if(percent != null) widget.setPercent(percent); @@ -783,15 +771,12 @@ }); }); - var percent = json["PercentInfo"]; - if(percent != null) - widget.setPercent(percent); + var percent = json["PercentInfo"] || 0; + widget.setPercent(percent); - var displaystate = json["DisplayState"]; - if(displaystate != null){ - widget.setBright(displaystate); - widget.setEnabled(displaystate); - } + var displaystate = getParam(json["DisplayState"], true); + widget.setBright(displaystate); + widget.setEnabled(displaystate); return widget; }; @@ -815,21 +800,20 @@ if(backGroundScale9Enabled){ widget.setBackGroundImageScale9Enabled(true); - var scale9OriginX = json["Scale9OriginX"]; - var scale9OriginY = json["Scale9OriginY"]; - var scale9Width = json["Scale9Width"]; - var scale9Height = json["Scale9Height"]; + var scale9OriginX = json["Scale9OriginX"] || 0; + var scale9OriginY = json["Scale9OriginY"] || 0; + var scale9Width = json["Scale9Width"] || 0; + var scale9Height = json["Scale9Height"] || 0; widget.setBackGroundImageCapInsets(cc.rect( - scale9OriginX || 0, - scale9OriginY || 0, - scale9Width || 0, - scale9Height || 0 + scale9OriginX, + scale9OriginY, + scale9Width, + scale9Height )); } - var colorType = json["ComboBoxIndex"]; - if(colorType != null) - widget.setBackGroundColorType(colorType); + var colorType = getParam(json["ComboBoxIndex"], 0); + widget.setBackGroundColorType(colorType); var bgColorOpacity = json["BackColorAlpha"]; var bgColor = getColor(json["SingleColor"]); @@ -869,30 +853,29 @@ if(clipEnabled) widget.setClippingEnabled(true); - var colorType = json["ComboBoxIndex"]; - if(colorType != null) - widget.setBackGroundColorType(colorType); + var colorType = getParam(json["ComboBoxIndex"], 0); + widget.setBackGroundColorType(colorType); - var bgColorOpacity = json["BackColorAlpha"]; + var bgColorOpacity = getParam(json["BackColorAlpha"], 255); var backGroundScale9Enabled = json["Scale9Enable"]; if(backGroundScale9Enabled){ widget.setBackGroundImageScale9Enabled(true); - var scale9OriginX = json["Scale9OriginX"]; - var scale9OriginY = json["Scale9OriginY"]; - var scale9Width = json["Scale9Width"]; - var scale9Height = json["Scale9Height"]; + var scale9OriginX = json["Scale9OriginX"] || 0; + var scale9OriginY = json["Scale9OriginY"] || 0; + var scale9Width = json["Scale9Width"] || 0; + var scale9Height = json["Scale9Height"] || 0; widget.setBackGroundImageCapInsets(cc.rect( - scale9OriginX || 0, - scale9OriginY || 0, - scale9Width || 0, - scale9Height || 0 + scale9OriginX, + scale9OriginY, + scale9Width, + scale9Height )); } - var directionType = json["DirectionType"]; - var verticalType = json["VerticalType"]; - var horizontalType = json["HorizontalType"]; + var directionType = getParam(json["DirectionType"], ccui.ListView.DIR_HORIZONTAL); + var verticalType = getParam(json["VerticalType"], "Align_Left"); + var horizontalType = getParam(json["HorizontalType"], "Align_Top"); if(!directionType){ widget.setDirection(ccui.ScrollView.DIR_HORIZONTAL); if(verticalType == "Align_Bottom") @@ -912,13 +895,11 @@ } - var bounceEnabled = json["IsBounceEnabled"]; - if(bounceEnabled) - widget.setBounceEnabled(true); - var itemMargin = json["ItemMargin"]; - if(itemMargin != null){ - widget.setItemsMargin(itemMargin); - } + var bounceEnabled = getParam(json["IsBounceEnabled"], false); + widget.setBounceEnabled(bounceEnabled); + + var itemMargin = json["ItemMargin"] || 0; + widget.setItemsMargin(itemMargin); var innerSize = json["InnerNodeSize"]; //Width @@ -1009,9 +990,8 @@ var passwordEnabled = json["PasswordEnable"]; if(passwordEnabled){ widget.setPasswordEnabled(true); - var passwordStyleText = json["PasswordStyleText"]; - if(passwordStyleText != null) - widget.setPasswordStyleText(passwordStyleText); + var passwordStyleText = json["PasswordStyleText"] || "*"; + widget.setPasswordStyleText(passwordStyleText); } var placeHolder = json["PlaceHolderText"]; @@ -1029,9 +1009,8 @@ var maxLengthEnabled = json["MaxLengthEnable"]; if(maxLengthEnabled){ widget.setMaxLengthEnabled(true); - var maxLength = json["MaxLengthText"]; - if(maxLength != null) - widget.setMaxLength(maxLength); + var maxLength = json["MaxLengthText"] || 0; + widget.setMaxLength(maxLength); } //var isCustomSize = json["IsCustomSize"]; @@ -1067,10 +1046,9 @@ */ parser.initSimpleAudio = function(json, resourcePath){ - var loop = json["Loop"]; - var volume = json["Volume"]; - if(volume != null) - cc.audioEngine.setMusicVolume(volume); + var loop = json["Loop"] || false; + var volume = json["Volume"] || 0; + cc.audioEngine.setMusicVolume(volume); //var name = json["Name"]; var resPath = ""; if(cc.loader.resPath) From 417c17a7ba4ca5738efa25d896f30ab0fd76a916 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 25 Jan 2015 11:17:12 +0800 Subject: [PATCH 1267/1564] #114840 background color error --- .../cocostudio/loader/parsers/action-2.x.js | 3 +- .../loader/parsers/timelineParser-2.x.js | 47 +++++++++++-------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index e04dd83017..f57709f8ad 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -216,8 +216,7 @@ frames.forEach(function(frameData){ var frame = item.handle(frameData, resourcePath); frame.setFrameIndex(frameData["FrameIndex"]); - var tween = frameData["Tween"] != null ? frameData["Tween"] : true; - frame.setTween(tween); + frame.setTween(frameData["Tween"]); timeline.addFrame(frame); }); } diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 04ef310735..14f7b745a8 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -639,11 +639,13 @@ //todo please check it setContentSize(widget, json["Size"]); - if(json["FirstColor"] && json["EndColor"]){ - var bgStartColor, bgEndColor; - bgStartColor = getColor(json["FirstColor"]); - bgEndColor = getColor(json["EndColor"]); - widget.setBackGroundColor(bgStartColor, bgEndColor); + var firstColor = json["FirstColor"]; + var endColor = json["EndColor"]; + if(firstColor && endColor){ + if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) + widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); + else + widget.setBackGroundColor(getColor(firstColor)); }else{ widget.setBackGroundColor(getColor(json["SingleColor"])); } @@ -816,13 +818,16 @@ widget.setBackGroundColorType(colorType); var bgColorOpacity = json["BackColorAlpha"]; - var bgColor = getColor(json["SingleColor"]); - var bgEndColor = getColor(json["EndColor"]); - var bgStartColor = getColor(json["FirstColor"]); - if(bgEndColor && bgStartColor) - widget.setBackGroundColor(bgStartColor, bgEndColor); - else - widget.setBackGroundColor(bgColor); + var firstColor = json["FirstColor"]; + var endColor = json["EndColor"]; + if(firstColor && endColor){ + if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) + widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); + else + widget.setBackGroundColor(getColor(firstColor)); + }else{ + widget.setBackGroundColor(getColor(json["SingleColor"])); + } var colorVector = json["ColorVector"]; if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) @@ -906,13 +911,17 @@ if(innerSize != null) widget.setInnerContainerSize(cc.size(innerSize["Widget"]||0, innerSize["Height"]||0)); - var bgColor = getColor(json["SingleColor"]); - var bgEndColor = getColor(json["EndColor"]); - var bgStartColor = getColor(json["FirstColor"]); - if(bgEndColor && bgStartColor) - widget.setBackGroundColor(bgStartColor, bgEndColor); - else - widget.setBackGroundColor(bgColor); + var firstColor = json["FirstColor"]; + var endColor = json["EndColor"]; + if(firstColor && endColor){ + if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) + widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); + else + widget.setBackGroundColor(getColor(firstColor)); + }else{ + widget.setBackGroundColor(getColor(json["SingleColor"])); + } + var colorVector = json["ColorVector"]; if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]); From f4d448ebb4fb4c963067a7a1cf4126af7b467231 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 25 Jan 2015 11:37:49 +0800 Subject: [PATCH 1268/1564] #14780 The listView parameter is missing --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 14f7b745a8..0ac47f244a 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -854,6 +854,8 @@ var widget = new ccui.ListView(); + this.widgetAttributes(widget, json); + var clipEnabled = json["ClipAble"]; if(clipEnabled) widget.setClippingEnabled(true); From bc2619276293a74e3201c847e23f04f3b305337c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 25 Jan 2015 12:54:54 +0800 Subject: [PATCH 1269/1564] #14837 UIText setFontName error --- .../loader/parsers/timelineParser-2.x.js | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 0ac47f244a..e277406c2f 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -481,8 +481,12 @@ var path = fontResource["Path"]; //resoutceType = fontResource["Type"]; if(path != null){ - fontName = path.match(/([^\/]+)\.ttf/); - fontName = fontName ? fontName[1] : ""; + if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { + fontName = cc.path.join(cc.loader.resPath, resourcePath, path); + } else { + fontName = path.match(/([^\/]+)\.ttf/); + fontName = fontName ? fontName[1] : ""; + } widget.setFontName(fontName); } } @@ -556,13 +560,18 @@ widget.loadTextureDisabled(path, type); }); - var fontResourcePath, fontResourceResourceType, fontResourcePlistFile; - var fontResource = json["FontResource"]; if(fontResource != null){ - //console.log(fontResource["Path"]); - // fontResourcePath = fontResource["Path"]; - // fontResourceResourceType = fontResource["Type"] == "Default" ? 0 : 1; - // fontResourcePlistFile = fontResource["Plist"]; + var path = fontResource["Path"]; + //resoutceType = fontResource["Type"]; + if(path != null){ + if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { + fontName = cc.path.join(cc.loader.resPath, resourcePath, path); + } else { + fontName = path.match(/([^\/]+)\.ttf/); + fontName = fontName ? fontName[1] : ""; + } + widget._labelRenderer.setFontName(fontName); + } } return widget; @@ -1031,9 +1040,20 @@ if(text != null) widget.setString(text); - loadTexture(json["FontResource"], resourcePath, function(path, type){ - widget.setFontName(path); - }); + var fontResource = json["FontResource"]; + if(fontResource != null){ + var path = fontResource["Path"]; + //resoutceType = fontResource["Type"]; + if(path != null){ + if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { + fontName = cc.path.join(cc.loader.resPath, resourcePath, path); + } else { + fontName = path.match(/([^\/]+)\.ttf/); + fontName = fontName ? fontName[1] : ""; + } + widget.setFontName(fontName); + } + } widget.setUnifySizeEnabled(false); widget.ignoreContentAdaptWithSize(false); From bd07572da6f07a1fd406b96b04f928263b232b72 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 25 Jan 2015 15:31:43 +0800 Subject: [PATCH 1270/1564] #14836 layout scale9Sprite error --- .../loader/parsers/timelineParser-2.x.js | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index e277406c2f..3d33210d68 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -261,9 +261,8 @@ widget.setTag(json["Tag"] || 0); - var touchEnabled = json["TouchEnable"]; - if(touchEnabled) - widget.setTouchEnabled(true); + var touchEnabled = json["TouchEnable"] || false; + widget.setTouchEnabled(touchEnabled); // -- var frameEvent = json["FrameEvent"]; @@ -387,11 +386,31 @@ if(backGroundScale9Enabled != null) widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled); - var scale9OriginX = json["Scale9OriginX"] || 0; - var scale9OriginY = json["Scale9OriginY"] || 0; + var opacity = json["Alpha"] || 255; + widget.setOpacity(opacity); - var scale9Width = json["Scale9Width"] || 0; - var scale9Height = json["Scale9Height"] || 0; + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + + if(backGroundScale9Enabled){ + var scale9OriginX = json["Scale9OriginX"] || 0; + var scale9OriginY = json["Scale9OriginY"] || 0; + + var scale9Width = json["Scale9Width"] || 0; + var scale9Height = json["Scale9Height"] || 0; + + widget.setBackGroundImageCapInsets(cc.rect( + scale9OriginX, scale9OriginY, scale9Width, scale9Height + )); + + setContentSize(widget, json["Size"]); + }else{ + if (!widget.isIgnoreContentAdaptWithSize()){ + setContentSize(widget, json["Size"]); + } + + } var bgStartColor = json["FirstColor"]; var bgEndColor = json["EndColor"]; @@ -407,10 +426,6 @@ if(colorVector != null) widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - return widget; }; @@ -481,7 +496,7 @@ var path = fontResource["Path"]; //resoutceType = fontResource["Type"]; if(path != null){ - if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { + if (cc.sys.isNative) { fontName = cc.path.join(cc.loader.resPath, resourcePath, path); } else { fontName = path.match(/([^\/]+)\.ttf/); @@ -542,10 +557,6 @@ if(fontName != null) widget.setTitleFontName(fontName); - var displaystate = getParam(json["DisplayState"], true); - widget.setBright(displaystate); - widget.setEnabled(displaystate); - var textColor = json["TextColor"]; if(textColor != null) widget.setTitleColor(getColor(textColor)); @@ -560,17 +571,22 @@ widget.loadTextureDisabled(path, type); }); + var displaystate = getParam(json["DisplayState"], true); + widget.setBright(displaystate); + widget.setEnabled(displaystate); + + var fontResource = json["FontResource"]; if(fontResource != null){ var path = fontResource["Path"]; //resoutceType = fontResource["Type"]; if(path != null){ - if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { + if (cc.sys.isNative) { fontName = cc.path.join(cc.loader.resPath, resourcePath, path); } else { fontName = path.match(/([^\/]+)\.ttf/); fontName = fontName ? fontName[1] : ""; } - widget._labelRenderer.setFontName(fontName); + widget.setTitleFontName(fontName); } } @@ -1045,7 +1061,7 @@ var path = fontResource["Path"]; //resoutceType = fontResource["Type"]; if(path != null){ - if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { + if (cc.sys.isNative) { fontName = cc.path.join(cc.loader.resPath, resourcePath, path); } else { fontName = path.match(/([^\/]+)\.ttf/); @@ -1064,7 +1080,9 @@ if (!widget.isIgnoreContentAdaptWithSize()) setContentSize(widget, json["Size"]); - //widget.getVirtualRenderer().setLineBreakWithoutSpace(true); + + if (cc.sys.isNative) + widget.getVirtualRenderer().setLineBreakWithoutSpace(true); return widget; From 0236a3963185a1309dfda35d91634d1b5bebf637 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 25 Jan 2015 17:02:36 +0800 Subject: [PATCH 1271/1564] #14843 Fixed ColorFrame throw error --- extensions/cocostudio/timeline/Frame.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index 8b39c62ca6..89a755f4fe 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -975,15 +975,18 @@ ccs.ColorFrame = ccs.Frame.extend({ */ apply: function(percent){ if (this._tween && (this._betweenAlpha !=0 || this._betweenRed != 0 || this._betweenGreen != 0 || this._betweenBlue != 0)){ - var alpha = this._alpha + this._betweenAlpha * percent; var color = cc.color(255, 255, 255); color.r = this._color.r + this._betweenRed * percent; color.g = this._color.g + this._betweenGreen * percent; color.b = this._color.b + this._betweenBlue * percent; - this._node.setOpacity(alpha); this._node.setColor(color); + if(this._alpha != null){ + var alpha = this._alpha + this._betweenAlpha * percent; + this._node.setOpacity(alpha); + } + } }, From f66d3fef3a040c29cfb3fde3d787a69097632462 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sun, 25 Jan 2015 17:03:01 +0800 Subject: [PATCH 1272/1564] #14843 Fixed ColorFrame throw error --- .../cocostudio/loader/parsers/action-2.x.js | 3 +- .../loader/parsers/timelineParser-2.x.js | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index f57709f8ad..e04dd83017 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -216,7 +216,8 @@ frames.forEach(function(frameData){ var frame = item.handle(frameData, resourcePath); frame.setFrameIndex(frameData["FrameIndex"]); - frame.setTween(frameData["Tween"]); + var tween = frameData["Tween"] != null ? frameData["Tween"] : true; + frame.setTween(tween); timeline.addFrame(frame); }); } diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 3d33210d68..096e1a3725 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -380,7 +380,8 @@ widget.setBackGroundColorType(colorType); var bgColorOpacity = getParam(json["BackColorAlpha"], 255); - widget.setBackGroundColorOpacity(bgColorOpacity); + if(bgColorOpacity != null) + widget.setBackGroundColorOpacity(bgColorOpacity); var backGroundScale9Enabled = json["Scale9Enable"]; if(backGroundScale9Enabled != null) @@ -490,7 +491,6 @@ if(isCustomSize != null) widget.ignoreContentAdaptWithSize(!isCustomSize); - //todo check it var fontResource = json["FontResource"]; if(fontResource != null){ var path = fontResource["Path"]; @@ -647,22 +647,25 @@ widget.setBackGroundColorType(colorType); var bgColorOpacity = json["BackColorAlpha"]; - if(bgColorOpacity) + if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); var backGroundScale9Enabled = json["Scale9Enable"]; if(backGroundScale9Enabled){ widget.setBackGroundImageScale9Enabled(true); - } - var scale9OriginX = json["Scale9OriginX"] || 0; - var scale9OriginY = json["Scale9OriginY"] || 0; - var scale9Width = json["Scale9Width"] || 0; - var scale9Height = json["Scale9Height"] || 0; - - //todo please check it - setContentSize(widget, json["Size"]); + var scale9OriginX = json["Scale9OriginX"] || 0; + var scale9OriginY = json["Scale9OriginY"] || 0; + var scale9Width = json["Scale9Width"] || 0; + var scale9Height = json["Scale9Height"] || 0; + widget.setBackGroundImageCapInsets(cc.rect( + scale9OriginX, scale9OriginY, scale9Width, scale9Height + )); + setContentSize(widget, json["Size"]); + }else if(!widget.isIgnoreContentAdaptWithSize()){ + setContentSize(widget, json["Size"]); + } var firstColor = json["FirstColor"]; var endColor = json["EndColor"]; @@ -857,7 +860,8 @@ var colorVector = json["ColorVector"]; if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]); - widget.setBackGroundColorOpacity(bgColorOpacity); + if(bgColorOpacity != null) + widget.setBackGroundColorOpacity(bgColorOpacity); loadTexture(json["FileData"], resourcePath, function(path, type){ widget.setBackGroundImage(path, type); @@ -952,7 +956,8 @@ var colorVector = json["ColorVector"]; if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]); - widget.setBackGroundColorOpacity(bgColorOpacity); + if(bgColorOpacity != null) + widget.setBackGroundColorOpacity(bgColorOpacity); loadTexture(json["FileData"], resourcePath, function(path, type){ @@ -1078,11 +1083,12 @@ if(color != null) widget.setTextColor(getColor(color)); - if (!widget.isIgnoreContentAdaptWithSize()) + if (!widget.isIgnoreContentAdaptWithSize()){ setContentSize(widget, json["Size"]); + if (cc.sys.isNative) + widget.getVirtualRenderer().setLineBreakWithoutSpace(true); + } - if (cc.sys.isNative) - widget.getVirtualRenderer().setLineBreakWithoutSpace(true); return widget; From 2b1267f3ac6d9a6ea9f6128de58184d5a4d87615 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 26 Jan 2015 15:17:39 +0800 Subject: [PATCH 1273/1564] Fixed #2024: Added font-style and font-weight functions to cc.LabelTTF --- cocos2d/core/labelttf/CCLabelTTF.js | 39 ++++++++++++++++--- .../labelttf/CCLabelTTFCanvasRenderCmd.js | 19 +++++---- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index e9847c0fe7..db818091b6 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -96,6 +96,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _lineHeight: 0, + //for web + _fontStyle: "normal", + _fontWeight: "normal", + /** * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, * you should pass the correct arguments in constructor to initialize the label. @@ -126,7 +130,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._vAlignment = vAlignment; this._fontSize = fontSize; - this._renderCmd._setFontStyle(this._fontName, fontSize); + this._renderCmd._setFontStyle(this._fontName, fontSize, this._fontStyle, this._fontWeight); this.string = strInfo; this._renderCmd._setColorsString(); this._renderCmd._updateTexture(); @@ -500,7 +504,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._fontName = textDefinition.fontName; this._fontSize = textDefinition.fontSize || 12; - this._renderCmd._setFontStyle(this._fontName, this._fontSize) + this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); // shadow if (textDefinition.shadowEnabled) @@ -666,7 +670,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ setFontSize: function (fontSize) { if (this._fontSize !== fontSize) { this._fontSize = fontSize; - this._renderCmd._setFontStyle(this._fontName, this._fontSize); + this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); // Force update this._setUpdateTextureDirty(); } @@ -679,7 +683,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ setFontName: function (fontName) { if (this._fontName && this._fontName != fontName) { this._fontName = fontName; - this._renderCmd._setFontStyle(this._fontName, this._fontSize); + this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); // Force update this._setUpdateTextureDirty(); } @@ -693,7 +697,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (res) { this._fontSize = parseInt(res[1]); this._fontName = res[2]; - this._renderCmd._setFontStyle(this._fontName, this._fontSize); + this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); // Force update this._setUpdateTextureDirty(); @@ -731,6 +735,31 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return new cc.LabelTTF.CanvasRenderCmd(this); else return new cc.LabelTTF.WebGLRenderCmd(this); + }, + + //For web only + _setFontStyle: function(fontStyle){ + if (this._fontStyle != fontStyle) { + this._fontStyle = fontStyle; + this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); + this._setUpdateTextureDirty(); + } + }, + + _getFontStyle: function(){ + return this._fontStyle; + }, + + _setFontWeight: function(fontWeight){ + if (this._fontWeight != fontWeight) { + this._fontWeight = fontWeight; + this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); + this._setUpdateTextureDirty(); + } + }, + + _getFontWeight: function(){ + return this._fontWeight; } }); diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index a851398cfe..835175bd50 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -72,8 +72,8 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; return this._labelContext; }; - proto._setFontStyle = function (fontName, fontSize) { - this._fontStyleStr = fontSize + "px '" + fontName + "'"; + proto._setFontStyle = function (fontName, fontSize, fontStyle, fontWeight) { + this._fontStyleStr = fontStyle + " " + fontWeight + " " + fontSize + "px '" + fontName + "'"; this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, fontSize); }; @@ -161,21 +161,24 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; //get offset for stroke and shadow if (locDimensionsWidth === 0) { if (this._isMultiLine) - locSize = cc.size(0 | (Math.max.apply(Math, locLineWidth) + locStrokeShadowOffsetX), - 0 | ((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); + locSize = cc.size(Math.ceil(Math.max.apply(Math, locLineWidth) + locStrokeShadowOffsetX), + Math.ceil((this._fontClientHeight * this._strings.length) + locStrokeShadowOffsetY)); else - locSize = cc.size(0 | (this._measure(node._string) + locStrokeShadowOffsetX), 0 | (this._fontClientHeight + locStrokeShadowOffsetY)); + locSize = cc.size(Math.ceil(this._measure(node._string) + locStrokeShadowOffsetX), Math.ceil(this._fontClientHeight + locStrokeShadowOffsetY)); } else { if (node._dimensions.height === 0) { if (this._isMultiLine) - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | ((node.getLineHeight() * this._strings.length) + locStrokeShadowOffsetY)); + locSize = cc.size(Math.ceil(locDimensionsWidth + locStrokeShadowOffsetX), Math.ceil((node.getLineHeight() * this._strings.length) + locStrokeShadowOffsetY)); else - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node.getLineHeight() + locStrokeShadowOffsetY)); + locSize = cc.size(Math.ceil(locDimensionsWidth + locStrokeShadowOffsetX), Math.ceil(node.getLineHeight() + locStrokeShadowOffsetY)); } else { //dimension is already set, contentSize must be same as dimension - locSize = cc.size(0 | (locDimensionsWidth + locStrokeShadowOffsetX), 0 | (node._dimensions.height + locStrokeShadowOffsetY)); + locSize = cc.size(Math.ceil(locDimensionsWidth + locStrokeShadowOffsetX), Math.ceil(node._dimensions.height + locStrokeShadowOffsetY)); } } + if(node._getFontStyle() != "normal"){ //add width for 'italic' and 'oblique' + locSize.width = Math.ceil(locSize.width + node._fontSize * 0.3); + } node.setContentSize(locSize); node._strokeShadowOffsetX = locStrokeShadowOffsetX; node._strokeShadowOffsetY = locStrokeShadowOffsetY; From fdbddaa32578d3726d98199f0c8be2279bc484ff Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 15:46:43 +0800 Subject: [PATCH 1274/1564] canvas transform --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 89 ++++++++++--------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 671d259538..aa1c39e09f 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -242,6 +242,11 @@ cc.Node.RenderCmd.prototype = { cc.Node.RenderCmd.call(this, renderable); this._cachedParent = null; this._cacheDirty = false; + + this._orginalPoint = { + x: 0, + y: 0 + }; }; var proto = cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); @@ -255,16 +260,13 @@ cc.Node.RenderCmd.prototype = { if (parentCmd) { var pt = parentCmd._worldTransform; // cc.AffineTransformConcat is incorrect at get world transform - worldT.a = t.a * pt.a + t.b * pt.c; //a - worldT.b = t.a * pt.b + t.b * pt.d; //b - worldT.c = t.c * pt.a + t.d * pt.c; //c - worldT.d = t.c * pt.b + t.d * pt.d; //d - - var plt = parentCmd._transform; - var xOffset = -(plt.b + plt.c) * t.ty; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + worldT.a = pt.a * t.a + pt.b * t.c; //a + worldT.b = pt.a * t.b + pt.b * t.d; //b + worldT.c = pt.c * t.a + pt.d * t.c; //c + worldT.d = pt.c * t.b + pt.d * t.d; //d + + worldT.tx = pt.a * t.tx + pt.b * t.ty + pt.tx ; + worldT.ty = pt.c * t.tx + pt.d * t.ty + pt.ty; } else { worldT.a = t.a; worldT.b = t.b; @@ -301,17 +303,23 @@ cc.Node.RenderCmd.prototype = { t.ty = node._position.y; // rotation Cos and Sin - var Cos = 1, Sin = 0; + var A = 1, B = 0, + C = 0, D = 1; if (node._rotationX) { var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - Cos = Math.cos(rotationRadiansX); - Sin = Math.sin(rotationRadiansX); + B = -Math.sin(rotationRadiansX); + D = Math.cos(rotationRadiansX); } - // base abcd - t.a = t.d = Cos; - t.b = -Sin; - t.c = Sin; + if (node._rotationY) { + var rotationRadiansY = node._rotationY * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance + A = Math.cos(rotationRadiansY); + C = Math.sin(rotationRadiansY); + } + t.a = A; + t.b = B; + t.c = C; + t.d = D; var lScaleX = node._scaleX, lScaleY = node._scaleY; var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; @@ -321,6 +329,14 @@ cc.Node.RenderCmd.prototype = { var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + t.a *= sx; + t.c *= sx; + t.b *= sy; + t.d *= sy; + } + // skew if (node._skewX || node._skewY) { // offset the anchorpoint @@ -332,31 +348,24 @@ cc.Node.RenderCmd.prototype = { sky = 99999999; var xx = appY * skx * sx; var yy = appX * sky * sy; - t.a = Cos + -Sin * sky; - t.b = Cos * skx + -Sin; - t.c = Sin + Cos * sky; - t.d = Sin * skx + Cos; - t.tx += Cos * xx + -Sin * yy; - t.ty += Sin * xx + Cos * yy; + t.a = A + B * sky; + t.b = A * skx + B; + t.c = C + D * sky; + t.d = C * skx + D; + t.tx += A * xx + B * yy; + t.ty += C * xx + D * yy; } - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.c *= sx; - t.b *= sy; - t.d *= sy; - } - - // adjust anchorPoint - t.tx += Cos * -appX * sx + -Sin * appY * sy; - t.ty -= Sin * -appX * sx + Cos * appY * sy; - - // if ignore anchorPoint - if (node._ignoreAnchorPointForPosition) { - t.tx += appX; - t.ty += appY; - } +// var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; +// // adjust anchorPoint +// t.tx += A * -appX * sx + B * appY * sy; +// t.ty -= C * -appX * sx + D * appY * sy; +// +// // if ignore anchorPoint +// if (node._ignoreAnchorPointForPosition) { +// t.tx += appX; +// t.ty += appY; +// } if (node._additionalTransformDirty) { this._transform = cc.affineTransformConcat(t, node._additionalTransform); From 62316eec21e3c3fac8a2027eec6f38aa77bef6ba Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 19:53:04 +0800 Subject: [PATCH 1275/1564] #14901 Update InnerFrame --- .../cocostudio/timeline/ActionTimeline.js | 2 +- extensions/cocostudio/timeline/Frame.js | 62 ++++++++++++++++++- extensions/cocostudio/timeline/Timeline.js | 4 +- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index 7bf9b7aed8..bc5a60cc00 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -374,7 +374,7 @@ ccs.ActionTimeline = cc.Action.extend({ } this._time += delta * this._timeSpeed; - this._currentFrame = this._time / this._frameInternal; + this._currentFrame = this._time / this._frameInternal | 0; this._stepToFrame(this._currentFrame); diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index 89a755f4fe..a813e07ca4 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -859,6 +859,11 @@ ccs.InnerActionFrame = ccs.Frame.extend({ _innerActionType: null, _startFrameIndex: null, + _endFrameIndex:0, + _singleFrameIndex: 0, + _enterWithName: false, + _animationName: "", + ctor: function(){ ccs.Frame.prototype.ctor.call(this); @@ -871,7 +876,62 @@ ccs.InnerActionFrame = ccs.Frame.extend({ * @param {ccs.Frame} nextFrame */ onEnter: function(nextFrame){ - //override + var innerActiontimeline = this._node.getActionByTag(this._node.getTag()); + if (/*ccs.InnerActionType.SingleFrame*/"SingleFrame" == this._innerActionType){ + innerActiontimeline.gotoFrameAndPause(this._singleFrameIndex); + return; + } + + var innerStart = this._startFrameIndex; + var innerEnd = this._endFrameIndex; + if (this._enterWithName){ + if (this._animationName == "-- ALL --"){ + innerStart = 0; + innerEnd = innerActiontimeline.getDuration(); + } else if(innerActiontimeline.IsAnimationInfoExists(this._animationName)) { + var info = innerActiontimeline.getAnimationInfo(this._animationName); + innerStart = info.startIndex; + innerEnd = info.endIndex; + }else{ + cc.log("Animation %s not exists!", this._animationName); + } + } + + var duration = this._timeline.getActionTimeline().getDuration(); + var odddiff = duration - this._frameIndex - innerEnd + innerStart; + if (odddiff < 0){ + innerEnd += odddiff; + } + + if (/*ccs.InnerActionType.NoLoopAction*/"NoLoopAction" == this._innerActionType){ + innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, false); + }else if (/*ccs.InnerActionType.LoopAction*/"LoopAction" == this._innerActionType){ + innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, true); + } + }, + + setAnimationName: function(animationName){ + if(!this._enterWithName){ + cc.log(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!"); + }else{ + this._animationName = animationName; + } + }, + + setSingleFrameIndex: function(frameIndex){ + this._singleFrameIndex = frameIndex; + }, + + getSingleFrameIndex: function(){ + return this._startFrameIndex; + }, + + setEnterWithName: function(isEnterWithName){ + this._enterWithName = isEnterWithName; + }, + + getEnterWithName: function(){ + return this._enterWithName; }, /** diff --git a/extensions/cocostudio/timeline/Timeline.js b/extensions/cocostudio/timeline/Timeline.js index 176c35419c..783d97fd26 100644 --- a/extensions/cocostudio/timeline/Timeline.js +++ b/extensions/cocostudio/timeline/Timeline.js @@ -134,12 +134,10 @@ ccs.Timeline = ccs.Class.extend({ * @param {cc.Node} node */ setNode: function(node){ - for (var i=0; i Date: Mon, 26 Jan 2015 19:53:26 +0800 Subject: [PATCH 1276/1564] #14901 Add actionValue parser --- extensions/cocostudio/loader/load.js | 2 ++ .../cocostudio/loader/parsers/action-2.x.js | 20 +++++++++++++++++++ .../loader/parsers/timelineParser-2.x.js | 13 +++++++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index e031a7dbff..8d893ae562 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -180,6 +180,8 @@ ccs.load = function(file){ object.node = ccs._load(file); object.action = ccs._load(file, "action"); + if(object.action && object.action.tag === -1) + object.action.tag = object.node.tag; return object; }; diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index e04dd83017..0cae03dfeb 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -201,6 +201,26 @@ var frame = new ccs.ZOrderFrame(); var zorder = options["Value"]; frame.setZOrder(zorder); + return frame; + } + }, + { + name: "ActionValue", + handle: function(options){ + + var frame = new ccs.InnerActionFrame(); + var innerActionType = options["InnerActionType"]; + + var currentAnimationFrame = options["CurrentAniamtionName"]; + + var singleFrameIndex = options["SingleFrameIndex"]; + + frame.setInnerActionType(innerActionType); + frame.setSingleFrameIndex(singleFrameIndex); + + frame.setEnterWithName(true); + frame.setAnimationName(currentAnimationFrame); + return frame; } } diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 096e1a3725..39d586e363 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1145,9 +1145,16 @@ var projectFile = json["FileData"]; if(projectFile != null && projectFile["Path"]){ var file = resourcePath + projectFile["Path"]; - if(cc.loader.getRes(file)) - return ccs._load(file); - else + if(cc.loader.getRes(file)){ + var obj = ccs.load(file); + parser.generalAttributes(obj.node, json); + if(obj.action){ + obj.action.tag = obj.node.tag; + obj.node.runAction(obj.action); + obj.action.gotoFrameAndPause(0); + } + return obj.node; + } else cc.log("%s need to be preloaded", file); } }; From 0275ba6fd32e836ceb35dbc3668e0b8fe627c5cc Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 20:20:53 +0800 Subject: [PATCH 1277/1564] #14897 Fixed setBackGroundColorVector --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 39d586e363..59a123024f 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -859,7 +859,7 @@ var colorVector = json["ColorVector"]; if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) - widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]); + widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); @@ -955,7 +955,7 @@ var colorVector = json["ColorVector"]; if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) - widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]); + widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); From 05aec015c3158f22596ec80e13bef19948e852b7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 20:26:53 +0800 Subject: [PATCH 1278/1564] #14890 Fixed clipEnable error --- .../loader/parsers/timelineParser-2.x.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 59a123024f..1ed6131218 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -639,9 +639,8 @@ this.widgetAttributes(widget, json); - var clipEnabled = json["ClipAble"]; - if(clipEnabled) - widget.setClippingEnabled(true); + var clipEnabled = json["ClipAble"] || false; + widget.setClippingEnabled(clipEnabled); var colorType = getParam(json["ComboBoxIndex"], 0); widget.setBackGroundColorType(colorType); @@ -822,9 +821,8 @@ this.widgetAttributes(widget, json); - var clipEnabled = json["ClipAble"]; - if(clipEnabled) - widget.setClippingEnabled(true); + var clipEnabled = json["ClipAble"] || false; + widget.setClippingEnabled(clipEnabled); var backGroundScale9Enabled = json["Scale9Enable"]; if(backGroundScale9Enabled){ @@ -885,9 +883,8 @@ this.widgetAttributes(widget, json); - var clipEnabled = json["ClipAble"]; - if(clipEnabled) - widget.setClippingEnabled(true); + var clipEnabled = json["ClipAble"] || false; + widget.setClippingEnabled(clipEnabled); var colorType = getParam(json["ComboBoxIndex"], 0); widget.setBackGroundColorType(colorType); From a89a3308331a0064fc8dd491b5cc506715617151 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 20:59:59 +0800 Subject: [PATCH 1279/1564] #14891 param error --- .../loader/parsers/timelineParser-2.x.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 1ed6131218..dd44818d1f 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -280,8 +280,10 @@ var scale = json["Scale"]; if(scale != null){ - widget.setScaleX(scale["ScaleX"] || 1); - widget.setScaleY(scale["ScaleY"] || 1); + var scaleX = getParam(scale["ScaleX"], 1); + var scaleY = getParam(scale["ScaleY"], 1); + widget.setScaleX(scaleX); + widget.setScaleY(scaleY); } var anchorPoint = json["AnchorPoint"]; @@ -387,7 +389,7 @@ if(backGroundScale9Enabled != null) widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled); - var opacity = json["Alpha"] || 255; + var opacity = getParam(json["Alpha"], 255); widget.setOpacity(opacity); loadTexture(json["FileData"], resourcePath, function(path, type){ @@ -639,7 +641,7 @@ this.widgetAttributes(widget, json); - var clipEnabled = json["ClipAble"] || false; + var clipEnabled = json["ClipAble"]; widget.setClippingEnabled(clipEnabled); var colorType = getParam(json["ComboBoxIndex"], 0); @@ -680,7 +682,9 @@ var colorVector = json["ColorVector"]; if(colorVector){ - widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"] || 1, colorVector["ScaleY"] || 1)); + var colorVectorX = getParam(colorVector["ScaleX"], 1); + var colorVectorY = getParam(colorVector["ScaleY"], 1); + widget.setBackGroundColorVector(cc.p(colorVectorX, colorVectorY)); } loadTexture(json["FileData"], resourcePath, function(path, type){ @@ -924,7 +928,7 @@ else if (horizontalType == "Align_Right") widget.setGravity(ccui.ListView.GRAVITY_RIGHT); else if (horizontalType == "Align_HorizontalCenter") - widget.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL); + widget.setGravity(ccui.ListView.GRAVITY_CENTER_HORIZONTAL); } From 0e65a1f0567769465c885f8b3fcd63a9b5d64de4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 21:03:12 +0800 Subject: [PATCH 1280/1564] #14885 #14886 --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index dd44818d1f..d3df868603 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -374,7 +374,7 @@ this.widgetAttributes(widget, json); - var clipEnabled = json["ClipAple"]; + var clipEnabled = json["ClipAble"]; if(clipEnabled != null) widget.setClippingEnabled(clipEnabled); @@ -693,8 +693,8 @@ var innerNodeSize = json["InnerNodeSize"]; var innerSize = cc.size( - innerNodeSize["width"] || 0, - innerNodeSize["height"] || 0 + innerNodeSize["Width"] || 0, + innerNodeSize["Height"] || 0 ); widget.setInnerContainerSize(innerSize); From af2bbee86248b17a30f2582adef9814f622a8e0e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 26 Jan 2015 21:07:06 +0800 Subject: [PATCH 1281/1564] Fixed a bug of cc.Tween that its _currentPercent is wrong in updateHandler function --- .../cocostudio/armature/animation/CCArmatureAnimation.js | 7 +++---- extensions/cocostudio/armature/animation/CCTween.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index 42ea8b5d9d..fda7946a17 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -234,7 +234,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * play animation by animation name. * @param {String} animationName The animation name you want to play * @param {Number} [durationTo=-1] - * he frames between two animation changing-over.It's meaning is changing to this animation need how many frames + * the frames between two animation changing-over.It's meaning is changing to this animation need how many frames * -1 : use the value from CCMovementData get from flash design panel * @param {Number} [loop=-1] * Whether the animation is loop. @@ -278,10 +278,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# this._durationTween = durationTween; } - var movementBoneData; - this._tweenList = []; + this._tweenList.length = 0; - var map = this._armature.getBoneDic(); + var movementBoneData, map = this._armature.getBoneDic(); for(var element in map) { var bone = map[element]; movementBoneData = this._movementData.movBoneDataDic[bone.getName()]; diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index 2139e7f46c..f35dbb9f33 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -156,7 +156,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * update will call this handler, you can handle your logic here */ updateHandler:function () { - var locCurrentPercent = this._currentPercent || 1; + var locCurrentPercent = this._currentPercent == null ? 1 : this._currentPercent; var locLoopType = this._loopType; if (locCurrentPercent >= 1) { switch (locLoopType) { From 5deec86b9a9884fb0db94501a1febb46b6322d5e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 21:41:56 +0800 Subject: [PATCH 1282/1564] #14883 Add LayerObjectData parser --- extensions/cocostudio/loader/load.js | 2 +- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index 8d893ae562..ec49ad7e9a 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -180,7 +180,7 @@ ccs.load = function(file){ object.node = ccs._load(file); object.action = ccs._load(file, "action"); - if(object.action && object.action.tag === -1) + if(object.action && object.action.tag === -1 && object.node) object.action.tag = object.node.tag; return object; }; diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index d3df868603..53edf4ceba 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1131,6 +1131,8 @@ loadTexture(json["FileData"], resourcePath, function(path, type){ if(type == 0) node = new cc.TMXTiledMap(path); + + parser.generalAttributes(node, json); }); return node; @@ -1149,7 +1151,7 @@ if(cc.loader.getRes(file)){ var obj = ccs.load(file); parser.generalAttributes(obj.node, json); - if(obj.action){ + if(obj.action && obj.node){ obj.action.tag = obj.node.tag; obj.node.runAction(obj.action); obj.action.gotoFrameAndPause(0); @@ -1184,6 +1186,8 @@ var currentAnimationName = json["CurrentAnimationName"]; + parser.generalAttributes(node, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ var plists, pngs; var armJson = cc.loader.getRes(path); @@ -1249,6 +1253,7 @@ var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, + {name: "LayerObjectData", handle: parser.initSingleNode}, {name: "SpriteObjectData", handle: parser.initSprite}, {name: "ParticleObjectData", handle: parser.initParticle}, {name: "PanelObjectData", handle: parser.initPanel}, From dc1eb8efa34eb610a7a2451a670b593563708f15 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 22:00:54 +0800 Subject: [PATCH 1283/1564] parser error --- extensions/cocostudio/loader/parsers/action-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 0cae03dfeb..e5a0cad7c7 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -215,7 +215,7 @@ var singleFrameIndex = options["SingleFrameIndex"]; - frame.setInnerActionType(innerActionType); + frame.setInnerActionType(ccs.InnerActionType[innerActionType]); frame.setSingleFrameIndex(singleFrameIndex); frame.setEnterWithName(true); From 055d55bdf3f9640b899c698f3f3396a298e933af Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 26 Jan 2015 22:49:02 +0800 Subject: [PATCH 1284/1564] action parser error --- .../cocostudio/loader/parsers/action-2.x.js | 16 ++++++++++++++++ extensions/cocostudio/timeline/Frame.js | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index e5a0cad7c7..8916285cbf 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -43,6 +43,7 @@ action.setDuration(json["Duration"]); action.setTimeSpeed(json["Speed"] || 1); + //The process of analysis var timelines = json["Timelines"]; timelines.forEach(function(timeline){ @@ -59,6 +60,21 @@ cache[file] = action; cache[file].retain(); return action.clone(); + }, + + deferred: function(json, resourcePath, action, file){ + if(cc.sys.isNative) { + var animationlist = json["Content"]["Content"]["AnimationList"]; + var length = animationlist ? animationlist.length : 0; + for (var i = 0; i < length; i++) { + var animationdata = animationlist[i]; + var info = { name: null, startIndex: null, endIndex: null }; + info.name = animationdata["Name"]; + info.startIndex = animationdata["StartIndex"]; + info.endIndex = animationdata["EndIndex"]; + action.addAnimationInfo(info); + } + } } }); diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index a813e07ca4..83013aa842 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -903,9 +903,9 @@ ccs.InnerActionFrame = ccs.Frame.extend({ innerEnd += odddiff; } - if (/*ccs.InnerActionType.NoLoopAction*/"NoLoopAction" == this._innerActionType){ + if (ccs.InnerActionType.NoLoopAction == this._innerActionType){ innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, false); - }else if (/*ccs.InnerActionType.LoopAction*/"LoopAction" == this._innerActionType){ + }else if (ccs.InnerActionType.LoopAction == this._innerActionType){ innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, true); } }, From f82c62b85d9ac338597fa9975219fb3ddc835d09 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 27 Jan 2015 00:04:26 +0800 Subject: [PATCH 1285/1564] #14831 Scale9Sprite error --- .../loader/parsers/timelineParser-2.x.js | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 53edf4ceba..811086e193 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -526,27 +526,21 @@ var widget = new ccui.Button(); - this.widgetAttributes(widget, json); + loadTexture(json["NormalFileData"], resourcePath, function(path, type){ + widget.loadTextureNormal(path, type); + }); + loadTexture(json["PressedFileData"], resourcePath, function(path, type){ + widget.loadTexturePressed(path, type); + }); + loadTexture(json["DisabledFileData"], resourcePath, function(path, type){ + widget.loadTextureDisabled(path, type); + }); var scale9Enabled = getParam(json["Scale9Enable"], false); - if(scale9Enabled){ + if(scale9Enabled) { widget.setScale9Enabled(scale9Enabled); - widget.setUnifySizeEnabled(false); - widget.ignoreContentAdaptWithSize(false); - - var capInsets = cc.rect( - json["Scale9OriginX"] || 0, - json["Scale9OriginY"] || 0, - json["Scale9Width"] || 0, - json["Scale9Height"] || 0 - ); - - widget.setCapInsets(capInsets); - } - setContentSize(widget, json["Size"]); - var text = json["ButtonText"]; if(text != null) widget.setTitleText(text); @@ -563,16 +557,6 @@ if(textColor != null) widget.setTitleColor(getColor(textColor)); - loadTexture(json["NormalFileData"], resourcePath, function(path, type){ - widget.loadTextureNormal(path, type); - }); - loadTexture(json["PressedFileData"], resourcePath, function(path, type){ - widget.loadTexturePressed(path, type); - }); - loadTexture(json["DisabledFileData"], resourcePath, function(path, type){ - widget.loadTextureDisabled(path, type); - }); - var displaystate = getParam(json["DisplayState"], true); widget.setBright(displaystate); widget.setEnabled(displaystate); @@ -591,6 +575,22 @@ widget.setTitleFontName(fontName); } } + this.widgetAttributes(widget, json); + + if(scale9Enabled) { + widget.setUnifySizeEnabled(false); + widget.ignoreContentAdaptWithSize(false); + var capInsets = cc.rect( + json["Scale9OriginX"] || 0, + json["Scale9OriginY"] || 0, + json["Scale9Width"] || 0, + json["Scale9Height"] || 0 + ); + widget.setCapInsets(capInsets); + + } + + setContentSize(widget, json["Size"]); return widget; From 942d2469d3a033e62ee9e60913df79ecbfb924c8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 27 Jan 2015 00:14:07 +0800 Subject: [PATCH 1286/1564] #14830 --- .../loader/parsers/timelineParser-2.x.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 811086e193..29094dd81d 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -607,13 +607,6 @@ this.widgetAttributes(widget, json); - var selectedState = getParam(json["CheckedState"], false); - widget.setSelected(selectedState); - - var displaystate = getParam(json["DisplayState"], true); - widget.setBright(displaystate); - widget.setEnabled(displaystate); - var dataList = [ {name: "NormalBackFileData", handle: widget.loadTextureBackGround}, {name: "PressedBackFileData", handle: widget.loadTextureBackGroundSelected}, @@ -628,6 +621,13 @@ }); }); + var selectedState = getParam(json["CheckedState"], false); + widget.setSelected(selectedState); + + var displaystate = getParam(json["DisplayState"], true); + widget.setBright(displaystate); + widget.setEnabled(displaystate); + return widget; }; From a9d70baf20cc9a4e6a7da976c7d959b89035a774 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 27 Jan 2015 11:36:16 +0800 Subject: [PATCH 1287/1564] Fixed cocos2d/cocos2d-js/#1267: migrated the up-to-date -x UI --- extensions/ccui/layouts/UILayoutComponent.js | 39 ++++- extensions/ccui/uiwidgets/UIButton.js | 50 +++--- extensions/ccui/uiwidgets/UIImageView.js | 8 +- extensions/ccui/uiwidgets/UILoadingBar.js | 6 +- extensions/ccui/uiwidgets/UISlider.js | 15 +- extensions/ccui/uiwidgets/UIText.js | 14 +- extensions/ccui/uiwidgets/UITextBMFont.js | 13 +- extensions/ccui/uiwidgets/UITextField.js | 23 ++- .../uiwidgets/scroll-widget/UIListView.js | 161 ++++++++---------- 9 files changed, 185 insertions(+), 144 deletions(-) diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index 19f3c2158a..a178d9ed8d 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -66,6 +66,8 @@ ccui.LayoutComponent = cc.Component.extend({ _usingPercentHeight: false, _actived: true, + _isPercentOnly: false, + ctor: function () { this._name = ccui.LayoutComponent.NAME; }, @@ -425,10 +427,17 @@ ccui.LayoutComponent = cc.Component.extend({ this._usingPercentHeight = false; }, + setPercentOnlyEnabled: function(enable){ + this._isPercentOnly = enable; + }, + setActiveEnabled: function (enable) { this._actived = enable; }, refreshLayout: function () { + if(!this._actived) + return; + var parent = this._getOwnerParent(); if (parent == null) return; @@ -439,7 +448,7 @@ ccui.LayoutComponent = cc.Component.extend({ switch (this._horizontalEdge) { case ccui.LayoutComponent.horizontalEdge.NONE: - if (this._usingStretchWidth) { + if (this._usingStretchWidth && !this._isPercentOnly) { ownerSize.width = parentSize.width * this._percentWidth; ownerPosition.x = this._leftMargin + ownerAnchor.x * ownerSize.width; } else { @@ -450,23 +459,32 @@ ccui.LayoutComponent = cc.Component.extend({ } break; case ccui.LayoutComponent.horizontalEdge.LEFT: + if(this._isPercentOnly) + break; if (this._usingPercentWidth || this._usingStretchWidth) ownerSize.width = parentSize.width * this._percentWidth; ownerPosition.x = this._leftMargin + ownerAnchor.x * ownerSize.width; break; case ccui.LayoutComponent.horizontalEdge.RIGHT: + if(this._isPercentOnly) + break; if (this._usingPercentWidth || this._usingStretchWidth) ownerSize.width = parentSize.width * this._percentWidth; ownerPosition.x = parentSize.width - (this._rightMargin + (1 - ownerAnchor.x) * ownerSize.width); break; case ccui.LayoutComponent.horizontalEdge.CENTER: - if (this._usingPercentWidth || this._usingStretchWidth) { + if(this._isPercentOnly) + break; + if (this._usingStretchWidth) { ownerSize.width = parentSize.width - this._leftMargin - this._rightMargin; if (ownerSize.width < 0) ownerSize.width = 0; ownerPosition.x = this._leftMargin + ownerAnchor.x * ownerSize.width; - } else + } else { + if (this._usingPercentWidth) + ownerSize.width = parentSize.width * this._percentWidth; ownerPosition.x = parentSize.width * this._positionPercentX; + } break; default: break; @@ -474,7 +492,7 @@ ccui.LayoutComponent = cc.Component.extend({ switch (this._verticalEdge) { case ccui.LayoutComponent.verticalEdge.NONE: - if (this._usingStretchHeight) { + if (this._usingStretchHeight && !this._isPercentOnly) { ownerSize.height = parentSize.height * this._percentHeight; ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; } else { @@ -485,23 +503,32 @@ ccui.LayoutComponent = cc.Component.extend({ } break; case ccui.LayoutComponent.verticalEdge.BOTTOM: + if(this._isPercentOnly) + break; if (this._usingPercentHeight || this._usingStretchHeight) ownerSize.height = parentSize.height * this._percentHeight; ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; break; case ccui.LayoutComponent.verticalEdge.TOP: + if(this._isPercentOnly) + break; if (this._usingPercentHeight || this._usingStretchHeight) ownerSize.height = parentSize.height * this._percentHeight; ownerPosition.y = parentSize.height - (this._topMargin + (1 - ownerAnchor.y) * ownerSize.height); break; case ccui.LayoutComponent.verticalEdge.CENTER: - if (this._usingPercentHeight || this._usingStretchHeight) { + if(this._isPercentOnly) + break; + if (this._usingStretchHeight) { ownerSize.height = parentSize.height - this._topMargin - this._bottomMargin; if (ownerSize.height < 0) ownerSize.height = 0; ownerPosition.y = this._bottomMargin + ownerAnchor.y * ownerSize.height; - } else + } else { + if(this._usingPercentHeight) + ownerSize.height = parentSize.height * this._percentHeight; ownerPosition.y = parentSize.height * this._positionPercentY; + } break; default: break; diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 7f54bdabed..593992f201 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -185,6 +185,10 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ this.setCapInsetsPressedRenderer(this._capInsetsPressed); this.setCapInsetsDisabledRenderer(this._capInsetsDisabled); this.setBright(this._bright); + + this._normalTextureAdaptDirty = true; + this._pressedTextureAdaptDirty = true; + this._disabledTextureAdaptDirty = true; }, /** @@ -506,33 +510,31 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ if (this.pressedActionEnabled){ this._buttonNormalRenderer.stopAllActions(); this._buttonClickedRenderer.stopAllActions(); - var zoomAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); - this._buttonNormalRenderer.runAction(zoomAction); + //var zoomAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); + //fixme: the zoomAction will run in the next frame which will cause the _buttonNormalRenderer to a wrong scale + //this._buttonNormalRenderer.runAction(zoomAction); + this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize); this._titleRenderer.stopAllActions(); if (this._unifySize){ var zoomTitleAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, 1, 1); this._titleRenderer.runAction(zoomTitleAction); - }else - this._titleRenderer.runAction(zoomAction.clone()); + }else{ + this._titleRenderer.setScaleX(1); + this._titleRenderer.setScaleY(1); + } } } else { this._buttonNormalRenderer.stopAllActions(); this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize); this._titleRenderer.stopAllActions(); - if (this._scale9Enabled) this._buttonNormalRenderer.setColor(cc.color.WHITE); - if(this._unifySize){ - this._titleRenderer.setScaleX(1); - this._titleRenderer.setScaleY(1); - }else{ - this._titleRenderer.setScaleX(this._normalTextureScaleXInSize); - this._titleRenderer.setScaleY(this._normalTextureScaleYInSize); - } + this._titleRenderer.setScaleX(1); + this._titleRenderer.setScaleY(1); } }, @@ -554,11 +556,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locNormalRenderer.setScale(this._pressedTextureScaleXInSize + this._zoomScale, this._pressedTextureScaleYInSize + this._zoomScale); this._titleRenderer.stopAllActions(); - if (this._unifySize){ - var zoomTitleAction = cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, 1 + this._zoomScale, 1 + this._zoomScale); - this._titleRenderer.runAction(zoomTitleAction); - } else - this._titleRenderer.runAction(zoomAction.clone()); + this._titleRenderer.runAction(cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP, 1 + this._zoomScale, 1 + this._zoomScale)); } } else { locNormalRenderer.setVisible(true); @@ -571,13 +569,8 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locNormalRenderer.setState(ccui.Scale9Sprite.state.GRAY); this._titleRenderer.stopAllActions(); - if (this._unifySize){ - this._titleRenderer.setScaleX(1 + this._zoomScale); - this._titleRenderer.setScaleY(1 + this._zoomScale); - }else{ - this._titleRenderer.setScaleX(this._normalTextureScaleXInSize + this._zoomScale); - this._titleRenderer.setScaleY(this._normalTextureScaleYInSize + this._zoomScale); - } + this._titleRenderer.setScaleX(1 + this._zoomScale); + this._titleRenderer.setScaleY(1 + this._zoomScale); } }, @@ -831,6 +824,15 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ return this._zoomScale; }, + /** + * Returns the normalize of texture size + * @since v3.3 + * @returns {cc.Size} + */ + getNormalTextureSize: function(){ + return this._normalTextureSize; + }, + /** * Sets title fontName to ccui.Button. * @param {String} fontName diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 9d33c6c678..7f4519bc23 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -174,6 +174,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ } else this.ignoreContentAdaptWithSize(this._prevIgnoreSize); this.setCapInsets(this._capInsets); + this._imageRendererAdaptDirty = true; }, /** @@ -256,10 +257,11 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if (!this._scale9Enabled) this._imageRenderer.setScale(1.0); } else { - if (this._scale9Enabled) + if (this._scale9Enabled){ this._imageRenderer.setPreferredSize(this._contentSize); - else { - var textureSize = this._imageRenderer.getContentSize(); + this._imageRenderer.setScale(1); + } else { + var textureSize = this._imageTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { this._imageRenderer.setScale(1.0); return; diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 68f4316c1f..68cd78f917 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -188,6 +188,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ this.ignoreContentAdaptWithSize(this._prevIgnoreSize); this.setCapInsets(this._capInsets); this.setPercent(this._percent); + this._barRendererAdaptDirty = true; }, /** @@ -328,9 +329,10 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ } } else { this._totalLength = locContentSize.width; - if (this._scale9Enabled) + if (this._scale9Enabled){ this._setScale9Scale(); - else { + locBarRender.setScale(1.0); + } else { var textureSize = this._barRendererTextureSize; if (textureSize.width <= 0.0 || textureSize.height <= 0.0) { locBarRender.setScale(1.0); diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 7c3b4f5f13..4c3a61fef6 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -33,6 +33,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ _barRenderer: null, _progressBarRenderer: null, + _barTextureSize: null, _progressBarTextureSize: null, _slidBallNormalRenderer: null, _slidBallPressedRenderer: null, @@ -74,6 +75,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ * var uiSlider = new ccui.Slider(); */ ctor: function (barTextureName, normalBallTextureName, resType) { + this._barTextureSize = cc.size(0,0); this._progressBarTextureSize = cc.size(0, 0); this._capInsetsBarRenderer = cc.rect(0, 0, 0, 0); this._capInsetsProgressBarRenderer = cc.rect(0, 0, 0, 0); @@ -155,6 +157,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._progressBarRendererDirty = true; this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize()); this._findLayout(); + this._barTextureSize = this._barRenderer.getContentSize(); }, /** @@ -233,6 +236,8 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ } this.setCapInsetsBarRenderer(this._capInsetsBarRenderer); this.setCapInsetProgressBarRenderer(this._capInsetsProgressBarRenderer); + this._barRendererAdaptDirty = true; + this._progressBarRendererDirty = true; }, /** @@ -448,7 +453,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var dis = this._barLength * res; this._slidBallRenderer.setPosition(dis, this._contentSize.height / 2); if (this._scale9Enabled) - this._progressBarRenderer.setPreferredSize(cc.size(dis, this._progressBarTextureSize.height)); + this._progressBarRenderer.setPreferredSize(cc.size(dis, this._contentSize.height)); else { var spriteRenderer = this._progressBarRenderer; var rect = spriteRenderer.getTextureRect(); @@ -595,9 +600,9 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ this._barLength = this._contentSize.width; if (this._scale9Enabled) { this._barRenderer.setPreferredSize(this._contentSize); - } - else { - var btextureSize = this._barRenderer.getContentSize(); + this._barRenderer.setScale(1.0); + } else { + var btextureSize = this._barTextureSize; if (btextureSize.width <= 0.0 || btextureSize.height <= 0.0) { this._barRenderer.setScale(1.0); return; @@ -627,7 +632,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ else { if (this._scale9Enabled) { this._progressBarRenderer.setPreferredSize(this._contentSize); - this._progressBarTextureSize = this._progressBarRenderer.getContentSize(); + this._progressBarRenderer.setScale(1); } else { var ptextureSize = this._progressBarTextureSize; diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 84e7123a70..857e4663d4 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -23,7 +23,6 @@ THE SOFTWARE. ****************************************************************************/ - /** * The text control of Cocos UI. * @class @@ -85,9 +84,9 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ init: function (textContent, fontName, fontSize) { if (ccui.Widget.prototype.init.call(this)) { if(arguments.length > 0){ - this.setString(textContent); this.setFontName(fontName); this.setFontSize(fontSize); + this.setString(textContent); } return true; } @@ -325,6 +324,17 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ return this._labelRenderer; }, + //@since v3.3 + getAutoRenderSize: function(){ + var virtualSize = this._labelRenderer.getContentSize(); + if (!this._ignoreSize) { + this._labelRenderer.setDimensions(0, 0); + virtualSize = this._labelRenderer.getContentSize(); + this._labelRenderer.setDimensions(this._contentSize.width, this._contentSize.height); + } + return virtualSize; + }, + _labelScaleChangedWithSize: function () { var locContentSize = this._contentSize; if (this._ignoreSize) { diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index e659906ebd..e50733de8e 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -68,13 +68,14 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo setFntFile: function (fileName) { if (!fileName) return; + this._fntFileName = fileName; - var _self = this; - _self._fntFileName = fileName; - - _self._fntFileHasInit = true; - _self._labelBMFontRenderer.initWithString(this._stringValue, fileName); + this._fntFileHasInit = true; + this._labelBMFontRenderer.initWithString(this._stringValue, fileName); + this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()); + this._labelBMFontRendererAdaptDirty = true; + var _self = this; var locRenderer = _self._labelBMFontRenderer; if(!locRenderer._textureLoaded){ locRenderer.addEventListener("load", function(){ @@ -101,9 +102,9 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo if(value == this._labelBMFontRenderer.getString()) return; this._stringValue = value; + this._labelBMFontRenderer.setString(value); if (!this._fntFileHasInit) return; - this._labelBMFontRenderer.setString(value); this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()); this._labelBMFontRendererAdaptDirty = true; }, diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 90deb83d4f..859fec09dc 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -252,12 +252,12 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ */ ctor: function (placeholder, fontName, fontSize) { ccui.Widget.prototype.ctor.call(this); - if (placeholder) - this.setPlaceHolder(placeholder); if (fontName) this.setFontName(fontName); if (fontSize) this.setFontSize(fontSize); + if (placeholder) + this.setPlaceHolder(placeholder); }, /** @@ -565,14 +565,14 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ }, update: function (dt) { - if (this.getAttachWithIME()) { - this._attachWithIMEEvent(); - this.setAttachWithIME(false); - } if (this.getDetachWithIME()) { this._detachWithIMEEvent(); this.setDetachWithIME(false); } + if (this.getAttachWithIME()) { + this._attachWithIMEEvent(); + this.setAttachWithIME(false); + } if (this.getInsertText()) { this._textFieldRendererAdaptDirty = true; this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()); @@ -736,6 +736,17 @@ ccui.TextField = ccui.Widget.extend(/** @lends ccui.TextField# */{ this._textFieldRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2); }, + //@since v3.3 + getAutoRenderSize: function(){ + var virtualSize = this._textFieldRenderer.getContentSize(); + if (!this._ignoreSize) { + this._textFieldRenderer.setDimensions(0, 0); + virtualSize = this._textFieldRenderer.getContentSize(); + this._textFieldRenderer.setDimensions(this._contentSize.width, this._contentSize.height); + } + return virtualSize; + }, + /** * Returns the ccui.TextField's content size. * @returns {cc.Size} diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index aacc0be62e..3ea7385fde 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -83,8 +83,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {ccui.Widget} model */ setItemModel: function (model) { - if (!model) + if (!model){ + cc.log("Can't set a null to item model!"); return; + } + this._model = model; }, @@ -113,104 +116,80 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, _remedyLayoutParameter: function (item) { - if (!item) - return; - var llp; - switch (this.direction) { - case ccui.ScrollView.DIR_VERTICAL: - llp = item.getLayoutParameter(); - if (!llp) { - var defaultLp = new ccui.LinearLayoutParameter(); - switch (this._gravity) { - case ccui.ListView.GRAVITY_LEFT: - defaultLp.setGravity(ccui.LinearLayoutParameter.LEFT); - break; - case ccui.ListView.GRAVITY_RIGHT: - defaultLp.setGravity(ccui.LinearLayoutParameter.RIGHT); - break; - case ccui.ListView.GRAVITY_CENTER_HORIZONTAL: - defaultLp.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL); - break; - default: - break; - } - if (this.getIndex(item) == 0) - defaultLp.setMargin(ccui.MarginZero()); - else - defaultLp.setMargin(new ccui.Margin(0.0, this._itemsMargin, 0.0, 0.0)); - item.setLayoutParameter(defaultLp); - } else { - if (this.getIndex(item) == 0) - llp.setMargin(ccui.MarginZero()); - else - llp.setMargin(new ccui.Margin(0, this._itemsMargin, 0, 0)); - switch (this._gravity) { - case ccui.ListView.GRAVITY_LEFT: - llp.setGravity(ccui.LinearLayoutParameter.LEFT); - break; - case ccui.ListView.GRAVITY_RIGHT: - llp.setGravity(ccui.LinearLayoutParameter.RIGHT); - break; - case ccui.ListView.GRAVITY_CENTER_HORIZONTAL: - llp.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL); - break; - default: - break; - } - } + cc.assert(null != item, "ListView Item can't be nil!"); + + var linearLayoutParameter = item.getLayoutParameter(); + var isLayoutParameterExists = true; + if (!linearLayoutParameter) { + linearLayoutParameter = new ccui.LinearLayoutParameter(); + isLayoutParameterExists = false; + } + var itemIndex = this.getIndex(item); + switch (this._direction) { + case ccui.ListView.DIR_VERTICAL: + this._remedyVerticalLayoutParameter(linearLayoutParameter, itemIndex); break; - case ccui.ScrollView.DIR_HORIZONTAL: - llp = item.getLayoutParameter(); - if (!llp) { - var defaultLp = new ccui.LinearLayoutParameter(); - switch (this._gravity) { - case ccui.ListView.GRAVITY_TOP: - defaultLp.setGravity(ccui.LinearLayoutParameter.TOP); - break; - case ccui.ListView.GRAVITY_BOTTOM: - defaultLp.setGravity(ccui.LinearLayoutParameter.BOTTOM ); - break; - case ccui.ListView.GRAVITY_CENTER_VERTICAL: - defaultLp.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL); - break; - default: - break; - } - if (this.getIndex(item) == 0) - defaultLp.setMargin(ccui.MarginZero()); - else - defaultLp.setMargin(new ccui.Margin(this._itemsMargin, 0.0, 0.0, 0.0)); - item.setLayoutParameter(defaultLp); - } else { - if (this.getIndex(item) == 0) - llp.setMargin(ccui.MarginZero()); - else - llp.setMargin(new ccui.Margin(this._itemsMargin, 0.0, 0.0, 0.0)); - switch (this._gravity) { - case ccui.ListView.GRAVITY_TOP: - llp.setGravity(ccui.LinearLayoutParameter.TOP); - break; - case ccui.ListView.GRAVITY_BOTTOM: - llp.setGravity(ccui.LinearLayoutParameter.BOTTOM); - break; - case ccui.ListView.GRAVITY_CENTER_VERTICAL: - llp.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL); - break; - default: - break; - } - } + case ccui.ListView.DIR_HORIZONTAL: + this._remedyHorizontalLayoutParameter(linearLayoutParameter, itemIndex); + break; + default: + break; + } + if (!isLayoutParameterExists) + item.setLayoutParameter(linearLayoutParameter); + }, + + //@since v3.3 + _remedyVerticalLayoutParameter: function (layoutParameter, itemIndex) { + cc.assert(null != layoutParameter, "Layout parameter can't be nil!"); + + switch (this._gravity) { + case ccui.ListView.GRAVITY_LEFT: + layoutParameter.setGravity(ccui.LinearLayoutParameter.LEFT); + break; + case ccui.ListView.GRAVITY_RIGHT: + layoutParameter.setGravity(ccui.LinearLayoutParameter.RIGHT); + break; + case ccui.ListView.GRAVITY_CENTER_HORIZONTAL: + layoutParameter.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL); + break; + default: + break; + } + if (0 == itemIndex) + layoutParameter.setMargin(ccui.MarginZero()); + else + layoutParameter.setMargin(new ccui.Margin(0.0, this._itemsMargin, 0.0, 0.0)); + }, + + //@since v3.3 + _remedyHorizontalLayoutParameter: function (layoutParameter, itemIndex) { + cc.assert(null != layoutParameter, "Layout parameter can't be nil!"); + + switch (this._gravity) { + case ccui.ListView.GRAVITY_TOP: + layoutParameter.setGravity(ccui.LinearLayoutParameter.TOP); + break; + case ccui.ListView.GRAVITY_BOTTOM: + layoutParameter.setGravity(ccui.LinearLayoutParameter.BOTTOM); + break; + case ccui.ListView.GRAVITY_CENTER_VERTICAL: + layoutParameter.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL); break; default: break; } + if (0 == itemIndex) + layoutParameter.setMargin(ccui.MarginZero()); + else + layoutParameter.setMargin(new ccui.Margin(this._itemsMargin, 0.0, 0.0, 0.0)); }, /** * Push back a default item(create by a cloned model) into ListView. */ pushBackDefaultItem: function () { - if (!this._model) + if (this._model == null) return; var newItem = this._model.clone(); this._remedyLayoutParameter(newItem); @@ -223,7 +202,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {Number} index */ insertDefaultItem: function (index) { - if (!this._model) + if (this._model == null) return; var newItem = this._model.clone(); this._items.splice(index, 0, newItem); @@ -309,7 +288,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ */ removeItem: function (index) { var item = this.getItem(index); - if (!item) + if (item == null) return; this.removeChild(item, true); this._refreshViewDirty = true; @@ -354,6 +333,8 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @returns {Number} the index of item. */ getIndex: function (item) { + if(item == null) + return -1; return this._items.indexOf(item); }, From ef96ed10c33f135287983d4050c08e4a3b2913af Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 27 Jan 2015 11:44:05 +0800 Subject: [PATCH 1288/1564] Studio loader error - loadingBar direction --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 29094dd81d..6c1cfbb85c 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -766,8 +766,8 @@ widget.loadTexture(path, type); }); - var direction = json["ProgressType"]; - widget.setDirection((direction != "Left_To_Right") | 0); + var direction = json["ProgressType"] === "Right_To_Left" ? 1 : 0; + widget.setDirection(direction); var percent = getParam(json["ProgressInfo"], 80); if(percent != null) From 056a72b373ad7f900d14932fac0d1b120e66a70d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 27 Jan 2015 14:35:45 +0800 Subject: [PATCH 1289/1564] Fixed a bug of ccui.Button that its state in incorrect in _onPressStateChangedToNormal --- extensions/ccui/uiwidgets/UIButton.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 593992f201..23dd90d41b 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -565,9 +565,6 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ locNormalRenderer.stopAllActions(); locNormalRenderer.setScale(this._normalTextureScaleXInSize + this._zoomScale, this._normalTextureScaleYInSize + this._zoomScale); - if (this._scale9Enabled) - locNormalRenderer.setState(ccui.Scale9Sprite.state.GRAY); - this._titleRenderer.stopAllActions(); this._titleRenderer.setScaleX(1 + this._zoomScale); this._titleRenderer.setScaleY(1 + this._zoomScale); From a898614cfa55d589ad6bd9e64f54f985d8136abb Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 27 Jan 2015 14:56:29 +0800 Subject: [PATCH 1290/1564] Corrected a mistake of ccui.ListView --- extensions/ccui/uiwidgets/scroll-widget/UIListView.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 3ea7385fde..89610664e2 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -125,11 +125,11 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ isLayoutParameterExists = false; } var itemIndex = this.getIndex(item); - switch (this._direction) { - case ccui.ListView.DIR_VERTICAL: + switch (this.direction) { + case ccui.ScrollView.DIR_VERTICAL: this._remedyVerticalLayoutParameter(linearLayoutParameter, itemIndex); break; - case ccui.ListView.DIR_HORIZONTAL: + case ccui.ScrollView.DIR_HORIZONTAL: this._remedyHorizontalLayoutParameter(linearLayoutParameter, itemIndex); break; default: From 3042f5b8be913e9054352d665c3e1bf152dc83a5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 27 Jan 2015 18:55:32 +0800 Subject: [PATCH 1291/1564] status --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 30 ++++++++++++++++--- .../core/sprites/CCSpriteCanvasRenderCmd.js | 10 ++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index aa1c39e09f..ba8820695f 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -243,7 +243,7 @@ cc.Node.RenderCmd.prototype = { this._cachedParent = null; this._cacheDirty = false; - this._orginalPoint = { + this.__point = { x: 0, y: 0 }; @@ -258,15 +258,34 @@ cc.Node.RenderCmd.prototype = { worldT = this._worldTransform; //get the world transform if (parentCmd) { - var pt = parentCmd._worldTransform; + var pt = parentCmd._worldTransform, + pn = parentCmd._node; + var pAnchor = parentCmd._anchorPointInPoints; + + var tx, ty; + if (pn && !pn._ignoreAnchorPointForPosition) { + tx = pt.tx - pAnchor.x; + ty = pt.ty - pAnchor.y; + + }else{ + tx = pt.tx; + ty = pt.ty; + } + // cc.AffineTransformConcat is incorrect at get world transform worldT.a = pt.a * t.a + pt.b * t.c; //a worldT.b = pt.a * t.b + pt.b * t.d; //b worldT.c = pt.c * t.a + pt.d * t.c; //c worldT.d = pt.c * t.b + pt.d * t.d; //d - worldT.tx = pt.a * t.tx + pt.b * t.ty + pt.tx ; - worldT.ty = pt.c * t.tx + pt.d * t.ty + pt.ty; + worldT.tx = pt.a * (t.tx - pAnchor.x) + pt.b * (t.ty - pAnchor.y) + pt.tx; + worldT.ty = pt.c * (t.tx - pAnchor.x) + pt.d * (t.ty - pAnchor.y) + pt.ty; + if(pn && !pn._ignoreAnchorPointForPosition){ + }else{ + worldT.tx += pAnchor.x; + worldT.ty += pAnchor.y; + } + } else { worldT.a = t.a; worldT.b = t.b; @@ -360,6 +379,9 @@ cc.Node.RenderCmd.prototype = { // // adjust anchorPoint // t.tx += A * -appX * sx + B * appY * sy; // t.ty -= C * -appX * sx + D * appY * sy; + + this.__point.x = A * -appX * sx + B * appY * sy; + this.__point.y = C * -appX * sx + D * appY * sy; // // // if ignore anchorPoint // if (node._ignoreAnchorPointForPosition) { diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 05984018fd..92567ad6c5 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -119,6 +119,8 @@ || !node._texture._textureLoaded)) || alpha === 0) return; + var anchor = this._anchorPointInPoints; + var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); var locX = node._offsetPosition.x, locHeight = node._rect.height, locWidth = node._rect.width, locY = -node._offsetPosition.y - locHeight, image; @@ -142,16 +144,16 @@ image = node._texture._htmlElementObj; if (node._texture._pattern != "") { wrapper.setFillStyle(context.createPattern(image, node._texture._pattern)); - context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + context.fillRect((locX - anchor.x) * scaleX, (locY + anchor.y) * scaleY, locWidth * scaleX, locHeight * scaleY); } else { if (this._colorized) { context.drawImage(image, 0, 0, locTextureCoord.width,locTextureCoord.height, - locX * scaleX,locY * scaleY, locWidth * scaleX, locHeight * scaleY); + (locX-anchor.x) * scaleX, (locY+anchor.y) * scaleY, locWidth * scaleX, locHeight * scaleY); } else { context.drawImage(image, locTextureCoord.renderX, locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, - locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + (locX-anchor.x) * scaleX, (locY+anchor.y) * scaleY, locWidth * scaleX, locHeight * scaleY); } } } else { @@ -159,7 +161,7 @@ if (locTextureCoord.validRect) { var curColor = this._displayedColor; wrapper.setFillStyle("rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"); - context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + context.fillRect((locX-anchor.x) * scaleX, (locY + anchor.y) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } if(node._flippedX || node._flippedY) From 49c7afc44b1959a5309746a701b4e78c6ff8ea00 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 28 Jan 2015 15:24:09 +0800 Subject: [PATCH 1292/1564] matrix algorithm (add anchorPoint) --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index ba8820695f..77076067d6 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -262,28 +262,18 @@ cc.Node.RenderCmd.prototype = { pn = parentCmd._node; var pAnchor = parentCmd._anchorPointInPoints; - var tx, ty; - if (pn && !pn._ignoreAnchorPointForPosition) { - tx = pt.tx - pAnchor.x; - ty = pt.ty - pAnchor.y; - - }else{ - tx = pt.tx; - ty = pt.ty; - } - // cc.AffineTransformConcat is incorrect at get world transform worldT.a = pt.a * t.a + pt.b * t.c; //a worldT.b = pt.a * t.b + pt.b * t.d; //b worldT.c = pt.c * t.a + pt.d * t.c; //c worldT.d = pt.c * t.b + pt.d * t.d; //d - worldT.tx = pt.a * (t.tx - pAnchor.x) + pt.b * (t.ty - pAnchor.y) + pt.tx; - worldT.ty = pt.c * (t.tx - pAnchor.x) + pt.d * (t.ty - pAnchor.y) + pt.ty; if(pn && !pn._ignoreAnchorPointForPosition){ + worldT.tx = pt.a * (t.tx - pAnchor.x) - pt.b * (t.ty - pAnchor.y) + pt.tx; + worldT.ty = -pt.c * (t.tx - pAnchor.x) + pt.d * (t.ty - pAnchor.y) + pt.ty; }else{ - worldT.tx += pAnchor.x; - worldT.ty += pAnchor.y; + worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx; + worldT.ty = -pt.c * t.tx + pt.d * t.ty + pt.ty; } } else { From 465252d77265b8eb0ea0406aa05f5479b9c39f57 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 28 Jan 2015 17:27:28 +0800 Subject: [PATCH 1293/1564] param error (CCProtectedNodeCanvasRenderCmd) --- extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 1a1a34f113..564b30be35 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -78,7 +78,7 @@ var i, len, selChildren, item; if (this._cascadeOpacityEnabledDirty && !node._cascadeOpacityEnabled) { this._displayedOpacity = node._realOpacity; - selChildren = this._children; + selChildren = node._children; for (i = 0, len = selChildren.length; i < len; i++) { item = selChildren[i]; if (item && item._renderCmd) From d9888249635d798399308b1c21a760d81373f081 Mon Sep 17 00:00:00 2001 From: Park Hyun Chen Date: Wed, 28 Jan 2015 20:22:36 +0900 Subject: [PATCH 1294/1564] Update CCArmatureAnimation.js --- .../cocostudio/armature/animation/CCArmatureAnimation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js index fda7946a17..06fd7f75f3 100644 --- a/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +++ b/extensions/cocostudio/armature/animation/CCArmatureAnimation.js @@ -526,7 +526,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# */ setMovementEventCallFunc: function (callFunc, target) { if(arguments.length == 1){ - this._frameEventListener = callFunc; + this._movementEventListener = callFunc; }else if(arguments.length == 2){ this._movementEventTarget = target; this._movementEventCallFunc = callFunc; @@ -666,4 +666,4 @@ _p = null; */ ccs.ArmatureAnimation.create = function (armature) { return new ccs.ArmatureAnimation(armature); -}; \ No newline at end of file +}; From 29e2f5a0bc205f8e53b4c4ce48290a364ce27108 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 29 Jan 2015 13:37:15 +0800 Subject: [PATCH 1295/1564] repair queue repeat errors --- cocos2d/actions/CCActionInterval.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index fe0d0bc4c1..7b97fb9b57 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -501,12 +501,25 @@ cc.sequence = function (/*Multiple Arguments*/tempArray) { if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null)) cc.log("parameters should not be ending with null in Javascript"); - var prev = paramArray[0]; - for (var i = 1; i < paramArray.length; i++) { - if (paramArray[i]) - prev = cc.Sequence._actionOneTwo(prev, paramArray[i]); + var result, current, i, repeat; + while(paramArray && paramArray.length > 0){ + current = Array.prototype.shift.call(paramArray); + repeat = current._timesForRepeat || 1; + current._repeatMethod = false; + current._timesForRepeat = 1; + + i = 0; + if(!result){ + result = current; + i = 1; + } + + for(i; i Date: Thu, 29 Jan 2015 14:09:28 +0800 Subject: [PATCH 1296/1564] Listen orientation change event for resolution policy --- cocos2d/core/platform/CCEGLView.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index c54f79024a..7375997f0b 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -195,8 +195,15 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ }else{ view = cc.view; } + + // Check frame size changed or not + var prevFrameW = view._frameSize.width, prevFrameH = view._frameSize.height; + view._initFrameSize(); + if (view._frameSize.width == prevFrameW && view._frameSize.height == prevFrameH) + return; + + // Frame size changed, do resize works if (view._resizeCallback) { - view._initFrameSize(); view._resizeCallback.call(); } var width = view._originalDesignResolutionSize.width; @@ -239,13 +246,15 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ //enable if (!this.__resizeWithBrowserSize) { this.__resizeWithBrowserSize = true; - cc._addEventListener(window, 'resize', this._resizeEvent, false); + cc._addEventListener(window, 'resize', this._resizeEvent); + cc._addEventListener(window, 'orientationchange', this._resizeEvent); } } else { //disable if (this.__resizeWithBrowserSize) { this.__resizeWithBrowserSize = false; - window.removeEventListener('resize', this._resizeEvent, false); + window.removeEventListener('resize', this._resizeEvent); + window.removeEventListener('orientationchange', this._resizeEvent); } } }, @@ -552,6 +561,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ return; } + // Reinit frame size + this._initFrameSize(); + this.setResolutionPolicy(resolutionPolicy); var policy = this._resolutionPolicy; if (!policy){ @@ -560,12 +572,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ } policy.preApply(this); - // Reinit frame size if(cc.sys.isMobile) this._setViewPortMeta(); - this._initFrameSize(); - this._originalDesignResolutionSize.width = this._designResolutionSize.width = width; this._originalDesignResolutionSize.height = this._designResolutionSize.height = height; From f7a6cff563e66471e1d928b3329e66514c3bc435 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 29 Jan 2015 14:12:51 +0800 Subject: [PATCH 1297/1564] Fix _anchorPointInPoints usage issue --- cocos2d/node-grid/CCNodeGrid.js | 5 +++-- extensions/editbox/CCdomNode.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index 3c0e1d6f8a..f75ce939f8 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -84,8 +84,9 @@ cc.NodeGrid = cc.Node.extend({ // XXX: Expensive calls. Camera should be integrated into the cached affine matrix if (this._camera != null && !(this.grid && this.grid.isActive())) { - var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; - var translate = (apx !== 0.0 || apy !== 0.0); + var app = this._renderCmd._anchorPointInPoints, + apx = app.x, apy = app.y, + translate = (apx !== 0.0 || apy !== 0.0); if (translate) { if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) { apx = 0 | apx; diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index a90efb3702..1c49130546 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -168,12 +168,13 @@ cc.DOM.methods = /** @lends cc.DOM# */{ */ _setAnchorX:function (x) { var locAnchorPoint = this._anchorPoint; + var cmd = this._renderCmd; if (x === locAnchorPoint.x) return; locAnchorPoint.x = x; - var locAPP = this._anchorPointInPoints, locSize = this._contentSize; + var locAPP = cmd._anchorPointInPoints, locSize = this._contentSize; locAPP.x = locSize.width * locAnchorPoint.x; this.dom.style[cc.$.pfx + 'TransformOrigin'] = '' + locAPP.x + 'px ' + -locAPP.y + 'px'; @@ -192,12 +193,13 @@ cc.DOM.methods = /** @lends cc.DOM# */{ */ _setAnchorY:function (y) { var locAnchorPoint = this._anchorPoint; + var cmd = this._renderCmd; if (y === locAnchorPoint.y) return; locAnchorPoint.y = y; - var locAPP = this._anchorPointInPoints, locSize = this._contentSize; + var locAPP = cmd._anchorPointInPoints, locSize = this._contentSize; locAPP.y = locSize.height * locAnchorPoint.y; this.dom.style[cc.$.pfx + 'TransformOrigin'] = '' + locAPP.x + 'px ' + -locAPP.y + 'px'; @@ -246,11 +248,12 @@ cc.DOM.methods = /** @lends cc.DOM# */{ */ _setWidth:function (width) { var locContentSize = this._contentSize; + var cmd = this._renderCmd; if (width === locContentSize.width) return; locContentSize.width = width; - var locAPP = this._anchorPointInPoints, locAnchorPoint = this._anchorPoint; + var locAPP = cmd._anchorPointInPoints, locAnchorPoint = this._anchorPoint; locAPP.x = locContentSize.width * locAnchorPoint.x; this.dom.width = locContentSize.width; this.anchorX = locAnchorPoint.x; @@ -267,11 +270,12 @@ cc.DOM.methods = /** @lends cc.DOM# */{ */ _setHeight:function (height) { var locContentSize = this._contentSize; + var cmd = this._renderCmd; if (height === locContentSize.height) return; locContentSize.height = height; - var locAPP = this._anchorPointInPoints, locAnchorPoint = this._anchorPoint; + var locAPP = cmd._anchorPointInPoints, locAnchorPoint = this._anchorPoint; locAPP.y = locContentSize.height * locAnchorPoint.y; this.dom.height = locContentSize.height; this.anchorY = locAnchorPoint.y; From 3057b33eec8c046e65729c0982057ba6111f52f9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 29 Jan 2015 14:13:10 +0800 Subject: [PATCH 1298/1564] Fix EditBox position issue on web --- extensions/editbox/CCdomNode.js | 80 +++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index 1c49130546..fb62932ed3 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -426,13 +426,13 @@ cc.DOM.methods = /** @lends cc.DOM# */{ }; cc.DOM._resetEGLViewDiv = function(){ - var eglViewDiv = cc.$("#EGLViewDiv"); - if(eglViewDiv){ - var eglViewer = cc.view; - var designSize = eglViewer.getDesignResolutionSize(); - var viewPortRect = eglViewer.getViewPortRect(); - var screenSize = eglViewer.getFrameSize(); - var pixelRatio = eglViewer.getDevicePixelRatio(); + var div = cc.$("#EGLViewDiv"); + if(div){ + var view = cc.view; + var designSize = view.getDesignResolutionSize(); + var viewPortRect = view.getViewPortRect(); + var screenSize = view.getFrameSize(); + var pixelRatio = view.getDevicePixelRatio(); var designSizeWidth = designSize.width, designSizeHeight = designSize.height; if((designSize.width === 0) && (designSize.height === 0)){ designSizeWidth = screenSize.width; @@ -444,15 +444,21 @@ cc.DOM._resetEGLViewDiv = function(){ viewPortWidth = screenSize.width; } - eglViewDiv.style.position = 'absolute'; + div.style.position = 'absolute'; //x.dom.style.display='block'; - eglViewDiv.style.width = designSizeWidth + "px"; - eglViewDiv.style.maxHeight = designSizeHeight + "px"; - eglViewDiv.style.margin = 0; - - eglViewDiv.resize(eglViewer.getScaleX()/pixelRatio, eglViewer.getScaleY()/pixelRatio); - eglViewDiv.style.left = (viewPortWidth - designSizeWidth) / 2 + "px"; - eglViewDiv.style.bottom = "0px"; + div.style.width = designSizeWidth + "px"; + div.style.maxHeight = designSizeHeight + "px"; + div.style.margin = 0; + + div.resize(view.getScaleX()/pixelRatio, view.getScaleY()/pixelRatio); + if (view.getResolutionPolicy() == view._rpNoBorder) { + div.style.left = (view.getFrameSize().width - designSizeWidth)/2 + "px"; + div.style.bottom = (view.getFrameSize().height - designSizeHeight*view.getScaleY()/pixelRatio)/2 + "px"; + } + else { + div.style.left = (designSizeWidth*view.getScaleX()/pixelRatio - designSizeWidth) / 2 + "px"; + div.style.bottom = "0px"; + } } }; @@ -493,17 +499,17 @@ cc.DOM.parentDOM = function (x) { }; cc.DOM._createEGLViewDiv = function(p){ - var eglViewDiv = cc.$("#EGLViewDiv"); - if(!eglViewDiv){ - eglViewDiv = cc.$new("div"); - eglViewDiv.id = "EGLViewDiv"; + var div = cc.$("#EGLViewDiv"); + if(!div){ + div = cc.$new("div"); + div.id = "EGLViewDiv"; } - var eglViewer = cc.view; - var designSize = eglViewer.getDesignResolutionSize(); - var viewPortRect = eglViewer.getViewPortRect(); - var screenSize = eglViewer.getFrameSize(); - var pixelRatio = eglViewer.getDevicePixelRatio(); + var view = cc.view; + var designSize = view.getDesignResolutionSize(); + var viewPortRect = view.getViewPortRect(); + var screenSize = view.getFrameSize(); + var pixelRatio = view.getDevicePixelRatio(); var designSizeWidth = designSize.width, designSizeHeight = designSize.height; if ((designSize.width === 0) && (designSize.height === 0)) { designSizeWidth = screenSize.width; @@ -515,18 +521,24 @@ cc.DOM._createEGLViewDiv = function(p){ viewPortWidth = screenSize.width; } - eglViewDiv.style.position = 'absolute'; + div.style.position = 'absolute'; //x.dom.style.display='block'; - eglViewDiv.style.width = designSizeWidth + "px"; - eglViewDiv.style.maxHeight = designSizeHeight + "px"; - eglViewDiv.style.margin = 0; - - eglViewDiv.resize(eglViewer.getScaleX()/pixelRatio, eglViewer.getScaleY()/pixelRatio); - eglViewDiv.style.left = (viewPortWidth - designSizeWidth) / 2 + "px"; - eglViewDiv.style.bottom = "0px"; + div.style.width = designSizeWidth + "px"; + div.style.maxHeight = designSizeHeight + "px"; + div.style.margin = 0; + + div.resize(view.getScaleX()/pixelRatio, view.getScaleY()/pixelRatio); + if (view.getResolutionPolicy() == view._rpNoBorder) { + div.style.left = (screenSize.width - designSizeWidth)/2 + "px"; + div.style.bottom = (screenSize.height - designSizeHeight*view.getScaleY()/pixelRatio)/2 + "px"; + } + else { + div.style.left = (designSizeWidth*view.getScaleX()/pixelRatio - designSizeWidth) / 2 + "px"; + div.style.bottom = "0px"; + } - p.dom.appendTo(eglViewDiv); - eglViewDiv.appendTo(cc.container); + p.dom.appendTo(div); + div.appendTo(cc.container); }; /** From 6f9c61f22c8ff10f26ffb67b809b67d8b703d2c7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 29 Jan 2015 14:59:58 +0800 Subject: [PATCH 1299/1564] Add a message to Armature that it doesn't support to add widget as its child. --- extensions/cocostudio/armature/CCArmature.js | 8 ++++++++ .../cocostudio/armature/CCArmatureWebGLRenderCmd.js | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index 9577d3c831..d743c19b25 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -151,6 +151,14 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ return true; }, + addChild: function (child, localZOrder, tag) { + if(child instanceof ccui.Widget){ + cc.log("Armature doesn't support to add Widget as its child, it will be fix soon."); + return; + } + cc.Node.prototype.addChild.call(this, child, localZOrder, tag); + }, + /** * create a bone with name * @param {String} boneName diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index 42985ca1e0..54bf4e762a 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -83,7 +83,8 @@ } else if (selBone instanceof cc.Node) { selBone.setShaderProgram(this._shaderProgram); selBone._renderCmd.transform(); - selBone._renderCmd.rendering(ctx); + if(selBone._renderCmd.rendering) + selBone._renderCmd.rendering(ctx); } } if(!dontChangeMatrix) From 230f04984ac4aad2739f19a72e2298465af7aa0c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 29 Jan 2015 15:50:44 +0800 Subject: [PATCH 1300/1564] Fixed #2651: fixed a bug of cc.GLProgram that it doesn't work on some devices which isn't supported highp float precision. --- cocos2d/shaders/CCGLProgram.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 831b91fd7a..1b429a9734 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -83,8 +83,8 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ if (!source || !shader) return false; - //var preStr = (type == this._glContext.VERTEX_SHADER) ? "precision highp float;\n" : "precision mediump float;\n"; - source = "precision highp float; \n" + var preStr = cc.GLProgram._isHighpSupported() ? "precision highp float;\n" : "precision mediump float;\n"; + source = preStr + "uniform mat4 CC_PMatrix; \n" + "uniform mat4 CC_MVMatrix; \n" + "uniform mat4 CC_MVPMatrix; \n" @@ -731,6 +731,17 @@ cc.GLProgram.create = function (vShaderFileName, fShaderFileName) { return new cc.GLProgram(vShaderFileName, fShaderFileName); }; +cc.GLProgram._highpSupported = null; + +cc.GLProgram._isHighpSupported = function(){ + if(cc.GLProgram._highpSupported == null){ + var ctx = cc._renderContext; + var highp = ctx.getShaderPrecisionFormat(ctx.FRAGMENT_SHADER, ctx.HIGH_FLOAT); + cc.GLProgram._highpSupported = highp.precision != 0; + } + return cc.GLProgram._highpSupported; +}; + /** *

    * Sets the shader program for this node From 69f106b0131b61f7a89f603dd054848c5490ec01 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 29 Jan 2015 16:16:52 +0800 Subject: [PATCH 1301/1564] change node transform --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 90 ++++++++----------- .../core/sprites/CCSpriteCanvasRenderCmd.js | 10 +-- 2 files changed, 39 insertions(+), 61 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 77076067d6..9b0859b5bf 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -243,39 +243,45 @@ cc.Node.RenderCmd.prototype = { this._cachedParent = null; this._cacheDirty = false; - this.__point = { - x: 0, - y: 0 - }; }; var proto = cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype); proto.constructor = cc.Node.CanvasRenderCmd; proto.transform = function (parentCmd, recursive) { + var node = this._node; // transform for canvas var t = this.getNodeToParentTransform(), worldT = this._worldTransform; //get the world transform if (parentCmd) { - var pt = parentCmd._worldTransform, - pn = parentCmd._node; - var pAnchor = parentCmd._anchorPointInPoints; - + var pt = parentCmd._worldTransform; // cc.AffineTransformConcat is incorrect at get world transform worldT.a = pt.a * t.a + pt.b * t.c; //a worldT.b = pt.a * t.b + pt.b * t.d; //b worldT.c = pt.c * t.a + pt.d * t.c; //c worldT.d = pt.c * t.b + pt.d * t.d; //d - if(pn && !pn._ignoreAnchorPointForPosition){ - worldT.tx = pt.a * (t.tx - pAnchor.x) - pt.b * (t.ty - pAnchor.y) + pt.tx; - worldT.ty = -pt.c * (t.tx - pAnchor.x) + pt.d * (t.ty - pAnchor.y) + pt.ty; - }else{ - worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx; - worldT.ty = -pt.c * t.tx + pt.d * t.ty + pt.ty; - } + worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx ; + worldT.ty = -pt.c * t.tx + pt.d * t.ty + pt.ty; + var lScaleX = node._scaleX, lScaleY = node._scaleY; + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + var appX = this._anchorPointInPoints.x / lScaleX, + appY = this._anchorPointInPoints.y / lScaleY; + + // adjust anchorPoint + worldT.tx += worldT.a * -appX * sx + worldT.b * appY * sy; + worldT.ty -= worldT.c * -appX * sx + worldT.d * appY * sy; + + // if ignore anchorPoint + if (this._node._ignoreAnchorPointForPosition) { + worldT.tx += appX; + worldT.ty += appY; + } } else { worldT.a = t.a; worldT.b = t.b; @@ -311,41 +317,33 @@ cc.Node.RenderCmd.prototype = { t.tx = node._position.x; t.ty = node._position.y; + var lScaleX = node._scaleX, lScaleY = node._scaleY; + + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + // rotation Cos and Sin - var A = 1, B = 0, - C = 0, D = 1; + var A = sx, B = 0, + C = 0, D = sy; if (node._rotationX) { var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - B = -Math.sin(rotationRadiansX); - D = Math.cos(rotationRadiansX); + B = -Math.sin(rotationRadiansX) * sy; + D = Math.cos(rotationRadiansX) * sy; } if (node._rotationY) { var rotationRadiansY = node._rotationY * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - A = Math.cos(rotationRadiansY); - C = Math.sin(rotationRadiansY); + A = Math.cos(rotationRadiansY) * sx; + C = Math.sin(rotationRadiansY) * sx; } + t.a = A; t.b = B; t.c = C; t.d = D; - var lScaleX = node._scaleX, lScaleY = node._scaleY; - var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; - - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.c *= sx; - t.b *= sy; - t.d *= sy; - } - // skew if (node._skewX || node._skewY) { // offset the anchorpoint @@ -355,30 +353,12 @@ cc.Node.RenderCmd.prototype = { skx = 99999999; if (sky === Infinity) sky = 99999999; - var xx = appY * skx * sx; - var yy = appX * sky * sy; t.a = A + B * sky; t.b = A * skx + B; t.c = C + D * sky; t.d = C * skx + D; - t.tx += A * xx + B * yy; - t.ty += C * xx + D * yy; } -// var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; -// // adjust anchorPoint -// t.tx += A * -appX * sx + B * appY * sy; -// t.ty -= C * -appX * sx + D * appY * sy; - - this.__point.x = A * -appX * sx + B * appY * sy; - this.__point.y = C * -appX * sx + D * appY * sy; -// -// // if ignore anchorPoint -// if (node._ignoreAnchorPointForPosition) { -// t.tx += appX; -// t.ty += appY; -// } - if (node._additionalTransformDirty) { this._transform = cc.affineTransformConcat(t, node._additionalTransform); node._additionalTransformDirty = false; diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 92567ad6c5..05984018fd 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -119,8 +119,6 @@ || !node._texture._textureLoaded)) || alpha === 0) return; - var anchor = this._anchorPointInPoints; - var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); var locX = node._offsetPosition.x, locHeight = node._rect.height, locWidth = node._rect.width, locY = -node._offsetPosition.y - locHeight, image; @@ -144,16 +142,16 @@ image = node._texture._htmlElementObj; if (node._texture._pattern != "") { wrapper.setFillStyle(context.createPattern(image, node._texture._pattern)); - context.fillRect((locX - anchor.x) * scaleX, (locY + anchor.y) * scaleY, locWidth * scaleX, locHeight * scaleY); + context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); } else { if (this._colorized) { context.drawImage(image, 0, 0, locTextureCoord.width,locTextureCoord.height, - (locX-anchor.x) * scaleX, (locY+anchor.y) * scaleY, locWidth * scaleX, locHeight * scaleY); + locX * scaleX,locY * scaleY, locWidth * scaleX, locHeight * scaleY); } else { context.drawImage(image, locTextureCoord.renderX, locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, - (locX-anchor.x) * scaleX, (locY+anchor.y) * scaleY, locWidth * scaleX, locHeight * scaleY); + locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); } } } else { @@ -161,7 +159,7 @@ if (locTextureCoord.validRect) { var curColor = this._displayedColor; wrapper.setFillStyle("rgba(" + curColor.r + "," + curColor.g + "," + curColor.b + ",1)"); - context.fillRect((locX-anchor.x) * scaleX, (locY + anchor.y) * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); + context.fillRect(locX * scaleX, locY * scaleY, contentSize.width * scaleX, contentSize.height * scaleY); } } if(node._flippedX || node._flippedY) From 0d7d06f2d008a002e17831400db8d9c8624ec915 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 29 Jan 2015 16:32:14 +0800 Subject: [PATCH 1302/1564] change ccui transform --- .../CCProtectedNodeCanvasRenderCmd.js | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 564b30be35..60d1c3dc84 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -206,21 +206,33 @@ node._changePosition(); var t = node.getNodeToParentTransform(), worldT = this._worldTransform; - if(parentCmd){ + if (parentCmd) { var pt = parentCmd._worldTransform; - worldT.a = t.a * pt.a + t.b * pt.c; //a - worldT.b = t.a * pt.b + t.b * pt.d; //b - worldT.c = t.c * pt.a + t.d * pt.c; //c - worldT.d = t.c * pt.b + t.d * pt.d; //d - if(node._skewX || node._skewY){ - var plt = parentCmd._transform; - var xOffset = -(plt.b + plt.c) * t.ty ; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty - }else{ - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty + // cc.AffineTransformConcat is incorrect at get world transform + worldT.a = pt.a * t.a + pt.b * t.c; //a + worldT.b = pt.a * t.b + pt.b * t.d; //b + worldT.c = pt.c * t.a + pt.d * t.c; //c + worldT.d = pt.c * t.b + pt.d * t.d; //d + + worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx ; + worldT.ty = -pt.c * t.tx + pt.d * t.ty + pt.ty; + + var lScaleX = node._scaleX, lScaleY = node._scaleY; + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + var appX = this._anchorPointInPoints.x / lScaleX, + appY = this._anchorPointInPoints.y / lScaleY; + + // adjust anchorPoint + worldT.tx += worldT.a * -appX * sx + worldT.b * appY * sy; + worldT.ty -= worldT.c * -appX * sx + worldT.d * appY * sy; + + // if ignore anchorPoint + if (this._node._ignoreAnchorPointForPosition) { + worldT.tx += appX; + worldT.ty += appY; } } else { worldT.a = t.a; From 375b33fbb8268738e5adf36a53bdd5872d4f4a32 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 29 Jan 2015 17:57:39 +0800 Subject: [PATCH 1303/1564] Fixed #2488: fixed a bug of cc.FadeOut and cc.FadeIn that they don't work when duration is 0 --- cocos2d/actions/CCActionInterval.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js index 7b97fb9b57..4d6243b1dc 100644 --- a/cocos2d/actions/CCActionInterval.js +++ b/cocos2d/actions/CCActionInterval.js @@ -2654,7 +2654,6 @@ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{ time = this._computeEaseTime(time); var fromOpacity = this._fromOpacity !== undefined ? this._fromOpacity : 255; this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time; - }, /** @@ -2706,7 +2705,9 @@ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{ */ ctor:function (duration) { cc.FadeTo.prototype.ctor.call(this); - duration && this.initWithDuration(duration, 255); + if (duration == null) + duration = 0; + this.initWithDuration(duration, 255); }, /** @@ -2780,7 +2781,9 @@ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{ */ ctor:function (duration) { cc.FadeTo.prototype.ctor.call(this); - duration && this.initWithDuration(duration, 0); + if (duration == null) + duration = 0; + this.initWithDuration(duration, 0); }, /** From b18fac6eecce140d7f4b8f9ae1bcd3786b238005 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 Jan 2015 10:08:47 +0800 Subject: [PATCH 1304/1564] Listen orientation change event for resolution policy --- cocos2d/core/platform/CCEGLView.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 7375997f0b..068ab4188f 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -60,6 +60,12 @@ cc.__BrowserGetter = { switch(cc.sys.browserType){ case cc.sys.BROWSER_TYPE_SAFARI: cc.__BrowserGetter.meta["minimal-ui"] = "true"; + cc.__BrowserGetter.availWidth = function(frame){ + return frame.clientWidth; + }; + cc.__BrowserGetter.availHeight = function(frame){ + return frame.clientHeight; + }; break; case cc.sys.BROWSER_TYPE_CHROME: cc.__BrowserGetter.__defineGetter__("target-densitydpi", function(){ @@ -246,15 +252,15 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ //enable if (!this.__resizeWithBrowserSize) { this.__resizeWithBrowserSize = true; - cc._addEventListener(window, 'resize', this._resizeEvent); - cc._addEventListener(window, 'orientationchange', this._resizeEvent); + cc._addEventListener(window, 'resize', this._resizeEvent, false); + cc._addEventListener(window, 'orientationchange', this._resizeEvent, false); } } else { //disable if (this.__resizeWithBrowserSize) { - this.__resizeWithBrowserSize = false; - window.removeEventListener('resize', this._resizeEvent); - window.removeEventListener('orientationchange', this._resizeEvent); + this.__resizeWithBrowserSize = true; + window.removeEventListener('resize', this._resizeEvent, false); + window.removeEventListener('orientationchange', this._resizeEvent, false); } } }, @@ -561,9 +567,6 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ return; } - // Reinit frame size - this._initFrameSize(); - this.setResolutionPolicy(resolutionPolicy); var policy = this._resolutionPolicy; if (!policy){ @@ -572,9 +575,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ } policy.preApply(this); + // Reinit frame size if(cc.sys.isMobile) this._setViewPortMeta(); + this._initFrameSize(); + this._originalDesignResolutionSize.width = this._designResolutionSize.width = width; this._originalDesignResolutionSize.height = this._designResolutionSize.height = height; From aba727f4999eca506cb76576c43afabe376c99e1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 Jan 2015 10:27:56 +0800 Subject: [PATCH 1305/1564] onended callback time is error (Second plays will direct callback) --- cocos2d/audio/CCAudio.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 0500abad0c..aa39edcd72 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -302,10 +302,6 @@ cc.Audio = cc.Class.extend({ audio["noteOn"](0); } this._currentSource = audio; - var self = this; - audio["onended"] = function(){ - self._playing = false; - }; }, _playOfAudio: function(){ From c2c50433f03d7e6c40aae86cbb47c1d4866b0614 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 Jan 2015 10:31:00 +0800 Subject: [PATCH 1306/1564] Listen orientation change event for resolution policy --- cocos2d/core/platform/CCEGLView.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 068ab4188f..78184ce5c5 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -252,15 +252,15 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ //enable if (!this.__resizeWithBrowserSize) { this.__resizeWithBrowserSize = true; - cc._addEventListener(window, 'resize', this._resizeEvent, false); - cc._addEventListener(window, 'orientationchange', this._resizeEvent, false); + cc._addEventListener(window, 'resize', this._resizeEvent); + cc._addEventListener(window, 'orientationchange', this._resizeEvent); } } else { //disable if (this.__resizeWithBrowserSize) { - this.__resizeWithBrowserSize = true; - window.removeEventListener('resize', this._resizeEvent, false); - window.removeEventListener('orientationchange', this._resizeEvent, false); + this.__resizeWithBrowserSize = false; + window.removeEventListener('resize', this._resizeEvent); + window.removeEventListener('orientationchange', this._resizeEvent); } } }, From beecce14fc934cef11d7e0bff9112e4e3e4fd1ad Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 Jan 2015 11:24:49 +0800 Subject: [PATCH 1307/1564] Listen orientation change event for resolution policy --- cocos2d/audio/CCAudio.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index aa39edcd72..d47cb112a7 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -174,6 +174,8 @@ cc.Audio = cc.Class.extend({ _context: null, _volume: null, + _ignoreEnded: false, + //DOM Audio _element: null, @@ -262,9 +264,10 @@ cc.Audio = cc.Class.extend({ return; } if(!this._pause && cs){ - if(this._context.currentTime === 0 || this._currentTime + this._context.currentTime - this._startTime > this._currentSource.buffer.duration) + if(this._context.currentTime === 0 || this._currentTime + this._context.currentTime - this._startTime > this._currentSource.buffer.duration){ + this._ignoreEnded = true; this._stopOfWebAudio(); - else + }else return; } var audio = this._context["createBufferSource"](); @@ -302,6 +305,14 @@ cc.Audio = cc.Class.extend({ audio["noteOn"](0); } this._currentSource = audio; + var self = this; + audio["onended"] = function(){ + if(self._ignoreEnded){ + self._ignoreEnded = false; + }else{ + self._playing = false; + } + }; }, _playOfAudio: function(){ @@ -1010,5 +1021,4 @@ cc.Audio = cc.Class.extend({ cc.audioEngine._resumePlaying(); }); - })(cc.__audioSupport); From 544e3d6e305806cb82e29c1f959a5dc02626db3b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 Jan 2015 11:45:21 +0800 Subject: [PATCH 1308/1564] Listen orientation change event for resolution policy --- cocos2d/audio/CCAudio.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index d47cb112a7..ab5dc5478a 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -264,10 +264,9 @@ cc.Audio = cc.Class.extend({ return; } if(!this._pause && cs){ - if(this._context.currentTime === 0 || this._currentTime + this._context.currentTime - this._startTime > this._currentSource.buffer.duration){ - this._ignoreEnded = true; + if(this._context.currentTime === 0 || this._currentTime + this._context.currentTime - this._startTime > this._currentSource.buffer.duration) this._stopOfWebAudio(); - }else + else return; } var audio = this._context["createBufferSource"](); @@ -334,6 +333,7 @@ cc.Audio = cc.Class.extend({ _stopOfWebAudio: function(){ var audio = this._currentSource; + this._ignoreEnded = true; if(audio){ audio.stop(0); this._currentSource = null; From 666cc06e128d343c90ee191d2096d568394d1dfe Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 30 Jan 2015 16:20:43 +0800 Subject: [PATCH 1309/1564] update version string --- cocos2d/core/platform/CCConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index f960492f24..7208062c13 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3 Beta0"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3 RC0"; /** *

    From fe902a05901bf87c642be5a4ca9b41f046e292ad Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 31 Jan 2015 01:22:22 +0800 Subject: [PATCH 1310/1564] Fix CCB animation auto play issue --- extensions/ccb-reader/CCBReader.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index 98d8512233..cde09e6f92 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -1080,6 +1080,9 @@ cc.BuilderReader.load = function (ccbFilePath, owner, parentSize, ccbRootPath) { } } + //auto play animations + animationManager.runAnimations(animationManager.getAutoPlaySequenceId(), 0); + return node; }; From 1641bdad29ede27ae1f23485f8ad3d62476128a9 Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Sat, 31 Jan 2015 11:58:15 +0200 Subject: [PATCH 1311/1564] Add MESH to the attachment types. --- extensions/spine/CCSkeleton.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index e60491d668..0e4aadd472 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -48,14 +48,15 @@ sp.VERTEX_INDEX = { }; /** - * The attachment type of spine. It contains three type: REGION(0), BOUNDING_BOX(1) and REGION_SEQUENCE(2). + * The attachment type of spine. It contains three type: REGION(0), BOUNDING_BOX(1), REGION_SEQUENCE(2) and MESH(2). * @constant - * @type {{REGION: number, BOUNDING_BOX: number, REGION_SEQUENCE: number}} + * @type {{REGION: number, BOUNDING_BOX: number, REGION_SEQUENCE: number, MESH: number}} */ sp.ATTACHMENT_TYPE = { REGION: 0, BOUNDING_BOX: 1, - REGION_SEQUENCE: 2 + REGION_SEQUENCE: 2, + MESH: 2 }; /** From b69d9b543f2fa83d812098a10272a6d7457f561b Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Sat, 31 Jan 2015 12:00:05 +0200 Subject: [PATCH 1312/1564] Add update verticles method for meshAttachment. --- extensions/spine/CCSkeletonWebGLRenderCmd.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index 4b12770e79..9b78bbd0eb 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -54,7 +54,7 @@ for (i = 0, n = locSkeleton.slots.length; i < n; i++) { slot = locSkeleton.drawOrder[i]; - if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) + if (!slot.attachment) continue; attachment = slot.attachment; var regionTextureAtlas = node.getTextureAtlas(attachment); @@ -80,7 +80,15 @@ return; } - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + switch(slot.attachment.type) { + case sp.ATTACHMENT_TYPE.REGION: + sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + break; + case sp.ATTACHMENT_TYPE.MESH: + sp._meshAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + break; + } + textureAtlas.updateQuad(quad, quadCount); } From 5a11b64da33801a3b861447189d90f02e20202a8 Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Sat, 31 Jan 2015 12:01:30 +0200 Subject: [PATCH 1313/1564] Add _meshAttachment_updateQuad method. --- extensions/spine/CCSkeletonAnimation.js | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index c71948ea80..19a2884e9b 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -116,6 +116,45 @@ sp._regionAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) quad.br.texCoords.v = self.uvs[VERTEX.Y4]; }; +sp._meshAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { + var vertices = {}; + self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot, vertices); + var r = slot.skeleton.r * slot.r * 255; + var g = slot.skeleton.g * slot.g * 255; + var b = slot.skeleton.b * slot.b * 255; + var normalizedAlpha = slot.skeleton.a * slot.a; + if (premultipliedAlpha) { + r *= normalizedAlpha; + g *= normalizedAlpha; + b *= normalizedAlpha; + } + var a = normalizedAlpha * 255; + + quad.bl.colors.r = quad.tl.colors.r = quad.tr.colors.r = quad.br.colors.r = r; + quad.bl.colors.g = quad.tl.colors.g = quad.tr.colors.g = quad.br.colors.g = g; + quad.bl.colors.b = quad.tl.colors.b = quad.tr.colors.b = quad.br.colors.b = b; + quad.bl.colors.a = quad.tl.colors.a = quad.tr.colors.a = quad.br.colors.a = a; + + var VERTEX = sp.VERTEX_INDEX; + quad.bl.vertices.x = vertices[VERTEX.X1]; + quad.bl.vertices.y = vertices[VERTEX.Y1]; + quad.tl.vertices.x = vertices[VERTEX.X2]; + quad.tl.vertices.y = vertices[VERTEX.Y2]; + quad.tr.vertices.x = vertices[VERTEX.X3]; + quad.tr.vertices.y = vertices[VERTEX.Y3]; + quad.br.vertices.x = vertices[VERTEX.X4]; + quad.br.vertices.y = vertices[VERTEX.Y4]; + + quad.bl.texCoords.u = self.uvs[VERTEX.X1]; + quad.bl.texCoords.v = self.uvs[VERTEX.Y1]; + quad.tl.texCoords.u = self.uvs[VERTEX.X2]; + quad.tl.texCoords.v = self.uvs[VERTEX.Y2]; + quad.tr.texCoords.u = self.uvs[VERTEX.X3]; + quad.tr.texCoords.v = self.uvs[VERTEX.Y3]; + quad.br.texCoords.u = self.uvs[VERTEX.X4]; + quad.br.texCoords.v = self.uvs[VERTEX.Y4]; +}; + sp._regionAttachment_updateSlotForCanvas = function(self, slot, points) { if(!points) return; From ef695a754f43caba819b6f6e4727fcbf284f169f Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Sat, 31 Jan 2015 12:04:38 +0200 Subject: [PATCH 1314/1564] Update Spine.js from official spine runtimes repo. --- extensions/spine/Spine.js | 638 +++++++++++++++++++++++++++++++------- 1 file changed, 529 insertions(+), 109 deletions(-) diff --git a/extensions/spine/Spine.js b/extensions/spine/Spine.js index a5bd20cc0f..c446ff7247 100644 --- a/extensions/spine/Spine.js +++ b/extensions/spine/Spine.js @@ -26,7 +26,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -var spine = spine || {}; +var spine = spine || { + radDeg: 180 / Math.PI, + degRad: Math.PI / 180, + temp: [], + Float32Array: (typeof(Float32Array) === 'undefined') ? Array : Float32Array, + Uint16Array: (typeof(Uint16Array) === 'undefined') ? Array : Uint16Array +}; spine.BoneData = function (name, parent) { this.name = name; @@ -161,7 +167,6 @@ spine.Skin.prototype = { return this.attachments[slotIndex + ":" + name]; }, _attachAll: function (skeleton, oldSkin) { - console.log(oldSkin.attachments); for (var key in oldSkin.attachments) { var colon = key.indexOf(":"); var slotIndex = parseInt(key.substring(0, colon)); @@ -811,7 +816,9 @@ spine.Event.prototype = { spine.AttachmentType = { region: 0, - boundingbox: 1 + boundingbox: 1, + mesh: 2, + skinnedmesh: 3 }; spine.RegionAttachment = function (name) { @@ -883,7 +890,8 @@ spine.RegionAttachment.prototype = { offset[6/*X4*/] = localX2Cos - localYSin; offset[7/*Y4*/] = localYCos + localX2Sin; }, - computeVertices: function (x, y, bone, vertices) { + computeVertices: function (x, y, slot, vertices) { + var bone = slot.bone; x += bone.worldX; y += bone.worldY; var m00 = bone.m00; @@ -902,6 +910,141 @@ spine.RegionAttachment.prototype = { } }; +spine.MeshAttachment = function (name) { + this.name = name; +}; +spine.MeshAttachment.prototype = { + type: spine.AttachmentType.mesh, + vertices: null, + uvs: null, + regionUVs: null, + triangles: null, + hullLength: 0, + r: 1, g: 1, b: 1, a: 1, + path: null, + rendererObject: null, + regionU: 0, regionV: 0, regionU2: 0, regionV2: 0, regionRotate: false, + regionOffsetX: 0, regionOffsetY: 0, + regionWidth: 0, regionHeight: 0, + regionOriginalWidth: 0, regionOriginalHeight: 0, + edges: null, + width: 0, height: 0, + updateUVs: function () { + var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV; + var n = this.regionUVs.length; + if (!this.uvs || this.uvs.length != n) { + this.uvs = new spine.Float32Array(n); + } + if (this.regionRotate) { + for (var i = 0; i < n; i += 2) { + this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width; + this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height; + } + } else { + for (var i = 0; i < n; i += 2) { + this.uvs[i] = this.regionU + this.regionUVs[i] * width; + this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height; + } + } + }, + computeVertices: function (x, y, slot, vertices) { + var bone = slot.bone; + x += bone.worldX; + y += bone.worldY; + var m00 = bone.m00, m01 = bone.m01, m10 = bone.m10, m11 = bone.m11; + var verticesCount = this.vertices.length; + if (slot.attachment.length == verticesCount) this.vertices = slot.attachment; + for (var i = 0; i < verticesCount; i += 2) { + var vx = this.vertices[i]; + var vy = this.vertices[i + 1]; + vertices[i] = vx * m00 + vy * m01 + x; + vertices[i + 1] = vx * m10 + vy * m11 + y; + } + } +}; + +spine.SkinnedMeshAttachment = function (name) { + this.name = name; +}; +spine.SkinnedMeshAttachment.prototype = { + type: spine.AttachmentType.skinnedmesh, + bones: null, + weights: null, + uvs: null, + regionUVs: null, + triangles: null, + hullLength: 0, + r: 1, g: 1, b: 1, a: 1, + path: null, + rendererObject: null, + regionU: 0, regionV: 0, regionU2: 0, regionV2: 0, regionRotate: false, + regionOffsetX: 0, regionOffsetY: 0, + regionWidth: 0, regionHeight: 0, + regionOriginalWidth: 0, regionOriginalHeight: 0, + edges: null, + width: 0, height: 0, + updateUVs: function (u, v, u2, v2, rotate) { + var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV; + var n = this.regionUVs.length; + if (!this.uvs || this.uvs.length != n) { + this.uvs = new spine.Float32Array(n); + } + if (this.regionRotate) { + for (var i = 0; i < n; i += 2) { + this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width; + this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height; + } + } else { + for (var i = 0; i < n; i += 2) { + this.uvs[i] = this.regionU + this.regionUVs[i] * width; + this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height; + } + } + }, + computeWorldVertices: function (x, y, slot, worldVertices) { + var skeletonBones = slot.bone.skeleton.bones; + var weights = this.weights; + var bones = this.bones; + + var w = 0, v = 0, b = 0, f = 0, n = bones.length, nn; + var wx, wy, bone, vx, vy, weight; + if (!slot.attachmentVertices.length) { + for (; v < n; w += 2) { + wx = 0; + wy = 0; + nn = bones[v++] + v; + for (; v < nn; v++, b += 3) { + bone = skeletonBones[bones[v]]; + vx = weights[b]; + vy = weights[b + 1]; + weight = weights[b + 2]; + wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight; + wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight; + } + worldVertices[w] = wx + x; + worldVertices[w + 1] = wy + y; + } + } else { + var ffd = slot.attachmentVertices; + for (; v < n; w += 2) { + wx = 0; + wy = 0; + nn = bones[v++] + v; + for (; v < nn; v++, b += 3, f += 2) { + bone = skeletonBones[bones[v]]; + vx = weights[b] + ffd[f]; + vy = weights[b + 1] + ffd[f + 1]; + weight = weights[b + 2]; + wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight; + wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight; + } + worldVertices[w] = wx + x; + worldVertices[w + 1] = wy + y; + } + } + } +}; + spine.BoundingBoxAttachment = function (name) { this.name = name; this.vertices = []; @@ -1143,8 +1286,18 @@ spine.SkeletonJson = function (attachmentLoader) { }; spine.SkeletonJson.prototype = { scale: 1, - readSkeletonData: function (root) { + readSkeletonData: function (root, name) { var skeletonData = new spine.SkeletonData(); + skeletonData.name = name; + + // Skeleton. + var skeletonMap = root["skeleton"]; + if (skeletonMap) { + skeletonData.hash = skeletonMap["hash"]; + skeletonData.version = skeletonMap["spine"]; + skeletonData.width = skeletonMap["width"] || 0; + skeletonData.height = skeletonMap["height"] || 0; + } // Bones. var bones = root["bones"]; @@ -1160,13 +1313,37 @@ spine.SkeletonJson.prototype = { boneData.x = (boneMap["x"] || 0) * this.scale; boneData.y = (boneMap["y"] || 0) * this.scale; boneData.rotation = (boneMap["rotation"] || 0); - boneData.scaleX = boneMap["scaleX"] || 1; - boneData.scaleY = boneMap["scaleY"] || 1; - boneData.inheritScale = !boneMap["inheritScale"] || boneMap["inheritScale"] == "true"; - boneData.inheritRotation = !boneMap["inheritRotation"] || boneMap["inheritRotation"] == "true"; + boneData.scaleX = boneMap.hasOwnProperty("scaleX") ? boneMap["scaleX"] : 1; + boneData.scaleY = boneMap.hasOwnProperty("scaleY") ? boneMap["scaleY"] : 1; + boneData.inheritScale = boneMap.hasOwnProperty("inheritScale") ? boneMap["inheritScale"] : true; + boneData.inheritRotation = boneMap.hasOwnProperty("inheritRotation") ? boneMap["inheritRotation"] : true; skeletonData.bones.push(boneData); } + // IK constraints. + var ik = root["ik"]; + if (ik) { + for (var i = 0, n = ik.length; i < n; i++) { + var ikMap = ik[i]; + var ikConstraintData = new spine.IkConstraintData(ikMap["name"]); + + var bones = ikMap["bones"]; + for (var ii = 0, nn = bones.length; ii < nn; ii++) { + var bone = skeletonData.findBone(bones[ii]); + if (!bone) throw "IK bone not found: " + bones[ii]; + ikConstraintData.bones.push(bone); + } + + ikConstraintData.target = skeletonData.findBone(ikMap["target"]); + if (!ikConstraintData.target) throw "Target bone not found: " + ikMap["target"]; + + ikConstraintData.bendDirection = (!ikMap.hasOwnProperty("bendPositive") || ikMap["bendPositive"]) ? 1 : -1; + ikConstraintData.mix = ikMap.hasOwnProperty("mix") ? ikMap["mix"] : 1; + + skeletonData.ikConstraints.push(ikConstraintData); + } + } + // Slots. var slots = root["slots"]; for (var i = 0, n = slots.length; i < n; i++) { @@ -1177,10 +1354,10 @@ spine.SkeletonJson.prototype = { var color = slotMap["color"]; if (color) { - slotData.r = spine.SkeletonJson.toColor(color, 0); - slotData.g = spine.SkeletonJson.toColor(color, 1); - slotData.b = spine.SkeletonJson.toColor(color, 2); - slotData.a = spine.SkeletonJson.toColor(color, 3); + slotData.r = this.toColor(color, 0); + slotData.g = this.toColor(color, 1); + slotData.b = this.toColor(color, 2); + slotData.a = this.toColor(color, 3); } slotData.attachmentName = slotMap["attachment"]; @@ -1202,7 +1379,7 @@ spine.SkeletonJson.prototype = { for (var attachmentName in slotEntry) { if (!slotEntry.hasOwnProperty(attachmentName)) continue; var attachment = this.readAttachment(skin, attachmentName, slotEntry[attachmentName]); - if (attachment != null) skin.addAttachment(slotIndex, attachmentName, attachment); + if (attachment) skin.addAttachment(slotIndex, attachmentName, attachment); } } skeletonData.skins.push(skin); @@ -1234,29 +1411,150 @@ spine.SkeletonJson.prototype = { name = map["name"] || name; var type = spine.AttachmentType[map["type"] || "region"]; - var attachment = this.attachmentLoader.newAttachment(skin, type, name); - + var path = map["path"] || name; + + var scale = this.scale; if (type == spine.AttachmentType.region) { - attachment.x = (map["x"] || 0) * this.scale; - attachment.y = (map["y"] || 0) * this.scale; - attachment.scaleX = map["scaleX"] || 1; - attachment.scaleY = map["scaleY"] || 1; - attachment.rotation = map["rotation"] || 0; - attachment.width = (map["width"] || 32) * this.scale; - attachment.height = (map["height"] || 32) * this.scale; - attachment.updateOffset(); - } else if (type == spine.AttachmentType.boundingBox) { + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (!region) return null; + region.path = path; + region.x = (map["x"] || 0) * scale; + region.y = (map["y"] || 0) * scale; + region.scaleX = map.hasOwnProperty("scaleX") ? map["scaleX"] : 1; + region.scaleY = map.hasOwnProperty("scaleY") ? map["scaleY"] : 1; + region.rotation = map["rotation"] || 0; + region.width = (map["width"] || 0) * scale; + region.height = (map["height"] || 0) * scale; + + var color = map["color"]; + if (color) { + region.r = this.toColor(color, 0); + region.g = this.toColor(color, 1); + region.b = this.toColor(color, 2); + region.a = this.toColor(color, 3); + } + + region.updateOffset(); + return region; + } else if (type == spine.AttachmentType.mesh) { + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (!mesh) return null; + mesh.path = path; + mesh.vertices = this.getFloatArray(map, "vertices", scale); + mesh.triangles = this.getIntArray(map, "triangles"); + mesh.regionUVs = this.getFloatArray(map, "uvs", 1); + mesh.updateUVs(); + + color = map["color"]; + if (color) { + mesh.r = this.toColor(color, 0); + mesh.g = this.toColor(color, 1); + mesh.b = this.toColor(color, 2); + mesh.a = this.toColor(color, 3); + } + + mesh.hullLength = (map["hull"] || 0) * 2; + if (map["edges"]) mesh.edges = this.getIntArray(map, "edges"); + mesh.width = (map["width"] || 0) * scale; + mesh.height = (map["height"] || 0) * scale; + return mesh; + } else if (type == spine.AttachmentType.skinnedmesh) { + var mesh = this.attachmentLoader.newSkinnedMeshAttachment(skin, name, path); + if (!mesh) return null; + mesh.path = path; + + var uvs = this.getFloatArray(map, "uvs", 1); + var vertices = this.getFloatArray(map, "vertices", 1); + var weights = []; + var bones = []; + for (var i = 0, n = vertices.length; i < n; ) { + var boneCount = vertices[i++] | 0; + bones[bones.length] = boneCount; + for (var nn = i + boneCount * 4; i < nn; ) { + bones[bones.length] = vertices[i]; + weights[weights.length] = vertices[i + 1] * scale; + weights[weights.length] = vertices[i + 2] * scale; + weights[weights.length] = vertices[i + 3]; + i += 4; + } + } + mesh.bones = bones; + mesh.weights = weights; + mesh.triangles = this.getIntArray(map, "triangles"); + mesh.regionUVs = uvs; + mesh.updateUVs(); + + color = map["color"]; + if (color) { + mesh.r = this.toColor(color, 0); + mesh.g = this.toColor(color, 1); + mesh.b = this.toColor(color, 2); + mesh.a = this.toColor(color, 3); + } + + mesh.hullLength = (map["hull"] || 0) * 2; + if (map["edges"]) mesh.edges = this.getIntArray(map, "edges"); + mesh.width = (map["width"] || 0) * scale; + mesh.height = (map["height"] || 0) * scale; + return mesh; + } else if (type == spine.AttachmentType.boundingbox) { + var attachment = this.attachmentLoader.newBoundingBoxAttachment(skin, name); var vertices = map["vertices"]; for (var i = 0, n = vertices.length; i < n; i++) - attachment.vertices.push(vertices[i] * this.scale); + attachment.vertices.push(vertices[i] * scale); + return attachment; } - - return attachment; + throw "Unknown attachment type: " + type; }, readAnimation: function (name, map, skeletonData) { var timelines = []; var duration = 0; + var slots = map["slots"]; + for (var slotName in slots) { + if (!slots.hasOwnProperty(slotName)) continue; + var slotMap = slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + + for (var timelineName in slotMap) { + if (!slotMap.hasOwnProperty(timelineName)) continue; + var values = slotMap[timelineName]; + if (timelineName == "color") { + var timeline = new spine.ColorTimeline(values.length); + timeline.slotIndex = slotIndex; + + var frameIndex = 0; + for (var i = 0, n = values.length; i < n; i++) { + var valueMap = values[i]; + var color = valueMap["color"]; + var r = this.toColor(color, 0); + var g = this.toColor(color, 1); + var b = this.toColor(color, 2); + var a = this.toColor(color, 3); + timeline.setFrame(frameIndex, valueMap["time"], r, g, b, a); + this.readCurve(timeline, frameIndex, valueMap); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 5 - 5]); + + } else if (timelineName == "attachment") { + var timeline = new spine.AttachmentTimeline(values.length); + timeline.slotIndex = slotIndex; + + var frameIndex = 0; + for (var i = 0, n = values.length; i < n; i++) { + var valueMap = values[i]; + timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + + } else + throw "Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"; + } + } + var bones = map["bones"]; for (var boneName in bones) { if (!bones.hasOwnProperty(boneName)) continue; @@ -1275,7 +1573,7 @@ spine.SkeletonJson.prototype = { for (var i = 0, n = values.length; i < n; i++) { var valueMap = values[i]; timeline.setFrame(frameIndex, valueMap["time"], valueMap["angle"]); - spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); + this.readCurve(timeline, frameIndex, valueMap); frameIndex++; } timelines.push(timeline); @@ -1298,81 +1596,116 @@ spine.SkeletonJson.prototype = { var x = (valueMap["x"] || 0) * timelineScale; var y = (valueMap["y"] || 0) * timelineScale; timeline.setFrame(frameIndex, valueMap["time"], x, y); - spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); + this.readCurve(timeline, frameIndex, valueMap); frameIndex++; } timelines.push(timeline); duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 3 - 3]); - } else - throw "Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"; - } - } - - var slots = map["slots"]; - for (var slotName in slots) { - if (!slots.hasOwnProperty(slotName)) continue; - var slotMap = slots[slotName]; - var slotIndex = skeletonData.findSlotIndex(slotName); - - for (var timelineName in slotMap) { - if (!slotMap.hasOwnProperty(timelineName)) continue; - var values = slotMap[timelineName]; - if (timelineName == "color") { - var timeline = new spine.ColorTimeline(values.length); - timeline.slotIndex = slotIndex; + } else if (timelineName == "flipX" || timelineName == "flipY") { + var x = timelineName == "flipX"; + var timeline = x ? new spine.FlipXTimeline(values.length) : new spine.FlipYTimeline(values.length); + timeline.boneIndex = boneIndex; + var field = x ? "x" : "y"; var frameIndex = 0; for (var i = 0, n = values.length; i < n; i++) { var valueMap = values[i]; - var color = valueMap["color"]; - var r = spine.SkeletonJson.toColor(color, 0); - var g = spine.SkeletonJson.toColor(color, 1); - var b = spine.SkeletonJson.toColor(color, 2); - var a = spine.SkeletonJson.toColor(color, 3); - timeline.setFrame(frameIndex, valueMap["time"], r, g, b, a); - spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap); + timeline.setFrame(frameIndex, valueMap["time"], valueMap[field] || false); frameIndex++; } timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 5 - 5]); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 2 - 2]); + } else + throw "Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"; + } + } - } else if (timelineName == "attachment") { - var timeline = new spine.AttachmentTimeline(values.length); + var ikMap = map["ik"]; + for (var ikConstraintName in ikMap) { + if (!ikMap.hasOwnProperty(ikConstraintName)) continue; + var ikConstraint = skeletonData.findIkConstraint(ikConstraintName); + var values = ikMap[ikConstraintName]; + var timeline = new spine.IkConstraintTimeline(values.length); + timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(ikConstraint); + var frameIndex = 0; + for (var i = 0, n = values.length; i < n; i++) { + var valueMap = values[i]; + var mix = valueMap.hasOwnProperty("mix") ? valueMap["mix"] : 1; + var bendDirection = (!valueMap.hasOwnProperty("bendPositive") || valueMap["bendPositive"]) ? 1 : -1; + timeline.setFrame(frameIndex, valueMap["time"], mix, bendDirection); + this.readCurve(timeline, frameIndex, valueMap); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.frameCount * 3 - 3]); + } + + var ffd = map["ffd"]; + for (var skinName in ffd) { + var skin = skeletonData.findSkin(skinName); + var slotMap = ffd[skinName]; + for (slotName in slotMap) { + var slotIndex = skeletonData.findSlotIndex(slotName); + var meshMap = slotMap[slotName]; + for (var meshName in meshMap) { + var values = meshMap[meshName]; + var timeline = new spine.FfdTimeline(values.length); + var attachment = skin.getAttachment(slotIndex, meshName); + if (!attachment) throw "FFD attachment not found: " + meshName; timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + + var isMesh = attachment.type == spine.AttachmentType.mesh; + var vertexCount; + if (isMesh) + vertexCount = attachment.vertices.length; + else + vertexCount = attachment.weights.length / 3 * 2; var frameIndex = 0; for (var i = 0, n = values.length; i < n; i++) { var valueMap = values[i]; - timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]); + var vertices; + if (!valueMap["vertices"]) { + if (isMesh) + vertices = attachment.vertices; + else { + vertices = []; + vertices.length = vertexCount; + } + } else { + var verticesValue = valueMap["vertices"]; + var vertices = []; + vertices.length = vertexCount; + var start = valueMap["offset"] || 0; + var nn = verticesValue.length; + if (this.scale == 1) { + for (var ii = 0; ii < nn; ii++) + vertices[ii + start] = verticesValue[ii]; + } else { + for (var ii = 0; ii < nn; ii++) + vertices[ii + start] = verticesValue[ii] * this.scale; + } + if (isMesh) { + var meshVertices = attachment.vertices; + for (var ii = 0, nn = vertices.length; ii < nn; ii++) + vertices[ii] += meshVertices[ii]; + } + } + + timeline.setFrame(frameIndex, valueMap["time"], vertices); + this.readCurve(timeline, frameIndex, valueMap); + frameIndex++; } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); - - } else - throw "Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"; - } - } - - var events = map["events"]; - if (events) { - var timeline = new spine.EventTimeline(events.length); - var frameIndex = 0; - for (var i = 0, n = events.length; i < n; i++) { - var eventMap = events[i]; - var eventData = skeletonData.findEvent(eventMap["name"]); - if (!eventData) throw "Event not found: " + eventMap["name"]; - var event = new spine.Event(eventData); - event.intValue = eventMap.hasOwnProperty("int") ? eventMap["int"] : eventData.intValue; - event.floatValue = eventMap.hasOwnProperty("float") ? eventMap["float"] : eventData.floatValue; - event.stringValue = eventMap.hasOwnProperty("string") ? eventMap["string"] : eventData.stringValue; - timeline.setFrame(frameIndex++, eventMap["time"], event); + timelines[timelines.length] = timeline; + duration = Math.max(duration, timeline.frames[timeline.frameCount - 1]); + } } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); } - var drawOrderValues = map["draworder"]; + var drawOrderValues = map["drawOrder"]; + if (!drawOrderValues) drawOrderValues = map["draworder"]; if (drawOrderValues) { var timeline = new spine.DrawOrderTimeline(drawOrderValues.length); var slotCount = skeletonData.slots.length; @@ -1412,7 +1745,58 @@ spine.SkeletonJson.prototype = { duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); } + var events = map["events"]; + if (events) { + var timeline = new spine.EventTimeline(events.length); + var frameIndex = 0; + for (var i = 0, n = events.length; i < n; i++) { + var eventMap = events[i]; + var eventData = skeletonData.findEvent(eventMap["name"]); + if (!eventData) throw "Event not found: " + eventMap["name"]; + var event = new spine.Event(eventData); + event.intValue = eventMap.hasOwnProperty("int") ? eventMap["int"] : eventData.intValue; + event.floatValue = eventMap.hasOwnProperty("float") ? eventMap["float"] : eventData.floatValue; + event.stringValue = eventMap.hasOwnProperty("string") ? eventMap["string"] : eventData.stringValue; + timeline.setFrame(frameIndex++, eventMap["time"], event); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + skeletonData.animations.push(new spine.Animation(name, timelines, duration)); + }, + readCurve: function (timeline, frameIndex, valueMap) { + var curve = valueMap["curve"]; + if (!curve) + timeline.curves.setLinear(frameIndex); + else if (curve == "stepped") + timeline.curves.setStepped(frameIndex); + else if (curve instanceof Array) + timeline.curves.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); + }, + toColor: function (hexString, colorIndex) { + if (hexString.length != 8) throw "Color hexidecimal length must be 8, recieved: " + hexString; + return parseInt(hexString.substring(colorIndex * 2, (colorIndex * 2) + 2), 16) / 255; + }, + getFloatArray: function (map, name, scale) { + var list = map[name]; + var values = new spine.Float32Array(list.length); + var i = 0, n = list.length; + if (scale == 1) { + for (; i < n; i++) + values[i] = list[i]; + } else { + for (; i < n; i++) + values[i] = list[i] * scale; + } + return values; + }, + getIntArray: function (map, name) { + var list = map[name]; + var values = new spine.Uint16Array(list.length); + for (var i = 0, n = list.length; i < n; i++) + values[i] = list[i] | 0; + return values; } }; @@ -1441,15 +1825,20 @@ spine.Atlas = function (atlasText, textureLoader) { var page = null; while (true) { var line = reader.readLine(); - if (line == null) break; + if (line === null) break; line = reader.trim(line); - if (line.length == 0) + if (!line.length) page = null; else if (!page) { page = new spine.AtlasPage(); page.name = line; - page.format = spine.Atlas.Format[reader.readValue()]; + if (reader.readTuple(tuple) == 2) { // size is only optional for an atlas packed with an old TexturePacker. + page.width = parseInt(tuple[0]); + page.height = parseInt(tuple[1]); + reader.readTuple(tuple); + } + page.format = spine.Atlas.Format[tuple[0]]; reader.readTuple(tuple); page.minFilter = spine.Atlas.TextureFilter[tuple[0]]; @@ -1468,6 +1857,7 @@ spine.Atlas = function (atlasText, textureLoader) { textureLoader.load(page, line, this); this.pages.push(page); + } else { var region = new spine.AtlasRegion(); region.name = line; @@ -1624,7 +2014,7 @@ spine.AtlasReader.prototype = { if (colon == -1) throw "Invalid line: " + line; return this.trim(line.substring(colon + 1)); }, - /** Returns the number of tuple values read (2 or 4). */ + /** Returns the number of tuple values read (1, 2 or 4). */ readTuple: function (tuple) { var line = this.readLine(); var colon = line.indexOf(":"); @@ -1632,10 +2022,7 @@ spine.AtlasReader.prototype = { var i = 0, lastMatch = colon + 1; for (; i < 3; i++) { var comma = line.indexOf(",", lastMatch); - if (comma == -1) { - if (i == 0) throw "Invalid line: " + line; - break; - } + if (comma == -1) break; tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch)); lastMatch = comma + 1; } @@ -1648,25 +2035,58 @@ spine.AtlasAttachmentLoader = function (atlas) { this.atlas = atlas; }; spine.AtlasAttachmentLoader.prototype = { - newAttachment: function (skin, type, name) { - switch (type) { - case spine.AttachmentType.boundingbox: - return new spine.BoundingBoxAttachment(name); - case spine.AttachmentType.region: - var region = this.atlas.findRegion(name); - if (!region) throw "Region not found in atlas: " + name + " (" + type + ")"; - var attachment = new spine.RegionAttachment(name); - attachment.rendererObject = region; - attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate); - attachment.regionOffsetX = region.offsetX; - attachment.regionOffsetY = region.offsetY; - attachment.regionWidth = region.width; - attachment.regionHeight = region.height; - attachment.regionOriginalWidth = region.originalWidth; - attachment.regionOriginalHeight = region.originalHeight; - return attachment; - } - throw "Unknown attachment type: " + type; + newRegionAttachment: function (skin, name, path) { + var region = this.atlas.findRegion(name); + if (!region) throw "Region not found in atlas: " + path + " (region attachment: " + name + ")"; + var attachment = new spine.RegionAttachment(name); + attachment.rendererObject = region; + attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate); + attachment.regionOffsetX = region.offsetX; + attachment.regionOffsetY = region.offsetY; + attachment.regionWidth = region.width; + attachment.regionHeight = region.height; + attachment.regionOriginalWidth = region.originalWidth; + attachment.regionOriginalHeight = region.originalHeight; + return attachment; + }, + newMeshAttachment: function (skin, name, path) { + var region = this.atlas.findRegion(name); + if (!region) throw "Region not found in atlas: " + path + " (mesh attachment: " + name + ")"; + var attachment = new spine.MeshAttachment(name); + attachment.rendererObject = region; + attachment.regionU = region.u; + attachment.regionV = region.v; + attachment.regionU2 = region.u2; + attachment.regionV2 = region.v2; + attachment.regionRotate = region.rotate; + attachment.regionOffsetX = region.offsetX; + attachment.regionOffsetY = region.offsetY; + attachment.regionWidth = region.width; + attachment.regionHeight = region.height; + attachment.regionOriginalWidth = region.originalWidth; + attachment.regionOriginalHeight = region.originalHeight; + return attachment; + }, + newSkinnedMeshAttachment: function (skin, name, path) { + var region = this.atlas.findRegion(name); + if (!region) throw "Region not found in atlas: " + path + " (skinned mesh attachment: " + name + ")"; + var attachment = new spine.SkinnedMeshAttachment(name); + attachment.rendererObject = region; + attachment.regionU = region.u; + attachment.regionV = region.v; + attachment.regionU2 = region.u2; + attachment.regionV2 = region.v2; + attachment.regionRotate = region.rotate; + attachment.regionOffsetX = region.offsetX; + attachment.regionOffsetY = region.offsetY; + attachment.regionWidth = region.width; + attachment.regionHeight = region.height; + attachment.regionOriginalWidth = region.originalWidth; + attachment.regionOriginalHeight = region.originalHeight; + return attachment; + }, + newBoundingBoxAttachment: function (skin, name) { + return new spine.BoundingBoxAttachment(name); } }; From b36b7d6f94fe1d54178e2251cb786cba49e27716 Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Sat, 31 Jan 2015 12:10:09 +0200 Subject: [PATCH 1315/1564] Fix issue with spine content size. --- extensions/spine/CCSkeleton.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 0e4aadd472..cf64429e28 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -291,6 +291,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ * @param {spine.SkeletonData} ownsSkeletonData */ setSkeletonData: function (skeletonData, ownsSkeletonData) { + this.setContentSize(skeletonData.width / cc.director.getContentScaleFactor(), skeletonData.height / cc.director.getContentScaleFactor()); + this._skeleton = new spine.Skeleton(skeletonData); this._rootBone = this._skeleton.getRootBone(); this._ownsSkeletonData = ownsSkeletonData; From f53e471e9befdd6d22908245c8e9dbd79810d62d Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 1 Feb 2015 17:24:41 +0800 Subject: [PATCH 1316/1564] Upgrade docs for v3.3 RC0 release --- AUTHORS.txt | 1 + CHANGELOG.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 5777d39dcd..f38d11180d 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -187,6 +187,7 @@ Xiaodong Liu @tianxing113 cc.Spawn.create bug fix Park Hyun Chen @sincntx Touch anywhere of screen to finish input when using cc.EditBox ccui.TextBMFont bug fix cc.game bug fix + Fixed an issue of cc.ArmatureAnimation's setMovementEventCallFunc Ninja Lau @mutoo A typo bug in UILayout fix One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c61ba3f643..e72346566d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,33 @@ ChangeLog: +Cocos2d-JS v3.3 RC0 @ Reb.1, 2015 + +* Added web exclusive functions: `_getFontStyle`, `_setFontStyle`, `_getFontWeight` and `_setFontWeight` APIs to `cc.LabelTTF`. +* Observed orientation change event on mobile for resolution policy adaptation. + +* Bug fixes: + 1. Fixed Cocos Studio JSON parser's issues for parsing nested animation. + 2. Fixed Cocos Studio JSON parser's parameters parsing issues. + 3. Fixed Cocos Studio JSON parser's issue for parsing layer. + 4. Fixed Cocos Studio JSON action parser's issues. + 5. Fixed Cocos Studio JSON parser's issue for parsing Scale9Sprite. + 6. Fixed Cocos Studio JSON parser's issues caused by parsing process order. + 7. Fixed Cocos Studio JSON parser's issue for parsing loading bar's direction. + 8. Fixed UI layout system issues. + 9. Fixed `cc.EditBox`'s position issue under certain resolution policies. + 10. Fixed `ccui.ListView`'s issue for setting direction. + 11. Fixed an issue of `cc.Tween` that its `_currentPercent` is incorrect in `updateHandler` function. + 12. Fixed an issue of `ccui.Button` that its state is incorrect in `_onPressStateChangedToNormal`. + 13. Fixed an issue of `cc.ArmatureAnimation`'s `setMovementEventCallFunc`. + 14. Fixed an issue of `cc.Sequence` action when it's repeated. + 15. Fixed `_anchorPointInPoints` usage issue. + 16. Fixed an issue of `cc.GLProgram` that it doesn't work on some devices which didn't support highp float precision. + 17. Fixed an issue of fade actions that they don't work when duration is 0. + 18. Fixed `onended` callback issue of audio engine on iOS. + 19. Fixed Cocos Builder's parser issue for auto playing animations. + 20. Added a message to `ccs.Armature` that it doesn't support adding widget as its child. + 21. Improved test cases for stability. + Cocos2d-JS v3.3 Beta @ Jan.24, 2015 * Added Cocos Studio v2.x parser and refactored 1.x parser. From c95fa77176624904d3546ec1cd3aa6cd608c3766 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 2 Feb 2015 11:45:16 +0800 Subject: [PATCH 1317/1564] ccs.load add info for armature file --- extensions/cocostudio/loader/load.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index ec49ad7e9a..ee106266c7 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -59,6 +59,12 @@ ccs._load = (function(){ return new cc.Node(); } var version = json["version"] || json["Version"]; + if(!version && json["armature_data"]){ + cc.warn("%s is armature. please use:", file); + cc.warn(" ccs.armatureDataManager.addArmatureFileInfoAsync(%s);", file); + cc.warn(" var armature = new new ccs.Armature('name');"); + return new cc.Node(); + } var currentParser = getParser(parse, version); if(!currentParser){ cc.log("Can't find the parser : %s", file); From b139f9e94c3417387156d00a61c3776dba900240 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 3 Feb 2015 09:46:58 +0800 Subject: [PATCH 1318/1564] Fixed ccs.load warn info --- extensions/cocostudio/loader/load.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index ee106266c7..4a46b956b7 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -62,7 +62,7 @@ ccs._load = (function(){ if(!version && json["armature_data"]){ cc.warn("%s is armature. please use:", file); cc.warn(" ccs.armatureDataManager.addArmatureFileInfoAsync(%s);", file); - cc.warn(" var armature = new new ccs.Armature('name');"); + cc.warn(" var armature = new ccs.Armature('name');"); return new cc.Node(); } var currentParser = getParser(parse, version); From 537d9af305cbea468ea812d4a033823e4a13a3c9 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 3 Feb 2015 11:53:44 +0800 Subject: [PATCH 1319/1564] Fixed some issues for the latest spine runtime. --- cocos2d/core/sprites/CCSprite.js | 5 ++-- .../core/sprites/CCSpriteCanvasRenderCmd.js | 16 +++++++++---- extensions/spine/CCSkeleton.js | 3 ++- extensions/spine/CCSkeletonAnimation.js | 4 ++-- extensions/spine/CCSkeletonCanvasRenderCmd.js | 24 +++++++++++++++---- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index c6d5d7a984..e47ecb4f52 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -679,14 +679,15 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture A pointer to an existing CCTexture2D object. You can use a CCTexture2D object for many sprites. * @param {cc.Rect} [rect] Only the contents inside rect of this texture will be applied for this sprite. * @param {Boolean} [rotated] Whether or not the texture rectangle is rotated. + * @param {Boolean} [counterclockwise=true] Whether or not the texture rectangle rotation is counterclockwise (texture package is counterclockwise, spine is clockwise). * @return {Boolean} true if the sprite is initialized properly, false otherwise. */ - initWithTexture: function (texture, rect, rotated) { + initWithTexture: function (texture, rect, rotated, counterclockwise) { var _t = this; cc.assert(arguments.length != 0, cc._LogInfos.CCSpriteBatchNode_initWithTexture); rotated = rotated || false; - texture = this._renderCmd._handleTextureForRotatedTexture(texture, rect, rotated); + texture = this._renderCmd._handleTextureForRotatedTexture(texture, rect, rotated, counterclockwise); if (!cc.Node.prototype.init.call(_t)) return false; diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 05984018fd..51ae6f1524 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -88,14 +88,15 @@ return true; }; - proto._handleTextureForRotatedTexture = function (texture, rect, rotated) { + proto._handleTextureForRotatedTexture = function (texture, rect, rotated, counterclockwise) { if (rotated && texture.isLoaded()) { var tempElement = texture.getHtmlElementObj(); - tempElement = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, rect); + tempElement = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, rect, counterclockwise); var tempTexture = new cc.Texture2D(); tempTexture.initWithElement(tempElement); tempTexture.handleLoadedTexture(); texture = tempTexture; + rect.x = rect.y = 0; this._node._rect = cc.rect(0, 0, rect.width, rect.height); } return texture; @@ -123,9 +124,9 @@ var locX = node._offsetPosition.x, locHeight = node._rect.height, locWidth = node._rect.width, locY = -node._offsetPosition.y - locHeight, image; + wrapper.setTransform(this._worldTransform, scaleX, scaleY); wrapper.setCompositeOperation(this._blendFuncStr); wrapper.setGlobalAlpha(alpha); - wrapper.setTransform(this._worldTransform, scaleX, scaleY); if(node._flippedX || node._flippedY) wrapper.save(); @@ -493,19 +494,24 @@ cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas = cc.newElement('canvas'); cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCtx = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas.getContext('2d'); - cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas = function (texture, rect) { + cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas = function (texture, rect, counterclockwise) { if (!texture) return null; if (!rect) return texture; + counterclockwise = counterclockwise == null? true: counterclockwise; // texture package is counterclockwise, spine is clockwise + var nCanvas = cc.newElement("canvas"); nCanvas.width = rect.width; nCanvas.height = rect.height; var ctx = nCanvas.getContext("2d"); ctx.translate(nCanvas.width / 2, nCanvas.height / 2); - ctx.rotate(-1.5707963267948966); + if(counterclockwise) + ctx.rotate(-1.5707963267948966); + else + ctx.rotate(1.5707963267948966); ctx.drawImage(texture, rect.x, rect.y, rect.height, rect.width, -rect.height / 2, -rect.width / 2, rect.height, rect.width); return nCanvas; }; diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index cf64429e28..28b49bebd1 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -291,7 +291,8 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ * @param {spine.SkeletonData} ownsSkeletonData */ setSkeletonData: function (skeletonData, ownsSkeletonData) { - this.setContentSize(skeletonData.width / cc.director.getContentScaleFactor(), skeletonData.height / cc.director.getContentScaleFactor()); + if(skeletonData.width != null && skeletonData.height != null) + this.setContentSize(skeletonData.width / cc.director.getContentScaleFactor(), skeletonData.height / cc.director.getContentScaleFactor()); this._skeleton = new spine.Skeleton(skeletonData); this._rootBone = this._skeleton.getRootBone(); diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index 19a2884e9b..58ecb7351a 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -79,7 +79,7 @@ sp._regionAttachment_computeWorldVertices = function(self, x, y, bone, vertices) sp._regionAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { var vertices = {}; - self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); + self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot, vertices); var r = slot.skeleton.r * slot.r * 255; var g = slot.skeleton.g * slot.g * 255; var b = slot.skeleton.b * slot.b * 255; @@ -160,7 +160,7 @@ sp._regionAttachment_updateSlotForCanvas = function(self, slot, points) { return; var vertices = {}; - self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); + self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot, vertices); var VERTEX = sp.VERTEX_INDEX; points.length = 0; points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1])); diff --git a/extensions/spine/CCSkeletonCanvasRenderCmd.js b/extensions/spine/CCSkeletonCanvasRenderCmd.js index 5bad93ef87..d887f6d791 100644 --- a/extensions/spine/CCSkeletonCanvasRenderCmd.js +++ b/extensions/spine/CCSkeletonCanvasRenderCmd.js @@ -43,7 +43,7 @@ wrapper._switchToArmatureMode(true, this._worldTransform, scaleX, scaleY); for(i = 0, n = sprites.length; i < n; i++){ selSpriteCmd = sprites[i]._renderCmd; - if(selSpriteCmd && selSpriteCmd.rendering){ + if(sprites[i]._visible && selSpriteCmd && selSpriteCmd.rendering){ selSpriteCmd.rendering(wrapper, scaleX, scaleY); selSpriteCmd._dirtyFlag = 0; } @@ -111,7 +111,12 @@ continue; rendererObject = attachment.rendererObject; rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); - var sprite = new cc.Sprite(rendererObject.page._texture, rect, rendererObject.rotate); + var sprite = new cc.Sprite(); + sprite.initWithTexture(rendererObject.page._texture, rect, rendererObject.rotate, false); + sprite._rect.width = attachment.width; + sprite._rect.height = attachment.height; + sprite.setContentSize(attachment.width, attachment.height); + sprite.setRotation(-(slot.bone.worldRotation + attachment.rotation)); this._skeletonSprites.push(sprite); slot.currentSprite = sprite; } @@ -133,9 +138,13 @@ if(!selSprite){ var rendererObject = attachment.rendererObject; var rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); - var sprite = new cc.Sprite(rendererObject.page._texture, rect, rendererObject.rotate); + var sprite = new cc.Sprite(); + sprite.initWithTexture(rendererObject.page._texture, rect, rendererObject.rotate, false); + sprite._rect.width = attachment.width; + sprite._rect.height = attachment.height; + sprite.setContentSize(attachment.width, attachment.height); this._skeletonSprites.push(sprite); - slot.currentSprite = sprite; + selSprite = slot.currentSprite = sprite; } selSprite.setVisible(true); //update color and blendFunc @@ -145,7 +154,12 @@ selSprite.setPosition(bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01, bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); selSprite.setScale(bone.worldScaleX, bone.worldScaleY); - selSprite.setRotation(- (slot.bone.worldRotation + attachment.rotation)); + selSprite.setRotation(-(slot.bone.worldRotation + attachment.rotation)); + selSprite.setOpacity(0 | (slot.skeleton.a * slot.a * 255)); + var r = 0 | (slot.skeleton.r * slot.r * 255); + var g = 0 | (slot.skeleton.g * slot.g * 255); + var b = 0 | (slot.skeleton.b * slot.b * 255); + selSprite.setColor(cc.color(r,g,b)); } }; })(); \ No newline at end of file From 28c9dc0038654f2447cbc78b65fb030c8d5a9a33 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 3 Feb 2015 14:36:04 +0800 Subject: [PATCH 1320/1564] Fixed a bug of cc.Sprite that its setSpriteFrame doesn't work when SpriteFrame's rotated is true. --- cocos2d/core/sprites/CCSprite.js | 6 +----- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index e47ecb4f52..876b5def45 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -831,8 +831,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _t._unflippedOffsetPositionFromCenter.y = frameOffset.y; // update rect - _t._rectRotated = newFrame.isRotated(); - var pNewTexture = newFrame.getTexture(); var locTextureLoaded = newFrame.textureLoaded(); if (!locTextureLoaded) { @@ -850,10 +848,8 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // update texture before updating texture rect if (pNewTexture != _t._texture) _t.texture = pNewTexture; - - _t.setTextureRect(newFrame.getRect(), _t._rectRotated, newFrame.getOriginalSize()); + _t.setTextureRect(newFrame.getRect(), newFrame.isRotated(), newFrame.getOriginalSize()); } - this._renderCmd._updateForSetSpriteFrame(pNewTexture); }, diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 6c1cfbb85c..5ecff16100 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -171,7 +171,6 @@ var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); node.setSpriteFrame(spriteFrame); } - }); if(json["FlipX"]) From 101138176baadfec0a0891cc3ac6656ab69ceb4b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 3 Feb 2015 15:36:50 +0800 Subject: [PATCH 1321/1564] Project.json add noCache options --- CCBoot.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index c0b3919823..ca81412fce 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -604,8 +604,15 @@ cc.loader = /** @lends cc.loader# */{ _createScript: function (jsPath, isAsync, cb) { var d = document, self = this, s = cc.newElement('script'); s.async = isAsync; - s.src = jsPath; self._jsCache[jsPath] = true; + if(cc.game.config["noCache"] && typeof jsPath === "string"){ + if(self._noCacheRex.test(jsPath)) + s.src = jsPath + "&_t=" + (new Date() - 0); + else + s.src = jsPath + "?_t=" + (new Date() - 0); + }else{ + s.src = jsPath; + } cc._addEventListener(s, 'load', function () { s.parentNode.removeChild(s); this.removeEventListener('load', arguments.callee, false); @@ -834,6 +841,12 @@ cc.loader = /** @lends cc.loader# */{ } var basePath = loader.getBasePath ? loader.getBasePath() : self.resPath; var realUrl = self.getUrl(basePath, url); + if(cc.game.config["noCache"] && typeof realUrl === "string"){ + if(self._noCacheRex.test(realUrl)) + realUrl += "&_t=" + (new Date() - 0); + else + realUrl += "?_t=" + (new Date() - 0); + } loader.load(realUrl, url, item, function (err, data) { if (err) { cc.log(err); @@ -846,6 +859,7 @@ cc.loader = /** @lends cc.loader# */{ } }); }, + _noCacheRex: /\?/, /** * Get url with basePath. From ca035cc34e6bbf9861f28a3c08041578b510402c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 3 Feb 2015 15:36:50 +0800 Subject: [PATCH 1322/1564] Project.json add noCache options --- CCBoot.js | 16 +++++++++++++++- template/project.json | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index c0b3919823..ca81412fce 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -604,8 +604,15 @@ cc.loader = /** @lends cc.loader# */{ _createScript: function (jsPath, isAsync, cb) { var d = document, self = this, s = cc.newElement('script'); s.async = isAsync; - s.src = jsPath; self._jsCache[jsPath] = true; + if(cc.game.config["noCache"] && typeof jsPath === "string"){ + if(self._noCacheRex.test(jsPath)) + s.src = jsPath + "&_t=" + (new Date() - 0); + else + s.src = jsPath + "?_t=" + (new Date() - 0); + }else{ + s.src = jsPath; + } cc._addEventListener(s, 'load', function () { s.parentNode.removeChild(s); this.removeEventListener('load', arguments.callee, false); @@ -834,6 +841,12 @@ cc.loader = /** @lends cc.loader# */{ } var basePath = loader.getBasePath ? loader.getBasePath() : self.resPath; var realUrl = self.getUrl(basePath, url); + if(cc.game.config["noCache"] && typeof realUrl === "string"){ + if(self._noCacheRex.test(realUrl)) + realUrl += "&_t=" + (new Date() - 0); + else + realUrl += "?_t=" + (new Date() - 0); + } loader.load(realUrl, url, item, function (err, data) { if (err) { cc.log(err); @@ -846,6 +859,7 @@ cc.loader = /** @lends cc.loader# */{ } }); }, + _noCacheRex: /\?/, /** * Get url with basePath. diff --git a/template/project.json b/template/project.json index 0c277b291a..6c2c93bd3d 100644 --- a/template/project.json +++ b/template/project.json @@ -1,5 +1,6 @@ { "debugMode" : 1, + "noCache": true, "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", From fb620c870bfe9d67cadf33ab6b555803e60e121a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 3 Feb 2015 16:08:21 +0800 Subject: [PATCH 1323/1564] Project.json add noCache options --- cocos2d/audio/CCAudio.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index ab5dc5478a..4c4b565d32 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -504,8 +504,8 @@ cc.Audio = cc.Class.extend({ var audio; - if(loader.cache[realUrl]) - return cb(null, loader.cache[realUrl]); + if(loader.cache[url]) + return cb(null, loader.cache[url]); if(SWA){ var volume = context["createGain"](); @@ -518,7 +518,7 @@ cc.Audio = cc.Class.extend({ this.loadAudioFromExtList(realUrl, typeList, audio, cb); - loader.cache[realUrl] = audio; + loader.cache[url] = audio; }, From ea88b6e4c213d778f2cd539d0de16f67c39ff46a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 4 Feb 2015 11:12:50 +0800 Subject: [PATCH 1324/1564] Fixed #2556: set the default value of ParticleSystem's draw mode to texture mode --- cocos2d/particle/CCParticleSystemCanvasRenderCmd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js index 7b316d3ed3..8420e8e1e2 100644 --- a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js @@ -30,7 +30,7 @@ cc.Node.CanvasRenderCmd.call(this, renderable); this._needDraw = true; - this._drawMode = cc.ParticleSystem.SHAPE_MODE; + this._drawMode = cc.ParticleSystem.TEXTURE_MODE; this._shapeType = cc.ParticleSystem.BALL_SHAPE; this._pointRect = cc.rect(0, 0, 0, 0); @@ -82,9 +82,9 @@ var i, particle, lpx, alpha; var particleCount = this._node.particleCount, particles = this._node._particles; - if (node.drawMode == cc.ParticleSystem.TEXTURE_MODE) { + if (node.drawMode !== cc.ParticleSystem.SHAPE_MODE && node._texture) { // Delay drawing until the texture is fully loaded by the browser - if (!node._texture || !node._texture._textureLoaded) { + if (!node._texture._textureLoaded) { wrapper.restore(); return; } From ceee24c74f0d769dc835fa7d6c98e623c08b1183 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 4 Feb 2015 14:20:47 +0800 Subject: [PATCH 1325/1564] =?UTF-8?q?Issue=20#2670:=20We=20should=20judge?= =?UTF-8?q?=20whether=20the=20stencil=20is=20drawNode,=20don=E2=80=98t=20j?= =?UTF-8?q?udge=20is=20Sprite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js index 4f2b5ece54..5e237d7c48 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -180,10 +180,10 @@ parentCmd = parentCmd || this.getParentRenderCmd(); if( parentCmd) this._curLevel = parentCmd._curLevel + 1; - var transformRenderCmd = (node._stencil instanceof cc.Sprite) ? this : null; + var transformRenderCmd = this; // Composition mode, costy but support texture stencil - this._clipElemType = (this._cangodhelpme() || node._stencil instanceof cc.Sprite); + this._clipElemType = !(!this._cangodhelpme() && node._stencil instanceof cc.DrawNode); if (!node._stencil || !node._stencil.visible) { if (this.inverted) cc.Node.CanvasRenderCmd.prototype.visit.call(this, parentCmd); // draw everything From d97d9a521b936cec2261afe7fd756a653426c764 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 4 Feb 2015 14:50:43 +0800 Subject: [PATCH 1326/1564] Fixed ccui position error --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 5ecff16100..7b719077a0 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -132,8 +132,6 @@ var anchor = node.getAnchorPoint(); child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); } - var AnchorPointIn = node.getAnchorPointInPoints(); - child.setPosition(cc.p(child.getPositionX() + AnchorPointIn.x, child.getPositionY() + AnchorPointIn.y)); } node.addChild(child); } From 048f51398bc3552d41ce22536691acc58543f1b7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 4 Feb 2015 14:55:45 +0800 Subject: [PATCH 1327/1564] Fixed ccui position error --- extensions/cocostudio/loader/parsers/timelineParser-1.x.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js index e5f6b8ef8e..5b0c849df9 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -147,6 +147,7 @@ var anchor = widget.getAnchorPoint(); child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); } + //To make up for the studio positioning error problem var AnchorPointIn = widget.getAnchorPointInPoints(); child.setPosition(cc.p(child.getPositionX() + AnchorPointIn.x, child.getPositionY() + AnchorPointIn.y)); } From 3769b24f5ce10d0ea665e01fbb00d00b3c7f319c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 4 Feb 2015 17:19:30 +0800 Subject: [PATCH 1328/1564] UPDATE CANVAS TRANSFORM --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 9b0859b5bf..25eb9d0e84 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -249,7 +249,6 @@ cc.Node.RenderCmd.prototype = { proto.constructor = cc.Node.CanvasRenderCmd; proto.transform = function (parentCmd, recursive) { - var node = this._node; // transform for canvas var t = this.getNodeToParentTransform(), worldT = this._worldTransform; //get the world transform @@ -262,26 +261,8 @@ cc.Node.RenderCmd.prototype = { worldT.c = pt.c * t.a + pt.d * t.c; //c worldT.d = pt.c * t.b + pt.d * t.d; //d - worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx ; - worldT.ty = -pt.c * t.tx + pt.d * t.ty + pt.ty; - - var lScaleX = node._scaleX, lScaleY = node._scaleY; - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - var appX = this._anchorPointInPoints.x / lScaleX, - appY = this._anchorPointInPoints.y / lScaleY; - - // adjust anchorPoint - worldT.tx += worldT.a * -appX * sx + worldT.b * appY * sy; - worldT.ty -= worldT.c * -appX * sx + worldT.d * appY * sy; - - // if ignore anchorPoint - if (this._node._ignoreAnchorPointForPosition) { - worldT.tx += appX; - worldT.ty += appY; - } + worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx; + worldT.ty = pt.d * t.ty + pt.ty - pt.c * t.tx; } else { worldT.a = t.a; worldT.b = t.b; @@ -317,33 +298,33 @@ cc.Node.RenderCmd.prototype = { t.tx = node._position.x; t.ty = node._position.y; - var lScaleX = node._scaleX, lScaleY = node._scaleY; - - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - // rotation Cos and Sin - var A = sx, B = 0, - C = 0, D = sy; + var A = 1, B = 0, + C = 0, D = 1; if (node._rotationX) { var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - B = -Math.sin(rotationRadiansX) * sy; - D = Math.cos(rotationRadiansX) * sy; + B = -Math.sin(rotationRadiansX); + D = Math.cos(rotationRadiansX); } if (node._rotationY) { var rotationRadiansY = node._rotationY * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - A = Math.cos(rotationRadiansY) * sx; - C = Math.sin(rotationRadiansY) * sx; + A = Math.cos(rotationRadiansY); + C = Math.sin(rotationRadiansY); } - t.a = A; t.b = B; t.c = C; t.d = D; + var lScaleX = node._scaleX, lScaleY = node._scaleY; + var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; + + // Firefox on Vista and XP crashes + // GPU thread in case of scale(0.0, 0.0) + var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, + sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + // skew if (node._skewX || node._skewY) { // offset the anchorpoint @@ -353,10 +334,32 @@ cc.Node.RenderCmd.prototype = { skx = 99999999; if (sky === Infinity) sky = 99999999; + var xx = appY * skx * sx; + var yy = appX * sky * sy; t.a = A + B * sky; t.b = A * skx + B; t.c = C + D * sky; t.d = C * skx + D; + t.tx += A * xx + B * yy; + t.ty += C * xx + D * yy; + } + + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + t.a *= sx; + t.c *= sx; + t.b *= sy; + t.d *= sy; + } + + // adjust anchorPoint + t.tx += A * -appX * sx + B * appY * sy; + t.ty -= C * -appX * sx + D * appY * sy; + + // if ignore anchorPoint + if (node._ignoreAnchorPointForPosition) { + t.tx += appX; + t.ty += appY; } if (node._additionalTransformDirty) { From 6dbe0e5a2836ef27ff929a150c992cb5a8e9f597 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 4 Feb 2015 17:28:46 +0800 Subject: [PATCH 1329/1564] UPDATE CANVAS TRANSFORM --- .../CCProtectedNodeCanvasRenderCmd.js | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 60d1c3dc84..25cfd9169d 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -214,26 +214,8 @@ worldT.c = pt.c * t.a + pt.d * t.c; //c worldT.d = pt.c * t.b + pt.d * t.d; //d - worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx ; - worldT.ty = -pt.c * t.tx + pt.d * t.ty + pt.ty; - - var lScaleX = node._scaleX, lScaleY = node._scaleY; - // Firefox on Vista and XP crashes - // GPU thread in case of scale(0.0, 0.0) - var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, - sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; - var appX = this._anchorPointInPoints.x / lScaleX, - appY = this._anchorPointInPoints.y / lScaleY; - - // adjust anchorPoint - worldT.tx += worldT.a * -appX * sx + worldT.b * appY * sy; - worldT.ty -= worldT.c * -appX * sx + worldT.d * appY * sy; - - // if ignore anchorPoint - if (this._node._ignoreAnchorPointForPosition) { - worldT.tx += appX; - worldT.ty += appY; - } + worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx; + worldT.ty = pt.d * t.ty + pt.ty - pt.c * t.tx; } else { worldT.a = t.a; worldT.b = t.b; From 76b7c9baf9875b7dfd8d228d7f4755924d547d88 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 4 Feb 2015 18:15:46 +0800 Subject: [PATCH 1330/1564] UPDATE CANVAS TRANSFORM --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 25eb9d0e84..9027f2ab0d 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -299,23 +299,23 @@ cc.Node.RenderCmd.prototype = { t.ty = node._position.y; // rotation Cos and Sin - var A = 1, B = 0, - C = 0, D = 1; + var a = 1, b = 0, + c = 0, d = 1; if (node._rotationX) { var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - B = -Math.sin(rotationRadiansX); - D = Math.cos(rotationRadiansX); + b = -Math.sin(rotationRadiansX); + d = Math.cos(rotationRadiansX); } if (node._rotationY) { var rotationRadiansY = node._rotationY * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - A = Math.cos(rotationRadiansY); - C = Math.sin(rotationRadiansY); + a = Math.cos(rotationRadiansY); + c = Math.sin(rotationRadiansY); } - t.a = A; - t.b = B; - t.c = C; - t.d = D; + t.a = a; + t.b = b; + t.c = c; + t.d = d; var lScaleX = node._scaleX, lScaleY = node._scaleY; var appX = this._anchorPointInPoints.x, appY = this._anchorPointInPoints.y; @@ -336,12 +336,12 @@ cc.Node.RenderCmd.prototype = { sky = 99999999; var xx = appY * skx * sx; var yy = appX * sky * sy; - t.a = A + B * sky; - t.b = A * skx + B; - t.c = C + D * sky; - t.d = C * skx + D; - t.tx += A * xx + B * yy; - t.ty += C * xx + D * yy; + t.a = a + b * sky; + t.b = a * skx + b; + t.c = c + d * sky; + t.d = c * skx + d; + t.tx += a * xx + b * yy; + t.ty += c * xx + d * yy; } // scale @@ -353,8 +353,8 @@ cc.Node.RenderCmd.prototype = { } // adjust anchorPoint - t.tx += A * -appX * sx + B * appY * sy; - t.ty -= C * -appX * sx + D * appY * sy; + t.tx += a * -appX * sx + b * appY * sy; + t.ty -= c * -appX * sx + d * appY * sy; // if ignore anchorPoint if (node._ignoreAnchorPointForPosition) { From 8031e0ddbd72b13c070ce07be07342b03e14ece8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 5 Feb 2015 10:37:56 +0800 Subject: [PATCH 1331/1564] Fixed #2674: Fixed a bug of cc.PhysicsSprite that setIgnoreBodyRotation doesn't work --- cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js | 2 +- cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js index cb67531c89..ae95d94df9 100644 --- a/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js @@ -59,7 +59,7 @@ // rotation Cos and Sin var radians = -locBody.a; var Cos = 1, Sin = 0; - if (radians) { + if (radians && !node._ignoreBodyRotation) { Cos = Math.cos(radians); Sin = Math.sin(radians); } diff --git a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js index 893c272953..332c8e5d6f 100644 --- a/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +++ b/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js @@ -59,9 +59,11 @@ } // Make matrix - var radians = locBody.a; - var c = Math.cos(radians); - var s = Math.sin(radians); + var radians = locBody.a, c = 1, s=0; + if (radians && !node._ignoreBodyRotation) { + c = Math.cos(radians); + s = Math.sin(radians); + } // Although scale is not used by physics engines, it is calculated just in case // the sprite is animated (scaled up/down) using actions. From f44f8e87d1755664eca5ead93e3f9f4ad9022e4c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Feb 2015 11:15:06 +0800 Subject: [PATCH 1332/1564] FiFixed ccui.Button can't set pressed texture, after set setScale9Enabled --- extensions/ccui/uiwidgets/UIButton.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 23dd90d41b..060838e963 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -295,7 +295,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTexturePressed: function (selected, texType) { - if (!selected || (this._clickedFileName == selected && this._pressedTexType == texType)) + if (!selected) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._clickedFileName = selected; From bdf20698384b806d098fe06007c90b5f97d68984 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 5 Feb 2015 16:40:13 +0800 Subject: [PATCH 1333/1564] Fixed a bug of ccui.ScrollView that its dir is null when direction is DIR_NONE in _endRecordSlidAction --- extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 4c1113aeab..b3bc3e5957 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1321,7 +1321,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (!this._checkNeedBounce() && this.inertiaScrollEnabled) { if (this._slidTime <= 0.016) return; - var totalDis = 0, dir; + var totalDis = 0, dir = cc.p(0,0); var touchEndPositionInNodeSpace = this.convertToNodeSpace(this._touchEndPosition); var touchBeganPositionInNodeSpace = this.convertToNodeSpace(this._touchBeganPosition); switch (this.direction) { From a86fd5e879573b2f170454322dc482ffc05f512a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 5 Feb 2015 16:41:55 +0800 Subject: [PATCH 1334/1564] Fixed a bug of ccui.ScrollView that its dir is null when direction is DIR_NONE in _endRecordSlidAction --- extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index b3bc3e5957..3bfa11913d 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -1321,7 +1321,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ if (!this._checkNeedBounce() && this.inertiaScrollEnabled) { if (this._slidTime <= 0.016) return; - var totalDis = 0, dir = cc.p(0,0); + var totalDis = 0, dir; var touchEndPositionInNodeSpace = this.convertToNodeSpace(this._touchEndPosition); var touchBeganPositionInNodeSpace = this.convertToNodeSpace(this._touchBeganPosition); switch (this.direction) { @@ -1339,6 +1339,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ dir = cc.pNormalize(subVector); break; default: + dir = cc.p(0,0); break; } var orSpeed = Math.min(Math.abs(totalDis) / (this._slidTime), ccui.ScrollView.AUTO_SCROLL_MAX_SPEED); From ef0473f230b6a1d61455b069c013564088293f32 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 6 Feb 2015 10:13:10 +0800 Subject: [PATCH 1335/1564] Update the AUTHORS.txt for v3.3 final --- AUTHORS.txt | 1 + CHANGELOG.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index f38d11180d..56a564aebf 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -220,6 +220,7 @@ Robert Rouhani @Robmaister cc.TMXMapInfo bug fix cc.TMXLayer bug fix Igor Mats @IgorMats cc.Scale9Sprite bug fix + Spine runtime update Tim @duhaibo0404 ccs.csLoader bug fix diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e72346566d..7eb4179d7c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,6 @@ ChangeLog: -Cocos2d-JS v3.3 RC0 @ Reb.1, 2015 +Cocos2d-JS v3.3 RC0 @ Feb.1, 2015 * Added web exclusive functions: `_getFontStyle`, `_setFontStyle`, `_getFontWeight` and `_setFontWeight` APIs to `cc.LabelTTF`. * Observed orientation change event on mobile for resolution policy adaptation. From 2fc54d1d15e8e6a9733890f7155f65882563de21 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 6 Feb 2015 13:36:49 +0800 Subject: [PATCH 1336/1564] [Cocos2d-JS] v3.3 Release doc --- CHANGELOG.txt | 18 +++++++++++++++++- cocos2d/core/platform/CCConfig.js | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e72346566d..58ea7b6413 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,22 @@ ChangeLog: -Cocos2d-JS v3.3 RC0 @ Reb.1, 2015 +Cocos2d-JS v3.3 @ Feb.9, 2015 + +* Upgraded spine runtime to support the latest version and updated its test case. +* Added an option "noCache" for debugging on browsers. +* Set the default value of `cc.ParticleSystem`'s draw mode to texture mode. +* Added message to `ccs.load` when loading armature json file. +* Improved particle system test case. + +* Bug fixes: + 1. Fixed a bug of `cc.Sprite` that its `setSpriteFrame` doesn't work when sprite frame's `rotated` property is true. + 2. Fixed a bug of `cc.ClippingNode` when its stencil is `cc.Node` object in canvas mode. + 3. Fixed a ccui bug that the position of widgets is incorrect after loaded v2.x json file with `ccs.load`. + 4. Fixed a bug of `cc.PhysicsSprite` that `setIgnoreBodyRotation` function doesn't work. + 5. Fixed a bug of `ccui.Button` that setting pressed texture doesn't work when scale9 enabled. + 6. Fixed a bug of `ccui.ScrollView` that its `dir` property is null when passing `DIR_NONE` as `direction` in `_endRecordSlidAction` function. + +Cocos2d-JS v3.3 RC0 @ Feb.1, 2015 * Added web exclusive functions: `_getFontStyle`, `_setFontStyle`, `_getFontWeight` and `_setFontWeight` APIs to `cc.LabelTTF`. * Observed orientation change event on mobile for resolution policy adaptation. diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 7208062c13..e33721a2b8 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3 RC0"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3"; /** *

    From 2def33e0eea0f0cbdac6271d64a57cc876707af0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 6 Feb 2015 15:00:25 +0800 Subject: [PATCH 1337/1564] Fix setAdditionalTransform errors --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 9027f2ab0d..37410dbd4b 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -363,7 +363,20 @@ cc.Node.RenderCmd.prototype = { } if (node._additionalTransformDirty) { - this._transform = cc.affineTransformConcat(t, node._additionalTransform); + var additionalTransform = node._additionalTransform; + lScaleX = additionalTransform.a; + lScaleY = additionalTransform.d; + additionalTransform.a = 1; + additionalTransform.d = 1; + this._transform = cc.affineTransformConcat(t, additionalTransform); + + this._transform.a *= lScaleX; + this._transform.d *= lScaleY; + if((lScaleX < 0 && lScaleY > 0) || (lScaleX > 0 && lScaleY < 0)){ + this._transform.b *= -1; + this._transform.c *= -1; + } + node._additionalTransformDirty = false; } } From d32e5e4e2af6a33de98761fe1e5f5426dae9c24d Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Fri, 6 Feb 2015 10:21:41 -0500 Subject: [PATCH 1338/1564] Allow child renderer to be affected by ccui.RichText's opacity --- extensions/ccui/uiwidgets/UIRichText.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 6b44784902..f2f01b523a 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -545,6 +545,14 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ */ getDescription: function(){ return "RichText"; + }, + /** + * Allow child renderer to be affected by ccui.RichText's opacity + * @param {boolean} value + */ + setCascadeOpacityEnabled: function(value) { + this._super(value); + this._elementRenderersContainer.setCascadeOpacityEnabled(value); } }); From 87bf752f56546577474d4d7589836798bd42cc86 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Fri, 6 Feb 2015 10:36:39 -0500 Subject: [PATCH 1339/1564] cc.FontDefinition - inline definition usefull for constructor injection This will be usefull for avoiding countless parameters for LabelTTF and also to allow injection an new instance of FontDefinition directly in LabelTTF constructor --- cocos2d/core/platform/CCTypes.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index fcc16a9b77..4b94fefc96 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -338,10 +338,27 @@ cc._Dictionary = cc.Class.extend({ }); /** + * Common usage: + * + * var fontDef = new cc.FontDefinition(); + * fontDef.fontName = "Arial"; + * fontDef.fontSize = 12; + * ... + * + * OR using inline definition usefull for constructor injection + * + * var fontDef = new cc.FontDefinition({ + * fontName: "Arial", + * fontSize: 12 + * }); + * + * + * * @class cc.FontDefinition + * @param {Object} properties - (OPTIONAL) Allow inline FontDefinition * @constructor */ -cc.FontDefinition = function () { +cc.FontDefinition = function (properties) { var _t = this; _t.fontName = "Arial"; _t.fontSize = 12; @@ -360,6 +377,14 @@ cc.FontDefinition = function () { _t.shadowOffsetY = 0; _t.shadowBlur = 0; _t.shadowOpacity = 1.0; + + //properties mapping: + if(properties && properties instanceof Object){ + for(var key in properties){ + _t[key] = properties[key]; + } + } + }; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { From 7e77e4f1e97efa1d1b5155cb99ad355598a6bf73 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Fri, 6 Feb 2015 15:30:27 -0500 Subject: [PATCH 1340/1564] Added LineHeight support in ccui.RichText & FontDefinition Support for RichTextElement - cc.LabelTTF.__getFontHeightByDiv can be resolved by FontDefinition - Added getCanvasFontStr() to cc.FontDefinition + lineHeight support - small fix for clipped text issue --- cocos2d/core/labelttf/CCLabelTTF.js | 29 ++++- .../labelttf/CCLabelTTFCanvasRenderCmd.js | 17 ++- cocos2d/core/platform/CCTypes.js | 11 +- extensions/ccui/uiwidgets/UIRichText.js | 118 +++++++++++++++--- 4 files changed, 152 insertions(+), 23 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index db818091b6..02f2b7a21a 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -504,7 +504,12 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._fontName = textDefinition.fontName; this._fontSize = textDefinition.fontSize || 12; - this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); + + if(textDefinition.lineHeight) + this._lineHeight = textDefinition.lineHeight + + this._renderCmd._setFontStyle(textDefinition); + // shadow if (textDefinition.shadowEnabled) @@ -814,6 +819,27 @@ document.body ? }, false); cc.LabelTTF.__getFontHeightByDiv = function (fontName, fontSize) { + + if(fontName instanceof cc.FontDefinition){ + /** @type cc.FontDefinition */ + var fontDef = fontName; + var clientHeight = cc.LabelTTF.__fontHeightCache[fontDef.getCanvasFontStr()]; + if (clientHeight > 0) return clientHeight; + var labelDiv = cc.LabelTTF.__labelHeightDiv; + labelDiv.innerHTML = "ajghl~!"; + labelDiv.style.fontFamily = fontDef.fontName; + labelDiv.style.fontSize = fontDef.fontSize + "px"; + labelDiv.style.fontStyle = fontDef.fontStyle; + labelDiv.style.fontWeight = fontDef.fontWeight; + //labelDiv.style.lineHeight = fontDef.lineHeight + "px"; //FIXME: the text get clipped here + + clientHeight = labelDiv.clientHeight; + cc.LabelTTF.__fontHeightCache[fontDef.getCanvasFontStr()] = clientHeight; + labelDiv.innerHTML = ""; + return clientHeight; + } + + //Default var clientHeight = cc.LabelTTF.__fontHeightCache[fontName + "." + fontSize]; if (clientHeight > 0) return clientHeight; var labelDiv = cc.LabelTTF.__labelHeightDiv; @@ -824,6 +850,7 @@ cc.LabelTTF.__getFontHeightByDiv = function (fontName, fontSize) { cc.LabelTTF.__fontHeightCache[fontName + "." + fontSize] = clientHeight; labelDiv.innerHTML = ""; return clientHeight; + }; cc.LabelTTF.__fontHeightCache = {}; \ No newline at end of file diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 835175bd50..c167d84f1f 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -72,9 +72,16 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; return this._labelContext; }; - proto._setFontStyle = function (fontName, fontSize, fontStyle, fontWeight) { - this._fontStyleStr = fontStyle + " " + fontWeight + " " + fontSize + "px '" + fontName + "'"; - this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontName, fontSize); + proto._setFontStyle = function (fontNameOrFontDef, fontSize, fontStyle, fontWeight) { + + if(fontNameOrFontDef instanceof cc.FontDefinition){ + this._fontStyleStr = fontNameOrFontDef.getCanvasFontStr(); + this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontNameOrFontDef); + + }else { + this._fontStyleStr = fontStyle + " " + fontWeight + " " + fontSize + "px '" + fontNameOrFontDef + "'"; + this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontNameOrFontDef, fontSize); + } }; proto._getFontStyle = function () { @@ -197,7 +204,9 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var locContentSizeHeight = node._contentSize.height - locStrokeShadowOffsetY, locVAlignment = node._vAlignment, locHAlignment = node._hAlignment, locStrokeSize = node._strokeSize; - context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); + + //locContentSizeHeight *1.1 resolve the clipping of the text + context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight *1.1 + locStrokeShadowOffsetY * 0.5); //this is fillText for canvas if (context.font != this._fontStyleStr) diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 4b94fefc96..817e935fb3 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -371,6 +371,9 @@ cc.FontDefinition = function (properties) { _t.strokeEnabled = false; _t.strokeStyle = cc.color(255, 255, 255, 255); _t.lineWidth = 1; + _t.lineHeight = _t.fontSize; + _t.fontStyle = "normal"; + _t.fontWeight = "normal"; _t.shadowEnabled = false; _t.shadowOffsetX = 0; @@ -384,7 +387,13 @@ cc.FontDefinition = function (properties) { _t[key] = properties[key]; } } - +}; +/** + * + * Web ONLY + * */ +cc.FontDefinition.prototype.getCanvasFontStr = function(){ + return this.fontStyle + " " + this.fontWeight + " " + this.fontSize + "px/" + this.lineHeight+"px '" + this.fontName + "'"; }; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index f2f01b523a..bc40f170ca 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -70,23 +70,43 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# _text: "", _fontName: "", _fontSize: 0, + /** @type cc.FontDefinition */ + _fontDefinition: null, /** + * Usage Example using FontDefinition: + * + * var rtEl = new ccui.RichElementText("tag", new cc.FontDefinition({ + * fillStyle: cc.color.BLACK, + * fontName: "Arial", + * fontSize: 12, + * fontWeight: "bold", + * fontStyle: "normal", + * lineHeight: 12, + * marginTop: 0, + * marginBottom: 0, + * marginRight: 0, + * marginLeft: 0 + * }), 255, "Some Text"); + * * Constructor of ccui.RichElementText * @param {Number} tag - * @param {cc.Color} color + * @param {cc.Color|cc.FontDefinition} colorOrFontDef * @param {Number} opacity * @param {String} text * @param {String} fontName * @param {Number} fontSize */ - ctor: function (tag, color, opacity, text, fontName, fontSize) { + ctor: function (tag, colorOrFontDef, opacity, text, fontName, fontSize) { ccui.RichElement.prototype.ctor.call(this); this._type = ccui.RichElement.TEXT; this._text = ""; this._fontName = ""; this._fontSize = 0; - fontSize && this.init(tag, color, opacity, text, fontName, fontSize); + if( colorOrFontDef && colorOrFontDef instanceof cc.FontDefinition) + this.initWithStringAndTextDefinition(tag, text, colorOrFontDef, opacity); + else + fontSize && this.init(tag, colorOrFontDef, opacity, text, fontName, fontSize); }, /** @@ -104,6 +124,15 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# this._text = text; this._fontName = fontName; this._fontSize = fontSize; + }, + initWithStringAndTextDefinition: function(tag, text, fontDef, opacity){ + + ccui.RichElement.prototype.init.call(this, tag, fontDef.fillStyle, opacity); + this._fontDefinition = fontDef; + this._text = text; + this._fontName = fontDef.fontName; + this._fontSize = fontDef.fontSize; + } }); @@ -238,6 +267,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ _leftSpaceWidth: 0, _verticalSpace: 0, _elementRenderersContainer: null, + _lineBreakOnSpace: false, /** * create a rich text @@ -306,8 +336,10 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var elementRenderer = null; switch (element._type) { case ccui.RichElement.TEXT: - //todo: There may be ambiguous - elementRenderer = new cc.LabelTTF(element._text, element._fontName, element._fontSize); + if( element._fontDefinition) + elementRenderer = new cc.LabelTTF(element._text, element._fontDefinition); + else //todo: There may be ambiguous + elementRenderer = new cc.LabelTTF(element._text, element._fontName, element._fontSize); break; case ccui.RichElement.IMAGE: elementRenderer = new cc.Sprite(element._filePath); @@ -328,7 +360,10 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ element = locRichElements[i]; switch (element._type) { case ccui.RichElement.TEXT: - this._handleTextRenderer(element._text, element._fontName, element._fontSize, element._color); + if( element._fontDefinition) + this._handleTextRenderer(element._text, element._fontDefinition, element._fontDefinition.fontSize, element._fontDefinition.fillStyle); + else + this._handleTextRenderer(element._text, element._fontName, element._fontSize, element._color); break; case ccui.RichElement.IMAGE: this._handleImageRenderer(element._filePath, element._color, element._color.a); @@ -345,9 +380,25 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._formatTextDirty = false; } }, + /** + * Prepare the child LabelTTF based on line breaking + * @param {String} text + * @param {String|cc.FontDefinition} fontNameOrFontDef + * @param {Number} fontSize + * @param {cc.Color} color + * @private + */ + _handleTextRenderer: function (text, fontNameOrFontDef, fontSize, color) { - _handleTextRenderer: function (text, fontName, fontSize, color) { - var textRenderer = new cc.LabelTTF(text, fontName, fontSize); + if(text == "") + return; + + if(text == "\n"){ //Force Line Breaking + this._addNewLine(); + return; + } + + var textRenderer = fontNameOrFontDef instanceof cc.FontDefinition ? new cc.LabelTTF(text, fontNameOrFontDef) : new cc.LabelTTF(text, fontNameOrFontDef, fontSize); var textRendererWidth = textRenderer.getContentSize().width; this._leftSpaceWidth -= textRendererWidth; if (this._leftSpaceWidth < 0) { @@ -357,18 +408,38 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var leftLength = stringLength * (1 - overstepPercent); var leftWords = curText.substr(0, leftLength); var cutWords = curText.substr(leftLength, curText.length - 1); - if (leftLength > 0) { - var leftRenderer = new cc.LabelTTF(leftWords.substr(0, leftLength), fontName, fontSize); - leftRenderer.setColor(color); - leftRenderer.setOpacity(color.a); + var validLeftLength = leftLength > 0; + + if(this._lineBreakOnSpace){ + var lastSpaceIndex = leftWords.lastIndexOf(' '); + leftLength = lastSpaceIndex == -1 ? leftLength : lastSpaceIndex+1 ; + cutWords = curText.substr(leftLength, curText.length - 1); + validLeftLength = leftLength > 0 && cutWords != " "; + } + + if (validLeftLength) { + var leftRenderer = null; + if( fontNameOrFontDef instanceof cc.FontDefinition) + { + leftRenderer = new cc.LabelTTF(leftWords.substr(0, leftLength), fontNameOrFontDef); + leftRenderer.setOpacity(fontNameOrFontDef.fillStyle.a); //TODO: Verify that might not be needed... + }else{ + leftRenderer = new cc.LabelTTF(leftWords.substr(0, leftLength), fontNameOrFontDef, fontSize); + leftRenderer.setColor(color); + leftRenderer.setOpacity(color.a); + } this._pushToContainer(leftRenderer); } this._addNewLine(); - this._handleTextRenderer(cutWords, fontName, fontSize, color); + this._handleTextRenderer(cutWords, fontNameOrFontDef, fontSize, color); } else { - textRenderer.setColor(color); - textRenderer.setOpacity(color.a); + if( fontNameOrFontDef instanceof cc.FontDefinition) { + textRenderer.setOpacity(fontNameOrFontDef.fillStyle.a); //TODO: Verify that might not be needed... + }else { + textRenderer.setColor(color); + textRenderer.setOpacity(color.a); + } this._pushToContainer(textRenderer); } }, @@ -412,7 +483,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ locRenderersContainer.addChild(l, 1, j); var iSize = l.getContentSize(); newContentSizeWidth += iSize.width; - newContentSizeHeight = Math.max(newContentSizeHeight, iSize.height); + newContentSizeHeight = Math.max(Math.min(newContentSizeHeight, l.getLineHeight()), iSize.height); nextPosX += iSize.width; } locRenderersContainer.setContentSize(newContentSizeWidth, newContentSizeHeight); @@ -423,7 +494,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var maxHeight = 0; for (j = 0; j < row.length; j++) { l = row[j]; - maxHeight = Math.max(l.getContentSize().height, maxHeight); + maxHeight = Math.max(Math.min(l.getContentSize().height, l.getLineHeight()), maxHeight); } maxHeights[i] = maxHeight; newContentSizeHeight += maxHeights[i]; @@ -454,6 +525,9 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this.setContentSize(this._ignoreSize?this.getVirtualRendererSize():this._customSize); this._updateContentSizeWithTextureSize(this._contentSize); + + //locRenderersContainer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); + locRenderersContainer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); }, @@ -553,6 +627,16 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ setCascadeOpacityEnabled: function(value) { this._super(value); this._elementRenderersContainer.setCascadeOpacityEnabled(value); + }, + /** + * This allow the RichText layout to break line on space only like in Latin text format + * by default the property is false, which break the line on characters + * @param value + */ + setLineBreakOnSpace: function(value){ + this._lineBreakOnSpace = value; + this._formatTextDirty = true; + this.formatText(); } }); From 353df19ea870c247521ccd29f265f5646bdf87e9 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Fri, 6 Feb 2015 15:55:28 -0500 Subject: [PATCH 1341/1564] setting the multiplication to 1.03 still solve the text clipping issue without disturbing too much the normal vertical alignment of LabelTTF It worth mentioning that this is a uggly fix, ill look into it later for now it work --- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index c167d84f1f..fff249bc30 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -205,8 +205,8 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; locHAlignment = node._hAlignment, locStrokeSize = node._strokeSize; - //locContentSizeHeight *1.1 resolve the clipping of the text - context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight *1.1 + locStrokeShadowOffsetY * 0.5); + //locContentSizeHeight *1.03 resolve the clipping of the text + context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight *1.03 + locStrokeShadowOffsetY * 0.5); //this is fillText for canvas if (context.font != this._fontStyleStr) From f53bcb3cb06297a9d95bf91d69b34fcb2b1c94a7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 9 Feb 2015 11:55:54 +0800 Subject: [PATCH 1342/1564] Fixed affect its value --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 37410dbd4b..9919c0b07c 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -369,6 +369,8 @@ cc.Node.RenderCmd.prototype = { additionalTransform.a = 1; additionalTransform.d = 1; this._transform = cc.affineTransformConcat(t, additionalTransform); + additionalTransform.a = lScaleX; + additionalTransform.d = lScaleY; this._transform.a *= lScaleX; this._transform.d *= lScaleY; From b5e90c4cfdec37e7f8136158f73216474c05d028 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 9 Feb 2015 15:20:46 +0800 Subject: [PATCH 1343/1564] Remove _loadTxtSync, Because chrome(40) deprecated this API --- CCBoot.js | 58 ++++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index ca81412fce..11dcd5661b 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -690,26 +690,6 @@ cc.loader = /** @lends cc.loader# */{ }); } }, - _loadTxtSync: function (url) { - if (!cc._isNodeJs) { - var xhr = this.getXMLHttpRequest(); - xhr.open("GET", url, false); - if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { - // IE-specific logic here - xhr.setRequestHeader("Accept-Charset", "utf-8"); - } else { - if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8"); - } - xhr.send(null); - if (!xhr.readyState == 4 || xhr.status != 200) { - return null; - } - return xhr.responseText; - } else { - var fs = require("fs"); - return fs.readFileSync(url).toString(); - } - }, loadCsb: function(url, cb){ var xhr = new XMLHttpRequest(); @@ -1964,6 +1944,7 @@ cc.game = /** @lends cc.game# */{ DEBUG_MODE_INFO_FOR_WEB_PAGE: 4, DEBUG_MODE_WARN_FOR_WEB_PAGE: 5, DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6, + _ready: false, EVENT_HIDE: "game_on_hide", EVENT_SHOW: "game_on_show", @@ -2101,6 +2082,12 @@ cc.game = /** @lends cc.game# */{ * Run game. */ run: function (id) { + if(this._ready === false){ + this._ready = id === undefined ? true : id; + return; + }else if(typeof this._ready !== "boolean"){ + id = this._ready; + } var self = this; var _run = function () { if (id) { @@ -2143,7 +2130,13 @@ cc.game = /** @lends cc.game# */{ cfg[CONFIG_KEY.frameRate] = cfg[CONFIG_KEY.frameRate] || 60; if(cfg[CONFIG_KEY.renderMode] == null) cfg[CONFIG_KEY.renderMode] = 1; - return cfg; + //init debug move to CCDebugger + cc._initSys(cfg, CONFIG_KEY); + self.config = cfg; + if(cc.game._ready !== false){ + self._ready = true; + cc.game.run(); + } }; if (document["ccConfig"]) { self.config = _init(document["ccConfig"]); @@ -2154,7 +2147,7 @@ cc.game = /** @lends cc.game# */{ var _t = cocos_script[i].getAttribute('cocos'); if(_t == '' || _t){break;} } - var _src, txt, _resPath; + var _src, _resPath; if(i < cocos_script.length){ _src = cocos_script[i].src; if(_src){ @@ -2162,20 +2155,23 @@ cc.game = /** @lends cc.game# */{ cc.loader.resPath = _resPath; _src = cc.path.join(_resPath, 'project.json'); } - txt = cc.loader._loadTxtSync(_src); - } - if(!txt){ - txt = cc.loader._loadTxtSync("project.json"); + cc.loader.loadTxt(_src, function(err, txt){ + if(err) + return cc.error(err); + _init(JSON.parse(txt) || {}); + }); + }else{ + cc.loader.loadTxt("project.json", function(err, txt){ + if(err) + return cc.error(err); + _init(JSON.parse(txt) || {}); + }); } - var data = JSON.parse(txt); - self.config = _init(data || {}); } catch (e) { cc.log("Failed to read or parse project.json"); - self.config = _init({}); + _init({}); } } - //init debug move to CCDebugger - cc._initSys(self.config, CONFIG_KEY); }, //cache for js and module that has added into jsList to be loaded. From 4e87d5c6d026e12966e58f5cf68d2635c120f4b9 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Mon, 9 Feb 2015 11:07:01 -0500 Subject: [PATCH 1344/1564] removed the ugly fix as it just make no sense to me --- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index fff249bc30..868a1ef98c 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -204,9 +204,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var locContentSizeHeight = node._contentSize.height - locStrokeShadowOffsetY, locVAlignment = node._vAlignment, locHAlignment = node._hAlignment, locStrokeSize = node._strokeSize; - - //locContentSizeHeight *1.03 resolve the clipping of the text - context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight *1.03 + locStrokeShadowOffsetY * 0.5); + context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); //this is fillText for canvas if (context.font != this._fontStyleStr) From 12a69696f4cb99a97b2a4903be34639a04a84666 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Mon, 9 Feb 2015 11:30:52 -0500 Subject: [PATCH 1345/1564] Added getLineHeight check in the formatRenderers so it doesnt break with other type of Renderer --- extensions/ccui/uiwidgets/UIRichText.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index bc40f170ca..a707f6c656 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -481,9 +481,10 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ l.setAnchorPoint(cc.p(0, 0)); l.setPosition(nextPosX, 0); locRenderersContainer.addChild(l, 1, j); + var lineHeight = l.getLineHeight ? l.getLineHeight() : newContentSizeHeight; var iSize = l.getContentSize(); newContentSizeWidth += iSize.width; - newContentSizeHeight = Math.max(Math.min(newContentSizeHeight, l.getLineHeight()), iSize.height); + newContentSizeHeight = Math.max(Math.min(newContentSizeHeight, lineHeight), iSize.height); nextPosX += iSize.width; } locRenderersContainer.setContentSize(newContentSizeWidth, newContentSizeHeight); @@ -494,7 +495,8 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var maxHeight = 0; for (j = 0; j < row.length; j++) { l = row[j]; - maxHeight = Math.max(Math.min(l.getContentSize().height, l.getLineHeight()), maxHeight); + var lineHeight = l.getLineHeight ? l.getLineHeight() : l.getContentSize().height; + maxHeight = Math.max(Math.min(l.getContentSize().height, lineHeight), maxHeight); } maxHeights[i] = maxHeight; newContentSizeHeight += maxHeights[i]; From ad219d19566f62fd150903615fe142f62290892f Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Mon, 9 Feb 2015 13:44:07 -0500 Subject: [PATCH 1346/1564] Added Horizontal Alignment feature to ccui.Richtext --- extensions/ccui/uiwidgets/UIRichText.js | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index a707f6c656..6e2f31f5bf 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -268,6 +268,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ _verticalSpace: 0, _elementRenderersContainer: null, _lineBreakOnSpace: false, + _textHorizontalAlignment: null, /** * create a rich text @@ -282,6 +283,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._elementRenders = []; this._leftSpaceWidth = 0; this._verticalSpace = 0; + this._textHorizontalAlignment = cc.TEXT_ALIGNMENT_LEFT; }, _initRenderer: function () { @@ -476,6 +478,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ var newContentSizeWidth = 0; row = locElementRenders[0]; nextPosX = 0; + for (j = 0; j < row.length; j++) { l = row[j]; l.setAnchorPoint(cc.p(0, 0)); @@ -487,6 +490,18 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ newContentSizeHeight = Math.max(Math.min(newContentSizeHeight, lineHeight), iSize.height); nextPosX += iSize.width; } + + //Text flow alignment: + if(this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT) { + var offsetX = 0; + if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_RIGHT) + offsetX = this._contentSize.width - nextPosX; + else if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_CENTER) + offsetX = (this._contentSize.width - nextPosX) / 2; + for (j = 0; j < row.length; j++) + row[j].x += offsetX; + } + locRenderersContainer.setContentSize(newContentSizeWidth, newContentSizeHeight); } else { var maxHeights = []; @@ -515,6 +530,17 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ locRenderersContainer.addChild(l, 1); nextPosX += l.getContentSize().width; } + //Text flow alignment: (duplicate code) refactor? + if(this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT) { + var offsetX = 0; + if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_RIGHT) + offsetX = this._contentSize.width - nextPosX; + else if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_CENTER) + offsetX = (this._contentSize.width - nextPosX) / 2; + for (j = 0; j < row.length; j++) + row[j].x += offsetX; + } + } locRenderersContainer.setContentSize(this._contentSize); } @@ -639,6 +665,18 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._lineBreakOnSpace = value; this._formatTextDirty = true; this.formatText(); + }, + /** + * Set the renderer horizontal flow alignment for the Control + * although it is named TextHorizontalAlignment, it should work with all type of renderer too. + * NOTE: we should rename this to setHorizontalAlignment directly + * @param {Number} value - example cc.TEXT_ALIGNMENT_LEFT + */ + setTextHorizontalAlignment: function(value){ + if(value != this._textHorizontalAlignment) { + this._textHorizontalAlignment = value; + this.formatText(); + } } }); From 17da0b67845d21de739924c7b5d7790f054e137c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 10 Feb 2015 10:03:14 +0800 Subject: [PATCH 1347/1564] Fix setAdditionalTransform errors T.T --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 9919c0b07c..d561d1858d 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -364,20 +364,12 @@ cc.Node.RenderCmd.prototype = { if (node._additionalTransformDirty) { var additionalTransform = node._additionalTransform; - lScaleX = additionalTransform.a; - lScaleY = additionalTransform.d; - additionalTransform.a = 1; - additionalTransform.d = 1; - this._transform = cc.affineTransformConcat(t, additionalTransform); - additionalTransform.a = lScaleX; - additionalTransform.d = lScaleY; - - this._transform.a *= lScaleX; - this._transform.d *= lScaleY; - if((lScaleX < 0 && lScaleY > 0) || (lScaleX > 0 && lScaleY < 0)){ - this._transform.b *= -1; - this._transform.c *= -1; - } + this._transform = cc.affineTransformConcat(t, { + a: 1 , b: -additionalTransform.c, tx: additionalTransform.tx, + c: -additionalTransform.b , d: 1, ty: additionalTransform.ty + }); + this._transform.a *= additionalTransform.a; + this._transform.d *= additionalTransform.d; node._additionalTransformDirty = false; } From 32bfb64379ecf7e817bcbfaf4ca2686b97bf8551 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 10 Feb 2015 11:27:22 +0800 Subject: [PATCH 1348/1564] The ccui.text default font setting error --- extensions/ccui/uiwidgets/UIText.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 857e4663d4..8ae99ecb62 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -87,6 +87,8 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this.setFontName(fontName); this.setFontSize(fontSize); this.setString(textContent); + }else{ + this.setFontName("Thonburi"); } return true; } From d07faab5b4c7f4c552e89481c97002818496bde6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 10 Feb 2015 11:38:47 +0800 Subject: [PATCH 1349/1564] The ccui.text default font setting error --- extensions/ccui/uiwidgets/UIText.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index 8ae99ecb62..d52f7bba17 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -88,7 +88,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ this.setFontSize(fontSize); this.setString(textContent); }else{ - this.setFontName("Thonburi"); + this.setFontName(this._fontName); } return true; } From 6a7c7bf4dba59de40c75531ab98f5f8660e07d27 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 10 Feb 2015 17:54:25 +0800 Subject: [PATCH 1350/1564] Fixed pageView getPage code error... --- extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index cfedf69092..8dd03b0b5a 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -576,7 +576,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @returns {ccui.Layout} */ getPage: function(index){ - if (index < 0 || index >= this.getPages().size()) + if (index < 0 || index >= this._pages.length) return null; return this._pages[index]; }, From 60b84fa1f9197097d2c8a42eecacdd99631d03d9 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Tue, 10 Feb 2015 14:50:55 -0500 Subject: [PATCH 1351/1564] Added Vertical Alignment to ccui.RichText --- extensions/ccui/uiwidgets/UIRichText.js | 36 +++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 6e2f31f5bf..695e6aaaf6 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -269,6 +269,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ _elementRenderersContainer: null, _lineBreakOnSpace: false, _textHorizontalAlignment: null, + _textVerticalAlignment: null, /** * create a rich text @@ -284,6 +285,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._leftSpaceWidth = 0; this._verticalSpace = 0; this._textHorizontalAlignment = cc.TEXT_ALIGNMENT_LEFT; + this._textVerticalAlignment = cc.VERTICAL_TEXT_ALIGNMENT_TOP; }, _initRenderer: function () { @@ -498,6 +500,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ offsetX = this._contentSize.width - nextPosX; else if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_CENTER) offsetX = (this._contentSize.width - nextPosX) / 2; + for (j = 0; j < row.length; j++) row[j].x += offsetX; } @@ -518,6 +521,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } var nextPosY = this._customSize.height; + for (i = 0; i < locElementRenders.length; i++) { row = locElementRenders[i]; nextPosX = 0; @@ -530,18 +534,28 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ locRenderersContainer.addChild(l, 1); nextPosX += l.getContentSize().width; } - //Text flow alignment: (duplicate code) refactor? - if(this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT) { + //Text flow Horizontal alignment + if( this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT || this._textVerticalAlignment != cc.VERTICAL_TEXT_ALIGNMENT_TOP) { var offsetX = 0; if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_RIGHT) offsetX = this._contentSize.width - nextPosX; else if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_CENTER) offsetX = (this._contentSize.width - nextPosX) / 2; - for (j = 0; j < row.length; j++) - row[j].x += offsetX; - } + var offsetY = 0; + if (this._textVerticalAlignment == cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) + offsetY = this._customSize.height - newContentSizeHeight; + else if (this._textVerticalAlignment == cc.VERTICAL_TEXT_ALIGNMENT_CENTER) + offsetY = (this._customSize.height - newContentSizeHeight) / 2; + + for (j = 0; j < row.length; j++) { + l = row[j]; + l.x += offsetX; + l.y -= offsetY; + } + } } + locRenderersContainer.setContentSize(this._contentSize); } @@ -677,6 +691,18 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this._textHorizontalAlignment = value; this.formatText(); } + }, + /** + * Set the renderer vertical flow alignment for the Control + * although it is named TextHorizontalAlignment, it should work with all type of renderer too. + * NOTE: we should rename this to setVerticalAlignment directly + * @param {Number} value - example cc.VERTICAL_TEXT_ALIGNMENT_TOP + */ + setTextVerticalAlignment: function(value){ + if(value != this._textVerticalAlignment) { + this._textVerticalAlignment = value; + this.formatText(); + } } }); From 9d6b6bdcd36edf6d9791a86c477a866cab6066a4 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Tue, 10 Feb 2015 14:57:11 -0500 Subject: [PATCH 1352/1564] Little changes to comments for RichText alignment --- extensions/ccui/uiwidgets/UIRichText.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index 695e6aaaf6..ee75e8e0cc 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -684,7 +684,12 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * Set the renderer horizontal flow alignment for the Control * although it is named TextHorizontalAlignment, it should work with all type of renderer too. * NOTE: we should rename this to setHorizontalAlignment directly - * @param {Number} value - example cc.TEXT_ALIGNMENT_LEFT + * + * @example + * var richText = new ccui.RichText(); + * richText.setTextHorizontalAlignment(cc.Text_ALIGNMENT_RIGHT); + * + * @param {Number} value - example cc.TEXT_ALIGNMENT_RIGHT */ setTextHorizontalAlignment: function(value){ if(value != this._textHorizontalAlignment) { @@ -694,9 +699,13 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ }, /** * Set the renderer vertical flow alignment for the Control - * although it is named TextHorizontalAlignment, it should work with all type of renderer too. - * NOTE: we should rename this to setVerticalAlignment directly - * @param {Number} value - example cc.VERTICAL_TEXT_ALIGNMENT_TOP + * although it is named TextVerticalAlignment, it should work with all type of renderer too. + * + * @example + * var richText = new ccui.RichText(); + * richText.setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_CENTER); + * + * @param {Number} value - example cc.VERTICAL_TEXT_ALIGNMENT_CENTER */ setTextVerticalAlignment: function(value){ if(value != this._textVerticalAlignment) { From bd9b9be0de72098cad8402601c64397683035631 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 11 Feb 2015 13:55:06 +0800 Subject: [PATCH 1353/1564] Fix setAdditionalTransform errors T.T --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index d561d1858d..954b5e3cb8 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -364,13 +364,13 @@ cc.Node.RenderCmd.prototype = { if (node._additionalTransformDirty) { var additionalTransform = node._additionalTransform; - this._transform = cc.affineTransformConcat(t, { - a: 1 , b: -additionalTransform.c, tx: additionalTransform.tx, - c: -additionalTransform.b , d: 1, ty: additionalTransform.ty - }); - this._transform.a *= additionalTransform.a; - this._transform.d *= additionalTransform.d; - + var tb = this._transform.b; + this._transform.b = -this._transform.c; + this._transform.c = -tb; + this._transform = cc.affineTransformConcat(t, additionalTransform); + tb = this._transform.b; + this._transform.b = -this._transform.c; + this._transform.c = -tb; node._additionalTransformDirty = false; } } From c706770e5bc56e7a1342ef207aadedc809133c21 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 11 Feb 2015 17:52:10 +0800 Subject: [PATCH 1354/1564] transform.b, transform.c is contrary in the canvas --- cocos2d/core/base-nodes/CCNode.js | 2 + .../core/base-nodes/CCNodeCanvasRenderCmd.js | 57 ++++++++----------- cocos2d/core/renderer/RendererCanvas.js | 4 +- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 91b49f0d40..a82ded43a2 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1811,6 +1811,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * spriteB.setAdditionalTransform(t); */ setAdditionalTransform: function (additionalTransform) { + if(additionalTransform == null) + return this._additionalTransformDirty = false; this._additionalTransform = additionalTransform; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); this._additionalTransformDirty = true; diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 954b5e3cb8..5e4fdb724b 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -261,8 +261,8 @@ cc.Node.RenderCmd.prototype = { worldT.c = pt.c * t.a + pt.d * t.c; //c worldT.d = pt.c * t.b + pt.d * t.d; //d - worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx; - worldT.ty = pt.d * t.ty + pt.ty - pt.c * t.tx; + worldT.tx = pt.a * t.tx + pt.c * t.ty + pt.tx; + worldT.ty = pt.d * t.ty + pt.ty + pt.b * t.tx; } else { worldT.a = t.a; worldT.b = t.b; @@ -303,14 +303,14 @@ cc.Node.RenderCmd.prototype = { c = 0, d = 1; if (node._rotationX) { var rotationRadiansX = node._rotationX * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance - b = -Math.sin(rotationRadiansX); + c = Math.sin(rotationRadiansX); d = Math.cos(rotationRadiansX); } if (node._rotationY) { var rotationRadiansY = node._rotationY * 0.017453292519943295; //0.017453292519943295 = (Math.PI / 180); for performance a = Math.cos(rotationRadiansY); - c = Math.sin(rotationRadiansY); + b = -Math.sin(rotationRadiansY); } t.a = a; t.b = b; @@ -325,6 +325,14 @@ cc.Node.RenderCmd.prototype = { var sx = (lScaleX < 0.000001 && lScaleX > -0.000001) ? 0.000001 : lScaleX, sy = (lScaleY < 0.000001 && lScaleY > -0.000001) ? 0.000001 : lScaleY; + // scale + if (lScaleX !== 1 || lScaleY !== 1) { + a = t.a *= sx; + b = t.b *= sx; + c = t.c *= sy; + d = t.d *= sy; + } + // skew if (node._skewX || node._skewY) { // offset the anchorpoint @@ -334,27 +342,19 @@ cc.Node.RenderCmd.prototype = { skx = 99999999; if (sky === Infinity) sky = 99999999; - var xx = appY * skx * sx; - var yy = appX * sky * sy; - t.a = a + b * sky; - t.b = a * skx + b; - t.c = c + d * sky; - t.d = c * skx + d; - t.tx += a * xx + b * yy; - t.ty += c * xx + d * yy; - } - - // scale - if (lScaleX !== 1 || lScaleY !== 1) { - t.a *= sx; - t.c *= sx; - t.b *= sy; - t.d *= sy; + var xx = appY * skx; + var yy = appX * sky; + t.a = a - c * sky; + t.b = b - d * sky; + t.c = c - a * skx; + t.d = d - b * skx; + t.tx += a * xx + c * yy; + t.ty += b * xx + d * yy; } // adjust anchorPoint - t.tx += a * -appX * sx + b * appY * sy; - t.ty -= c * -appX * sx + d * appY * sy; + t.tx -= a * appX + c * appY; + t.ty -= b * appX + d * appY; // if ignore anchorPoint if (node._ignoreAnchorPointForPosition) { @@ -362,17 +362,8 @@ cc.Node.RenderCmd.prototype = { t.ty += appY; } - if (node._additionalTransformDirty) { - var additionalTransform = node._additionalTransform; - var tb = this._transform.b; - this._transform.b = -this._transform.c; - this._transform.c = -tb; - this._transform = cc.affineTransformConcat(t, additionalTransform); - tb = this._transform.b; - this._transform.b = -this._transform.c; - this._transform.c = -tb; - node._additionalTransformDirty = false; - } + if (node._additionalTransformDirty) + this._transform = cc.affineTransformConcat(t, node._additionalTransform); } return this._transform; }; diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js index db1bbff120..855207715b 100644 --- a/cocos2d/core/renderer/RendererCanvas.js +++ b/cocos2d/core/renderer/RendererCanvas.js @@ -254,9 +254,9 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) //ugly for armature this.restore(); this.save(); - this._context.transform(t.a, t.c, t.b, t.d, t.tx * scaleX, -(t.ty * scaleY)); + this._context.transform(t.a, -t.b, -t.c, t.d, t.tx * scaleX, -(t.ty * scaleY)); } else { - this._context.setTransform(t.a, t.c, t.b, t.d, this._offsetX + t.tx * scaleX, this._realOffsetY - (t.ty * scaleY)); + this._context.setTransform(t.a, -t.b, -t.c, t.d, this._offsetX + t.tx * scaleX, this._realOffsetY - (t.ty * scaleY)); } }; From 4f9ee0d2fd73dbb352463ad70a8a3124dc5cf905 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 11 Feb 2015 17:57:11 +0800 Subject: [PATCH 1355/1564] update ccui transform --- .../ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 25cfd9169d..120ba9c1b3 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -214,8 +214,8 @@ worldT.c = pt.c * t.a + pt.d * t.c; //c worldT.d = pt.c * t.b + pt.d * t.d; //d - worldT.tx = pt.a * t.tx - pt.b * t.ty + pt.tx; - worldT.ty = pt.d * t.ty + pt.ty - pt.c * t.tx; + worldT.tx = pt.a * t.tx + pt.c * t.ty + pt.tx; + worldT.ty = pt.d * t.ty + pt.ty + pt.b * t.tx; } else { worldT.a = t.a; worldT.b = t.b; From 5805d609979f4e476722b16d54918bb605486642 Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Wed, 11 Feb 2015 11:30:07 -0500 Subject: [PATCH 1356/1564] Renamed getCanvasFontStr to _getCanvasFontStr & Added support for lineHeight "normal" on LabelTTF --- cocos2d/core/labelttf/CCLabelTTF.js | 14 ++++++++------ .../core/labelttf/CCLabelTTFCanvasRenderCmd.js | 2 +- cocos2d/core/platform/CCTypes.js | 8 ++++---- extensions/ccui/uiwidgets/UIRichText.js | 15 ++++++--------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 02f2b7a21a..95b2e776fe 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -94,11 +94,10 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ _lineWidths: null, _className: "LabelTTF", - _lineHeight: 0, - //for web _fontStyle: "normal", _fontWeight: "normal", + _lineHeight: "normal", /** * Initializes the cc.LabelTTF with a font name, alignment, dimension and font size, do not call it by yourself, @@ -186,7 +185,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, getLineHeight: function () { - return this._lineHeight || this._renderCmd._getFontClientHeight(); + return !this._lineHeight || this._lineHeight.charAt ? + this._renderCmd._getFontClientHeight() : + this._lineHeight || this._renderCmd._getFontClientHeight(); }, setLineHeight: function (lineHeight) { @@ -507,6 +508,8 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if(textDefinition.lineHeight) this._lineHeight = textDefinition.lineHeight + else + this._lineHeight = this._fontSize; this._renderCmd._setFontStyle(textDefinition); @@ -823,7 +826,7 @@ cc.LabelTTF.__getFontHeightByDiv = function (fontName, fontSize) { if(fontName instanceof cc.FontDefinition){ /** @type cc.FontDefinition */ var fontDef = fontName; - var clientHeight = cc.LabelTTF.__fontHeightCache[fontDef.getCanvasFontStr()]; + var clientHeight = cc.LabelTTF.__fontHeightCache[fontDef._getCanvasFontStr()]; if (clientHeight > 0) return clientHeight; var labelDiv = cc.LabelTTF.__labelHeightDiv; labelDiv.innerHTML = "ajghl~!"; @@ -831,10 +834,9 @@ cc.LabelTTF.__getFontHeightByDiv = function (fontName, fontSize) { labelDiv.style.fontSize = fontDef.fontSize + "px"; labelDiv.style.fontStyle = fontDef.fontStyle; labelDiv.style.fontWeight = fontDef.fontWeight; - //labelDiv.style.lineHeight = fontDef.lineHeight + "px"; //FIXME: the text get clipped here clientHeight = labelDiv.clientHeight; - cc.LabelTTF.__fontHeightCache[fontDef.getCanvasFontStr()] = clientHeight; + cc.LabelTTF.__fontHeightCache[fontDef._getCanvasFontStr()] = clientHeight; labelDiv.innerHTML = ""; return clientHeight; } diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 868a1ef98c..276ef15313 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -75,7 +75,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; proto._setFontStyle = function (fontNameOrFontDef, fontSize, fontStyle, fontWeight) { if(fontNameOrFontDef instanceof cc.FontDefinition){ - this._fontStyleStr = fontNameOrFontDef.getCanvasFontStr(); + this._fontStyleStr = fontNameOrFontDef._getCanvasFontStr(); this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontNameOrFontDef); }else { diff --git a/cocos2d/core/platform/CCTypes.js b/cocos2d/core/platform/CCTypes.js index 817e935fb3..06ed754cce 100644 --- a/cocos2d/core/platform/CCTypes.js +++ b/cocos2d/core/platform/CCTypes.js @@ -371,7 +371,7 @@ cc.FontDefinition = function (properties) { _t.strokeEnabled = false; _t.strokeStyle = cc.color(255, 255, 255, 255); _t.lineWidth = 1; - _t.lineHeight = _t.fontSize; + _t.lineHeight = "normal"; _t.fontStyle = "normal"; _t.fontWeight = "normal"; @@ -389,11 +389,11 @@ cc.FontDefinition = function (properties) { } }; /** - * * Web ONLY * */ -cc.FontDefinition.prototype.getCanvasFontStr = function(){ - return this.fontStyle + " " + this.fontWeight + " " + this.fontSize + "px/" + this.lineHeight+"px '" + this.fontName + "'"; +cc.FontDefinition.prototype._getCanvasFontStr = function(){ + var lineHeight = !this.lineHeight.charAt ? this.lineHeight+"px" : this.lineHeight; + return this.fontStyle + " " + this.fontWeight + " " + this.fontSize + "px/"+lineHeight+" '" + this.fontName + "'"; }; if (cc._renderType === cc._RENDER_TYPE_WEBGL) { diff --git a/extensions/ccui/uiwidgets/UIRichText.js b/extensions/ccui/uiwidgets/UIRichText.js index ee75e8e0cc..a5fe79a187 100644 --- a/extensions/ccui/uiwidgets/UIRichText.js +++ b/extensions/ccui/uiwidgets/UIRichText.js @@ -81,11 +81,7 @@ ccui.RichElementText = ccui.RichElement.extend(/** @lends ccui.RichElementText# * fontSize: 12, * fontWeight: "bold", * fontStyle: "normal", - * lineHeight: 12, - * marginTop: 0, - * marginBottom: 0, - * marginRight: 0, - * marginLeft: 0 + * lineHeight: 14 * }), 255, "Some Text"); * * Constructor of ccui.RichElementText @@ -486,14 +482,16 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ l.setAnchorPoint(cc.p(0, 0)); l.setPosition(nextPosX, 0); locRenderersContainer.addChild(l, 1, j); + var lineHeight = l.getLineHeight ? l.getLineHeight() : newContentSizeHeight; + var iSize = l.getContentSize(); newContentSizeWidth += iSize.width; newContentSizeHeight = Math.max(Math.min(newContentSizeHeight, lineHeight), iSize.height); nextPosX += iSize.width; } - //Text flow alignment: + //Text flow horizontal alignment: if(this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT) { var offsetX = 0; if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_RIGHT) @@ -514,6 +512,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ for (j = 0; j < row.length; j++) { l = row[j]; var lineHeight = l.getLineHeight ? l.getLineHeight() : l.getContentSize().height; + cc.log(lineHeight); maxHeight = Math.max(Math.min(l.getContentSize().height, lineHeight), maxHeight); } maxHeights[i] = maxHeight; @@ -534,7 +533,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ locRenderersContainer.addChild(l, 1); nextPosX += l.getContentSize().width; } - //Text flow Horizontal alignment + //Text flow alignment(s) if( this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT || this._textVerticalAlignment != cc.VERTICAL_TEXT_ALIGNMENT_TOP) { var offsetX = 0; if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_RIGHT) @@ -568,8 +567,6 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ this.setContentSize(this._ignoreSize?this.getVirtualRendererSize():this._customSize); this._updateContentSizeWithTextureSize(this._contentSize); - //locRenderersContainer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); - locRenderersContainer.setPosition(this._contentSize.width * 0.5, this._contentSize.height * 0.5); }, From 28ef3eb8a8968825f18c16106fb7adff8b2c9c93 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 12 Feb 2015 14:33:05 +0800 Subject: [PATCH 1357/1564] Added 'setVirtualViewport' to cc.RenderTexture --- cocos2d/render-texture/CCRenderTexture.js | 10 ++++++ .../CCRenderTextureCanvasRenderCmd.js | 2 ++ .../CCRenderTextureWebGLRenderCmd.js | 31 ++++++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/cocos2d/render-texture/CCRenderTexture.js b/cocos2d/render-texture/CCRenderTexture.js index 56763ee666..3a8f14da69 100644 --- a/cocos2d/render-texture/CCRenderTexture.js +++ b/cocos2d/render-texture/CCRenderTexture.js @@ -156,6 +156,16 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{ this.sprite = sprite; }, + /** + * Used for grab part of screen to a texture. + * @param {cc.Point} rtBegin + * @param {cc.Rect} fullRect + * @param {cc.Rect} fullViewport + */ + setVirtualViewport: function(rtBegin, fullRect, fullViewport){ + this._renderCmd.setVirtualViewport(rtBegin, fullRect, fullViewport); + }, + /** * Initializes the instance of cc.RenderTexture * @function diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js index d93c976aa1..1f302501e1 100644 --- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -42,6 +42,8 @@ proto.clearStencil = function (stencilValue) { }; + proto.setVirtualViewport = function(rtBegin, fullRect, fullViewport) {}; + proto.updateClearColor = function(clearColor){ this._clearColorStr = "rgba(" + (0 | clearColor.r) + "," + (0 | clearColor.g) + "," + (0 | clearColor.b) + "," + clearColor.a / 255 + ")"; }; diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index ae567f689b..4a2e48cb63 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -31,11 +31,23 @@ this._oldFBO = null; this._textureCopy = null; this._depthRenderBuffer = null; + + this._rtTextureRect = new cc.Rect(); + this._fullRect = new cc.Rect(); + this._fullViewport = new cc.Rect(); }; var proto = cc.RenderTexture.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.RenderTexture.WebGLRenderCmd; + proto.setVirtualViewport = function(rtBegin, fullRect, fullViewport) { + this._rtTextureRect.x = rtBegin.x; + this._rtTextureRect.y = rtBegin.y; + + this._fullRect = fullRect; + this._fullViewport = fullViewport; + }; + proto.rendering = function (ctx) { var gl = ctx || cc._renderContext; var node = this._node; @@ -122,6 +134,8 @@ cc.log( "cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;"); var gl = cc._renderContext, locScaleFactor = cc.contentScaleFactor(); + this._fullRect = new cc.Rect(0,0, width, height); + this._fullViewport = new cc.Rect(0,0, width, height); width = 0 | (width * locScaleFactor); height = 0 | (height * locScaleFactor); @@ -213,6 +227,8 @@ cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLPushMatrix(); + var gl = cc._renderContext; + var director = cc.director; director.setProjection(director.getProjection()); @@ -223,16 +239,21 @@ var widthRatio = size.width / texSize.width; var heightRatio = size.height / texSize.height; - var gl = cc._renderContext; - - // Adjust the orthographic projection and viewport - gl.viewport(0, 0, texSize.width, texSize.height); - var orthoMatrix = new cc.kmMat4(); cc.kmMat4OrthographicProjection(orthoMatrix, -1.0 / widthRatio, 1.0 / widthRatio, -1.0 / heightRatio, 1.0 / heightRatio, -1, 1); cc.kmGLMultMatrix(orthoMatrix); + //calculate viewport + var viewport = new cc.Rect(0, 0, 0, 0); + viewport.width = this._fullViewport.width; + viewport.height = this._fullViewport.height; + var viewPortRectWidthRatio = viewport.width / this._fullRect.width; + var viewPortRectHeightRatio = viewport.height / this._fullRect.height; + viewport.x = (this._fullRect.x - this._rtTextureRect.x) * viewPortRectWidthRatio; + viewport.y = (this._fullRect.y - this._rtTextureRect.y) * viewPortRectHeightRatio; + gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); + this._oldFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING); gl.bindFramebuffer(gl.FRAMEBUFFER, this._fBO);//Will direct drawing to the frame buffer created above From ab69c9c12fcbc6ad45f4ceaee1b32b8992b1c38a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 12 Feb 2015 17:06:56 +0800 Subject: [PATCH 1358/1564] follow https://github.com/cocos2d/cocos2d-x/pull/9963/files --- cocos2d/core/event-manager/CCEventManager.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index f412e20b13..d45126255c 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -381,15 +381,16 @@ cc.eventManager = /** @lends cc.eventManager# */{ _updateListeners: function (event) { var locInDispatch = this._inDispatch; cc.assert(locInDispatch > 0, cc._LogInfos.EventManager__updateListeners); + + if(locInDispatch > 1) + return; + if (event.getType() == cc.Event.TOUCH) { this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID); this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID); } else this._onUpdateListeners(cc.__getListenerID(event)); - if(locInDispatch > 1) - return; - cc.assert(locInDispatch == 1, cc._LogInfos.EventManager__updateListeners_2); var locListenersMap = this._listenersMap, locPriorityDirtyFlagMap = this._priorityDirtyFlagMap; for (var selKey in locListenersMap) { From cbd2acd929854b62b648d29e7cb4bd1654f0f259 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 13 Feb 2015 18:15:53 +0800 Subject: [PATCH 1359/1564] Fixed #2568: Matrix of the partial reversal --- cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js | 8 ++++---- .../ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index 5e4fdb724b..dbcdaf8101 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -256,10 +256,10 @@ cc.Node.RenderCmd.prototype = { if (parentCmd) { var pt = parentCmd._worldTransform; // cc.AffineTransformConcat is incorrect at get world transform - worldT.a = pt.a * t.a + pt.b * t.c; //a - worldT.b = pt.a * t.b + pt.b * t.d; //b - worldT.c = pt.c * t.a + pt.d * t.c; //c - worldT.d = pt.c * t.b + pt.d * t.d; //d + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d worldT.tx = pt.a * t.tx + pt.c * t.ty + pt.tx; worldT.ty = pt.d * t.ty + pt.ty + pt.b * t.tx; diff --git a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js index 120ba9c1b3..c3ecd0bb7d 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js @@ -209,10 +209,10 @@ if (parentCmd) { var pt = parentCmd._worldTransform; // cc.AffineTransformConcat is incorrect at get world transform - worldT.a = pt.a * t.a + pt.b * t.c; //a - worldT.b = pt.a * t.b + pt.b * t.d; //b - worldT.c = pt.c * t.a + pt.d * t.c; //c - worldT.d = pt.c * t.b + pt.d * t.d; //d + worldT.a = t.a * pt.a + t.b * pt.c; //a + worldT.b = t.a * pt.b + t.b * pt.d; //b + worldT.c = t.c * pt.a + t.d * pt.c; //c + worldT.d = t.c * pt.b + t.d * pt.d; //d worldT.tx = pt.a * t.tx + pt.c * t.ty + pt.tx; worldT.ty = pt.d * t.ty + pt.ty + pt.b * t.tx; From c648d8bf614d94992746730e15f3c1409661328c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sun, 15 Feb 2015 10:25:47 +0800 Subject: [PATCH 1360/1564] Fixed a bug of ccui.ImageView that its loadTexture doesn't work when calling loadTexture multiple times at same frame. --- extensions/ccui/uiwidgets/UIImageView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UIImageView.js b/extensions/ccui/uiwidgets/UIImageView.js index 7f4519bc23..2a0a14f28b 100644 --- a/extensions/ccui/uiwidgets/UIImageView.js +++ b/extensions/ccui/uiwidgets/UIImageView.js @@ -102,7 +102,7 @@ ccui.ImageView = ccui.Widget.extend(/** @lends ccui.ImageView# */{ if(!imageRenderer._textureLoaded){ imageRenderer.addEventListener("load", function(){ - self.loadTexture(fileName, texType); + self.loadTexture(self._textureFile, self._imageTexType); }); } From bc95107462b34bbae39b31978c60543f38276096 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sun, 15 Feb 2015 11:30:46 +0800 Subject: [PATCH 1361/1564] Fixed a bug of ccui that its load event callbacks have some mistakes --- extensions/ccui/uiwidgets/UIButton.js | 6 +++--- extensions/ccui/uiwidgets/UICheckBox.js | 10 +++++----- extensions/ccui/uiwidgets/UILoadingBar.js | 2 +- extensions/ccui/uiwidgets/UISlider.js | 10 +++++----- extensions/ccui/uiwidgets/UITextBMFont.js | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 060838e963..dd76a26d8a 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -258,7 +258,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var normalRenderer = this._buttonNormalRenderer; if(!normalRenderer._textureLoaded){ normalRenderer.addEventListener("load", function(){ - self.loadTextureNormal(normal, texType); + self.loadTextureNormal(self._normalFileName, self._normalTexType); }); } switch (this._normalTexType){ @@ -305,7 +305,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var clickedRenderer = this._buttonClickedRenderer; if(!clickedRenderer._textureLoaded){ clickedRenderer.addEventListener("load", function(){ - self.loadTexturePressed(selected, texType); + self.loadTexturePressed(self._clickedFileName, self._pressedTexType); }); } @@ -350,7 +350,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var disabledRenderer = this._buttonDisableRenderer; if(!disabledRenderer._textureLoaded){ disabledRenderer.addEventListener("load", function() { - self.loadTextureDisabled(disabled, texType); + self.loadTextureDisabled(self._disabledFileName, self._disabledTexType); }); } diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index d62fdccf00..9f9f257fc4 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -174,7 +174,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ if(!bgBoxRenderer._textureLoaded){ bgBoxRenderer.addEventListener("load", function(){ this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize()); - this.loadTextureBackGround(backGround, texType); + this.loadTextureBackGround(this._backGroundFileName, this._backGroundTexType); }, this); }else{ this._backGroundBoxRenderer.setContentSize(this._customSize); @@ -216,7 +216,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var backGroundSelectedBoxRenderer = this._backGroundSelectedBoxRenderer; if(!backGroundSelectedBoxRenderer._textureLoaded){ backGroundSelectedBoxRenderer.addEventListener("load", function(){ - this.loadTextureBackGroundSelected(backGroundSelected, texType); + this.loadTextureBackGroundSelected(this._backGroundSelectedFileName, this._backGroundSelectedTexType); }, this); } @@ -256,7 +256,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var frontCrossRenderer = this._frontCrossRenderer; if(!frontCrossRenderer._textureLoaded){ frontCrossRenderer.addEventListener("load", function(){ - this.loadTextureFrontCross(cross, texType); + this.loadTextureFrontCross(this._frontCrossFileName, this._frontCrossTexType); }, this); } @@ -295,7 +295,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var backGroundBoxDisabledRenderer = this._backGroundBoxDisabledRenderer; if(!backGroundBoxDisabledRenderer._textureLoaded){ backGroundBoxDisabledRenderer.addEventListener("load", function(){ - this.loadTextureBackGroundDisabled(backGroundDisabled, texType); + this.loadTextureBackGroundDisabled(this._backGroundDisabledFileName, this._backGroundDisabledTexType); }, this); } @@ -334,7 +334,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var frontCrossDisabledRenderer = this._frontCrossDisabledRenderer; if(!frontCrossDisabledRenderer._textureLoaded){ frontCrossDisabledRenderer.addEventListener("load", function(){ - this.loadTextureFrontCrossDisabled(frontCrossDisabled, texType); + this.loadTextureFrontCrossDisabled(this._frontCrossDisabledFileName, this._frontCrossDisabledTexType); }, this); } diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 68cd78f917..dc3331a68f 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -124,7 +124,7 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ var self = this; if(!barRenderer._textureLoaded){ barRenderer.addEventListener("load", function(){ - self.loadTexture(texture, texType); + self.loadTexture(self._renderBarTexType, self._textureFile); }); } diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 4c3a61fef6..e36244fa92 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -135,7 +135,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!barRenderer._textureLoaded){ barRenderer.addEventListener("load", function(){ - self.loadBarTexture(fileName, texType); + self.loadBarTexture(self._textureFile, self._barTexType); }); } @@ -177,7 +177,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!progressBarRenderer._textureLoaded){ progressBarRenderer.addEventListener("load", function(){ - self.loadProgressBarTexture(fileName, texType); + self.loadProgressBarTexture(self._progressBarTextureFile, self._progressBarTexType); }); } @@ -347,7 +347,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallNormalRenderer._textureLoaded){ this._slidBallNormalRenderer.addEventListener("load", function(){ - self.loadSlidBallTextureNormal(normal, texType); + self.loadSlidBallTextureNormal(self._slidBallNormalTextureFile, self._ballNTexType); }); } @@ -383,7 +383,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallPressedRenderer._textureLoaded){ this._slidBallPressedRenderer.addEventListener("load", function(){ - self.loadSlidBallTexturePressed(pressed, texType); + self.loadSlidBallTexturePressed(self._slidBallPressedTextureFile, self._ballPTexType); }); } @@ -419,7 +419,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var self = this; if(!this._slidBallDisabledRenderer._textureLoaded){ this._slidBallDisabledRenderer.addEventListener("load", function(){ - self.loadSlidBallTextureDisabled(disabled, texType); + self.loadSlidBallTextureDisabled(self._slidBallDisabledTextureFile, self._ballDTexType); }); } diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index e50733de8e..b0af3462c1 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -79,7 +79,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo var locRenderer = _self._labelBMFontRenderer; if(!locRenderer._textureLoaded){ locRenderer.addEventListener("load", function(){ - _self.setFntFile(fileName); + _self.setFntFile(_self._fntFileName); }); } }, From 471855f108050180200d42bde7e00ccadf051013 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sun, 15 Feb 2015 17:39:15 +0800 Subject: [PATCH 1362/1564] Fixed a bug of cc.Layer that its bake function doesn't work when the layer has a parent node --- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 4 +- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 37 ++++--------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index dbcdaf8101..a61ba7ee65 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -252,7 +252,7 @@ cc.Node.RenderCmd.prototype = { // transform for canvas var t = this.getNodeToParentTransform(), worldT = this._worldTransform; //get the world transform - + this._cacheDirty = true; if (parentCmd) { var pt = parentCmd._worldTransform; // cc.AffineTransformConcat is incorrect at get world transform @@ -447,7 +447,7 @@ cc.Node.RenderCmd.prototype = { proto.setDirtyFlag = function (dirtyFlag) { cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, dirtyFlag); - this._setCacheDirty(); + this._setCacheDirty(); //TODO it should remove from here. if(this._cachedParent) this._cachedParent.setDirtyFlag(dirtyFlag); }; diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index a7f3c6a24b..436cde4ad8 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -55,7 +55,7 @@ if (!this._bakeSprite){ this._bakeSprite = new cc.BakeSprite(); - this._bakeSprite._parent = this._node; + this._bakeSprite.setAnchorPoint(0,0); } } }; @@ -93,19 +93,8 @@ var ctx = bakeContext.getContext(); locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); - var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = node._position; - if(node._ignoreAnchorPointForPosition){ - //bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); - //reset the bake sprite's position - locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); - } else { - var selfAnchor = this.getAnchorPointInPoints(); - var selfPos = {x: locPos.x - selfAnchor.x, y: locPos.y - selfAnchor.y}; - //bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y); - locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); - } + bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); + locBakeSprite.setPosition(boundingBox.x, boundingBox.y); //visit for canvas node.sortAllChildren(); @@ -114,7 +103,7 @@ children[i].visit(this); } cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); - locBakeSprite.transform(this); //because bake sprite's position was changed at rendering. + locBakeSprite.transform(); //because bake sprite's position was changed at rendering. this._cacheDirty = false; } }; @@ -234,19 +223,9 @@ var bakeContext = locBakeSprite.getCacheContext(); var ctx = bakeContext.getContext(); locBakeSprite.resetCanvasSize(boundingBox.width, boundingBox.height); - var anchor = locBakeSprite.getAnchorPointInPoints(), locPos = node._position; - if(node._ignoreAnchorPointForPosition){ - //bakeContext.translate(0 - boundingBox.x + locPos.x, boundingBox.height + boundingBox.y - locPos.y); - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); - //reset the bake sprite's position - locBakeSprite.setPosition(anchor.x + boundingBox.x - locPos.x, anchor.y + boundingBox.y - locPos.y); - } else { - var selfAnchor = this.getAnchorPointInPoints(); - var selfPos = {x: locPos.x - selfAnchor.x, y: locPos.y - selfAnchor.y}; - //bakeContext.translate(0 - boundingBox.x + selfPos.x, boundingBox.height + boundingBox.y - selfPos.y); - bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y); - locBakeSprite.setPosition(anchor.x + boundingBox.x - selfPos.x, anchor.y + boundingBox.y - selfPos.y); - } + + bakeContext.setOffset(0 - boundingBox.x, ctx.canvas.height - boundingBox.height + boundingBox.y ); + locBakeSprite.setPosition(boundingBox.x, boundingBox.y); var child; cc.renderer._turnToCacheMode(this.__instanceId); @@ -268,7 +247,7 @@ } else cc.renderer.pushRenderCommand(this); cc.renderer._renderingToCacheCanvas(bakeContext, this.__instanceId); - locBakeSprite.transform(this); + locBakeSprite.transform(); this._cacheDirty = false; } }; From 6702831e467b74feeb9e41de939e8dedc1404ca1 Mon Sep 17 00:00:00 2001 From: Mykyta Usikov Date: Mon, 16 Feb 2015 18:11:16 +0200 Subject: [PATCH 1363/1564] fixed typos in cc.ClippingNode.WebGLRenderCmd and cc.ParticleSystem.WebGLRenderCmd creation --- cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js | 2 +- cocos2d/particle/CCParticleSystemWebGLRenderCmd.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js index a1ce0ae0d6..451fb6ab7f 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js @@ -44,7 +44,7 @@ this._mask_layer_le = null; }; - var proto = cc.ClippingNode.WebGLRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); + var proto = cc.ClippingNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.ClippingNode.WebGLRenderCmd; cc.ClippingNode.WebGLRenderCmd._init_once = null; diff --git a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js index 0bdd3462f3..87f501510f 100644 --- a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js @@ -36,7 +36,7 @@ this._quadsArrayBuffer = null; }; var proto = cc.ParticleSystem.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); - proto.constructor = cc.ParticleSystem.CanvasRenderCmd; + proto.constructor = cc.ParticleSystem.WebGLRenderCmd; proto.getDrawMode = function(){}; proto.setDrawMode = function(drawMode){}; From 750b1406c8a070452c2d16b751afff29e46df54d Mon Sep 17 00:00:00 2001 From: Dany Ellement Date: Mon, 16 Feb 2015 14:52:55 -0500 Subject: [PATCH 1364/1564] Added GradientStops Feature to LayerGradient (Canvas Mode) --- cocos2d/core/layers/CCLayer.js | 64 +++++++++++++++++-- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 29 ++++++++- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index 297217e3b6..a072e282a3 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -322,21 +322,38 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ _alongVector: null, _compressedInterpolation: false, _className: "LayerGradient", + _colorStops: [], /** * Constructor of cc.LayerGradient * @param {cc.Color} start * @param {cc.Color} end * @param {cc.Point} [v=cc.p(0, -1)] - */ - ctor: function (start, end, v) { + * @param {Array|Null} stops + * + * @example Using ColorStops argument: + * //startColor & endColor are for default and backward compatibility + * var layerGradient = new cc.LayerGradient(cc.color.RED, new cc.Color(255,0,0,0), cc.p(0, -1), + * [{p:0, color: cc.color.RED}, + * {p:.5, color: new cc.Color(0,0,0,0)}, + * {p:1, color: cc.color.RED}]); + * //where p = A value between 0.0 and 1.0 that represents the position between start and end in a gradient + * + */ + ctor: function (start, end, v, stops) { var _t = this; cc.LayerColor.prototype.ctor.call(_t); _t._endColor = cc.color(0, 0, 0, 255); _t._alongVector = cc.p(0, -1); _t._startOpacity = 255; _t._endOpacity = 255; - cc.LayerGradient.prototype.init.call(_t, start, end, v); + + if(stops && stops instanceof Array) + _t._colorStops = stops; + else + _t._colorStops = [{p:0, color: start}, {p:1, color: end}]; + + cc.LayerGradient.prototype.init.call(_t, start, end, v, stops); }, /** @@ -344,9 +361,10 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ * @param {cc.Color} start starting color * @param {cc.Color} end * @param {cc.Point|Null} v + * @param {Array|Null} stops * @return {Boolean} */ - init: function (start, end, v) { + init: function (start, end, v, stops) { start = start || cc.color(0, 0, 0, 255); end = end || cc.color(0, 0, 0, 255); v = v || cc.p(0, -1); @@ -498,6 +516,36 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty); }, + /** + * Return an array of Object representing a colorStop for the gradient, if no stops was specified + * start & endColor will be provided as default values + * @example + * [{p: 0, color: cc.color.RED},{p: 1, color: cc.color.RED},...] + * @returns {Array} + */ + getColorStops: function(){ + return this._colorStops; + }, + /** + * Set the colorStops to create the gradient using multiple point & color + * + * @param colorStops + * + * @example + * //startColor & endColor are for default and backward compatibility + * var layerGradient = new cc.LayerGradient(cc.color.RED, new cc.Color(255,0,0,0), cc.p(0, -1)); + * layerGradient.setColorStops([{p:0, color: cc.color.RED}, + * {p:.5, color: new cc.Color(0,0,0,0)}, + * {p:1, color: cc.color.RED}]); + * //where p = A value between 0.0 and 1.0 that represents the position between start and end in a gradient + * + */ + setColorStops: function(colorStops){ + + this._colorStops = colorStops; + this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty|cc.Node._dirtyFlags.gradientDirty); + }, + _createRenderCmd: function(){ if (cc._renderType === cc._RENDER_TYPE_CANVAS) return new cc.LayerGradient.CanvasRenderCmd(this); @@ -513,10 +561,11 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ * @param {cc.Color} start starting color * @param {cc.Color} end ending color * @param {cc.Point|Null} v + * @param {Array|NULL} stops * @return {cc.LayerGradient} */ -cc.LayerGradient.create = function (start, end, v) { - return new cc.LayerGradient(start, end, v); +cc.LayerGradient.create = function (start, end, v, stops) { + return new cc.LayerGradient(start, end, v, stops); }; //LayerGradient - Getter Setter (function(){ @@ -537,6 +586,9 @@ cc.LayerGradient.create = function (start, end, v) { /** @expose */ proto.vector; cc.defineGetterSetter(proto, "vector", proto.getVector, proto.setVector); + /** @expose */ + proto.colorStops; + cc.defineGetterSetter(proto, "colorStops", proto.getColorStops, proto.setColorStops); })(); /** diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index a7f3c6a24b..cf8ce7abfd 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -369,9 +369,18 @@ var locWidth = node._contentSize.width, locHeight = node._contentSize.height; wrapper.setCompositeOperation(this._blendFuncStr); wrapper.setGlobalAlpha(opacity); - var gradient = context.createLinearGradient(this._startPoint.x, this._startPoint.y, this._endPoint.x, this._endPoint.y); - gradient.addColorStop(0, this._startStopStr); - gradient.addColorStop(1, this._endStopStr); + var gradient = context.createLinearGradient(this._startPoint.x*scaleX, this._startPoint.y*scaleY, this._endPoint.x*scaleX, this._endPoint.y*scaleY); + + if(node._colorStops){ //Should always fall here now + for(var i=0; i < node._colorStops.length; i++) { + var stop = node._colorStops[i]; + gradient.addColorStop(stop.p, this._colorStopsStr[i]); + } + }else{ + gradient.addColorStop(0, this._startStopStr); + gradient.addColorStop(1, this._endStopStr); + } + wrapper.setFillStyle(gradient); wrapper.setTransform(this._worldTransform, scaleX, scaleY); @@ -430,5 +439,19 @@ + Math.round(locStartColor.b) + "," + startOpacity.toFixed(4) + ")"; this._endStopStr = "rgba(" + Math.round(locEndColor.r) + "," + Math.round(locEndColor.g) + "," + Math.round(locEndColor.b) + "," + endOpacity.toFixed(4) + ")"; + + if( node._colorStops){ + this._startOpacity = 0; + this._endOpacity = 0; + + this._colorStopsStr = []; + for(var i =0; i < node._colorStops.length; i++){ + var stopColor = node._colorStops[i].color; + var stopOpacity = stopColor.a/255; + this._colorStopsStr.push("rgba(" + Math.round(stopColor.r) + "," + Math.round(stopColor.g) + "," + + Math.round(stopColor.b) + "," + stopOpacity.toFixed(4) + ")"); + } + } + }; })(); \ No newline at end of file From 521235099fff435c7e7749f38ce1ef1f024fb4e2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 26 Feb 2015 09:58:50 +0800 Subject: [PATCH 1365/1564] Fixed #2416: fixed a bug of cc.Sprite in setTextureRect --- cocos2d/core/labelttf/CCLabelTTF.js | 6 +++--- cocos2d/core/sprites/CCSprite.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 95b2e776fe..106e92bc19 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -642,7 +642,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._dimensions.width = width; this._dimensions.height = height; this._updateString(); - // Force udpate + // Force update this._setUpdateTextureDirty(); } }, @@ -654,7 +654,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (width != this._dimensions.width) { this._dimensions.width = width; this._updateString(); - // Force udpate + // Force update this._setUpdateTextureDirty(); } }, @@ -666,7 +666,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (height != this._dimensions.height) { this._dimensions.height = height; this._updateString(); - // Force udpate + // Force update this._setUpdateTextureDirty(); } }, diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 876b5def45..7bcd41db64 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -759,14 +759,14 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _t.setVertexRect(rect); _t._renderCmd._setTextureCoords(rect, needConvert); - var relativeOffset = _t._unflippedOffsetPositionFromCenter; + var relativeOffsetX = _t._unflippedOffsetPositionFromCenter.x, relativeOffsetY = _t._unflippedOffsetPositionFromCenter.y; if (_t._flippedX) - relativeOffset.x = -relativeOffset.x; + relativeOffsetX = -relativeOffsetX; if (_t._flippedY) - relativeOffset.y = -relativeOffset.y; + relativeOffsetY = -relativeOffsetY; var locRect = _t._rect; - _t._offsetPosition.x = relativeOffset.x + (_t._contentSize.width - locRect.width) / 2; - _t._offsetPosition.y = relativeOffset.y + (_t._contentSize.height - locRect.height) / 2; + _t._offsetPosition.x = relativeOffsetX + (_t._contentSize.width - locRect.width) / 2; + _t._offsetPosition.y = relativeOffsetY + (_t._contentSize.height - locRect.height) / 2; // rendering using batch node if (_t._batchNode) { From 9cdb4c03cf444f33105d384159692f48db502a4f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 27 Feb 2015 11:20:24 +0800 Subject: [PATCH 1366/1564] update scheduler cocos2d/cocos2d-js#1316 --- cocos2d/core/CCDirector.js | 2 +- cocos2d/core/CCScheduler.js | 785 ++++++++++++------ cocos2d/core/base-nodes/CCNode.js | 75 +- .../armature/utils/CCDataReaderHelper.js | 2 +- 4 files changed, 617 insertions(+), 247 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index c4111ffdc3..ab18b55675 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -154,7 +154,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ this._scheduler = new cc.Scheduler(); //action manager this._actionManager = cc.ActionManager ? new cc.ActionManager() : null; - this._scheduler.scheduleUpdateForTarget(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false); + this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false); this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW); this._eventAfterDraw.setUserData(this); diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index df1f7354cc..6bc4a72b0b 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -39,14 +39,16 @@ cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1; * @name cc.ListEntry * @param {cc.ListEntry} prev * @param {cc.ListEntry} next + * @param {function} callback * @param {cc.Class} target not retained (retained by hashUpdateEntry) * @param {Number} priority * @param {Boolean} paused * @param {Boolean} markedForDeletion selector will no longer be called and entry will be removed at end of the next tick */ -cc.ListEntry = function (prev, next, target, priority, paused, markedForDeletion) { +cc.ListEntry = function (prev, next, callback, target, priority, paused, markedForDeletion) { this.prev = prev; this.next = next; + this.callback = callback; this.target = target; this.priority = priority; this.paused = paused; @@ -60,12 +62,14 @@ cc.ListEntry = function (prev, next, target, priority, paused, markedForDeletion * @param {cc.ListEntry} list Which list does it belong to ? * @param {cc.ListEntry} entry entry in the list * @param {cc.Class} target hash key (retained) + * @param {function} callback * @param {Array} hh */ -cc.HashUpdateEntry = function (list, entry, target, hh) { +cc.HashUpdateEntry = function (list, entry, target, callback, hh) { this.list = list; this.entry = entry; this.target = target; + this.callback = callback; this.hh = hh; }; @@ -81,7 +85,7 @@ cc.HashUpdateEntry = function (list, entry, target, hh) { * @param {Boolean} paused * @param {Array} hh */ -cc.HashTimerEntry = function (timers, target, timerIndex, currentTimer, currentTimerSalvaged, paused, hh) { +cc.HashTimerEntry = cc.hashSelectorEntry = function (timers, target, timerIndex, currentTimer, currentTimerSalvaged, paused, hh) { var _t = this; _t.timers = timers; _t.target = target; @@ -98,17 +102,18 @@ cc.HashTimerEntry = function (timers, target, timerIndex, currentTimer, currentT * @extends cc.Class */ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ - _interval:0.0, - _callback:null,//is called _callback before - - _target:null,//target of _callback + _scheduler: null, _elapsed:0.0, - _runForever:false, _useDelay:false, _timesExecuted:0, _repeat:0, //0 = once, 1 is 2 x executed _delay:0, + _interval:0.0, + + //_callback:null,//is called _callback before + //_target:null,//target of _callback + /** * @return {Number} returns interval of timer @@ -119,10 +124,30 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ */ setInterval : function(interval){this._interval = interval;}, + setupTimerWithInterval: function(seconds, repeat, delay){ + //todo checking here + this._elapsed = -1; + this._interval = seconds; + this._delay = delay; + this._useDelay = this._delay > 0 ? true : false; + this._repeat = repeat; + this._runForever = this._repeat == cc.REPEAT_FOREVER ? true : false; + }, + + //todo checking here + trigger: function(){ + return 0; + }, + + //todo checking here + cancel: function(){ + return 0; + }, + /** * @return {String|function} returns callback */ - getCallback : function(){return this._callback}, + //getCallback : function(){return this._callback}, /** @@ -135,23 +160,14 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ * @param {Number} [delay=0] delay */ ctor:function (target, callback, interval, repeat, delay) { - var self = this; - self._target = target; - self._callback = callback; - self._elapsed = -1; - self._interval = interval || 0; - self._delay = delay || 0; - self._useDelay = self._delay > 0; - self._repeat = (repeat == null) ? cc.REPEAT_FOREVER : repeat; - self._runForever = (self._repeat == cc.REPEAT_FOREVER); - }, - - _doCallback:function(){ - var self = this; - if (cc.isString(self._callback)) - self._target[self._callback](self._elapsed); - else // if (typeof(this._callback) == "function") { - self._callback.call(self._target, self._elapsed); + this._scheduler = null; + this._elapsed = -1; + this._runForever = false; + this._useDelay = false; + this._timesExecuted = 0; + this._repeat = 0; + this._delay = 0; + this._interval = 0; }, /** @@ -159,47 +175,119 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ * @param {Number} dt delta time */ update:function (dt) { - var self = this; - if (self._elapsed == -1) { - self._elapsed = 0; - self._timesExecuted = 0; + if (this._elapsed == -1) { + this._elapsed = 0; + this._timesExecuted = 0; } else { - var locTarget = self._target, locCallback = self._callback; - self._elapsed += dt;//standard timer usage - if (self._runForever && !self._useDelay) { - if (self._elapsed >= self._interval) { - if (locTarget && locCallback) - self._doCallback(); - self._elapsed = 0; + this._elapsed += dt; + if (this._runForever && !this._useDelay) {//standard timer usage + if (this._elapsed >= this._interval) { + this.trigger(); + this._elapsed = 0; } - } else { - //advanced usage - if (self._useDelay) { - if (self._elapsed >= self._delay) { - if (locTarget && locCallback) - self._doCallback(); - - self._elapsed = self._elapsed - self._delay; - self._timesExecuted += 1; - self._useDelay = false; + } else {//advanced usage + if (this._useDelay) { + if (this._elapsed >= this._delay) { + this.trigger(); + + this._elapsed -= this._delay; + this._timesExecuted += 1; + this._useDelay = false; } } else { - if (self._elapsed >= self._interval) { - if (locTarget && locCallback) - self._doCallback(); + if (this._elapsed >= this._interval) { + this.trigger(); - self._elapsed = 0; - self._timesExecuted += 1; + this._elapsed = 0; + this._timesExecuted += 1; } } - if (self._timesExecuted > self._repeat) - cc.director.getScheduler().unscheduleCallbackForTarget(locTarget, locCallback); + if (!this._runForever && this._timesExecuted > this._repeat) + this.cancel(); } } } }); +cc.TimerTargetSelector = cc.Timer.extend({ + + _target: null, + _selector: null, + + ctor: function(){ + this._target = null; + this._selector = null; + }, + + initWithSelector: function(scheduler, selector, target, seconds, repeat, delay){ + this._scheduler = scheduler; + this._target = target; + this._selector = selector; + this.setupTimerWithInterval(seconds, repeat, delay); + return true; + }, + + getSelector: function(){ + return this._selector; + }, + + trigger: function(){ + //override + if (this._target && this._selector){ + this._target.call(this._selector, this._elapsed); + } + }, + + cancel: function(){ + //override + this._scheduler.unschedule(this._selector, this._target); + } + +}); + +cc.TimerTargetCallback = cc.Timer.extend({ + + _target: null, + _callback: null, + _key: null, + + ctor: function(){ + this._target = null; + this._callback = null; + }, + + initWithCallback: function(scheduler, callback, target, key, seconds, repeat, delay){ + //todo checking here + this._scheduler = scheduler; + this._target = target; + this._callback = callback; + this._key = key; + this.setupTimerWithInterval(seconds, repeat, delay); + return true; + }, + + getCallback: function(){ + return this._callback; + }, + + getKey: function(){ + return this._key; + }, + + trigger: function(){ + //override + if(this._callback) + this._callback.call(this._target, this._elapsed); + }, + + cancel: function(){ + //override + this._scheduler.unschedule(this._key, this._target); + } + +}); + /** *

    * Scheduler is responsible of triggering the scheduled callbacks.
    @@ -221,38 +309,79 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ _timeScale:1.0, - _updates : null, //_updates[0] list of priority < 0, _updates[1] list of priority == 0, _updates[2] list of priority > 0, + //_updates : null, //_updates[0] list of priority < 0, _updates[1] list of priority == 0, _updates[2] list of priority > 0, + _updatesNegList: null, + _updates0List: null, + _updatesPosList: null, _hashForUpdates:null, // hash used to fetch quickly the list entries for pause,delete,etc - _arrayForUpdates:null, _hashForTimers:null, //Used for "selectors with interval" - _arrayForTimes:null, - _currentTarget:null, _currentTargetSalvaged:false, _updateHashLocked:false, //If true unschedule will not remove anything from a hash. Elements will only be marked for deletion. + //_arrayForTimes:null, + //_arrayForUpdates:null, + ctor:function () { var self = this; self._timeScale = 1.0; - self._updates = [[], [], []]; + //self._updates = [[], [], []]; + this._updatesNegList = []; + this._updates0List = []; + this._updatesPosList = []; self._hashForUpdates = {}; - self._arrayForUpdates = []; - self._hashForTimers = {}; - self._arrayForTimers = []; - self._currentTarget = null; self._currentTargetSalvaged = false; self._updateHashLocked = false; + + //self._arrayForUpdates = []; + //self._arrayForTimers = []; + }, //-----------------------private method---------------------- + + _schedulePerFrame: function(callback, target, priority, paused){ + //todo + var hashElement = this._hashForUpdates[target.__instanceId]; + if (hashElement){ + // check if priority has changed + if (hashElement.list.priority != priority){ + if (this._updateHashLocked){ + cc.log("warning: you CANNOT change update priority in scheduled function"); + hashElement.entry.markedForDeletion = false; + hashElement.entry.paused = paused; + return; + }else{ + // will be added again outside if (hashElement). + this.unscheduleUpdate(target); + } + }else{ + hashElement.entry.markedForDeletion = false; + hashElement.entry.paused = paused; + return; + } + } + + // most of the updates are going to be 0, that's way there + // is an special list for updates with priority 0 + if (priority == 0){ + this._appendIn(this._updates0List, callback, target, paused); + }else if (priority < 0){ + this._priorityIn(this._updatesNegList, callback, target, priority, paused); + }else{ + // priority > 0 + this._priorityIn(this._updatesPosList, callback, target, priority, paused); + } + }, + _removeHashElement:function (element) { delete this._hashForTimers[element.target.__instanceId]; - cc.arrayRemoveObject(this._arrayForTimers, element); + //cc.arrayRemoveObject(this._arrayForTimers, element); element.Timer = null; element.target = null; element = null; @@ -265,7 +394,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ cc.arrayRemoveObject(element.list, element.entry); delete self._hashForUpdates[element.target.__instanceId]; - cc.arrayRemoveObject(self._arrayForUpdates, element); + cc.arrayRemoveObject(self._hashForUpdates, element); element.entry = null; //hash entry @@ -273,8 +402,9 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ } }, - _priorityIn:function (ppList, target, priority, paused) { - var self = this, listElement = new cc.ListEntry(null, null, target, priority, paused, false); + _priorityIn:function (ppList, callback, target, priority, paused) { + var self = this, + listElement = new cc.ListEntry(null, null, callback, target, priority, paused, false); // empey list ? if (!ppList) { @@ -293,19 +423,17 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ //update hash entry for quick access var hashElement = new cc.HashUpdateEntry(ppList, listElement, target, null); - self._arrayForUpdates.push(hashElement); self._hashForUpdates[target.__instanceId] = hashElement; return ppList; }, - _appendIn:function (ppList, target, paused) { - var self = this, listElement = new cc.ListEntry(null, null, target, 0, paused, false); + _appendIn:function (ppList, callback, target, paused) { + var self = this, listElement = new cc.ListEntry(null, null, callback, target, 0, paused, false); ppList.push(listElement); //update hash entry for quicker access - var hashElement = new cc.HashUpdateEntry(ppList, listElement, target, null); - self._arrayForUpdates.push(hashElement); + var hashElement = new cc.HashUpdateEntry(ppList, listElement, target, null, null); self._hashForUpdates[target.__instanceId] = hashElement; }, @@ -337,33 +465,40 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * @param {Number} dt delta time */ update:function (dt) { - var self = this; - var locUpdates = self._updates, locArrayForTimers = self._arrayForTimers; - var tmpEntry, elt, i, li; - self._updateHashLocked = true; - - if (this._timeScale != 1.0) { + this._updateHashLocked = true; + if(this._timeScale != 1) dt *= this._timeScale; + + var i, list, len, entry; + + for(i=0,list=this._updatesNegList, len = list.length; i= 0; i++){ - var update = self._updates[i]; - for(var j = 0, lj = update.length; j < lj; j++){ - tmpEntry = update[j]; - if ((!tmpEntry.paused) && (!tmpEntry.markedForDeletion)) tmpEntry.target.update(dt); - } + for(i=0, list=this._updates0List, len=list.length; i * delay is the amount of time the action will wait before it'll start
    *

    + * @deprecated since v3.4 please use .schedule * @param {cc.Class} target * @param {function} callback_fn * @param {Number} interval @@ -411,109 +566,111 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * //register a schedule to scheduler * cc.director.getScheduler().scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning ); */ - scheduleCallbackForTarget:function (target, callback_fn, interval, repeat, delay, paused) { + scheduleCallbackForTarget: function(target, callback_fn, interval, repeat, delay, paused){ + cc.log("scheduleCallbackForTarget is deprecated. Please use schedule."); + this.schedule(callback_fn, target, interval, repeat, delay, paused, target.__instanceId + ""); + }, - cc.assert(callback_fn, cc._LogInfos.Scheduler_scheduleCallbackForTarget_2); + schedule: function(callback, target, interval, repeat, delay, paused, key){ + var isSelector = false; + if(typeof callback != "function"){ + var selector = callback; + isSelector = true; + } - cc.assert(target, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3); + if(isSelector === false){ + //callback, target, interval, repeat, delay, paused, key + //callback, target, interval, paused, key + if(arguments.length === 5){ + key = delay; + paused = repeat; + delay = 0; + repeat = cc.REPEAT_FOREVER; + } + }else{ + //selector, target, interval, repeat, delay, paused + //selector, target, interval, paused + if(arguments.length == 4){ + paused = repeat; + repeat = cc.REPEAT_FOREVER; + delay = 0; + } + } - // default arguments - interval = interval || 0; - repeat = (repeat == null) ? cc.REPEAT_FOREVER : repeat; - delay = delay || 0; - paused = paused || false; + cc.assert(target, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3); + if(isSelector === false) + cc.assert(key, "key should not be empty!"); - var self = this, timer; - var element = self._hashForTimers[target.__instanceId]; + var element = this._hashForTimers[target.__instanceId]; - if (!element) { + if(!element){ // Is this the 1st element ? Then set the pause level to all the callback_fns of this target element = new cc.HashTimerEntry(null, target, 0, null, null, paused, null); - self._arrayForTimers.push(element); - self._hashForTimers[target.__instanceId] = element; + //this._arrayForTimers.push(element); + this._hashForTimers[target.__instanceId] = element; + }else{ + cc.assert(element.paused == paused, ""); } + var timer; if (element.timers == null) { element.timers = []; - } else { + } else if(isSelector === false) { for (var i = 0; i < element.timers.length; i++) { timer = element.timers[i]; - if (callback_fn == timer._callback) { + if (callback == timer._callback) { cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, timer.getInterval().toFixed(4), interval.toFixed(4)); timer._interval = interval; return; } } + }else{ + for (var i = 0; i < element.timers.length; ++i){ + timer =element.timers[i]; + if (timer && selector == timer.getSelector()){ + cc.log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer.getInterval(), interval); + timer.setInterval(interval); + return; + } + } + //ccArrayEnsureExtraCapacity(element->timers, 1); } - timer = new cc.Timer(target, callback_fn, interval, repeat, delay); - element.timers.push(timer); - }, - - /** - *

    - * Schedules the 'update' callback_fn for a given target with a given priority.
    - * The 'update' callback_fn will be called every frame.
    - * The lower the priority, the earlier it is called. - *

    - * @param {cc.Class} target - * @param {Number} priority - * @param {Boolean} paused - * @example - * //register this object to scheduler - * cc.director.getScheduler().scheduleUpdateForTarget(this, priority, !this._isRunning ); - */ - scheduleUpdateForTarget:function (target, priority, paused) { - if(target === null) - return; - var self = this, locUpdates = self._updates; - var hashElement = self._hashForUpdates[target.__instanceId]; - - if (hashElement) { - // TODO: check if priority has changed! - hashElement.entry.markedForDeletion = false; - return; + if(isSelector === false){ + timer = new cc.TimerTargetCallback(); + timer.initWithCallback(this, callback, target, key, interval, repeat, delay); + element.timers.push(timer); + }else{ + timer = new cc.TimerTargetSelector(); + timer.initWithSelector(this, selector, target, interval, repeat, delay); + element.timers.push(timer); } + }, - // most of the updates are going to be 0, that's way there - // is an special list for updates with priority 0 - if (priority == 0) { - self._appendIn(locUpdates[1], target, paused); - } else if (priority < 0) { - locUpdates[0] = self._priorityIn(locUpdates[0], target, priority, paused); - } else { - // priority > 0 - locUpdates[2] = self._priorityIn(locUpdates[2], target, priority, paused); - } + scheduleUpdate: function(target, priority, paused){ + this._schedulePerFrame(function(dt){ + target.update(dt); + }, target, priority, paused); }, - /** - *

    - * Unschedule a callback function for a given target.
    - * If you want to unschedule the "update", use unscheudleUpdateForTarget. - *

    - * @param {cc.Class} target - * @param {function} callback_fn - * @example - * //unschedule a callback of target - * cc.director.getScheduler().unscheduleCallbackForTarget(function, this); - */ - unscheduleCallbackForTarget:function (target, callback_fn) { + unschedule: function(key, target){ + //key, target + //selector, target + // explicity handle nil arguments when removing an object - if ((target == null) || (callback_fn == null)) { + if (!target || !key) return; - } var self = this, element = self._hashForTimers[target.__instanceId]; if (element) { var timers = element.timers; for(var i = 0, li = timers.length; i < li; i++){ var timer = timers[i]; - if (callback_fn == timer._callback) { + if (key == timer.getKey()) { if ((timer == element.currentTimer) && (!element.currentTimerSalvaged)) { element.currentTimerSalvaged = true; } - timers.splice(i, 1) + timers.splice(i, 1); //update timerIndex in case we are in tick;, looping over the actions if (element.timerIndex >= i) { element.timerIndex--; @@ -532,89 +689,122 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ } }, - /** - * Unschedules the update callback function for a given target - * @param {cc.Class} target - * @example - * //unschedules the "update" method. - * cc.director.getScheduler().unscheduleUpdateForTarget(this); - */ - unscheduleUpdateForTarget:function (target) { - if (target == null) { + unscheduleUpdate: function(target){ + if (target == null) return; - } - var self = this, element = self._hashForUpdates[target.__instanceId]; - if (element != null) { - if (self._updateHashLocked) { + var element = this._hashForUpdates[target.__instanceId]; + + if (element){ + if (this._updateHashLocked){ element.entry.markedForDeletion = true; - } else { - self._removeUpdateFromHash(element.entry); + }else{ + this._removeUpdateFromHash(element.entry); } } }, - /** - * Unschedules all function callbacks for a given target. This also includes the "update" callback function. - * @param {cc.Class} target - */ - unscheduleAllCallbacksForTarget:function (target) { - //explicit NULL handling - if (target == null) { + unscheduleAllForTarget: function(target){ + // explicit nullptr handling + if (target == null){ return; } - var self = this, element = self._hashForTimers[target.__instanceId]; - if (element) { - var timers = element.timers; - if ((!element.currentTimerSalvaged) && (timers.indexOf(element.currentTimer) >= 0)) { + // Custom Selectors + var element = this._hashForTimers[target.__instanceId]; + + if (element){ + if (element.timers.indexOf(element.currentTimer) > -1 + && (! element.currentTimerSalvaged)){ element.currentTimerSalvaged = true; } - timers.length = 0; + // ccArrayRemoveAllObjects(element.timers); + element.timers.length = 0; - if (self._currentTarget == element) { - self._currentTargetSalvaged = true; - } else { - self._removeHashElement(element); + if (this._currentTarget == element){ + this._currentTargetSalvaged = true; + }else{ + this._removeHashElement(element); } } - // update callback - self.unscheduleUpdateForTarget(target); + + // update selector + this.unscheduleUpdate(target); }, - /** - *

    - * Unschedules all function callbacks from all targets.
    - * You should NEVER call this method, unless you know what you are doing. - *

    - */ - unscheduleAllCallbacks:function () { - this.unscheduleAllCallbacksWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM); + unscheduleAll: function(){ + this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM); }, - /** - *

    - * Unschedules all function callbacks from all targets with a minimum priority.
    - * You should only call this with kCCPriorityNonSystemMin or higher. - *

    - * @param {Number} minPriority - */ - unscheduleAllCallbacksWithMinPriority:function (minPriority) { + unscheduleAllWithMinPriority: function(minPriority){ // Custom Selectors - var self = this, locArrayForTimers = self._arrayForTimers, locUpdates = self._updates; - for(var i = 0, li = locArrayForTimers.length; i < li; i++){ - // element may be removed in unscheduleAllCallbacksForTarget - self.unscheduleAllCallbacksForTarget(locArrayForTimers[i].target); + var element; + for(var p in this._hashForTimers){ + element = this._hashForTimers[p]; + this.unscheduleAllForTarget(element.target); } - for(var i = 2; i >= 0; i--){ - if((i == 1 && minPriority > 0) || (i == 0 && minPriority >= 0)) continue; - var updates = locUpdates[i]; - for(var j = 0, lj = updates.length; j < lj; j++){ - self.unscheduleUpdateForTarget(updates[j].target); + + // Updates selectors + var entry, i; + if(minPriority < 0){ + for(i=0; i= minPriority){ + this.unscheduleUpdate(entry.target); + } + } + } + } + + if(minPriority <= 0){ + for(i=0; i= minPriority) + { + this.unscheduleUpdate(entry.target); + } } } }, + isScheduled: function(key, target){ + //key, target + //selector, target + cc.assert(key, "Argument key must not be empty"); + cc.assert(target, "Argument target must be non-nullptr"); + + var element = this._hashForUpdates[target.__instanceId]; + + if (!element){ + return false; + } + + if (element.timers == null){ + return false; + }else{ + //todo checking here timers.length + var timers = element.timers; + for (var i = 0; i < timers.length; ++i){ + var timer = timers[i]; + + if (key == timer.getKey()){ + return true; + } + } + return false; + } + }, + /** *

    * Pause all selectors from all targets.
    @@ -733,7 +923,138 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ if (element) { return element.paused; } + var elementUpdate = this._hashForUpdates[target.__instanceId]; + if (elementUpdate) { + return elementUpdate.entry.paused; + } return false; + }, + + /** + *

    + * Schedules the 'update' callback_fn for a given target with a given priority.
    + * The 'update' callback_fn will be called every frame.
    + * The lower the priority, the earlier it is called. + *

    + * @deprecated since v3.4 please use .scheduleUpdate + * @param {cc.Class} target + * @param {Number} priority + * @param {Boolean} paused + * @example + * //register this object to scheduler + * cc.director.getScheduler().scheduleUpdateForTarget(this, priority, !this._isRunning ); + */ + scheduleUpdateForTarget: function(target, priority, paused){ + cc.log("scheduleUpdateForTarget is deprecated. Please use scheduleUpdate."); + this.scheduleUpdate(target, priority, paused); + }, + + /** + *

    + * Unschedule a callback function for a given target.
    + * If you want to unschedule the "update", use unscheudleUpdateForTarget. + *

    + * @deprecated since v3.4 please use .unschedule + * @param {cc.Class} target + * @param {function} callback callback[Function] or key[String] + * @example + * //unschedule a callback of target + * cc.director.getScheduler().unscheduleCallbackForTarget(function, this); + */ + unscheduleCallbackForTarget:function (target, callback) { + cc.log("unscheduleCallbackForTarget is deprecated. Please use unschedule."); + //this.unschedule(callback, target); + // explicity handle nil arguments when removing an object + if ((target == null) || (callback == null)) { + return; + } + + var self = this, element = self._hashForTimers[target.__instanceId]; + if (element) { + var timers = element.timers; + for(var i = 0, li = timers.length; i < li; i++){ + var timer = timers[i]; + if (callback == timer._callback) { + if ((timer == element.currentTimer) && (!element.currentTimerSalvaged)) { + element.currentTimerSalvaged = true; + } + timers.splice(i, 1); + //update timerIndex in case we are in tick;, looping over the actions + if (element.timerIndex >= i) { + element.timerIndex--; + } + + if (timers.length == 0) { + if (self._currentTarget == element) { + self._currentTargetSalvaged = true; + } else { + self._removeHashElement(element); + } + } + return; + } + } + } + }, + + /** + * Unschedules the update callback function for a given target + * @param {cc.Class} target + * @deprecated since v3.4 please use .unschedule + * @example + * //unschedules the "update" method. + * cc.director.getScheduler().unscheduleUpdateForTarget(this); + */ + unscheduleUpdateForTarget:function (target) { + cc.log("unscheduleUpdateForTarget is deprecated. Please use unschedule."); + //this.unschedule(callback, target); + if (target == null) { + return; + } + + var self = this, element = self._hashForUpdates[target.__instanceId]; + if (element != null) { + if (self._updateHashLocked) { + element.entry.markedForDeletion = true; + } else { + self._removeUpdateFromHash(element.entry); + } + } + }, + + /** + * Unschedules all function callbacks for a given target. This also includes the "update" callback function. + * @deprecated since v3.4 please use .unscheduleAll + * @param {cc.Class} target + */ + unscheduleAllCallbacksForTarget: function(target){ + cc.log("unscheduleAllCallbacksForTarget is deprecated. Please use unscheduleAll."); + this.unscheduleAll(); + }, + + /** + *

    + * Unschedules all function callbacks from all targets.
    + * You should NEVER call this method, unless you know what you are doing. + *

    + * @deprecated since v3.4 please use .unscheduleAllWithMinPriority + */ + unscheduleAllCallbacks: function(){ + cc.log("unscheduleAllCallbacks is deprecated. Please use unscheduleAllWithMinPriority."); + this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM); + }, + + /** + *

    + * Unschedules all function callbacks from all targets with a minimum priority.
    + * You should only call this with kCCPriorityNonSystemMin or higher. + *

    + * @deprecated since v3.4 please use .unscheduleAllWithMinPriority + * @param {Number} minPriority + */ + unscheduleAllCallbacksWithMinPriority:function (minPriority) { + cc.log("unscheduleAllCallbacksWithMinPriority is deprecated. Please use unscheduleAllWithMinPriority."); + this.unscheduleAllWithMinPriority(minPriority); } }); /** diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index a82ded43a2..f91b0097f1 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1652,7 +1652,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} priority */ scheduleUpdateWithPriority: function (priority) { - this.scheduler.scheduleUpdateForTarget(this, priority, !this._running); + this.scheduler.scheduleUpdate(this, priority, !this._running); }, /** @@ -1661,39 +1661,86 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @see cc.Node#scheduleUpdate */ unscheduleUpdate: function () { - this.scheduler.unscheduleUpdateForTarget(this); + this.scheduler.unschedule(this.__instanceId, this); }, /** *

    Schedules a custom selector.
    * If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.

    * @function - * @param {function} callback_fn A function wrapped as a selector + * @param {function} callback A function wrapped as a selector * @param {Number} interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead. * @param {Number} repeat The selector will be executed (repeat + 1) times, you can use kCCRepeatForever for tick infinitely. * @param {Number} delay The amount of time that the first tick will wait before execution. - */ - schedule: function (callback_fn, interval, repeat, delay) { - interval = interval || 0; + * @param {String} key The only string identifying the callback + */ + schedule: function (callback, interval, repeat, delay, key) { + var len = arguments.length; + if(typeof callback === "function"){ + //callback, interval, repeat, delay, key + if(len == 1){ + //callback + interval = 0; + repeat = cc.REPEAT_FOREVER; + delay = 0; + key = this.__instanceId; + }else if(len == 2){ + if(typeof interval === "number"){ + //callback, interval + repeat = cc.REPEAT_FOREVER; + delay = 0; + key = this.__instanceId; + }else{ + //callback, key + key = interval; + interval = 0; + repeat = cc.REPEAT_FOREVER; + delay = 0; + } + }else if(len === 3){ + //callback, interval, key + key = repeat; + repeat = cc.REPEAT_FOREVER; + delay = 0; + }else if(len === 4){ + key = this.__instanceId; + } + }else{ + //selector + //selector, interval + //selector, interval, repeat, delay + if(len == 1){ + interval = 0; + repeat = cc.REPEAT_FOREVER; + delay = 0; + }else if(len == 2){ + repeat = cc.REPEAT_FOREVER; + delay = 0; + } + } - cc.assert(callback_fn, cc._LogInfos.Node_schedule); + cc.assert(callback, cc._LogInfos.Node_schedule); cc.assert(interval >= 0, cc._LogInfos.Node_schedule_2); + interval = interval || 0; repeat = (repeat == null) ? cc.REPEAT_FOREVER : repeat; delay = delay || 0; - this.scheduler.scheduleCallbackForTarget(this, callback_fn, interval, repeat, delay, !this._running); + this.scheduler.schedule(callback, this, interval, repeat, delay, !this._running, key); }, /** * Schedules a callback function that runs only once, with a delay of 0 or larger * @function * @see cc.Node#schedule - * @param {function} callback_fn A function wrapped as a selector + * @param {function} callback A function wrapped as a selector * @param {Number} delay The amount of time that the first tick will wait before execution. + * @param {String} key The only string identifying the callback */ - scheduleOnce: function (callback_fn, delay) { - this.schedule(callback_fn, 0.0, 0, delay); + scheduleOnce: function (callback, delay, key) { + //selector, delay + //callback, delay, key + this.schedule(callback, 0, 0, delay, key); }, /** @@ -1703,10 +1750,12 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {function} callback_fn A function wrapped as a selector */ unschedule: function (callback_fn) { + //key + //selector if (!callback_fn) return; - this.scheduler.unscheduleCallbackForTarget(this, callback_fn); + this.scheduler.unschedule(this.__instanceId, callback_fn); }, /** @@ -1715,7 +1764,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @function */ unscheduleAllCallbacks: function () { - this.scheduler.unscheduleAllCallbacksForTarget(this); + this.scheduler.unscheduleAllForTarget(this); }, /** diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index 1068296453..bffb430d5d 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -233,7 +233,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ self._asyncRefCount--; self._asyncCallBack(selector,target, (self._asyncRefTotalCount - self._asyncRefCount) / self._asyncRefTotalCount); }; - cc.director.getScheduler().scheduleCallbackForTarget(this, fun, 0.1, false); + cc.director.getScheduler().schedule(fun, this, 0.1, false, 0, false, "armatrueDataHelper"); }, /** From 801f992c8c9f440be7a1257d79a8c5680a744df6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 27 Feb 2015 13:39:07 +0800 Subject: [PATCH 1367/1564] Issue #2699: fix the bug of sprite about premultiplied. --- CCBoot.js | 3 ++- cocos2d/core/platform/CCTypesWebGL.js | 2 +- cocos2d/core/textures/TexturesWebGL.js | 1 + template/project.json | 4 ++-- template/src/myApp.js | 11 +++++++++++ template/src/resource.js | 1 + 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 11dcd5661b..6d52bd02e6 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1854,7 +1854,8 @@ cc._setup = function (el, width, height) { 'stencil': true, 'preserveDrawingBuffer': true, 'antialias': !cc.sys.isMobile, - 'alpha': false}); + 'alpha': false + }); if (cc._renderContext) { win.gl = cc._renderContext; // global variable declared in CCMacro.js cc._drawingUtil = new cc.DrawingPrimitiveWebGL(cc._renderContext); diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index e9e0151da6..643b973aa1 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -561,7 +561,7 @@ cc._tmp.WebGLColor = function () { //redefine cc.V2F_C4B_T2F /** * @class cc.V2F_C4B_T2F - * @param {new cc.Vertex2F} vertices + * @param {cc.Vertex2F} vertices * @param {cc.color} colors * @param {cc.Tex2F} texCoords * @param {Array} arrayBuffer diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index d26cbe5a57..a62de74fff 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -462,6 +462,7 @@ cc._tmp.WebGLTexture2D = function () { cc.glBindTexture2D(self); gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); // Specify OpenGL texture image gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, self._htmlElementObj); diff --git a/template/project.json b/template/project.json index 6c2c93bd3d..d1a00e8fdd 100644 --- a/template/project.json +++ b/template/project.json @@ -1,7 +1,7 @@ { "debugMode" : 1, - "noCache": true, - "showFPS" : true, + "noCache": false, + "showFPS" : false, "frameRate" : 60, "id" : "gameCanvas", "renderMode" : 0, diff --git a/template/src/myApp.js b/template/src/myApp.js index f91b7c40af..b4258ed20a 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,6 +44,17 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); + + var root = new cc.Node(); + var body = new cc.Sprite("cut_the_hope1.png", cc.rect(827, 775, 143, 134)); + var leg = new cc.Sprite("cut_the_hope1.png", cc.rect(934, 248, 46, 51)); + //leg.setBlendFunc(cc.BlendFunc.ALPHA_PREMULTIPLIED); + + root.addChild(body); + root.addChild(leg); + this.addChild(root); + root.setScale(3); + root.setPosition(size.width/2, size.height/2); } }); diff --git a/template/src/resource.js b/template/src/resource.js index 94284083d1..a70fc7f61b 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -5,6 +5,7 @@ var s_CloseSelected = "CloseSelected.png"; var g_resources = [ //image s_HelloWorld, + "cut_the_hope1.png", s_CloseNormal, s_CloseSelected From cb1fbaf46f6b02b61ec6e885136229ba434478f6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 27 Feb 2015 14:07:20 +0800 Subject: [PATCH 1368/1564] update scheduler cocos2d/cocos2d-js#1316 --- cocos2d/core/base-nodes/CCNode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index f91b0097f1..b9ea1c7502 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1155,7 +1155,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setScheduler: function (scheduler) { if (this._scheduler != scheduler) { - this.unscheduleAllCallbacks(); + this.unscheduleAllWithMinPriority(); this._scheduler = scheduler; } }, @@ -1755,7 +1755,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if (!callback_fn) return; - this.scheduler.unschedule(this.__instanceId, callback_fn); + this.scheduler.unschedule(this.__instanceId, this, callback_fn); }, /** From 5987cbf8652656331260b1ca43aa89a742d64a42 Mon Sep 17 00:00:00 2001 From: IShm Date: Sat, 28 Feb 2015 01:00:42 +0200 Subject: [PATCH 1369/1564] use fullscreenElement for determining on/off fullscreen mode instead of fullscreenEnabled --- cocos2d/core/platform/CCScreen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index 130ebfbafb..c33566b5d4 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -92,7 +92,7 @@ cc.screen = /** @lends cc.screen# */{ } } - this._supportsFullScreen = (this._fn.requestFullscreen != undefined); + this._supportsFullScreen = (this._fn.requestFullscreen != undefined); this._touchEvent = ('ontouchstart' in window) ? 'touchstart' : 'mousedown'; }, @@ -101,7 +101,7 @@ cc.screen = /** @lends cc.screen# */{ * @returns {Boolean} */ fullScreen: function() { - return this._supportsFullScreen && document[ this._fn.fullscreenEnabled ]; + return this._supportsFullScreen && document[this._fn.fullscreenElement]; }, /** From 3eeeae290e4c8e93f9bc582035c7913cb4867cf7 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 28 Feb 2015 10:00:39 +0800 Subject: [PATCH 1370/1564] Issue #2693: implements Gradient color stops --- cocos2d/core/layers/CCLayer.js | 59 ++++++++++++++----- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 2 +- template/project.json | 4 +- template/src/myApp.js | 10 ++++ 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index a072e282a3..a6b2cf7f4e 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -341,19 +341,20 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ * */ ctor: function (start, end, v, stops) { - var _t = this; - cc.LayerColor.prototype.ctor.call(_t); - _t._endColor = cc.color(0, 0, 0, 255); - _t._alongVector = cc.p(0, -1); - _t._startOpacity = 255; - _t._endOpacity = 255; - - if(stops && stops instanceof Array) - _t._colorStops = stops; - else - _t._colorStops = [{p:0, color: start}, {p:1, color: end}]; + cc.LayerColor.prototype.ctor.call(this); + this._endColor = cc.color(0, 0, 0, 255); + this._alongVector = cc.p(0, -1); + this._startOpacity = 255; + this._endOpacity = 255; + + if(stops && stops instanceof Array){ + this._colorStops = stops; + stops.splice(0, 0, {p:0, color: start}); + stops.push({p:1, color: end}); + } else + this._colorStops = [{p:0, color: start}, {p:1, color: end}]; - cc.LayerGradient.prototype.init.call(_t, start, end, v, stops); + cc.LayerGradient.prototype.init.call(this, start, end, v, stops); }, /** @@ -411,7 +412,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ * @return {cc.Color} */ getStartColor: function () { - return this._realColor; + return cc.color(this._realColor); }, /** @@ -424,6 +425,14 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ */ setStartColor: function (color) { this.color = color; + //update the color stops + var stops = this._colorStops; + if(stops && stops.length > 0){ + var selColor = stops[0].color; + selColor.r = color.r; + selColor.g = color.g; + selColor.b = color.b; + } }, /** @@ -435,7 +444,18 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ * //set the ending gradient to red */ setEndColor: function (color) { - this._endColor = color; + var locColor = this._endColor; + locColor.r = color.r; + locColor.g = color.g; + locColor.b = color.b; + //update the color stops + var stops = this._colorStops; + if(stops && stops.length > 0){ + var selColor = stops[stops.length -1].color; + selColor.r = color.r; + selColor.g = color.g; + selColor.b = color.b; + } this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); }, @@ -444,7 +464,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ * @return {cc.Color} */ getEndColor: function () { - return this._endColor; + return cc.color(this._endColor); }, /** @@ -453,6 +473,10 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ */ setStartOpacity: function (o) { this._startOpacity = o; + //update the color stops + var stops = this._colorStops; + if(stops && stops.length > 0) + stops[0].color.a = o; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); }, @@ -470,6 +494,9 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ */ setEndOpacity: function (o) { this._endOpacity = o; + var stops = this._colorStops; + if(stops && stops.length > 0) + stops[stops.length -1].color.a = o; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty); }, @@ -541,8 +568,8 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ * */ setColorStops: function(colorStops){ - this._colorStops = colorStops; + //todo need update the start color and end color this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty|cc.Node._dirtyFlags.gradientDirty); }, diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index afbe414842..e01fc07def 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -426,7 +426,7 @@ this._colorStopsStr = []; for(var i =0; i < node._colorStops.length; i++){ var stopColor = node._colorStops[i].color; - var stopOpacity = stopColor.a/255; + var stopOpacity = stopColor.a == null ? 1 : stopColor.a / 255; this._colorStopsStr.push("rgba(" + Math.round(stopColor.r) + "," + Math.round(stopColor.g) + "," + Math.round(stopColor.b) + "," + stopOpacity.toFixed(4) + ")"); } diff --git a/template/project.json b/template/project.json index 6c2c93bd3d..fbca33527f 100644 --- a/template/project.json +++ b/template/project.json @@ -1,10 +1,10 @@ { "debugMode" : 1, - "noCache": true, + "noCache": false, "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 0, + "renderMode" : 1, "engineDir":"../", "modules" : ["cocos2d"], diff --git a/template/src/myApp.js b/template/src/myApp.js index f91b7c40af..627c735ac3 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,6 +44,16 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); + + var layerGradient = new cc.LayerGradient(cc.color.RED, cc.color.GREEN, cc.p(1,1), + [//{p:0, color: cc.color.RED}, + {p:0.25, color: new cc.Color(0,255,255,128)}, + {p:0.50, color: new cc.Color(255,255,0,128)}, + {p:0.75, color: new cc.Color(255,0,0,128)} + //{p:1, color: cc.color.GREEN} + ]); + this.addChild(layerGradient, 100); + window.gradient = layerGradient; } }); From 523e67c85c5c8480442aeae5800e6491b6316d3a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Sat, 28 Feb 2015 10:08:32 +0800 Subject: [PATCH 1371/1564] Fixed #2701: added getSpriteFrame to cc.Sprite --- cocos2d/core/sprites/CCSprite.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 7bcd41db64..7c891aeb7d 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -875,14 +875,23 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ /** * Returns the current displayed frame. + * @deprecated since 3.4, please use getSpriteFrame instead * @return {cc.SpriteFrame} */ displayFrame: function () { + return this.getSpriteFrame(); + }, + + /** + * Returns the current displayed frame. + * @return {cc.SpriteFrame} + */ + getSpriteFrame: function () { return new cc.SpriteFrame(this._texture, - cc.rectPointsToPixels(this._rect), - this._rectRotated, - cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), - cc.sizePointsToPixels(this._contentSize)); + cc.rectPointsToPixels(this._rect), + this._rectRotated, + cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), + cc.sizePointsToPixels(this._contentSize)); }, /** From 84f7513a7608a35596300042744d12dfa58a7bb1 Mon Sep 17 00:00:00 2001 From: IShm Date: Sat, 28 Feb 2015 04:31:15 +0200 Subject: [PATCH 1372/1564] code formatting --- cocos2d/core/platform/CCScreen.js | 155 +++++++++++++++--------------- 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index c33566b5d4..97452e6e36 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -2,19 +2,19 @@ Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. - + http://www.cocos2d-x.org - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -32,116 +32,119 @@ */ cc.screen = /** @lends cc.screen# */{ _supportsFullScreen: false, - // the pre fullscreenchange function + // the pre fullscreenchange function _preOnFullScreenChange: null, _touchEvent: "", - _fn: null, - // Function mapping for cross browser support - _fnMap: [ - [ - 'requestFullscreen', - 'exitFullscreen', - 'fullscreenchange', - 'fullscreenEnabled', - 'fullscreenElement' - ], - [ - 'requestFullScreen', - 'exitFullScreen', - 'fullScreenchange', - 'fullScreenEnabled', - 'fullScreenElement' - ], - [ - 'webkitRequestFullScreen', - 'webkitCancelFullScreen', - 'webkitfullscreenchange', - 'webkitIsFullScreen', - 'webkitCurrentFullScreenElement' - ], - [ - 'mozRequestFullScreen', - 'mozCancelFullScreen', - 'mozfullscreenchange', - 'mozFullScreen', - 'mozFullScreenElement' - ], - [ - 'msRequestFullscreen', - 'msExitFullscreen', - 'MSFullscreenChange', - 'msFullscreenEnabled', - 'msFullscreenElement' - ] - ], - + _fn: null, + // Function mapping for cross browser support + _fnMap: [ + [ + 'requestFullscreen', + 'exitFullscreen', + 'fullscreenchange', + 'fullscreenEnabled', + 'fullscreenElement' + ], + [ + 'requestFullScreen', + 'exitFullScreen', + 'fullScreenchange', + 'fullScreenEnabled', + 'fullScreenElement' + ], + [ + 'webkitRequestFullScreen', + 'webkitCancelFullScreen', + 'webkitfullscreenchange', + 'webkitIsFullScreen', + 'webkitCurrentFullScreenElement' + ], + [ + 'mozRequestFullScreen', + 'mozCancelFullScreen', + 'mozfullscreenchange', + 'mozFullScreen', + 'mozFullScreenElement' + ], + [ + 'msRequestFullscreen', + 'msExitFullscreen', + 'MSFullscreenChange', + 'msFullscreenEnabled', + 'msFullscreenElement' + ] + ], + /** * initialize * @function */ init: function () { - this._fn = {}; - var i, val, map = this._fnMap, valL; - for (i = 0, l = map.length; i < l; i++ ) { - val = map[ i ]; - if ( val && val[1] in document ) { - for ( i = 0, valL = val.length; i < valL; i++ ) { - this._fn[ map[0][ i ] ] = val[ i ]; - } - break; - } - } + this._fn = {}; + var i, val, map = this._fnMap, valL; + for (i = 0, l = map.length; i < l; i++) { + val = map[i]; + if (val && val[1] in document) { + for (i = 0, valL = val.length; i < valL; i++) { + this._fn[map[0][i]] = val[i]; + } + break; + } + } - this._supportsFullScreen = (this._fn.requestFullscreen != undefined); + this._supportsFullScreen = (typeof this._fn.requestFullscreen !== 'undefined'); this._touchEvent = ('ontouchstart' in window) ? 'touchstart' : 'mousedown'; }, - + /** * return true if it's full now. * @returns {Boolean} */ - fullScreen: function() { - return this._supportsFullScreen && document[this._fn.fullscreenElement]; + fullScreen: function () { + return this._supportsFullScreen && document[this._fn.fullscreenElement]; }, - + /** * change the screen to full mode. * @param {Element} element * @param {Function} onFullScreenChange */ requestFullScreen: function (element, onFullScreenChange) { - if (!this._supportsFullScreen) return; + if (!this._supportsFullScreen) { + return; + } - element = element || document.documentElement; - element[ this._fn.requestFullscreen ](); + element = element || document.documentElement; + element[this._fn.requestFullscreen](); - if (onFullScreenChange) { - var eventName = this._fn.fullscreenchange; - if (this._preOnFullScreenChange) - document.removeEventListener(eventName, this._preOnFullScreenChange); - this._preOnFullScreenChange = onFullScreenChange; + if (onFullScreenChange) { + var eventName = this._fn.fullscreenchange; + if (this._preOnFullScreenChange) { + document.removeEventListener(eventName, this._preOnFullScreenChange); + } + this._preOnFullScreenChange = onFullScreenChange; cc._addEventListener(document, eventName, onFullScreenChange, false); - } + } - return element[ this._fn.requestFullscreen ](); + return element[this._fn.requestFullscreen](); }, - + /** * exit the full mode. * @return {Boolean} */ exitFullScreen: function () { - return this._supportsFullScreen ? document[ this._fn.exitFullscreen ]() : true; + return this._supportsFullScreen ? document[this._fn.exitFullscreen]() : true; }, - + /** * Automatically request full screen with a touch/click event * @param {Element} element * @param {Function} onFullScreenChange */ autoFullScreen: function (element, onFullScreenChange) { - element = element || document.body; - var touchTarget = cc._canvas || element; + element = element || document.body; + var touchTarget = cc._canvas || element; var theScreen = this; // Function bind will be too complicated here because we need the callback function's reference to remove the listener function callback() { From f813a7f0712bc4ad228071585c9935068cf61caa Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Feb 2015 10:40:50 +0800 Subject: [PATCH 1373/1564] Update scheduler; --- cocos2d/core/CCActionManager.js | 2 +- cocos2d/core/CCDirector.js | 2 +- cocos2d/core/CCScheduler.js | 121 ++++++------------ cocos2d/core/base-nodes/CCNode.js | 2 + cocos2d/core/platform/CCInputExtension.js | 4 +- extensions/ccpool/CCPool.js | 2 +- .../cocostudio/action/CCActionObject.js | 4 +- extensions/editbox/CCdomNode.js | 2 +- 8 files changed, 50 insertions(+), 89 deletions(-) diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index 18c2e3900d..ba8c2b499a 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -287,7 +287,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ * because it uses this, so it can not be static */ purgeSharedManager:function () { - cc.director.getScheduler().unscheduleUpdateForTarget(this); + cc.director.getScheduler().scheduleUpdate(this); }, //protected diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index ab18b55675..b9cfbc1437 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -386,7 +386,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ */ purgeDirector: function () { //cleanup scheduler - this.getScheduler().unscheduleAllCallbacks(); + this.getScheduler().unscheduleAll(); // Disable event dispatching if (cc.eventManager) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 6bc4a72b0b..7820616047 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -125,21 +125,18 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ setInterval : function(interval){this._interval = interval;}, setupTimerWithInterval: function(seconds, repeat, delay){ - //todo checking here this._elapsed = -1; this._interval = seconds; this._delay = delay; - this._useDelay = this._delay > 0 ? true : false; + this._useDelay = (this._delay > 0); this._repeat = repeat; - this._runForever = this._repeat == cc.REPEAT_FOREVER ? true : false; + this._runForever = (this._repeat == cc.REPEAT_FOREVER); }, - //todo checking here trigger: function(){ return 0; }, - //todo checking here cancel: function(){ return 0; }, @@ -153,13 +150,8 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ /** * cc.Timer's Constructor * Constructor of cc.Timer - * @param {cc.Class} target target - * @param {String|function} callback Selector - * @param {Number} [interval=0] second - * @param {Number} [repeat=cc.REPEAT_FOREVER] repeat times - * @param {Number} [delay=0] delay */ - ctor:function (target, callback, interval, repeat, delay) { + ctor:function () { this._scheduler = null; this._elapsed = -1; this._runForever = false; @@ -314,32 +306,30 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ _updates0List: null, _updatesPosList: null, + _hashForTimers:null, //Used for "selectors with interval" + //_arrayForTimes:null, //Speed up indexing _hashForUpdates:null, // hash used to fetch quickly the list entries for pause,delete,etc + //_arrayForUpdates:null, //Speed up indexing - _hashForTimers:null, //Used for "selectors with interval" _currentTarget:null, _currentTargetSalvaged:false, _updateHashLocked:false, //If true unschedule will not remove anything from a hash. Elements will only be marked for deletion. - //_arrayForTimes:null, - //_arrayForUpdates:null, ctor:function () { - var self = this; - self._timeScale = 1.0; - //self._updates = [[], [], []]; + this._timeScale = 1.0; this._updatesNegList = []; this._updates0List = []; this._updatesPosList = []; - self._hashForUpdates = {}; - self._hashForTimers = {}; - self._currentTarget = null; - self._currentTargetSalvaged = false; - self._updateHashLocked = false; + this._hashForUpdates = {}; + this._hashForTimers = {}; + this._currentTarget = null; + this._currentTargetSalvaged = false; + this._updateHashLocked = false; - //self._arrayForUpdates = []; - //self._arrayForTimers = []; + //this._arrayForUpdates = []; + //this._arrayForTimers = []; }, @@ -422,8 +412,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ } //update hash entry for quick access - var hashElement = new cc.HashUpdateEntry(ppList, listElement, target, null); - self._hashForUpdates[target.__instanceId] = hashElement; + self._hashForUpdates[target.__instanceId] = new cc.HashUpdateEntry(ppList, listElement, target, null); return ppList; }, @@ -433,8 +422,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ ppList.push(listElement); //update hash entry for quicker access - var hashElement = new cc.HashUpdateEntry(ppList, listElement, target, null, null); - self._hashForUpdates[target.__instanceId] = hashElement; + self._hashForUpdates[target.__instanceId] = new cc.HashUpdateEntry(ppList, listElement, target, null, null); }, //-----------------------public method------------------------- @@ -612,11 +600,11 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ cc.assert(element.paused == paused, ""); } - var timer; + var timer, i; if (element.timers == null) { element.timers = []; } else if(isSelector === false) { - for (var i = 0; i < element.timers.length; i++) { + for (i = 0; i < element.timers.length; i++) { timer = element.timers[i]; if (callback == timer._callback) { cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, timer.getInterval().toFixed(4), interval.toFixed(4)); @@ -625,7 +613,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ } } }else{ - for (var i = 0; i < element.timers.length; ++i){ + for (i = 0; i < element.timers.length; ++i){ timer =element.timers[i]; if (timer && selector == timer.getSelector()){ cc.log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer.getInterval(), interval); @@ -653,9 +641,22 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ }, target, priority, paused); }, + _getUnscheduleMark: function(key, timer){ + //key, callback, selector + switch (typeof key){ + case "number": + case "string": + return key == timer.getKey(); + case "function": + return key == timer._callback; + default: + return key == timer.getSelector(); + } + }, unschedule: function(key, target){ //key, target //selector, target + //callback, target - This is in order to increase compatibility // explicity handle nil arguments when removing an object if (!target || !key) @@ -666,7 +667,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ var timers = element.timers; for(var i = 0, li = timers.length; i < li; i++){ var timer = timers[i]; - if (key == timer.getKey()) { + if (this._getUnscheduleMark(key, timer)) { if ((timer == element.currentTimer) && (!element.currentTimerSalvaged)) { element.currentTimerSalvaged = true; } @@ -824,15 +825,16 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ var idsWithSelectors = []; var self = this, element, locArrayForTimers = self._arrayForTimers, locUpdates = self._updates; + var i, li; // Custom Selectors - for(var i = 0, li = locArrayForTimers.length; i < li; i++){ + for(i = 0, li = locArrayForTimers.length; i < li; i++){ element = locArrayForTimers[i]; if (element) { element.paused = true; idsWithSelectors.push(element.target); } } - for(var i = 0, li = locUpdates.length; i < li; i++){ + for(i = 0, li = locUpdates.length; i < li; i++){ var updates = locUpdates[i]; for(var j = 0, lj = updates.length; j < lj; j++){ element = updates[j]; @@ -963,38 +965,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ */ unscheduleCallbackForTarget:function (target, callback) { cc.log("unscheduleCallbackForTarget is deprecated. Please use unschedule."); - //this.unschedule(callback, target); - // explicity handle nil arguments when removing an object - if ((target == null) || (callback == null)) { - return; - } - - var self = this, element = self._hashForTimers[target.__instanceId]; - if (element) { - var timers = element.timers; - for(var i = 0, li = timers.length; i < li; i++){ - var timer = timers[i]; - if (callback == timer._callback) { - if ((timer == element.currentTimer) && (!element.currentTimerSalvaged)) { - element.currentTimerSalvaged = true; - } - timers.splice(i, 1); - //update timerIndex in case we are in tick;, looping over the actions - if (element.timerIndex >= i) { - element.timerIndex--; - } - - if (timers.length == 0) { - if (self._currentTarget == element) { - self._currentTargetSalvaged = true; - } else { - self._removeHashElement(element); - } - } - return; - } - } - } + this.unschedule(callback, target); }, /** @@ -1007,19 +978,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ */ unscheduleUpdateForTarget:function (target) { cc.log("unscheduleUpdateForTarget is deprecated. Please use unschedule."); - //this.unschedule(callback, target); - if (target == null) { - return; - } - - var self = this, element = self._hashForUpdates[target.__instanceId]; - if (element != null) { - if (self._updateHashLocked) { - element.entry.markedForDeletion = true; - } else { - self._removeUpdateFromHash(element.entry); - } - } + this.unscheduleUpdate(target); }, /** @@ -1029,7 +988,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ */ unscheduleAllCallbacksForTarget: function(target){ cc.log("unscheduleAllCallbacksForTarget is deprecated. Please use unscheduleAll."); - this.unscheduleAll(); + this.unschedule(target.__instanceId + "", target); }, /** @@ -1040,7 +999,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * @deprecated since v3.4 please use .unscheduleAllWithMinPriority */ unscheduleAllCallbacks: function(){ - cc.log("unscheduleAllCallbacks is deprecated. Please use unscheduleAllWithMinPriority."); + cc.log("unscheduleAllCallbacks is deprecated. Please use unscheduleAll."); this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM); }, diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b9ea1c7502..0e869aad9c 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1740,6 +1740,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ scheduleOnce: function (callback, delay, key) { //selector, delay //callback, delay, key + if(key == undefined) + key = this.__instanceId; this.schedule(callback, 0, 0, delay, key); }, diff --git a/cocos2d/core/platform/CCInputExtension.js b/cocos2d/core/platform/CCInputExtension.js index 1d6c49bbcd..3c13edfcd0 100644 --- a/cocos2d/core/platform/CCInputExtension.js +++ b/cocos2d/core/platform/CCInputExtension.js @@ -39,10 +39,10 @@ _p.setAccelerometerEnabled = function(isEnable){ var scheduler = cc.director.getScheduler(); if(_t._accelEnabled){ _t._accelCurTime = 0; - scheduler.scheduleUpdateForTarget(_t); + scheduler.scheduleUpdate(_t); } else { _t._accelCurTime = 0; - scheduler.unscheduleUpdateForTarget(_t); + scheduler.scheduleUpdate(_t); } }; diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 4121439db4..8c930642c3 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -52,7 +52,7 @@ cc.pool = /** @lends cc.pool# */{ _autoRelease: function (obj) { var running = obj._running === undefined ? false : !obj._running; - cc.director.getScheduler().scheduleCallbackForTarget(obj, this._releaseCB, 0, 0, 0, running) + cc.director.getScheduler().schedule(this._releaseCB, obj, 0, 0, 0, running) }, /** diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js index 15e0c200d4..7c0ca0c9eb 100644 --- a/extensions/cocostudio/action/CCActionObject.js +++ b/extensions/cocostudio/action/CCActionObject.js @@ -200,7 +200,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ locActionNodeList[i].playAction(fun); } if (this._loop) - this._scheduler.scheduleCallbackForTarget(this, this.simulationActionUpdate, 0, cc.REPEAT_FOREVER, 0, false); + this._scheduler.schedule(this.simulationActionUpdate, this, 0, cc.REPEAT_FOREVER, 0, false, this.__instanceId + ""); if(fun !== undefined) this._callback = fun; }, @@ -220,7 +220,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ var locActionNodeList = this._actionNodeList; for (var i = 0; i < locActionNodeList.length; i++) locActionNodeList[i].stopAction(); - this._scheduler.unscheduleCallbackForTarget(this, this.simulationActionUpdate); + this._scheduler.unschedule(this.simulationActionUpdate, this); this._pause = false; this._playing = false; }, diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index fb62932ed3..a9b6a09c45 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -391,7 +391,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ cleanup:function () { // actions this.stopAllActions(); - this.unscheduleAllCallbacks(); + this.unscheduleAll(); // timers this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.cleanup); From d3ad9484a4ee3ec2f4b1ab68073957ce54389848 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Feb 2015 13:39:53 +0800 Subject: [PATCH 1374/1564] Speed up indexing --- cocos2d/core/CCScheduler.js | 73 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 7820616047..c7a20bc6ff 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -111,10 +111,6 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ _delay:0, _interval:0.0, - //_callback:null,//is called _callback before - //_target:null,//target of _callback - - /** * @return {Number} returns interval of timer */ @@ -141,12 +137,6 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ return 0; }, - /** - * @return {String|function} returns callback - */ - //getCallback : function(){return this._callback}, - - /** * cc.Timer's Constructor * Constructor of cc.Timer @@ -250,7 +240,6 @@ cc.TimerTargetCallback = cc.Timer.extend({ }, initWithCallback: function(scheduler, callback, target, key, seconds, repeat, delay){ - //todo checking here this._scheduler = scheduler; this._target = target; this._callback = callback; @@ -307,7 +296,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ _updatesPosList: null, _hashForTimers:null, //Used for "selectors with interval" - //_arrayForTimes:null, //Speed up indexing + _arrayForTimers:null, //Speed up indexing _hashForUpdates:null, // hash used to fetch quickly the list entries for pause,delete,etc //_arrayForUpdates:null, //Speed up indexing @@ -328,15 +317,14 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ this._currentTargetSalvaged = false; this._updateHashLocked = false; + this._arrayForTimers = []; //this._arrayForUpdates = []; - //this._arrayForTimers = []; }, //-----------------------private method---------------------- _schedulePerFrame: function(callback, target, priority, paused){ - //todo var hashElement = this._hashForUpdates[target.__instanceId]; if (hashElement){ // check if priority has changed @@ -371,7 +359,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ _removeHashElement:function (element) { delete this._hashForTimers[element.target.__instanceId]; - //cc.arrayRemoveObject(this._arrayForTimers, element); + cc.arrayRemoveObject(this._arrayForTimers, element); element.Timer = null; element.target = null; element = null; @@ -384,7 +372,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ cc.arrayRemoveObject(element.list, element.entry); delete self._hashForUpdates[element.target.__instanceId]; - cc.arrayRemoveObject(self._hashForUpdates, element); + //cc.arrayRemoveObject(self._hashForUpdates, element); element.entry = null; //hash entry @@ -478,9 +466,9 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ } // Iterate over all the custom selectors - var elt; - for (var p in this._hashForTimers){ - elt = this._hashForTimers[p]; + var elt, arr = this._arrayForTimers; + for(i=0; i= minPriority){ + element.paused = true; + idsWithSelectors.push(element.target); + } + } + } + } + + if(minPriority <= 0){ + for(i=0; i= minPriority){ + element.paused = true; + idsWithSelectors.push(element.target); + } + } + } + return idsWithSelectors; }, From 2a964f93a35160971ffbf2be83b4b8757bd79595 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Feb 2015 14:58:09 +0800 Subject: [PATCH 1375/1564] Maybe the black screen of 8.1.2 after adaptation --- cocos2d/core/platform/CCEGLView.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 78184ce5c5..fd5cfe2aa3 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -54,10 +54,13 @@ cc.__BrowserGetter = { meta: { "width": "device-width", "user-scalable": "no" - } + }, + adaptationType: cc.sys.browserType }; +if(window.navigator.userAgent.indexOf("OS 8_1_2") > -1) + cc.__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_MIUI; -switch(cc.sys.browserType){ +switch(cc.__BrowserGetter.adaptationType){ case cc.sys.BROWSER_TYPE_SAFARI: cc.__BrowserGetter.meta["minimal-ui"] = "true"; cc.__BrowserGetter.availWidth = function(frame){ From 8e8357a4e0440f4f08c643031b4259c7cf5975c3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Feb 2015 15:41:32 +0800 Subject: [PATCH 1376/1564] Added note --- cocos2d/core/platform/CCEGLView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index fd5cfe2aa3..271033a5af 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -57,7 +57,8 @@ cc.__BrowserGetter = { }, adaptationType: cc.sys.browserType }; -if(window.navigator.userAgent.indexOf("OS 8_1_2") > -1) + +if(window.navigator.userAgent.indexOf("OS 8_1_2") > -1) //this mistake like MIUI, so use of MIUI treatment method cc.__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_MIUI; switch(cc.__BrowserGetter.adaptationType){ From 376ff5e6c00dbb50c66bc11f6c2811a630064a87 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Feb 2015 16:06:41 +0800 Subject: [PATCH 1377/1564] Fixed - Call error --- cocos2d/core/CCActionManager.js | 2 +- cocos2d/core/base-nodes/CCNode.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index ba8c2b499a..aeade2fe6e 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -287,7 +287,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ * because it uses this, so it can not be static */ purgeSharedManager:function () { - cc.director.getScheduler().scheduleUpdate(this); + cc.director.getScheduler().unscheduleUpdate(this); }, //protected diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 0e869aad9c..b83d29e7ec 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1155,7 +1155,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setScheduler: function (scheduler) { if (this._scheduler != scheduler) { - this.unscheduleAllWithMinPriority(); + this.unscheduleAll(); this._scheduler = scheduler; } }, @@ -1661,7 +1661,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @see cc.Node#scheduleUpdate */ unscheduleUpdate: function () { - this.scheduler.unschedule(this.__instanceId, this); + this.scheduler.unscheduleUpdate(this); }, /** From 8338e63936fee91073cd0df82e98c8eab91322fe Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 2 Mar 2015 11:25:54 +0800 Subject: [PATCH 1378/1564] Issue #1498: bug on cc.isObject --- CCBoot.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 11dcd5661b..98e933bc8f 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -141,7 +141,8 @@ cc.isString = function(obj) { * @returns {boolean} */ cc.isArray = function(obj) { - return Object.prototype.toString.call(obj) == '[object Array]'; + return Array.isArray(obj) || + (typeof obj === 'object' && objectToString(obj) === '[object Array]'); }; /** @@ -150,7 +151,7 @@ cc.isArray = function(obj) { * @returns {boolean} */ cc.isUndefined = function(obj) { - return typeof obj == 'undefined'; + return typeof obj === 'undefined'; }; /** @@ -159,9 +160,7 @@ cc.isUndefined = function(obj) { * @returns {boolean} */ cc.isObject = function(obj) { - var type = typeof obj; - - return type == 'function' || (obj && type == 'object'); + return typeof obj === "object" && Object.prototype.toString.call(obj) === '[object Object]'; }; /** From d7d507f91db15e7907c2c54b7246222f2ce0e43b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 2 Mar 2015 11:31:05 +0800 Subject: [PATCH 1379/1564] Issue #1498: bug on cc.isObject --- CCBoot.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 11dcd5661b..98e933bc8f 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -141,7 +141,8 @@ cc.isString = function(obj) { * @returns {boolean} */ cc.isArray = function(obj) { - return Object.prototype.toString.call(obj) == '[object Array]'; + return Array.isArray(obj) || + (typeof obj === 'object' && objectToString(obj) === '[object Array]'); }; /** @@ -150,7 +151,7 @@ cc.isArray = function(obj) { * @returns {boolean} */ cc.isUndefined = function(obj) { - return typeof obj == 'undefined'; + return typeof obj === 'undefined'; }; /** @@ -159,9 +160,7 @@ cc.isUndefined = function(obj) { * @returns {boolean} */ cc.isObject = function(obj) { - var type = typeof obj; - - return type == 'function' || (obj && type == 'object'); + return typeof obj === "object" && Object.prototype.toString.call(obj) === '[object Object]'; }; /** From 653452095feb6efb4a2091a16a9f58acabe0afda Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 2 Mar 2015 11:39:11 +0800 Subject: [PATCH 1380/1564] Issue #1498: bug on cc.isObject --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 98e933bc8f..aca8a3b6f2 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -142,7 +142,7 @@ cc.isString = function(obj) { */ cc.isArray = function(obj) { return Array.isArray(obj) || - (typeof obj === 'object' && objectToString(obj) === '[object Array]'); + (typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object Array]'); }; /** From 2b6809fb7f5eaec961d0949f2e1099a781a3e4ed Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 2 Mar 2015 13:39:39 +0800 Subject: [PATCH 1381/1564] cc.TMXObjectGroup.prototype.objectNamed in JSB --- cocos2d/tilemap/CCTMXObjectGroup.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js index ddeb400080..7cd3267c21 100644 --- a/cocos2d/tilemap/CCTMXObjectGroup.js +++ b/cocos2d/tilemap/CCTMXObjectGroup.js @@ -116,6 +116,16 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ * @return {object|Null} */ objectNamed:function (objectName) { + this.getObject(objectName); + }, + + /** + *

    Return the dictionary for the specific object name.
    + * It will return the 1st object found on the array for the given name.

    + * @param {String} objectName + * @return {object|Null} + */ + getObject: function(objectName){ if (this._objects && this._objects.length > 0) { var locObjects = this._objects; for (var i = 0, len = locObjects.length; i < len; i++) { From 868ee3d9462e06db4f9308a70d60fd4ae8bd9f4d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 2 Mar 2015 14:36:13 +0800 Subject: [PATCH 1382/1564] cc.TMXObjectGroup.prototype.objectNamed in JSB --- cocos2d/tilemap/CCTMXObjectGroup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js index 7cd3267c21..7bfcafbe32 100644 --- a/cocos2d/tilemap/CCTMXObjectGroup.js +++ b/cocos2d/tilemap/CCTMXObjectGroup.js @@ -112,6 +112,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ /** *

    Return the dictionary for the specific object name.
    * It will return the 1st object found on the array for the given name.

    + * @deprecated since v3.4 please use .getObject * @param {String} objectName * @return {object|Null} */ From 161afd07449280573947dc6bf3224247ebe8a9d0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 2 Mar 2015 15:46:06 +0800 Subject: [PATCH 1383/1564] Maybe the black screen of 8.1.3 after adaptation --- cocos2d/core/platform/CCEGLView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 271033a5af..e5be3e63b5 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -58,7 +58,7 @@ cc.__BrowserGetter = { adaptationType: cc.sys.browserType }; -if(window.navigator.userAgent.indexOf("OS 8_1_2") > -1) //this mistake like MIUI, so use of MIUI treatment method +if(window.navigator.userAgent.indexOf("OS 8_1_") > -1) //this mistake like MIUI, so use of MIUI treatment method cc.__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_MIUI; switch(cc.__BrowserGetter.adaptationType){ From 936651b64728b8f5ba3d381aeca93a6d9c9be767 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 3 Mar 2015 14:01:06 +0800 Subject: [PATCH 1384/1564] audioEngine not playing in Firefox, using minified/compiled lib --- cocos2d/audio/CCAudio.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 4c4b565d32..de28710216 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -32,6 +32,7 @@ * auto : Supports auto-play audio - if Don‘t support it, On a touch detecting background music canvas, and then replay * replay : The first music will fail, must be replay after touchstart * emptied : Whether to use the emptied event to replace load callback + * delay : delay created the context object - only webAudio * * May be modifications for a few browser version */ @@ -48,7 +49,7 @@ // ANDROID // supportTable[sys.BROWSER_TYPE_ANDROID] = {multichannel: false, webAudio: false, auto: false}; supportTable[sys.BROWSER_TYPE_CHROME] = {multichannel: true , webAudio: true , auto: false}; - supportTable[sys.BROWSER_TYPE_FIREFOX] = {multichannel: true , webAudio: true , auto: true }; + supportTable[sys.BROWSER_TYPE_FIREFOX] = {multichannel: true , webAudio: true , auto: true , delay: true}; supportTable[sys.BROWSER_TYPE_UC] = {multichannel: true , webAudio: false, auto: false}; supportTable[sys.BROWSER_TYPE_QQ] = {multichannel: false, webAudio: false, auto: true }; supportTable[sys.BROWSER_TYPE_OUPENG] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; @@ -476,6 +477,8 @@ cc.Audio = cc.Class.extend({ try{ if(SWA){ var context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); + if(polyfill.delay) + setTimeout(function(){ context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); }, 0); } }catch(error){ SWA = false; From 30764bc4b89d270aef9dca0cc52c8d401a579466 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 3 Mar 2015 17:40:24 +0800 Subject: [PATCH 1385/1564] Fixed #2693: Add color stops to cc.LayerGradient on WebGL and fixed a bug of cc.LayerGradientRenderCmd --- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 16 +- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 143 +++++++++++++----- cocos2d/core/support/CCPointExtension.js | 2 +- template/project.json | 2 +- template/src/myApp.js | 10 -- 5 files changed, 115 insertions(+), 58 deletions(-) diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index e01fc07def..cfa224148d 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -404,13 +404,18 @@ proto._updateColor = function(){ var node = this._node; var contentSize = node._contentSize; - var locAlongVector = node._alongVector, tWidth = contentSize.width * 0.5, tHeight = contentSize.height * 0.5; + var tWidth = contentSize.width * 0.5, tHeight = contentSize.height * 0.5; this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty ^ this._dirtyFlag; - this._startPoint.x = tWidth * (-locAlongVector.x) + tWidth; - this._startPoint.y = tHeight * locAlongVector.y - tHeight; - this._endPoint.x = tWidth * locAlongVector.x + tWidth; - this._endPoint.y = tHeight * (-locAlongVector.y) - tHeight; + //fix the bug of gradient layer + var angle = cc.pAngleSigned(cc.p(0, -1), node._alongVector); + var p1 = cc.pRotateByAngle(cc.p(0, -1), cc.p(0,0), angle); + var factor = Math.min(Math.abs(1 / p1.x), Math.abs(1/ p1.y)); + + this._startPoint.x = tWidth * (-p1.x * factor) + tWidth; + this._startPoint.y = tHeight * (p1.y * factor) - tHeight; + this._endPoint.x = tWidth * (p1.x * factor) + tWidth; + this._endPoint.y = tHeight * (-p1.y * factor) - tHeight; var locStartColor = this._displayedColor, locEndColor = node._endColor; var startOpacity = node._startOpacity/255, endOpacity = node._endOpacity/255; @@ -431,6 +436,5 @@ + Math.round(stopColor.b) + "," + stopOpacity.toFixed(4) + ")"); } } - }; })(); \ No newline at end of file diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index 85e90b33dd..812c6d9394 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -75,7 +75,7 @@ var proto = cc.LayerColor.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype); proto.constructor = cc.LayerColor.WebGLRenderCmd; - cc.LayerColor.WebGLRenderCmd.prototype.rendering = function (ctx) { + proto.rendering = function (ctx) { var context = ctx || cc._renderContext; var node = this._node; @@ -93,7 +93,7 @@ context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); - context.drawArrays(context.TRIANGLE_STRIP, 0, 4); + context.drawArrays(context.TRIANGLE_STRIP, 0, this._squareVertices.length); }; proto._updateSquareVertices = function(size, height){ @@ -160,6 +160,8 @@ cc.LayerGradient.WebGLRenderCmd = function(renderable){ cc.LayerColor.WebGLRenderCmd.call(this, renderable); this._needDraw = true; + this._clipRect = new cc.Rect(); + this._clippingRectDirty = false; }; var proto = cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype); cc.inject(cc.LayerGradient.RenderCmd, proto); @@ -201,48 +203,109 @@ proto._updateColor = function(){ this._dirtyFlag = this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty ^ this._dirtyFlag; - var _t = this, node = this._node; - var locAlongVector = node._alongVector; - var h = cc.pLength(locAlongVector); - if (h === 0) + var node = this._node, stops = node._colorStops; + if(!stops || stops.length < 2) return; - var c = Math.sqrt(2.0), u = cc.p(locAlongVector.x / h, locAlongVector.y / h); + this._clippingRectDirty = true; + var stopsLen = stops.length, verticesLen = stopsLen * 2, i, contentSize = node._contentSize; + this._squareVerticesAB = new ArrayBuffer(verticesLen * 8); + this._squareColorsAB = new ArrayBuffer(verticesLen * 4); + var locVertices = this._squareVertices, locColors = this._squareColors; + locVertices.length = 0; + locColors.length = 0; - // Compressed Interpolation mode - if (node._compressedInterpolation) { - var h2 = 1 / ( Math.abs(u.x) + Math.abs(u.y) ); - u = cc.pMult(u, h2 * c); + var locSquareVerticesAB = this._squareVerticesAB, locSquareColorsAB = this._squareColorsAB; + var locVertex2FLen = cc.Vertex2F.BYTES_PER_ELEMENT, locColorLen = cc.Color.BYTES_PER_ELEMENT; + for(i = 0; i < verticesLen; i++){ + locVertices.push(new cc.Vertex2F(0, 0, locSquareVerticesAB, locVertex2FLen * i)); + locColors.push(cc.color(0, 0, 0, 255, locSquareColorsAB, locColorLen * i)) + } + + //init vertex + var angle = Math.PI + cc.pAngleSigned(cc.p(0, -1), node._alongVector), locAnchor = cc.p(contentSize.width/2, contentSize.height /2); + var degrees = Math.round(cc.radiansToDegrees(angle)); + var transMat = cc.affineTransformMake(1, 0, 0, 1, locAnchor.x, locAnchor.y); + transMat = cc.affineTransformRotate(transMat, angle); + var a, b; + if(degrees < 90) { + a = cc.p(-locAnchor.x, locAnchor.y); + b = cc.p(locAnchor.x, locAnchor.y); + } else if(degrees < 180) { + a = cc.p(locAnchor.x, locAnchor.y); + b = cc.p(locAnchor.x, -locAnchor.y); + } else if(degrees < 270) { + a = cc.p(locAnchor.x, -locAnchor.y); + b = cc.p(-locAnchor.x, -locAnchor.y); + } else { + a = cc.p(-locAnchor.x, -locAnchor.y); + b = cc.p(-locAnchor.x, locAnchor.y); + } + + var sin = Math.sin(angle), cos = Math.cos(angle); + var tx = Math.abs((a.x * cos - a.y * sin)/locAnchor.x), ty = Math.abs((b.x * sin + b.y * cos)/locAnchor.y); + transMat = cc.affineTransformScale(transMat, tx, ty); + for (i = 0; i < stopsLen; i++) { + var stop = stops[i], y = stop.p * contentSize.height ; + var p0 = cc._pointApplyAffineTransform(- locAnchor.x , y - locAnchor.y, transMat); + locVertices[i * 2].x = p0.x; + locVertices[i * 2].y = p0.y; + var p1 = cc._pointApplyAffineTransform(contentSize.width - locAnchor.x, y - locAnchor.y, transMat); + locVertices[i * 2 + 1].x = p1.x; + locVertices[i * 2 + 1].y = p1.y; + } + + //init color + var opacityf = this._displayedOpacity / 255.0; //, displayColor = this._displayedColor; + for(i = 0; i < stopsLen; i++){ + var stopColor = stops[i].color, locSquareColor0 = locColors[i * 2], locSquareColor1 = locColors[i * 2 + 1]; + locSquareColor0.r = stopColor.r; + locSquareColor0.g = stopColor.g; + locSquareColor0.b = stopColor.b; + locSquareColor0.a = stopColor.a * opacityf; + + locSquareColor1.r = stopColor.r; + locSquareColor1.g = stopColor.g; + locSquareColor1.b = stopColor.b; + locSquareColor1.a = stopColor.a * opacityf; } + this._bindLayerVerticesBufferData(); + this._bindLayerColorsBufferData(); + }; + + proto.rendering = function (ctx) { + var context = ctx || cc._renderContext, node = this._node; + + //it is too expensive to use stencil to clip, so it use Scissor, + //but it has a bug when layer rotated and layer's content size less than canvas's size. + var clippingRect = this._getClippingRect(); + context.enable(context.SCISSOR_TEST); + cc.view.setScissorInPoints(clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height); + + //draw gradient layer + this._shaderProgram.use(); + this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); + cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR); + cc.glBlendFunc(node._blendFunc.src, node._blendFunc.dst); + // + // Attributes + // + context.bindBuffer(context.ARRAY_BUFFER, this._verticesFloat32Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, context.FLOAT, false, 0, 0); + context.bindBuffer(context.ARRAY_BUFFER, this._colorsUint8Buffer); + context.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, context.UNSIGNED_BYTE, true, 0, 0); + context.drawArrays(context.TRIANGLE_STRIP, 0, this._squareVertices.length); - var opacityf = _t._displayedOpacity / 255.0; - var locDisplayedColor = _t._displayedColor, locEndColor = node._endColor; - var S = { r: locDisplayedColor.r, g: locDisplayedColor.g, b: locDisplayedColor.b, a: node._startOpacity * opacityf}; - var E = {r: locEndColor.r, g: locEndColor.g, b: locEndColor.b, a: node._endOpacity * opacityf}; - - // (-1, -1) - var locSquareColors = _t._squareColors; - var locSquareColor0 = locSquareColors[0], locSquareColor1 = locSquareColors[1], locSquareColor2 = locSquareColors[2], locSquareColor3 = locSquareColors[3]; - locSquareColor0.r = ((E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.g = ((E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.b = ((E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0 * c)))); - locSquareColor0.a = ((E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0 * c)))); - // (1, -1) - locSquareColor1.r = ((E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.g = ((E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.b = ((E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0 * c)))); - locSquareColor1.a = ((E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0 * c)))); - // (-1, 1) - locSquareColor2.r = ((E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.g = ((E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.b = ((E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0 * c)))); - locSquareColor2.a = ((E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0 * c)))); - // (1, 1) - locSquareColor3.r = ((E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.g = ((E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.b = ((E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0 * c)))); - locSquareColor3.a = ((E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0 * c)))); - - _t._bindLayerColorsBufferData(); + context.disable(context.SCISSOR_TEST); + }; + + proto._getClippingRect = function(){ + if(this._clippingRectDirty){ + var node = this._node; + var rect = cc.rect(0, 0, node._contentSize.width, node._contentSize.height); + var trans = node.getNodeToWorldTransform(); + this._clipRect = cc._rectApplyAffineTransformIn(rect, trans); + } + return this._clipRect; }; })(); \ No newline at end of file diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/support/CCPointExtension.js index db74da1001..cf74e24b79 100644 --- a/cocos2d/core/support/CCPointExtension.js +++ b/cocos2d/core/support/CCPointExtension.js @@ -507,7 +507,7 @@ cc.pAddIn = function(v1, v2) { /** * normalizes the point (inplace) - * @param {cc.Point{ v + * @param {cc.Point} v */ cc.pNormalizeIn = function(v) { cc.pMultIn(v, 1.0 / Math.sqrt(v.x * v.x + v.y * v.y)); diff --git a/template/project.json b/template/project.json index fbca33527f..a4a9435aab 100644 --- a/template/project.json +++ b/template/project.json @@ -4,7 +4,7 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 1, + "renderMode" : 0, "engineDir":"../", "modules" : ["cocos2d"], diff --git a/template/src/myApp.js b/template/src/myApp.js index 627c735ac3..f91b7c40af 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,16 +44,6 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); - - var layerGradient = new cc.LayerGradient(cc.color.RED, cc.color.GREEN, cc.p(1,1), - [//{p:0, color: cc.color.RED}, - {p:0.25, color: new cc.Color(0,255,255,128)}, - {p:0.50, color: new cc.Color(255,255,0,128)}, - {p:0.75, color: new cc.Color(255,0,0,128)} - //{p:1, color: cc.color.GREEN} - ]); - this.addChild(layerGradient, 100); - window.gradient = layerGradient; } }); From 169f117d3a18f121402a2ed2295aca56b3a4510b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 3 Mar 2015 17:52:30 +0800 Subject: [PATCH 1386/1564] update scheduler cocos2d/cocos2d-js#1316 --- cocos2d/core/CCScheduler.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index c7a20bc6ff..510b21735b 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -543,7 +543,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * cc.director.getScheduler().scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning ); */ scheduleCallbackForTarget: function(target, callback_fn, interval, repeat, delay, paused){ - cc.log("scheduleCallbackForTarget is deprecated. Please use schedule."); + //cc.log("scheduleCallbackForTarget is deprecated. Please use schedule."); this.schedule(callback_fn, target, interval, repeat, delay, paused, target.__instanceId + ""); }, @@ -958,7 +958,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * cc.director.getScheduler().scheduleUpdateForTarget(this, priority, !this._isRunning ); */ scheduleUpdateForTarget: function(target, priority, paused){ - cc.log("scheduleUpdateForTarget is deprecated. Please use scheduleUpdate."); + //cc.log("scheduleUpdateForTarget is deprecated. Please use scheduleUpdate."); this.scheduleUpdate(target, priority, paused); }, @@ -975,7 +975,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * cc.director.getScheduler().unscheduleCallbackForTarget(function, this); */ unscheduleCallbackForTarget:function (target, callback) { - cc.log("unscheduleCallbackForTarget is deprecated. Please use unschedule."); + //cc.log("unscheduleCallbackForTarget is deprecated. Please use unschedule."); this.unschedule(callback, target); }, @@ -988,7 +988,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * cc.director.getScheduler().unscheduleUpdateForTarget(this); */ unscheduleUpdateForTarget:function (target) { - cc.log("unscheduleUpdateForTarget is deprecated. Please use unschedule."); + //cc.log("unscheduleUpdateForTarget is deprecated. Please use unschedule."); this.unscheduleUpdate(target); }, @@ -998,7 +998,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * @param {cc.Class} target */ unscheduleAllCallbacksForTarget: function(target){ - cc.log("unscheduleAllCallbacksForTarget is deprecated. Please use unscheduleAll."); + //cc.log("unscheduleAllCallbacksForTarget is deprecated. Please use unscheduleAll."); this.unschedule(target.__instanceId + "", target); }, @@ -1010,7 +1010,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * @deprecated since v3.4 please use .unscheduleAllWithMinPriority */ unscheduleAllCallbacks: function(){ - cc.log("unscheduleAllCallbacks is deprecated. Please use unscheduleAll."); + //cc.log("unscheduleAllCallbacks is deprecated. Please use unscheduleAll."); this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM); }, @@ -1023,7 +1023,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ * @param {Number} minPriority */ unscheduleAllCallbacksWithMinPriority:function (minPriority) { - cc.log("unscheduleAllCallbacksWithMinPriority is deprecated. Please use unscheduleAllWithMinPriority."); + //cc.log("unscheduleAllCallbacksWithMinPriority is deprecated. Please use unscheduleAllWithMinPriority."); this.unscheduleAllWithMinPriority(minPriority); } }); From d129bf4791ac020eebcc538e54d2d3dabc237b6f Mon Sep 17 00:00:00 2001 From: Igor Shmulyan Date: Tue, 3 Mar 2015 15:06:34 +0200 Subject: [PATCH 1387/1564] removed requestFullscreen before adding of listener --- cocos2d/core/platform/CCScreen.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2d/core/platform/CCScreen.js b/cocos2d/core/platform/CCScreen.js index 97452e6e36..f1730fe015 100644 --- a/cocos2d/core/platform/CCScreen.js +++ b/cocos2d/core/platform/CCScreen.js @@ -115,7 +115,6 @@ cc.screen = /** @lends cc.screen# */{ } element = element || document.documentElement; - element[this._fn.requestFullscreen](); if (onFullScreenChange) { var eventName = this._fn.fullscreenchange; From 2f8c9023864ba35f9cbd4c249fdf01df9742e023 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 4 Mar 2015 14:55:23 +0800 Subject: [PATCH 1388/1564] Fixed #2699: add the parameter 'premultiplied' to cc.Texture --- cocos2d/core/textures/TexturesWebGL.js | 11 ++++++++--- template/src/myApp.js | 11 ----------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index a62de74fff..7f838f0609 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -442,8 +442,10 @@ cc._tmp.WebGLTexture2D = function () { /** * handler of texture loaded event + * @param {Boolean} [premultipled=false] */ - handleLoadedTexture: function () { + handleLoadedTexture: function (premultipled) { + premultipled = (premultipled === undefined)?false: premultipled; var self = this; // Not sure about this ! Some texture need to be updated even after loaded if (!cc._rendererInitialized) @@ -462,7 +464,8 @@ cc._tmp.WebGLTexture2D = function () { cc.glBindTexture2D(self); gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); + if(premultipled) + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); // Specify OpenGL texture image gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, self._htmlElementObj); @@ -474,6 +477,8 @@ cc._tmp.WebGLTexture2D = function () { self.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE); cc.glBindTexture2D(null); + if(premultipled) + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0); var pixelsWide = self._htmlElementObj.width; var pixelsHigh = self._htmlElementObj.height; @@ -484,7 +489,7 @@ cc._tmp.WebGLTexture2D = function () { self.maxS = 1; self.maxT = 1; - self._hasPremultipliedAlpha = false; + self._hasPremultipliedAlpha = premultipled; self._hasMipmaps = false; //dispatch load event to listener. diff --git a/template/src/myApp.js b/template/src/myApp.js index b4258ed20a..f91b7c40af 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,17 +44,6 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); - - var root = new cc.Node(); - var body = new cc.Sprite("cut_the_hope1.png", cc.rect(827, 775, 143, 134)); - var leg = new cc.Sprite("cut_the_hope1.png", cc.rect(934, 248, 46, 51)); - //leg.setBlendFunc(cc.BlendFunc.ALPHA_PREMULTIPLIED); - - root.addChild(body); - root.addChild(leg); - this.addChild(root); - root.setScale(3); - root.setPosition(size.width/2, size.height/2); } }); From 32ec57da1a90b53a7a82d47c3298890ea85c2e88 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 4 Mar 2015 15:01:39 +0800 Subject: [PATCH 1389/1564] Removed the test codes. --- template/src/resource.js | 1 - 1 file changed, 1 deletion(-) diff --git a/template/src/resource.js b/template/src/resource.js index a70fc7f61b..94284083d1 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -5,7 +5,6 @@ var s_CloseSelected = "CloseSelected.png"; var g_resources = [ //image s_HelloWorld, - "cut_the_hope1.png", s_CloseNormal, s_CloseSelected From 5b5d0c9b77fa9c3e511c2790a1cf0b7616d05f1e Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 5 Mar 2015 14:02:22 +0800 Subject: [PATCH 1390/1564] Fixed a bug of cc.DrawNode that its lineWidth is always to default value when set linewidth to zero. --- cocos2d/shape-nodes/CCDrawNode.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 18b8456fd2..9564b6bdc9 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -181,7 +181,7 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ * @param {cc.Color} lineColor */ drawRect: function (origin, destination, fillColor, lineWidth, lineColor) { - lineWidth = lineWidth || this._lineWidth; + lineWidth = (lineWidth == null) ? this._lineWidth : lineWidth; lineColor = lineColor || this.getDrawColor(); if(lineColor.a == null) lineColor.a = 255; @@ -436,7 +436,7 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ * @param {cc.Color} color */ drawPoly_: function (verts, fillColor, lineWidth, color) { - lineWidth = lineWidth || this._lineWidth; + lineWidth = (lineWidth == null ) ? this._lineWidth : lineWidth; color = color || this.getDrawColor(); if (color.a == null) color.a = 255; @@ -554,7 +554,7 @@ cc.DrawNodeWebGL = cc.Node.extend({ }, drawRect: function (origin, destination, fillColor, lineWidth, lineColor) { - lineWidth = lineWidth || this._lineWidth; + lineWidth = (lineWidth == null) ? this._lineWidth : lineWidth; lineColor = lineColor || this.getDrawColor(); if (lineColor.a == null) lineColor.a = 255; @@ -789,7 +789,7 @@ cc.DrawNodeWebGL = cc.Node.extend({ fillColor.a = 255; if (borderColor.a == null) borderColor.a = 255; - borderWidth = borderWidth || this._lineWidth; + borderWidth = (borderWidth == null)? this._lineWidth : borderWidth; borderWidth *= 0.5; var c4bFillColor = {r: 0 | fillColor.r, g: 0 | fillColor.g, b: 0 | fillColor.b, a: 0 | fillColor.a}; var c4bBorderColor = {r: 0 | borderColor.r, g: 0 | borderColor.g, b: 0 | borderColor.b, a: 0 | borderColor.a}; @@ -852,7 +852,7 @@ cc.DrawNodeWebGL = cc.Node.extend({ }, _drawSegments: function(verts, borderWidth, borderColor, closePoly){ - borderWidth = borderWidth || this._lineWidth; + borderWidth = (borderWidth == null) ? this._lineWidth : borderWidth; borderColor = borderColor || this._drawColor; if(borderColor.a == null) borderColor.a = 255; From 1d091c2801877a949dd1b2842937a45c8ca3cf17 Mon Sep 17 00:00:00 2001 From: SijieWang Date: Thu, 5 Mar 2015 15:42:57 +0800 Subject: [PATCH 1391/1564] Revert "Remove _loadTxtSync, Because chrome(40) deprecated this API" --- CCBoot.js | 58 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 5e76480f82..5359522ea4 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -689,6 +689,26 @@ cc.loader = /** @lends cc.loader# */{ }); } }, + _loadTxtSync: function (url) { + if (!cc._isNodeJs) { + var xhr = this.getXMLHttpRequest(); + xhr.open("GET", url, false); + if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { + // IE-specific logic here + xhr.setRequestHeader("Accept-Charset", "utf-8"); + } else { + if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8"); + } + xhr.send(null); + if (!xhr.readyState == 4 || xhr.status != 200) { + return null; + } + return xhr.responseText; + } else { + var fs = require("fs"); + return fs.readFileSync(url).toString(); + } + }, loadCsb: function(url, cb){ var xhr = new XMLHttpRequest(); @@ -1944,7 +1964,6 @@ cc.game = /** @lends cc.game# */{ DEBUG_MODE_INFO_FOR_WEB_PAGE: 4, DEBUG_MODE_WARN_FOR_WEB_PAGE: 5, DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6, - _ready: false, EVENT_HIDE: "game_on_hide", EVENT_SHOW: "game_on_show", @@ -2082,12 +2101,6 @@ cc.game = /** @lends cc.game# */{ * Run game. */ run: function (id) { - if(this._ready === false){ - this._ready = id === undefined ? true : id; - return; - }else if(typeof this._ready !== "boolean"){ - id = this._ready; - } var self = this; var _run = function () { if (id) { @@ -2130,13 +2143,7 @@ cc.game = /** @lends cc.game# */{ cfg[CONFIG_KEY.frameRate] = cfg[CONFIG_KEY.frameRate] || 60; if(cfg[CONFIG_KEY.renderMode] == null) cfg[CONFIG_KEY.renderMode] = 1; - //init debug move to CCDebugger - cc._initSys(cfg, CONFIG_KEY); - self.config = cfg; - if(cc.game._ready !== false){ - self._ready = true; - cc.game.run(); - } + return cfg; }; if (document["ccConfig"]) { self.config = _init(document["ccConfig"]); @@ -2147,7 +2154,7 @@ cc.game = /** @lends cc.game# */{ var _t = cocos_script[i].getAttribute('cocos'); if(_t == '' || _t){break;} } - var _src, _resPath; + var _src, txt, _resPath; if(i < cocos_script.length){ _src = cocos_script[i].src; if(_src){ @@ -2155,23 +2162,20 @@ cc.game = /** @lends cc.game# */{ cc.loader.resPath = _resPath; _src = cc.path.join(_resPath, 'project.json'); } - cc.loader.loadTxt(_src, function(err, txt){ - if(err) - return cc.error(err); - _init(JSON.parse(txt) || {}); - }); - }else{ - cc.loader.loadTxt("project.json", function(err, txt){ - if(err) - return cc.error(err); - _init(JSON.parse(txt) || {}); - }); + txt = cc.loader._loadTxtSync(_src); + } + if(!txt){ + txt = cc.loader._loadTxtSync("project.json"); } + var data = JSON.parse(txt); + self.config = _init(data || {}); } catch (e) { cc.log("Failed to read or parse project.json"); - _init({}); + self.config = _init({}); } } + //init debug move to CCDebugger + cc._initSys(self.config, CONFIG_KEY); }, //cache for js and module that has added into jsList to be loaded. From c88599e642744796b963a3d32640093308a91bff Mon Sep 17 00:00:00 2001 From: Igor Shmulyan Date: Fri, 6 Mar 2015 11:37:15 +0200 Subject: [PATCH 1392/1564] fixed bug in hack for performance. --- cocos2d/particle/CCParticleSystemCanvasRenderCmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js index 8420e8e1e2..ed58e9821b 100644 --- a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js @@ -206,7 +206,7 @@ proto._initWithTotalParticles = function(totalParticles){}; proto._updateDeltaColor = function(selParticle, dt){ - if (!this._dontTint) { + if (!this._node._dontTint) { selParticle.color.r += selParticle.deltaColor.r * dt; selParticle.color.g += selParticle.deltaColor.g * dt; selParticle.color.b += selParticle.deltaColor.b * dt; From 24373c424456b6dcb380994c066a3107f5a453b0 Mon Sep 17 00:00:00 2001 From: Thomas Jablonski Date: Sat, 7 Mar 2015 13:29:40 +0100 Subject: [PATCH 1393/1564] audioEngine not playing in Firefox, using minified/compiled lib Load the right supportTable to support BROWSER_TYPE_FIREFOX settings --- cocos2d/audio/CCAudio.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index de28710216..6ce489238c 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -134,11 +134,16 @@ else cc.__audioSupport = supportTable[sys.BROWSER_TYPE_SAFARI]; }else{ - //Desktop support all - if(cc.sys.browserType != cc.sys.BROWSER_TYPE_IE) - cc.__audioSupport = supportTable["common"]; - else - cc.__audioSupport = supportTable[sys.BROWSER_TYPE_IE]; + switch(sys.browserType){ + case sys.BROWSER_TYPE_IE: + cc.__audioSupport = supportTable[sys.BROWSER_TYPE_IE]; + break; + case sys.BROWSER_TYPE_FIREFOX: + cc.__audioSupport = supportTable[sys.BROWSER_TYPE_FIREFOX]; + break; + default: + cc.__audioSupport = supportTable["common"]; + } } if(DEBUG){ From ef6b796829933b65785f8c412dfdd96d529f2320 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 9 Mar 2015 09:49:18 +0800 Subject: [PATCH 1394/1564] Add an initial loading icon --- template/index.html | 1 + template/main.js | 3 +++ template/src/loading.js | 1 + 3 files changed, 5 insertions(+) create mode 100644 template/src/loading.js diff --git a/template/index.html b/template/index.html index a5e02d13d4..776f7d11d7 100644 --- a/template/index.html +++ b/template/index.html @@ -23,6 +23,7 @@ + \ No newline at end of file diff --git a/template/main.js b/template/main.js index 8d14ccf6a2..dcbd88808c 100644 --- a/template/main.js +++ b/template/main.js @@ -1,4 +1,7 @@ cc.game.onStart = function(){ + if(!cc.sys.isNative) //If referenced loading.js, please remove it + document.body.removeChild(document.getElementById("cocosLoading")); + var designSize = cc.size(480, 800); var screenSize = cc.view.getFrameSize(); diff --git a/template/src/loading.js b/template/src/loading.js new file mode 100644 index 0000000000..d17a700344 --- /dev/null +++ b/template/src/loading.js @@ -0,0 +1 @@ +(function(){var createStyle=function(){return".cocosLoading{position:absolute;margin:-30px -60px;padding:0;top:50%;left:50%}"+".cocosLoading ul{margin:0;padding:0;}"+".cocosLoading span{color:#FFF;text-align:center;display:block;}"+".cocosLoading li{list-style:none;float:left;border-radius:15px;width:15px;height:15px;background:#FFF;margin:5px 0 0 10px}"+".cocosLoading li .ball,.cocosLoading li .unball{background-color:#2187e7;background-image:-moz-linear-gradient(90deg,#2187e7 25%,#a0eaff);background-image:-webkit-linear-gradient(90deg,#2187e7 25%,#a0eaff);width:15px;height:15px;border-radius:50px}"+".cocosLoading li .ball{transform:scale(0);-moz-transform:scale(0);-webkit-transform:scale(0);animation:showDot 1s linear forwards;-moz-animation:showDot 1s linear forwards;-webkit-animation:showDot 1s linear forwards}"+".cocosLoading li .unball{transform:scale(1);-moz-transform:scale(1);-webkit-transform:scale(1);animation:hideDot 1s linear forwards;-moz-animation:hideDot 1s linear forwards;-webkit-animation:hideDot 1s linear forwards}"+"@keyframes showDot{0%{transform:scale(0,0)}100%{transform:scale(1,1)}}"+"@-moz-keyframes showDot{0%{-moz-transform:scale(0,0)}100%{-moz-transform:scale(1,1)}}"+"@-webkit-keyframes showDot{0%{-webkit-transform:scale(0,0)}100%{-webkit-transform:scale(1,1)}}"+"@keyframes hideDot{0%{transform:scale(1,1)}100%{transform:scale(0,0)}}"+"@-moz-keyframes hideDot{0%{-moz-transform:scale(1,1)}100%{-moz-transform:scale(0,0)}}"+"@-webkit-keyframes hideDot{0%{-webkit-transform:scale(1,1)}100%{-webkit-transform:scale(0,0)}}"};var createDom=function(id,num){id=id||"cocosLoading";num=num||5;var i,item;var div=document.createElement("div");div.className="cocosLoading";div.id=id;var bar=document.createElement("ul");var list=[];for(i=0;i=list.length){direction=!direction;index=0;time=1000}else{time=300}animation()},time)};animation()};(function(){var bgColor=document.body.style.background;document.body.style.background="#000";var style=document.createElement("style");style.type="text/css";style.innerHTML=createStyle();document.head.appendChild(style);var list=createDom();startAnimation(list,function(){var div=document.getElementById("cocosLoading");if(!div){document.body.style.background=bgColor}return !!div})})()})(); \ No newline at end of file From dcd76c6225eda3e1463a5e9a7bdcc66c6eb1ab91 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 9 Mar 2015 09:58:33 +0800 Subject: [PATCH 1395/1564] update build.xml --- tools/build.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build.xml b/tools/build.xml index aa09aa2fa3..c1d0858cb8 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.3-min.js"> @@ -298,7 +298,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.3-core-min.js"> From e15c3eaff03b09c6268c32c2eea7e926e7b0dc78 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 9 Mar 2015 10:13:06 +0800 Subject: [PATCH 1396/1564] =?UTF-8?q?IPhone=E2=80=98s=20WebView=20does=20n?= =?UTF-8?q?ot=20default=20=20use=20the=20webgl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CCBoot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 5359522ea4..7543fbc756 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1560,6 +1560,8 @@ cc._initSys = function (config, CONFIG_KEY) { browserType = sys.BROWSER_TYPE_ANDROID; else if (browserType == "trident") browserType = sys.BROWSER_TYPE_IE; else if (browserType == "360 aphone") browserType = sys.BROWSER_TYPE_360; + }else if(ua.indexOf("iphone") && ua.indexOf("mobile")){ + browserType = "safari"; } /** * Indicate the running browser type From dfa1b8be502675e3f578b1f79b81dcad0526f8a4 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 9 Mar 2015 11:59:28 +0800 Subject: [PATCH 1397/1564] Issue #2698: refactor vec2, vec3 and aabb --- cocos2d/core/CCCamera.js | 20 +- cocos2d/core/CCDirectorWebGL.js | 20 +- cocos2d/kazmath/aabb.js | 52 +++-- cocos2d/kazmath/gl/matrix.js | 4 +- cocos2d/kazmath/mat3.js | 4 +- cocos2d/kazmath/mat4.js | 68 ++++--- cocos2d/kazmath/plane.js | 47 ++--- cocos2d/kazmath/quaternion.js | 99 ++++------ cocos2d/kazmath/ray2.js | 221 ++++++++++----------- cocos2d/kazmath/utility.js | 46 ++--- cocos2d/kazmath/vec2.js | 162 ++++++++-------- cocos2d/kazmath/vec3.js | 330 ++++++++++++++++---------------- cocos2d/kazmath/vec4.js | 12 +- 13 files changed, 494 insertions(+), 591 deletions(-) diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js index 79fe599b66..d9189391e8 100644 --- a/cocos2d/core/CCCamera.js +++ b/cocos2d/core/CCCamera.js @@ -113,14 +113,10 @@ cc.Camera = cc.Class.extend({ */ locate:function () { if (this._dirty) { - var eye = new cc.kmVec3(), center = new cc.kmVec3(), up = new cc.kmVec3(); - - cc.kmVec3Fill( eye, this._eyeX, this._eyeY , this._eyeZ ); - cc.kmVec3Fill( center, this._centerX, this._centerY, this._centerZ); - - cc.kmVec3Fill( up, this._upX, this._upY, this._upZ); + var eye = new cc.math.Vec3(this._eyeX, this._eyeY , this._eyeZ), + center = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ), + up = new cc.math.Vec3(this._upX, this._upY, this._upZ); cc.kmMat4LookAt( this._lookupMatrix, eye, center, up); - this._dirty = false; } cc.kmGLMultMatrix( this._lookupMatrix); @@ -128,14 +124,10 @@ cc.Camera = cc.Class.extend({ _locateForRenderer: function(matrix){ if (this._dirty) { - var eye = new cc.kmVec3(), center = new cc.kmVec3(), up = new cc.kmVec3(); - - cc.kmVec3Fill( eye, this._eyeX, this._eyeY , this._eyeZ ); - cc.kmVec3Fill( center, this._centerX, this._centerY, this._centerZ); - - cc.kmVec3Fill( up, this._upX, this._upY, this._upZ); + var eye = new cc.math.Vec3(this._eyeX, this._eyeY , this._eyeZ), + center = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ), + up = new cc.math.Vec3(this._upX, this._upY, this._upZ); cc.kmMat4LookAt( this._lookupMatrix, eye, center, up); - this._dirty = false; } cc.kmMat4Multiply(matrix, matrix, this._lookupMatrix); diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index d5468d4fe0..092dda5b7d 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -82,9 +82,9 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); cc.kmGLLoadIdentity(); - var eye = cc.kmVec3Fill(null, -ox + size.width / 2, -oy + size.height / 2, zeye); - var center = cc.kmVec3Fill(null, -ox + size.width / 2, -oy + size.height / 2, 0.0); - var up = cc.kmVec3Fill(null, 0.0, 1.0, 0.0); + var eye = new cc.math.Vec3(-ox + size.width / 2, -oy + size.height / 2, zeye); + var center = new cc.math.Vec3( -ox + size.width / 2, -oy + size.height / 2, 0.0); + var up = new cc.math.Vec3( 0.0, 1.0, 0.0); cc.kmMat4LookAt(matrixLookup, eye, center, up); cc.kmGLMultMatrix(matrixLookup); break; @@ -246,13 +246,9 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { // Calculate z=0 using -> transform*[0, 0, 0, 1]/w var zClip = transform.mat[14] / transform.mat[15]; - var glSize = this._openGLView.getDesignResolutionSize(); - var clipCoord = new cc.kmVec3(2.0 * uiPoint.x / glSize.width - 1.0, 1.0 - 2.0 * uiPoint.y / glSize.height, zClip); - - var glCoord = new cc.kmVec3(); - cc.kmVec3TransformCoord(glCoord, clipCoord, transformInv); - + var glCoord = new cc.math.Vec3(2.0 * uiPoint.x / glSize.width - 1.0, 1.0 - 2.0 * uiPoint.y / glSize.height, zClip); + glCoord.transformCoord(transformInv); return cc.p(glCoord.x, glCoord.y); }; @@ -260,16 +256,14 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { var transform = new cc.kmMat4(); cc.GLToClipTransform(transform); - var clipCoord = new cc.kmVec3(); + var clipCoord = new cc.math.Vec3(glPoint.x, glPoint.y, 0.0); // Need to calculate the zero depth from the transform. - var glCoord = new cc.kmVec3(glPoint.x, glPoint.y, 0.0); - cc.kmVec3TransformCoord(clipCoord, glCoord, transform); + clipCoord.transformCoord(transform); var glSize = this._openGLView.getDesignResolutionSize(); return cc.p(glSize.width * (clipCoord.x * 0.5 + 0.5), glSize.height * (-clipCoord.y * 0.5 + 0.5)); }; - _p.getVisibleSize = function () { //if (this._openGLView) { return this._openGLView.getVisibleSize(); diff --git a/cocos2d/kazmath/aabb.js b/cocos2d/kazmath/aabb.js index 8fafef6f67..a6d207ad8b 100644 --- a/cocos2d/kazmath/aabb.js +++ b/cocos2d/kazmath/aabb.js @@ -27,42 +27,52 @@ */ /** - * A struture that represents an axis-aligned - * bounding box. + * A structure that represents an axis-aligned bounding box. + * cc.kmAABB => cc.math.AABB */ -cc.kmAABB = function (min, max) { +cc.math.AABB = function (min, max) { /** The max corner of the box */ - this.min = min || new cc.kmVec3(); + this.min = min || new cc.math.Vec3(); /** The min corner of the box */ - this.max = max || new cc.kmVec3(); + this.max = max || new cc.math.Vec3(); }; /** - * Returns KM_TRUE if point is in the specified AABB, returns - * KM_FALSE otherwise. + * Returns true if point is in the specified AABB, returns false otherwise. + * @param {cc.kmVec3} point + * @returns {boolean} */ -cc.kmAABBContainsPoint = function (pPoint, pBox) { - if (pPoint.x >= pBox.min.x && pPoint.x <= pBox.max.x && +cc.math.AABB.prototype.containsPoint = function (point) { + return (point.x >= this.min.x && point.x <= this.max.x && + point.y >= this.min.y && point.y <= this.max.y && + point.z >= this.min.z && point.z <= this.max.z); +}; + +/** + * Returns true if point is in the specified AABB, returns + * false otherwise. + */ +cc.math.AABB.containsPoint = function (pPoint, pBox) { + return (pPoint.x >= pBox.min.x && pPoint.x <= pBox.max.x && pPoint.y >= pBox.min.y && pPoint.y <= pBox.max.y && - pPoint.z >= pBox.min.z && pPoint.z <= pBox.max.z) { - return cc.KM_TRUE; - } - return cc.KM_FALSE; + pPoint.z >= pBox.min.z && pPoint.z <= pBox.max.z); }; /** - * Assigns pIn to pOut, returns pOut. + * Assigns aabb to current AABB object + * @param {cc.math.AABB} aabb */ -cc.kmAABBAssign = function (pOut, pIn) { - cc.kmVec3Assign(pOut.min, pIn.min); - cc.kmVec3Assign(pOut.max, pIn.max); - return pOut; +cc.math.AABB.prototype.assign = function(aabb){ + this.min.assign(aabb.min); + this.max.assign(aabb.max); }; /** - * Scales pIn by s, stores the resulting AABB in pOut. Returns pOut + * Assigns pIn to pOut, returns pOut. */ -cc.kmAABBScale = function (pOut, pIn, s) { - cc.log("cc.kmAABBScale hasn't been supported."); +cc.math.AABB.assign = function (pOut, pIn) { //cc.kmAABBAssign + pOut.min.assign(pIn.min); + pOut.max.assign(pIn.max); + return pOut; }; diff --git a/cocos2d/kazmath/gl/matrix.js b/cocos2d/kazmath/gl/matrix.js index ed579f8c0f..97b0134faf 100644 --- a/cocos2d/kazmath/gl/matrix.js +++ b/cocos2d/kazmath/gl/matrix.js @@ -133,11 +133,11 @@ cc.kmGLTranslatef = function (x, y, z) { }; cc.kmGLRotatef = function (angle, x, y, z) { - var axis = new cc.kmVec3(x, y, z); + var axis = new cc.math.Vec3(x, y, z); var rotation = new cc.kmMat4(); //Create a rotation matrix using the axis and the angle - cc.kmMat4RotationAxisAngle(rotation, axis, cc.kmDegreesToRadians(angle)); + cc.kmMat4RotationAxisAngle(rotation, axis, cc.degreesToRadians(angle)); //Multiply the rotation matrix by the current matrix cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, rotation); diff --git a/cocos2d/kazmath/mat3.js b/cocos2d/kazmath/mat3.js index fea8559630..565df74a6f 100644 --- a/cocos2d/kazmath/mat3.js +++ b/cocos2d/kazmath/mat3.js @@ -179,8 +179,8 @@ cc.kmMat3AreEqual = function (pMat1, pMat2) { return true; for (var i = 0; i < 9; ++i) { - if (!(pMat1.mat[i] + cc.kmEpsilon > pMat2.mat[i] && - pMat1.mat[i] - cc.kmEpsilon < pMat2.mat[i])) { + if (!(pMat1.mat[i] + cc.math.EPSILON > pMat2.mat[i] && + pMat1.mat[i] - cc.math.EPSILON < pMat2.mat[i])) { return false; } } diff --git a/cocos2d/kazmath/mat4.js b/cocos2d/kazmath/mat4.js index 9c62be7284..fd1a428ea5 100644 --- a/cocos2d/kazmath/mat4.js +++ b/cocos2d/kazmath/mat4.js @@ -122,7 +122,7 @@ cc.kmMat4._gaussj = function (a, b) { indxr[i] = irow; indxc[i] = icol; if (cc.kmMat4._get(a, icol, icol) == 0.0) - return cc.KM_FALSE; + return false; pivinv = 1.0 / cc.kmMat4._get(a, icol, icol); cc.kmMat4._set(a, icol, icol, 1.0); @@ -153,7 +153,7 @@ cc.kmMat4._gaussj = function (a, b) { cc.kmMat4._swap(a, k, indxr[l], k, indxc[l]); } } - return cc.KM_TRUE; + return true; }; cc.kmMat4._identity = @@ -174,7 +174,7 @@ cc.kmMat4Inverse = function (pOut, pM) { cc.kmMat4Assign(inv, pM); cc.kmMat4Identity(tmp); - if (cc.kmMat4._gaussj(inv, tmp) == cc.KM_FALSE) + if (cc.kmMat4._gaussj(inv, tmp) == false) return null; cc.kmMat4Assign(pOut, inv); @@ -338,8 +338,8 @@ cc.kmMat4AreEqual = function (pMat1, pMat2) { } for (var i = 0; i < 16; i++) { - if (!(pMat1.mat[i] + cc.kmEpsilon > pMat2.mat[i] && - pMat1.mat[i] - cc.kmEpsilon < pMat2.mat[i])) { + if (!(pMat1.mat[i] + cc.math.EPSILON > pMat2.mat[i] && + pMat1.mat[i] - cc.math.EPSILON < pMat2.mat[i])) { return false; } } @@ -573,35 +573,32 @@ cc.kmMat4Translation = function (pOut, x, y, z) { * wish to extract the vector from. pOut is a pointer to the * kmVec3 structure that should hold the resulting vector */ -cc.kmMat4GetUpVec3 = function (pOut, pIn) { - pOut.x = pIn.mat[4]; - pOut.y = pIn.mat[5]; - pOut.z = pIn.mat[6]; - cc.kmVec3Normalize(pOut, pOut); - return pOut; +cc.kmMat4GetUpVec3 = function (vec3, mat4) { + vec3.x = mat4.mat[4]; + vec3.y = mat4.mat[5]; + vec3.z = mat4.mat[6]; + return vec3.normalize(); }; /** Extract the right vector from a 4x4 matrix. The result is * stored in pOut. Returns pOut. */ -cc.kmMat4GetRightVec3 = function (pOut, pIn) { - pOut.x = pIn.mat[0]; - pOut.y = pIn.mat[1]; - pOut.z = pIn.mat[2]; - cc.kmVec3Normalize(pOut, pOut); - return pOut; +cc.kmMat4GetRightVec3 = function (vec3, mat4) { + vec3.x = mat4.mat[0]; + vec3.y = mat4.mat[1]; + vec3.z = mat4.mat[2]; + return vec3.normalize(); }; /** * Extract the forward vector from a 4x4 matrix. The result is * stored in pOut. Returns pOut. */ -cc.kmMat4GetForwardVec3 = function (pOut, pIn) { - pOut.x = pIn.mat[8]; - pOut.y = pIn.mat[9]; - pOut.z = pIn.mat[10]; - cc.kmVec3Normalize(pOut, pOut); - return pOut; +cc.kmMat4GetForwardVec3 = function (vec3, mat4) { + vec3.x = mat4.mat[8]; + vec3.y = mat4.mat[9]; + vec3.z = mat4.mat[10]; + return vec3.normalize(); }; /** @@ -609,7 +606,7 @@ cc.kmMat4GetForwardVec3 = function (pOut, pIn) { * same way as gluPerspective */ cc.kmMat4PerspectiveProjection = function (pOut, fovY, aspect, zNear, zFar) { - var r = cc.kmDegreesToRadians(fovY / 2); + var r = cc.degreesToRadians(fovY / 2); var deltaZ = zFar - zNear; var s = Math.sin(r); @@ -647,20 +644,21 @@ cc.kmMat4OrthographicProjection = function (pOut, left, right, bottom, top, near * the resulting matrix is stored in pOut. pOut is returned. */ cc.kmMat4LookAt = function (pOut, pEye, pCenter, pUp) { - var f = new cc.kmVec3(), up = new cc.kmVec3(), s = new cc.kmVec3(), u = new cc.kmVec3(); + var f = new cc.math.Vec3(pCenter), up = new cc.math.Vec3(pUp); var translate = new cc.kmMat4(); - cc.kmVec3Subtract(f, pCenter, pEye); - cc.kmVec3Normalize(f, f); + f.subtract(pEye); + f.normalize(); - cc.kmVec3Assign(up, pUp); - cc.kmVec3Normalize(up, up); + up.normalize(); - cc.kmVec3Cross(s, f, up); - cc.kmVec3Normalize(s, s); + var s = new cc.math.Vec3(f); + s.cross(up); + s.normalize(); - cc.kmVec3Cross(u, s, f); - cc.kmVec3Normalize(s, s); + var u = new cc.math.Vec3(s); + u.cross(f); + s.normalize(); cc.kmMat4Identity(pOut); @@ -690,8 +688,8 @@ cc.kmMat4RotationAxisAngle = function (pOut, axis, radians) { var rcos = Math.cos(radians); var rsin = Math.sin(radians); - var normalizedAxis = new cc.kmVec3(); - cc.kmVec3Normalize(normalizedAxis, axis); + var normalizedAxis = new cc.math.Vec3(axis); + normalizedAxis.normalize(); pOut.mat[0] = rcos + normalizedAxis.x * normalizedAxis.x * (1 - rcos); pOut.mat[1] = normalizedAxis.z * rsin + normalizedAxis.y * normalizedAxis.x * (1 - rcos); diff --git a/cocos2d/kazmath/plane.js b/cocos2d/kazmath/plane.js index 02acd8399b..a3b9a0d5bd 100644 --- a/cocos2d/kazmath/plane.js +++ b/cocos2d/kazmath/plane.js @@ -84,7 +84,7 @@ cc.kmPlaneFromPointNormal = function(pOut, pPoint, pNormal){ pOut.a = pNormal.x; pOut.b = pNormal.y; pOut.c = pNormal.z; - pOut.d = -cc.kmVec3Dot(pNormal, pPoint); + pOut.d = - pNormal.dot(pPoint); return pOut; }; @@ -103,58 +103,33 @@ cc.kmPlaneFromPoints = function(pOut, p1, p2, p3){ Outd = −n⋅A */ - var n = new cc.kmVec3(), v1 = new cc.kmVec3(), v2 = new cc.kmVec3(); - cc.kmVec3Subtract(v1, p2, p1); //Create the vectors for the 2 sides of the triangle - cc.kmVec3Subtract(v2, p3, p1); - cc.kmVec3Cross(n, v1, v2); //Use the cross product to get the normal - - cc.kmVec3Normalize(n, n); //Normalize it and assign to pOut.m_N + var v1 = new cc.math.Vec3(p2), v2 = new cc.math.Vec3(p3); + v1.subtract(p1); //Create the vectors for the 2 sides of the triangle + v2.subtract(p1); + var n = new cc.math.Vec3(v1); + n.cross(v2); // Use the cross product to get the normal + n.normalize(); //Normalize it and assign to pOut.m_N pOut.a = n.x; pOut.b = n.y; pOut.c = n.z; - pOut.d = cc.kmVec3Dot(cc.kmVec3Scale(n, n, -1.0), p1); - + pOut.d = n.scale(-1.0).dot(p1); return pOut; }; -cc.kmPlaneIntersectLine = function(pOut, pP, pV1, pV2){ - throw "cc.kmPlaneIntersectLine() hasn't been implemented."; - /* - n = (Planea, Planeb, Planec) - d = V − U - Out = U − d⋅(Pd + n⋅U)⁄(d⋅n) [iff d⋅n ≠ 0] - */ - //var d = new cc.kmVec3(); - - //cc.kmVec3Subtract(d, pV2, pV1); //Get the direction vector - - //TODO: Continue here! - /*if (fabs(kmVec3Dot(&pP.m_N, &d)) > kmEpsilon) - { - //If we get here then the plane and line are parallel (i.e. no intersection) - pOut = nullptr; //Set to nullptr - - return pOut; - } */ - - //return null; -}; - cc.kmPlaneNormalize = function(pOut, pP){ - var n = new cc.kmVec3(); + var n = new cc.math.Vec3(); n.x = pP.a; n.y = pP.b; n.z = pP.c; - var l = 1.0 / cc.kmVec3Length(n); //Get 1/length - cc.kmVec3Normalize(n, n); //Normalize the vector and assign to pOut + var l = 1.0 / n.length(); //Get 1/length + n.normalize(); //Normalize the vector and assign to pOut pOut.a = n.x; pOut.b = n.y; pOut.c = n.z; - pOut.d = pP.d * l; //Scale the D value and assign to pOut return pOut; diff --git a/cocos2d/kazmath/quaternion.js b/cocos2d/kazmath/quaternion.js index 1a863f372b..6c7b20ca2b 100644 --- a/cocos2d/kazmath/quaternion.js +++ b/cocos2d/kazmath/quaternion.js @@ -82,7 +82,7 @@ cc.kmQuaternionInverse = function (pOut, pIn) { var l = cc.kmQuaternionLength(pIn); var tmp = new cc.kmQuaternion(); - if (Math.abs(l) > cc.kmEpsilon) { + if (Math.abs(l) > cc.math.EPSILON) { pOut.x = 0.0; pOut.y = 0.0; pOut.z = 0.0; @@ -139,7 +139,7 @@ cc.kmQuaternionMultiply = function (pOut, q1, q2) { ///< Normalizes a quaternion cc.kmQuaternionNormalize = function (pOut, pIn) { var length = cc.kmQuaternionLength(pIn); - if(Math.abs(length) <= cc.kmEpsilon) + if(Math.abs(length) <= cc.math.EPSILON) throw "cc.kmQuaternionNormalize(): pIn is an invalid value"; cc.kmQuaternionScale(pOut, pIn, 1.0 / length); @@ -217,7 +217,7 @@ cc.kmQuaternionRotationMatrix = function (pOut, pIn) { diagonal = pMatrix[0] + pMatrix[5] + pMatrix[10] + 1; - if (diagonal > cc.kmEpsilon) { + if (diagonal > cc.math.EPSILON) { // Calculate the scale of the diagonal scale = Math.sqrt(diagonal) * 2; @@ -275,9 +275,9 @@ cc.kmQuaternionRotationYawPitchRoll = function (pOut, yaw, pitch, roll) { var ex, ey, ez; // temp half euler angles var cr, cp, cy, sr, sp, sy, cpcy, spsy; // temp vars in roll,pitch yaw - ex = cc.kmDegreesToRadians(pitch) / 2.0; // convert to rads and half them - ey = cc.kmDegreesToRadians(yaw) / 2.0; - ez = cc.kmDegreesToRadians(roll) / 2.0; + ex = cc.degreesToRadians(pitch) / 2.0; // convert to rads and half them + ey = cc.degreesToRadians(yaw) / 2.0; + ez = cc.degreesToRadians(roll) / 2.0; cr = Math.cos(ex); cp = Math.cos(ey); @@ -330,7 +330,7 @@ cc.kmQuaternionSlerp = function (pOut, q1, q2, t) { var ct = cc.kmQuaternionDot(q1, q2); var theta = Math.acos(ct); - var st = Math.sqrt(1.0 - cc.kmSQR(ct)); + var st = Math.sqrt(1.0 - cc.math.square(ct)); var stt = Math.sin(t * theta) / st; var somt = Math.sin((1.0 - t) * theta) / st; @@ -349,10 +349,10 @@ cc.kmQuaternionToAxisAngle = function (pIn, pAxis, pAngle) { var scale; // temp vars tempAngle = Math.acos(pIn.w); - scale = Math.sqrt(cc.kmSQR(pIn.x) + cc.kmSQR(pIn.y) + cc.kmSQR(pIn.z)); + scale = Math.sqrt(cc.math.square(pIn.x) + cc.math.square(pIn.y) + cc.math.square(pIn.z)); - if (((scale > -cc.kmEpsilon) && scale < cc.kmEpsilon) - || (scale < 2 * cc.kmPI + cc.kmEpsilon && scale > 2 * cc.kmPI - cc.kmEpsilon)) { // angle is 0 or 360 so just simply set axis to 0,0,1 with angle 0 + if (((scale > -cc.math.EPSILON) && scale < cc.math.EPSILON) + || (scale < 2 * Math.PI + cc.math.EPSILON && scale > 2 * Math.PI - cc.math.EPSILON)) { // angle is 0 or 360 so just simply set axis to 0,0,1 with angle 0 pAngle = 0.0; pAxis.x = 0.0; @@ -364,7 +364,7 @@ cc.kmQuaternionToAxisAngle = function (pIn, pAxis, pAngle) { pAxis.x = pIn.x / scale; pAxis.y = pIn.y / scale; pAxis.z = pIn.z / scale; - cc.kmVec3Normalize(pAxis, pAxis); + pAxis.normalize(); } }; @@ -407,16 +407,10 @@ cc.kmQuaternionAdd = function (pOut, pQ1, pQ2) { ANY axis of rotation is valid. */ cc.kmQuaternionRotationBetweenVec3 = function (pOut, vec1, vec2, fallback) { - var v1 = new cc.kmVec3(), v2 = new cc.kmVec3(); - var a; - - cc.kmVec3Assign(v1, vec1); - cc.kmVec3Assign(v2, vec2); - - cc.kmVec3Normalize(v1, v1); - cc.kmVec3Normalize(v2, v2); - - a = cc.kmVec3Dot(v1, v2); + var v1 = new cc.math.Vec3(vec1), v2 = new cc.math.Vec3(vec2); + v1.normalize(); + v2.normalize(); + var a = v1.dot(v2); if (a >= 1.0) { cc.kmQuaternionIdentity(pOut); @@ -424,40 +418,28 @@ cc.kmQuaternionRotationBetweenVec3 = function (pOut, vec1, vec2, fallback) { } if (a < (1e-6 - 1.0)) { - if (Math.abs(cc.kmVec3LengthSq(fallback)) < cc.kmEpsilon) { - cc.kmQuaternionRotationAxis(pOut, fallback, cc.kmPI); + if (Math.abs(fallback.lengthSq()) < cc.math.EPSILON) { + cc.kmQuaternionRotationAxis(pOut, fallback, Math.PI); } else { - var axis = new cc.kmVec3(); - var X = new cc.kmVec3(); - X.x = 1.0; - X.y = 0.0; - X.z = 0.0; - - cc.kmVec3Cross(axis, X, vec1); + var X = new cc.math.Vec3(1.0, 0.0, 0.0); + var axis = new cc.math.Vec3(X); + axis.cross(vec1); //If axis is zero - if (Math.abs(cc.kmVec3LengthSq(axis)) < cc.kmEpsilon) { - var Y = new cc.kmVec3(); - Y.x = 0.0; - Y.y = 1.0; - Y.z = 0.0; - - cc.kmVec3Cross(axis, Y, vec1); + if (Math.abs(axis.lengthSq()) < cc.math.EPSILON) { + axis.fill(0.0, 1.0, 0.0); + axis.cross(vec1); } - - cc.kmVec3Normalize(axis, axis); - cc.kmQuaternionRotationAxis(pOut, axis, cc.kmPI); + axis.normalize(); + cc.kmQuaternionRotationAxis(pOut, axis, Math.PI); } } else { - var s = Math.sqrt((1 + a) * 2); - var invs = 1 / s; - - var c = new cc.kmVec3(); - cc.kmVec3Cross(c, v1, v2); + var s = Math.sqrt((1 + a) * 2), invs = 1 / s; + v1.cross(v2); - pOut.x = c.x * invs; - pOut.y = c.y * invs; - pOut.z = c.z * invs; + pOut.x = v1.x * invs; + pOut.y = v1.y * invs; + pOut.z = v1.z * invs; pOut.w = s * 0.5; cc.kmQuaternionNormalize(pOut, pOut); @@ -466,21 +448,16 @@ cc.kmQuaternionRotationBetweenVec3 = function (pOut, vec1, vec2, fallback) { }; cc.kmQuaternionMultiplyVec3 = function (pOut, q, v) { - var uv = new cc.kmVec3(), uuv = new cc.kmVec3(), qvec = new cc.kmVec3(); - - qvec.x = q.x; - qvec.y = q.y; - qvec.z = q.z; - - cc.kmVec3Cross(uv, qvec, v); - cc.kmVec3Cross(uuv, qvec, uv); - - cc.kmVec3Scale(uv, uv, (2.0 * q.w)); - cc.kmVec3Scale(uuv, uuv, 2.0); + var uv = new cc.math.Vec3(q), uuv = new cc.math.Vec3(q); + uv.cross(v); + uuv.cross(uv); - cc.kmVec3Add(pOut, v, uv); - cc.kmVec3Add(pOut, pOut, uuv); + uv.scale((2.0 * q.w)); + uuv.scale(2.0); + pOut.fill(v); + pOut.add(uv); + pOut.add(uuv); return pOut; }; diff --git a/cocos2d/kazmath/ray2.js b/cocos2d/kazmath/ray2.js index e9edbcd13d..5a29794e88 100644 --- a/cocos2d/kazmath/ray2.js +++ b/cocos2d/kazmath/ray2.js @@ -26,138 +26,115 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -cc.kmRay2 = function(start, dir){ - this.start = start || new cc.kmVec2(); - this.start = start || new cc.kmVec2(); -}; - -cc.kmRay2Fill = function(ray, px, py,vx,vy){ - ray.start.x = px; - ray.start.y = py; - ray.dir.x = vx; - ray.dir.y = vy; -}; - -cc.kmRay2IntersectLineSegment = function(ray, p1, p2, intersection){ - var x1 = ray.start.x; - var y1 = ray.start.y; - var x2 = ray.start.x + ray.dir.x; - var y2 = ray.start.y + ray.dir.y; - var x3 = p1.x; - var y3 = p1.y; - var x4 = p2.x; - var y4 = p2.y; - - var denom = (y4 -y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - var ua, x, y; - //If denom is zero, the lines are parallel - if(denom > -cc.kmEpsilon && denom < cc.kmEpsilon) { - return cc.KM_FALSE; - } +(function(cc){ + cc.math.Ray2 = function (start, dir) { // = cc.kmRay2 + this.start = start || new cc.math.Vec2(); + this.dir = dir || new cc.math.Vec2(); + }; + + cc.math.Ray2.prototype.fill = function (px, py, vx, vy) { // = cc.kmRay2Fill + this.start.x = px; + this.start.y = py; + this.dir.x = vx; + this.dir.y = vy; + }; + + cc.math.Ray2.prototype.intersectLineSegment = function (p1, p2, intersection) { // = cc.kmRay2IntersectLineSegment + var x1 = this.start.x, y1 = this.start.y; + var x2 = this.start.x + this.dir.x, y2 = this.start.y + this.dir.y; + var x3 = p1.x, y3 = p1.y; + var x4 = p2.x, y4 = p2.y; + + var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + var ua, x, y; + //If denom is zero, the lines are parallel + if (denom > -cc.math.EPSILON && denom < cc.math.EPSILON) + return false; + + ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denom; + //var ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denom; + + x = x1 + ua * (x2 - x1); + y = y1 + ua * (y2 - y1); + + if (x < Math.min(p1.x, p2.x) - cc.math.EPSILON || + x > Math.max(p1.x, p2.x) + cc.math.EPSILON || + y < Math.min(p1.y, p2.y) - cc.math.EPSILON || + y > Math.max(p1.y, p2.y) + cc.math.EPSILON) { + //Outside of line + //printf("Outside of line, %f %f (%f %f)(%f, %f)\n", x, y, p1.x, p1.y, p2.x, p2.y); + return false; + } - ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denom; -// var ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denom; + if (x < Math.min(x1, x2) - cc.math.EPSILON || + x > Math.max(x1, x2) + cc.math.EPSILON || + y < Math.min(y1, y2) - cc.math.EPSILON || + y > Math.max(y1, y2) + cc.math.EPSILON) { + //printf("Outside of ray, %f %f (%f %f)(%f, %f)\n", x, y, x1, y1, x2, y2); + return false; + } - x = x1 + ua * (x2 - x1); - y = y1 + ua * (y2 - y1); + intersection.x = x; + intersection.y = y; + return true; + }; - if(x < cc.kmMin(p1.x, p2.x) - cc.kmEpsilon || - x > cc.kmMax(p1.x, p2.x) + cc.kmEpsilon || - y < cc.kmMin(p1.y, p2.y) - cc.kmEpsilon || - y > cc.kmMax(p1.y, p2.y) + cc.kmEpsilon) { - //Outside of line - //printf("Outside of line, %f %f (%f %f)(%f, %f)\n", x, y, p1.x, p1.y, p2.x, p2.y); - return cc.KM_FALSE; - } + function calculate_line_normal(p1, p2, normalOut){ + var tmp = new cc.math.Vec2(p2); + tmp.subtract(p1); - if(x < cc.kmMin(x1, x2) - cc.kmEpsilon || - x > cc.kmMax(x1, x2) + cc.kmEpsilon || - y < cc.kmMin(y1, y2) - cc.kmEpsilon || - y > cc.kmMax(y1, y2) + cc.kmEpsilon) { - //printf("Outside of ray, %f %f (%f %f)(%f, %f)\n", x, y, x1, y1, x2, y2); - return cc.KM_FALSE; + normalOut.x = -tmp.y; + normalOut.y = tmp.x; + normalOut.normalize(); + //TODO: should check that the normal is pointing out of the triangle } - intersection.x = x; - intersection.y = y; - - return cc.KM_TRUE; -}; - -cc.calculate_line_normal = function(p1, p2, normal_out){ - var tmp = new cc.kmVec2(); - cc.kmVec2Subtract(tmp, p2, p1); //Get direction vector - - normal_out.x = -tmp.y; - normal_out.y = tmp.x; - cc.kmVec2Normalize(normal_out, normal_out); - - //TODO: should check that the normal is pointing out of the triangle -}; - -cc.kmRay2IntersectTriangle = function(ray, p1, p2, p3, intersection, normal_out){ - var intersect = new cc.kmVec2(); - var final_intersect = new cc.kmVec2(); - var normal = new cc.kmVec2(); - var distance = 10000.0; - var intersected = cc.KM_FALSE; - - var tmp,this_distance; - - if(cc.kmRay2IntersectLineSegment(ray, p1, p2, intersect)) { - tmp = new cc.kmVec2(); - - intersected = cc.KM_TRUE; - this_distance = cc.kmVec2Length(cc.kmVec2Subtract(tmp, intersect, ray.start)); - if(this_distance < distance) { - final_intersect.x = intersect.x; - final_intersect.y = intersect.y; - distance = this_distance; - - cc.calculate_line_normal(p1, p2, normal); + cc.math.Ray2.prototype.intersectTriangle = function(p1, p2, p3, intersection, normal_out){ + var intersect = new cc.math.Vec2(), final_intersect = new cc.math.Vec2(); + var normal = new cc.math.Vec2(), distance = 10000.0, intersected = false; + var this_distance; + + if(this.intersectLineSegment(p1, p2, intersect)) { + intersected = true; + this_distance = intersect.subtract(this.start).length(); + if(this_distance < distance) { + final_intersect.x = intersect.x; + final_intersect.y = intersect.y; + distance = this_distance; + calculate_line_normal(p1, p2, normal); + } } - } - - if(cc.kmRay2IntersectLineSegment(ray, p2, p3, intersect)) { - tmp = new cc.kmVec2(); - intersected = cc.KM_TRUE; - this_distance = cc.kmVec2Length(cc.kmVec2Subtract(tmp, intersect, ray.start)); - if(this_distance < distance) { - final_intersect.x = intersect.x; - final_intersect.y = intersect.y; - distance = this_distance; - - cc.calculate_line_normal(p2, p3, normal); + if(this.intersectLineSegment(p2, p3, intersect)) { + intersected = true; + this_distance = intersect.subtract(this.start).length(); + if(this_distance < distance) { + final_intersect.x = intersect.x; + final_intersect.y = intersect.y; + distance = this_distance; + calculate_line_normal(p2, p3, normal); + } } - } - - if(cc.kmRay2IntersectLineSegment(ray, p3, p1, intersect)) { - tmp = new cc.kmVec2(); - intersected = cc.KM_TRUE; - this_distance = cc.kmVec2Length(cc.kmVec2Subtract(tmp, intersect, ray.start)); - if(this_distance < distance) { - final_intersect.x = intersect.x; - final_intersect.y = intersect.y; - distance = this_distance; - - cc.calculate_line_normal(p3, p1, normal); + if(this.intersectLineSegment(p3, p1, intersect)) { + intersected = true; + this_distance = intersect.subtract(this.start).length(); + if(this_distance < distance) { + final_intersect.x = intersect.x; + final_intersect.y = intersect.y; + distance = this_distance; + calculate_line_normal(p3, p1, normal); + } } - } - if(intersected) { - intersection.x = final_intersect.x; - intersection.y = final_intersect.y; - if(normal_out) { - normal_out.x = normal.x; - normal_out.y = normal.y; + if(intersected) { + intersection.x = final_intersect.x; + intersection.y = final_intersect.y; + if(normal_out) { + normal_out.x = normal.x; + normal_out.y = normal.y; + } } - } - - return intersected; -}; - -cc.kmRay2IntersectCircle = function(ray, centre, radius, intersection) { - cc.log("cc.kmRay2IntersectCircle() has not been implemented."); -}; \ No newline at end of file + return intersected; + }; +})(cc); diff --git a/cocos2d/kazmath/utility.js b/cocos2d/kazmath/utility.js index 4f1d8153c7..9cd3fb4c71 100644 --- a/cocos2d/kazmath/utility.js +++ b/cocos2d/kazmath/utility.js @@ -26,51 +26,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + /** - * @ignore + *

    The main namespace of Cocos2d-html5's math library,
    + * all math core classes, functions, properties and constants are defined in this namespace

    + * @namespace + * @name cc.math */ -cc.kmScalar = Number; - -cc.kmBool = Number; - -cc.kmEnum = Number; - -cc.KM_FALSE = 0; +cc.math = cc.math || {}; -cc.KM_TRUE = 1; +//cc.kmPIOver180 = 0.017453; please use cc.RAD -cc.kmPI = 3.141592; +//cc.kmPIUnder180 = 57.295779; please use cc.DEG -cc.kmPIOver180 = 0.017453; - -cc.kmPIUnder180 = 57.295779; - -cc.kmEpsilon = 1.0 / 64.0; +cc.math.EPSILON = 1.0 / 64.0; //cc.kmEpsilon /** * Returns the square of s (e.g. s*s) * @param {Number} s */ -cc.kmSQR = function(s){ +cc.math.square = function(s){ return s*s; }; -cc.kmDegreesToRadians = function(degrees){ - return degrees * cc.kmPIOver180; -}; - -cc.kmRadiansToDegrees = function(radians){ - return radians * cc.kmPIUnder180; -}; - -cc.kmMin = function(lhs,rhs){ - return (lhs < rhs)? lhs : rhs; -}; - -cc.kmMax = function(lhs,rhs){ - return (lhs > rhs)? lhs : rhs; -}; - -cc.kmAlmostEqual = function(lhs,rhs){ - return (lhs + cc.kmEpsilon > rhs && lhs - cc.kmEpsilon < rhs); +cc.math.almostEqual = function(lhs,rhs){ + return (lhs + cc.math.EPSILON > rhs && lhs - cc.math.EPSILON < rhs); }; diff --git a/cocos2d/kazmath/vec2.js b/cocos2d/kazmath/vec2.js index 888b234bf1..a682bc4853 100644 --- a/cocos2d/kazmath/vec2.js +++ b/cocos2d/kazmath/vec2.js @@ -26,82 +26,88 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -cc.kmVec2 = function (x, y) { - this.x = x || 0; - this.y = y || 0; -}; +(function(cc){ + cc.math.Vec2 = function (x, y) { + if(y === undefined){ + this.x = x.x; + this.y = x.y; + }else{ + this.x = x || 0; + this.y = y || 0; + } + }; + + var proto = cc.math.Vec2.prototype; + proto.fill = function(x, y){ // = cc.kmVec2Fill + this.x = x; + this.y = y; + }; + + proto.length = function(){ // = cc.kmVec2Length + return Math.sqrt(cc.math.square(this.x) + cc.math.square(this.y)); + }; + + proto.lengthSq = function(){ // = cc.kmVec2LengthSq + return cc.math.square(this.x) + cc.math.square(this.y); + }; + + proto.normalize = function(){ // = cc.kmVec2Normalize + var l = 1.0 / this.length(); + this.x *= l; + this.y *= l; + return this; + }; + + cc.math.Vec2.add = function (pOut, pV1, pV2) { // = cc.kmVec2Add + pOut.x = pV1.x + pV2.x; + pOut.y = pV1.y + pV2.y; + return pOut + }; + + proto.add = function(vec){ // = cc.kmVec2Add + this.x += vec.x; + this.y += vec.y; + return this; + }; + + proto.dot = function (vec) { //cc.kmVec2Dot + return this.x * vec.x + this.y * vec.y; + }; + + cc.math.Vec2.subtract = function (pOut, pV1, pV2) { // = cc.kmVec2Subtract + pOut.x = pV1.x - pV2.x; + pOut.y = pV1.y - pV2.y; + return pOut; + }; + + proto.subtract = function(vec){ // = cc.kmVec2Subtract + this.x -= vec.x; + this.y -= vec.y; + return this; + }; + + proto.transform = function (mat3) { // = cc.kmVec2Transform + var x = this.x, y = this.y; + this.x = x * mat3.mat[0] + y * mat3.mat[3] + mat3.mat[6]; + this.y = x * mat3.mat[1] + y * mat3.mat[4] + mat3.mat[7]; + return this; + }; + + cc.math.Vec2.scale = function (pOut, pIn, s) { // = cc.kmVec2Scale + pOut.x = pIn.x * s; + pOut.y = pIn.y * s; + return pOut; + }; + + proto.scale = function(s) { // = cc.kmVec2Scale + this.x *= s; + this.y *= s; + return this; + }; + + proto.equals = function (vec) { // = cc.kmVec2AreEqual + return (this.x < vec.x + cc.math.EPSILON && this.x > vec.x - cc.math.EPSILON) && + (this.y < vec.y + cc.math.EPSILON && this.y > vec.y - cc.math.EPSILON); + }; +})(cc); -cc.kmVec2Fill = function (pOut, x, y) { - pOut.x = x; - pOut.y = y; - return pOut; -}; - -cc.kmVec2Length = function (pIn) { - return Math.sqrt(cc.kmSQR(pIn.x) + cc.kmSQR(pIn.y)); -}; - -cc.kmVec2LengthSq = function (pIn) { - return cc.kmSQR(pIn.x) + cc.kmSQR(pIn.y); -}; - -cc.kmVec2Normalize = function (pOut, pIn) { - var l = 1.0 / cc.kmVec2Length(pIn); - - var v = new cc.kmVec2(); - v.x = pIn.x * l; - v.y = pIn.y * l; - - pOut.x = v.x; - pOut.y = v.y; - - return pOut; -}; - -cc.kmVec2Add = function (pOut, pV1, pV2) { - pOut.x = pV1.x + pV2.x; - pOut.y = pV1.y + pV2.y; - - return pOut -}; - -cc.kmVec2Dot = function (pV1, pV2) { - return pV1.x * pV2.x + pV1.y * pV2.y; -}; - -cc.kmVec2Subtract = function (pOut, pV1, pV2) { - pOut.x = pV1.x - pV2.x; - pOut.y = pV1.y - pV2.y; - - return pOut; -}; - -cc.kmVec2Transform = function (pOut, pV, pM) { - var v= new cc.kmVec2(); - - v.x = pV.x * pM.mat[0] + pV.y * pM.mat[3] + pM.mat[6]; - v.y = pV.x * pM.mat[1] + pV.y * pM.mat[4] + pM.mat[7]; - - pOut.x = v.x; - pOut.y = v.y; - - return pOut; -}; - -cc.kmVec2TransformCoord = function (pOut, pV, pM) { - return null; -}; - -cc.kmVec2Scale = function (pOut, pIn, s) { - pOut.x = pIn.x * s; - pOut.y = pIn.y * s; - - return pOut; -}; - -cc.kmVec2AreEqual = function (p1, p2) { - return ( - (p1.x < p2.x + cc.kmEpsilon && p1.x > p2.x - cc.kmEpsilon) && - (p1.y < p2.y + cc.kmEpsilon && p1.y > p2.y - cc.kmEpsilon) - ); -}; diff --git a/cocos2d/kazmath/vec3.js b/cocos2d/kazmath/vec3.js index 07dc0fb4ea..77fd12f3da 100644 --- a/cocos2d/kazmath/vec3.js +++ b/cocos2d/kazmath/vec3.js @@ -26,173 +26,169 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -cc.kmVec3 = function (x, y, z) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; -}; - -cc.kmVec3Fill = function(pOut, x, y , z){ - if(!pOut) - return new cc.kmVec3(x, y , z); - pOut.x = x; - pOut.y = y; - pOut.z = z; - return pOut; -}; - -cc.kmVec3Length = function(pIn){ - return Math.sqrt(cc.kmSQR(pIn.x) + cc.kmSQR(pIn.y) + cc.kmSQR(pIn.z)); -}; - -cc.kmVec3LengthSq = function(pIn){ - return cc.kmSQR(pIn.x) + cc.kmSQR(pIn.y) + cc.kmSQR(pIn.z) -} ; - -cc.kmVec3Normalize = function(pOut,pIn){ - var l = 1.0 / cc.kmVec3Length(pIn); - - pOut.x = pIn.x * l; - pOut.y = pIn.y * l; - pOut.z = pIn.z * l; - return pOut; -}; - -cc.kmVec3Cross = function(pOut, pV1,pV2){ - pOut.x = (pV1.y * pV2.z) - (pV1.z * pV2.y); - pOut.y = (pV1.z * pV2.x) - (pV1.x * pV2.z); - pOut.z = (pV1.x * pV2.y) - (pV1.y * pV2.x); - return pOut; -}; - -cc.kmVec3Dot = function(pV1, pV2){ - return ( pV1.x * pV2.x - + pV1.y * pV2.y - + pV1.z * pV2.z ); -} ; - -cc.kmVec3Add = function(pOut, pV1, pV2){ - pOut.x = pV1.x + pV2.x; - pOut.y = pV1.y + pV2.y; - pOut.z = pV1.z + pV2.z; - return pOut; -}; - -cc.kmVec3Subtract = function(pOut, pV1, pV2){ - pOut.x = pV1.x - pV2.x; - pOut.y = pV1.y - pV2.y; - pOut.z = pV1.z - pV2.z; - return pOut; -}; - -cc.kmVec3Transform = function(pOut, pV, pM){ - /* - a = (Vx, Vy, Vz, 1) - b = (a×M)T - Out = (bx, by, bz) - */ - pOut.x = pV.x * pM.mat[0] + pV.y * pM.mat[4] + pV.z * pM.mat[8] + pM.mat[12]; - pOut.y = pV.x * pM.mat[1] + pV.y * pM.mat[5] + pV.z * pM.mat[9] + pM.mat[13]; - pOut.z = pV.x * pM.mat[2] + pV.y * pM.mat[6] + pV.z * pM.mat[10] + pM.mat[14]; - return pOut; -}; - -cc.kmVec3TransformNormal = function(pOut, pV, pM){ - /* - a = (Vx, Vy, Vz, 0) - b = (a×M)T - Out = (bx, by, bz) - */ - //Omits the translation, only scaling + rotating - pOut.x = pV.x * pM.mat[0] + pV.y * pM.mat[4] + pV.z * pM.mat[8]; - pOut.y = pV.x * pM.mat[1] + pV.y * pM.mat[5] + pV.z * pM.mat[9]; - pOut.z = pV.x * pM.mat[2] + pV.y * pM.mat[6] + pV.z * pM.mat[10]; - return pOut; -}; - -cc.kmVec3TransformCoord = function(pOut,pV,pM){ - /* - a = (Vx, Vy, Vz, 1) - b = (a×M)T - Out = 1⁄bw(bx, by, bz) - */ - var v = new cc.kmVec4(); - var inV = new cc.kmVec4(); - cc.kmVec4Fill(inV, pV.x, pV.y, pV.z, 1.0); - - cc.kmVec4Transform(v, inV,pM); - - pOut.x = v.x / v.w; - pOut.y = v.y / v.w; - pOut.z = v.z / v.w; - - return pOut; -}; - -cc.kmVec3Scale = function(pOut, pIn, s){ - pOut.x = pIn.x * s; - pOut.y = pIn.y * s; - pOut.z = pIn.z * s; - - return pOut; -}; - -cc.kmVec3AreEqual = function(p1, p2){ - if ((p1.x < (p2.x + cc.kmEpsilon) && p1.x > (p2.x - cc.kmEpsilon)) && - (p1.y < (p2.y + cc.kmEpsilon) && p1.y > (p2.y - cc.kmEpsilon)) && - (p1.z < (p2.z + cc.kmEpsilon) && p1.z > (p2.z - cc.kmEpsilon))) { - return 1; - } - - return 0; -}; - -cc.kmVec3InverseTransform = function(pOut, pVect,pM){ - var v1 = new cc.kmVec3(pVect.x - pM.mat[12], pVect.y - pM.mat[13],pVect.z - pM.mat[14]); - - pOut.x = v1.x * pM.mat[0] + v1.y * pM.mat[1] + v1.z * pM.mat[2]; - pOut.y = v1.x * pM.mat[4] + v1.y * pM.mat[5] + v1.z * pM.mat[6]; - pOut.z = v1.x * pM.mat[8] + v1.y * pM.mat[9] + v1.z * pM.mat[10]; - - return pOut; -}; - -cc.kmVec3InverseTransformNormal = function(pOut, pVect, pM){ - pOut.x = pVect.x * pM.mat[0] + pVect.y * pM.mat[1] + pVect.z * pM.mat[2]; - pOut.y = pVect.x * pM.mat[4] + pVect.y * pM.mat[5] + pVect.z * pM.mat[6]; - pOut.z = pVect.x * pM.mat[8] + pVect.y * pM.mat[9] + pVect.z * pM.mat[10]; - - return pOut; -}; - -cc.kmVec3Assign = function(pOut,pIn){ - if (pOut == pIn) - return pOut; - - pOut.x = pIn.x; - pOut.y = pIn.y; - pOut.z = pIn.z; - return pOut; -}; - -cc.kmVec3Zero = function(pOut){ - pOut.x = 0.0; - pOut.y = 0.0; - pOut.z = 0.0; - - return pOut; -}; - -cc.kmVec3ToTypeArray = function(vecValue){ - if(!vecValue) - return null; - - var tyArr = new Float32Array(3); - tyArr[0] = vecValue.x; - tyArr[1] = vecValue.y; - tyArr[2] = vecValue.z; - return tyArr; -}; +(function(cc) { + cc.kmVec3 = cc.math.Vec3 = function (x, y, z) { + if(y === undefined){ + this.x = x.x; + this.y = x.y; + this.z = x.z; + } else { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + }; + + var proto = cc.math.Vec3.prototype; + + proto.fill = function (x, y, z) { // =cc.kmVec3Fill + if (y === undefined) { + this.x = x.x; + this.y = x.y; + this.z = x.z; + } else { + this.x = x; + this.y = y; + this.z = z; + } + return this; + }; + + proto.length = function () { //=cc.kmVec3Length + return Math.sqrt(cc.math.square(this.x) + cc.math.square(this.y) + cc.math.square(this.z)); + }; + + proto.lengthSq = function () { //=cc.kmVec3LengthSq + return cc.math.square(this.x) + cc.math.square(this.y) + cc.math.square(this.z) + }; + + proto.normalize = function () { //= cc.kmVec3Normalize + var l = 1.0 / this.length(); + this.x *= l; + this.y *= l; + this.z *= l; + return this; + }; + + proto.cross = function (vec3) { //= cc.kmVec3Cross + var x = this.x, y = this.y, z = this.z; + this.x = (y * vec3.z) - (z * vec3.y); + this.y = (z * vec3.x) - (x * vec3.z); + this.z = (x * vec3.y) - (y * vec3.x); + return this; + }; + + proto.dot = function (vec) { //= cc.kmVec3Dot + return ( this.x * vec.x + this.y * vec.y + this.z * vec.z ); + }; + + proto.add = function(vec){ //= cc.kmVec3Add + this.x += vec.x; + this.y += vec.y; + this.z += vec.z; + return this; + }; + + proto.subtract = function (vec) { // = cc.kmVec3Subtract + this.x -= vec.x; + this.y -= vec.y; + this.z -= vec.z; + return this; + }; + + proto.transform = function (mat4) { // = cc.kmVec3Transform + var x = this.x, y = this.y, z = this.z, mat = mat4.mat; + this.x = x * mat[0] + y * mat[4] + z * mat[8] + mat[12]; + this.y = x * mat[1] + y * mat[5] + z * mat[9] + mat[13]; + this.z = x * mat[2] + y * mat[6] + z * mat[10] + mat[14]; + return this; + }; + + proto.transformNormal = function(mat4){ + /* + a = (Vx, Vy, Vz, 0) + b = (a×M)T + Out = (bx, by, bz) + */ + //Omits the translation, only scaling + rotating + var x = this.x, y = this.y, z = this.z, mat = mat4.mat; + this.x = x * mat[0] + y * mat[4] + z * mat[8]; + this.y = x * mat[1] + y * mat[5] + z * mat[9]; + this.z = x * mat[2] + y * mat[6] + z * mat[10]; + return this; + }; + + proto.transformCoord = function(mat4){ // = cc.kmVec3TransformCoord + /* + a = (Vx, Vy, Vz, 1) + b = (a×M)T + Out = 1⁄bw(bx, by, bz) + */ + var v = new cc.kmVec4(); + var inV = new cc.kmVec4(); + cc.kmVec4Fill(inV, this.x, this.y, this.z, 1.0); + cc.kmVec4Transform(v, inV, mat4); + this.x = v.x / v.w; + this.y = v.y / v.w; + this.z = v.z / v.w; + return this; + }; + + proto.scale = function(scale){ // = cc.kmVec3Scale + this.x *= scale; + this.y *= scale; + this.z *= scale; + return this; + }; + + proto.equals = function(vec){ // = cc.kmVec3AreEqual + var EPSILON = cc.math.EPSILON; + return (this.x < (vec.x + EPSILON) && this.x > (vec.x - EPSILON)) && + (this.y < (vec.y + EPSILON) && this.y > (vec.y - EPSILON)) && + (this.z < (vec.z + EPSILON) && this.z > (vec.z - EPSILON)); + }; + + proto.inverseTransform = function(mat4){ //= cc.kmVec3InverseTransform + var mat = mat4.mat; + var v1 = new cc.math.Vec3(this.x - mat[12], this.y - mat[13], this.z - mat[14]); + this.x = v1.x * mat[0] + v1.y * mat[1] + v1.z * mat[2]; + this.y = v1.x * mat[4] + v1.y * mat[5] + v1.z * mat[6]; + this.z = v1.x * mat[8] + v1.y * mat[9] + v1.z * mat[10]; + return this; + }; + + proto.inverseTransformNormal = function(mat4){ // = cc.kmVec3InverseTransformNormal + var x = this.x, y = this.y, z = this.z, mat = mat4.mat; + this.x = x * mat[0] + y * mat[1] + z * mat[2]; + this.y = x * mat[4] + y * mat[5] + z * mat[6]; + this.z = x * mat[8] + y * mat[9] + z * mat[10]; + return this; + }; + + proto.assign = function(vec){ + if(!vec) + return this; + this.x = vec.x; + this.y = vec.y; + this.z = vec.z; + return this; + }; + + cc.math.Vec3.zero = function(vec){ // = cc.kmVec3Zero + vec.x = vec.y = vec.z = 0.0; + return vec; + }; + + cc.mat.Vec3.toTypeArray = function(vec){ //cc.kmVec3ToTypeArray + if(!vec) + return null; + var tyArr = new Float32Array(3); + tyArr[0] = vec.x; + tyArr[1] = vec.y; + tyArr[2] = vec.z; + return tyArr; + }; +})(cc); diff --git a/cocos2d/kazmath/vec4.js b/cocos2d/kazmath/vec4.js index 9712743fff..20c8c78118 100644 --- a/cocos2d/kazmath/vec4.js +++ b/cocos2d/kazmath/vec4.js @@ -59,11 +59,11 @@ cc.kmVec4Dot = function( vec1, vec2){ }; cc.kmVec4Length = function(inVec){ - return Math.sqrt(cc.kmSQR(inVec.x) + cc.kmSQR(inVec.y) + cc.kmSQR(inVec.z) + cc.kmSQR(inVec.w)); + return Math.sqrt(cc.math.square(inVec.x) + cc.math.square(inVec.y) + cc.math.square(inVec.z) + cc.math.square(inVec.w)); }; cc.kmVec4LengthSq = function(inVec){ - return cc.kmSQR(inVec.x) + cc.kmSQR(inVec.y) + cc.kmSQR(inVec.z) + cc.kmSQR(inVec.w); + return cc.math.square(inVec.x) + cc.math.square(inVec.y) + cc.math.square(inVec.z) + cc.math.square(inVec.w); }; cc.kmVec4Lerp = function(outVec, pV1, pV2, t){ @@ -123,10 +123,10 @@ cc.kmVec4TransformArray = function(outVec,outStride,vecObj,stride,mat4Obj,count) cc.kmVec4AreEqual = function(vec1,vec2){ return ( - (vec1.x < vec2.x + cc.kmEpsilon && vec1.x > vec2.x - cc.kmEpsilon) && - (vec1.y < vec2.y + cc.kmEpsilon && vec1.y > vec2.y - cc.kmEpsilon) && - (vec1.z < vec2.z + cc.kmEpsilon && vec1.z > vec2.z - cc.kmEpsilon) && - (vec1.w < vec2.w + cc.kmEpsilon && vec1.w > vec2.w - cc.kmEpsilon) + (vec1.x < vec2.x + cc.math.EPSILON && vec1.x > vec2.x - cc.math.EPSILON) && + (vec1.y < vec2.y + cc.math.EPSILON && vec1.y > vec2.y - cc.math.EPSILON) && + (vec1.z < vec2.z + cc.math.EPSILON && vec1.z > vec2.z - cc.math.EPSILON) && + (vec1.w < vec2.w + cc.math.EPSILON && vec1.w > vec2.w - cc.math.EPSILON) ); }; From 6d56bfb25462ba8ea6ebb6936a79bdeecd5b4fc2 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 9 Mar 2015 13:45:30 +0800 Subject: [PATCH 1398/1564] Fixed : Added addImageAsync to cc.textureCache. --- cocos2d/core/textures/CCTextureCache.js | 1 + cocos2d/core/textures/TexturesWebGL.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index a32929ffbf..ad24eea7d9 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -362,6 +362,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { return tex; }; + _p.addImageAsync = _p.addImage; _p = null; } else { diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index 7f838f0609..b1667ed971 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -901,5 +901,7 @@ cc._tmp.WebGLTextureCache = function () { return tex; }; - _p = null; + + _p.addImageAsync = _p.addImage; + _p = null; }; From 2be3a494916b21cc57316b96585daa22b3c67253 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 10 Mar 2015 14:00:26 +0800 Subject: [PATCH 1399/1564] Issue #2698: refactor the math library and remove the unuse function from cc namespace. --- cocos2d/kazmath/gl/matrix.js | 1 - cocos2d/kazmath/mat3.js | 603 +++++++++++++------------ cocos2d/kazmath/mat4.js | 21 +- cocos2d/kazmath/plane.js | 228 +++++----- cocos2d/kazmath/quaternion.js | 823 +++++++++++++++++----------------- cocos2d/kazmath/vec3.js | 20 +- cocos2d/kazmath/vec4.js | 258 +++++------ 7 files changed, 964 insertions(+), 990 deletions(-) diff --git a/cocos2d/kazmath/gl/matrix.js b/cocos2d/kazmath/gl/matrix.js index 97b0134faf..0431721b7c 100644 --- a/cocos2d/kazmath/gl/matrix.js +++ b/cocos2d/kazmath/gl/matrix.js @@ -151,7 +151,6 @@ cc.kmGLScalef = function (x, y, z) { cc.kmGLGetMatrix = function (mode, pOut) { //cc.lazyInitialize(); - switch (mode) { case cc.KM_GL_MODELVIEW: cc.kmMat4Assign(pOut, cc.modelview_matrix_stack.top); diff --git a/cocos2d/kazmath/mat3.js b/cocos2d/kazmath/mat3.js index 565df74a6f..87c11a4871 100644 --- a/cocos2d/kazmath/mat3.js +++ b/cocos2d/kazmath/mat3.js @@ -27,301 +27,320 @@ */ var Float32Array = Float32Array || Array; - -cc.kmMat3 = function () { - this.mat = new Float32Array([0, 0, 0, - 0, 0, 0, - 0, 0, 0]); -}; - -cc.kmMat3Fill = function (pOut, pMat) { - for (var i = 0; i < 9; i++) { - pOut.mat[i] = pMat; - } - return pOut; -}; - -cc.kmMat3Adjugate = function (pOut, pIn) { - pOut.mat[0] = pIn.mat[4] * pIn.mat[8] - pIn.mat[5] * pIn.mat[7]; - pOut.mat[1] = pIn.mat[2] * pIn.mat[7] - pIn.mat[1] * pIn.mat[8]; - pOut.mat[2] = pIn.mat[1] * pIn.mat[5] - pIn.mat[2] * pIn.mat[4]; - pOut.mat[3] = pIn.mat[5] * pIn.mat[6] - pIn.mat[3] * pIn.mat[8]; - pOut.mat[4] = pIn.mat[0] * pIn.mat[8] - pIn.mat[2] * pIn.mat[6]; - pOut.mat[5] = pIn.mat[2] * pIn.mat[3] - pIn.mat[0] * pIn.mat[5]; - pOut.mat[6] = pIn.mat[3] * pIn.mat[7] - pIn.mat[4] * pIn.mat[6]; - - // XXX: pIn.mat[9] is invalid! -// pOut.mat[7] = pIn.mat[1] * pIn.mat[6] - pIn.mat[9] * pIn.mat[7]; - pOut.mat[8] = pIn.mat[0] * pIn.mat[4] - pIn.mat[1] * pIn.mat[3]; - - return pOut; -}; - -cc.kmMat3Identity = function (pOut) { - pOut.mat[1] = pOut.mat[2] = pOut.mat[3] = - pOut.mat[5] = pOut.mat[6] = pOut.mat[7] = 0; - pOut.mat[0] = pOut.mat[4] = pOut.mat[8] = 1.0; - return pOut; -}; - -cc.kmMat3Inverse = function (pOut, pDeterminate, pM) { - var detInv; - var adjugate = new cc.kmMat3(); - - if (pDeterminate === 0.0) - return null; - - detInv = 1.0 / pDeterminate; - - cc.kmMat3Adjugate(adjugate, pM); - cc.kmMat3ScalarMultiply(pOut, adjugate, detInv); - - return pOut; -}; - -cc.kmMat3._identity = - new Float32Array([1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0]); - -cc.kmMat3IsIdentity = function (pIn) { - for (var i = 0; i < 9; i++) { - if (cc.kmMat3._identity[i] !== pIn.mat[i]) - return false; - } - return true; -}; - -cc.kmMat3Transpose = function (pOut, pIn) { - var z, x; - for (z = 0; z < 3; ++z) { - for (x = 0; x < 3; ++x) - pOut.mat[(z * 3) + x] = pIn.mat[(x * 3) + z]; - } - - return pOut; -}; - -cc.kmMat3Determinant = function (pIn) { - var output; - /* - calculating the determinant following the rule of sarus, - | 0 3 6 | 0 3 | - m = | 1 4 7 | 1 4 | - | 2 5 8 | 2 5 | - now sum up the products of the diagonals going to the right (i.e. 0,4,8) - and substract the products of the other diagonals (i.e. 2,4,6) - */ - - output = pIn.mat[0] * pIn.mat[4] * pIn.mat[8] + pIn.mat[1] * pIn.mat[5] * pIn.mat[6] + pIn.mat[2] * pIn.mat[3] * pIn.mat[7]; - output -= pIn.mat[2] * pIn.mat[4] * pIn.mat[6] + pIn.mat[0] * pIn.mat[5] * pIn.mat[7] + pIn.mat[1] * pIn.mat[3] * pIn.mat[8]; - - return output; -}; - -cc.kmMat3Multiply = function (pOut, pM1, pM2) { - var m1 = pM1.mat, m2 = pM2.mat; - - pOut.mat[0] = m1[0] * m2[0] + m1[3] * m2[1] + m1[6] * m2[2]; - pOut.mat[1] = m1[1] * m2[0] + m1[4] * m2[1] + m1[7] * m2[2]; - pOut.mat[2] = m1[2] * m2[0] + m1[5] * m2[1] + m1[8] * m2[2]; - - pOut.mat[3] = m1[0] * m2[3] + m1[3] * m2[4] + m1[6] * m2[5]; - pOut.mat[4] = m1[1] * m2[3] + m1[4] * m2[4] + m1[7] * m2[5]; - pOut.mat[5] = m1[2] * m2[3] + m1[5] * m2[4] + m1[8] * m2[5]; - - pOut.mat[6] = m1[0] * m2[6] + m1[3] * m2[7] + m1[6] * m2[8]; - pOut.mat[7] = m1[1] * m2[6] + m1[4] * m2[7] + m1[7] * m2[8]; - pOut.mat[8] = m1[2] * m2[6] + m1[5] * m2[7] + m1[8] * m2[8]; - - return pOut; -}; - -cc.kmMat3ScalarMultiply = function (pOut, pM, pFactor) { - for (var i = 0; i < 9; i++) { - pOut.mat[i] = pM.mat[i] * pFactor; - } - return pOut; -}; - -cc.kmMat3RotationAxisAngle = function (pOut, axis, radians) { - var rcos = Math.cos(radians); - var rsin = Math.sin(radians); - - pOut.mat[0] = rcos + axis.x * axis.x * (1 - rcos); - pOut.mat[1] = axis.z * rsin + axis.y * axis.x * (1 - rcos); - pOut.mat[2] = -axis.y * rsin + axis.z * axis.x * (1 - rcos); - - pOut.mat[3] = -axis.z * rsin + axis.x * axis.y * (1 - rcos); - pOut.mat[4] = rcos + axis.y * axis.y * (1 - rcos); - pOut.mat[5] = axis.x * rsin + axis.z * axis.y * (1 - rcos); - - pOut.mat[6] = axis.y * rsin + axis.x * axis.z * (1 - rcos); - pOut.mat[7] = -axis.x * rsin + axis.y * axis.z * (1 - rcos); - pOut.mat[8] = rcos + axis.z * axis.z * (1 - rcos); - - return pOut; -}; - -cc.kmMat3Assign = function (pOut, pIn) { - if(pOut == pIn) { - cc.log("cc.kmMat3Assign(): pOut equals pIn"); - return pOut; - } - - for (var i = 0; i < 9; i++) - pOut.mat[i] = pIn.mat[i]; - return pOut; -}; - -cc.kmMat3AreEqual = function (pMat1, pMat2) { - if (pMat1 == pMat2) - return true; - - for (var i = 0; i < 9; ++i) { - if (!(pMat1.mat[i] + cc.math.EPSILON > pMat2.mat[i] && - pMat1.mat[i] - cc.math.EPSILON < pMat2.mat[i])) { - return false; +(function(cc){ + cc.math.Matrix3 = function(mat3) { + if (mat3) { + var mat = mat3; + this.mat = new Float32Array([mat[0], mat[1], mat[2], + mat[3], mat[4], mat[5], + mat[60], mat[7], mat[8]]); + } else { + this.mat = new Float32Array([0, 0, 0, + 0, 0, 0, + 0, 0, 0]); + } + }; + cc.kmMat3 = cc.math.Matrix3; + var proto = cc.math.Matrix3.prototype; + + proto.fill = function(mat3) { //cc.kmMat3Fill + var mat = this.mat, matIn = mat3.mat; + mat[0] = matIn[0]; + mat[1] = matIn[1]; + mat[2] = matIn[2]; + mat[3] = matIn[3]; + mat[4] = matIn[4]; + mat[5] = matIn[5]; + mat[6] = matIn[6]; + mat[7] = matIn[7]; + mat[8] = matIn[8]; + return this; + }; + + proto.adjugate = function(){ //= cc.kmMat3Adjugate + var mat = this.mat; + var m0 = mat[0], m1 = mat[1], m2 = mat[2], m3 = mat[3], m4 = mat[4], + m5 = mat[5], m6 = mat[6], m7 = mat[7], m8 = mat[8]; + mat[0] = m4 * m8 - m5 * m7; + mat[1] = m2 * m7 - m1 * m8; + mat[2] = m1 * m5 - m2 * m4; + mat[3] = m5 * m6 - m3 * m8; + mat[4] = m0 * m8 - m2 * m6; + mat[5] = m2 * m3 - m0 * m5; + mat[6] = m3 * m7 - m4 * m6; + + // XXX: pIn.mat[9] is invalid! + //mat[7] = m1 * m6 - pIn.mat[9] * m7; + mat[8] = m0 * m4 - m1 * m3; + return this; + }; + + proto.identity = function() { //cc.kmMat3Identity + var mat = this.mat; + mat[1] = mat[2] = mat[3] = + mat[5] = mat[6] = mat[7] = 0; + mat[0] = mat[4] = mat[8] = 1.0; + return this; + }; + + var tmpMatrix = new cc.math.Matrix3(); // internal matrix + + proto.inverse = function(determinate){ //cc.kmMat3Inverse + if (determinate === 0.0) + return this; + tmpMatrix.assign(this); + var detInv = 1.0 / determinate; + this.adjugate(); + this.multiplyScalar(detInv); + return this; + }; + + proto.isIdentity = function(){ //= cc.kmMat3IsIdentity + var mat = this.mat; + return (mat[0] === 1 && mat[1] === 0 && mat[2] === 0 + && mat[3] === 0 && mat[4] === 1 && mat[5] === 0 + && mat[6] === 0 && mat[7] === 0 && mat[8] === 1); + }; + + proto.transpose = function(){ // cc.kmMat3Transpose + var mat = this.mat; + var m1 = mat[1], m2 = mat[2], m3 = mat[3], m5 = mat[5], + m6 = mat[6], m7 = mat[7]; + // m0 = mat[0],m8 = mat[8], m4 = mat[4]; + //mat[0] = m0; + //mat[8] = m8; + //mat[4] = m4 + mat[1] = m3; + mat[2] = m6; + mat[3] = m1; + mat[5] = m7; + mat[6] = m2; + mat[7] = m5; + return this; + }; + + proto.determinant = function(){ + var mat = this.mat; + /* + calculating the determinant following the rule of sarus, + | 0 3 6 | 0 3 | + m = | 1 4 7 | 1 4 | + | 2 5 8 | 2 5 | + now sum up the products of the diagonals going to the right (i.e. 0,4,8) + and substract the products of the other diagonals (i.e. 2,4,6) + */ + var output = mat[0] * mat[4] * mat[8] + mat[1] * mat[5] * mat[6] + mat[2] * mat[3] * mat[7]; + output -= mat[2] * mat[4] * mat[6] + mat[0] * mat[5] * mat[7] + mat[1] * mat[3] * mat[8]; + return output; + }; + + proto.multiply = function(mat3){ + var m1 = this.mat, m2 = mat3.mat; + var a0 = m1[0], a1 = m1[1], a2 = m1[2], a3 = m1[3], a4 = m1[4], a5 = m1[5], + a6 = m1[6], a7 = m1[7], a8 = m1[8]; + var b0 = m2[0], b1 = m2[1], b2 = m2[2], b3 = m2[3], b4 = m2[4], b5 = m2[5], + b6 = m2[6], b7 = m2[7], b8 = m2[8]; + + m1[0] = a0 * b0 + a3 * b1 + a6 * b2; + m1[1] = a1 * b0 + a4 * b1 + a7 * b2; + m1[2] = a2 * b0 + a5 * b1 + a8 * b2; + + m1[3] = a2 * b0 + a5 * b1 + a8 * b2; + m1[4] = a1 * b3 + a4 * b4 + a7 * b5; + m1[5] = a2 * b3 + a5 * b4 + a8 * b5; + + m1[6] = a0 * b6 + a3 * b7 + a6 * b8; + m1[7] = a1 * b6 + a4 * b7 + a7 * b8; + m1[8] = a2 * b6 + a5 * b7 + a8 * b8; + return this; + }; + + proto.multiplyScalar = function(factor) { + var mat = this.mat; + mat[0] *= factor; + mat[1] *= factor; + mat[2] *= factor; + mat[3] *= factor; + mat[4] *= factor; + mat[5] *= factor; + mat[6] *= factor; + mat[7] *= factor; + mat[8] *= factor; + return this; + }; + + cc.math.Matrix3.rotationAxisAngle = function(axis, radians) { //cc.kmMat3RotationAxisAngle + var rcos = Math.cos(radians), rsin = Math.sin(radians); + var retMat = new cc.math.Matrix3(); + var mat = retMat.mat; + + mat[0] = rcos + axis.x * axis.x * (1 - rcos); + mat[1] = axis.z * rsin + axis.y * axis.x * (1 - rcos); + mat[2] = -axis.y * rsin + axis.z * axis.x * (1 - rcos); + + mat[3] = -axis.z * rsin + axis.x * axis.y * (1 - rcos); + mat[4] = rcos + axis.y * axis.y * (1 - rcos); + mat[5] = axis.x * rsin + axis.z * axis.y * (1 - rcos); + + mat[6] = axis.y * rsin + axis.x * axis.z * (1 - rcos); + mat[7] = -axis.x * rsin + axis.y * axis.z * (1 - rcos); + mat[8] = rcos + axis.z * axis.z * (1 - rcos); + + return retMat; + }; + + proto.assign = function(matIn){ // cc.kmMat3Assign + if(this === matIn) { + cc.log("cc.math.Matrix3.assign(): current matrix equals matIn"); + return this; } + var mat = this.mat, m2 = matIn.mat; + mat[0] = m2[0]; + mat[1] = m2[1]; + mat[2] = m2[2]; + mat[3] = m2[3]; + mat[4] = m2[4]; + mat[5] = m2[5]; + mat[6] = m2[6]; + mat[7] = m2[7]; + mat[8] = m2[8]; + return this; + }; + + proto.equals = function(mat3) { + if (this === mat3) + return true; + var EPSILON = cc.math.EPSILON,m1 = this.mat, m2 = mat3.mat; + for (var i = 0; i < 9; ++i) { + if (!(m1[i] + EPSILON > m2[i] && m1[i] - EPSILON < m2[i])) + return false; + } + return true; + }; + + cc.math.Matrix3.createByRotationX = function(radians) { + var retMat = new cc.math.Matrix3(), mat = retMat.mat; + mat[0] = 1.0; + mat[1] = 0.0; + mat[2] = 0.0; + + mat[3] = 0.0; + mat[4] = Math.cos(radians); + mat[5] = Math.sin(radians); + + mat[6] = 0.0; + mat[7] = -Math.sin(radians); + mat[8] = Math.cos(radians); + return retMat; + }; + + cc.math.Matrix3.createByRotationY = function(radians) { + /* + | cos(A) 0 sin(A) | + M = | 0 1 0 | + | -sin(A) 0 cos(A) | + */ + var retMat = new cc.math.Matrix3(), mat = retMat.mat; + mat[0] = Math.cos(radians); + mat[1] = 0.0; + mat[2] = -Math.sin(radians); + + mat[3] = 0.0; + mat[4] = 1.0; + mat[5] = 0.0; + + mat[6] = Math.sin(radians); + mat[7] = 0.0; + mat[8] = Math.cos(radians); + return retMat; + }; + + cc.math.Matrix3.createByRotationZ = function(radians) { + /* + | cos(A) -sin(A) 0 | + M = | sin(A) cos(A) 0 | + | 0 0 1 | + */ + var retMat = new cc.math.Matrix3(), mat = retMat.mat; + mat[0] = Math.cos(radians); + mat[1] = -Math.sin(radians); + mat[2] = 0.0; + + mat[3] = Math.sin(radians); + mat[4] = Math.cos(radians); + mat[5] = 0.0; + + mat[6] = 0.0; + mat[7] = 0.0; + mat[8] = 1.0; + return retMat; + }; + + cc.math.Matrix3.createByRotation = function(radians) { + /* + | cos(A) -sin(A) 0 | + M = | sin(A) cos(A) 0 | + | 0 0 1 | + */ + var retMat = new cc.math.Matrix3(), mat = retMat.mat; + mat[0] = Math.cos(radians); + mat[1] = Math.sin(radians); + mat[2] = 0.0; + + mat[3] = -Math.sin(radians); + mat[4] = Math.cos(radians); + mat[5] = 0.0; + + mat[6] = 0.0; + mat[7] = 0.0; + mat[8] = 1.0; + return retMat; + }; + + cc.math.Matrix3.createByScale = function(x, y) { + var ret = new cc.math.Matrix3(); + ret.identity(); + ret.mat[0] = x; + ret.mat[4] = y; + return ret; + }; + + cc.math.Matrix3.createByTranslation = function(x, y){ + var ret = new cc.math.Matrix3(); + ret.identity(); + ret.mat[6] = x; + ret.mat[7] = y; + return ret; + }; + + cc.math.Matrix3.createByQuaternion = function(quaternion) { //cc.kmMat3RotationQuaternion + if(!quaternion) + return null; + + var ret = new cc.math.Matrix3(), mat = ret.mat; + // First row + mat[0] = 1.0 - 2.0 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z); + mat[1] = 2.0 * (quaternion.x * quaternion.y - quaternion.w * quaternion.z); + mat[2] = 2.0 * (quaternion.x * quaternion.z + quaternion.w * quaternion.y); + + // Second row + mat[3] = 2.0 * (quaternion.x * quaternion.y + quaternion.w * quaternion.z); + mat[4] = 1.0 - 2.0 * (quaternion.x * quaternion.x + quaternion.z * quaternion.z); + mat[5] = 2.0 * (quaternion.y * quaternion.z - quaternion.w * quaternion.x); + + // Third row + mat[6] = 2.0 * (quaternion.x * quaternion.z - quaternion.w * quaternion.y); + mat[7] = 2.0 * (quaternion.y * quaternion.z + quaternion.w * quaternion.x); + mat[8] = 1.0 - 2.0 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y); + return ret; + }; + + proto.rotationToAxisAngle = function() { //cc.kmMat3RotationToAxisAngle + return cc.math.Quaternion.rotationMatrix(this).toAxisAndAngle(); } +})(cc); + - return true; -}; - -cc.kmMat3RotationX = function (pOut, radians) { - /* - | 1 0 0 | - M = | 0 cos(A) -sin(A) | - | 0 sin(A) cos(A) | - - */ - - pOut.mat[0] = 1.0; - pOut.mat[1] = 0.0; - pOut.mat[2] = 0.0; - - pOut.mat[3] = 0.0; - pOut.mat[4] = Math.cos(radians); - pOut.mat[5] = Math.sin(radians); - - pOut.mat[6] = 0.0; - pOut.mat[7] = -Math.sin(radians); - pOut.mat[8] = Math.cos(radians); - - return pOut; -}; - -cc.kmMat3RotationY = function (pOut, radians) { - /* - | cos(A) 0 sin(A) | - M = | 0 1 0 | - | -sin(A) 0 cos(A) | - */ - - pOut.mat[0] = Math.cos(radians); - pOut.mat[1] = 0.0; - pOut.mat[2] = -Math.sin(radians); - - pOut.mat[3] = 0.0; - pOut.mat[4] = 1.0; - pOut.mat[5] = 0.0; - - pOut.mat[6] = Math.sin(radians); - pOut.mat[7] = 0.0; - pOut.mat[8] = Math.cos(radians); - - return pOut; -}; - -cc.kmMat3RotationZ = function (pOut, radians) { - /* - | cos(A) -sin(A) 0 | - M = | sin(A) cos(A) 0 | - | 0 0 1 | - */ - pOut.mat[0] = Math.cos(radians); - pOut.mat[1] = -Math.sin(radians); - pOut.mat[2] = 0.0; - - pOut.mat[3] = Math.sin(radians); - pOut.mat[4] = Math.cos(radians); - pOut.mat[5] = 0.0; - - pOut.mat[6] = 0.0; - pOut.mat[7] = 0.0; - pOut.mat[8] = 1.0; - - return pOut; -}; - -cc.kmMat3Rotation = function (pOut, radians) { - /* - | cos(A) -sin(A) 0 | - M = | sin(A) cos(A) 0 | - | 0 0 1 | - */ - pOut.mat[0] = Math.cos(radians); - pOut.mat[1] = Math.sin(radians); - pOut.mat[2] = 0.0; - - pOut.mat[3] = -Math.sin(radians); - pOut.mat[4] = Math.cos(radians); - pOut.mat[5] = 0.0; - - pOut.mat[6] = 0.0; - pOut.mat[7] = 0.0; - pOut.mat[8] = 1.0; - return pOut; -}; - -cc.kmMat3Scaling = function (pOut, x, y) { -// memset(pOut.mat, 0, sizeof(float) * 9); - cc.kmMat3Identity(pOut); - pOut.mat[0] = x; - pOut.mat[4] = y; - - return pOut; -}; - -cc.kmMat3Translation = function (pOut, x, y) { -// memset(pOut.mat, 0, sizeof(float) * 9); - cc.kmMat3Identity(pOut); - pOut.mat[6] = x; - pOut.mat[7] = y; -// pOut.mat[8] = 1.0; - - return pOut; -}; - -cc.kmMat3RotationQuaternion = function (pOut, pIn) { - if (!pIn || !pOut) - return null; - - // First row - pOut.mat[0] = 1.0 - 2.0 * (pIn.y * pIn.y + pIn.z * pIn.z); - pOut.mat[1] = 2.0 * (pIn.x * pIn.y - pIn.w * pIn.z); - pOut.mat[2] = 2.0 * (pIn.x * pIn.z + pIn.w * pIn.y); - - // Second row - pOut.mat[3] = 2.0 * (pIn.x * pIn.y + pIn.w * pIn.z); - pOut.mat[4] = 1.0 - 2.0 * (pIn.x * pIn.x + pIn.z * pIn.z); - pOut.mat[5] = 2.0 * (pIn.y * pIn.z - pIn.w * pIn.x); - - // Third row - pOut.mat[6] = 2.0 * (pIn.x * pIn.z - pIn.w * pIn.y); - pOut.mat[7] = 2.0 * (pIn.y * pIn.z + pIn.w * pIn.x); - pOut.mat[8] = 1.0 - 2.0 * (pIn.x * pIn.x + pIn.y * pIn.y); - - return pOut; -}; - -cc.kmMat3RotationToAxisAngle = function (pAxis, radians, pIn) { - /*Surely not this easy?*/ - var temp; - cc.kmQuaternionRotationMatrix(temp, pIn); - cc.kmQuaternionToAxisAngle(temp, pAxis, radians); - return pAxis; -}; diff --git a/cocos2d/kazmath/mat4.js b/cocos2d/kazmath/mat4.js index fd1a428ea5..f142132742 100644 --- a/cocos2d/kazmath/mat4.js +++ b/cocos2d/kazmath/mat4.js @@ -730,43 +730,42 @@ cc.kmMat4ExtractRotation = function (pOut, pIn) { pOut.mat[6] = pIn.mat[8]; pOut.mat[7] = pIn.mat[9]; pOut.mat[8] = pIn.mat[10]; - return pOut; }; cc.kmMat4ExtractPlane = function (pOut, pIn, plane) { switch (plane) { - case cc.KM_PLANE_RIGHT: + case cc.math.Plane.RIGHT: pOut.a = pIn.mat[3] - pIn.mat[0]; pOut.b = pIn.mat[7] - pIn.mat[4]; pOut.c = pIn.mat[11] - pIn.mat[8]; pOut.d = pIn.mat[15] - pIn.mat[12]; break; - case cc.KM_PLANE_LEFT: + case cc.math.Plane.LEFT: pOut.a = pIn.mat[3] + pIn.mat[0]; pOut.b = pIn.mat[7] + pIn.mat[4]; pOut.c = pIn.mat[11] + pIn.mat[8]; pOut.d = pIn.mat[15] + pIn.mat[12]; break; - case cc.KM_PLANE_BOTTOM: + case cc.math.Plane.BOTTOM: pOut.a = pIn.mat[3] + pIn.mat[1]; pOut.b = pIn.mat[7] + pIn.mat[5]; pOut.c = pIn.mat[11] + pIn.mat[9]; pOut.d = pIn.mat[15] + pIn.mat[13]; break; - case cc.KM_PLANE_TOP: + case cc.math.Plane.TOP: pOut.a = pIn.mat[3] - pIn.mat[1]; pOut.b = pIn.mat[7] - pIn.mat[5]; pOut.c = pIn.mat[11] - pIn.mat[9]; pOut.d = pIn.mat[15] - pIn.mat[13]; break; - case cc.KM_PLANE_FAR: + case cc.math.Plane.FAR: pOut.a = pIn.mat[3] - pIn.mat[2]; pOut.b = pIn.mat[7] - pIn.mat[6]; pOut.c = pIn.mat[11] - pIn.mat[10]; pOut.d = pIn.mat[15] - pIn.mat[14]; break; - case cc.KM_PLANE_NEAR: + case cc.math.Plane.NEAR: pOut.a = pIn.mat[3] + pIn.mat[2]; pOut.b = pIn.mat[7] + pIn.mat[6]; pOut.c = pIn.mat[11] + pIn.mat[10]; @@ -794,12 +793,10 @@ cc.kmMat4ExtractPlane = function (pOut, pIn, plane) { */ cc.kmMat4RotationToAxisAngle = function (pAxis, radians, pIn) { /*Surely not this easy?*/ - var temp = new cc.kmQuaternion(); - var rotation = new cc.kmMat3(); + var rotation = new cc.math.Matrix3(); cc.kmMat4ExtractRotation(rotation, pIn); - cc.kmQuaternionRotationMatrix(temp, rotation); - cc.kmQuaternionToAxisAngle(temp, pAxis, radians); - return pAxis; + var temp = cc.math.Quaternion.rotationMatrix(rotation); + return temp.toAxisAndAngle(); }; diff --git a/cocos2d/kazmath/plane.js b/cocos2d/kazmath/plane.js index a3b9a0d5bd..94ab4e9b71 100644 --- a/cocos2d/kazmath/plane.js +++ b/cocos2d/kazmath/plane.js @@ -29,131 +29,109 @@ /** * @ignore */ -cc.KM_PLANE_LEFT = 0; +(function(cc){ + cc.math.Plane = function (a, b, c, d) { + if (a && b === undefined) { + this.a = a.a; + this.b = a.b; + this.c = a.c; + this.d = a.d; + } else { + this.a = a || 0; + this.b = b || 0; + this.c = c || 0; + this.d = d || 0; + } + }; + cc.kmPlane = cc.math.Plane; + var proto = cc.math.Plane.prototype; + + cc.math.Plane.LEFT = 0; + + cc.math.Plane.RIGHT = 1; + + cc.math.Plane.BOTTOM = 2; + + cc.math.Plane.TOP = 3; + + cc.math.Plane.NEAR = 4; + + cc.math.Plane.FAR = 5; + + cc.math.Plane.POINT_INFRONT_OF_PLANE = 0; + + cc.math.Plane.POINT_BEHIND_PLANE = 1; + + cc.math.Plane.POINT_ON_PLANE = 2; + + proto.dot = function(vec4){ //cc.kmPlaneDot + return (this.a * vec4.x + this.b * vec4.y + this.c * vec4.z + this.d * vec4.w); + }; + + proto.dotCoord = function(vec3) { //=cc.kmPlaneDotCoord + return (this.a * vec3.x + this.b * vec3.y + this.c * vec3.z + this.d); + }; + + proto.dotNormal = function(vec3) { //=cc.kmPlaneDotNormal + return (this.a * vec3.x + this.b * vec3.y + this.c * vec3.z); + }; + + cc.math.Plane.fromPointNormal = function(vec3, normal) { //cc.kmPlaneFromPointNormal + /* + Planea = Nx + Planeb = Ny + Planec = Nz + Planed = −N⋅P + */ + return new cc.math.Plane(normal.x, normal.y, normal.z, -normal.dot(vec3)); + }; + + cc.math.Plane.fromPoints = function(vec1, vec2, vec3) { //cc.kmPlaneFromPoints + /* + v = (B − A) × (C − A) + n = 1⁄|v| v + Outa = nx + Outb = ny + Outc = nz + Outd = −n⋅A + */ + var v1 = new cc.math.Vec3(vec2), v2 = new cc.math.Vec3(vec3), plane = new cc.math.Plane(); + v1.subtract(vec1); //Create the vectors for the 2 sides of the triangle + v2.subtract(vec1); + v1.cross(v2); // Use the cross product to get the normal + v1.normalize(); //Normalize it and assign to pOut.m_N + + plane.a = v1.x; + plane.b = v1.y; + plane.c = v1.z; + plane.d = v1.scale(-1.0).dot(vec1); + return plane; + }; + + proto.normalize = function(){ //cc.kmPlaneNormalize + var n = new cc.math.Vec3(this.a, this.b, this.c), l = 1.0 / n.length(); //Get 1/length + n.normalize(); //Normalize the vector and assign to pOut + this.a = n.x; + this.b = n.y; + this.c = n.z; + this.d = this.d * l; //Scale the D value and assign to pOut + return this; + }; + + proto.classifyPoint = function(vec3) { + // This function will determine if a point is on, in front of, or behind + // the plane. First we store the dot product of the plane and the point. + var distance = this.a * vec3.x + this.b * vec3.y + this.c * vec3.z + this.d; + + // Simply put if the dot product is greater than 0 then it is infront of it. + // If it is less than 0 then it is behind it. And if it is 0 then it is on it. + if(distance > 0.001) + return cc.math.Plane.POINT_INFRONT_OF_PLANE; + if(distance < -0.001) + return cc.math.Plane.POINT_BEHIND_PLANE; + return cc.math.Plane.POINT_ON_PLANE; + }; +})(cc); -cc.KM_PLANE_RIGHT = 1; - -cc.KM_PLANE_BOTTOM = 2; - -cc.KM_PLANE_TOP = 3; - -cc.KM_PLANE_NEAR = 4; - -cc.KM_PLANE_FAR = 5; - -cc.kmPlane = function (a, b, c, d) { - this.a = a || 0; - this.b = b || 0; - this.c = c || 0; - this.d = d || 0; -}; - -cc.POINT_INFRONT_OF_PLANE = 0; - -cc.POINT_BEHIND_PLANE = 1; - -cc.POINT_ON_PLANE = 2; - -cc.kmPlaneDot = function(pP, pV){ - //a*x + b*y + c*z + d*w - return (pP.a * pV.x + - pP.b * pV.y + - pP.c * pV.z + - pP.d * pV.w); -}; - -cc.kmPlaneDotCoord = function(pP, pV){ - return (pP.a * pV.x + - pP.b * pV.y + - pP.c * pV.z + pP.d); -}; - -cc.kmPlaneDotNormal = function(pP, pV){ - return (pP.a * pV.x + - pP.b * pV.y + - pP.c * pV.z); -}; - -cc.kmPlaneFromPointNormal = function(pOut, pPoint, pNormal){ - /* - Planea = Nx - Planeb = Ny - Planec = Nz - Planed = −N⋅P - */ - pOut.a = pNormal.x; - pOut.b = pNormal.y; - pOut.c = pNormal.z; - pOut.d = - pNormal.dot(pPoint); - - return pOut; -}; - -/** - * Creates a plane from 3 points. The result is stored in pOut. - * pOut is returned. - */ -cc.kmPlaneFromPoints = function(pOut, p1, p2, p3){ - /* - v = (B − A) × (C − A) - n = 1⁄|v| v - Outa = nx - Outb = ny - Outc = nz - Outd = −n⋅A - */ - - var v1 = new cc.math.Vec3(p2), v2 = new cc.math.Vec3(p3); - v1.subtract(p1); //Create the vectors for the 2 sides of the triangle - v2.subtract(p1); - var n = new cc.math.Vec3(v1); - n.cross(v2); // Use the cross product to get the normal - n.normalize(); //Normalize it and assign to pOut.m_N - - pOut.a = n.x; - pOut.b = n.y; - pOut.c = n.z; - pOut.d = n.scale(-1.0).dot(p1); - return pOut; -}; - -cc.kmPlaneNormalize = function(pOut, pP){ - var n = new cc.math.Vec3(); - - n.x = pP.a; - n.y = pP.b; - n.z = pP.c; - - var l = 1.0 / n.length(); //Get 1/length - n.normalize(); //Normalize the vector and assign to pOut - - pOut.a = n.x; - pOut.b = n.y; - pOut.c = n.z; - pOut.d = pP.d * l; //Scale the D value and assign to pOut - - return pOut; -}; - -cc.kmPlaneScale = function(pOut, pP, s){ - cc.log("cc.kmPlaneScale() has not been implemented."); -}; - -/** - * Returns POINT_INFRONT_OF_PLANE if pP is infront of pIn. Returns - * POINT_BEHIND_PLANE if it is behind. Returns POINT_ON_PLANE otherwise - */ -cc.kmPlaneClassifyPoint = function(pIn, pP){ - // This function will determine if a point is on, in front of, or behind - // the plane. First we store the dot product of the plane and the point. - var distance = pIn.a * pP.x + pIn.b * pP.y + pIn.c * pP.z + pIn.d; - - // Simply put if the dot product is greater than 0 then it is infront of it. - // If it is less than 0 then it is behind it. And if it is 0 then it is on it. - if(distance > 0.001) return cc.POINT_INFRONT_OF_PLANE; - if(distance < -0.001) return cc.POINT_BEHIND_PLANE; - - return cc.POINT_ON_PLANE; -}; diff --git a/cocos2d/kazmath/quaternion.js b/cocos2d/kazmath/quaternion.js index 6c7b20ca2b..3b24830871 100644 --- a/cocos2d/kazmath/quaternion.js +++ b/cocos2d/kazmath/quaternion.js @@ -26,440 +26,425 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * The Quaternion class - * @param {Number} x - * @param {Number} y - * @param {Number} z - * @param {Number} w - * @constructor - */ -cc.kmQuaternion = function (x, y, z, w) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; -}; - -///< Returns pOut, sets pOut to the conjugate of pIn -cc.kmQuaternionConjugate = function (pOut, pIn) { - pOut.x = -pIn.x; - pOut.y = -pIn.y; - pOut.z = -pIn.z; - pOut.w = pIn.w; - - return pOut; -}; - -///< Returns the dot product of the 2 quaternions -cc.kmQuaternionDot = function (q1, q2) { - // A dot B = B dot A = AtBt + AxBx + AyBy + AzBz - return (q1.w * q2.w + - q1.x * q2.x + - q1.y * q2.y + - q1.z * q2.z); -}; - -///< Returns the exponential of the quaternion -cc.kmQuaternionExp = function (pOut, pIn) { - //TODO not implement - //cc.assert(0); - return pOut; -}; - -///< Makes the passed quaternion an identity quaternion -cc.kmQuaternionIdentity = function (pOut) { - pOut.x = 0.0; - pOut.y = 0.0; - pOut.z = 0.0; - pOut.w = 1.0; - - return pOut; -}; - -///< Returns the inverse of the passed Quaternion -cc.kmQuaternionInverse = function (pOut, pIn) { - var l = cc.kmQuaternionLength(pIn); - var tmp = new cc.kmQuaternion(); - - if (Math.abs(l) > cc.math.EPSILON) { - pOut.x = 0.0; - pOut.y = 0.0; - pOut.z = 0.0; - pOut.w = 0.0; - return pOut; - } - - ///Get the conjugute and divide by the length - cc.kmQuaternionScale(pOut, - cc.kmQuaternionConjugate(tmp, pIn), 1.0 / l); - - return pOut; -}; - -///< Returns true if the quaternion is an identity quaternion -cc.kmQuaternionIsIdentity = function (pIn) { - return (pIn.x == 0.0 && pIn.y == 0.0 && pIn.z == 0.0 && - pIn.w == 1.0); -}; - -///< Returns the length of the quaternion -cc.kmQuaternionLength = function (pIn) { - return Math.sqrt(cc.kmQuaternionLengthSq(pIn)); -}; - -///< Returns the length of the quaternion squared (prevents a sqrt) -cc.kmQuaternionLengthSq = function (pIn) { - return pIn.x * pIn.x + pIn.y * pIn.y + - pIn.z * pIn.z + pIn.w * pIn.w; -}; - -///< Returns the natural logarithm -cc.kmQuaternionLn = function (pOut, pIn) { - /* - A unit quaternion, is defined by: - Q == (cos(theta), sin(theta) * v) where |v| = 1 - The natural logarithm of Q is, ln(Q) = (0, theta * v) +(function(cc) { + /** + * The Quaternion class + * @param {Number|cc.math.Quaternion} [x=0] + * @param {Number} [y=0] + * @param {Number} [z=0] + * @param {Number} [w=0] + * @constructor */ - //assert(0); - //TODO not implement - return pOut; -}; - -///< Multiplies 2 quaternions together -cc.kmQuaternionMultiply = function (pOut, q1, q2) { - pOut.w = q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z; - pOut.x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y; - pOut.y = q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z; - pOut.z = q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x; - - return pOut; -}; - -///< Normalizes a quaternion -cc.kmQuaternionNormalize = function (pOut, pIn) { - var length = cc.kmQuaternionLength(pIn); - if(Math.abs(length) <= cc.math.EPSILON) - throw "cc.kmQuaternionNormalize(): pIn is an invalid value"; - cc.kmQuaternionScale(pOut, pIn, 1.0 / length); - - return pOut; -}; - -///< Rotates a quaternion around an axis -cc.kmQuaternionRotationAxis = function (pOut, pV, angle) { - var rad = angle * 0.5; - var scale = Math.sin(rad); - - pOut.w = Math.cos(rad); - pOut.x = pV.x * scale; - pOut.y = pV.y * scale; - pOut.z = pV.z * scale; - - return pOut; -}; - -///< Creates a quaternion from a rotation matrix -cc.kmQuaternionRotationMatrix = function (pOut, pIn) { - /* - Note: The OpenGL matrices are transposed from the description below - taken from the Matrix and Quaternion FAQ - - if ( mat[0] > mat[5] && mat[0] > mat[10] ) { // Column 0: - S = sqrt( 1.0 + mat[0] - mat[5] - mat[10] ) * 2; - X = 0.25 * S; - Y = (mat[4] + mat[1] ) / S; - Z = (mat[2] + mat[8] ) / S; - W = (mat[9] - mat[6] ) / S; - } else if ( mat[5] > mat[10] ) { // Column 1: - S = sqrt( 1.0 + mat[5] - mat[0] - mat[10] ) * 2; - X = (mat[4] + mat[1] ) / S; - Y = 0.25 * S; - Z = (mat[9] + mat[6] ) / S; - W = (mat[2] - mat[8] ) / S; - } else { // Column 2: - S = sqrt( 1.0 + mat[10] - mat[0] - mat[5] ) * 2; - X = (mat[2] + mat[8] ) / S; - Y = (mat[9] + mat[6] ) / S; - Z = 0.25 * S; - W = (mat[4] - mat[1] ) / S; - } - */ - var x, y, z, w; - var m4x4 = []; - var scale = 0.0; - var diagonal = 0.0; - - if (!pIn) { - return null; - } - - /* 0 3 6 - 1 4 7 - 2 5 8 - - 0 1 2 3 - 4 5 6 7 - 8 9 10 11 - 12 13 14 15*/ - - m4x4[0] = pIn.mat[0]; - m4x4[1] = pIn.mat[3]; - m4x4[2] = pIn.mat[6]; - m4x4[4] = pIn.mat[1]; - m4x4[5] = pIn.mat[4]; - m4x4[6] = pIn.mat[7]; - m4x4[8] = pIn.mat[2]; - m4x4[9] = pIn.mat[5]; - m4x4[10] = pIn.mat[8]; - m4x4[15] = 1; - var pMatrix = m4x4[0]; - - diagonal = pMatrix[0] + pMatrix[5] + pMatrix[10] + 1; - - if (diagonal > cc.math.EPSILON) { - // Calculate the scale of the diagonal - scale = Math.sqrt(diagonal) * 2; - - // Calculate the x, y, x and w of the quaternion through the respective equation - x = ( pMatrix[9] - pMatrix[6] ) / scale; - y = ( pMatrix[2] - pMatrix[8] ) / scale; - z = ( pMatrix[4] - pMatrix[1] ) / scale; - w = 0.25 * scale; - } else { - // If the first element of the diagonal is the greatest value - if (pMatrix[0] > pMatrix[5] && pMatrix[0] > pMatrix[10]) { - // Find the scale according to the first element, and double that value - scale = Math.sqrt(1.0 + pMatrix[0] - pMatrix[5] - pMatrix[10]) * 2.0; - - // Calculate the x, y, x and w of the quaternion through the respective equation - x = 0.25 * scale; - y = (pMatrix[4] + pMatrix[1] ) / scale; - z = (pMatrix[2] + pMatrix[8] ) / scale; - w = (pMatrix[9] - pMatrix[6] ) / scale; - } - // Else if the second element of the diagonal is the greatest value - else if (pMatrix[5] > pMatrix[10]) { - // Find the scale according to the second element, and double that value - scale = Math.sqrt(1.0 + pMatrix[5] - pMatrix[0] - pMatrix[10]) * 2.0; - - // Calculate the x, y, x and w of the quaternion through the respective equation - x = (pMatrix[4] + pMatrix[1] ) / scale; - y = 0.25 * scale; - z = (pMatrix[9] + pMatrix[6] ) / scale; - w = (pMatrix[2] - pMatrix[8] ) / scale; + cc.math.Quaternion = function (x, y, z, w) { + if (x && y === undefined) { + this.x = x.x; + this.y = x.y; + this.z = x.z; + this.w = x.w; } else { - // Else the third element of the diagonal is the greatest value - - // Find the scale according to the third element, and double that value - scale = Math.sqrt(1.0 + pMatrix[10] - pMatrix[0] - pMatrix[5]) * 2.0; - - // Calculate the x, y, x and w of the quaternion through the respective equation - x = (pMatrix[2] + pMatrix[8] ) / scale; - y = (pMatrix[9] + pMatrix[6] ) / scale; - z = 0.25 * scale; - w = (pMatrix[4] - pMatrix[1] ) / scale; + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; } - } - - pOut.x = x; - pOut.y = y; - pOut.z = z; - pOut.w = w; - - return pOut; -}; + }; + cc.kmQuaternion = cc.math.Quaternion; + var proto = cc.math.Quaternion.prototype; -///< Create a quaternion from yaw, pitch and roll -cc.kmQuaternionRotationYawPitchRoll = function (pOut, yaw, pitch, roll) { - var ex, ey, ez; // temp half euler angles - var cr, cp, cy, sr, sp, sy, cpcy, spsy; // temp vars in roll,pitch yaw - - ex = cc.degreesToRadians(pitch) / 2.0; // convert to rads and half them - ey = cc.degreesToRadians(yaw) / 2.0; - ez = cc.degreesToRadians(roll) / 2.0; - - cr = Math.cos(ex); - cp = Math.cos(ey); - cy = Math.cos(ez); - - sr = Math.sin(ex); - sp = Math.sin(ey); - sy = Math.sin(ez); - - cpcy = cp * cy; - spsy = sp * sy; + /** + * Sets the conjugate of quaternion to self + * @param {cc.math.Quaternion} quaternion + */ + proto.conjugate = function (quaternion) { //= cc.kmQuaternionConjugate + this.x = -quaternion.x; + this.y = -quaternion.y; + this.z = -quaternion.z; + this.w = quaternion.w; + return this; + }; + + /** + * Returns the dot product of the current quaternion and parameter quaternion + * @param quaternion + * @returns {number} + */ + proto.dot = function(quaternion) { // = cc.kmQuaternionDot + // A dot B = B dot A = AtBt + AxBx + AyBy + AzBz + return (this.w * quaternion.w + this.x * quaternion.x + this.y * quaternion.y + this.z * quaternion.z); + }; + + /** + * Returns the exponential of the quaternion, this function doesn't implemented. + * @returns {cc.math.Quaternion} + */ + proto.exponential = function(){ //=cc.kmQuaternionExp + return this; + }; - pOut.w = cr * cpcy + sr * spsy; - - pOut.x = sr * cpcy - cr * spsy; - pOut.y = cr * sp * cy + sr * cp * sy; - pOut.z = cr * cp * sy - sr * sp * cy; + /** + * Makes the current quaternion an identity quaternion + */ + proto.identity = function(){ //=cc.kmQuaternionIdentity + this.x = 0.0; + this.y = 0.0; + this.z = 0.0; + this.w = 1.0; + return this; + }; + + /** + * Inverses the value of current Quaternion + */ + proto.inverse = function(){ //=cc.kmQuaternionInverse + var len = this.length(); + if (Math.abs(len) > cc.math.EPSILON) { + this.x = 0.0; + this.y = 0.0; + this.z = 0.0; + this.w = 0.0; + return this; + } - cc.kmQuaternionNormalize(pOut, pOut); + ///Get the conjugute and divide by the length + this.conjugate(this).scale(1.0 / len); + return this; + }; - return pOut; -}; + /** + * Returns true if the quaternion is an identity quaternion + * @returns {boolean} + */ + proto.isIdentity = function(){ //=cc.kmQuaternionIsIdentity + return (this.x == 0.0 && this.y == 0.0 && this.z == 0.0 && this.w == 1.0); + }; -///< Interpolate between 2 quaternions -cc.kmQuaternionSlerp = function (pOut, q1, q2, t) { - /*float CosTheta = Q0.DotProd(Q1); - float Theta = acosf(CosTheta); - float SinTheta = sqrtf(1.0f-CosTheta*CosTheta); - - float Sin_T_Theta = sinf(T*Theta)/SinTheta; - float Sin_OneMinusT_Theta = sinf((1.0f-T)*Theta)/SinTheta; - - Quaternion Result = Q0*Sin_OneMinusT_Theta; - Result += (Q1*Sin_T_Theta); - - return Result;*/ - - if (q1.x == q2.x && - q1.y == q2.y && - q1.z == q2.z && - q1.w == q2.w) { - - pOut.x = q1.x; - pOut.y = q1.y; - pOut.z = q1.z; - pOut.w = q1.w; - - return pOut; - } - - var ct = cc.kmQuaternionDot(q1, q2); - var theta = Math.acos(ct); - var st = Math.sqrt(1.0 - cc.math.square(ct)); - - var stt = Math.sin(t * theta) / st; - var somt = Math.sin((1.0 - t) * theta) / st; - - var temp = new cc.kmQuaternion(), temp2 = new cc.kmQuaternion(); - cc.kmQuaternionScale(temp, q1, somt); - cc.kmQuaternionScale(temp2, q2, stt); - cc.kmQuaternionAdd(pOut, temp, temp2); - - return pOut; -}; - -///< Get the axis and angle of rotation from a quaternion -cc.kmQuaternionToAxisAngle = function (pIn, pAxis, pAngle) { - var tempAngle; // temp angle - var scale; // temp vars - - tempAngle = Math.acos(pIn.w); - scale = Math.sqrt(cc.math.square(pIn.x) + cc.math.square(pIn.y) + cc.math.square(pIn.z)); - - if (((scale > -cc.math.EPSILON) && scale < cc.math.EPSILON) - || (scale < 2 * Math.PI + cc.math.EPSILON && scale > 2 * Math.PI - cc.math.EPSILON)) { // angle is 0 or 360 so just simply set axis to 0,0,1 with angle 0 - pAngle = 0.0; - - pAxis.x = 0.0; - pAxis.y = 0.0; - pAxis.z = 1.0; - } else { - pAngle = tempAngle * 2.0; // angle in radians - - pAxis.x = pIn.x / scale; - pAxis.y = pIn.y / scale; - pAxis.z = pIn.z / scale; - pAxis.normalize(); - } -}; - -///< Scale a quaternion -cc.kmQuaternionScale = function (pOut, pIn, s) { - pOut.x = pIn.x * s; - pOut.y = pIn.y * s; - pOut.z = pIn.z * s; - pOut.w = pIn.w * s; + /** + * Returns the length of the quaternion + * @returns {number} + */ + proto.length = function() { //=cc.kmQuaternionLength + return Math.sqrt(this.lengthSq()); + }; - return pOut; -}; - -cc.kmQuaternionAssign = function (pOut, pIn) { - pOut.x = pIn.x; - pOut.y = pIn.y; - pOut.z = pIn.z; - pOut.w = pIn.w; - - return pOut; -}; + /** + * Returns the length of the quaternion squared (prevents a sqrt) + * @returns {number} + */ + proto.lengthSq = function() { //=cc.kmQuaternionLengthSq + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + }; + + /** + * Uses current quaternion multiplies other quaternion. + * @param {cc.math.Quaternion} quaternion + * @returns {cc.math.Quaternion} + */ + proto.multiply = function(quaternion) { //cc.kmQuaternionMultiply + var x = this.x, y = this.y, z = this.z, w = this.w; + this.w = w * quaternion.w - x * quaternion.x - y * quaternion.y - z * quaternion.z; + this.x = w * quaternion.x + x * quaternion.w + y * quaternion.z - z * quaternion.y; + this.y = w * quaternion.y + y * quaternion.w + z * quaternion.x - x * quaternion.z; + this.z = w * quaternion.z + z * quaternion.w + x * quaternion.y - y * quaternion.x; + return this; + }; + + /** + * Normalizes a quaternion + * @returns {cc.math.Quaternion} + */ + proto.normalize = function(){ //=cc.kmQuaternionNormalize + var length = this.length(); + if (Math.abs(length) <= cc.math.EPSILON) + throw "current quaternion is an invalid value"; + this.scale(1.0 / length); + return this; + }; + + /** + * Rotates a quaternion around an axis and an angle + * @param {cc.math.Vec3} axis + * @param {Number} angle + */ + proto.rotationAxis = function(axis, angle){ //cc.kmQuaternionRotationAxis + var rad = angle * 0.5, scale = Math.sin(rad); + this.w = Math.cos(rad); + this.x = axis.x * scale; + this.y = axis.y * scale; + this.z = axis.z * scale; + return this; + }; + + /** + * Creates a quaternion from a rotation matrix + * @param mat3 + * @returns {*} + */ + cc.math.Quaternion.rotationMatrix = function (mat3) { //cc.kmQuaternionRotationMatrix + if (!mat3) + return null; + + var x, y, z, w; + var m4x4 = [], mat = mat3.mat, scale = 0.0; + + /* 0 3 6 + 1 4 7 + 2 5 8 + + 0 1 2 3 + 4 5 6 7 + 8 9 10 11 + 12 13 14 15*/ + m4x4[0] = mat[0]; + m4x4[1] = mat[3]; + m4x4[2] = mat[6]; + m4x4[4] = mat[1]; + m4x4[5] = mat[4]; + m4x4[6] = mat[7]; + m4x4[8] = mat[2]; + m4x4[9] = mat[5]; + m4x4[10] = mat[8]; + m4x4[15] = 1; + var pMatrix = m4x4[0]; + + var diagonal = pMatrix[0] + pMatrix[5] + pMatrix[10] + 1; + if (diagonal > cc.math.EPSILON) { + // Calculate the scale of the diagonal + scale = Math.sqrt(diagonal) * 2; -cc.kmQuaternionAdd = function (pOut, pQ1, pQ2) { - pOut.x = pQ1.x + pQ2.x; - pOut.y = pQ1.y + pQ2.y; - pOut.z = pQ1.z + pQ2.z; - pOut.w = pQ1.w + pQ2.w; - - return pOut; -}; - -/** Adapted from the OGRE engine! - - Gets the shortest arc quaternion to rotate this vector to the destination - vector. - @remarks - If you call this with a dest vector that is close to the inverse - of this vector, we will rotate 180 degrees around the 'fallbackAxis' - (if specified, or a generated axis if not) since in this case - ANY axis of rotation is valid. - */ -cc.kmQuaternionRotationBetweenVec3 = function (pOut, vec1, vec2, fallback) { - var v1 = new cc.math.Vec3(vec1), v2 = new cc.math.Vec3(vec2); - v1.normalize(); - v2.normalize(); - var a = v1.dot(v2); - - if (a >= 1.0) { - cc.kmQuaternionIdentity(pOut); - return pOut; - } - - if (a < (1e-6 - 1.0)) { - if (Math.abs(fallback.lengthSq()) < cc.math.EPSILON) { - cc.kmQuaternionRotationAxis(pOut, fallback, Math.PI); + // Calculate the x, y, x and w of the quaternion through the respective equation + x = ( pMatrix[9] - pMatrix[6] ) / scale; + y = ( pMatrix[2] - pMatrix[8] ) / scale; + z = ( pMatrix[4] - pMatrix[1] ) / scale; + w = 0.25 * scale; + } else { + // If the first element of the diagonal is the greatest value + if (pMatrix[0] > pMatrix[5] && pMatrix[0] > pMatrix[10]) { + // Find the scale according to the first element, and double that value + scale = Math.sqrt(1.0 + pMatrix[0] - pMatrix[5] - pMatrix[10]) * 2.0; + + // Calculate the x, y, x and w of the quaternion through the respective equation + x = 0.25 * scale; + y = (pMatrix[4] + pMatrix[1] ) / scale; + z = (pMatrix[2] + pMatrix[8] ) / scale; + w = (pMatrix[9] - pMatrix[6] ) / scale; + } + // Else if the second element of the diagonal is the greatest value + else if (pMatrix[5] > pMatrix[10]) { + // Find the scale according to the second element, and double that value + scale = Math.sqrt(1.0 + pMatrix[5] - pMatrix[0] - pMatrix[10]) * 2.0; + + // Calculate the x, y, x and w of the quaternion through the respective equation + x = (pMatrix[4] + pMatrix[1] ) / scale; + y = 0.25 * scale; + z = (pMatrix[9] + pMatrix[6] ) / scale; + w = (pMatrix[2] - pMatrix[8] ) / scale; + } else { + // Else the third element of the diagonal is the greatest value + + // Find the scale according to the third element, and double that value + scale = Math.sqrt(1.0 + pMatrix[10] - pMatrix[0] - pMatrix[5]) * 2.0; + + // Calculate the x, y, x and w of the quaternion through the respective equation + x = (pMatrix[2] + pMatrix[8] ) / scale; + y = (pMatrix[9] + pMatrix[6] ) / scale; + z = 0.25 * scale; + w = (pMatrix[4] - pMatrix[1] ) / scale; + } + } + return new cc.math.Quaternion(x, y, z, w); + }; + + /** + * Create a quaternion from yaw, pitch and roll + * @param yaw + * @param pitch + * @param roll + * @returns {cc.math.Quaternion} + */ + cc.math.Quaternion.rotationYawPitchRoll = function (yaw, pitch, roll) { //cc.kmQuaternionRotationYawPitchRoll + var ex, ey, ez; // temp half euler angles + var cr, cp, cy, sr, sp, sy, cpcy, spsy; // temp vars in roll,pitch yaw + + ex = cc.degreesToRadians(pitch) / 2.0; // convert to rads and half them + ey = cc.degreesToRadians(yaw) / 2.0; + ez = cc.degreesToRadians(roll) / 2.0; + + cr = Math.cos(ex); + cp = Math.cos(ey); + cy = Math.cos(ez); + + sr = Math.sin(ex); + sp = Math.sin(ey); + sy = Math.sin(ez); + + cpcy = cp * cy; + spsy = sp * sy; + + var ret = new cc.math.Quaternion(); + ret.w = cr * cpcy + sr * spsy; + ret.x = sr * cpcy - cr * spsy; + ret.y = cr * sp * cy + sr * cp * sy; + ret.z = cr * cp * sy - sr * sp * cy; + ret.normalize(); + return ret; + }; + + /** + * Interpolate with other quaternions + * @param {cc.math.Quaternion} quaternion + * @param {Number} t + * @returns {cc.math.Quaternion} + */ + proto.slerp = function(quaternion, t) { //=cc.kmQuaternionSlerp + if (this.x === quaternion.x && this.y === quaternion.y && this.z === quaternion.z && this.w === quaternion.w) { + return this; + } + var ct = this.dot(quaternion), theta = Math.acos(ct), st = Math.sqrt(1.0 - cc.math.square(ct)); + var stt = Math.sin(t * theta) / st, somt = Math.sin((1.0 - t) * theta) / st; + var temp2 = new cc.math.Quaternion(quaternion); + this.scale(somt); + temp2.scale(stt); + this.add(temp2); + return this; + }; + + /** + * Get the axis and angle of rotation from a quaternion + * @returns {{axis: cc.math.Vec3, angle: number}} + */ + proto.toAxisAndAngle = function(){ //=cc.kmQuaternionToAxisAngle + var tempAngle; // temp angle + var scale; // temp vars + var retAngle, retAxis = new cc.math.Vec3(); + + tempAngle = Math.acos(this.w); + scale = Math.sqrt(cc.math.square(this.x) + cc.math.square(this.y) + cc.math.square(this.z)); + + if (((scale > -cc.math.EPSILON) && scale < cc.math.EPSILON) + || (scale < 2 * Math.PI + cc.math.EPSILON && scale > 2 * Math.PI - cc.math.EPSILON)) { // angle is 0 or 360 so just simply set axis to 0,0,1 with angle 0 + retAngle = 0.0; + retAxis.x = 0.0; + retAxis.y = 0.0; + retAxis.z = 1.0; } else { - var X = new cc.math.Vec3(1.0, 0.0, 0.0); - var axis = new cc.math.Vec3(X); - axis.cross(vec1); + retAngle = tempAngle * 2.0; // angle in radians + retAxis.x = this.x / scale; + retAxis.y = this.y / scale; + retAxis.z = this.z / scale; + retAxis.normalize(); + } + return {axis: retAxis, angle: retAngle}; + }; - //If axis is zero - if (Math.abs(axis.lengthSq()) < cc.math.EPSILON) { - axis.fill(0.0, 1.0, 0.0); + /** + * Scale a quaternion + * @param {Number} scale + */ + proto.scale = function(scale) { //cc.kmQuaternionScale + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + return this; + }; + + /** + * Assign current quaternion value from a quaternion. + * @param {cc.math.Quaternion} quaternion + * @returns {cc.math.Quaternion} current quaternion + */ + proto.assign = function(quaternion){ //=cc.kmQuaternionAssign + this.x = quaternion.x; + this.y = quaternion.y; + this.z = quaternion.z; + this.w = quaternion.w; + return this; + }; + + /** + * Adds other quaternion + * @param {cc.math.Quaternion} quaternion + * @returns {cc.math.Quaternion} + */ + proto.add = function(quaternion) { //cc.kmQuaternionAdd + this.x += quaternion.x; + this.y += quaternion.y; + this.z += quaternion.z; + this.w += quaternion.w; + return this; + }; + + /** + *

    + * Adapted from the OGRE engine!
    + * Gets the shortest arc quaternion to rotate this vector to the destination vector.
    + * @remarks
    + * If you call this with a destination vector that is close to the inverse
    + * of this vector, we will rotate 180 degrees around the 'fallbackAxis'
    + * (if specified, or a generated axis if not) since in this case ANY axis of rotation is valid. + *

    + * @param {cc.math.Vec3} vec1 + * @param {cc.math.Vec3} vec2 + * @param {cc.math.Vec3} fallback + * @returns {cc.math.Quaternion} + */ + cc.math.Quaternion.rotationBetweenVec3 = function(vec1, vec2, fallback) { //cc.kmQuaternionRotationBetweenVec3 + var v1 = new cc.math.Vec3(vec1), v2 = new cc.math.Vec3(vec2); + v1.normalize(); + v2.normalize(); + var a = v1.dot(v2), quaternion = new cc.math.Quaternion(); + + if (a >= 1.0) { + quaternion.identity(); + return quaternion; + } + + if (a < (1e-6 - 1.0)) { + if (Math.abs(fallback.lengthSq()) < cc.math.EPSILON) { + quaternion.rotationAxis(fallback, Math.PI); + } else { + var axis = new cc.math.Vec3(1.0, 0.0, 0.0); axis.cross(vec1); + + //If axis is zero + if (Math.abs(axis.lengthSq()) < cc.math.EPSILON) { + axis.fill(0.0, 1.0, 0.0); + axis.cross(vec1); + } + axis.normalize(); + quaternion.rotationAxis(axis, Math.PI); } - axis.normalize(); - cc.kmQuaternionRotationAxis(pOut, axis, Math.PI); + } else { + var s = Math.sqrt((1 + a) * 2), invs = 1 / s; + v1.cross(v2); + quaternion.x = v1.x * invs; + quaternion.y = v1.y * invs; + quaternion.z = v1.z * invs; + quaternion.w = s * 0.5; + quaternion.normalize(); } - } else { - var s = Math.sqrt((1 + a) * 2), invs = 1 / s; - v1.cross(v2); - - pOut.x = v1.x * invs; - pOut.y = v1.y * invs; - pOut.z = v1.z * invs; - pOut.w = s * 0.5; - - cc.kmQuaternionNormalize(pOut, pOut); - } - return pOut; -}; - -cc.kmQuaternionMultiplyVec3 = function (pOut, q, v) { - var uv = new cc.math.Vec3(q), uuv = new cc.math.Vec3(q); - uv.cross(v); - uuv.cross(uv); - - uv.scale((2.0 * q.w)); - uuv.scale(2.0); - - pOut.fill(v); - pOut.add(uv); - pOut.add(uuv); - return pOut; -}; + return quaternion; + }; + + /** + * Current quaternion multiplies a vec3 + * @param {cc.math.Vec3} vec + * @returns {cc.math.Vec3} + */ + proto.multiplyVec3 = function(vec){ //=cc.kmQuaternionMultiplyVec3 + var x = this.x, y = this.y, z = this.z, retVec = new cc.math.Vec3(vec); + var uv = new cc.math.Vec3(x, y, z), uuv = new cc.math.Vec3(x, y, z); + uv.cross(vec); + uuv.cross(uv); + uv.scale((2.0 * q.w)); + uuv.scale(2.0); + + retVec.add(uv); + retVec.add(uuv); + return retVec; + }; +})(cc); + diff --git a/cocos2d/kazmath/vec3.js b/cocos2d/kazmath/vec3.js index 77fd12f3da..18200dfa8b 100644 --- a/cocos2d/kazmath/vec3.js +++ b/cocos2d/kazmath/vec3.js @@ -28,7 +28,7 @@ (function(cc) { cc.kmVec3 = cc.math.Vec3 = function (x, y, z) { - if(y === undefined){ + if(x && y === undefined){ this.x = x.x; this.y = x.y; this.z = x.z; @@ -42,7 +42,7 @@ var proto = cc.math.Vec3.prototype; proto.fill = function (x, y, z) { // =cc.kmVec3Fill - if (y === undefined) { + if (x && y === undefined) { this.x = x.x; this.y = x.y; this.z = x.z; @@ -124,10 +124,8 @@ b = (a×M)T Out = 1⁄bw(bx, by, bz) */ - var v = new cc.kmVec4(); - var inV = new cc.kmVec4(); - cc.kmVec4Fill(inV, this.x, this.y, this.z, 1.0); - cc.kmVec4Transform(v, inV, mat4); + var v = new cc.math.Vec4(this.x, this.y, this.z, 1.0); + v.transform(mat4); this.x = v.x / v.w; this.y = v.y / v.w; this.z = v.z / v.w; @@ -179,13 +177,11 @@ return vec; }; - cc.mat.Vec3.toTypeArray = function(vec){ //cc.kmVec3ToTypeArray - if(!vec) - return null; + proto.toTypeArray = function(){ //cc.kmVec3ToTypeArray var tyArr = new Float32Array(3); - tyArr[0] = vec.x; - tyArr[1] = vec.y; - tyArr[2] = vec.z; + tyArr[0] = this.x; + tyArr[1] = this.y; + tyArr[2] = this.z; return tyArr; }; })(cc); diff --git a/cocos2d/kazmath/vec4.js b/cocos2d/kazmath/vec4.js index 20c8c78118..bb4e2ac807 100644 --- a/cocos2d/kazmath/vec4.js +++ b/cocos2d/kazmath/vec4.js @@ -26,133 +26,133 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -cc.kmVec4 = function (x, y, z, w) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; -}; - - -cc.kmVec4Fill = function(outVec, x, y ,z, w){ - outVec.x = x; - outVec.y = y; - outVec.z = z; - outVec.w = w; - return outVec; -}; - -cc.kmVec4Add = function(outVec, pV1, pV2){ - outVec.x = pV1.x + pV2.x; - outVec.y = pV1.y + pV2.y; - outVec.z = pV1.z + pV2.z; - outVec.w = pV1.w + pV2.w; - - return outVec; -}; - -cc.kmVec4Dot = function( vec1, vec2){ - return ( vec1.x * vec2.x - + vec1.y * vec2.y - + vec1.z * vec2.z - + vec1.w * vec2.w ); -}; - -cc.kmVec4Length = function(inVec){ - return Math.sqrt(cc.math.square(inVec.x) + cc.math.square(inVec.y) + cc.math.square(inVec.z) + cc.math.square(inVec.w)); -}; - -cc.kmVec4LengthSq = function(inVec){ - return cc.math.square(inVec.x) + cc.math.square(inVec.y) + cc.math.square(inVec.z) + cc.math.square(inVec.w); -}; - -cc.kmVec4Lerp = function(outVec, pV1, pV2, t){ - return outVec; -}; - -cc.kmVec4Normalize = function(outVec, inVec){ - var l = 1.0 / cc.kmVec4Length(inVec); - - outVec.x *= l; - outVec.y *= l; - outVec.z *= l; - outVec.w *= l; - - return outVec; -}; - -cc.kmVec4Scale = function(outVec, inVec, scale){ - cc.kmVec4Normalize(outVec, inVec); - - outVec.x *= scale; - outVec.y *= scale; - outVec.z *= scale; - outVec.w *= scale; - return outVec; -}; - -cc.kmVec4Subtract = function(outVec,vec1, vec2){ - outVec.x = vec1.x - vec2.x; - outVec.y = vec1.y - vec2.y; - outVec.z = vec1.z - vec2.z; - outVec.w = vec1.w - vec2.w; - - return outVec; -}; - -cc.kmVec4Transform = function(outVec, vec,mat4Obj){ - outVec.x = vec.x * mat4Obj.mat[0] + vec.y * mat4Obj.mat[4] + vec.z * mat4Obj.mat[8] + vec.w * mat4Obj.mat[12]; - outVec.y = vec.x * mat4Obj.mat[1] + vec.y * mat4Obj.mat[5] + vec.z * mat4Obj.mat[9] + vec.w * mat4Obj.mat[13]; - outVec.z = vec.x * mat4Obj.mat[2] + vec.y * mat4Obj.mat[6] + vec.z * mat4Obj.mat[10] + vec.w * mat4Obj.mat[14]; - outVec.w = vec.x * mat4Obj.mat[3] + vec.y * mat4Obj.mat[7] + vec.z * mat4Obj.mat[11] + vec.w * mat4Obj.mat[15]; - return outVec; -}; - -cc.kmVec4TransformArray = function(outVec,outStride,vecObj,stride,mat4Obj,count){ - var i = 0; - //Go through all of the vectors - while (i < count) { - var currIn = vecObj + (i * stride); //Get a pointer to the current input - var out = outVec + (i * outStride); //and the current output - cc.kmVec4Transform(out, currIn, mat4Obj); //Perform transform on it - ++i; - } - - return outVec; -}; - -cc.kmVec4AreEqual = function(vec1,vec2){ - return ( - (vec1.x < vec2.x + cc.math.EPSILON && vec1.x > vec2.x - cc.math.EPSILON) && - (vec1.y < vec2.y + cc.math.EPSILON && vec1.y > vec2.y - cc.math.EPSILON) && - (vec1.z < vec2.z + cc.math.EPSILON && vec1.z > vec2.z - cc.math.EPSILON) && - (vec1.w < vec2.w + cc.math.EPSILON && vec1.w > vec2.w - cc.math.EPSILON) - ); -}; - -cc.kmVec4Assign = function(destVec, srcVec){ - if(destVec == srcVec){ - cc.log("destVec and srcVec are same object"); - return destVec; - } - - destVec.x = srcVec.x; - destVec.y = srcVec.y; - destVec.z = srcVec.z; - destVec.w = srcVec.w; - - return destVec; -}; - -cc.kmVec4ToTypeArray = function(vecValue){ - if(!vecValue) - return null; - - var tyArr = new Float32Array(4); - tyArr[0] = vecValue.x; - tyArr[1] = vecValue.y; - tyArr[2] = vecValue.z; - tyArr[3] = vecValue.w; - return tyArr; -}; +(function(cc) { + cc.math.Vec4 = function (x, y, z, w) { + if (x && y === undefined) { + this.x = x.x; + this.y = x.y; + this.z = x.z; + this.w = x.w; + } else { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }; + cc.kmVec4 = cc.math.Vec4; + var proto = cc.math.Vec4.prototype; + + proto.fill = function (x, y, z, w) { //=cc.kmVec4Fill + if (x && y === undefined) { + this.x = x.x; + this.y = x.y; + this.z = x.z; + this.w = x.w; + } else { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + }; + + proto.add = function(vec) { //cc.kmVec4Add + if(!vec) + return this; + this.x += vec.x; + this.y += vec.y; + this.z += vec.z; + this.w += vec.w; + return this; + }; + + proto.dot = function(vec){ //cc.kmVec4Dot + return ( this.x * vec.x + this.y * vec.y + this.z * vec.z + this.w * vec.w ); + }; + + proto.length = function(){ //=cc.kmVec4Length + return Math.sqrt(cc.math.square(this.x) + cc.math.square(this.y) + cc.math.square(this.z) + cc.math.square(this.w)); + }; + + proto.lengthSq = function(){ //=cc.kmVec4LengthSq + return cc.math.square(this.x) + cc.math.square(this.y) + cc.math.square(this.z) + cc.math.square(this.w); + }; + + proto.lerp = function(vec, t){ //= cc.kmVec4Lerp + //not implemented + return this; + }; + + proto.normalize = function() { // cc.kmVec4Normalize + var l = 1.0 / this.length(); + this.x *= l; + this.y *= l; + this.z *= l; + this.w *= l; + return this; + }; + + proto.scale = function(scale){ //= cc.kmVec4Scale + /// Scales a vector to the required length. This performs a Normalize before multiplying by S. + this.normalize(); + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + return this; + }; + + proto.subtract = function(vec) { + this.x -= vec.x; + this.y -= vec.y; + this.z -= vec.z; + this.w -= vec.w; + }; + + proto.transform = function(mat4) { + var x = this.x, y = this.y, z = this.z, w = this.w, mat = mat4.mat; + this.x = x * mat[0] + y * mat[4] + z * mat[8] + w * mat[12]; + this.y = x * mat[1] + y * mat[5] + z * mat[9] + w * mat[13]; + this.z = x * mat[2] + y * mat[6] + z * mat[10] + w * mat[14]; + this.w = x * mat[3] + y * mat[7] + z * mat[11] + w * mat[15]; + return this; + }; + + cc.math.Vec4.transformArray = function(vecArray, mat4){ + var retArray = []; + for (var i = 0; i < vecArray.length; i++) { + var selVec = new cc.math.Vec4(vecArray[i]); + selVec.transform(mat4); + retArray.push(selVec); + } + return retArray; + }; + + proto.equals = function(vec){ //=cc.kmVec4AreEqual + var EPSILON = cc.math.EPSILON; + return (this.x < vec.x + EPSILON && this.x > vec.x - EPSILON) && + (this.y < vec.y + EPSILON && this.y > vec.y - EPSILON) && + (this.z < vec.z + EPSILON && this.z > vec.z - EPSILON) && + (this.w < vec.w + EPSILON && this.w > vec.w - EPSILON); + }; + + proto.assign = function(vec) { //= cc.kmVec4Assign + this.x = vec.x; + this.y = vec.y; + this.z = vec.z; + this.w = vec.w; + return this; + }; + + proto.toTypeArray = function(){ //cc.kmVec4ToTypeArray + var tyArr = new Float32Array(4); + tyArr[0] = this.x; + tyArr[1] = this.y; + tyArr[2] = this.z; + tyArr[3] = this.w; + return tyArr; + }; +})(cc); + From 876527a98590a0c60440d2ebaf0ca1cef47713cc Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 10 Mar 2015 17:00:48 +0800 Subject: [PATCH 1400/1564] Fixed parser is not exists. --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 7b719077a0..e3a9f47f3f 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1250,6 +1250,7 @@ var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, + {name: "NodeObjectData", handle: parser.initSingleNode}, {name: "LayerObjectData", handle: parser.initSingleNode}, {name: "SpriteObjectData", handle: parser.initSprite}, {name: "ParticleObjectData", handle: parser.initParticle}, From d38b562b0b6ec289d43f5c9b7de15d53d53bad5d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 10 Mar 2015 18:08:18 +0800 Subject: [PATCH 1401/1564] Use cc.defineGetterSetter to replace Object.defineProperties for performance on firefox --- cocos2d/core/platform/CCTypesWebGL.js | 561 +++++++++--------- .../CCRenderTextureCanvasRenderCmd.js | 2 +- 2 files changed, 281 insertions(+), 282 deletions(-) diff --git a/cocos2d/core/platform/CCTypesWebGL.js b/cocos2d/core/platform/CCTypesWebGL.js index 643b973aa1..dbcd2ad478 100644 --- a/cocos2d/core/platform/CCTypesWebGL.js +++ b/cocos2d/core/platform/CCTypesWebGL.js @@ -84,9 +84,7 @@ cc._tmp.WebGLColor = function () { * @type {number} */ cc.Color.BYTES_PER_ELEMENT = 4; - var _p = cc.Color.prototype; - _p._getR = function () { return this._rU8[0]; }; @@ -124,7 +122,6 @@ cc._tmp.WebGLColor = function () { _p.a; cc.defineGetterSetter(_p, "a", _p._getA, _p._setA); - //redefine cc.Vertex2F /** * @class cc.Vertex2F @@ -148,26 +145,26 @@ cc._tmp.WebGLColor = function () { * @type {number} */ cc.Vertex2F.BYTES_PER_ELEMENT = 8; - Object.defineProperties(cc.Vertex2F.prototype, { - x: { - get: function () { - return this._xF32[0]; - }, - set: function (xValue) { - this._xF32[0] = xValue; - }, - enumerable: true - }, - y: { - get: function () { - return this._yF32[0]; - }, - set: function (yValue) { - this._yF32[0] = yValue; - }, - enumerable: true - } - }); + + _p = cc.Vertex2F.prototype; + _p._getX = function () { + return this._xF32[0]; + }; + _p._setX = function (xValue) { + this._xF32[0] = xValue; + }; + _p._getY = function () { + return this._yF32[0]; + }; + _p._setY = function (yValue) { + this._yF32[0] = yValue; + }; + /** @expose */ + _p.x; + cc.defineGetterSetter(_p, "x", _p._getX, _p._setX); + /** @expose */ + _p.y; + cc.defineGetterSetter(_p, "y", _p._getY, _p._setY); // redefine cc.Vertex3F /** @@ -196,35 +193,35 @@ cc._tmp.WebGLColor = function () { * @type {number} */ cc.Vertex3F.BYTES_PER_ELEMENT = 12; - Object.defineProperties(cc.Vertex3F.prototype, { - x: { - get: function () { - return this._xF32[0]; - }, - set: function (xValue) { - this._xF32[0] = xValue; - }, - enumerable: true - }, - y: { - get: function () { - return this._yF32[0]; - }, - set: function (yValue) { - this._yF32[0] = yValue; - }, - enumerable: true - }, - z: { - get: function () { - return this._zF32[0]; - }, - set: function (zValue) { - this._zF32[0] = zValue; - }, - enumerable: true - } - }); + + _p = cc.Vertex3F.prototype; + _p._getX = function () { + return this._xF32[0]; + }; + _p._setX = function (xValue) { + this._xF32[0] = xValue; + }; + _p._getY = function () { + return this._yF32[0]; + }; + _p._setY = function (yValue) { + this._yF32[0] = yValue; + }; + _p._getZ = function () { + return this._zF32[0]; + }; + _p._setZ = function (zValue) { + this._zF32[0] = zValue; + }; + /** @expose */ + _p.x; + cc.defineGetterSetter(_p, "x", _p._getX, _p._setX); + /** @expose */ + _p.y; + cc.defineGetterSetter(_p, "y", _p._getY, _p._setY); + /** @expose */ + _p.z; + cc.defineGetterSetter(_p, "z", _p._getZ, _p._setZ); // redefine cc.Tex2F /** @@ -249,26 +246,26 @@ cc._tmp.WebGLColor = function () { * @type {number} */ cc.Tex2F.BYTES_PER_ELEMENT = 8; - Object.defineProperties(cc.Tex2F.prototype, { - u: { - get: function () { - return this._uF32[0]; - }, - set: function (xValue) { - this._uF32[0] = xValue; - }, - enumerable: true - }, - v: { - get: function () { - return this._vF32[0]; - }, - set: function (yValue) { - this._vF32[0] = yValue; - }, - enumerable: true - } - }); + + _p = cc.Tex2F.prototype; + _p._getU = function () { + return this._uF32[0]; + }; + _p._setU = function (xValue) { + this._uF32[0] = xValue; + }; + _p._getV = function () { + return this._vF32[0]; + }; + _p._setV = function (yValue) { + this._vF32[0] = yValue; + }; + /** @expose */ + _p.u; + cc.defineGetterSetter(_p, "u", _p._getU, _p._setU); + /** @expose */ + _p.v; + cc.defineGetterSetter(_p, "v", _p._getV, _p._setV); //redefine cc.Quad2 /** @@ -297,6 +294,49 @@ cc._tmp.WebGLColor = function () { */ cc.Quad2.BYTES_PER_ELEMENT = 32; + _p = cc.Quad2.prototype; + _p._getTL = function () { + return this._tl; + }; + _p._setTL = function (tlValue) { + this._tl.x = tlValue.x; + this._tl.y = tlValue.y; + }; + _p._getTR = function () { + return this._tr; + }; + _p._setTR = function (trValue) { + this._tr.x = trValue.x; + this._tr.y = trValue.y; + }; + _p._getBL = function() { + return this._bl; + }; + _p._setBL = function (blValue) { + this._bl.x = blValue.x; + this._bl.y = blValue.y; + }; + _p._getBR = function () { + return this._br; + }; + _p._setBR = function (brValue) { + this._br.x = brValue.x; + this._br.y = brValue.y; + }; + + /** @expose */ + _p.tl; + cc.defineGetterSetter(_p, "tl", _p._getTL, _p._setTL); + /** @expose */ + _p.tr; + cc.defineGetterSetter(_p, "tr", _p._getTR, _p._setTR); + /** @expose */ + _p.bl; + cc.defineGetterSetter(_p, "bl", _p._getBL, _p._setBL); + /** @expose */ + _p.br; + cc.defineGetterSetter(_p, "br", _p._getBR, _p._setBR); + /** * A 3D Quad. 4 * 3 floats * @Class cc.Quad3 @@ -313,49 +353,6 @@ cc._tmp.WebGLColor = function () { this.tr = tr1 || new cc.Vertex3F(0, 0, 0); }; - Object.defineProperties(cc.Quad2.prototype, { - tl: { - get: function () { - return this._tl; - }, - set: function (tlValue) { - this._tl.x = tlValue.x; - this._tl.y = tlValue.y; - }, - enumerable: true - }, - tr: { - get: function () { - return this._tr; - }, - set: function (trValue) { - this._tr.x = trValue.x; - this._tr.y = trValue.y; - }, - enumerable: true - }, - bl: { - get: function () { - return this._bl; - }, - set: function (blValue) { - this._bl.x = blValue.x; - this._bl.y = blValue.y; - }, - enumerable: true - }, - br: { - get: function () { - return this._br; - }, - set: function (brValue) { - this._br.x = brValue.x; - this._br.y = brValue.y; - }, - enumerable: true - } - }); - //redefine cc.V3F_C4B_T2F /** * @class cc.V3F_C4B_T2F @@ -383,43 +380,43 @@ cc._tmp.WebGLColor = function () { * @type {number} */ cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24; - Object.defineProperties(cc.V3F_C4B_T2F.prototype, { - vertices: { - get: function () { - return this._vertices; - }, - set: function (verticesValue) { - var locVertices = this._vertices; - locVertices.x = verticesValue.x; - locVertices.y = verticesValue.y; - locVertices.z = verticesValue.z; - }, - enumerable: true - }, - colors: { - get: function () { - return this._colors; - }, - set: function (colorValue) { - var locColors = this._colors; - locColors.r = colorValue.r; - locColors.g = colorValue.g; - locColors.b = colorValue.b; - locColors.a = colorValue.a; - }, - enumerable: true - }, - texCoords: { - get: function () { - return this._texCoords; - }, - set: function (texValue) { - this._texCoords.u = texValue.u; - this._texCoords.v = texValue.v; - }, - enumerable: true - } - }); + + _p = cc.V3F_C4B_T2F.prototype; + _p._getVertices = function () { + return this._vertices; + }; + _p._setVertices = function (verticesValue) { + var locVertices = this._vertices; + locVertices.x = verticesValue.x; + locVertices.y = verticesValue.y; + locVertices.z = verticesValue.z; + }; + _p._getColor = function () { + return this._colors; + }; + _p._setColor = function (colorValue) { + var locColors = this._colors; + locColors.r = colorValue.r; + locColors.g = colorValue.g; + locColors.b = colorValue.b; + locColors.a = colorValue.a; + }; + _p._getTexCoords = function () { + return this._texCoords; + }; + _p._setTexCoords = function (texValue) { + this._texCoords.u = texValue.u; + this._texCoords.v = texValue.v; + }; + /** @expose */ + _p.vertices; + cc.defineGetterSetter(_p, "vertices", _p._getVertices, _p._setVertices); + /** @expose */ + _p.colors; + cc.defineGetterSetter(_p, "colors", _p._getColor, _p._setColor); + /** @expose */ + _p.texCoords; + cc.defineGetterSetter(_p, "texCoords", _p._getTexCoords, _p._setTexCoords); //redefine cc.V3F_C4B_T2F_Quad /** @@ -451,62 +448,63 @@ cc._tmp.WebGLColor = function () { * @type {number} */ cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96; - Object.defineProperties(cc.V3F_C4B_T2F_Quad.prototype, { - tl: { - get: function () { - return this._tl; - }, - set: function (tlValue) { - var locTl = this._tl; - locTl.vertices = tlValue.vertices; - locTl.colors = tlValue.colors; - locTl.texCoords = tlValue.texCoords; - }, - enumerable: true - }, - bl: { - get: function () { - return this._bl; - }, - set: function (blValue) { - var locBl = this._bl; - locBl.vertices = blValue.vertices; - locBl.colors = blValue.colors; - locBl.texCoords = blValue.texCoords; - }, - enumerable: true - }, - tr: { - get: function () { - return this._tr; - }, - set: function (trValue) { - var locTr = this._tr; - locTr.vertices = trValue.vertices; - locTr.colors = trValue.colors; - locTr.texCoords = trValue.texCoords; - }, - enumerable: true - }, - br: { - get: function () { - return this._br; - }, - set: function (brValue) { - var locBr = this._br; - locBr.vertices = brValue.vertices; - locBr.colors = brValue.colors; - locBr.texCoords = brValue.texCoords; - }, - enumerable: true - }, - arrayBuffer: { - get: function () { - return this._arrayBuffer; - }, - enumerable: true - } - }); + _p = cc.V3F_C4B_T2F_Quad.prototype; + _p._getTL = function () { + return this._tl; + }; + _p._setTL = function (tlValue) { + var locTl = this._tl; + locTl.vertices = tlValue.vertices; + locTl.colors = tlValue.colors; + locTl.texCoords = tlValue.texCoords; + }; + _p._getBL = function () { + return this._bl; + }; + _p._setBL = function (blValue) { + var locBl = this._bl; + locBl.vertices = blValue.vertices; + locBl.colors = blValue.colors; + locBl.texCoords = blValue.texCoords; + }; + _p._getTR = function () { + return this._tr; + }; + _p._setTR = function (trValue) { + var locTr = this._tr; + locTr.vertices = trValue.vertices; + locTr.colors = trValue.colors; + locTr.texCoords = trValue.texCoords; + }; + _p._getBR = function () { + return this._br; + }; + _p._setBR = function (brValue) { + var locBr = this._br; + locBr.vertices = brValue.vertices; + locBr.colors = brValue.colors; + locBr.texCoords = brValue.texCoords; + }; + _p._getArrayBuffer = function () { + return this._arrayBuffer; + }; + + /** @expose */ + _p.tl; + cc.defineGetterSetter(_p, "tl", _p._getTL, _p._setTL); + /** @expose */ + _p.tr; + cc.defineGetterSetter(_p, "tr", _p._getTR, _p._setTR); + /** @expose */ + _p.bl; + cc.defineGetterSetter(_p, "bl", _p._getBL, _p._setBL); + /** @expose */ + _p.br; + cc.defineGetterSetter(_p, "br", _p._getBR, _p._setBR); + /** @expose */ + _p.arrayBuffer; + cc.defineGetterSetter(_p, "arrayBuffer", _p._getArrayBuffer, null); + /** * @function * @returns {cc.V3F_C4B_T2F_Quad} @@ -580,46 +578,47 @@ cc._tmp.WebGLColor = function () { this._texCoords = texCoords ? new cc.Tex2F(texCoords.u, texCoords.v, locArrayBuffer, locOffset + locElementLen + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, locArrayBuffer, locOffset + locElementLen + cc.Color.BYTES_PER_ELEMENT); }; + /** * @constant * @type {number} */ cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20; - Object.defineProperties(cc.V2F_C4B_T2F.prototype, { - vertices: { - get: function () { - return this._vertices; - }, - set: function (verticesValue) { - this._vertices.x = verticesValue.x; - this._vertices.y = verticesValue.y; - }, - enumerable: true - }, - colors: { - get: function () { - return this._colors; - }, - set: function (colorValue) { - var locColors = this._colors; - locColors.r = colorValue.r; - locColors.g = colorValue.g; - locColors.b = colorValue.b; - locColors.a = colorValue.a; - }, - enumerable: true - }, - texCoords: { - get: function () { - return this._texCoords; - }, - set: function (texValue) { - this._texCoords.u = texValue.u; - this._texCoords.v = texValue.v; - }, - enumerable: true - } - }); + _p = cc.V2F_C4B_T2F.prototype; + _p._getVertices = function () { + return this._vertices; + }; + _p._setVertices = function (verticesValue) { + this._vertices.x = verticesValue.x; + this._vertices.y = verticesValue.y; + }; + _p._getColor = function () { + return this._colors; + }; + _p._setColor = function (colorValue) { + var locColors = this._colors; + locColors.r = colorValue.r; + locColors.g = colorValue.g; + locColors.b = colorValue.b; + locColors.a = colorValue.a; + }; + _p._getTexCoords = function () { + return this._texCoords; + }; + _p._setTexCoords = function (texValue) { + this._texCoords.u = texValue.u; + this._texCoords.v = texValue.v; + }; + + /** @expose */ + _p.vertices; + cc.defineGetterSetter(_p, "vertices", _p._getVertices, _p._setVertices); + /** @expose */ + _p.colors; + cc.defineGetterSetter(_p, "colors", _p._getColor, _p._setColor); + /** @expose */ + _p.texCoords; + cc.defineGetterSetter(_p, "texCoords", _p._getTexCoords, _p._setTexCoords); //redefine cc.V2F_C4B_T2F_Triangle /** @@ -648,42 +647,42 @@ cc._tmp.WebGLColor = function () { * @type {number} */ cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60; - Object.defineProperties(cc.V2F_C4B_T2F_Triangle.prototype, { - a: { - get: function () { - return this._a; - }, - set: function (aValue) { - var locA = this._a; - locA.vertices = aValue.vertices; - locA.colors = aValue.colors; - locA.texCoords = aValue.texCoords; - }, - enumerable: true - }, - b: { - get: function () { - return this._b; - }, - set: function (bValue) { - var locB = this._b; - locB.vertices = bValue.vertices; - locB.colors = bValue.colors; - locB.texCoords = bValue.texCoords; - }, - enumerable: true - }, - c: { - get: function () { - return this._c; - }, - set: function (cValue) { - var locC = this._c; - locC.vertices = cValue.vertices; - locC.colors = cValue.colors; - locC.texCoords = cValue.texCoords; - }, - enumerable: true - } - }); + _p = cc.V2F_C4B_T2F_Triangle.prototype; + _p._getA = function () { + return this._a; + }; + _p._setA = function (aValue) { + var locA = this._a; + locA.vertices = aValue.vertices; + locA.colors = aValue.colors; + locA.texCoords = aValue.texCoords; + }; + _p._getB = function () { + return this._b; + }; + _p._setB = function (bValue) { + var locB = this._b; + locB.vertices = bValue.vertices; + locB.colors = bValue.colors; + locB.texCoords = bValue.texCoords; + }; + _p._getC = function () { + return this._c; + }; + _p._setC = function (cValue) { + var locC = this._c; + locC.vertices = cValue.vertices; + locC.colors = cValue.colors; + locC.texCoords = cValue.texCoords; + }; + + /** @expose */ + _p.a; + cc.defineGetterSetter(_p, "a", _p._getA, _p._setA); + /** @expose */ + _p.b; + cc.defineGetterSetter(_p, "b", _p._getB, _p._setB); + /** @expose */ + _p.c; + cc.defineGetterSetter(_p, "c", _p._getC, _p._setC); }; \ No newline at end of file diff --git a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js index 1f302501e1..6df19091a0 100644 --- a/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js @@ -73,7 +73,7 @@ r = r || 0; g = g || 0; b = b || 0; - a = isNaN(a) ? 1 : a; + a = isNaN(a) ? 255 : a; var context = this._cacheContext.getContext(); var locCanvas = this._cacheCanvas; From b2bfd7c22b5243c3a718d96f618095522552ca53 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 11 Mar 2015 11:47:26 +0800 Subject: [PATCH 1402/1564] Loading spriteFrames from jsonObject has been supported. --- cocos2d/core/sprites/CCSpriteFrameCache.js | 80 +++++++++++++--------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 79321e5327..851a30f278 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -71,6 +71,17 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ this._frameConfigCache[url] = dict; return dict; } + this._frameConfigCache[url] = this._parseFrameConfig(dict); + return this._frameConfigCache[url]; + }, + + _getFrameConfigByJsonObject: function(url, jsonObject) { + cc.assert(jsonObject, cc._LogInfos.spriteFrameCache__getFrameConfig_2, url); + this._frameConfigCache[url] = this._parseFrameConfig(jsonObject); + return this._frameConfigCache[url]; + }, + + _parseFrameConfig: function(dict) { var tempFrames = dict["frames"], tempMeta = dict["metadata"] || dict["meta"]; var frames = {}, meta = {}; var format = 0; @@ -125,38 +136,21 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ } frames[key] = tempFrame; } - var cfg = this._frameConfigCache[url] = { - _inited : true, - frames : frames, - meta : meta - }; - return cfg; + return {_inited: true, frames: frames, meta: meta}; }, - /** - *

    - * Adds multiple Sprite Frames from a plist or json file.
    - * A texture will be loaded automatically. The texture name will composed by replacing the .plist or .json suffix with .png
    - * If you want to use another texture, you should use the addSpriteFrames:texture method.
    - *

    - * @param {String} url file path - * @param {HTMLImageElement|cc.Texture2D|string} texture - * @example - * // add SpriteFrames to SpriteFrameCache With File - * cc.spriteFrameCache.addSpriteFrames(s_grossiniPlist); - * cc.spriteFrameCache.addSpriteFrames(s_grossiniJson); - */ - addSpriteFrames: function (url, texture) { + // Adds multiple Sprite Frames from a json object. it uses for local web view app. + _addSpriteFramesByObject: function(url, jsonObject, texture) { cc.assert(url, cc._LogInfos.spriteFrameCache_addSpriteFrames_2); - - //Is it a SpriteFrame plist? - var dict = this._frameConfigCache[url] || cc.loader.getRes(url); - if(!dict || !dict["frames"]) + if(!jsonObject || !jsonObject["frames"]) return; - var self = this; - var frameConfig = self._frameConfigCache[url] || self._getFrameConfig(url); - //self._checkConflict(frameConfig); //TODO + var frameConfig = this._frameConfigCache[url] || this._getFrameConfigByJsonObject(url, jsonObject); + //this._checkConflict(frameConfig); //TODO + this._createSpriteFrames(frameConfig, texture); + }, + + _createSpriteFrames: function(frameConfig, texture) { var frames = frameConfig.frames, meta = frameConfig.meta; if(!texture){ var texturePath = cc.path.changeBasename(url, meta.image || ".png"); @@ -170,7 +164,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ } //create sprite frames - var spAliases = self._spriteFramesAliases, spriteFrames = self._spriteFrames; + var spAliases = this._spriteFramesAliases, spriteFrames = this._spriteFrames; for (var key in frames) { var frame = frames[key]; var spriteFrame = spriteFrames[key]; @@ -180,9 +174,8 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ if(aliases){//set aliases for(var i = 0, li = aliases.length; i < li; i++){ var alias = aliases[i]; - if (spAliases[alias]) { + if (spAliases[alias]) cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames, alias); - } spAliases[alias] = key; } } @@ -202,12 +195,37 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ spriteFrame.setRect(cc.rect(0, 0, rect.width, rect.height)); } } - spriteFrames[key] = spriteFrame; } } }, + /** + *

    + * Adds multiple Sprite Frames from a plist or json file.
    + * A texture will be loaded automatically. The texture name will composed by replacing the .plist or .json suffix with .png
    + * If you want to use another texture, you should use the addSpriteFrames:texture method.
    + *

    + * @param {String} url file path + * @param {HTMLImageElement|cc.Texture2D|string} texture + * @example + * // add SpriteFrames to SpriteFrameCache With File + * cc.spriteFrameCache.addSpriteFrames(s_grossiniPlist); + * cc.spriteFrameCache.addSpriteFrames(s_grossiniJson); + */ + addSpriteFrames: function (url, texture) { + cc.assert(url, cc._LogInfos.spriteFrameCache_addSpriteFrames_2); + + //Is it a SpriteFrame plist? + var dict = this._frameConfigCache[url] || cc.loader.getRes(url); + if(!dict || !dict["frames"]) + return; + + var frameConfig = this._frameConfigCache[url] || this._getFrameConfig(url); + //this._checkConflict(frameConfig); //TODO + this._createSpriteFrames(frameConfig, texture); + }, + // Function to check if frames to add exists already, if so there may be name conflit that must be solved _checkConflict: function (dictionary) { var framesDict = dictionary["frames"]; From d11949f3a7f7d5c1e4f2b110fba1811021ba776a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 11 Mar 2015 14:19:59 +0800 Subject: [PATCH 1403/1564] Fixed a bug that is position error when checkbox does not pre loaded --- extensions/ccui/uiwidgets/UICheckBox.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index 9f9f257fc4..dbe967c859 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -163,7 +163,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGround: function (backGround, texType) { - if (!backGround || (this._backGroundFileName == backGround && this._backGroundTexType == texType)) + if (!backGround) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; @@ -206,7 +206,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGroundSelected: function (backGroundSelected, texType) { - if (!backGroundSelected || (this._backGroundSelectedFileName == backGroundSelected && this._backGroundSelectedTexType == texType)) + if (!backGroundSelected) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; @@ -246,7 +246,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureFrontCross: function (cross, texType) { - if (!cross || (this._frontCrossFileName == cross && this._frontCrossTexType == texType)) + if (!cross) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossFileName = cross; @@ -285,7 +285,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureBackGroundDisabled: function (backGroundDisabled, texType) { - if (!backGroundDisabled || (this._backGroundDisabledFileName == backGroundDisabled && this._backGroundDisabledTexType == texType)) + if (!backGroundDisabled) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._backGroundDisabledFileName = backGroundDisabled; @@ -324,7 +324,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType */ loadTextureFrontCrossDisabled: function (frontCrossDisabled, texType) { - if (!frontCrossDisabled || (this._frontCrossDisabledFileName == frontCrossDisabled && this._frontCrossDisabledTexType == texType)) + if (!frontCrossDisabled) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; this._frontCrossDisabledFileName = frontCrossDisabled; From aa1deb903ef790045a4abf8769e06a1ae2db7252 Mon Sep 17 00:00:00 2001 From: WingGao Date: Wed, 11 Mar 2015 18:03:05 +0800 Subject: [PATCH 1404/1564] FIx getTileGIDAt If pos equals 0 it will also throw the exception --- cocos2d/tilemap/CCTMXLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index d9a6219398..c2e763ac64 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -370,7 +370,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ * @return {Number} */ getTileGIDAt:function (pos, y) { - if(!pos) + if(pos == null) throw "cc.TMXLayer.getTileGIDAt(): pos should be non-null"; if(y !== undefined) pos = cc.p(pos, y); From d009c11e3532e82ef9ee22cbd70c8221cfe53cce Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 13 Mar 2015 10:08:34 +0800 Subject: [PATCH 1405/1564] Fixed TMX setTileGID error --- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 40 +++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index 7cada6db60..d7cdc2b080 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -87,8 +87,46 @@ return; var node = this._node; + //TODO: it will implement dynamic compute child cutting automation. + var i, len, locChildren = node._children; + // quick return if not visible + if (!node._visible || !locChildren || locChildren.length === 0) + return; + + var wrapper, context; + + if (this._cacheDirty) { + var locCanvas = this._cacheCanvas, instanceID = node.__instanceId, renderer = cc.renderer; + wrapper = this._cacheContext, context = wrapper.getContext(), + //begin cache + renderer._turnToCacheMode(instanceID); + + node.sortAllChildren(); + for (i = 0, len = locChildren.length; i < len; i++) { + if (locChildren[i]){ + var selCmd = locChildren[i]._renderCmd; + if(selCmd){ + selCmd.visit(this); + selCmd._cacheDirty = false; + } + } + } + + //copy cached render cmd array to TMXLayer renderer + this._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); + + //wrapper.save(); + context.setTransform(1, 0, 0, 1, 0, 0); + context.clearRect(0, 0, locCanvas.width, locCanvas.height); + //set the wrapper's offset + + //draw to cache canvas + renderer._renderingToCacheCanvas(wrapper, instanceID); + } + this._renderingChildToCache(scaleX, scaleY); - var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); + wrapper = ctx || cc._renderContext; + context = wrapper.getContext(); wrapper.setGlobalAlpha(alpha); var posX = 0 | ( -this._anchorPointInPoints.x), posY = 0 | ( -this._anchorPointInPoints.y); From 18d0efe813caa3b50973354f9516fff60f004380 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 13 Mar 2015 11:32:48 +0800 Subject: [PATCH 1406/1564] Remove _childrenRenderCmds --- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 71 ++++---------------- 1 file changed, 13 insertions(+), 58 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index d7cdc2b080..6767d78c71 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -27,7 +27,6 @@ cc.SpriteBatchNode.CanvasRenderCmd.call(this, renderable); this._needDraw = true; this._realWorldTransform = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0}; - this._childrenRenderCmds = []; var locCanvas = cc._canvas; var tmpCanvas = cc.newElement('canvas'); @@ -46,17 +45,6 @@ var proto = cc.TMXLayer.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype); proto.constructor = cc.TMXLayer.CanvasRenderCmd; - proto._copyRendererCmds = function (rendererCmds) { - if (!rendererCmds) - return; - - var locCacheCmds = this._childrenRenderCmds; - locCacheCmds.length = 0; - for (var i = 0, len = rendererCmds.length; i < len; i++) { - locCacheCmds[i] = rendererCmds[i]; - } - }; - //set the cache dirty flag for canvas proto._setNodeDirtyForCache = function () { this._cacheDirty = true; @@ -64,7 +52,7 @@ proto._renderingChildToCache = function (scaleX, scaleY) { if (this._cacheDirty) { - var locCacheCmds = this._childrenRenderCmds, wrapper = this._cacheContext, + var wrapper = this._cacheContext, context = wrapper.getContext(), locCanvas = this._cacheCanvas; //wrapper.save(); @@ -72,10 +60,18 @@ context.clearRect(0, 0, locCanvas.width, locCanvas.height); //reset the cache context - for (var i = 0, len = locCacheCmds.length; i < len; i++) { - locCacheCmds[i].rendering(wrapper, scaleX, scaleY); - locCacheCmds[i]._cacheDirty = false; + this._node.sortAllChildren(); + var locChildren = this._node._children; + for (var i = 0, len = locChildren.length; i < len; i++) { + if (locChildren[i]){ + var selCmd = locChildren[i]._renderCmd; + if(selCmd){ + selCmd.rendering(wrapper, scaleX, scaleY); + selCmd._cacheDirty = false; + } + } } + //wrapper.restore(); this._cacheDirty = false; } @@ -87,46 +83,8 @@ return; var node = this._node; - //TODO: it will implement dynamic compute child cutting automation. - var i, len, locChildren = node._children; - // quick return if not visible - if (!node._visible || !locChildren || locChildren.length === 0) - return; - - var wrapper, context; - - if (this._cacheDirty) { - var locCanvas = this._cacheCanvas, instanceID = node.__instanceId, renderer = cc.renderer; - wrapper = this._cacheContext, context = wrapper.getContext(), - //begin cache - renderer._turnToCacheMode(instanceID); - - node.sortAllChildren(); - for (i = 0, len = locChildren.length; i < len; i++) { - if (locChildren[i]){ - var selCmd = locChildren[i]._renderCmd; - if(selCmd){ - selCmd.visit(this); - selCmd._cacheDirty = false; - } - } - } - - //copy cached render cmd array to TMXLayer renderer - this._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); - - //wrapper.save(); - context.setTransform(1, 0, 0, 1, 0, 0); - context.clearRect(0, 0, locCanvas.width, locCanvas.height); - //set the wrapper's offset - - //draw to cache canvas - renderer._renderingToCacheCanvas(wrapper, instanceID); - } - this._renderingChildToCache(scaleX, scaleY); - wrapper = ctx || cc._renderContext; - context = wrapper.getContext(); + var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); wrapper.setGlobalAlpha(alpha); var posX = 0 | ( -this._anchorPointInPoints.x), posY = 0 | ( -this._anchorPointInPoints.y); @@ -199,9 +157,6 @@ } } - //copy cached render cmd array to TMXLayer renderer - this._copyRendererCmds(renderer._cacheToCanvasCmds[instanceID]); - //wrapper.save(); context.setTransform(1, 0, 0, 1, 0, 0); context.clearRect(0, 0, locCanvas.width, locCanvas.height); From 63e8675c683d38fa93bf506bca8aea58978309c3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 13 Mar 2015 11:35:08 +0800 Subject: [PATCH 1407/1564] remove sortAllChildren --- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index 6767d78c71..c1a63a4924 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -60,7 +60,6 @@ context.clearRect(0, 0, locCanvas.width, locCanvas.height); //reset the cache context - this._node.sortAllChildren(); var locChildren = this._node._children; for (var i = 0, len = locChildren.length; i < len; i++) { if (locChildren[i]){ From 843c0ee4e5926f8ea16a07a113fcd8f3d01def69 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 13 Mar 2015 14:33:31 +0800 Subject: [PATCH 1408/1564] Issue #2698: rename cc.kmMat4 to cc.math.Matrix4 and refactor math library for better performance. --- cocos2d/core/CCCamera.js | 10 +- cocos2d/core/CCDirector.js | 9 +- cocos2d/core/CCDirectorWebGL.js | 21 +- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 20 +- cocos2d/effects/CCGrid.js | 12 +- cocos2d/kazmath/aabb.js | 12 +- cocos2d/kazmath/gl/mat4stack.js | 75 +- cocos2d/kazmath/gl/matrix.js | 267 ++- cocos2d/kazmath/mat3.js | 9 +- cocos2d/kazmath/mat4.js | 1674 ++++++++++------- cocos2d/kazmath/quaternion.js | 2 +- cocos2d/kazmath/vec3.js | 2 +- cocos2d/kazmath/vec4.js | 2 +- cocos2d/node-grid/CCNodeGrid.js | 2 +- .../CCRenderTextureWebGLRenderCmd.js | 5 +- cocos2d/shaders/CCGLProgram.js | 10 +- .../CCProtectedNodeWebGLRenderCmd.js | 10 +- 17 files changed, 1182 insertions(+), 960 deletions(-) diff --git a/cocos2d/core/CCCamera.js b/cocos2d/core/CCCamera.js index d9189391e8..ea6c6db8c7 100644 --- a/cocos2d/core/CCCamera.js +++ b/cocos2d/core/CCCamera.js @@ -62,7 +62,7 @@ cc.Camera = cc.Class.extend({ * constructor of cc.Camera */ ctor:function () { - this._lookupMatrix = new cc.kmMat4(); + this._lookupMatrix = new cc.math.Matrix4(); this.restore(); }, @@ -103,7 +103,7 @@ cc.Camera = cc.Class.extend({ this._upY = 1.0; this._upZ = 0.0; - cc.kmMat4Identity( this._lookupMatrix ); + this._lookupMatrix.identity(); this._dirty = false; }, @@ -116,7 +116,7 @@ cc.Camera = cc.Class.extend({ var eye = new cc.math.Vec3(this._eyeX, this._eyeY , this._eyeZ), center = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ), up = new cc.math.Vec3(this._upX, this._upY, this._upZ); - cc.kmMat4LookAt( this._lookupMatrix, eye, center, up); + this._lookupMatrix.lookAt(eye, center, up); this._dirty = false; } cc.kmGLMultMatrix( this._lookupMatrix); @@ -127,10 +127,10 @@ cc.Camera = cc.Class.extend({ var eye = new cc.math.Vec3(this._eyeX, this._eyeY , this._eyeZ), center = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ), up = new cc.math.Vec3(this._upX, this._upY, this._upZ); - cc.kmMat4LookAt( this._lookupMatrix, eye, center, up); + this._lookupMatrix.lookAt(eye, center, up); this._dirty = false; } - cc.kmMat4Multiply(matrix, matrix, this._lookupMatrix); + matrix.multiply(this._lookupMatrix); }, /** diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index b9cfbc1437..99988bd431 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -27,13 +27,14 @@ cc.g_NumberOfDraws = 0; cc.GLToClipTransform = function (transformOut) { - var projection = new cc.kmMat4(); - cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, projection); + //var projection = new cc.math.Matrix4(); + //cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, projection); + cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, transformOut); - var modelview = new cc.kmMat4(); + var modelview = new cc.math.Matrix4(); cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, modelview); - cc.kmMat4Multiply(transformOut, projection, modelview); + transformOut.multiply(modelview); }; //---------------------------------------------------------------------------------------------------------------------- diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 092dda5b7d..0747f31794 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -57,13 +57,11 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { case cc.Director.PROJECTION_2D: cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); - var orthoMatrix = new cc.kmMat4(); - cc.kmMat4OrthographicProjection( - orthoMatrix, + var orthoMatrix = cc.math.Matrix4.createOrthographicProjection( -ox, - size.width - ox, + size.width - ox, -oy, - size.height - oy, + size.height - oy, -1024, 1024); cc.kmGLMultMatrix(orthoMatrix); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); @@ -71,12 +69,12 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { break; case cc.Director.PROJECTION_3D: var zeye = _t.getZEye(); - var matrixPerspective = new cc.kmMat4(), matrixLookup = new cc.kmMat4(); + var matrixPerspective = new cc.math.Matrix4(), matrixLookup = new cc.math.Matrix4(); cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); // issue #1334 - cc.kmMat4PerspectiveProjection(matrixPerspective, 60, size.width / size.height, 0.1, zeye * 2); + matrixPerspective = cc.math.Matrix4.createPerspectiveProjection(60, size.width / size.height, 0.1, zeye * 2); cc.kmGLMultMatrix(matrixPerspective); @@ -85,7 +83,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { var eye = new cc.math.Vec3(-ox + size.width / 2, -oy + size.height / 2, zeye); var center = new cc.math.Vec3( -ox + size.width / 2, -oy + size.height / 2, 0.0); var up = new cc.math.Vec3( 0.0, 1.0, 0.0); - cc.kmMat4LookAt(matrixLookup, eye, center, up); + matrixLookup.lookAt(eye, center, up); cc.kmGLMultMatrix(matrixLookup); break; case cc.Director.PROJECTION_CUSTOM: @@ -238,11 +236,10 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { }; _p.convertToGL = function (uiPoint) { - var transform = new cc.kmMat4(); + var transform = new cc.math.Matrix4(); cc.GLToClipTransform(transform); - var transformInv = new cc.kmMat4(); - cc.kmMat4Inverse(transformInv, transform); + var transformInv = transform.inverse(); // Calculate z=0 using -> transform*[0, 0, 0, 1]/w var zClip = transform.mat[14] / transform.mat[15]; @@ -253,7 +250,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { }; _p.convertToUI = function (glPoint) { - var transform = new cc.kmMat4(); + var transform = new cc.math.Matrix4(); cc.GLToClipTransform(transform); var clipCoord = new cc.math.Vec3(glPoint.x, glPoint.y, 0.0); diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index d0fc3a4afd..5342f1c3a5 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -26,11 +26,11 @@ cc.Node.WebGLRenderCmd = function (renderable) { cc.Node.RenderCmd.call(this, renderable); - var mat4 = new cc.kmMat4(); - mat4.mat[2] = mat4.mat[3] = mat4.mat[6] = mat4.mat[7] = mat4.mat[8] = mat4.mat[9] = mat4.mat[11] = mat4.mat[14] = 0.0; - mat4.mat[10] = mat4.mat[15] = 1.0; + var mat4 = new cc.math.Matrix4(), mat = mat4.mat; + mat[2] = mat[3] = mat[6] = mat[7] = mat[8] = mat[9] = mat[11] = mat[14] = 0.0; + mat[10] = mat[15] = 1.0; this._transform4x4 = mat4; - this._stackMatrix = new cc.kmMat4(); + this._stackMatrix = new cc.math.Matrix4(); this._shaderProgram = null; this._camera = null; @@ -223,15 +223,15 @@ apy = 0 | apy; } //cc.kmGLTranslatef(apx, apy, 0); - var translation = new cc.kmMat4(); - cc.kmMat4Translation(translation, apx, apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + var translation = cc.math.Matrix4.createByTranslation(apx, apy, 0, t4x4); //t4x4 as a temp matrix + stackMatrix.multiply(translation); node._camera._locateForRenderer(stackMatrix); - //cc.kmGLTranslatef(-apx, -apy, 0); - cc.kmMat4Translation(translation, -apx, -apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + //cc.kmGLTranslatef(-apx, -apy, 0); optimize at here : kmGLTranslatef + translation = cc.math.Matrix4.createByTranslation(apx, apy, 0, translation); + stackMatrix.multiply(translation); + t4x4.identity(); //reset t4x4; } else { node._camera._locateForRenderer(stackMatrix); } diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index 04719e1df9..a7276fe7c4 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -229,16 +229,15 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ // XXX: Camera should be applied in the AnchorPoint // //cc.kmGLTranslatef(offset.x, offset.y, 0); - var translation = new cc.kmMat4(); - cc.kmMat4Translation(translation, offset.x, offset.y, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + var translation = cc.math.Matrix4.createByTranslation(offset.x, offset.y, 0); + stackMatrix.multiply(translation); //target.getCamera().locate(); target._camera._locateForRenderer(stackMatrix); //cc.kmGLTranslatef(-offset.x, -offset.y, 0); - cc.kmMat4Translation(translation, -offset.x, -offset.y, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + translation = cc.math.Matrix4.createByTranslation(-offset.x, -offset.y, 0, translation); + stackMatrix.multiply(translation); } cc.glBindTexture2D(this._texture); @@ -265,8 +264,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); cc.kmGLLoadIdentity(); - var orthoMatrix = new cc.kmMat4(); - cc.kmMat4OrthographicProjection(orthoMatrix, 0, winSize.width, 0, winSize.height, -1, 1); + var orthoMatrix = cc.math.Matrix4.createOrthographicProjection(0, winSize.width, 0, winSize.height, -1, 1); cc.kmGLMultMatrix(orthoMatrix); cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); diff --git a/cocos2d/kazmath/aabb.js b/cocos2d/kazmath/aabb.js index a6d207ad8b..8c5dc5b664 100644 --- a/cocos2d/kazmath/aabb.js +++ b/cocos2d/kazmath/aabb.js @@ -39,7 +39,7 @@ cc.math.AABB = function (min, max) { /** * Returns true if point is in the specified AABB, returns false otherwise. - * @param {cc.kmVec3} point + * @param {cc.math.Vec3} point * @returns {boolean} */ cc.math.AABB.prototype.containsPoint = function (point) { @@ -62,17 +62,17 @@ cc.math.AABB.containsPoint = function (pPoint, pBox) { * Assigns aabb to current AABB object * @param {cc.math.AABB} aabb */ -cc.math.AABB.prototype.assign = function(aabb){ - this.min.assign(aabb.min); - this.max.assign(aabb.max); +cc.math.AABB.prototype.assignFrom = function(aabb){ + this.min.assignFrom(aabb.min); + this.max.assignFrom(aabb.max); }; /** * Assigns pIn to pOut, returns pOut. */ cc.math.AABB.assign = function (pOut, pIn) { //cc.kmAABBAssign - pOut.min.assign(pIn.min); - pOut.max.assign(pIn.max); + pOut.min.assignFrom(pIn.min); + pOut.max.assignFrom(pIn.max); return pOut; }; diff --git a/cocos2d/kazmath/gl/mat4stack.js b/cocos2d/kazmath/gl/mat4stack.js index b87450e9c7..b11fd6b1cf 100644 --- a/cocos2d/kazmath/gl/mat4stack.js +++ b/cocos2d/kazmath/gl/mat4stack.js @@ -26,33 +26,54 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -cc.km_mat4_stack = function(capacity, item_count, top, stack){ - this.top = top ; - this.stack = stack ; -}; - -cc.km_mat4_stack.INITIAL_SIZE = 30; - -cc.km_mat4_stack_initialize = function(stack){ - stack.stack = []; //allocate the memory - stack.top = null; //Set the top to NULL -}; - -cc.km_mat4_stack_push = function(stack, item){ - stack.stack.push(stack.top); - stack.top = new cc.kmMat4(); - cc.kmMat4Assign(stack.top, item); -}; - -cc.km_mat4_stack_pop = function(stack, pOut){ - stack.top = stack.stack.pop(); -}; - -cc.km_mat4_stack_release = function(stack){ - stack.stack = null; - stack.top = null; - stack = null; -}; +(function(cc){ + /** + * The stack of cc.math.Matrix4 + * @param {cc.math.Matrix4} [top] + * @param {Array} [stack] + * @constructor + */ + cc.math.Matrix4Stack = function(top, stack) { + this.top = top; + this.stack = stack || []; + }; + cc.km_mat4_stack = cc.math.Matrix4Stack; + var proto = cc.math.Matrix4Stack.prototype; + + proto.initialize = function() { //cc.km_mat4_stack_initialize + this.stack.length = 0; + this.top = null; + }; + + //for compatibility + cc.km_mat4_stack_push = function(stack, item){ + stack.stack.push(stack.top); + stack.top = new cc.math.Matrix4(item); + }; + + cc.km_mat4_stack_pop = function(stack, pOut){ + stack.top = stack.stack.pop(); + }; + + cc.km_mat4_stack_release = function(stack){ + stack.stack = null; + stack.top = null; + }; + + proto.push = function(item) { + this.stack.push(this.top); + this.top = new cc.math.Matrix4(item); + }; + + proto.pop = function() { + this.top = this.stack.pop(); + }; + + proto.release = function(){ + this.stack = null; + this.top = null; + }; +})(cc); diff --git a/cocos2d/kazmath/gl/matrix.js b/cocos2d/kazmath/gl/matrix.js index 0431721b7c..574bd0dd5d 100644 --- a/cocos2d/kazmath/gl/matrix.js +++ b/cocos2d/kazmath/gl/matrix.js @@ -26,143 +26,142 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -cc.KM_GL_MODELVIEW = 0x1700; +(function(cc) { + cc.KM_GL_MODELVIEW = 0x1700; + cc.KM_GL_PROJECTION = 0x1701; + cc.KM_GL_TEXTURE = 0x1702; -cc.KM_GL_PROJECTION = 0x1701; + cc.modelview_matrix_stack = new cc.math.Matrix4Stack(); + cc.projection_matrix_stack = new cc.math.Matrix4Stack(); + cc.texture_matrix_stack = new cc.math.Matrix4Stack(); -cc.KM_GL_TEXTURE = 0x1702; + cc.current_stack = null; + var initialized = false; -cc.modelview_matrix_stack = new cc.km_mat4_stack(); -cc.projection_matrix_stack = new cc.km_mat4_stack(); -cc.texture_matrix_stack = new cc.km_mat4_stack(); + cc.lazyInitialize = function () { + if (!initialized) { + var identity = new cc.math.Matrix4(); //Temporary identity matrix -cc.current_stack = null; + //Initialize all 3 stacks + cc.modelview_matrix_stack.initialized(); + cc.projection_matrix_stack.initialized(); + cc.texture_matrix_stack.initialized(); -cc.initialized = false; - -cc.lazyInitialize = function () { - if (!cc.initialized) { - var identity = new cc.kmMat4(); //Temporary identity matrix - - //Initialize all 3 stacks - cc.km_mat4_stack_initialize(cc.modelview_matrix_stack); - cc.km_mat4_stack_initialize(cc.projection_matrix_stack); - cc.km_mat4_stack_initialize(cc.texture_matrix_stack); - - cc.current_stack = cc.modelview_matrix_stack; - cc.initialized = true; - cc.kmMat4Identity(identity); - - //Make sure that each stack has the identity matrix - cc.km_mat4_stack_push(cc.modelview_matrix_stack, identity); - cc.km_mat4_stack_push(cc.projection_matrix_stack, identity); - cc.km_mat4_stack_push(cc.texture_matrix_stack, identity); - } -}; - -cc.lazyInitialize(); - -cc.kmGLFreeAll = function () { - //Clear the matrix stacks - cc.km_mat4_stack_release(cc.modelview_matrix_stack); - cc.km_mat4_stack_release(cc.projection_matrix_stack); - cc.km_mat4_stack_release(cc.texture_matrix_stack); - - //Delete the matrices - cc.initialized = false; //Set to uninitialized - cc.current_stack = null; //Set the current stack to point nowhere -}; - -cc.kmGLPushMatrix = function () { - cc.km_mat4_stack_push(cc.current_stack, cc.current_stack.top); -}; - -cc.kmGLPushMatrixWitMat4 = function (saveMat) { - cc.current_stack.stack.push(cc.current_stack.top); - cc.kmMat4Assign(saveMat, cc.current_stack.top); - cc.current_stack.top = saveMat; -}; - -cc.kmGLPopMatrix = function () { - //No need to lazy initialize, you shouldnt be popping first anyway! - //cc.km_mat4_stack_pop(cc.current_stack, null); - cc.current_stack.top = cc.current_stack.stack.pop(); -}; - -cc.kmGLMatrixMode = function (mode) { - //cc.lazyInitialize(); - switch (mode) { - case cc.KM_GL_MODELVIEW: cc.current_stack = cc.modelview_matrix_stack; - break; - case cc.KM_GL_PROJECTION: - cc.current_stack = cc.projection_matrix_stack; - break; - case cc.KM_GL_TEXTURE: - cc.current_stack = cc.texture_matrix_stack; - break; - default: - throw "Invalid matrix mode specified"; //TODO: Proper error handling - break; - } -}; - -cc.kmGLLoadIdentity = function () { - //cc.lazyInitialize(); - cc.kmMat4Identity(cc.current_stack.top); //Replace the top matrix with the identity matrix -}; - -cc.kmGLLoadMatrix = function (pIn) { - //cc.lazyInitialize(); - cc.kmMat4Assign(cc.current_stack.top, pIn); -}; - -cc.kmGLMultMatrix = function (pIn) { - //cc.lazyInitialize(); - cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, pIn); -}; - -cc.kmGLTranslatef = function (x, y, z) { - var translation = new cc.kmMat4(); - - //Create a rotation matrix using the axis and the angle - cc.kmMat4Translation(translation, x, y, z); - - //Multiply the rotation matrix by the current matrix - cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, translation); -}; - -cc.kmGLRotatef = function (angle, x, y, z) { - var axis = new cc.math.Vec3(x, y, z); - var rotation = new cc.kmMat4(); - - //Create a rotation matrix using the axis and the angle - cc.kmMat4RotationAxisAngle(rotation, axis, cc.degreesToRadians(angle)); - - //Multiply the rotation matrix by the current matrix - cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, rotation); -}; - -cc.kmGLScalef = function (x, y, z) { - var scaling = new cc.kmMat4(); - cc.kmMat4Scaling(scaling, x, y, z); - cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, scaling); -}; - -cc.kmGLGetMatrix = function (mode, pOut) { - //cc.lazyInitialize(); - switch (mode) { - case cc.KM_GL_MODELVIEW: - cc.kmMat4Assign(pOut, cc.modelview_matrix_stack.top); - break; - case cc.KM_GL_PROJECTION: - cc.kmMat4Assign(pOut, cc.projection_matrix_stack.top); - break; - case cc.KM_GL_TEXTURE: - cc.kmMat4Assign(pOut, cc.texture_matrix_stack.top); - break; - default: - throw "Invalid matrix mode specified"; //TODO: Proper error handling - break; - } -}; + cc.initialized = true; + identity.identity(); + + //Make sure that each stack has the identity matrix + cc.modelview_matrix_stack.push(identity); + cc.projection_matrix_stack.push(identity); + cc.texture_matrix_stack.push(identity); + } + }; + + cc.lazyInitialize(); + + cc.kmGLFreeAll = function () { + //Clear the matrix stacks + cc.modelview_matrix_stack.release(); + cc.modelview_matrix_stack = null; + cc.projection_matrix_stack.release(); + cc.projection_matrix_stack = null; + cc.texture_matrix_stack.release(); + cc.texture_matrix_stack = null; + + //Delete the matrices + cc.initialized = false; //Set to uninitialized + cc.current_stack = null; //Set the current stack to point nowhere + }; + + cc.kmGLPushMatrix = function () { + cc.current_stack.push(cc.current_stack.top); + }; + + cc.kmGLPushMatrixWitMat4 = function (saveMat) { + cc.current_stack.stack.push(cc.current_stack.top); + saveMat.assignFrom(cc.current_stack.top); + cc.current_stack.top = saveMat; + }; + + cc.kmGLPopMatrix = function () { + //No need to lazy initialize, you shouldnt be popping first anyway! + //cc.km_mat4_stack_pop(cc.current_stack, null); + cc.current_stack.top = cc.current_stack.stack.pop(); + }; + + cc.kmGLMatrixMode = function (mode) { + //cc.lazyInitialize(); + switch (mode) { + case cc.KM_GL_MODELVIEW: + cc.current_stack = cc.modelview_matrix_stack; + break; + case cc.KM_GL_PROJECTION: + cc.current_stack = cc.projection_matrix_stack; + break; + case cc.KM_GL_TEXTURE: + cc.current_stack = cc.texture_matrix_stack; + break; + default: + throw "Invalid matrix mode specified"; //TODO: Proper error handling + break; + } + }; + + cc.kmGLLoadIdentity = function () { + //cc.lazyInitialize(); + cc.current_stack.top.identity(); //Replace the top matrix with the identity matrix + }; + + cc.kmGLLoadMatrix = function (pIn) { + //cc.lazyInitialize(); + cc.current_stack.top.assignFrom(pIn); + }; + + cc.kmGLMultMatrix = function (pIn) { + //cc.lazyInitialize(); + cc.current_stack.top.multiply(pIn); + }; + + var tempMatrix = new cc.math.Matrix4(); //an internal matrix + cc.kmGLTranslatef = function (x, y, z) { + //Create a rotation matrix using translation + var translation = cc.math.Matrix4.createByTranslation(x, y, z, tempMatrix); + + //Multiply the rotation matrix by the current matrix + cc.current_stack.top.multiply(translation); + }; + + var tempVector3 = new cc.math.Vec3(x, y, z); + cc.kmGLRotatef = function (angle, x, y, z) { + tempVector3.fill(x, y, z); + //Create a rotation matrix using the axis and the angle + var rotation = cc.math.Matrix4.createByAxisAndAngle(tempVector3, cc.degreesToRadians(angle), tempMatrix); + + //Multiply the rotation matrix by the current matrix + cc.current_stack.top.multiply(rotation); + }; + + cc.kmGLScalef = function (x, y, z) { + var scaling = cc.math.Matrix4.createByScale(x, y, z, tempMatrix); + cc.current_stack.top.multiply(scaling); + }; + + cc.kmGLGetMatrix = function (mode, pOut) { + //cc.lazyInitialize(); + switch (mode) { + case cc.KM_GL_MODELVIEW: + pOut.assignFrom(cc.modelview_matrix_stack.top); + break; + case cc.KM_GL_PROJECTION: + pOut.assignFrom(cc.projection_matrix_stack.top); + break; + case cc.KM_GL_TEXTURE: + pOut.assignFrom(cc.texture_matrix_stack.top); + break; + default: + throw "Invalid matrix mode specified"; //TODO: Proper error handling + break; + } + }; +})(cc); diff --git a/cocos2d/kazmath/mat3.js b/cocos2d/kazmath/mat3.js index 87c11a4871..737bc9b77f 100644 --- a/cocos2d/kazmath/mat3.js +++ b/cocos2d/kazmath/mat3.js @@ -30,10 +30,7 @@ var Float32Array = Float32Array || Array; (function(cc){ cc.math.Matrix3 = function(mat3) { if (mat3) { - var mat = mat3; - this.mat = new Float32Array([mat[0], mat[1], mat[2], - mat[3], mat[4], mat[5], - mat[60], mat[7], mat[8]]); + this.mat = new Float32Array(mat3); } else { this.mat = new Float32Array([0, 0, 0, 0, 0, 0, @@ -88,7 +85,7 @@ var Float32Array = Float32Array || Array; proto.inverse = function(determinate){ //cc.kmMat3Inverse if (determinate === 0.0) return this; - tmpMatrix.assign(this); + tmpMatrix.assignFrom(this); var detInv = 1.0 / determinate; this.adjugate(); this.multiplyScalar(detInv); @@ -189,7 +186,7 @@ var Float32Array = Float32Array || Array; return retMat; }; - proto.assign = function(matIn){ // cc.kmMat3Assign + proto.assignFrom = function(matIn){ // cc.kmMat3Assign if(this === matIn) { cc.log("cc.math.Matrix3.assign(): current matrix equals matIn"); return this; diff --git a/cocos2d/kazmath/mat4.js b/cocos2d/kazmath/mat4.js index f142132742..45b9a1d59b 100644 --- a/cocos2d/kazmath/mat4.js +++ b/cocos2d/kazmath/mat4.js @@ -26,779 +26,989 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - *

    - A 4x4 matrix
    -
    - mat =
    - | 0 4 8 12 |
    - | 1 5 9 13 |
    - | 2 6 10 14 |
    - | 3 7 11 15 | -

    - */ -cc.kmMat4 = function () { - this.mat = new Float32Array([0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]); -}; +(function(cc) { + /** + *

    + * A 4x4 matrix
    + *
    + * mat =
    + * | 0 4 8 12 |
    + * | 1 5 9 13 |
    + * | 2 6 10 14 |
    + * | 3 7 11 15 | + *

    + * @param {cc.math.Matrix4} [mat4] + */ + cc.math.Matrix4 = function (mat4) { + if(mat4){ + this.mat = new Float32Array(mat4.mat); + } else { + this.mat = new Float32Array([0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0]); + } + }; + cc.kmMat4 = cc.math.Matrix4; + var proto = cc.math.Matrix4.prototype; -/** - * Fills a kmMat4 structure with the values from a 16 element array of floats - * @Params pOut - A pointer to the destination matrix - * @Params pMat - A 16 element array of floats - * @Return Returns pOut so that the call can be nested - */ -cc.kmMat4Fill = function (pOut, pMat) { - pOut.mat[0] = pOut.mat[1] = pOut.mat[2] =pOut.mat[3] = - pOut.mat[4] =pOut.mat[5] =pOut.mat[6] =pOut.mat[7] = - pOut.mat[8] =pOut.mat[9] =pOut.mat[10] =pOut.mat[11] = - pOut.mat[12] =pOut.mat[13] =pOut.mat[14] =pOut.mat[15] =pMat; -}; + /** + * Fills a cc.math.Matrix4 structure with the values from a 16 element array of floats + * @param {Array} scalarArr + */ + proto.fill = function(scalarArr){ //cc.kmMat4Fill + var mat = this.mat; + for(var i = 0; i < 16; i++){ + mat[i] = scalarArr[i]; + } + return this; + }; -/** - * Sets pOut to an identity matrix returns pOut - * @Params pOut - A pointer to the matrix to set to identity - * @Return Returns pOut so that the call can be nested - */ -cc.kmMat4Identity = function (pOut) { - pOut.mat[1] = pOut.mat[2] = pOut.mat[3] - = pOut.mat[4] = pOut.mat[6] = pOut.mat[7] - = pOut.mat[8] = pOut.mat[9] = pOut.mat[11] - = pOut.mat[12] = pOut.mat[13] = pOut.mat[14] = 0; - pOut.mat[0] = pOut.mat[5] = pOut.mat[10] = pOut.mat[15] = 1.0; - return pOut; -}; - -cc.kmMat4._get = function (pIn, row, col) { - return pIn.mat[row + 4 * col]; -}; - -cc.kmMat4._set = function (pIn, row, col, value) { - pIn.mat[row + 4 * col] = value; -}; - -cc.kmMat4._swap = function (pIn, r1, c1, r2, c2) { - var tmp = cc.kmMat4._get(pIn, r1, c1); - cc.kmMat4._set(pIn, r1, c1, cc.kmMat4._get(pIn, r2, c2)); - cc.kmMat4._set(pIn, r2, c2, tmp); -}; - -//Returns an upper and a lower triangular matrix which are L and R in the Gauss algorithm -cc.kmMat4._gaussj = function (a, b) { - var i, icol = 0, irow = 0, j, k, l, ll, n = 4, m = 4; - var big, dum, pivinv; - var indxc = [0, 0, 0, 0]; - var indxr = [0, 0, 0, 0]; - var ipiv = [0, 0, 0, 0]; - - /* for (j = 0; j < n; j++) { - ipiv[j] = 0; - }*/ - - for (i = 0; i < n; i++) { - big = 0.0; - for (j = 0; j < n; j++) { - if (ipiv[j] != 1) { - for (k = 0; k < n; k++) { - if (ipiv[k] == 0) { - if (Math.abs(cc.kmMat4._get(a, j, k)) >= big) { - big = Math.abs(cc.kmMat4._get(a, j, k)); - irow = j; - icol = k; + /** + * Sets pOut to an identity matrix returns pOut + * @Params pOut - A pointer to the matrix to set to identity + * @Return Returns pOut so that the call can be nested + */ + cc.kmMat4Identity = function (pOut) { + var mat = pOut.mat; + mat[1] = mat[2] = mat[3] = mat[4] = mat[6] = mat[7] + = mat[8] = mat[9] = mat[11] = mat[12] = mat[13] = mat[14] = 0; + mat[0] = mat[5] = mat[10] = mat[15] = 1.0; + return pOut; + }; + + /** + * Sets matrix to identity value. + * @returns {cc.math.Matrix4} + */ + proto.identity = function(){ + var mat = this.mat; + mat[1] = mat[2] = mat[3] = mat[4] = mat[6] = mat[7] + = mat[8] = mat[9] = mat[11] = mat[12] = mat[13] = mat[14] = 0; + mat[0] = mat[5] = mat[10] = mat[15] = 1.0; + return this; + }; + + proto.get = function(row, col){ + return this.mat[row + 4 * col]; + }; + + proto.set = function(row, col, value){ + this.mat[row + 4 * col] = value; + }; + + proto.swap = function(r1, c1, r2, c2) { +/* var tmp = this.get(r1, c1); + this.set(r1, c1, this.get(r2, c2)); + this.set(r2, c2, tmp);*/ + var mat = this.mat, tmp = mat[r1 + 4 * c1]; + mat[r1 + 4 * c1] = mat[r2 + 4 * c2]; + mat[r2 + 4 * c2] = tmp; + }; + + //Returns an upper and a lower triangular matrix which are L and R in the Gauss algorithm + cc.math.Matrix4._gaussj = function (a, b) { + var i, icol = 0, irow = 0, j, k, l, ll, n = 4, m = 4, selElement; + var big, dum, pivinv; + var indxc = [0, 0, 0, 0], indxr = [0, 0, 0, 0], ipiv = [0, 0, 0, 0]; + + /* for (j = 0; j < n; j++) { + ipiv[j] = 0; + }*/ + + for (i = 0; i < n; i++) { + big = 0.0; + for (j = 0; j < n; j++) { + if (ipiv[j] !== 1) { + for (k = 0; k < n; k++) { + if (ipiv[k] === 0) { + selElement = Math.abs(a.get(j, k)); + if (selElement >= big) { + big = selElement; + irow = j; + icol = k; + } } } } } - } - ++(ipiv[icol]); - if (irow != icol) { - for (l = 0; l < n; l++) - cc.kmMat4._swap(a, irow, l, icol, l); - for (l = 0; l < m; l++) - cc.kmMat4._swap(b, irow, l, icol, l); - } - indxr[i] = irow; - indxc[i] = icol; - if (cc.kmMat4._get(a, icol, icol) == 0.0) - return false; - - pivinv = 1.0 / cc.kmMat4._get(a, icol, icol); - cc.kmMat4._set(a, icol, icol, 1.0); - for (l = 0; l < n; l++) - cc.kmMat4._set(a, icol, l, cc.kmMat4._get(a, icol, l) * pivinv); - - for (l = 0; l < m; l++) - cc.kmMat4._set(b, icol, l, cc.kmMat4._get(b, icol, l) * pivinv); - - for (ll = 0; ll < n; ll++) { - if (ll != icol) { - dum = cc.kmMat4._get(a, ll, icol); - cc.kmMat4._set(a, ll, icol, 0.0); + ++(ipiv[icol]); + if (irow != icol) { for (l = 0; l < n; l++) - cc.kmMat4._set(a, ll, l, cc.kmMat4._get(a, ll, l) - cc.kmMat4._get(a, icol, l) * dum); - + a.swap(irow, l, icol, l); for (l = 0; l < m; l++) - cc.kmMat4._set(b, ll, l, cc.kmMat4._get(a, ll, l) - cc.kmMat4._get(b, icol, l) * dum); + b.swap(irow, l, icol, l); } - } - } -// This is the end of the main loop over columns of the reduction. It only remains to unscram- -// ble the solution in view of the column interchanges. We do this by interchanging pairs of -// columns in the reverse order that the permutation was built up. - for (l = n - 1; l >= 0; l--) { - if (indxr[l] != indxc[l]) { - for (k = 0; k < n; k++) - cc.kmMat4._swap(a, k, indxr[l], k, indxc[l]); - } - } - return true; -}; - -cc.kmMat4._identity = - new Float32Array([1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0]); - -/** - * Calculates the inverse of pM and stores the result in - * pOut. - * @Return Returns NULL if there is no inverse, else pOut - */ -cc.kmMat4Inverse = function (pOut, pM) { - var inv = new cc.kmMat4(); - var tmp = new cc.kmMat4(); + indxr[i] = irow; + indxc[i] = icol; + if (a.get(icol, icol) === 0.0) + return false; - cc.kmMat4Assign(inv, pM); - cc.kmMat4Identity(tmp); - - if (cc.kmMat4._gaussj(inv, tmp) == false) - return null; + pivinv = 1.0 / a.get(icol, icol); + a.set(icol, icol, 1.0); + for (l = 0; l < n; l++) + a.set(icol, l, a.get(icol, l) * pivinv); - cc.kmMat4Assign(pOut, inv); - return pOut; -}; + for (l = 0; l < m; l++) + b.set(icol, l, b.get(icol, l) * pivinv); -/** - * Returns KM_TRUE if pIn is an identity matrix - * KM_FALSE otherwise - */ -cc.kmMat4IsIdentity = function (pIn) { - for (var i = 0; i < 16; i++) { - if (cc.kmMat4._identity[i] != pIn.mat[i]) - return false; - } - return true; -}; + for (ll = 0; ll < n; ll++) { + if (ll != icol) { + dum = a.get(ll, icol); + a.set(ll, icol, 0.0); + for (l = 0; l < n; l++) + a.set(ll, l, a.get(ll, l) - a.get(icol, l) * dum); -/** - * Sets pOut to the transpose of pIn, returns pOut - */ -cc.kmMat4Transpose = function (pOut, pIn) { - var x, z, outArr = pOut.mat,inArr = pIn.mat; - for (z = 0; z < 4; ++z) { - for (x = 0; x < 4; ++x) - outArr[(z * 4) + x] = inArr[(x * 4) + z]; - } - return pOut; -}; + for (l = 0; l < m; l++) + b.set(ll, l, a.get(ll, l) - b.get(icol, l) * dum); + } + } + } + // This is the end of the main loop over columns of the reduction. It only remains to unscram- + // ble the solution in view of the column interchanges. We do this by interchanging pairs of + // columns in the reverse order that the permutation was built up. + for (l = n - 1; l >= 0; l--) { + if (indxr[l] != indxc[l]) { + for (k = 0; k < n; k++) + a.swap(k, indxr[l], k, indxc[l]); + } + } + return true; + }; -/** - * Multiplies pM1 with pM2, stores the result in pOut, returns pOut - */ -cc.kmMat4Multiply = function (pOut, pM1, pM2) { - // Cache the matrix values (makes for huge speed increases!) - var outArray = pOut.mat; - var a00 = pM1.mat[0], a01 = pM1.mat[1], a02 = pM1.mat[2], a03 = pM1.mat[3]; - var a10 = pM1.mat[4], a11 = pM1.mat[5], a12 = pM1.mat[6], a13 = pM1.mat[7]; - var a20 = pM1.mat[8], a21 = pM1.mat[9], a22 = pM1.mat[10], a23 = pM1.mat[11]; - var a30 = pM1.mat[12], a31 = pM1.mat[13], a32 = pM1.mat[14], a33 = pM1.mat[15]; - - var b00 = pM2.mat[0], b01 = pM2.mat[1], b02 = pM2.mat[2], b03 = pM2.mat[3]; - var b10 = pM2.mat[4], b11 = pM2.mat[5], b12 = pM2.mat[6], b13 = pM2.mat[7]; - var b20 = pM2.mat[8], b21 = pM2.mat[9], b22 = pM2.mat[10], b23 = pM2.mat[11]; - var b30 = pM2.mat[12], b31 = pM2.mat[13], b32 = pM2.mat[14], b33 = pM2.mat[15]; - - outArray[0] = b00 * a00 + b01 * a10 + b02 * a20 + b03 * a30; - outArray[1] = b00 * a01 + b01 * a11 + b02 * a21 + b03 * a31; - outArray[2] = b00 * a02 + b01 * a12 + b02 * a22 + b03 * a32; - outArray[3] = b00 * a03 + b01 * a13 + b02 * a23 + b03 * a33; - outArray[4] = b10 * a00 + b11 * a10 + b12 * a20 + b13 * a30; - outArray[5] = b10 * a01 + b11 * a11 + b12 * a21 + b13 * a31; - outArray[6] = b10 * a02 + b11 * a12 + b12 * a22 + b13 * a32; - outArray[7] = b10 * a03 + b11 * a13 + b12 * a23 + b13 * a33; - outArray[8] = b20 * a00 + b21 * a10 + b22 * a20 + b23 * a30; - outArray[9] = b20 * a01 + b21 * a11 + b22 * a21 + b23 * a31; - outArray[10] = b20 * a02 + b21 * a12 + b22 * a22 + b23 * a32; - outArray[11] = b20 * a03 + b21 * a13 + b22 * a23 + b23 * a33; - outArray[12] = b30 * a00 + b31 * a10 + b32 * a20 + b33 * a30; - outArray[13] = b30 * a01 + b31 * a11 + b32 * a21 + b33 * a31; - outArray[14] = b30 * a02 + b31 * a12 + b32 * a22 + b33 * a32; - outArray[15] = b30 * a03 + b31 * a13 + b32 * a23 + b33 * a33; - return pOut; -}; - -cc.getMat4MultiplyValue = function (pM1, pM2) { - var m1 = pM1.mat, m2 = pM2.mat; - var mat = new Float32Array(16); - - mat[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]; - mat[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]; - mat[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]; - mat[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]; - - mat[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]; - mat[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]; - mat[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]; - mat[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]; - - mat[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]; - mat[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]; - mat[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]; - mat[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]; - - mat[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]; - mat[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]; - mat[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; - mat[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; - - return mat; -}; - -cc.getMat4MultiplyWithMat4 = function (pM1, pM2, swapMat) { - var m1 = pM1.mat, m2 = pM2.mat; - var mat = swapMat.mat; - - mat[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]; - mat[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]; - mat[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]; - mat[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]; - - mat[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]; - mat[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]; - mat[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]; - mat[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]; - - mat[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]; - mat[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]; - mat[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]; - mat[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]; - - mat[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]; - mat[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]; - mat[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; - mat[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; - - return swapMat.mat; -}; + var identityMatrix = new cc.math.Matrix4().identity(); + /** + * Calculates the inverse of pM and stores the result in pOut. + * Please use matrix4's inverse function instead. + * @Return Returns NULL if there is no inverse, else pOut + */ + cc.kmMat4Inverse = function (pOut, pM) { + var inv = new cc.math.Matrix4(pM); + if (cc.math.Matrix4._gaussj(inv, identityMatrix) === false) + return null; + pOut.assignFrom(inv); + return pOut; + }; -/** - * Assigns the value of pIn to pOut - */ -cc.kmMat4Assign = function (pOut, pIn) { - if(pOut == pIn) { - cc.log("cc.kmMat4Assign(): pOut equals pIn"); + /** + * Calculates the inverse of current matrix. + * @returns {cc.math.Matrix4} Returns null if there is no inverse, else returns a new inverse matrix object + */ + proto.inverse = function(){ //cc.kmMat4Inverse + var inv = new cc.math.Matrix4(this); + if (cc.math.Matrix4._gaussj(inv, identityMatrix) === false) + return null; + return inv; + }; + + /** + * Returns true if current matrix is an identity matrix, false otherwise + */ + proto.isIdentity = function () { // cc.kmMat4IsIdentity + var mat = this.mat; + return (mat[0] === 1 && mat[1] === 0 && mat[2] === 0 && mat[3] === 0 + && mat[4] === 0 && mat[5] === 1 && mat[6] === 0 && mat[7] === 0 + && mat[8] === 0 && mat[9] === 0 && mat[10] === 1 && mat[11] === 0 + && mat[12] === 0 && mat[13] === 0 && mat[14] === 0 && mat[15] === 1); + }; + + /** + * transpose the current matrix + */ + proto.transpose = function() { // cc.kmMat4Transpose + var mat = this.mat; + var m1 = mat[1], m2 = mat[2], m3 = mat[3], + m4 = mat[4], m6 = mat[6], m7 = mat[7], + m8 = mat[8], m9 = mat[9], m11 = mat[11], + m12 = mat[12], m13 = mat[13], m14 = mat[14]; + mat[1] = m4; + mat[2] = m8; + mat[3] = m12; + + mat[4] = m1; + mat[6] = m9; + mat[7] = m13; + + mat[8] = m2; + mat[9] = m6; + mat[11] = m14; + + mat[12] = m3; + mat[13] = m7; + mat[14] = m11; + return this; + }; + + /** + * Multiplies pM1 with pM2, stores the result in pOut, returns pOut + */ + cc.kmMat4Multiply = function (pOut, pM1, pM2) { + // Cache the matrix values (makes for huge speed increases!) + var outArray = pOut.mat, mat1 = pM1.mat, mat2 = pM2.mat; + var a00 = mat1[0], a01 = mat1[1], a02 = mat1[2], a03 = mat1[3]; + var a10 = mat1[4], a11 = mat1[5], a12 = mat1[6], a13 = mat1[7]; + var a20 = mat1[8], a21 = mat1[9], a22 = mat1[10], a23 = mat1[11]; + var a30 = mat1[12], a31 = mat1[13], a32 = mat1[14], a33 = mat1[15]; + + var b00 = mat2[0], b01 = mat2[1], b02 = mat2[2], b03 = mat2[3]; + var b10 = mat2[4], b11 = mat2[5], b12 = mat2[6], b13 = mat2[7]; + var b20 = mat2[8], b21 = mat2[9], b22 = mat2[10], b23 = mat2[11]; + var b30 = mat2[12], b31 = mat2[13], b32 = mat2[14], b33 = mat2[15]; + + outArray[0] = b00 * a00 + b01 * a10 + b02 * a20 + b03 * a30; + outArray[1] = b00 * a01 + b01 * a11 + b02 * a21 + b03 * a31; + outArray[2] = b00 * a02 + b01 * a12 + b02 * a22 + b03 * a32; + outArray[3] = b00 * a03 + b01 * a13 + b02 * a23 + b03 * a33; + outArray[4] = b10 * a00 + b11 * a10 + b12 * a20 + b13 * a30; + outArray[5] = b10 * a01 + b11 * a11 + b12 * a21 + b13 * a31; + outArray[6] = b10 * a02 + b11 * a12 + b12 * a22 + b13 * a32; + outArray[7] = b10 * a03 + b11 * a13 + b12 * a23 + b13 * a33; + outArray[8] = b20 * a00 + b21 * a10 + b22 * a20 + b23 * a30; + outArray[9] = b20 * a01 + b21 * a11 + b22 * a21 + b23 * a31; + outArray[10] = b20 * a02 + b21 * a12 + b22 * a22 + b23 * a32; + outArray[11] = b20 * a03 + b21 * a13 + b22 * a23 + b23 * a33; + outArray[12] = b30 * a00 + b31 * a10 + b32 * a20 + b33 * a30; + outArray[13] = b30 * a01 + b31 * a11 + b32 * a21 + b33 * a31; + outArray[14] = b30 * a02 + b31 * a12 + b32 * a22 + b33 * a32; + outArray[15] = b30 * a03 + b31 * a13 + b32 * a23 + b33 * a33; return pOut; - } + }; - var outArr = pOut.mat; - var inArr = pIn.mat; + /** + * current matrix multiplies with other matrix mat4 + * @param {cc.math.Matrix4} mat4 + * @returns {cc.math.Matrix4} + */ + proto.multiply = function(mat4){ + // Cache the matrix values (makes for huge speed increases!) + var mat = this.mat, mat2 = mat4.mat; + var a00 = mat[0], a01 = mat[1], a02 = mat[2], a03 = mat[3]; + var a10 = mat[4], a11 = mat[5], a12 = mat[6], a13 = mat[7]; + var a20 = mat[8], a21 = mat[9], a22 = mat[10], a23 = mat[11]; + var a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15]; + + var b00 = mat2[0], b01 = mat2[1], b02 = mat2[2], b03 = mat2[3]; + var b10 = mat2[4], b11 = mat2[5], b12 = mat2[6], b13 = mat2[7]; + var b20 = mat2[8], b21 = mat2[9], b22 = mat2[10], b23 = mat2[11]; + var b30 = mat2[12], b31 = mat2[13], b32 = mat2[14], b33 = mat2[15]; + + mat[0] = b00 * a00 + b01 * a10 + b02 * a20 + b03 * a30; + mat[1] = b00 * a01 + b01 * a11 + b02 * a21 + b03 * a31; + mat[2] = b00 * a02 + b01 * a12 + b02 * a22 + b03 * a32; + mat[3] = b00 * a03 + b01 * a13 + b02 * a23 + b03 * a33; + mat[4] = b10 * a00 + b11 * a10 + b12 * a20 + b13 * a30; + mat[5] = b10 * a01 + b11 * a11 + b12 * a21 + b13 * a31; + mat[6] = b10 * a02 + b11 * a12 + b12 * a22 + b13 * a32; + mat[7] = b10 * a03 + b11 * a13 + b12 * a23 + b13 * a33; + mat[8] = b20 * a00 + b21 * a10 + b22 * a20 + b23 * a30; + mat[9] = b20 * a01 + b21 * a11 + b22 * a21 + b23 * a31; + mat[10] = b20 * a02 + b21 * a12 + b22 * a22 + b23 * a32; + mat[11] = b20 * a03 + b21 * a13 + b22 * a23 + b23 * a33; + mat[12] = b30 * a00 + b31 * a10 + b32 * a20 + b33 * a30; + mat[13] = b30 * a01 + b31 * a11 + b32 * a21 + b33 * a31; + mat[14] = b30 * a02 + b31 * a12 + b32 * a22 + b33 * a32; + mat[15] = b30 * a03 + b31 * a13 + b32 * a23 + b33 * a33; + return this; + }; + + cc.getMat4MultiplyValue = function (pM1, pM2) { + var m1 = pM1.mat, m2 = pM2.mat; + var mat = new Float32Array(16); + + mat[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]; + mat[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]; + mat[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]; + mat[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]; + + mat[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]; + mat[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]; + mat[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]; + mat[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]; + + mat[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]; + mat[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]; + mat[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]; + mat[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]; + + mat[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]; + mat[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]; + mat[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; + mat[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; + + return mat; + }; + + /** + * Assigns the value of pIn to pOut + */ + cc.kmMat4Assign = function (pOut, pIn) { + if (pOut === pIn) { + cc.log("cc.kmMat4Assign(): pOut equals pIn"); + return pOut; + } - outArr[0] = inArr[0]; - outArr[1] = inArr[1]; - outArr[2] = inArr[2]; - outArr[3] = inArr[3]; + var outArr = pOut.mat; + var inArr = pIn.mat; - outArr[4] = inArr[4]; - outArr[5] = inArr[5]; - outArr[6] = inArr[6]; - outArr[7] = inArr[7]; + outArr[0] = inArr[0]; + outArr[1] = inArr[1]; + outArr[2] = inArr[2]; + outArr[3] = inArr[3]; - outArr[8] = inArr[8]; - outArr[9] = inArr[9]; - outArr[10] = inArr[10]; - outArr[11] = inArr[11]; + outArr[4] = inArr[4]; + outArr[5] = inArr[5]; + outArr[6] = inArr[6]; + outArr[7] = inArr[7]; - outArr[12] = inArr[12]; - outArr[13] = inArr[13]; - outArr[14] = inArr[14]; - outArr[15] = inArr[15]; - return pOut; -}; + outArr[8] = inArr[8]; + outArr[9] = inArr[9]; + outArr[10] = inArr[10]; + outArr[11] = inArr[11]; -/** - * Returns KM_TRUE if the 2 matrices are equal (approximately) - */ -cc.kmMat4AreEqual = function (pMat1, pMat2) { - if(pMat1 == pMat2){ - cc.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."); - return true; - } + outArr[12] = inArr[12]; + outArr[13] = inArr[13]; + outArr[14] = inArr[14]; + outArr[15] = inArr[15]; + return pOut; + }; - for (var i = 0; i < 16; i++) { - if (!(pMat1.mat[i] + cc.math.EPSILON > pMat2.mat[i] && - pMat1.mat[i] - cc.math.EPSILON < pMat2.mat[i])) { - return false; + /** + * Assigns the value of current matrix from mat4 + * @param {cc.math.Matrix4} mat4 + * @returns {cc.math.Matrix4} + */ + proto.assignFrom = function(mat4) { + if (this == mat4) { + cc.log("cc.mat.Matrix4.assignFrom(): mat4 equals current matrix"); + return this; } - } - return true; -}; - -/** - * Builds an X-axis rotation matrix and stores it in pOut, returns pOut - */ -cc.kmMat4RotationX = function (pOut, radians) { - /* - | 1 0 0 0 | - M = | 0 cos(A) -sin(A) 0 | - | 0 sin(A) cos(A) 0 | - | 0 0 0 1 | - + var outArr = this.mat, inArr = mat4.mat; + + outArr[0] = inArr[0]; + outArr[1] = inArr[1]; + outArr[2] = inArr[2]; + outArr[3] = inArr[3]; + + outArr[4] = inArr[4]; + outArr[5] = inArr[5]; + outArr[6] = inArr[6]; + outArr[7] = inArr[7]; + + outArr[8] = inArr[8]; + outArr[9] = inArr[9]; + outArr[10] = inArr[10]; + outArr[11] = inArr[11]; + + outArr[12] = inArr[12]; + outArr[13] = inArr[13]; + outArr[14] = inArr[14]; + outArr[15] = inArr[15]; + return this; + }; + + /** + * Returns true if current matrix equal mat4 (approximately) + * @param {cc.math.Matrix4} mat4 + * @returns {boolean} */ + proto.equals = function(mat4) { + if (this === mat4) { + cc.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."); + return true; + } + var matA = this.mat, matB = mat4.mat, EPSILON = cc.math.EPSILON; + for (var i = 0; i < 16; i++) { + if (!(matA[i] + EPSILON > matB[i] && matA[i] - EPSILON < matB[i])) + return false; + } + return true; + }; - pOut.mat[0] = 1.0; - pOut.mat[1] = 0.0; - pOut.mat[2] = 0.0; - pOut.mat[3] = 0.0; - - pOut.mat[4] = 0.0; - pOut.mat[5] = Math.cos(radians); - pOut.mat[6] = Math.sin(radians); - pOut.mat[7] = 0.0; - - pOut.mat[8] = 0.0; - pOut.mat[9] = -Math.sin(radians); - pOut.mat[10] = Math.cos(radians); - pOut.mat[11] = 0.0; - - pOut.mat[12] = 0.0; - pOut.mat[13] = 0.0; - pOut.mat[14] = 0.0; - pOut.mat[15] = 1.0; - - return pOut; -}; - -/** - * Builds a rotation matrix using the rotation around the Y-axis - * The result is stored in pOut, pOut is returned. - */ -cc.kmMat4RotationY = function (pOut, radians) { - /* - | cos(A) 0 sin(A) 0 | - M = | 0 1 0 0 | - | -sin(A) 0 cos(A) 0 | - | 0 0 0 1 | - */ - pOut.mat[0] = Math.cos(radians); - pOut.mat[1] = 0.0; - pOut.mat[2] = -Math.sin(radians); - pOut.mat[3] = 0.0; - - pOut.mat[4] = 0.0; - pOut.mat[5] = 1.0; - pOut.mat[6] = 0.0; - pOut.mat[7] = 0.0; - - pOut.mat[8] = Math.sin(radians); - pOut.mat[9] = 0.0; - pOut.mat[10] = Math.cos(radians); - pOut.mat[11] = 0.0; - - pOut.mat[12] = 0.0; - pOut.mat[13] = 0.0; - pOut.mat[14] = 0.0; - pOut.mat[15] = 1.0; - - return pOut; -}; - -/** - * Builds a rotation matrix around the Z-axis. The resulting - * matrix is stored in pOut. pOut is returned. - */ -cc.kmMat4RotationZ = function (pOut, radians) { - /* - | cos(A) -sin(A) 0 0 | - M = | sin(A) cos(A) 0 0 | - | 0 0 1 0 | - | 0 0 0 1 | - */ - pOut.mat[0] = Math.cos(radians); - pOut.mat[1] = Math.sin(radians); - pOut.mat[2] = 0.0; - pOut.mat[3] = 0.0; - - pOut.mat[4] = -Math.sin(radians); - pOut.mat[5] = Math.cos(radians); - pOut.mat[6] = 0.0; - pOut.mat[7] = 0.0; - - pOut.mat[8] = 0.0; - pOut.mat[9] = 0.0; - pOut.mat[10] = 1.0; - pOut.mat[11] = 0.0; - - pOut.mat[12] = 0.0; - pOut.mat[13] = 0.0; - pOut.mat[14] = 0.0; - pOut.mat[15] = 1.0; - - return pOut; -}; - -/** - * Builds a rotation matrix from pitch, yaw and roll. The resulting - * matrix is stored in pOut and pOut is returned - */ -cc.kmMat4RotationPitchYawRoll = function (pOut, pitch, yaw, roll) { - var cr = Math.cos(pitch); - var sr = Math.sin(pitch); - var cp = Math.cos(yaw); - var sp = Math.sin(yaw); - var cy = Math.cos(roll); - var sy = Math.sin(roll); - var srsp = sr * sp; - var crsp = cr * sp; - - pOut.mat[0] = cp * cy; - pOut.mat[4] = cp * sy; - pOut.mat[8] = -sp; - - pOut.mat[1] = srsp * cy - cr * sy; - pOut.mat[5] = srsp * sy + cr * cy; - pOut.mat[9] = sr * cp; - - pOut.mat[2] = crsp * cy + sr * sy; - pOut.mat[6] = crsp * sy - sr * cy; - pOut.mat[10] = cr * cp; - - pOut.mat[3] = pOut.mat[7] = pOut.mat[11] = 0.0; - pOut.mat[15] = 1.0; - - return pOut; -}; - -/** Converts a quaternion to a rotation matrix, - * the result is stored in pOut, returns pOut - */ -cc.kmMat4RotationQuaternion = function (pOut, pQ) { - pOut.mat[0] = 1.0 - 2.0 * (pQ.y * pQ.y + pQ.z * pQ.z ); - pOut.mat[1] = 2.0 * (pQ.x * pQ.y + pQ.z * pQ.w); - pOut.mat[2] = 2.0 * (pQ.x * pQ.z - pQ.y * pQ.w); - pOut.mat[3] = 0.0; - - // Second row - pOut.mat[4] = 2.0 * ( pQ.x * pQ.y - pQ.z * pQ.w ); - pOut.mat[5] = 1.0 - 2.0 * ( pQ.x * pQ.x + pQ.z * pQ.z ); - pOut.mat[6] = 2.0 * (pQ.z * pQ.y + pQ.x * pQ.w ); - pOut.mat[7] = 0.0; - - // Third row - pOut.mat[8] = 2.0 * ( pQ.x * pQ.z + pQ.y * pQ.w ); - pOut.mat[9] = 2.0 * ( pQ.y * pQ.z - pQ.x * pQ.w ); - pOut.mat[10] = 1.0 - 2.0 * ( pQ.x * pQ.x + pQ.y * pQ.y ); - pOut.mat[11] = 0.0; - - // Fourth row - pOut.mat[12] = 0; - pOut.mat[13] = 0; - pOut.mat[14] = 0; - pOut.mat[15] = 1.0; - - return pOut; -}; - -/** Build a 4x4 OpenGL transformation matrix using a 3x3 rotation matrix, - * and a 3d vector representing a translation. Assign the result to pOut, - * pOut is also returned. - */ -cc.kmMat4RotationTranslation = function (pOut, rotation, translation) { - pOut.mat[0] = rotation.mat[0]; - pOut.mat[1] = rotation.mat[1]; - pOut.mat[2] = rotation.mat[2]; - pOut.mat[3] = 0.0; - - pOut.mat[4] = rotation.mat[3]; - pOut.mat[5] = rotation.mat[4]; - pOut.mat[6] = rotation.mat[5]; - pOut.mat[7] = 0.0; - - pOut.mat[8] = rotation.mat[6]; - pOut.mat[9] = rotation.mat[7]; - pOut.mat[10] = rotation.mat[8]; - pOut.mat[11] = 0.0; - - pOut.mat[12] = translation.x; - pOut.mat[13] = translation.y; - pOut.mat[14] = translation.z; - pOut.mat[15] = 1.0; - - return pOut; -}; - -/** Builds a scaling matrix */ -cc.kmMat4Scaling = function (pOut, x, y, z) { - pOut.mat[0] = x; - pOut.mat[5] = y; - pOut.mat[10] = z; - pOut.mat[15] = 1.0; - pOut.mat[1] = pOut.mat[2] = pOut.mat[3] = - pOut.mat[4] = pOut.mat[6] = pOut.mat[7] = - pOut.mat[8] = pOut.mat[9] = pOut.mat[11] = - pOut.mat[12] = pOut.mat[13] = pOut.mat[14] = 0; - return pOut; -}; - -/** - * Builds a translation matrix. All other elements in the matrix - * will be set to zero except for the diagonal which is set to 1.0 - */ -cc.kmMat4Translation = function (pOut, x, y, z) { - //FIXME: Write a test for this - pOut.mat[0] = pOut.mat[5] = pOut.mat[10] = pOut.mat[15] = 1.0; - pOut.mat[1] = pOut.mat[2] = pOut.mat[3] = - pOut.mat[4] = pOut.mat[6] = pOut.mat[7] = - pOut.mat[8] = pOut.mat[9] = pOut.mat[11] = 0.0; - pOut.mat[12] = x; - pOut.mat[13] = y; - pOut.mat[14] = z; - return pOut; -}; - -/** - * Get the up vector from a matrix. pIn is the matrix you - * wish to extract the vector from. pOut is a pointer to the - * kmVec3 structure that should hold the resulting vector - */ -cc.kmMat4GetUpVec3 = function (vec3, mat4) { - vec3.x = mat4.mat[4]; - vec3.y = mat4.mat[5]; - vec3.z = mat4.mat[6]; - return vec3.normalize(); -}; - -/** Extract the right vector from a 4x4 matrix. The result is - * stored in pOut. Returns pOut. - */ -cc.kmMat4GetRightVec3 = function (vec3, mat4) { - vec3.x = mat4.mat[0]; - vec3.y = mat4.mat[1]; - vec3.z = mat4.mat[2]; - return vec3.normalize(); -}; - -/** - * Extract the forward vector from a 4x4 matrix. The result is - * stored in pOut. Returns pOut. - */ -cc.kmMat4GetForwardVec3 = function (vec3, mat4) { - vec3.x = mat4.mat[8]; - vec3.y = mat4.mat[9]; - vec3.z = mat4.mat[10]; - return vec3.normalize(); -}; - -/** - * Creates a perspective projection matrix in the - * same way as gluPerspective - */ -cc.kmMat4PerspectiveProjection = function (pOut, fovY, aspect, zNear, zFar) { - var r = cc.degreesToRadians(fovY / 2); - var deltaZ = zFar - zNear; - var s = Math.sin(r); - - if (deltaZ == 0 || s == 0 || aspect == 0) - return null; - - //cos(r) / sin(r) = cot(r) - var cotangent = Math.cos(r) / s; - - cc.kmMat4Identity(pOut); - pOut.mat[0] = cotangent / aspect; - pOut.mat[5] = cotangent; - pOut.mat[10] = -(zFar + zNear) / deltaZ; - pOut.mat[11] = -1; - pOut.mat[14] = -2 * zNear * zFar / deltaZ; - pOut.mat[15] = 0; - - return pOut; -}; - -/** Creates an orthographic projection matrix like glOrtho */ -cc.kmMat4OrthographicProjection = function (pOut, left, right, bottom, top, nearVal, farVal) { - cc.kmMat4Identity(pOut); - pOut.mat[0] = 2 / (right - left); - pOut.mat[5] = 2 / (top - bottom); - pOut.mat[10] = -2 / (farVal - nearVal); - pOut.mat[12] = -((right + left) / (right - left)); - pOut.mat[13] = -((top + bottom) / (top - bottom)); - pOut.mat[14] = -((farVal + nearVal) / (farVal - nearVal)); - return pOut; -}; - -/** - * Builds a translation matrix in the same way as gluLookAt() - * the resulting matrix is stored in pOut. pOut is returned. - */ -cc.kmMat4LookAt = function (pOut, pEye, pCenter, pUp) { - var f = new cc.math.Vec3(pCenter), up = new cc.math.Vec3(pUp); - var translate = new cc.kmMat4(); - - f.subtract(pEye); - f.normalize(); - - up.normalize(); - - var s = new cc.math.Vec3(f); - s.cross(up); - s.normalize(); - - var u = new cc.math.Vec3(s); - u.cross(f); - s.normalize(); - - cc.kmMat4Identity(pOut); + /** + * Builds an X-axis rotation matrix and stores it in matrix, returns matrix, if matrix is null, create a new matrix + * @param {Number} radians + * @param {cc.math.Matrix4} [matrix] + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createByRotationX = function(radians, matrix) { //cc.kmMat4RotationX + /* + | 1 0 0 0 | + M = | 0 cos(A) -sin(A) 0 | + | 0 sin(A) cos(A) 0 | + | 0 0 0 1 | + */ + matrix = matrix || new cc.math.Matrix4(); + var mat = matrix.mat; + mat[0] = 1.0; + mat[3] = mat[2] = mat[1] = 0.0; + + mat[4] = 0.0; + mat[5] = Math.cos(radians); + mat[6] = Math.sin(radians); + mat[7] = 0.0; + + mat[8] = 0.0; + mat[9] = -Math.sin(radians); + mat[10] = Math.cos(radians); + mat[11] = 0.0; + + mat[14] = mat[13] = mat[12] = 0.0; + mat[15] = 1.0; + return matrix; + }; + + /** + * Builds a rotation matrix using the rotation around the Y-axis, The result is stored in matrix, matrix is returned. + * @param {Number} radians + * @param {cc.math.Matrix4} [matrix] + * @returns {*} + */ + cc.math.Matrix4.createByRotationY = function(radians, matrix) { // cc.kmMat4RotationY + /* + | cos(A) 0 sin(A) 0 | + M = | 0 1 0 0 | + | -sin(A) 0 cos(A) 0 | + | 0 0 0 1 | + */ + matrix = matrix || new cc.math.Matrix4(); + var mat = matrix.mat; + mat[0] = Math.cos(radians); + mat[1] = 0.0; + mat[2] = -Math.sin(radians); + mat[3] = 0.0; + + mat[7] = mat[6] = mat[4] = 0.0; + mat[5] = 1.0; + + mat[8] = Math.sin(radians); + mat[9] = 0.0; + mat[10] = Math.cos(radians); + mat[11] = 0.0; + + mat[14] = mat[13] = mat[12] = 0.0; + mat[15] = 1.0; + return matrix; + }; + + /** + * Builds a rotation matrix around the Z-axis. The resulting matrix is stored in matrix. matrix is returned. + * @param {Number} radians + * @param {cc.math.Matrix4} matrix + * @return {cc.math.Matrix4} + */ + cc.math.Matrix4.createByRotationZ = function(radians, matrix){ // cc.kmMat4RotationZ + /* + | cos(A) -sin(A) 0 0 | + M = | sin(A) cos(A) 0 0 | + | 0 0 1 0 | + | 0 0 0 1 | + */ + matrix = matrix || new cc.math.Matrix4(); + var mat = matrix.mat; + mat[0] = Math.cos(radians); + mat[1] = Math.sin(radians); + mat[3] = mat[2] = 0.0; + + mat[4] = -Math.sin(radians); + mat[5] = Math.cos(radians); + mat[7] = mat[6] = 0.0; + + mat[11] = mat[9] = mat[8] = 0.0; + mat[10] = 1.0; + + mat[14] = mat[13] = mat[12] = 0.0; + mat[15] = 1.0; + + return matrix; + }; + + /** + * Builds a rotation matrix from pitch, yaw and roll. The resulting matrix is stored in parameter matrix and returns. + * @param {Number} pitch + * @param {Number} yaw + * @param {Number} roll + * @param {cc.math.Matrix4} [matrix] if matrix is undefined, creates a new matrix. + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createByPitchYawRoll = function(pitch, yaw, roll, matrix) { + matrix = matrix || new cc.math.Matrix4(); + var cr = Math.cos(pitch), sr = Math.sin(pitch); + var cp = Math.cos(yaw), sp = Math.sin(yaw); + var cy = Math.cos(roll), sy = Math.sin(roll); + var srsp = sr * sp, crsp = cr * sp; + var mat = matrix.mat; + + mat[0] = cp * cy; + mat[4] = cp * sy; + mat[8] = -sp; + + mat[1] = srsp * cy - cr * sy; + mat[5] = srsp * sy + cr * cy; + mat[9] = sr * cp; + + mat[2] = crsp * cy + sr * sy; + mat[6] = crsp * sy - sr * cy; + mat[10] = cr * cp; + + mat[3] = mat[7] = mat[11] = 0.0; + mat[15] = 1.0; + return matrix; + }; + + /** + * Builds a matrix by a quaternion. + * @param {cc.math.Quaternion} quaternion + * @param {cc.math.Matrix4} [matrix] if matrix is undefined, creates a new matrix. + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createByQuaternion = function(quaternion, matrix) { + matrix = matrix || new cc.math.Matrix4(); + var mat = matrix.mat; + mat[0] = 1.0 - 2.0 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z ); + mat[1] = 2.0 * (quaternion.x * quaternion.y + quaternion.z * quaternion.w); + mat[2] = 2.0 * (quaternion.x * quaternion.z - quaternion.y * quaternion.w); + mat[3] = 0.0; + + // Second row + mat[4] = 2.0 * ( quaternion.x * quaternion.y - quaternion.z * quaternion.w ); + mat[5] = 1.0 - 2.0 * ( quaternion.x * quaternion.x + quaternion.z * quaternion.z ); + mat[6] = 2.0 * (quaternion.z * quaternion.y + quaternion.x * quaternion.w ); + mat[7] = 0.0; + + // Third row + mat[8] = 2.0 * ( quaternion.x * quaternion.z + quaternion.y * quaternion.w ); + mat[9] = 2.0 * ( quaternion.y * quaternion.z - quaternion.x * quaternion.w ); + mat[10] = 1.0 - 2.0 * ( quaternion.x * quaternion.x + quaternion.y * quaternion.y ); + mat[11] = 0.0; + + // Fourth row + mat[14] = mat[13] = mat[12] = 0; + mat[15] = 1.0; + return matrix; + }; + + /** + * Build a 4x4 OpenGL transformation matrix using a 3x3 rotation matrix, and a 3d vector representing a translation. + * @param {cc.math.Matrix3} rotation + * @param {cc.math.Vec3} translation + * @param {cc.math.Matrix4} [matrix] if matrix is undefined, creates a new matrix. + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createByRotationTranslation = function(rotation, translation, matrix) { + matrix = matrix || new cc.math.Matrix4(); + var mat = matrix.mat, rMat = rotation.mat; + mat[0] = rMat[0]; + mat[1] = rMat[1]; + mat[2] = rMat[2]; + mat[3] = 0.0; + + mat[4] = rMat[3]; + mat[5] = rMat[4]; + mat[6] = rMat[5]; + mat[7] = 0.0; + + mat[8] = rMat[6]; + mat[9] = rMat[7]; + mat[10] = rMat[8]; + mat[11] = 0.0; + + mat[12] = translation.x; + mat[13] = translation.y; + mat[14] = translation.z; + mat[15] = 1.0; + return matrix; + }; + + /** + * Builds a scaling matrix + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {cc.math.Matrix4} [matrix] if matrix is undefined, creates a new matrix. + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createByScale = function(x, y, z, matrix) { //cc.kmMat4Scaling + matrix = matrix || new cc.math.Matrix4(); + var mat = matrix.mat; + mat[0] = x; + mat[5] = y; + mat[10] = z; + mat[15] = 1.0; + mat[1] = mat[2] = mat[3] = mat[4] = mat[6] = mat[7] = + mat[8] = mat[9] = mat[11] = mat[12] = mat[13] = mat[14] = 0; + return matrix; + }; + + /** + * Builds a translation matrix. All other elements in the matrix + * will be set to zero except for the diagonal which is set to 1.0 + */ + cc.kmMat4Translation = function (pOut, x, y, z) { + //FIXME: Write a test for this + pOut.mat[0] = pOut.mat[5] = pOut.mat[10] = pOut.mat[15] = 1.0; + pOut.mat[1] = pOut.mat[2] = pOut.mat[3] = + pOut.mat[4] = pOut.mat[6] = pOut.mat[7] = + pOut.mat[8] = pOut.mat[9] = pOut.mat[11] = 0.0; + pOut.mat[12] = x; + pOut.mat[13] = y; + pOut.mat[14] = z; + return pOut; + }; + + /** + * Builds a translation matrix. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @param {cc.math.Matrix4} [matrix] if matrix is undefined, creates a new matrix. + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createByTranslation = function(x, y, z, matrix){ //cc.kmMat4Translation + matrix = matrix || new cc.math.Matrix4(); + matrix.identity(); + matrix.mat[12] = x; + matrix.mat[13] = y; + matrix.mat[14] = z; + return matrix; + }; + + /** + * Get the up vector from a matrix. + * @returns {cc.math.Vec3} + */ + proto.getUpVec3 = function() { + var mat = this.mat; + var ret = new cc.math.Vec3(mat[4],mat[5], mat[6]); + return ret.normalize(); + }; + + /** + * Extract the right vector from a 4x4 matrix. + * @returns {cc.math.Vec3} + */ + proto.getRightVec3 = function(){ + var mat = this.mat; + var ret = new cc.math.Vec3(mat[0],mat[1], mat[2]); + return ret.normalize(); + }; + + /** + * Extract the forward vector from a 4x4 matrix. + * @returns {cc.math.Vec3} + */ + proto.getForwardVec3 = function() { + var mat = this.mat; + var ret = new cc.math.Vec3(mat[8],mat[9], mat[10]); + return ret.normalize(); + }; + + /** + * Creates a perspective projection matrix in the + * same way as gluPerspective + */ + cc.kmMat4PerspectiveProjection = function (pOut, fovY, aspect, zNear, zFar) { + var r = cc.degreesToRadians(fovY / 2); + var deltaZ = zFar - zNear; + var s = Math.sin(r); + + if (deltaZ == 0 || s == 0 || aspect == 0) + return null; + + //cos(r) / sin(r) = cot(r) + var cotangent = Math.cos(r) / s; + pOut.identity(); + pOut.mat[0] = cotangent / aspect; + pOut.mat[5] = cotangent; + pOut.mat[10] = -(zFar + zNear) / deltaZ; + pOut.mat[11] = -1; + pOut.mat[14] = -2 * zNear * zFar / deltaZ; + pOut.mat[15] = 0; - pOut.mat[0] = s.x; - pOut.mat[4] = s.y; - pOut.mat[8] = s.z; + return pOut; + }; + + /** + * Creates a perspective projection matrix in the same way as gluPerspective + * @param {Number} fovY + * @param {Number} aspect + * @param {Number} zNear + * @param {Number} zFar + * @returns {cc.math.Matrix4|Null} + */ + cc.math.Matrix4.createPerspectiveProjection = function(fovY, aspect, zNear, zFar){ + var r = cc.degreesToRadians(fovY / 2), deltaZ = zFar - zNear; + var s = Math.sin(r); + + if (deltaZ == 0 || s == 0 || aspect == 0) + return null; + + //cos(r) / sin(r) = cot(r) + var cotangent = Math.cos(r) / s; + var matrix = new cc.math.Matrix4(), mat = matrix.mat; + matrix.identity(); + mat[0] = cotangent / aspect; + mat[5] = cotangent; + mat[10] = -(zFar + zNear) / deltaZ; + mat[11] = -1; + mat[14] = -2 * zNear * zFar / deltaZ; + mat[15] = 0; + return matrix; + }; + + /** Creates an orthographic projection matrix like glOrtho */ + cc.kmMat4OrthographicProjection = function (pOut, left, right, bottom, top, nearVal, farVal) { + pOut.identity(); + pOut.mat[0] = 2 / (right - left); + pOut.mat[5] = 2 / (top - bottom); + pOut.mat[10] = -2 / (farVal - nearVal); + pOut.mat[12] = -((right + left) / (right - left)); + pOut.mat[13] = -((top + bottom) / (top - bottom)); + pOut.mat[14] = -((farVal + nearVal) / (farVal - nearVal)); + return pOut; + }; + + /** + * Creates an orthographic projection matrix like glOrtho + * @param {Number} left + * @param {Number} right + * @param {Number} bottom + * @param {Number} top + * @param {Number} nearVal + * @param {Number} farVal + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createOrthographicProjection = function (left, right, bottom, top, nearVal, farVal) { + var matrix = new cc.math.Matrix4(), mat = matrix.mat; + matrix.identity(); + mat[0] = 2 / (right - left); + mat[5] = 2 / (top - bottom); + mat[10] = -2 / (farVal - nearVal); + mat[12] = -((right + left) / (right - left)); + mat[13] = -((top + bottom) / (top - bottom)); + mat[14] = -((farVal + nearVal) / (farVal - nearVal)); + return matrix; + }; + + /** + * Builds a translation matrix in the same way as gluLookAt() + * the resulting matrix is stored in pOut. pOut is returned. + */ + cc.kmMat4LookAt = function (pOut, pEye, pCenter, pUp) { + var f = new cc.math.Vec3(pCenter), up = new cc.math.Vec3(pUp); + f.subtract(pEye); + f.normalize(); + up.normalize(); - pOut.mat[1] = u.x; - pOut.mat[5] = u.y; - pOut.mat[9] = u.z; + var s = new cc.math.Vec3(f); + s.cross(up); + s.normalize(); - pOut.mat[2] = -f.x; - pOut.mat[6] = -f.y; - pOut.mat[10] = -f.z; + var u = new cc.math.Vec3(s); + u.cross(f); + s.normalize(); - cc.kmMat4Translation(translate, -pEye.x, -pEye.y, -pEye.z); - cc.kmMat4Multiply(pOut, pOut, translate); + pOut.identity(); - return pOut; -}; + pOut.mat[0] = s.x; + pOut.mat[4] = s.y; + pOut.mat[8] = s.z; -/** - * Build a rotation matrix from an axis and an angle. Result is stored in pOut. - * pOut is returned. - */ -cc.kmMat4RotationAxisAngle = function (pOut, axis, radians) { - var rcos = Math.cos(radians); - var rsin = Math.sin(radians); + pOut.mat[1] = u.x; + pOut.mat[5] = u.y; + pOut.mat[9] = u.z; - var normalizedAxis = new cc.math.Vec3(axis); - normalizedAxis.normalize(); + pOut.mat[2] = -f.x; + pOut.mat[6] = -f.y; + pOut.mat[10] = -f.z; - pOut.mat[0] = rcos + normalizedAxis.x * normalizedAxis.x * (1 - rcos); - pOut.mat[1] = normalizedAxis.z * rsin + normalizedAxis.y * normalizedAxis.x * (1 - rcos); - pOut.mat[2] = -normalizedAxis.y * rsin + normalizedAxis.z * normalizedAxis.x * (1 - rcos); - pOut.mat[3] = 0.0; + var translate = cc.math.Matrix4.createByTranslation(-pEye.x, -pEye.y, -pEye.z); + pOut.multiply(translate); + return pOut; + }; + + var tempMatrix = new cc.math.Matrix4(); // an internal matrix + proto.lookAt = function(eyeVec, centerVec, upVec) { + var f = new cc.math.Vec3(centerVec), up = new cc.math.Vec3(upVec), mat = this.mat; + f.subtract(eyeVec); + f.normalize(); + up.normalize(); + + var s = new cc.math.Vec3(f); + s.cross(up); + s.normalize(); + + var u = new cc.math.Vec3(s); + u.cross(f); + s.normalize(); + + this.identity(); + mat[0] = s.x; + mat[4] = s.y; + mat[8] = s.z; + + mat[1] = u.x; + mat[5] = u.y; + mat[9] = u.z; + + mat[2] = -f.x; + mat[6] = -f.y; + mat[10] = -f.z; + + tempMatrix = cc.math.Matrix4.createByTranslation(-eyeVec.x, -eyeVec.y, -eyeVec.z, tempMatrix); + this.multiply(tempMatrix); + return this; + }; + + /** + * Build a rotation matrix from an axis and an angle. Result is stored in pOut. + * pOut is returned. + */ + cc.kmMat4RotationAxisAngle = function (pOut, axis, radians) { + var rcos = Math.cos(radians), rsin = Math.sin(radians); - pOut.mat[4] = -normalizedAxis.z * rsin + normalizedAxis.x * normalizedAxis.y * (1 - rcos); - pOut.mat[5] = rcos + normalizedAxis.y * normalizedAxis.y * (1 - rcos); - pOut.mat[6] = normalizedAxis.x * rsin + normalizedAxis.z * normalizedAxis.y * (1 - rcos); - pOut.mat[7] = 0.0; + var normalizedAxis = new cc.math.Vec3(axis); + normalizedAxis.normalize(); - pOut.mat[8] = normalizedAxis.y * rsin + normalizedAxis.x * normalizedAxis.z * (1 - rcos); - pOut.mat[9] = -normalizedAxis.x * rsin + normalizedAxis.y * normalizedAxis.z * (1 - rcos); - pOut.mat[10] = rcos + normalizedAxis.z * normalizedAxis.z * (1 - rcos); - pOut.mat[11] = 0.0; + pOut.mat[0] = rcos + normalizedAxis.x * normalizedAxis.x * (1 - rcos); + pOut.mat[1] = normalizedAxis.z * rsin + normalizedAxis.y * normalizedAxis.x * (1 - rcos); + pOut.mat[2] = -normalizedAxis.y * rsin + normalizedAxis.z * normalizedAxis.x * (1 - rcos); + pOut.mat[3] = 0.0; - pOut.mat[12] = 0.0; - pOut.mat[13] = 0.0; - pOut.mat[14] = 0.0; - pOut.mat[15] = 1.0; + pOut.mat[4] = -normalizedAxis.z * rsin + normalizedAxis.x * normalizedAxis.y * (1 - rcos); + pOut.mat[5] = rcos + normalizedAxis.y * normalizedAxis.y * (1 - rcos); + pOut.mat[6] = normalizedAxis.x * rsin + normalizedAxis.z * normalizedAxis.y * (1 - rcos); + pOut.mat[7] = 0.0; - return pOut; -}; + pOut.mat[8] = normalizedAxis.y * rsin + normalizedAxis.x * normalizedAxis.z * (1 - rcos); + pOut.mat[9] = -normalizedAxis.x * rsin + normalizedAxis.y * normalizedAxis.z * (1 - rcos); + pOut.mat[10] = rcos + normalizedAxis.z * normalizedAxis.z * (1 - rcos); + pOut.mat[11] = 0.0; -/** - * Extract a 3x3 rotation matrix from the input 4x4 transformation. - * Stores the result in pOut, returns pOut - */ -cc.kmMat4ExtractRotation = function (pOut, pIn) { - pOut.mat[0] = pIn.mat[0]; - pOut.mat[1] = pIn.mat[1]; - pOut.mat[2] = pIn.mat[2]; - - pOut.mat[3] = pIn.mat[4]; - pOut.mat[4] = pIn.mat[5]; - pOut.mat[5] = pIn.mat[6]; - - pOut.mat[6] = pIn.mat[8]; - pOut.mat[7] = pIn.mat[9]; - pOut.mat[8] = pIn.mat[10]; - return pOut; -}; - -cc.kmMat4ExtractPlane = function (pOut, pIn, plane) { - switch (plane) { - case cc.math.Plane.RIGHT: - pOut.a = pIn.mat[3] - pIn.mat[0]; - pOut.b = pIn.mat[7] - pIn.mat[4]; - pOut.c = pIn.mat[11] - pIn.mat[8]; - pOut.d = pIn.mat[15] - pIn.mat[12]; - break; - case cc.math.Plane.LEFT: - pOut.a = pIn.mat[3] + pIn.mat[0]; - pOut.b = pIn.mat[7] + pIn.mat[4]; - pOut.c = pIn.mat[11] + pIn.mat[8]; - pOut.d = pIn.mat[15] + pIn.mat[12]; - break; - case cc.math.Plane.BOTTOM: - pOut.a = pIn.mat[3] + pIn.mat[1]; - pOut.b = pIn.mat[7] + pIn.mat[5]; - pOut.c = pIn.mat[11] + pIn.mat[9]; - pOut.d = pIn.mat[15] + pIn.mat[13]; - break; - case cc.math.Plane.TOP: - pOut.a = pIn.mat[3] - pIn.mat[1]; - pOut.b = pIn.mat[7] - pIn.mat[5]; - pOut.c = pIn.mat[11] - pIn.mat[9]; - pOut.d = pIn.mat[15] - pIn.mat[13]; - break; - case cc.math.Plane.FAR: - pOut.a = pIn.mat[3] - pIn.mat[2]; - pOut.b = pIn.mat[7] - pIn.mat[6]; - pOut.c = pIn.mat[11] - pIn.mat[10]; - pOut.d = pIn.mat[15] - pIn.mat[14]; - break; - case cc.math.Plane.NEAR: - pOut.a = pIn.mat[3] + pIn.mat[2]; - pOut.b = pIn.mat[7] + pIn.mat[6]; - pOut.c = pIn.mat[11] + pIn.mat[10]; - pOut.d = pIn.mat[15] + pIn.mat[14]; - break; - default: - cc.log("cc.kmMat4ExtractPlane(): Invalid plane index"); - break; - } - - var t = Math.sqrt(pOut.a * pOut.a + - pOut.b * pOut.b + - pOut.c * pOut.c); - pOut.a /= t; - pOut.b /= t; - pOut.c /= t; - pOut.d /= t; - - return pOut; -}; + pOut.mat[12] = 0.0; + pOut.mat[13] = 0.0; + pOut.mat[14] = 0.0; + pOut.mat[15] = 1.0; -/** - * Take the rotation from a 4x4 transformation matrix, and return it as an axis and an angle (in radians) - * returns the output axis. - */ -cc.kmMat4RotationToAxisAngle = function (pAxis, radians, pIn) { - /*Surely not this easy?*/ - var rotation = new cc.math.Matrix3(); - cc.kmMat4ExtractRotation(rotation, pIn); - var temp = cc.math.Quaternion.rotationMatrix(rotation); - return temp.toAxisAndAngle(); -}; + return pOut; + }; + + /** + * Build a rotation matrix from an axis and an angle. + * @param {cc.math.Vec3} axis + * @param {Number} radians + * @param {cc.math.Matrix4} [matrix] + * @returns {cc.math.Matrix4} + */ + cc.math.Matrix4.createByAxisAndAngle = function(axis, radians, matrix) { + matrix = matrix || new cc.math.Matrix4(); + var mat = this.mat, rcos = Math.cos(radians), rsin = Math.sin(radians) ; + + var normalizedAxis = new cc.math.Vec3(axis); + normalizedAxis.normalize(); + + mat[0] = rcos + normalizedAxis.x * normalizedAxis.x * (1 - rcos); + mat[1] = normalizedAxis.z * rsin + normalizedAxis.y * normalizedAxis.x * (1 - rcos); + mat[2] = -normalizedAxis.y * rsin + normalizedAxis.z * normalizedAxis.x * (1 - rcos); + mat[3] = 0.0; + + mat[4] = -normalizedAxis.z * rsin + normalizedAxis.x * normalizedAxis.y * (1 - rcos); + mat[5] = rcos + normalizedAxis.y * normalizedAxis.y * (1 - rcos); + mat[6] = normalizedAxis.x * rsin + normalizedAxis.z * normalizedAxis.y * (1 - rcos); + mat[7] = 0.0; + + mat[8] = normalizedAxis.y * rsin + normalizedAxis.x * normalizedAxis.z * (1 - rcos); + mat[9] = -normalizedAxis.x * rsin + normalizedAxis.y * normalizedAxis.z * (1 - rcos); + mat[10] = rcos + normalizedAxis.z * normalizedAxis.z * (1 - rcos); + mat[11] = 0.0; + + mat[12] = mat[13] = mat[14] = 0.0; + mat[15] = 1.0; + return matrix; + }; + + /** + * Extract a 3x3 rotation matrix from the input 4x4 transformation. + * @returns {cc.math.Matrix3} + */ + proto.extractRotation = function(){ + var matrix = new cc.math.Matrix3(), mat4 = this.mat, mat3 = matrix.mat; + mat3[0] = mat4[0]; + mat3[1] = mat4[1]; + mat3[2] = mat4[2]; + + mat3[3] = mat4[4]; + mat3[4] = mat4[5]; + mat3[5] = mat4[6]; + + mat3[6] = mat4[8]; + mat3[7] = mat4[9]; + mat3[8] = mat4[10]; + return matrix; + }; + + proto.extractPlane = function(planeType) { + var plane = new cc.math.Plane(), mat = this.mat; + switch (planeType) { + case cc.math.Plane.RIGHT: + plane.a = mat[3] - mat[0]; + plane.b = mat[7] - mat[4]; + plane.c = mat[11] - mat[8]; + plane.d = mat[15] - mat[12]; + break; + case cc.math.Plane.LEFT: + plane.a = mat[3] + mat[0]; + plane.b = mat[7] + mat[4]; + plane.c = mat[11] + mat[8]; + plane.d = mat[15] + mat[12]; + break; + case cc.math.Plane.BOTTOM: + plane.a = mat[3] + mat[1]; + plane.b = mat[7] + mat[5]; + plane.c = mat[11] + mat[9]; + plane.d = mat[15] + mat[13]; + break; + case cc.math.Plane.TOP: + plane.a = mat[3] - mat[1]; + plane.b = mat[7] - mat[5]; + plane.c = mat[11] - mat[9]; + plane.d = mat[15] - mat[13]; + break; + case cc.math.Plane.FAR: + plane.a = mat[3] - mat[2]; + plane.b = mat[7] - mat[6]; + plane.c = mat[11] - mat[10]; + plane.d = mat[15] - mat[14]; + break; + case cc.math.Plane.NEAR: + plane.a = mat[3] + mat[2]; + plane.b = mat[7] + mat[6]; + plane.c = mat[11] + mat[10]; + plane.d = mat[15] + mat[14]; + break; + default: + cc.log("cc.math.Matrix4.extractPlane: Invalid plane index"); + break; + } + var t = Math.sqrt(plane.a * plane.a + plane.b * plane.b + plane.c * plane.c); + plane.a /= t; + plane.b /= t; + plane.c /= t; + plane.d /= t; + return plane; + }; + + /** + * Take the rotation from a 4x4 transformation matrix, and return it as an axis and an angle (in radians) + * @returns {*|{axis: cc.math.Vec3, angle: number}} + */ + proto.toAxisAndAngle = function() { + /*Surely not this easy?*/ + var rotation = this.extractRotation(); + var temp = cc.math.Quaternion.rotationMatrix(rotation); + return temp.toAxisAndAngle(); + }; +})(cc); diff --git a/cocos2d/kazmath/quaternion.js b/cocos2d/kazmath/quaternion.js index 3b24830871..13e9d67ef6 100644 --- a/cocos2d/kazmath/quaternion.js +++ b/cocos2d/kazmath/quaternion.js @@ -353,7 +353,7 @@ * @param {cc.math.Quaternion} quaternion * @returns {cc.math.Quaternion} current quaternion */ - proto.assign = function(quaternion){ //=cc.kmQuaternionAssign + proto.assignFrom = function(quaternion){ //=cc.kmQuaternionAssign this.x = quaternion.x; this.y = quaternion.y; this.z = quaternion.z; diff --git a/cocos2d/kazmath/vec3.js b/cocos2d/kazmath/vec3.js index 18200dfa8b..de64594604 100644 --- a/cocos2d/kazmath/vec3.js +++ b/cocos2d/kazmath/vec3.js @@ -163,7 +163,7 @@ return this; }; - proto.assign = function(vec){ + proto.assignFrom = function(vec){ if(!vec) return this; this.x = vec.x; diff --git a/cocos2d/kazmath/vec4.js b/cocos2d/kazmath/vec4.js index bb4e2ac807..fb2e376380 100644 --- a/cocos2d/kazmath/vec4.js +++ b/cocos2d/kazmath/vec4.js @@ -137,7 +137,7 @@ (this.w < vec.w + EPSILON && this.w > vec.w - EPSILON); }; - proto.assign = function(vec) { //= cc.kmVec4Assign + proto.assignFrom = function(vec) { //= cc.kmVec4Assign this.x = vec.x; this.y = vec.y; this.z = vec.z; diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index f75ce939f8..3426e84d74 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -80,7 +80,7 @@ cc.NodeGrid = cc.Node.extend({ t4x4Mat[14] = this._vertexZ; //optimize performance for Javascript - cc.kmMat4Multiply(topMat4, topMat4, t4x4); // = cc.kmGLMultMatrix(this._transform4x4); + topMat4.multiply(t4x4) ; // = cc.kmGLMultMatrix(this._transform4x4); // XXX: Expensive calls. Camera should be integrated into the cached affine matrix if (this._camera != null && !(this.grid && this.grid.isActive())) { diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index 4a2e48cb63..5238694b38 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -239,9 +239,8 @@ var widthRatio = size.width / texSize.width; var heightRatio = size.height / texSize.height; - var orthoMatrix = new cc.kmMat4(); - cc.kmMat4OrthographicProjection(orthoMatrix, -1.0 / widthRatio, 1.0 / widthRatio, - -1.0 / heightRatio, 1.0 / heightRatio, -1, 1); + var orthoMatrix = cc.math.Matrix4.createOrthographicProjection(-1.0 / widthRatio, 1.0 / widthRatio, + -1.0 / heightRatio, 1.0 / heightRatio, -1, 1); cc.kmGLMultMatrix(orthoMatrix); //calculate viewport diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 1b429a9734..c8812bcac4 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -543,9 +543,9 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ * will update the builtin uniforms if they are different than the previous call for this same shader program. */ setUniformsForBuiltins: function () { - var matrixP = new cc.kmMat4(); - var matrixMV = new cc.kmMat4(); - var matrixMVP = new cc.kmMat4(); + var matrixP = new cc.math.Matrix4(); + var matrixMV = new cc.math.Matrix4(); + var matrixMVP = new cc.math.Matrix4(); cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, matrixP); cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, matrixMV); @@ -576,9 +576,9 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ if(!node || !node._renderCmd) return; - var matrixP = new cc.kmMat4(); + var matrixP = new cc.math.Matrix4(); //var matrixMV = new cc.kmMat4(); - var matrixMVP = new cc.kmMat4(); + var matrixMVP = new cc.math.Matrix4(); cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, matrixP); //cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, node._stackMatrix); diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index b4581dbaaf..476c790a5f 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -129,15 +129,15 @@ apy = 0 | apy; } //cc.kmGLTranslatef(apx, apy, 0); - var translation = new cc.kmMat4(); - cc.kmMat4Translation(translation, apx, apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + var translation = cc.math.Matrix4.createByTranslation(apx, apy, 0, t4x4); //t4x4 as a temp matrix + stackMatrix.multiply(translate); node._camera._locateForRenderer(stackMatrix); //cc.kmGLTranslatef(-apx, -apy, 0); - cc.kmMat4Translation(translation, -apx, -apy, 0); - cc.kmMat4Multiply(stackMatrix, stackMatrix, translation); + translation = cc.math.Matrix4.createByTranslation(-apx, -apy, 0, translation); + stackMatrix.multiply(translation); + t4x4.identity(); //reset t4x4; } else { node._camera._locateForRenderer(stackMatrix); } From 96e999eadaeb9829d9394bb9e0fe46faa59f379f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 13 Mar 2015 14:56:01 +0800 Subject: [PATCH 1409/1564] Issue #2698: corrected some mistakes for refactoring. --- cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js | 2 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 6 +++--- cocos2d/kazmath/gl/matrix.js | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 5342f1c3a5..2c70b47fd2 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -229,7 +229,7 @@ node._camera._locateForRenderer(stackMatrix); //cc.kmGLTranslatef(-apx, -apy, 0); optimize at here : kmGLTranslatef - translation = cc.math.Matrix4.createByTranslation(apx, apy, 0, translation); + translation = cc.math.Matrix4.createByTranslation(-apx, -apy, 0, translation); stackMatrix.multiply(translation); t4x4.identity(); //reset t4x4; } else { diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 851a30f278..9f4166a131 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -147,10 +147,10 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ var frameConfig = this._frameConfigCache[url] || this._getFrameConfigByJsonObject(url, jsonObject); //this._checkConflict(frameConfig); //TODO - this._createSpriteFrames(frameConfig, texture); + this._createSpriteFrames(url, frameConfig, texture); }, - _createSpriteFrames: function(frameConfig, texture) { + _createSpriteFrames: function(url, frameConfig, texture) { var frames = frameConfig.frames, meta = frameConfig.meta; if(!texture){ var texturePath = cc.path.changeBasename(url, meta.image || ".png"); @@ -223,7 +223,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ var frameConfig = this._frameConfigCache[url] || this._getFrameConfig(url); //this._checkConflict(frameConfig); //TODO - this._createSpriteFrames(frameConfig, texture); + this._createSpriteFrames(url, frameConfig, texture); }, // Function to check if frames to add exists already, if so there may be name conflit that must be solved diff --git a/cocos2d/kazmath/gl/matrix.js b/cocos2d/kazmath/gl/matrix.js index 574bd0dd5d..3975fa620c 100644 --- a/cocos2d/kazmath/gl/matrix.js +++ b/cocos2d/kazmath/gl/matrix.js @@ -43,9 +43,9 @@ var identity = new cc.math.Matrix4(); //Temporary identity matrix //Initialize all 3 stacks - cc.modelview_matrix_stack.initialized(); - cc.projection_matrix_stack.initialized(); - cc.texture_matrix_stack.initialized(); + cc.modelview_matrix_stack.initialize(); + cc.projection_matrix_stack.initialize(); + cc.texture_matrix_stack.initialize(); cc.current_stack = cc.modelview_matrix_stack; cc.initialized = true; @@ -132,7 +132,7 @@ cc.current_stack.top.multiply(translation); }; - var tempVector3 = new cc.math.Vec3(x, y, z); + var tempVector3 = new cc.math.Vec3(); cc.kmGLRotatef = function (angle, x, y, z) { tempVector3.fill(x, y, z); //Create a rotation matrix using the axis and the angle From 9f48972405e15b1cb3cd31a3718b66d7ea5b71de Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 13 Mar 2015 16:09:09 +0800 Subject: [PATCH 1410/1564] Fixed TMX scale error --- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index c1a63a4924..82d68230f6 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -82,7 +82,7 @@ return; var node = this._node; - this._renderingChildToCache(scaleX, scaleY); + this._renderingChildToCache(node._scaleX, node._scaleY); var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); wrapper.setGlobalAlpha(alpha); @@ -145,16 +145,16 @@ //begin cache renderer._turnToCacheMode(instanceID); - node.sortAllChildren(); + node.sortAllChildren(); for (i = 0, len = locChildren.length; i < len; i++) { - if (locChildren[i]){ - var selCmd = locChildren[i]._renderCmd; + if (locChildren[i]){ + var selCmd = locChildren[i]._renderCmd; if(selCmd){ selCmd.visit(this); selCmd._cacheDirty = false; } } - } + } //wrapper.save(); context.setTransform(1, 0, 0, 1, 0, 0); From c67d5f3740a0eb87846ba711bebbab36eb91ece1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 13 Mar 2015 16:15:00 +0800 Subject: [PATCH 1411/1564] Fixed TMX scale error --- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index 82d68230f6..b4f53b561a 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -50,7 +50,7 @@ this._cacheDirty = true; }; - proto._renderingChildToCache = function (scaleX, scaleY) { + proto._renderingChildToCache = function () { if (this._cacheDirty) { var wrapper = this._cacheContext, context = wrapper.getContext(), locCanvas = this._cacheCanvas; @@ -65,7 +65,7 @@ if (locChildren[i]){ var selCmd = locChildren[i]._renderCmd; if(selCmd){ - selCmd.rendering(wrapper, scaleX, scaleY); + selCmd.rendering(wrapper, 1, 1); selCmd._cacheDirty = false; } } @@ -82,7 +82,7 @@ return; var node = this._node; - this._renderingChildToCache(node._scaleX, node._scaleY); + this._renderingChildToCache(); var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); wrapper.setGlobalAlpha(alpha); From db9022810bf1c86a4802ad8ca02d5d99a6490f98 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 13 Mar 2015 18:17:07 +0800 Subject: [PATCH 1412/1564] Fixed a bug of cc.LayerGradient that it doesn't work when constructor parameter is null. --- cocos2d/core/layers/CCLayer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index a6b2cf7f4e..c7fd9af7d7 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -349,10 +349,10 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ if(stops && stops instanceof Array){ this._colorStops = stops; - stops.splice(0, 0, {p:0, color: start}); - stops.push({p:1, color: end}); + stops.splice(0, 0, {p:0, color: start || cc.color.BLACK}); + stops.push({p:1, color: end || cc.color.BLACK}); } else - this._colorStops = [{p:0, color: start}, {p:1, color: end}]; + this._colorStops = [{p:0, color: start || cc.color.BLACK}, {p:1, color: end || cc.color.BLACK}]; cc.LayerGradient.prototype.init.call(this, start, end, v, stops); }, From ebb9a749b8db17c9f29c6a742b798a4b04d0d17d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 16 Mar 2015 09:45:41 +0800 Subject: [PATCH 1413/1564] Add cc.math.vec3... --- cocos2d/kazmath/vec3.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos2d/kazmath/vec3.js b/cocos2d/kazmath/vec3.js index de64594604..282b34aaae 100644 --- a/cocos2d/kazmath/vec3.js +++ b/cocos2d/kazmath/vec3.js @@ -39,6 +39,10 @@ } }; + cc.math.vec3 = function(x, y, z){ + return new cc.math.Vec3(x, y, z); + }; + var proto = cc.math.Vec3.prototype; proto.fill = function (x, y, z) { // =cc.kmVec3Fill From 4f039d8036b4f09a3584e5cbd9ec9cb2b490fa4f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 16 Mar 2015 10:12:57 +0800 Subject: [PATCH 1414/1564] Fixed a bug that is unscheduleAll is not exists. --- cocos2d/core/base-nodes/CCNode.js | 2 +- extensions/editbox/CCdomNode.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b83d29e7ec..0094a86464 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1155,7 +1155,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ setScheduler: function (scheduler) { if (this._scheduler != scheduler) { - this.unscheduleAll(); + this.unscheduleAllCallbacks(); this._scheduler = scheduler; } }, diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index a9b6a09c45..fb62932ed3 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -391,7 +391,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ cleanup:function () { // actions this.stopAllActions(); - this.unscheduleAll(); + this.unscheduleAllCallbacks(); // timers this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.cleanup); From 9b98619a96bee45c67fe6aa84650479803ea4f0b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 16 Mar 2015 10:44:57 +0800 Subject: [PATCH 1415/1564] Update build.xml --- tools/XmlCheck.js | 13 +++++++++++++ tools/build.xml | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/XmlCheck.js b/tools/XmlCheck.js index 62f383d0a5..159933cd37 100644 --- a/tools/XmlCheck.js +++ b/tools/XmlCheck.js @@ -72,6 +72,19 @@ var xmlFile2 = []; })(); console.log(" The number of files in the XML file : %s", xmlFile.length); +contains = contains.map(function(a){ + return path.normalize(a); +}); +moduleFile = moduleFile.map(function(a){ + return path.normalize(a); +}); +xmlFile = xmlFile.map(function(a){ + return path.normalize(a); +}); +xmlFile2 = xmlFile2.map(function(a){ + return path.normalize(a); +}); + console.log("\x1B[0m\x1B[33m"); console.log(" warn : moduleConfig missing..."); contains.forEach(function(a){ diff --git a/tools/build.xml b/tools/build.xml index c1d0858cb8..6d50b363bc 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.4-beta-min.js"> @@ -298,7 +298,7 @@ + debug="false" output="./../lib/cocos2d-js-v3..4-beta-core-min.js"> From 90a5adeddf62192aba11249a13224ebcef9876c6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 16 Mar 2015 10:47:42 +0800 Subject: [PATCH 1416/1564] Update version number --- cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index e33721a2b8..eb24ebe368 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.4 Beta0"; /** *

    diff --git a/tools/build.xml b/tools/build.xml index 6d50b363bc..a28de92575 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.4-beta0-min.js"> @@ -298,7 +298,7 @@ + debug="false" output="./../lib/cocos2d-js-v3..4-beta0-core-min.js"> From 0114826428cda423438b00d52bbfaff0db6a7f11 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 16 Mar 2015 10:48:36 +0800 Subject: [PATCH 1417/1564] Update version number --- tools/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build.xml b/tools/build.xml index a28de92575..ce6e9c35cf 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -298,7 +298,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.4-beta0-core-min.js"> From 069d7325e155d99e0b692dd9dbf918498315e17d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 16 Mar 2015 13:50:12 +0800 Subject: [PATCH 1418/1564] Update the ignore list of git. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f5e28b036a..73b9c1ae31 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ node_modules /tools/jsdoc_toolkit-2.4.0 /package /tools/jsdoc_toolkit/jsdoc_toolkit-2.4.0 +/.project From 6b7f1c1f215d4cc1f9b6a91e81c9ba5c0aa127bd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 16 Mar 2015 14:25:51 +0800 Subject: [PATCH 1419/1564] Automatic open webgl for IOS --- CCBoot.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 7543fbc756..8e2a876172 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1598,10 +1598,13 @@ cc._initSys = function (config, CONFIG_KEY) { var renderType = cc._RENDER_TYPE_WEBGL; var tempCanvas = cc.newElement("Canvas"); cc._supportRender = true; - var notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1; - if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://")) { + var notSupportGL = true; + if(iOS) + notSupportGL = !window.WebGLRenderingContext || osSupportWebGL.indexOf(sys.os) == -1; + else + notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1; + if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://")) renderType = cc._RENDER_TYPE_CANVAS; - } sys._canUseCanvasNewBlendModes = function(){ var canvas = document.createElement('canvas'); From 1efa9d52d106154bd534fe9c454590d190601aa5 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Mon, 16 Mar 2015 15:38:01 +0800 Subject: [PATCH 1420/1564] Update the Authors for v3.4 beta0 --- AUTHORS.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 56a564aebf..8d63894f5e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -169,13 +169,14 @@ Asano @LaercioAsano cc.Node bug fix Bruno Assarisse @bassarisse cc.LabelBMFont bug fix -Mykyta Usikov @musikov cc.ClippingNode bug fix +Mykyta Usikov @musikov cc.ClippingNode bugs fix cc.fontLoader bug fix Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode JumpTo bug with wrong _delta position bug fix cc.ProgressTimer bugs fix cc.Scale9Sprite bugs fix cc.RenderTexture bug fix + cc.ParticleSystem bug fix Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix @@ -234,6 +235,15 @@ Joe Lafiosca @lafiosca Added Javascript file loader galapagosit @galapagosit ccs.actionManager bug fix +Dany Ellement @DEllement cc.FontDefinition & ccui.RichText improvements + cc.LayerGradient improvements + +IShm @IShm cc.Screen bug fix + cc.ParticleSystem bug fix + +Thomas Jablonski @thomas-jablonski cc.audioEngine bug fix + +WingGao @WingGao cc.TMXLayer bug fix Retired Core Developers: Shengxiang Chen (Nero Chan) From 4acfc3596d929134af4e08563229c2e250120146 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 16 Mar 2015 17:11:31 +0800 Subject: [PATCH 1421/1564] Fixed a bug that EGLView gets the rect error --- cocos2d/core/platform/CCEGLView.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index e5be3e63b5..75826042ff 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -75,6 +75,7 @@ switch(cc.__BrowserGetter.adaptationType){ cc.__BrowserGetter.__defineGetter__("target-densitydpi", function(){ return cc.view._targetDensityDPI; }); + case cc.sys.BROWSER_TYPE_SOUGOU: case cc.sys.BROWSER_TYPE_UC: cc.__BrowserGetter.availWidth = function(frame){ return frame.clientWidth; From 515f5a6ad98d33c75b9840178888519cf8815322 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 17 Mar 2015 10:47:46 +0800 Subject: [PATCH 1422/1564] Corrected an issue of chipmunk.js that it doesn't work after compiled. --- external/chipmunk/chipmunk.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/chipmunk/chipmunk.js b/external/chipmunk/chipmunk.js index 0fb3aeaa68..3be84bfc61 100644 --- a/external/chipmunk/chipmunk.js +++ b/external/chipmunk/chipmunk.js @@ -33,7 +33,7 @@ if(typeof exports === 'undefined'){ cp = {}; if(typeof window === 'object'){ - window.cp = cp; + window["cp"] = cp; } } else { cp = exports; @@ -1312,7 +1312,7 @@ var BoxShape2 = cp.BoxShape2 = function(body, box) box.l, box.b, box.l, box.t, box.r, box.t, - box.r, box.b, + box.r, box.b ]; return new PolyShape(body, verts, vzero); From 4ef6dc08c90d759cc744a9d92826994dedac0d1f Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 17 Mar 2015 17:08:28 +0800 Subject: [PATCH 1423/1564] Fixed #2742: Use '===' to replace '==' for performance. --- CCBoot.js | 116 +++++++++--------- CCDebugger.js | 10 +- cocos2d/actions/CCAction.js | 4 +- cocos2d/actions/CCActionCatmullRom.js | 6 +- cocos2d/actions/CCActionEase.js | 14 +-- cocos2d/actions/CCActionInstant.js | 2 +- cocos2d/actions/CCActionInterval.js | 10 +- cocos2d/actions3d/CCActionGrid.js | 2 +- cocos2d/actions3d/CCActionGrid3D.js | 4 +- cocos2d/actions3d/CCActionTiledGrid.js | 16 +-- cocos2d/audio/CCAudio.js | 12 +- cocos2d/clipping-nodes/CCClippingNode.js | 2 +- .../CCClippingNodeWebGLRenderCmd.js | 2 +- cocos2d/compression/base64.js | 6 +- cocos2d/compression/gzip.js | 40 +++--- cocos2d/core/CCActionManager.js | 18 +-- cocos2d/core/CCDirector.js | 12 +- cocos2d/core/CCDirectorWebGL.js | 2 +- cocos2d/core/CCDrawingPrimitivesCanvas.js | 2 +- cocos2d/core/CCDrawingPrimitivesWebGL.js | 6 +- cocos2d/core/CCScheduler.js | 38 +++--- .../base-nodes/CCAtlasNodeCanvasRenderCmd.js | 2 +- cocos2d/core/base-nodes/CCNode.js | 32 ++--- .../core/base-nodes/CCNodeCanvasRenderCmd.js | 10 +- .../core/base-nodes/CCNodeWebGLRenderCmd.js | 2 +- cocos2d/core/cocoa/CCGeometry.js | 6 +- .../core/event-manager/CCEventExtension.js | 2 +- cocos2d/core/event-manager/CCEventListener.js | 10 +- cocos2d/core/event-manager/CCEventManager.js | 58 ++++----- cocos2d/core/labelttf/CCLabelTTF.js | 34 ++--- .../labelttf/CCLabelTTFCanvasRenderCmd.js | 8 +- cocos2d/core/layers/CCLayerCanvasRenderCmd.js | 2 +- cocos2d/core/platform/CCClass.js | 8 +- cocos2d/core/platform/CCCommon.js | 22 ++-- cocos2d/core/platform/CCEGLView.js | 14 +-- cocos2d/core/platform/CCInputExtension.js | 8 +- cocos2d/core/platform/CCInputManager.js | 6 +- cocos2d/core/platform/CCLoaders.js | 2 +- cocos2d/core/platform/CCMacro.js | 4 +- cocos2d/core/platform/CCSAXParser.js | 26 ++-- cocos2d/core/platform/miniFramework.js | 2 +- cocos2d/core/sprites/CCAnimationCache.js | 2 +- cocos2d/core/sprites/CCSprite.js | 12 +- cocos2d/core/sprites/CCSpriteBatchNode.js | 16 +-- .../CCSpriteBatchNodeWebGLRenderCmd.js | 12 +- .../core/sprites/CCSpriteCanvasRenderCmd.js | 16 +-- cocos2d/core/sprites/CCSpriteFrame.js | 2 +- cocos2d/core/sprites/CCSpriteFrameCache.js | 6 +- .../core/sprites/CCSpriteWebGLRenderCmd.js | 12 +- cocos2d/core/support/CCPointExtension.js | 8 +- cocos2d/core/support/CCVertex.js | 6 +- cocos2d/core/textures/CCTexture2D.js | 4 +- cocos2d/core/textures/CCTextureAtlas.js | 8 +- cocos2d/core/textures/CCTextureCache.js | 7 +- cocos2d/core/textures/TexturesWebGL.js | 16 +-- cocos2d/core/utils/BinaryLoader.js | 8 +- cocos2d/effects/CCGrabber.js | 2 +- cocos2d/effects/CCGrid.js | 2 +- cocos2d/kazmath/mat4.js | 12 +- cocos2d/kazmath/quaternion.js | 2 +- cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js | 4 +- cocos2d/labels/CCLabelBMFont.js | 22 ++-- .../labels/CCLabelBMFontCanvasRenderCmd.js | 2 +- cocos2d/menus/CCMenu.js | 20 +-- cocos2d/menus/CCMenuItem.js | 18 +-- cocos2d/motion-streak/CCMotionStreak.js | 6 +- cocos2d/node-grid/CCNodeGrid.js | 2 +- cocos2d/parallax/CCParallaxNode.js | 4 +- cocos2d/particle/CCParticleBatchNode.js | 20 +-- .../CCParticleBatchNodeWebGLRenderCmd.js | 2 +- cocos2d/particle/CCParticleSystem.js | 38 +++--- .../CCParticleSystemCanvasRenderCmd.js | 4 +- .../CCParticleSystemWebGLRenderCmd.js | 5 +- cocos2d/physics/CCPhysicsSprite.js | 4 +- cocos2d/progress-timer/CCProgressTimer.js | 4 +- .../CCProgressTimerCanvasRenderCmd.js | 6 +- .../CCProgressTimerWebGLRenderCmd.js | 14 +-- .../CCRenderTextureWebGLRenderCmd.js | 6 +- cocos2d/shaders/CCGLProgram.js | 10 +- cocos2d/shaders/CCGLStateCache.js | 6 +- cocos2d/shape-nodes/CCDrawNode.js | 8 +- .../shape-nodes/CCDrawNodeCanvasRenderCmd.js | 2 +- cocos2d/text-input/CCIMEDispatcher.js | 22 ++-- cocos2d/text-input/CCTextFieldTTF.js | 4 +- cocos2d/tilemap/CCTGAlib.js | 8 +- cocos2d/tilemap/CCTMXLayer.js | 14 +-- cocos2d/tilemap/CCTMXObjectGroup.js | 2 +- cocos2d/tilemap/CCTMXTiledMap.js | 8 +- cocos2d/tilemap/CCTMXXMLParser.js | 14 +-- cocos2d/transitions/CCTransition.js | 7 +- cocos2d/transitions/CCTransitionProgress.js | 4 +- extensions/ccb-reader/CCBAnimationManager.js | 20 ++- extensions/ccb-reader/CCBReader.js | 66 +++++----- extensions/ccb-reader/CCControlLoader.js | 76 ++++++------ extensions/ccb-reader/CCNodeLoader.js | 43 ++++--- extensions/ccb-reader/CCSpriteLoader.js | 2 +- extensions/ccpool/CCPool.js | 2 +- .../ccui/base-classes/CCProtectedNode.js | 6 +- .../CCProtectedNodeWebGLRenderCmd.js | 2 +- .../ccui/base-classes/UIScale9Sprite.js | 16 +-- .../UIScale9SpriteCanvasRenderCmd.js | 2 +- extensions/ccui/base-classes/UIWidget.js | 38 +++--- extensions/ccui/layouts/UILayout.js | 76 ++++++------ extensions/ccui/layouts/UILayoutComponent.js | 46 +++---- extensions/ccui/layouts/UILayoutManager.js | 4 +- extensions/ccui/layouts/UILayoutParameter.js | 2 +- .../ccui/layouts/UILayoutWebGLRenderCmd.js | 2 +- extensions/ccui/system/UIHelper.js | 16 +-- extensions/ccui/uiwidgets/UIButton.js | 8 +- extensions/ccui/uiwidgets/UICheckBox.js | 6 +- extensions/ccui/uiwidgets/UIImageView.js | 2 +- extensions/ccui/uiwidgets/UILoadingBar.js | 6 +- extensions/ccui/uiwidgets/UIRichText.js | 31 +++-- extensions/ccui/uiwidgets/UISlider.js | 2 +- extensions/ccui/uiwidgets/UIText.js | 4 +- extensions/ccui/uiwidgets/UITextAtlas.js | 2 +- extensions/ccui/uiwidgets/UITextBMFont.js | 2 +- extensions/ccui/uiwidgets/UITextField.js | 4 +- .../uiwidgets/scroll-widget/UIListView.js | 14 +-- .../uiwidgets/scroll-widget/UIPageView.js | 4 +- .../uiwidgets/scroll-widget/UIScrollView.js | 56 ++++----- .../cocostudio/action/CCActionManager.js | 2 +- extensions/cocostudio/action/CCActionNode.js | 20 +-- .../cocostudio/action/CCActionObject.js | 2 +- extensions/cocostudio/armature/CCArmature.js | 8 +- .../armature/CCArmatureCanvasRenderCmd.js | 2 +- .../armature/CCArmatureWebGLRenderCmd.js | 10 +- extensions/cocostudio/armature/CCBone.js | 14 +-- .../armature/animation/CCArmatureAnimation.js | 20 +-- .../armature/animation/CCProcessBase.js | 4 +- .../cocostudio/armature/animation/CCTween.js | 28 ++--- .../cocostudio/armature/datas/CCDatas.js | 4 +- .../armature/display/CCDisplayFactory.js | 9 +- .../armature/display/CCDisplayManager.js | 10 +- .../cocostudio/armature/display/CCSkin.js | 6 +- .../armature/physics/CCColliderDetector.js | 4 +- .../armature/utils/CCDataReaderHelper.js | 28 ++--- .../armature/utils/CCTransformHelp.js | 2 +- .../armature/utils/CCTweenFunction.js | 10 +- .../cocostudio/components/CCComController.js | 2 +- .../components/CCComponentContainer.js | 2 +- .../cocostudio/loader/parsers/action-1.x.js | 2 +- .../cocostudio/loader/parsers/compatible.js | 8 +- .../cocostudio/loader/parsers/scene-1.x.js | 18 +-- .../loader/parsers/timelineParser-1.x.js | 10 +- .../loader/parsers/timelineParser-2.x.js | 44 +++---- .../cocostudio/loader/parsers/uiParser-1.x.js | 4 +- .../cocostudio/timeline/ActionTimeline.js | 2 +- extensions/cocostudio/timeline/Frame.js | 22 ++-- extensions/cocostudio/timeline/Timeline.js | 13 +- extensions/cocostudio/trigger/TriggerMng.js | 10 +- extensions/cocostudio/trigger/TriggerObj.js | 4 +- extensions/editbox/CCEditBox.js | 24 ++-- extensions/editbox/CCdomNode.js | 10 +- extensions/gui/control-extension/CCControl.js | 4 +- .../gui/control-extension/CCControlButton.js | 6 +- .../CCControlColourPicker.js | 2 +- .../CCControlPotentiometer.js | 2 +- .../gui/control-extension/CCControlStepper.js | 10 +- .../gui/control-extension/CCMenuPassive.js | 2 +- .../gui/control-extension/CCScale9Sprite.js | 16 +-- .../CCScale9SpriteCanvasRenderCmd.js | 2 +- .../CCScale9SpriteWebGLRenderCmd.js | 2 +- extensions/gui/scrollview/CCScrollView.js | 30 ++--- extensions/gui/scrollview/CCSorting.js | 20 +-- extensions/gui/scrollview/CCTableView.js | 38 +++--- 166 files changed, 1031 insertions(+), 1046 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 8e2a876172..24331d41b9 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -114,7 +114,7 @@ cc.extend = function(target) { * @returns {boolean} */ cc.isFunction = function(obj) { - return typeof obj == 'function'; + return typeof obj === 'function'; }; /** @@ -123,7 +123,7 @@ cc.isFunction = function(obj) { * @returns {boolean} */ cc.isNumber = function(obj) { - return typeof obj == 'number' || Object.prototype.toString.call(obj) == '[object Number]'; + return typeof obj === 'number' || Object.prototype.toString.call(obj) === '[object Number]'; }; /** @@ -132,7 +132,7 @@ cc.isNumber = function(obj) { * @returns {boolean} */ cc.isString = function(obj) { - return typeof obj == 'string' || Object.prototype.toString.call(obj) == '[object String]'; + return typeof obj === 'string' || Object.prototype.toString.call(obj) === '[object String]'; }; /** @@ -174,12 +174,12 @@ cc.isCrossOrigin = function (url) { return false; } var startIndex = url.indexOf("://"); - if (startIndex == -1) + if (startIndex === -1) return false; var endIndex = url.indexOf("/", startIndex + 3); - var urlOrigin = (endIndex == -1) ? url : url.substring(0, endIndex); - return urlOrigin != location.origin; + var urlOrigin = (endIndex === -1) ? url : url.substring(0, endIndex); + return urlOrigin !== location.origin; }; //+++++++++++++++++++++++++something about async begin+++++++++++++++++++++++++++++++ @@ -226,7 +226,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ self._handleItem = function(){ var self = this; - if(self._pool.length == 0 || self._workingSize >= self._limit) + if(self._pool.length === 0 || self._workingSize >= self._limit) return; //return directly if the array's length = 0 or the working size great equal limit number var item = self._pool.shift(); @@ -248,7 +248,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ var arr = Array.prototype.slice.call(arguments, 1); self._results[this.index] = arr[0]; - if (self.finishedSize == self.size) { + if (self.finishedSize === self.size) { if (self._onEnd) self._onEnd.call(self._onEndTarget, null, self._results); return; @@ -260,7 +260,7 @@ cc.AsyncPool = function(srcObj, limit, iterator, onEnd, target){ self.flow = function(){ var self = this; - if(self._pool.length == 0) { + if(self._pool.length === 0) { if(self._onEnd) self._onEnd.call(self._onEndTarget, null, []); return; @@ -318,7 +318,7 @@ cc.async = /** @lends cc.async# */{ function (func, index, cb1) { args.push(function (err) { args = Array.prototype.slice.call(arguments, 1); - if(tasks.length - 1 == index) lastResults = lastResults.concat(args);//while the last task + if(tasks.length - 1 === index) lastResults = lastResults.concat(args);//while the last task cb1.apply(null, arguments); }); func.apply(target, args); @@ -343,7 +343,7 @@ cc.async = /** @lends cc.async# */{ */ map : function(tasks, iterator, callback, target){ var locIterator = iterator; - if(typeof(iterator) == "object"){ + if(typeof(iterator) === "object"){ callback = iterator.cb; target = iterator.iteratorTarget; locIterator = iterator.iterator; @@ -388,7 +388,7 @@ cc.path = /** @lends cc.path# */{ var l = arguments.length; var result = ""; for (var i = 0; i < l; i++) { - result = (result + (result == "" ? "" : "/") + arguments[i]).replace(/(\/|\\\\)$/, ""); + result = (result + (result === "" ? "" : "/") + arguments[i]).replace(/(\/|\\\\)$/, ""); } return result; }, @@ -441,7 +441,7 @@ cc.path = /** @lends cc.path# */{ var result = reg.exec(pathStr.replace(/(\/|\\\\)$/, "")); if (!result) return null; var baseName = result[2]; - if (extname && pathStr.substring(pathStr.length - extname.length).toLowerCase() == extname.toLowerCase()) + if (extname && pathStr.substring(pathStr.length - extname.length).toLowerCase() === extname.toLowerCase()) return baseName.substring(0, baseName.length - extname.length); return baseName; }, @@ -499,7 +499,7 @@ cc.path = /** @lends cc.path# */{ * @returns {string} */ changeBasename: function (pathStr, basename, isSameExt) { - if (basename.indexOf(".") == 0) return this.changeExtname(pathStr, basename); + if (basename.indexOf(".") === 0) return this.changeExtname(pathStr, basename); var index = pathStr.indexOf("?"); var tempStr = ""; var ext = isSameExt ? this.extname(pathStr) : ""; @@ -545,7 +545,7 @@ cc.loader = /** @lends cc.loader# */{ if (args.length === 1) { results[1] = a0 instanceof Array ? a0 : [a0]; } else if (args.length === 2) { - if (typeof a1 == "function") { + if (typeof a1 === "function") { results[1] = a0 instanceof Array ? a0 : [a0]; results[2] = a1; } else { @@ -671,14 +671,14 @@ cc.loader = /** @lends cc.loader# */{ // IE-specific logic here xhr.setRequestHeader("Accept-Charset", "utf-8"); xhr.onreadystatechange = function () { - if(xhr.readyState == 4) - xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo); + if(xhr.readyState === 4) + xhr.status === 200 ? cb(null, xhr.responseText) : cb(errInfo); }; } else { if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8"); xhr.onload = function () { - if(xhr.readyState == 4) - xhr.status == 200 ? cb(null, xhr.responseText) : cb(errInfo); + if(xhr.readyState === 4) + xhr.status === 200 ? cb(null, xhr.responseText) : cb(errInfo); }; } xhr.send(null); @@ -700,7 +700,7 @@ cc.loader = /** @lends cc.loader# */{ if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=utf-8"); } xhr.send(null); - if (!xhr.readyState == 4 || xhr.status != 200) { + if (!xhr.readyState === 4 || xhr.status !== 200) { return null; } return xhr.responseText; @@ -720,8 +720,8 @@ cc.loader = /** @lends cc.loader# */{ if (arrayBuffer) { window.msg = arrayBuffer; } - if(xhr.readyState == 4) - xhr.status == 200 ? cb(null, xhr.response) : cb("load " + url + " failed!"); + if(xhr.readyState === 4) + xhr.status === 200 ? cb(null, xhr.response) : cb("load " + url + " failed!"); }; xhr.send(null); @@ -766,7 +766,7 @@ cc.loader = /** @lends cc.loader# */{ isCrossOrigin: true }; if (callback !== undefined) - opt.isCrossOrigin = option.isCrossOrigin == null ? opt.isCrossOrigin : option.isCrossOrigin; + opt.isCrossOrigin = option.isCrossOrigin === null ? opt.isCrossOrigin : option.isCrossOrigin; else if (option !== undefined) callback = option; @@ -777,7 +777,7 @@ cc.loader = /** @lends cc.loader# */{ } img = new Image(); - if (opt.isCrossOrigin && location.origin != "file://") + if (opt.isCrossOrigin && location.origin !== "file://") img.crossOrigin = "Anonymous"; var loadCallback = function () { @@ -793,12 +793,12 @@ cc.loader = /** @lends cc.loader# */{ var errorCallback = function () { this.removeEventListener('error', errorCallback, false); - if(img.crossOrigin && img.crossOrigin.toLowerCase() == "anonymous"){ + if(img.crossOrigin && img.crossOrigin.toLowerCase() === "anonymous"){ opt.isCrossOrigin = false; self.release(url); cc.loader.loadImg(url, opt, callback); }else{ - typeof callback == "function" && callback("load image failed"); + typeof callback === "function" && callback("load image failed"); } }; @@ -898,20 +898,20 @@ cc.loader = /** @lends cc.loader# */{ load : function(resources, option, loadCallback){ var self = this; var len = arguments.length; - if(len == 0) + if(len === 0) throw "arguments error!"; - if(len == 3){ - if(typeof option == "function"){ - if(typeof loadCallback == "function") + if(len === 3){ + if(typeof option === "function"){ + if(typeof loadCallback === "function") option = {trigger : option, cb : loadCallback }; else option = { cb : option, cbTarget : loadCallback}; } - }else if(len == 2){ - if(typeof option == "function") + }else if(len === 2){ + if(typeof option === "function") option = {cb : option}; - }else if(len == 1){ + }else if(len === 1){ option = {}; } @@ -992,7 +992,7 @@ cc.loader = /** @lends cc.loader# */{ register: function (extNames, loader) { if (!extNames || !loader) return; var self = this; - if (typeof extNames == "string") + if (typeof extNames === "string") return this._register[extNames.trim().toLowerCase()] = loader; for (var i = 0, li = extNames.length; i < li; i++) { self._register["." + extNames[i].trim().toLowerCase()] = loader; @@ -1047,7 +1047,7 @@ cc.formatStr = function(){ var str = args[0]; var needToFormat = true; - if(typeof str == "object"){ + if(typeof str === "object"){ needToFormat = false; } for(var i = 1; i < l; ++i){ @@ -1055,7 +1055,7 @@ cc.formatStr = function(){ if(needToFormat){ while(true){ var result = null; - if(typeof arg == "number"){ + if(typeof arg === "number"){ result = str.match(/(%d)|(%s)/); if(result){ str = str.replace(/(%d)|(%s)/, arg); @@ -1527,7 +1527,7 @@ cc._initSys = function (config, CONFIG_KEY) { * @name isMobile * @type {Boolean} */ - sys.isMobile = ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1; + sys.isMobile = ua.indexOf('mobile') !== -1 || ua.indexOf('android') !== -1; /** * Indicate the running platform @@ -1554,12 +1554,12 @@ cc._initSys = function (config, CONFIG_KEY) { || ua.match(/chrome|safari/i); if (browserTypes && browserTypes.length > 0) { browserType = browserTypes[0]; - if (browserType == 'micromessenger') { + if (browserType === 'micromessenger') { browserType = sys.BROWSER_TYPE_WECHAT; } else if (browserType === "safari" && (ua.match(/android.*applewebkit/))) browserType = sys.BROWSER_TYPE_ANDROID; - else if (browserType == "trident") browserType = sys.BROWSER_TYPE_IE; - else if (browserType == "360 aphone") browserType = sys.BROWSER_TYPE_360; + else if (browserType === "trident") browserType = sys.BROWSER_TYPE_IE; + else if (browserType === "360 aphone") browserType = sys.BROWSER_TYPE_360; }else if(ua.indexOf("iphone") && ua.indexOf("mobile")){ browserType = "safari"; } @@ -1575,12 +1575,12 @@ cc._initSys = function (config, CONFIG_KEY) { var iOS = ( ua.match(/(iPad|iPhone|iPod)/i) ? true : false ); var isAndroid = ua.match(/android/i) || nav.platform.match(/android/i) ? true : false; var osName = sys.OS_UNKNOWN; - if (nav.appVersion.indexOf("Win") != -1) osName = sys.OS_WINDOWS; + if (nav.appVersion.indexOf("Win") !== -1) osName = sys.OS_WINDOWS; else if (iOS) osName = sys.OS_IOS; - else if (nav.appVersion.indexOf("Mac") != -1) osName = sys.OS_OSX; - else if (nav.appVersion.indexOf("X11") != -1 && nav.appVersion.indexOf("Linux") == -1) osName = sys.OS_UNIX; + else if (nav.appVersion.indexOf("Mac") !== -1) osName = sys.OS_OSX; + else if (nav.appVersion.indexOf("X11") !== -1 && nav.appVersion.indexOf("Linux") === -1) osName = sys.OS_UNIX; else if (isAndroid) osName = sys.OS_ANDROID; - else if (nav.appVersion.indexOf("Linux") != -1) osName = sys.OS_LINUX; + else if (nav.appVersion.indexOf("Linux") !== -1) osName = sys.OS_LINUX; /** * Indicate the running os name @@ -1600,10 +1600,10 @@ cc._initSys = function (config, CONFIG_KEY) { cc._supportRender = true; var notSupportGL = true; if(iOS) - notSupportGL = !window.WebGLRenderingContext || osSupportWebGL.indexOf(sys.os) == -1; + notSupportGL = !window.WebGLRenderingContext || osSupportWebGL.indexOf(sys.os) === -1; else - notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) == -1 || osSupportWebGL.indexOf(sys.os) == -1; - if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin == "file://")) + notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) === -1 || osSupportWebGL.indexOf(sys.os) === -1; + if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin === "file://")) renderType = cc._RENDER_TYPE_CANVAS; sys._canUseCanvasNewBlendModes = function(){ @@ -1630,15 +1630,15 @@ cc._initSys = function (config, CONFIG_KEY) { //Whether or not the Canvas BlendModes are supported. sys._supportCanvasNewBlendModes = sys._canUseCanvasNewBlendModes(); - if (renderType == cc._RENDER_TYPE_WEBGL) { + if (renderType === cc._RENDER_TYPE_WEBGL) { if (!win.WebGLRenderingContext || !cc.create3DContext(tempCanvas, {'stencil': true, 'preserveDrawingBuffer': true })) { - if (userRenderMode == 0) renderType = cc._RENDER_TYPE_CANVAS; + if (userRenderMode === 0) renderType = cc._RENDER_TYPE_CANVAS; else cc._supportRender = false; } } - if (renderType == cc._RENDER_TYPE_CANVAS) { + if (renderType === cc._RENDER_TYPE_CANVAS) { try { tempCanvas.getContext("2d"); } catch (e) { @@ -1676,7 +1676,7 @@ cc._initSys = function (config, CONFIG_KEY) { } var capabilities = sys.capabilities = {"canvas": true}; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) + if (cc._renderType === cc._RENDER_TYPE_WEBGL) capabilities["opengl"] = true; if (docEle['ontouchstart'] !== undefined || doc['ontouchstart'] !== undefined || nav.msPointerEnabled) capabilities["touches"] = true; @@ -1838,7 +1838,7 @@ cc._setup = function (el, width, height) { cc.game._setAnimFrame(); - if (element.tagName == "CANVAS") { + if (element.tagName === "CANVAS") { width = width || element.width; height = height || element.height; @@ -1849,7 +1849,7 @@ cc._setup = function (el, width, height) { localCanvas.appendTo(localContainer); localContainer.setAttribute('id', 'Cocos2dGameContainer'); } else {//we must make a new canvas and place into this element - if (element.tagName != "DIV") { + if (element.tagName !== "DIV") { cc.log("Warning: target element is not a DIV or CANVAS"); } width = width || element.clientWidth; @@ -1873,7 +1873,7 @@ cc._setup = function (el, width, height) { localConStyle.overflow = 'hidden'; localContainer.top = '100%'; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) + if (cc._renderType === cc._RENDER_TYPE_WEBGL) cc._renderContext = cc.webglContext = cc.create3DContext(localCanvas, { 'stencil': true, 'preserveDrawingBuffer': true, @@ -2036,7 +2036,7 @@ cc.game = /** @lends cc.game# */{ _setAnimFrame: function () { this._lastTime = new Date(); this._frameTime = 1000 / cc.game.config[cc.game.CONFIG_KEY.frameRate]; - if((cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT) || cc.game.config[cc.game.CONFIG_KEY.frameRate] != 60) { + if((cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT) || cc.game.config[cc.game.CONFIG_KEY.frameRate] !== 60) { window.requestAnimFrame = this._stTime; window.cancelAnimationFrame = this._ctTime; } @@ -2157,7 +2157,7 @@ cc.game = /** @lends cc.game# */{ var cocos_script = document.getElementsByTagName('script'); for(var i=0;i 0) { var locGridSize = targetGrid.getGridSize(); - if (targetGrid.isActive() && (locGridSize.width == this._gridSize.width) && (locGridSize.height == this._gridSize.height)) + if (targetGrid.isActive() && (locGridSize.width === this._gridSize.width) && (locGridSize.height === this._gridSize.height)) targetGrid.reuse(); } else { if (targetGrid && targetGrid.isActive()) diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js index d795c69b40..31be9c2e9a 100644 --- a/cocos2d/actions3d/CCActionGrid3D.js +++ b/cocos2d/actions3d/CCActionGrid3D.js @@ -184,7 +184,7 @@ cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{ * @return {Boolean} */ initWithSize:function (gridSize, duration) { - if (gridSize.width != 1 || gridSize.height != 1) { + if (gridSize.width !== 1 || gridSize.height !== 1) { // Grid size must be (1,1) cc.log("Grid size must be (1,1)"); return false; @@ -516,7 +516,7 @@ cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{ if (r < locRadius) { r = locRadius - r; pre_log = r / locRadius; - if (pre_log == 0) + if (pre_log === 0) pre_log = 0.001; l = Math.log(pre_log) * locLensEffect; diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js index ff9b42e6be..dae3d8daa2 100644 --- a/cocos2d/actions3d/CCActionTiledGrid.js +++ b/cocos2d/actions3d/CCActionTiledGrid.js @@ -457,7 +457,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ testFunc:function (pos, time) { var locX = this._gridSize.width * time; var locY = this._gridSize.height * time; - if ((locX + locY) == 0.0) + if ((locX + locY) === 0.0) return 1.0; return Math.pow((pos.width + pos.height) / (locX + locY), 6); }, @@ -516,7 +516,7 @@ cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */ locSize.width = i; locSize.height = j; distance = this.testFunc(locSize, dt); - if (distance == 0) + if (distance === 0) this.turnOffTile(locPos); else if (distance < 1) this.transformTile(locPos, distance); @@ -566,7 +566,7 @@ cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{ testFunc:function (pos, time) { var locX = this._gridSize.width * (1.0 - time); var locY = this._gridSize.height * (1.0 - time); - if ((pos.width + pos.height) == 0) + if ((pos.width + pos.height) === 0) return 1.0; return Math.pow((locX + locY) / (pos.width + pos.height), 6); @@ -606,7 +606,7 @@ cc.FadeOutBLTiles.create = cc.fadeOutBLTiles; cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{ testFunc:function (pos, time) { var locY = this._gridSize.height * time; - if (locY == 0.0) + if (locY === 0.0) return 1.0; return Math.pow(pos.height / locY, 6); }, @@ -657,7 +657,7 @@ cc.FadeOutUpTiles.create = cc.fadeOutUpTiles; cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend(/** @lends cc.FadeOutDownTiles# */{ testFunc:function (pos, time) { var locY = this._gridSize.height * (1.0 - time); - if (pos.height == 0) + if (pos.height === 0) return 1.0; return Math.pow(locY / pos.height, 6); } @@ -1057,7 +1057,7 @@ cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{ //var coords = this.originalTile(cc.p(i, j)); coords = locGrid.originalTile(locPos); - if (((i + j) % 2) == 0) { + if (((i + j) % 2) === 0) { coords.bl.z += sinz; coords.br.z += sinz; coords.tl.z += sinz; @@ -1150,7 +1150,7 @@ cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{ coords = this.originalTile(locPos); direction = 1; - if ((j % 2 ) == 0) + if ((j % 2 ) === 0) direction = -1; coords.bl.x += direction * locWinSizeWidth * dt; @@ -1241,7 +1241,7 @@ cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{ coords = this.originalTile(locPos); direction = 1; - if ((i % 2 ) == 0) + if ((i % 2 ) === 0) direction = -1; coords.bl.y += direction * locWinSizeHeight * dt; diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 6ce489238c..e59d580ffc 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -121,7 +121,7 @@ break; case sys.BROWSER_TYPE_MIUI: version = version.match(/\d+/g); - if(version[0] < 2 || (version[0] == 2 && version[1] == 0 && version[2] <= 1)){ + if(version[0] < 2 || (version[0] === 2 && version[1] === 0 && version[2] <= 1)){ supportTable[sys.BROWSER_TYPE_MIUI].auto = false; } break; @@ -129,7 +129,7 @@ } if(cc.sys.isMobile){ - if(cc.sys.os != cc.sys.OS_IOS) + if(cc.sys.os !== cc.sys.OS_IOS) cc.__audioSupport = supportTable[sys.browserType] || supportTable["common"]; else cc.__audioSupport = supportTable[sys.BROWSER_TYPE_SAFARI]; @@ -200,7 +200,7 @@ cc.Audio = cc.Class.extend({ var playing = this._playing; this._AUDIO_TYPE = "WEBAUDIO"; - if(this._buffer && this._buffer != buffer && this.getPlaying()) + if(this._buffer && this._buffer !== buffer && this.getPlaying()) this.stop(); this._buffer = buffer; @@ -217,7 +217,7 @@ cc.Audio = cc.Class.extend({ var playing = this._playing; this._AUDIO_TYPE = "AUDIO"; - if(this._element && this._element != element && this.getPlaying()) + if(this._element && this._element !== element && this.getPlaying()) this.stop(); this._element = element; @@ -350,7 +350,7 @@ cc.Audio = cc.Class.extend({ var audio = this._element; if(audio){ audio.pause(); - if (audio.duration && audio.duration != Infinity) + if (audio.duration && audio.duration !== Infinity) audio.currentTime = 0; } }, @@ -570,7 +570,7 @@ cc.Audio = cc.Class.extend({ var termination = false; var timer = setTimeout(function(){ - if(element.readyState == 0){ + if(element.readyState === 0){ emptied(); }else{ termination = true; diff --git a/cocos2d/clipping-nodes/CCClippingNode.js b/cocos2d/clipping-nodes/CCClippingNode.js index 7d73097c3f..65a10b45cf 100644 --- a/cocos2d/clipping-nodes/CCClippingNode.js +++ b/cocos2d/clipping-nodes/CCClippingNode.js @@ -189,7 +189,7 @@ cc.ClippingNode = cc.Node.extend(/** @lends cc.ClippingNode# */{ * @param {cc.Node} stencil */ setStencil: function (stencil) { - if(this._stencil == stencil) + if(this._stencil === stencil) return; this._renderCmd.setStencil(stencil); }, diff --git a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js index 451fb6ab7f..283df8fc46 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js @@ -91,7 +91,7 @@ return; } - if (cc.ClippingNode.WebGLRenderCmd._layer + 1 == cc.stencilBits) { + if (cc.ClippingNode.WebGLRenderCmd._layer + 1 === cc.stencilBits) { cc.ClippingNode.WebGLRenderCmd._visit_once = true; if (cc.ClippingNode.WebGLRenderCmd._visit_once) { cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its children."); diff --git a/cocos2d/compression/base64.js b/cocos2d/compression/base64.js index dbbf5b9f70..adb0d68871 100644 --- a/cocos2d/compression/base64.js +++ b/cocos2d/compression/base64.js @@ -42,10 +42,10 @@ cc.Codec.Base64.decode = function Jacob__Codec__Base64__decode(input) { output.push(String.fromCharCode(chr1)); - if (enc3 != 64) { + if (enc3 !== 64) { output.push(String.fromCharCode(chr2)); } - if (enc4 != 64) { + if (enc4 !== 64) { output.push(String.fromCharCode(chr3)); } } @@ -82,7 +82,7 @@ cc.Codec.Base64.decodeAsArray = function Jacob__Codec__Base64___decodeAsArray(in }; cc.uint8ArrayToUint32Array = function(uint8Arr){ - if(uint8Arr.length % 4 != 0) + if(uint8Arr.length % 4 !== 0) return null; var arrLen = uint8Arr.length /4; diff --git a/cocos2d/compression/gzip.js b/cocos2d/compression/gzip.js index 65c7d79eda..baed633cef 100644 --- a/cocos2d/compression/gzip.js +++ b/cocos2d/compression/gzip.js @@ -157,7 +157,7 @@ cc.Codec.GZip.prototype.readBit = function () { this.bits++; carry = (this.bb & 1); this.bb >>= 1; - if (this.bb == 0) { + if (this.bb === 0) { this.bb = this.readByte(); carry = (this.bb & 1); this.bb = (this.bb >> 1) | 0x80; @@ -182,13 +182,13 @@ cc.Codec.GZip.prototype.flushBuffer = function () { cc.Codec.GZip.prototype.addBuffer = function (a) { this.buf32k[this.bIdx++] = a; this.outputArr.push(String.fromCharCode(a)); - if (this.bIdx == 0x8000) this.bIdx = 0; + if (this.bIdx === 0x8000) this.bIdx = 0; }; cc.Codec.GZip.prototype.IsPat = function () { while (1) { if (this.fpos[this.len] >= this.fmax) return -1; - if (this.flens[this.fpos[this.len]] == this.len) return this.fpos[this.len]++; + if (this.flens[this.fpos[this.len]] === this.len) return this.fpos[this.len]++; this.fpos[this.len]++; } }; @@ -197,7 +197,7 @@ cc.Codec.GZip.prototype.Rec = function () { var curplace = this.Places[this.treepos]; var tmp; //if (this.debug) document.write("
    len:"+this.len+" treepos:"+this.treepos); - if (this.len == 17) { //war 17 + if (this.len === 17) { //war 17 return -1; } this.treepos++; @@ -304,7 +304,7 @@ cc.Codec.GZip.prototype.DeflateLoop = function () { last = this.readBit(); type = this.readBits(2); - if (type == 0) { + if (type === 0) { var blockLen, cSum; // Stored @@ -322,7 +322,7 @@ cc.Codec.GZip.prototype.DeflateLoop = function () { c = this.readByte(); this.addBuffer(c); } - } else if (type == 1) { + } else if (type === 1) { var j; /* Fixed Huffman tables -- fixed decode routine */ @@ -368,7 +368,7 @@ cc.Codec.GZip.prototype.DeflateLoop = function () { } if (j < 256) { this.addBuffer(j); - } else if (j == 256) { + } else if (j === 256) { /* EOF */ break; // FIXME: make this the loop-condition } else { @@ -394,7 +394,7 @@ cc.Codec.GZip.prototype.DeflateLoop = function () { } } // while - } else if (type == 2) { + } else if (type === 2) { var j, n, literalCodes, distCodes, lenCodes; var ll = new Array(288 + 32); // "static" just to preserve stack @@ -436,7 +436,7 @@ cc.Codec.GZip.prototype.DeflateLoop = function () { // if (this.debug) document.write("
    "+z+" i:"+i+" decode: "+j+" bits "+this.bits+"
    "); if (j < 16) { // length of code in bits (0..15) ll[i++] = j; - } else if (j == 16) { // repeat last length 3 to 6 times + } else if (j === 16) { // repeat last length 3 to 6 times var l; j = 3 + this.readBits(2); if (i + j > n) { @@ -448,7 +448,7 @@ cc.Codec.GZip.prototype.DeflateLoop = function () { ll[i++] = l; } } else { - if (j == 17) { // 3 to 10 zero length codes + if (j === 17) { // 3 to 10 zero length codes j = 3 + this.readBits(3); } else { // j == 18: 11 to 138 zero length codes j = 11 + this.readBits(7); @@ -485,7 +485,7 @@ cc.Codec.GZip.prototype.DeflateLoop = function () { if (j >= 256) { // In C64: if carry set var len, dist; j -= 256; - if (j == 0) { + if (j === 0) { // EOF break; } @@ -520,7 +520,7 @@ cc.Codec.GZip.prototype.unzipFile = function (name) { var i; this.gunzip(); for (i = 0; i < this.unzipped.length; i++) { - if (this.unzipped[i][1] == name) { + if (this.unzipped[i][1] === name) { return this.unzipped[i][0]; } } @@ -537,25 +537,25 @@ cc.Codec.GZip.prototype.nextFile = function () { tmp[1] = this.readByte(); // if (this.debug) alert("type: "+tmp[0]+" "+tmp[1]); - if (tmp[0] == 0x78 && tmp[1] == 0xda) { //GZIP + if (tmp[0] === 0x78 && tmp[1] === 0xda) { //GZIP // if (this.debug) alert("GEONExT-GZIP"); this.DeflateLoop(); // if (this.debug) alert(this.outputArr.join('')); this.unzipped[this.files] = [this.outputArr.join(''), "geonext.gxt"]; this.files++; } - if (tmp[0] == 0x1f && tmp[1] == 0x8b) { //GZIP + if (tmp[0] === 0x1f && tmp[1] === 0x8b) { //GZIP // if (this.debug) alert("GZIP"); this.skipdir(); // if (this.debug) alert(this.outputArr.join('')); this.unzipped[this.files] = [this.outputArr.join(''), "file"]; this.files++; } - if (tmp[0] == 0x50 && tmp[1] == 0x4b) { //ZIP + if (tmp[0] === 0x50 && tmp[1] === 0x4b) { //ZIP this.modeZIP = true; tmp[2] = this.readByte(); tmp[3] = this.readByte(); - if (tmp[2] == 0x03 && tmp[3] == 0x04) { + if (tmp[2] === 0x03 && tmp[3] === 0x04) { //MODE_ZIP tmp[0] = this.readByte(); tmp[1] = this.readByte(); @@ -602,7 +602,7 @@ cc.Codec.GZip.prototype.nextFile = function () { this.nameBuf = []; while (filelen--) { var c = this.readByte(); - if (c == "/" | c == ":") { + if (c === "/" | c === ":") { i = 0; } else if (i < cc.Codec.GZip.NAMEMAX - 1) { this.nameBuf[i++] = String.fromCharCode(c); @@ -622,7 +622,7 @@ cc.Codec.GZip.prototype.nextFile = function () { // //skipdir // // if (this.debug) alert("skipdir"); // } - if (method == 8) { + if (method === 8) { this.DeflateLoop(); // if (this.debug) alert(this.outputArr.join('')); this.unzipped[this.files] = [this.outputArr.join(''), this.nameBuf.join('')]; @@ -666,7 +666,7 @@ cc.Codec.GZip.prototype.skipdir = function () { if (this.modeZIP) this.nextFile(); tmp[0] = this.readByte(); - if (tmp[0] != 8) { + if (tmp[0] !== 8) { // if (this.debug) alert("Unknown compression method!"); return 0; } @@ -695,7 +695,7 @@ cc.Codec.GZip.prototype.skipdir = function () { i = 0; this.nameBuf = []; while (c = this.readByte()) { - if (c == "7" || c == ":") + if (c === "7" || c === ":") i = 0; if (i < cc.Codec.GZip.NAMEMAX - 1) this.nameBuf[i++] = c; diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/core/CCActionManager.js index aeade2fe6e..ac061e3f5a 100644 --- a/cocos2d/core/CCActionManager.js +++ b/cocos2d/core/CCActionManager.js @@ -73,7 +73,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ _searchElementByTarget:function (arr, target) { for (var k = 0; k < arr.length; k++) { - if (target == arr[k].target) + if (target === arr[k].target) return arr[k]; } return null; @@ -143,7 +143,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ element.currentActionSalvaged = true; element.actions.length = 0; - if (this._currentTarget == element && !forceDelete) { + if (this._currentTarget === element && !forceDelete) { this._currentTargetSalvaged = true; } else { this._deleteHashElement(element); @@ -162,7 +162,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ if (element) { for (var i = 0; i < element.actions.length; i++) { - if (element.actions[i] == action) { + if (element.actions[i] === action) { element.actions.splice(i, 1); break; } @@ -177,7 +177,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ * @param {object} target */ removeActionByTag:function (tag, target) { - if(tag == cc.ACTION_TAG_INVALID) + if(tag === cc.ACTION_TAG_INVALID) cc.log(cc._LogInfos.ActionManager_addAction); cc.assert(target, cc._LogInfos.ActionManager_addAction); @@ -188,7 +188,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ var limit = element.actions.length; for (var i = 0; i < limit; ++i) { var action = element.actions[i]; - if (action && action.getTag() === tag && action.getOriginalTarget() == target) { + if (action && action.getTag() === tag && action.getOriginalTarget() === target) { this._removeActionAtIndex(i, element); break; } @@ -202,7 +202,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ * @return {cc.Action|Null} return the Action with the given tag on success */ getActionByTag:function (tag, target) { - if(tag == cc.ACTION_TAG_INVALID) + if(tag === cc.ACTION_TAG_INVALID) cc.log(cc._LogInfos.ActionManager_getActionByTag); var element = this._hashTargets[target.__instanceId]; @@ -294,7 +294,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ _removeActionAtIndex:function (index, element) { var action = element.actions[index]; - if ((action == element.currentAction) && (!element.currentActionSalvaged)) + if ((action === element.currentAction) && (!element.currentActionSalvaged)) element.currentActionSalvaged = true; element.actions.splice(index, 1); @@ -303,8 +303,8 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{ if (element.actionIndex >= index) element.actionIndex--; - if (element.actions.length == 0) { - if (this._currentTarget == element) { + if (element.actions.length === 0) { + if (this._currentTarget === element) { this._currentTargetSalvaged = true; } else { this._deleteHashElement(element); diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 99988bd431..02141cbda5 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -365,7 +365,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ this._scenesStack.pop(); var c = this._scenesStack.length; - if (c == 0) + if (c === 0) this.end(); else { this._sendCleanupToScene = true; @@ -485,7 +485,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ * @param {Number} scaleFactor */ setContentScaleFactor: function (scaleFactor) { - if (scaleFactor != this._contentScaleFactor) { + if (scaleFactor !== this._contentScaleFactor) { this._contentScaleFactor = scaleFactor; this._createStatsLabel(); } @@ -542,7 +542,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ cc.renderer.childrenOrderDirty = true; this._nextScene = null; - if ((!runningIsTransition) && (this._runningScene != null)) { + if ((!runningIsTransition) && (this._runningScene !== null)) { this._runningScene.onEnter(); this._runningScene.onEnterTransitionDidFinish(); } @@ -737,7 +737,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ var locScenesStack = this._scenesStack; var c = locScenesStack.length; - if (c == 0) { + if (c === 0) { this.end(); return; } @@ -772,7 +772,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ * @param {cc.Scheduler} scheduler */ setScheduler: function (scheduler) { - if (this._scheduler != scheduler) { + if (this._scheduler !== scheduler) { this._scheduler = scheduler; } }, @@ -789,7 +789,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ * @param {cc.ActionManager} actionManager */ setActionManager: function (actionManager) { - if (this._actionManager != actionManager) { + if (this._actionManager !== actionManager) { this._actionManager = actionManager; } }, diff --git a/cocos2d/core/CCDirectorWebGL.js b/cocos2d/core/CCDirectorWebGL.js index 0747f31794..bdd9d62fb6 100644 --- a/cocos2d/core/CCDirectorWebGL.js +++ b/cocos2d/core/CCDirectorWebGL.js @@ -167,7 +167,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) { return } - if ((cc.Director._fpsImageLoaded == null) || (cc.Director._fpsImageLoaded == false)) + if ((cc.Director._fpsImageLoaded == null) || (cc.Director._fpsImageLoaded === false)) return; var texture = new cc.Texture2D(); diff --git a/cocos2d/core/CCDrawingPrimitivesCanvas.js b/cocos2d/core/CCDrawingPrimitivesCanvas.js index 93b24ea628..a08dfbe38c 100644 --- a/cocos2d/core/CCDrawingPrimitivesCanvas.js +++ b/cocos2d/core/CCDrawingPrimitivesCanvas.js @@ -279,7 +279,7 @@ cc.DrawingPrimitiveCanvas = cc.Class.extend(/** @lends cc.DrawingPrimitiveCanvas var dt = i / segments; // border - if (dt == 1) { + if (dt === 1) { p = config.length - 1; lt = 1; } else { diff --git a/cocos2d/core/CCDrawingPrimitivesWebGL.js b/cocos2d/core/CCDrawingPrimitivesWebGL.js index f5461a01f5..c3942a9981 100644 --- a/cocos2d/core/CCDrawingPrimitivesWebGL.js +++ b/cocos2d/core/CCDrawingPrimitivesWebGL.js @@ -104,7 +104,7 @@ cc.DrawingPrimitiveWebGL = cc.Class.extend(/** @lends cc.DrawingPrimitiveWebGL# * @param {Number} numberOfPoints */ drawPoints:function (points, numberOfPoints) { - if (!points || points.length == 0) + if (!points || points.length === 0) return; this.lazy_init(); @@ -395,7 +395,7 @@ cc.DrawingPrimitiveWebGL = cc.Class.extend(/** @lends cc.DrawingPrimitiveWebGL# var dt = i / segments; // border - if (dt == 1) { + if (dt === 1) { p = config.length - 1; lt = 1; } else { @@ -403,7 +403,7 @@ cc.DrawingPrimitiveWebGL = cc.Class.extend(/** @lends cc.DrawingPrimitiveWebGL# lt = (dt - deltaT * p) / deltaT; } - var newPos = cc.CardinalSplineAt( + var newPos = cc.cardinalSplineAt( cc.getControlPointAt(config, p - 1), cc.getControlPointAt(config, p), cc.getControlPointAt(config, p + 1), diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 510b21735b..fda045ebb2 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -126,7 +126,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ this._delay = delay; this._useDelay = (this._delay > 0); this._repeat = repeat; - this._runForever = (this._repeat == cc.REPEAT_FOREVER); + this._runForever = (this._repeat === cc.REPEAT_FOREVER); }, trigger: function(){ @@ -157,7 +157,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ * @param {Number} dt delta time */ update:function (dt) { - if (this._elapsed == -1) { + if (this._elapsed === -1) { this._elapsed = 0; this._timesExecuted = 0; } else { @@ -328,7 +328,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ var hashElement = this._hashForUpdates[target.__instanceId]; if (hashElement){ // check if priority has changed - if (hashElement.list.priority != priority){ + if (hashElement.list.priority !== priority){ if (this._updateHashLocked){ cc.log("warning: you CANNOT change update priority in scheduled function"); hashElement.entry.markedForDeletion = false; @@ -347,7 +347,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ // most of the updates are going to be 0, that's way there // is an special list for updates with priority 0 - if (priority == 0){ + if (priority === 0){ this._appendIn(this._updates0List, callback, target, paused); }else if (priority < 0){ this._priorityIn(this._updatesNegList, callback, target, priority, paused); @@ -442,7 +442,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ */ update:function (dt) { this._updateHashLocked = true; - if(this._timeScale != 1) + if(this._timeScale !== 1) dt *= this._timeScale; var i, list, len, entry; @@ -488,7 +488,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ //elt = elt.hh.next; // only delete currentTarget if no actions were scheduled during the cycle (issue #481) - if (this._currentTargetSalvaged && this._currentTarget.timers.length == 0) + if (this._currentTargetSalvaged && this._currentTarget.timers.length === 0) this._removeHashElement(this._currentTarget); } @@ -549,7 +549,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ schedule: function(callback, target, interval, repeat, delay, paused, key){ var isSelector = false; - if(typeof callback != "function"){ + if(typeof callback !== "function"){ var selector = callback; isSelector = true; } @@ -566,7 +566,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ }else{ //selector, target, interval, repeat, delay, paused //selector, target, interval, paused - if(arguments.length == 4){ + if(arguments.length === 4){ paused = repeat; repeat = cc.REPEAT_FOREVER; delay = 0; @@ -585,7 +585,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ this._arrayForTimers.push(element); this._hashForTimers[target.__instanceId] = element; }else{ - cc.assert(element.paused == paused, ""); + cc.assert(element.paused === paused, ""); } var timer, i; @@ -594,7 +594,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ } else if(isSelector === false) { for (i = 0; i < element.timers.length; i++) { timer = element.timers[i]; - if (callback == timer._callback) { + if (callback === timer._callback) { cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, timer.getInterval().toFixed(4), interval.toFixed(4)); timer._interval = interval; return; @@ -603,7 +603,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ }else{ for (i = 0; i < element.timers.length; ++i){ timer =element.timers[i]; - if (timer && selector == timer.getSelector()){ + if (timer && selector === timer.getSelector()){ cc.log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer.getInterval(), interval); timer.setInterval(interval); return; @@ -634,11 +634,11 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ switch (typeof key){ case "number": case "string": - return key == timer.getKey(); + return key === timer.getKey(); case "function": - return key == timer._callback; + return key === timer._callback; default: - return key == timer.getSelector(); + return key === timer.getSelector(); } }, unschedule: function(key, target){ @@ -656,7 +656,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ for(var i = 0, li = timers.length; i < li; i++){ var timer = timers[i]; if (this._getUnscheduleMark(key, timer)) { - if ((timer == element.currentTimer) && (!element.currentTimerSalvaged)) { + if ((timer === element.currentTimer) && (!element.currentTimerSalvaged)) { element.currentTimerSalvaged = true; } timers.splice(i, 1); @@ -665,8 +665,8 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ element.timerIndex--; } - if (timers.length == 0) { - if (self._currentTarget == element) { + if (timers.length === 0) { + if (self._currentTarget === element) { self._currentTargetSalvaged = true; } else { self._removeHashElement(element); @@ -710,7 +710,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ // ccArrayRemoveAllObjects(element.timers); element.timers.length = 0; - if (this._currentTarget == element){ + if (this._currentTarget === element){ this._currentTargetSalvaged = true; }else{ this._removeHashElement(element); @@ -785,7 +785,7 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ for (var i = 0; i < timers.length; ++i){ var timer = timers[i]; - if (key == timer.getKey()){ + if (key === timer.getKey()){ return true; } } diff --git a/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js index e236ae82fb..64e557c966 100644 --- a/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js @@ -58,7 +58,7 @@ proto.setColor = function(color3){ var node = this._node; var locRealColor = node._realColor; - if ((locRealColor.r == color3.r) && (locRealColor.g == color3.g) && (locRealColor.b == color3.b)) + if ((locRealColor.r === color3.r) && (locRealColor.g === color3.g) && (locRealColor.b === color3.b)) return; this._colorUnmodified = color3; this._changeTextureColor(); diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 0094a86464..b2888ae0fd 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -446,7 +446,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Number} globalZOrder */ setGlobalZOrder: function (globalZOrder) { - if (this._globalZOrder != globalZOrder) { + if (this._globalZOrder !== globalZOrder) { this._globalZOrder = globalZOrder; cc.eventManager._setDirtyForNode(this); } @@ -966,7 +966,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {Boolean} newValue true if anchor point will be ignored when you position this node */ ignoreAnchorPointForPosition: function (newValue) { - if (newValue != this._ignoreAnchorPointForPosition) { + if (newValue !== this._ignoreAnchorPointForPosition) { this._ignoreAnchorPointForPosition = newValue; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); } @@ -1076,7 +1076,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {object} newValue A user cocos2d object */ setUserObject: function (newValue) { - if (this.userObject != newValue) + if (this.userObject !== newValue) this.userObject = newValue; }, @@ -1125,7 +1125,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param {cc.ActionManager} actionManager A CCActionManager object that is used by all actions. */ setActionManager: function (actionManager) { - if (this._actionManager != actionManager) { + if (this._actionManager !== actionManager) { this.stopAllActions(); this._actionManager = actionManager; } @@ -1154,7 +1154,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * @param scheduler A cc.Scheduler object that is used to schedule all "update" and timers. */ setScheduler: function (scheduler) { - if (this._scheduler != scheduler) { + if (this._scheduler !== scheduler) { this.unscheduleAllCallbacks(); this._scheduler = scheduler; } @@ -1206,10 +1206,10 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ getChildByTag: function (aTag) { var __children = this._children; - if (__children != null) { + if (__children !== null) { for (var i = 0; i < __children.length; i++) { var node = __children[i]; - if (node && node.tag == aTag) + if (node && node.tag === aTag) return node; } } @@ -1230,7 +1230,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var locChildren = this._children; for(var i = 0, len = locChildren.length; i < len; i++){ - if(locChildren[i]._name == name) + if(locChildren[i]._name === name) return locChildren[i]; } return null; @@ -1378,7 +1378,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ removeAllChildren: function (cleanup) { // not using detachChild improves speed here var __children = this._children; - if (__children != null) { + if (__children !== null) { if (cleanup == null) cleanup = true; for (var i = 0; i < __children.length; i++) { @@ -1494,7 +1494,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // Internal use only, do not call it by yourself, transformAncestors: function () { - if (this._parent != null) { + if (this._parent !== null) { this._parent.transformAncestors(); this._parent.transform(); } @@ -1678,13 +1678,13 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ var len = arguments.length; if(typeof callback === "function"){ //callback, interval, repeat, delay, key - if(len == 1){ + if(len === 1){ //callback interval = 0; repeat = cc.REPEAT_FOREVER; delay = 0; key = this.__instanceId; - }else if(len == 2){ + }else if(len === 2){ if(typeof interval === "number"){ //callback, interval repeat = cc.REPEAT_FOREVER; @@ -1709,11 +1709,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ //selector //selector, interval //selector, interval, repeat, delay - if(len == 1){ + if(len === 1){ interval = 0; repeat = cc.REPEAT_FOREVER; delay = 0; - }else if(len == 2){ + }else if(len === 2){ repeat = cc.REPEAT_FOREVER; delay = 0; } @@ -1740,7 +1740,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ scheduleOnce: function (callback, delay, key) { //selector, delay //callback, delay, key - if(key == undefined) + if(key === undefined) key = this.__instanceId; this.schedule(callback, 0, 0, delay, key); }, @@ -1895,7 +1895,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ getNodeToWorldTransform: function () { //TODO renderCmd has a WorldTransform var t = this.getNodeToParentTransform(); - for (var p = this._parent; p != null; p = p.parent) + for (var p = this._parent; p !== null; p = p.parent) t = cc.affineTransformConcat(t, p.getNodeToParentTransform()); return t; }, diff --git a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js index a61ba7ee65..24713c459c 100644 --- a/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js @@ -456,12 +456,12 @@ cc.Node.RenderCmd.prototype = { if (this._cacheDirty === false) { this._cacheDirty = true; var cachedP = this._cachedParent; - cachedP && cachedP != this && cachedP._setNodeDirtyForCache && cachedP._setNodeDirtyForCache(); + cachedP && cachedP !== this && cachedP._setNodeDirtyForCache && cachedP._setNodeDirtyForCache(); } }; proto._setCachedParent = function (cachedParent) { - if (this._cachedParent == cachedParent) + if (this._cachedParent === cachedParent) return; this._cachedParent = cachedParent; @@ -493,11 +493,11 @@ cc.Node.RenderCmd.prototype = { if (!blendFunc) return "source-over"; else { - if (( blendFunc.src == cc.SRC_ALPHA && blendFunc.dst == cc.ONE) || (blendFunc.src == cc.ONE && blendFunc.dst == cc.ONE)) + if (( blendFunc.src === cc.SRC_ALPHA && blendFunc.dst === cc.ONE) || (blendFunc.src === cc.ONE && blendFunc.dst === cc.ONE)) return "lighter"; - else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.SRC_ALPHA) + else if (blendFunc.src === cc.ZERO && blendFunc.dst === cc.SRC_ALPHA) return "destination-in"; - else if (blendFunc.src == cc.ZERO && blendFunc.dst == cc.ONE_MINUS_SRC_ALPHA) + else if (blendFunc.src === cc.ZERO && blendFunc.dst === cc.ONE_MINUS_SRC_ALPHA) return "destination-out"; else return "source-over"; diff --git a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js index 2c70b47fd2..ce62ce39e3 100644 --- a/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +++ b/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js @@ -214,7 +214,7 @@ cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if (node._camera != null && !(node.grid != null && node.grid.isActive())) { + if (node._camera !== null && !(node.grid !== null && node.grid.isActive())) { var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; var translate = (apx !== 0.0 || apy !== 0.0); if (translate){ diff --git a/cocos2d/core/cocoa/CCGeometry.js b/cocos2d/core/cocoa/CCGeometry.js index 3b047b5742..0eeffd5ad2 100644 --- a/cocos2d/core/cocoa/CCGeometry.js +++ b/cocos2d/core/cocoa/CCGeometry.js @@ -55,9 +55,9 @@ cc.p = function (x, y) { // but this one will instead flood the heap with newly allocated hash maps // giving little room for optimization by the JIT, // note: we have tested this item on Chrome and firefox, it is faster than cc.p(x, y) - if (x == undefined) + if (x === undefined) return {x: 0, y: 0}; - if (y == undefined) + if (y === undefined) return {x: x.x, y: x.y}; return {x: x, y: y}; }; @@ -120,7 +120,7 @@ cc.size = function (w, h) { * @return {Boolean} */ cc.sizeEqualToSize = function (size1, size2) { - return (size1 && size2 && (size1.width == size2.width) && (size1.height == size2.height)); + return (size1 && size2 && (size1.width === size2.width) && (size1.height === size2.height)); }; diff --git a/cocos2d/core/event-manager/CCEventExtension.js b/cocos2d/core/event-manager/CCEventExtension.js index afa4c81550..a14968f0f7 100644 --- a/cocos2d/core/event-manager/CCEventExtension.js +++ b/cocos2d/core/event-manager/CCEventExtension.js @@ -111,7 +111,7 @@ cc._EventListenerKeyboard = cc.EventListener.extend({ }, checkAvailable: function () { - if (this.onKeyPressed == null && this.onKeyReleased == null) { + if (this.onKeyPressed === null && this.onKeyReleased === null) { cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable); return false; } diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js index 642d7d9e47..3c9dbab79d 100644 --- a/cocos2d/core/event-manager/CCEventListener.js +++ b/cocos2d/core/event-manager/CCEventListener.js @@ -162,7 +162,7 @@ cc.EventListener = cc.Class.extend(/** @lends cc.EventListener# */{ * @returns {boolean} */ checkAvailable: function () { - return this._onEvent != null; + return this._onEvent !== null; }, /** @@ -288,7 +288,7 @@ cc._EventListenerCustom = cc.EventListener.extend({ this._onCustomEvent = callback; var selfPointer = this; var listener = function (event) { - if (selfPointer._onCustomEvent != null) + if (selfPointer._onCustomEvent !== null) selfPointer._onCustomEvent(event); }; @@ -296,7 +296,7 @@ cc._EventListenerCustom = cc.EventListener.extend({ }, checkAvailable: function () { - return (cc.EventListener.prototype.checkAvailable.call(this) && this._onCustomEvent != null); + return (cc.EventListener.prototype.checkAvailable.call(this) && this._onCustomEvent !== null); }, clone: function () { @@ -428,8 +428,8 @@ cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({ }, checkAvailable: function(){ - if (this.onTouchesBegan == null && this.onTouchesMoved == null - && this.onTouchesEnded == null && this.onTouchesCancelled == null) { + if (this.onTouchesBegan === null && this.onTouchesMoved === null + && this.onTouchesEnded === null && this.onTouchesCancelled === null) { cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable); return false; } diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index d45126255c..84cabd26a4 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -45,7 +45,7 @@ cc._EventListenerVector = cc.Class.extend({ }, push: function (listener) { - if (listener._getFixedPriority() == 0) + if (listener._getFixedPriority() === 0) this._sceneGraphListeners.push(listener); else this._fixedListeners.push(listener); @@ -185,11 +185,11 @@ cc.eventManager = /** @lends cc.eventManager# */{ } listeners.push(listener); - if (listener._getFixedPriority() == 0) { + if (listener._getFixedPriority() === 0) { this._setDirty(listenerID, this.DIRTY_SCENE_GRAPH_PRIORITY); var node = listener._getSceneGraphPriority(); - if (node == null) + if (node === null) cc.log(cc._LogInfos.eventManager__forceAddEventListener); this._associateNodeAndEventListener(node, listener); @@ -204,7 +204,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ }, _updateDirtyFlagForSceneGraph: function () { - if (this._dirtyNodes.length == 0) + if (this._dirtyNodes.length === 0) return; var locDirtyNodes = this._dirtyNodes, selListeners, selListener, locNodeListenersMap = this._nodeListenersMap; @@ -262,7 +262,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ var locToAddedListeners = this._toAddedListeners, listener; for (i = 0; i < locToAddedListeners.length;) { listener = locToAddedListeners[i]; - if (listener && listener._getListenerID() == listenerID) + if (listener && listener._getListenerID() === listenerID) cc.arrayRemoveObject(locToAddedListeners, listener); else ++i; @@ -274,7 +274,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ if (locFlagMap[listenerID]) dirtyFlag = locFlagMap[listenerID]; - if (dirtyFlag != this.DIRTY_NONE) { + if (dirtyFlag !== this.DIRTY_NONE) { // Clear the dirty flag first, if `rootNode` is null, then set its dirty flag of scene graph priority locFlagMap[listenerID] = this.DIRTY_NONE; @@ -385,13 +385,13 @@ cc.eventManager = /** @lends cc.eventManager# */{ if(locInDispatch > 1) return; - if (event.getType() == cc.Event.TOUCH) { + if (event.getType() === cc.Event.TOUCH) { this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID); this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID); } else this._onUpdateListeners(cc.__getListenerID(event)); - cc.assert(locInDispatch == 1, cc._LogInfos.EventManager__updateListeners_2); + cc.assert(locInDispatch === 1, cc._LogInfos.EventManager__updateListeners_2); var locListenersMap = this._listenersMap, locPriorityDirtyFlagMap = this._priorityDirtyFlagMap; for (var selKey in locListenersMap) { if (locListenersMap[selKey].empty()) { @@ -418,14 +418,14 @@ cc.eventManager = /** @lends cc.eventManager# */{ var isClaimed = false, removedIdx; var getCode = event.getEventCode(), eventCode = cc.EventTouch.EventCode; - if (getCode == eventCode.BEGAN) { + if (getCode === eventCode.BEGAN) { if (listener.onTouchBegan) { isClaimed = listener.onTouchBegan(selTouch, event); if (isClaimed && listener._registered) listener._claimedTouches.push(selTouch); } } else if (listener._claimedTouches.length > 0 - && ((removedIdx = listener._claimedTouches.indexOf(selTouch)) != -1)) { + && ((removedIdx = listener._claimedTouches.indexOf(selTouch)) !== -1)) { isClaimed = true; if(getCode === eventCode.MOVED && listener.onTouchMoved){ listener.onTouchMoved(selTouch, event); @@ -464,7 +464,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ var allAtOnceListeners = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID); // If there aren't any touch listeners, return directly. - if (null == oneByOneListeners && null == allAtOnceListeners) + if (null === oneByOneListeners && null === allAtOnceListeners) return; var originalTouches = event.getTouches(), mutableTouches = cc.copyArray(originalTouches); @@ -500,13 +500,13 @@ cc.eventManager = /** @lends cc.eventManager# */{ var eventCode = cc.EventTouch.EventCode, event = callbackParams.event, touches = callbackParams.touches, getCode = event.getEventCode(); event._setCurrentTarget(listener._node); - if(getCode == eventCode.BEGAN && listener.onTouchesBegan) + if(getCode === eventCode.BEGAN && listener.onTouchesBegan) listener.onTouchesBegan(touches, event); - else if(getCode == eventCode.MOVED && listener.onTouchesMoved) + else if(getCode === eventCode.MOVED && listener.onTouchesMoved) listener.onTouchesMoved(touches, event); - else if(getCode == eventCode.ENDED && listener.onTouchesEnded) + else if(getCode === eventCode.ENDED && listener.onTouchesEnded) listener.onTouchesEnded(touches, event); - else if(getCode == eventCode.CANCELLED && listener.onTouchesCancelled) + else if(getCode === eventCode.CANCELLED && listener.onTouchesCancelled) listener.onTouchesCancelled(touches, event); // If the event was stopped, return directly. @@ -667,7 +667,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ return; if (cc.isNumber(nodeOrPriority)) { - if (nodeOrPriority == 0) { + if (nodeOrPriority === 0) { cc.log(cc._LogInfos.eventManager_addListener); return; } @@ -735,7 +735,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ var locToAddedListeners = this._toAddedListeners; for (var i = 0, len = locToAddedListeners.length; i < len; i++) { var selListener = locToAddedListeners[i]; - if (selListener == listener) { + if (selListener === listener) { cc.arrayRemoveObject(locToAddedListeners, selListener); selListener._setRegistered(false); break; @@ -750,14 +750,14 @@ cc.eventManager = /** @lends cc.eventManager# */{ for (var i = 0, len = listeners.length; i < len; i++) { var selListener = listeners[i]; - if (selListener == listener) { + if (selListener === listener) { selListener._setRegistered(false); if (selListener._getSceneGraphPriority() != null){ this._dissociateNodeAndEventListener(selListener._getSceneGraphPriority(), selListener); selListener._setSceneGraphPriority(null); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes. } - if (this._inDispatch == 0) + if (this._inDispatch === 0) cc.arrayRemoveObject(listeners, selListener); return true; } @@ -793,7 +793,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ var locToAddedListeners = _t._toAddedListeners; for (i = 0; i < locToAddedListeners.length; ) { var listener = locToAddedListeners[i]; - if (listener._getSceneGraphPriority() == listenerType) { + if (listener._getSceneGraphPriority() === listenerType) { listener._setSceneGraphPriority(null); // Ensure no dangling ptr to the target node. listener._setRegistered(false); locToAddedListeners.splice(i, 1); @@ -807,15 +807,15 @@ cc.eventManager = /** @lends cc.eventManager# */{ _t.removeListeners(locChildren[i], true); } } else { - if (listenerType == cc.EventListener.TOUCH_ONE_BY_ONE) + if (listenerType === cc.EventListener.TOUCH_ONE_BY_ONE) _t._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID); - else if (listenerType == cc.EventListener.TOUCH_ALL_AT_ONCE) + else if (listenerType === cc.EventListener.TOUCH_ALL_AT_ONCE) _t._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID); - else if (listenerType == cc.EventListener.MOUSE) + else if (listenerType === cc.EventListener.MOUSE) _t._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID); - else if (listenerType == cc.EventListener.ACCELERATION) + else if (listenerType === cc.EventListener.ACCELERATION) _t._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID); - else if (listenerType == cc.EventListener.KEYBOARD) + else if (listenerType === cc.EventListener.KEYBOARD) _t._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID); else cc.log(cc._LogInfos.eventManager_removeListeners); @@ -856,7 +856,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ var fixedPriorityListeners = selListeners.getFixedPriorityListeners(); if (fixedPriorityListeners) { var found = fixedPriorityListeners.indexOf(listener); - if (found != -1) { + if (found !== -1) { if(listener._getSceneGraphPriority() != null) cc.log(cc._LogInfos.eventManager_setPriority); if (listener._getFixedPriority() !== fixedPriority) { @@ -897,7 +897,7 @@ cc.eventManager = /** @lends cc.eventManager# */{ this._inDispatch++; if(!event || !event.getType) throw "event is undefined"; - if (event.getType() == cc.Event.TOUCH) { + if (event.getType() === cc.Event.TOUCH) { this._dispatchTouchEvent(event); this._inDispatch--; return; @@ -972,7 +972,7 @@ cc.EventHelper.prototype = { if ( listeners[ type ] !== undefined ) { for(var i = 0, len = listeners.length; i < len ; i++){ var selListener = listeners[i]; - if(selListener.callback == listener && selListener.eventTarget == target) + if(selListener.callback === listener && selListener.eventTarget === target) return true; } } @@ -989,7 +989,7 @@ cc.EventHelper.prototype = { if ( listenerArray !== undefined ) { for(var i = 0; i < listenerArray.length ; ){ var selListener = listenerArray[i]; - if(selListener.eventTarget == target) + if(selListener.eventTarget === target) listenerArray.splice( i, 1 ); else i++ diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 106e92bc19..fb4855e6a5 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -300,17 +300,17 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ this._shadowEnabled = true; var locShadowOffset = this._shadowOffset; - if (locShadowOffset && (locShadowOffset.x != shadowOffsetX) || (locShadowOffset._y != shadowOffsetY)) { + if (locShadowOffset && (locShadowOffset.x !== shadowOffsetX) || (locShadowOffset._y !== shadowOffsetY)) { locShadowOffset.x = shadowOffsetX; locShadowOffset.y = shadowOffsetY; } - if (this._shadowOpacity != shadowOpacity) { + if (this._shadowOpacity !== shadowOpacity) { this._shadowOpacity = shadowOpacity; } this._renderCmd._setColorsString(); - if (this._shadowBlur != shadowBlur) + if (this._shadowBlur !== shadowBlur) this._shadowBlur = shadowBlur; this._setUpdateTextureDirty(); }, @@ -339,7 +339,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (false === this._shadowEnabled) this._shadowEnabled = true; - if (this._shadowOffset.x != x) { + if (this._shadowOffset.x !== x) { this._shadowOffset.x = x; this._setUpdateTextureDirty(); } @@ -352,7 +352,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (false === this._shadowEnabled) this._shadowEnabled = true; - if (this._shadowOffset._y != y) { + if (this._shadowOffset._y !== y) { this._shadowOffset._y = y; this._setUpdateTextureDirty(); } @@ -365,7 +365,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (false === this._shadowEnabled) this._shadowEnabled = true; - if (this._shadowOffset.x != offset.x || this._shadowOffset.y != offset.y) { + if (this._shadowOffset.x !== offset.x || this._shadowOffset.y !== offset.y) { this._shadowOffset.x = offset.x; this._shadowOffset.y = offset.y; this._setUpdateTextureDirty(); @@ -379,7 +379,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (false === this._shadowEnabled) this._shadowEnabled = true; - if (this._shadowOpacity != shadowOpacity) { + if (this._shadowOpacity !== shadowOpacity) { this._shadowOpacity = shadowOpacity; this._renderCmd._setColorsString(); this._setUpdateTextureDirty(); @@ -393,7 +393,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ if (false === this._shadowEnabled) this._shadowEnabled = true; - if (this._shadowBlur != shadowBlur) { + if (this._shadowBlur !== shadowBlur) { this._shadowBlur = shadowBlur; this._setUpdateTextureDirty(); } @@ -477,7 +477,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ */ setFontFillColor: function (fillColor) { var locTextFillColor = this._textFillColor; - if (locTextFillColor.r != fillColor.r || locTextFillColor.g != fillColor.g || locTextFillColor.b != fillColor.b) { + if (locTextFillColor.r !== fillColor.r || locTextFillColor.g !== fillColor.g || locTextFillColor.b !== fillColor.b) { locTextFillColor.r = fillColor.r; locTextFillColor.g = fillColor.g; locTextFillColor.b = fillColor.b; @@ -584,7 +584,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ */ setString: function (text) { text = String(text); - if (this._originalText != text) { + if (this._originalText !== text) { this._originalText = text + ""; this._updateString(); @@ -617,7 +617,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} verticalAlignment */ setVerticalAlignment: function (verticalAlignment) { - if (verticalAlignment != this._vAlignment) { + if (verticalAlignment !== this._vAlignment) { this._vAlignment = verticalAlignment; // Force update @@ -638,7 +638,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ } else width = dim; - if (width != this._dimensions.width || height != this._dimensions.height) { + if (width !== this._dimensions.width || height !== this._dimensions.height) { this._dimensions.width = width; this._dimensions.height = height; this._updateString(); @@ -651,7 +651,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return this._dimensions.width; }, _setBoundingWidth: function (width) { - if (width != this._dimensions.width) { + if (width !== this._dimensions.width) { this._dimensions.width = width; this._updateString(); // Force update @@ -663,7 +663,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ return this._dimensions.height; }, _setBoundingHeight: function (height) { - if (height != this._dimensions.height) { + if (height !== this._dimensions.height) { this._dimensions.height = height; this._updateString(); // Force update @@ -689,7 +689,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ * @param {String} fontName */ setFontName: function (fontName) { - if (this._fontName && this._fontName != fontName) { + if (this._fontName && this._fontName !== fontName) { this._fontName = fontName; this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); // Force update @@ -747,7 +747,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ //For web only _setFontStyle: function(fontStyle){ - if (this._fontStyle != fontStyle) { + if (this._fontStyle !== fontStyle) { this._fontStyle = fontStyle; this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); this._setUpdateTextureDirty(); @@ -759,7 +759,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ }, _setFontWeight: function(fontWeight){ - if (this._fontWeight != fontWeight) { + if (this._fontWeight !== fontWeight) { this._fontWeight = fontWeight; this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight); this._setUpdateTextureDirty(); diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 276ef15313..d18507c02d 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -110,7 +110,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; locContext.font = this._fontStyleStr; this._updateTTF(); var width = locContentSize.width, height = locContentSize.height; - var flag = locLabelCanvas.width == width && locLabelCanvas.height == height; + var flag = locLabelCanvas.width === width && locLabelCanvas.height === height; locLabelCanvas.width = width; locLabelCanvas.height = height; if (flag) locContext.clearRect(0, 0, width, height); @@ -183,7 +183,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; locSize = cc.size(Math.ceil(locDimensionsWidth + locStrokeShadowOffsetX), Math.ceil(node._dimensions.height + locStrokeShadowOffsetY)); } } - if(node._getFontStyle() != "normal"){ //add width for 'italic' and 'oblique' + if(node._getFontStyle() !== "normal"){ //add width for 'italic' and 'oblique' locSize.width = Math.ceil(locSize.width + node._fontSize * 0.3); } node.setContentSize(locSize); @@ -204,10 +204,10 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var locContentSizeHeight = node._contentSize.height - locStrokeShadowOffsetY, locVAlignment = node._vAlignment, locHAlignment = node._hAlignment, locStrokeSize = node._strokeSize; - context.setTransform(1, 0, 0, 1, 0 + locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); + context.setTransform(1, 0, 0, 1, locStrokeShadowOffsetX * 0.5, locContentSizeHeight + locStrokeShadowOffsetY * 0.5); //this is fillText for canvas - if (context.font != this._fontStyleStr) + if (context.font !== this._fontStyleStr) context.font = this._fontStyleStr; context.fillStyle = this._fillColorStr; diff --git a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js index cfa224148d..2fb954e115 100644 --- a/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +++ b/cocos2d/core/layers/CCLayerCanvasRenderCmd.js @@ -129,7 +129,7 @@ }; proto._bakeForAddChild = function(child){ - if(child._parent == this._node && this._isBaked) + if(child._parent === this._node && this._isBaked) child._renderCmd._setCachedParent(this); }; diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index cf187cad09..2aaf3e6621 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -49,7 +49,7 @@ var ClassManager = { //now we have the content of the function, replace this._super //find this._super - while(str.indexOf('this._super')!= -1) + while(str.indexOf('this._super') !== -1) { var sp = str.indexOf('this._super'); //find the first '(' from this._super) @@ -186,7 +186,7 @@ ClassManager.compileSuper.ClassManager = ClassManager; if (this.__getters__ && this.__getters__[name]) { propertyName = this.__getters__[name]; for (var i in this.__setters__) { - if (this.__setters__[i] == propertyName) { + if (this.__setters__[i] === propertyName) { setter = i; break; } @@ -196,7 +196,7 @@ ClassManager.compileSuper.ClassManager = ClassManager; if (this.__setters__ && this.__setters__[name]) { propertyName = this.__setters__[name]; for (var i in this.__getters__) { - if (this.__getters__[i] == propertyName) { + if (this.__getters__[i] === propertyName) { getter = i; break; } @@ -316,7 +316,7 @@ cc.clone = function (obj) { for (var key in obj) { var copy = obj[key]; // Beware that typeof null == "object" ! - if (((typeof copy) == "object") && copy && + if (((typeof copy) === "object") && copy && !(copy instanceof cc.Node) && !(copy instanceof HTMLElement)) { newObj[key] = cc.clone(copy); } else { diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js index 9edef5f478..2db723b4f9 100644 --- a/cocos2d/core/platform/CCCommon.js +++ b/cocos2d/core/platform/CCCommon.js @@ -227,21 +227,21 @@ cc.FMT_UNKNOWN = 5; */ cc.getImageFormatByData = function (imgData) { // if it is a png file buffer. - if (imgData.length > 8 && imgData[0] == 0x89 - && imgData[1] == 0x50 - && imgData[2] == 0x4E - && imgData[3] == 0x47 - && imgData[4] == 0x0D - && imgData[5] == 0x0A - && imgData[6] == 0x1A - && imgData[7] == 0x0A) { + if (imgData.length > 8 && imgData[0] === 0x89 + && imgData[1] === 0x50 + && imgData[2] === 0x4E + && imgData[3] === 0x47 + && imgData[4] === 0x0D + && imgData[5] === 0x0A + && imgData[6] === 0x1A + && imgData[7] === 0x0A) { return cc.FMT_PNG; } // if it is a tiff file buffer. - if (imgData.length > 2 && ((imgData[0] == 0x49 && imgData[1] == 0x49) - || (imgData[0] == 0x4d && imgData[1] == 0x4d) - || (imgData[0] == 0xff && imgData[1] == 0xd8))) { + if (imgData.length > 2 && ((imgData[0] === 0x49 && imgData[1] === 0x49) + || (imgData[0] === 0x4d && imgData[1] === 0x4d) + || (imgData[0] === 0xff && imgData[1] === 0xd8))) { return cc.FMT_TIFF; } return cc.FMT_UNKNOWN; diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 75826042ff..7dce4366ac 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -183,7 +183,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ _t._viewName = "Cocos2dHTML5"; var sys = cc.sys; - _t.enableRetina(sys.os == sys.OS_IOS || sys.os == sys.OS_OSX); + _t.enableRetina(sys.os === sys.OS_IOS || sys.os === sys.OS_OSX); cc.visibleRect && cc.visibleRect.init(_t._visibleRect); // Setup system default resolution policies @@ -210,7 +210,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ // Check frame size changed or not var prevFrameW = view._frameSize.width, prevFrameH = view._frameSize.height; view._initFrameSize(); - if (view._frameSize.width == prevFrameW && view._frameSize.height == prevFrameH) + if (view._frameSize.width === prevFrameW && view._frameSize.height === prevFrameH) return; // Frame size changed, do resize works @@ -418,7 +418,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ * @return {Boolean} */ isOpenGLReady: function () { - return (this._hDC != null && this._hRC != null); + return (this._hDC !== null && this._hRC !== null); }, /* @@ -591,7 +591,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ var result = policy.apply(this, this._designResolutionSize); - if(result.scale && result.scale.length == 2){ + if(result.scale && result.scale.length === 2){ this._scaleX = result.scale[0]; this._scaleY = result.scale[1]; } @@ -621,7 +621,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{ cc.winSize.width = director._winSizeInPoints.width; cc.winSize.height = director._winSizeInPoints.height; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + if (cc._renderType === cc._RENDER_TYPE_WEBGL) { // reset director's member variables to fit visible rect director._createStatsLabel(); director.setGLDefaultValues(); @@ -821,7 +821,7 @@ cc.ContainerStrategy = cc.Class.extend(/** @lends cc.ContainerStrategy# */{ _setupContainer: function (view, w, h) { var frame = view._frame; - if (cc.view._autoFullScreen && cc.sys.isMobile && frame == document.documentElement) { + if (cc.view._autoFullScreen && cc.sys.isMobile && frame === document.documentElement) { // Automatically full screen when user touches on mobile version cc.screen.autoFullScreen(frame); } @@ -897,7 +897,7 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{ contentW, contentH); // Translate the content - if (cc._renderType == cc._RENDER_TYPE_CANVAS){ + if (cc._renderType === cc._RENDER_TYPE_CANVAS){ //TODO: modify something for setTransform //cc._renderContext.translate(viewport.x, viewport.y + contentH); } diff --git a/cocos2d/core/platform/CCInputExtension.js b/cocos2d/core/platform/CCInputExtension.js index 3c13edfcd0..470864db02 100644 --- a/cocos2d/core/platform/CCInputExtension.js +++ b/cocos2d/core/platform/CCInputExtension.js @@ -76,12 +76,12 @@ _p._registerAccelerometerEvent = function(){ _t._accelDeviceEvent = w.DeviceMotionEvent || w.DeviceOrientationEvent; //TODO fix DeviceMotionEvent bug on QQ Browser version 4.1 and below. - if (cc.sys.browserType == cc.sys.BROWSER_TYPE_MOBILE_QQ) + if (cc.sys.browserType === cc.sys.BROWSER_TYPE_MOBILE_QQ) _t._accelDeviceEvent = window.DeviceOrientationEvent; - var _deviceEventType = (_t._accelDeviceEvent == w.DeviceMotionEvent) ? "devicemotion" : "deviceorientation"; + var _deviceEventType = (_t._accelDeviceEvent === w.DeviceMotionEvent) ? "devicemotion" : "deviceorientation"; var ua = navigator.userAgent; - if (/Android/.test(ua) || (/Adr/.test(ua) && cc.sys.browserType == cc.BROWSER_TYPE_UC)) { + if (/Android/.test(ua) || (/Adr/.test(ua) && cc.sys.browserType === cc.BROWSER_TYPE_UC)) { _t._minus = -1; } @@ -97,7 +97,7 @@ _p.didAccelerate = function (eventData) { var x, y, z; - if (_t._accelDeviceEvent == window.DeviceMotionEvent) { + if (_t._accelDeviceEvent === window.DeviceMotionEvent) { var eventAcceleration = eventData["accelerationIncludingGravity"]; x = _t._accelMinus * eventAcceleration.x * 0.1; y = _t._accelMinus * eventAcceleration.y * 0.1; diff --git a/cocos2d/core/platform/CCInputManager.js b/cocos2d/core/platform/CCInputManager.js index 1c7a7edeaa..545d0b0d90 100644 --- a/cocos2d/core/platform/CCInputManager.js +++ b/cocos2d/core/platform/CCInputManager.js @@ -118,7 +118,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ if(index == null){ var unusedIndex = this._getUnUsedIndex(); - if (unusedIndex == -1) { + if (unusedIndex === -1) { cc.log(cc._LogInfos.inputManager_handleTouchesBegin, unusedIndex); continue; } @@ -266,7 +266,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ var locPreTouchPool = this._preTouchPool; var id = touch.getID(); for (var i = locPreTouchPool.length - 1; i >= 0; i--) { - if (locPreTouchPool[i].getID() == id) { + if (locPreTouchPool[i].getID() === id) { preTouch = locPreTouchPool[i]; break; } @@ -285,7 +285,7 @@ cc.inputManager = /** @lends cc.inputManager# */{ var locPreTouchPool = this._preTouchPool; var id = touch.getID(); for (var i = locPreTouchPool.length - 1; i >= 0; i--) { - if (locPreTouchPool[i].getID() == id) { + if (locPreTouchPool[i].getID() === id) { locPreTouchPool[i] = touch; find = true; break; diff --git a/cocos2d/core/platform/CCLoaders.js b/cocos2d/core/platform/CCLoaders.js index 44aefd9f00..541e3b91c5 100644 --- a/cocos2d/core/platform/CCLoaders.js +++ b/cocos2d/core/platform/CCLoaders.js @@ -96,7 +96,7 @@ cc._fontLoader = { var src = srcs[i]; type = path.extname(src).toLowerCase(); fontStr += "url('" + srcs[i] + "') format('" + TYPE[type] + "')"; - fontStr += (i == li - 1) ? ";" : ","; + fontStr += (i === li - 1) ? ";" : ","; } }else{ fontStr += "url('" + srcs + "') format('" + TYPE[type] + "');"; diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index 2f94ced6cf..cabb8f2c30 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -460,7 +460,7 @@ cc.MIRRORED_REPEAT = 0x8370; * @function */ cc.checkGLErrorDebug = function () { - if (cc.renderMode == cc._RENDER_TYPE_WEBGL) { + if (cc.renderMode === cc._RENDER_TYPE_WEBGL) { var _error = cc._renderContext.getError(); if (_error) { cc.log(cc._LogInfos.checkGLErrorDebug, _error); @@ -785,7 +785,7 @@ cc.arrayVerifyType = function (arr, type) { */ cc.arrayRemoveObject = function (arr, delObj) { for (var i = 0, l = arr.length; i < l; i++) { - if (arr[i] == delObj) { + if (arr[i] === delObj) { arr.splice(i, 1); break; } diff --git a/cocos2d/core/platform/CCSAXParser.js b/cocos2d/core/platform/CCSAXParser.js index 94ec96589d..d0088e8f26 100644 --- a/cocos2d/core/platform/CCSAXParser.js +++ b/cocos2d/core/platform/CCSAXParser.js @@ -88,14 +88,14 @@ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ parse : function (xmlTxt) { var xmlDoc = this._parseXML(xmlTxt); var plist = xmlDoc.documentElement; - if (plist.tagName != 'plist') + if (plist.tagName !== 'plist') throw "Not a plist file!"; // Get first real node var node = null; for (var i = 0, len = plist.childNodes.length; i < len; i++) { node = plist.childNodes[i]; - if (node.nodeType == 1) + if (node.nodeType === 1) break; } xmlDoc = null; @@ -104,12 +104,12 @@ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ _parseNode: function (node) { var data = null, tagName = node.tagName; - if(tagName == "dict"){ + if(tagName === "dict"){ data = this._parseDict(node); - }else if(tagName == "array"){ + }else if(tagName === "array"){ data = this._parseArray(node); - }else if(tagName == "string"){ - if (node.childNodes.length == 1) + }else if(tagName === "string"){ + if (node.childNodes.length === 1) data = node.firstChild.nodeValue; else { //handle Firefox's 4KB nodeValue limit @@ -117,13 +117,13 @@ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ for (var i = 0; i < node.childNodes.length; i++) data += node.childNodes[i].nodeValue; } - }else if(tagName == "false"){ + }else if(tagName === "false"){ data = false; - }else if(tagName == "true"){ + }else if(tagName === "true"){ data = true; - }else if(tagName == "real"){ + }else if(tagName === "real"){ data = parseFloat(node.firstChild.nodeValue); - }else if(tagName == "integer"){ + }else if(tagName === "integer"){ data = parseInt(node.firstChild.nodeValue, 10); } return data; @@ -133,7 +133,7 @@ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ var data = []; for (var i = 0, len = node.childNodes.length; i < len; i++) { var child = node.childNodes[i]; - if (child.nodeType != 1) + if (child.nodeType !== 1) continue; data.push(this._parseNode(child)); } @@ -145,11 +145,11 @@ cc.PlistParser = cc.SAXParser.extend(/** @lends cc.plistParser# */{ var key = null; for (var i = 0, len = node.childNodes.length; i < len; i++) { var child = node.childNodes[i]; - if (child.nodeType != 1) + if (child.nodeType !== 1) continue; // Grab the key, next noe should be the value - if (child.tagName == 'key') + if (child.tagName === 'key') key = child.firstChild.nodeValue; else data[key] = this._parseNode(child); // Parse the value node diff --git a/cocos2d/core/platform/miniFramework.js b/cocos2d/core/platform/miniFramework.js index 9b4d3e05bd..048a2db325 100644 --- a/cocos2d/core/platform/miniFramework.js +++ b/cocos2d/core/platform/miniFramework.js @@ -33,7 +33,7 @@ */ cc.$ = function (x) { /** @lends cc.$# */ - var parent = (this == cc) ? document : this; + var parent = (this === cc) ? document : this; var el = (x instanceof HTMLElement) ? x : parent.querySelector(x); diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js index 23adb0a203..d156393e26 100644 --- a/cocos2d/core/sprites/CCAnimationCache.js +++ b/cocos2d/core/sprites/CCAnimationCache.js @@ -156,7 +156,7 @@ cc.animationCache = /** @lends cc.animationCache# */{ if (frames.length === 0) { cc.log(cc._LogInfos.animationCache__parseVersion1_3, key); continue; - } else if (frames.length != frameNames.length) { + } else if (frames.length !== frameNames.length) { cc.log(cc._LogInfos.animationCache__parseVersion1_4, key); } animation = new cc.Animation(frames, delay, 1); diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 7c891aeb7d..48acbb4fa6 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -427,7 +427,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param {Boolean} flippedX true if the sprite should be flipped horizontally, false otherwise. */ setFlippedX:function (flippedX) { - if (this._flippedX != flippedX) { + if (this._flippedX !== flippedX) { this._flippedX = flippedX; this.setTextureRect(this._rect, this._rectRotated, this._contentSize); this.setNodeDirty(true); @@ -439,7 +439,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ * @param {Boolean} flippedY true if the sprite should be flipped vertically, false otherwise. */ setFlippedY:function (flippedY) { - if (this._flippedY != flippedY) { + if (this._flippedY !== flippedY) { this._flippedY = flippedY; this.setTextureRect(this._rect, this._rectRotated, this._contentSize); this.setNodeDirty(true); @@ -534,7 +534,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if (!this._reorderChildDirty) { this._reorderChildDirty = true; var pNode = this._parent; - while (pNode && pNode != this._batchNode) { + while (pNode && pNode !== this._batchNode) { pNode._setReorderChildDirtyRecursively(); pNode = pNode.parent; } @@ -684,7 +684,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ */ initWithTexture: function (texture, rect, rotated, counterclockwise) { var _t = this; - cc.assert(arguments.length != 0, cc._LogInfos.CCSpriteBatchNode_initWithTexture); + cc.assert(arguments.length !== 0, cc._LogInfos.CCSpriteBatchNode_initWithTexture); rotated = rotated || false; texture = this._renderCmd._handleTextureForRotatedTexture(texture, rect, rotated, counterclockwise); @@ -838,7 +838,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ newFrame.addEventListener("load", function (sender) { _t._textureLoaded = true; var locNewTexture = sender.getTexture(); - if (locNewTexture != _t._texture) + if (locNewTexture !== _t._texture) _t.texture = locNewTexture; _t.setTextureRect(sender.getRect(), sender.isRotated(), sender.getOriginalSize()); _t.dispatchEvent("load"); @@ -846,7 +846,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }, _t); }else{ // update texture before updating texture rect - if (pNewTexture != _t._texture) + if (pNewTexture !== _t._texture) _t.texture = pNewTexture; _t.setTextureRect(newFrame.getRect(), newFrame.isRotated(), newFrame.getOriginalSize()); } diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 12438e6048..a67c4cac19 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -217,7 +217,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ } } // ignore self (batch node) - if (!pobParent == this) { + if (!pobParent === this) { pobParent.atlasIndex = index; index++; } @@ -239,7 +239,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ highestAtlasIndexInChild: function (sprite) { var children = sprite.children; - if (!children || children.length == 0) + if (!children || children.length === 0) return sprite.atlasIndex; else return this.highestAtlasIndexInChild(children[children.length - 1]); @@ -252,7 +252,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ */ lowestAtlasIndexInChild: function (sprite) { var children = sprite.children; - if (!children || children.length == 0) + if (!children || children.length === 0) return sprite.atlasIndex; else return this.lowestAtlasIndexInChild(children[children.length - 1]); @@ -270,21 +270,21 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ var childIndex = brothers.indexOf(sprite); // ignore parent Z if parent is spriteSheet - var ignoreParent = selParent == this; + var ignoreParent = selParent === this; var previous = null; if (childIndex > 0 && childIndex < cc.UINT_MAX) previous = brothers[childIndex - 1]; // first child of the sprite sheet if (ignoreParent) { - if (childIndex == 0) + if (childIndex === 0) return 0; return this.highestAtlasIndexInChild(previous) + 1; } // parent is a cc.Sprite, so, it must be taken into account // first child of an cc.Sprite ? - if (childIndex == 0) { + if (childIndex === 0) { // less than parent and brothers if (nZ < 0) return selParent.atlasIndex; @@ -514,7 +514,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ sprite.batchNode = null; var locDescendants = this._descendants; var index = locDescendants.indexOf(sprite); - if (index != -1) { + if (index !== -1) { locDescendants.splice(index, 1); // update all sprites beyond this one @@ -608,7 +608,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller while (j >= 0 && ( tempItem._localZOrder < tempChild._localZOrder || - ( tempItem._localZOrder == tempChild._localZOrder && tempItem.arrivalOrder < tempChild.arrivalOrder ))) { + ( tempItem._localZOrder === tempChild._localZOrder && tempItem.arrivalOrder < tempChild.arrivalOrder ))) { childrenArr[j + 1] = tempChild; j = j - 1; tempChild = childrenArr[j]; diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 8c371d0635..d61973d7e7 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -90,7 +90,7 @@ proto.checkAtlasCapacity = function(index){ // make needed room var locAtlas = this._textureAtlas; - while (index >= locAtlas.capacity || locAtlas.capacity == locAtlas.totalQuads) { + while (index >= locAtlas.capacity || locAtlas.capacity === locAtlas.totalQuads) { this.increaseAtlasCapacity(); } }; @@ -169,7 +169,7 @@ oldIndex = sprite.atlasIndex; sprite.atlasIndex = curIndex; sprite.arrivalOrder = 0; - if (oldIndex != curIndex) + if (oldIndex !== curIndex) this._swap(oldIndex, curIndex); curIndex++; } else { @@ -179,7 +179,7 @@ oldIndex = sprite.atlasIndex; sprite.atlasIndex = curIndex; sprite.arrivalOrder = 0; - if (oldIndex != curIndex) + if (oldIndex !== curIndex) this._swap(oldIndex, curIndex); curIndex++; needNewIndex = false; @@ -190,7 +190,7 @@ oldIndex = sprite.atlasIndex; sprite.atlasIndex = curIndex; sprite.arrivalOrder = 0; - if (oldIndex != curIndex) { + if (oldIndex !== curIndex) { this._swap(oldIndex, curIndex); } curIndex++; @@ -204,7 +204,7 @@ oldIndex = sprite.atlasIndex; sprite.atlasIndex = curIndex; sprite.arrivalOrder = 0; - if (oldIndex != curIndex) { + if (oldIndex !== curIndex) { this._swap(oldIndex, curIndex); } curIndex++; @@ -234,7 +234,7 @@ }; proto.setTextureAtlas = function(textureAtlas){ - if (textureAtlas != this._textureAtlas) { + if (textureAtlas !== this._textureAtlas) { this._textureAtlas = textureAtlas; } }; diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 51ae6f1524..4eb973c819 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -57,7 +57,7 @@ proto._setTexture = function (texture) { var node = this._node; - if (node._texture != texture) { + if (node._texture !== texture) { if (texture) { if(texture.getHtmlElementObj() instanceof HTMLImageElement) this._originalTexture = texture; @@ -75,7 +75,7 @@ proto.isFrameDisplayed = function (frame) { //TODO there maybe has a bug var node = this._node; - if (frame.getTexture() != node._texture) + if (frame.getTexture() !== node._texture) return false; return cc.rectEqualToRect(frame.getRect(), node._rect); }; @@ -141,7 +141,7 @@ if (node._texture) { image = node._texture._htmlElementObj; - if (node._texture._pattern != "") { + if (node._texture._pattern !== "") { wrapper.setFillStyle(context.createPattern(image, node._texture._pattern)); context.fillRect(locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); } else { @@ -221,7 +221,7 @@ this._colorized = true; if (locElement instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor - && this._originalTexture._htmlElementObj != locElement) + && this._originalTexture._htmlElementObj !== locElement) cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, displayedColor, locRect, locElement); else { locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, displayedColor, locRect); @@ -260,12 +260,12 @@ if (node.dirty) { // If it is not visible, or one of its ancestors is not visible, then do nothing: var locParent = node._parent; - if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { + if (!node._visible || ( locParent && locParent !== node._batchNode && locParent._shouldBeHidden)) { node._shouldBeHidden = true; } else { node._shouldBeHidden = false; - if (!locParent || locParent == node._batchNode) { + if (!locParent || locParent === node._batchNode) { node._transformToBatch = _t.getNodeToParentTransform(); } else { //cc.assert(_t._parent instanceof cc.Sprite, "Logic error in CCSprite. Parent must be a CCSprite"); @@ -314,7 +314,7 @@ //set the texture's color after the it loaded var locColor = locRenderCmd._displayedColor; - if (locColor.r != 255 || locColor.g != 255 || locColor.b != 255) + if (locColor.r !== 255 || locColor.g !== 255 || locColor.b !== 255) locRenderCmd._updateColor(); // by default use "Self Render". @@ -348,7 +348,7 @@ renderCanvas = renderCanvas || cc.newElement("canvas"); rect = rect || cc.rect(0, 0, image.width, image.height); var context = renderCanvas.getContext("2d"); - if (renderCanvas.width != rect.width || renderCanvas.height != rect.height) { + if (renderCanvas.width !== rect.width || renderCanvas.height !== rect.height) { renderCanvas.width = rect.width; renderCanvas.height = rect.height; } else { diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 56ca499e7c..b59154f894 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -236,7 +236,7 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ * @param {cc.Texture2D} texture */ setTexture:function (texture) { - if (this._texture != texture) { + if (this._texture !== texture) { var locLoaded = texture.isLoaded(); this._textureLoaded = locLoaded; this._texture = texture; diff --git a/cocos2d/core/sprites/CCSpriteFrameCache.js b/cocos2d/core/sprites/CCSpriteFrameCache.js index 9f4166a131..f6ebcf2c58 100644 --- a/cocos2d/core/sprites/CCSpriteFrameCache.js +++ b/cocos2d/core/sprites/CCSpriteFrameCache.js @@ -300,7 +300,7 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ if (spriteFrames[key]) { delete(spriteFrames[key]); for (var alias in aliases) {//remove alias - if(aliases[alias] == key) delete aliases[alias]; + if(aliases[alias] === key) delete aliases[alias]; } } } @@ -317,10 +317,10 @@ cc.spriteFrameCache = /** @lends cc.spriteFrameCache# */{ var self = this, spriteFrames = self._spriteFrames, aliases = self._spriteFramesAliases; for (var key in spriteFrames) { var frame = spriteFrames[key]; - if (frame && (frame.getTexture() == texture)) { + if (frame && (frame.getTexture() === texture)) { delete(spriteFrames[key]); for (var alias in aliases) {//remove alias - if(aliases[alias] == key) delete aliases[alias]; + if(aliases[alias] === key) delete aliases[alias]; } } } diff --git a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js index 56ac66f8b2..78a83f5736 100644 --- a/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js @@ -80,7 +80,7 @@ proto.isFrameDisplayed = function (frame) { var node = this._node; - return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() == node._texture.getName() + return (cc.rectEqualToRect(frame.getRect(), node._rect) && frame.getTexture().getName() === node._texture.getName() && cc.pointEqualToPoint(frame.getOffset(), node._unflippedOffsetPositionFromCenter)); }; @@ -251,7 +251,7 @@ // renders using Sprite Manager if (node._batchNode) { - if (node.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED) { + if (node.atlasIndex !== cc.Sprite.INDEX_NOT_INITIALIZED) { node.textureAtlas.updateQuad(locQuad, node.atlasIndex) } else { // no need to set it recursively @@ -287,12 +287,12 @@ var node = this._node; // If batchnode, then texture id should be the same if (node._batchNode) { - if(node._batchNode.texture != texture){ + if(node._batchNode.texture !== texture){ cc.log(cc._LogInfos.Sprite_setTexture); return; } }else{ - if(node._texture != texture){ + if(node._texture !== texture){ node._textureLoaded = texture ? texture._textureLoaded : false; node._texture = texture; this._updateBlendFunc(); @@ -313,7 +313,7 @@ if (this._dirty) { var locQuad = _t._quad, locParent = node._parent; // If it is not visible, or one of its ancestors is not visible, then do nothing: - if (!node._visible || ( locParent && locParent != node._batchNode && locParent._shouldBeHidden)) { + if (!node._visible || ( locParent && locParent !== node._batchNode && locParent._shouldBeHidden)) { locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0}; node._shouldBeHidden = true; } else { @@ -323,7 +323,7 @@ this._dirtyFlag = 0; } - if (!locParent || locParent == node._batchNode) { + if (!locParent || locParent === node._batchNode) { node._transformToBatch = _t.getNodeToParentTransform(); } else { node._transformToBatch = cc.affineTransformConcat(_t.getNodeToParentTransform(), locParent._transformToBatch); diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/support/CCPointExtension.js index cf74e24b79..9771087379 100644 --- a/cocos2d/core/support/CCPointExtension.js +++ b/cocos2d/core/support/CCPointExtension.js @@ -371,7 +371,7 @@ cc.pRotateByAngle = function (v, pivot, angle) { * @return {Boolean} */ cc.pLineIntersect = function (A, B, C, D, retP) { - if ((A.x == B.x && A.y == B.y) || (C.x == D.x && C.y == D.y)) { + if ((A.x === B.x && A.y === B.y) || (C.x === D.x && C.y === D.y)) { return false; } var BAx = B.x - A.x; @@ -386,8 +386,8 @@ cc.pLineIntersect = function (A, B, C, D, retP) { retP.x = DCx * ACy - DCy * ACx; retP.y = BAx * ACy - BAy * ACx; - if (denom == 0) { - if (retP.x == 0 || retP.y == 0) { + if (denom === 0) { + if (retP.x === 0 || retP.y === 0) { // Lines incident return true; } @@ -447,7 +447,7 @@ cc.pIntersectPoint = function (A, B, C, D) { */ cc.pSameAs = function (A, B) { if ((A != null) && (B != null)) { - return (A.x == B.x && A.y == B.y); + return (A.x === B.x && A.y === B.y); } return false; }; diff --git a/cocos2d/core/support/CCVertex.js b/cocos2d/core/support/CCVertex.js index c300506f7a..44b92f0d22 100644 --- a/cocos2d/core/support/CCVertex.js +++ b/cocos2d/core/support/CCVertex.js @@ -76,7 +76,7 @@ cc.vertexLineToPolygon = function (points, stroke, vertices, offset, nuPoints) { } // Validate vertexes - offset = (offset == 0) ? 0 : offset - 1; + offset = (offset === 0) ? 0 : offset - 1; for (i = offset; i < nuPointsMinus; i++) { idx = i * 2; var idx1 = idx + 2; @@ -117,7 +117,7 @@ cc.vertexLineIntersect = function (Ax, Ay, Bx, By, Cx, Cy, Dx, Dy) { var distAB, theCos, theSin, newX; // FAIL: Line undefined - if ((Ax == Bx && Ay == By) || (Cx == Dx && Cy == Dy)) + if ((Ax === Bx && Ay === By) || (Cx === Dx && Cy === Dy)) return {isSuccess:false, value:0}; // Translate system to make A the origin @@ -142,7 +142,7 @@ cc.vertexLineIntersect = function (Ax, Ay, Bx, By, Cx, Cy, Dx, Dy) { Dx = newX; // FAIL: Lines are parallel. - if (Cy == Dy) return {isSuccess:false, value:0}; + if (Cy === Dy) return {isSuccess:false, value:0}; // Discover the relative position of the intersection in the line AB var t = (Dx + (Cx - Dx) * Dy / (Dy - Cy)) / distAB; diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 6d3f8a3e53..dca144d060 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -408,7 +408,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { _backupElement: null, _isGray: false, _switchToGray: function(toGray){ - if(!this._textureLoaded || this._isGray == toGray) + if(!this._textureLoaded || this._isGray === toGray) return; this._isGray = toGray; if(this._isGray){ @@ -417,7 +417,7 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { this._grayElementObj = cc.Texture2D._generateGrayTexture(this._htmlElementObj); this._htmlElementObj = this._grayElementObj; } else { - if(this._backupElement != null) + if(this._backupElement !== null) this._htmlElementObj = this._backupElement; } } diff --git a/cocos2d/core/textures/CCTextureAtlas.js b/cocos2d/core/textures/CCTextureAtlas.js index 4bda9fb0d2..6de91ca14f 100644 --- a/cocos2d/core/textures/CCTextureAtlas.js +++ b/cocos2d/core/textures/CCTextureAtlas.js @@ -461,7 +461,7 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ //WebGL only * @return {Boolean} */ resizeCapacity: function (newCapacity) { - if (newCapacity == this._capacity) + if (newCapacity === this._capacity) return true; var quadSize = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT; @@ -471,7 +471,7 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ //WebGL only this._capacity = 0 | newCapacity; var i, capacity = this._capacity, locTotalQuads = this._totalQuads; - if (this._quads == null) { + if (this._quads === null) { this._quads = []; this._quadsArrayBuffer = new ArrayBuffer(quadSize * capacity); this._quadsReader = new Uint8Array(this._quadsArrayBuffer); @@ -506,7 +506,7 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ //WebGL only } } - if (this._indices == null) { + if (this._indices === null) { this._indices = new Uint16Array(capacity * 6); } else { if (capacity > oldCapacity) { @@ -552,7 +552,7 @@ cc.TextureAtlas = cc.Class.extend(/** @lends cc.TextureAtlas# */{ //WebGL only cc.assert((newIndex + amount) <= this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_2); cc.assert(oldIndex < this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_3); - if (oldIndex == newIndex) + if (oldIndex === newIndex) return; } diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index ad24eea7d9..8068eb485b 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -121,7 +121,7 @@ cc.textureCache = /** @lends cc.textureCache# */{ */ getKeyByTexture: function (texture) { for (var key in this._textures) { - if (this._textures[key] == texture) { + if (this._textures[key] === texture) { return key; } } @@ -197,7 +197,7 @@ cc.textureCache = /** @lends cc.textureCache# */{ var locTextures = this._textures; for (var selKey in locTextures) { - if (locTextures[selKey] == texture) { + if (locTextures[selKey] === texture) { locTextures[selKey].releaseTexture(); delete(locTextures[selKey]); } @@ -247,7 +247,6 @@ cc.textureCache = /** @lends cc.textureCache# */{ * @return {cc.Texture2D} */ addUIImage: function (image, key) { - cc.assert(image, cc._LogInfos.textureCache_addUIImage_2); if (key) { @@ -258,7 +257,7 @@ cc.textureCache = /** @lends cc.textureCache# */{ // prevents overloading the autorelease pool var texture = new cc.Texture2D(); texture.initWithImage(image); - if ((key != null) && (texture != null)) + if (key != null) this._textures[key] = texture; else cc.log(cc._LogInfos.textureCache_addUIImage); diff --git a/cocos2d/core/textures/TexturesWebGL.js b/cocos2d/core/textures/TexturesWebGL.js index b1667ed971..c08cd2c49d 100644 --- a/cocos2d/core/textures/TexturesWebGL.js +++ b/cocos2d/core/textures/TexturesWebGL.js @@ -571,8 +571,8 @@ cc._tmp.WebGLTexture2D = function () { if(magFilter !== undefined) texParams = {minFilter: texParams, magFilter: magFilter, wrapS: wrapS, wrapT: wrapT}; - cc.assert((_t._pixelsWide == cc.NextPOT(_t._pixelsWide) && _t._pixelsHigh == cc.NextPOT(_t._pixelsHigh)) || - (texParams.wrapS == gl.CLAMP_TO_EDGE && texParams.wrapT == gl.CLAMP_TO_EDGE), + cc.assert((_t._pixelsWide === cc.NextPOT(_t._pixelsWide) && _t._pixelsHigh === cc.NextPOT(_t._pixelsHigh)) || + (texParams.wrapS === gl.CLAMP_TO_EDGE && texParams.wrapT === gl.CLAMP_TO_EDGE), "WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures"); cc.glBindTexture2D(_t); @@ -620,7 +620,7 @@ cc._tmp.WebGLTexture2D = function () { */ generateMipmap: function () { var _t = this; - cc.assert(_t._pixelsWide == cc.NextPOT(_t._pixelsWide) && _t._pixelsHigh == cc.NextPOT(_t._pixelsHigh), "Mimpap texture only works in POT textures"); + cc.assert(_t._pixelsWide === cc.NextPOT(_t._pixelsWide) && _t._pixelsHigh === cc.NextPOT(_t._pixelsHigh), "Mimpap texture only works in POT textures"); cc.glBindTexture2D(_t); cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D); @@ -672,7 +672,7 @@ cc._tmp.WebGLTexture2D = function () { // Repack the pixel data into the right format var length = width * height; - if (pixelFormat == tex2d.PIXEL_FORMAT_RGB565) { + if (pixelFormat === tex2d.PIXEL_FORMAT_RGB565) { if (hasAlpha) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB" tempData = new Uint16Array(width * height); @@ -696,7 +696,7 @@ cc._tmp.WebGLTexture2D = function () { (((inPixel8[i] & 0xFF) >> 3) << 0); // B } } - } else if (pixelFormat == tex2d.PIXEL_FORMAT_RGBA4444) { + } else if (pixelFormat === tex2d.PIXEL_FORMAT_RGBA4444) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" tempData = new Uint16Array(width * height); inPixel32 = uiImage.getData(); @@ -708,7 +708,7 @@ cc._tmp.WebGLTexture2D = function () { ((((inPixel32[i] >> 16) & 0xFF) >> 4) << 4) | // B ((((inPixel32[i] >> 24) & 0xFF) >> 4) << 0); // A } - } else if (pixelFormat == tex2d.PIXEL_FORMAT_RGB5A1) { + } else if (pixelFormat === tex2d.PIXEL_FORMAT_RGB5A1) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA" tempData = new Uint16Array(width * height); inPixel32 = uiImage.getData(); @@ -720,7 +720,7 @@ cc._tmp.WebGLTexture2D = function () { ((((inPixel32[i] >> 16) & 0xFF) >> 3) << 1) | // B ((((inPixel32[i] >> 24) & 0xFF) >> 7) << 0); // A } - } else if (pixelFormat == tex2d.PIXEL_FORMAT_A8) { + } else if (pixelFormat === tex2d.PIXEL_FORMAT_A8) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "AAAAAAAA" tempData = new Uint8Array(width * height); inPixel32 = uiImage.getData(); @@ -730,7 +730,7 @@ cc._tmp.WebGLTexture2D = function () { } } - if (hasAlpha && pixelFormat == tex2d.PIXEL_FORMAT_RGB888) { + if (hasAlpha && pixelFormat === tex2d.PIXEL_FORMAT_RGB888) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB" inPixel32 = uiImage.getData(); tempData = new Uint8Array(width * height * 3); diff --git a/cocos2d/core/utils/BinaryLoader.js b/cocos2d/core/utils/BinaryLoader.js index 9478bd06ae..013c3dee6e 100644 --- a/cocos2d/core/utils/BinaryLoader.js +++ b/cocos2d/core/utils/BinaryLoader.js @@ -41,7 +41,7 @@ cc.loader.loadBinary = function (url, cb) { // IE-specific logic here xhr.setRequestHeader("Accept-Charset", "x-user-defined"); xhr.onreadystatechange = function () { - if (xhr.readyState == 4 && xhr.status == 200) { + if (xhr.readyState === 4 && xhr.status === 200) { var fileContents = cc._convertResponseBodyToText(xhr["responseBody"]); cb(null, self._str2Uint8Array(fileContents)); } else cb(errInfo); @@ -49,7 +49,7 @@ cc.loader.loadBinary = function (url, cb) { } else { if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=x-user-defined"); xhr.onload = function () { - xhr.readyState == 4 && xhr.status == 200 ? cb(null, self._str2Uint8Array(xhr.responseText)) : cb(errInfo); + xhr.readyState === 4 && xhr.status === 200 ? cb(null, self._str2Uint8Array(xhr.responseText)) : cb(errInfo); }; } xhr.send(null); @@ -81,7 +81,7 @@ cc.loader.loadBinarySync = function (url) { if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { req.setRequestHeader("Accept-Charset", "x-user-defined"); req.send(null); - if (req.status != 200) { + if (req.status !== 200) { cc.log(errInfo); return null; } @@ -94,7 +94,7 @@ cc.loader.loadBinarySync = function (url) { if (req.overrideMimeType) req.overrideMimeType('text\/plain; charset=x-user-defined'); req.send(null); - if (req.status != 200) { + if (req.status !== 200) { cc.log(errInfo); return null; } diff --git a/cocos2d/effects/CCGrabber.js b/cocos2d/effects/CCGrabber.js index 96f78b2fa5..427ffb57e5 100644 --- a/cocos2d/effects/CCGrabber.js +++ b/cocos2d/effects/CCGrabber.js @@ -62,7 +62,7 @@ cc.Grabber = cc.Class.extend({ // check if it worked (probably worth doing :) ) var status = locGL.checkFramebufferStatus(locGL.FRAMEBUFFER); - if (status != locGL.FRAMEBUFFER_COMPLETE) + if (status !== locGL.FRAMEBUFFER_COMPLETE) cc.log("Frame Grabber: could not attach texture to frmaebuffer"); locGL.bindFramebuffer(locGL.FRAMEBUFFER, this._oldFBO); }, diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index a7276fe7c4..d324338c81 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -150,7 +150,7 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ * @param {Boolean} flipped */ setTextureFlipped:function (flipped) { - if (this._isTextureFlipped != flipped) { + if (this._isTextureFlipped !== flipped) { this._isTextureFlipped = flipped; this.calculateVertexPoints(); } diff --git a/cocos2d/kazmath/mat4.js b/cocos2d/kazmath/mat4.js index 45b9a1d59b..33882b7a98 100644 --- a/cocos2d/kazmath/mat4.js +++ b/cocos2d/kazmath/mat4.js @@ -133,7 +133,7 @@ } } ++(ipiv[icol]); - if (irow != icol) { + if (irow !== icol) { for (l = 0; l < n; l++) a.swap(irow, l, icol, l); for (l = 0; l < m; l++) @@ -153,7 +153,7 @@ b.set(icol, l, b.get(icol, l) * pivinv); for (ll = 0; ll < n; ll++) { - if (ll != icol) { + if (ll !== icol) { dum = a.get(ll, icol); a.set(ll, icol, 0.0); for (l = 0; l < n; l++) @@ -168,7 +168,7 @@ // ble the solution in view of the column interchanges. We do this by interchanging pairs of // columns in the reverse order that the permutation was built up. for (l = n - 1; l >= 0; l--) { - if (indxr[l] != indxc[l]) { + if (indxr[l] !== indxc[l]) { for (k = 0; k < n; k++) a.swap(k, indxr[l], k, indxc[l]); } @@ -378,7 +378,7 @@ * @returns {cc.math.Matrix4} */ proto.assignFrom = function(mat4) { - if (this == mat4) { + if (this === mat4) { cc.log("cc.mat.Matrix4.assignFrom(): mat4 equals current matrix"); return this; } @@ -711,7 +711,7 @@ var deltaZ = zFar - zNear; var s = Math.sin(r); - if (deltaZ == 0 || s == 0 || aspect == 0) + if (deltaZ === 0 || s === 0 || aspect === 0) return null; //cos(r) / sin(r) = cot(r) @@ -739,7 +739,7 @@ var r = cc.degreesToRadians(fovY / 2), deltaZ = zFar - zNear; var s = Math.sin(r); - if (deltaZ == 0 || s == 0 || aspect == 0) + if (deltaZ === 0 || s === 0 || aspect === 0) return null; //cos(r) / sin(r) = cot(r) diff --git a/cocos2d/kazmath/quaternion.js b/cocos2d/kazmath/quaternion.js index 13e9d67ef6..ac926ebec2 100644 --- a/cocos2d/kazmath/quaternion.js +++ b/cocos2d/kazmath/quaternion.js @@ -115,7 +115,7 @@ * @returns {boolean} */ proto.isIdentity = function(){ //=cc.kmQuaternionIsIdentity - return (this.x == 0.0 && this.y == 0.0 && this.z == 0.0 && this.w == 1.0); + return (this.x === 0.0 && this.y === 0.0 && this.z === 0.0 && this.w === 1.0); }; /** diff --git a/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js index fed5c47dbd..2be997851d 100644 --- a/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js @@ -54,7 +54,7 @@ var fontChar = node.getChildByTag(i); if (!fontChar) { fontChar = new cc.Sprite(); - if (c == 32) { + if (c === 32) { fontChar.init(); fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); } else @@ -62,7 +62,7 @@ cc.Node.prototype.addChild.call(node, fontChar, 0, i); } else { - if (c == 32) { + if (c === 32) { fontChar.init(); fontChar.setTextureRect(cc.rect(0, 0, 10, 10), false, cc.size(0, 0)); } else { diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 0b5169d090..6ac229c8b5 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -305,7 +305,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var i, locCfg = self._config, locKerningDict = locCfg.kerningDict, locCommonH = locCfg.commonHeight, locFontDict = locCfg.fontDefDictionary; for (i = 0; i < stringLen - 1; i++) { - if (locStr.charCodeAt(i) == 10) quantityOfLines++; + if (locStr.charCodeAt(i) === 10) quantityOfLines++; } var totalHeight = locCommonH * quantityOfLines; @@ -314,7 +314,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var prev = -1; for (i = 0; i < stringLen; i++) { var key = locStr.charCodeAt(i); - if (key == 0) continue; + if (key === 0) continue; if (key === 10) { //new line @@ -564,7 +564,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ } // Step 2: Make alignment - if (self._alignment != cc.TEXT_ALIGNMENT_LEFT) { + if (self._alignment !== cc.TEXT_ALIGNMENT_LEFT) { i = 0; var lineNumber = 0; @@ -572,11 +572,11 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ var last_line = []; for (var ctr = 0; ctr < strlen; ctr++) { - if (self._string[ctr].charCodeAt(0) == 10 || self._string[ctr].charCodeAt(0) == 0) { + if (self._string[ctr].charCodeAt(0) === 10 || self._string[ctr].charCodeAt(0) === 0) { var lineWidth = 0; var line_length = last_line.length; // if last line is empty we must just increase lineNumber and work with next line - if (line_length == 0) { + if (line_length === 0) { lineNumber++; continue; } @@ -600,7 +600,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ break; } - if (shift != 0) { + if (shift !== 0) { for (j = 0; j < line_length; j++) { index = i + j + lineNumber; if (index < 0) continue; @@ -698,7 +698,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ */ setFntFile: function (fntFile) { var self = this; - if (fntFile != null && fntFile != self._fntFile) { + if (fntFile != null && fntFile !== self._fntFile) { var newConf = cc.loader.getRes(fntFile); if (!newConf) { @@ -789,9 +789,9 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ //Checking whether the character is a whitespace _isspace_unicode: function(ch){ ch = ch.charCodeAt(0); - return ((ch >= 9 && ch <= 13) || ch == 32 || ch == 133 || ch == 160 || ch == 5760 - || (ch >= 8192 && ch <= 8202) || ch == 8232 || ch == 8233 || ch == 8239 - || ch == 8287 || ch == 12288) + return ((ch >= 9 && ch <= 13) || ch === 32 || ch === 133 || ch === 160 || ch === 5760 + || (ch >= 8192 && ch <= 8202) || ch === 8232 || ch === 8233 || ch === 8239 + || ch === 8287 || ch === 12288) }, _utf8_trim_ws: function(str){ @@ -874,7 +874,7 @@ cc._fntLoader = { var key = tempStr.substring(0, index); var value = tempStr.substring(index + 1); if (value.match(this.INT_EXP)) value = parseInt(value); - else if (value[0] == '"') value = value.substring(1, value.length - 1); + else if (value[0] === '"') value = value.substring(1, value.length - 1); obj[key] = value; } } diff --git a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js index 211932df4e..2fd0ac9792 100644 --- a/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +++ b/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js @@ -75,7 +75,7 @@ var selChild = locChildren[i]; var cm = selChild._renderCmd; var childDColor = cm._displayedColor; - if (this._texture != cm._texture && (childDColor.r !== locDisplayedColor.r || + if (this._texture !== cm._texture && (childDColor.r !== locDisplayedColor.r || childDColor.g !== locDisplayedColor.g || childDColor.b !== locDisplayedColor.b)) continue; selChild.texture = texture; diff --git a/cocos2d/menus/CCMenu.js b/cocos2d/menus/CCMenu.js index 794ef3ed61..53c34e6a1f 100644 --- a/cocos2d/menus/CCMenu.js +++ b/cocos2d/menus/CCMenu.js @@ -88,9 +88,9 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ cc.log("parameters should not be ending with null in Javascript"); var argc = arguments.length, items; - if (argc == 0) { + if (argc === 0) { items = []; - } else if (argc == 1) { + } else if (argc === 1) { if (menuItems instanceof Array) { items = menuItems; } @@ -315,7 +315,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ if (locChildren && locChildren.length > 0) { for (i = 0, len = locChildren.length; i < len; i++) { var child = locChildren[i]; - if (rowColumns == 0) { + if (rowColumns === 0) { rowColumns = rows[row]; w = winSize.width / (1 + rowColumns); x = w; @@ -409,7 +409,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ if (locChildren && locChildren.length > 0) { for (i = 0, len = locChildren.length; i < len; i++) { child = locChildren[i]; - if (columnRows == 0) { + if (columnRows === 0) { columnRows = columns[column]; y = columnHeights[column]; } @@ -447,14 +447,14 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ return; } - if (this._selectedItem == child) + if (this._selectedItem === child) this._selectedItem = null; cc.Node.prototype.removeChild.call(this, child, cleanup); }, _onTouchBegan: function (touch, event) { var target = event.getCurrentTarget(); - if (target._state != cc.MENU_STATE_WAITING || !target._visible || !target.enabled) + if (target._state !== cc.MENU_STATE_WAITING || !target._visible || !target.enabled) return false; for (var c = target.parent; c != null; c = c.parent) { @@ -506,7 +506,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ return; } var currentItem = target._itemForTouch(touch); - if (currentItem != target._selectedItem) { + if (currentItem !== target._selectedItem) { if (target._selectedItem) { target._selectedItem.unselected(); target._selectedItem.setNodeDirty(); @@ -528,7 +528,7 @@ cc.Menu = cc.Layer.extend(/** @lends cc.Menu# */{ *

    */ onExit: function () { - if (this._state == cc.MENU_STATE_TRACKING_TOUCH) { + if (this._state === cc.MENU_STATE_TRACKING_TOUCH) { if (this._selectedItem) { this._selectedItem.unselected(); this._selectedItem = null; @@ -590,9 +590,9 @@ cc.Menu.create = function (menuItems) { cc.log("parameters should not be ending with null in Javascript"); var ret; - if (argc == 0) + if (argc === 0) ret = new cc.Menu(); - else if (argc == 1) + else if (argc === 1) ret = new cc.Menu(menuItems); else ret = new cc.Menu(Array.prototype.slice.call(arguments, 0)); diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 8225c03cc6..06c85bb05e 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -295,7 +295,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{ * @param {Boolean} enabled */ setEnabled: function (enabled) { - if (this._enabled != enabled) { + if (this._enabled !== enabled) { var locLabel = this._label; if (!enabled) { this._colorBackup = locLabel.color; @@ -492,7 +492,7 @@ cc.MenuItemAtlasFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemAtlasFont# * @return {Boolean} */ initWithString: function (value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) { - if (!value || value.length == 0) + if (!value || value.length === 0) throw "cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0"; var label = new cc.LabelAtlas(); @@ -566,7 +566,7 @@ cc.MenuItemFont = cc.MenuItemLabel.extend(/** @lends cc.MenuItemFont# */{ * @return {Boolean} */ initWithString: function (value, callback, target) { - if (!value || value.length == 0) + if (!value || value.length === 0) throw "Value should be non-null and its length should be greater than 0"; this._fontName = cc._globalFontName; @@ -760,7 +760,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ * @param {cc.Sprite} normalImage */ setNormalImage: function (normalImage) { - if (this._normalImage == normalImage) { + if (this._normalImage === normalImage) { return; } if (normalImage) { @@ -798,7 +798,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ * @param {cc.Sprite} selectedImage */ setSelectedImage: function (selectedImage) { - if (this._selectedImage == selectedImage) + if (this._selectedImage === selectedImage) return; if (selectedImage) { @@ -828,7 +828,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ * @param {cc.Sprite} disabledImage */ setDisabledImage: function (disabledImage) { - if (this._disabledImage == disabledImage) + if (this._disabledImage === disabledImage) return; if (disabledImage) { @@ -959,7 +959,7 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ * @param {Boolean} bEnabled */ setEnabled: function (bEnabled) { - if (this._enabled != bEnabled) { + if (this._enabled !== bEnabled) { cc.MenuItem.prototype.setEnabled.call(this, bEnabled); this._updateImagesVisibility(); } @@ -1251,7 +1251,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ * @param {Number} SelectedIndex */ setSelectedIndex: function (SelectedIndex) { - if (SelectedIndex != this._selectedIndex) { + if (SelectedIndex !== this._selectedIndex) { this._selectedIndex = SelectedIndex; var currItem = this.getChildByTag(cc.CURRENT_ITEM); if (currItem) @@ -1358,7 +1358,7 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{ * @param {Boolean} enabled */ setEnabled: function (enabled) { - if (this._enabled != enabled) { + if (this._enabled !== enabled) { cc.MenuItem.prototype.setEnabled.call(this, enabled); var locItems = this.subItems; if (locItems && locItems.length > 0) { diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index e62727be07..13c66a0f28 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -129,7 +129,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ * @param {cc.Texture2D} texture */ setTexture:function (texture) { - if (this.texture != texture) + if (this.texture !== texture) this.texture = texture; }, @@ -432,7 +432,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ else if (locNuPoints > 0) { var a1 = cc.pDistanceSQ(cc.p(locPointVertexes[(locNuPoints - 1) * 2], locPointVertexes[(locNuPoints - 1) * 2 + 1]), this._positionR) < this._minSeg; - var a2 = (locNuPoints == 1) ? false : (cc.pDistanceSQ( + var a2 = (locNuPoints === 1) ? false : (cc.pDistanceSQ( cc.p(locPointVertexes[(locNuPoints - 2) * 2], locPointVertexes[(locNuPoints - 2) * 2 + 1]), this._positionR) < (this._minSeg * 2.0)); if (a1 || a2) appendNewPoint = false; @@ -473,7 +473,7 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ cc.vertexLineToPolygon(locPointVertexes, this._stroke, this._vertices, 0, locNuPoints); // Updated Tex Coords only if they are different than previous step - if (locNuPoints && this._previousNuPoints != locNuPoints) { + if (locNuPoints && this._previousNuPoints !== locNuPoints) { var texDelta = 1.0 / locNuPoints; var locTexCoords = this._texCoords; for (i = 0; i < locNuPoints; i++) { diff --git a/cocos2d/node-grid/CCNodeGrid.js b/cocos2d/node-grid/CCNodeGrid.js index 3426e84d74..781b8db4c8 100644 --- a/cocos2d/node-grid/CCNodeGrid.js +++ b/cocos2d/node-grid/CCNodeGrid.js @@ -83,7 +83,7 @@ cc.NodeGrid = cc.Node.extend({ topMat4.multiply(t4x4) ; // = cc.kmGLMultMatrix(this._transform4x4); // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if (this._camera != null && !(this.grid && this.grid.isActive())) { + if (this._camera !== null && !(this.grid && this.grid.isActive())) { var app = this._renderCmd._anchorPointInPoints, apx = app.x, apy = app.y, translate = (apx !== 0.0 || apy !== 0.0); diff --git a/cocos2d/parallax/CCParallaxNode.js b/cocos2d/parallax/CCParallaxNode.js index c7716ea99f..ca41c526aa 100644 --- a/cocos2d/parallax/CCParallaxNode.js +++ b/cocos2d/parallax/CCParallaxNode.js @@ -190,7 +190,7 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ var locParallaxArray = this.parallaxArray; for (var i = 0; i < locParallaxArray.length; i++) { var point = locParallaxArray[i]; - if (point.getChild() == child) { + if (point.getChild() === child) { locParallaxArray.splice(i, 1); break; } @@ -224,7 +224,7 @@ cc.ParallaxNode = cc.Node.extend(/** @lends cc.ParallaxNode# */{ _absolutePosition:function () { var ret = this._position; var cn = this; - while (cn.parent != null) { + while (cn.parent !== null) { cn = cn.parent; ret = cc.pAdd(ret, cn.getPosition()); } diff --git a/cocos2d/particle/CCParticleBatchNode.js b/cocos2d/particle/CCParticleBatchNode.js index 69809898d1..b92f11bc27 100644 --- a/cocos2d/particle/CCParticleBatchNode.js +++ b/cocos2d/particle/CCParticleBatchNode.js @@ -161,7 +161,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ zOrder = (zOrder == null) ? child.zIndex : zOrder; tag = (tag == null) ? child.tag : tag; - if(child.getTexture() != this.textureAtlas.texture) + if(child.getTexture() !== this.textureAtlas.texture) throw "cc.ParticleSystem.addChild() : the child is not using the same texture id"; // If this is the 1st children, then copy blending function @@ -169,7 +169,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ if (this._children.length === 0) this.setBlendFunc(childBlendFunc); else{ - if((childBlendFunc.src != this._blendFunc.src) || (childBlendFunc.dst != this._blendFunc.dst)){ + if((childBlendFunc.src !== this._blendFunc.src) || (childBlendFunc.dst !== this._blendFunc.dst)){ cc.log("cc.ParticleSystem.addChild() : Can't add a ParticleSystem that uses a different blending function"); return; } @@ -181,7 +181,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ //get new atlasIndex var atlasIndex = 0; - if (pos != 0) { + if (pos !== 0) { var p = this._children[pos - 1]; atlasIndex = p.getAtlasIndex() + p.getTotalParticles(); } else @@ -210,7 +210,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ } // make room for quads, not necessary for last child - if (pSystem.getAtlasIndex() + totalParticles != totalQuads) + if (pSystem.getAtlasIndex() + totalParticles !== totalQuads) locTextureAtlas.moveQuadsFromIndex(index, index + totalParticles); // increase totalParticles here for new particles, update method of particlesystem will fill the quads @@ -229,7 +229,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ if(!(child instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children"; - if(this._children.indexOf(child) == -1){ + if(this._children.indexOf(child) === -1){ cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it"); return; } @@ -264,14 +264,14 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ return; } - if (zOrder == child.zIndex) + if (zOrder === child.zIndex) return; // no reordering if only 1 child if (this._children.length > 1) { var getIndexes = this._getCurrentIndex(child, zOrder); - if (getIndexes.oldIndex != getIndexes.newIndex) { + if (getIndexes.oldIndex !== getIndexes.newIndex) { // reorder m_pChildren.array this._children.splice(getIndexes.oldIndex, 1) this._children.splice(getIndexes.newIndex, 0, child); @@ -287,7 +287,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ var locChildren = this._children; for (var i = 0; i < locChildren.length; i++) { var pNode = locChildren[i]; - if (pNode == child) { + if (pNode === child) { newAtlasIndex = child.getAtlasIndex(); break; } @@ -350,7 +350,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ // If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it var locBlendFunc = this._blendFunc; - if (texture && !texture.hasPremultipliedAlpha() && ( locBlendFunc.src == cc.BLEND_SRC && locBlendFunc.dst == cc.BLEND_DST )) { + if (texture && !texture.hasPremultipliedAlpha() && ( locBlendFunc.src === cc.BLEND_SRC && locBlendFunc.dst === cc.BLEND_DST )) { locBlendFunc.src = cc.SRC_ALPHA; locBlendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; } @@ -429,7 +429,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{ break; } // current index - if (child == pNode) { + if (child === pNode) { oldIndex = i; foundCurrentIdx = true; if (!foundNewIdx) diff --git a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js index 38611de45c..16da24b496 100644 --- a/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js @@ -36,7 +36,7 @@ proto.rendering = function (ctx) { var _t = this._node; - if (_t.textureAtlas.totalQuads == 0) + if (_t.textureAtlas.totalQuads === 0) return; this._shaderProgram.use(); diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index f270679a0a..85a844df33 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1144,12 +1144,12 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ */ setBlendFunc:function (src, dst) { if (dst === undefined) { - if (this._blendFunc != src) { + if (this._blendFunc !== src) { this._blendFunc = src; this._updateBlendFunc(); } } else { - if (this._blendFunc.src != src || this._blendFunc.dst != dst) { + if (this._blendFunc.src !== src || this._blendFunc.dst !== dst) { this._blendFunc = {src:src, dst:dst}; this._updateBlendFunc(); } @@ -1182,7 +1182,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ * dest blend function = GL_ONE; */ isBlendAdditive:function () { - return (( this._blendFunc.src == cc.SRC_ALPHA && this._blendFunc.dst == cc.ONE) || (this._blendFunc.src == cc.ONE && this._blendFunc.dst == cc.ONE)); + return (( this._blendFunc.src === cc.SRC_ALPHA && this._blendFunc.dst === cc.ONE) || (this._blendFunc.src === cc.ONE && this._blendFunc.dst === cc.ONE)); }, /** @@ -1364,7 +1364,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.ParticleSystem.MODE_GRAVITY) { + if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) { var locModeA = this.modeA; // gravity locModeA.gravity.x = parseFloat(locValueForKey("gravityx", dictionary)); @@ -1391,7 +1391,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.ParticleSystem.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)); @@ -1603,9 +1603,9 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ particle.deltaRotation = (endA - startA) / locParticleTimeToLive; // position - if (this.positionType == cc.ParticleSystem.TYPE_FREE) + if (this.positionType === cc.ParticleSystem.TYPE_FREE) particle.startPos = this.convertToWorldSpace(this._pointZeroForParticle); - else if (this.positionType == cc.ParticleSystem.TYPE_RELATIVE){ + else if (this.positionType === cc.ParticleSystem.TYPE_RELATIVE){ particle.startPos.x = this._position.x; particle.startPos.y = this._position.y; } @@ -1710,15 +1710,15 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } this._elapsed += dt; - if (this.duration != -1 && this.duration < this._elapsed) + if (this.duration !== -1 && this.duration < this._elapsed) this.stopSystem(); } this._particleIdx = 0; var currentPosition = cc.Particle.TemporaryPoints[0]; - if (this.positionType == cc.ParticleSystem.TYPE_FREE) { + if (this.positionType === cc.ParticleSystem.TYPE_FREE) { cc.pIn(currentPosition, this.convertToWorldSpace(this._pointZeroForParticle)); - } else if (this.positionType == cc.ParticleSystem.TYPE_RELATIVE) { + } else if (this.positionType === cc.ParticleSystem.TYPE_RELATIVE) { currentPosition.x = this._position.x; currentPosition.y = this._position.y; } @@ -1744,7 +1744,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.ParticleSystem.MODE_GRAVITY) { + if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) { var tmp = tpc, radial = tpa, tangential = tpb; @@ -1801,7 +1801,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ // update values in quad // var newPos = tpa; - if (this.positionType == cc.ParticleSystem.TYPE_FREE || this.positionType == cc.ParticleSystem.TYPE_RELATIVE) { + if (this.positionType === cc.ParticleSystem.TYPE_FREE || this.positionType === cc.ParticleSystem.TYPE_RELATIVE) { var diff = tpb; cc.pIn(diff, currentPosition); cc.pSubIn(diff, selParticle.startPos); @@ -1838,7 +1838,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ } --this.particleCount; - if (this.particleCount == 0 && this.autoRemoveOnFinish) { + if (this.particleCount === 0 && this.autoRemoveOnFinish) { this.unscheduleUpdate(); this._parent.removeChild(this, true); return; @@ -1884,7 +1884,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ if (locTexture && locTexture instanceof cc.Texture2D) { this._opacityModifyRGB = false; var locBlendFunc = this._blendFunc; - if (locBlendFunc.src == cc.BLEND_SRC && locBlendFunc.dst == cc.BLEND_DST) { + if (locBlendFunc.src === cc.BLEND_SRC && locBlendFunc.dst === cc.BLEND_DST) { if (locTexture.hasPremultipliedAlpha()) { this._opacityModifyRGB = true; } else { @@ -1945,7 +1945,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ retParticle.setEmitterMode(this.getEmitterMode()); // Mode A: Gravity + tangential accel + radial accel - if (this.getEmitterMode() == cc.ParticleSystem.MODE_GRAVITY) { + if (this.getEmitterMode() === cc.ParticleSystem.MODE_GRAVITY) { // gravity var gra = this.getGravity(); retParticle.setGravity(cc.p(gra.x,gra.y)); @@ -1962,7 +1962,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ retParticle.setTangentialAccel(this.getTangentialAccel()); retParticle.setTangentialAccelVar(this.getTangentialAccelVar()); - } else if (this.getEmitterMode() == cc.ParticleSystem.MODE_RADIUS) { + } else if (this.getEmitterMode() === cc.ParticleSystem.MODE_RADIUS) { // or Mode B: radius movement retParticle.setStartRadius(this.getStartRadius()); retParticle.setStartRadiusVar(this.getStartRadiusVar()); @@ -2006,12 +2006,12 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ return; var locOffset = spriteFrame.getOffsetInPixels(); - if (locOffset.x != 0 || locOffset.y != 0) + if (locOffset.x !== 0 || locOffset.y !== 0) cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets"); // update texture before updating texture rect var texture = spriteFrame.getTexture(), locTexture = this._texture; - if (locTexture != texture) + if (locTexture !== texture) this.setTexture(texture); }, @@ -2022,7 +2022,7 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ */ setTextureWithRect: function (texture, rect) { var locTexture = this._texture; - if (locTexture != texture) { + if (locTexture !== texture) { this._texture = texture; this._updateBlendFunc(); } diff --git a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js index ed58e9821b..7537bb94d5 100644 --- a/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js @@ -55,7 +55,7 @@ }; proto.setBatchNode = function(batchNode){ - if (this._batchNode != batchNode) { + if (this._batchNode !== batchNode) { this._node._batchNode = batchNode; } }; @@ -129,7 +129,7 @@ context.save(); context.translate(0 | particle.drawPos.x, -(0 | particle.drawPos.y)); - if (node.shapeType == cc.ParticleSystem.STAR_SHAPE) { + if (node.shapeType === cc.ParticleSystem.STAR_SHAPE) { if (particle.rotation) context.rotate(cc.degreesToRadians(particle.rotation)); drawTool.drawStar(wrapper, lpx, particle.color); diff --git a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js index 87f501510f..eb1ce063b0 100644 --- a/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +++ b/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js @@ -45,7 +45,7 @@ proto.setBatchNode = function(batchNode){ var node = this._node; - if (node._batchNode != batchNode) { + if (node._batchNode !== batchNode) { var oldBatch = node._batchNode; node._batchNode = batchNode; //weak reference @@ -89,8 +89,7 @@ }; proto.isDifferentTexture = function(texture1, texture2){ - if(texture1 == texture2) - return true; + return (texture1 === texture2); }; proto.updateParticlePosition = function(particle, position){ diff --git a/cocos2d/physics/CCPhysicsSprite.js b/cocos2d/physics/CCPhysicsSprite.js index 913b8726e6..2fa248da8f 100644 --- a/cocos2d/physics/CCPhysicsSprite.js +++ b/cocos2d/physics/CCPhysicsSprite.js @@ -347,7 +347,7 @@ _syncPosition:function () { var locPosition = this._position, locBody = this._body; - if (locPosition.x != locBody.p.x || locPosition.y != locBody.p.y) { + if (locPosition.x !== locBody.p.x || locPosition.y !== locBody.p.y) { cc.Sprite.prototype.setPosition.call(this, locBody.p.x, locBody.p.y); } }, @@ -373,7 +373,7 @@ } }, _syncRotation:function () { - if (this._rotationX != -cc.radiansToDegrees(this._body.a)) { + if (this._rotationX !== -cc.radiansToDegrees(this._body.a)) { cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegrees(this._body.a)); } }, diff --git a/cocos2d/progress-timer/CCProgressTimer.js b/cocos2d/progress-timer/CCProgressTimer.js index b5b9fff6f3..3ad05586f0 100644 --- a/cocos2d/progress-timer/CCProgressTimer.js +++ b/cocos2d/progress-timer/CCProgressTimer.js @@ -145,7 +145,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {Number} percentage */ setPercentage:function (percentage) { - if (this._percentage != percentage) { + if (this._percentage !== percentage) { this._percentage = cc.clampf(percentage, 0, 100); this._renderCmd._updateProgress(); } @@ -224,7 +224,7 @@ cc.ProgressTimer = cc.Node.extend(/** @lends cc.ProgressTimer# */{ * @param {cc.Sprite} sprite */ setSprite: function(sprite){ - if (this._sprite != sprite) { + if (this._sprite !== sprite) { this._sprite = sprite; if(sprite) this.setContentSize(sprite.width,sprite.height); diff --git a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js index c914c07267..fbb87b8ced 100644 --- a/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js @@ -72,13 +72,13 @@ } //clip - if (node._type == cc.ProgressTimer.TYPE_BAR) { + if (node._type === cc.ProgressTimer.TYPE_BAR) { var locBarRect = this._barRect; context.beginPath(); context.rect(locBarRect.x * scaleX, locBarRect.y * scaleY, locBarRect.width * scaleX, locBarRect.height * scaleY); context.clip(); context.closePath(); - } else if (node._type == cc.ProgressTimer.TYPE_RADIAL) { + } else if (node._type === cc.ProgressTimer.TYPE_RADIAL) { var locOriginX = this._origin.x * scaleX; var locOriginY = this._origin.y * scaleY; context.beginPath(); @@ -113,7 +113,7 @@ var sw = locSprite.width, sh = locSprite.height; var locMidPoint = node._midPoint; - if (node._type == cc.ProgressTimer.TYPE_RADIAL) { + if (node._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; diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index 4ca4286c07..c8b147ae8b 100644 --- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -67,7 +67,7 @@ if (node._type === cc.ProgressTimer.TYPE_RADIAL) context.drawArrays(context.TRIANGLE_FAN, 0, this._vertexDataCount); - else if (node._type == cc.ProgressTimer.TYPE_BAR) { + else if (node._type === cc.ProgressTimer.TYPE_BAR) { if (!node._reverseDirection) context.drawArrays(context.TRIANGLE_STRIP, 0, this._vertexDataCount); else { @@ -327,12 +327,12 @@ var index = 0; var hit; - if (alpha == 0) { + if (alpha === 0) { // More efficient since we don't always need to check intersection // If the alpha is zero then the hit point is top mid and the index is 0. hit = topMid; index = 0; - } else if (alpha == 1) { + } else if (alpha === 1) { // More efficient since we don't always need to check intersection // If the alpha is one then the hit point is top mid and the index is 4. hit = topMid; @@ -352,9 +352,9 @@ // Remember that the top edge is split in half for the 12 o'clock position // Let's deal with that here by finding the correct endpoints - if (i == 0) + if (i === 0) edgePtB = cc.pLerp(edgePtA, edgePtB, 1 - locMidPoint.x); - else if (i == 4) + else if (i === 4) edgePtA = cc.pLerp(edgePtA, edgePtB, 1 - locMidPoint.x); // retPoint are returned by ccpLineIntersect @@ -362,7 +362,7 @@ if (cc.pLineIntersect(edgePtA, edgePtB, locMidPoint, percentagePt, retPoint)) { // Since our hit test is on rays we have to deal with the top edge // being in split in half so we have to test as a segment - if ((i == 0 || i == 4)) { + if ((i === 0 || i === 4)) { // s represents the point between edgePtA--edgePtB if (!(0 <= retPoint.x && retPoint.x <= 1)) continue; @@ -387,7 +387,7 @@ // The size of the vertex data is the index from the hitpoint // the 3 is for the m_tMidpoint, 12 o'clock point and hitpoint position. var sameIndexCount = true; - if (this._vertexDataCount != index + 3) { + if (this._vertexDataCount !== index + 3) { sameIndexCount = false; this._vertexData = null; this._vertexArrayBuffer = null; diff --git a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js index 5238694b38..50bed35f16 100644 --- a/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +++ b/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js @@ -95,7 +95,7 @@ var locChildren = node._children; for (var i = 0; i < locChildren.length; i++) { var getChild = locChildren[i]; - if (getChild != node.sprite){ + if (getChild !== node.sprite){ getChild._renderCmd.visit(node.sprite._renderCmd); //TODO it's very Strange } } @@ -130,7 +130,7 @@ proto.initWithWidthAndHeight = function(width, height, format, depthStencilFormat){ var node = this._node; - if(format == cc.Texture2D.PIXEL_FORMAT_A8) + if(format === cc.Texture2D.PIXEL_FORMAT_A8) cc.log( "cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;"); var gl = cc._renderContext, locScaleFactor = cc.contentScaleFactor(); @@ -185,7 +185,7 @@ // associate texture with FBO gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, locTexture._webTextureObj, 0); - if (depthStencilFormat != 0) { + if (depthStencilFormat !== 0) { //create and attach depth buffer this._depthRenderBuffer = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderBuffer); diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index c8812bcac4..283a2f5390 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -101,12 +101,12 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ if (!status) { cc.log("cocos2d: ERROR: Failed to compile shader:\n" + this._glContext.getShaderSource(shader)); - if (type == this._glContext.VERTEX_SHADER) + if (type === this._glContext.VERTEX_SHADER) cc.log("cocos2d: \n" + this.vertexShaderLog()); else cc.log("cocos2d: \n" + this.fragmentShaderLog()); } - return ( status == 1 ); + return ( status === 1 ); }, /** @@ -568,7 +568,7 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time)); } - if (this._uniforms[cc.UNIFORM_RANDOM01] != -1) + if (this._uniforms[cc.UNIFORM_RANDOM01] !== -1) this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); }, @@ -601,7 +601,7 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], time / 8.0, time / 4.0, time / 2.0, Math.cos(time)); } - if (this._uniforms[cc.UNIFORM_RANDOM01] != -1) + if (this._uniforms[cc.UNIFORM_RANDOM01] !== -1) this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random()); }, @@ -737,7 +737,7 @@ cc.GLProgram._isHighpSupported = function(){ if(cc.GLProgram._highpSupported == null){ var ctx = cc._renderContext; var highp = ctx.getShaderPrecisionFormat(ctx.FRAGMENT_SHADER, ctx.HIGH_FLOAT); - cc.GLProgram._highpSupported = highp.precision != 0; + cc.GLProgram._highpSupported = highp.precision !== 0; } return cc.GLProgram._highpSupported; }; diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js index 9fac3b5998..f048ce03e3 100644 --- a/cocos2d/shaders/CCGLStateCache.js +++ b/cocos2d/shaders/CCGLStateCache.js @@ -240,7 +240,7 @@ cc.glBindTexture2D = function (textureId) { * @param {cc.Texture2D} textureId */ cc.glBindTexture2DN = function (textureUnit, textureId) { - if (cc._currentBoundTexture[textureUnit] == textureId) + if (cc._currentBoundTexture[textureUnit] === textureId) return; cc._currentBoundTexture[textureUnit] = textureId; @@ -281,7 +281,7 @@ cc.glDeleteTexture = function (textureId) { */ cc.glDeleteTextureN = function (textureUnit, textureId) { if (cc.ENABLE_GL_STATE_CACHE) { - if (textureId == cc._currentBoundTexture[ textureUnit ]) + if (textureId === cc._currentBoundTexture[ textureUnit ]) cc._currentBoundTexture[ textureUnit ] = -1; } cc._renderContext.deleteTexture(textureId); @@ -298,7 +298,7 @@ cc.glBindVAO = function (vaoId) { return; if (cc.ENABLE_GL_STATE_CACHE) { - if (cc._uVAO != vaoId) { + if (cc._uVAO !== vaoId) { cc._uVAO = vaoId; //TODO need fixed //glBindVertexArray(vaoId); diff --git a/cocos2d/shape-nodes/CCDrawNode.js b/cocos2d/shape-nodes/CCDrawNode.js index 9564b6bdc9..1d222cb9e7 100644 --- a/cocos2d/shape-nodes/CCDrawNode.js +++ b/cocos2d/shape-nodes/CCDrawNode.js @@ -346,7 +346,7 @@ cc.DrawNodeCanvas = cc.Node.extend(/** @lends cc.DrawNode# */{ for (var i = 0; i < segments + 1; i++) { var dt = i / segments; // border - if (dt == 1) { + if (dt === 1) { p = config.length - 1; lt = 1; } else { @@ -632,7 +632,7 @@ cc.DrawNodeWebGL = cc.Node.extend({ var dt = i / segments; // border - if (dt == 1) { + if (dt === 1) { p = config.length - 1; lt = 1; } else { @@ -722,7 +722,7 @@ cc.DrawNodeWebGL = cc.Node.extend({ }, drawDots: function(points, radius,color) { - if(!points || points.length == 0) + if(!points || points.length === 0) return; color = color || this.getDrawColor(); if (color.a == null) @@ -911,7 +911,7 @@ cc.DrawNodeWebGL = cc.Node.extend({ } }); -cc.DrawNode = cc._renderType == cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas; +cc.DrawNode = cc._renderType === cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas; /** * Creates a DrawNode diff --git a/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js b/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js index a9b99147af..8631e70a71 100644 --- a/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js +++ b/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js @@ -45,7 +45,7 @@ //context.save(); wrapper.setGlobalAlpha(alpha); - if ((this._blendFunc && (this._blendFunc.src == cc.SRC_ALPHA) && (this._blendFunc.dst == cc.ONE))) + if ((this._blendFunc && (this._blendFunc.src === cc.SRC_ALPHA) && (this._blendFunc.dst === cc.ONE))) wrapper.setCompositeOperation('lighter'); //todo: need refactor var locBuffer = this._buffer; for (var i = 0, len = locBuffer.length; i < len; i++) { diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index 61786c3444..56c08d3204 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -178,7 +178,7 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ if (e.keyCode === cc.KEY.tab) { e.stopPropagation(); e.preventDefault(); - } else if (e.keyCode == cc.KEY.enter) { + } else if (e.keyCode === cc.KEY.enter) { selfPointer.dispatchInsertText("\n", 1); e.stopPropagation(); e.preventDefault(); @@ -187,7 +187,7 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ if (/msie/i.test(navigator.userAgent)) { cc._addEventListener(this._domInputControl, "keyup", function (e) { - if (e.keyCode == cc.KEY.backspace) { + if (e.keyCode === cc.KEY.backspace) { selfPointer._processDomInputString(selfPointer._domInputControl.value); } }, false); @@ -353,7 +353,7 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ return false; // if delegate is not in delegate list, return - if (this.impl._delegateList.indexOf(delegate) == -1) + if (this.impl._delegateList.indexOf(delegate) === -1) return false; if (this.impl._delegateWithIme) { @@ -423,7 +423,7 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ return false; // if delegate is not the current delegate attached with ime, return - if (this.impl._delegateWithIme != delegate) + if (this.impl._delegateWithIme !== delegate) return false; if (!delegate.canDetachWithIME()) @@ -447,11 +447,11 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ return; // if delegate is not in delegate list, return - if (this.impl._delegateList.indexOf(delegate) == -1) + if (this.impl._delegateList.indexOf(delegate) === -1) return; if (this.impl._delegateWithIme) { - if (delegate == this.impl._delegateWithIme) { + if (delegate === this.impl._delegateWithIme) { this.impl._delegateWithIme = null; } } @@ -469,13 +469,13 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ */ processKeycode:function (keyCode) { if (keyCode < 32) { - if (keyCode == cc.KEY.backspace) { + if (keyCode === cc.KEY.backspace) { this.dispatchDeleteBackward(); - } else if (keyCode == cc.KEY.enter) { + } else if (keyCode === cc.KEY.enter) { this.dispatchInsertText("\n", 1); - } else if (keyCode == cc.KEY.tab) { + } else if (keyCode === cc.KEY.tab) { //tab input - } else if (keyCode == cc.KEY.escape) { + } else if (keyCode === cc.KEY.escape) { //ESC input } } else if (keyCode < 255) { @@ -509,7 +509,7 @@ cc.IMEDispatcher.Impl = cc.Class.extend(/** @lends cc.IMEDispatcher.Impl# */{ */ findDelegate:function (delegate) { for (var i = 0; i < this._delegateList.length; i++) { - if (this._delegateList[i] == delegate) + if (this._delegateList[i] === delegate) return i; } return null; diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index 2624093618..3628df9e9a 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -356,7 +356,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ */ deleteBackward:function () { var strLen = this._inputText.length; - if (strLen == 0) + if (strLen === 0) return; // get the delete byte number @@ -413,7 +413,7 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ this.string = sText; } - if (pos == -1) + if (pos === -1) return; // '\n' has inserted, let delegate process first diff --git a/cocos2d/tilemap/CCTGAlib.js b/cocos2d/tilemap/CCTGAlib.js index 3bca0832f7..60a8672ca4 100644 --- a/cocos2d/tilemap/CCTGAlib.js +++ b/cocos2d/tilemap/CCTGAlib.js @@ -212,10 +212,10 @@ cc.tgaLoadRLEImageData = function (buffer, bufSize, psInfo) { for (i = 0; i < total; i++) { // if we have a run length pending, run it - if (runlength != 0) { + if (runlength !== 0) { // we do, update the run length count runlength--; - skip = (flag != 0); + skip = (flag !== 0); } else { // otherwise, read in the run length token if (step + 1 > bufSize) @@ -352,7 +352,7 @@ cc.BinaryStreamReader = cc.Class.extend({ this._offset += size; - return exponent == (bias << 1) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity + return exponent === (bias << 1) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity : (1 + signal * -2) * (exponent || significand ? !exponent ? Math.pow(2, -bias + 1) * significand : Math.pow(2, exponent - bias) * (1 + significand) : 0); }, @@ -370,7 +370,7 @@ cc.BinaryStreamReader = cc.Class.extend({ }, _shl:function (a, b) { - for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1){}; + for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) === 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1){}; return a; }, diff --git a/cocos2d/tilemap/CCTMXLayer.js b/cocos2d/tilemap/CCTMXLayer.js index c2e763ac64..9491fb6b70 100644 --- a/cocos2d/tilemap/CCTMXLayer.js +++ b/cocos2d/tilemap/CCTMXLayer.js @@ -452,7 +452,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ var currentFlags = this.getTileFlagsAt(pos); var currentGID = this.getTileGIDAt(pos); - if (currentGID != gid || currentFlags != flags) { + if (currentGID !== gid || currentFlags !== flags) { var gidAndFlags = (gid | flags) >>> 0; // setting gid=0 is equal to remove the tile if (gid === 0) @@ -662,7 +662,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ }, _positionForHexAt:function (pos) { - var diffY = (pos.x % 2 == 1) ? (-this._mapTileSize.height / 2) : 0; + var diffY = (pos.x % 2 === 1) ? (-this._mapTileSize.height / 2) : 0; return cc.p(pos.x * this._mapTileSize.width * 3 / 4, (this._layerSize.height - pos.y - 1) * this._mapTileSize.height + diffY); }, @@ -762,7 +762,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ // if cc_vertex=automatic, then tiles will be rendered using vertexz var vertexz = this.getProperty("cc_vertexz"); if (vertexz) { - if (vertexz == "automatic") { + if (vertexz === "automatic") { this._useAutomaticVertexZ = true; var alphaFuncVal = this.getProperty("cc_alpha_func"); var alphaFuncValue = 0; @@ -809,11 +809,11 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ var flag = (gid & (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG) >>> 0) >>> 0; // handle the 4 diagonally flipped states. - if (flag == cc.TMX_TILE_HORIZONTAL_FLAG) + if (flag === cc.TMX_TILE_HORIZONTAL_FLAG) sprite.rotation = 90; - else if (flag == cc.TMX_TILE_VERTICAL_FLAG) + else if (flag === cc.TMX_TILE_VERTICAL_FLAG) sprite.rotation = 270; - else if (flag == (cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0) { + else if (flag === (cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0) { sprite.rotation = 90; sprite.setFlippedX(true); } else { @@ -861,7 +861,7 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{ var locAtlasIndexArray = this._atlasIndexArray; for (var i = 0, len = locAtlasIndexArray.length; i < len; i++) { item = locAtlasIndexArray[i]; - if (item == z) + if (item === z) break; } } diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js index 7bfcafbe32..560c690afe 100644 --- a/cocos2d/tilemap/CCTMXObjectGroup.js +++ b/cocos2d/tilemap/CCTMXObjectGroup.js @@ -131,7 +131,7 @@ cc.TMXObjectGroup = cc.Class.extend(/** @lends cc.TMXObjectGroup# */{ var locObjects = this._objects; for (var i = 0, len = locObjects.length; i < len; i++) { var name = locObjects[i]["name"]; - if (name && name == objectName) + if (name && name === objectName) return locObjects[i]; } } diff --git a/cocos2d/tilemap/CCTMXTiledMap.js b/cocos2d/tilemap/CCTMXTiledMap.js index 2344cdb9fc..97165dd3b2 100644 --- a/cocos2d/tilemap/CCTMXTiledMap.js +++ b/cocos2d/tilemap/CCTMXTiledMap.js @@ -269,7 +269,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ * map.initWithTMXFile("hello.tmx"); */ initWithTMXFile:function (tmxFile) { - if(!tmxFile || tmxFile.length == 0) + if(!tmxFile || tmxFile.length === 0) throw "cc.TMXTiledMap.initWithTMXFile(): tmxFile should be non-null or non-empty string."; this.width = 0; this.height = 0; @@ -353,7 +353,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ var locChildren = this._children; for (var i = 0; i < locChildren.length; i++) { var layer = locChildren[i]; - if (layer && layer.layerName == layerName) + if (layer && layer.layerName === layerName) return layer; } // layer not found @@ -371,7 +371,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ if (this.objectGroups) { for (var i = 0; i < this.objectGroups.length; i++) { var objectGroup = this.objectGroups[i]; - if (objectGroup && objectGroup.groupName == groupName) { + if (objectGroup && objectGroup.groupName === groupName) { return objectGroup; } } @@ -429,7 +429,7 @@ cc.TMXTiledMap = cc.Node.extend(/** @lends cc.TMXTiledMap# */{ for (var x = 0; x < size.width; x++) { var pos = x + size.width * y; var gid = layerInfo._tiles[pos]; - if (gid != 0) { + if (gid !== 0) { // Optimization: quick return // if the layer is invalid (more than 1 tileset per layer) an cc.assert will be thrown later if (((gid & cc.TMX_TILE_FLIPPED_MASK)>>>0) >= tileset.firstGid) { diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index bae661de31..478db3f2ef 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -542,15 +542,15 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ var version = map.getAttribute('version'); var orientationStr = map.getAttribute('orientation'); - if (map.nodeName == "map") { - if (version != "1.0" && version !== null) + if (map.nodeName === "map") { + if (version !== "1.0" && version !== null) cc.log("cocos2d: TMXFormat: Unsupported TMX version:" + version); - if (orientationStr == "orthogonal") + if (orientationStr === "orthogonal") this.orientation = cc.TMX_ORIENTATION_ORTHO; - else if (orientationStr == "isometric") + else if (orientationStr === "isometric") this.orientation = cc.TMX_ORIENTATION_ISO; - else if (orientationStr == "hexagonal") + else if (orientationStr === "hexagonal") this.orientation = cc.TMX_ORIENTATION_HEX; else if (orientationStr !== null) cc.log("cocos2d: TMXFomat: Unsupported orientation:" + orientationStr); @@ -693,7 +693,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ case null: case '': // Uncompressed - if (encoding == "base64") + if (encoding === "base64") layer._tiles = cc.Codec.Base64.decodeAsArray(nodeValue, 4); else if (encoding === "csv") { layer._tiles = []; @@ -709,7 +709,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ } break; default: - if(this.layerAttrs == cc.TMXLayerInfo.ATTRIB_NONE) + if(this.layerAttrs === cc.TMXLayerInfo.ATTRIB_NONE) cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported"); break; } diff --git a/cocos2d/transitions/CCTransition.js b/cocos2d/transitions/CCTransition.js index 07a5bd7e8e..f5ccb82cfe 100644 --- a/cocos2d/transitions/CCTransition.js +++ b/cocos2d/transitions/CCTransition.js @@ -195,7 +195,7 @@ cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ this._outScene.init(); } - if(this._inScene == this._outScene) + if(this._inScene === this._outScene) throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene"; this._sceneOrder(); @@ -1019,7 +1019,7 @@ cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionF var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ; - if (this._orientation == cc.TRANSITION_ORIENTATION_UP_OVER) { + if (this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; @@ -1495,9 +1495,6 @@ cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCross // create the first render texture for inScene var inTexture = new cc.RenderTexture(winSize.width, winSize.height); - if (null == inTexture) - return; - inTexture.sprite.anchorX = 0.5; inTexture.sprite.anchorY = 0.5; inTexture.attr({ diff --git a/cocos2d/transitions/CCTransitionProgress.js b/cocos2d/transitions/CCTransitionProgress.js index ab128091c8..803fe4d20f 100644 --- a/cocos2d/transitions/CCTransitionProgress.js +++ b/cocos2d/transitions/CCTransitionProgress.js @@ -89,7 +89,7 @@ cc.TransitionProgress = cc.TransitionScene.extend(/** @lends cc.TransitionProgre texture.end(); // Since we've passed the outScene to the texture we don't need it. - if (this._sceneToBeModified == this._outScene) + if (this._sceneToBeModified === this._outScene) this.hideOutShowIn(); // We need the texture in RenderTexture. @@ -245,7 +245,7 @@ cc.TransitionProgressRadialCW = cc.TransitionProgress.extend(/** @lends cc.Trans */ cc.TransitionProgressRadialCW.create = function (t, scene) { var tempScene = new cc.TransitionProgressRadialCW(); - if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) { + if ((tempScene !== null) && (tempScene.initWithDuration(t, scene))) { return tempScene; } return new cc.TransitionProgressRadialCW(t, scene); diff --git a/extensions/ccb-reader/CCBAnimationManager.js b/extensions/ccb-reader/CCBAnimationManager.js index 0b8e9cdfbc..8952fc9de7 100644 --- a/extensions/ccb-reader/CCBAnimationManager.js +++ b/extensions/ccb-reader/CCBAnimationManager.js @@ -205,7 +205,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ // Move base values var locBaseValues = this._baseValues; var baseValue = locBaseValues.objectForKey(fromNode); - if(baseValue != null) { + if(baseValue !== null) { locBaseValues.setObject(baseValue, toNode); locBaseValues.removeObjectForKey(fromNode); } @@ -246,20 +246,18 @@ cc.BuilderAnimationManager = cc.Class.extend({ actions.push(callback); } else { var target; - if(selectorTarget == CCB_TARGETTYPE_DOCUMENTROOT) + if(selectorTarget === CCB_TARGETTYPE_DOCUMENTROOT) target = this._rootNode; - else if (selectorTarget == CCB_TARGETTYPE_OWNER) + else if (selectorTarget === CCB_TARGETTYPE_OWNER) target = this._owner; if(target != null) { if(selectorName.length > 0) { var selCallFunc = 0; - var targetAsCCBSelectorResolver = target; - if(target.onResolveCCBCCCallFuncSelector != null) - selCallFunc = targetAsCCBSelectorResolver.onResolveCCBCCCallFuncSelector(target, selectorName); - if(selCallFunc == 0) + selCallFunc = target.onResolveCCBCCCallFuncSelector(target, selectorName); + if(selCallFunc === 0) cc.log("Skipping selector '" + selectorName + "' since no CCBSelectorResolver is present."); else actions.push(cc.callFunc(selCallFunc,target)); @@ -342,7 +340,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ var baseKeys = nodeBaseValues.allKeys(); for(j = 0; j < baseKeys.length;j++){ var selBaseKey = baseKeys[j]; - if(seqNodePropNames.indexOf(selBaseKey) == -1){ + if(seqNodePropNames.indexOf(selBaseKey) === -1){ var value = nodeBaseValues.objectForKey(selBaseKey); if(value != null) this._setAnimatedProperty(selBaseKey,node, value, tweenDuration); @@ -539,10 +537,10 @@ cc.BuilderAnimationManager = cc.Class.extend({ // TODO only handle rotation, opacity, displayFrame, color if(propName === "rotation"){ node.setRotation(value); - } else if(propName == "rotationX") + } else if(propName === "rotationX") { node.setRotationSkewX(value); - }else if(propName == "rotationY") + }else if(propName === "rotationY") { node.setRotationSkewY(value); }else if(propName === "opacity"){ @@ -656,7 +654,7 @@ cc.BuilderAnimationManager = cc.Class.extend({ var nextSeqId = locRunningSequence.getChainedSequenceId(); this._runningSequence = null; - if (nextSeqId != -1) + if (nextSeqId !== -1) this.runAnimations(nextSeqId, 0); if (this._delegate) diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index cde09e6f92..e22f54decf 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -159,7 +159,7 @@ cc.BuilderReader = cc.Class.extend({ this._currentBit = -1; this._currentByte = -1; - if (arguments.length != 0) { + if (arguments.length !== 0) { if (ccNodeLoaderLibrary instanceof cc.BuilderReader) { var ccbReader = ccNodeLoaderLibrary; @@ -222,7 +222,7 @@ cc.BuilderReader = cc.Class.extend({ if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { req.setRequestHeader("Accept-Charset", "x-user-defined"); req.send(null); - if (req.status != 200) { + if (req.status !== 200) { cc.log(errInfo); return null; } @@ -236,7 +236,7 @@ cc.BuilderReader = cc.Class.extend({ if (req.overrideMimeType) req.overrideMimeType('text\/plain; charset=x-user-defined'); req.send(null); - if (req.status != 200) { + if (req.status !== 200) { cc.log(errInfo); return null; } @@ -280,7 +280,7 @@ cc.BuilderReader = cc.Class.extend({ var nodeGraph = this.readFileWithCleanUp(true); - if (nodeGraph && locAnimationManager.getAutoPlaySequenceId() != -1) { + if (nodeGraph && locAnimationManager.getAutoPlaySequenceId() !== -1) { //auto play animations locAnimationManager.runAnimations(locAnimationManager.getAutoPlaySequenceId(), 0); } @@ -376,7 +376,7 @@ cc.BuilderReader = cc.Class.extend({ }, readBool:function () { - return (0 != this.readByte()); + return (0 !== this.readByte()); }, readFloat:function () { @@ -428,7 +428,7 @@ cc.BuilderReader = cc.Class.extend({ this._currentByte += size; - return exponent == (bias << 1) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity + return exponent === (bias << 1) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity : (1 + signal * -2) * (exponent || significand ? !exponent ? Math.pow(2, -bias + 1) * significand : Math.pow(2, exponent - bias) * (1 + significand) : 0); }, @@ -458,7 +458,7 @@ cc.BuilderReader = cc.Class.extend({ }, _shl:function (a, b) { - for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1); + for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) === 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1); return a; }, @@ -669,24 +669,24 @@ cc.BuilderReader = cc.Class.extend({ keyframe.setEasingType(easingType); keyframe.setEasingOpt(easingOpt); - if (type == CCB_PROPTYPE_CHECK) { + if (type === CCB_PROPTYPE_CHECK) { value = this.readBool(); - } else if (type == CCB_PROPTYPE_BYTE) { + } else if (type === CCB_PROPTYPE_BYTE) { value = this.readByte(); - } else if (type == CCB_PROPTYPE_COLOR3) { + } else if (type === CCB_PROPTYPE_COLOR3) { var c = cc.color(this.readByte(), this.readByte(), this.readByte()); value = cc.Color3BWapper.create(c); - } else if (type == CCB_PROPTYPE_FLOATXY) { + } else if (type === CCB_PROPTYPE_FLOATXY) { value = [this.readFloat(), this.readFloat()]; - } else if (type == CCB_PROPTYPE_DEGREES) { + } else if (type === CCB_PROPTYPE_DEGREES) { value = this.readFloat(); - } else if (type == CCB_PROPTYPE_SCALELOCK || type == CCB_PROPTYPE_POSITION || type == CCB_PROPTYPE_FLOATXY) { + } else if (type === CCB_PROPTYPE_SCALELOCK || type === CCB_PROPTYPE_POSITION || type === CCB_PROPTYPE_FLOATXY) { value = [this.readFloat(), this.readFloat()]; - } else if (type == CCB_PROPTYPE_SPRITEFRAME) { + } else if (type === CCB_PROPTYPE_SPRITEFRAME) { var spriteSheet = this.readCachedString(); var spriteFile = this.readCachedString(); - if (spriteSheet == "") { + if (spriteSheet === "") { spriteFile = this._ccbRootPath + spriteFile; var texture = cc.textureCache.addImage(spriteFile); var locContentSize = texture.getContentSize(); @@ -696,7 +696,7 @@ cc.BuilderReader = cc.Class.extend({ spriteSheet = this._ccbRootPath + spriteSheet; var frameCache = cc.spriteFrameCache; // Load the sprite sheet only if it is not loaded - if (this._loadedSpriteSheets.indexOf(spriteSheet) == -1) { + if (this._loadedSpriteSheets.indexOf(spriteSheet) === -1) { frameCache.addSpriteFrames(spriteSheet); this._loadedSpriteSheets.push(spriteSheet); } @@ -709,7 +709,7 @@ cc.BuilderReader = cc.Class.extend({ _readHeader:function () { /* If no bytes loaded, don't crash about it. */ - if (this._data == null) { + if (this._data === null) { return false; } @@ -717,13 +717,13 @@ cc.BuilderReader = cc.Class.extend({ var magicBytes = this._readStringFromBytes(this._currentByte, 4, true); this._currentByte += 4; - if (magicBytes != 'ccbi') { + if (magicBytes !== 'ccbi') { return false; } /* Read version. */ var version = this.readInt(false); - if (version != CCB_VERSION) { + if (version !== CCB_VERSION) { cc.log("WARNING! Incompatible ccbi file version (file: " + version + " reader: " + CCB_VERSION + ")"); return false; } @@ -783,7 +783,7 @@ cc.BuilderReader = cc.Class.extend({ var memberVarAssignmentType = this.readInt(false); var memberVarAssignmentName; - if (memberVarAssignmentType != CCB_TARGETTYPE_NONE) { + if (memberVarAssignmentType !== CCB_TARGETTYPE_NONE) { memberVarAssignmentName = this.readCachedString(); } @@ -799,7 +799,7 @@ cc.BuilderReader = cc.Class.extend({ if (!locActionManager.getRootNode()) locActionManager.setRootNode(node); - if (locJsControlled && node == locActionManager.getRootNode()) { + if (locJsControlled && node === locActionManager.getRootNode()) { locActionManager.setDocumentControllerName(jsControlledName); } @@ -855,7 +855,7 @@ cc.BuilderReader = cc.Class.extend({ node = embeddedNode; } var target = null, locMemberAssigner = null; - if (memberVarAssignmentType != CCB_TARGETTYPE_NONE) { + if (memberVarAssignmentType !== CCB_TARGETTYPE_NONE) { if (!locJsControlled) { if (memberVarAssignmentType === CCB_TARGETTYPE_DOCUMENTROOT) { target = locActionManager.getRootNode(); @@ -863,10 +863,10 @@ cc.BuilderReader = cc.Class.extend({ target = this._owner; } - if (target != null) { + if (target !== null) { var assigned = false; - if (target != null && (target.onAssignCCBMemberVariable)) { + if (target.onAssignCCBMemberVariable) { assigned = target.onAssignCCBMemberVariable(target, memberVarAssignmentName, node); } locMemberAssigner = this._ccbMemberVariableAssigner; @@ -875,7 +875,7 @@ cc.BuilderReader = cc.Class.extend({ } } } else { - if (memberVarAssignmentType == CCB_TARGETTYPE_DOCUMENTROOT) { + if (memberVarAssignmentType === CCB_TARGETTYPE_DOCUMENTROOT) { locActionManager.addDocumentOutletName(memberVarAssignmentName); locActionManager.addDocumentOutletNode(node); } else { @@ -928,8 +928,7 @@ cc.BuilderReader = cc.Class.extend({ }, _getBit:function () { - var bit = (this._data[this._currentByte] & (1 << this._currentBit)) != 0; - + var bit = (this._data[this._currentByte] & (1 << this._currentBit)) !== 0; this._currentBit++; if (this._currentBit >= 8) { @@ -938,7 +937,6 @@ cc.BuilderReader = cc.Class.extend({ if(this._currentByte > this._data.length) throw "out of the data bound"; } - return bit; }, @@ -980,7 +978,7 @@ cc.BuilderReader.load = function (ccbFilePath, owner, parentSize, ccbRootPath) { ccbRootPath = ccbRootPath || cc.BuilderReader.getResourcePath(); var reader = new cc.BuilderReader(cc.NodeLoaderLibrary.newDefaultCCNodeLoaderLibrary()); reader.setCCBRootPath(ccbRootPath); - if((ccbFilePath.length < 5)||(ccbFilePath.toLowerCase().lastIndexOf(".ccbi") != ccbFilePath.length - 5)) + if((ccbFilePath.length < 5)||(ccbFilePath.toLowerCase().lastIndexOf(".ccbi") !== ccbFilePath.length - 5)) ccbFilePath = ccbFilePath + ".ccbi"; var node = reader.readNodeGraphFromFile(ccbFilePath, owner, parentSize); @@ -1072,9 +1070,9 @@ cc.BuilderReader.load = function (ccbFilePath, owner, parentSize, ccbRootPath) { var callbackType = callbackSplit[0]; var kfCallbackName = callbackSplit[1]; - if (callbackType == 1){ // Document callback + if (callbackType === 1){ // Document callback animationManager.setCallFunc(cc.callFunc(controller[kfCallbackName], controller), keyframeCallbacks[j]); - } else if (callbackType == 2 && owner) {// Owner callback + } else if (callbackType === 2 && owner) {// Owner callback animationManager.setCallFunc(cc.callFunc(owner[kfCallbackName], owner), keyframeCallbacks[j]); } } @@ -1097,7 +1095,7 @@ cc.BuilderReader.getResourcePath = function () { cc.BuilderReader.lastPathComponent = function (pathStr) { var slashPos = pathStr.lastIndexOf("/"); - if (slashPos != -1) { + if (slashPos !== -1) { return pathStr.substring(slashPos + 1, pathStr.length - slashPos); } return pathStr; @@ -1105,7 +1103,7 @@ cc.BuilderReader.lastPathComponent = function (pathStr) { cc.BuilderReader.deletePathExtension = function (pathStr) { var dotPos = pathStr.lastIndexOf("."); - if (dotPos != -1) { + if (dotPos !== -1) { return pathStr.substring(0, dotPos); } return pathStr; @@ -1117,7 +1115,7 @@ cc.BuilderReader.toLowerCase = function (sourceStr) { cc.BuilderReader.endsWith = function (sourceStr, ending) { if (sourceStr.length >= ending.length) - return (sourceStr.lastIndexOf(ending) == 0); + return (sourceStr.lastIndexOf(ending) === 0); else return false; }; diff --git a/extensions/ccb-reader/CCControlLoader.js b/extensions/ccb-reader/CCControlLoader.js index 7e0bf1e499..901f8509dd 100644 --- a/extensions/ccb-reader/CCControlLoader.js +++ b/extensions/ccb-reader/CCControlLoader.js @@ -31,7 +31,7 @@ cc.BuilderFileLoader = cc.NodeLoader.extend({ return cc.BuilderFile.create(); }, onHandlePropTypeCCBFile:function (node, parent, propertyName, ccbFileNode, ccbReader) { - if (propertyName == PROPERTY_CCBFILE) { + if (propertyName === PROPERTY_CCBFILE) { node.setCCBFileNode(ccbFileNode); } else { cc.NodeLoader.prototype.onHandlePropTypeCCBFile.call(this, node, parent, propertyName, ccbFileNode, ccbReader); @@ -51,16 +51,16 @@ cc.ControlLoader = cc.NodeLoader.extend({ _createCCNode:function (parent, ccbReander) { }, onHandlePropTypeBlockCCControl:function (node, parent, propertyName, blockCCControlData, ccbReader) { - if (propertyName == PROPERTY_CCCONTROL) { + if (propertyName === PROPERTY_CCCONTROL) { node.addTargetWithActionForControlEvents(blockCCControlData.target, blockCCControlData.selCCControlHandler, blockCCControlData.controlEvents); } else { cc.NodeLoader.prototype.onHandlePropTypeBlockCCControl.call(this, node, parent, propertyName, blockCCControlData, ccbReader); } }, onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) { - if (propertyName == PROPERTY_ENABLED) { + if (propertyName === PROPERTY_ENABLED) { node.setEnabled(check); - } else if (propertyName == PROPERTY_SELECTED) { + } else if (propertyName === PROPERTY_SELECTED) { node.setSelected(check); } else { cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader); @@ -93,69 +93,69 @@ cc.ControlButtonLoader = cc.ControlLoader.extend({ }, onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) { - if (propertyName == PROPERTY_ZOOMONTOUCHDOWN) { + if (propertyName === PROPERTY_ZOOMONTOUCHDOWN) { node.setZoomOnTouchDown(check); } else { cc.ControlLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader); } }, onHandlePropTypeString:function (node, parent, propertyName, stringValue, ccbReader) { - if (propertyName == PROPERTY_TITLE_NORMAL) { + if (propertyName === PROPERTY_TITLE_NORMAL) { node.setTitleForState(stringValue, cc.CONTROL_STATE_NORMAL); - } else if (propertyName == PROPERTY_TITLE_HIGHLIGHTED) { + } else if (propertyName === PROPERTY_TITLE_HIGHLIGHTED) { node.setTitleForState(stringValue, cc.CONTROL_STATE_HIGHLIGHTED); - } else if (propertyName == PROPERTY_TITLE_DISABLED) { + } else if (propertyName === PROPERTY_TITLE_DISABLED) { node.setTitleForState(stringValue, cc.CONTROL_STATE_DISABLED); } else { cc.ControlLoader.prototype.onHandlePropTypeString.call(this, node, parent, propertyName, stringValue, ccbReader); } }, onHandlePropTypeFontTTF:function (node, parent, propertyName, fontTTF, ccbReader) { - if (propertyName == PROPERTY_TITLETTF_NORMAL) { + if (propertyName === PROPERTY_TITLETTF_NORMAL) { node.setTitleTTFForState(fontTTF, cc.CONTROL_STATE_NORMAL); - } else if (propertyName == PROPERTY_TITLETTF_HIGHLIGHTED) { + } else if (propertyName === PROPERTY_TITLETTF_HIGHLIGHTED) { node.setTitleTTFForState(fontTTF, cc.CONTROL_STATE_HIGHLIGHTED); - } else if (propertyName == PROPERTY_TITLETTF_DISABLED) { + } else if (propertyName === PROPERTY_TITLETTF_DISABLED) { node.setTitleTTFForState(fontTTF, cc.CONTROL_STATE_DISABLED); } else { cc.ControlLoader.prototype.onHandlePropTypeFontTTF.call(this, node, parent, propertyName, fontTTF, ccbReader); } }, onHandlePropTypeFloatScale:function (node, parent, propertyName, floatScale, ccbReader) { - if (propertyName == PROPERTY_TITLETTFSIZE_NORMAL) { + if (propertyName === PROPERTY_TITLETTFSIZE_NORMAL) { node.setTitleTTFSizeForState(floatScale, cc.CONTROL_STATE_NORMAL); - } else if (propertyName == PROPERTY_TITLETTFSIZE_HIGHLIGHTED) { + } else if (propertyName === PROPERTY_TITLETTFSIZE_HIGHLIGHTED) { node.setTitleTTFSizeForState(floatScale, cc.CONTROL_STATE_HIGHLIGHTED); - } else if (propertyName == PROPERTY_TITLETTFSIZE_DISABLED) { + } else if (propertyName === PROPERTY_TITLETTFSIZE_DISABLED) { node.setTitleTTFSizeForState(floatScale, cc.CONTROL_STATE_DISABLED); } else { cc.ControlLoader.prototype.onHandlePropTypeFloatScale.call(this, node, parent, propertyName, floatScale, ccbReader); } }, onHandlePropTypePoint:function (node, parent, propertyName, point, ccbReader) { - if (propertyName == PROPERTY_LABELANCHORPOINT) { + if (propertyName === PROPERTY_LABELANCHORPOINT) { node.setLabelAnchorPoint(point); } else { cc.ControlLoader.prototype.onHandlePropTypePoint.call(this, node, parent, propertyName, point, ccbReader); } }, onHandlePropTypeSize:function (node, parent, propertyName, size, ccbReader) { - if (propertyName == PROPERTY_PREFEREDSIZE) { + if (propertyName === PROPERTY_PREFEREDSIZE) { node.setPreferredSize(size); } else { cc.ControlLoader.prototype.onHandlePropTypeSize.call(this, node, parent, propertyName, size, ccbReader); } }, onHandlePropTypeSpriteFrame:function (node, parent, propertyName, spriteFrame, ccbReader) { - if (propertyName == PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) { + if (propertyName === PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) { if (spriteFrame != null) { node.setBackgroundSpriteFrameForState(spriteFrame, cc.CONTROL_STATE_NORMAL); } - } else if (propertyName == PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) { + } else if (propertyName === PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) { if (spriteFrame != null) { node.setBackgroundSpriteFrameForState(spriteFrame, cc.CONTROL_STATE_HIGHLIGHTED); } - } else if (propertyName == PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) { + } else if (propertyName === PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) { if (spriteFrame != null) { node.setBackgroundSpriteFrameForState(spriteFrame, cc.CONTROL_STATE_DISABLED); } @@ -164,11 +164,11 @@ cc.ControlButtonLoader = cc.ControlLoader.extend({ } }, onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) { - if (propertyName == PROPERTY_TITLECOLOR_NORMAL) { + if (propertyName === PROPERTY_TITLECOLOR_NORMAL) { node.setTitleColorForState(ccColor3B, cc.CONTROL_STATE_NORMAL); - } else if (propertyName == PROPERTY_TITLECOLOR_HIGHLIGHTED) { + } else if (propertyName === PROPERTY_TITLECOLOR_HIGHLIGHTED) { node.setTitleColorForState(ccColor3B, cc.CONTROL_STATE_HIGHLIGHTED); - } else if (propertyName == PROPERTY_TITLECOLOR_DISABLED) { + } else if (propertyName === PROPERTY_TITLECOLOR_DISABLED) { node.setTitleColorForState(ccColor3B, cc.CONTROL_STATE_DISABLED); } else { cc.ControlLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader); @@ -192,7 +192,7 @@ cc.ScrollViewLoader = cc.NodeLoader.extend({ }, onHandlePropTypeSize:function(node,parent,propertyName,size,ccbReader){ - if(propertyName == PROPERTY_CONTENTSIZE){ + if(propertyName === PROPERTY_CONTENTSIZE){ node.setViewSize(size); }else{ cc.NodeLoader.prototype.onHandlePropTypeSize.call(this, node,parent,propertyName,size,ccbReader); @@ -200,7 +200,7 @@ cc.ScrollViewLoader = cc.NodeLoader.extend({ }, onHandlePropTypeCCBFile:function (node, parent, propertyName, ccbFileNode, ccbReader) { - if (propertyName == PROPERTY_CONTAINER) { + if (propertyName === PROPERTY_CONTAINER) { node.setContainer(ccbFileNode); node.updateInset(); } else { @@ -208,23 +208,23 @@ cc.ScrollViewLoader = cc.NodeLoader.extend({ } }, onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) { - if (propertyName == PROPERTY_CLIPSTOBOUNDS) { + if (propertyName === PROPERTY_CLIPSTOBOUNDS) { node.setClippingToBounds(check); - } else if (propertyName == PROPERTY_BOUNCES) { + } else if (propertyName === PROPERTY_BOUNCES) { node.setBounceable(check); } else { cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader); } }, onHandlePropTypeFloat:function (node, parent, propertyName, floatValue, ccbReader) { - if (propertyName == PROPERTY_SCALE) { + if (propertyName === PROPERTY_SCALE) { node.setScale(floatValue); } else { cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this, node, parent, propertyName, floatValue, ccbReader); } }, onHandlePropTypeIntegerLabeled:function (node, parent, propertyName, integerLabeled, ccbReader) { - if (propertyName == PROPERTY_DIRECTION) { + if (propertyName === PROPERTY_DIRECTION) { node.setDirection(integerLabeled); } else { cc.NodeLoader.prototype.onHandlePropTypeIntegerLabeled.call(this, node, parent, propertyName, integerLabeled, ccbReader); @@ -256,7 +256,7 @@ cc.Scale9SpriteLoader = cc.NodeLoader.extend({ }, onHandlePropTypeColor3:function(node, parent, propertyName, ccColor3B,ccbReader){ - if(propertyName == PROPERTY_COLOR) { + if(propertyName === PROPERTY_COLOR) { if(ccColor3B.r !== 255 || ccColor3B.g !== 255 || ccColor3B.b !== 255){ node.setColor(ccColor3B); } @@ -265,14 +265,14 @@ cc.Scale9SpriteLoader = cc.NodeLoader.extend({ } }, onHandlePropTypeByte:function(node, parent, propertyName, byteValue,ccbReader){ - if(propertyName == PROPERTY_OPACITY) { + if(propertyName === PROPERTY_OPACITY) { node.setOpacity(byteValue); } else { cc.NodeLoader.prototype.onHandlePropTypeByte.call(this, node, parent, propertyName, byteValue,ccbReader); } }, onHandlePropTypeBlendFunc:function(node, parent, propertyName, ccBlendFunc,ccbReader){ - if(propertyName == PROPERTY_BLENDFUNC) { + if(propertyName === PROPERTY_BLENDFUNC) { // TODO Not exported by CocosBuilder yet! // node.setBlendFunc(ccBlendFunc); } else { @@ -280,29 +280,29 @@ cc.Scale9SpriteLoader = cc.NodeLoader.extend({ } }, onHandlePropTypeSpriteFrame:function(node, parent, propertyName, spriteFrame,ccbReader){ - if(propertyName == PROPERTY_SPRITEFRAME) { + if(propertyName === PROPERTY_SPRITEFRAME) { node.setSpriteFrame(spriteFrame); } else { cc.NodeLoader.prototype.onHandlePropTypeSpriteFrame.call(this, node, parent, propertyName, spriteFrame,ccbReader); } }, onHandlePropTypeSize:function(node, parent, propertyName, size,ccbReader){ - if(propertyName == PROPERTY_CONTENTSIZE) { + if(propertyName === PROPERTY_CONTENTSIZE) { //node.setContentSize(size); - } else if(propertyName == PROPERTY_PREFEREDSIZE) { + } else if(propertyName === PROPERTY_PREFEREDSIZE) { node.setPreferredSize(size); } else { cc.NodeLoader.prototype.onHandlePropTypeSize.call(this, node, parent, propertyName, size,ccbReader); } }, onHandlePropTypeFloat:function(node, parent, propertyName, floatValue,ccbReader){ - if(propertyName == PROPERTY_INSETLEFT) { + if(propertyName === PROPERTY_INSETLEFT) { node.setInsetLeft(floatValue); - } else if(propertyName == PROPERTY_INSETTOP) { + } else if(propertyName === PROPERTY_INSETTOP) { node.setInsetTop(floatValue); - } else if(propertyName == PROPERTY_INSETRIGHT) { + } else if(propertyName === PROPERTY_INSETRIGHT) { node.setInsetRight(floatValue); - } else if(propertyName == PROPERTY_INSETBOTTOM) { + } else if(propertyName === PROPERTY_INSETBOTTOM) { node.setInsetBottom(floatValue); } else { cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this, node, parent, propertyName, floatValue,ccbReader); diff --git a/extensions/ccb-reader/CCNodeLoader.js b/extensions/ccb-reader/CCNodeLoader.js index b00c01b377..67b575f41a 100644 --- a/extensions/ccb-reader/CCNodeLoader.js +++ b/extensions/ccb-reader/CCNodeLoader.js @@ -89,9 +89,9 @@ cc.NodeLoader = cc.Class.extend({ node = node.getCCBFileNode(); //skip properties that doesn't have a value to override var getExtraPropsNames = node.userObject; - setProp = getExtraPropsNames.indexOf(propertyName) != -1; + setProp = getExtraPropsNames.indexOf(propertyName) !== -1; } - } else if(isExtraProp && node == ccbReader.getAnimationManager().getRootNode()){ + } else if(isExtraProp && node === ccbReader.getAnimationManager().getRootNode()){ var extraPropsNames = node.userObject; if(!extraPropsNames){ extraPropsNames = []; @@ -418,7 +418,7 @@ cc.NodeLoader = cc.Class.extend({ ccbReader.getAnimationManager().setBaseValue([x,y,type],node,propertyName); } - if (type == CCB_SCALETYPE_MULTIPLY_RESOLUTION) { + if (type === CCB_SCALETYPE_MULTIPLY_RESOLUTION) { x *= cc.BuilderReader.getResolutionScale(); y *= cc.BuilderReader.getResolutionScale(); } @@ -443,7 +443,7 @@ cc.NodeLoader = cc.Class.extend({ var type = ccbReader.readInt(false); - if (type == CCB_SCALETYPE_MULTIPLY_RESOLUTION) { + if (type === CCB_SCALETYPE_MULTIPLY_RESOLUTION) { f *= cc.BuilderReader.getResolutionScale(); } @@ -477,8 +477,8 @@ cc.NodeLoader = cc.Class.extend({ var spriteFile = ccbReader.readCachedString(); var spriteFrame; - if(spriteFile != null && spriteFile.length != 0){ - if(spriteSheet.length == 0){ + if(spriteFile != null && spriteFile.length !== 0){ + if(spriteSheet.length === 0){ spriteFile = ccbReader.getCCBRootPath() + spriteFile; var texture = cc.textureCache.addImage(spriteFile); @@ -489,7 +489,7 @@ cc.NodeLoader = cc.Class.extend({ var frameCache = cc.spriteFrameCache; spriteSheet = ccbReader.getCCBRootPath() + spriteSheet; //load the sprite sheet only if it is not loaded - if(ccbReader.getLoadedSpriteSheet().indexOf(spriteSheet) == -1){ + if(ccbReader.getLoadedSpriteSheet().indexOf(spriteSheet) === -1){ frameCache.addSpriteFrames(spriteSheet); ccbReader.getLoadedSpriteSheet().push(spriteSheet); } @@ -517,7 +517,7 @@ cc.NodeLoader = cc.Class.extend({ animation = cc.BuilderReader.lastPathComponent(animation); animationFile = cc.BuilderReader.lastPathComponent(animationFile); - if (animation != null && animation != "") { + if (animation != null && animation !== "") { var animationCache = cc.animationCache; animationCache.addAnimations(animationFile); @@ -529,7 +529,7 @@ cc.NodeLoader = cc.Class.extend({ parsePropTypeTexture:function (node, parent, ccbReader) { var spriteFile = ccbReader.getCCBRootPath() + ccbReader.readCachedString(); - if(spriteFile != "") + if(spriteFile !== "") return cc.textureCache.addImage(spriteFile); return null; }, @@ -624,21 +624,21 @@ cc.NodeLoader = cc.Class.extend({ target = ccbReader.getOwner(); } - if (target != null) { + if (target !== null) { if (selectorName.length > 0) { var selMenuHandler = 0; //var targetAsCCBSelectorResolver = target; - if (target != null && target.onResolveCCBCCMenuItemSelector) + if (target.onResolveCCBCCMenuItemSelector) selMenuHandler = target.onResolveCCBCCMenuItemSelector(target, selectorName); - if (selMenuHandler == 0) { + if (selMenuHandler === 0) { var ccbSelectorResolver = ccbReader.getCCBSelectorResolver(); if (ccbSelectorResolver != null) selMenuHandler = ccbSelectorResolver.onResolveCCBCCMenuItemSelector(target, selectorName); } - if (selMenuHandler == 0) { + if (selMenuHandler === 0) { cc.log("Skipping selector '" +selectorName+ "' since no CCBSelectorResolver is present."); } else { return new BlockData(selMenuHandler,target); @@ -672,27 +672,27 @@ cc.NodeLoader = cc.Class.extend({ if (selectorTarget !== CCB_TARGETTYPE_NONE) { if(!ccbReader.isJSControlled()){ var target = null; - if (selectorTarget == CCB_TARGETTYPE_DOCUMENTROOT) { + if (selectorTarget === CCB_TARGETTYPE_DOCUMENTROOT) { target = ccbReader.getAnimationManager().getRootNode(); - } else if (selectorTarget == CCB_TARGETTYPE_OWNER) { + } else if (selectorTarget === CCB_TARGETTYPE_OWNER) { target = ccbReader.getOwner(); } - if (target != null) { + if (target !== null) { if (selectorName.length > 0) { var selCCControlHandler = 0; - if (target != null && target.onResolveCCBCCControlSelector) { + if (target.onResolveCCBCCControlSelector) { selCCControlHandler = target.onResolveCCBCCControlSelector(target, selectorName); } - if (selCCControlHandler == 0) { + if (selCCControlHandler === 0) { var ccbSelectorResolver = ccbReader.getCCBSelectorResolver(); if (ccbSelectorResolver != null) { selCCControlHandler = ccbSelectorResolver.onResolveCCBCCControlSelector(target, selectorName); } } - if (selCCControlHandler == 0) { + if (selCCControlHandler === 0) { cc.log("Skipping selector '" + selectorName + "' since no CCBSelectorResolver is present."); } else { return new BlockCCControlData(selCCControlHandler,target,controlEvents); @@ -704,7 +704,7 @@ cc.NodeLoader = cc.Class.extend({ cc.log("Unexpected NULL target for selector."); } } else { - if(selectorTarget == CCB_TARGETTYPE_DOCUMENTROOT){ + if(selectorTarget === CCB_TARGETTYPE_DOCUMENTROOT){ ccbReader.addDocumentCallbackNode(node); ccbReader.addDocumentCallbackName(selectorName); ccbReader.addDocumentCallbackControlEvents(controlEvents); @@ -740,10 +740,9 @@ cc.NodeLoader = cc.Class.extend({ myCCBReader.getAnimationManager().setOwner(ccbReader.getOwner()); var ccbFileNode = myCCBReader.readFileWithCleanUp(false); - ccbReader.setAnimationManagers(myCCBReader.getAnimationManagers()); - if(ccbFileNode && myCCBReader.getAnimationManager().getAutoPlaySequenceId() != -1) + if(ccbFileNode && myCCBReader.getAnimationManager().getAutoPlaySequenceId() !== -1) myCCBReader.getAnimationManager().runAnimations(myCCBReader.getAnimationManager().getAutoPlaySequenceId(),0); return ccbFileNode; diff --git a/extensions/ccb-reader/CCSpriteLoader.js b/extensions/ccb-reader/CCSpriteLoader.js index b1ba28e7ac..857b2bb025 100644 --- a/extensions/ccb-reader/CCSpriteLoader.js +++ b/extensions/ccb-reader/CCSpriteLoader.js @@ -171,7 +171,7 @@ cc.LayerGradientLoader = cc.LayerLoader.extend({ onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) { if (propertyName === PROPERTY_STARTCOLOR) { node.setStartColor(ccColor3B); - } else if (propertyName == PROPERTY_ENDCOLOR) { + } else if (propertyName === PROPERTY_ENDCOLOR) { node.setEndColor(ccColor3B); } else { cc.LayerLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader); diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js index 8c930642c3..205c8a2295 100644 --- a/extensions/ccpool/CCPool.js +++ b/extensions/ccpool/CCPool.js @@ -84,7 +84,7 @@ cc.pool = /** @lends cc.pool# */{ hasObject: function (objClass) { var pid = objClass.prototype.__pid; var list = this._pool[pid]; - if (!list || list.length == 0) { + if (!list || list.length === 0) { return false; } return true; diff --git a/extensions/ccui/base-classes/CCProtectedNode.js b/extensions/ccui/base-classes/CCProtectedNode.js index c9f8d9f812..ad1e3c8f90 100644 --- a/extensions/ccui/base-classes/CCProtectedNode.js +++ b/extensions/ccui/base-classes/CCProtectedNode.js @@ -85,10 +85,10 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ * @return {cc.Node} a Node object whose tag equals to the input parameter */ getProtectedChildByTag: function(tag){ - cc.assert(tag != cc.NODE_TAG_INVALID, "Invalid tag"); + cc.assert(tag !== cc.NODE_TAG_INVALID, "Invalid tag"); var locChildren = this._protectedChildren; for(var i = 0, len = locChildren.length; i < len; i++) - if(locChildren.getTag() == tag) + if(locChildren.getTag() === tag) return locChildren[i]; return null; }, @@ -129,7 +129,7 @@ cc.ProtectedNode = cc.Node.extend(/** @lends cc.ProtectedNode# */{ * @param {Boolean} [cleanup=true] */ removeProtectedChildByTag: function(tag, cleanup){ - cc.assert( tag != cc.NODE_TAG_INVALID, "Invalid tag"); + cc.assert( tag !== cc.NODE_TAG_INVALID, "Invalid tag"); if(cleanup == null) cleanup = true; diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index 476c790a5f..bcac0b4834 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -120,7 +120,7 @@ cc.kmMat4Multiply(stackMatrix, parentMatrix, t4x4); // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if (node._camera != null && !(node.grid != null && node.grid.isActive())) { + if (node._camera !== null && !(node.grid !== null && node.grid.isActive())) { var apx = this._anchorPointInPoints.x, apy = this._anchorPointInPoints.y; var translate = (apx !== 0.0 || apy !== 0.0); if (translate){ diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index e36ee5d569..813ceae5c1 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -150,15 +150,15 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ var leftWidth = locBottomLeftContentSize.width; var bottomHeight = locBottomLeftContentSize.height; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + if (cc._renderType === cc._RENDER_TYPE_WEBGL) { //browser is in canvas mode, need to manually control rounding to prevent overlapping pixels var roundedRescaledWidth = Math.round(rescaledWidth); - if (rescaledWidth != roundedRescaledWidth) { + if (rescaledWidth !== roundedRescaledWidth) { rescaledWidth = roundedRescaledWidth; horizontalScale = rescaledWidth / locCenterContentSize.width; } var roundedRescaledHeight = Math.round(rescaledHeight); - if (rescaledHeight != roundedRescaledHeight) { + if (rescaledHeight !== roundedRescaledHeight) { rescaledHeight = roundedRescaledHeight; verticalScale = rescaledHeight / locCenterContentSize.height; } @@ -502,7 +502,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); - this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); + this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); @@ -510,7 +510,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ } var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9); // the texture is rotated on Canvas render mode, so isRotated always is false. - return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets); + return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets); }, /** @@ -592,7 +592,7 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ // Release old sprites this.removeAllChildren(true); - if (this._scale9Image != batchNode) + if (this._scale9Image !== batchNode) this._scale9Image = batchNode; if(!this._scale9Image) @@ -902,13 +902,13 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); - this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); + this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); },this); } - this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0)); + this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0)); // Reset insets this._insetLeft = 0; diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index 7c5abde255..1dc9ae4734 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -105,7 +105,7 @@ var locCanvas = this._cacheCanvas, wrapper = this._cacheContext, locContext = wrapper.getContext(); var contentSizeChanged = false; - if(locCanvas.width != sizeInPixels.width || locCanvas.height != sizeInPixels.height){ + if(locCanvas.width !== sizeInPixels.width || locCanvas.height !== sizeInPixels.height){ locCanvas.width = sizeInPixels.width; locCanvas.height = sizeInPixels.height; contentSizeChanged = true; diff --git a/extensions/ccui/base-classes/UIWidget.js b/extensions/ccui/base-classes/UIWidget.js index d3cea43929..b7e7a16f76 100644 --- a/extensions/ccui/base-classes/UIWidget.js +++ b/extensions/ccui/base-classes/UIWidget.js @@ -30,7 +30,7 @@ ccui._FocusNavigationController = cc.Class.extend({ _keyboardEventPriority: 1, enableFocusNavigation: function(flag){ - if (this._enableFocusNavigation == flag) + if (this._enableFocusNavigation === flag) return; this._enableFocusNavigation = flag; @@ -46,16 +46,16 @@ ccui._FocusNavigationController = cc.Class.extend({ _onKeyPressed: function(keyCode, event){ if (this._enableFocusNavigation && this._firstFocusedWidget) { - if (keyCode == cc.KEY.dpadDown) { + if (keyCode === cc.KEY.dpadDown) { this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.DOWN, this._firstFocusedWidget); } - if (keyCode == cc.KEY.dpadUp){ + if (keyCode === cc.KEY.dpadUp){ this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.UP, this._firstFocusedWidget); } - if (keyCode == cc.KEY.dpadLeft) { + if (keyCode === cc.KEY.dpadLeft) { this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.LEFT, this._firstFocusedWidget); } - if (keyCode == cc.KEY.dpadRight) { + if (keyCode === cc.KEY.dpadRight) { this._firstFocusedWidget = this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.RIGHT, this._firstFocusedWidget); } } @@ -329,7 +329,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._touchListener = null; //cleanup focused widget and focus navigation controller - if (ccui.Widget._focusedWidget == this){ + if (ccui.Widget._focusedWidget === this){ ccui.Widget._focusedWidget = null; ccui.Widget._focusNavigationController = null; } @@ -542,7 +542,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._sizeType = type; if (this._usingLayoutComponent) { var component = this._getOrCreateLayoutComponent(); - component.setUsingPercentContentSize(this._sizeType == ccui.SIZE_PERCENT); + component.setUsingPercentContentSize(this._sizeType === ccui.SIZE_PERCENT); } }, @@ -564,7 +564,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return; } - if(this._ignoreSize == ignore) + if(this._ignoreSize === ignore) return; this._ignoreSize = ignore; @@ -696,7 +696,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param highlight true if the widget is highlighted, false if the widget is not highlighted. */ setHighlighted:function(highlight){ - if (highlight == this._highlight) + if (highlight === this._highlight) return; this._highlight = highlight; if (this._bright) { @@ -757,11 +757,11 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @return the next focused widget in a layout */ findNextFocusedWidget: function( direction, current){ - if (null == this.onNextFocusedWidget || null == this.onNextFocusedWidget(direction) ) { + if (null === this.onNextFocusedWidget || null == this.onNextFocusedWidget(direction) ) { var isLayout = current instanceof ccui.Layout; if (this.isFocused() || isLayout) { var layout = this.getParent(); - if (null == layout || !(layout instanceof ccui.Layout)){ + if (null === layout || !(layout instanceof ccui.Layout)){ //the outer layout's default behaviour is : loop focus if (isLayout) return current.findNextFocusedWidget(direction, current); @@ -781,7 +781,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * when a widget calls this method, it will get focus immediately. */ requestFocus: function(){ - if (this == ccui.Widget._focusedWidget) + if (this === ccui.Widget._focusedWidget) return; this.dispatchFocusEvent(ccui.Widget._focusedWidget, this); }, @@ -841,7 +841,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ if (widgetLostFocus && !widgetLostFocus.isFocused()) widgetLostFocus = ccui.Widget._focusedWidget; - if (widgetGetFocus != widgetLostFocus){ + if (widgetGetFocus !== widgetLostFocus){ if (widgetGetFocus && widgetGetFocus.onFocusChanged) widgetGetFocus.onFocusChanged(widgetLostFocus, widgetGetFocus); if (widgetLostFocus && widgetGetFocus.onFocusChanged) @@ -868,9 +868,9 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ * @param {Number} style BRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state. */ setBrightStyle: function (style) { - if (this._brightStyle == style) { + if (this._brightStyle === style) return; - } + style = style || ccui.Widget.BRIGHT_STYLE_NORMAL; this._brightStyle = style; switch (this._brightStyle) { @@ -1136,7 +1136,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._positionPercent.x = 0; this._positionPercent.y = 0; } else { - if (posY == undefined) { + if (posY === undefined) { this._positionPercent.x = pos.x / pSize.width; this._positionPercent.y = pos.y / pSize.height; } else { @@ -1254,7 +1254,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ this._positionType = type; if(this._usingLayoutComponent){ var component = this._getOrCreateLayoutComponent(); - if (type == ccui.POSITION_ABSOLUTE){ + if (type === ccui.POSITION_ABSOLUTE){ component.setPositionPercentXEnabled(false); component.setPositionPercentYEnabled(false); } else { @@ -1645,7 +1645,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ var _nodes = this._nodes; for (var i = 0; i < _nodes.length; i++) { var node = _nodes[i]; - if (node && node.getTag() == tag) { + if (node && node.getTag() === tag) { return node; } } @@ -1768,7 +1768,7 @@ ccui.Widget = ccui.ProtectedNode.extend(/** @lends ccui.Widget# */{ return originalScale; }, getScale: function(){ - if(this.getScaleX() == this.getScaleY()) + if(this.getScaleX() === this.getScaleY()) cc.log("Widget#scale. ScaleX != ScaleY. Don't know which one to return"); return this.getScaleX(); }, diff --git a/extensions/ccui/layouts/UILayout.js b/extensions/ccui/layouts/UILayout.js index 08bb627824..99b242c2ae 100644 --- a/extensions/ccui/layouts/UILayout.js +++ b/extensions/ccui/layouts/UILayout.js @@ -176,7 +176,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ parent._isFocusPassing = true; return parent.findNextFocusedWidget(direction, this); } else if(current.isFocused() || current instanceof ccui.Layout) { - if (this._layoutType == ccui.Layout.LINEAR_HORIZONTAL) { + if (this._layoutType === ccui.Layout.LINEAR_HORIZONTAL) { switch (direction){ case ccui.Widget.LEFT: return this._getPreviousFocusedWidget(direction, current); @@ -198,7 +198,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ cc.assert(0, "Invalid Focus Direction"); return current; } - } else if (this._layoutType == ccui.Layout.LINEAR_VERTICAL) { + } else if (this._layoutType === ccui.Layout.LINEAR_VERTICAL) { switch (direction){ case ccui.Widget.LEFT: case ccui.Widget.RIGHT: @@ -340,7 +340,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {Boolean} able clipping enabled. */ setClippingEnabled: function (able) { - if (able == this._clippingEnabled) + if (able === this._clippingEnabled) return; this._clippingEnabled = able; switch (this._clippingType) { @@ -367,9 +367,9 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Layout.CLIPPING_STENCIL|ccui.Layout.CLIPPING_SCISSOR} type */ setClippingType: function (type) { - if (type == this._clippingType) + if (type === this._clippingType) return; - if(cc._renderType === cc._RENDER_TYPE_CANVAS && type == ccui.Layout.CLIPPING_SCISSOR){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS && type === ccui.Layout.CLIPPING_SCISSOR){ cc.log("Only supports STENCIL on canvas mode."); return; } @@ -388,7 +388,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ }, _setStencilClippingSize: function (size) { - if (this._clippingEnabled && this._clippingType == ccui.Layout.CLIPPING_STENCIL) { + if (this._clippingEnabled && this._clippingType === ccui.Layout.CLIPPING_STENCIL) { var rect = []; rect[0] = cc.p(0, 0); rect[1] = cc.p(size.width, 0); @@ -481,7 +481,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {Boolean} able true that use scale9 renderer, false otherwise. */ setBackGroundImageScale9Enabled: function (able) { - if (this._backGroundScale9Enabled == able) + if (this._backGroundScale9Enabled === able) return; this.removeProtectedChild(this._backGroundImage); this._backGroundImage = null; @@ -508,7 +508,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ if (!fileName) return; texType = texType || ccui.Widget.LOCAL_TEXTURE; - if (this._backGroundImage == null){ + if (this._backGroundImage === null){ this._addBackGroundImage(); this.setBackGroundImageScale9Enabled(this._backGroundScale9Enabled); } @@ -609,7 +609,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @param {ccui.Layout.BG_COLOR_NONE|ccui.Layout.BG_COLOR_SOLID|ccui.Layout.BG_COLOR_GRADIENT} type */ setBackGroundColorType: function (type) { - if (this._colorType == type) + if (this._colorType === type) return; switch (this._colorType) { case ccui.Layout.BG_COLOR_NONE: @@ -897,7 +897,7 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var widgetCount = 0, locSize; for(var i = 0, len = children.length; i < len; i++) { var layout = children[i]; - if (null != layout && layout instanceof ccui.Layout){ + if (null !== layout && layout instanceof ccui.Layout){ locSize = layout._getLayoutAccumulatedSize(); layoutSize.width += locSize.width; layoutSize.height += locSize.height; @@ -914,10 +914,10 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ //substract extra size var type = this.getLayoutType(); - if (type == ccui.Layout.LINEAR_HORIZONTAL) + if (type === ccui.Layout.LINEAR_HORIZONTAL) layoutSize.height = layoutSize.height - layoutSize.height/widgetCount * (widgetCount-1); - if (type == ccui.Layout.LINEAR_VERTICAL) + if (type === ccui.Layout.LINEAR_VERTICAL) layoutSize.width = layoutSize.width - layoutSize.width/widgetCount * (widgetCount-1); return layoutSize; }, @@ -931,14 +931,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @private */ _findNearestChildWidgetIndex: function(direction, baseWidget){ - if (baseWidget == null || baseWidget == this) + if (baseWidget == null || baseWidget === this) return this._findFirstFocusEnabledWidgetIndex(); var index = 0, locChildren = this.getChildren(); var count = locChildren.length, widgetPosition; var distance = cc.FLT_MAX, found = 0; - if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT || direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) { + if (direction === ccui.Widget.LEFT || direction === ccui.Widget.RIGHT || direction === ccui.Widget.DOWN || direction === ccui.Widget.UP) { widgetPosition = this._getWorldCenterPoint(baseWidget); while (index < count) { var w = locChildren[index]; @@ -967,14 +967,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ * @private */ _findFarthestChildWidgetIndex: function(direction, baseWidget){ - if (baseWidget == null || baseWidget == this) + if (baseWidget == null || baseWidget === this) return this._findFirstFocusEnabledWidgetIndex(); var index = 0, locChildren = this.getChildren(); var count = locChildren.length; var distance = -cc.FLT_MAX, found = 0; - if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT || direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) { + if (direction === ccui.Widget.LEFT || direction === ccui.Widget.RIGHT || direction === ccui.Widget.DOWN || direction === ccui.Widget.UP) { var widgetPosition = this._getWorldCenterPoint(baseWidget); while (index < count) { var w = locChildren[index]; @@ -1063,16 +1063,16 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var previousWidgetPosition = this._getWorldCenterPoint(baseWidget); var widgetPosition = this._getWorldCenterPoint(this._findFirstNonLayoutWidget()); - if (direction == ccui.Widget.LEFT) { + if (direction === ccui.Widget.LEFT) { this.onPassFocusToChild = (previousWidgetPosition.x > widgetPosition.x) ? this._findNearestChildWidgetIndex.bind(this) : this._findFarthestChildWidgetIndex.bind(this); - } else if (direction == ccui.Widget.RIGHT) { + } else if (direction === ccui.Widget.RIGHT) { this.onPassFocusToChild = (previousWidgetPosition.x > widgetPosition.x) ? this._findFarthestChildWidgetIndex.bind(this) : this._findNearestChildWidgetIndex.bind(this); - }else if(direction == ccui.Widget.DOWN) { + }else if(direction === ccui.Widget.DOWN) { this.onPassFocusToChild = (previousWidgetPosition.y > widgetPosition.y) ? this._findNearestChildWidgetIndex.bind(this) : this._findFarthestChildWidgetIndex.bind(this); - }else if(direction == ccui.Widget.UP) { + }else if(direction === ccui.Widget.UP) { this.onPassFocusToChild = (previousWidgetPosition.y < widgetPosition.y) ? this._findNearestChildWidgetIndex.bind(this) : this._findFarthestChildWidgetIndex.bind(this); }else @@ -1293,41 +1293,41 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ var container = parent.getChildren(); var index = container.indexOf(widget); - if (parent.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) { - if (direction == ccui.Widget.LEFT) { - if (index == 0) + if (parent.getLayoutType() === ccui.Layout.LINEAR_HORIZONTAL) { + if (direction === ccui.Widget.LEFT) { + if (index === 0) return this._isLastWidgetInContainer(parent, direction); else return false; } - if (direction == ccui.Widget.RIGHT) { - if (index == container.length - 1) + if (direction === ccui.Widget.RIGHT) { + if (index === container.length - 1) return this._isLastWidgetInContainer(parent, direction); else return false; } - if (direction == ccui.Widget.DOWN) + if (direction === ccui.Widget.DOWN) return this._isLastWidgetInContainer(parent, direction); - if (direction == ccui.Widget.UP) + if (direction === ccui.Widget.UP) return this._isLastWidgetInContainer(parent, direction); - } else if(parent.getLayoutType() == ccui.Layout.LINEAR_VERTICAL){ - if (direction == ccui.Widget.UP){ - if (index == 0) + } else if(parent.getLayoutType() === ccui.Layout.LINEAR_VERTICAL){ + if (direction === ccui.Widget.UP){ + if (index === 0) return this._isLastWidgetInContainer(parent, direction); else return false; } - if (direction == ccui.Widget.DOWN) { - if (index == container.length - 1) + if (direction === ccui.Widget.DOWN) { + if (index === container.length - 1) return this._isLastWidgetInContainer(parent, direction); else return false; } - if (direction == ccui.Widget.LEFT) + if (direction === ccui.Widget.LEFT) return this._isLastWidgetInContainer(parent, direction); - if (direction == ccui.Widget.RIGHT) + if (direction === ccui.Widget.RIGHT) return this._isLastWidgetInContainer(parent, direction); } else { cc.log("invalid layout Type"); @@ -1348,14 +1348,14 @@ ccui.Layout = ccui.Widget.extend(/** @lends ccui.Layout# */{ return false; if (parent.isLoopFocus()) { var layoutType = parent.getLayoutType(); - if (layoutType == ccui.Layout.LINEAR_HORIZONTAL) { - if (direction == ccui.Widget.LEFT || direction == ccui.Widget.RIGHT) + if (layoutType === ccui.Layout.LINEAR_HORIZONTAL) { + if (direction === ccui.Widget.LEFT || direction === ccui.Widget.RIGHT) return true; else return this._isWidgetAncestorSupportLoopFocus(parent, direction); } - if (layoutType == ccui.Layout.LINEAR_VERTICAL){ - if (direction == ccui.Widget.DOWN || direction == ccui.Widget.UP) + if (layoutType === ccui.Layout.LINEAR_VERTICAL){ + if (direction === ccui.Widget.DOWN || direction === ccui.Widget.UP) return true; else return this._isWidgetAncestorSupportLoopFocus(parent, direction); diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index a178d9ed8d..ed7182def5 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -137,7 +137,7 @@ ccui.LayoutComponent = cc.Component.extend({ x = position; var parentSize = parent.getContentSize(); - if (parentSize.width != 0) + if (parentSize.width !== 0) this._positionPercentX = x / parentSize.width; else { this._positionPercentX = 0; @@ -145,7 +145,7 @@ ccui.LayoutComponent = cc.Component.extend({ x = 0; } - if (parentSize.height != 0) + if (parentSize.height !== 0) this._positionPercentY = y / parentSize.height; else { this._positionPercentY = 0; @@ -176,7 +176,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._positionPercentX = percentMargin; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { this._owner.setPositionX(parent.width * this._positionPercentX); this._refreshHorizontalMargin(); } @@ -198,7 +198,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._positionPercentY = percentMargin; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { this._owner.setPositionY(parent.height * this._positionPercentY); this._refreshVerticalMargin(); } @@ -209,14 +209,14 @@ ccui.LayoutComponent = cc.Component.extend({ }, setHorizontalEdge: function (hEdge) { this._horizontalEdge = hEdge; - if (this._horizontalEdge != ccui.LayoutComponent.horizontalEdge.NONE) + if (this._horizontalEdge !== ccui.LayoutComponent.horizontalEdge.NONE) this._usingPositionPercentX = false; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { var ownerPoint = this._owner.getPosition(); var parentSize = parent.getContentSize(); - if (parentSize.width != 0) + if (parentSize.width !== 0) this._positionPercentX = ownerPoint.x / parentSize.width; else { this._positionPercentX = 0; @@ -233,14 +233,14 @@ ccui.LayoutComponent = cc.Component.extend({ }, setVerticalEdge: function (vEdge) { this._verticalEdge = vEdge; - if (this._verticalEdge != ccui.LayoutComponent.verticalEdge.NONE) + if (this._verticalEdge !== ccui.LayoutComponent.verticalEdge.NONE) this._usingPositionPercentY = false; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { var ownerPoint = this._owner.getPosition(); var parentSize = parent.getContentSize(); - if (parentSize.height != 0) + if (parentSize.height !== 0) this._positionPercentY = ownerPoint.y / parentSize.height; else { this._positionPercentY = 0; @@ -286,10 +286,10 @@ ccui.LayoutComponent = cc.Component.extend({ }, setSize: function (size) { var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { var ownerSize = size, parentSize = parent.getContentSize(); - if (parentSize.width != 0) + if (parentSize.width !== 0) this._percentWidth = ownerSize.width / parentSize.width; else { this._percentWidth = 0; @@ -297,7 +297,7 @@ ccui.LayoutComponent = cc.Component.extend({ ownerSize.width = 0; } - if (parentSize.height != 0) + if (parentSize.height !== 0) this._percentHeight = ownerSize.height / parentSize.height; else { this._percentHeight = 0; @@ -331,9 +331,9 @@ ccui.LayoutComponent = cc.Component.extend({ ownerSize.width = width; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { var parentSize = parent.getContentSize(); - if (parentSize.width != 0) + if (parentSize.width !== 0) this._percentWidth = ownerSize.width / parentSize.width; else { this._percentWidth = 0; @@ -353,7 +353,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._percentWidth = percentWidth; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { var ownerSize = this._owner.getContentSize(); ownerSize.width = parent.width * this._percentWidth; this._owner.setContentSize(ownerSize); @@ -378,9 +378,9 @@ ccui.LayoutComponent = cc.Component.extend({ ownerSize.height = height; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { var parentSize = parent.getContentSize(); - if (parentSize.height != 0) + if (parentSize.height !== 0) this._percentHeight = ownerSize.height / parentSize.height; else { this._percentHeight = 0; @@ -401,7 +401,7 @@ ccui.LayoutComponent = cc.Component.extend({ this._percentHeight = percentHeight; var parent = this._getOwnerParent(); - if (parent != null) { + if (parent !== null) { var ownerSize = this._owner.getContentSize(); ownerSize.height = parent.height * this._percentHeight; this._owner.setContentSize(ownerSize); @@ -439,7 +439,7 @@ ccui.LayoutComponent = cc.Component.extend({ return; var parent = this._getOwnerParent(); - if (parent == null) + if (parent === null) return; var parentSize = parent.getContentSize(), locOwner = this._owner; @@ -545,7 +545,7 @@ ccui.LayoutComponent = cc.Component.extend({ }, _refreshHorizontalMargin: function () { var parent = this._getOwnerParent(); - if (parent == null) + if (parent === null) return; var ownerPoint = this._owner.getPosition(), ownerAnchor = this._owner.getAnchorPoint(); @@ -556,7 +556,7 @@ ccui.LayoutComponent = cc.Component.extend({ }, _refreshVerticalMargin: function () { var parent = this._getOwnerParent(); - if (parent == null) + if (parent === null) return; var ownerPoint = this._owner.getPosition(), ownerAnchor = this._owner.getAnchorPoint(); @@ -573,7 +573,7 @@ ccui.LayoutComponent.verticalEdge = {NONE: 0, BOTTOM: 1, TOP: 2, CENTER: 3}; ccui.LayoutComponent.NAME = "__ui_layout"; ccui.LayoutComponent.bindLayoutComponent = function (node) { var layout = node.getComponent(ccui.LayoutComponent.NAME); - if (layout != null) + if (layout !== null) return layout; layout = new ccui.LayoutComponent(); diff --git a/extensions/ccui/layouts/UILayoutManager.js b/extensions/ccui/layouts/UILayoutManager.js index d24e8996ab..e12cc31333 100644 --- a/extensions/ccui/layouts/UILayoutManager.js +++ b/extensions/ccui/layouts/UILayoutManager.js @@ -191,13 +191,13 @@ ccui.relativeLayoutManager = /** @lends ccui.relativeLayoutManager# */{ var layoutParameter = widget.getLayoutParameter(); var relativeName = layoutParameter.getRelativeToWidgetName(); - if (relativeName && relativeName.length != 0) { + if (relativeName && relativeName.length !== 0) { var locChildren = this._widgetChildren; for(var i = 0, len = locChildren.length; i < len; i++){ var child = locChildren[i]; if (child){ var rlayoutParameter = child.getLayoutParameter(); - if (rlayoutParameter && rlayoutParameter.getRelativeName() == relativeName) { + if (rlayoutParameter && rlayoutParameter.getRelativeName() === relativeName) { relativeWidget = child; this._relativeWidgetLP = rlayoutParameter; break; diff --git a/extensions/ccui/layouts/UILayoutParameter.js b/extensions/ccui/layouts/UILayoutParameter.js index c90d34de86..2ea2919426 100644 --- a/extensions/ccui/layouts/UILayoutParameter.js +++ b/extensions/ccui/layouts/UILayoutParameter.js @@ -78,7 +78,7 @@ ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{ * @returns {boolean} */ equals: function (target) { - return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom); + return (this.left === target.left && this.top === target.top && this.right === target.right && this.bottom === target.bottom); } }); diff --git a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js index 4ec484d55e..d46e1e8939 100644 --- a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js @@ -170,7 +170,7 @@ return; // all the _stencilBits are in use? - if (ccui.Layout.WebGLRenderCmd._layer + 1 == cc.stencilBits) { + if (ccui.Layout.WebGLRenderCmd._layer + 1 === cc.stencilBits) { // warn once ccui.Layout.WebGLRenderCmd._visit_once = true; if (ccui.Layout.WebGLRenderCmd._visit_once) { diff --git a/extensions/ccui/system/UIHelper.js b/extensions/ccui/system/UIHelper.js index 2c0263b35f..70d82c9b84 100644 --- a/extensions/ccui/system/UIHelper.js +++ b/extensions/ccui/system/UIHelper.js @@ -41,7 +41,7 @@ ccui.helper = { seekWidgetByTag: function (root, tag) { if (!root) return null; - if (root.getTag() == tag) + if (root.getTag() === tag) return root; var arrayRootChildren = root.getChildren(); @@ -49,7 +49,7 @@ ccui.helper = { for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; var res = ccui.helper.seekWidgetByTag(child, tag); - if (res != null) + if (res !== null) return res; } return null; @@ -64,14 +64,14 @@ ccui.helper = { seekWidgetByName: function (root, name) { if (!root) return null; - if (root.getName() == name) + if (root.getName() === name) return root; var arrayRootChildren = root.getChildren(); var length = arrayRootChildren.length; for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; var res = ccui.helper.seekWidgetByName(child, name); - if (res != null) + if (res !== null) return res; } return null; @@ -92,7 +92,7 @@ ccui.helper = { for (var i = 0; i < length; i++) { var child = arrayRootChildren[i]; var layoutParameter = child.getLayoutParameter(ccui.LayoutParameter.RELATIVE); - if (layoutParameter && layoutParameter.getRelativeName() == name) + if (layoutParameter && layoutParameter.getRelativeName() === name) return child; } return null; @@ -107,13 +107,13 @@ ccui.helper = { seekActionWidgetByActionTag: function (root, tag) { if (!root) return null; - if (root.getActionTag() == tag) + if (root.getActionTag() === tag) return root; var arrayRootChildren = root.getChildren(); for (var i = 0; i < arrayRootChildren.length; i++) { var child = arrayRootChildren[i]; var res = ccui.helper.seekActionWidgetByActionTag(child, tag); - if (res != null) + if (res !== null) return res; } return null; @@ -132,7 +132,7 @@ ccui.helper = { node = children[i]; var com = node.getComponent(ccui.LayoutComponent.NAME); var parent = node.getParent(); - if (null != com && null != parent && com.refreshLayout) + if (null != com && null !== parent && com.refreshLayout) com.refreshLayout(); } }, diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index dd76a26d8a..3ee086fbbc 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -144,7 +144,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ */ setScale9Enabled: function (able) { //todo create Scale9Sprite - if (this._scale9Enabled == able) + if (this._scale9Enabled === able) return; this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE; @@ -750,7 +750,7 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ * @param {String} text */ setTitleText: function (text) { - if(text == this.getTitleText()) + if(text === this.getTitleText()) return; this._titleRenderer.setString(text); if (this._ignoreSize){ @@ -900,11 +900,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ _getNormalSize: function(){ var titleSize; - if (this._titleRenderer != null) + if (this._titleRenderer !== null) titleSize = this._titleRenderer.getContentSize(); var imageSize; - if (this._buttonNormalRenderer != null) + if (this._buttonNormalRenderer !== null) imageSize = this._buttonNormalRenderer.getContentSize(); var width = titleSize.width > imageSize.width ? titleSize.width : imageSize.width; var height = titleSize.height > imageSize.height ? titleSize.height : imageSize.height; diff --git a/extensions/ccui/uiwidgets/UICheckBox.js b/extensions/ccui/uiwidgets/UICheckBox.js index dbe967c859..dc4b3ed922 100644 --- a/extensions/ccui/uiwidgets/UICheckBox.js +++ b/extensions/ccui/uiwidgets/UICheckBox.js @@ -84,7 +84,7 @@ ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{ var strNum = 0; for(var i=0; i 0 && cutWords != " "; + validLeftLength = leftLength > 0 && cutWords !== " "; } if (validLeftLength) { @@ -492,11 +491,11 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ } //Text flow horizontal alignment: - if(this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT) { + if(this._textHorizontalAlignment !== cc.TEXT_ALIGNMENT_LEFT) { var offsetX = 0; - if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_RIGHT) + if (this._textHorizontalAlignment === cc.TEXT_ALIGNMENT_RIGHT) offsetX = this._contentSize.width - nextPosX; - else if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_CENTER) + else if (this._textHorizontalAlignment === cc.TEXT_ALIGNMENT_CENTER) offsetX = (this._contentSize.width - nextPosX) / 2; for (j = 0; j < row.length; j++) @@ -534,17 +533,17 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ nextPosX += l.getContentSize().width; } //Text flow alignment(s) - if( this._textHorizontalAlignment != cc.TEXT_ALIGNMENT_LEFT || this._textVerticalAlignment != cc.VERTICAL_TEXT_ALIGNMENT_TOP) { + if( this._textHorizontalAlignment !== cc.TEXT_ALIGNMENT_LEFT || this._textVerticalAlignment !== cc.VERTICAL_TEXT_ALIGNMENT_TOP) { var offsetX = 0; - if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_RIGHT) + if (this._textHorizontalAlignment === cc.TEXT_ALIGNMENT_RIGHT) offsetX = this._contentSize.width - nextPosX; - else if (this._textHorizontalAlignment == cc.TEXT_ALIGNMENT_CENTER) + else if (this._textHorizontalAlignment === cc.TEXT_ALIGNMENT_CENTER) offsetX = (this._contentSize.width - nextPosX) / 2; var offsetY = 0; - if (this._textVerticalAlignment == cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) + if (this._textVerticalAlignment === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM) offsetY = this._customSize.height - newContentSizeHeight; - else if (this._textVerticalAlignment == cc.VERTICAL_TEXT_ALIGNMENT_CENTER) + else if (this._textVerticalAlignment === cc.VERTICAL_TEXT_ALIGNMENT_CENTER) offsetY = (this._customSize.height - newContentSizeHeight) / 2; for (j = 0; j < row.length; j++) { @@ -621,7 +620,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @override */ ignoreContentAdaptWithSize: function (ignore) { - if (this._ignoreSize != ignore) { + if (this._ignoreSize !== ignore) { this._formatTextDirty = true; ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, ignore); } @@ -689,7 +688,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @param {Number} value - example cc.TEXT_ALIGNMENT_RIGHT */ setTextHorizontalAlignment: function(value){ - if(value != this._textHorizontalAlignment) { + if(value !== this._textHorizontalAlignment) { this._textHorizontalAlignment = value; this.formatText(); } @@ -705,7 +704,7 @@ ccui.RichText = ccui.Widget.extend(/** @lends ccui.RichText# */{ * @param {Number} value - example cc.VERTICAL_TEXT_ALIGNMENT_CENTER */ setTextVerticalAlignment: function(value){ - if(value != this._textVerticalAlignment) { + if(value !== this._textVerticalAlignment) { this._textVerticalAlignment = value; this.formatText(); } diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index e36244fa92..3eed1abe54 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -208,7 +208,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ */ setScale9Enabled: function (able) { //todo use setScale9Enabled - if (this._scale9Enabled == able) + if (this._scale9Enabled === able) return; this._scale9Enabled = able; diff --git a/extensions/ccui/uiwidgets/UIText.js b/extensions/ccui/uiwidgets/UIText.js index d52f7bba17..5d7bfc107a 100644 --- a/extensions/ccui/uiwidgets/UIText.js +++ b/extensions/ccui/uiwidgets/UIText.js @@ -115,7 +115,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param {String} text */ setString: function (text) { - if(text == this._labelRenderer.getString()) + if(text === this._labelRenderer.getString()) return; this._labelRenderer.setString(text); this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()); @@ -392,7 +392,7 @@ ccui.Text = ccui.Widget.extend(/** @lends ccui.Text# */{ * @param glowColor */ enableGlow: function(glowColor){ - if (this._type == ccui.Text.Type.TTF) + if (this._type === ccui.Text.Type.TTF) this._labelRenderer.enableGlow(glowColor); }, diff --git a/extensions/ccui/uiwidgets/UITextAtlas.js b/extensions/ccui/uiwidgets/UITextAtlas.js index cb4ad707cc..bb7e0d27ca 100644 --- a/extensions/ccui/uiwidgets/UITextAtlas.js +++ b/extensions/ccui/uiwidgets/UITextAtlas.js @@ -95,7 +95,7 @@ ccui.TextAtlas = ccui.Widget.extend(/** @lends ccui.TextAtlas# */{ * @param {String} value */ setString: function (value) { - if(value == this._labelAtlasRenderer.getString()) + if(value === this._labelAtlasRenderer.getString()) return; this._stringValue = value; this._labelAtlasRenderer.setString(value); diff --git a/extensions/ccui/uiwidgets/UITextBMFont.js b/extensions/ccui/uiwidgets/UITextBMFont.js index b0af3462c1..e77f043765 100644 --- a/extensions/ccui/uiwidgets/UITextBMFont.js +++ b/extensions/ccui/uiwidgets/UITextBMFont.js @@ -99,7 +99,7 @@ ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend(/** @lends ccui.TextBMFo * @param {String} value */ setString: function (value) { - if(value == this._labelBMFontRenderer.getString()) + if(value === this._labelBMFontRenderer.getString()) return; this._stringValue = value; this._labelBMFontRenderer.setString(value); diff --git a/extensions/ccui/uiwidgets/UITextField.js b/extensions/ccui/uiwidgets/UITextField.js index 859fec09dc..8fd34e0173 100644 --- a/extensions/ccui/uiwidgets/UITextField.js +++ b/extensions/ccui/uiwidgets/UITextField.js @@ -61,7 +61,7 @@ ccui._TextFieldRenderer = cc.TextFieldTTF.extend({ }, onTextFieldInsertText: function (sender, text, len) { - if (len == 1 && text == "\n") + if (len === 1 && text === "\n") return false; this.setInsertText(true); @@ -81,7 +81,7 @@ ccui._TextFieldRenderer = cc.TextFieldTTF.extend({ insertText: function (text, len) { var input_text = text; - if (text != "\n"){ + if (text !== "\n"){ if (this._maxLengthEnabled){ var text_count = this.getString().length; if (text_count >= this._maxLength){ diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js index 89610664e2..370dd411b3 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIListView.js @@ -156,7 +156,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ default: break; } - if (0 == itemIndex) + if (0 === itemIndex) layoutParameter.setMargin(ccui.MarginZero()); else layoutParameter.setMargin(new ccui.Margin(0.0, this._itemsMargin, 0.0, 0.0)); @@ -179,7 +179,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ default: break; } - if (0 == itemIndex) + if (0 === itemIndex) layoutParameter.setMargin(ccui.MarginZero()); else layoutParameter.setMargin(new ccui.Margin(this._itemsMargin, 0.0, 0.0, 0.0)); @@ -343,7 +343,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {ccui.ListView.GRAVITY_LEFT|ccui.ListView.GRAVITY_RIGHT|ccui.ListView.GRAVITY_CENTER_HORIZONTAL|ccui.ListView.GRAVITY_BOTTOM|ccui.ListView.GRAVITY_CENTER_VERTICAL} gravity */ setGravity: function (gravity) { - if (this._gravity == gravity) + if (this._gravity === gravity) return; this._gravity = gravity; this._refreshViewDirty = true; @@ -354,7 +354,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ * @param {Number} margin */ setItemsMargin: function (margin) { - if (this._itemsMargin == margin) + if (this._itemsMargin === margin) return; this._itemsMargin = margin; this._refreshViewDirty = true; @@ -445,7 +445,7 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ }, _selectedItemEvent: function (event) { - var eventEnum = (event == ccui.Widget.TOUCH_BEGAN) ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END; + var eventEnum = (event === ccui.Widget.TOUCH_BEGAN) ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END; if(this._listViewEventSelector){ if (this._listViewEventListener) this._listViewEventSelector.call(this._listViewEventListener, this, eventEnum); @@ -464,10 +464,10 @@ ccui.ListView = ccui.ScrollView.extend(/** @lends ccui.ListView# */{ */ interceptTouchEvent: function (eventType, sender, touch) { ccui.ScrollView.prototype.interceptTouchEvent.call(this, eventType, sender, touch); - if (eventType != ccui.Widget.TOUCH_MOVED) { + if (eventType !== ccui.Widget.TOUCH_MOVED) { var parent = sender; while (parent) { - if (parent && parent.getParent() == this._innerContainer) { + if (parent && parent.getParent() === this._innerContainer) { this._curSelectedIndex = this.getIndex(parent); break; } diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 8dd03b0b5a..ba4d69c2ff 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -138,7 +138,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {ccui.Layout} page */ addPage: function (page) { - if (!page || this._pages.indexOf(page) != -1) + if (!page || this._pages.indexOf(page) !== -1) return; this.addChild(page); @@ -152,7 +152,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ * @param {Number} idx index */ insertPage: function (page, idx) { - if (idx < 0 || !page || this._pages.indexOf(page) != -1) + if (idx < 0 || !page || this._pages.indexOf(page) !== -1) return; var pageCount = this._getPageCount(); diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js index 3bfa11913d..db3227ffbc 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js @@ -132,8 +132,8 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @returns {ccui.Widget} */ findNextFocusedWidget: function(direction, current){ - if (this.getLayoutType() == ccui.Layout.LINEAR_VERTICAL - || this.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) { + if (this.getLayoutType() === ccui.Layout.LINEAR_VERTICAL + || this.getLayoutType() === ccui.Layout.LINEAR_HORIZONTAL) { return this._innerContainer.findNextFocusedWidget(direction, current); } else return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, current); @@ -656,7 +656,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollEnabled = false; } this._moveChildren(realOffsetX, realOffsetY); - } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // bounce to top + } else if (touchOffsetX === 0.0 && touchOffsetY > 0.0){ // bounce to top realOffsetY = touchOffsetY; icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY >= this._topBoundary) { @@ -665,7 +665,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollEnabled = false; } this._moveChildren(0.0, realOffsetY); - } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) {//bounce to bottom + } else if (touchOffsetX === 0.0 && touchOffsetY < 0.0) {//bounce to bottom realOffsetY = touchOffsetY; icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY <= this._bottomBoundary) { @@ -674,7 +674,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollEnabled = false; } this._moveChildren(0.0, realOffsetY); - } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ //bounce to right + } else if (touchOffsetX > 0.0 && touchOffsetY === 0.0){ //bounce to right realOffsetX = touchOffsetX; icRightPos = locContainer.getRightBoundary(); if (icRightPos + realOffsetX >= this._rightBoundary) { @@ -683,7 +683,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ scrollEnabled = false; } this._moveChildren(realOffsetX, 0.0); - }else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ //bounce to left + }else if (touchOffsetX < 0.0 && touchOffsetY === 0.0){ //bounce to left realOffsetX = touchOffsetX; var icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + realOffsetX <= this._leftBoundary) { @@ -776,25 +776,25 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ touchOffsetY = locDestination.y - icTopPos; scrollEnabled = false; } - } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up + } else if (touchOffsetX === 0.0 && touchOffsetY > 0.0){ // up icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= locDestination.y) { touchOffsetY = locDestination.y - icBottomPos; scrollEnabled = false; } - } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left + } else if (touchOffsetX < 0.0 && touchOffsetY === 0.0){ // left icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= locDestination.x) { touchOffsetX = locDestination.x - icRightPos; scrollEnabled = false; } - } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down + } else if (touchOffsetX === 0.0 && touchOffsetY < 0.0){ // down icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= locDestination.y) { touchOffsetY = locDestination.y - icTopPos; scrollEnabled = false; } - } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right + } else if (touchOffsetX > 0.0 && touchOffsetY === 0.0){ // right icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= locDestination.x) { touchOffsetX = locDestination.x - icLeftPos; @@ -957,28 +957,28 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._scrollToTopEvent(); scrollEnabled = false; } - } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up + } else if (touchOffsetX === 0.0 && touchOffsetY > 0.0){ // up icBottomPos = locContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) { realOffsetY = this._bounceBottomBoundary - icBottomPos; this._scrollToBottomEvent(); scrollEnabled = false; } - } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left + } else if (touchOffsetX < 0.0 && touchOffsetY === 0.0){ // left icRightPos = locContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._bounceRightBoundary) { realOffsetX = this._bounceRightBoundary - icRightPos; this._scrollToRightEvent(); scrollEnabled = false; } - } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down + } else if (touchOffsetX === 0.0 && touchOffsetY < 0.0){ // down icTopPos = locContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._bounceTopBoundary) { realOffsetY = this._bounceTopBoundary - icTopPos; this._scrollToTopEvent(); scrollEnabled = false; } - } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right + } else if (touchOffsetX > 0.0 && touchOffsetY === 0.0){ // right icLeftPos = locContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) { realOffsetX = this._bounceLeftBoundary - icLeftPos; @@ -1039,28 +1039,28 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ this._scrollToTopEvent(); scrollEnabled = false; } - } else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) { // up + } else if (touchOffsetX === 0.0 && touchOffsetY > 0.0) { // up icBottomPos = this._innerContainer.getBottomBoundary(); if (icBottomPos + touchOffsetY >= this._bottomBoundary) { realOffsetY = this._bottomBoundary - icBottomPos; this._scrollToBottomEvent(); scrollEnabled = false; } - } else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left + } else if (touchOffsetX < 0.0 && touchOffsetY === 0.0){ // left icRightPos = this._innerContainer.getRightBoundary(); if (icRightPos + touchOffsetX <= this._rightBoundary) { realOffsetX = this._rightBoundary - icRightPos; this._scrollToRightEvent(); scrollEnabled = false; } - } else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down + } else if (touchOffsetX === 0.0 && touchOffsetY < 0.0){ // down icTopPos = this._innerContainer.getTopBoundary(); if (icTopPos + touchOffsetY <= this._topBoundary) { realOffsetY = this._topBoundary - icTopPos; this._scrollToTopEvent(); scrollEnabled = false; } - } else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right + } else if (touchOffsetX > 0.0 && touchOffsetY === 0.0){ // right icLeftPos = this._innerContainer.getLeftBoundary(); if (icLeftPos + touchOffsetX >= this._leftBoundary) { realOffsetX = this._leftBoundary - icLeftPos; @@ -1117,7 +1117,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToTopLeft: function (time, attenuated) { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1130,7 +1130,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToTopRight: function (time, attenuated) { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1145,7 +1145,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToBottomLeft: function (time, attenuated) { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1158,7 +1158,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToBottomRight: function (time, attenuated) { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1195,7 +1195,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {Boolean} attenuated */ scrollToPercentBothDirection: function (percent, time, attenuated) { - if (this.direction != ccui.ScrollView.DIR_BOTH) + if (this.direction !== ccui.ScrollView.DIR_BOTH) return; var minY = this._contentSize.height - this._innerContainer.getContentSize().height; var h = -minY; @@ -1235,7 +1235,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Move inner container to top and left boundary of ScrollView. */ jumpToTopLeft: function () { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1246,7 +1246,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Move inner container to top and right boundary of ScrollView. */ jumpToTopRight: function () { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1258,7 +1258,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Move inner container to bottom and left boundary of ScrollView. */ jumpToBottomLeft: function () { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1269,7 +1269,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * Move inner container to bottom and right boundary of ScrollView. */ jumpToBottomRight: function () { - if (this.direction != ccui.ScrollView.DIR_BOTH) { + if (this.direction !== ccui.ScrollView.DIR_BOTH) { cc.log("Scroll direction is not both!"); return; } @@ -1300,7 +1300,7 @@ ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{ * @param {cc.Point} percent The destination vertical percent, accept value between 0 - 100 */ jumpToPercentBothDirection: function (percent) { - if (this.direction != ccui.ScrollView.DIR_BOTH) + if (this.direction !== ccui.ScrollView.DIR_BOTH) return; var inSize = this._innerContainer.getContentSize(); var minY = this._contentSize.height - inSize.height; diff --git a/extensions/cocostudio/action/CCActionManager.js b/extensions/cocostudio/action/CCActionManager.js index 903de51d8c..434fb83327 100644 --- a/extensions/cocostudio/action/CCActionManager.js +++ b/extensions/cocostudio/action/CCActionManager.js @@ -67,7 +67,7 @@ ccs.actionManager = /** @lends ccs.actionManager# */{ return null; for (var i = 0; i < actionList.length; i++) { var locAction = actionList[i]; - if (actionName == locAction.getName()) + if (actionName === locAction.getName()) return locAction; } return null; diff --git a/extensions/cocostudio/action/CCActionNode.js b/extensions/cocostudio/action/CCActionNode.js index 5dfb2ee28a..a4ae9a9332 100644 --- a/extensions/cocostudio/action/CCActionNode.js +++ b/extensions/cocostudio/action/CCActionNode.js @@ -256,7 +256,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ }, _refreshActionProperty: function () { - if (this._object == null) + if (this._object === null) return null; var locSpawnArray = []; for (var i = 0; i < this._frameArrayNum; i++) { @@ -266,7 +266,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var locSequenceArray = []; for (var j = 0; j < locArray.length; j++) { var locFrame = locArray[j]; - if (j != 0) { + if (j !== 0) { var locSrcFrame = locArray[j - 1]; var locDuration = (locFrame.frameIndex - locSrcFrame.frameIndex) * this.getUnitTime(); var locAction = locFrame.getAction(locDuration); @@ -276,7 +276,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ } if(locSequenceArray){ var locSequence = cc.sequence(locSequenceArray); - if (locSequence != null) + if (locSequence !== null) locSpawnArray.push(locSequence); } } @@ -291,7 +291,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ * @param {cc.CallFunc} fun */ playAction: function (fun) { - if (this._object == null || this._actionSpawn == null) + if (this._object === null || this._actionSpawn === null) return; if(fun) this._action = cc.sequence(this._actionSpawn, fun); @@ -302,7 +302,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ _runAction: function () { var node = this.getActionNode(); - if (node != null && this._action != null) + if (node !== null && this._action !== null) node.runAction(this._action); }, @@ -311,7 +311,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ */ stopAction: function () { var node = this.getActionNode(); - if (node != null && this._action != null) { + if (node !== null && this._action !== null) { if(!this._action.isDone()) node.stopAction(this._action); } @@ -368,17 +368,17 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ var locUnitTime = this.getUnitTime(); for (var i = 0; i < this._frameArrayNum; i++) { var locArray = this._frameArray[i]; - if (locArray == null) + if (locArray === null) continue; for (var j = 0; j < locArray.length; j++) { var locFrame = locArray[j]; - if (locFrame.frameIndex * locUnitTime == time) { + if (locFrame.frameIndex * locUnitTime === time) { this._easingToFrame(1.0, 1.0, locFrame); locIsFindFrame = true; break; } else if (locFrame.frameIndex * locUnitTime > time) { - if (j == 0) { + if (j === 0) { this._easingToFrame(1.0, 1.0, locFrame); locIsFindFrame = false; } else { @@ -410,7 +410,7 @@ ccs.ActionNode = ccs.Class.extend(/** @lends ccs.ActionNode# */{ * @returns {Boolean} that if the action is done once time */ isActionDoneOnce: function () { - if (this._action == null) + if (this._action === null) return true; return this._action.isDone(); } diff --git a/extensions/cocostudio/action/CCActionObject.js b/extensions/cocostudio/action/CCActionObject.js index 7c0ca0c9eb..88597f382e 100644 --- a/extensions/cocostudio/action/CCActionObject.js +++ b/extensions/cocostudio/action/CCActionObject.js @@ -250,7 +250,7 @@ ccs.ActionObject = ccs.Class.extend(/** @lends ccs.ActionObject# */{ } if (isEnd){ - if (this._callback != null) + if (this._callback !== null) this._callback.execute(); if (this._loop) this.play(); diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index d743c19b25..e2c912b02c 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -94,7 +94,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var armatureDataManager = ccs.armatureDataManager; var animationData; - if (name != "") { + if (name !== "") { //animationData animationData = armatureDataManager.getAnimationData(name); cc.assert(animationData, "AnimationData not exist!"); @@ -279,7 +279,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var locOffsetPoint = this._offsetPoint; locOffsetPoint.x = -rect.x; locOffsetPoint.y = -rect.y; - if (rect.width != 0 && rect.height != 0) + if (rect.width !== 0 && rect.height !== 0) this.setAnchorPoint(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height); }, @@ -357,7 +357,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ var bone = locChildren[i]; if (bone) { var r = bone.getDisplayManager().getBoundingBox(); - if (r.x == 0 && r.y == 0 && r.width == 0 && r.height == 0) + if (r.x === 0 && r.y === 0 && r.width === 0 && r.height === 0) continue; if(first) { @@ -442,7 +442,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ }, setBody: function (body) { - if (this._body == body) + if (this._body === body) return; this._body = body; diff --git a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js index ac491c13ba..4d0a4f06f3 100644 --- a/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js @@ -114,7 +114,7 @@ var selBone = locChildren[i]; if (selBone && selBone.getDisplayRenderNode) { var selNode = selBone.getDisplayRenderNode(); - if (null == selNode) + if (null === selNode) continue; switch (selBone.getDisplayRenderNodeType()) { diff --git a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js index 54bf4e762a..05e86742cd 100644 --- a/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +++ b/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js @@ -50,7 +50,7 @@ var selBone = locChildren[i]; if (selBone && selBone.getDisplayRenderNode) { var selNode = selBone.getDisplayRenderNode(); - if (null == selNode) + if (null === selNode) continue; selNode.setShaderProgram(this._shaderProgram); switch (selBone.getDisplayRenderNodeType()) { @@ -60,10 +60,10 @@ selNode.updateTransform(); var func = selBone.getBlendFunc(); - if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + if (func.src !== alphaPremultiplied.src || func.dst !== alphaPremultiplied.dst) selNode.setBlendFunc(selBone.getBlendFunc()); else { - if ((node._blendFunc.src == alphaPremultiplied.src && node._blendFunc.dst == alphaPremultiplied.dst) + if ((node._blendFunc.src === alphaPremultiplied.src && node._blendFunc.dst === alphaPremultiplied.dst) && !selNode.getTexture().hasPremultipliedAlpha()) selNode.setBlendFunc(alphaNonPremultipled); else @@ -118,10 +118,10 @@ dis.updateTransform(); var func = selBone.getBlendFunc(); - if (func.src != alphaPremultiplied.src || func.dst != alphaPremultiplied.dst) + if (func.src !== alphaPremultiplied.src || func.dst !== alphaPremultiplied.dst) dis.setBlendFunc(selBone.getBlendFunc()); else { - if ((node._blendFunc.src == alphaPremultiplied.src && node_blendFunc.dst == alphaPremultiplied.dst) + if ((node._blendFunc.src === alphaPremultiplied.src && node_blendFunc.dst === alphaPremultiplied.dst) && !dis.getTexture().hasPremultipliedAlpha()) dis.setBlendFunc(alphaNonPremultipled); else diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index eb4bdff222..071ea83170 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -116,7 +116,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ setBoneData: function (boneData) { cc.assert(boneData, "_boneData must not be null"); - if(this._boneData != boneData) + if(this._boneData !== boneData) this._boneData = boneData; this.setName(this._boneData.name); @@ -230,7 +230,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ srcValue = blendFunc; dstValue = dst; } - if (locBlendFunc.src != srcValue || locBlendFunc.dst != dstValue) { + if (locBlendFunc.src !== srcValue || locBlendFunc.dst !== dstValue) { locBlendFunc.src = srcValue; locBlendFunc.dst = dstValue; this.blendDirty = true; @@ -242,7 +242,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ */ updateColor: function () { var display = this._displayManager.getDisplayRenderNode(); - if (display != null) { + if (display !== null) { var cmd = this._renderCmd; display.setColor( cc.color( @@ -284,7 +284,7 @@ ccs.Bone = ccs.Node.extend(/** @lends ccs.Bone# */{ * @param {Boolean} recursion */ removeChildBone: function (bone, recursion) { - if (this._children.length > 0 && this._children.getIndex(bone) != -1 ) { + if (this._children.length > 0 && this._children.getIndex(bone) !== -1 ) { if(recursion) { var ccbones = bone._children; for(var i=0; i 0 ? this._durationTween : 1; this.movementEvent(this, ccs.MovementEventType.start, this._movementID); break; @@ -525,9 +525,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Object} target */ setMovementEventCallFunc: function (callFunc, target) { - if(arguments.length == 1){ + if(arguments.length === 1){ this._movementEventListener = callFunc; - }else if(arguments.length == 2){ + }else if(arguments.length === 2){ this._movementEventTarget = target; this._movementEventCallFunc = callFunc; } @@ -539,9 +539,9 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {Object} target */ setFrameEventCallFunc: function (callFunc, target) { - if(arguments.length == 1){ + if(arguments.length === 1){ this._frameEventListener = callFunc; - }else if(arguments.length == 2){ + }else if(arguments.length === 2){ this._frameEventTarget = target; this._frameEventCallFunc = callFunc; } @@ -618,7 +618,7 @@ ccs.ArmatureAnimation = ccs.ProcessBase.extend(/** @lends ccs.ArmatureAnimation# * @param {ccs.AnimationData} data */ setAnimationData: function (data) { - if(this._animationData != data) + if(this._animationData !== data) this._animationData = data; }, diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index 9f2ec90f78..e98cb7fd94 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -220,9 +220,9 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ */ gotoFrame: function (frameIndex) { var locLoopType = this._loopType; - if (locLoopType == ccs.ANIMATION_TYPE_NO_LOOP) + if (locLoopType === ccs.ANIMATION_TYPE_NO_LOOP) locLoopType = ccs.ANIMATION_TYPE_MAX; - else if (locLoopType == ccs.ANIMATION_TYPE_TO_LOOP_FRONT) + else if (locLoopType === ccs.ANIMATION_TYPE_TO_LOOP_FRONT) locLoopType = ccs.ANIMATION_TYPE_LOOP_FRONT; this._loopType = locLoopType; this._curFrameIndex = frameIndex; diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index f35dbb9f33..ce0da172cc 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -67,7 +67,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._tweenData = this._bone.getTweenData(); this._tweenData.displayIndex = -1; - this._animation = (this._bone != null && this._bone.getArmature() != null) ? + this._animation = (this._bone !== null && this._bone.getArmature() !== null) ? this._bone.getArmature().getAnimation() : null; return true; @@ -89,7 +89,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._betweenDuration = 0; this._fromIndex = this._toIndex = 0; - var difMovement = movementBoneData != this._movementBoneData; + var difMovement = movementBoneData !== this._movementBoneData; this.setMovementBoneData(movementBoneData); this._rawDuration = this._movementBoneData.duration; @@ -103,9 +103,9 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._tweenData.scaleY += 1; } - if (this._rawDuration == 0) { + if (this._rawDuration === 0) { this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME; - if (durationTo == 0) + if (durationTo === 0) this.setBetween(nextKeyFrame, nextKeyFrame); else this.setBetween(this._tweenData, nextKeyFrame); @@ -113,10 +113,10 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ } else if (this._movementBoneData.frameList.length > 1) { this._durationTween = durationTween * this._movementBoneData.scale; - if (loop && this._movementBoneData.delay != 0) + if (loop && this._movementBoneData.delay !== 0) this.setBetween(this._tweenData, this.tweenNodeTo(this.updateFrameData(1 - this._movementBoneData.delay), this._between)); else { - if (!difMovement || durationTo == 0) + if (!difMovement || durationTo === 0) this.setBetween(nextKeyFrame, nextKeyFrame); else this.setBetween(this._tweenData, nextKeyFrame); @@ -188,7 +188,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ locLoopType = ccs.ANIMATION_TYPE_LOOP_FRONT; this._nextFrameIndex = this._durationTween > 0 ? this._durationTween : 1; - if (this._movementBoneData.delay != 0) { + if (this._movementBoneData.delay !== 0) { this._currentFrame = (1 - this._movementBoneData.delay) * this._nextFrameIndex; locCurrentPercent = this._currentFrame / this._nextFrameIndex; } else { @@ -219,7 +219,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ if (locLoopType > ccs.ANIMATION_TYPE_TO_LOOP_BACK) locCurrentPercent = this.updateFrameData(locCurrentPercent); - if (this._frameTweenEasing != ccs.TweenType.tweenEasingMax) + if (this._frameTweenEasing !== ccs.TweenType.tweenEasingMax) this.tweenNodeTo(locCurrentPercent); }, @@ -277,7 +277,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ var childAramture = locBone.getChildArmature(); if (childAramture) { - if (keyFrameData.movement != "") + if (keyFrameData.movement !== "") childAramture.getAnimation().play(keyFrameData.movement); } } @@ -332,7 +332,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ * @return {Number} */ updateFrameData:function (currentPercent) { //TODO set tweenColorTo to protected in v3.1 - if (currentPercent > 1 && this._movementBoneData.delay != 0) + if (currentPercent > 1 && this._movementBoneData.delay !== 0) currentPercent = ccs.fmodf(currentPercent,1); var playedTime = (this._rawDuration-1) * currentPercent; @@ -379,7 +379,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ if(from.strEvent && !this._animation.isIgnoreFrameEvent()) this._animation.frameEvent(this._bone, from.strEvent,from.frameID, playedTime); - if (playedTime == from.frameID|| (this._passLastFrame && this._fromIndex == length-1)) + if (playedTime === from.frameID|| (this._passLastFrame && this._fromIndex === length-1)) break; } while (playedTime < from.frameID || playedTime >= to.frameID); @@ -391,13 +391,13 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this._betweenDuration = locBetweenDuration; this._toIndex = locToIndex; } - currentPercent = locBetweenDuration == 0 ? 0 : (playedTime - this._totalDuration) / this._betweenDuration; + currentPercent = locBetweenDuration === 0 ? 0 : (playedTime - this._totalDuration) / this._betweenDuration; /* * if frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween. */ - var tweenType = (this._frameTweenEasing != ccs.TweenType.linear) ? this._frameTweenEasing : this._tweenEasing; - if (tweenType != ccs.TweenType.tweenEasingMax && tweenType != ccs.TweenType.linear && !this._passLastFrame) { + var tweenType = (this._frameTweenEasing !== ccs.TweenType.linear) ? this._frameTweenEasing : this._tweenEasing; + if (tweenType !== ccs.TweenType.tweenEasingMax && tweenType !== ccs.TweenType.linear && !this._passLastFrame) { currentPercent = ccs.TweenFunction.tweenTo(currentPercent, tweenType, this._from.easingParams); } return currentPercent; diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index ec4fad918c..bfab738d55 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -319,7 +319,7 @@ ccs.DisplayData = ccs.Class.extend(/** @lends ccs.DisplayData# */{ var textureName = displayName; var startPos = textureName.lastIndexOf("."); - if (startPos != -1) + if (startPos !== -1) textureName = textureName.substring(0, startPos); return textureName; }, @@ -580,7 +580,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ // this.sound = frameData.sound; // this.soundEffect = frameData.soundEffect; // this.easingParams.length = 0; - if (this.easingParamNumber != 0){ + if (this.easingParamNumber !== 0){ this.easingParams.length = 0; for (var i = 0; i= ccs.CONST_VERSION_2_0) { x = frameXML.getAttribute(ccs.CONST_A_COCOS2DX_X); @@ -898,7 +898,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if(_easing != ccs.CONST_FL_NAN){ tweenEasing = frameXML.getAttribute(ccs.CONST_A_TWEEN_EASING); if( tweenEasing ) - frameData.tweenEasing = (tweenEasing == 2) ? ccs.TweenType.sineEaseInOut : tweenEasing; + frameData.tweenEasing = (tweenEasing === 2) ? ccs.TweenType.sineEaseInOut : tweenEasing; } else frameData.tweenEasing = ccs.TweenType.linear; } diff --git a/extensions/cocostudio/armature/utils/CCTransformHelp.js b/extensions/cocostudio/armature/utils/CCTransformHelp.js index 93084a8870..0d6228d5cd 100644 --- a/extensions/cocostudio/armature/utils/CCTransformHelp.js +++ b/extensions/cocostudio/armature/utils/CCTransformHelp.js @@ -103,7 +103,7 @@ ccs.TransformHelp.transformToParentWithoutScale = function(node, parentNode){ * @param {cc.AffineTransform} matrix */ ccs.TransformHelp.nodeToMatrix = function (node, matrix) { - if (node.skewX == -node.skewY) { + if (node.skewX === -node.skewY) { var sine = Math.sin(node.skewX); var cosine = Math.cos(node.skewX); matrix.a = node.scaleX * cosine; diff --git a/extensions/cocostudio/armature/utils/CCTweenFunction.js b/extensions/cocostudio/armature/utils/CCTweenFunction.js index 11cc1547c5..b6d62d482e 100644 --- a/extensions/cocostudio/armature/utils/CCTweenFunction.js +++ b/extensions/cocostudio/armature/utils/CCTweenFunction.js @@ -298,10 +298,10 @@ ccs.TweenFunction.quintEaseInOut = function (time) { // Expo Ease ccs.TweenFunction.expoEaseIn = function (time) { - return time == 0 ? 0 : Math.pow(2, 10 * (time - 1)) - 0.001; + return time === 0 ? 0 : Math.pow(2, 10 * (time - 1)) - 0.001; }; ccs.TweenFunction.expoEaseOut = function (time) { - return time == 1 ? 1 : (-Math.pow(2, -10 * time) + 1); + return time === 1 ? 1 : (-Math.pow(2, -10 * time) + 1); }; ccs.TweenFunction.expoEaseInOut = function (time) { time /= 0.5; @@ -342,7 +342,7 @@ ccs.TweenFunction.elasticEaseIn = function (time, easingParam) { } var newT = 0; - if (time == 0 || time == 1) { + if (time === 0 || time === 1) { newT = time; } else { @@ -361,7 +361,7 @@ ccs.TweenFunction.elasticEaseOut = function (time, easingParam) { } var newT = 0; - if (time == 0 || time == 1) { + if (time === 0 || time === 1) { newT = time; } else { @@ -379,7 +379,7 @@ ccs.TweenFunction.elasticEaseInOut = function (time, easingParam) { } var newT = 0; - if (time == 0 || time == 1) { + if (time === 0 || time === 1) { newT = time; } else { diff --git a/extensions/cocostudio/components/CCComController.js b/extensions/cocostudio/components/CCComController.js index e9bb63d719..cdd85eeb94 100644 --- a/extensions/cocostudio/components/CCComController.js +++ b/extensions/cocostudio/components/CCComController.js @@ -43,7 +43,7 @@ ccs.ComController = ccs.Component.extend(/** @lends ccs.ComController# */{ * @override */ onEnter: function () { - if (this._owner != null) + if (this._owner !== null) this._owner.scheduleUpdate(); }, diff --git a/extensions/cocostudio/components/CCComponentContainer.js b/extensions/cocostudio/components/CCComponentContainer.js index 1d54c6bc2d..c82103e7ee 100644 --- a/extensions/cocostudio/components/CCComponentContainer.js +++ b/extensions/cocostudio/components/CCComponentContainer.js @@ -152,7 +152,7 @@ cc.ComponentContainer = cc.Class.extend(/** @lends cc.ComponentContainer# */{ isEmpty: function () { if (!this._components) return true; - return this._components.length == 0; + return this._components.length === 0; } }); diff --git a/extensions/cocostudio/loader/parsers/action-1.x.js b/extensions/cocostudio/loader/parsers/action-1.x.js index c5c20446c4..e7123e7f54 100644 --- a/extensions/cocostudio/loader/parsers/action-1.x.js +++ b/extensions/cocostudio/loader/parsers/action-1.x.js @@ -55,7 +55,7 @@ if(frame) action.addTimeline(frame); - if(timeline["frameType"] == "ColorFrame"){ + if(timeline["frameType"] === "ColorFrame"){ action.addTimeline( self.parsers["AlphaFrame"].call(self, timeline, resourcePath) ); diff --git a/extensions/cocostudio/loader/parsers/compatible.js b/extensions/cocostudio/loader/parsers/compatible.js index 0969d257d5..caa681d4fc 100644 --- a/extensions/cocostudio/loader/parsers/compatible.js +++ b/extensions/cocostudio/loader/parsers/compatible.js @@ -91,9 +91,9 @@ * @returns {Number} */ getVersionInteger: function(version){ - if(!version || typeof version != "string") return 0; + if(!version || typeof version !== "string") return 0; var arr = version.split("."); - if (arr.length != 4) + if (arr.length !== 4) return 0; var num = 0; arr.forEach(function(n, i){ @@ -199,7 +199,7 @@ getNodeByTag: function(tag){ if (this._node == null) return null; - if (this._node.getTag() == tag) + if (this._node.getTag() === tag) return this._node; return this._nodeByTag(this._node, tag); }, @@ -211,7 +211,7 @@ var children = parent.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - if (child && child.getTag() == tag) { + if (child && child.getTag() === tag) { retNode = child; break; } else { diff --git a/extensions/cocostudio/loader/parsers/scene-1.x.js b/extensions/cocostudio/loader/parsers/scene-1.x.js index aad9b5a73b..04569cb17f 100644 --- a/extensions/cocostudio/loader/parsers/scene-1.x.js +++ b/extensions/cocostudio/loader/parsers/scene-1.x.js @@ -92,9 +92,9 @@ "CCSprite": function(node, component, resourcePath){ var child = new cc.Sprite(); loadTexture(component["fileData"], resourcePath, function(path, type){ - if(type == 0) + if(type === 0) child.setTexture(path); - else if(type == 1){ + else if(type === 1){ var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); child.setSpriteFrame(spriteFrame); } @@ -106,7 +106,7 @@ "CCTMXTiledMap": function(node, component, resourcePath){ var child = null; loadTexture(component["fileData"], resourcePath, function(path, type){ - if(type == 0) + if(type === 0) child = new cc.TMXTiledMap(path); }); var render = new ccs.ComRender(child, "CCTMXTiledMap"); @@ -116,7 +116,7 @@ "CCParticleSystemQuad": function(node, component, resourcePath){ var child = null; loadTexture(component["fileData"], resourcePath, function(path, type){ - if(type == 0) + if(type === 0) child = new cc.ParticleSystem(path); else cc.log("unknown resourcetype on CCParticleSystemQuad!"); @@ -129,7 +129,7 @@ "CCArmature": function(node, component, resourcePath){ var child = null; loadTexture(component["fileData"], resourcePath, function(path, type){ - if(type == 0){ + if(type === 0){ var jsonDict = cc.loader.getRes(path); if (!jsonDict) cc.log("Please load the resource [%s] first!", path); var armature_data = jsonDict["armature_data"]; @@ -153,7 +153,7 @@ "CCComAudio": function(node, component, resourcePath){ var audio = null; loadTexture(component["fileData"], resourcePath, function(path, type){ - if(type == 0){ + if(type === 0){ audio = new ccs.ComAudio(); audio.preloadEffect(path); var name = component["name"]; @@ -166,9 +166,9 @@ "CCComAttribute": function(node, component, resourcePath){ var attribute = null; loadTexture(component["fileData"], resourcePath, function(path, type){ - if(type == 0){ + if(type === 0){ attribute = new ccs.ComAttribute(); - if (path != "") + if (path !== "") attribute.parse(path); node.addComponent(attribute); }else @@ -179,7 +179,7 @@ "CCBackgroundAudio": function(node, component, resourcePath){ var audio = null; loadTexture(component["fileData"], resourcePath, function(path, type){ - if(type == 0){ + if(type === 0){ audio = new ccs.ComAudio(); audio.preloadBackgroundMusic(path); audio.setFile(path);var bLoop = Boolean(component["loop"] || 0); diff --git a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js index 5b0c849df9..c9c3efbab5 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-1.x.js @@ -33,7 +33,7 @@ }, addSpriteFrame: function(plists, pngs, resourcePath){ - if(!plists || !pngs || plists.length != pngs.length) + if(!plists || !pngs || plists.length !== pngs.length) return; for (var i = 0; i < plists.length; i++) { var plist = resourcePath + plists[i]; @@ -142,7 +142,7 @@ widget.pushBackCustomItem(child); } else { if(!(widget instanceof ccui.Layout) && child instanceof ccui.Widget) { - if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { + if(child.getPositionType() === ccui.Widget.POSITION_PERCENT) { var position = child.getPositionPercent(); var anchor = widget.getAnchorPoint(); child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); @@ -167,7 +167,7 @@ var filePath = options["fileName"]; var node; - if (filePath && "" != filePath){ + if (filePath && "" !== filePath){ node = this.createNode(filePath); }else{ node = new ccs.Node(); @@ -219,9 +219,9 @@ var path = options["resourcePath"]; var tmx = null; - if (tmxFile && "" != tmxFile){ + if (tmxFile && "" !== tmxFile){ tmx = new cc.TMXTiledMap(tmxFile); - }else if (tmxString && "" != tmxString && path && "" != path){ + }else if (tmxString && "" !== tmxString && path && "" !== path){ tmx = new cc.TMXTiledMap(tmxString, path); } return tmx; diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index e3a9f47f3f..2eb90d429b 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -127,7 +127,7 @@ node.pushBackCustomItem(child); } else { if(!(node instanceof ccui.Layout) && child instanceof ccui.Widget) { - if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { + if(child.getPositionType() === ccui.Widget.POSITION_PERCENT) { var position = child.getPositionPercent(); var anchor = node.getAnchorPoint(); child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); @@ -163,9 +163,9 @@ var node = new cc.Sprite(); loadTexture(json["FileData"], resourcePath, function(path, type){ - if(type == 0) + if(type === 0) node.setTexture(path); - else if(type == 1){ + else if(type === 1){ var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); node.setSpriteFrame(spriteFrame); } @@ -333,21 +333,21 @@ layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; - if (horizontalEdge == "LeftEdge"){ + if (horizontalEdge === "LeftEdge"){ horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; - }else if (horizontalEdge == "RightEdge"){ + }else if (horizontalEdge === "RightEdge"){ horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; - }else if (horizontalEdge == "BothEdge"){ + }else if (horizontalEdge === "BothEdge"){ horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; } layoutComponent.setHorizontalEdge(horizontalEdgeType); var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; - if (verticalEdge == "TopEdge"){ + if (verticalEdge === "TopEdge"){ verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; - }else if (verticalEdge == "BottomEdge"){ + }else if (verticalEdge === "BottomEdge"){ verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; - }else if (verticalEdge == "BothEdge"){ + }else if (verticalEdge === "BothEdge"){ verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; } layoutComponent.setVerticalEdge(verticalEdgeType); @@ -696,9 +696,9 @@ widget.setInnerContainerSize(innerSize); var direction = 0; - if(json["ScrollDirectionType"] == "Vertical") direction = 1; - if(json["ScrollDirectionType"] == "Horizontal") direction = 2; - if(json["ScrollDirectionType"] == "Vertical_Horizontal") direction = 3; + if(json["ScrollDirectionType"] === "Vertical") direction = 1; + if(json["ScrollDirectionType"] === "Horizontal") direction = 2; + if(json["ScrollDirectionType"] === "Vertical_Horizontal") direction = 3; widget.setDirection(direction); var bounceEnabled = getParam(json["IsBounceEnabled"], false); @@ -795,7 +795,7 @@ ]; textureList.forEach(function(item){ loadTexture(json[item.name], resourcePath, function(path, type){ - if(type == 0 && !loader.getRes(path)) + if(type === 0 && !loader.getRes(path)) cc.log("%s need to be preloaded", path); item.handle.call(widget, path, type); }); @@ -912,19 +912,19 @@ var horizontalType = getParam(json["HorizontalType"], "Align_Top"); if(!directionType){ widget.setDirection(ccui.ScrollView.DIR_HORIZONTAL); - if(verticalType == "Align_Bottom") + if(verticalType === "Align_Bottom") widget.setGravity(ccui.ListView.GRAVITY_BOTTOM); - else if(verticalType == "Align_VerticalCenter") + else if(verticalType === "Align_VerticalCenter") widget.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL); else widget.setGravity(ccui.ListView.GRAVITY_TOP); - }else if(directionType == "Vertical"){ + }else if(directionType === "Vertical"){ widget.setDirection(ccui.ScrollView.DIR_VERTICAL); - if (horizontalType == "") + if (horizontalType === "") widget.setGravity(ccui.ListView.GRAVITY_LEFT); - else if (horizontalType == "Align_Right") + else if (horizontalType === "Align_Right") widget.setGravity(ccui.ListView.GRAVITY_RIGHT); - else if (horizontalType == "Align_HorizontalCenter") + else if (horizontalType === "Align_HorizontalCenter") widget.setGravity(ccui.ListView.GRAVITY_CENTER_HORIZONTAL); } @@ -986,7 +986,7 @@ loadTexture(json["LabelAtlasFileImage_CNB"], resourcePath, function(path, type){ if(!cc.loader.getRes(path)) cc.log("%s need to be preloaded", path); - if(type == 0){ + if(type === 0){ widget.setProperty(stringValue, path, itemWidth, itemHeight, startCharMap); } }); @@ -1126,7 +1126,7 @@ var node = null; loadTexture(json["FileData"], resourcePath, function(path, type){ - if(type == 0) + if(type === 0) node = new cc.TMXTiledMap(path); parser.generalAttributes(node, json); @@ -1212,7 +1212,7 @@ if(json != null){ var path = json["Path"]; var type; - if(json["Type"] == "Default" || json["Type"] == "Normal") + if(json["Type"] === "Default" || json["Type"] === "Normal") type = 0; else type = 1; diff --git a/extensions/cocostudio/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js index 41500f531f..c27002bb22 100644 --- a/extensions/cocostudio/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -186,7 +186,7 @@ widget.pushBackCustomItem(child); } else { if(!(widget instanceof ccui.Layout)) { - if(child.getPositionType() == ccui.Widget.POSITION_PERCENT) { + if(child.getPositionType() === ccui.Widget.POSITION_PERCENT) { var position = child.getPositionPercent(); var anchor = widget.getAnchorPoint(); child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y)); @@ -203,7 +203,7 @@ var getPath = function(res, type, path, cb){ if(path){ - if(type == 0) + if(type === 0) cb(res + path, type); else cb(path, type); diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index bc5a60cc00..ec1a707419 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -368,7 +368,7 @@ ccs.ActionTimeline = cc.Action.extend({ * @param {number} delta */ step: function(delta){ - if (!this._playing || this._timelineMap.length == 0 || this._duration == 0) + if (!this._playing || this._timelineMap.length === 0 || this._duration === 0) { return; } diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index 83013aa842..460bbf86d2 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -320,7 +320,7 @@ ccs.RotationFrame = ccs.Frame.extend({ * @param {number} percent */ apply: function(percent){ - if (this._tween && this._betwennRotation != 0){ + if (this._tween && this._betwennRotation !== 0){ var rotation = this._rotation + percent * this._betwennRotation; this._node.setRotation(rotation); } @@ -406,7 +406,7 @@ ccs.SkewFrame = ccs.Frame.extend({ * @param {number} percent */ apply: function(percent){ - if (this._tween && (this._betweenSkewX != 0 || this._betweenSkewY != 0)) + if (this._tween && (this._betweenSkewX !== 0 || this._betweenSkewY !== 0)) { var skewx = this._skewX + percent * this._betweenSkewX; var skewy = this._skewY + percent * this._betweenSkewY; @@ -504,7 +504,7 @@ ccs.RotationSkewFrame = ccs.SkewFrame.extend({ * @param {number} percent */ apply: function(percent){ - if (this._tween && (this._betweenSkewX != 0 || this._betweenSkewY != 0)){ + if (this._tween && (this._betweenSkewX !== 0 || this._betweenSkewY !== 0)){ var skewx = this._skewX + percent * this._betweenSkewX; var skewy = this._skewY + percent * this._betweenSkewY; @@ -576,7 +576,7 @@ ccs.PositionFrame = ccs.Frame.extend({ * @param {number} percent */ apply: function(percent){ - if (this._tween && (this._betweenX != 0 || this._betweenY != 0)){ + if (this._tween && (this._betweenX !== 0 || this._betweenY !== 0)){ var p = cc.p(0, 0); p.x = this._position.x + this._betweenX * percent; p.y = this._position.y + this._betweenY * percent; @@ -697,7 +697,7 @@ ccs.ScaleFrame = ccs.Frame.extend({ * @param {number} percent */ apply: function(percent){ - if (this._tween && (this._betweenScaleX != 0 || this._betweenScaleY != 0)){ + if (this._tween && (this._betweenScaleX !== 0 || this._betweenScaleY !== 0)){ var scaleX = this._scaleX + this._betweenScaleX * percent; var scaleY = this._scaleY + this._betweenScaleY * percent; @@ -877,7 +877,7 @@ ccs.InnerActionFrame = ccs.Frame.extend({ */ onEnter: function(nextFrame){ var innerActiontimeline = this._node.getActionByTag(this._node.getTag()); - if (/*ccs.InnerActionType.SingleFrame*/"SingleFrame" == this._innerActionType){ + if (/*ccs.InnerActionType.SingleFrame*/"SingleFrame" === this._innerActionType){ innerActiontimeline.gotoFrameAndPause(this._singleFrameIndex); return; } @@ -885,7 +885,7 @@ ccs.InnerActionFrame = ccs.Frame.extend({ var innerStart = this._startFrameIndex; var innerEnd = this._endFrameIndex; if (this._enterWithName){ - if (this._animationName == "-- ALL --"){ + if (this._animationName === "-- ALL --"){ innerStart = 0; innerEnd = innerActiontimeline.getDuration(); } else if(innerActiontimeline.IsAnimationInfoExists(this._animationName)) { @@ -903,9 +903,9 @@ ccs.InnerActionFrame = ccs.Frame.extend({ innerEnd += odddiff; } - if (ccs.InnerActionType.NoLoopAction == this._innerActionType){ + if (ccs.InnerActionType.NoLoopAction === this._innerActionType){ innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, false); - }else if (ccs.InnerActionType.LoopAction == this._innerActionType){ + }else if (ccs.InnerActionType.LoopAction === this._innerActionType){ innerActiontimeline.gotoFrameAndPlay(innerStart, innerEnd, true); } }, @@ -1034,7 +1034,7 @@ ccs.ColorFrame = ccs.Frame.extend({ * @param {number} percent */ apply: function(percent){ - if (this._tween && (this._betweenAlpha !=0 || this._betweenRed != 0 || this._betweenGreen != 0 || this._betweenBlue != 0)){ + if (this._tween && (this._betweenAlpha !== 0 || this._betweenRed !== 0 || this._betweenGreen !== 0 || this._betweenBlue !== 0)){ var color = cc.color(255, 255, 255); color.r = this._color.r + this._betweenRed * percent; @@ -1042,7 +1042,7 @@ ccs.ColorFrame = ccs.Frame.extend({ color.b = this._color.b + this._betweenBlue * percent; this._node.setColor(color); - if(this._alpha != null){ + if(this._alpha !== null){ var alpha = this._alpha + this._betweenAlpha * percent; this._node.setOpacity(alpha); } diff --git a/extensions/cocostudio/timeline/Timeline.js b/extensions/cocostudio/timeline/Timeline.js index 783d97fd26..273ef72a11 100644 --- a/extensions/cocostudio/timeline/Timeline.js +++ b/extensions/cocostudio/timeline/Timeline.js @@ -61,7 +61,7 @@ ccs.Timeline = ccs.Class.extend({ }, _gotoFrame: function(frameIndex){ - if(this._frames.length == 0) + if(this._frames.length === 0) return; this._binarySearchKeyFrame(frameIndex); @@ -69,7 +69,7 @@ ccs.Timeline = ccs.Class.extend({ }, _stepToFrame: function(frameIndex){ - if(this._frames.length == 0) + if(this._frames.length === 0) return; this._updateCurrentKeyFrame(frameIndex); @@ -187,7 +187,7 @@ ccs.Timeline = ccs.Class.extend({ _apply: function(frameIndex){ if (this._currentKeyFrame) { - var currentPercent = this._betweenDuration == 0 ? 0 : (frameIndex - this._currentKeyFrameIndex) / this._betweenDuration; + var currentPercent = this._betweenDuration === 0 ? 0 : (frameIndex - this._currentKeyFrameIndex) / this._betweenDuration; this._currentKeyFrame.apply(currentPercent); } }, @@ -239,15 +239,14 @@ ccs.Timeline = ccs.Class.extend({ from = this._frames[target]; to = this._frames[target+1]; - if(target == 0 && this._currentKeyFrameIndex < from.getFrameIndex()) + if(target === 0 && this._currentKeyFrameIndex < from.getFrameIndex()) needEnterFrame = true; this._currentKeyFrameIndex = from.getFrameIndex(); this._betweenDuration = to.getFrameIndex() - from.getFrameIndex(); } while (0); - if(needEnterFrame || this._currentKeyFrame != from) - { + if(needEnterFrame || this._currentKeyFrame != from) { this._currentKeyFrame = from; this._currentKeyFrame.onEnter(to); } @@ -293,7 +292,7 @@ ccs.Timeline = ccs.Class.extend({ to = this._frames[this._toIndex]; - if (frameIndex == from.getFrameIndex()) + if (frameIndex === from.getFrameIndex()) { break; } diff --git a/extensions/cocostudio/trigger/TriggerMng.js b/extensions/cocostudio/trigger/TriggerMng.js index f647e7ce6f..e0167a1ab6 100644 --- a/extensions/cocostudio/trigger/TriggerMng.js +++ b/extensions/cocostudio/trigger/TriggerMng.js @@ -78,7 +78,7 @@ ccs.triggerManager = /** @lends ccs.triggerManager# */{ var eventTriggers = this._eventTriggers[event]; if (!eventTriggers) eventTriggers = []; - if (eventTriggers.indexOf(triggerObj) == -1) { + if (eventTriggers.indexOf(triggerObj) === -1) { eventTriggers.push(triggerObj); this._eventTriggers[event] = eventTriggers; } @@ -180,7 +180,7 @@ ccs.triggerManager = /** @lends ccs.triggerManager# */{ var locAmd, hasADD = false; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; - if (locAmd && locAmd[0] == armature) { + if (locAmd && locAmd[0] === armature) { locAmd.addAnimationEventCallBack(callFunc, target); hasADD = true; } @@ -205,7 +205,7 @@ ccs.triggerManager = /** @lends ccs.triggerManager# */{ var locAmd; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; - if (locAmd && locAmd[0] == armature) + if (locAmd && locAmd[0] === armature) locAmd.removeAnimationEventCallBack(callFunc, target); } }, @@ -220,7 +220,7 @@ ccs.triggerManager = /** @lends ccs.triggerManager# */{ var locAmd; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; - if (locAmd && locAmd[0] == armature) { + if (locAmd && locAmd[0] === armature) { this._movementDispatches.splice(i, 1); break; } @@ -293,7 +293,7 @@ ccs.ArmatureMovementDispatcher = ccs.Class.extend(/** @lends ccs.ArmatureMovemen var locEventAni; for (var i = 0; i < this._mapEventAnimation.length; i++) { locEventAni = this._mapEventAnimation[i]; - if (locEventAni[0] == target) { + if (locEventAni[0] === target) { this._mapEventAnimation.splice(i, 1); } } diff --git a/extensions/cocostudio/trigger/TriggerObj.js b/extensions/cocostudio/trigger/TriggerObj.js index 5d4e36af4b..6a8e3c1226 100644 --- a/extensions/cocostudio/trigger/TriggerObj.js +++ b/extensions/cocostudio/trigger/TriggerObj.js @@ -140,7 +140,7 @@ ccs.TriggerObj = ccs.Class.extend(/** @lends ccs.TriggerObj# */{ * @returns {boolean} */ detect: function () { - if (!this._enable || this._cons.length == 0) { + if (!this._enable || this._cons.length === 0) { return true; } var ret = true; @@ -157,7 +157,7 @@ ccs.TriggerObj = ccs.Class.extend(/** @lends ccs.TriggerObj# */{ * Sets trigger's actions to done. */ done: function () { - if (!this._enable || this._acts.length == 0) + if (!this._enable || this._acts.length === 0) return; var obj; for (var i = 0; i < this._acts.length; i++) { diff --git a/extensions/editbox/CCEditBox.js b/extensions/editbox/CCEditBox.js index 561e771d77..4c68eb84c2 100644 --- a/extensions/editbox/CCEditBox.js +++ b/extensions/editbox/CCEditBox.js @@ -273,11 +273,11 @@ cc.EditBox = cc.ControlButton.extend({ } }); cc._addEventListener(tmpEdTxt, "focus", function () { - if (this.value == selfPointer._placeholderText) { + if (this.value === selfPointer._placeholderText) { this.value = ""; this.style.fontSize = selfPointer._edFontSize + "px"; this.style.color = cc.colorToHex(selfPointer._textColor); - if (selfPointer._editBoxInputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD) + if (selfPointer._editBoxInputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD) selfPointer._edTxt.type = "password"; else selfPointer._edTxt.type = "text"; @@ -287,7 +287,7 @@ cc.EditBox = cc.ControlButton.extend({ cc._addEventListener(cc._canvas, "click", onCanvasClick); }); cc._addEventListener(tmpEdTxt, "blur", function () { - if (this.value == "") { + if (this.value === "") { this.value = selfPointer._placeholderText; this.style.fontSize = selfPointer._placeholderFontSize + "px"; this.style.color = cc.colorToHex(selfPointer._placeholderColor); @@ -358,10 +358,10 @@ cc.EditBox = cc.ControlButton.extend({ }, _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"; - if (this._editBoxInputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD) + if (this._editBoxInputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD) this._edTxt.type = "password"; else this._edTxt.type = "text"; @@ -384,14 +384,14 @@ cc.EditBox = cc.ControlButton.extend({ */ setString: function (text) { if (text != null) { - if (text == "") { + if (text === "") { this._edTxt.value = this._placeholderText; this._edTxt.style.color = cc.colorToHex(this._placeholderColor); this._edTxt.type = "text"; } else { this._edTxt.value = text; this._edTxt.style.color = cc.colorToHex(this._textColor); - if (this._editBoxInputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD) + if (this._editBoxInputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD) this._edTxt.type = "password"; else this._edTxt.type = "text"; @@ -405,7 +405,7 @@ cc.EditBox = cc.ControlButton.extend({ */ setFontColor: function (color) { this._textColor = color; - if (this._edTxt.value != this._placeholderText) { + if (this._edTxt.value !== this._placeholderText) { this._edTxt.style.color = cc.colorToHex(color); } }, @@ -440,7 +440,7 @@ cc.EditBox = cc.ControlButton.extend({ if (text != null) { var oldPlaceholderText = this._placeholderText; this._placeholderText = text; - if (this._edTxt.value == oldPlaceholderText) { + if (this._edTxt.value === oldPlaceholderText) { this._edTxt.value = text; this._edTxt.style.color = cc.colorToHex(this._placeholderColor); this._setPlaceholderFontToEditText(); @@ -486,7 +486,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"; this._edTxt.type = "text"; @@ -499,7 +499,7 @@ cc.EditBox = cc.ControlButton.extend({ */ setPlaceholderFontColor: function (color) { this._placeholderColor = color; - if (this._edTxt.value == this._placeholderText) { + if (this._edTxt.value === this._placeholderText) { this._edTxt.style.color = cc.colorToHex(color); } }, @@ -511,7 +511,7 @@ cc.EditBox = cc.ControlButton.extend({ */ setInputFlag: function (inputFlag) { this._editBoxInputFlag = inputFlag; - if ((this._edTxt.value !== this._placeholderText) && (inputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD)) + if ((this._edTxt.value !== this._placeholderText) && (inputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD)) this._edTxt.type = "password"; else this._edTxt.type = "text"; diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index fb62932ed3..c38ac03136 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -291,7 +291,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ * @param {Number} newRotation */ setRotation:function (newRotation) { - if (this._rotation == newRotation) + if (this._rotation === newRotation) return; this._rotationX = this._rotationY = newRotation; @@ -360,7 +360,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{ //if dom does not have parent, but node has no parent and its running if (this.dom && !this.dom.parentNode) { if (!this.getParent()) { - if(this.dom.id == ""){ + if(this.dom.id === ""){ cc.DOM._createEGLViewDiv(this); }else{ this.dom.appendTo(cc.container); @@ -451,7 +451,7 @@ cc.DOM._resetEGLViewDiv = function(){ div.style.margin = 0; div.resize(view.getScaleX()/pixelRatio, view.getScaleY()/pixelRatio); - if (view.getResolutionPolicy() == view._rpNoBorder) { + if (view.getResolutionPolicy() === view._rpNoBorder) { div.style.left = (view.getFrameSize().width - designSizeWidth)/2 + "px"; div.style.bottom = (view.getFrameSize().height - designSizeHeight*view.getScaleY()/pixelRatio)/2 + "px"; } @@ -528,7 +528,7 @@ cc.DOM._createEGLViewDiv = function(p){ div.style.margin = 0; div.resize(view.getScaleX()/pixelRatio, view.getScaleY()/pixelRatio); - if (view.getResolutionPolicy() == view._rpNoBorder) { + if (view.getResolutionPolicy() === view._rpNoBorder) { div.style.left = (screenSize.width - designSizeWidth)/2 + "px"; div.style.bottom = (screenSize.height - designSizeHeight*view.getScaleY()/pixelRatio)/2 + "px"; } @@ -632,7 +632,7 @@ cc.DOM.convert = function (nodeObject) { if (arguments.length > 1) { cc.DOM.convert(arguments); return; - } else if (arguments.length == 1 && !arguments[0].length) { + } else if (arguments.length === 1 && !arguments[0].length) { cc.DOM.convert([arguments[0]]); return; } diff --git a/extensions/gui/control-extension/CCControl.js b/extensions/gui/control-extension/CCControl.js index cb4011c241..2ff72a7ee7 100644 --- a/extensions/gui/control-extension/CCControl.js +++ b/extensions/gui/control-extension/CCControl.js @@ -335,9 +335,9 @@ cc.Control = cc.Layer.extend(/** @lends cc.Control# */{ var invocation = eventInvocationList[i]; var shouldBeRemoved = true; if (target) - shouldBeRemoved = (target == invocation.getTarget()); + shouldBeRemoved = (target === invocation.getTarget()); if (action) - shouldBeRemoved = (shouldBeRemoved && (action == invocation.getAction())); + shouldBeRemoved = (shouldBeRemoved && (action === invocation.getAction())); // Remove the corresponding invocation object if (shouldBeRemoved) cc.arrayRemoveObject(eventInvocationList, invocation); diff --git a/extensions/gui/control-extension/CCControlButton.js b/extensions/gui/control-extension/CCControlButton.js index 6f198bc9a3..068a649ff8 100644 --- a/extensions/gui/control-extension/CCControlButton.js +++ b/extensions/gui/control-extension/CCControlButton.js @@ -461,7 +461,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ this._titleDispatchTable[state] = title || ""; // If the current state if equal to the given state we update the layout - if (this.getState() == state) + if (this.getState() === state) this.needsLayout(); }, @@ -492,7 +492,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ this._titleColorDispatchTable[state] = color; // If the current state if equal to the given state we update the layout - if (this.getState() == state) + if (this.getState() === state) this.needsLayout(); }, @@ -531,7 +531,7 @@ cc.ControlButton = cc.Control.extend(/** @lends cc.ControlButton# */{ this.addChild(titleLabel, 1); // If the current state if equal to the given state we update the layout - if (this.getState() == state) + if (this.getState() === state) this.needsLayout(); }, diff --git a/extensions/gui/control-extension/CCControlColourPicker.js b/extensions/gui/control-extension/CCControlColourPicker.js index 4e7a49f039..6cdfd6bcc8 100644 --- a/extensions/gui/control-extension/CCControlColourPicker.js +++ b/extensions/gui/control-extension/CCControlColourPicker.js @@ -151,7 +151,7 @@ cc.ControlColourPicker = cc.Control.extend(/** @lends cc.ControlColourPicker# */ }, setEnabled:function (enabled) { cc.Control.prototype.setEnabled.call(this, enabled); - if (this._huePicker != null) { + if (this._huePicker !== null) { this._huePicker.setEnabled(enabled); } if (this._colourPicker) { diff --git a/extensions/gui/control-extension/CCControlPotentiometer.js b/extensions/gui/control-extension/CCControlPotentiometer.js index 3fb2d8bba1..7c035efd5c 100644 --- a/extensions/gui/control-extension/CCControlPotentiometer.js +++ b/extensions/gui/control-extension/CCControlPotentiometer.js @@ -99,7 +99,7 @@ cc.ControlPotentiometer = cc.Control.extend(/** @lends cc.ControlPotentiometer# setEnabled:function (enabled) { this.setEnabled(enabled); - if (this._thumbSprite != NULL) { + if (this._thumbSprite !== null) { this._thumbSprite.setOpacity((enabled) ? 255 : 128); } }, diff --git a/extensions/gui/control-extension/CCControlStepper.js b/extensions/gui/control-extension/CCControlStepper.js index f9757cc3b2..5dbc5e5d63 100644 --- a/extensions/gui/control-extension/CCControlStepper.js +++ b/extensions/gui/control-extension/CCControlStepper.js @@ -210,8 +210,8 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{ this._value = value; if (!this._wraps) { - this._minusLabel.setColor((value == this._minimumValue) ? cc.CONTROL_STEPPER_LABELCOLOR_DISABLED : cc.CONTROL_STEPPER_LABELCOLOR_ENABLED); - this._plusLabel.setColor((value == this._maximumValue) ? cc.CONTROL_STEPPER_LABELCOLOR_DISABLED : cc.CONTROL_STEPPER_LABELCOLOR_ENABLED); + this._minusLabel.setColor((value === this._minimumValue) ? cc.CONTROL_STEPPER_LABELCOLOR_DISABLED : cc.CONTROL_STEPPER_LABELCOLOR_ENABLED); + this._plusLabel.setColor((value === this._maximumValue) ? cc.CONTROL_STEPPER_LABELCOLOR_DISABLED : cc.CONTROL_STEPPER_LABELCOLOR_ENABLED); } if (send) { @@ -232,12 +232,12 @@ cc.ControlStepper = cc.Control.extend(/** @lends cc.ControlStepper# */{ update:function (dt) { this._autorepeatCount++; - if ((this._autorepeatCount < cc.AUTOREPEAT_INCREASETIME_INCREMENT) && (this._autorepeatCount % 3) != 0) + if ((this._autorepeatCount < cc.AUTOREPEAT_INCREASETIME_INCREMENT) && (this._autorepeatCount % 3) !== 0) return; - if (this._touchedPart == cc.CONTROL_STEPPER_PARTMINUS) { + if (this._touchedPart === cc.CONTROL_STEPPER_PARTMINUS) { this.setValueWithSendingEvent(this._value - this._stepValue, this._continuous); - } else if (this._touchedPart == cc.CONTROL_STEPPER_PARTPLUS) { + } else if (this._touchedPart === cc.CONTROL_STEPPER_PARTPLUS) { this.setValueWithSendingEvent(this._value + this._stepValue, this._continuous); } }, diff --git a/extensions/gui/control-extension/CCMenuPassive.js b/extensions/gui/control-extension/CCMenuPassive.js index f6600c1c5a..82a3fd32fe 100644 --- a/extensions/gui/control-extension/CCMenuPassive.js +++ b/extensions/gui/control-extension/CCMenuPassive.js @@ -257,7 +257,7 @@ cc.MenuPassive = cc.Layer.extend(/** @lends cc.MenuPassive# */{ if (this._children && this._children.length > 0) { for (i = 0; i < this._children.length; i++) { if (this._children[i]) { - if (rowColumns == 0) { + if (rowColumns === 0) { rowColumns = rows[row]; w = winSize.width / (1 + rowColumns); x = w; diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 1188d28d44..abe7056ef7 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -145,15 +145,15 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var leftWidth = locBottomLeftContentSize.width; var bottomHeight = locBottomLeftContentSize.height; - if (cc._renderType == cc._RENDER_TYPE_WEBGL) { + if (cc._renderType === cc._RENDER_TYPE_WEBGL) { //browser is in canvas mode, need to manually control rounding to prevent overlapping pixels var roundedRescaledWidth = Math.round(rescaledWidth); - if (rescaledWidth != roundedRescaledWidth) { + if (rescaledWidth !== roundedRescaledWidth) { rescaledWidth = roundedRescaledWidth; horizontalScale = rescaledWidth / locCenterContentSize.width; } var roundedRescaledHeight = Math.round(rescaledHeight); - if (rescaledHeight != roundedRescaledHeight) { + if (rescaledHeight !== roundedRescaledHeight) { rescaledHeight = roundedRescaledHeight; verticalScale = rescaledHeight / locCenterContentSize.height; } @@ -497,7 +497,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); - this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); + this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); @@ -505,7 +505,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ } var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9); // the texture is rotated on Canvas render mode, so isRotated always is false. - return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets); + return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets); }, /** @@ -587,7 +587,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // Release old sprites this.removeAllChildren(true); - if (this._scale9Image != batchNode) + if (this._scale9Image !== batchNode) this._scale9Image = batchNode; if(!this._scale9Image) @@ -897,13 +897,13 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); - this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); + this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); },this); } - this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0)); + this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0)); // Reset insets this._insetLeft = 0; diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js index 4d91c032d6..f0acc0bb7a 100644 --- a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -105,7 +105,7 @@ var locCanvas = this._cacheCanvas, wrapper = this._cacheContext, locContext = wrapper.getContext(); var contentSizeChanged = false; - if(locCanvas.width != sizeInPixels.width || locCanvas.height != sizeInPixels.height){ + if(locCanvas.width !== sizeInPixels.width || locCanvas.height !== sizeInPixels.height){ locCanvas.width = sizeInPixels.width; locCanvas.height = sizeInPixels.height; contentSizeChanged = true; diff --git a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js index f133b83c7f..e0379495e0 100644 --- a/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js @@ -89,7 +89,7 @@ proto.setState = function (state) { var scale9Image = this._node._scale9Image; - if(scale9Image == null) + if(scale9Image === null) return; if (state === cc.Scale9Sprite.state.NORMAL) { scale9Image.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); diff --git a/extensions/gui/scrollview/CCScrollView.js b/extensions/gui/scrollview/CCScrollView.js index 854bf08953..6eb3dfbdf9 100644 --- a/extensions/gui/scrollview/CCScrollView.js +++ b/extensions/gui/scrollview/CCScrollView.js @@ -227,11 +227,11 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ } var locContainer = this._container; - if (locContainer.getScale() != scale) { + if (locContainer.getScale() !== scale) { var oldCenter, newCenter; var center; - if (this._touchLength == 0.0) { + if (this._touchLength === 0.0) { var locViewSize = this._viewSize; center = cc.p(locViewSize.width * 0.5, locViewSize.height * 0.5); center = this.convertToWorldSpace(center); @@ -262,7 +262,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ setZoomScaleInDuration:function (s, dt) { if (dt > 0) { var locScale = this._container.getScale(); - if (locScale != s) { + if (locScale !== s) { var scaleAction = cc.actionTween(dt, "zoomScale", locScale, s); this.runAction(scaleAction); } @@ -421,7 +421,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ this._scrollDistance.x = 0; this._scrollDistance.y = 0; this._touchLength = 0.0; - } else if (locTouches.length == 2) { + } else if (locTouches.length === 2) { this._touchPoint = cc.pMidpoint(this.convertTouchToNodeSpace(locTouches[0]), this.convertTouchToNodeSpace(locTouches[1])); this._touchLength = cc.pDistance(locContainer.convertTouchToNodeSpace(locTouches[0]), @@ -514,7 +514,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ if (!this.isVisible()) return; - if (this._touches.length == 1 && this._touchMoved) + if (this._touches.length === 1 && this._touchMoved) this.schedule(this._deaccelerateScrolling); this._touches.length = 0; @@ -532,7 +532,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ }, setContentSize: function (size, height) { - if (this.getContainer() != null) { + if (this.getContainer() !== null) { if(height === undefined) this.getContainer().setContentSize(size); else @@ -542,14 +542,14 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ }, _setWidth: function (value) { var container = this.getContainer(); - if (container != null) { + if (container !== null) { container._setWidth(value); this.updateInset(); } }, _setHeight: function (value) { var container = this.getContainer(); - if (container != null) { + if (container !== null) { container._setHeight(value); this.updateInset(); } @@ -560,7 +560,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ }, updateInset:function () { - if (this.getContainer() != null) { + if (this.getContainer() !== null) { var locViewSize = this._viewSize; var tempOffset = this.maxContainerOffset(); this._maxInset.x = tempOffset.x + locViewSize.width * INSET_RATIO; @@ -599,7 +599,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ //child.ignoreAnchorPointForPosition(false); //child.setAnchorPoint(0, 0); - if (this._container != child) { + if (this._container !== child) { this._container.addChild(child, zOrder, tag); } else { cc.Layer.prototype.addChild.call(this, child, zOrder, tag); @@ -607,7 +607,7 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ }, isTouchEnabled: function(){ - return this._touchListener != null; + return this._touchListener !== null; }, setTouchEnabled:function (e) { @@ -663,12 +663,12 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ newX = Math.min(newX, max.x); } - if (locDirection == cc.SCROLLVIEW_DIRECTION_BOTH || locDirection == cc.SCROLLVIEW_DIRECTION_VERTICAL) { + if (locDirection === cc.SCROLLVIEW_DIRECTION_BOTH || locDirection === cc.SCROLLVIEW_DIRECTION_VERTICAL) { newY = Math.min(newY, max.y); newY = Math.max(newY, min.y); } - if (newY != oldPoint.y || newX != oldPoint.x) { + if (newY !== oldPoint.y || newX !== oldPoint.x) { this.setContentOffset(cc.p(newX, newY), animated); } }, @@ -709,8 +709,8 @@ cc.ScrollView = cc.Layer.extend(/** @lends cc.ScrollView# */{ Math.abs(locScrollDistance.y) <= SCROLL_DEACCEL_DIST) || newY > maxInset.y || newY < minInset.y || newX > maxInset.x || newX < minInset.x || - newX == maxInset.x || newX == minInset.x || - newY == maxInset.y || newY == minInset.y) { + newX === maxInset.x || newX === minInset.x || + newY === maxInset.y || newY === minInset.y) { this.unschedule(this._deaccelerateScrolling); this._relocateContainer(true); } diff --git a/extensions/gui/scrollview/CCSorting.js b/extensions/gui/scrollview/CCSorting.js index 8d53f3c4c3..8aaf500710 100644 --- a/extensions/gui/scrollview/CCSorting.js +++ b/extensions/gui/scrollview/CCSorting.js @@ -103,14 +103,14 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# * @param {Object} delObject Object to remove */ removeSortedObject:function (delObject) { - if (this.count() == 0) { + if (this.count() === 0) { return; } var idx = this.indexOfSortedObject(delObject); - if (idx < this.count() && idx != cc.INVALID_INDEX) { + if (idx < this.count() && idx !== cc.INVALID_INDEX) { var foundObj = this.objectAtIndex(idx); - if (foundObj.getObjectID() == delObject.getObjectID()) { + if (foundObj.getObjectID() === delObject.getObjectID()) { this.removeObjectAtIndex(idx); } } @@ -129,9 +129,9 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# */ setObjectID_ofSortedObject:function (tag, setObject) { var idx = this.indexOfSortedObject(setObject); - if (idx < this.count() && idx != cc.INVALID_INDEX) { + if (idx < this.count() && idx !== cc.INVALID_INDEX) { var foundObj = this.objectAtIndex(idx); - if (foundObj.getObjectID() == setObject.getObjectID()) { + if (foundObj.getObjectID() === setObject.getObjectID()) { this.removeObjectAtIndex(idx); foundObj.setObjectID(tag); this.insertSortedObject(foundObj); @@ -140,16 +140,16 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# }, objectWithObjectID:function (tag) { - if (this.count() == 0) { + if (this.count() === 0) { return null; } var foundObj = new cc.SortedObject(); foundObj.setObjectID(tag); var idx = this.indexOfSortedObject(foundObj); - if (idx < this.count() && idx != cc.INVALID_INDEX) { + if (idx < this.count() && idx !== cc.INVALID_INDEX) { foundObj = this.objectAtIndex(idx); - if (foundObj.getObjectID() != tag) + if (foundObj.getObjectID() !== tag) foundObj = null; } return foundObj; @@ -193,7 +193,7 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# for (var i = 0; i < locObjectArr.length; i++) { var pSortableObj = locObjectArr[i]; var curObjectID = pSortableObj.getObjectID(); - if ((uOfSortObjectID == curObjectID) || + if ((uOfSortObjectID === curObjectID) || (uOfSortObjectID >= uPrevObjectID && uOfSortObjectID < curObjectID)) { break; } @@ -213,7 +213,7 @@ cc.ArrayForObjectSorting = cc.Class.extend(/** @lends cc.ArrayForObjectSorting# lastObject:function () { var locObjectArr = this._saveObjectArr; - if (locObjectArr.length == 0) + if (locObjectArr.length === 0) return null; return locObjectArr[locObjectArr.length - 1]; }, diff --git a/extensions/gui/scrollview/CCTableView.js b/extensions/gui/scrollview/CCTableView.js index f3347aa498..1c27563724 100644 --- a/extensions/gui/scrollview/CCTableView.js +++ b/extensions/gui/scrollview/CCTableView.js @@ -254,7 +254,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ locOffset.y = this.getContainer().getContentSize().height - locOffset.y; var index = this.__indexFromOffset(locOffset); - if (index != -1) { + if (index !== -1) { index = Math.max(0, index); if (index > maxIdx) index = cc.INVALID_INDEX; @@ -328,8 +328,8 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ this.setContentSize(size); - if (this._oldDirection != this._direction) { - if (this._direction == cc.SCROLLVIEW_DIRECTION_HORIZONTAL) { + if (this._oldDirection !== this._direction) { + if (this._direction === cc.SCROLLVIEW_DIRECTION_HORIZONTAL) { this.setContentOffset(cc.p(0, 0)); } else { this.setContentOffset(cc.p(0, this.minContainerOffset().y)); @@ -347,7 +347,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ cc.arrayRemoveObject(this._indices, cell.getIdx()); cell.reset(); - if (cell.getParent() == this.getContainer()) { + if (cell.getParent() === this.getContainer()) { this.getContainer().removeChild(cell, true); } }, @@ -359,12 +359,12 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ }, _addCellIfNecessary:function (cell) { - if (cell.getParent() != this.getContainer()) { + if (cell.getParent() !== this.getContainer()) { this.getContainer().addChild(cell); } this._cellsUsed.insertSortedObject(cell); var locIndices = this._indices, addIdx = cell.getIdx(); - if(locIndices.indexOf(addIdx) == -1){ + if(locIndices.indexOf(addIdx) === -1){ locIndices.push(addIdx); //sort locIndices.sort(function(a,b){return a-b;}); @@ -396,7 +396,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ * determines how cell is ordered and filled in the view. */ setVerticalFillOrder:function (fillOrder) { - if (this._vOrdering != fillOrder) { + if (this._vOrdering !== fillOrder) { this._vOrdering = fillOrder; if (this._cellsUsed.count() > 0) { this.reloadData(); @@ -428,7 +428,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ * @param idx index to find a cell */ updateCellAtIndex:function (idx) { - if (idx == cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) + if (idx === cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) return; var cell = this.cellAtIndex(idx); @@ -446,7 +446,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ * @param idx location to insert */ insertCellAtIndex:function (idx) { - if (idx == cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) + if (idx === cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) return; var newIdx, locCellsUsed = this._cellsUsed; @@ -474,7 +474,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ * @param idx index to find a cell */ removeCellAtIndex:function (idx) { - if (idx == cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) + if (idx === cc.INVALID_INDEX || idx > this._dataSource.numberOfCellsInTableView(this) - 1) return; var cell = this.cellAtIndex(idx); @@ -509,7 +509,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ locCellsFreed.addObject(cell); cell.reset(); - if (cell.getParent() == locContainer) + if (cell.getParent() === locContainer) locContainer.removeChild(cell, true); } @@ -545,7 +545,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ */ cellAtIndex:function (idx) { var i = this._indices.indexOf(idx); - if (i == -1) + if (i === -1) return null; return this._cellsUsed.objectWithObjectID(idx); }, @@ -556,7 +556,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ if (0 === countOfItems) return; - if (this._tableViewDelegate != null && this._tableViewDelegate.scrollViewDidScroll) + if (this._tableViewDelegate !== null && this._tableViewDelegate.scrollViewDidScroll) this._tableViewDelegate.scrollViewDidScroll(this); var idx = 0, locViewSize = this._viewSize, locContainer = this.getContainer(); @@ -611,7 +611,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ var locIndices = this._indices; for (var i = startIdx; i <= endIdx; i++) { - if (locIndices.indexOf(i) != -1) + if (locIndices.indexOf(i) !== -1) continue; this.updateCellAtIndex(i); } @@ -631,7 +631,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ bb.x = tmpOrigin.x; bb.y = tmpOrigin.y; var locTableViewDelegate = this._tableViewDelegate; - if (cc.rectContainsPoint(bb, touch.getLocation()) && locTableViewDelegate != null){ + if (cc.rectContainsPoint(bb, touch.getLocation()) && locTableViewDelegate !== null){ if(locTableViewDelegate.tableCellUnhighlight) locTableViewDelegate.tableCellUnhighlight(this, this._touchedCell); if(locTableViewDelegate.tableCellTouched) @@ -659,10 +659,10 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ else this._touchedCell = this.cellAtIndex(index); - if (this._touchedCell && this._tableViewDelegate != null && this._tableViewDelegate.tableCellHighlight) + if (this._touchedCell && this._tableViewDelegate !== null && this._tableViewDelegate.tableCellHighlight) this._tableViewDelegate.tableCellHighlight(this, this._touchedCell); } else if(this._touchedCell) { - if(this._tableViewDelegate != null && this._tableViewDelegate.tableCellUnhighlight) + if(this._tableViewDelegate !== null && this._tableViewDelegate.tableCellUnhighlight) this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell); this._touchedCell = null; } @@ -674,7 +674,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ cc.ScrollView.prototype.onTouchMoved.call(this, touch, event); if (this._touchedCell && this.isTouchMoved()) { - if(this._tableViewDelegate != null && this._tableViewDelegate.tableCellUnhighlight) + if(this._tableViewDelegate !== null && this._tableViewDelegate.tableCellUnhighlight) this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell); this._touchedCell = null; } @@ -684,7 +684,7 @@ cc.TableView = cc.ScrollView.extend(/** @lends cc.TableView# */{ cc.ScrollView.prototype.onTouchCancelled.call(this, touch, event); if (this._touchedCell) { - if(this._tableViewDelegate != null && this._tableViewDelegate.tableCellUnhighlight) + if(this._tableViewDelegate !== null && this._tableViewDelegate.tableCellUnhighlight) this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell); this._touchedCell = null; } From 099a99d7d94eaa8d5d027a7f069a896ed6952856 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 18 Mar 2015 09:47:44 +0800 Subject: [PATCH 1424/1564] Fixed #2742: corrected some mistakes after using '===' to replace '==' --- cocos2d/core/base-nodes/CCNode.js | 2 ++ cocos2d/shaders/CCGLProgram.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index b2888ae0fd..6cb06db921 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -186,6 +186,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _renderCmd:null, + _camera: null, + /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. * @function diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 283a2f5390..4e63c3c435 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -106,7 +106,7 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ else cc.log("cocos2d: \n" + this.fragmentShaderLog()); } - return ( status === 1 ); + return ( status === true ); }, /** From fb1883a46333520c390dad5c397a89588c0f7890 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 18 Mar 2015 11:55:30 +0800 Subject: [PATCH 1425/1564] Fixed a bug of template/main.js that if loading.js doesn't add. --- template/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/main.js b/template/main.js index dcbd88808c..b0afefa923 100644 --- a/template/main.js +++ b/template/main.js @@ -1,5 +1,5 @@ cc.game.onStart = function(){ - if(!cc.sys.isNative) //If referenced loading.js, please remove it + if(!cc.sys.isNative && document.getElementById("cocosLoading")) //If referenced loading.js, please remove it document.body.removeChild(document.getElementById("cocosLoading")); var designSize = cc.size(480, 800); From 851bbbf15de23d75b584ca33f8557990a33fdf63 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 18 Mar 2015 14:20:57 +0800 Subject: [PATCH 1426/1564] Moved loading.js to res folder for Cocos console release mode. --- template/index.html | 2 +- template/{src => res}/loading.js | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename template/{src => res}/loading.js (100%) diff --git a/template/index.html b/template/index.html index 776f7d11d7..e0f577b927 100644 --- a/template/index.html +++ b/template/index.html @@ -23,7 +23,7 @@ - + \ No newline at end of file diff --git a/template/src/loading.js b/template/res/loading.js similarity index 100% rename from template/src/loading.js rename to template/res/loading.js From 9ba7709db1f80ac0a32c621180fcb29346d4583b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 18 Mar 2015 18:07:26 +0800 Subject: [PATCH 1427/1564] Fixed a bug of Cocostudio parser that widget doesn't set layoutComponent expect Layout --- .../loader/parsers/timelineParser-2.x.js | 153 +++++++++--------- 1 file changed, 75 insertions(+), 78 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index e3a9f47f3f..540d34de2e 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -208,7 +208,7 @@ // WIDGET // //////////// - parser.widgetAttributes = function(widget, json){ + parser.widgetAttributes = function(widget, json) { widget.setCascadeColorEnabled(true); widget.setCascadeOpacityEnabled(true); @@ -218,7 +218,7 @@ setContentSize(widget, json["Size"]); var name = json["Name"]; - if(name) + if (name) widget.setName(name); var actionTag = json["ActionTag"] || 0; @@ -226,25 +226,25 @@ widget.setUserObject(new ccs.ActionTimelineData(actionTag)); var rotationSkewX = json["RotationSkewX"]; - if(rotationSkewX) + if (rotationSkewX) widget.setRotationX(rotationSkewX); var rotationSkewY = json["RotationSkewY"]; - if(rotationSkewY) + if (rotationSkewY) widget.setRotationY(rotationSkewY); //var rotation = json["Rotation"]; var flipX = json["FlipX"]; - if(flipX) + if (flipX) widget.setFlippedX(true); var flipY = json["FlipY"]; - if(flipY) + if (flipY) widget.setFlippedY(true); var zOrder = json["zOrder"]; - if(zOrder != null) + if (zOrder != null) widget.setLocalZOrder(zOrder); //var visible = json["Visible"]; @@ -253,7 +253,7 @@ widget.setVisible(visible); var alpha = json["Alpha"]; - if(alpha != null) + if (alpha != null) widget.setOpacity(alpha); widget.setTag(json["Tag"] || 0); @@ -264,19 +264,19 @@ // -- var frameEvent = json["FrameEvent"]; var callBackType = json["CallBackType"]; - if(callBackType != null) + if (callBackType != null) widget.setCallbackType(callBackType); var callBackName = json["CallBackName"]; - if(callBackName) + if (callBackName) widget.setCallbackName(callBackName); var position = json["Position"]; - if(position != null) + if (position != null) widget.setPosition(position["X"] || 0, position["Y"] || 0); var scale = json["Scale"]; - if(scale != null){ + if (scale != null) { var scaleX = getParam(scale["ScaleX"], 1); var scaleY = getParam(scale["ScaleY"], 1); widget.setScaleX(scaleX); @@ -284,80 +284,77 @@ } var anchorPoint = json["AnchorPoint"]; - if(anchorPoint != null) + if (anchorPoint != null) widget.setAnchorPoint(anchorPoint["ScaleX"] || 0, anchorPoint["ScaleY"] || 0); var color = json["CColor"]; - if(color != null) + if (color != null) widget.setColor(getColor(color)); - if(widget instanceof ccui.Layout){ - var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); - - var positionXPercentEnabled = json["PositionPercentXEnable"] || false; - var positionYPercentEnabled = json["PositionPercentYEnable"] || false; - var positionXPercent = 0, - positionYPercent = 0, - PrePosition = json["PrePosition"]; - if(PrePosition != null){ - positionXPercent = PrePosition["X"] || 0; - positionYPercent = PrePosition["Y"] || 0; - } - var sizeXPercentEnable = json["PercentWidthEnable"] || false; - var sizeYPercentEnable = json["PercentHeightEnable"] || false; - var sizeXPercent = 0, - sizeYPercent = 0, - PreSize = json["PreSize"]; - if(PrePosition != null){ - sizeXPercent = PreSize["X"] || 0; - sizeYPercent = PreSize["Y"] || 0; - } - var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; - var stretchVerticalEnabled = json["StretchHeightEnable"] || false; - var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; - var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; - var leftMargin = json["LeftMargin"] || 0; - var rightMargin = json["RightMargin"] || 0; - var topMargin = json["TopMargin"] || 0; - var bottomMargin = json["BottomMargin"] || 0; - - layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); - layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); - layoutComponent.setPositionPercentX(positionXPercent); - layoutComponent.setPositionPercentY(positionYPercent); - layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); - layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); - layoutComponent.setPercentWidth(sizeXPercent); - layoutComponent.setPercentHeight(sizeYPercent); - layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); - layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); - - var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; - if (horizontalEdge == "LeftEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; - }else if (horizontalEdge == "RightEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; - }else if (horizontalEdge == "BothEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; - } - layoutComponent.setHorizontalEdge(horizontalEdgeType); - - var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; - if (verticalEdge == "TopEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; - }else if (verticalEdge == "BottomEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; - }else if (verticalEdge == "BothEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; - } - layoutComponent.setVerticalEdge(verticalEdgeType); + var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); - layoutComponent.setTopMargin(topMargin); - layoutComponent.setBottomMargin(bottomMargin); - layoutComponent.setLeftMargin(leftMargin); - layoutComponent.setRightMargin(rightMargin); + var positionXPercentEnabled = json["PositionPercentXEnable"] || false; + var positionYPercentEnabled = json["PositionPercentYEnable"] || false; + var positionXPercent = 0, + positionYPercent = 0, + PrePosition = json["PrePosition"]; + if (PrePosition != null) { + positionXPercent = PrePosition["X"] || 0; + positionYPercent = PrePosition["Y"] || 0; + } + var sizeXPercentEnable = json["PercentWidthEnable"] || false; + var sizeYPercentEnable = json["PercentHeightEnable"] || false; + var sizeXPercent = 0, + sizeYPercent = 0, + PreSize = json["PreSize"]; + if (PrePosition != null) { + sizeXPercent = PreSize["X"] || 0; + sizeYPercent = PreSize["Y"] || 0; + } + var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; + var stretchVerticalEnabled = json["StretchHeightEnable"] || false; + var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; + var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; + var leftMargin = json["LeftMargin"] || 0; + var rightMargin = json["RightMargin"] || 0; + var topMargin = json["TopMargin"] || 0; + var bottomMargin = json["BottomMargin"] || 0; + + layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); + layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); + layoutComponent.setPositionPercentX(positionXPercent); + layoutComponent.setPositionPercentY(positionYPercent); + layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); + layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); + layoutComponent.setPercentWidth(sizeXPercent); + layoutComponent.setPercentHeight(sizeYPercent); + layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); + layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); + + var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; + if (horizontalEdge == "LeftEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; + } else if (horizontalEdge == "RightEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; + } else if (horizontalEdge == "BothEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; + } + layoutComponent.setHorizontalEdge(horizontalEdgeType); + + var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; + if (verticalEdge == "TopEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; + } else if (verticalEdge == "BottomEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; + } else if (verticalEdge == "BothEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; } + layoutComponent.setVerticalEdge(verticalEdgeType); + layoutComponent.setTopMargin(topMargin); + layoutComponent.setBottomMargin(bottomMargin); + layoutComponent.setLeftMargin(leftMargin); + layoutComponent.setRightMargin(rightMargin); }; /** From 666ce3a8a6975eff71e36b0eba0740a908f25736 Mon Sep 17 00:00:00 2001 From: igogo Date: Wed, 18 Mar 2015 12:36:55 +0200 Subject: [PATCH 1428/1564] Add support installing from bower.io --- bower.json | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000000..9ea43d8147 --- /dev/null +++ b/bower.json @@ -0,0 +1,37 @@ +{ + "name": "cocos2d-html5", + "version": "3.4", + "homepage": "http://www.cocos2d-x.org", + "authors": [ + "AUTHORS.txt" + ], + "description": "Cocos2d-html5 is a cross-platform 2D game engine written in Javascript, based on Cocos2d-X and licensed under MIT. It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X. It currently supports canvas and will support WebGL in the future.", + "main": "README.mdown", + "keywords": [ + "cocos2d-x", + "cocos2d", + "game", + "engine", + "opengl", + "cross", + "multi", + "platform", + "iphone", + "ipad", + "android", + "windows", + "metro", + "bada", + "marmalade", + "playbook" + ], + "license": "MIT", + "private": false, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} From 18c0b49bdd0d050068aa3ae80ee06b15c6ab8a87 Mon Sep 17 00:00:00 2001 From: igogo Date: Wed, 18 Mar 2015 12:42:33 +0200 Subject: [PATCH 1429/1564] . --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 9ea43d8147..0c5aa5db1e 100644 --- a/bower.json +++ b/bower.json @@ -34,4 +34,4 @@ "test", "tests" ] -} +} \ No newline at end of file From 585c9622a600fb88bdc02f980d665d273b95dbfc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 19 Mar 2015 00:06:55 +0800 Subject: [PATCH 1430/1564] Update engine version --- cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index e33721a2b8..e7f788bd95 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.3"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.4 beta"; /** *

    diff --git a/tools/build.xml b/tools/build.xml index c1d0858cb8..2d1913ae0a 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.4-beta-min.js"> @@ -298,7 +298,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.4-beta-core-min.js"> From 391c2841d90b985e959742c04509a46c7b93fd45 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 19 Mar 2015 09:42:53 +0800 Subject: [PATCH 1431/1564] Update the README.mdown --- README.mdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mdown b/README.mdown index 5e3bc6adcd..3e545138cb 100644 --- a/README.mdown +++ b/README.mdown @@ -3,7 +3,7 @@ Cocos2d-html5 [Cocos2d-html5][1] is a cross-platform 2D game engine written in Javascript, based on [Cocos2d-X][2] and licensed under MIT. It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X. -It currently supports canvas and will support WebGL in the future. +It currently supports canvas and WebGL renderer. Cross Platform ------------- From a09ac4289d3b8278c0c58f37df4c83b05278bbae Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 19 Mar 2015 17:47:12 +0800 Subject: [PATCH 1432/1564] Update Changelog --- CHANGELOG.txt | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 58ea7b6413..cb53252b0c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,44 @@ ChangeLog: +Cocos2d-JS v3.4 Beta0 @ March 19 2015 + +* Added Windows Phone 8.0 platform support. +* Upgraded SpiderMonkey to v33, greatly improved JS object garbage collection and performance. +* Bound 3D modules including camera, light, sprite 3d, animation 3d, billboard, etc. +* Improved `cc.FontDefinition` & `ccui.RichText` in the web engine. +* Added gradient stops feature to `cc.LayerGradient` [Web exclusive]. +* Upgraded `cc.Scheduler` in the web engine with Cocos2d-x v3.4 implementation. +* Added a loading screen when scripts are loading. +* Improved performance by replacing `Object.defineProperties` with `cc.defineGetterSetter`. +* Supported loading sprite frames from json object. +* Refactored math library to improve web engine performance. +* Removed some variables from `cc` namespace to improve web engine performance. +* Added the Firefox OS Web manifest to support Firefox OS apps. +* Added `cocos` attr to the script element in templates. +* Moved loading.js to res folder for Cocos Console release mode. + +* Bug fixes: + 1. Added `getSpriteFrame` to `cc.Sprite` to fix API inconsistency. + 2. Added `getObejct` to `cc.TMXObjectGroup` to fix API inconsistency. + 3. Added `addImageAsync` to `cc.textureCache` to fix API inconsistency. + 4. Fixed a bug of `cc.text` that its default font name is incorrect. + 5. Fixed a bug of `ccui.PageView` that its `getPage` doesn't work. + 6. Fixed a bug of `ccui.ImageView` that its `loadTexture` doesn't work while it's invoked multiple times at the same frame. + 7. Fixed a bug of `ccui` that its load event callbacks have some mistakes. + 8. Fixed a bug of `cc.Layer` that its bake function doesn't work when the layer has a parent node. + 9. Fixed typos in `cc.ClippingNode.WebGLRenderCmd` and `cc.ParticleSystem.WebGLRenderCmd` creation. + 10. Fixed a bug of `cc.Sprite` in `setTextureRect`. + 11. Fixed a bug of `cc.Screen`. + 12. Fixed a bug of `cc.view` that it doesn't work on iOS 8.1.2. + 13. Fixed a bug of cc.DrawNode that its lineWidth is always to default value when set linewidth to zero. + 14. Fixed a bug in hack for particles performance on canvas. + 15. Fixed a bug of `cc.audioEngine` that it doesn't work after minified/compiled. + 16. Fixed a bug in `CCBoot.js` that WebGL is not activated in web view of iOS 8. + 17. Fixed a bug of `cc.CheckBox` that its position is incorrect when its texture isn't preloaded. + 18. Fixed a bug of `cc.TMXLayer` that it stops to work after `setTileGID` called. + 19. Fixed a bug of Cocos parser 2.x that it doesn't set widget's LayoutComponent. + 20. Fixed a bug of `cc.isObject` that it considered function as an object. + Cocos2d-JS v3.3 @ Feb.9, 2015 * Upgraded spine runtime to support the latest version and updated its test case. From f53c6dfe86061f30c9429f9d59d244888b783161 Mon Sep 17 00:00:00 2001 From: igogo Date: Thu, 19 Mar 2015 20:57:52 +0200 Subject: [PATCH 1433/1564] change description --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 0c5aa5db1e..5493b6e512 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "authors": [ "AUTHORS.txt" ], - "description": "Cocos2d-html5 is a cross-platform 2D game engine written in Javascript, based on Cocos2d-X and licensed under MIT. It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X. It currently supports canvas and will support WebGL in the future.", + "description": "Cocos2d-html5 is a cross-platform 2D game engine written in Javascript, based on Cocos2d-X and licensed under MIT. It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X. It currently supports canvas and WebGL renderering.", "main": "README.mdown", "keywords": [ "cocos2d-x", From 80582fb44207c566217c6b5d891a21ce061a46b7 Mon Sep 17 00:00:00 2001 From: Thomas Jablonski Date: Thu, 19 Mar 2015 20:02:18 +0100 Subject: [PATCH 1434/1564] Fixed grammatical mistakes in cocostudio logs --- extensions/cocostudio/loader/load.js | 4 ++-- extensions/cocostudio/loader/parsers/action-1.x.js | 4 ++-- extensions/cocostudio/loader/parsers/action-2.x.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index 4a46b956b7..e47bbaec7e 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -35,7 +35,7 @@ ccs._load = (function(){ var json = cc.loader.getRes(file); if(!json) - return cc.log("%s is not exists", file); + return cc.log("%s does not exist", file); var ext = extname(file).toLocaleLowerCase(); if(ext !== "json" && ext !== "exportjson") return cc.log("%s load error, must be json file", file); @@ -218,4 +218,4 @@ ccs.csLoader = { createNode: function(file){ return ccs._load(file); } -}; \ No newline at end of file +}; diff --git a/extensions/cocostudio/loader/parsers/action-1.x.js b/extensions/cocostudio/loader/parsers/action-1.x.js index c5c20446c4..0c17159213 100644 --- a/extensions/cocostudio/loader/parsers/action-1.x.js +++ b/extensions/cocostudio/loader/parsers/action-1.x.js @@ -51,7 +51,7 @@ if(parser) frame = parser.call(self, timeline, resourcePath); else - cc.log("parser is not exists : %s", timeline["frameType"]); + cc.log("parser does not exist : %s", timeline["frameType"]); if(frame) action.addTimeline(frame); @@ -235,4 +235,4 @@ load.registerParser("action", "*", parser); -})(ccs._load, ccs._parser); \ No newline at end of file +})(ccs._load, ccs._parser); diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 8916285cbf..ac0fccd291 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -52,7 +52,7 @@ if(parser) frame = parser.call(self, timeline, resourcePath); else - cc.log("parser is not exists : %s", timeline["Property"]); + cc.log("parser does not exist : %s", timeline["Property"]); if(frame) action.addTimeline(frame); }); From 28295587b478c572cb65d652bf24ad1c7db36d04 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 20 Mar 2015 09:51:30 +0800 Subject: [PATCH 1435/1564] Issue #2698: refactor cc.pointApplyAffineTransform --- cocos2d/core/CCScheduler.js | 2 +- cocos2d/core/cocoa/CCAffineTransform.js | 39 ++++++++++++-------- cocos2d/core/layers/CCLayer.js | 2 +- cocos2d/core/layers/CCLayerWebGLRenderCmd.js | 4 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 510b21735b..ec341b58ff 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -285,7 +285,7 @@ cc.TimerTargetCallback = cc.Timer.extend({ * * @example * //register a schedule to scheduler - * cc.director.getScheduler().scheduleSelector(callback, this, interval, !this._isRunning); + * cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); */ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ _timeScale:1.0, diff --git a/cocos2d/core/cocoa/CCAffineTransform.js b/cocos2d/core/cocoa/CCAffineTransform.js index 1135c252a3..d979b9d61b 100644 --- a/cocos2d/core/cocoa/CCAffineTransform.js +++ b/cocos2d/core/cocoa/CCAffineTransform.js @@ -66,17 +66,26 @@ cc.affineTransformMake = function (a, b, c, d, tx, ty) { * Apply the affine transformation on a point. * @function * - * @param {cc.Point} point - * @param {cc.AffineTransform} t + * @param {cc.Point|Number} point or x + * @param {cc.AffineTransform|Number} transOrY transform matrix or y + * @param {cc.AffineTransform} t transform matrix or y * @return {cc.Point} */ -cc.pointApplyAffineTransform = function (point, t) { - return {x: t.a * point.x + t.c * point.y + t.tx, y: t.b * point.x + t.d * point.y + t.ty}; +cc.pointApplyAffineTransform = function (point, transOrY, t) { + var x, y; + if (t === undefined) { + t = transOrY; + x = point.x; + y = point.y; + } else { + x = point; + y = transOrY; + } + return {x: t.a * x + t.c * y + t.tx, y: t.b * x + t.d * y + t.ty}; }; -cc._pointApplyAffineTransform = function (x, y, t) { - return {x: t.a * x + t.c * y + t.tx, - y: t.b * x + t.d * y + t.ty}; +cc._pointApplyAffineTransform = function (x, y, t) { //it will remove. + return cc.pointApplyAffineTransform(x, y, t); }; /** @@ -131,10 +140,10 @@ cc.rectApplyAffineTransform = function (rect, anAffineTransform) { var right = cc.rectGetMaxX(rect); var bottom = cc.rectGetMaxY(rect); - var topLeft = cc._pointApplyAffineTransform(left, top, anAffineTransform); - var topRight = cc._pointApplyAffineTransform(right, top, anAffineTransform); - var bottomLeft = cc._pointApplyAffineTransform(left, bottom, anAffineTransform); - var bottomRight = cc._pointApplyAffineTransform(right, bottom, anAffineTransform); + var topLeft = cc.pointApplyAffineTransform(left, top, anAffineTransform); + var topRight = cc.pointApplyAffineTransform(right, top, anAffineTransform); + var bottomLeft = cc.pointApplyAffineTransform(left, bottom, anAffineTransform); + var bottomRight = cc.pointApplyAffineTransform(right, bottom, anAffineTransform); var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); @@ -150,10 +159,10 @@ cc._rectApplyAffineTransformIn = function(rect, anAffineTransform){ var right = cc.rectGetMaxX(rect); var bottom = cc.rectGetMaxY(rect); - var topLeft = cc._pointApplyAffineTransform(left, top, anAffineTransform); - var topRight = cc._pointApplyAffineTransform(right, top, anAffineTransform); - var bottomLeft = cc._pointApplyAffineTransform(left, bottom, anAffineTransform); - var bottomRight = cc._pointApplyAffineTransform(right, bottom, anAffineTransform); + var topLeft = cc.pointApplyAffineTransform(left, top, anAffineTransform); + var topRight = cc.pointApplyAffineTransform(right, top, anAffineTransform); + var bottomLeft = cc.pointApplyAffineTransform(left, bottom, anAffineTransform); + var bottomRight = cc.pointApplyAffineTransform(right, bottom, anAffineTransform); var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x); diff --git a/cocos2d/core/layers/CCLayer.js b/cocos2d/core/layers/CCLayer.js index c7fd9af7d7..f80af56a0c 100644 --- a/cocos2d/core/layers/CCLayer.js +++ b/cocos2d/core/layers/CCLayer.js @@ -313,7 +313,7 @@ cc.LayerColor.create = function (color, width, height) { * @property {Number} startOpacity - Start opacity of the color gradient * @property {Number} endOpacity - End opacity of the color gradient * @property {Number} vector - Direction vector of the color gradient - * @property {Number} compresseInterpolation - Indicate whether or not the interpolation will be compressed + * @property {Number} compressedInterpolation - Indicate whether or not the interpolation will be compressed */ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{ _endColor: null, diff --git a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js index 812c6d9394..c9314203ac 100644 --- a/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +++ b/cocos2d/core/layers/CCLayerWebGLRenderCmd.js @@ -247,10 +247,10 @@ transMat = cc.affineTransformScale(transMat, tx, ty); for (i = 0; i < stopsLen; i++) { var stop = stops[i], y = stop.p * contentSize.height ; - var p0 = cc._pointApplyAffineTransform(- locAnchor.x , y - locAnchor.y, transMat); + var p0 = cc.pointApplyAffineTransform(- locAnchor.x , y - locAnchor.y, transMat); locVertices[i * 2].x = p0.x; locVertices[i * 2].y = p0.y; - var p1 = cc._pointApplyAffineTransform(contentSize.width - locAnchor.x, y - locAnchor.y, transMat); + var p1 = cc.pointApplyAffineTransform(contentSize.width - locAnchor.x, y - locAnchor.y, transMat); locVertices[i * 2 + 1].x = p1.x; locVertices[i * 2 + 1].y = p1.y; } From 7d353d56e3fec3fab9745453007b4274a8988886 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 20 Mar 2015 10:17:34 +0800 Subject: [PATCH 1436/1564] Add resource path for ccs.load. and modify path for ProjectNode. --- extensions/cocostudio/loader/load.js | 12 ++++--- .../loader/parsers/timelineParser-2.x.js | 34 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index 4a46b956b7..1eba08cf26 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -28,9 +28,10 @@ ccs._load = (function(){ * load file * @param file * @param type - ccui|node|action + * @param path - Resource search path * @returns {*} */ - var load = function(file, type){ + var load = function(file, type, path){ var json = cc.loader.getRes(file); @@ -71,7 +72,7 @@ ccs._load = (function(){ return new cc.Node(); } - return currentParser.parse(file, json) || null; + return currentParser.parse(file, json, path) || null; }; var parser = { @@ -176,16 +177,17 @@ ccs._parser = cc.Class.extend({ * action 1.* - 2.* * scene 0.* - 1.* * @param {String} file + * @param {String} path Resource path * @returns {{node: cc.Node, action: cc.Action}} */ -ccs.load = function(file){ +ccs.load = function(file, path){ var object = { node: null, action: null }; - object.node = ccs._load(file); - object.action = ccs._load(file, "action"); + object.node = ccs._load(file, null, path); + object.action = ccs._load(file, "action", path); if(object.action && object.action.tag === -1 && object.node) object.action.tag = object.node.tag; return object; diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index e3a9f47f3f..1042e9ca91 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -28,8 +28,12 @@ var Parser = baseParser.extend({ - parse: function(file, json){ - var resourcePath = this._dirname(file); + parse: function(file, json, path){ + var resourcePath; + if(path !== undefined) + resourcePath = path; + else + resourcePath = this._dirname(file); this.pretreatment(json, resourcePath, file); var node = this.parseNode(this.getNodeJson(json), resourcePath); this.deferred(json, resourcePath, node, file); @@ -734,10 +738,10 @@ var scale9Width = json["Scale9Width"] || 0; var scale9Height = json["Scale9Height"] || 0; widget.setCapInsets(cc.rect( - scale9OriginX , - scale9OriginY, - scale9Width, - scale9Height + scale9OriginX , + scale9OriginY, + scale9Width, + scale9Height )); } else setContentSize(widget, json["Size"]); @@ -834,10 +838,10 @@ var scale9Width = json["Scale9Width"] || 0; var scale9Height = json["Scale9Height"] || 0; widget.setBackGroundImageCapInsets(cc.rect( - scale9OriginX, - scale9OriginY, - scale9Width, - scale9Height + scale9OriginX, + scale9OriginY, + scale9Width, + scale9Height )); } @@ -900,10 +904,10 @@ var scale9Width = json["Scale9Width"] || 0; var scale9Height = json["Scale9Height"] || 0; widget.setBackGroundImageCapInsets(cc.rect( - scale9OriginX, - scale9OriginY, - scale9Width, - scale9Height + scale9OriginX, + scale9OriginY, + scale9Width, + scale9Height )); } @@ -1146,7 +1150,7 @@ if(projectFile != null && projectFile["Path"]){ var file = resourcePath + projectFile["Path"]; if(cc.loader.getRes(file)){ - var obj = ccs.load(file); + var obj = ccs.load(file, resourcePath); parser.generalAttributes(obj.node, json); if(obj.action && obj.node){ obj.action.tag = obj.node.tag; From c5b69895879bb2441e8f31d985a4f41214f05484 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 20 Mar 2015 10:21:13 +0800 Subject: [PATCH 1437/1564] Add resource path for ccs.load. and modify path for ProjectNode. --- extensions/cocostudio/loader/load.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/loader/load.js b/extensions/cocostudio/loader/load.js index 1eba08cf26..8578034ee0 100644 --- a/extensions/cocostudio/loader/load.js +++ b/extensions/cocostudio/loader/load.js @@ -26,9 +26,9 @@ ccs._load = (function(){ /** * load file - * @param file - * @param type - ccui|node|action - * @param path - Resource search path + * @param {String} file + * @param {String} [type=] - ccui|node|action + * @param {String} [path=] - Resource search path * @returns {*} */ var load = function(file, type, path){ @@ -177,7 +177,7 @@ ccs._parser = cc.Class.extend({ * action 1.* - 2.* * scene 0.* - 1.* * @param {String} file - * @param {String} path Resource path + * @param {String} [path=] Resource path * @returns {{node: cc.Node, action: cc.Action}} */ ccs.load = function(file, path){ From 6bd5193d621584f4b2f3c19ec42dc28353f4c3f9 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 20 Mar 2015 11:02:08 +0800 Subject: [PATCH 1438/1564] Add ActionTimeline animationsList --- .../cocostudio/loader/parsers/action-2.x.js | 20 ++++++------- .../cocostudio/timeline/ActionTimeline.js | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 8916285cbf..287f0cbe10 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -63,17 +63,15 @@ }, deferred: function(json, resourcePath, action, file){ - if(cc.sys.isNative) { - var animationlist = json["Content"]["Content"]["AnimationList"]; - var length = animationlist ? animationlist.length : 0; - for (var i = 0; i < length; i++) { - var animationdata = animationlist[i]; - var info = { name: null, startIndex: null, endIndex: null }; - info.name = animationdata["Name"]; - info.startIndex = animationdata["StartIndex"]; - info.endIndex = animationdata["EndIndex"]; - action.addAnimationInfo(info); - } + var animationlist = json["Content"]["Content"]["AnimationList"]; + var length = animationlist ? animationlist.length : 0; + for (var i = 0; i < length; i++) { + var animationdata = animationlist[i]; + var info = { name: null, startIndex: null, endIndex: null }; + info.name = animationdata["Name"]; + info.startIndex = animationdata["StartIndex"]; + info.endIndex = animationdata["EndIndex"]; + action.addAnimationInfo(info); } } diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index bc5a60cc00..84b7341724 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -97,11 +97,13 @@ ccs.ActionTimeline = cc.Action.extend({ _endFrame: 0, _loop: null, _frameEventListener: null, + _animationInfos: null, ctor: function(){ cc.Action.prototype.ctor.call(this); this._timelineMap = {}; this._timelineList = []; + this._animationInfos = {}; this.init(); }, @@ -431,6 +433,34 @@ ccs.ActionTimeline = cc.Action.extend({ */ isDone: function(){ return false; + }, + + /** + * @param {String} name + * @param {Boolean} loop + */ + play: function(name, loop){ + var info = this._animationInfos[name]; + if (!info) + return cc.log("Can't find animation info for %s", name); + + this.gotoFrameAndPlay(info.startIndex, info.endIndex, loop); + }, + + /** + * Add animationInfo + * @param {Object} info + */ + addAnimationInfo: function(info){ + this._animationInfos[info.name] = info; + }, + + /** + * Remove animationInfo + * @param {String} name + */ + removeAnimationInfo: function(name){ + delete this._animationInfos[name]; } }); From 056a5356facbe5fe512d90768dcae8c7cf451b20 Mon Sep 17 00:00:00 2001 From: Tian Fei <12128735@qq.com> Date: Fri, 20 Mar 2015 11:17:07 +0800 Subject: [PATCH 1439/1564] update spine from 2.0 to 2.1 update spine from 2.0 to 2.1 --- extensions/spine/CCSkeleton.js | 2 +- extensions/spine/CCSkeletonAnimation.js | 23 +- extensions/spine/Spine.js | 954 +++++++++++++++++------- 3 files changed, 686 insertions(+), 293 deletions(-) diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 28b49bebd1..2a3816a75a 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -185,7 +185,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) continue; var attachment = slot.attachment; - sp._regionAttachment_computeWorldVertices(attachment, slot.skeleton.x, slot.skeleton.y, slot.bone, vertices); + sp._regionAttachment_computeWorldVertices(attachment, slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); minX = Math.min(minX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); minY = Math.min(minY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY); maxX = Math.max(maxX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index 58ecb7351a..bb00ba2da5 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -79,11 +79,12 @@ sp._regionAttachment_computeWorldVertices = function(self, x, y, bone, vertices) sp._regionAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { var vertices = {}; - self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot, vertices); - var r = slot.skeleton.r * slot.r * 255; - var g = slot.skeleton.g * slot.g * 255; - var b = slot.skeleton.b * slot.b * 255; - var normalizedAlpha = slot.skeleton.a * slot.a; + self.computeVertices(slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); + var r = slot.bone.skeleton.r * slot.r * 255; + var g = slot.bone.skeleton.g * slot.g * 255; + var b = slot.bone.skeleton.b * slot.b * 255; + var normalizedAlpha = slot.bone.skeleton.a * slot.a; + if (premultipliedAlpha) { r *= normalizedAlpha; g *= normalizedAlpha; @@ -118,11 +119,11 @@ sp._regionAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) sp._meshAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { var vertices = {}; - self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot, vertices); - var r = slot.skeleton.r * slot.r * 255; - var g = slot.skeleton.g * slot.g * 255; - var b = slot.skeleton.b * slot.b * 255; - var normalizedAlpha = slot.skeleton.a * slot.a; + self.computeVertices(slot.bone.x, slot.bone.y, slot.bone, vertices); + var r = slot.bone.skeleton.r * slot.r * 255; + var g = slot.bone.skeleton.g * slot.g * 255; + var b = slot.bone.skeleton.b * slot.b * 255; + var normalizedAlpha = slot.bone.skeleton.a * slot.a; if (premultipliedAlpha) { r *= normalizedAlpha; g *= normalizedAlpha; @@ -160,7 +161,7 @@ sp._regionAttachment_updateSlotForCanvas = function(self, slot, points) { return; var vertices = {}; - self.computeVertices(slot.skeleton.x, slot.skeleton.y, slot, vertices); + self.computeVertices(slot.bone.x, slot.bone.y, slot.bone, vertices); var VERTEX = sp.VERTEX_INDEX; points.length = 0; points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1])); diff --git a/extensions/spine/Spine.js b/extensions/spine/Spine.js index c446ff7247..d76f2c3dac 100644 --- a/extensions/spine/Spine.js +++ b/extensions/spine/Spine.js @@ -1,6 +1,6 @@ /****************************************************************************** * Spine Runtimes Software License - * Version 2 + * Version 2.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. @@ -8,30 +8,30 @@ * You are granted a perpetual, non-exclusive, non-sublicensable and * non-transferable license to install, execute and perform the Spine Runtimes * Software (the "Software") solely for internal use. Without the written - * permission of Esoteric Software, you may not (a) modify, translate, adapt or - * otherwise create derivative works, improvements of the Software or develop - * new applications using the Software or (b) remove, delete, alter or obscure - * any trademarks or any copyright, trademark, patent or other intellectual - * property or proprietary rights notices on or in the Software, including - * any copy thereof. Redistributions in binary or source form must include - * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * permission of Esoteric Software (typically granted by licensing Spine), you + * may not (a) modify, translate, adapt or otherwise create derivative works, + * improvements of the Software or develop new applications using the Software + * or (b) remove, delete, alter or obscure any trademarks or any copyright, + * trademark, patent or other intellectual property or proprietary rights + * notices on or in the Software, including any copy thereof. Redistributions + * in binary or source form must include this license and terms. + * + * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -var spine = spine || { +var spine = { radDeg: 180 / Math.PI, degRad: Math.PI / 180, - temp: [], - Float32Array: (typeof(Float32Array) === 'undefined') ? Array : Float32Array, - Uint16Array: (typeof(Uint16Array) === 'undefined') ? Array : Uint16Array + temp: [] }; spine.BoneData = function (name, parent) { @@ -44,13 +44,13 @@ spine.BoneData.prototype = { rotation: 0, scaleX: 1, scaleY: 1, inheritScale: true, - inheritRotation: true + inheritRotation: true, + flipX: false, flipY: false }; spine.SlotData = function (name, boneData) { this.name = name; this.boneData = boneData; - this.r = this.g = this.b = this.a = 1; //FOR google compiler Advance mode }; spine.SlotData.prototype = { r: 1, g: 1, b: 1, a: 1, @@ -58,23 +58,36 @@ spine.SlotData.prototype = { additiveBlending: false }; -spine.Bone = function (boneData, parent) { +spine.IkConstraintData = function (name) { + this.name = name; + this.bones = []; +}; +spine.IkConstraintData.prototype = { + target: null, + bendDirection: 1, + mix: 1 +}; + +spine.Bone = function (boneData, skeleton, parent) { this.data = boneData; + this.skeleton = skeleton; this.parent = parent; this.setToSetupPose(); }; spine.Bone.yDown = false; spine.Bone.prototype = { x: 0, y: 0, - rotation: 0, + rotation: 0, rotationIK: 0, scaleX: 1, scaleY: 1, + flipX: false, flipY: false, m00: 0, m01: 0, worldX: 0, // a b x m10: 0, m11: 0, worldY: 0, // c d y worldRotation: 0, worldScaleX: 1, worldScaleY: 1, - updateWorldTransform: function (flipX, flipY) { + worldFlipX: false, worldFlipY: false, + updateWorldTransform: function () { var parent = this.parent; - if (parent != null) { + if (parent) { this.worldX = this.x * parent.m00 + this.y * parent.m01 + parent.worldX; this.worldY = this.x * parent.m10 + this.y * parent.m11 + parent.worldY; if (this.data.inheritScale) { @@ -84,28 +97,35 @@ spine.Bone.prototype = { this.worldScaleX = this.scaleX; this.worldScaleY = this.scaleY; } - this.worldRotation = this.data.inheritRotation ? parent.worldRotation + this.rotation : this.rotation; + this.worldRotation = this.data.inheritRotation ? (parent.worldRotation + this.rotationIK) : this.rotationIK; + this.worldFlipX = parent.worldFlipX != this.flipX; + this.worldFlipY = parent.worldFlipY != this.flipY; } else { - this.worldX = flipX ? -this.x : this.x; - this.worldY = flipY != spine.Bone.yDown ? -this.y : this.y; + var skeletonFlipX = this.skeleton.flipX, skeletonFlipY = this.skeleton.flipY; + this.worldX = skeletonFlipX ? -this.x : this.x; + this.worldY = (skeletonFlipY != spine.Bone.yDown) ? -this.y : this.y; this.worldScaleX = this.scaleX; this.worldScaleY = this.scaleY; - this.worldRotation = this.rotation; + this.worldRotation = this.rotationIK; + this.worldFlipX = skeletonFlipX != this.flipX; + this.worldFlipY = skeletonFlipY != this.flipY; } - var radians = this.worldRotation * Math.PI / 180; + var radians = this.worldRotation * spine.degRad; var cos = Math.cos(radians); var sin = Math.sin(radians); - this.m00 = cos * this.worldScaleX; - this.m10 = sin * this.worldScaleX; - this.m01 = -sin * this.worldScaleY; - this.m11 = cos * this.worldScaleY; - if (flipX) { - this.m00 = -this.m00; - this.m01 = -this.m01; + if (this.worldFlipX) { + this.m00 = -cos * this.worldScaleX; + this.m01 = sin * this.worldScaleY; + } else { + this.m00 = cos * this.worldScaleX; + this.m01 = -sin * this.worldScaleY; } - if (flipY != spine.Bone.yDown) { - this.m10 = -this.m10; - this.m11 = -this.m11; + if (this.worldFlipY != spine.Bone.yDown) { + this.m10 = -sin * this.worldScaleX; + this.m11 = -cos * this.worldScaleY; + } else { + this.m10 = sin * this.worldScaleX; + this.m11 = cos * this.worldScaleY; } }, setToSetupPose: function () { @@ -113,14 +133,32 @@ spine.Bone.prototype = { this.x = data.x; this.y = data.y; this.rotation = data.rotation; + this.rotationIK = this.rotation; this.scaleX = data.scaleX; this.scaleY = data.scaleY; + this.flipX = data.flipX; + this.flipY = data.flipY; + }, + worldToLocal: function (world) { + var dx = world[0] - this.worldX, dy = world[1] - this.worldY; + var m00 = this.m00, m10 = this.m10, m01 = this.m01, m11 = this.m11; + if (this.worldFlipX != (this.worldFlipY != spine.Bone.yDown)) { + m00 = -m00; + m11 = -m11; + } + var invDet = 1 / (m00 * m11 - m01 * m10); + world[0] = (dx * m00 * invDet - dy * m01 * invDet); + world[1] = (dy * m11 * invDet - dx * m10 * invDet); + }, + localToWorld: function (local) { + var localX = local[0], localY = local[1]; + local[0] = localX * this.m00 + localY * this.m01 + this.worldX; + local[1] = localX * this.m10 + localY * this.m11 + this.worldY; } }; -spine.Slot = function (slotData, skeleton, bone) { +spine.Slot = function (slotData, bone) { this.data = slotData; - this.skeleton = skeleton; this.bone = bone; this.setToSetupPose(); }; @@ -128,15 +166,17 @@ spine.Slot.prototype = { r: 1, g: 1, b: 1, a: 1, _attachmentTime: 0, attachment: null, + attachmentVertices: [], setAttachment: function (attachment) { this.attachment = attachment; - this._attachmentTime = this.skeleton.time; + this._attachmentTime = this.bone.skeleton.time; + this.attachmentVertices.length = 0; }, setAttachmentTime: function (time) { - this._attachmentTime = this.skeleton.time - time; + this._attachmentTime = this.bone.skeleton.time - time; }, getAttachmentTime: function () { - return this.skeleton.time - this._attachmentTime; + return this.bone.skeleton.time - this._attachmentTime; }, setToSetupPose: function () { var data = this.data; @@ -145,16 +185,112 @@ spine.Slot.prototype = { this.b = data.b; this.a = data.a; - var slotDatas = this.skeleton.data.slots; + var slotDatas = this.bone.skeleton.data.slots; for (var i = 0, n = slotDatas.length; i < n; i++) { if (slotDatas[i] == data) { - this.setAttachment(!data.attachmentName ? null : this.skeleton.getAttachmentBySlotIndex(i, data.attachmentName)); + this.setAttachment(!data.attachmentName ? null : this.bone.skeleton.getAttachmentBySlotIndex(i, data.attachmentName)); break; } } } }; +spine.IkConstraint = function (data, skeleton) { + this.data = data; + this.mix = data.mix; + this.bendDirection = data.bendDirection; + + this.bones = []; + for (var i = 0, n = data.bones.length; i < n; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); +}; +spine.IkConstraint.prototype = { + apply: function () { + var target = this.target; + var bones = this.bones; + switch (bones.length) { + case 1: + spine.IkConstraint.apply1(bones[0], target.worldX, target.worldY, this.mix); + break; + case 2: + spine.IkConstraint.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.mix); + break; + } + } +}; +/** Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified in the world + * coordinate system. */ +spine.IkConstraint.apply1 = function (bone, targetX, targetY, alpha) { + var parentRotation = (!bone.data.inheritRotation || !bone.parent) ? 0 : bone.parent.worldRotation; + var rotation = bone.rotation; + var rotationIK = Math.atan2(targetY - bone.worldY, targetX - bone.worldX) * spine.radDeg - parentRotation; + bone.rotationIK = rotation + (rotationIK - rotation) * alpha; +}; +/** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The + * target is specified in the world coordinate system. + * @param child Any descendant bone of the parent. */ +spine.IkConstraint.apply2 = function (parent, child, targetX, targetY, bendDirection, alpha) { + var childRotation = child.rotation, parentRotation = parent.rotation; + if (!alpha) { + child.rotationIK = childRotation; + parent.rotationIK = parentRotation; + return; + } + var positionX, positionY, tempPosition = spine.temp; + var parentParent = parent.parent; + if (parentParent) { + tempPosition[0] = targetX; + tempPosition[1] = targetY; + parentParent.worldToLocal(tempPosition); + targetX = (tempPosition[0] - parent.x) * parentParent.worldScaleX; + targetY = (tempPosition[1] - parent.y) * parentParent.worldScaleY; + } else { + targetX -= parent.x; + targetY -= parent.y; + } + if (child.parent == parent) { + positionX = child.x; + positionY = child.y; + } else { + tempPosition[0] = child.x; + tempPosition[1] = child.y; + child.parent.localToWorld(tempPosition); + parent.worldToLocal(tempPosition); + positionX = tempPosition[0]; + positionY = tempPosition[1]; + } + var childX = positionX * parent.worldScaleX, childY = positionY * parent.worldScaleY; + var offset = Math.atan2(childY, childX); + var len1 = Math.sqrt(childX * childX + childY * childY), len2 = child.data.length * child.worldScaleX; + // Based on code by Ryan Juckett with permission: Copyright (c) 2008-2009 Ryan Juckett, http://www.ryanjuckett.com/ + var cosDenom = 2 * len1 * len2; + if (cosDenom < 0.0001) { + child.rotationIK = childRotation + (Math.atan2(targetY, targetX) * spine.radDeg - parentRotation - childRotation) * alpha; + return; + } + var cos = (targetX * targetX + targetY * targetY - len1 * len1 - len2 * len2) / cosDenom; + if (cos < -1) + cos = -1; + else if (cos > 1) + cos = 1; + var childAngle = Math.acos(cos) * bendDirection; + var adjacent = len1 + len2 * cos, opposite = len2 * Math.sin(childAngle); + var parentAngle = Math.atan2(targetY * adjacent - targetX * opposite, targetX * adjacent + targetY * opposite); + var rotation = (parentAngle - offset) * spine.radDeg - parentRotation; + if (rotation > 180) + rotation -= 360; + else if (rotation < -180) // + rotation += 360; + parent.rotationIK = parentRotation + rotation * alpha; + rotation = (childAngle + offset) * spine.radDeg - childRotation; + if (rotation > 180) + rotation -= 360; + else if (rotation < -180) // + rotation += 360; + child.rotationIK = childRotation + (rotation + parent.worldRotation - child.parent.worldRotation) * alpha; +}; + spine.Skin = function (name) { this.name = name; this.attachments = {}; @@ -205,11 +341,10 @@ spine.Animation.prototype = { timelines[i].apply(skeleton, lastTime, time, events, alpha); } }; - -spine.binarySearch = function (values, target, step) { +spine.Animation.binarySearch = function (values, target, step) { var low = 0; var high = Math.floor(values.length / step) - 2; - if (high == 0) return step; + if (!high) return step; var current = high >>> 1; while (true) { if (values[(current + 1) * step] <= target) @@ -220,69 +355,56 @@ spine.binarySearch = function (values, target, step) { current = (low + high) >>> 1; } }; -spine.linearSearch = function (values, target, step) { +spine.Animation.binarySearch1 = function (values, target) { + var low = 0; + var high = values.length - 2; + if (!high) return 1; + var current = high >>> 1; + while (true) { + if (values[current + 1] <= target) + low = current + 1; + else + high = current; + if (low == high) return low + 1; + current = (low + high) >>> 1; + } +}; +spine.Animation.linearSearch = function (values, target, step) { for (var i = 0, last = values.length - step; i <= last; i += step) if (values[i] > target) return i; return -1; }; spine.Curves = function (frameCount) { - this.curves = []; // dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... - this.curves.length = (frameCount - 1) * 6; + this.curves = []; // type, x, y, ... + //this.curves.length = (frameCount - 1) * 19/*BEZIER_SIZE*/; }; spine.Curves.prototype = { setLinear: function (frameIndex) { - this.curves[frameIndex * 6] = 0/*LINEAR*/; + this.curves[frameIndex * 19/*BEZIER_SIZE*/] = 0/*LINEAR*/; }, setStepped: function (frameIndex) { - this.curves[frameIndex * 6] = -1/*STEPPED*/; + this.curves[frameIndex * 19/*BEZIER_SIZE*/] = 1/*STEPPED*/; }, /** Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next. * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of * the difference between the keyframe's values. */ setCurve: function (frameIndex, cx1, cy1, cx2, cy2) { - var subdiv_step = 1 / 10/*BEZIER_SEGMENTS*/; - var subdiv_step2 = subdiv_step * subdiv_step; - var subdiv_step3 = subdiv_step2 * subdiv_step; - var pre1 = 3 * subdiv_step; - var pre2 = 3 * subdiv_step2; - var pre4 = 6 * subdiv_step2; - var pre5 = 6 * subdiv_step3; - var tmp1x = -cx1 * 2 + cx2; - var tmp1y = -cy1 * 2 + cy2; - var tmp2x = (cx1 - cx2) * 3 + 1; - var tmp2y = (cy1 - cy2) * 3 + 1; - var i = frameIndex * 6; - var curves = this.curves; - curves[i] = cx1 * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3; - curves[i + 1] = cy1 * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3; - curves[i + 2] = tmp1x * pre4 + tmp2x * pre5; - curves[i + 3] = tmp1y * pre4 + tmp2y * pre5; - curves[i + 4] = tmp2x * pre5; - curves[i + 5] = tmp2y * pre5; - }, - getCurvePercent: function (frameIndex, percent) { - percent = percent < 0 ? 0 : (percent > 1 ? 1 : percent); - var curveIndex = frameIndex * 6; + var subdiv1 = 1 / 10/*BEZIER_SEGMENTS*/, subdiv2 = subdiv1 * subdiv1, subdiv3 = subdiv2 * subdiv1; + var pre1 = 3 * subdiv1, pre2 = 3 * subdiv2, pre4 = 6 * subdiv2, pre5 = 6 * subdiv3; + var tmp1x = -cx1 * 2 + cx2, tmp1y = -cy1 * 2 + cy2, tmp2x = (cx1 - cx2) * 3 + 1, tmp2y = (cy1 - cy2) * 3 + 1; + var dfx = cx1 * pre1 + tmp1x * pre2 + tmp2x * subdiv3, dfy = cy1 * pre1 + tmp1y * pre2 + tmp2y * subdiv3; + var ddfx = tmp1x * pre4 + tmp2x * pre5, ddfy = tmp1y * pre4 + tmp2y * pre5; + var dddfx = tmp2x * pre5, dddfy = tmp2y * pre5; + + var i = frameIndex * 19/*BEZIER_SIZE*/; var curves = this.curves; - var dfx = curves[curveIndex]; - if (!dfx/*LINEAR*/) return percent; - if (dfx == -1/*STEPPED*/) return 0; - var dfy = curves[curveIndex + 1]; - var ddfx = curves[curveIndex + 2]; - var ddfy = curves[curveIndex + 3]; - var dddfx = curves[curveIndex + 4]; - var dddfy = curves[curveIndex + 5]; + curves[i++] = 2/*BEZIER*/; + var x = dfx, y = dfy; - var i = 10/*BEZIER_SEGMENTS*/ - 2; - while (true) { - if (x >= percent) { - var lastX = x - dfx; - var lastY = y - dfy; - return lastY + (y - lastY) * (percent - lastX) / (x - lastX); - } - if (i == 0) break; - i--; + for (var n = i + 19/*BEZIER_SIZE*/ - 1; i < n; i += 2) { + curves[i] = x; + curves[i + 1] = y; dfx += ddfx; dfy += ddfy; ddfx += dddfx; @@ -290,6 +412,31 @@ spine.Curves.prototype = { x += dfx; y += dfy; } + }, + getCurvePercent: function (frameIndex, percent) { + percent = percent < 0 ? 0 : (percent > 1 ? 1 : percent); + var curves = this.curves; + var i = frameIndex * 19/*BEZIER_SIZE*/; + var type = curves[i]; + if (type === 0/*LINEAR*/) return percent; + if (type == 1/*STEPPED*/) return 0; + i++; + var x = 0; + for (var start = i, n = i + 19/*BEZIER_SIZE*/ - 1; i < n; i += 2) { + x = curves[i]; + if (x >= percent) { + var prevX, prevY; + if (i == start) { + prevX = 0; + prevY = 0; + } else { + prevX = curves[i - 2]; + prevY = curves[i - 1]; + } + return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX); + } + } + var y = curves[i - 1]; return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1. } }; @@ -325,19 +472,19 @@ spine.RotateTimeline.prototype = { return; } - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 2); - var lastFrameValue = frames[frameIndex - 1]; + // Interpolate between the previous frame and the current frame. + var frameIndex = spine.Animation.binarySearch(frames, time, 2); + var prevFrameValue = frames[frameIndex - 1]; var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex - 2/*LAST_FRAME_TIME*/] - frameTime); + var percent = 1 - (time - frameTime) / (frames[frameIndex - 2/*PREV_FRAME_TIME*/] - frameTime); percent = this.curves.getCurvePercent(frameIndex / 2 - 1, percent); - var amount = frames[frameIndex + 1/*FRAME_VALUE*/] - lastFrameValue; + var amount = frames[frameIndex + 1/*FRAME_VALUE*/] - prevFrameValue; while (amount > 180) amount -= 360; while (amount < -180) amount += 360; - amount = bone.data.rotation + (lastFrameValue + amount * percent) - bone.rotation; + amount = bone.data.rotation + (prevFrameValue + amount * percent) - bone.rotation; while (amount > 180) amount -= 360; while (amount < -180) @@ -374,16 +521,16 @@ spine.TranslateTimeline.prototype = { return; } - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 3); - var lastFrameX = frames[frameIndex - 2]; - var lastFrameY = frames[frameIndex - 1]; + // Interpolate between the previous frame and the current frame. + var frameIndex = spine.Animation.binarySearch(frames, time, 3); + var prevFrameX = frames[frameIndex - 2]; + var prevFrameY = frames[frameIndex - 1]; var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime); + var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*PREV_FRAME_TIME*/] - frameTime); percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent); - bone.x += (bone.data.x + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.x) * alpha; - bone.y += (bone.data.y + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.y) * alpha; + bone.x += (bone.data.x + prevFrameX + (frames[frameIndex + 1/*FRAME_X*/] - prevFrameX) * percent - bone.x) * alpha; + bone.y += (bone.data.y + prevFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - prevFrameY) * percent - bone.y) * alpha; } }; @@ -410,21 +557,21 @@ spine.ScaleTimeline.prototype = { var bone = skeleton.bones[this.boneIndex]; if (time >= frames[frames.length - 3]) { // Time is after last frame. - bone.scaleX += (bone.data.scaleX - 1 + frames[frames.length - 2] - bone.scaleX) * alpha; - bone.scaleY += (bone.data.scaleY - 1 + frames[frames.length - 1] - bone.scaleY) * alpha; + bone.scaleX += (bone.data.scaleX * frames[frames.length - 2] - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY * frames[frames.length - 1] - bone.scaleY) * alpha; return; } - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 3); - var lastFrameX = frames[frameIndex - 2]; - var lastFrameY = frames[frameIndex - 1]; + // Interpolate between the previous frame and the current frame. + var frameIndex = spine.Animation.binarySearch(frames, time, 3); + var prevFrameX = frames[frameIndex - 2]; + var prevFrameY = frames[frameIndex - 1]; var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime); + var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*PREV_FRAME_TIME*/] - frameTime); percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent); - bone.scaleX += (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.scaleX) * alpha; - bone.scaleY += (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.scaleY) * alpha; + bone.scaleX += (bone.data.scaleX * (prevFrameX + (frames[frameIndex + 1/*FRAME_X*/] - prevFrameX) * percent) - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY * (prevFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - prevFrameY) * percent) - bone.scaleY) * alpha; } }; @@ -450,31 +597,31 @@ spine.ColorTimeline.prototype = { var frames = this.frames; if (time < frames[0]) return; // Time is before first frame. - var slot = skeleton.slots[this.slotIndex]; - - if (time >= frames[frames.length - 5]) { // Time is after last frame. + var r, g, b, a; + if (time >= frames[frames.length - 5]) { + // Time is after last frame. var i = frames.length - 1; - slot.r = frames[i - 3]; - slot.g = frames[i - 2]; - slot.b = frames[i - 1]; - slot.a = frames[i]; - return; + r = frames[i - 3]; + g = frames[i - 2]; + b = frames[i - 1]; + a = frames[i]; + } else { + // Interpolate between the previous frame and the current frame. + var frameIndex = spine.Animation.binarySearch(frames, time, 5); + var prevFrameR = frames[frameIndex - 4]; + var prevFrameG = frames[frameIndex - 3]; + var prevFrameB = frames[frameIndex - 2]; + var prevFrameA = frames[frameIndex - 1]; + var frameTime = frames[frameIndex]; + var percent = 1 - (time - frameTime) / (frames[frameIndex - 5/*PREV_FRAME_TIME*/] - frameTime); + percent = this.curves.getCurvePercent(frameIndex / 5 - 1, percent); + + r = prevFrameR + (frames[frameIndex + 1/*FRAME_R*/] - prevFrameR) * percent; + g = prevFrameG + (frames[frameIndex + 2/*FRAME_G*/] - prevFrameG) * percent; + b = prevFrameB + (frames[frameIndex + 3/*FRAME_B*/] - prevFrameB) * percent; + a = prevFrameA + (frames[frameIndex + 4/*FRAME_A*/] - prevFrameA) * percent; } - - // Interpolate between the last frame and the current frame. - var frameIndex = spine.binarySearch(frames, time, 5); - var lastFrameR = frames[frameIndex - 4]; - var lastFrameG = frames[frameIndex - 3]; - var lastFrameB = frames[frameIndex - 2]; - var lastFrameA = frames[frameIndex - 1]; - var frameTime = frames[frameIndex]; - var percent = 1 - (time - frameTime) / (frames[frameIndex - 5/*LAST_FRAME_TIME*/] - frameTime); - percent = this.curves.getCurvePercent(frameIndex / 5 - 1, percent); - - var r = lastFrameR + (frames[frameIndex + 1/*FRAME_R*/] - lastFrameR) * percent; - var g = lastFrameG + (frames[frameIndex + 2/*FRAME_G*/] - lastFrameG) * percent; - var b = lastFrameB + (frames[frameIndex + 3/*FRAME_B*/] - lastFrameB) * percent; - var a = lastFrameA + (frames[frameIndex + 4/*FRAME_A*/] - lastFrameA) * percent; + var slot = skeleton.slots[this.slotIndex]; if (alpha < 1) { slot.r += (r - slot.r) * alpha; slot.g += (g - slot.g) * alpha; @@ -507,16 +654,18 @@ spine.AttachmentTimeline.prototype = { }, apply: function (skeleton, lastTime, time, firedEvents, alpha) { var frames = this.frames; - if (time < frames[0]) return; // Time is before first frame. + if (time < frames[0]) { + if (lastTime > time) this.apply(skeleton, lastTime, Number.MAX_VALUE, null, 0); + return; + } else if (lastTime > time) // + lastTime = -1; - var frameIndex; - if (time >= frames[frames.length - 1]) // Time is after last frame. - frameIndex = frames.length - 1; - else - frameIndex = spine.binarySearch(frames, time, 1) - 1; + var frameIndex = time >= frames[frames.length - 1] ? frames.length - 1 : spine.Animation.binarySearch1(frames, time) - 1; + if (frames[frameIndex] < lastTime) return; var attachmentName = this.attachmentNames[frameIndex]; - skeleton.slots[this.slotIndex].setAttachment(!attachmentName ? null : skeleton.getAttachmentBySlotIndex(this.slotIndex, attachmentName)); + skeleton.slots[this.slotIndex].setAttachment( + !attachmentName ? null : skeleton.getAttachmentBySlotIndex(this.slotIndex, attachmentName)); } }; @@ -552,7 +701,7 @@ spine.EventTimeline.prototype = { if (lastTime < frames[0]) frameIndex = 0; else { - frameIndex = spine.binarySearch(frames, lastTime, 1); + frameIndex = spine.Animation.binarySearch1(frames, lastTime); var frame = frames[frameIndex]; while (frameIndex > 0) { // Fire multiple events with the same frame. if (frames[frameIndex - 1] != frame) break; @@ -587,7 +736,7 @@ spine.DrawOrderTimeline.prototype = { if (time >= frames[frames.length - 1]) // Time is after last frame. frameIndex = frames.length - 1; else - frameIndex = spine.binarySearch(frames, time, 1) - 1; + frameIndex = spine.Animation.binarySearch1(frames, time) - 1; var drawOrder = skeleton.drawOrder; var slots = skeleton.slots; @@ -603,15 +752,185 @@ spine.DrawOrderTimeline.prototype = { } }; +spine.FfdTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; + this.frames.length = frameCount; + this.frameVertices = []; + this.frameVertices.length = frameCount; +}; +spine.FfdTimeline.prototype = { + slotIndex: 0, + attachment: 0, + getFrameCount: function () { + return this.frames.length; + }, + setFrame: function (frameIndex, time, vertices) { + this.frames[frameIndex] = time; + this.frameVertices[frameIndex] = vertices; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var slot = skeleton.slots[slotIndex]; + if (slot.attachment != attachment) return; + + var frames = this.frames; + if (time < frames[0]) { + slot.attachmentVertices.length = 0; + return; // Time is before first frame. + } + + var frameVertices = this.frameVertices; + var vertexCount = frameVertices[0].length; + + var vertices = slot.attachmentVertices; + if (vertices.length != vertexCount) alpha = 1; + vertices.length = vertexCount; + + if (time >= frames[frames.length - 1]) { // Time is after last frame. + var lastVertices = frameVertices[frames.length - 1]; + if (alpha < 1) { + for (var i = 0; i < vertexCount; i++) + vertices[i] += (lastVertices[i] - vertices[i]) * alpha; + } else { + for (var i = 0; i < vertexCount; i++) + vertices[i] = lastVertices[i]; + } + return; + } + + // Interpolate between the previous frame and the current frame. + var frameIndex = spine.Animation.binarySearch1(frames, time); + var frameTime = frames[frameIndex]; + var percent = 1 - (time - frameTime) / (frames[frameIndex - 1] - frameTime); + percent = this.curves.getCurvePercent(frameIndex - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); + + var prevVertices = frameVertices[frameIndex - 1]; + var nextVertices = frameVertices[frameIndex]; + + if (alpha < 1) { + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha; + } + } else { + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] = prev + (nextVertices[i] - prev) * percent; + } + } + } +}; + +spine.IkConstraintTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, mix, bendDirection, ... + this.frames.length = frameCount * 3; +}; +spine.IkConstraintTimeline.prototype = { + ikConstraintIndex: 0, + getFrameCount: function () { + return this.frames.length / 3; + }, + setFrame: function (frameIndex, time, mix, bendDirection) { + frameIndex *= 3; + this.frames[frameIndex] = time; + this.frames[frameIndex + 1] = mix; + this.frames[frameIndex + 2] = bendDirection; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) return; // Time is before first frame. + + var ikConstraint = skeleton.ikConstraints[this.ikConstraintIndex]; + + if (time >= frames[frames.length - 3]) { // Time is after last frame. + ikConstraint.mix += (frames[frames.length - 2] - ikConstraint.mix) * alpha; + ikConstraint.bendDirection = frames[frames.length - 1]; + return; + } + + // Interpolate between the previous frame and the current frame. + var frameIndex = spine.Animation.binarySearch(frames, time, 3); + var prevFrameMix = frames[frameIndex + -2/*PREV_FRAME_MIX*/]; + var frameTime = frames[frameIndex]; + var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*PREV_FRAME_TIME*/] - frameTime); + percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent); + + var mix = prevFrameMix + (frames[frameIndex + 1/*FRAME_MIX*/] - prevFrameMix) * percent; + ikConstraint.mix += (mix - ikConstraint.mix) * alpha; + ikConstraint.bendDirection = frames[frameIndex + -1/*PREV_FRAME_BEND_DIRECTION*/]; + } +}; + +spine.FlipXTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, flip, ... + this.frames.length = frameCount * 2; +}; +spine.FlipXTimeline.prototype = { + boneIndex: 0, + getFrameCount: function () { + return this.frames.length / 2; + }, + setFrame: function (frameIndex, time, flip) { + frameIndex *= 2; + this.frames[frameIndex] = time; + this.frames[frameIndex + 1] = flip ? 1 : 0; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) { + if (lastTime > time) this.apply(skeleton, lastTime, Number.MAX_VALUE, null, 0); + return; + } else if (lastTime > time) // + lastTime = -1; + var frameIndex = (time >= frames[frames.length - 2] ? frames.length : spine.Animation.binarySearch(frames, time, 2)) - 2; + if (frames[frameIndex] < lastTime) return; + skeleton.bones[boneIndex].flipX = frames[frameIndex + 1] != 0; + } +}; + +spine.FlipYTimeline = function (frameCount) { + this.curves = new spine.Curves(frameCount); + this.frames = []; // time, flip, ... + this.frames.length = frameCount * 2; +}; +spine.FlipYTimeline.prototype = { + boneIndex: 0, + getFrameCount: function () { + return this.frames.length / 2; + }, + setFrame: function (frameIndex, time, flip) { + frameIndex *= 2; + this.frames[frameIndex] = time; + this.frames[frameIndex + 1] = flip ? 1 : 0; + }, + apply: function (skeleton, lastTime, time, firedEvents, alpha) { + var frames = this.frames; + if (time < frames[0]) { + if (lastTime > time) this.apply(skeleton, lastTime, Number.MAX_VALUE, null, 0); + return; + } else if (lastTime > time) // + lastTime = -1; + var frameIndex = (time >= frames[frames.length - 2] ? frames.length : spine.Animation.binarySearch(frames, time, 2)) - 2; + if (frames[frameIndex] < lastTime) return; + skeleton.bones[boneIndex].flipY = frames[frameIndex + 1] != 0; + } +}; + spine.SkeletonData = function () { this.bones = []; this.slots = []; this.skins = []; this.events = []; this.animations = []; + this.ikConstraints = []; }; spine.SkeletonData.prototype = { + name: null, defaultSkin: null, + width: 0, height: 0, + version: null, hash: null, /** @return May be null. */ findBone: function (boneName) { var bones = this.bones; @@ -630,7 +949,7 @@ spine.SkeletonData.prototype = { findSlot: function (slotName) { var slots = this.slots; for (var i = 0, n = slots.length; i < n; i++) { - if (slots[i].name == slotName) return slots[i]; + if (slots[i].name == slotName) return slot[i]; } return null; }, @@ -661,6 +980,13 @@ spine.SkeletonData.prototype = { for (var i = 0, n = animations.length; i < n; i++) if (animations[i].name == animationName) return animations[i]; return null; + }, + /** @return May be null. */ + findIkConstraint: function (ikConstraintName) { + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) + if (ikConstraints[i].name == ikConstraintName) return ikConstraints[i]; + return null; } }; @@ -671,7 +997,7 @@ spine.Skeleton = function (skeletonData) { for (var i = 0, n = skeletonData.bones.length; i < n; i++) { var boneData = skeletonData.bones[i]; var parent = !boneData.parent ? null : this.bones[skeletonData.bones.indexOf(boneData.parent)]; - this.bones.push(new spine.Bone(boneData, parent)); + this.bones.push(new spine.Bone(boneData, this, parent)); } this.slots = []; @@ -679,10 +1005,17 @@ spine.Skeleton = function (skeletonData) { for (var i = 0, n = skeletonData.slots.length; i < n; i++) { var slotData = skeletonData.slots[i]; var bone = this.bones[skeletonData.bones.indexOf(slotData.boneData)]; - var slot = new spine.Slot(slotData, this, bone); + var slot = new spine.Slot(slotData, bone); this.slots.push(slot); this.drawOrder.push(slot); } + + this.ikConstraints = []; + for (var i = 0, n = skeletonData.ikConstraints.length; i < n; i++) + this.ikConstraints.push(new spine.IkConstraint(skeletonData.ikConstraints[i], this)); + + this.boneCache = []; + this.updateCache(); }; spine.Skeleton.prototype = { x: 0, y: 0, @@ -690,13 +1023,62 @@ spine.Skeleton.prototype = { r: 1, g: 1, b: 1, a: 1, time: 0, flipX: false, flipY: false, + /** Caches information about bones and IK constraints. Must be called if bones or IK constraints are added or removed. */ + updateCache: function () { + var ikConstraints = this.ikConstraints; + var ikConstraintsCount = ikConstraints.length; + + var arrayCount = ikConstraintsCount + 1; + var boneCache = this.boneCache; + if (boneCache.length > arrayCount) boneCache.length = arrayCount; + for (var i = 0, n = boneCache.length; i < n; i++) + boneCache[i].length = 0; + while (boneCache.length < arrayCount) + boneCache[boneCache.length] = []; + + var nonIkBones = boneCache[0]; + var bones = this.bones; + + outer: + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var current = bone; + do { + for (var ii = 0; ii < ikConstraintsCount; ii++) { + var ikConstraint = ikConstraints[ii]; + var parent = ikConstraint.bones[0]; + var child= ikConstraint.bones[ikConstraint.bones.length - 1]; + while (true) { + if (current == child) { + boneCache[ii].push(bone); + boneCache[ii + 1].push(bone); + continue outer; + } + if (child == parent) break; + child = child.parent; + } + } + current = current.parent; + } while (current); + nonIkBones[nonIkBones.length] = bone; + } + }, /** Updates the world transform for each bone. */ updateWorldTransform: function () { - var flipX = this.flipX; - var flipY = this.flipY; var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - bones[i].updateWorldTransform(flipX, flipY); + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + bone.rotationIK = bone.rotation; + } + var i = 0, last = this.boneCache.length - 1; + while (true) { + var cacheBones = this.boneCache[i]; + for (var ii = 0, nn = cacheBones.length; ii < nn; ii++) + cacheBones[ii].updateWorldTransform(); + if (i == last) break; + this.ikConstraints[i].apply(); + i++; + } }, /** Sets the bones and slots to their setup pose values. */ setToSetupPose: function () { @@ -707,15 +1089,25 @@ spine.Skeleton.prototype = { var bones = this.bones; for (var i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); + + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var ikConstraint = ikConstraints[i]; + ikConstraint.bendDirection = ikConstraint.data.bendDirection; + ikConstraint.mix = ikConstraint.data.mix; + } }, setSlotsToSetupPose: function () { var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) + var drawOrder = this.drawOrder; + for (var i = 0, n = slots.length; i < n; i++) { + drawOrder[i] = slots[i]; slots[i].setToSetupPose(i); + } }, /** @return May return null. */ getRootBone: function () { - return this.bones.length == 0 ? null : this.bones[0]; + return this.bones.length ? this.bones[0] : null; }, /** @return May be null. */ findBone: function (boneName) { @@ -751,11 +1143,24 @@ spine.Skeleton.prototype = { this.setSkin(skin); }, /** Sets the skin used to look up attachments not found in the {@link SkeletonData#getDefaultSkin() default skin}. Attachments - * from the new skin are attached if the corresponding attachment from the old skin was attached. + * from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no old skin, + * each slot's setup mode attachment is attached from the new skin. * @param newSkin May be null. */ setSkin: function (newSkin) { - if (this.skin && newSkin) { - newSkin._attachAll(this, this.skin); + if (newSkin) { + if (this.skin) + newSkin._attachAll(this, this.skin); + else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name = slot.data.attachmentName; + if (name) { + var attachment = newSkin.getAttachment(i, name); + if (attachment) slot.setAttachment(attachment); + } + } + } } this.skin = newSkin; }, @@ -780,7 +1185,7 @@ spine.Skeleton.prototype = { if (slot.data.name == slotName) { var attachment = null; if (attachmentName) { - attachment = this.getAttachment(i, attachmentName); + attachment = this.getAttachmentBySlotIndex(i, attachmentName); if (!attachment) throw "Attachment not found: " + attachmentName + ", for slot: " + slotName; } slot.setAttachment(attachment); @@ -789,6 +1194,13 @@ spine.Skeleton.prototype = { } throw "Slot not found: " + slotName; }, + /** @return May be null. */ + findIkConstraint: function (ikConstraintName) { + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) + if (ikConstraints[i].data.name == ikConstraintName) return ikConstraints[i]; + return null; + }, update: function (delta) { this.time += delta; } @@ -797,7 +1209,6 @@ spine.Skeleton.prototype = { spine.EventData = function (name) { this.name = name; }; - spine.EventData.prototype = { intValue: 0, floatValue: 0, @@ -807,7 +1218,6 @@ spine.EventData.prototype = { spine.Event = function (data) { this.data = data; }; - spine.Event.prototype = { intValue: 0, floatValue: 0, @@ -827,15 +1237,15 @@ spine.RegionAttachment = function (name) { this.offset.length = 8; this.uvs = []; this.uvs.length = 8; - this["type"] = spine.AttachmentType.region; //FOR advance mode }; - spine.RegionAttachment.prototype = { type: spine.AttachmentType.region, x: 0, y: 0, rotation: 0, scaleX: 1, scaleY: 1, width: 0, height: 0, + r: 1, g: 1, b: 1, a: 1, + path: null, rendererObject: null, regionOffsetX: 0, regionOffsetY: 0, regionWidth: 0, regionHeight: 0, @@ -869,7 +1279,7 @@ spine.RegionAttachment.prototype = { var localY = -this.height / 2 * this.scaleY + this.regionOffsetY * regionScaleY; var localX2 = localX + this.regionWidth * regionScaleX; var localY2 = localY + this.regionHeight * regionScaleY; - var radians = this.rotation * Math.PI / 180; + var radians = this.rotation * spine.degRad; var cos = Math.cos(radians); var sin = Math.sin(radians); var localXCos = localX * cos + this.x; @@ -890,14 +1300,10 @@ spine.RegionAttachment.prototype = { offset[6/*X4*/] = localX2Cos - localYSin; offset[7/*Y4*/] = localYCos + localX2Sin; }, - computeVertices: function (x, y, slot, vertices) { - var bone = slot.bone; + computeVertices: function (x, y, bone, vertices) { x += bone.worldX; y += bone.worldY; - var m00 = bone.m00; - var m01 = bone.m01; - var m10 = bone.m10; - var m11 = bone.m11; + var m00 = bone.m00, m01 = bone.m01, m10 = bone.m10, m11 = bone.m11; var offset = this.offset; vertices[0/*X1*/] = offset[0/*X1*/] * m00 + offset[1/*Y1*/] * m01 + x; vertices[1/*Y1*/] = offset[0/*X1*/] * m10 + offset[1/*Y1*/] * m11 + y; @@ -930,35 +1336,37 @@ spine.MeshAttachment.prototype = { edges: null, width: 0, height: 0, updateUVs: function () { - var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV; - var n = this.regionUVs.length; - if (!this.uvs || this.uvs.length != n) { - this.uvs = new spine.Float32Array(n); + var width = regionU2 - regionU, height = regionV2 - regionV; + var n = regionUVs.length; + if (!uvs || uvs.length != n) { + uvs = []; + uvs.length = n; } - if (this.regionRotate) { + if (regionRotate) { for (var i = 0; i < n; i += 2) { - this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width; - this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height; + uvs[i] = regionU + regionUVs[i + 1] * width; + uvs[i + 1] = regionV + height - regionUVs[i] * height; } } else { for (var i = 0; i < n; i += 2) { - this.uvs[i] = this.regionU + this.regionUVs[i] * width; - this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height; + uvs[i] = regionU + regionUVs[i] * width; + uvs[i + 1] = regionV + regionUVs[i + 1] * height; } } }, - computeVertices: function (x, y, slot, vertices) { + computeWorldVertices: function (x, y, slot, worldVertices) { var bone = slot.bone; x += bone.worldX; y += bone.worldY; var m00 = bone.m00, m01 = bone.m01, m10 = bone.m10, m11 = bone.m11; - var verticesCount = this.vertices.length; - if (slot.attachment.length == verticesCount) this.vertices = slot.attachment; + var vertices = this.vertices; + var verticesCount = vertices.length; + if (slot.attachmentVertices.length == verticesCount) vertices = slot.attachmentVertices; for (var i = 0; i < verticesCount; i += 2) { - var vx = this.vertices[i]; - var vy = this.vertices[i + 1]; - vertices[i] = vx * m00 + vy * m01 + x; - vertices[i + 1] = vx * m10 + vy * m11 + y; + var vx = vertices[i]; + var vy = vertices[i + 1]; + worldVertices[i] = vx * m00 + vy * m01 + x; + worldVertices[i + 1] = vx * m10 + vy * m11 + y; } } }; @@ -984,20 +1392,21 @@ spine.SkinnedMeshAttachment.prototype = { edges: null, width: 0, height: 0, updateUVs: function (u, v, u2, v2, rotate) { - var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV; - var n = this.regionUVs.length; - if (!this.uvs || this.uvs.length != n) { - this.uvs = new spine.Float32Array(n); + var width = regionU2 - regionU, height = regionV2 - regionV; + var n = regionUVs.length; + if (!uvs || uvs.length != n) { + uvs = []; + uvs.length = n; } - if (this.regionRotate) { + if (regionRotate) { for (var i = 0; i < n; i += 2) { - this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width; - this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height; + uvs[i] = regionU + regionUVs[i + 1] * width; + uvs[i + 1] = regionV + height - regionUVs[i] * height; } } else { for (var i = 0; i < n; i += 2) { - this.uvs[i] = this.regionU + this.regionUVs[i] * width; - this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height; + uvs[i] = regionU + regionUVs[i] * width; + uvs[i + 1] = regionV + regionUVs[i + 1] * height; } } }, @@ -1048,18 +1457,13 @@ spine.SkinnedMeshAttachment.prototype = { spine.BoundingBoxAttachment = function (name) { this.name = name; this.vertices = []; - this["type"] = spine.AttachmentType.boundingBox; //FOR advance mode }; - spine.BoundingBoxAttachment.prototype = { - type: spine.AttachmentType.boundingBox, + type: spine.AttachmentType.boundingbox, computeWorldVertices: function (x, y, bone, worldVertices) { x += bone.worldX; y += bone.worldY; - var m00 = bone.m00; - var m01 = bone.m01; - var m10 = bone.m10; - var m11 = bone.m11; + var m00 = bone.m00, m01 = bone.m01, m10 = bone.m10, m11 = bone.m11; var vertices = this.vertices; for (var i = 0, n = vertices.length; i < n; i += 2) { var px = vertices[i]; @@ -1087,20 +1491,19 @@ spine.AnimationStateData.prototype = { this.animationToMixTime[from.name + ":" + to.name] = duration; }, getMix: function (from, to) { - var time = this.animationToMixTime[from.name + ":" + to.name]; - return time ? time : this.defaultMix; + var key = from.name + ":" + to.name; + return this.animationToMixTime.hasOwnProperty(key) ? this.animationToMixTime[key] : this.defaultMix; } }; -spine.TrackEntry = function () { -}; +spine.TrackEntry = function () {}; spine.TrackEntry.prototype = { next: null, previous: null, animation: null, loop: false, delay: 0, time: 0, lastTime: -1, endTime: 0, timeScale: 1, - mixTime: 0, mixDuration: 0, + mixTime: 0, mixDuration: 0, mix: 1, onStart: null, onEnd: null, onComplete: null, onEvent: null }; @@ -1109,7 +1512,6 @@ spine.AnimationState = function (stateData) { this.tracks = []; this.events = []; }; - spine.AnimationState.prototype = { onStart: null, onEnd: null, @@ -1122,16 +1524,17 @@ spine.AnimationState.prototype = { var current = this.tracks[i]; if (!current) continue; - var trackDelta = delta * current.timeScale; - current.time += trackDelta; + current.time += delta * current.timeScale; if (current.previous) { - current.previous.time += trackDelta; - current.mixTime += trackDelta; + var previousDelta = delta * current.previous.timeScale; + current.previous.time += previousDelta; + current.mixTime += previousDelta; } var next = current.next; if (next) { - if (current.lastTime >= next.delay) this.setCurrent(i, next); + next.time = current.lastTime - next.delay; + if (next.time >= 0) this.setCurrent(i, next); } else { // End non-looping animation when it reaches its end time and there is no next entry. if (!current.loop && current.lastTime >= current.endTime) this.clearTrack(i); @@ -1152,14 +1555,17 @@ spine.AnimationState.prototype = { if (!loop && time > endTime) time = endTime; var previous = current.previous; - if (!previous) - current.animation.apply(skeleton, current.lastTime, time, loop, this.events); - else { + if (!previous) { + if (current.mix == 1) + current.animation.apply(skeleton, current.lastTime, time, loop, this.events); + else + current.animation.mix(skeleton, current.lastTime, time, loop, this.events, current.mix); + } else { var previousTime = previous.time; if (!previous.loop && previousTime > previous.endTime) previousTime = previous.endTime; previous.animation.apply(skeleton, previousTime, previousTime, previous.loop, null); - var alpha = current.mixTime / current.mixDuration; + var alpha = current.mixTime / current.mixDuration * current.mix; if (alpha >= 1) { alpha = 1; current.previous = null; @@ -1169,8 +1575,8 @@ spine.AnimationState.prototype = { for (var ii = 0, nn = this.events.length; ii < nn; ii++) { var event = this.events[ii]; - if (current.onEvent != null) current.onEvent(i, event); - if (this.onEvent != null) this.onEvent(i, event); + if (current.onEvent) current.onEvent(i, event); + if (this.onEvent) this.onEvent(i, event); } // Check if completed the animation or a loop iteration. @@ -1193,8 +1599,8 @@ spine.AnimationState.prototype = { var current = this.tracks[trackIndex]; if (!current) return; - if (current.onEnd != null) current.onEnd(trackIndex); - if (this.onEnd != null) this.onEnd(trackIndex); + if (current.onEnd) current.onEnd(trackIndex); + if (this.onEnd) this.onEnd(trackIndex); this.tracks[trackIndex] = null; }, @@ -1210,8 +1616,8 @@ spine.AnimationState.prototype = { var previous = current.previous; current.previous = null; - if (current.onEnd != null) current.onEnd(index); - if (this.onEnd != null) this.onEnd(index); + if (current.onEnd) current.onEnd(index); + if (this.onEnd) this.onEnd(index); entry.mixDuration = this.data.getMix(current.animation, entry.animation); if (entry.mixDuration > 0) { @@ -1226,8 +1632,8 @@ spine.AnimationState.prototype = { this.tracks[index] = entry; - if (entry.onStart != null) entry.onStart(index); - if (this.onStart != null) this.onStart(index); + if (entry.onStart) entry.onStart(index); + if (this.onStart) this.onStart(index); }, setAnimationByName: function (trackIndex, animationName, loop) { var animation = this.data.skeletonData.findAnimation(animationName); @@ -1412,14 +1818,14 @@ spine.SkeletonJson.prototype = { var type = spine.AttachmentType[map["type"] || "region"]; var path = map["path"] || name; - + var scale = this.scale; if (type == spine.AttachmentType.region) { var region = this.attachmentLoader.newRegionAttachment(skin, name, path); if (!region) return null; region.path = path; - region.x = (map["x"] || 0) * scale; - region.y = (map["y"] || 0) * scale; + region.x = (map["x"] || 0) * this.scale; + region.y = (map["y"] || 0) * this.scale; region.scaleX = map.hasOwnProperty("scaleX") ? map["scaleX"] : 1; region.scaleY = map.hasOwnProperty("scaleY") ? map["scaleY"] : 1; region.rotation = map["rotation"] || 0; @@ -1439,7 +1845,7 @@ spine.SkeletonJson.prototype = { } else if (type == spine.AttachmentType.mesh) { var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); if (!mesh) return null; - mesh.path = path; + mesh.path = path; mesh.vertices = this.getFloatArray(map, "vertices", scale); mesh.triangles = this.getIntArray(map, "triangles"); mesh.regionUVs = this.getFloatArray(map, "uvs", 1); @@ -1464,7 +1870,7 @@ spine.SkeletonJson.prototype = { mesh.path = path; var uvs = this.getFloatArray(map, "uvs", 1); - var vertices = this.getFloatArray(map, "vertices", 1); + vertices = this.getFloatArray(map, "vertices", 1); var weights = []; var bones = []; for (var i = 0, n = vertices.length; i < n; ) { @@ -1483,7 +1889,7 @@ spine.SkeletonJson.prototype = { mesh.triangles = this.getIntArray(map, "triangles"); mesh.regionUVs = uvs; mesh.updateUVs(); - + color = map["color"]; if (color) { mesh.r = this.toColor(color, 0); @@ -1491,7 +1897,7 @@ spine.SkeletonJson.prototype = { mesh.b = this.toColor(color, 2); mesh.a = this.toColor(color, 3); } - + mesh.hullLength = (map["hull"] || 0) * 2; if (map["edges"]) mesh.edges = this.getIntArray(map, "edges"); mesh.width = (map["width"] || 0) * scale; @@ -1501,7 +1907,7 @@ spine.SkeletonJson.prototype = { var attachment = this.attachmentLoader.newBoundingBoxAttachment(skin, name); var vertices = map["vertices"]; for (var i = 0, n = vertices.length; i < n; i++) - attachment.vertices.push(vertices[i] * scale); + attachment.vertices.push(vertices[i] * this.scale); return attachment; } throw "Unknown attachment type: " + type; @@ -1655,7 +2061,7 @@ spine.SkeletonJson.prototype = { if (!attachment) throw "FFD attachment not found: " + meshName; timeline.slotIndex = slotIndex; timeline.attachment = attachment; - + var isMesh = attachment.type == spine.AttachmentType.mesh; var vertexCount; if (isMesh) @@ -1680,20 +2086,20 @@ spine.SkeletonJson.prototype = { vertices.length = vertexCount; var start = valueMap["offset"] || 0; var nn = verticesValue.length; - if (this.scale == 1) { + if (scale == 1) { for (var ii = 0; ii < nn; ii++) vertices[ii + start] = verticesValue[ii]; } else { for (var ii = 0; ii < nn; ii++) - vertices[ii + start] = verticesValue[ii] * this.scale; + vertices[ii + start] = verticesValue[ii] * scale; } if (isMesh) { var meshVertices = attachment.vertices; - for (var ii = 0, nn = vertices.length; ii < nn; ii++) + for (var ii = 0, nn = vertices.length; ii < nn; i++) vertices[ii] += meshVertices[ii]; } } - + timeline.setFrame(frameIndex, valueMap["time"], vertices); this.readCurve(timeline, frameIndex, valueMap); frameIndex++; @@ -1767,7 +2173,7 @@ spine.SkeletonJson.prototype = { }, readCurve: function (timeline, frameIndex, valueMap) { var curve = valueMap["curve"]; - if (!curve) + if (!curve) timeline.curves.setLinear(frameIndex); else if (curve == "stepped") timeline.curves.setStepped(frameIndex); @@ -1780,7 +2186,8 @@ spine.SkeletonJson.prototype = { }, getFloatArray: function (map, name, scale) { var list = map[name]; - var values = new spine.Float32Array(list.length); + var values = []; + values = list.length; var i = 0, n = list.length; if (scale == 1) { for (; i < n; i++) @@ -1793,27 +2200,14 @@ spine.SkeletonJson.prototype = { }, getIntArray: function (map, name) { var list = map[name]; - var values = new spine.Uint16Array(list.length); + var values = []; + values = list.length; for (var i = 0, n = list.length; i < n; i++) values[i] = list[i] | 0; return values; } }; -spine.SkeletonJson.readCurve = function (timeline, frameIndex, valueMap) { - var curve = valueMap["curve"]; - if (!curve) return; - if (curve == "stepped") - timeline.curves.setStepped(frameIndex); - else if (curve instanceof Array) - timeline.curves.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); -}; - -spine.SkeletonJson.toColor = function (hexString, colorIndex) { - if (hexString.length != 8) throw "Color hexidecimal length must be 8, recieved: " + hexString; - return parseInt(hexString.substring(colorIndex * 2, (colorIndex * 2) + 2), 16) / 255; -}; - spine.Atlas = function (atlasText, textureLoader) { this.textureLoader = textureLoader; this.pages = []; @@ -1941,23 +2335,23 @@ spine.Atlas.prototype = { }; spine.Atlas.Format = { - Alpha: 0, - Intensity: 1, - LuminanceAlpha: 2, - RGB565: 3, - RGBA4444: 4, - RGB888: 5, - RGBA8888: 6 + alpha: 0, + intensity: 1, + luminanceAlpha: 2, + rgb565: 3, + rgba4444: 4, + rgb888: 5, + rgba8888: 6 }; spine.Atlas.TextureFilter = { - Nearest: 0, - Linear: 1, - MipMap: 2, - MipMapNearestNearest: 3, - MipMapLinearNearest: 4, - MipMapNearestLinear: 5, - MipMapLinearLinear: 6 + nearest: 0, + linear: 1, + mipMap: 2, + mipMapNearestNearest: 3, + mipMapLinearNearest: 4, + mipMapNearestLinear: 5, + mipMapLinearLinear: 6 }; spine.Atlas.TextureWrap = { @@ -1966,8 +2360,7 @@ spine.Atlas.TextureWrap = { repeat: 2 }; -spine.AtlasPage = function () { -}; +spine.AtlasPage = function () {}; spine.AtlasPage.prototype = { name: null, format: null, @@ -1980,8 +2373,7 @@ spine.AtlasPage.prototype = { height: 0 }; -spine.AtlasRegion = function () { -}; +spine.AtlasRegion = function () {}; spine.AtlasRegion.prototype = { page: null, name: null, @@ -2113,7 +2505,7 @@ spine.SkeletonBounds.prototype = { for (var i = 0; i < slotCount; i++) { var slot = slots[i]; var boundingBox = slot.attachment; - if (boundingBox.type != spine.AttachmentType.boundingBox) continue; + if (boundingBox.type != spine.AttachmentType.boundingbox) continue; boundingBoxes.push(boundingBox); var poolCount = polygonPool.length, polygon; @@ -2206,7 +2598,7 @@ spine.SkeletonBounds.prototype = { return inside; }, /** Returns true if the polygon contains the line segment. */ - intersectsSegment: function (polygon, x1, y1, x2, y2) { + polygonIntersectsSegment: function (polygon, x1, y1, x2, y2) { var nn = polygon.length; var width12 = x1 - x2, height12 = y1 - y2; var det1 = x1 * y2 - y1 * x2; @@ -2236,4 +2628,4 @@ spine.SkeletonBounds.prototype = { getHeight: function () { return this.maxY - this.minY; } -}; \ No newline at end of file +}; From 42bf0201d59c9ee494a8a10235fecda73c05025b Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 20 Mar 2015 12:00:26 +0800 Subject: [PATCH 1440/1564] Issue #2756: fixed the memory leak in cc.LabelBMFont --- cocos2d/labels/CCLabelBMFont.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js index 6ac229c8b5..83bdf818cf 100644 --- a/cocos2d/labels/CCLabelBMFont.js +++ b/cocos2d/labels/CCLabelBMFont.js @@ -539,6 +539,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ updateLabel: function () { var self = this; self.string = self._initialString; + var i, j, characterSprite; // process string // Step 1: Make multiline if (self._width > 0) { @@ -549,8 +550,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{ for (i = 0; i < stringArr.length; i++) { oldArrLength = stringArr.length; this._checkWarp(stringArr, i, self._width * this._scaleX, newWrapNum); - if (oldArrLength < stringArr.length) - { + if (oldArrLength < stringArr.length) { newWrapNum++; } if (i > 0) From 9c6f56cc1aadbfad7c1e127c09fbcc4eb736b9b8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 20 Mar 2015 17:36:56 +0800 Subject: [PATCH 1441/1564] Fixed a bug that scale9Sprite updateDisplayColor error --- extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js | 4 +++- .../gui/control-extension/CCScale9SpriteCanvasRenderCmd.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index 1dc9ae4734..ceab4aeb03 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -85,8 +85,10 @@ var scaleChildren = scale9Image.getChildren(); for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; - if (selChild) + if (selChild){ selChild._renderCmd._updateDisplayColor(parentColor); + selChild._renderCmd._updateColor(); + } } this._cacheScale9Sprite(); } diff --git a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js index f0acc0bb7a..73a6514003 100644 --- a/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +++ b/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js @@ -85,8 +85,10 @@ var scaleChildren = scale9Image.getChildren(); for (var i = 0; i < scaleChildren.length; i++) { var selChild = scaleChildren[i]; - if (selChild) + if (selChild){ selChild._renderCmd._updateDisplayColor(parentColor); + selChild._renderCmd._updateColor(); + } } this._cacheScale9Sprite(); } From e611228d8ca4e803e4dbe50127635df4fafc4d87 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 20 Mar 2015 17:39:50 +0800 Subject: [PATCH 1442/1564] Fixed a bug that layoutComponent is undefined --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 56b0d7c008..d11e2ff293 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -296,6 +296,8 @@ widget.setColor(getColor(color)); var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); + if(!layoutComponent) + return; var positionXPercentEnabled = json["PositionPercentXEnable"] || false; var positionYPercentEnabled = json["PositionPercentYEnable"] || false; From 79cf83c4587b28495c3149506f62a29262a8e7ab Mon Sep 17 00:00:00 2001 From: igogo Date: Fri, 20 Mar 2015 11:54:51 +0200 Subject: [PATCH 1443/1564] Readme changed for support installing and testing in different versions --- README.mdown | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.mdown b/README.mdown index 5e3bc6adcd..82d051efba 100644 --- a/README.mdown +++ b/README.mdown @@ -16,7 +16,15 @@ Documentation * Website: [www.cocos2d-x.org][3] * API References: [http://www.cocos2d-x.org/wiki/Reference] [4] -Running the tests + +Installing from [bower.io][5] (version >=3.4) +------------------ + +```shell +$ bower install cocos2d-html5 + + +Running the tests (version <3) ------------------ ```shell @@ -30,9 +38,9 @@ $ python -m SimpleHTTPServer Contact us ------------------ - * Forum: [http://forum.cocos2d-x.org][5] - * Twitter: [http://www.twitter.com/cocos2dhtml5][6] - * Sina Microblog: [http://t.sina.com.cn/cocos2dhtml5][7] + * Forum: [http://forum.cocos2d-x.org][6] + * Twitter: [http://www.twitter.com/cocos2dhtml5][7] + * Sina Microblog: [http://t.sina.com.cn/cocos2dhtml5][8] [1]: http://www.cocos2d-x.org "Cocos2d-html5" [2]: http://www.cocos2d-x.org "Cocos2d-X" From c62e73d2fd1c719b1316b1942b79dd58b5cd6225 Mon Sep 17 00:00:00 2001 From: igogo Date: Fri, 20 Mar 2015 12:25:37 +0200 Subject: [PATCH 1444/1564] Readme changed for support installing and testing in different versions --- README.mdown | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.mdown b/README.mdown index 82d051efba..9c6ce013e6 100644 --- a/README.mdown +++ b/README.mdown @@ -17,12 +17,12 @@ Documentation * API References: [http://www.cocos2d-x.org/wiki/Reference] [4] -Installing from [bower.io][5] (version >=3.4) +Installing from [bower][8] (version >=3.4) ------------------ ```shell $ bower install cocos2d-html5 - +``` Running the tests (version <3) ------------------ @@ -38,9 +38,9 @@ $ python -m SimpleHTTPServer Contact us ------------------ - * Forum: [http://forum.cocos2d-x.org][6] - * Twitter: [http://www.twitter.com/cocos2dhtml5][7] - * Sina Microblog: [http://t.sina.com.cn/cocos2dhtml5][8] + * Forum: [http://forum.cocos2d-x.org][5] + * Twitter: [http://www.twitter.com/cocos2dhtml5][6] + * Sina Microblog: [http://t.sina.com.cn/cocos2dhtml5][7] [1]: http://www.cocos2d-x.org "Cocos2d-html5" [2]: http://www.cocos2d-x.org "Cocos2d-X" @@ -49,3 +49,4 @@ Contact us [5]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org" [6]: http://www.twitter.com/cocos2dhtml5 "http://www.twitter.com/cocos2dhtml5" [7]: http://t.sina.com.cn/cocos2dhtml5 "http://t.sina.com.cn/cocos2dhtml5" +[8]: http://bower.io "http://bower.io" \ No newline at end of file From 8f2bb416787ded9992df1a144417de1ca816df52 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 20 Mar 2015 18:34:43 +0800 Subject: [PATCH 1445/1564] Fixed #1571: Fixed a bug of cc.MenuItemSprite that it doesn't work when parameter `selectedSprite` is a Scale9Sprite instance. --- cocos2d/menus/CCMenuItem.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/menus/CCMenuItem.js b/cocos2d/menus/CCMenuItem.js index 06c85bb05e..b083fca0bf 100644 --- a/cocos2d/menus/CCMenuItem.js +++ b/cocos2d/menus/CCMenuItem.js @@ -725,8 +725,8 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ this._disabledImage = null; if (selectedSprite !== undefined) { - normalSprite = normalSprite; - selectedSprite = selectedSprite; + //normalSprite = normalSprite; + //selectedSprite = selectedSprite; var disabledImage, target, callback; //when you send 4 arguments, five is undefined if (five !== undefined) { @@ -739,9 +739,9 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{ } else if (four !== undefined && cc.isFunction(three)) { target = four; callback = three; - disabledImage = new cc.Sprite(selectedSprite.getTexture(), selectedSprite.getTextureRect()); + disabledImage = null; } else if (three === undefined) { - disabledImage = new cc.Sprite(selectedSprite.getTexture(), selectedSprite.getTextureRect()); + disabledImage = null; } this.initWithNormalSprite(normalSprite, selectedSprite, disabledImage, callback, target); } From 2905045cd4f85b04e99da05f5f23b9570febdf06 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 23 Mar 2015 11:39:13 +0800 Subject: [PATCH 1446/1564] Fixed bug that is Scale9sprite cap error when no pre loading picture --- extensions/ccui/base-classes/UIScale9Sprite.js | 9 +++++++++ extensions/gui/control-extension/CCScale9Sprite.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 813ceae5c1..6b0aa9c917 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -466,6 +466,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._textureLoaded = locLoaded; if(!locLoaded){ texture.addEventListener("load", function(sender){ + if(this._capInsets.width === 0 && this._capInsets.height === 0){ + this._capInsets.width = sender._contentSize.width; + this._capInsets.height = sender._contentSize.height; + } // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); @@ -475,6 +479,11 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._positionsAreDirty = true; this.dispatchEvent("load"); }, this); + }else{ + if(this._capInsets.width === 0 && this._capInsets.height === 0){ + capInsets.width = texture._contentSize.width; + capInsets.height = texture._contentSize.height; + } } return this.initWithBatchNode(new cc.SpriteBatchNode(file, 9), rect, false, capInsets); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index abe7056ef7..063f4bed33 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -461,6 +461,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._textureLoaded = locLoaded; if(!locLoaded){ texture.addEventListener("load", function(sender){ + if(this._capInsets.width === 0 && this._capInsets.height === 0){ + this._capInsets.width = sender._contentSize.width; + this._capInsets.height = sender._contentSize.height; + } // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); @@ -470,6 +474,11 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._positionsAreDirty = true; this.dispatchEvent("load"); }, this); + }else{ + if(this._capInsets.width === 0 && this._capInsets.height === 0){ + capInsets.width = texture._contentSize.width; + capInsets.height = texture._contentSize.height; + } } return this.initWithBatchNode(new cc.SpriteBatchNode(file, 9), rect, false, capInsets); From a5db17ec0d41044c14fdd0d9f9df8e458f99d72a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 23 Mar 2015 14:14:26 +0800 Subject: [PATCH 1447/1564] Fixed #2753: Background color of panel from cocos studio 2 doesnt work --- .../loader/parsers/timelineParser-2.x.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index d11e2ff293..fb9f0fd7ec 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -422,15 +422,12 @@ } - var bgStartColor = json["FirstColor"]; - var bgEndColor = json["EndColor"]; - if(bgStartColor != null && bgEndColor != null){ - var startC = getColor(bgStartColor); - if(bgEndColor["R"] == null && bgEndColor["G"] == null && bgEndColor["B"] == null) - widget.setBackGroundColor( startC ); - else - widget.setBackGroundColor( startC, getColor(bgEndColor) ); - } + var firstColor = json["FirstColor"]; + var endColor = json["EndColor"]; + if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) + widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); + else + widget.setBackGroundColor(getColor(json["SingleColor"])); var colorVector = json["ColorVector"]; if(colorVector != null) From 192339af3e96b492291014d5646c39a11530ac11 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 23 Mar 2015 16:18:40 +0800 Subject: [PATCH 1448/1564] Fixed punchbox #16651 --- .../loader/parsers/timelineParser-2.x.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index fb9f0fd7ec..89350c2cba 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -645,6 +645,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"]; widget.setClippingEnabled(clipEnabled); @@ -691,10 +695,6 @@ widget.setBackGroundColorVector(cc.p(colorVectorX, colorVectorY)); } - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - var innerNodeSize = json["InnerNodeSize"]; var innerSize = cc.size( innerNodeSize["Width"] || 0, @@ -829,6 +829,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"] || false; widget.setClippingEnabled(clipEnabled); @@ -869,10 +873,6 @@ if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - setContentSize(widget, json["Size"]); return widget; @@ -891,6 +891,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"] || false; widget.setClippingEnabled(clipEnabled); @@ -964,11 +968,6 @@ if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); - - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - setContentSize(widget, json["Size"]); return widget; From 7672694bcbae9d0af199039b2e74e227e851d2c8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 24 Mar 2015 10:20:36 +0800 Subject: [PATCH 1449/1564] Issue #2698: corrected a mistake of cc.math.Matrix in constructor. --- .../CCClippingNodeWebGLRenderCmd.js | 32 +++++++++++++------ cocos2d/kazmath/gl/mat4stack.js | 18 +++++++++++ cocos2d/kazmath/mat3.js | 8 ++--- cocos2d/kazmath/mat4.js | 7 ++-- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js index 283df8fc46..0e199ff3b7 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js @@ -144,17 +144,29 @@ proto._drawFullScreenQuadClearStencil = function () { // draw a fullscreen solid rectangle to clear the stencil buffer - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPushMatrix(); - cc.kmGLLoadIdentity(); + var projStack = cc.projection_matrix_stack; + //cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + //cc.kmGLPushMatrix(); + //cc.kmGLLoadIdentity(); + projStack.push(); + projStack.top.identity(); + + //cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + //cc.kmGLPushMatrix(); + //cc.kmGLLoadIdentity(); + var modelViewStack = cc.modelview_matrix_stack; + modelViewStack.push(); + modelViewStack.top.identity(); + cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255)); - cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); - cc.kmGLPopMatrix(); - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - cc.kmGLPopMatrix(); + + //cc.kmGLMatrixMode(cc.KM_GL_PROJECTION); + //cc.kmGLPopMatrix(); + projStack.pop(); + + //cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + //cc.kmGLPopMatrix(); + modelViewStack.pop(); }; proto._onBeforeVisit = function(ctx){ diff --git a/cocos2d/kazmath/gl/mat4stack.js b/cocos2d/kazmath/gl/mat4stack.js index b11fd6b1cf..ecd3aceba3 100644 --- a/cocos2d/kazmath/gl/mat4stack.js +++ b/cocos2d/kazmath/gl/mat4stack.js @@ -36,6 +36,7 @@ cc.math.Matrix4Stack = function(top, stack) { this.top = top; this.stack = stack || []; + //this._matrixPool = []; // use pool in next version }; cc.km_mat4_stack = cc.math.Matrix4Stack; var proto = cc.math.Matrix4Stack.prototype; @@ -61,17 +62,34 @@ }; proto.push = function(item) { + item = item || this.top; this.stack.push(this.top); this.top = new cc.math.Matrix4(item); + //this.top = this._getFromPool(item); }; proto.pop = function() { + //this._putInPool(this.top); this.top = this.stack.pop(); }; proto.release = function(){ this.stack = null; this.top = null; + this._matrixPool = null; + }; + + proto._getFromPool = function (item) { + var pool = this._matrixPool; + if (pool.length === 0) + return new cc.math.Matrix4(item); + var ret = pool.pop(); + ret.assignFrom(item); + return ret; + }; + + proto._putInPool = function(matrix){ + this._matrixPool.push(matrix); }; })(cc); diff --git a/cocos2d/kazmath/mat3.js b/cocos2d/kazmath/mat3.js index 737bc9b77f..05cdbe1417 100644 --- a/cocos2d/kazmath/mat3.js +++ b/cocos2d/kazmath/mat3.js @@ -29,12 +29,10 @@ var Float32Array = Float32Array || Array; (function(cc){ cc.math.Matrix3 = function(mat3) { - if (mat3) { - this.mat = new Float32Array(mat3); + if (mat3 && mat3.mat) { + this.mat = new Float32Array(mat3.mat); } else { - this.mat = new Float32Array([0, 0, 0, - 0, 0, 0, - 0, 0, 0]); + this.mat = new Float32Array(9); } }; cc.kmMat3 = cc.math.Matrix3; diff --git a/cocos2d/kazmath/mat4.js b/cocos2d/kazmath/mat4.js index 33882b7a98..b1af75efc3 100644 --- a/cocos2d/kazmath/mat4.js +++ b/cocos2d/kazmath/mat4.js @@ -40,13 +40,10 @@ * @param {cc.math.Matrix4} [mat4] */ cc.math.Matrix4 = function (mat4) { - if(mat4){ + if(mat4 && mat4.mat){ this.mat = new Float32Array(mat4.mat); } else { - this.mat = new Float32Array([0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]); + this.mat = new Float32Array(16); } }; cc.kmMat4 = cc.math.Matrix4; From 687f4436cb2d275152c57c74aba04c3ba20cae43 Mon Sep 17 00:00:00 2001 From: SijieWang Date: Tue, 24 Mar 2015 14:17:25 +0800 Subject: [PATCH 1450/1564] Revert "Fixed bug that is Scale9sprite cap error when no pre loading picture" --- extensions/ccui/base-classes/UIScale9Sprite.js | 9 --------- extensions/gui/control-extension/CCScale9Sprite.js | 9 --------- 2 files changed, 18 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 6b0aa9c917..813ceae5c1 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -466,10 +466,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._textureLoaded = locLoaded; if(!locLoaded){ texture.addEventListener("load", function(sender){ - if(this._capInsets.width === 0 && this._capInsets.height === 0){ - this._capInsets.width = sender._contentSize.width; - this._capInsets.height = sender._contentSize.height; - } // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); @@ -479,11 +475,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ this._positionsAreDirty = true; this.dispatchEvent("load"); }, this); - }else{ - if(this._capInsets.width === 0 && this._capInsets.height === 0){ - capInsets.width = texture._contentSize.width; - capInsets.height = texture._contentSize.height; - } } return this.initWithBatchNode(new cc.SpriteBatchNode(file, 9), rect, false, capInsets); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 063f4bed33..abe7056ef7 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -461,10 +461,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._textureLoaded = locLoaded; if(!locLoaded){ texture.addEventListener("load", function(sender){ - if(this._capInsets.width === 0 && this._capInsets.height === 0){ - this._capInsets.width = sender._contentSize.width; - this._capInsets.height = sender._contentSize.height; - } // the texture is rotated on Canvas render mode, so isRotated always is false. var preferredSize = this._preferredSize; preferredSize = cc.size(preferredSize.width, preferredSize.height); @@ -474,11 +470,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ this._positionsAreDirty = true; this.dispatchEvent("load"); }, this); - }else{ - if(this._capInsets.width === 0 && this._capInsets.height === 0){ - capInsets.width = texture._contentSize.width; - capInsets.height = texture._contentSize.height; - } } return this.initWithBatchNode(new cc.SpriteBatchNode(file, 9), rect, false, capInsets); From aec8545deb99d7a66ce78ce9e173aee0ab552b8f Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Tue, 24 Mar 2015 18:09:00 -0500 Subject: [PATCH 1451/1564] Audio DOM loader Improved audio loader that seems to work way better when using DOM audio. --- cocos2d/audio/CCAudio.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index e59d580ffc..f03a888f92 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -574,12 +574,18 @@ cc.Audio = cc.Class.extend({ emptied(); }else{ termination = true; + element.pause(); + document.body.removeChild(element); cb("audio load timeout : " + realUrl, audio); } }, 10000); var success = function(){ if(!cbCheck){ + element.pause(); + try { element.currentTime = 0; + element.volume = 1; } catch (e) {} + document.body.removeChild(element); audio.setElement(element); element.removeEventListener("canplaythrough", success, false); element.removeEventListener("error", failure, false); @@ -592,6 +598,8 @@ cc.Audio = cc.Class.extend({ var failure = function(){ if(!cbCheck) return; + element.pause(); + document.body.removeChild(element); element.removeEventListener("canplaythrough", success, false); element.removeEventListener("error", failure, false); element.removeEventListener("emptied", emptied, false); @@ -612,7 +620,9 @@ cc.Audio = cc.Class.extend({ cc._addEventListener(element, "emptied", emptied, false); element.src = realUrl; - element.load(); + document.body.appendChild(element); + element.volume = 0; + element.play(); } } From 536d07a0019097d048d728a1eebbd8d5472e761d Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 25 Mar 2015 14:32:58 +0800 Subject: [PATCH 1452/1564] Issue #2760: update some spine skeleton APIs, but it doesn't support Mesh. --- extensions/spine/CCSkeleton.js | 50 ++++++-- extensions/spine/CCSkeletonAnimation.js | 124 ++++++++++++++++++- extensions/spine/CCSkeletonWebGLRenderCmd.js | 13 +- extensions/spine/Spine.js | 93 +++++++------- 4 files changed, 216 insertions(+), 64 deletions(-) diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index 2a3816a75a..a3c7b402b4 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -48,15 +48,15 @@ sp.VERTEX_INDEX = { }; /** - * The attachment type of spine. It contains three type: REGION(0), BOUNDING_BOX(1), REGION_SEQUENCE(2) and MESH(2). + * The attachment type of spine. It contains three type: REGION(0), BOUNDING_BOX(1), MESH(2) and SKINNED_MESH. * @constant * @type {{REGION: number, BOUNDING_BOX: number, REGION_SEQUENCE: number, MESH: number}} */ sp.ATTACHMENT_TYPE = { REGION: 0, BOUNDING_BOX: 1, - REGION_SEQUENCE: 2, - MESH: 2 + MESH: 2, + SKINNED_MESH:3 }; /** @@ -112,7 +112,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ }, /** - * Sets whether open debug solots. + * Sets whether open debug slots. * @param {boolean} enable true to open, false to close. */ setDebugSolots:function(enable){ @@ -127,12 +127,48 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ this._debugBones = enable; }, + /** + * Sets whether open debug slots. + * @param {boolean} enabled true to open, false to close. + */ + setDebugSlotsEnabled: function(enabled) { + this._debugSlots = enabled; + }, + + /** + * Gets whether open debug slots. + * @returns {boolean} true to open, false to close. + */ + getDebugSlotsEnabled: function() { + return this._debugSlots; + }, + + /** + * Sets whether open debug bones. + * @param {boolean} enabled + */ + setDebugBonesEnabled: function(enabled) { + this._debugBones = enabled; + }, + + /** + * Gets whether open debug bones. + * @returns {boolean} true to open, false to close. + */ + getDebugBonesEnabled: function() { + return this._debugBones; + }, + /** * Sets the time scale of sp.Skeleton. - * @param {Number} v + * @param {Number} scale */ - setTimeScale:function(v){ - this._timeScale = v; + setTimeScale:function(scale){ + this._timeScale = scale; + }, + + getTimeScale: function(){ + return this._timeScale; }, /** diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index bb00ba2da5..0d1e392a34 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -119,7 +119,7 @@ sp._regionAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) sp._meshAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { var vertices = {}; - self.computeVertices(slot.bone.x, slot.bone.y, slot.bone, vertices); + self.computeWorldVertices(slot.bone.x, slot.bone.y, slot, vertices); var r = slot.bone.skeleton.r * slot.r * 255; var g = slot.bone.skeleton.g * slot.g * 255; var b = slot.bone.skeleton.b * slot.b * 255; @@ -182,6 +182,25 @@ sp.ANIMATION_EVENT_TYPE = { EVENT: 3 }; +sp.TrackEntryListeners = function(startListener, endListener, completeListener, eventListener){ + this.startListener = startListener || null; + this.endListener = endListener || null; + this.completeListener = completeListener || null; + this.eventListener = eventListener || null; +}; + +sp.TrackEntryListeners.getListeners = function(entry){ + if(!entry.rendererObject){ + entry.rendererObject = new sp.TrackEntryListeners(); + entry.listener = sp.trackEntryCallback; + } + return entry.rendererObject; +}; + +sp.trackEntryCallback = function(state, trackIndex, type, event, loopCount) { + state.rendererObject.onTrackEntryEvent(trackIndex, type, event, loopCount); +}; + /** * The skeleton animation of spine. It updates animation's state and skeleton's world transform. * @class @@ -195,12 +214,19 @@ sp.SkeletonAnimation = sp.Skeleton.extend(/** @lends sp.SkeletonAnimation# */{ _target: null, _callback: null, + _ownsAnimationStateData: false, + _startListener: null, + _endListener: null, + _completeListener: null, + _eventListener: null, + /** * Initializes a sp.SkeletonAnimation. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. * @override */ init: function () { sp.Skeleton.prototype.init.call(this); + this._ownsAnimationStateData = true; this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data)); }, @@ -210,6 +236,7 @@ sp.SkeletonAnimation = sp.Skeleton.extend(/** @lends sp.SkeletonAnimation# */{ */ setAnimationStateData: function (stateData) { var state = new spine.AnimationState(stateData); + state.rendererObject = this; state.onStart = this._onAnimationStateStart.bind(this); state.onComplete = this._onAnimationStateComplete.bind(this); state.onEnd = this._onAnimationStateEnd.bind(this); @@ -258,10 +285,11 @@ sp.SkeletonAnimation = sp.Skeleton.extend(/** @lends sp.SkeletonAnimation# */{ * @param {Number} trackIndex * @param {String} name * @param {Boolean} loop - * @param {Number} delay + * @param {Number} [delay=0] * @returns {spine.TrackEntry|null} */ addAnimation: function (trackIndex, name, loop, delay) { + delay = delay == null ? 0 : delay; var animation = this._skeleton.data.findAnimation(name); if (!animation) { cc.log("Spine: Animation not found:" + name); @@ -302,13 +330,102 @@ sp.SkeletonAnimation = sp.Skeleton.extend(/** @lends sp.SkeletonAnimation# */{ */ update: function (dt) { this._super(dt); - dt *= this._timeScale; this._state.update(dt); this._state.apply(this._skeleton); this._skeleton.updateWorldTransform(); }, + /** + * Set the start event listener. + * @param {function} listener + */ + setStartListener: function(listener){ + this._startListener = listener; + }, + + /** + * Set the end event listener. + * @param {function} listener + */ + setEndListener: function(listener) { + this._endListener = listener; + }, + + setCompleteListener: function(listener) { + this._completeListener = listener; + }, + + setEventListener: function(listener){ + this._eventListener = listener; + }, + + setTrackStartListener: function(entry, listener){ + sp.TrackEntryListeners.getListeners(entry).startListener = listener; + }, + + setTrackEndListener: function(entry, listener){ + sp.TrackEntryListeners.getListeners(entry).endListener = listener; + }, + + setTrackCompleteListener: function(entry, listener){ + sp.TrackEntryListeners.getListeners(entry).completeListener = listener; + }, + + setTrackEventListener: function(entry, listener){ + sp.TrackEntryListeners.getListeners(entry).eventListener = listener; + }, + + onTrackEntryEvent: function(traceIndex, type, event, loopCount){ + var entry = this._state.getCurrent(traceIndex); + if(!entry.rendererObject) + return; + var listeners = entry.rendererObject; + switch (type){ + case sp.ANIMATION_EVENT_TYPE.START: + if(listeners.startListener) + listeners.startListener(traceIndex); + break; + case sp.ANIMATION_EVENT_TYPE.END: + if(listeners.endListener) + listeners.endListener(traceIndex); + break; + case sp.ANIMATION_EVENT_TYPE.COMPLETE: + if(listeners.completeListener) + listeners.completeListener(traceIndex, loopCount); + break; + case sp.ANIMATION_EVENT_TYPE.EVENT: + if(listeners.eventListener) + listeners.eventListener(traceIndex, event); + break; + } + }, + + onAnimationStateEvent: function(trackIndex, type, event, loopCount) { + switch(type){ + case sp.ANIMATION_EVENT_TYPE.START: + if(this._startListener) + this._startListener(trackIndex); + break; + case sp.ANIMATION_EVENT_TYPE.END: + if(this._endListener) + this._endListener(trackIndex); + break; + case sp.ANIMATION_EVENT_TYPE.COMPLETE: + if(this._completeListener) + this._completeListener(trackIndex, loopCount); + break; + case sp.ANIMATION_EVENT_TYPE.EVENT: + if(this._eventListener) + this._eventListener(trackIndex, event); + break; + } + }, + + getState: function(){ + return this._state; + }, + _onAnimationStateStart: function (trackIndex) { this._animationStateCallback(trackIndex, sp.ANIMATION_EVENT_TYPE.START, null, 0); }, @@ -322,6 +439,7 @@ sp.SkeletonAnimation = sp.Skeleton.extend(/** @lends sp.SkeletonAnimation# */{ this._animationStateCallback(trackIndex, sp.ANIMATION_EVENT_TYPE.EVENT, event, 0); }, _animationStateCallback: function (trackIndex, type, event, loopCount) { + this.onAnimationStateEvent(trackIndex, type, event, loopCount); if (this._target && this._callback) { this._callback.call(this._target, this, trackIndex, type, event, loopCount) } diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index 9b78bbd0eb..83c6aa93da 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -82,11 +82,13 @@ switch(slot.attachment.type) { case sp.ATTACHMENT_TYPE.REGION: - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); - break; + sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + break; case sp.ATTACHMENT_TYPE.MESH: - sp._meshAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); - break; + sp._meshAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + break; + case sp.ATTACHMENT_TYPE.SKINNED_MESH: + break; } textureAtlas.updateQuad(quad, quadCount); @@ -98,9 +100,8 @@ } if (node._debugBones || node._debugSlots) { - cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); - //cc.kmGLPushMatrixWitMat4(node._stackMatrix); + //cc.kmGLPushMatrixWitMat4(this._stackMatrix); cc.current_stack.stack.push(cc.current_stack.top); cc.current_stack.top = this._stackMatrix; diff --git a/extensions/spine/Spine.js b/extensions/spine/Spine.js index d76f2c3dac..e29bca57d0 100644 --- a/extensions/spine/Spine.js +++ b/extensions/spine/Spine.js @@ -31,7 +31,9 @@ var spine = { radDeg: 180 / Math.PI, degRad: Math.PI / 180, - temp: [] + temp: [], + Float32Array: (typeof(Float32Array) === 'undefined') ? Array : Float32Array, + Uint16Array: (typeof(Uint16Array) === 'undefined') ? Array : Uint16Array }; spine.BoneData = function (name, parent) { @@ -147,8 +149,8 @@ spine.Bone.prototype = { m11 = -m11; } var invDet = 1 / (m00 * m11 - m01 * m10); - world[0] = (dx * m00 * invDet - dy * m01 * invDet); - world[1] = (dy * m11 * invDet - dx * m10 * invDet); + world[0] = dx * m00 * invDet - dy * m01 * invDet; + world[1] = dy * m11 * invDet - dx * m10 * invDet; }, localToWorld: function (local) { var localX = local[0], localY = local[1]; @@ -224,7 +226,9 @@ spine.IkConstraint.prototype = { spine.IkConstraint.apply1 = function (bone, targetX, targetY, alpha) { var parentRotation = (!bone.data.inheritRotation || !bone.parent) ? 0 : bone.parent.worldRotation; var rotation = bone.rotation; - var rotationIK = Math.atan2(targetY - bone.worldY, targetX - bone.worldX) * spine.radDeg - parentRotation; + var rotationIK = Math.atan2(targetY - bone.worldY, targetX - bone.worldX) * spine.radDeg; + if (bone.worldFlipX != (bone.worldFlipY != spine.Bone.yDown)) rotationIK = -rotationIK; + rotationIK -= parentRotation; bone.rotationIK = rotation + (rotationIK - rotation) * alpha; }; /** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The @@ -770,14 +774,11 @@ spine.FfdTimeline.prototype = { this.frameVertices[frameIndex] = vertices; }, apply: function (skeleton, lastTime, time, firedEvents, alpha) { - var slot = skeleton.slots[slotIndex]; - if (slot.attachment != attachment) return; + var slot = skeleton.slots[this.slotIndex]; + if (slot.attachment != this.attachment) return; var frames = this.frames; - if (time < frames[0]) { - slot.attachmentVertices.length = 0; - return; // Time is before first frame. - } + if (time < frames[0]) return; // Time is before first frame. var frameVertices = this.frameVertices; var vertexCount = frameVertices[0].length; @@ -1142,9 +1143,9 @@ spine.Skeleton.prototype = { if (!skin) throw "Skin not found: " + skinName; this.setSkin(skin); }, - /** Sets the skin used to look up attachments not found in the {@link SkeletonData#getDefaultSkin() default skin}. Attachments - * from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no old skin, - * each slot's setup mode attachment is attached from the new skin. + /** Sets the skin used to look up attachments before looking in the {@link SkeletonData#getDefaultSkin() default skin}. + * Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. If there was + * no old skin, each slot's setup mode attachment is attached from the new skin. * @param newSkin May be null. */ setSkin: function (newSkin) { if (newSkin) { @@ -1336,21 +1337,20 @@ spine.MeshAttachment.prototype = { edges: null, width: 0, height: 0, updateUVs: function () { - var width = regionU2 - regionU, height = regionV2 - regionV; - var n = regionUVs.length; - if (!uvs || uvs.length != n) { - uvs = []; - uvs.length = n; + var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV; + var n = this.regionUVs.length; + if (!this.uvs || this.uvs.length != n) { + this.uvs = new spine.Float32Array(n); } - if (regionRotate) { + if (this.regionRotate) { for (var i = 0; i < n; i += 2) { - uvs[i] = regionU + regionUVs[i + 1] * width; - uvs[i + 1] = regionV + height - regionUVs[i] * height; + this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width; + this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height; } } else { for (var i = 0; i < n; i += 2) { - uvs[i] = regionU + regionUVs[i] * width; - uvs[i + 1] = regionV + regionUVs[i + 1] * height; + this.uvs[i] = this.regionU + this.regionUVs[i] * width; + this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height; } } }, @@ -1392,21 +1392,20 @@ spine.SkinnedMeshAttachment.prototype = { edges: null, width: 0, height: 0, updateUVs: function (u, v, u2, v2, rotate) { - var width = regionU2 - regionU, height = regionV2 - regionV; - var n = regionUVs.length; - if (!uvs || uvs.length != n) { - uvs = []; - uvs.length = n; + var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV; + var n = this.regionUVs.length; + if (!this.uvs || this.uvs.length != n) { + this.uvs = new spine.Float32Array(n); } - if (regionRotate) { + if (this.regionRotate) { for (var i = 0; i < n; i += 2) { - uvs[i] = regionU + regionUVs[i + 1] * width; - uvs[i + 1] = regionV + height - regionUVs[i] * height; + this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width; + this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height; } } else { for (var i = 0; i < n; i += 2) { - uvs[i] = regionU + regionUVs[i] * width; - uvs[i + 1] = regionV + regionUVs[i + 1] * height; + this.uvs[i] = this.regionU + this.regionUVs[i] * width; + this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height; } } }, @@ -1824,8 +1823,8 @@ spine.SkeletonJson.prototype = { var region = this.attachmentLoader.newRegionAttachment(skin, name, path); if (!region) return null; region.path = path; - region.x = (map["x"] || 0) * this.scale; - region.y = (map["y"] || 0) * this.scale; + region.x = (map["x"] || 0) * scale; + region.y = (map["y"] || 0) * scale; region.scaleX = map.hasOwnProperty("scaleX") ? map["scaleX"] : 1; region.scaleY = map.hasOwnProperty("scaleY") ? map["scaleY"] : 1; region.rotation = map["rotation"] || 0; @@ -1870,7 +1869,7 @@ spine.SkeletonJson.prototype = { mesh.path = path; var uvs = this.getFloatArray(map, "uvs", 1); - vertices = this.getFloatArray(map, "vertices", 1); + var vertices = this.getFloatArray(map, "vertices", 1); var weights = []; var bones = []; for (var i = 0, n = vertices.length; i < n; ) { @@ -1907,7 +1906,7 @@ spine.SkeletonJson.prototype = { var attachment = this.attachmentLoader.newBoundingBoxAttachment(skin, name); var vertices = map["vertices"]; for (var i = 0, n = vertices.length; i < n; i++) - attachment.vertices.push(vertices[i] * this.scale); + attachment.vertices.push(vertices[i] * scale); return attachment; } throw "Unknown attachment type: " + type; @@ -2086,16 +2085,16 @@ spine.SkeletonJson.prototype = { vertices.length = vertexCount; var start = valueMap["offset"] || 0; var nn = verticesValue.length; - if (scale == 1) { + if (this.scale == 1) { for (var ii = 0; ii < nn; ii++) vertices[ii + start] = verticesValue[ii]; } else { for (var ii = 0; ii < nn; ii++) - vertices[ii + start] = verticesValue[ii] * scale; + vertices[ii + start] = verticesValue[ii] * this.scale; } if (isMesh) { var meshVertices = attachment.vertices; - for (var ii = 0, nn = vertices.length; ii < nn; i++) + for (var ii = 0, nn = vertices.length; ii < nn; ii++) vertices[ii] += meshVertices[ii]; } } @@ -2186,8 +2185,7 @@ spine.SkeletonJson.prototype = { }, getFloatArray: function (map, name, scale) { var list = map[name]; - var values = []; - values = list.length; + var values = new spine.Float32Array(list.length); var i = 0, n = list.length; if (scale == 1) { for (; i < n; i++) @@ -2200,8 +2198,7 @@ spine.SkeletonJson.prototype = { }, getIntArray: function (map, name) { var list = map[name]; - var values = []; - values = list.length; + var values = new spine.Uint16Array(list.length); for (var i = 0, n = list.length; i < n; i++) values[i] = list[i] | 0; return values; @@ -2428,7 +2425,7 @@ spine.AtlasAttachmentLoader = function (atlas) { }; spine.AtlasAttachmentLoader.prototype = { newRegionAttachment: function (skin, name, path) { - var region = this.atlas.findRegion(name); + var region = this.atlas.findRegion(path); if (!region) throw "Region not found in atlas: " + path + " (region attachment: " + name + ")"; var attachment = new spine.RegionAttachment(name); attachment.rendererObject = region; @@ -2442,7 +2439,7 @@ spine.AtlasAttachmentLoader.prototype = { return attachment; }, newMeshAttachment: function (skin, name, path) { - var region = this.atlas.findRegion(name); + var region = this.atlas.findRegion(path); if (!region) throw "Region not found in atlas: " + path + " (mesh attachment: " + name + ")"; var attachment = new spine.MeshAttachment(name); attachment.rendererObject = region; @@ -2460,7 +2457,7 @@ spine.AtlasAttachmentLoader.prototype = { return attachment; }, newSkinnedMeshAttachment: function (skin, name, path) { - var region = this.atlas.findRegion(name); + var region = this.atlas.findRegion(path); if (!region) throw "Region not found in atlas: " + path + " (skinned mesh attachment: " + name + ")"; var attachment = new spine.SkinnedMeshAttachment(name); attachment.rendererObject = region; @@ -2628,4 +2625,4 @@ spine.SkeletonBounds.prototype = { getHeight: function () { return this.maxY - this.minY; } -}; +}; \ No newline at end of file From 038d25b729dfddd8292753da511d88fbe7272af4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 25 Mar 2015 15:42:26 +0800 Subject: [PATCH 1453/1564] Fixed a bug context["createGain"] error of 360browser --- cocos2d/audio/CCAudio.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index e59d580ffc..ccc1853d56 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -516,10 +516,16 @@ cc.Audio = cc.Class.extend({ return cb(null, loader.cache[url]); if(SWA){ - var volume = context["createGain"](); - volume["gain"].value = 1; - volume["connect"](context["destination"]); - audio = new cc.Audio(context, volume, realUrl); + try{ + var volume = context["createGain"](); + volume["gain"].value = 1; + volume["connect"](context["destination"]); + audio = new cc.Audio(context, volume, realUrl); + }catch(err){ + SWA = false; + cc.log("browser don't support webAudio"); + audio = new cc.Audio(null, null, realUrl); + } }else{ audio = new cc.Audio(null, null, realUrl); } From 3ee128946d4014bda1f52ee6ad88e2a58b4cbdac Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 25 Mar 2015 16:28:40 +0800 Subject: [PATCH 1454/1564] Sync the latest OS info --- CCBoot.js | 110 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 81 insertions(+), 29 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 8e2a876172..040ffe09a2 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1321,32 +1321,32 @@ cc._initSys = function (config, CONFIG_KEY) { /** * @memberof cc.sys - * @name OS_WINDOWS + * @name OS_IOS * @constant * @type {string} */ - sys.OS_WINDOWS = "Windows"; + sys.OS_IOS = "iOS"; /** * @memberof cc.sys - * @name OS_IOS + * @name OS_ANDROID * @constant * @type {string} */ - sys.OS_IOS = "iOS"; + sys.OS_ANDROID = "Android"; /** * @memberof cc.sys - * @name OS_OSX + * @name OS_WINDOWS * @constant * @type {string} */ - sys.OS_OSX = "OS X"; + sys.OS_WINDOWS = "Windows"; /** * @memberof cc.sys - * @name OS_UNIX + * @name OS_MARMALADE * @constant * @type {string} */ - sys.OS_UNIX = "UNIX"; + sys.OS_MARMALADE = "Marmalade"; /** * @memberof cc.sys * @name OS_LINUX @@ -1356,11 +1356,39 @@ cc._initSys = function (config, CONFIG_KEY) { sys.OS_LINUX = "Linux"; /** * @memberof cc.sys - * @name OS_ANDROID + * @name OS_BADA * @constant * @type {string} */ - sys.OS_ANDROID = "Android"; + sys.OS_BADA = "Bada"; + /** + * @memberof cc.sys + * @name OS_BLACKBERRY + * @constant + * @type {string} + */ + sys.OS_BLACKBERRY = "Blackberry"; + /** + * @memberof cc.sys + * @name OS_OSX + * @constant + * @type {string} + */ + sys.OS_OSX = "OS X"; + /** + * @memberof cc.sys + * @name OS_WP8 + * @constant + * @type {string} + */ + sys.OS_WP8 = "WP8"; + /** + * @memberof cc.sys + * @name OS_WINRT + * @constant + * @type {string} + */ + sys.OS_WINRT = "WINRT"; /** * @memberof cc.sys * @name OS_UNKNOWN @@ -1371,52 +1399,60 @@ cc._initSys = function (config, CONFIG_KEY) { /** * @memberof cc.sys - * @name WINDOWS + * @name UNKNOWN * @constant * @default * @type {Number} */ - sys.WINDOWS = 0; + sys.UNKNOWN = 0; /** * @memberof cc.sys - * @name LINUX + * @name IOS * @constant * @default * @type {Number} */ - sys.LINUX = 1; + sys.IOS = 1; /** * @memberof cc.sys - * @name MACOS + * @name ANDROID * @constant * @default * @type {Number} */ - sys.MACOS = 2; + sys.ANDROID = 2; /** * @memberof cc.sys - * @name ANDROID + * @name WIN32 + * @constant + * @default + * @type {Number} + */ + sys.WIN32 = 3; + /** + * @memberof cc.sys + * @name MARMALADE * @constant * @default * @type {Number} */ - sys.ANDROID = 3; + sys.MARMALADE = 4; /** * @memberof cc.sys - * @name IPHONE + * @name LINUX * @constant * @default * @type {Number} */ - sys.IPHONE = 4; + sys.LINUX = 5; /** * @memberof cc.sys - * @name IPAD + * @name BADA * @constant * @default * @type {Number} */ - sys.IPAD = 5; + sys.BADA = 6; /** * @memberof cc.sys * @name BLACKBERRY @@ -1424,7 +1460,15 @@ cc._initSys = function (config, CONFIG_KEY) { * @default * @type {Number} */ - sys.BLACKBERRY = 6; + sys.BLACKBERRY = 7; + /** + * @memberof cc.sys + * @name MACOS + * @constant + * @default + * @type {Number} + */ + sys.MACOS = 8; /** * @memberof cc.sys * @name NACL @@ -1432,7 +1476,7 @@ cc._initSys = function (config, CONFIG_KEY) { * @default * @type {Number} */ - sys.NACL = 7; + sys.NACL = 9; /** * @memberof cc.sys * @name EMSCRIPTEN @@ -1440,7 +1484,7 @@ cc._initSys = function (config, CONFIG_KEY) { * @default * @type {Number} */ - sys.EMSCRIPTEN = 8; + sys.EMSCRIPTEN = 10; /** * @memberof cc.sys * @name TIZEN @@ -1448,15 +1492,15 @@ cc._initSys = function (config, CONFIG_KEY) { * @default * @type {Number} */ - sys.TIZEN = 9; + sys.TIZEN = 11; /** * @memberof cc.sys - * @name WINRT + * @name QT5 * @constant * @default * @type {Number} */ - sys.WINRT = 10; + sys.QT5 = 12; /** * @memberof cc.sys * @name WP8 @@ -1464,7 +1508,15 @@ cc._initSys = function (config, CONFIG_KEY) { * @default * @type {Number} */ - sys.WP8 = 11; + sys.WP8 = 13; + /** + * @memberof cc.sys + * @name WINRT + * @constant + * @default + * @type {Number} + */ + sys.WINRT = 14; /** * @memberof cc.sys * @name MOBILE_BROWSER From 937166250a563769be4b9b8033f85b5a2ab88a3c Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 25 Mar 2015 16:35:28 +0800 Subject: [PATCH 1455/1564] Corrected a mistake of cc.Scheduler in _schedulePerFrame that the hasElement hasn't priority because it's an array. --- cocos2d/core/CCScheduler.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 947db33029..75c955a2cd 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -59,7 +59,7 @@ cc.ListEntry = function (prev, next, callback, target, priority, paused, markedF * A update entry list * @Class * @name cc.HashUpdateEntry - * @param {cc.ListEntry} list Which list does it belong to ? + * @param {Array} list Which list does it belong to ? * @param {cc.ListEntry} entry entry in the list * @param {cc.Class} target hash key (retained) * @param {function} callback @@ -193,7 +193,6 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ }); cc.TimerTargetSelector = cc.Timer.extend({ - _target: null, _selector: null, @@ -326,9 +325,9 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ _schedulePerFrame: function(callback, target, priority, paused){ var hashElement = this._hashForUpdates[target.__instanceId]; - if (hashElement){ + if (hashElement && hashElement.entry){ // check if priority has changed - if (hashElement.list.priority !== priority){ + if (hashElement.entry.priority !== priority){ if (this._updateHashLocked){ cc.log("warning: you CANNOT change update priority in scheduled function"); hashElement.entry.markedForDeletion = false; From 0824be041a4ac4594348f5ff579fd0804a33b309 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 25 Mar 2015 17:37:51 +0800 Subject: [PATCH 1456/1564] Fixed #2776: Fixed a bug of cc.ClippingNode that it doesn't work when set Inverted to true on Canvas Mode. --- cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js index 5e237d7c48..988af800f2 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -104,8 +104,8 @@ if(!stencil) return; var node = this._node; - if(stencil._renderCmd && stencil._renderCmd._setBlendFuncStr) - stencil._renderCmd._setBlendFuncStr(node.inverted ? "destination-out" : "destination-in"); + if(stencil._renderCmd && stencil._renderCmd._blendFuncStr) + stencil._renderCmd._blendFuncStr = (node.inverted ? "destination-out" : "destination-in"); if(!stencil._children) return; From 8e13665d74dcc23e8a687f3658c3e185742146e6 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 25 Mar 2015 17:42:54 +0800 Subject: [PATCH 1457/1564] Removed the unused function from cc.Sprite. --- cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js | 2 +- cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js index 988af800f2..9a0a0d8d2d 100644 --- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js @@ -104,7 +104,7 @@ if(!stencil) return; var node = this._node; - if(stencil._renderCmd && stencil._renderCmd._blendFuncStr) + if(stencil._renderCmd && stencil._renderCmd._blendFuncStr) //it is a hack way. stencil._renderCmd._blendFuncStr = (node.inverted ? "destination-out" : "destination-in"); if(!stencil._children) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 4eb973c819..1dac4df749 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -46,11 +46,6 @@ proto._init = function () {}; - proto._setBlendFuncStr = function(compositeOperation){ - //a hack function for clippingNode - this._blendFuncStr = compositeOperation; - }; - proto.setDirtyRecursively = function (value) {}; proto._resetForBatchNode = function () {}; From f821b69d08b9e17755a2b47f827573bca7914656 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 26 Mar 2015 11:10:27 +0800 Subject: [PATCH 1458/1564] Issue #1565: TTF font haven't been set when parser Label --- .../cocostudio/loader/parsers/uiParser-1.x.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/uiParser-1.x.js b/extensions/cocostudio/loader/parsers/uiParser-1.x.js index c27002bb22..c14763e875 100644 --- a/extensions/cocostudio/loader/parsers/uiParser-1.x.js +++ b/extensions/cocostudio/loader/parsers/uiParser-1.x.js @@ -458,6 +458,7 @@ /** * Text parser (UIText) */ + var regTTF = /\.ttf$/; parser.TextAttributes = function(widget, options, resourcePath){ var touchScaleChangeAble = options["touchScaleEnable"]; widget.setTouchScaleChangeEnabled(touchScaleChangeAble); @@ -469,7 +470,15 @@ } var fn = options["fontName"]; if (fn != null){ - widget.setFontName(options["fontName"]); + if(cc.sys.isNative){ + if(regTTF.test(fn)){ + widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn)); + }else{ + widget.setFontName(fn); + } + }else{ + widget.setFontName(fn.replace(regTTF, '')); + } } var aw = options["areaWidth"]; var ah = options["areaHeight"]; @@ -599,7 +608,7 @@ /** * TextField parser (UITextField) */ - parser.TextFieldAttributes = function(widget, options, resoutcePath){ + parser.TextFieldAttributes = function(widget, options, resourcePath){ var ph = options["placeHolder"]; if(ph) widget.setPlaceHolder(ph); @@ -608,8 +617,17 @@ if(fs) widget.setFontSize(fs); var fn = options["fontName"]; - if(fn) - widget.setFontName(fn); + if (fn != null){ + if(cc.sys.isNative){ + if(regTTF.test(fn)){ + widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn)); + }else{ + widget.setFontName(fn); + } + }else{ + widget.setFontName(fn.replace(regTTF, '')); + } + } var tsw = options["touchSizeWidth"]; var tsh = options["touchSizeHeight"]; if(tsw!=null && tsh!=null) From c0de7f261dfa12b77e9676945f347ad6c168b4c8 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 26 Mar 2015 12:01:18 +0800 Subject: [PATCH 1459/1564] Fixed a bug of Scale9Sprite that it doesn't work when texture doesn't preload. --- extensions/ccui/base-classes/UIScale9Sprite.js | 18 +++++++++--------- .../gui/control-extension/CCScale9Sprite.js | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index 813ceae5c1..f828457d2d 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -467,11 +467,11 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ if(!locLoaded){ texture.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. - var preferredSize = this._preferredSize; - preferredSize = cc.size(preferredSize.width, preferredSize.height); + var preferredSize = this._preferredSize, restorePreferredSize = preferredSize.width !== 0 && preferredSize.height !== 0; + if (restorePreferredSize) preferredSize = cc.size(preferredSize.width, preferredSize.height); var size = sender.getContentSize(); this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets); - this.setPreferredSize(preferredSize); + if (restorePreferredSize)this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); }, this); @@ -500,10 +500,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ if(!locLoaded){ spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. - var preferredSize = this._preferredSize; - preferredSize = cc.size(preferredSize.width, preferredSize.height); + var preferredSize = this._preferredSize, restorePreferredSize = preferredSize.width !== 0 && preferredSize.height !== 0; + if (restorePreferredSize) preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); - this.setPreferredSize(preferredSize); + if (restorePreferredSize)this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); },this); @@ -900,10 +900,10 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ if(!locLoaded){ spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. - var preferredSize = this._preferredSize; - preferredSize = cc.size(preferredSize.width, preferredSize.height); + var preferredSize = this._preferredSize, restorePreferredSize = preferredSize.width !== 0 && preferredSize.height !== 0; + if (restorePreferredSize) preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); - this.setPreferredSize(preferredSize); + if (restorePreferredSize)this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); },this); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index abe7056ef7..917ccd0332 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -462,11 +462,11 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if(!locLoaded){ texture.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. - var preferredSize = this._preferredSize; - preferredSize = cc.size(preferredSize.width, preferredSize.height); + var preferredSize = this._preferredSize, restorePreferredSize = (preferredSize.width !== 0 || preferredSize.height !== 0); + if(restorePreferredSize)preferredSize = cc.size(preferredSize.width, preferredSize.height); var size = sender.getContentSize(); this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets); - this.setPreferredSize(preferredSize); + if(restorePreferredSize)this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); }, this); @@ -495,10 +495,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if(!locLoaded){ spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. - var preferredSize = this._preferredSize; - preferredSize = cc.size(preferredSize.width, preferredSize.height); + var preferredSize = this._preferredSize, restorePreferredSize = (preferredSize.width !== 0 || preferredSize.height !== 0); + if(restorePreferredSize)preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); - this.setPreferredSize(preferredSize); + if(restorePreferredSize)this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); },this); @@ -895,10 +895,10 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ if(!locLoaded){ spriteFrame.addEventListener("load", function(sender){ // the texture is rotated on Canvas render mode, so isRotated always is false. - var preferredSize = this._preferredSize; - preferredSize = cc.size(preferredSize.width, preferredSize.height); + var preferredSize = this._preferredSize, restorePreferredSize = (preferredSize.width !== 0 || preferredSize.height !== 0); + if(restorePreferredSize)preferredSize = cc.size(preferredSize.width, preferredSize.height); this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType === cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets); - this.setPreferredSize(preferredSize); + if(restorePreferredSize)this.setPreferredSize(preferredSize); this._positionsAreDirty = true; this.dispatchEvent("load"); },this); From 72a8a85a979d7b58cdccb4a79eb87c493e7f759e Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 26 Mar 2015 13:52:44 +0800 Subject: [PATCH 1460/1564] make particle can be created from a object --- cocos2d/particle/CCParticleSystem.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 85a844df33..1c3a310adf 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -341,8 +341,10 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ var ton = plistFile || 100; this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); this.initWithTotalParticles(ton); - } else if (plistFile) { + } else if (cc.isString(plistFile)) { this.initWithFile(plistFile); + } else if (cc.isObject(plistFile)) { + this.initWithDictionary(plistFile, ""); } }, From 8cdd3254b09e9a524ba11b14cc4cdb549b821a43 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 26 Mar 2015 16:44:00 +0800 Subject: [PATCH 1461/1564] fix labelAtlas recover old label --- cocos2d/labels/CCLabelAtlas.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/labels/CCLabelAtlas.js b/cocos2d/labels/CCLabelAtlas.js index 4e649f6881..e922ddc2d6 100644 --- a/cocos2d/labels/CCLabelAtlas.js +++ b/cocos2d/labels/CCLabelAtlas.js @@ -143,9 +143,10 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{ var locLoaded = texture.isLoaded(); this._textureLoaded = locLoaded; if (!locLoaded) { + this._string = label; texture.addEventListener("load", function (sender) { this.initWithTexture(texture, width, height, label.length); - this.string = label; + this.string = this._string; this.setColor(this._renderCmd._displayedColor); this.dispatchEvent("load"); }, this); From 5dc60c280d4add59d8b3c13adf13008767a017df Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 27 Mar 2015 09:51:15 +0800 Subject: [PATCH 1462/1564] Issue #2751: added some functions to cc.Grid3D and cc.PageTurn3D --- cocos2d/actions3d/CCActionGrid.js | 53 ++++++++++++-- cocos2d/actions3d/CCActionPageTurn3D.js | 14 +++- cocos2d/effects/CCGrid.js | 92 +++++++++++++++++++++++-- 3 files changed, 148 insertions(+), 11 deletions(-) diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js index faaa31f7fe..38b5c8a37f 100644 --- a/cocos2d/actions3d/CCActionGrid.js +++ b/cocos2d/actions3d/CCActionGrid.js @@ -33,6 +33,7 @@ */ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ _gridSize:null, + _gridNodeTarget:null, /** * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. @@ -47,6 +48,8 @@ cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{ gridSize && this.initWithDuration(duration, gridSize); }, + _cacheTargetAsGridNode: function(){}, + /** * to copy object with deep copy. * returns a clone of action. @@ -155,20 +158,40 @@ cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{ }, /** - * returns the vertex than belongs to certain position in the grid + * returns the vertex than belongs to certain position in the grid.
    + * It will be deprecated in future, please use getVertex instead. * @param {cc.Point} position * @return {cc.Vertex3F} */ vertex:function (position) { - return this.target.grid.vertex(position); + return this.getVertex(position); }, /** - * returns the non-transformed vertex than belongs to certain position in the grid + * returns the vertex than belongs to certain position in the grid + * @param {cc.Point} position + * @return {cc.Vertex3F} + */ + getVertex: function(position){ + return this.target.grid.getVertex(position); + }, + + /** + * returns the non-transformed vertex than belongs to certain position in the grid
    + * It will be deprecated in future, please use getVertex instead. * @param {cc.Point} position * @return {cc.Vertex3F} */ originalVertex:function (position) { + return this.getOriginalVertex(position); + }, + + /** + * returns the non-transformed vertex than belongs to certain position in the grid + * @param {cc.Point} position + * @return {cc.Vertex3F} + */ + getOriginalVertex:function (position) { return this.target.grid.originalVertex(position); }, @@ -211,20 +234,40 @@ cc.Grid3DAction.create = cc.grid3DAction; cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{ /** - * returns the tile that belongs to a certain position of the grid + * returns the tile that belongs to a certain position of the grid
    + * It will be deprecated in future, please use getTile instead. * @param {cc.Point} position * @return {cc.Quad3} */ tile:function (position) { + return this.getTile(position); + }, + + /** + * returns the tile that belongs to a certain position of the grid + * @param {cc.Point} position + * @return {cc.Quad3} + */ + getTile:function (position) { return this.target.grid.tile(position); }, /** - * returns the non-transformed tile that belongs to a certain position of the grid + * returns the non-transformed tile that belongs to a certain position of the grid
    + * It will be deprecated in future, please use getOriginalTile instead. * @param {cc.Point} position * @return {cc.Quad3} */ originalTile:function (position) { + return this.getOriginalTile(position); + }, + + /** + * returns the non-transformed tile that belongs to a certain position of the grid + * @param {cc.Point} position + * @return {cc.Quad3} + */ + getOriginalTile:function (position) { return this.target.grid.originalTile(position); }, diff --git a/cocos2d/actions3d/CCActionPageTurn3D.js b/cocos2d/actions3d/CCActionPageTurn3D.js index 367531662c..a28f0d4852 100644 --- a/cocos2d/actions3d/CCActionPageTurn3D.js +++ b/cocos2d/actions3d/CCActionPageTurn3D.js @@ -36,6 +36,18 @@ * @extends cc.Grid3DAction */ cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{ + getGrid: function(){ + var result = new cc.Grid3D(this._gridSize); + result.setNeedDepthTestForBlit(true); + return result; + }, + + clone: function(){ + var ret = new cc.PageTurn3D(); + ret.initWithDuration(this._duration, this._gridSize); + return ret; + }, + /** * Update each tick
    * Time is the percentage of the way through the duration @@ -58,7 +70,7 @@ cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{ locVer.x = i; locVer.y = j; // Get original vertex - var p = this.originalVertex(locVer); + var p = this.getOriginalVertex(locVer); var R = Math.sqrt((p.x * p.x) + ((p.y - ay) * (p.y - ay))); var r = R * sinTheta; diff --git a/cocos2d/effects/CCGrid.js b/cocos2d/effects/CCGrid.js index d324338c81..3a0ec265c9 100644 --- a/cocos2d/effects/CCGrid.js +++ b/cocos2d/effects/CCGrid.js @@ -241,7 +241,15 @@ cc.GridBase = cc.Class.extend(/** @lends cc.GridBase# */{ } cc.glBindTexture2D(this._texture); + this.beforeBlit(); this.blit(target); + this.afterBlit(); + }, + + beforeBlit: function () { + }, + + afterBlit: function () { }, blit:function () { @@ -300,6 +308,10 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ _verticesBuffer:null, _indicesBuffer:null, + _needDepthTestForBlit: false, + _oldDepthTestValue: false, + _oldDepthWriteValue: false, + /** * create one Grid3D object * Constructor of cc.Grid3D @@ -323,11 +335,21 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ }, /** - * returns the vertex at a given position + * returns the vertex at a given position
    + * It will be deprecated in future, please use getVertex instead. * @param {cc.Point} pos * @return {cc.Vertex3F} */ vertex:function (pos) { + return this.getVertex(pos); + }, + + /** + * returns the vertex at a given position + * @param {cc.Point} pos + * @return {cc.Vertex3F} + */ + getVertex: function(pos){ if(pos.x !== (0| pos.x) || pos.y !== (0| pos.y)) cc.log("cc.Grid3D.vertex() : Numbers must be integers"); var index = 0 | ((pos.x * (this._gridSize.height + 1) + pos.y) * 3); @@ -336,11 +358,21 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ }, /** - * returns the original (non-transformed) vertex at a given position + * returns the original (non-transformed) vertex at a given position
    + * It will be deprecated in future, please use getOriginalVertex instead. * @param {cc.Point} pos * @return {cc.Vertex3F} */ originalVertex:function (pos) { + return this.getOriginalVertex(pos); + }, + + /** + * returns the original (non-transformed) vertex at a given position + * @param {cc.Point} pos + * @return {cc.Vertex3F} + */ + getOriginalVertex: function(pos) { if(pos.x !== (0| pos.x) || pos.y !== (0| pos.y)) cc.log("cc.Grid3D.originalVertex() : Numbers must be integers"); var index = 0 | ((pos.x * (this._gridSize.height + 1) + pos.y) * 3); @@ -364,6 +396,28 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ this._dirty = true; }, + beforeBlit: function () { + if (this._needDepthTestForBlit) { + var gl = cc._renderContext; + this._oldDepthTestValue = gl.isEnabled(gl.DEPTH_TEST); + this._oldDepthWriteValue = gl.getParameter(gl.DEPTH_WRITEMASK); + //CHECK_GL_ERROR_DEBUG(); + gl.enable(gl.DEPTH_TEST); + gl.depthMask(true); + } + }, + + afterBlit: function () { + if (this._needDepthTestForBlit) { + var gl = cc._renderContext; + if (this._oldDepthTestValue) + gl.enable(gl.DEPTH_TEST); + else + gl.disable(gl.DEPTH_TEST); + gl.depthMask(this._oldDepthWriteValue); + } + }, + blit:function (target) { var n = this._gridSize.width * this._gridSize.height; cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS); @@ -480,6 +534,14 @@ cc.Grid3D = cc.GridBase.extend(/** @lends cc.Grid3D# */{ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._indices, gl.STATIC_DRAW); this._dirty = true; + }, + + setNeedDepthTestForBlit: function(needDepthTest){ + this._needDepthTestForBlit = needDepthTest; + }, + + getNeedDepthTestForBlit: function(){ + return this._needDepthTestForBlit; } }); @@ -534,11 +596,21 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ }, /** - * returns the tile at the given position + * returns the tile at the given position
    + * It will be deprecated in future, please use getTile instead. * @param {cc.Point} pos * @return {cc.Quad3} */ tile:function (pos) { + return this.getTile(pos); + }, + + /** + * returns the tile at the given position + * @param {cc.Point} pos + * @return {cc.Quad3} + */ + getTile: function(pos){ if(pos.x !== (0| pos.x) || pos.y !== (0| pos.y)) cc.log("cc.TiledGrid3D.tile() : Numbers must be integers"); @@ -555,7 +627,7 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ * @param {cc.Point} pos * @return {cc.Quad3} */ - originalTile:function (pos) { + getOriginalTile:function (pos) { if(pos.x !== (0| pos.x) || pos.y !== (0| pos.y)) cc.log("cc.TiledGrid3D.originalTile() : Numbers must be integers"); @@ -567,6 +639,16 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ new cc.Vertex3F(locOriginalVertices[idx + 9], locOriginalVertices[idx + 10], locOriginalVertices[idx + 11])); }, + /** + * returns the original tile (untransformed) at the given position.
    + * It will be deprecated in future, please use getOriginalTile instead. + * @param {cc.Point} pos + * @return {cc.Quad3} + */ + originalTile: function(pos) { + return this.getOriginalTile(pos); + }, + /** * sets a new tile * @param {cc.Point} pos @@ -593,7 +675,7 @@ cc.TiledGrid3D = cc.GridBase.extend(/** @lends cc.TiledGrid3D# */{ this._dirty = true; }, - blit:function (target) { + blit: function (target) { var n = this._gridSize.width * this._gridSize.height; this._shaderProgram.use(); From 39f2e0b1d02ef54b9c336c4e7f421d6ccc37de2a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 27 Mar 2015 15:34:27 +0800 Subject: [PATCH 1463/1564] Fixed #2786: fixed a bug of ccs.Armature that its name changes to animation name when loading from json files. --- extensions/cocostudio/armature/CCArmature.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/extensions/cocostudio/armature/CCArmature.js b/extensions/cocostudio/armature/CCArmature.js index e2c912b02c..7e8c58c3c9 100644 --- a/extensions/cocostudio/armature/CCArmature.js +++ b/extensions/cocostudio/armature/CCArmature.js @@ -89,8 +89,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this._boneDic = {}; this._topBoneList.length = 0; - - this._name = name || ""; + //this._name = name || ""; var armatureDataManager = ccs.armatureDataManager; var animationData; @@ -131,15 +130,15 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{ this.update(0); this.updateOffsetPoint(); } else { - this._name = "new_armature"; + name = "new_armature"; this.armatureData = new ccs.ArmatureData(); - this.armatureData.name = this._name; + this.armatureData.name = name; animationData = new ccs.AnimationData(); - animationData.name = this._name; + animationData.name = name; - armatureDataManager.addArmatureData(this._name, this.armatureData); - armatureDataManager.addAnimationData(this._name, animationData); + armatureDataManager.addArmatureData(name, this.armatureData); + armatureDataManager.addAnimationData(name, animationData); this.animation.setAnimationData(animationData); } From 6e25cdfcbca795fcf0ba310bb8bcce66f905d452 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Fri, 27 Mar 2015 16:43:48 +0800 Subject: [PATCH 1464/1564] Fixed 2786: Added a tip message function to cc.TextField on mobile browser. --- cocos2d/text-input/CCIMEDispatcher.js | 4 +++- cocos2d/text-input/CCTextFieldTTF.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cocos2d/text-input/CCIMEDispatcher.js b/cocos2d/text-input/CCIMEDispatcher.js index 56c08d3204..4b713086e5 100644 --- a/cocos2d/text-input/CCIMEDispatcher.js +++ b/cocos2d/text-input/CCIMEDispatcher.js @@ -387,7 +387,9 @@ cc.IMEDispatcher = cc.Class.extend(/** @lends cc.imeDispatcher# */{ delegate.didAttachWithIME(); //prompt this._currentInputString = delegate.string || ""; - var userInput = prompt("please enter your word:", this._currentInputString); + + var tipMessage = delegate.getTipMessage ? delegate.getTipMessage() : "please enter your word:"; + var userInput = prompt(tipMessage, this._currentInputString); if(userInput != null) this._processDomInputString(userInput); this.dispatchInsertText("\n", 1); diff --git a/cocos2d/text-input/CCTextFieldTTF.js b/cocos2d/text-input/CCTextFieldTTF.js index 3628df9e9a..b5c9fb1283 100644 --- a/cocos2d/text-input/CCTextFieldTTF.js +++ b/cocos2d/text-input/CCTextFieldTTF.js @@ -387,6 +387,25 @@ cc.TextFieldTTF = cc.LabelTTF.extend(/** @lends cc.TextFieldTTF# */{ cc.imeDispatcher.removeDelegate(this); }, + _tipMessage: "please enter your word:", + /** + * Sets the input tip message to show on mobile browser. (mobile Web only) + * @param {string} tipMessage + */ + setTipMessage: function (tipMessage) { + if (tipMessage == null) + return; + this._tipMessage = tipMessage; + }, + + /** + * Gets the input tip message to show on mobile browser. (mobile Web only) + * @returns {string} + */ + getTipMessage: function () { + return this._tipMessage; + }, + /** * Append the text.
    * Input the character. From 5cb3f16b60f15bab4085f755c716e41049819994 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Sat, 28 Mar 2015 16:27:06 +0800 Subject: [PATCH 1465/1564] Fixed a bug that UILayoutComponent.js --- extensions/ccui/layouts/UILayoutComponent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/layouts/UILayoutComponent.js b/extensions/ccui/layouts/UILayoutComponent.js index ed7182def5..96a9dbf3fa 100644 --- a/extensions/ccui/layouts/UILayoutComponent.js +++ b/extensions/ccui/layouts/UILayoutComponent.js @@ -573,7 +573,7 @@ ccui.LayoutComponent.verticalEdge = {NONE: 0, BOTTOM: 1, TOP: 2, CENTER: 3}; ccui.LayoutComponent.NAME = "__ui_layout"; ccui.LayoutComponent.bindLayoutComponent = function (node) { var layout = node.getComponent(ccui.LayoutComponent.NAME); - if (layout !== null) + if (layout !== undefined) return layout; layout = new ccui.LayoutComponent(); From bcc0ed3a78b4c5449625074744168619cb0b4f10 Mon Sep 17 00:00:00 2001 From: Igor Shmulyan Date: Sat, 28 Mar 2015 22:58:37 +0200 Subject: [PATCH 1466/1564] fixed canceling child touch during moving of page view --- extensions/ccui/uiwidgets/scroll-widget/UIPageView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js index 8dd03b0b5a..233fdebf78 100644 --- a/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +++ b/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js @@ -508,7 +508,7 @@ ccui.PageView = ccui.Layout.extend(/** @lends ccui.PageView# */{ var offset = 0; offset = Math.abs(sender.getTouchBeganPosition().x - touchPoint.x); if (offset > this._childFocusCancelOffset) { - sender.setFocused(false); + sender.setHighlighted(false); this._handleMoveLogic(touch); } break; From 6bad3e1b9fb720c972db4310a459f07adb4164c8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Mar 2015 09:49:06 +0800 Subject: [PATCH 1467/1564] Change the version number --- cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index eb24ebe368..96753a2e8f 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.4 Beta0"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.4"; /** *

    diff --git a/tools/build.xml b/tools/build.xml index ce6e9c35cf..0f5b80ac2f 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,7 +5,7 @@ classpath="./compiler/compiler.jar"/> + debug="false" output="./../lib/cocos2d-js-v3.4-min.js"> @@ -298,7 +298,7 @@ + debug="false" output="./../lib/cocos2d-js-v3.4-core-min.js"> From b8efc5f958b78a8100723cea5e7a385e10895543 Mon Sep 17 00:00:00 2001 From: feijing566 Date: Mon, 30 Mar 2015 10:14:30 +0800 Subject: [PATCH 1468/1564] Fixed a bug about CCAudio Fixed a bug about CCAudio --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index ccc1853d56..4312a527d7 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -255,7 +255,7 @@ cc.Audio = cc.Class.extend({ return true; }else{ var sourceNode = this._currentSource; - if(!this._playing && !sourceNode) + if(!this._playing || !sourceNode) return true; if(sourceNode["playbackState"] == null) return this._playing; From 28aa5043970dd7ac29534ef0c442d2a69663d674 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Mar 2015 10:56:06 +0800 Subject: [PATCH 1469/1564] Fixed CCScheduler repeat error --- cocos2d/core/CCScheduler.js | 2 +- cocos2d/core/base-nodes/CCNode.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 75c955a2cd..a1abe6f467 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -159,7 +159,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ update:function (dt) { if (this._elapsed === -1) { this._elapsed = 0; - this._timesExecuted = 0; + this._timesExecuted = 1; } else { this._elapsed += dt; if (this._runForever && !this._useDelay) {//standard timer usage diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 6cb06db921..590a751414 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1700,9 +1700,14 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ delay = 0; } }else if(len === 3){ - //callback, interval, key - key = repeat; - repeat = cc.REPEAT_FOREVER; + if(typeof repeat === "string"){ + //callback, interval, key + key = repeat; + repeat = cc.REPEAT_FOREVER; + }else{ + //callback, interval, repeat + key = this.__instanceId; + } delay = 0; }else if(len === 4){ key = this.__instanceId; From 9a3215ffff2b4b618c1195fd33af8ced8185db99 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Mar 2015 11:35:16 +0800 Subject: [PATCH 1470/1564] Fixed CCScheduler repeat error --- cocos2d/core/CCScheduler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index a1abe6f467..75c955a2cd 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -159,7 +159,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{ update:function (dt) { if (this._elapsed === -1) { this._elapsed = 0; - this._timesExecuted = 1; + this._timesExecuted = 0; } else { this._elapsed += dt; if (this._runForever && !this._useDelay) {//standard timer usage From 65ec96f44a5ea3c01b56bdb5b0c381d08f309c87 Mon Sep 17 00:00:00 2001 From: joshuastray Date: Mon, 30 Mar 2015 11:35:24 +0800 Subject: [PATCH 1471/1564] add cc.sys.OpenURL --- CCBoot.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index b67dd68d0b..ac316ccd3c 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1797,6 +1797,16 @@ cc._initSys = function (config, CONFIG_KEY) { str += "platform : " + self.platform + "\r\n"; cc.log(str); } + + /** + * Open a url in browser + * @memberof cc.sys + * @name openURL + * @param {String} url + */ + sys.openURL = function(url){ + window.open(url); + } }; //+++++++++++++++++++++++++something about sys end+++++++++++++++++++++++++++++ From d942918530e5d21846a294ae54a0d6dab2b77063 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Mar 2015 14:46:31 +0800 Subject: [PATCH 1472/1564] Fixed spine collapse. (canvas) --- extensions/spine/CCSkeletonCanvasRenderCmd.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/spine/CCSkeletonCanvasRenderCmd.js b/extensions/spine/CCSkeletonCanvasRenderCmd.js index d887f6d791..ff31b3d0e9 100644 --- a/extensions/spine/CCSkeletonCanvasRenderCmd.js +++ b/extensions/spine/CCSkeletonCanvasRenderCmd.js @@ -155,10 +155,10 @@ bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); selSprite.setScale(bone.worldScaleX, bone.worldScaleY); selSprite.setRotation(-(slot.bone.worldRotation + attachment.rotation)); - selSprite.setOpacity(0 | (slot.skeleton.a * slot.a * 255)); - var r = 0 | (slot.skeleton.r * slot.r * 255); - var g = 0 | (slot.skeleton.g * slot.g * 255); - var b = 0 | (slot.skeleton.b * slot.b * 255); + selSprite.setOpacity(0 | (node._skeleton.a * slot.a * 255)); + var r = 0 | (node._skeleton.r * slot.r * 255); + var g = 0 | (node._skeleton.g * slot.g * 255); + var b = 0 | (node._skeleton.b * slot.b * 255); selSprite.setColor(cc.color(r,g,b)); } }; From d773bbf00322fe6a8b0e7f67f78e021d5a4ba242 Mon Sep 17 00:00:00 2001 From: feijing566 Date: Mon, 30 Mar 2015 15:00:41 +0800 Subject: [PATCH 1473/1564] Update CCAudio.js remove the check because this._playing alway is true --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 4312a527d7..34f412f60d 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -255,7 +255,7 @@ cc.Audio = cc.Class.extend({ return true; }else{ var sourceNode = this._currentSource; - if(!this._playing || !sourceNode) + if(!sourceNode) return true; if(sourceNode["playbackState"] == null) return this._playing; From e9c40c3a611dd403fe77fd4d83e6244e55118c33 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 30 Mar 2015 20:13:45 +0800 Subject: [PATCH 1474/1564] Fixed unscheduler error --- cocos2d/core/base-nodes/CCNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 6cb06db921..f4d4fa05b1 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1759,7 +1759,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if (!callback_fn) return; - this.scheduler.unschedule(this.__instanceId, this, callback_fn); + this.scheduler.unschedule(callback_fn, this); }, /** From b2e07cf7fb338355b118c81e6984d00478d28570 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 31 Mar 2015 16:44:04 +0800 Subject: [PATCH 1475/1564] Update the authors --- AUTHORS.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 8d63894f5e..933701bb3e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -240,11 +240,18 @@ Dany Ellement @DEllement cc.FontDefinition & ccui.RichText improvemen IShm @IShm cc.Screen bug fix cc.ParticleSystem bug fix + ccui.PageView bug fix Thomas Jablonski @thomas-jablonski cc.audioEngine bug fix + Cocostudio typo fix WingGao @WingGao cc.TMXLayer bug fix +Skliar Ihor @igogo5yo Add Bower support + +feijing566 @feijing566 cc.Audio bug fix + + Retired Core Developers: Shengxiang Chen (Nero Chan) Xingsen Ma From ecaa1aed18c4fc4b0d71c862c1259530c85075d3 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 31 Mar 2015 22:03:38 +0800 Subject: [PATCH 1476/1564] Update Engine version --- cocos2d/core/platform/CCConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 96753a2e8f..4a6ba3834b 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.4"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.5"; /** *

    From 97e739cc1fce776c082747ff7a278617fc7a9548 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 1 Apr 2015 10:51:20 +0800 Subject: [PATCH 1477/1564] [Cocos2d-JS v3.5] Added changelog --- CHANGELOG.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index cb53252b0c..6f25c68923 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,35 @@ ChangeLog: +Cocos2d-JS v3.5 @ April 1 2015 + +* Upgraded Cocos Studio parser to support Cocos Studio v2.2. +* Upgraded Spine support to v2.1, added spine test case with FFD. FFD is supported in native but not in web, both engine can parse the new version file correctly, but the web engine will ignore FFD informations. +* Replaced '==' with '===' for better performance. +* Added `path` parameter in `ccs.load` to support modifying cocostudio project resource path. +* Added animationList to Cocostudio ActionTimeline to support playing animation by name. +* Made ParticleSystem support creation from an map object. +* Added missing functions to `cc.Grid3D` and `cc.PageTurn3D`. +* Added tip message functions to `cc.TextFieldTTF` for mobile browser. +* Added a function `cc.sys.openURL`. +* Disabled retina display by default for better performance. +* Added Bower support. +* Updated `cc.sys.OS_XXX` informations for supported systems. + +* Bug fixes: + 1. Fixed a bug of chipmunk.js that it doesn't work under closure compiler advanced mode. + 2. Fixed a bug of Cocos Studio parser that widget didn't set its layout component. + 3. Fixed grammatical mistakes in cocostudio parser logs. + 4. Fixed memory leak issue in `cc.LabelBMFont`. + 5. Fixed a bug of `cc.Scale9Sprite` that its `updateDisplayColor` doesn't take effect. + 6. Fixed a bug of Cocos Studio parser that `cc.Scale9Sprite` doesn't display correctly if its texture isn't preloaded. + 7. Fixed a bug of `cc.MenuItemSprite` that the construction will fail when parameter `selectedSprite` is a Scale9Sprite instance. + 8. Fixed a bug of Cocos Studio parser that the background color of `ccui.Layout` can't be parsed correctly. + 9. Fixed a bug of `cc.ClippingNode` that it doesn't work when set `inverted` to true in Canvas Mode. + 10. Fixed a bug of `ccs.Armature` that its name was modified to animation name when loading from json files. + 11. Fixed a bug of `ccui.PageView` that it cancel child touch during movment of page view. + 12. Fixed a bug of `cc.Scheduler` that its parameter `repeat` is invalid in schedule function. + 13. Fixed a bug of `cc.Scheduler` that `unschedule` function may fail. + Cocos2d-JS v3.4 Beta0 @ March 19 2015 * Added Windows Phone 8.0 platform support. From 31c397cb0c60d923f49ac056d0fd6e28b02110be Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 1 Apr 2015 14:34:38 +0800 Subject: [PATCH 1478/1564] Update build.xml --- tools/build.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/build.xml b/tools/build.xml index 0f5b80ac2f..29c6abadb1 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,8 +5,8 @@ classpath="./compiler/compiler.jar"/> - + debug="false" output="./../lib/cocos2d-js-v3.5-min.js"> + @@ -298,8 +298,8 @@ - + debug="false" output="./../lib/cocos2d-js-v3.5-core-min.js"> + From 2354cc8e111bc7092f8380aed644dcc6f2ab52b0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 1 Apr 2015 14:36:40 +0800 Subject: [PATCH 1479/1564] Fixed a bug that scheduleUpdate error when cc.ActionManager is null --- cocos2d/core/CCDirector.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 02141cbda5..cd84958624 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -154,8 +154,12 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{ //scheduler this._scheduler = new cc.Scheduler(); //action manager - this._actionManager = cc.ActionManager ? new cc.ActionManager() : null; - this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false); + if(cc.ActionManager){ + this._actionManager = new cc.ActionManager(); + this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false); + }else{ + this._actionManager = null; + } this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW); this._eventAfterDraw.setUserData(this); From 2bc070301dcca4c865836ab55ebf847f7eff9ba0 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 1 Apr 2015 15:46:35 +0800 Subject: [PATCH 1480/1564] Fixed a bug of cc.LabelTTF that its enableShadow doesn't work. --- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 2 +- cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index d18507c02d..b6bddd9636 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -413,7 +413,7 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; locShadowColor = node._shadowColor || this._displayedColor; var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; - this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r * 0.5)) + "," + (0 | (locShadowColor.g * 0.5)) + "," + (0 | (locShadowColor.b * 0.5)) + "," + node._shadowOpacity + ")"; + this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r)) + "," + (0 | (locShadowColor.g)) + "," + (0 | (locShadowColor.b)) + "," + node._shadowOpacity + ")"; this._fillColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locFontFillColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locFontFillColor.g)) + "," + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", 1)"; //use globalOpacity + locDisplayedOpacity / 255 + ")"; this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," diff --git a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js index 12a70b54f5..dfa2893e61 100644 --- a/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js @@ -37,8 +37,9 @@ proto._setColorsString = function () { this.setDirtyFlag(cc.Node._dirtyFlags.textDirty); var node = this._node; - var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; - this._shadowColorStr = "rgba(128,128,128," + node._shadowOpacity + ")"; + var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor, + locShadowColor = node._shadowColor || this._displayedColor; + this._shadowColorStr = "rgba(" + (0 | locShadowColor.r) + "," + (0 | locShadowColor.g) + "," + (0 | locShadowColor.b) + "," + node._shadowOpacity + ")"; this._fillColorStr = "rgba(" + (0 | locFontFillColor.r) + "," + (0 | locFontFillColor.g) + "," + (0 | locFontFillColor.b) + ", 1)"; this._strokeColorStr = "rgba(" + (0 | locStrokeColor.r) + "," + (0 | locStrokeColor.g) + "," + (0 | locStrokeColor.b) + ", 1)"; }; From df97e0e8935bef7e436384965fd112688e147ede Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 1 Apr 2015 16:56:36 +0800 Subject: [PATCH 1481/1564] Fixed a bug that LoadingBar texture error without pre load. --- extensions/ccui/uiwidgets/UILoadingBar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UILoadingBar.js b/extensions/ccui/uiwidgets/UILoadingBar.js index 4a3235aa87..0b9b90eaed 100644 --- a/extensions/ccui/uiwidgets/UILoadingBar.js +++ b/extensions/ccui/uiwidgets/UILoadingBar.js @@ -124,7 +124,8 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ var self = this; if(!barRenderer._textureLoaded){ barRenderer.addEventListener("load", function(){ - self.loadTexture(self._renderBarTexType, self._textureFile); + self.loadTexture(self._textureFile, self._renderBarTexType); + self._setPercent(self._percent); }); } @@ -236,6 +237,10 @@ ccui.LoadingBar = ccui.Widget.extend(/** @lends ccui.LoadingBar# */{ if (percent === this._percent) return; this._percent = percent; + this._setPercent(percent); + }, + + _setPercent: function(percent){ if (this._totalLength <= 0) return; var res = this._percent / 100.0; From c8af0a9e5b704e3532d5e5a55413cedd05452e88 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 1 Apr 2015 17:00:36 +0800 Subject: [PATCH 1482/1564] Fixed a bug of cc.LabelTTF that its setColor doesn't set shadowColor on CanvasMode --- cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index b6bddd9636..fa687f865a 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -412,12 +412,14 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var locDisplayColor = this._displayedColor, node = this._node, locShadowColor = node._shadowColor || this._displayedColor; var locStrokeColor = node._strokeColor, locFontFillColor = node._textFillColor; - - this._shadowColorStr = "rgba(" + (0 | (locShadowColor.r)) + "," + (0 | (locShadowColor.g)) + "," + (0 | (locShadowColor.b)) + "," + node._shadowOpacity + ")"; - this._fillColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locFontFillColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locFontFillColor.g)) + "," - + (0 | (locDisplayColor.b / 255 * locFontFillColor.b)) + ", 1)"; //use globalOpacity + locDisplayedOpacity / 255 + ")"; - this._strokeColorStr = "rgba(" + (0 | (locDisplayColor.r / 255 * locStrokeColor.r)) + "," + (0 | (locDisplayColor.g / 255 * locStrokeColor.g)) + "," - + (0 | (locDisplayColor.b / 255 * locStrokeColor.b)) + ", 1)"; //use globalOpacity + locDisplayedOpacity / 255 + ")"; + var dr = locDisplayColor.r / 255, dg = locDisplayColor.g / 255, db = locDisplayColor.b / 255; + + this._shadowColorStr = "rgba(" + (0 | (dr * locShadowColor.r)) + "," + (0 | ( dg * locShadowColor.g)) + "," + + (0 | (db * locShadowColor.b)) + "," + node._shadowOpacity + ")"; + this._fillColorStr = "rgba(" + (0 | (dr * locFontFillColor.r)) + "," + (0 | (dg * locFontFillColor.g)) + "," + + (0 | (db * locFontFillColor.b)) + ", 1)"; + this._strokeColorStr = "rgba(" + (0 | (dr * locStrokeColor.r)) + "," + (0 | (dg * locStrokeColor.g)) + "," + + (0 | (db * locStrokeColor.b)) + ", 1)"; }; proto._updateColor = function(){ From 51f52789bec4792673924520a13012974aadc3a6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 2 Apr 2015 14:55:11 +0800 Subject: [PATCH 1483/1564] Repair a bug that is callback can't running. (cocosbuilder) --- extensions/ccb-reader/CCBReader.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index e22f54decf..32e8d8919f 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -709,9 +709,8 @@ cc.BuilderReader = cc.Class.extend({ _readHeader:function () { /* If no bytes loaded, don't crash about it. */ - if (this._data === null) { + if (!this._data) return false; - } /* Read magic bytes */ var magicBytes = this._readStringFromBytes(this._currentByte, 4, true); @@ -866,9 +865,9 @@ cc.BuilderReader = cc.Class.extend({ if (target !== null) { var assigned = false; - if (target.onAssignCCBMemberVariable) { + if (!target && (target.onAssignCCBMemberVariable)) assigned = target.onAssignCCBMemberVariable(target, memberVarAssignmentName, node); - } + locMemberAssigner = this._ccbMemberVariableAssigner; if (!assigned && locMemberAssigner != null && locMemberAssigner.onAssignCCBMemberVariable) { locMemberAssigner.onAssignCCBMemberVariable(target, memberVarAssignmentName, node); @@ -1070,9 +1069,9 @@ cc.BuilderReader.load = function (ccbFilePath, owner, parentSize, ccbRootPath) { var callbackType = callbackSplit[0]; var kfCallbackName = callbackSplit[1]; - if (callbackType === 1){ // Document callback + if (callbackType == 1){ // Document callback animationManager.setCallFunc(cc.callFunc(controller[kfCallbackName], controller), keyframeCallbacks[j]); - } else if (callbackType === 2 && owner) {// Owner callback + } else if (callbackType == 2 && owner) {// Owner callback animationManager.setCallFunc(cc.callFunc(owner[kfCallbackName], owner), keyframeCallbacks[j]); } } From 4460d7fba7edb2e6403436368563998dcf8bffda Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 2 Apr 2015 14:58:25 +0800 Subject: [PATCH 1484/1564] Repair a bug that is callback can't running. (cocosbuilder) --- extensions/ccb-reader/CCBReader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccb-reader/CCBReader.js b/extensions/ccb-reader/CCBReader.js index 32e8d8919f..657f68f607 100644 --- a/extensions/ccb-reader/CCBReader.js +++ b/extensions/ccb-reader/CCBReader.js @@ -862,10 +862,10 @@ cc.BuilderReader = cc.Class.extend({ target = this._owner; } - if (target !== null) { + if (!target) { var assigned = false; - if (!target && (target.onAssignCCBMemberVariable)) + if (target.onAssignCCBMemberVariable) assigned = target.onAssignCCBMemberVariable(target, memberVarAssignmentName, node); locMemberAssigner = this._ccbMemberVariableAssigner; From f111b1cd7860d0da623569ead42b7bf6764ff9c1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 2 Apr 2015 16:51:09 +0800 Subject: [PATCH 1485/1564] Fixed a bug that cancel error of cc.TimerTargetCallback --- cocos2d/core/CCScheduler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 75c955a2cd..df5849dd5c 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -263,7 +263,7 @@ cc.TimerTargetCallback = cc.Timer.extend({ cancel: function(){ //override - this._scheduler.unschedule(this._key, this._target); + this._scheduler.unschedule(this._callback, this._target); } }); From ee232559111a4748fd2a2661809ff119a35a84ff Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 3 Apr 2015 13:33:23 +0800 Subject: [PATCH 1486/1564] Fixed a bug that TMX Objects position error when set ContentScaleFactor --- cocos2d/tilemap/CCTMXXMLParser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js index 478db3f2ef..63b295d0e7 100644 --- a/cocos2d/tilemap/CCTMXXMLParser.js +++ b/cocos2d/tilemap/CCTMXXMLParser.js @@ -748,6 +748,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ } var objects = selGroup.querySelectorAll('object'); + var getContentScaleFactor = cc.director.getContentScaleFactor(); if (objects) { for (j = 0; j < objects.length; j++) { var selObj = objects[j]; @@ -761,15 +762,14 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{ // Assign all the attributes as key/name pairs in the properties dictionary objectProp["type"] = selObj.getAttribute('type') || ""; - objectProp["x"] = parseInt(selObj.getAttribute('x') || 0) + objectGroup.getPositionOffset().x; - var y = parseInt(selObj.getAttribute('y') || 0) + objectGroup.getPositionOffset().y; - objectProp["width"] = parseInt(selObj.getAttribute('width')) || 0; objectProp["height"] = parseInt(selObj.getAttribute('height')) || 0; + objectProp["x"] = (((selObj.getAttribute('x') || 0) | 0) + objectGroup.getPositionOffset().x) / getContentScaleFactor; + var y = ((selObj.getAttribute('y') || 0) | 0) + objectGroup.getPositionOffset().y / getContentScaleFactor; // Correct y position. (Tiled uses Flipped, cocos2d uses Standard) - objectProp["y"] = parseInt(this.getMapSize().height * this.getTileSize().height) - y - objectProp["height"]; - + objectProp["y"] = (parseInt(this.getMapSize().height * this.getTileSize().height) - y - objectProp["height"]) / cc.director.getContentScaleFactor(); + objectProp["rotation"] = parseInt(selObj.getAttribute('rotation')) || 0; var docObjProps = selObj.querySelectorAll("properties > property"); From 6c7666513a729dd09b467a9fb567d3a4dbf92483 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 3 Apr 2015 14:19:10 +0800 Subject: [PATCH 1487/1564] Fixed a bug that TMX position error on canvas --- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index b4f53b561a..fd6896e866 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -86,7 +86,6 @@ var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); wrapper.setGlobalAlpha(alpha); - var posX = 0 | ( -this._anchorPointInPoints.x), posY = 0 | ( -this._anchorPointInPoints.y); var locCacheCanvas = this._cacheCanvas; //direct draw image by canvas drawImage if (locCacheCanvas && locCacheCanvas.width !== 0 && locCacheCanvas.height !== 0) { @@ -95,10 +94,10 @@ if (node.layerOrientation === cc.TMX_ORIENTATION_HEX) { var halfTileSize = node._mapTileSize.height * 0.5 * scaleY; context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight) + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); + 0, -locCanvasHeight + halfTileSize, locCacheCanvas.width * scaleX, locCanvasHeight); } else { context.drawImage(locCacheCanvas, 0, 0, locCacheCanvas.width, locCacheCanvas.height, - posX, -(posY + locCanvasHeight), locCacheCanvas.width * scaleX, locCanvasHeight); + 0, -locCanvasHeight, locCacheCanvas.width * scaleX, locCanvasHeight); } } cc.g_NumberOfDraws++; From 57fe80299954319ea2f5187998e8758dae51767c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 3 Apr 2015 14:41:01 +0800 Subject: [PATCH 1488/1564] Update TMX transform to support RotationX and RotationY --- cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js index fd6896e866..6589bb2643 100644 --- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js @@ -182,11 +182,8 @@ worldT.c = t.c * pt.a + t.d * pt.c; //c worldT.d = t.c * pt.b + t.d * pt.d; //d - var plt = parentCmd._transform; - var xOffset = -(plt.b + plt.c) * t.ty; - var yOffset = -(plt.b + plt.c) * t.tx; - worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx - worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty + worldT.tx = pt.a * t.tx + pt.c * t.ty + pt.tx; + worldT.ty = pt.d * t.ty + pt.ty + pt.b * t.tx; } else { worldT.a = t.a; worldT.b = t.b; From be3f4f1008b8b0d77268cb78124c85530ba3a4ab Mon Sep 17 00:00:00 2001 From: RackovychV Date: Fri, 3 Apr 2015 13:08:47 +0300 Subject: [PATCH 1489/1564] fix scheduler pauseAllTargetsWithMinPriority --- cocos2d/core/CCScheduler.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index df5849dd5c..75ba323127 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -827,8 +827,8 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ entry = this._updatesNegList[i]; if (entry) { if(entry.priority >= minPriority){ - element.paused = true; - idsWithSelectors.push(element.target); + entry.paused = true; + idsWithSelectors.push(entry.target); } } } @@ -838,8 +838,8 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ for(i=0; i= minPriority){ - element.paused = true; - idsWithSelectors.push(element.target); + entry.paused = true; + idsWithSelectors.push(entry.target); } } } From 9748f03aa7781f4a45f7871efc9902b015112729 Mon Sep 17 00:00:00 2001 From: RackovychV Date: Mon, 6 Apr 2015 16:42:18 +0300 Subject: [PATCH 1490/1564] fix scheduler unscheduleAllWithMinPriority --- cocos2d/core/CCScheduler.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 75ba323127..95e3208d2f 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -734,27 +734,41 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ // Updates selectors var entry; + var temp_length = 0; if(minPriority < 0){ - for(i=0; i= minPriority){ this.unscheduleUpdate(entry.target); } } + + if (temp_length == this._updatesNegList.length) + { + i++; + } } } if(minPriority <= 0){ - for(i=0; i= minPriority) @@ -762,6 +776,11 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ this.unscheduleUpdate(entry.target); } } + + if (temp_length == this._updatesPosList.length) + { + i++; + } } }, From 5ba96c3f5e8a1d7df577ef3972b2577a3d836f65 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 7 Apr 2015 10:20:26 +0800 Subject: [PATCH 1491/1564] Issue: add test case and refactor spine skeleton --- extensions/spine/CCSkeletonAnimation.js | 2 +- extensions/spine/CCSkeletonCanvasRenderCmd.js | 59 ++++++++++++++----- extensions/spine/CCSkeletonWebGLRenderCmd.js | 28 ++++----- template/project.json | 4 +- template/src/myApp.js | 9 +++ template/src/resource.js | 3 + 6 files changed, 73 insertions(+), 32 deletions(-) diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index 0d1e392a34..ef844c83fe 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -161,7 +161,7 @@ sp._regionAttachment_updateSlotForCanvas = function(self, slot, points) { return; var vertices = {}; - self.computeVertices(slot.bone.x, slot.bone.y, slot.bone, vertices); + self.computeVertices(slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); var VERTEX = sp.VERTEX_INDEX; points.length = 0; points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1])); diff --git a/extensions/spine/CCSkeletonCanvasRenderCmd.js b/extensions/spine/CCSkeletonCanvasRenderCmd.js index ff31b3d0e9..5833881bc1 100644 --- a/extensions/spine/CCSkeletonCanvasRenderCmd.js +++ b/extensions/spine/CCSkeletonCanvasRenderCmd.js @@ -33,11 +33,29 @@ var proto = sp.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); proto.constructor = sp.Skeleton.CanvasRenderCmd; + proto._drawSkeleton = function(){ + + }; + proto.rendering = function (wrapper, scaleX, scaleY) { - var node = this._node, i, n, sprites = this._skeletonSprites, selSpriteCmd; + var node = this._node, i, n; wrapper = wrapper || cc._renderContext; - //draw skeleton sprite by it self + var locSkeleton = node._skeleton,color = node.getColor(); + locSkeleton.r = color.r / 255; + locSkeleton.g = color.g / 255; + locSkeleton.b = color.b / 255; + locSkeleton.a = this.getDisplayedOpacity() / 255; + if (node._premultipliedAlpha) { + locSkeleton.r *= locSkeleton.a; + locSkeleton.g *= locSkeleton.a; + locSkeleton.b *= locSkeleton.a; + } + + wrapper.setTransform(this._worldTransform, scaleX, scaleY); + wrapper.save(); + +/* //draw skeleton sprite by it self wrapper.save(); //set to armature mode (spine need same way to draw) wrapper._switchToArmatureMode(true, this._worldTransform, scaleX, scaleY); @@ -49,14 +67,24 @@ } } wrapper._switchToArmatureMode(false); + wrapper.restore();*/ + + //draw skeleton by itself. + var slot, attachment; + for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment) + continue; + + attachment = slot.attachment; + var regionTextureAtlas = node.getTextureAtlas(attachment); + } wrapper.restore(); if (!node._debugSlots && !node._debugBones) return; - wrapper.setTransform(this._worldTransform, scaleX, scaleY); - var locSkeleton = node._skeleton; - var attachment, slot, drawingUtil = cc._drawingUtil; + var drawingUtil = cc._drawingUtil; if (node._debugSlots) { // Slots. drawingUtil.setDrawColor(0, 0, 255, 255); @@ -124,8 +152,9 @@ proto._updateChild = function(){ var node = this._node; - var locSkeleton = node._skeleton; + var locSkeleton = node._skeleton, locSkeletonSprites = this._skeletonSprites; locSkeleton.updateWorldTransform(); + locSkeletonSprites.length = 0; var drawOrder = node._skeleton.drawOrder; for (var i = 0, n = drawOrder.length; i < n; i++) { var slot = drawOrder[i]; @@ -135,17 +164,19 @@ selSprite.setVisible(false); continue; } + var rendererObject = attachment.rendererObject; + var rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); if(!selSprite){ - var rendererObject = attachment.rendererObject; - var rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); var sprite = new cc.Sprite(); - sprite.initWithTexture(rendererObject.page._texture, rect, rendererObject.rotate, false); - sprite._rect.width = attachment.width; - sprite._rect.height = attachment.height; - sprite.setContentSize(attachment.width, attachment.height); - this._skeletonSprites.push(sprite); + locSkeletonSprites.push(sprite); selSprite = slot.currentSprite = sprite; - } + }else + locSkeletonSprites.push(selSprite); + selSprite.initWithTexture(rendererObject.page._texture, rect, rendererObject.rotate, false); + selSprite.setContentSize(attachment.width, attachment.height); + selSprite._rect.width = attachment.width; + selSprite._rect.height = attachment.height; + selSprite.setVisible(true); //update color and blendFunc selSprite.setBlendFunc(cc.BLEND_SRC, slot.data.additiveBlending ? cc.ONE : cc.BLEND_DST); diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index 83c6aa93da..91bbff1145 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -27,13 +27,14 @@ cc.Node.WebGLRenderCmd.call(this, renderableObject); this._needDraw = true; this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)); + this._tmpQuad = new cc.V3F_C4B_T2F_Quad(); }; var proto = sp.Skeleton.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = sp.Skeleton.WebGLRenderCmd; proto.rendering = function (ctx) { - var node = this._node; + var node = this._node, tmpQuad = this._tmpQuad; this._shaderProgram.use(); this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix); // cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst); @@ -48,11 +49,11 @@ locSkeleton.b *= locSkeleton.a; } - var additive, textureAtlas, attachment, slot, i, n, - quad = new cc.V3F_C4B_T2F_Quad(); + var additive, textureAtlas, attachment, slot, i, n; var locBlendFunc = node._blendFunc; - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + //for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { slot = locSkeleton.drawOrder[i]; if (!slot.attachment) continue; @@ -82,16 +83,16 @@ switch(slot.attachment.type) { case sp.ATTACHMENT_TYPE.REGION: - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + sp._regionAttachment_updateQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); break; case sp.ATTACHMENT_TYPE.MESH: - sp._meshAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + sp._meshAttachment_updateQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); break; case sp.ATTACHMENT_TYPE.SKINNED_MESH: break; } - textureAtlas.updateQuad(quad, quadCount); + textureAtlas.updateQuad(tmpQuad, quadCount); } if (textureAtlas) { @@ -104,7 +105,6 @@ //cc.kmGLPushMatrixWitMat4(this._stackMatrix); cc.current_stack.stack.push(cc.current_stack.top); cc.current_stack.top = this._stackMatrix; - var drawingUtil = cc._drawingUtil; if (node._debugSlots) { @@ -117,14 +117,13 @@ if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) continue; attachment = slot.attachment; - quad = new cc.V3F_C4B_T2F_Quad(); - sp._regionAttachment_updateQuad(attachment, slot, quad); + sp._regionAttachment_updateQuad(attachment, slot, tmpQuad); var points = []; - points.push(cc.p(quad.bl.vertices.x, quad.bl.vertices.y)); - points.push(cc.p(quad.br.vertices.x, quad.br.vertices.y)); - points.push(cc.p(quad.tr.vertices.x, quad.tr.vertices.y)); - points.push(cc.p(quad.tl.vertices.x, quad.tl.vertices.y)); + points.push(cc.p(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y)); + points.push(cc.p(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y)); + points.push(cc.p(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y)); + points.push(cc.p(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y)); drawingUtil.drawPoly(points, 4, true); } @@ -155,7 +154,6 @@ } } } - cc.kmGLPopMatrix(); } }; diff --git a/template/project.json b/template/project.json index a4a9435aab..2db719e811 100644 --- a/template/project.json +++ b/template/project.json @@ -4,10 +4,10 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 0, + "renderMode" : 1, "engineDir":"../", - "modules" : ["cocos2d"], + "modules" : ["cocos2d", "extensions"], "jsList" : [ "src/resource.js", diff --git a/template/src/myApp.js b/template/src/myApp.js index f91b7c40af..3794fac45e 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,6 +44,15 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); + + var spineBoy = new sp.SkeletonAnimation('skeleton.json', 'skeleton.atlas'); + spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150)); + this.addChild(spineBoy, 10); + spineBoy.setAnimation(0, 'attack1', true); + spineBoy.setTimeScale(0.1); + //spineBoy.setDebugBonesEnabled(true); + spineBoy.setDebugSlotsEnabled(true); + window.spineBoy = spineBoy; } }); diff --git a/template/src/resource.js b/template/src/resource.js index 94284083d1..377ed46234 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -6,6 +6,9 @@ var g_resources = [ //image s_HelloWorld, s_CloseNormal, + "skeleton-1.png", + "skeleton.atlas", + "skeleton.json", s_CloseSelected //plist From 5c95cdd96af3c673cd160b0702bf9c7ea60404ad Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 7 Apr 2015 10:42:00 +0800 Subject: [PATCH 1492/1564] Formatting (#2810) --- cocos2d/core/CCScheduler.js | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js index 95e3208d2f..688726099e 100644 --- a/cocos2d/core/CCScheduler.js +++ b/cocos2d/core/CCScheduler.js @@ -739,16 +739,10 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ for(i=0; i= minPriority){ - this.unscheduleUpdate(entry.target); - } - } - + if(entry && entry.priority >= minPriority) + this.unscheduleUpdate(entry.target); if (temp_length == this._updatesNegList.length) - { i++; - } } } @@ -756,31 +750,20 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{ for(i=0; i= minPriority) - { - this.unscheduleUpdate(entry.target); - } - } - + if(entry && entry.priority >= minPriority) + this.unscheduleUpdate(entry.target); if (temp_length == this._updatesPosList.length) - { i++; - } } }, From 5c112425e2461e24c7c14f3ee03865e343a8f075 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 7 Apr 2015 14:44:10 +0800 Subject: [PATCH 1493/1564] Fixed #2811: fixed a bug of cc.eventManager that its sorted order is incorrect when some nodes haven't add to scene graph or remove from parent without cleanup. --- cocos2d/core/event-manager/CCEventManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 84cabd26a4..46ba136659 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -311,8 +311,9 @@ cc.eventManager = /** @lends cc.eventManager# */{ }, _sortEventListenersOfSceneGraphPriorityDes : function(l1, l2){ - var locNodePriorityMap = cc.eventManager._nodePriorityMap; - if(!l1 || !l2 || !l1._getSceneGraphPriority() || !l2._getSceneGraphPriority()) + var locNodePriorityMap = cc.eventManager._nodePriorityMap, node1 = l1._getSceneGraphPriority(), + node2 = l2._getSceneGraphPriority(); + if(!l1 || !l2 || !node1 || !node2 || !locNodePriorityMap[node1.__instanceId] || !locNodePriorityMap[node2.__instanceId]) return -1; return locNodePriorityMap[l2._getSceneGraphPriority().__instanceId] - locNodePriorityMap[l1._getSceneGraphPriority().__instanceId]; }, From bab3a57a19ef00b3d8b9147b4bc147bdab6b8fb8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 7 Apr 2015 15:58:39 +0800 Subject: [PATCH 1494/1564] Add notes for CCSprite.js --- cocos2d/core/sprites/CCSprite.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 48acbb4fa6..a21206b5fe 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -558,7 +558,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // Init with a sprite frame name var frameName = fileName.substr(1, fileName.length - 1); var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); - this.initWithSpriteFrame(spriteFrame); + if(spriteFrame) + this.initWithSpriteFrame(spriteFrame); + else + cc.log("%s does not exist", fileName); } else { // Init with filename and rect cc.Sprite.prototype.init.call(this, fileName, rect); From a05860d55f995f5052bddf3f987dee32805332cd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 7 Apr 2015 16:03:43 +0800 Subject: [PATCH 1495/1564] Add notes for CCSprite.js --- cocos2d/core/sprites/CCSprite.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index a21206b5fe..810d7392a3 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -558,10 +558,10 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // Init with a sprite frame name var frameName = fileName.substr(1, fileName.length - 1); var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); - if(spriteFrame) - this.initWithSpriteFrame(spriteFrame); - else - cc.log("%s does not exist", fileName); + if (spriteFrame) + this.initWithSpriteFrame(spriteFrame); + else + cc.log("%s does not exist", fileName); } else { // Init with filename and rect cc.Sprite.prototype.init.call(this, fileName, rect); From bfaa8a1542a77ea1f69e8630fce9c3c1533f61fe Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Apr 2015 14:55:52 +0800 Subject: [PATCH 1496/1564] Fix a bug that is pause has stopped audio can be resume. --- cocos2d/audio/CCAudio.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index b55a04c309..4a8296e365 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -356,6 +356,8 @@ cc.Audio = cc.Class.extend({ }, pause: function(){ + if(this.getPlaying() === false) + return; this._playing = false; this._pause = true; if(this._AUDIO_TYPE === "AUDIO"){ From 6301dad4bc296a79765a3e8499f9b54f287f2720 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 8 Apr 2015 17:28:41 +0800 Subject: [PATCH 1497/1564] Fixed a bug that is isObject error --- cocos2d/core/sprites/CCSprite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 810d7392a3..cf138f0633 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -566,7 +566,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ // Init with filename and rect cc.Sprite.prototype.init.call(this, fileName, rect); } - } else if (cc.isObject(fileName)) { + } else if (typeof fileName === "object") { if (fileName instanceof cc.Texture2D) { // Init with texture and rect this.initWithTexture(fileName, rect, rotated); From cf6c8111aae01ffff1c81c6c64c81ab43da01679 Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Wed, 8 Apr 2015 21:45:17 +0300 Subject: [PATCH 1498/1564] Add setStroke method. --- cocos2d/motion-streak/CCMotionStreak.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 13c66a0f28..3add251835 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -222,6 +222,14 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this.startingPositionInitialized = startingPositionInitialized; }, + /** + * Set stroke. + * @param {Number} stroke + */ + setStroke:function (stroke) { + this._stroke = stroke; + }, + /** * initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename or texture * @param {Number} fade time to fade From 4469edb558dd2a2d800006d8078c0a1211d3db62 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 9 Apr 2015 12:02:37 +0800 Subject: [PATCH 1499/1564] Issue #2806: refactor cc.SkeletonCanvasRenderCmd --- extensions/spine/CCSkeleton.js | 16 ++- extensions/spine/CCSkeletonAnimation.js | 112 ------------------ extensions/spine/CCSkeletonCanvasRenderCmd.js | 92 ++++++++++---- extensions/spine/CCSkeletonWebGLRenderCmd.js | 85 ++++++++++++- extensions/spine/Spine.js | 4 +- template/src/myApp.js | 2 +- template/src/resource.js | 2 +- 7 files changed, 167 insertions(+), 146 deletions(-) diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index a3c7b402b4..a0132b0f43 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -221,7 +221,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) continue; var attachment = slot.attachment; - sp._regionAttachment_computeWorldVertices(attachment, slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); + this._computeRegionAttachmentWorldVertices(attachment, slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); minX = Math.min(minX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); minY = Math.min(minY, vertices[VERTEX.Y1] * scaleY, vertices[VERTEX.Y4] * scaleY, vertices[VERTEX.Y2] * scaleY, vertices[VERTEX.Y3] * scaleY); maxX = Math.max(maxX, vertices[VERTEX.X1] * scaleX, vertices[VERTEX.X4] * scaleX, vertices[VERTEX.X2] * scaleX, vertices[VERTEX.X3] * scaleX); @@ -231,6 +231,20 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ return cc.rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY); }, + _computeRegionAttachmentWorldVertices : function(self, x, y, bone, vertices){ + var offset = self.offset, vertexIndex = sp.VERTEX_INDEX; + x += bone.worldX; + y += bone.worldY; + vertices[vertexIndex.X1] = offset[vertexIndex.X1] * bone.m00 + offset[vertexIndex.Y1] * bone.m01 + x; + vertices[vertexIndex.Y1] = offset[vertexIndex.X1] * bone.m10 + offset[vertexIndex.Y1] * bone.m11 + y; + vertices[vertexIndex.X2] = offset[vertexIndex.X2] * bone.m00 + offset[vertexIndex.Y2] * bone.m01 + x; + vertices[vertexIndex.Y2] = offset[vertexIndex.X2] * bone.m10 + offset[vertexIndex.Y2] * bone.m11 + y; + vertices[vertexIndex.X3] = offset[vertexIndex.X3] * bone.m00 + offset[vertexIndex.Y3] * bone.m01 + x; + vertices[vertexIndex.Y3] = offset[vertexIndex.X3] * bone.m10 + offset[vertexIndex.Y3] * bone.m11 + y; + vertices[vertexIndex.X4] = offset[vertexIndex.X4] * bone.m00 + offset[vertexIndex.Y4] * bone.m01 + x; + vertices[vertexIndex.Y4] = offset[vertexIndex.X4] * bone.m10 + offset[vertexIndex.Y4] * bone.m11 + y; + }, + /** * Computes the world SRT from the local SRT for each bone. */ diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index ef844c83fe..e60465ec30 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -58,118 +58,6 @@ sp._atlasLoader = { } }; -sp._regionAttachment_computeWorldVertices = function(self, x, y, bone, vertices){ - var offset = self.offset; - x += bone.worldX; - y += bone.worldY; - var vertexIndex = sp.VERTEX_INDEX; - vertices[vertexIndex.X1] = offset[vertexIndex.X1] * bone.m00 + offset[vertexIndex.Y1] * bone.m01 + x; - vertices[vertexIndex.Y1] = offset[vertexIndex.X1] * bone.m10 + offset[vertexIndex.Y1] * bone.m11 + y; - vertices[vertexIndex.X2] = offset[vertexIndex.X2] * bone.m00 + offset[vertexIndex.Y2] * bone.m01 + x; - vertices[vertexIndex.Y2] = offset[vertexIndex.X2] * bone.m10 + offset[vertexIndex.Y2] * bone.m11 + y; - vertices[vertexIndex.X3] = offset[vertexIndex.X3] * bone.m00 + offset[vertexIndex.Y3] * bone.m01 + x; - vertices[vertexIndex.Y3] = offset[vertexIndex.X3] * bone.m10 + offset[vertexIndex.Y3] * bone.m11 + y; - vertices[vertexIndex.X4] = offset[vertexIndex.X4] * bone.m00 + offset[vertexIndex.Y4] * bone.m01 + x; - vertices[vertexIndex.Y4] = offset[vertexIndex.X4] * bone.m10 + offset[vertexIndex.Y4] * bone.m11 + y; -}; - -/*cc._spCallback = function(state, trackIndex, type,event, loopCount){ - state.context.onAnimationStateEvent(trackIndex, type, event, loopCount); - };*/ - -sp._regionAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { - var vertices = {}; - self.computeVertices(slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); - var r = slot.bone.skeleton.r * slot.r * 255; - var g = slot.bone.skeleton.g * slot.g * 255; - var b = slot.bone.skeleton.b * slot.b * 255; - var normalizedAlpha = slot.bone.skeleton.a * slot.a; - - if (premultipliedAlpha) { - r *= normalizedAlpha; - g *= normalizedAlpha; - b *= normalizedAlpha; - } - var a = normalizedAlpha * 255; - - quad.bl.colors.r = quad.tl.colors.r = quad.tr.colors.r = quad.br.colors.r = r; - quad.bl.colors.g = quad.tl.colors.g = quad.tr.colors.g = quad.br.colors.g = g; - quad.bl.colors.b = quad.tl.colors.b = quad.tr.colors.b = quad.br.colors.b = b; - quad.bl.colors.a = quad.tl.colors.a = quad.tr.colors.a = quad.br.colors.a = a; - - var VERTEX = sp.VERTEX_INDEX; - quad.bl.vertices.x = vertices[VERTEX.X1]; - quad.bl.vertices.y = vertices[VERTEX.Y1]; - quad.tl.vertices.x = vertices[VERTEX.X2]; - quad.tl.vertices.y = vertices[VERTEX.Y2]; - quad.tr.vertices.x = vertices[VERTEX.X3]; - quad.tr.vertices.y = vertices[VERTEX.Y3]; - quad.br.vertices.x = vertices[VERTEX.X4]; - quad.br.vertices.y = vertices[VERTEX.Y4]; - - quad.bl.texCoords.u = self.uvs[VERTEX.X1]; - quad.bl.texCoords.v = self.uvs[VERTEX.Y1]; - quad.tl.texCoords.u = self.uvs[VERTEX.X2]; - quad.tl.texCoords.v = self.uvs[VERTEX.Y2]; - quad.tr.texCoords.u = self.uvs[VERTEX.X3]; - quad.tr.texCoords.v = self.uvs[VERTEX.Y3]; - quad.br.texCoords.u = self.uvs[VERTEX.X4]; - quad.br.texCoords.v = self.uvs[VERTEX.Y4]; -}; - -sp._meshAttachment_updateQuad = function(self, slot, quad, premultipliedAlpha) { - var vertices = {}; - self.computeWorldVertices(slot.bone.x, slot.bone.y, slot, vertices); - var r = slot.bone.skeleton.r * slot.r * 255; - var g = slot.bone.skeleton.g * slot.g * 255; - var b = slot.bone.skeleton.b * slot.b * 255; - var normalizedAlpha = slot.bone.skeleton.a * slot.a; - if (premultipliedAlpha) { - r *= normalizedAlpha; - g *= normalizedAlpha; - b *= normalizedAlpha; - } - var a = normalizedAlpha * 255; - - quad.bl.colors.r = quad.tl.colors.r = quad.tr.colors.r = quad.br.colors.r = r; - quad.bl.colors.g = quad.tl.colors.g = quad.tr.colors.g = quad.br.colors.g = g; - quad.bl.colors.b = quad.tl.colors.b = quad.tr.colors.b = quad.br.colors.b = b; - quad.bl.colors.a = quad.tl.colors.a = quad.tr.colors.a = quad.br.colors.a = a; - - var VERTEX = sp.VERTEX_INDEX; - quad.bl.vertices.x = vertices[VERTEX.X1]; - quad.bl.vertices.y = vertices[VERTEX.Y1]; - quad.tl.vertices.x = vertices[VERTEX.X2]; - quad.tl.vertices.y = vertices[VERTEX.Y2]; - quad.tr.vertices.x = vertices[VERTEX.X3]; - quad.tr.vertices.y = vertices[VERTEX.Y3]; - quad.br.vertices.x = vertices[VERTEX.X4]; - quad.br.vertices.y = vertices[VERTEX.Y4]; - - quad.bl.texCoords.u = self.uvs[VERTEX.X1]; - quad.bl.texCoords.v = self.uvs[VERTEX.Y1]; - quad.tl.texCoords.u = self.uvs[VERTEX.X2]; - quad.tl.texCoords.v = self.uvs[VERTEX.Y2]; - quad.tr.texCoords.u = self.uvs[VERTEX.X3]; - quad.tr.texCoords.v = self.uvs[VERTEX.Y3]; - quad.br.texCoords.u = self.uvs[VERTEX.X4]; - quad.br.texCoords.v = self.uvs[VERTEX.Y4]; -}; - -sp._regionAttachment_updateSlotForCanvas = function(self, slot, points) { - if(!points) - return; - - var vertices = {}; - self.computeVertices(slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); - var VERTEX = sp.VERTEX_INDEX; - points.length = 0; - points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1])); - points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4])); - points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3])); - points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2])); -}; - /** * The event type of spine skeleton animation. It contains event types: START(0), END(1), COMPLETE(2), EVENT(3). * @constant diff --git a/extensions/spine/CCSkeletonCanvasRenderCmd.js b/extensions/spine/CCSkeletonCanvasRenderCmd.js index 5833881bc1..b27ee8ae10 100644 --- a/extensions/spine/CCSkeletonCanvasRenderCmd.js +++ b/extensions/spine/CCSkeletonCanvasRenderCmd.js @@ -33,13 +33,10 @@ var proto = sp.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); proto.constructor = sp.Skeleton.CanvasRenderCmd; - proto._drawSkeleton = function(){ - - }; - proto.rendering = function (wrapper, scaleX, scaleY) { var node = this._node, i, n; wrapper = wrapper || cc._renderContext; + var context = wrapper.getContext(); var locSkeleton = node._skeleton,color = node.getColor(); locSkeleton.r = color.r / 255; @@ -52,16 +49,43 @@ locSkeleton.b *= locSkeleton.a; } - wrapper.setTransform(this._worldTransform, scaleX, scaleY); - wrapper.save(); + /*wrapper.setTransform(this._worldTransform, scaleX, scaleY); + context.save(); + //draw skeleton by itself. + var slot, attachment, selTexture, selBone, rendererObject; + for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { + slot = locSkeleton.drawOrder[i]; + if (!slot.attachment) + continue; -/* //draw skeleton sprite by it self - wrapper.save(); + attachment = slot.attachment; + rendererObject = attachment.rendererObject; + selTexture = rendererObject.page._texture; + if(!selTexture || !selTexture._textureLoaded || !slot.bone) + continue; + + selBone = slot.bone; + //context.transform(selBone.m00, selBone.m01, selBone.m10, selBone.m11, selBone.worldX, selBone.worldY); + context.translate(selBone.worldX, selBone.worldY); + context.scale(selBone.worldScaleX, selBone.worldScaleY); + console.log(selBone); + context.rotate(selBone.worldRotation); + context.drawImage(selTexture._htmlElementObj, + rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height, + //locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + 0, 0, rendererObject.width * scaleX, rendererObject.height * scaleY); + + } + context.restore();*/ + + //draw skeleton sprite by it self +/* wrapper.save(); //set to armature mode (spine need same way to draw) wrapper._switchToArmatureMode(true, this._worldTransform, scaleX, scaleY); - for(i = 0, n = sprites.length; i < n; i++){ + var sprites = this._skeletonSprites, slot, selSpriteCmd,attachment; + for (i = 0, n = sprites.length; i < n; i++) { selSpriteCmd = sprites[i]._renderCmd; - if(sprites[i]._visible && selSpriteCmd && selSpriteCmd.rendering){ + if (sprites[i]._visible && selSpriteCmd && selSpriteCmd.rendering) { selSpriteCmd.rendering(wrapper, scaleX, scaleY); selSpriteCmd._dirtyFlag = 0; } @@ -69,21 +93,20 @@ wrapper._switchToArmatureMode(false); wrapper.restore();*/ - //draw skeleton by itself. - var slot, attachment; - for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment) - continue; - - attachment = slot.attachment; - var regionTextureAtlas = node.getTextureAtlas(attachment); + //set to armature mode (spine need same way to draw) + var sprites = this._skeletonSprites, slot, selSpriteCmd,attachment; + for (i = 0, n = sprites.length; i < n; i++) { + selSpriteCmd = sprites[i]._renderCmd; + if (sprites[i]._visible && selSpriteCmd && selSpriteCmd.rendering) { + selSpriteCmd.transform(this, false); + selSpriteCmd.rendering(wrapper, scaleX, scaleY); + selSpriteCmd._dirtyFlag = 0; + } } - wrapper.restore(); if (!node._debugSlots && !node._debugBones) return; - + wrapper.setTransform(this._worldTransform, scaleX, scaleY); var drawingUtil = cc._drawingUtil; if (node._debugSlots) { // Slots. @@ -91,12 +114,14 @@ drawingUtil.setLineWidth(1); var points = []; - for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + var drawOrder = node._skeleton.drawOrder; + for (i = 0, n = drawOrder.length; i < n; i++) { + //for (i = 0, n = locSkeleton.slots.length; i < n; i++) { slot = locSkeleton.drawOrder[i]; if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) continue; attachment = slot.attachment; - sp._regionAttachment_updateSlotForCanvas(attachment, slot, points); + this._updateRegionAttachmentSlot(attachment, slot, points); drawingUtil.drawPoly(points, 4, true); } } @@ -129,6 +154,19 @@ } }; + proto._updateRegionAttachmentSlot = function(attachment, slot, points) { + if(!points) + return; + + var vertices = {}, VERTEX = sp.VERTEX_INDEX, bone = slot.bone; + attachment.computeVertices(bone.skeleton.x, bone.skeleton.y, bone, vertices); + points.length = 0; + points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1])); + points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4])); + points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3])); + points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2])); + }; + proto._createChildFormSkeletonData = function(){ var node = this._node; var locSkeleton = node._skeleton, rendererObject, rect; @@ -182,11 +220,13 @@ selSprite.setBlendFunc(cc.BLEND_SRC, slot.data.additiveBlending ? cc.ONE : cc.BLEND_DST); var bone = slot.bone; - selSprite.setPosition(bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01, - bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); + selSprite.setPosition(bone.worldX, bone.worldY); selSprite.setScale(bone.worldScaleX, bone.worldScaleY); - selSprite.setRotation(-(slot.bone.worldRotation + attachment.rotation)); + //selSprite.setRotation(-(slot.bone.worldRotation + attachment.rotation)); + selSprite.setRotation(-bone.worldRotation); selSprite.setOpacity(0 | (node._skeleton.a * slot.a * 255)); + selSprite.setFlippedX(bone.flipX); + selSprite.setFlippedY(bone.flipY); var r = 0 | (node._skeleton.r * slot.r * 255); var g = 0 | (node._skeleton.g * slot.g * 255); var b = 0 | (node._skeleton.b * slot.b * 255); diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index 91bbff1145..4aa0c4b93d 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -83,10 +83,10 @@ switch(slot.attachment.type) { case sp.ATTACHMENT_TYPE.REGION: - sp._regionAttachment_updateQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); + this._updateRegionAttachmentQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); break; case sp.ATTACHMENT_TYPE.MESH: - sp._meshAttachment_updateQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); + this._updateMeshAttachmentQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); break; case sp.ATTACHMENT_TYPE.SKINNED_MESH: break; @@ -117,7 +117,7 @@ if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) continue; attachment = slot.attachment; - sp._regionAttachment_updateQuad(attachment, slot, tmpQuad); + this._updateRegionAttachmentQuad(attachment, slot, tmpQuad); var points = []; points.push(cc.p(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y)); @@ -161,4 +161,83 @@ proto._createChildFormSkeletonData = function(){}; proto._updateChild = function(){}; + + proto._updateRegionAttachmentQuad = function(self, slot, quad, premultipliedAlpha) { + var vertices = {}; + self.computeVertices(slot.bone.skeleton.x, slot.bone.skeleton.y, slot.bone, vertices); + var r = slot.bone.skeleton.r * slot.r * 255; + var g = slot.bone.skeleton.g * slot.g * 255; + var b = slot.bone.skeleton.b * slot.b * 255; + var normalizedAlpha = slot.bone.skeleton.a * slot.a; + + if (premultipliedAlpha) { + r *= normalizedAlpha; + g *= normalizedAlpha; + b *= normalizedAlpha; + } + var a = normalizedAlpha * 255; + + quad.bl.colors.r = quad.tl.colors.r = quad.tr.colors.r = quad.br.colors.r = r; + quad.bl.colors.g = quad.tl.colors.g = quad.tr.colors.g = quad.br.colors.g = g; + quad.bl.colors.b = quad.tl.colors.b = quad.tr.colors.b = quad.br.colors.b = b; + quad.bl.colors.a = quad.tl.colors.a = quad.tr.colors.a = quad.br.colors.a = a; + + var VERTEX = sp.VERTEX_INDEX; + quad.bl.vertices.x = vertices[VERTEX.X1]; + quad.bl.vertices.y = vertices[VERTEX.Y1]; + quad.tl.vertices.x = vertices[VERTEX.X2]; + quad.tl.vertices.y = vertices[VERTEX.Y2]; + quad.tr.vertices.x = vertices[VERTEX.X3]; + quad.tr.vertices.y = vertices[VERTEX.Y3]; + quad.br.vertices.x = vertices[VERTEX.X4]; + quad.br.vertices.y = vertices[VERTEX.Y4]; + + quad.bl.texCoords.u = self.uvs[VERTEX.X1]; + quad.bl.texCoords.v = self.uvs[VERTEX.Y1]; + quad.tl.texCoords.u = self.uvs[VERTEX.X2]; + quad.tl.texCoords.v = self.uvs[VERTEX.Y2]; + quad.tr.texCoords.u = self.uvs[VERTEX.X3]; + quad.tr.texCoords.v = self.uvs[VERTEX.Y3]; + quad.br.texCoords.u = self.uvs[VERTEX.X4]; + quad.br.texCoords.v = self.uvs[VERTEX.Y4]; + }; + + proto._updateMeshAttachmentQuad = function(self, slot, quad, premultipliedAlpha) { + var vertices = {}; + self.computeWorldVertices(slot.bone.x, slot.bone.y, slot, vertices); + var r = slot.bone.skeleton.r * slot.r * 255; + var g = slot.bone.skeleton.g * slot.g * 255; + var b = slot.bone.skeleton.b * slot.b * 255; + var normalizedAlpha = slot.bone.skeleton.a * slot.a; + if (premultipliedAlpha) { + r *= normalizedAlpha; + g *= normalizedAlpha; + b *= normalizedAlpha; + } + var a = normalizedAlpha * 255; + + quad.bl.colors.r = quad.tl.colors.r = quad.tr.colors.r = quad.br.colors.r = r; + quad.bl.colors.g = quad.tl.colors.g = quad.tr.colors.g = quad.br.colors.g = g; + quad.bl.colors.b = quad.tl.colors.b = quad.tr.colors.b = quad.br.colors.b = b; + quad.bl.colors.a = quad.tl.colors.a = quad.tr.colors.a = quad.br.colors.a = a; + + var VERTEX = sp.VERTEX_INDEX; + quad.bl.vertices.x = vertices[VERTEX.X1]; + quad.bl.vertices.y = vertices[VERTEX.Y1]; + quad.tl.vertices.x = vertices[VERTEX.X2]; + quad.tl.vertices.y = vertices[VERTEX.Y2]; + quad.tr.vertices.x = vertices[VERTEX.X3]; + quad.tr.vertices.y = vertices[VERTEX.Y3]; + quad.br.vertices.x = vertices[VERTEX.X4]; + quad.br.vertices.y = vertices[VERTEX.Y4]; + + quad.bl.texCoords.u = self.uvs[VERTEX.X1]; + quad.bl.texCoords.v = self.uvs[VERTEX.Y1]; + quad.tl.texCoords.u = self.uvs[VERTEX.X2]; + quad.tl.texCoords.v = self.uvs[VERTEX.Y2]; + quad.tr.texCoords.u = self.uvs[VERTEX.X3]; + quad.tr.texCoords.v = self.uvs[VERTEX.Y3]; + quad.br.texCoords.u = self.uvs[VERTEX.X4]; + quad.br.texCoords.v = self.uvs[VERTEX.Y4]; + }; })(); \ No newline at end of file diff --git a/extensions/spine/Spine.js b/extensions/spine/Spine.js index e29bca57d0..7a25bab80e 100644 --- a/extensions/spine/Spine.js +++ b/extensions/spine/Spine.js @@ -887,7 +887,7 @@ spine.FlipXTimeline.prototype = { lastTime = -1; var frameIndex = (time >= frames[frames.length - 2] ? frames.length : spine.Animation.binarySearch(frames, time, 2)) - 2; if (frames[frameIndex] < lastTime) return; - skeleton.bones[boneIndex].flipX = frames[frameIndex + 1] != 0; + skeleton.bones[this.boneIndex].flipX = frames[frameIndex + 1] != 0; } }; @@ -915,7 +915,7 @@ spine.FlipYTimeline.prototype = { lastTime = -1; var frameIndex = (time >= frames[frames.length - 2] ? frames.length : spine.Animation.binarySearch(frames, time, 2)) - 2; if (frames[frameIndex] < lastTime) return; - skeleton.bones[boneIndex].flipY = frames[frameIndex + 1] != 0; + skeleton.bones[this.boneIndex].flipY = frames[frameIndex + 1] != 0; } }; diff --git a/template/src/myApp.js b/template/src/myApp.js index 3794fac45e..16ad0863c0 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -48,7 +48,7 @@ var MyLayer = cc.Layer.extend({ var spineBoy = new sp.SkeletonAnimation('skeleton.json', 'skeleton.atlas'); spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150)); this.addChild(spineBoy, 10); - spineBoy.setAnimation(0, 'attack1', true); + spineBoy.setAnimation(0, 'attack5', true); spineBoy.setTimeScale(0.1); //spineBoy.setDebugBonesEnabled(true); spineBoy.setDebugSlotsEnabled(true); diff --git a/template/src/resource.js b/template/src/resource.js index 377ed46234..f9016890a0 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -6,7 +6,7 @@ var g_resources = [ //image s_HelloWorld, s_CloseNormal, - "skeleton-1.png", + "skeleton.png", "skeleton.atlas", "skeleton.json", s_CloseSelected From cdb52adcd6c08ae52ff15ee82619d27f00eeaff3 Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 9 Apr 2015 15:27:28 +0800 Subject: [PATCH 1500/1564] add clone positionType --- cocos2d/particle/CCParticleSystem.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js index 1c3a310adf..7136f5335e 100644 --- a/cocos2d/particle/CCParticleSystem.js +++ b/cocos2d/particle/CCParticleSystem.js @@ -1938,6 +1938,8 @@ cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{ retParticle.setPosition(cc.p(this.x, this.y)); retParticle.setPosVar(cc.p(this.getPosVar().x,this.getPosVar().y)); + retParticle.setPositionType(this.getPositionType()); + // Spinning retParticle.setStartSpin(this.getStartSpin()||0); retParticle.setStartSpinVar(this.getStartSpinVar()||0); From 1e97cce80e4efa7b2a0fe5db87f315e13fc511ca Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 9 Apr 2015 15:42:55 +0800 Subject: [PATCH 1501/1564] Fix undefined parameter check in CCNode --- cocos2d/core/base-nodes/CCNode.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 8222e5c042..50af27bddc 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1304,7 +1304,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ */ removeFromParent: function (cleanup) { if (this._parent) { - if (cleanup == null) + if (cleanup === undefined) cleanup = true; this._parent.removeChild(this, cleanup); } @@ -1335,7 +1335,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ if (this._children.length === 0) return; - if (cleanup == null) + if (cleanup === undefined) cleanup = true; if (this._children.indexOf(child) > -1) this._detachChild(child, cleanup); @@ -1357,7 +1357,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ cc.log(cc._LogInfos.Node_removeChildByTag); var child = this.getChildByTag(tag); - if (child == null) + if (!child) cc.log(cc._LogInfos.Node_removeChildByTag_2, tag); else this.removeChild(child, cleanup); @@ -1381,7 +1381,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ // not using detachChild improves speed here var __children = this._children; if (__children !== null) { - if (cleanup == null) + if (cleanup === undefined) cleanup = true; for (var i = 0; i < __children.length; i++) { var node = __children[i]; @@ -1869,7 +1869,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ * spriteB.setAdditionalTransform(t); */ setAdditionalTransform: function (additionalTransform) { - if(additionalTransform == null) + if(additionalTransform === undefined) return this._additionalTransformDirty = false; this._additionalTransform = additionalTransform; this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty); @@ -2255,7 +2255,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ _getBoundingBoxToCurrentNode: function (parentTransform) { var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height); - var trans = (parentTransform == null) ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), parentTransform); + var trans = (parentTransform === undefined) ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), parentTransform); rect = cc.rectApplyAffineTransform(rect, trans); //query child's BoundingBox From 969f865d616765df76eb407fcf6db6fafb793fb5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Apr 2015 16:07:34 +0800 Subject: [PATCH 1502/1564] To prevent the object does not exist error --- extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js | 2 ++ extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js | 2 ++ extensions/ccui/layouts/UILayoutWebGLRenderCmd.js | 2 ++ extensions/cocostudio/armature/CCBone.js | 2 ++ 4 files changed, 8 insertions(+) diff --git a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js index bcac0b4834..0074027217 100644 --- a/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js @@ -23,6 +23,8 @@ ****************************************************************************/ (function(){ + if(!cc.Node.WebGLRenderCmd) + return; cc.ProtectedNode.WebGLRenderCmd = function (renderable) { cc.Node.WebGLRenderCmd.call(this, renderable); }; diff --git a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js index 8b8949d82f..dc0c477997 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js @@ -23,6 +23,8 @@ ****************************************************************************/ (function() { + if(!cc.Node.WebGLRenderCmd) + return; ccui.Scale9Sprite.WebGLRenderCmd = function (renderable) { cc.Node.WebGLRenderCmd.call(this, renderable); this._cachedParent = null; diff --git a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js index d46e1e8939..baf4773fca 100644 --- a/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +++ b/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js @@ -24,6 +24,8 @@ ****************************************************************************/ (function(){ + if(!ccui.ProtectedNode.WebGLRenderCmd) + return; ccui.Layout.WebGLRenderCmd = function(renderable){ ccui.ProtectedNode.WebGLRenderCmd.call(this, renderable); this._needDraw = false; diff --git a/extensions/cocostudio/armature/CCBone.js b/extensions/cocostudio/armature/CCBone.js index 071ea83170..32f12553f5 100644 --- a/extensions/cocostudio/armature/CCBone.js +++ b/extensions/cocostudio/armature/CCBone.js @@ -700,6 +700,8 @@ ccs.Bone.RenderCmd = { })(); (function(){ + if(!cc.Node.WebGLRenderCmd) + return; ccs.Bone.WebGLRenderCmd = function(renderable){ cc.Node.WebGLRenderCmd.call(this, renderable); this._needDraw = false; From 40588d0ab9a75609462ea5d04fab984a2524381a Mon Sep 17 00:00:00 2001 From: Igor Mats Date: Thu, 9 Apr 2015 12:03:52 +0300 Subject: [PATCH 1503/1564] Add getStroke method. --- cocos2d/motion-streak/CCMotionStreak.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos2d/motion-streak/CCMotionStreak.js b/cocos2d/motion-streak/CCMotionStreak.js index 3add251835..85b43531dd 100644 --- a/cocos2d/motion-streak/CCMotionStreak.js +++ b/cocos2d/motion-streak/CCMotionStreak.js @@ -222,6 +222,14 @@ cc.MotionStreak = cc.Node.extend(/** @lends cc.MotionStreak# */{ this.startingPositionInitialized = startingPositionInitialized; }, + /** + * Get stroke. + * @returns {Number} stroke + */ + getStroke:function () { + return this._stroke; + }, + /** * Set stroke. * @param {Number} stroke From e8064f514c8977a62f05bc4f2568aa58a34e94af Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 9 Apr 2015 17:28:39 +0800 Subject: [PATCH 1504/1564] Fixed a bug that adaptation value error of IOS --- cocos2d/core/platform/CCEGLView.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js index 7dce4366ac..01c58088ed 100644 --- a/cocos2d/core/platform/CCEGLView.js +++ b/cocos2d/core/platform/CCEGLView.js @@ -61,6 +61,9 @@ cc.__BrowserGetter = { if(window.navigator.userAgent.indexOf("OS 8_1_") > -1) //this mistake like MIUI, so use of MIUI treatment method cc.__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_MIUI; +if(cc.sys.os === cc.sys.OS_IOS) // All browsers are WebView + cc.__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_SAFARI; + switch(cc.__BrowserGetter.adaptationType){ case cc.sys.BROWSER_TYPE_SAFARI: cc.__BrowserGetter.meta["minimal-ui"] = "true"; From 010c8cffcec102393517331dc76e406841610c6e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 10 Apr 2015 18:22:37 +0800 Subject: [PATCH 1505/1564] Issue #1642: Fixed a bug that is setter is error of editBox --- extensions/editbox/CCdomNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/editbox/CCdomNode.js b/extensions/editbox/CCdomNode.js index c38ac03136..25085855eb 100644 --- a/extensions/editbox/CCdomNode.js +++ b/extensions/editbox/CCdomNode.js @@ -48,7 +48,7 @@ cc.DOM._addMethods = function (node) { cc.defineGetterSetter(node, "anchorY", node._getAnchorY, node._setAnchorY); cc.defineGetterSetter(node, "scale", node.getScale, node.setScale); cc.defineGetterSetter(node, "scaleX", node.getScaleX, node.setScaleX); - cc.defineGetterSetter(node, "scaleY", node.getScaleY, node.getScaleY); + cc.defineGetterSetter(node, "scaleY", node.getScaleY, node.setScaleY); cc.defineGetterSetter(node, "rotation", node.getRotation, node.setRotation); cc.defineGetterSetter(node, "skewX", node.getSkewX, node.setSkewX); cc.defineGetterSetter(node, "skewY", node.getSkewY, node.setSkewY); From 65e4177a65b1fe0c2c09b6c35145c06a310fe67a Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 13 Apr 2015 13:53:08 +0800 Subject: [PATCH 1506/1564] Arrangement the render mode --- CCBoot.js | 75 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index ac316ccd3c..75740d3825 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1563,13 +1563,6 @@ cc._initSys = function (config, CONFIG_KEY) { */ sys.isNative = false; - var browserSupportWebGL = [sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_SAFARI]; - var osSupportWebGL = [sys.OS_IOS, sys.OS_WINDOWS, sys.OS_OSX, sys.OS_LINUX]; - var multipleAudioWhiteList = [ - sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_BAIDU_APP, - sys.BROWSER_TYPE_SAFARI, sys.BROWSER_TYPE_UC, sys.BROWSER_TYPE_QQ, sys.BROWSER_TYPE_MOBILE_QQ, sys.BROWSER_TYPE_IE - ]; - var win = window, nav = win.navigator, doc = document, docEle = doc.documentElement; var ua = nav.userAgent.toLowerCase(); @@ -1642,21 +1635,51 @@ cc._initSys = function (config, CONFIG_KEY) { */ sys.os = osName; + var multipleAudioWhiteList = [ + sys.BROWSER_TYPE_BAIDU, sys.BROWSER_TYPE_OPERA, sys.BROWSER_TYPE_FIREFOX, sys.BROWSER_TYPE_CHROME, sys.BROWSER_TYPE_BAIDU_APP, + sys.BROWSER_TYPE_SAFARI, sys.BROWSER_TYPE_UC, sys.BROWSER_TYPE_QQ, sys.BROWSER_TYPE_MOBILE_QQ, sys.BROWSER_TYPE_IE + ]; + sys._supportMultipleAudio = multipleAudioWhiteList.indexOf(sys.browserType) > -1; //++++++++++++++++++something about cc._renderTYpe and cc._supportRender begin++++++++++++++++++++++++++++ - var userRenderMode = parseInt(config[CONFIG_KEY.renderMode]); - var renderType = cc._RENDER_TYPE_WEBGL; - var tempCanvas = cc.newElement("Canvas"); - cc._supportRender = true; - var notSupportGL = true; - if(iOS) - notSupportGL = !window.WebGLRenderingContext || osSupportWebGL.indexOf(sys.os) === -1; - else - notSupportGL = !window.WebGLRenderingContext || browserSupportWebGL.indexOf(sys.browserType) === -1 || osSupportWebGL.indexOf(sys.os) === -1; - if (userRenderMode === 1 || (userRenderMode === 0 && notSupportGL) || (location.origin === "file://")) - renderType = cc._RENDER_TYPE_CANVAS; + + (function(sys, config){ + var userRenderMode = config[CONFIG_KEY.renderMode] - 0; + if(isNaN(userRenderMode) || userRenderMode > 2 || userRenderMode < 0) + userRenderMode = 0; + var shieldOs = [sys.OS_ANDROID]; + var shieldBrowser = []; + var tmpCanvas = cc.newElement("canvas"); + cc._renderType = cc._RENDER_TYPE_CANVAS; + cc._supportRender = true; + + var supportWebGL = win.WebGLRenderingContext; + if(userRenderMode === 0){ + if(supportWebGL && shieldOs.indexOf(sys.os) === -1 && shieldBrowser.indexOf(sys.browserType)) + userRenderMode = 2; + else + userRenderMode = 1; + } + + if(userRenderMode === 2) + try{ + cc.create3DContext(tmpCanvas, {'stencil': true, 'preserveDrawingBuffer': true }); + cc._renderType = cc._RENDER_TYPE_WEBGL; + }catch(e){ + cc.log("Browsers doesn‘t support WebGL"); + userRenderMode = 1; + } + + if(userRenderMode === 1) + try { + tmpCanvas.getContext("2d"); + cc._renderType = cc._RENDER_TYPE_CANVAS; + } catch (e) { + cc._supportRender = false; + } + })(sys, config); sys._canUseCanvasNewBlendModes = function(){ var canvas = document.createElement('canvas'); @@ -1682,22 +1705,6 @@ cc._initSys = function (config, CONFIG_KEY) { //Whether or not the Canvas BlendModes are supported. sys._supportCanvasNewBlendModes = sys._canUseCanvasNewBlendModes(); - if (renderType === cc._RENDER_TYPE_WEBGL) { - if (!win.WebGLRenderingContext - || !cc.create3DContext(tempCanvas, {'stencil': true, 'preserveDrawingBuffer': true })) { - if (userRenderMode === 0) renderType = cc._RENDER_TYPE_CANVAS; - else cc._supportRender = false; - } - } - - if (renderType === cc._RENDER_TYPE_CANVAS) { - try { - tempCanvas.getContext("2d"); - } catch (e) { - cc._supportRender = false; - } - } - cc._renderType = renderType; //++++++++++++++++++something about cc._renderType and cc._supportRender end++++++++++++++++++++++++++++++ // check if browser supports Web Audio From 997d2d7967c3e6b6309caa13f90d63800824fd87 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 13 Apr 2015 14:02:53 +0800 Subject: [PATCH 1507/1564] Arrangement the render mode --- CCBoot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCBoot.js b/CCBoot.js index 75740d3825..4e1d5fd438 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1657,7 +1657,7 @@ cc._initSys = function (config, CONFIG_KEY) { var supportWebGL = win.WebGLRenderingContext; if(userRenderMode === 0){ - if(supportWebGL && shieldOs.indexOf(sys.os) === -1 && shieldBrowser.indexOf(sys.browserType)) + if(supportWebGL && shieldOs.indexOf(sys.os) === -1 && shieldBrowser.indexOf(sys.browserType) === -1) userRenderMode = 2; else userRenderMode = 1; From ff63de504e7e1a7b54fdb599081b0be949187055 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 13 Apr 2015 14:20:21 +0800 Subject: [PATCH 1508/1564] Arrangement the render mode --- CCBoot.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 4e1d5fd438..ff7b5aed87 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1665,8 +1665,13 @@ cc._initSys = function (config, CONFIG_KEY) { if(userRenderMode === 2) try{ - cc.create3DContext(tmpCanvas, {'stencil': true, 'preserveDrawingBuffer': true }); - cc._renderType = cc._RENDER_TYPE_WEBGL; + var context = cc.create3DContext(tmpCanvas, {'stencil': true, 'preserveDrawingBuffer': true }); + if(context){ + cc._renderType = cc._RENDER_TYPE_WEBGL; + }else{ + cc.log("Browsers doesn‘t support WebGL"); + userRenderMode = 1; + } }catch(e){ cc.log("Browsers doesn‘t support WebGL"); userRenderMode = 1; From c967b3f0ed41245545e030e534597395a79b8e3e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 13 Apr 2015 14:48:29 +0800 Subject: [PATCH 1509/1564] Arrangement the render mode --- CCBoot.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index ff7b5aed87..0fc02c4b06 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1656,28 +1656,19 @@ cc._initSys = function (config, CONFIG_KEY) { cc._supportRender = true; var supportWebGL = win.WebGLRenderingContext; - if(userRenderMode === 0){ - if(supportWebGL && shieldOs.indexOf(sys.os) === -1 && shieldBrowser.indexOf(sys.browserType) === -1) - userRenderMode = 2; - else - userRenderMode = 1; - } - if(userRenderMode === 2) + if(userRenderMode === 2 || (userRenderMode === 0 && supportWebGL && shieldOs.indexOf(sys.os) === -1 && shieldBrowser.indexOf(sys.browserType) === -1)) try{ var context = cc.create3DContext(tmpCanvas, {'stencil': true, 'preserveDrawingBuffer': true }); - if(context){ + if(context) cc._renderType = cc._RENDER_TYPE_WEBGL; - }else{ - cc.log("Browsers doesn‘t support WebGL"); - userRenderMode = 1; - } + else + cc._supportRender = false; }catch(e){ - cc.log("Browsers doesn‘t support WebGL"); - userRenderMode = 1; + cc._supportRender = false; } - if(userRenderMode === 1) + if(userRenderMode === 1 || (userRenderMode === 0 && cc._supportRender === false)) try { tmpCanvas.getContext("2d"); cc._renderType = cc._RENDER_TYPE_CANVAS; From a2047b9c53cbcad57f04ab1c696d13424621c1a8 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 13 Apr 2015 15:06:08 +0800 Subject: [PATCH 1510/1564] Arrangement the render mode --- CCBoot.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index 0fc02c4b06..8c6b92c9fb 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1653,28 +1653,25 @@ cc._initSys = function (config, CONFIG_KEY) { var shieldBrowser = []; var tmpCanvas = cc.newElement("canvas"); cc._renderType = cc._RENDER_TYPE_CANVAS; - cc._supportRender = true; + cc._supportRender = false; var supportWebGL = win.WebGLRenderingContext; if(userRenderMode === 2 || (userRenderMode === 0 && supportWebGL && shieldOs.indexOf(sys.os) === -1 && shieldBrowser.indexOf(sys.browserType) === -1)) try{ var context = cc.create3DContext(tmpCanvas, {'stencil': true, 'preserveDrawingBuffer': true }); - if(context) + if(context){ cc._renderType = cc._RENDER_TYPE_WEBGL; - else - cc._supportRender = false; - }catch(e){ - cc._supportRender = false; - } + cc._supportRender = true; + } + }catch(e){} if(userRenderMode === 1 || (userRenderMode === 0 && cc._supportRender === false)) try { tmpCanvas.getContext("2d"); cc._renderType = cc._RENDER_TYPE_CANVAS; - } catch (e) { - cc._supportRender = false; - } + cc._supportRender = true; + } catch (e) {} })(sys, config); sys._canUseCanvasNewBlendModes = function(){ From 6da998a3593b3635eee1b73cd2eb3d4b3a27dad3 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 14 Apr 2015 10:36:26 +0800 Subject: [PATCH 1511/1564] Fixed #2806: fixed a bug of cc.SkeletonAnimation that its canvas renderCmd doesn't work --- extensions/spine/CCSkeleton.js | 4 +- extensions/spine/CCSkeletonAnimation.js | 1 + extensions/spine/CCSkeletonCanvasRenderCmd.js | 231 ++++++++---------- template/project.json | 2 +- template/src/myApp.js | 9 - template/src/resource.js | 3 - 6 files changed, 108 insertions(+), 142 deletions(-) diff --git a/extensions/spine/CCSkeleton.js b/extensions/spine/CCSkeleton.js index a0132b0f43..27e1ac1763 100644 --- a/extensions/spine/CCSkeleton.js +++ b/extensions/spine/CCSkeleton.js @@ -105,7 +105,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ */ init: function () { cc.Node.prototype.init.call(this); - this.setOpacityModifyRGB(true); + //this.setOpacityModifyRGB(true); this._blendFunc.src = cc.ONE; this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA; this.scheduleUpdate(); @@ -345,6 +345,7 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ this.setContentSize(skeletonData.width / cc.director.getContentScaleFactor(), skeletonData.height / cc.director.getContentScaleFactor()); this._skeleton = new spine.Skeleton(skeletonData); + this._skeleton.updateWorldTransform(); this._rootBone = this._skeleton.getRootBone(); this._ownsSkeletonData = ownsSkeletonData; @@ -390,7 +391,6 @@ sp.Skeleton = cc.Node.extend(/** @lends sp.Skeleton# */{ */ update: function (dt) { this._skeleton.update(dt); - this._renderCmd._updateChild(); } }); diff --git a/extensions/spine/CCSkeletonAnimation.js b/extensions/spine/CCSkeletonAnimation.js index e60465ec30..f351d83c80 100644 --- a/extensions/spine/CCSkeletonAnimation.js +++ b/extensions/spine/CCSkeletonAnimation.js @@ -222,6 +222,7 @@ sp.SkeletonAnimation = sp.Skeleton.extend(/** @lends sp.SkeletonAnimation# */{ this._state.update(dt); this._state.apply(this._skeleton); this._skeleton.updateWorldTransform(); + this._renderCmd._updateChild(); }, /** diff --git a/extensions/spine/CCSkeletonCanvasRenderCmd.js b/extensions/spine/CCSkeletonCanvasRenderCmd.js index b27ee8ae10..1b4f873cd1 100644 --- a/extensions/spine/CCSkeletonCanvasRenderCmd.js +++ b/extensions/spine/CCSkeletonCanvasRenderCmd.js @@ -26,97 +26,39 @@ sp.Skeleton.CanvasRenderCmd = function(renderableObject){ cc.Node.CanvasRenderCmd.call(this, renderableObject); this._needDraw = true; - - this._skeletonSprites = []; }; var proto = sp.Skeleton.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype); proto.constructor = sp.Skeleton.CanvasRenderCmd; proto.rendering = function (wrapper, scaleX, scaleY) { - var node = this._node, i, n; + var node = this._node, i, n, slot, slotNode; wrapper = wrapper || cc._renderContext; - var context = wrapper.getContext(); - - var locSkeleton = node._skeleton,color = node.getColor(); - locSkeleton.r = color.r / 255; - locSkeleton.g = color.g / 255; - locSkeleton.b = color.b / 255; - locSkeleton.a = this.getDisplayedOpacity() / 255; - if (node._premultipliedAlpha) { - locSkeleton.r *= locSkeleton.a; - locSkeleton.g *= locSkeleton.a; - locSkeleton.b *= locSkeleton.a; - } - - /*wrapper.setTransform(this._worldTransform, scaleX, scaleY); - context.save(); - //draw skeleton by itself. - var slot, attachment, selTexture, selBone, rendererObject; - for (i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { - slot = locSkeleton.drawOrder[i]; - if (!slot.attachment) - continue; - attachment = slot.attachment; - rendererObject = attachment.rendererObject; - selTexture = rendererObject.page._texture; - if(!selTexture || !selTexture._textureLoaded || !slot.bone) - continue; - - selBone = slot.bone; - //context.transform(selBone.m00, selBone.m01, selBone.m10, selBone.m11, selBone.worldX, selBone.worldY); - context.translate(selBone.worldX, selBone.worldY); - context.scale(selBone.worldScaleX, selBone.worldScaleY); - console.log(selBone); - context.rotate(selBone.worldRotation); - context.drawImage(selTexture._htmlElementObj, - rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height, - //locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); - 0, 0, rendererObject.width * scaleX, rendererObject.height * scaleY); - - } - context.restore();*/ - - //draw skeleton sprite by it self -/* wrapper.save(); - //set to armature mode (spine need same way to draw) - wrapper._switchToArmatureMode(true, this._worldTransform, scaleX, scaleY); - var sprites = this._skeletonSprites, slot, selSpriteCmd,attachment; - for (i = 0, n = sprites.length; i < n; i++) { - selSpriteCmd = sprites[i]._renderCmd; - if (sprites[i]._visible && selSpriteCmd && selSpriteCmd.rendering) { - selSpriteCmd.rendering(wrapper, scaleX, scaleY); - selSpriteCmd._dirtyFlag = 0; - } - } - wrapper._switchToArmatureMode(false); - wrapper.restore();*/ - - //set to armature mode (spine need same way to draw) - var sprites = this._skeletonSprites, slot, selSpriteCmd,attachment; - for (i = 0, n = sprites.length; i < n; i++) { - selSpriteCmd = sprites[i]._renderCmd; - if (sprites[i]._visible && selSpriteCmd && selSpriteCmd.rendering) { - selSpriteCmd.transform(this, false); - selSpriteCmd.rendering(wrapper, scaleX, scaleY); - selSpriteCmd._dirtyFlag = 0; + var locSkeleton = node._skeleton, drawOrder = locSkeleton.drawOrder; + for(i = 0, n = drawOrder.length; i < n; i++){ + slot = drawOrder[i]; + slotNode = slot._slotNode; + if(slotNode._visible && slotNode._renderCmd && slot.currentSprite){ + slotNode._renderCmd.transform(this, true); + slot.currentSprite._renderCmd.rendering(wrapper, scaleX, scaleY); + slotNode._renderCmd._dirtyFlag = slot.currentSprite._renderCmd._dirtyFlag = 0; } } if (!node._debugSlots && !node._debugBones) return; + wrapper.setTransform(this._worldTransform, scaleX, scaleY); - var drawingUtil = cc._drawingUtil; + wrapper.setGlobalAlpha(1); + var attachment, drawingUtil = cc._drawingUtil; if (node._debugSlots) { // Slots. drawingUtil.setDrawColor(0, 0, 255, 255); drawingUtil.setLineWidth(1); var points = []; - var drawOrder = node._skeleton.drawOrder; - for (i = 0, n = drawOrder.length; i < n; i++) { - //for (i = 0, n = locSkeleton.slots.length; i < n; i++) { + for (i = 0, n = locSkeleton.slots.length; i < n; i++) { slot = locSkeleton.drawOrder[i]; if (!slot.attachment || slot.attachment.type != sp.ATTACHMENT_TYPE.REGION) continue; @@ -169,68 +111,103 @@ proto._createChildFormSkeletonData = function(){ var node = this._node; - var locSkeleton = node._skeleton, rendererObject, rect; - for (var i = 0, n = locSkeleton.drawOrder.length; i < n; i++) { - var slot = locSkeleton.drawOrder[i]; - var attachment = slot.attachment; - if (!(attachment instanceof spine.RegionAttachment)) - continue; - rendererObject = attachment.rendererObject; - rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); - var sprite = new cc.Sprite(); - sprite.initWithTexture(rendererObject.page._texture, rect, rendererObject.rotate, false); - sprite._rect.width = attachment.width; - sprite._rect.height = attachment.height; - sprite.setContentSize(attachment.width, attachment.height); - sprite.setRotation(-(slot.bone.worldRotation + attachment.rotation)); - this._skeletonSprites.push(sprite); - slot.currentSprite = sprite; + var locSkeleton = node._skeleton, spriteName, sprite; + for (var i = 0, n = locSkeleton.slots.length; i < n; i++) { + var slot = locSkeleton.slots[i], attachment = slot.attachment; + var slotNode = new cc.Node(); + slot._slotNode = slotNode; + + if(attachment instanceof spine.RegionAttachment){ + spriteName = attachment.rendererObject.name; + sprite = this._createSprite(slot, attachment); + slot.currentSprite = sprite; + slot.currentSpriteName = spriteName; + slotNode.addChild(sprite); + } else if(attachment instanceof spine.MeshAttachment){ + //todo for mesh + } } }; + proto._createSprite = function(slot, attachment){ + var rendererObject = attachment.rendererObject; + var texture = rendererObject.page._texture; + var rect = new cc.Rect(rendererObject.x, rendererObject.y, rendererObject.width, rendererObject.height); + var sprite = new cc.Sprite(); + sprite.initWithTexture(rendererObject.page._texture, rect, rendererObject.rotate, false); + sprite._rect.width = attachment.width; + sprite._rect.height = attachment.height; + sprite.setContentSize(attachment.width, attachment.height); + sprite.setRotation(-attachment.rotation); + sprite.setScale(rendererObject.width / rendererObject.originalWidth * attachment.scaleX, + rendererObject.height / rendererObject.originalHeight * attachment.scaleY); + + slot.sprites = slot.sprites || {}; + slot.sprites[rendererObject.name] = sprite; + + return sprite; + }; + proto._updateChild = function(){ - var node = this._node; - var locSkeleton = node._skeleton, locSkeletonSprites = this._skeletonSprites; - locSkeleton.updateWorldTransform(); - locSkeletonSprites.length = 0; - var drawOrder = node._skeleton.drawOrder; - for (var i = 0, n = drawOrder.length; i < n; i++) { - var slot = drawOrder[i]; - var attachment = slot.attachment, selSprite = slot.currentSprite; - if (!(attachment instanceof spine.RegionAttachment)) { - if(selSprite) - selSprite.setVisible(false); + var locSkeleton = this._node._skeleton, slots = locSkeleton.slots; + var i, n, selSprite; + + var slot, attachment, slotNode; + for(i = 0, n = slots.length; i < n; i++){ + slot = slots[i]; + attachment = slot.attachment; + slotNode = slot._slotNode; + if(!attachment){ + slotNode.setVisible(false); + continue; + } + var type = attachment.type; + if (type === spine.AttachmentType.region){ + if(attachment.rendererObject){ + if(!slot.currentSpriteName || slot.currentSpriteName !== attachment.name){ + var spriteName = attachment.rendererObject.name; + if(slot.currentSprite !== undefined) + slot.currentSprite.setVisible(false); + slot.sprites = slot.sprites ||{}; + if(slot.sprites[spriteName] !== undefined) + slot.sprites[spriteName].setVisible(true); + else{ + var sprite = this._createSprite(slot, attachment); + slotNode.addChild(sprite); + } + slot.currentSprite = slot.sprites[spriteName]; + slot.currentSpriteName = spriteName; + } + } + var bone = slot.bone; + slotNode.setPosition(bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01, + bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11); + slotNode.setScale(bone.worldScaleX, bone.worldScaleY); + + //set the color and opacity + selSprite = slot.currentSprite; + selSprite._flippedX = bone.worldFlipX; + selSprite._flippedY = bone.worldFlipY; + if(selSprite._flippedY || selSprite._flippedX){ + slotNode.setRotation(bone.worldRotation); + selSprite.setRotation(attachment.rotation); + }else{ + slotNode.setRotation(-bone.worldRotation); + selSprite.setRotation(-attachment.rotation); + } + + //hack for sprite + selSprite._renderCmd._displayedOpacity = 0 | (locSkeleton.a * slot.a * 255); + var r = 0 | (locSkeleton.r * slot.r * 255), g = 0 | (locSkeleton.g * slot.g * 255), b = 0 | (locSkeleton.b * slot.b * 255); + selSprite.setColor(cc.color(r,g,b)); + selSprite._renderCmd._updateColor(); + } else if (type === spine.AttachmentType.skinnedmesh) { + //todo for mesh + } else { + slotNode.setVisible(false); continue; } - var rendererObject = attachment.rendererObject; - var rect = cc.rect(rendererObject.x, rendererObject.y, rendererObject.width,rendererObject.height); - if(!selSprite){ - var sprite = new cc.Sprite(); - locSkeletonSprites.push(sprite); - selSprite = slot.currentSprite = sprite; - }else - locSkeletonSprites.push(selSprite); - selSprite.initWithTexture(rendererObject.page._texture, rect, rendererObject.rotate, false); - selSprite.setContentSize(attachment.width, attachment.height); - selSprite._rect.width = attachment.width; - selSprite._rect.height = attachment.height; - - selSprite.setVisible(true); - //update color and blendFunc - selSprite.setBlendFunc(cc.BLEND_SRC, slot.data.additiveBlending ? cc.ONE : cc.BLEND_DST); - - var bone = slot.bone; - selSprite.setPosition(bone.worldX, bone.worldY); - selSprite.setScale(bone.worldScaleX, bone.worldScaleY); - //selSprite.setRotation(-(slot.bone.worldRotation + attachment.rotation)); - selSprite.setRotation(-bone.worldRotation); - selSprite.setOpacity(0 | (node._skeleton.a * slot.a * 255)); - selSprite.setFlippedX(bone.flipX); - selSprite.setFlippedY(bone.flipY); - var r = 0 | (node._skeleton.r * slot.r * 255); - var g = 0 | (node._skeleton.g * slot.g * 255); - var b = 0 | (node._skeleton.b * slot.b * 255); - selSprite.setColor(cc.color(r,g,b)); + slotNode.setVisible(true); } }; })(); \ No newline at end of file diff --git a/template/project.json b/template/project.json index 2db719e811..29de061423 100644 --- a/template/project.json +++ b/template/project.json @@ -4,7 +4,7 @@ "showFPS" : true, "frameRate" : 60, "id" : "gameCanvas", - "renderMode" : 1, + "renderMode" : 0, "engineDir":"../", "modules" : ["cocos2d", "extensions"], diff --git a/template/src/myApp.js b/template/src/myApp.js index 16ad0863c0..f91b7c40af 100644 --- a/template/src/myApp.js +++ b/template/src/myApp.js @@ -44,15 +44,6 @@ var MyLayer = cc.Layer.extend({ this.sprite.setPosition(size.width / 2, size.height / 2); this.sprite.setScale(size.height / this.sprite.getContentSize().height); this.addChild(this.sprite, 0); - - var spineBoy = new sp.SkeletonAnimation('skeleton.json', 'skeleton.atlas'); - spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150)); - this.addChild(spineBoy, 10); - spineBoy.setAnimation(0, 'attack5', true); - spineBoy.setTimeScale(0.1); - //spineBoy.setDebugBonesEnabled(true); - spineBoy.setDebugSlotsEnabled(true); - window.spineBoy = spineBoy; } }); diff --git a/template/src/resource.js b/template/src/resource.js index f9016890a0..94284083d1 100644 --- a/template/src/resource.js +++ b/template/src/resource.js @@ -6,9 +6,6 @@ var g_resources = [ //image s_HelloWorld, s_CloseNormal, - "skeleton.png", - "skeleton.atlas", - "skeleton.json", s_CloseSelected //plist From 801bcb4cf3309e81e39940f40f2b5bcc72c4088a Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Tue, 14 Apr 2015 10:43:53 +0800 Subject: [PATCH 1512/1564] Fixed #2806: remove the test codes. --- template/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/project.json b/template/project.json index 29de061423..a4a9435aab 100644 --- a/template/project.json +++ b/template/project.json @@ -7,7 +7,7 @@ "renderMode" : 0, "engineDir":"../", - "modules" : ["cocos2d", "extensions"], + "modules" : ["cocos2d"], "jsList" : [ "src/resource.js", From 8e5df94fb15ce8491c8e44cc3a924576dcffeb22 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 14 Apr 2015 18:10:36 +0800 Subject: [PATCH 1513/1564] The width of the labelBMFont parsing error --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 89350c2cba..542fb9b5eb 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -1020,6 +1020,7 @@ cc.log("%s need to be pre loaded", path); widget.setFntFile(path); }); + widget.ignoreContentAdaptWithSize(true); return widget; }; From 494672b1c424e8f9124b64fadf82fac04b1df3ac Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 14 Apr 2015 18:21:23 +0800 Subject: [PATCH 1514/1564] Update -x timeline and parser --- extensions/cocostudio/action/CCActionFrame.js | 16 +- .../cocostudio/loader/parsers/action-2.x.js | 35 ++- .../loader/parsers/timelineParser-2.x.js | 51 +++- .../cocostudio/timeline/ActionTimeline.js | 28 +++ extensions/cocostudio/timeline/Frame.js | 232 ++++++++++++++++-- 5 files changed, 321 insertions(+), 41 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 04c1dfa450..755cbbd578 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -99,9 +99,9 @@ ccs.FrameEaseType = { Circ_EaseOut : 20, Circ_EaseInOut : 21, - Elastic_EaesIn : 22, - Elastic_EaesOut : 23, - Elastic_EaesInOut : 24, + Elastic_EaseIn : 22, + Elastic_EaseOut : 23, + Elastic_EaseInOut : 24, Back_EaseIn : 25, Back_EaseOut : 26, @@ -109,7 +109,9 @@ ccs.FrameEaseType = { Bounce_EaseIn : 28, Bounce_EaseOut : 29, - Bounce_EaseInOut : 30 + Bounce_EaseInOut : 30, + + TWEEN_EASING_MAX: 1000 }; @@ -227,13 +229,13 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ case ccs.FrameEaseType.Circ_EaseInOut: resultAction = action.easing(cc.easeCircleActionInOut()); break; - case ccs.FrameEaseType.Elastic_EaesIn: + case ccs.FrameEaseType.Elastic_EaseIn: resultAction = action.easing(cc.easeElasticIn()); break; - case ccs.FrameEaseType.Elastic_EaesOut: + case ccs.FrameEaseType.Elastic_EaseOut: resultAction = action.easing(cc.easeElasticOut()); break; - case ccs.FrameEaseType.Elastic_EaesInOut: + case ccs.FrameEaseType.Elastic_EaseInOut: resultAction = action.easing(cc.easeElasticInOut()); break; case ccs.FrameEaseType.Back_EaseIn: diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index d7ff403256..58d5801c5c 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -65,14 +65,14 @@ deferred: function(json, resourcePath, action, file){ var animationlist = json["Content"]["Content"]["AnimationList"]; var length = animationlist ? animationlist.length : 0; - for (var i = 0; i < length; i++) { - var animationdata = animationlist[i]; - var info = { name: null, startIndex: null, endIndex: null }; - info.name = animationdata["Name"]; - info.startIndex = animationdata["StartIndex"]; - info.endIndex = animationdata["EndIndex"]; - action.addAnimationInfo(info); - } + for (var i = 0; i < length; i++){ + var animationdata = animationlist[i]; + var info = { name: null, startIndex: null, endIndex: null }; + info.name = animationdata["Name"]; + info.startIndex = animationdata["StartIndex"]; + info.endIndex = animationdata["EndIndex"]; + action.addAnimationInfo(info); + } } }); @@ -220,7 +220,7 @@ }, { name: "ActionValue", - handle: function(options){ + handle: function (options) { var frame = new ccs.InnerActionFrame(); var innerActionType = options["InnerActionType"]; @@ -229,6 +229,10 @@ var singleFrameIndex = options["SingleFrameIndex"]; + var frameIndex = options["FrameIndex"]; + if(frameIndex !== undefined) + frame.setFrameIndex(frameIndex); + frame.setInnerActionType(ccs.InnerActionType[innerActionType]); frame.setSingleFrameIndex(singleFrameIndex); @@ -240,6 +244,15 @@ } ]; + var loadEasingDataWithFlatBuffers = function(frame, options){ + var type = options["Type"]; + frame.setTweenType(type); + var points = options["Points"]; + if(points){ + frame.setEasingParams(points); + } + }; + frameList.forEach(function(item){ parser.registerParser(item.name, function(options, resourcePath){ var timeline = new ccs.Timeline(); @@ -252,6 +265,10 @@ frame.setFrameIndex(frameData["FrameIndex"]); var tween = frameData["Tween"] != null ? frameData["Tween"] : true; frame.setTween(tween); + //https://github.com/cocos2d/cocos2d-x/pull/11388/files + var easingData = options["EasingData"]; + if(easingData) + loadEasingDataWithFlatBuffers(frame, easingData); timeline.addFrame(frame); }); } diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 542fb9b5eb..fe4bd63ef8 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -111,7 +111,13 @@ node.setTag(json["Tag"] || 0); - node.setUserObject(new ccs.ActionTimelineData(json["ActionTag"] || 0)); + var actionTag = json["ActionTag"] || 0; + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + node.setUserObject(extensionData); node.setCascadeColorEnabled(true); node.setCascadeOpacityEnabled(true); @@ -175,6 +181,16 @@ } }); + var blendData = json["BlendFunc"]; + if(json["BlendFunc"]) { + var blendFunc = cc.BlendFunc.ALPHA_PREMULTIPLIED; + if (blendData["Src"] !== undefined) + blendFunc.src = blendData["Src"]; + if (blendData["Dst"] !== undefined) + blendFunc.dst = blendData["Dst"]; + node.setBlendFunc(new cc.BlendFunc()); + } + if(json["FlipX"]) node.setFlippedX(true); if(json["FlipY"]) @@ -203,6 +219,16 @@ node = new cc.ParticleSystem(path); self.generalAttributes(node, json); !cc.sys.isNative && node.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); + + var blendData = json["BlendFunc"]; + if(json["BlendFunc"]){ + var blendFunc = cc.BlendFunc.ALPHA_PREMULTIPLIED; + if(blendData["Src"] !== undefined) + blendFunc.src = blendData["Src"]; + if(blendData["Dst"] !== undefined) + blendFunc.dst = blendData["Dst"]; + node.setBlendFunc(new cc.BlendFunc()); + } }); return node; }; @@ -227,7 +253,12 @@ var actionTag = json["ActionTag"] || 0; widget.setActionTag(actionTag); - widget.setUserObject(new ccs.ActionTimelineData(actionTag)); + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + widget.setUserObject(extensionData); var rotationSkewX = json["RotationSkewX"]; if (rotationSkewX) @@ -492,6 +523,16 @@ } widget.setTextVerticalAlignment(v_alignment); + if(json["OutlineEnabled"] && json["OutlineColor"]) + widget.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 0); + + if(json["ShadowEnabled"] && json["ShadowColor"]) + widget.enableShadow( + getColor(json["ShadowColor"]), + cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), + json["ShadowBlurRadius"] || 0 + ); + //todo check it var isCustomSize = json["IsCustomSize"]; if(isCustomSize != null) @@ -1157,6 +1198,9 @@ parser.generalAttributes(obj.node, json); if(obj.action && obj.node){ obj.action.tag = obj.node.tag; + var InnerActionSpeed = json["InnerActionSpeed"]; + if(InnerActionSpeed !== undefined) + obj.action.setTimeSpeed(InnerActionSpeed); obj.node.runAction(obj.action); obj.action.gotoFrameAndPause(0); } @@ -1245,7 +1289,8 @@ var r = json["R"] != null ? json["R"] : 255; var g = json["G"] != null ? json["G"] : 255; var b = json["B"] != null ? json["B"] : 255; - return cc.color(r, g, b); + var a = json["A"] != null ? json["A"] : 255; + return cc.color(r, g, b, a); }; var setContentSize = function(node, size){ diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index 0bada129ee..9109c60ea7 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -60,6 +60,34 @@ ccs.ActionTimelineData = ccs.Class.extend({ }); +ccs.ObjectExtensionData = ccs.Class.extend({ + + _customProperty: null, + _timelineData: null, + + ctor: function(){ + this._init(); + }, + + _init: function(){ + this._timelineData = new ccs.ActionTimelineData(0); + return true; + }, + + setActionTag: function(actionTag){ + this._timelineData.setActionTag(actionTag); + }, + + getActionTag: function(){ + return this._timelineData.getActionTag(); + } +}); + +ccs.ObjectExtensionData.create = function(){ + var ret = new ccs.ObjectExtensionData(); + return ret; +}; + /** * Create new ActionTimelineData. * diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index 460bbf86d2..b76f1e1328 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -33,12 +33,15 @@ ccs.Frame = ccs.Class.extend({ _tween: null, _timeline: null, _node: null, + _tweenType: null, + _easingParam: null, ctor: function(){ this._frameIndex = 0; this._tween = true; this._timeline = null; this._node = null; + this._easingParam = []; }, _emitEvent: function(){ @@ -50,6 +53,8 @@ ccs.Frame = ccs.Class.extend({ _cloneProperty: function(frame){ this._frameIndex = frame.getFrameIndex(); this._tween = frame.isTween(); + this._tweenType = frame.getTweenType(); + this.setEasingParams(frame.getEasingParams()); }, /** @@ -131,6 +136,15 @@ ccs.Frame = ccs.Class.extend({ * @param {number} percent */ apply: function(percent){ + if(!this._tween) + return; + if(this._tweenType !== ccs.FrameEaseType.TWEEN_EASING_MAX && this._tweenType !== ccs.FrameEaseType.Linear) + percent = this.tweenPercent(percent); + this._onApply(percent); + }, + + _onApply: function(percent){ + }, /** @@ -140,6 +154,140 @@ ccs.Frame = ccs.Class.extend({ * @return {ccs.Frame} */ clone: function(){ // = 0 + }, + + tweenPercent: function(percent){ + return this._tweenTo(percent, this._tweenType, this._easingParam); + }, + + setEasingParams: function(easingParams){ + if(easingParams){ + this._easingParam.length = 0; + for(var i=0; i Date: Tue, 14 Apr 2015 18:26:54 +0800 Subject: [PATCH 1515/1564] Update -x timeline and parser --- .../cocostudio/loader/parsers/action-2.x.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 58d5801c5c..8e27788733 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -65,14 +65,14 @@ deferred: function(json, resourcePath, action, file){ var animationlist = json["Content"]["Content"]["AnimationList"]; var length = animationlist ? animationlist.length : 0; - for (var i = 0; i < length; i++){ - var animationdata = animationlist[i]; - var info = { name: null, startIndex: null, endIndex: null }; - info.name = animationdata["Name"]; - info.startIndex = animationdata["StartIndex"]; - info.endIndex = animationdata["EndIndex"]; - action.addAnimationInfo(info); - } + for (var i = 0; i < length; i++){ + var animationdata = animationlist[i]; + var info = { name: null, startIndex: null, endIndex: null }; + info.name = animationdata["Name"]; + info.startIndex = animationdata["StartIndex"]; + info.endIndex = animationdata["EndIndex"]; + action.addAnimationInfo(info); + } } }); From b9217d8e858fb3a0dc1bac9b36005cd277f14329 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 15 Apr 2015 11:23:05 +0800 Subject: [PATCH 1516/1564] Add enumerateChildren for cc.Node --- cocos2d/core/base-nodes/CCNode.js | 87 +++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 50af27bddc..ac7fbc5740 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2426,6 +2426,93 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return new cc.Node.CanvasRenderCmd(this); else return new cc.Node.WebGLRenderCmd(this); + }, + + enumerateChildren: function(name, callback){ + cc.assert(name.length != 0, "Invalid name"); + cc.assert(name.length != null, "Invalid callback function"); + + var length = name.length; + var subStrStartPos = 0; + var subStrlength = length; + + // Starts with '//'? + var searchRecursively = false; + if(length > 2 && name[0] === "/" && name[1] === "/"){ + searchRecursively = true; + subStrStartPos = 2; + subStrlength -= 2; + } + + var searchFromParent = false; + if(length > 3 && name[length-3] === "/" && name[length-2] === "." && name[length-1] === "."){ + searchFromParent = true; + subStrlength -= 3; + } + + var newName = name.substr(subStrStartPos, subStrlength); + + if(searchFromParent) + newName = "[[:alnum:]]+/" + newName; + + if(searchRecursively) + this.doEnumerateRecursive(this, newName, callback); + else + this.doEnumerate(newName, callback); + }, + + doEnumerateRecursive: function(node, name, callback){ + var ret = false; + if(node.doEnumerate(name,callback)){ + ret = true; + }else{ + var child, + children = node.getChildren(), + length = children.length; + // search its children + for (var i=0; i Date: Wed, 15 Apr 2015 14:58:17 +0800 Subject: [PATCH 1517/1564] Add enumerateChildren for cc.Node --- cocos2d/core/base-nodes/CCNode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index ac7fbc5740..0f6969ca1b 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2429,8 +2429,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ }, enumerateChildren: function(name, callback){ - cc.assert(name.length != 0, "Invalid name"); - cc.assert(name.length != null, "Invalid callback function"); + cc.assert(name && name.length != 0, "Invalid name"); + cc.assert(callback != null, "Invalid callback function"); var length = name.length; var subStrStartPos = 0; From 690a06c79d0c3d3ba2d6d35cb600145e7127ba84 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 15 Apr 2015 14:59:21 +0800 Subject: [PATCH 1518/1564] Add notes --- cocos2d/core/base-nodes/CCNode.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 0f6969ca1b..e57c63e92f 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -2428,6 +2428,32 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ return new cc.Node.WebGLRenderCmd(this); }, + /** Search the children of the receiving node to perform processing for nodes which share a name. + * + * @param name The name to search for, supports c++11 regular expression. + * Search syntax options: + * `//`: Can only be placed at the begin of the search string. This indicates that it will search recursively. + * `..`: The search should move up to the node's parent. Can only be placed at the end of string. + * `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children. + * + * @code + * enumerateChildren("//MyName", ...): This searches the children recursively and matches any node with the name `MyName`. + * enumerateChildren("[[:alnum:]]+", ...): This search string matches every node of its children. + * enumerateChildren("A[[:digit:]]", ...): This searches the node's children and returns any child named `A0`, `A1`, ..., `A9`. + * enumerateChildren("Abby/Normal", ...): This searches the node's grandchildren and returns any node whose name is `Normal` + * and whose parent is named `Abby`. + * enumerateChildren("//Abby/Normal", ...): This searches recursively and returns any node whose name is `Normal` and whose + * parent is named `Abby`. + * @endcode + * + * @warning Only support alpha or number for name, and not support unicode. + * + * @param callback A callback function to execute on nodes that match the `name` parameter. The function takes the following arguments: + * `node` + * A node that matches the name + * And returns a boolean result. Your callback can return `true` to terminate the enumeration. + * + */ enumerateChildren: function(name, callback){ cc.assert(name && name.length != 0, "Invalid name"); cc.assert(callback != null, "Invalid callback function"); From 51af269ed9e2f152d4e932dbf38f585669c800b7 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 15 Apr 2015 15:21:44 +0800 Subject: [PATCH 1519/1564] Update -x timeline and parser --- extensions/cocostudio/loader/parsers/action-2.x.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index 8e27788733..dfe69dc51f 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -249,6 +249,9 @@ frame.setTweenType(type); var points = options["Points"]; if(points){ + points = points.map(function(p){ + return cc.p(p["X"], p["Y"]); + }); frame.setEasingParams(points); } }; @@ -266,7 +269,7 @@ var tween = frameData["Tween"] != null ? frameData["Tween"] : true; frame.setTween(tween); //https://github.com/cocos2d/cocos2d-x/pull/11388/files - var easingData = options["EasingData"]; + var easingData = frameData["EasingData"]; if(easingData) loadEasingDataWithFlatBuffers(frame, easingData); timeline.addFrame(frame); From 8d8c2004a203e547c8cbfe09b2c00b2b34092aa1 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 15 Apr 2015 15:38:16 +0800 Subject: [PATCH 1520/1564] Update -x timeline and parser --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- extensions/cocostudio/timeline/ActionTimeline.js | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index fe4bd63ef8..cae39cfa3d 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -188,7 +188,7 @@ blendFunc.src = blendData["Src"]; if (blendData["Dst"] !== undefined) blendFunc.dst = blendData["Dst"]; - node.setBlendFunc(new cc.BlendFunc()); + node.setBlendFunc(blendFunc); } if(json["FlipX"]) diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index 9109c60ea7..3712238878 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -66,10 +66,6 @@ ccs.ObjectExtensionData = ccs.Class.extend({ _timelineData: null, ctor: function(){ - this._init(); - }, - - _init: function(){ this._timelineData = new ccs.ActionTimelineData(0); return true; }, @@ -84,8 +80,7 @@ ccs.ObjectExtensionData = ccs.Class.extend({ }); ccs.ObjectExtensionData.create = function(){ - var ret = new ccs.ObjectExtensionData(); - return ret; + return new ccs.ObjectExtensionData(); }; /** From ed70bb073a97612b62656927160ec5300f7409c3 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 15 Apr 2015 16:53:08 +0800 Subject: [PATCH 1521/1564] Fix ccs.TweenType naming issue --- .../armature/animation/CCProcessBase.js | 2 +- .../cocostudio/armature/animation/CCTween.js | 10 +- .../cocostudio/armature/datas/CCDatas.js | 4 +- .../armature/utils/CCDataReaderHelper.js | 12 +- .../armature/utils/CCTweenFunction.js | 130 +++++++++--------- 5 files changed, 79 insertions(+), 79 deletions(-) diff --git a/extensions/cocostudio/armature/animation/CCProcessBase.js b/extensions/cocostudio/armature/animation/CCProcessBase.js index e98cb7fd94..a4707d3854 100644 --- a/extensions/cocostudio/armature/animation/CCProcessBase.js +++ b/extensions/cocostudio/armature/animation/CCProcessBase.js @@ -112,7 +112,7 @@ ccs.ProcessBase = ccs.Class.extend(/** @lends ccs.ProcessBase# */{ this._durationTween = 0; this._rawDuration = 0; this._loopType = ccs.ANIMATION_TYPE_LOOP_BACK; - this._tweenEasing = ccs.TweenType.linear; + this._tweenEasing = ccs.TweenType.LINEAR; this.animationInternal = 1 / 60; this._curFrameIndex = 0; this._durationTween = 0; diff --git a/extensions/cocostudio/armature/animation/CCTween.js b/extensions/cocostudio/armature/animation/CCTween.js index ce0da172cc..5706d1d595 100644 --- a/extensions/cocostudio/armature/animation/CCTween.js +++ b/extensions/cocostudio/armature/animation/CCTween.js @@ -49,7 +49,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ ctor:function (bone) { ccs.ProcessBase.prototype.ctor.call(this); - this._frameTweenEasing = ccs.TweenType.linear; + this._frameTweenEasing = ccs.TweenType.LINEAR; ccs.Tween.prototype.init.call(this, bone); }, @@ -109,7 +109,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ this.setBetween(nextKeyFrame, nextKeyFrame); else this.setBetween(this._tweenData, nextKeyFrame); - this._frameTweenEasing = ccs.TweenType.linear; + this._frameTweenEasing = ccs.TweenType.LINEAR; } else if (this._movementBoneData.frameList.length > 1) { this._durationTween = durationTween * this._movementBoneData.scale; @@ -219,7 +219,7 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ if (locLoopType > ccs.ANIMATION_TYPE_TO_LOOP_BACK) locCurrentPercent = this.updateFrameData(locCurrentPercent); - if (this._frameTweenEasing !== ccs.TweenType.tweenEasingMax) + if (this._frameTweenEasing !== ccs.TweenType.TWEEN_EASING_MAX) this.tweenNodeTo(locCurrentPercent); }, @@ -396,8 +396,8 @@ ccs.Tween = ccs.ProcessBase.extend(/** @lends ccs.Tween# */{ /* * if frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween. */ - var tweenType = (this._frameTweenEasing !== ccs.TweenType.linear) ? this._frameTweenEasing : this._tweenEasing; - if (tweenType !== ccs.TweenType.tweenEasingMax && tweenType !== ccs.TweenType.linear && !this._passLastFrame) { + var tweenType = (this._frameTweenEasing !== ccs.TweenType.LINEAR) ? this._frameTweenEasing : this._tweenEasing; + if (tweenType !== ccs.TweenType.TWEEN_EASING_MAX && tweenType !== ccs.TweenType.LINEAR && !this._passLastFrame) { currentPercent = ccs.TweenFunction.tweenTo(currentPercent, tweenType, this._from.easingParams); } return currentPercent; diff --git a/extensions/cocostudio/armature/datas/CCDatas.js b/extensions/cocostudio/armature/datas/CCDatas.js index bfab738d55..6aa958b36a 100644 --- a/extensions/cocostudio/armature/datas/CCDatas.js +++ b/extensions/cocostudio/armature/datas/CCDatas.js @@ -549,7 +549,7 @@ ccs.FrameData = ccs.BaseData.extend(/** @lends ccs.FrameData# */{ ctor:function () { ccs.BaseData.prototype.ctor.call(this); this.duration = 1; - this.tweenEasing = ccs.TweenType.linear; + this.tweenEasing = ccs.TweenType.LINEAR; this.easingParamNumber = 0; this.easingParams = []; this.displayIndex = 0; @@ -675,7 +675,7 @@ ccs.MovementData = function(){ * Which tween easing effect the movement use * TWEEN_EASING_MAX : use the value from MovementData get from flash design panel */ - this.tweenEasing = ccs.TweenType.linear; + this.tweenEasing = ccs.TweenType.LINEAR; this.movBoneDataDic = {}; }; diff --git a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js index cc3ffb62a3..e23fad1aa4 100644 --- a/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +++ b/extensions/cocostudio/armature/utils/CCDataReaderHelper.js @@ -559,9 +559,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if (easing) { if (easing != ccs.CONST_FL_NAN) { tweenEasing = easing == null ? 0 : parseFloat(easing); - movementData.tweenEasing = tweenEasing === 2 ? ccs.TweenType.sineEaseInOut : tweenEasing; + movementData.tweenEasing = tweenEasing === 2 ? ccs.TweenType.SINE_EASEINOUT : tweenEasing; } else - movementData.tweenEasing = ccs.TweenType.linear; + movementData.tweenEasing = ccs.TweenType.LINEAR; } var movBonesXml = movementXML.querySelectorAll(ccs.CONST_MOVEMENT + " > " + ccs.CONST_BONE); @@ -610,7 +610,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ movementData.scale = json[ccs.CONST_A_MOVEMENT_SCALE] == null ? 1 : json[ccs.CONST_A_MOVEMENT_SCALE]; } - movementData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] == null ? ccs.TweenType.linear : json[ccs.CONST_A_TWEEN_EASING]; + movementData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] == null ? ccs.TweenType.LINEAR : json[ccs.CONST_A_TWEEN_EASING]; var name = json[ccs.CONST_A_NAME]; if(name) movementData.name = name; @@ -898,9 +898,9 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ if(_easing != ccs.CONST_FL_NAN){ tweenEasing = frameXML.getAttribute(ccs.CONST_A_TWEEN_EASING); if( tweenEasing ) - frameData.tweenEasing = (tweenEasing === 2) ? ccs.TweenType.sineEaseInOut : tweenEasing; + frameData.tweenEasing = (tweenEasing === 2) ? ccs.TweenType.SINE_EASEINOUT : tweenEasing; } else - frameData.tweenEasing = ccs.TweenType.linear; + frameData.tweenEasing = ccs.TweenType.LINEAR; } if (parentFrameXml) { @@ -935,7 +935,7 @@ ccs.dataReaderHelper = /** @lends ccs.dataReaderHelper# */{ this.decodeNodeFromJson(frameData, json, dataInfo); - frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear; + frameData.tweenEasing = json[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.LINEAR; frameData.displayIndex = json[ccs.CONST_A_DISPLAY_INDEX]; var bd_src = json[ccs.CONST_A_BLEND_SRC] == null ? cc.BLEND_SRC : json[ccs.CONST_A_BLEND_SRC]; var bd_dst = json[ccs.CONST_A_BLEND_DST] == null ? cc.BLEND_DST : json[ccs.CONST_A_BLEND_DST]; diff --git a/extensions/cocostudio/armature/utils/CCTweenFunction.js b/extensions/cocostudio/armature/utils/CCTweenFunction.js index b6d62d482e..7ced7fad96 100644 --- a/extensions/cocostudio/armature/utils/CCTweenFunction.js +++ b/extensions/cocostudio/armature/utils/CCTweenFunction.js @@ -28,50 +28,50 @@ * @type Object */ ccs.TweenType = { - customEasing: -1, - linear: 0, + CUSTOM_EASING: -1, + LINEAR: 0, - sineEaseIn: 1, - sineEaseOut: 2, - sineEaseInOut: 3, + SINE_EASEIN: 1, + SINE_EASEOUT: 2, + SINE_EASEINOUT: 3, - quadEaseIn: 4, - quadEaseOut: 5, - quadEaseInOut: 6, + QUAD_EASEIN: 4, + QUAD_EASEOUT: 5, + QUAD_EASEINOUT: 6, - cubicEaseIn: 7, - cubicEaseOut: 8, - cubicEaseInOut: 9, + CUBIC_EASEIN: 7, + CUBIC_EASEOUT: 8, + CUBIC_EASEINOUT: 9, - quartEaseIn: 10, - quartEaseOut: 11, - quartEaseInOut: 12, + QUART_EASEIN: 10, + QUART_EASEOUT: 11, + QUART_EASEINOUT: 12, - quintEaseIn: 13, - quintEaseOut: 14, - quintEaseInOut: 15, + QUINT_EASEIN: 13, + QUINT_EASEOUT: 14, + QUINT_EASEINOUT: 15, - expoEaseIn: 16, - expoEaseOut: 17, - expoEaseInOut: 18, + EXPO_EASEIN: 16, + EXPO_EASEOUT: 17, + EXPO_EASEINOUT: 18, - circEaseIn: 19, - eircEaseOut: 20, - circEaseInOut: 21, + CIRC_EASEIN: 19, + CIRC_EASEOUT: 20, + CIRC_EASEINOUT: 21, - elasticEaseIn: 22, - elasticEaseOut: 23, - elasticEaseInOut: 24, + ELASTIC_EASEIN: 22, + ELASTIC_EASEOUT: 23, + ELASTIC_EASEINOUT: 24, - backEaseIn: 25, - backEaseOut: 26, - backEaseInOut: 27, + BACK_EASEIN: 25, + BACK_EASEOUT: 26, + BACK_EASEINOUT: 27, - bounceEaseIn: 28, - bounceEaseOut: 29, - bounceEaseInOut: 30, + BOUNCE_EASEIN: 28, + BOUNCE_EASEOUT: 29, + BOUNCE_EASEINOUT: 30, - tweenEasingMax: 10000 + TWEEN_EASING_MAX: 10000 }; ccs.TweenFunction = ccs.TweenFunction || ccs.Class.extend({}); @@ -84,97 +84,97 @@ ccs.TweenFunction.tweenTo = function (time, type, easingParam) { var delta = 0; switch (type) { - case ccs.TweenType.customEasing: + case ccs.TweenType.CUSTOM_EASING: delta = this.customEase(time, easingParam); break; - case ccs.TweenType.linear: + case ccs.TweenType.LINEAR: delta = this.linear(time); break; - case ccs.TweenType.sineEaseIn: + case ccs.TweenType.SINE_EASEIN: delta = this.sineEaseIn(time); break; - case ccs.TweenType.sineEaseOut: + case ccs.TweenType.SINE_EASEOUT: delta = this.sineEaseOut(time); break; - case ccs.TweenType.sineEaseInOut: + case ccs.TweenType.SINE_EASEINOUT: delta = this.sineEaseInOut(time); break; - case ccs.TweenType.quadEaseIn: + case ccs.TweenType.QUAD_EASEIN: delta = this.quadEaseIn(time); break; - case ccs.TweenType.quadEaseOut: + case ccs.TweenType.QUAD_EASEOUT: delta = this.quadEaseOut(time); break; - case ccs.TweenType.quadEaseInOut: + case ccs.TweenType.QUAD_EASEINOUT: delta = this.quadEaseInOut(time); break; - case ccs.TweenType.cubicEaseIn: + case ccs.TweenType.CUBIC_EASEIN: delta = this.cubicEaseIn(time); break; - case ccs.TweenType.cubicEaseOut: + case ccs.TweenType.CUBIC_EASEOUT: delta = this.cubicEaseOut(time); break; - case ccs.TweenType.cubicEaseInOut: + case ccs.TweenType.CUBIC_EASEINOUT: delta = this.cubicEaseInOut(time); break; - case ccs.TweenType.quartEaseIn: + case ccs.TweenType.QUART_EASEIN: delta = this.quartEaseIn(time); break; - case ccs.TweenType.quartEaseOut: + case ccs.TweenType.QUART_EASEOUT: delta = this.quartEaseOut(time); break; - case ccs.TweenType.quartEaseInOut: + case ccs.TweenType.QUART_EASEINOUT: delta = this.quartEaseInOut(time); break; - case ccs.TweenType.quintEaseIn: + case ccs.TweenType.QUINT_EASEIN: delta = this.quintEaseIn(time); break; - case ccs.TweenType.quintEaseOut: + case ccs.TweenType.QUINT_EASEOUT: delta = this.quintEaseOut(time); break; - case ccs.TweenType.quintEaseInOut: + case ccs.TweenType.QUINT_EASEINOUT: delta = this.quintEaseInOut(time); break; - case ccs.TweenType.expoEaseIn: + case ccs.TweenType.EXPO_EASEIN: delta = this.expoEaseIn(time); break; - case ccs.TweenType.expoEaseOut: + case ccs.TweenType.EXPO_EASEOUT: delta = this.expoEaseOut(time); break; - case ccs.TweenType.expoEaseInOut: + case ccs.TweenType.EXPO_EASEINOUT: delta = this.expoEaseInOut(time); break; - case ccs.TweenType.circEaseIn: + case ccs.TweenType.CIRC_EASEIN: delta = this.circEaseIn(time); break; - case ccs.TweenType.eircEaseOut: + case ccs.TweenType.CIRC_EASEOUT: delta = this.circEaseOut(time); break; - case ccs.TweenType.circEaseInOut: + case ccs.TweenType.CIRC_EASEINOUT: delta = this.circEaseInOut(time); break; - case ccs.TweenType.elasticEaseIn: + case ccs.TweenType.ELASTIC_EASEIN: var period = 0.3; if(null != easingParam && easingParam.length > 0){ period = easingParam[0]; } delta = this.elasticEaseIn(time, period); break; - case ccs.TweenType.elasticEaseOut: + case ccs.TweenType.ELASTIC_EASEOUT: var period = 0.3; if(null != easingParam && easingParam.length > 0){ period = easingParam[0]; } delta = this.elasticEaseOut(time, period); break; - case ccs.TweenType.elasticEaseInOut: + case ccs.TweenType.ELASTIC_EASEINOUT: var period = 0.3; if(null != easingParam && easingParam.length > 0){ period = easingParam[0]; @@ -182,23 +182,23 @@ ccs.TweenFunction.tweenTo = function (time, type, easingParam) { delta = this.elasticEaseInOut(time, period); break; - case ccs.TweenType.backEaseIn: + case ccs.TweenType.BACK_EASEIN: delta = this.backEaseIn(time); break; - case ccs.TweenType.backEaseOut: + case ccs.TweenType.BACK_EASEOUT: delta = this.backEaseOut(time); break; - case ccs.TweenType.backEaseInOut: + case ccs.TweenType.BACK_EASEINOUT: delta = this.backEaseInOut(time); break; - case ccs.TweenType.bounceEaseIn: + case ccs.TweenType.BOUNCE_EASEIN: delta = this.bounceEaseIn(time); break; - case ccs.TweenType.bounceEaseOut: + case ccs.TweenType.BOUNCE_EASEOUT: delta = this.bounceEaseOut(time); break; - case ccs.TweenType.bounceEaseInOut: + case ccs.TweenType.BOUNCE_EASEINOUT: delta = this.bounceEaseInOut(time); break; From f6a6e460a643e88223e10fe414844453f71783c0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 16 Apr 2015 11:57:08 +0800 Subject: [PATCH 1522/1564] Optimization of ccs.frame --- extensions/cocostudio/timeline/Frame.js | 166 +++++++++--------------- 1 file changed, 59 insertions(+), 107 deletions(-) diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index b76f1e1328..bcc155c22b 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -157,7 +157,11 @@ ccs.Frame = ccs.Class.extend({ }, tweenPercent: function(percent){ - return this._tweenTo(percent, this._tweenType, this._easingParam); + var func = ccs.Frame.tweenToMap[this._tweenType]; + if(func) + return func(percent, this._easingParam); + else + return percent; }, setEasingParams: function(easingParams){ @@ -182,115 +186,63 @@ ccs.Frame = ccs.Class.extend({ isEnterWhenPassed: function(){ return this._enterWhenPassed; - }, - - _tweenTo: function(time, type, easingParam){ - var period = 0.3; - switch (type) { - case ccs.FrameEaseType.Custom: - case ccs.FrameEaseType.Linear: - break; - case ccs.FrameEaseType.Sine_EaseIn: - time = cc._easeSineInObj.easing(time); - break; - case ccs.FrameEaseType.Sine_EaseOut: - time = cc._easeSineOutObj.easing(time); - break; - case ccs.FrameEaseType.Sine_EaseInOut: - time = cc._easeSineInOutObj.easing(time); - break; - case ccs.FrameEaseType.Quad_EaseIn: - time = cc._easeQuadraticActionIn.easing(time); - break; - case ccs.FrameEaseType.Quad_EaseOut: - time = cc._easeQuadraticActionOut.easing(time); - break; - case ccs.FrameEaseType.Quad_EaseInOut: - time = cc._easeQuadraticActionInOut.easing(time); - break; - case ccs.FrameEaseType.Cubic_EaseIn: - time = cc._easeCubicActionIn.easing(time); - break; - case ccs.FrameEaseType.Cubic_EaseOut: - time = cc._easeCubicActionOut.easing(time); - break; - case ccs.FrameEaseType.Cubic_EaseInOut: - time = cc._easeCubicActionInOut.easing(time); - break; - case ccs.FrameEaseType.Quart_EaseIn: - time = cc._easeQuarticActionIn.easing(time); - break; - case ccs.FrameEaseType.Quart_EaseOut: - time = cc._easeQuarticActionOut.easing(time); - break; - case ccs.FrameEaseType.Quart_EaseInOut: - time = cc._easeQuarticActionInOut.easing(time); - break; - case ccs.FrameEaseType.Quint_EaseIn: - time = cc._easeQuinticActionIn.easing(time); - break; - case ccs.FrameEaseType.Quint_EaseOut: - time = cc._easeQuinticActionOut.easing(time); - break; - case ccs.FrameEaseType.Quint_EaseInOut: - time = cc._easeQuinticActionInOut.easing(time); - break; - case ccs.FrameEaseType.Expo_EaseIn: - time = cc._easeExponentialInObj.easing(time); - break; - case ccs.FrameEaseType.Expo_EaseOut: - time = cc._easeExponentialOutObj.easing(time); - break; - case ccs.FrameEaseType.Expo_EaseInOut: - time = cc._easeExponentialInOutObj.easing(time); - break; - case ccs.FrameEaseType.Circ_EaseIn: - time = cc._easeCircleActionIn.easing(time); - break; - case ccs.FrameEaseType.Circ_EaseOut: - time = cc._easeCircleActionOut.easing(time); - break; - case ccs.FrameEaseType.Circ_EaseInOut: - time = cc._easeCircleActionInOut.easing(time); - break; - case ccs.FrameEaseType.Elastic_EaseIn: - if(easingParam) - period = easingParam[0]; - time = cc.easeElasticIn(period).easing(time); - break; - case ccs.FrameEaseType.Elastic_EaseOut: - if(easingParam) - period = easingParam[0]; - time = cc.easeElasticOut(period).easing(time); - break; - case ccs.FrameEaseType.Elastic_EaseInOut: - if(easingParam) - period = easingParam[0]; - time = cc.easeElasticInOut(period).easing(time); - break; - case ccs.FrameEaseType.Back_EaseIn: - time = cc._easeBackInObj.easing(time); - break; - case ccs.FrameEaseType.Back_EaseOut: - time = cc._easeBackOutObj.easing(time); - break; - case ccs.FrameEaseType.Back_EaseInOut: - time = cc._easeBackInOutObj.easing(time); - break; - case ccs.FrameEaseType.Bounce_EaseIn: - time = cc._easeBounceInObj.easing(time); - break; - case ccs.FrameEaseType.Bounce_EaseOut: - time = cc._easeBounceOutObj.easing(time); - break; - case ccs.FrameEaseType.Bounce_EaseInOut: - time = cc._easeBounceInOutObj.easing(time); - break; - } - return time; } }); +ccs.Frame.tweenToMap = { + 1: cc._easeSineInObj.easing,//Sine_EaseIn + 2: cc._easeSineOutObj.easing,//Sine_EaseOut + 3: cc._easeSineInOutObj.easing,//Sine_EaseInOut + + 4: cc._easeQuadraticActionIn.easing,//Quad_EaseIn + 5: cc._easeQuadraticActionOut.easing,//Quad_EaseOut + 6: cc._easeQuadraticActionInOut.easing,//Quad_EaseInOut + + 7: cc._easeCubicActionIn.easing, //Cubic_EaseIn + 8: cc._easeCubicActionOut.easing,//Cubic_EaseOut + 9: cc._easeCubicActionInOut.easing,//Cubic_EaseInOut + + 10: cc._easeCubicActionIn.easing,//Cubic_EaseIn + 11: cc._easeCubicActionOut.easing,//Cubic_EaseOut + 12: cc._easeCubicActionInOut.easing,//Cubic_EaseInOut + + 13: cc._easeQuinticActionIn.easing,//Quint_EaseIn + 14: cc._easeQuinticActionOut.easing,//Quint_EaseOut + 15: cc._easeQuinticActionInOut.easing,//Quint_EaseInOut + + 16: cc._easeExponentialInObj.easing,//Expo_EaseIn + 17: cc._easeExponentialOutObj.easing,//Expo_EaseOut + 18: cc._easeExponentialInOutObj.easing,//Expo_EaseInOut + + 19: cc._easeCircleActionIn.easing,//Circ_EaseIn + 20: cc._easeCircleActionOut.easing,//Circ_EaseOut + 21: cc._easeCircleActionInOut.easing,//Circ_EaseInOut + + 22: function(time, easingParam){ + var period = 0.3; + easingParam != null && ( period = easingParam[0] ); + return cc.easeElasticIn(period).easing(time); + },//Elastic_EaesIn + 23: function(time, easingParam){ + var period = 0.3; + easingParam != null && ( period = easingParam[0] ); + return cc.easeElasticOut(period).easing(time); + },//Elastic_EaesOut + 24: function(time, easingParam){ + var period = 0.3; + easingParam != null && ( period = easingParam[0] ); + return cc.easeElasticInOut(period).easing(time); + },//Elastic_EaesInOut + + 25: cc._easeBackInObj.easing, //Back_EaseIn + 26: cc._easeBackOutObj.easing, //Back_EaseOut + 27: cc._easeBackInOutObj.easing, //Back_EaseInOut + + 28: cc._easeBounceInObj.easing, //Bounce_EaseIn + 29: cc._easeBounceOutObj.easing, //Bounce_EaseOut + 30: cc._easeBounceInOutObj.easing //Bounce_EaseInOut +}; + /** * Visible frame * To control the display state From 110c2ca379bf79d10f750308f09d93f534e5e26e Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 17 Apr 2015 13:49:15 +0800 Subject: [PATCH 1523/1564] Fixed a bug about the spine draw the not supported mode --- extensions/spine/CCSkeletonWebGLRenderCmd.js | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index 83c6aa93da..5ca4b72113 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -57,6 +57,20 @@ if (!slot.attachment) continue; attachment = slot.attachment; + + switch(slot.attachment.type) { + case sp.ATTACHMENT_TYPE.REGION: + sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + break; + case sp.ATTACHMENT_TYPE.MESH: + sp._meshAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + break; + case sp.ATTACHMENT_TYPE.SKINNED_MESH: + break; + default: + continue; + } + var regionTextureAtlas = node.getTextureAtlas(attachment); if (slot.data.additiveBlending != additive) { @@ -80,17 +94,6 @@ return; } - switch(slot.attachment.type) { - case sp.ATTACHMENT_TYPE.REGION: - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); - break; - case sp.ATTACHMENT_TYPE.MESH: - sp._meshAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); - break; - case sp.ATTACHMENT_TYPE.SKINNED_MESH: - break; - } - textureAtlas.updateQuad(quad, quadCount); } From 8df2b8149029c33833404a694f95708bf3aa9e99 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 17 Apr 2015 14:19:23 +0800 Subject: [PATCH 1524/1564] Remove todo... --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index cae39cfa3d..aa03d488bc 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -533,7 +533,6 @@ json["ShadowBlurRadius"] || 0 ); - //todo check it var isCustomSize = json["IsCustomSize"]; if(isCustomSize != null) widget.ignoreContentAdaptWithSize(!isCustomSize); From a7a5677a11fdd793435ebdfa2753b543687ada37 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Apr 2015 15:13:35 +0800 Subject: [PATCH 1525/1564] Fixed a bug that is Particle BlendFunc error --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index aa03d488bc..c3e8ccc0f4 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -227,7 +227,7 @@ blendFunc.src = blendData["Src"]; if(blendData["Dst"] !== undefined) blendFunc.dst = blendData["Dst"]; - node.setBlendFunc(new cc.BlendFunc()); + node.setBlendFunc(blendFunc); } }); return node; From 714ccda1b074ae2abfbc1c1523a3e560dba53cb3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 20 Apr 2015 17:14:55 +0800 Subject: [PATCH 1526/1564] Synchronization - https://github.com/cocos2d/cocos2d-x/pull/11510 --- .../cocostudio/loader/parsers/timelineParser-2.x.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index c3e8ccc0f4..0c2664c57c 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -601,6 +601,17 @@ if(textColor != null) widget.setTitleColor(getColor(textColor)); + var label = widget.getTitleRenderer(); + if(label && json["ShadowEnabled"] && json["ShadowColor"]){ + label.enableShadow( + getColor(json["ShadowColor"]), + cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), + json["ShadowBlurRadius"] || 0 + ); + } + if(label && json["OutlineEnabled"] && json["OutlineColor"]) + label.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 0); + var displaystate = getParam(json["DisplayState"], true); widget.setBright(displaystate); widget.setEnabled(displaystate); From 52f7dd217af18a396ae8c1ce735115e4015a3b0b Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Apr 2015 11:48:55 +0800 Subject: [PATCH 1527/1564] To prevent an problem that is function does not exist --- .../cocostudio/loader/parsers/timelineParser-2.x.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 0c2664c57c..99a57fbc0a 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -523,10 +523,10 @@ } widget.setTextVerticalAlignment(v_alignment); - if(json["OutlineEnabled"] && json["OutlineColor"]) + if(json["OutlineEnabled"] && json["OutlineColor"] && widget.enableOutline) widget.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 0); - if(json["ShadowEnabled"] && json["ShadowColor"]) + if(json["ShadowEnabled"] && json["ShadowColor"] && widget.enableShadow) widget.enableShadow( getColor(json["ShadowColor"]), cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), @@ -602,14 +602,14 @@ widget.setTitleColor(getColor(textColor)); var label = widget.getTitleRenderer(); - if(label && json["ShadowEnabled"] && json["ShadowColor"]){ + if(label && json["ShadowEnabled"] && json["ShadowColor"] && label.enableShadow){ label.enableShadow( getColor(json["ShadowColor"]), cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), json["ShadowBlurRadius"] || 0 ); } - if(label && json["OutlineEnabled"] && json["OutlineColor"]) + if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableOutline) label.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 0); var displaystate = getParam(json["DisplayState"], true); From aafdb898ed3a3f4199f74cb3fac54b7046d46a91 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 21 Apr 2015 13:42:45 +0800 Subject: [PATCH 1528/1564] Fix ccs.displayFactory usage issue --- extensions/cocostudio/armature/display/CCDisplayManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/armature/display/CCDisplayManager.js b/extensions/cocostudio/armature/display/CCDisplayManager.js index 6be772a0cb..5ea12a0fe7 100644 --- a/extensions/cocostudio/armature/display/CCDisplayManager.js +++ b/extensions/cocostudio/armature/display/CCDisplayManager.js @@ -83,7 +83,7 @@ ccs.DisplayManager = ccs.Class.extend(/** @lends ccs.DisplayManager */{ } if(display instanceof ccs.DisplayData){ - cc.displayFactory.addDisplay(this._bone, decoDisplay, display); + ccs.displayFactory.addDisplay(this._bone, decoDisplay, display); //! if changed display index is current display index, then change current display to the new display if(index === this._displayIndex) { this._displayIndex = -1; From eb623926aad882db33589e2a0fa6575d2ea1dfac Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 21 Apr 2015 13:42:53 +0800 Subject: [PATCH 1529/1564] Update engine version --- cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index 4a6ba3834b..ead1460436 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.5"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.6 Beta"; /** *

    diff --git a/tools/build.xml b/tools/build.xml index 29c6abadb1..8c05c73ab9 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,8 +5,8 @@ classpath="./compiler/compiler.jar"/> - + debug="false" output="./../lib/cocos2d-js-v3.6-Beta-min.js"> + @@ -298,8 +298,8 @@ - + debug="false" output="./../lib/cocos2d-js-v3.6-Beta-core-min.js"> + From 5502c627269288c167daa160c23d244193ed6bf6 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Apr 2015 16:07:16 +0800 Subject: [PATCH 1530/1564] To fix a problem that is no preload scale9sprite display error --- extensions/ccui/base-classes/UIScale9Sprite.js | 14 ++++++++------ extensions/gui/control-extension/CCScale9Sprite.js | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/extensions/ccui/base-classes/UIScale9Sprite.js index f828457d2d..e9afd7b658 100644 --- a/extensions/ccui/base-classes/UIScale9Sprite.js +++ b/extensions/ccui/base-classes/UIScale9Sprite.js @@ -601,6 +601,14 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ var tmpTexture = batchNode.getTexture(); var locLoaded = tmpTexture.isLoaded(); this._textureLoaded = locLoaded; + + //this._capInsets = capInsets; + var locCapInsets = this._capInsets; + locCapInsets.x = capInsets.x; + locCapInsets.y = capInsets.y; + locCapInsets.width = capInsets.width; + locCapInsets.height = capInsets.height; + if(!locLoaded){ tmpTexture.addEventListener("load", function(sender){ this._positionsAreDirty = true; @@ -611,12 +619,6 @@ ccui.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprite# */{ var locScale9Image = this._scale9Image; locScale9Image.removeAllChildren(true); - //this._capInsets = capInsets; - var locCapInsets = this._capInsets; - locCapInsets.x = capInsets.x; - locCapInsets.y = capInsets.y; - locCapInsets.width = capInsets.width; - locCapInsets.height = capInsets.height; this._spriteFrameRotated = rotated; var selTexture = locScale9Image.getTexture(); diff --git a/extensions/gui/control-extension/CCScale9Sprite.js b/extensions/gui/control-extension/CCScale9Sprite.js index 917ccd0332..9e1fefa38a 100644 --- a/extensions/gui/control-extension/CCScale9Sprite.js +++ b/extensions/gui/control-extension/CCScale9Sprite.js @@ -596,6 +596,14 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var tmpTexture = batchNode.getTexture(); var locLoaded = tmpTexture.isLoaded(); this._textureLoaded = locLoaded; + + //this._capInsets = capInsets; + var locCapInsets = this._capInsets; + locCapInsets.x = capInsets.x; + locCapInsets.y = capInsets.y; + locCapInsets.width = capInsets.width; + locCapInsets.height = capInsets.height; + if(!locLoaded){ tmpTexture.addEventListener("load", function(sender){ this._positionsAreDirty = true; @@ -606,12 +614,6 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{ var locScale9Image = this._scale9Image; locScale9Image.removeAllChildren(true); - //this._capInsets = capInsets; - var locCapInsets = this._capInsets; - locCapInsets.x = capInsets.x; - locCapInsets.y = capInsets.y; - locCapInsets.width = capInsets.width; - locCapInsets.height = capInsets.height; this._spriteFrameRotated = rotated; var selTexture = locScale9Image.getTexture(); From b70ed3c78bf158ca9df0bb1f098ffd36a0277163 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Apr 2015 16:46:20 +0800 Subject: [PATCH 1531/1564] Change the default value --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 99a57fbc0a..fd1f20da33 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -610,7 +610,7 @@ ); } if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableOutline) - label.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 0); + label.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 1); var displaystate = getParam(json["DisplayState"], true); widget.setBright(displaystate); From bdbf527b540125bbc31ce11a4bf1e3a758e2b6fd Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Apr 2015 16:47:39 +0800 Subject: [PATCH 1532/1564] Change the default value --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index fd1f20da33..2bf55fba5c 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -610,7 +610,7 @@ ); } if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableOutline) - label.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 1); + label.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); var displaystate = getParam(json["DisplayState"], true); widget.setBright(displaystate); From 7bbe07126d1b3876a6798be9ef447d2bb4dbc7d4 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 21 Apr 2015 17:22:29 +0800 Subject: [PATCH 1533/1564] Change the default value --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 2bf55fba5c..9288442532 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -524,7 +524,7 @@ widget.setTextVerticalAlignment(v_alignment); if(json["OutlineEnabled"] && json["OutlineColor"] && widget.enableOutline) - widget.enableOutline(getColor(json["OutlineColor"]), json["OutlineSize"] || 0); + widget.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); if(json["ShadowEnabled"] && json["ShadowColor"] && widget.enableShadow) widget.enableShadow( From 770e08e344ca89048b5709e1eee25d0364034de4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 21 Apr 2015 18:11:48 +0800 Subject: [PATCH 1534/1564] Add cc.sys.isObjectValid --- CCBoot.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CCBoot.js b/CCBoot.js index 8c6b92c9fb..1be2d4ff3b 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -1780,6 +1780,21 @@ cc._initSys = function (config, CONFIG_KEY) { // N/A in cocos2d-html5 }; + /** + * Check whether an object is valid, + * In web engine, it will return true if the object exist + * In native engine, it will return true if the JS object and the correspond native object are both valid + * @memberof cc.sys + * @name isObjectValid + * @param {Object} obj + * @return {boolean} Validity of the object + * @function + */ + sys.isObjectValid = function (obj) { + if (obj) return true; + else return false; + }; + /** * Dump system informations * @memberof cc.sys From 6c4381369aa6726ac3b64f9e1c769bd558ccb6ba Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Wed, 22 Apr 2015 11:08:31 +0800 Subject: [PATCH 1535/1564] Fixed #2846: fixed a bug of ccs.ActionTimeline.setCurrentFrame. --- extensions/cocostudio/timeline/ActionTimeline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index 3712238878..a0500514c3 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -278,7 +278,7 @@ ccs.ActionTimeline = cc.Action.extend({ * Set current frame index, this will cause action plays to this frame. */ setCurrentFrame: function(frameIndex){ - if (frameIndex >= this._startFrame && frameIndex >= this._endFrame){ + if (frameIndex >= this._startFrame && frameIndex <= this._endFrame){ this._currentFrame = frameIndex; this._time = this._currentFrame * this._frameInternal; }else{ From c9357bfbc9f47276b9921320781ab144dee60bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E6=B0=B4?= Date: Wed, 22 Apr 2015 14:34:51 +0800 Subject: [PATCH 1536/1564] Fixed a bug of CCNode.setPosition --- cocos2d/core/base-nodes/CCNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index e57c63e92f..977d3f9339 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -656,7 +656,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ locPosition.x = newPosOrxValue.x; locPosition.y = newPosOrxValue.y; } else { - if(locPosition.x === newPosOrxValue.x && locPosition.y === yValue) + if(locPosition.x === newPosOrxValue && locPosition.y === yValue) return; locPosition.x = newPosOrxValue; locPosition.y = yValue; From 76a9c01dad1268df8880c644101a3227b89c6aec Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 22 Apr 2015 18:23:06 +0800 Subject: [PATCH 1537/1564] Fixed a bug that is spine merge error --- extensions/spine/CCSkeletonWebGLRenderCmd.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/extensions/spine/CCSkeletonWebGLRenderCmd.js b/extensions/spine/CCSkeletonWebGLRenderCmd.js index 726f5bd986..ca0f14b613 100644 --- a/extensions/spine/CCSkeletonWebGLRenderCmd.js +++ b/extensions/spine/CCSkeletonWebGLRenderCmd.js @@ -61,10 +61,10 @@ switch(slot.attachment.type) { case sp.ATTACHMENT_TYPE.REGION: - sp._regionAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + this._updateRegionAttachmentQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); break; case sp.ATTACHMENT_TYPE.MESH: - sp._meshAttachment_updateQuad(attachment, slot, quad, node._premultipliedAlpha); + this._updateMeshAttachmentQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); break; case sp.ATTACHMENT_TYPE.SKINNED_MESH: break; @@ -95,17 +95,6 @@ return; } - switch(slot.attachment.type) { - case sp.ATTACHMENT_TYPE.REGION: - this._updateRegionAttachmentQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); - break; - case sp.ATTACHMENT_TYPE.MESH: - this._updateMeshAttachmentQuad(attachment, slot, tmpQuad, node._premultipliedAlpha); - break; - case sp.ATTACHMENT_TYPE.SKINNED_MESH: - break; - } - textureAtlas.updateQuad(tmpQuad, quadCount); } From 9114dce74d88d82fc45f16b25b1ac68b14330365 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 22 Apr 2015 21:53:33 +0800 Subject: [PATCH 1538/1564] Updated docs --- AUTHORS.txt | 15 ++++++++++----- CHANGELOG.txt | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 933701bb3e..e61d18e5cb 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -12,11 +12,11 @@ Core Developers: Ricardo Quesada - Huabin LING (pandamicro) + Huabin LING (@pandamicro) - Sijie Wang + Sijie Wang (@VisualSJ) - Jialong Zhai + Jialong Zhai (@JoshuaAstray) Contributors: Name GithubID Main contribution @@ -86,8 +86,9 @@ Kang-Hao Lu(Opera/Oupeng) @kennyluck Optimize John Resig's inheritance patter Mark Henderson @MarkEHenderson Code review, LabelTTF and Scale9Sprite bug fix Jing Wang @06wj CCScheduler improvements - Js file loading image add - cc.RectApplyAffineTransform improvements + Js file loading image add + cc.RectApplyAffineTransform improvements + Fixed a bug of cc.Node.setPosition that parameter check is incorrect Ze Wang @WanderWang Fix crash when BrowserTypes match nothing from navigator.userAgent LabelTTF improvements @@ -222,6 +223,7 @@ Robert Rouhani @Robmaister cc.TMXMapInfo bug fix Igor Mats @IgorMats cc.Scale9Sprite bug fix Spine runtime update + Add getStroke and setStroke method to cc.MotionStreak Tim @duhaibo0404 ccs.csLoader bug fix @@ -251,6 +253,9 @@ Skliar Ihor @igogo5yo Add Bower support feijing566 @feijing566 cc.Audio bug fix +RackovychV @RackovychV Fixed a bug of `cc.Scheduler`'s `pauseAllTargetsWithMinPriority` + + Retired Core Developers: Shengxiang Chen (Nero Chan) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6f25c68923..ec7c62b829 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,41 @@ ChangeLog: +Cocos2d-JS v3.6 Beta @ April 22 2015 + +* Improved TMX transform to support RotationX and RotationY. +* Refactored Spine skeleton render command. +* Added checks to prevent issues when `cc.Node.WebGLRenderCmd` is not exist. +* Improved iOS browsers detection. +* Added getter setter function for `cc.MotionStreak`'s stroke property. +* Improved the detection of render mode. +* Upgraded Action Timeline and parser for the latest version of Cocos editor. +* Added `enumerateChildren` function for `cc.Node`. +* Make `cc.Scale9Sprite` support unpreloaded texture. +* Added `cc.sys.isObjectValid` to detect whether an object is still valid (in web and native engine). + +* Bug fixes: + 1. Fixed a bug that `cc.Scheduler`'s `scheduleOnce` runs multiply times. + 2. Fixed a bug of `cc.Scheduler`'s `pauseAllTargetsWithMinPriority`. + 3. Fixed a bug of `cc.eventManager` that its event listeners' order is incorrect when some nodes haven't been added to the scene graph or have been removed from parent without cleanup. + 4. Fixed a bug of `cc.LabelTTF` that `enableShadow` doesn't work. + 5. Fixed a bug of `cc.LabelTTF` that `setColor` doesn't set shadow color under Canvas render mode. + 6. Fixed a bug that stopped audios can be resume after invoking pause on them. + 7. Fixed a bug that `ccui.LoadingBar`'s texture renders incorrectly without preload. + 8. Fixed a bug that cocos builder's callback doesn't get invoked. + 9. Fixed a bug that TMX objects' position is incorrect when content scale factor is modified. + 10. Fixed a mistaken usage of `cc.isObject` in `cc.Sprite` implementation. + 11. Fixed a bug that position type haven't been copied in `cc.ParticleSystem`'s `clone` function. + 12. Fixed some undefined parameter check issues in `cc.Node`. + 13. Fixed a bug that setter for `scaleY` of `cc.EditBox` is incorrect. + 14. Fixed a bug of `cc.SkeletonAnimation` that its canvas render command doesn't work correctly. + 15. Fixed a parsing issue for the width of `cc.LabelBMFont`. + 16. Fixed `ccs.TweenType`'s constants naming issue. + 17. Fixed a bug that the spine skeleton may be rendered under the unsupported mode. + 18. Fixed a bug when setting `cc.ParticleSystem`'s blend function in the ActionTimeline parser. + 19. Added check to prevent issues that functions may not exist in the ActionTimeline parser. + 20. Fixed a typo of `ccs.displayFactory`. + 21. Fixed a bug of `cc.Node.setPosition` that parameter check is incorrect. + Cocos2d-JS v3.5 @ April 1 2015 * Upgraded Cocos Studio parser to support Cocos Studio v2.2. From 1f3f3b31a14593d338a315790843e5918c3eb497 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 23 Apr 2015 15:45:58 +0800 Subject: [PATCH 1539/1564] Fixed a bug that is Outline error(Text|Button) --- .../loader/parsers/timelineParser-2.x.js | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 9288442532..954b036d89 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -523,20 +523,6 @@ } widget.setTextVerticalAlignment(v_alignment); - if(json["OutlineEnabled"] && json["OutlineColor"] && widget.enableOutline) - widget.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); - - if(json["ShadowEnabled"] && json["ShadowColor"] && widget.enableShadow) - widget.enableShadow( - getColor(json["ShadowColor"]), - cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), - json["ShadowBlurRadius"] || 0 - ); - - var isCustomSize = json["IsCustomSize"]; - if(isCustomSize != null) - widget.ignoreContentAdaptWithSize(!isCustomSize); - var fontResource = json["FontResource"]; if(fontResource != null){ var path = fontResource["Path"]; @@ -552,6 +538,20 @@ } } + if(json["OutlineEnabled"] && json["OutlineColor"] && widget.enableOutline) + widget.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); + + if(json["ShadowEnabled"] && json["ShadowColor"] && widget.enableShadow) + widget.enableShadow( + getColor(json["ShadowColor"]), + cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), + json["ShadowBlurRadius"] || 0 + ); + + var isCustomSize = json["IsCustomSize"]; + if(isCustomSize != null) + widget.ignoreContentAdaptWithSize(!isCustomSize); + widget.setUnifySizeEnabled(false); if(widget.isIgnoreContentAdaptWithSize()) @@ -601,17 +601,6 @@ if(textColor != null) widget.setTitleColor(getColor(textColor)); - var label = widget.getTitleRenderer(); - if(label && json["ShadowEnabled"] && json["ShadowColor"] && label.enableShadow){ - label.enableShadow( - getColor(json["ShadowColor"]), - cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), - json["ShadowBlurRadius"] || 0 - ); - } - if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableOutline) - label.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); - var displaystate = getParam(json["DisplayState"], true); widget.setBright(displaystate); widget.setEnabled(displaystate); @@ -630,6 +619,18 @@ widget.setTitleFontName(fontName); } } + + var label = widget.getTitleRenderer(); + if(label && json["ShadowEnabled"] && json["ShadowColor"] && label.enableShadow){ + label.enableShadow( + getColor(json["ShadowColor"]), + cc.size(getParam(json["ShadowOffsetX"], 2), getParam(json["ShadowOffsetY"], -2)), + json["ShadowBlurRadius"] || 0 + ); + } + if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableOutline) + label.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); + this.widgetAttributes(widget, json); if(scale9Enabled) { From efdf1a6e897edfdbaefb2f59510ca6a027d88667 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 24 Apr 2015 13:39:48 +0800 Subject: [PATCH 1540/1564] Adding Gaf --- external/gaf/GAFBoot.js | 24 + external/gaf/GAFMacros.js | 33 ++ external/gaf/Library/GAFAsset.js | 429 ++++++++++++++ external/gaf/Library/GAFAssetPreload.js | 270 +++++++++ external/gaf/Library/GAFAtlasLoader.js | 50 ++ external/gaf/Library/GAFDataReader.js | 229 ++++++++ external/gaf/Library/GAFLoader.js | 75 +++ external/gaf/Library/GAFMask.js | 36 ++ external/gaf/Library/GAFMaskProto.js | 16 + external/gaf/Library/GAFObject.js | 426 ++++++++++++++ external/gaf/Library/GAFShaderManager.js | 63 ++ external/gaf/Library/GAFShaders.js | 58 ++ external/gaf/Library/GAFSprite.js | 100 ++++ .../gaf/Library/GAFSpriteCanvasRenderCmd.js | 233 ++++++++ external/gaf/Library/GAFSpriteProto.js | 36 ++ .../gaf/Library/GAFSpriteWebGLRenderCmd.js | 132 +++++ external/gaf/Library/GAFTags.js | 378 ++++++++++++ external/gaf/Library/GAFTextField.js | 6 + external/gaf/Library/GAFTimeLine.js | 547 ++++++++++++++++++ external/gaf/Library/GAFTimeLineProto.js | 32 + external/gaf/gaf_viewer.css | 42 ++ external/gaf/gaf_viewer.html | 21 + external/gaf/gaf_viewer.js | 219 +++++++ moduleConfig.json | 26 +- 24 files changed, 3480 insertions(+), 1 deletion(-) create mode 100644 external/gaf/GAFBoot.js create mode 100644 external/gaf/GAFMacros.js create mode 100644 external/gaf/Library/GAFAsset.js create mode 100644 external/gaf/Library/GAFAssetPreload.js create mode 100644 external/gaf/Library/GAFAtlasLoader.js create mode 100644 external/gaf/Library/GAFDataReader.js create mode 100644 external/gaf/Library/GAFLoader.js create mode 100644 external/gaf/Library/GAFMask.js create mode 100644 external/gaf/Library/GAFMaskProto.js create mode 100644 external/gaf/Library/GAFObject.js create mode 100644 external/gaf/Library/GAFShaderManager.js create mode 100644 external/gaf/Library/GAFShaders.js create mode 100644 external/gaf/Library/GAFSprite.js create mode 100644 external/gaf/Library/GAFSpriteCanvasRenderCmd.js create mode 100644 external/gaf/Library/GAFSpriteProto.js create mode 100644 external/gaf/Library/GAFSpriteWebGLRenderCmd.js create mode 100644 external/gaf/Library/GAFTags.js create mode 100644 external/gaf/Library/GAFTextField.js create mode 100644 external/gaf/Library/GAFTimeLine.js create mode 100644 external/gaf/Library/GAFTimeLineProto.js create mode 100644 external/gaf/gaf_viewer.css create mode 100644 external/gaf/gaf_viewer.html create mode 100644 external/gaf/gaf_viewer.js diff --git a/external/gaf/GAFBoot.js b/external/gaf/GAFBoot.js new file mode 100644 index 0000000000..0baccc7ecd --- /dev/null +++ b/external/gaf/GAFBoot.js @@ -0,0 +1,24 @@ +var gaf = gaf || {}; +gaf._tmp = gaf._tmp || {}; +gaf._initialized = false; + +gaf.CCGAFLoader = function() +{ + this.load = function(realUrl, url, item, cb) + { + if(!gaf._initialized) + { + gaf._setup(); + } + var loader = new gaf.Loader(); + loader.LoadFile(realUrl, function(data){cb(null, data)}); + }; +}; + +gaf._setup = function() +{ + gaf._setupShaders(); + gaf._initialized = true; +}; + +cc.loader.register('.gaf', new gaf.CCGAFLoader()); diff --git a/external/gaf/GAFMacros.js b/external/gaf/GAFMacros.js new file mode 100644 index 0000000000..ef34cc8f5d --- /dev/null +++ b/external/gaf/GAFMacros.js @@ -0,0 +1,33 @@ +var gaf = gaf || {}; + +gaf.COMPRESSION_NONE = 0x00474146; +gaf.COMPRESSION_ZIP = 0x00474143; + +gaf.IDNONE = 0xffffffff; +gaf.FIRST_FRAME_INDEX = 0; + +gaf.EFFECT_DROP_SHADOW = 0; +gaf.EFFECT_BLUR = 1; +gaf.EFFECT_GLOW = 2; +gaf.EFFECT_COLOR_MATRIX = 6; + +gaf.ACTION_STOP = 0; +gaf.ACTION_PLAY = 1; +gaf.ACTION_GO_TO_AND_STOP = 2; +gaf.ACTION_GO_TO_AND_PLAY = 3; +gaf.ACTION_DISPATCH_EVENT = 4; + +gaf.PI_FRAME = 0; +gaf.PI_EVENT_TYPE = 0; + +gaf.TYPE_TEXTURE = 0; +gaf.TYPE_TEXT_FIELD = 1; +gaf.TYPE_TIME_LINE = 2; + +gaf.UNIFORM_BLUR_TEXEL_OFFSET = "u_step"; +gaf.UNIFORM_GLOW_TEXEL_OFFSET = "u_step"; +gaf.UNIFORM_GLOW_COLOR = "u_glowColor"; +gaf.UNIFORM_ALPHA_TINT_MULT = "colorTransformMult"; +gaf.UNIFORM_ALPHA_TINT_OFFSET = "colorTransformOffsets"; +gaf.UNIFORM_ALPHA_COLOR_MATRIX_BODY = "colorMatrix"; +gaf.UNIFORM_ALPHA_COLOR_MATRIX_APPENDIX = "colorMatrix2"; diff --git a/external/gaf/Library/GAFAsset.js b/external/gaf/Library/GAFAsset.js new file mode 100644 index 0000000000..23804e61ff --- /dev/null +++ b/external/gaf/Library/GAFAsset.js @@ -0,0 +1,429 @@ +var gaf = gaf || {}; + +gaf.Asset = cc.Class.extend +({ + _className: "GAFAsset", + + // Private members + _header: null, + _timeLines: null, + _textFields: null, + _protos: null, + _objects: null, + _masks: null, + + _rootTimeLine: null, + _textureLoadDelegate: null, + _sceneFps: 60, + _sceneWidth: 0, + _sceneHeight: 0, + _sceneColor: 0, + _gafData: null, + _desiredAtlasScale: 1, + _usedAtlasScale: 0, + + _atlases: null, + _onLoadTasks: null, + _atlasScales: null, + _textureLoaded: false, // For async loading with cc.event manager + _atlasesToLoad: null, // Atlases that are not yet loaded + _gafName: null, + + /** + * @method initWithGAFFile + * @param {String} filePath - path to .gaf file + * @param {String function(String)} textureLoadDelegate - is used to change atlas path, e.g. to load `atlas.tga` instead of `atlas.png` + * @return {bool} + */ + initWithGAFFile: function (filePath, textureLoadDelegate) { + var self = this; + this._textureLoadDelegate = textureLoadDelegate; + this._gafName = filePath; + var gafData = cc.loader.getRes(filePath); + if(!gafData) + { + cc.loader.load(filePath, function(err, data){ + if(!err) + { + self._init(data[0]); + } + }); + } + else { + return this._init(gafData); + } + return false; + }, + + /** + * @method initWithGAFBundle + * @param {String} zipFilePath - path to the archive with .gaf and its textures + * @param {String} entryFile - name of the .gaf file in archive + * @param {function({path:String})} delegate - is used to change atlas path, e.g. to load `atlas.tga` instead of `atlas.png` + * @return {bool} + */ + initWithGAFBundle: function (zipFilePath, entryFile, delegate) + { + cc.assert(false, "initWithGAFBundle is not yet implemented"); + return false; + }, + + /** + * @method setRootTimelineWithName + * @param {String} name + */ + setRootTimelineWithName: function (name) + { + for(var i = 0, end = this._timeLines.length; i < end; ++i) + { + var object = this._timeLines[i]; + if (object && object.getLinkageName() === name) + { + this._setRootTimeline(object); + return; + } + } + }, + +/* addEventListener: function(name, listener) + {},*/ + + isAssetVersionPlayable: function () + { + return true; + }, + + /** + * Desired atlas scale. + * Default is 1.0f + * @returns {number} + */ + desiredAtlasScale : function(){ + return this._desiredAtlasScale; + }, + + /** + * Sets desired atlas scale. Will choose nearest atlas scale from available. + * Default is 1.0f + * @param scale + */ + setDesiredAtlasScale : function(desiredAtlasScale){ + this._desiredAtlasScale = desiredAtlasScale; + for(var currentScale in this._atlasScales)if(this._atlasScales.hasOwnProperty(currentScale)) + { + if( (this._usedAtlasScale === 0) || + (Math.abs(this._usedAtlasScale - desiredAtlasScale) > Math.abs(currentScale - desiredAtlasScale) )) + { + this._usedAtlasScale = currentScale; + } + + } + }, + + /** + * @method createObject + * @return {gaf.Object} + */ + createObject: function () + { + return this._instantiateGaf(this._gafData); + }, + + /** + * @method createObjectAndRun + * @param {boolean} arg0 - run looped + * @return {gaf.Object} + */ + createObjectAndRun: function (looped) + { + cc.assert(arguments.length === 1, "GAFAsset::createObjectAndRun should have one param"); + var object = this._instantiateGaf(this._gafData); + object.setLooped(looped, true); + object.start(); + return object; + }, + + /** + * @method setTextureLoadDelegate + * @param {function} delegate + */ + setTextureLoadDelegate: function (delegate) + { + debugger; + }, + + + /** + * @method getSceneFps + * @return {uint} + */ + getSceneFps: function () + { + return this._sceneFps; + }, + + /** + * @method getSceneWidth + * @return {uint} + */ + getSceneWidth: function () + { + debugger; + }, + + /** + * @method getSceneHeight + * @return {uint} + */ + getSceneHeight: function () + { + debugger; + }, + + /** + * @method getSceneColor + * @return {cc.color4b} + */ + getSceneColor: function () + { + debugger; + }, + + /** + * @method setSceneFps + * @param {uint} fps + */ + setSceneFps: function (fps) + { + this._sceneFps = fps; + }, + + /** + * @method setSceneWidth + * @param {uint} width + */ + setSceneWidth: function (width) + { + debugger; + }, + + /** + * @method setSceneHeight + * @param {uint} height + */ + setSceneHeight: function (height) + { + debugger; + }, + + /** + * @method setSceneColor + * @param {color4b_object} arg0 + */ + setSceneColor: function (color4B) + { + debugger; + }, + + /** + * @method getHeader + * @return {GAFHeader} + */ + getHeader: function () + { + return this._header; + }, + + getGAFFileName: function() + { + return this._gafName; + }, + + // Private + + ctor : function() + { + this._header = {}; + this._timeLines = []; + this._textFields = []; + this._objects = []; + this._masks = []; + this._protos = []; + this._atlases = {}; + this._onLoadTasks = []; + this._atlasScales = {}; + this._atlasesToLoad = {}; + + if(arguments.length > 0) + this.initWithGAFFile.apply(this, arguments); + }, + + _getProtos: function() + { + return this._protos; + }, + + _setRootTimeline : function(timeLine) + { + this._rootTimeLine = timeLine; + this._header.pivot = timeLine.getPivot(); + this._header.frameSize = timeLine.getRect(); + }, + + _setHeader : function (gafHeader) + { + for(var prop in gafHeader) + { + if(gafHeader.hasOwnProperty(prop)) + { + this._header[prop] = gafHeader[prop]; + } + } + }, + + _getMajorVerison : function() + { + return this._header.versionMajor; + }, + + _init : function(gafData) + { + var self = this; + this._gafData = gafData; + this._setHeader(gafData.header); + this._timeLinesToLink = []; + if(this._getMajorVerison() < 4) + { + this._pushTimeLine(new gaf._TimeLineProto(this, this._header.framesCount, this._header.frameSize, this._header.pivot)); + } + gaf._AssetPreload.Tags(this, gafData.tags, this._rootTimeLine); + + //Link and create + this._objects.forEach(function(item) + { + switch(item.type) + { + case gaf.TYPE_TEXTURE: + // Create gaf sprite proto if it is not yet created + if(!self._protos[item.objectId]) + { + self._protos[item.objectId] = new gaf._SpriteProto(self, self._atlasScales, item.elementAtlasIdRef); + } + break; + case gaf.TYPE_TIME_LINE: + // All time line protos are already created, just copy reference + self._protos[item.objectId] = self._timeLines[item.elementAtlasIdRef]; + break; + case gaf.TYPE_TEXT_FIELD: + // All text field protos are already created, just copy reference + self._protos[item.objectId] = self._textFields[item.elementAtlasIdRef]; + break; + default: + cc.log("Unknown object type: " + item.type); + break; + } + }); + this._masks.forEach(function(item) + { + if(self._protos[item.objectId]) + { + return; // this is continue + } + var proto = null; + switch(item.type) + { + case gaf.TYPE_TEXTURE: + // Create gaf sprite proto if it is not yet created + proto = new gaf._SpriteProto(self, self._atlasScales, item.elementAtlasIdRef); + break; + case gaf.TYPE_TIME_LINE: + // All time line protos are already created, just copy reference + proto = self._timeLines[item.elementAtlasIdRef]; + break; + case gaf.TYPE_TEXT_FIELD: + // All text field protos are already created, just copy reference + proto = self._textFields[item.elementAtlasIdRef]; + break; + } + self._protos[item.objectId] = new gaf._MaskProto(self, proto, item.elementAtlasIdRef); + }); + this.setDesiredAtlasScale(this._desiredAtlasScale); + + if(Object.keys(this._atlasesToLoad).length === 0) + { + this._textureLoaded = true; + this.dispatchEvent("load"); + } + }, + + _pushTimeLine : function(timeLine) + { + this._timeLines[timeLine.getId()] = timeLine; + + if(timeLine.getId() === 0) + { + this._setRootTimeline(timeLine); + } + }, + + _instantiateGaf : function() + { + var root = null; + root = this._rootTimeLine._gafConstruct(); + return root; + }, + + _onAtlasLoaded : function(id, atlas) + { + this._atlases[id] = atlas; + delete this._atlasesToLoad[id]; + if(Object.keys(this._atlasesToLoad).length === 0) + { + this._onLoadTasks.forEach(function(fn){fn()}); + this._onLoadTasks.length = 0; + this._textureLoaded = true; + this.dispatchEvent("load"); + } + }, + + isLoaded : function() + { + return this._textureLoaded; + }, + + _getSearchPaths: function(imageUrl) + { + var extendedPath = this.getGAFFileName().split('/'); + extendedPath[extendedPath.length-1] = imageUrl; + var alternativeUrl = extendedPath.join('/'); + + return [imageUrl, alternativeUrl]; + } +}); + +/** + * @method initWithGAFFile + * @param {String} gafFilePath - path to .gaf file + * @param {function({path:String})} delegate - is used to change atlas path, e.g. to load `atlas.tga` instead of `atlas.png` + * @return {gaf.Asset} + */ +gaf.Asset.create = function (gafFilePath, delegate) +{ + return new gaf.Asset(gafFilePath, delegate); +}; + +/** + * @method createWithBundle + * @param {String} zipFilePath - path to the archive with .gaf and its textures + * @param {String} entryFile - name of the .gaf file in archive + * @param {function({path:String})} delegate - is used to change atlas path, e.g. to load `atlas.tga` instead of `atlas.png` + * @return {gaf.Asset} + */ +gaf.Asset.createWithBundle = function (zipFilePath, entryFile, delegate) +{ + var asset = new gaf.Asset(); + asset.initWithGAFBundle(zipFilePath, entryFile, delegate); + return asset; +}; + +cc.EventHelper.prototype.apply(gaf.Asset.prototype); diff --git a/external/gaf/Library/GAFAssetPreload.js b/external/gaf/Library/GAFAssetPreload.js new file mode 100644 index 0000000000..8514e09f2d --- /dev/null +++ b/external/gaf/Library/GAFAssetPreload.js @@ -0,0 +1,270 @@ + +gaf.CGAffineTransformCocosFormatFromFlashFormat = function(transform) +{ + var t = {}; + t.a = transform.a; + t.b = -transform.b; + t.c = -transform.c; + t.d = transform.d; + t.tx = transform.tx; + t.ty = -transform.ty; + return t; +}; + +gaf._AssetPreload = function() +{ + this["0"] = this.End; + this["1"] = this.Atlases; + this["2"] = this.AnimationMasks; + this["3"] = this.AnimationObjects; + this["4"] = this.AnimationFrames; + this["5"] = this.NamedParts; + this["6"] = this.Sequences; + this["7"] = this.TextFields; + this["8"] = this.Atlases; // 2 + this["9"] = this.Stage; + this["10"] = this.AnimationObjects; //2 + this["11"] = this.AnimationMasks; // 2 + this["12"] = this.AnimationFrames; // 2 + this["13"] = this.TimeLine; +}; + +gaf._AssetPreload.prototype.End = function(asset, content, timeLine){ + if(timeLine) + { + timeLine.getFps = function() + { + return asset.getSceneFps(); + }; + } +}; + +gaf._AssetPreload.prototype.Tag = function(asset, tag, timeLine) +{ + (this[tag.tagId]).call(this, asset, tag.content, timeLine); +}; + +gaf._AssetPreload.prototype.Tags = function(asset, tags, timeLine) +{ + var self = this; + tags.forEach(function(tag) + { + self.Tag(asset, tag, timeLine); + }); +}; + +gaf._AssetPreload.prototype.AtlasCreateFrames = function(elements, asset, spriteFrames) +{ + elements.forEach(function (item) { + var texture = asset._atlases[item.atlasId]; + var rect = cc.rect(item.origin.x, item.origin.y, item.size.x, item.size.y); + var frame = new cc.SpriteFrame(texture, rect); + frame._gafAnchor = + { + x: (0 - (0 - (item.pivot.x / item.size.x))), + y: (0 + (1 - (item.pivot.y / item.size.y))) + }; + spriteFrames[item.elementAtlasId] = frame; + // 9 grid + }); +}; + + + +gaf._AssetPreload.prototype.Atlases = function(asset, content, timeLine) +{ + var spriteFrames = asset._atlasScales[content.scale] = asset._atlasScales[content.scale] || []; + var csf = cc.Director._getInstance().getContentScaleFactor(); + + content.atlases.forEach(function(item) + { + var atlasId = item.id; + var finalizeLoading = function() + { + gaf._AssetPreload.AtlasCreateFrames(content.elements, asset, spriteFrames); + }; + + var atlasPath = ""; + item.sources.forEach(function(atlasSource) + { + if(atlasSource.csf === csf) + { + atlasPath = atlasSource.source; + } + }); + cc.assert(atlasPath, "GAF Error. Texture for current CSF not found. Reconvert animation with correct parameters."); + + if(asset._textureLoadDelegate) + { + atlasPath = asset._textureLoadDelegate(atlasPath); + } + + var loaded = false; + var paths = asset._getSearchPaths(atlasPath); + for(var i = 0, len = paths.length; i < len; ++i){ + var path = paths[i]; + var atlas = cc.textureCache.getTextureForKey(path); + if(atlas && atlas.isLoaded()) + { + atlas.handleLoadedTexture(true); + loaded = true; + asset._atlases[atlasId] = atlas; + finalizeLoading(); + break; + } + } + // Need to load atlases async + if(!loaded) + { + var success = function (atlas) { + atlas.handleLoadedTexture(true); + asset._onAtlasLoaded(atlasId, atlas); + }; + + var fail = function () { + cc.log("GAF Error. Couldn't find `" + atlasPath + "` required by `" + asset.getGAFFileName() + "`"); + }; + + if(!asset._atlasesToLoad.hasOwnProperty(atlasId)) + { + gaf._AtlasLoader.loadArray(paths, success, fail); + asset._atlasesToLoad[atlasId] = {}; + } + asset._onLoadTasks.push(finalizeLoading); + } + }); +}; + +gaf._AssetPreload.prototype.AnimationObjects = function(asset, content, timeLine) +{ + content.forEach(function(item) + { + item.type = (item.type === undefined) ? gaf.TYPE_TEXTURE : item.type; + timeLine._objects.push(item.objectId); + asset._objects[item.objectId] = item; + }); +}; + +gaf._AssetPreload.prototype.convertTint = function(mat, alpha) +{ + if(!mat) + return null; + return { + mult: + { + r: mat.redMultiplier * 255, + g: mat.greenMultiplier * 255, + b: mat.blueMultiplier * 255, + a: alpha * 255 + }, + offset: + { + r: mat.redOffset * 255, + g: mat.greenOffset * 255, + b: mat.blueOffset * 255, + a: mat.alphaOffset * 255 + } + }; +}; + +gaf._AssetPreload.prototype.convertState = function(state) +{ + return { + hasColorTransform: state.hasColorTransform, + hasMask: state.hasMask, + hasEffect: state.hasEffect, + objectIdRef: state.objectIdRef, + depth: state.depth, + alpha: state.alpha * 255, + matrix: gaf.CGAffineTransformCocosFormatFromFlashFormat(state.matrix), + colorTransform: this.convertTint(state.colorTransform, state.alpha), + effect: state.effect, + maskObjectIdRef: state.maskObjectIdRef + }; +}; + +gaf._AssetPreload.prototype.AnimationFrames = function(asset, content, timeLine) +{ + var self = this; + cc.assert(timeLine, "Error. Time Line should not be null."); + var statesForId = {}; + var frames = []; + var lastFrame = {}; + for(var i = 0, len = content.length; i < len; ++i) + { + var frame = content[i]; + if(frame.state) + { + frame.state.forEach(function (state) + { + if (state.alpha !== 0) + { + statesForId[state.objectIdRef] = self.convertState(state); + } + else + { + statesForId[state.objectIdRef] = null; + } + }); + } + var stateArray = []; + for(var obj in statesForId){ if(statesForId.hasOwnProperty(obj) && statesForId[obj]) + { + stateArray.push(statesForId[obj]); + }} + lastFrame = frame; + frames[frame.frame - 1] = {states: stateArray, actions: frame.actions || null}; + } + timeLine.getFrames = function(){return frames}; +}; + +gaf._AssetPreload.prototype.NamedParts = function(asset, content, timeLine) +{ + var parts = {}; + content.forEach(function(item) + { + parts[item.name] = item.objectId; + }); + timeLine.getNamedParts = function(){return parts}; +}; + +gaf._AssetPreload.prototype.Sequences = function(asset, content, timeLine) +{ + var sequences = {}; + content.forEach(function(item){ + sequences[item.id] = {start: item.start - 1, end: item.end}; + }); + timeLine.getSequences = function(){return sequences}; +}; + +gaf._AssetPreload.prototype.TextFields = function(asset, content, timeLine) +{ + debugger; +}; + +gaf._AssetPreload.prototype.Stage = function(asset, content, timeLine) +{ + asset._sceneFps = content.fps; + asset._sceneColor = content.color; + asset._sceneWidth = content.width; + asset._sceneHeight = content.height; +}; + +gaf._AssetPreload.prototype.AnimationMasks = function(asset, content, timeLine) +{ + content.forEach(function(item) + { + item.type = (item.type === undefined) ? gaf.TYPE_TEXTURE : item.type; + timeLine._objects.push(item.objectId); + asset._masks[item.objectId] = item; + }); +}; + +gaf._AssetPreload.prototype.TimeLine = function(asset, content, timeLine) +{ + var result = new gaf._TimeLineProto(asset, content.animationFrameCount, content.boundingBox, content.pivotPoint, content.id, content.linkageName); + asset._pushTimeLine(result); + this.Tags(asset, content.tags, result); +}; + +gaf._AssetPreload = new gaf._AssetPreload(); diff --git a/external/gaf/Library/GAFAtlasLoader.js b/external/gaf/Library/GAFAtlasLoader.js new file mode 100644 index 0000000000..152bba0788 --- /dev/null +++ b/external/gaf/Library/GAFAtlasLoader.js @@ -0,0 +1,50 @@ +/** + * Created by admiral on 19.02.2015. + */ + +gaf._AtlasLoader = {}; +gaf._AtlasLoader.execute = function(condition, success, fail) +{ + condition() ? success() : fail(); +}; + +gaf._AtlasLoader.checkAtlas = function(atlas) // curried function +{ + return function(){return atlas && typeof atlas !== "string" && atlas.isLoaded()}; +}; + +gaf._AtlasLoader.load = function(path, success, fail) +{ + cc.textureCache.addImage(path, function(atlas){ + gaf._AtlasLoader.execute( + gaf._AtlasLoader.checkAtlas(atlas), + function(){success(atlas)}, + fail + ); + }); +}; + +gaf._AtlasLoader.loadFront = function(arr, success, fail) +{ + // Call recursively this function for each element starting from the first + // stops on first success, or fails after last element + return function() + { + if (arr.length > 0){ + gaf._AtlasLoader.load( + arr[0], + success, + gaf._AtlasLoader.loadFront( + arr.slice(1), + success, + fail + ));} + else + fail(); + } +}; + +gaf._AtlasLoader.loadArray = function(array, success, fail) +{ + gaf._AtlasLoader.loadFront(array, success, fail)(); +}; diff --git a/external/gaf/Library/GAFDataReader.js b/external/gaf/Library/GAFDataReader.js new file mode 100644 index 0000000000..3affbe1335 --- /dev/null +++ b/external/gaf/Library/GAFDataReader.js @@ -0,0 +1,229 @@ +gaf.DataReader = function(data) { + this.dataRaw = data; + this.buf = new DataView(data); + this.offset = [0]; +}; + +gaf.DataReader.prototype.constructor = gaf.DataReader; + +gaf.DataReader.prototype.newOffset = function(size){ + this.offset[this.offset.length - 1] += size; + if(this.getOffset() > this.maxOffset()){ + throw new Error("GAF format error"); + } + return this.offset[this.offset.length - 1] - size; +}; + +gaf.DataReader.prototype.maxOffset = function(){ + if(this.offset.length == 1){ + return this.buf.byteLength; + } + else{ + return this.offset[this.offset.length - 2]; + } +}; + +gaf.DataReader.prototype.getOffset = function(size){ + return this.offset[this.offset.length - 1]; +}; + +gaf.DataReader.prototype.Ubyte = function() { + return this.buf.getUint8(this.newOffset(1)); +}; + +gaf.DataReader.prototype.Boolean = function() { + var result = this.buf.getUint8(this.newOffset(1)); + if(result > 1){ + throw new Error("GAF format error"); + } + return result; +}; + +gaf.DataReader.prototype.Uint = function() { + return this.buf.getUint32(this.newOffset(4), true); +}; + +gaf.DataReader.prototype.Int = function() { + return this.buf.getInt32(this.newOffset(4), true); +}; + +gaf.DataReader.prototype.color = function() { + return { + b: this.Ubyte(), + g: this.Ubyte(), + r: this.Ubyte(), + a: this.Ubyte() + }; +}; + +gaf.DataReader.prototype.Ushort = function() { + return this.buf.getUint16(this.newOffset(2), true); +}; + +gaf.DataReader.prototype.Float = function() { + return this.buf.getFloat32(this.newOffset(4), true); +}; + +gaf.DataReader.prototype.String = function() { + var strLen = this.Ushort(); + var from = this.newOffset(strLen); + var to = this.getOffset(); + + try + { + var str = this.dataRaw.slice(from, to); + } + catch(e) + { + // Internet Explorer 10 T.T + if(e.message == "Object doesn't support property or method 'slice'") + { + str = []; + for(var i = from; i < to; ++i) + str.push(this.buf.getUint8(i)); + } + else + { + throw(e); + } + } + return decodeURIComponent(escape(String.fromCharCode.apply(null, new Uint8Array(str)))); + +}; + +gaf.DataReader.prototype.startNestedBuffer = function(length) { + this.offset.push(this.offset[this.offset.length-1]); + this.offset[this.offset.length-2] += length; +}; + +gaf.DataReader.prototype.endNestedBuffer = function() { + if (this.offset.length == 1) throw new Error('No nested buffer available'); + this.offset.pop(); +}; + +gaf.DataReader.prototype.Point = function(){ + return { + x: this.Float(), + y: this.Float() + }; +}; + +gaf.DataReader.prototype.Rect = function(){ + return { + x: this.Float(), + y: this.Float(), + width: this.Float(), + height: this.Float() + }; +}; + +gaf.DataReader.prototype.Matrix = function(){ + return { + a: this.Float(), + b: this.Float(), + c: this.Float(), + d: this.Float(), + tx: this.Float(), + ty: this.Float() + }; +}; + +gaf.DataReader.prototype.seek = function(pos){ + this.offset[this.offset.length-1] = pos; +}; + +gaf.DataReader.prototype.tell = function(){ + return this.offset[this.offset.length-1]; +}; + +/* Creates a fields parsing function +* @ returns a function that will read from DataReader `field` of type `type` +* @`key` - key for read data to be stored +* @`data` - data to store. Can be DataReader function name or a function that will return a value +* Note. Parameters pair `key` and `data` can be repeated any number of times*/ + +gaf.DataReader.prototype.fields = function(){ + var self = this; + var arguments_ = arguments; + return function(){ + arguments.callee.result = {}; + var i = 0; + if(arguments_.length % 2){ + throw new Error('Number of arguments is not even'); + } + while(i < arguments_.length){ + var field = arguments_[i++]; + var func = arguments_[i++]; + if(typeof func === 'function'){ + arguments.callee.result[field] = func(); + } + else if (func in self && typeof self[func] === 'function'){ + arguments.callee.result[field] = self[func].call(self); + } + else{ + throw new Error('Object DataReader has no function `' + func + '`'); + } + } + return arguments.callee.result; + } +}; + +/* +* Creates a parsing function +* @ returns function that will execute expression if caller's `result` field has `key` equal to `value` parameter +* @ `key` - key in caller's `result` element +* @ `value` - expected value of the `key` or a comparator function +* @ `func` - function to execute if condition is true +* */ + +gaf.DataReader.prototype.condition = function(key, value, func){ + var arguments_ = arguments; + return function() { + if(arguments_.length != 3){ + throw new Error('Condition function'); + } + var parent = arguments.callee.caller; + if(!('result' in parent)){ + throw new Error('Condition function caller has no key `result`'); + } + var container = parent.result; + var field = arguments_[0]; + var value = arguments_[1]; + var exec = arguments_[2]; + + var evaluate = null; + if(typeof value === 'function'){ + evaluate = function(){return value(container[field]);}; + } + else{ + evaluate = function(){return value == container[field];}; + } + if(evaluate()){ + return exec(); + } + else{ + return null; + } + } +}; + +/* +* Creates an array parsing function +* @ returns function that will execute `func` number of times read from DataReader +* @ `type` - type of count number +* @ `func` - function to be executed +* */ + +gaf.DataReader.prototype.array = function(){ + var self = this; + var arguments_ = arguments; + return function() { + arguments.callee.result = []; + var length = self[arguments_[0]].call(self); + for (var i = 0; i < length; ++i) { + var r = arguments_[1].call(); + arguments.callee.result.push(r); + } + return arguments.callee.result; + } +}; diff --git a/external/gaf/Library/GAFLoader.js b/external/gaf/Library/GAFLoader.js new file mode 100644 index 0000000000..3e40c33947 --- /dev/null +++ b/external/gaf/Library/GAFLoader.js @@ -0,0 +1,75 @@ +var gaf = gaf || {}; + +//@Private class +gaf.Loader = function(){ + + var readHeaderBegin = function(stream, header){ + header.compression = stream.Uint(); + header.versionMajor = stream.Ubyte(); + header.versionMinor = stream.Ubyte(); + header.fileLength = stream.Uint(); + }; + + var readHeaderEndV3 = function(stream, header) { + header.framesCount = stream.Ushort(); + header.frameSize = stream.Rect(); + header.pivot = stream.Point(); + }; + + var readHeaderEndV4 = function(stream, header){ + var scaleCount = stream.Uint(); + header.scaleValues = []; + for(var i = 0; i < scaleCount; ++i){ + header.scaleValues.push(stream.Float()); + } + var csfCount = stream.Uint(); + header.csfValues = []; + for(var i = 0; i < csfCount; ++i){ + header.csfValues.push(stream.Float()); + } + }; + + this.LoadFile = function(filePath, onLoaded){ + var oReq = new XMLHttpRequest(); + oReq.open("GET", filePath, true); + var self = this; + oReq.responseType = "arraybuffer"; + oReq.onload = function(oEvent) { + var gaf_data = new gaf.DataReader(oReq.response); + var gafFile = self.LoadStream(gaf_data); + if(onLoaded) + onLoaded(gafFile); + }; + oReq.send(); + }; + + this.LoadStream = function(stream){ + var header = {}; + readHeaderBegin(stream, header); + if(header.compression == gaf.COMPRESSION_NONE) { // GAF + } + else if(header.compression == gaf.COMPRESSION_ZIP){ // GAC + var compressed = stream.dataRaw.slice(stream.tell()); + + var inflate = new window.Zlib.Inflate(new Uint8Array(compressed)); + var decompressed = inflate.decompress(); + stream = new gaf.DataReader(decompressed.buffer); + } + else{ + throw new Error("GAF syntax error."); + } + + if(header.versionMajor < 4){ + readHeaderEndV3(stream, header); + } + else{ + readHeaderEndV4(stream, header); + } + + var tags = gaf.ReadTags(stream); + return { + header: header, + tags: tags + }; + }; +}; diff --git a/external/gaf/Library/GAFMask.js b/external/gaf/Library/GAFMask.js new file mode 100644 index 0000000000..34ca20681c --- /dev/null +++ b/external/gaf/Library/GAFMask.js @@ -0,0 +1,36 @@ + +gaf.Mask = gaf.Object.extend +({ + _className: "GAFMask", + _clippingNode: null, + + ctor : function(gafSpriteProto) + { + this._super(); + cc.assert(gafSpriteProto, "Error! Missing mandatory parameter."); + this._gafproto = gafSpriteProto; + }, + + _init : function() + { + var maskNodeProto = this._gafproto.getMaskNodeProto(); + cc.assert(maskNodeProto, "Error. Mask node for id ref " + this._gafproto.getIdRef() + " not found."); + this._maskNode = maskNodeProto._gafConstruct(); + this._clippingNode = cc.ClippingNode.create(this._maskNode); + this._clippingNode.setAlphaThreshold(0.5); + this.addChild(this._clippingNode); + }, + + setExternalTransform : function(affineTransform) + { + if(!cc.affineTransformEqualToTransform(this._maskNode._additionalTransform, affineTransform)) + { + this._maskNode.setAdditionalTransform(affineTransform); + } + }, + + _getNode : function() + { + return this._clippingNode; + } +}); \ No newline at end of file diff --git a/external/gaf/Library/GAFMaskProto.js b/external/gaf/Library/GAFMaskProto.js new file mode 100644 index 0000000000..6074fd1279 --- /dev/null +++ b/external/gaf/Library/GAFMaskProto.js @@ -0,0 +1,16 @@ + +gaf._MaskProto = function(asset, mask, idRef) +{ + this.getIdRef = function(){return idRef}; + this.getMaskNodeProto = function() {return mask}; + + /* + * Will construct GAFMask + */ + this._gafConstruct = function() + { + var ret = new gaf.Mask(this); + ret._init(); + return ret; + }; +}; diff --git a/external/gaf/Library/GAFObject.js b/external/gaf/Library/GAFObject.js new file mode 100644 index 0000000000..7d5375abe5 --- /dev/null +++ b/external/gaf/Library/GAFObject.js @@ -0,0 +1,426 @@ +var gaf = gaf || {}; + +gaf._stateHasCtx = function(state) +{ + // Check for tint color offset + if( state.hasColorTransform && + (state.colorTransform.offset.r > 0 || + state.colorTransform.offset.g > 0 || + state.colorTransform.offset.b > 0 || + state.colorTransform.offset.a > 0) + ) + { + return true; + } + + // Check for color transform filter + if(state.hasEffect) + { + for(var i = 0, total = state.effect.length; i < total; ++i) + { + if(state.effect[i].type === gaf.EFFECT_COLOR_MATRIX) + return true; + } + } + return false; +}; + +gaf.Object = cc.Node.extend +({ + _asset : null, + _className : "GAFObject", + _id : gaf.IDNONE, + _gafproto : null, + _parentTimeLine : null, + _lastVisibleInFrame : 0, + _filterStack : null, + _cascadeColorMult : null, + _cascadeColorOffset : null, + _needsCtx : false, + _usedAtlasScale: 1, + + // Public methods + ctor: function(scale) + { + if(arguments.length == 1) + { + this._usedAtlasScale = scale; + } + this._super(); + this._cascadeColorMult = cc.color(255, 255, 255, 255); + this._cascadeColorOffset = cc.color(0, 0, 0, 0); + this._filterStack = []; + }, + + /** + * @method setAnimationStartedNextLoopDelegate + * @param {function(Object)} delegate + */ + setAnimationStartedNextLoopDelegate : function (delegate) {}, + + /** + * @method setAnimationFinishedPlayDelegate + * @param {function(Object)} delegate + */ + setAnimationFinishedPlayDelegate : function (delegate) {}, + + /** + * @method setLooped + * @param {bool} looped + */ + setLooped : function (looped) {}, + + /** + * @method getBoundingBoxForCurrentFrame + * @return {cc.Rect} + */ + getBoundingBoxForCurrentFrame : function () {return null;}, + + /** + * @method setFps + * @param {uint} fps + */ + setFps : function (fps) {}, + + /** + * @method getObjectByName + * @param {String} name - name of the object to find + * @return {gaf.Object} + */ + getObjectByName : function (name) {return null;}, + + /** + * @method clearSequence + */ + clearSequence : function () {}, + + /** + * @method getIsAnimationRunning + * @return {bool} + */ + getIsAnimationRunning : function () {return false;}, + + /** + * @method getSequences + * @return [string] - list of sequences if has any + */ + getSequences : function(){return [];}, + + + /** + * @method gotoAndStop + * @param {uint|String} value - label ot frame number + * @return {bool} + */ + gotoAndStop : function (value) {}, + + /** + * @method getStartFrame + * @param {String} frameLabel + * @return {uint} + */ + getStartFrame : function (frameLabel) {return gaf.IDNONE;}, + + /** + * @method setFramePlayedDelegate + * @param {function(Object, frame)} delegate + */ + setFramePlayedDelegate : function (delegate) {}, + + /** + * @method getCurrentFrameIndex + * @return {uint} + */ + getCurrentFrameIndex : function () { + return gaf.IDNONE; + }, + + /** + * @method getTotalFrameCount + * @return {uint} + */ + getTotalFrameCount : function () {return 0;}, + + /** + * @method start + */ + start : function () {}, + + /** + * @method stop + */ + stop : function () {}, + + /** + * @method isVisibleInCurrentFrame + * @return {bool} + */ + isVisibleInCurrentFrame : function () + { + /*if (this._parentTimeLine && + ((this._parentTimeLine.getCurrentFrameIndex() + 1) != this._lastVisibleInFrame)) + { + return false; + } + else + { + return true; + }*/ + return !(this._parentTimeLine && ((this._parentTimeLine.getCurrentFrameIndex() + 1) != this._lastVisibleInFrame)); + }, + + /** + * @method isDone + * @return {bool} + */ + isDone : function () {return true;}, + + /** + * @method playSequence + * @param {String} name - name of the sequence to play + * @param {bool} looped - play looped + * @param {bool} resume - whether to resume animation if stopped. True by default + * @return {bool} + */ + playSequence : function (name, looped, resume) {return false;}, + + /** + * @method isReversed + * @return {bool} + */ + isReversed : function () {return false;}, + + /** + * @method setSequenceDelegate + * @param {function(Object, sequenceName)} delegate + */ + setSequenceDelegate : function (delegate) {}, + + /** + * @method setFrame + * @param {uint} index + * @return {bool} + */ + setFrame : function (index) {return false;}, + + /** + * @method setControlDelegate + * @param {function} func + */ + setControlDelegate : function (func) {}, + + /** + * @method getEndFrame + * @param {String} frameLabel + * @return {uint} + */ + getEndFrame : function (frameLabel) {return gaf.IDNONE;}, + + /** + * @method pauseAnimation + */ + pauseAnimation : function () {}, + + /** + * @method gotoAndPlay + * @param {uint|String} value - label ot frame number + * @return {bool} + */ + gotoAndPlay : function (value) {}, + + /** + * @method isLooped + * @return {bool} + */ + isLooped : function () {return false;}, + + /** + * @method resumeAnimation + */ + resumeAnimation : function () {}, + + /** + * @method setReversed + * @param {bool} reversed + */ + setReversed : function (reversed) {}, + + /** + * @method hasSequences + * @return {bool} + */ + hasSequences : function () {return false;}, + + /** + * @method getFps + * @return {uint} + */ + getFps : function () {return 60;}, + + /** + * @method setLocator + * @param {bool} locator + * Locator object will not draw itself, but its children will be drawn + */ + setLocator : function (locator){}, + + setExternalTransform : function(affineTransform) + { + if(!cc.affineTransformEqualToTransform(this._additionalTransform, affineTransform)) + { + this.setAdditionalTransform(affineTransform); + } + }, + + getExternalTransform : function() + { + return this._additionalTransform; + }, + + setAnimationRunning: function () {}, + + //////////////// + // Private + //////////////// + _enableTick: function(val){}, + + _resetState : function() + {}, + + _updateVisibility : function(state, parent) + { + var alphaOffset = state.hasColorTransform ? state.colorTransform.offset.a : 0; + this.setOpacity(state.alpha + alphaOffset); + //return this.isVisible(); + }, + + // @Override + isVisible : function() + { + return this.getOpacity() > 0; + }, + + // @Override + visit: function(parentCmd) + { + if(this.isVisibleInCurrentFrame()) + { + this._super(parentCmd); + } + }, + + _getFilters : function(){return null}, + + _processAnimation : function(){}, + + + _applyState : function(state, parent) + { + this._applyStateSuper(state, parent); + }, + + _applyStateSuper : function(state, parent) + { + this._needsCtx = parent._needsCtx; + this._filterStack.length = 0; // clear + this._parentTimeLine = parent; // only gaf time line can call applyState. Assign it as parent + if(this._usedAtlasScale != 1) + { + var newMat = cc.clone(state.matrix); + newMat.tx *= this._usedAtlasScale; + newMat.ty *= this._usedAtlasScale; + this.setExternalTransform(newMat); // apply transformations of the state + } + else + { + this.setExternalTransform(state.matrix); // apply transformations of the state + } + // Cascade filters + // TODO: apply more than one filter + if (state.hasEffect) { + this._filterStack = this._filterStack.concat(state.effect); + this._needsCtx = true; + } + if (parent._filterStack && parent._filterStack.length > 0) { + this._filterStack = this._filterStack.concat(parent._filterStack); + } + + if(this._filterStack.length > 0 && this._filterStack[0].type === gaf.EFFECT_COLOR_MATRIX) + { + this._needsCtx = true; + } + + // Cascade color transformations + + // If state has a tint, then we should process it + if (state.hasColorTransform) + { + this._cascadeColorMult.r = state.colorTransform.mult.r * parent._cascadeColorMult.r / 255; + this._cascadeColorMult.g = state.colorTransform.mult.g * parent._cascadeColorMult.g / 255; + this._cascadeColorMult.b = state.colorTransform.mult.b * parent._cascadeColorMult.b / 255; + this._cascadeColorMult.a = state.colorTransform.mult.a * parent._cascadeColorMult.a / 255; + + this._cascadeColorOffset.r = state.colorTransform.offset.r + parent._cascadeColorOffset.r; + this._cascadeColorOffset.g = state.colorTransform.offset.g + parent._cascadeColorOffset.g; + this._cascadeColorOffset.b = state.colorTransform.offset.b + parent._cascadeColorOffset.b; + this._cascadeColorOffset.a = state.colorTransform.offset.a + parent._cascadeColorOffset.a; + } + else + { + this._cascadeColorMult.r = parent._cascadeColorMult.r; + this._cascadeColorMult.g = parent._cascadeColorMult.g; + this._cascadeColorMult.b = parent._cascadeColorMult.b; + this._cascadeColorMult.a = state.alpha * (parent._cascadeColorMult.a / 255); + + this._cascadeColorOffset.r = parent._cascadeColorOffset.r; + this._cascadeColorOffset.g = parent._cascadeColorOffset.g; + this._cascadeColorOffset.b = parent._cascadeColorOffset.b; + this._cascadeColorOffset.a = parent._cascadeColorOffset.a; + } + + if (this._cascadeColorOffset.r > 0 || + this._cascadeColorOffset.g > 0 || + this._cascadeColorOffset.b > 0 || + this._cascadeColorOffset.a > 0) + { + this._needsCtx = true; + } + }, + + _initRendererCmd: function() + { + this._renderCmd = cc.renderer.getRenderCmd(this); + this._renderCmd._visit = this._renderCmd.visit; + var self = this; + this._renderCmd.visit = function(parentCmd) { + if(self.isVisibleInCurrentFrame()){ + this._visit(parentCmd); + } + } + }, + + _getNode : function() + { + return this; + }, + + setAnchorPoint : function(point, y) + { + if (y === undefined) + { + this._super(point.x, point.y - 1); + } + else + { + this._super(point, y - 1); + } + } + +}); + +gaf.Object._createNullObject = function() +{ + var ret = new gaf.Object(); + ret.isVisible = function(){return true}; + return ret; +}; diff --git a/external/gaf/Library/GAFShaderManager.js b/external/gaf/Library/GAFShaderManager.js new file mode 100644 index 0000000000..fd72f79825 --- /dev/null +++ b/external/gaf/Library/GAFShaderManager.js @@ -0,0 +1,63 @@ + +gaf._glShaderInit = function() { + gaf._Uniforms = { + ColorTransformMult: -1, + ColorTransformOffset: -1, + ColorMatrixBody: -1, + ColorMatrixAppendix: -1, + BlurTexelOffset: -1, + GlowTexelOffset: -1, + GlowColor: -1 + }; + + gaf._shaderCreate = function (fs, vs) { + var program = new cc.GLProgram(); + var result = program.initWithVertexShaderByteArray(vs, fs); + cc.assert(result, "Shader init error"); + program.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); + program.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); + program.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); + result = program.link(); + cc.assert(result, "Shader linking error"); + program.updateUniforms(); + return program; + }; + + gaf._shaderCreateAlpha = function () { + var program = gaf._shaderCreate(gaf.SHADER_COLOR_MATRIX_FRAG, cc.SHADER_POSITION_TEXTURE_COLOR_VERT); + gaf._Uniforms.ColorTransformMult = program.getUniformLocationForName(gaf.UNIFORM_ALPHA_TINT_MULT); + gaf._Uniforms.ColorTransformOffset = program.getUniformLocationForName(gaf.UNIFORM_ALPHA_TINT_OFFSET); + gaf._Uniforms.ColorMatrixBody = program.getUniformLocationForName(gaf.UNIFORM_ALPHA_COLOR_MATRIX_BODY); + gaf._Uniforms.ColorMatrixAppendix = program.getUniformLocationForName(gaf.UNIFORM_ALPHA_COLOR_MATRIX_APPENDIX); + return program; + }; + + gaf._shaderCreateBlur = function () { + var program = gaf._shaderCreate(gaf.SHADER_GAUSSIAN_BLUR_FRAG, cc.SHADER_POSITION_TEXTURE_COLOR_VERT); + gaf._Uniforms.BlurTexelOffset = program._glContext.getUniformLocation(program._programObj, gaf.UNIFORM_BLUR_TEXEL_OFFSET); + + return program; + }; + + gaf._shaderCreateGlow = function () { + var program = gaf._shaderCreate(gaf.SHADER_GLOW_FRAG, cc.SHADER_POSITION_TEXTURE_COLOR_VERT); + gaf._Uniforms.GlowTexelOffset = program._glContext.getUniformLocation(program._programObj, gaf.UNIFORM_GLOW_TEXEL_OFFSET); + gaf._Uniforms.GlowColor = program._glContext.getUniformLocation(program._programObj, gaf.UNIFORM_GLOW_COLOR); + return program; + }; + + gaf._Shaders = { + Alpha: gaf._shaderCreateAlpha(), + Blur: gaf._shaderCreateBlur(), + Glow: gaf._shaderCreateGlow() + }; +}; + +gaf._setupShaders = function() { + if (cc._renderType === cc._RENDER_TYPE_WEBGL) { + gaf._glShaderInit(); + } + else { + delete gaf._glShaderInit; + } +}; diff --git a/external/gaf/Library/GAFShaders.js b/external/gaf/Library/GAFShaders.js new file mode 100644 index 0000000000..7d91537285 --- /dev/null +++ b/external/gaf/Library/GAFShaders.js @@ -0,0 +1,58 @@ +gaf.SHADER_GAUSSIAN_BLUR_FRAG = + "varying mediump vec2 v_texCoord;\n" + + "uniform mediump vec2 u_step;\n" + + "void main()\n" + + "{ \n" + + " mediump vec4 sum = vec4(0.0); \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 4.0) * 0.05; \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 3.0) * 0.09; \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 2.0) * 0.12; \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 1.0) * 0.15; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 0.0) * 0.18; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 1.0) * 0.15; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 2.0) * 0.12; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 3.0) * 0.09; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 4.0) * 0.05; \n" + + " gl_FragColor = sum; \n" + + "} \n"; + +gaf.SHADER_GLOW_FRAG = + "varying mediump vec2 v_texCoord;\n" + + "uniform mediump vec2 u_step;\n" + + "uniform mediump vec4 u_glowColor;\n" + + "void main()\n" + + "{ \n" + + " mediump vec4 sum = vec4(0.0); \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 4.0) * 0.05; \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 3.0) * 0.09; \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 2.0) * 0.12; \n" + + " sum += texture2D(CC_Texture0, v_texCoord - u_step * 1.0) * 0.15; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 0.0) * 0.18; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 1.0) * 0.15; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 2.0) * 0.12; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 3.0) * 0.09; \n" + + " sum += texture2D(CC_Texture0, v_texCoord + u_step * 4.0) * 0.05; \n" + + " gl_FragColor = sum * u_glowColor; \n" + + "} \n"; + +gaf.SHADER_COLOR_MATRIX_FRAG = + "varying mediump vec2 v_texCoord;\n" + + "varying mediump vec4 v_fragmentColor;\n" + + "uniform mediump vec4 colorTransformMult;\n" + + "uniform mediump vec4 colorTransformOffsets;\n" + + "uniform mediump mat4 colorMatrix;\n" + + "uniform mediump vec4 colorMatrix2;\n" + + "void main()\n" + + "{ \n" + + " vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n" + + " const float kMinimalAlphaAllowed = 1.0e-8; \n" + + " if (texColor.a > kMinimalAlphaAllowed) \n" + + " { \n" + + " texColor = vec4(texColor.rgb / texColor.a, texColor.a); \n" + + " vec4 ctxColor = texColor * colorTransformMult + colorTransformOffsets; \n" + + " vec4 adjustColor = colorMatrix * ctxColor + colorMatrix2; \n" + + " adjustColor *= v_fragmentColor; \n" + + " texColor = vec4(adjustColor.rgb * adjustColor.a, adjustColor.a); \n" + + " } \n" + + " gl_FragColor = texColor; \n" + + "}\n"; diff --git a/external/gaf/Library/GAFSprite.js b/external/gaf/Library/GAFSprite.js new file mode 100644 index 0000000000..07ea732f44 --- /dev/null +++ b/external/gaf/Library/GAFSprite.js @@ -0,0 +1,100 @@ + +gaf.Sprite = gaf.Object.extend +({ + _className: "GAFSprite", + + _hasCtx: false, + _hasFilter: false, + + ctor : function(gafSpriteProto, usedScale) + { + this._super(usedScale); + cc.assert(gafSpriteProto, "Error! Missing mandatory parameter."); + this._gafproto = gafSpriteProto; + }, + + // Private + + _init : function() + { + var frame = this._gafproto.getFrame(); + cc.assert(frame instanceof cc.SpriteFrame, "Error. Wrong object type."); + + // Create sprite with custom render command from frame + this._sprite = new cc.Sprite(); + this._sprite._renderCmd = this._gafCreateRenderCmd(this._sprite); + this._sprite.initWithSpriteFrame(frame); + + this._sprite.setAnchorPoint(this._gafproto.getAnchor()); + this.addChild(this._sprite); + //this._sprite.setCascadeColorEnabled(true); + //this._sprite.setCascadeOpacityEnabled(true); + this._sprite.setOpacityModifyRGB(true); + + if(cc._renderType === cc._RENDER_TYPE_WEBGL) + this._sprite.setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + }, + + _applyState : function(state, parent) + { + this._applyStateSuper(state, parent); + if(this._needsCtx) + { + // Enable ctx state if wasn't enabled + if(!this._hasCtx) + { + this._enableCtx(); + this._hasCtx = true; + } + // Set ctx shader + this._applyCtxState(state); + } + else + { + // Disable ctx state if was enabled + if(this._hasCtx) + { + this._disableCtx(); + this._hasCtx = false; + } + // Apply color + if(!cc.colorEqual(this._sprite._realColor, this._cascadeColorMult)) + { + this._sprite.setColor(this._cascadeColorMult); + } + // Apply opacity + if(this._sprite.getOpacity() != this._cascadeColorMult.a) + { + this._sprite.setOpacity(this._cascadeColorMult.a); + } + + } + }, + + _enableCtx: function() + { + this._sprite._renderCmd._enableCtx(); + }, + + _disableCtx: function() + { + this._sprite._renderCmd._disableCtx(); + }, + + _applyCtxState: function(state){ + this._sprite._renderCmd._applyCtxState(this); + }, + + getBoundingBoxForCurrentFrame: function () + { + var result = this._sprite.getBoundingBox(); + return cc._rectApplyAffineTransformIn(result, this.getNodeToParentTransform()); + }, + + _gafCreateRenderCmd: function(item){ + if(cc._renderType === cc._RENDER_TYPE_CANVAS) + return new gaf.Sprite.CanvasRenderCmd(item); + else + return new gaf.Sprite.WebGLRenderCmd(item); + } +}); diff --git a/external/gaf/Library/GAFSpriteCanvasRenderCmd.js b/external/gaf/Library/GAFSpriteCanvasRenderCmd.js new file mode 100644 index 0000000000..26f7b0ed18 --- /dev/null +++ b/external/gaf/Library/GAFSpriteCanvasRenderCmd.js @@ -0,0 +1,233 @@ + +(function() { + gaf.Sprite.CanvasRenderCmd = function (renderable) { + cc.Sprite.CanvasRenderCmd.call(this, renderable); + this._hasTintMult = false; + this._hasTintOffset = false; + this._hasCtx = false; + this._tintMult = cc.color(255,255,255,255); + this._tintOffset = cc.color(0,0,0,0); + this._textureDirty = false; + }; + var proto = gaf.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype); + proto.constructor = gaf.Sprite.CanvasRenderCmd; + + proto._disableCtx = function(){ + this._hasTintOffset = false; + this._hasCtx = false; + this._textureDirty = true; + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); + this._tintMult = cc.color(255,255,255,255); + this._tintOffset = cc.color(0,0,0,0); + }; + + proto._enableCtx = function(){ + + }; + + proto._applyCtxState = function(gafObject){ + + var tintMult = gafObject._cascadeColorMult; + var tintOffset = gafObject._cascadeColorOffset; + var opacity = tintMult.a; + + // Apply opacity + if(this._node.getOpacity() != opacity) + { + this._node.setOpacity(opacity); + } + + // Check Tint multiplicator + var multDirty = !cc.colorEqual(this._tintMult, tintMult); + if(multDirty) + { + this._node.setColor(tintMult); + this._tintMult = tintMult; + this._hasTintMult = + (tintMult.r !== 255 || + tintMult.g !== 255 || + tintMult.b !== 255 ); + } + + // Check Tint offset + var offfsetDirty = + (this._tintOffset.r != tintOffset.r) || + (this._tintOffset.g != tintOffset.g) || + (this._tintOffset.b != tintOffset.b) || + (this._tintOffset.a != tintOffset.a); + + if(offfsetDirty) + { + this._tintOffset = tintOffset; + this._hasTintOffset = + (tintOffset.r !== 0 || + tintOffset.g !== 0 || + tintOffset.b !== 0 || + tintOffset.a !== 0 ); + } + + // Update dirty flag + this._textureDirty = multDirty || offfsetDirty; + if(this._textureDirty) + { + this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty); + } + + + this._hasCtx = gafObject._filterStack.length > 0 && gafObject._filterStack[0].type === gaf.EFFECT_COLOR_MATRIX; + + }; + + proto.rendering = function(ctx, scaleX, scaleY) + { + var node = this._node; + var locTextureCoord = this._textureCoord, + alpha = (this._displayedOpacity / 255); + + if ((node._texture && ((locTextureCoord.width === 0 || locTextureCoord.height === 0) //set texture but the texture isn't loaded. + || !node._texture._textureLoaded)) || alpha === 0) + return; + + var wrapper = ctx || cc._renderContext, + context = wrapper.getContext(); + var locX = node._offsetPosition.x, + locHeight = node._rect.height, + locWidth = node._rect.width, + locY = -node._offsetPosition.y - locHeight, + image; + + wrapper.setTransform(this._worldTransform, scaleX, scaleY); + wrapper.setCompositeOperation(this._blendFuncStr); + wrapper.setGlobalAlpha(alpha); + + if(node._flippedX || node._flippedY) + wrapper.save(); + if (node._flippedX) { + locX = -locX - locWidth; + context.scale(-1, 1); + } + if (node._flippedY) { + locY = node._offsetPosition.y; + context.scale(1, -1); + } + + image = node._texture._htmlElementObj; + + if (this._colorized) { + context.drawImage(image, + 0, 0, locTextureCoord.width,locTextureCoord.height, + locX * scaleX,locY * scaleY, locWidth * scaleX, locHeight * scaleY); + } else { + context.drawImage(image, + locTextureCoord.renderX, locTextureCoord.renderY, locTextureCoord.width, locTextureCoord.height, + locX * scaleX, locY * scaleY, locWidth * scaleX, locHeight * scaleY); + } + + if(node._flippedX || node._flippedY) + wrapper.restore(); + cc.g_NumberOfDraws++; + }; + + if(cc.sys._supportCanvasNewBlendModes){ + proto._updateColor = function () { + var displayedColor = this._displayedColor, node = this._node; + this._hasTintMult |= (displayedColor.r !== 255 || displayedColor.g !== 255 || displayedColor.b !== 255); + + // If no color changes + if(this._textureDirty) + { + this._textureDirty = false; + if (this._colorized) { + this._colorized = false; + node.texture = this._originalTexture; + } + } + else + { + return; + } + + var locElement, locTexture = node._texture, locRect = this._textureCoord; + if(this._hasTintMult) + { + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + + this._colorized = true; + if (this._hasTintOffset || this._hasCtx) displayedColor = this._tintMult; + + locElement = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, displayedColor, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.texture = locTexture; + } + } + + locTexture = node._texture; + if(this._hasTintOffset) + { + var cacheTextureForColor = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()); + if (locTexture && locRect.validRect && this._originalTexture) { + locElement = locTexture.getHtmlElementObj(); + if (!locElement) + return; + if(this._colorized) + var texRect = cc.rect(0,0,locRect.width, locRect.height); + else + texRect = locRect; + locElement = this._gafGenerateTintImage(node.texture._htmlElementObj, texRect, cacheTextureForColor, this._tintOffset, locRect); + locTexture = new cc.Texture2D(); + locTexture.initWithElement(locElement); + locTexture.handleLoadedTexture(); + node.texture = locTexture; + this._colorized = true; + } + } + + + }; + + proto._gafGenerateTintImage = function(texture, texRect, tintedImgCache, color, rect, renderCanvas){ + if (!rect) + rect = cc.rect(0, 0, texture.width, texture.height); + + // Create a new buffer if required + var w = Math.min(rect.width, tintedImgCache[0].width); + var h = Math.min(rect.height, tintedImgCache[0].height); + var buff = renderCanvas, ctx; + if (!buff) { + buff = cc.newElement("canvas"); + buff.width = w; + buff.height = h; + ctx = buff.getContext("2d"); + } else { + ctx = buff.getContext("2d"); + ctx.clearRect(0, 0, w, h); + } + ctx.save(); + + // draw a channel with alpha of the original image + ctx.globalCompositeOperation = 'source-over'; + //ctx.globalAlpha = 1; + ctx.drawImage(tintedImgCache[2], rect.x, rect.y, w, h, 0, 0, w, h); + + // draw a rect of specified color + ctx.globalCompositeOperation = 'source-in'; + ctx.fillStyle = 'rgba(' + Math.round(color.r) + ',' + Math.round(color.g) + ',' + Math.round(color.b) + ',1)'; + ctx.fillRect(0, 0, w, h); + + // add the desired image to the drawn + ctx.globalCompositeOperation = 'lighter'; + ctx.drawImage(texture, texRect.x, texRect.y, w, h, 0, 0, w, h); + + + ctx.restore(); + return buff; + + }; + } + +})(); diff --git a/external/gaf/Library/GAFSpriteProto.js b/external/gaf/Library/GAFSpriteProto.js new file mode 100644 index 0000000000..6e33fa7d5f --- /dev/null +++ b/external/gaf/Library/GAFSpriteProto.js @@ -0,0 +1,36 @@ + +gaf._SpriteProto = function(asset, atlasFrames, elementAtlasIdRef) +{ + //this._anchor = atlasFrame._gafAnchor; + //delete atlasFrame._gafAnchor; + + this.getFrames = function(){return atlasFrames}; + this.getIdRef = function(){return elementAtlasIdRef}; + //this.getAnchor = function() {return this._anchor}; + this.getAsset = function() {return asset}; + + /* + * Will construct GAFSprite + */ + this._gafConstruct = function() + { + var usedScale = this.getAsset()._usedAtlasScale; + var ret = new gaf.Sprite(this, usedScale); + ret._init(); + return ret; + }; +}; + +gaf._SpriteProto.prototype.getFrame = function() +{ + var usedScale = this.getAsset()._usedAtlasScale; + cc.assert(usedScale, "Error. Atlas scale zero."); + var frames = this.getFrames()[usedScale]; + cc.assert(frames, "Error. No frames found for used scale `"+usedScale+"`"); + return frames[this.getIdRef()]; +}; + +gaf._SpriteProto.prototype.getAnchor = function() +{ + return this.getFrame()._gafAnchor; +}; diff --git a/external/gaf/Library/GAFSpriteWebGLRenderCmd.js b/external/gaf/Library/GAFSpriteWebGLRenderCmd.js new file mode 100644 index 0000000000..eabe25b0c9 --- /dev/null +++ b/external/gaf/Library/GAFSpriteWebGLRenderCmd.js @@ -0,0 +1,132 @@ + +(function(){ + gaf.Sprite.WebGLRenderCmd = function (renderable) { + cc.Sprite.WebGLRenderCmd.call(this, renderable); + this._defualtShader = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR); + this._customShader = gaf._Shaders.Alpha; + + //this._shaderProgram = this._defualtShader; + + this._tintMult = null; + this._tintOffset = null; + this._ctxMatrixBody = null; + this._ctxMatrixAppendix = null; + }; + + var proto = gaf.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype); + proto.constructor = gaf.Sprite.WebGLRenderCmd; + + proto._identityVec = [1.0, 1.0, 1.0, 1.0]; + proto._zeroVec = [0.0, 0.0, 0.0, 0.0]; + proto._identityMat = [ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]; + + proto._disableCtx = function(){ + this.setShaderProgram(this._defualtShader); + }; + + proto._enableCtx = function(){ + this.setShaderProgram(this._customShader); + }; + + proto._applyCtxState = function(gafObject){ + var tintMult = gafObject._cascadeColorMult; + this._tintMult = [ + tintMult.r / 255, + tintMult.g / 255, + tintMult.b / 255, + tintMult.a / 255 + ]; + + var tintOffset = gafObject._cascadeColorOffset; + this._tintOffset = [ + tintOffset.r / 255, + tintOffset.g / 255, + tintOffset.b / 255, + tintOffset.a / 255 + ]; + + var filterStack = gafObject._filterStack; + if(filterStack && filterStack.length > 0 && filterStack[0].type === gaf.EFFECT_COLOR_MATRIX) + { + var m = filterStack[0].colorMatrix; + this._ctxMatrixBody = [ + m.rr, m.rg, m.rb, m.ra, + m.gr, m.gg, m.gb, m.ga, + m.br, m.bg, m.bb, m.ba, + m.ar, m.ag, m.ab, m.aa + ]; + this._ctxMatrixAppendix = [ + m.r / 255, + m.g / 255, + m.b / 255, + m.a / 255 + ]; + } + else + { + this._ctxMatrixBody = null; + this._ctxMatrixAppendix = null; + } + }; + + proto._setUniforms = function() + { + if(this._shaderProgram === this._customShader) + { + this._shaderProgram.use(); + { + this._shaderProgram.setUniformLocationWith4fv( + gaf._Uniforms.ColorTransformMult, + this._tintMult, + 1 + ); + this._shaderProgram.setUniformLocationWith4fv( + gaf._Uniforms.ColorTransformOffset, + this._tintOffset, + 1 + ); + } + + if(this._ctxMatrixBody && this._ctxMatrixAppendix) + { + this._shaderProgram.setUniformLocationWithMatrix4fv( + gaf._Uniforms.ColorMatrixBody, + this._ctxMatrixBody, + 1 + ); + this._shaderProgram.setUniformLocationWith4fv( + gaf._Uniforms.ColorMatrixAppendix, + this._ctxMatrixAppendix, + 1 + ); + } + else + { + this._shaderProgram.setUniformLocationWithMatrix4fv( + gaf._Uniforms.ColorMatrixBody, + this._identityMat, + 1 + ); + this._shaderProgram.setUniformLocationWith4fv( + gaf._Uniforms.ColorMatrixAppendix, + this._zeroVec, + 1 + ); + } + } + }; + + proto.rendering = function(ctx) + { + this._setUniforms(); + + // Super call + cc.Sprite.WebGLRenderCmd.prototype.rendering.call(this, ctx); + }; + +})(); diff --git a/external/gaf/Library/GAFTags.js b/external/gaf/Library/GAFTags.js new file mode 100644 index 0000000000..09f8186538 --- /dev/null +++ b/external/gaf/Library/GAFTags.js @@ -0,0 +1,378 @@ + +gaf.ReadSingleTag = function(stream){ + var tagId = stream.Ushort(); + var tag = gaf.Tags[tagId]; + var result = {}; + if(typeof tag === "undefined"){ + console.log("GAF. Non implemented tag detected."); + gaf.Tags.Default.parse(stream, tagId); + } + else{ + //console.log("tag " + tag.tagName); + result = tag.parse(stream, tagId); + } + return result; +}; + +gaf.ReadTags = function(stream){ + var tags = []; + try { + do { + var tag = gaf.ReadSingleTag(stream); + tags.push(tag); + } while (tag.tagId != 0); + } + catch (e){ + if (e instanceof Error && e.message == "GAF format error"){ + console.log("GAF format error:\n" + e.stack); + // Tag will be closed and parser will continue from where it should. + } + else{ + console.log(e.stack); + throw e; + } + } + return tags; +}; + + +gaf.Tag = function(){ + this.Default = Object.create(gaf.Tag.base); + this["0"] = Object.create(gaf.Tag.End); + this["1"] = Object.create(gaf.Tag.DefineAtlas); + this["2"] = Object.create(gaf.Tag.DefineAnimationMasks); + this["3"] = Object.create(gaf.Tag.DefineAnimationObjects); + this["4"] = Object.create(gaf.Tag.DefineAnimationFrames); + this["5"] = Object.create(gaf.Tag.DefineNamedParts); + this["6"] = Object.create(gaf.Tag.DefineSequences); + this["7"] = Object.create(gaf.Tag.DefineTextFields); + this["8"] = Object.create(gaf.Tag.DefineAtlas2); + this["9"] = Object.create(gaf.Tag.DefineStage); + this["10"] = Object.create(gaf.Tag.DefineAnimationObjects2); + this["11"] = Object.create(gaf.Tag.DefineAnimationMasks2); + this["12"] = Object.create(gaf.Tag.DefineAnimationFrames2); + this["13"] = Object.create(gaf.Tag.DefineTimeline); +}; + +gaf.Tag.base = function() {}; +gaf.Tag.base.parse = function(stream, tagId){ + var size = stream.Uint(); + + stream.startNestedBuffer(size); + var result = this.doParse(stream); + stream.endNestedBuffer(); + + result.tagName = this.tagName; + result.tagId = tagId; + return result; +}; +gaf.Tag.base.doParse = function(stream){ + return {}; + }; + +gaf.Tag.End = Object.create(gaf.Tag.base); +gaf.Tag.End.tagName = "TagEnd"; + +gaf.Tag.DefineAtlas = Object.create(gaf.Tag.base); +gaf.Tag.DefineAtlas.tagName = "TagDefineAtlas"; +gaf.Tag.DefineAtlas.doParse = function (s) { + var exec = s.fields( + 'scale', 'Float', + 'atlases', s.array('Ubyte', s.fields( + 'id', 'Uint', + 'sources', s.array('Ubyte', s.fields( + 'source', 'String', + 'csf', 'Float' + )) + )), + 'elements', s.array('Uint', s.fields( + 'pivot', 'Point', + 'origin', 'Point', + 'scale', 'Float', + 'size', 'Point', + 'atlasId', 'Uint', + 'elementAtlasId', 'Uint' + )) + ); + return {'content': exec()}; +}; + +gaf.Tag.DefineAnimationMasks = Object.create(gaf.Tag.base); +gaf.Tag.DefineAnimationMasks.tagName = "TagDefineAnimationMasks"; +gaf.Tag.DefineAnimationMasks.doParse = function (s) { + var exec = s.array('Uint', s.fields( + 'objectId', 'Uint', + 'elementAtlasIdRef', 'Uint' + )); + var result = {'content': exec()}; + debugger; + return result; +}; + +gaf.Tag.DefineAnimationObjects = Object.create(gaf.Tag.base); +gaf.Tag.DefineAnimationObjects.tagName = "TagDefineAnimationObjects"; +gaf.Tag.DefineAnimationObjects.doParse = function (s) { + var exec = s.array('Uint', s.fields( + 'objectId', 'Uint', + 'elementAtlasIdRef', 'Uint' + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineAnimationFrames = Object.create(gaf.Tag.base); +gaf.Tag.DefineAnimationFrames.tagName = "TagDefineAnimationFrames"; +gaf.Tag.DefineAnimationFrames.doParse = function(s){ + var exec = s.array('Uint', s.fields( + 'frame', 'Uint', + 'state', s.array('Uint', s.fields( + 'hasColorTransform', 'Ubyte', + 'hasMask', 'Ubyte', + 'hasEffect', 'Ubyte', + 'objectIdRef', 'Uint', + 'depth', 'Int', + 'alpha', 'Float', + 'matrix', 'Matrix', + 'colorTransform', s.condition('hasColorTransform', 1, s.fields( + 'alphaOffset', 'Float', + 'redMultiplier', 'Float', + 'redOffset', 'Float', + 'greenMultiplier', 'Float', + 'greenOffset', 'Float', + 'blueMultiplier', 'Float', + 'blueOffset', 'Float' + )), + 'effect', s.condition('hasEffect', 1, s.array('Ubyte', gaf.Tag._readFilter(s))), + 'maskObjectIdRef', s.condition('hasMask', 1, s.fields( + 'maskObjectIdRef', 'Uint' + )) + )) + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineNamedParts = Object.create(gaf.Tag.base); +gaf.Tag.DefineNamedParts.tagName = "TagDefineNamedParts"; +gaf.Tag.DefineNamedParts.doParse = function(s) { + var exec = s.array('Uint', s.fields( + 'objectId', 'Uint', + 'name', 'String' + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineSequences = Object.create(gaf.Tag.base); +gaf.Tag.DefineSequences.tagName = "TagDefineSequences"; +gaf.Tag.DefineSequences.doParse = function(s) { + var exec = s.array('Uint', s.fields( + 'id', 'String', + 'start', 'Ushort', + 'end', 'Ushort' + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineTextFields = Object.create(gaf.Tag.base); +gaf.Tag.DefineTextFields.tagName = "TagDefineTextFields"; +gaf.Tag.DefineTextFields.doParse = function(s) { + var exec = s.array('Uint', s.fields( + 'id', 'Uint', + 'pivot', 'Point', + 'end', 'Ushort', + 'width', 'Float', + 'height', 'Float', + 'text', 'String', + 'embedFonts', 'Boolean', + 'multiline', 'Boolean', + 'wordWrap', 'Boolean', + 'hasRestrict', 'Boolean', + 'restrict', s.condition('hasRestrict', 1, function (){return s['String'];}), + 'editable', 'Boolean', + 'selectable', 'Boolean', + 'displayAsPassword', 'Boolean', + 'maxChars', 'Uint', + 'align', 'Uint', + 'blockIndent', 'Uint', + 'bold', 'Boolean', + 'bullet', 'Boolean', + 'color', 'color', + 'font', 'String', + 'indent', 'Uint', + 'italic', 'Boolean', + 'kerning', 'Boolean', + 'leading', 'Uint', + 'leftMargin', 'Uint', + 'letterSpacing', 'Float', + 'rightMargin', 'Uint', + 'size', 'Uint', + 'tabStops', s.array('Uint', s.fields( + 'value', 'Uint' + )), + 'target', 'string', + 'underline', 'Boolean', + 'url', 'String' + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineAtlas2 = Object.create(gaf.Tag.base); +gaf.Tag.DefineAtlas2.tagName = "TagDefineAtlas2"; +gaf.Tag.DefineAtlas2.doParse = function(s) { + var exec = s.fields( + 'scale', 'Float', + 'atlases', s.array('Ubyte', s.fields( + 'id', 'Uint', + 'sources', s.array('Ubyte', s.fields( + 'source', 'String', + 'csf', 'Float' + )) + )), + 'elements', s.array('Uint', s.fields( + 'pivot', 'Point', + 'origin', 'Point', + 'scale', 'Float', + 'size', 'Point', + 'atlasId', 'Uint', + 'elementAtlasId', 'Uint', + 'hasScale9Grid', 'Boolean', + 'scale9GridRect', s.condition('hasScale9Grid', 1, function(){return s.Rect();}) + )) + ); + return {'content': exec()}; +}; + +gaf.Tag.DefineStage = Object.create(gaf.Tag.base); +gaf.Tag.DefineStage.tagName = "TagDefineStage"; +gaf.Tag.DefineStage.doParse = function(s) { + var exec = s.fields( + 'fps', 'Ubyte', + 'color', 'color', + 'width', 'Ushort', + 'height', 'Ushort' + ); + return {'content': exec()}; +}; + +gaf.Tag.DefineAnimationObjects2 = Object.create(gaf.Tag.base); +gaf.Tag.DefineAnimationObjects2.tagName = "TagDefineAnimationObjects2"; +gaf.Tag.DefineAnimationObjects2.doParse = function(s) { + var exec = s.array('Uint', s.fields( + 'objectId', 'Uint', + 'elementAtlasIdRef', 'Uint', + 'type', 'Ushort' + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineAnimationMasks2 = Object.create(gaf.Tag.base); +gaf.Tag.DefineAnimationMasks2.tagName = "TagDefineAnimationMasks2"; +gaf.Tag.DefineAnimationMasks2.doParse = function(s) { + var exec = s.array('Uint', s.fields( + 'objectId', 'Uint', + 'elementAtlasIdRef', 'Uint', + 'type', 'Ushort' + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineAnimationFrames2 = Object.create(gaf.Tag.base); +gaf.Tag.DefineAnimationFrames2.tagName = "TagDefineAnimationFrames2"; +gaf.Tag.DefineAnimationFrames2.doParse = function(s) { + var exec = s.array('Uint', s.fields( + 'frame', 'Uint', + 'hasChangesInDisplayList', 'Boolean', + 'hasActions', 'Boolean', + 'state', s.condition('hasChangesInDisplayList', 1, s.array('Uint', s.fields( + 'hasColorTransform', 'Boolean', + 'hasMask', 'Boolean', + 'hasEffect', 'Boolean', + 'objectIdRef', 'Uint', + 'depth', 'Int', + 'alpha', 'Float', + 'matrix', 'Matrix', + 'colorTransform', s.condition('hasColorTransform', 1, s.fields( + 'alphaOffset', 'Float', + 'redMultiplier', 'Float', + 'redOffset', 'Float', + 'greenMultiplier', 'Float', + 'greenOffset', 'Float', + 'blueMultiplier', 'Float', + 'blueOffset', 'Float' + )), + 'effect', s.condition('hasEffect', 1, s.array('Ubyte', gaf.Tag._readFilter(s))), + 'maskObjectIdRef', s.condition('hasMask', 1, function(){return s.Uint()}) + ))), + 'actions', s.condition('hasActions', 1, s.array('Uint', s.fields( + 'type', 'Uint', + 'scope', 'String', + 'params', gaf.Tag._readActionArguments(s) + ))) + )); + return {'content': exec()}; +}; + +gaf.Tag.DefineTimeline = Object.create(gaf.Tag.base); +gaf.Tag.DefineTimeline.tagName = "TagDefineTimeline"; +gaf.Tag.DefineTimeline.doParse = function(s) { + var exec = s.fields( + 'id', 'Uint', + 'animationFrameCount', 'Uint', + 'boundingBox', 'Rect', + 'pivotPoint', 'Point', + 'hasLinkage', 'Boolean', + 'linkageName', s.condition('hasLinkage', 1, function () { + return s.String(); + }) + ); + var result = {'content': exec()}; + result.content.tags = gaf.ReadTags(s); + return result; +}; + +gaf.Tag._readActionArguments = function(s){ + return function(){ + var size = s.Uint(); + var ret = []; + s.startNestedBuffer(size); + while(s.maxOffset() < s.tell()){ + ret.push(s.String()); + } + s.endNestedBuffer(); + return ret; + }; +}; + +gaf.Tag._readFilter = function(s){ + return s.fields( + 'type', 'Uint', + 'dropShadow', s.condition('type', gaf.EFFECT_DROP_SHADOW, s.fields( // DropShadow + 'color', 'color', + 'blurX', 'Float', + 'blurY', 'Float', + 'angle', 'Float', + 'distance', 'Float', + 'strength', 'Float', + 'inner', 'Boolean', + 'knockout', 'Boolean' + )), + 'blur', s.condition('type', gaf.EFFECT_BLUR, s.fields( // Blur + 'blurX', 'Float', + 'blurY', 'Float' + )), + 'glow', s.condition('type', gaf.EFFECT_GLOW, s.fields( // Glow + 'color', 'color', + 'blurX', 'Float', + 'blurY', 'Float', + 'strength', 'Float', + 'inner', 'Boolean', + 'knockout', 'Boolean' + )), + 'colorMatrix', s.condition('type', gaf.EFFECT_COLOR_MATRIX, s.fields( // ColorMatrix + 'rr', 'Float', 'gr', 'Float', 'br', 'Float', 'ar', 'Float', 'r', 'Float', + 'rg', 'Float', 'gg', 'Float', 'bg', 'Float', 'ag', 'Float', 'g', 'Float', + 'rb', 'Float', 'gb', 'Float', 'bb', 'Float', 'ab', 'Float', 'b', 'Float', + 'ra', 'Float', 'ga', 'Float', 'ba', 'Float', 'aa', 'Float', 'a', 'Float' + )) + ) +}; + +gaf.Tags = new gaf.Tag(); diff --git a/external/gaf/Library/GAFTextField.js b/external/gaf/Library/GAFTextField.js new file mode 100644 index 0000000000..04f9744920 --- /dev/null +++ b/external/gaf/Library/GAFTextField.js @@ -0,0 +1,6 @@ + +gaf.TextField = gaf.Object.extend +({ + _className: "GAFTextField" + +}); \ No newline at end of file diff --git a/external/gaf/Library/GAFTimeLine.js b/external/gaf/Library/GAFTimeLine.js new file mode 100644 index 0000000000..ef9387aa46 --- /dev/null +++ b/external/gaf/Library/GAFTimeLine.js @@ -0,0 +1,547 @@ + +gaf.TimeLine = gaf.Object.extend +({ + _className: "GAFTimeLine", + _objects: null, + _container: null, + _animationStartedNextLoopDelegate: null, + _animationFinishedPlayDelegate: null, + _framePlayedDelegate: null, + _sequenceDelegate: null, + _fps: 60, + _frameTime: 1/60, + _currentSequenceStart: gaf.FIRST_FRAME_INDEX, + _currentSequenceEnd: gaf.FIRST_FRAME_INDEX, + _totalFrameCount: 0, + _isRunning: false, + _isLooped: false, + _isReversed: false, + _timeDelta: 0, + _animationsSelectorScheduled: false, + _currentFrame: gaf.FIRST_FRAME_INDEX, + + + setAnimationStartedNextLoopDelegate: function (delegate) + { + this._animationStartedNextLoopDelegate = delegate; + }, + setAnimationFinishedPlayDelegate: function (delegate) + { + this._animationFinishedPlayDelegate = delegate; + }, + setLooped: function (looped, recursively) + { + this._isLooped = looped; + if (recursively) + { + this._objects.forEach(function (item) + { + item.setLooped(looped, recursively); + }); + } + }, + getBoundingBoxForCurrentFrame: function () + { + var result = null;//cc.rect(); + var isFirstObj = true; + this._objects.forEach(function (item) { + if(item.isVisibleInCurrentFrame() && item.isVisible()) + { + var bb = item.getBoundingBoxForCurrentFrame(); + if(!bb) + { + bb = item.getBoundingBox(); + } + if (isFirstObj) + { + isFirstObj = false; + result = bb; + } + else + { + result = cc.rectUnion(result, bb); + } + } + }); + return cc._rectApplyAffineTransformIn(result, this._container.getNodeToParentTransform()); + }, + setFps: function (fps) + { + cc.assert(fps !== 0, 'Error! Fps is set to zero.'); + this._fps = fps; + this._frameTime = 1/fps; + }, + getObjectByName: function (name) + { + var elements = name.split('.'); + var result = null; + var retId = -1; + var timeLine = this; + var BreakException = {}; + try + { + elements.forEach(function(element) + { + var parts = timeLine._gafproto.getNamedParts(); + if(parts.hasOwnProperty(element)) + { + retId = parts[element]; + } + else + { + // Sequence is incorrect + BreakException.lastElement = element; + throw BreakException; + } + result = timeLine._objects[retId]; + timeLine = result; + }); + } + catch (e) + { + if (e!==BreakException) + { + throw e; + } + cc.log("Sequence incorrect: `" + name + "` At: `" + BreakException.lastElement + "`"); + return null; + } + return result; + }, + clearSequence: function () + { + this._currentSequenceStart = gaf.FIRST_FRAME_INDEX; + this._currentSequenceEnd = this._gafproto.getTotalFrames(); + }, + getIsAnimationRunning: function () + { + return this._isRunning; + }, + gotoAndStop: function (value) + { + var frame = 0; + if (typeof value === 'string') + { + frame = this.getStartFrame(value); + } + else + { + frame = value; + } + if (this.setFrame(frame)) + { + this.setAnimationRunning(false, false); + return true; + } + return false; + }, + gotoAndPlay: function (value) + { + var frame = 0; + if (typeof value === 'string') + { + frame = this.getStartFrame(value); + } + else + { + frame = value; + } + if (this.setFrame(frame)) + { + this.setAnimationRunning(true, false); + return true; + } + return false; + }, + getStartFrame: function (frameLabel) + { + var seq = this._gafproto.getSequences()[frameLabel]; + if (seq) + { + return seq.start; + } + return gaf.IDNONE; + }, + getEndFrame: function (frameLabel) + { + var seq = this._gafproto.getSequences()[frameLabel]; + if (seq) + { + return seq.end; + } + return gaf.IDNONE; + }, + setFramePlayedDelegate: function (delegate) + { + this._framePlayedDelegate = delegate; + }, + getCurrentFrameIndex: function () + { + return this._showingFrame; + }, + getTotalFrameCount: function () + { + return this._gafproto.getTotalFrames(); + }, + start: function () + { + this._enableTick(true); + if (!this._isRunning) + { + this._currentFrame = gaf.FIRST_FRAME_INDEX; + this.setAnimationRunning(true, true); + } + }, + stop: function () + { + this._enableTick(false); + if (this._isRunning) + { + this._currentFrame = gaf.FIRST_FRAME_INDEX; + this.setAnimationRunning(false, true); + } + }, + isDone: function () + { + if (this._isLooped) + { + return false; + } + else + { + if (!this._isReversed) + { + return this._currentFrame > this._totalFrameCount; + } + else + { + return this._currentFrame < gaf.FIRST_FRAME_INDEX - 1; + } + } + }, + getSequences: function() + { + return this._gafproto.getSequences(); + }, + playSequence: function (name, looped) + { + var s = this.getStartFrame(name); + var e = this.getEndFrame(name); + if (gaf.IDNONE === s || gaf.IDNONE === e) + { + return false; + } + this._currentSequenceStart = s; + this._currentSequenceEnd = e; + if (this._currentFrame < this._currentSequenceStart || this._currentFrame > this._currentSequenceEnd) + { + this._currentFrame = this._currentSequenceStart; + } + else + { + this._currentFrame = this._currentSequenceStart; + } + this.setLooped(looped, false); + this.resumeAnimation(); + return true; + }, + isReversed: function () + { + return this._isReversed; + }, + setSequenceDelegate: function (delegate) + { + this._sequenceDelegate = delegate; + }, + setFrame: function (index) + { + if (index >= gaf.FIRST_FRAME_INDEX && index < this._totalFrameCount) + { + this._showingFrame = index; + this._currentFrame = index; + this._processAnimation(); + return true; + } + return false; + }, + + pauseAnimation: function () + { + if (this._isRunning) + { + this.setAnimationRunning(false, false); + } + }, + isLooped: function () + { + return this._isLooped; + }, + resumeAnimation: function () + { + if (!this._isRunning) + { + this.setAnimationRunning(true, false); + } + }, + setReversed: function (reversed) + { + this._isReversed = reversed; + }, + hasSequences: function () + { + return this._gafproto.getSequences().length > 0; + }, + getFps: function () + { + return this._fps; + }, + + + // Private + + ctor: function(gafTimeLineProto, scale) + { + this._super(scale); + this._objects = []; + cc.assert(gafTimeLineProto, "Error! Missing mandatory parameter."); + this._gafproto = gafTimeLineProto; + }, + + setExternalTransform: function(affineTransform) + { + if(!cc.affineTransformEqualToTransform(this._container._additionalTransform, affineTransform)) + { + this._container.setAdditionalTransform(affineTransform); + } + }, + + _init: function() + { + this.setContentSize(this._gafproto.getBoundingBox()); + this._currentSequenceEnd = this._gafproto.getTotalFrames(); + this._totalFrameCount = this._currentSequenceEnd; + this.setFps(this._gafproto.getFps()); + this._container = new cc.Node(); + this.addChild(this._container); + + var self = this; + var asset = this._gafproto.getAsset(); + + // Construct objects for current time line + this._gafproto.getObjects().forEach(function(object) + { + var objectProto = asset._getProtos()[object]; + cc.assert(objectProto, "Error. GAF proto for type: " + object.type + " and reference id: " + object + " not found."); + self._objects[object] = objectProto._gafConstruct(); + }); + }, + + _enableTick: function(val) + { + if (!this._animationsSelectorScheduled && val) + { + this.schedule(this._processAnimations); + this._animationsSelectorScheduled = true; + } + else if (this._animationsSelectorScheduled && !val) + { + this.unschedule(this._processAnimations); + this._animationsSelectorScheduled = false; + } + }, + + _processAnimations: function (dt) + { + this._timeDelta += dt; + while (this._timeDelta >= this._frameTime) + { + this._timeDelta -= this._frameTime; + this._step(); + } + }, + + _step: function () + { + this._showingFrame = this._currentFrame; + + if(!this.getIsAnimationRunning()) + { + this._processAnimation(); + return; + } + + if(this._sequenceDelegate) + { + var seq; + if(!this._isReversed) + { + seq = this._getSequenceByLastFrame(this._currentFrame); + } + else + { + seq = this._getSequenceByFirstFrame(this._currentFrame + 1); + } + + if (seq) + { + this._sequenceDelegate(this, seq); + } + } + if (this._isCurrentFrameLastInSequence()) + { + if(this._isLooped) + { + if(this._animationStartedNextLoopDelegate) + this._animationStartedNextLoopDelegate(this); + } + else + { + this.setAnimationRunning(false, false); + if(this._animationFinishedPlayDelegate) + this._animationFinishedPlayDelegate(this); + } + } + this._processAnimation(); + this._currentFrame = this._nextFrame(); + }, + + _isCurrentFrameLastInSequence: function() + { + if (this._isReversed) + return this._currentFrame == this._currentSequenceStart; + return this._currentFrame == this._currentSequenceEnd - 1; + }, + + _nextFrame: function() + { + if (this._isCurrentFrameLastInSequence()) + { + if (!this._isLooped) + return this._currentFrame; + + if (this._isReversed) + return this._currentSequenceEnd - 1; + else + return this._currentSequenceStart; + } + + return this._currentFrame + (this._isReversed ? -1 : 1); + }, + + _processAnimation: function () + { + //var id = this._gafproto.getId(); + this._realizeFrame(this._container, this._currentFrame); + if (this._framePlayedDelegate) + { + this._framePlayedDelegate(this, this._currentFrame); + } + }, + _realizeFrame: function(out, frameIndex) + { + var self = this; + var objects = self._objects; + var frames = self._gafproto.getFrames(); + if(frameIndex > frames.length) + { + return; + } + var currentFrame = frames[frameIndex]; + if(!currentFrame) + { + return; + } + var states = currentFrame.states; + for(var stateIdx = 0, total = states.length; stateIdx < total; ++stateIdx) + { + var state = states[stateIdx]; + var object = objects[state.objectIdRef]; + if(!object) + { + return; + } + if(state.alpha < 0) + { + object._resetState(); + } + object._updateVisibility(state, self); + if(!object.isVisible()) + { + continue; + } + object._applyState(state, self); + var parent = out; + if(state.hasMask) + { + parent = objects[state.maskObjectIdRef]._getNode(); + cc.assert(parent, "Error! Mask not found."); + } + object._lastVisibleInFrame = 1 + frameIndex; + gaf.TimeLine.rearrangeSubobject(parent, object, state.depth); + if(object._step) + { + object._step(); + } + } + }, + setAnimationRunning: function (value, recursively) + { + this._isRunning = value; + if(recursively) + { + this._objects.forEach(function (obj) + { + if (obj && obj.setAnimationRunning) + { + obj.setAnimationRunning(value, recursively); + } + }); + } + }, + + _getSequenceByLastFrame: function(){ + var sequences = this._gafproto.getSequences(); + for(var item in sequences){ + if(sequences.hasOwnProperty(item)){ + if(sequences[item].end === frame + 1) + { + return item; + } + } + } + return ""; + }, + + _resetState : function() + { + this._super(); + this._currentFrame = this._currentSequenceStart; + }, + + _getSequenceByFirstFrame: function(){ + var sequences = this._gafproto.getSequences(); + for(var item in sequences){ + if(sequences.hasOwnProperty(item)){ + if(sequences[item].start === frame) + { + return item; + } + } + } + return ""; + } +}); + +gaf.TimeLine.rearrangeSubobject = function(out, object, depth) +{ + var parent = object.getParent(); + if (parent !== out) + { + object.removeFromParent(false); + out.addChild(object, depth); + } + else + { + object.setLocalZOrder(depth); + } +}; diff --git a/external/gaf/Library/GAFTimeLineProto.js b/external/gaf/Library/GAFTimeLineProto.js new file mode 100644 index 0000000000..9d78b219d9 --- /dev/null +++ b/external/gaf/Library/GAFTimeLineProto.js @@ -0,0 +1,32 @@ + +gaf._TimeLineProto = function(asset, animationFrameCount, boundingBox, pivotPoint, id, linkageName) +{ + id = typeof id != 'undefined' ? id : 0; + linkageName = linkageName || ""; + + this._objects = []; + + this.getTotalFrames = function(){return animationFrameCount}; + this.getBoundingBox = function() {return boundingBox}; + this.getId = function() {return id}; + this.getLinkageName = function() {return linkageName}; + this.getPivot = function(){return pivotPoint}; + this.getRect = function(){return boundingBox}; + this.getNamedParts = function() {return {}}; // Map name -> id + this.getSequences = function() {return {}}; // Map name -> {start, end} + this.getFrames = function(){return []}; // Array {states, actions} + this.getFps = function(){return 60}; + this.getObjects = function(){return this._objects}; + this.getAsset = function(){return asset}; + + /* + * Will construct GAFTimeLine + */ + this._gafConstruct = function() + { + var usedScale = this.getAsset()._usedAtlasScale; + var ret = new gaf.TimeLine(this, usedScale); + ret._init(); + return ret; + }; +}; diff --git a/external/gaf/gaf_viewer.css b/external/gaf/gaf_viewer.css new file mode 100644 index 0000000000..60933161d2 --- /dev/null +++ b/external/gaf/gaf_viewer.css @@ -0,0 +1,42 @@ +#drop_zone { + border: 2px dashed #bbb; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + padding: 25px; + text-align: center; + font: 20pt bold 'Vollkorn'; + color: #bbb; + +} +.renderjson a { + text-decoration: none; +} +.renderjson .disclosure { + color: crimson; + font-size: 150%; +} +.renderjson .syntax { + color: grey; +} +.renderjson .string { + color: darkred; +} +.renderjson .number { + color: darkcyan; +} +.renderjson .boolean { + color: blueviolet; +} +.renderjson .key { + color: darkblue; +} +.renderjson .keyword { + color: blue; +} +.renderjson .object.syntax { + color: lightseagreen; +} +.renderjson .array.syntax { + color: orange; +} diff --git a/external/gaf/gaf_viewer.html b/external/gaf/gaf_viewer.html new file mode 100644 index 0000000000..2c66aeb05f --- /dev/null +++ b/external/gaf/gaf_viewer.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + +

    Drop GAF here
    + + + + + + \ No newline at end of file diff --git a/external/gaf/gaf_viewer.js b/external/gaf/gaf_viewer.js new file mode 100644 index 0000000000..db5bdbea7f --- /dev/null +++ b/external/gaf/gaf_viewer.js @@ -0,0 +1,219 @@ + /* + * Created by Teivaz on 29.11.2014. + * Thanks to David Caldwell for `renderjson` + */ +function handleFileSelect(evt) { + evt.stopPropagation(); + evt.preventDefault(); + + var files = evt.dataTransfer.files; + + var output = []; + for (var i = 0, f; f = files[i]; i++) { + var name = escape(f.name); + var ext = name.split('.').pop(); + if (ext == 'gaf') { + var reader = new FileReader(); + reader.onload = (function(theFile) { + return function(req) { + var arrayBuffer = new gaf.DataReader(req.target.result); + var loader = new gaf.Loader(); + var data = loader.LoadStream(arrayBuffer); + document.getElementById('list').appendChild(renderjson(data)); + }; + })(f); + reader.readAsArrayBuffer(f); + } + } +} + +function handleDragOver(evt) { + evt.stopPropagation(); + evt.preventDefault(); + evt.dataTransfer.dropEffect = 'copy'; +} + +var dropZone = document.getElementById('drop_zone'); +dropZone.addEventListener('dragover', handleDragOver, false); +dropZone.addEventListener('drop', handleFileSelect, false); + +var module; +(module || {}).exports = renderjson = (function() { + var themetext = function( /* [class, text]+ */ ) { + var spans = []; + while (arguments.length) + spans.push(append(span(Array.prototype.shift.call(arguments)), + text(Array.prototype.shift.call(arguments)))); + return spans; + }; + var append = function( /* el, ... */ ) { + var el = Array.prototype.shift.call(arguments); + for (var a = 0; a < arguments.length; a++) + if (arguments[a].constructor == Array) + append.apply(this, [el].concat(arguments[a])); + else + el.appendChild(arguments[a]); + return el; + }; + var prepend = function(el, child) { + el.insertBefore(child, el.firstChild); + return el; + }; + var isempty = function(obj) { + for (var k in obj) + if (obj.hasOwnProperty(k)) return false; + return true; + }; + var text = function(txt) { + return document.createTextNode(txt) + }; + var div = function() { + return document.createElement("div") + }; + var span = function(classname) { + var s = document.createElement("span"); + if (classname) s.className = classname; + return s; + }; + var A = function A(txt, classname, callback) { + var a = document.createElement("a"); + if (classname) a.className = classname; + a.appendChild(text(txt)); + a.href = '#'; + a.onclick = function() { + callback(); + return false; + }; + return a; + }; + + function _renderjson(json, indent, dont_indent, show_level, sort_objects) { + var my_indent = dont_indent ? "" : indent; + + if (json === null) return themetext(null, my_indent, "keyword", "null"); + if (json === void 0) return themetext(null, my_indent, "keyword", "undefined"); + if (typeof(json) != "object") // Strings, numbers and bools + return themetext(null, my_indent, typeof(json), JSON.stringify(json)); + + var disclosure = function(open, close, type, builder) { + var content; + var empty = span(type); + var show = function() { + if (!content) append(empty.parentNode, + content = prepend(builder(), + A(renderjson.hide, "disclosure", + function() { + content.style.display = "none"; + empty.style.display = "inline"; + }))); + content.style.display = "inline"; + empty.style.display = "none"; + }; + + function isColor(a){ + return a.hasOwnProperty('a') && a.hasOwnProperty('r') && a.hasOwnProperty('g') && a.hasOwnProperty('b'); + } + + var color_rect = span(); + if (json.hasOwnProperty("tagName")) + var placeholder = json.tagName; + else if (json.hasOwnProperty("header")) + placeholder = " GAF v" + json.header.versionMajor + "." + json.header.versionMinor + " "; + else if (json.constructor == Array) + placeholder = " " + json.length + " "; + else if (json.hasOwnProperty("id")) + placeholder = " id:" + json.id + " ... "; + else if (json.hasOwnProperty("objectId")) + placeholder = " id:" + json.objectId + " ... "; + else if (json.hasOwnProperty("frame")) + placeholder = " frame:" + json.frame + " ... "; + else if(isColor(json)){ + color_rect.style.backgroundColor = "rgba("+json.r+","+json.g+","+json.b+","+json.a / 255.0+")";// parseInt(json.r).toString(16) + parseInt(json.g).toString(16) + parseInt(json.b).toString(16); + color_rect.style.height = '10px'; + color_rect.style.width = '10px'; + color_rect.style.display = 'inline-block'; + color_rect.style.margin = '0 4px'; + color_rect.style.border = '1px solid #7f7f7f'; + } + + placeholder = placeholder || ' ... '; + append(empty, + A(renderjson.show, "disclosure", show), + color_rect, + themetext(type + " syntax", open), + A(placeholder, null, show), + themetext(type + " syntax", close)); + + var el = append(span(), text(my_indent.slice(0, -1)), empty); + if (show_level > 0) + show(); + return el; + }; + + if (json.constructor == Array) { + if (json.length == 0) return themetext(null, my_indent, "array syntax", "[]"); + + return disclosure("[", "]", "array", function() { + var as = append(span("array"), themetext("array syntax", "[", null, "\n")); + for (var i = 0; i < json.length; i++) + append(as, + _renderjson(json[i], indent + " ", false, show_level - 1, sort_objects), + i != json.length - 1 ? themetext("syntax", ",") : [], + text("\n")); + append(as, themetext(null, indent, "array syntax", "]")); + return as; + }); + } + + // object + if (isempty(json)) + return themetext(null, my_indent, "object syntax", "{}"); + + + return disclosure("{", "}", "object", function() { + var os = append(span("object"), themetext("object syntax", "{", null, "\n")); + for (var k in json) var last = k; + var keys = Object.keys(json); + if (sort_objects) + keys = keys.sort(); + for (var i in keys) { + var k = keys[i]; + append(os, themetext(null, indent + " ", "key", '"' + k + '"', "object syntax", ': '), + _renderjson(json[k], indent + " ", true, show_level - 1, sort_objects), + k != last ? themetext("syntax", ",") : [], + text("\n")); + } + append(os, themetext(null, indent, "object syntax", "}")); + return os; + }); + } + + var renderjson = function renderjson(json) { + var pre = append(document.createElement("pre"), _renderjson(json, "", false, renderjson.show_to_level, renderjson.sort_objects)); + pre.className = "renderjson"; + return pre; + }; + renderjson.set_icons = function(show, hide) { + renderjson.show = show; + renderjson.hide = hide; + return renderjson; + }; + renderjson.set_show_to_level = function(level) { + renderjson.show_to_level = typeof level == "string" && + level.toLowerCase() === "all" ? Number.MAX_VALUE : level; + return renderjson; + }; + renderjson.set_sort_objects = function(sort_bool) { + renderjson.sort_objects = sort_bool; + return renderjson; + }; + // Backwards compatiblity. Use set_show_to_level() for new code. + renderjson.set_show_by_default = function(show) { + renderjson.show_to_level = show ? Number.MAX_VALUE : 0; + return renderjson; + }; + renderjson.set_icons('⊕', '⊖'); + renderjson.set_show_by_default(false); + renderjson.set_sort_objects(false); + return renderjson; +})(); \ No newline at end of file diff --git a/moduleConfig.json b/moduleConfig.json index 0419870439..a089e198d8 100644 --- a/moduleConfig.json +++ b/moduleConfig.json @@ -432,6 +432,30 @@ "extensions/spine/CCSkeletonCanvasRenderCmd.js", "extensions/spine/CCSkeletonWebGLRenderCmd.js" ], + "gaf":[ + "core", + + "external/gaf/GAFMacros.js", + "external/gaf/GAFBoot.js", + "external/gaf/Library/GAFAssetPreload.js", + "external/gaf/Library/GAFAsset.js", + "external/gaf/Library/GAFObject.js", + "external/gaf/Library/GAFTimeLine.js", + "external/gaf/Library/GAFTextField.js", + "external/gaf/Library/GAFSprite.js", + "external/gaf/Library/GAFMask.js", + "external/gaf/Library/GAFSpriteCanvasRenderCmd.js", + "external/gaf/Library/GAFSpriteWebGLRenderCmd.js", + "external/gaf/Library/GAFTimeLineProto.js", + "external/gaf/Library/GAFSpriteProto.js", + "external/gaf/Library/GAFMaskProto.js", + "external/gaf/Library/GAFTags.js", + "external/gaf/Library/GAFLoader.js", + "external/gaf/Library/GAFDataReader.js", + "external/gaf/Library/GAFShaders.js", + "external/gaf/Library/GAFShaderManager.js", + "external/gaf/Library/GAFAtlasLoader.js" + ], "extensions" : ["gui", "ccbreader", "editbox", "cocostudio", "spine", "ccpool"], "box2d" : [ @@ -447,7 +471,7 @@ "socketio" : [ "external/socketio/socket.io.min.js" ], - "external" : ["box2d", "chipmunk", "socketio", "pluginx"] + "external" : ["box2d", "chipmunk", "socketio", "pluginx", "gaf"] }, "bootFile" : "CCBoot.js" } \ No newline at end of file From cc90c2a13e94fb758862dc3d3dde43efde846aa0 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 24 Apr 2015 16:20:21 +0800 Subject: [PATCH 1541/1564] Fixed a bug that resume audio error --- cocos2d/audio/CCAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 4a8296e365..e3890afd59 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -280,7 +280,7 @@ cc.Audio = cc.Class.extend({ audio["connect"](this._volume); audio.loop = this.loop; this._startTime = this._context.currentTime; - this._currentTime = 0; + this._currentTime = offset || 0; /* * Safari on iOS 6 only supports noteOn(), noteGrainOn(), and noteOff() now.(iOS 6.1.3) From 6a9327c2734ea5b6627ccc8d775edf0237b77eb3 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 24 Apr 2015 17:03:59 +0800 Subject: [PATCH 1542/1564] To fix a bug about the Sprite set texture cann't update contentsize --- cocos2d/core/sprites/CCSprite.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index cf138f0633..7dd5fede71 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -962,8 +962,6 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _changeRectWithTexture: function(rect){ if(!rect || (!rect.width && !rect.height)) return; - var textureRect = this.getTextureRect(); - if(textureRect.height || textureRect.width) return; rect.x = rect.x || 0; rect.y = rect.y || 0; rect.width = rect.width || 0; From 3d0f26a33e573386b759012c3af15ad48f649888 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 24 Apr 2015 17:39:42 +0800 Subject: [PATCH 1543/1564] To fix a bug about the Sprite set texture cann't update contentsize --- cocos2d/core/sprites/CCSprite.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index 7dd5fede71..cf138f0633 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -962,6 +962,8 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ _changeRectWithTexture: function(rect){ if(!rect || (!rect.width && !rect.height)) return; + var textureRect = this.getTextureRect(); + if(textureRect.height || textureRect.width) return; rect.x = rect.x || 0; rect.y = rect.y || 0; rect.width = rect.width || 0; From 4fd5b40015787ca335aca2582a38bedebf94343d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Fri, 24 Apr 2015 18:03:38 +0800 Subject: [PATCH 1544/1564] To fix a bug about the Sprite set texture cann't update contentsize --- cocos2d/core/sprites/CCSprite.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index cf138f0633..b6662b3455 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -941,12 +941,14 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ if(!texture._textureLoaded){ texture.addEventListener("load", function(){ + this._clearRect(); this._renderCmd._setTexture(texture); this._changeRectWithTexture(texture.getContentSize()); this.setColor(this._realColor); this._textureLoaded = true; }, this); }else{ + this._clearRect(); this._renderCmd._setTexture(texture); this._changeRectWithTexture(texture.getContentSize()); this.setColor(this._realColor); @@ -955,11 +957,25 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{ }else{ // CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet cc.assert(texture instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2); + this._clearRect(); this._changeRectWithTexture(texture.getContentSize()); this._renderCmd._setTexture(texture); } }, + _clearRect: function(){ + var texture = this._texture; + if(texture){ + var textureRect = texture._contentSize; + var spriteRect = this._rect; + if( + textureRect.width === spriteRect.width && + textureRect.height === spriteRect.height + ) + spriteRect.width = spriteRect.height = 0; + } + }, + _changeRectWithTexture: function(rect){ if(!rect || (!rect.width && !rect.height)) return; var textureRect = this.getTextureRect(); From 6f46817c467085bae801e86be4dec1a1a716b438 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 26 Apr 2015 08:50:43 +0800 Subject: [PATCH 1545/1564] Fixed Scale9Sprite's children doesn't get transformed recursively --- extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js | 2 +- .../gui/control-extension/CCScale9SpriteCanvasRenderCmd.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js index ceab4aeb03..33dca3d05a 100644 --- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +++ b/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js @@ -73,7 +73,7 @@ var children = node._children; for(var i=0; i Date: Sun, 26 Apr 2015 16:17:30 +0800 Subject: [PATCH 1546/1564] Fixed cocos2d/cocos2d-js#1703: Fix constants naming issue for ccs.FrameEaseType --- extensions/cocostudio/action/CCActionFrame.js | 130 +++++++++--------- extensions/cocostudio/timeline/Frame.js | 2 +- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/extensions/cocostudio/action/CCActionFrame.js b/extensions/cocostudio/action/CCActionFrame.js index 755cbbd578..2571031de9 100644 --- a/extensions/cocostudio/action/CCActionFrame.js +++ b/extensions/cocostudio/action/CCActionFrame.js @@ -67,49 +67,49 @@ ccs.FRAME_TYPE_MAX = 5; * @type {Object} */ ccs.FrameEaseType = { - Custom : -1, + CUSTOM : -1, - Linear : 0, + LINEAR : 0, - Sine_EaseIn : 1, - Sine_EaseOut : 2, - Sine_EaseInOut : 3, + SINE_EASEIN : 1, + SINE_EASEOUT : 2, + SINE_EASEINOUT : 3, - Quad_EaseIn : 4, - Quad_EaseOut : 5, - Quad_EaseInOut : 6, + QUAD_EASEIN : 4, + QUAD_EASEOUT : 5, + QUAD_EASEINOUT : 6, - Cubic_EaseIn : 7, - Cubic_EaseOut : 8, - Cubic_EaseInOut : 9, + CUBIC_EASEIN : 7, + CUBIC_EASEOUT : 8, + CUBIC_EASEINOUT : 9, - Quart_EaseIn : 10, - Quart_EaseOut : 11, - Quart_EaseInOut : 12, + QUART_EASEIN : 10, + QUART_EASEOUT : 11, + QUART_EASEINOUT : 12, - Quint_EaseIn : 13, - Quint_EaseOut : 14, - Quint_EaseInOut : 15, + QUINT_EASEIN : 13, + QUINT_EASEOUT : 14, + QUINT_EASEINOUT : 15, - Expo_EaseIn : 16, - Expo_EaseOut : 17, - Expo_EaseInOut : 18, + EXPO_EASEIN : 16, + EXPO_EASEOUT : 17, + EXPO_EASEINOUT : 18, - Circ_EaseIn : 19, - Circ_EaseOut : 20, - Circ_EaseInOut : 21, + CIRC_EASEIN : 19, + CIRC_EASEOUT : 20, + CIRC_EASEINOUT : 21, - Elastic_EaseIn : 22, - Elastic_EaseOut : 23, - Elastic_EaseInOut : 24, + ELASTIC_EASEIN : 22, + ELASTIC_EASEOUT : 23, + ELASTIC_EASEINOUT : 24, - Back_EaseIn : 25, - Back_EaseOut : 26, - Back_EaseInOut : 27, + BACK_EASEIN : 25, + BACK_EASEOUT : 26, + BACK_EASEINOUT : 27, - Bounce_EaseIn : 28, - Bounce_EaseOut : 29, - Bounce_EaseInOut : 30, + BOUNCE_EASEIN : 28, + BOUNCE_EASEOUT : 29, + BOUNCE_EASEINOUT : 30, TWEEN_EASING_MAX: 1000 }; @@ -137,7 +137,7 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ */ ctor: function () { this.frameType = 0; - this.easingType = ccs.FrameEaseType.Linear; + this.easingType = ccs.FrameEaseType.LINEAR; this.frameIndex = 0; this.time = 0; }, @@ -161,99 +161,99 @@ ccs.ActionFrame = ccs.Class.extend(/** @lends ccs.ActionFrame# */{ var resultAction; switch (this.easingType) { - case ccs.FrameEaseType.Custom: + case ccs.FrameEaseType.CUSTOM: break; - case ccs.FrameEaseType.Linear: + case ccs.FrameEaseType.LINEAR: resultAction = action; break; - case ccs.FrameEaseType.Sine_EaseIn: + case ccs.FrameEaseType.SINE_EASEIN: resultAction = action.easing(cc.easeSineIn()); break; - case ccs.FrameEaseType.Sine_EaseOut: + case ccs.FrameEaseType.SINE_EASEOUT: resultAction = action.easing(cc.easeSineOut()); break; - case ccs.FrameEaseType.Sine_EaseInOut: + case ccs.FrameEaseType.SINE_EASEINOUT: resultAction = action.easing(cc.easeSineInOut()); break; - case ccs.FrameEaseType.Quad_EaseIn: + case ccs.FrameEaseType.QUAD_EASEIN: resultAction = action.easing(cc.easeQuadraticActionIn()); break; - case ccs.FrameEaseType.Quad_EaseOut: + case ccs.FrameEaseType.QUAD_EASEOUT: resultAction = action.easing(cc.easeQuadraticActionOut()); break; - case ccs.FrameEaseType.Quad_EaseInOut: + case ccs.FrameEaseType.QUAD_EASEINOUT: resultAction = action.easing(cc.easeQuadraticActionInOut()); break; - case ccs.FrameEaseType.Cubic_EaseIn: + case ccs.FrameEaseType.CUBIC_EASEIN: resultAction = action.easing(cc.easeCubicActionIn()); break; - case ccs.FrameEaseType.Cubic_EaseOut: + case ccs.FrameEaseType.CUBIC_EASEOUT: resultAction = action.easing(cc.easeCubicActionOut()); break; - case ccs.FrameEaseType.Cubic_EaseInOut: + case ccs.FrameEaseType.CUBIC_EASEINOUT: resultAction = action.easing(cc.easeCubicActionInOut()); break; - case ccs.FrameEaseType.Quart_EaseIn: + case ccs.FrameEaseType.QUART_EASEIN: resultAction = action.easing(cc.easeQuarticActionIn()); break; - case ccs.FrameEaseType.Quart_EaseOut: + case ccs.FrameEaseType.QUART_EASEOUT: resultAction = action.easing(cc.easeQuarticActionOut()); break; - case ccs.FrameEaseType.Quart_EaseInOut: + case ccs.FrameEaseType.QUART_EASEINOUT: resultAction = action.easing(cc.easeQuarticActionInOut()); break; - case ccs.FrameEaseType.Quint_EaseIn: + case ccs.FrameEaseType.QUINT_EASEIN: resultAction = action.easing(cc.easeQuinticActionIn()); break; - case ccs.FrameEaseType.Quint_EaseOut: + case ccs.FrameEaseType.QUINT_EASEOUT: resultAction = action.easing(cc.easeQuinticActionOut()); break; - case ccs.FrameEaseType.Quint_EaseInOut: + case ccs.FrameEaseType.QUINT_EASEINOUT: resultAction = action.easing(cc.easeQuinticActionInOut()); break; - case ccs.FrameEaseType.Expo_EaseIn: + case ccs.FrameEaseType.EXPO_EASEIN: resultAction = action.easing(cc.easeExponentialIn()); break; - case ccs.FrameEaseType.Expo_EaseOut: + case ccs.FrameEaseType.EXPO_EASEOUT: resultAction = action.easing(cc.easeExponentialOut()); break; - case ccs.FrameEaseType.Expo_EaseInOut: + case ccs.FrameEaseType.EXPO_EASEINOUT: resultAction = action.easing(cc.easeExponentialInOut()); break; - case ccs.FrameEaseType.Circ_EaseIn: + case ccs.FrameEaseType.CIRC_EASEIN: resultAction = action.easing(cc.easeCircleActionIn()); break; - case ccs.FrameEaseType.Circ_EaseOut: + case ccs.FrameEaseType.CIRC_EASEOUT: resultAction = action.easing(cc.easeCircleActionOut()); break; - case ccs.FrameEaseType.Circ_EaseInOut: + case ccs.FrameEaseType.CIRC_EASEINOUT: resultAction = action.easing(cc.easeCircleActionInOut()); break; - case ccs.FrameEaseType.Elastic_EaseIn: + case ccs.FrameEaseType.ELASTIC_EASEIN: resultAction = action.easing(cc.easeElasticIn()); break; - case ccs.FrameEaseType.Elastic_EaseOut: + case ccs.FrameEaseType.ELASTIC_EASEOUT: resultAction = action.easing(cc.easeElasticOut()); break; - case ccs.FrameEaseType.Elastic_EaseInOut: + case ccs.FrameEaseType.ELASTIC_EASEINOUT: resultAction = action.easing(cc.easeElasticInOut()); break; - case ccs.FrameEaseType.Back_EaseIn: + case ccs.FrameEaseType.BACK_EASEIN: resultAction = action.easing(cc.easeBackIn()); break; - case ccs.FrameEaseType.Back_EaseOut: + case ccs.FrameEaseType.BACK_EASEOUT: resultAction = action.easing(cc.easeBackOut()); break; - case ccs.FrameEaseType.Back_EaseInOut: + case ccs.FrameEaseType.BACK_EASEINOUT: resultAction = action.easing(cc.easeBackInOut()); break; - case ccs.FrameEaseType.Bounce_EaseIn: + case ccs.FrameEaseType.BOUNCE_EASEIN: resultAction = action.easing(cc.easeBounceIn()); break; - case ccs.FrameEaseType.Bounce_EaseOut: + case ccs.FrameEaseType.BOUNCE_EASEOUT: resultAction = action.easing(cc.easeBounceOut()); break; - case ccs.FrameEaseType.Bounce_EaseInOut: + case ccs.FrameEaseType.BOUNCE_EASEINOUT: resultAction = action.easing(cc.easeBounceInOut()); break; } diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index bcc155c22b..f165d5686f 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -138,7 +138,7 @@ ccs.Frame = ccs.Class.extend({ apply: function(percent){ if(!this._tween) return; - if(this._tweenType !== ccs.FrameEaseType.TWEEN_EASING_MAX && this._tweenType !== ccs.FrameEaseType.Linear) + if(this._tweenType !== ccs.FrameEaseType.TWEEN_EASING_MAX && this._tweenType !== ccs.FrameEaseType.LINEAR) percent = this.tweenPercent(percent); this._onApply(percent); }, From 50e470d1746db184396c7663e2930d84c52b624f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 26 Apr 2015 16:28:53 +0800 Subject: [PATCH 1547/1564] Fixed cocos2d/cocos2d-js#1650: cc.LoaderScene.preload API inconsistency --- cocos2d/core/scenes/CCLoaderScene.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/scenes/CCLoaderScene.js b/cocos2d/core/scenes/CCLoaderScene.js index 51417498c3..562b71ff30 100644 --- a/cocos2d/core/scenes/CCLoaderScene.js +++ b/cocos2d/core/scenes/CCLoaderScene.js @@ -34,6 +34,8 @@ cc.LoaderScene = cc.Scene.extend({ _interval : null, _label : null, _className:"LoaderScene", + cb: null, + target: null, /** * Contructor of cc.LoaderScene * @returns {boolean} @@ -101,12 +103,14 @@ cc.LoaderScene = cc.Scene.extend({ * init with resources * @param {Array} resources * @param {Function|String} cb + * @param {Object} target */ - initWithResources: function (resources, cb) { + initWithResources: function (resources, cb, target) { if(cc.isString(resources)) resources = [resources]; this.resources = resources || []; this.cb = cb; + this.target = target; }, _startLoading: function () { @@ -120,7 +124,7 @@ cc.LoaderScene = cc.Scene.extend({ self._label.setString("Loading... " + percent + "%"); }, function () { if (self.cb) - self.cb(); + self.cb.call(self.target); }); } }); @@ -129,6 +133,7 @@ cc.LoaderScene = cc.Scene.extend({ *

    when all the resource are downloaded it will invoke call function

    * @param resources * @param cb + * @param target * @returns {cc.LoaderScene|*} * @example * //Example @@ -136,13 +141,13 @@ cc.LoaderScene = cc.Scene.extend({ cc.director.runScene(new HelloWorldScene()); }, this); */ -cc.LoaderScene.preload = function(resources, cb){ +cc.LoaderScene.preload = function(resources, cb, target){ var _cc = cc; if(!_cc.loaderScene) { _cc.loaderScene = new cc.LoaderScene(); _cc.loaderScene.init(); } - _cc.loaderScene.initWithResources(resources, cb); + _cc.loaderScene.initWithResources(resources, cb, target); cc.director.runScene(_cc.loaderScene); return _cc.loaderScene; From 71ddb495a1df838c8d747b7488d2a00c51cc74eb Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 09:41:37 +0800 Subject: [PATCH 1548/1564] Fixed a bug that is Frame InnerActionFrame error --- .../cocostudio/timeline/ActionTimeline.js | 8 ++++++++ extensions/cocostudio/timeline/Frame.js | 18 +++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index 3712238878..1b1348c2c4 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -484,6 +484,14 @@ ccs.ActionTimeline = cc.Action.extend({ */ removeAnimationInfo: function(name){ delete this._animationInfos[name]; + }, + + IsAnimationInfoExists: function(name){ + return this._animationInfos[name]; + }, + + getAnimationInfo: function(name){ + return this._animationInfos[name]; } }); diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index bcc155c22b..818ef18bb9 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -976,12 +976,13 @@ ccs.InnerActionFrame = ccs.Frame.extend({ _endFrameIndex:0, _singleFrameIndex: 0, - _enterWithName: false, + _enterWithName: null, _animationName: "", ctor: function(){ ccs.Frame.prototype.ctor.call(this); + this._enterWithName = false; this._innerActionType = ccs.InnerActionType.LoopAction; this._startFrameIndex = 0; }, @@ -991,10 +992,10 @@ ccs.InnerActionFrame = ccs.Frame.extend({ * @param {ccs.Frame} nextFrame */ onEnter: function(nextFrame){ - if(!this._node) - return; + if(!this._node) return; var innerActiontimeline = this._node.getActionByTag(this._node.getTag()); - if (/*ccs.InnerActionType.SingleFrame*/"SingleFrame" === this._innerActionType){ + if(!innerActiontimeline) return; + if (ccs.InnerActionType.SingleFrame === this._innerActionType){ innerActiontimeline.gotoFrameAndPause(this._singleFrameIndex); return; } @@ -1028,11 +1029,7 @@ ccs.InnerActionFrame = ccs.Frame.extend({ }, setAnimationName: function(animationName){ - if(!this._enterWithName){ - cc.log(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!"); - }else{ - this._animationName = animationName; - } + this._animationName = animationName; }, setSingleFrameIndex: function(frameIndex){ @@ -1060,6 +1057,9 @@ ccs.InnerActionFrame = ccs.Frame.extend({ var frame = new ccs.InnerActionFrame(); frame.setInnerActionType(this._innerActionType); frame.setStartFrameIndex(this._startFrameIndex); + frame.setEnterWithName(this._enterWithName); + frame.setAnimationName(this._animationName); + frame.setSingleFrameIndex(this._singleFrameIndex); frame._cloneProperty(this); From 35a6b0fee0151baa9b83f5cb0371ebf805227f40 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 09:55:07 +0800 Subject: [PATCH 1549/1564] Fixed a bug that is Frame InnerActionFrame error --- extensions/cocostudio/timeline/ActionTimeline.js | 2 +- extensions/cocostudio/timeline/Frame.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/timeline/ActionTimeline.js b/extensions/cocostudio/timeline/ActionTimeline.js index 1b1348c2c4..75aecd0415 100644 --- a/extensions/cocostudio/timeline/ActionTimeline.js +++ b/extensions/cocostudio/timeline/ActionTimeline.js @@ -486,7 +486,7 @@ ccs.ActionTimeline = cc.Action.extend({ delete this._animationInfos[name]; }, - IsAnimationInfoExists: function(name){ + isAnimationInfoExists: function(name){ return this._animationInfos[name]; }, diff --git a/extensions/cocostudio/timeline/Frame.js b/extensions/cocostudio/timeline/Frame.js index 818ef18bb9..58910b7ffd 100644 --- a/extensions/cocostudio/timeline/Frame.js +++ b/extensions/cocostudio/timeline/Frame.js @@ -1006,7 +1006,7 @@ ccs.InnerActionFrame = ccs.Frame.extend({ if (this._animationName === "-- ALL --"){ innerStart = 0; innerEnd = innerActiontimeline.getDuration(); - } else if(innerActiontimeline.IsAnimationInfoExists(this._animationName)) { + } else if(innerActiontimeline.isAnimationInfoExists(this._animationName)) { var info = innerActiontimeline.getAnimationInfo(this._animationName); innerStart = info.startIndex; innerEnd = info.endIndex; From 6a88df5b875f51b6e729a7879ffbe3319e8c541c Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 10:28:41 +0800 Subject: [PATCH 1550/1564] To fix a bug on the slider within the scaleX may be not 1 --- extensions/ccui/uiwidgets/UISlider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ccui/uiwidgets/UISlider.js b/extensions/ccui/uiwidgets/UISlider.js index 3eed1abe54..5b1f8f38b4 100644 --- a/extensions/ccui/uiwidgets/UISlider.js +++ b/extensions/ccui/uiwidgets/UISlider.js @@ -458,7 +458,7 @@ ccui.Slider = ccui.Widget.extend(/** @lends ccui.Slider# */{ var spriteRenderer = this._progressBarRenderer; var rect = spriteRenderer.getTextureRect(); spriteRenderer.setTextureRect( - cc.rect(rect.x, rect.y, dis, rect.height), + cc.rect(rect.x, rect.y, dis / spriteRenderer._scaleX, rect.height), spriteRenderer.isTextureRectRotated() ); } From 0bef4ccbafd479c8d5c755989cc2a8186b2a6b4d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 11:07:24 +0800 Subject: [PATCH 1551/1564] To fix a problem about the UIButton after enable scale9sprite --- extensions/ccui/uiwidgets/UIButton.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/ccui/uiwidgets/UIButton.js b/extensions/ccui/uiwidgets/UIButton.js index 3ee086fbbc..3d6a21103d 100644 --- a/extensions/ccui/uiwidgets/UIButton.js +++ b/extensions/ccui/uiwidgets/UIButton.js @@ -437,11 +437,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var x = capInsets.x, y = capInsets.y; var width = capInsets.width, height = capInsets.height; - if (this._normalTextureSize.width < width) { + if (this._pressedTextureSize.width < width) { x = 0; width = 0; } - if (this._normalTextureSize.height < height) { + if (this._pressedTextureSize.height < height) { y = 0; height = 0; } @@ -474,11 +474,11 @@ ccui.Button = ccui.Widget.extend(/** @lends ccui.Button# */{ var x = capInsets.x, y = capInsets.y; var width = capInsets.width, height = capInsets.height; - if (this._normalTextureSize.width < width) { + if (this._disabledTextureSize.width < width) { x = 0; width = 0; } - if (this._normalTextureSize.height < height) { + if (this._disabledTextureSize.height < height) { y = 0; height = 0; } From 5481fb10064378da18d6c8c0470b9d8489d01e8d Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 11:54:39 +0800 Subject: [PATCH 1552/1564] Fixed a bug that is UIText set ContentSize --- .../cocostudio/loader/parsers/timelineParser-2.x.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 954b036d89..ee015658ee 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -238,14 +238,14 @@ // WIDGET // //////////// - parser.widgetAttributes = function (widget, json) { + parser.widgetAttributes = function (widget, json, enableContent) { widget.setCascadeColorEnabled(true); widget.setCascadeOpacityEnabled(true); widget.setUnifySizeEnabled(false); //widget.setLayoutComponentEnabled(true); widget.ignoreContentAdaptWithSize(false); - setContentSize(widget, json["Size"]); + !enableContent && setContentSize(widget, json["Size"]); var name = json["Name"]; if (name) @@ -476,8 +476,6 @@ var widget = new ccui.Text(); - this.widgetAttributes(widget, json); - var touchScaleEnabled = json["TouchScaleChangeAble"]; if(touchScaleEnabled != null) widget.setTouchScaleChangeEnabled(touchScaleEnabled); @@ -554,8 +552,7 @@ widget.setUnifySizeEnabled(false); - if(widget.isIgnoreContentAdaptWithSize()) - setContentSize(widget, json["Size"]); + this.widgetAttributes(widget, json, widget.isIgnoreContentAdaptWithSize()); return widget; From d0f21d3508fa038e8a7db236d201ec105d2d5097 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 14:14:16 +0800 Subject: [PATCH 1553/1564] Repair the button can't set the Outline --- .../cocostudio/loader/parsers/timelineParser-2.x.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index ee015658ee..e1dec00399 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -625,8 +625,12 @@ json["ShadowBlurRadius"] || 0 ); } - if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableOutline) - label.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); + if(label && json["OutlineEnabled"] && json["OutlineColor"]){ + if(label.enableOutline) + label.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); + if(label.enableStroke) + label.enableStroke(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); + } this.widgetAttributes(widget, json); From 481fd2b08e075f2a7c4de70eb25acc83d43a5253 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 27 Apr 2015 14:17:31 +0800 Subject: [PATCH 1554/1564] [v3.6] Update engine version --- cocos2d/core/platform/CCConfig.js | 2 +- tools/build.xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js index ead1460436..d22450daad 100644 --- a/cocos2d/core/platform/CCConfig.js +++ b/cocos2d/core/platform/CCConfig.js @@ -31,7 +31,7 @@ * @type {String} * @name cc.ENGINE_VERSION */ -window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.6 Beta"; +window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.6"; /** *

    diff --git a/tools/build.xml b/tools/build.xml index 8c05c73ab9..326af567d2 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -5,8 +5,8 @@ classpath="./compiler/compiler.jar"/> - + debug="false" output="./../lib/cocos2d-js-v3.6-min.js"> + @@ -298,8 +298,8 @@ - + debug="false" output="./../lib/cocos2d-js-v3.6-core-min.js"> + From 7617f3195b1a1d47cbdbebcad750c6858becb9c5 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 14:33:11 +0800 Subject: [PATCH 1555/1564] Repair the button can't set the Outline --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index e1dec00399..fa9809dd5d 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -625,12 +625,8 @@ json["ShadowBlurRadius"] || 0 ); } - if(label && json["OutlineEnabled"] && json["OutlineColor"]){ - if(label.enableOutline) - label.enableOutline(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); - if(label.enableStroke) + if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableStroke) label.enableStroke(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); - } this.widgetAttributes(widget, json); From ba26ad0f4260e505155ce012ea5916d5d8155177 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 14:34:24 +0800 Subject: [PATCH 1556/1564] Repair the button can't set the Outline --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index fa9809dd5d..12e26f4c5b 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -626,7 +626,7 @@ ); } if(label && json["OutlineEnabled"] && json["OutlineColor"] && label.enableStroke) - label.enableStroke(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); + label.enableStroke(getColor(json["OutlineColor"]), getParam(json["OutlineSize"], 1)); this.widgetAttributes(widget, json); From 5ca3365697034421cd662ed07869d330343c8721 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Mon, 27 Apr 2015 16:26:02 +0800 Subject: [PATCH 1557/1564] Fix the background color set wrong --- .../loader/parsers/timelineParser-2.x.js | 81 ++++++------------- 1 file changed, 26 insertions(+), 55 deletions(-) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index 12e26f4c5b..e6c2a4bbe8 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -401,6 +401,23 @@ layoutComponent.setRightMargin(rightMargin); }; + var setLayoutBackground = function(layout, single, first, end){ + if( layout.getBackGroundColorType() === 2 ){ + first = first || {}; + end = end || {}; + layout.setBackGroundColor(getColor(first), getColor(end)); + }else{ + single = single || {}; + layout.setBackGroundColor(getColor(single)); + } + }; + + var setLayoutBackgroundVector = function(widget, vector){ + var x = vector["ScaleX"] || 0; + var y = vector["ScaleY"] || 0; + widget.setBackGroundColorVector(cc.p(x, y)); + }; + /** * Layout * @param json @@ -453,16 +470,8 @@ } - var firstColor = json["FirstColor"]; - var endColor = json["EndColor"]; - if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) - widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); - else - widget.setBackGroundColor(getColor(json["SingleColor"])); - - var colorVector = json["ColorVector"]; - if(colorVector != null) - widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); + setLayoutBackground(widget, json["SingleColor"], json["FirstColor"], json["EndColor"]); + setLayoutBackgroundVector(widget, json["ColorVector"]); return widget; }; @@ -725,24 +734,8 @@ setContentSize(widget, json["Size"]); } - var firstColor = json["FirstColor"]; - var endColor = json["EndColor"]; - if(firstColor && endColor){ - if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) - widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); - else - widget.setBackGroundColor(getColor(firstColor)); - }else{ - widget.setBackGroundColor(getColor(json["SingleColor"])); - } - - - var colorVector = json["ColorVector"]; - if(colorVector){ - var colorVectorX = getParam(colorVector["ScaleX"], 1); - var colorVectorY = getParam(colorVector["ScaleY"], 1); - widget.setBackGroundColorVector(cc.p(colorVectorX, colorVectorY)); - } + setLayoutBackground(widget, json["SingleColor"], json["FirstColor"], json["EndColor"]); + setLayoutBackgroundVector(widget, json["ColorVector"]); var innerNodeSize = json["InnerNodeSize"]; var innerSize = cc.size( @@ -904,21 +897,10 @@ var colorType = getParam(json["ComboBoxIndex"], 0); widget.setBackGroundColorType(colorType); - var bgColorOpacity = json["BackColorAlpha"]; - var firstColor = json["FirstColor"]; - var endColor = json["EndColor"]; - if(firstColor && endColor){ - if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) - widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); - else - widget.setBackGroundColor(getColor(firstColor)); - }else{ - widget.setBackGroundColor(getColor(json["SingleColor"])); - } + setLayoutBackground(widget, json["SingleColor"], json["FirstColor"], json["EndColor"]); + setLayoutBackgroundVector(widget, json["ColorVector"]); - var colorVector = json["ColorVector"]; - if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) - widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); + var bgColorOpacity = json["BackColorAlpha"]; if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); @@ -1000,20 +982,9 @@ if(innerSize != null) widget.setInnerContainerSize(cc.size(innerSize["Widget"]||0, innerSize["Height"]||0)); - var firstColor = json["FirstColor"]; - var endColor = json["EndColor"]; - if(firstColor && endColor){ - if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) - widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); - else - widget.setBackGroundColor(getColor(firstColor)); - }else{ - widget.setBackGroundColor(getColor(json["SingleColor"])); - } + setLayoutBackground(widget, json["SingleColor"], json["FirstColor"], json["EndColor"]); + setLayoutBackgroundVector(widget, json["ColorVector"]); - var colorVector = json["ColorVector"]; - if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null) - widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); From 661c62987fc230c7ad8d06de106ac8ea0e9c241a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 28 Apr 2015 14:10:03 +0800 Subject: [PATCH 1558/1564] Fix removeAllChildren issue that it doesn't notify the renderer to update --- cocos2d/core/base-nodes/CCNode.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 977d3f9339..81f5dc51dc 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1386,20 +1386,11 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ for (var i = 0; i < __children.length; i++) { var node = __children[i]; if (node) { - // IMPORTANT: - // -1st do onExit - // -2nd cleanup - if (this._running) { - node.onExitTransitionDidStart(); - node.onExit(); - } - if (cleanup) - node.cleanup(); - // set parent nil at the end - node.parent = null; + this._detachChild(node, cleanup); } } this._children.length = 0; + cc.renderer.childrenOrderDirty = true; } }, From 0bb25cec0a8be634b3056a17e622bf7cabe5d813 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 28 Apr 2015 14:43:01 +0800 Subject: [PATCH 1559/1564] Repair the infinite loop --- cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js index 1dac4df749..dd08d36c00 100644 --- a/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js @@ -332,7 +332,6 @@ if(this._colorized){ this._node._texture = this._originalTexture; this._colorized = false; - this._updateColor(); } }; From 61c4e3dc4e850b9859b9e8d7bbad8520e0e7e786 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 28 Apr 2015 15:44:48 +0800 Subject: [PATCH 1560/1564] Fix array delete issue in removeAllChildren --- cocos2d/core/base-nodes/CCNode.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/base-nodes/CCNode.js b/cocos2d/core/base-nodes/CCNode.js index 81f5dc51dc..5184a42b9c 100644 --- a/cocos2d/core/base-nodes/CCNode.js +++ b/cocos2d/core/base-nodes/CCNode.js @@ -1386,7 +1386,18 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{ for (var i = 0; i < __children.length; i++) { var node = __children[i]; if (node) { - this._detachChild(node, cleanup); + if (this._running) { + node.onExitTransitionDidStart(); + node.onExit(); + } + + // If you don't do cleanup, the node's actions will not get removed and the + if (cleanup) + node.cleanup(); + + // set parent nil at the end + node.parent = null; + node._renderCmd.detachFromParent(); } } this._children.length = 0; From 37a963bd21aa182cd3932d2acd7d47fc21dfa8cc Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 28 Apr 2015 18:34:07 +0800 Subject: [PATCH 1561/1564] [Cocos2d-JS] v3.6 changelog --- CHANGELOG.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ec7c62b829..50b7feade2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,25 @@ ChangeLog: +Cocos2d-JS v3.6 @ April 29 2015 + +* Added GAF web runtime to the web engine, the native support will be merged in future version. +* Synchronised Cocos2d-x v3.6. + +* Bug fixes: + 1. Fixed a bug of Cocos Studio parser that it doesn't parse correctly the outline of text widget and button widget. + 2. Fixed a bug of Cocos Studio parser that it doesn't support inner action correctly. + 3. Fixed a bug of Cocos Studio parser that `ccui.Text`'s content size is set incorrectly. + 4. Fixed a bug of Cocos Studio parser that `ccui.Layout`'s background color is set incorrectly. + 5. Fixed a bug of `cc.Node`'s `removeAllChildren` that it doesn't notify the renderer to update. + 6. Fixed a bug of audio system that the resume of music may start from the beginning. + 7. Fixed a bug that sprite's `setTexture` fails to update its content size. + 8. Fixed a bug that Scale9Sprite's children doesn't get transformed recursively. + 9. Fixed constant naming issue of `ccs.FrameEaseType`. + 10. Fixed `cc.LoaderScene.preload` API inconsistency between web engine and native engine. + 11. Fixed a bug that `ccui.Slider` doesn't act correctly when it's scaled. + 12. Fixed a bug that `ccui.Button` renders incorrectly when scale9sprite option enabled. + 13. Fixed circular invocation issue in `cc.Sprite`'s canvas render command. + Cocos2d-JS v3.6 Beta @ April 22 2015 * Improved TMX transform to support RotationX and RotationY. From a81d0011732b35daf9b9372c43cbbdc1ab857079 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 29 Apr 2015 17:40:37 +0800 Subject: [PATCH 1562/1564] The positionType error of particleSystem - timelineParser-2.x --- extensions/cocostudio/loader/parsers/timelineParser-2.x.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js index e6c2a4bbe8..e5644ccada 100644 --- a/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +++ b/extensions/cocostudio/loader/parsers/timelineParser-2.x.js @@ -218,6 +218,7 @@ cc.log("%s need to be preloaded", path); node = new cc.ParticleSystem(path); self.generalAttributes(node, json); + node.setPositionType(cc.ParticleSystem.TYPE_GROUPED); !cc.sys.isNative && node.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); var blendData = json["BlendFunc"]; From 3c599bfc445a143c8eeeeac0b9070cd184f78520 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 29 Apr 2015 22:56:09 +0800 Subject: [PATCH 1563/1564] Fix parser's setAnimationName issue while the property is undefined --- extensions/cocostudio/loader/parsers/action-2.x.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/cocostudio/loader/parsers/action-2.x.js b/extensions/cocostudio/loader/parsers/action-2.x.js index dfe69dc51f..3329106e25 100644 --- a/extensions/cocostudio/loader/parsers/action-2.x.js +++ b/extensions/cocostudio/loader/parsers/action-2.x.js @@ -237,7 +237,8 @@ frame.setSingleFrameIndex(singleFrameIndex); frame.setEnterWithName(true); - frame.setAnimationName(currentAnimationFrame); + if (currentAnimationFrame) + frame.setAnimationName(currentAnimationFrame); return frame; } From 705d8d1bb913fd702887ecb37d9e2704c1ebc3c7 Mon Sep 17 00:00:00 2001 From: Shun Lin Date: Mon, 25 Feb 2019 18:45:26 +0800 Subject: [PATCH 1564/1564] Update the latest status of Cocos2d-html5 Update the latest status of Cocos2d-html5 --- README.mdown | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/README.mdown b/README.mdown index c41b79bc2c..20868869a1 100644 --- a/README.mdown +++ b/README.mdown @@ -5,6 +5,8 @@ Cocos2d-html5 It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X. It currently supports canvas and WebGL renderer. +#### Cocos2d-html5 has evolved to Cocos Creator, new generation of Cocos game engine with a full featured editor and content creation friendly workflow. The latest repository is maintained in here [Engine of Cocos Creator][9]. + Cross Platform ------------- * Popular browsers: Chrome 14+, Safari 5.0+, IE9+, Firefox 3.5+. @@ -14,27 +16,7 @@ Cross Platform Documentation ------------------ * Website: [www.cocos2d-x.org][3] - * API References: [http://www.cocos2d-x.org/wiki/Reference] [4] - - -Installing from [bower][8] (version >=3.4) ------------------- - -```shell -$ bower install cocos2d-html5 -``` - -Running the tests (version <3) ------------------- - -```shell -$ git clone git://github.com/cocos2d/cocos2d-html5.git -$ cd cocos2d-html5 -$ git submodule update --init -$ python -m SimpleHTTPServer -``` -... and then open a browser and go to `http://localhost:8000/tests` - + * Cocos Creator download: [Cocos Creator][4] Contact us ------------------ @@ -45,8 +27,9 @@ Contact us [1]: http://www.cocos2d-x.org "Cocos2d-html5" [2]: http://www.cocos2d-x.org "Cocos2d-X" [3]: http://www.cocos2d-x.org "www.cocos2d-x.org" -[4]: http://www.cocos2d-x.org/wiki/Reference "API References" +[4]: http://www.cocos2d-x.org/download [5]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org" [6]: http://www.twitter.com/cocos2dhtml5 "http://www.twitter.com/cocos2dhtml5" [7]: http://t.sina.com.cn/cocos2dhtml5 "http://t.sina.com.cn/cocos2dhtml5" -[8]: http://bower.io "http://bower.io" \ No newline at end of file +[8]: http://bower.io "http://bower.io" +[9]: https://github.com/cocos-creator/engine